driftnet 0.11.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -4
- package/README.zh-TW.md +10 -4
- package/dist/driftnet.mjs +1743 -575
- package/package.json +1 -1
- package/public/index.html +140 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "driftnet",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"mcpName": "io.github.KevinChu1110/driftnet",
|
|
5
5
|
"description": "Drop links into any chat; get them sorted, explained and searchable, for you and your agents. Any model, or none.",
|
|
6
6
|
"license": "MIT",
|
package/public/index.html
CHANGED
|
@@ -310,7 +310,13 @@
|
|
|
310
310
|
.tabs button[aria-selected="true"] { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
|
|
311
311
|
#st-body section[data-tab] { display: none; }
|
|
312
312
|
#st-body[data-tab="general"] section[data-tab="general"], #st-body[data-tab="access"] section[data-tab="access"],
|
|
313
|
-
#st-body[data-tab="ai"] section[data-tab="ai"] { display: block; }
|
|
313
|
+
#st-body[data-tab="ai"] section[data-tab="ai"], #st-body[data-tab="chats"] section[data-tab="chats"] { display: block; }
|
|
314
|
+
.chat-st { font-size: 13px; margin: 0 0 8px; display: flex; gap: 8px; align-items: baseline; overflow-wrap: anywhere; }
|
|
315
|
+
.chat-st::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); transform: translateY(-1px); }
|
|
316
|
+
.chat-st[data-state="connected"]::before, .chat-st[data-state="webhook"]::before { background: var(--ok); }
|
|
317
|
+
.chat-st[data-state="error"] { color: var(--danger); } .chat-st[data-state="error"]::before { background: var(--danger); }
|
|
318
|
+
.chat-st[data-state="starting"]::before { background: var(--accent); }
|
|
319
|
+
.chat-help { display: block; color: var(--muted); margin: 0 0 8px; } .chat-help a { color: var(--accent); }
|
|
314
320
|
.set-row { overflow-wrap: anywhere; }
|
|
315
321
|
#st-body:not(.show-env) .envname { display: none; }
|
|
316
322
|
.tabs { background: var(--bg); box-shadow: 0 -8px 0 var(--panel); margin-bottom: 16px; }
|
|
@@ -380,6 +386,8 @@
|
|
|
380
386
|
.crumb b { color: var(--accent); font-weight: 600; }
|
|
381
387
|
main { padding: 16px 20px 48px; display: grid; gap: 12px; align-content: start; }
|
|
382
388
|
.hint { color: var(--muted); font-size: 13px; margin: -4px 2px 0; }
|
|
389
|
+
.hint.corrected button { all: unset; color: var(--accent); text-decoration: underline; cursor: pointer; }
|
|
390
|
+
.hint.corrected button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
|
383
391
|
|
|
384
392
|
/* A card sits on top of two action strips that show while it is dragged. */
|
|
385
393
|
.swipe { content-visibility: auto; contain-intrinsic-size: auto 150px; position: relative; border-radius: 12px; overflow: hidden; scroll-margin-top: 90px; transition: height .25s ease, margin .25s ease, opacity .25s ease; }
|
|
@@ -757,6 +765,7 @@
|
|
|
757
765
|
stats: (n, s) => `${n} ${n === 1 ? "item" : "items"} · shared ${s}×`, shared: (n) => `shared ${n}×`,
|
|
758
766
|
empty: "Nothing here yet.", emptyStart: "Nothing here yet. Paste a link below to start — or save one with the Chrome extension, or run npx driftnet add <link>.",
|
|
759
767
|
noMatch: (q, v) => `No cards match “${q}” in ${v}.`, searchAll: "Search everything", searchIn: (v) => `Search ${v}…`,
|
|
768
|
+
showingFor: (c) => `Showing results for “${c}”`, searchInstead: (q) => `search for “${q}” instead`,
|
|
760
769
|
addTitle: "Add a link", addHelp: "A link to a tool, post or video (example.com works too)", addThis: (u) => `Add this link: ${u}`, kAdd: "Add a link",
|
|
761
770
|
addedAlready: "Already saved — here it is", addNothing: "No link found in that.", noSuggestion: "No suggestion for this card — press m to pick a folder", emptyFav: "No favorites yet — swipe a card right, or tap the star.",
|
|
762
771
|
pageMore: (n) => `Show more (${n} left)`, emptyTrash: "The trash is empty.", hint: "Swipe right to favorite, left to remove.", hintTrash: "Swipe right to restore.",
|
|
@@ -835,7 +844,17 @@
|
|
|
835
844
|
status: (e) => `Now: sorting by ${({ jev: "Jev", llm: "the model", heuristic: "built-in rules" })[e.judge] ?? e.judge}, summaries: ${e.summarizer === "off" ? "off" : e.summarizer}`, keep: "set — leave empty to keep", unset: "not set",
|
|
836
845
|
locked: "set by the environment driftnet runs in", forbidden: "Server settings can only be changed on the computer running driftnet (or set DRIFTNET_TOKEN). Display settings still work.",
|
|
837
846
|
savedServer: "Saved — already in effect", chat: "Chat replies", webhook: "Outgoing webhook", digest: "Scheduled digest", feed: "Feed (RSS)", genCopied: "New password generated and copied — press Save to keep it",
|
|
838
|
-
tabGeneral: "General", tabAccess: "Access", tabAi: "AI",
|
|
847
|
+
tabGeneral: "General", tabAccess: "Access", tabAi: "AI", tabChats: "Chats",
|
|
848
|
+
chatsIntro: "Paste a bot's token and press Save: driftnet connects right away, no restart. Then send the bot a link.",
|
|
849
|
+
chatsAdvanced: "Advanced", chatsAdvancedHelp: "Limit the bots to some chats or channels, and Slack without Socket Mode (needs a public URL).",
|
|
850
|
+
chatState: { off: "Not connected — paste a token below", starting: "Connecting…", connected: (n) => n ? `Connected as ${n}` : "Connected",
|
|
851
|
+
webhook: (url) => `Ready — messages arrive at ${url}`, error: (e) => `Problem: ${e}`, needs: (f) => `Also needs: ${f}`, publicUrl: "your public URL" },
|
|
852
|
+
chatHelp: {
|
|
853
|
+
telegram: ["In Telegram, open @BotFather, send /newbot and paste the token it gives you. For groups, also send /setprivacy → Disable so the bot sees links.", [["https://t.me/BotFather", "Open @BotFather"]]],
|
|
854
|
+
discord: ["In the Discord Developer Portal, create an application, open Bot, press Reset Token and turn on Message Content Intent on the same page. Invite it with OAuth2 → URL Generator → bot.", [["https://discord.com/developers/applications", "Discord Developer Portal"]]],
|
|
855
|
+
slack: ["Create an app at api.slack.com, turn on Socket Mode (that makes the xapp- token), add the bot scopes channels:history, groups:history, chat:write and the message events, then install it and copy the xoxb- Bot User OAuth Token.", [["https://api.slack.com/apps", "Slack apps"]]],
|
|
856
|
+
line: ["In LINE Developers, create a Messaging API channel: the Channel secret is under Basic settings, the access token under Messaging API. LINE has to reach driftnet from the internet, so it needs a public URL; set the webhook to that URL + /webhooks/line.", [["https://developers.line.biz/console/", "LINE Developers"], ["https://github.com/KevinChu1110/driftnet/blob/main/docs/online.md", "Putting it online"]]],
|
|
857
|
+
},
|
|
839
858
|
updates: "Updates", bkTitle: "Backup", bkHelp: "One zip with your whole catalogue (cards, folders, notes, tokens) and your settings. Passwords and keys are left out unless you tick the box.",
|
|
840
859
|
bkDownload: "Download backup", bkSecrets: "Include passwords and keys (enter the admin password again)", bkPassword: "Admin password",
|
|
841
860
|
bkRestoreFile: "Restore from a backup file", bkRestoreHelp: "The backup is checked first. Nothing changes until you restart driftnet; your current data is kept next to it as a before-restore copy.",
|
|
@@ -917,6 +936,8 @@
|
|
|
917
936
|
DRIFTNET_PROFILE: ["About you", "Who you are and what you care about (600 characters at most). The model uses it to judge what is worth your time and to write the \"why\" line. e.g. Backend engineer, Odoo and TypeScript; collecting AI coding tools and MCP servers; not interested in crypto."],
|
|
918
937
|
DRIFTNET_UPDATE_CHECK: ["Check for new versions", "Once a day driftnet asks the npm registry for the latest version number (nothing about you is sent) and shows a small notice. Off (the default) = never."],
|
|
919
938
|
DRIFTNET_BLOCK_DOMAINS: ["Never catalogue these domains", "Comma or space separated, e.g. example.com, spam.io"],
|
|
939
|
+
DRIFTNET_LINKS_PER_MESSAGE: ["Links read per chat message", "Default 10. Every link may cost a model call, and anyone in the chat can paste links; the rest are left unread."],
|
|
940
|
+
DRIFTNET_LINKS_PER_HOUR: ["Links read per chat per hour", "Default 60, per chat room or channel. Over the quota, links are left unread until the hour passes."],
|
|
920
941
|
DRIFTNET_WEBHOOK_URL: ["Webhook URL", "driftnet POSTs each new or updated card here (n8n, Zapier, Slack workflows…). Treated as a secret."],
|
|
921
942
|
DRIFTNET_WEBHOOK_SECRET: ["Webhook signing secret", "Optional. Adds X-Driftnet-Signature: sha256=<HMAC of the body>."],
|
|
922
943
|
DRIFTNET_DIGEST: ["Digest", "A short summary of new cards, posted into your chats."],
|
|
@@ -931,6 +952,15 @@
|
|
|
931
952
|
DRIFTNET_WHISPER: ["whisper path", "Only if whisper or whisper-cli (speech) is not on PATH."],
|
|
932
953
|
DRIFTNET_VIDEO_FRAMES: ["Show frames to the model", "Off by default. When on, and a reel or short is still thin after the local tools, up to 8 distinct frames are attached to the same summary request, so they go to the model you configured and nowhere else. The model must accept pictures (Ollama: a vision model)."],
|
|
933
954
|
DRIFTNET_WEBHOOK_ALLOW_LOCAL: ["Allow a local webhook", "Needed when the receiver is on your own network (n8n on a LAN). Only that exact address is allowed."],
|
|
955
|
+
TELEGRAM_BOT_TOKEN: ["Bot token", "Looks like 123456789:AA…"],
|
|
956
|
+
DRIFTNET_TELEGRAM_CHATS: ["Telegram: only these chats", "Comma-separated chat ids. Empty: anyone who finds the bot. The log prints the id of each new chat."],
|
|
957
|
+
DISCORD_BOT_TOKEN: ["Bot token", "From Bot → Reset Token (not the client secret)."],
|
|
958
|
+
DISCORD_CHANNELS: ["Discord: only these channels", "Comma-separated channel ids (right-click a channel → Copy Channel ID). Empty: every channel the bot can read."],
|
|
959
|
+
SLACK_APP_TOKEN: ["App-level token", "Starts with xapp- (Basic Information → App-Level Tokens, scope connections:write)."],
|
|
960
|
+
SLACK_BOT_TOKEN: ["Bot token", "Starts with xoxb- (OAuth & Permissions)."],
|
|
961
|
+
SLACK_SIGNING_SECRET: ["Slack signing secret", "Only for Slack without Socket Mode: events go to your public URL + /webhooks/slack."],
|
|
962
|
+
LINE_CHANNEL_SECRET: ["Channel secret", "32 letters and digits, under Basic settings."],
|
|
963
|
+
LINE_CHANNEL_ACCESS_TOKEN: ["Channel access token", "Messaging API → Channel access token (long-lived) → Issue."],
|
|
934
964
|
},
|
|
935
965
|
choices: {
|
|
936
966
|
DRIFTNET_LLM_PROVIDER: { "": "None", anthropic: "Anthropic (API key)", openai: "OpenAI-compatible (OpenAI, Grok, Ollama…)", gemini: "Google Gemini (API key)", bedrock: "Amazon Bedrock", vertex: "Google Vertex AI", "claude-cli": "Claude subscription (Claude Code CLI)", "gemini-cli": "Google account (Gemini CLI)" },
|
|
@@ -958,6 +988,7 @@
|
|
|
958
988
|
stats: (n, s) => `${n} 則 · 分享 ${s} 次`, shared: (n) => `分享 ${n} 次`,
|
|
959
989
|
empty: "這裡還沒有內容。", emptyStart: "還沒有內容。在下面貼一個連結開始,或用 Chrome 擴充功能收錄,也可以執行 npx driftnet add <連結>。",
|
|
960
990
|
noMatch: (q, v) => `「${v}」裡沒有符合「${q}」的卡片。`, searchAll: "搜尋全部", searchIn: (v) => `在「${v}」裡搜尋…`,
|
|
991
|
+
showingFor: (c) => `顯示「${c}」的搜尋結果`, searchInstead: (q) => `改搜尋「${q}」`,
|
|
961
992
|
addTitle: "收錄連結", addHelp: "工具、貼文或影片的連結(只打 example.com 也可以)", addThis: (u) => `收錄這個連結:${u}`, kAdd: "收錄連結",
|
|
962
993
|
addedAlready: "已經收過了,就是這張", addNothing: "裡面找不到連結。", noSuggestion: "這張卡片沒有建議的資料夾,按 m 自己選", emptyFav: "還沒有最愛,把卡片往右滑或按星號。",
|
|
963
994
|
pageMore: (n) => `再顯示 ${n} 張`, emptyTrash: "垃圾桶是空的。", hint: "往右滑加入最愛,往左滑移到垃圾桶。", hintTrash: "往右滑還原。",
|
|
@@ -1035,7 +1066,17 @@
|
|
|
1035
1066
|
status: (e) => `目前:分類用 ${({ jev: "Jev", llm: "模型", heuristic: "內建規則" })[e.judge] ?? e.judge},摘要用 ${e.summarizer === "off" ? "(未開啟)" : e.summarizer}`, keep: "已設定,留空就不變", unset: "未設定",
|
|
1036
1067
|
locked: "由執行環境設定", forbidden: "伺服器設定只能在執行 driftnet 的那台電腦上改(或設定 DRIFTNET_TOKEN)。顯示設定照常可用。",
|
|
1037
1068
|
savedServer: "已儲存,馬上生效", chat: "聊天室回覆", webhook: "對外 Webhook", digest: "定時摘要", feed: "訂閱源(RSS)", genCopied: "已產生新密碼並複製,按「儲存」才會生效",
|
|
1038
|
-
tabGeneral: "一般", tabAccess: "存取", tabAi: "AI",
|
|
1069
|
+
tabGeneral: "一般", tabAccess: "存取", tabAi: "AI", tabChats: "聊天室",
|
|
1070
|
+
chatsIntro: "貼上機器人的權杖,按「儲存」就會馬上連線,不用重新啟動。接著傳一個連結給機器人試試。",
|
|
1071
|
+
chatsAdvanced: "進階", chatsAdvancedHelp: "只讓機器人在某些聊天室或頻道運作,以及不用 Socket Mode 的 Slack(需要公開網址)。",
|
|
1072
|
+
chatState: { off: "尚未連線,請在下面貼上權杖", starting: "連線中…", connected: (n) => n ? `已連線:${n}` : "已連線",
|
|
1073
|
+
webhook: (url) => `已就緒,訊息會送到 ${url}`, error: (e) => `有問題:${e}`, needs: (f) => `還需要填:${f}`, publicUrl: "你的公開網址" },
|
|
1074
|
+
chatHelp: {
|
|
1075
|
+
telegram: ["在 Telegram 找 @BotFather,傳 /newbot,把它給你的權杖貼到這裡。要在群組用的話,再傳 /setprivacy → Disable,機器人才看得到連結。", [["https://t.me/BotFather", "開啟 @BotFather"]]],
|
|
1076
|
+
discord: ["在 Discord Developer Portal 建立應用程式,進 Bot 頁按 Reset Token,並在同一頁打開 Message Content Intent。再用 OAuth2 → URL Generator → bot 邀請它進伺服器。", [["https://discord.com/developers/applications", "Discord Developer Portal"]]],
|
|
1077
|
+
slack: ["在 api.slack.com 建立 app,打開 Socket Mode(會產生 xapp- 開頭的權杖),加上 bot 權限 channels:history、groups:history、chat:write 和 message 事件,安裝後複製 xoxb- 開頭的 Bot User OAuth Token。", [["https://api.slack.com/apps", "Slack apps"]]],
|
|
1078
|
+
line: ["在 LINE Developers 建立 Messaging API channel:Channel secret 在 Basic settings,存取權杖在 Messaging API 頁。LINE 要從網路連到 driftnet,所以需要公開網址;把 webhook 設成該網址加上 /webhooks/line。", [["https://developers.line.biz/console/", "LINE Developers"], ["https://github.com/KevinChu1110/driftnet/blob/main/docs/zh-TW/online.md", "放上網路"]]],
|
|
1079
|
+
},
|
|
1039
1080
|
updates: "更新", bkTitle: "備份", bkHelp: "一個 zip 檔,包含整個收藏(卡片、資料夾、筆記、權杖)和設定。除非勾選,否則不會包含密碼和金鑰。",
|
|
1040
1081
|
bkDownload: "下載備份", bkSecrets: "包含密碼和金鑰(需要再輸入一次管理員密碼)", bkPassword: "管理員密碼",
|
|
1041
1082
|
bkRestoreFile: "從備份檔還原", bkRestoreHelp: "會先檢查備份檔。重新啟動 driftnet 之前不會有任何改變;目前的資料會留在旁邊,檔名帶有 before-restore。",
|
|
@@ -1117,6 +1158,8 @@
|
|
|
1117
1158
|
DRIFTNET_PROFILE: ["關於你", "你是誰、關心什麼(最多 600 字)。模型會用它判斷什麼值得你花時間,並寫「為什麼值得看」那一句。例如:後端工程師,做 Odoo 和 TypeScript;蒐集 AI 寫程式工具和 MCP 伺服器;對加密貨幣沒興趣。"],
|
|
1118
1159
|
DRIFTNET_UPDATE_CHECK: ["檢查新版本", "每天向 npm 查一次最新版本號(不會傳送任何與你有關的資料),有新版就顯示小提示。關閉(預設)=完全不查。"],
|
|
1119
1160
|
DRIFTNET_BLOCK_DOMAINS: ["不要收錄的網域", "用逗號或空白分隔,例如 example.com, spam.io"],
|
|
1161
|
+
DRIFTNET_LINKS_PER_MESSAGE: ["每則聊天訊息最多讀幾條連結", "預設 10。每條連結都可能花一次模型呼叫,而群組裡任何人都能貼連結;超過的不讀。"],
|
|
1162
|
+
DRIFTNET_LINKS_PER_HOUR: ["每個聊天室每小時最多讀幾條連結", "預設 60,以聊天室/頻道計。超過配額的連結不讀,等這一小時過去。"],
|
|
1120
1163
|
DRIFTNET_WEBHOOK_URL: ["Webhook 網址", "每張新增或更新的卡片都會 POST 到這裡(n8n、Zapier、Slack 工作流程…)。視為機密。"],
|
|
1121
1164
|
DRIFTNET_WEBHOOK_SECRET: ["Webhook 簽章密鑰", "選填。會加上 X-Driftnet-Signature: sha256=<內容的 HMAC>。"],
|
|
1122
1165
|
DRIFTNET_DIGEST: ["定時摘要", "把新卡片整理成一則短訊息,貼進你的聊天室。"],
|
|
@@ -1131,6 +1174,15 @@
|
|
|
1131
1174
|
DRIFTNET_WHISPER: ["whisper 路徑", "只有 whisper 或 whisper-cli(語音轉文字)不在 PATH 時才需要。"],
|
|
1132
1175
|
DRIFTNET_VIDEO_FRAMES: ["把畫面交給模型看", "預設關閉。開啟後,reel 或 short 在本機工具讀完後仍然太少時,最多 8 張不重複的畫面會附在同一次摘要請求裡,只送給你設定的模型。模型必須看得懂圖片(Ollama:要用視覺模型)。"],
|
|
1133
1176
|
DRIFTNET_WEBHOOK_ALLOW_LOCAL: ["允許本機 Webhook", "接收端在你自己的區域網路時需要(例如內網的 n8n)。只放行你填的那個位址。"],
|
|
1177
|
+
TELEGRAM_BOT_TOKEN: ["機器人權杖", "長得像 123456789:AA…"],
|
|
1178
|
+
DRIFTNET_TELEGRAM_CHATS: ["Telegram:只限這些聊天室", "以逗號分隔的聊天室 ID。留空:任何找到機器人的人都能用。記錄檔會印出每個新聊天室的 ID。"],
|
|
1179
|
+
DISCORD_BOT_TOKEN: ["機器人權杖", "在 Bot → Reset Token 取得(不是 client secret)。"],
|
|
1180
|
+
DISCORD_CHANNELS: ["Discord:只限這些頻道", "以逗號分隔的頻道 ID(在頻道上按右鍵 → 複製頻道 ID)。留空:機器人看得到的所有頻道。"],
|
|
1181
|
+
SLACK_APP_TOKEN: ["App-level 權杖", "xapp- 開頭(Basic Information → App-Level Tokens,權限 connections:write)。"],
|
|
1182
|
+
SLACK_BOT_TOKEN: ["機器人權杖", "xoxb- 開頭(OAuth & Permissions 頁)。"],
|
|
1183
|
+
SLACK_SIGNING_SECRET: ["Slack 簽章密鑰", "只有不用 Socket Mode 時才需要:事件會送到你的公開網址 + /webhooks/slack。"],
|
|
1184
|
+
LINE_CHANNEL_SECRET: ["Channel secret", "32 個英數字,在 Basic settings 頁。"],
|
|
1185
|
+
LINE_CHANNEL_ACCESS_TOKEN: ["Channel access token", "Messaging API → Channel access token (long-lived) → Issue。"],
|
|
1134
1186
|
},
|
|
1135
1187
|
choices: {
|
|
1136
1188
|
DRIFTNET_LLM_PROVIDER: { "": "不使用", anthropic: "Anthropic(API 金鑰)", openai: "OpenAI 相容(OpenAI、Grok、Ollama…)", gemini: "Google Gemini(API 金鑰)", bedrock: "Amazon Bedrock", vertex: "Google Vertex AI", "claude-cli": "Claude 訂閱(Claude Code CLI)", "gemini-cli": "Google 帳號(Gemini CLI)" },
|
|
@@ -1165,7 +1217,7 @@
|
|
|
1165
1217
|
// Warnings (injection, hidden characters, low reputation) keep ⚠; "read from video" is good news, not a warning.
|
|
1166
1218
|
function flagLines(i, t) {
|
|
1167
1219
|
const flags = i.flags ?? [];
|
|
1168
|
-
const warn = flags.filter((f) => !f.startsWith("video-") && f !== "needs-transcript");
|
|
1220
|
+
const warn = flags.filter((f) => !f.startsWith("video-") && f !== "needs-transcript" && f !== "needs-page");
|
|
1169
1221
|
const steps = flags.filter((f) => f.startsWith("video-") && f !== "video-read");
|
|
1170
1222
|
return (warn.length ? `<div class="flag">⚠ ${esc(warn.map((f) => t.flags[f] ?? f).join(", "))}</div>` : "")
|
|
1171
1223
|
+ (flags.includes("video-read") ? `<div class="vflag">🎬 ${esc(t.flags["video-read"])}${steps.length ? ` · ${esc(steps.map((f) => t.flags[f] ?? f).join(", "))}` : ""}</div>` : "");
|
|
@@ -1236,7 +1288,11 @@
|
|
|
1236
1288
|
}
|
|
1237
1289
|
if (res.status === 401) throw Object.assign(new Error("unauthorized"), { unauthorized: true });
|
|
1238
1290
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
1239
|
-
if (meta)
|
|
1291
|
+
if (meta) {
|
|
1292
|
+
meta.total = Number(res.headers.get("x-total-count"));
|
|
1293
|
+
// A search that matched nothing as typed was run with its misspelt words corrected.
|
|
1294
|
+
try { meta.corrected = decodeURIComponent(res.headers.get("x-search-corrected") ?? ""); } catch { meta.corrected = ""; }
|
|
1295
|
+
}
|
|
1240
1296
|
return res.json();
|
|
1241
1297
|
}
|
|
1242
1298
|
|
|
@@ -1840,30 +1896,86 @@
|
|
|
1840
1896
|
const yes = (b) => (b ? "✓" : "—");
|
|
1841
1897
|
const accessStatus = `<p class="set-status">${esc(st.accessStatus(yes(a.passwordSet), yes(a.readKey), a.tunnel.running ? a.tunnel.url : "—"))}</p>`;
|
|
1842
1898
|
server = {
|
|
1843
|
-
general: group("language") + group("
|
|
1899
|
+
general: group("language") + group("digest") + group("webhook") + group("updates") + importPanel() + backupPanel(serverSettings),
|
|
1844
1900
|
access: accessStatus + accessPanel(serverSettings, field) + (agentTokens ? tokensPanel(serverSettings.access, agentTokens, minted) + pairPanel(serverSettings.access) : ""),
|
|
1845
1901
|
ai: `<p class="set-status" id="st-status">${esc(st.status(serverSettings.engines))}</p>` + aiPanel(serverSettings, field) +
|
|
1846
1902
|
`<fieldset class="set-group"><legend>${esc(st.plugins)}</legend><div class="set-row">${plugins}</div></fieldset>`,
|
|
1903
|
+
chats: chatsPanel(serverSettings, field) + group("chat"),
|
|
1847
1904
|
};
|
|
1848
1905
|
}
|
|
1849
|
-
//
|
|
1906
|
+
// Tabs instead of one long scroll: what you see, who gets in, which AI, which chats.
|
|
1850
1907
|
const tab = want ?? (welcome ? "ai" : store.get("driftnet-settings-tab") || "general");
|
|
1851
|
-
const tabs = [["general", st.tabGeneral], ["access", st.tabAccess], ["ai", st.tabAi]];
|
|
1908
|
+
const tabs = [["general", st.tabGeneral], ["access", st.tabAccess], ["ai", st.tabAi], ["chats", st.tabChats]];
|
|
1852
1909
|
const section = (k, html) => `<section data-tab="${k}" role="tabpanel" id="panel-${k}" aria-labelledby="tab-${k}">${html}</section>`;
|
|
1853
1910
|
$("st-title").textContent = st.title;
|
|
1854
1911
|
$("st-error").textContent = "";
|
|
1855
1912
|
$("st-body").innerHTML = (welcome ? `<p class="welcome">${esc(st.welcome)}</p>` : "") +
|
|
1856
1913
|
`<div class="tabs" role="tablist">${tabs.map(([k, l]) => `<button type="button" role="tab" id="tab-${k}" aria-controls="panel-${k}" tabindex="${k === tab ? 0 : -1}" data-tab-btn="${k}" aria-selected="${k === tab}">${esc(l)}</button>`).join("")}</div>` +
|
|
1857
1914
|
(typeof server === "string"
|
|
1858
|
-
? section("general", local) + section("access", server) + section("ai", server)
|
|
1859
|
-
: section("general", local + server.general) + section("access", server.access) + section("ai", server.ai));
|
|
1915
|
+
? section("general", local) + section("access", server) + section("ai", server) + section("chats", server)
|
|
1916
|
+
: section("general", local + server.general) + section("access", server.access) + section("ai", server.ai) + section("chats", server.chats));
|
|
1860
1917
|
$("st-body").dataset.tab = tab;
|
|
1861
1918
|
placeAi();
|
|
1862
1919
|
$("st-cancel").textContent = t.cancel;
|
|
1863
1920
|
$("st-save").textContent = st.save;
|
|
1864
|
-
|
|
1865
|
-
|
|
1921
|
+
// Re-drawn while open (after saving a chat token): keep who opened it.
|
|
1922
|
+
if (!$("settings-dlg").open) {
|
|
1923
|
+
settingsOpener = isDrawer() ? $("menu") : document.activeElement;
|
|
1924
|
+
$("settings-dlg").showModal();
|
|
1925
|
+
}
|
|
1866
1926
|
$("st-body").querySelector('[data-tab-btn][aria-selected="true"]')?.focus();
|
|
1927
|
+
pollChats();
|
|
1928
|
+
}
|
|
1929
|
+
/** Settings › Chats: one section per platform with its status, where to get the token, and its fields. */
|
|
1930
|
+
const CHAT_FIELDS = { telegram: ["TELEGRAM_BOT_TOKEN"], discord: ["DISCORD_BOT_TOKEN"], slack: ["SLACK_APP_TOKEN", "SLACK_BOT_TOKEN"],
|
|
1931
|
+
line: ["LINE_CHANNEL_SECRET", "LINE_CHANNEL_ACCESS_TOKEN"] };
|
|
1932
|
+
const CHAT_ADVANCED = ["DRIFTNET_TELEGRAM_CHATS", "DISCORD_CHANNELS", "SLACK_SIGNING_SECRET"];
|
|
1933
|
+
const CHAT_NAMES = { telegram: "Telegram", discord: "Discord", slack: "Slack", line: "LINE" };
|
|
1934
|
+
function chatStatusText(p, c) {
|
|
1935
|
+
const cs = T().st.chatState;
|
|
1936
|
+
if (!c) return "";
|
|
1937
|
+
if (c.state === "connected") return cs.connected(c.name);
|
|
1938
|
+
// A half-filled platform: name the missing field the way the form does.
|
|
1939
|
+
const needs = /^also needs (.+)$/.exec(c.error ?? "");
|
|
1940
|
+
if (c.state === "error" && needs) return cs.needs(needs[1].split(" and ").map((k) => T().st.labels[k]?.[0] ?? k).join(", "));
|
|
1941
|
+
if (c.state === "error") return cs.error(c.error ?? "");
|
|
1942
|
+
if (c.state === "webhook") return cs.webhook(`${(serverSettings?.access?.publicUrl ?? cs.publicUrl).replace(/\/$/, "")}/webhooks/${p}`);
|
|
1943
|
+
return cs[c.state] ?? "";
|
|
1944
|
+
}
|
|
1945
|
+
function chatsPanel(sv, field) {
|
|
1946
|
+
const st = T().st, byKey = (k) => sv.settings.find((x) => x.key === k);
|
|
1947
|
+
const rows = (keys) => keys.map(byKey).filter(Boolean).map(field).join("");
|
|
1948
|
+
const sections = Object.entries(CHAT_FIELDS).map(([p, keys]) => {
|
|
1949
|
+
const [help, links] = st.chatHelp[p];
|
|
1950
|
+
const c = sv.chats?.[p];
|
|
1951
|
+
const status = c ? `<p class="chat-st" data-chat-status="${p}" data-state="${esc(c.state)}" role="status">${esc(chatStatusText(p, c))}</p>` : "";
|
|
1952
|
+
return `<fieldset class="set-group" id="chat-${p}"><legend>${esc(CHAT_NAMES[p])}</legend>${status}
|
|
1953
|
+
<small class="chat-help">${esc(help)} ${links.map(([u, l]) => `<a href="${esc(u)}" target="_blank" rel="noopener noreferrer">${esc(l)}</a>`).join(" · ")}</small>${rows(keys)}</fieldset>`;
|
|
1954
|
+
}).join("");
|
|
1955
|
+
return `<p class="set-status">${esc(st.chatsIntro)}</p>` + sections +
|
|
1956
|
+
`<details class="set-adv"><summary>${esc(st.chatsAdvanced)}</summary><small>${esc(st.chatsAdvancedHelp)}</small>${rows(CHAT_ADVANCED)}</details>`;
|
|
1957
|
+
}
|
|
1958
|
+
/** While a bot is connecting, refresh the status lines (not the fields) every 2 s, for up to 30 s. */
|
|
1959
|
+
let chatPoll = null;
|
|
1960
|
+
function pollChats() {
|
|
1961
|
+
clearTimeout(chatPoll);
|
|
1962
|
+
let n = 0;
|
|
1963
|
+
const tick = async () => {
|
|
1964
|
+
const open = $("settings-dlg").open && serverSettings?.chats;
|
|
1965
|
+
if (!open || !Object.values(serverSettings.chats).some((c) => c.state === "starting") || ++n > 15) return;
|
|
1966
|
+
const token = store.get("driftnet-token");
|
|
1967
|
+
const r = await fetch("/api/settings", { headers: token ? { authorization: `Bearer ${token}` } : {} }).then((x) => x.ok ? x.json() : null).catch(() => null);
|
|
1968
|
+
if (r?.chats && serverSettings) {
|
|
1969
|
+
serverSettings.chats = r.chats;
|
|
1970
|
+
for (const el of $("st-body").querySelectorAll("[data-chat-status]")) {
|
|
1971
|
+
const c = r.chats[el.dataset.chatStatus];
|
|
1972
|
+
el.dataset.state = c.state;
|
|
1973
|
+
el.textContent = chatStatusText(el.dataset.chatStatus, c);
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
chatPoll = setTimeout(tick, 2000);
|
|
1977
|
+
};
|
|
1978
|
+
chatPoll = setTimeout(tick, 2000);
|
|
1867
1979
|
}
|
|
1868
1980
|
/** Settings › AI: the chosen provider's own fields sit under it; other providers', embeddings and tool paths fold into Advanced. */
|
|
1869
1981
|
const PROVIDER_FIELDS = { DRIFTNET_LLM_MODEL: "anthropic openai gemini bedrock vertex claude-cli gemini-cli", DRIFTNET_LLM_BASE_URL: "openai",
|
|
@@ -2231,9 +2343,9 @@
|
|
|
2231
2343
|
for (const el of body.querySelectorAll("[data-pref]")) prefs[el.dataset.pref] = el.type === "checkbox" ? el.checked : el.value;
|
|
2232
2344
|
store.set("driftnet-prefs", JSON.stringify(prefs));
|
|
2233
2345
|
applyPrefs();
|
|
2234
|
-
let serverSaved = false;
|
|
2346
|
+
let serverSaved = false, values = null;
|
|
2235
2347
|
if (serverSettings) {
|
|
2236
|
-
|
|
2348
|
+
values = {};
|
|
2237
2349
|
for (const el of body.querySelectorAll("[data-key]:not([disabled])")) {
|
|
2238
2350
|
const s = serverSettings.settings.find((x) => x.key === el.dataset.key);
|
|
2239
2351
|
if (s.secret ? el.value.trim() : el.value.trim() !== (s.value ?? "").trim()) values[s.key] = el.value.trim() === "" ? null : el.value;
|
|
@@ -2249,12 +2361,14 @@
|
|
|
2249
2361
|
if ("DRIFTNET_TOKEN" in values) values.DRIFTNET_TOKEN ? store.set("driftnet-token", values.DRIFTNET_TOKEN.trim()) : store.set("driftnet-token", "");
|
|
2250
2362
|
}
|
|
2251
2363
|
}
|
|
2252
|
-
return { serverSaved };
|
|
2364
|
+
return { serverSaved, chats: serverSaved && Object.keys(values ?? {}).some((k) => serverSettings.settings.find((x) => x.key === k)?.group === "chats") };
|
|
2253
2365
|
}
|
|
2254
2366
|
$("settings-form").onsubmit = async (e) => {
|
|
2255
2367
|
e.preventDefault();
|
|
2256
2368
|
const saved = await saveSettings();
|
|
2257
2369
|
if (!saved) return;
|
|
2370
|
+
// A chat token: stay on Chats and show whether it connects.
|
|
2371
|
+
if (saved.chats) { toast(T().st.savedServer); return openSettings(false, "chats"); }
|
|
2258
2372
|
$("settings-dlg").close();
|
|
2259
2373
|
toast(saved.serverSaved ? T().st.savedServer : T().saved);
|
|
2260
2374
|
load();
|
|
@@ -2281,6 +2395,9 @@
|
|
|
2281
2395
|
[/(\S+) did not resolve/, (m) => zh ? `沒有收錄:找不到 ${m[1]} 這個網站,請檢查網址。` : `Not saved: ${m[1]} couldn't be found — check the address.`],
|
|
2282
2396
|
[/links are not fetched|not a web link/, () => zh ? "沒有收錄:這不是網頁連結,要以 http:// 或 https:// 開頭。" : "Not saved: that isn't a web link — it needs to start with http:// or https://."],
|
|
2283
2397
|
[/(\S+) is blocked in your settings/, (m) => zh ? `沒有收錄:${m[1]} 在你的封鎖清單裡(設定 → AI →「不要收錄的網域」)。` : `Not saved: ${m[1]} is on your blocked list (Settings → AI → Never catalogue these domains).`],
|
|
2398
|
+
// A chat token of the wrong shape (Settings › Chats): name the field, and say what it should look like.
|
|
2399
|
+
[/^([A-Z_]+) doesn't look right: it (.+)/, (m) => { const l = T().st.labels[m[1]]?.[0] ?? m[1], hint = T().st.labels[m[1]]?.[1] ?? "";
|
|
2400
|
+
return zh ? `「${l}」看起來不對,請確認貼的是正確的值。${hint}` : `“${l}” doesn't look right: it ${m[2]}.`; }],
|
|
2284
2401
|
[/too many wrong passwords/, () => zh ? "密碼錯太多次,請 15 分鐘後再試。" : "Too many wrong passwords — try again in 15 minutes."],
|
|
2285
2402
|
];
|
|
2286
2403
|
for (const [re, f] of rules) { const m = re.exec(msg); if (m) return f(m); }
|
|
@@ -3590,12 +3707,15 @@
|
|
|
3590
3707
|
/** Cards fetched per page; the rest come as the reader reaches the end of the list. */
|
|
3591
3708
|
const PAGE = 60;
|
|
3592
3709
|
let pageTotal = 0, pageGen = 0, pageBusy = false, pageObserver = null, pageHost = null, keepPages = false;
|
|
3710
|
+
/** The query the reader asked to search exactly as typed (no spelling correction). */
|
|
3711
|
+
let exactQ = "";
|
|
3593
3712
|
const listParams = () => {
|
|
3594
3713
|
const p = new URLSearchParams();
|
|
3595
3714
|
if (prefs.sort !== "best") p.set("sort", prefs.sort);
|
|
3596
3715
|
if (state.view === "review") p.set("health", "dead,archived,stale");
|
|
3597
3716
|
else if (state.view !== "all") p.set("view", state.view);
|
|
3598
3717
|
for (const k of ["category", "kind", "q"]) if (state[k]) p.set(k, state[k]);
|
|
3718
|
+
if (state.q && state.q === exactQ) p.set("fuzzy", "0");
|
|
3599
3719
|
return p;
|
|
3600
3720
|
};
|
|
3601
3721
|
const moreHtml = () => items.length < pageTotal
|
|
@@ -3681,8 +3801,11 @@
|
|
|
3681
3801
|
const addQ = role === "admin" && state.q && linkLike(state.q) && (!items.length || /^(https?:\/\/|www\.)/i.test(state.q))
|
|
3682
3802
|
? `<div class="add-q"><button class="btn primary" type="button" data-add-q>${ic("plus")} ${esc(t.addThis(state.q))}</button></div>` : "";
|
|
3683
3803
|
const scoped = state.view !== "all" || state.category || state.kind;
|
|
3804
|
+
// Nothing matched the words as typed: say which spelling was searched, and offer the original.
|
|
3805
|
+
const fixed = items.length && state.q && meta.corrected
|
|
3806
|
+
? `<p class="hint corrected">${esc(t.showingFor(meta.corrected))} — <button type="button" data-search-exact>${esc(t.searchInstead(state.q))}</button></p>` : "";
|
|
3684
3807
|
$("list").innerHTML = items.length
|
|
3685
|
-
? addQ + (state.view === "trash" ? `<div class="trash-bar"><button class="btn danger" type="button" id="trash-empty">${ic("trash")} ${esc(t.emptyTrashBtn)}</button></div>` : "") + `<p class="hint swipe-hint">${esc(state.view === "trash" ? t.hintTrash : state.view === "inbox" ? t.hintInbox : state.view === "review" ? t.hintReview : t.hint)}</p>` + items.map(card).join("") + moreHtml()
|
|
3808
|
+
? fixed + addQ + (state.view === "trash" ? `<div class="trash-bar"><button class="btn danger" type="button" id="trash-empty">${ic("trash")} ${esc(t.emptyTrashBtn)}</button></div>` : "") + `<p class="hint swipe-hint">${esc(state.view === "trash" ? t.hintTrash : state.view === "inbox" ? t.hintInbox : state.view === "review" ? t.hintReview : t.hint)}</p>` + items.map(card).join("") + moreHtml()
|
|
3686
3809
|
: state.q
|
|
3687
3810
|
// Searching found nothing: say so (not "Inbox zero"), and offer the whole catalogue when only part of it was searched.
|
|
3688
3811
|
? `<div class="empty nomatch"><span>${esc(t.noMatch(state.q, viewName()))}</span>${scoped ? `<button class="btn" type="button" data-search-all>${esc(t.searchAll)}</button>` : ""}${addQ}</div>`
|
|
@@ -3692,6 +3815,7 @@
|
|
|
3692
3815
|
<button class="btn" type="button" data-connect-empty>${ic("plug")} ${esc(t.st.connect)}</button>${templateChooser(t)}` : ""}</div>`;
|
|
3693
3816
|
$("list").querySelector("[data-add-q]")?.addEventListener("click", (e) => { const b = e.currentTarget; b.disabled = true; addUrl(state.q).then(() => { if (b.isConnected) b.disabled = false; }); });
|
|
3694
3817
|
$("list").querySelector("[data-search-all]")?.addEventListener("click", () => { Object.assign(state, { view: "all", category: "", kind: "" }); load(); });
|
|
3818
|
+
$("list").querySelector("[data-search-exact]")?.addEventListener("click", () => { exactQ = state.q; render(); });
|
|
3695
3819
|
watchMore();
|
|
3696
3820
|
if (keep) scrollTo({ top: y });
|
|
3697
3821
|
$("add-form")?.addEventListener("submit", addLink);
|