@wirecat/cli-core 0.611.0 → 0.613.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.
Files changed (63) hide show
  1. package/CHANGELOG.md +62 -1
  2. package/dist/background/report/render.d.ts +10 -1
  3. package/dist/background/report/render.js +20 -7
  4. package/dist/background/report/schema.d.ts +37 -0
  5. package/dist/background/report/schema.js +98 -4
  6. package/dist/background/report/templates/morning-digest.email.en.liquid +49 -8
  7. package/dist/background/report/templates/morning-digest.email.ru.liquid +49 -8
  8. package/dist/background/report/templates/morning-digest.telegram.en.liquid +49 -9
  9. package/dist/background/report/templates/morning-digest.telegram.ru.liquid +49 -9
  10. package/dist/background/report/templates/morning-digest.text.en.liquid +49 -9
  11. package/dist/background/report/templates/morning-digest.text.ru.liquid +49 -9
  12. package/dist/background/report/view.d.ts +34 -3
  13. package/dist/background/report/view.js +59 -5
  14. package/dist/background/schedules.js +19 -3
  15. package/dist/calendar/mcp/index.d.ts +12 -12
  16. package/dist/cli/enrichment-consents-command.d.ts +19 -0
  17. package/dist/cli/enrichment-consents-command.js +110 -0
  18. package/dist/cli/model-catalogue-command.d.ts +8 -0
  19. package/dist/cli/model-catalogue-command.js +4 -1
  20. package/dist/domain/links.d.ts +72 -0
  21. package/dist/domain/links.js +139 -0
  22. package/dist/embeddings/keys.d.ts +2 -0
  23. package/dist/embeddings/keys.js +2 -0
  24. package/dist/errors/reasons.js +1 -0
  25. package/dist/index.d.ts +1 -0
  26. package/dist/index.js +1 -0
  27. package/dist/meetings/mcp/index.d.ts +15 -15
  28. package/dist/models/anthropic.js +6 -0
  29. package/dist/models/index.d.ts +1 -1
  30. package/dist/models/openai.js +8 -1
  31. package/dist/models/types.d.ts +7 -0
  32. package/dist/services/enrichment-setting.d.ts +50 -0
  33. package/dist/services/enrichment-setting.js +84 -0
  34. package/dist/services/enrichment.d.ts +111 -0
  35. package/dist/services/enrichment.js +240 -0
  36. package/dist/services/index.d.ts +2 -0
  37. package/dist/services/index.js +2 -0
  38. package/dist/services/notes-search.d.ts +15 -1
  39. package/dist/services/notes-search.js +38 -2
  40. package/dist/store/exports.d.ts +1 -0
  41. package/dist/store/exports.js +1 -0
  42. package/dist/store/sqlite/email-index.d.ts +2 -2
  43. package/dist/store/sqlite/email-index.js +6 -4
  44. package/dist/store/sqlite/emails.js +5 -0
  45. package/dist/store/sqlite/enrichments.d.ts +60 -0
  46. package/dist/store/sqlite/enrichments.js +113 -0
  47. package/dist/store/sqlite/entity-types.d.ts +1 -0
  48. package/dist/store/sqlite/entity-types.js +1 -0
  49. package/dist/store/sqlite/index-text.d.ts +2 -0
  50. package/dist/store/sqlite/index-text.js +2 -0
  51. package/dist/store/sqlite/mail-nearest.js +1 -1
  52. package/dist/store/sqlite/manifest.js +2 -0
  53. package/dist/store/sqlite/migrations.generated.js +14 -0
  54. package/dist/store/sqlite/note-index.d.ts +1 -2
  55. package/dist/store/sqlite/note-index.js +25 -4
  56. package/dist/store/sqlite/note-search.js +8 -1
  57. package/dist/store/sqlite/schema/enrichments.d.ts +137 -0
  58. package/dist/store/sqlite/schema/enrichments.js +12 -0
  59. package/dist/store/sqlite/schema.d.ts +1 -0
  60. package/dist/store/sqlite/schema.js +1 -0
  61. package/dist/store/store.d.ts +3 -0
  62. package/dist/store/store.js +5 -0
  63. package/package.json +2 -2
@@ -10,7 +10,7 @@ Every string from the report is already escaped. Lines are written with {{ nl }}
10
10
  {%- if summary %}{{ nl }}{{ summary }}{% endif -%}
11
11
  {%- if quiet -%}
12
12
  {{ nl }}{{ nl }}
13
- {%- if health.items.size > 0 %}Новых дел нет, но {{ health.items[0].source }} не обновлялся {{ health.items[0].span }}.
13
+ {%- if health.items.size > 0 %}Новых дел нет, но синхронизация требует внимания.
14
14
  {%- else %}Тихое утро: ничего срочного.{% endif -%}
15
15
  {%- endif -%}
16
16
  {%- for section in sections -%}
@@ -35,7 +35,7 @@ Every string from the report is already escaped. Lines are written with {{ nl }}
35
35
  {%- case item.type -%}
36
36
  {%- when "reply" %}<b>{{ item.who }} · {{ item.topic }}</b> — {{ item.action }}
37
37
  {%- when "question" %}<b>{{ item.who }}</b> спрашивает: {{ item.action }}
38
- {%- when "task" %}<b>{{ item.topic }}</b> — {{ due }}
38
+ {%- when "task" %}<b>{{ item.topic }}</b>{% if due != "" %} — {{ due }}{% elsif item.who %} — {{ item.who }}{% endif %}
39
39
  {%- when "fact" %}<b>{{ item.topic }}</b>: {{ item.detail }}
