@oyasmi/pipiclaw 0.9.1-beta.1 → 0.9.1-beta.2
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/dist/agent/channel-runner.d.ts +0 -1
- package/dist/agent/channel-runner.js +0 -2
- package/dist/agent/runner-factory.d.ts +0 -2
- package/dist/memory/task-digest.js +0 -2
- package/dist/playbooks/agent-delegation.md +3 -2
- package/dist/playbooks/task-driving.md +11 -13
- package/dist/playbooks/task-planning.md +3 -5
- package/dist/runtime/bootstrap.d.ts +1 -1
- package/dist/runtime/bootstrap.js +13 -49
- package/dist/runtime/channel-event.d.ts +0 -6
- package/dist/runtime/task-commands.d.ts +1 -1
- package/dist/runtime/task-commands.js +33 -174
- package/dist/runtime/task-driver.d.ts +1 -3
- package/dist/runtime/task-driver.js +34 -40
- package/dist/runtime/task-migration.d.ts +7 -6
- package/dist/runtime/task-migration.js +85 -19
- package/dist/runtime/task-wake.d.ts +3 -5
- package/dist/runtime/task-wake.js +7 -15
- package/dist/subagents/external/run.js +18 -1
- package/dist/subagents/runs.js +22 -3
- package/dist/subagents/tool.d.ts +10 -0
- package/dist/subagents/tool.js +32 -7
- package/dist/subagents/verification-outcome.js +17 -10
- package/dist/tasks/control.d.ts +18 -67
- package/dist/tasks/control.js +44 -176
- package/dist/tasks/ledger.d.ts +7 -13
- package/dist/tasks/ledger.js +13 -49
- package/dist/tasks/store.d.ts +15 -48
- package/dist/tasks/store.js +22 -154
- package/dist/tasks/transitions.d.ts +3 -4
- package/dist/tasks/transitions.js +8 -27
- package/dist/tools/index.d.ts +0 -2
- package/dist/tools/index.js +2 -1
- package/dist/tools/registry.d.ts +0 -1
- package/dist/tools/registry.js +0 -1
- package/dist/tools/subagent-manage.d.ts +8 -1
- package/dist/tools/subagent-manage.js +77 -7
- package/dist/tools/task-manage/lifecycle.js +19 -17
- package/dist/tools/task-manage/schema.d.ts +2 -6
- package/dist/tools/task-manage/schema.js +4 -17
- package/dist/tools/task-manage/shared.js +1 -6
- package/dist/tools/task-manage/types.d.ts +0 -3
- package/dist/tools/task-manage/verification.d.ts +9 -6
- package/dist/tools/task-manage/verification.js +19 -71
- package/dist/tools/task-manage.d.ts +1 -1
- package/dist/tools/task-manage.js +2 -4
- package/dist/usage/ledger.d.ts +4 -0
- package/dist/usage/ledger.js +3 -0
- package/package.json +1 -1
|
@@ -15,7 +15,6 @@ export declare class ChannelRunner implements AgentRunner {
|
|
|
15
15
|
private readonly modelsConfigPath;
|
|
16
16
|
private readonly onSessionEvent?;
|
|
17
17
|
private readonly mediaSender?;
|
|
18
|
-
private readonly dispatchVerification?;
|
|
19
18
|
private readonly workspaceDir;
|
|
20
19
|
/**
|
|
21
20
|
* Frozen for the lifetime of this runner generation (spec 043, D4.2): AgentSession, the
|
|
@@ -109,7 +109,6 @@ export class ChannelRunner {
|
|
|
109
109
|
this.modelsConfigPath = paths.modelsConfigPath;
|
|
110
110
|
this.onSessionEvent = paths.onSessionEvent;
|
|
111
111
|
this.mediaSender = paths.mediaSender;
|
|
112
|
-
this.dispatchVerification = paths.dispatchVerification;
|
|
113
112
|
const executor = createExecutor();
|
|
114
113
|
this.executor = executor;
|
|
115
114
|
this.workspaceDir = resolve(dirname(channelDir));
|
|
@@ -1261,7 +1260,6 @@ export class ChannelRunner {
|
|
|
1261
1260
|
securityConfig: securityLoad.config,
|
|
1262
1261
|
toolsConfig: toolsLoad.config,
|
|
1263
1262
|
mediaSender: this.mediaSender,
|
|
1264
|
-
dispatchVerification: this.dispatchVerification,
|
|
1265
1263
|
});
|
|
1266
1264
|
this.currentTools = tools;
|
|
1267
1265
|
// Tool schemas are billed with the system prompt and, unlike it, nothing trims them.
|
|
@@ -18,8 +18,6 @@ export interface RunnerFactoryPaths {
|
|
|
18
18
|
* Present enables the `send_media` tool; absent, the tool is not built.
|
|
19
19
|
*/
|
|
20
20
|
mediaSender?: MediaSender;
|
|
21
|
-
/** Runtime callback that durably enqueues an independent task verifier. */
|
|
22
|
-
dispatchVerification?: (taskId: string) => Promise<boolean>;
|
|
23
21
|
}
|
|
24
22
|
/**
|
|
25
23
|
* Stateless: always constructs a fresh runner. The daemon (`runtime/bootstrap.ts`) and the TUI
|
|
@@ -27,8 +27,6 @@ function renderLine(entry, now) {
|
|
|
27
27
|
];
|
|
28
28
|
const control = entry.frontmatter.control;
|
|
29
29
|
if (control) {
|
|
30
|
-
parts.push(`priority ${control.priority}`);
|
|
31
|
-
parts.push(`attempt ${control.usage.attempts}/${control.budget.maxAttempts}`);
|
|
32
30
|
if (control.verification.required)
|
|
33
31
|
parts.push(`verify required/${control.verification.status}`);
|
|
34
32
|
if (control.waitingFor)
|
|
@@ -49,10 +49,11 @@ order: 36
|
|
|
49
49
|
一次委派的返回只有两种:结果已经在手,或者一个 `runId` 加"稍后会叫醒你"。后一种情况下:
|
|
50
50
|
|
|
51
51
|
1. **不要轮询,也不要用后台作业包一层等待。** 委派结束时 runtime 会唤醒本频道,带回状态、耗时、结果尾部和产物路径。这是 runtime 保证。
|
|
52
|
-
2. **立即结束当前回合。** 属于某个 task 时,派发就带上 `taskId`,并用 `task_manage progress`
|
|
52
|
+
2. **立即结束当前回合。** 属于某个 task 时,派发就带上 `taskId`,并用 `task_manage progress` 停泊为 `waiting`(`waitingFor` 随手记一个 external-signal/job 之类的展示值即可)——runtime 按 run 记录里的 `taskId` 认领并恢复该任务,不看 `waitingFor` 写了什么。
|
|
53
53
|
3. 想看进度用 `subagent_manage op=list`(人可用 `/subagents list`),不要靠反复调用委派工具来"检查"。
|
|
54
54
|
4. 每个频道最多 6 个同时在跑的委派(宿主全局 20 个)。被上限拒绝时先等一个结束或 `cancel` 一个,不要改小任务再试。
|
|
55
|
-
5. daemon 重启时外部 run
|
|
55
|
+
5. daemon 重启时外部 run 通常继续跑,内置 run 会被判 `lost` 并唤醒说明;但外部 run 若在进程 pid 真正落盘之前就重启,也会被判 `lost`,不是外部 run 的例外。收到 `lost` 就是"结局未知":先查真实产物,再决定重派,不要假设它已经做完。重连恢复出的耗时前面会带 `≈`,那是从产物文件估算出来的,不是实测值,别当精确数字用。
|
|
56
|
+
6. `subagent_manage op=show <runId>` 给出一次派发的完整机器可读细节(实际 argv、派发警告、适配器/CLI 版本、外部 run 的 stderr 尾部)——外部 run 失败但看不出原因时,先用它自诊断,不要凭猜测重派。
|
|
56
57
|
|
|
57
58
|
## 五、纠偏与续接
|
|
58
59
|
|
|
@@ -9,24 +9,23 @@ order: 41
|
|
|
9
9
|
|
|
10
10
|
## 等待与恢复
|
|
11
11
|
|
|
12
|
-
本页是 task waiting 两种形态的唯一真相源:`waiting + wake` 是定时等待;`waiting` 无 wake 是停泊信号等待,普通 driver
|
|
12
|
+
本页是 task waiting 两种形态的唯一真相源:`waiting + wake` 是定时等待;`waiting` 无 wake 是停泊信号等待,普通 driver 不会轮询。`waitingFor` 只是记录性展示——真正决定能否恢复的,是一个真实的 wake,或者 runtime 里一条 `taskId` 指向本任务、已经 settle 的 run/job 记录,不是 `waitingFor` 写的字符串本身。
|
|
13
13
|
|
|
14
|
-
- 等外部 job
|
|
15
|
-
-
|
|
16
|
-
- 只有状态查询:设置合理 wake,写 `waitingFor: time`,并在 blockedReason 记录回访对象、条件和下一步。
|
|
14
|
+
- 等外部 job、用户或委派(含 verify sub-agent):不设 wake,写 `waitingFor: job`、`user` 或 `external-signal`;后台作业或委派结束时 runtime 只恢复所属 task。独立验收就是按这条路径委派 `purpose: verify` sub-agent,没有单独的等待语义。
|
|
15
|
+
- 只有状态查询:设置合理 wake,写 `waitingFor: time`,并在 `nextAction` 记录回访对象、条件和下一步。
|
|
17
16
|
|
|
18
17
|
后台作业的启动与完成唤醒见 `background-jobs.md`;外部 AI Agent 的等待、纠偏和验收见 `agent-delegation.md`。
|
|
19
18
|
|
|
20
19
|
## 每次唤醒先恢复真相
|
|
21
20
|
|
|
22
21
|
1. 打开消息指定的 `tasks/<id>.md`,不要只依赖唤醒文本、旧对话或记忆。
|
|
23
|
-
2. 核对 status、enabled/stop、Current Cycle、`nextAction`、wake、deadline、
|
|
22
|
+
2. 核对 status、enabled/stop、Current Cycle、`nextAction`、wake、deadline、waitingFor 和 verification。
|
|
24
23
|
3. 检查上一步产物是否已经存在。派发是 at-least-once,重放可能让同一步再次到达。
|
|
25
24
|
4. 只推进一个清晰的下一阶段;外部动作前先查询真实状态,避免重复发送、发布或部署。
|
|
26
25
|
|
|
27
26
|
## 回合结束必须留下状态
|
|
28
27
|
|
|
29
|
-
仍需继续时,用 `task_manage progress` 原子记录发生了什么、证据、下一步、status/wake;Plan 变化放在同一次 `planSteps` 中。生命周期动作 `
|
|
28
|
+
仍需继续时,用 `task_manage progress` 原子记录发生了什么、证据、下一步、status/wake;Plan 变化放在同一次 `planSteps` 中。生命周期动作 `complete`、`skip`、`cancel` 本身就是 checkpoint。
|
|
30
29
|
|
|
31
30
|
- 当前可继续:`active`,清除 wake。
|
|
32
31
|
- 等待真实条件:按“等待与恢复”设置 `waiting`、wake 和 waitingFor。
|
|
@@ -47,8 +46,8 @@ Task 创建即持续委托;能力边界和 task scope 是 authority。不要
|
|
|
47
46
|
## 独立验收
|
|
48
47
|
|
|
49
48
|
1. 只有证据成立后才勾选 DoD/Verification checklist。
|
|
50
|
-
2.
|
|
51
|
-
3. checker
|
|
49
|
+
2. 像任何其他委派一样,派发一个 `purpose: verify`、带 `taskId` 的 sub-agent,然后用 `task_manage progress` 把任务停泊为 `waiting`(不设 wake,`waitingFor: external-signal`)——没有单独的 `request-verification` 动作或 `waiting + waitingFor: verification` 状态。
|
|
50
|
+
3. checker 只读检查,结尾返回 `VERDICT: PASS` 或 `VERDICT: FAIL`;完成后 runtime 通过完成唤醒恢复所属 task,恢复的依据是 run 记录里的 `taskId`,不是 `waitingFor` 写的值。
|
|
52
51
|
4. 主回合用 `task_manage verify` 导入 runId;attestation 必须属于当前 task、未改变 workspace,且 contract body hash 与 artifact subject 新鲜。
|
|
53
52
|
5. PASS/FAIL 都恢复 active;PASS 后 complete 仍会重新校验 attestation、contract hash 和 artifact subject。
|
|
54
53
|
|
|
@@ -70,7 +69,7 @@ driver 只派发 enabled 且 active 的任务。waiting 到 wake 时 runtime 先
|
|
|
70
69
|
|
|
71
70
|
## 治理器停止
|
|
72
71
|
|
|
73
|
-
deadline
|
|
72
|
+
deadline 超期,或连续三次 wake 没有可见 effect 时,runtime 写:
|
|
74
73
|
|
|
75
74
|
```text
|
|
76
75
|
enabled: false
|
|
@@ -79,18 +78,17 @@ control.stop.by: governor
|
|
|
79
78
|
control.stop.reason: <确定性原因>
|
|
80
79
|
```
|
|
81
80
|
|
|
82
|
-
治理器直接发送确定性 receipt,不开启诊断回合。先检查 Current Cycle
|
|
81
|
+
治理器直接发送确定性 receipt,不开启诊断回合。先检查 Current Cycle 和真实产物;修正范围或 deadline 后用 `/tasks resume <id>` 保留原阶段,或让 Agent cancel。
|
|
83
82
|
|
|
84
83
|
## Doctor 与损坏文件
|
|
85
84
|
|
|
86
85
|
`/tasks doctor` 的每条问题都带 Next step。重点检查:
|
|
87
86
|
|
|
88
87
|
- active 隐藏 future wake;
|
|
89
|
-
-
|
|
90
|
-
- waiting parked 是否有明确 user/job/verification 来源;
|
|
88
|
+
- waiting parked 是否有真实、可恢复的来源(有效 wake,或一条正在跑、`taskId` 指向本任务的 job/委派记录)——不看 `waitingFor` 写了什么;
|
|
91
89
|
- sleeping 的 schedule、wake 和 occurrence;
|
|
92
90
|
- enabled 与 stop 是否一致;
|
|
93
91
|
- required verification 的 attestation、contract hash、artifact subject;
|
|
94
|
-
-
|
|
92
|
+
- 不可读 frontmatter 或不可解析的 control(旧版本 control 会直接判为不可读,用 task_manage set 重写)。
|
|
95
93
|
|
|
96
94
|
修复 metadata 不执行外部动作。坏 frontmatter 会 fail-open 让问题显现;坏 control 先修 JSON,再用 task_manage set。daemon restart 后按任务文件重新恢复,仍须遵守幂等检查。
|
|
@@ -32,11 +32,9 @@ Task 创建即持续委托;是否触达外部系统由可用工具、security
|
|
|
32
32
|
|
|
33
33
|
## Control 决策
|
|
34
34
|
|
|
35
|
-
- `
|
|
36
|
-
- `nextAction
|
|
37
|
-
- `
|
|
38
|
-
- `waitingFor`:记录恢复源:time、user、job、verification 或 external-signal。
|
|
39
|
-
- `blockedReason`:写清楚等待的对象、条件和下一步。
|
|
35
|
+
- `deadline`:硬期限,表达真实用户意图;不用 `wake` 冒充 deadline。
|
|
36
|
+
- `nextAction`:下一条可执行动作,避免抽象愿望;也是等待时记录"等什么、条件、下一步"的地方——不再有单独的 blockedReason 字段。
|
|
37
|
+
- `waitingFor`:记录性展示,说明恢复源大致是 time、user、job 还是 external-signal;driver 是否恢复只看真实的 wake 或 run/job 记录,`waitingFor` 本身不影响恢复。
|
|
40
38
|
- `wake`:最早回访时间;future wake 会使任务规范为 waiting。
|
|
41
39
|
- `schedule`:五字段 cron;存在即 recurring。
|
|
42
40
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type AgentRunner } from "../agent/index.js";
|
|
2
2
|
import { type Executor } from "../executor.js";
|
|
3
3
|
import { PipiclawSettingsManager } from "../settings.js";
|
|
4
|
-
import {
|
|
4
|
+
import type { WakeTaskTransitionHooks } from "../tasks/store.js";
|
|
5
5
|
import { type BootstrapIO, type BootstrapPaths } from "./app-home.js";
|
|
6
6
|
import type { ChannelEvent } from "./channel-event.js";
|
|
7
7
|
import { DingTalkBot, type DingTalkConfig, type DingTalkHandler } from "./dingtalk.js";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, writeFileSync } from "fs";
|
|
2
1
|
import { join } from "path";
|
|
3
2
|
import { formatUnknownCommandMessage, isRunnerBuiltInCommand, parseBuiltInCommand, slashCommandName, } from "../agent/commands.js";
|
|
4
3
|
import { channelEffectCount, noteTaskEffects, taskEffectCount } from "../agent/effect-ledger.js";
|
|
@@ -22,7 +21,6 @@ import { errorMessage } from "../shared/text-utils.js";
|
|
|
22
21
|
import { loadDetachedSubAgentDiscovery } from "../subagents/detached-discovery.js";
|
|
23
22
|
import { configureSubAgentRuntime, getSubAgentRunManager, restoreAllSubAgentRuns, stopSubAgentGarbageCollector, } from "../subagents/runs.js";
|
|
24
23
|
import { readActiveTasks } from "../tasks/ledger.js";
|
|
25
|
-
import { finishTaskAttempt } from "../tasks/store.js";
|
|
26
24
|
import { getToolsConfigPath, loadToolsConfig, loadToolsConfigWithDiagnostics } from "../tools/config.js";
|
|
27
25
|
import { getUsageLedger } from "../usage/ledger.js";
|
|
28
26
|
import { parseUsageMode, renderUsageReport } from "../usage/render.js";
|
|
@@ -41,7 +39,7 @@ import { installLlmProxy } from "./proxy.js";
|
|
|
41
39
|
import { ChannelStore } from "./store.js";
|
|
42
40
|
import { handleSubagentsCommand as runSubagentsCommand } from "./subagent-commands.js";
|
|
43
41
|
import { pauseTask, handleTasksCommand as runTasksCommand } from "./task-commands.js";
|
|
44
|
-
import { createTaskDriverEvent,
|
|
42
|
+
import { createTaskDriverEvent, TaskDriver } from "./task-driver.js";
|
|
45
43
|
import { migrateLegacyTaskScheduleEvents, migrateLegacyTaskState } from "./task-migration.js";
|
|
46
44
|
import { claimVerifiedDelegationWake, claimVerifiedJobWake } from "./task-wake.js";
|
|
47
45
|
const SHUTDOWN_WAIT_MS = 15000;
|
|
@@ -181,14 +179,6 @@ export async function createRuntimeContext(options) {
|
|
|
181
179
|
// `bot` is defined below in this same scope and initialized before any message
|
|
182
180
|
// (and thus any getRunner call) can arrive.
|
|
183
181
|
mediaSender: bot,
|
|
184
|
-
dispatchVerification: async (taskId) => {
|
|
185
|
-
const entries = await readActiveTasks(join(channelDir, "tasks"));
|
|
186
|
-
const entry = entries.find((candidate) => candidate.id === taskId);
|
|
187
|
-
if (!entry)
|
|
188
|
-
return false;
|
|
189
|
-
const verificationEvent = createTaskVerificationEvent(channelId, entry, Date.now());
|
|
190
|
-
return (await durableDispatch?.dispatch(verificationEvent)) ?? false;
|
|
191
|
-
},
|
|
192
182
|
});
|
|
193
183
|
channelRunners.set(channelId, runner);
|
|
194
184
|
void evictIdleRunnersOverCap(channelRunners);
|
|
@@ -332,7 +322,7 @@ export async function createRuntimeContext(options) {
|
|
|
332
322
|
channelDir: getChannelDir(options.paths.workspaceDir, event.channelId),
|
|
333
323
|
workspaceDir: options.paths.workspaceDir,
|
|
334
324
|
channelId: event.channelId,
|
|
335
|
-
dispatchTask: async (id
|
|
325
|
+
dispatchTask: async (id) => {
|
|
336
326
|
const channelDir = getChannelDir(options.paths.workspaceDir, event.channelId);
|
|
337
327
|
const entry = (await readActiveTasks(join(channelDir, "tasks"))).find((candidate) => candidate.id === id);
|
|
338
328
|
if (!entry)
|
|
@@ -340,7 +330,7 @@ export async function createRuntimeContext(options) {
|
|
|
340
330
|
// A human asking to run a task twice means twice, so this key is deliberately
|
|
341
331
|
// unique per invocation rather than sharing the driver's occurrence key (D1).
|
|
342
332
|
const now = Date.now();
|
|
343
|
-
const driverEvent = createTaskDriverEvent(event.channelId, entry, now
|
|
333
|
+
const driverEvent = createTaskDriverEvent(event.channelId, entry, now);
|
|
344
334
|
return ((await durableDispatch?.dispatch({
|
|
345
335
|
...driverEvent,
|
|
346
336
|
dispatchId: `task:${event.channelId}:${entry.id}:manual:${new Date(now).toISOString()}`,
|
|
@@ -525,7 +515,7 @@ export async function createRuntimeContext(options) {
|
|
|
525
515
|
// y." or "[SUBAGENT:x] ... belongs to task y." — including another user, or an
|
|
526
516
|
// external agent's own untrusted stdout (spec 040, D8's threat model explicitly
|
|
527
517
|
// treats external output as untrusted). Activating a waiting task on text pattern
|
|
528
|
-
// alone lets that forged claim
|
|
518
|
+
// alone lets that forged claim wake an unrelated task early. The
|
|
529
519
|
// pattern match only extracts a *candidate* id pair now; both paths verify the
|
|
530
520
|
// named run/job actually exists, is done, and really is the one that names this
|
|
531
521
|
// taskId before ever calling `activateWaitingTask` (T9).
|
|
@@ -540,8 +530,6 @@ export async function createRuntimeContext(options) {
|
|
|
540
530
|
if (claimed) {
|
|
541
531
|
if (claimed.activated)
|
|
542
532
|
recoveredJobTaskId = claimed.taskId;
|
|
543
|
-
if (claimed.generation !== undefined)
|
|
544
|
-
event.taskAttemptGeneration = claimed.generation;
|
|
545
533
|
await claimed.finish();
|
|
546
534
|
structuredWakeFinalized = true;
|
|
547
535
|
if (event.internalWake?.kind === "job" && !claimed.activated)
|
|
@@ -569,8 +557,6 @@ export async function createRuntimeContext(options) {
|
|
|
569
557
|
if (claimed) {
|
|
570
558
|
if (claimed.activated)
|
|
571
559
|
recoveredDelegationTaskId = claimed.taskId;
|
|
572
|
-
if (claimed.generation !== undefined)
|
|
573
|
-
event.taskAttemptGeneration = claimed.generation;
|
|
574
560
|
await claimed.finish();
|
|
575
561
|
structuredWakeFinalized = true;
|
|
576
562
|
if (event.internalWake?.kind === "subagent" && !claimed.activated)
|
|
@@ -593,18 +579,6 @@ export async function createRuntimeContext(options) {
|
|
|
593
579
|
if (taskAttemptId) {
|
|
594
580
|
noteTaskEffects(event.channelId, taskAttemptId, channelEffectCount(event.channelId) - effectsBefore);
|
|
595
581
|
}
|
|
596
|
-
if (taskAttemptId && result.usage && result.durationMs !== undefined) {
|
|
597
|
-
await finishTaskAttempt(getChannelDir(options.paths.workspaceDir, event.channelId), taskAttemptId, {
|
|
598
|
-
tokens: result.usage.total,
|
|
599
|
-
costUsd: result.usage.cost.total,
|
|
600
|
-
costKnown: result.costKnown === true,
|
|
601
|
-
wallTimeMinutes: result.durationMs / 60_000,
|
|
602
|
-
failed: result.stopReason === "error" || result.stopReason === "aborted",
|
|
603
|
-
silent: result.silent,
|
|
604
|
-
finishedAt: new Date(),
|
|
605
|
-
generation: event.taskAttemptGeneration,
|
|
606
|
-
});
|
|
607
|
-
}
|
|
608
582
|
if (result.stopReason === "aborted" && runner.getTurnStatus().stopRequested) {
|
|
609
583
|
log.logInfo(`[${event.channelId}] Stopped`);
|
|
610
584
|
}
|
|
@@ -834,25 +808,15 @@ export async function createRuntimeContext(options) {
|
|
|
834
808
|
});
|
|
835
809
|
}
|
|
836
810
|
if (startServices) {
|
|
837
|
-
//
|
|
838
|
-
//
|
|
839
|
-
// relies on the
|
|
840
|
-
//
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
]).then(() => {
|
|
847
|
-
try {
|
|
848
|
-
mkdirSync(join(options.paths.appHomeDir, "state"), { recursive: true });
|
|
849
|
-
writeFileSync(taskMigrationMarkerPath, `${new Date().toISOString()}\n`);
|
|
850
|
-
}
|
|
851
|
-
catch (error) {
|
|
852
|
-
log.logWarning("Failed to write task migration marker", errorMessage(error));
|
|
853
|
-
}
|
|
854
|
-
});
|
|
855
|
-
}
|
|
811
|
+
// Close the 027/038 migration windows: fold any residual legacy `.schedule` events into task
|
|
812
|
+
// frontmatter, and upgrade any task still on the legacy control/status vocabulary, before the
|
|
813
|
+
// driver relies on the current contract alone. Version-gated, not marker-gated (spec 043,
|
|
814
|
+
// phase 5): each file is judged by what it actually contains, so this is safe and cheap to run
|
|
815
|
+
// on every startup — a hand-edited or freshly-restored legacy file self-heals on the next boot.
|
|
816
|
+
void Promise.all([
|
|
817
|
+
migrateLegacyTaskScheduleEvents(options.paths.workspaceDir),
|
|
818
|
+
migrateLegacyTaskState(options.paths.workspaceDir),
|
|
819
|
+
]);
|
|
856
820
|
eventsWatcher.start();
|
|
857
821
|
memoryMaintenanceScheduler.start();
|
|
858
822
|
taskDriver.start();
|
|
@@ -32,10 +32,4 @@ export interface ChannelEvent {
|
|
|
32
32
|
taskId: string;
|
|
33
33
|
dispatchId: string;
|
|
34
34
|
};
|
|
35
|
-
/**
|
|
36
|
-
* The `attemptGeneration` this event's claim recorded, for `[TASK_DRIVER:id]` events only.
|
|
37
|
-
* Carried through durable dispatch so `finishTaskAttempt` can tell a stale, superseded claim's
|
|
38
|
-
* turn from the current one, even when redelivery or claim races reorder completions.
|
|
39
|
-
*/
|
|
40
|
-
taskAttemptGeneration?: number;
|
|
41
35
|
}
|
|
@@ -6,7 +6,7 @@ export interface HandleTasksCommandOptions {
|
|
|
6
6
|
workspaceDir?: string;
|
|
7
7
|
channelId?: string;
|
|
8
8
|
/** Optional immediate task wake, available in the long-lived DingTalk runtime. */
|
|
9
|
-
dispatchTask?: (id: string
|
|
9
|
+
dispatchTask?: (id: string) => Promise<boolean>;
|
|
10
10
|
}
|
|
11
11
|
export declare function pauseTask(options: HandleTasksCommandOptions, idInput: string): Promise<string>;
|
|
12
12
|
export declare function resumeTask(options: HandleTasksCommandOptions, idInput: string): Promise<string>;
|