dsh-edge 0.24.0 → 0.26.0-alpha.1
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 -3
- package/README.zh.md +5 -3
- package/THIRD_PARTY_NOTICES.md +1 -230
- package/package.json +3 -1
- package/scripts/bundle-size.d.mts +3 -2
- package/scripts/bundle-size.mjs +21 -11
- package/scripts/check-startup.d.mts +2 -0
- package/scripts/check-startup.mjs +74 -0
- package/worker/direct/index.js +1930 -1401
- package/worker/isolated/index.js +1574 -1045
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: 9a90840708b0550751ddd08934ef278e98b85067
|
|
6
|
+
README.zh.md: d5903302c32ad467b52b23f05bb75bbb14c3e438
|
package/README.md
CHANGED
|
@@ -140,7 +140,7 @@ This reference separates code that runs natively in Workers, code adapted at an
|
|
|
140
140
|
| --- | --- | --- | --- |
|
|
141
141
|
| DeepSeek transport | Fetch, SSE parsing, wire translation, retry metadata | Reused | Construct the upstream `DeepSeekAdapter` per request. `nodejs_compat` supplies its compatible Node APIs. |
|
|
142
142
|
| Provider attribution | Package version loaded with Node `createRequire` | Reused after portability fix | Import package metadata statically so bundlers preserve the same version source without requiring `import.meta.url` at runtime. |
|
|
143
|
-
| LLM protocol | DSH messages, content blocks, stream chunks, tool calls, usage, and finish reasons | Reused | Let upstream `LlmRuntime` and `ReactLoopAgent` assemble, stream, and log the model exchange. |
|
|
143
|
+
| LLM protocol | DSH messages, content blocks, stream chunks, tool calls, usage, and finish reasons | Reused | Let upstream `LlmRuntime` and `ReactLoopAgent` assemble, stream, and log the model exchange. DeepSeek is served by `dsh-llm-deepseek-api-key` (`llm-deepseek`). Other providers are added on the Settings → Models page as upstream does it, through `dsh-llm-pi-ai` (`llm-pi-ai`): OpenAI chat completions, OpenAI responses, or Anthropic messages, any HTTP(S) Base URL without credentials, a query, or a fragment (OpenRouter, Cloudflare Workers AI or AI Gateway, a self-hosted gateway), and model discovery from the endpoint. A saved route serves turns without a restart and can be picked in the model menu, as a new-session default, and for subagents. Providers that sign in through a local login or read local credential files (GitHub Copilot, OpenAI Codex, and Amazon Bedrock or Google Vertex through local credentials) are not offered. |
|
|
144
144
|
| Agent loop | Cordis-composed `ReactLoopAgent` with hooks, guards, sessions, and tools | Reused | Create and cold-resume agents through `AgentRegistry`. Context compaction, token metering, tool-result pruning, automatic session title generation, the repeated-tool-call reminder (after 3, 5, and 8 identical consecutive calls), model-request retry (a rate limit, server error, timeout, transport error, or empty response is retried up to five times within the turn, with 0.5–10 s backoff or the provider's `Retry-After`), and durability checkpoints (the session log is stored before each model request, each top-level tool call, and each step) run as upstream cordis plugins. The upstream `/compact` command (`dsh-command-compact`) compacts the session's history on request. |
|
|
145
145
|
| Bash tool | Node subprocess, sandbox, terminal, and job services | Adapted at the native tool seam | Register an upstream `ToolDefinition`, but execute its body through the configured Computer workspace backend and just-bash. The default direct backend runs inside the owner Durable Object with hardened interpreter limits and no network command; adding a `LOADER` binding selects Computer's isolated Worker Shell backend. Native tool cancellation sends `SIGINT` through the Computer execution handle. Deployment configuration supplies an explicit default timeout and caller-selectable ceiling, while `timedOut` reports the deadline independently from exit and cancellation status. Native binaries, background processes, PTYs, and arbitrary Linux behavior are unavailable. |
|
|
146
146
|
| Workspace filesystem | Local filesystem services and host paths | Adapted | Store `/workspace` in the owner's SQLite-backed Durable Object VFS. |
|
|
@@ -210,6 +210,8 @@ A focused failure test proves that post-enqueue durability failure blocks model
|
|
|
210
210
|
|
|
211
211
|
`DEEPSEEK_API_KEY` may be set as a Worker secret at deployment or entered later through the Settings → Models page. The Edge credential provider checks Durable Object KV first, then falls back to the Worker environment variable; resolved values remain request-scoped and are never written to session events or responses. Surrounding whitespace is removed; a blank value is unconfigured.
|
|
212
212
|
|
|
213
|
+
An API key for another provider is entered on the same Models page, which stores it under the credential name the provider's route names (for example `OPENROUTER_API_KEY`) in Durable Object KV. These keys are not read from Worker variables: only `DEEPSEEK_API_KEY` keeps that fallback, for deployments from before the Models page. A route's extra headers are stored in the settings document in plain text, so only headers that never carry a secret are accepted: `HTTP-Referer`, `Referer`, `X-Title`, `OpenAI-Organization`, `OpenAI-Project`, and `anthropic-beta`. A gateway that needs a second credential header, such as an authenticated Cloudflare AI Gateway's `cf-aig-authorization`, cannot be configured yet. A route's key name may not be one that belongs to DeepSeek or another Edge feature (`DEEPSEEK_*`, `MCP_TOKEN_*`, `DSH_EDGE_*`), so the deployment's DeepSeek key is never sent to another endpoint. Every route needs its own key name: without one pi-ai would look for a key in the process environment, where Workers expose the deployment's secrets.
|
|
214
|
+
|
|
213
215
|
| Variable | Purpose and validation |
|
|
214
216
|
| --- | --- |
|
|
215
217
|
| `DEEPSEEK_BASE_URL` | Anthropic-compatible Messages endpoint. Defaults to `https://api.deepseek.com/anthropic`. DeepSeek's former OpenAI-compatible root (`https://api.deepseek.com`, `/v1`, or `/beta`), here or saved as the Models page Base URL, is moved to that default on start; a 404 from another endpoint keeps its message and adds that the endpoint may not serve the Messages API and where to change it. Must be HTTP(S) without URL userinfo. The browser projection omits query and fragment components that may carry gateway credentials. |
|
|
@@ -252,7 +254,7 @@ Direct mode is lighter isolation than a separate Worker; do not expose the singl
|
|
|
252
254
|
- Isolated preserves that shell core and replaces the unreachable Direct backend with a fail-closed module. Each artifact therefore carries only its selected command runtime.
|
|
253
255
|
- The installer generates a private mode-specific config, points it at the selected artifact, and uploads with `no_bundle`. The user's machine does not rebuild dsh-edge or resolve Harness packages into a new Worker.
|
|
254
256
|
- Container mode deploys the isolated artifact with `docker.io/pawaca/dsh-edge-computer:<version>`, which the release workflow builds from `container/Dockerfile` and pushes once per version before npm publication. Installing it needs no local Docker; `pnpm dev:container` and `pnpm test:container` build the Dockerfile locally and do.
|
|
255
|
-
- CI starts the Direct artifact from an installed tarball
|
|
257
|
+
- CI starts the Direct artifact from an installed tarball. Bundling rejects a Worker above Cloudflare's 64 MiB uncompressed limit (Cloudflare has no compressed-size limit, temporary accounts included), and CI profiles each artifact's startup against Cloudflare's 1 s startup limit.
|
|
256
258
|
|
|
257
259
|
### Install and upgrade
|
|
258
260
|
|
|
@@ -304,7 +306,7 @@ The installer asks in this order: account, Worker name, then what to change. Eve
|
|
|
304
306
|
- If upload succeeds but handoff fails, a recovery card prints the active owner key and all known URLs before the command exits unsuccessfully.
|
|
305
307
|
- Installation uploads directly through Wrangler; it does not create or bind a GitHub repository, Cloudflare Builds project, or source-build pipeline.
|
|
306
308
|
|
|
307
|
-
Contributors working from a checkout can reproduce the two release artifacts locally with `pnpm --filter dsh-edge bundle:direct` and `pnpm --filter dsh-edge bundle:isolated`.
|
|
309
|
+
Contributors working from a checkout can reproduce the two release artifacts locally with `pnpm --filter dsh-edge bundle:direct` and `pnpm --filter dsh-edge bundle:isolated`. Both commands enforce Cloudflare's 64 MiB uncompressed Worker size limit (Cloudflare has no compressed-size limit), and `pnpm --filter dsh-edge check:startup` profiles the promoted artifacts' startup against Cloudflare's 1 s startup limit.
|
|
308
310
|
|
|
309
311
|
Contributors can replay the complete Free temporary-account journey without a key or network call. This example runs the shipped bin, real prompts, Wrangler subprocess, structured deployment-output parsing, public-activation observation, and final handoff while replacing the external Cloudflare boundaries:
|
|
310
312
|
|
package/README.zh.md
CHANGED
|
@@ -140,7 +140,7 @@ curl -b /tmp/dsh-edge-cookie -N -X POST -H 'content-type: application/json' \
|
|
|
140
140
|
| --- | --- | --- | --- |
|
|
141
141
|
| DeepSeek transport | Fetch、SSE 解析、wire translation 和 retry metadata | 复用 | 每个请求构造一个上游 `DeepSeekAdapter`;其兼容的 Node API 由 `nodejs_compat` 提供。 |
|
|
142
142
|
| Provider attribution | 用 Node `createRequire` 加载 package version | 完成可移植修复后复用 | 静态导入 package metadata,让 bundler 保留同一个版本来源,运行时不再依赖 `import.meta.url`。 |
|
|
143
|
-
| LLM protocol | DSH messages、content blocks、stream chunks、tool calls、usage 和 finish reasons | 复用 | 由上游 `LlmRuntime` 和 `ReactLoopAgent` 组装、流式处理并记录 model exchange。 |
|
|
143
|
+
| LLM protocol | DSH messages、content blocks、stream chunks、tool calls、usage 和 finish reasons | 复用 | 由上游 `LlmRuntime` 和 `ReactLoopAgent` 组装、流式处理并记录 model exchange。 DeepSeek 由 `dsh-llm-deepseek-api-key`(`llm-deepseek`)提供。其他服务商与上游一样在"设置 → Models"页面添加,通过 `dsh-llm-pi-ai`(`llm-pi-ai`)接入:支持 OpenAI chat completions、OpenAI responses 和 Anthropic messages 协议,Base URL 可以是任意不带账号密码、查询参数或片段的 HTTP(S) 地址(OpenRouter、Cloudflare Workers AI 或 AI Gateway、自建网关),并可从端点发现模型。保存的路由无需重启即可用于对话,可以在模型菜单中选择,可以作为新会话的默认模型,也可以给子 agent 使用。依赖本地登录或读取本地凭据文件的服务商(GitHub Copilot、OpenAI Codex,以及通过本地凭据使用的 Amazon Bedrock 或 Google Vertex)不提供。 |
|
|
144
144
|
| Agent loop | 由 Cordis 组合、带 hooks、guards、sessions 和 tools 的 `ReactLoopAgent` | 复用 | 通过 `AgentRegistry` 创建和冷恢复 agent。上下文压缩、token 计量、工具结果修剪、自动 session 标题生成、重复工具调用提醒(连续 3、5、8 次完全相同的调用时提醒)、模型请求重试(遇到限流、服务端错误、超时、网络错误或空响应时,在同一轮内最多重试 5 次,等待 0.5–10 秒,或按服务端的 `Retry-After`),以及持久化检查点(每次模型请求、每次顶层工具调用和每一步之前先保存 session 日志),作为上游 cordis 插件运行。上游的 `/compact` 命令(`dsh-command-compact`)按需压缩会话历史。 |
|
|
145
145
|
| Bash tool | Node subprocess、sandbox、terminal 和 job services | 在原生 tool seam 上适配 | 注册上游 `ToolDefinition`,但通过配置的 Computer workspace backend 和 just-bash 执行其 body。默认 direct backend 在 owner Durable Object 内运行,启用 hardened interpreter limits 且不提供网络命令;添加 `LOADER` binding 后会选择 Computer 的 isolated Worker Shell backend。原生 tool cancellation 会通过 Computer execution handle 发送 `SIGINT`。部署配置提供明确的默认 timeout 与调用方可选值上限,`timedOut` 则独立于 exit 与 cancellation status 报告 deadline。不支持原生二进制、后台进程、PTY 和任意 Linux 行为。 |
|
|
146
146
|
| Workspace filesystem | 本地 filesystem services 和 host paths | 适配 | 在 owner 基于 SQLite 的 Durable Object VFS 中保存 `/workspace`。 |
|
|
@@ -210,6 +210,8 @@ Cloudflare static assets -> upstream Web shell + client plugin graph
|
|
|
210
210
|
|
|
211
211
|
`DEEPSEEK_API_KEY` 可以在部署时作为 Worker secret 设置,也可以之后通过 Settings → Models 页面输入。Edge credential provider 先查 Durable Object KV,再降级到 Worker 环境变量;解析值保持请求级作用域,绝不写入 session event 或 response。首尾空白会被移除;空白值视为未配置。
|
|
212
212
|
|
|
213
|
+
其他服务商的 API key 也在同一个 Models 页面填写,按该服务商路由所指定的凭据名(例如 `OPENROUTER_API_KEY`)存入 Durable Object KV。这些 key 不从 Worker 变量读取:只有 `DEEPSEEK_API_KEY` 为了兼容 Models 页面出现之前的部署而保留这一兜底。路由的附加请求头以明文存在设置文档里,所以只接受不会携带密钥的请求头:`HTTP-Referer`、`Referer`、`X-Title`、`OpenAI-Organization`、`OpenAI-Project` 和 `anthropic-beta`。需要第二个认证头的网关(例如开启认证的 Cloudflare AI Gateway 所需的 `cf-aig-authorization`)暂时无法配置。路由的 key 名不能使用属于 DeepSeek 或其他 Edge 功能的名字(`DEEPSEEK_*`、`MCP_TOKEN_*`、`DSH_EDGE_*`),因此部署的 DeepSeek 密钥不会被发到其他地址。每个路由都必须有自己的 key 名:没有的话,pi-ai 会到进程环境里找 key,而 Workers 会把部署的 secret 暴露在那里。
|
|
214
|
+
|
|
213
215
|
| 变量 | 用途与校验 |
|
|
214
216
|
| --- | --- |
|
|
215
217
|
| `DEEPSEEK_BASE_URL` | Anthropic-compatible Messages endpoint。默认为 `https://api.deepseek.com/anthropic`。DeepSeek 以前的 OpenAI-compatible 根地址(`https://api.deepseek.com`、`/v1` 或 `/beta`),无论设在这里还是保存为 Models 页的 Base URL,启动时都会改成该默认值;其他地址返回 404 时,保留原报错并补充提示:该地址可能不支持 Messages API,以及在哪里修改。必须是不含 URL userinfo 的 HTTP(S) URL。Browser 投影会省略可能携带 gateway credential 的 query 与 fragment。 |
|
|
@@ -252,7 +254,7 @@ Direct 模式比独立 Worker 的隔离更轻;不要把 single-owner 部署暴
|
|
|
252
254
|
- Isolated 保留该 shell core,并把不可达的 Direct backend 替换成 fail-closed module。因此每个 artifact 只携带所选 command runtime。
|
|
253
255
|
- 安装器生成私有 mode-specific config,指向所选 artifact,并通过 `no_bundle` 上传。用户机器不会重新构建 dsh-edge,也不会把 Harness package 解析进新 Worker。
|
|
254
256
|
- Container 模式部署 isolated 产物,并使用 `docker.io/pawaca/dsh-edge-computer:<version>` 镜像。该镜像由发版流程从 `container/Dockerfile` 构建,每个版本在 npm 发布前推送一次。安装时不需要本地 Docker;`pnpm dev:container` 和 `pnpm test:container` 会在本地构建 Dockerfile,因此需要。
|
|
255
|
-
- CI 从已安装 tarball 启动 Direct artifact
|
|
257
|
+
- CI 从已安装 tarball 启动 Direct artifact。打包时会拒绝超过 Cloudflare 未压缩 64 MiB 上限的 Worker(Cloudflare 不限制压缩后体积,临时账户也一样),CI 还会对照 Cloudflare 1 秒的启动上限检查每个产物的启动耗时。
|
|
256
258
|
|
|
257
259
|
### 安装与升级
|
|
258
260
|
|
|
@@ -304,7 +306,7 @@ npx dsh-edge upgrade
|
|
|
304
306
|
- 上传成功但交接失败时,恢复卡片会在命令按失败退出前输出已生效 owner key 与所有已知 URL。
|
|
305
307
|
- 安装直接通过 Wrangler 上传;不会创建或绑定 GitHub 仓库、Cloudflare Builds 项目或源码构建流水线。
|
|
306
308
|
|
|
307
|
-
从 checkout 开发的贡献者可以用 `pnpm --filter dsh-edge bundle:direct` 和 `pnpm --filter dsh-edge bundle:isolated` 在本地复现两种 release artifact
|
|
309
|
+
从 checkout 开发的贡献者可以用 `pnpm --filter dsh-edge bundle:direct` 和 `pnpm --filter dsh-edge bundle:isolated` 在本地复现两种 release artifact。两条命令都会检查 Cloudflare 未压缩 64 MiB 的 Worker 体积上限(Cloudflare 不限制压缩后体积),`pnpm --filter dsh-edge check:startup` 会对照 Cloudflare 1 秒的启动上限分析已提升产物的启动耗时。
|
|
308
310
|
|
|
309
311
|
贡献者可以在没有 key 且不发起网络请求的情况下重放完整的 Free 临时账户流程。这个 example 会运行实际交付的 bin、真实 prompt、Wrangler 子进程、结构化部署输出解析、公开激活观察与最终交接,并替换外部 Cloudflare 边界:
|
|
310
312
|
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -37,13 +37,12 @@ SOFTWARE.
|
|
|
37
37
|
|
|
38
38
|
`dsh-edge` also applies a version-bound fix to `@cloudflare/computer@0.3.1`, recorded with its reason in `standalone/patches/audit.json`; the component's license below is unchanged.
|
|
39
39
|
|
|
40
|
-
The following
|
|
40
|
+
The following 665 package versions form the conservative, platform-neutral production closure used to assemble the Web and Worker artifacts in this distribution. Platform-specific build binaries that are not distributed in those artifacts are excluded; tree shaking can omit additional code. The inventory and legal texts are generated during packaging rather than referring recipients to a source checkout. License expressions are SPDX identifiers supplied by each package. Dependencies installed separately by npm remain declared in this package's `package.json`.
|
|
41
41
|
|
|
42
42
|
| Component | License |
|
|
43
43
|
| --- | --- |
|
|
44
44
|
| `@anthropic-ai/sdk@0.124.0` | `MIT` |
|
|
45
45
|
| `@aws-sdk/client-bedrock-runtime@3.1127.0` | `Apache-2.0` |
|
|
46
|
-
| `@aws-sdk/core@3.977.9` | `Apache-2.0` |
|
|
47
46
|
| `@aws-sdk/core@3.978.1` | `Apache-2.0` |
|
|
48
47
|
| `@aws-sdk/credential-provider-env@3.972.72` | `Apache-2.0` |
|
|
49
48
|
| `@aws-sdk/credential-provider-http@3.972.74` | `Apache-2.0` |
|
|
@@ -56,15 +55,11 @@ The following 674 package versions form the conservative, platform-neutral produ
|
|
|
56
55
|
| `@aws-sdk/eventstream-handler-node@3.972.34` | `Apache-2.0` |
|
|
57
56
|
| `@aws-sdk/middleware-eventstream@3.972.29` | `Apache-2.0` |
|
|
58
57
|
| `@aws-sdk/middleware-websocket@3.972.52` | `Apache-2.0` |
|
|
59
|
-
| `@aws-sdk/nested-clients@3.997.44` | `Apache-2.0` |
|
|
60
58
|
| `@aws-sdk/nested-clients@3.997.46` | `Apache-2.0` |
|
|
61
|
-
| `@aws-sdk/signature-v4-multi-region@3.996.46` | `Apache-2.0` |
|
|
62
59
|
| `@aws-sdk/signature-v4-multi-region@3.996.47` | `Apache-2.0` |
|
|
63
60
|
| `@aws-sdk/token-providers@3.1127.0` | `Apache-2.0` |
|
|
64
61
|
| `@aws-sdk/token-providers@3.1138.0` | `Apache-2.0` |
|
|
65
|
-
| `@aws-sdk/types@3.974.5` | `Apache-2.0` |
|
|
66
62
|
| `@aws-sdk/types@3.974.6` | `Apache-2.0` |
|
|
67
|
-
| `@aws-sdk/xml-builder@3.972.40` | `Apache-2.0` |
|
|
68
63
|
| `@aws-sdk/xml-builder@3.972.41` | `Apache-2.0` |
|
|
69
64
|
| `@aws/lambda-invoke-store@0.3.0` | `Apache-2.0` |
|
|
70
65
|
| `@babel/code-frame@7.29.7` | `MIT` |
|
|
@@ -380,15 +375,11 @@ The following 674 package versions form the conservative, platform-neutral produ
|
|
|
380
375
|
| `@sec-ant/readable-stream@0.4.1` | `MIT` |
|
|
381
376
|
| `@sindresorhus/is@7.2.0` | `MIT` |
|
|
382
377
|
| `@sindresorhus/merge-streams@4.0.0` | `MIT` |
|
|
383
|
-
| `@smithy/core@3.33.3` | `Apache-2.0` |
|
|
384
378
|
| `@smithy/core@3.35.1` | `Apache-2.0` |
|
|
385
379
|
| `@smithy/credential-provider-imds@4.5.2` | `Apache-2.0` |
|
|
386
|
-
| `@smithy/fetch-http-handler@5.7.2` | `Apache-2.0` |
|
|
387
380
|
| `@smithy/fetch-http-handler@5.8.0` | `Apache-2.0` |
|
|
388
|
-
| `@smithy/node-http-handler@4.11.3` | `Apache-2.0` |
|
|
389
381
|
| `@smithy/node-http-handler@4.12.1` | `Apache-2.0` |
|
|
390
382
|
| `@smithy/signature-v4@5.7.3` | `Apache-2.0` |
|
|
391
|
-
| `@smithy/types@4.17.2` | `Apache-2.0` |
|
|
392
383
|
| `@smithy/types@4.19.0` | `Apache-2.0` |
|
|
393
384
|
| `@speed-highlight/core@1.2.24` | `CC0-1.0` |
|
|
394
385
|
| `@stablelib/base64@1.0.1` | `MIT` |
|
|
@@ -2018,11 +2009,8 @@ Applies to:
|
|
|
2018
2009
|
- `@aws-sdk/credential-provider-web-identity@3.972.78` (`LICENSE`)
|
|
2019
2010
|
- `@aws-sdk/eventstream-handler-node@3.972.34` (`LICENSE`)
|
|
2020
2011
|
- `@aws-sdk/middleware-websocket@3.972.52` (`LICENSE`)
|
|
2021
|
-
- `@aws-sdk/signature-v4-multi-region@3.996.46` (`LICENSE`)
|
|
2022
2012
|
- `@aws-sdk/signature-v4-multi-region@3.996.47` (`LICENSE`)
|
|
2023
|
-
- `@smithy/core@3.33.3` (`LICENSE`)
|
|
2024
2013
|
- `@smithy/core@3.35.1` (`LICENSE`)
|
|
2025
|
-
- `@smithy/types@4.17.2` (`LICENSE`)
|
|
2026
2014
|
- `@smithy/types@4.19.0` (`LICENSE`)
|
|
2027
2015
|
|
|
2028
2016
|
```text
|
|
@@ -10830,14 +10818,10 @@ Applies to:
|
|
|
10830
10818
|
- `@aws-sdk/middleware-eventstream@3.972.29` (`LICENSE`)
|
|
10831
10819
|
- `@aws-sdk/token-providers@3.1127.0` (`LICENSE`)
|
|
10832
10820
|
- `@aws-sdk/token-providers@3.1138.0` (`LICENSE`)
|
|
10833
|
-
- `@aws-sdk/types@3.974.5` (`LICENSE`)
|
|
10834
10821
|
- `@aws-sdk/types@3.974.6` (`LICENSE`)
|
|
10835
|
-
- `@aws-sdk/xml-builder@3.972.40` (`LICENSE`)
|
|
10836
10822
|
- `@aws-sdk/xml-builder@3.972.41` (`LICENSE`)
|
|
10837
10823
|
- `@smithy/credential-provider-imds@4.5.2` (`LICENSE`)
|
|
10838
|
-
- `@smithy/fetch-http-handler@5.7.2` (`LICENSE`)
|
|
10839
10824
|
- `@smithy/fetch-http-handler@5.8.0` (`LICENSE`)
|
|
10840
|
-
- `@smithy/node-http-handler@4.11.3` (`LICENSE`)
|
|
10841
10825
|
- `@smithy/node-http-handler@4.12.1` (`LICENSE`)
|
|
10842
10826
|
- `@smithy/signature-v4@5.7.3` (`LICENSE`)
|
|
10843
10827
|
|
|
@@ -11862,7 +11846,6 @@ SOFTWARE.
|
|
|
11862
11846
|
|
|
11863
11847
|
Applies to:
|
|
11864
11848
|
|
|
11865
|
-
- `@aws-sdk/core@3.977.9` (`LICENSE`)
|
|
11866
11849
|
- `@aws-sdk/core@3.978.1` (`LICENSE`)
|
|
11867
11850
|
|
|
11868
11851
|
```text
|
|
@@ -12135,218 +12118,6 @@ FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TOR
|
|
|
12135
12118
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
12136
12119
|
```
|
|
12137
12120
|
|
|
12138
|
-
### License/notice f1aac97cee45
|
|
12139
|
-
|
|
12140
|
-
Applies to:
|
|
12141
|
-
|
|
12142
|
-
- `@aws-sdk/nested-clients@3.997.44` (`package metadata fallback`)
|
|
12143
|
-
|
|
12144
|
-
```text
|
|
12145
|
-
The published @aws-sdk/nested-clients@3.997.44 package declared Apache-2.0 but did not include a license or notice file. Attribution from its package metadata: AWS SDK for JavaScript Team. Repository: https://github.com/aws/aws-sdk-js-v3.git.
|
|
12146
|
-
|
|
12147
|
-
Apache License
|
|
12148
|
-
Version 2.0, January 2004
|
|
12149
|
-
http://www.apache.org/licenses/
|
|
12150
|
-
|
|
12151
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
12152
|
-
|
|
12153
|
-
1. Definitions.
|
|
12154
|
-
|
|
12155
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
12156
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
12157
|
-
|
|
12158
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
12159
|
-
the copyright owner that is granting the License.
|
|
12160
|
-
|
|
12161
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
12162
|
-
other entities that control, are controlled by, or are under common
|
|
12163
|
-
control with that entity. For the purposes of this definition,
|
|
12164
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
12165
|
-
direction or management of such entity, whether by contract or
|
|
12166
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
12167
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
12168
|
-
|
|
12169
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
12170
|
-
exercising permissions granted by this License.
|
|
12171
|
-
|
|
12172
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
12173
|
-
including but not limited to software source code, documentation
|
|
12174
|
-
source, and configuration files.
|
|
12175
|
-
|
|
12176
|
-
"Object" form shall mean any form resulting from mechanical
|
|
12177
|
-
transformation or translation of a Source form, including but
|
|
12178
|
-
not limited to compiled object code, generated documentation,
|
|
12179
|
-
and conversions to other media types.
|
|
12180
|
-
|
|
12181
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
12182
|
-
Object form, made available under the License, as indicated by a
|
|
12183
|
-
copyright notice that is included in or attached to the work
|
|
12184
|
-
(an example is provided in the Appendix below).
|
|
12185
|
-
|
|
12186
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
12187
|
-
form, that is based on (or derived from) the Work and for which the
|
|
12188
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
12189
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
12190
|
-
of this License, Derivative Works shall not include works that remain
|
|
12191
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
12192
|
-
the Work and Derivative Works thereof.
|
|
12193
|
-
|
|
12194
|
-
"Contribution" shall mean any work of authorship, including
|
|
12195
|
-
the original version of the Work and any modifications or additions
|
|
12196
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
12197
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
12198
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
12199
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
12200
|
-
means any form of electronic, verbal, or written communication sent
|
|
12201
|
-
to the Licensor or its representatives, including but not limited to
|
|
12202
|
-
communication on electronic mailing lists, source code control systems,
|
|
12203
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
12204
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
12205
|
-
excluding communication that is conspicuously marked or otherwise
|
|
12206
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
12207
|
-
|
|
12208
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
12209
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
12210
|
-
subsequently incorporated within the Work.
|
|
12211
|
-
|
|
12212
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
12213
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
12214
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
12215
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
12216
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
12217
|
-
Work and such Derivative Works in Source or Object form.
|
|
12218
|
-
|
|
12219
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
12220
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
12221
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
12222
|
-
(except as stated in this section) patent license to make, have made,
|
|
12223
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
12224
|
-
where such license applies only to those patent claims licensable
|
|
12225
|
-
by such Contributor that are necessarily infringed by their
|
|
12226
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
12227
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
12228
|
-
institute patent litigation against any entity (including a
|
|
12229
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
12230
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
12231
|
-
or contributory patent infringement, then any patent licenses
|
|
12232
|
-
granted to You under this License for that Work shall terminate
|
|
12233
|
-
as of the date such litigation is filed.
|
|
12234
|
-
|
|
12235
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
12236
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
12237
|
-
modifications, and in Source or Object form, provided that You
|
|
12238
|
-
meet the following conditions:
|
|
12239
|
-
|
|
12240
|
-
(a) You must give any other recipients of the Work or
|
|
12241
|
-
Derivative Works a copy of this License; and
|
|
12242
|
-
|
|
12243
|
-
(b) You must cause any modified files to carry prominent notices
|
|
12244
|
-
stating that You changed the files; and
|
|
12245
|
-
|
|
12246
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
12247
|
-
that You distribute, all copyright, patent, trademark, and
|
|
12248
|
-
attribution notices from the Source form of the Work,
|
|
12249
|
-
excluding those notices that do not pertain to any part of
|
|
12250
|
-
the Derivative Works; and
|
|
12251
|
-
|
|
12252
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
12253
|
-
distribution, then any Derivative Works that You distribute must
|
|
12254
|
-
include a readable copy of the attribution notices contained
|
|
12255
|
-
within such NOTICE file, excluding those notices that do not
|
|
12256
|
-
pertain to any part of the Derivative Works, in at least one
|
|
12257
|
-
of the following places: within a NOTICE text file distributed
|
|
12258
|
-
as part of the Derivative Works; within the Source form or
|
|
12259
|
-
documentation, if provided along with the Derivative Works; or,
|
|
12260
|
-
within a display generated by the Derivative Works, if and
|
|
12261
|
-
wherever such third-party notices normally appear. The contents
|
|
12262
|
-
of the NOTICE file are for informational purposes only and
|
|
12263
|
-
do not modify the License. You may add Your own attribution
|
|
12264
|
-
notices within Derivative Works that You distribute, alongside
|
|
12265
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
12266
|
-
that such additional attribution notices cannot be construed
|
|
12267
|
-
as modifying the License.
|
|
12268
|
-
|
|
12269
|
-
You may add Your own copyright statement to Your modifications and
|
|
12270
|
-
may provide additional or different license terms and conditions
|
|
12271
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
12272
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
12273
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
12274
|
-
the conditions stated in this License.
|
|
12275
|
-
|
|
12276
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
12277
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
12278
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
12279
|
-
this License, without any additional terms or conditions.
|
|
12280
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
12281
|
-
the terms of any separate license agreement you may have executed
|
|
12282
|
-
with Licensor regarding such Contributions.
|
|
12283
|
-
|
|
12284
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
12285
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
12286
|
-
except as required for reasonable and customary use in describing the
|
|
12287
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
12288
|
-
|
|
12289
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
12290
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
12291
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
12292
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
12293
|
-
implied, including, without limitation, any warranties or conditions
|
|
12294
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
12295
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
12296
|
-
appropriateness of using or redistributing the Work and assume any
|
|
12297
|
-
risks associated with Your exercise of permissions under this License.
|
|
12298
|
-
|
|
12299
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
12300
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
12301
|
-
unless required by applicable law (such as deliberate and grossly
|
|
12302
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
12303
|
-
liable to You for damages, including any direct, indirect, special,
|
|
12304
|
-
incidental, or consequential damages of any character arising as a
|
|
12305
|
-
result of this License or out of the use or inability to use the
|
|
12306
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
12307
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
12308
|
-
other commercial damages or losses), even if such Contributor
|
|
12309
|
-
has been advised of the possibility of such damages.
|
|
12310
|
-
|
|
12311
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
12312
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
12313
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
12314
|
-
or other liability obligations and/or rights consistent with this
|
|
12315
|
-
License. However, in accepting such obligations, You may act only
|
|
12316
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
12317
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
12318
|
-
defend, and hold each Contributor harmless for any liability
|
|
12319
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
12320
|
-
of your accepting any such warranty or additional liability.
|
|
12321
|
-
|
|
12322
|
-
END OF TERMS AND CONDITIONS
|
|
12323
|
-
|
|
12324
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
12325
|
-
|
|
12326
|
-
To apply the Apache License to your work, attach the following
|
|
12327
|
-
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
12328
|
-
replaced with your own identifying information. (Don't include
|
|
12329
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
12330
|
-
comment syntax for the file format. We also recommend that a
|
|
12331
|
-
file or class name and description of purpose be included on the
|
|
12332
|
-
same "printed page" as the copyright notice for easier
|
|
12333
|
-
identification within third-party archives.
|
|
12334
|
-
|
|
12335
|
-
Copyright 2018-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
12336
|
-
|
|
12337
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
12338
|
-
you may not use this file except in compliance with the License.
|
|
12339
|
-
You may obtain a copy of the License at
|
|
12340
|
-
|
|
12341
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
12342
|
-
|
|
12343
|
-
Unless required by applicable law or agreed to in writing, software
|
|
12344
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12345
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12346
|
-
See the License for the specific language governing permissions and
|
|
12347
|
-
limitations under the License.
|
|
12348
|
-
```
|
|
12349
|
-
|
|
12350
12121
|
### License/notice f2b90afb27a6
|
|
12351
12122
|
|
|
12352
12123
|
Applies to:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-edge",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0-alpha.1",
|
|
4
4
|
"description": "Your DeepSeek Harness, anywhere — deploy a persistent personal coding agent to Cloudflare Workers in one command",
|
|
5
5
|
"author": "pawaca",
|
|
6
6
|
"license": "MIT",
|
|
@@ -103,6 +103,7 @@
|
|
|
103
103
|
"@deepseek-ai/dsh-llm": "0.2.0-rc.2",
|
|
104
104
|
"@deepseek-ai/dsh-llm-deepseek": "0.2.0-rc.2",
|
|
105
105
|
"@deepseek-ai/dsh-llm-deepseek-api-key": "0.2.0-rc.2",
|
|
106
|
+
"@deepseek-ai/dsh-llm-pi-ai": "0.2.0-rc.2",
|
|
106
107
|
"@deepseek-ai/dsh-llm-retry": "0.2.0-rc.2",
|
|
107
108
|
"@deepseek-ai/dsh-message-feedback": "0.2.0-rc.2",
|
|
108
109
|
"@deepseek-ai/dsh-output-retention": "0.2.0-rc.2",
|
|
@@ -192,6 +193,7 @@
|
|
|
192
193
|
"example:install": "node examples/install-keyless.mjs",
|
|
193
194
|
"install:cloudflare": "pnpm run bundle:workers && node scripts/cli.mjs install",
|
|
194
195
|
"legal:write": "node scripts/legal-files.mjs write",
|
|
196
|
+
"check:startup": "node scripts/check-startup.mjs",
|
|
195
197
|
"pack:verify": "node scripts/verify-packed.mjs",
|
|
196
198
|
"web:build": "pnpm --dir standalone run build:web && node standalone/scripts/promote.mjs web",
|
|
197
199
|
"test": "vitest run --root ../.. --project edge-runtime",
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export
|
|
2
|
-
export function
|
|
1
|
+
export const WORKER_SIZE_LIMIT_BYTES: number
|
|
2
|
+
export function parseWranglerUploadSizes(output: string): { bytes: number, gzipBytes: number }
|
|
3
|
+
export function requireWorkerSizeLimit(output: string, maxBytes?: number): { bytes: number, gzipBytes: number }
|
package/scripts/bundle-size.mjs
CHANGED
|
@@ -4,23 +4,33 @@ const SIZE_UNITS = Object.freeze({
|
|
|
4
4
|
MiB: 1024 * 1024,
|
|
5
5
|
})
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Cloudflare's Worker size limit: 64 MiB uncompressed on Workers Free and Paid.
|
|
9
|
+
* There is no compressed-size limit; Wrangler's gzip figure is for reference.
|
|
10
|
+
* https://developers.cloudflare.com/workers/platform/limits/
|
|
11
|
+
*/
|
|
12
|
+
export const WORKER_SIZE_LIMIT_BYTES = 64 * 1024 * 1024
|
|
13
|
+
|
|
14
|
+
/** Extract Wrangler's total upload sizes (uncompressed and gzip) in bytes. */
|
|
15
|
+
export function parseWranglerUploadSizes(output) {
|
|
16
|
+
const match = /Total Upload:\s*([0-9]+(?:\.[0-9]+)?)\s*(B|KiB|MiB)\s*\/ gzip:\s*([0-9]+(?:\.[0-9]+)?)\s*(B|KiB|MiB)/u.exec(output)
|
|
17
|
+
if (match === null) throw new Error('Wrangler did not report the upload size.')
|
|
18
|
+
return {
|
|
19
|
+
bytes: Math.ceil(Number(match[1]) * SIZE_UNITS[match[2]]),
|
|
20
|
+
gzipBytes: Math.ceil(Number(match[3]) * SIZE_UNITS[match[4]]),
|
|
21
|
+
}
|
|
12
22
|
}
|
|
13
23
|
|
|
14
|
-
/** Reject a
|
|
15
|
-
export function
|
|
24
|
+
/** Reject a Worker artifact above Cloudflare's uncompressed size limit. */
|
|
25
|
+
export function requireWorkerSizeLimit(output, maxBytes = WORKER_SIZE_LIMIT_BYTES) {
|
|
16
26
|
if (!Number.isSafeInteger(maxBytes) || maxBytes <= 0) {
|
|
17
27
|
throw new TypeError('maxBytes must be a positive safe integer.')
|
|
18
28
|
}
|
|
19
|
-
const
|
|
20
|
-
if (
|
|
29
|
+
const sizes = parseWranglerUploadSizes(output)
|
|
30
|
+
if (sizes.bytes > maxBytes) {
|
|
21
31
|
throw new Error(
|
|
22
|
-
`
|
|
32
|
+
`Worker size ${sizes.bytes} bytes exceeds Cloudflare's ${maxBytes}-byte uncompressed limit.`,
|
|
23
33
|
)
|
|
24
34
|
}
|
|
25
|
-
return
|
|
35
|
+
return sizes
|
|
26
36
|
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profile the promoted Worker artifacts' startup with `wrangler check startup`
|
|
3
|
+
* and reject one whose global scope takes longer than the budget.
|
|
4
|
+
*
|
|
5
|
+
* Cloudflare gives a Worker 1 second of startup CPU to parse and run its
|
|
6
|
+
* global scope (https://developers.cloudflare.com/workers/platform/limits/).
|
|
7
|
+
* The profile runs locally on a different CPU, so the budget leaves margin
|
|
8
|
+
* below that limit and serves as a regression guard, not a measurement of the
|
|
9
|
+
* deployed startup time.
|
|
10
|
+
*
|
|
11
|
+
* Usage: node scripts/check-startup.mjs [direct|isolated|all]
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { mkdtemp, readFile, rm } from 'node:fs/promises'
|
|
15
|
+
import { createRequire } from 'node:module'
|
|
16
|
+
import { tmpdir } from 'node:os'
|
|
17
|
+
import { join } from 'node:path'
|
|
18
|
+
import { fileURLToPath } from 'node:url'
|
|
19
|
+
import { execa } from 'execa'
|
|
20
|
+
import { writePrebuiltModeWranglerConfig } from './wrangler-config.mjs'
|
|
21
|
+
|
|
22
|
+
export const STARTUP_BUDGET_MS = 600
|
|
23
|
+
|
|
24
|
+
/** Startup duration of a V8 CPU profile, in milliseconds. */
|
|
25
|
+
export function profileDurationMs(profile) {
|
|
26
|
+
if (typeof profile?.startTime !== 'number' || typeof profile?.endTime !== 'number' || profile.endTime < profile.startTime) {
|
|
27
|
+
throw new Error('The startup profile has no valid start and end times.')
|
|
28
|
+
}
|
|
29
|
+
return (profile.endTime - profile.startTime) / 1000
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const appDirectory = fileURLToPath(new URL('..', import.meta.url))
|
|
33
|
+
const wranglerCli = createRequire(import.meta.url).resolve('wrangler')
|
|
34
|
+
|
|
35
|
+
async function checkStartup(mode) {
|
|
36
|
+
const directory = await mkdtemp(join(tmpdir(), `dsh-edge-startup-${mode}-`))
|
|
37
|
+
try {
|
|
38
|
+
const config = join(directory, 'wrangler.json')
|
|
39
|
+
const profile = join(directory, 'startup.cpuprofile')
|
|
40
|
+
await writePrebuiltModeWranglerConfig(mode, config, { r2BucketName: 'dsh-edge-startup-check' })
|
|
41
|
+
const result = await execa(process.execPath, [
|
|
42
|
+
wranglerCli, 'check', 'startup',
|
|
43
|
+
'--config', config,
|
|
44
|
+
...mode === 'isolated' ? ['--env', 'isolated'] : [],
|
|
45
|
+
'--outfile', profile,
|
|
46
|
+
], { cwd: appDirectory, reject: false, all: true })
|
|
47
|
+
if (result.exitCode !== 0) {
|
|
48
|
+
throw new Error(`wrangler check startup failed for the ${mode} Worker:\n${result.all ?? ''}`)
|
|
49
|
+
}
|
|
50
|
+
const durationMs = profileDurationMs(JSON.parse(await readFile(profile, 'utf8')))
|
|
51
|
+
process.stdout.write(`${mode} Worker startup: ${durationMs.toFixed(0)} ms (budget ${STARTUP_BUDGET_MS} ms, local CPU).\n`)
|
|
52
|
+
if (durationMs > STARTUP_BUDGET_MS) {
|
|
53
|
+
throw new Error(`The ${mode} Worker startup took ${durationMs.toFixed(0)} ms, above the ${STARTUP_BUDGET_MS} ms budget (Cloudflare allows 1000 ms).`)
|
|
54
|
+
}
|
|
55
|
+
} finally {
|
|
56
|
+
await rm(directory, { recursive: true, force: true })
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
|
61
|
+
const requested = process.argv[2] ?? 'all'
|
|
62
|
+
const modes = requested === 'all' ? ['direct', 'isolated'] : [requested]
|
|
63
|
+
if (!modes.every(mode => mode === 'direct' || mode === 'isolated')) {
|
|
64
|
+
process.stderr.write('Usage: node scripts/check-startup.mjs [direct|isolated|all]\n')
|
|
65
|
+
process.exitCode = 2
|
|
66
|
+
} else {
|
|
67
|
+
try {
|
|
68
|
+
for (const mode of modes) await checkStartup(mode)
|
|
69
|
+
} catch (error) {
|
|
70
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`)
|
|
71
|
+
process.exitCode = 1
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|