nao-core 0.0.11__py3-none-any.whl → 0.0.14__py3-none-any.whl

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 (39) hide show
  1. nao_core/__init__.py +1 -1
  2. nao_core/bin/db.sqlite +0 -0
  3. nao_core/bin/fastapi/main.py +102 -0
  4. nao_core/bin/migrations-postgres/0000_supreme_cable.sql +85 -0
  5. nao_core/bin/migrations-postgres/meta/0000_snapshot.json +610 -0
  6. nao_core/bin/migrations-postgres/meta/_journal.json +13 -0
  7. nao_core/bin/migrations-sqlite/0000_cloudy_squirrel_girl.sql +85 -0
  8. nao_core/bin/migrations-sqlite/meta/0000_snapshot.json +590 -0
  9. nao_core/bin/migrations-sqlite/meta/_journal.json +13 -0
  10. nao_core/bin/nao-chat-server +0 -0
  11. nao_core/bin/public/assets/_chatId-z5gRlor1.js +1 -0
  12. nao_core/bin/public/assets/chat-messages-DUR3D342.js +1 -0
  13. nao_core/bin/public/assets/index-BDlcD_HE.js +1 -0
  14. nao_core/bin/public/assets/index-Bc7icYyJ.css +1 -0
  15. nao_core/bin/public/assets/index-CGg3ZQH6.js +49 -0
  16. nao_core/bin/public/assets/login-D87n9R5V.js +1 -0
  17. nao_core/bin/public/assets/signinForm-9PY1Lvqj.js +1 -0
  18. nao_core/bin/public/assets/signup-B7NC1g08.js +1 -0
  19. nao_core/bin/public/github-icon.svg +19 -0
  20. nao_core/bin/public/google-icon.svg +2 -0
  21. nao_core/bin/public/index.html +2 -2
  22. nao_core/commands/chat.py +67 -25
  23. nao_core/commands/init.py +3 -3
  24. nao_core/commands/sync.py +274 -44
  25. nao_core/config/__init__.py +13 -0
  26. nao_core/{config.py → config/base.py} +4 -66
  27. nao_core/config/databases/__init__.py +29 -0
  28. nao_core/config/databases/base.py +72 -0
  29. nao_core/config/databases/bigquery.py +42 -0
  30. nao_core/config/llm/__init__.py +16 -0
  31. {nao_core-0.0.11.dist-info → nao_core-0.0.14.dist-info}/METADATA +3 -1
  32. nao_core-0.0.14.dist-info/RECORD +39 -0
  33. nao_core/bin/public/assets/index-BSxC58nD.js +0 -36
  34. nao_core/bin/public/assets/index-Dh3br3Ia.js +0 -13
  35. nao_core/bin/public/assets/index-heKLHGGE.css +0 -1
  36. nao_core-0.0.11.dist-info/RECORD +0 -20
  37. {nao_core-0.0.11.dist-info → nao_core-0.0.14.dist-info}/WHEEL +0 -0
  38. {nao_core-0.0.11.dist-info → nao_core-0.0.14.dist-info}/entry_points.txt +0 -0
  39. {nao_core-0.0.11.dist-info → nao_core-0.0.14.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,590 @@
1
+ {
2
+ "version": "6",
3
+ "dialect": "sqlite",
4
+ "id": "3f42e028-937d-4923-b9a2-9102012a7cc2",
5
+ "prevId": "00000000-0000-0000-0000-000000000000",
6
+ "tables": {
7
+ "account": {
8
+ "name": "account",
9
+ "columns": {
10
+ "id": {
11
+ "name": "id",
12
+ "type": "text",
13
+ "primaryKey": true,
14
+ "notNull": true,
15
+ "autoincrement": false
16
+ },
17
+ "account_id": {
18
+ "name": "account_id",
19
+ "type": "text",
20
+ "primaryKey": false,
21
+ "notNull": true,
22
+ "autoincrement": false
23
+ },
24
+ "provider_id": {
25
+ "name": "provider_id",
26
+ "type": "text",
27
+ "primaryKey": false,
28
+ "notNull": true,
29
+ "autoincrement": false
30
+ },
31
+ "user_id": {
32
+ "name": "user_id",
33
+ "type": "text",
34
+ "primaryKey": false,
35
+ "notNull": true,
36
+ "autoincrement": false
37
+ },
38
+ "access_token": {
39
+ "name": "access_token",
40
+ "type": "text",
41
+ "primaryKey": false,
42
+ "notNull": false,
43
+ "autoincrement": false
44
+ },
45
+ "refresh_token": {
46
+ "name": "refresh_token",
47
+ "type": "text",
48
+ "primaryKey": false,
49
+ "notNull": false,
50
+ "autoincrement": false
51
+ },
52
+ "id_token": {
53
+ "name": "id_token",
54
+ "type": "text",
55
+ "primaryKey": false,
56
+ "notNull": false,
57
+ "autoincrement": false
58
+ },
59
+ "access_token_expires_at": {
60
+ "name": "access_token_expires_at",
61
+ "type": "integer",
62
+ "primaryKey": false,
63
+ "notNull": false,
64
+ "autoincrement": false
65
+ },
66
+ "refresh_token_expires_at": {
67
+ "name": "refresh_token_expires_at",
68
+ "type": "integer",
69
+ "primaryKey": false,
70
+ "notNull": false,
71
+ "autoincrement": false
72
+ },
73
+ "scope": {
74
+ "name": "scope",
75
+ "type": "text",
76
+ "primaryKey": false,
77
+ "notNull": false,
78
+ "autoincrement": false
79
+ },
80
+ "password": {
81
+ "name": "password",
82
+ "type": "text",
83
+ "primaryKey": false,
84
+ "notNull": false,
85
+ "autoincrement": false
86
+ },
87
+ "created_at": {
88
+ "name": "created_at",
89
+ "type": "integer",
90
+ "primaryKey": false,
91
+ "notNull": true,
92
+ "autoincrement": false,
93
+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"
94
+ },
95
+ "updated_at": {
96
+ "name": "updated_at",
97
+ "type": "integer",
98
+ "primaryKey": false,
99
+ "notNull": true,
100
+ "autoincrement": false
101
+ }
102
+ },
103
+ "indexes": {
104
+ "account_userId_idx": {
105
+ "name": "account_userId_idx",
106
+ "columns": [
107
+ "user_id"
108
+ ],
109
+ "isUnique": false
110
+ }
111
+ },
112
+ "foreignKeys": {
113
+ "account_user_id_user_id_fk": {
114
+ "name": "account_user_id_user_id_fk",
115
+ "tableFrom": "account",
116
+ "tableTo": "user",
117
+ "columnsFrom": [
118
+ "user_id"
119
+ ],
120
+ "columnsTo": [
121
+ "id"
122
+ ],
123
+ "onDelete": "cascade",
124
+ "onUpdate": "no action"
125
+ }
126
+ },
127
+ "compositePrimaryKeys": {},
128
+ "uniqueConstraints": {},
129
+ "checkConstraints": {}
130
+ },
131
+ "chat_message": {
132
+ "name": "chat_message",
133
+ "columns": {
134
+ "id": {
135
+ "name": "id",
136
+ "type": "text",
137
+ "primaryKey": true,
138
+ "notNull": true,
139
+ "autoincrement": false
140
+ },
141
+ "conversation_id": {
142
+ "name": "conversation_id",
143
+ "type": "text",
144
+ "primaryKey": false,
145
+ "notNull": true,
146
+ "autoincrement": false
147
+ },
148
+ "role": {
149
+ "name": "role",
150
+ "type": "text",
151
+ "primaryKey": false,
152
+ "notNull": true,
153
+ "autoincrement": false
154
+ },
155
+ "content": {
156
+ "name": "content",
157
+ "type": "text",
158
+ "primaryKey": false,
159
+ "notNull": true,
160
+ "autoincrement": false
161
+ },
162
+ "created_at": {
163
+ "name": "created_at",
164
+ "type": "integer",
165
+ "primaryKey": false,
166
+ "notNull": true,
167
+ "autoincrement": false,
168
+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"
169
+ }
170
+ },
171
+ "indexes": {
172
+ "chat_message_conversationId_idx": {
173
+ "name": "chat_message_conversationId_idx",
174
+ "columns": [
175
+ "conversation_id"
176
+ ],
177
+ "isUnique": false
178
+ }
179
+ },
180
+ "foreignKeys": {
181
+ "chat_message_conversation_id_conversation_id_fk": {
182
+ "name": "chat_message_conversation_id_conversation_id_fk",
183
+ "tableFrom": "chat_message",
184
+ "tableTo": "conversation",
185
+ "columnsFrom": [
186
+ "conversation_id"
187
+ ],
188
+ "columnsTo": [
189
+ "id"
190
+ ],
191
+ "onDelete": "cascade",
192
+ "onUpdate": "no action"
193
+ }
194
+ },
195
+ "compositePrimaryKeys": {},
196
+ "uniqueConstraints": {},
197
+ "checkConstraints": {}
198
+ },
199
+ "conversation": {
200
+ "name": "conversation",
201
+ "columns": {
202
+ "id": {
203
+ "name": "id",
204
+ "type": "text",
205
+ "primaryKey": true,
206
+ "notNull": true,
207
+ "autoincrement": false
208
+ },
209
+ "user_id": {
210
+ "name": "user_id",
211
+ "type": "text",
212
+ "primaryKey": false,
213
+ "notNull": true,
214
+ "autoincrement": false
215
+ },
216
+ "title": {
217
+ "name": "title",
218
+ "type": "text",
219
+ "primaryKey": false,
220
+ "notNull": true,
221
+ "autoincrement": false,
222
+ "default": "'New Conversation'"
223
+ },
224
+ "created_at": {
225
+ "name": "created_at",
226
+ "type": "integer",
227
+ "primaryKey": false,
228
+ "notNull": true,
229
+ "autoincrement": false,
230
+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"
231
+ },
232
+ "updated_at": {
233
+ "name": "updated_at",
234
+ "type": "integer",
235
+ "primaryKey": false,
236
+ "notNull": true,
237
+ "autoincrement": false,
238
+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"
239
+ }
240
+ },
241
+ "indexes": {
242
+ "conversation_userId_idx": {
243
+ "name": "conversation_userId_idx",
244
+ "columns": [
245
+ "user_id"
246
+ ],
247
+ "isUnique": false
248
+ }
249
+ },
250
+ "foreignKeys": {
251
+ "conversation_user_id_user_id_fk": {
252
+ "name": "conversation_user_id_user_id_fk",
253
+ "tableFrom": "conversation",
254
+ "tableTo": "user",
255
+ "columnsFrom": [
256
+ "user_id"
257
+ ],
258
+ "columnsTo": [
259
+ "id"
260
+ ],
261
+ "onDelete": "cascade",
262
+ "onUpdate": "no action"
263
+ }
264
+ },
265
+ "compositePrimaryKeys": {},
266
+ "uniqueConstraints": {},
267
+ "checkConstraints": {}
268
+ },
269
+ "session": {
270
+ "name": "session",
271
+ "columns": {
272
+ "id": {
273
+ "name": "id",
274
+ "type": "text",
275
+ "primaryKey": true,
276
+ "notNull": true,
277
+ "autoincrement": false
278
+ },
279
+ "expires_at": {
280
+ "name": "expires_at",
281
+ "type": "integer",
282
+ "primaryKey": false,
283
+ "notNull": true,
284
+ "autoincrement": false
285
+ },
286
+ "token": {
287
+ "name": "token",
288
+ "type": "text",
289
+ "primaryKey": false,
290
+ "notNull": true,
291
+ "autoincrement": false
292
+ },
293
+ "created_at": {
294
+ "name": "created_at",
295
+ "type": "integer",
296
+ "primaryKey": false,
297
+ "notNull": true,
298
+ "autoincrement": false,
299
+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"
300
+ },
301
+ "updated_at": {
302
+ "name": "updated_at",
303
+ "type": "integer",
304
+ "primaryKey": false,
305
+ "notNull": true,
306
+ "autoincrement": false
307
+ },
308
+ "ip_address": {
309
+ "name": "ip_address",
310
+ "type": "text",
311
+ "primaryKey": false,
312
+ "notNull": false,
313
+ "autoincrement": false
314
+ },
315
+ "user_agent": {
316
+ "name": "user_agent",
317
+ "type": "text",
318
+ "primaryKey": false,
319
+ "notNull": false,
320
+ "autoincrement": false
321
+ },
322
+ "user_id": {
323
+ "name": "user_id",
324
+ "type": "text",
325
+ "primaryKey": false,
326
+ "notNull": true,
327
+ "autoincrement": false
328
+ }
329
+ },
330
+ "indexes": {
331
+ "session_token_unique": {
332
+ "name": "session_token_unique",
333
+ "columns": [
334
+ "token"
335
+ ],
336
+ "isUnique": true
337
+ },
338
+ "session_userId_idx": {
339
+ "name": "session_userId_idx",
340
+ "columns": [
341
+ "user_id"
342
+ ],
343
+ "isUnique": false
344
+ }
345
+ },
346
+ "foreignKeys": {
347
+ "session_user_id_user_id_fk": {
348
+ "name": "session_user_id_user_id_fk",
349
+ "tableFrom": "session",
350
+ "tableTo": "user",
351
+ "columnsFrom": [
352
+ "user_id"
353
+ ],
354
+ "columnsTo": [
355
+ "id"
356
+ ],
357
+ "onDelete": "cascade",
358
+ "onUpdate": "no action"
359
+ }
360
+ },
361
+ "compositePrimaryKeys": {},
362
+ "uniqueConstraints": {},
363
+ "checkConstraints": {}
364
+ },
365
+ "tool_call": {
366
+ "name": "tool_call",
367
+ "columns": {
368
+ "id": {
369
+ "name": "id",
370
+ "type": "text",
371
+ "primaryKey": true,
372
+ "notNull": true,
373
+ "autoincrement": false
374
+ },
375
+ "message_id": {
376
+ "name": "message_id",
377
+ "type": "text",
378
+ "primaryKey": false,
379
+ "notNull": true,
380
+ "autoincrement": false
381
+ },
382
+ "tool_call_id": {
383
+ "name": "tool_call_id",
384
+ "type": "text",
385
+ "primaryKey": false,
386
+ "notNull": true,
387
+ "autoincrement": false
388
+ },
389
+ "tool_name": {
390
+ "name": "tool_name",
391
+ "type": "text",
392
+ "primaryKey": false,
393
+ "notNull": true,
394
+ "autoincrement": false
395
+ },
396
+ "input": {
397
+ "name": "input",
398
+ "type": "text",
399
+ "primaryKey": false,
400
+ "notNull": true,
401
+ "autoincrement": false
402
+ },
403
+ "output": {
404
+ "name": "output",
405
+ "type": "text",
406
+ "primaryKey": false,
407
+ "notNull": false,
408
+ "autoincrement": false
409
+ },
410
+ "created_at": {
411
+ "name": "created_at",
412
+ "type": "integer",
413
+ "primaryKey": false,
414
+ "notNull": true,
415
+ "autoincrement": false,
416
+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"
417
+ }
418
+ },
419
+ "indexes": {
420
+ "tool_call_messageId_idx": {
421
+ "name": "tool_call_messageId_idx",
422
+ "columns": [
423
+ "message_id"
424
+ ],
425
+ "isUnique": false
426
+ }
427
+ },
428
+ "foreignKeys": {
429
+ "tool_call_message_id_chat_message_id_fk": {
430
+ "name": "tool_call_message_id_chat_message_id_fk",
431
+ "tableFrom": "tool_call",
432
+ "tableTo": "chat_message",
433
+ "columnsFrom": [
434
+ "message_id"
435
+ ],
436
+ "columnsTo": [
437
+ "id"
438
+ ],
439
+ "onDelete": "cascade",
440
+ "onUpdate": "no action"
441
+ }
442
+ },
443
+ "compositePrimaryKeys": {},
444
+ "uniqueConstraints": {},
445
+ "checkConstraints": {}
446
+ },
447
+ "user": {
448
+ "name": "user",
449
+ "columns": {
450
+ "id": {
451
+ "name": "id",
452
+ "type": "text",
453
+ "primaryKey": true,
454
+ "notNull": true,
455
+ "autoincrement": false
456
+ },
457
+ "name": {
458
+ "name": "name",
459
+ "type": "text",
460
+ "primaryKey": false,
461
+ "notNull": true,
462
+ "autoincrement": false
463
+ },
464
+ "email": {
465
+ "name": "email",
466
+ "type": "text",
467
+ "primaryKey": false,
468
+ "notNull": true,
469
+ "autoincrement": false
470
+ },
471
+ "email_verified": {
472
+ "name": "email_verified",
473
+ "type": "integer",
474
+ "primaryKey": false,
475
+ "notNull": true,
476
+ "autoincrement": false,
477
+ "default": false
478
+ },
479
+ "image": {
480
+ "name": "image",
481
+ "type": "text",
482
+ "primaryKey": false,
483
+ "notNull": false,
484
+ "autoincrement": false
485
+ },
486
+ "created_at": {
487
+ "name": "created_at",
488
+ "type": "integer",
489
+ "primaryKey": false,
490
+ "notNull": true,
491
+ "autoincrement": false,
492
+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"
493
+ },
494
+ "updated_at": {
495
+ "name": "updated_at",
496
+ "type": "integer",
497
+ "primaryKey": false,
498
+ "notNull": true,
499
+ "autoincrement": false,
500
+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"
501
+ }
502
+ },
503
+ "indexes": {
504
+ "user_email_unique": {
505
+ "name": "user_email_unique",
506
+ "columns": [
507
+ "email"
508
+ ],
509
+ "isUnique": true
510
+ }
511
+ },
512
+ "foreignKeys": {},
513
+ "compositePrimaryKeys": {},
514
+ "uniqueConstraints": {},
515
+ "checkConstraints": {}
516
+ },
517
+ "verification": {
518
+ "name": "verification",
519
+ "columns": {
520
+ "id": {
521
+ "name": "id",
522
+ "type": "text",
523
+ "primaryKey": true,
524
+ "notNull": true,
525
+ "autoincrement": false
526
+ },
527
+ "identifier": {
528
+ "name": "identifier",
529
+ "type": "text",
530
+ "primaryKey": false,
531
+ "notNull": true,
532
+ "autoincrement": false
533
+ },
534
+ "value": {
535
+ "name": "value",
536
+ "type": "text",
537
+ "primaryKey": false,
538
+ "notNull": true,
539
+ "autoincrement": false
540
+ },
541
+ "expires_at": {
542
+ "name": "expires_at",
543
+ "type": "integer",
544
+ "primaryKey": false,
545
+ "notNull": true,
546
+ "autoincrement": false
547
+ },
548
+ "created_at": {
549
+ "name": "created_at",
550
+ "type": "integer",
551
+ "primaryKey": false,
552
+ "notNull": true,
553
+ "autoincrement": false,
554
+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"
555
+ },
556
+ "updated_at": {
557
+ "name": "updated_at",
558
+ "type": "integer",
559
+ "primaryKey": false,
560
+ "notNull": true,
561
+ "autoincrement": false,
562
+ "default": "(cast(unixepoch('subsecond') * 1000 as integer))"
563
+ }
564
+ },
565
+ "indexes": {
566
+ "verification_identifier_idx": {
567
+ "name": "verification_identifier_idx",
568
+ "columns": [
569
+ "identifier"
570
+ ],
571
+ "isUnique": false
572
+ }
573
+ },
574
+ "foreignKeys": {},
575
+ "compositePrimaryKeys": {},
576
+ "uniqueConstraints": {},
577
+ "checkConstraints": {}
578
+ }
579
+ },
580
+ "views": {},
581
+ "enums": {},
582
+ "_meta": {
583
+ "schemas": {},
584
+ "tables": {},
585
+ "columns": {}
586
+ },
587
+ "internal": {
588
+ "indexes": {}
589
+ }
590
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "version": "7",
3
+ "dialect": "sqlite",
4
+ "entries": [
5
+ {
6
+ "idx": 0,
7
+ "version": "6",
8
+ "when": 1767804099092,
9
+ "tag": "0000_cloudy_squirrel_girl",
10
+ "breakpoints": true
11
+ }
12
+ ]
13
+ }
Binary file
@@ -0,0 +1 @@
1
+ import{d as t,e as a,j as e}from"./index-CGg3ZQH6.js";import{S as n,C as r}from"./chat-messages-DUR3D342.js";function m(){const{chatId:s}=t({from:"/$chatId"});return a({chatId:s}).isFetching?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx(n,{})}):e.jsx(r,{},s)}export{m as component};
@@ -0,0 +1 @@
1
+ import{c as D,j as r,f as q,a as g,r as c,i as U,g as O,B as P,h as G,k as J,l as X}from"./index-CGg3ZQH6.js";const K=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],V=D("arrow-down",K);const W=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Y=D("chevron-right",W);function $({className:t,...n}){return r.jsx(q,{role:"status","aria-label":"Loading",className:g("size-4 animate-spin opacity-50",t),...n})}const Q=c.createContext(null),Z=({toolPart:t,onClick:n})=>{const[o,l]=c.useState(!1),[u,T]=c.useState(!1),v=!!t.errorText||!!t.output,x=n||v,S=U(t),d=O(t),p=()=>{v?l(!o):n&&!v&&n()};return r.jsx(Q.Provider,{value:{isHovering:u,isExpanded:o},children:r.jsxs("div",{onMouseEnter:()=>T(!0),onMouseLeave:()=>T(!1),children:[r.jsxs("span",{className:g("select-none flex items-center gap-2 min-w-0 overflow-hidden text-ellipsis whitespace-nowrap [&_*]:overflow-hidden [&_*]:text-ellipsis [&_*]:whitespace-nowrap transition-opacity duration-150",o?"opacity-100":"opacity-50",x&&!o?"cursor-pointer hover:opacity-75":x?"cursor-pointer":""),onClick:p,children:[S?r.jsx(Y,{size:12,className:g(o?"rotate-90":"")}):r.jsx($,{className:"size-4 opacity-50"}),r.jsx("span",{className:g(S?"":"text-shimmer"),children:d})]}),o&&v&&r.jsxs("div",{className:"pl-5 mt-1.5 bg-backgroundSecondary relative",children:[r.jsx("div",{className:"h-full border-l border-l-border absolute top-0 left-[6px]"}),r.jsx("div",{children:t.errorText?r.jsx("pre",{className:"p-2 overflow-auto max-h-80 m-0 bg-red-950",children:t.errorText}):t.output?r.jsx("pre",{className:"overflow-auto max-h-80 m-0",children:JSON.stringify(t.output,null,2)}):null})]})]})})};const ee={damping:.7,stiffness:.05,mass:1.25},te=70,ne=1e3/60,re=350;let A=!1;globalThis.document?.addEventListener("mousedown",()=>{A=!0});globalThis.document?.addEventListener("mouseup",()=>{A=!1});globalThis.document?.addEventListener("click",()=>{A=!1});const se=(t={})=>{const[n,o]=c.useState(!1),[l,u]=c.useState(t.initial!==!1),[T,v]=c.useState(!1),x=c.useRef(null);x.current=t;const S=c.useCallback(()=>{if(!A)return!1;const s=window.getSelection();if(!s||!s.rangeCount)return!1;const i=s.getRangeAt(0);return i.commonAncestorContainer.contains(f.current)||f.current?.contains(i.commonAncestorContainer)},[]),d=c.useCallback(s=>{e.isAtBottom=s,u(s)},[]),p=c.useCallback(s=>{e.escapedFromLock=s,o(s)},[]),e=c.useMemo(()=>{let s;return{escapedFromLock:n,isAtBottom:l,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return f.current?.scrollTop??0},set scrollTop(i){f.current&&(f.current.scrollTop=i,e.ignoreScrollToTop=f.current.scrollTop)},get targetScrollTop(){return!f.current||!j.current?0:f.current.scrollHeight-1-f.current.clientHeight},get calculatedTargetScrollTop(){if(!f.current||!j.current)return 0;const{targetScrollTop:i}=this;if(!t.targetScrollTop)return i;if(s?.targetScrollTop===i)return s.calculatedScrollTop;const a=Math.max(Math.min(t.targetScrollTop(i,{scrollElement:f.current,contentElement:j.current}),i),0);return s={targetScrollTop:i,calculatedScrollTop:a},requestAnimationFrame(()=>{s=void 0}),a},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=te}}},[]),y=c.useCallback((s={})=>{typeof s=="string"&&(s={animation:s}),s.preserveScrollPosition||d(!0);const i=Date.now()+(Number(s.wait)||0),a=M(x.current,s.animation),{ignoreEscapes:m=!1}=s;let h,w=e.calculatedTargetScrollTop;s.duration instanceof Promise?s.duration.finally(()=>{h=Date.now()}):h=i+(s.duration??0);const b=async()=>{const R=new Promise(requestAnimationFrame).then(()=>{if(!e.isAtBottom)return e.animation=void 0,!1;const{scrollTop:E}=e,I=performance.now(),H=(I-(e.lastTick??I))/ne;if(e.animation||(e.animation={behavior:a,promise:R,ignoreEscapes:m}),e.animation.behavior===a&&(e.lastTick=I),S()||i>Date.now())return b();if(E<Math.min(w,e.calculatedTargetScrollTop)){if(e.animation?.behavior===a){if(a==="instant")return e.scrollTop=e.calculatedTargetScrollTop,b();e.velocity=(a.damping*e.velocity+a.stiffness*e.scrollDifference)/a.mass,e.accumulated+=e.velocity*H,e.scrollTop+=e.accumulated,e.scrollTop!==E&&(e.accumulated=0)}return b()}return h>Date.now()?(w=e.calculatedTargetScrollTop,b()):(e.animation=void 0,e.scrollTop<e.calculatedTargetScrollTop?y({animation:M(x.current,x.current.resize),ignoreEscapes:m,duration:Math.max(0,h-Date.now())||void 0}):e.isAtBottom)});return R.then(E=>(requestAnimationFrame(()=>{e.animation||(e.lastTick=void 0,e.velocity=0)}),E))};return s.wait!==!0&&(e.animation=void 0),e.animation?.behavior===a?e.animation.promise:b()},[d,S,e]),N=c.useCallback(()=>{p(!0),d(!1)},[p,d]),C=c.useCallback(({target:s})=>{if(s!==f.current)return;const{scrollTop:i,ignoreScrollToTop:a}=e;let{lastScrollTop:m=i}=e;e.lastScrollTop=i,e.ignoreScrollToTop=void 0,a&&a>i&&(m=a),v(e.isNearBottom),setTimeout(()=>{if(e.resizeDifference||i===a)return;if(S()){p(!0),d(!1);return}const h=i>m,w=i<m;if(e.animation?.ignoreEscapes){e.scrollTop=m;return}w&&(p(!0),d(!1)),h&&p(!1),!e.escapedFromLock&&e.isNearBottom&&d(!0)},1)},[p,d,S,e]),k=c.useCallback(({target:s,deltaY:i})=>{let a=s;for(;!["scroll","auto"].includes(getComputedStyle(a).overflow);){if(!a.parentElement)return;a=a.parentElement}a===f.current&&i<0&&f.current.scrollHeight>f.current.clientHeight&&!e.animation?.ignoreEscapes&&(p(!0),d(!1))},[p,d,e]),f=z(s=>{f.current?.removeEventListener("scroll",C),f.current?.removeEventListener("wheel",k),s?.addEventListener("scroll",C,{passive:!0}),s?.addEventListener("wheel",k,{passive:!0})},[]),j=z(s=>{if(e.resizeObserver?.disconnect(),!s)return;let i;e.resizeObserver=new ResizeObserver(([a])=>{const{height:m}=a.contentRect,h=m-(i??m);if(e.resizeDifference=h,e.scrollTop>e.targetScrollTop&&(e.scrollTop=e.targetScrollTop),v(e.isNearBottom),h>=0){const w=M(x.current,i?x.current.resize:x.current.initial);y({animation:w,wait:!0,preserveScrollPosition:!0,duration:w==="instant"?void 0:re})}else e.isNearBottom&&(p(!1),d(!0));i=m,requestAnimationFrame(()=>{setTimeout(()=>{e.resizeDifference===h&&(e.resizeDifference=0)},1)})}),e.resizeObserver?.observe(s)},[]);return{contentRef:j,scrollRef:f,scrollToBottom:y,stopScroll:N,isAtBottom:l||T,isNearBottom:T,escapedFromLock:n,state:e}};function z(t,n){const o=c.useCallback(l=>(o.current=l,t(l)),n);return o}const L=new Map;function M(...t){const n={...ee};let o=!1;for(const u of t){if(u==="instant"){o=!0;continue}typeof u=="object"&&(o=!1,n.damping=u.damping??n.damping,n.stiffness=u.stiffness??n.stiffness,n.mass=u.mass??n.mass)}const l=JSON.stringify(n);return L.has(l)||L.set(l,Object.freeze(n)),o?"instant":L.get(l)}const _=c.createContext(null),oe=typeof window<"u"?c.useLayoutEffect:c.useEffect;function B({instance:t,children:n,resize:o,initial:l,mass:u,damping:T,stiffness:v,targetScrollTop:x,contextRef:S,...d}){const p=c.useRef(null),e=c.useCallback((m,h)=>(a?.targetScrollTop??x)?.(m,h)??m,[x]),y=se({mass:u,damping:T,stiffness:v,resize:o,initial:l,targetScrollTop:e}),{scrollRef:N,contentRef:C,scrollToBottom:k,stopScroll:f,isAtBottom:j,escapedFromLock:s,state:i}=t??y,a=c.useMemo(()=>({scrollToBottom:k,stopScroll:f,scrollRef:N,isAtBottom:j,escapedFromLock:s,contentRef:C,state:i,get targetScrollTop(){return p.current},set targetScrollTop(m){p.current=m}}),[k,j,C,N,f,s,i]);return c.useImperativeHandle(S,()=>a,[a]),oe(()=>{N.current&&getComputedStyle(N.current).overflow==="visible"&&(N.current.style.overflow="auto")},[]),r.jsx(_.Provider,{value:a,children:r.jsx("div",{...d,children:typeof n=="function"?n(a):n})})}(function(t){function n({children:o,...l}){const u=F();return r.jsx("div",{ref:u.scrollRef,style:{height:"100%",width:"100%"},children:r.jsx("div",{...l,ref:u.contentRef,children:typeof o=="function"?o(u):o})})}t.Content=n})(B||(B={}));function F(){const t=c.useContext(_);if(!t)throw new Error("use-stick-to-bottom component context must be used within a StickToBottom component");return t}const ae=({className:t,...n})=>r.jsx(B,{className:g("relative flex-1 overflow-y-hidden",t),initial:"instant",resize:"smooth",role:"",...n}),ie=({className:t,...n})=>r.jsx(B.Content,{className:g("flex flex-col gap-8 p-4",t),...n}),ce=({className:t,title:n="No messages yet",description:o="Start a conversation to see messages here",icon:l,children:u,...T})=>r.jsx("div",{className:g("flex size-full flex-col items-center justify-center gap-3 p-8 text-center",t),...T,children:u??r.jsxs(r.Fragment,{children:[l&&r.jsx("div",{className:"text-muted-foreground",children:l}),r.jsxs("div",{className:"space-y-1",children:[r.jsx("h3",{className:"font-medium text-sm",children:n}),o&&r.jsx("p",{className:"text-muted-foreground text-sm",children:o})]})]})}),le=({className:t,...n})=>{const{isAtBottom:o,scrollToBottom:l}=F(),u=c.useCallback(()=>{l()},[l]);return!o&&r.jsx(P,{className:g("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full",t),onClick:u,size:"icon",type:"button",variant:"outline",...n,children:r.jsx(V,{className:"size-4"})})},ue=()=>r.jsx("div",{className:"px-4 py-2 h-[40px] flex items-center",children:r.jsx("div",{className:"chat-response-loading"})});function xe(){const{messages:t,status:n}=G(),o=J(n,t),l=n==="streaming"||n==="submitted";return r.jsxs(ae,{className:"w-full",children:[r.jsxs(ie,{children:[t.length===0?r.jsx(ce,{}):t.map(u=>r.jsx(fe,{message:u},u.id)),!o&&l&&r.jsx(ue,{})]}),r.jsx(le,{})]})}function fe({message:t}){const n=t.role==="user";return t.parts.length===0?null:n?r.jsx(me,{message:t}):r.jsx(de,{message:t})}const me=({message:t})=>r.jsx("div",{className:g("rounded-3xl px-4 py-2 bg-primary text-primary-foreground ml-auto"),children:t.parts.map((n,o)=>n.type==="text"?r.jsx("span",{className:"whitespace-pre-wrap",children:n.text},o):null)}),de=({message:t})=>r.jsx("div",{className:g("rounded-2xl px-4 py-2 bg-muted flex flex-col gap-2"),children:t.parts.map((n,o)=>X(n)?r.jsx(Z,{toolPart:n},o):n.type==="text"?r.jsx("span",{className:"whitespace-pre-wrap",children:n.text},o):null)});export{xe as C,$ as S};
@@ -0,0 +1 @@
1
+ import{j as o}from"./index-CGg3ZQH6.js";import{C as t}from"./chat-messages-DUR3D342.js";function n(){return o.jsx(t,{})}export{n as component};