@fish-under-sea/dsh-agent-teams-fish 1.0.2 → 2.0.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/NOTICE.md +13 -7
- package/README.en.md +20 -12
- package/README.md +20 -12
- package/compatibility.json +82 -46
- package/icon.png +0 -0
- package/lib/artifacts.js +148 -25
- package/lib/client/ActivityPanel.js +26 -5
- package/lib/client/WorkspaceActivity.js +6 -4
- package/lib/client/activity-monitor.js +113 -41
- package/lib/client/locales.js +14 -0
- package/lib/client.js +433 -199
- package/lib/client.js.map +1 -1
- package/lib/command.js +7 -4
- package/lib/git-artifact-stamp.json +2 -2
- package/lib/harness-compat.js +120 -62
- package/lib/index.js +7 -10
- package/lib/mailbox.js +15 -5
- package/lib/members.js +221 -154
- package/lib/snapshot.js +15 -10
- package/lib/state.js +41 -8
- package/lib/tools.js +123 -64
- package/lib/types/artifacts.d.ts +6 -3
- package/lib/types/client/activity-monitor.d.ts +13 -4
- package/lib/types/client/locales.d.ts +14 -0
- package/lib/types/harness-compat.d.ts +63 -16
- package/lib/types/mailbox.d.ts +2 -0
- package/lib/types/members.d.ts +5 -17
- package/lib/types/snapshot.d.ts +12 -7
- package/lib/types/state.d.ts +10 -3
- package/lib/types/types.d.ts +5 -0
- package/lib/types/web-routes.d.ts +2 -0
- package/lib/types/workspace-audit-service.d.ts +35 -0
- package/lib/types/workspace-audit-worker.d.ts +1 -0
- package/lib/web-routes.js +31 -0
- package/lib/workspace-audit-service.js +165 -0
- package/lib/workspace-audit-worker.js +11 -0
- package/lib/workspace-audit.js +6 -5
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +69 -64
- package/pnpm-workspace.yaml +306 -273
- package/release-notes/v0.1.25.md +16 -0
- package/release-notes/v0.1.26.md +19 -0
- package/release-notes/v0.1.27.md +42 -0
- package/release-notes/v0.1.28.md +45 -0
- package/release-notes/v0.1.29.md +23 -0
- package/release-notes/v1.1.0.md +42 -0
- package/release-notes/v2.0.0.md +17 -0
- package/scripts/artwork-role-match.test.mjs +517 -0
- package/scripts/capabilities.test.mjs +301 -0
- package/scripts/check-install-channel.mjs +55 -0
- package/scripts/check-install-channel.test.mjs +39 -0
- package/scripts/clean-build.mjs +14 -0
- package/scripts/client-harness-migration.test.mjs +46 -0
- package/scripts/compatibility.mjs +20 -0
- package/scripts/compatibility.test.mjs +187 -0
- package/scripts/corrupt-teamjson.test.mjs +180 -0
- package/scripts/custom-artwork.test.mjs +273 -0
- package/scripts/fallback-tdd.mjs +61 -0
- package/scripts/fixtures/harness-benchmark-scope.mjs +16 -0
- package/scripts/fixtures/harness-benchmark-scope.test.mjs +18 -0
- package/scripts/fixtures/harness-complex-case.mjs +201 -0
- package/scripts/fixtures/harness-complex-case.test.mjs +21 -0
- package/scripts/fixtures/harness-complex-oracle.mjs +63 -0
- package/scripts/fixtures/harness-issue-case.mjs +51 -0
- package/scripts/fixtures/harness-issue159-case.mjs +28 -0
- package/scripts/fixtures/harness-model-case.mjs +127 -0
- package/scripts/fixtures/harness-model-case.test.mjs +37 -0
- package/scripts/fixtures/harness-model-driver.mjs +100 -0
- package/scripts/fixtures/harness-runtime-credentials.mjs +23 -0
- package/scripts/fixtures/harness-runtime-entry.mjs +171 -0
- package/scripts/fixtures/harness-runtime-idle.mjs +42 -0
- package/scripts/fixtures/harness-runtime-llm.mjs +193 -0
- package/scripts/fixtures/harness-runtime-protocol.mjs +187 -0
- package/scripts/fixtures/harness-runtime-resume.mjs +24 -0
- package/scripts/fixtures/harness-runtime-stability.mjs +282 -0
- package/scripts/fixtures/harness-runtime-tools.mjs +13 -0
- package/scripts/fixtures/harness-runtime-web-approval.mjs +341 -0
- package/scripts/fixtures/issue-336-audit-worker.mjs +18 -0
- package/scripts/git-artifacts.mjs +64 -0
- package/scripts/git-artifacts.test.mjs +32 -0
- package/scripts/harness-compat-tdd.mjs +492 -0
- package/scripts/harness-issue-verify.mjs +26 -0
- package/scripts/harness-model-benchmark.mjs +163 -0
- package/scripts/harness-runtime-platform.test.mjs +31 -0
- package/scripts/harness-runtime-scenarios.mjs +297 -0
- package/scripts/harness-runtime-verify.mjs +169 -0
- package/scripts/harness-source-verify.mjs +211 -0
- package/scripts/harness-source-verify.test.mjs +97 -0
- package/scripts/harness-validation.mjs +68 -0
- package/scripts/harness-validation.test.mjs +95 -0
- package/scripts/http-body.test.mjs +72 -0
- package/scripts/import-vendor-artwork.mjs +78 -0
- package/scripts/inline-plan-blank-optional-tdd.mjs +121 -0
- package/scripts/issue-159.test.mjs +78 -0
- package/scripts/issue-188.test.mjs +148 -0
- package/scripts/issue-189.test.mjs +100 -0
- package/scripts/issue-203-card.test.mjs +181 -0
- package/scripts/issue-205.test.mjs +163 -0
- package/scripts/issue-234.test.mjs +424 -0
- package/scripts/issue-236-stale-module.test.mjs +63 -0
- package/scripts/issue-236.test.mjs +59 -0
- package/scripts/issue-262.test.mjs +98 -0
- package/scripts/issue-336.test.mjs +404 -0
- package/scripts/legacy-session-source-repair.test.mjs +201 -0
- package/scripts/lifecycle-verify.mjs +1573 -0
- package/scripts/lineage-identity.test.mjs +77 -0
- package/scripts/member-failure-tdd.mjs +451 -0
- package/scripts/member-spawn-recovery.test.mjs +92 -0
- package/scripts/quality-gates-amend.test.mjs +161 -0
- package/scripts/quality-gates-content-bound.test.mjs +572 -0
- package/scripts/quality-gates-cross-binding.test.mjs +184 -0
- package/scripts/quality-gates-excluded-scope.test.mjs +163 -0
- package/scripts/quality-gates-repair-scope.test.mjs +143 -0
- package/scripts/quality-gates-repair-wiring.test.mjs +189 -0
- package/scripts/quality-gates-tdd.mjs +1238 -0
- package/scripts/quality-gates-work-order.test.mjs +494 -0
- package/scripts/readme-version.mjs +89 -0
- package/scripts/readme-version.test.mjs +77 -0
- package/scripts/release-metadata.mjs +45 -0
- package/scripts/release-metadata.test.mjs +66 -0
- package/scripts/scoped-release.test.mjs +52 -0
- package/scripts/stability-tdd.mjs +144 -0
- package/scripts/stress-verify.mjs +548 -0
- package/scripts/symlink-support.mjs +46 -0
- package/scripts/sync-skill.mjs +103 -0
- package/scripts/tool-policies.test.mjs +280 -0
- package/scripts/update-skills.mjs +105 -0
- package/scripts/update-skills.test.mjs +79 -0
- package/scripts/upgrade-status.mjs +66 -0
- package/scripts/upgrade-status.test.mjs +83 -0
- package/scripts/verify-package.mjs +73 -0
- package/scripts/verify.mjs +2199 -0
- package/scripts/web-routes-verify.mjs +142 -0
- package/scripts/workspace-activity.test.mjs +346 -0
- package/scripts/workspace-summary.test.mjs +49 -0
- package/src/artifacts.ts +487 -0
- package/src/artwork-source.ts +262 -0
- package/src/capabilities.ts +113 -0
- package/src/client/ActivityPanel.module.css +2390 -0
- package/src/client/ActivityPanel.tsx +1507 -0
- package/src/client/AgentTeamsCard.module.css +148 -0
- package/src/client/AgentTeamsCard.tsx +155 -0
- package/src/client/StagingPlanEditor.tsx +829 -0
- package/src/client/TeamChatEntry.tsx +27 -0
- package/src/client/WorkspaceActivity.module.css +41 -0
- package/src/client/WorkspaceActivity.tsx +137 -0
- package/src/client/activity-model.ts +372 -0
- package/src/client/activity-monitor.ts +440 -0
- package/src/client/agent-teams-card-definition.ts +250 -0
- package/src/client/artwork.ts +374 -0
- package/src/client/icons.tsx +17 -0
- package/src/client/index.tsx +140 -0
- package/src/client/locales.ts +481 -0
- package/src/client/panel-geometry.ts +194 -0
- package/src/client/session-navigation.ts +73 -0
- package/src/client/workspace-state.ts +52 -0
- package/src/command.ts +145 -0
- package/src/css-modules.d.ts +4 -0
- package/src/event-types.ts +177 -0
- package/src/events.ts +78 -0
- package/src/harness-compat.ts +570 -0
- package/src/index.ts +599 -0
- package/src/lineage.ts +248 -0
- package/src/mailbox.ts +185 -0
- package/src/members.ts +1230 -0
- package/src/profiles.ts +765 -0
- package/src/quality-gates.ts +2124 -0
- package/src/scheduler.ts +554 -0
- package/src/snapshot.ts +333 -0
- package/src/state.ts +1317 -0
- package/src/tool-names.ts +14 -0
- package/src/tool-policies.ts +219 -0
- package/src/tools.ts +2939 -0
- package/src/types.ts +414 -0
- package/src/web-routes.ts +128 -0
- package/src/workspace-audit-service.ts +182 -0
- package/src/workspace-audit-worker.ts +12 -0
- package/src/workspace-audit.ts +57 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** Real-provider paired business benchmark through published CLI + Loader.
|
|
3
|
+
* Does not modify an active profile, copy credentials, or script model responses.
|
|
4
|
+
* Requires an already verified exact Harness runtime. Example:
|
|
5
|
+
* node scripts/harness-model-benchmark.mjs --runtime-dir /tmp/runtime
|
|
6
|
+
* --baseline-artifact /tmp/old.tgz --candidate-artifact /tmp/new.tgz
|
|
7
|
+
* --report-dir /tmp/agentteams-real-ab
|
|
8
|
+
*/
|
|
9
|
+
import { spawn } from 'node:child_process';
|
|
10
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync, symlinkSync, rmSync } from 'node:fs';
|
|
11
|
+
import { resolve, join, dirname, relative } from 'node:path';
|
|
12
|
+
import { homedir } from 'node:os';
|
|
13
|
+
import { createHash } from 'node:crypto';
|
|
14
|
+
import { createRequire } from 'node:module';
|
|
15
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
16
|
+
|
|
17
|
+
const args = new Map(), allowed = new Set(['--runtime-dir','--baseline-artifact','--candidate-artifact','--report-dir','--settings','--credential-file','--only','--timeout-ms','--max-requests','--agent-cwd','--case']);
|
|
18
|
+
for (let i=2;i<process.argv.length;i++) { const flag=process.argv[i]; if(!allowed.has(flag)||args.has(flag)||!process.argv[i+1]) throw Error('Invalid argument '+flag); args.set(flag,process.argv[++i]); }
|
|
19
|
+
for(const flag of ['--runtime-dir','--report-dir','--baseline-artifact']) if(!args.has(flag))throw Error(flag+' required');
|
|
20
|
+
const only=args.get('--only'); if(only&&!['baseline','candidate','upgrade','candidate-finish','candidate-cold','candidate-cold-resume','cancellation'].includes(only))throw Error('Invalid --only');
|
|
21
|
+
if(only!=='baseline'&&!args.has('--candidate-artifact'))throw Error('--candidate-artifact required');
|
|
22
|
+
const caseName=args.get('--case')??'review';
|
|
23
|
+
if(!['review','complex','issue159'].includes(caseName))throw Error('Unknown benchmark case');
|
|
24
|
+
const caseFile=caseName==='complex'?'fixtures/harness-complex-case.mjs':caseName==='issue159'?'fixtures/harness-issue159-case.mjs':'fixtures/harness-model-case.mjs';
|
|
25
|
+
const caseDefinition=await import('./'+caseFile);
|
|
26
|
+
if(only==='candidate-finish'&&!caseDefinition.finishPrompt)throw Error('Selected case does not support interrupted-work continuation');
|
|
27
|
+
if(only==='candidate-cold-resume'&&!caseDefinition.resumeColdPrompt)throw Error('Selected case does not support interrupted regression continuation');
|
|
28
|
+
const {sources,freshPrompt,coldPrompt}=caseDefinition;
|
|
29
|
+
const runtime=resolve(args.get('--runtime-dir')), report=resolve(args.get('--report-dir'));
|
|
30
|
+
const requestedAgentCwd=args.has('--agent-cwd')?resolve(args.get('--agent-cwd')):undefined;
|
|
31
|
+
if(requestedAgentCwd&&!existsSync(requestedAgentCwd))throw Error('--agent-cwd must already exist');
|
|
32
|
+
mkdirSync(report,{recursive:true});
|
|
33
|
+
const req=createRequire(join(runtime,'package.json')), yaml=req('yaml');
|
|
34
|
+
const credentialFile=resolve(args.get('--credential-file')??join(homedir(),'.dsh','.credentials.yaml'));
|
|
35
|
+
const settingsFile=resolve(args.get('--settings')??join(homedir(),'.dsh','settings.yaml'));
|
|
36
|
+
const settings=yaml.parse(readFileSync(settingsFile,'utf8'))??{};
|
|
37
|
+
const chosen=settings['agent-default-model'];
|
|
38
|
+
if(chosen?.provider!=='deepseek-official'||typeof chosen.model!=='string')throw Error('This benchmark requires the configured deepseek-official model; no provider is silently substituted');
|
|
39
|
+
const model={provider:chosen.provider,model:chosen.model,...chosen.reasoningEffort?{reasoningEffort:chosen.reasoningEffort}:{}};
|
|
40
|
+
const configured=settings['llm-deepseek']??{};
|
|
41
|
+
const credentialRef=configured.apiKeyEnv??'DEEPSEEK_API_KEY';
|
|
42
|
+
if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(credentialRef))throw Error('Invalid configured credential reference');
|
|
43
|
+
const {parseCredentialsDocument,renderFlatLayoutMigration}=await import(pathToFileURL(req.resolve('@deepseek-ai/dsh-credentials-local')).href);
|
|
44
|
+
// Parse only to check the selected route. Values never enter artifacts or logs.
|
|
45
|
+
// Refuse the legacy format because the official provider would migrate it.
|
|
46
|
+
const credentialText=existsSync(credentialFile)?readFileSync(credentialFile,'utf8'):'';
|
|
47
|
+
if(renderFlatLayoutMigration(credentialText)!==undefined)throw Error('Credential store needs migration; benchmark refuses to modify it');
|
|
48
|
+
const credentialAvailable=Boolean(process.env[credentialRef])||parseCredentialsDocument(credentialText,credentialFile).refs.has(credentialRef);
|
|
49
|
+
console.log(JSON.stringify({provider:model.provider,model:model.model,credentialAvailable}));
|
|
50
|
+
const hash=path=>createHash('sha256').update(readFileSync(path)).digest('hex');
|
|
51
|
+
const json=(path,value)=>writeFileSync(path,JSON.stringify(value,null,2)+'\n');
|
|
52
|
+
if(!credentialAvailable) { json(join(report,'result.json'),{passed:false,blocked:'Configured model credential unavailable',provider:model.provider,model:model.model});process.exit(2); }
|
|
53
|
+
// A URL containing a credential is never copied into a generated profile.
|
|
54
|
+
if(configured.baseURL) {const url=new URL(configured.baseURL);if(url.username||url.password||url.search)throw Error('Credential-bearing adapter URL cannot be persisted by benchmark');}
|
|
55
|
+
const adapter={apiKeyEnv:credentialRef,...configured.maxTokens?{maxTokens:configured.maxTokens}:{},...configured.baseURL?{baseURL:configured.baseURL}:{},...configured.models?{models:configured.models}:{}};
|
|
56
|
+
const lock=JSON.parse(readFileSync(join(runtime,'package-lock.json'),'utf8'));
|
|
57
|
+
const cohort=Object.entries(lock.packages).filter(([path])=>/node_modules\/@deepseek-ai\/dsh(?:-[^/]+)?$/.test(path)).map(([path,entry])=>({path,version:entry.version,disk:JSON.parse(readFileSync(join(runtime,path,'package.json'),'utf8')).version}));
|
|
58
|
+
const hostVersion=JSON.parse(readFileSync(join(runtime,'node_modules/@deepseek-ai/dsh/package.json'),'utf8')).version;
|
|
59
|
+
if(!cohort.length||cohort.some(item=>item.version!==hostVersion||item.disk!==hostVersion))throw Error('Mixed DSH runtime; prepare one exact cohort first');
|
|
60
|
+
const timeoutMs=Number(args.get('--timeout-ms')??900000),maxRequests=Number(args.get('--max-requests')??100);
|
|
61
|
+
if(!Number.isFinite(timeoutMs)||timeoutMs<1000||!Number.isInteger(maxRequests)||maxRequests<1)throw Error('Invalid benchmark limits');
|
|
62
|
+
const fixtures=dirname(fileURLToPath(import.meta.url));
|
|
63
|
+
// Freeze inputs before the first provider call: later builds or edits cannot
|
|
64
|
+
// silently change a subsequent phase of the same paid comparison.
|
|
65
|
+
const testContents=Object.fromEntries([...new Set(['harness-model-benchmark.mjs','fixtures/harness-model-case.mjs','fixtures/harness-model-driver.mjs','fixtures/harness-benchmark-scope.mjs',caseFile,...caseName==='complex'?['fixtures/harness-complex-oracle.mjs']:[]])].map(path=>[path,readFileSync(join(fixtures,path))]));
|
|
66
|
+
const testFiles=Object.fromEntries(Object.entries(testContents).map(([path,bytes])=>[path,createHash('sha256').update(bytes).digest('hex')]));
|
|
67
|
+
const artifacts=Object.fromEntries(['baseline','candidate'].filter(label=>args.has('--'+label+'-artifact')).map(label=>[label,{path:resolve(args.get('--'+label+'-artifact')),bytes:readFileSync(resolve(args.get('--'+label+'-artifact')))}]));
|
|
68
|
+
const manifestPath=join(report,only?'manifest-'+only+'.json':'manifest.json');
|
|
69
|
+
if(existsSync(manifestPath))throw Error('Benchmark manifest exists; use a fresh report directory');
|
|
70
|
+
json(manifestPath,{caseName,agentCwd:requestedAgentCwd,hostVersion,cohortCount:cohort.length,runtime,model,testFiles,artifacts:Object.fromEntries(Object.entries(artifacts).map(([label,item])=>[label,{path:item.path,sha256:createHash('sha256').update(item.bytes).digest('hex')}])),timeoutMs,maxRequests,seedSha256:Object.fromEntries(Object.entries(sources).map(([path,text])=>[path,createHash('sha256').update(text).digest('hex')])),inputs:{fresh:freshPrompt,cold:coldPrompt},scope:'Real configured DeepSeek adapter; exact published Harness CLI/Loader. External acceptance checks files, task status and member tool provenance. No model call order is preprogrammed.'});
|
|
71
|
+
const environment={PATH:process.env.PATH,LANG:process.env.LANG??'en_US.UTF-8',HOME:join(report,'user-home'),DSH_TELEMETRY_DISABLED:'1',DSH_PERMISSION_MODE:'workspace-write',...process.env[credentialRef]?{[credentialRef]:process.env[credentialRef]}:{}};
|
|
72
|
+
mkdirSync(environment.HOME,{recursive:true});
|
|
73
|
+
async function command(argv,cwd,env,label,limit=timeoutMs+90000) {
|
|
74
|
+
const child=spawn(argv[0],argv.slice(1),{cwd,env,stdio:['ignore','pipe','pipe']});
|
|
75
|
+
let stdout='',stderr='',timedOut=false;
|
|
76
|
+
child.stdout.on('data',data=>stdout+=data);child.stderr.on('data',data=>stderr+=data);
|
|
77
|
+
const timer=setTimeout(()=>{timedOut=true;child.kill('SIGTERM');setTimeout(()=>child.kill('SIGKILL'),5000).unref();},limit);
|
|
78
|
+
const exit=await new Promise((resolve,reject)=>{child.on('error',reject);child.on('exit',(code,signal)=>resolve({code,signal}));});clearTimeout(timer);
|
|
79
|
+
writeFileSync(join(report,label+'.stdout.log'),stdout);writeFileSync(join(report,label+'.stderr.log'),stderr);
|
|
80
|
+
return {...exit,timedOut};
|
|
81
|
+
}
|
|
82
|
+
async function extract(artifact,label) {
|
|
83
|
+
const target=join(report,label+'-artifact');
|
|
84
|
+
if(existsSync(target))throw Error('Artifact directory already exists; use a fresh report or a new --only phase');
|
|
85
|
+
mkdirSync(target,{recursive:true});
|
|
86
|
+
const unpacked=await command(['tar','-xzf',artifact,'-C',target],report,environment,label+'-unpack',60000);
|
|
87
|
+
if(unpacked.code!==0)throw Error('Artifact extraction failed');
|
|
88
|
+
const packageDir=join(target,'package'),pkg=JSON.parse(readFileSync(join(packageDir,'package.json'),'utf8'));
|
|
89
|
+
if(pkg.name!=='@fish-under-sea/dsh-agent-teams-fish')throw Error('Wrong artifact identity');
|
|
90
|
+
symlinkSync(join(runtime,'node_modules'),join(packageDir,'node_modules'),'dir');
|
|
91
|
+
return {packageDir,artifactSha256:hash(artifact),pluginVersion:pkg.version};
|
|
92
|
+
}
|
|
93
|
+
async function run(label,phase,artifact,existing) {
|
|
94
|
+
const runDir=join(report,label);mkdirSync(runDir,{recursive:true});
|
|
95
|
+
const workspace=existing?.workspace??join(runDir,'workspace'),home=existing?.home??join(runDir,'home'),profile=join(home,'profiles','headless');
|
|
96
|
+
if(phase==='fresh') {
|
|
97
|
+
if(existsSync(workspace))throw Error('Workspace already exists; never overwrite a completed benchmark');
|
|
98
|
+
for(const [path,source] of Object.entries(sources)){mkdirSync(dirname(join(workspace,path)),{recursive:true});writeFileSync(join(workspace,path),source);}
|
|
99
|
+
mkdirSync(join(workspace,'reports'),{recursive:true});
|
|
100
|
+
mkdirSync(join(profile,'node_modules'),{recursive:true});
|
|
101
|
+
symlinkSync(join(runtime,'node_modules/@deepseek-ai'),join(profile,'node_modules/@deepseek-ai'),'dir');
|
|
102
|
+
}
|
|
103
|
+
const agentCwd=requestedAgentCwd??workspace;
|
|
104
|
+
const artifactSnapshot=join(runDir,'artifact.tgz');
|
|
105
|
+
if(existsSync(artifactSnapshot))throw Error('Run artifact already exists; never overwrite benchmark evidence');
|
|
106
|
+
writeFileSync(artifactSnapshot,artifact.bytes);
|
|
107
|
+
const extracted={...await extract(artifactSnapshot,label),sourceArtifact:artifact.path};
|
|
108
|
+
mkdirSync(join(profile,'node_modules/@fish-under-sea'),{recursive:true});
|
|
109
|
+
const pluginLink=join(profile,'node_modules/@fish-under-sea/dsh-agent-teams-fish');
|
|
110
|
+
if(existsSync(pluginLink))rmSync(pluginLink);
|
|
111
|
+
symlinkSync(extracted.packageDir,pluginLink,'dir');
|
|
112
|
+
json(join(profile,'package.json'),{name:'agentteams-real-model-profile',version:'0.0.0',private:true,type:'module',dsh:{profile:{bundles:['@deepseek-ai/dsh-base','@deepseek-ai/dsh-headless','@fish-under-sea/dsh-agent-teams-fish'],patchReload:'startup'}}});
|
|
113
|
+
mkdirSync(join(runDir,'executed-fixtures'),{recursive:true});
|
|
114
|
+
for(const [source,target] of [['fixtures/harness-model-driver.mjs','fixture-model-driver.mjs'],['fixtures/harness-benchmark-scope.mjs','fixture-benchmark-scope.mjs'],[caseFile,'fixture-model-case.mjs'],...caseName!=='review'?[['fixtures/harness-model-case.mjs','harness-model-case.mjs']]:[],...caseName==='complex'?[['fixtures/harness-complex-oracle.mjs','harness-complex-oracle.mjs']]:[]]) {
|
|
115
|
+
writeFileSync(join(profile,target),testContents[source]);
|
|
116
|
+
writeFileSync(join(runDir,'executed-fixtures',target),testContents[source]);
|
|
117
|
+
}
|
|
118
|
+
const patch=[{id:'headless-startup',disabled:true},{id:'headless-runner',disabled:true},{id:'llm-pi-ai',disabled:true},{id:'session-title-llm',disabled:true},{id:'credentials',config:{path:credentialFile,watch:false}},{id:'llm-deepseek',config:adapter},{id:'agent-default-model',config:model},{id:'approval',config:{policy:'never'}},{id:'permission',config:{defaultPreset:'benchmark-workspace',presets:{'benchmark-workspace':{sandbox:'workspace-write',approval:'never'}}}},{insert:[{id:'agentteams-real-model-benchmark',name:'./fixture-model-driver.mjs'}]}];
|
|
119
|
+
if(requestedAgentCwd) patch.push({id:'agent-teams',config:{stateDir:relative(agentCwd,join(workspace,'.agent-teams'))}});
|
|
120
|
+
writeFileSync(join(profile,'cordis.patch.yml'),yaml.stringify(patch));
|
|
121
|
+
const trace=join(runDir,'trace.jsonl'),resultPath=join(runDir,'result.json'),configPath=join(runDir,'driver-config.json');
|
|
122
|
+
json(configPath,{phase,caseName,model,workspace,agentCwd,trace,result:resultPath,timeoutMs,maxRequests,...existing?.previous?{previous:existing.previous}:{},...existing?.priorTrace?{priorTrace:existing.priorTrace}:{}});
|
|
123
|
+
const exit=await command([process.execPath,join(runtime,'node_modules/@deepseek-ai/dsh/lib/bin.js'),'--profile','headless'],agentCwd,{...environment,DSH_HOME:home,AGENTTEAMS_BENCH_CONFIG:configPath},label);
|
|
124
|
+
const result=existsSync(resultPath)?JSON.parse(readFileSync(resultPath,'utf8')):{passed:false,error:'Driver did not produce a result'};
|
|
125
|
+
const outcome={label,...extracted,workspace,agentCwd,home,...result,exit};
|
|
126
|
+
outcome.passed=result.passed===true&&exit.code===0&&!exit.timedOut;
|
|
127
|
+
json(join(runDir,'run.json'),outcome);
|
|
128
|
+
console.log(JSON.stringify({label,passed:outcome.passed,provider:model.provider,model:model.model,requests:outcome.requests,elapsedMs:outcome.elapsedMs,checks:outcome.checks,error:outcome.error,modelErrors:outcome.modelErrors}));
|
|
129
|
+
return outcome;
|
|
130
|
+
}
|
|
131
|
+
const runs=[];
|
|
132
|
+
if(!only||only==='baseline')runs.push(await run('baseline','fresh',artifacts.baseline));
|
|
133
|
+
if(!only||only==='candidate')runs.push(await run('candidate','fresh',artifacts.candidate));
|
|
134
|
+
if(only==='candidate-finish') {
|
|
135
|
+
const previous=JSON.parse(readFileSync(join(report,'candidate/run.json'),'utf8'));
|
|
136
|
+
if(previous.passed||!previous.team)throw Error('Continuation requires an incomplete candidate with retained team evidence');
|
|
137
|
+
runs.push(await run(only,'finish',artifacts.candidate,{workspace:previous.workspace,home:previous.home,previous:previous.team,priorTrace:join(report,'candidate/trace.jsonl')}));
|
|
138
|
+
}
|
|
139
|
+
if(only==='candidate-cold-resume') {
|
|
140
|
+
const origin=JSON.parse(readFileSync(join(report,'candidate-cold/driver-config.json'),'utf8'));
|
|
141
|
+
const stopped=JSON.parse(readFileSync(join(report,'candidate-cold/run.json'),'utf8'));
|
|
142
|
+
if(stopped.passed)throw Error('Regression continuation requires an incomplete cold run');
|
|
143
|
+
runs.push(await run(only,'cold-resume',artifacts.candidate,{workspace:stopped.workspace,home:stopped.home,previous:origin.previous,priorTrace:join(report,'candidate-cold/trace.jsonl')}));
|
|
144
|
+
}
|
|
145
|
+
if(only==='candidate-cold'||only==='cancellation') {
|
|
146
|
+
const completedPath=existsSync(join(report,'candidate-finish/run.json'))?'candidate-finish/run.json':'candidate/run.json';
|
|
147
|
+
const previous=JSON.parse(readFileSync(join(report,completedPath),'utf8'));
|
|
148
|
+
if(!previous.passed||!previous.team)throw Error('Candidate must complete before follow-up verification');
|
|
149
|
+
const coldPlan=only==='candidate-cold'&&caseDefinition.prepareContinuation?await caseDefinition.prepareContinuation(previous.workspace):undefined;
|
|
150
|
+
runs.push(await run(only,only==='cancellation'?'cancel':'cold',artifacts.candidate,{workspace:previous.workspace,home:previous.home,previous:{...previous.team,...coldPlan?{coldPlan}:{}}}));
|
|
151
|
+
}
|
|
152
|
+
if(!only||only==='upgrade') {
|
|
153
|
+
const baseline=runs.find(run=>run.label==='baseline')??(existsSync(join(report,'baseline/run.json'))?JSON.parse(readFileSync(join(report,'baseline/run.json'),'utf8')):undefined);
|
|
154
|
+
if(baseline?.passed&&baseline.team)runs.push(await run('upgrade','cold',artifacts.candidate,{workspace:baseline.workspace,home:baseline.home,previous:baseline.team}));
|
|
155
|
+
else runs.push({label:'upgrade',passed:false,blocked:'Baseline must complete and retain its team before old-team cold-resume validation'});
|
|
156
|
+
}
|
|
157
|
+
const combined=['baseline','candidate','candidate-finish','upgrade','candidate-cold','candidate-cold-resume','cancellation'].flatMap(label=>existsSync(join(report,label,'run.json'))?[JSON.parse(readFileSync(join(report,label,'run.json'),'utf8'))]:runs.filter(run=>run.label===label));
|
|
158
|
+
const passed=combined.every(run=>run.passed);
|
|
159
|
+
const completedAfterContinuation=combined.some(run=>run.label==='candidate-finish'&&run.passed);
|
|
160
|
+
const regressionCompletedAfterContinuation=combined.some(run=>run.label==='candidate-cold-resume'&&run.passed);
|
|
161
|
+
const workflowPassed=combined.every(run=>run.passed||(run.label==='candidate'&&completedAfterContinuation)||(run.label==='candidate-cold'&®ressionCompletedAfterContinuation));
|
|
162
|
+
json(join(report,'result.json'),{passed,workflowPassed,completedAfterContinuation,regressionCompletedAfterContinuation,caseName,hostVersion,model,testFiles,runs:combined,unverified:['statistical success-rate equivalence from repeated independent trials','other providers/models',...caseName==='complex'&&combined.some(run=>['candidate-cold','candidate-cold-resume'].includes(run.label)&&run.passed)?[]:['real-provider quality repair loop'],...completedAfterContinuation?[]:['real-provider mid-task pause/resume'],'real-provider captain takeover','real browser interaction']});
|
|
163
|
+
process.exitCode=workflowPassed?0:1;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { test } from 'node:test';
|
|
6
|
+
import { linkDirectory } from './harness-runtime-scenarios.mjs';
|
|
7
|
+
|
|
8
|
+
test('fixture package links work without Windows symlink privileges and replace stale links', t => {
|
|
9
|
+
const root = mkdtempSync(join(tmpdir(), 'runtime link test '));
|
|
10
|
+
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
11
|
+
const first = join(root, 'first'), second = join(root, 'second'), link = join(root, 'profile package');
|
|
12
|
+
for (const target of [first, second]) {
|
|
13
|
+
mkdirSync(target);
|
|
14
|
+
writeFileSync(join(target, 'package.json'), JSON.stringify({ name: target }));
|
|
15
|
+
}
|
|
16
|
+
linkDirectory(first, link);
|
|
17
|
+
assert.equal(readFileSync(join(link, 'package.json'), 'utf8'), readFileSync(join(first, 'package.json'), 'utf8'));
|
|
18
|
+
rmSync(first, { recursive: true });
|
|
19
|
+
linkDirectory(second, link);
|
|
20
|
+
assert.equal(readFileSync(join(link, 'package.json'), 'utf8'), readFileSync(join(second, 'package.json'), 'utf8'));
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('fixture linking refuses to replace real files or directories', t => {
|
|
24
|
+
const root = mkdtempSync(join(tmpdir(), 'runtime-link-preserve-'));
|
|
25
|
+
t.after(() => rmSync(root, { recursive: true, force: true }));
|
|
26
|
+
const file = join(root, 'file'), directory = join(root, 'directory');
|
|
27
|
+
writeFileSync(file, 'keep');
|
|
28
|
+
mkdirSync(directory);
|
|
29
|
+
for (const path of [file, directory]) assert.throws(() => linkDirectory(root, path), /non-link fixture path/);
|
|
30
|
+
assert.equal(readFileSync(file, 'utf8'), 'keep');
|
|
31
|
+
});
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
/** Shared built-product scenarios for registry releases and explicitly identified source checkouts. */
|
|
2
|
+
import { mkdirSync, writeFileSync, readFileSync, existsSync, copyFileSync, symlinkSync, unlinkSync, lstatSync } from 'node:fs';
|
|
3
|
+
import { join, dirname, resolve } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { hostVerification } from './harness-validation.mjs';
|
|
6
|
+
|
|
7
|
+
const json = (path, value) => writeFileSync(path, JSON.stringify(value, null, 2) + '\n');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Windows refuses `symlinkSync(..., 'dir')` without Developer Mode or an elevated
|
|
11
|
+
* token. A directory junction links the same paths with no privilege, so the
|
|
12
|
+
* fixture profile can point at the prepared runtime on every supported host.
|
|
13
|
+
* A leftover link is removed first, so repeated runs over the same report
|
|
14
|
+
* directory do not fail with EEXIST.
|
|
15
|
+
*/
|
|
16
|
+
export const linkDirectory = (target, path) => {
|
|
17
|
+
try {
|
|
18
|
+
if (!lstatSync(path).isSymbolicLink()) throw Error('Refusing to replace non-link fixture path: ' + path);
|
|
19
|
+
unlinkSync(path);
|
|
20
|
+
} catch (error) { if (error.code !== 'ENOENT') throw error; }
|
|
21
|
+
symlinkSync(target, path, process.platform === 'win32' ? 'junction' : 'dir');
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const runtimeScenarios = ['lifecycle', 'fallback', 'failure', 'captain-idle-wakeup', 'progressive-entry', 'web-approval', 'protocol-compatibility', 'stability'];
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 0.2.1-rc.2 起 @deepseek-ai/dsh-client-connection 自己 inject credentials。凭据提供者由
|
|
28
|
+
* @deepseek-ai/dsh-base 声明(`- id: credentials` → dsh-credentials-local),但
|
|
29
|
+
* @deepseek-ai/dsh-headless 在同版本的 patch 里把它 disabled: true(无头任务用启动期凭据,
|
|
30
|
+
* 不挂交互式存储),于是连接会一直 pending(runtime-lab-connection),需要内存桩。
|
|
31
|
+
* 旧宿主(0.1.2 / 0.1.5 系)的 headless 不禁用它,宿主的提供者会自己注册;此时再 provide
|
|
32
|
+
* 一次会让 cordis 抛 `service "credentials" has been registered` 并让整个插件树加载失败。
|
|
33
|
+
* 因此按 base → headless 的加载顺序求 credentials 条目的最终状态,只在其被禁用时才注入。
|
|
34
|
+
*/
|
|
35
|
+
function credentialsEntryState(patchText) {
|
|
36
|
+
const lines = patchText.split('\n');
|
|
37
|
+
let state;
|
|
38
|
+
for (let index = 0; index < lines.length; index++) {
|
|
39
|
+
const header = /^(\s*)-\s+id:\s*credentials\s*$/.exec(lines[index]);
|
|
40
|
+
if (!header)
|
|
41
|
+
continue;
|
|
42
|
+
const indent = header[1].length;
|
|
43
|
+
let disabled = false;
|
|
44
|
+
let provider = false;
|
|
45
|
+
for (let cursor = index + 1; cursor < lines.length; cursor++) {
|
|
46
|
+
const line = lines[cursor];
|
|
47
|
+
const trimmed = line.trim();
|
|
48
|
+
if (trimmed === '' || trimmed.startsWith('#'))
|
|
49
|
+
continue;
|
|
50
|
+
if (line.length - line.trimStart().length <= indent)
|
|
51
|
+
break;
|
|
52
|
+
if (/^disabled:\s*true\s*$/.test(trimmed))
|
|
53
|
+
disabled = true;
|
|
54
|
+
if (/^name:\s*['"]?@deepseek-ai\/dsh-credentials-local/.test(trimmed))
|
|
55
|
+
provider = true;
|
|
56
|
+
}
|
|
57
|
+
state = { disabled, provider };
|
|
58
|
+
}
|
|
59
|
+
return state;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function webApprovalNeedsCredentialsStub(runtime) {
|
|
63
|
+
const connection = join(runtime, 'node_modules/@deepseek-ai/dsh-client-connection/lib/index.js');
|
|
64
|
+
if (!existsSync(connection) || !/inject\s*=\s*\[[^\]]*['"]credentials['"]/.test(readFileSync(connection, 'utf8')))
|
|
65
|
+
return false;
|
|
66
|
+
let state;
|
|
67
|
+
for (const bundle of ['@deepseek-ai/dsh-base', '@deepseek-ai/dsh-headless']) {
|
|
68
|
+
const patch = join(runtime, 'node_modules', ...bundle.split('/'), 'cordis.patch.yml');
|
|
69
|
+
if (!existsSync(patch))
|
|
70
|
+
continue;
|
|
71
|
+
state = credentialsEntryState(readFileSync(patch, 'utf8')) ?? state;
|
|
72
|
+
}
|
|
73
|
+
// 没有任何凭据条目时连接只能自己等,桩是唯一出路;有条目就看它是否还启用着提供者。
|
|
74
|
+
return state ? state.disabled : true;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** The direct fixture link cannot prove that a user's plugin install is accepted. */
|
|
78
|
+
export async function runPluginInstallation({ version, pluginVersion, artifact, runtime, report, command, environment }) {
|
|
79
|
+
if (!hostVerification(version).pluginManagerInstall) return [];
|
|
80
|
+
const home = join(report, 'plugin-install-home');
|
|
81
|
+
const install = await command([process.execPath, join(runtime, 'node_modules/@deepseek-ai/dsh/lib/bin.js'), 'plugin', '--profile', 'web', 'add', '--save-exact', resolve(artifact)], runtime, environment({ DSH_HOME: home, DSH_TELEMETRY_DISABLED: '1' }), 'plugin-manager-install', 120000);
|
|
82
|
+
const installedPath = join(home, 'profiles/web/node_modules/@fish-under-sea/dsh-agent-teams-fish/package.json');
|
|
83
|
+
const installed = existsSync(installedPath) ? JSON.parse(readFileSync(installedPath, 'utf8')) : undefined;
|
|
84
|
+
const assertions = { exit0: install.code === 0 && !install.timedOut, exactPluginVersion: installed?.version === pluginVersion };
|
|
85
|
+
return [{ scenario: 'plugin-manager-install', passed: Object.values(assertions).every(Boolean), assertions }];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Run the same fixture and persisted-state assertions against an already prepared runtime. */
|
|
89
|
+
export async function runRuntimeScenarios({ report, runtime, command, environment, selectedScenarios = runtimeScenarios, linkWorkspacePackages = false }) {
|
|
90
|
+
const runs = [];
|
|
91
|
+
for (const scenario of selectedScenarios) {
|
|
92
|
+
const home = join(report, scenario, 'home'), profile = join(home, 'profiles', 'headless'), workspace = join(report, scenario, 'workspace');
|
|
93
|
+
mkdirSync(profile, { recursive: true });
|
|
94
|
+
mkdirSync(workspace, { recursive: true });
|
|
95
|
+
mkdirSync(join(profile, 'node_modules/@fish-under-sea'), { recursive: true });
|
|
96
|
+
if (linkWorkspacePackages) linkDirectory(join(runtime, 'node_modules/@deepseek-ai'), join(profile, 'node_modules/@deepseek-ai'));
|
|
97
|
+
linkDirectory(join(runtime, 'node_modules/@fish-under-sea/dsh-agent-teams-fish'), join(profile, 'node_modules/@fish-under-sea/dsh-agent-teams-fish'));
|
|
98
|
+
json(join(profile, 'package.json'), { name: 'runtime-test-profile', version: '0.0.0', private: true, type: 'module', dsh: { profile: { bundles: ['@deepseek-ai/dsh-base', '@deepseek-ai/dsh-headless', '@fish-under-sea/dsh-agent-teams-fish'], patchReload: 'startup' } } });
|
|
99
|
+
copyFileSync(join(dirname(fileURLToPath(import.meta.url)), 'fixtures/harness-runtime-llm.mjs'), join(profile, 'fixture-llm.mjs'));
|
|
100
|
+
writeFileSync(join(profile, 'cordis.patch.yml'), `- id: llm-deepseek\n disabled: true\n- id: llm-pi-ai\n disabled: true\n- id: agent-default-model\n config:\n provider: runtime-lab\n model: fixture-model\n- insert:\n - id: runtime-lab-fixture\n name: './fixture-llm.mjs'\n`);
|
|
101
|
+
if (scenario === 'lifecycle')
|
|
102
|
+
// Regression for #163/#164: rename the delegation tool so no global
|
|
103
|
+
// tool named `subagent` exists, mirroring compositions where the
|
|
104
|
+
// host configured a different toolName. The default-depth member
|
|
105
|
+
// spawn must still succeed instead of dying in tools.restrict().
|
|
106
|
+
// Patch entries replace a same-id entry wholesale, so repeat the
|
|
107
|
+
// full dsh-base configuration and change only the tool name.
|
|
108
|
+
writeFileSync(join(profile, 'cordis.patch.yml'), readFileSync(join(profile, 'cordis.patch.yml'), 'utf8') + '- id: tool-subagent\n name: \'@deepseek-ai/dsh-tool-subagent\'\n config:\n provider: spawn\n toolName: subagent_legacy\n backgroundMode: continuable\n');
|
|
109
|
+
if (scenario === 'fallback')
|
|
110
|
+
writeFileSync(join(profile, 'cordis.patch.yml'), readFileSync(join(profile, 'cordis.patch.yml'), 'utf8') + '- id: agent-teams\n config:\n stateDir: .agent-teams\n memberProvider: spawn\n fallback:\n provider: runtime-lab\n model: fixture-fallback\n');
|
|
111
|
+
// Custom drivers replace the task runner, while startup still provides
|
|
112
|
+
// the host's filesystem and sandbox setup on newer Harness versions.
|
|
113
|
+
if (scenario === 'captain-idle-wakeup') {
|
|
114
|
+
copyFileSync(join(dirname(fileURLToPath(import.meta.url)), 'fixtures/harness-runtime-idle.mjs'), join(profile, 'fixture-idle.mjs'));
|
|
115
|
+
writeFileSync(join(profile, 'cordis.patch.yml'), readFileSync(join(profile, 'cordis.patch.yml'), 'utf8') + '- id: headless-runner\n disabled: true\n- insert:\n - id: runtime-lab-idle-captain\n name: ./fixture-idle.mjs\n');
|
|
116
|
+
}
|
|
117
|
+
if (scenario === 'progressive-entry' || scenario === 'stability')
|
|
118
|
+
copyFileSync(join(dirname(fileURLToPath(import.meta.url)), 'fixtures/harness-runtime-tools.mjs'), join(profile, 'fixture-tools.mjs'));
|
|
119
|
+
if (scenario === 'progressive-entry') {
|
|
120
|
+
copyFileSync(join(dirname(fileURLToPath(import.meta.url)), 'fixtures/harness-runtime-entry.mjs'), join(profile, 'fixture-entry.mjs'));
|
|
121
|
+
writeFileSync(join(profile, 'cordis.patch.yml'), readFileSync(join(profile, 'cordis.patch.yml'), 'utf8') + `- id: headless-runner
|
|
122
|
+
disabled: true
|
|
123
|
+
- id: agent-teams
|
|
124
|
+
config:
|
|
125
|
+
profiles:
|
|
126
|
+
demo-profile:
|
|
127
|
+
description: Entry benchmark roster
|
|
128
|
+
taskPlanning: captain
|
|
129
|
+
members:
|
|
130
|
+
- name: worker
|
|
131
|
+
role: MEMBER_FIXTURE
|
|
132
|
+
executionPrompt: 'MEMBER_FIXTURE: complete the assigned task and report.'
|
|
133
|
+
reasoning_effort: high
|
|
134
|
+
- insert:
|
|
135
|
+
- id: runtime-lab-progressive-entry
|
|
136
|
+
name: ./fixture-entry.mjs
|
|
137
|
+
`);
|
|
138
|
+
}
|
|
139
|
+
if (scenario === 'web-approval') {
|
|
140
|
+
copyFileSync(join(dirname(fileURLToPath(import.meta.url)), 'fixtures/harness-runtime-web-approval.mjs'), join(profile, 'fixture-web-approval.mjs'));
|
|
141
|
+
const credentialsStub = webApprovalNeedsCredentialsStub(runtime);
|
|
142
|
+
if (credentialsStub)
|
|
143
|
+
copyFileSync(join(dirname(fileURLToPath(import.meta.url)), 'fixtures/harness-runtime-credentials.mjs'), join(profile, 'fixture-credentials.mjs'));
|
|
144
|
+
writeFileSync(join(profile, 'cordis.patch.yml'), readFileSync(join(profile, 'cordis.patch.yml'), 'utf8') + `- id: runtime-lab-fixture
|
|
145
|
+
disabled: true
|
|
146
|
+
- id: headless-runner
|
|
147
|
+
disabled: true
|
|
148
|
+
- id: credentials
|
|
149
|
+
disabled: false
|
|
150
|
+
- insert:
|
|
151
|
+
- id: runtime-lab-webserver
|
|
152
|
+
name: '@deepseek-ai/dsh-host-webserver'
|
|
153
|
+
config:
|
|
154
|
+
host: 127.0.0.1
|
|
155
|
+
port: 0
|
|
156
|
+
${credentialsStub ? ' - id: runtime-lab-credentials\n name: ./fixture-credentials.mjs\n' : ''} - id: runtime-lab-connection
|
|
157
|
+
name: '@deepseek-ai/dsh-client-connection'
|
|
158
|
+
- id: runtime-lab-workspace
|
|
159
|
+
name: '@deepseek-ai/dsh-workspace'
|
|
160
|
+
- id: runtime-lab-web-approval
|
|
161
|
+
name: ./fixture-web-approval.mjs
|
|
162
|
+
`);
|
|
163
|
+
}
|
|
164
|
+
if (scenario === 'protocol-compatibility') {
|
|
165
|
+
copyFileSync(join(dirname(fileURLToPath(import.meta.url)), 'fixtures/harness-runtime-protocol.mjs'), join(profile, 'fixture-protocol.mjs'));
|
|
166
|
+
writeFileSync(join(profile, 'cordis.patch.yml'), readFileSync(join(profile, 'cordis.patch.yml'), 'utf8') + `- id: runtime-lab-fixture
|
|
167
|
+
disabled: true
|
|
168
|
+
- id: headless-runner
|
|
169
|
+
disabled: true
|
|
170
|
+
- id: agent-teams
|
|
171
|
+
config:
|
|
172
|
+
profiles:
|
|
173
|
+
north:
|
|
174
|
+
protocol: Investigate an existing codebase and design a goal-specific task DAG.
|
|
175
|
+
taskPlanning: captain
|
|
176
|
+
members:
|
|
177
|
+
- name: worker
|
|
178
|
+
role: Research the existing implementation
|
|
179
|
+
south:
|
|
180
|
+
protocol: Apply a fixed release-readiness checklist to a prepared release.
|
|
181
|
+
taskPlanning: seed
|
|
182
|
+
members:
|
|
183
|
+
- name: reviewer
|
|
184
|
+
role: Review release readiness
|
|
185
|
+
tasks:
|
|
186
|
+
- id: release-check
|
|
187
|
+
subject: Check the release checklist
|
|
188
|
+
assignee: reviewer
|
|
189
|
+
- insert:
|
|
190
|
+
- id: runtime-lab-protocol-compatibility
|
|
191
|
+
name: ./fixture-protocol.mjs
|
|
192
|
+
`);
|
|
193
|
+
}
|
|
194
|
+
if (scenario === 'stability') {
|
|
195
|
+
copyFileSync(join(dirname(fileURLToPath(import.meta.url)), 'fixtures/harness-runtime-stability.mjs'), join(profile, 'fixture-stability.mjs'));
|
|
196
|
+
writeFileSync(join(profile, 'cordis.patch.yml'), readFileSync(join(profile, 'cordis.patch.yml'), 'utf8') + `- id: runtime-lab-fixture
|
|
197
|
+
disabled: true
|
|
198
|
+
- id: headless-runner
|
|
199
|
+
disabled: true
|
|
200
|
+
- id: agent-teams
|
|
201
|
+
config:
|
|
202
|
+
memberMaxDepth: 1
|
|
203
|
+
toolPolicies:
|
|
204
|
+
restricted:
|
|
205
|
+
deny: [lab_forbidden]
|
|
206
|
+
- insert:
|
|
207
|
+
- id: runtime-lab-stability
|
|
208
|
+
name: ./fixture-stability.mjs
|
|
209
|
+
`);
|
|
210
|
+
}
|
|
211
|
+
const tracePath = join(report, scenario, 'trace.jsonl');
|
|
212
|
+
const result = await command([process.execPath, join(runtime, 'node_modules/@deepseek-ai/dsh/lib/bin.js'), '--profile', 'headless', 'Run the authorized deterministic AgentTeams fixture immediately.'], workspace, environment({ DSH_HOME: home, DSH_PERMISSION_MODE: 'danger-full-access', DSH_TELEMETRY_DISABLED: '1', LAB_TRACE: tracePath, LAB_TEAMS: '1', LAB_SCENARIO: scenario }), scenario, 90000);
|
|
213
|
+
const trace = existsSync(tracePath) ? readFileSync(tracePath, 'utf8').trim().split('\n').filter(Boolean).map(s => JSON.parse(s)) : [];
|
|
214
|
+
if (scenario === 'stability') {
|
|
215
|
+
const checks = ['hmr', 'lazy-start', 'running-plan-correction', 'steering', 'read-receipt-continuation', 'reassign', 'archive', 'batch-plan', 'terminal-evidence', 'report-retry', 'settlement-dedup'];
|
|
216
|
+
const assertions = { exit0: result.code === 0 && !result.timedOut, productMarker: result.stdout.includes('STABILITY_OK'), ...Object.fromEntries(checks.map(check => [check, trace.some(x => x.event === `stability-${check}-passed`)])) };
|
|
217
|
+
runs.push({ scenario, passed: Object.values(assertions).every(Boolean), assertions, evidence: trace.filter(x => checks.some(check => x.event === `stability-${check}-passed`)), exit: { code: result.code, signal: result.signal, timedOut: result.timedOut } });
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
if (scenario === 'protocol-compatibility') {
|
|
221
|
+
const cases = trace.filter(x => x.event === 'protocol-case-passed');
|
|
222
|
+
const assertions = { exit0: result.code === 0 && !result.timedOut, productMarker: result.stdout.includes('PROTOCOL_COMPATIBILITY_OK'), legacyAllowlistAndColdRestore: cases.some(x => x.label === 'legacy-allowlist-cold-compact') && trace.some(x => x.event === 'protocol-cold-restored'), legacyProfileDirectory: trace.some(x => x.event === 'protocol-legacy-profile-directory' && x.onlyOriginalTools === true && x.northPurposeVisible && x.southPurposeVisible) && cases.some(x => x.label === 'legacy-allowlist-cold-compact' && x.profile === 'north'), actualPtcDiscard: cases.some(x => x.label === 'ptc-discard-and-compact') && trace.some(x => x.event === 'protocol-ptc-output-discarded' && x.tool === 'agent_teams_status'), actualPruning: trace.some(x => x.event === 'protocol-pruned'), actualCompaction: trace.filter(x => x.event === 'protocol-compacted').length === 2, existingPlanRevised: cases.length === 2 && cases.every(x => x.persistedSubject === 'Recovered task'), lifecycleArchived: cases.length === 2 && cases.every(x => x.archived === true) };
|
|
223
|
+
runs.push({ scenario, passed: Object.values(assertions).every(Boolean), assertions, cases, exit: { code: result.code, signal: result.signal, timedOut: result.timedOut } });
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
if (scenario === 'progressive-entry') {
|
|
227
|
+
const cases = trace.filter(x => x.event === 'entry-case-passed').map(x => x.label);
|
|
228
|
+
const stablePrefixes = trace.filter(x => x.event === 'stable-prefix-passed');
|
|
229
|
+
const labels = ['natural', 'natural-zh', 'raw-slash', 'command', 'profile-command', 'profile-raw'];
|
|
230
|
+
const assertions = { exit0: result.code === 0 && !result.timedOut, productMarker: result.stdout.includes('PROGRESSIVE_ENTRY_OK'), allEntries: labels.every(label => cases.includes(label)), stablePrefixes: labels.every(label => stablePrefixes.some(x => x.label === label)), thirtyOrdinaryTurns: stablePrefixes.some(x => x.label === 'natural' && x.precedingOrdinaryTurns === 30) };
|
|
231
|
+
runs.push({ scenario, passed: Object.values(assertions).every(Boolean), assertions, cases, exit: { code: result.code, signal: result.signal, timedOut: result.timedOut } });
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
if (scenario === 'web-approval') {
|
|
235
|
+
const staged = trace.find(x => x.event === 'web-staged-idle'), approved = trace.find(x => x.event === 'web-http-approved');
|
|
236
|
+
const approvalWake = trace.find(x => x.event === 'web-captain-approval-wake'), yielded = trace.find(x => x.event === 'web-approved-idle');
|
|
237
|
+
const released = trace.find(x => x.event === 'web-member-output-released'), reportWake = trace.find(x => x.event === 'web-captain-report-wake');
|
|
238
|
+
const evidence = trace.find(x => x.event === 'web-approval-passed');
|
|
239
|
+
const invalid = trace.find(x => x.event === 'web-http-invalid-team-rejected'), repeated = trace.find(x => x.event === 'web-http-repeat-rejected');
|
|
240
|
+
const stable = trace.find(x => x.event === 'web-headers-stable');
|
|
241
|
+
const byteAudit = trace.find(x => x.event === 'web-workspace-audit');
|
|
242
|
+
const assertions = { claimedProjection: trace.some(x => x.event === 'web-claimed-projection' && x.taskStatus === 'claimed' && x.visualState === 'claimed' && x.memberActivity === 'working'), exit0: result.code === 0 && !result.timedOut, productMarker: result.stdout.includes('WEB_APPROVAL_OK'), driverCompleted: Boolean(evidence), stagedBeforeApproval: Boolean(staged?.status === 'idle' && approved?.status === 200 && staged.order < approved.order), independentApprovalWake: Boolean(approvalWake && yielded?.status === 'idle' && released && approvalWake.order < yielded.order && yielded.order < released.order), reportWakeAfterYield: Boolean(released && reportWake && released.order < reportWake.order && reportWake.sessionId === staged?.sessionId), noPollingOrDuplicateApproval: !trace.some(x => x.event === 'web-model-tool-call' && ['agent_teams_approve', 'agent_teams_status'].includes(x.name)), oneUserMessageAndHttpApproval: trace.filter(x => x.event === 'web-driver-user-message').length === 1 && trace.filter(x => x.event === 'web-http-approval-start').length === 1, invalidTeamRejected: Boolean(invalid?.status === 404 && approved && invalid.order < approved.order), repeatApprovalRejected: Boolean(repeated?.status === 409 && yielded && released && yielded.order < repeated.order && repeated.order < released.order), stableCaptainHeaders: Boolean(stable?.systemSha256 && stable?.toolsSha256), memberFourTools: stable?.memberTeamToolCount === 4 && stable.memberRequests > 0, taskCompleted: evidence?.taskStatus === 'completed' };
|
|
243
|
+
assertions.byteAuditSnapshot = byteAudit?.before?.ok === true && byteAudit.before.deliverable === true
|
|
244
|
+
&& byteAudit?.after?.ok === false && byteAudit.after.deliverable === false && byteAudit.after.stale === true && byteAudit.hostBytesRead === 0;
|
|
245
|
+
runs.push({ scenario, passed: Object.values(assertions).every(Boolean), assertions, evidence, exit: { code: result.code, signal: result.signal, timedOut: result.timedOut } });
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
const statePath = join(workspace, '.agent-teams/runtime-lab/team.json'), state = existsSync(statePath) ? JSON.parse(readFileSync(statePath, 'utf8')) : undefined;
|
|
249
|
+
const requests = trace.filter(x => x.event === 'request' && x.purpose === undefined), memberRequests = requests.filter(x => x.isMember);
|
|
250
|
+
const isFailure = scenario === 'failure';
|
|
251
|
+
const memberToolsRestricted = rows => rows.length > 0 && rows.every(x => !x.toolNames.includes('agent_teams_create') && x.toolNames.includes('agent_teams_claim_task'));
|
|
252
|
+
const assertions = { exit0: result.code === 0 && !result.timedOut, productMarker: result.stdout.includes(isFailure ? 'AGENTTEAMS_EXPECTED_FAILURE_OK' : scenario === 'captain-idle-wakeup' ? 'CAPTAIN_IDLE_WAKEUP_OK' : 'AGENTTEAMS_PRODUCT_TURN_OK'), pluginToolsVisible: requests.some(x => x.toolNames.includes('agent_teams_create')), memberExecuted: memberRequests.length > 0, memberToolsRestricted: memberToolsRestricted(memberRequests), explicitReasoning: memberRequests.length > 0 && memberRequests.some(x => x.model !== 'fixture-fallback') && memberRequests.filter(x => x.model !== 'fixture-fallback').every(x => x.reasoningEffort === 'high'), taskTerminal: state?.tasks?.find(t => t.id === 't1')?.status === (isFailure ? 'failed' : 'completed') };
|
|
253
|
+
if (!isFailure && scenario !== 'captain-idle-wakeup')
|
|
254
|
+
assertions.secondWake = memberRequests.some(x => x.userText.includes('SECOND_WAKE_FIXTURE'));
|
|
255
|
+
if (scenario === 'captain-idle-wakeup') {
|
|
256
|
+
const idle = trace.find(x => x.event === 'captain-idle-observed');
|
|
257
|
+
const notified = trace.find(x => x.event === 'captain-notified-after-yield');
|
|
258
|
+
assertions.captainActuallyYielded = idle?.status === 'idle';
|
|
259
|
+
assertions.notifiedAfterIdle = Boolean(idle && notified && idle.time < notified.time && idle.sessionId === notified.sessionId);
|
|
260
|
+
}
|
|
261
|
+
if (scenario === 'lifecycle') {
|
|
262
|
+
const withBoth = memberRequests.find(x => x.userText.includes('FIFO_FIRST') && x.userText.includes('FIFO_SECOND'));
|
|
263
|
+
assertions.fifoMessageOrder = Boolean(withBoth && withBoth.userText.indexOf('FIFO_FIRST') < withBoth.userText.indexOf('FIFO_SECOND'));
|
|
264
|
+
const firstMember = memberRequests[0], firstResponse = trace.find(x => x.event === 'response' && x.isMember);
|
|
265
|
+
const busySend = trace.find(x => x.event === 'request' && !x.isMember && x.called.includes('agent_teams_send_message'));
|
|
266
|
+
assertions.messagesSentWhileBusy = Boolean(firstMember && firstResponse && busySend && firstMember.time <= busySend.time && busySend.time < firstResponse.time);
|
|
267
|
+
}
|
|
268
|
+
if (scenario === 'fallback') {
|
|
269
|
+
assertions.fallbackActivated = memberRequests.some(x => x.model === 'fixture-fallback') && state?.members?.some(m => m.fallbackActive && m.activeModel === 'fixture-fallback');
|
|
270
|
+
assertions.fallbackReasoningReset = memberRequests.some(x => x.model === 'fixture-fallback') && memberRequests.filter(x => x.model === 'fixture-fallback').every(x => x.reasoningEffort === 'low');
|
|
271
|
+
const primaryFailures = trace.filter(x => x.event === 'fallback-primary-auth');
|
|
272
|
+
const firstFallback = memberRequests.find(x => x.model === 'fixture-fallback');
|
|
273
|
+
const task = state?.tasks?.find(task => task.id === 't1');
|
|
274
|
+
assertions.fallbackPreservedAttempt = primaryFailures.length === 1 && firstFallback !== undefined
|
|
275
|
+
&& firstFallback.sessionId === primaryFailures[0].sessionId
|
|
276
|
+
&& task?.attemptId === primaryFailures[0].attemptId && task.attempt === 1
|
|
277
|
+
&& firstFallback.called.filter(name => name === 'agent_teams_claim_task').length === 1
|
|
278
|
+
&& firstFallback.called.filter(name => name === 'agent_teams_update_task').length === 1;
|
|
279
|
+
}
|
|
280
|
+
const passed = Object.values(assertions).every(Boolean);
|
|
281
|
+
runs.push({ scenario, passed, exit: { code: result.code, signal: result.signal, timedOut: result.timedOut }, assertions, requests: requests.length, memberRequests: memberRequests.length });
|
|
282
|
+
if (state)
|
|
283
|
+
json(join(report, scenario, 'team-evidence.json'), state);
|
|
284
|
+
if (passed && !isFailure && scenario !== 'captain-idle-wakeup') {
|
|
285
|
+
copyFileSync(join(dirname(fileURLToPath(import.meta.url)), 'fixtures/harness-runtime-resume.mjs'), join(profile, 'fixture-resume.mjs'));
|
|
286
|
+
writeFileSync(join(profile, 'cordis.patch.yml'), readFileSync(join(profile, 'cordis.patch.yml'), 'utf8') + '- id: headless-runner\n disabled: true\n- insert:\n - id: runtime-lab-cold-resume\n name: ./fixture-resume.mjs\n');
|
|
287
|
+
const coldTrace = join(report, scenario, 'cold-trace.jsonl');
|
|
288
|
+
// Older startup parsers require a task even when the runner is disabled.
|
|
289
|
+
const cold = await command([process.execPath, join(runtime, 'node_modules/@deepseek-ai/dsh/lib/bin.js'), '--profile', 'headless', 'Run the deterministic cold restore fixture.'], workspace, environment({ DSH_HOME: home, DSH_PERMISSION_MODE: 'danger-full-access', DSH_TELEMETRY_DISABLED: '1', LAB_TRACE: coldTrace, LAB_TEAMS: '1', LAB_COLD: '1', LAB_SCENARIO: scenario, LAB_PARENT_SESSION: state.captainSessionId }), scenario + '-cold', 90000);
|
|
290
|
+
const coldEvents = existsSync(coldTrace) ? readFileSync(coldTrace, 'utf8').trim().split('\n').filter(Boolean).map(s => JSON.parse(s)) : [];
|
|
291
|
+
const coldMember = coldEvents.find(x => x.event === 'cold-member-completed');
|
|
292
|
+
const coldAssertions = { memberToolsRestricted: memberToolsRestricted(coldEvents.filter(x => x.event === 'request' && x.isMember && x.purpose === undefined)), exit0: cold.code === 0 && !cold.timedOut, driverCompleted: cold.stdout.includes('COLD_RESTORE_DRIVER_DONE'), sameMemberRestored: coldMember?.sessionId === state.members.find(m => m.name === 'worker')?.id, routeRestored: coldMember?.model === (scenario === 'fallback' ? 'fixture-fallback' : 'fixture-model'), reasoningRestored: coldMember?.reasoningEffort === (scenario === 'fallback' ? 'low' : 'high') };
|
|
293
|
+
runs.push({ scenario: scenario + '-cold-restore', passed: Object.values(coldAssertions).every(Boolean), assertions: coldAssertions, exit: { code: cold.code, signal: cold.signal, timedOut: cold.timedOut } });
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return runs;
|
|
297
|
+
}
|