@axium/ai 0.0.0-stage → 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.
Files changed (109) hide show
  1. package/LICENSE.md +157 -0
  2. package/README.md +2 -2
  3. package/db.json +114 -0
  4. package/dist/.locale.d.ts +300 -0
  5. package/dist/.locale.js +1 -0
  6. package/dist/client/cli.d.ts +1 -0
  7. package/dist/client/cli.js +224 -0
  8. package/dist/client/config.d.ts +196 -0
  9. package/dist/client/config.js +55 -0
  10. package/dist/client/hooks.d.ts +3 -0
  11. package/dist/client/hooks.js +32 -0
  12. package/dist/client/local.d.ts +17 -0
  13. package/dist/client/local.js +112 -0
  14. package/dist/common.d.ts +1318 -0
  15. package/dist/common.js +569 -0
  16. package/dist/hooks.d.ts +13 -0
  17. package/dist/hooks.js +34 -0
  18. package/dist/hub.d.ts +4 -0
  19. package/dist/hub.js +75 -0
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.js +1 -0
  22. package/dist/integrations/notes.d.ts +1 -0
  23. package/dist/integrations/notes.js +104 -0
  24. package/dist/integrations/tasks.d.ts +1 -0
  25. package/dist/integrations/tasks.js +157 -0
  26. package/dist/loop.d.ts +75 -0
  27. package/dist/loop.js +238 -0
  28. package/dist/memory.d.ts +107 -0
  29. package/dist/memory.js +193 -0
  30. package/dist/node/chat.d.ts +50 -0
  31. package/dist/node/chat.js +60 -0
  32. package/dist/node/llama.d.ts +115 -0
  33. package/dist/node/llama.js +385 -0
  34. package/dist/node/markdown.d.ts +6 -0
  35. package/dist/node/markdown.js +285 -0
  36. package/dist/node/models.d.ts +34 -0
  37. package/dist/node/models.js +287 -0
  38. package/dist/node/web.d.ts +1 -0
  39. package/dist/node/web.js +203 -0
  40. package/dist/server/api/conversations.d.ts +1 -0
  41. package/dist/server/api/conversations.js +216 -0
  42. package/dist/server/api/gateway.d.ts +1 -0
  43. package/dist/server/api/gateway.js +113 -0
  44. package/dist/server/api/memories.d.ts +1 -0
  45. package/dist/server/api/memories.js +129 -0
  46. package/dist/server/api/models.d.ts +1 -0
  47. package/dist/server/api/models.js +161 -0
  48. package/dist/server/api/temporary.d.ts +1 -0
  49. package/dist/server/api/temporary.js +50 -0
  50. package/dist/server/api/timers.d.ts +1 -0
  51. package/dist/server/api/timers.js +27 -0
  52. package/dist/server/api/voice.d.ts +1 -0
  53. package/dist/server/api/voice.js +188 -0
  54. package/dist/server/api.d.ts +1 -0
  55. package/dist/server/api.js +157 -0
  56. package/dist/server/generation.d.ts +38 -0
  57. package/dist/server/generation.js +299 -0
  58. package/dist/server/memory.d.ts +7 -0
  59. package/dist/server/memory.js +218 -0
  60. package/dist/server/models.d.ts +13 -0
  61. package/dist/server/models.js +59 -0
  62. package/dist/server/preferences.d.ts +3 -0
  63. package/dist/server/preferences.js +12 -0
  64. package/dist/server/timers.d.ts +7 -0
  65. package/dist/server/timers.js +66 -0
  66. package/dist/speech.d.ts +17 -0
  67. package/dist/speech.js +69 -0
  68. package/dist/timers.d.ts +1 -0
  69. package/dist/timers.js +67 -0
  70. package/dist/tools.d.ts +70 -0
  71. package/dist/tools.js +84 -0
  72. package/lib/ChatMessage.svelte +331 -0
  73. package/lib/Composer.svelte +234 -0
  74. package/lib/Conversation.svelte +433 -0
  75. package/lib/ConversationMenu.svelte +18 -0
  76. package/lib/ModelActions.svelte +71 -0
  77. package/lib/ModelOptions.svelte +101 -0
  78. package/lib/ModelStatus.svelte +49 -0
  79. package/lib/ToolCall.svelte +171 -0
  80. package/lib/VoiceMode.svelte +113 -0
  81. package/lib/actions.ts +21 -0
  82. package/lib/index.ts +7 -0
  83. package/lib/live.svelte.ts +113 -0
  84. package/lib/markdown.ts +40 -0
  85. package/lib/preferences.ts +13 -0
  86. package/lib/transition.ts +24 -0
  87. package/lib/tsconfig.json +14 -0
  88. package/lib/voice.svelte.ts +476 -0
  89. package/locales/en.json +316 -0
  90. package/package.json +139 -5
  91. package/routes/ai/+layout.svelte +177 -0
  92. package/routes/ai/+layout.ts +26 -0
  93. package/routes/ai/+page.svelte +109 -0
  94. package/routes/ai/TimerAlerts.svelte +51 -0
  95. package/routes/ai/Timers.svelte +121 -0
  96. package/routes/ai/[id]/+page.svelte +18 -0
  97. package/routes/ai/[id]/+page.ts +14 -0
  98. package/routes/ai/memory/+page.svelte +313 -0
  99. package/routes/ai/memory/+page.ts +10 -0
  100. package/routes/ai/memory/MemoryForm.svelte +111 -0
  101. package/routes/ai/models/+page.svelte +199 -0
  102. package/routes/ai/models/+page.ts +5 -0
  103. package/routes/ai/models/AddModel.svelte +240 -0
  104. package/routes/ai/models/MemoryMeter.svelte +120 -0
  105. package/routes/ai/models/Roles.svelte +159 -0
  106. package/routes/ai/models/[id]/+page.svelte +331 -0
  107. package/routes/ai/models/[id]/+page.ts +6 -0
  108. package/routes/ai/timers.svelte.ts +94 -0
  109. package/routes/tsconfig.json +14 -0