40
40
  {%- when "risk" %}<b>{{ item.topic }}</b>: {{ item.detail }} → {{ item.action }}
41
41
  {%- when "money" %}<b>{{ item.amount.text }} · {{ item.who }} · {{ item.topic }}</b>{% if item.action %} — {{ item.action }}{% endif %}
@@ -53,7 +53,8 @@ Every string from the report is already escaped. Lines are written with {{ nl }}
53
53
  {%- if due != "" and "risk,money,decision" contains item.type %}{{ sep }}{{ due }}{% assign sep = " · " %}{% endif -%}
54
54
  {%- if item.action and "task,meeting" contains item.type %}{{ sep }}{{ item.action }}{% assign sep = " · " %}{% endif -%}
55
55
  {%- if item.detail and "task,money,meeting,decision" contains item.type %}{{ sep }}{{ item.detail }}{% assign sep = " · " %}{% endif -%}
56
- {%- if item.who and "task,fact,risk,decision" contains item.type %}{{ sep }}{{ item.who }}{% assign sep = " · " %}{% endif -%}
56
+ {%- if item.who and "fact,risk,decision" contains item.type %}{{ sep }}{{ item.who }}{% assign sep = " · " %}{% endif -%}
57
+ {%- if item.who and item.type == "task" and due != "" %}{{ sep }}{{ item.who }}{% assign sep = " · " %}{% endif -%}
57
58
  {%- if item.channel %}{{ sep }}
58
59
  {%- case item.channel -%}
59
60
  {%- when "telegram" %}Telegram{% when "max" %}MAX{% when "whatsapp" %}WhatsApp
@@ -67,11 +68,50 @@ Every string from the report is already escaped. Lines are written with {{ nl }}
67
68
  {%- if second != "" %}{{ nl }}{{ second }}{% endif -%}
68
69
  {%- endfor -%}
69
70
  {%- if section.more > 0 %}{{ nl }}ещё {{ section.more }}{% endif -%}
71
+ {%- if section.groups.size > 0 %}{{ nl }}
72
+ {%- for group in section.groups -%}
73
+ {%- unless forloop.first %} · {% endunless -%}
74
+ {%- capture words -%}
75
+ {%- case group.filter -%}
76
+ {%- when "overdue" %}Все просроченные
77
+ {%- when "today" %}{% if forloop.first %}На сегодня{% else %}на сегодня{% endif %}
78
+ {%- when "tomorrow" %}{% if forloop.first %}На завтра{% else %}на завтра{% endif %}
79
+ {%- when "new" %}{% if forloop.first %}Новые{% else %}новые{% endif %}
80
+ {%- endcase %} ({{ group.count }})
81
+ {%- endcapture -%}
82
+ {%- if group.link %}<a href="{{ group.link.url }}">{{ words }}</a>{% else %}{{ words }}{% endif -%}
83
+ {%- endfor -%}
84
+ {%- endif -%}
70
85
  {%- endfor -%}
71
- {%- unless quiet -%}
72
- {%- if health.items.size > 0 %}{{ nl }}{% endif -%}
73
- {%- for source in health.items -%}
74
- {{ nl }}{{ health.emoji }} {{ source.source }} не обновлялся {{ source.span }}
75
- {%- for link in source.links %} · <a href="{{ link.url }}">{{ link.label }}</a>{% endfor -%}
86
+ {%- if health.items.size > 0 %}{{ nl }}{% endif -%}
87
+ {%- for source in health.items -%}
88
+ {{ nl }}{{ health.emoji }} {{ source.source }}
89
+ {%- if source.account %} ({{ source.account }}){% endif -%}
90
+ {%- case source.reason -%}
91
+ {%- when "sync-failed" %}: синхронизация падает{% if source.since %} с {{ source.since.date }}{% endif %}
92
+ {%- when "no-schedule" %}: нет расписания синхронизации
93
+ {%- when "quiet" %}: ничего нового {% if source.since %}с {{ source.since.date }}{% else %}{{ source.span }}{% endif %}
94
+ {%- else %} не обновлялся {{ source.span }}
95
+ {%- endcase -%}
96
+ {%- for link in source.links %} · <a href="{{ link.url }}">{{ link.label }}</a>{% endfor -%}
97
+ {%- endfor -%}
98
+ {%- if scope -%}
99
+ {{ nl }}{{ nl }}Просмотрено за {{ scope.window }}
100
+ {%- for source in scope.sources -%}
101
+ {%- if forloop.first %}: {% else %}, {% endif -%}
102
+ {%- case source.kind -%}
103
+ {%- when "telegram" %}Telegram{% when "max" %}MAX{% when "whatsapp" %}WhatsApp
104
+ {%- when "mail" %}почта{% when "meeting" %}встречи{% when "task" %}задачи
105
+ {%- endcase -%}
106
+ {%- if source.accounts > 1 %} ({{ source.accounts }} {% if source.kind == "mail" %}{% case source.plural %}{% when "one" %}ящик{% when "few" %}ящика{% else %}ящиков{% endcase %}{% else %}{% case source.plural %}{% when "one" %}аккаунт{% when "few" %}аккаунта{% else %}аккаунтов{% endcase %}{% endif %}){% endif -%}
76
107
  {%- endfor -%}
