ralphflow-dsh 2.1.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/lib/client/definition.d.ts +14 -0
- package/lib/client/definition.js +42 -0
- package/lib/client/index.d.ts +12 -0
- package/lib/client/index.js +16 -0
- package/lib/client/status-source.d.ts +13 -0
- package/lib/client/status-source.js +60 -0
- package/lib/client/status.d.ts +5 -0
- package/lib/client/status.js +122 -0
- package/lib/client.js +457 -0
- package/lib/engine.d.ts +10 -0
- package/lib/engine.js +78 -3
- package/lib/index.js +72 -14
- package/lib/message-source.d.ts +12 -3
- package/lib/status-contract.d.ts +46 -0
- package/lib/status-contract.js +58 -0
- package/lib/status-service.d.ts +18 -0
- package/lib/status-service.js +86 -0
- package/lib/typert.d.ts +3 -0
- package/lib/typert.js +6 -0
- package/package.json +66 -13
package/lib/index.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
import fs from "node:fs";
|
|
8
8
|
import { toolPairingBalancedAfter } from "@deepseek-ai/dsh-compaction";
|
|
9
9
|
import { createUserMessage, boundContextSummary } from "@deepseek-ai/dsh-llm";
|
|
10
|
+
import { WorkflowStatusService } from "./status-service.js";
|
|
10
11
|
import { RALPHFLOW_SOURCE_KIND } from "./message-source.js";
|
|
11
12
|
import { createEngine, listWorkflowsIn } from "./engine.js";
|
|
12
13
|
import { createResetSurface } from "./reset.js";
|
|
@@ -128,22 +129,18 @@ export function apply(ctx) {
|
|
|
128
129
|
* · {@link deliverDirective} **指令** = 要模型干活(DO / 命令转达 / 交卷提醒)→ `agent.steer`;
|
|
129
130
|
* · {@link deliverNotice} **播报** = 给人看的记录(验证进度、判定、暂停/完成)→ 直接 append。
|
|
130
131
|
*
|
|
131
|
-
*
|
|
132
|
-
* user
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* 这正是 dsh 自己的做法:`dsh-agent` 的 modelSwitchNotice 就用
|
|
136
|
-
* `{kind:"plugin", plugin:"model-selection", form:"notice", summary: boundContextSummary(...)}`。
|
|
137
|
-
*
|
|
138
|
-
* 所以:**凡是要让用户看见的播报,都必须带 summary**;不带 summary 的只适合纯内部管道。
|
|
132
|
+
* `source.form` 决定 context 内容的展开方式,不决定 Chat 是否收录这一行:
|
|
133
|
+
* 非 user 来源的普通 context 会整行过滤。本包客户端把带 notice + summary 的 append
|
|
134
|
+
* 日志另投影为会话级 `ralphflow-notice` 节点,才让人类看到记录。
|
|
135
|
+
* summary 是默认可读的摘要;没有 summary 的内部指令不匹配该客户端 Definition。
|
|
139
136
|
* {@link buildMessage} 就是这个 source 的唯一构造点。
|
|
140
137
|
*/
|
|
141
|
-
const buildMessage = (text, summary) => {
|
|
138
|
+
const buildMessage = (text, summary, uiRef) => {
|
|
142
139
|
const brief = typeof summary === "string" ? summary.trim() : "";
|
|
143
140
|
const source = brief
|
|
144
141
|
? { kind: RALPHFLOW_SOURCE_KIND, form: "notice", summary: boundContextSummary(brief) }
|
|
145
142
|
: { kind: RALPHFLOW_SOURCE_KIND };
|
|
146
|
-
return createUserMessage({ content: [{ type: "text", text }], source });
|
|
143
|
+
return createUserMessage({ content: [{ type: "text", text }], source: { ...source, ...(uiRef ? { uiRef } : {}) } });
|
|
147
144
|
};
|
|
148
145
|
/**
|
|
149
146
|
* 去重护栏(只给**命令指令**路径用;引擎自驱投递传 `dedupe:false` 跳过)。命中返回 true。
|
|
@@ -253,8 +250,8 @@ export function apply(ctx) {
|
|
|
253
250
|
* `dsh-agent-loop` 的回合循环在 `turnEnds && inbox.nextStep.length > 0` 时**继续跑下一步**,
|
|
254
251
|
* 所以它照样把正在收尾的回合续上 —— 而且收件箱里的东西在**被 claim 之前不进可见面**
|
|
255
252
|
* (客户端 `inbox-definition` 的 `publication: () => "none"`),用户时间线上不会立刻多一行。
|
|
256
|
-
* · 直接 append
|
|
257
|
-
*
|
|
253
|
+
* · 直接 append 则两件事同时成立:立刻成为模型可见面节点(本包客户端另外投影为
|
|
254
|
+
* 用户可见的私有 Chat 节点),且**完全不碰驱动器**(不唤醒、不续回合)。它还天然满足「模型在下一回合
|
|
258
255
|
* 能看到它」与「仍被 reset 整段遮蔽」(reset 的 `sourceEventSeqs` 取的是可见面全部节点)。
|
|
259
256
|
*/
|
|
260
257
|
const deliverNotice = (sessionId, text, summary, opts) => {
|
|
@@ -265,7 +262,7 @@ export function apply(ctx) {
|
|
|
265
262
|
if (deduped(sessionId, text, opts))
|
|
266
263
|
return true;
|
|
267
264
|
const session = sessionOf(sessionId, agent);
|
|
268
|
-
const msg = buildMessage(text, summary);
|
|
265
|
+
const msg = buildMessage(text, summary, opts?.uiRef);
|
|
269
266
|
if (canAppendNoticeNow(session)) {
|
|
270
267
|
// 先落挂起的历史播报,再落这一条 —— 保持时间线顺序
|
|
271
268
|
flushNotices(sessionId);
|
|
@@ -305,12 +302,29 @@ export function apply(ctx) {
|
|
|
305
302
|
* 不到 / 历史列表永远空 / doctor 看不见残留」的同一个根因。
|
|
306
303
|
*/
|
|
307
304
|
const engines = new Map();
|
|
305
|
+
const statusListeners = new Set();
|
|
306
|
+
let statusQueued = false;
|
|
307
|
+
const statusChanged = () => {
|
|
308
|
+
if (statusQueued)
|
|
309
|
+
return;
|
|
310
|
+
statusQueued = true;
|
|
311
|
+
queueMicrotask(() => {
|
|
312
|
+
statusQueued = false;
|
|
313
|
+
for (const listener of statusListeners) {
|
|
314
|
+
try {
|
|
315
|
+
listener();
|
|
316
|
+
}
|
|
317
|
+
catch { }
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
};
|
|
308
321
|
const ports = {
|
|
309
322
|
// 投递分两类(判据 1):指令 = 唤醒(DO / 命令转达 / 交卷提醒),播报 = 只记录不唤醒。
|
|
310
323
|
// 每个调用点都必须显式选一个 —— 端口名就是分类,代码里一眼看得出(见 docs/v2/delivery-classification.md
|
|
311
324
|
// 与 scripts/delivery-classification-test.mjs 的静态审计)。
|
|
312
325
|
deliverDirective,
|
|
313
326
|
deliverNotice,
|
|
327
|
+
statusChanged,
|
|
314
328
|
/** 把挂起的播报在**安全边界**补齐(reset 门在整段替换前先调一次:让替换把它们一并遮蔽) */
|
|
315
329
|
flushNotices,
|
|
316
330
|
verify: (req) => runVerifier({ ctx }, req),
|
|
@@ -363,6 +377,48 @@ export function apply(ctx) {
|
|
|
363
377
|
}
|
|
364
378
|
return e;
|
|
365
379
|
};
|
|
380
|
+
// Optional outside web: headless/test compositions keep the same workflow behavior.
|
|
381
|
+
ctx.inject(["typert"], (remoteCtx) => {
|
|
382
|
+
const terminalRefs = new WeakMap();
|
|
383
|
+
new WorkflowStatusService(remoteCtx, {
|
|
384
|
+
subscribe(listener) { statusListeners.add(listener); return () => statusListeners.delete(listener); },
|
|
385
|
+
async read(session) {
|
|
386
|
+
// Viewing status never runs restore or registers skills / sends a notice.
|
|
387
|
+
const key = session.header.cwd || workspace;
|
|
388
|
+
const engine = engines.get(key) ?? createEngine(key, ports);
|
|
389
|
+
const active = engine.uiStatus(session.id);
|
|
390
|
+
if (active.status && engine.readState(active.status.id)?.active)
|
|
391
|
+
return active;
|
|
392
|
+
let cached = terminalRefs.get(session);
|
|
393
|
+
if (!cached || cached.seq !== session.seq) {
|
|
394
|
+
const query = ctx.get("sessionQuery");
|
|
395
|
+
if (!query)
|
|
396
|
+
return active;
|
|
397
|
+
const observedSeq = session.seq;
|
|
398
|
+
const log = await query.readSession(session.id);
|
|
399
|
+
let ref;
|
|
400
|
+
for (const event of log.events) {
|
|
401
|
+
if (event.seq < log.inheritedEventCount || event.type !== "user/message" || event.surfaceOp !== "append"
|
|
402
|
+
|| event.data.source.kind !== RALPHFLOW_SOURCE_KIND)
|
|
403
|
+
continue;
|
|
404
|
+
const candidate = event.data.source.uiRef;
|
|
405
|
+
if (candidate?.v === 1 && (candidate.ended === "done" || candidate.ended === "cancelled"))
|
|
406
|
+
ref = candidate;
|
|
407
|
+
}
|
|
408
|
+
cached = { seq: observedSeq, ref };
|
|
409
|
+
terminalRefs.set(session, cached);
|
|
410
|
+
}
|
|
411
|
+
// A new active run may have landed while the cold read awaited persistence.
|
|
412
|
+
const current = engine.uiStatus(session.id);
|
|
413
|
+
const terminal = cached.ref ? engine.uiReport(cached.ref) : null;
|
|
414
|
+
// A residual from an older archive failure must not cover a newer completed run.
|
|
415
|
+
if (current.status && (engine.readState(current.status.id)?.active || !terminal
|
|
416
|
+
|| Date.parse(current.status.updatedAt) >= Date.parse(terminal.updatedAt)))
|
|
417
|
+
return current;
|
|
418
|
+
return { status: terminal, error: current.error ?? (cached.ref && !terminal ? "本次运行的报告暂不可读取,请检查报告文件。" : null) };
|
|
419
|
+
},
|
|
420
|
+
});
|
|
421
|
+
});
|
|
366
422
|
/**
|
|
367
423
|
* 只查**已存在**的引擎:会话事件是高频路径,不能为了它给每个会话凭空建引擎
|
|
368
424
|
* (没有引擎 = 该工作区没有活跃实例,也就没有需要提醒/捕获的东西)。
|
|
@@ -382,6 +438,8 @@ export function apply(ctx) {
|
|
|
382
438
|
const sid = s?.id;
|
|
383
439
|
if (!sid || !e || typeof e !== "object")
|
|
384
440
|
return;
|
|
441
|
+
if (e.type === "user/message" && e.data?.source?.uiRef)
|
|
442
|
+
statusChanged();
|
|
385
443
|
if (deferredNotices.has(sid))
|
|
386
444
|
queueMicrotask(() => { try {
|
|
387
445
|
flushNotices(sid);
|
|
@@ -426,7 +484,7 @@ export function apply(ctx) {
|
|
|
426
484
|
log("warn", "turn_stopping_failed", { sessionId: sid, error: e instanceof Error ? e.message : String(e) });
|
|
427
485
|
return;
|
|
428
486
|
}
|
|
429
|
-
//
|
|
487
|
+
// 本包客户端以 notice + summary 匹配播报,再由私有节点绕过普通 context 的过滤
|
|
430
488
|
if (!verdict.message)
|
|
431
489
|
return;
|
|
432
490
|
if (!verdict.remind) {
|
package/lib/message-source.d.ts
CHANGED
|
@@ -9,17 +9,26 @@
|
|
|
9
9
|
* 只按**当前** dsh 的这套写法写,不为任何更老的 dsh 留分支 —— dsh 的破坏性改动是常态,
|
|
10
10
|
* 我们的立场是跟着最新版走(作者定案)。
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
* notice
|
|
14
|
-
*
|
|
12
|
+
* Chat 可见性受 kind 过滤控制:非 user 来源先成为 context,普通 context 整行丢弃。
|
|
13
|
+
* `form: "notice"` + summary 只控制已可见 context 的展开,不能绕过过滤。
|
|
14
|
+
* 本包客户端另注册 `ralphflow-notice` 私有节点与渲染器,读取 append 日志并显式定位
|
|
15
|
+
* 会话级;它决定播报在 Chat 可见,reset 的模型面替换不会抹掉这条人类记录。
|
|
15
16
|
*/
|
|
16
17
|
import type { ContextFormed } from "@deepseek-ai/dsh-llm";
|
|
17
18
|
declare module "@deepseek-ai/dsh-llm" {
|
|
18
19
|
interface MessageSourceMap {
|
|
19
20
|
ralphflow: {
|
|
20
21
|
kind: "ralphflow";
|
|
22
|
+
uiRef?: WorkflowUiRef;
|
|
21
23
|
} & ContextFormed;
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
/** 本插件消息的来源 kind。用户可见的播报另带 `form: "notice"` + `summary`。 */
|
|
25
27
|
export declare const RALPHFLOW_SOURCE_KIND: "ralphflow";
|
|
28
|
+
/** Index on existing terminal notices; never changes model content or sends another event. */
|
|
29
|
+
export interface WorkflowUiRef {
|
|
30
|
+
v: 1;
|
|
31
|
+
runId: string;
|
|
32
|
+
reportRef: string;
|
|
33
|
+
ended: "done" | "cancelled";
|
|
34
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { InvocationDescriptor, RemoteStream, TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol";
|
|
2
|
+
export type WorkflowStage = "executing" | "verifying" | "gate" | "paused" | "switching" | "done" | "cancelled" | "unavailable";
|
|
3
|
+
export interface WorkflowStatus {
|
|
4
|
+
id: string;
|
|
5
|
+
workflow: string;
|
|
6
|
+
task: string;
|
|
7
|
+
step: string;
|
|
8
|
+
stage: WorkflowStage;
|
|
9
|
+
hint: string;
|
|
10
|
+
failures: number;
|
|
11
|
+
maxFailures: number;
|
|
12
|
+
updatedAt: string;
|
|
13
|
+
report: string | null;
|
|
14
|
+
steps: Array<{
|
|
15
|
+
id: string;
|
|
16
|
+
description: string;
|
|
17
|
+
current: boolean;
|
|
18
|
+
failures: number;
|
|
19
|
+
}>;
|
|
20
|
+
votes: Array<{
|
|
21
|
+
index: number;
|
|
22
|
+
status: "pending" | "running" | "passed" | "failed" | "infra";
|
|
23
|
+
reason: string;
|
|
24
|
+
}>;
|
|
25
|
+
recent: Array<{
|
|
26
|
+
step: string;
|
|
27
|
+
event: string;
|
|
28
|
+
detail: string;
|
|
29
|
+
}>;
|
|
30
|
+
}
|
|
31
|
+
export interface StatusFrame {
|
|
32
|
+
kind: "snapshot" | "update";
|
|
33
|
+
sessionId: string;
|
|
34
|
+
status: WorkflowStatus | null;
|
|
35
|
+
error: string | null;
|
|
36
|
+
}
|
|
37
|
+
export declare function parseStatusFrame(value: unknown): StatusFrame;
|
|
38
|
+
export declare const statusDescriptors: readonly InvocationDescriptor[];
|
|
39
|
+
export declare const statusRemote: TypertRemoteContribution;
|
|
40
|
+
declare module "@deepseek-ai/dsh-typert-protocol" {
|
|
41
|
+
interface TypertRemoteNamespaceMap {
|
|
42
|
+
ralphflowStatus: {
|
|
43
|
+
watch(sessionId: string, signal?: AbortSignal): RemoteStream<StatusFrame>;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** One explicit, strict public Typert contract shared by both faces. No SRC fallback. */
|
|
2
|
+
function record(value) {
|
|
3
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
4
|
+
throw new TypeError("expected status object");
|
|
5
|
+
return value;
|
|
6
|
+
}
|
|
7
|
+
function string(value) {
|
|
8
|
+
if (typeof value !== "string")
|
|
9
|
+
throw new TypeError("expected status string");
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
function count(value) {
|
|
13
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0)
|
|
14
|
+
throw new TypeError("expected status count");
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
function array(value, parse) {
|
|
18
|
+
if (!Array.isArray(value) || value.length > 2000)
|
|
19
|
+
throw new TypeError("expected bounded status list");
|
|
20
|
+
return value.map(parse);
|
|
21
|
+
}
|
|
22
|
+
function bool(value) {
|
|
23
|
+
if (typeof value !== "boolean")
|
|
24
|
+
throw new TypeError("expected status boolean");
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
function choice(value, values) {
|
|
28
|
+
if (!values.includes(value))
|
|
29
|
+
throw new TypeError("unknown status variant");
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
export function parseStatusFrame(value) {
|
|
33
|
+
const frame = record(value);
|
|
34
|
+
let status = null;
|
|
35
|
+
if (frame.status !== null) {
|
|
36
|
+
const s = record(frame.status);
|
|
37
|
+
status = {
|
|
38
|
+
id: string(s.id), workflow: string(s.workflow), task: string(s.task), step: string(s.step),
|
|
39
|
+
stage: choice(s.stage, ["executing", "verifying", "gate", "paused", "switching", "done", "cancelled", "unavailable"]),
|
|
40
|
+
hint: string(s.hint), failures: count(s.failures), maxFailures: count(s.maxFailures), updatedAt: string(s.updatedAt),
|
|
41
|
+
report: s.report === null ? null : string(s.report),
|
|
42
|
+
steps: array(s.steps, (v) => { const x = record(v); return { id: string(x.id), description: string(x.description), current: bool(x.current), failures: count(x.failures) }; }),
|
|
43
|
+
votes: array(s.votes, (v) => { const x = record(v); return { index: count(x.index), status: choice(x.status, ["pending", "running", "passed", "failed", "infra"]), reason: string(x.reason) }; }),
|
|
44
|
+
recent: array(s.recent, (v) => { const x = record(v); return { step: string(x.step), event: string(x.event), detail: string(x.detail) }; }),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return { kind: choice(frame.kind, ["snapshot", "update"]), sessionId: string(frame.sessionId), status,
|
|
48
|
+
error: frame.error === null ? null : string(frame.error) };
|
|
49
|
+
}
|
|
50
|
+
const sessionCodec = { mode: "strict", typeSymbol: "@deepseek-ai/dsh-session/types#SessionId", create: () => ({ parse: string }) };
|
|
51
|
+
const frameCodec = { mode: "strict", typeSymbol: "ralphflow-dsh#StatusFrame", create: () => ({ parse: parseStatusFrame }) };
|
|
52
|
+
export const statusDescriptors = [{
|
|
53
|
+
id: "ralphflow-dsh#ralphflowStatus/watch", service: "ralphflowStatus", namespace: "ralphflowStatus", method: "watch",
|
|
54
|
+
mode: "stream", invocation: { kind: "direct" },
|
|
55
|
+
parameters: [{ name: "session", wire: "sessionId", source: "lookup", lookup: "session", codec: sessionCodec }],
|
|
56
|
+
cancellation: { parameter: "signal" }, result: frameCodec,
|
|
57
|
+
}];
|
|
58
|
+
export const statusRemote = { package: "ralphflow-dsh", descriptors: statusDescriptors };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
import type { Session } from "@deepseek-ai/dsh-session";
|
|
3
|
+
import { TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
4
|
+
import type { StatusFrame, WorkflowStatus } from "./status-contract.js";
|
|
5
|
+
export interface StatusReader {
|
|
6
|
+
read(session: Session): Promise<{
|
|
7
|
+
status: WorkflowStatus | null;
|
|
8
|
+
error: string | null;
|
|
9
|
+
}>;
|
|
10
|
+
subscribe(listener: () => void): () => void;
|
|
11
|
+
}
|
|
12
|
+
/** The existing session lookup owns admission/resume. This face only observes that Session. */
|
|
13
|
+
export declare class WorkflowStatusService extends TypertRemoteService {
|
|
14
|
+
private readonly reader;
|
|
15
|
+
private readonly lifetime;
|
|
16
|
+
constructor(ctx: Context, reader: StatusReader);
|
|
17
|
+
watch(session: Session, signal: AbortSignal): AsyncGenerator<StatusFrame>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
2
|
+
var useValue = arguments.length > 2;
|
|
3
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
4
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
5
|
+
}
|
|
6
|
+
return useValue ? value : void 0;
|
|
7
|
+
};
|
|
8
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
9
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
10
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
11
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
12
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
13
|
+
var _, done = false;
|
|
14
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
15
|
+
var context = {};
|
|
16
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
17
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
18
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
19
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
20
|
+
if (kind === "accessor") {
|
|
21
|
+
if (result === void 0) continue;
|
|
22
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
23
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
24
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
25
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
26
|
+
}
|
|
27
|
+
else if (_ = accept(result)) {
|
|
28
|
+
if (kind === "field") initializers.unshift(_);
|
|
29
|
+
else descriptor[key] = _;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
33
|
+
done = true;
|
|
34
|
+
};
|
|
35
|
+
import { Remote, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
36
|
+
/** The existing session lookup owns admission/resume. This face only observes that Session. */
|
|
37
|
+
let WorkflowStatusService = (() => {
|
|
38
|
+
let _classSuper = TypertRemoteService;
|
|
39
|
+
let _instanceExtraInitializers = [];
|
|
40
|
+
let _watch_decorators;
|
|
41
|
+
return class WorkflowStatusService extends _classSuper {
|
|
42
|
+
static {
|
|
43
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
44
|
+
_watch_decorators = [Remote({ mode: "stream" })];
|
|
45
|
+
__esDecorate(this, null, _watch_decorators, { kind: "method", name: "watch", static: false, private: false, access: { has: obj => "watch" in obj, get: obj => obj.watch }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
46
|
+
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
47
|
+
}
|
|
48
|
+
reader = __runInitializers(this, _instanceExtraInitializers);
|
|
49
|
+
lifetime = new AbortController();
|
|
50
|
+
constructor(ctx, reader) {
|
|
51
|
+
super(ctx, "ralphflowStatus");
|
|
52
|
+
this.reader = reader;
|
|
53
|
+
ctx.effect(() => () => this.lifetime.abort(), "ralphflow status stream lifetime");
|
|
54
|
+
}
|
|
55
|
+
async *watch(session, signal) {
|
|
56
|
+
signal = AbortSignal.any([signal, this.lifetime.signal]);
|
|
57
|
+
let pending = true;
|
|
58
|
+
let wake;
|
|
59
|
+
const changed = () => { pending = true; wake?.(); };
|
|
60
|
+
const unsubscribe = this.reader.subscribe(changed);
|
|
61
|
+
signal.addEventListener("abort", changed);
|
|
62
|
+
let first = true;
|
|
63
|
+
try {
|
|
64
|
+
while (!signal.aborted) {
|
|
65
|
+
if (!pending)
|
|
66
|
+
await new Promise((resolve) => { wake = resolve; if (pending || signal.aborted)
|
|
67
|
+
resolve(); });
|
|
68
|
+
wake = undefined;
|
|
69
|
+
if (signal.aborted)
|
|
70
|
+
return;
|
|
71
|
+
pending = false;
|
|
72
|
+
const next = await this.reader.read(session);
|
|
73
|
+
if (signal.aborted)
|
|
74
|
+
return;
|
|
75
|
+
yield { kind: first ? "snapshot" : "update", sessionId: session.id, ...next };
|
|
76
|
+
first = false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
unsubscribe();
|
|
81
|
+
signal.removeEventListener("abort", changed);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
})();
|
|
86
|
+
export { WorkflowStatusService };
|
package/lib/typert.d.ts
ADDED
package/lib/typert.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { statusDescriptors } from "./status-contract.js";
|
|
2
|
+
/** Public registry artifact, kept explicit rather than requiring dsh's monorepo generator. */
|
|
3
|
+
export const TYPERT = {
|
|
4
|
+
package: "ralphflow-dsh", face: "host", schemas: [], invocations: statusDescriptors,
|
|
5
|
+
model: { services: [{ key: "ralphflowStatus", exportName: "WorkflowStatusService", members: [], types: [], tags: [] }], events: [], objects: [] },
|
|
6
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ralphflow-dsh",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Ralph Flow for DeepSeek Harness — 执行者/验证者模式的具象化:主会话执行,独立验证者对抗检查,推进权在机械程序(v2 原生重做)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -10,7 +10,15 @@
|
|
|
10
10
|
"types": "./lib/index.d.ts",
|
|
11
11
|
"default": "./lib/index.js"
|
|
12
12
|
},
|
|
13
|
-
"./package.json": "./package.json"
|
|
13
|
+
"./package.json": "./package.json",
|
|
14
|
+
"./client": {
|
|
15
|
+
"types": "./lib/client/index.d.ts",
|
|
16
|
+
"default": "./lib/client.js"
|
|
17
|
+
},
|
|
18
|
+
"./typert": {
|
|
19
|
+
"types": "./lib/typert.d.ts",
|
|
20
|
+
"default": "./lib/typert.js"
|
|
21
|
+
}
|
|
14
22
|
},
|
|
15
23
|
"files": [
|
|
16
24
|
"lib",
|
|
@@ -21,6 +29,21 @@
|
|
|
21
29
|
"dsh": {
|
|
22
30
|
"bundle": {
|
|
23
31
|
"patch": "./cordis.patch.yml"
|
|
32
|
+
},
|
|
33
|
+
"client": {
|
|
34
|
+
"platform": "web",
|
|
35
|
+
"inject": [
|
|
36
|
+
"@deepseek-ai/dsh-client-ui-chat",
|
|
37
|
+
"@deepseek-ai/dsh-client-ui-conversation",
|
|
38
|
+
"@deepseek-ai/dsh-client-ui-renderer",
|
|
39
|
+
"@deepseek-ai/dsh-api-gateway",
|
|
40
|
+
"@deepseek-ai/dsh-client-ui-primitives"
|
|
41
|
+
],
|
|
42
|
+
"external": [
|
|
43
|
+
"react",
|
|
44
|
+
"@deepseek-ai/dsh-api-gateway/client",
|
|
45
|
+
"@deepseek-ai/dsh-client-ui-primitives"
|
|
46
|
+
]
|
|
24
47
|
}
|
|
25
48
|
},
|
|
26
49
|
"license": "MIT",
|
|
@@ -36,22 +59,52 @@
|
|
|
36
59
|
"js-yaml": "^4.1.1"
|
|
37
60
|
},
|
|
38
61
|
"peerDependencies": {
|
|
39
|
-
"@deepseek-ai/cordis": "
|
|
40
|
-
"@deepseek-ai/dsh-agent": "
|
|
41
|
-
"@deepseek-ai/dsh-llm": "
|
|
42
|
-
"@deepseek-ai/dsh-tools": "
|
|
43
|
-
"@deepseek-ai/dsh-subagent": "
|
|
44
|
-
"@deepseek-ai/dsh-session": "
|
|
45
|
-
"@deepseek-ai/dsh-compaction": "
|
|
46
|
-
"@deepseek-ai/dsh-commands": "
|
|
47
|
-
"@deepseek-ai/dsh-skill": "
|
|
62
|
+
"@deepseek-ai/cordis": "^4.0.5-alpha.1",
|
|
63
|
+
"@deepseek-ai/dsh-agent": "^0.2.1-alpha.1",
|
|
64
|
+
"@deepseek-ai/dsh-llm": "^0.2.1-alpha.1",
|
|
65
|
+
"@deepseek-ai/dsh-tools": "^0.2.1-alpha.1",
|
|
66
|
+
"@deepseek-ai/dsh-subagent": "^0.2.1-alpha.1",
|
|
67
|
+
"@deepseek-ai/dsh-session": "^0.2.1-alpha.1",
|
|
68
|
+
"@deepseek-ai/dsh-compaction": "^0.2.1-alpha.1",
|
|
69
|
+
"@deepseek-ai/dsh-commands": "^0.2.1-alpha.1",
|
|
70
|
+
"@deepseek-ai/dsh-skill": "^0.2.1-alpha.1",
|
|
71
|
+
"@deepseek-ai/dsh-client-ui-chat": "^0.2.1-alpha.1",
|
|
72
|
+
"@deepseek-ai/dsh-client-ui-conversation": "^0.2.1-alpha.1",
|
|
73
|
+
"@deepseek-ai/dsh-client-ui-renderer": "^0.2.1-alpha.1",
|
|
74
|
+
"@deepseek-ai/dsh-typert-protocol": "^0.2.1-alpha.1",
|
|
75
|
+
"@deepseek-ai/dsh-typert-registry": "^0.2.1-alpha.1",
|
|
76
|
+
"@deepseek-ai/dsh-api-gateway": "^0.2.1-alpha.1",
|
|
77
|
+
"@deepseek-ai/dsh-session-query": "^0.2.1-alpha.1",
|
|
78
|
+
"@deepseek-ai/dsh-client-ui-primitives": "^0.2.1-alpha.1"
|
|
48
79
|
},
|
|
49
80
|
"devDependencies": {
|
|
50
81
|
"@types/js-yaml": "^4.0.9",
|
|
51
|
-
"@types/node": "^22.20.1"
|
|
82
|
+
"@types/node": "^22.20.1",
|
|
83
|
+
"esbuild": "^0.28.2",
|
|
84
|
+
"@types/react": "^18.3.1",
|
|
85
|
+
"react": "^18.3.1",
|
|
86
|
+
"@deepseek-ai/cordis": "4.0.5-alpha.1",
|
|
87
|
+
"@deepseek-ai/dsh-agent": "0.2.1-alpha.1",
|
|
88
|
+
"@deepseek-ai/dsh-llm": "0.2.1-alpha.1",
|
|
89
|
+
"@deepseek-ai/dsh-tools": "0.2.1-alpha.1",
|
|
90
|
+
"@deepseek-ai/dsh-subagent": "0.2.1-alpha.1",
|
|
91
|
+
"@deepseek-ai/dsh-session": "0.2.1-alpha.1",
|
|
92
|
+
"@deepseek-ai/dsh-compaction": "0.2.1-alpha.1",
|
|
93
|
+
"@deepseek-ai/dsh-commands": "0.2.1-alpha.1",
|
|
94
|
+
"@deepseek-ai/dsh-skill": "0.2.1-alpha.1",
|
|
95
|
+
"@deepseek-ai/dsh-client-ui-chat": "0.2.1-alpha.1",
|
|
96
|
+
"@deepseek-ai/dsh-client-ui-conversation": "0.2.1-alpha.1",
|
|
97
|
+
"@deepseek-ai/dsh-client-ui-renderer": "0.2.1-alpha.1",
|
|
98
|
+
"@deepseek-ai/dsh-typert-protocol": "0.2.1-alpha.1",
|
|
99
|
+
"@deepseek-ai/dsh-typert-registry": "0.2.1-alpha.1",
|
|
100
|
+
"@deepseek-ai/dsh-api-gateway": "0.2.1-alpha.1",
|
|
101
|
+
"@deepseek-ai/dsh-session-query": "0.2.1-alpha.1",
|
|
102
|
+
"@deepseek-ai/dsh-client-ui-primitives": "0.2.1-alpha.1",
|
|
103
|
+
"typescript": "^5.9.3",
|
|
104
|
+
"@deepseek-ai/dsh": "0.2.1-alpha.1"
|
|
52
105
|
},
|
|
53
106
|
"scripts": {
|
|
54
|
-
"build": "tsc -p tsconfig.json",
|
|
107
|
+
"build": "tsc -p tsconfig.json && node scripts/build-client.mjs",
|
|
55
108
|
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
56
109
|
"verify": "node scripts/verify-all.mjs",
|
|
57
110
|
"prepublishOnly": "npm run build && npm run typecheck && npm run verify"
|