@@ -0,0 +1,316 @@
1
+ {
2
+ "app_name": {
3
+ "ai": "AI"
4
+ },
5
+ "ai": {
6
+ "action": {
7
+ "load": "Load",
8
+ "unload": "Unload",
9
+ "pause": "Pause",
10
+ "resume": "Resume"
11
+ },
12
+ "add": {
13
+ "download": "Download",
14
+ "id": "ID",
15
+ "id_taken": "Another model already uses this ID",
16
+ "name": "Name",
17
+ "no_quants": "This repository has no GGUF files llama.cpp can load",
18
+ "no_results": "No models found",
19
+ "pick_quant": "Pick a quantization",
20
+ "search": "Search Hugging Face",
21
+ "search_button": "Search",
22
+ "started": "Downloading {name}",
23
+ "title": "Add model"
24
+ },
25
+ "conversation_missing": "That conversation doesn't exist. It may have been deleted.",
26
+ "conversation_title": "AI — {title}",
27
+ "delete_body": "The model's files are deleted. Conversations using it switch to the default chat model.",
28
+ "delete_title": "Delete {name}?",
29
+ "detail": {
30
+ "added": "Added",
31
+ "context": "Context",
32
+ "context_loaded": "({count} while loaded)",
33
+ "default_reasoning": "Default reasoning",
34
+ "inputs": "Inputs",
35
+ "loading": "Loading",
36
+ "loading_note": "Changing these reloads the model the next time it is used.",
37
+ "memory_current": "Memory in use",
38
+ "memory_minimum": "Memory needed",
39
+ "size": "Size",
40
+ "source": "Source",
41
+ "system_prompt": "System prompt",
42
+ "system_prompt_default": "Uses the default system prompt",
43
+ "template_default": "(model default: {level})",
44
+ "outputs": "Outputs",
45
+ "roles": "Roles"
46
+ },
47
+ "empty": "What can I help with?",
48
+ "error": "The response failed: {error}",
49
+ "fit": {
50
+ "device": "Fits in VRAM",
51
+ "host": "Needs RAM",
52
+ "none": "Too large"
53
+ },
54
+ "modality": {
55
+ "text": "Text",
56
+ "image": "Images",
57
+ "audio": "Audio",
58
+ "video": "Video"
59
+ },
60
+ "load_failed": "Failed to load",
61
+ "model": "Model",
62
+ "model_deleted": "Deleted {name}",
63
+ "model_removed": "This model was deleted.",
64
+ "model_saved": "Model saved",
65
+ "model_title": "AI — {name}",
66
+ "memory": {
67
+ "title": "Memory",
68
+ "description": "What the assistant remembers about you. It uses these in new conversations.",
69
+ "disabled": "Memory is turned off in your AI preferences, so these aren't used.",
70
+ "empty": "Nothing remembered yet.",
71
+ "description_placeholder": "What this memory is about, in one line",
72
+ "id_placeholder": "id-in-kebab-case",
73
+ "id_invalid": "Use lowercase words separated by hyphens",
74
+ "content_placeholder": "Details (optional, Markdown)",
75
+ "add": "Add",
76
+ "edit": "Edit",
77
+ "save": "Save",
78
+ "delete": "Delete",
79
+ "delete_confirm": "Delete the memory \"{id}\"?",
80
+ "from_conversation": "From a conversation",
81
+ "source": {
82
+ "user": "Added by you",
83
+ "explicit": "Saved when you asked",
84
+ "inferred": "Saved by the assistant",
85
+ "periodic": "From reviewing conversations"
86
+ }
87
+ },
88
+ "models": "Models",
89
+ "models_title": "AI — Models",
90
+ "new": "New chat",
91
+ "no_models": "No models are available yet.",
92
+ "no_models_admin": "No models yet. Add one from Hugging Face to get started.",
93
+ "not_running": "llama-server is not running. Check the server log.",
94
+ "option": {
95
+ "automatic": "Automatic",
96
+ "context": "Context size (tokens)",
97
+ "device": "Devices",
98
+ "parallel": "Parallel requests",
99
+ "reserve": "VRAM to leave free (MiB)",
100
+ "mmproj": "Projector file",
101
+ "mmproj_default": "The repository's"
102
+ },
103
+ "placeholder": "Message",
104
+ "preferences": {
105
+ "model": "Default model",
106
+ "reasoning": "Default reasoning",
107
+ "ctrl_enter": "Send with Ctrl+Enter",
108
+ "instructions": "Custom instructions",
109
+ "tools": {
110
+ "$title": "Tools",
111
+ "account_access": "Access to your account",
112
+ "confirm_writes": "Confirm writes",
113
+ "web": "Web access",
114
+ "approvals": {
115
+ "$title": "Approvals by tool"
116
+ },
117
+ "memory": "Memory",
118
+ "memory_updates": "Review conversations to update memory"
119
+ }
120
+ },
121
+ "memory_updates": {
122
+ "frequency": {
123
+ "off": "Never",
124
+ "daily": "Daily",
125
+ "weekly": "Weekly"
126
+ },
127
+ "title": "Automatic updates",
128
+ "off": "Off. Turn them on in your AI preferences.",
129
+ "schedule": "{frequency}, next {next}",
130
+ "never_ran": "Not run yet",
131
+ "last": "Last updated {when}",
132
+ "changes": "{added} added, {updated} updated, {deleted} removed",
133
+ "running": "Updating...",
134
+ "run": "Update now",
135
+ "started": "Updating memories in the background"
136
+ },
137
+ "approval": {
138
+ "ask": "Ask first",
139
+ "allow": "Allow"
140
+ },
141
+ "config": {
142
+ "data_dir": "Data directory",
143
+ "system_prompt": "Default system prompt",
144
+ "timeout": "Response timeout (seconds)",
145
+ "max_steps": "Most steps per turn",
146
+ "search_url": "SearXNG URL",
147
+ "max_memories": "Most memories per user",
148
+ "max_memory_length": "Longest memory (characters)",
149
+ "speaker_reference": "Voice reference recording",
150
+ "speaker_reference_text": "Voice reference transcript",
151
+ "llama": {
152
+ "$title": "llama-server",
153
+ "command": "Command",
154
+ "host": "Host",
155
+ "port": "Port",
156
+ "models_max": "Most loaded models (0 for no limit)",
157
+ "memory_margin": "Memory to keep free (MiB)",
158
+ "defaults": {
159
+ "$title": "Default model options"
160
+ },
161
+ "hf_token": "Hugging Face token"
162
+ }
163
+ },
164
+ "data_access": {
165
+ "none": "None",
166
+ "read": "Read only",
167
+ "write": "Read and write"
168
+ },
169
+ "ram": {
170
+ "host": "RAM",
171
+ "other": "Other",
172
+ "split": "{device} VRAM, {host} RAM",
173
+ "title": "Memory",
174
+ "usage": "{used} of {total}"
175
+ },
176
+ "reasoning": "Reasoning",
177
+ "reasoning_default": "{level} (default)",
178
+ "reasoning_level": {
179
+ "default": "Default",
180
+ "none": "Off",
181
+ "minimal": "Minimal",
182
+ "low": "Low",
183
+ "medium": "Medium",
184
+ "high": "High",
185
+ "xhigh": "Extra",
186
+ "max": "Max"
187
+ },
188
+ "reasoning_on": "On",
189
+ "reasoning_template": "Model default ({level})",
190
+ "reasoning_toggle": "On or off",
191
+ "reasoning_unknown": "Learned the first time the model is loaded",
192
+ "edit": "Edit",
193
+ "retry": "Retry",
194
+ "save": "Save",
195
+ "send": "Send",
196
+ "settings": "Settings",
197
+ "speed": "{speed} tok/s",
198
+ "status": {
199
+ "unavailable": "Unavailable",
200
+ "downloading": "Downloading",
201
+ "incomplete": "Paused",
202
+ "unloaded": "Not loaded",
203
+ "loading": "Loading",
204
+ "loaded": "Loaded",
205
+ "sleeping": "Sleeping"
206
+ },
207
+ "stop": "Stop",
208
+ "stopped": "Stopped",
209
+ "thinking": "Thinking…",
210
+ "toast_deleted": "Conversation deleted",
211
+ "toast_renamed": "Conversation renamed",
212
+ "tokens": "{count} tokens",
213
+ "unknown": "Unknown",
214
+ "temporary": {
215
+ "title": "Temporary chat",
216
+ "toggle": "Temporary",
217
+ "description": "Temporary chats are never saved and won't appear in your history.",
218
+ "discard": "Discard",
219
+ "discard_confirm": "Leave this temporary chat? It will be lost.",
220
+ "anonymous": "Anonymous"
221
+ },
222
+ "tool": {
223
+ "fetch_url": "Read web page",
224
+ "search_web": "Web search",
225
+ "list_notes": "List notes",
226
+ "read_note": "Read note",
227
+ "create_note": "Created note",
228
+ "update_note": "Changed note",
229
+ "delete_note": "Deleted note",
230
+ "list_tasks": "List tasks",
231
+ "add_task": "Added task",
232
+ "update_task": "Changed task",
233
+ "delete_task": "Deleted task",
234
+ "create_task_list": "Created task list",
235
+ "update_task_list": "Changed task list",
236
+ "delete_task_list": "Deleted task list",
237
+ "read_memory": "Recalled memory",
238
+ "add_memory": "Saved memory",
239
+ "update_memory": "Updated memory",
240
+ "delete_memory": "Removed memory",
241
+ "set_timer": "Started timer",
242
+ "list_timers": "Checked timers",
243
+ "cancel_timer": "Cancelled timer"
244
+ },
245
+ "timer": {
246
+ "title": "Timer",
247
+ "count": "{count} timers",
248
+ "list": "Timers",
249
+ "done": "Time's up",
250
+ "cancel": "Cancel timer",
251
+ "dismiss": "Dismiss"
252
+ },
253
+ "tool_awaiting": "Allow this change?",
254
+ "tool_decision": {
255
+ "deny": "Deny",
256
+ "once": "Allow once",
257
+ "chat": "Allow in this chat",
258
+ "always": "Always allow"
259
+ },
260
+ "tool_input": "Input",
261
+ "tool_result": "Result",
262
+ "untitled": "New conversation",
263
+ "role": {
264
+ "title": "Roles",
265
+ "description": "Which models are used for each purpose, most preferred first.",
266
+ "add": "Add a model",
267
+ "none": "None",
268
+ "unavailable": "No model is available",
269
+ "fallback": "Using {name} as a fallback",
270
+ "serving": "In use for this role",
271
+ "move_up": "Prefer over the previous model",
272
+ "remove": "Remove",
273
+ "saved": "Roles saved",
274
+ "name": {
275
+ "chat": "Chat",
276
+ "assistant": "Assistant",
277
+ "coding": "Coding",
278
+ "stt": "Speech to text",
279
+ "tts": "Text to speech"
280
+ },
281
+ "about": {
282
+ "chat": "Conversations without a chosen model",
283
+ "assistant": "Quick tasks and voice",
284
+ "coding": "Claude Code and other coding tools",
285
+ "stt": "Transcribing speech; needs audio input",
286
+ "tts": "Speaking replies; needs audio output"
287
+ }
288
+ },
289
+ "voice": {
290
+ "dictate": "Dictate",
291
+ "listening": "Listening…",
292
+ "transcribing": "Transcribing…",
293
+ "finish": "Finish dictating",
294
+ "cancel": "Cancel dictation",
295
+ "microphone_error": "Could not use the microphone: {error}",
296
+ "speak": "Read aloud",
297
+ "stop_speaking": "Stop reading",
298
+ "conversation": "Talk",
299
+ "end": "End",
300
+ "phase": {
301
+ "idle": "Tap to talk",
302
+ "listening": "Listening…",
303
+ "transcribing": "Transcribing…",
304
+ "responding": "Thinking…",
305
+ "speaking": "Speaking. Tap to interrupt"
306
+ },
307
+ "action": {
308
+ "idle": "Start talking",
309
+ "listening": "Send now",
310
+ "transcribing": "Transcribing",
311
+ "responding": "Interrupt",
312
+ "speaking": "Interrupt"
313
+ }
314
+ }
315
+ }
316
+ }
package/package.json CHANGED
@@ -1,6 +1,140 @@
1
1
  {
2
- "name": "@axium/ai",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@axium/ai",
3
+ "version": "0.0.1",
4
+ "author": "James Prevett <axium@jamespre.dev>",
5
+ "description": "Local-first AI assistant for Axium",
6
+ "funding": {
7
+ "type": "individual",
8
+ "url": "https://github.com/sponsors/james-pre"
9
+ },
10
+ "license": "LGPL-3.0-or-later",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/james-pre/axium.git"
14
+ },
15
+ "homepage": "https://github.com/james-pre/axium#readme",
16
+ "bugs": {
17
+ "url": "https://github.com/james-pre/axium/issues"
18
+ },
19
+ "type": "module",
20
+ "main": "dist/index.js",
21
+ "types": "dist/index.d.ts",
22
+ "exports": {
23
+ ".": "./dist/index.js",
24
+ "./*": "./dist/*.js",
25
+ "./components": "./lib/index.js",
26
+ "./components/*": "./lib/*.svelte",
27
+ "./live": "./lib/live.svelte.js",
28
+ "./actions": "./lib/actions.js",
29
+ "./markdown": "./lib/markdown.js",
30
+ "./preferences": "./lib/preferences.js",
31
+ "./transition": "./lib/transition.js",
32
+ "./voice": "./lib/voice.svelte.js"
33
+ },
34
+ "files": [
35
+ "dist",
36
+ "lib",
37
+ "routes",
38
+ "locales",
39
+ "db.json"
40
+ ],
41
+ "scripts": {
42
+ "build": "tsc"
43
+ },
44
+ "peerDependencies": {
45
+ "@axium/client": ">=0.43.0",
46
+ "@axium/core": ">=0.45.0",
47
+ "@axium/notes": ">=0.4.10",
48
+ "@axium/server": ">=0.60.0",
49
+ "@axium/tasks": ">=0.5.13",
50
+ "@james-pre/config": "^1.2.0",
51
+ "@james-pre/locales": "^1.0.0",
52
+ "@sveltejs/kit": "^3.0.0",
53
+ "domhandler": "^6.0.1",
54
+ "kysely": "^0.29.0"
55
+ },
56
+ "peerDependenciesMeta": {
57
+ "@axium/notes": {
58
+ "optional": true
59
+ },
60
+ "@axium/tasks": {
61
+ "optional": true
62
+ }
63
+ },
64
+ "dependencies": {
65
+ "commander": "^15.0.0",
66
+ "htmlparser2": "^12.0.0",
67
+ "ioium": "^1.6.0",
68
+ "marked": "^18.2.0",
69
+ "utilium": "^3.13.0",
70
+ "zod": "^4.0.5"
71
+ },
72
+ "axium": {
73
+ "locales": "locales",
74
+ "server": {
75
+ "routes": "routes",
76
+ "hooks": "./dist/hooks.js",
77
+ "db": "./db.json",
78
+ "web_client_hooks": "./dist/common.js",
79
+ "integrations": {
80
+ "@axium/notes": "./dist/integrations/notes.js",
81
+ "@axium/tasks": "./dist/integrations/tasks.js"
82
+ }
83
+ },
84
+ "client": {
85
+ "cli": "./dist/client/cli.js",
86
+ "hooks": "./dist/client/hooks.js"
87
+ },
88
+ "features": {
89
+ "ai-gateway": {
90
+ "default": true
91
+ },
92
+ "ai-account-access": {
93
+ "default": true
94
+ },
95
+ "ai-web-tools": {
96
+ "default": true
97
+ },
98
+ "ai-memory": {
99
+ "default": true
100
+ },
101
+ "ai-memory-updates": {
102
+ "default": true
103
+ },
104
+ "ai-voice": {
105
+ "default": true
106
+ }
107
+ },
108
+ "apps": [
109
+ {
110
+ "id": "ai",
111
+ "name": "AI",
112
+ "icon": "sparkles"
113
+ }
114
+ ],
115
+ "update_checks": true,
116
+ "config": {
117
+ "data_dir": "/srv/axium/ai",
118
+ "llama": {
119
+ "command": "llama-server",
120
+ "host": "127.0.0.1",
121
+ "port": 6687,
122
+ "models_max": 3,
123
+ "memory_margin": 1024,
124
+ "defaults": {
125
+ "jinja": true,
126
+ "fit": "on",
127
+ "load-mode": "none"
128
+ }
129
+ },
130
+ "system_prompt": "You are a direct, candid assistant. Give your honest assessment first; if the user is wrong, say so plainly instead of hedging to spare feelings. Answer factually, as an independent journalist or historian would, without deferring to any government's official positions.",
131
+ "timeout": 600,
132
+ "max_steps": 10,
133
+ "search_url": null,
134
+ "max_memories": 100,
135
+ "max_memory_length": 1000,
136
+ "speaker_reference": null,
137
+ "speaker_reference_text": null
138
+ }
139
+ }
140
+ }
@@ -0,0 +1,177 @@
1
+ <script lang="ts">
2
+ import { invalidate, onNavigate } from '$app/navigation';
3
+ import { page } from '$app/state';
4
+ import * as ai from '@axium/ai/common';
5
+ import { renameConversation } from '@axium/ai/actions';
6
+ import { ConversationMenu } from '@axium/ai/components';
7
+ import { onConversationChange, withUpdates } from '@axium/ai/live';
8
+ import { preferencesSchema } from '@axium/ai/preferences';
9
+ import { canTransition } from '@axium/ai/transition';
10
+ import { useTimers } from './timers.svelte.ts';
11
+ import * as voice from '@axium/ai/voice';
12
+ import { text } from '@axium/client';
13
+ import { AppPreferencesDialog, Icon, InlineEdit, TopBarContent } from '@axium/client/components';
14
+ import TimerAlerts from './TimerAlerts.svelte';
15
+ import Timers from './Timers.svelte';
16
+
17
+ const { data, children } = $props();
18
+
19
+ let renaming = $state<string>();
20
+
21
+ const schema = $derived(preferencesSchema(withUpdates(data.models.models).filter(ai.isUsable)));
22
+
23
+ $effect(() => onConversationChange(() => invalidate('ai:conversations')));
24
+
25
+ $effect(() => voice.useModels({ models: withUpdates(data.models.models), roles: data.models.roles }));
26
+
27
+ $effect(() => useTimers(data.session.userId));
28
+
29
+ /** Animates the composer between the start page and a conversation */
30
+ onNavigate(navigation => {
31
+ if (!canTransition()) return;
32
+ if (navigation.from?.url.pathname != '/ai' && navigation.to?.url.pathname != '/ai') return;
33
+
34
+ return new Promise(resolve => {
35
+ document.startViewTransition(async () => {
36
+ resolve();
37
+ await navigation.complete;
38
+ });
39
+ });
40
+ });
41
+ </script>
42
+
43
+ <TopBarContent name={text('app_name.ai')} icon="sparkles" href="/ai" />
44
+
45
+ <div id="ai-app" class={[(page.params.id || page.url.pathname != '/ai') && 'in-page']}>
46
+ <nav id="ai-sidebar">
47
+ <a href="/ai" class="new icon-text">
48
+ <Icon i="plus" />
49
+ <span>{text('ai.new')}</span>
50
+ </a>
51
+ {#each data.conversations as conversation (conversation.id)}
52
+ <div class={['item', page.params.id == conversation.id && 'active']}>
53
+ {#if renaming == conversation.id}
54
+ <InlineEdit
55
+ value={conversation.title}
56
+ schema={ai.ConversationInit.shape.title}
57
+ commit={title => renameConversation(conversation.id, title)}
58
+ close={() => (renaming = undefined)}
59
+ />
60
+ {:else}
61
+ <a href="/ai/{conversation.id}">{conversation.title || text('ai.untitled')}</a>
62
+ <ConversationMenu id={conversation.id} onrename={() => (renaming = conversation.id)} />
63
+ {/if}
64
+ </div>
65
+ {/each}
66
+ <div class="footer">
67
+ <Timers />
68
+ <a href="/ai/memory" class={['icon-text', page.url.pathname == '/ai/memory' && 'active']}>
69
+ <Icon i="brain" />
70
+ <span>{text('ai.memory.title')}</span>
71
+ </a>
72
+ <a href="/ai/models" class={['icon-text', page.url.pathname.startsWith('/ai/models') && 'active']}>
73
+ <Icon i="microchip" />
74
+ <span>{text('ai.models')}</span>
75
+ </a>
76
+ <AppPreferencesDialog appId="ai" userId={data.session.userId} {schema} onsave={() => invalidate('ai:conversations')} />
77
+ </div>
78
+ </nav>
79
+
80
+ <main id="ai-main">
81
+ {@render children()}
82
+ </main>
83
+ </div>
84
+
85
+ <TimerAlerts />
86
+
87
+ <style>
88
+ #ai-app {
89
+ display: grid;
90
+ grid-template-columns: 15em 1fr;
91
+ position: fixed;
92
+ inset: var(--top-bar-height, 0px) 0 0;
93
+ }
94
+
95
+ #ai-sidebar {
96
+ display: flex;
97
+ flex-direction: column;
98
+ gap: 0.25em;
99
+ padding: 1em;
100
+ overflow-y: auto;
101
+
102
+ .new {
103
+ justify-content: center;
104
+ padding: 0.5em 1em;
105
+ margin-bottom: 1em;
106
+ border-radius: 1.5em;
107
+ background-color: var(--bg-alt);
108
+ }
109
+
110
+ .item {
111
+ display: flex;
112
+ align-items: center;
113
+ gap: 0.5em;
114
+ padding: 0.5em 1em;
115
+ border-radius: 1.5em;
116
+
117
+ a {
118
+ flex: 1;
119
+ overflow: hidden;
120
+ text-overflow: ellipsis;
121
+ white-space: nowrap;
122
+ }
123
+
124
+ &:hover {
125
+ background-color: var(--bg-alt);
126
+ }
127
+
128
+ &.active {
129
+ background-color: var(--bg-accent);
130
+ font-weight: bold;
131
+ }
132
+ }
133
+
134
+ .footer {
135
+ display: flex;
136
+ flex-direction: column;
137
+ gap: 0.25em;
138
+ margin-top: auto;
139
+ padding-top: 1em;
140
+
141
+ > :global(:not(dialog)) {
142
+ padding: 0.5em 1em;
143
+ border-radius: 1.5em;
144
+ }
145
+
146
+ a:hover,
147
+ a.active {
148
+ background-color: var(--bg-alt);
149
+ }
150
+ }
151
+ }
152
+
153
+ #ai-main {
154
+ min-width: 0;
155
+ min-height: 0;
156
+ margin: 0 1em 1em 0;
157
+ border-radius: 1em;
158
+ background-color: var(--bg-menu);
159
+ overflow: hidden;
160
+ }
161
+
162
+ @media (width < 700px) {
163
+ #ai-app {
164
+ grid-template-columns: 1fr;
165
+ }
166
+
167
+ #ai-main {
168
+ margin: 0;
169
+ border-radius: 0;
170
+ }
171
+
172
+ #ai-app.in-page #ai-sidebar,
173
+ #ai-app:not(.in-page) #ai-main {
174
+ display: none;
175
+ }
176
+ }
177
+ </style>
@@ -0,0 +1,26 @@
1
+ import '@axium/ai/common';
2
+ import { preferences } from '@axium/client';
3
+ import { fetchAPI } from '@axium/client/requests';
4
+ import { currentSession } from '@axium/client/user';
5
+ import type { Session, UserPublic } from '@axium/core';
6
+ import { redirect } from '@sveltejs/kit';
7
+
8
+ export const ssr = false;
9
+
10
+ export async function load({ parent, depends }) {
11
+ depends('ai:conversations');
12
+
13
+ let { session }: { session?: (Session & { user: UserPublic }) | null } = await parent();
14
+
15
+ session ||= await currentSession();
16
+
17
+ if (!session) redirect(307, '/login?after=/ai');
18
+
19
+ const [conversations, models, aiPreferences] = await Promise.all([
20
+ fetchAPI('GET', 'users/:id/ai/conversations', {}, session.userId),
21
+ fetchAPI('GET', 'ai/models'),
22
+ preferences.get(session.userId, 'ai'),
23
+ ]);
24
+
25
+ return { session, conversations, models, preferences: aiPreferences };
26
+ }