77
- {%- endunless -%}
108
+ {%- for count in scope.counts -%}
109
+ {%- if forloop.first %} · {% else %}, {% endif -%}
110
+ {{ count.count }} {% case count.kind -%}
111
+ {%- when "chats" %}{% case count.plural %}{% when "one" %}чат{% when "few" %}чата{% else %}чатов{% endcase %}
112
+ {%- when "mail" %}{% case count.plural %}{% when "one" %}письмо{% when "few" %}письма{% else %}писем{% endcase %}
113
+ {%- when "tasks" %}{% case count.plural %}{% when "one" %}задача{% when "few" %}задачи{% else %}задач{% endcase %}
114
+ {%- when "meetings" %}{% case count.plural %}{% when "one" %}встреча{% when "few" %}встречи{% else %}встреч{% endcase %}
115
+ {%- endcase -%}
116
+ {%- endfor -%}
117
+ {%- endif -%}
@@ -9,7 +9,7 @@ Plain text: the terminal, latest.txt, the desktop notice, the email's plain part
9
9
  {%- if summary %}{{ nl }}{{ summary }}{% endif -%}
10
10
  {%- if quiet -%}
11
11
  {{ nl }}{{ nl }}
12
- {%- if health.items.size > 0 %}Nothing new, but {{ health.items[0].source }} has not synced for {{ health.items[0].span }}.
12
+ {%- if health.items.size > 0 %}Nothing new, but sync needs attention.
13
13
  {%- else %}A quiet morning: nothing urgent.{% endif -%}
14
14
  {%- endif -%}
15
15
  {%- for section in sections -%}
@@ -34,7 +34,7 @@ Plain text: the terminal, latest.txt, the desktop notice, the email's plain part
34
34
  {%- case item.type -%}
35
35
  {%- when "reply" %}{{ item.who }} · {{ item.topic }} — {{ item.action }}
36
36
  {%- when "question" %}{{ item.who }} asks: {{ item.action }}
37
- {%- when "task" %}{{ item.topic }} — {{ due }}
37
+ {%- when "task" %}{{ item.topic }}{% if due != "" %} — {{ due }}{% elsif item.who %} — {{ item.who }}{% endif %}
38
38
  {%- when "fact" %}{{ item.topic }}: {{ item.detail }}
39
39
  {%- when "risk" %}{{ item.topic }}: {{ item.detail }} → {{ item.action }}
40
40
  {%- when "money" %}{{ item.amount.text }} · {{ item.who }} · {{ item.topic }}{% if item.action %} — {{ item.action }}{% endif %}
@@ -52,7 +52,8 @@ Plain text: the terminal, latest.txt, the desktop notice, the email's plain part
52
52
  {%- if due != "" and "risk,money,decision" contains item.type %}{{ sep }}{{ due }}{% assign sep = " · " %}{% endif -%}
53
53
  {%- if item.action and "task,meeting" contains item.type %}{{ sep }}{{ item.action }}{% assign sep = " · " %}{% endif -%}
54
54
  {%- if item.detail and "task,money,meeting,decision" contains item.type %}{{ sep }}{{ item.detail }}{% assign sep = " · " %}{% endif -%}
55
- {%- if item.who and "task,fact,risk,decision" contains item.type %}{{ sep }}{{ item.who }}{% assign sep = " · " %}{% endif -%}
55
+ {%- if item.who and "fact,risk,decision" contains item.type %}{{ sep }}{{ item.who }}{% assign sep = " · " %}{% endif -%}
56
+ {%- if item.who and item.type == "task" and due != "" %}{{ sep }}{{ item.who }}{% assign sep = " · " %}{% endif -%}
56
57
  {%- if item.channel %}{{ sep }}
57
58
  {%- case item.channel -%}
58
59
  {%- when "telegram" %}Telegram{% when "max" %}MAX{% when "whatsapp" %}WhatsApp
@@ -66,11 +67,50 @@ Plain text: the terminal, latest.txt, the desktop notice, the email's plain part
66
67
  {%- if second != "" %}{{ nl }} {{ second }}{% endif -%}
67
68
  {%- endfor -%}
68
69
  {%- if section.more > 0 %}{{ nl }}{{ section.more }} more{% endif -%}
70
+ {%- if section.groups.size > 0 %}{{ nl }}
71
+ {%- for group in section.groups -%}
72
+ {%- unless forloop.first %} · {% endunless -%}
73
+ {%- capture words -%}
74
+ {%- case group.filter -%}
75
+ {%- when "overdue" %}All overdue
76
+ {%- when "today" %}{% if forloop.first %}Due today{% else %}due today{% endif %}
77
+ {%- when "tomorrow" %}{% if forloop.first %}Due tomorrow{% else %}due tomorrow{% endif %}
78
+ {%- when "new" %}{% if forloop.first %}New{% else %}new{% endif %}
79
+ {%- endcase %} ({{ group.count }})
80
+ {%- endcapture -%}
81
+ {%- if group.link %}{{ words }} {{ group.link.url }}{% else %}{{ words }}{% endif -%}
82
+ {%- endfor -%}
83
+ {%- endif -%}
69
84
  {%- endfor -%}
