@axium/ai 0.0.1 → 0.1.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.
- package/dist/client/config.d.ts +6 -6
- package/dist/common.d.ts +18 -18
- package/dist/loop.js +20 -19
- package/package.json +1 -1
- package/dist/.locale.d.ts +0 -300
- package/dist/.locale.js +0 -1
- package/dist/server/api.d.ts +0 -1
- package/dist/server/api.js +0 -157
package/dist/client/config.d.ts
CHANGED
|
@@ -5,9 +5,9 @@ import type * as llama from '../node/llama.js';
|
|
|
5
5
|
import type { Registered } from '../node/models.js';
|
|
6
6
|
declare const LocalModel: z.ZodObject<{
|
|
7
7
|
id: z.ZodString;
|
|
8
|
+
name: z.ZodString;
|
|
8
9
|
source: z.ZodString;
|
|
9
10
|
created: z.ZodCoercedDate<unknown>;
|
|
10
|
-
name: z.ZodString;
|
|
11
11
|
reasoning: z.ZodNullable<z.ZodString>;
|
|
12
12
|
systemPrompt: z.ZodNullable<z.ZodString>;
|
|
13
13
|
size: z.ZodNumber;
|
|
@@ -37,9 +37,9 @@ declare const LocalConfig: z.ZodObject<{
|
|
|
37
37
|
}, z.core.$strip>>;
|
|
38
38
|
models: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
39
39
|
id: z.ZodString;
|
|
40
|
+
name: z.ZodString;
|
|
40
41
|
source: z.ZodString;
|
|
41
42
|
created: z.ZodCoercedDate<unknown>;
|
|
42
|
-
name: z.ZodString;
|
|
43
43
|
reasoning: z.ZodNullable<z.ZodString>;
|
|
44
44
|
systemPrompt: z.ZodNullable<z.ZodString>;
|
|
45
45
|
size: z.ZodNumber;
|
|
@@ -70,9 +70,9 @@ export declare const configManager: Manager<z.ZodObject<{
|
|
|
70
70
|
}, z.core.$strip>>;
|
|
71
71
|
models: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
72
72
|
id: z.ZodString;
|
|
73
|
+
name: z.ZodString;
|
|
73
74
|
source: z.ZodString;
|
|
74
75
|
created: z.ZodCoercedDate<unknown>;
|
|
75
|
-
name: z.ZodString;
|
|
76
76
|
reasoning: z.ZodNullable<z.ZodString>;
|
|
77
77
|
systemPrompt: z.ZodNullable<z.ZodString>;
|
|
78
78
|
size: z.ZodNumber;
|
|
@@ -102,9 +102,9 @@ export declare const configManager: Manager<z.ZodObject<{
|
|
|
102
102
|
} | undefined;
|
|
103
103
|
models?: {
|
|
104
104
|
id: string;
|
|
105
|
+
name: string;
|
|
105
106
|
source: string;
|
|
106
107
|
created: unknown;
|
|
107
|
-
name: string;
|
|
108
108
|
reasoning: string | null;
|
|
109
109
|
systemPrompt: string | null;
|
|
110
110
|
size: number;
|
|
@@ -134,9 +134,9 @@ export declare const configManager: Manager<z.ZodObject<{
|
|
|
134
134
|
} | undefined;
|
|
135
135
|
models?: {
|
|
136
136
|
id?: string | undefined;
|
|
137
|
+
name?: string | undefined;
|
|
137
138
|
source?: string | undefined;
|
|
138
139
|
created?: Date | undefined;
|
|
139
|
-
name?: string | undefined;
|
|
140
140
|
reasoning?: string | null | undefined;
|
|
141
141
|
systemPrompt?: string | null | undefined;
|
|
142
142
|
size?: number | undefined;
|
|
@@ -168,9 +168,9 @@ export declare const config: {
|
|
|
168
168
|
};
|
|
169
169
|
models: {
|
|
170
170
|
id: string;
|
|
171
|
+
name: string;
|
|
171
172
|
source: string;
|
|
172
173
|
created: Date;
|
|
173
|
-
name: string;
|
|
174
174
|
reasoning: string | null;
|
|
175
175
|
systemPrompt: string | null;
|
|
176
176
|
size: number;
|
package/dist/common.d.ts
CHANGED
|
@@ -342,7 +342,7 @@ export declare const Conversation: z.ZodObject<{
|
|
|
342
342
|
}, z.core.$strip>;
|
|
343
343
|
export interface Conversation extends z.infer<typeof Conversation> {
|
|
344
344
|
}
|
|
345
|
-
export declare const MessageRole: z.ZodLiteral<"
|
|
345
|
+
export declare const MessageRole: z.ZodLiteral<"assistant" | "user" | "tool">;
|
|
346
346
|
export type MessageRole = z.infer<typeof MessageRole>;
|
|
347
347
|
/** `awaiting` is a tool call waiting for the user to approve it */
|
|
348
348
|
export declare const MessageStatus: z.ZodLiteral<"error" | "done" | "pending" | "cancelled" | "awaiting">;
|
|
@@ -354,7 +354,7 @@ export type Environment = z.infer<typeof Environment>;
|
|
|
354
354
|
export declare const ToolAccess: z.ZodLiteral<"read" | "write">;
|
|
355
355
|
export type ToolAccess = z.infer<typeof ToolAccess>;
|
|
356
356
|
/** Whether a tool runs without asking */
|
|
357
|
-
export declare const Approval: z.ZodLiteral<"
|
|
357
|
+
export declare const Approval: z.ZodLiteral<"ask" | "allow">;
|
|
358
358
|
export type Approval = z.infer<typeof Approval>;
|
|
359
359
|
/** `chat` allows the tool for the rest of the conversation, `always` for every conversation */
|
|
360
360
|
export declare const Decision: z.ZodLiteral<"chat" | "deny" | "once" | "always">;
|
|
@@ -381,7 +381,7 @@ export declare const Message: z.ZodObject<{
|
|
|
381
381
|
id: z.ZodUUID;
|
|
382
382
|
conversationId: z.ZodUUID;
|
|
383
383
|
created: z.ZodCoercedDate<unknown>;
|
|
384
|
-
role: z.ZodLiteral<"
|
|
384
|
+
role: z.ZodLiteral<"assistant" | "user" | "tool">;
|
|
385
385
|
content: z.ZodString;
|
|
386
386
|
reasoning: z.ZodNullable<z.ZodString>;
|
|
387
387
|
toolCalls: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
@@ -422,9 +422,9 @@ export declare const ConversationAction: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
422
422
|
export type ConversationAction = z.infer<typeof ConversationAction>;
|
|
423
423
|
/** A message in a temporary conversation, which only the client keeps */
|
|
424
424
|
export declare const TemporaryMessage: z.ZodObject<{
|
|
425
|
-
id: z.ZodUUID;
|
|
426
425
|
status: z.ZodLiteral<"error" | "done" | "pending" | "cancelled" | "awaiting">;
|
|
427
|
-
|
|
426
|
+
id: z.ZodUUID;
|
|
427
|
+
role: z.ZodLiteral<"assistant" | "user" | "tool">;
|
|
428
428
|
toolCalls: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
429
429
|
id: z.ZodString;
|
|
430
430
|
name: z.ZodString;
|
|
@@ -442,9 +442,9 @@ export declare const TemporaryInit: z.ZodObject<{
|
|
|
442
442
|
reasoning: z.ZodString;
|
|
443
443
|
anonymous: z.ZodDefault<z.ZodBoolean>;
|
|
444
444
|
messages: z.ZodArray<z.ZodObject<{
|
|
445
|
-
id: z.ZodUUID;
|
|
446
445
|
status: z.ZodLiteral<"error" | "done" | "pending" | "cancelled" | "awaiting">;
|
|
447
|
-
|
|
446
|
+
id: z.ZodUUID;
|
|
447
|
+
role: z.ZodLiteral<"assistant" | "user" | "tool">;
|
|
448
448
|
toolCalls: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
449
449
|
id: z.ZodString;
|
|
450
450
|
name: z.ZodString;
|
|
@@ -506,10 +506,10 @@ export declare const Preferences: z.ZodObject<{
|
|
|
506
506
|
ctrl_enter: z.ZodDefault<z.ZodBoolean>;
|
|
507
507
|
instructions: z.ZodOptional<z.ZodString>;
|
|
508
508
|
tools: z.ZodDefault<z.ZodObject<{
|
|
509
|
-
account_access: z.ZodDefault<z.ZodLiteral<"
|
|
509
|
+
account_access: z.ZodDefault<z.ZodLiteral<"none" | "read" | "write">>;
|
|
510
510
|
confirm_writes: z.ZodDefault<z.ZodBoolean>;
|
|
511
511
|
web: z.ZodDefault<z.ZodBoolean>;
|
|
512
|
-
approvals: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodLiteral<"
|
|
512
|
+
approvals: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodLiteral<"ask" | "allow">>>;
|
|
513
513
|
memory: z.ZodDefault<z.ZodBoolean>;
|
|
514
514
|
memory_updates: z.ZodDefault<z.ZodLiteral<"off" | "daily" | "weekly">>;
|
|
515
515
|
}, z.core.$strip>>;
|
|
@@ -887,7 +887,7 @@ declare const AIAPI: {
|
|
|
887
887
|
id: z.ZodUUID;
|
|
888
888
|
conversationId: z.ZodUUID;
|
|
889
889
|
created: z.ZodCoercedDate<unknown>;
|
|
890
|
-
role: z.ZodLiteral<"
|
|
890
|
+
role: z.ZodLiteral<"assistant" | "user" | "tool">;
|
|
891
891
|
content: z.ZodString;
|
|
892
892
|
reasoning: z.ZodNullable<z.ZodString>;
|
|
893
893
|
toolCalls: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
@@ -929,7 +929,7 @@ declare const AIAPI: {
|
|
|
929
929
|
id: z.ZodUUID;
|
|
930
930
|
conversationId: z.ZodUUID;
|
|
931
931
|
created: z.ZodCoercedDate<unknown>;
|
|
932
|
-
role: z.ZodLiteral<"
|
|
932
|
+
role: z.ZodLiteral<"assistant" | "user" | "tool">;
|
|
933
933
|
content: z.ZodString;
|
|
934
934
|
reasoning: z.ZodNullable<z.ZodString>;
|
|
935
935
|
toolCalls: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
@@ -965,7 +965,7 @@ declare const AIAPI: {
|
|
|
965
965
|
id: z.ZodUUID;
|
|
966
966
|
conversationId: z.ZodUUID;
|
|
967
967
|
created: z.ZodCoercedDate<unknown>;
|
|
968
|
-
role: z.ZodLiteral<"
|
|
968
|
+
role: z.ZodLiteral<"assistant" | "user" | "tool">;
|
|
969
969
|
content: z.ZodString;
|
|
970
970
|
reasoning: z.ZodNullable<z.ZodString>;
|
|
971
971
|
toolCalls: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
@@ -1003,9 +1003,9 @@ declare const AIAPI: {
|
|
|
1003
1003
|
reasoning: z.ZodString;
|
|
1004
1004
|
anonymous: z.ZodDefault<z.ZodBoolean>;
|
|
1005
1005
|
messages: z.ZodArray<z.ZodObject<{
|
|
1006
|
-
id: z.ZodUUID;
|
|
1007
1006
|
status: z.ZodLiteral<"error" | "done" | "pending" | "cancelled" | "awaiting">;
|
|
1008
|
-
|
|
1007
|
+
id: z.ZodUUID;
|
|
1008
|
+
role: z.ZodLiteral<"assistant" | "user" | "tool">;
|
|
1009
1009
|
toolCalls: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
1010
1010
|
id: z.ZodString;
|
|
1011
1011
|
name: z.ZodString;
|
|
@@ -1022,7 +1022,7 @@ declare const AIAPI: {
|
|
|
1022
1022
|
id: z.ZodUUID;
|
|
1023
1023
|
conversationId: z.ZodUUID;
|
|
1024
1024
|
created: z.ZodCoercedDate<unknown>;
|
|
1025
|
-
role: z.ZodLiteral<"
|
|
1025
|
+
role: z.ZodLiteral<"assistant" | "user" | "tool">;
|
|
1026
1026
|
content: z.ZodString;
|
|
1027
1027
|
reasoning: z.ZodNullable<z.ZodString>;
|
|
1028
1028
|
toolCalls: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
@@ -1194,7 +1194,7 @@ export interface MessagesRemoved extends z.infer<typeof MessagesRemoved> {
|
|
|
1194
1194
|
export declare const Delta: z.ZodObject<{
|
|
1195
1195
|
conversationId: z.ZodUUID;
|
|
1196
1196
|
messageId: z.ZodUUID;
|
|
1197
|
-
field: z.ZodLiteral<"
|
|
1197
|
+
field: z.ZodLiteral<"reasoning" | "content">;
|
|
1198
1198
|
text: z.ZodString;
|
|
1199
1199
|
position: z.ZodInt;
|
|
1200
1200
|
}, z.core.$strip>;
|
|
@@ -1204,7 +1204,7 @@ declare const AIServerToClient: {
|
|
|
1204
1204
|
readonly 'ai.delta': readonly [z.ZodObject<{
|
|
1205
1205
|
conversationId: z.ZodUUID;
|
|
1206
1206
|
messageId: z.ZodUUID;
|
|
1207
|
-
field: z.ZodLiteral<"
|
|
1207
|
+
field: z.ZodLiteral<"reasoning" | "content">;
|
|
1208
1208
|
text: z.ZodString;
|
|
1209
1209
|
position: z.ZodInt;
|
|
1210
1210
|
}, z.core.$strip>];
|
|
@@ -1212,7 +1212,7 @@ declare const AIServerToClient: {
|
|
|
1212
1212
|
id: z.ZodUUID;
|
|
1213
1213
|
conversationId: z.ZodUUID;
|
|
1214
1214
|
created: z.ZodCoercedDate<unknown>;
|
|
1215
|
-
role: z.ZodLiteral<"
|
|
1215
|
+
role: z.ZodLiteral<"assistant" | "user" | "tool">;
|
|
1216
1216
|
content: z.ZodString;
|
|
1217
1217
|
reasoning: z.ZodNullable<z.ZodString>;
|
|
1218
1218
|
toolCalls: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
package/dist/loop.js
CHANGED
|
@@ -2,17 +2,19 @@ import * as io from 'ioium';
|
|
|
2
2
|
import * as memory from './memory.js';
|
|
3
3
|
import './timers.js';
|
|
4
4
|
import * as tools from './tools.js';
|
|
5
|
-
const toolGuidance =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
const toolGuidance = `\
|
|
6
|
+
You can call tools. Only call one when it helps with what the user asked.\
|
|
7
|
+
If a call fails, read the error and correct the input instead of repeating the same call.\
|
|
8
|
+
Never create, change or delete anything the user didn't ask for, even as a workaround.\
|
|
9
|
+
Only say an action was done when a tool result confirms it; if you could not do something, say so.`;
|
|
10
|
+
const voiceGuidance = `\
|
|
11
|
+
The user is speaking to you, and your reply will be read aloud by a speech synthesizer, so write only what should be heard.\
|
|
12
|
+
Reply in plain spoken prose: no Markdown, lists, tables, headings, code, emoji, URLs or symbols that would be read out literally.\
|
|
13
|
+
Be brief and conversational, usually one to three sentences.\
|
|
14
|
+
Write numbers, dates, times and units the way they are said aloud, e.g. "twenty past three" and "about four kilometres".\
|
|
15
|
+
Don't read out IDs, links, file paths or long values; describe them, or say the details are in the chat.\
|
|
16
|
+
Only state facts you are sure of or that a tool result gave you; if you don't know, say so briefly.\
|
|
17
|
+
The transcript of what the user said may contain recognition mistakes, so read it for its likely meaning`;
|
|
16
18
|
/** When a message was sent, e.g. `<sent>Monday 2026-11-16T21:15-06:00 (2026-11-17T03:15Z)</sent>` */
|
|
17
19
|
function sentTag(created, timeZone) {
|
|
18
20
|
const instant = created.toTemporalInstant();
|
|
@@ -26,20 +28,19 @@ function systemPrompt({ prompt, instructions, offered, remembered, voice, timeZo
|
|
|
26
28
|
// date information
|
|
27
29
|
const local = Temporal.Now.zonedDateTimeISO(timeZone);
|
|
28
30
|
const date = local.toLocaleString('en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' });
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"The tag isn't part of what they wrote, so don't repeat it.");
|
|
31
|
+
sections.push(`For the user, today is ${date}. Their time zone is ${timeZone} (UTC${local.offset}).\
|
|
32
|
+
${homeTimeZone && homeTimeZone != timeZone ? ` Their home time zone is ${homeTimeZone}.` : ''}\
|
|
33
|
+
Each of the user's messages starts with a <sent> tag saying when it was sent,\
|
|
34
|
+
in their time and UTC; the latest one is the current time.\
|
|
35
|
+
The tag isn't part of what they wrote, so don't repeat it.`);
|
|
35
36
|
if (offered.length)
|
|
36
37
|
sections.push(toolGuidance);
|
|
37
38
|
if (remembered)
|
|
38
39
|
sections.push(remembered);
|
|
39
|
-
if (instructions)
|
|
40
|
-
sections.push(`The user has given these instructions for every conversation:\n\n${instructions}`);
|
|
41
40
|
if (voice)
|
|
42
41
|
sections.push(voiceGuidance);
|
|
42
|
+
if (instructions)
|
|
43
|
+
sections.push(`The user has given these instructions for every conversation:\n\n${instructions}`);
|
|
43
44
|
return sections.join('\n\n');
|
|
44
45
|
}
|
|
45
46
|
/**
|
package/package.json
CHANGED
package/dist/.locale.d.ts
DELETED
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
import type { Value } from '@james-pre/locales';
|
|
2
|
-
declare module '@james-pre/locales' {
|
|
3
|
-
interface Keys {
|
|
4
|
-
'ai.action.load': {};
|
|
5
|
-
'ai.action.pause': {};
|
|
6
|
-
'ai.action.resume': {};
|
|
7
|
-
'ai.action.unload': {};
|
|
8
|
-
'ai.add.download': {};
|
|
9
|
-
'ai.add.id': {};
|
|
10
|
-
'ai.add.id_taken': {};
|
|
11
|
-
'ai.add.name': {};
|
|
12
|
-
'ai.add.no_quants': {};
|
|
13
|
-
'ai.add.no_results': {};
|
|
14
|
-
'ai.add.pick_quant': {};
|
|
15
|
-
'ai.add.search': {};
|
|
16
|
-
'ai.add.search_button': {};
|
|
17
|
-
'ai.add.started': {
|
|
18
|
-
name: Value;
|
|
19
|
-
};
|
|
20
|
-
'ai.add.title': {};
|
|
21
|
-
'ai.approval.allow': {};
|
|
22
|
-
'ai.approval.ask': {};
|
|
23
|
-
'ai.config.data_dir': {};
|
|
24
|
-
'ai.config.llama.$title': {};
|
|
25
|
-
'ai.config.llama.command': {};
|
|
26
|
-
'ai.config.llama.defaults.$title': {};
|
|
27
|
-
'ai.config.llama.hf_token': {};
|
|
28
|
-
'ai.config.llama.host': {};
|
|
29
|
-
'ai.config.llama.memory_margin': {};
|
|
30
|
-
'ai.config.llama.models_max': {};
|
|
31
|
-
'ai.config.llama.port': {};
|
|
32
|
-
'ai.config.max_memories': {};
|
|
33
|
-
'ai.config.max_memory_length': {};
|
|
34
|
-
'ai.config.max_steps': {};
|
|
35
|
-
'ai.config.search_url': {};
|
|
36
|
-
'ai.config.speaker_reference': {};
|
|
37
|
-
'ai.config.speaker_reference_text': {};
|
|
38
|
-
'ai.config.system_prompt': {};
|
|
39
|
-
'ai.config.timeout': {};
|
|
40
|
-
'ai.conversation_missing': {};
|
|
41
|
-
'ai.conversation_title': {
|
|
42
|
-
title: Value;
|
|
43
|
-
};
|
|
44
|
-
'ai.data_access.none': {};
|
|
45
|
-
'ai.data_access.read': {};
|
|
46
|
-
'ai.data_access.write': {};
|
|
47
|
-
'ai.delete_body': {};
|
|
48
|
-
'ai.delete_title': {
|
|
49
|
-
name: Value;
|
|
50
|
-
};
|
|
51
|
-
'ai.detail.added': {};
|
|
52
|
-
'ai.detail.context': {};
|
|
53
|
-
'ai.detail.context_loaded': {
|
|
54
|
-
count: Value;
|
|
55
|
-
};
|
|
56
|
-
'ai.detail.default_reasoning': {};
|
|
57
|
-
'ai.detail.inputs': {};
|
|
58
|
-
'ai.detail.loading': {};
|
|
59
|
-
'ai.detail.loading_note': {};
|
|
60
|
-
'ai.detail.memory_current': {};
|
|
61
|
-
'ai.detail.memory_minimum': {};
|
|
62
|
-
'ai.detail.outputs': {};
|
|
63
|
-
'ai.detail.roles': {};
|
|
64
|
-
'ai.detail.size': {};
|
|
65
|
-
'ai.detail.source': {};
|
|
66
|
-
'ai.detail.system_prompt': {};
|
|
67
|
-
'ai.detail.system_prompt_default': {};
|
|
68
|
-
'ai.detail.template_default': {
|
|
69
|
-
level: Value;
|
|
70
|
-
};
|
|
71
|
-
'ai.edit': {};
|
|
72
|
-
'ai.empty': {};
|
|
73
|
-
'ai.error': {
|
|
74
|
-
error: Value;
|
|
75
|
-
};
|
|
76
|
-
'ai.fit.device': {};
|
|
77
|
-
'ai.fit.host': {};
|
|
78
|
-
'ai.fit.none': {};
|
|
79
|
-
'ai.load_failed': {};
|
|
80
|
-
'ai.memory.add': {};
|
|
81
|
-
'ai.memory.content_placeholder': {};
|
|
82
|
-
'ai.memory.delete': {};
|
|
83
|
-
'ai.memory.delete_confirm': {
|
|
84
|
-
id: Value;
|
|
85
|
-
};
|
|
86
|
-
'ai.memory.description': {};
|
|
87
|
-
'ai.memory.description_placeholder': {};
|
|
88
|
-
'ai.memory.disabled': {};
|
|
89
|
-
'ai.memory.edit': {};
|
|
90
|
-
'ai.memory.empty': {};
|
|
91
|
-
'ai.memory.from_conversation': {};
|
|
92
|
-
'ai.memory.id_invalid': {};
|
|
93
|
-
'ai.memory.id_placeholder': {};
|
|
94
|
-
'ai.memory.save': {};
|
|
95
|
-
'ai.memory.source.explicit': {};
|
|
96
|
-
'ai.memory.source.inferred': {};
|
|
97
|
-
'ai.memory.source.periodic': {};
|
|
98
|
-
'ai.memory.source.user': {};
|
|
99
|
-
'ai.memory.title': {};
|
|
100
|
-
'ai.memory_updates.changes': {
|
|
101
|
-
added: Value;
|
|
102
|
-
updated: Value;
|
|
103
|
-
deleted: Value;
|
|
104
|
-
};
|
|
105
|
-
'ai.memory_updates.frequency.daily': {};
|
|
106
|
-
'ai.memory_updates.frequency.off': {};
|
|
107
|
-
'ai.memory_updates.frequency.weekly': {};
|
|
108
|
-
'ai.memory_updates.last': {
|
|
109
|
-
when: Value;
|
|
110
|
-
};
|
|
111
|
-
'ai.memory_updates.never_ran': {};
|
|
112
|
-
'ai.memory_updates.off': {};
|
|
113
|
-
'ai.memory_updates.run': {};
|
|
114
|
-
'ai.memory_updates.running': {};
|
|
115
|
-
'ai.memory_updates.schedule': {
|
|
116
|
-
frequency: Value;
|
|
117
|
-
next: Value;
|
|
118
|
-
};
|
|
119
|
-
'ai.memory_updates.started': {};
|
|
120
|
-
'ai.memory_updates.title': {};
|
|
121
|
-
'ai.modality.audio': {};
|
|
122
|
-
'ai.modality.image': {};
|
|
123
|
-
'ai.modality.text': {};
|
|
124
|
-
'ai.modality.video': {};
|
|
125
|
-
'ai.model': {};
|
|
126
|
-
'ai.model_deleted': {
|
|
127
|
-
name: Value;
|
|
128
|
-
};
|
|
129
|
-
'ai.model_removed': {};
|
|
130
|
-
'ai.model_saved': {};
|
|
131
|
-
'ai.model_title': {
|
|
132
|
-
name: Value;
|
|
133
|
-
};
|
|
134
|
-
'ai.models': {};
|
|
135
|
-
'ai.models_title': {};
|
|
136
|
-
'ai.new': {};
|
|
137
|
-
'ai.no_models': {};
|
|
138
|
-
'ai.no_models_admin': {};
|
|
139
|
-
'ai.not_running': {};
|
|
140
|
-
'ai.option.automatic': {};
|
|
141
|
-
'ai.option.context': {};
|
|
142
|
-
'ai.option.device': {};
|
|
143
|
-
'ai.option.mmproj': {};
|
|
144
|
-
'ai.option.mmproj_default': {};
|
|
145
|
-
'ai.option.parallel': {};
|
|
146
|
-
'ai.option.reserve': {};
|
|
147
|
-
'ai.placeholder': {};
|
|
148
|
-
'ai.preferences.ctrl_enter': {};
|
|
149
|
-
'ai.preferences.instructions': {};
|
|
150
|
-
'ai.preferences.model': {};
|
|
151
|
-
'ai.preferences.reasoning': {};
|
|
152
|
-
'ai.preferences.tools.$title': {};
|
|
153
|
-
'ai.preferences.tools.account_access': {};
|
|
154
|
-
'ai.preferences.tools.approvals.$title': {};
|
|
155
|
-
'ai.preferences.tools.confirm_writes': {};
|
|
156
|
-
'ai.preferences.tools.memory': {};
|
|
157
|
-
'ai.preferences.tools.memory_updates': {};
|
|
158
|
-
'ai.preferences.tools.web': {};
|
|
159
|
-
'ai.ram.host': {};
|
|
160
|
-
'ai.ram.other': {};
|
|
161
|
-
'ai.ram.split': {
|
|
162
|
-
device: Value;
|
|
163
|
-
host: Value;
|
|
164
|
-
};
|
|
165
|
-
'ai.ram.title': {};
|
|
166
|
-
'ai.ram.usage': {
|
|
167
|
-
used: Value;
|
|
168
|
-
total: Value;
|
|
169
|
-
};
|
|
170
|
-
'ai.reasoning': {};
|
|
171
|
-
'ai.reasoning_default': {
|
|
172
|
-
level: Value;
|
|
173
|
-
};
|
|
174
|
-
'ai.reasoning_level.default': {};
|
|
175
|
-
'ai.reasoning_level.high': {};
|
|
176
|
-
'ai.reasoning_level.low': {};
|
|
177
|
-
'ai.reasoning_level.max': {};
|
|
178
|
-
'ai.reasoning_level.medium': {};
|
|
179
|
-
'ai.reasoning_level.minimal': {};
|
|
180
|
-
'ai.reasoning_level.none': {};
|
|
181
|
-
'ai.reasoning_level.xhigh': {};
|
|
182
|
-
'ai.reasoning_on': {};
|
|
183
|
-
'ai.reasoning_template': {
|
|
184
|
-
level: Value;
|
|
185
|
-
};
|
|
186
|
-
'ai.reasoning_toggle': {};
|
|
187
|
-
'ai.reasoning_unknown': {};
|
|
188
|
-
'ai.retry': {};
|
|
189
|
-
'ai.role.about.assistant': {};
|
|
190
|
-
'ai.role.about.chat': {};
|
|
191
|
-
'ai.role.about.coding': {};
|
|
192
|
-
'ai.role.about.stt': {};
|
|
193
|
-
'ai.role.about.tts': {};
|
|
194
|
-
'ai.role.add': {};
|
|
195
|
-
'ai.role.description': {};
|
|
196
|
-
'ai.role.fallback': {
|
|
197
|
-
name: Value;
|
|
198
|
-
};
|
|
199
|
-
'ai.role.move_up': {};
|
|
200
|
-
'ai.role.name.assistant': {};
|
|
201
|
-
'ai.role.name.chat': {};
|
|
202
|
-
'ai.role.name.coding': {};
|
|
203
|
-
'ai.role.name.stt': {};
|
|
204
|
-
'ai.role.name.tts': {};
|
|
205
|
-
'ai.role.none': {};
|
|
206
|
-
'ai.role.remove': {};
|
|
207
|
-
'ai.role.saved': {};
|
|
208
|
-
'ai.role.serving': {};
|
|
209
|
-
'ai.role.title': {};
|
|
210
|
-
'ai.role.unavailable': {};
|
|
211
|
-
'ai.save': {};
|
|
212
|
-
'ai.send': {};
|
|
213
|
-
'ai.settings': {};
|
|
214
|
-
'ai.speed': {
|
|
215
|
-
speed: Value;
|
|
216
|
-
};
|
|
217
|
-
'ai.status.downloading': {};
|
|
218
|
-
'ai.status.incomplete': {};
|
|
219
|
-
'ai.status.loaded': {};
|
|
220
|
-
'ai.status.loading': {};
|
|
221
|
-
'ai.status.sleeping': {};
|
|
222
|
-
'ai.status.unavailable': {};
|
|
223
|
-
'ai.status.unloaded': {};
|
|
224
|
-
'ai.stop': {};
|
|
225
|
-
'ai.stopped': {};
|
|
226
|
-
'ai.temporary.anonymous': {};
|
|
227
|
-
'ai.temporary.description': {};
|
|
228
|
-
'ai.temporary.discard': {};
|
|
229
|
-
'ai.temporary.discard_confirm': {};
|
|
230
|
-
'ai.temporary.title': {};
|
|
231
|
-
'ai.temporary.toggle': {};
|
|
232
|
-
'ai.thinking': {};
|
|
233
|
-
'ai.timer.cancel': {};
|
|
234
|
-
'ai.timer.count': {
|
|
235
|
-
count: Value;
|
|
236
|
-
};
|
|
237
|
-
'ai.timer.dismiss': {};
|
|
238
|
-
'ai.timer.done': {};
|
|
239
|
-
'ai.timer.list': {};
|
|
240
|
-
'ai.timer.title': {};
|
|
241
|
-
'ai.toast_deleted': {};
|
|
242
|
-
'ai.toast_renamed': {};
|
|
243
|
-
'ai.tokens': {
|
|
244
|
-
count: Value;
|
|
245
|
-
};
|
|
246
|
-
'ai.tool.add_memory': {};
|
|
247
|
-
'ai.tool.add_task': {};
|
|
248
|
-
'ai.tool.cancel_timer': {};
|
|
249
|
-
'ai.tool.create_note': {};
|
|
250
|
-
'ai.tool.create_task_list': {};
|
|
251
|
-
'ai.tool.delete_memory': {};
|
|
252
|
-
'ai.tool.delete_note': {};
|
|
253
|
-
'ai.tool.delete_task': {};
|
|
254
|
-
'ai.tool.delete_task_list': {};
|
|
255
|
-
'ai.tool.fetch_url': {};
|
|
256
|
-
'ai.tool.list_notes': {};
|
|
257
|
-
'ai.tool.list_tasks': {};
|
|
258
|
-
'ai.tool.list_timers': {};
|
|
259
|
-
'ai.tool.read_memory': {};
|
|
260
|
-
'ai.tool.read_note': {};
|
|
261
|
-
'ai.tool.search_web': {};
|
|
262
|
-
'ai.tool.set_timer': {};
|
|
263
|
-
'ai.tool.update_memory': {};
|
|
264
|
-
'ai.tool.update_note': {};
|
|
265
|
-
'ai.tool.update_task': {};
|
|
266
|
-
'ai.tool.update_task_list': {};
|
|
267
|
-
'ai.tool_awaiting': {};
|
|
268
|
-
'ai.tool_decision.always': {};
|
|
269
|
-
'ai.tool_decision.chat': {};
|
|
270
|
-
'ai.tool_decision.deny': {};
|
|
271
|
-
'ai.tool_decision.once': {};
|
|
272
|
-
'ai.tool_input': {};
|
|
273
|
-
'ai.tool_result': {};
|
|
274
|
-
'ai.unknown': {};
|
|
275
|
-
'ai.untitled': {};
|
|
276
|
-
'ai.voice.action.idle': {};
|
|
277
|
-
'ai.voice.action.listening': {};
|
|
278
|
-
'ai.voice.action.responding': {};
|
|
279
|
-
'ai.voice.action.speaking': {};
|
|
280
|
-
'ai.voice.action.transcribing': {};
|
|
281
|
-
'ai.voice.cancel': {};
|
|
282
|
-
'ai.voice.conversation': {};
|
|
283
|
-
'ai.voice.dictate': {};
|
|
284
|
-
'ai.voice.end': {};
|
|
285
|
-
'ai.voice.finish': {};
|
|
286
|
-
'ai.voice.listening': {};
|
|
287
|
-
'ai.voice.microphone_error': {
|
|
288
|
-
error: Value;
|
|
289
|
-
};
|
|
290
|
-
'ai.voice.phase.idle': {};
|
|
291
|
-
'ai.voice.phase.listening': {};
|
|
292
|
-
'ai.voice.phase.responding': {};
|
|
293
|
-
'ai.voice.phase.speaking': {};
|
|
294
|
-
'ai.voice.phase.transcribing': {};
|
|
295
|
-
'ai.voice.speak': {};
|
|
296
|
-
'ai.voice.stop_speaking': {};
|
|
297
|
-
'ai.voice.transcribing': {};
|
|
298
|
-
'app_name.ai': {};
|
|
299
|
-
}
|
|
300
|
-
}
|
package/dist/.locale.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/server/api.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/server/api.js
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { getConfig } from '@axium/core';
|
|
2
|
-
import { checkAuthForUser, requireSession } from '@axium/server/auth';
|
|
3
|
-
import { database } from '@axium/server/database';
|
|
4
|
-
import { error, parseBody, withError } from '@axium/server/requests';
|
|
5
|
-
import { addRoute } from '@axium/server/routes';
|
|
6
|
-
import * as z from 'zod';
|
|
7
|
-
import { AIConversationAction, AIConversationInit, AIMessageInit } from '../common.js';
|
|
8
|
-
import { cancel, emitMessage, generate, isGenerating, toMessage, withProgress } from './generation.js';
|
|
9
|
-
import { getModels } from './models.js';
|
|
10
|
-
async function authConversation(request, id) {
|
|
11
|
-
const conversation = await database
|
|
12
|
-
.selectFrom('ai_conversations')
|
|
13
|
-
.selectAll()
|
|
14
|
-
.where('id', '=', id)
|
|
15
|
-
.executeTakeFirstOrThrow()
|
|
16
|
-
.catch(withError('Conversation not found', 404));
|
|
17
|
-
await checkAuthForUser(request, conversation.userId);
|
|
18
|
-
return conversation;
|
|
19
|
-
}
|
|
20
|
-
function defaultModel() {
|
|
21
|
-
const model = getConfig('@axium/ai').default_model;
|
|
22
|
-
if (!model)
|
|
23
|
-
error(503, 'No default model is configured');
|
|
24
|
-
return model;
|
|
25
|
-
}
|
|
26
|
-
addRoute({
|
|
27
|
-
path: '/api/ai/models',
|
|
28
|
-
async GET(request) {
|
|
29
|
-
await requireSession(request);
|
|
30
|
-
return await getModels();
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
addRoute({
|
|
34
|
-
path: '/api/users/:id/ai/conversations',
|
|
35
|
-
params: { id: z.uuid() },
|
|
36
|
-
async GET(request, { id: userId }) {
|
|
37
|
-
await checkAuthForUser(request, userId);
|
|
38
|
-
return await database
|
|
39
|
-
.selectFrom('ai_conversations')
|
|
40
|
-
.selectAll()
|
|
41
|
-
.where('userId', '=', userId)
|
|
42
|
-
.orderBy('modified', 'desc')
|
|
43
|
-
.execute()
|
|
44
|
-
.catch(withError('Could not get conversations'));
|
|
45
|
-
},
|
|
46
|
-
async PUT(request, { id: userId }) {
|
|
47
|
-
const init = await parseBody(request, AIConversationInit);
|
|
48
|
-
await checkAuthForUser(request, userId);
|
|
49
|
-
return await database
|
|
50
|
-
.insertInto('ai_conversations')
|
|
51
|
-
.values({ title: init.title, model: init.model ?? defaultModel(), reasoning: init.reasoning, userId })
|
|
52
|
-
.returningAll()
|
|
53
|
-
.executeTakeFirstOrThrow()
|
|
54
|
-
.catch(withError('Could not create conversation'));
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
addRoute({
|
|
58
|
-
path: '/api/ai/conversations/:id',
|
|
59
|
-
params: { id: z.uuid() },
|
|
60
|
-
async GET(request, { id }) {
|
|
61
|
-
const conversation = await authConversation(request, id);
|
|
62
|
-
const messages = await database
|
|
63
|
-
.selectFrom('ai_messages')
|
|
64
|
-
.selectAll()
|
|
65
|
-
.where('conversationId', '=', id)
|
|
66
|
-
.orderBy('created')
|
|
67
|
-
.execute()
|
|
68
|
-
.catch(withError('Could not get messages'));
|
|
69
|
-
return { ...conversation, messages: messages.map(row => withProgress(toMessage(row))) };
|
|
70
|
-
},
|
|
71
|
-
async PATCH(request, { id }) {
|
|
72
|
-
const init = await parseBody(request, AIConversationInit);
|
|
73
|
-
await authConversation(request, id);
|
|
74
|
-
return await database
|
|
75
|
-
.updateTable('ai_conversations')
|
|
76
|
-
.set(init)
|
|
77
|
-
.where('id', '=', id)
|
|
78
|
-
.returningAll()
|
|
79
|
-
.executeTakeFirstOrThrow()
|
|
80
|
-
.catch(withError('Could not update conversation'));
|
|
81
|
-
},
|
|
82
|
-
async PUT(request, { id }) {
|
|
83
|
-
const { content } = await parseBody(request, AIMessageInit);
|
|
84
|
-
let conversation = await authConversation(request, id);
|
|
85
|
-
if (isGenerating(id))
|
|
86
|
-
error(409, 'A response is already being generated');
|
|
87
|
-
conversation = await database
|
|
88
|
-
.updateTable('ai_conversations')
|
|
89
|
-
.set({ modified: new Date(), title: conversation.title || content.slice(0, 60) })
|
|
90
|
-
.where('id', '=', id)
|
|
91
|
-
.returningAll()
|
|
92
|
-
.executeTakeFirstOrThrow()
|
|
93
|
-
.catch(withError('Could not update conversation'));
|
|
94
|
-
const user = await database
|
|
95
|
-
.insertInto('ai_messages')
|
|
96
|
-
.values({ conversationId: id, role: 'user', content })
|
|
97
|
-
.returningAll()
|
|
98
|
-
.executeTakeFirstOrThrow()
|
|
99
|
-
.catch(withError('Could not save message'));
|
|
100
|
-
const assistant = await database
|
|
101
|
-
.insertInto('ai_messages')
|
|
102
|
-
.values({ conversationId: id, role: 'assistant', status: 'pending' })
|
|
103
|
-
.returningAll()
|
|
104
|
-
.executeTakeFirstOrThrow()
|
|
105
|
-
.catch(withError('Could not save message'));
|
|
106
|
-
const messages = [toMessage(user), toMessage(assistant)];
|
|
107
|
-
for (const message of messages)
|
|
108
|
-
emitMessage(conversation.userId, message);
|
|
109
|
-
void generate(conversation, assistant);
|
|
110
|
-
return messages;
|
|
111
|
-
},
|
|
112
|
-
async POST(request, { id }) {
|
|
113
|
-
const { action } = await parseBody(request, AIConversationAction);
|
|
114
|
-
const conversation = await authConversation(request, id);
|
|
115
|
-
switch (action) {
|
|
116
|
-
case 'cancel':
|
|
117
|
-
if (!cancel(id))
|
|
118
|
-
error(409, 'No response is being generated');
|
|
119
|
-
return {};
|
|
120
|
-
case 'retry': {
|
|
121
|
-
if (isGenerating(id))
|
|
122
|
-
error(409, 'A response is already being generated');
|
|
123
|
-
const last = await database
|
|
124
|
-
.selectFrom('ai_messages')
|
|
125
|
-
.selectAll()
|
|
126
|
-
.where('conversationId', '=', id)
|
|
127
|
-
.orderBy('created', 'desc')
|
|
128
|
-
.limit(1)
|
|
129
|
-
.executeTakeFirst()
|
|
130
|
-
.catch(withError('Could not get messages'));
|
|
131
|
-
if (last?.role != 'assistant' || last.status == 'pending')
|
|
132
|
-
error(409, 'Only the last finished response can be retried');
|
|
133
|
-
const pending = await database
|
|
134
|
-
.updateTable('ai_messages')
|
|
135
|
-
.set({ content: '', reasoning: null, status: 'pending', error: null, usage: null })
|
|
136
|
-
.where('id', '=', last.id)
|
|
137
|
-
.returningAll()
|
|
138
|
-
.executeTakeFirstOrThrow()
|
|
139
|
-
.catch(withError('Could not update message'));
|
|
140
|
-
const message = toMessage(pending);
|
|
141
|
-
emitMessage(conversation.userId, message);
|
|
142
|
-
void generate(conversation, pending);
|
|
143
|
-
return { message };
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
async DELETE(request, { id }) {
|
|
148
|
-
await authConversation(request, id);
|
|
149
|
-
cancel(id);
|
|
150
|
-
return await database
|
|
151
|
-
.deleteFrom('ai_conversations')
|
|
152
|
-
.where('id', '=', id)
|
|
153
|
-
.returningAll()
|
|
154
|
-
.executeTakeFirstOrThrow()
|
|
155
|
-
.catch(withError('Could not delete conversation'));
|
|
156
|
-
},
|
|
157
|
-
});
|