@suifei/dsh-ai-team 0.4.151 → 0.4.152

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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.152 - 2026-12-02
4
+
5
+ - 修复 PMO 冷恢复时缺少 `provider` 和 `model` 导致首轮请求失败。恢复原会话时一并传入默认模型和推理等级,宿主可继续沿用已保存的模型选择。原 PMO 会话、成员关系和任务可继续使用。感谢 @phm101299-ui 提供复现、根因和桌面验证(#112)。
6
+
3
7
  ## 0.4.151 - 2026-12-02
4
8
 
5
9
  - 统一新建人才的技能导入入口。单个 Markdown、完整技能文件夹、ZIP 与 `.skill` 都从「导入技能」进入。
package/README.md CHANGED
@@ -37,6 +37,7 @@
37
37
 
38
38
  ## 最近更新
39
39
 
40
+ - **PMO 重启后续跑**(0.4.152)。恢复原会话时即提供模型路由,避免首轮因缺少模型而失败。保留原 PMO 会话、成员关系和任务。感谢 [@phm101299-ui](https://github.com/phm101299-ui),[#112](https://github.com/suifei/dsh-ai-team/issues/112)。
40
41
  - **文渊阁直接导入技能包**(0.4.151)。「导入技能」可选 Markdown、技能文件夹、ZIP 和 `.skill`。只需安装文渊阁,即可安装完整包并在 DSH 确认可加载后加入技能列表。感谢 [@godfay-g](https://github.com/godfay-g),[#109](https://github.com/suifei/dsh-ai-team/issues/109)。
41
42
  - **给成员装技能包**(0.4.150)。成员资料和新建人才增加已安装技能选择和完整技能包导入。感谢 [@godfay-g](https://github.com/godfay-g),[#109](https://github.com/suifei/dsh-ai-team/issues/109)。
42
43
  - **会话标题栏看板入口**(0.4.149)。文渊阁管理的 PMO 和成员会话会显示文渊阁图标,点击直达所属项目的看板。运行时的轻微脉冲遵循系统的减少动态效果设置。
@@ -361,6 +362,7 @@ round-19 DeepSeek + Zhipu 双 provider
361
362
 
362
363
  | 贡献者 | 贡献 | 带来的进展 |
363
364
  |---|---|---|
365
+ | [@phm101299-ui](https://github.com/phm101299-ui) | PMO 冷恢复的复现、根因和桌面验证 [#112](https://github.com/suifei/dsh-ai-team/issues/112) | 让原 PMO 在宿主重启后带着模型路由继续工作,保留成员关系和任务 |
364
366
  | [@godfay-g](https://github.com/godfay-g) | 技能目录和 ZIP 的导入建议 [#109](https://github.com/suifei/dsh-ai-team/issues/109) | 成员与自定义人才可在文渊阁选择已安装的技能或导入完整技能包。0.4.151 统一新建人才的导入入口,并由文渊阁直接安装整包 |
365
367
  | [@qq958691165](https://github.com/qq958691165) | 归档项目的成员反馈、团队管理建议 [#103](https://github.com/suifei/dsh-ai-team/issues/103) | 人员池排除归档项目,侧栏集中管理项目成员与团队预设 |
366
368
  | [@Arnoldnuo](https://github.com/Arnoldnuo) | 桌面端启动 503 反馈 [#102](https://github.com/suifei/dsh-ai-team/issues/102) | 工作台提供分情况的 503 提示,快速开始说明内置 `desktop` 与 `web` 的安装和启动方式,连接错误提示引导核对 profile |
@@ -1,204 +1,204 @@
1
- import { lstat, mkdir, mkdtemp, realpath, rename, rm, stat, writeFile } from 'node:fs/promises';
2
- import { dirname, join, posix, relative } from 'node:path';
3
- import { buffer } from 'node:stream/consumers';
4
- import { setTimeout as delay } from 'node:timers/promises';
5
- import { crc32 } from 'node:zlib';
6
- import yauzl from 'yauzl';
7
- import { inspectFileSkill, MAX_SKILL_BODY_BYTES } from '../runtime/skill-provider.js';
8
-
9
- export const MAX_SKILL_IMPORT_REQUEST_BYTES = 64 * 1024 * 1024;
10
- const MAX_FILES = 10_000;
11
- const MAX_FILE_BYTES = 64 * 1024 * 1024;
12
- const MAX_EXPANDED_BYTES = 256 * 1024 * 1024;
13
- const MANIFEST = 'SKILL.md';
14
- const imports = new Set();
15
- const publishDelays = [0, 50, 150, 350, 800];
16
- const transientRenameErrors = new Set(['EACCES', 'EBUSY', 'EPERM']);
17
-
18
- function importError(message, { code = 'E_INVALID_SKILL_PACK', status = 400, details } = {}) {
19
- return Object.assign(new Error(message), { code, status, details });
20
- }
21
-
22
- function packTooLarge() {
23
- return importError('Skill package exceeds the import size limit.', { code: 'E_SKILL_PACK_TOO_LARGE', status: 413 });
24
- }
25
-
26
- function filePath(path) {
27
- if (typeof path !== 'string' || !path.isWellFormed() || path.split('/').some((part) => (
28
- part === '' || /[. ]$/.test(part) || /[\x00-\x1f<>:"\\|?*]/.test(part)
29
- || /^(?:con|prn|aux|nul|conin\$|conout\$|com[1-9¹²³]|lpt[1-9¹²³])(?:\.|$)/i.test(part)
30
- ))) throw importError('Skill package contains an invalid file path.');
31
- return path;
32
- }
33
-
34
- function base64(value) {
35
- if (typeof value !== 'string' || value.length % 4 !== 0 || /[^A-Za-z0-9+/=]|=[^=]|={3}/.test(value)) {
36
- throw importError('Skill package contains invalid file data.');
37
- }
38
- return Buffer.from(value, 'base64');
39
- }
40
-
41
- async function zipFiles(encoded) {
42
- try {
43
- const zip = await yauzl.fromBufferPromise(base64(encoded), { validateEntrySizes: true });
44
- if (zip.entryCount > MAX_FILES) throw packTooLarge();
45
- const files = [];
46
- let expanded = 0;
47
- for await (const entry of zip.eachEntry()) {
48
- const directory = entry.fileName.endsWith('/');
49
- const path = filePath(directory ? entry.fileName.slice(0, -1) : entry.fileName);
50
- const kind = (entry.externalFileAttributes >>> 16) & 0o170000;
51
- if (kind && kind !== (directory ? 0o040000 : 0o100000)) {
52
- throw importError('Skill package may contain only regular files and directories.');
53
- }
54
- if (directory) continue;
55
- if (entry.uncompressedSize > MAX_FILE_BYTES) throw packTooLarge();
56
- expanded += entry.uncompressedSize;
57
- if (expanded > MAX_EXPANDED_BYTES) throw packTooLarge();
58
- files.push({
59
- path,
60
- size: entry.uncompressedSize,
61
- async read() {
62
- let bytes;
63
- try {
64
- bytes = await buffer(await zip.openReadStreamPromise(entry));
65
- } catch {
66
- throw importError('A file in the ZIP skill package could not be read.');
67
- }
68
- if (crc32(bytes) !== entry.crc32) throw importError('A file in the ZIP skill package failed its checksum.');
69
- return bytes;
70
- },
71
- });
72
- }
73
- return files;
74
- } catch (error) {
75
- if (error?.status) throw error;
76
- throw importError('The ZIP or .skill package could not be opened.');
77
- }
78
- }
79
-
80
- async function readPack(payload) {
81
- const hasArchive = typeof payload?.zipBase64 === 'string';
82
- const hasFiles = Array.isArray(payload?.files);
83
- if (hasArchive === hasFiles) throw importError('Upload one skill folder or one ZIP/.skill package.');
84
- if (hasFiles && payload.files.length > MAX_FILES) throw packTooLarge();
85
- const files = hasArchive ? await zipFiles(payload.zipBase64) : payload.files.map((file) => {
86
- const bytes = base64(file?.contentBase64);
87
- if (bytes.length > MAX_FILE_BYTES) throw packTooLarge();
88
- return { path: filePath(file?.path), size: bytes.length, read: () => bytes };
89
- });
90
- const manifests = files.filter((file) => posix.basename(file.path) === MANIFEST)
91
- .sort((a, b) => a.path.length - b.path.length);
92
- if (!manifests.length) throw importError('The skill package is missing SKILL.md.');
93
- const manifest = manifests[0];
94
- const folder = posix.dirname(manifest.path);
95
- const prefix = folder === '.' ? '' : folder + '/';
96
- if (manifests.some((file) => !file.path.startsWith(prefix))) {
97
- throw importError('Select one skill package per import.');
98
- }
99
- if (manifest.size > MAX_SKILL_BODY_BYTES) throw packTooLarge();
100
- const selected = files.filter((file) => file.path.startsWith(prefix))
101
- .map((file) => ({ ...file, path: file.path.slice(prefix.length) }));
102
- const paths = new Set(selected.map((file) => file.path.normalize('NFC').toLowerCase()));
103
- if (paths.size !== selected.length) throw importError('The skill package contains duplicate file paths.');
104
- for (const path of paths) {
105
- for (let parent = posix.dirname(path); parent !== '.'; parent = posix.dirname(parent)) {
106
- if (paths.has(parent)) throw importError('The skill package uses a file as a directory.');
107
- }
108
- }
109
- const markdown = await manifest.read();
110
- let text;
111
- try {
112
- text = new TextDecoder('utf-8', { fatal: true }).decode(markdown);
113
- } catch {
114
- throw importError('SKILL.md must be UTF-8 text.');
115
- }
116
- const metadata = inspectFileSkill(text);
117
- if (metadata.problem || metadata.name.length > 64) {
118
- throw importError('SKILL.md needs a valid skill name, description, and invocation settings.', {
119
- details: { reason: metadata.problem ?? 'name-too-long' },
120
- });
121
- }
122
- if (!metadata.invocation.modelInvocable) throw importError('This skill disables model invocation.');
123
- return { name: filePath(metadata.name), selected, markdown };
124
- }
125
-
126
- async function installRoot(baseDir, project) {
127
- let root = await realpath(baseDir);
128
- if (!(await stat(root)).isDirectory()) throw importError('The skill destination must be a directory.');
129
- for (const segment of project ? ['.dsh', 'skills'] : ['skills']) {
130
- root = join(root, segment);
131
- await mkdir(root).catch((error) => { if (error.code !== 'EEXIST') throw error; });
132
- if (!(await lstat(root)).isDirectory()) throw importError('The skill destination must be a real directory.');
133
- }
134
- return root;
135
- }
136
-
137
- async function pathExists(path) {
138
- try {
139
- await lstat(path);
140
- return true;
141
- } catch (error) {
142
- if (error.code === 'ENOENT') return false;
143
- throw error;
144
- }
145
- }
146
-
147
- /** Both upload formats create one complete, discoverable DSH skill directory. */
148
- export async function installSkillPack(payload, { baseDir, project, installedNames, confirm, moveDirectory = rename }) {
149
- const { name, selected, markdown } = await readPack(payload);
150
- const conflict = () => importError('A skill with this name is already installed or being imported.', {
151
- code: 'E_SKILL_EXISTS', status: 409, details: { name },
152
- });
153
- if (installedNames?.has(name)) throw conflict();
154
- const root = await installRoot(baseDir, project);
155
- const target = join(root, name);
156
- const checkDestination = async () => {
157
- if (await pathExists(target) || await pathExists(target + '.md')) throw conflict();
158
- };
159
- if (imports.has(target)) throw conflict();
160
- imports.add(target);
161
- let temporary;
162
- try {
163
- await checkDestination();
164
- // DSH scans every immediate child of the skill root, including most dot directories.
165
- temporary = await mkdtemp(join(dirname(root), '.ai-team-skill-'));
166
- for (const file of selected) {
167
- const destination = join(temporary, file.path);
168
- await mkdir(dirname(destination), { recursive: true });
169
- await writeFile(destination, file.path === MANIFEST ? markdown : await file.read(), { flag: 'wx' });
170
- }
171
- for (const [attempt, pause] of publishDelays.entries()) {
172
- if (pause > 0) await delay(pause);
173
- await checkDestination();
174
- try {
175
- await moveDirectory(temporary, target);
176
- break;
177
- } catch (error) {
178
- if (attempt === publishDelays.length - 1 || !transientRenameErrors.has(error?.code)) {
179
- await checkDestination();
180
- throw error;
181
- }
182
- }
183
- }
184
- // Keep ownership of this newly published directory until the DSH catalog confirms it.
185
- temporary = target;
186
- const installed = await confirm({ name, path: join(target, MANIFEST) });
187
- temporary = undefined;
188
- return installed;
189
- } finally {
190
- try {
191
- if (temporary) {
192
- const canonical = await realpath(temporary).catch((error) => {
193
- if (error.code === 'ENOENT') return null;
194
- throw error;
195
- });
196
- if (canonical !== null && relative(temporary, canonical) === '') {
197
- await rm(temporary, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
198
- }
199
- }
200
- } finally {
201
- imports.delete(target);
202
- }
203
- }
204
- }
1
+ import { lstat, mkdir, mkdtemp, realpath, rename, rm, stat, writeFile } from 'node:fs/promises';
2
+ import { dirname, join, posix, relative } from 'node:path';
3
+ import { buffer } from 'node:stream/consumers';
4
+ import { setTimeout as delay } from 'node:timers/promises';
5
+ import { crc32 } from 'node:zlib';
6
+ import yauzl from 'yauzl';
7
+ import { inspectFileSkill, MAX_SKILL_BODY_BYTES } from '../runtime/skill-provider.js';
8
+
9
+ export const MAX_SKILL_IMPORT_REQUEST_BYTES = 64 * 1024 * 1024;
10
+ const MAX_FILES = 10_000;
11
+ const MAX_FILE_BYTES = 64 * 1024 * 1024;
12
+ const MAX_EXPANDED_BYTES = 256 * 1024 * 1024;
13
+ const MANIFEST = 'SKILL.md';
14
+ const imports = new Set();
15
+ const publishDelays = [0, 50, 150, 350, 800];
16
+ const transientRenameErrors = new Set(['EACCES', 'EBUSY', 'EPERM']);
17
+
18
+ function importError(message, { code = 'E_INVALID_SKILL_PACK', status = 400, details } = {}) {
19
+ return Object.assign(new Error(message), { code, status, details });
20
+ }
21
+
22
+ function packTooLarge() {
23
+ return importError('Skill package exceeds the import size limit.', { code: 'E_SKILL_PACK_TOO_LARGE', status: 413 });
24
+ }
25
+
26
+ function filePath(path) {
27
+ if (typeof path !== 'string' || !path.isWellFormed() || path.split('/').some((part) => (
28
+ part === '' || /[. ]$/.test(part) || /[\x00-\x1f<>:"\\|?*]/.test(part)
29
+ || /^(?:con|prn|aux|nul|conin\$|conout\$|com[1-9¹²³]|lpt[1-9¹²³])(?:\.|$)/i.test(part)
30
+ ))) throw importError('Skill package contains an invalid file path.');
31
+ return path;
32
+ }
33
+
34
+ function base64(value) {
35
+ if (typeof value !== 'string' || value.length % 4 !== 0 || /[^A-Za-z0-9+/=]|=[^=]|={3}/.test(value)) {
36
+ throw importError('Skill package contains invalid file data.');
37
+ }
38
+ return Buffer.from(value, 'base64');
39
+ }
40
+
41
+ async function zipFiles(encoded) {
42
+ try {
43
+ const zip = await yauzl.fromBufferPromise(base64(encoded), { validateEntrySizes: true });
44
+ if (zip.entryCount > MAX_FILES) throw packTooLarge();
45
+ const files = [];
46
+ let expanded = 0;
47
+ for await (const entry of zip.eachEntry()) {
48
+ const directory = entry.fileName.endsWith('/');
49
+ const path = filePath(directory ? entry.fileName.slice(0, -1) : entry.fileName);
50
+ const kind = (entry.externalFileAttributes >>> 16) & 0o170000;
51
+ if (kind && kind !== (directory ? 0o040000 : 0o100000)) {
52
+ throw importError('Skill package may contain only regular files and directories.');
53
+ }
54
+ if (directory) continue;
55
+ if (entry.uncompressedSize > MAX_FILE_BYTES) throw packTooLarge();
56
+ expanded += entry.uncompressedSize;
57
+ if (expanded > MAX_EXPANDED_BYTES) throw packTooLarge();
58
+ files.push({
59
+ path,
60
+ size: entry.uncompressedSize,
61
+ async read() {
62
+ let bytes;
63
+ try {
64
+ bytes = await buffer(await zip.openReadStreamPromise(entry));
65
+ } catch {
66
+ throw importError('A file in the ZIP skill package could not be read.');
67
+ }
68
+ if (crc32(bytes) !== entry.crc32) throw importError('A file in the ZIP skill package failed its checksum.');
69
+ return bytes;
70
+ },
71
+ });
72
+ }
73
+ return files;
74
+ } catch (error) {
75
+ if (error?.status) throw error;
76
+ throw importError('The ZIP or .skill package could not be opened.');
77
+ }
78
+ }
79
+
80
+ async function readPack(payload) {
81
+ const hasArchive = typeof payload?.zipBase64 === 'string';
82
+ const hasFiles = Array.isArray(payload?.files);
83
+ if (hasArchive === hasFiles) throw importError('Upload one skill folder or one ZIP/.skill package.');
84
+ if (hasFiles && payload.files.length > MAX_FILES) throw packTooLarge();
85
+ const files = hasArchive ? await zipFiles(payload.zipBase64) : payload.files.map((file) => {
86
+ const bytes = base64(file?.contentBase64);
87
+ if (bytes.length > MAX_FILE_BYTES) throw packTooLarge();
88
+ return { path: filePath(file?.path), size: bytes.length, read: () => bytes };
89
+ });
90
+ const manifests = files.filter((file) => posix.basename(file.path) === MANIFEST)
91
+ .sort((a, b) => a.path.length - b.path.length);
92
+ if (!manifests.length) throw importError('The skill package is missing SKILL.md.');
93
+ const manifest = manifests[0];
94
+ const folder = posix.dirname(manifest.path);
95
+ const prefix = folder === '.' ? '' : folder + '/';
96
+ if (manifests.some((file) => !file.path.startsWith(prefix))) {
97
+ throw importError('Select one skill package per import.');
98
+ }
99
+ if (manifest.size > MAX_SKILL_BODY_BYTES) throw packTooLarge();
100
+ const selected = files.filter((file) => file.path.startsWith(prefix))
101
+ .map((file) => ({ ...file, path: file.path.slice(prefix.length) }));
102
+ const paths = new Set(selected.map((file) => file.path.normalize('NFC').toLowerCase()));
103
+ if (paths.size !== selected.length) throw importError('The skill package contains duplicate file paths.');
104
+ for (const path of paths) {
105
+ for (let parent = posix.dirname(path); parent !== '.'; parent = posix.dirname(parent)) {
106
+ if (paths.has(parent)) throw importError('The skill package uses a file as a directory.');
107
+ }
108
+ }
109
+ const markdown = await manifest.read();
110
+ let text;
111
+ try {
112
+ text = new TextDecoder('utf-8', { fatal: true }).decode(markdown);
113
+ } catch {
114
+ throw importError('SKILL.md must be UTF-8 text.');
115
+ }
116
+ const metadata = inspectFileSkill(text);
117
+ if (metadata.problem || metadata.name.length > 64) {
118
+ throw importError('SKILL.md needs a valid skill name, description, and invocation settings.', {
119
+ details: { reason: metadata.problem ?? 'name-too-long' },
120
+ });
121
+ }
122
+ if (!metadata.invocation.modelInvocable) throw importError('This skill disables model invocation.');
123
+ return { name: filePath(metadata.name), selected, markdown };
124
+ }
125
+
126
+ async function installRoot(baseDir, project) {
127
+ let root = await realpath(baseDir);
128
+ if (!(await stat(root)).isDirectory()) throw importError('The skill destination must be a directory.');
129
+ for (const segment of project ? ['.dsh', 'skills'] : ['skills']) {
130
+ root = join(root, segment);
131
+ await mkdir(root).catch((error) => { if (error.code !== 'EEXIST') throw error; });
132
+ if (!(await lstat(root)).isDirectory()) throw importError('The skill destination must be a real directory.');
133
+ }
134
+ return root;
135
+ }
136
+
137
+ async function pathExists(path) {
138
+ try {
139
+ await lstat(path);
140
+ return true;
141
+ } catch (error) {
142
+ if (error.code === 'ENOENT') return false;
143
+ throw error;
144
+ }
145
+ }
146
+
147
+ /** Both upload formats create one complete, discoverable DSH skill directory. */
148
+ export async function installSkillPack(payload, { baseDir, project, installedNames, confirm, moveDirectory = rename }) {
149
+ const { name, selected, markdown } = await readPack(payload);
150
+ const conflict = () => importError('A skill with this name is already installed or being imported.', {
151
+ code: 'E_SKILL_EXISTS', status: 409, details: { name },
152
+ });
153
+ if (installedNames?.has(name)) throw conflict();
154
+ const root = await installRoot(baseDir, project);
155
+ const target = join(root, name);
156
+ const checkDestination = async () => {
157
+ if (await pathExists(target) || await pathExists(target + '.md')) throw conflict();
158
+ };
159
+ if (imports.has(target)) throw conflict();
160
+ imports.add(target);
161
+ let temporary;
162
+ try {
163
+ await checkDestination();
164
+ // DSH scans every immediate child of the skill root, including most dot directories.
165
+ temporary = await mkdtemp(join(dirname(root), '.ai-team-skill-'));
166
+ for (const file of selected) {
167
+ const destination = join(temporary, file.path);
168
+ await mkdir(dirname(destination), { recursive: true });
169
+ await writeFile(destination, file.path === MANIFEST ? markdown : await file.read(), { flag: 'wx' });
170
+ }
171
+ for (const [attempt, pause] of publishDelays.entries()) {
172
+ if (pause > 0) await delay(pause);
173
+ await checkDestination();
174
+ try {
175
+ await moveDirectory(temporary, target);
176
+ break;
177
+ } catch (error) {
178
+ if (attempt === publishDelays.length - 1 || !transientRenameErrors.has(error?.code)) {
179
+ await checkDestination();
180
+ throw error;
181
+ }
182
+ }
183
+ }
184
+ // Keep ownership of this newly published directory until the DSH catalog confirms it.
185
+ temporary = target;
186
+ const installed = await confirm({ name, path: join(target, MANIFEST) });
187
+ temporary = undefined;
188
+ return installed;
189
+ } finally {
190
+ try {
191
+ if (temporary) {
192
+ const canonical = await realpath(temporary).catch((error) => {
193
+ if (error.code === 'ENOENT') return null;
194
+ throw error;
195
+ });
196
+ if (canonical !== null && relative(temporary, canonical) === '') {
197
+ await rm(temporary, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
198
+ }
199
+ }
200
+ } finally {
201
+ imports.delete(target);
202
+ }
203
+ }
204
+ }
@@ -52,6 +52,17 @@ export async function ensureHostAgent(options) {
52
52
  if (agents === undefined || typeof agents.create !== 'function') {
53
53
  throw new HostAgentError('E_RUNTIME_UNAVAILABLE', 'agents service is unavailable');
54
54
  }
55
+ const selection = typeof options.agentDefaultModel?.currentSelection === 'function'
56
+ ? options.agentDefaultModel.currentSelection()
57
+ : null;
58
+ let agentOptions;
59
+ if (typeof selection?.provider === 'string' && selection.provider !== ''
60
+ && typeof selection?.model === 'string' && selection.model !== '') {
61
+ agentOptions = { provider: selection.provider, model: selection.model };
62
+ if (typeof selection.reasoningEffort === 'string' && selection.reasoningEffort !== '') {
63
+ agentOptions.reasoningEffort = selection.reasoningEffort;
64
+ }
65
+ }
55
66
  // Repair a Host Agent archived by an earlier revision: the archive gate
56
67
  // covers the host's whole subagent lineage, so every member turn would end
57
68
  // blocked before any model request. `unarchiveSession` resolves without
@@ -70,20 +81,11 @@ export async function ensureHostAgent(options) {
70
81
  // Persist the resolved route into the session log. Live AgentOptions die
71
82
  // with the process; without a recorded selection a restored session renders
72
83
  // prompts with an unresolvable {{model}} variable.
73
- const persistSelection = (sessionId, selection) => {
84
+ const persistSelection = (sessionId) => {
85
+ if (agentOptions === undefined) return;
74
86
  try {
75
87
  const session = options.sessions?.get?.(sessionId);
76
- if (session === undefined || session === null || typeof session.append !== 'function') return;
77
- if (typeof selection?.provider !== 'string' || typeof selection?.model !== 'string') return;
78
- // 推理等级一并记下,否则恢复出来的会话按模型默认档走。
79
- const effort = typeof selection.reasoningEffort === 'string' && selection.reasoningEffort !== ''
80
- ? selection.reasoningEffort
81
- : null;
82
- session.append('model/selection', {
83
- provider: selection.provider,
84
- model: selection.model,
85
- ...(effort === null ? {} : { reasoningEffort: effort }),
86
- });
88
+ session?.append?.('model/selection', agentOptions);
87
89
  } catch (error) {
88
90
  reportFail('host.model.persist.fail', {}, '[ai-team] host model selection persist failed: ' + (error?.message ?? error));
89
91
  }
@@ -94,7 +96,11 @@ export async function ensureHostAgent(options) {
94
96
  let release = async () => {};
95
97
  if (agent === undefined) {
96
98
  try {
97
- const handle = await agents.resume({ resumeSessionId: options.resumeSessionId });
99
+ // The inbox can wake before resume returns. Supply the initial route
100
+ // at construction, leaving any persisted selection to the host.
101
+ const request = { resumeSessionId: options.resumeSessionId };
102
+ if (agentOptions !== undefined) request.agentOptions = agentOptions;
103
+ const handle = await agents.resume(request);
98
104
  agent = handle?.agent;
99
105
  release = async () => { try { await handle?.dispose?.(); } catch { /* already gone */ } };
100
106
  } catch (error) {
@@ -119,21 +125,15 @@ export async function ensureHostAgent(options) {
119
125
  );
120
126
  } else {
121
127
  await unarchiveHost(options.resumeSessionId);
122
- const selection = typeof options.agentDefaultModel?.currentSelection === 'function' ? options.agentDefaultModel.currentSelection() : null;
123
- persistSelection(options.resumeSessionId, selection);
128
+ if (live !== undefined && live.model?.current?.() === undefined) persistSelection(options.resumeSessionId);
124
129
  return { agent, created: false, resumed: true, sessionId: options.resumeSessionId, dispose: release };
125
130
  }
126
131
  }
127
132
 
128
- const selection = typeof options.agentDefaultModel?.currentSelection === 'function'
129
- ? options.agentDefaultModel.currentSelection()
130
- : null;
131
- if (selection === null || typeof selection.provider !== 'string' || typeof selection.model !== 'string') {
133
+ if (agentOptions === undefined) {
132
134
  throw new HostAgentError('E_RUNTIME_UNAVAILABLE', 'no default provider/model is configured for the Team Host Agent');
133
135
  }
134
136
  const sessionId = options.newSessionId?.() ?? `session-team-host-${randomUUID()}`;
135
- const agentOptions = { provider: selection.provider, model: selection.model };
136
- if (typeof selection.reasoningEffort === 'string') agentOptions.reasoningEffort = selection.reasoningEffort;
137
137
  let handle;
138
138
  try {
139
139
  handle = await agents.create({
@@ -146,7 +146,7 @@ export async function ensureHostAgent(options) {
146
146
  cause: error?.code ?? null,
147
147
  });
148
148
  }
149
- persistSelection(sessionId, selection);
149
+ persistSelection(sessionId);
150
150
  const host = handle.agent;
151
151
  await unarchiveHost(sessionId);
152
152
  return {
package/package.json CHANGED
@@ -1,75 +1,75 @@
1
- {
2
- "name": "@suifei/dsh-ai-team",
3
- "version": "0.4.151",
4
- "type": "module",
5
- "description": "文渊阁 (Wenyuan Pavilion) — AI Team mode for DeepSeek Harness: concurrent projects, owned tasks, threads, inbox and an append-only team ledger",
6
- "license": "MIT",
7
- "author": "suifei",
8
- "homepage": "https://github.com/suifei/dsh-ai-team#readme",
9
- "repository": {
10
- "type": "git",
11
- "url": "https://github.com/suifei/dsh-ai-team.git"
12
- },
13
- "bugs": {
14
- "url": "https://github.com/suifei/dsh-ai-team/issues"
15
- },
16
- "keywords": [
17
- "deepseek-harness",
18
- "dsh",
19
- "dsh-plugin",
20
- "ai-team",
21
- "multi-agent",
22
- "agent-team",
23
- "task-ledger",
24
- "wenyuan"
25
- ],
26
- "publishConfig": {
27
- "access": "public"
28
- },
29
- "icon": "./icon.svg",
30
- "exports": {
31
- ".": "./index.js",
32
- "./client": "./client.js",
33
- "./package.json": "./package.json",
34
- "./lib/*": "./lib/*",
35
- "./locale/*.json": "./locale/*.json",
36
- "./icon": "./icon.svg"
37
- },
38
- "dependencies": {
39
- "@deepseek-ai/schemastery": "~3.19.0",
40
- "yaml": "~2.9.1",
41
- "yauzl": "3.4.0"
42
- },
43
- "files": [
44
- "index.js",
45
- "client.js",
46
- "cordis.patch.yml",
47
- "icon.svg",
48
- "locale/*.json",
49
- "lib/**/*.js",
50
- "lib/vendor/skillopt/scripts/*.py",
51
- "lib/vendor/skillopt/skillopt_sleep/**/*.py",
52
- "lib/vendor/skillopt/skillopt_sleep/**/*.mjs",
53
- "lib/vendor/skillopt/requirements.txt",
54
- "lib/vendor/skillopt/LICENSE",
55
- "skills/**/*",
56
- "talents/**/*",
57
- "teams/**/*",
58
- "README.md",
59
- "CHANGELOG.md",
60
- "LICENSE"
61
- ],
62
- "scripts": {
63
- "test": "node --test"
64
- },
65
- "dsh": {
66
- "bundle": {
67
- "patch": "./cordis.patch.yml"
68
- },
69
- "client": {
70
- "platform": "web",
71
- "immediately": true,
72
- "inject": []
73
- }
74
- }
75
- }
1
+ {
2
+ "name": "@suifei/dsh-ai-team",
3
+ "version": "0.4.152",
4
+ "type": "module",
5
+ "description": "文渊阁 (Wenyuan Pavilion) — AI Team mode for DeepSeek Harness: concurrent projects, owned tasks, threads, inbox and an append-only team ledger",
6
+ "license": "MIT",
7
+ "author": "suifei",
8
+ "homepage": "https://github.com/suifei/dsh-ai-team#readme",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/suifei/dsh-ai-team.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/suifei/dsh-ai-team/issues"
15
+ },
16
+ "keywords": [
17
+ "deepseek-harness",
18
+ "dsh",
19
+ "dsh-plugin",
20
+ "ai-team",
21
+ "multi-agent",
22
+ "agent-team",
23
+ "task-ledger",
24
+ "wenyuan"
25
+ ],
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "icon": "./icon.svg",
30
+ "exports": {
31
+ ".": "./index.js",
32
+ "./client": "./client.js",
33
+ "./package.json": "./package.json",
34
+ "./lib/*": "./lib/*",
35
+ "./locale/*.json": "./locale/*.json",
36
+ "./icon": "./icon.svg"
37
+ },
38
+ "dependencies": {
39
+ "@deepseek-ai/schemastery": "~3.19.0",
40
+ "yaml": "~2.9.1",
41
+ "yauzl": "3.4.0"
42
+ },
43
+ "files": [
44
+ "index.js",
45
+ "client.js",
46
+ "cordis.patch.yml",
47
+ "icon.svg",
48
+ "locale/*.json",
49
+ "lib/**/*.js",
50
+ "lib/vendor/skillopt/scripts/*.py",
51
+ "lib/vendor/skillopt/skillopt_sleep/**/*.py",
52
+ "lib/vendor/skillopt/skillopt_sleep/**/*.mjs",
53
+ "lib/vendor/skillopt/requirements.txt",
54
+ "lib/vendor/skillopt/LICENSE",
55
+ "skills/**/*",
56
+ "talents/**/*",
57
+ "teams/**/*",
58
+ "README.md",
59
+ "CHANGELOG.md",
60
+ "LICENSE"
61
+ ],
62
+ "scripts": {
63
+ "test": "node --test"
64
+ },
65
+ "dsh": {
66
+ "bundle": {
67
+ "patch": "./cordis.patch.yml"
68
+ },
69
+ "client": {
70
+ "platform": "web",
71
+ "immediately": true,
72
+ "inject": []
73
+ }
74
+ }
75
+ }