nx-kv 0.66.2 → 0.67.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/CHANGELOG.md +69 -0
- package/assets/nx-kv/references/A02-/346/217/220/344/272/244/344/273/273/345/212/241.md +6 -7
- package/assets/nx-kv/references/A03-/346/226/207/346/241/243/344/270/216/345/275/222/345/261/236.md +1 -1
- package/assets/nx-kv/references/B02-CLI/351/200/237/346/237/245.md +2 -2
- package/package.json +1 -1
- package/src/core/attachmentdb/ids.ts +14 -1
- package/src/core/attachmentdb/query.ts +0 -38
- package/src/core/attachmentdb/repo.ts +98 -0
- package/src/core/attachmentdb.ts +5 -1
- package/src/core/db/import-json/tasks.ts +10 -9
- package/src/core/db/import-json.ts +16 -6
- package/src/core/db/index.ts +1 -1
- package/src/core/db/migrations/index.ts +2 -0
- package/src/core/db/migrations/v15.sql +88 -0
- package/src/core/db/verify.ts +7 -3
- package/src/core/db/version.ts +4 -1
- package/src/core/topic-key.ts +5 -8
- package/src/core/workflow/readiness.ts +1 -1
- package/src/core/workflow/types.ts +1 -1
- package/src/modules/claim/assemble.ts +0 -5
- package/src/modules/claim/host.ts +2 -4
- package/src/modules/claim/preview.ts +0 -1
- package/src/modules/claim/wait.ts +9 -49
- package/src/modules/docs/actions/docs-detach.ts +1 -2
- package/src/modules/docs/attach.ts +3 -17
- package/src/modules/docs/render.ts +4 -13
- package/src/modules/localtask/actions/localtask-add.ts +1 -3
- package/src/modules/localtask/actions/localtask-attach.ts +4 -2
- package/src/modules/localtask/actions/localtask-boardtasks.ts +0 -1
- package/src/modules/localtask/actions/localtask-clone.ts +1 -1
- package/src/modules/localtask/actions/localtask-config.ts +2 -11
- package/src/modules/localtask/actions/localtask-detach.ts +1 -3
- package/src/modules/localtask/infra/events.ts +5 -5
- package/src/modules/localtask/infra/repo/rows.ts +0 -1
- package/src/modules/localtask/infra/repo/settings.ts +1 -9
- package/src/modules/localtask/infra/repo/topics.ts +0 -4
- package/src/modules/localtask/lifecycle/add.ts +2 -9
- package/src/modules/localtask/lifecycle/deletion.ts +7 -15
- package/src/modules/localtask/lifecycle/task-lifecycle.ts +2 -2
- package/src/modules/localtask/lifecycle/task-ops.ts +14 -56
- package/src/modules/localtask/lifecycle/task-templates.ts +0 -13
- package/src/modules/localtask/lifecycle/task-view.ts +2 -3
- package/src/modules/localtask/lifecycle/topics.ts +3 -8
- package/src/modules/localtask/ops/attach-resource.ts +46 -4
- package/src/modules/localtask/ops/attach-template.ts +73 -3
- package/src/modules/localtask/ops/attach.ts +45 -18
- package/src/modules/localtask/paths.ts +7 -17
- package/src/modules/localtask/service.ts +3 -7
- package/src/modules/localtask/ui/action-flags.ts +2 -2
- package/src/modules/localtask/ui/action-render.ts +7 -19
- package/src/modules/localtask/waiting.ts +1 -8
- package/src/modules/promptplug/compose.ts +1 -3
- package/src/modules/promptplug/plugins/attachment.ts +56 -6
- package/src/modules/promptplug/plugins/context.ts +11 -2
- package/src/modules/promptplug/template-store.ts +25 -3
- package/src/modules/templates/scope.ts +1 -1
- package/src/shared/prompt-blocks.ts +2 -23
- package/src/web/frontend/App.tsx +4 -9
- package/src/web/frontend/api/cli-tree.json +6 -6
- package/src/web/frontend/api/client.generated.ts +11 -11
- package/src/web/frontend/api/tasks.ts +117 -0
- package/src/web/frontend/components/Introduction/index.tsx +50 -3
- package/src/web/frontend/components/Introduction/style.css +6 -0
- package/src/web/frontend/components/Introduction/use-intro.ts +25 -0
- package/src/web/frontend/components/md/attachments/attach-area.tsx +9 -11
- package/src/web/frontend/components/md/attachments/attach-common.ts +12 -5
- package/src/web/frontend/components/md/attachments/attach-modal.tsx +54 -9
- package/src/web/frontend/components/md/attachments/attach-repo-pick.tsx +48 -0
- package/src/web/frontend/components/sidebar/index.tsx +52 -48
- package/src/web/frontend/components/sidebar/model.ts +16 -32
- package/src/web/frontend/components/sidebar/queue-nav.ts +3 -4
- package/src/web/frontend/components/sidebar/row-menu.tsx +1 -1
- package/src/web/frontend/components/sidebar/task-children.tsx +53 -32
- package/src/web/frontend/{page/dir → components/task-panel}/dag-editor.tsx +1 -1
- package/src/web/frontend/components/task-panel/task-ops.ts +299 -0
- package/src/web/frontend/components/task-panel/task-page.tsx +495 -0
- package/src/web/frontend/components/tool-acts/modules.ts +3 -0
- package/src/web/frontend/modules/board/board-view.ts +2 -56
- package/src/web/frontend/modules/md/doc-store.ts +2 -3
- package/src/web/frontend/page/dag/head-bar.tsx +0 -1
- package/src/web/frontend/page/dag/index.tsx +1 -4
- package/src/web/frontend/page/dag/model.ts +0 -1
- package/src/web/frontend/page/dir/api.ts +4 -108
- package/src/web/frontend/page/dir/index.tsx +161 -348
- package/src/web/frontend/page/dir/task-actions.ts +20 -32
- package/src/web/frontend/page/dir/task-board-section.tsx +3 -0
- package/src/web/frontend/page/dir/task-chain.ts +6 -10
- package/src/web/frontend/page/dir/task-dock-panel.tsx +3 -6
- package/src/web/frontend/page/dir/task-feedback.ts +9 -17
- package/src/web/frontend/page/dir/task-not-found.tsx +2 -3
- package/src/web/frontend/page/dir/task-utils.ts +0 -1
- package/src/web/frontend/page/dir/task.tsx +14 -18
- package/src/web/frontend/page/doc/doc-dock.tsx +1 -1
- package/src/web/frontend/page/group/api.ts +3 -21
- package/src/web/frontend/page/group/group-project-memo.ts +41 -0
- package/src/web/frontend/page/group/index.tsx +289 -429
- package/src/web/frontend/page/progress/index.tsx +7 -12
- package/src/web/frontend/page/settings/api.ts +1 -2
- package/src/web/frontend/page/settings/prompt-templates-section.tsx +12 -44
- package/src/web/frontend/panels.tsx +1 -1
- package/src/web/frontend/registry.ts +1 -2
- package/src/web/frontend/route-map.ts +0 -1
- package/src/web/frontend/routes/dir.ts +1 -4
- package/src/web/frontend/routes/keys.ts +5 -3
- package/src/web/frontend/svghub/catalog-nav.ts +8 -11
- package/src/web/public/assets/app-context-CngKv8Tc.js +1 -0
- package/src/web/public/assets/{bar-Dy_QDX2h.js → bar-C0Q_Qe4z.js} +1 -1
- package/src/web/public/assets/board-view-C8OQhkyi.js +1 -0
- package/src/web/public/assets/{button-3JlUeln_.js → button-Cs6w2CDi.js} +1 -1
- package/src/web/public/assets/{composer-launch-B7DH53Yf.js → composer-launch-BF3_hyn5.js} +1 -1
- package/src/web/public/assets/{composer-panel-Cj1J16r-.js → composer-panel-D6vBrzCs.js} +1 -1
- package/src/web/public/assets/{dag-DXRPHVl8.js → dag-CZF6sV2_.js} +1 -1
- package/src/web/public/assets/dir-6RhnWw1E.js +1 -0
- package/src/web/public/assets/doc-CVIVBV6n.js +6 -0
- package/src/web/public/assets/doc-DgYKv2wo.css +1 -0
- package/src/web/public/assets/group-AF62Z-_G.js +1 -0
- package/src/web/public/assets/group-project-memo-G-O6sPRw.js +1 -0
- package/src/web/public/assets/index-Bposj22Z.js +3 -0
- package/src/web/public/assets/{list-filter-CWxiOSg_.js → list-search-DFvFY408.js} +1 -1
- package/src/web/public/assets/md-history-COQu16vy.js +47 -0
- package/src/web/public/assets/{member-picker-BZgE3HGb.js → member-picker-CHX0nS0O.js} +1 -1
- package/src/web/public/assets/popup-dBtYqEM1.js +1 -0
- package/src/web/public/assets/progress-CDh6DY7g.js +3 -0
- package/src/web/public/assets/refs-t79ynSY8.js +2 -0
- package/src/web/public/assets/reopen-text-B2d9SZi0.js +13 -0
- package/src/web/public/assets/{repo-form-modal-CNLYR12c.js → repo-form-modal-dZqpHyUj.js} +1 -1
- package/src/web/public/assets/{repos-BGx-yAXd.js → repos-DdhOQJqF.js} +9 -9
- package/src/web/public/assets/{route-crumb-DX9C4jmQ.js → route-crumb-BKq2jry0.js} +1 -1
- package/src/web/public/assets/settings-Bk3clN2f.js +1 -0
- package/src/web/public/assets/task-C8nax2rT.js +13 -0
- package/src/web/public/assets/task-ops-D6E_TgEC.js +2 -0
- package/src/web/public/assets/task-utils-Dh33OFKe.js +1 -0
- package/src/web/public/assets/{templates-Co1Qb1aA.js → templates-Dusbff7Z.js} +3 -3
- package/src/web/public/assets/{tool-bar-D5wLBLRl.js → tool-bar-DPXnjdQF.js} +2 -2
- package/src/web/public/assets/use-rail-drag-B6J0iqFK.js +1 -0
- package/src/web/public/index.html +13 -13
- package/src/web/frontend/page/dir/landing.tsx +0 -553
- package/src/web/public/assets/app-context-BqCBcDsx.js +0 -1
- package/src/web/public/assets/board-view-Cm8189wG.js +0 -1
- package/src/web/public/assets/dir-_M1ciSxM.js +0 -3
- package/src/web/public/assets/doc-Iuxssa-b.css +0 -1
- package/src/web/public/assets/doc-_iteSM2X.js +0 -6
- package/src/web/public/assets/get-loop-modal-DlAfqJMz.js +0 -2
- package/src/web/public/assets/group-CH8qe-eg.js +0 -1
- package/src/web/public/assets/index-Cui4IuGj.js +0 -3
- package/src/web/public/assets/md-history-Bj790fdn.js +0 -46
- package/src/web/public/assets/popup-DZ2Khv2c.js +0 -1
- package/src/web/public/assets/progress-MPse2JLQ.js +0 -3
- package/src/web/public/assets/refs-DiIPoqnJ.js +0 -2
- package/src/web/public/assets/settings-Pt4YgGdY.js +0 -1
- package/src/web/public/assets/task-DOIIpQ4X.js +0 -13
- package/src/web/public/assets/task-utils-CJfMODCP.js +0 -13
- package/src/web/public/assets/use-rail-drag-CNOHXWng.js +0 -1
package/src/core/topic-key.ts
CHANGED
|
@@ -15,11 +15,8 @@
|
|
|
15
15
|
// 迁移时旧 key 只写进 `topics.ext.ext_legacy_key` 作取证,不参与任何查询。
|
|
16
16
|
import crypto from 'node:crypto';
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/** 全局池的 cwd(`ux_topics_cwd_group` 里 `cwd COLLATE NOCASE` → 空串只容得下一行)。 */
|
|
22
|
-
export const GLOBAL_TOPIC_CWD = '';
|
|
18
|
+
// #190:**全局池已删除**。队列一律绑定真实目录——没有 cwd 的调用方必须先解析出
|
|
19
|
+
// 当前目录(CLI 层用 process.cwd()),不允许再出现「无目录共享池」这种形态。
|
|
23
20
|
|
|
24
21
|
/**
|
|
25
22
|
* `(cwd, groupKey)` → 外部寻址串。
|
|
@@ -27,13 +24,13 @@ export const GLOBAL_TOPIC_CWD = '';
|
|
|
27
24
|
* 大小写折叠(`toLowerCase`)与 schema 里 `ux_topics_cwd_group` 的 `COLLATE NOCASE`
|
|
28
25
|
* 同口径:D:/Work/Web 与 D:/work/web 必须算出同一个 key,否则「同一条队列两个名字」。
|
|
29
26
|
*
|
|
30
|
-
* @param cwd
|
|
27
|
+
* @param cwd 本机目录(必填——#190 起不再有全局池)
|
|
31
28
|
* @param groupKey 组上下文 key(无组上下文传空串/null)
|
|
32
|
-
* @returns
|
|
29
|
+
* @returns 16 位 sha1 前缀
|
|
33
30
|
*/
|
|
34
31
|
export function topicKeyOf(cwd: unknown, groupKey: unknown = ''): string {
|
|
35
32
|
const dir = String(cwd ?? '');
|
|
36
|
-
if (dir === '')
|
|
33
|
+
if (dir === '') throw new Error('topicKeyOf: 需要 cwd(#190 起全局池已删除,队列必须绑定目录)');
|
|
37
34
|
const group = String(groupKey ?? '');
|
|
38
35
|
return crypto
|
|
39
36
|
.createHash('sha1')
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
import { edgesFromTasks, taskToNode, isGateNode } from './types.js';
|
|
12
12
|
import type { WfEdge, WfNode } from './types.js';
|
|
13
13
|
|
|
14
|
-
/** topicKey:id —— key 允许字母数字与 _
|
|
14
|
+
/** topicKey:id —— key 允许字母数字与 _- */
|
|
15
15
|
const FOREIGN_RE = /^([A-Za-z0-9_-]+):(\d+)$/;
|
|
16
16
|
|
|
17
17
|
export type DepRef = { kind: 'local'; id: number } | { kind: 'foreign'; key: string; id: number };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// workflow 契约(#34 阶段 0)—— 冻结类型;#237 引擎门(facade)已删除,仅剩写路径底座在用。
|
|
2
2
|
//
|
|
3
3
|
// 对照参考方案(Node+TS DAG 动态工作流)在 nx-kv 上的映射:
|
|
4
|
-
// workflowId → 主题 key(cwd 归一化 / repos key
|
|
4
|
+
// workflowId → 主题 key(cwd 归一化 / repos key)
|
|
5
5
|
// submit(init) → localtask add(只入队,不构造全图)
|
|
6
6
|
// get(id,node?) → 引擎门(#237 已删除;现役领取走 localtask.get,即 claim 域)
|
|
7
7
|
// Node → localtask 一条任务(id 数字;状态用 status+completedAt)
|
|
@@ -60,8 +60,6 @@ export interface DeliveryHostData {
|
|
|
60
60
|
getLoopWaitMinutes?: number;
|
|
61
61
|
/** 外部参数(--param k=v 解析产物):{{params.k}} + 平面扩展 {{k}} */
|
|
62
62
|
params?: Record<string, string>;
|
|
63
|
-
/** 设置里的追加模式:'plain' 直拼文本,其余(含缺省)包 XML 标签 */
|
|
64
|
-
appendMode?: unknown;
|
|
65
63
|
/** seed 原样透传的上下文键(保持 unknown:宿主传什么 seed 就是什么) */
|
|
66
64
|
source?: unknown;
|
|
67
65
|
summary?: unknown;
|
|
@@ -102,7 +100,6 @@ export async function assembleDelivery(host: DeliveryHostData): Promise<Assemble
|
|
|
102
100
|
getLoopEnabled = false,
|
|
103
101
|
getLoopWaitMinutes = 0,
|
|
104
102
|
params,
|
|
105
|
-
appendMode,
|
|
106
103
|
trace,
|
|
107
104
|
} = host;
|
|
108
105
|
const renderWarnings: RenderWarning[] = [];
|
|
@@ -119,7 +116,6 @@ export async function assembleDelivery(host: DeliveryHostData): Promise<Assemble
|
|
|
119
116
|
...flat,
|
|
120
117
|
};
|
|
121
118
|
|
|
122
|
-
const mode: 'xml' | 'plain' = appendMode === 'plain' ? 'plain' : 'xml';
|
|
123
119
|
// #152:模板是插件类的内置正文(不再从 settings 解析)。
|
|
124
120
|
// 宿主取数以 Supply 注入(惰性:不消费就不算)。
|
|
125
121
|
const plugins = [
|
|
@@ -137,7 +133,6 @@ export async function assembleDelivery(host: DeliveryHostData): Promise<Assemble
|
|
|
137
133
|
plugins,
|
|
138
134
|
groups: ['get', 'check', 'done'],
|
|
139
135
|
seed: seedCtx,
|
|
140
|
-
mode,
|
|
141
136
|
trace,
|
|
142
137
|
segments: DELIVERY_SEGMENTS,
|
|
143
138
|
});
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
// 「这段是哪来的」。真实领取不传 trace,行为与改造前逐字节一致。
|
|
20
20
|
import { formatDuration, formatGoalTiming } from '../../core/instruction-template.js';
|
|
21
21
|
import { parseFrontmatter } from '../../shared/frontmatter.js';
|
|
22
|
-
import {
|
|
22
|
+
import { pendingQueueInfo } from '../localtask/service.js';
|
|
23
23
|
import { assembleDelivery, type AssembledDelivery } from './assemble.js';
|
|
24
24
|
import { annotateTaskDelivery, attachTemplateCtx } from '../localtask/ops/attach.js';
|
|
25
25
|
import { readGroupContext } from './groupctx.js';
|
|
@@ -87,7 +87,7 @@ export function enrichGoalTiming(g: any): any {
|
|
|
87
87
|
// 绝不写盘:showTimegoal 走 loadRecycledStore({persist:false})——timegoals.json
|
|
88
88
|
// 字节数不变,goal-expiry 单测字节比对钉着。
|
|
89
89
|
async function readGoalCtx(cwd: unknown): Promise<Record<string, any> | null> {
|
|
90
|
-
if (!cwd
|
|
90
|
+
if (!cwd) return null; // 没有目录就没有组上下文(#190 起不再有全局池)
|
|
91
91
|
try {
|
|
92
92
|
const show = await timegoal.showTimegoal({ cwd });
|
|
93
93
|
if (!show || !show.hasGoal) return null;
|
|
@@ -163,7 +163,6 @@ export async function buildTaskDelivery(
|
|
|
163
163
|
// 提交的纯项目任务只带项目介绍,不把所属组的材料挂进来。
|
|
164
164
|
const boardMark = String(parseFrontmatter(String((task && task.text) || '')).board || '').trim();
|
|
165
165
|
const groupCtx = await readGroupContext(cwd as string, { board: boardMark });
|
|
166
|
-
const settings: any = (await getSettings().catch(() => null)) || {};
|
|
167
166
|
|
|
168
167
|
// ── 插件化组装(promptplug):宿主完成领域取数,插件 data() 做同步变换 ──
|
|
169
168
|
// 任务级 goal → 完整 check 指令;目录级 goal → 状态行(二者都进 timecheck 段)。
|
|
@@ -207,7 +206,6 @@ export async function buildTaskDelivery(
|
|
|
207
206
|
getLoopEnabled,
|
|
208
207
|
getLoopWaitMinutes,
|
|
209
208
|
params,
|
|
210
|
-
appendMode: settings.appendMode,
|
|
211
209
|
source: source || '',
|
|
212
210
|
summary,
|
|
213
211
|
cwd,
|
|
@@ -88,7 +88,6 @@ export async function previewTaskDelivery({ task, cwd, key, summary, params }: P
|
|
|
88
88
|
// 两个旧开关保留:模板已全部内置,custom 恒为 false
|
|
89
89
|
deliveryTemplate: builtinBlock('context'),
|
|
90
90
|
attachTemplate: builtinBlock('attachment'),
|
|
91
|
-
appendMode: settings.appendMode || 'xml',
|
|
92
91
|
// 每个区块当前生效的模板(全部内置)
|
|
93
92
|
blockTemplates: Object.fromEntries(PLUGIN_IDS.map((id) => [id, builtinBlock(id)])),
|
|
94
93
|
// 时机链(#152):get / check / done 各自的插件顺序
|
|
@@ -17,12 +17,9 @@ import {
|
|
|
17
17
|
consumeCancelRequest,
|
|
18
18
|
claimFirstPending,
|
|
19
19
|
getSettings,
|
|
20
|
-
GLOBAL_KEY,
|
|
21
|
-
isGlobalKey,
|
|
22
20
|
normalizeCwd,
|
|
23
21
|
normalizeSummary,
|
|
24
22
|
probeEffectivePresence,
|
|
25
|
-
registerGlobalWaiter,
|
|
26
23
|
registerTopicWaiter,
|
|
27
24
|
repoContextIndex,
|
|
28
25
|
repoCtxOf,
|
|
@@ -46,7 +43,7 @@ const POLL_MS = 500;
|
|
|
46
43
|
|
|
47
44
|
// 等待期到点探针(只读、不写盘):返回该目录目标的截止 epoch ms;已到点/无目标 → 0
|
|
48
45
|
async function readGoalDeadlineMs(key: unknown): Promise<number> {
|
|
49
|
-
if (!key
|
|
46
|
+
if (!key) return 0;
|
|
50
47
|
try {
|
|
51
48
|
const g = await timegoal.probeGoalExpiry(key);
|
|
52
49
|
if (!g || g.reached) return 0; // 已经到点的:不参与自动取消
|
|
@@ -60,7 +57,7 @@ async function readGoalDeadlineMs(key: unknown): Promise<number> {
|
|
|
60
57
|
// ─── 阻塞等待:核心入口 ─────────────────────────────────────────────
|
|
61
58
|
|
|
62
59
|
export interface WaitForTaskOptions {
|
|
63
|
-
/** 工作目录(主题按目录名识别);缺省 → 进程当前 cwd
|
|
60
|
+
/** 工作目录(主题按目录名识别);缺省 → 进程当前 cwd */
|
|
64
61
|
cwd?: unknown;
|
|
65
62
|
/** 当前现状(#171 起不再必填:面板上没有对应输入界面) */
|
|
66
63
|
summary?: unknown;
|
|
@@ -90,8 +87,8 @@ type WaitOutcome =
|
|
|
90
87
|
|
|
91
88
|
/**
|
|
92
89
|
* 针对某主题(工作目录)等待用户回填下一条任务。
|
|
93
|
-
* 领取顺序:本目录队列 →
|
|
94
|
-
* 返回带 source: 'local'
|
|
90
|
+
* 领取顺序:本目录队列 → 阻塞(#190 起全局共享池已删除,不再跨目录兜底)。
|
|
91
|
+
* 返回带 source: 'local' 标明任务来自本目录队列。
|
|
95
92
|
*/
|
|
96
93
|
export async function waitForTask({
|
|
97
94
|
cwd: rawCwd,
|
|
@@ -131,33 +128,13 @@ export async function waitForTask({
|
|
|
131
128
|
return { status: 'ok', key, cwd, name, summary, ...delivery, queued: true, source: 'local', repo: repoCtx };
|
|
132
129
|
}
|
|
133
130
|
|
|
134
|
-
// 1b. 本地空 →
|
|
135
|
-
//
|
|
136
|
-
// (防止调用方习惯性传 cwd 导致共享池永远无人领取。)
|
|
137
|
-
// instant(localtask get 默认形态):两处快路径都没货 → 立即返回,不进阻塞窗口。
|
|
131
|
+
// 1b. 本地空 → 没货了(#190 起不再去全局共享池兜底)。
|
|
132
|
+
// instant(localtask get 默认形态):本地没货就立即返回,不进阻塞窗口。
|
|
138
133
|
// 「无任务时唤起阻塞等待」是 waitgoal(项目 getLoop)的语义,见 claim/get.ts。
|
|
139
134
|
if (instant) {
|
|
140
135
|
return { status: 'timeout', key, cwd, name, summary, timeoutMs: 0, instant: true };
|
|
141
136
|
}
|
|
142
137
|
|
|
143
|
-
const fromGlobal = await claimFirstPending(GLOBAL_KEY, summary, by);
|
|
144
|
-
if (fromGlobal) {
|
|
145
|
-
// 全局池投递渲染的仍是**等待方目录**的 goal——目标绑定在等待中的 agent 目录上,
|
|
146
|
-
// 与任务来自哪个队列无关。
|
|
147
|
-
const delivery = await buildTaskDelivery(fromGlobal, { source: 'global', summary, cwd, name, topicKey: key, params, getLoopEnabled, getLoopWaitMinutes });
|
|
148
|
-
return {
|
|
149
|
-
status: 'ok',
|
|
150
|
-
key,
|
|
151
|
-
cwd,
|
|
152
|
-
name,
|
|
153
|
-
summary,
|
|
154
|
-
...delivery,
|
|
155
|
-
queued: true,
|
|
156
|
-
source: 'global',
|
|
157
|
-
repo: repoCtx,
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
|
|
161
138
|
// 1c. 这个目录的时间目标**还在跑** → 记下它的截止时刻。
|
|
162
139
|
// 等待期间一旦越过这个时刻,本轮立刻收尾(见下方 goalPoll)。
|
|
163
140
|
// 目标早就过期的(reached)不记:那是"这一局已经结束了",
|
|
@@ -179,7 +156,7 @@ export async function waitForTask({
|
|
|
179
156
|
const presence = panelInfo.running ? await probeEffectivePresence() : 0;
|
|
180
157
|
const deepLink = deepLinkUrl(key, panelInfo.port || DEFAULT_PORT);
|
|
181
158
|
|
|
182
|
-
// 3.
|
|
159
|
+
// 3. 结果承诺:两个生产者(同进程本地 waiter / 跨进程轮询)+ 超时(#190 全局 FIFO 已删)
|
|
183
160
|
let resolveOutcome!: (r: WaitOutcome) => void;
|
|
184
161
|
const outcome = new Promise<WaitOutcome>((r) => {
|
|
185
162
|
resolveOutcome = r;
|
|
@@ -187,19 +164,10 @@ export async function waitForTask({
|
|
|
187
164
|
registerTopicWaiter(key, {
|
|
188
165
|
resolve: (task: any) => resolveOutcome({ kind: 'task', task, delivered: true }),
|
|
189
166
|
});
|
|
190
|
-
// 全局兜底:同进程有人 addTask({global:true}) 时按 FIFO 唤醒本轮等待
|
|
191
|
-
const unregisterGlobal = registerGlobalWaiter(
|
|
192
|
-
(task: any) => resolveOutcome({ kind: 'task', task, delivered: true, source: 'global' }),
|
|
193
|
-
summary,
|
|
194
|
-
// by 承载 {key,cwd,name} 对象(领取后记进 task.claimedBy,见 task-ops 的 gw.by 消费);
|
|
195
|
-
// waiters 层的 by 已按 WaiterBy 标注(曾误标 string),此处直接透传
|
|
196
|
-
by
|
|
197
|
-
);
|
|
198
|
-
|
|
199
167
|
const timer = setTimeout(() => resolveOutcome({ kind: 'timeout' }), tmo);
|
|
200
168
|
|
|
201
169
|
// 三个 500ms 节拍的轮询合一为一个 ticker(原 poll/cancelPoll/goalPoll 三个 setInterval):
|
|
202
|
-
// ①
|
|
170
|
+
// ① 跨进程兜底轮询:只查本地队列(#190 起不再查全局池)
|
|
203
171
|
// ② 关闭轮询:用户在面板点了「关闭」→ 立即收尾本轮(走与超时同一条出口,只多带
|
|
204
172
|
// cancelled 标记,agent 不必认识新状态,照常结束本轮)
|
|
205
173
|
// ③ 时间目标到点 → 立刻收尾本轮(等的是"下一条任务",预算用完了就没必要等)。
|
|
@@ -215,14 +183,7 @@ export async function waitForTask({
|
|
|
215
183
|
}
|
|
216
184
|
claimFirstPending(key, undefined, by)
|
|
217
185
|
.then((task: any) => {
|
|
218
|
-
if (task) {
|
|
219
|
-
resolveOutcome({ kind: 'task', task, delivered: false, source: 'local' });
|
|
220
|
-
return null;
|
|
221
|
-
}
|
|
222
|
-
return claimFirstPending(GLOBAL_KEY, undefined, by);
|
|
223
|
-
})
|
|
224
|
-
.then((task: any) => {
|
|
225
|
-
if (task) resolveOutcome({ kind: 'task', task, delivered: false, source: 'global' });
|
|
186
|
+
if (task) resolveOutcome({ kind: 'task', task, delivered: false, source: 'local' });
|
|
226
187
|
})
|
|
227
188
|
.catch(() => {
|
|
228
189
|
/* 瞬时读写错误,下一轮再试 */
|
|
@@ -298,7 +259,6 @@ export async function waitForTask({
|
|
|
298
259
|
escort.stop();
|
|
299
260
|
clearTimeout(timer);
|
|
300
261
|
unregisterTopicWaiter(key);
|
|
301
|
-
unregisterGlobal();
|
|
302
262
|
await clearWaiting(key);
|
|
303
263
|
}
|
|
304
264
|
return result;
|
|
@@ -13,7 +13,6 @@ const renderDetach: any = _renderDetach;
|
|
|
13
13
|
const input = z.object({
|
|
14
14
|
ref: z.string(),
|
|
15
15
|
attachment: z.string().describe("资源 id(见 docs attachments)"),
|
|
16
|
-
purge: z.boolean().optional().describe("连资源与字节一起删(仍被引用时拒绝)"),
|
|
17
16
|
});
|
|
18
17
|
|
|
19
18
|
export class DocsDetachAction extends ActionBase<typeof input> {
|
|
@@ -21,7 +20,7 @@ export class DocsDetachAction extends ActionBase<typeof input> {
|
|
|
21
20
|
id: 'docs.detach',
|
|
22
21
|
cli: ['docs', 'detach'],
|
|
23
22
|
http: ['DELETE', '/api/docs/attach'],
|
|
24
|
-
summary: '
|
|
23
|
+
summary: '解除文档与附件的关系(#189:只解除关联;清理走库级 GC,不在这里删资源)',
|
|
25
24
|
args: ['ref'],
|
|
26
25
|
input,
|
|
27
26
|
render: renderDetach,
|
|
@@ -5,7 +5,6 @@ import { badInput } from '../../core/errors.js';
|
|
|
5
5
|
import { getDb } from '../../core/db/index.js';
|
|
6
6
|
import { tx } from '../../core/db/tx.js';
|
|
7
7
|
import {
|
|
8
|
-
deleteAttachment,
|
|
9
8
|
ensureDocRef,
|
|
10
9
|
ensureRefAttachment,
|
|
11
10
|
ensureTaskAttachment,
|
|
@@ -18,10 +17,8 @@ import {
|
|
|
18
17
|
upsertFileAttachment,
|
|
19
18
|
} from '../../core/attachmentdb.js';
|
|
20
19
|
import type { LinkedAttachmentView } from '../../core/attachmentdb/query.js';
|
|
21
|
-
import type { DeleteAttachmentResult } from '../../core/attachmentdb/query.js';
|
|
22
20
|
import { localUpload } from '../../core/localatt.js';
|
|
23
21
|
import { contentTypeOf, isImageName } from '../../core/filekind.js';
|
|
24
|
-
import { attachmentsRootFromEnv } from '../../core/paths.js';
|
|
25
22
|
import { readFile } from 'node:fs/promises';
|
|
26
23
|
import { basename, resolve as resolvePath } from 'node:path';
|
|
27
24
|
|
|
@@ -232,7 +229,6 @@ export async function attachToDoc(ctx: AttachToDocCtx): Promise<AttachToDocResul
|
|
|
232
229
|
export interface DetachFromDocInput {
|
|
233
230
|
ref?: unknown;
|
|
234
231
|
attachment?: unknown;
|
|
235
|
-
purge?: unknown;
|
|
236
232
|
}
|
|
237
233
|
|
|
238
234
|
/** docs detach 的出参。 */
|
|
@@ -241,36 +237,26 @@ export interface DetachFromDocResult {
|
|
|
241
237
|
ref: string;
|
|
242
238
|
attachment: string;
|
|
243
239
|
unlinked: number;
|
|
244
|
-
purged: boolean;
|
|
245
|
-
purgeReason: string;
|
|
246
|
-
bytesRemoved: boolean;
|
|
247
240
|
}
|
|
248
241
|
|
|
249
|
-
/**
|
|
250
|
-
export async function detachFromDoc({ ref, attachment
|
|
242
|
+
/** 解除文档与资源的关系(#189:**只解除关联**,资源行与字节不动,清理走库级 GC)。 */
|
|
243
|
+
export async function detachFromDoc({ ref, attachment }: DetachFromDocInput = {}): Promise<DetachFromDocResult> {
|
|
251
244
|
const { refId } = await docRefOf(ref);
|
|
252
245
|
const attId = String(attachment || '').trim();
|
|
253
246
|
if (!attId) throw badInput('需要 --attachment <资源 id>(见 docs attachments 输出)');
|
|
254
247
|
const db = getDb();
|
|
255
248
|
let unlinked = 0;
|
|
256
|
-
const purgeHolder: { result: DeleteAttachmentResult | null } = { result: null };
|
|
257
249
|
tx(
|
|
258
250
|
(conn) => {
|
|
251
|
+
// #189:只解除关联——资源行与字节不动,清理由库级 GC 负责
|
|
259
252
|
unlinked = unlinkAttachment(conn, { host: 'ref', hostId: refId, attachmentId: attId });
|
|
260
|
-
if (purge && unlinked) {
|
|
261
|
-
purgeHolder.result = deleteAttachment(conn, attId, { attachmentsRoot: attachmentsRootFromEnv() });
|
|
262
|
-
}
|
|
263
253
|
},
|
|
264
254
|
{ db, mode: 'IMMEDIATE' }
|
|
265
255
|
);
|
|
266
|
-
const purgeResult = purgeHolder.result;
|
|
267
256
|
return {
|
|
268
257
|
status: 'ok',
|
|
269
258
|
ref: refId,
|
|
270
259
|
attachment: attId,
|
|
271
260
|
unlinked,
|
|
272
|
-
purged: !!(purgeResult && purgeResult.removed),
|
|
273
|
-
purgeReason: purgeResult ? purgeResult.reason || '' : '',
|
|
274
|
-
bytesRemoved: !!(purgeResult && purgeResult.bytesRemoved),
|
|
275
261
|
};
|
|
276
262
|
}
|
|
@@ -82,16 +82,7 @@ export const renderAttachments = (d: any): string => {
|
|
|
82
82
|
export const renderAttach = (d: any): string =>
|
|
83
83
|
`已附加 ${d.attachmentId}(${d.kind})到「${d.ref}」· ${d.area === 'area' ? '附件区(未写正文)' : '正文内嵌'}${d.markdown ? `\n嵌入: ${d.markdown}` : ''}`;
|
|
84
84
|
|
|
85
|
-
export const renderDetach = (d: any): string =>
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const tail = d.purged
|
|
90
|
-
? ';资源已删除(含本机字节)'
|
|
91
|
-
: d.purgeReason === 'in-use'
|
|
92
|
-
? ';资源仍被其他任务/文档引用,未删字节'
|
|
93
|
-
: d.purgeReason === 'file-locked'
|
|
94
|
-
? ';文件被占用,未删字节'
|
|
95
|
-
: '';
|
|
96
|
-
return head + tail;
|
|
97
|
-
};
|
|
85
|
+
export const renderDetach = (d: any): string => (d.unlinked
|
|
86
|
+
// #189:只解除关联——不删资源行与字节(清理走库级 GC)
|
|
87
|
+
? `已解除「${d.ref}」与附件 ${d.attachment} 的关系(资源留在孤儿池)`
|
|
88
|
+
: `「${d.ref}」本来就没有引用附件 ${d.attachment}`);
|
|
@@ -42,7 +42,6 @@ const input = z.object({
|
|
|
42
42
|
file: z.string().optional().describe("从本机文件读任务正文(- 表示标准输入)——长文本/多行不必靠引号硬拼"),
|
|
43
43
|
cwd: z.string().optional().describe("工作目录(作为主题;默认当前目录)。归属由 --project 决定:给了 --project 就用它推导落点,这里再给且不一致会报错"),
|
|
44
44
|
summary: z.string().optional().describe("顺带刷新该主题的当前现状(可选)"),
|
|
45
|
-
global: z.boolean().optional().describe("推到全局主题(共享池):任何目录的 wait 在本地空时自动领取;--cwd 被忽略"),
|
|
46
45
|
board: z.string().optional().describe("工作组(看板)id / key / 名称:任务正文自动带上 frontmatter(board + 组介绍引用),该任务才会出现在组面板里;必须同时给 --project 指明归属项目"),
|
|
47
46
|
project: z.string().optional().describe("归属项目(仓库 key / 名称 / 路径):任务挂在哪个项目上,落点目录由它推导,frontmatter 带上 project + 项目介绍引用;配 --board 时必须是该组成员"),
|
|
48
47
|
duration: z.string().optional().describe("时间目标时长(2h / 90m / 5小时):领取即计时,未到点不许标完成"),
|
|
@@ -62,7 +61,7 @@ export class LocaltaskAddAction extends ActionBase<typeof input> {
|
|
|
62
61
|
id: 'localtask.add',
|
|
63
62
|
cli: ['localtask', 'add'],
|
|
64
63
|
http: ['POST', '/api/localtasks'],
|
|
65
|
-
summary: '向某主题(工作目录)的队列回填一条任务(正文可多行;--file <文件|-> 从文件/标准输入读,长文本不必靠引号硬拼;有 wait 在等则即时投递,否则排队);--
|
|
64
|
+
summary: '向某主题(工作目录)的队列回填一条任务(正文可多行;--file <文件|-> 从文件/标准输入读,长文本不必靠引号硬拼;有 wait 在等则即时投递,否则排队);--duration 给任务带时间目标(领取即计时,完成前必须 check);--board/--project 让任务带工作组语义(正文 frontmatter:board + project + 双方介绍引用),并落进该项目的队列;正文自带 frontmatter 时同样认归属——补介绍引用,落点跟到项目队列(显式给过 --cwd 时不挪窝)',
|
|
66
65
|
args: ['text'],
|
|
67
66
|
input,
|
|
68
67
|
output: addView,
|
|
@@ -90,7 +89,6 @@ export class LocaltaskAddAction extends ActionBase<typeof input> {
|
|
|
90
89
|
text: body,
|
|
91
90
|
cwd: ctx.cwd,
|
|
92
91
|
summary: ctx.summary,
|
|
93
|
-
global: ctx.global,
|
|
94
92
|
board: ctx.board,
|
|
95
93
|
project: ctx.project,
|
|
96
94
|
duration: ctx.duration,
|
|
@@ -17,6 +17,7 @@ const input = z.object({
|
|
|
17
17
|
ref: z.string().optional().describe("文档路径或 ref id(kind=ref,落 nxkv://ref/<refId>)"),
|
|
18
18
|
mdfile: z.string().optional().describe("本地 .md 文件路径(kind=mdfile:只登记指针,不复制正文;web 的 md 栏按此过滤)"),
|
|
19
19
|
folder: z.string().optional().describe("本地文件夹路径(kind=folder:只登记目录路径,不复制目录内容;交付给 agent 的是绝对路径)"),
|
|
20
|
+
repo: z.string().optional().describe("#184 参考仓库(kind=repo):已登记仓库的 key / 本地 checkout 路径 / 名称——只登记指针,交付时强制 agent 参考源码"),
|
|
20
21
|
inline: z.boolean().optional().describe("文档进原文:交付时附全文(截断 2 万字)而不是只给路径;仅 --ref 有效"),
|
|
21
22
|
name: z.string().optional().describe("显示名 / 本地文件名(默认取原名)"),
|
|
22
23
|
kind: z.string().optional().describe("image | file(仅 --path/--fileId 用;不给按扩展名判)"),
|
|
@@ -30,10 +31,10 @@ export class LocaltaskAttachAction extends ActionBase<typeof input> {
|
|
|
30
31
|
id: 'localtask.attach',
|
|
31
32
|
cli: ['localtask', 'attach'],
|
|
32
33
|
http: ['POST', '/api/localtasks/attach'],
|
|
33
|
-
summary: '给任务挂附件:--path 存本机附件仓 / --fileId 引用已有附件 / --url / --task(同主题任务)/ --ref(文档)/ --mdfile(本地 md 指针)/ --folder
|
|
34
|
+
summary: '给任务挂附件:--path 存本机附件仓 / --fileId 引用已有附件 / --url / --task(同主题任务)/ --ref(文档)/ --mdfile(本地 md 指针)/ --folder(本地文件夹路径)/ --repo(已登记仓库);默认嵌进正文,--no-embed 只挂到附件区(不写正文),--ref 加 --inline 文档进原文(交付带全文)',
|
|
34
35
|
input,
|
|
35
36
|
render: (d: any) =>
|
|
36
|
-
`已附加 ${d.fileId}(${d.kind === 'image' ? '图片' : d.kind === 'url' ? '链接' : d.kind === 'task' ? '任务' : d.kind === 'ref' ? '文档' : d.kind === 'mdfile' ? 'md' : d.kind === 'folder' ? '文件夹' : '文件'})到主题「${d.name}」#${d.task.id} · ${d.role === 'doc' ? '文档资料(交付进原文)' : d.area === 'area' ? '附件区(未写正文)' : '正文内嵌'}${d.markdown ? `\n嵌入: ${d.markdown}` : ''}`,
|
|
37
|
+
`已附加 ${d.fileId}(${d.kind === 'image' ? '图片' : d.kind === 'url' ? '链接' : d.kind === 'task' ? '任务' : d.kind === 'ref' ? '文档' : d.kind === 'mdfile' ? 'md' : d.kind === 'folder' ? '文件夹' : d.kind === 'repo' ? '仓库' : '文件'})到主题「${d.name}」#${d.task.id} · ${d.role === 'doc' ? '文档资料(交付进原文)' : d.area === 'area' ? '附件区(未写正文)' : '正文内嵌'}${d.markdown ? `\n嵌入: ${d.markdown}` : ''}`,
|
|
37
38
|
})
|
|
38
39
|
override async run(ctx: ActionInput<this['_input']>) {
|
|
39
40
|
|
|
@@ -49,6 +50,7 @@ export class LocaltaskAttachAction extends ActionBase<typeof input> {
|
|
|
49
50
|
ref: ctx.ref,
|
|
50
51
|
mdfile: ctx.mdfile,
|
|
51
52
|
folder: ctx.folder,
|
|
53
|
+
repo: ctx.repo,
|
|
52
54
|
inline: ctx.inline,
|
|
53
55
|
name: ctx.name,
|
|
54
56
|
kind: ctx.kind,
|
|
@@ -114,7 +114,6 @@ export class LocaltaskBoardTasksAction extends ActionBase<typeof input> {
|
|
|
114
114
|
);
|
|
115
115
|
const rows: any[] = [];
|
|
116
116
|
for (const t of topics) {
|
|
117
|
-
if (t.isGlobal) continue;
|
|
118
117
|
const repoKey = t.repo && t.repo.key ? String(t.repo.key) : '';
|
|
119
118
|
// 成员关系按仓库 key 对(与 board.repos[].key 同一键空间);
|
|
120
119
|
// 没登记仓库的目录队列不属于任何组,天然出局。
|
|
@@ -19,7 +19,7 @@ export class LocaltaskCloneAction extends ActionBase<typeof input> {
|
|
|
19
19
|
id: 'localtask.clone',
|
|
20
20
|
cli: ['localtask', 'clone'],
|
|
21
21
|
http: ['POST', '/api/localtasks/clone'],
|
|
22
|
-
summary: '
|
|
22
|
+
summary: '克隆任务:复制正文内容为一条新任务(同主题)。不带派生链、不继承时间目标与依赖——开新活用',
|
|
23
23
|
input,
|
|
24
24
|
render: (d: any) =>
|
|
25
25
|
`已克隆 #${d.from.id} → #${d.task.id} @ ${d.name}(内容复制,无派生链;${d.delivered ? '已实时投递' : '待领取'})`,
|
|
@@ -16,11 +16,6 @@ const PLUGIN_IDS: any = _PLUGIN_IDS;
|
|
|
16
16
|
/** localtask.config 的入参契约(CLI 与 HTTP 共用同一份)。 */
|
|
17
17
|
const input = z.object({
|
|
18
18
|
timeout: z.number().optional().describe('超时秒数(1-600)'),
|
|
19
|
-
'append-mode': z
|
|
20
|
-
.string()
|
|
21
|
-
.optional()
|
|
22
|
-
.describe('系统上下文追加模式(全局):xml(默认,每段包独立标签)/ plain(按空行直接拼正文)。HTTP body 用 appendMode'),
|
|
23
|
-
appendMode: z.string().optional().describe('同 --append-mode(驼峰写法,HTTP body 用)'),
|
|
24
19
|
});
|
|
25
20
|
|
|
26
21
|
export class LocaltaskConfigAction extends ActionBase<typeof input> {
|
|
@@ -28,18 +23,14 @@ export class LocaltaskConfigAction extends ActionBase<typeof input> {
|
|
|
28
23
|
id: 'localtask.config',
|
|
29
24
|
cli: ['localtask', 'config'],
|
|
30
25
|
http: ['PATCH', '/api/localtasks/setting'],
|
|
31
|
-
summary: '
|
|
26
|
+
summary: '配置等待超时(秒)(系统上下文固定 XML 区块;提示词模板正文固定在插件类里,不再可配)',
|
|
32
27
|
input,
|
|
33
28
|
render: (s: any) => {
|
|
34
|
-
|
|
35
|
-
return `已配置等待超时 ${s.timeoutSec} 秒(推荐 ${s.recommendedSec},最大 ${s.maxSec})· 追加模式:${mode} · 提示词模板:${PLUGIN_IDS.length} 段全部内置(不可在此修改)`;
|
|
29
|
+
return `已配置等待超时 ${s.timeoutSec} 秒(推荐 ${s.recommendedSec},最大 ${s.maxSec})· 提示词模板:${PLUGIN_IDS.length} 段全部内置(不可在此修改)`;
|
|
36
30
|
},
|
|
37
31
|
})
|
|
38
32
|
override async run(ctx: ActionInput<this['_input']>) {
|
|
39
33
|
const patch: any = { timeoutSec: ctx.timeout };
|
|
40
|
-
// 系统上下文追加模式(全局)——HTTP body 用驼峰别名 appendMode(#104)
|
|
41
|
-
const appendMode: any = ctx.appendMode ?? ctx['append-mode'];
|
|
42
|
-
if (appendMode !== undefined) patch.appendMode = appendMode;
|
|
43
34
|
return service.updateSettings(patch);
|
|
44
35
|
}
|
|
45
36
|
}
|
|
@@ -13,7 +13,6 @@ const input = z.object({
|
|
|
13
13
|
cwd: z.string().optional(),
|
|
14
14
|
key: z.string().optional(),
|
|
15
15
|
attachment: z.string().describe("资源 id(见 localtask attachments)"),
|
|
16
|
-
purge: z.boolean().optional().describe("连资源行与本机字节一起删(仍被其他任务/文档引用时拒绝删)"),
|
|
17
16
|
});
|
|
18
17
|
|
|
19
18
|
export class LocaltaskDetachAction extends ActionBase<typeof input> {
|
|
@@ -21,7 +20,7 @@ export class LocaltaskDetachAction extends ActionBase<typeof input> {
|
|
|
21
20
|
id: 'localtask.detach',
|
|
22
21
|
cli: ['localtask', 'detach'],
|
|
23
22
|
http: ['DELETE', '/api/localtasks/attach'],
|
|
24
|
-
summary: '
|
|
23
|
+
summary: '解除任务与附件的关系(#189:只解除关联,资源进孤儿池;清理走库级 GC,不在这里删资源)',
|
|
25
24
|
input,
|
|
26
25
|
render: renderDetach,
|
|
27
26
|
})
|
|
@@ -33,7 +32,6 @@ export class LocaltaskDetachAction extends ActionBase<typeof input> {
|
|
|
33
32
|
cwd: ctx.cwd,
|
|
34
33
|
key: ctx.key,
|
|
35
34
|
attachment: ctx.attachment,
|
|
36
|
-
purge: ctx.purge,
|
|
37
35
|
});
|
|
38
36
|
|
|
39
37
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// (#54 自 service.js 拆出)等待生命周期事件流:轮询 store,从 waiting/waitingUntil 与
|
|
2
2
|
// 已领取数的变化里派生 waiting/reminder/resolved 事件;SSE(streamEventsSSE)与
|
|
3
3
|
// CLI(NDJSON)共用 watchEvents 生成器。
|
|
4
|
-
import {
|
|
4
|
+
import { normalizeCwd } from '../paths.js';
|
|
5
5
|
import { openLocaltaskStore as openStore, topics as topicsRepo } from './repo/index.js';
|
|
6
6
|
import { deadlineMsOf } from '../lifecycle/task-view.js';
|
|
7
7
|
import { addEventStreamConn } from '../ui/panel-presence.js';
|
|
@@ -123,7 +123,7 @@ export async function* watchEvents({ cwd: rawCwd, key: rawKey, pollMs = EVENT_PO
|
|
|
123
123
|
cwd: t.cwd || '',
|
|
124
124
|
name: t.name || '',
|
|
125
125
|
summary: t.summary || '',
|
|
126
|
-
|
|
126
|
+
// #190 全局池已删除,字段保留给旧事件消费方(恒 false)
|
|
127
127
|
waitingUntil: t.waitingUntil,
|
|
128
128
|
remainMs: Math.max(0, deadline - now),
|
|
129
129
|
replay: first,
|
|
@@ -138,7 +138,7 @@ export async function* watchEvents({ cwd: rawCwd, key: rawKey, pollMs = EVENT_PO
|
|
|
138
138
|
cwd: t.cwd || '',
|
|
139
139
|
name: t.name || '',
|
|
140
140
|
summary: t.summary || '',
|
|
141
|
-
|
|
141
|
+
// #190 全局池已删除,字段保留给旧事件消费方(恒 false)
|
|
142
142
|
waitingUntil: t.waitingUntil,
|
|
143
143
|
remainSec: sec,
|
|
144
144
|
remainMs: Math.max(0, st!.deadline! - now),
|
|
@@ -148,7 +148,7 @@ export async function* watchEvents({ cwd: rawCwd, key: rawKey, pollMs = EVENT_PO
|
|
|
148
148
|
} else if (st && st.phase === 'waiting') {
|
|
149
149
|
const outcome = deliveredCount(t) > st.delivered0! ? 'delivered' : 'timeout';
|
|
150
150
|
state.set(t.key, { phase: 'ended' });
|
|
151
|
-
yield { type: 'resolved', key: t.key, cwd: t.cwd || '', name: t.name || '',
|
|
151
|
+
yield { type: 'resolved', key: t.key, cwd: t.cwd || '', name: t.name || '', outcome };
|
|
152
152
|
} else if (!st) {
|
|
153
153
|
state.set(t.key, { phase: 'idle' });
|
|
154
154
|
}
|
|
@@ -163,7 +163,7 @@ export async function* watchEvents({ cwd: rawCwd, key: rawKey, pollMs = EVENT_PO
|
|
|
163
163
|
key: t.key,
|
|
164
164
|
cwd: t.cwd || '',
|
|
165
165
|
name: t.name || '',
|
|
166
|
-
|
|
166
|
+
// #190 全局池已删除,字段保留给旧事件消费方(恒 false)
|
|
167
167
|
outcome: 'timeout',
|
|
168
168
|
stale: true,
|
|
169
169
|
};
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// - #238 补上了**用户层**的落库(用户在设置页加/改/启用的那几条):那是 promptplug
|
|
12
12
|
// 自己的键(settings 表,一段一个 `prompt.tpl.<段>`),由 template-store.ts 读写,
|
|
13
13
|
// 与本文件的 lt.* 无关。
|
|
14
|
-
// -
|
|
14
|
+
// - 因此本文件只剩一个真正可写的键:`lt.timeoutSec`(#186 起 appendMode 已删除,只保留 XML)。
|
|
15
15
|
import { db, txw } from './open.js';
|
|
16
16
|
import { nowMs } from '../../../../core/db/time.js';
|
|
17
17
|
import {
|
|
@@ -19,13 +19,11 @@ import {
|
|
|
19
19
|
MAX_TIMEOUT_SEC,
|
|
20
20
|
clampTimeoutSec,
|
|
21
21
|
} from '../store-io.js';
|
|
22
|
-
import { clampAppendMode } from '../../lifecycle/task-templates.js';
|
|
23
22
|
import type { DbApi } from '../../../../core/db/driver.js';
|
|
24
23
|
import { activeTemplateOf } from '../../../promptplug/index.js';
|
|
25
24
|
|
|
26
25
|
const KEYS = {
|
|
27
26
|
timeoutSec: 'lt.timeoutSec',
|
|
28
|
-
appendMode: 'lt.appendMode',
|
|
29
27
|
};
|
|
30
28
|
|
|
31
29
|
function readSetting(conn: DbApi, key: string): any {
|
|
@@ -57,7 +55,6 @@ export function getLtSettings(): Record<string, any> {
|
|
|
57
55
|
const conn = db();
|
|
58
56
|
return {
|
|
59
57
|
timeoutSec: clampTimeoutSec(readSetting(conn, KEYS.timeoutSec)),
|
|
60
|
-
appendMode: clampAppendMode(readSetting(conn, KEYS.appendMode)),
|
|
61
58
|
// 旧视图字段:ack 段落正文来自 ack 插件类的内置模板,仍按「多条」形态给出,
|
|
62
59
|
// 让老 CLI 的 localtask config 输出不必断代(#152:只是回显,不可写)。
|
|
63
60
|
ackPrompt: splitEntries(activeTemplateOf('ack')),
|
|
@@ -67,7 +64,6 @@ export function getLtSettings(): Record<string, any> {
|
|
|
67
64
|
/** setLtSettings 的 patch 形状(#152:模板不再可写,只留两个键)。 */
|
|
68
65
|
export interface LtSettingsPatch {
|
|
69
66
|
timeoutSec?: unknown;
|
|
70
|
-
appendMode?: unknown;
|
|
71
67
|
}
|
|
72
68
|
|
|
73
69
|
/** 写部分设置(只改传入项;校验沿用 store-io 的 clamp)。 */
|
|
@@ -76,9 +72,6 @@ export function setLtSettings(patch: LtSettingsPatch = {}): Record<string, any>
|
|
|
76
72
|
if (patch.timeoutSec !== undefined) {
|
|
77
73
|
writeSetting(conn, KEYS.timeoutSec, clampTimeoutSec(patch.timeoutSec));
|
|
78
74
|
}
|
|
79
|
-
if (patch.appendMode !== undefined) {
|
|
80
|
-
writeSetting(conn, KEYS.appendMode, clampAppendMode(patch.appendMode));
|
|
81
|
-
}
|
|
82
75
|
return getLtSettings();
|
|
83
76
|
});
|
|
84
77
|
}
|
|
@@ -91,7 +84,6 @@ export function settingsView(): Record<string, any> {
|
|
|
91
84
|
recommendedSec: DEFAULT_TIMEOUT_SEC,
|
|
92
85
|
maxSec: MAX_TIMEOUT_SEC,
|
|
93
86
|
ackPromptList: s.ackPrompt,
|
|
94
|
-
appendMode: s.appendMode,
|
|
95
87
|
};
|
|
96
88
|
}
|
|
97
89
|
|