nx-kv 0.65.2 → 0.65.3
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/CHANGELOG.md +23 -0
- package/package.json +1 -1
- package/src/core/db/settings.ts +1 -1
- package/src/core/instruction-template.ts +1 -1
- package/src/core/workflow/plugin-registry.ts +1 -1
- package/src/core/workflow/types.ts +4 -4
- package/src/modules/claim/actions/_manifest.generated.ts +23 -0
- package/src/modules/{localtask → claim}/actions/localtask-claim.ts +4 -4
- package/src/modules/{localtask → claim}/actions/localtask-preview.ts +4 -4
- package/src/modules/{localtask → claim}/actions/localtask-wait.ts +4 -4
- package/src/modules/{tasktool → claim}/get.ts +2 -2
- package/src/modules/claim/index.ts +25 -0
- package/src/modules/{tasktool → claim}/panel-escort.ts +2 -2
- package/src/modules/{tasktool → claim}/params.ts +1 -1
- package/src/modules/{tasktool → claim}/wait.ts +5 -5
- package/src/modules/{tasktool/plugins → claim}/waitgoal-config.ts +3 -3
- package/src/modules/{promptplug/delivery.ts → delivery/assemble.ts} +5 -5
- package/src/modules/{tasktool → delivery}/attach-resource.ts +2 -2
- package/src/modules/{tasktool → delivery}/attach-template.ts +1 -1
- package/src/modules/{tasktool → delivery}/attach.ts +1 -1
- package/src/modules/{tasktool → delivery}/delivery-text.ts +2 -2
- package/src/modules/{tasktool → delivery}/doc-inline.ts +1 -1
- package/src/modules/{tasktool → delivery}/groupctx.ts +1 -1
- package/src/modules/{tasktool/delivery.ts → delivery/host.ts} +4 -4
- package/src/modules/delivery/index.ts +18 -0
- package/src/modules/{tasktool → delivery}/preview.ts +4 -4
- package/src/modules/{tasktool → goals}/actions/timegoal-check.ts +1 -1
- package/src/modules/{tasktool → goals}/actions/timegoal-clear.ts +1 -1
- package/src/modules/{tasktool → goals}/actions/timegoal-list.ts +1 -1
- package/src/modules/{tasktool → goals}/actions/timegoal-log.ts +1 -1
- package/src/modules/{tasktool → goals}/actions/timegoal-set.ts +1 -1
- package/src/modules/{tasktool → goals}/actions/timegoal-show.ts +1 -1
- package/src/modules/{tasktool → goals}/actions/timegoal-update.ts +1 -1
- package/src/modules/goals/index.ts +25 -0
- package/src/modules/{tasktool → goals}/plugins/discover.ts +3 -3
- package/src/modules/{tasktool → goals}/plugins/index.ts +0 -2
- package/src/modules/{tasktool → goals}/plugins/taskgoal-store.ts +2 -2
- package/src/modules/localtask/action-render.ts +1 -1
- package/src/modules/localtask/actions/_manifest.generated.ts +0 -9
- package/src/modules/localtask/actions/localtask-add.ts +2 -2
- package/src/modules/localtask/actions/localtask-attach-note.ts +1 -1
- package/src/modules/localtask/actions/localtask-attach.ts +1 -1
- package/src/modules/localtask/actions/localtask-attachments.ts +1 -1
- package/src/modules/localtask/actions/localtask-detach.ts +1 -1
- package/src/modules/localtask/actions/localtask-get.ts +1 -1
- package/src/modules/localtask/actions/localtask-reopen.ts +1 -1
- package/src/modules/localtask/actions/localtask-timegoalLog.ts +1 -1
- package/src/modules/localtask/actions/localtask-update.ts +2 -2
- package/src/modules/{tasktool → localtask}/add.ts +3 -3
- package/src/modules/localtask/engine.ts +1 -1
- package/src/modules/{tasktool → localtask}/group-store.ts +2 -2
- package/src/modules/localtask/mutator/index.ts +1 -1
- package/src/modules/localtask/panel-presence.ts +2 -2
- package/src/modules/localtask/scheduler/state-drive.ts +1 -1
- package/src/modules/{tasktool → localtask}/support.ts +1 -1
- package/src/modules/localtask/task-lifecycle.ts +4 -4
- package/src/modules/localtask/task-ops.ts +1 -1
- package/src/modules/localtask/task-templates.ts +1 -1
- package/src/modules/localtask/task-view.ts +1 -1
- package/src/modules/{tasktool → localtask}/update.ts +1 -1
- package/src/modules/localtask/waiters.ts +1 -1
- package/src/modules/localtask/writes.ts +1 -1
- package/src/modules/promptplug/factory.ts +2 -2
- package/src/modules/promptplug/index.ts +4 -6
- package/src/modules/promptplug/plugins/attachment.ts +1 -1
- package/src/modules/promptplug/plugins/context.ts +1 -1
- package/src/modules/promptplug/plugins/goal-prompt.ts +1 -1
- package/src/modules/repos/service/crud.ts +1 -1
- package/src/runtime/registry.ts +6 -2
- package/src/web/frontend/api/cli-tree.json +138 -138
- package/src/web/frontend/api/client.generated.ts +90 -88
- package/src/core/workflow/edges.ts +0 -28
- package/src/core/workflow/layout.ts +0 -118
- package/src/modules/tasktool/facade/get.ts +0 -54
- package/src/modules/tasktool/facade/index.ts +0 -4
- package/src/modules/tasktool/facade/submit.ts +0 -61
- package/src/modules/tasktool/facade/wait.ts +0 -3
- package/src/modules/tasktool/getloop.ts +0 -2
- package/src/modules/tasktool/index.ts +0 -24
- package/src/modules/tasktool/plugins/runtime.ts +0 -73
- package/src/modules/tasktool/plugins/waitgoal.ts +0 -71
- /package/src/modules/{tasktool → goals}/actions/_manifest.generated.ts +0 -0
- /package/src/modules/{tasktool → goals}/actions/timegoal-prune.ts +0 -0
- /package/src/modules/{tasktool → goals}/plugins/base.ts +0 -0
- /package/src/modules/{tasktool → goals}/plugins/blockgoal.ts +0 -0
- /package/src/modules/{tasktool → goals}/plugins/container.ts +0 -0
- /package/src/modules/{tasktool → goals}/plugins/taskgoal.ts +0 -0
- /package/src/modules/{tasktool → goals}/plugins/timegoal-core-store.ts +0 -0
- /package/src/modules/{tasktool → goals}/plugins/timegoal-cwd-store.ts +0 -0
- /package/src/modules/{tasktool → goals}/plugins/timegoal-store.ts +0 -0
- /package/src/modules/{tasktool → goals}/plugins/timegoal-task-store.ts +0 -0
- /package/src/modules/{tasktool → goals}/plugins/timegoal.ts +0 -0
- /package/src/modules/{tasktool → goals}/taskgoal.ts +0 -0
- /package/src/modules/{tasktool → goals}/timegoal.ts +0 -0
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { edgesFromTasks } from './types.js';
|
|
2
|
-
import type { WorkflowSnapshot } from './types.js';
|
|
3
|
-
|
|
4
|
-
export { edgesFromTasks };
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 从快照边表收集某节点的前驱 id。
|
|
8
|
-
*/
|
|
9
|
-
export function predecessorsOf(snap: WorkflowSnapshot, nodeId: string | number): Array<string | number> {
|
|
10
|
-
const id = String(nodeId);
|
|
11
|
-
const out: Array<string | number> = [];
|
|
12
|
-
for (const e of snap?.edges || []) {
|
|
13
|
-
if (String(e.to) === id) out.push(e.from);
|
|
14
|
-
}
|
|
15
|
-
return out;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* 某节点的后继 id。
|
|
20
|
-
*/
|
|
21
|
-
export function successorsOf(snap: WorkflowSnapshot, nodeId: string | number): Array<string | number> {
|
|
22
|
-
const id = String(nodeId);
|
|
23
|
-
const out: Array<string | number> = [];
|
|
24
|
-
for (const e of snap?.edges || []) {
|
|
25
|
-
if (String(e.from) === id) out.push(e.to);
|
|
26
|
-
}
|
|
27
|
-
return out;
|
|
28
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
// workflow 目标目录规范(按 nx-kv 分层 + 语义子目录)。
|
|
2
|
-
//
|
|
3
|
-
// 原则
|
|
4
|
-
// 1. 禁止平行顶层 src/{facade,store,mutator,scheduler,plugins}/。
|
|
5
|
-
// 同名语义**必须**落在 modules 或 core/workflow 的子目录里。
|
|
6
|
-
// 2. **全部 goal 同一目录、每种一份**——block / wait / time / task 都在
|
|
7
|
-
// tasktool/plugins/;禁止再拆「core 一份 + modules 一份」。
|
|
8
|
-
// 3. localtask = 写侧(store/mutator/scheduler/bus);
|
|
9
|
-
// tasktool = 消费门面 + goal 族;二者成对,允许互引
|
|
10
|
-
// (scheduler 调 blockgoal → import tasktool/plugins 即可)。
|
|
11
|
-
// 4. 面板只吃 /api;两端同构投影才进 shared/。
|
|
12
|
-
// 5. JS ESM only;子目录均带 index.js 桶文件对外导出。
|
|
13
|
-
//
|
|
14
|
-
// 依赖方向(单向)
|
|
15
|
-
// web → modules → core/workflow → Node 内置
|
|
16
|
-
// tasktool/facade ──▶ localtask/{store,mutator}
|
|
17
|
-
// localtask/scheduler ──▶ tasktool/plugins/blockgoal + core readiness + bus
|
|
18
|
-
// localtask/mutator ──▶ localtask/store
|
|
19
|
-
// tasktool/plugins/runtime ──▶ 同目录各 goal
|
|
20
|
-
//
|
|
21
|
-
// ---------------------------------------------------------------------------
|
|
22
|
-
// 目标树(✅ 已有 / ○ 待落地 / → 自现状迁入)
|
|
23
|
-
// ---------------------------------------------------------------------------
|
|
24
|
-
//
|
|
25
|
-
// src/core/workflow/
|
|
26
|
-
// ├── types.js ✅
|
|
27
|
-
// ├── snapshot.example.json ✅
|
|
28
|
-
// ├── layout.js ✅ 本规范
|
|
29
|
-
// ├── readiness.js ✅ 自 dag 下沉
|
|
30
|
-
// ├── edges.js ✅
|
|
31
|
-
// ├── event-names.js ✅
|
|
32
|
-
// └── plugin-registry.js ✅ 按 name / scope 校验
|
|
33
|
-
//
|
|
34
|
-
// src/modules/localtask/
|
|
35
|
-
// ├── index.js / service.js ✅ 模块壳;complete → refreshTopicAfterComplete
|
|
36
|
-
// ├── dag.js ✅ 再导出 readiness
|
|
37
|
-
// ├── engine.js / writes.js ✅ 主题引擎;DAG 日常写经 Mutator
|
|
38
|
-
// ├── store/ ✅ SnapshotStore + memory/file/topic adapter
|
|
39
|
-
// ├── bus/ mutator/ scheduler/ ✅
|
|
40
|
-
//
|
|
41
|
-
// src/modules/tasktool/
|
|
42
|
-
// ├── index.js ✅
|
|
43
|
-
// ├── facade/ ✅ submit/get/wait 再导出
|
|
44
|
-
// ├── plugins/ ✅ 目录扫描 IoC + 实现同目录
|
|
45
|
-
// │ ├── discover.js 扫描注册(跳过 *-store/*-config)
|
|
46
|
-
// │ ├── *-store.js / waitgoal-config 原 timegoal/taskgoal/getloop 迁入
|
|
47
|
-
// │ └── block|wait|time|task goal.js definePlugin
|
|
48
|
-
// ├── facade/ ✅ submit→store+入队;get→AsyncIterable
|
|
49
|
-
// ├── groupctx.js / attach.js ✅
|
|
50
|
-
// └── getloop/timegoal/taskgoal.js ✅ 薄再导出 → plugins/*
|
|
51
|
-
//
|
|
52
|
-
// 为何 blockgoal 也进 tasktool/plugins(不留 core)
|
|
53
|
-
// goal 是插件族,视觉与注册平级;拆到 core 会造成「调度 goal 一套路径、
|
|
54
|
-
// 消费 goal 另一套路径」。localtask↔tasktool 本就可配对互引,scheduler
|
|
55
|
-
// 直接 import blockgoal 即可,无需为避依赖把家族拆开。
|
|
56
|
-
//
|
|
57
|
-
// ---------------------------------------------------------------------------
|
|
58
|
-
|
|
59
|
-
export const TARGET_PATHS: Readonly<Record<string, string>> = Object.freeze({
|
|
60
|
-
'core types': 'src/core/workflow/types.js',
|
|
61
|
-
'snapshot example': 'src/core/workflow/snapshot.example.json',
|
|
62
|
-
'this layout norm': 'src/core/workflow/layout.js',
|
|
63
|
-
readiness: 'src/core/workflow/readiness.js',
|
|
64
|
-
'plugin registry': 'src/core/workflow/plugin-registry.js',
|
|
65
|
-
'store/': 'src/modules/localtask/store/',
|
|
66
|
-
'store barrel': 'src/modules/localtask/store/index.js',
|
|
67
|
-
'store file-adapter': 'src/modules/localtask/store/file-adapter.js',
|
|
68
|
-
'store memory-adapter': 'src/modules/localtask/store/memory-adapter.js',
|
|
69
|
-
'bus/': 'src/modules/localtask/bus/',
|
|
70
|
-
'bus barrel': 'src/modules/localtask/bus/index.js',
|
|
71
|
-
'mutator/': 'src/modules/localtask/mutator/',
|
|
72
|
-
'mutator barrel': 'src/modules/localtask/mutator/index.js',
|
|
73
|
-
'mutator validate': 'src/modules/localtask/mutator/validate.js',
|
|
74
|
-
'scheduler/': 'src/modules/localtask/scheduler/',
|
|
75
|
-
'scheduler barrel': 'src/modules/localtask/scheduler/index.js',
|
|
76
|
-
'scheduler state-drive': 'src/modules/localtask/scheduler/state-drive.js',
|
|
77
|
-
'facade/': 'src/modules/tasktool/facade/',
|
|
78
|
-
'facade barrel': 'src/modules/tasktool/facade/index.js',
|
|
79
|
-
'facade submit': 'src/modules/tasktool/facade/submit.js',
|
|
80
|
-
'facade get': 'src/modules/tasktool/facade/get.js',
|
|
81
|
-
'facade wait': 'src/modules/tasktool/facade/wait.js',
|
|
82
|
-
'plugins/': 'src/modules/tasktool/plugins/',
|
|
83
|
-
'plugins barrel': 'src/modules/tasktool/plugins/index.js',
|
|
84
|
-
'plugins runtime': 'src/modules/tasktool/plugins/runtime.js',
|
|
85
|
-
blockgoal: 'src/modules/tasktool/plugins/blockgoal.js',
|
|
86
|
-
waitgoal: 'src/modules/tasktool/plugins/waitgoal.js',
|
|
87
|
-
timegoal: 'src/modules/tasktool/plugins/timegoal.js',
|
|
88
|
-
taskgoal: 'src/modules/tasktool/plugins/taskgoal.js',
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
/** 全部 goal 唯一落点(同一目录;禁止第二份) */
|
|
92
|
-
export const GOAL_HOMES = Object.freeze({
|
|
93
|
-
blockgoal: 'src/modules/tasktool/plugins/blockgoal.js',
|
|
94
|
-
waitgoal: 'src/modules/tasktool/plugins/waitgoal.js',
|
|
95
|
-
timegoal: 'src/modules/tasktool/plugins/timegoal.js',
|
|
96
|
-
taskgoal: 'src/modules/tasktool/plugins/taskgoal.js',
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
/** 必须出现的语义子目录(相对仓库根) */
|
|
100
|
-
export const REQUIRED_SEMANTIC_DIRS = Object.freeze([
|
|
101
|
-
'src/modules/localtask/store',
|
|
102
|
-
'src/modules/localtask/bus',
|
|
103
|
-
'src/modules/localtask/mutator',
|
|
104
|
-
'src/modules/localtask/scheduler',
|
|
105
|
-
'src/modules/tasktool/facade',
|
|
106
|
-
'src/modules/tasktool/plugins',
|
|
107
|
-
]);
|
|
108
|
-
|
|
109
|
-
/** 禁止的平行顶层 */
|
|
110
|
-
export const FORBIDDEN_TOP_LEVEL = Object.freeze([
|
|
111
|
-
'src/facade',
|
|
112
|
-
'src/store',
|
|
113
|
-
'src/mutator',
|
|
114
|
-
'src/scheduler',
|
|
115
|
-
'src/plugins',
|
|
116
|
-
'src/bus',
|
|
117
|
-
'src/core/types',
|
|
118
|
-
]);
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
// Facade get(workflowId, nodeId?) → AsyncIterable
|
|
2
|
-
// 真实现:PluginRuntime.runGetHooks + pull=consumeFirstPending;
|
|
3
|
-
// getTask 仍给 CLI/agent 单次领取(内部可走 wait)。
|
|
4
|
-
import '../plugins/index.js';
|
|
5
|
-
import { runGetHooks } from '../plugins/runtime.js';
|
|
6
|
-
import { createTopicSnapshotStore } from '../../localtask/store/index.js';
|
|
7
|
-
import { getTask as getTaskImpl } from '../get.js';
|
|
8
|
-
|
|
9
|
-
export interface FacadeGetOptions {
|
|
10
|
-
signal?: AbortSignal;
|
|
11
|
-
summary?: string;
|
|
12
|
-
pull?: () => Promise<unknown | null>;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* 引擎态异步迭代领取。
|
|
17
|
-
* @param workflowId 主题 key
|
|
18
|
-
*/
|
|
19
|
-
export async function* get(
|
|
20
|
-
workflowId: string,
|
|
21
|
-
nodeId?: string | number,
|
|
22
|
-
opts: FacadeGetOptions = {},
|
|
23
|
-
): AsyncGenerator<any, void, unknown> {
|
|
24
|
-
const store = await createTopicSnapshotStore();
|
|
25
|
-
let snap: any;
|
|
26
|
-
try {
|
|
27
|
-
snap = await store.load(workflowId);
|
|
28
|
-
} catch (err) {
|
|
29
|
-
if ((err as any)?.code === 'NOT_FOUND') return;
|
|
30
|
-
throw err;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const pull =
|
|
34
|
-
opts.pull ||
|
|
35
|
-
(async () => {
|
|
36
|
-
const { consumeFirstPending } = await import('../../localtask/service.js');
|
|
37
|
-
return consumeFirstPending(workflowId, opts.summary || '', {
|
|
38
|
-
key: workflowId,
|
|
39
|
-
name: snap.meta?.name || workflowId,
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
yield* runGetHooks(
|
|
44
|
-
{ snapshot: snap, nodeId, signal: opts.signal },
|
|
45
|
-
{ pull },
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/** CLI/agent 兼容:单次领取(原 getTask) */
|
|
50
|
-
export async function getTask(args: any): Promise<Record<string, any>> {
|
|
51
|
-
return getTaskImpl(args);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export { getTaskImpl };
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
// Facade submit(initMeta) → workflowId
|
|
2
|
-
// 语义:只确保主题/工作流存在;有 text 则入队(不在此构造全图)。
|
|
3
|
-
import { submitTask } from '../add.js';
|
|
4
|
-
import { createTopicSnapshotStore } from '../../localtask/store/index.js';
|
|
5
|
-
|
|
6
|
-
/** submit 的入参(core/workflow InitMeta 的宽松形态 + 任意附加键) */
|
|
7
|
-
export interface FacadeSubmitMeta {
|
|
8
|
-
cwd?: string;
|
|
9
|
-
key?: string;
|
|
10
|
-
text?: unknown;
|
|
11
|
-
blockBy?: unknown;
|
|
12
|
-
blocksFollowing?: boolean;
|
|
13
|
-
gate?: boolean;
|
|
14
|
-
meta?: Record<string, unknown>;
|
|
15
|
-
[k: string]: any;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @returns Promise<{ workflowId: string, key: string, cwd?: string, name?: string, task?: object, status: string }>
|
|
20
|
-
*/
|
|
21
|
-
export async function submit(initMeta: FacadeSubmitMeta = {}): Promise<Record<string, any>> {
|
|
22
|
-
const { normalizeCwd } = await import('../../localtask/service.js');
|
|
23
|
-
// paths.normalizeCwd 的 @returns 标注漏了 name(运行时恒返回 {cwd, name, key})
|
|
24
|
-
const { key, cwd, name } = normalizeCwd(initMeta.cwd || initMeta.key) as { cwd: string; key: string; name: string };
|
|
25
|
-
|
|
26
|
-
// SnapshotStore:确保 workflow 桶存在(topic adapter 会建主题壳)
|
|
27
|
-
const store = await createTopicSnapshotStore();
|
|
28
|
-
try {
|
|
29
|
-
await store.load(key);
|
|
30
|
-
} catch (err) {
|
|
31
|
-
if ((err as any)?.code === 'NOT_FOUND') {
|
|
32
|
-
await store.create({ key, cwd, meta: { name, ...(initMeta.meta || {}) } });
|
|
33
|
-
} else {
|
|
34
|
-
throw err;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (initMeta.text != null && String(initMeta.text).trim()) {
|
|
39
|
-
const added = await submitTask({
|
|
40
|
-
cwd,
|
|
41
|
-
text: initMeta.text,
|
|
42
|
-
blockBy: initMeta.blockBy,
|
|
43
|
-
blocksFollowing: initMeta.blocksFollowing ?? initMeta.gate,
|
|
44
|
-
...(initMeta.meta || {}),
|
|
45
|
-
});
|
|
46
|
-
return {
|
|
47
|
-
status: 'ok',
|
|
48
|
-
workflowId: key,
|
|
49
|
-
key,
|
|
50
|
-
cwd: added.cwd ?? cwd,
|
|
51
|
-
name: added.name ?? name,
|
|
52
|
-
task: added.task,
|
|
53
|
-
delivered: added.delivered,
|
|
54
|
-
queued: added.queued,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return { status: 'ok', workflowId: key, key, cwd, name, created: true };
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export { submitTask };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// tasktool 模块(模板形态):只做装配——模块元信息 + 从 action 清单建实例。
|
|
2
|
-
//
|
|
3
|
-
// action 清单由 `pnpm gen:actions` 扫 actions/ 目录生成(actions/_manifest.generated.ts),
|
|
4
|
-
// 本文件**不手工列举** action 类——加一条 action = 新建一个文件 + 跑一次生成。
|
|
5
|
-
import { ModuleBase } from '../../runtime/types/module.js';
|
|
6
|
-
import { zodActionsOf, type ZodBoundAction } from '../../runtime/action-decorator.js';
|
|
7
|
-
import { container, type Container } from '../../runtime/container.js';
|
|
8
|
-
import { ACTIONS } from './actions/_manifest.generated.js';
|
|
9
|
-
|
|
10
|
-
export class TasktoolModule extends ModuleBase {
|
|
11
|
-
override readonly id = 'tasktool';
|
|
12
|
-
override readonly title = "任务工具(timegoal 时间目标 / waitgoal 等待与领取;UI 嵌入在「本地任务」主题卡里)";
|
|
13
|
-
override readonly order = 21;
|
|
14
|
-
|
|
15
|
-
override readonly actions: readonly ZodBoundAction[];
|
|
16
|
-
|
|
17
|
-
constructor(c: Container = container) {
|
|
18
|
-
super();
|
|
19
|
-
this.actions = ACTIONS.flatMap((Cls) => zodActionsOf(c.create(Cls)));
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const tasktoolModule = new TasktoolModule();
|
|
24
|
-
export default tasktoolModule;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
// PluginRuntime —— 只依赖 container(控制反转);插件自注册后按契约调钩子。
|
|
2
|
-
import { getPlugin, requirePlugin } from './container.js';
|
|
3
|
-
import type { BasePlugin, PluginContext } from './base.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 只跑 scope=control 的 onSchedule。
|
|
7
|
-
* @param ctx
|
|
8
|
-
*/
|
|
9
|
-
export function runScheduleHooks(ctx: PluginContext): unknown[] {
|
|
10
|
-
const snap = ctx.snapshot;
|
|
11
|
-
const results: unknown[] = [];
|
|
12
|
-
const node = (snap.nodes || []).find((n) => String(n.id) === String(ctx.nodeId));
|
|
13
|
-
for (const spec of node?.plugins || []) {
|
|
14
|
-
if (spec.scope !== 'control' && spec.name !== 'blockgoal') continue;
|
|
15
|
-
const impl = getPlugin(spec.name);
|
|
16
|
-
if (!impl) continue;
|
|
17
|
-
results.push(impl.onSchedule(ctx, spec.config || {}));
|
|
18
|
-
}
|
|
19
|
-
return results;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* 消费侧:timegoal(workflow)包裹 waitgoal(node)。
|
|
24
|
-
* @param ctx
|
|
25
|
-
* @param opts
|
|
26
|
-
*/
|
|
27
|
-
export async function* runGetHooks(
|
|
28
|
-
ctx: PluginContext,
|
|
29
|
-
opts: { pull?: () => Promise<unknown | null> } = {},
|
|
30
|
-
): AsyncGenerator<unknown, void, unknown> {
|
|
31
|
-
const snap = ctx.snapshot;
|
|
32
|
-
const wfTime = (snap.workflowPlugins || []).find((p) => p.name === 'timegoal');
|
|
33
|
-
const node =
|
|
34
|
-
ctx.nodeId != null
|
|
35
|
-
? (snap.nodes || []).find((n) => String(n.id) === String(ctx.nodeId))
|
|
36
|
-
: null;
|
|
37
|
-
const nodeWait = (node?.plugins || []).find((p) => p.name === 'waitgoal');
|
|
38
|
-
|
|
39
|
-
const waitPlugin = getPlugin('waitgoal');
|
|
40
|
-
const waitConfig: Record<string, unknown> = {
|
|
41
|
-
...(nodeWait?.config || {}),
|
|
42
|
-
pull: opts.pull,
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const once = (): AsyncGenerator<unknown, void, unknown> => {
|
|
46
|
-
if (!waitPlugin) return empty();
|
|
47
|
-
return waitPlugin.onGet({ ...ctx, env: { ...(ctx.env || {}), pull: opts.pull } }, waitConfig);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
if (wfTime) {
|
|
51
|
-
const timePlugin = requirePlugin('timegoal');
|
|
52
|
-
yield* timePlugin.onGet(
|
|
53
|
-
{ ...ctx, env: { ...(ctx.env || {}), inner: once } },
|
|
54
|
-
{ ...(wfTime.config || {}), inner: once },
|
|
55
|
-
);
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
yield* once();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async function* empty(): AsyncGenerator<unknown, void, unknown> {
|
|
62
|
-
/* no waitgoal registered */
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/** @deprecated 兼容旧测试:按需取实例 */
|
|
66
|
-
export function getBY_NAME(): Record<string, BasePlugin | null> {
|
|
67
|
-
return {
|
|
68
|
-
blockgoal: getPlugin('blockgoal'),
|
|
69
|
-
waitgoal: getPlugin('waitgoal'),
|
|
70
|
-
timegoal: getPlugin('timegoal'),
|
|
71
|
-
taskgoal: getPlugin('taskgoal'),
|
|
72
|
-
};
|
|
73
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// waitgoal —— 节点级消费 goal(唯一落点:契约类 + 配置同目录)
|
|
2
|
-
import { BasePlugin, definePlugin, type PluginContext } from './base.js';
|
|
3
|
-
import {
|
|
4
|
-
GET_LOOP_DEFAULT_MINUTES,
|
|
5
|
-
sanitizeGetLoop,
|
|
6
|
-
getLoopForCwd,
|
|
7
|
-
} from './waitgoal-config.js';
|
|
8
|
-
|
|
9
|
-
export {
|
|
10
|
-
GET_LOOP_DEFAULT_MINUTES,
|
|
11
|
-
sanitizeGetLoop,
|
|
12
|
-
getLoopForCwd,
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
class WaitGoalPlugin extends BasePlugin {
|
|
16
|
-
static override id = 'waitgoal';
|
|
17
|
-
static override scope = 'node' as const;
|
|
18
|
-
|
|
19
|
-
override onBind(_ctx: PluginContext, config: Record<string, unknown> = {}): Record<string, unknown> {
|
|
20
|
-
const minutes = Number(config.waitMinutes ?? config.minutes);
|
|
21
|
-
if (minutes != null && Number.isFinite(minutes) && minutes <= 0) {
|
|
22
|
-
throw new Error('waitgoal.waitMinutes must be > 0');
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
waitMinutes:
|
|
26
|
-
Number.isFinite(minutes) && minutes > 0 ? Math.floor(minutes) : GET_LOOP_DEFAULT_MINUTES,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
override async *onGet(ctx: PluginContext = {} as PluginContext, config: Record<string, unknown> = {}): AsyncGenerator<unknown, void, unknown> {
|
|
31
|
-
const waitMinutes = Number(config.waitMinutes) || GET_LOOP_DEFAULT_MINUTES;
|
|
32
|
-
const timeoutMs = Math.min(Math.max(waitMinutes, 0.05), 10) * 60_000;
|
|
33
|
-
const pull =
|
|
34
|
-
typeof config.pull === 'function'
|
|
35
|
-
? (config.pull as () => Promise<unknown | null>)
|
|
36
|
-
: typeof ctx.env?.pull === 'function'
|
|
37
|
-
? (ctx.env.pull as () => Promise<unknown | null>)
|
|
38
|
-
: async () => null;
|
|
39
|
-
const deadline = Date.now() + timeoutMs;
|
|
40
|
-
const signal = ctx.signal;
|
|
41
|
-
|
|
42
|
-
while (Date.now() < deadline) {
|
|
43
|
-
if (signal?.aborted) return;
|
|
44
|
-
const item = await pull();
|
|
45
|
-
if (item != null) {
|
|
46
|
-
yield item;
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
await sleep(Math.min(200, deadline - Date.now()), signal);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function sleep(ms: number, signal?: AbortSignal): Promise<void> {
|
|
55
|
-
if (ms <= 0) return Promise.resolve();
|
|
56
|
-
return new Promise((resolve) => {
|
|
57
|
-
const t = setTimeout(resolve, ms);
|
|
58
|
-
signal?.addEventListener(
|
|
59
|
-
'abort',
|
|
60
|
-
() => {
|
|
61
|
-
clearTimeout(t);
|
|
62
|
-
resolve();
|
|
63
|
-
},
|
|
64
|
-
{ once: true },
|
|
65
|
-
);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const instance = definePlugin(WaitGoalPlugin);
|
|
70
|
-
export default instance;
|
|
71
|
-
export { WaitGoalPlugin };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|