@suifei/dsh-ai-team 0.4.144 → 0.4.145
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 +5 -0
- package/LICENSE +21 -21
- package/README.md +4 -0
- package/client.js +22 -14
- package/cordis.patch.yml +31 -31
- package/icon.svg +12 -12
- package/lib/domain/ids.js +26 -26
- package/lib/domain/inbox.js +93 -93
- package/lib/domain/member-config.js +168 -168
- package/lib/host/decision-report.js +72 -72
- package/lib/host/default-workspace.js +69 -69
- package/lib/host/fault-adapter.js +50 -50
- package/lib/host/people-view.js +120 -120
- package/lib/host/permission-guard.js +61 -61
- package/lib/host/pmo.js +13 -13
- package/lib/host/project-registry.js +104 -104
- package/lib/host/risk-view.js +99 -99
- package/lib/host/weekly-view.js +86 -86
- package/lib/host/workspace-path.js +94 -94
- package/lib/ledger/checkpoint.js +415 -415
- package/lib/ledger/events.js +398 -398
- package/lib/ledger/namespace.js +124 -124
- package/lib/ledger/tools.js +118 -118
- package/lib/ledger/writer.js +1266 -1266
- package/lib/runtime/error-chain.js +31 -31
- package/lib/runtime/shell-guard.js +102 -102
- package/lib/runtime/skill-catalog.js +41 -41
- package/lib/runtime/skill-policy.js +12 -12
- package/lib/skillopt/adopt-gate.js +108 -108
- package/lib/skillopt/gate-wiring.js +146 -146
- package/lib/skillopt/jobs.js +135 -135
- package/lib/skillopt/proposal-store.js +33 -33
- package/lib/skillopt/review-runner.js +107 -107
- package/lib/skillopt/rubric.js +189 -189
- package/lib/skillopt/subagent-text.js +101 -101
- package/lib/skillopt/tool-access.js +56 -56
- package/locale/en.json +6 -6
- package/locale/zh.json +6 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.145 - 2026-11-26
|
|
4
|
+
|
|
5
|
+
- PMO 自动决策不再给「不推荐」加分或按字母编号偏向选项,且「建议 A」可命中带括注的 A 选项。感谢 @Lamooner 的复现和建议(#99)。
|
|
6
|
+
- 新建和编辑项目共用工作目录选择兜底:识别宿主不提供当前表单可用选择器的情况,保留手填路径,并在后续选中目录后清除旧提示。不改宿主配置或 Workspace 注册时机。感谢 @ljyzww 的 Windows 反馈(#100)。
|
|
7
|
+
|
|
3
8
|
## 0.4.144 - 2026-11-21
|
|
4
9
|
|
|
5
10
|
**SkillOpt:采纳闸门回归借自上游;评审记录把「评分解析失败」和「有效评分但没提升」分开**
|
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 suifei
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 suifei
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -30,6 +30,8 @@
|
|
|
30
30
|
|
|
31
31
|
## 最近更新
|
|
32
32
|
|
|
33
|
+
- **PMO 决策排序**(0.4.145):不再把「不推荐」当作加分,也不按选项字母编号偏向某个方案;结构化建议可以匹配带括注的编号。感谢 [@Lamooner](https://github.com/Lamooner) 的复现和建议([#99](https://github.com/suifei/dsh-ai-team/issues/99))。
|
|
34
|
+
- **工作目录选择兜底**(0.4.145):新建和编辑项目时,如果宿主没有提供此表单可用的目录选择器,可直接粘贴或输入完整路径。不改宿主配置,也不会在提交项目前注册 Workspace(感谢 [@ljyzww](https://github.com/ljyzww) 的反馈,[#100](https://github.com/suifei/dsh-ai-team/issues/100))。
|
|
33
35
|
- **输入框与 @成员**(0.4.120–0.4.123):输入框随内容长高、可拖大;能贴图、拖文件、选附件;@ 能点名具体成员,被 @ 的成员可以直接在主对话回你;成员可一键复制。文渊阁对话框和 DSH 标准会话(「文渊阁·PMO」)是同一套实现(感谢 [@xiuchuan666](https://github.com/xiuchuan666) 的反馈与建议,#65)。
|
|
34
36
|
- **人才市场**(0.4.124–0.4.129):9 个内置团队、44 位内置人才,各自带看家技能。可以招聘、复制为可编辑、自建人才并装技能,也能把项目成员「存为人才」;新建项目时选团队,或从人才里挑人组新团队(源自 [@xiuchuan666](https://github.com/xiuchuan666) 在 #65 里的建议)。
|
|
35
37
|
- **主理人只调度交付**(0.4.128):主理人不看产出,只问负责人做全没有;内容由验收人把关。
|
|
@@ -330,6 +332,8 @@ round-19 DeepSeek + Zhipu 双 provider
|
|
|
330
332
|
|
|
331
333
|
| 贡献者 | 贡献 | 带来的进展 |
|
|
332
334
|
|---|---|---|
|
|
335
|
+
| [@Lamooner](https://github.com/Lamooner) | PMO 决策反馈与建议 [#99](https://github.com/suifei/dsh-ai-team/issues/99) | 避免选中「不推荐」项,移除编号偏向并补充括注编号回归 |
|
|
336
|
+
| [@ljyzww](https://github.com/ljyzww) | Windows 目录选择反馈 [#100](https://github.com/suifei/dsh-ai-team/issues/100) | 新建和编辑项目共用目录选择失败提示,保留手填路径 |
|
|
333
337
|
| [@xiuchuan666](https://github.com/xiuchuan666) | 反馈与建议 [#65](https://github.com/suifei/dsh-ai-team/issues/65) | 输入框长高可拖大、贴图拖文件、@ 点名成员(0.4.120–0.4.123);人才市场与在线人才库(0.4.124–0.4.131);团队扩编:超限排队、开发验收配对、空闲必派、写入范围、加人建议(0.4.140) |
|
|
334
338
|
| [@TardisBooo](https://github.com/TardisBooo) | 代码 [#88](https://github.com/suifei/dsh-ai-team/pull/88) | 工具参数改为对象 JSON Schema,Grok 4.7 可用(0.4.139) |
|
|
335
339
|
|
package/client.js
CHANGED
|
@@ -265,8 +265,8 @@ window.__ModuleLoader__.load({
|
|
|
265
265
|
workspaceDialogTitle: '设置项目工作目录',
|
|
266
266
|
workspaceDialogHint: 'Project 的成员会在这个目录里执行 Task;多个 Project 用不同目录隔离。',
|
|
267
267
|
workspacePathPlaceholder: '例如 D:/work/my-project',
|
|
268
|
-
workspacePickUnavailable: '
|
|
269
|
-
workspacePickFailed: '
|
|
268
|
+
workspacePickUnavailable: '当前宿主的目录选择器不能用于此表单。请在「工作目录」中粘贴或输入完整路径。',
|
|
269
|
+
workspacePickFailed: '未能打开目录选择器。请重试,或在「工作目录」中粘贴或输入完整路径。',
|
|
270
270
|
workspaceSave: '保存目录',
|
|
271
271
|
projectCreate: '创建项目',
|
|
272
272
|
projectCreated: '已创建项目 {name}。',
|
|
@@ -729,8 +729,8 @@ window.__ModuleLoader__.load({
|
|
|
729
729
|
workspaceDialogTitle: 'Set Project workspace',
|
|
730
730
|
workspaceDialogHint: 'Members run Tasks in this directory; separate Projects use separate directories.',
|
|
731
731
|
workspacePathPlaceholder: 'e.g. D:/work/my-project',
|
|
732
|
-
workspacePickUnavailable: '
|
|
733
|
-
workspacePickFailed: '
|
|
732
|
+
workspacePickUnavailable: 'The host’s directory picker is unavailable for this form. Paste or enter the full path in the Workspace field.',
|
|
733
|
+
workspacePickFailed: 'Could not open the directory picker. Retry, or paste or enter the full path in the Workspace field.',
|
|
734
734
|
workspaceSave: 'Save directory',
|
|
735
735
|
projectCreate: 'Create project',
|
|
736
736
|
projectCreated: 'Created project {name}.',
|
|
@@ -4324,15 +4324,26 @@ window.__ModuleLoader__.load({
|
|
|
4324
4324
|
}
|
|
4325
4325
|
try {
|
|
4326
4326
|
return { path: await service.pickDirectory(), error: null };
|
|
4327
|
-
} catch {
|
|
4328
|
-
|
|
4327
|
+
} catch (error) {
|
|
4328
|
+
// Harness rc.5 wraps the RPC error in a plain Error and retains only its message.
|
|
4329
|
+
const unavailable = error?.code === 'directory-picker/unavailable'
|
|
4330
|
+
|| error?.message === 'directory picker failed: directoryPicker.pick needs the native capability; the composed picker serves "browse"';
|
|
4331
|
+
return { error: unavailable ? 'unavailable' : 'failed', path: null };
|
|
4329
4332
|
}
|
|
4330
4333
|
}
|
|
4331
|
-
async function
|
|
4334
|
+
async function applyWorkspacePick(setPath, setError) {
|
|
4332
4335
|
const picked = await pickWorkspacePath();
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
+
const unavailable = t('workspacePickUnavailable');
|
|
4337
|
+
const failed = t('workspacePickFailed');
|
|
4338
|
+
if (picked.path) {
|
|
4339
|
+
setPath(picked.path);
|
|
4340
|
+
setError((previous) => previous === unavailable || previous === failed ? '' : previous);
|
|
4341
|
+
} else if (picked.error) {
|
|
4342
|
+
setError(picked.error === 'unavailable' ? unavailable : failed);
|
|
4343
|
+
}
|
|
4344
|
+
}
|
|
4345
|
+
async function pickNewWorkspace() {
|
|
4346
|
+
await applyWorkspacePick(setNWorkspace, setNError);
|
|
4336
4347
|
}
|
|
4337
4348
|
function openWorkspaceEditor() {
|
|
4338
4349
|
setWorkspaceDraft(project?.workspacePath ?? '');
|
|
@@ -4340,10 +4351,7 @@ window.__ModuleLoader__.load({
|
|
|
4340
4351
|
setWorkspaceOpen(true);
|
|
4341
4352
|
}
|
|
4342
4353
|
async function pickProjectWorkspace() {
|
|
4343
|
-
|
|
4344
|
-
if (picked.path) setWorkspaceDraft(picked.path);
|
|
4345
|
-
else if (picked.error === 'unavailable') setWorkspaceError(t('workspacePickUnavailable'));
|
|
4346
|
-
else if (picked.error === 'failed') setWorkspaceError(t('workspacePickFailed'));
|
|
4354
|
+
await applyWorkspacePick(setWorkspaceDraft, setWorkspaceError);
|
|
4347
4355
|
}
|
|
4348
4356
|
async function saveWorkspace() {
|
|
4349
4357
|
if (!project || workspaceBusy || !workspaceDraft.trim()) return;
|
package/cordis.patch.yml
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
# dsh-ai-team bundle patch: mounts the Host half.
|
|
2
|
-
# The Client half is discovered from this package's `dsh.client` declaration.
|
|
3
|
-
# AI Team is a dedicated, trusted profile: members run with full access by
|
|
4
|
-
# design. These patches make that explicit at the profile layer, so a plain
|
|
5
|
-
# web/desktop profile is never affected.
|
|
6
|
-
- insert:
|
|
7
|
-
- id: ai-team
|
|
8
|
-
name: '@suifei/dsh-ai-team'
|
|
9
|
-
|
|
10
|
-
# The Team profile must be danger-full-access end to end. The Host validates
|
|
11
|
-
# this at boot (E_PERMISSION_PROFILE) and refuses to serve a weaker profile.
|
|
12
|
-
- id: sandbox-policy
|
|
13
|
-
config:
|
|
14
|
-
mode: danger-full-access
|
|
15
|
-
workspaceRoot: !!js process.cwd()
|
|
16
|
-
- id: approval
|
|
17
|
-
config:
|
|
18
|
-
policy: never
|
|
19
|
-
- id: permission
|
|
20
|
-
config:
|
|
21
|
-
defaultPreset: danger-full-access
|
|
22
|
-
presets:
|
|
23
|
-
read-only:
|
|
24
|
-
sandbox: read-only
|
|
25
|
-
approval: ask
|
|
26
|
-
workspace-write:
|
|
27
|
-
sandbox: workspace-write
|
|
28
|
-
approval: ask
|
|
29
|
-
danger-full-access:
|
|
30
|
-
sandbox: danger-full-access
|
|
31
|
-
approval: never
|
|
1
|
+
# dsh-ai-team bundle patch: mounts the Host half.
|
|
2
|
+
# The Client half is discovered from this package's `dsh.client` declaration.
|
|
3
|
+
# AI Team is a dedicated, trusted profile: members run with full access by
|
|
4
|
+
# design. These patches make that explicit at the profile layer, so a plain
|
|
5
|
+
# web/desktop profile is never affected.
|
|
6
|
+
- insert:
|
|
7
|
+
- id: ai-team
|
|
8
|
+
name: '@suifei/dsh-ai-team'
|
|
9
|
+
|
|
10
|
+
# The Team profile must be danger-full-access end to end. The Host validates
|
|
11
|
+
# this at boot (E_PERMISSION_PROFILE) and refuses to serve a weaker profile.
|
|
12
|
+
- id: sandbox-policy
|
|
13
|
+
config:
|
|
14
|
+
mode: danger-full-access
|
|
15
|
+
workspaceRoot: !!js process.cwd()
|
|
16
|
+
- id: approval
|
|
17
|
+
config:
|
|
18
|
+
policy: never
|
|
19
|
+
- id: permission
|
|
20
|
+
config:
|
|
21
|
+
defaultPreset: danger-full-access
|
|
22
|
+
presets:
|
|
23
|
+
read-only:
|
|
24
|
+
sandbox: read-only
|
|
25
|
+
approval: ask
|
|
26
|
+
workspace-write:
|
|
27
|
+
sandbox: workspace-write
|
|
28
|
+
approval: ask
|
|
29
|
+
danger-full-access:
|
|
30
|
+
sandbox: danger-full-access
|
|
31
|
+
approval: never
|
package/icon.svg
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" role="img" aria-label="文渊阁">
|
|
2
|
-
<!-- 重檐(上层屋顶) -->
|
|
3
|
-
<path d="M5 8l7-4 7 4" />
|
|
4
|
-
<path d="M7 11h10" />
|
|
5
|
-
<!-- 出檐(下层屋檐) -->
|
|
6
|
-
<path d="M4 14h16" />
|
|
7
|
-
<!-- 立柱(三开间) -->
|
|
8
|
-
<path d="M9 14v3" />
|
|
9
|
-
<path d="M15 14v3" />
|
|
10
|
-
<!-- 渊水(底部波纹) -->
|
|
11
|
-
<path d="M4 20c2.5-1.5 5.5-1.5 8 0s5.5 1.5 8 0" />
|
|
12
|
-
</svg>
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" role="img" aria-label="文渊阁">
|
|
2
|
+
<!-- 重檐(上层屋顶) -->
|
|
3
|
+
<path d="M5 8l7-4 7 4" />
|
|
4
|
+
<path d="M7 11h10" />
|
|
5
|
+
<!-- 出檐(下层屋檐) -->
|
|
6
|
+
<path d="M4 14h16" />
|
|
7
|
+
<!-- 立柱(三开间) -->
|
|
8
|
+
<path d="M9 14v3" />
|
|
9
|
+
<path d="M15 14v3" />
|
|
10
|
+
<!-- 渊水(底部波纹) -->
|
|
11
|
+
<path d="M4 20c2.5-1.5 5.5-1.5 8 0s5.5 1.5 8 0" />
|
|
12
|
+
</svg>
|
package/lib/domain/ids.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { randomBytes } from 'node:crypto';
|
|
2
|
-
|
|
3
|
-
const CROCKFORD = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';
|
|
4
|
-
|
|
5
|
-
/** Monotonic-ish ULID-style id: 10 chars time + 12 chars randomness. */
|
|
6
|
-
export function newId(prefix = '') {
|
|
7
|
-
let time = Date.now();
|
|
8
|
-
let out = '';
|
|
9
|
-
for (let i = 0; i < 10; i += 1) {
|
|
10
|
-
out = CROCKFORD[time % 32] + out;
|
|
11
|
-
time = Math.floor(time / 32);
|
|
12
|
-
}
|
|
13
|
-
const bytes = randomBytes(12);
|
|
14
|
-
for (const byte of bytes) out += CROCKFORD[byte % 32];
|
|
15
|
-
return prefix === '' ? out : `${prefix}_${out}`;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const ids = {
|
|
19
|
-
project: () => newId('prj'),
|
|
20
|
-
member: () => newId('mem'),
|
|
21
|
-
task: () => newId('tsk'),
|
|
22
|
-
event: () => newId('evt'),
|
|
23
|
-
stream: () => newId('str'),
|
|
24
|
-
inbox: () => newId('inb'),
|
|
25
|
-
review: () => newId('rev'),
|
|
26
|
-
};
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
|
|
3
|
+
const CROCKFORD = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';
|
|
4
|
+
|
|
5
|
+
/** Monotonic-ish ULID-style id: 10 chars time + 12 chars randomness. */
|
|
6
|
+
export function newId(prefix = '') {
|
|
7
|
+
let time = Date.now();
|
|
8
|
+
let out = '';
|
|
9
|
+
for (let i = 0; i < 10; i += 1) {
|
|
10
|
+
out = CROCKFORD[time % 32] + out;
|
|
11
|
+
time = Math.floor(time / 32);
|
|
12
|
+
}
|
|
13
|
+
const bytes = randomBytes(12);
|
|
14
|
+
for (const byte of bytes) out += CROCKFORD[byte % 32];
|
|
15
|
+
return prefix === '' ? out : `${prefix}_${out}`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const ids = {
|
|
19
|
+
project: () => newId('prj'),
|
|
20
|
+
member: () => newId('mem'),
|
|
21
|
+
task: () => newId('tsk'),
|
|
22
|
+
event: () => newId('evt'),
|
|
23
|
+
stream: () => newId('str'),
|
|
24
|
+
inbox: () => newId('inb'),
|
|
25
|
+
review: () => newId('rev'),
|
|
26
|
+
};
|
package/lib/domain/inbox.js
CHANGED
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
import { ERRORS, fail } from './errors.js';
|
|
2
|
-
import { ids } from './ids.js';
|
|
3
|
-
|
|
4
|
-
/** The 12 closed inbox types from 02 FR-028. */
|
|
5
|
-
export const INBOX_TYPES = new Set([
|
|
6
|
-
'mention',
|
|
7
|
-
'assigned',
|
|
8
|
-
'handoff',
|
|
9
|
-
'review_requested',
|
|
10
|
-
'review_result',
|
|
11
|
-
'task_blocked',
|
|
12
|
-
'dependency_cleared',
|
|
13
|
-
'member_stalled',
|
|
14
|
-
'project_recovered',
|
|
15
|
-
'followed_task_update',
|
|
16
|
-
'decision_required',
|
|
17
|
-
'stale_reply_rejected',
|
|
18
|
-
]);
|
|
19
|
-
|
|
20
|
-
export const DECISION_TYPES = new Set(['decision_required']);
|
|
21
|
-
|
|
22
|
-
/** Progress reports mentioning Human are not actionable decisions. */
|
|
23
|
-
export function isInformationalThreadMention(item) {
|
|
24
|
-
return item?.ref?.category === 'thread_mention'
|
|
25
|
-
&& !(Array.isArray(item.ref?.questions) && item.ref.questions.length > 0);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Create one inbox item. It points at a source object; it is not a copy of the
|
|
30
|
-
* message body (the reader pulls the source on demand).
|
|
31
|
-
*/
|
|
32
|
-
export function createInboxItem(input, options = {}) {
|
|
33
|
-
if (typeof input.memberId !== 'string' || input.memberId === '') fail(ERRORS.INVALID_ARGUMENT, 'memberId is required');
|
|
34
|
-
if (!INBOX_TYPES.has(input.type)) fail(ERRORS.INVALID_ARGUMENT, `unknown inbox type: ${String(input.type)}`);
|
|
35
|
-
if (input.ref === undefined || input.ref === null) fail(ERRORS.INVALID_ARGUMENT, 'ref is required');
|
|
36
|
-
const requiresDecision = input.requiresDecision ?? DECISION_TYPES.has(input.type);
|
|
37
|
-
return {
|
|
38
|
-
id: input.id ?? ids.inbox(),
|
|
39
|
-
memberId: input.memberId,
|
|
40
|
-
type: input.type,
|
|
41
|
-
ref: input.ref,
|
|
42
|
-
requiresDecision,
|
|
43
|
-
state: 'unread',
|
|
44
|
-
createdAt: options.at ?? Date.now(),
|
|
45
|
-
ackedAt: null,
|
|
46
|
-
disposition: null,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Acknowledge one item. Decision items may be marked read but cannot be marked
|
|
52
|
-
* done without an explicit decision; they can never be bulk-acked.
|
|
53
|
-
*/
|
|
54
|
-
export function ackInboxItem(item, input, options = {}) {
|
|
55
|
-
if (item.state === 'resolved' || item.state === 'dismissed' || item.state === 'superseded') return item;
|
|
56
|
-
const disposition = input.disposition ?? 'read';
|
|
57
|
-
if (disposition !== 'read' && disposition !== 'done' && disposition !== 'dismiss') {
|
|
58
|
-
fail(ERRORS.INVALID_ARGUMENT, 'disposition must be read, done or dismiss');
|
|
59
|
-
}
|
|
60
|
-
if (item.requiresDecision && disposition === 'done' && input.decision === undefined) {
|
|
61
|
-
fail(ERRORS.INVALID_STATE, 'a decision item requires an explicit decision before it can be done', {
|
|
62
|
-
details: { itemId: item.id },
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
return {
|
|
66
|
-
...item,
|
|
67
|
-
state: disposition === 'done' ? 'resolved' : disposition === 'dismiss' ? 'dismissed' : 'read',
|
|
68
|
-
disposition,
|
|
69
|
-
decision: input.decision ?? null,
|
|
70
|
-
ackedAt: options.at ?? Date.now(),
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/** Bulk read only touches non-decision items; decision items stay unread. */
|
|
75
|
-
export function markAllRead(items, options = {}) {
|
|
76
|
-
let changed = 0;
|
|
77
|
-
const next = items.map((item) => {
|
|
78
|
-
if (item.state !== 'unread' || item.requiresDecision) return item;
|
|
79
|
-
changed += 1;
|
|
80
|
-
return { ...item, state: 'read', disposition: 'read', ackedAt: options.at ?? Date.now() };
|
|
81
|
-
});
|
|
82
|
-
return { items: next, changed };
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/** Five fixed Human-inbox groups, in product order. */
|
|
86
|
-
export function inboxGroup(item) {
|
|
87
|
-
if (item.requiresDecision) return 'needs_decision';
|
|
88
|
-
if (item.type === 'review_requested') return 'needs_review';
|
|
89
|
-
if (item.type === 'mention') return 'mentions';
|
|
90
|
-
if (item.type === 'followed_task_update') return 'following';
|
|
91
|
-
if (item.type === 'member_stalled' || item.type === 'project_recovered' || item.type === 'task_blocked') return 'failures';
|
|
92
|
-
return 'other';
|
|
93
|
-
}
|
|
1
|
+
import { ERRORS, fail } from './errors.js';
|
|
2
|
+
import { ids } from './ids.js';
|
|
3
|
+
|
|
4
|
+
/** The 12 closed inbox types from 02 FR-028. */
|
|
5
|
+
export const INBOX_TYPES = new Set([
|
|
6
|
+
'mention',
|
|
7
|
+
'assigned',
|
|
8
|
+
'handoff',
|
|
9
|
+
'review_requested',
|
|
10
|
+
'review_result',
|
|
11
|
+
'task_blocked',
|
|
12
|
+
'dependency_cleared',
|
|
13
|
+
'member_stalled',
|
|
14
|
+
'project_recovered',
|
|
15
|
+
'followed_task_update',
|
|
16
|
+
'decision_required',
|
|
17
|
+
'stale_reply_rejected',
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
export const DECISION_TYPES = new Set(['decision_required']);
|
|
21
|
+
|
|
22
|
+
/** Progress reports mentioning Human are not actionable decisions. */
|
|
23
|
+
export function isInformationalThreadMention(item) {
|
|
24
|
+
return item?.ref?.category === 'thread_mention'
|
|
25
|
+
&& !(Array.isArray(item.ref?.questions) && item.ref.questions.length > 0);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Create one inbox item. It points at a source object; it is not a copy of the
|
|
30
|
+
* message body (the reader pulls the source on demand).
|
|
31
|
+
*/
|
|
32
|
+
export function createInboxItem(input, options = {}) {
|
|
33
|
+
if (typeof input.memberId !== 'string' || input.memberId === '') fail(ERRORS.INVALID_ARGUMENT, 'memberId is required');
|
|
34
|
+
if (!INBOX_TYPES.has(input.type)) fail(ERRORS.INVALID_ARGUMENT, `unknown inbox type: ${String(input.type)}`);
|
|
35
|
+
if (input.ref === undefined || input.ref === null) fail(ERRORS.INVALID_ARGUMENT, 'ref is required');
|
|
36
|
+
const requiresDecision = input.requiresDecision ?? DECISION_TYPES.has(input.type);
|
|
37
|
+
return {
|
|
38
|
+
id: input.id ?? ids.inbox(),
|
|
39
|
+
memberId: input.memberId,
|
|
40
|
+
type: input.type,
|
|
41
|
+
ref: input.ref,
|
|
42
|
+
requiresDecision,
|
|
43
|
+
state: 'unread',
|
|
44
|
+
createdAt: options.at ?? Date.now(),
|
|
45
|
+
ackedAt: null,
|
|
46
|
+
disposition: null,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Acknowledge one item. Decision items may be marked read but cannot be marked
|
|
52
|
+
* done without an explicit decision; they can never be bulk-acked.
|
|
53
|
+
*/
|
|
54
|
+
export function ackInboxItem(item, input, options = {}) {
|
|
55
|
+
if (item.state === 'resolved' || item.state === 'dismissed' || item.state === 'superseded') return item;
|
|
56
|
+
const disposition = input.disposition ?? 'read';
|
|
57
|
+
if (disposition !== 'read' && disposition !== 'done' && disposition !== 'dismiss') {
|
|
58
|
+
fail(ERRORS.INVALID_ARGUMENT, 'disposition must be read, done or dismiss');
|
|
59
|
+
}
|
|
60
|
+
if (item.requiresDecision && disposition === 'done' && input.decision === undefined) {
|
|
61
|
+
fail(ERRORS.INVALID_STATE, 'a decision item requires an explicit decision before it can be done', {
|
|
62
|
+
details: { itemId: item.id },
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
...item,
|
|
67
|
+
state: disposition === 'done' ? 'resolved' : disposition === 'dismiss' ? 'dismissed' : 'read',
|
|
68
|
+
disposition,
|
|
69
|
+
decision: input.decision ?? null,
|
|
70
|
+
ackedAt: options.at ?? Date.now(),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Bulk read only touches non-decision items; decision items stay unread. */
|
|
75
|
+
export function markAllRead(items, options = {}) {
|
|
76
|
+
let changed = 0;
|
|
77
|
+
const next = items.map((item) => {
|
|
78
|
+
if (item.state !== 'unread' || item.requiresDecision) return item;
|
|
79
|
+
changed += 1;
|
|
80
|
+
return { ...item, state: 'read', disposition: 'read', ackedAt: options.at ?? Date.now() };
|
|
81
|
+
});
|
|
82
|
+
return { items: next, changed };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Five fixed Human-inbox groups, in product order. */
|
|
86
|
+
export function inboxGroup(item) {
|
|
87
|
+
if (item.requiresDecision) return 'needs_decision';
|
|
88
|
+
if (item.type === 'review_requested') return 'needs_review';
|
|
89
|
+
if (item.type === 'mention') return 'mentions';
|
|
90
|
+
if (item.type === 'followed_task_update') return 'following';
|
|
91
|
+
if (item.type === 'member_stalled' || item.type === 'project_recovered' || item.type === 'task_blocked') return 'failures';
|
|
92
|
+
return 'other';
|
|
93
|
+
}
|