@absolutejs/ai 0.0.1
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.
- package/README.md +6 -0
- package/dist/ai/client/index.js +682 -0
- package/dist/ai/client/index.js.map +15 -0
- package/dist/ai/index.js +3317 -0
- package/dist/ai/index.js.map +28 -0
- package/dist/ai/providers/anthropic.js +371 -0
- package/dist/ai/providers/anthropic.js.map +10 -0
- package/dist/ai/providers/gemini.js +260 -0
- package/dist/ai/providers/gemini.js.map +10 -0
- package/dist/ai/providers/ollama.js +221 -0
- package/dist/ai/providers/ollama.js.map +10 -0
- package/dist/ai/providers/openai.js +322 -0
- package/dist/ai/providers/openai.js.map +10 -0
- package/dist/ai/providers/openaiCompatible.js +360 -0
- package/dist/ai/providers/openaiCompatible.js.map +11 -0
- package/dist/ai/providers/openaiResponses.js +381 -0
- package/dist/ai/providers/openaiResponses.js.map +10 -0
- package/dist/src/ai/client/actions.d.ts +186 -0
- package/dist/src/ai/client/connection.d.ts +9 -0
- package/dist/src/ai/client/createAIStream.d.ts +12 -0
- package/dist/src/ai/client/index.d.ts +4 -0
- package/dist/src/ai/client/messageStore.d.ts +12 -0
- package/dist/src/ai/conversationManager.d.ts +19 -0
- package/dist/src/ai/htmxRenderers.d.ts +3 -0
- package/dist/src/ai/index.d.ts +19 -0
- package/dist/src/ai/memoryStore.d.ts +2 -0
- package/dist/src/ai/protocol.d.ts +4 -0
- package/dist/src/ai/providers/anthropic.d.ts +3 -0
- package/dist/src/ai/providers/gemini.d.ts +8 -0
- package/dist/src/ai/providers/ollama.d.ts +6 -0
- package/dist/src/ai/providers/openai.d.ts +7 -0
- package/dist/src/ai/providers/openaiCompatible.d.ts +30 -0
- package/dist/src/ai/providers/openaiResponses.d.ts +33 -0
- package/dist/src/ai/streamAI.d.ts +2 -0
- package/dist/src/ai/streamAIToSSE.d.ts +6 -0
- package/dist/src/constants.d.ts +60 -0
- package/dist/src/plugins/aiChat.d.ts +239 -0
- package/dist/types/ai.d.ts +4773 -0
- package/dist/types/anthropic.d.ts +20 -0
- package/dist/types/session.d.ts +16 -0
- package/dist/types/typeGuards.d.ts +3 -0
- package/package.json +59 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { aiChat } from '../plugins/aiChat';
|
|
2
|
+
export { streamAI } from './streamAI';
|
|
3
|
+
export { streamAIToSSE } from './streamAIToSSE';
|
|
4
|
+
export { createConversationManager } from './conversationManager';
|
|
5
|
+
export { resolveRenderers } from './htmxRenderers';
|
|
6
|
+
export { createMemoryStore } from './memoryStore';
|
|
7
|
+
export { generateId, parseAIMessage, serializeAIMessage } from './protocol';
|
|
8
|
+
export { serverMessageToAction } from './client/actions';
|
|
9
|
+
export { createAIConnection } from './client/connection';
|
|
10
|
+
export { createAIStream } from './client/createAIStream';
|
|
11
|
+
export type { CreateAIStream } from './client/createAIStream';
|
|
12
|
+
export { openaiCompatible, google, xai, deepseek, mistralai, alibaba, meta, moonshot } from './providers/openaiCompatible';
|
|
13
|
+
export { openaiResponses } from './providers/openaiResponses';
|
|
14
|
+
export { gemini } from './providers/gemini';
|
|
15
|
+
export { anthropic } from './providers/anthropic';
|
|
16
|
+
export { ollama } from './providers/ollama';
|
|
17
|
+
export { openai } from './providers/openai';
|
|
18
|
+
export * from '../../types/ai';
|
|
19
|
+
export type { SessionStore } from '../../types/session';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AIServerMessage } from '../../types/ai';
|
|
2
|
+
export declare const generateId: () => `${string}-${string}-${string}-${string}-${string}`;
|
|
3
|
+
export declare const parseAIMessage: (raw: unknown) => import(".").AIClientMessage | null;
|
|
4
|
+
export declare const serializeAIMessage: (message: AIServerMessage) => string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a provider for any OpenAI-compatible API.
|
|
3
|
+
* Many providers (Google, xAI, DeepSeek, Mistral, etc.)
|
|
4
|
+
* expose OpenAI-compatible chat completion endpoints.
|
|
5
|
+
*/
|
|
6
|
+
export declare const alibaba: (config: {
|
|
7
|
+
apiKey: string;
|
|
8
|
+
}) => import("..").AIProviderConfig;
|
|
9
|
+
export declare const deepseek: (config: {
|
|
10
|
+
apiKey: string;
|
|
11
|
+
}) => import("..").AIProviderConfig;
|
|
12
|
+
export declare const google: (config: {
|
|
13
|
+
apiKey: string;
|
|
14
|
+
}) => import("..").AIProviderConfig;
|
|
15
|
+
export declare const meta: (config: {
|
|
16
|
+
apiKey: string;
|
|
17
|
+
}) => import("..").AIProviderConfig;
|
|
18
|
+
export declare const mistralai: (config: {
|
|
19
|
+
apiKey: string;
|
|
20
|
+
}) => import("..").AIProviderConfig;
|
|
21
|
+
export declare const moonshot: (config: {
|
|
22
|
+
apiKey: string;
|
|
23
|
+
}) => import("..").AIProviderConfig;
|
|
24
|
+
export declare const openaiCompatible: (config: {
|
|
25
|
+
apiKey: string;
|
|
26
|
+
baseUrl: string;
|
|
27
|
+
}) => import("..").AIProviderConfig;
|
|
28
|
+
export declare const xai: (config: {
|
|
29
|
+
apiKey: string;
|
|
30
|
+
}) => import("..").AIProviderConfig;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { AIProviderStreamParams } from '../../../types/ai';
|
|
2
|
+
type OpenAIResponsesConfig = {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
imageModels?: Set<string> | string[];
|
|
6
|
+
};
|
|
7
|
+
export declare const openaiResponses: (config: OpenAIResponsesConfig) => {
|
|
8
|
+
stream: (params: AIProviderStreamParams) => AsyncGenerator<{
|
|
9
|
+
content: string;
|
|
10
|
+
type: "text";
|
|
11
|
+
} | {
|
|
12
|
+
data: string;
|
|
13
|
+
format: string;
|
|
14
|
+
imageId: string | undefined;
|
|
15
|
+
isPartial: boolean;
|
|
16
|
+
type: "image";
|
|
17
|
+
} | {
|
|
18
|
+
id: string;
|
|
19
|
+
input: any;
|
|
20
|
+
name: string;
|
|
21
|
+
type: "tool_use";
|
|
22
|
+
} | {
|
|
23
|
+
type: "done";
|
|
24
|
+
usage: {
|
|
25
|
+
inputTokens: number;
|
|
26
|
+
outputTokens: number;
|
|
27
|
+
} | undefined;
|
|
28
|
+
} | {
|
|
29
|
+
content: string;
|
|
30
|
+
type: "thinking";
|
|
31
|
+
}, void, unknown>;
|
|
32
|
+
};
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { StreamAIOptions } from '../../types/ai';
|
|
2
|
+
import type { ResolvedRenderers } from './htmxRenderers';
|
|
3
|
+
export declare const streamAIToSSE: (conversationId: string, messageId: string, options: StreamAIOptions, renderers: ResolvedRenderers) => AsyncGenerator<{
|
|
4
|
+
data: string;
|
|
5
|
+
event: string;
|
|
6
|
+
}, void, unknown>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export declare const ANGULAR_INIT_TIMEOUT_MS = 500;
|
|
2
|
+
export declare const ANSI_ESCAPE_LENGTH = 3;
|
|
3
|
+
export declare const ASCII_SPACE = 32;
|
|
4
|
+
export declare const BASE_36_RADIX = 36;
|
|
5
|
+
export declare const BUN_BUILD_WARNING_SUPPRESSION = "wildcard sideEffects are not supported yet";
|
|
6
|
+
export declare const BODY_SLICE_LENGTH = 2000;
|
|
7
|
+
export declare const BYTES_PER_KILOBYTE = 1024;
|
|
8
|
+
export declare const CLI_ARGS_OFFSET = 3;
|
|
9
|
+
export declare const CSS_ERROR_RESOLVE_DELAY_MS = 50;
|
|
10
|
+
export declare const CSS_MAX_CHECK_ATTEMPTS = 10;
|
|
11
|
+
export declare const CSS_MAX_PARSE_TIMEOUT_MS = 500;
|
|
12
|
+
export declare const CSS_SHEET_READY_TIMEOUT_MS = 100;
|
|
13
|
+
export declare const DEFAULT_CHUNK_SIZE = 16384;
|
|
14
|
+
export declare const DEFAULT_DEBOUNCE_MS = 15;
|
|
15
|
+
export declare const DEFAULT_PORT = 3000;
|
|
16
|
+
export declare const DEV_SERVER_RESTART_DEBOUNCE_MS = 100;
|
|
17
|
+
export declare const DOM_UPDATE_DELAY_MS = 50;
|
|
18
|
+
export declare const FILE_PROTOCOL_PREFIX_LENGTH = 7;
|
|
19
|
+
export declare const FOCUS_ID_PREFIX_LENGTH = 3;
|
|
20
|
+
export declare const FOCUS_IDX_PREFIX_LENGTH = 4;
|
|
21
|
+
export declare const FOCUS_NAME_PREFIX_LENGTH = 5;
|
|
22
|
+
export declare const HMR_UPDATE_TIMEOUT_MS = 2000;
|
|
23
|
+
export declare const HOOK_SIGNATURE_LENGTH = 12;
|
|
24
|
+
export declare const EXCLUDE_LAST_OFFSET = -1;
|
|
25
|
+
export declare const HTTP_STATUS_OK = 200;
|
|
26
|
+
export declare const HTTP_STATUS_BAD_REQUEST = 400;
|
|
27
|
+
export declare const HTTP_STATUS_NOT_FOUND = 404;
|
|
28
|
+
export declare const HOURS_IN_DAY = 24;
|
|
29
|
+
export declare const HOURS_IN_HALF_DAY = 12;
|
|
30
|
+
export declare const MAX_ERROR_LENGTH = 200;
|
|
31
|
+
export declare const MAX_RECONNECT_ATTEMPTS = 60;
|
|
32
|
+
export declare const MILLISECONDS_IN_A_SECOND = 1000;
|
|
33
|
+
export declare const MINUTES_IN_AN_HOUR = 60;
|
|
34
|
+
export declare const SECONDS_IN_A_MINUTE = 60;
|
|
35
|
+
export declare const MILLISECONDS_IN_A_MINUTE: number;
|
|
36
|
+
export declare const MILLISECONDS_IN_A_DAY: number;
|
|
37
|
+
export declare const OVERLAY_FADE_DURATION_MS = 150;
|
|
38
|
+
export declare const PING_INTERVAL_MS = 30000;
|
|
39
|
+
export declare const RAF_BATCH_COUNT = 3;
|
|
40
|
+
export declare const RANDOM_ID_END_INDEX = 11;
|
|
41
|
+
export declare const REBUILD_BATCH_DELAY_MS = 10;
|
|
42
|
+
export declare const REBUILD_RELOAD_DELAY_MS = 200;
|
|
43
|
+
export declare const RECONNECT_INITIAL_DELAY_MS = 500;
|
|
44
|
+
export declare const RECONNECT_POLL_INTERVAL_MS = 300;
|
|
45
|
+
export declare const RAG_CHUNK_ID_PAD_LENGTH = 3;
|
|
46
|
+
export declare const RAG_DOCUMENT_ID_PREVIEW_LENGTH = 32;
|
|
47
|
+
export declare const RAG_DOCUMENT_SLUG_MAX_LENGTH = 48;
|
|
48
|
+
export declare const RAG_MIN_CHUNK_LENGTH_FLOOR = 120;
|
|
49
|
+
export declare const RAG_NATIVE_QUERY_CANDIDATE_LIMIT = 1000;
|
|
50
|
+
export declare const RAG_SEARCH_SCORE_DECIMAL_PLACES = 3;
|
|
51
|
+
export declare const RAG_VECTOR_DIMENSIONS_DEFAULT = 24;
|
|
52
|
+
export declare const REACT_STREAM_SLOT_FAST_DELAY_MS = 5;
|
|
53
|
+
export declare const REACT_STREAM_SLOT_SLOW_DELAY_MS = 20;
|
|
54
|
+
export declare const SIGINT_EXIT_CODE = 130;
|
|
55
|
+
export declare const SIGTERM_EXIT_CODE = 143;
|
|
56
|
+
export declare const SVELTE_CSS_LOAD_TIMEOUT_MS = 500;
|
|
57
|
+
export declare const TIME_PRECISION = 2;
|
|
58
|
+
export declare const TWO_THIRDS: number;
|
|
59
|
+
export declare const UNFOUND_INDEX = -1;
|
|
60
|
+
export declare const WEBSOCKET_NORMAL_CLOSURE = 1000;
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { Elysia } from 'elysia';
|
|
2
|
+
import type { AIChatPluginConfig, AIMessage } from '../../types/ai';
|
|
3
|
+
export declare const aiChat: (config: AIChatPluginConfig) => Elysia<"", {
|
|
4
|
+
decorator: {};
|
|
5
|
+
store: {};
|
|
6
|
+
derive: {};
|
|
7
|
+
resolve: {};
|
|
8
|
+
}, {
|
|
9
|
+
typebox: {};
|
|
10
|
+
error: {};
|
|
11
|
+
}, {
|
|
12
|
+
schema: {};
|
|
13
|
+
standaloneSchema: {};
|
|
14
|
+
macro: {};
|
|
15
|
+
macroFn: {};
|
|
16
|
+
parser: {};
|
|
17
|
+
response: {};
|
|
18
|
+
}, {
|
|
19
|
+
[x: string]: {
|
|
20
|
+
subscribe: {
|
|
21
|
+
body: unknown;
|
|
22
|
+
params: {};
|
|
23
|
+
query: unknown;
|
|
24
|
+
headers: unknown;
|
|
25
|
+
response: {};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
} & {
|
|
29
|
+
[x: string]: {
|
|
30
|
+
conversations: {
|
|
31
|
+
get: {
|
|
32
|
+
body: unknown;
|
|
33
|
+
params: {};
|
|
34
|
+
query: unknown;
|
|
35
|
+
headers: unknown;
|
|
36
|
+
response: {
|
|
37
|
+
200: import("../ai").AIConversationSummary[];
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
} & ({
|
|
43
|
+
[x: string]: {
|
|
44
|
+
conversations: {
|
|
45
|
+
":id": {
|
|
46
|
+
get: {
|
|
47
|
+
body: unknown;
|
|
48
|
+
params: {
|
|
49
|
+
id: string;
|
|
50
|
+
} & {};
|
|
51
|
+
query: unknown;
|
|
52
|
+
headers: unknown;
|
|
53
|
+
response: {
|
|
54
|
+
200: Response | {
|
|
55
|
+
id: string;
|
|
56
|
+
messages: AIMessage[];
|
|
57
|
+
title: string;
|
|
58
|
+
};
|
|
59
|
+
422: {
|
|
60
|
+
type: "validation";
|
|
61
|
+
on: string;
|
|
62
|
+
summary?: string;
|
|
63
|
+
message?: string;
|
|
64
|
+
found?: unknown;
|
|
65
|
+
property?: string;
|
|
66
|
+
expected?: string;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
} & ({
|
|
74
|
+
[x: string]: {
|
|
75
|
+
conversations: {
|
|
76
|
+
":id": {
|
|
77
|
+
delete: {
|
|
78
|
+
body: unknown;
|
|
79
|
+
params: {
|
|
80
|
+
id: string;
|
|
81
|
+
} & {};
|
|
82
|
+
query: unknown;
|
|
83
|
+
headers: unknown;
|
|
84
|
+
response: {
|
|
85
|
+
200: {
|
|
86
|
+
ok: boolean;
|
|
87
|
+
};
|
|
88
|
+
422: {
|
|
89
|
+
type: "validation";
|
|
90
|
+
on: string;
|
|
91
|
+
summary?: string;
|
|
92
|
+
message?: string;
|
|
93
|
+
found?: unknown;
|
|
94
|
+
property?: string;
|
|
95
|
+
expected?: string;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
} | ({
|
|
103
|
+
[x: string]: {
|
|
104
|
+
conversations: {
|
|
105
|
+
":id": {
|
|
106
|
+
delete: {
|
|
107
|
+
body: unknown;
|
|
108
|
+
params: {
|
|
109
|
+
id: string;
|
|
110
|
+
} & {};
|
|
111
|
+
query: unknown;
|
|
112
|
+
headers: unknown;
|
|
113
|
+
response: {
|
|
114
|
+
200: {
|
|
115
|
+
ok: boolean;
|
|
116
|
+
};
|
|
117
|
+
422: {
|
|
118
|
+
type: "validation";
|
|
119
|
+
on: string;
|
|
120
|
+
summary?: string;
|
|
121
|
+
message?: string;
|
|
122
|
+
found?: unknown;
|
|
123
|
+
property?: string;
|
|
124
|
+
expected?: string;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
} & {
|
|
132
|
+
[x: string]: {
|
|
133
|
+
message: {
|
|
134
|
+
post: {
|
|
135
|
+
body: unknown;
|
|
136
|
+
params: {};
|
|
137
|
+
query: unknown;
|
|
138
|
+
headers: unknown;
|
|
139
|
+
response: {
|
|
140
|
+
200: Response;
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
} & {
|
|
146
|
+
[x: string]: {
|
|
147
|
+
sse: {
|
|
148
|
+
":conversationId": {
|
|
149
|
+
":messageId": {
|
|
150
|
+
get: {
|
|
151
|
+
body: unknown;
|
|
152
|
+
params: {
|
|
153
|
+
conversationId: string;
|
|
154
|
+
messageId: string;
|
|
155
|
+
} & {};
|
|
156
|
+
query: unknown;
|
|
157
|
+
headers: unknown;
|
|
158
|
+
response: {
|
|
159
|
+
200: AsyncGenerator<{
|
|
160
|
+
data: string;
|
|
161
|
+
event: string;
|
|
162
|
+
}, void, unknown>;
|
|
163
|
+
422: {
|
|
164
|
+
type: "validation";
|
|
165
|
+
on: string;
|
|
166
|
+
summary?: string;
|
|
167
|
+
message?: string;
|
|
168
|
+
found?: unknown;
|
|
169
|
+
property?: string;
|
|
170
|
+
expected?: string;
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
} & {
|
|
179
|
+
[x: string]: {
|
|
180
|
+
history: {
|
|
181
|
+
":conversationId": {
|
|
182
|
+
get: {
|
|
183
|
+
body: unknown;
|
|
184
|
+
params: {
|
|
185
|
+
conversationId: string;
|
|
186
|
+
} & {};
|
|
187
|
+
query: unknown;
|
|
188
|
+
headers: unknown;
|
|
189
|
+
response: {
|
|
190
|
+
200: Response;
|
|
191
|
+
422: {
|
|
192
|
+
type: "validation";
|
|
193
|
+
on: string;
|
|
194
|
+
summary?: string;
|
|
195
|
+
message?: string;
|
|
196
|
+
found?: unknown;
|
|
197
|
+
property?: string;
|
|
198
|
+
expected?: string;
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
} & {
|
|
206
|
+
[x: string]: {
|
|
207
|
+
conversations: {
|
|
208
|
+
list: {
|
|
209
|
+
get: {
|
|
210
|
+
body: unknown;
|
|
211
|
+
params: {};
|
|
212
|
+
query: unknown;
|
|
213
|
+
headers: unknown;
|
|
214
|
+
response: {
|
|
215
|
+
200: Response;
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
}))), {
|
|
222
|
+
derive: {};
|
|
223
|
+
resolve: {};
|
|
224
|
+
schema: {};
|
|
225
|
+
standaloneSchema: {};
|
|
226
|
+
response: {};
|
|
227
|
+
}, {
|
|
228
|
+
derive: {};
|
|
229
|
+
resolve: {};
|
|
230
|
+
schema: {};
|
|
231
|
+
standaloneSchema: {};
|
|
232
|
+
response: {};
|
|
233
|
+
} & {
|
|
234
|
+
derive: {};
|
|
235
|
+
resolve: {};
|
|
236
|
+
schema: {};
|
|
237
|
+
standaloneSchema: {};
|
|
238
|
+
response: {};
|
|
239
|
+
}>;
|