driftnet 0.2.2 → 0.3.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 +14 -1
- package/README.zh-TW.md +10 -1
- package/dist/driftnet.mjs +137 -75
- package/package.json +1 -1
- package/public/index.html +1187 -149
package/README.md
CHANGED
|
@@ -113,7 +113,7 @@ where to read it on the web page. Want the summary in the chat instead, or no re
|
|
|
113
113
|
|
|
114
114
|
### The web page
|
|
115
115
|
|
|
116
|
-
<p align="center"><img src="https://raw.githubusercontent.com/KevinChu1110/driftnet/main/assets/phone-en.jpg" alt="driftnet on a phone: the ☰ drawer with your folder tree, the
|
|
116
|
+
<p align="center"><img src="https://raw.githubusercontent.com/KevinChu1110/driftnet/main/assets/phone-en.jpg" alt="driftnet on a phone: the ☰ drawer with your folder tree, filing a card on the mind map (hold it, then tap a folder), and a card being swiped left to the trash" width="100%"></p>
|
|
117
117
|
|
|
118
118
|
Every link lands on a page you can search, filter by folder and kind, and open from a phone. On a
|
|
119
119
|
phone the sidebar folds into a ☰ drawer, and a line under the search box says what you're looking at.
|
|
@@ -122,6 +122,11 @@ phone the sidebar folds into a ☰ drawer, and a line under the search box says
|
|
|
122
122
|
the AI files new links by each folder's path and description, so “Games › MapleStory — Artale
|
|
123
123
|
helpers” gets the MapleStory tools. Move a card with 📁 **Move to…**, or drag it by ⠿ onto a folder
|
|
124
124
|
on a computer; a card you placed stays put. Deleting a folder moves its links up one level.
|
|
125
|
+
- **Mind map.** Folders branch out on both sides of the root like XMind, a colour per branch (one tap
|
|
126
|
+
switches to everything on the right). Tap a folder to open
|
|
127
|
+
it, tap a card to preview it, and drag a card onto a folder to file it (on a phone, hold it a moment
|
|
128
|
+
first, so a quick swipe still pans). Drag a folder onto another to nest it. Search highlights the
|
|
129
|
+
matches; big folders fold into “+N”.
|
|
125
130
|
- **Swipe right** to add a favorite, **swipe left** to move to the trash; a short swipe does nothing,
|
|
126
131
|
and scrolling never counts as a swipe. On a computer, use ☆ and 🗑 or drag with the mouse.
|
|
127
132
|
- **Undo** right after removing, or restore anything later from **Trash**. Trashed links disappear from
|
|
@@ -134,8 +139,15 @@ phone the sidebar folds into a ☰ drawer, and a line under the search box says
|
|
|
134
139
|
newest, most shared), compact cards, tags, chat text, light or dark.
|
|
135
140
|
- **Export** everything as one Markdown file, or as a zip of Markdown files with front matter that
|
|
136
141
|
Obsidian opens as a vault and Notion imports (Import → Markdown & CSV).
|
|
142
|
+
- **Shared links open read-only.** A card link from a chat bot or an agent carries the read-only share
|
|
143
|
+
key, so it opens on a phone without a password; edit buttons appear after **Unlock** with the admin
|
|
144
|
+
password. Forgot it? Open driftnet on the computer it runs on: Settings there sets a new one.
|
|
145
|
+
- **Keyboard.** `j`/`k` step through cards, `f` favorite, `m` move (type to find the folder), `n` note,
|
|
146
|
+
`#` trash, `z` undo, `/` search, `g m` mind map, `?` the list.
|
|
137
147
|
- **Add to Home Screen** to open it like an app.
|
|
138
148
|
|
|
149
|
+
<p align="center"><img src="https://raw.githubusercontent.com/KevinChu1110/driftnet/main/assets/map-en.jpg" alt="The mind map: folders branching out from driftnet, cards under them, the read-only view on a phone" width="100%"></p>
|
|
150
|
+
|
|
139
151
|
<p align="center"><img src="https://raw.githubusercontent.com/KevinChu1110/driftnet/main/assets/notes-settings-en.jpg" alt="The notes page with links to cards, and the settings dialog" width="100%"></p>
|
|
140
152
|
|
|
141
153
|
### Chrome extension
|
|
@@ -398,6 +410,7 @@ pnpm typecheck && pnpm test
|
|
|
398
410
|
CHROME=/path/to/chromium pnpm e2e:extension # the extension in a real browser (Chrome for Testing or Chromium)
|
|
399
411
|
CHROME=/path/to/chrome pnpm e2e:web # the web page on a phone-sized screen, with real touch swipes
|
|
400
412
|
pnpm build:npm # the npm package in dist/npm (try: cd dist/npm && npm pack)
|
|
413
|
+
pnpm demo -- --many --private --password demo-pass-123 --read-key demo-share-key-0000 # a throwaway driftnet with demo data
|
|
401
414
|
```
|
|
402
415
|
|
|
403
416
|
Releasing: bump the version in `apps/server/package.json`, `server.json` and `.claude-plugin/`, then push a tag
|
package/README.zh-TW.md
CHANGED
|
@@ -105,7 +105,7 @@ curl -X POST localhost:8787/api/chat -H 'content-type: application/json' \
|
|
|
105
105
|
|
|
106
106
|
### 網頁
|
|
107
107
|
|
|
108
|
-
<p align="center"><img src="https://raw.githubusercontent.com/KevinChu1110/driftnet/main/assets/phone-zh-TW.jpg" alt="driftnet 在手機上:☰
|
|
108
|
+
<p align="center"><img src="https://raw.githubusercontent.com/KevinChu1110/driftnet/main/assets/phone-zh-TW.jpg" alt="driftnet 在手機上:☰ 選單裡的資料夾樹、在樹狀圖上整理卡片(按住後點資料夾)、一張卡片往左滑向垃圾桶" width="100%"></p>
|
|
109
109
|
|
|
110
110
|
每個連結都會整理到一個網頁上,可以搜尋、依資料夾和類型篩選,手機也能開。在手機上,側邊欄會收進左上角的 ☰,
|
|
111
111
|
搜尋框下方有一行字告訴你現在看的是哪個資料夾。
|
|
@@ -113,6 +113,9 @@ curl -X POST localhost:8787/api/chat -H 'content-type: application/json' \
|
|
|
113
113
|
- **資料夾就是分類。**在側邊欄用 + 和 ⋯ 新增、巢狀、改名、寫說明;AI 會照資料夾的路徑和說明分新連結,
|
|
114
114
|
例如「遊戲 › 楓之谷 — Artale 小工具」就會收到楓之谷的工具。卡片可以按 📁 **移動到…**,電腦上也能拖著 ⠿ 丟到資料夾;
|
|
115
115
|
自己放好的卡片不會再被 AI 搬走。刪掉資料夾時,裡面的連結會移到上一層。
|
|
116
|
+
- **樹狀圖。**資料夾像 XMind 一樣從中心往兩側展開,每條分支一個顏色(按一下可以切成全部往右)。點資料夾展開,點卡片預覽;把卡片拖到資料夾上就完成整理
|
|
117
|
+
(手機上先按住一下再拖,所以快速滑動還是在移動畫面)。資料夾拖到另一個資料夾底下就變子資料夾。搜尋會標亮符合的節點,
|
|
118
|
+
卡片太多的資料夾會收成「還有 N 張」。
|
|
116
119
|
- **往右滑**加入最愛,**往左滑**移到垃圾桶;滑太短不會觸發,上下捲動也不會被當成滑動。電腦上可以按 ☆ 和 🗑,或用滑鼠拖曳。
|
|
117
120
|
- 剛移除時可以馬上按**復原**,之後也能隨時從**垃圾桶**還原。移到垃圾桶的連結,agent 和 `/llms.txt` 也看不到;如果有人再次分享,它會自動回來。
|
|
118
121
|
- **筆記。**每張卡片都能按 📝 寫自己的筆記(試過了嗎?要 GPU 嗎?)。大家丟連結時在聊天室說的話也會顯示在卡片上(💬),
|
|
@@ -121,8 +124,13 @@ curl -X POST localhost:8787/api/chat -H 'content-type: application/json' \
|
|
|
121
124
|
不用重新啟動就生效。每個瀏覽器各自的顯示:排序(值得看/最新/最多人分享)、精簡卡片、標籤、聊天原文、深淺色。
|
|
122
125
|
- **匯出**全部內容:一個 Markdown 檔,或一包附 front matter 的 Markdown(zip),Obsidian 可以直接當 vault 開,
|
|
123
126
|
Notion 可以匯入(匯入 → Markdown & CSV)。
|
|
127
|
+
- **分享出去的連結是唯讀的。**聊天機器人和 agent 給你的卡片連結帶著唯讀分享碼,手機點開不用密碼;按「解鎖編輯」輸入管理密碼後,
|
|
128
|
+
才會出現編輯按鈕。忘記密碼的話,到跑 driftnet 的那台電腦打開網頁,設定裡可以直接設新的。
|
|
129
|
+
- **鍵盤。**`j`/`k` 上下一張、`f` 最愛、`m` 移動(打字找資料夾)、`n` 筆記、`#` 垃圾桶、`z` 復原、`/` 搜尋、`g m` 樹狀圖、`?` 看全部快捷鍵。
|
|
124
130
|
- 用瀏覽器的**加入主畫面**,就能像 App 一樣打開。
|
|
125
131
|
|
|
132
|
+
<p align="center"><img src="https://raw.githubusercontent.com/KevinChu1110/driftnet/main/assets/map-zh-TW.jpg" alt="樹狀圖:資料夾從 driftnet 往外展開、底下掛著卡片;以及手機上的唯讀瀏覽" width="100%"></p>
|
|
133
|
+
|
|
126
134
|
<p align="center"><img src="https://raw.githubusercontent.com/KevinChu1110/driftnet/main/assets/notes-settings-zh-TW.jpg" alt="筆記頁(可以連到卡片)和設定視窗" width="100%"></p>
|
|
127
135
|
|
|
128
136
|
### Chrome 擴充
|
|
@@ -367,6 +375,7 @@ pnpm typecheck && pnpm test
|
|
|
367
375
|
CHROME=/path/to/chromium pnpm e2e:extension # 在真的瀏覽器裡測擴充(Chrome for Testing 或 Chromium)
|
|
368
376
|
CHROME=/path/to/chrome pnpm e2e:web # 用手機尺寸和真的觸控滑動測網頁
|
|
369
377
|
pnpm build:npm # 打包 npm 套件到 dist/npm(試用:cd dist/npm && npm pack)
|
|
378
|
+
pnpm demo -- --many --private --password demo-pass-123 --read-key demo-share-key-0000 # 開一個帶示範資料的臨時 driftnet
|
|
370
379
|
```
|
|
371
380
|
|
|
372
381
|
發新版:改 `apps/server/package.json`、`server.json` 和 `.claude-plugin/` 裡的版號,再推一個標籤
|
package/dist/driftnet.mjs
CHANGED
|
@@ -1212,6 +1212,73 @@ ${digest.text.slice(0, 500)}`,
|
|
|
1212
1212
|
}
|
|
1213
1213
|
});
|
|
1214
1214
|
|
|
1215
|
+
// packages/core/src/i18n.ts
|
|
1216
|
+
function resolveLocale(env2 = process.env) {
|
|
1217
|
+
const explicit = env2.DRIFTNET_LOCALE;
|
|
1218
|
+
if (explicit && explicit in MESSAGES) return explicit;
|
|
1219
|
+
return /chinese|中文|zh/i.test(env2.DRIFTNET_LANGUAGE ?? "") ? "zh-TW" : "en";
|
|
1220
|
+
}
|
|
1221
|
+
function messages(locale = resolveLocale()) {
|
|
1222
|
+
return MESSAGES[locale];
|
|
1223
|
+
}
|
|
1224
|
+
function categoryLabel(id, locale = resolveLocale()) {
|
|
1225
|
+
return CATEGORY_LABELS[id]?.[locale] ?? id;
|
|
1226
|
+
}
|
|
1227
|
+
var MESSAGES, CATEGORY_LABELS, LOCALES;
|
|
1228
|
+
var init_i18n = __esm({
|
|
1229
|
+
"packages/core/src/i18n.ts"() {
|
|
1230
|
+
"use strict";
|
|
1231
|
+
MESSAGES = {
|
|
1232
|
+
en: {
|
|
1233
|
+
injection: "\u26A0\uFE0F Contains instructions aimed at AI \u2014 hidden from agent feeds",
|
|
1234
|
+
lowReputation: "\u26A0\uFE0F Source often voted down \u2014 not summarized",
|
|
1235
|
+
mentions: "Mentions: ",
|
|
1236
|
+
listSep: ", ",
|
|
1237
|
+
queued: "\u23F3 Waiting for a summary (queued for your agent)",
|
|
1238
|
+
alsoFound: "+ ",
|
|
1239
|
+
seenBefore: "(already saved)",
|
|
1240
|
+
cached: (n) => `(already saved \xB7 shared ${n}\xD7)`,
|
|
1241
|
+
footer: (id) => `#${id} \xB7 reply \u{1F44D}${id} / \u{1F44E}${id}`,
|
|
1242
|
+
noItem: (id) => `No item #${id}.`,
|
|
1243
|
+
votedUp: (id) => `\u{1F44D} #${id}`,
|
|
1244
|
+
votedDown: (id) => `\u{1F44E} #${id} \u2014 noted, similar items will cost less next time`,
|
|
1245
|
+
locale: "en"
|
|
1246
|
+
},
|
|
1247
|
+
"zh-TW": {
|
|
1248
|
+
injection: "\u26A0\uFE0F \u5167\u5BB9\u542B\u6709\u91DD\u5C0D AI \u7684\u6307\u4EE4\uFF0C\u4E0D\u6703\u63D0\u4F9B\u7D66 agent",
|
|
1249
|
+
lowReputation: "\u26A0\uFE0F \u6B64\u4F86\u6E90\u5E38\u88AB\u5012\u8B9A\uFF0C\u672A\u505A\u6458\u8981",
|
|
1250
|
+
mentions: "\u63D0\u5230\uFF1A",
|
|
1251
|
+
listSep: "\u3001",
|
|
1252
|
+
queued: "\u23F3 \u7B49\u5F85\u6458\u8981\uFF08\u5DF2\u6392\u9032 agent \u7684\u5F85\u6574\u7406\u4F47\u5217\uFF09",
|
|
1253
|
+
alsoFound: "\uFF0B ",
|
|
1254
|
+
seenBefore: "\uFF08\u5DF2\u6536\u9304\u904E\uFF09",
|
|
1255
|
+
cached: (n) => `\uFF08\u5DF2\u6536\u9304\u904E \xB7 \u5206\u4EAB ${n} \u6B21\uFF09`,
|
|
1256
|
+
footer: (id) => `#${id} \xB7 \u56DE\u8986 \u{1F44D}${id} / \u{1F44E}${id}`,
|
|
1257
|
+
noItem: (id) => `\u627E\u4E0D\u5230 #${id}\u3002`,
|
|
1258
|
+
votedUp: (id) => `\u{1F44D} #${id}`,
|
|
1259
|
+
votedDown: (id) => `\u{1F44E} #${id} \u2014 \u6536\u5230\uFF0C\u4E4B\u5F8C\u985E\u4F3C\u7684\u5167\u5BB9\u6703\u5C11\u82B1\u4E00\u9EDE`,
|
|
1260
|
+
locale: "zh-TW"
|
|
1261
|
+
}
|
|
1262
|
+
};
|
|
1263
|
+
CATEGORY_LABELS = {
|
|
1264
|
+
"coding-agent": { en: "Coding agents", "zh-TW": "AI \u5BEB\u7A0B\u5F0F" },
|
|
1265
|
+
"agent-framework": { en: "Agent frameworks", "zh-TW": "Agent \u6846\u67B6" },
|
|
1266
|
+
"chat-assistant": { en: "Chat assistants", "zh-TW": "\u804A\u5929\u52A9\u7406" },
|
|
1267
|
+
"image-video": { en: "Image & video", "zh-TW": "\u5716\u7247\u5F71\u7247" },
|
|
1268
|
+
"design-frontend": { en: "Design & frontend", "zh-TW": "\u8A2D\u8A08\u524D\u7AEF" },
|
|
1269
|
+
"audio-voice": { en: "Audio & voice", "zh-TW": "\u8A9E\u97F3\u97F3\u8A0A" },
|
|
1270
|
+
automation: { en: "Automation", "zh-TW": "\u81EA\u52D5\u5316" },
|
|
1271
|
+
"knowledge-rag": { en: "Knowledge & RAG", "zh-TW": "\u77E5\u8B58\u5EAB" },
|
|
1272
|
+
"model-infra": { en: "Models & infra", "zh-TW": "\u6A21\u578B\u8207\u57FA\u790E\u8A2D\u65BD" },
|
|
1273
|
+
productivity: { en: "Productivity", "zh-TW": "\u751F\u7522\u529B" },
|
|
1274
|
+
news: { en: "News", "zh-TW": "\u65B0\u805E\u52D5\u614B" },
|
|
1275
|
+
learning: { en: "Learning", "zh-TW": "\u5B78\u7FD2\u8CC7\u6E90" },
|
|
1276
|
+
other: { en: "Other", "zh-TW": "\u5176\u4ED6" }
|
|
1277
|
+
};
|
|
1278
|
+
LOCALES = Object.keys(MESSAGES);
|
|
1279
|
+
}
|
|
1280
|
+
});
|
|
1281
|
+
|
|
1215
1282
|
// packages/core/src/store.ts
|
|
1216
1283
|
import { mkdirSync } from "node:fs";
|
|
1217
1284
|
import { dirname } from "node:path";
|
|
@@ -1253,6 +1320,7 @@ var FolderError, WORTH_ORDER, Store, PENDING_SQL;
|
|
|
1253
1320
|
var init_store = __esm({
|
|
1254
1321
|
"packages/core/src/store.ts"() {
|
|
1255
1322
|
"use strict";
|
|
1323
|
+
init_i18n();
|
|
1256
1324
|
FolderError = class extends Error {
|
|
1257
1325
|
};
|
|
1258
1326
|
WORTH_ORDER = "CASE worth WHEN 'skip' THEN 0 WHEN 'low' THEN 1 WHEN 'normal' THEN 2 ELSE 3 END";
|
|
@@ -1417,6 +1485,10 @@ var init_store = __esm({
|
|
|
1417
1485
|
if (!name2) throw new FolderError("a folder needs a name");
|
|
1418
1486
|
const parent = input.parent || null;
|
|
1419
1487
|
if (parent && !this.folderExists(parent)) throw new FolderError(`no folder ${parent}`);
|
|
1488
|
+
const names = (f) => (f.name ? [f.name] : [f.id, ...LOCALES.map((l) => categoryLabel(f.id, l))]).map((x) => x.toLowerCase());
|
|
1489
|
+
if (this.folders().some((f) => (f.parent ?? null) === parent && names(f).includes(name2.toLowerCase()))) {
|
|
1490
|
+
throw new FolderError(`there is already a folder called \u201C${name2}\u201D here`);
|
|
1491
|
+
}
|
|
1420
1492
|
const base = name2.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40);
|
|
1421
1493
|
let id = base.length >= 2 ? base : `f-${Math.random().toString(36).slice(2, 8)}`;
|
|
1422
1494
|
while (this.folderExists(id)) id = `${base || "f"}-${Math.random().toString(36).slice(2, 6)}`;
|
|
@@ -2000,73 +2072,6 @@ var init_llm = __esm({
|
|
|
2000
2072
|
}
|
|
2001
2073
|
});
|
|
2002
2074
|
|
|
2003
|
-
// packages/core/src/i18n.ts
|
|
2004
|
-
function resolveLocale(env2 = process.env) {
|
|
2005
|
-
const explicit = env2.DRIFTNET_LOCALE;
|
|
2006
|
-
if (explicit && explicit in MESSAGES) return explicit;
|
|
2007
|
-
return /chinese|中文|zh/i.test(env2.DRIFTNET_LANGUAGE ?? "") ? "zh-TW" : "en";
|
|
2008
|
-
}
|
|
2009
|
-
function messages(locale = resolveLocale()) {
|
|
2010
|
-
return MESSAGES[locale];
|
|
2011
|
-
}
|
|
2012
|
-
function categoryLabel(id, locale = resolveLocale()) {
|
|
2013
|
-
return CATEGORY_LABELS[id]?.[locale] ?? id;
|
|
2014
|
-
}
|
|
2015
|
-
var MESSAGES, CATEGORY_LABELS, LOCALES;
|
|
2016
|
-
var init_i18n = __esm({
|
|
2017
|
-
"packages/core/src/i18n.ts"() {
|
|
2018
|
-
"use strict";
|
|
2019
|
-
MESSAGES = {
|
|
2020
|
-
en: {
|
|
2021
|
-
injection: "\u26A0\uFE0F Contains instructions aimed at AI \u2014 hidden from agent feeds",
|
|
2022
|
-
lowReputation: "\u26A0\uFE0F Source often voted down \u2014 not summarized",
|
|
2023
|
-
mentions: "Mentions: ",
|
|
2024
|
-
listSep: ", ",
|
|
2025
|
-
queued: "\u23F3 Waiting for a summary (queued for your agent)",
|
|
2026
|
-
alsoFound: "+ ",
|
|
2027
|
-
seenBefore: "(already saved)",
|
|
2028
|
-
cached: (n) => `(already saved \xB7 shared ${n}\xD7)`,
|
|
2029
|
-
footer: (id) => `#${id} \xB7 reply \u{1F44D}${id} / \u{1F44E}${id}`,
|
|
2030
|
-
noItem: (id) => `No item #${id}.`,
|
|
2031
|
-
votedUp: (id) => `\u{1F44D} #${id}`,
|
|
2032
|
-
votedDown: (id) => `\u{1F44E} #${id} \u2014 noted, similar items will cost less next time`,
|
|
2033
|
-
locale: "en"
|
|
2034
|
-
},
|
|
2035
|
-
"zh-TW": {
|
|
2036
|
-
injection: "\u26A0\uFE0F \u5167\u5BB9\u542B\u6709\u91DD\u5C0D AI \u7684\u6307\u4EE4\uFF0C\u4E0D\u6703\u63D0\u4F9B\u7D66 agent",
|
|
2037
|
-
lowReputation: "\u26A0\uFE0F \u6B64\u4F86\u6E90\u5E38\u88AB\u5012\u8B9A\uFF0C\u672A\u505A\u6458\u8981",
|
|
2038
|
-
mentions: "\u63D0\u5230\uFF1A",
|
|
2039
|
-
listSep: "\u3001",
|
|
2040
|
-
queued: "\u23F3 \u7B49\u5F85\u6458\u8981\uFF08\u5DF2\u6392\u9032 agent \u7684\u5F85\u6574\u7406\u4F47\u5217\uFF09",
|
|
2041
|
-
alsoFound: "\uFF0B ",
|
|
2042
|
-
seenBefore: "\uFF08\u5DF2\u6536\u9304\u904E\uFF09",
|
|
2043
|
-
cached: (n) => `\uFF08\u5DF2\u6536\u9304\u904E \xB7 \u5206\u4EAB ${n} \u6B21\uFF09`,
|
|
2044
|
-
footer: (id) => `#${id} \xB7 \u56DE\u8986 \u{1F44D}${id} / \u{1F44E}${id}`,
|
|
2045
|
-
noItem: (id) => `\u627E\u4E0D\u5230 #${id}\u3002`,
|
|
2046
|
-
votedUp: (id) => `\u{1F44D} #${id}`,
|
|
2047
|
-
votedDown: (id) => `\u{1F44E} #${id} \u2014 \u6536\u5230\uFF0C\u4E4B\u5F8C\u985E\u4F3C\u7684\u5167\u5BB9\u6703\u5C11\u82B1\u4E00\u9EDE`,
|
|
2048
|
-
locale: "zh-TW"
|
|
2049
|
-
}
|
|
2050
|
-
};
|
|
2051
|
-
CATEGORY_LABELS = {
|
|
2052
|
-
"coding-agent": { en: "Coding agents", "zh-TW": "AI \u5BEB\u7A0B\u5F0F" },
|
|
2053
|
-
"agent-framework": { en: "Agent frameworks", "zh-TW": "Agent \u6846\u67B6" },
|
|
2054
|
-
"chat-assistant": { en: "Chat assistants", "zh-TW": "\u804A\u5929\u52A9\u7406" },
|
|
2055
|
-
"image-video": { en: "Image & video", "zh-TW": "\u5716\u7247\u5F71\u7247" },
|
|
2056
|
-
"design-frontend": { en: "Design & frontend", "zh-TW": "\u8A2D\u8A08\u524D\u7AEF" },
|
|
2057
|
-
"audio-voice": { en: "Audio & voice", "zh-TW": "\u8A9E\u97F3\u97F3\u8A0A" },
|
|
2058
|
-
automation: { en: "Automation", "zh-TW": "\u81EA\u52D5\u5316" },
|
|
2059
|
-
"knowledge-rag": { en: "Knowledge & RAG", "zh-TW": "\u77E5\u8B58\u5EAB" },
|
|
2060
|
-
"model-infra": { en: "Models & infra", "zh-TW": "\u6A21\u578B\u8207\u57FA\u790E\u8A2D\u65BD" },
|
|
2061
|
-
productivity: { en: "Productivity", "zh-TW": "\u751F\u7522\u529B" },
|
|
2062
|
-
news: { en: "News", "zh-TW": "\u65B0\u805E\u52D5\u614B" },
|
|
2063
|
-
learning: { en: "Learning", "zh-TW": "\u5B78\u7FD2\u8CC7\u6E90" },
|
|
2064
|
-
other: { en: "Other", "zh-TW": "\u5176\u4ED6" }
|
|
2065
|
-
};
|
|
2066
|
-
LOCALES = Object.keys(MESSAGES);
|
|
2067
|
-
}
|
|
2068
|
-
});
|
|
2069
|
-
|
|
2070
2075
|
// packages/core/src/home.ts
|
|
2071
2076
|
import { existsSync, mkdirSync as mkdirSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
2072
2077
|
import { homedir } from "node:os";
|
|
@@ -2285,12 +2290,35 @@ function isLocal(req) {
|
|
|
2285
2290
|
const forwarded = ["x-forwarded-for", "forwarded", "x-real-ip", "cf-connecting-ip", "cf-ray"].some((h) => req.headers[h] !== void 0);
|
|
2286
2291
|
return loopback && host && !forwarded;
|
|
2287
2292
|
}
|
|
2293
|
+
function isTrustedLocal(req) {
|
|
2294
|
+
if (!isLocal(req)) return false;
|
|
2295
|
+
const origin = req.headers.origin;
|
|
2296
|
+
const host = req.headers.host ?? "";
|
|
2297
|
+
return !origin || origin === `http://${host}` || origin === `https://${host}`;
|
|
2298
|
+
}
|
|
2299
|
+
function foreignOrigin(req) {
|
|
2300
|
+
const origin = req.headers.origin;
|
|
2301
|
+
if (!origin || origin.startsWith("chrome-extension://")) return false;
|
|
2302
|
+
const host = req.headers.host ?? "";
|
|
2303
|
+
return origin !== `http://${host}` && origin !== `https://${host}`;
|
|
2304
|
+
}
|
|
2305
|
+
function role(req, env2) {
|
|
2306
|
+
if (isTrustedLocal(req) || (token(env2) ? isAdmin(req, env2) : true)) return "admin";
|
|
2307
|
+
return canRead(req, env2) ? "reader" : "none";
|
|
2308
|
+
}
|
|
2288
2309
|
function shareBase(env2) {
|
|
2289
2310
|
const base = (env2.DRIFTNET_TUNNEL_URL || env2.DRIFTNET_PUBLIC_URL)?.replace(/\/$/, "");
|
|
2290
2311
|
if (!base) return void 0;
|
|
2291
2312
|
const k = readKey(env2);
|
|
2292
2313
|
return isPrivate(env2) && k ? `${base}/?key=${encodeURIComponent(k)}` : base;
|
|
2293
2314
|
}
|
|
2315
|
+
function strength(password) {
|
|
2316
|
+
const kinds = [/[a-z]/, /[A-Z]/, /\d/, /[^\w]/].filter((r) => r.test(password)).length;
|
|
2317
|
+
if (password.length >= 16 && kinds >= 2) return "strong";
|
|
2318
|
+
if (password.length >= 12 && kinds >= 3) return "strong";
|
|
2319
|
+
if (password.length >= 10 && kinds >= 2) return "ok";
|
|
2320
|
+
return "weak";
|
|
2321
|
+
}
|
|
2294
2322
|
var token, readKey, isPrivate, bearer, queryKey, newKey, Tunnel;
|
|
2295
2323
|
var init_access = __esm({
|
|
2296
2324
|
"apps/server/src/access.ts"() {
|
|
@@ -2624,7 +2652,7 @@ var init_discord = __esm({
|
|
|
2624
2652
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2625
2653
|
import { z as z3 } from "zod";
|
|
2626
2654
|
function createMcpServer(dn3, agentName = "agent", opts = {}) {
|
|
2627
|
-
const mcp = new McpServer({ name: "driftnet", version: "0.
|
|
2655
|
+
const mcp = new McpServer({ name: "driftnet", version: "0.3.0" });
|
|
2628
2656
|
const READ_TOOLS = /* @__PURE__ */ new Set(["driftnet_search", "driftnet_recent", "driftnet_get", "driftnet_folders"]);
|
|
2629
2657
|
const server2 = {
|
|
2630
2658
|
registerTool: ((name2, ...rest) => {
|
|
@@ -3204,7 +3232,7 @@ function llmsTxt(dn3) {
|
|
|
3204
3232
|
function openApi(serverUrl) {
|
|
3205
3233
|
return {
|
|
3206
3234
|
openapi: "3.1.0",
|
|
3207
|
-
info: { title: "driftnet", version: "0.
|
|
3235
|
+
info: { title: "driftnet", version: "0.3.0", description: "Search and save shared AI tools." },
|
|
3208
3236
|
servers: [{ url: serverUrl }],
|
|
3209
3237
|
components: { securitySchemes: { bearer: { type: "http", scheme: "bearer" } } },
|
|
3210
3238
|
security: [{ bearer: [] }],
|
|
@@ -3376,8 +3404,24 @@ async function readBody(req, limit = 1e6) {
|
|
|
3376
3404
|
}
|
|
3377
3405
|
return Buffer.concat(chunks).toString("utf8");
|
|
3378
3406
|
}
|
|
3407
|
+
function throttled(req) {
|
|
3408
|
+
const m = misses.get(clientIp(req));
|
|
3409
|
+
if (!m) return false;
|
|
3410
|
+
if (Date.now() - m.since > 15 * 6e4) {
|
|
3411
|
+
misses.delete(clientIp(req));
|
|
3412
|
+
return false;
|
|
3413
|
+
}
|
|
3414
|
+
return m.n >= 20;
|
|
3415
|
+
}
|
|
3379
3416
|
function send(res, status, body, type = "application/json; charset=utf-8") {
|
|
3380
|
-
|
|
3417
|
+
const req = res.req;
|
|
3418
|
+
if ((status === 401 || status === 403) && req && triedCredentials(req)) {
|
|
3419
|
+
const ip = clientIp(req);
|
|
3420
|
+
const m = misses.get(ip) ?? { n: 0, since: Date.now() };
|
|
3421
|
+
m.n++;
|
|
3422
|
+
misses.set(ip, m);
|
|
3423
|
+
}
|
|
3424
|
+
res.writeHead(status, { "content-type": type });
|
|
3381
3425
|
res.end(typeof body === "string" ? body : JSON.stringify(body));
|
|
3382
3426
|
}
|
|
3383
3427
|
function openBrowser(url2) {
|
|
@@ -3403,7 +3447,7 @@ async function suggestLocalModel() {
|
|
|
3403
3447
|
} catch {
|
|
3404
3448
|
}
|
|
3405
3449
|
}
|
|
3406
|
-
var env, fromEnvironment, envFile, plugins, dn, settings, PORT, HOST, indexHtml, STATIC, authorized, tunnel, BadRequest, server;
|
|
3450
|
+
var env, fromEnvironment, envFile, plugins, dn, settings, PORT, HOST, indexHtml, STATIC, authorized, tunnel, BadRequest, misses, clientIp, triedCredentials, server;
|
|
3407
3451
|
var init_main = __esm({
|
|
3408
3452
|
async "apps/server/src/main.ts"() {
|
|
3409
3453
|
"use strict";
|
|
@@ -3437,7 +3481,7 @@ var init_main = __esm({
|
|
|
3437
3481
|
"/icon-512.png": [readFileSync5(new URL("../public/icon-512.png", import.meta.url)), "image/png"],
|
|
3438
3482
|
"/manifest.webmanifest": [readFileSync5(new URL("../public/manifest.webmanifest", import.meta.url)), "application/manifest+json"]
|
|
3439
3483
|
};
|
|
3440
|
-
authorized = (req) => isAdmin(req, env);
|
|
3484
|
+
authorized = (req) => !foreignOrigin(req) && (isAdmin(req, env) || isTrustedLocal(req));
|
|
3441
3485
|
tunnel = new Tunnel(PORT);
|
|
3442
3486
|
process.on("exit", () => tunnel.stop());
|
|
3443
3487
|
for (const signal of ["SIGINT", "SIGTERM"]) process.on(signal, () => {
|
|
@@ -3446,6 +3490,9 @@ var init_main = __esm({
|
|
|
3446
3490
|
});
|
|
3447
3491
|
BadRequest = class extends Error {
|
|
3448
3492
|
};
|
|
3493
|
+
misses = /* @__PURE__ */ new Map();
|
|
3494
|
+
clientIp = (req) => req.headers["x-forwarded-for"]?.split(",")[0]?.trim() || req.socket.remoteAddress || "?";
|
|
3495
|
+
triedCredentials = (req) => !!req.headers.authorization || /[?&]key=/.test(req.url ?? "");
|
|
3449
3496
|
server = createServer(async (req, res) => {
|
|
3450
3497
|
const url2 = new URL(req.url ?? "/", `http://${req.headers.host ?? "localhost"}`);
|
|
3451
3498
|
const path = url2.pathname;
|
|
@@ -3456,7 +3503,9 @@ var init_main = __esm({
|
|
|
3456
3503
|
res.writeHead(200, { "content-type": asset[1], "cache-control": "public, max-age=86400" });
|
|
3457
3504
|
return res.end(asset[0]);
|
|
3458
3505
|
}
|
|
3459
|
-
if (
|
|
3506
|
+
if (path.startsWith("/.well-known/")) return send(res, 404, { error: "not found" });
|
|
3507
|
+
if (triedCredentials(req) && throttled(req)) return send(res, 429, { error: "too many wrong passwords; try again in 15 minutes" });
|
|
3508
|
+
if (req.method === "GET" && !canRead(req, env) && !isTrustedLocal(req)) return send(res, 401, { error: "unauthorized" });
|
|
3460
3509
|
if (req.method === "GET" && path === "/llms.txt") return send(res, 200, llmsTxt(dn), "text/plain; charset=utf-8");
|
|
3461
3510
|
if (req.method === "GET" && path === "/openapi.json") return send(res, 200, openApi(env.DRIFTNET_TUNNEL_URL || env.DRIFTNET_PUBLIC_URL || `${url2.protocol}//${url2.host}`));
|
|
3462
3511
|
if (req.method === "GET" && path === "/api/categories") return send(res, 200, dn.categories);
|
|
@@ -3465,7 +3514,16 @@ var init_main = __esm({
|
|
|
3465
3514
|
dn.store.folders().map((f) => [f.id, Object.fromEntries(LOCALES.map((l) => [l, dn.folderLabel(f.id, l)]))])
|
|
3466
3515
|
);
|
|
3467
3516
|
const setup = !envFile && dn.engines.summarizer === "off" && dn.engines.judge === "heuristic" && !dn.store.stats().items;
|
|
3468
|
-
return send(res, 200, {
|
|
3517
|
+
return send(res, 200, {
|
|
3518
|
+
locale: resolveLocale(),
|
|
3519
|
+
categories,
|
|
3520
|
+
setup,
|
|
3521
|
+
role: role(req, env),
|
|
3522
|
+
local: isLocal(req),
|
|
3523
|
+
passwordSet: !!token(env),
|
|
3524
|
+
port: PORT,
|
|
3525
|
+
summaries: dn.engines.summarizer !== "off"
|
|
3526
|
+
});
|
|
3469
3527
|
}
|
|
3470
3528
|
if (req.method === "GET" && path === "/api/folders") {
|
|
3471
3529
|
return send(res, 200, dn.store.folders().map((f) => ({ ...f, label: Object.fromEntries(LOCALES.map((l) => [l, dn.folderLabel(f.id, l)])) })));
|
|
@@ -3560,6 +3618,9 @@ var init_main = __esm({
|
|
|
3560
3618
|
const nextAccess = "DRIFTNET_ACCESS" in values ? values.DRIFTNET_ACCESS : env.DRIFTNET_ACCESS;
|
|
3561
3619
|
if (nextAccess === "private" && !nextToken) throw new SettingsError("private access needs an admin password");
|
|
3562
3620
|
if (values.DRIFTNET_TOKEN === null && tunnel.running) throw new SettingsError("turn the public URL off before removing the password");
|
|
3621
|
+
if (typeof values.DRIFTNET_TOKEN === "string" && values.DRIFTNET_TOKEN.trim() && tunnel.running && strength(values.DRIFTNET_TOKEN.trim()) === "weak") {
|
|
3622
|
+
throw new SettingsError("while the public URL is open, the password must not be weak");
|
|
3623
|
+
}
|
|
3563
3624
|
const changed = settings.update(values);
|
|
3564
3625
|
if (changed.length) dn.reconfigure(env);
|
|
3565
3626
|
return send(res, 200, { ...settings.view(), changed, engines: dn.engines });
|
|
@@ -3589,6 +3650,7 @@ var init_main = __esm({
|
|
|
3589
3650
|
delete env.DRIFTNET_TUNNEL_URL;
|
|
3590
3651
|
} else {
|
|
3591
3652
|
if (!token(env)) throw new SettingsError("set an admin password first");
|
|
3653
|
+
if (strength(token(env)) === "weak") throw new SettingsError("choose a stronger password before opening a public URL");
|
|
3592
3654
|
if (!tunnel.available()) throw new SettingsError("cloudflared is not installed");
|
|
3593
3655
|
const lock = {};
|
|
3594
3656
|
if (!isPrivate(env)) lock.DRIFTNET_ACCESS = "private";
|
|
@@ -3781,7 +3843,7 @@ var init_mcp_stdio = __esm({
|
|
|
3781
3843
|
|
|
3782
3844
|
// apps/server/src/cli.ts
|
|
3783
3845
|
var [cmd = "start"] = process.argv.slice(2);
|
|
3784
|
-
var VERSION = "0.
|
|
3846
|
+
var VERSION = "0.3.0";
|
|
3785
3847
|
if (cmd === "start") await init_main().then(() => main_exports);
|
|
3786
3848
|
else if (cmd === "mcp") await init_mcp_stdio().then(() => mcp_stdio_exports);
|
|
3787
3849
|
else if (cmd === "--version" || cmd === "-v") console.log(VERSION);
|
package/package.json
CHANGED