diff --git a/content/zh-CN/recipes/dsh-qoder-cloud-agents/assets/cloud-mode-switch.png b/content/zh-CN/recipes/dsh-qoder-cloud-agents/assets/cloud-mode-switch.png new file mode 100644 index 0000000..4c10175 Binary files /dev/null and b/content/zh-CN/recipes/dsh-qoder-cloud-agents/assets/cloud-mode-switch.png differ diff --git a/content/zh-CN/recipes/dsh-qoder-cloud-agents/assets/cloud-reply.png b/content/zh-CN/recipes/dsh-qoder-cloud-agents/assets/cloud-reply.png new file mode 100644 index 0000000..744a49c Binary files /dev/null and b/content/zh-CN/recipes/dsh-qoder-cloud-agents/assets/cloud-reply.png differ diff --git a/content/zh-CN/recipes/dsh-qoder-cloud-agents/assets/environment-picker.png b/content/zh-CN/recipes/dsh-qoder-cloud-agents/assets/environment-picker.png new file mode 100644 index 0000000..5497a3e Binary files /dev/null and b/content/zh-CN/recipes/dsh-qoder-cloud-agents/assets/environment-picker.png differ diff --git a/content/zh-CN/recipes/dsh-qoder-cloud-agents/assets/follow-up.png b/content/zh-CN/recipes/dsh-qoder-cloud-agents/assets/follow-up.png new file mode 100644 index 0000000..ff98c9f Binary files /dev/null and b/content/zh-CN/recipes/dsh-qoder-cloud-agents/assets/follow-up.png differ diff --git a/content/zh-CN/recipes/dsh-qoder-cloud-agents/index.md b/content/zh-CN/recipes/dsh-qoder-cloud-agents/index.md new file mode 100644 index 0000000..2b6940e --- /dev/null +++ b/content/zh-CN/recipes/dsh-qoder-cloud-agents/index.md @@ -0,0 +1,142 @@ +--- +schema_version: 1 +slug: dsh-qoder-cloud-agents +title: 在 DeepSeek Harness 里用云端模式把任务交给 Qoder Cloud Agents +summary: 为 DeepSeek Harness 装一个插件,新会话打开「云端模式」后,每一轮都在 Qoder Cloud 沙箱里执行,可连续追问,改动推到新分支后拿回本地。适合想把本地 Agent 客户端接到云端执行的开发者。 +type: recipe +category: build-deploy +tags: + - session + - sandbox + - credential + - github +author: + name: Anchen + github: anchenqlw +locale: zh-CN +cover: ./assets/cloud-mode-switch.png +--- + +## 目标与适用场景 + +[DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)(dsh)是一个"万物皆插件"的本地 Agent 客户端。这篇 Recipe 用一个开源插件 `dsh-qoder-cloud-agents`,让 dsh 的会话直接跑在 Qoder Cloud Agents 的托管沙箱里: + +- 新会话打开「云端模式」开关,这个会话的每一轮都交给云端 Agent 执行,工具调用和回复实时回到对话; +- 继续输入就是追问,始终在同一个云端沙箱里,上一轮的改动都还在; +- 工作区是 git 仓库时,插件把 `origin` 挂载到云端,云端 Agent 把改动推到新分支,本地 `git fetch` 拿回来。 + +适合这些情况:任务需要较长时间运行、不想占用本机;需要干净可复现的执行环境;或者希望在熟悉的 dsh 界面里直接使用 Qoder Cloud 的托管沙箱。 + +插件还提供一个子代理工具 `subagent_qoder_cloud_agents`:在普通会话里由 DeepSeek 把某个子任务委派到云端,跑完后结果交回 DeepSeek。本文聚焦云端模式。 + +一轮云端执行的数据流如下:dsh 只把你新输入的文字(以及首轮的仓库与分支说明)发给 Qoder Cloud,云端 Agent 在沙箱里读写仓库、推送分支,事件通过 SSE 实时流回 dsh。 + +```mermaid +sequenceDiagram + participant U as dsh 会话 + participant P as 云端模式插件 + participant Q as Qoder Cloud Agents + participant G as 代码仓库 + U->>P: 发送任务 + P->>Q: 创建 Session 并挂载 origin + Q->>G: 克隆仓库 + Q-->>P: SSE 推送工具调用与回复 + P-->>U: 实时显示在对话里 + Q->>G: 推送 qoder-cloud-agents 分支 +``` + +## 操作步骤 + +### 第一步:安装插件、配置令牌 + +准备 Node.js 22+、DeepSeek Harness 0.2.x,以及在 [qoder.com](https://qoder.com) 的 Settings → Personal Access Tokens 中创建的 Qoder 个人访问令牌(PAT)。 + +从 Demo 源码构建安装包并装进 dsh 的 web profile,路径必须是绝对路径: + +```bash +cd demos/dsh-qoder-cloud-agents +npm ci +npm pack +dsh plugin --profile web add "$PWD/dsh-qoder-cloud-agents-0.1.0.tgz" +``` + +把令牌写进 `~/.dsh/.env`。`QODER_GIT_TOKEN` 用于云端克隆私有仓库和 `git push`,公开仓库、只读任务可以不配: + +```bash +echo 'QODER_PAT=pt-' >> ~/.dsh/.env +echo 'QODER_GIT_TOKEN=' >> ~/.dsh/.env +chmod 600 ~/.dsh/.env +``` + +按仓库所在平台准备代码仓库令牌: + +| 仓库在哪 | `QODER_GIT_TOKEN` 填什么 | 还要配 `gitUsername` 吗 | +|---|---|---| +| GitHub | fine-grained PAT 授予 Contents 读写,或 classic PAT 授予 `repo` | 不用 | +| GitLab.com、Gitee 等通用 Git | 该平台的个人访问令牌(GitLab 需要 `read_repository` 和 `write_repository`) | 要 | + +通用 Git 还要在 `~/.dsh/profiles/web/cordis.patch.yml` 里写上用户名: + +```yaml +- id: qoder-cloud-agents + name: dsh-qoder-cloud-agents + config: + gitUsername: your-git-user +``` + +最后重启 dsh:在 `dsh web` 的终端按 `Ctrl+C` 停掉,再运行 `dsh web`。dsh 只在启动时读取插件和令牌。 + +### 第二步:新会话打开云端模式 + +在左侧工作区选择一个本地 git 仓库,先 `git push`:云端只能拿到已推送的提交。点击「新会话」,打开输入框上方最右侧的「云端模式」开关,左边的模式标签会同步变成「云端模式」。 + +![新会话页:输入框上方最右侧的云端模式开关](./assets/cloud-mode-switch.png) + +照常输入任务并发送。第一次使用会弹窗选择 Qoder 环境,一般选托管 cloud 环境(如 Default),选择会保存到 profile;之后可以用 `/qoder-cloud-agents env` 查看和切换。 + +![首次使用:选择 Qoder 环境](./assets/environment-picker.png) + +### 第三步:云端执行,结果实时回来 + +云端 Agent 的回复显示在对话里。展开「已完成」→「已完成分析」,能看到云端 session、仓库、分支,以及每一个工具调用。 + +![云端回复:工具调用与结果](./assets/cloud-reply.png) + +继续输入就是追问,还在同一个云端沙箱里: + +![追问:仍在同一个云端沙箱](./assets/follow-up.png) + +### 第四步:把分支拿回本地 + +云端的改动推到新分支 `qoder-cloud-agents/<随机8位>`,分支名写在回复里: + +```bash +git fetch origin && git checkout qoder-cloud-agents/xxxxxxxx +git log --oneline -3 +``` + +完整的配置项、子代理工具与斜杠命令说明、清理步骤和安全提示见 Demo README。 + +[查看 Demo 源码](https://github.com/QoderAI/cloud-agents-cookbook/tree/main/demos/dsh-qoder-cloud-agents) + +## 验证结果 + +逐项确认: + +- 云端模式会话的输入框右下角显示「云端模式(Qoder Cloud Agents)」,模式在会话发出第一条消息后固定。 +- 回复的「已完成分析」里能看到云端 session id、仓库地址、结果分支,以及 `› Bash: git push …` 这样的工具调用。 +- 第二轮追问的回复说明仍在同一个沙箱,结果推送到同一个分支。 +- 本地 `git fetch` 后,`git log --oneline -3` 能看到云端提交。 +- 在 Demo 目录运行 `npm test`,35 个单元测试全部通过;它们使用本机模拟网关,不消耗额度。 + +常见问题: + +| 现象 | 处理 | +|---|---| +| 看不到「云端模式」开关 | dsh 是装插件之前启动的,重启 dsh;开关只在「新会话」页面 | +| 报错 no Qoder PAT | `QODER_PAT` 没写进 `~/.dsh/.env`,或写完没重启 | +| 云端说仓库目录不存在 | 私有仓库没配 `QODER_GIT_TOKEN`,或令牌无效、没有该仓库的权限 | +| 报错 needs an account name | 通用 Git 配了 `QODER_GIT_TOKEN` 但没配 `gitUsername` | +| 云端看不到刚写的代码 | 先 `git push`,云端只能拿到已推送的提交 | + +每次云端执行都会消耗 Qoder 额度;作者实测一个只读小任务加一次追问约 5.8 credits。不再使用时,在 Qoder 控制台归档云端 session,删除不需要的结果分支,并吊销不再使用的令牌。 diff --git a/demos/dsh-qoder-cloud-agents/.gitignore b/demos/dsh-qoder-cloud-agents/.gitignore new file mode 100644 index 0000000..3681b3b --- /dev/null +++ b/demos/dsh-qoder-cloud-agents/.gitignore @@ -0,0 +1,3 @@ +node_modules/ +lib/ +*.tgz diff --git a/demos/dsh-qoder-cloud-agents/README.md b/demos/dsh-qoder-cloud-agents/README.md new file mode 100644 index 0000000..7da9ca5 --- /dev/null +++ b/demos/dsh-qoder-cloud-agents/README.md @@ -0,0 +1,151 @@ +# DeepSeek Harness 云端模式插件 Demo + +`dsh-qoder-cloud-agents` 是一个 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)(dsh)插件,把任务交给 Qoder Cloud Agents 在云端沙箱里执行。它提供三个入口: + +| 入口 | 用法 | 适合 | +|---|---|---| +| 云端模式 | 新会话输入框上方最右侧的「云端模式」开关 | 整个会话在云端执行,回复实时显示,可在同一个云端沙箱里连续追问 | +| 子代理工具 `subagent_qoder_cloud_agents` | 普通会话里由 DeepSeek 调用 | 把某个子任务委派到云端,跑完后结果交回 DeepSeek | +| 斜杠命令 `/qoder-cloud-agents` | 在对话框输入 | 查看和切换 Qoder 环境、Agent | + +工作区是 git 仓库时,插件按 Qoder 控制台的方式把 `origin` 挂载到云端 `/data/workspace/<仓库名>`,并要求云端 Agent 把改动推送到新分支 `qoder-cloud-agents/<随机8位>`。 + +## 对应文章 + +- 标题:在 DeepSeek Harness 里用云端模式把任务交给 Qoder Cloud Agents +- Slug:`dsh-qoder-cloud-agents` + +## 前置条件 + +- Node.js 22 或更高版本,以及 npm。 +- DeepSeek Harness 0.2.x(`dsh --version` 可查看),或内置 dsh 0.2.x 的 Mac / Windows 客户端。 +- Qoder 个人访问令牌(PAT):登录 [qoder.com](https://qoder.com),在 Settings → Personal Access Tokens 中创建,形如 `pt-…`,只显示一次。 +- 可选:代码仓库令牌。仓库是私有的,或者要让云端 `git push` 时才需要: + - GitHub:fine-grained PAT 授予 Contents 读写,或 classic PAT 授予 `repo`。 + - GitLab.com、Gitee 等通用 Git:该平台的个人访问令牌(GitLab 需要 `read_repository` 和 `write_repository`),并在插件配置里写上用户名 `gitUsername`。 +- 在本机打开的 git 仓库需要配置好 `origin`,并且已经把要处理的提交推送到远端:云端只能拿到已推送的提交。 + +## 安装与配置 + +1. 在本目录构建安装包(`npm pack` 会先执行构建): + + ```bash + npm ci + npm pack + ``` + + 得到 `dsh-qoder-cloud-agents-0.1.0.tgz`。把它放到一个固定目录(例如 `~/dsh-plugins/`),profile 里记录的是这个路径。 + +2. 安装到 dsh 的 web profile(其他 profile 换成对应名字),路径必须是绝对路径: + + ```bash + dsh plugin --profile web add ~/dsh-plugins/dsh-qoder-cloud-agents-0.1.0.tgz + ``` + + Mac / Windows 客户端:在侧边栏「插件」→ 安装插件,填 tgz 的绝对路径。 + +3. 把令牌写进 `~/.dsh/.env`,不要写进仓库或 yml 配置: + + ```bash + echo 'QODER_PAT=pt-' >> ~/.dsh/.env + echo 'QODER_GIT_TOKEN=' >> ~/.dsh/.env # 公开仓库、只读可以不配 + chmod 600 ~/.dsh/.env + ``` + +4. 通用 Git(GitHub 跳过):打开 `~/.dsh/profiles/web/cordis.patch.yml`,加上用户名。文件里已有 `id: qoder-cloud-agents` 时只在它的 `config` 下补字段;文件只有一行 `[]` 时先删掉它: + + ```yaml + - id: qoder-cloud-agents + name: dsh-qoder-cloud-agents + config: + gitUsername: your-git-user + ``` + +5. 其他可选配置也写在同一段 `config` 下(patch 会整体替换 `config`,已有字段要一起保留): + + ```yaml + - id: qoder-cloud-agents + name: dsh-qoder-cloud-agents + config: + baseURL: https://api.qoder.com/api/v1/cloud + environmentId: env_xxx # 不填:首次使用时弹窗选择并记住 + agentId: agent_xxx # 不填:自动选择或新建插件管理的 Agent + repository: auto # auto | none + branchPrefix: qoder-cloud-agents/ + archiveOnFinish: false # true:子代理回合结束后归档云端 session + timeoutMs: 7200000 # 单次委派上限,超时会取消云端回合 + ``` + + 全部字段见 [src/index.ts](src/index.ts) 中的 `Config`。 + +6. 重启 dsh:在 `dsh web` 的终端按 `Ctrl+C` 停掉再运行 `dsh web`;客户端用户完全退出(⌘Q)后重新打开。dsh 只在启动时读取插件和令牌。 + +## 运行 + +### 云端模式 + +1. 在 dsh web 左侧工作区选择一个本地 git 仓库,点击「新会话」。 +2. 打开输入框上方最右侧的「云端模式」开关,左边的模式标签会同步变成「云端模式」。 +3. 输入任务并发送,例如「把 README 的问候语改成中英双语,提交并推送到新分支」。第一次使用会弹窗选择 Qoder 环境,一般选托管 cloud 环境(如 Default),选择会保存到 profile。 +4. 继续输入就是追问,始终在同一个云端沙箱里,上一轮的改动都还在。 +5. 在本地拿回云端推送的分支,分支名写在回复里: + + ```bash + git fetch origin && git checkout qoder-cloud-agents/xxxxxxxx + ``` + +### 子代理工具 + +在普通会话里点名让 DeepSeek 使用这个工具最可靠: + +```text +用 subagent_qoder_cloud_agents 把这个任务交给云端:给 src/utils/date.ts 补单元测试,跑通后推送到新分支。 +``` + +工具调用立即返回,云端跑完后结果(含云端 session id、结果分支、交付文件和本地未推送提醒)自动回到对话。一次委派是一个独立的云端 session,不能追问;需要来回交流时用云端模式。 + +### 斜杠命令 + +| 命令 | 作用 | +|---|---| +| `/qoder-cloud-agents` | 查看当前环境、Agent 和网关 | +| `/qoder-cloud-agents env` | 列出环境(`*` 为当前) | +| `/qoder-cloud-agents env ` | 切换环境并保存 | +| `/qoder-cloud-agents agent` | 列出 Agent | +| `/qoder-cloud-agents agent ` | 切换 Agent;`new` 使用插件管理的 Agent | +| `/qoder-cloud-agents reset` | 清除已保存的选择,下次重新选择 | + +## 验证结果 + +单元测试不访问外部网络:它在本机起一个模拟 Qoder Cloud 网关,覆盖环境与 Agent 的选择、仓库挂载、SSE 断线续传、取消、云端模式的请求路由和系统提示词变量。 + +```bash +npm ci +npm test +``` + +预期 2 个测试文件、35 个测试全部通过。 + +端到端验证(会消耗 Qoder 额度): + +- 云端模式会话的输入框右下角显示「云端模式(Qoder Cloud Agents)」。 +- 回复下展开「已完成」→「已完成分析」,能看到云端 session id、仓库地址、结果分支,以及 `› Read`、`› Bash: git push …` 这样的工具调用。 +- 第二轮追问的回复说明仍在同一个沙箱,结果推送到同一个分支。 +- 本地 `git fetch` 后 `git log --oneline -3` 能看到云端的提交。 +- 轨迹页里,云端模式会话不会在第二轮出现「系统提示词已更新」。 + +## 清理资源 + +- 云端 session:子代理工具在配置 `archiveOnFinish: true` 时会自动归档;云端模式和默认配置下 session 保留在 Qoder 控制台,可在控制台归档或删除。 +- 结果分支:不需要时删除远端分支,例如 `git push origin --delete qoder-cloud-agents/xxxxxxxx`。 +- 插件:`dsh plugin --profile web remove dsh-qoder-cloud-agents`,然后重启 dsh。`cordis.patch.yml` 里保存的 `environmentId`、`agentId`、`gitUsername` 不会随卸载删除,不需要时手动删掉那一段。 +- 令牌:从 `~/.dsh/.env` 删除 `QODER_PAT`、`QODER_GIT_TOKEN`,并在 Qoder 与 Git 平台吊销不再使用的令牌。 +- 本地构建产物:删除本目录下的 `node_modules/`、`lib/` 和生成的 `.tgz`。 + +## 成本与安全 + +- 每次云端执行都会消耗 Qoder 额度。作者实测一个只读小任务加一次追问约 5.8 credits,实际消耗取决于任务和模型。 +- `QODER_PAT` 可以代表你调用 Qoder Cloud Agents API;`QODER_GIT_TOKEN` 会作为仓库凭据随 session 发送到 Qoder Cloud,云端 Agent 可以用它向你的仓库推送。请使用最小权限、可随时吊销的令牌,只把令牌放在 `~/.dsh/.env`(`chmod 600`)或环境变量里。 +- 云端 Agent 会在新分支上提交并推送,不会改动当前分支;合并前请像审查同事的 PR 一样审查改动。 +- 云端模式只把你新输入的文字(以及首轮的仓库与分支说明)发送给 Qoder Cloud,不会发送 dsh 的系统提示词;本地附加的图片和文件不会上传。 +- 插件以 dsh 宿主进程的权限运行。这是示例代码,用于生产前请自行评估错误处理、超时、额度和令牌轮换策略。 diff --git a/demos/dsh-qoder-cloud-agents/client.js b/demos/dsh-qoder-cloud-agents/client.js new file mode 100644 index 0000000..e61b869 --- /dev/null +++ b/demos/dsh-qoder-cloud-agents/client.js @@ -0,0 +1,123 @@ +/** + * Web / Desktop client: a 「云端模式」 switch in the New Session row + * (`conversation.hero.options`). Turning it on selects the `qoder-cloud-agents` + * agent preset for the blank session, whose turns then run on Qoder Cloud; + * turning it off returns to the default preset. dsh locks the preset once + * the session's first turn starts. + * + * Hand-written in the ModuleLoader format the Host serves for `exports["./client"]`; + * React and the UI primitives come from the host. + */ +window.__ModuleLoader__.load({ + id: 'dsh-qoder-cloud-agents', + factory(require) { + const React = require('react') + const { Switch, IconGlobeOutlineRegular } = require('@deepseek-ai/dsh-client-ui-primitives') + const h = React.createElement + const PRESET = 'qoder-cloud-agents' + const NS = 'qoderCloudAgents' + + const zh = { + label: '云端模式', + on: '本会话的每一轮都交给 Qoder Cloud 云端 Agent 执行', + off: '开启后,本会话的每一轮都交给 Qoder Cloud 云端 Agent 执行;当前目录的 git 仓库会挂载到云端', + locked: '会话开始后不能切换模式', + failed: '切换失败:', + } + const en = { + label: 'Cloud mode', + on: 'Every turn of this session runs on a Qoder Cloud agent', + off: 'Run every turn of this session on a Qoder Cloud agent; the git repository of this workspace is mounted in the cloud', + locked: 'The mode is fixed once the session starts', + failed: 'Could not switch: ', + } + + /** Message of a failed Remote result. */ + function refusal(error) { + const reason = error && error.details && typeof error.details.reason === 'string' ? error.details.reason : undefined + return reason || (error && error.message) || 'unknown error' + } + + function CloudModeSwitch({ useMode, setCloud, t }) { + // dsh turns `hooks.mode` into a selector hook: always pass a selector. + const on = useMode(mode => mode.state === 'on') + const locked = useMode(mode => !mode.blank) + const [busy, setBusy] = React.useState(false) + const [error, setError] = React.useState(null) + const hint = error !== null ? t('failed') + error : locked ? t('locked') : on ? t('on') : t('off') + return h('div', { + title: hint, + style: { display: 'inline-flex', alignItems: 'center', gap: 6, fontSize: 13, color: 'var(--text-secondary, inherit)' }, + }, + h(IconGlobeOutlineRegular, { size: 14 }), + h('span', null, t('label')), + h(Switch, { + checked: on, + label: t('label'), + title: hint, + disabled: busy || locked, + onChange: async (next) => { + setBusy(true) + setError(null) + try { + const failure = await setCloud(next) + if (failure !== undefined) setError(failure) + } finally { + setBusy(false) + } + }, + })) + } + + return { + inject: ['slots', 'sessions', 'remote', 'remote.agentPresets', 'locale'], + apply(ctx) { + ctx.effect(() => ctx.locale.register(NS, { en, zh })) + + /** Snapshot cache keyed by session so the hook source stays referentially stable. */ + const snapshots = new Map() + const modeOf = (sessionId) => { + const summary = ctx.sessions.list.getSnapshot().byId[sessionId] + const preset = summary && summary.projectionValues ? summary.projectionValues.agentPreset : undefined + const state = preset === PRESET ? 'on' : 'off' + const blank = summary !== undefined && summary.blank === true + const previous = snapshots.get(sessionId) + if (previous !== undefined && previous.state === state && previous.blank === blank) return previous + const next = { state, blank } + snapshots.set(sessionId, next) + return next + } + + ctx.slots.inject('conversation.hero.options', () => ctx.slots.register({ + name: 'conversation.hero.options', + id: 'qoder-cloud-agents-mode', + order: 100, + locale: NS, + inject: (sessionId) => ({ + hooks: { + mode: { + getSnapshot: () => modeOf(sessionId), + subscribe: listener => ctx.sessions.list.subscribe(listener), + }, + }, + /** Select the cloud preset, or the default one; resolves to a refusal message or undefined. */ + setCloud: async (on) => { + let target = PRESET + if (!on) { + const roster = await ctx.remote.agentPresets.list() + if (!roster.ok) return refusal(roster.error) + const presets = roster.value.presets || [] + const fallback = presets.find(preset => preset.isDefault && preset.id !== PRESET) + || presets.find(preset => preset.id !== PRESET) + if (fallback === undefined) return 'no other agent preset is available' + target = fallback.id + } + const result = await ctx.remote.agentPresets.select(sessionId, target) + return result.ok ? undefined : refusal(result.error) + }, + }), + }, CloudModeSwitch)) + }, + } + }, +}) diff --git a/demos/dsh-qoder-cloud-agents/cordis.patch.yml b/demos/dsh-qoder-cloud-agents/cordis.patch.yml new file mode 100644 index 0000000..83aa5d3 --- /dev/null +++ b/demos/dsh-qoder-cloud-agents/cordis.patch.yml @@ -0,0 +1,20 @@ +- insert: + - id: qoder-cloud-agents + name: 'dsh-qoder-cloud-agents' + - id: tool-qoder-cloud-agents + name: '@deepseek-ai/dsh-tool-subagent' + config: + provider: qoder-cloud-agents + toolName: subagent_qoder_cloud_agents + maxDepth: provider-managed + # 云端模式: a session created with this preset runs every turn on Qoder Cloud. + - id: preset-qoder-cloud-agents + name: '@deepseek-ai/dsh-agent-preset' + config: + id: qoder-cloud-agents + name: 云端模式 + description: 每一轮对话都交给 Qoder Cloud 的云端 Agent 执行,可连续追问;当前目录的 git 仓库会挂载到云端沙箱。 + order: 50 + plugins: + - id: qoder-cloud-agents-route + name: 'dsh-qoder-cloud-agents/cloud-route' diff --git a/demos/dsh-qoder-cloud-agents/icon.svg b/demos/dsh-qoder-cloud-agents/icon.svg new file mode 100644 index 0000000..5d1b889 --- /dev/null +++ b/demos/dsh-qoder-cloud-agents/icon.svg @@ -0,0 +1 @@ + diff --git a/demos/dsh-qoder-cloud-agents/locale/en.json b/demos/dsh-qoder-cloud-agents/locale/en.json new file mode 100644 index 0000000..abb5589 --- /dev/null +++ b/demos/dsh-qoder-cloud-agents/locale/en.json @@ -0,0 +1,6 @@ +{ + "meta": { + "title": "Qoder Cloud Agents cloud mode", + "description": "Turn on cloud mode in a new session to run every turn in a Qoder Cloud Agents sandbox, with follow-ups in the same sandbox and changes pushed to a new branch. Also adds a subagent tool for delegating single tasks." + } +} diff --git a/demos/dsh-qoder-cloud-agents/locale/zh.json b/demos/dsh-qoder-cloud-agents/locale/zh.json new file mode 100644 index 0000000..8b61ac4 --- /dev/null +++ b/demos/dsh-qoder-cloud-agents/locale/zh.json @@ -0,0 +1,6 @@ +{ + "meta": { + "title": "Qoder Cloud Agents 云端模式", + "description": "新会话打开云端模式,任务在 Qoder Cloud Agents 沙箱里执行、可连续追问,改动推送到新分支;也可作为子代理工具委派单个任务。" + } +} diff --git a/demos/dsh-qoder-cloud-agents/package-lock.json b/demos/dsh-qoder-cloud-agents/package-lock.json new file mode 100644 index 0000000..19c3a0e --- /dev/null +++ b/demos/dsh-qoder-cloud-agents/package-lock.json @@ -0,0 +1,3629 @@ +{ + "name": "dsh-qoder-cloud-agents", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "dsh-qoder-cloud-agents", + "version": "0.1.0", + "license": "Apache-2.0", + "devDependencies": { + "@deepseek-ai/cordis": "4.0.5-alpha.2", + "@deepseek-ai/dsh-agent": "0.2.1-alpha.4", + "@deepseek-ai/dsh-commands": "^0.2.1-alpha.4", + "@deepseek-ai/dsh-credentials": "0.2.1-alpha.4", + "@deepseek-ai/dsh-launch-environment": "0.2.1-alpha.4", + "@deepseek-ai/dsh-llm": "0.2.1-alpha.4", + "@deepseek-ai/dsh-session": "0.2.1-alpha.4", + "@deepseek-ai/dsh-session-projection": "0.2.1-alpha.4", + "@deepseek-ai/dsh-settings": "^0.2.1-alpha.4", + "@deepseek-ai/dsh-subagent": "0.2.1-alpha.4", + "@deepseek-ai/dsh-tool-subagent": "0.2.1-alpha.4", + "@deepseek-ai/dsh-user-questions": "^0.2.1-alpha.4", + "@deepseek-ai/schemastery": "3.18.5-alpha.2", + "@types/node": "^22.10.0", + "tsdown": "^0.15.0", + "typescript": "^5.9.0", + "vitest": "^3.2.0" + }, + "engines": { + "dsh": ">=0.2.0-0 <0.3.0", + "node": ">=22" + }, + "peerDependencies": { + "@deepseek-ai/cordis": ">=4.0.0-0 <5", + "@deepseek-ai/dsh-credentials": ">=0.2.0-0 <0.3.0", + "@deepseek-ai/dsh-launch-environment": ">=0.2.0-0 <0.3.0", + "@deepseek-ai/dsh-llm": ">=0.2.0-0 <0.3.0", + "@deepseek-ai/dsh-subagent": ">=0.2.0-0 <0.3.0", + "@deepseek-ai/dsh-tool-subagent": ">=0.2.0-0 <0.3.0", + "@deepseek-ai/schemastery": ">=3.18.0-0 <4" + } + }, + "node_modules/@babel/generator": { + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.8.tgz", + "integrity": "sha512-gZbepsdh3WDtgZKWL+vTPh71LSBrm/Y4/QDZBVCcYfmeTEEuoOYwlSy+G1StfJg+/Zy550u/3TATbm7qDbbMtg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.8", + "@babel/types": "^7.29.8", + "@jridgewell/gen-mapping": "^0.3.12", + "@jridgewell/trace-mapping": "^0.3.28", + "jsesc": "^3.0.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz", + "integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", + "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.29.9", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.9.tgz", + "integrity": "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.8" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.8.tgz", + "integrity": "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@deepseek-ai/cordis": { + "version": "4.0.5-alpha.2", + "resolved": "https://registry.npmjs.org/@deepseek-ai/cordis/-/cordis-4.0.5-alpha.2.tgz", + "integrity": "sha512-rd5Qp6PNrMk+0saWVMLUaVv08s/WBwf2TXM84ST6tppFqlHS0Yl9l/NwPrA4oVOuS/1BKCYOGlZ6zJRj+JG6IQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@deepseek-ai/cosmokit": "~1.8.6-alpha.2", + "@standard-schema/spec": "^1.1.0" + }, + "bin": { + "cordis": "bin.js" + }, + "peerDependencies": { + "@deepseek-ai/cordis-plugin-include": "~1.0.10-alpha.2", + "@deepseek-ai/cordis-plugin-loader": "~1.0.6-alpha.2" + }, + "peerDependenciesMeta": { + "@deepseek-ai/cordis-plugin-include": { + "optional": true + }, + "@deepseek-ai/cordis-plugin-loader": { + "optional": true + } + } + }, + "node_modules/@deepseek-ai/cosmokit": { + "version": "1.8.6", + "resolved": "https://registry.npmjs.org/@deepseek-ai/cosmokit/-/cosmokit-1.8.6.tgz", + "integrity": "sha512-ZSD/fN52L498LBIOYwjIOlaLv5veY6ZEwI2yzvZUKQtctn0QAPqu8tKdJ+OF5+Tv6NBq1U+wJWH+QI6OGy5EvQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@deepseek-ai/dsh-agent": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-agent/-/dsh-agent-0.2.1-alpha.4.tgz", + "integrity": "sha512-QIL78OhM5csPWkrdGfhUJQr3zdyUd/DZyM4euwUnkMS0BA5Hp21hCWg7N69HY73bqvV20oyU10g5huPtqJHSyQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2", + "@deepseek-ai/dsh-llm": "0.2.1-alpha.4", + "@deepseek-ai/dsh-scope": "0.2.1-alpha.4", + "@deepseek-ai/dsh-session": "0.2.1-alpha.4", + "@deepseek-ai/dsh-session-projection": "0.2.1-alpha.4", + "@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.4", + "@deepseek-ai/dsh-typert-protocol": "0.2.1-alpha.4", + "@deepseek-ai/dsh-util-values": "0.2.1-alpha.4", + "@deepseek-ai/dsh-workspace": "0.2.1-alpha.4" + }, + "peerDependenciesMeta": { + "@deepseek-ai/dsh-workspace": { + "optional": true + } + } + }, + "node_modules/@deepseek-ai/dsh-atomic-write": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-atomic-write/-/dsh-atomic-write-0.2.1-alpha.4.tgz", + "integrity": "sha512-30X62iB9m6OzezsDCmFvbO8+DrEfa6ql66hAM4E48UEZqgJAFJJ+g2FuQkVwjZYtqlHmMrgcuTuvjU+J7tWkaA==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2" + } + }, + "node_modules/@deepseek-ai/dsh-attachment": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-attachment/-/dsh-attachment-0.2.1-alpha.4.tgz", + "integrity": "sha512-pOpFhwxV0V/j2qrP6IFj5cQDuDDx8FWlbcdOjQytxk9YCYtxdRFm4G1CnlbCccXgxEkMaagRcrBwSUYKZv8hAw==", + "dev": true, + "license": "MIT", + "peer": true, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2", + "@deepseek-ai/dsh-brand": "0.2.1-alpha.4" + } + }, + "node_modules/@deepseek-ai/dsh-brand": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-brand/-/dsh-brand-0.2.1-alpha.4.tgz", + "integrity": "sha512-SlrYMisnHPNREhc9jsohRylcZmpQPuzcul7DxUCJNjK08fDUUuzcyrQI7uDjvbw1n34IwYHNNV6o4mrhIIForQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2" + } + }, + "node_modules/@deepseek-ai/dsh-chunked-list": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-chunked-list/-/dsh-chunked-list-0.2.1-alpha.4.tgz", + "integrity": "sha512-IUpKLZkI7DP4yEaSqyMVAA+OWkFjZ7Wz8J6QczhR99WgSGAytS+9lXZ038KSi6QHviy+cB5H7QhWxDD5d8ad0g==", + "dev": true, + "license": "MIT", + "dependencies": { + "zod": "4.4.3" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2" + } + }, + "node_modules/@deepseek-ai/dsh-commands": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-commands/-/dsh-commands-0.2.1-alpha.4.tgz", + "integrity": "sha512-Dktpl2mKIwYkvO94VSy5Y26Vf4s25xIaJCcbKKSJPi2cpkZCkhJE8E2TYqsPjlQqFuXL9pT6iZiQuyxSmbu5FQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@deepseek-ai/dsh-util-crypto": "0.2.1-alpha.4", + "zod": "4.4.3" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2", + "@deepseek-ai/dsh-agent": "0.2.1-alpha.4", + "@deepseek-ai/dsh-attachment": "0.2.1-alpha.4", + "@deepseek-ai/dsh-brand": "0.2.1-alpha.4", + "@deepseek-ai/dsh-llm": "0.2.1-alpha.4", + "@deepseek-ai/dsh-scope": "0.2.1-alpha.4", + "@deepseek-ai/dsh-session": "0.2.1-alpha.4", + "@deepseek-ai/dsh-typert-protocol": "0.2.1-alpha.4" + } + }, + "node_modules/@deepseek-ai/dsh-credentials": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-credentials/-/dsh-credentials-0.2.1-alpha.4.tgz", + "integrity": "sha512-ZBPM6EOUQjw7QP7N/Sc6Kr5q6nXevWRXJvWDa0561zNvjLYta9c0a+S2XehnCrDQpkiiivFtJHvcVNo6QBpqSQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@deepseek-ai/dsh-brand": "0.2.1-alpha.4" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2" + } + }, + "node_modules/@deepseek-ai/dsh-fs": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-fs/-/dsh-fs-0.2.1-alpha.4.tgz", + "integrity": "sha512-K5TK7QxC3fRM8s1Uvfy1O3C4kaybSXOLGFMSb9WLwfTe1QGsq7JZN0v8jmiv3VFA0cFUkTPybz/PokyDtRWvRg==", + "dev": true, + "license": "MIT", + "peer": true, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2", + "@deepseek-ai/dsh-brand": "0.2.1-alpha.4", + "@deepseek-ai/dsh-llm": "0.2.1-alpha.4", + "@deepseek-ai/dsh-sandbox": "0.2.1-alpha.4" + } + }, + "node_modules/@deepseek-ai/dsh-home-paths": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-home-paths/-/dsh-home-paths-0.2.1-alpha.4.tgz", + "integrity": "sha512-Cz4UnzrPrMHdnkjmN6w2AmphjC4U835FdOSkWOc7QqYZo6UF38cXcCtdd4c3wooaX8uyBPdDwoeeS7V+R9r82w==", + "dev": true, + "license": "MIT", + "peer": true, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2" + } + }, + "node_modules/@deepseek-ai/dsh-launch-environment": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-launch-environment/-/dsh-launch-environment-0.2.1-alpha.4.tgz", + "integrity": "sha512-heCKrGQ504Z52p/cf7TYi0rEOf+CwUzYvs1A+H6vLDPeZFd4/WVjK6T9dWTDzk8t7YiGlsb3xJvi8ULlbO6FGA==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2" + } + }, + "node_modules/@deepseek-ai/dsh-llm": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-llm/-/dsh-llm-0.2.1-alpha.4.tgz", + "integrity": "sha512-rjAT6x0iNUNLgCC3pCNaQxrtQxlcMAAdCh8x27C4PiGCXMaa7kNge8HnjPC3iaZoopSrr5XRBLcyIFmg46Cc+A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@deepseek-ai/dsh-brand": "0.2.1-alpha.4", + "@deepseek-ai/dsh-timeout": "0.2.1-alpha.4", + "@deepseek-ai/dsh-typert-protocol": "0.2.1-alpha.4", + "@deepseek-ai/dsh-util-crypto": "0.2.1-alpha.4", + "@deepseek-ai/dsh-util-values": "0.2.1-alpha.4", + "@deepseek-ai/schemastery": "~3.18.5-alpha.2", + "zod": "4.4.3" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2" + } + }, + "node_modules/@deepseek-ai/dsh-package-manifest": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-package-manifest/-/dsh-package-manifest-0.2.1-alpha.4.tgz", + "integrity": "sha512-LfzK3ayYzbLiVgn6snsGRUZ5jqhWbmmxSTnpT9t84pSJwDGUVTzg7nw2jN6gW60raHcNdY1wDJ0d/SWTNNEKOQ==", + "dev": true, + "license": "MIT", + "peer": true, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2" + } + }, + "node_modules/@deepseek-ai/dsh-ptc-runtime": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-ptc-runtime/-/dsh-ptc-runtime-0.2.1-alpha.4.tgz", + "integrity": "sha512-r+4GYR1UYbr0zyuu9tOO+iJuQvxYjtCJyTHr6YR9UZNJrfbwkrSeqlRIbR1cw5NaIh7dplZK1+a90FHURkrgWA==", + "dev": true, + "license": "MIT", + "peer": true, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2", + "@deepseek-ai/dsh-sandbox": "0.2.1-alpha.4" + } + }, + "node_modules/@deepseek-ai/dsh-sandbox": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-sandbox/-/dsh-sandbox-0.2.1-alpha.4.tgz", + "integrity": "sha512-PRCb2xDAvX609LagauDjLvYFmzYLBO3QYAYXcc7btfiqOdgfeDb7FgstzKjdbz2o31iVdvKUdDK1iFzXjVg6eg==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@deepseek-ai/dsh-util-values": "0.2.1-alpha.4" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2", + "@deepseek-ai/dsh-llm": "0.2.1-alpha.4", + "@deepseek-ai/dsh-session": "0.2.1-alpha.4" + } + }, + "node_modules/@deepseek-ai/dsh-sandbox-policy": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-sandbox-policy/-/dsh-sandbox-policy-0.2.1-alpha.4.tgz", + "integrity": "sha512-xEfAiquD87cg1aOzdPtFoB82e0P4hzWkVEimwRk1s85ESb8YiV+DRzWLrIGprfi9fKhsxSFFIFnCKgzOKjURuA==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@deepseek-ai/schemastery": "~3.18.5-alpha.2", + "zod": "4.4.3" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2", + "@deepseek-ai/dsh-agent": "0.2.1-alpha.4", + "@deepseek-ai/dsh-sandbox": "0.2.1-alpha.4", + "@deepseek-ai/dsh-session": "0.2.1-alpha.4", + "@deepseek-ai/dsh-session-projection": "0.2.1-alpha.4", + "@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.4" + } + }, + "node_modules/@deepseek-ai/dsh-scope": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-scope/-/dsh-scope-0.2.1-alpha.4.tgz", + "integrity": "sha512-oo1AraYsu5D3oYGdKim43HGg0Hf6NbYLmV5LZO8jiDnaXiE+xfNDqI8ARwq049lODJMxP0ONX2hTo5DTG5zjuQ==", + "dev": true, + "license": "MIT", + "peer": true, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2" + } + }, + "node_modules/@deepseek-ai/dsh-session": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-session/-/dsh-session-0.2.1-alpha.4.tgz", + "integrity": "sha512-YMdG+ZdvM+jXFDkfzO+ksCn6YpUFuoN4YuMEIcbSqLnwNo0Q7ba0GJWJEH7oP5v0sCwGtMKQySKSgqBjkUyw+w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@deepseek-ai/dsh-brand": "0.2.1-alpha.4", + "@deepseek-ai/dsh-llm": "0.2.1-alpha.4", + "@deepseek-ai/dsh-util-values": "0.2.1-alpha.4" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2", + "@deepseek-ai/dsh-scope": "0.2.1-alpha.4" + } + }, + "node_modules/@deepseek-ai/dsh-session-projection": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-session-projection/-/dsh-session-projection-0.2.1-alpha.4.tgz", + "integrity": "sha512-+Tm9xJd7ETbcLlolf9wx+Nm2z1O0SFqXermWU3GZ7ffQqo+tRKQ2oEa6NhSS5Mw1wVkY0xuxye5RRnVk3gbb4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "zod": "4.4.3" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2", + "@deepseek-ai/dsh-session": "0.2.1-alpha.4" + } + }, + "node_modules/@deepseek-ai/dsh-settings": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-settings/-/dsh-settings-0.2.1-alpha.4.tgz", + "integrity": "sha512-2pKjmfjhC4CgWnr3ZaAzvOEzCkhnUvgYx3MmwxRYYt7VKI3m3ZW8AKM5jVzhi5u585c92+91l4xN4HyU+Jjctg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@deepseek-ai/cordis-plugin-loader": "~1.0.6-alpha.2", + "@deepseek-ai/cosmokit": "~1.8.6-alpha.2", + "@deepseek-ai/dsh-config-editor": "0.2.1-alpha.4", + "@deepseek-ai/dsh-util-values": "0.2.1-alpha.4", + "yaml": "^2.8.1" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2", + "@deepseek-ai/dsh-brand": "0.2.1-alpha.4", + "@deepseek-ai/dsh-session": "0.2.1-alpha.4", + "@deepseek-ai/schemastery": "~3.18.5-alpha.2" + } + }, + "node_modules/@deepseek-ai/dsh-settings/node_modules/@deepseek-ai/cordis-plugin-group": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@deepseek-ai/cordis-plugin-group/-/cordis-plugin-group-1.0.5.tgz", + "integrity": "sha512-PGYqImAydmAjmy5fl1Js6qDmk0Ivt1fipa3fOj1KyyRd0tZ9i61a2rhzHc7LaSeBb/spJ1LF4k3Pcppaq+w8fw==", + "dev": true, + "license": "MIT", + "peer": true, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5", + "@deepseek-ai/cordis-plugin-loader": "~1.0.6" + } + }, + "node_modules/@deepseek-ai/dsh-settings/node_modules/@deepseek-ai/cordis-plugin-include": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@deepseek-ai/cordis-plugin-include/-/cordis-plugin-include-1.0.10.tgz", + "integrity": "sha512-Rdo6Uqf9WfDbfN3dsYkYj/EW+SGuWCSfthz1PoOtZYUr6qrRpqD7ND4Gj3nUYj8XhSGIo8E3xpsck6J5nM5BYQ==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@deepseek-ai/cosmokit": "~1.8.6", + "js-yaml": "^4.1.0" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5", + "@deepseek-ai/cordis-plugin-loader": "~1.0.6" + } + }, + "node_modules/@deepseek-ai/dsh-settings/node_modules/@deepseek-ai/cordis-plugin-loader": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@deepseek-ai/cordis-plugin-loader/-/cordis-plugin-loader-1.0.6.tgz", + "integrity": "sha512-fr011A782oEjkJXCY4pePt2qaPpkGvem7Rmst6Rhwgg6icgwI4eN9QBRb6S/q9XOYGVQUdvL0wXUWyNxO8WipA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@deepseek-ai/cosmokit": "~1.8.6", + "@deepseek-ai/schemastery": "~3.18.5" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5", + "node-addon-require-builtin": "^0.1.9" + }, + "peerDependenciesMeta": { + "node-addon-require-builtin": { + "optional": true + } + } + }, + "node_modules/@deepseek-ai/dsh-settings/node_modules/@deepseek-ai/cordis-plugin-loader/node_modules/@deepseek-ai/schemastery": { + "version": "3.18.5", + "resolved": "https://registry.npmjs.org/@deepseek-ai/schemastery/-/schemastery-3.18.5.tgz", + "integrity": "sha512-Mnobvqf9rHsZYv4g5edj5ddxS1oF1kIdSlz0DunUgnY3LWG5F26MqvH3YOOsSaodCgyzJ16OMN9O99/s5Crtdw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@deepseek-ai/cosmokit": "~1.8.6", + "@standard-schema/spec": "^1.1.0" + } + }, + "node_modules/@deepseek-ai/dsh-settings/node_modules/@deepseek-ai/dsh-app-boot": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-app-boot/-/dsh-app-boot-0.2.1-alpha.4.tgz", + "integrity": "sha512-++mxPAgoRHM5UZLs8YZS5U7ouIYgsH8oycLcGUcFxcyU+JqDtPanIX08V6JIf2OiHOOaV4NbJrZCq5pi3z+Upg==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@deepseek-ai/dsh-atomic-write": "0.2.1-alpha.4", + "@deepseek-ai/dsh-package-manifest": "0.2.1-alpha.4", + "@eslint-community/regexpp": "^4.12.2", + "ajv": "^8.20.0", + "js-yaml": "^4.3.2", + "node-addon-require-builtin": "^0.1.9", + "resolve.exports": "^2.0.3", + "semver": "^7.8.5" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2", + "@deepseek-ai/cordis-plugin-group": "~1.0.5-alpha.2", + "@deepseek-ai/cordis-plugin-include": "~1.0.10-alpha.2", + "@deepseek-ai/cordis-plugin-loader": "~1.0.6-alpha.2", + "@deepseek-ai/dsh-home-paths": "0.2.1-alpha.4", + "@deepseek-ai/dsh-launch-environment": "0.2.1-alpha.4" + } + }, + "node_modules/@deepseek-ai/dsh-settings/node_modules/@deepseek-ai/dsh-config-editor": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-config-editor/-/dsh-config-editor-0.2.1-alpha.4.tgz", + "integrity": "sha512-uL/3qnAEMM49bT66sJJ8ncoAL5n14/EHtKXKj53jMM8fjpSfjrxmeYM+bkQyyoX9/PVe6dC9dzBipndQXsuiKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@deepseek-ai/dsh-atomic-write": "0.2.1-alpha.4", + "js-yaml": "^4.3.2", + "yaml": "^2.8.1" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2", + "@deepseek-ai/cordis-plugin-include": "~1.0.10-alpha.2", + "@deepseek-ai/cordis-plugin-loader": "~1.0.6-alpha.2", + "@deepseek-ai/dsh-app-boot": "0.2.1-alpha.4", + "@deepseek-ai/dsh-hmr": "0.2.1-alpha.4" + }, + "peerDependenciesMeta": { + "@deepseek-ai/dsh-hmr": { + "optional": true + } + } + }, + "node_modules/@deepseek-ai/dsh-subagent": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-subagent/-/dsh-subagent-0.2.1-alpha.4.tgz", + "integrity": "sha512-gkTq/tyTOoN4A80DFJ/5P/kdEzGEDVBFmUnY/nx9OyZ1apTTzv1JCceIJmpuzaDgLPzV9JfS1t6SSErbw450og==", + "dev": true, + "license": "MIT", + "dependencies": { + "@deepseek-ai/dsh-brand": "0.2.1-alpha.4", + "@deepseek-ai/dsh-chunked-list": "0.2.1-alpha.4", + "@deepseek-ai/dsh-util-values": "0.2.1-alpha.4", + "@deepseek-ai/schemastery": "~3.18.5-alpha.2", + "zod": "4.4.3" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2", + "@deepseek-ai/dsh-agent": "0.2.1-alpha.4", + "@deepseek-ai/dsh-agent-preset-registry": "0.2.1-alpha.4", + "@deepseek-ai/dsh-attachment": "0.2.1-alpha.4", + "@deepseek-ai/dsh-llm": "0.2.1-alpha.4", + "@deepseek-ai/dsh-permission-presets": "0.2.1-alpha.4", + "@deepseek-ai/dsh-sandbox": "0.2.1-alpha.4", + "@deepseek-ai/dsh-sandbox-policy": "0.2.1-alpha.4", + "@deepseek-ai/dsh-scope": "0.2.1-alpha.4", + "@deepseek-ai/dsh-session": "0.2.1-alpha.4", + "@deepseek-ai/dsh-session-persistence": "0.2.1-alpha.4", + "@deepseek-ai/dsh-session-projection": "0.2.1-alpha.4", + "@deepseek-ai/dsh-session-query": "0.2.1-alpha.4", + "@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.4", + "@deepseek-ai/dsh-tools": "0.2.1-alpha.4", + "@deepseek-ai/dsh-typert-protocol": "0.2.1-alpha.4", + "@deepseek-ai/dsh-user-approval": "0.2.1-alpha.4", + "@deepseek-ai/dsh-util-time": "0.2.1-alpha.4", + "@deepseek-ai/dsh-working-directory": "0.2.1-alpha.4", + "@deepseek-ai/dsh-workspace": "0.2.1-alpha.4" + }, + "peerDependenciesMeta": { + "@deepseek-ai/dsh-agent-preset-registry": { + "optional": true + }, + "@deepseek-ai/dsh-permission-presets": { + "optional": true + }, + "@deepseek-ai/dsh-sandbox": { + "optional": true + }, + "@deepseek-ai/dsh-sandbox-policy": { + "optional": true + }, + "@deepseek-ai/dsh-session-persistence": { + "optional": true + }, + "@deepseek-ai/dsh-session-projection": { + "optional": true + }, + "@deepseek-ai/dsh-session-query": { + "optional": true + }, + "@deepseek-ai/dsh-user-approval": { + "optional": true + }, + "@deepseek-ai/dsh-workspace": { + "optional": true + } + } + }, + "node_modules/@deepseek-ai/dsh-system-prompt": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-system-prompt/-/dsh-system-prompt-0.2.1-alpha.4.tgz", + "integrity": "sha512-oHk8b0F2ecwrcN58ZtkMkR8FIRTULNSMTkHB1KbOz1LpTYuD6M01VFhWG0FvzZw01xPeuDlbO9wNmYtYi6/RsA==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@deepseek-ai/schemastery": "~3.18.5-alpha.2" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2", + "@deepseek-ai/dsh-llm": "0.2.1-alpha.4", + "@deepseek-ai/dsh-scope": "0.2.1-alpha.4" + } + }, + "node_modules/@deepseek-ai/dsh-timeout": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-timeout/-/dsh-timeout-0.2.1-alpha.4.tgz", + "integrity": "sha512-hXCp1YWwDZAaTrNNon3ypb/Z6ZgDNKi/3zdC2JLHb9gU2f7DdSexbvRs37xKfyXO8HhtXDKvp/FUCWvI6rpRlg==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2" + } + }, + "node_modules/@deepseek-ai/dsh-tool-subagent": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-tool-subagent/-/dsh-tool-subagent-0.2.1-alpha.4.tgz", + "integrity": "sha512-bimQl0T5/GgBBKRfI73Qikwe4vNP/Y7fmfVtJr/3fCnxdSlKuQee8PbrrHCzPqzRPwMU2GKQt00Bs+VNlPWzOA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@deepseek-ai/schemastery": "~3.18.5-alpha.2", + "zod": "4.4.3" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2", + "@deepseek-ai/dsh-agent": "0.2.1-alpha.4", + "@deepseek-ai/dsh-agent-preset-registry": "0.2.1-alpha.4", + "@deepseek-ai/dsh-llm": "0.2.1-alpha.4", + "@deepseek-ai/dsh-scope": "0.2.1-alpha.4", + "@deepseek-ai/dsh-session": "0.2.1-alpha.4", + "@deepseek-ai/dsh-session-projection": "0.2.1-alpha.4", + "@deepseek-ai/dsh-subagent": "0.2.1-alpha.4", + "@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.4", + "@deepseek-ai/dsh-tools": "0.2.1-alpha.4" + }, + "peerDependenciesMeta": { + "@deepseek-ai/dsh-agent-preset-registry": { + "optional": true + } + } + }, + "node_modules/@deepseek-ai/dsh-tools": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-tools/-/dsh-tools-0.2.1-alpha.4.tgz", + "integrity": "sha512-oTurHJ91LmlirKbEMyU0K+ES8LYtfJW4MAGrLjSBSaRKrq8eERTWNJafcxlhEKNpTWeUNU7h3OHaX/rqcMmLyA==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@deepseek-ai/dsh-brand": "0.2.1-alpha.4", + "@deepseek-ai/dsh-util-values": "0.2.1-alpha.4", + "@deepseek-ai/schemastery": "~3.18.5-alpha.2" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2", + "@deepseek-ai/dsh-agent": "0.2.1-alpha.4", + "@deepseek-ai/dsh-llm": "0.2.1-alpha.4", + "@deepseek-ai/dsh-ptc-runtime": "0.2.1-alpha.4", + "@deepseek-ai/dsh-sandbox": "0.2.1-alpha.4", + "@deepseek-ai/dsh-sandbox-policy": "0.2.1-alpha.4", + "@deepseek-ai/dsh-scope": "0.2.1-alpha.4", + "@deepseek-ai/dsh-session": "0.2.1-alpha.4", + "@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.4", + "@deepseek-ai/dsh-user-approval": "0.2.1-alpha.4", + "@deepseek-ai/dsh-working-directory": "0.2.1-alpha.4" + } + }, + "node_modules/@deepseek-ai/dsh-typert-protocol": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-typert-protocol/-/dsh-typert-protocol-0.2.1-alpha.4.tgz", + "integrity": "sha512-LBNUgiwbRqhyRNPvaAca++eLAxJ1jmmFJnd3RJAa8pT+oULJgZvqPgr9jVnTfX/P5pQT0p7AMZeelTc7QpQ/OA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@deepseek-ai/dsh-brand": "0.2.1-alpha.4", + "zod": "^4.4.3" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2" + } + }, + "node_modules/@deepseek-ai/dsh-user-approval": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-user-approval/-/dsh-user-approval-0.2.1-alpha.4.tgz", + "integrity": "sha512-J6bcZV3rFuQiRDuMej5S/DalSeztfVIFngoGA15M31khb0E74kfrgWUIxvS7pRwy2j1MKz89wR8BbbDzufHTRw==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@deepseek-ai/schemastery": "~3.18.5-alpha.2" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2", + "@deepseek-ai/dsh-agent": "0.2.1-alpha.4", + "@deepseek-ai/dsh-brand": "0.2.1-alpha.4", + "@deepseek-ai/dsh-llm": "0.2.1-alpha.4", + "@deepseek-ai/dsh-scope": "0.2.1-alpha.4", + "@deepseek-ai/dsh-session": "0.2.1-alpha.4", + "@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.4" + } + }, + "node_modules/@deepseek-ai/dsh-user-questions": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-user-questions/-/dsh-user-questions-0.2.1-alpha.4.tgz", + "integrity": "sha512-xcSshuTGcRobEnF4ekzQiwZek8wF/szv24rrm0je2H240/vABESiXmPfr87oadX7m9uZ1RTGpxmCxKJegLFfvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@deepseek-ai/schemastery": "~3.18.5-alpha.2", + "zod": "4.4.3" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2", + "@deepseek-ai/dsh-agent": "0.2.1-alpha.4", + "@deepseek-ai/dsh-llm": "0.2.1-alpha.4", + "@deepseek-ai/dsh-scope": "0.2.1-alpha.4", + "@deepseek-ai/dsh-session": "0.2.1-alpha.4", + "@deepseek-ai/dsh-session-projection": "0.2.1-alpha.4", + "@deepseek-ai/dsh-typert-protocol": "0.2.1-alpha.4" + } + }, + "node_modules/@deepseek-ai/dsh-util-crypto": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-util-crypto/-/dsh-util-crypto-0.2.1-alpha.4.tgz", + "integrity": "sha512-BLMlmD3y+HhTZPGij4viPRFWx8DNdsPNMauUW5XxyE2Iq5KG9ohQ+6xULju/J2Ah9JldVr3XAku7ItDPDk8Mpg==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2" + } + }, + "node_modules/@deepseek-ai/dsh-util-time": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-util-time/-/dsh-util-time-0.2.1-alpha.4.tgz", + "integrity": "sha512-omwQNx42tX5Sv2rRol6fFsc9QACD9lYqqAns5TsxhiXy6qarThN1YCAjyxn+2iMh3XnKgxbQSPBldu/gEPGazg==", + "dev": true, + "license": "MIT", + "peer": true, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2" + } + }, + "node_modules/@deepseek-ai/dsh-util-values": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-util-values/-/dsh-util-values-0.2.1-alpha.4.tgz", + "integrity": "sha512-RM3gAmdyUsldAb4AIsU++KYbBY98UvHRCskcHX2bojZ6kefGd1a8P1Yl/Fo+bUWIAHZj/VoA1pnAl7r5e5456A==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2" + } + }, + "node_modules/@deepseek-ai/dsh-working-directory": { + "version": "0.2.1-alpha.4", + "resolved": "https://registry.npmjs.org/@deepseek-ai/dsh-working-directory/-/dsh-working-directory-0.2.1-alpha.4.tgz", + "integrity": "sha512-VtgMMlvYJ4iOPtpasI+ey6ioBekJy5MLSw3ky6lvLdLnKPmj0zobVOFhldr7KEvZFRizKYN5ktU8D85qKZG9Cg==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@deepseek-ai/schemastery": "~3.18.5-alpha.2", + "zod": "^4.4.3" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "~4.0.5-alpha.2", + "@deepseek-ai/dsh-agent": "0.2.1-alpha.4", + "@deepseek-ai/dsh-fs": "0.2.1-alpha.4", + "@deepseek-ai/dsh-llm": "0.2.1-alpha.4", + "@deepseek-ai/dsh-session": "0.2.1-alpha.4", + "@deepseek-ai/dsh-session-projection": "0.2.1-alpha.4", + "@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.4" + } + }, + "node_modules/@deepseek-ai/schemastery": { + "version": "3.18.5-alpha.2", + "resolved": "https://registry.npmjs.org/@deepseek-ai/schemastery/-/schemastery-3.18.5-alpha.2.tgz", + "integrity": "sha512-W+2TSjdeKOEKqaii9BNpw7ev2Yf8C+J74i/BE/VBx56O7BX0zxV2zQKwRY4ADLTXD5O69iJ+/Skm91/ES7iMgw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@deepseek-ai/cosmokit": "~1.8.6-alpha.2", + "@standard-schema/spec": "^1.1.0" + } + }, + "node_modules/@emnapi/core": { + "version": "1.11.3", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.11.3.tgz", + "integrity": "sha512-zLpS5asjEb7lq8jYLq37N6XKaE41DIexlY1rF/z4/tIl3wo13Sqm28fRyfIsKZD+NZ8mM5RoKkpW/rBcuoSZSg==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "@emnapi/wasi-threads": "1.2.3", + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/runtime": { + "version": "1.11.3", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz", + "integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/wasi-threads": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.3.tgz", + "integrity": "sha512-ELEBe8PsLvvJ6QMr0zLt8ffvOHW/dc1m3CEzNMg7aJUv3bMaoDtw2TXyDAwkYBuroxxuHEwhRTLJSe5sya547g==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz", + "integrity": "sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.2.tgz", + "integrity": "sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.2.tgz", + "integrity": "sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.2.tgz", + "integrity": "sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.2.tgz", + "integrity": "sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.2.tgz", + "integrity": "sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.2.tgz", + "integrity": "sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.2.tgz", + "integrity": "sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.2.tgz", + "integrity": "sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.2.tgz", + "integrity": "sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.2.tgz", + "integrity": "sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.2.tgz", + "integrity": "sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.2.tgz", + "integrity": "sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.2.tgz", + "integrity": "sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.2.tgz", + "integrity": "sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.2.tgz", + "integrity": "sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.2.tgz", + "integrity": "sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.2.tgz", + "integrity": "sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.2.tgz", + "integrity": "sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.2.tgz", + "integrity": "sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.2.tgz", + "integrity": "sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.2.tgz", + "integrity": "sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.2.tgz", + "integrity": "sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.2.tgz", + "integrity": "sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.2.tgz", + "integrity": "sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.2.tgz", + "integrity": "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.12.2", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.2.tgz", + "integrity": "sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@napi-rs/lzma-linux-x64-gnu": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-linux-x64-gnu/-/lzma-linux-x64-gnu-1.5.1.tgz", + "integrity": "sha512-oTXEIha4SsuXdTA4Iyskj0kpdx2yVXdhd75c2v3xGrHFfVMsbhTPZU/nMPL4sWKo4pBHm3aucLaqGlF696dTyQ==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^22.20 || ^24.12 || >=25" + } + }, + "node_modules/@napi-rs/wasm-runtime": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.2.5.tgz", + "integrity": "sha512-HshSvXzmBxNzqejd3k/KemgQ3hdREUYFRRrgxOZ+gPljDIsO2SDZrVZMd4Z/HsxudQbE62OVyVFE8z9BCurfjA==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@tybys/wasm-util": "^0.10.3" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=23.5.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + }, + "peerDependencies": { + "@emnapi/core": "^1.7.1 || ^2.0.0-alpha.4", + "@emnapi/runtime": "^1.7.1 || ^2.0.0-alpha.4" + } + }, + "node_modules/@oxc-project/types": { + "version": "0.95.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.95.0.tgz", + "integrity": "sha512-vACy7vhpMPhjEJhULNxrdR0D943TkA/MigMpJCHmBHvMXxRStRi/dPtTlfQ3uDwWSzRpT8z+7ImjZVf8JWBocQ==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/Boshen" + } + }, + "node_modules/@quansync/fs": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@quansync/fs/-/fs-1.1.0.tgz", + "integrity": "sha512-qAPG/t3HqML1TlN7sY/pTbEjzFVAKsMjNNMGheyDosro+kT4iw2KCUoHcVdmliwWjorm4elZbgNQyU2eD97eDg==", + "dev": true, + "license": "MIT", + "dependencies": { + "quansync": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sxzz" + } + }, + "node_modules/@rolldown/binding-android-arm64": { + "version": "1.0.0-beta.45", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.0.0-beta.45.tgz", + "integrity": "sha512-bfgKYhFiXJALeA/riil908+2vlyWGdwa7Ju5S+JgWZYdR4jtiPOGdM6WLfso1dojCh+4ZWeiTwPeV9IKQEX+4g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-arm64": { + "version": "1.0.0-beta.45", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.0.0-beta.45.tgz", + "integrity": "sha512-xjCv4CRVsSnnIxTuyH1RDJl5OEQ1c9JYOwfDAHddjJDxCw46ZX9q80+xq7Eok7KC4bRSZudMJllkvOKv0T9SeA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-x64": { + "version": "1.0.0-beta.45", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.0.0-beta.45.tgz", + "integrity": "sha512-ddcO9TD3D/CLUa/l8GO8LHzBOaZqWg5ClMy3jICoxwCuoz47h9dtqPsIeTiB6yR501LQTeDsjA4lIFd7u3Ljfw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-freebsd-x64": { + "version": "1.0.0-beta.45", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.0.0-beta.45.tgz", + "integrity": "sha512-MBTWdrzW9w+UMYDUvnEuh0pQvLENkl2Sis15fHTfHVW7ClbGuez+RWopZudIDEGkpZXdeI4CkRXk+vdIIebrmg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm-gnueabihf": { + "version": "1.0.0-beta.45", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.0.0-beta.45.tgz", + "integrity": "sha512-4YgoCFiki1HR6oSg+GxxfzfnVCesQxLF1LEnw9uXS/MpBmuog0EOO2rYfy69rWP4tFZL9IWp6KEfGZLrZ7aUog==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-gnu": { + "version": "1.0.0-beta.45", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.0.0-beta.45.tgz", + "integrity": "sha512-LE1gjAwQRrbCOorJJ7LFr10s5vqYf5a00V5Ea9wXcT2+56n5YosJkcp8eQ12FxRBv2YX8dsdQJb+ZTtYJwb6XQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-musl": { + "version": "1.0.0-beta.45", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.0.0-beta.45.tgz", + "integrity": "sha512-tdy8ThO/fPp40B81v0YK3QC+KODOmzJzSUOO37DinQxzlTJ026gqUSOM8tzlVixRbQJltgVDCTYF8HNPRErQTA==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-gnu": { + "version": "1.0.0-beta.45", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.0.0-beta.45.tgz", + "integrity": "sha512-lS082ROBWdmOyVY/0YB3JmsiClaWoxvC+dA8/rbhyB9VLkvVEaihLEOr4CYmrMse151C4+S6hCw6oa1iewox7g==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-musl": { + "version": "1.0.0-beta.45", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.0.0-beta.45.tgz", + "integrity": "sha512-Hi73aYY0cBkr1/SvNQqH8Cd+rSV6S9RB5izCv0ySBcRnd/Wfn5plguUoGYwBnhHgFbh6cPw9m2dUVBR6BG1gxA==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-openharmony-arm64": { + "version": "1.0.0-beta.45", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.0.0-beta.45.tgz", + "integrity": "sha512-fljEqbO7RHHogNDxYtTzr+GNjlfOx21RUyGmF+NrkebZ8emYYiIqzPxsaMZuRx0rgZmVmliOzEp86/CQFDKhJQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-wasm32-wasi": { + "version": "1.0.0-beta.45", + "resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.0.0-beta.45.tgz", + "integrity": "sha512-ZJDB7lkuZE9XUnWQSYrBObZxczut+8FZ5pdanm8nNS1DAo8zsrPuvGwn+U3fwU98WaiFsNrA4XHngesCGr8tEQ==", + "cpu": [ + "wasm32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@napi-rs/wasm-runtime": "^1.0.7" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/@rolldown/binding-win32-arm64-msvc": { + "version": "1.0.0-beta.45", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.0.0-beta.45.tgz", + "integrity": "sha512-zyzAjItHPUmxg6Z8SyRhLdXlJn3/D9KL5b9mObUrBHhWS/GwRH4665xCiFqeuktAhhWutqfc+rOV2LjK4VYQGQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-ia32-msvc": { + "version": "1.0.0-beta.45", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-1.0.0-beta.45.tgz", + "integrity": "sha512-wODcGzlfxqS6D7BR0srkJk3drPwXYLu7jPHN27ce2c4PUnVVmJnp9mJzUQGT4LpmHmmVdMZ+P6hKvyTGBzc1CA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-x64-msvc": { + "version": "1.0.0-beta.45", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.0.0-beta.45.tgz", + "integrity": "sha512-wiU40G1nQo9rtfvF9jLbl79lUgjfaD/LTyUEw2Wg/gdF5OhjzpKMVugZQngO+RNdwYaNj+Fs+kWBWfp4VXPMHA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/pluginutils": { + "version": "1.0.0-beta.45", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.45.tgz", + "integrity": "sha512-Le9ulGCrD8ggInzWw/k2J8QcbPz7eGIOWqfJ2L+1R0Opm7n6J37s2hiDWlh6LJN0Lk9L5sUzMvRHKW7UxBZsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.64.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.64.7.tgz", + "integrity": "sha512-GFF2tHk0NqYVObrK0+/ps/LEXsV/v2q6Lyiy7mZr+Ej24fpQScvqK2ziz9NHeEQYnKWKym38Ml7dZbPtC9tuAw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.64.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.64.7.tgz", + "integrity": "sha512-BOymcXJFYYXqluDidj6sLelNjXruC3u1BqVxLn2OPCXH9xaPSOTH+MS4uychsGI1NU7tJoiv9KvqijDHFe+hhQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.64.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.64.7.tgz", + "integrity": "sha512-jgVpGweIbls2H5jfBB70tnX52abMd5pJr3xmtoDILx6JdmGl+Un+tMb9R+MbHPVB46tTBpY8emtn7M71SnQhEQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.64.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.64.7.tgz", + "integrity": "sha512-AVMpt94mrXH7WjyWKmd9nT4RC5yM0AN3Lt6A89xVIsuLDi3dDX6dxMytLbW36FlppY9JsoqUoS3LUUpUrYxiMQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.64.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.64.7.tgz", + "integrity": "sha512-Nje29c/MyajxRNFGU05oyeTDS6SWdMg/wWMSlZSBTBju5BKz2NVc0kFiFSQGzRELNiB+CBk/ZvAVsWsENgjGag==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.64.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.64.7.tgz", + "integrity": "sha512-xxgN5/kMzCNz/NYJ4t49B0/WS6InNlWv6xvgwUQqNnWM9WJMMwMUGWrAxdNEgYWdHL0sMnuh8I87StGrIMTA+w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.64.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.64.7.tgz", + "integrity": "sha512-5U/9gVn/X657I8+NHoHO9Wnfyd0lEXwqbslobRoB9TC8SwYzOitcIr6TLE7531Q/NWs3L4mb+YOGzlf3vHIeYw==", + "cpu": [ + "arm" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.64.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.64.7.tgz", + "integrity": "sha512-hcDS0a/Y8ggM3dcOfzH7UpSaogCViWTtNDSl0EXpWIj8g8/r86ITqptjil2hayTXS0Umzb+Yt3mjgpQVFVf2+A==", + "cpu": [ + "arm" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.64.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.64.7.tgz", + "integrity": "sha512-awbAr4N7Qd/yjZAQBEEPzgcPveYG2Gi5L6gq1/Bp+3SMRjn5F68Wv1zKsntzvvoioBR6yKvhLtWqu11am1TsxA==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.64.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.64.7.tgz", + "integrity": "sha512-Ut7xQJfeLhzu2yN3rHzVvL9ccyPJvN4aCdP1V7hJ5lGxX/eCzgB9SiMk/Md3J+rWWZgvoYsDW4BUFggJr32pBA==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.64.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.64.7.tgz", + "integrity": "sha512-trqoni/vHkuM5oo5iQhoKPh6fjjD7E80pMgCXWgGxU8vSRPUlwvG8GeYvEEcB6eJAxNa99WH9iVHPHelgtKiHA==", + "cpu": [ + "loong64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.64.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.64.7.tgz", + "integrity": "sha512-gvlUy0XFIwtUWiQmhc+4GT2Knm3KosinpUVhr7CtTFA78gFDnE5NWwMPzHrJsYpKkh2LlY7yvBIboN1FAV6Xeg==", + "cpu": [ + "loong64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.64.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.64.7.tgz", + "integrity": "sha512-8yS/kSXTJ/47Z62JW+C2AJ3vd/8zZw016vFjtNpZwmZlwJumLua4s1i78dkYuSSqQ+0aIMxJcBp/4uIwp2ehjA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.64.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.64.7.tgz", + "integrity": "sha512-mxVSKvvty0hOP1AFo/l4Kpv3i3HK0zx4rYUrirZDToYlWhS3xzmIkq3vUJ7rtrM2cPyXveDyDT6M1FfXZ9hTRA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.64.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.64.7.tgz", + "integrity": "sha512-lEse1zra1CagM+uHH2bl28GInDsZZ45NJzHei2OMaXQFzZWKBO1hFo07rS0xB6ayV4WU360UrSmPDSyCMpYsUQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.64.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.64.7.tgz", + "integrity": "sha512-d/cqCoiG9WMZ5VuJZ5Qdlv9g97QyoGwnmvHccvGhKSacTy7xFrAS+jMcJSBdMNOw1oacSkl6p7K6O/DRYTKL3g==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.64.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.64.7.tgz", + "integrity": "sha512-kVEA//CeDOZZP1XCH2JBgqXb9+ALlwuA/4civaazMVdgzaSQC9WM38w65zG/LLk0lA7F9Od19CSBZW7J9mCbNg==", + "cpu": [ + "s390x" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.64.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.64.7.tgz", + "integrity": "sha512-14oLfDsOSr0TSntT/34jRg/V8B2XW/Jomh9zX9CjIM9gwwNlI1OCymS/GVn0DV32h67eRf7U0GGem0rvfXgNwQ==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.64.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.64.7.tgz", + "integrity": "sha512-dFVtPfjZqAnUPpPY4Bfg+87yo1IBW9HiY8iCFtg49Pn46MfZTebSHZh8PL6SOsgyt9LQP8Nj/sE6jm3aWpySmQ==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.64.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.64.7.tgz", + "integrity": "sha512-Dm9CZ2SM3u2NgvBj4awW/gGqkOwzH8f6MSYIJE6+bKcKLI+T0+LhpD6vtetTfrIIx+rLXDf5RJqBP6v7V5O+wg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.64.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.64.7.tgz", + "integrity": "sha512-oaxsvS2mL6+78741CT2HCORBvy1USg3Wqpt5qvZwy3aMXRMl4zxyDo8maeFRWJkF3dp0Wbi71fKH5Gr9YI3vYA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.64.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.64.7.tgz", + "integrity": "sha512-UKZz1Y4mxUqkWh60uH7B1aZn6UcAimPk4ipRktpb3wfZq7JrzZYyAXTwiafkb3T+kd5P3Sf+vzcRdsDks4WtjQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.64.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.64.7.tgz", + "integrity": "sha512-WWkSuC1J+mZJnsDh0mRaCAFSWfQdl6y3fDjZeWElI6zHo8CcOSG5lY3yurKJjEq+FrX0WD60sFrVVpbHqzMmrw==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.64.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.64.7.tgz", + "integrity": "sha512-u9bp2yXCI3/BUjUxY6uWknAY32pfvvDCPysyUTySotx0dj3ydlFHrRQYfn/b/kZgnfjyEwySMtI7Ga054uiysQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.64.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.64.7.tgz", + "integrity": "sha512-EhX6N3XPMEnVU5cRfNgzPOKcSucsbu3nNNWuoAaEuKIqmddBKHN5b9d4rPe65T1I+FaOT176JKiZNsUBp3rqbA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@standard-schema/spec": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz", + "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@tybys/wasm-util": { + "version": "0.10.4", + "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.4.tgz", + "integrity": "sha512-W3c4gRigFS0T/Ma4qIYF3GDAc5AQdHb1yL5znJT1Zv1YaD9Kitx656wBjvr19qbiosmZT8lWDM5BEMynUqX65A==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@types/chai": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", + "integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/deep-eql": "*", + "assertion-error": "^2.0.1" + } + }, + "node_modules/@types/deep-eql": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz", + "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/estree": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz", + "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "22.20.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.5.tgz", + "integrity": "sha512-U2+DNr+wSjpsTS/wZGYHq7GcwfuSmKiKvoPvK22zwTlRhU91yOniN4qRR5KhIjvif7ysw/dz/hKmfDH0Ris4aA==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/@vitest/expect": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-3.2.7.tgz", + "integrity": "sha512-E8eBXaKibuvH2pSZErOjdVb5vF4PbKYcrnluBTYxEk1l/VhhwZg1kZQsdtjq+CsF5CFydf2Rdkz7jDHKSisi3w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/chai": "^5.2.2", + "@vitest/spy": "3.2.7", + "@vitest/utils": "3.2.7", + "chai": "^5.2.0", + "tinyrainbow": "^2.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/mocker": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-3.2.7.tgz", + "integrity": "sha512-Trr0hYO9CM3Wj6ksWHRhK9IZpIY6wTMO5u/MqXurMxT57sWBaOPEtP3Oq60ihZuh5JsiagKfz95OcxdEP6dBrA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/spy": "3.2.7", + "estree-walker": "^3.0.3", + "magic-string": "^0.30.17" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "msw": "^2.4.9", + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0" + }, + "peerDependenciesMeta": { + "msw": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "node_modules/@vitest/pretty-format": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-3.2.7.tgz", + "integrity": "sha512-KUHlwqVu0sRlhCdyPdQ/wBoTfRahjUky1MubOmYw9fWfIZy1gNoHpuaaQBPAaMaVYdQYHJLurzj8ECCj5OwTqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyrainbow": "^2.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/runner": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-3.2.7.tgz", + "integrity": "sha512-sB9y4ovltoQP+WaUPwmSxO9WIg9Ig694Di5PalVPsYHklAdE027mehpWF2SQSVq+k6sFgaivbTjTJwZLSHbedA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/utils": "3.2.7", + "pathe": "^2.0.3", + "strip-literal": "^3.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/snapshot": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-3.2.7.tgz", + "integrity": "sha512-7C+MwShwtBSI5Buwoyg3s/iY1eHL9PKAf+O1wVh/TdnjXUtkoL/9YQtre90i4MtNXM6edP1wJ2zOBpfCyhIS7g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "3.2.7", + "magic-string": "^0.30.17", + "pathe": "^2.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/spy": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-3.2.7.tgz", + "integrity": "sha512-Q2eQGI6d2L/hBtZ0qNuKcAGid68XK6cv1xsoaIma6PaJhHPoqcEJhYpXZ/5myCMqkNgtP6UKuBhbc0nHKnrkuQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyspy": "^4.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/utils": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-3.2.7.tgz", + "integrity": "sha512-x6BDOd7dyo3PFLY3I9/HJ25X/6OurhGXk2/B9gOZNPF7XDVjeBK4k01lQE5uvDpbuheErh91qYuE1E2OEjK3Rw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "3.2.7", + "loupe": "^3.1.4", + "tinyrainbow": "^2.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/ajv": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.20.0.tgz", + "integrity": "sha512-Thbli+OlOj+iMPYFBVBfJ3OmCAnaSyNn4M1vz9T6Gka5Jt9ba/HIR56joy65tY6kx/FCF5VXNB819Y7/GUrBGA==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ansis": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/ansis/-/ansis-4.4.0.tgz", + "integrity": "sha512-9k3v7xcHwgdO/DruxGIg4HtjvlAZlcnsX/mzqUb1t3NkYnl9kK2UJ+Gq0io+vQf7iT//BD/HB/NBkUR1LWxoeA==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=14" + } + }, + "node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, + "license": "Python-2.0" + }, + "node_modules/assertion-error": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/ast-kit": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/ast-kit/-/ast-kit-2.2.0.tgz", + "integrity": "sha512-m1Q/RaVOnTp9JxPX+F+Zn7IcLYMzM8kZofDImfsKZd8MbR+ikdOzTeztStWqfrqIxZnYWryyI9ePm3NGjnZgGw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.28.5", + "pathe": "^2.0.3" + }, + "engines": { + "node": ">=20.19.0" + }, + "funding": { + "url": "https://github.com/sponsors/sxzz" + } + }, + "node_modules/birpc": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/birpc/-/birpc-2.9.0.tgz", + "integrity": "sha512-KrayHS5pBi69Xi9JmvoqrIgYGDkD6mcSe/i6YKi3w5kekCLzrX4+nawcXqrj2tIp50Kw/mT/s3p+GVK0A0sKxw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/chai": { + "version": "5.3.3", + "resolved": "https://registry.npmjs.org/chai/-/chai-5.3.3.tgz", + "integrity": "sha512-4zNhdJD/iOjSH0A05ea+Ke6MU5mmpQcbQsSOkgdaUMJ9zTlDTD/GYlwohmIE2u0gaxHYiVHEn1Fw9mZ/ktJWgw==", + "dev": true, + "license": "MIT", + "dependencies": { + "assertion-error": "^2.0.1", + "check-error": "^2.1.1", + "deep-eql": "^5.0.1", + "loupe": "^3.1.0", + "pathval": "^2.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/check-error": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.3.tgz", + "integrity": "sha512-PAJdDJusoxnwm1VwW07VWwUN1sl7smmC3OKggvndJFadxxDRyFJBX/ggnu/KE4kQAB7a3Dp8f/YXC1FlUprWmA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 16" + } + }, + "node_modules/chokidar": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", + "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", + "dev": true, + "license": "MIT", + "dependencies": { + "readdirp": "^4.0.1" + }, + "engines": { + "node": ">= 14.16.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deep-eql": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz", + "integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/defu": { + "version": "6.1.7", + "resolved": "https://registry.npmjs.org/defu/-/defu-6.1.7.tgz", + "integrity": "sha512-7z22QmUWiQ/2d0KkdYmANbRUVABpZ9SNYyH5vx6PZ+nE5bcC0l7uFvEfHlyld/HcGBFTL536ClDt3DEcSlEJAQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/diff": { + "version": "8.0.4", + "resolved": "https://registry.npmjs.org/diff/-/diff-8.0.4.tgz", + "integrity": "sha512-DPi0FmjiSU5EvQV0++GFDOJ9ASQUVFh5kD+OzOnYdi7n3Wpm9hWWGfB/O2blfHcMVTL5WkQXSnRiK9makhrcnw==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/dts-resolver": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/dts-resolver/-/dts-resolver-2.1.3.tgz", + "integrity": "sha512-bihc7jPC90VrosXNzK0LTE2cuLP6jr0Ro8jk+kMugHReJVLIpHz/xadeq3MhuwyO4TD4OA3L1Q8pBBFRc08Tsw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20.19.0" + }, + "funding": { + "url": "https://github.com/sponsors/sxzz" + }, + "peerDependencies": { + "oxc-resolver": ">=11.0.0" + }, + "peerDependenciesMeta": { + "oxc-resolver": { + "optional": true + } + } + }, + "node_modules/empathic": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/empathic/-/empathic-2.1.0.tgz", + "integrity": "sha512-AnfC1ATldl49/cvZdLPDjBfrRNwbDO05aibiOtzQu3qtlbJtomNLhF30HEtn/7iBz50dlMECqATo3fG0LrdEgw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14" + } + }, + "node_modules/es-module-lexer": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz", + "integrity": "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==", + "dev": true, + "license": "MIT" + }, + "node_modules/esbuild": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz", + "integrity": "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.28.2", + "@esbuild/android-arm": "0.28.2", + "@esbuild/android-arm64": "0.28.2", + "@esbuild/android-x64": "0.28.2", + "@esbuild/darwin-arm64": "0.28.2", + "@esbuild/darwin-x64": "0.28.2", + "@esbuild/freebsd-arm64": "0.28.2", + "@esbuild/freebsd-x64": "0.28.2", + "@esbuild/linux-arm": "0.28.2", + "@esbuild/linux-arm64": "0.28.2", + "@esbuild/linux-ia32": "0.28.2", + "@esbuild/linux-loong64": "0.28.2", + "@esbuild/linux-mips64el": "0.28.2", + "@esbuild/linux-ppc64": "0.28.2", + "@esbuild/linux-riscv64": "0.28.2", + "@esbuild/linux-s390x": "0.28.2", + "@esbuild/linux-x64": "0.28.2", + "@esbuild/netbsd-arm64": "0.28.2", + "@esbuild/netbsd-x64": "0.28.2", + "@esbuild/openbsd-arm64": "0.28.2", + "@esbuild/openbsd-x64": "0.28.2", + "@esbuild/openharmony-arm64": "0.28.2", + "@esbuild/sunos-x64": "0.28.2", + "@esbuild/win32-arm64": "0.28.2", + "@esbuild/win32-ia32": "0.28.2", + "@esbuild/win32-x64": "0.28.2" + } + }, + "node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0" + } + }, + "node_modules/expect-type": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.4.0.tgz", + "integrity": "sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, + "license": "MIT", + "peer": true + }, + "node_modules/fast-uri": { + "version": "3.1.8", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.8.tgz", + "integrity": "sha512-GZMtZUTNRpOVIECoXwLNZS5xUGE+mVNbTB8h/7Rwh2TFWcBQiPzTgyZi05BF9UMZKkLJv8XBRJTlU7zg8+ZfMg==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "BSD-3-Clause", + "peer": true + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/get-tsconfig": { + "version": "4.14.3", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.14.3.tgz", + "integrity": "sha512-++QEw4DIY7WGoukz+/+A/8dGYPT9l9yIadnmSgZ8Rjr3YVSVDipQSO9CdnJo9ePqFqUUqh+wk9uIaoiAwsiPkA==", + "dev": true, + "license": "MIT", + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, + "node_modules/hookable": { + "version": "5.5.3", + "resolved": "https://registry.npmjs.org/hookable/-/hookable-5.5.3.tgz", + "integrity": "sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/jiti": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz", + "integrity": "sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==", + "dev": true, + "license": "MIT", + "bin": { + "jiti": "lib/jiti-cli.mjs" + } + }, + "node_modules/js-tokens": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-9.0.1.tgz", + "integrity": "sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/js-yaml": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.2.tgz", + "integrity": "sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/nodeca" + } + ], + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/jsesc": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", + "dev": true, + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true, + "license": "MIT", + "peer": true + }, + "node_modules/loupe": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.2.1.tgz", + "integrity": "sha512-CdzqowRJCeLU72bHvWqwRBBlLcMEtIvGrlvef74kMnV2AolS9Y8xUv1I0U/MNAWMhBlKIoyuEgoJ0t/bbwHbLQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/magic-string": { + "version": "0.30.21", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", + "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/nanoid": { + "version": "3.3.20", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz", + "integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/node-addon-native-custom-loader": { + "version": "0.1.9", + "resolved": "https://registry.npmjs.org/node-addon-native-custom-loader/-/node-addon-native-custom-loader-0.1.9.tgz", + "integrity": "sha512-Zh87aubSc1UF8CzZsRws1KtSwXiPDH0tbcg8V/2OA8Tcq9yGJRESFcEOC5NGLFama5IGfC3aJhubZbrj9Un2qA==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">=20" + } + }, + "node_modules/node-addon-require-builtin": { + "version": "0.1.9", + "resolved": "https://registry.npmjs.org/node-addon-require-builtin/-/node-addon-require-builtin-0.1.9.tgz", + "integrity": "sha512-BCxXCMZDs/VLLh64SwKNw/me7Qx1I7Be4qxWwYVRRm8tJoOB8fL7qg6CmXhSXeUqsKt72t8RaKCX4EN+5nocVg==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "node-addon-native-custom-loader": "0.1.9" + }, + "engines": { + "node": ">=20" + }, + "optionalDependencies": { + "node-addon-require-builtin-darwin-arm64": "0.1.9", + "node-addon-require-builtin-darwin-x64": "0.1.9", + "node-addon-require-builtin-linux-arm64-gnu": "0.1.9", + "node-addon-require-builtin-linux-arm64-musl": "0.1.9", + "node-addon-require-builtin-linux-x64-gnu": "0.1.9", + "node-addon-require-builtin-linux-x64-musl": "0.1.9", + "node-addon-require-builtin-win32-arm64-msvc": "0.1.9", + "node-addon-require-builtin-win32-ia32-msvc": "0.1.9", + "node-addon-require-builtin-win32-x64-msvc": "0.1.9" + } + }, + "node_modules/node-addon-require-builtin-darwin-arm64": { + "version": "0.1.9", + "resolved": "https://registry.npmjs.org/node-addon-require-builtin-darwin-arm64/-/node-addon-require-builtin-darwin-arm64-0.1.9.tgz", + "integrity": "sha512-n45xEILQVOLZ2hVhzRXesTMYS4odHquyI/B/IkPMPUCONa8PjNfBag6lYBH4wDrhgpLNNBwMsUD8d8O/13QPPA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "peer": true, + "dependencies": { + "node-addon-native-custom-loader": "0.1.9" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/node-addon-require-builtin-darwin-x64": { + "version": "0.1.9", + "resolved": "https://registry.npmjs.org/node-addon-require-builtin-darwin-x64/-/node-addon-require-builtin-darwin-x64-0.1.9.tgz", + "integrity": "sha512-Sm4Liqh1uo9zgJB2F/pACPPZdHu+fj9Qniyr1Q99dDQB0v71VgZgkAgv3K0/E1iPQBlZq9rakFkY7MGUIfWc0A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "peer": true, + "dependencies": { + "node-addon-native-custom-loader": "0.1.9" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/node-addon-require-builtin-linux-arm64-gnu": { + "version": "0.1.9", + "resolved": "https://registry.npmjs.org/node-addon-require-builtin-linux-arm64-gnu/-/node-addon-require-builtin-linux-arm64-gnu-0.1.9.tgz", + "integrity": "sha512-ToU4wGtOD/069i2y4fJ3cjDJiiWtcjSQTZMf0YKlotb5BmTM7FjhR3X1aub8J/YjlOwl6665J/XAYuvCaDO5sA==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "dependencies": { + "node-addon-native-custom-loader": "0.1.9" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/node-addon-require-builtin-linux-arm64-musl": { + "version": "0.1.9", + "resolved": "https://registry.npmjs.org/node-addon-require-builtin-linux-arm64-musl/-/node-addon-require-builtin-linux-arm64-musl-0.1.9.tgz", + "integrity": "sha512-85Z5Avp++wfa9iiTIH8LC/r6qvlC/CiwpifiwIz0gYQ9PzajTSkz06gX7YDqf1oUqWYxU9uwNEOmo7mktHOOfA==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "dependencies": { + "node-addon-native-custom-loader": "0.1.9" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/node-addon-require-builtin-linux-x64-gnu": { + "version": "0.1.9", + "resolved": "https://registry.npmjs.org/node-addon-require-builtin-linux-x64-gnu/-/node-addon-require-builtin-linux-x64-gnu-0.1.9.tgz", + "integrity": "sha512-fh3K3/JvBfSYwU8vEOpp4Wdp4N/jX0EnZYq5GsaftlQin1FVqgve/yDNoh+asxBMOQyHOG8F4dXlV1WCierrfg==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "dependencies": { + "node-addon-native-custom-loader": "0.1.9" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/node-addon-require-builtin-linux-x64-musl": { + "version": "0.1.9", + "resolved": "https://registry.npmjs.org/node-addon-require-builtin-linux-x64-musl/-/node-addon-require-builtin-linux-x64-musl-0.1.9.tgz", + "integrity": "sha512-B6fu/5xmbRxnifM7nWz0IESkYnUl8dwFZmRDMsxdhzv2nb+EtBRFAXg4lf73qhX3yoZD4SnWJILBQMlIAwBCzw==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "dependencies": { + "node-addon-native-custom-loader": "0.1.9" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/node-addon-require-builtin-win32-arm64-msvc": { + "version": "0.1.9", + "resolved": "https://registry.npmjs.org/node-addon-require-builtin-win32-arm64-msvc/-/node-addon-require-builtin-win32-arm64-msvc-0.1.9.tgz", + "integrity": "sha512-FOQuzNe8B1BANu886rJgdbQuRxPGUQmewkykw87wSr32U0ibQ3AWGuUM/Gh7LG4RekjFaifj7gEI/tq2+6GU6g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "peer": true, + "dependencies": { + "node-addon-native-custom-loader": "0.1.9" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/node-addon-require-builtin-win32-ia32-msvc": { + "version": "0.1.9", + "resolved": "https://registry.npmjs.org/node-addon-require-builtin-win32-ia32-msvc/-/node-addon-require-builtin-win32-ia32-msvc-0.1.9.tgz", + "integrity": "sha512-N29P0kmIBT6hnkNNFYzxn+o9ydT6OYZe9RFAi8dSxV1rNSul1FlxtuKWYe8w2sQpbQGYuGDEtpOwdeFtq2iFTg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "peer": true, + "dependencies": { + "node-addon-native-custom-loader": "0.1.9" + }, + "engines": { + "node": ">=20 <23" + } + }, + "node_modules/node-addon-require-builtin-win32-x64-msvc": { + "version": "0.1.9", + "resolved": "https://registry.npmjs.org/node-addon-require-builtin-win32-x64-msvc/-/node-addon-require-builtin-win32-x64-msvc-0.1.9.tgz", + "integrity": "sha512-+i6N4A7m7txjbw8pDYESdWXiKO9EEVq0SzTzwPS0WZuV4F1MzQnaDJwJJnO7T6zAc0BvqHXBOkpharCrUjFhbQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "peer": true, + "dependencies": { + "node-addon-native-custom-loader": "0.1.9" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/obug": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/obug/-/obug-2.2.1.tgz", + "integrity": "sha512-XrsrhT5sybtKI6wakr2SPOlGZWWYbUXZ7a0jT8/QOeAPau+1X/bSegNe5YR75oJmEZQbKningirmGOEJCIk61Q==", + "dev": true, + "funding": [ + "https://github.com/sponsors/sxzz", + "https://opencollective.com/debug" + ], + "license": "MIT", + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/pathe": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", + "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==", + "dev": true, + "license": "MIT" + }, + "node_modules/pathval": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.1.tgz", + "integrity": "sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14.16" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/postcss": { + "version": "8.5.30", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.30.tgz", + "integrity": "sha512-zkd+e9S1AQHhmaBKye9zlFHWjOwVgqXl1q3ECYy8561K7qxR2cREf/STLskulBFd78k6AOFeA+ff1TtEzk9bAA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.20", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/quansync": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/quansync/-/quansync-1.0.0.tgz", + "integrity": "sha512-5xZacEEufv3HSTPQuchrvV6soaiACMFnq1H8wkVioctoH3TRha9Sz66lOxRwPK/qZj7HPiSveih9yAyh98gvqA==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/antfu" + }, + { + "type": "individual", + "url": "https://github.com/sponsors/sxzz" + } + ], + "license": "MIT" + }, + "node_modules/readdirp": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", + "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14.18.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, + "node_modules/resolve.exports": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.4.tgz", + "integrity": "sha512-zepuGL0ulf+nt+XaFrlKeaiTJeyPFPLLY62+ncq1/VTHBdt3HsfXOH60priZ6tnXQozdGcDeIF5JVTanvIcYWQ==", + "dev": true, + "license": "MIT", + "peer": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/rolldown": { + "version": "1.0.0-beta.45", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.0.0-beta.45.tgz", + "integrity": "sha512-iMmuD72XXLf26Tqrv1cryNYLX6NNPLhZ3AmNkSf8+xda0H+yijjGJ+wVT9UdBUHOpKzq9RjKtQKRCWoEKQQBZQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@oxc-project/types": "=0.95.0", + "@rolldown/pluginutils": "1.0.0-beta.45" + }, + "bin": { + "rolldown": "bin/cli.mjs" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "optionalDependencies": { + "@rolldown/binding-android-arm64": "1.0.0-beta.45", + "@rolldown/binding-darwin-arm64": "1.0.0-beta.45", + "@rolldown/binding-darwin-x64": "1.0.0-beta.45", + "@rolldown/binding-freebsd-x64": "1.0.0-beta.45", + "@rolldown/binding-linux-arm-gnueabihf": "1.0.0-beta.45", + "@rolldown/binding-linux-arm64-gnu": "1.0.0-beta.45", + "@rolldown/binding-linux-arm64-musl": "1.0.0-beta.45", + "@rolldown/binding-linux-x64-gnu": "1.0.0-beta.45", + "@rolldown/binding-linux-x64-musl": "1.0.0-beta.45", + "@rolldown/binding-openharmony-arm64": "1.0.0-beta.45", + "@rolldown/binding-wasm32-wasi": "1.0.0-beta.45", + "@rolldown/binding-win32-arm64-msvc": "1.0.0-beta.45", + "@rolldown/binding-win32-ia32-msvc": "1.0.0-beta.45", + "@rolldown/binding-win32-x64-msvc": "1.0.0-beta.45" + } + }, + "node_modules/rolldown-plugin-dts": { + "version": "0.17.8", + "resolved": "https://registry.npmjs.org/rolldown-plugin-dts/-/rolldown-plugin-dts-0.17.8.tgz", + "integrity": "sha512-76EEBlhF00yeY6M7VpMkWKI4r9WjuoMiOGey7j4D6zf3m0BR+ZrrY9hvSXdueJ3ljxSLq4DJBKFpX/X9+L7EKw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/generator": "^7.28.5", + "@babel/parser": "^7.28.5", + "@babel/types": "^7.28.5", + "ast-kit": "^2.2.0", + "birpc": "^2.8.0", + "dts-resolver": "^2.1.3", + "get-tsconfig": "^4.13.0", + "magic-string": "^0.30.21", + "obug": "^2.0.0" + }, + "engines": { + "node": ">=20.19.0" + }, + "funding": { + "url": "https://github.com/sponsors/sxzz" + }, + "peerDependencies": { + "@ts-macro/tsc": "^0.3.6", + "@typescript/native-preview": ">=7.0.0-dev.20250601.1", + "rolldown": "^1.0.0-beta.44", + "typescript": "^5.0.0", + "vue-tsc": "~3.1.0" + }, + "peerDependenciesMeta": { + "@ts-macro/tsc": { + "optional": true + }, + "@typescript/native-preview": { + "optional": true + }, + "typescript": { + "optional": true + }, + "vue-tsc": { + "optional": true + } + } + }, + "node_modules/rollup": { + "version": "4.64.7", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.64.7.tgz", + "integrity": "sha512-aCiJONoZp0lNGJ6sYqspLkh6UXaWEey/7Ko2TZyXQ4kgzAhDUxAgbt/oulXKmD+zFHXw1k+RF6ZZWOrjp7DZnQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.9" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@napi-rs/lzma-linux-x64-gnu": "1.5.1", + "@rollup/rollup-android-arm-eabi": "4.64.7", + "@rollup/rollup-android-arm64": "4.64.7", + "@rollup/rollup-darwin-arm64": "4.64.7", + "@rollup/rollup-darwin-x64": "4.64.7", + "@rollup/rollup-freebsd-arm64": "4.64.7", + "@rollup/rollup-freebsd-x64": "4.64.7", + "@rollup/rollup-linux-arm-gnueabihf": "4.64.7", + "@rollup/rollup-linux-arm-musleabihf": "4.64.7", + "@rollup/rollup-linux-arm64-gnu": "4.64.7", + "@rollup/rollup-linux-arm64-musl": "4.64.7", + "@rollup/rollup-linux-loong64-gnu": "4.64.7", + "@rollup/rollup-linux-loong64-musl": "4.64.7", + "@rollup/rollup-linux-ppc64-gnu": "4.64.7", + "@rollup/rollup-linux-ppc64-musl": "4.64.7", + "@rollup/rollup-linux-riscv64-gnu": "4.64.7", + "@rollup/rollup-linux-riscv64-musl": "4.64.7", + "@rollup/rollup-linux-s390x-gnu": "4.64.7", + "@rollup/rollup-linux-x64-gnu": "4.64.7", + "@rollup/rollup-linux-x64-musl": "4.64.7", + "@rollup/rollup-openbsd-x64": "4.64.7", + "@rollup/rollup-openharmony-arm64": "4.64.7", + "@rollup/rollup-win32-arm64-msvc": "4.64.7", + "@rollup/rollup-win32-ia32-msvc": "4.64.7", + "@rollup/rollup-win32-x64-gnu": "4.64.7", + "@rollup/rollup-win32-x64-msvc": "4.64.7", + "fsevents": "~2.3.2" + } + }, + "node_modules/semver": { + "version": "7.8.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", + "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/siginfo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", + "dev": true, + "license": "ISC" + }, + "node_modules/source-map-js": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz", + "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", + "dev": true, + "license": "MIT" + }, + "node_modules/std-env": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.10.0.tgz", + "integrity": "sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==", + "dev": true, + "license": "MIT" + }, + "node_modules/strip-literal": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/strip-literal/-/strip-literal-3.1.0.tgz", + "integrity": "sha512-8r3mkIM/2+PpjHoOtiAW8Rg3jJLHaV7xPwG+YRGrv6FP0wwk/toTpATxWYOW0BKdWwl82VT2tFYi5DlROa0Mxg==", + "dev": true, + "license": "MIT", + "dependencies": { + "js-tokens": "^9.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/tinybench": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", + "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinyexec": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.3.1.tgz", + "integrity": "sha512-GCvB3aoys96IuDFBMcTB46JOR6mdMtAToqwiW8JlWhsoh1mhHi/xn9ss/Dg7N555GiJyEt2qzoG/NHCwM6h1EA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tinypool": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.1.1.tgz", + "integrity": "sha512-Zba82s87IFq9A9XmjiX5uZA/ARWDrB03OHlq+Vw1fSdt0I+4/Kutwy8BP4Y/y/aORMo61FQ0vIb5j44vSo5Pkg==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.0.0 || >=20.0.0" + } + }, + "node_modules/tinyrainbow": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-2.0.0.tgz", + "integrity": "sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/tinyspy": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-4.0.6.tgz", + "integrity": "sha512-u8KszXvGfU68hVcZpRHKG28T0krMuv2G5nDhiHaMLen/gIuFEgIJhaJuO69qjnXg5paSrbPMFfx3brNuN8eVSg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/tree-kill": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", + "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", + "dev": true, + "license": "MIT", + "bin": { + "tree-kill": "cli.js" + } + }, + "node_modules/tsdown": { + "version": "0.15.12", + "resolved": "https://registry.npmjs.org/tsdown/-/tsdown-0.15.12.tgz", + "integrity": "sha512-c8VLlQm8/lFrOAg5VMVeN4NAbejZyVQkzd+ErjuaQgJFI/9MhR9ivr0H/CM7UlOF1+ELlF6YaI7sU/4itgGQ8w==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansis": "^4.2.0", + "cac": "^6.7.14", + "chokidar": "^4.0.3", + "debug": "^4.4.3", + "diff": "^8.0.2", + "empathic": "^2.0.0", + "hookable": "^5.5.3", + "rolldown": "1.0.0-beta.45", + "rolldown-plugin-dts": "^0.17.2", + "semver": "^7.7.3", + "tinyexec": "^1.0.1", + "tinyglobby": "^0.2.15", + "tree-kill": "^1.2.2", + "unconfig": "^7.3.3" + }, + "bin": { + "tsdown": "dist/run.mjs" + }, + "engines": { + "node": ">=20.19.0" + }, + "funding": { + "url": "https://github.com/sponsors/sxzz" + }, + "peerDependencies": { + "@arethetypeswrong/core": "^0.18.1", + "publint": "^0.3.0", + "typescript": "^5.0.0", + "unplugin-lightningcss": "^0.4.0", + "unplugin-unused": "^0.5.0", + "unrun": "^0.2.1" + }, + "peerDependenciesMeta": { + "@arethetypeswrong/core": { + "optional": true + }, + "publint": { + "optional": true + }, + "typescript": { + "optional": true + }, + "unplugin-lightningcss": { + "optional": true + }, + "unplugin-unused": { + "optional": true + }, + "unrun": { + "optional": true + } + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, + "license": "0BSD", + "optional": true + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/unconfig": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/unconfig/-/unconfig-7.5.0.tgz", + "integrity": "sha512-oi8Qy2JV4D3UQ0PsopR28CzdQ3S/5A1zwsUwp/rosSbfhJ5z7b90bIyTwi/F7hCLD4SGcZVjDzd4XoUQcEanvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@quansync/fs": "^1.0.0", + "defu": "^6.1.4", + "jiti": "^2.6.1", + "quansync": "^1.0.0", + "unconfig-core": "7.5.0" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/unconfig-core": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/unconfig-core/-/unconfig-core-7.5.0.tgz", + "integrity": "sha512-Su3FauozOGP44ZmKdHy2oE6LPjk51M/TRRjHv2HNCWiDvfvCoxC2lno6jevMA91MYAdCdwP05QnWdWpSbncX/w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@quansync/fs": "^1.0.0", + "quansync": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/vite": { + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.7.tgz", + "integrity": "sha512-AHEzTORMbi7/7aXp7w7KZ5+DCUdSeLsJz0grY8xHpc9DHdYb0vQu6DqJfm2tOw3gDExNgPgnJTXxM6syYFHaCA==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.27.0 || ^0.28.0", + "fdir": "^6.5.0", + "picomatch": "^4.0.3", + "postcss": "^8.5.6", + "rollup": "^4.43.0", + "tinyglobby": "^0.2.15" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "lightningcss": "^1.21.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vite-node": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-3.2.4.tgz", + "integrity": "sha512-EbKSKh+bh1E1IFxeO0pg1n4dvoOTt0UDiXMd/qn++r98+jPO1xtJilvXldeuQ8giIB5IkpjCgMleHMNEsGH6pg==", + "dev": true, + "license": "MIT", + "dependencies": { + "cac": "^6.7.14", + "debug": "^4.4.1", + "es-module-lexer": "^1.7.0", + "pathe": "^2.0.3", + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0" + }, + "bin": { + "vite-node": "vite-node.mjs" + }, + "engines": { + "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/vitest": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-3.2.7.tgz", + "integrity": "sha512-KrxIJ62Fd89gfysR4WotlgZABiz2dqFPgqGzX7s+CwsqLFomRH7777ZcrOD6+WVAh7khPQP41A+BKbpcJFrdEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/chai": "^5.2.2", + "@vitest/expect": "3.2.7", + "@vitest/mocker": "3.2.7", + "@vitest/pretty-format": "^3.2.7", + "@vitest/runner": "3.2.7", + "@vitest/snapshot": "3.2.7", + "@vitest/spy": "3.2.7", + "@vitest/utils": "3.2.7", + "chai": "^5.2.0", + "debug": "^4.4.1", + "expect-type": "^1.2.1", + "magic-string": "^0.30.17", + "pathe": "^2.0.3", + "picomatch": "^4.0.2", + "std-env": "^3.9.0", + "tinybench": "^2.9.0", + "tinyexec": "^0.3.2", + "tinyglobby": "^0.2.14", + "tinypool": "^1.1.1", + "tinyrainbow": "^2.0.0", + "vite": "^5.0.0 || ^6.0.0 || ^7.0.0-0", + "vite-node": "3.2.4", + "why-is-node-running": "^2.3.0" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@types/debug": "^4.1.12", + "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", + "@vitest/browser": "3.2.7", + "@vitest/ui": "3.2.7", + "happy-dom": "*", + "jsdom": "*" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@types/debug": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@vitest/browser": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + } + } + }, + "node_modules/vitest/node_modules/tinyexec": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-0.3.2.tgz", + "integrity": "sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/why-is-node-running": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", + "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==", + "dev": true, + "license": "MIT", + "dependencies": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + }, + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yaml": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.1.tgz", + "integrity": "sha512-3NxN8+78OdzbT7C/WjGsyfPAtJaN3FNDsWxv7Y7mcDsT/oOmgW8BpyQQFFBnvZE3j9Y2Sdz1ULFLezL7Eb2yFw==", + "dev": true, + "license": "ISC", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14.6" + }, + "funding": { + "url": "https://github.com/sponsors/eemeli" + } + }, + "node_modules/zod": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.4.3.tgz", + "integrity": "sha512-ytENFjIJFl2UwYglde2jchW2Hwm4GJFLDiSXWdTrJQBIN9Fcyp7n4DhxJEiWNAJMV1/BqWfW/kkg71UDcHJyTQ==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } + } + } +} diff --git a/demos/dsh-qoder-cloud-agents/package.json b/demos/dsh-qoder-cloud-agents/package.json new file mode 100644 index 0000000..739f164 --- /dev/null +++ b/demos/dsh-qoder-cloud-agents/package.json @@ -0,0 +1,91 @@ +{ + "name": "dsh-qoder-cloud-agents", + "description": "DeepSeek Harness plugin that runs sessions and delegated tasks on Qoder Cloud Agents sandboxes", + "homepage": "https://github.com/QoderAI/cloud-agents-cookbook/tree/main/demos/dsh-qoder-cloud-agents", + "repository": { + "type": "git", + "url": "git+https://github.com/QoderAI/cloud-agents-cookbook.git", + "directory": "demos/dsh-qoder-cloud-agents" + }, + "version": "0.1.0", + "type": "module", + "main": "lib/index.js", + "types": "lib/types/index.d.ts", + "exports": { + ".": { + "types": "./lib/types/index.d.ts", + "default": "./lib/index.js" + }, + "./cloud-route": { + "types": "./lib/types/cloud-route.d.ts", + "default": "./lib/cloud-route.js" + }, + "./client": "./client.js", + "./package.json": "./package.json", + "./locale/*.json": "./locale/*.json", + "./cordis.patch.yml": "./cordis.patch.yml" + }, + "files": [ + "icon.svg", + "locale/*.json", + "lib/index.js", + "lib/cloud-route.js", + "/client.js", + "cordis.patch.yml", + "lib/types/**/*.d.ts" + ], + "license": "Apache-2.0", + "keywords": [ + "dsh-plugin", + "deepseek-harness", + "qoder", + "cloud-agents" + ], + "icon": "./icon.svg", + "dsh": { + "bundle": { + "patch": "./cordis.patch.yml" + }, + "client": { + "platform": "web" + } + }, + "engines": { + "node": ">=22", + "dsh": ">=0.2.0-0 <0.3.0" + }, + "scripts": { + "build": "tsc -p tsconfig.json && tsdown", + "typecheck": "tsc -p tsconfig.json --noEmit", + "test": "vitest run", + "prepack": "npm run build" + }, + "peerDependencies": { + "@deepseek-ai/cordis": ">=4.0.0-0 <5", + "@deepseek-ai/dsh-credentials": ">=0.2.0-0 <0.3.0", + "@deepseek-ai/dsh-launch-environment": ">=0.2.0-0 <0.3.0", + "@deepseek-ai/dsh-llm": ">=0.2.0-0 <0.3.0", + "@deepseek-ai/dsh-subagent": ">=0.2.0-0 <0.3.0", + "@deepseek-ai/dsh-tool-subagent": ">=0.2.0-0 <0.3.0", + "@deepseek-ai/schemastery": ">=3.18.0-0 <4" + }, + "devDependencies": { + "@deepseek-ai/cordis": "4.0.5-alpha.2", + "@deepseek-ai/dsh-agent": "0.2.1-alpha.4", + "@deepseek-ai/dsh-commands": "^0.2.1-alpha.4", + "@deepseek-ai/dsh-credentials": "0.2.1-alpha.4", + "@deepseek-ai/dsh-launch-environment": "0.2.1-alpha.4", + "@deepseek-ai/dsh-llm": "0.2.1-alpha.4", + "@deepseek-ai/dsh-session": "0.2.1-alpha.4", + "@deepseek-ai/dsh-session-projection": "0.2.1-alpha.4", + "@deepseek-ai/dsh-settings": "^0.2.1-alpha.4", + "@deepseek-ai/dsh-subagent": "0.2.1-alpha.4", + "@deepseek-ai/dsh-tool-subagent": "0.2.1-alpha.4", + "@deepseek-ai/dsh-user-questions": "^0.2.1-alpha.4", + "@deepseek-ai/schemastery": "3.18.5-alpha.2", + "@types/node": "^22.10.0", + "tsdown": "^0.15.0", + "typescript": "^5.9.0", + "vitest": "^3.2.0" + } +} diff --git a/demos/dsh-qoder-cloud-agents/src/client.ts b/demos/dsh-qoder-cloud-agents/src/client.ts new file mode 100644 index 0000000..a221e4a --- /dev/null +++ b/demos/dsh-qoder-cloud-agents/src/client.ts @@ -0,0 +1,282 @@ +/** + * Thin `fetch` client for the Qoder Cloud Agents OpenAPI + * (`https://api.qoder.com/api/v1/cloud`): environments, agents, sessions, + * session events and the session SSE stream. + * + * @module dsh-qoder-cloud-agents/client + */ + +import { randomUUID } from 'node:crypto' +import { SseParser } from './sse.ts' + +/** Default public gateway. */ +export const DEFAULT_BASE_URL = 'https://api.qoder.com/api/v1/cloud' + +/** Built-in sandbox toolset (Bash, Read, Write, Edit, Glob, Grep, WebFetch, …). */ +export const AGENT_TOOLSET = 'agent_toolset_20260401' + +/** `{type, message}` from the platform error envelope. */ +export class QoderCloudError extends Error { + constructor( + readonly status: number, + readonly errorType: string, + message: string, + readonly requestId?: string, + ) { + super(`Qoder Cloud ${status} ${errorType}: ${message}${requestId === undefined ? '' : ` (request_id ${requestId})`}`) + this.name = 'QoderCloudError' + } +} + +export interface CursorPage { + readonly data: T[] + readonly has_more?: boolean + readonly next_page?: string | null +} + +export interface EnvironmentView { + readonly id: string + readonly name: string + readonly archived_at?: string | null + /** `{type: 'cloud' | 'self_hosted', networking?, packages?, setup_script?}`. */ + readonly config?: { readonly type?: string } | null +} + +export interface AgentView { + readonly id: string + readonly name: string + /** A model id string or `{id, effort?, speed?}`. */ + readonly model?: unknown + readonly version?: number + readonly archived_at?: string | null +} + +export interface SessionView { + readonly id: string + readonly status: 'idle' | 'running' | 'rescheduling' | 'terminated' | string + readonly title?: string | null +} + +/** One public session event; only the fields this client reads are typed. */ +export interface SessionEvent { + readonly id: string + readonly type: string + readonly content?: unknown + readonly stop_reason?: { readonly type?: string; readonly event_ids?: readonly string[] } | null + readonly error?: { readonly type?: string; readonly message?: string; readonly retry_status?: { readonly type?: string } } | null + readonly name?: string + readonly file_id?: string + readonly original_filename?: string + readonly size?: number + readonly [key: string]: unknown +} + +export type SessionResource = + | { type: 'github_repository'; url: string; authorization_token?: string; checkout?: Checkout; mount_path?: string } + /** Authenticated clones carry the account in the URL (`https://user@host/…`) and the token as `password`. */ + | { type: 'git_repository'; url: string; password?: string; checkout?: Checkout; mount_path?: string } + | { type: 'file'; file_id: string; mount_path?: string } + +export type Checkout = { type: 'branch'; name: string } | { type: 'commit'; sha: string } + +export interface CreateSessionRequest { + agent: string | { type: 'agent'; id: string; version?: number } + environment_id: string + title?: string + metadata?: Record + resources?: SessionResource[] + environment_variables?: Record +} + +export interface CreateAgentRequest { + name: string + model: string + system?: string + description?: string + tools: { type: string }[] + metadata?: Record +} + +export interface QoderCloudClientOptions { + baseURL: string + token: string + headers?: Record + /** Injected for tests. */ + fetch?: typeof fetch + /** Retries for 429 / 5xx on idempotent or idempotency-keyed requests. */ + maxRetries?: number +} + +const RETRYABLE = new Set([408, 425, 429, 500, 502, 503, 504]) + +export class QoderCloudClient { + private readonly baseURL: string + private readonly fetchImpl: typeof fetch + private readonly maxRetries: number + + constructor(private readonly options: QoderCloudClientOptions) { + this.baseURL = options.baseURL.replace(/\/+$/, '') + this.fetchImpl = options.fetch ?? fetch + this.maxRetries = options.maxRetries ?? 3 + } + + listEnvironments(signal?: AbortSignal): Promise> { + return this.request('GET', '/environments?limit=100', undefined, signal) + } + + createEnvironment(name: string, signal?: AbortSignal): Promise { + return this.request('POST', '/environments', { + name, + config: { type: 'cloud', networking: { type: 'unrestricted' } }, + }, signal) + } + + listAgents(signal?: AbortSignal): Promise> { + return this.request('GET', '/agents?limit=100', undefined, signal) + } + + createAgent(body: CreateAgentRequest, signal?: AbortSignal): Promise { + return this.request('POST', '/agents', body, signal) + } + + createSession(body: CreateSessionRequest, signal?: AbortSignal): Promise { + return this.request('POST', '/sessions', body, signal) + } + + getSession(id: string, signal?: AbortSignal): Promise { + return this.request('GET', `/sessions/${encodeURIComponent(id)}`, undefined, signal) + } + + sendEvents(id: string, events: readonly Record[], signal?: AbortSignal): Promise<{ data: SessionEvent[] }> { + return this.request('POST', `/sessions/${encodeURIComponent(id)}/events`, { events }, signal) + } + + cancelSession(id: string, signal?: AbortSignal): Promise { + return this.request('POST', `/sessions/${encodeURIComponent(id)}/cancel`, {}, signal) + } + + archiveSession(id: string, signal?: AbortSignal): Promise { + return this.request('POST', `/sessions/${encodeURIComponent(id)}/archive`, {}, signal) + } + + /** + * Open the session event stream once. Without `lastEventId` the server + * replays the whole history first; with it, delivery resumes strictly after + * that event. The stream never ends on idle: the caller stops reading. + * @param id - session id. + * @param lastEventId - resume point (`Last-Event-ID`). + * @param signal - aborts the underlying request. + */ + async *streamEvents(id: string, lastEventId: string | undefined, signal: AbortSignal): AsyncGenerator { + const response = await this.fetchImpl(`${this.baseURL}/sessions/${encodeURIComponent(id)}/events/stream`, { + method: 'GET', + headers: { + ...this.options.headers, + Authorization: `Bearer ${this.options.token}`, + Accept: 'text/event-stream', + ...lastEventId === undefined ? {} : { 'Last-Event-ID': lastEventId }, + }, + signal, + }) + if (!response.ok) throw await errorOf(response) + if (response.body === null) throw new Error('Qoder Cloud stream returned no body') + const parser = new SseParser() + const decoder = new TextDecoder() + const reader = response.body.getReader() + try { + for (;;) { + const { done, value } = await reader.read() + if (done) return + for (const frame of parser.push(decoder.decode(value, { stream: true }))) { + let event: SessionEvent + try { + event = JSON.parse(frame.data) as SessionEvent + } catch { + continue + } + yield { ...event, id: event.id ?? frame.id, type: event.type ?? frame.event } + } + } + } finally { + reader.releaseLock() + void response.body.cancel().catch(() => {}) + } + } + + private async request(method: string, path: string, body: unknown, signal?: AbortSignal): Promise { + // One key per logical request, reused across retries, so a retried POST + // whose first attempt did land is not applied twice. + const idempotencyKey = method === 'POST' ? randomUUID() : undefined + for (let attempt = 0; ; attempt++) { + signal?.throwIfAborted() + let response: Response + try { + response = await this.fetchImpl(`${this.baseURL}${path}`, { + method, + headers: { + ...this.options.headers, + Authorization: `Bearer ${this.options.token}`, + Accept: 'application/json', + ...body === undefined ? {} : { 'Content-Type': 'application/json' }, + ...idempotencyKey === undefined ? {} : { 'Idempotency-Key': idempotencyKey }, + }, + ...body === undefined ? {} : { body: JSON.stringify(body) }, + ...signal === undefined ? {} : { signal }, + }) + } catch (error: unknown) { + if (signal?.aborted || attempt >= this.maxRetries) throw error + await delay(backoff(attempt), signal) + continue + } + if (response.ok) { + const text = await response.text() + return (text.length === 0 ? {} : JSON.parse(text)) as T + } + if (RETRYABLE.has(response.status) && attempt < this.maxRetries) { + const retryAfter = Number(response.headers.get('retry-after')) + await response.body?.cancel().catch(() => {}) + await delay(Number.isFinite(retryAfter) && retryAfter > 0 ? retryAfter * 1000 : backoff(attempt), signal) + continue + } + throw await errorOf(response) + } + } +} + +async function errorOf(response: Response): Promise { + const text = await response.text().catch(() => '') + try { + const body = JSON.parse(text) as { request_id?: string; error?: { type?: string; message?: string } } + return new QoderCloudError( + response.status, + body.error?.type ?? 'api_error', + body.error?.message ?? response.statusText, + body.request_id, + ) + } catch { + return new QoderCloudError(response.status, 'api_error', text.slice(0, 500) || response.statusText) + } +} + +function backoff(attempt: number): number { + return Math.min(500 * 2 ** attempt, 8_000) +} + +/** Abortable sleep. */ +export function delay(ms: number, signal?: AbortSignal): Promise { + return new Promise((resolve, reject) => { + if (signal?.aborted) { + reject(signal.reason) + return + } + const onAbort = (): void => { + clearTimeout(timer) + reject(signal?.reason) + } + const timer = setTimeout(() => { + signal?.removeEventListener('abort', onAbort) + resolve() + }, ms) + signal?.addEventListener('abort', onAbort, { once: true }) + }) +} diff --git a/demos/dsh-qoder-cloud-agents/src/cloud-constants.ts b/demos/dsh-qoder-cloud-agents/src/cloud-constants.ts new file mode 100644 index 0000000..3a7cdb9 --- /dev/null +++ b/demos/dsh-qoder-cloud-agents/src/cloud-constants.ts @@ -0,0 +1,13 @@ +/** + * Identifiers shared by the cloud-mode adapter, the preset route plugin and + * the Web toggle (which repeats them in client.js). + * + * @module dsh-qoder-cloud-agents/cloud-constants + */ + +/** LLM provider route served by the Qoder Cloud adapter. */ +export const CLOUD_PROVIDER = 'qoder-cloud-agents' +/** The route's single model. */ +export const CLOUD_MODEL = 'agent' +/** Agent preset id the bundle patch inserts; the Web toggle selects it. */ +export const CLOUD_PRESET_ID = 'qoder-cloud-agents' diff --git a/demos/dsh-qoder-cloud-agents/src/cloud-mode.ts b/demos/dsh-qoder-cloud-agents/src/cloud-mode.ts new file mode 100644 index 0000000..510152d --- /dev/null +++ b/demos/dsh-qoder-cloud-agents/src/cloud-mode.ts @@ -0,0 +1,487 @@ +/** + * Cloud mode: a `qoder-cloud-agents` LLM route whose "model" is a Qoder Cloud agent. + * Each dsh turn posts the user's new message to one Qoder Cloud session (one + * per dsh session) and streams the remote agent's messages and tool activity + * back as the assistant reply, so the ordinary agent loop logs and renders it + * and follow-ups continue the same remote session. + * + * The remote session id travels on each reply's `replayState`, so it survives + * restarts and forks without extra storage. + * + * @module dsh-qoder-cloud-agents/cloud-mode + */ + +import { randomUUID } from 'node:crypto' +import { + LlmAdapter, + LlmError, + resolveRetryPolicy, + type ContentBlock, + type GenerateOptions, + type LlmModelInfo, + type LlmProviderInfo, + type LlmResolvedModelInfo, + type RequestMessage, + type ResolvedRetryPolicy, + type StreamChunk, +} from '@deepseek-ai/dsh-llm' +import { delay, type QoderCloudClient, type SessionEvent, type SessionResource } from './client.ts' +import { detectRepository, type LocalRepository } from './git.ts' +import { checkGitHubAccess } from './github.ts' +import { repositoryResource } from './run.ts' +import type { Asker, TargetResolver } from './target.ts' + +import { CLOUD_MODEL, CLOUD_PROVIDER } from './cloud-constants.ts' + +export { CLOUD_MODEL, CLOUD_PRESET_ID, CLOUD_PROVIDER } from './cloud-constants.ts' + +/** Consecutive stream failures tolerated within one turn. */ +const MAX_STREAM_FAILURES = 6 + +/** What a successful reply records for the next turn. */ +interface CloudReplay { + readonly remoteSessionId: string +} + +/** Session-scoped facts the adapter needs from the host, resolved per turn. */ +export interface CloudTurnContext { + /** Working directory of the dsh session, for repository detection. */ + readonly cwd: string | undefined + /** Human answerer for the environment / agent picker, when one is attached. */ + readonly asker: Asker | undefined +} + +export interface CloudModeOptions { + readonly client: () => Promise + readonly resolver: TargetResolver + /** Session cwd and answerer for a dsh session id. */ + readonly turnContext: (sessionId: string | undefined) => CloudTurnContext + readonly repository: 'auto' | 'none' + readonly gitToken: () => Promise + readonly gitTokenEnv: string + readonly gitUsername: string | undefined + readonly branchPrefix: string + readonly toolConfirmation: 'allow' | 'deny' + readonly environmentVariables: Readonly> + readonly onWarn?: (message: string, error?: unknown) => void +} + +/** Join the visible text of request content blocks; attachments become placeholders. */ +function blocksText(content: readonly ContentBlock[]): string { + const parts: string[] = [] + for (const block of content) { + if (block.type === 'text') parts.push(block.text) + else if (block.type === 'image') parts.push('[an image was attached locally; it is not available in the cloud]') + else if (block.type === 'file') parts.push(`[a file was attached locally: ${(block as { attachment?: { name?: string } }).attachment?.name ?? 'file'}; it is not available in the cloud]`) + } + return parts.join('\n') +} + +function isUserInput(message: RequestMessage): boolean { + if (message.role !== 'user') return false + // Identity-free one-shot input, or a message the user typed. Other user-role + // sources (context notices, relays) are local harness plumbing. + return message.source === undefined || message.source.kind === 'user' +} + +/** + * Find the remote session of the latest cloud reply and the user text typed since. + * @param messages - the request history. + * @returns the replay (if any) and the new user text. + */ +export function splitHistory(messages: readonly RequestMessage[]): { replay: CloudReplay | undefined; input: string } { + let lastAssistant = -1 + let replay: CloudReplay | undefined + for (let index = messages.length - 1; index >= 0; index--) { + const message = messages[index]! + if (message.role !== 'assistant') continue + if (lastAssistant < 0) lastAssistant = index + const source = message.source + const state = source.provider === CLOUD_PROVIDER ? (source.replayState as { response?: unknown } | undefined) : undefined + const response = state?.response as Partial | undefined + if (typeof response?.remoteSessionId === 'string') { + replay = { remoteSessionId: response.remoteSessionId } + break + } + } + const input = messages + .slice(lastAssistant + 1) + .filter(isUserInput) + .map(message => blocksText(message.content)) + .filter(text => text.trim().length > 0) + .join('\n\n') + return { replay, input } +} + +/** First-turn preamble: how the workspace reached the sandbox and how to hand changes back. */ +export function cloudModePreamble(repo: LocalRepository | undefined, resultBranch: string | undefined): string { + const lines = [ + 'You are working in a Qoder Cloud sandbox for a user of DeepSeek Harness. Your messages are shown to them as your replies; they may follow up in later turns.', + ] + if (repo !== undefined && resultBranch !== undefined) { + const at = repo.checkout.type === 'branch' + ? `checked out at branch \`${repo.checkout.name}\`` + : `checked out at its default branch; before working, run \`git fetch origin ${repo.checkout.sha} && git checkout ${repo.checkout.sha}\` there` + lines.push( + `The user's git repository ${repo.url} is mounted at \`${repo.mountPath}\` (in a self-hosted environment: \`workspace/${repo.name}\` under your working directory), ${at}.`, + 'First check that the mounted repository exists. If it does not, the platform failed to mount it (unreachable host or missing/invalid token): say so and stop, without cloning it yourself.', + `When you change files, commit them on the branch \`${resultBranch}\` and \`git push -u origin ${resultBranch}\`; keep using that branch for later turns and never push to any other branch. Say which branch you pushed.`, + ) + } else { + lines.push('No local repository was shared with this sandbox.') + } + return lines.join('\n') +} + +function summarizeInput(input: unknown): string { + if (input === null || typeof input !== 'object') return '' + const record = input as Record + for (const key of ['command', 'file_path', 'path', 'pattern', 'url', 'query']) { + const value = record[key] + if (typeof value === 'string' && value.length > 0) return value.length > 160 ? `${value.slice(0, 157)}…` : value + } + const json = JSON.stringify(record) + return json.length > 160 ? `${json.slice(0, 157)}…` : json +} + +function eventText(content: unknown): string { + if (typeof content === 'string') return content + if (!Array.isArray(content)) return '' + return content + .filter((block): block is { type: 'text'; text: string } => + typeof block === 'object' && block !== null && block.type === 'text' && typeof block.text === 'string') + .map(block => block.text) + .join('') +} + +/** Emits well-formed block sequences with increasing indexes. */ +class ChunkWriter { + private index = 0 + text(text: string): StreamChunk[] { return this.block('text', text) } + reasoning(text: string): StreamChunk[] { return this.block('reasoning', text) } + private block(type: 'text' | 'reasoning', text: string): StreamChunk[] { + const index = this.index++ + return [ + { type: 'block-start', index, blockType: type }, + type === 'text' ? { type: 'text-delta', index, text } : { type: 'reasoning-delta', index, text }, + { type: 'block-end', index, block: { type, text } }, + ] + } +} + +const ZERO_USAGE = { inputTokens: 0, outputTokens: 0 } as const + +/** Model-picker group of the cloud route. */ +const CLOUD_GROUP_NAME = 'Qoder Cloud Agents' +/** Model-picker entry: marks the route as cloud mode's, not a general model. */ +const CLOUD_MODEL_NAME = '云端模式(Qoder Cloud Agents)' +const CLOUD_MODEL_DESCRIPTION = '仅供云端模式使用:请在新会话打开「云端模式」开关,不要在普通会话里切换到它' + +/** The `qoder-cloud-agents` route. */ +export class QoderCloudAdapter extends LlmAdapter { + /** Same-process fallback when a turn failed before recording its replay state. */ + private readonly remoteByDshSession = new Map() + + constructor(private readonly options: CloudModeOptions) { + super() + } + + override providerInfo(provider: string): LlmProviderInfo { + return { id: provider, name: CLOUD_GROUP_NAME } + } + + override providerRetryPolicy(provider: string): ResolvedRetryPolicy { + // A retry would post the user's message to the cloud agent a second time. + return resolveRetryPolicy({ mode: 'normal', maxRetries: 0 }, provider) + } + + override async listModels(provider: string): Promise { + // Listed only so a cloud-mode session's picker can name its route; the name + // says it belongs to cloud mode rather than offering it as a general model. + return [{ provider, id: CLOUD_MODEL, name: CLOUD_MODEL_NAME, description: CLOUD_MODEL_DESCRIPTION }] + } + + override async resolveModel(provider: string, model: string): Promise { + // The remote agent keeps its own context; dsh only sends each new turn. + return { provider, id: model, name: CLOUD_MODEL_NAME, context: { contextWindow: 1_000_000 } } + } + + async *stream(options: GenerateOptions): AsyncIterable { + if (options.purpose !== undefined) { + yield* this.auxiliary(options) + return + } + const signal = options.signal ?? new AbortController().signal + const { replay, input } = splitHistory(options.messages) + if (input.trim().length === 0) { + throw new LlmError('Cloud mode received no user text to send', 'EMPTY_REQUEST') + } + const client = await this.options.client() + if (typeof client === 'string') throw new LlmError(`Qoder Cloud: ${client}`, 'AUTH') + + const sessionKey = options.sessionId as string | undefined + let remoteSessionId = replay?.remoteSessionId ?? (sessionKey === undefined ? undefined : this.remoteByDshSession.get(sessionKey)) + const writer = new ChunkWriter() + let text = input + if (remoteSessionId === undefined) { + const created = await this.createRemoteSession(client, sessionKey, signal) + remoteSessionId = created.id + text = `${created.preamble}\n\n---\n\n${input}` + if (created.notes.length > 0) yield* writer.reasoning(created.notes.join('\n')) + } + if (sessionKey !== undefined) this.remoteByDshSession.set(sessionKey, remoteSessionId) + + let posted + try { + posted = await client.sendEvents(remoteSessionId, [{ type: 'user.message', content: [{ type: 'text', text }] }], signal) + } catch (error: unknown) { + throw toLlmError(error, 'Qoder Cloud refused the message') + } + const id = remoteSessionId + const onAbort = (): void => { void client.cancelSession(id, AbortSignal.timeout(10_000)).catch(() => {}) } + signal.addEventListener('abort', onAbort, { once: true }) + try { + yield* this.follow(client, id, posted.data.at(-1)?.id, writer, signal) + } finally { + signal.removeEventListener('abort', onAbort) + } + } + + /** Session titles and compaction never reach the cloud agent. */ + private async *auxiliary(options: GenerateOptions): AsyncIterable { + const writer = new ChunkWriter() + const text = options.purpose === 'session-title' + ? localTitle(options.messages) + : 'The conversation continues in the same Qoder Cloud session, which keeps the full history.' + yield* writer.text(text) + yield { type: 'usage', usage: ZERO_USAGE } + yield { type: 'finish', reason: { kind: 'stop' } } + } + + private async createRemoteSession( + client: QoderCloudClient, + sessionKey: string | undefined, + signal: AbortSignal, + ): Promise<{ id: string; preamble: string; notes: string[] }> { + const { options } = this + const context = options.turnContext(sessionKey) + const notes: string[] = [] + let repo: LocalRepository | undefined + let resultBranch: string | undefined + const resources: SessionResource[] = [] + if (options.repository === 'auto' && context.cwd !== undefined) { + repo = await detectRepository(context.cwd, signal) + } + if (repo !== undefined) { + const gitToken = await options.gitToken() + if (repo.github) { + const access = await checkGitHubAccess(repo.url, gitToken, options.gitTokenEnv, signal) + if (access.error !== undefined) throw new LlmError(`Qoder Cloud: ${access.error}`, 'REPOSITORY_ACCESS') + notes.push(...access.warnings) + } + try { + resources.push(repositoryResource(repo, { gitToken, gitTokenEnv: options.gitTokenEnv, gitUsername: options.gitUsername })) + } catch (error: unknown) { + throw toLlmError(error, 'Qoder Cloud repository configuration') + } + resultBranch = `${options.branchPrefix}${randomUUID().slice(0, 8)}` + notes.push(...repo.warnings) + } + let target + try { + target = await options.resolver.resolve(client, context.asker, signal) + } catch (error: unknown) { + throw toLlmError(error, 'Qoder Cloud environment selection') + } + let session + try { + session = await client.createSession({ + agent: target.agent, + environment_id: target.environmentId, + title: 'DeepSeek Harness cloud mode', + metadata: { source: 'deepseek-harness', mode: 'cloud' }, + ...resources.length === 0 ? {} : { resources }, + ...Object.keys(options.environmentVariables).length === 0 + ? {} + : { environment_variables: { ...options.environmentVariables } }, + }, signal) + } catch (error: unknown) { + throw toLlmError(error, 'Qoder Cloud could not create a session') + } + notes.unshift( + `Qoder Cloud session ${session.id}` + + (repo === undefined ? '' : ` · repository ${repo.url} → branch ${resultBranch}`), + ...target.notes, + ) + return { id: session.id, preamble: cloudModePreamble(repo, resultBranch), notes } + } + + /** Stream one remote turn as chunks until it settles. */ + private async *follow( + client: QoderCloudClient, + remoteSessionId: string, + lastPosted: string | undefined, + writer: ChunkWriter, + signal: AbortSignal, + ): AsyncIterable { + let lastEventId = lastPosted + let failures = 0 + let errorMessage: string | undefined + let wroteText = false + const pendingTools = new Map() + for (;;) { + try { + for await (const event of client.streamEvents(remoteSessionId, lastEventId, signal)) { + failures = 0 + if (event.id !== undefined) lastEventId = event.id + const chunks = this.render(event, writer, pendingTools) + if (event.type === 'agent.message' && chunks.length > 0) wroteText = true + yield* chunks + if (event.type === 'session.error') errorMessage = event.error?.message ?? errorMessage + if (event.type === 'session.status_idle') { + const reason = event.stop_reason?.type ?? 'end_turn' + if (reason === 'requires_action') { + await this.answerPause(client, remoteSessionId, event.stop_reason?.event_ids ?? [], pendingTools, signal) + continue + } + if (reason === 'end_turn' || reason === 'max_tokens') { + if (!wroteText) yield* writer.text('(the cloud agent ended the turn without a message)') + yield { type: 'usage', usage: ZERO_USAGE } + yield { + type: 'finish', + reason: reason === 'max_tokens' ? { kind: 'max-tokens' } : { kind: 'stop' }, + replayState: { response: { remoteSessionId } satisfies CloudReplay }, + } + return + } + throw new LlmError( + errorMessage ?? `Qoder Cloud turn ended with ${reason} (session ${remoteSessionId})`, + reason === 'cancelled' ? 'REMOTE_CANCELLED' : 'REMOTE_AGENT_ERROR', + ) + } + if (event.type === 'session.status_terminated' || event.type === 'session.deleted') { + throw new LlmError(errorMessage ?? `Qoder Cloud session ${remoteSessionId} was terminated`, 'REMOTE_TERMINATED') + } + } + } catch (error: unknown) { + if (error instanceof LlmError || signal.aborted) throw error + if (++failures >= MAX_STREAM_FAILURES) throw toLlmError(error, 'Qoder Cloud stream failed') + } + await delay(Math.min(1_000 * 2 ** failures, 15_000), signal) + } + } + + /** Map one remote event onto visible blocks: messages as text, activity as reasoning. */ + private render(event: SessionEvent, writer: ChunkWriter, pendingTools: Map): StreamChunk[] { + switch (event.type) { + case 'agent.message': { + const text = eventText(event.content) + return text.trim().length > 0 ? writer.text(text) : [] + } + case 'agent.thinking': { + const text = typeof event.thinking === 'string' ? event.thinking : typeof event.text === 'string' ? event.text : '' + return text.trim().length > 0 ? writer.reasoning(text) : [] + } + case 'agent.tool_use': + case 'agent.mcp_tool_use': + case 'agent.custom_tool_use': { + pendingTools.set(event.id, event.type) + const server = typeof event.mcp_server_name === 'string' ? `${event.mcp_server_name}/` : '' + const detail = summarizeInput(event.input) + return writer.reasoning(`› ${server}${event.name ?? 'tool'}${detail.length > 0 ? `: ${detail}` : ''}`) + } + case 'agent.tool_result': + case 'agent.mcp_tool_result': + return event.is_error === true ? writer.reasoning(` ✗ ${eventText(event.content).slice(0, 300) || 'tool failed'}`) : [] + case 'agent.artifact_delivered': + return writer.reasoning(`Delivered file ${event.original_filename ?? event.file_id} (${event.file_id})`) + case 'session.error': + return event.error?.retry_status?.type === 'retrying' + ? writer.reasoning(`Qoder Cloud is retrying: ${event.error.message ?? 'transient error'}`) + : [] + default: + return [] + } + } + + private async answerPause( + client: QoderCloudClient, + remoteSessionId: string, + eventIds: readonly string[], + pendingTools: Map, + signal: AbortSignal, + ): Promise { + for (const eventId of eventIds) { + const event = pendingTools.get(eventId) === 'agent.custom_tool_use' + ? { + type: 'user.custom_tool_result', + custom_tool_use_id: eventId, + content: [{ type: 'text', text: 'Custom tools are unavailable in DeepSeek Harness cloud mode.' }], + is_error: true, + } + : { + type: 'user.tool_confirmation', + tool_use_id: eventId, + result: this.options.toolConfirmation, + ...this.options.toolConfirmation === 'deny' + ? { deny_message: 'Denied by the DeepSeek Harness cloud-mode policy.' } + : {}, + } + await client.sendEvents(remoteSessionId, [event], signal) + } + } +} + +/** + * A session title without a model call: the first human message. The title + * plugin frames human messages as a JSON array after one instruction line. + * @param messages - the title request's messages. + */ +export function localTitle(messages: readonly RequestMessage[]): string { + const raw = messages + .filter(message => message.role === 'user') + .map(message => blocksText(message.content)) + .join('\n') + const framed = raw.indexOf('[') + let candidate: string | undefined + if (framed >= 0) { + try { + candidate = firstString(JSON.parse(raw.slice(framed))) + } catch { + // Not a framed array; fall back to the raw text. + } + } + const line = (candidate ?? raw).split(/\r?\n/).map(item => item.trim()).find(item => item.length > 0) + return (line ?? 'Qoder Cloud').slice(0, 40) +} + +/** First string found depth-first, preferring a `text` field. */ +function firstString(value: unknown): string | undefined { + if (typeof value === 'string') return value.trim().length > 0 ? value : undefined + if (Array.isArray(value)) { + for (const item of value) { + const found = firstString(item) + if (found !== undefined) return found + } + return undefined + } + if (value !== null && typeof value === 'object') { + const record = value as Record + if (typeof record.text === 'string' && record.text.trim().length > 0) return record.text + for (const item of Object.values(record)) { + const found = firstString(item) + if (found !== undefined) return found + } + } + return undefined +} + +function toLlmError(error: unknown, context: string): LlmError { + if (error instanceof LlmError) return error + const message = error instanceof Error ? error.message.replace(/^qoder-cloud-agents: /, '') : String(error) + const status = (error as { status?: unknown }).status + return new LlmError(`${context}: ${message}`, 'REMOTE_AGENT_ERROR', { + cause: error, + ...typeof status === 'number' && status >= 100 && status <= 599 ? { status } : {}, + }) +} diff --git a/demos/dsh-qoder-cloud-agents/src/cloud-route.ts b/demos/dsh-qoder-cloud-agents/src/cloud-route.ts new file mode 100644 index 0000000..4bbeb51 --- /dev/null +++ b/demos/dsh-qoder-cloud-agents/src/cloud-route.ts @@ -0,0 +1,41 @@ +/** + * Child plugin of the 「云端模式」 agent preset: pins every model request of + * the preset's agent to the `qoder-cloud-agents` route. Registered with `prepend` so + * it stays the outermost `agent/request` listener and a manual model pick + * cannot route a cloud-mode session back to a local model. + * + * It also pins the `{{provider}}` / `{{model}}` prompt variables of the + * agent's system prompt to the route. They otherwise follow the session's + * selected model, which is still the pre-toggle model on the first turn and the + * cloud route afterwards, so the persona line ("powered by the {{model}} model") + * changed between turns and the trace logged a spurious 「系统提示词已更新」. + * + * @module dsh-qoder-cloud-agents/cloud-route + */ + +import type { Context } from '@deepseek-ai/cordis' +import type { LlmCallConfig } from '@deepseek-ai/dsh-llm' +import type {} from '@deepseek-ai/dsh-agent' +import type { PromptAssembly } from '@deepseek-ai/dsh-system-prompt' +import { CLOUD_MODEL, CLOUD_PROVIDER } from './cloud-constants.ts' + +export const name = 'qoder-cloud-agents-route' + +/** + * Route the preset's agent to Qoder Cloud. + * @param ctx - the preset's agent-scoped context. + */ +export function apply(ctx: Context): void { + ctx.on('agent/request', async (_payload, next): Promise => { + // The cloud route has no reasoning levels or output cap of its own. + const { reasoningEffort: _effort, maxTokens: _maxTokens, ...rest } = await next() + return { ...rest, provider: CLOUD_PROVIDER, model: CLOUD_MODEL } + }, { prepend: true }) + + // The assembly waterfall's result is what gets rendered, so overriding the + // variables here wins over every registered provider on every turn. + ctx.on('system-prompt/assemble', async (_assembly, _context, next): Promise => { + const assembly = await next() + return { ...assembly, variables: { ...assembly.variables, provider: CLOUD_PROVIDER, model: CLOUD_MODEL } } + }, { prepend: true }) +} diff --git a/demos/dsh-qoder-cloud-agents/src/command.ts b/demos/dsh-qoder-cloud-agents/src/command.ts new file mode 100644 index 0000000..9016dc5 --- /dev/null +++ b/demos/dsh-qoder-cloud-agents/src/command.ts @@ -0,0 +1,165 @@ +/** + * `/qoder-cloud-agents` — inspect and change the saved Qoder Cloud environment and + * agent from an interactive dsh UI without involving the model. + * + * /qoder-cloud-agents show the current binding + * /qoder-cloud-agents env list environments + * /qoder-cloud-agents env use an environment (saved to the profile) + * /qoder-cloud-agents agent list agents + * /qoder-cloud-agents agent use an agent; `new` uses the plugin-managed one + * /qoder-cloud-agents reset forget both; the next delegation asks again + * + * @module dsh-qoder-cloud-agents/command + */ + +import type { CommandDefinition } from '@deepseek-ai/dsh-commands' +import type { QoderCloudClient } from './client.ts' +import { + describeEnvironment, + matchByIdOrName, + type Selection, + type TargetResolver, +} from './target.ts' + +export const COMMAND_NAME = 'qoder-cloud-agents' + +type CommandResult = Awaited> + +export interface CommandDeps { + readonly configured: () => Selection + readonly baseURL: string + /** Authenticated client, or an error message when no PAT resolves. */ + readonly client: () => Promise + readonly resolver: TargetResolver + /** Save (or with `undefined` values, clear) fields; false when not saved. */ + readonly persist: (selection: Selection) => Promise + readonly managedAgentName: string +} + +const USAGE = [ + 'Usage:', + ' /qoder-cloud-agents show the current environment and agent', + ' /qoder-cloud-agents env list environments', + ' /qoder-cloud-agents env use an environment', + ' /qoder-cloud-agents agent list agents', + ' /qoder-cloud-agents agent use an agent (`new`: the plugin-managed agent)', + ' /qoder-cloud-agents reset forget both; the next delegation asks again', +].join('\n') + +const saved = (ok: boolean): string => ok + ? 'Saved to this profile.' + : 'Applied for this process only: no settings service is available to save it; set it in the profile patch to keep it.' + +/** + * Build the command definition. + * @param deps - configuration readers, client factory, resolver and persistence. + */ +export function qoderCloudCommand(deps: CommandDeps): CommandDefinition { + return { + name: COMMAND_NAME, + description: 'Show or change the Qoder Cloud environment and agent used for delegated tasks', + input: { hint: '[env|agent []|reset]' }, + handler: async ({ rawInput, signal }): Promise => { + const [sub = 'status', ...rest] = rawInput.trim().split(/\s+/).filter(Boolean) + const argument = rest.join(' ') + try { + switch (sub) { + case 'status': + return await status(deps, signal) + case 'env': + case 'environment': + return argument === '' ? await listEnvironments(deps, signal) : await useEnvironment(deps, argument, signal) + case 'agent': + return argument === '' ? await listAgents(deps, signal) : await useAgent(deps, argument, signal) + case 'reset': { + deps.resolver.forget() + const ok = await deps.persist({ environmentId: undefined, agentId: undefined }) + return { kind: 'success', text: `Cleared the saved environment and agent; the next delegation will choose again.\n${saved(ok)}` } + } + case 'help': + return { kind: 'success', text: USAGE } + default: + return { kind: 'error', text: `Unknown subcommand "${sub}".\n${USAGE}` } + } + } catch (error: unknown) { + return { kind: 'error', text: error instanceof Error ? error.message : String(error) } + } + }, + } +} + +async function clientOrError(deps: CommandDeps): Promise { + const client = await deps.client() + if (typeof client === 'string') throw new Error(client) + return client +} + +async function status(deps: CommandDeps, signal: AbortSignal): Promise { + const { environmentId, agentId } = deps.configured() + const lines = [`Gateway: ${deps.baseURL}`] + const client = await deps.client() + if (typeof client === 'string') { + lines.push(`Token: ${client}`) + } else { + const [envs, agents] = await Promise.all([client.listEnvironments(signal), client.listAgents(signal)]) + const env = envs.data.find(item => item.id === environmentId) + const agent = agents.data.find(item => item.id === agentId) + lines.push(environmentId === undefined + ? 'Environment: not chosen (the next delegation asks, or uses the only environment)' + : `Environment: ${env === undefined ? `${environmentId} (not found on the platform)` : `${env.name} (${env.id}) — ${describeEnvironment(env)}`}`) + lines.push(agentId === undefined + ? `Agent: not chosen (the next delegation uses "${deps.managedAgentName}" or asks)` + : `Agent: ${agent === undefined ? `${agentId} (not found on the platform)` : `${agent.name} (${agent.id})`}`) + } + lines.push('', USAGE) + return { kind: 'success', text: lines.join('\n') } +} + +async function listEnvironments(deps: CommandDeps, signal: AbortSignal): Promise { + const client = await clientOrError(deps) + const current = deps.configured().environmentId + const envs = (await client.listEnvironments(signal)).data.filter(env => !env.archived_at) + if (envs.length === 0) return { kind: 'success', text: 'No environments yet; the next delegation creates "dsh-default".' } + const rows = envs.map(env => `${env.id === current ? '*' : ' '} ${env.id} ${env.name} (${describeEnvironment(env)})`) + return { kind: 'success', text: ['Environments (* = current):', ...rows, '', 'Use one with /qoder-cloud-agents env '].join('\n') } +} + +async function useEnvironment(deps: CommandDeps, text: string, signal: AbortSignal): Promise { + const client = await clientOrError(deps) + const envs = (await client.listEnvironments(signal)).data.filter(env => !env.archived_at) + const match = matchByIdOrName(envs, text, 'environment') + if (typeof match === 'string') return { kind: 'error', text: match } + deps.resolver.remember({ environmentId: match.id }) + const ok = await deps.persist({ environmentId: match.id }) + const warning = match.config?.type === 'self_hosted' + ? '\nNote: this is a self-hosted environment; delegations wait until one of its workers is online.' + : '' + return { kind: 'success', text: `Environment set to ${match.name} (${match.id}).${warning}\n${saved(ok)}` } +} + +async function listAgents(deps: CommandDeps, signal: AbortSignal): Promise { + const client = await clientOrError(deps) + const current = deps.configured().agentId + const agents = (await client.listAgents(signal)).data.filter(agent => !agent.archived_at) + const rows = agents.map(agent => `${agent.id === current ? '*' : ' '} ${agent.id} ${agent.name}${typeof agent.model === 'string' ? ` (model ${agent.model})` : ''}`) + return { + kind: 'success', + text: ['Agents (* = current):', ...rows, '', `Use one with /qoder-cloud-agents agent , or /qoder-cloud-agents agent new for "${deps.managedAgentName}"`].join('\n'), + } +} + +async function useAgent(deps: CommandDeps, text: string, signal: AbortSignal): Promise { + const client = await clientOrError(deps) + let agent + if (text === 'new') { + agent = await deps.resolver.createManagedAgent(client, signal) + } else { + const agents = (await client.listAgents(signal)).data.filter(item => !item.archived_at) + const match = matchByIdOrName(agents, text, 'agent') + if (typeof match === 'string') return { kind: 'error', text: match } + agent = match + } + deps.resolver.remember({ agentId: agent.id }) + const ok = await deps.persist({ agentId: agent.id }) + return { kind: 'success', text: `Agent set to ${agent.name} (${agent.id}).\n${saved(ok)}` } +} diff --git a/demos/dsh-qoder-cloud-agents/src/git.ts b/demos/dsh-qoder-cloud-agents/src/git.ts new file mode 100644 index 0000000..9e95b78 --- /dev/null +++ b/demos/dsh-qoder-cloud-agents/src/git.ts @@ -0,0 +1,142 @@ +/** + * Describe the delegating workspace's git checkout so the cloud sandbox can + * mount the same repository. The cloud agent never sees local files: only + * what is reachable on the remote (pushed commits) travels. + * + * @module dsh-qoder-cloud-agents/git + */ + +import { execFile } from 'node:child_process' + +export interface LocalRepository { + /** HTTPS clone URL derived from `remote.origin.url` (no credentials). */ + readonly url: string + /** `github.com` remotes map to the `github_repository` resource type. */ + readonly github: boolean + /** Repository directory name. */ + readonly name: string + /** Where the sandbox mounts it; the console's convention `/data/workspace/`. */ + readonly mountPath: string + /** Account name an `https://user@host/...` origin carries (never `git`), for authenticated non-GitHub clones. */ + readonly remoteUsername?: string + /** Current branch, when HEAD is attached and the branch exists on origin. */ + readonly branch?: string + /** HEAD commit. */ + readonly head: string + /** Checkout to request: the pushed branch, else the HEAD commit. */ + readonly checkout: { type: 'branch'; name: string } | { type: 'commit'; sha: string } + /** Local state the cloud agent cannot see. */ + readonly warnings: readonly string[] +} + +type Git = (args: readonly string[]) => Promise + +function gitIn(cwd: string, signal?: AbortSignal): Git { + return args => new Promise((resolve) => { + execFile('git', args, { + cwd, + timeout: 10_000, + ...signal === undefined ? {} : { signal }, + env: { ...process.env, GIT_TERMINAL_PROMPT: '0' }, + }, (error, stdout) => { + resolve(error === null ? stdout.trim() : undefined) + }) + }) +} + +/** + * Normalize a git remote to an HTTPS URL without embedded credentials. + * Accepts `https://`, `ssh://git@host[:port]/path` and scp-like `git@host:path`. + * @param remote - raw `remote.origin.url`. + * @returns the HTTPS URL, or `undefined` for local/unsupported remotes. + */ +export function httpsRemote(remote: string): string | undefined { + const trimmed = remote.trim() + const scp = /^[\w.-]+@([\w.-]+):(?!\/)(.+)$/.exec(trimmed) + if (scp !== null) return `https://${scp[1]}/${scp[2]}` + let url: URL + try { + url = new URL(trimmed) + } catch { + return undefined + } + if (url.protocol === 'ssh:' || url.protocol === 'git+ssh:') { + return `https://${url.hostname}${url.pathname}` + } + if (url.protocol !== 'https:' && url.protocol !== 'http:') return undefined + url.username = '' + url.password = '' + return url.toString() +} + +/** Mount root the Qoder console uses for repositories (environment-manager's code workspace). */ +export const WORKSPACE_ROOT = '/data/workspace' + +/** + * The account name of an HTTP(S) remote such as `https://alice@code.example.com/g/r.git`. + * SSH remotes (`git@…`) carry a transport user, not an account, so they yield nothing. + */ +export function httpsRemoteUsername(remote: string): string | undefined { + let url: URL + try { + url = new URL(remote.trim()) + } catch { + return undefined + } + if (url.protocol !== 'https:' && url.protocol !== 'http:') return undefined + const username = decodeURIComponent(url.username) + return username.length > 0 && username !== 'git' ? username : undefined +} + +/** + * Inspect `cwd` as a git checkout. + * @param cwd - the delegating session's working directory. + * @param signal - cancellation. + * @returns the repository description, or `undefined` when `cwd` is not a + * checkout with a usable `origin` remote. + */ +export async function detectRepository(cwd: string, signal?: AbortSignal): Promise { + const git = gitIn(cwd, signal) + const top = await git(['rev-parse', '--show-toplevel']) + if (top === undefined) return undefined + const remote = await git(['config', '--get', 'remote.origin.url']) + const url = remote === undefined ? undefined : httpsRemote(remote) + const remoteUsername = remote === undefined ? undefined : httpsRemoteUsername(remote) + const head = await git(['rev-parse', 'HEAD']) + if (url === undefined || head === undefined) return undefined + + const warnings: string[] = [] + const branchName = await git(['symbolic-ref', '--quiet', '--short', 'HEAD']) + let branch: string | undefined + if (branchName !== undefined && branchName.length > 0) { + const remoteHead = await git(['rev-parse', '--verify', '--quiet', `refs/remotes/origin/${branchName}`]) + if (remoteHead !== undefined) { + branch = branchName + if (remoteHead !== head) { + const ahead = await git(['rev-list', '--count', `refs/remotes/origin/${branchName}..HEAD`]) + if (ahead !== undefined && ahead !== '0') { + warnings.push(`${ahead} local commit(s) on ${branchName} are not pushed to origin; the cloud agent works from origin/${branchName}.`) + } + } + } else { + warnings.push(`branch ${branchName} has no origin counterpart (last fetched state); the cloud agent starts from the default branch and fetches commit ${head.slice(0, 12)}, which must exist on origin.`) + } + } + const dirty = await git(['status', '--porcelain', '--untracked-files=no']) + if (dirty !== undefined && dirty.length > 0) { + warnings.push('the local working tree has uncommitted changes that the cloud agent cannot see.') + } + + const name = (url.replace(/\/+$/, '').split('/').pop() ?? 'repo').replace(/\.git$/, '') || 'repo' + return { + url, + github: new URL(url).hostname.toLowerCase() === 'github.com', + name, + mountPath: `${WORKSPACE_ROOT}/${name}`, + ...remoteUsername === undefined ? {} : { remoteUsername }, + ...branch === undefined ? {} : { branch }, + head, + checkout: branch === undefined ? { type: 'commit', sha: head } : { type: 'branch', name: branch }, + warnings, + } +} diff --git a/demos/dsh-qoder-cloud-agents/src/github.ts b/demos/dsh-qoder-cloud-agents/src/github.ts new file mode 100644 index 0000000..1041c57 --- /dev/null +++ b/demos/dsh-qoder-cloud-agents/src/github.ts @@ -0,0 +1,89 @@ +/** + * Pre-flight check for GitHub repositories, run on the delegating machine + * before a cloud session is created: the platform mounts repositories + * silently, so a private repository without a usable token would otherwise + * surface only as a missing directory inside the sandbox. + * + * @module dsh-qoder-cloud-agents/github + */ + +/** Outcome of the pre-flight check. */ +export interface GitHubAccess { + /** Fatal: the session would not be able to mount the repository. */ + readonly error?: string + /** Non-fatal notes for the run result. */ + readonly warnings: readonly string[] +} + +/** + * Parse `https://github.com//(.git)`. + * @returns owner and repo, or `undefined` for other URLs. + */ +export function githubSlug(url: string): { owner: string; repo: string } | undefined { + let parsed: URL + try { + parsed = new URL(url) + } catch { + return undefined + } + if (parsed.hostname.toLowerCase() !== 'github.com') return undefined + const [owner, repo] = parsed.pathname.replace(/^\/+|\/+$/g, '').replace(/\.git$/, '').split('/') + return owner && repo ? { owner, repo } : undefined +} + +/** + * Ask the GitHub API whether the repository is reachable with `token` and + * whether it can be pushed to. Network failures are not fatal: the check is + * advisory and the platform has the final word. + * @param url - HTTPS clone URL. + * @param token - git token handed to the sandbox, if any. + * @param tokenEnv - credential name, for messages. + * @param signal - cancellation. + * @param fetchImpl - injected for tests. + */ +export async function checkGitHubAccess( + url: string, + token: string | undefined, + tokenEnv: string, + signal: AbortSignal, + fetchImpl: typeof fetch = fetch, +): Promise { + const slug = githubSlug(url) + if (slug === undefined) return { warnings: [] } + let response: Response + try { + response = await fetchImpl(`https://api.github.com/repos/${slug.owner}/${slug.repo}`, { + headers: { + Accept: 'application/vnd.github+json', + 'User-Agent': 'dsh-qoder-cloud-agents', + ...token === undefined ? {} : { Authorization: `Bearer ${token}` }, + }, + signal: AbortSignal.any([signal, AbortSignal.timeout(10_000)]), + }) + } catch { + if (signal.aborted) throw signal.reason + return { warnings: ['could not reach api.github.com to check repository access; continuing.'] } + } + if (response.status === 401) { + return { error: `the GitHub token in ${tokenEnv} was rejected (401); fix or remove it`, warnings: [] } + } + if (response.status === 404) { + return { + error: token === undefined + ? `${slug.owner}/${slug.repo} is private or does not exist; set ${tokenEnv} to a GitHub token with access to it` + : `the GitHub token in ${tokenEnv} cannot see ${slug.owner}/${slug.repo} (404); grant it access to this repository`, + warnings: [], + } + } + if (!response.ok) { + return { warnings: [`GitHub repository check returned HTTP ${response.status}; continuing.`] } + } + const body = await response.json().catch(() => ({})) as { permissions?: { push?: boolean } } + if (token === undefined) { + return { warnings: [`no ${tokenEnv} is set: the cloud agent can read this public repository but cannot push its branch.`] } + } + if (body.permissions?.push === false) { + return { warnings: [`the token in ${tokenEnv} has no push access to ${slug.owner}/${slug.repo}: the cloud agent cannot push its branch.`] } + } + return { warnings: [] } +} diff --git a/demos/dsh-qoder-cloud-agents/src/index.ts b/demos/dsh-qoder-cloud-agents/src/index.ts new file mode 100644 index 0000000..4908017 --- /dev/null +++ b/demos/dsh-qoder-cloud-agents/src/index.ts @@ -0,0 +1,317 @@ +/** + * Profile-named Qoder Cloud Agents subagent provider. Every accepted run + * creates a Qoder Cloud session — mounting the delegating workspace's git + * repository when there is one — sends the task, and returns the cloud + * agent's final message to the parent when the turn settles. + * + * The environment and agent come from explicit config; otherwise the first + * interactive delegation asks the user and saves the answer to the profile + * (see ./target.ts), and `/qoder-cloud-agents` changes it later. + * + * @module dsh-qoder-cloud-agents + */ + +import type { Context, Volatile } from '@deepseek-ai/cordis' +import z from '@deepseek-ai/schemastery' +import { credentialRef } from '@deepseek-ai/dsh-credentials' +import { launchEnvironmentOf } from '@deepseek-ai/dsh-launch-environment' +import { + NO_START_CAPABILITIES, + assertPositiveFinite, + assertUsableCwd, + type ResolvedSubagentStartRequest, + type SubagentCapabilities, + type SubagentProvider, +} from '@deepseek-ai/dsh-subagent' +import type {} from '@deepseek-ai/dsh-commands' +import type {} from '@deepseek-ai/dsh-settings' +import type {} from '@deepseek-ai/dsh-user-questions' +import type {} from '@deepseek-ai/dsh-llm' +import { DEFAULT_BASE_URL, QoderCloudClient } from './client.ts' +import { CLOUD_PROVIDER, QoderCloudAdapter, type CloudTurnContext } from './cloud-mode.ts' +import { qoderCloudCommand } from './command.ts' +import { DEFAULT_TIMEOUT_MS, startQoderCloudRun } from './run.ts' +import { TargetResolver, type Asker, type Selection } from './target.ts' + +export { QoderCloudClient, QoderCloudError } from './client.ts' +export { detectRepository, httpsRemote } from './git.ts' +export { SelectionRequiredError } from './target.ts' +export { CLOUD_MODEL, CLOUD_PRESET_ID, CLOUD_PROVIDER, QoderCloudAdapter } from './cloud-mode.ts' + +export const name = 'qoder-cloud-agents' +export const inject = ['subagents'] + +const DEFAULT_PROVIDER_NAME = 'qoder-cloud-agents' +const DEFAULT_AGENT_NAME = 'dsh-qoder-cloud-delegate' +/** Row id this package's bundle patch inserts; fallback when no Loader entry is known. */ +const DEFAULT_ENTRY_ID = 'qoder-cloud-agents' +const MAX_TIMER_DELAY_MS = 2_147_483_647 + +const DEFAULT_SYSTEM = [ + 'You are a coding agent running in a Qoder Cloud sandbox on behalf of another agent (DeepSeek Harness).', + 'Work autonomously: nobody can answer questions mid-task.', + 'Your final message is returned verbatim to the delegating agent, so make it a self-contained report.', +].join(' ') + +export interface Config { + /** Provider name on `ctx.subagents` (default `qoder-cloud-agents`). */ + providerName?: string + /** Gateway base URL (default `https://api.qoder.com/api/v1/cloud`). */ + baseURL?: string + /** Credential / environment variable holding the Qoder PAT (default `QODER_PAT`). */ + tokenEnv?: string + /** Literal PAT; prefer {@link tokenEnv} so no secret enters configuration files. */ + token?: string + /** Cloud agent (`agent_…`); unset: the plugin-managed agent, or ask in an interactive UI. Live-editable. */ + agentId?: Volatile + /** Name of the plugin-managed cloud agent. */ + agentName?: string + /** Model of the plugin-managed cloud agent (default `ultimate`). */ + model?: string + /** System prompt of the plugin-managed cloud agent. */ + system?: string + /** Cloud environment (`env_…`); unset: ask in an interactive UI, fail when ambiguous headless. Live-editable. */ + environmentId?: Volatile + /** `auto` mounts the cwd's git `origin` in the sandbox; `none` sends the task only. */ + repository?: 'auto' | 'none' + /** + * Credential / environment variable holding a git token for clone and push (default `QODER_GIT_TOKEN`): + * a GitHub PAT, or a personal access token of the repository's Git host. + */ + gitTokenEnv?: string + /** Account for authenticated non-GitHub repositories (your user name on that Git host); default: the origin URL's user. */ + gitUsername?: string + /** Prefix of the branch the cloud agent pushes its changes to. */ + branchPrefix?: string + /** Answer to tool calls paused by the cloud agent's `always_ask` policy. */ + toolConfirmation?: 'allow' | 'deny' + /** Extra sandbox environment variables for every session. */ + environmentVariables?: Record + /** Archive the cloud session after the turn settles (default keeps it for inspection). */ + archiveOnFinish?: boolean + /** Ceiling for one delegated turn in milliseconds (default 2 h). */ + timeoutMs?: number + /** Extra gateway headers. */ + headers?: Record +} + +export const Config: z = z.object({ + providerName: z.string().min(1).default(DEFAULT_PROVIDER_NAME), + baseURL: z.string().min(1).default(DEFAULT_BASE_URL), + tokenEnv: z.string().role('credential-ref').default('QODER_PAT'), + token: z.string().role('secret'), + agentId: z.string().min(1).volatile(), + agentName: z.string().min(1).default(DEFAULT_AGENT_NAME), + model: z.string().min(1).default('ultimate'), + system: z.string().default(DEFAULT_SYSTEM), + environmentId: z.string().min(1).volatile(), + repository: z.union(['auto', 'none'] as const).default('auto'), + gitTokenEnv: z.string().role('credential-ref').default('QODER_GIT_TOKEN'), + gitUsername: z.string().min(1), + branchPrefix: z.string().min(1).default('qoder-cloud-agents/'), + toolConfirmation: z.union(['allow', 'deny'] as const).default('allow'), + environmentVariables: z.dict(z.string()).default({}), + archiveOnFinish: z.boolean().default(false), + timeoutMs: z.number().default(DEFAULT_TIMEOUT_MS), + headers: z.dict(z.string()).default({}), +}) as z + +/** Config after Cordis applied the schema defaults. */ +type ResolvedConfig = Required> + & Pick + +/** + * Resolve a secret by credential name: the credential seam when mounted, else + * the launch environment. Resolved per run so rotation applies immediately. + */ +async function resolveSecret(ctx: Context, name: string): Promise { + const ref = credentialRef(name) + const credentials = ctx.get('credentials') + if (credentials !== undefined) { + const hit = (await credentials.resolve(ref))?.value + if (hit !== undefined && hit.length > 0) return hit + } + // Without a mounted launch environment this falls back to process.env. + const ambient = launchEnvironmentOf(ctx).get(ref)?.value + return ambient !== undefined && ambient.length > 0 ? ambient : undefined +} + +/** Read a volatile field whether Cordis wrapped it or a caller passed a plain value. */ +function live(value: Volatile | string | undefined): string | undefined { + if (value === undefined || typeof value === 'string') return value + return value.get() +} + +/** + * The delegating workspace. dsh 0.2.1+ resolves `request.cwd`; 0.2.0 has no + * such field, so fall back to the parent session's working directory. + */ +function requestCwd(ctx: Context, request: ResolvedSubagentStartRequest): string { + const explicit = (request as { cwd?: unknown }).cwd + if (typeof explicit === 'string') return explicit + const session = (request.parent as { session?: unknown } | undefined)?.session + return (session === undefined ? undefined : sessionCwd(ctx, session)) ?? process.cwd() +} + +/** A session's working directory: the workingDirectory service, else its header. */ +function sessionCwd(ctx: Context, session: unknown): string | undefined { + const service = (ctx as unknown as { get(name: string): unknown }).get('workingDirectory') as + { get?(session: unknown): unknown } | undefined + const fromService = service?.get?.(session) + if (typeof fromService === 'string') return fromService + const header = (session as { header?: { cwd?: unknown } }).header + return typeof header?.cwd === 'string' ? header.cwd : undefined +} + +/** Live root agent of a dsh session, the one user questions must be addressed to. */ +function rootAgentOf(ctx: Context, sessionId: string): { session: unknown } | undefined { + const agents = (ctx as unknown as { get(name: string): unknown }).get('agents') as + { roots?(): readonly { session: { id: unknown } }[] } | undefined + return agents?.roots?.().find(agent => agent.session.id === sessionId) +} + +class QoderCloudProvider implements SubagentProvider { + readonly capabilities: SubagentCapabilities = NO_START_CAPABILITIES + readonly inheritsParentContext = false + + constructor( + readonly name: string, + private readonly ctx: Context, + private readonly config: ResolvedConfig, + private readonly resolver: TargetResolver, + private readonly client: () => Promise, + ) {} + + async start(request: ResolvedSubagentStartRequest) { + const cwd = assertUsableCwd('qoder-cloud-agents', 'child cwd', requestCwd(this.ctx, request)) + const client = await this.client() + if (typeof client === 'string') throw new Error(`qoder-cloud-agents: ${client}`) + const questions = this.ctx.get('userQuestions') + const asker: Asker | undefined = questions === undefined + ? undefined + : (items, signal) => questions.ask({ agent: request.parent, signal, questions: items }) + const gitToken = this.config.repository === 'auto' + ? await resolveSecret(this.ctx, this.config.gitTokenEnv) + : undefined + return startQoderCloudRun({ + cwd, + prompt: request.prompt, + label: request.label, + signal: request.signal, + }, { + client, + resolveTarget: signal => this.resolver.resolve(client, asker, signal), + repository: this.config.repository, + gitToken, + gitTokenEnv: this.config.gitTokenEnv, + gitUsername: this.config.gitUsername, + branchPrefix: this.config.branchPrefix, + toolConfirmation: this.config.toolConfirmation, + environmentVariables: this.config.environmentVariables, + archiveOnFinish: this.config.archiveOnFinish, + timeoutMs: this.config.timeoutMs, + onError: (error, stopReason) => { + this.ctx.logger.warn(`qoder-cloud-agents "${this.name}": run failed (${stopReason}): %o`, error) + }, + }) + } +} + +/** + * Register one Profile-named Qoder Cloud provider and the `/qoder-cloud-agents` command. + * @param ctx - context carrying the shared subagent service. + * @param config - endpoint, credentials, agent / environment binding and run policy. + */ +export function apply(ctx: Context, config: Config): void { + const resolved = config as ResolvedConfig + assertPositiveFinite('qoder-cloud-agents', 'timeoutMs', resolved.timeoutMs) + if (resolved.timeoutMs > MAX_TIMER_DELAY_MS) { + throw new Error(`qoder-cloud-agents: timeoutMs must be no greater than ${MAX_TIMER_DELAY_MS}`) + } + try { + new URL(resolved.baseURL) + } catch { + throw new Error(`qoder-cloud-agents: baseURL is not a valid URL: ${resolved.baseURL}`) + } + + const loaderEntryId = (ctx.fiber as { entry?: { options?: { id?: string } } }).entry?.options?.id + const entryId = loaderEntryId ?? DEFAULT_ENTRY_ID + const configured = (): Selection => ({ + environmentId: live(resolved.environmentId), + agentId: live(resolved.agentId), + }) + + /** Save into this entry's profile layer through Settings (live: volatile fields). */ + const persist = async (selection: Selection): Promise => { + const settings = ctx.get('settings') + if (settings === undefined) return false + const ops = Object.entries(selection).map(([key, value]) => value === undefined + ? { op: 'unset' as const, path: [key] } + : { op: 'set' as const, path: [key], value }) + if (ops.length === 0) return true + try { + if (!settings.describe().some(form => form.ns === entryId)) return false + await settings.mutate(entryId, ops) + return true + } catch (error: unknown) { + ctx.logger.warn('qoder-cloud-agents: could not save the selection to the profile: %o', error) + return false + } + } + + const client = async (): Promise => { + const token = resolved.token ?? await resolveSecret(ctx, resolved.tokenEnv) + if (token === undefined) { + return `no Qoder PAT — set ${resolved.tokenEnv} (environment, .env, or dsh credentials)` + } + return new QoderCloudClient({ baseURL: resolved.baseURL, token, headers: resolved.headers }) + } + + const resolver = new TargetResolver({ + configured, + agentName: resolved.agentName, + model: resolved.model, + system: resolved.system, + entryId, + persist, + }) + + ctx.subagents.registerProvider(new QoderCloudProvider(resolved.providerName, ctx, resolved, resolver, client)) + + // Cloud mode: the `qoder-cloud-agents` model route the 「云端模式」 preset pins. + const turnContext = (sessionId: string | undefined): CloudTurnContext => { + const agent = sessionId === undefined ? undefined : rootAgentOf(ctx, sessionId) + const questions = ctx.get('userQuestions') + return { + cwd: agent === undefined ? undefined : sessionCwd(ctx, agent.session), + asker: agent === undefined || questions === undefined + ? undefined + : (items, signal) => questions.ask({ agent: agent as never, signal, questions: items }), + } + } + ctx.inject(['llm'], (scope) => { + scope.llm.registerAdapter([CLOUD_PROVIDER], new QoderCloudAdapter({ + client, + resolver, + turnContext, + repository: resolved.repository, + gitToken: () => resolveSecret(ctx, resolved.gitTokenEnv), + gitTokenEnv: resolved.gitTokenEnv, + gitUsername: resolved.gitUsername, + branchPrefix: resolved.branchPrefix, + toolConfirmation: resolved.toolConfirmation, + environmentVariables: resolved.environmentVariables, + })) + }) + + ctx.inject(['commands'], (scope) => { + scope.commands.register(qoderCloudCommand({ + configured, + baseURL: resolved.baseURL, + client, + resolver, + persist, + managedAgentName: resolved.agentName, + })) + }) +} diff --git a/demos/dsh-qoder-cloud-agents/src/run.ts b/demos/dsh-qoder-cloud-agents/src/run.ts new file mode 100644 index 0000000..27492d5 --- /dev/null +++ b/demos/dsh-qoder-cloud-agents/src/run.ts @@ -0,0 +1,414 @@ +/** + * One-shot Qoder Cloud run: create a cloud session (optionally mounting the + * delegating workspace's git repository), send the task as one user message, + * follow the session SSE stream until the turn settles, and map the outcome + * onto the shared subagent result. + * + * @module dsh-qoder-cloud-agents/run + */ + +import { randomUUID } from 'node:crypto' +import type { ContentBlock } from '@deepseek-ai/dsh-llm' +import type { SessionId } from '@deepseek-ai/dsh-session' +import { + settleRunResult, + subprocessRunHandle, + type SubagentResult, + type SubagentRun, + type SubagentStopReason, +} from '@deepseek-ai/dsh-subagent' +import { + delay, + type QoderCloudClient, + type SessionEvent, + type SessionResource, +} from './client.ts' +import { detectRepository, type LocalRepository } from './git.ts' +import { checkGitHubAccess } from './github.ts' +import type { QoderCloudTarget } from './target.ts' + +/** Default ceiling for one delegated turn. */ +export const DEFAULT_TIMEOUT_MS = 2 * 60 * 60 * 1000 + +/** Consecutive stream failures tolerated before the run fails. */ +const MAX_STREAM_FAILURES = 6 + +/** Provider-owned settings for one run. */ +export interface QoderCloudRunSpec { + readonly client: QoderCloudClient + readonly resolveTarget: (signal: AbortSignal) => Promise + /** `auto` mounts the cwd's origin repository when there is one. */ + readonly repository: 'auto' | 'none' + /** Token the sandbox uses to clone and push the mounted repository. */ + readonly gitToken?: string | undefined + /** Credential name of {@link gitToken}, for messages. */ + readonly gitTokenEnv?: string | undefined + /** Account for authenticated non-GitHub clones (your user name on that Git host); else the origin URL's user. */ + readonly gitUsername?: string | undefined + /** Prefix of the branch the cloud agent is asked to push. */ + readonly branchPrefix: string + /** Answer for tool calls the cloud agent's permission policy pauses on. */ + readonly toolConfirmation: 'allow' | 'deny' + readonly environmentVariables: Readonly> + readonly archiveOnFinish: boolean + readonly timeoutMs: number + /** Diagnostic sink; a throw from it is contained. */ + readonly onError?: ((error: Error, stopReason: SubagentStopReason) => void) | undefined +} + +/** The request fields this backend reads. */ +export interface QoderCloudRunRequest { + readonly cwd: string + readonly prompt: readonly ContentBlock[] + readonly label?: string | undefined + readonly signal: AbortSignal +} + +/** + * Join the delegated task's text blocks; the cloud session receives text only. + * @param prompt - the subagent prompt. + * @returns the task text. + */ +export function textTask(prompt: readonly ContentBlock[]): string { + const texts: string[] = [] + for (const block of prompt) { + if (block.type !== 'text') { + throw new Error('qoder-cloud-agents: the delegated task must contain only text blocks') + } + texts.push(block.text) + } + const text = texts.join('\n') + if (text.trim().length === 0) throw new Error('qoder-cloud-agents: the delegated task must not be empty') + return text +} + +/** + * Compose the cloud-side message: the task plus how to hand changes back. + * @param task - delegated task text. + * @param repo - mounted repository, if any. + * @param resultBranch - branch the agent should push. + */ +export function cloudPrompt(task: string, repo: LocalRepository | undefined, resultBranch: string | undefined): string { + if (repo === undefined || resultBranch === undefined) return task + const at = repo.checkout.type === 'branch' + ? `checked out at branch \`${repo.checkout.name}\`` + : `checked out at its default branch; before working, run \`git fetch origin ${repo.checkout.sha} && git checkout ${repo.checkout.sha}\` there` + return [ + task, + '', + '---', + 'Workspace handed over from the delegating DeepSeek Harness session:', + `- The git repository ${repo.url} is mounted in this sandbox at \`${repo.mountPath}\` (in a self-hosted environment: \`workspace/${repo.name}\` under your working directory), ${at}.`, + `- First check that the mounted repository exists. If it does not, the platform failed to mount it (unreachable host or missing/invalid token): stop immediately and report that, without cloning it yourself or doing any other work.`, + `- If you change files, commit them on a new branch named \`${resultBranch}\` and \`git push -u origin ${resultBranch}\`. Do not push to any other branch.`, + '- Your final message is returned to the delegating agent verbatim: summarize what you did, and state the pushed branch name (or that nothing was pushed).', + ].join('\n') +} + +function messageText(content: unknown): string { + if (typeof content === 'string') return content + if (!Array.isArray(content)) return '' + return content + .filter((block): block is { type: 'text'; text: string } => + typeof block === 'object' && block !== null && block.type === 'text' && typeof block.text === 'string') + .map(block => block.text) + .join('') +} + +/** What the stream observed, folded for the final answer. */ +class TurnFold { + finalText: string | undefined + errorMessage: string | undefined + stopReason: string | undefined + readonly artifacts: { name: string; fileId: string; size?: number }[] = [] + readonly pendingTools = new Map() + + push(event: SessionEvent): void { + switch (event.type) { + case 'agent.message': { + const text = messageText(event.content) + if (text.trim().length > 0) this.finalText = text + break + } + case 'agent.tool_use': + case 'agent.mcp_tool_use': + case 'agent.custom_tool_use': + this.pendingTools.set(event.id, event.type) + break + case 'agent.artifact_delivered': + if (typeof event.file_id === 'string') { + this.artifacts.push({ + name: event.original_filename ?? event.file_id, + fileId: event.file_id, + ...typeof event.size === 'number' ? { size: event.size } : {}, + }) + } + break + case 'session.error': + if (event.error?.message !== undefined) this.errorMessage = event.error.message + break + default: + break + } + } +} + +/** + * Map the workspace repository onto a session resource the way the Qoder + * console does: GitHub takes a bare URL plus an optional token; any other + * host authenticates with the account in the URL and the token as password, + * both or neither (the Qoder Cloud API rejects one without the other). + */ +export function repositoryResource( + repo: LocalRepository, + spec: Pick, +): SessionResource { + // The platform drops commit checkouts; the prompt has the agent fetch the commit instead. + const checkout = repo.checkout.type === 'branch' ? { checkout: repo.checkout } : {} + if (repo.github) { + return { + type: 'github_repository', + url: repo.url, + mount_path: repo.mountPath, + ...checkout, + ...spec.gitToken === undefined ? {} : { authorization_token: spec.gitToken }, + } + } + if (spec.gitToken === undefined) { + return { type: 'git_repository', url: repo.url, mount_path: repo.mountPath, ...checkout } + } + const username = spec.gitUsername ?? repo.remoteUsername + if (username === undefined) { + const host = new URL(repo.url).host + throw new Error( + `qoder-cloud-agents: ${host} needs an account name with ${spec.gitTokenEnv ?? 'the git token'}; ` + + 'set gitUsername in the plugin config ' + + `or use an origin like https://@${host}/…`, + ) + } + const url = new URL(repo.url) + url.username = encodeURIComponent(username) + const token = spec.gitToken + return { type: 'git_repository', url: url.toString(), password: token, mount_path: repo.mountPath, ...checkout } +} + +const STOP_REASONS: Readonly> = { + end_turn: 'completed', + cancelled: 'aborted', + max_tokens: 'max-tokens', + refusal: 'refusal', + error: 'error', + retries_exhausted: 'error', + terminated: 'error', +} + +/** + * Start one Qoder Cloud session and publish its one-shot run. Session creation + * and the first message happen before publication, so a platform rejection + * (auth, quota, bad repository) fails the delegation call itself. + * @param request - resolved subagent request. + * @param spec - client, binding and run policy. + * @returns the published run. + */ +export async function startQoderCloudRun( + request: QoderCloudRunRequest, + spec: QoderCloudRunSpec, +): Promise { + const task = textTask(request.prompt) + if (request.signal.aborted) throw new Error('qoder-cloud-agents: request was aborted before session start') + + const controller = new AbortController() + const requestCancel = (): void => { + if (!controller.signal.aborted) controller.abort(new Error('qoder-cloud-agents: run cancelled locally')) + } + const onAbort = (): void => { requestCancel() } + request.signal.addEventListener('abort', onAbort, { once: true }) + const { client } = spec + + let sessionId: string | undefined + let lastEventId: string | undefined + let repo: LocalRepository | undefined + let resultBranch: string | undefined + let target: QoderCloudTarget | undefined + const preflightNotes: string[] = [] + try { + repo = spec.repository === 'auto' ? await detectRepository(request.cwd, controller.signal) : undefined + if (repo?.github) { + // The platform clones silently and lazily; catch an unusable token here. + const access = await checkGitHubAccess(repo.url, spec.gitToken, spec.gitTokenEnv ?? 'QODER_GIT_TOKEN', controller.signal) + if (access.error !== undefined) throw new Error(`qoder-cloud-agents: ${access.error}`) + preflightNotes.push(...access.warnings) + } + // Build resources before resolving the target so a credential mistake fails before any prompt. + const resources: SessionResource[] = [] + if (repo !== undefined) { + resultBranch = `${spec.branchPrefix}${randomUUID().slice(0, 8)}` + resources.push(repositoryResource(repo, spec)) + } + target = await spec.resolveTarget(controller.signal) + const title = (request.label ?? task.split('\n')[0] ?? 'DeepSeek Harness task').slice(0, 120) + const session = await client.createSession({ + agent: target.agent, + environment_id: target.environmentId, + title, + metadata: { source: 'deepseek-harness' }, + ...resources.length === 0 ? {} : { resources }, + ...Object.keys(spec.environmentVariables).length === 0 + ? {} + : { environment_variables: { ...spec.environmentVariables } }, + }, controller.signal) + sessionId = session.id + const posted = await client.sendEvents(session.id, [{ + type: 'user.message', + content: [{ type: 'text', text: cloudPrompt(task, repo, resultBranch) }], + }], controller.signal) + lastEventId = posted.data.at(-1)?.id + } catch (error: unknown) { + request.signal.removeEventListener('abort', onAbort) + if (sessionId !== undefined) await bestEffort(() => client.archiveSession(sessionId!, AbortSignal.timeout(10_000))) + if (controller.signal.aborted) throw new Error('qoder-cloud-agents: request was aborted before session start') + throw error instanceof Error ? error : new Error(String(error)) + } + + const id = sessionId + const fold = new TurnFold() + let timedOut = false + const timer = setTimeout(() => { + timedOut = true + controller.abort(new Error('qoder-cloud-agents: turn timed out')) + }, spec.timeoutMs) + + const footer = (stopReason: string): string => { + const lines = [`[Qoder Cloud] session ${id} · stop_reason ${stopReason}`] + if (repo !== undefined) { + lines.push(`Repository: this workspace's origin ${repo.url} (${repo.checkout.type === 'branch' ? repo.checkout.name : repo.checkout.sha.slice(0, 12)}); requested result branch: ${resultBranch}`) + } + if (fold.artifacts.length > 0) { + lines.push(`Artifacts: ${fold.artifacts.map(a => `${a.name} (${a.fileId}${a.size === undefined ? '' : `, ${a.size} bytes`})`).join(', ')}`) + } + for (const note of target?.notes ?? []) lines.push(note) + for (const warning of [...repo?.warnings ?? [], ...preflightNotes]) lines.push(`Note: ${warning}`) + return lines.join('\n') + } + const output = (stopReason: string): ContentBlock[] => { + const body = fold.finalText ?? '(the cloud agent produced no final message)' + return [{ type: 'text', text: `${body}\n\n${footer(stopReason)}` }] + } + + const answerPause = async (eventIds: readonly string[]): Promise => { + for (const eventId of eventIds) { + const kind = fold.pendingTools.get(eventId) + const event = kind === 'agent.custom_tool_use' + ? { + type: 'user.custom_tool_result', + custom_tool_use_id: eventId, + content: [{ type: 'text', text: 'Custom tools are unavailable in an unattended DeepSeek Harness delegation.' }], + is_error: true, + } + : { + type: 'user.tool_confirmation', + tool_use_id: eventId, + result: spec.toolConfirmation, + ...spec.toolConfirmation === 'deny' + ? { deny_message: 'Denied by the unattended DeepSeek Harness delegation policy.' } + : {}, + } + await client.sendEvents(id, [event], controller.signal) + } + } + + const follow = async (): Promise => { + let failures = 0 + for (;;) { + try { + for await (const event of client.streamEvents(id, lastEventId, controller.signal)) { + failures = 0 + if (event.id !== undefined) lastEventId = event.id + fold.push(event) + if (event.type === 'session.status_idle') { + const reason = event.stop_reason?.type ?? 'end_turn' + if (reason === 'requires_action') { + await answerPause(event.stop_reason?.event_ids ?? []) + continue + } + fold.stopReason = reason + const stopReason = STOP_REASONS[reason] ?? 'completed' + return { + output: output(reason), + ...stopReason === 'error' ? { diagnostic: fold.errorMessage ?? `Qoder Cloud turn ended with ${reason}` } : {}, + stopReason, + } + } + if (event.type === 'session.status_terminated' || event.type === 'session.deleted') { + fold.stopReason = 'terminated' + return { + output: output('terminated'), + diagnostic: fold.errorMessage ?? `Qoder Cloud session ${id} was terminated`, + stopReason: 'error', + } + } + } + } catch (error: unknown) { + if (controller.signal.aborted) throw error + if (++failures >= MAX_STREAM_FAILURES) throw error + } + // The stream never closes on idle; an end or error is transport loss. + await delay(Math.min(1_000 * 2 ** failures, 15_000), controller.signal) + } + } + + const following = follow() + const result = settleRunResult({ + attempt: async () => { + try { + return await following + } catch (error: unknown) { + if (timedOut) throw new Error(`qoder-cloud-agents: turn exceeded ${spec.timeoutMs} ms`) + throw error + } finally { + clearTimeout(timer) + if (fold.stopReason !== undefined && spec.archiveOnFinish) { + await bestEffort(() => client.archiveSession(id, AbortSignal.timeout(10_000))) + } + } + }, + collectOutput: () => fold.finalText === undefined ? [] : output('cancelled'), + collectDiagnostic: () => timedOut + ? `Qoder Cloud session ${id} exceeded ${spec.timeoutMs} ms and was cancelled` + : fold.errorMessage ?? `Qoder Cloud session ${id}: stream failed`, + cancelled: () => controller.signal.aborted && !timedOut, + onError: spec.onError, + signal: request.signal, + onAbort, + }) + // A turn that did not settle remotely (local cancel, timeout, lost stream) + // is cancelled on the platform so the sandbox stops spending credits. + const remoteCleanup = result.then(async () => { + if (fold.stopReason !== undefined) return + await bestEffort(() => client.cancelSession(id, AbortSignal.timeout(10_000))) + if (spec.archiveOnFinish) await bestEffort(() => client.archiveSession(id, AbortSignal.timeout(10_000))) + }) + + return subprocessRunHandle({ + // Provider-minted run id; SessionId is a branded string. + id: randomUUID() as string as SessionId, + result, + signal: request.signal, + onAbort, + requestCancel, + teardown: async () => { + clearTimeout(timer) + await following.catch(() => {}) + await result + await remoteCleanup + }, + }) +} + +async function bestEffort(action: () => Promise): Promise { + try { + await action() + } catch { + // Remote cleanup is advisory; the local run already settled. + } +} diff --git a/demos/dsh-qoder-cloud-agents/src/sse.ts b/demos/dsh-qoder-cloud-agents/src/sse.ts new file mode 100644 index 0000000..3e5c795 --- /dev/null +++ b/demos/dsh-qoder-cloud-agents/src/sse.ts @@ -0,0 +1,82 @@ +/** + * Minimal Server-Sent Events frame parser for the Qoder Cloud session stream. + * Browser `EventSource` cannot send a Bearer header, so the stream is read + * through `fetch` and decoded here. + * + * @module dsh-qoder-cloud-agents/sse + */ + +/** One dispatched SSE frame. Comment-only frames (heartbeats) are dropped. */ +export interface SseFrame { + readonly id?: string + readonly event: string + readonly data: string +} + +/** + * Incremental parser: feed decoded text chunks, receive complete frames. + * Handles `\n`, `\r\n` and `\r` line endings and frames split across chunks. + */ +export class SseParser { + private buffer = '' + private id: string | undefined + private event: string | undefined + private data: string[] = [] + + /** + * Feed one decoded chunk. + * @param chunk - the next piece of the response body. + * @returns frames completed by this chunk, in order. + */ + push(chunk: string): SseFrame[] { + this.buffer += chunk + const frames: SseFrame[] = [] + for (;;) { + const match = /\r\n|\r|\n/.exec(this.buffer) + if (match === null) break + // A trailing lone `\r` may be the first half of `\r\n`; wait for more. + if (match[0] === '\r' && match.index === this.buffer.length - 1) break + const line = this.buffer.slice(0, match.index) + this.buffer = this.buffer.slice(match.index + match[0].length) + const frame = this.line(line) + if (frame !== undefined) frames.push(frame) + } + return frames + } + + private line(line: string): SseFrame | undefined { + if (line === '') return this.dispatch() + if (line.startsWith(':')) return undefined + const colon = line.indexOf(':') + const field = colon < 0 ? line : line.slice(0, colon) + let value = colon < 0 ? '' : line.slice(colon + 1) + if (value.startsWith(' ')) value = value.slice(1) + switch (field) { + case 'id': + if (!value.includes('\0')) this.id = value + break + case 'event': + this.event = value + break + case 'data': + this.data.push(value) + break + default: + break + } + return undefined + } + + private dispatch(): SseFrame | undefined { + const data = this.data + const event = this.event + this.data = [] + this.event = undefined + if (data.length === 0) return undefined + return { + ...this.id === undefined ? {} : { id: this.id }, + event: event ?? 'message', + data: data.join('\n'), + } + } +} diff --git a/demos/dsh-qoder-cloud-agents/src/target.ts b/demos/dsh-qoder-cloud-agents/src/target.ts new file mode 100644 index 0000000..4051e03 --- /dev/null +++ b/demos/dsh-qoder-cloud-agents/src/target.ts @@ -0,0 +1,347 @@ +/** + * Which Qoder Cloud environment and agent a delegation runs on. + * + * Order: explicit profile config (`environmentId` / `agentId`, including a + * choice saved by an earlier prompt) → this process's earlier choice → + * an unambiguous default → asking the user through `ctx.userQuestions`. + * Without anyone to ask (headless, or a nested delegation) an ambiguous + * environment fails the delegation and names the candidates instead of + * guessing. + * + * @module dsh-qoder-cloud-agents/target + */ + +import type { AskUserQuestionAnswer, AskUserQuestionItem } from '@deepseek-ai/dsh-user-questions' +import { + AGENT_TOOLSET, + type AgentView, + type CreateSessionRequest, + type EnvironmentView, + type QoderCloudClient, +} from './client.ts' + +/** Name of the environment created when the account has no managed-cloud one. */ +export const DEFAULT_ENVIRONMENT_NAME = 'dsh-default' + +const ENVIRONMENT_QUESTION = 'qoder-cloud-agents-environment' +const AGENT_QUESTION = 'qoder-cloud-agents-agent' +const MAX_AGENT_OPTIONS = 20 + +/** Where a run is bound on the platform. */ +export interface QoderCloudTarget { + readonly agent: CreateSessionRequest['agent'] + readonly environmentId: string + /** How the binding was chosen, surfaced in the run result. */ + readonly notes: readonly string[] +} + +/** Ask the human; rejects with a `code`-carrying error when nobody can answer. */ +export type Asker = (questions: AskUserQuestionItem[], signal: AbortSignal) => Promise + +/** Fields persisted into this plugin's profile entry. */ +export type Selection = { environmentId?: string | undefined; agentId?: string | undefined } + +export interface TargetResolverOptions { + /** Current explicit config (volatile: reflects saved choices live). */ + readonly configured: () => Selection + readonly agentName: string + readonly model: string + readonly system: string + /** Profile entry id, for configuration snippets in errors. */ + readonly entryId: string + /** Save a choice to the profile; resolves false when it could not be saved. */ + readonly persist: (selection: Selection) => Promise +} + +/** User-question failures that mean "nobody can answer here". */ +const UNANSWERABLE = new Set(['NO_PROVIDER', 'DELEGATED_CALLER', 'CALLER_NOT_LIVE']) + +function errorCode(error: unknown): string | undefined { + return typeof error === 'object' && error !== null && typeof (error as { code?: unknown }).code === 'string' + ? (error as { code: string }).code + : undefined +} + +/** Usable environment: not archived. */ +function active(items: readonly T[]): T[] { + return items.filter(item => !item.archived_at) +} + +/** The Qoder Cloud API defaults an environment's config to `{type: 'cloud'}`; only an explicit `self_hosted` is BYOC. */ +function isManagedCloud(env: EnvironmentView): boolean { + return env.config?.type !== 'self_hosted' +} + +/** One-line summary of what an environment carries (packages, networking). */ +export function describeEnvironment(env: EnvironmentView): string { + const config = (env.config ?? {}) as { + type?: string + networking?: { type?: string } + packages?: Record + setup_script?: unknown + } + if (config.type === 'self_hosted') { + return `self-hosted (BYOC) · runs on your own workers, one must be online${config.setup_script !== undefined ? ' · setup script' : ''}` + } + const parts: string[] = [config.type ?? 'unknown type'] + const packages = Object.entries(config.packages ?? {}) + .filter(([, list]) => Array.isArray(list) && list.length > 0) + .map(([manager, list]) => `${manager}: ${(list as unknown[]).slice(0, 4).join(', ')}${(list as unknown[]).length > 4 ? ', …' : ''}`) + parts.push(packages.length > 0 ? packages.join('; ') : 'no extra packages') + if (config.networking?.type !== undefined) parts.push(`network ${config.networking.type}`) + if (config.setup_script !== undefined) parts.push('setup script') + return parts.join(' · ') +} + +const environmentLabel = (env: EnvironmentView): string => `${env.name} · ${env.id}` +const agentLabel = (agent: AgentView): string => `${agent.name} · ${agent.id}` + +/** + * Match free text (an id or an exact, unique name) against items. + * @returns the match, or an error message. + */ +function matchByIdOrName(items: readonly T[], text: string, kind: string): T | string { + const needle = text.trim() + const byId = items.find(item => item.id === needle) + if (byId !== undefined) return byId + const byName = items.filter(item => item.name === needle) + if (byName.length === 1) return byName[0]! + if (byName.length > 1) return `several ${kind}s are named "${needle}"; use the id (${byName.map(item => item.id).join(', ')})` + return `no active ${kind} matches "${needle}"` +} + +/** Failure naming what to configure when the choice cannot be made here. */ +export class SelectionRequiredError extends Error { + constructor(message: string) { + super(message) + this.name = 'SelectionRequiredError' + } +} + +function ambiguousEnvironment(candidates: readonly EnvironmentView[], entryId: string, reason: string): SelectionRequiredError { + const lines = [ + candidates.length === 1 + ? `qoder-cloud-agents: the only Qoder Cloud environment is self-hosted (BYOC) and ${reason}.` + : `qoder-cloud-agents: ${candidates.length} Qoder Cloud environments are available and ${reason}.`, + 'Choose one with `/qoder-cloud-agents env ` in an interactive dsh session, or set it in the profile patch:', + '', + `- id: ${entryId}`, + ' config:', + ` environmentId: ${candidates[0]?.id ?? 'env_…'}`, + '', + 'Candidates:', + ...candidates.map(env => ` ${env.id} ${env.name} (${describeEnvironment(env)})`), + ] + return new SelectionRequiredError(lines.join('\n')) +} + +type EnvironmentPlan = + | { kind: 'use'; env: EnvironmentView; why: string } + | { kind: 'create' } + | { kind: 'ask'; candidates: EnvironmentView[]; all: EnvironmentView[] } + +type AgentPlan = + | { kind: 'use'; agent: AgentView; why: string } + | { kind: 'create' } + | { kind: 'ask'; candidates: AgentView[]; all: AgentView[] } + +/** Per-provider binding resolution; one selection at a time. */ +export class TargetResolver { + private memo: Selection = {} + private queue: Promise = Promise.resolve() + + constructor(private readonly options: TargetResolverOptions) {} + + /** Drop this process's remembered choice (after `/qoder-cloud-agents reset`). */ + forget(): void { + this.memo = {} + } + + /** Remember a choice made outside a run (the slash command). */ + remember(selection: Selection): void { + this.memo = { ...this.memo, ...selection } + } + + /** + * Resolve the binding for one run. Concurrent runs queue so one prompt + * answers them all. + * @param client - authenticated platform client. + * @param asker - human answerer, or `undefined` when none is mounted. + * @param signal - run cancellation. + */ + resolve(client: QoderCloudClient, asker: Asker | undefined, signal: AbortSignal): Promise { + const next = this.queue.then(() => this.resolveNow(client, asker, signal)) + this.queue = next.catch(() => {}) + return next + } + + private async resolveNow(client: QoderCloudClient, asker: Asker | undefined, signal: AbortSignal): Promise { + const { options } = this + const configured = options.configured() + const environmentId = configured.environmentId ?? this.memo.environmentId + const agentId = configured.agentId ?? this.memo.agentId + if (environmentId !== undefined && agentId !== undefined) { + return { environmentId, agent: agentId, notes: [] } + } + + const envPlan: EnvironmentPlan | undefined = environmentId === undefined + ? this.planEnvironment(active((await client.listEnvironments(signal)).data)) + : undefined + const agentPlan: AgentPlan | undefined = agentId === undefined + ? this.planAgent(active((await client.listAgents(signal)).data), asker !== undefined) + : undefined + + const questions: AskUserQuestionItem[] = [] + if (envPlan?.kind === 'ask') { + questions.push({ + id: ENVIRONMENT_QUESTION, + header: 'Qoder Cloud', + question: 'Which Qoder Cloud environment should delegated tasks run in?', + detail: 'The environment sets where the sandbox runs, its preinstalled packages and network policy. ' + + 'Managed cloud environments run on Qoder; self-hosted (BYOC) ones run on your own workers and can reach ' + + 'networks those workers reach (e.g. an intranet Git host). ' + + 'The choice is saved to this profile; change it later with `/qoder-cloud-agents env`.', + options: [ + ...envPlan.candidates.map(env => ({ label: environmentLabel(env), description: describeEnvironment(env) })), + { label: `Create a new environment "${DEFAULT_ENVIRONMENT_NAME}"`, description: 'cloud · no extra packages · network unrestricted' }, + ], + }) + } + if (agentPlan?.kind === 'ask') { + questions.push({ + id: AGENT_QUESTION, + header: 'Qoder Cloud', + question: 'Which Qoder Cloud agent should run delegated tasks?', + detail: 'The agent sets the cloud model, system prompt and tools. ' + + 'The choice is saved to this profile; change it later with `/qoder-cloud-agents agent`.', + options: [ + { label: `Create "${options.agentName}"`, description: `model ${options.model} · built-in sandbox toolset` }, + ...agentPlan.candidates.map(agent => ({ label: agentLabel(agent), ...typeof agent.model === 'string' ? { description: `model ${agent.model}` } : {} })), + ], + }) + } + + let answer: AskUserQuestionAnswer | undefined + if (questions.length > 0) { + let unanswerable: string | undefined = asker === undefined ? 'no one can be asked to choose (no interactive UI)' : undefined + if (asker !== undefined) { + try { + answer = await asker(questions, signal) + } catch (error: unknown) { + const code = errorCode(error) + if (code === undefined || !UNANSWERABLE.has(code)) throw error + unanswerable = code === 'NO_PROVIDER' + ? 'no one can be asked to choose (no interactive UI is attached)' + : 'the delegating agent is itself a delegated task, which cannot ask the user' + } + } + if (answer === undefined && envPlan?.kind === 'ask') { + throw ambiguousEnvironment(envPlan.candidates, options.entryId, unanswerable ?? 'none was chosen') + } + } + + const notes: string[] = [] + const chosen: Selection = {} + let resolvedEnvironment = environmentId + if (envPlan !== undefined) { + const env = await this.applyEnvironment(client, envPlan, answer, signal) + resolvedEnvironment = env.id + chosen.environmentId = env.id + notes.push(`Environment: ${env.name} (${env.id})${envPlan.kind === 'use' ? ` — ${envPlan.why}` : ''}`) + } + let resolvedAgent = agentId + if (agentPlan !== undefined) { + const agent = await this.applyAgent(client, answer === undefined && agentPlan.kind === 'ask' ? { kind: 'create' } : agentPlan, answer, signal) + resolvedAgent = agent.id + chosen.agentId = agent.id + notes.push(`Agent: ${agent.name} (${agent.id})${agentPlan.kind === 'use' ? ` — ${agentPlan.why}` : ''}`) + } + + this.memo = { ...this.memo, ...chosen } + const saved = await options.persist(chosen) + notes.push(saved + ? 'Saved to this profile; change with /qoder-cloud-agents.' + : 'Not saved to the profile (no settings service); set environmentId / agentId in the profile patch to keep it.') + return { environmentId: resolvedEnvironment!, agent: resolvedAgent!, notes } + } + + private planEnvironment(envs: EnvironmentView[]): EnvironmentPlan { + if (envs.length === 0) return { kind: 'create' } + // A lone self-hosted environment is not a safe silent default: it needs a live worker. + if (envs.length === 1 && isManagedCloud(envs[0]!)) return { kind: 'use', env: envs[0]!, why: 'the only environment' } + // Managed cloud first, then self-hosted (BYOC), each in platform order. + const ordered = [...envs.filter(isManagedCloud), ...envs.filter(env => !isManagedCloud(env))] + return { kind: 'ask', candidates: ordered, all: envs } + } + + private planAgent(agents: AgentView[], canAsk: boolean): AgentPlan { + const managed = agents.find(agent => agent.name === this.options.agentName) + if (managed !== undefined) return { kind: 'use', agent: managed, why: 'managed by this plugin' } + // The plugin's own agent is a defined default, so headless runs create it + // instead of failing; only an interactive run offers the account's agents. + if (!canAsk || agents.length === 0) return { kind: 'create' } + return { kind: 'ask', candidates: agents.slice(0, MAX_AGENT_OPTIONS), all: agents } + } + + private async applyEnvironment( + client: QoderCloudClient, + plan: EnvironmentPlan, + answer: AskUserQuestionAnswer | undefined, + signal: AbortSignal, + ): Promise { + if (plan.kind === 'use') return plan.env + if (plan.kind === 'ask') { + const item = answer?.answers.find(entry => entry.id === ENVIRONMENT_QUESTION) + const label = item?.selected[0] + const picked = plan.candidates.find(env => environmentLabel(env) === label) + if (picked !== undefined) return picked + const custom = item?.custom?.trim() + if (custom !== undefined && custom.length > 0 && label === undefined) { + const match = matchByIdOrName(plan.all, custom, 'environment') + if (typeof match === 'string') throw new SelectionRequiredError(`qoder-cloud-agents: ${match}`) + return match + } + if (label === undefined) throw new SelectionRequiredError('qoder-cloud-agents: no Qoder Cloud environment was chosen') + } + return client.createEnvironment(DEFAULT_ENVIRONMENT_NAME, signal) + } + + private async applyAgent( + client: QoderCloudClient, + plan: AgentPlan, + answer: AskUserQuestionAnswer | undefined, + signal: AbortSignal, + ): Promise { + if (plan.kind === 'use') return plan.agent + if (plan.kind === 'ask') { + const item = answer?.answers.find(entry => entry.id === AGENT_QUESTION) + const label = item?.selected[0] + const picked = plan.candidates.find(agent => agentLabel(agent) === label) + if (picked !== undefined) return picked + const custom = item?.custom?.trim() + if (custom !== undefined && custom.length > 0 && label === undefined) { + const match = matchByIdOrName(plan.all, custom, 'agent') + if (typeof match === 'string') throw new SelectionRequiredError(`qoder-cloud-agents: ${match}`) + return match + } + if (label === undefined) throw new SelectionRequiredError('qoder-cloud-agents: no Qoder Cloud agent was chosen') + } + return this.createManagedAgent(client, signal) + } + + /** Create (or reuse) the plugin-managed agent. */ + async createManagedAgent(client: QoderCloudClient, signal: AbortSignal): Promise { + const existing = active((await client.listAgents(signal)).data).find(agent => agent.name === this.options.agentName) + if (existing !== undefined) return existing + return client.createAgent({ + name: this.options.agentName, + model: this.options.model, + system: this.options.system, + description: 'Managed by the DeepSeek Harness dsh-qoder-cloud-agents plugin', + tools: [{ type: AGENT_TOOLSET }], + metadata: { source: 'deepseek-harness' }, + }, signal) + } +} + +export { matchByIdOrName } diff --git a/demos/dsh-qoder-cloud-agents/tests/cloud-mode.spec.ts b/demos/dsh-qoder-cloud-agents/tests/cloud-mode.spec.ts new file mode 100644 index 0000000..dfed585 --- /dev/null +++ b/demos/dsh-qoder-cloud-agents/tests/cloud-mode.spec.ts @@ -0,0 +1,227 @@ +import { execFileSync } from 'node:child_process' +import { mkdtempSync, rmSync, writeFileSync } from 'node:fs' +import { tmpdir } from 'node:os' +import { join } from 'node:path' +import { Context } from '@deepseek-ai/cordis' +import { LlmError, type GenerateOptions, type RequestMessage, type StreamChunk } from '@deepseek-ai/dsh-llm' +import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest' +import { QoderCloudClient } from '../src/client.ts' +import { QoderCloudAdapter, splitHistory, type CloudModeOptions } from '../src/cloud-mode.ts' +import * as route from '../src/cloud-route.ts' +import { TargetResolver } from '../src/target.ts' +import { startMockQoder, type StreamContext } from './mock-server.ts' + +const user = (id: string, text: string, kind = 'user'): RequestMessage => + ({ id, role: 'user', content: [{ type: 'text', text }], source: { kind } }) as unknown as RequestMessage +const reply = (id: string, text: string, remoteSessionId?: string): RequestMessage => ({ + id, + role: 'assistant', + content: [{ type: 'text', text }], + source: { + kind: 'model', + provider: 'qoder-cloud-agents', + model: 'agent', + ...remoteSessionId === undefined ? {} : { replayState: { response: { remoteSessionId } } }, + }, +}) as unknown as RequestMessage +const system: RequestMessage = { id: 's', role: 'system', content: [{ type: 'text', text: 'sys' }], source: { kind: 'system-prompt' } } as unknown as RequestMessage + +async function collect(stream: AsyncIterable): Promise { + const chunks: StreamChunk[] = [] + for await (const chunk of stream) chunks.push(chunk) + return chunks +} +const texts = (chunks: StreamChunk[], kind: 'text' | 'reasoning') => chunks + .filter((c): c is Extract => c.type === 'block-end' && c.block.type === kind) + .map(c => (c.block as { text: string }).text) + +const cleanups: (() => Promise | void)[] = [] +afterEach(async () => { + while (cleanups.length > 0) await cleanups.pop()!() + vi.restoreAllMocks() +}) + +let repo: string +beforeAll(() => { + repo = mkdtempSync(join(tmpdir(), 'qoder-cloudmode-')) + const git = (...args: string[]) => execFileSync('git', args, { cwd: repo, stdio: 'pipe' }) + git('init', '-q', '-b', 'main'); git('config', 'user.email', 't@example.com'); git('config', 'user.name', 't') + writeFileSync(join(repo, 'a.txt'), 'a'); git('add', '.'); git('commit', '-q', '-m', 'one') + git('remote', 'add', 'origin', 'https://github.com/acme/widgets.git') + git('update-ref', 'refs/remotes/origin/main', 'HEAD') +}) +afterAll(() => rmSync(repo, { recursive: true, force: true })) + +function adapterFor(baseURL: string, overrides: Partial = {}) { + const resolver = new TargetResolver({ + configured: () => ({ environmentId: 'env_1', agentId: 'agent_1' }), + agentName: 'dsh-qoder-cloud-delegate', + model: 'ultimate', + system: '', + entryId: 'qoder-cloud-agents', + persist: async () => true, + }) + return new QoderCloudAdapter({ + client: async () => new QoderCloudClient({ baseURL, token: 'pt-test' }), + resolver, + turnContext: () => ({ cwd: repo, asker: undefined }), + repository: 'auto', + gitToken: async () => 'ghp_test', + gitTokenEnv: 'QODER_GIT_TOKEN', + gitUsername: undefined, + branchPrefix: 'qoder-cloud-agents/', + toolConfirmation: 'allow', + environmentVariables: {}, + ...overrides, + }) +} + +function stubGitHub() { + const realFetch = globalThis.fetch + vi.spyOn(globalThis, 'fetch').mockImplementation(async (input: any, init?: any) => { + const url = typeof input === 'string' ? input : input.url + if (url.startsWith('https://api.github.com/')) return new Response(JSON.stringify({ permissions: { push: true } }), { status: 200 }) + return realFetch(input, init) + }) +} + +const options = (messages: RequestMessage[], extra: Partial = {}): GenerateOptions => ({ + provider: 'qoder-cloud-agents', + model: 'agent', + messages, + sessionId: 'session-1' as GenerateOptions['sessionId'], + ...extra, +}) + +describe('splitHistory', () => { + it('sends only what the user typed since the last reply and finds the remote session', () => { + expect(splitHistory([system, user('u1', 'hello')])).toEqual({ replay: undefined, input: 'hello' }) + const followUp = splitHistory([ + system, + user('u1', 'hello'), + reply('a1', 'hi', 'sess_9'), + user('n1', 'local notice', 'subagent-settled'), + user('u2', 'and then?'), + ]) + expect(followUp).toEqual({ replay: { remoteSessionId: 'sess_9' }, input: 'and then?' }) + }) +}) + +describe('qoder-cloud-agents adapter', () => { + it('creates a session on the first turn and streams messages, activity and the replay state', async () => { + stubGitHub() + const mock = await startMockQoder({ + stream: async (s: StreamContext) => { + s.emit({ type: 'session.status_running' }) + const tool = s.emit({ type: 'agent.tool_use', name: 'Bash', input: { command: 'npm test' } }) + s.emit({ type: 'session.status_idle', stop_reason: { type: 'requires_action', event_ids: [tool] } }) + await s.waitFor('user.tool_confirmation') + s.emit({ type: 'agent.tool_result', tool_use_id: tool, is_error: true, content: [{ type: 'text', text: '1 failing' }] }) + s.emit({ type: 'agent.message', content: [{ type: 'text', text: 'Fixed it and pushed.' }] }) + s.emit({ type: 'session.status_idle', stop_reason: { type: 'end_turn' } }) + }, + }) + cleanups.push(mock.close) + const chunks = await collect(adapterFor(mock.baseURL).stream(options([system, user('u1', 'fix the tests')]))) + + const created = mock.requests.find(r => r.path === '/sessions')!.body + expect(created).toMatchObject({ + agent: 'agent_1', + environment_id: 'env_1', + metadata: { mode: 'cloud' }, + resources: [{ type: 'github_repository', url: 'https://github.com/acme/widgets.git', mount_path: '/data/workspace/widgets', authorization_token: 'ghp_test' }], + }) + const message = mock.posted.find(e => e.type === 'user.message')!.content[0].text as string + expect(message).toMatch(/^You are working in a Qoder Cloud sandbox[\s\S]*mounted at `\/data\/workspace\/widgets`[\s\S]*---\n\nfix the tests$/) + + expect(texts(chunks, 'reasoning')).toEqual([ + expect.stringMatching(/^Qoder Cloud session sess_1 · repository https:\/\/github.com\/acme\/widgets.git → branch qoder-cloud-agents\/[0-9a-f]{8}$/), + '› Bash: npm test', + ' ✗ 1 failing', + ]) + expect(texts(chunks, 'text')).toEqual(['Fixed it and pushed.']) + expect(chunks.at(-2)).toEqual({ type: 'usage', usage: { inputTokens: 0, outputTokens: 0 } }) + expect(chunks.at(-1)).toEqual({ type: 'finish', reason: { kind: 'stop' }, replayState: { response: { remoteSessionId: 'sess_1' } } }) + // Block indexes are unique and each block is closed before the next opens. + const starts = chunks.filter(c => c.type === 'block-start').map(c => (c as { index: number }).index) + expect(new Set(starts).size).toBe(starts.length) + }) + + it('continues the same remote session on a follow-up without the preamble', async () => { + const mock = await startMockQoder({ + stream: async (s) => { + s.emit({ type: 'agent.message', content: [{ type: 'text', text: 'Sure.' }] }) + s.emit({ type: 'session.status_idle', stop_reason: { type: 'end_turn' } }) + }, + }) + cleanups.push(mock.close) + const chunks = await collect(adapterFor(mock.baseURL).stream(options([ + system, user('u1', 'fix the tests'), reply('a1', 'done', 'sess_1'), user('u2', 'also update the README'), + ]))) + expect(mock.requests.map(r => r.path)).not.toContain('/sessions') + expect(mock.posted.find(e => e.type === 'user.message')!.content[0].text).toBe('also update the README') + expect(texts(chunks, 'text')).toEqual(['Sure.']) + }) + + it('titles a session from the framed first human message', async () => { + const mock = await startMockQoder({ stream: async () => {} }) + cleanups.push(mock.close) + const framed = user('t', 'Generate the session title from this JSON array of human messages:\n' + + JSON.stringify([{ seq: 3, text: '帮我看看这个仓库的状态' }]), 'dsh-session-title-llm') + const chunks = await collect(adapterFor(mock.baseURL).stream(options([framed], { purpose: 'session-title' }))) + expect(texts(chunks, 'text')).toEqual(['帮我看看这个仓库的状态']) + expect(mock.requests).toEqual([]) + }) + + it('answers session titles locally', async () => { + const mock = await startMockQoder({ stream: async () => {} }) + cleanups.push(mock.close) + const chunks = await collect(adapterFor(mock.baseURL).stream(options([user('u1', 'Refactor the payment module\nand more')], { purpose: 'session-title' }))) + expect(texts(chunks, 'text')).toEqual(['Refactor the payment module']) + expect(mock.requests).toEqual([]) + }) + + it('turns a failed remote turn into an LlmError carrying the platform message', async () => { + const mock = await startMockQoder({ + stream: async (s) => { + s.emit({ type: 'session.error', error: { type: 'model_error', message: 'upstream overloaded', retry_status: { type: 'exhausted' } } }) + s.emit({ type: 'session.status_idle', stop_reason: { type: 'retries_exhausted' } }) + }, + }) + cleanups.push(mock.close) + const failure = collect(adapterFor(mock.baseURL, { repository: 'none' }).stream(options([user('u1', 'x')]))) + await expect(failure).rejects.toBeInstanceOf(LlmError) + await expect(failure).rejects.toThrow('upstream overloaded') + }) + + it('never retries a turn and advertises one model', async () => { + const adapter = adapterFor('https://qoder.invalid') + expect(adapter.providerRetryPolicy('qoder-cloud-agents')).toMatchObject({ mode: 'normal', maxRetries: 0 }) + expect(await adapter.listModels('qoder-cloud-agents')).toEqual([expect.objectContaining({ + provider: 'qoder-cloud-agents', id: 'agent', name: '云端模式(Qoder Cloud Agents)', + })]) + expect(adapter.providerInfo('qoder-cloud-agents')).toEqual({ id: 'qoder-cloud-agents', name: 'Qoder Cloud Agents' }) + }) +}) + +describe('cloud-route preset plugin', () => { + it('pins the request route to qoder-cloud-agents and drops local-model controls', async () => { + const ctx = new Context() + await ctx.plugin(route) + // A later, inner listener (e.g. a manual model pick) cannot win over the prepended route. + ctx.on('agent/request' as never, (async (_payload: unknown, next: () => Promise) => ({ ...await next() as object, provider: 'deepseek-official', model: 'deepseek-flash' })) as never) + const resolved = await (ctx as any).waterfall('agent/request', { agent: {}, turn: 1, step: 1, signal: new AbortController().signal }, + async () => ({ provider: 'deepseek-official', model: 'deepseek-pro', reasoningEffort: 'high', maxTokens: 8000, temperature: 0.2 })) + expect(resolved).toEqual({ provider: 'qoder-cloud-agents', model: 'agent', temperature: 0.2 }) + await ctx.fiber.dispose() + }) + + it('pins the {{provider}} / {{model}} prompt variables so the persona line stays stable across turns', async () => { + const ctx = new Context() + await ctx.plugin(route) + const assembly = { sections: [], contexts: [], tools: [], variables: { provider: 'deepseek', model: 'deepseek-flash', cwd: '/w' } } + const resolved = await (ctx as any).waterfall('system-prompt/assemble', assembly, {}, async () => assembly) + expect(resolved.variables).toEqual({ provider: 'qoder-cloud-agents', model: 'agent', cwd: '/w' }) + await ctx.fiber.dispose() + }) +}) diff --git a/demos/dsh-qoder-cloud-agents/tests/mock-server.ts b/demos/dsh-qoder-cloud-agents/tests/mock-server.ts new file mode 100644 index 0000000..fc53342 --- /dev/null +++ b/demos/dsh-qoder-cloud-agents/tests/mock-server.ts @@ -0,0 +1,124 @@ +import { createServer, type IncomingMessage, type ServerResponse } from 'node:http' +import type { AddressInfo } from 'node:net' + +export interface RecordedRequest { + method: string + path: string + headers: IncomingMessage['headers'] + body: any +} + +type Script = (ctx: StreamContext) => Promise + +export interface StreamContext { + /** Write one event frame (also appended to the session history). */ + emit(event: Record): string + heartbeat(): void + /** Drop the connection without a terminating frame. */ + drop(): void + /** Resolve when the client posts an event of `type`. */ + waitFor(type: string): Promise + readonly lastEventId: string | undefined + readonly connection: number +} + +/** Scriptable stand-in for the Qoder Cloud Agents gateway. */ +export async function startMockQoder(options: { + environments?: { id: string; name: string; archived_at?: string | null; config?: { type: string } }[] + agents?: { id: string; name: string }[] + stream: Script + /** Fixed port for standalone use; default picks a free one. */ + port?: number + /** Session id returned by POST /sessions (default `sess_1`). */ + sessionId?: string +}) { + const sid = options.sessionId ?? 'sess_1' + const requests: RecordedRequest[] = [] + const posted: any[] = [] + const waiters: { type: string; resolve: (event: any) => void }[] = [] + let seq = 0 + let connections = 0 + const nextId = () => `sevt_${String(++seq).padStart(4, '0')}` + + const server = createServer(async (req, res) => { + const url = new URL(req.url ?? '/', 'http://x') + const path = url.pathname.replace(/^\/api\/v1\/cloud/, '') + let raw = '' + for await (const chunk of req) raw += chunk + const body = raw.length > 0 ? JSON.parse(raw) : undefined + requests.push({ method: req.method ?? 'GET', path: `${path}${url.search}`, headers: req.headers, body }) + const json = (status: number, value: unknown) => { + res.writeHead(status, { 'content-type': 'application/json' }) + res.end(JSON.stringify(value)) + } + if (req.headers.authorization !== 'Bearer pt-test') { + json(401, { type: 'error', request_id: 'req_1', error: { type: 'authentication_error', message: 'bad token' } }) + return + } + if (req.method === 'GET' && path === '/environments') return json(200, { data: options.environments ?? [] }) + if (req.method === 'POST' && path === '/environments') return json(200, { id: 'env_new', name: body.name }) + if (req.method === 'GET' && path === '/agents') return json(200, { data: options.agents ?? [] }) + if (req.method === 'POST' && path === '/agents') return json(200, { id: 'agent_new', name: body.name, version: 1 }) + if (req.method === 'POST' && path === '/sessions') return json(200, { id: sid, status: 'idle' }) + if (req.method === 'POST' && path === `/sessions/${sid}/events`) { + const data = body.events.map((event: any) => ({ ...event, id: nextId() })) + posted.push(...data) + for (const event of data) { + for (const waiter of waiters.filter(w => w.type === event.type)) { + waiters.splice(waiters.indexOf(waiter), 1) + waiter.resolve(event) + } + } + return json(200, { data }) + } + if (req.method === 'POST' && path === `/sessions/${sid}/cancel`) return json(202, { id: sid, type: 'session', status: 'canceling' }) + if (req.method === 'POST' && path === `/sessions/${sid}/archive`) return json(200, { id: sid, status: 'terminated' }) + if (req.method === 'GET' && path === `/sessions/${sid}/events/stream`) return stream(req, res) + json(404, { type: 'error', error: { type: 'not_found_error', message: path } }) + }) + + const stream = async (req: IncomingMessage, res: ServerResponse) => { + res.writeHead(200, { 'content-type': 'text/event-stream', 'cache-control': 'no-cache' }) + res.flushHeaders() + const header = req.headers['last-event-id'] + const ctx: StreamContext = { + emit(event) { + const id = nextId() + const frame = JSON.stringify({ id, processed_at: new Date().toISOString(), ...event }) + res.write(`id: ${id}\r\nevent: ${String(event.type)}\r\ndata: ${frame}\r\n\r\n`) + return id + }, + heartbeat() { res.write(': heartbeat\n\n') }, + drop() { setTimeout(() => res.destroy(), 50) }, + waitFor(type) { + const seen = posted.find(e => e.type === type && !e.consumed) + if (seen !== undefined) { + seen.consumed = true + return Promise.resolve(seen) + } + return new Promise(resolve => waiters.push({ type, resolve })) + }, + lastEventId: Array.isArray(header) ? header[0] : header, + connection: ++connections, + } + try { + await options.stream(ctx) + } catch { + // client went away + } + } + + // Bind the default address and connect back through whatever the OS reports. + await new Promise(resolve => server.listen(options.port ?? 0, resolve)) + const { address, port } = server.address() as AddressInfo + const host = address.includes(':') ? `[${address}]` : address + return { + baseURL: `http://${host}:${port}/api/v1/cloud`, + requests, + posted, + close: () => new Promise((resolve) => { + server.closeAllConnections() + server.close(() => resolve()) + }), + } +} diff --git a/demos/dsh-qoder-cloud-agents/tests/qoder-cloud-agents.spec.ts b/demos/dsh-qoder-cloud-agents/tests/qoder-cloud-agents.spec.ts new file mode 100644 index 0000000..983ea15 --- /dev/null +++ b/demos/dsh-qoder-cloud-agents/tests/qoder-cloud-agents.spec.ts @@ -0,0 +1,560 @@ +import { execFileSync } from 'node:child_process' +import { mkdtempSync, rmSync, writeFileSync } from 'node:fs' +import { tmpdir } from 'node:os' +import { join } from 'node:path' +import { Context, Service } from '@deepseek-ai/cordis' +import type { Agent } from '@deepseek-ai/dsh-agent' +import SessionProjectionRegistry from '@deepseek-ai/dsh-session-projection' +import SubagentRuntime, { type SubagentProvider } from '@deepseek-ai/dsh-subagent' +import { afterEach, beforeAll, beforeEach, afterAll, describe, expect, it, vi } from 'vitest' +import * as plugin from '../src/index.ts' +import { httpsRemote, httpsRemoteUsername, type LocalRepository } from '../src/git.ts' +import { SseParser } from '../src/sse.ts' +import { cloudPrompt, repositoryResource } from '../src/run.ts' +import { startMockQoder, type StreamContext } from './mock-server.ts' + +class FixtureWorkingDirectory extends Service { + constructor(ctx: Context) { + super(ctx, 'workingDirectory') + } + get(): string { return process.cwd() } + async ensure(): Promise { return process.cwd() } + async set(_agent: unknown, path: string): Promise { return path } +} + +async function mountProvider(config: plugin.Config) { + const ctx = new Context() + await ctx.plugin(SessionProjectionRegistry) + await ctx.plugin(FixtureWorkingDirectory) + await ctx.plugin(SubagentRuntime) + const fiber = await ctx.plugin(plugin, config) + const provider = ctx.subagents.getProvider('qoder-cloud-agents') as SubagentProvider + return { ctx, fiber, provider } +} + +function start(provider: SubagentProvider, cwd: string, text: string, signal = new AbortController().signal) { + return provider.start!({ + cwd, + prompt: [{ type: 'text', text }], + parent: {} as Agent, + signal, + }) +} + +let repo: string +let plain: string +const git = (...args: string[]) => execFileSync('git', args, { cwd: repo, stdio: 'pipe' }).toString().trim() + +beforeAll(() => { + repo = mkdtempSync(join(tmpdir(), 'qoder-repo-')) + plain = mkdtempSync(join(tmpdir(), 'qoder-plain-')) + git('init', '-q', '-b', 'main') + git('config', 'user.email', 't@example.com') + git('config', 'user.name', 't') + writeFileSync(join(repo, 'a.txt'), 'a') + git('add', '.') + git('commit', '-q', '-m', 'one') + git('remote', 'add', 'origin', 'git@github.com:acme/widgets.git') + git('update-ref', 'refs/remotes/origin/main', 'HEAD') + writeFileSync(join(repo, 'b.txt'), 'b') + git('add', '.') + git('commit', '-q', '-m', 'two (unpushed)') +}) + +afterAll(() => { + rmSync(repo, { recursive: true, force: true }) + rmSync(plain, { recursive: true, force: true }) +}) + +/** Scripted `api.github.com/repos/:owner/:repo` answers; everything else goes to the network/mock. */ +let githubAnswer: (auth: string | undefined) => Response +const realFetch = globalThis.fetch +beforeEach(() => { + githubAnswer = () => new Response(JSON.stringify({ permissions: { push: true } }), { status: 200 }) + vi.spyOn(globalThis, 'fetch').mockImplementation(async (input: any, init?: any) => { + const url = typeof input === 'string' ? input : input.url + if (url.startsWith('https://api.github.com/')) { + const auth = new Headers(init?.headers).get('authorization') ?? undefined + return githubAnswer(auth) + } + return realFetch(input, init) + }) +}) +afterEach(() => { vi.restoreAllMocks() }) + +const cleanups: (() => Promise)[] = [] +afterEach(async () => { + while (cleanups.length > 0) await cleanups.pop()!() +}) + +describe('SseParser', () => { + it('reassembles frames across chunks, CRLF endings and heartbeats', () => { + const parser = new SseParser() + expect(parser.push(': heartbeat\n\nid: e1\r')).toEqual([]) + expect(parser.push('\nevent: agent.message\r\ndata: {"a":')).toEqual([]) + expect(parser.push('1}\r\n\r\ndata: x\ndata: y\n\n')).toEqual([ + { id: 'e1', event: 'agent.message', data: '{"a":1}' }, + { id: 'e1', event: 'message', data: 'x\ny' }, + ]) + }) +}) + +describe('httpsRemote', () => { + it('normalizes ssh, scp-like and credentialed remotes', () => { + expect(httpsRemote('git@github.com:acme/widgets.git')).toBe('https://github.com/acme/widgets.git') + expect(httpsRemote('ssh://git@code.example.com:2222/team/repo.git')).toBe('https://code.example.com/team/repo.git') + expect(httpsRemote('https://user:secret@code.example.com/team/repo.git')).toBe('https://code.example.com/team/repo.git') + expect(httpsRemote('/srv/git/repo.git')).toBeUndefined() + }) +}) + +describe('cloudPrompt', () => { + it('leaves the task untouched without a repository', () => { + expect(cloudPrompt('do it', undefined, undefined)).toBe('do it') + }) +}) + +describe('qoder-cloud-agents provider', () => { + it('registers, validates config and unregisters on dispose', async () => { + const { ctx, fiber, provider } = await mountProvider({ token: 'pt-test' }) + expect(provider).toMatchObject({ + name: 'qoder-cloud-agents', + inheritsParentContext: false, + capabilities: { agentOptions: false, agentPreset: false, outputSchema: false, depthLimit: false }, + }) + await fiber.dispose() + expect(ctx.subagents.list()).toEqual([]) + await expect(ctx.plugin(plugin, { timeoutMs: 0 })).rejects.toThrow('timeoutMs') + await expect(ctx.plugin(plugin, { baseURL: 'not a url' })).rejects.toThrow('baseURL') + await ctx.fiber.dispose() + }) + + it('runs a task end to end: repo mount, resume after a dropped stream, tool confirmation', async () => { + const mock = await startMockQoder({ + environments: [ + { id: 'env_old', name: 'Default', archived_at: '2026-01-01T00:00:00Z', config: { type: 'cloud' } }, + { id: 'env_1', name: 'Default', config: { type: 'cloud' } }, + ], + stream: async (s) => { + if (s.connection === 1) { + s.heartbeat() + s.emit({ type: 'session.status_running' }) + s.emit({ type: 'agent.message', content: [{ type: 'text', text: 'Working on it' }] }) + s.drop() + return + } + const toolUse = s.emit({ type: 'agent.tool_use', name: 'Bash', input: { command: 'git push' } }) + s.emit({ type: 'session.status_idle', stop_reason: { type: 'requires_action', event_ids: [toolUse] } }) + const confirmation = await s.waitFor('user.tool_confirmation') + expect(confirmation).toMatchObject({ tool_use_id: toolUse, result: 'allow' }) + s.emit({ type: 'agent.artifact_delivered', file_id: 'file_1', original_filename: 'report.md', size: 12 }) + s.emit({ type: 'agent.message', content: [{ type: 'text', text: 'Done. Pushed ' }, { type: 'text', text: 'branch X.' }] }) + s.emit({ type: 'session.usage', total_credits: 1 }) + s.emit({ type: 'session.status_idle', stop_reason: { type: 'end_turn' } }) + }, + }) + cleanups.push(mock.close) + process.env.QODER_GIT_TOKEN_E2E = 'ghp_test' + const { fiber, provider } = await mountProvider({ token: 'pt-test', baseURL: mock.baseURL, gitTokenEnv: 'QODER_GIT_TOKEN_E2E' }) + cleanups.push(() => fiber.dispose()) + + const run = await start(provider, repo, 'Fix the flaky test') + const result = await run.result + await run.dispose() + + expect(result.stopReason).toBe('completed') + const text = (result.output[0] as { text: string }).text + expect(text).toMatch(/^Done\. Pushed branch X\./) + expect(text).toContain('[Qoder Cloud] session sess_1 · stop_reason end_turn') + expect(text).toContain('report.md (file_1, 12 bytes)') + expect(text).toContain('1 local commit(s) on main are not pushed') + expect(text).toContain('Environment: Default (env_1) — the only environment') + expect(text).toContain('Not saved to the profile') + + const calls = mock.requests.map(r => `${r.method} ${r.path}`) + expect(calls).toContain('POST /agents') + const agent = mock.requests.find(r => r.method === 'POST' && r.path === '/agents')!.body + expect(agent).toMatchObject({ name: 'dsh-qoder-cloud-delegate', model: 'ultimate', tools: [{ type: 'agent_toolset_20260401' }] }) + const session = mock.requests.find(r => r.method === 'POST' && r.path === '/sessions')! + expect(session.headers['idempotency-key']).toBeTruthy() + expect(session.body).toMatchObject({ + agent: 'agent_new', + environment_id: 'env_1', + title: 'Fix the flaky test', + resources: [{ type: 'github_repository', url: 'https://github.com/acme/widgets.git', mount_path: '/data/workspace/widgets', checkout: { type: 'branch', name: 'main' }, authorization_token: 'ghp_test' }], + }) + const message = mock.posted.find(e => e.type === 'user.message') + expect(message.content[0].text).toMatch(/Fix the flaky test[\s\S]*git push -u origin qoder-cloud-agents\/[0-9a-f]{8}/) + expect(message.content[0].text).toContain('mounted in this sandbox at `/data/workspace/widgets`') + expect(message.content[0].text).toContain('First check that the mounted repository exists') + + const streams = mock.requests.filter(r => r.path === '/sessions/sess_1/events/stream') + expect(streams).toHaveLength(2) + expect(streams[0]!.headers['last-event-id']).toBe(message.id) + // Resumed after the last event delivered before the drop. + expect(streams[1]!.headers['last-event-id']).not.toBe(message.id) + expect(calls).not.toContain('POST /sessions/sess_1/cancel') + }) + + it('maps a platform error turn to stopReason error with the session.error message', async () => { + const mock = await startMockQoder({ + environments: [{ id: 'env_1', name: 'default', config: { type: 'cloud' } }], + agents: [{ id: 'agent_existing', name: 'dsh-qoder-cloud-delegate' }], + stream: async (s) => { + s.emit({ type: 'session.error', error: { type: 'model_error', message: 'upstream overloaded', retry_status: { type: 'exhausted' } } }) + s.emit({ type: 'session.status_idle', stop_reason: { type: 'retries_exhausted' } }) + }, + }) + cleanups.push(mock.close) + const { fiber, provider } = await mountProvider({ token: 'pt-test', baseURL: mock.baseURL, archiveOnFinish: true }) + cleanups.push(() => fiber.dispose()) + + const run = await start(provider, plain, 'Summarize') + const result = await run.result + await run.dispose() + expect(result.stopReason).toBe('error') + expect(result.diagnostic).toBe('upstream overloaded') + const calls = mock.requests.map(r => `${r.method} ${r.path}`) + expect(calls).not.toContain('POST /agents') + const session = mock.requests.find(r => r.method === 'POST' && r.path === '/sessions')!.body + expect(session.agent).toBe('agent_existing') + expect(session.resources).toBeUndefined() + expect(calls).toContain('POST /sessions/sess_1/archive') + }) + + it('cancels the remote turn when the parent aborts', async () => { + const mock = await startMockQoder({ + environments: [{ id: 'env_1', name: 'default', config: { type: 'cloud' } }], + stream: async (s) => { + s.emit({ type: 'agent.message', content: [{ type: 'text', text: 'partial' }] }) + await new Promise(() => {}) + }, + }) + cleanups.push(mock.close) + const { fiber, provider } = await mountProvider({ token: 'pt-test', baseURL: mock.baseURL }) + cleanups.push(() => fiber.dispose()) + + const controller = new AbortController() + const run = await start(provider, plain, 'Long task', controller.signal) + await new Promise(resolve => setTimeout(resolve, 100)) + controller.abort() + const result = await run.result + await run.dispose() + expect(result.stopReason).toBe('aborted') + expect((result.output[0] as { text: string }).text).toContain('partial') + expect(mock.requests.map(r => `${r.method} ${r.path}`)).toContain('POST /sessions/sess_1/cancel') + }) + + it('fails the delegation call itself on a rejected PAT', async () => { + const mock = await startMockQoder({ stream: async () => {} }) + cleanups.push(mock.close) + const { fiber, provider } = await mountProvider({ token: 'pt-wrong', baseURL: mock.baseURL }) + cleanups.push(() => fiber.dispose()) + await expect(start(provider, plain, 'x')).rejects.toThrow('401 authentication_error: bad token') + }) + + it('reports a missing PAT before any request', async () => { + const { fiber, provider } = await mountProvider({ tokenEnv: 'QODER_PAT_DEFINITELY_UNSET' }) + cleanups.push(() => fiber.dispose()) + await expect(start(provider, plain, 'x')).rejects.toThrow('no Qoder PAT') + }) +}) + +const ENVIRONMENTS = [ + { id: 'env_byoc', name: 'team byoc', config: { type: 'self_hosted' } }, + { id: 'env_cli', name: 'CLI tools', config: { type: 'cloud' } }, + { id: 'env_a', name: 'Default', config: { type: 'cloud' } }, + { id: 'env_b', name: 'Default', config: { type: 'cloud' } }, +] +const idleStream = async (s: StreamContext) => { + s.emit({ type: 'agent.message', content: [{ type: 'text', text: 'ok' }] }) + s.emit({ type: 'session.status_idle', stop_reason: { type: 'end_turn' } }) +} + +class StubSettings extends Service { + readonly writes: { ns: string; ops: unknown[] }[] = [] + constructor(ctx: Context) { super(ctx, 'settings') } + describe() { return [{ ns: 'qoder-cloud-agents', revision: 0 }] } + async mutate(ns: string, ops: unknown[]) { this.writes.push({ ns, ops }) } +} + +function stubQuestions(answer: (questions: any[]) => any) { + return class StubQuestions extends Service { + readonly asked: any[][] = [] + constructor(ctx: Context) { super(ctx, 'userQuestions') } + async ask(request: { questions: any[] }) { + this.asked.push(request.questions) + return answer(request.questions) + } + } +} + +class StubCommands extends Service { + readonly definitions: any[] = [] + constructor(ctx: Context) { super(ctx, 'commands') } + register(definition: any) { + this.definitions.push(definition) + return () => {} + } +} + +async function mountWith(services: (typeof Service)[], config: plugin.Config) { + const ctx = new Context() + await ctx.plugin(SessionProjectionRegistry) + await ctx.plugin(FixtureWorkingDirectory) + await ctx.plugin(SubagentRuntime) + for (const service of services) await ctx.plugin(service as any) + const fiber = await ctx.plugin(plugin, config) + cleanups.push(() => fiber.dispose()) + return { ctx, provider: ctx.subagents.getProvider('qoder-cloud-agents') as SubagentProvider } +} + +describe('environment / agent selection', () => { + it('uses explicit config without listing anything', async () => { + const mock = await startMockQoder({ environments: ENVIRONMENTS, stream: idleStream }) + cleanups.push(mock.close) + const { provider } = await mountWith([], { token: 'pt-test', baseURL: mock.baseURL, environmentId: 'env_b', agentId: 'agent_x' } as any) + const result = await (await start(provider, plain, 'x')).result + expect(result.stopReason).toBe('completed') + const calls = mock.requests.map(r => `${r.method} ${r.path}`) + expect(calls).not.toContain('GET /environments?limit=100') + expect(calls).not.toContain('GET /agents?limit=100') + expect(mock.requests.find(r => r.path === '/sessions')!.body).toMatchObject({ environment_id: 'env_b', agent: 'agent_x' }) + }) + + it('fails headless when several cloud environments exist, naming the candidates', async () => { + const mock = await startMockQoder({ environments: ENVIRONMENTS, stream: idleStream }) + cleanups.push(mock.close) + const { provider } = await mountWith([], { token: 'pt-test', baseURL: mock.baseURL }) + const failure = start(provider, plain, 'x') + await expect(failure).rejects.toThrow('4 Qoder Cloud environments are available and no one can be asked to choose') + const message = await failure.catch((e: Error) => e.message) + expect(message).toContain('environmentId: env_cli') + expect(message).toContain('env_a Default') + expect(message).toContain('env_byoc team byoc (self-hosted (BYOC)') + expect(mock.requests.map(r => r.path)).not.toContain('/sessions') + }) + + it('treats an environment without a config type as managed cloud, but never auto-picks a lone BYOC one', async () => { + const plainEnv = await startMockQoder({ environments: [{ id: 'env_plain', name: 'old' }], stream: idleStream }) + cleanups.push(plainEnv.close) + const first = await mountWith([], { token: 'pt-test', baseURL: plainEnv.baseURL }) + await (await start(first.provider, plain, 'x')).result + expect(plainEnv.requests.find(r => r.path === '/sessions')!.body.environment_id).toBe('env_plain') + + const byocOnly = await startMockQoder({ environments: [{ id: 'env_byoc', name: 'byoc', config: { type: 'self_hosted' } }], stream: idleStream }) + cleanups.push(byocOnly.close) + const second = await mountWith([], { token: 'pt-test', baseURL: byocOnly.baseURL }) + await expect(start(second.provider, plain, 'x')).rejects.toThrow('the only Qoder Cloud environment is self-hosted (BYOC) and no one can be asked') + }) + + it('treats a NO_PROVIDER answerer like headless', async () => { + const mock = await startMockQoder({ environments: ENVIRONMENTS, stream: idleStream }) + cleanups.push(mock.close) + const Questions = stubQuestions(() => { throw Object.assign(new Error('no answerer'), { code: 'NO_PROVIDER' }) }) + const { provider } = await mountWith([Questions], { token: 'pt-test', baseURL: mock.baseURL }) + await expect(start(provider, plain, 'x')).rejects.toThrow('no interactive UI is attached') + }) + + it('asks once, uses the answer, saves it, and does not ask again', async () => { + const mock = await startMockQoder({ environments: ENVIRONMENTS, agents: [{ id: 'agent_cr', name: 'Code Review' }], stream: idleStream }) + cleanups.push(mock.close) + const Questions = stubQuestions(questions => ({ + answers: questions.map(q => q.id === 'qoder-cloud-agents-environment' + ? { id: q.id, selected: ['Default · env_b'] } + : { id: q.id, selected: ['Code Review · agent_cr'] }), + })) + const { ctx, provider } = await mountWith([Questions, StubSettings], { token: 'pt-test', baseURL: mock.baseURL }) + const [first, second] = await Promise.all([start(provider, plain, 'one'), start(provider, plain, 'two')]) + const results = await Promise.all([first.result, second.result]) + const questions = (ctx as any).userQuestions.asked + expect(questions).toHaveLength(1) + expect(questions[0].map((q: any) => q.id)).toEqual(['qoder-cloud-agents-environment', 'qoder-cloud-agents-agent']) + const envOptions = questions[0][0].options.map((o: any) => o.label) + expect(envOptions).toEqual(['CLI tools · env_cli', 'Default · env_a', 'Default · env_b', 'team byoc · env_byoc', 'Create a new environment "dsh-default"']) + const sessions = mock.requests.filter(r => r.path === '/sessions').map(r => r.body) + expect(sessions.map(b => [b.environment_id, b.agent])).toEqual([['env_b', 'agent_cr'], ['env_b', 'agent_cr']]) + expect((ctx as any).settings.writes).toEqual([{ + ns: 'qoder-cloud-agents', + ops: [{ op: 'set', path: ['environmentId'], value: 'env_b' }, { op: 'set', path: ['agentId'], value: 'agent_cr' }], + }]) + // Whichever run won the selection queue reports how the binding was chosen. + const footers = results.map(result => (result.output[0] as { text: string }).text) + expect(footers.filter(text => text.includes('Saved to this profile; change with /qoder-cloud-agents.'))).toHaveLength(1) + }) + + it('accepts a free-text environment id, including a self-hosted one', async () => { + const mock = await startMockQoder({ environments: ENVIRONMENTS, agents: [{ id: 'agent_m', name: 'dsh-qoder-cloud-delegate' }], stream: idleStream }) + cleanups.push(mock.close) + const Questions = stubQuestions(questions => ({ answers: questions.map(q => ({ id: q.id, selected: [], custom: 'env_byoc' })) })) + const { ctx, provider } = await mountWith([Questions], { token: 'pt-test', baseURL: mock.baseURL }) + await (await start(provider, plain, 'x')).result + expect((ctx as any).userQuestions.asked[0].map((q: any) => q.id)).toEqual(['qoder-cloud-agents-environment']) + expect(mock.requests.find(r => r.path === '/sessions')!.body).toMatchObject({ environment_id: 'env_byoc', agent: 'agent_m' }) + }) +}) + +describe('/qoder-cloud-agents command', () => { + it('lists, sets and resets the saved binding', async () => { + const mock = await startMockQoder({ environments: ENVIRONMENTS, agents: [{ id: 'agent_cr', name: 'Code Review' }], stream: idleStream }) + cleanups.push(mock.close) + const { ctx, provider } = await mountWith([StubCommands, StubSettings], { token: 'pt-test', baseURL: mock.baseURL }) + const command = (ctx as any).commands.definitions[0] + expect(command.name).toBe('qoder-cloud-agents') + const run = (rawInput: string) => command.handler({ rawInput, signal: new AbortController().signal, agent: {}, attachments: [] }) + + const list = await run(' env') + expect(list.kind).toBe('success') + expect(list.text).toContain('env_byoc team byoc (self-hosted (BYOC)') + + expect((await run(' env Default')).text).toContain('several environments are named "Default"') + const set = await run(' env env_a') + expect(set.text).toContain('Environment set to Default (env_a).\nSaved to this profile.') + const agent = await run(' agent new') + expect(agent.text).toContain('Agent set to dsh-qoder-cloud-delegate (agent_new)') + + // The command's choice is used without asking (no userQuestions mounted). + await (await start(provider, plain, 'x')).result + expect(mock.requests.find(r => r.path === '/sessions')!.body).toMatchObject({ environment_id: 'env_a', agent: 'agent_new' }) + + expect((await run(' reset')).kind).toBe('success') + expect((ctx as any).settings.writes.at(-1).ops).toEqual([ + { op: 'unset', path: ['environmentId'] }, + { op: 'unset', path: ['agentId'] }, + ]) + await expect(start(provider, plain, 'y')).rejects.toThrow('no one can be asked to choose') + expect((await run(' bogus')).kind).toBe('error') + }) +}) + + +describe('GitHub pre-flight', () => { + let ghRepo: string + const gitIn = (dir: string, ...args: string[]) => execFileSync('git', args, { cwd: dir, stdio: 'pipe' }).toString().trim() + beforeAll(() => { + ghRepo = mkdtempSync(join(tmpdir(), 'qoder-gh-')) + gitIn(ghRepo, 'init', '-q', '-b', 'feature') + gitIn(ghRepo, 'config', 'user.email', 't@example.com') + gitIn(ghRepo, 'config', 'user.name', 't') + writeFileSync(join(ghRepo, 'a.txt'), 'a') + gitIn(ghRepo, 'add', '.') + gitIn(ghRepo, 'commit', '-q', '-m', 'one') + gitIn(ghRepo, 'remote', 'add', 'origin', 'https://github.com/acme/secret.git') + }) + afterAll(() => rmSync(ghRepo, { recursive: true, force: true })) + + const ENV = [{ id: 'env_1', name: 'Default', config: { type: 'cloud' } }] + + it('refuses a private repository without a token before creating a session', async () => { + githubAnswer = () => new Response('{"message":"Not Found"}', { status: 404 }) + const mock = await startMockQoder({ environments: ENV, stream: idleStream }) + cleanups.push(mock.close) + const { provider } = await mountWith([], { token: 'pt-test', baseURL: mock.baseURL, gitTokenEnv: 'QODER_GIT_TOKEN_UNSET' }) + await expect(start(provider, ghRepo, 'x')).rejects.toThrow('acme/secret is private or does not exist; set QODER_GIT_TOKEN_UNSET') + expect(mock.requests.map(r => r.path)).not.toContain('/sessions') + }) + + it('rejects a token GitHub does not accept', async () => { + githubAnswer = () => new Response('{}', { status: 401 }) + process.env.QODER_GIT_TOKEN_BAD = 'ghp_bad' + const mock = await startMockQoder({ environments: ENV, stream: idleStream }) + cleanups.push(mock.close) + const { provider } = await mountWith([], { token: 'pt-test', baseURL: mock.baseURL, gitTokenEnv: 'QODER_GIT_TOKEN_BAD' }) + await expect(start(provider, ghRepo, 'x')).rejects.toThrow('token in QODER_GIT_TOKEN_BAD was rejected') + }) + + it('warns when the token cannot push, and drops the commit checkout the platform ignores', async () => { + let seenAuth: string | undefined + githubAnswer = (auth) => { + seenAuth = auth + return new Response(JSON.stringify({ permissions: { push: false } }), { status: 200 }) + } + process.env.QODER_GIT_TOKEN_RO = 'ghp_readonly' + const mock = await startMockQoder({ environments: ENV, stream: idleStream }) + cleanups.push(mock.close) + const { provider } = await mountWith([], { token: 'pt-test', baseURL: mock.baseURL, gitTokenEnv: 'QODER_GIT_TOKEN_RO' }) + const result = await (await start(provider, ghRepo, 'x')).result + expect(seenAuth).toBe('Bearer ghp_readonly') + const text = (result.output[0] as { text: string }).text + expect(text).toContain('Note: the token in QODER_GIT_TOKEN_RO has no push access to acme/secret') + const resource = mock.requests.find(r => r.path === '/sessions')!.body.resources[0] + expect(resource).toEqual({ type: 'github_repository', url: 'https://github.com/acme/secret.git', mount_path: '/data/workspace/secret', authorization_token: 'ghp_readonly' }) + const message = mock.posted.find(e => e.type === 'user.message') + expect(message.content[0].text).toMatch(/default branch; before working, run `git fetch origin [0-9a-f]{40} && git checkout [0-9a-f]{40}`/) + }) + + it('notes that a public repository without a token cannot be pushed to', async () => { + githubAnswer = () => new Response(JSON.stringify({}), { status: 200 }) + const mock = await startMockQoder({ environments: ENV, stream: idleStream }) + cleanups.push(mock.close) + const { provider } = await mountWith([], { token: 'pt-test', baseURL: mock.baseURL, gitTokenEnv: 'QODER_GIT_TOKEN_UNSET' }) + const result = await (await start(provider, ghRepo, 'x')).result + expect((result.output[0] as { text: string }).text).toContain('no QODER_GIT_TOKEN_UNSET is set: the cloud agent can read this public repository but cannot push') + expect(mock.requests.find(r => r.path === '/sessions')!.body.resources[0].authorization_token).toBeUndefined() + }) +}) + + +describe('repository resources (aligned with the Qoder console)', () => { + const code: LocalRepository = { + url: 'https://git.example.com/team/svc.git', + github: false, + name: 'svc', + mountPath: '/data/workspace/svc', + head: 'a'.repeat(40), + checkout: { type: 'branch', name: 'master' }, + warnings: [], + } + + it('reads the account from an https origin but not from ssh', () => { + expect(httpsRemoteUsername('https://alice@git.example.com/team/svc.git')).toBe('alice') + expect(httpsRemoteUsername('https://alice:secret@git.example.com/team/svc.git')).toBe('alice') + expect(httpsRemoteUsername('git@gitlab.example.com:team/svc.git')).toBeUndefined() + expect(httpsRemoteUsername('ssh://git@gitlab.example.com/team/svc.git')).toBeUndefined() + expect(httpsRemoteUsername('https://git.example.com/team/svc.git')).toBeUndefined() + }) + + it('puts the account in the URL and the token in password', () => { + expect(repositoryResource(code, { gitToken: 'pt_code', gitUsername: 'alice.w' })).toEqual({ + type: 'git_repository', + url: 'https://alice.w@git.example.com/team/svc.git', + password: 'pt_code', + mount_path: '/data/workspace/svc', + checkout: { type: 'branch', name: 'master' }, + }) + }) + + it('falls back to the origin URL account', () => { + const resource = repositoryResource({ ...code, remoteUsername: 'alice' }, { gitToken: 'pt_code' }) + expect(resource).toMatchObject({ url: 'https://alice@git.example.com/team/svc.git', password: 'pt_code' }) + }) + + it('requires an account when a token is set', () => { + expect(() => repositoryResource(code, { gitToken: 'pt_code', gitTokenEnv: 'QODER_GIT_TOKEN' })) + .toThrow('git.example.com needs an account name with QODER_GIT_TOKEN; set gitUsername') + }) + + it('sends a public clone without account or password when no token is set', () => { + expect(repositoryResource({ ...code, remoteUsername: 'alice' }, {})).toEqual({ + type: 'git_repository', + url: 'https://git.example.com/team/svc.git', + mount_path: '/data/workspace/svc', + checkout: { type: 'branch', name: 'master' }, + }) + }) + + it('fails a token-authenticated delegation before prompting or creating a session when the account is missing', async () => { + const codeRepo = mkdtempSync(join(tmpdir(), 'qoder-code-')) + cleanups.push(async () => rmSync(codeRepo, { recursive: true, force: true })) + const g = (...args: string[]) => execFileSync('git', args, { cwd: codeRepo, stdio: 'pipe' }) + g('init', '-q', '-b', 'master'); g('config', 'user.email', 't@example.com'); g('config', 'user.name', 't') + writeFileSync(join(codeRepo, 'a.txt'), 'a'); g('add', '.'); g('commit', '-q', '-m', 'one') + g('remote', 'add', 'origin', 'git@gitlab.example.com:team/svc.git') + process.env.QODER_GIT_TOKEN_CODE = 'pt_code' + const mock = await startMockQoder({ environments: ENVIRONMENTS, stream: idleStream }) + cleanups.push(mock.close) + const { provider } = await mountWith([], { token: 'pt-test', baseURL: mock.baseURL, gitTokenEnv: 'QODER_GIT_TOKEN_CODE' }) + await expect(start(provider, codeRepo, 'x')).rejects.toThrow('gitlab.example.com needs an account name') + expect(mock.requests.map(r => r.path)).toEqual([]) + }) +}) diff --git a/demos/dsh-qoder-cloud-agents/tsconfig.json b/demos/dsh-qoder-cloud-agents/tsconfig.json new file mode 100644 index 0000000..c410330 --- /dev/null +++ b/demos/dsh-qoder-cloud-agents/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "target": "es2024", + "module": "esnext", + "moduleResolution": "bundler", + "rootDir": "src", + "outDir": "lib/types", + "declaration": true, + "skipLibCheck": true, + "allowImportingTsExtensions": true, + "rewriteRelativeImportExtensions": true, + "strict": true, + "noUncheckedIndexedAccess": true, + "exactOptionalPropertyTypes": true, + "noImplicitOverride": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "types": ["node"] + }, + "include": ["src/**/*.ts"] +} diff --git a/demos/dsh-qoder-cloud-agents/tsdown.config.ts b/demos/dsh-qoder-cloud-agents/tsdown.config.ts new file mode 100644 index 0000000..b626c8d --- /dev/null +++ b/demos/dsh-qoder-cloud-agents/tsdown.config.ts @@ -0,0 +1,19 @@ +import { defineConfig } from 'tsdown' + +/** Self-contained Loader entries: dsh packages stay external (peers). */ +const entry = (path: string) => ({ + entry: [path], + outDir: 'lib', + format: ['esm'] as const, + platform: 'node' as const, + target: 'es2024' as const, + fixedExtension: false, + dts: false, + clean: false, +}) + +export default defineConfig([ + entry('lib/types/index.js'), + // The 「云端模式」 preset's child plugin, loaded as `dsh-qoder-cloud-agents/cloud-route`. + entry('lib/types/cloud-route.js'), +]) diff --git a/demos/dsh-qoder-cloud-agents/vitest.config.ts b/demos/dsh-qoder-cloud-agents/vitest.config.ts new file mode 100644 index 0000000..5523f18 --- /dev/null +++ b/demos/dsh-qoder-cloud-agents/vitest.config.ts @@ -0,0 +1,3 @@ +import { defineConfig } from 'vitest/config' + +export default defineConfig({ test: { include: ['tests/**/*.spec.ts'], testTimeout: 20_000 } })