dsh-edge 0.19.0-alpha.1 → 0.19.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.i18n.yaml +2 -2
- package/README.md +5 -5
- package/README.zh.md +5 -5
- package/package.json +1 -1
- package/scripts/cli.mjs +13 -3
- package/scripts/install.d.mts +7 -2
- package/scripts/install.mjs +5 -2
- package/worker/direct/index.js +750 -747
- package/worker/isolated/index.js +564 -561
package/README.i18n.yaml
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
# last confirmed-consistent state. Both languages carry equal authority.
|
|
3
3
|
# After editing either side, update both and re-record every pair with:
|
|
4
4
|
# pnpm run doc-pairs -- --write
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 868e26fc38e89e8b8da95773ec440cc7603ed25c
|
|
6
|
+
README.zh.md: df33ca4a8cb4f38d4eedcf06c44ff30e6532d6ff
|
package/README.md
CHANGED
|
@@ -278,7 +278,7 @@ The installer asks in this order: account, Worker name, then what to change. Eve
|
|
|
278
278
|
|
|
279
279
|
- **Account.** A signed-in Cloudflare account comes first, so Enter keeps a permanent instance. Without a login the temporary account comes first; it needs no login, runs only the free capabilities, and must be claimed within 60 minutes. You can also sign in or create an account.
|
|
280
280
|
- **Worker name.** The installer checks whether the name already exists in that account. `--name` alone selects the Worker, whatever capabilities deployed it.
|
|
281
|
-
- **An existing name is an update.** The installer reads what the Worker can do from its bindings and offers **Update it** (the default), **Update and change what it can do**, **Use another name**, or **Cancel**. "Update it" is the confirmation: it deploys the new release with the same capabilities and keeps conversations, files, the owner access key, and the DeepSeek key. It never renames the Worker for you or asks for secrets again.
|
|
281
|
+
- **An existing name is an update.** The installer reads what the Worker can do from its bindings and offers **Update it** (the default), **Update and change what it can do**, **Update and reset the access key**, **Use another name**, or **Cancel**. "Update it" is the confirmation: it deploys the new release with the same capabilities and keeps conversations, files, the owner access key, and the DeepSeek key. It never renames the Worker for you or asks for secrets again.
|
|
282
282
|
- **A new name asks what the agent should do.** The choices are cumulative, and the price comes second:
|
|
283
283
|
- `Research and write` (the direct mode, the default): search the web, read pages, draft docs, and connect your tools through MCP. It runs on Workers Free.
|
|
284
284
|
- `+ Analyze data and split big jobs` (the isolated mode): adds `workflow` for parallel subagents, and `run_code` for scripts over your data in sessions started in the PTC mode agent preset (which, like upstream, does not offer `workflow`). It requires Workers Paid (from $5/month).
|
|
@@ -289,17 +289,17 @@ The installer asks in this order: account, Worker name, then what to change. Eve
|
|
|
289
289
|
### Defaults
|
|
290
290
|
|
|
291
291
|
- **Images** are stored in the instance's Durable Object (64 MiB), so a new install needs no R2 setup. Every deployment records its attachment-storage marker, and updates keep the marked or bound backend. A Worker already on private R2 stays there; if R2 is no longer enabled (Cloudflare error `10042`), the installer offers the account's activation link, a retry, or cancellation, never a switch that would strand image references. A pre-image Worker has no references to strand and moves to the Durable Object default. Mixed active rollouts are refused rather than guessed.
|
|
292
|
-
- **The owner access key** is generated for a new instance and shown when installation finishes. To choose your own, set `DSH_EDGE_ACCESS_KEY` (32–512 UTF-8 bytes) in the installer's environment; it stays out of shell history and the process list. An update keeps the existing key.
|
|
292
|
+
- **The owner access key** is generated for a new instance and shown when installation finishes. To choose your own, set `DSH_EDGE_ACCESS_KEY` (32–512 UTF-8 bytes) in the installer's environment; it stays out of shell history and the process list. An ordinary update keeps the existing key. Cloudflare cannot show a stored key again, so if you lose it, run the upgrade command for your deployment's release channel and choose **Update and reset the access key**: `npx dsh-edge upgrade` on a stable release, or `npx dsh-edge@next upgrade` if the installed version contains `-alpha` or `-rc` (the login page shows the one for your deployment). The installer deploys the release with a new key (generated, or `DSH_EDGE_ACCESS_KEY`) and shows it once. Conversations, files, and the DeepSeek key are kept; the old key stops working, and every signed-in browser must sign in again.
|
|
293
293
|
- **The DeepSeek API key** is added after installation in Settings → Models. The installer never asks for it.
|
|
294
294
|
- **Image optimization** (the Cloudflare Images binding) is on for accounts you own and off for temporary accounts.
|
|
295
295
|
|
|
296
296
|
### Credential handoff and activation
|
|
297
297
|
|
|
298
|
-
- A new instance's owner key travels through a mode-`0600` temporary secrets file, which is removed after the command. An update passes no secrets file, so Cloudflare keeps the Worker's existing secrets. Wrangler receives only an allowlisted runtime environment and the selected Cloudflare authentication; unrelated ambient secrets and Node injection options do not reach the child.
|
|
298
|
+
- A new instance's owner key, or the replacement key of an update that resets it, travels through a mode-`0600` temporary secrets file, which is removed after the command. Wrangler applies the file additively, so the Worker's other secrets stay. An ordinary update passes no secrets file, so Cloudflare keeps the Worker's existing secrets. Wrangler receives only an allowlisted runtime environment and the selected Cloudflare authentication; unrelated ambient secrets and Node injection options do not reach the child.
|
|
299
299
|
- Wrangler's structured output supplies the deployed URL. Add `--verbose` to inspect full deployment diagnostics.
|
|
300
|
-
- After upload, the installer observes public `/api/health` for up to 45 seconds without credentials or redirects. Only the exact package version and capabilities count; propagation, challenge, placeholder, transport, and older-release responses remain pending. A new instance then signs in with
|
|
300
|
+
- After upload, the installer observes public `/api/health` for up to 45 seconds without credentials or redirects. Only the exact package version and capabilities count; propagation, challenge, placeholder, transport, and older-release responses remain pending. A new instance, or an update that resets the key, then signs in with the new key and checks `/api/ready`. An ordinary update does not know the kept key, so it reports the verified release as live and asks you to sign in.
|
|
301
301
|
- Observation expiry exits successfully and asks the owner to refresh shortly. It never calls DeepSeek or touches Durable Object state.
|
|
302
|
-
- The final card prints the URL, the new owner key (or "unchanged" after an update), and next steps, then offers to open the URL in your browser (default Yes, interactive terminals only). Temporary accounts also receive a bearer claim URL that must be claimed within 60 minutes.
|
|
302
|
+
- The final card prints the URL, the new owner key (or "unchanged" after an ordinary update), and next steps, then offers to open the URL in your browser (default Yes, interactive terminals only). Temporary accounts also receive a bearer claim URL that must be claimed within 60 minutes.
|
|
303
303
|
- A rejected upload is reported as not installed. If Wrangler created a temporary account, its claim URL is still shown without presenting the unused owner key as active. A paid capability rejected by Cloudflare suggests enabling Workers Paid or choosing `Research and write`.
|
|
304
304
|
- If upload succeeds but handoff fails, a recovery card prints the active owner key and all known URLs before the command exits unsuccessfully.
|
|
305
305
|
- Installation uploads directly through Wrangler; it does not create or bind a GitHub repository, Cloudflare Builds project, or source-build pipeline.
|
package/README.zh.md
CHANGED
|
@@ -278,7 +278,7 @@ npx dsh-edge upgrade
|
|
|
278
278
|
|
|
279
279
|
- **账户。** 已登录的 Cloudflare 账户排在最前,按 Enter 即得到永久实例。未登录时临时账户排在最前:无需登录,只运行免费能力,必须在 60 分钟内认领。也可以登录或注册账户。
|
|
280
280
|
- **Worker 名称。** 安装器检查该名称在账户中是否已存在。只用 `--name` 就能选中 Worker,与部署它时的能力无关。
|
|
281
|
-
- **已存在的名称就是更新。** 安装器从 Worker 的 binding 读出它当前能做什么,提供 **Update it**(默认)、**Update and change what it can do**、**Use another name** 和 **Cancel**。选 "Update it" 即是确认:以相同能力部署新版本,并保留对话、文件、owner access key 与 DeepSeek key。安装器不会替你改名,也不会再次询问 secret。
|
|
281
|
+
- **已存在的名称就是更新。** 安装器从 Worker 的 binding 读出它当前能做什么,提供 **Update it**(默认)、**Update and change what it can do**、**Update and reset the access key**、**Use another name** 和 **Cancel**。选 "Update it" 即是确认:以相同能力部署新版本,并保留对话、文件、owner access key 与 DeepSeek key。安装器不会替你改名,也不会再次询问 secret。
|
|
282
282
|
- **新名称会询问 agent 要做什么。** 选项逐级包含,价格放在第二位:
|
|
283
283
|
- `Research and write`(direct 模式,默认):联网搜索、读网页、写文档,并通过 MCP 连接你的工具。可在 Workers Free 上运行。
|
|
284
284
|
- `+ Analyze data and split big jobs`(isolated 模式):增加 `workflow`,把任务交给并行子 agent;在以 PTC 模式 agent 预设开始的会话中增加 `run_code`,用脚本处理你的数据(与上游一样,该预设不提供 `workflow`)。需要 Workers Paid(每月 5 美元起)。
|
|
@@ -289,17 +289,17 @@ npx dsh-edge upgrade
|
|
|
289
289
|
### 默认值
|
|
290
290
|
|
|
291
291
|
- **图片** 存入实例的 Durable Object(64 MiB),因此新安装无需配置 R2。每个部署都会记录 attachment-storage marker,更新时保留 marker 或 binding 指定的 backend。已使用私有 R2 的 Worker 会继续使用 R2;如果 R2 不再启用(Cloudflare 错误 `10042`),安装器提供账户专属的启用链接、重试或取消,绝不切换到会让图片引用失联的 backend。图片功能之前的 Worker 没有可失联的引用,会改用 Durable Object 默认值。Active rollout 混用 backend 时会拒绝猜测。
|
|
292
|
-
- **Owner access key** 在新实例上自动生成,并在安装完成时显示。如需自定义,请在安装器环境中设置 `DSH_EDGE_ACCESS_KEY`(32–512 个 UTF-8 字节);它不会进入 shell
|
|
292
|
+
- **Owner access key** 在新实例上自动生成,并在安装完成时显示。如需自定义,请在安装器环境中设置 `DSH_EDGE_ACCESS_KEY`(32–512 个 UTF-8 字节);它不会进入 shell 历史或进程列表。普通更新会保留现有 key。Cloudflare 无法再次显示已存的 key,所以丢失时请按部署所在的发布渠道运行升级命令,并选择 **Update and reset the access key**:稳定版运行 `npx dsh-edge upgrade`;已安装版本包含 `-alpha` 或 `-rc` 时运行 `npx dsh-edge@next upgrade`(登录页会显示适用于该部署的命令)。安装器会用新 key(自动生成,或取自 `DSH_EDGE_ACCESS_KEY`)部署该版本,并只显示一次。对话、文件与 DeepSeek key 均保留;旧 key 随即失效,所有已登录的浏览器都需要用新 key 重新登录。
|
|
293
293
|
- **DeepSeek API key** 在安装完成后于 Settings → Models 中添加。安装器不会询问它。
|
|
294
294
|
- **图片优化**(Cloudflare Images binding)对你自己的账户开启,对临时账户关闭。
|
|
295
295
|
|
|
296
296
|
### Credential 交接与激活
|
|
297
297
|
|
|
298
|
-
- 新实例的 owner key
|
|
298
|
+
- 新实例的 owner key,或重置 key 的更新所生成的新 key,通过权限模式为 `0600` 的临时 secret 文件传递,命令结束后删除该文件。Wrangler 以增量方式应用该文件,Worker 的其他 secret 保持不变。普通更新不传 secret 文件,Cloudflare 会保留 Worker 现有的 secret。Wrangler 只收到 allowlist 内的 runtime 环境与当前选中的 Cloudflare authentication;其他 ambient secret 与 Node 注入选项不会进入子进程。
|
|
299
299
|
- 部署 URL 来自 Wrangler 的结构化输出。添加 `--verbose` 可查看完整部署诊断。
|
|
300
|
-
- 上传后,安装器会在不携带 credential、不跟随重定向的前提下,最多观察公开 `/api/health` 45 秒。只有精确 package 版本与能力才算数;propagation、challenge、占位页、传输错误与旧 release response 均保持 pending
|
|
300
|
+
- 上传后,安装器会在不携带 credential、不跟随重定向的前提下,最多观察公开 `/api/health` 45 秒。只有精确 package 版本与能力才算数;propagation、challenge、占位页、传输错误与旧 release response 均保持 pending。随后新实例或重置 key 的更新会用新 key 登录并检查 `/api/ready`。普通更新不知道被保留的 key,因此会把已验证的版本报告为 live,并请你登录确认。
|
|
301
301
|
- 观察到期仍以成功退出,并请 owner 稍后刷新。该观察不调用 DeepSeek,也不触碰 Durable Object 状态。
|
|
302
|
-
- 最终卡片输出 URL、新的 owner key
|
|
302
|
+
- 最终卡片输出 URL、新的 owner key(普通更新后显示 "unchanged")与下一步,然后询问是否在浏览器中打开该 URL(默认 Yes,仅限交互式终端)。临时账户还会收到必须在 60 分钟内认领的 bearer claim URL。
|
|
303
303
|
- 上传被拒绝时会明确报告未安装。Wrangler 如果已创建临时账户,仍显示其 claim URL,但不把未使用的 owner key 显示为 active。付费能力被 Cloudflare 拒绝时,会建议启用 Workers Paid 或改选 `Research and write`。
|
|
304
304
|
- 上传成功但交接失败时,恢复卡片会在命令按失败退出前输出已生效 owner key 与所有已知 URL。
|
|
305
305
|
- 安装直接通过 Wrangler 上传;不会创建或绑定 GitHub 仓库、Cloudflare Builds 项目或源码构建流水线。
|
package/package.json
CHANGED
package/scripts/cli.mjs
CHANGED
|
@@ -28,6 +28,7 @@ const DSH_EDGE_HERO = String.raw` ____ ____ _ _ _____ ____ ____ ____
|
|
|
28
28
|
| |_| |___) | _ |_____| |___| |_| | |_| | |___
|
|
29
29
|
|____/|____/|_| |_| |_____|____/ \____|_____|`
|
|
30
30
|
const KEPT_ON_UPDATE = 'conversations, files, access key, and DeepSeek key'
|
|
31
|
+
const KEPT_ON_KEY_RESET = 'conversations, files, and DeepSeek key'
|
|
31
32
|
const CONTAINER_ROLLOUT_NOTE = 'The first command after this can take a few minutes while the container image rolls out.'
|
|
32
33
|
const SESSION_FORMAT_UPGRADE_NOTE = 'Stored sessions move to a new format when this release first starts; only the stored rows that change are rewritten. Rolling back to an earlier dsh-edge release afterwards is not supported.'
|
|
33
34
|
|
|
@@ -146,6 +147,7 @@ export function createInstallerUi(
|
|
|
146
147
|
options: [
|
|
147
148
|
{ value: 'update', label: 'Update it', hint: 'keeps everything' },
|
|
148
149
|
{ value: 'change', label: 'Update and change what it can do' },
|
|
150
|
+
{ value: 'reset-key', label: 'Update and reset the access key', hint: 'if you lost it' },
|
|
149
151
|
{ value: 'rename', label: 'Use another name' },
|
|
150
152
|
{ value: 'cancel', label: 'Cancel' },
|
|
151
153
|
],
|
|
@@ -210,13 +212,21 @@ export function createInstallerUi(
|
|
|
210
212
|
['Images', summary.attachmentStorage === 'temporary-do'
|
|
211
213
|
? 'stored in this instance (64 MiB limit)'
|
|
212
214
|
: 'stored privately in Cloudflare R2'],
|
|
213
|
-
...(summary.
|
|
215
|
+
...(summary.resetAccessKey
|
|
216
|
+
? [
|
|
217
|
+
['Kept', KEPT_ON_KEY_RESET],
|
|
218
|
+
['Owner key', 'replaced; the new key is shown when the update finishes'],
|
|
219
|
+
]
|
|
220
|
+
: summary.updating
|
|
214
221
|
? [['Kept', KEPT_ON_UPDATE]]
|
|
215
222
|
: [
|
|
216
223
|
['Owner key', 'generated and shown when installation finishes'],
|
|
217
224
|
['DeepSeek', 'add your API key when the web app asks, or later in Settings → Models'],
|
|
218
225
|
]),
|
|
219
226
|
]),
|
|
227
|
+
...(summary.resetAccessKey
|
|
228
|
+
? ['', 'The old key stops working, and every signed-in browser must sign in again with the new key.']
|
|
229
|
+
: []),
|
|
220
230
|
...(summary.mode === 'container'
|
|
221
231
|
? ['', 'The container sleeps after 10 idle minutes by default; change it in Settings → DSH Edge.', CONTAINER_ROLLOUT_NOTE]
|
|
222
232
|
: []),
|
|
@@ -298,7 +308,7 @@ export function createInstallerUi(
|
|
|
298
308
|
: ['Claim this temporary account within 60 minutes to keep the Worker and its data.']),
|
|
299
309
|
'Open the URL above.',
|
|
300
310
|
newKey
|
|
301
|
-
?
|
|
311
|
+
? `Enter the ${result.updated ? 'new ' : ''}owner access key when prompted.`
|
|
302
312
|
: 'Sign in with your existing owner access key.',
|
|
303
313
|
...(result.updated ? [] : ['Add your DeepSeek API key when the web app asks (or later in Settings → Models).']),
|
|
304
314
|
...(newKey ? ['Save the owner access key; you need it to sign in.'] : []),
|
|
@@ -615,7 +625,7 @@ async function main() {
|
|
|
615
625
|
const args = process.argv.slice(2)
|
|
616
626
|
const command = parseCommand(args)
|
|
617
627
|
if (command === 'help') {
|
|
618
|
-
process.stdout.write('Usage: dsh-edge <install|upgrade> [--verbose]\n\nCommands:\n install Create an instance, or update one that already exists\n upgrade Update an existing instance, keeping its data and keys\n\nOptions:\n --verbose Show Wrangler deployment output\n\nEnvironment:\n DSH_EDGE_ACCESS_KEY Owner access key for a new instance (default: generated)\n')
|
|
628
|
+
process.stdout.write('Usage: dsh-edge <install|upgrade> [--verbose]\n\nCommands:\n install Create an instance, or update one that already exists\n upgrade Update an existing instance, keeping its data and keys\n (choose \"Update and reset the access key\" if you lost it)\n\nOptions:\n --verbose Show Wrangler deployment output\n\nEnvironment:\n DSH_EDGE_ACCESS_KEY Owner access key for a new instance or an access-key reset\n (default: generated)\n')
|
|
619
629
|
return
|
|
620
630
|
}
|
|
621
631
|
if (command === 'version') {
|
package/scripts/install.d.mts
CHANGED
|
@@ -23,13 +23,16 @@ export interface InstallerUi {
|
|
|
23
23
|
step(message: string): void
|
|
24
24
|
selectAccount(choices: Array<{ value: string; label: string; hint?: string }>): Promise<string>
|
|
25
25
|
workerName(initialValue: string, validate: (value: string) => string | undefined): Promise<string>
|
|
26
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* The Worker name already exists; `update` keeps everything and is the
|
|
28
|
+
* confirmation. `reset-key` updates and replaces the owner access key.
|
|
29
|
+
*/
|
|
27
30
|
existingWorker(existing: {
|
|
28
31
|
workerName: string
|
|
29
32
|
mode: RuntimeMode
|
|
30
33
|
/** The running release predates the 0.19 session format; updating migrates stored sessions. */
|
|
31
34
|
sessionFormatUpgrade: boolean
|
|
32
|
-
}): Promise<'update' | 'change' | 'rename' | 'cancel'>
|
|
35
|
+
}): Promise<'update' | 'change' | 'reset-key' | 'rename' | 'cancel'>
|
|
33
36
|
/** The Worker name belongs to something other than dsh-edge; it is never updated. */
|
|
34
37
|
nameTaken(workerName: string): Promise<'rename' | 'cancel'>
|
|
35
38
|
/** Choose what the agent can do; `current` marks an existing instance's capabilities. */
|
|
@@ -43,6 +46,8 @@ export interface InstallerUi {
|
|
|
43
46
|
workerName: string
|
|
44
47
|
temporary: boolean
|
|
45
48
|
updating: boolean
|
|
49
|
+
/** An update that replaces the owner access key with a new one. */
|
|
50
|
+
resetAccessKey: boolean
|
|
46
51
|
attachmentStorage: AttachmentStorage
|
|
47
52
|
}): Promise<boolean>
|
|
48
53
|
deploymentStart?(message: string): void
|
package/scripts/install.mjs
CHANGED
|
@@ -669,8 +669,10 @@ export async function installEdge({
|
|
|
669
669
|
requireRuntimeMode(mode)
|
|
670
670
|
const attachmentStorage = existing?.attachmentStorage ?? 'temporary-do'
|
|
671
671
|
requireAttachmentStorage(attachmentStorage)
|
|
672
|
-
// An update keeps the Worker's secrets
|
|
673
|
-
|
|
672
|
+
// An update keeps the Worker's secrets unless the owner resets the access
|
|
673
|
+
// key; `--secrets-file` is additive, so the other secrets stay in place.
|
|
674
|
+
const resetAccessKey = updating && updateAction === 'reset-key'
|
|
675
|
+
const ownerSecret = updating && !resetAccessKey ? undefined : resolveOwnerSecret(environment)
|
|
674
676
|
// Choosing "Update it" was the confirmation; everything else confirms once here.
|
|
675
677
|
if (updateAction !== 'update' && !await ui.confirm({
|
|
676
678
|
mode,
|
|
@@ -678,6 +680,7 @@ export async function installEdge({
|
|
|
678
680
|
workerName,
|
|
679
681
|
temporary,
|
|
680
682
|
updating,
|
|
683
|
+
resetAccessKey,
|
|
681
684
|
attachmentStorage,
|
|
682
685
|
})) {
|
|
683
686
|
throw new InstallCancelledError()
|