70
- {%- unless quiet -%}
71
- {%- if health.items.size > 0 %}{{ nl }}{% endif -%}
72
- {%- for source in health.items -%}
73
- {{ nl }}{{ health.emoji }} {{ source.source }} has not synced for {{ source.span }}
74
- {%- for link in source.links %} · {{ link.url }}{% endfor -%}
85
+ {%- if health.items.size > 0 %}{{ nl }}{% endif -%}
86
+ {%- for source in health.items -%}
87
+ {{ nl }}{{ health.emoji }} {{ source.source }}
88
+ {%- if source.account %} ({{ source.account }}){% endif -%}
89
+ {%- case source.reason -%}
90
+ {%- when "sync-failed" %}: sync failing{% if source.since %} since {{ source.since.date }}{% endif %}
91
+ {%- when "no-schedule" %}: no sync schedule
92
+ {%- when "quiet" %}: nothing new {% if source.since %}since {{ source.since.date }}{% else %}for {{ source.span }}{% endif %}
93
+ {%- else %} has not synced for {{ source.span }}
94
+ {%- endcase -%}
95
+ {%- for link in source.links %} · {{ link.url }}{% endfor -%}
96
+ {%- endfor -%}
97
+ {%- if scope -%}
98
+ {{ nl }}{{ nl }}Viewed over {{ scope.window }}
99
+ {%- for source in scope.sources -%}
100
+ {%- if forloop.first %}: {% else %}, {% endif -%}
101
+ {%- case source.kind -%}
102
+ {%- when "telegram" %}Telegram{% when "max" %}MAX{% when "whatsapp" %}WhatsApp
103
+ {%- when "mail" %}mail{% when "meeting" %}meetings{% when "task" %}tasks
104
+ {%- endcase -%}
105
+ {%- if source.accounts > 1 %} ({{ source.accounts }} {% if source.kind == "mail" %}{% if source.plural == "one" %}mailbox{% else %}mailboxes{% endif %}{% else %}{% if source.plural == "one" %}account{% else %}accounts{% endif %}{% endif %}){% endif -%}
75
106
  {%- endfor -%}
76
- {%- endunless -%}
107
+ {%- for count in scope.counts -%}
108
+ {%- if forloop.first %} · {% else %}, {% endif -%}
109
+ {{ count.count }} {% case count.kind -%}
110
+ {%- when "chats" %}{% if count.plural == "one" %}chat{% else %}chats{% endif %}
111
+ {%- when "mail" %}{% if count.plural == "one" %}email{% else %}emails{% endif %}
112
+ {%- when "tasks" %}{% if count.plural == "one" %}task{% else %}tasks{% endif %}
113
+ {%- when "meetings" %}{% if count.plural == "one" %}meeting{% else %}meetings{% endif %}
114
+ {%- endcase -%}
115
+ {%- endfor -%}
116
+ {%- endif -%}
@@ -9,7 +9,7 @@ Plain text: the terminal, latest.txt, the desktop notice, the email's plain part
9
9
  {%- if summary %}{{ nl }}{{ summary }}{% endif -%}
10
10
  {%- if quiet -%}
11
11
  {{ nl }}{{ nl }}
12
- {%- if health.items.size > 0 %}Новых дел нет, но {{ health.items[0].source }} не обновлялся {{ health.items[0].span }}.
12
+ {%- if health.items.size > 0 %}Новых дел нет, но синхронизация требует внимания.
13
13
  {%- else %}Тихое утро: ничего срочного.{% endif -%}
14
14
  {%- endif -%}
15
15
  {%- for section in sections -%}
@@ -34,7 +34,7 @@ Plain text: the terminal, latest.txt, the desktop notice, the email's plain part
34
34
  {%- case item.type -%}
35
35
  {%- when "reply" %}{{ item.who }} · {{ item.topic }} — {{ item.action }}
36
36
  {%- when "question" %}{{ item.who }} спрашивает: {{ item.action }}
37
- {%- when "task" %}{{ item.topic }} — {{ due }}
37
+ {%- when "task" %}{{ item.topic }}{% if due != "" %} — {{ due }}{% elsif item.who %} — {{ item.who }}{% endif %}
38
38
  {%- when "fact" %}{{ item.topic }}: {{ item.detail }}
39
39
  {%- when "risk" %}{{ item.topic }}: {{ item.detail }} → {{ item.action }}
40
40
  {%- when "money" %}{{ item.amount.text }} · {{ item.who }} · {{ item.topic }}{% if item.action %} — {{ item.action }}{% endif %}
@@ -52,7 +52,8 @@ Plain text: the terminal, latest.txt, the desktop notice, the email's plain part
52
52
  {%- if due != "" and "risk,money,decision" contains item.type %}{{ sep }}{{ due }}{% assign sep = " · " %}{% endif -%}
53
53
  {%- if item.action and "task,meeting" contains item.type %}{{ sep }}{{ item.action }}{% assign sep = " · " %}{% endif -%}
54
54
  {%- if item.detail and "task,money,meeting,decision" contains item.type %}{{ sep }}{{ item.detail }}{% assign sep = " · " %}{% endif -%}
55
- {%- if item.who and "task,fact,risk,decision" contains item.type %}{{ sep }}{{ item.who }}{% assign sep = " · " %}{% endif -%}
55
+ {%- if item.who and "fact,risk,decision" contains item.type %}{{ sep }}{{ item.who }}{% assign sep = " · " %}{% endif -%}
56
+ {%- if item.who and item.type == "task" and due != "" %}{{ sep }}{{ item.who }}{% assign sep = " · " %}{% endif -%}
56
57
  {%- if item.channel %}{{ sep }}
57
58
  {%- case item.channel -%}
58
59
  {%- when "telegram" %}Telegram{% when "max" %}MAX{% when "whatsapp" %}WhatsApp
@@ -66,11 +67,50 @@ Plain text: the terminal, latest.txt, the desktop notice, the email's plain part
66
67
  {%- if second != "" %}{{ nl }} {{ second }}{% endif -%}
67
68
  {%- endfor -%}
68
69
  {%- if section.more > 0 %}{{ nl }}ещё {{ section.more }}{% endif -%}
