@deepseek-ai/dsh-goal-round-driver 0.2.0-rc.2 → 0.2.1-alpha.1
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.i18n.yaml +6 -6
- package/README.md +2 -3
- package/README.zh.md +2 -3
- package/lib/index.js +5 -3
- package/package.json +16 -23
- package/lib/invariant.js +0 -77
- package/lib/types/invariant.d.ts +0 -13
package/README.i18n.yaml
CHANGED
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
en: a1312339977f1127
|
|
25
25
|
zh: 57450327ff7e7d83
|
|
26
26
|
/deepseek-ai-dsh-goal-round-driver/use-this-package/when-continuation-stops:
|
|
27
|
-
en:
|
|
28
|
-
zh:
|
|
27
|
+
en: 87b20bc93e1c6ebb
|
|
28
|
+
zh: 20eebb2538da1551
|
|
29
29
|
/deepseek-ai-dsh-goal-round-driver/use-this-package/after-resume-fork-or-unload:
|
|
30
30
|
en: 85d5470b1b330330
|
|
31
31
|
zh: e761f9046ba7af8a
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
en: 58a2316725fe1f38
|
|
37
37
|
zh: d42d60cf02ad518e
|
|
38
38
|
/deepseek-ai-dsh-goal-round-driver/understand-the-implementation/source-map:
|
|
39
|
-
en:
|
|
40
|
-
zh:
|
|
39
|
+
en: 80fe3f7859194ce5
|
|
40
|
+
zh: 6d2090722d94718c
|
|
41
41
|
/deepseek-ai-dsh-goal-round-driver/understand-the-implementation/the-round-prompt:
|
|
42
|
-
en:
|
|
43
|
-
zh:
|
|
42
|
+
en: dc95a473296236c6
|
|
43
|
+
zh: ec69b7081cd9fa73
|
|
44
44
|
/deepseek-ai-dsh-goal-round-driver/further-exploration:
|
|
45
45
|
en: 4bf1ec9b975f92b7
|
|
46
46
|
zh: 00b4b2eba534c127
|
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ With an exact live agent idle, an active armed goal, and remaining capacity, the
|
|
|
50
50
|
|
|
51
51
|
### When continuation stops
|
|
52
52
|
|
|
53
|
-
A round starts only at whole-agent idle, and completion, pause, and blocking suppress continuation; a host-initiated pause also aborts the turn already running, while a model-initiated pause inside its own turn finishes normally. An edit only invalidates an in-flight round through the revision fence, and the driver continues the new revision. The driver also stops on its own when a turn ends on max tokens, a durability write fails, the agent is cancelled, the plugin unloads, or the round cap is exhausted — at the cap it records a blocker with the stable code `round-limit`. Cancellation never auto-restarts a round: a goal whose round was under way
|
|
53
|
+
A round starts only at whole-agent idle, and completion, pause, and blocking suppress continuation; a host-initiated pause also aborts the turn already running, while a model-initiated pause inside its own turn finishes normally. An edit only invalidates an in-flight round through the revision fence, and the driver continues the new revision. The driver also stops on its own when a turn ends on max tokens, a durability write fails, the agent is cancelled, the plugin unloads, or the round cap is exhausted — at the cap it records a blocker with the stable code `round-limit`. Cancellation never auto-restarts a round: a goal whose round was under way is paused at the next idle point, and a cancellation unrelated to a goal attempt only disarms continuation. A round prompt still queued when the agent reaches idle is removed from the inbox, so later human input does not wait behind it; when the cancelled turn belonged to other work, continuation is disarmed rather than paused.
|
|
54
54
|
|
|
55
55
|
### After resume, fork, or unload
|
|
56
56
|
|
|
@@ -79,11 +79,10 @@ This section explains how the driver schedules rounds without races; the observa
|
|
|
79
79
|
|---|---|
|
|
80
80
|
| [`src/index.ts`](src/index.ts) | Plugin entry: driver state machine, race fences, teardown |
|
|
81
81
|
| [`src/prompt.ts`](src/prompt.ts) | The retained `<goal_round>` continuation prompt |
|
|
82
|
-
| [`src/invariant.ts`](src/invariant.ts) | Invariant companion: goal-round messages must match the package-owned prompt |
|
|
83
82
|
|
|
84
83
|
### The round prompt
|
|
85
84
|
|
|
86
|
-
The retained prompt is one text block: the JSON-quoted objective and `round/maxGoalRounds` on the first lines, then the working instructions.
|
|
85
|
+
The retained prompt is one text block: the JSON-quoted objective and `round/maxGoalRounds` on the first lines, then the working instructions.
|
|
87
86
|
|
|
88
87
|
</details>
|
|
89
88
|
|
package/README.zh.md
CHANGED
|
@@ -50,7 +50,7 @@ kind: "package-reference"
|
|
|
50
50
|
|
|
51
51
|
### 何时停止续行
|
|
52
52
|
|
|
53
|
-
Round 只在整个 agent 进入 idle 时启动;完成、暂停和阻塞会阻止续行;宿主发起的暂停还会中止正在运行的轮次,而模型在自己轮次内发起的暂停会正常结束。编辑只会通过修订栅栏使进行中的 Round 失效,驱动器会继续新修订。驱动器也会在以下情况自行停止:轮次因 max tokens 结束、持久性写入失败、agent 被取消、插件卸载,或 Round 上限耗尽——上限耗尽时它会以稳定代码 `round-limit` 记录一个 blocker。取消绝不会自动重启 Round:Round
|
|
53
|
+
Round 只在整个 agent 进入 idle 时启动;完成、暂停和阻塞会阻止续行;宿主发起的暂停还会中止正在运行的轮次,而模型在自己轮次内发起的暂停会正常结束。编辑只会通过修订栅栏使进行中的 Round 失效,驱动器会继续新修订。驱动器也会在以下情况自行停止:轮次因 max tokens 结束、持久性写入失败、agent 被取消、插件卸载,或 Round 上限耗尽——上限耗尽时它会以稳定代码 `round-limit` 记录一个 blocker。取消绝不会自动重启 Round:Round 已在进行的 goal 会在下一次 idle 时被暂停;与 goal 尝试无关的取消只会停用续行。agent 进入 idle 时仍在排队的 Round 提示会从收件箱移除,后续人类输入不会排在它后面等待;被取消的轮次属于其他工作时,续行会被停用而不是暂停。
|
|
54
54
|
|
|
55
55
|
### resume、fork 或卸载之后
|
|
56
56
|
|
|
@@ -79,11 +79,10 @@ Round 只在整个 agent 进入 idle 时启动;完成、暂停和阻塞会阻
|
|
|
79
79
|
|---|---|
|
|
80
80
|
| [`src/index.ts`](src/index.ts) | 插件入口:驱动器状态机、竞态防护、teardown |
|
|
81
81
|
| [`src/prompt.ts`](src/prompt.ts) | 保留的 `<goal_round>` 续行提示词 |
|
|
82
|
-
| [`src/invariant.ts`](src/invariant.ts) | 不变式伴生:goal-round 消息必须与包自有提示词一致 |
|
|
83
82
|
|
|
84
83
|
### Round 提示词
|
|
85
84
|
|
|
86
|
-
保留的提示词是一个文本块:前几行为 JSON 引用的目标与 `round/maxGoalRounds
|
|
85
|
+
保留的提示词是一个文本块:前几行为 JSON 引用的目标与 `round/maxGoalRounds`,其后是工作指令。
|
|
87
86
|
|
|
88
87
|
</details>
|
|
89
88
|
|
package/lib/index.js
CHANGED
|
@@ -216,12 +216,14 @@ function apply(ctx) {
|
|
|
216
216
|
state.competingQueued = false;
|
|
217
217
|
const attempt = state.attempt;
|
|
218
218
|
const goal = currentGoal(state);
|
|
219
|
-
|
|
219
|
+
const pause = attempt !== void 0 && (attempt.phase === "queued" || attempt.phase === "claimed" || attempt.cancelled) && goal !== void 0 && goal.phase === "active" && goal.activation === "armed" && attempt.goalId === goal.id && attempt.revision === goal.revision;
|
|
220
|
+
if (pause || attempt?.phase === "queued") {
|
|
220
221
|
state.attempt = void 0;
|
|
221
222
|
try {
|
|
222
|
-
|
|
223
|
+
if (attempt.phase === "queued") agent.inbox.remove(attempt.messageId);
|
|
224
|
+
if (pause) ctx.goals.pause(agent, goalRef(goal));
|
|
223
225
|
} catch (error) {
|
|
224
|
-
ctx.logger.warn(`goal-round-driver: could not
|
|
226
|
+
ctx.logger.warn(`goal-round-driver: could not settle cancelled goal round for agent "${agent.id}": ${renderThrown(error)}`);
|
|
225
227
|
disarm(state);
|
|
226
228
|
}
|
|
227
229
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-goal-round-driver",
|
|
3
3
|
"description": "Race-fenced same-session goal-round driver",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.1-alpha.1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -18,38 +18,31 @@
|
|
|
18
18
|
"types": "./lib/types/index.d.ts",
|
|
19
19
|
"default": "./lib/index.js"
|
|
20
20
|
},
|
|
21
|
-
"./invariant": {
|
|
22
|
-
"types": "./lib/types/invariant.d.ts",
|
|
23
|
-
"default": "./lib/invariant.js"
|
|
24
|
-
},
|
|
25
21
|
"./src/*": "./src/*",
|
|
26
22
|
"./package.json": "./package.json"
|
|
27
23
|
},
|
|
28
24
|
"files": [
|
|
29
25
|
"lib/index.js",
|
|
30
|
-
"lib/invariant.js",
|
|
31
26
|
"lib/types/**/*.d.ts"
|
|
32
27
|
],
|
|
33
28
|
"license": "MIT",
|
|
34
29
|
"peerDependencies": {
|
|
35
|
-
"@deepseek-ai/dsh-agent": "0.2.
|
|
36
|
-
"@deepseek-ai/dsh-goal": "0.2.
|
|
37
|
-
"@deepseek-ai/dsh-
|
|
38
|
-
"@deepseek-ai/dsh-
|
|
39
|
-
"@deepseek-ai/
|
|
40
|
-
"@deepseek-ai/cordis": "~4.0.4"
|
|
30
|
+
"@deepseek-ai/dsh-agent": "0.2.1-alpha.1",
|
|
31
|
+
"@deepseek-ai/dsh-goal": "0.2.1-alpha.1",
|
|
32
|
+
"@deepseek-ai/dsh-llm": "0.2.1-alpha.1",
|
|
33
|
+
"@deepseek-ai/dsh-session": "0.2.1-alpha.1",
|
|
34
|
+
"@deepseek-ai/cordis": "~4.0.5-alpha.1"
|
|
41
35
|
},
|
|
42
36
|
"devDependencies": {
|
|
43
|
-
"@deepseek-ai/dsh-agent": "0.2.
|
|
44
|
-
"@deepseek-ai/dsh-
|
|
45
|
-
"@deepseek-ai/dsh-agent-loop-testkit": "0.2.
|
|
46
|
-
"@deepseek-ai/dsh-
|
|
47
|
-
"@deepseek-ai/dsh-
|
|
48
|
-
"@deepseek-ai/dsh-
|
|
49
|
-
"@deepseek-ai/dsh-
|
|
50
|
-
"@deepseek-ai/dsh-tools": "0.2.
|
|
51
|
-
"@deepseek-ai/
|
|
52
|
-
"@deepseek-ai/
|
|
53
|
-
"@deepseek-ai/dsh-system-prompt": "0.2.0-rc.2"
|
|
37
|
+
"@deepseek-ai/dsh-agent-loop": "0.2.1-alpha.1",
|
|
38
|
+
"@deepseek-ai/dsh-goal": "0.2.1-alpha.1",
|
|
39
|
+
"@deepseek-ai/dsh-agent-loop-testkit": "0.2.1-alpha.1",
|
|
40
|
+
"@deepseek-ai/dsh-llm": "0.2.1-alpha.1",
|
|
41
|
+
"@deepseek-ai/dsh-session": "0.2.1-alpha.1",
|
|
42
|
+
"@deepseek-ai/dsh-agent": "0.2.1-alpha.1",
|
|
43
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.1",
|
|
44
|
+
"@deepseek-ai/dsh-tools": "0.2.1-alpha.1",
|
|
45
|
+
"@deepseek-ai/dsh-session-projection": "0.2.1-alpha.1",
|
|
46
|
+
"@deepseek-ai/cordis": "~4.0.5-alpha.1"
|
|
54
47
|
}
|
|
55
48
|
}
|
package/lib/invariant.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { isDeepStrictEqual } from "node:util";
|
|
2
|
-
import { foldGoal } from "@deepseek-ai/dsh-goal";
|
|
3
|
-
//#region lib/types/prompt.js
|
|
4
|
-
/** Model-visible continuation prompt for one same-session goal round. */
|
|
5
|
-
/**
|
|
6
|
-
* Render the complete goal-round instruction retained in session history.
|
|
7
|
-
* @param goal - exact active goal revision being admitted.
|
|
8
|
-
* @param round - next positive round number.
|
|
9
|
-
* @returns a fresh one-block prompt for `Agent.followup()`.
|
|
10
|
-
*/
|
|
11
|
-
function renderGoalRoundPrompt(goal, round) {
|
|
12
|
-
return [{
|
|
13
|
-
type: "text",
|
|
14
|
-
text: `<goal_round>
|
|
15
|
-
Objective: ${JSON.stringify(goal.objective)}\nRound: ${round}/${goal.maxGoalRounds}\n\nContinue working toward the objective in this same session. Treat the current workspace, tool results, and durable session state as authoritative; inspect them instead of assuming earlier narration is still current. Make concrete progress and verify the result. Before claiming completion, gather evidence that the whole objective is achieved, read the current goal, and mark it complete. If work remains, leave the goal active for the next round. Follow the configured goal-tool policy before reporting a blocker.
|
|
16
|
-
</goal_round>`
|
|
17
|
-
}];
|
|
18
|
-
}
|
|
19
|
-
//#endregion
|
|
20
|
-
//#region lib/types/invariant.js
|
|
21
|
-
/** Package-owned goal-round prompt invariants. @module @deepseek-ai/dsh-goal-round-driver/invariant */
|
|
22
|
-
const PACKAGE_NAME = "@deepseek-ai/dsh-goal-round-driver";
|
|
23
|
-
/** Cordis companion plugin name. */
|
|
24
|
-
const name = "goal-round-driver-invariant";
|
|
25
|
-
/** Service required before the companion can reserve package ownership. */
|
|
26
|
-
const inject = ["invariants"];
|
|
27
|
-
/** Attribute strict goal-fold failures to this companion's reconstruction. */
|
|
28
|
-
function foldChecked(events, fail) {
|
|
29
|
-
try {
|
|
30
|
-
return foldGoal(events);
|
|
31
|
-
} catch (error) {
|
|
32
|
-
return fail(`cannot reconstruct the goal before a continuation message: ${error instanceof Error ? error.message : String(error)}`);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
/** Recreate the live-shaped view consumed by the package's pure prompt renderer. */
|
|
36
|
-
function goalView(folded, source, fail) {
|
|
37
|
-
const goal = folded.goal;
|
|
38
|
-
if (goal === void 0 || folded.createdAt === void 0 || folded.updatedAt === void 0 || goal.phase !== "active" || goal.id !== source.goalId || goal.revision !== source.revision || source.round !== folded.roundsStarted + 1 || source.round > goal.maxGoalRounds) return fail(`goal round ${source.round} cannot be reconstructed from the preceding durable goal state`);
|
|
39
|
-
return {
|
|
40
|
-
...goal,
|
|
41
|
-
roundsStarted: folded.roundsStarted,
|
|
42
|
-
createdAt: folded.createdAt,
|
|
43
|
-
updatedAt: folded.updatedAt,
|
|
44
|
-
activation: "armed"
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
/** Validate one package-owned continuation message against its durable prefix. */
|
|
48
|
-
function validateEvent(prior, event, fail) {
|
|
49
|
-
if (event.type !== "user/message") return;
|
|
50
|
-
const source = event.data.source;
|
|
51
|
-
if (source.kind !== "goal" || source.round <= 0) return;
|
|
52
|
-
const expected = renderGoalRoundPrompt(goalView(foldChecked(prior, fail), source, fail), source.round);
|
|
53
|
-
if (!isDeepStrictEqual(event.data.content, expected)) fail(`goal round ${source.round} content does not match the package-owned continuation prompt`);
|
|
54
|
-
}
|
|
55
|
-
/** Check existing sessions and every candidate event before Session publishes it. */
|
|
56
|
-
const install = Object.assign((ctx, fail) => {
|
|
57
|
-
for (const session of ctx.sessions.list()) {
|
|
58
|
-
const prior = [];
|
|
59
|
-
for (const event of session.snapshotEvents()) {
|
|
60
|
-
validateEvent(prior, event, fail);
|
|
61
|
-
prior.push(event);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
ctx.on("internal/dispatch", (_mode, eventName, args) => {
|
|
65
|
-
if (eventName !== "session/event") return;
|
|
66
|
-
const [session, event] = args;
|
|
67
|
-
validateEvent(session.snapshotEvents(), event, fail);
|
|
68
|
-
}, { global: true });
|
|
69
|
-
}, { inject: ["sessions"] });
|
|
70
|
-
/**
|
|
71
|
-
* Register the goal-round-driver invariant companion.
|
|
72
|
-
* @param ctx - Cordis context carrying the invariant service.
|
|
73
|
-
* @returns the installed registration's disposer after setup succeeds.
|
|
74
|
-
*/
|
|
75
|
-
const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
76
|
-
//#endregion
|
|
77
|
-
export { apply, inject, name };
|
package/lib/types/invariant.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/** Package-owned goal-round prompt invariants. @module @deepseek-ai/dsh-goal-round-driver/invariant */
|
|
2
|
-
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
-
/** Cordis companion plugin name. */
|
|
4
|
-
export declare const name = "goal-round-driver-invariant";
|
|
5
|
-
/** Service required before the companion can reserve package ownership. */
|
|
6
|
-
export declare const inject: string[];
|
|
7
|
-
/**
|
|
8
|
-
* Register the goal-round-driver invariant companion.
|
|
9
|
-
* @param ctx - Cordis context carrying the invariant service.
|
|
10
|
-
* @returns the installed registration's disposer after setup succeeds.
|
|
11
|
-
*/
|
|
12
|
-
export declare const apply: (ctx: Context) => Promise<() => void>;
|
|
13
|
-
//# sourceMappingURL=invariant.d.ts.map
|