@fubai-fenzhi/dsh-session-admin 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +71 -2
- package/cordis.patch.yml +8 -0
- package/lib/index.js +283 -0
- package/package.json +41 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DSH coordination team
|
|
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
|
@@ -1,3 +1,72 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-session-admin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
给 DSH agent 的**会话管理**工具:改名(`session_rename`)与归档(`session_archive`),**走 Host 现有服务**(与 GUI 同一写入路径),不手改投影缓存/会话日志。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
dsh plugin install_bundle --target npm:@fubai-fenzhi/dsh-session-admin
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
> 注意:npm 上的 `dsh-session-admin` 是**别人的包**(Jemius/dsh-session-manager),同名不同物,勿装;认准 scoped 名 `@fubai-fenzhi/dsh-session-admin`。
|
|
12
|
+
|
|
13
|
+
## 工具
|
|
14
|
+
|
|
15
|
+
### session_rename
|
|
16
|
+
```json
|
|
17
|
+
{ "sessionId": "self", "title": "新标题" }
|
|
18
|
+
```
|
|
19
|
+
- `sessionId`:会话 id,或 `"self"`(调用者当前会话)
|
|
20
|
+
- 走 `sessionTitle.rename()`:追加 `session/title` 事件,标题持久化并 **pin**(该会话自动标题不再更新)
|
|
21
|
+
- 错误:`E_TITLE_EMPTY` / `E_TITLE_TOO_LONG` / `E_SESSION_NOT_FOUND` / `E_SERVICE_UNAVAILABLE`
|
|
22
|
+
|
|
23
|
+
### session_archive
|
|
24
|
+
```json
|
|
25
|
+
{ "sessionId": "session-…", "confirm": true, "stopActivity": false }
|
|
26
|
+
```
|
|
27
|
+
- **默认 dryRun**(不写任何东西),`confirm: true` 才真归档
|
|
28
|
+
- `archive: false` + `confirm: true` 执行 unarchive
|
|
29
|
+
- **禁止归档当前会话**(`E_SELF_ARCHIVE_FORBIDDEN`)
|
|
30
|
+
- 运行中的会话默认拒归档(Host 抛 `WorkspaceActiveSessionError`);`stopActivity: true` 强制归档并停止其工作
|
|
31
|
+
- 归档会同时丢弃该会话的 pin,并可能回收该会话创建的 clean worktree(Host 行为,无开关)
|
|
32
|
+
- 权限:`archive` 只允许 `allowedActors` 里的 actor;默认空 = 禁止 archive(rename 默认全员可用)
|
|
33
|
+
|
|
34
|
+
### session_team_enable
|
|
35
|
+
```json
|
|
36
|
+
{ "enable": true }
|
|
37
|
+
```
|
|
38
|
+
- 只允许**当前 root 会话**调用(`ctx.agents.currentInitiator()` + `agentTeams.setEnabled`);子会话继承选择
|
|
39
|
+
- `enable: false` 关闭
|
|
40
|
+
- 把 `team/mode` 写入当前 root 的会话日志;不需要 UI 开关
|
|
41
|
+
- 错误:`E_SERVICE_UNAVAILABLE` / `E_NOT_ROOT` / `E_TEAM_ENABLE_FAILED`
|
|
42
|
+
|
|
43
|
+
## 配置(cordis.patch.yml)
|
|
44
|
+
|
|
45
|
+
| 键 | 默认 | 说明 |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| `auditFile` | `~/.dsh/session-admin-audit.jsonl` | 审计文件;**不落 coordination/** |
|
|
48
|
+
| `maxTitleBytes` | `120` | 标题 UTF-8 字节上限 |
|
|
49
|
+
| `allowedActors` | `[]` | 允许 archive 的 actor 名单(空 = 谁都不可 archive) |
|
|
50
|
+
| `rosterFile` | 自动探测:`workingDirectory.defaultDirectory/coordination/state.json` → `$TEAM_ROOM_DIR/state.json` → `<cwd>/coordination/state.json` | 用于 actor 名字回查(agent 无 name 时按 sessionId 反查;查不到退回 id)。**自动探测不到时请显式配置**,否则 `allowedActors: ['阿衡']` 这类按名字的白名单会不匹配 |
|
|
51
|
+
|
|
52
|
+
## 审计
|
|
53
|
+
|
|
54
|
+
每行 JSON:`{at, actor, action, sessionId, before, after, result}`;`before/after` **不存标题全文**,只存前 40 字节 + sha256。
|
|
55
|
+
|
|
56
|
+
## 回滚
|
|
57
|
+
|
|
58
|
+
- 改名:审计里有 before 摘要;用同一工具改回旧标题(或调用 Host 的 refresh 重新生成)
|
|
59
|
+
- 归档:`session_archive { archive: false, confirm: true }`
|
|
60
|
+
- 插件级:卸载 bundle 即回,仓库/会话日志零改动
|
|
61
|
+
|
|
62
|
+
## 测试
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
npm test # 20 条:正常/空标题/超长/非 live/自归档/重复归档/服务缺失/权限/Team 开关/actor 名回查
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## 边界
|
|
69
|
+
|
|
70
|
+
- 只改标题与归档标记,不读会话正文
|
|
71
|
+
- 不提供会话列表/正文读取
|
|
72
|
+
- 与 team-room 解耦,独立包
|
package/cordis.patch.yml
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { appendFileSync, mkdirSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { dirname, join } from 'node:path';
|
|
5
|
+
|
|
6
|
+
export const name = 'dsh-session-admin';
|
|
7
|
+
export const inject = ['tools', 'agents'];
|
|
8
|
+
|
|
9
|
+
export function normalizeConfig(raw = {}) {
|
|
10
|
+
const source = raw && typeof raw === 'object' ? raw : {};
|
|
11
|
+
return {
|
|
12
|
+
auditFile: typeof source.auditFile === 'string' && source.auditFile.trim()
|
|
13
|
+
? source.auditFile.trim()
|
|
14
|
+
: join(homedir(), '.dsh', 'session-admin-audit.jsonl'),
|
|
15
|
+
maxTitleBytes: Number.isInteger(source.maxTitleBytes) && source.maxTitleBytes > 0 ? source.maxTitleBytes : 120,
|
|
16
|
+
allowedActors: Array.isArray(source.allowedActors) ? source.allowedActors.map(String) : [],
|
|
17
|
+
rosterFile: typeof source.rosterFile === 'string' ? source.rosterFile.trim() : '',
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function normalizeTitle(input, maxBytes) {
|
|
22
|
+
const title = String(input ?? '').replace(/\s+/g, ' ').trim();
|
|
23
|
+
if (!title) {
|
|
24
|
+
const error = new Error('title is empty');
|
|
25
|
+
error.code = 'E_TITLE_EMPTY';
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
if (Buffer.byteLength(title, 'utf8') > maxBytes) {
|
|
29
|
+
const error = new Error('title too long');
|
|
30
|
+
error.code = 'E_TITLE_TOO_LONG';
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
return title;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function titleDigest(title) {
|
|
37
|
+
const text = String(title ?? '');
|
|
38
|
+
return {
|
|
39
|
+
prefix: Buffer.from(text, 'utf8').subarray(0, 40).toString('utf8'),
|
|
40
|
+
sha256: createHash('sha256').update(text).digest('hex'),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const E = (code, message) => {
|
|
45
|
+
const error = new Error(message ?? code);
|
|
46
|
+
error.code = code;
|
|
47
|
+
return error;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export function apply(ctx, rawConfig) {
|
|
51
|
+
const cfg = normalizeConfig(rawConfig);
|
|
52
|
+
|
|
53
|
+
function getService(key) {
|
|
54
|
+
try {
|
|
55
|
+
return typeof ctx.get === 'function' ? ctx.get(key) : undefined;
|
|
56
|
+
} catch {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function resolveRosterFile() {
|
|
62
|
+
if (cfg.rosterFile) return cfg.rosterFile;
|
|
63
|
+
const candidates = [];
|
|
64
|
+
try {
|
|
65
|
+
const wd = ctx.get?.('workingDirectory');
|
|
66
|
+
if (wd?.defaultDirectory) candidates.push(join(wd.defaultDirectory, 'coordination', 'state.json'));
|
|
67
|
+
} catch {
|
|
68
|
+
/* fall through */
|
|
69
|
+
}
|
|
70
|
+
if (process.env.TEAM_ROOM_DIR) candidates.push(join(process.env.TEAM_ROOM_DIR, 'state.json'));
|
|
71
|
+
try {
|
|
72
|
+
const cwd = process.cwd();
|
|
73
|
+
candidates.push(join(cwd, 'coordination', 'state.json'));
|
|
74
|
+
} catch {
|
|
75
|
+
/* ignore */
|
|
76
|
+
}
|
|
77
|
+
for (const candidate of candidates) {
|
|
78
|
+
try {
|
|
79
|
+
if (readFileSync(candidate, 'utf8')) return candidate;
|
|
80
|
+
} catch {
|
|
81
|
+
/* try next */
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return candidates[0] ?? '';
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
let rosterCache = { at: 0, file: '', map: new Map() };
|
|
88
|
+
function rosterName(sessionId) {
|
|
89
|
+
const file = resolveRosterFile();
|
|
90
|
+
if (!file || !sessionId) return undefined;
|
|
91
|
+
const now = Date.now();
|
|
92
|
+
if (now - rosterCache.at > 5000 || rosterCache.file !== file) {
|
|
93
|
+
const map = new Map();
|
|
94
|
+
try {
|
|
95
|
+
const state = JSON.parse(readFileSync(file, 'utf8'));
|
|
96
|
+
for (const member of Array.isArray(state.members) ? state.members : []) {
|
|
97
|
+
if (member?.sessionId && member?.name) map.set(String(member.sessionId), String(member.name));
|
|
98
|
+
}
|
|
99
|
+
} catch {
|
|
100
|
+
/* 名册读不到不影响主流程 */
|
|
101
|
+
}
|
|
102
|
+
rosterCache = { at: now, file, map };
|
|
103
|
+
}
|
|
104
|
+
return rosterCache.map.get(String(sessionId));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function callingAgent() {
|
|
108
|
+
try {
|
|
109
|
+
const agents = getService('agents');
|
|
110
|
+
if (!agents || typeof agents.currentInitiator !== 'function') return undefined;
|
|
111
|
+
return agents.currentInitiator();
|
|
112
|
+
} catch {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function actor() {
|
|
118
|
+
try {
|
|
119
|
+
const agent = callingAgent();
|
|
120
|
+
const id = String(agent?.id ?? '');
|
|
121
|
+
const rawName = String(agent?.name ?? '').trim();
|
|
122
|
+
if (rawName && rawName !== 'unknown') return { id, name: rawName };
|
|
123
|
+
const mapped = rosterName(id);
|
|
124
|
+
if (mapped) return { id, name: mapped };
|
|
125
|
+
return { id, name: id || 'unknown' };
|
|
126
|
+
} catch {
|
|
127
|
+
return { id: '', name: 'unknown' };
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function audit(event) {
|
|
132
|
+
const current = actor();
|
|
133
|
+
const record = { at: new Date().toISOString(), actor: current.name, actorId: current.id, ...event };
|
|
134
|
+
try {
|
|
135
|
+
mkdirSync(dirname(cfg.auditFile), { recursive: true });
|
|
136
|
+
appendFileSync(cfg.auditFile, JSON.stringify(record) + '\n');
|
|
137
|
+
} catch {
|
|
138
|
+
/* 审计写不进去不能阻断操作,但结果里标记 */
|
|
139
|
+
}
|
|
140
|
+
return record;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function resolveSession(sessionId) {
|
|
144
|
+
const sessions = getService('sessions');
|
|
145
|
+
if (!sessions) throw E('E_SERVICE_UNAVAILABLE', 'sessions service unavailable');
|
|
146
|
+
const id = sessionId === 'self' ? actor().id : String(sessionId ?? '');
|
|
147
|
+
if (!id) throw E('E_SESSION_NOT_FOUND', 'sessionId is required');
|
|
148
|
+
let session;
|
|
149
|
+
try {
|
|
150
|
+
session = sessions.get(id);
|
|
151
|
+
} catch {
|
|
152
|
+
session = undefined;
|
|
153
|
+
}
|
|
154
|
+
if (!session) throw E('E_SESSION_NOT_FOUND', 'session not found or not live: ' + id);
|
|
155
|
+
return session;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function assertArchiveActor() {
|
|
159
|
+
const current = actor();
|
|
160
|
+
const allowed = cfg.allowedActors;
|
|
161
|
+
if (!allowed.length) throw E('E_FORBIDDEN', 'archive requires allowedActors configuration');
|
|
162
|
+
if (!allowed.includes(current.name) && !allowed.includes(current.id)) {
|
|
163
|
+
throw E('E_FORBIDDEN', 'actor not allowed to archive: ' + current.name);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const objectSchema = (properties, required = []) => ({ type: 'object', additionalProperties: false, properties, required });
|
|
168
|
+
const textOutput = (schema) => ({ schema, render: (_args, value) => [{ type: 'text', text: JSON.stringify(value) }] });
|
|
169
|
+
|
|
170
|
+
ctx.tools.register({
|
|
171
|
+
name: 'session_rename',
|
|
172
|
+
description: 'Rename one DSH session through the host session-title service. Use self or a session id; the title is durable and pinned (automatic title generation stops for that session).',
|
|
173
|
+
parameters: objectSchema({
|
|
174
|
+
sessionId: { type: 'string', description: 'Session id, or "self" for the calling agent session.' },
|
|
175
|
+
title: { type: 'string', description: 'New title.' },
|
|
176
|
+
}, ['sessionId', 'title']),
|
|
177
|
+
output: textOutput(objectSchema({
|
|
178
|
+
ok: { type: 'boolean' },
|
|
179
|
+
sessionId: { type: 'string' },
|
|
180
|
+
title: { type: 'string' },
|
|
181
|
+
eventSeq: { type: 'number' },
|
|
182
|
+
changed: { type: 'boolean' },
|
|
183
|
+
}, ['ok'])),
|
|
184
|
+
async execute(args = {}) {
|
|
185
|
+
const titleService = getService('sessionTitle');
|
|
186
|
+
if (!titleService || typeof titleService.rename !== 'function') throw E('E_SERVICE_UNAVAILABLE', 'sessionTitle service unavailable');
|
|
187
|
+
const title = normalizeTitle(args.title, cfg.maxTitleBytes);
|
|
188
|
+
const session = resolveSession(args.sessionId);
|
|
189
|
+
const before = typeof titleService.get === 'function' ? titleService.get(session) : undefined;
|
|
190
|
+
try {
|
|
191
|
+
const snapshot = titleService.rename(session, title);
|
|
192
|
+
const record = audit({ action: 'rename', sessionId: String(session.id ?? args.sessionId), before: before ? titleDigest(before.title) : null, after: titleDigest(title), result: 'ok' });
|
|
193
|
+
void record;
|
|
194
|
+
return { ok: true, sessionId: String(session.id ?? args.sessionId), title: snapshot?.title ?? title, eventSeq: Number(snapshot?.eventSeq ?? 0), changed: before?.title !== title };
|
|
195
|
+
} catch (error) {
|
|
196
|
+
if (error?.name === 'SessionTitleInvalidError' || /empty/i.test(String(error?.message))) throw E('E_TITLE_EMPTY', String(error?.message ?? error));
|
|
197
|
+
audit({ action: 'rename', sessionId: String(session.id ?? args.sessionId), after: titleDigest(title), result: 'error', error: String(error?.message ?? error) });
|
|
198
|
+
throw E('E_RENAME_FAILED', String(error?.message ?? error));
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
presentCall: (args) => ({ card: 'generic', title: '会话改名', kind: 'other', rawInput: args }),
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
ctx.tools.register({
|
|
205
|
+
name: 'session_archive',
|
|
206
|
+
description: 'Archive or unarchive one DSH session through the host workspace registry. Dry-run by default; pass confirm:true to really archive. Archiving is refused for the calling session and may reclaim worktrees created by that session.',
|
|
207
|
+
parameters: objectSchema({
|
|
208
|
+
sessionId: { type: 'string', description: 'Session id to archive.' },
|
|
209
|
+
archive: { type: 'boolean', description: 'true to archive (default), false to unarchive.' },
|
|
210
|
+
confirm: { type: 'boolean', description: 'Must be true to perform the change; omit for dry-run.' },
|
|
211
|
+
stopActivity: { type: 'boolean', description: 'Archive even if the session is running (stops its work).' },
|
|
212
|
+
}, ['sessionId']),
|
|
213
|
+
output: textOutput(objectSchema({
|
|
214
|
+
ok: { type: 'boolean' },
|
|
215
|
+
sessionId: { type: 'string' },
|
|
216
|
+
archived: { type: 'boolean' },
|
|
217
|
+
dryRun: { type: 'boolean' },
|
|
218
|
+
changed: { type: 'boolean' },
|
|
219
|
+
}, ['ok'])),
|
|
220
|
+
async execute(args = {}) {
|
|
221
|
+
const registry = getService('workspaceRegistry');
|
|
222
|
+
if (!registry) throw E('E_SERVICE_UNAVAILABLE', 'workspaceRegistry service unavailable');
|
|
223
|
+
const sessionId = String(args.sessionId ?? '');
|
|
224
|
+
if (!sessionId) throw E('E_SESSION_NOT_FOUND', 'sessionId is required');
|
|
225
|
+
if (sessionId === actor().id) throw E('E_SELF_ARCHIVE_FORBIDDEN', 'refusing to archive the calling session');
|
|
226
|
+
const wantArchive = args.archive !== false;
|
|
227
|
+
const confirm = args.confirm === true;
|
|
228
|
+
|
|
229
|
+
if (!wantArchive) {
|
|
230
|
+
if (confirm && typeof registry.unarchiveSession === 'function') {
|
|
231
|
+
await registry.unarchiveSession(sessionId);
|
|
232
|
+
audit({ action: 'unarchive', sessionId, result: 'ok' });
|
|
233
|
+
return { ok: true, sessionId, archived: false, dryRun: false, changed: true };
|
|
234
|
+
}
|
|
235
|
+
return { ok: true, sessionId, archived: false, dryRun: true, changed: false };
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
assertArchiveActor();
|
|
239
|
+
if (!confirm) {
|
|
240
|
+
return { ok: true, sessionId, archived: false, dryRun: true, changed: false };
|
|
241
|
+
}
|
|
242
|
+
await registry.archiveSession(sessionId, args.stopActivity === true ? { stopActivity: true } : {});
|
|
243
|
+
audit({ action: 'archive', sessionId, stopActivity: args.stopActivity === true, result: 'ok' });
|
|
244
|
+
return { ok: true, sessionId, archived: true, dryRun: false, changed: true };
|
|
245
|
+
},
|
|
246
|
+
presentCall: (args) => ({ card: 'generic', title: '会话归档', kind: 'other', rawInput: args }),
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
ctx.tools.register({
|
|
250
|
+
name: 'session_team_enable',
|
|
251
|
+
description: 'Enable or disable DSH Agent Teams for the calling root session. Only the current live root may call this; descendants inherit the selection. Persists team/mode in the root session log.',
|
|
252
|
+
parameters: objectSchema({
|
|
253
|
+
enable: { type: 'boolean', description: 'true to enable (default), false to disable.' },
|
|
254
|
+
}, []),
|
|
255
|
+
output: textOutput(objectSchema({
|
|
256
|
+
ok: { type: 'boolean' },
|
|
257
|
+
sessionId: { type: 'string' },
|
|
258
|
+
enabled: { type: 'boolean' },
|
|
259
|
+
}, ['ok'])),
|
|
260
|
+
async execute(args = {}) {
|
|
261
|
+
const teams = getService('agentTeams');
|
|
262
|
+
if (!teams || typeof teams.setEnabled !== 'function') throw E('E_SERVICE_UNAVAILABLE', 'agentTeams service unavailable');
|
|
263
|
+
let agent;
|
|
264
|
+
try {
|
|
265
|
+
agent = callingAgent();
|
|
266
|
+
} catch {
|
|
267
|
+
agent = undefined;
|
|
268
|
+
}
|
|
269
|
+
if (!agent) throw E('E_NOT_ROOT', 'no calling agent');
|
|
270
|
+
const enabled = args.enable !== false;
|
|
271
|
+
try {
|
|
272
|
+
await teams.setEnabled(agent, enabled);
|
|
273
|
+
} catch (error) {
|
|
274
|
+
const message = String(error?.message ?? error);
|
|
275
|
+
if (/descendant|not .*root|root/i.test(message)) throw E('E_NOT_ROOT', message);
|
|
276
|
+
throw E('E_TEAM_ENABLE_FAILED', message);
|
|
277
|
+
}
|
|
278
|
+
audit({ action: enabled ? 'team_enable' : 'team_disable', sessionId: String(agent.id ?? ''), result: 'ok' });
|
|
279
|
+
return { ok: true, sessionId: String(agent.id ?? ''), enabled };
|
|
280
|
+
},
|
|
281
|
+
presentCall: (args) => ({ card: 'generic', title: args.enable === false ? '关闭 Agent Teams' : '开启 Agent Teams', kind: 'other', rawInput: args }),
|
|
282
|
+
});
|
|
283
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fubai-fenzhi/dsh-session-admin",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./lib/index.js"
|
|
8
|
+
},
|
|
9
|
+
"description": "会话管理:给 agent 提供 session_rename / session_archive / session_team_enable 三个工具,走 Host 会话服务(与 GUI 同一写入路径),带审计与回滚。",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"author": "fubai-fenzhi",
|
|
12
|
+
"homepage": "https://github.com/fubai-fenzhi/dsh-session-admin#readme",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/fubai-fenzhi/dsh-session-admin.git"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"dsh",
|
|
19
|
+
"dsh-plugin",
|
|
20
|
+
"deepseek-harness",
|
|
21
|
+
"session",
|
|
22
|
+
"archive",
|
|
23
|
+
"rename"
|
|
24
|
+
],
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=18",
|
|
27
|
+
"dsh": ">=0.2.1-rc.3"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"test": "node test/admin.test.mjs"
|
|
31
|
+
},
|
|
32
|
+
"dsh": {
|
|
33
|
+
"bundle": {
|
|
34
|
+
"patch": "./cordis.patch.yml"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"lib",
|
|
39
|
+
"cordis.patch.yml",
|
|
40
|
+
"README.md",
|
|
41
|
+
"LICENSE"
|
|
42
|
+
]
|
|
43
|
+
}
|