70
+ {%- if section.groups.size > 0 %}{{ nl }}
71
+ {%- for group in section.groups -%}
72
+ {%- unless forloop.first %} · {% endunless -%}
73
+ {%- capture words -%}
74
+ {%- case group.filter -%}
75
+ {%- when "overdue" %}Все просроченные
76
+ {%- when "today" %}{% if forloop.first %}На сегодня{% else %}на сегодня{% endif %}
77
+ {%- when "tomorrow" %}{% if forloop.first %}На завтра{% else %}на завтра{% endif %}
78
+ {%- when "new" %}{% if forloop.first %}Новые{% else %}новые{% endif %}
79
+ {%- endcase %} ({{ group.count }})
80
+ {%- endcapture -%}
81
+ {%- if group.link %}{{ words }} {{ group.link.url }}{% else %}{{ words }}{% endif -%}
82
+ {%- endfor -%}
83
+ {%- endif -%}
69
84
  {%- endfor -%}
70
- {%- unless quiet -%}
71
- {%- if health.items.size > 0 %}{{ nl }}{% endif -%}
72
- {%- for source in health.items -%}
73
- {{ nl }}{{ health.emoji }} {{ source.source }} не обновлялся {{ source.span }}
74
- {%- for link in source.links %} · {{ link.url }}{% endfor -%}
85
+ {%- if health.items.size > 0 %}{{ nl }}{% endif -%}
86
+ {%- for source in health.items -%}
87
+ {{ nl }}{{ health.emoji }} {{ source.source }}
88
+ {%- if source.account %} ({{ source.account }}){% endif -%}
89
+ {%- case source.reason -%}
90
+ {%- when "sync-failed" %}: синхронизация падает{% if source.since %} с {{ source.since.date }}{% endif %}
91
+ {%- when "no-schedule" %}: нет расписания синхронизации
92
+ {%- when "quiet" %}: ничего нового {% if source.since %}с {{ source.since.date }}{% else %}{{ source.span }}{% endif %}
93
+ {%- else %} не обновлялся {{ source.span }}
94
+ {%- endcase -%}
95
+ {%- for link in source.links %} · {{ link.url }}{% endfor -%}
96
+ {%- endfor -%}
97
+ {%- if scope -%}
98
+ {{ nl }}{{ nl }}Просмотрено за {{ scope.window }}
99
+ {%- for source in scope.sources -%}
100
+ {%- if forloop.first %}: {% else %}, {% endif -%}
101
+ {%- case source.kind -%}
102
+ {%- when "telegram" %}Telegram{% when "max" %}MAX{% when "whatsapp" %}WhatsApp
103
+ {%- when "mail" %}почта{% when "meeting" %}встречи{% when "task" %}задачи
104
+ {%- endcase -%}
105
+ {%- if source.accounts > 1 %} ({{ source.accounts }} {% if source.kind == "mail" %}{% case source.plural %}{% when "one" %}ящик{% when "few" %}ящика{% else %}ящиков{% endcase %}{% else %}{% case source.plural %}{% when "one" %}аккаунт{% when "few" %}аккаунта{% else %}аккаунтов{% endcase %}{% endif %}){% endif -%}
75
106
  {%- endfor -%}
