@yiyi_zhang/laoshi 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/README.md +3 -2
- package/adapters/dsh/adapter.ts +22 -1
- package/adapters/dsh/dsh-runtime.ts +14 -3
- package/adapters/dsh/install.mjs +16 -4
- package/adapters/dsh/plugin/index.mjs +197 -18
- package/adapters/dsh/plugin/package.json +1 -1
- package/adapters/mogao/adapter.ts +9 -1
- package/adapters/mogao/mogao-runtime.ts +30 -8
- package/adapters/paseo/install.mjs +13 -4
- package/adapters/paseo/plugin/client/data.ts +13 -2
- package/adapters/paseo/plugin/client/detail.tsx +244 -4
- package/adapters/paseo/plugin/client/format.ts +25 -117
- package/adapters/paseo/plugin/client/overview.tsx +3 -3
- package/adapters/paseo/plugin/index.server.ts +2 -1
- package/adapters/paseo/plugin/package.json +1 -1
- package/adapters/paseo/plugin/paseo-plugin.json +1 -1
- package/adapters/paseo/plugin/server/handlers.ts +22 -4
- package/adapters/paseo/plugin/server/req.ts +17 -4
- package/adapters/paseo/plugin/shared/contracts.ts +28 -2
- package/adapters/paseo/plugin/shared/view-model.ts +425 -0
- package/bin/req.mjs +10 -0
- package/contracts/cli-json.md +3 -1
- package/docs/design/dsh-adapter.md +9 -9
- package/docs/design/shared-ui.md +43 -0
- package/docs/guide//345/256/211/350/243/205/344/270/216/345/215/207/347/272/247.md +13 -8
- package/docs/guide//347/234/237/345/256/236/347/216/257/345/242/203/350/265/260/346/237/245.md +78 -0
- package/engine/src/api.ts +11 -2
- package/engine/src/board.ts +435 -0
- package/engine/src/config.ts +23 -0
- package/engine/src/doctor.ts +25 -0
- package/engine/src/estimate.ts +11 -0
- package/engine/src/extensions.ts +271 -0
- package/engine/src/handover-cmd.ts +47 -0
- package/engine/src/handover.ts +89 -0
- package/engine/src/history.ts +102 -0
- package/engine/src/joint.ts +49 -4
- package/engine/src/launch.ts +2 -1
- package/engine/src/main.ts +1 -1
- package/engine/src/messages.ts +58 -0
- package/engine/src/pipeline.ts +109 -4
- package/engine/src/reply.ts +27 -6
- package/engine/src/semver.ts +21 -0
- package/package.json +5 -2
- package/site-dist/404.html +2 -2
- package/site-dist/assets/{app.BxNgGFu-.js → app.DZpVs0VH.js} +1 -1
- package/site-dist/assets/changelog.md.CdUYbro4.js +1 -0
- package/site-dist/assets/{changelog.md.D0PzSXw9.lean.js → changelog.md.CdUYbro4.lean.js} +1 -1
- package/site-dist/assets/chunks/@localSearchIndexroot.CHr-ITwS.js +1 -0
- package/site-dist/assets/chunks/{VPLocalSearchBox.Dw_fzw9V.js → VPLocalSearchBox.BHkmziy1.js} +1 -1
- package/site-dist/assets/chunks/{theme.CwrnT4KI.js → theme.BsPChbDE.js} +2 -2
- package/site-dist/assets/guide_dsh.md.D0XhcUHz.js +7 -0
- package/site-dist/assets/guide_dsh.md.D0XhcUHz.lean.js +7 -0
- package/site-dist/assets/{guide_getting-started.md.CjzysdDe.js → guide_getting-started.md.BDd3nU5n.js} +1 -1
- package/site-dist/assets/{guide_install.md.By4WxsJG.js → guide_install.md.SsIHMfUu.js} +7 -5
- package/site-dist/assets/{guide_install.md.By4WxsJG.lean.js → guide_install.md.SsIHMfUu.lean.js} +7 -5
- package/site-dist/assets/guide_walkthrough.md.nj_PWP9Y.js +5 -0
- package/site-dist/assets/guide_walkthrough.md.nj_PWP9Y.lean.js +5 -0
- package/site-dist/assets/reference_contracts_cli-json.md.3iU9h4rw.js +1 -0
- package/site-dist/assets/reference_contracts_cli-json.md.3iU9h4rw.lean.js +1 -0
- package/site-dist/changelog.html +5 -5
- package/site-dist/guide/cli.html +4 -4
- package/site-dist/guide/dsh.html +8 -6
- package/site-dist/guide/getting-started.html +5 -5
- package/site-dist/guide/how-it-works.html +4 -4
- package/site-dist/guide/index.html +4 -4
- package/site-dist/guide/install.html +11 -9
- package/site-dist/guide/intranet.html +4 -4
- package/site-dist/guide/maintainer.html +4 -4
- package/site-dist/guide/mogao.html +4 -4
- package/site-dist/guide/phases.html +4 -4
- package/site-dist/guide/project.html +4 -4
- package/site-dist/guide/user.html +4 -4
- package/site-dist/guide/walkthrough.html +34 -0
- package/site-dist/hashmap.json +1 -1
- package/site-dist/index.html +4 -4
- package/site-dist/reference/adr/0001-new-repo-core-and-adapters.html +4 -4
- package/site-dist/reference/adr/0002-two-orchestration-modes.html +4 -4
- package/site-dist/reference/adr/0003-generate-once-then-lock.html +4 -4
- package/site-dist/reference/adr/0004-external-contracts-stay-stable.html +4 -4
- package/site-dist/reference/adr/0005-skill-names.html +4 -4
- package/site-dist/reference/adr/0006-deterministic-engine-platform-capabilities.html +4 -4
- package/site-dist/reference/adr/0007-one-install-many-repos.html +4 -4
- package/site-dist/reference/adr/0008-capability-sources-and-platform-plugin.html +4 -4
- package/site-dist/reference/adr/index.html +4 -4
- package/site-dist/reference/commands.html +4 -4
- package/site-dist/reference/config.html +4 -4
- package/site-dist/reference/contracts/agent-runtime.html +4 -4
- package/site-dist/reference/contracts/cli-json.html +5 -5
- package/site-dist/reference/contracts/feature-files.html +4 -4
- package/site-dist/reference/contracts/index.html +4 -4
- package/site-dist/reference/contracts/notifier-event.html +4 -4
- package/site-dist/reference/contracts/result-file.html +4 -4
- package/site-dist/reference/contracts/spec.html +4 -4
- package/site-dist/reference/contracts/state.html +4 -4
- package/site-dist/reference/contracts/usage-record.html +4 -4
- package/site-dist/reference/contracts/verify.html +4 -4
- package/site-dist/reference/design/adapter-guide.html +4 -4
- package/site-dist/reference/design/architecture.html +4 -4
- package/site-dist/reference/design/builtin-capabilities.html +4 -4
- package/site-dist/reference/design/cli-adapter.html +4 -4
- package/site-dist/reference/design/platform-vocabulary.html +4 -4
- package/site-dist/reference/scope.html +4 -4
- package/skills/laoshi-setup/SKILL.md +1 -1
- package/ui/shared/view-model.ts +424 -0
- package/ui/web/board.ts +1126 -0
- package/site-dist/assets/changelog.md.D0PzSXw9.js +0 -1
- package/site-dist/assets/chunks/@localSearchIndexroot.vA-yiw-8.js +0 -1
- package/site-dist/assets/guide_dsh.md.0X-eYB87.js +0 -5
- package/site-dist/assets/guide_dsh.md.0X-eYB87.lean.js +0 -5
- package/site-dist/assets/reference_contracts_cli-json.md.D6vfWOD9.js +0 -1
- package/site-dist/assets/reference_contracts_cli-json.md.D6vfWOD9.lean.js +0 -1
- /package/site-dist/assets/{guide_getting-started.md.CjzysdDe.lean.js → guide_getting-started.md.BDd3nU5n.lean.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
laoshi 的版本号遵循语义化版本,从 0.1.0 开始;每一版的标题写成 `## <版本> - <日期>`。每一版先写使用者会看到的变化,再写升级须知。laoshi 之前的历史见 paseo-req-kit 的更新记录(laoshi 从它的 1.15.0 抽出)。
|
|
4
4
|
|
|
5
|
+
## 0.3.0 - 2026-11-24
|
|
6
|
+
|
|
7
|
+
正式版(npm `latest` 标签):新增共享 Web 需求看板与验收工作台、全链路变更历史与转交、受控流程扩展、多仓库联合开发增强、预算预估与多模型评审检查,并将 Paseo(`0.11–0.17`)需求插件与 DeepSeek Harness(`dsh 0.2.2-alpha.2` / `0.2.2-rc.5`)宿主适配及文档补齐。安装:`npx -y @yiyi_zhang/laoshi@latest install --platform <平台>`。
|
|
8
|
+
|
|
9
|
+
### 使用者会看到的变化
|
|
10
|
+
|
|
11
|
+
- **共享 Web 需求看板与验收工作台(`laoshi board`)**:任意平台均可运行 `laoshi board` 打开本机实时中文 Bento 需求看板;支持总览分组、「需要你处理」置顶、需求详情 6 站放行轨,以及验收工作台(一键试用启停、逐条 AC 勾选与提交 `acceptance.md` 结论、证据预览)。安装时可通过 `dsh` 自动托管看板(默认启用 `board: true`,`--no-board` / `--board-port` 可选配置,`laoshi doctor` 直接显示访问地址)。
|
|
12
|
+
- **改需求、变更历史与转交接手**:Web 看板「变更与接手」页签、Paseo 插件详情页及 CLI(`laoshi reply --change`、`laoshi handover`)支持在需求推进中发起改需求、倒序查看 `changes.md` 变更历史与 `spec.md` 提交 diff(绿增/红删高亮),并支持转交接手及完整交接记录(`.pipeline/owner.json`)。
|
|
13
|
+
- **受控流程扩展(`extensions`)**:支持在项目配置 `.laoshi.json` 中向固定主阶段后挂载受控的 AI/skill 或脚本扩展步骤(注入 `LAOSHI_*` 环境变量,日志保留在 `.pipeline/extensions/`),并保持 Windows 下 `cmd.exe` 兼容。
|
|
14
|
+
- **多仓库联合开发增强**:支持配置 `maxJointRepos`(1–10),`/laoshi-setup` 自动发现同级 Git 仓库辅助配置,需求详情页直观展示各关联仓库分支、工作区路径与质量门状态。
|
|
15
|
+
- **预算预估与多模型评审检查**:开工前与看板详情提供历史同档位耗时 / token 预算预估及超预算提醒;启用多模型评审小组但配置缺失或仅单个提供方时由 `laoshi doctor` 提前告警。
|
|
16
|
+
- **Paseo `0.11–0.17` 实机适配与插件体验**:支持 `laoshi install --platform paseo --with-plugin` 一步部署并加载 Paseo 插件,插件与 Web 看板共享状态分组与文案,修复 Paseo 0.17 下服务端打包运行时缺少 `import.meta.url` 导致的插件 RPC 报错。
|
|
17
|
+
- **dsh `0.2.2-rc.5` 适配与定时能力补齐**:插件实现 `schedule` 的 `expiresAt` 到期自动取消及 `scheduleNewAgent` 独立定时会话;双版本兼容 `dsh 0.2.2-alpha.2` 与 `0.2.2-rc.5` 的 `startActivation`、`subagents.interrupt`、`schedule.create`/`edit`(含 `cron.time_zone`)与 `sessions.events`。
|
|
18
|
+
- **摸高与通知体验打磨**:摸高超长追问/打断消息写入文件兜底,同主机中断轮次自动续接;全部停顿通知统一附上【停下原因】与【下一步请说】提示;新增《Paseo Web 与 dsh 真实环境插件走查清单》及版本范围守护。
|
|
19
|
+
|
|
20
|
+
### 升级须知
|
|
21
|
+
|
|
22
|
+
- **Paseo**:运行 `laoshi upgrade` 升级到 `0.3.0`(支持 Paseo `0.11–0.17`;安装过插件时自动同步刷新并重载)。如果使用了非默认 `--home`,请在守护进程中设置 `LAOSHI_HOME` 或在 Paseo「设置 → 插件 → `laoshi 需求`」填写安装根路径。
|
|
23
|
+
- **DeepSeek Harness(dsh)**:运行 `laoshi upgrade` 升级到 `0.3.0`,同步更新 `laoshi-dsh-plugin`(同时兼容 `0.2.2-alpha.2` 与 `0.2.2-rc.5+`),并默认随宿主开启托管看板(可通过 `--no-board` 关闭)。
|
|
24
|
+
- **摸高**:替换为本版本 Release 附带的 `laoshi-expert-0.3.0.zip`(或运行 `node adapters/mogao/make-expert.mjs` 重新生成)。
|
|
25
|
+
|
|
5
26
|
## 0.2.0 - 2026-11-21
|
|
6
27
|
|
|
7
28
|
正式版(npm `latest` 标签):汇总 0.2.0-beta.1~beta.3 的全部功能(摸高适配器与专家包、Paseo 需求插件迁入、`laoshi migrate`、`laoshi permission`),并补充摸高版本自检、进程组清理、上下文控制、`laoshi diagnose` 脱敏诊断包与 Release 自动附带摸高专家包。安装:`npx -y @yiyi_zhang/laoshi@latest install --platform <平台>`。
|
package/README.md
CHANGED
|
@@ -4,14 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
laoshi 是从 [paseo-req-kit](https://github.com/yiyisf/paseo-req-kit)(req-kit)中抽取出来的、与 agent 平台无关的需求开发体系:用对话对齐需求,由一组分工明确的 agent 完成方案设计、实现、评审和验证,每一步都有产出文件和验收门,流程由程序保证,而不是由 AI 或人即兴发挥。
|
|
6
6
|
|
|
7
|
-
>
|
|
7
|
+
> 支持 **Paseo(`0.11–0.17`,优先 Web 端,内置 Paseo 需求插件)**、**DeepSeek Harness(`dsh 0.2.x`,内置 `laoshi-dsh-plugin` 与托管 Web 看板)**、**命令行 agent(`cli`)**与**摸高(`mogao`)**;全平台共用本地 Web 需求看板(`laoshi board`)。核心从 req-kit 抽取并持续演进(见[移植记录](docs/porting-log.md)、[架构文档](docs/design/architecture.md))。
|
|
8
8
|
|
|
9
9
|
## 安装
|
|
10
10
|
|
|
11
11
|
与 paseo-req-kit 一样从 npm 分发,一步安装:
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
npx -y @yiyi_zhang/laoshi@latest install --platform dsh
|
|
14
|
+
npx -y @yiyi_zhang/laoshi@latest install --platform dsh # dsh(默认开启托管看板)
|
|
15
|
+
npx -y @yiyi_zhang/laoshi@latest install --platform paseo --with-plugin # Paseo(同时安装需求插件)
|
|
15
16
|
# 公司内网只有 npm 镜像时:
|
|
16
17
|
npx -y --registry=https://npm.example.internal/ @yiyi_zhang/laoshi@latest install --platform dsh
|
|
17
18
|
laoshi doctor --no-project
|
package/adapters/dsh/adapter.ts
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import fs from "node:fs";
|
|
6
6
|
import type { AgentProfile } from "../../engine/src/config.js";
|
|
7
|
+
import { kitVersion } from "../../engine/src/locations.js";
|
|
7
8
|
import type { PlatformAdapter } from "../../engine/src/platform.js";
|
|
9
|
+
import { extractSemver, satisfies, supportedPlatformRange } from "../../engine/src/semver.js";
|
|
8
10
|
import type { DshModels } from "./dsh-runtime.js";
|
|
9
11
|
import { channelPaths, dshHome } from "./plugin/channel.mjs";
|
|
10
12
|
|
|
@@ -16,6 +18,7 @@ export const dshAdapter: PlatformAdapter = {
|
|
|
16
18
|
services: "builtin",
|
|
17
19
|
worktree: "builtin",
|
|
18
20
|
scheduling: "plugin",
|
|
21
|
+
scheduleAgent: "plugin",
|
|
19
22
|
sessionAgent: "plugin",
|
|
20
23
|
activity: "plugin",
|
|
21
24
|
runningTool: "plugin",
|
|
@@ -46,8 +49,26 @@ export const dshAdapter: PlatformAdapter = {
|
|
|
46
49
|
const paths = channelPaths(dshHome(env));
|
|
47
50
|
try {
|
|
48
51
|
const call = pluginClient(env, 10_000);
|
|
49
|
-
const hello = await call<{ plugin: string; approvals: string }>("hello");
|
|
52
|
+
const hello = await call<{ plugin: string; approvals: string; dshVersion?: string | null }>("hello");
|
|
50
53
|
tools.report("ok", `已连接 laoshi 的 dsh 插件 ${hello.plugin}(${paths.socket}),审批策略:${hello.approvals}`);
|
|
54
|
+
const expectedPlugin = kitVersion();
|
|
55
|
+
if (hello.plugin && hello.plugin !== expectedPlugin) {
|
|
56
|
+
tools.report("warn", `dsh 插件版本(${hello.plugin})与当前 laoshi(${expectedPlugin})不一致`, "运行 `laoshi install --platform dsh` 更新插件并重启 dsh");
|
|
57
|
+
}
|
|
58
|
+
const dshRange = supportedPlatformRange("dsh");
|
|
59
|
+
const dshVer = hello.dshVersion ? extractSemver(hello.dshVersion) : null;
|
|
60
|
+
if (dshRange && dshVer) {
|
|
61
|
+
if (satisfies(dshVer, dshRange)) tools.report("ok", `dsh 版本 ${dshVer} 在支持范围内(${dshRange})`);
|
|
62
|
+
else tools.report("warn", `dsh 版本 ${dshVer} 不在已验证的支持范围(${dshRange})内`, "dsh 处于快速迭代期,如接口行为异常请检查适配更新");
|
|
63
|
+
}
|
|
64
|
+
const board = await call<{ enabled: boolean; running: boolean; url: string | null; error: string | null }>("board").catch(() => null);
|
|
65
|
+
if (board?.running && board.url) {
|
|
66
|
+
tools.report("ok", `需求看板运行中:${board.url}`);
|
|
67
|
+
} else if (board?.enabled) {
|
|
68
|
+
tools.report("warn", `需求看板已启用但未运行${board.error ? `(${board.error})` : ""}`, "重启 dsh,或直接运行 laoshi board 打开本机看板");
|
|
69
|
+
} else if (board) {
|
|
70
|
+
tools.info("dsh 插件未开启托管需求看板;可随时运行 laoshi board 打开,或在 cordis.patch.yml 中设置 board: true");
|
|
71
|
+
}
|
|
51
72
|
const listed = await call<DshModels>("models").catch(() => null);
|
|
52
73
|
if (!listed) {
|
|
53
74
|
tools.report("warn", "插件没有列出 dsh 的模型(插件版本较旧?)", "重新运行安装脚本,更新 laoshi 的 dsh 插件后重启 dsh");
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
//
|
|
5
5
|
// Worktrees and services are laoshi's builtin ones (engine/src/builtin, laoshi M2b): the methods
|
|
6
6
|
// below are placeholders the runtime layer replaces. Each role can run on its own dsh model
|
|
7
|
-
// (stepModel). Not yet: provider quota, platform agent profiles,
|
|
7
|
+
// (stepModel). Not yet: provider quota, platform agent profiles, event-stream wait, browser capabilities.
|
|
8
8
|
import fs from "node:fs";
|
|
9
9
|
import net from "node:net";
|
|
10
10
|
import type { RunningTool } from "../../engine/src/scan-guard.js";
|
|
@@ -205,17 +205,28 @@ export function createRuntimeWithClient(call: PluginCall, log: (message: string)
|
|
|
205
205
|
},
|
|
206
206
|
|
|
207
207
|
async scheduleMessage(input) {
|
|
208
|
-
if (input.expiresAt) log("dsh 的定时任务不能设截止时间:这条定时消息会一直有效,直到被取消");
|
|
209
208
|
const { id } = await call<{ id: string }>("schedule", {
|
|
210
209
|
sessionId: input.agentId,
|
|
211
210
|
title: input.name,
|
|
212
211
|
prompt: input.prompt,
|
|
213
212
|
...(input.cron ? { cron: input.cron, timeZone: localTimeZone() } : { at: input.at?.toISOString() }),
|
|
213
|
+
...(input.expiresAt ? { expiresAt: input.expiresAt.toISOString() } : {}),
|
|
214
214
|
});
|
|
215
215
|
return scheduleId(input.agentId, id);
|
|
216
216
|
},
|
|
217
217
|
|
|
218
|
-
|
|
218
|
+
async scheduleNewAgent(input) {
|
|
219
|
+
// dsh sessions.create takes { cwd } and uses dsh's default session model.
|
|
220
|
+
if (stepModel(input.profile)) log("dsh 的定时会话使用 dsh 默认模型");
|
|
221
|
+
const r = await call<{ id: string; sessionId: string }>("scheduleAgent", {
|
|
222
|
+
cwd: input.cwd,
|
|
223
|
+
title: input.name,
|
|
224
|
+
prompt: input.prompt,
|
|
225
|
+
cron: input.cron,
|
|
226
|
+
timeZone: localTimeZone(),
|
|
227
|
+
});
|
|
228
|
+
return scheduleId(r.sessionId, r.id);
|
|
229
|
+
},
|
|
219
230
|
|
|
220
231
|
async cancelSchedule(id) {
|
|
221
232
|
const parsed = parseScheduleId(id);
|
package/adapters/dsh/install.mjs
CHANGED
|
@@ -14,6 +14,8 @@ export const options = {
|
|
|
14
14
|
profile: { type: "string" },
|
|
15
15
|
"dsh-bin": { type: "string" },
|
|
16
16
|
approvals: { type: "string" },
|
|
17
|
+
"no-board": { type: "boolean" },
|
|
18
|
+
"board-port": { type: "string" },
|
|
17
19
|
};
|
|
18
20
|
|
|
19
21
|
const slash = (p) => p.split(path.sep).join("/");
|
|
@@ -70,16 +72,26 @@ export function setup({ kit, args, config, env = process.env, dry, report }) {
|
|
|
70
72
|
const patchFile = path.join(profileDir, "cordis.patch.yml");
|
|
71
73
|
// dsh writes the file with an empty flow list ("[]"); entries go into a block list instead.
|
|
72
74
|
const current = (fs.existsSync(patchFile) ? fs.readFileSync(patchFile, "utf8") : "").replace(/^\s*\[\]\s*$/m, "");
|
|
73
|
-
if (current.includes("laoshi-dsh-plugin")) report("ok", `${patchFile}
|
|
75
|
+
if (current.includes("laoshi-dsh-plugin")) report("ok", `${patchFile} 中已挂载插件,不改动(审批与看板配置以文件中的为准)`);
|
|
74
76
|
else {
|
|
77
|
+
const enableBoard = !args["no-board"];
|
|
78
|
+
const boardPort = args["board-port"] ? Number(args["board-port"]) || 0 : 0;
|
|
75
79
|
if (!dry) {
|
|
76
80
|
fs.mkdirSync(profileDir, { recursive: true });
|
|
77
|
-
const
|
|
81
|
+
const extraLines = [
|
|
82
|
+
` kitRoot: '${slash(kit)}'`,
|
|
83
|
+
` board: ${enableBoard}`,
|
|
84
|
+
...(boardPort > 0 ? [` boardPort: ${boardPort}`] : []),
|
|
85
|
+
];
|
|
86
|
+
const block = `- insert:\n - id: laoshi-dsh\n name: 'laoshi-dsh-plugin'\n config:\n approvals: ${approvals}\n${extraLines.join("\n")}\n`;
|
|
78
87
|
fs.writeFileSync(patchFile, `${current}${current && !current.endsWith("\n") ? "\n" : ""}${block}`);
|
|
79
88
|
}
|
|
80
|
-
report("ok", `在 ${patchFile} 末尾挂载插件(审批策略 ${approvals})`);
|
|
89
|
+
report("ok", `在 ${patchFile} 末尾挂载插件(审批策略 ${approvals},需求看板${enableBoard ? "已启用" : "已关闭"})`);
|
|
81
90
|
}
|
|
82
|
-
return [
|
|
91
|
+
return [
|
|
92
|
+
`重启 dsh(profile ${profile}),让插件与需求看板生效`,
|
|
93
|
+
"运行 laoshi doctor 可查看需求看板地址;也可随时运行 laoshi board 打开",
|
|
94
|
+
];
|
|
83
95
|
}
|
|
84
96
|
|
|
85
97
|
/** Removes laoshi's dsh plugin and its mount. */
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// as a child of the chat, schedule a message into the chat, answer a step's approval request by
|
|
6
6
|
// policy; and it relays the rest (prompt, cancel, status, history) to dsh's session controller.
|
|
7
7
|
// It holds no pipeline logic: order, rounds and gates stay in the engine.
|
|
8
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
8
9
|
import crypto from "node:crypto";
|
|
9
10
|
import fs from "node:fs";
|
|
10
11
|
import net from "node:net";
|
|
@@ -14,7 +15,7 @@ import { channelPaths, dshHome } from "./channel.mjs";
|
|
|
14
15
|
export const name = "laoshi-dsh";
|
|
15
16
|
export const inject = ["agents", "subagents", "schedule", "approval", "sessionController", "llm"];
|
|
16
17
|
|
|
17
|
-
const VERSION = "0.
|
|
18
|
+
const VERSION = "0.3.0";
|
|
18
19
|
const SHELL_TOOLS = new Set(["bash", "pwsh"]);
|
|
19
20
|
const SEARCH_TOOLS = new Set(["grep", "glob"]);
|
|
20
21
|
|
|
@@ -83,8 +84,12 @@ export function apply(ctx, config = {}) {
|
|
|
83
84
|
return items.find((i) => i.sessionId === sessionId) ?? null;
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
const modernSubagents = typeof ctx.subagents.interrupt === "function" || typeof ctx.subagents.interruptByUser === "function";
|
|
88
|
+
const modernSchedule = typeof ctx.schedule.edit === "function" && typeof ctx.schedule.delete !== "function";
|
|
89
|
+
|
|
86
90
|
async function events(sessionId) {
|
|
87
|
-
const
|
|
91
|
+
const req = { address: address(sessionId), maxMessages: 1000 };
|
|
92
|
+
const page = sessions.events ? await sessions.events(req, timeout()) : await sessions.page(req, timeout());
|
|
88
93
|
return page.records.filter((r) => r.type === "event").map((r) => r.event);
|
|
89
94
|
}
|
|
90
95
|
|
|
@@ -93,7 +98,13 @@ export function apply(ctx, config = {}) {
|
|
|
93
98
|
const requestId = `laoshi-${crypto.randomUUID()}`;
|
|
94
99
|
if (sessionId in children) {
|
|
95
100
|
await ctx.subagents.prompt(
|
|
96
|
-
{
|
|
101
|
+
{
|
|
102
|
+
requestId,
|
|
103
|
+
...(modernSubagents ? {} : { parentSessionId: children[sessionId], mode: "continuable" }),
|
|
104
|
+
childSessionId: sessionId,
|
|
105
|
+
delivery: mode,
|
|
106
|
+
content,
|
|
107
|
+
},
|
|
97
108
|
timeout(),
|
|
98
109
|
);
|
|
99
110
|
} else {
|
|
@@ -101,6 +112,29 @@ export function apply(ctx, config = {}) {
|
|
|
101
112
|
}
|
|
102
113
|
}
|
|
103
114
|
|
|
115
|
+
async function createScheduleTask({ sessionId, title, prompt: text, at, cron, timeZone }) {
|
|
116
|
+
if (!modernSchedule) {
|
|
117
|
+
const timing = cron ? { cron: { expression: cron, time_zone: timeZone } } : { at };
|
|
118
|
+
return ctx.schedule.create(sessionId, { title, prompt: text, ...timing });
|
|
119
|
+
}
|
|
120
|
+
const resolvedTz = typeof timeZone === "string" && timeZone.trim() ? timeZone.trim() : Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
|
|
121
|
+
const timing = cron ? { kind: "cron", cron: { expression: cron, time_zone: resolvedTz } } : { kind: "at", at };
|
|
122
|
+
return ctx.schedule.create(
|
|
123
|
+
{
|
|
124
|
+
title: typeof title === "string" && title.trim() ? title.trim() : "laoshi",
|
|
125
|
+
prompt: text,
|
|
126
|
+
timing,
|
|
127
|
+
target: { kind: "session", sessionId },
|
|
128
|
+
},
|
|
129
|
+
sessionId,
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async function deleteScheduleTask({ sessionId, id }) {
|
|
134
|
+
if (modernSchedule) return ctx.schedule.edit({ id, action: "delete" }, undefined);
|
|
135
|
+
return ctx.schedule.delete({ sessionId, id });
|
|
136
|
+
}
|
|
137
|
+
|
|
104
138
|
async function liveAgent(sessionId) {
|
|
105
139
|
const live = ctx.agents.get(sessionId);
|
|
106
140
|
if (live) return live;
|
|
@@ -109,7 +143,11 @@ export function apply(ctx, config = {}) {
|
|
|
109
143
|
}
|
|
110
144
|
|
|
111
145
|
const methods = {
|
|
112
|
-
hello: async () => ({
|
|
146
|
+
hello: async () => ({
|
|
147
|
+
plugin: VERSION,
|
|
148
|
+
approvals,
|
|
149
|
+
...(process.env.DSH_VERSION?.trim() ? { dshVersion: process.env.DSH_VERSION.trim() } : {}),
|
|
150
|
+
}),
|
|
113
151
|
|
|
114
152
|
/** The chat (or any session): does it exist, where does it work. */
|
|
115
153
|
session: async ({ sessionId }) => {
|
|
@@ -123,13 +161,26 @@ export function apply(ctx, config = {}) {
|
|
|
123
161
|
const provider = config.subagentProvider ?? "spawn";
|
|
124
162
|
// The step's own model (the role's provider/model in laoshi's config); without it, the chat's.
|
|
125
163
|
const agentOptions = model?.provider && model?.model ? { provider: model.provider, model: model.model, ...(model.reasoningEffort ? { reasoningEffort: model.reasoningEffort } : {}) } : null;
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
164
|
+
const content = [{ type: "text", text }];
|
|
165
|
+
const spec = modernSubagents
|
|
166
|
+
? {
|
|
167
|
+
provider,
|
|
168
|
+
label,
|
|
169
|
+
parent: parentAgent,
|
|
170
|
+
prompt: content,
|
|
171
|
+
cwd,
|
|
172
|
+
...(agentOptions ? { agentOptions } : {}),
|
|
173
|
+
signal: new AbortController().signal,
|
|
174
|
+
delivery: "caller",
|
|
175
|
+
}
|
|
176
|
+
: {
|
|
177
|
+
provider,
|
|
178
|
+
label,
|
|
179
|
+
request: { prompt: content, parent: parentAgent, cwd, ...(agentOptions ? { agentOptions } : {}) },
|
|
180
|
+
signal: new AbortController().signal,
|
|
181
|
+
delivery: "caller",
|
|
182
|
+
};
|
|
183
|
+
const activation = await ctx.subagents.startActivation(spec);
|
|
133
184
|
const childId = activation.childId;
|
|
134
185
|
children[childId] = parent;
|
|
135
186
|
saveChildren();
|
|
@@ -213,8 +264,13 @@ export function apply(ctx, config = {}) {
|
|
|
213
264
|
|
|
214
265
|
/** Stop the session's current turn, then give it text. */
|
|
215
266
|
interrupt: async ({ sessionId, text }) => {
|
|
216
|
-
if (sessionId in children)
|
|
217
|
-
|
|
267
|
+
if (sessionId in children) {
|
|
268
|
+
if (typeof ctx.subagents.interrupt === "function") ctx.subagents.interrupt(sessionId, { kind: "user" });
|
|
269
|
+
else if (typeof ctx.subagents.interruptByUser === "function") ctx.subagents.interruptByUser(sessionId);
|
|
270
|
+
else ctx.subagents.interruptByParent(sessionId, children[sessionId], "continuable");
|
|
271
|
+
} else {
|
|
272
|
+
sessions.cancel({ sessionId });
|
|
273
|
+
}
|
|
218
274
|
if (text) await prompt(sessionId, text, "queue");
|
|
219
275
|
return {};
|
|
220
276
|
},
|
|
@@ -227,19 +283,128 @@ export function apply(ctx, config = {}) {
|
|
|
227
283
|
},
|
|
228
284
|
|
|
229
285
|
/** A message into the session at a time (`at`, ISO) or on a five-field cron in a time zone. */
|
|
230
|
-
schedule: async ({ sessionId, title, prompt: text, at, cron, timeZone }) => {
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
286
|
+
schedule: async ({ sessionId, title, prompt: text, at, cron, timeZone, expiresAt }) => {
|
|
287
|
+
const record = await createScheduleTask({ sessionId, title, prompt: text, at, cron, timeZone });
|
|
288
|
+
if (typeof expiresAt === "string" && expiresAt.trim()) {
|
|
289
|
+
const ms = Date.parse(expiresAt) - Date.now();
|
|
290
|
+
if (Number.isFinite(ms)) {
|
|
291
|
+
const key = `${sessionId}/${record.id}`;
|
|
292
|
+
const delay = Math.min(2_147_483_647, Math.max(0, ms));
|
|
293
|
+
const timer = setTimeout(() => {
|
|
294
|
+
scheduleTimers.delete(key);
|
|
295
|
+
deleteScheduleTask({ sessionId, id: record.id }).catch(() => {});
|
|
296
|
+
log({ scheduleExpired: record.id, sessionId });
|
|
297
|
+
}, delay);
|
|
298
|
+
timer.unref?.();
|
|
299
|
+
scheduleTimers.set(key, timer);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
log({ schedule: record.id, sessionId, title, ...(expiresAt ? { expiresAt } : {}) });
|
|
234
303
|
return { id: record.id };
|
|
235
304
|
},
|
|
236
305
|
|
|
306
|
+
/** A cron schedule that creates a dedicated session in cwd and schedules into it. */
|
|
307
|
+
scheduleAgent: async ({ cwd, title, prompt: text, cron, timeZone }) => {
|
|
308
|
+
if (typeof cwd !== "string" || !cwd.trim()) throw new Error("scheduleAgent: cwd is required");
|
|
309
|
+
if (typeof text !== "string" || !text.trim()) throw new Error("scheduleAgent: prompt is required");
|
|
310
|
+
if (typeof cron !== "string" || !cron.trim()) throw new Error("scheduleAgent: cron is required");
|
|
311
|
+
const { sessionId } = await sessions.create({ cwd });
|
|
312
|
+
const record = await createScheduleTask({
|
|
313
|
+
sessionId,
|
|
314
|
+
title: typeof title === "string" && title.trim() ? title.trim() : "laoshi",
|
|
315
|
+
prompt: text,
|
|
316
|
+
cron,
|
|
317
|
+
timeZone,
|
|
318
|
+
});
|
|
319
|
+
log({ scheduleAgent: record.id, sessionId, title, cron });
|
|
320
|
+
return { id: record.id, sessionId };
|
|
321
|
+
},
|
|
322
|
+
|
|
237
323
|
cancelSchedule: async ({ sessionId, id }) => {
|
|
238
|
-
|
|
324
|
+
const key = `${sessionId}/${id}`;
|
|
325
|
+
const timer = scheduleTimers.get(key);
|
|
326
|
+
if (timer) {
|
|
327
|
+
clearTimeout(timer);
|
|
328
|
+
scheduleTimers.delete(key);
|
|
329
|
+
}
|
|
330
|
+
await deleteScheduleTask({ sessionId, id });
|
|
239
331
|
return {};
|
|
240
332
|
},
|
|
333
|
+
|
|
334
|
+
/** Status (and optional on-demand start) of the hosted requirement board web UI. */
|
|
335
|
+
board: async ({ start = false } = {}) => {
|
|
336
|
+
if (start && !boardState.running) await startBoard();
|
|
337
|
+
return { enabled: boardEnabled, running: boardState.running, url: boardState.url, error: boardState.error };
|
|
338
|
+
},
|
|
241
339
|
};
|
|
242
340
|
|
|
341
|
+
const scheduleTimers = new Map();
|
|
342
|
+
|
|
343
|
+
// ---- optional hosted Web requirement board (`laoshi board --no-open`)
|
|
344
|
+
const boardEnabled = Boolean(config.board);
|
|
345
|
+
const boardPort = Number(config.boardPort ?? 0) || 0;
|
|
346
|
+
const boardReadOnly = Boolean(config.boardReadOnly);
|
|
347
|
+
const kitRoot = typeof config.kitRoot === "string" && config.kitRoot.trim() ? path.resolve(config.kitRoot.trim()) : null;
|
|
348
|
+
const boardState = { running: false, url: null, error: null };
|
|
349
|
+
let boardChild = null;
|
|
350
|
+
let boardStartPromise = null;
|
|
351
|
+
|
|
352
|
+
function startBoard() {
|
|
353
|
+
if (boardStartPromise) return boardStartPromise;
|
|
354
|
+
const reqBin = kitRoot ? path.join(kitRoot, "bin", "req.mjs") : null;
|
|
355
|
+
if (!reqBin || !fs.existsSync(reqBin)) {
|
|
356
|
+
boardState.error = "未配置有效的 kitRoot,请重新运行 laoshi install --platform dsh";
|
|
357
|
+
return Promise.resolve(boardState);
|
|
358
|
+
}
|
|
359
|
+
boardStartPromise = new Promise((resolve) => {
|
|
360
|
+
const args = [reqBin, "board", "--no-open", "--port", String(boardPort), ...(boardReadOnly ? ["--read-only"] : [])];
|
|
361
|
+
const child = spawn(process.execPath, args, { stdio: ["ignore", "pipe", "pipe"], windowsHide: true, detached: process.platform !== "win32" });
|
|
362
|
+
boardChild = child;
|
|
363
|
+
boardState.error = null;
|
|
364
|
+
let settled = false;
|
|
365
|
+
const finish = () => {
|
|
366
|
+
if (settled) return;
|
|
367
|
+
settled = true;
|
|
368
|
+
resolve(boardState);
|
|
369
|
+
};
|
|
370
|
+
const timer = setTimeout(finish, 8_000);
|
|
371
|
+
child.stdout.setEncoding("utf8");
|
|
372
|
+
child.stdout.on("data", (chunk) => {
|
|
373
|
+
const m = /(http:\/\/127\.0\.0\.1:\d+\/)/.exec(chunk);
|
|
374
|
+
if (m) {
|
|
375
|
+
boardState.running = true;
|
|
376
|
+
boardState.url = m[1];
|
|
377
|
+
log({ board: m[1] });
|
|
378
|
+
clearTimeout(timer);
|
|
379
|
+
finish();
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
child.stderr.setEncoding("utf8");
|
|
383
|
+
child.stderr.on("data", (chunk) => {
|
|
384
|
+
if (!boardState.running && chunk.trim()) boardState.error = chunk.trim().slice(0, 300);
|
|
385
|
+
});
|
|
386
|
+
child.on("exit", (code) => {
|
|
387
|
+
if (boardChild === child) {
|
|
388
|
+
boardChild = null;
|
|
389
|
+
boardStartPromise = null;
|
|
390
|
+
boardState.running = false;
|
|
391
|
+
boardState.url = null;
|
|
392
|
+
if (!settled && code !== 0) boardState.error = boardState.error || `看板进程退出(${code})`;
|
|
393
|
+
}
|
|
394
|
+
clearTimeout(timer);
|
|
395
|
+
finish();
|
|
396
|
+
});
|
|
397
|
+
child.on("error", (err) => {
|
|
398
|
+
boardState.error = String(err?.message ?? err);
|
|
399
|
+
clearTimeout(timer);
|
|
400
|
+
finish();
|
|
401
|
+
});
|
|
402
|
+
});
|
|
403
|
+
return boardStartPromise;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
if (boardEnabled) startBoard().catch(() => {});
|
|
407
|
+
|
|
243
408
|
// ---- the local socket
|
|
244
409
|
const token = crypto.randomBytes(32).toString("hex");
|
|
245
410
|
const tokenOk = (given) => typeof given === "string" && given.length === token.length && crypto.timingSafeEqual(Buffer.from(given), Buffer.from(token));
|
|
@@ -285,6 +450,20 @@ export function apply(ctx, config = {}) {
|
|
|
285
450
|
server.on("error", (e) => log({ serverError: String(e?.message ?? e) }));
|
|
286
451
|
|
|
287
452
|
ctx.on("dispose", () => {
|
|
453
|
+
for (const timer of scheduleTimers.values()) clearTimeout(timer);
|
|
454
|
+
scheduleTimers.clear();
|
|
455
|
+
if (boardChild?.pid) {
|
|
456
|
+
const pid = boardChild.pid;
|
|
457
|
+
boardChild = null;
|
|
458
|
+
try {
|
|
459
|
+
if (process.platform === "win32") spawnSync("taskkill", ["/T", "/F", "/PID", String(pid)], { stdio: "ignore", windowsHide: true });
|
|
460
|
+
else process.kill(-pid, "SIGTERM");
|
|
461
|
+
} catch {
|
|
462
|
+
try {
|
|
463
|
+
process.kill(pid, "SIGTERM");
|
|
464
|
+
} catch {}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
288
467
|
server.close();
|
|
289
468
|
fs.rmSync(paths.token, { force: true });
|
|
290
469
|
if (process.platform !== "win32") fs.rmSync(paths.socket, { force: true });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "laoshi-dsh-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"description": "laoshi's plugin for the DeepSeek Harness host: creates step agents under the chat, schedules messages, answers approvals by policy, and serves the laoshi engine over a local socket (ADR 0008).",
|
|
6
6
|
"type": "module",
|
|
@@ -7,6 +7,7 @@ import { spawnSync } from "node:child_process";
|
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
9
9
|
import type { PlatformAdapter } from "../../engine/src/platform.js";
|
|
10
|
+
import { extractSemver, satisfies, supportedPlatformRange } from "../../engine/src/semver.js";
|
|
10
11
|
import { mogaoSettings } from "./mogao-runtime.js";
|
|
11
12
|
|
|
12
13
|
export const mogaoAdapter: PlatformAdapter = {
|
|
@@ -42,7 +43,14 @@ export const mogaoAdapter: PlatformAdapter = {
|
|
|
42
43
|
tools.report("fail", `运行 ${settings.command} --version 失败:${r.error?.message ?? (r.stderr || r.stdout).trim()}`, "在摸高的对话或沙箱里运行;不在 PATH 中时在安装级配置的 platform.mogao.command 写上它的完整路径");
|
|
43
44
|
return;
|
|
44
45
|
}
|
|
45
|
-
|
|
46
|
+
const rawVersion = (r.stdout || "").trim();
|
|
47
|
+
const ver = extractSemver(rawVersion);
|
|
48
|
+
const range = supportedPlatformRange("mogao");
|
|
49
|
+
if (ver && range && !satisfies(ver, range)) {
|
|
50
|
+
tools.report("warn", `aimax ${rawVersion} 不在已验证的支持范围(${range})内(数据目录 ${settings.dataDir})`, "如回调或输出格式有变,请检查摸高适配器更新");
|
|
51
|
+
} else {
|
|
52
|
+
tools.report("ok", `aimax ${rawVersion}${range ? `(支持范围 ${range})` : ""}(数据目录 ${settings.dataDir},单次运行上限 ${settings.runTimeoutMinutes} 分钟)`);
|
|
53
|
+
}
|
|
46
54
|
if (!process.env.AIMAX_SESSION_ID) tools.info("没有 AIMAX_SESSION_ID:不在摸高的对话里运行,进展只写入日志");
|
|
47
55
|
},
|
|
48
56
|
};
|
|
@@ -207,13 +207,19 @@ export interface MogaoRuntimeOptions {
|
|
|
207
207
|
chatOut: string | null;
|
|
208
208
|
env?: NodeJS.ProcessEnv;
|
|
209
209
|
pollMs?: number;
|
|
210
|
+
/** Maximum UTF-8 bytes passed inline to `--message`; longer messages are written to a file. */
|
|
211
|
+
maxInlineBytes?: number;
|
|
210
212
|
}
|
|
211
213
|
|
|
212
214
|
export function createMogaoRuntime(options: MogaoRuntimeOptions): AgentRuntime {
|
|
213
215
|
const { settings, agentsDir, log } = options;
|
|
214
216
|
const env = options.env ?? process.env;
|
|
215
217
|
const pollMs = options.pollMs ?? 500;
|
|
218
|
+
const envMax = Number(env.LAOSHI_MOGAO_MAX_INLINE_BYTES);
|
|
219
|
+
const maxInlineBytes = options.maxInlineBytes ?? (Number.isFinite(envMax) && envMax > 0 ? envMax : 100_000);
|
|
216
220
|
const children = new Map<string, ChildProcess>();
|
|
221
|
+
/** Latest run number started by this runtime process, per agent (used to distinguish crashed own runs from cut-off earlier turns). */
|
|
222
|
+
const launchedRuns = new Map<string, number>();
|
|
217
223
|
const dir = (id: string) => path.join(agentsDir, id);
|
|
218
224
|
const recordFile = (id: string) => path.join(dir(id), "agent.json");
|
|
219
225
|
const read = (id: string): AgentRecord | null => {
|
|
@@ -307,9 +313,24 @@ export function createMogaoRuntime(options: MogaoRuntimeOptions): AgentRuntime {
|
|
|
307
313
|
fs.appendFileSync(path.join(dir(record.id), `run-${n}.err`), `\n${e.message}\n`);
|
|
308
314
|
forget();
|
|
309
315
|
});
|
|
316
|
+
launchedRuns.set(record.id, n);
|
|
310
317
|
write({ ...record, runs: n, pid: child.pid ?? null, host: os.hostname(), runStartedAt: new Date().toISOString() });
|
|
311
318
|
}
|
|
312
319
|
|
|
320
|
+
/**
|
|
321
|
+
* Passes short messages inline via `--message`; writes longer ones (start prompt, follow-up, or
|
|
322
|
+
* interrupt) to the agent's directory so we never hit OS ARG_MAX or CLI argument length limits.
|
|
323
|
+
*/
|
|
324
|
+
function prepareMessage(record: AgentRecord, text: string, filename: string, alwaysWrite = false): string {
|
|
325
|
+
const file = path.join(dir(record.id), filename);
|
|
326
|
+
const over = Buffer.byteLength(text) > maxInlineBytes;
|
|
327
|
+
if (alwaysWrite || over) {
|
|
328
|
+
fs.mkdirSync(dir(record.id), { recursive: true });
|
|
329
|
+
fs.writeFileSync(file, text, "utf8");
|
|
330
|
+
}
|
|
331
|
+
return over ? `请先完整阅读文件 ${file},然后严格按照其中的要求完成任务。` : text;
|
|
332
|
+
}
|
|
333
|
+
|
|
313
334
|
const runArgs = (record: AgentRecord, message: string) => [
|
|
314
335
|
"run",
|
|
315
336
|
...(record.sessionId ? ["-s", record.sessionId] : ["--project-dir", record.cwd]),
|
|
@@ -414,8 +435,8 @@ export function createMogaoRuntime(options: MogaoRuntimeOptions): AgentRuntime {
|
|
|
414
435
|
}
|
|
415
436
|
if (result && !result.error) return { ...base, usage, status: "idle", lastMessage: result.text ?? null };
|
|
416
437
|
if (result?.error) return { ...base, usage, status: "error", error: /timed out/i.test(result.error) ? `超过 ${settings.runTimeoutMinutes} 分钟(单次运行的上限),运行已停止` : result.error };
|
|
417
|
-
// No result: the run was cut off (
|
|
418
|
-
if (record.sessionId && record.host !== os.hostname()) {
|
|
438
|
+
// No result: the previous turn's run was cut off (container recycled or command timed out). Continue its session.
|
|
439
|
+
if (record.sessionId && (record.host !== os.hostname() || launchedRuns.get(id) !== record.runs)) {
|
|
419
440
|
log(`agent ${id} 的上一次运行被中断(没有结果),接着它的会话 ${record.sessionId} 继续`);
|
|
420
441
|
await launch(record, runArgs(record, CONTINUE_MESSAGE));
|
|
421
442
|
continue;
|
|
@@ -429,7 +450,8 @@ export function createMogaoRuntime(options: MogaoRuntimeOptions): AgentRuntime {
|
|
|
429
450
|
async followUp(text: string): Promise<void> {
|
|
430
451
|
const record = read(id);
|
|
431
452
|
if (!record?.sessionId) throw new Error(`agent ${id} 还没有会话,不能追问`);
|
|
432
|
-
|
|
453
|
+
const message = prepareMessage(record, text, `followup-${record.runs + 1}.md`);
|
|
454
|
+
await launch(record, runArgs(record, message));
|
|
433
455
|
},
|
|
434
456
|
async archive(): Promise<void> {
|
|
435
457
|
// Sessions stay with the platform (aimax sessions, export-html); nothing to archive.
|
|
@@ -462,10 +484,7 @@ export function createMogaoRuntime(options: MogaoRuntimeOptions): AgentRuntime {
|
|
|
462
484
|
async startAgent(input) {
|
|
463
485
|
const record: AgentRecord = { id: `mogao-${crypto.randomBytes(6).toString("hex")}`, cwd: input.cwd, title: input.title, sessionId: null, runs: 0, pid: null, host: null, answered: null };
|
|
464
486
|
write(record);
|
|
465
|
-
const
|
|
466
|
-
fs.writeFileSync(promptFile, input.prompt);
|
|
467
|
-
// One command-line argument holds at most 128 KB on Linux: a longer prompt is read from its file.
|
|
468
|
-
const message = Buffer.byteLength(input.prompt) <= 100_000 ? input.prompt : `请先完整阅读文件 ${promptFile},然后严格按照其中的要求完成任务。`;
|
|
487
|
+
const message = prepareMessage(record, input.prompt, "prompt.md", true);
|
|
469
488
|
await launch(record, runArgs(record, message));
|
|
470
489
|
return stepAgent(record.id);
|
|
471
490
|
},
|
|
@@ -492,7 +511,10 @@ export function createMogaoRuntime(options: MogaoRuntimeOptions): AgentRuntime {
|
|
|
492
511
|
for (let i = 0; i < 50 && isAlive(record.pid); i++) await sleep(100);
|
|
493
512
|
}
|
|
494
513
|
const now = read(agentId);
|
|
495
|
-
if (now?.sessionId)
|
|
514
|
+
if (now?.sessionId) {
|
|
515
|
+
const message = prepareMessage(now, text, `interrupt-${now.runs + 1}.md`);
|
|
516
|
+
await launch(now, runArgs(now, message));
|
|
517
|
+
}
|
|
496
518
|
},
|
|
497
519
|
|
|
498
520
|
agentDirectory: async () => null,
|
|
@@ -7,7 +7,9 @@ import path from "node:path";
|
|
|
7
7
|
import { pathToFileURL } from "node:url";
|
|
8
8
|
|
|
9
9
|
export const id = "paseo";
|
|
10
|
-
export const options = {
|
|
10
|
+
export const options = {
|
|
11
|
+
"with-plugin": { type: "boolean" },
|
|
12
|
+
};
|
|
11
13
|
|
|
12
14
|
export function platformConfig() {
|
|
13
15
|
return { adapter: "paseo" };
|
|
@@ -23,14 +25,21 @@ export function skillTargets() {
|
|
|
23
25
|
return roots;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
export async function setup({ kit, dry, report, home }) {
|
|
27
|
-
const { refreshPlugin, stagedDir } = await import(pathToFileURL(path.join(kit, "adapters", "paseo", "plugin-cmd.mjs")).href);
|
|
28
|
+
export async function setup({ kit, args = {}, dry, report, home }) {
|
|
29
|
+
const { installPlugin, refreshPlugin, stagedDir } = await import(pathToFileURL(path.join(kit, "adapters", "paseo", "plugin-cmd.mjs")).href);
|
|
28
30
|
const staged = fs.existsSync(path.join(stagedDir(home), "paseo-plugin.json"));
|
|
29
31
|
if (staged && !dry) {
|
|
30
32
|
// Installed before: refresh its files from this version and reload it in Paseo.
|
|
31
33
|
refreshPlugin({ kitRoot: kit, env: { ...process.env, LAOSHI_HOME: home }, log: (m) => report("ok", m) });
|
|
34
|
+
} else if (!staged && args["with-plugin"]) {
|
|
35
|
+
if (dry) report("ok", "将安装 Paseo 需求插件(--with-plugin)");
|
|
36
|
+
else {
|
|
37
|
+
const code = await installPlugin({ yes: true, kitRoot: kit, env: { ...process.env, LAOSHI_HOME: home } });
|
|
38
|
+
if (code === 0) report("ok", "已安装 Paseo 需求插件");
|
|
39
|
+
else report("warn", "Paseo 插件文件已就绪,但尚未注册到 Paseo daemon", "启动 Paseo daemon 后再运行 laoshi plugin install");
|
|
40
|
+
}
|
|
32
41
|
} else if (!staged) {
|
|
33
|
-
report("info", "Paseo
|
|
42
|
+
report("info", "Paseo 的需求插件(看需求、确认方案、一键试用、验收):运行 laoshi plugin install(或安装时加 --with-plugin 一步装好)");
|
|
34
43
|
}
|
|
35
44
|
return ["在终端运行 laoshi configure,选择 builder 和 reviewer 用的 agent"];
|
|
36
45
|
}
|