importtype{ AppState, ChatContextRef, ChatMessage, Goal, Note }from"./types";import{
cap1,
fmtDayMon,
fromISODate,
goalProgress,
pct,
toISODate,}from"./utils";/* ================= online mode: OpenAI-compatible call ================= */exportinterfaceApiMessage{
role:"system"|"user"|"assistant";
content:|string|(|{ type:"text"; text:string}|{ type:"image_url"; image_url: url
state AppState
todayISO
lines
stateaiinstructions
lines stateaiinstructions
lines
notes statenotesn ndeletedAt
lines
n notes
list nchecklistlength
preview nbody
lines
lines
g stategoals
lines
todayTasks
g stategoals
w gweeks
d wdays
ddate todayISO
t dtasks
todayTasks
lines
linestodayTaskslength todayTasks
lines
upcoming stateevents
e edate todayISO
a b adatebdate
upcominglength
e upcoming
d edate
lines
lines
lines
refs ChatContextRef state AppState
parts
ref refs
reftype
n statenotesx xid refid
n
parts
nchecklistlength
g stategoalsx xid refid
g
structure gweeks
w
tasks wdays
d dtaskst
parts
parts
state AppState
dialogMessages ChatMessage
userText
refs ChatContextRef
images
baseUrl apiKey model stateai
history ApiMessage dialogMessages
m role mrole content mtext
ctxText refs state
userContent ApiMessage
imageslength
type
text
ctxText
userText
imagesurl
type
image_url url
ctxText
userText
res
method
headers
Authorization
body
model
messages
role content state
history
role content userContent
temperature
resok
body res
json res
content jsonchoicesmessagecontent
content content
content
s AppState
saiapiKey saibaseUrl saimodel
note Note text
parts
wantsSummary text
firstLine notebodyl l
firstLine
parts
wantsSummary
parts
notechecklistlength
done notechecklistc cdonelength
next notechecklistc cdone
parts
next
parts
goal Goal text
p goal
parts
w goalweeks
d wdays
next dtaskst tdone
next
parts
text
remaining goalweeks
w2 w2daysd2 d2taskst tdonet ttitle
remaininglength
parts
parts
parts
parts
state AppState
upcoming stateevents
e edone
a b adatebdate
upcominglength
lines upcominge
d edate
text
context ChatContextRef
state AppState
images
lower text
noteRef contextr rtype
imageslength
noteRef
note statenotesn nid noteRefid
note
rules notebody
l l
Boolean
ref context
reftype
note statenotesn nid refid
note note text
reftype
goal stategoalsg gid refid
goal goal text
lower state
lower
list stategoalsg
stategoalslength
lower
n statenotesx xdeletedAtlength
n
lower
id
label
baseUrl
models
id
label
baseUrl
models
id
label
baseUrl
models
id label baseUrl models
`Но в демо-режиме я не вижу содержимое изображения — подключите API-ключ в настройках (кнопка «Демо» выше), и я решу задачу с фото строго по образцу из заметки.`
)
;
}
}
return
"Фото вижу, но в демо-режиме не могу его прочитать. Подключите API-ключ в настройках — тогда разберу задачу на изображении, а заметку с правилами привяжите через «/»."
;
}
for
(
const
of
)
{
if
(
.
===
"note"
)
{
const
=
.
.
find
(
(
)
=>
.
===
.
)
;
if
(
)
return
aboutNote
(
,
)
;
}
if
(
.
===
"goal"
)
{
const
=
.
.
find
(
(
)
=>
.
===
.
)
;
if
(
)
return
aboutGoal
(
,
)
;
}
}
if
(
/план|недел/
.
test
(
)
)
return
weeklyPlan
(
)
;
if
(
/цел|спринт/
.
test
(
)
)
{
const
=
.
.
map
(
(
)
=>
`«${g.title}» — ${pct(goalProgress(g))}`
)
.
join
(
", "
)
;
return
.
.
?
`Ваши цели сейчас: ${list}. Привяжите любую скрепкой — разберу её по шагам.`
:
"Целей пока нет. Поставьте первую во вкладке «Цели», и я помогу разложить её на недели."
;
}
if
(
/заметк/
.
test
(
)
)
{
const
=
.
.
filter
(
(
)
=>
!
.
)
.
;
return
?
`У вас ${n} заметок. Привяжите нужную скрепкой — вытащу суть и подскажу следующий шаг.`
:
"Заметок пока нет. Запишите первую во вкладке «Заметки» — я подключусь к ней по скрепке."
;
}
if
(
/привет|здравствуй|добрый/
.
test
(
)
)
return
"Здравствуйте, сэр. Я в курсе ваших заметок, целей и календаря. Привяжите контекст скрепкой или спросите про план на неделю."
;
return
"Принял, сэр. Чтобы ответить предметно, привяжите скрепкой заметку или цель — либо спросите: «составь план на неделю», «как продвигаются цели?»."