@suifei/dsh-ai-team 0.4.4 → 0.4.8
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/index.js +114 -65
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -46,9 +46,11 @@ import { createDiagLogger, defaultDiagDir } from './lib/diaglog.js';
|
|
|
46
46
|
export const name = 'ai-team';
|
|
47
47
|
|
|
48
48
|
/** The workbench only makes sense where the Web carrier exists. */
|
|
49
|
-
|
|
49
|
+
// cordis 按 inject 保证属性注入;未声明的属性访问会抛错,因此这里列全插件
|
|
50
|
+
// 实际使用的服务(含可选服务:缺失时 serviceOf 回退 ctx.get 并返回 undefined)。
|
|
51
|
+
export const inject = ['webServer', 'permissionPresets', 'sandboxPolicy', 'tools', 'shell', 'agents', 'subagents', 'sessions'];
|
|
50
52
|
|
|
51
|
-
const VERSION = '0.4.
|
|
53
|
+
const VERSION = '0.4.8';
|
|
52
54
|
const HUMAN_ID = 'mem_human';
|
|
53
55
|
|
|
54
56
|
const SKILLOPT_BACKENDS = ['mock', 'claude', 'codex', 'copilot', 'cursor', 'pi', 'opencode', 'handoff', 'azure_openai'];
|
|
@@ -79,9 +81,23 @@ export const Config = z.object({
|
|
|
79
81
|
* 惰性 shell 服务代理:插件注入时机可能早于 shell 服务就绪,注册与 tick 都
|
|
80
82
|
* 必须在调用时现取,避免「boot 时未就绪 → 整条技能链静默跳过」。
|
|
81
83
|
*/
|
|
84
|
+
/**
|
|
85
|
+
* 取 DSH 服务:cordis 以属性形式注入(ctx.tools / ctx.shell …),
|
|
86
|
+
* ctx.get(name) 是另一套查询;两者在不同宿主版本上可用性不同,故先属性后 get。
|
|
87
|
+
*/
|
|
88
|
+
function serviceOf(ctx, name) {
|
|
89
|
+
// cordis Context 是 Proxy:访问未注入的属主会抛错,故必须 try/catch;
|
|
90
|
+
// 属性不可用时回退 ctx.get(name)(可选服务缺失返回 undefined)。
|
|
91
|
+
try {
|
|
92
|
+
const direct = ctx?.[name];
|
|
93
|
+
if (direct !== undefined && direct !== null) return direct;
|
|
94
|
+
} catch { /* not injected: fall back to ctx.get */ }
|
|
95
|
+
return ctx?.get?.(name);
|
|
96
|
+
}
|
|
97
|
+
|
|
82
98
|
function lazyShellService(ctx) {
|
|
83
99
|
const get = () => {
|
|
84
|
-
const service = ctx
|
|
100
|
+
const service = serviceOf(ctx, 'shell');
|
|
85
101
|
if (service === undefined || service === null) throw new Error('shell service is not available');
|
|
86
102
|
return service;
|
|
87
103
|
};
|
|
@@ -192,7 +208,7 @@ export function apply(ctx, config = {}) {
|
|
|
192
208
|
send(res, { error: { code, message: error?.message ?? 'command failed', details: error?.details ?? null } }, status);
|
|
193
209
|
};
|
|
194
210
|
ctx.effect(() => {
|
|
195
|
-
const webServer = ctx
|
|
211
|
+
const webServer = serviceOf(ctx, 'webServer');
|
|
196
212
|
if (webServer === undefined) return () => {};
|
|
197
213
|
|
|
198
214
|
let booted = null;
|
|
@@ -208,7 +224,7 @@ export function apply(ctx, config = {}) {
|
|
|
208
224
|
return null;
|
|
209
225
|
};
|
|
210
226
|
const workspaceForProject = async (projectRuntime) => {
|
|
211
|
-
const registry = ctx
|
|
227
|
+
const registry = serviceOf(ctx, 'workspaceRegistry');
|
|
212
228
|
const path = projectRuntime?.service?.state?.projects?.[projectRuntime.id]?.workspacePath;
|
|
213
229
|
if (registry === undefined || typeof path !== 'string' || path === '') return null;
|
|
214
230
|
try {
|
|
@@ -227,8 +243,8 @@ export function apply(ctx, config = {}) {
|
|
|
227
243
|
const projectNameOf = (projectRuntime) => projectRuntime?.service?.state?.projects?.[projectRuntime?.id]?.name ?? '';
|
|
228
244
|
const titleMemberSession = async (projectRuntime, member) => {
|
|
229
245
|
if (member === undefined) return;
|
|
230
|
-
const sessions = ctx
|
|
231
|
-
const titleService = ctx
|
|
246
|
+
const sessions = serviceOf(ctx, 'sessions');
|
|
247
|
+
const titleService = serviceOf(ctx, 'sessionTitle');
|
|
232
248
|
const session = sessions?.get?.(member.sessionId);
|
|
233
249
|
if (session === undefined || session === null || typeof titleService?.rename !== 'function') return;
|
|
234
250
|
const title = memberSessionTitle(member, projectNameOf(projectRuntime));
|
|
@@ -262,7 +278,7 @@ export function apply(ctx, config = {}) {
|
|
|
262
278
|
const route = `${selection.provider}/${selection.model}`;
|
|
263
279
|
if (modelSelectionLogged.get(sessionId) === route) return;
|
|
264
280
|
try {
|
|
265
|
-
const session = ctx
|
|
281
|
+
const session = serviceOf(ctx, 'sessions')?.get?.(sessionId);
|
|
266
282
|
if (session === undefined || session === null || typeof session.append !== 'function') return;
|
|
267
283
|
session.append('model/selection', { provider: selection.provider, model: selection.model });
|
|
268
284
|
modelSelectionLogged.set(sessionId, route);
|
|
@@ -273,8 +289,8 @@ export function apply(ctx, config = {}) {
|
|
|
273
289
|
}
|
|
274
290
|
};
|
|
275
291
|
const access = validatePermissionProfile({
|
|
276
|
-
permissionPresets: ctx
|
|
277
|
-
sandboxPolicy: ctx
|
|
292
|
+
permissionPresets: serviceOf(ctx, 'permissionPresets'),
|
|
293
|
+
sandboxPolicy: serviceOf(ctx, 'sandboxPolicy'),
|
|
278
294
|
});
|
|
279
295
|
const ready = access.ok
|
|
280
296
|
? Promise.resolve().then(() => boot(diag))
|
|
@@ -373,7 +389,7 @@ export function apply(ctx, config = {}) {
|
|
|
373
389
|
// The child Agent owns a persisted session, but its live events are
|
|
374
390
|
// buffered by the JSONL writer until a session/flush checkpoint. Flush
|
|
375
391
|
// every member turn boundary so restart/memory can replay the history.
|
|
376
|
-
const sessions = ctx
|
|
392
|
+
const sessions = serviceOf(ctx, 'sessions');
|
|
377
393
|
try {
|
|
378
394
|
await sessions?.flush?.(session);
|
|
379
395
|
} catch (error) {
|
|
@@ -392,7 +408,7 @@ export function apply(ctx, config = {}) {
|
|
|
392
408
|
: () => {};
|
|
393
409
|
let llmFaultMode = null;
|
|
394
410
|
const offLlmFault = process.env.DSH_AI_TEAM_TEST === '1'
|
|
395
|
-
? installFaultAdapter(ctx
|
|
411
|
+
? installFaultAdapter(serviceOf(ctx, 'llm'), () => llmFaultMode)
|
|
396
412
|
: () => {};
|
|
397
413
|
let host = null;
|
|
398
414
|
let hostPromise = null;
|
|
@@ -429,10 +445,10 @@ export function apply(ctx, config = {}) {
|
|
|
429
445
|
for (const [key, seq] of wakeKeys) {
|
|
430
446
|
if (Number.isSafeInteger(seq) && head - seq > 500) wakeKeys.delete(key);
|
|
431
447
|
}
|
|
432
|
-
const subagents = ctx
|
|
433
|
-
const sessions = ctx
|
|
434
|
-
const permissionPresets = ctx
|
|
435
|
-
const sandboxPolicy = ctx
|
|
448
|
+
const subagents = serviceOf(ctx, 'subagents');
|
|
449
|
+
const sessions = serviceOf(ctx, 'sessions');
|
|
450
|
+
const permissionPresets = serviceOf(ctx, 'permissionPresets');
|
|
451
|
+
const sandboxPolicy = serviceOf(ctx, 'sandboxPolicy');
|
|
436
452
|
if (subagents === undefined || sessions === undefined || permissionPresets === undefined || sandboxPolicy === undefined) return;
|
|
437
453
|
const providers = typeof subagents.list === 'function' ? subagents.list() : [];
|
|
438
454
|
if (providers.length === 0) return;
|
|
@@ -482,11 +498,11 @@ export function apply(ctx, config = {}) {
|
|
|
482
498
|
await titleMemberSession(projectRuntime, member);
|
|
483
499
|
const runtime = new MemberRuntime({
|
|
484
500
|
subagents, sessions, permissionPresets, sandboxPolicy,
|
|
485
|
-
agents: ctx
|
|
486
|
-
agentPresets: ctx
|
|
501
|
+
agents: serviceOf(ctx, 'agents'),
|
|
502
|
+
agentPresets: serviceOf(ctx, 'agentPresets'),
|
|
487
503
|
direct: false,
|
|
488
504
|
parent: parentInfo.agent,
|
|
489
|
-
provider: (ctx
|
|
505
|
+
provider: (serviceOf(ctx, 'subagents')?.list?.() ?? [])[0],
|
|
490
506
|
preset: 'standard',
|
|
491
507
|
cwd,
|
|
492
508
|
trackHandle: (sessionId, handle) => resumedHandles.set(sessionId, handle),
|
|
@@ -577,7 +593,7 @@ export function apply(ctx, config = {}) {
|
|
|
577
593
|
projectDir: projectRuntime.dir,
|
|
578
594
|
deps: {
|
|
579
595
|
now: () => Date.now(),
|
|
580
|
-
provider: (ctx
|
|
596
|
+
provider: (serviceOf(ctx, 'subagents')?.list?.() ?? [])[0],
|
|
581
597
|
// parent 惰性解析:仅启动 judge 子代理时需要;generating 阶段
|
|
582
598
|
// 不依赖 agents 服务,避免 tick 阶段服务不可用时整块失败。
|
|
583
599
|
ensureParent: () => ensureParent(),
|
|
@@ -727,13 +743,13 @@ export function apply(ctx, config = {}) {
|
|
|
727
743
|
if (member === undefined || member.kind !== 'agent') {
|
|
728
744
|
return { error: { code: 'E_NOT_FOUND', message: 'agent not found' }, status: 404 };
|
|
729
745
|
}
|
|
730
|
-
const llm = ctx
|
|
746
|
+
const llm = serviceOf(ctx, 'llm');
|
|
731
747
|
if (llm?.stream === undefined) {
|
|
732
748
|
return { error: { code: 'E_RUNTIME_UNAVAILABLE', message: 'llm service is unavailable' }, status: 503 };
|
|
733
749
|
}
|
|
734
750
|
const selection = member.config?.provider && member.config?.model
|
|
735
751
|
? { provider: member.config.provider, model: member.config.model }
|
|
736
|
-
: ctx
|
|
752
|
+
: serviceOf(ctx, 'agentDefaultModel')?.currentSelection?.();
|
|
737
753
|
if (!selection?.provider || !selection?.model) {
|
|
738
754
|
return { error: { code: 'E_RUNTIME_UNAVAILABLE', message: 'no provider/model configured' }, status: 503 };
|
|
739
755
|
}
|
|
@@ -792,7 +808,7 @@ export function apply(ctx, config = {}) {
|
|
|
792
808
|
return { ok: true, member: result.member, distilled: { provider: selection.provider, model: selection.model } };
|
|
793
809
|
};
|
|
794
810
|
|
|
795
|
-
const skillsService = ctx
|
|
811
|
+
const skillsService = serviceOf(ctx, 'skills');
|
|
796
812
|
let disposeSkillProvider = () => {};
|
|
797
813
|
try {
|
|
798
814
|
// A vendor failure must never fail composition activation: that left
|
|
@@ -806,14 +822,14 @@ export function apply(ctx, config = {}) {
|
|
|
806
822
|
diag.append({ ev: 'skill.provider.fail', message: error?.message ?? String(error) });
|
|
807
823
|
console.warn('[ai-team] file skill provider failed:', error?.message ?? error);
|
|
808
824
|
}
|
|
809
|
-
const tools = ctx
|
|
825
|
+
const tools = serviceOf(ctx, 'tools');
|
|
810
826
|
let disposeSkillOpt = () => {};
|
|
811
827
|
try {
|
|
812
828
|
// shell 惰性代理:注入时机早于 shell 服务就绪时,注册仍必须完成——
|
|
813
829
|
// 每次调用现取,避免「boot 时 shell 未就绪 → 整条技能链静默跳过」。
|
|
814
830
|
const shellProxy = lazyShellService(ctx);
|
|
815
831
|
if (!tools?.register) {
|
|
816
|
-
diag.append({ ev: 'skillopt.skip.fail', hasToolsRegister: false, hasShell: Boolean(ctx
|
|
832
|
+
diag.append({ ev: 'skillopt.skip.fail', hasToolsRegister: false, hasShell: Boolean(serviceOf(ctx, 'shell')) });
|
|
817
833
|
console.warn('[ai-team] SkillOpt tools not registered: no tool registry');
|
|
818
834
|
}
|
|
819
835
|
if (tools?.register) {
|
|
@@ -822,11 +838,11 @@ export function apply(ctx, config = {}) {
|
|
|
822
838
|
const engineScript = fileURLToPath(new URL('./lib/vendor/skillopt/scripts/sleep.py', import.meta.url));
|
|
823
839
|
const readPair = makeReadPair({ shell: shellProxy, engineScript, diag });
|
|
824
840
|
const judge = makeJudge({
|
|
825
|
-
subagents: ctx
|
|
841
|
+
subagents: serviceOf(ctx, 'subagents'),
|
|
826
842
|
// 惰性解析:ensureParent 在 apply 之后才定义(const TDZ),
|
|
827
843
|
// judge 只在 adopt 时调用,此处不能立即取值。
|
|
828
844
|
ensureParent: () => ensureParent(),
|
|
829
|
-
providerName: () => (ctx
|
|
845
|
+
providerName: () => (serviceOf(ctx, 'subagents')?.list?.() ?? [])[0],
|
|
830
846
|
votes: config.skilloptJudgeVotes ?? 3,
|
|
831
847
|
diag,
|
|
832
848
|
});
|
|
@@ -929,9 +945,9 @@ export function apply(ctx, config = {}) {
|
|
|
929
945
|
if (dimension === null) return '[skillopt optimize] rubric produced no scorable dimension';
|
|
930
946
|
const parentInfo = await ensureParent();
|
|
931
947
|
const generator = makeGenerator({
|
|
932
|
-
subagents: ctx
|
|
948
|
+
subagents: serviceOf(ctx, 'subagents'),
|
|
933
949
|
ensureParent: () => ensureParent(),
|
|
934
|
-
providerName: () => (ctx
|
|
950
|
+
providerName: () => (serviceOf(ctx, 'subagents')?.list?.() ?? [])[0],
|
|
935
951
|
cwd: project,
|
|
936
952
|
diag,
|
|
937
953
|
});
|
|
@@ -970,8 +986,41 @@ export function apply(ctx, config = {}) {
|
|
|
970
986
|
parameters: { project: { type: 'string', description: 'Project directory' } },
|
|
971
987
|
output: { schema: { type: 'string' }, render: (_args, value) => [{ type: 'text', text: String(value) }] },
|
|
972
988
|
async execute(args) {
|
|
973
|
-
|
|
974
|
-
|
|
989
|
+
// 主动收割:工具调用即驱动(不依赖 PMO 定时器——实测宿主热重载/
|
|
990
|
+
// 重启后 setInterval 可能不重建,工具驱动保证链路可用)。
|
|
991
|
+
const explicit = typeof args?.project === 'string' && args.project !== '' ? args.project : null;
|
|
992
|
+
// job 归属项目数据目录(runtime.dir),显式路径只作为额外搜索根。
|
|
993
|
+
const runtimeRoots = [...(booted?.runtimes?.values?.() ?? [])].map((runtime) => runtime.dir).filter((root) => typeof root === 'string' && root !== '');
|
|
994
|
+
const jobRoots = [...new Set([...runtimeRoots, ...(explicit !== null ? [explicit] : [])])];
|
|
995
|
+
for (const jobRoot of jobRoots) {
|
|
996
|
+
if (typeof jobRoot !== 'string' || jobRoot === '') continue;
|
|
997
|
+
try {
|
|
998
|
+
await reconcileJobs({
|
|
999
|
+
ctx,
|
|
1000
|
+
projectDir: jobRoot,
|
|
1001
|
+
deps: {
|
|
1002
|
+
now: () => Date.now(),
|
|
1003
|
+
provider: (serviceOf(ctx, 'subagents')?.list?.() ?? [])[0],
|
|
1004
|
+
ensureParent: () => ensureParent(),
|
|
1005
|
+
votes: config.skilloptJudgeVotes ?? 3,
|
|
1006
|
+
startChild: async (label, spec) => {
|
|
1007
|
+
const child = await serviceOf(ctx, 'subagents').startActivation({ ...spec, label });
|
|
1008
|
+
return { childId: child.childId, outputStart: child.outputStart ?? null };
|
|
1009
|
+
},
|
|
1010
|
+
readText: (file) => readFileSync(file, 'utf8'),
|
|
1011
|
+
writeText: (file, next) => writeFileSync(file, next, 'utf8'),
|
|
1012
|
+
score: (value) => scoreSkillRubric(value, { measured: false }),
|
|
1013
|
+
appendResult: makeResultAppender({ projectDir: jobRoot }),
|
|
1014
|
+
vcs: await makeVcs({ shell: lazyShellService(ctx), projectDir: jobRoot }),
|
|
1015
|
+
diag: (row) => diag.append(row),
|
|
1016
|
+
},
|
|
1017
|
+
});
|
|
1018
|
+
} catch (error) {
|
|
1019
|
+
diag.append({ ev: 'skillopt.jobs.step.fail', message: error?.message ?? String(error), jobRoot });
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
const roots = jobRoots.length > 0 ? jobRoots : [process.cwd()];
|
|
1023
|
+
const jobs = roots.flatMap((jobRoot) => listJobs(jobRoot));
|
|
975
1024
|
if (jobs.length === 0) return '[skillopt jobs] none';
|
|
976
1025
|
return ['[skillopt jobs]', ...jobs.map((job) => ` ${job.id} ${job.state} ${job.dimension ?? '-'}${job.decision ? ` verdict=${job.decision.verdict} (${job.decision.better}-${job.decision.worse})` : ''}${job.error ? ` error=${job.error}` : ''}`)].join('\n');
|
|
977
1026
|
},
|
|
@@ -1018,10 +1067,10 @@ export function apply(ctx, config = {}) {
|
|
|
1018
1067
|
.map((runtime) => runtime.service.state.hostSessionId)
|
|
1019
1068
|
.find((value) => value !== undefined && value !== null);
|
|
1020
1069
|
hostPromise = ensureHostAgent({
|
|
1021
|
-
agents: ctx
|
|
1022
|
-
agentDefaultModel: ctx
|
|
1023
|
-
workspaceRegistry: ctx
|
|
1024
|
-
sessions: ctx
|
|
1070
|
+
agents: serviceOf(ctx, 'agents'),
|
|
1071
|
+
agentDefaultModel: serviceOf(ctx, 'agentDefaultModel'),
|
|
1072
|
+
workspaceRegistry: serviceOf(ctx, 'workspaceRegistry'),
|
|
1073
|
+
sessions: serviceOf(ctx, 'sessions'),
|
|
1025
1074
|
cwd: booted?.dataDir ?? process.cwd(),
|
|
1026
1075
|
resumeSessionId: existingHost,
|
|
1027
1076
|
}).then(async (value) => {
|
|
@@ -1078,10 +1127,10 @@ export function apply(ctx, config = {}) {
|
|
|
1078
1127
|
}
|
|
1079
1128
|
diag?.append({ ev: 'member.reseat', memberId: member.id, oldSessionId: staleId, projectId: projectRuntime.id });
|
|
1080
1129
|
}
|
|
1081
|
-
const subagents = ctx
|
|
1082
|
-
const sessions = ctx
|
|
1083
|
-
const permissionPresets = ctx
|
|
1084
|
-
const sandboxPolicy = ctx
|
|
1130
|
+
const subagents = serviceOf(ctx, 'subagents');
|
|
1131
|
+
const sessions = serviceOf(ctx, 'sessions');
|
|
1132
|
+
const permissionPresets = serviceOf(ctx, 'permissionPresets');
|
|
1133
|
+
const sandboxPolicy = serviceOf(ctx, 'sandboxPolicy');
|
|
1085
1134
|
if (subagents === undefined || sessions === undefined || permissionPresets === undefined || sandboxPolicy === undefined) {
|
|
1086
1135
|
diag?.append({ ev: 'activate.reject', projectId: projectRuntime.id, memberId: member.id, code: 'E_RUNTIME_UNAVAILABLE' });
|
|
1087
1136
|
return { error: { code: 'E_RUNTIME_UNAVAILABLE', message: 'member runtime services are unavailable' }, status: 503 };
|
|
@@ -1092,7 +1141,7 @@ export function apply(ctx, config = {}) {
|
|
|
1092
1141
|
return { error: { code: 'E_RUNTIME_UNAVAILABLE', message: 'no subagent provider is registered' }, status: 503 };
|
|
1093
1142
|
}
|
|
1094
1143
|
try {
|
|
1095
|
-
const selection = ctx
|
|
1144
|
+
const selection = serviceOf(ctx, 'agentDefaultModel')?.currentSelection?.();
|
|
1096
1145
|
const activationMember = member.config?.provider && member.config?.model
|
|
1097
1146
|
? member
|
|
1098
1147
|
: {
|
|
@@ -1112,11 +1161,11 @@ export function apply(ctx, config = {}) {
|
|
|
1112
1161
|
sessions,
|
|
1113
1162
|
permissionPresets,
|
|
1114
1163
|
sandboxPolicy,
|
|
1115
|
-
agents: ctx
|
|
1116
|
-
agentPresets: ctx
|
|
1164
|
+
agents: serviceOf(ctx, 'agents'),
|
|
1165
|
+
agentPresets: serviceOf(ctx, 'agentPresets'),
|
|
1117
1166
|
direct: false,
|
|
1118
1167
|
parent: parentInfo.agent,
|
|
1119
|
-
provider: (ctx
|
|
1168
|
+
provider: (serviceOf(ctx, 'subagents')?.list?.() ?? [])[0],
|
|
1120
1169
|
preset: 'standard',
|
|
1121
1170
|
cwd: effectiveDir,
|
|
1122
1171
|
trackHandle: (sessionId, handle) => resumedHandles.set(sessionId, handle),
|
|
@@ -1190,8 +1239,8 @@ export function apply(ctx, config = {}) {
|
|
|
1190
1239
|
};
|
|
1191
1240
|
disposePermissionGuard = tools.guard(createMemberPermissionGuard({
|
|
1192
1241
|
service: allMembers,
|
|
1193
|
-
permissionPresets: ctx
|
|
1194
|
-
sandboxPolicy: ctx
|
|
1242
|
+
permissionPresets: serviceOf(ctx, 'permissionPresets'),
|
|
1243
|
+
sandboxPolicy: serviceOf(ctx, 'sandboxPolicy'),
|
|
1195
1244
|
})) ?? (() => {});
|
|
1196
1245
|
}
|
|
1197
1246
|
// A restart is an explicit lifecycle event: resume unfinished Tasks
|
|
@@ -1311,7 +1360,7 @@ export function apply(ctx, config = {}) {
|
|
|
1311
1360
|
});
|
|
1312
1361
|
}
|
|
1313
1362
|
if (req.method === 'GET' && url.pathname === '/ai-team/api/models') {
|
|
1314
|
-
const catalog = await buildModelCatalog(ctx
|
|
1363
|
+
const catalog = await buildModelCatalog(serviceOf(ctx, 'llm'), serviceOf(ctx, 'agentDefaultModel'));
|
|
1315
1364
|
return send(res, catalog);
|
|
1316
1365
|
}
|
|
1317
1366
|
// R-17 person 别名:视图层绑定(name → personId),文件存策略数据
|
|
@@ -1424,19 +1473,19 @@ export function apply(ctx, config = {}) {
|
|
|
1424
1473
|
active: runtime.id === booted.activeProjectId,
|
|
1425
1474
|
})),
|
|
1426
1475
|
runtime: {
|
|
1427
|
-
roots: ctx
|
|
1476
|
+
roots: serviceOf(ctx, 'agents')?.roots?.().length ?? null,
|
|
1428
1477
|
// 服务探测(技能进化链路依赖 tools.register + shell):
|
|
1429
1478
|
// 同步可观测,避免历史「静默未启用」盲区。
|
|
1430
1479
|
services: {
|
|
1431
|
-
tools: typeof ctx
|
|
1432
|
-
shell: Boolean(ctx
|
|
1433
|
-
skilloptTools: (ctx
|
|
1480
|
+
tools: typeof serviceOf(ctx, 'tools')?.register === 'function',
|
|
1481
|
+
shell: Boolean(serviceOf(ctx, 'shell')),
|
|
1482
|
+
skilloptTools: (serviceOf(ctx, 'tools')?.definitions?.() ?? []).map((definition) => definition.name).filter((toolName) => String(toolName).startsWith('skillopt_')),
|
|
1434
1483
|
},
|
|
1435
|
-
defaultModel: ctx
|
|
1436
|
-
llmProviders: ctx
|
|
1437
|
-
providers: ctx
|
|
1438
|
-
providerCaps: (ctx
|
|
1439
|
-
const provider = ctx
|
|
1484
|
+
defaultModel: serviceOf(ctx, 'agentDefaultModel')?.currentSelection?.() ?? null,
|
|
1485
|
+
llmProviders: serviceOf(ctx, 'llm')?.listProviders?.() ?? [],
|
|
1486
|
+
providers: serviceOf(ctx, 'subagents')?.list?.() ?? [],
|
|
1487
|
+
providerCaps: (serviceOf(ctx, 'subagents')?.list?.() ?? []).map((providerName) => {
|
|
1488
|
+
const provider = serviceOf(ctx, 'subagents')?.getProvider?.(providerName);
|
|
1440
1489
|
return {
|
|
1441
1490
|
name: providerName,
|
|
1442
1491
|
capabilities: provider?.capabilities ?? null,
|
|
@@ -1445,17 +1494,17 @@ export function apply(ctx, config = {}) {
|
|
|
1445
1494
|
start: typeof provider?.start === 'function',
|
|
1446
1495
|
};
|
|
1447
1496
|
}),
|
|
1448
|
-
teamTool: ctx
|
|
1497
|
+
teamTool: serviceOf(ctx, 'tools')?.definitions?.().some((definition) => definition.name === 'team') ?? null,
|
|
1449
1498
|
skillsService: skillsService !== null && skillsService !== undefined,
|
|
1450
1499
|
skillNames: skillsService?.list
|
|
1451
1500
|
? await Promise.resolve(skillsService.list({})).then((rows) => rows.map((skill) => skill.name).filter((skillName) => !isSkillExcluded(skillName))).catch(() => [])
|
|
1452
1501
|
: [],
|
|
1453
1502
|
skilloptTools: tools?.definitions?.().map((definition) => definition.name).filter((name) => name.startsWith('skillopt_')) ?? [],
|
|
1454
|
-
presets: await Promise.resolve(ctx
|
|
1503
|
+
presets: await Promise.resolve(serviceOf(ctx, 'agentPresets')?.list?.()).catch(() => []),
|
|
1455
1504
|
members: Object.values(booted.service.state.members ?? {})
|
|
1456
1505
|
.filter((member) => member.kind === 'agent')
|
|
1457
1506
|
.map((member) => {
|
|
1458
|
-
const agent = ctx
|
|
1507
|
+
const agent = serviceOf(ctx, 'agents')?.get?.(member.sessionId);
|
|
1459
1508
|
let lastEvent = null;
|
|
1460
1509
|
let seq = null;
|
|
1461
1510
|
try {
|
|
@@ -1528,8 +1577,8 @@ export function apply(ctx, config = {}) {
|
|
|
1528
1577
|
};
|
|
1529
1578
|
}),
|
|
1530
1579
|
runtime: {
|
|
1531
|
-
defaultModel: ctx
|
|
1532
|
-
providers: ctx
|
|
1580
|
+
defaultModel: serviceOf(ctx, 'agentDefaultModel')?.currentSelection?.() ?? null,
|
|
1581
|
+
providers: serviceOf(ctx, 'subagents')?.list?.() ?? [],
|
|
1533
1582
|
},
|
|
1534
1583
|
});
|
|
1535
1584
|
}
|
|
@@ -1636,16 +1685,16 @@ export function apply(ctx, config = {}) {
|
|
|
1636
1685
|
return send(res, { error: { code: 'E_FORBIDDEN', message: 'test hook is disabled' } }, 403);
|
|
1637
1686
|
}
|
|
1638
1687
|
const member = runtime.service.state.members?.[body.payload?.memberId];
|
|
1639
|
-
const agent = member?.sessionId === undefined ? undefined : ctx
|
|
1688
|
+
const agent = member?.sessionId === undefined ? undefined : serviceOf(ctx, 'agents')?.get?.(member.sessionId);
|
|
1640
1689
|
const session = agent?.session;
|
|
1641
1690
|
if (session === undefined || session === null) {
|
|
1642
1691
|
return send(res, { error: { code: 'E_NOT_FOUND', message: 'member session not found' } }, 404);
|
|
1643
1692
|
}
|
|
1644
|
-
const permissionPresets = ctx
|
|
1693
|
+
const permissionPresets = serviceOf(ctx, 'permissionPresets');
|
|
1645
1694
|
permissionPresets?.set?.(session, 'workspace-write');
|
|
1646
1695
|
return send(res, {
|
|
1647
1696
|
ok: true,
|
|
1648
|
-
mode: ctx
|
|
1697
|
+
mode: serviceOf(ctx, 'sandboxPolicy')?.overrideOf?.(session) ?? null,
|
|
1649
1698
|
});
|
|
1650
1699
|
}
|
|
1651
1700
|
if (body.type === 'test.permission.read') {
|
|
@@ -1653,13 +1702,13 @@ export function apply(ctx, config = {}) {
|
|
|
1653
1702
|
return send(res, { error: { code: 'E_FORBIDDEN', message: 'test hook is disabled' } }, 403);
|
|
1654
1703
|
}
|
|
1655
1704
|
const member = runtime.service.state.members?.[body.payload?.memberId];
|
|
1656
|
-
const agent = member?.sessionId === undefined ? undefined : ctx
|
|
1705
|
+
const agent = member?.sessionId === undefined ? undefined : serviceOf(ctx, 'agents')?.get?.(member.sessionId);
|
|
1657
1706
|
const session = agent?.session;
|
|
1658
1707
|
return send(res, {
|
|
1659
1708
|
ok: true,
|
|
1660
1709
|
mode: session === undefined || session === null
|
|
1661
1710
|
? null
|
|
1662
|
-
: ctx
|
|
1711
|
+
: serviceOf(ctx, 'sandboxPolicy')?.overrideOf?.(session) ?? null,
|
|
1663
1712
|
});
|
|
1664
1713
|
}
|
|
1665
1714
|
if (body.type === 'member.distill' && body.payload?.mode === 'model') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suifei/dsh-ai-team",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.8",
|
|
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",
|