@suifei/dsh-ai-team 0.3.22 → 0.3.23
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/index.js +1 -1
- package/lib/host/service.js +61 -25
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/index.js
CHANGED
|
@@ -34,7 +34,7 @@ export const name = 'ai-team';
|
|
|
34
34
|
/** The workbench only makes sense where the Web carrier exists. */
|
|
35
35
|
export const inject = ['webServer', 'permissionPresets', 'sandboxPolicy'];
|
|
36
36
|
|
|
37
|
-
const VERSION = '0.3.
|
|
37
|
+
const VERSION = '0.3.23';
|
|
38
38
|
const PROJECT_ID = 'prj_main';
|
|
39
39
|
const HUMAN_ID = 'mem_human';
|
|
40
40
|
|
package/lib/host/service.js
CHANGED
|
@@ -168,39 +168,75 @@ export class TeamService {
|
|
|
168
168
|
reportQuestions = parseDecisionQuestions(readFileSync(reportPath, 'utf8'));
|
|
169
169
|
} catch { /* report may be unavailable; keep the Thread fallback */ }
|
|
170
170
|
}
|
|
171
|
-
|
|
171
|
+
const candidates = [];
|
|
172
172
|
for (const task of Object.values(this.state.tasks ?? {})) {
|
|
173
173
|
if (task.tombstone === true) continue;
|
|
174
174
|
for (const entry of this.state.threads?.[task.id]?.entries ?? []) {
|
|
175
175
|
const author = this.state.members?.[entry.authorId];
|
|
176
176
|
if (author?.kind !== 'agent' || !mentionsHuman(entry.body)) continue;
|
|
177
177
|
const key = `${task.id}:${entry.seq}`;
|
|
178
|
-
if (existing.has(key)) continue;
|
|
179
|
-
|
|
180
|
-
const useQuestions = reportQuestions.length > 0;
|
|
181
|
-
const item = createInboxItem({
|
|
182
|
-
memberId: humanId,
|
|
183
|
-
type: 'decision_required',
|
|
184
|
-
ref: {
|
|
185
|
-
taskId: task.id,
|
|
186
|
-
entrySeq: entry.seq,
|
|
187
|
-
memberId: entry.authorId,
|
|
188
|
-
category: 'thread_mention',
|
|
189
|
-
title: useQuestions ? `需 Human 决策 · ${reportQuestions.length} 问` : String(entry.body).slice(0, 180),
|
|
190
|
-
...(useQuestions ? { questions: reportQuestions, source: reportPath } : {}),
|
|
191
|
-
},
|
|
192
|
-
requiresDecision: true,
|
|
193
|
-
}, { at: this.now() });
|
|
194
|
-
await this.ledger.append({
|
|
195
|
-
type: 'inbox/item-created',
|
|
196
|
-
payload: { itemId: item.id, ...item },
|
|
197
|
-
actor: { kind: 'system' },
|
|
198
|
-
projectId,
|
|
199
|
-
at: this.now(),
|
|
200
|
-
});
|
|
201
|
-
created += 1;
|
|
178
|
+
if (existing.has(key) && reportQuestions.length === 0) continue;
|
|
179
|
+
candidates.push({ task, entry, key });
|
|
202
180
|
}
|
|
203
181
|
}
|
|
182
|
+
if (reportQuestions.length > 0 && candidates.length > 0) {
|
|
183
|
+
const alreadyStructured = Object.values(this.state.inbox ?? {}).some((item) =>
|
|
184
|
+
item.memberId === humanId
|
|
185
|
+
&& item.ref?.source === reportPath
|
|
186
|
+
&& Array.isArray(item.ref?.questions)
|
|
187
|
+
&& item.ref.questions.length > 0
|
|
188
|
+
&& !['resolved', 'dismissed', 'superseded'].includes(item.state));
|
|
189
|
+
if (alreadyStructured) return 0;
|
|
190
|
+
const chosen = candidates.find((candidate) => /§6|六问/.test(candidate.entry.body))
|
|
191
|
+
?? candidates.sort((left, right) => (right.entry.seq ?? 0) - (left.entry.seq ?? 0))[0];
|
|
192
|
+
const item = createInboxItem({
|
|
193
|
+
memberId: humanId,
|
|
194
|
+
type: 'decision_required',
|
|
195
|
+
ref: {
|
|
196
|
+
taskId: chosen.task.id,
|
|
197
|
+
entrySeq: chosen.entry.seq,
|
|
198
|
+
memberId: chosen.entry.authorId,
|
|
199
|
+
category: 'thread_mention',
|
|
200
|
+
title: `需 Human 决策 · ${reportQuestions.length} 问`,
|
|
201
|
+
questions: reportQuestions,
|
|
202
|
+
source: reportPath,
|
|
203
|
+
},
|
|
204
|
+
requiresDecision: true,
|
|
205
|
+
}, { at: this.now() });
|
|
206
|
+
await this.ledger.append({
|
|
207
|
+
type: 'inbox/item-created',
|
|
208
|
+
payload: { itemId: item.id, ...item },
|
|
209
|
+
actor: { kind: 'system' },
|
|
210
|
+
projectId,
|
|
211
|
+
at: this.now(),
|
|
212
|
+
});
|
|
213
|
+
return 1;
|
|
214
|
+
}
|
|
215
|
+
let created = 0;
|
|
216
|
+
for (const candidate of candidates) {
|
|
217
|
+
const { task, entry } = candidate;
|
|
218
|
+
existing.add(candidate.key);
|
|
219
|
+
const item = createInboxItem({
|
|
220
|
+
memberId: humanId,
|
|
221
|
+
type: 'decision_required',
|
|
222
|
+
ref: {
|
|
223
|
+
taskId: task.id,
|
|
224
|
+
entrySeq: entry.seq,
|
|
225
|
+
memberId: entry.authorId,
|
|
226
|
+
category: 'thread_mention',
|
|
227
|
+
title: String(entry.body).slice(0, 180),
|
|
228
|
+
},
|
|
229
|
+
requiresDecision: true,
|
|
230
|
+
}, { at: this.now() });
|
|
231
|
+
await this.ledger.append({
|
|
232
|
+
type: 'inbox/item-created',
|
|
233
|
+
payload: { itemId: item.id, ...item },
|
|
234
|
+
actor: { kind: 'system' },
|
|
235
|
+
projectId,
|
|
236
|
+
at: this.now(),
|
|
237
|
+
});
|
|
238
|
+
created += 1;
|
|
239
|
+
}
|
|
204
240
|
return created;
|
|
205
241
|
}
|
|
206
242
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suifei/dsh-ai-team",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.23",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "文渊阁 (Wenyuan Pavilion) — AI Team mode for DeepSeek Harness: concurrent projects, owned tasks, threads, inbox and an append-only team ledger",
|
|
6
6
|
"license": "MIT",
|