@absolutejs/ai 0.0.48 → 0.0.50

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.
Files changed (44) hide show
  1. package/README.md +122 -21
  2. package/dist/ai/client/index.js +19 -22
  3. package/dist/ai/client/index.js.map +7 -8
  4. package/dist/ai/index.js +703 -63
  5. package/dist/ai/index.js.map +20 -18
  6. package/dist/ai/providers/anthropic.js +6 -2
  7. package/dist/ai/providers/anthropic.js.map +4 -4
  8. package/dist/ai/providers/gemini.js +33 -3
  9. package/dist/ai/providers/gemini.js.map +4 -4
  10. package/dist/ai/providers/ollama.js +3 -2
  11. package/dist/ai/providers/ollama.js.map +3 -3
  12. package/dist/ai/providers/openai.js +130 -35
  13. package/dist/ai/providers/openai.js.map +4 -4
  14. package/dist/ai/providers/openaiCompatible.js +130 -35
  15. package/dist/ai/providers/openaiCompatible.js.map +4 -4
  16. package/dist/ai/providers/openaiResponses.js +48 -18
  17. package/dist/ai/providers/openaiResponses.js.map +4 -4
  18. package/dist/ai/providers/openrouter.js +1757 -0
  19. package/dist/ai/providers/openrouter.js.map +17 -0
  20. package/dist/angular/ai/index.js +31 -3
  21. package/dist/angular/ai/index.js.map +6 -6
  22. package/dist/react/ai/index.js +18 -3
  23. package/dist/react/ai/index.js.map +6 -6
  24. package/dist/src/ai/client/actions.d.ts +22 -0
  25. package/dist/src/ai/client/createAIStream.d.ts +1 -0
  26. package/dist/src/ai/client/index.d.ts +0 -1
  27. package/dist/src/ai/conversationManager.d.ts +1 -0
  28. package/dist/src/ai/generateAI.d.ts +4 -1
  29. package/dist/src/ai/index.d.ts +2 -0
  30. package/dist/src/ai/providers/openai.d.ts +7 -3
  31. package/dist/src/ai/providers/openaiResponses.d.ts +9 -4
  32. package/dist/src/ai/providers/openrouter.d.ts +113 -0
  33. package/dist/src/ai/providers/openrouterClient.d.ts +147 -0
  34. package/dist/src/angular/ai/ai-stream.service.d.ts +1 -0
  35. package/dist/src/react/ai/useAIStream.d.ts +1 -0
  36. package/dist/src/svelte/ai/createAIStream.d.ts +1 -0
  37. package/dist/src/vue/ai/useAIStream.d.ts +2 -0
  38. package/dist/svelte/ai/index.js +18 -3
  39. package/dist/svelte/ai/index.js.map +6 -6
  40. package/dist/types/ai.d.ts +74 -7
  41. package/dist/vue/ai/index.js +18 -3
  42. package/dist/vue/ai/index.js.map +6 -6
  43. package/package.json +9 -2
  44. package/dist/src/ai/client/composer.d.ts +0 -15
