@anvaka/vue-llm 0.1.2 → 0.2.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.
@@ -0,0 +1,172 @@
1
+ import { BaseProvider as y } from "./BaseProvider.js";
2
+ import { AnthropicProvider as w } from "./AnthropicProvider.js";
3
+ const g = [
4
+ "us.anthropic.claude-opus-4-7",
5
+ "us.anthropic.claude-sonnet-4-6",
6
+ "us.anthropic.claude-haiku-4-5-20251001-v1:0",
7
+ "us.anthropic.claude-opus-4-6-v1",
8
+ "us.anthropic.claude-opus-4-5-20251101-v1:0",
9
+ "us.anthropic.claude-sonnet-4-5-20250929-v1:0",
10
+ "us.anthropic.claude-opus-4-1-20250805-v1:0"
11
+ ];
12
+ class R extends w {
13
+ prepareRequest(r, n) {
14
+ const t = super.prepareRequest(r, n);
15
+ return delete t.stream, t.anthropic_version = "bedrock-2023-05-31", t;
16
+ }
17
+ buildHeaders() {
18
+ return y.prototype.buildHeaders.call(this);
19
+ }
20
+ getAuthHeaderName() {
21
+ return "Authorization";
22
+ }
23
+ getAuthHeaderValue() {
24
+ return `Bearer ${this.config.apiKey}`;
25
+ }
26
+ requiresAuth() {
27
+ return !!this.config.apiKey;
28
+ }
29
+ async makeRequest(r, n, t) {
30
+ const e = r.model, d = { ...r };
31
+ delete d.model;
32
+ const c = `${this.config.baseUrl}/model/${encodeURIComponent(e)}/invoke`, u = n ? { signal: n } : new AbortController();
33
+ n || (t = t || this.generateRequestId(), this.activeRequests.set(t, u));
34
+ try {
35
+ const s = await fetch(c, {
36
+ method: "POST",
37
+ headers: this.buildHeaders(),
38
+ body: JSON.stringify(d),
39
+ signal: u.signal || n
40
+ });
41
+ if (!s.ok) {
42
+ const l = await s.text();
43
+ throw new Error(`Bedrock API Error (${s.status}): ${l}`);
44
+ }
45
+ return s.json();
46
+ } finally {
47
+ !n && t && this.activeRequests.delete(t);
48
+ }
49
+ }
50
+ async makeStreamingRequest(r, n) {
51
+ const t = r.model, e = { ...r };
52
+ delete e.model;
53
+ const d = `${this.config.baseUrl}/model/${encodeURIComponent(t)}/invoke-with-response-stream`, c = await fetch(d, {
54
+ method: "POST",
55
+ headers: this.buildHeaders(),
56
+ body: JSON.stringify(e),
57
+ signal: n
58
+ });
59
+ if (!c.ok) {
60
+ const i = await c.text();
61
+ throw new Error(`Bedrock API Error (${c.status}): ${i}`);
62
+ }
63
+ const u = c.body.getReader(), s = new v(), l = new TextEncoder(), f = new ReadableStream({
64
+ async pull(i) {
65
+ try {
66
+ const { done: a, value: m } = await u.read();
67
+ if (a) {
68
+ i.close();
69
+ return;
70
+ }
71
+ const p = s.feed(m);
72
+ for (const h of p) {
73
+ if (h.kind === "error") {
74
+ i.error(new Error(h.message));
75
+ return;
76
+ }
77
+ i.enqueue(l.encode(`data: ${JSON.stringify(h.payload)}
78
+ `));
79
+ }
80
+ } catch (a) {
81
+ i.error(a);
82
+ }
83
+ },
84
+ cancel(i) {
85
+ try {
86
+ u.cancel(i);
87
+ } catch {
88
+ }
89
+ }
90
+ });
91
+ return new Response(f, { status: 200, headers: { "Content-Type": "text/event-stream" } });
92
+ }
93
+ // Bedrock control plane needs SigV4; Bearer auth can't list models.
94
+ // Return the hardcoded list so the dropdown still populates.
95
+ async discoverModels() {
96
+ return g.slice();
97
+ }
98
+ getModelsEndpoint() {
99
+ return null;
100
+ }
101
+ parseModelsResponse() {
102
+ return g.slice();
103
+ }
104
+ }
105
+ class v {
106
+ constructor() {
107
+ this.buf = new Uint8Array(0), this.textDecoder = new TextDecoder();
108
+ }
109
+ feed(r) {
110
+ if (r && r.length) {
111
+ const t = new Uint8Array(this.buf.length + r.length);
112
+ t.set(this.buf, 0), t.set(r, this.buf.length), this.buf = t;
113
+ }
114
+ const n = [];
115
+ for (; this.buf.length >= 12; ) {
116
+ const t = new DataView(this.buf.buffer, this.buf.byteOffset, this.buf.byteLength), e = t.getUint32(0, !1), d = t.getUint32(4, !1);
117
+ if (e < 16 || e > 16 * 1024 * 1024)
118
+ throw new Error(`Bedrock event stream: invalid frame length ${e}`);
119
+ if (this.buf.length < e) break;
120
+ const c = 12, u = c + d, s = u, l = e - 4, f = k(this.buf.subarray(c, u)), i = this.textDecoder.decode(this.buf.subarray(s, l));
121
+ this.buf = this.buf.subarray(e);
122
+ let a;
123
+ try {
124
+ a = JSON.parse(i);
125
+ } catch {
126
+ a = null;
127
+ }
128
+ const m = f[":message-type"], p = f[":exception-type"];
129
+ if (m === "exception" || p) {
130
+ const h = p || f[":event-type"] || "BedrockStreamException", b = (a == null ? void 0 : a.message) || i || "unknown error";
131
+ n.push({ kind: "error", message: `${h}: ${b}` });
132
+ continue;
133
+ }
134
+ if (a && typeof a.bytes == "string")
135
+ try {
136
+ const h = x(a.bytes), b = JSON.parse(h);
137
+ n.push({ kind: "event", payload: b });
138
+ } catch (h) {
139
+ n.push({ kind: "error", message: `Bedrock event-stream decode failed: ${h.message}` });
140
+ }
141
+ }
142
+ return n;
143
+ }
144
+ }
145
+ function k(o) {
146
+ const r = {}, n = new DataView(o.buffer, o.byteOffset, o.byteLength), t = new TextDecoder();
147
+ let e = 0;
148
+ for (; e < o.length; ) {
149
+ const d = o[e];
150
+ if (e += 1, e + d > o.length) break;
151
+ const c = t.decode(o.subarray(e, e + d));
152
+ if (e += d, e >= o.length) break;
153
+ const u = o[e];
154
+ if (e += 1, u === 7) {
155
+ if (e + 2 > o.length) break;
156
+ const s = n.getUint16(e, !1);
157
+ if (e += 2, e + s > o.length) break;
158
+ r[c] = t.decode(o.subarray(e, e + s)), e += s;
159
+ } else
160
+ break;
161
+ }
162
+ return r;
163
+ }
164
+ function x(o) {
165
+ const r = atob(o), n = new Uint8Array(r.length);
166
+ for (let t = 0; t < r.length; t++) n[t] = r.charCodeAt(t);
167
+ return new TextDecoder().decode(n);
168
+ }
169
+ export {
170
+ g as BEDROCK_CLAUDE_MODELS,
171
+ R as BedrockProvider
172
+ };
@@ -1,15 +1,15 @@
1
- var u = (n) => {
2
- throw TypeError(n);
1
+ var f = (i) => {
2
+ throw TypeError(i);
3
3
  };
4
- var f = (n, r, t) => r.has(n) || u("Cannot " + t);
5
- var h = (n, r, t) => r.has(n) ? u("Cannot add the same private member more than once") : r instanceof WeakSet ? r.add(n) : r.set(n, t);
6
- var g = (n, r, t) => (f(n, r, "access private method"), t);
7
- import { BaseProvider as m } from "./BaseProvider.js";
8
- var c, d;
9
- class k extends m {
4
+ var _ = (i, r, t) => r.has(i) || f("Cannot " + t);
5
+ var h = (i, r, t) => r.has(i) ? f("Cannot add the same private member more than once") : r instanceof WeakSet ? r.add(i) : r.set(i, t);
6
+ var p = (i, r, t) => (_(i, r, "access private method"), t);
7
+ import { BaseProvider as y } from "./BaseProvider.js";
8
+ var u, m;
9
+ class v extends y {
10
10
  constructor() {
11
11
  super(...arguments);
12
- h(this, c);
12
+ h(this, u);
13
13
  }
14
14
  async detectCapabilities() {
15
15
  if (!this.config.model) return;
@@ -17,38 +17,46 @@ class k extends m {
17
17
  (t.startsWith("o1") || t.startsWith("o2") || t.startsWith("o3") || t.startsWith("o-") || t.includes("gpt-5") || t === "gpt5") && this.capabilities.add("thinking"), t.includes("gpt-4") && t.includes("vision") && this.capabilities.add("vision"), (t.includes("gpt-4") || t.includes("gpt-3.5") || t.includes("gpt-5")) && this.capabilities.add("tools");
18
18
  }
19
19
  prepareRequest(t, e) {
20
- const i = e.model || this.config.model || "gpt-3.5-turbo", s = {
21
- model: i,
20
+ const s = e.model || this.config.model || "gpt-3.5-turbo", n = {
21
+ model: s,
22
22
  messages: this.processMessages(t, e),
23
23
  temperature: e.temperature ?? 0.7,
24
24
  stream: e.stream || !1
25
25
  };
26
- return g(this, c, d).call(this, i) ? (s.max_completion_tokens = e.maxTokens || 1e3, s.temperature = 1) : s.max_tokens = e.maxTokens || 1e3, e.enableThinking && this.capabilities.has("thinking") && (s.reasoning_effort = e.reasoningEffort || "medium"), e.tools && this.capabilities.has("tools") && (s.tools = e.tools), s;
26
+ return p(this, u, m).call(this, s) ? (n.max_completion_tokens = e.maxTokens || 1e3, n.temperature = 1) : n.max_tokens = e.maxTokens || 1e3, e.enableThinking && this.capabilities.has("thinking") && (n.reasoning_effort = e.reasoningEffort || "medium"), e.tools && this.capabilities.has("tools") && (n.tools = e.tools), n;
27
27
  }
28
28
  processMessages(t, e) {
29
- return e.images && this.capabilities.has("vision") ? this.addImagesToMessages(t, e.images) : t;
29
+ const s = b(t);
30
+ return e.images && this.capabilities.has("vision") ? this.addImagesToMessages(s, e.images) : s;
30
31
  }
31
32
  addImagesToMessages(t, e) {
32
- const i = t[t.length - 1];
33
- if (i && i.role === "user") {
34
- const s = [{ type: "text", text: i.content }];
33
+ const s = t[t.length - 1];
34
+ if (s && s.role === "user") {
35
+ const n = [{ type: "text", text: s.content }];
35
36
  e.forEach((a) => {
36
- s.push({
37
+ n.push({
37
38
  type: "image_url",
38
39
  image_url: { url: typeof a == "string" ? a : a.url }
39
40
  });
40
- }), i.content = s;
41
+ }), s.content = n;
41
42
  }
42
43
  return t;
43
44
  }
44
45
  processResponse(t) {
45
- var i, s, a, o, l;
46
- const e = {
47
- content: ((a = (s = (i = t.choices) == null ? void 0 : i[0]) == null ? void 0 : s.message) == null ? void 0 : a.content) || "",
46
+ var n, a, l, o;
47
+ const e = (a = (n = t.choices) == null ? void 0 : n[0]) == null ? void 0 : a.message, s = {
48
+ content: (e == null ? void 0 : e.content) || "",
48
49
  usage: t.usage || null,
49
- finishReason: ((l = (o = t.choices) == null ? void 0 : o[0]) == null ? void 0 : l.finish_reason) || null
50
+ finishReason: ((o = (l = t.choices) == null ? void 0 : l[0]) == null ? void 0 : o.finish_reason) || null
50
51
  };
51
- return t.reasoning && (e.thinking = t.reasoning), e;
52
+ return t.reasoning && (s.thinking = t.reasoning), Array.isArray(e == null ? void 0 : e.tool_calls) && (s.toolCalls = e.tool_calls.map((c) => {
53
+ var g, d;
54
+ return {
55
+ id: c.id,
56
+ name: (g = c.function) == null ? void 0 : g.name,
57
+ args: k((d = c.function) == null ? void 0 : d.arguments)
58
+ };
59
+ })), s;
52
60
  }
53
61
  parseStreamingLine(t) {
54
62
  if (!t.startsWith("data: ")) return null;
@@ -61,15 +69,31 @@ class k extends m {
61
69
  }
62
70
  }
63
71
  extractStreamingContent(t) {
64
- var i, s, a, o;
72
+ var n, a, l;
65
73
  if (t.done) return { done: !0 };
66
- const e = (s = (i = t.choices) == null ? void 0 : i[0]) == null ? void 0 : s.delta;
74
+ const e = (n = t.choices) == null ? void 0 : n[0], s = e == null ? void 0 : e.delta;
75
+ if (s && Array.isArray(s.tool_calls) && s.tool_calls.length) {
76
+ const o = s.tool_calls[0];
77
+ return {
78
+ content: s.content || "",
79
+ thinking: s.reasoning || "",
80
+ done: !1,
81
+ usage: t.usage || null,
82
+ finishReason: (e == null ? void 0 : e.finish_reason) || null,
83
+ toolCallDelta: {
84
+ index: o.index ?? 0,
85
+ id: o.id || void 0,
86
+ name: ((a = o.function) == null ? void 0 : a.name) || void 0,
87
+ argsTextDelta: ((l = o.function) == null ? void 0 : l.arguments) || ""
88
+ }
89
+ };
90
+ }
67
91
  return {
68
- content: (e == null ? void 0 : e.content) || "",
69
- thinking: (e == null ? void 0 : e.reasoning) || "",
92
+ content: (s == null ? void 0 : s.content) || "",
93
+ thinking: (s == null ? void 0 : s.reasoning) || "",
70
94
  done: !1,
71
95
  usage: t.usage || null,
72
- finishReason: ((o = (a = t.choices) == null ? void 0 : a[0]) == null ? void 0 : o.finish_reason) || null
96
+ finishReason: (e == null ? void 0 : e.finish_reason) || null
73
97
  };
74
98
  }
75
99
  getApiPath() {
@@ -83,16 +107,39 @@ class k extends m {
83
107
  }
84
108
  parseModelsResponse(t) {
85
109
  var e;
86
- return ((e = t.data) == null ? void 0 : e.filter((i) => {
87
- const s = i.id.toLowerCase();
88
- return s.includes("gpt") || s.includes("chat");
89
- }).map((i) => i.id).sort()) || [];
110
+ return ((e = t.data) == null ? void 0 : e.filter((s) => {
111
+ const n = s.id.toLowerCase();
112
+ return n.includes("gpt") || n.includes("chat");
113
+ }).map((s) => s.id).sort()) || [];
90
114
  }
91
115
  }
92
- c = new WeakSet(), d = function(t) {
116
+ u = new WeakSet(), m = function(t) {
93
117
  const e = (t || "").toLowerCase();
94
118
  return e.startsWith("o1") || e.startsWith("o2") || e.startsWith("o3") || e.startsWith("o-") || e.includes("gpt-5") || e === "gpt5" || e.includes("reasoning") || this.capabilities.has("thinking");
95
119
  };
120
+ function k(i) {
121
+ if (!i) return {};
122
+ try {
123
+ return JSON.parse(i);
124
+ } catch {
125
+ return { __parseError: !0, raw: i };
126
+ }
127
+ }
128
+ function b(i) {
129
+ return i.map((r) => r.role === "assistant" && Array.isArray(r.tool_calls) && r.tool_calls.length ? {
130
+ role: "assistant",
131
+ content: r.content ?? null,
132
+ tool_calls: r.tool_calls.map((t) => ({
133
+ id: t.id,
134
+ type: "function",
135
+ function: {
136
+ name: t.name,
137
+ arguments: typeof t.args == "string" ? t.args : JSON.stringify(t.args || {})
138
+ }
139
+ }))
140
+ } : r);
141
+ }
96
142
  export {
97
- k as OpenAIProvider
143
+ v as OpenAIProvider,
144
+ b as convertMessagesToOpenAI
98
145
  };
@@ -1,37 +1,46 @@
1
- import { BaseProvider as d } from "./BaseProvider.js";
2
- class f extends d {
1
+ import { BaseProvider as h } from "./BaseProvider.js";
2
+ import { convertMessagesToOpenAI as f } from "./OpenAIProvider.js";
3
+ class y extends h {
3
4
  async detectCapabilities() {
4
5
  this.config.model && (this.capabilities.add("tools"), (this.config.model.includes("o1") || this.config.model.includes("thinking") || this.config.model.includes("reasoning")) && this.capabilities.add("thinking"), (this.config.model.includes("vision") || this.config.model.includes("gpt-4") || this.config.model.includes("claude") || this.config.model.includes("gemini")) && this.capabilities.add("vision"));
5
6
  }
6
- prepareRequest(t, e) {
7
- const i = {
7
+ prepareRequest(n, e) {
8
+ const t = {
8
9
  model: e.model || this.config.model,
9
- messages: this.processMessages(t, e),
10
+ messages: this.processMessages(n, e),
10
11
  temperature: e.temperature ?? 0.7,
11
12
  max_tokens: e.maxTokens || 1e3,
12
13
  stream: e.stream || !1
13
14
  };
14
- return e.enableThinking && this.capabilities.has("thinking") && (i.reasoning = e.reasoning !== !1, e.reasoningEffort && (i.reasoning_effort = e.reasoningEffort)), e.tools && this.capabilities.has("tools") && (i.tools = e.tools, e.tool_choice && (i.tool_choice = e.tool_choice)), i;
15
+ return e.enableThinking && this.capabilities.has("thinking") && (t.reasoning = e.reasoning !== !1, e.reasoningEffort && (t.reasoning_effort = e.reasoningEffort)), e.tools && this.capabilities.has("tools") && (t.tools = e.tools, e.tool_choice && (t.tool_choice = e.tool_choice)), t;
15
16
  }
16
- processMessages(t, e) {
17
+ processMessages(n, e) {
18
+ const t = f(n);
17
19
  return e.images && this.capabilities.has("vision") ? this.addImagesToMessages(t, e.images) : t;
18
20
  }
19
- addImagesToMessages(t, e) {
20
- const i = t[t.length - 1];
21
- return i && i.role === "user" && (i.content = [{ type: "text", text: i.content }, ...e.map((s) => ({ type: "image_url", image_url: { url: s } }))]), t;
21
+ addImagesToMessages(n, e) {
22
+ const t = n[n.length - 1];
23
+ return t && t.role === "user" && (t.content = [{ type: "text", text: t.content }, ...e.map((i) => ({ type: "image_url", image_url: { url: i } }))]), n;
22
24
  }
23
25
  buildHeaders() {
24
- const t = { "Content-Type": "application/json" };
25
- return this.requiresAuth() && (t[this.getAuthHeaderName()] = this.getAuthHeaderValue()), this.config.siteUrl && (t["HTTP-Referer"] = this.config.siteUrl), this.config.siteName && (t["X-Title"] = this.config.siteName), t;
26
+ const n = { "Content-Type": "application/json" };
27
+ return this.requiresAuth() && (n[this.getAuthHeaderName()] = this.getAuthHeaderValue()), this.config.siteUrl && (n["HTTP-Referer"] = this.config.siteUrl), this.config.siteName && (n["X-Title"] = this.config.siteName), n;
26
28
  }
27
- processResponse(t) {
28
- var i, s, n, r, a, c, l, h;
29
- const e = { content: ((n = (s = (i = t.choices) == null ? void 0 : i[0]) == null ? void 0 : s.message) == null ? void 0 : n.content) || "", usage: t.usage || null, finishReason: u((a = (r = t.choices) == null ? void 0 : r[0]) == null ? void 0 : a.finish_reason) };
30
- return (h = (l = (c = t.choices) == null ? void 0 : c[0]) == null ? void 0 : l.message) != null && h.reasoning && (e.thinking = t.choices[0].message.reasoning), e;
29
+ processResponse(n) {
30
+ var i, s, o, a;
31
+ const e = (s = (i = n.choices) == null ? void 0 : i[0]) == null ? void 0 : s.message, t = { content: (e == null ? void 0 : e.content) || "", usage: n.usage || null, finishReason: c((a = (o = n.choices) == null ? void 0 : o[0]) == null ? void 0 : a.finish_reason) };
32
+ return e != null && e.reasoning && (t.thinking = e.reasoning), Array.isArray(e == null ? void 0 : e.tool_calls) && (t.toolCalls = e.tool_calls.map((l) => {
33
+ var u, d;
34
+ return {
35
+ id: l.id,
36
+ name: (u = l.function) == null ? void 0 : u.name,
37
+ args: g((d = l.function) == null ? void 0 : d.arguments)
38
+ };
39
+ })), t;
31
40
  }
32
- parseStreamingLine(t) {
33
- if (!t.startsWith("data: ")) return null;
34
- const e = t.slice(6).trim();
41
+ parseStreamingLine(n) {
42
+ if (!n.startsWith("data: ")) return null;
43
+ const e = n.slice(6).trim();
35
44
  if (e === "[DONE]") return { done: !0 };
36
45
  try {
37
46
  return JSON.parse(e);
@@ -39,11 +48,27 @@ class f extends d {
39
48
  return null;
40
49
  }
41
50
  }
42
- extractStreamingContent(t) {
43
- var i, s, n, r;
44
- if (t.done) return { done: !0 };
45
- const e = (s = (i = t.choices) == null ? void 0 : i[0]) == null ? void 0 : s.delta;
46
- return { content: (e == null ? void 0 : e.content) || "", thinking: (e == null ? void 0 : e.reasoning) || "", done: !1, usage: t.usage || null, finishReason: u((r = (n = t.choices) == null ? void 0 : n[0]) == null ? void 0 : r.finish_reason) };
51
+ extractStreamingContent(n) {
52
+ var i, s, o;
53
+ if (n.done) return { done: !0 };
54
+ const e = (i = n.choices) == null ? void 0 : i[0], t = e == null ? void 0 : e.delta;
55
+ if (t && Array.isArray(t.tool_calls) && t.tool_calls.length) {
56
+ const a = t.tool_calls[0];
57
+ return {
58
+ content: t.content || "",
59
+ thinking: t.reasoning || "",
60
+ done: !1,
61
+ usage: n.usage || null,
62
+ finishReason: c(e == null ? void 0 : e.finish_reason),
63
+ toolCallDelta: {
64
+ index: a.index ?? 0,
65
+ id: a.id || void 0,
66
+ name: ((s = a.function) == null ? void 0 : s.name) || void 0,
67
+ argsTextDelta: ((o = a.function) == null ? void 0 : o.arguments) || ""
68
+ }
69
+ };
70
+ }
71
+ return { content: (t == null ? void 0 : t.content) || "", thinking: (t == null ? void 0 : t.reasoning) || "", done: !1, usage: n.usage || null, finishReason: c(e == null ? void 0 : e.finish_reason) };
47
72
  }
48
73
  getApiPath() {
49
74
  return "/v1/chat/completions";
@@ -54,28 +79,36 @@ class f extends d {
54
79
  getModelsEndpoint() {
55
80
  return `${this.config.baseUrl}/v1/models`;
56
81
  }
57
- parseModelsResponse(t) {
58
- return Array.isArray(t.data) ? t.data.filter((e) => {
59
- var s;
60
- const i = (s = e.architecture) == null ? void 0 : s.modality;
61
- return i && (i.includes("text->text") || i.includes("text+image->text"));
82
+ parseModelsResponse(n) {
83
+ return Array.isArray(n.data) ? n.data.filter((e) => {
84
+ var i;
85
+ const t = (i = e.architecture) == null ? void 0 : i.modality;
86
+ return t && (t.includes("text->text") || t.includes("text+image->text"));
62
87
  }).map((e) => e.id).sort() : [];
63
88
  }
64
- async discoverModelsWithMetadata(t = 15e3) {
89
+ async discoverModelsWithMetadata(n = 15e3) {
65
90
  try {
66
- const e = this.buildHeaders(), i = new AbortController(), s = setTimeout(() => i.abort(), t), n = await fetch(this.getModelsEndpoint(), { method: "GET", headers: e, signal: i.signal });
67
- if (clearTimeout(s), !n.ok) throw new Error(`Failed to fetch models: ${n.status} ${n.statusText}`);
68
- return (await n.json()).data || [];
91
+ const e = this.buildHeaders(), t = new AbortController(), i = setTimeout(() => t.abort(), n), s = await fetch(this.getModelsEndpoint(), { method: "GET", headers: e, signal: t.signal });
92
+ if (clearTimeout(i), !s.ok) throw new Error(`Failed to fetch models: ${s.status} ${s.statusText}`);
93
+ return (await s.json()).data || [];
69
94
  } catch (e) {
70
95
  throw e.name === "AbortError" ? new Error("Model discovery timeout - please check your connection") : e;
71
96
  }
72
97
  }
73
98
  }
74
- function u(o) {
75
- if (!o) return null;
76
- const t = String(o).toLowerCase();
77
- return t === "length" || t === "max_tokens" ? "length" : t;
99
+ function c(r) {
100
+ if (!r) return null;
101
+ const n = String(r).toLowerCase();
102
+ return n === "length" || n === "max_tokens" ? "length" : n;
103
+ }
104
+ function g(r) {
105
+ if (!r) return {};
106
+ try {
107
+ return JSON.parse(r);
108
+ } catch {
109
+ return { __parseError: !0, raw: r };
110
+ }
78
111
  }
79
112
  export {
80
- f as OpenRouterProvider
113
+ y as OpenRouterProvider
81
114
  };
@@ -1,14 +1,16 @@
1
1
  import { OpenAIProvider as i } from "./OpenAIProvider.js";
2
- import { AnthropicProvider as n } from "./AnthropicProvider.js";
3
- import { GrokProvider as s } from "./GrokProvider.js";
4
- import { GeminiProvider as m } from "./GeminiProvider.js";
5
- import { OllamaProvider as p } from "./OllamaProvider.js";
6
- import { LlamaServerProvider as u } from "./LlamaServerProvider.js";
7
- import { OpenRouterProvider as l } from "./OpenRouterProvider.js";
8
- import { CustomProvider as A } from "./CustomProvider.js";
2
+ import { AnthropicProvider as s } from "./AnthropicProvider.js";
3
+ import { BedrockProvider as n } from "./BedrockProvider.js";
4
+ import { GrokProvider as m } from "./GrokProvider.js";
5
+ import { GeminiProvider as p } from "./GeminiProvider.js";
6
+ import { OllamaProvider as u } from "./OllamaProvider.js";
7
+ import { LlamaServerProvider as l } from "./LlamaServerProvider.js";
8
+ import { OpenRouterProvider as A } from "./OpenRouterProvider.js";
9
+ import { CustomProvider as O } from "./CustomProvider.js";
9
10
  const e = {
10
11
  OPENAI: "openai",
11
12
  ANTHROPIC: "anthropic",
13
+ BEDROCK: "bedrock",
12
14
  GROK: "grok",
13
15
  GEMINI: "gemini",
14
16
  OLLAMA: "ollama",
@@ -18,6 +20,7 @@ const e = {
18
20
  }, L = {
19
21
  [e.OPENAI]: { name: "OpenAI", baseUrl: "https://api.openai.com", requiresApiKey: !0 },
20
22
  [e.ANTHROPIC]: { name: "Anthropic", baseUrl: "https://api.anthropic.com", requiresApiKey: !0 },
23
+ [e.BEDROCK]: { name: "AWS Bedrock", baseUrl: "https://bedrock-runtime.us-east-1.amazonaws.com", requiresApiKey: !0 },
21
24
  [e.GROK]: { name: "Grok", baseUrl: "https://api.x.ai", requiresApiKey: !0 },
22
25
  [e.GEMINI]: { name: "Google Gemini", baseUrl: "https://generativelanguage.googleapis.com", requiresApiKey: !0 },
23
26
  [e.OLLAMA]: { name: "Ollama (Native)", baseUrl: "http://localhost:11434", requiresApiKey: !1 },
@@ -25,30 +28,32 @@ const e = {
25
28
  [e.OPENROUTER]: { name: "OpenRouter", baseUrl: "https://openrouter.ai/api", requiresApiKey: !0 },
26
29
  [e.CUSTOM]: { name: "Custom OpenAI Compatible", baseUrl: "", requiresApiKey: !1 }
27
30
  };
28
- function O(t, r) {
31
+ function c(t, r) {
29
32
  switch (t) {
30
33
  case e.OPENAI:
31
34
  return new i(r);
32
35
  case e.ANTHROPIC:
36
+ return new s(r);
37
+ case e.BEDROCK:
33
38
  return new n(r);
34
39
  case e.GROK:
35
- return new s(r);
36
- case e.GEMINI:
37
40
  return new m(r);
38
- case e.OLLAMA:
41
+ case e.GEMINI:
39
42
  return new p(r);
40
- case e.LLAMA_SERVER:
43
+ case e.OLLAMA:
41
44
  return new u(r);
42
- case e.OPENROUTER:
45
+ case e.LLAMA_SERVER:
43
46
  return new l(r);
44
- case e.CUSTOM:
47
+ case e.OPENROUTER:
45
48
  return new A(r);
49
+ case e.CUSTOM:
50
+ return new O(r);
46
51
  default:
47
52
  throw new Error(`Unknown provider type: ${t}`);
48
53
  }
49
54
  }
50
55
  const a = /* @__PURE__ */ new Map();
51
- function U(t, r) {
56
+ function K(t, r) {
52
57
  if (typeof t != "string" || !r)
53
58
  throw new Error("registerProvider requires a type string and a class reference");
54
59
  a.set(t, r);
@@ -58,12 +63,12 @@ function N(t, r) {
58
63
  const o = a.get(t);
59
64
  return new o(r);
60
65
  }
61
- return O(t, r);
66
+ return c(t, r);
62
67
  }
63
68
  export {
64
69
  L as DEFAULT_CONFIGS,
65
70
  e as PROVIDERS,
66
- O as createProvider,
71
+ c as createProvider,
67
72
  N as createProviderFlexible,
68
- U as registerProvider
73
+ K as registerProvider
69
74
  };
@@ -1,12 +1,17 @@
1
1
  import { BaseProvider as o } from "./BaseProvider.js";
2
2
  import { OpenAIProvider as t } from "./OpenAIProvider.js";
3
- import { DEFAULT_CONFIGS as d, PROVIDERS as v, createProvider as p, createProviderFlexible as x, registerProvider as a } from "./factory.js";
3
+ import { AnthropicProvider as P } from "./AnthropicProvider.js";
4
+ import { BEDROCK_CLAUDE_MODELS as v, BedrockProvider as x } from "./BedrockProvider.js";
5
+ import { DEFAULT_CONFIGS as m, PROVIDERS as D, createProvider as E, createProviderFlexible as O, registerProvider as c } from "./factory.js";
4
6
  export {
7
+ P as AnthropicProvider,
8
+ v as BEDROCK_CLAUDE_MODELS,
5
9
  o as BaseProvider,
6
- d as DEFAULT_CONFIGS,
10
+ x as BedrockProvider,
11
+ m as DEFAULT_CONFIGS,
7
12
  t as OpenAIProvider,
8
- v as PROVIDERS,
9
- p as createProvider,
10
- x as createProviderFlexible,
11
- a as registerProvider
13
+ D as PROVIDERS,
14
+ E as createProvider,
15
+ O as createProviderFlexible,
16
+ c as registerProvider
12
17
  };