76
- {%- endunless -%}
107
+ {%- for count in scope.counts -%}
108
+ {%- if forloop.first %} · {% else %}, {% endif -%}
109
+ {{ count.count }} {% case count.kind -%}
110
+ {%- when "chats" %}{% case count.plural %}{% when "one" %}чат{% when "few" %}чата{% else %}чатов{% endcase %}
111
+ {%- when "mail" %}{% case count.plural %}{% when "one" %}письмо{% when "few" %}письма{% else %}писем{% endcase %}
112
+ {%- when "tasks" %}{% case count.plural %}{% when "one" %}задача{% when "few" %}задачи{% else %}задач{% endcase %}
113
+ {%- when "meetings" %}{% case count.plural %}{% when "one" %}встреча{% when "few" %}встречи{% else %}встреч{% endcase %}
114
+ {%- endcase -%}
115
+ {%- endfor -%}
116
+ {%- endif -%}
@@ -1,5 +1,5 @@
1
- import type { ChannelKind, ItemType, Report, ReportKind, SectionKind } from "./schema.js";
2
- /** A link the renderer built; a template may point an `href` only at one of these. Empty until deep links exist. */
1
+ import type { ChannelKind, HealthReason, ItemType, Report, ReportKind, SectionKind } from "./schema.js";
2
+ /** A link the renderer built from a ref; a template may point an `href` only at one of these. */
3
3
  export interface ViewLink {
4
4
  kind: "open" | "web";
5
5
  url: string;
@@ -40,19 +40,46 @@ export interface ViewItem {
40
40
  time: Moment | null;
41
41
  links: ViewLink[];
42
42
  }
43
+ export interface ViewTaskGroup {
44
+ filter: "overdue" | "today" | "tomorrow" | "new";
45
+ count: number;
46
+ /** `tasks/<filter>`; null when links are off, or `new` has no time to count from. */
47
+ link: ViewLink | null;
48
+ }
43
49
  export interface ViewSection {
44
50
  kind: SectionKind;
45
51
  emoji: string;
46
52
  items: ViewItem[];
47
53
  /** The "ещё N" count: what the agent left out plus what the cap or the Telegram fit dropped. */
48
54
  more: number;
55
+ /** The task group links, on the section that holds the task items only; zero groups left out. */
56
+ groups: ViewTaskGroup[];
49
57
  }
50
58
  export interface ViewHealth {
51
59
  source: string;
60
+ account: string | null;
61
+ reason: HealthReason | null;
62
+ since: Moment | null;
52
63
  hours: number;
53
64
  span: string;
54
65
  links: ViewLink[];
55
66
  }
67
+ /** The footer line: a template picks a word's form by `plural` (`Intl.PluralRules`: one, few, many, other). */
68
+ export interface ViewScope {
69
+ /** "24 ч", "3 дня": hours below two days or for a part of a day, else days. */
70
+ window: string;
71
+ sources: {
72
+ kind: ChannelKind;
73
+ accounts: number;
74
+ plural: string;
75
+ }[];
76
+ /** Zero counts left out, in the order chats, mail, tasks, meetings. */
77
+ counts: {
78
+ kind: "chats" | "mail" | "tasks" | "meetings";
79
+ count: number;
80
+ plural: string;
81
+ }[];
82
+ }
56
83
  /** What a report template gets. Every string an agent wrote is already escaped for an HTML channel. */
57
84
  export interface ReportView {
58
85
  kind: ReportKind;
@@ -72,8 +99,11 @@ export interface ReportView {
72
99
  today: number;
73
100
  money: number;
74
101
  };
102
+ scope: ViewScope | null;
75
103
  links: ViewLink[];
76
104
  }
105
+ /** Builds the URL a ref opens, or null; the renderer passes `linkFor` with the form its channel needs. */
106
+ export type LinkOf = (ref: string) => string | null;
77
107
  export declare const SECTION_EMOJI: Record<SectionKind, string>;
78
108
  export declare const SECTION_CAPS: Record<SectionKind | "health", number>;
79
109
  export declare const momentFor: (iso: string, now: number, language: string, timeZone?: string) => Moment;
@@ -81,8 +111,9 @@ export declare const momentFor: (iso: string, now: number, language: string, tim
81
111
  * The view model of a checked report: sections in their fixed order, each cut to its cap with the rest counted in
82
112
  * `more`, dates and money formatted in `language` and `timeZone`. Refs never reach it.
83
113
  */
84
- export declare const reportView: (report: Report, { language, now, timeZone }: {
114
+ export declare const reportView: (report: Report, { language, now, timeZone, linkOf, }: {
85
115
  language: string;
86
116
  now: number;
87
117
  timeZone?: string;
118
+ linkOf?: LinkOf;
88
119
  }) => ReportView;
@@ -1,3 +1,7 @@
1
+ const LINK_WORDS = {
2
+ ru: { open: "открыть", fix: "исправить" },
3
+ en: { open: "open", fix: "fix" },
4
+ };
1
5
  export const SECTION_EMOJI = {
2
6
  today: "🔥",
3
7
  decisions: "🗳",
@@ -16,6 +20,7 @@ export const SECTION_CAPS = {
16
20
  health: 3,
17
21
  };
18
22
  const STALE_HOURS = 24;
23
+ const HOUR_MS = 3_600_000;
19
24
  const emojiOf = (item, overdue) => {
20
25
  switch (item.type) {
21
26
  case "reply":
@@ -78,12 +83,52 @@ const amountText = (amount, language) => {
78
83
  }).format(amount.value);
79
84
  return `${amount.direction === "in" ? "+" : "−"}${money}`;
80
85
  };
86
+ const taskGroups = (tasks, linkOf, label) => {
87
+ if (!tasks)
88
+ return [];
89
+ const groups = [
90
+ { filter: "overdue", count: tasks.overdue, ref: "tasks:overdue" },
91
+ { filter: "today", count: tasks.today, ref: "tasks:today" },
92
+ { filter: "tomorrow", count: tasks.tomorrow, ref: "tasks:tomorrow" },
93
+ {
94
+ filter: "new",
95
+ count: tasks.new,
96
+ ref: tasks.newSince === null ? null : `tasks:new/${encodeURIComponent(tasks.newSince)}`,
97
+ },
98
+ ];
99
+ return groups
100
+ .filter((group) => group.count > 0)
101
+ .map(({ filter, count, ref }) => {
102
+ const url = ref === null ? null : linkOf(ref);
103
+ return { filter, count, link: url === null ? null : { kind: "open", url, label } };
104
+ });
105
+ };
106
+ const scopeView = (scope, language) => {
107
+ const plural = new Intl.PluralRules(language);
108
+ const hours = Math.round((Date.parse(scope.to) - Date.parse(scope.from)) / HOUR_MS);
109
+ const window = hours >= 48 && hours % 24 === 0
110
+ ? new Intl.NumberFormat(language, { style: "unit", unit: "day", unitDisplay: "long" }).format(hours / 24)
111
+ : new Intl.NumberFormat(language, { style: "unit", unit: "hour", unitDisplay: "short" }).format(hours);
112
+ const counts = ["chats", "mail", "tasks", "meetings"]
113
+ .map((kind) => ({ kind, count: scope.counts[kind], plural: plural.select(scope.counts[kind]) }))
114
+ .filter((one) => one.count > 0);
115
+ return {
116
+ window,
117
+ sources: scope.sources.map((source) => ({ ...source, plural: plural.select(source.accounts) })),
118
+ counts,
119
+ };
120
+ };
81
121
  /**
82
122
  * The view model of a checked report: sections in their fixed order, each cut to its cap with the rest counted in
83
123
  * `more`, dates and money formatted in `language` and `timeZone`. Refs never reach it.
84
124
  */
85
- export const reportView = (report, { language, now, timeZone }) => {
125
+ export const reportView = (report, { language, now, timeZone, linkOf = () => null, }) => {
86
126
  const moment = (iso) => (iso === null ? null : momentFor(iso, now, language, timeZone));
127
+ const words = LINK_WORDS[language] ?? LINK_WORDS.en;
128
+ const linksOf = (refs, label) => {
129
+ const url = refs.map(linkOf).find((one) => one !== null);
130
+ return url ? [{ kind: "open", url, label }] : [];
131
+ };
87
132
  const itemOf = (item) => {
88
133
  const due = moment(item.due);
89
134
  const overdue = (item.type === "task" || item.type === "money" || item.type === "risk") && due?.past === true;
@@ -103,7 +148,7 @@ export const reportView = (report, { language, now, timeZone }) => {
103
148
  since: moment(item.since),
104
149
  due,
105
150
  time: moment(item.time),
106
- links: [],
151
+ links: linksOf(item.refs, words.open),
107
152
  };
108
153
  };
109
154
  const order = Object.keys(SECTION_EMOJI);
@@ -120,10 +165,15 @@ export const reportView = (report, { language, now, timeZone }) => {
120
165
  emoji: SECTION_EMOJI[kind],
121
166
  items: items.slice(0, cap).map(itemOf),
122
167
  more: more + Math.max(items.length - cap, 0),
168
+ groups: [],
123
169
  },
124
170
  ];
125
171
  });
126
- const stale = report.health.filter((entry) => entry.staleHours > STALE_HOURS);
172
+ const groups = taskGroups(report.tasks, linkOf, words.open);
173
+ const holder = sections.find((section) => section.items.some((item) => item.type === "task")) ??
174
+ sections.find((section) => section.kind === "today") ??
175
+ sections.at(-1);
176
+ const stale = report.health.filter((entry) => entry.reason !== null || entry.staleHours > STALE_HOURS);
127
177
  const count = (kind) => {
128
178
  const section = sections.find((one) => one.kind === kind);
129
179
  return section ? section.items.length + section.more : 0;
@@ -134,19 +184,23 @@ export const reportView = (report, { language, now, timeZone }) => {
134
184
  emoji: "☀️",
135
185
  date: momentFor(report.date, now, language, timeZone),
136
186
  summary: report.summary,
137
- sections,
187
+ sections: sections.map((section) => (section === holder ? { ...section, groups } : section)),
138
188
  health: {
139
189
  emoji: "🛠",
140
190
  items: stale.slice(0, SECTION_CAPS.health).map((entry) => ({
141
191
  source: entry.source,
192
+ account: entry.account,
193
+ reason: entry.reason,
194
+ since: moment(entry.since),
142
195
  hours: entry.staleHours,
143
196
  span: new Intl.NumberFormat(language, { style: "unit", unit: "day", unitDisplay: "long" }).format(Math.floor(entry.staleHours / 24)),
144
- links: [],
197
+ links: linksOf(entry.refs, words.fix),
145
198
  })),
146
199
  more: Math.max(stale.length - SECTION_CAPS.health, 0),
147
200
  },
148
201
  quiet: sections.length === 0,
149
202
  counts: { today: count("today"), money: count("money") },
203
+ scope: report.scope && scopeView(report.scope, language),
150
204
  links: [],
151
205
  };
152
206
  };
@@ -2,9 +2,12 @@ import { spawn } from "node:child_process";
2
2
  import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
3
3
  import { basename, join } from "node:path";
4
4
  import { CliError, errorCodes, writeSecurely } from "@wirecat/cli-base";
5
+ import { linkConfigOf } from "../domain/links.js";
5
6
  import { mailHolderVariable, readOnlyLockOf } from "../ports/app.js";
6
7
  import { recordLogFor } from "../runs/record-log.js";
7
8
  import { childTrace } from "../runs/scope.js";
9
+ import { storePath } from "../store/path.js";
10
+ import { readSharedSection, sharedConfigPath } from "../store/shared-config.js";
8
11
  import { deliver } from "./deliver.js";
9
12
  import { prepareReport } from "./report/render.js";
10
13
  export const NOTIFY_WHEN = ["always", "failures", "never"];
@@ -342,6 +345,15 @@ export const timerFor = (app, system, env) => {
342
345
  return launchdTimer(app, system, env, env.HOME);
343
346
  throw new CliError("validation_error", `${app.command} schedule knows Linux, macOS and Windows, not ${system.platform}`);
344
347
  };
348
+ /** The shared `links` settings; a config file that cannot be read keeps the default rather than stop a digest. */
349
+ const sharedLinks = (env) => {
350
+ try {
351
+ return linkConfigOf(readSharedSection(sharedConfigPath(storePath(env), env), "links"));
352
+ }
353
+ catch {
354
+ return linkConfigOf(undefined);
355
+ }
356
+ };
345
357
  /** A desktop notification; a machine without one loses only the notice, never the run. */
346
358
  export const notify = async (system, env, title, body) => {
347
359
  const argv = system.platform === "linux"
@@ -462,15 +474,20 @@ export const runSchedule = async (app, system, env, file, { now = () => new Date
462
474
  const errors = agent ? output.replace(/\.md$/, ".log") : output;
463
475
  if (agent && exitCode === 0)
464
476
  copyFileSync(output, join(folder, "latest.md"));
477
+ const runEnv = { ...env, ...schedule.environment };
465
478
  const prepared = agent && exitCode === 0
466
479
  ? await prepareReport(readFileSync(output, "utf8"), {
467
- language: await ownerLanguage({ ...env, ...schedule.environment }).catch(() => "ru"),
480
+ language: await ownerLanguage(runEnv).catch(() => "ru"),
468
481
  now: now().getTime(),
482
+ links: sharedLinks(runEnv),
483
+ env: runEnv,
469
484
  })
470
485
  : undefined;
471
486
  const latestText = join(folder, "latest.txt");
472
487
  if (prepared) {
473
- writeFileSync(latestText, `${prepared.text}\n`, { mode: 0o600 });
488
+ writeFileSync(latestText, `${prepared.terminal}\n`, { mode: 0o600 });
489
+ if (prepared.document)
490
+ writeFileSync(output.replace(/\.md$/, ".report.json"), prepared.document, { mode: 0o600 });
474
491
  last = rewriteRun(join(folder, "last.json"), { ...last, report: prepared.run });
475
492
  }
476
493
  else if (agent && exitCode === 0)
@@ -497,7 +514,6 @@ export const runSchedule = async (app, system, env, file, { now = () => new Date
497
514
  const routes = schedule.to ?? [];
498
515
  if (routes.length > 0 && (exitCode === 0 ? mode === "always" : mode !== "never")) {
499
516
  const at = shortTime(last.at);
500
- const runEnv = { ...env, ...schedule.environment };
501
517
  const locked = readOnlyLockOf(app, runEnv);
502
518
  const deliveries = await deliver(system, runEnv, routes, exitCode === 0
503
519
  ? {
@@ -10,13 +10,13 @@ export declare const calendarTools: ({
10
10
  inputSchema: {
11
11
  type: string;
12
12
  properties: {
13
+ limit?: undefined;
13
14
  account_id: {
14
15
  type: string;
15
16
  minimum: number;
16
17
  };
17
18
  query?: undefined;
18
19
  timezone?: undefined;
19
- limit?: undefined;
20
20
  page?: undefined;
21
21
  event?: undefined;
22
22
  } | {
@@ -45,9 +45,9 @@ export declare const calendarTools: ({
45
45
  };
46
46
  event?: undefined;
47
47
  } | {
48
+ limit?: undefined;
48
49
  query?: undefined;
49
50
  timezone?: undefined;
50
- limit?: undefined;
51
51
  page?: undefined;
52
52
  event: {
53
53
  type: string;
@@ -58,9 +58,9 @@ export declare const calendarTools: ({
58
58
  minimum: number;
59
59
  };
60
60
  } | {
61
+ limit?: undefined;
61
62
  query?: undefined;
62
63
  timezone?: undefined;
63
- limit?: undefined;
64
64
  page?: undefined;
65
65
  event?: undefined;
66
66
  account_id?: undefined;
@@ -80,13 +80,13 @@ export declare const calendarTools: ({
80
80
  inputSchema: {
81
81
  type: string;
82
82
  properties: {
83
+ limit?: undefined;
83
84
  account_id: {
84
85
  type: string;
85
86
  minimum: number;
86
87
  };
87
88
  query?: undefined;
88
89
  timezone?: undefined;
89
- limit?: undefined;
90
90
  page?: undefined;
91
91
  event?: undefined;
92
92
  } | {
@@ -115,9 +115,9 @@ export declare const calendarTools: ({
115
115
  };
116
116
  event?: undefined;
117
117
  } | {
118
+ limit?: undefined;
118
119
  query?: undefined;
119
120
  timezone?: undefined;
120
- limit?: undefined;
121
121
  page?: undefined;
122
122
  event: {
123
123
  type: string;
@@ -128,9 +128,9 @@ export declare const calendarTools: ({
128
128
  minimum: number;
129
129
  };
130
130
  } | {
131
+ limit?: undefined;
131
132
  query?: undefined;
132
133
  timezone?: undefined;
133
- limit?: undefined;
134
134
  page?: undefined;
135
135
  event?: undefined;
136
136
  account_id?: undefined;
@@ -150,13 +150,13 @@ export declare const calendarTools: ({
150
150
  inputSchema: {
151
151
  type: string;
152
152
  properties: {
153
+ limit?: undefined;
153
154
  account_id: {
154
155
  type: string;
155
156
  minimum: number;
156
157
  };
157
158
  query?: undefined;
158
159
  timezone?: undefined;
159
- limit?: undefined;
160
160
  page?: undefined;
161
161
  event?: undefined;
162
162
  } | {
@@ -185,9 +185,9 @@ export declare const calendarTools: ({
185
185
  };
186
186
  event?: undefined;
187
187
  } | {
188
+ limit?: undefined;
188
189
  query?: undefined;
189
190
  timezone?: undefined;
190
- limit?: undefined;
191
191
  page?: undefined;
192
192
  event: {
193
193
  type: string;
@@ -198,9 +198,9 @@ export declare const calendarTools: ({
198
198
  minimum: number;
199
199
  };
200
200
  } | {
201
+ limit?: undefined;
201
202
  query?: undefined;
202
203
  timezone?: undefined;
203
- limit?: undefined;
204
204
  page?: undefined;
205
205
  event?: undefined;
206
206
  account_id?: undefined;
@@ -220,13 +220,13 @@ export declare const calendarTools: ({
220
220
  inputSchema: {
221
221
  type: string;
222
222
  properties: {
223
+ limit?: undefined;
223
224
  account_id: {
224
225
  type: string;
225
226
  minimum: number;
226
227
  };
227
228
  query?: undefined;
228
229
  timezone?: undefined;
229
- limit?: undefined;
230
230
  page?: undefined;
231
231
  event?: undefined;
232
232
  } | {
@@ -255,9 +255,9 @@ export declare const calendarTools: ({
255
255
  };
256
256
  event?: undefined;
257
257
  } | {
258
+ limit?: undefined;
258
259
  query?: undefined;
259
260
  timezone?: undefined;
260
- limit?: undefined;
261
261
  page?: undefined;
262
262
  event: {
263
263
  type: string;
@@ -268,9 +268,9 @@ export declare const calendarTools: ({
268
268
  minimum: number;
269
269
  };
270
270
  } | {
271
+ limit?: undefined;
271
272
  query?: undefined;
272
273
  timezone?: undefined;
273
- limit?: undefined;
274
274
  page?: undefined;
275
275
  event?: undefined;
276
276
  account_id?: undefined;