@@ -18,7 +18,9 @@ export declare const serverMessageToAction: (message: AIServerMessage) => {
18
18
  sources?: undefined;
19
19
  usage?: undefined;
20
20
  position?: undefined;
21
+ attachments?: undefined;
21
22
  fromMessageId?: undefined;
23
+ mode?: undefined;
22
24
  newConversationId?: undefined;
23
25
  oldConversationId?: undefined;
24
26
  retrievalStartedAt?: undefined;
@@ -45,7 +47,9 @@ export declare const serverMessageToAction: (message: AIServerMessage) => {
45
47
  sources?: undefined;
46
48
  usage?: undefined;
47
49
  position?: undefined;
50
+ attachments?: undefined;
48
51
  fromMessageId?: undefined;
52
+ mode?: undefined;
49
53
  newConversationId?: undefined;
50
54
  oldConversationId?: undefined;
51
55
  retrievalStartedAt?: undefined;
@@ -72,7 +76,9 @@ export declare const serverMessageToAction: (message: AIServerMessage) => {
72
76
  sources?: undefined;
73
77
  usage?: undefined;
74
78
  position?: undefined;
79
+ attachments?: undefined;
75
80
  fromMessageId?: undefined;
81
+ mode?: undefined;
76
82
  newConversationId?: undefined;
77
83
  oldConversationId?: undefined;
78
84
  retrievalStartedAt?: undefined;
@@ -99,7 +105,9 @@ export declare const serverMessageToAction: (message: AIServerMessage) => {
99
105
  sources?: undefined;
100
106
  usage?: undefined;
101
107
  position?: undefined;
108
+ attachments?: undefined;
102
109
  fromMessageId?: undefined;
110
+ mode?: undefined;
103
111
  newConversationId?: undefined;
104
112
  oldConversationId?: undefined;
105
113
  retrievalStartedAt?: undefined;
@@ -126,7 +134,9 @@ export declare const serverMessageToAction: (message: AIServerMessage) => {
126
134
  isPartial?: undefined;
127
135
  revisedPrompt?: undefined;
128
136
  position?: undefined;
137
+ attachments?: undefined;
129
138
  fromMessageId?: undefined;
139
+ mode?: undefined;
130
140
  newConversationId?: undefined;
131
141
  oldConversationId?: undefined;
132
142
  retrievalStartedAt?: undefined;
@@ -153,7 +163,9 @@ export declare const serverMessageToAction: (message: AIServerMessage) => {
153
163
  model?: undefined;
154
164
  sources?: undefined;
155
165
  usage?: undefined;
166
+ attachments?: undefined;
156
167
  fromMessageId?: undefined;
168
+ mode?: undefined;
157
169
  newConversationId?: undefined;
158
170
  oldConversationId?: undefined;
159
171
  retrievalStartedAt?: undefined;
@@ -180,7 +192,9 @@ export declare const serverMessageToAction: (message: AIServerMessage) => {
180
192
  sources?: undefined;
181
193
  usage?: undefined;
182
194
  position?: undefined;
195
+ attachments?: undefined;
183
196
  fromMessageId?: undefined;
197
+ mode?: undefined;
184
198
  newConversationId?: undefined;
185
199
  oldConversationId?: undefined;
186
200
  retrievalStartedAt?: undefined;
@@ -189,9 +203,11 @@ export declare const serverMessageToAction: (message: AIServerMessage) => {
189
203
  trace?: undefined;
190
204
  message?: undefined;
191
205
  } | {
206
+ attachments: import("..").AIAttachment[] | undefined;
192
207
  content: string;
193
208
  fromMessageId: string;
194
209
  messageId: string;
210
+ mode: "append" | "replace" | undefined;
195
211
  newConversationId: string;
196
212
  oldConversationId: string;
197
213
  type: "branch";
@@ -235,7 +251,9 @@ export declare const serverMessageToAction: (message: AIServerMessage) => {
235
251
  sources?: undefined;
236
252
  usage?: undefined;
237
253
  position?: undefined;
254
+ attachments?: undefined;
238
255
  fromMessageId?: undefined;
256
+ mode?: undefined;
239
257
  newConversationId?: undefined;
240
258
  oldConversationId?: undefined;
241
259
  retrievalDurationMs?: undefined;
@@ -265,7 +283,9 @@ export declare const serverMessageToAction: (message: AIServerMessage) => {
265
283
  model?: undefined;
266
284
  usage?: undefined;
267
285
  position?: undefined;
286
+ attachments?: undefined;
268
287
  fromMessageId?: undefined;
288
+ mode?: undefined;
269
289
  newConversationId?: undefined;
270
290
  oldConversationId?: undefined;
271
291
  message?: undefined;
@@ -289,7 +309,9 @@ export declare const serverMessageToAction: (message: AIServerMessage) => {
289
309
  sources?: undefined;
290
310
  usage?: undefined;
291
311
  position?: undefined;
312
+ attachments?: undefined;
292
313
  fromMessageId?: undefined;
314
+ mode?: undefined;
293
315
  newConversationId?: undefined;
294
316
  oldConversationId?: undefined;
295
317
  retrievalStartedAt?: undefined;
@@ -3,6 +3,7 @@ export declare const createAIStream: (path: string, conversationId?: string) =>
3
3
  branch: (messageId: string, content: string) => void;
4
4
  cancel: () => void;
5
5
  destroy: () => void;
6
+ edit: (messageId: string, content: string) => void;
6
7
  send: (content: string, attachments?: AIAttachment[]) => void;
7
8
  subscribe: (callback: () => void) => () => void;
8
9
  readonly error: string | null;
@@ -2,5 +2,4 @@ export { serverMessageToAction } from "./actions";
2
2
  export { createAIConnection } from "./connection";
3
3
  export { createAIStream } from "./createAIStream";
4
4
  export type { CreateAIStream } from "./createAIStream";
5
- export { isAIComposerSubmitKey, resizeAIComposerTextarea, type AIComposerSizingOptions, } from "./composer";
6
5
  export { ConversationTurnQueueFullError, createConversationTurnQueue, type ConversationTurnQueueItem, type ConversationTurnQueueOptions, type ConversationTurnQueueSnapshot, type ConversationTurnQueueStatus, } from "./turnQueue";
@@ -3,6 +3,7 @@ export declare const createConversationManager: () => {
3
3
  abort: (conversationId: string) => void;
4
4
  appendMessage: (conversationId: string, message: AIMessage) => void;
5
5
  branch: (fromMessageId: string, sourceConversationId: string) => `${string}-${string}-${string}-${string}-${string}` | null;
6
+ edit: (messageId: string, sourceConversationId: string) => `${string}-${string}-${string}-${string}-${string}` | null;
6
7
  get: (conversationId: string) => AIConversation | undefined;
7
8
  getAbortController: (conversationId: string) => AbortController;
8
9
  getHistory: (conversationId: string) => AIProviderMessage[];
@@ -1,4 +1,4 @@
1
- import type { AIProviderConfig, AIProviderMessage, AIProviderResponseFormat, AIProviderToolChoice, AIProviderToolDefinition, AIToolMap, AIUsage, ReasoningConfig } from "../../types/ai";
1
+ import type { AICitationChunk, AIProviderConfig, AIProviderMessage, AIProviderResponseFormat, AIProviderToolChoice, AIProviderToolDefinition, AIResponseMetadata, AIToolMap, AIUsage, ReasoningConfig } from "../../types/ai";
2
2
  export type GenerateAIToolCall = {
3
3
  id: string;
4
4
  name: string;
@@ -13,6 +13,7 @@ export type GenerateAIOptions = {
13
13
  cacheSystemPrompt?: boolean;
14
14
  /** Per-call override of the provider `promptCaching` default. See AIProviderStreamParams. */
15
15
  promptCaching?: boolean;
16
+ providerOptions?: Record<string, unknown>;
16
17
  maxTokens?: number;
17
18
  temperature?: number;
18
19
  topP?: number;
@@ -25,6 +26,8 @@ export type GenerateAIOptions = {
25
26
  signal?: AbortSignal;
26
27
  };
27
28
  export type GenerateAIResult = {
29
+ citations: AICitationChunk[];
30
+ metadata?: AIResponseMetadata;
28
31
  text: string;
29
32
  toolCalls: GenerateAIToolCall[];
30
33
  usage?: AIUsage;
@@ -24,6 +24,8 @@ export { gemini } from "./providers/gemini";
24
24
  export { anthropic } from "./providers/anthropic";
25
25
  export { ollama } from "./providers/ollama";
26
26
  export { openai } from "./providers/openai";
27
+ export { createOpenRouterClient, openrouter, openrouterResponses, openRouterModelMatchesRule, } from "./providers/openrouter";
28
+ export type { OpenRouterClient, OpenRouterClientConfig, OpenRouterConfig, OpenRouterDataCollection, OpenRouterEmbeddingRequest, OpenRouterEmbeddingResponse, OpenRouterHttpRequestOptions, OpenRouterImageRequest, OpenRouterImageResponse, OpenRouterMaxPrice, OpenRouterModel, OpenRouterModelList, OpenRouterPerformancePreference, OpenRouterPlugin, OpenRouterProviderRouting, OpenRouterQuantization, OpenRouterRequestOptions, OpenRouterRerankRequest, OpenRouterRerankResponse, OpenRouterResponseCache, OpenRouterResponsesRequest, OpenRouterServerTool, OpenRouterServiceTier, OpenRouterSpeechRequest, OpenRouterSort, OpenRouterSortStrategy, OpenRouterTranscriptionRequest, OpenRouterVideoRequest, } from "./providers/openrouter";
27
29
  export { createOAuth2ClientCredentialsTokenSource } from "./providers/oauth2TokenSource";
28
30
  export type { OAuth2ClientCredentialsConfig } from "./providers/oauth2TokenSource";
29
31
  export { ProviderError, PROVIDER_STATUS_PAGES, providerStatusPage, } from "./errors/providerError";
@@ -1,8 +1,12 @@
1
- import type { AIProviderConfig } from "../../../types/ai";
2
- type OpenAIConfig = {
1
+ import type { AIProviderConfig, AIProviderStreamParams } from "../../../types/ai";
2
+ export type OpenAIConfig = {
3
3
  apiKey?: string;
4
4
  baseUrl?: string;
5
+ fetch?: typeof globalThis.fetch;
6
+ headers?: HeadersInit | ((params: AIProviderStreamParams) => HeadersInit | Promise<HeadersInit>);
7
+ modelForCapabilities?: (model: string) => string;
8
+ providerName?: string;
5
9
  tokenSource?: () => Promise<string> | string;
10
+ transformRequestBody?: (body: Record<string, unknown>, params: AIProviderStreamParams) => Record<string, unknown>;
6
11
  };
7
12
  export declare const openai: (config: OpenAIConfig) => AIProviderConfig;
8
- export {};
@@ -1,8 +1,13 @@
1
- import type { AIProviderConfig } from "../../../types/ai";
2
- type OpenAIResponsesConfig = {
3
- apiKey: string;
1
+ import type { AIProviderConfig, AIProviderStreamParams } from "../../../types/ai";
2
+ export type OpenAIResponsesConfig = {
3
+ apiKey?: string;
4
4
  baseUrl?: string;
5
+ fetch?: typeof globalThis.fetch;
6
+ headers?: HeadersInit | ((params: AIProviderStreamParams) => HeadersInit | Promise<HeadersInit>);
5
7
  imageModels?: Set<string> | string[];
8
+ modelForCapabilities?: (model: string) => string;
9
+ providerName?: string;
10
+ tokenSource?: () => Promise<string> | string;
11
+ transformRequestBody?: (body: Record<string, unknown>, params: AIProviderStreamParams) => Record<string, unknown>;
6
12
  };
7
13
  export declare const openaiResponses: (config: OpenAIResponsesConfig) => AIProviderConfig;
8
- export {};
@@ -0,0 +1,113 @@
1
+ import type { AIProviderConfig } from "../../../types/ai";
2
+ export type OpenRouterDataCollection = "allow" | "deny";
3
+ export type OpenRouterQuantization = "bf16" | "fp4" | "fp6" | "fp8" | "fp16" | "fp32" | "int4" | "int8" | "unknown";
4
+ export type OpenRouterSortStrategy = "latency" | "price" | "throughput";
5
+ export type OpenRouterSort = OpenRouterSortStrategy | {
6
+ by: OpenRouterSortStrategy;
7
+ partition?: "model" | "none";
8
+ };
9
+ export type OpenRouterPerformancePreference = number | {
10
+ p50?: number;
11
+ p75?: number;
12
+ p90?: number;
13
+ p99?: number;
14
+ };
15
+ export type OpenRouterMaxPrice = {
16
+ /** Maximum completion-token price in USD per million tokens. */
17
+ completion?: number;
18
+ /** Maximum price in USD per image. */
19
+ image?: number;
20
+ /** Maximum prompt-token price in USD per million tokens. */
21
+ prompt?: number;
22
+ /** Maximum price in USD per request. */
23
+ request?: number;
24
+ };
25
+ export type OpenRouterProviderRouting = {
26
+ allowFallbacks?: boolean;
27
+ dataCollection?: OpenRouterDataCollection;
28
+ enforceDistillableText?: boolean;
29
+ ignore?: readonly string[];
30
+ maxPrice?: OpenRouterMaxPrice;
31
+ only?: readonly string[];
32
+ order?: readonly string[];
33
+ preferredMaxLatency?: OpenRouterPerformancePreference;
34
+ preferredMinThroughput?: OpenRouterPerformancePreference;
35
+ quantizations?: readonly OpenRouterQuantization[];
36
+ requireParameters?: boolean;
37
+ sort?: OpenRouterSort;
38
+ zdr?: boolean;
39
+ };
40
+ export type OpenRouterServiceTier = "auto" | "default" | "flex" | "priority" | "fast";
41
+ export type OpenRouterResponseCache = {
42
+ clear?: boolean;
43
+ enabled: boolean;
44
+ /** OpenRouter response-cache TTL in seconds (1-86400). */
45
+ ttlSeconds?: number;
46
+ };
47
+ export type OpenRouterPlugin = {
48
+ id: string;
49
+ [option: string]: unknown;
50
+ };
51
+ export type OpenRouterServerTool = {
52
+ type: "openrouter:web_search" | "openrouter:web_fetch" | "openrouter:datetime" | "openrouter:image_generation" | "openrouter:apply_patch" | "openrouter:shell" | "openrouter:fusion" | "openrouter:advisor" | "openrouter:subagent" | "openrouter:experimental__search_models";
53
+ parameters?: Record<string, unknown>;
54
+ };
55
+ export type OpenRouterRequestOptions = {
56
+ /** Future OpenRouter fields. Security-sensitive routing fields are rejected. */
57
+ extraBody?: Record<string, unknown>;
58
+ fallbackModels?: readonly string[];
59
+ includeReasoning?: boolean;
60
+ maxToolCalls?: number;
61
+ plugins?: readonly OpenRouterPlugin[];
62
+ preset?: string;
63
+ responseCache?: OpenRouterResponseCache;
64
+ routerMetadata?: boolean;
65
+ routing?: OpenRouterProviderRouting;
66
+ serverTools?: readonly OpenRouterServerTool[];
67
+ serviceTier?: OpenRouterServiceTier;
68
+ sessionId?: string;
69
+ stopServerToolsWhen?: readonly Record<string, unknown>[];
70
+ transforms?: readonly string[];
71
+ user?: string;
72
+ verbosity?: "low" | "medium" | "high";
73
+ };
74
+ export type OpenRouterConfig = {
75
+ /**
76
+ * Local model policy. Entries are exact model IDs or namespace wildcards such
77
+ * as `anthropic/*`. Requests outside the list fail before network access.
78
+ */
79
+ allowedModels?: readonly string[];
80
+ /** Preset slugs deliberately approved for use with this provider. */
81
+ allowedPresets?: readonly string[];
82
+ /**
83
+ * Inference-provider policy sent as OpenRouter's `provider.only`. When
84
+ * `routing.only` is also set, every entry must be allowed by this policy.
85
+ */
86
+ allowedProviders?: readonly string[];
87
+ apiKey?: string;
88
+ /** Up to two OpenRouter marketplace categories. */
89
+ appCategories?: readonly string[];
90
+ /** Public application name used for optional OpenRouter attribution. */
91
+ appName?: string;
92
+ /** Public application URL used for optional OpenRouter attribution. */
93
+ appUrl?: string;
94
+ baseUrl?: string;
95
+ fetch?: typeof globalThis.fetch;
96
+ headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
97
+ /** Default OpenRouter request options, overridable per call. */
98
+ requestOptions?: OpenRouterRequestOptions;
99
+ routing?: OpenRouterProviderRouting;
100
+ tokenSource?: () => Promise<string> | string;
101
+ };
102
+ /**
103
+ * OpenRouter provider for the shared AbsoluteJS AI contract.
104
+ *
105
+ * Uses the existing OpenAI-compatible streaming implementation while adding
106
+ * OpenRouter attribution, typed provider routing, local model policy, provider
107
+ * allowlists, cost metadata, and OpenRouter-specific error attribution.
108
+ */
109
+ export declare const openrouter: (config: OpenRouterConfig) => AIProviderConfig;
110
+ /** OpenRouter's stateless OpenAI-compatible Responses API provider skin. */
111
+ export declare const openrouterResponses: (config: OpenRouterConfig) => AIProviderConfig;
112
+ export { createOpenRouterClient, openRouterModelMatchesRule, } from "./openrouterClient";
113
+ export type { OpenRouterClient, OpenRouterClientConfig, OpenRouterEmbeddingRequest, OpenRouterEmbeddingResponse, OpenRouterHttpRequestOptions, OpenRouterImageRequest, OpenRouterImageResponse, OpenRouterModel, OpenRouterModelList, OpenRouterRerankRequest, OpenRouterRerankResponse, OpenRouterResponsesRequest, OpenRouterSpeechRequest, OpenRouterTranscriptionRequest, OpenRouterVideoRequest, } from "./openrouterClient";
@@ -0,0 +1,147 @@
1
+ export type OpenRouterClientConfig = {
2
+ allowedModels?: readonly string[];
3
+ apiKey?: string;
4
+ baseUrl?: string;
5
+ fetch?: typeof globalThis.fetch;
6
+ headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
7
+ tokenSource?: () => Promise<string> | string;
8
+ };
9
+ export type OpenRouterModel = {
10
+ id: string;
11
+ name?: string;
12
+ description?: string;
13
+ context_length?: number;
14
+ architecture?: Record<string, unknown>;
15
+ pricing?: Record<string, string>;
16
+ supported_parameters?: string[] | Record<string, unknown>;
17
+ [field: string]: unknown;
18
+ };
19
+ export type OpenRouterModelList = {
20
+ data: OpenRouterModel[];
21
+ };
22
+ export type OpenRouterEmbeddingRequest = {
23
+ model: string;
24
+ input: string | string[] | number[] | number[][];
25
+ dimensions?: number;
26
+ encoding_format?: "float" | "base64";
27
+ provider?: Record<string, unknown>;
28
+ user?: string;
29
+ };
30
+ export type OpenRouterEmbeddingResponse = {
31
+ data: Array<{
32
+ embedding: number[] | string;
33
+ index: number;
34
+ object: string;
35
+ }>;
36
+ model: string;
37
+ object: string;
38
+ usage?: {
39
+ prompt_tokens: number;
40
+ total_tokens: number;
41
+ cost?: number;
42
+ };
43
+ };
44
+ export type OpenRouterRerankRequest = {
45
+ model: string;
46
+ query: string;
47
+ documents: Array<string | {
48
+ text: string;
49
+ }>;
50
+ top_n?: number;
51
+ return_documents?: boolean;
52
+ };
53
+ export type OpenRouterRerankResponse = {
54
+ id?: string;
55
+ model?: string;
56
+ results: Array<{
57
+ document?: {
58
+ text: string;
59
+ };
60
+ index: number;
61
+ relevance_score: number;
62
+ }>;
63
+ usage?: Record<string, number>;
64
+ };
65
+ export type OpenRouterImageRequest = {
66
+ model: string;
67
+ prompt: string;
68
+ n?: number;
69
+ resolution?: string;
70
+ aspect_ratio?: string;
71
+ size?: string;
72
+ quality?: "auto" | "low" | "medium" | "high";
73
+ output_format?: "png" | "jpeg" | "webp" | "svg";
74
+ background?: "auto" | "transparent" | "opaque";
75
+ output_compression?: number;
76
+ seed?: number;
77
+ input_references?: Array<Record<string, unknown>>;
78
+ provider?: Record<string, unknown>;
79
+ };
80
+ export type OpenRouterImageResponse = {
81
+ created: number;
82
+ data: Array<{
83
+ b64_json: string;
84
+ media_type?: string;
85
+ }>;
86
+ usage?: Record<string, number>;
87
+ };
88
+ export type OpenRouterResponsesRequest = Record<string, unknown> & {
89
+ input: unknown;
90
+ model: string;
91
+ stream?: boolean;
92
+ };
93
+ export type OpenRouterSpeechRequest = Record<string, unknown> & {
94
+ input: string;
95
+ model: string;
96
+ voice: string;
97
+ };
98
+ export type OpenRouterTranscriptionRequest = Record<string, unknown> & {
99
+ model: string;
100
+ };
101
+ export type OpenRouterVideoRequest = Record<string, unknown> & {
102
+ model: string;
103
+ prompt: string;
104
+ };
105
+ export type OpenRouterHttpRequestOptions = Omit<RequestInit, "body" | "headers"> & {
106
+ body?: unknown;
107
+ headers?: HeadersInit;
108
+ query?: Record<string, boolean | number | string | undefined>;
109
+ };
110
+ export type OpenRouterClient = ReturnType<typeof createOpenRouterClient>;
111
+ export declare const openRouterModelMatchesRule: (model: string, rule: string) => boolean;
112
+ export declare const createOpenRouterClient: (config: OpenRouterClientConfig) => {
113
+ cancelBatch: (id: string) => Promise<Record<string, unknown>>;
114
+ createBatch: (body: Record<string, unknown>) => Promise<Record<string, unknown>>;
115
+ createEmbedding: (body: OpenRouterEmbeddingRequest) => Promise<OpenRouterEmbeddingResponse>;
116
+ generateImage: (body: OpenRouterImageRequest) => Promise<OpenRouterImageResponse>;
117
+ generateVideo: (body: OpenRouterVideoRequest) => Promise<Record<string, unknown>>;
118
+ getBatch: (id: string) => Promise<Record<string, unknown>>;
119
+ getCredits: () => Promise<{
120
+ data: Record<string, number>;
121
+ }>;
122
+ getCurrentKey: () => Promise<{
123
+ data: Record<string, unknown>;
124
+ }>;
125
+ getGeneration: (id: string) => Promise<{
126
+ data: Record<string, unknown>;
127
+ }>;
128
+ getModelEndpoints: (model: string) => Promise<Record<string, unknown>>;
129
+ getVideo: (id: string) => Promise<Record<string, unknown>>;
130
+ listImageModels: () => Promise<OpenRouterModelList>;
131
+ listModels: (query?: OpenRouterHttpRequestOptions["query"]) => Promise<OpenRouterModelList>;
132
+ listPresets: (offset?: number, limit?: number) => Promise<{
133
+ data: Record<string, unknown>[];
134
+ total_count: number;
135
+ }>;
136
+ listProviders: () => Promise<{
137
+ data: Record<string, unknown>[];
138
+ }>;
139
+ listRerankModels: () => Promise<OpenRouterModelList>;
140
+ listVideoModels: () => Promise<OpenRouterModelList>;
141
+ request: <T>(path: string, options?: OpenRouterHttpRequestOptions) => Promise<T>;
142
+ requestRaw: (path: string, options?: OpenRouterHttpRequestOptions) => Promise<Response>;
143
+ respond: (body: OpenRouterResponsesRequest) => Promise<Response> | Promise<Record<string, unknown>>;
144
+ rerank: (body: OpenRouterRerankRequest) => Promise<OpenRouterRerankResponse>;
145
+ speak: (body: OpenRouterSpeechRequest) => Promise<Response>;
146
+ transcribe: (body: OpenRouterTranscriptionRequest | FormData) => Promise<Record<string, unknown>>;
147
+ };
@@ -5,6 +5,7 @@ export declare class AIStreamService implements OnDestroy {
5
5
  connect(path: string, conversationId?: string): {
6
6
  branch: (messageId: string, content: string) => void;
7
7
  cancel: () => void;
8
+ edit: (messageId: string, content: string) => void;
8
9
  error: import("@angular/core").Signal<string | null>;
9
10
  isStreaming: import("@angular/core").Signal<boolean>;
10
11
  messages: import("@angular/core").Signal<AIMessage[]>;
@@ -2,6 +2,7 @@ import type { AIAttachment } from "../../../types/ai";
2
2
  export declare const useAIStream: (path?: string, conversationId?: string) => {
3
3
  branch: (messageId: string, content: string) => void;
4
4
  cancel: () => void;
5
+ edit: (messageId: string, content: string) => void;
5
6
  error: string | null;
6
7
  isStreaming: boolean;
7
8
  messages: import("../../ai").AIMessage[];
@@ -3,6 +3,7 @@ export declare const createAIStream: (path: string, conversationId?: string) =>
3
3
  branch: (messageId: string, content: string) => void;
4
4
  cancel: () => void;
5
5
  destroy: () => void;
6
+ edit: (messageId: string, content: string) => void;
6
7
  send: (content: string, attachments?: AIAttachment[]) => void;
7
8
  readonly error: string | null;
8
9
  readonly isStreaming: boolean;
@@ -4,6 +4,7 @@ type AIStreamReturn = {
4
4
  branch: (messageId: string, content: string) => void;
5
5
  cancel: () => void;
6
6
  destroy: () => void;
7
+ edit: (messageId: string, content: string) => void;
7
8
  error: Ref<string | null>;
8
9
  isStreaming: Ref<boolean>;
9
10
  messages: Ref<AIMessage[]>;
@@ -14,6 +15,7 @@ export declare const useAIStream: (path: string, conversationId?: string) => {
14
15
  branch: (messageId: string, content: string) => void;
15
16
  cancel: () => void;
16
17
  destroy: () => void;
18
+ edit: (messageId: string, content: string) => void;
17
19
  error: Ref<string | null, string | null>;
18
20
  isStreaming: Ref<boolean, boolean>;
19
21
  messages: import("vue").ShallowRef<AIMessage[], AIMessage[]>;
@@ -131,9 +131,11 @@ var serverMessageToAction = (message) => {
131
131
  };
132
132
  case "branched":
133
133
  return {
134
+ attachments: message.attachments,
134
135
  content: message.content,
135
136
  fromMessageId: message.fromMessageId,
136
137
  messageId: message.messageId,
138
+ mode: message.mode,
137
139
  newConversationId: message.newConversationId,
138
140
  oldConversationId: message.oldConversationId,
139
141
  type: "branch"
@@ -186,7 +188,7 @@ var isValidAIServerMessage = (data) => {
186
188
  case "turn_started":
187
189
  return "conversationId" in data && typeof data.conversationId === "string" && "messageId" in data && typeof data.messageId === "string";
188
190
  case "branched":
189
- return "content" in data && typeof data.content === "string" && "fromMessageId" in data && typeof data.fromMessageId === "string" && "messageId" in data && typeof data.messageId === "string" && "newConversationId" in data && typeof data.newConversationId === "string" && "oldConversationId" in data && typeof data.oldConversationId === "string";
191
+ return "content" in data && typeof data.content === "string" && "fromMessageId" in data && typeof data.fromMessageId === "string" && "messageId" in data && typeof data.messageId === "string" && "newConversationId" in data && typeof data.newConversationId === "string" && "oldConversationId" in data && typeof data.oldConversationId === "string" && (!("mode" in data) || data.mode === "append" || data.mode === "replace");
190
192
  case "rag_retrieved":
191
193
  return "conversationId" in data && "messageId" in data && "sources" in data && Array.isArray(data.sources);
192
194
  case "error":
@@ -572,13 +574,15 @@ var handleBranch = (state, action) => {
572
574
  if (cutoffIndex < 0) {
573
575
  return;
574
576
  }
575
- const branchedMessages = source.messages.slice(0, cutoffIndex + 1).map((msg) => ({ ...msg, conversationId: action.newConversationId }));
577
+ const cutoffOffset = action.mode === "replace" ? 0 : 1;
578
+ const branchedMessages = source.messages.slice(0, cutoffIndex + cutoffOffset).map((msg) => ({ ...msg, conversationId: action.newConversationId }));
576
579
  const newConversation = {
577
580
  createdAt: Date.now(),
578
581
  id: action.newConversationId,
579
582
  messages: [
580
583
  ...branchedMessages,
581
584
  {
585
+ attachments: action.attachments,
582
586
  content: action.content,
583
587
  conversationId: action.newConversationId,
584
588
  id: action.messageId,
@@ -699,6 +703,16 @@ var createAIStream = (path, conversationId) => {
699
703
  });
700
704
  }
701
705
  };
706
+ const edit = (messageId, content) => {
707
+ if (activeConversationId) {
708
+ connection.send({
709
+ content,
710
+ conversationId: activeConversationId,
711
+ messageId,
712
+ type: "edit"
713
+ });
714
+ }
715
+ };
702
716
  const cancel = () => {
703
717
  if (activeConversationId) {
704
718
  store.dispatch({ type: "cancel" });
@@ -735,6 +749,7 @@ var createAIStream = (path, conversationId) => {
735
749
  branch,
736
750
  cancel,
737
751
  destroy,
752
+ edit,
738
753
  send,
739
754
  get error() {
740
755
  return currentError;
@@ -757,5 +772,5 @@ export {
757
772
  createAIStream
758
773
  };
759
774
 
760
- //# debugId=04909313392ABC9E64756E2164756E21
775
+ //# debugId=1D557221A7953C4F64756E2164756E21
761
776
  //# sourceMappingURL=index.js.map