ralphflow-dsh 0.1.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/LICENSE +21 -0
- package/README.md +196 -0
- package/lib/actions.d.ts +37 -0
- package/lib/actions.js +55 -0
- package/lib/check-voting.d.ts +54 -0
- package/lib/check-voting.js +289 -0
- package/lib/check.d.ts +64 -0
- package/lib/check.js +329 -0
- package/lib/client/CommandCard.d.ts +24 -0
- package/lib/client/CommandCard.js +69 -0
- package/lib/client/HeaderAction.d.ts +39 -0
- package/lib/client/HeaderAction.js +509 -0
- package/lib/client/RunCard.d.ts +27 -0
- package/lib/client/RunCard.js +375 -0
- package/lib/client/client.d.ts +3 -0
- package/lib/client/client.js +275 -0
- package/lib/client/definition.d.ts +126 -0
- package/lib/client/definition.js +259 -0
- package/lib/client/hidden-runs.d.ts +6 -0
- package/lib/client/hidden-runs.js +52 -0
- package/lib/client/http-state.d.ts +67 -0
- package/lib/client/http-state.js +81 -0
- package/lib/client/markdown.d.ts +26 -0
- package/lib/client/markdown.js +174 -0
- package/lib/client/notify-watch.d.ts +38 -0
- package/lib/client/notify-watch.js +98 -0
- package/lib/client/notify.d.ts +21 -0
- package/lib/client/notify.js +168 -0
- package/lib/client/snapshots.d.ts +8 -0
- package/lib/client/snapshots.js +101 -0
- package/lib/client.js +2361 -0
- package/lib/commands.d.ts +41 -0
- package/lib/commands.js +223 -0
- package/lib/create.d.ts +14 -0
- package/lib/create.js +98 -0
- package/lib/deps.d.ts +17 -0
- package/lib/deps.js +19 -0
- package/lib/done-detect.d.ts +2 -0
- package/lib/done-detect.js +28 -0
- package/lib/driver.d.ts +32 -0
- package/lib/driver.js +248 -0
- package/lib/engine.d.ts +306 -0
- package/lib/engine.js +2851 -0
- package/lib/events.d.ts +35 -0
- package/lib/events.js +52 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.js +201 -0
- package/lib/jobs.d.ts +56 -0
- package/lib/jobs.js +355 -0
- package/lib/mutex.d.ts +9 -0
- package/lib/mutex.js +21 -0
- package/lib/session-hygiene.d.ts +25 -0
- package/lib/session-hygiene.js +205 -0
- package/lib/tools.d.ts +24 -0
- package/lib/tools.js +716 -0
- package/lib/voting-progress.d.ts +37 -0
- package/lib/voting-progress.js +89 -0
- package/package.json +73 -0
- package/workflows/loop.yaml +27 -0
- package/workflows/spec.yaml +105 -0
package/lib/client.js
ADDED
|
@@ -0,0 +1,2361 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "ralphflow",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
"use strict";
|
|
8
|
+
var __create = Object.create;
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name2 in all)
|
|
16
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
27
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
29
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
31
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
32
|
+
mod
|
|
33
|
+
));
|
|
34
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
|
+
|
|
36
|
+
// src/client/client.ts
|
|
37
|
+
var client_exports = {};
|
|
38
|
+
__export(client_exports, {
|
|
39
|
+
apply: () => apply,
|
|
40
|
+
inject: () => inject,
|
|
41
|
+
name: () => name
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(client_exports);
|
|
44
|
+
|
|
45
|
+
// src/client/hidden-runs.ts
|
|
46
|
+
var KEY = "ralphflow:hidden-runs";
|
|
47
|
+
var cache = null;
|
|
48
|
+
function load() {
|
|
49
|
+
if (cache) return cache;
|
|
50
|
+
try {
|
|
51
|
+
const raw = localStorage.getItem(KEY);
|
|
52
|
+
cache = new Set(raw ? JSON.parse(raw) : []);
|
|
53
|
+
} catch {
|
|
54
|
+
cache = /* @__PURE__ */ new Set();
|
|
55
|
+
}
|
|
56
|
+
return cache;
|
|
57
|
+
}
|
|
58
|
+
function persist(set) {
|
|
59
|
+
try {
|
|
60
|
+
localStorage.setItem(KEY, JSON.stringify([...set].slice(-300)));
|
|
61
|
+
cache = set;
|
|
62
|
+
} catch {
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function isRunHidden(runId) {
|
|
66
|
+
if (!runId) return false;
|
|
67
|
+
try {
|
|
68
|
+
return load().has(runId);
|
|
69
|
+
} catch {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function hideRun(runId) {
|
|
74
|
+
try {
|
|
75
|
+
const s = load();
|
|
76
|
+
s.add(runId);
|
|
77
|
+
persist(s);
|
|
78
|
+
} catch {
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
function isHiddenEvent(data) {
|
|
82
|
+
const id = data?.runId;
|
|
83
|
+
return typeof id === "string" && id.length > 0 && isRunHidden(id);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// src/client/definition.ts
|
|
87
|
+
var RALPHFLOW_RUN_KIND = "ralphflow-run";
|
|
88
|
+
var EVENT_TYPES = [
|
|
89
|
+
"tool-ralphflow/run-start",
|
|
90
|
+
"tool-ralphflow/run-detach",
|
|
91
|
+
"tool-ralphflow/step-start",
|
|
92
|
+
"tool-ralphflow/check-voter-start",
|
|
93
|
+
"tool-ralphflow/check-verdict",
|
|
94
|
+
"tool-ralphflow/check-result",
|
|
95
|
+
"tool-ralphflow/gate",
|
|
96
|
+
"tool-ralphflow/rewind",
|
|
97
|
+
"tool-ralphflow/reset",
|
|
98
|
+
"tool-ralphflow/report",
|
|
99
|
+
"tool-ralphflow/run-end"
|
|
100
|
+
];
|
|
101
|
+
function match(event) {
|
|
102
|
+
if (!event.data?.runId) return null;
|
|
103
|
+
if (isHiddenEvent(event.data)) return null;
|
|
104
|
+
if (event.type === "tool-ralphflow/run-start") {
|
|
105
|
+
return { id: String(event.data?.runId), role: "start" };
|
|
106
|
+
}
|
|
107
|
+
if (EVENT_TYPES.includes(event.type) && event.type !== "tool-ralphflow/run-start") {
|
|
108
|
+
return { id: String(event.data?.runId), role: "update" };
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
function startState(data) {
|
|
113
|
+
return {
|
|
114
|
+
workflow: data?.workflow ?? "",
|
|
115
|
+
task: data?.task ?? "",
|
|
116
|
+
runId: data?.runId ? String(data.runId) : void 0,
|
|
117
|
+
steps: Array.isArray(data?.steps) ? data.steps : [],
|
|
118
|
+
current: null,
|
|
119
|
+
stepStartedAt: void 0,
|
|
120
|
+
voterStarts: [],
|
|
121
|
+
verdicts: [],
|
|
122
|
+
lastCheck: null,
|
|
123
|
+
gate: null,
|
|
124
|
+
rewinds: [],
|
|
125
|
+
report: null,
|
|
126
|
+
stopReason: void 0
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function updateState(state, event) {
|
|
130
|
+
if (state.stopReason === "done" || state.stopReason === "cancelled") return state;
|
|
131
|
+
const d = event.data ?? {};
|
|
132
|
+
switch (event.type) {
|
|
133
|
+
// 转交:实例已被另一个会话接管,本会话这张卡停止计数(僵尸运行消除)
|
|
134
|
+
case "tool-ralphflow/run-detach":
|
|
135
|
+
return { ...state, detached: true };
|
|
136
|
+
case "tool-ralphflow/step-start":
|
|
137
|
+
return {
|
|
138
|
+
...state,
|
|
139
|
+
current: { step: d.step, phase: d.phase, failCount: d.failCount ?? 0 },
|
|
140
|
+
stepStartedAt: typeof d.ts === "number" && d.ts > 0 ? d.ts : Date.now(),
|
|
141
|
+
voters: typeof d.voters === "number" && d.voters > 0 ? d.voters : state.voters,
|
|
142
|
+
timeoutMs: typeof d.timeoutMs === "number" && d.timeoutMs > 0 ? d.timeoutMs : state.timeoutMs,
|
|
143
|
+
// 新验证轮开始:上一轮的启动记录清空(verdicts 由 check-result 清)
|
|
144
|
+
voterStarts: [],
|
|
145
|
+
// step-start 到达即说明审查门已批准/跳过(门只在 DO 完成点停住),
|
|
146
|
+
// check 相位的第一帧也要摘掉门卡,不能等下一步 DO 才清。
|
|
147
|
+
gate: null
|
|
148
|
+
};
|
|
149
|
+
case "tool-ralphflow/check-voter-start": {
|
|
150
|
+
const incoming = {
|
|
151
|
+
voter: typeof d.voter === "number" ? d.voter : 1,
|
|
152
|
+
count: typeof d.count === "number" ? d.count : 1,
|
|
153
|
+
model: typeof d.model === "string" && d.model ? d.model : void 0,
|
|
154
|
+
startedAt: typeof d.startedAt === "number" && d.startedAt > 0 ? d.startedAt : Date.now(),
|
|
155
|
+
retry: !!d.retry
|
|
156
|
+
};
|
|
157
|
+
const idx = state.voterStarts.findIndex((s) => s.voter === incoming.voter);
|
|
158
|
+
const voterStarts = idx >= 0 ? state.voterStarts.map((s, i) => i === idx ? incoming : s) : [...state.voterStarts, incoming];
|
|
159
|
+
return { ...state, voterStarts };
|
|
160
|
+
}
|
|
161
|
+
case "tool-ralphflow/check-verdict": {
|
|
162
|
+
const status = d.status === "pass" || d.status === "fail" || d.status === "infra" ? d.status : "infra";
|
|
163
|
+
const incoming = {
|
|
164
|
+
voter: d.voter ?? 1,
|
|
165
|
+
count: d.count ?? 1,
|
|
166
|
+
model: d.model ?? "",
|
|
167
|
+
status,
|
|
168
|
+
reasoning: d.reasoning ?? "",
|
|
169
|
+
...typeof d.arrivedAt === "number" && d.arrivedAt > 0 ? { arrivedAt: d.arrivedAt } : {}
|
|
170
|
+
};
|
|
171
|
+
const idx = state.verdicts.findIndex((v) => v.voter === incoming.voter);
|
|
172
|
+
const verdicts = idx >= 0 ? state.verdicts.map((v, i) => i === idx ? incoming : v) : [...state.verdicts, incoming];
|
|
173
|
+
return { ...state, verdicts };
|
|
174
|
+
}
|
|
175
|
+
case "tool-ralphflow/check-result":
|
|
176
|
+
return { ...state, lastCheck: { passed: !!d.passed, reason: d.reason }, verdicts: [] };
|
|
177
|
+
case "tool-ralphflow/gate":
|
|
178
|
+
return {
|
|
179
|
+
...state,
|
|
180
|
+
gate: {
|
|
181
|
+
step: d.step,
|
|
182
|
+
title: d.title,
|
|
183
|
+
reason: d.reason,
|
|
184
|
+
...typeof d.taskExcerpt === "string" && d.taskExcerpt ? { taskExcerpt: d.taskExcerpt } : {}
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
case "tool-ralphflow/rewind":
|
|
188
|
+
return {
|
|
189
|
+
...state,
|
|
190
|
+
rewinds: [...state.rewinds, { fromStep: d.fromStep, toStep: d.toStep, reason: d.reason }],
|
|
191
|
+
gate: null,
|
|
192
|
+
verdicts: [],
|
|
193
|
+
lastCheck: null
|
|
194
|
+
};
|
|
195
|
+
case "tool-ralphflow/reset":
|
|
196
|
+
return { ...state, gate: null };
|
|
197
|
+
case "tool-ralphflow/report":
|
|
198
|
+
return { ...state, report: { text: d.text ?? "", ...typeof d.reportPath === "string" && d.reportPath ? { reportPath: d.reportPath } : {} } };
|
|
199
|
+
case "tool-ralphflow/run-end":
|
|
200
|
+
return { ...state, stopReason: d.stopReason };
|
|
201
|
+
default:
|
|
202
|
+
return state;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
function buildViewNode(context) {
|
|
206
|
+
if (!context.start) return null;
|
|
207
|
+
const state = context.state ?? startState({});
|
|
208
|
+
return {
|
|
209
|
+
key: context.key,
|
|
210
|
+
kind: RALPHFLOW_RUN_KIND,
|
|
211
|
+
id: context.id,
|
|
212
|
+
target: "chat",
|
|
213
|
+
anchorSeq: context.start.event.seq,
|
|
214
|
+
location: context.start.location,
|
|
215
|
+
visibility: "visible",
|
|
216
|
+
data: state
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
function createDefinition() {
|
|
220
|
+
return {
|
|
221
|
+
kind: RALPHFLOW_RUN_KIND,
|
|
222
|
+
target: "chat",
|
|
223
|
+
match,
|
|
224
|
+
start: (_context, match2) => startState(match2.event.data),
|
|
225
|
+
update: (context, match2) => updateState(context.state, match2.event),
|
|
226
|
+
buildViewNode
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
var RALPHFLOW_COMMAND_KIND = "ralphflow-command";
|
|
230
|
+
var STATIC_COMMAND_NAMES = /* @__PURE__ */ new Set([
|
|
231
|
+
"ralphflow-start",
|
|
232
|
+
"ralphflow-continue",
|
|
233
|
+
"ralphflow-status",
|
|
234
|
+
"ralphflow-list",
|
|
235
|
+
"ralphflow-cancel",
|
|
236
|
+
"ralphflow-rewind",
|
|
237
|
+
"ralphflow-reset",
|
|
238
|
+
"ralphflow-doctor",
|
|
239
|
+
"ralphflow-create"
|
|
240
|
+
]);
|
|
241
|
+
var workflowShortcuts = /* @__PURE__ */ new Set();
|
|
242
|
+
function registerWorkflowShortcutNames(names) {
|
|
243
|
+
workflowShortcuts.clear();
|
|
244
|
+
for (const n of Array.isArray(names) ? names : []) {
|
|
245
|
+
try {
|
|
246
|
+
workflowShortcuts.add(String(n).toLowerCase());
|
|
247
|
+
} catch {
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
function isRalphflowCommand(name2) {
|
|
252
|
+
const n = String(name2 ?? "");
|
|
253
|
+
return STATIC_COMMAND_NAMES.has(n) || n.startsWith("ralphflow-") || workflowShortcuts.has(n.toLowerCase());
|
|
254
|
+
}
|
|
255
|
+
var knownCommandIds = /* @__PURE__ */ new Set();
|
|
256
|
+
function matchCommand(event) {
|
|
257
|
+
const d = event.data ?? {};
|
|
258
|
+
const commandId = String(d?.commandId ?? "");
|
|
259
|
+
if (!commandId) return null;
|
|
260
|
+
if (event.type === "command/run") {
|
|
261
|
+
const name2 = String(d?.name ?? "");
|
|
262
|
+
if (!name2 || !isRalphflowCommand(name2)) return null;
|
|
263
|
+
knownCommandIds.add(commandId);
|
|
264
|
+
return { id: `cmd-${commandId}`, role: "start" };
|
|
265
|
+
}
|
|
266
|
+
if (event.type === "command/done") {
|
|
267
|
+
if (!knownCommandIds.has(commandId)) return null;
|
|
268
|
+
knownCommandIds.delete(commandId);
|
|
269
|
+
return { id: `cmd-${commandId}`, role: "update" };
|
|
270
|
+
}
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
function startCommandState(data) {
|
|
274
|
+
return { command: String(data?.name ?? ""), text: "", running: true, error: false };
|
|
275
|
+
}
|
|
276
|
+
function updateCommandState(state, data) {
|
|
277
|
+
try {
|
|
278
|
+
const kind = String(data?.kind ?? "");
|
|
279
|
+
const text = String(data?.text ?? "");
|
|
280
|
+
return { command: state.command || String(data?.name ?? ""), text, running: false, error: kind === "error" };
|
|
281
|
+
} catch {
|
|
282
|
+
return state;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
function buildCommandViewNode(context) {
|
|
286
|
+
if (!context.start) return null;
|
|
287
|
+
const state = context.state ?? startCommandState({});
|
|
288
|
+
return {
|
|
289
|
+
key: context.key,
|
|
290
|
+
kind: RALPHFLOW_COMMAND_KIND,
|
|
291
|
+
id: context.id,
|
|
292
|
+
target: "chat",
|
|
293
|
+
anchorSeq: context.start.event.seq,
|
|
294
|
+
location: context.start.location,
|
|
295
|
+
visibility: "visible",
|
|
296
|
+
data: state
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
function createCommandDefinition() {
|
|
300
|
+
return {
|
|
301
|
+
kind: RALPHFLOW_COMMAND_KIND,
|
|
302
|
+
target: "chat",
|
|
303
|
+
match: matchCommand,
|
|
304
|
+
start: (_context, m) => startCommandState(m.event.data),
|
|
305
|
+
update: (context, m) => updateCommandState(context.state, m.event.data),
|
|
306
|
+
buildViewNode: buildCommandViewNode
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// src/client/RunCard.tsx
|
|
311
|
+
var React = __toESM(require("react"), 1);
|
|
312
|
+
|
|
313
|
+
// src/client/markdown.tsx
|
|
314
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
315
|
+
function parseInline(text) {
|
|
316
|
+
const tokens = [];
|
|
317
|
+
const re = /(`[^`]+`)|(\*\*[^*]+\*\*)|(\*[^*\s][^*]*\*)|(\[[^\]]+\]\([^)\s]+\))/g;
|
|
318
|
+
let last = 0;
|
|
319
|
+
let m;
|
|
320
|
+
while ((m = re.exec(text)) !== null) {
|
|
321
|
+
if (m.index > last) tokens.push({ type: "text", text: text.slice(last, m.index) });
|
|
322
|
+
const raw = m[0];
|
|
323
|
+
if (raw.startsWith("`")) tokens.push({ type: "code", text: raw.slice(1, -1) });
|
|
324
|
+
else if (raw.startsWith("**")) tokens.push({ type: "bold", text: raw.slice(2, -2) });
|
|
325
|
+
else if (raw.startsWith("*")) tokens.push({ type: "italic", text: raw.slice(1, -1) });
|
|
326
|
+
else {
|
|
327
|
+
const link = /^\[([^\]]+)\]\(([^)\s]+)\)$/.exec(raw);
|
|
328
|
+
tokens.push(link ? { type: "link", text: link[1], href: link[2] } : { type: "text", text: raw });
|
|
329
|
+
}
|
|
330
|
+
last = m.index + raw.length;
|
|
331
|
+
}
|
|
332
|
+
if (last < text.length) tokens.push({ type: "text", text: text.slice(last) });
|
|
333
|
+
return tokens.length > 0 ? tokens : [{ type: "text", text }];
|
|
334
|
+
}
|
|
335
|
+
function renderInline(tokens, keyPrefix) {
|
|
336
|
+
return tokens.map((tk, i) => {
|
|
337
|
+
const key = `${keyPrefix}-${i}`;
|
|
338
|
+
switch (tk.type) {
|
|
339
|
+
case "code":
|
|
340
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { style: { fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace", fontSize: "0.92em", background: "var(--dsw-alias-bg-layer-2)", borderRadius: "4px", padding: "1px 5px" }, children: tk.text }, key);
|
|
341
|
+
case "bold":
|
|
342
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { style: { fontWeight: 600 }, children: tk.text }, key);
|
|
343
|
+
case "italic":
|
|
344
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("em", { children: tk.text }, key);
|
|
345
|
+
case "link": {
|
|
346
|
+
const href = safeLinkHref(tk.href);
|
|
347
|
+
return href === null ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: tk.text }, key) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href, target: "_blank", rel: "noreferrer", style: { color: "var(--dsw-alias-state-business-primary)" }, children: tk.text }, key);
|
|
348
|
+
}
|
|
349
|
+
default:
|
|
350
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: tk.text }, key);
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
function safeLinkHref(href) {
|
|
355
|
+
try {
|
|
356
|
+
if (!href) return null;
|
|
357
|
+
const h = href.trim();
|
|
358
|
+
if (h.startsWith("#") || h.startsWith("/") || h.startsWith("./") || h.startsWith("../")) return h;
|
|
359
|
+
if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(h)) {
|
|
360
|
+
return /^(https?|mailto|file):/i.test(h) ? h : null;
|
|
361
|
+
}
|
|
362
|
+
return null;
|
|
363
|
+
} catch {
|
|
364
|
+
return null;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
var block = {
|
|
368
|
+
h1: { fontSize: "16px", fontWeight: 600, margin: "10px 0 4px", color: "var(--dsw-alias-label-primary)" },
|
|
369
|
+
h2: { fontSize: "14.5px", fontWeight: 600, margin: "10px 0 4px", color: "var(--dsw-alias-label-primary)" },
|
|
370
|
+
h3: { fontSize: "13.5px", fontWeight: 600, margin: "8px 0 3px", color: "var(--dsw-alias-label-primary)" },
|
|
371
|
+
p: { margin: "3px 0" },
|
|
372
|
+
li: { margin: "2px 0", marginLeft: "18px" },
|
|
373
|
+
quote: { borderLeft: "3px solid var(--dsw-alias-border-l2)", margin: "6px 0", padding: "2px 10px", color: "var(--dsw-alias-label-secondary)" },
|
|
374
|
+
codeBlock: {
|
|
375
|
+
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
|
|
376
|
+
fontSize: "12px",
|
|
377
|
+
background: "var(--dsw-alias-bg-layer-2)",
|
|
378
|
+
borderRadius: "6px",
|
|
379
|
+
padding: "8px 10px",
|
|
380
|
+
overflowX: "auto",
|
|
381
|
+
whiteSpace: "pre-wrap",
|
|
382
|
+
wordBreak: "break-word",
|
|
383
|
+
margin: "6px 0"
|
|
384
|
+
},
|
|
385
|
+
hr: { border: "none", borderTop: "1px solid var(--dsw-alias-border-l1)", margin: "10px 0" }
|
|
386
|
+
};
|
|
387
|
+
function Markdown({ text }) {
|
|
388
|
+
try {
|
|
389
|
+
const lines = String(text ?? "").split("\n");
|
|
390
|
+
const out = [];
|
|
391
|
+
let i = 0;
|
|
392
|
+
let key = 0;
|
|
393
|
+
while (i < lines.length) {
|
|
394
|
+
const line = lines[i];
|
|
395
|
+
if (/^\s*```/.test(line)) {
|
|
396
|
+
const buf2 = [];
|
|
397
|
+
i++;
|
|
398
|
+
while (i < lines.length && !/^\s*```/.test(lines[i])) {
|
|
399
|
+
buf2.push(lines[i]);
|
|
400
|
+
i++;
|
|
401
|
+
}
|
|
402
|
+
i++;
|
|
403
|
+
out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { style: block.codeBlock, children: buf2.join("\n") }, key++));
|
|
404
|
+
continue;
|
|
405
|
+
}
|
|
406
|
+
if (/^\s*(---+|\*\*\*+)\s*$/.test(line)) {
|
|
407
|
+
out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("hr", { style: block.hr }, key++));
|
|
408
|
+
i++;
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
const head = /^(#{1,4})\s+(.*)$/.exec(line);
|
|
412
|
+
if (head) {
|
|
413
|
+
const level = head[1].length;
|
|
414
|
+
const st = level === 1 ? block.h1 : level === 2 ? block.h2 : block.h3;
|
|
415
|
+
out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: st, children: renderInline(parseInline(head[2]), `h${key}`) }, key++));
|
|
416
|
+
i++;
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
if (/^\s*>\s?/.test(line)) {
|
|
420
|
+
const buf2 = [];
|
|
421
|
+
while (i < lines.length && /^\s*>\s?/.test(lines[i])) {
|
|
422
|
+
buf2.push(lines[i].replace(/^\s*>\s?/, ""));
|
|
423
|
+
i++;
|
|
424
|
+
}
|
|
425
|
+
out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("blockquote", { style: block.quote, children: renderInline(parseInline(buf2.join(" ")), `q${key}`) }, key++));
|
|
426
|
+
continue;
|
|
427
|
+
}
|
|
428
|
+
if (/^\s*[-*]\s+/.test(line)) {
|
|
429
|
+
const items = [];
|
|
430
|
+
while (i < lines.length && /^\s*[-*]\s+/.test(lines[i])) {
|
|
431
|
+
items.push(lines[i].replace(/^\s*[-*]\s+/, ""));
|
|
432
|
+
i++;
|
|
433
|
+
}
|
|
434
|
+
out.push(
|
|
435
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { style: { margin: "4px 0", paddingLeft: "4px" }, children: items.map((it, j) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { style: block.li, children: renderInline(parseInline(it), `u${key}-${j}`) }, j)) }, key++)
|
|
436
|
+
);
|
|
437
|
+
continue;
|
|
438
|
+
}
|
|
439
|
+
if (/^\s*\d+[.)]\s+/.test(line)) {
|
|
440
|
+
const items = [];
|
|
441
|
+
while (i < lines.length && /^\s*\d+[.)]\s+/.test(lines[i])) {
|
|
442
|
+
items.push(lines[i].replace(/^\s*\d+[.)]\s+/, ""));
|
|
443
|
+
i++;
|
|
444
|
+
}
|
|
445
|
+
out.push(
|
|
446
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("ol", { style: { margin: "4px 0", paddingLeft: "20px" }, children: items.map((it, j) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { style: block.li, children: renderInline(parseInline(it), `o${key}-${j}`) }, j)) }, key++)
|
|
447
|
+
);
|
|
448
|
+
continue;
|
|
449
|
+
}
|
|
450
|
+
if (!line.trim()) {
|
|
451
|
+
i++;
|
|
452
|
+
continue;
|
|
453
|
+
}
|
|
454
|
+
const buf = [];
|
|
455
|
+
while (i < lines.length && lines[i].trim() && !/^\s*(#{1,4}\s|[-*]\s|\d+[.)]\s|>|```|---+$)/.test(lines[i])) {
|
|
456
|
+
buf.push(lines[i]);
|
|
457
|
+
i++;
|
|
458
|
+
}
|
|
459
|
+
if (buf.length > 0) out.push(/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { style: block.p, children: renderInline(parseInline(buf.join("\n")), `p${key}`) }, key++));
|
|
460
|
+
else i++;
|
|
461
|
+
}
|
|
462
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: out });
|
|
463
|
+
} catch {
|
|
464
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { whiteSpace: "pre-wrap", wordBreak: "break-word" }, children: String(text ?? "") });
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
// src/client/RunCard.tsx
|
|
469
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
470
|
+
var NUM = { fontVariantNumeric: "tabular-nums" };
|
|
471
|
+
var STYLE = {
|
|
472
|
+
root: {
|
|
473
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
474
|
+
borderRadius: "10px",
|
|
475
|
+
background: "var(--dsw-alias-bg-layer-1)",
|
|
476
|
+
padding: "12px 14px",
|
|
477
|
+
margin: "6px 0",
|
|
478
|
+
fontSize: "13.5px",
|
|
479
|
+
lineHeight: 1.6
|
|
480
|
+
},
|
|
481
|
+
head: {
|
|
482
|
+
display: "flex",
|
|
483
|
+
alignItems: "center",
|
|
484
|
+
gap: "8px",
|
|
485
|
+
marginBottom: "8px"
|
|
486
|
+
},
|
|
487
|
+
shrinkName: {
|
|
488
|
+
minWidth: 0,
|
|
489
|
+
overflow: "hidden",
|
|
490
|
+
textOverflow: "ellipsis",
|
|
491
|
+
whiteSpace: "nowrap"
|
|
492
|
+
},
|
|
493
|
+
badge: (bg, fg) => ({
|
|
494
|
+
fontSize: "11px",
|
|
495
|
+
padding: "2px 8px",
|
|
496
|
+
borderRadius: "999px",
|
|
497
|
+
background: bg,
|
|
498
|
+
color: fg || "var(--dsw-alias-label-primary-inverted)",
|
|
499
|
+
flexShrink: 0,
|
|
500
|
+
whiteSpace: "nowrap",
|
|
501
|
+
transition: "background-color .25s ease, color .25s ease"
|
|
502
|
+
}),
|
|
503
|
+
steps: { display: "flex", flexWrap: "wrap", gap: "6px" },
|
|
504
|
+
step: (state) => ({
|
|
505
|
+
fontSize: "12px",
|
|
506
|
+
padding: "3px 8px",
|
|
507
|
+
borderRadius: "6px",
|
|
508
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
509
|
+
maxWidth: "220px",
|
|
510
|
+
overflow: "hidden",
|
|
511
|
+
textOverflow: "ellipsis",
|
|
512
|
+
whiteSpace: "nowrap",
|
|
513
|
+
background: state === "done" ? "var(--dsw-alias-state-success-tertiary)" : state === "active" ? "var(--dsw-alias-state-business-tertiary)" : state === "fail" ? "var(--dsw-alias-state-error-secondary)" : "transparent",
|
|
514
|
+
color: state === "done" ? "var(--dsw-alias-state-success-primary)" : state === "active" ? "var(--dsw-alias-state-business-primary)" : state === "fail" ? "var(--dsw-alias-state-error-primary)" : "var(--dsw-alias-label-secondary)",
|
|
515
|
+
transition: "background-color .25s ease, color .25s ease"
|
|
516
|
+
}),
|
|
517
|
+
verdictRow: {
|
|
518
|
+
display: "flex",
|
|
519
|
+
alignItems: "center",
|
|
520
|
+
gap: "8px",
|
|
521
|
+
padding: "4px 0",
|
|
522
|
+
borderBottom: "1px solid var(--dsw-alias-border-l1)",
|
|
523
|
+
flexWrap: "wrap",
|
|
524
|
+
animation: "ralphflow-row-in .3s ease"
|
|
525
|
+
},
|
|
526
|
+
mono: { fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace", fontSize: "12px", color: "var(--dsw-alias-label-secondary)", ...NUM },
|
|
527
|
+
reason: {
|
|
528
|
+
whiteSpace: "pre-wrap",
|
|
529
|
+
wordBreak: "break-word",
|
|
530
|
+
maxHeight: "180px",
|
|
531
|
+
overflowY: "auto",
|
|
532
|
+
fontSize: "12.5px",
|
|
533
|
+
color: "var(--dsw-alias-label-secondary)"
|
|
534
|
+
},
|
|
535
|
+
task: {
|
|
536
|
+
marginBottom: "6px",
|
|
537
|
+
color: "var(--dsw-alias-label-secondary)",
|
|
538
|
+
wordBreak: "break-word",
|
|
539
|
+
overflowWrap: "anywhere",
|
|
540
|
+
display: "-webkit-box",
|
|
541
|
+
WebkitLineClamp: 3,
|
|
542
|
+
WebkitBoxOrient: "vertical",
|
|
543
|
+
overflow: "hidden"
|
|
544
|
+
},
|
|
545
|
+
excerpt: {
|
|
546
|
+
margin: "6px 0",
|
|
547
|
+
padding: "6px 8px",
|
|
548
|
+
borderRadius: "6px",
|
|
549
|
+
background: "var(--dsw-alias-bg-layer-2)",
|
|
550
|
+
fontSize: "12.5px",
|
|
551
|
+
color: "var(--dsw-alias-label-secondary)",
|
|
552
|
+
maxHeight: "120px",
|
|
553
|
+
overflowY: "auto",
|
|
554
|
+
whiteSpace: "pre-wrap",
|
|
555
|
+
wordBreak: "break-word"
|
|
556
|
+
},
|
|
557
|
+
rewindRow: {
|
|
558
|
+
marginTop: "6px",
|
|
559
|
+
fontSize: "12px",
|
|
560
|
+
padding: "4px 8px",
|
|
561
|
+
borderRadius: "6px",
|
|
562
|
+
background: "var(--dsw-alias-bg-layer-2)",
|
|
563
|
+
color: "var(--dsw-alias-label-secondary)"
|
|
564
|
+
},
|
|
565
|
+
actions: {
|
|
566
|
+
display: "flex",
|
|
567
|
+
gap: "8px",
|
|
568
|
+
marginTop: "10px",
|
|
569
|
+
flexWrap: "wrap",
|
|
570
|
+
alignItems: "center"
|
|
571
|
+
},
|
|
572
|
+
btn: (kind) => ({
|
|
573
|
+
fontSize: "12.5px",
|
|
574
|
+
padding: "5px 12px",
|
|
575
|
+
borderRadius: "6px",
|
|
576
|
+
cursor: "pointer",
|
|
577
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
578
|
+
background: kind === "primary" ? "var(--dsw-alias-button-primary-fill)" : "transparent",
|
|
579
|
+
color: kind === "primary" ? "var(--dsw-alias-label-primary-foreground)" : "var(--dsw-alias-label-primary)"
|
|
580
|
+
}),
|
|
581
|
+
textarea: {
|
|
582
|
+
width: "100%",
|
|
583
|
+
boxSizing: "border-box",
|
|
584
|
+
minHeight: "56px",
|
|
585
|
+
resize: "vertical",
|
|
586
|
+
fontSize: "12.5px",
|
|
587
|
+
lineHeight: 1.5,
|
|
588
|
+
padding: "6px 8px",
|
|
589
|
+
borderRadius: "6px",
|
|
590
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
591
|
+
background: "var(--dsw-alias-bg-layer-2)",
|
|
592
|
+
color: "var(--dsw-alias-label-primary)",
|
|
593
|
+
marginTop: "6px"
|
|
594
|
+
},
|
|
595
|
+
chip: {
|
|
596
|
+
fontSize: "11.5px",
|
|
597
|
+
padding: "2px 8px",
|
|
598
|
+
borderRadius: "999px",
|
|
599
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
600
|
+
background: "transparent",
|
|
601
|
+
color: "var(--dsw-alias-label-secondary)",
|
|
602
|
+
cursor: "pointer"
|
|
603
|
+
},
|
|
604
|
+
progressTrack: {
|
|
605
|
+
height: "3px",
|
|
606
|
+
borderRadius: "999px",
|
|
607
|
+
background: "var(--dsw-alias-bg-layer-2)",
|
|
608
|
+
marginTop: "6px",
|
|
609
|
+
overflow: "hidden"
|
|
610
|
+
}
|
|
611
|
+
};
|
|
612
|
+
var KEYFRAMES_ID = "ralphflow-keyframes";
|
|
613
|
+
function ensureKeyframes() {
|
|
614
|
+
try {
|
|
615
|
+
if (document.getElementById(KEYFRAMES_ID)) return;
|
|
616
|
+
const el = document.createElement("style");
|
|
617
|
+
el.id = KEYFRAMES_ID;
|
|
618
|
+
el.textContent = `
|
|
619
|
+
@keyframes ralphflow-row-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
|
|
620
|
+
@keyframes ralphflow-breath { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
|
|
621
|
+
`;
|
|
622
|
+
document.head.appendChild(el);
|
|
623
|
+
} catch {
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
function tr(t, key, fallback) {
|
|
627
|
+
try {
|
|
628
|
+
const v = t?.(key);
|
|
629
|
+
return typeof v === "string" && v ? v : fallback;
|
|
630
|
+
} catch {
|
|
631
|
+
return fallback;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
function trf(t, key, fallback, params) {
|
|
635
|
+
const raw = tr(t, key, fallback);
|
|
636
|
+
return raw.replace(/\{(\w+)\}/g, (_, k) => params[k] != null ? String(params[k]) : `{${k}}`);
|
|
637
|
+
}
|
|
638
|
+
function formatElapsed(ms) {
|
|
639
|
+
const s = Math.max(0, Math.floor(ms / 1e3));
|
|
640
|
+
if (s < 90) return `${s}s`;
|
|
641
|
+
const m = Math.floor(s / 60);
|
|
642
|
+
if (m < 60) return `${m}m`;
|
|
643
|
+
return `${Math.floor(m / 60)}h${m % 60}m`;
|
|
644
|
+
}
|
|
645
|
+
function shortRunId(runId) {
|
|
646
|
+
if (typeof runId !== "string" || !runId) return null;
|
|
647
|
+
return runId.slice(-4);
|
|
648
|
+
}
|
|
649
|
+
function StepBar({ steps, current }) {
|
|
650
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: STYLE.steps, children: steps.map((s, i) => {
|
|
651
|
+
const active = !!(current && s.id === current.step);
|
|
652
|
+
const curIdx = steps.findIndex((x) => current && x.id === current.step);
|
|
653
|
+
const done = !active && curIdx >= 0 && i < curIdx;
|
|
654
|
+
const fail = active && (current?.failCount ?? 0) > 0;
|
|
655
|
+
const label = String(s.desc ?? "").trim() || s.id || `#${i + 1}`;
|
|
656
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
657
|
+
"span",
|
|
658
|
+
{
|
|
659
|
+
style: STYLE.step(fail ? "fail" : active ? "active" : done ? "done" : "todo"),
|
|
660
|
+
title: `${s.id ?? ""}${s.desc ? ` \u2014 ${s.desc}` : ""}`,
|
|
661
|
+
children: [
|
|
662
|
+
done ? "\u2713 " : "",
|
|
663
|
+
label.length > 24 ? `${label.slice(0, 24)}\u2026` : label
|
|
664
|
+
]
|
|
665
|
+
},
|
|
666
|
+
s.id ?? i
|
|
667
|
+
);
|
|
668
|
+
}) });
|
|
669
|
+
}
|
|
670
|
+
function VoterPanel({
|
|
671
|
+
voterStarts,
|
|
672
|
+
verdicts,
|
|
673
|
+
votersTotal,
|
|
674
|
+
timeoutMs,
|
|
675
|
+
checkStartedAt,
|
|
676
|
+
now,
|
|
677
|
+
t
|
|
678
|
+
}) {
|
|
679
|
+
const total = votersTotal && votersTotal > 0 ? votersTotal : Math.max(1, ...verdicts.map((v) => v.count || 1), ...voterStarts.map((s) => s.count || 1));
|
|
680
|
+
const allDone = verdicts.length >= total;
|
|
681
|
+
const rows = [];
|
|
682
|
+
for (let i = 1; i <= total; i++) {
|
|
683
|
+
const verdict = verdicts.find((v) => v.voter === i);
|
|
684
|
+
const start = voterStarts.find((s) => s.voter === i);
|
|
685
|
+
let icon = "\xB7";
|
|
686
|
+
let iconColor = "var(--dsw-alias-label-tertiary)";
|
|
687
|
+
let stateLabel = tr(t, "run.voter.queued", "\u6392\u961F\u4E2D");
|
|
688
|
+
let elapsedText = "";
|
|
689
|
+
if (verdict) {
|
|
690
|
+
const ok = verdict.status === "pass";
|
|
691
|
+
const infra = verdict.status === "infra";
|
|
692
|
+
icon = ok ? "\u2713" : infra ? "\u26A0" : "\u2717";
|
|
693
|
+
iconColor = ok ? "var(--dsw-alias-state-success-primary)" : infra ? "var(--dsw-alias-state-warn-primary)" : "var(--dsw-alias-state-error-primary)";
|
|
694
|
+
stateLabel = ok ? tr(t, "run.pass", "\u901A\u8FC7") : infra ? tr(t, "run.infra", "\u73AF\u5883\u6545\u969C") : tr(t, "run.fail", "\u672A\u901A\u8FC7");
|
|
695
|
+
if (start?.startedAt && verdict.arrivedAt) elapsedText = formatElapsed(verdict.arrivedAt - start.startedAt);
|
|
696
|
+
} else if (start) {
|
|
697
|
+
icon = "\u27F3";
|
|
698
|
+
iconColor = "var(--dsw-alias-state-business-primary)";
|
|
699
|
+
stateLabel = start.retry ? tr(t, "run.voter.retrying", "\u91CD\u8BD5\u4E2D") : tr(t, "run.voter.running", "\u8FD0\u884C\u4E2D");
|
|
700
|
+
elapsedText = formatElapsed(now - (start.startedAt || now));
|
|
701
|
+
}
|
|
702
|
+
rows.push(
|
|
703
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: STYLE.verdictRow, children: [
|
|
704
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "aria-hidden": "true", style: { color: iconColor, ...icon === "\u27F3" ? { animation: "ralphflow-breath 1.6s ease-in-out infinite", display: "inline-block" } : {} }, children: icon }),
|
|
705
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { color: "var(--dsw-alias-label-secondary)", ...NUM }, children: trf(t, "run.verifier", "\u9A8C\u8BC1\u8005 {v}/{count}", { v: i, count: total }) }),
|
|
706
|
+
start?.model ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: STYLE.mono, children: start.model }) : verdict?.model ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: STYLE.mono, children: verdict.model }) : null,
|
|
707
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { style: { marginLeft: "auto", fontSize: "11px", color: "var(--dsw-alias-label-secondary)", flexShrink: 0, ...NUM }, children: [
|
|
708
|
+
stateLabel,
|
|
709
|
+
elapsedText ? ` \xB7 ${elapsedText}` : ""
|
|
710
|
+
] }),
|
|
711
|
+
verdict?.reason ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { ...STYLE.reason, width: "100%" }, children: verdict.reason }) : null
|
|
712
|
+
] }, `v${i}`)
|
|
713
|
+
);
|
|
714
|
+
}
|
|
715
|
+
const showProgress = !!timeoutMs && !!checkStartedAt && !allDone;
|
|
716
|
+
const ratio = showProgress ? Math.min(1, Math.max(0.02, (now - (checkStartedAt || now)) / timeoutMs)) : 0;
|
|
717
|
+
const nearTimeout = showProgress && ratio > 0.8;
|
|
718
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { marginTop: "8px" }, children: [
|
|
719
|
+
total > 1 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { fontSize: "12px", color: "var(--dsw-alias-label-secondary)", marginBottom: "2px", ...NUM }, children: [
|
|
720
|
+
"\u{1F916} ",
|
|
721
|
+
trf(t, "run.votes", "\u72EC\u7ACB\u9A8C\u8BC1 \xB7 \u5DF2\u6536 {done}/{total} \u7968", { done: verdicts.length, total })
|
|
722
|
+
] }) : null,
|
|
723
|
+
rows,
|
|
724
|
+
showProgress ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
725
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: STYLE.progressTrack, role: "progressbar", "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": Math.round(ratio * 100), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: {
|
|
726
|
+
width: `${ratio * 100}%`,
|
|
727
|
+
height: "100%",
|
|
728
|
+
borderRadius: "999px",
|
|
729
|
+
background: nearTimeout ? "var(--dsw-alias-state-warn-primary)" : "var(--dsw-alias-state-business-tertiary)",
|
|
730
|
+
transition: "width 1s linear, background-color .3s ease"
|
|
731
|
+
} }) }),
|
|
732
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { fontSize: "11px", marginTop: "2px", color: nearTimeout ? "var(--dsw-alias-state-warn-primary)" : "var(--dsw-alias-label-tertiary)", ...NUM }, children: nearTimeout ? tr(t, "run.timeout.near", "\u63A5\u8FD1\u8D85\u65F6\u4E0A\u9650\u2014\u2014\u8D85\u65F6\u540E\u81EA\u52A8\u6682\u505C\uFF0C\u5DF2\u6295\u51FA\u7684\u7968\u4FDD\u7559") : trf(t, "run.timeout.left", "\u8D85\u65F6\u4E0A\u9650 {min} \u5206\u949F", { min: Math.round((timeoutMs || 0) / 6e4) }) })
|
|
733
|
+
] }) : null
|
|
734
|
+
] });
|
|
735
|
+
}
|
|
736
|
+
function GateCard({ gate, t }) {
|
|
737
|
+
const [hint, setHint] = React.useState("");
|
|
738
|
+
const [returning, setReturning] = React.useState(false);
|
|
739
|
+
const [opinion, setOpinion] = React.useState("");
|
|
740
|
+
const sendReturn = () => {
|
|
741
|
+
const text = opinion.trim();
|
|
742
|
+
if (!text) {
|
|
743
|
+
window.dispatchEvent(new CustomEvent("ralphflow:command", { detail: { command: "/ralphflow-reset ", autoSubmit: false } }));
|
|
744
|
+
setHint(tr(t, "run.hint.return", "\u5DF2\u5728\u8F93\u5165\u6846\u586B\u5165 /ralphflow-reset\u2014\u2014\u5728\u540E\u9762\u8865\u4E0A\u4F60\u7684\u4FEE\u6539\u610F\u89C1\u518D\u56DE\u8F66\uFF0C\u6A21\u578B\u4F1A\u636E\u6B64\u8FD4\u5DE5\uFF08\u4E0D\u4F1A\u81EA\u52A8\u53D1\u9001\uFF09\u3002"));
|
|
745
|
+
return;
|
|
746
|
+
}
|
|
747
|
+
window.dispatchEvent(new CustomEvent("ralphflow:command", { detail: { command: `/ralphflow-reset ${text}`, autoSubmit: true } }));
|
|
748
|
+
setHint(tr(t, "run.hint.returned", "\u6253\u56DE\u610F\u89C1\u5DF2\u53D1\u9001\uFF0C\u6A21\u578B\u4F1A\u6309\u4F60\u7684\u610F\u89C1\u8FD4\u5DE5\u672C\u6B65\u9AA4\u3002"));
|
|
749
|
+
};
|
|
750
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
751
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { fontWeight: 600, color: "var(--dsw-alias-label-primary)", marginTop: "8px" }, children: [
|
|
752
|
+
"\u{1F4CB} ",
|
|
753
|
+
tr(t, "run.gate", "\u5F85\u5BA1\u67E5"),
|
|
754
|
+
" \xB7 ",
|
|
755
|
+
gate.title
|
|
756
|
+
] }),
|
|
757
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { ...STYLE.reason, margin: "6px 0" }, children: gate.reason }),
|
|
758
|
+
gate.taskExcerpt ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
759
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { fontSize: "11.5px", color: "var(--dsw-alias-label-tertiary)", marginBottom: "2px" }, children: tr(t, "run.gate.requirement", "\u672C\u6B65\u8981\u6C42\uFF08\u5BA1\u6279\u6750\u6599\uFF09") }),
|
|
760
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: STYLE.excerpt, children: gate.taskExcerpt })
|
|
761
|
+
] }) : null,
|
|
762
|
+
!returning ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: STYLE.actions, children: [
|
|
763
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
764
|
+
"button",
|
|
765
|
+
{
|
|
766
|
+
style: STYLE.btn("primary"),
|
|
767
|
+
onClick: () => {
|
|
768
|
+
window.dispatchEvent(new CustomEvent("ralphflow:command", { detail: { command: "/ralphflow-continue", autoSubmit: true } }));
|
|
769
|
+
setHint(tr(t, "run.hint.approve", "\u5DF2\u628A /ralphflow-continue \u586B\u5165\u8F93\u5165\u6846\u5E76\u5C1D\u8BD5\u53D1\u9001\u2014\u2014\u82E5\u672A\u53D1\u51FA\uFF0C\u6309\u56DE\u8F66\u5373\u6279\u51C6\u8FDB\u5165\u9A8C\u8BC1\u3002"));
|
|
770
|
+
},
|
|
771
|
+
children: [
|
|
772
|
+
"\u2713 ",
|
|
773
|
+
tr(t, "run.approve", "\u901A\u8FC7")
|
|
774
|
+
]
|
|
775
|
+
}
|
|
776
|
+
),
|
|
777
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { style: STYLE.btn("ghost"), onClick: () => setReturning(true), children: [
|
|
778
|
+
"\u2717 ",
|
|
779
|
+
tr(t, "run.return", "\u6253\u56DE")
|
|
780
|
+
] })
|
|
781
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
782
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { fontSize: "12px", color: "var(--dsw-alias-label-secondary)", marginTop: "8px" }, children: tr(t, "run.return.opinion", "\u6253\u56DE\u610F\u89C1\uFF08\u4F1A\u968F\u547D\u4EE4\u53D1\u7ED9\u6A21\u578B\uFF09") }),
|
|
783
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("textarea", { style: STYLE.textarea, value: opinion, onChange: (e) => setOpinion(e.target.value), placeholder: tr(t, "run.return.placeholder", "\u4F8B\u5982\uFF1A\u8FB9\u754C\u60C5\u51B5\u6CA1\u8986\u76D6\uFF0C\u6D4B\u8BD5\u5168\u6302\u4E86\uFF0C\u8BF7\u5148\u4FEE CI \u518D\u4EA4\u4ED8\u2026") }),
|
|
784
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: STYLE.actions, children: [tr(t, "run.chip.tests", "\u6D4B\u8BD5\u6CA1\u8FC7\uFF0C\u8BF7\u5148\u4FEE\u590D"), tr(t, "run.chip.scope", "\u504F\u79BB\u9700\u6C42\u8303\u56F4\uFF0C\u8BF7\u5BF9\u7167\u539F\u59CB\u4EFB\u52A1"), tr(t, "run.chip.quality", "\u8D28\u91CF\u4E0D\u8FBE\u6807\uFF0C\u8BF7\u81EA\u67E5\u540E\u91CD\u65B0\u63D0\u4EA4")].map((c) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", style: STYLE.chip, onClick: () => setOpinion((v) => v ? `${v}\uFF1B${c}` : c), children: c }, c)) }),
|
|
785
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: STYLE.actions, children: [
|
|
786
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { style: STYLE.btn("primary"), onClick: sendReturn, children: tr(t, "run.return.send", "\u53D1\u9001\u6253\u56DE") }),
|
|
787
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { style: STYLE.btn("ghost"), onClick: () => {
|
|
788
|
+
setReturning(false);
|
|
789
|
+
setOpinion("");
|
|
790
|
+
}, children: tr(t, "run.cancel.action", "\u53D6\u6D88") })
|
|
791
|
+
] })
|
|
792
|
+
] }),
|
|
793
|
+
hint ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { marginTop: "6px", fontSize: "12px", color: "var(--dsw-alias-state-warn-primary)" }, children: [
|
|
794
|
+
"\u21A9 ",
|
|
795
|
+
hint
|
|
796
|
+
] }) : null
|
|
797
|
+
] });
|
|
798
|
+
}
|
|
799
|
+
function ReportCard({ report, t }) {
|
|
800
|
+
if (!report.text && !report.reportPath) return null;
|
|
801
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
802
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { fontWeight: 600, marginBottom: "6px", color: "var(--dsw-alias-label-primary)" }, children: [
|
|
803
|
+
"\u{1F4C4} ",
|
|
804
|
+
tr(t, "run.report", "\u6700\u7EC8\u62A5\u544A")
|
|
805
|
+
] }),
|
|
806
|
+
report.text ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { maxHeight: "340px", overflowY: "auto", fontSize: "13px", border: "1px solid var(--dsw-alias-border-l1)", borderRadius: "8px", padding: "10px 12px" }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Markdown, { text: report.text }) }) : null,
|
|
807
|
+
report.reportPath ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { ...STYLE.mono, marginTop: report.text ? "6px" : 0, wordBreak: "break-all" }, children: [
|
|
808
|
+
"\u{1F4C1} ",
|
|
809
|
+
report.reportPath
|
|
810
|
+
] }) : null
|
|
811
|
+
] });
|
|
812
|
+
}
|
|
813
|
+
function RalphRunCard({ node, t }) {
|
|
814
|
+
const data = node?.data;
|
|
815
|
+
const [, tick3] = React.useReducer((n) => n + 1, 0);
|
|
816
|
+
const live = !!data && !data.stopReason && typeof data.stepStartedAt === "number" && data.stepStartedAt > 0;
|
|
817
|
+
const checking = !!data && !data.stopReason && !data.gate && data.current?.phase === "check";
|
|
818
|
+
React.useEffect(() => {
|
|
819
|
+
if (!live && !checking) return;
|
|
820
|
+
const h = setInterval(tick3, 5e3);
|
|
821
|
+
return () => clearInterval(h);
|
|
822
|
+
}, [live, checking]);
|
|
823
|
+
try {
|
|
824
|
+
ensureKeyframes();
|
|
825
|
+
} catch {
|
|
826
|
+
}
|
|
827
|
+
if (!data) return null;
|
|
828
|
+
const isPaused = data.stopReason === "failed";
|
|
829
|
+
const statusBg = data.stopReason === "done" ? "var(--dsw-alias-state-success-primary)" : isPaused ? "var(--dsw-alias-state-warn-tertiary)" : data.stopReason === "cancelled" ? "transparent" : data.gate ? "var(--dsw-alias-state-warn-primary)" : data.current?.phase === "check" ? "var(--dsw-alias-state-business-primary)" : "var(--dsw-alias-state-business-tertiary)";
|
|
830
|
+
const statusFg = isPaused ? "var(--dsw-alias-state-warn-primary)" : data.stopReason === "cancelled" || !data.stopReason && !data.gate && data.current?.phase !== "check" ? "var(--dsw-alias-state-business-primary)" : void 0;
|
|
831
|
+
const statusLabel = data.stopReason === "done" ? tr(t, "run.done", "\u5DF2\u5B8C\u6210") : data.stopReason === "cancelled" ? tr(t, "run.cancelled", "\u5DF2\u53D6\u6D88") : isPaused ? tr(t, "run.paused", "\u23F8 \u5DF2\u6682\u505C") : data.gate ? tr(t, "run.gate", "\u5F85\u5BA1\u67E5") : data.current?.phase === "check" ? tr(t, "run.check", "\u9A8C\u8BC1\u4E2D") : tr(t, "run.running", "\u8FDB\u884C\u4E2D");
|
|
832
|
+
const elapsed = live ? formatElapsed(Date.now() - data.stepStartedAt) : null;
|
|
833
|
+
const shortId = shortRunId(data.runId);
|
|
834
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { "data-ralphflow-run": true, "data-runid": String(data.runId ?? ""), style: { ...STYLE.root, ...data.detached ? { opacity: 0.75 } : {} }, children: [
|
|
835
|
+
data.detached ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { marginBottom: "8px", padding: "5px 8px", borderRadius: "6px", background: "var(--dsw-alias-bg-layer-2)", fontSize: "12px", color: "var(--dsw-alias-label-secondary)" }, children: [
|
|
836
|
+
"\u21AA ",
|
|
837
|
+
tr(t, "run.detached", "\u6B64\u5DE5\u4F5C\u6D41\u5DF2\u5728\u53E6\u4E00\u4E2A\u4F1A\u8BDD\u7EE7\u7EED\u2014\u2014\u672C\u5361\u4EC5\u4FDD\u7559\u5386\u53F2\uFF0C\u4E0D\u518D\u66F4\u65B0\u3002")
|
|
838
|
+
] }) : null,
|
|
839
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: STYLE.head, children: [
|
|
840
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "aria-hidden": "true", style: { fontWeight: 600, color: "var(--dsw-alias-label-primary)", flexShrink: 0 }, children: "\u{1F300} Ralph Flow" }),
|
|
841
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { "aria-hidden": "true", style: { ...STYLE.mono, ...STYLE.shrinkName }, children: [
|
|
842
|
+
data.workflow,
|
|
843
|
+
shortId ? `\xB7${shortId}` : ""
|
|
844
|
+
] }),
|
|
845
|
+
(data.current?.failCount ?? 0) > 0 && !data.stopReason ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { style: { ...STYLE.mono, color: "var(--dsw-alias-state-error-primary)", flexShrink: 0 }, children: [
|
|
846
|
+
"\xD7",
|
|
847
|
+
data.current.failCount
|
|
848
|
+
] }) : null,
|
|
849
|
+
elapsed ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { style: { ...STYLE.mono, fontSize: "11px", flexShrink: 0 }, title: tr(t, "run.elapsed.title", "\u5F53\u524D\u6B65\u9AA4\u5DF2\u8FD0\u884C\u65F6\u957F"), children: [
|
|
850
|
+
"\u23F1 ",
|
|
851
|
+
elapsed
|
|
852
|
+
] }) : null,
|
|
853
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { marginLeft: "auto", ...STYLE.badge(statusBg, statusFg) }, role: "status", children: statusLabel }),
|
|
854
|
+
(data.stopReason === "done" || data.stopReason === "cancelled" || data.detached) && data.runId ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
855
|
+
"button",
|
|
856
|
+
{
|
|
857
|
+
type: "button",
|
|
858
|
+
"aria-label": tr(t, "run.hide", "\u5173\u95ED\u8FD9\u5F20\u5361\u7247"),
|
|
859
|
+
title: tr(t, "run.hide", "\u5173\u95ED\u8FD9\u5F20\u5361\u7247"),
|
|
860
|
+
style: { border: "none", background: "transparent", color: "var(--dsw-alias-label-tertiary)", cursor: "pointer", fontSize: "13px", flexShrink: 0, padding: "0 2px" },
|
|
861
|
+
onClick: () => {
|
|
862
|
+
try {
|
|
863
|
+
hideRun(String(data.runId));
|
|
864
|
+
} catch {
|
|
865
|
+
}
|
|
866
|
+
try {
|
|
867
|
+
const section = document.querySelector(`[data-ralphflow-run][data-runid="${String(data.runId).replace(/"/g, '\\"')}"]`);
|
|
868
|
+
section?.parentElement?.removeChild(section);
|
|
869
|
+
} catch {
|
|
870
|
+
}
|
|
871
|
+
},
|
|
872
|
+
children: "\xD7"
|
|
873
|
+
}
|
|
874
|
+
) : null
|
|
875
|
+
] }),
|
|
876
|
+
data.task ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: STYLE.task, children: data.task }) : null,
|
|
877
|
+
!Array.isArray(data.steps) || data.steps.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { fontSize: "12.5px", color: "var(--dsw-alias-label-tertiary)", animation: live ? "ralphflow-breath 2.4s ease-in-out infinite" : void 0 }, children: trf(t, "run.waiting.start", "\u6B63\u5728\u7B49\u5F85\u6A21\u578B\u5F00\u59CB\u6267\u884C\u2026{step}", { step: data.current?.step ? `\uFF08${data.current.step}\uFF09` : "" }) }) : null,
|
|
878
|
+
Array.isArray(data.steps) && data.steps.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(StepBar, { steps: data.steps, current: data.current }) : null,
|
|
879
|
+
!isPaused && !data.stopReason ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
880
|
+
VoterPanel,
|
|
881
|
+
{
|
|
882
|
+
voterStarts: Array.isArray(data.voterStarts) ? data.voterStarts : [],
|
|
883
|
+
verdicts: Array.isArray(data.verdicts) ? data.verdicts : [],
|
|
884
|
+
votersTotal: data.voters,
|
|
885
|
+
timeoutMs: data.timeoutMs,
|
|
886
|
+
checkStartedAt: data.current?.phase === "check" ? data.stepStartedAt : void 0,
|
|
887
|
+
now: Date.now(),
|
|
888
|
+
t
|
|
889
|
+
}
|
|
890
|
+
) : null,
|
|
891
|
+
Array.isArray(data.rewinds) && data.rewinds.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { children: data.rewinds.slice(-3).map((r, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: STYLE.rewindRow, children: [
|
|
892
|
+
trf(t, "run.rewind", "\u21A9 \u56DE\u9000 {from} \u2192 {to}", { from: r.fromStep, to: r.toStep }),
|
|
893
|
+
r.reason ? `\uFF1A${String(r.reason).slice(0, 80)}` : ""
|
|
894
|
+
] }, `${r.fromStep}>${r.toStep}-${i}`)) }) : null,
|
|
895
|
+
data.lastCheck ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { marginTop: "6px" }, children: [
|
|
896
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { color: data.lastCheck.passed ? "var(--dsw-alias-state-success-primary)" : "var(--dsw-alias-state-error-primary)", fontWeight: 600 }, children: data.lastCheck.passed ? `\u2705 ${tr(t, "run.check.passed", "\u9A8C\u8BC1\u901A\u8FC7")}` : `\u274C ${tr(t, "run.check.failed", "\u9A8C\u8BC1\u672A\u901A\u8FC7")}` }),
|
|
897
|
+
data.lastCheck.reason ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { ...STYLE.reason, marginTop: "2px" }, children: data.lastCheck.reason }) : null
|
|
898
|
+
] }) : null,
|
|
899
|
+
isPaused ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { marginTop: "8px", padding: "6px 8px", borderRadius: "6px", background: "var(--dsw-alias-state-warn-tertiary)", fontSize: "12.5px", color: "var(--dsw-alias-label-primary)" }, children: [
|
|
900
|
+
"\u23F8 ",
|
|
901
|
+
data.lastCheck && data.lastCheck.passed === false ? tr(t, "run.paused.hint.checkfailed", "\u8FD9\u4E00\u6B65\u7684\u9A8C\u8BC1\u6CA1\u6709\u901A\u8FC7\uFF0C\u5DE5\u4F5C\u6D41\u505C\u5728\u8FD9\u91CC\u7B49\u4F60\u3002\u5DF2\u5B8C\u6210\u7684\u5DE5\u4F5C\u5168\u90E8\u4FDD\u7559\uFF1A\u70B9\u300C\u7EE7\u7EED\u300D\u8BA9\u6A21\u578B\u5E26\u7740\u5931\u8D25\u539F\u56E0\u91CD\u505A\uFF0C\u6216\u7528 /ralphflow-rewind \u56DE\u9000\u5230\u66F4\u65E9\u7684\u6B65\u9AA4\u3002") : tr(t, "run.paused.hint", "\u5DE5\u4F5C\u6D41\u5DF2\u6682\u505C\uFF08\u9A8C\u8BC1\u672A\u901A\u8FC7\u6216\u8FBE\u5230\u5931\u8D25\u4E0A\u9650\uFF09\u2014\u2014\u8FD9\u4E0D\u662F\u7EC8\u70B9\uFF1A\u4FEE\u590D\u95EE\u9898\u540E\u5373\u53EF\u7EE7\u7EED\uFF0C\u5DF2\u5B8C\u6210\u7684\u5DE5\u4F5C\u5168\u90E8\u4FDD\u7559\u3002"),
|
|
902
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: STYLE.actions, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
903
|
+
"button",
|
|
904
|
+
{
|
|
905
|
+
style: STYLE.btn("primary"),
|
|
906
|
+
onClick: () => {
|
|
907
|
+
window.dispatchEvent(new CustomEvent("ralphflow:command", { detail: { command: "/ralphflow-continue", autoSubmit: true } }));
|
|
908
|
+
},
|
|
909
|
+
children: [
|
|
910
|
+
"\u25B6 ",
|
|
911
|
+
tr(t, "run.resume", "\u7EE7\u7EED")
|
|
912
|
+
]
|
|
913
|
+
}
|
|
914
|
+
) })
|
|
915
|
+
] }) : null,
|
|
916
|
+
data.gate ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(GateCard, { gate: data.gate, t }) : null,
|
|
917
|
+
data.report ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ReportCard, { report: data.report, t }) : null
|
|
918
|
+
] });
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
// src/client/CommandCard.tsx
|
|
922
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
923
|
+
var STYLE2 = {
|
|
924
|
+
root: {
|
|
925
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
926
|
+
borderRadius: "10px",
|
|
927
|
+
background: "var(--dsw-alias-bg-layer-1)",
|
|
928
|
+
padding: "12px 14px",
|
|
929
|
+
margin: "6px 0",
|
|
930
|
+
fontSize: "13.5px",
|
|
931
|
+
lineHeight: 1.6
|
|
932
|
+
},
|
|
933
|
+
head: {
|
|
934
|
+
display: "flex",
|
|
935
|
+
alignItems: "center",
|
|
936
|
+
gap: "8px",
|
|
937
|
+
marginBottom: "8px"
|
|
938
|
+
},
|
|
939
|
+
commandName: {
|
|
940
|
+
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
|
|
941
|
+
fontSize: "12.5px",
|
|
942
|
+
color: "var(--dsw-alias-label-secondary)"
|
|
943
|
+
},
|
|
944
|
+
body: {
|
|
945
|
+
whiteSpace: "pre-wrap",
|
|
946
|
+
wordBreak: "break-word",
|
|
947
|
+
maxHeight: "320px",
|
|
948
|
+
overflowY: "auto",
|
|
949
|
+
fontSize: "13px",
|
|
950
|
+
color: "var(--dsw-alias-label-primary)"
|
|
951
|
+
}
|
|
952
|
+
};
|
|
953
|
+
var badgeStyle = (error, running) => ({
|
|
954
|
+
fontSize: "11px",
|
|
955
|
+
padding: "2px 8px",
|
|
956
|
+
borderRadius: "999px",
|
|
957
|
+
background: error ? "var(--dsw-alias-state-error-secondary)" : running ? "var(--dsw-alias-state-warn-tertiary)" : "var(--dsw-alias-state-business-tertiary)",
|
|
958
|
+
color: error ? "var(--dsw-alias-state-error-primary)" : running ? "var(--dsw-alias-state-warn-primary)" : "var(--dsw-alias-state-business-primary)",
|
|
959
|
+
fontWeight: 600,
|
|
960
|
+
flexShrink: 0,
|
|
961
|
+
whiteSpace: "nowrap"
|
|
962
|
+
});
|
|
963
|
+
function tr2(t, key, fallback) {
|
|
964
|
+
try {
|
|
965
|
+
const v = t?.(key);
|
|
966
|
+
return typeof v === "string" && v ? v : fallback;
|
|
967
|
+
} catch {
|
|
968
|
+
return fallback;
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
function RalphCommandCard({ node, t }) {
|
|
972
|
+
const data = node?.data;
|
|
973
|
+
if (!data || !data.command && !data.text) return null;
|
|
974
|
+
const isError = !!data.error;
|
|
975
|
+
const isRunning = !!data.running;
|
|
976
|
+
const disp = String(data.command ?? "").replace(/^ralphflow-/, "");
|
|
977
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: isError ? { ...STYLE2.root, borderColor: "var(--dsw-alias-state-error-secondary)" } : STYLE2.root, children: [
|
|
978
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: STYLE2.head, children: [
|
|
979
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: badgeStyle(isError, isRunning), children: "Ralph Flow" }),
|
|
980
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { ...STYLE2.commandName, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: `/${disp}` }),
|
|
981
|
+
isError ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { style: { marginLeft: "auto", fontSize: "11px", color: "var(--dsw-alias-state-error-primary)", flexShrink: 0 }, children: [
|
|
982
|
+
"\u26A0 ",
|
|
983
|
+
tr2(t, "command.error", "\u51FA\u9519")
|
|
984
|
+
] }) : null,
|
|
985
|
+
isRunning ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { style: { marginLeft: "auto", fontSize: "11px", color: "var(--dsw-alias-state-warn-primary)", flexShrink: 0 }, children: [
|
|
986
|
+
"\u23F3 ",
|
|
987
|
+
tr2(t, "command.running", "\u6267\u884C\u4E2D\u2026")
|
|
988
|
+
] }) : null
|
|
989
|
+
] }),
|
|
990
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: STYLE2.body, children: data.text ?? "" })
|
|
991
|
+
] });
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
// src/client/HeaderAction.tsx
|
|
995
|
+
var React2 = __toESM(require("react"), 1);
|
|
996
|
+
|
|
997
|
+
// src/client/snapshots.ts
|
|
998
|
+
var KEY2 = "ralphflow:run-snapshots";
|
|
999
|
+
var MAX_SNAPS = 20;
|
|
1000
|
+
var MAX_TEXT = 1500;
|
|
1001
|
+
var MAX_AGE_MS = 24 * 60 * 60 * 1e3;
|
|
1002
|
+
var cacheAt = 0;
|
|
1003
|
+
var cacheValue = {};
|
|
1004
|
+
function loadAll() {
|
|
1005
|
+
try {
|
|
1006
|
+
const raw = localStorage.getItem(KEY2);
|
|
1007
|
+
return raw ? JSON.parse(raw) : {};
|
|
1008
|
+
} catch {
|
|
1009
|
+
return {};
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
function persist2(all) {
|
|
1013
|
+
try {
|
|
1014
|
+
const entries = Object.entries(all).sort((a, b) => b[1].savedAt - a[1].savedAt).slice(0, MAX_SNAPS);
|
|
1015
|
+
localStorage.setItem(KEY2, JSON.stringify(Object.fromEntries(entries)));
|
|
1016
|
+
} catch {
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
function compactRunState(data) {
|
|
1020
|
+
const clip = (v) => typeof v === "string" && v.length > MAX_TEXT ? `${v.slice(0, MAX_TEXT)}\u2026` : v;
|
|
1021
|
+
const verdicts = Array.isArray(data.verdicts) ? data.verdicts.map((v) => ({ ...v, reasoning: clip(v.reasoning) })) : data.verdicts;
|
|
1022
|
+
const lastCheck = data.lastCheck && typeof data.lastCheck === "object" ? { ...data.lastCheck, reason: clip(data.lastCheck.reason) } : data.lastCheck;
|
|
1023
|
+
const report = data.report && typeof data.report === "object" ? { ...data.report, text: clip(data.report.text) } : data.report;
|
|
1024
|
+
return { ...data, verdicts, lastCheck, report };
|
|
1025
|
+
}
|
|
1026
|
+
function saveRunSnapshot(data) {
|
|
1027
|
+
try {
|
|
1028
|
+
const runId = String(data?.runId ?? "");
|
|
1029
|
+
if (!runId) return;
|
|
1030
|
+
const all = loadAll();
|
|
1031
|
+
all[runId] = { savedAt: Date.now(), state: compactRunState(data) };
|
|
1032
|
+
persist2(all);
|
|
1033
|
+
cacheAt = 0;
|
|
1034
|
+
} catch {
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
function loadRunSnapshots() {
|
|
1038
|
+
try {
|
|
1039
|
+
const now = Date.now();
|
|
1040
|
+
if (now - cacheAt < 1e3) return cacheValue;
|
|
1041
|
+
const all = loadAll();
|
|
1042
|
+
const out = {};
|
|
1043
|
+
for (const [runId, rec] of Object.entries(all)) {
|
|
1044
|
+
if (!rec?.state) continue;
|
|
1045
|
+
if (now - (rec.savedAt || 0) > MAX_AGE_MS) continue;
|
|
1046
|
+
out[runId] = rec.state;
|
|
1047
|
+
}
|
|
1048
|
+
cacheAt = now;
|
|
1049
|
+
cacheValue = out;
|
|
1050
|
+
return out;
|
|
1051
|
+
} catch {
|
|
1052
|
+
return {};
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
function isRunHiddenSnap(runId) {
|
|
1056
|
+
try {
|
|
1057
|
+
const raw = localStorage.getItem("ralphflow:hidden-runs");
|
|
1058
|
+
const set = raw ? JSON.parse(raw) : [];
|
|
1059
|
+
return set.includes(runId);
|
|
1060
|
+
} catch {
|
|
1061
|
+
return false;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
// src/client/http-state.ts
|
|
1066
|
+
var import_react = require("react");
|
|
1067
|
+
function checkTimeLeft(checkStartedAt, timeoutMs, now = Date.now()) {
|
|
1068
|
+
if (typeof checkStartedAt !== "number" || checkStartedAt <= 0 || typeof timeoutMs !== "number" || timeoutMs <= 0) return null;
|
|
1069
|
+
const elapsed = Math.max(0, now - checkStartedAt);
|
|
1070
|
+
const leftMs = Math.max(0, timeoutMs - elapsed);
|
|
1071
|
+
return { leftMs, ratio: Math.min(1, elapsed / timeoutMs), over: elapsed >= timeoutMs };
|
|
1072
|
+
}
|
|
1073
|
+
var snapshot = { instances: [], workflows: [], ts: 0 };
|
|
1074
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
1075
|
+
var started = false;
|
|
1076
|
+
function emit() {
|
|
1077
|
+
for (const l of [...listeners]) {
|
|
1078
|
+
try {
|
|
1079
|
+
l();
|
|
1080
|
+
} catch {
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
async function tick() {
|
|
1085
|
+
try {
|
|
1086
|
+
const res = await fetch("/ralphflow/instances", { cache: "no-store" });
|
|
1087
|
+
if (res.ok) {
|
|
1088
|
+
const data = await res.json();
|
|
1089
|
+
if (Array.isArray(data?.instances)) {
|
|
1090
|
+
const workflows = Array.isArray(data.workflows) ? data.workflows : snapshot.workflows;
|
|
1091
|
+
snapshot = { instances: data.instances, workflows, ts: Date.now() };
|
|
1092
|
+
try {
|
|
1093
|
+
registerWorkflowShortcutNames(workflows ?? []);
|
|
1094
|
+
} catch {
|
|
1095
|
+
}
|
|
1096
|
+
emit();
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
} catch {
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
function startHttpPolling(intervalMs = 2500) {
|
|
1103
|
+
if (started) return;
|
|
1104
|
+
started = true;
|
|
1105
|
+
void tick();
|
|
1106
|
+
const h = window.setInterval(() => void tick(), intervalMs);
|
|
1107
|
+
try {
|
|
1108
|
+
window.addEventListener("unload", () => clearInterval(h), { once: true });
|
|
1109
|
+
} catch {
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
function subscribe(cb) {
|
|
1113
|
+
listeners.add(cb);
|
|
1114
|
+
return () => {
|
|
1115
|
+
listeners.delete(cb);
|
|
1116
|
+
};
|
|
1117
|
+
}
|
|
1118
|
+
function getSnapshot() {
|
|
1119
|
+
return snapshot;
|
|
1120
|
+
}
|
|
1121
|
+
function useRalphHttpState() {
|
|
1122
|
+
return (0, import_react.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
1123
|
+
}
|
|
1124
|
+
function httpStateCache() {
|
|
1125
|
+
return snapshot;
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
// src/client/HeaderAction.tsx
|
|
1129
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1130
|
+
function tr3(t, key, fallback) {
|
|
1131
|
+
try {
|
|
1132
|
+
const v = t?.(key);
|
|
1133
|
+
return typeof v === "string" && v ? v : fallback;
|
|
1134
|
+
} catch {
|
|
1135
|
+
return fallback;
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
var NUM2 = { fontVariantNumeric: "tabular-nums" };
|
|
1139
|
+
function runFromJob(job) {
|
|
1140
|
+
try {
|
|
1141
|
+
const label = String(job?.label ?? "");
|
|
1142
|
+
if (!label.startsWith("ralphflow")) return null;
|
|
1143
|
+
const parts = label.split(/\s+/);
|
|
1144
|
+
const instId = parts[2] ?? "";
|
|
1145
|
+
if (!instId) return null;
|
|
1146
|
+
const m = /^ralphflow\s+\S+\s+(\S+)\s+(\S+)\s+fail=(\d+)( paused)?/.exec(String(job?.output ?? ""));
|
|
1147
|
+
const step = m?.[1] ?? "";
|
|
1148
|
+
const phase = m?.[2] === "CHECK" ? "check" : "do";
|
|
1149
|
+
const paused = !!m?.[4];
|
|
1150
|
+
const live = job.status === "running" || job.status === "stopping";
|
|
1151
|
+
const status = !live ? "done" : paused ? "failed" : phase === "check" ? "check" : "do";
|
|
1152
|
+
return {
|
|
1153
|
+
key: `job-${instId}`,
|
|
1154
|
+
runId: instId,
|
|
1155
|
+
workflow: parts[1] ?? "",
|
|
1156
|
+
task: "",
|
|
1157
|
+
steps: [],
|
|
1158
|
+
current: step ? { step, phase, failCount: Number(m?.[3] ?? 0) } : null,
|
|
1159
|
+
gate: null,
|
|
1160
|
+
stopReason: void 0,
|
|
1161
|
+
stepStartedAt: typeof job.startedAt === "number" ? job.startedAt : void 0,
|
|
1162
|
+
status
|
|
1163
|
+
};
|
|
1164
|
+
} catch {
|
|
1165
|
+
return null;
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
function runFromHttp(r) {
|
|
1169
|
+
const phase = r.current?.phase ?? "do";
|
|
1170
|
+
const status = r.paused ? "failed" : r.gate ? "gate" : phase === "check" ? "check" : "do";
|
|
1171
|
+
return {
|
|
1172
|
+
key: `http-${r.runId}`,
|
|
1173
|
+
runId: r.runId,
|
|
1174
|
+
workflow: r.workflow ?? "",
|
|
1175
|
+
task: r.task ?? "",
|
|
1176
|
+
steps: Array.isArray(r.steps) ? r.steps : [],
|
|
1177
|
+
current: r.current ? { step: r.current.step, phase: phase === "check" ? "check" : "do", failCount: r.current.failCount ?? 0 } : null,
|
|
1178
|
+
gate: r.gate ?? null,
|
|
1179
|
+
stopReason: r.paused ? "failed" : void 0,
|
|
1180
|
+
stepStartedAt: r.startedAt ? Date.parse(String(r.startedAt)) : void 0,
|
|
1181
|
+
status
|
|
1182
|
+
};
|
|
1183
|
+
}
|
|
1184
|
+
function collectRuns(nodes, jobs, http, ended) {
|
|
1185
|
+
const out = [];
|
|
1186
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1187
|
+
try {
|
|
1188
|
+
for (const r of Array.isArray(http) ? http : []) {
|
|
1189
|
+
if (!r?.runId) continue;
|
|
1190
|
+
seen.add(r.runId);
|
|
1191
|
+
out.push(runFromHttp(r));
|
|
1192
|
+
}
|
|
1193
|
+
} catch {
|
|
1194
|
+
}
|
|
1195
|
+
try {
|
|
1196
|
+
for (const e of Array.isArray(ended) ? ended : []) {
|
|
1197
|
+
const runId = String(e?.instId ?? "");
|
|
1198
|
+
if (!runId || seen.has(runId)) continue;
|
|
1199
|
+
const completed = e?.status === "completed";
|
|
1200
|
+
if (e?.status !== "completed" && e?.status !== "cancelled") continue;
|
|
1201
|
+
seen.add(runId);
|
|
1202
|
+
out.push({
|
|
1203
|
+
key: `end-${runId}`,
|
|
1204
|
+
runId,
|
|
1205
|
+
workflow: String(e?.workflow ?? ""),
|
|
1206
|
+
task: String(e?.task ?? ""),
|
|
1207
|
+
steps: [],
|
|
1208
|
+
current: null,
|
|
1209
|
+
gate: null,
|
|
1210
|
+
stopReason: completed ? "done" : "cancelled",
|
|
1211
|
+
status: completed ? "done" : "cancelled",
|
|
1212
|
+
reportPath: typeof e?.reportPath === "string" && e.reportPath ? e.reportPath : void 0
|
|
1213
|
+
});
|
|
1214
|
+
}
|
|
1215
|
+
} catch {
|
|
1216
|
+
}
|
|
1217
|
+
try {
|
|
1218
|
+
if (nodes) {
|
|
1219
|
+
const values = typeof nodes.values === "function" ? nodes.values() : [];
|
|
1220
|
+
for (const node of values) {
|
|
1221
|
+
if (!node || node.kind !== RALPHFLOW_RUN_KIND) continue;
|
|
1222
|
+
const d = node.data ?? {};
|
|
1223
|
+
const runId = String(d.runId ?? node.id ?? "");
|
|
1224
|
+
if (!runId || seen.has(runId)) continue;
|
|
1225
|
+
seen.add(runId);
|
|
1226
|
+
const status = d.detached ? "detached" : d.stopReason === "done" ? "done" : d.stopReason === "cancelled" ? "cancelled" : d.stopReason === "failed" ? "failed" : d.gate ? "gate" : d.current?.phase === "check" ? "check" : "do";
|
|
1227
|
+
out.push({
|
|
1228
|
+
key: String(node.key ?? node.id ?? ""),
|
|
1229
|
+
runId,
|
|
1230
|
+
workflow: d.workflow ?? "",
|
|
1231
|
+
task: d.task ?? "",
|
|
1232
|
+
steps: Array.isArray(d.steps) ? d.steps : [],
|
|
1233
|
+
current: d.current ?? null,
|
|
1234
|
+
gate: d.gate,
|
|
1235
|
+
stopReason: d.stopReason,
|
|
1236
|
+
stepStartedAt: typeof d.stepStartedAt === "number" ? d.stepStartedAt : void 0,
|
|
1237
|
+
status
|
|
1238
|
+
});
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
} catch {
|
|
1242
|
+
}
|
|
1243
|
+
try {
|
|
1244
|
+
for (const job of Array.isArray(jobs) ? jobs : []) {
|
|
1245
|
+
const r = runFromJob(job);
|
|
1246
|
+
if (!r || seen.has(r.runId)) continue;
|
|
1247
|
+
seen.add(r.runId);
|
|
1248
|
+
out.push(r);
|
|
1249
|
+
}
|
|
1250
|
+
} catch {
|
|
1251
|
+
}
|
|
1252
|
+
try {
|
|
1253
|
+
const snaps = loadRunSnapshots();
|
|
1254
|
+
for (const [runId, s] of Object.entries(snaps)) {
|
|
1255
|
+
if (seen.has(runId) || isRunHiddenSnap(runId)) continue;
|
|
1256
|
+
const status = s.detached ? "detached" : s.stopReason === "done" ? "done" : s.stopReason === "cancelled" ? "cancelled" : s.stopReason === "failed" ? "failed" : s.gate ? "gate" : s.current?.phase === "check" ? "check" : "do";
|
|
1257
|
+
out.push({
|
|
1258
|
+
key: `snap-${runId}`,
|
|
1259
|
+
runId,
|
|
1260
|
+
workflow: String(s.workflow ?? ""),
|
|
1261
|
+
task: String(s.task ?? ""),
|
|
1262
|
+
steps: Array.isArray(s.steps) ? s.steps : [],
|
|
1263
|
+
current: s.current ?? null,
|
|
1264
|
+
gate: s.gate,
|
|
1265
|
+
stopReason: s.stopReason,
|
|
1266
|
+
stepStartedAt: typeof s.stepStartedAt === "number" ? s.stepStartedAt : void 0,
|
|
1267
|
+
status
|
|
1268
|
+
});
|
|
1269
|
+
}
|
|
1270
|
+
} catch {
|
|
1271
|
+
}
|
|
1272
|
+
return out;
|
|
1273
|
+
}
|
|
1274
|
+
function statusColorOf(s) {
|
|
1275
|
+
return s === "done" ? "var(--dsw-alias-state-success-primary)" : s === "failed" ? "var(--dsw-alias-state-warn-primary)" : s === "gate" ? "var(--dsw-alias-state-warn-primary)" : s === "check" ? "var(--dsw-alias-state-business-primary)" : s === "cancelled" || s === "detached" ? "var(--dsw-alias-label-tertiary)" : "var(--dsw-alias-state-business-tertiary)";
|
|
1276
|
+
}
|
|
1277
|
+
var STATUS_KEY = {
|
|
1278
|
+
done: "status.done",
|
|
1279
|
+
cancelled: "status.cancelled",
|
|
1280
|
+
failed: "status.failed",
|
|
1281
|
+
gate: "status.gate",
|
|
1282
|
+
check: "status.check",
|
|
1283
|
+
do: "status.do",
|
|
1284
|
+
detached: "status.detached"
|
|
1285
|
+
};
|
|
1286
|
+
var STATUS_FALLBACK = {
|
|
1287
|
+
done: "\u5DF2\u5B8C\u6210",
|
|
1288
|
+
cancelled: "\u5DF2\u53D6\u6D88",
|
|
1289
|
+
failed: "\u5DF2\u6682\u505C",
|
|
1290
|
+
gate: "\u5F85\u5BA1\u67E5",
|
|
1291
|
+
check: "\u9A8C\u8BC1\u4E2D",
|
|
1292
|
+
do: "\u8FDB\u884C\u4E2D",
|
|
1293
|
+
detached: "\u5DF2\u8F6C\u4EA4"
|
|
1294
|
+
};
|
|
1295
|
+
var statusLabelOf = (t, s) => tr3(t, STATUS_KEY[s] ?? "status.do", STATUS_FALLBACK[s] ?? STATUS_FALLBACK.do);
|
|
1296
|
+
function trf2(t, key, fallback, params) {
|
|
1297
|
+
return tr3(t, key, fallback).replace(/\{(\w+)\}/g, (_, k) => params[k] != null ? String(params[k]) : `{${k}}`);
|
|
1298
|
+
}
|
|
1299
|
+
async function postAction(sessionId, payload) {
|
|
1300
|
+
try {
|
|
1301
|
+
const res = await fetch("/ralphflow/instances", {
|
|
1302
|
+
method: "POST",
|
|
1303
|
+
headers: { "Content-Type": "application/json" },
|
|
1304
|
+
body: JSON.stringify({ ...payload, sessionId: sessionId ?? "" })
|
|
1305
|
+
});
|
|
1306
|
+
let data = {};
|
|
1307
|
+
try {
|
|
1308
|
+
data = await res.json();
|
|
1309
|
+
} catch {
|
|
1310
|
+
}
|
|
1311
|
+
if (res.ok && data?.ok) return { ok: true, text: String(data.text ?? "\u5DF2\u63D0\u4EA4\u3002") };
|
|
1312
|
+
return { ok: false, text: String(data?.text ?? data?.error ?? (res.ok ? "\u8BF7\u6C42\u672A\u786E\u8BA4\u3002" : `HTTP ${res.status}`)) };
|
|
1313
|
+
} catch (e) {
|
|
1314
|
+
return { ok: false, text: e instanceof Error ? e.message : String(e) };
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
function formatElapsed2(ms) {
|
|
1318
|
+
const s = Math.max(0, Math.floor(ms / 1e3));
|
|
1319
|
+
if (s < 90) return `${s}s`;
|
|
1320
|
+
const m = Math.floor(s / 60);
|
|
1321
|
+
if (m < 60) return `${m}m`;
|
|
1322
|
+
return `${Math.floor(m / 60)}h${m % 60}m`;
|
|
1323
|
+
}
|
|
1324
|
+
function stepLabel(s) {
|
|
1325
|
+
const d = String(s?.desc ?? "").trim();
|
|
1326
|
+
return d.length > 0 ? d.length > 10 ? `${d.slice(0, 10)}\u2026` : d : String(s?.id ?? "?");
|
|
1327
|
+
}
|
|
1328
|
+
function MiniPipeline({ steps, current, status }) {
|
|
1329
|
+
if (!Array.isArray(steps) || steps.length === 0) return null;
|
|
1330
|
+
const curIdx = steps.findIndex((s) => current && s.id === current.step);
|
|
1331
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { display: "inline-flex", alignItems: "center", gap: "4px", minWidth: 0, overflow: "hidden" }, children: steps.slice(0, 6).map((s, i) => {
|
|
1332
|
+
const active = !!(current && s.id === current.step);
|
|
1333
|
+
const done = !active && curIdx >= 0 && i < curIdx;
|
|
1334
|
+
const color = done ? "var(--dsw-alias-state-success-primary)" : active ? statusColorOf(status) : "var(--dsw-alias-label-tertiary)";
|
|
1335
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1336
|
+
"span",
|
|
1337
|
+
{
|
|
1338
|
+
title: `${s.id ?? ""}${s.desc ? ` \u2014 ${s.desc}` : ""}`,
|
|
1339
|
+
style: { display: "inline-flex", alignItems: "center", gap: "3px", flexShrink: i > 2 ? 1 : 0, minWidth: 0 },
|
|
1340
|
+
children: [
|
|
1341
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "aria-hidden": "true", style: { fontSize: "10.5px", color }, children: done ? "\u2713" : active ? "\u25CF" : "\u25CB" }),
|
|
1342
|
+
active ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { fontSize: "11px", color, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: stepLabel(s) }) : null
|
|
1343
|
+
]
|
|
1344
|
+
},
|
|
1345
|
+
s.id ?? i
|
|
1346
|
+
);
|
|
1347
|
+
}) });
|
|
1348
|
+
}
|
|
1349
|
+
var style = {
|
|
1350
|
+
root: { position: "relative", display: "inline-block" },
|
|
1351
|
+
trigger: {
|
|
1352
|
+
display: "inline-flex",
|
|
1353
|
+
alignItems: "center",
|
|
1354
|
+
gap: "6px",
|
|
1355
|
+
padding: "4px 10px",
|
|
1356
|
+
borderRadius: "8px",
|
|
1357
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
1358
|
+
background: "transparent",
|
|
1359
|
+
color: "var(--dsw-alias-label-primary)",
|
|
1360
|
+
fontSize: "12.5px",
|
|
1361
|
+
cursor: "pointer",
|
|
1362
|
+
maxWidth: "420px"
|
|
1363
|
+
},
|
|
1364
|
+
menu: {
|
|
1365
|
+
position: "absolute",
|
|
1366
|
+
right: 0,
|
|
1367
|
+
top: "calc(100% + 6px)",
|
|
1368
|
+
width: "340px",
|
|
1369
|
+
maxHeight: "70vh",
|
|
1370
|
+
overflowY: "auto",
|
|
1371
|
+
background: "var(--dsw-alias-bg-layer-3)",
|
|
1372
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
1373
|
+
borderRadius: "10px",
|
|
1374
|
+
padding: "8px",
|
|
1375
|
+
zIndex: 50,
|
|
1376
|
+
boxShadow: "var(--dsw-shadow-lv2)"
|
|
1377
|
+
},
|
|
1378
|
+
row: {
|
|
1379
|
+
display: "flex",
|
|
1380
|
+
alignItems: "center",
|
|
1381
|
+
gap: "8px",
|
|
1382
|
+
padding: "7px 8px",
|
|
1383
|
+
borderRadius: "6px",
|
|
1384
|
+
fontSize: "12.5px",
|
|
1385
|
+
cursor: "pointer",
|
|
1386
|
+
border: "none",
|
|
1387
|
+
width: "100%",
|
|
1388
|
+
textAlign: "left",
|
|
1389
|
+
background: "transparent"
|
|
1390
|
+
}
|
|
1391
|
+
};
|
|
1392
|
+
var badgeWarn = {
|
|
1393
|
+
fontSize: "11px",
|
|
1394
|
+
lineHeight: 1,
|
|
1395
|
+
padding: "2px 8px",
|
|
1396
|
+
borderRadius: "999px",
|
|
1397
|
+
background: "var(--dsw-alias-state-warn-tertiary)",
|
|
1398
|
+
color: "var(--dsw-alias-state-warn-primary)",
|
|
1399
|
+
fontWeight: 600
|
|
1400
|
+
};
|
|
1401
|
+
var badgeFail = {
|
|
1402
|
+
fontSize: "11px",
|
|
1403
|
+
lineHeight: 1,
|
|
1404
|
+
padding: "2px 8px",
|
|
1405
|
+
borderRadius: "999px",
|
|
1406
|
+
background: "var(--dsw-alias-state-error-secondary)",
|
|
1407
|
+
color: "var(--dsw-alias-state-error-primary)",
|
|
1408
|
+
fontWeight: 600
|
|
1409
|
+
};
|
|
1410
|
+
function scrollToRun(runId) {
|
|
1411
|
+
try {
|
|
1412
|
+
const el = document.querySelector(`[data-ralphflow-run][data-runid="${CSS.escape(runId)}"]`);
|
|
1413
|
+
if (el) {
|
|
1414
|
+
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
1415
|
+
el.style.transition = "box-shadow .3s ease";
|
|
1416
|
+
el.style.boxShadow = "0 0 0 2px var(--dsw-alias-state-business-primary)";
|
|
1417
|
+
setTimeout(() => {
|
|
1418
|
+
try {
|
|
1419
|
+
el.style.boxShadow = "";
|
|
1420
|
+
} catch {
|
|
1421
|
+
}
|
|
1422
|
+
}, 1600);
|
|
1423
|
+
return true;
|
|
1424
|
+
}
|
|
1425
|
+
} catch {
|
|
1426
|
+
}
|
|
1427
|
+
return false;
|
|
1428
|
+
}
|
|
1429
|
+
function HeaderAction({ sessionId, useSession, useSessions, t }) {
|
|
1430
|
+
const [open, setOpen] = React2.useState(false);
|
|
1431
|
+
const rootRef = React2.useRef(null);
|
|
1432
|
+
const useSessionsSafe = useSessions ?? ((_sel) => void 0);
|
|
1433
|
+
const useSessionSafe = useSession ?? ((_sel) => void 0);
|
|
1434
|
+
const jobs = useSessionsSafe((s) => sessionId && s?.jobsBySession ? s.jobsBySession[sessionId] : void 0);
|
|
1435
|
+
const nodes = useSessionSafe((s) => s?.chat?.nodes);
|
|
1436
|
+
const http = useRalphHttpState();
|
|
1437
|
+
const runs = React2.useMemo(() => collectRuns(nodes, jobs, http.instances, http.recentEnded), [nodes, jobs, http.instances, http.recentEnded]);
|
|
1438
|
+
const [busyRun, setBusyRun] = React2.useState(null);
|
|
1439
|
+
const [actionMsg, setActionMsg] = React2.useState(null);
|
|
1440
|
+
const [returnFor, setReturnFor] = React2.useState(null);
|
|
1441
|
+
const [returnText, setReturnText] = React2.useState("");
|
|
1442
|
+
const [expanded, setExpanded] = React2.useState(null);
|
|
1443
|
+
const [confirmCancel, setConfirmCancel] = React2.useState(null);
|
|
1444
|
+
const returnRef = React2.useRef(null);
|
|
1445
|
+
const msgTimer = React2.useRef(null);
|
|
1446
|
+
const [, tick3] = React2.useReducer((n) => n + 1, 0);
|
|
1447
|
+
React2.useEffect(() => {
|
|
1448
|
+
if (!open) return;
|
|
1449
|
+
const h = setInterval(tick3, 5e3);
|
|
1450
|
+
return () => clearInterval(h);
|
|
1451
|
+
}, [open]);
|
|
1452
|
+
React2.useEffect(() => {
|
|
1453
|
+
if (!open) return;
|
|
1454
|
+
const onDown = (e) => {
|
|
1455
|
+
if (rootRef.current && !rootRef.current.contains(e.target)) setOpen(false);
|
|
1456
|
+
};
|
|
1457
|
+
const onKey = (e) => {
|
|
1458
|
+
if (e.key === "Escape") {
|
|
1459
|
+
setOpen(false);
|
|
1460
|
+
setReturnFor(null);
|
|
1461
|
+
setExpanded(null);
|
|
1462
|
+
}
|
|
1463
|
+
};
|
|
1464
|
+
document.addEventListener("mousedown", onDown);
|
|
1465
|
+
document.addEventListener("keydown", onKey);
|
|
1466
|
+
return () => {
|
|
1467
|
+
document.removeEventListener("mousedown", onDown);
|
|
1468
|
+
document.removeEventListener("keydown", onKey);
|
|
1469
|
+
};
|
|
1470
|
+
}, [open]);
|
|
1471
|
+
React2.useEffect(() => {
|
|
1472
|
+
if (returnFor) {
|
|
1473
|
+
try {
|
|
1474
|
+
returnRef.current?.focus();
|
|
1475
|
+
} catch {
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
}, [returnFor]);
|
|
1479
|
+
const runAction = async (runId, action, reason) => {
|
|
1480
|
+
if (busyRun) return;
|
|
1481
|
+
setBusyRun(runId);
|
|
1482
|
+
setActionMsg(null);
|
|
1483
|
+
const res = await postAction(sessionId, { action, runId, reason });
|
|
1484
|
+
setBusyRun(null);
|
|
1485
|
+
setActionMsg({ runId, ok: res.ok, text: res.text });
|
|
1486
|
+
if (msgTimer.current) window.clearTimeout(msgTimer.current);
|
|
1487
|
+
msgTimer.current = window.setTimeout(() => setActionMsg(null), 8e3);
|
|
1488
|
+
if (res.ok) {
|
|
1489
|
+
setReturnFor(null);
|
|
1490
|
+
setReturnText("");
|
|
1491
|
+
setExpanded(null);
|
|
1492
|
+
setConfirmCancel(null);
|
|
1493
|
+
} else if (action === "approve" || action === "resume") {
|
|
1494
|
+
window.dispatchEvent(new CustomEvent("ralphflow:command", {
|
|
1495
|
+
detail: { command: action === "approve" ? "/ralphflow-continue" : "/ralphflow-continue", autoSubmit: true }
|
|
1496
|
+
}));
|
|
1497
|
+
}
|
|
1498
|
+
};
|
|
1499
|
+
const toggleDetail = (r) => {
|
|
1500
|
+
setExpanded((cur) => cur === r.runId ? null : r.runId);
|
|
1501
|
+
setReturnFor(null);
|
|
1502
|
+
};
|
|
1503
|
+
const live = runs.filter((r) => r.status === "do" || r.status === "check");
|
|
1504
|
+
const waiting = runs.filter((r) => r.status === "gate" || r.status === "failed");
|
|
1505
|
+
const ended = runs.filter((r) => r.status === "done" || r.status === "cancelled" || r.status === "detached");
|
|
1506
|
+
const liveCount = live.length;
|
|
1507
|
+
const gateCount = waiting.filter((r) => r.status === "gate").length;
|
|
1508
|
+
const failCount = waiting.filter((r) => r.status === "failed").length;
|
|
1509
|
+
const primary = live[0] ?? waiting[0];
|
|
1510
|
+
const locateRun = (r) => {
|
|
1511
|
+
if (!scrollToRun(r.runId)) {
|
|
1512
|
+
window.dispatchEvent(new CustomEvent("ralphflow:command", { detail: { command: `/ralphflow-status ${r.runId || r.workflow}` } }));
|
|
1513
|
+
}
|
|
1514
|
+
};
|
|
1515
|
+
const VOTER_STATUS_KEYS = {
|
|
1516
|
+
pending: "voter.status.pending",
|
|
1517
|
+
running: "voter.status.running",
|
|
1518
|
+
passed: "voter.status.passed",
|
|
1519
|
+
failed: "voter.status.failed",
|
|
1520
|
+
infra_pending: "voter.status.infra_pending",
|
|
1521
|
+
infra_failed: "voter.status.infra_failed",
|
|
1522
|
+
cancelled: "voter.status.cancelled"
|
|
1523
|
+
};
|
|
1524
|
+
const VOTER_STATUS_FALLBACK = {
|
|
1525
|
+
pending: "\u6392\u961F\u4E2D",
|
|
1526
|
+
running: "\u8FD0\u884C\u4E2D",
|
|
1527
|
+
passed: "\u901A\u8FC7",
|
|
1528
|
+
failed: "\u672A\u901A\u8FC7",
|
|
1529
|
+
infra_pending: "\u73AF\u5883\u91CD\u8BD5",
|
|
1530
|
+
infra_failed: "\u73AF\u5883\u6545\u969C",
|
|
1531
|
+
cancelled: "\u5DF2\u53D6\u6D88"
|
|
1532
|
+
};
|
|
1533
|
+
const voterLabel = (t2, status) => tr3(t2, VOTER_STATUS_KEYS[status] ?? "voter.status.pending", VOTER_STATUS_FALLBACK[status] ?? status);
|
|
1534
|
+
function voterColor(status) {
|
|
1535
|
+
return status === "passed" ? "var(--dsw-alias-state-success-primary)" : status === "failed" || status === "infra_failed" ? "var(--dsw-alias-state-error-primary)" : status === "running" || status === "infra_pending" ? "var(--dsw-alias-state-business-primary)" : "var(--dsw-alias-label-tertiary)";
|
|
1536
|
+
}
|
|
1537
|
+
const renderRow = (r) => {
|
|
1538
|
+
const detail = Array.isArray(http.instances) ? http.instances.find((i) => String(i.runId) === r.runId) : void 0;
|
|
1539
|
+
const isExpanded = expanded === r.runId;
|
|
1540
|
+
const isBusy = busyRun === r.runId;
|
|
1541
|
+
const showMsg = actionMsg && actionMsg.runId === r.runId ? actionMsg : null;
|
|
1542
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { borderBottom: "1px solid var(--dsw-alias-border-l1)", paddingBottom: "4px", marginBottom: "4px" }, children: [
|
|
1543
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { ...style.row, cursor: "default", flexWrap: "wrap" }, children: [
|
|
1544
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "aria-hidden": "true", style: { width: 8, height: 8, borderRadius: "50%", background: statusColorOf(r.status), flexShrink: 0 } }),
|
|
1545
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: { color: "var(--dsw-alias-label-primary)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", minWidth: 0 }, children: [
|
|
1546
|
+
r.workflow,
|
|
1547
|
+
r.runId ? `\xB7${r.runId.slice(-4)}` : ""
|
|
1548
|
+
] }),
|
|
1549
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { marginLeft: "auto", fontSize: "11px", color: statusColorOf(r.status), flexShrink: 0 }, children: statusLabelOf(t, r.status) }),
|
|
1550
|
+
r.current && !r.stopReason ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: { fontSize: "11px", color: "var(--dsw-alias-label-tertiary)", width: "100%", ...NUM2 }, title: String(r.task ?? ""), children: [
|
|
1551
|
+
tr3(t, "drawer.step.prefix", "\u25B8"),
|
|
1552
|
+
stepLabel(r.steps.find((s) => s.id === r.current.step) ?? { id: r.current.step }),
|
|
1553
|
+
typeof r.stepStartedAt === "number" ? ` \xB7 ${formatElapsed2(Date.now() - r.stepStartedAt)}` : ""
|
|
1554
|
+
] }) : null,
|
|
1555
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(MiniPipeline, { steps: r.steps, current: r.current, status: r.status })
|
|
1556
|
+
] }),
|
|
1557
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", gap: "6px", paddingLeft: "16px", paddingBottom: "2px", flexWrap: "wrap" }, children: [
|
|
1558
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1559
|
+
"button",
|
|
1560
|
+
{
|
|
1561
|
+
type: "button",
|
|
1562
|
+
style: { fontSize: "11px", padding: "2px 8px", borderRadius: "6px", border: "1px solid var(--dsw-alias-border-l2)", background: "transparent", color: "var(--dsw-alias-label-secondary)", cursor: "pointer" },
|
|
1563
|
+
onClick: () => {
|
|
1564
|
+
setOpen(false);
|
|
1565
|
+
locateRun(r);
|
|
1566
|
+
},
|
|
1567
|
+
children: tr3(t, "drawer.locate", "\u5B9A\u4F4D\u5230\u5BF9\u8BDD")
|
|
1568
|
+
}
|
|
1569
|
+
),
|
|
1570
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1571
|
+
"button",
|
|
1572
|
+
{
|
|
1573
|
+
type: "button",
|
|
1574
|
+
style: { fontSize: "11px", padding: "2px 8px", borderRadius: "6px", border: "1px solid var(--dsw-alias-border-l2)", background: "transparent", color: "var(--dsw-alias-label-secondary)", cursor: "pointer" },
|
|
1575
|
+
onClick: () => toggleDetail(r),
|
|
1576
|
+
children: isExpanded ? tr3(t, "drawer.collapse", "\u6536\u8D77\u8BE6\u60C5") : tr3(t, "drawer.detail", "\u72B6\u6001\u8BE6\u60C5")
|
|
1577
|
+
}
|
|
1578
|
+
),
|
|
1579
|
+
r.status === "failed" && r.runId ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1580
|
+
"button",
|
|
1581
|
+
{
|
|
1582
|
+
type: "button",
|
|
1583
|
+
style: { fontSize: "11px", padding: "2px 8px", borderRadius: "6px", border: "1px solid var(--dsw-alias-border-l2)", background: "var(--dsw-alias-button-primary-fill)", color: "var(--dsw-alias-label-primary-foreground)", cursor: isBusy ? "wait" : "pointer", opacity: isBusy ? 0.6 : 1 },
|
|
1584
|
+
onClick: () => void runAction(r.runId, "resume"),
|
|
1585
|
+
children: [
|
|
1586
|
+
"\u25B6 ",
|
|
1587
|
+
tr3(t, "run.resume", "\u7EE7\u7EED")
|
|
1588
|
+
]
|
|
1589
|
+
}
|
|
1590
|
+
) : null,
|
|
1591
|
+
r.status === "gate" && r.runId ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
1592
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1593
|
+
"button",
|
|
1594
|
+
{
|
|
1595
|
+
type: "button",
|
|
1596
|
+
style: { fontSize: "11px", padding: "2px 8px", borderRadius: "6px", border: "1px solid var(--dsw-alias-border-l2)", background: "var(--dsw-alias-button-primary-fill)", color: "var(--dsw-alias-label-primary-foreground)", cursor: isBusy ? "wait" : "pointer", opacity: isBusy ? 0.6 : 1 },
|
|
1597
|
+
onClick: () => void runAction(r.runId, "approve"),
|
|
1598
|
+
children: [
|
|
1599
|
+
"\u2713 ",
|
|
1600
|
+
tr3(t, "run.approve", "\u901A\u8FC7")
|
|
1601
|
+
]
|
|
1602
|
+
}
|
|
1603
|
+
),
|
|
1604
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1605
|
+
"button",
|
|
1606
|
+
{
|
|
1607
|
+
type: "button",
|
|
1608
|
+
style: { fontSize: "11px", padding: "2px 8px", borderRadius: "6px", border: "1px solid var(--dsw-alias-border-l2)", background: "transparent", color: "var(--dsw-alias-label-secondary)", cursor: "pointer" },
|
|
1609
|
+
onClick: () => {
|
|
1610
|
+
setReturnFor((cur) => cur === r.runId ? null : r.runId);
|
|
1611
|
+
setExpanded(null);
|
|
1612
|
+
setConfirmCancel(null);
|
|
1613
|
+
},
|
|
1614
|
+
children: [
|
|
1615
|
+
"\u2717 ",
|
|
1616
|
+
tr3(t, "run.return", "\u6253\u56DE")
|
|
1617
|
+
]
|
|
1618
|
+
}
|
|
1619
|
+
)
|
|
1620
|
+
] }) : null,
|
|
1621
|
+
r.status !== "done" && r.status !== "cancelled" && r.status !== "detached" && r.runId ? confirmCancel === r.runId ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
1622
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1623
|
+
"button",
|
|
1624
|
+
{
|
|
1625
|
+
type: "button",
|
|
1626
|
+
style: { fontSize: "11px", padding: "2px 8px", borderRadius: "6px", border: "1px solid var(--dsw-alias-state-error-secondary)", background: "var(--dsw-alias-state-error-secondary)", color: "var(--dsw-alias-state-error-primary)", cursor: isBusy ? "wait" : "pointer", fontWeight: 600, opacity: isBusy ? 0.6 : 1 },
|
|
1627
|
+
onClick: () => void runAction(r.runId, "cancel"),
|
|
1628
|
+
children: tr3(t, "drawer.cancel.confirm", "\u786E\u8BA4\u53D6\u6D88\uFF1F")
|
|
1629
|
+
}
|
|
1630
|
+
),
|
|
1631
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1632
|
+
"button",
|
|
1633
|
+
{
|
|
1634
|
+
type: "button",
|
|
1635
|
+
style: { fontSize: "11px", padding: "2px 8px", borderRadius: "6px", border: "1px solid var(--dsw-alias-border-l2)", background: "transparent", color: "var(--dsw-alias-label-secondary)", cursor: "pointer" },
|
|
1636
|
+
onClick: () => setConfirmCancel(null),
|
|
1637
|
+
children: tr3(t, "drawer.cancel.back", "\u8FD4\u56DE")
|
|
1638
|
+
}
|
|
1639
|
+
)
|
|
1640
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1641
|
+
"button",
|
|
1642
|
+
{
|
|
1643
|
+
type: "button",
|
|
1644
|
+
style: { fontSize: "11px", padding: "2px 8px", borderRadius: "6px", border: "1px solid var(--dsw-alias-border-l2)", background: "transparent", color: "var(--dsw-alias-label-secondary)", cursor: "pointer" },
|
|
1645
|
+
onClick: () => {
|
|
1646
|
+
setConfirmCancel(r.runId);
|
|
1647
|
+
setReturnFor(null);
|
|
1648
|
+
},
|
|
1649
|
+
children: [
|
|
1650
|
+
"\u2715 ",
|
|
1651
|
+
tr3(t, "run.cancel.action", "\u53D6\u6D88")
|
|
1652
|
+
]
|
|
1653
|
+
}
|
|
1654
|
+
) : null
|
|
1655
|
+
] }),
|
|
1656
|
+
returnFor === r.runId ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { padding: "0 6px 6px 16px" }, children: [
|
|
1657
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1658
|
+
"textarea",
|
|
1659
|
+
{
|
|
1660
|
+
ref: returnRef,
|
|
1661
|
+
rows: 2,
|
|
1662
|
+
value: returnText,
|
|
1663
|
+
onChange: (e) => setReturnText(e.target.value),
|
|
1664
|
+
"aria-label": tr3(t, "run.return.opinion", "\u6253\u56DE\u610F\u89C1\uFF08\u4F1A\u968F\u547D\u4EE4\u53D1\u7ED9\u6A21\u578B\uFF09"),
|
|
1665
|
+
placeholder: tr3(t, "run.return.placeholder", "\u4F8B\u5982\uFF1A\u8FB9\u754C\u60C5\u51B5\u6CA1\u8986\u76D6\uFF0C\u6D4B\u8BD5\u5168\u6302\u4E86\uFF0C\u8BF7\u5148\u4FEE CI \u518D\u4EA4\u4ED8\u2026"),
|
|
1666
|
+
style: { width: "100%", boxSizing: "border-box", fontSize: "12px", padding: "6px 8px", borderRadius: "6px", border: "1px solid var(--dsw-alias-border-l2)", background: "var(--dsw-alias-bg-layer-2)", color: "var(--dsw-alias-label-primary)", resize: "vertical" }
|
|
1667
|
+
}
|
|
1668
|
+
),
|
|
1669
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", gap: "6px", alignItems: "center", marginTop: "6px" }, children: [
|
|
1670
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1671
|
+
"button",
|
|
1672
|
+
{
|
|
1673
|
+
type: "button",
|
|
1674
|
+
style: { fontSize: "11px", padding: "2px 10px", borderRadius: "6px", border: "1px solid var(--dsw-alias-border-l2)", background: "var(--dsw-alias-state-error-secondary)", color: "var(--dsw-alias-state-error-primary)", cursor: isBusy ? "wait" : "pointer", opacity: isBusy ? 0.6 : 1 },
|
|
1675
|
+
disabled: isBusy || !returnText.trim(),
|
|
1676
|
+
onClick: () => void runAction(r.runId, "return", returnText.trim()),
|
|
1677
|
+
children: tr3(t, "run.return.send", "\u53D1\u9001\u6253\u56DE")
|
|
1678
|
+
}
|
|
1679
|
+
),
|
|
1680
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1681
|
+
"button",
|
|
1682
|
+
{
|
|
1683
|
+
type: "button",
|
|
1684
|
+
style: { fontSize: "11px", padding: "2px 8px", borderRadius: "6px", border: "1px solid var(--dsw-alias-border-l2)", background: "transparent", color: "var(--dsw-alias-label-secondary)", cursor: "pointer" },
|
|
1685
|
+
onClick: () => {
|
|
1686
|
+
setReturnFor(null);
|
|
1687
|
+
setReturnText("");
|
|
1688
|
+
},
|
|
1689
|
+
children: tr3(t, "run.cancel.action", "\u53D6\u6D88")
|
|
1690
|
+
}
|
|
1691
|
+
)
|
|
1692
|
+
] })
|
|
1693
|
+
] }) : null,
|
|
1694
|
+
showMsg ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { padding: "2px 6px 4px 16px", fontSize: "11.5px", color: showMsg.ok ? "var(--dsw-alias-state-success-primary)" : "var(--dsw-alias-state-error-primary)" }, children: showMsg.ok ? `\u2713 ${tr3(t, "run.hint.approved", "\u5DF2\u63D0\u4EA4\uFF0C\u8FDB\u5EA6\u5C06\u5B9E\u65F6\u66F4\u65B0\u3002")}` : `\u26A0 ${showMsg.text}` }) : null,
|
|
1695
|
+
isExpanded ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { padding: "4px 8px 6px 16px", fontSize: "12px", color: "var(--dsw-alias-label-secondary)", lineHeight: 1.6 }, children: [
|
|
1696
|
+
detail?.owner ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { marginBottom: "4px" }, children: [
|
|
1697
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("strong", { style: { color: "var(--dsw-alias-label-primary)" }, children: [
|
|
1698
|
+
tr3(t, "drawer.owner", "\u5C5E\u4E3B"),
|
|
1699
|
+
"\uFF1A"
|
|
1700
|
+
] }),
|
|
1701
|
+
detail.owner === sessionId ? tr3(t, "drawer.owner.me", "\u672C\u4F1A\u8BDD") : String(detail.owner).slice(0, 8)
|
|
1702
|
+
] }) : null,
|
|
1703
|
+
r.task ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { marginBottom: "4px" }, children: [
|
|
1704
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("strong", { style: { color: "var(--dsw-alias-label-primary)" }, children: [
|
|
1705
|
+
tr3(t, "drawer.task", "\u4EFB\u52A1"),
|
|
1706
|
+
"\uFF1A"
|
|
1707
|
+
] }),
|
|
1708
|
+
" ",
|
|
1709
|
+
String(r.task)
|
|
1710
|
+
] }) : null,
|
|
1711
|
+
r.status === "gate" && detail?.gate ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { marginBottom: "4px", padding: "4px 8px", borderRadius: "6px", background: "var(--dsw-alias-state-warn-tertiary)" }, children: [
|
|
1712
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("strong", { style: { color: "var(--dsw-alias-label-primary)" }, children: [
|
|
1713
|
+
tr3(t, "drawer.gate.todo", "\u5BA1\u67E5\u8981\u6C42"),
|
|
1714
|
+
"\uFF1A"
|
|
1715
|
+
] }),
|
|
1716
|
+
" ",
|
|
1717
|
+
String(detail.gate.title ?? r.current?.step ?? ""),
|
|
1718
|
+
detail.gate.reason ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { marginTop: "2px" }, children: String(detail.gate.reason) }) : null,
|
|
1719
|
+
detail.gate.taskExcerpt ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { marginTop: "4px", whiteSpace: "pre-wrap", wordBreak: "break-word", maxHeight: "120px", overflowY: "auto", background: "var(--dsw-alias-bg-layer-2)", padding: "4px 6px", borderRadius: "4px" }, children: String(detail.gate.taskExcerpt) }) : null
|
|
1720
|
+
] }) : null,
|
|
1721
|
+
detail?.pauseReason ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { marginBottom: "4px" }, children: [
|
|
1722
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("strong", { style: { color: "var(--dsw-alias-label-primary)" }, children: [
|
|
1723
|
+
tr3(t, "drawer.pausereason", "\u6682\u505C\u539F\u56E0"),
|
|
1724
|
+
"\uFF1A"
|
|
1725
|
+
] }),
|
|
1726
|
+
" ",
|
|
1727
|
+
String(detail.pauseReason)
|
|
1728
|
+
] }) : null,
|
|
1729
|
+
detail?.lastFailureReason ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { marginBottom: "4px", maxHeight: "150px", overflowY: "auto" }, children: [
|
|
1730
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("strong", { style: { color: "var(--dsw-alias-label-primary)" }, children: [
|
|
1731
|
+
tr3(t, "drawer.failreason", "\u5931\u8D25\u539F\u56E0"),
|
|
1732
|
+
"\uFF1A"
|
|
1733
|
+
] }),
|
|
1734
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { whiteSpace: "pre-wrap", wordBreak: "break-word" }, children: String(detail.lastFailureReason) })
|
|
1735
|
+
] }) : null,
|
|
1736
|
+
detail?.current?.phase === "check" && !detail?.paused ? (() => {
|
|
1737
|
+
const tl = checkTimeLeft(detail.checkStartedAt, detail.timeoutMs);
|
|
1738
|
+
if (!tl) return null;
|
|
1739
|
+
const minutes = Math.max(1, Math.round((detail.timeoutMs ?? 0) / 6e4));
|
|
1740
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { marginBottom: "6px" }, children: [
|
|
1741
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", justifyContent: "space-between", gap: "8px", fontSize: "11px", marginBottom: "2px" }, children: [
|
|
1742
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { color: tl.over ? "var(--dsw-alias-state-error-primary)" : tl.ratio > 0.85 ? "var(--dsw-alias-state-warn-primary)" : "var(--dsw-alias-label-tertiary)" }, children: tl.over ? tr3(t, "drawer.timeout", "\u5DF2\u8D85\u65F6\uFF0C\u7B49\u5F85\u81EA\u52A8\u6682\u505C") : trf2(t, "drawer.timeleft", "\u5269\u4F59 {t}", { t: formatElapsed2(tl.leftMs) }) }),
|
|
1743
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { color: "var(--dsw-alias-label-tertiary)" }, children: trf2(t, "run.timeout.left", "\u8D85\u65F6\u4E0A\u9650 {min} \u5206\u949F", { min: minutes }) })
|
|
1744
|
+
] }),
|
|
1745
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { height: 4, borderRadius: 2, background: "var(--dsw-alias-bg-layer-2)", overflow: "hidden" }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
|
|
1746
|
+
height: "100%",
|
|
1747
|
+
width: `${Math.round(tl.ratio * 100)}%`,
|
|
1748
|
+
background: tl.over || tl.ratio > 0.85 ? "var(--dsw-alias-state-error-primary)" : tl.ratio > 0.6 ? "var(--dsw-alias-state-warn-primary)" : "var(--dsw-alias-state-business-primary)",
|
|
1749
|
+
transition: "width .6s ease"
|
|
1750
|
+
} }) })
|
|
1751
|
+
] });
|
|
1752
|
+
})() : null,
|
|
1753
|
+
Array.isArray(detail?.voterProgress) && detail.voterProgress.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { marginBottom: "4px" }, children: [
|
|
1754
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("strong", { style: { color: "var(--dsw-alias-label-primary)" }, children: [
|
|
1755
|
+
tr3(t, "drawer.voters", "\u9A8C\u8BC1\u8005"),
|
|
1756
|
+
"\uFF1A"
|
|
1757
|
+
] }),
|
|
1758
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { style: { margin: "2px 0 0", paddingLeft: "16px" }, children: detail.voterProgress.map((v, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("li", { style: { margin: "1px 0" }, children: [
|
|
1759
|
+
trf2(t, "run.verifier", "\u9A8C\u8BC1\u8005 {v}/{count}", { v: v.voter, count: detail.voterProgress.length }),
|
|
1760
|
+
" ",
|
|
1761
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { color: voterColor(v.status), fontWeight: 600 }, children: voterLabel(t, v.status) }),
|
|
1762
|
+
typeof v.startedAt === "number" && (v.status === "running" || v.status === "infra_pending") ? ` \xB7 ${formatElapsed2(Date.now() - v.startedAt)}` : "",
|
|
1763
|
+
v.model ? ` \xB7 ${v.model}` : "",
|
|
1764
|
+
v.check ? ` \u2014 ${v.check}` : ""
|
|
1765
|
+
] }, i)) })
|
|
1766
|
+
] }) : null
|
|
1767
|
+
] }) : null
|
|
1768
|
+
] }, r.key || r.runId);
|
|
1769
|
+
};
|
|
1770
|
+
if (runs.length === 0) {
|
|
1771
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { ref: rootRef, style: style.root, children: [
|
|
1772
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1773
|
+
"button",
|
|
1774
|
+
{
|
|
1775
|
+
type: "button",
|
|
1776
|
+
style: { ...style.trigger, color: "var(--dsw-alias-label-tertiary)", borderColor: "var(--dsw-alias-border-l1)", maxWidth: "220px" },
|
|
1777
|
+
"aria-expanded": open,
|
|
1778
|
+
"aria-haspopup": "dialog",
|
|
1779
|
+
"aria-label": tr3(t, "coldstart.aria", "Ralph Flow\uFF1A\u5DE5\u4F5C\u6D41\u5F15\u64CE\uFF08\u70B9\u51FB\u67E5\u770B\u4E0A\u624B\u5F15\u5BFC\uFF09"),
|
|
1780
|
+
onClick: () => setOpen((v) => !v),
|
|
1781
|
+
children: [
|
|
1782
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "aria-hidden": "true", style: { width: "8px", height: "8px", borderRadius: "50%", flexShrink: 0, background: "var(--dsw-alias-border-l2)" } }),
|
|
1783
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "Ralph Flow" })
|
|
1784
|
+
]
|
|
1785
|
+
}
|
|
1786
|
+
),
|
|
1787
|
+
open ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { id: "ralphflow-header-menu", role: "dialog", "aria-label": tr3(t, "coldstart.title", "\u5F00\u59CB\u4F7F\u7528 Ralph Flow"), style: { ...style.menu, width: "300px" }, children: [
|
|
1788
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { fontSize: "12.5px", fontWeight: 600, color: "var(--dsw-alias-label-primary)", padding: "4px 6px" }, children: [
|
|
1789
|
+
"\u{1F300} ",
|
|
1790
|
+
tr3(t, "coldstart.title", "\u5F00\u59CB\u4F7F\u7528 Ralph Flow")
|
|
1791
|
+
] }),
|
|
1792
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { fontSize: "12px", color: "var(--dsw-alias-label-secondary)", padding: "0 6px 8px", lineHeight: 1.55 }, children: tr3(t, "coldstart.desc", "DO\u2192CHECK \u72B6\u6001\u673A\u5DE5\u4F5C\u6D41\uFF1A\u6A21\u578B\u6267\u884C\u4EFB\u52A1\uFF0C\u72EC\u7ACB\u9A8C\u8BC1\u8005\u5BF9\u6297\u68C0\u67E5\uFF0C\u5931\u8D25\u81EA\u52A8\u8FD4\u5DE5\uFF0C\u5173\u952E\u6B65\u9AA4\u505C\u4E0B\u7B49\u4F60\u5BA1\u67E5\u3002") }),
|
|
1793
|
+
[
|
|
1794
|
+
{ cmd: "/loop ", label: tr3(t, "coldstart.try.loop", "/loop <\u4EFB\u52A1\u63CF\u8FF0> \u2014 \u8FED\u4EE3\u6267\u884C\u76F4\u5230\u9A8C\u8BC1\u901A\u8FC7"), autosubmit: false },
|
|
1795
|
+
{ cmd: "/ralphflow-list", label: tr3(t, "coldstart.try.list", "/ralphflow-list \u2014 \u67E5\u770B\u53EF\u7528\u5DE5\u4F5C\u6D41"), autosubmit: true }
|
|
1796
|
+
].map((item) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1797
|
+
"button",
|
|
1798
|
+
{
|
|
1799
|
+
type: "button",
|
|
1800
|
+
style: style.row,
|
|
1801
|
+
onClick: () => {
|
|
1802
|
+
setOpen(false);
|
|
1803
|
+
window.dispatchEvent(new CustomEvent("ralphflow:command", { detail: { command: item.cmd, autoSubmit: item.autosubmit } }));
|
|
1804
|
+
},
|
|
1805
|
+
children: [
|
|
1806
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "aria-hidden": "true", style: { color: "var(--dsw-alias-state-business-primary)", flexShrink: 0 }, children: "\u25B6" }),
|
|
1807
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", minWidth: 0, color: "var(--dsw-alias-label-primary)" }, children: item.label })
|
|
1808
|
+
]
|
|
1809
|
+
},
|
|
1810
|
+
item.cmd
|
|
1811
|
+
))
|
|
1812
|
+
] }) : null
|
|
1813
|
+
] });
|
|
1814
|
+
}
|
|
1815
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { ref: rootRef, style: style.root, children: [
|
|
1816
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1817
|
+
"button",
|
|
1818
|
+
{
|
|
1819
|
+
type: "button",
|
|
1820
|
+
style: { ...style.trigger, maxWidth: "300px" },
|
|
1821
|
+
"aria-expanded": open,
|
|
1822
|
+
"aria-haspopup": "dialog",
|
|
1823
|
+
"aria-controls": "ralphflow-header-menu",
|
|
1824
|
+
"aria-label": tr3(t, "header.aria", `Ralph Flow\uFF1A{live} \u8FD0\u884C\u4E2D\uFF0C{gate} \u5F85\u5BA1\u67E5\uFF0C{fail} \u5DF2\u6682\u505C`).replace("{live}", String(liveCount)).replace("{gate}", String(gateCount)).replace("{fail}", String(failCount)),
|
|
1825
|
+
onClick: () => setOpen((v) => !v),
|
|
1826
|
+
children: [
|
|
1827
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "aria-hidden": "true", style: { width: "8px", height: "8px", borderRadius: "50%", flexShrink: 0, background: statusColorOf(primary ? primary.status : "do") } }),
|
|
1828
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { flexShrink: 0 }, children: "Ralph Flow" }),
|
|
1829
|
+
primary && (primary.status === "do" || primary.status === "check") ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
1830
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(MiniPipeline, { steps: primary.steps, current: primary.current, status: primary.status }),
|
|
1831
|
+
typeof primary.stepStartedAt === "number" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { fontSize: "11px", color: "var(--dsw-alias-label-tertiary)", ...NUM2 }, children: formatElapsed2(Date.now() - primary.stepStartedAt) }) : null
|
|
1832
|
+
] }) : null,
|
|
1833
|
+
liveCount > 1 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: NUM2, children: liveCount }) : null,
|
|
1834
|
+
gateCount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: badgeWarn, children: gateCount }) : null,
|
|
1835
|
+
failCount > 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: badgeFail, children: failCount }) : null
|
|
1836
|
+
]
|
|
1837
|
+
}
|
|
1838
|
+
),
|
|
1839
|
+
open ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { id: "ralphflow-header-menu", role: "dialog", "aria-label": tr3(t, "header.list", "Ralph Flow \u4EFB\u52A1\u5217\u8868"), style: style.menu, children: [
|
|
1840
|
+
waiting.length + live.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
|
|
1841
|
+
waiting.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
1842
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { fontSize: "11px", fontWeight: 600, color: "var(--dsw-alias-state-warn-primary)", textTransform: "uppercase", letterSpacing: ".04em", padding: "2px 6px 6px" }, children: [
|
|
1843
|
+
tr3(t, "drawer.todo", "\u5F85\u5904\u7406"),
|
|
1844
|
+
waiting.length > 1 ? ` \xB7 ${waiting.length}` : ""
|
|
1845
|
+
] }),
|
|
1846
|
+
waiting.map(renderRow)
|
|
1847
|
+
] }) : null,
|
|
1848
|
+
live.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
1849
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { fontSize: "11px", fontWeight: 600, color: "var(--dsw-alias-label-tertiary)", textTransform: "uppercase", letterSpacing: ".04em", padding: waiting.length > 0 ? "10px 6px 6px" : "2px 6px 6px" }, children: [
|
|
1850
|
+
tr3(t, "drawer.live", "\u8FD0\u884C\u4E2D"),
|
|
1851
|
+
live.length > 1 ? ` \xB7 ${live.length}` : ""
|
|
1852
|
+
] }),
|
|
1853
|
+
live.map(renderRow)
|
|
1854
|
+
] }) : null
|
|
1855
|
+
] }) : null,
|
|
1856
|
+
ended.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { marginTop: live.length > 0 || waiting.length > 0 ? "10px" : 0 }, children: [
|
|
1857
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { fontSize: "11px", fontWeight: 600, color: "var(--dsw-alias-label-tertiary)", textTransform: "uppercase", letterSpacing: ".04em", padding: "2px 6px 6px" }, children: tr3(t, "drawer.ended", "\u5DF2\u7ED3\u675F\uFF08\u672C\u4F1A\u8BDD\uFF09") }),
|
|
1858
|
+
ended.slice(-6).map((r) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
|
|
1859
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1860
|
+
"button",
|
|
1861
|
+
{
|
|
1862
|
+
type: "button",
|
|
1863
|
+
style: style.row,
|
|
1864
|
+
title: r.status === "detached" ? tr3(t, "status.detached", "\u5DF2\u8F6C\u4EA4") : r.task,
|
|
1865
|
+
onClick: () => {
|
|
1866
|
+
setOpen(false);
|
|
1867
|
+
locateRun(r);
|
|
1868
|
+
},
|
|
1869
|
+
children: [
|
|
1870
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "aria-hidden": "true", style: { width: 8, height: 8, borderRadius: "50%", background: statusColorOf(r.status), flexShrink: 0 } }),
|
|
1871
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: { color: "var(--dsw-alias-label-primary)", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", minWidth: 0 }, children: [
|
|
1872
|
+
r.workflow,
|
|
1873
|
+
r.runId ? `\xB7${r.runId.slice(-4)}` : ""
|
|
1874
|
+
] }),
|
|
1875
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { marginLeft: "auto", fontSize: "11px", color: "var(--dsw-alias-label-tertiary)", flexShrink: 0 }, children: statusLabelOf(t, r.status) })
|
|
1876
|
+
]
|
|
1877
|
+
}
|
|
1878
|
+
),
|
|
1879
|
+
r.reportPath ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { paddingLeft: "16px", paddingBottom: "4px" }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
1880
|
+
"button",
|
|
1881
|
+
{
|
|
1882
|
+
type: "button",
|
|
1883
|
+
style: { fontSize: "11px", padding: "2px 8px", borderRadius: "6px", border: "1px solid var(--dsw-alias-border-l2)", background: "transparent", color: "var(--dsw-alias-state-business-primary)", cursor: "pointer" },
|
|
1884
|
+
onClick: () => {
|
|
1885
|
+
try {
|
|
1886
|
+
window.open(r.reportPath, "_blank");
|
|
1887
|
+
} catch {
|
|
1888
|
+
}
|
|
1889
|
+
},
|
|
1890
|
+
children: [
|
|
1891
|
+
"\u{1F4C4} ",
|
|
1892
|
+
tr3(t, "drawer.report", "\u62A5\u544A")
|
|
1893
|
+
]
|
|
1894
|
+
}
|
|
1895
|
+
) }) : null
|
|
1896
|
+
] }, r.key || r.runId)),
|
|
1897
|
+
ended.length > 6 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { fontSize: "11px", color: "var(--dsw-alias-label-tertiary)", padding: "0 8px 4px" }, children: trf2(t, "drawer.ended.more", "\u2026\u4EE5\u53CA\u66F4\u65E9\u7684 {n} \u6761", { n: ended.length - 6 }) }) : null
|
|
1898
|
+
] }) : null
|
|
1899
|
+
] }) : null
|
|
1900
|
+
] });
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
// src/client/notify.ts
|
|
1904
|
+
var NOTIFIED_KEY = "ralphflow:notified";
|
|
1905
|
+
function notifiedSet() {
|
|
1906
|
+
try {
|
|
1907
|
+
const raw = sessionStorage.getItem(NOTIFIED_KEY);
|
|
1908
|
+
return new Set(raw ? JSON.parse(raw) : []);
|
|
1909
|
+
} catch {
|
|
1910
|
+
return /* @__PURE__ */ new Set();
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
function markNotified(key) {
|
|
1914
|
+
try {
|
|
1915
|
+
const s = notifiedSet();
|
|
1916
|
+
s.add(key);
|
|
1917
|
+
sessionStorage.setItem(NOTIFIED_KEY, JSON.stringify([...s].slice(-200)));
|
|
1918
|
+
} catch {
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
function notificationsSupported() {
|
|
1922
|
+
try {
|
|
1923
|
+
return typeof window !== "undefined" && "Notification" in window;
|
|
1924
|
+
} catch {
|
|
1925
|
+
return false;
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
function primeNotifications() {
|
|
1929
|
+
try {
|
|
1930
|
+
if (!notificationsSupported()) return;
|
|
1931
|
+
if (Notification.permission === "default") {
|
|
1932
|
+
const ask = () => {
|
|
1933
|
+
try {
|
|
1934
|
+
void Notification.requestPermission();
|
|
1935
|
+
} catch {
|
|
1936
|
+
}
|
|
1937
|
+
window.removeEventListener("pointerdown", ask);
|
|
1938
|
+
window.removeEventListener("keydown", ask);
|
|
1939
|
+
};
|
|
1940
|
+
window.addEventListener("pointerdown", ask, { once: true });
|
|
1941
|
+
window.addEventListener("keydown", ask, { once: true });
|
|
1942
|
+
}
|
|
1943
|
+
} catch {
|
|
1944
|
+
}
|
|
1945
|
+
}
|
|
1946
|
+
function systemNotify(title, body, tag) {
|
|
1947
|
+
try {
|
|
1948
|
+
if (!notificationsSupported() || Notification.permission !== "granted") return;
|
|
1949
|
+
const n = new Notification(title, { body, tag });
|
|
1950
|
+
n.onclick = () => {
|
|
1951
|
+
try {
|
|
1952
|
+
window.focus();
|
|
1953
|
+
n.close();
|
|
1954
|
+
} catch {
|
|
1955
|
+
}
|
|
1956
|
+
};
|
|
1957
|
+
} catch {
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
var flashTimer;
|
|
1961
|
+
var flashCount = 0;
|
|
1962
|
+
function flashTitle(text) {
|
|
1963
|
+
try {
|
|
1964
|
+
if (flashTimer) return;
|
|
1965
|
+
const original = document.title;
|
|
1966
|
+
flashCount = 0;
|
|
1967
|
+
flashTimer = setInterval(() => {
|
|
1968
|
+
try {
|
|
1969
|
+
flashCount++;
|
|
1970
|
+
if (flashCount > 40 || document.hasFocus()) {
|
|
1971
|
+
stopFlashTitle(original);
|
|
1972
|
+
return;
|
|
1973
|
+
}
|
|
1974
|
+
document.title = flashCount % 2 === 1 ? `\u23F0 ${text}` : original;
|
|
1975
|
+
} catch {
|
|
1976
|
+
stopFlashTitle(original);
|
|
1977
|
+
}
|
|
1978
|
+
}, 1200);
|
|
1979
|
+
const onFocus = () => stopFlashTitle(original);
|
|
1980
|
+
window.addEventListener("focus", onFocus, { once: true });
|
|
1981
|
+
} catch {
|
|
1982
|
+
}
|
|
1983
|
+
}
|
|
1984
|
+
function stopFlashTitle(original) {
|
|
1985
|
+
try {
|
|
1986
|
+
if (flashTimer) {
|
|
1987
|
+
clearInterval(flashTimer);
|
|
1988
|
+
flashTimer = void 0;
|
|
1989
|
+
}
|
|
1990
|
+
document.title = original;
|
|
1991
|
+
} catch {
|
|
1992
|
+
}
|
|
1993
|
+
}
|
|
1994
|
+
function shouldNotifyRun(prevStopReason, nextStopReason, prevGate, nextGate) {
|
|
1995
|
+
const hasGate = !!nextGate;
|
|
1996
|
+
const gateArrived = hasGate && !prevGate;
|
|
1997
|
+
if (gateArrived) return "gate";
|
|
1998
|
+
if (nextStopReason === "failed" && prevStopReason !== "failed") return "paused";
|
|
1999
|
+
if (nextStopReason === "done" && prevStopReason !== "done") return "done";
|
|
2000
|
+
return null;
|
|
2001
|
+
}
|
|
2002
|
+
var CROSS_TAB_KEY = "ralphflow:notif-cross-tab";
|
|
2003
|
+
var CROSS_TAB_WINDOW_MS = 6e3;
|
|
2004
|
+
function crossTabSeen(key) {
|
|
2005
|
+
try {
|
|
2006
|
+
const raw = window.localStorage.getItem(CROSS_TAB_KEY);
|
|
2007
|
+
const map = raw ? JSON.parse(raw) : {};
|
|
2008
|
+
const now = Date.now();
|
|
2009
|
+
for (const k of Object.keys(map)) {
|
|
2010
|
+
if (now - map[k] > 6e4) delete map[k];
|
|
2011
|
+
}
|
|
2012
|
+
if (map[key] && now - map[key] < CROSS_TAB_WINDOW_MS) return true;
|
|
2013
|
+
map[key] = now;
|
|
2014
|
+
window.localStorage.setItem(CROSS_TAB_KEY, JSON.stringify(map));
|
|
2015
|
+
return false;
|
|
2016
|
+
} catch {
|
|
2017
|
+
return false;
|
|
2018
|
+
}
|
|
2019
|
+
}
|
|
2020
|
+
function notifyRunEvent(runId, workflow, kind) {
|
|
2021
|
+
try {
|
|
2022
|
+
const key = `${runId || "?"}:${kind}`;
|
|
2023
|
+
if (notifiedSet().has(key)) return;
|
|
2024
|
+
if (crossTabSeen(key)) return;
|
|
2025
|
+
markNotified(key);
|
|
2026
|
+
const label = kind === "gate" ? "\u5F85\u4F60\u5BA1\u67E5" : kind === "paused" ? "\u5DF2\u6682\u505C\uFF0C\u9700\u8981\u5904\u7406" : "\u5DF2\u5B8C\u6210 \u2713";
|
|
2027
|
+
const title = `\u{1F300} Ralph Flow \xB7 ${workflow || "\u5DE5\u4F5C\u6D41"} ${label}`;
|
|
2028
|
+
systemNotify(title, kind === "gate" ? "\u70B9\u51FB\u56DE\u5230\u5BF9\u8BDD\u5904\u7406\u5BA1\u67E5\u95E8\u3002" : "\u70B9\u51FB\u56DE\u5230\u5BF9\u8BDD\u67E5\u770B\u8BE6\u60C5\u3002", key);
|
|
2029
|
+
flashTitle(`Ralph Flow \xB7 ${label}`);
|
|
2030
|
+
} catch {
|
|
2031
|
+
}
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2034
|
+
// src/client/notify-watch.ts
|
|
2035
|
+
function initialWatchState() {
|
|
2036
|
+
return { runs: /* @__PURE__ */ new Map(), endedCursor: 0 };
|
|
2037
|
+
}
|
|
2038
|
+
function diffWatchState(prev2, payload) {
|
|
2039
|
+
const events = [];
|
|
2040
|
+
const runs = /* @__PURE__ */ new Map();
|
|
2041
|
+
for (const inst of Array.isArray(payload.instances) ? payload.instances : []) {
|
|
2042
|
+
const runId = String(inst?.runId ?? "");
|
|
2043
|
+
if (!runId) continue;
|
|
2044
|
+
const gate = inst.gate ?? null;
|
|
2045
|
+
const stopReason = inst.paused ? "failed" : void 0;
|
|
2046
|
+
runs.set(runId, { gate, stopReason });
|
|
2047
|
+
const before = prev2.runs.get(runId);
|
|
2048
|
+
if (before) {
|
|
2049
|
+
const kind = shouldNotifyRun(before.stopReason, stopReason, before.gate, gate);
|
|
2050
|
+
if (kind) events.push({ kind, runId, workflow: String(inst.workflow ?? "") });
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
const endedList = Array.isArray(payload.recentEnded) ? payload.recentEnded : [];
|
|
2054
|
+
let maxEnded = prev2.endedCursor;
|
|
2055
|
+
for (const e of endedList) {
|
|
2056
|
+
const endedAt = Number(e?.endedAt ?? 0);
|
|
2057
|
+
if (endedAt > maxEnded) maxEnded = endedAt;
|
|
2058
|
+
}
|
|
2059
|
+
const next = { runs, endedCursor: maxEnded };
|
|
2060
|
+
if (prev2.endedCursor === 0) {
|
|
2061
|
+
return { events: [], next };
|
|
2062
|
+
}
|
|
2063
|
+
for (const e of endedList) {
|
|
2064
|
+
const endedAt = Number(e?.endedAt ?? 0);
|
|
2065
|
+
if (e?.status !== "completed" || !endedAt || endedAt <= prev2.endedCursor) continue;
|
|
2066
|
+
const runId = String(e?.instId ?? "");
|
|
2067
|
+
if (!runId) continue;
|
|
2068
|
+
events.push({ kind: "done", runId, workflow: String(e?.workflow ?? "") });
|
|
2069
|
+
}
|
|
2070
|
+
return { events, next };
|
|
2071
|
+
}
|
|
2072
|
+
var prev = initialWatchState();
|
|
2073
|
+
var started2 = false;
|
|
2074
|
+
function tick2() {
|
|
2075
|
+
try {
|
|
2076
|
+
const payload = httpStateCache();
|
|
2077
|
+
const { events, next } = diffWatchState(prev, payload);
|
|
2078
|
+
prev = next;
|
|
2079
|
+
for (const ev of events) {
|
|
2080
|
+
try {
|
|
2081
|
+
notifyRunEvent(ev.runId, ev.workflow, ev.kind);
|
|
2082
|
+
} catch {
|
|
2083
|
+
}
|
|
2084
|
+
try {
|
|
2085
|
+
saveRunSnapshot({
|
|
2086
|
+
runId: ev.runId,
|
|
2087
|
+
workflow: ev.workflow,
|
|
2088
|
+
stopReason: ev.kind === "done" ? "done" : ev.kind === "paused" ? "failed" : void 0
|
|
2089
|
+
});
|
|
2090
|
+
} catch {
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
} catch {
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
function startNotifyWatch(intervalMs = 2500) {
|
|
2097
|
+
if (started2) return;
|
|
2098
|
+
started2 = true;
|
|
2099
|
+
tick2();
|
|
2100
|
+
const h = window.setInterval(() => void tick2(), intervalMs);
|
|
2101
|
+
try {
|
|
2102
|
+
window.addEventListener("unload", () => clearInterval(h), { once: true });
|
|
2103
|
+
} catch {
|
|
2104
|
+
}
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2107
|
+
// src/client/client.ts
|
|
2108
|
+
var name = "ralphflow-client";
|
|
2109
|
+
var inject = ["conversationEvents", "slots", "sessions", "locale"];
|
|
2110
|
+
var NS = "ralphflow";
|
|
2111
|
+
var zh = {
|
|
2112
|
+
"run.running": "\u8FDB\u884C\u4E2D",
|
|
2113
|
+
"run.check": "\u9A8C\u8BC1\u4E2D",
|
|
2114
|
+
"run.gate": "\u5F85\u5BA1\u67E5",
|
|
2115
|
+
"run.done": "\u5DF2\u5B8C\u6210",
|
|
2116
|
+
"run.failed": "\u5DF2\u5931\u8D25",
|
|
2117
|
+
"run.cancelled": "\u5DF2\u53D6\u6D88",
|
|
2118
|
+
"run.paused": "\u23F8 \u5DF2\u6682\u505C",
|
|
2119
|
+
"run.paused.hint": "\u5DE5\u4F5C\u6D41\u5DF2\u6682\u505C\uFF08\u9A8C\u8BC1\u672A\u901A\u8FC7\u6216\u8FBE\u5230\u5931\u8D25\u4E0A\u9650\uFF09\u2014\u2014\u8FD9\u4E0D\u662F\u7EC8\u70B9\uFF1A\u4FEE\u590D\u95EE\u9898\u540E\u5373\u53EF\u7EE7\u7EED\uFF0C\u5DF2\u5B8C\u6210\u7684\u5DE5\u4F5C\u5168\u90E8\u4FDD\u7559\u3002",
|
|
2120
|
+
"run.paused.hint.checkfailed": "\u8FD9\u4E00\u6B65\u7684\u9A8C\u8BC1\u6CA1\u6709\u901A\u8FC7\uFF0C\u5DE5\u4F5C\u6D41\u505C\u5728\u8FD9\u91CC\u7B49\u4F60\u3002\u5DF2\u5B8C\u6210\u7684\u5DE5\u4F5C\u5168\u90E8\u4FDD\u7559\uFF1A\u70B9\u300C\u7EE7\u7EED\u300D\u8BA9\u6A21\u578B\u5E26\u7740\u5931\u8D25\u539F\u56E0\u91CD\u505A\uFF0C\u6216\u7528 /ralphflow-rewind \u56DE\u9000\u5230\u66F4\u65E9\u7684\u6B65\u9AA4\u3002",
|
|
2121
|
+
"run.resume": "\u7EE7\u7EED",
|
|
2122
|
+
"run.approve": "\u901A\u8FC7",
|
|
2123
|
+
"run.return": "\u6253\u56DE",
|
|
2124
|
+
"run.return.opinion": "\u6253\u56DE\u610F\u89C1\uFF08\u4F1A\u968F\u547D\u4EE4\u53D1\u7ED9\u6A21\u578B\uFF09",
|
|
2125
|
+
"run.return.placeholder": "\u4F8B\u5982\uFF1A\u8FB9\u754C\u60C5\u51B5\u6CA1\u8986\u76D6\uFF0C\u6D4B\u8BD5\u5168\u6302\u4E86\uFF0C\u8BF7\u5148\u4FEE CI \u518D\u4EA4\u4ED8\u2026",
|
|
2126
|
+
"run.return.send": "\u53D1\u9001\u6253\u56DE",
|
|
2127
|
+
"run.cancel.action": "\u53D6\u6D88",
|
|
2128
|
+
"run.chip.tests": "\u6D4B\u8BD5\u6CA1\u8FC7\uFF0C\u8BF7\u5148\u4FEE\u590D",
|
|
2129
|
+
"run.chip.scope": "\u504F\u79BB\u9700\u6C42\u8303\u56F4\uFF0C\u8BF7\u5BF9\u7167\u539F\u59CB\u4EFB\u52A1",
|
|
2130
|
+
"run.chip.quality": "\u8D28\u91CF\u4E0D\u8FBE\u6807\uFF0C\u8BF7\u81EA\u67E5\u540E\u91CD\u65B0\u63D0\u4EA4",
|
|
2131
|
+
"run.hint.approve": "\u5DF2\u628A /ralphflow-continue \u586B\u5165\u8F93\u5165\u6846\u5E76\u5C1D\u8BD5\u53D1\u9001\u2014\u2014\u82E5\u672A\u53D1\u51FA\uFF0C\u6309\u56DE\u8F66\u5373\u6279\u51C6\u8FDB\u5165\u9A8C\u8BC1\u3002",
|
|
2132
|
+
"run.hint.return": "\u5DF2\u5728\u8F93\u5165\u6846\u586B\u5165 /ralphflow-reset\u2014\u2014\u5728\u540E\u9762\u8865\u4E0A\u4F60\u7684\u4FEE\u6539\u610F\u89C1\u518D\u56DE\u8F66\uFF0C\u6A21\u578B\u4F1A\u636E\u6B64\u8FD4\u5DE5\uFF08\u4E0D\u4F1A\u81EA\u52A8\u53D1\u9001\uFF09\u3002",
|
|
2133
|
+
"run.hint.returned": "\u6253\u56DE\u610F\u89C1\u5DF2\u53D1\u9001\uFF0C\u6A21\u578B\u4F1A\u6309\u4F60\u7684\u610F\u89C1\u8FD4\u5DE5\u672C\u6B65\u9AA4\u3002",
|
|
2134
|
+
"run.gate.requirement": "\u672C\u6B65\u8981\u6C42\uFF08\u5BA1\u6279\u6750\u6599\uFF09",
|
|
2135
|
+
"run.verifier": "\u9A8C\u8BC1\u8005 {v}/{count}",
|
|
2136
|
+
"run.voter.queued": "\u6392\u961F\u4E2D",
|
|
2137
|
+
"run.voter.running": "\u8FD0\u884C\u4E2D",
|
|
2138
|
+
"run.voter.retrying": "\u91CD\u8BD5\u4E2D",
|
|
2139
|
+
"run.votes": "\u72EC\u7ACB\u9A8C\u8BC1 \xB7 \u5DF2\u6536 {done}/{total} \u7968",
|
|
2140
|
+
"run.timeout.left": "\u8D85\u65F6\u4E0A\u9650 {min} \u5206\u949F",
|
|
2141
|
+
"run.timeout.near": "\u63A5\u8FD1\u8D85\u65F6\u4E0A\u9650\u2014\u2014\u8D85\u65F6\u540E\u81EA\u52A8\u6682\u505C\uFF0C\u5DF2\u6295\u51FA\u7684\u7968\u4FDD\u7559",
|
|
2142
|
+
"run.waiting.start": "\u6B63\u5728\u7B49\u5F85\u6A21\u578B\u5F00\u59CB\u6267\u884C\u2026{step}",
|
|
2143
|
+
"run.pass": "\u901A\u8FC7",
|
|
2144
|
+
"run.fail": "\u672A\u901A\u8FC7",
|
|
2145
|
+
"run.infra": "\u73AF\u5883\u6545\u969C",
|
|
2146
|
+
"run.check.passed": "\u9A8C\u8BC1\u901A\u8FC7",
|
|
2147
|
+
"run.check.failed": "\u9A8C\u8BC1\u672A\u901A\u8FC7",
|
|
2148
|
+
"run.rewind": "\u21A9 \u56DE\u9000 {from} \u2192 {to}",
|
|
2149
|
+
"run.report": "\u6700\u7EC8\u62A5\u544A",
|
|
2150
|
+
"run.elapsed.title": "\u5F53\u524D\u6B65\u9AA4\u5DF2\u8FD0\u884C\u65F6\u957F",
|
|
2151
|
+
"status.done": "\u5DF2\u5B8C\u6210",
|
|
2152
|
+
"status.cancelled": "\u5DF2\u53D6\u6D88",
|
|
2153
|
+
"status.failed": "\u5DF2\u6682\u505C",
|
|
2154
|
+
"status.gate": "\u5F85\u5BA1\u67E5",
|
|
2155
|
+
"status.check": "\u9A8C\u8BC1\u4E2D",
|
|
2156
|
+
"status.do": "\u8FDB\u884C\u4E2D",
|
|
2157
|
+
"status.detached": "\u5DF2\u8F6C\u4EA4",
|
|
2158
|
+
"run.hide": "\u5173\u95ED\u8FD9\u5F20\u5361\u7247",
|
|
2159
|
+
"run.detached": "\u6B64\u5DE5\u4F5C\u6D41\u5DF2\u5728\u53E6\u4E00\u4E2A\u4F1A\u8BDD\u7EE7\u7EED\u2014\u2014\u672C\u5361\u4EC5\u4FDD\u7559\u5386\u53F2\uFF0C\u4E0D\u518D\u66F4\u65B0\u3002",
|
|
2160
|
+
"drawer.ended.more": "\u2026\u4EE5\u53CA\u66F4\u65E9\u7684 {n} \u6761",
|
|
2161
|
+
"drawer.cancel.confirm": "\u786E\u8BA4\u53D6\u6D88\uFF1F",
|
|
2162
|
+
"drawer.cancel.back": "\u8FD4\u56DE",
|
|
2163
|
+
"drawer.report": "\u62A5\u544A",
|
|
2164
|
+
"drawer.timeleft": "\u5269\u4F59 {t}",
|
|
2165
|
+
"drawer.timeout": "\u5DF2\u8D85\u65F6\uFF0C\u7B49\u5F85\u81EA\u52A8\u6682\u505C",
|
|
2166
|
+
"header.aria": "Ralph Flow\uFF1A{live} \u8FD0\u884C\u4E2D\uFF0C{gate} \u5F85\u5BA1\u67E5\uFF0C{fail} \u5DF2\u6682\u505C",
|
|
2167
|
+
"header.list": "Ralph Flow \u4EFB\u52A1\u5217\u8868",
|
|
2168
|
+
"drawer.live": "\u8FDB\u884C\u4E2D",
|
|
2169
|
+
"drawer.todo": "\u5F85\u5904\u7406",
|
|
2170
|
+
"drawer.owner": "\u5C5E\u4E3B",
|
|
2171
|
+
"drawer.owner.me": "\u672C\u4F1A\u8BDD",
|
|
2172
|
+
"drawer.gate.todo": "\u5BA1\u67E5\u8981\u6C42",
|
|
2173
|
+
"voter.status.pending": "\u6392\u961F\u4E2D",
|
|
2174
|
+
"voter.status.running": "\u8FD0\u884C\u4E2D",
|
|
2175
|
+
"voter.status.passed": "\u901A\u8FC7",
|
|
2176
|
+
"voter.status.failed": "\u672A\u901A\u8FC7",
|
|
2177
|
+
"voter.status.infra_pending": "\u73AF\u5883\u91CD\u8BD5",
|
|
2178
|
+
"voter.status.infra_failed": "\u73AF\u5883\u6545\u969C",
|
|
2179
|
+
"voter.status.cancelled": "\u5DF2\u53D6\u6D88",
|
|
2180
|
+
"drawer.ended": "\u5DF2\u7ED3\u675F",
|
|
2181
|
+
"drawer.step.prefix": "\u25B8",
|
|
2182
|
+
"drawer.locate": "\u5B9A\u4F4D\u5230\u5BF9\u8BDD",
|
|
2183
|
+
"drawer.detail": "\u72B6\u6001\u8BE6\u60C5",
|
|
2184
|
+
"command.error": "\u51FA\u9519",
|
|
2185
|
+
"command.running": "\u6267\u884C\u4E2D\u2026",
|
|
2186
|
+
"run.hint.approved": "\u5DF2\u63D0\u4EA4\uFF0C\u8FDB\u5EA6\u5C06\u5B9E\u65F6\u66F4\u65B0\u3002",
|
|
2187
|
+
"drawer.collapse": "\u6536\u8D77\u8BE6\u60C5",
|
|
2188
|
+
"drawer.task": "\u4EFB\u52A1",
|
|
2189
|
+
"drawer.pausereason": "\u6682\u505C\u539F\u56E0",
|
|
2190
|
+
"drawer.failreason": "\u5931\u8D25\u539F\u56E0",
|
|
2191
|
+
"drawer.voters": "\u9A8C\u8BC1\u8005",
|
|
2192
|
+
"coldstart.aria": "Ralph Flow\uFF1A\u5DE5\u4F5C\u6D41\u5F15\u64CE\uFF08\u70B9\u51FB\u67E5\u770B\u4E0A\u624B\u5F15\u5BFC\uFF09",
|
|
2193
|
+
"coldstart.title": "\u5F00\u59CB\u4F7F\u7528 Ralph Flow",
|
|
2194
|
+
"coldstart.desc": "DO\u2192CHECK \u72B6\u6001\u673A\u5DE5\u4F5C\u6D41\uFF1A\u6A21\u578B\u6267\u884C\u4EFB\u52A1\uFF0C\u72EC\u7ACB\u9A8C\u8BC1\u8005\u5BF9\u6297\u68C0\u67E5\uFF0C\u5931\u8D25\u81EA\u52A8\u8FD4\u5DE5\uFF0C\u5173\u952E\u6B65\u9AA4\u505C\u4E0B\u7B49\u4F60\u5BA1\u67E5\u3002",
|
|
2195
|
+
"coldstart.try.loop": "/loop <\u4EFB\u52A1\u63CF\u8FF0> \u2014 \u8FED\u4EE3\u6267\u884C\u76F4\u5230\u9A8C\u8BC1\u901A\u8FC7",
|
|
2196
|
+
"coldstart.try.list": "/ralphflow-list \u2014 \u67E5\u770B\u53EF\u7528\u5DE5\u4F5C\u6D41"
|
|
2197
|
+
};
|
|
2198
|
+
var en = {
|
|
2199
|
+
"run.running": "Running",
|
|
2200
|
+
"run.check": "Verifying",
|
|
2201
|
+
"run.gate": "Pending review",
|
|
2202
|
+
"run.done": "Completed",
|
|
2203
|
+
"run.failed": "Failed",
|
|
2204
|
+
"run.cancelled": "Cancelled",
|
|
2205
|
+
"run.paused": "\u23F8 Paused",
|
|
2206
|
+
"run.paused.hint": "The workflow is paused (a check failed or the retry limit was reached) \u2014 this is not the end: fix the issue and continue; all completed work is preserved.",
|
|
2207
|
+
"run.paused.hint.checkfailed": "The check for this step did not pass and the workflow is waiting for you. All finished work is preserved: click Resume to let the model redo it with the failure reasons, or use /ralphflow-rewind to go back to an earlier step.",
|
|
2208
|
+
"run.resume": "Resume",
|
|
2209
|
+
"run.approve": "Approve",
|
|
2210
|
+
"run.return": "Send back",
|
|
2211
|
+
"run.return.opinion": "Change request (sent to the model with the command)",
|
|
2212
|
+
"run.return.placeholder": "e.g. edge cases not covered, tests are broken \u2014 fix CI first\u2026",
|
|
2213
|
+
"run.return.send": "Send back",
|
|
2214
|
+
"run.cancel.action": "Cancel",
|
|
2215
|
+
"run.chip.tests": "Tests failing \u2014 fix them first",
|
|
2216
|
+
"run.chip.scope": "Drifted off-scope \u2014 recheck the original task",
|
|
2217
|
+
"run.chip.quality": "Quality below bar \u2014 self-review and resubmit",
|
|
2218
|
+
"run.hint.approve": "/ralphflow-continue filled into the composer and submit attempted \u2014 press Enter if it was not sent to approve verification.",
|
|
2219
|
+
"run.hint.return": "/ralphflow-reset filled into the composer \u2014 append your change request, then press Enter yourself (it is never auto-sent).",
|
|
2220
|
+
"run.hint.returned": "Change request sent \u2014 the model will redo this step accordingly.",
|
|
2221
|
+
"run.gate.requirement": "Step requirement (review material)",
|
|
2222
|
+
"run.verifier": "Verifier {v}/{count}",
|
|
2223
|
+
"run.voter.queued": "Queued",
|
|
2224
|
+
"run.voter.running": "Running",
|
|
2225
|
+
"run.voter.retrying": "Retrying",
|
|
2226
|
+
"run.votes": "Independent check \xB7 {done}/{total} votes in",
|
|
2227
|
+
"run.timeout.left": "Timeout cap {min} min",
|
|
2228
|
+
"run.timeout.near": "Near the timeout cap \u2014 it will auto-pause; votes already cast are kept",
|
|
2229
|
+
"run.waiting.start": "Waiting for the model to start\u2026{step}",
|
|
2230
|
+
"run.pass": "PASS",
|
|
2231
|
+
"run.fail": "FAIL",
|
|
2232
|
+
"run.infra": "Infra error",
|
|
2233
|
+
"run.check.passed": "Check passed",
|
|
2234
|
+
"run.check.failed": "Check failed",
|
|
2235
|
+
"run.rewind": "\u21A9 Rewound {from} \u2192 {to}",
|
|
2236
|
+
"run.report": "Final report",
|
|
2237
|
+
"run.elapsed.title": "Time elapsed on current step",
|
|
2238
|
+
"status.done": "Done",
|
|
2239
|
+
"status.cancelled": "Cancelled",
|
|
2240
|
+
"status.failed": "Paused",
|
|
2241
|
+
"status.gate": "Pending review",
|
|
2242
|
+
"status.check": "Verifying",
|
|
2243
|
+
"status.do": "Running",
|
|
2244
|
+
"status.detached": "Handed off",
|
|
2245
|
+
"run.hide": "Dismiss this card",
|
|
2246
|
+
"run.detached": "This workflow continues in another session \u2014 this card keeps history only and will not update.",
|
|
2247
|
+
"drawer.ended.more": "\u2026and {n} earlier entries",
|
|
2248
|
+
"drawer.cancel.confirm": "Confirm cancel?",
|
|
2249
|
+
"drawer.cancel.back": "Back",
|
|
2250
|
+
"drawer.report": "Report",
|
|
2251
|
+
"drawer.timeleft": "{t} left",
|
|
2252
|
+
"drawer.timeout": "Timed out \u2014 auto-pausing",
|
|
2253
|
+
"header.aria": "Ralph Flow: {live} running, {gate} pending review, {fail} paused",
|
|
2254
|
+
"header.list": "Ralph Flow task list",
|
|
2255
|
+
"drawer.live": "In progress",
|
|
2256
|
+
"drawer.todo": "Needs attention",
|
|
2257
|
+
"drawer.owner": "Owner",
|
|
2258
|
+
"drawer.owner.me": "This session",
|
|
2259
|
+
"drawer.gate.todo": "Review requirement",
|
|
2260
|
+
"voter.status.pending": "Queued",
|
|
2261
|
+
"voter.status.running": "Running",
|
|
2262
|
+
"voter.status.passed": "Passed",
|
|
2263
|
+
"voter.status.failed": "Failed",
|
|
2264
|
+
"voter.status.infra_pending": "Infra retry",
|
|
2265
|
+
"voter.status.infra_failed": "Infra error",
|
|
2266
|
+
"voter.status.cancelled": "Cancelled",
|
|
2267
|
+
"drawer.ended": "Ended",
|
|
2268
|
+
"drawer.step.prefix": "\u25B8",
|
|
2269
|
+
"drawer.locate": "Locate in chat",
|
|
2270
|
+
"drawer.detail": "Status detail",
|
|
2271
|
+
"command.error": "Error",
|
|
2272
|
+
"command.running": "Running\u2026",
|
|
2273
|
+
"run.hint.approved": "Submitted \u2014 progress updates live.",
|
|
2274
|
+
"drawer.collapse": "Collapse details",
|
|
2275
|
+
"drawer.task": "Task",
|
|
2276
|
+
"drawer.pausereason": "Pause reason",
|
|
2277
|
+
"drawer.failreason": "Failure reason",
|
|
2278
|
+
"drawer.voters": "Verifiers",
|
|
2279
|
+
"coldstart.aria": "Ralph Flow: workflow engine (click for onboarding)",
|
|
2280
|
+
"coldstart.title": "Get started with Ralph Flow",
|
|
2281
|
+
"coldstart.desc": "DO\u2192CHECK state-machine workflows: the model does the work, independent verifiers adversarially check it, failures loop back automatically, and key steps pause for your review.",
|
|
2282
|
+
"coldstart.try.loop": "/loop <task> \u2014 iterate until verification passes",
|
|
2283
|
+
"coldstart.try.list": "/ralphflow-list \u2014 list available workflows"
|
|
2284
|
+
};
|
|
2285
|
+
function apply(ctx) {
|
|
2286
|
+
try {
|
|
2287
|
+
startHttpPolling();
|
|
2288
|
+
} catch {
|
|
2289
|
+
}
|
|
2290
|
+
try {
|
|
2291
|
+
startNotifyWatch();
|
|
2292
|
+
} catch {
|
|
2293
|
+
}
|
|
2294
|
+
try {
|
|
2295
|
+
primeNotifications();
|
|
2296
|
+
} catch {
|
|
2297
|
+
}
|
|
2298
|
+
ctx.conversationEvents.register(createDefinition());
|
|
2299
|
+
ctx.conversationEvents.register(createCommandDefinition());
|
|
2300
|
+
ctx.effect(() => ctx.locale.register(NS, { zh, en }), "ralphflow:dictionaries");
|
|
2301
|
+
ctx.slots.inject(
|
|
2302
|
+
"conversation.chat.node",
|
|
2303
|
+
() => ctx.slots.register({
|
|
2304
|
+
name: "conversation.chat.node",
|
|
2305
|
+
key: RALPHFLOW_RUN_KIND,
|
|
2306
|
+
locale: NS,
|
|
2307
|
+
inject: () => ({
|
|
2308
|
+
openFile: (path) => {
|
|
2309
|
+
try {
|
|
2310
|
+
window.open(path, "_blank");
|
|
2311
|
+
} catch {
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
})
|
|
2315
|
+
}, RalphRunCard)
|
|
2316
|
+
);
|
|
2317
|
+
ctx.slots.inject(
|
|
2318
|
+
"conversation.chat.node",
|
|
2319
|
+
() => ctx.slots.register({
|
|
2320
|
+
name: "conversation.chat.node",
|
|
2321
|
+
key: RALPHFLOW_COMMAND_KIND,
|
|
2322
|
+
locale: NS
|
|
2323
|
+
}, RalphCommandCard)
|
|
2324
|
+
);
|
|
2325
|
+
ctx.slots.inject(
|
|
2326
|
+
"conversation.session.header.actions",
|
|
2327
|
+
() => ctx.slots.register({
|
|
2328
|
+
name: "conversation.session.header.actions",
|
|
2329
|
+
id: "ralphflow-header",
|
|
2330
|
+
locale: NS,
|
|
2331
|
+
order: 100
|
|
2332
|
+
}, HeaderAction)
|
|
2333
|
+
);
|
|
2334
|
+
try {
|
|
2335
|
+
const findComposer = () => document.querySelector("textarea[data-dsh-composer]") ?? document.querySelector(".composer textarea") ?? document.querySelector("textarea");
|
|
2336
|
+
const onCommand = (e) => {
|
|
2337
|
+
const detail = e.detail;
|
|
2338
|
+
if (!detail?.command) return;
|
|
2339
|
+
const input = findComposer();
|
|
2340
|
+
if (!input) return;
|
|
2341
|
+
const setter = Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, "value")?.set;
|
|
2342
|
+
if (setter) setter.call(input, detail.command);
|
|
2343
|
+
else input.value = detail.command;
|
|
2344
|
+
input.focus();
|
|
2345
|
+
input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
2346
|
+
if (detail.autoSubmit === false) return;
|
|
2347
|
+
const opts = { key: "Enter", code: "Enter", keyCode: 13, bubbles: true, cancelable: true };
|
|
2348
|
+
input.dispatchEvent(new KeyboardEvent("keydown", opts));
|
|
2349
|
+
input.dispatchEvent(new KeyboardEvent("keyup", opts));
|
|
2350
|
+
};
|
|
2351
|
+
window.addEventListener("ralphflow:command", onCommand);
|
|
2352
|
+
ctx.effect(() => () => window.removeEventListener("ralphflow:command", onCommand), "ralphflow:command-bridge");
|
|
2353
|
+
} catch {
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
|
|
2357
|
+
return module.exports;
|
|
2358
|
+
}
|
|
2359
|
+
});
|
|
2360
|
+
|
|
2361
|
+
//# sourceMappingURL=client.js.map
|