ralphflow-dsh 2.5.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -1
- package/lib/assets.d.ts +6 -2
- package/lib/assets.js +7 -4
- package/lib/engine.d.ts +13 -13
- package/lib/engine.js +143 -48
- package/lib/facade.d.ts +8 -7
- package/lib/facade.js +50 -19
- package/lib/graph/assets.d.ts +9 -4
- package/lib/graph/assets.js +51 -15
- package/lib/graph/engine.d.ts +2 -1
- package/lib/graph/engine.js +49 -36
- package/lib/graph/report.d.ts +6 -2
- package/lib/graph/report.js +5 -5
- package/lib/graph/state.d.ts +14 -14
- package/lib/graph/state.js +28 -28
- package/lib/graph/workspace.d.ts +3 -2
- package/lib/graph/workspace.js +6 -5
- package/lib/index.d.ts +10 -0
- package/lib/index.js +10 -5
- package/lib/paths.d.ts +52 -0
- package/lib/paths.js +75 -2
- package/lib/terminal.d.ts +29 -0
- package/lib/terminal.js +57 -0
- package/lib/tools.js +2 -2
- package/lib/verify.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -109,12 +109,25 @@ dsh plugin --profile web add ralphflow-dsh
|
|
|
109
109
|
|
|
110
110
|
**宿主重启 / 进程退出**:属主心跳失联 → 实例标**中断**(`host_restarted`),不再显示“执行中”;状态、判定与产出都保留,`/ralphflow-continue` 恢复。另一个活着的 dsh 正在驱动同一个实例时不会被误标(心跳还在走)。
|
|
111
111
|
|
|
112
|
-
跑完后报告归档到**项目根**的 `.dsh/ralph-flow/reports/`,交付物在 `.dsh/ralph-flow/artifacts
|
|
112
|
+
跑完后报告归档到**项目根**的 `.dsh/ralph-flow/reports/`,交付物在 `.dsh/ralph-flow/artifacts/<产出目录名>/`(两者永久保留)。完成、取消或暂停时,同一目录还会落一份机器可读的 `<实例ID>.json`(见[结构化终态 JSON](https://github.com/534529531/ralph-flow-dsh/blob/main/docs/commands.md#结构化终态-json无头宿主读取)):宿主与脚本读字段,不必解析报告正文。
|
|
113
113
|
|
|
114
114
|
**项目根**与 dsh 原生 Skill 同一条规则:从会话的当前目录(`/cd` 之后按新目录)向上最近的含 `.git` 的祖先目录;没有 `.git` 就用该目录本身。同一仓库的任意子目录会话共享同一套资产、实例、报告与产出。用户级资产在 `$DSH_HOME/ralph-flow/`(`DSH_HOME` 支持 `~`,空值视为未设置,缺省 `~/.dsh`)。
|
|
115
115
|
|
|
116
116
|
> **跑之前确认宿主有委派后端**:验证者需要一个**全新上下文**的子代理后端。dsh 0.2.1-rc.2 起验证者的身份与只读工具面经 `ralphflow-verifier` Agent Preset 提供,因此宿主还需装配 `agentPresets` 服务(标准 **web** 组合已带;headless 或自定义组合需要在 profile 里加 `@deepseek-ai/dsh-agent-preset-registry` 行);旧版 0.2.0 则使用 persona / toolFilter 通道。缺少这些能力时,验证会以**基础设施故障**暂停(`check_infra`),`/ralphflow-continue` 只会重派、无法让它通过——这时需要先在 dsh 里启用支持该能力的后端。
|
|
117
117
|
|
|
118
|
+
### 无头运行(嵌入自治工厂)
|
|
119
|
+
|
|
120
|
+
无人值守运行时有两件事必须与交互式使用分开:运行态不能污染被管理的业务仓库,工作流来源不能由被管理的仓库决定。
|
|
121
|
+
|
|
122
|
+
| 开关 | 作用 | 缺省 |
|
|
123
|
+
|------|------|------|
|
|
124
|
+
| `RALPH_FLOW_STATE_DIR=<目录>`(或插件配置 `stateDir`) | `instances/`、`reports/`、`artifacts/`(Graph 另含节点 worktree)全部落这个目录;项目根下**不建** `.dsh/ralph-flow/`。报告里的产出目录与执行日志改写为绝对路径 | 未设置:`<项目根>/.dsh/ralph-flow/` |
|
|
125
|
+
| `RALPH_FLOW_HEADLESS=1`(或插件配置 `ignoreWorkspaceWorkflows: true`) | 工作流发现与加载跳过项目级 `workflows/` 与 `graphs/`,只认 `$DSH_HOME/ralph-flow/` 与内置;带顶层 `manual_step` 的 Flow / Graph 在加载期拒绝(没有人能放行审查门) | 未设置:项目根 > 用户级 > 内置 |
|
|
126
|
+
|
|
127
|
+
两个开关互相独立,工厂场景通常都打开;取值规则(哪些值算关闭、`~` 与相对路径怎么解析、配置与环境变量谁优先)见[命令参考的环境变量表](https://github.com/534529531/ralph-flow-dsh/blob/main/docs/commands.md#环境变量)。
|
|
128
|
+
|
|
129
|
+
**退出后怎么裁定真实终态**:Flow 进入完成 / 取消 / 暂停时,在生效状态目录的 `reports/<实例ID>.json` 落一份机器可读记录(`schemaVersion` / `instanceId` / `workflow` / `status` / `pauseReason` / `reportPath` / `updatedAt`);运行中不产生该文件,恢复后旧记录移除,再次完成或取消时同一文件更新为最新状态。宿主只读字段,不用正则解析中文报告。字段与语义见[结构化终态 JSON](https://github.com/534529531/ralph-flow-dsh/blob/main/docs/commands.md#结构化终态-json无头宿主读取)。
|
|
130
|
+
|
|
118
131
|
### 定义你自己的工作流
|
|
119
132
|
|
|
120
133
|
```yaml
|
package/lib/assets.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { type WorkflowEntry } from "./engine.js";
|
|
10
10
|
import { type GraphWorkflowEntry } from "./graph/assets.js";
|
|
11
|
+
import type { RuntimeOptions } from "./paths.js";
|
|
11
12
|
export type AssetKind = "flow" | "graph";
|
|
12
13
|
export interface AssetSummary {
|
|
13
14
|
name: string;
|
|
@@ -29,8 +30,11 @@ export interface UnifiedAssetEntry {
|
|
|
29
30
|
/** 跨类别同名:Flow 与 Graph 同时存在。 */
|
|
30
31
|
conflict?: boolean;
|
|
31
32
|
}
|
|
32
|
-
/**
|
|
33
|
-
|
|
33
|
+
/**
|
|
34
|
+
* 只读清单(给动态技能用;不校验内容,避免会话创建时读整棵目录)。
|
|
35
|
+
* `runtime` 与引擎同一条来源规则:无头运行时项目级资产不参与发现。
|
|
36
|
+
*/
|
|
37
|
+
export declare function discoverAssetsIn(workspace: string, runtime?: RuntimeOptions): AssetSummary[];
|
|
34
38
|
/**
|
|
35
39
|
* 把 Flow 引擎的完整校验结果与 Graph 发现结果合并。
|
|
36
40
|
* 跨类别同名时两条都标 `conflict`,`list`/`doctor` 必须报错,`start` 拒绝。
|
package/lib/assets.js
CHANGED
|
@@ -8,15 +8,18 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { listWorkflowsIn } from "./engine.js";
|
|
10
10
|
import { listGraphWorkflows } from "./graph/assets.js";
|
|
11
|
-
/**
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* 只读清单(给动态技能用;不校验内容,避免会话创建时读整棵目录)。
|
|
13
|
+
* `runtime` 与引擎同一条来源规则:无头运行时项目级资产不参与发现。
|
|
14
|
+
*/
|
|
15
|
+
export function discoverAssetsIn(workspace, runtime = {}) {
|
|
13
16
|
const out = [];
|
|
14
17
|
const seen = new Set();
|
|
15
|
-
for (const workflow of listWorkflowsIn(workspace)) {
|
|
18
|
+
for (const workflow of listWorkflowsIn(workspace, runtime)) {
|
|
16
19
|
out.push({ name: workflow.name, desc: workflow.desc, kind: "flow", count: 0 });
|
|
17
20
|
seen.add(workflow.name);
|
|
18
21
|
}
|
|
19
|
-
for (const graph of listGraphWorkflows(workspace)) {
|
|
22
|
+
for (const graph of listGraphWorkflows(workspace, runtime)) {
|
|
20
23
|
if (seen.has(graph.name))
|
|
21
24
|
continue;
|
|
22
25
|
out.push({ name: graph.name, desc: graph.desc, kind: "graph", count: graph.nodes });
|
package/lib/engine.d.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
+
import { RALPH_FLOW_DIR, type RuntimeOptions } from "./paths.js";
|
|
1
2
|
import { type PauseReason } from "./pause.js";
|
|
3
|
+
import { type ArchiveStatus } from "./terminal.js";
|
|
2
4
|
import type { WorkflowStatus } from "./status-contract.js";
|
|
3
5
|
import type { WorkflowUiRef } from "./message-source.js";
|
|
4
6
|
import { MAX_VOTERS, formatVotingFailureReason, formatVotingInfraReason, formatVotingPassReason, voterProgressLine, voterStatusLabel } from "./voting.js";
|
|
5
7
|
export { MAX_VOTERS };
|
|
6
8
|
export { formatVotingFailureReason, formatVotingPassReason, formatVotingInfraReason, voterProgressLine, voterStatusLabel };
|
|
7
9
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `<DSH_HOME>/ralph-flow/` 由 `paths.ts` 解析。
|
|
11
|
-
*
|
|
12
|
-
* 注意:这里是**项目根相对路径**(含 `/`),`path.join(projectRoot, RALPH_FLOW_DIR)` 仍成立。
|
|
10
|
+
* 项目内的运行时根目录名。定义在 `paths.ts`(运行态布局的唯一解析点),这里只转出,
|
|
11
|
+
* 让 `lib/engine.js` 仍是路径常量与引擎的既有入口。
|
|
13
12
|
*/
|
|
14
|
-
export
|
|
13
|
+
export { RALPH_FLOW_DIR };
|
|
15
14
|
/**
|
|
16
15
|
* 执行日志(JSONL)轮转参数 —— 照 opencode:单文件上限 **10 MB**、保留 **3** 份
|
|
17
16
|
* (`execution.log.1` / `.2` / `.3`,最旧的删除)。见 docs/v2/execution-log-brief.md §3.3。
|
|
@@ -799,8 +798,9 @@ export interface VerifyRequest {
|
|
|
799
798
|
check: string;
|
|
800
799
|
};
|
|
801
800
|
/**
|
|
802
|
-
*
|
|
803
|
-
*
|
|
801
|
+
* 本实例产出目录的**展示路径**(§1.7,正斜杠)。
|
|
802
|
+
* 默认是工作区相对路径(验证者继承父会话工作区,按它就能读到 DO 的产出);外部状态目录下
|
|
803
|
+
* 运行态不在工作区里,给绝对路径。CHECK 提示词据此注入「产出目录」。
|
|
804
804
|
*/
|
|
805
805
|
artifactsRelDir: string;
|
|
806
806
|
/**
|
|
@@ -896,11 +896,11 @@ export declare function globalWorkflowsDirOf(): string;
|
|
|
896
896
|
* **必须包含内置工作流**(`loop`/`spec`)——它们不落盘,只存在于插件目录,漏掉就会让
|
|
897
897
|
* `/ralphflow-loop`、`/ralphflow-spec` 消失。项目根里的同名文件遮蔽内置(有意行为)。
|
|
898
898
|
*/
|
|
899
|
-
export declare function listWorkflowsIn(workspace: string): Array<{
|
|
899
|
+
export declare function listWorkflowsIn(workspace: string, runtime?: RuntimeOptions): Array<{
|
|
900
900
|
name: string;
|
|
901
901
|
desc: string;
|
|
902
902
|
}>;
|
|
903
|
-
export declare function createEngine(projectDir: string, ports: EnginePorts): {
|
|
903
|
+
export declare function createEngine(projectDir: string, ports: EnginePorts, runtime?: RuntimeOptions): {
|
|
904
904
|
root: string;
|
|
905
905
|
instancesDir: string;
|
|
906
906
|
workflowsDir: string;
|
|
@@ -918,9 +918,9 @@ export declare function createEngine(projectDir: string, ports: EnginePorts): {
|
|
|
918
918
|
listHistory: () => HistoryInfo[];
|
|
919
919
|
instanceDir: (instId: string) => string;
|
|
920
920
|
artifactsDirOf: (instId: string) => string;
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
destroyInstance: (instId: string, status:
|
|
921
|
+
artifactsDisplayDirOf: (instId: string) => string;
|
|
922
|
+
reportPathOf: (instId: string) => string;
|
|
923
|
+
destroyInstance: (instId: string, status: ArchiveStatus, state?: InstanceState) => {
|
|
924
924
|
reportPath: string;
|
|
925
925
|
instanceDirRemoved: boolean;
|
|
926
926
|
instanceDir: string;
|
package/lib/engine.js
CHANGED
|
@@ -13,9 +13,10 @@ import { normalizeUnfinished } from "./unfinished.js";
|
|
|
13
13
|
import path from "node:path";
|
|
14
14
|
import { fileURLToPath } from "node:url";
|
|
15
15
|
import yaml from "js-yaml";
|
|
16
|
-
import { userRalphFlowDir } from "./paths.js";
|
|
16
|
+
import { RALPH_FLOW_DIR, assetSearchDirs, displayPath, headlessModeEnabled, resolveRalphFlowLayout, userRalphFlowDir, } from "./paths.js";
|
|
17
17
|
import { FLOW_ENTRY_FILE, assetCandidates, assetReferenceSection, assetRootOf, discoverAssetsIn, placementSection, } from "./asset-path.js";
|
|
18
18
|
import { pauseLabel } from "./pause.js";
|
|
19
|
+
import { TERMINAL_RECORD_SCHEMA_VERSION, removeTerminalRecord, writeTerminalRecord, } from "./terminal.js";
|
|
19
20
|
import { OWNER_HEARTBEAT_REFRESH_MS, ownerAlive, ownerRecheckMs, runtimeId, stampOwner } from "./owner.js";
|
|
20
21
|
import { MAX_VOTERS, decideVotingOutcome, formatVotingFailureReason, formatVotingInfraReason, formatVotingPassReason, voterProgressLine, voterStatusLabel, } from "./voting.js";
|
|
21
22
|
// 纯函数层(聚合优先级与三份文案)的唯一实现在 voting.ts;这里只把常量与展示标签转出去,
|
|
@@ -23,13 +24,10 @@ import { MAX_VOTERS, decideVotingOutcome, formatVotingFailureReason, formatVotin
|
|
|
23
24
|
export { MAX_VOTERS };
|
|
24
25
|
export { formatVotingFailureReason, formatVotingPassReason, formatVotingInfraReason, voterProgressLine, voterStatusLabel };
|
|
25
26
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* `<DSH_HOME>/ralph-flow/` 由 `paths.ts` 解析。
|
|
29
|
-
*
|
|
30
|
-
* 注意:这里是**项目根相对路径**(含 `/`),`path.join(projectRoot, RALPH_FLOW_DIR)` 仍成立。
|
|
27
|
+
* 项目内的运行时根目录名。定义在 `paths.ts`(运行态布局的唯一解析点),这里只转出,
|
|
28
|
+
* 让 `lib/engine.js` 仍是路径常量与引擎的既有入口。
|
|
31
29
|
*/
|
|
32
|
-
export
|
|
30
|
+
export { RALPH_FLOW_DIR };
|
|
33
31
|
/** 每实例产出目录的目录名(§1.7,与 opencode 同名) */
|
|
34
32
|
const ARTIFACTS_DIRNAME = "artifacts";
|
|
35
33
|
/**
|
|
@@ -730,9 +728,11 @@ export function globalWorkflowsDirOf() {
|
|
|
730
728
|
* **必须包含内置工作流**(`loop`/`spec`)——它们不落盘,只存在于插件目录,漏掉就会让
|
|
731
729
|
* `/ralphflow-loop`、`/ralphflow-spec` 消失。项目根里的同名文件遮蔽内置(有意行为)。
|
|
732
730
|
*/
|
|
733
|
-
export function listWorkflowsIn(workspace) {
|
|
734
|
-
const found = new Map(); // name →
|
|
735
|
-
|
|
731
|
+
export function listWorkflowsIn(workspace, runtime = {}) {
|
|
732
|
+
const found = new Map(); // name → 入口文件路径(项目根优先,其次用户级,最后内置;无头时只剩后两者)
|
|
733
|
+
// 无头运行的工作流来源隔离与引擎加载面同一条规则:只认用户级与内置。
|
|
734
|
+
const headless = headlessModeEnabled(runtime.ignoreWorkspaceWorkflows);
|
|
735
|
+
for (const dir of assetSearchDirs(workspace, "workflows", headless)) {
|
|
736
736
|
for (const [name, file] of discoverAssetsIn(dir, FLOW_ENTRY_FILE)) {
|
|
737
737
|
if (!found.has(name))
|
|
738
738
|
found.set(name, file);
|
|
@@ -756,14 +756,21 @@ export function listWorkflowsIn(workspace) {
|
|
|
756
756
|
return { name, desc };
|
|
757
757
|
});
|
|
758
758
|
}
|
|
759
|
-
export function createEngine(projectDir, ports) {
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
const
|
|
763
|
-
const
|
|
764
|
-
const
|
|
765
|
-
|
|
766
|
-
const
|
|
759
|
+
export function createEngine(projectDir, ports, runtime = {}) {
|
|
760
|
+
// 运行态布局只有一处解析(外部状态目录 / 无头模式都在这里落定):Flow 与 Graph 共用同一份
|
|
761
|
+
// 根,报告、产出、实例目录绝不会一半在项目根、一半在外部目录。
|
|
762
|
+
const layout = resolveRalphFlowLayout(projectDir, runtime);
|
|
763
|
+
const root = layout.root;
|
|
764
|
+
const instancesDir = layout.instancesDir;
|
|
765
|
+
const workflowsDir = layout.workflowsDir;
|
|
766
|
+
const reportsDir = layout.reportsDir;
|
|
767
|
+
const artifactsDir = layout.artifactsDir;
|
|
768
|
+
/** 运行态在项目根之外:报告与提示词里的路径必须给绝对路径(工作区里读不到相对路径)。 */
|
|
769
|
+
const externalState = layout.external;
|
|
770
|
+
/** 无头运行:项目级资产不可信,人工审查门没人放行。 */
|
|
771
|
+
const headless = layout.headless;
|
|
772
|
+
/** 报告目录在人类可读文案里的写法(默认沿用工作区相对路径,外部化时给绝对路径)。 */
|
|
773
|
+
const reportsDirLabel = displayPath(projectDir, reportsDir, externalState);
|
|
767
774
|
/**
|
|
768
775
|
* 实例 → 在飞取消信号集合(取消/重开/暂停时中止验证者,不白烧 token)。
|
|
769
776
|
*
|
|
@@ -873,13 +880,19 @@ export function createEngine(projectDir, ports) {
|
|
|
873
880
|
/**
|
|
874
881
|
* 产出目录的**工作区相对路径**(正斜杠,可嵌进 DO/CHECK 提示词)。
|
|
875
882
|
* 验证者继承父会话工作区,所以这个路径对它同样可读。
|
|
883
|
+
*
|
|
884
|
+
* 外部化时运行态不在工作区里:这里改给**绝对路径**,否则执行者与验证者都会按工作区
|
|
885
|
+
* 解析出一个不存在的目录。
|
|
876
886
|
*/
|
|
877
|
-
function
|
|
878
|
-
return
|
|
887
|
+
function artifactsDisplayDirOf(instId) {
|
|
888
|
+
return displayPath(projectDir, path.join(artifactsDir, artifactsDirNameOf(instId)), externalState);
|
|
879
889
|
}
|
|
880
|
-
/**
|
|
881
|
-
|
|
882
|
-
|
|
890
|
+
/**
|
|
891
|
+
* 报告的路径(完成/取消消息、历史列表、状态查询共用同一份事实)。
|
|
892
|
+
* 默认是工作区相对路径;外部化时给绝对路径,报告在项目根之外也指得准。
|
|
893
|
+
*/
|
|
894
|
+
function reportPathOf(instId) {
|
|
895
|
+
return displayPath(projectDir, path.join(reportsDir, `${instId}.md`), externalState);
|
|
883
896
|
}
|
|
884
897
|
// ─── 执行日志(JSONL,docs/v2/execution-log-brief.md)───────────────────────
|
|
885
898
|
//
|
|
@@ -1005,7 +1018,12 @@ export function createEngine(projectDir, ports) {
|
|
|
1005
1018
|
}
|
|
1006
1019
|
}
|
|
1007
1020
|
function ensureLayout() {
|
|
1008
|
-
|
|
1021
|
+
const dirs = [root, instancesDir, reportsDir, artifactsDir];
|
|
1022
|
+
// 项目资产目录只在默认布局下创建:外部化/无头运行时**绝不**在目标仓库里留下
|
|
1023
|
+
// `.dsh/ralph-flow/`(那是「零污染」契约,也是 git status 保持干净的前提)。
|
|
1024
|
+
if (!externalState && !headless)
|
|
1025
|
+
dirs.push(workflowsDir);
|
|
1026
|
+
for (const p of dirs) {
|
|
1009
1027
|
try {
|
|
1010
1028
|
fs.mkdirSync(p, { recursive: true });
|
|
1011
1029
|
}
|
|
@@ -1028,8 +1046,14 @@ export function createEngine(projectDir, ports) {
|
|
|
1028
1046
|
const CALL_POINT_KEYS = new Set(["id", "desc", "do", "input", "output", "workflow", "on_pass", "on_fail", "max_fail_count", "reset"]);
|
|
1029
1047
|
const KNOWN_WF_KEYS = new Set(["kind", "description", "manual_step", "adversarial_check", "auto_reset", "steps"]);
|
|
1030
1048
|
function knownWorkflowDirs() {
|
|
1031
|
-
// 单根:本项目根的工作流目录 + 用户级目录(内置工作流不落盘,由 builtinWorkflowPath
|
|
1032
|
-
|
|
1049
|
+
// 单根:本项目根的工作流目录 + 用户级目录(内置工作流不落盘,由 builtinWorkflowPath 回落)。
|
|
1050
|
+
// 无头运行只认用户级与内置:受管业务仓库里放同名文件不能覆盖工厂内置 Flow。
|
|
1051
|
+
return assetSearchDirs(projectDir, "workflows", headless);
|
|
1052
|
+
}
|
|
1053
|
+
/** 「工作流能放哪」的文案:无头模式不把作者引向被忽略的项目资产目录。 */
|
|
1054
|
+
function workflowPlacementText(name) {
|
|
1055
|
+
const dir = knownWorkflowDirs()[0];
|
|
1056
|
+
return `${dir}/${name}/workflow.yaml(目录形态;单文件 ${dir}/${name}.yaml 也识别)`;
|
|
1033
1057
|
}
|
|
1034
1058
|
function workflowPaths(name) {
|
|
1035
1059
|
return knownWorkflowDirs().flatMap((dir) => assetCandidates(dir, name, FLOW_ENTRY_FILE));
|
|
@@ -1103,7 +1127,7 @@ export function createEngine(projectDir, ports) {
|
|
|
1103
1127
|
}
|
|
1104
1128
|
}
|
|
1105
1129
|
if (raw === undefined) {
|
|
1106
|
-
problems.push(`未找到工作流 "${name}"。把资产放到 ${
|
|
1130
|
+
problems.push(`未找到工作流 "${name}"。把资产放到 ${workflowPlacementText("<name>")} 即可被加载。`);
|
|
1107
1131
|
return { def: null, problems, warnings };
|
|
1108
1132
|
}
|
|
1109
1133
|
raw = raw.replace(/^\uFEFF/, "");
|
|
@@ -1252,7 +1276,7 @@ export function createEngine(projectDir, ports) {
|
|
|
1252
1276
|
problems.push(`步骤 \`${s.id}\` 写了 \`workflow\` 但没有给出要调用的工作流名(必须是非空字符串,例如 \`workflow: analyze\`)。调用点以 \`workflow:\` 声明委托(此时 \`do\` 可省略;写了就是这段子工作流的任务)。`);
|
|
1253
1277
|
}
|
|
1254
1278
|
else if (/[\\/]/.test(subName)) {
|
|
1255
|
-
problems.push(`步骤 \`${s.id}\` 的 \`workflow: ${subName}\` 含路径分隔符:\`workflow\` 只能是工作流**名**(对应目录 \`${
|
|
1279
|
+
problems.push(`步骤 \`${s.id}\` 的 \`workflow: ${subName}\` 含路径分隔符:\`workflow\` 只能是工作流**名**(对应目录 \`${knownWorkflowDirs()[0]}/<名字>/workflow.yaml\`${headless ? "、内置同名资产" : "、全局目录或内置同名资产"}),不能是路径。`);
|
|
1256
1280
|
}
|
|
1257
1281
|
if (s.id.includes(SUBWORKFLOW_ID_SEP)) {
|
|
1258
1282
|
problems.push(`调用点 \`${s.id}\` 的 id 含 \`${SUBWORKFLOW_ID_SEP}\`:展开后步骤 id 是 \`调用点id${SUBWORKFLOW_ID_SEP}子步骤id\`,调用点 id 含分隔符会与展开结果撞名。请把 id 改成不含 \`${SUBWORKFLOW_ID_SEP}\` 的名字。`);
|
|
@@ -1567,6 +1591,15 @@ export function createEngine(projectDir, ports) {
|
|
|
1567
1591
|
problems.push(`manual_step 引用了不存在的步骤:${unknownManual.map((m) => `\`${m}\``).join("、")}(审查门会静默失效,必须修正拼写或删掉)。`);
|
|
1568
1592
|
return { def: null, problems, warnings };
|
|
1569
1593
|
}
|
|
1594
|
+
// ── 无头运行:人工审查门没人放行 ────────────────────────────────────────────
|
|
1595
|
+
// 无头会话里没有人类可以执行 `/ralphflow-continue`,实例会停在一个永远等不到确认的
|
|
1596
|
+
// 审查门上(画面上看起来像「卡住」,没有任何错误)。因此加载期就拒绝整份定义,
|
|
1597
|
+
// 让启动失败得响亮而不是运行到一半静默停摆。
|
|
1598
|
+
if (headless && manualSet.size > 0) {
|
|
1599
|
+
problems.push(`工作流 \`${name}\` 声明了人工审查门(\`manual_step\`:${[...manualSet].map((m) => `\`${m}\``).join("、")}),但本次是无头运行:没有会话能执行 \`/ralphflow-continue\` 放行它。`
|
|
1600
|
+
+ `无头运行只接受没有审查门的工作流:请删掉顶层 \`manual_step\`,让每一步由独立验证者的判定自动推进;需要人工审查的工作流放到交互式会话里运行。`);
|
|
1601
|
+
return { def: null, problems, warnings };
|
|
1602
|
+
}
|
|
1570
1603
|
// 子工作流里的 `adversarial_check.model` 下沉到它各步的 `check_model`(对齐 opencode 的
|
|
1571
1604
|
// 逐字段继承):**只在子层加载时**做,且只填「自己没填或填了但无效」的步骤 ——
|
|
1572
1605
|
// 父级的 `adversarial_check` 是整份定义的兜底、不区分层次,帮不了子层。
|
|
@@ -1641,6 +1674,9 @@ export function createEngine(projectDir, ports) {
|
|
|
1641
1674
|
fs.writeFileSync(tmp, JSON.stringify(persisted, null, 2), "utf-8");
|
|
1642
1675
|
fs.renameSync(tmp, statePath(instId));
|
|
1643
1676
|
statusErrors.delete(instId);
|
|
1677
|
+
// 终态记录与 state 同一次写:state 是唯一事实源,记录只由它推导。
|
|
1678
|
+
// 放在 rename 之后 —— 只有真正落盘的状态才能成为机器事实。sync 自身永不抛出。
|
|
1679
|
+
syncTerminalRecord(state, instId);
|
|
1644
1680
|
}
|
|
1645
1681
|
catch (e) {
|
|
1646
1682
|
statusErrors.set(instId, "状态写盘失败,当前显示最后确认值。请检查工作区权限或磁盘空间。");
|
|
@@ -1648,6 +1684,55 @@ export function createEngine(projectDir, ports) {
|
|
|
1648
1684
|
}
|
|
1649
1685
|
publishStatus();
|
|
1650
1686
|
}
|
|
1687
|
+
// ─── 结构化终态记录(reports/<instId>.json,契约见 terminal.ts)──────────────
|
|
1688
|
+
//
|
|
1689
|
+
// 两个写入点:暂停态由 `writeState` 统一同步(所有暂停入口都汇聚到它,不会漏),
|
|
1690
|
+
// 终态由 `destroyInstance` 在报告归档后写(只有那时才有 reportPath)。
|
|
1691
|
+
// 恢复运行后移除旧记录,避免一份过期的 `paused` 继续冒充真实状态。
|
|
1692
|
+
/** 把 `state` 的暂停事实投影成记录;`done` / `cancelled` 由 {@link destroyInstance} 调用。 */
|
|
1693
|
+
function writeTerminalRecordFor(state, instId, status, reportPath) {
|
|
1694
|
+
const record = {
|
|
1695
|
+
schemaVersion: TERMINAL_RECORD_SCHEMA_VERSION,
|
|
1696
|
+
instanceId: instId,
|
|
1697
|
+
workflow: state.workflow_name,
|
|
1698
|
+
status,
|
|
1699
|
+
// 引擎的每条暂停路径都会写原因;手改过的老 state 缺字段时如实写 null,不编造原因。
|
|
1700
|
+
pauseReason: status === "paused" ? (state.pause_reason ?? null) : null,
|
|
1701
|
+
reportPath,
|
|
1702
|
+
updatedAt: new Date().toISOString(),
|
|
1703
|
+
};
|
|
1704
|
+
try {
|
|
1705
|
+
writeTerminalRecord(reportsDir, instId, record);
|
|
1706
|
+
}
|
|
1707
|
+
catch (e) {
|
|
1708
|
+
// 终态记录是派生事实:写失败只告警,绝不阻塞状态推进或实例销毁。
|
|
1709
|
+
log("warn", "terminal_record_write_failed", { instId, status, error: msg(e) });
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
/** 暂停中 → 落一份 `paused`;其它(运行中 / 恢复后 / 残留)→ 移除旧记录。 */
|
|
1713
|
+
function syncTerminalRecord(state, instId) {
|
|
1714
|
+
if (state.active && state.paused) {
|
|
1715
|
+
if (!state.pause_reason) {
|
|
1716
|
+
// 契约要求 `paused` 必带原因;引擎所有暂停路径都写了原因,缺字段只可能来自手改的
|
|
1717
|
+
// 老状态。与其写一份不合契约的记录,不如不写(宿主 fail-closed)并留下告警。
|
|
1718
|
+
log("warn", "terminal_record_pause_reason_missing", { instId });
|
|
1719
|
+
removeTerminalRecordBestEffort(instId);
|
|
1720
|
+
return;
|
|
1721
|
+
}
|
|
1722
|
+
writeTerminalRecordFor(state, instId, "paused", null);
|
|
1723
|
+
return;
|
|
1724
|
+
}
|
|
1725
|
+
removeTerminalRecordBestEffort(instId);
|
|
1726
|
+
}
|
|
1727
|
+
function removeTerminalRecordBestEffort(instId) {
|
|
1728
|
+
try {
|
|
1729
|
+
removeTerminalRecord(reportsDir, instId);
|
|
1730
|
+
}
|
|
1731
|
+
catch (e) {
|
|
1732
|
+
// 删不掉就说出来:一份过期的 paused 会让机器宿主误判真实终态。
|
|
1733
|
+
log("warn", "terminal_record_remove_failed", { instId, error: msg(e) });
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1651
1736
|
/** 某步当前的失败轮数(按步计数;缺省 0) */
|
|
1652
1737
|
function failCountOf(state, stepId) {
|
|
1653
1738
|
const id = stepId ?? state.current_step;
|
|
@@ -1775,7 +1860,8 @@ export function createEngine(projectDir, ports) {
|
|
|
1775
1860
|
const startedAt = field("开始");
|
|
1776
1861
|
const endedAt = field("结束");
|
|
1777
1862
|
const artifactsRel = strip(field("产出目录"));
|
|
1778
|
-
|
|
1863
|
+
// 产出目录可能是工作区相对路径或绝对路径:只看最后一段目录名。
|
|
1864
|
+
const artifactsDirName = artifactsRel ? path.basename(artifactsRel.replace(/[\\/]+$/, "")) : undefined;
|
|
1779
1865
|
const workflow = /^#\s*ralphflow 报告 ·\s*(.+)$/m.exec(text)?.[1]?.trim();
|
|
1780
1866
|
const statusLabel = statusRaw.includes("完成") ? "完成" : statusRaw.includes("取消") ? "取消" : undefined;
|
|
1781
1867
|
return {
|
|
@@ -1811,7 +1897,7 @@ export function createEngine(projectDir, ports) {
|
|
|
1811
1897
|
text = fs.readFileSync(path.join(reportsDir, f), "utf-8");
|
|
1812
1898
|
}
|
|
1813
1899
|
catch { }
|
|
1814
|
-
return parseReportHeader(
|
|
1900
|
+
return parseReportHeader(reportPathOf(id), id, text);
|
|
1815
1901
|
});
|
|
1816
1902
|
const key = (h) => {
|
|
1817
1903
|
const t = h.endedAt ? new Date(h.endedAt).getTime() : NaN;
|
|
@@ -1943,7 +2029,7 @@ export function createEngine(projectDir, ports) {
|
|
|
1943
2029
|
*/
|
|
1944
2030
|
function doPrompt(instId, wf, state, step, rework, rewind, continuation) {
|
|
1945
2031
|
const idx = wf.steps.findIndex((s) => s.id === step.id) + 1;
|
|
1946
|
-
const rel =
|
|
2032
|
+
const rel = artifactsDisplayDirOf(instId);
|
|
1947
2033
|
const hasCheck = stepHasVerification(step);
|
|
1948
2034
|
const voters = voterCountOf(step);
|
|
1949
2035
|
const assetRef = assetReferenceSection(assetRootOf(assetPathOfStep(wf, step)));
|
|
@@ -2078,7 +2164,7 @@ export function createEngine(projectDir, ports) {
|
|
|
2078
2164
|
verdict = await ports.verify({
|
|
2079
2165
|
instId, step, workflow: wf, userTask: effectiveTaskOf(step, state.user_task),
|
|
2080
2166
|
assetPath: assetPathOfStep(wf, step),
|
|
2081
|
-
ownerSession: state.owner_session, checkIndex, artifactsRelDir:
|
|
2167
|
+
ownerSession: state.owner_session, checkIndex, artifactsRelDir: artifactsDisplayDirOf(instId),
|
|
2082
2168
|
// 验证模型优先级链(对齐 opencode resolveVerifierModel):
|
|
2083
2169
|
// 步骤 check_model > 全局 adversarial_check.model > 发起会话当前模型
|
|
2084
2170
|
//(没有覆盖时不传 agentOptions,由宿主 resolveChildAgentOptions 继承父级)
|
|
@@ -2175,7 +2261,7 @@ export function createEngine(projectDir, ports) {
|
|
|
2175
2261
|
ownerSession: state.owner_session, checkIndex: index,
|
|
2176
2262
|
// 该票的专属检查依据 + 序号:verify.ts 据此生成「你是 N 个之一」的投票提示词。
|
|
2177
2263
|
voter: { index: index + 1, count, check: entry.check },
|
|
2178
|
-
artifactsRelDir:
|
|
2264
|
+
artifactsRelDir: artifactsDisplayDirOf(instId),
|
|
2179
2265
|
// 模型优先级链(对齐 opencode):**该票 `model`** > 全局 `adversarial_check.model` >
|
|
2180
2266
|
// 发起会话当前模型。(`check_voting` 与步骤 `check_model` 同写是加载期硬错误,
|
|
2181
2267
|
// 所以这条链上没有 check_model 那一级。)
|
|
@@ -2463,7 +2549,7 @@ export function createEngine(projectDir, ports) {
|
|
|
2463
2549
|
// 销毁顺序与失败分支都在 destroyInstance 里(不变量 2/3)。
|
|
2464
2550
|
const destroyed = destroyInstance(instId, "done", state);
|
|
2465
2551
|
if (destroyed) {
|
|
2466
|
-
const rel =
|
|
2552
|
+
const rel = reportPathOf(instId);
|
|
2467
2553
|
// 诚实播报:只有**复查确认**实例目录真没了,才说「已销毁」;否则如实说残留并指向 doctor。
|
|
2468
2554
|
if (destroyed.instanceDirRemoved) {
|
|
2469
2555
|
notify(state, `✅ 工作流 \`${wf.name}\` 完成,报告已归档到 \`${rel}\`。\n\n实例目录已销毁、产出目录保留;报告与产出是永久的,需要时按上面这个路径翻。`, `✅ 工作流 ${wf.name} 完成(报告 ${rel})`);
|
|
@@ -2495,7 +2581,7 @@ export function createEngine(projectDir, ports) {
|
|
|
2495
2581
|
const instId = stateIds.get(state);
|
|
2496
2582
|
const ended = state.history.some((h) => h.event === "cancelled") ? "cancelled" : "done";
|
|
2497
2583
|
const uiRef = !state.active && instId && fs.existsSync(path.join(reportsDir, `${instId}.md`))
|
|
2498
|
-
? { v: 1, runId: instId, reportRef:
|
|
2584
|
+
? { v: 1, runId: instId, reportRef: reportPathOf(instId), ended } : undefined;
|
|
2499
2585
|
const ok = ports.deliverNotice(state.owner_session, text, summary, { dedupe: false, ...(uiRef ? { uiRef } : {}) });
|
|
2500
2586
|
if (!ok)
|
|
2501
2587
|
log("warn", "deliver_notice_failed", { instId: state.owner_session });
|
|
@@ -2644,7 +2730,7 @@ export function createEngine(projectDir, ports) {
|
|
|
2644
2730
|
*/
|
|
2645
2731
|
function resetRequestFor(state, instId, wf, step, trigger, rewind, every) {
|
|
2646
2732
|
const idx = wf.steps.findIndex((s) => s.id === step.id) + 1;
|
|
2647
|
-
const rel =
|
|
2733
|
+
const rel = artifactsDisplayDirOf(instId);
|
|
2648
2734
|
const hasCheck = stepHasVerification(step);
|
|
2649
2735
|
const voters = voterCountOf(step);
|
|
2650
2736
|
const contract = hasCheck
|
|
@@ -2899,7 +2985,7 @@ export function createEngine(projectDir, ports) {
|
|
|
2899
2985
|
const stats = stepStatsOf(state, endTs);
|
|
2900
2986
|
const totalMs = Math.max(0, endTs - new Date(state.started_at).getTime());
|
|
2901
2987
|
const totalFails = stats.reduce((a, s) => a + s.retries, 0);
|
|
2902
|
-
const artifactsRel =
|
|
2988
|
+
const artifactsRel = artifactsDisplayDirOf(instId);
|
|
2903
2989
|
const lines = [
|
|
2904
2990
|
`# ralphflow 报告 · ${wf.name}`,
|
|
2905
2991
|
"",
|
|
@@ -2914,7 +3000,7 @@ export function createEngine(projectDir, ports) {
|
|
|
2914
3000
|
// §3.1:报告只新增**这一行**指路,其余内容逐字节不变(验收 2 用 diff 证明)。
|
|
2915
3001
|
// 只在运行期日志确实存在时才写:日志压根没写出来时不指一个不存在的文件(诚实优先,
|
|
2916
3002
|
// 也让「日志写失败」这件事在报告里表现为**少一行**而不是**假指路**)。
|
|
2917
|
-
...(fs.existsSync(logFileOf(instId)) ? [`- 执行日志:\`${
|
|
3003
|
+
...(fs.existsSync(logFileOf(instId)) ? [`- 执行日志:\`${displayPath(projectDir, archivedLogOf(instId), externalState)}\``] : []),
|
|
2918
3004
|
"",
|
|
2919
3005
|
"## 步骤耗时与重试",
|
|
2920
3006
|
"",
|
|
@@ -2969,12 +3055,19 @@ export function createEngine(projectDir, ports) {
|
|
|
2969
3055
|
// (这一步写 state 是安全的:实例目录本就存在且不打算删。)
|
|
2970
3056
|
s.active = false;
|
|
2971
3057
|
writeState(s, instId);
|
|
3058
|
+
// 上一步的 writeState 会移除旧记录;这里补写**真实的**终态(报告没归档 → reportPath
|
|
3059
|
+
// 为 null)。否则留在盘上的最后一份 `paused` 会冒充“当前仍暂停”,与 active=false 矛盾。
|
|
3060
|
+
writeTerminalRecordFor(s, instId, status, null);
|
|
2972
3061
|
notify(s, `⚠️ 实例 \`${instId}\` 的报告归档失败,已**保留**实例目录与 \`state.json\`,未销毁。\n\n` +
|
|
2973
|
-
|
|
3062
|
+
`请检查报告目录 \`${reportsDirLabel}/\` 是否可写(例如被同名文件占位)。\n` +
|
|
2974
3063
|
`报告不会自动补写;残留可用 \`/ralphflow-doctor\` 查看,确认无需保留后可手动删除该实例目录。`, `⚠️ 报告归档失败,实例 ${instId} 未销毁`);
|
|
2975
3064
|
}
|
|
2976
3065
|
return null;
|
|
2977
3066
|
}
|
|
3067
|
+
// 1a) 结构化终态记录:报告路径只有归档成功后才存在,所以 done / cancelled 的机器事实
|
|
3068
|
+
// 在这里落(暂停态已在 writeState 里同步过)。写入失败只告警(见 writeTerminalRecordFor)。
|
|
3069
|
+
if (s)
|
|
3070
|
+
writeTerminalRecordFor(s, instId, status, reportPath);
|
|
2978
3071
|
// 1b) 执行日志随报告一起归档(§3.1):先落 `destroy` 事件、再拷副本,归档的日志因此以
|
|
2979
3072
|
// `destroy` 收尾(副本必须在删目录之前拷)。**日志归档失败只告警、不阻塞销毁** ——
|
|
2980
3073
|
// 与第 1 步「报告归档失败即中止销毁」是有意的不对称:报告是主事实,日志是辅助证据。
|
|
@@ -3876,7 +3969,7 @@ export function createEngine(projectDir, ports) {
|
|
|
3876
3969
|
// 取消 = 与完成同一条销毁路径(归档报告 → 销毁实例目录 → 删空产出目录)。
|
|
3877
3970
|
const destroyed = destroyInstance(instId, "cancelled", state);
|
|
3878
3971
|
if (destroyed) {
|
|
3879
|
-
const rel =
|
|
3972
|
+
const rel = reportPathOf(instId);
|
|
3880
3973
|
const head = `🛑 实例 \`${instId}\` 已取消${reason ? `:${reason}` : ""}。报告已归档到 \`${rel}\`。`;
|
|
3881
3974
|
if (destroyed.instanceDirRemoved) {
|
|
3882
3975
|
notify(state, head, `🛑 ralphflow 实例已取消(报告 ${rel})`);
|
|
@@ -3905,7 +3998,7 @@ export function createEngine(projectDir, ports) {
|
|
|
3905
3998
|
const all = listInstances();
|
|
3906
3999
|
if (all.length > 0)
|
|
3907
4000
|
return { ok: true, text: renderActiveOverview(all, sessionId) };
|
|
3908
|
-
return { ok: true, text: `当前没有活跃实例。用 \`/ralphflow-start <工作流> <任务>\` 启动;已结束的运行:报告在 \`${
|
|
4001
|
+
return { ok: true, text: `当前没有活跃实例。用 \`/ralphflow-start <工作流> <任务>\` 启动;已结束的运行:报告在 \`${reportsDirLabel}/\`。` };
|
|
3909
4002
|
}
|
|
3910
4003
|
const info = listInstances().find((i) => i.id === instanceRef || i.id.startsWith(instanceRef));
|
|
3911
4004
|
if (info)
|
|
@@ -3929,7 +4022,7 @@ export function createEngine(projectDir, ports) {
|
|
|
3929
4022
|
].filter(Boolean).join("\n"),
|
|
3930
4023
|
};
|
|
3931
4024
|
}
|
|
3932
|
-
return { ok: true, text: `找不到活跃实例 \`${instanceRef}\`,也没有与它匹配的历史报告。用 \`/ralphflow-list\` 查看活跃实例,或直接看 \`${
|
|
4025
|
+
return { ok: true, text: `找不到活跃实例 \`${instanceRef}\`,也没有与它匹配的历史报告。用 \`/ralphflow-list\` 查看活跃实例,或直接看 \`${reportsDirLabel}/\`。` };
|
|
3933
4026
|
}
|
|
3934
4027
|
}
|
|
3935
4028
|
/**
|
|
@@ -4021,7 +4114,7 @@ export function createEngine(projectDir, ports) {
|
|
|
4021
4114
|
function nextActionHint(s, instId, step) {
|
|
4022
4115
|
if (!s.active) {
|
|
4023
4116
|
// 基本不可达:实例一旦结束就被销毁。保留但改为**指向精确报告路径**。
|
|
4024
|
-
const rel = instId ? `\`${
|
|
4117
|
+
const rel = instId ? `\`${reportPathOf(instId)}\`` : "`" + reportsDirLabel + "/`";
|
|
4025
4118
|
return `工作流已结束,历史在报告里:${rel};要再跑一次用 \`/ralphflow-start <工作流> <任务>\`。`;
|
|
4026
4119
|
}
|
|
4027
4120
|
if (s.paused) {
|
|
@@ -4121,7 +4214,7 @@ export function createEngine(projectDir, ports) {
|
|
|
4121
4214
|
//
|
|
4122
4215
|
// **数据面 `listHistory()` 仍然保留**:doctor 的孤儿产出体检与 status 的历史报告查找
|
|
4123
4216
|
// 都靠它 —— 去掉的是「列表里这一节」,不是「读历史的能力」。
|
|
4124
|
-
body.push("", `已结束的运行:报告在 \`${
|
|
4217
|
+
body.push("", `已结束的运行:报告在 \`${reportsDirLabel}/\`(不在此逐个列出;报告与产出永久保留,只能由你显式删除)。`);
|
|
4125
4218
|
return { ok: true, text: head.concat(body).join("\n") };
|
|
4126
4219
|
}
|
|
4127
4220
|
/**
|
|
@@ -4132,6 +4225,7 @@ export function createEngine(projectDir, ports) {
|
|
|
4132
4225
|
*/
|
|
4133
4226
|
function diagnoseInstanceDirs() {
|
|
4134
4227
|
const issues = [];
|
|
4228
|
+
const instancesLabel = displayPath(projectDir, instancesDir, externalState);
|
|
4135
4229
|
let entries = [];
|
|
4136
4230
|
try {
|
|
4137
4231
|
entries = fs.readdirSync(instancesDir, { withFileTypes: true });
|
|
@@ -4143,7 +4237,7 @@ export function createEngine(projectDir, ports) {
|
|
|
4143
4237
|
if (!e.isDirectory())
|
|
4144
4238
|
continue;
|
|
4145
4239
|
const id = e.name;
|
|
4146
|
-
const label =
|
|
4240
|
+
const label = `${instancesLabel}/${id}/`;
|
|
4147
4241
|
const sp = path.join(instancesDir, id, "state.json");
|
|
4148
4242
|
if (!fs.existsSync(sp)) {
|
|
4149
4243
|
issues.push(`实例目录 \`${label}\` 缺少 state.json —— 所有工具都看不到它。若是残留目录可直接删除`);
|
|
@@ -4171,6 +4265,7 @@ export function createEngine(projectDir, ports) {
|
|
|
4171
4265
|
/** 孤儿产出:`artifacts/<name>/` 既无对应报告、也无对应活跃实例(通常来自被手动清理的实例)。同样只报不删。 */
|
|
4172
4266
|
function diagnoseOrphanArtifacts() {
|
|
4173
4267
|
const issues = [];
|
|
4268
|
+
const artifactsLabel = displayPath(projectDir, artifactsDir, externalState);
|
|
4174
4269
|
const claimed = new Set();
|
|
4175
4270
|
for (const { state } of listInstances())
|
|
4176
4271
|
if (state.artifacts_dir_name)
|
|
@@ -4202,7 +4297,7 @@ export function createEngine(projectDir, ports) {
|
|
|
4202
4297
|
for (const e of entries) {
|
|
4203
4298
|
if (!e.isDirectory() || claimed.has(e.name))
|
|
4204
4299
|
continue;
|
|
4205
|
-
issues.push(`产出目录
|
|
4300
|
+
issues.push(`产出目录 \`${artifactsLabel}/${e.name}/\` 既无对应报告、也无对应实例目录(通常来自被手动清理的实例)—— 只报告,不删除`);
|
|
4206
4301
|
}
|
|
4207
4302
|
return issues;
|
|
4208
4303
|
}
|
|
@@ -4390,7 +4485,7 @@ export function createEngine(projectDir, ports) {
|
|
|
4390
4485
|
}
|
|
4391
4486
|
/** Resolve only an exact trusted report id, never a browser-supplied filesystem path. */
|
|
4392
4487
|
function uiReport(ref) {
|
|
4393
|
-
if (!/^[a-zA-Z0-9_-]+$/.test(ref.runId) || ref.reportRef !==
|
|
4488
|
+
if (!/^[a-zA-Z0-9_-]+$/.test(ref.runId) || ref.reportRef !== reportPathOf(ref.runId))
|
|
4394
4489
|
return null;
|
|
4395
4490
|
let report;
|
|
4396
4491
|
try {
|
|
@@ -4409,7 +4504,7 @@ export function createEngine(projectDir, ports) {
|
|
|
4409
4504
|
root, instancesDir, workflowsDir, reportsDir, projectDir,
|
|
4410
4505
|
ensureLayout, listWorkflows, loadWorkflow,
|
|
4411
4506
|
readState, listInstances, listHistory, instanceDir,
|
|
4412
|
-
artifactsDirOf,
|
|
4507
|
+
artifactsDirOf, artifactsDisplayDirOf, reportPathOf, destroyInstance,
|
|
4413
4508
|
start, onSubmit, noteAssistantText, remindToSubmit, pauseForUserStop, continueInstance, resetCurrent, rewindTo, cancelInstance, statusOf, listAll, restore, diagnose,
|
|
4414
4509
|
activeInstanceOfSession, uiStatus, uiReport,
|
|
4415
4510
|
};
|
package/lib/facade.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ import { type GraphWorkflowEntry } from "./graph/assets.js";
|
|
|
5
5
|
import { type GraphInstanceState, type GraphRunProjection } from "./graph/state.js";
|
|
6
6
|
import { type UnifiedAssetEntry } from "./assets.js";
|
|
7
7
|
import type { ViewerAsset, WorkflowStatus } from "./status-contract.js";
|
|
8
|
-
|
|
8
|
+
import { type RuntimeOptions } from "./paths.js";
|
|
9
|
+
export interface FacadeOptions extends RuntimeOptions {
|
|
9
10
|
ctx: Context;
|
|
10
11
|
ports: EnginePorts;
|
|
11
12
|
}
|
|
@@ -30,9 +31,9 @@ export declare function createFacade(workspace: string, options: FacadeOptions):
|
|
|
30
31
|
listHistory: () => HistoryInfo[];
|
|
31
32
|
instanceDir: (instId: string) => string;
|
|
32
33
|
artifactsDirOf: (instId: string) => string;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
destroyInstance: (instId: string, status: "
|
|
34
|
+
artifactsDisplayDirOf: (instId: string) => string;
|
|
35
|
+
reportPathOf: (instId: string) => string;
|
|
36
|
+
destroyInstance: (instId: string, status: import("./terminal.js").ArchiveStatus, state?: InstanceState) => {
|
|
36
37
|
reportPath: string;
|
|
37
38
|
instanceDirRemoved: boolean;
|
|
38
39
|
instanceDir: string;
|
|
@@ -137,9 +138,9 @@ export declare function createFacade(workspace: string, options: FacadeOptions):
|
|
|
137
138
|
listHistory: () => HistoryInfo[];
|
|
138
139
|
instanceDir: (instId: string) => string;
|
|
139
140
|
artifactsDirOf: (instId: string) => string;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
destroyInstance: (instId: string, status: "
|
|
141
|
+
artifactsDisplayDirOf: (instId: string) => string;
|
|
142
|
+
reportPathOf: (instId: string) => string;
|
|
143
|
+
destroyInstance: (instId: string, status: import("./terminal.js").ArchiveStatus, state?: InstanceState) => {
|
|
143
144
|
reportPath: string;
|
|
144
145
|
instanceDirRemoved: boolean;
|
|
145
146
|
instanceDir: string;
|