@anusornneal/chat-relay 1.9.0 → 2.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/README.md +8 -0
- package/agent/activity-capture.mjs +218 -0
- package/agent/auto-session-binding.mjs +46 -0
- package/agent/capability-scheduler.mjs +82 -5
- package/agent/file-manager.mjs +33 -8
- package/agent/full-bridge.mjs +53 -0
- package/agent/full-desktop-actions.mjs +124 -0
- package/agent/full-desktop-auth.mjs +53 -0
- package/agent/full-desktop-broker.mjs +318 -0
- package/agent/full-host.mjs +153 -0
- package/agent/full-job-broker.mjs +360 -0
- package/agent/full-native-job.mjs +205 -0
- package/agent/full-presentation-changes.mjs +191 -0
- package/agent/full-remote-diagnostics.mjs +129 -0
- package/agent/full-resources.mjs +343 -0
- package/agent/full-runtime-supervisor.mjs +67 -0
- package/agent/full-session-dispatch.mjs +167 -0
- package/agent/full-workspace-broker.mjs +290 -0
- package/agent/git-worktree-manager.mjs +171 -4
- package/agent/lifecycle.mjs +11 -0
- package/agent/local-agent.mjs +177 -24
- package/agent/local-usage.mjs +21 -0
- package/agent/monitor-activity.mjs +135 -0
- package/agent/presentation-redaction.mjs +10 -0
- package/agent/process-manager.mjs +32 -0
- package/agent/terminal-manager.mjs +189 -31
- package/agent/toolcall-context.mjs +27 -1
- package/agent/toolcall-summary.mjs +1 -1
- package/agent/windows-desktop-runner.mjs +65 -61
- package/agent/windows-desktop-worker.ps1 +33 -18
- package/agent/windows-powershell.mjs +51 -0
- package/cli/full-background.mjs +69 -0
- package/cli/full-launch.mjs +76 -0
- package/cli/full-prepare-child.mjs +48 -0
- package/cli/full-prepare.mjs +171 -0
- package/cli/full-release-default.json +4 -0
- package/cli/full-release-files.mjs +36 -0
- package/cli/full-release-official.mjs +48 -0
- package/cli/full-release-source.mjs +37 -0
- package/cli/index.mjs +9 -5
- package/cli/mod-cache.mjs +170 -0
- package/cli/mod-loader.mjs +67 -0
- package/cli/mod-manifest.mjs +63 -0
- package/cli/remote.mjs +173 -18
- package/cli/runner-ownership.mjs +116 -3
- package/cli/self-update.mjs +1 -1
- package/cli/tui.mjs +2 -20
- package/package.json +5 -3
- package/packages/full-contracts/auto-session.mjs +14 -0
- package/packages/full-contracts/index.mjs +193 -0
- package/packages/full-contracts/monitor-metadata.mjs +28 -0
- package/packages/full-contracts/native-job.mjs +13 -0
- package/packages/full-contracts/package.json +7 -0
- package/packages/full-contracts/remote-session.mjs +239 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import {spawn,execFile} from "node:child_process";
|
|
4
|
+
import {createHash,randomBytes} from "node:crypto";
|
|
5
|
+
import {StringDecoder} from "node:string_decoder";
|
|
6
|
+
import {FullContractError} from "../packages/full-contracts/index.mjs";
|
|
7
|
+
import {nativeJobPlatform,validNativeRecovery} from "../packages/full-contracts/native-job.mjs";
|
|
8
|
+
import {validateCommand} from "./terminal-manager.mjs";
|
|
9
|
+
import {powerShellUtf8Script} from "./windows-powershell.mjs";
|
|
10
|
+
|
|
11
|
+
const err=code=>new FullContractError(code);
|
|
12
|
+
const MAX_OUTPUT_BYTES=128*1024,MAX_FRAME=8193,MAX_PAGE=24*1024;
|
|
13
|
+
const timeout=(v)=>Number.isSafeInteger(v)&&v>=1000&&v<=1800000;
|
|
14
|
+
const nativeEnvironment=()=>Object.fromEntries(Object.entries(process.env).filter(([key])=>{
|
|
15
|
+
// Inherited Relay credentials and bootstrap/IPC state must never reach jobs.
|
|
16
|
+
// Preserve normal developer environment (including SDK/tool paths).
|
|
17
|
+
return !/^(?:RELAY_|AGENT_|CHAT_RELAY_|NODE_CHANNEL_|OPENAI_APPS_|TEST_ADMIN_TOKEN$|CALLER_TOKEN$|ADMIN_TOKEN$)/i.test(key);
|
|
18
|
+
}));
|
|
19
|
+
// Stable selected toolchain environment identity, not a claim of a complete
|
|
20
|
+
// machine/dependency snapshot. Hash values rather than disclosing paths.
|
|
21
|
+
export function verificationEnvironment(artifactId){
|
|
22
|
+
const keys=new Set(["path","java_home","android_home","android_sdk_root","gradle_user_home","node_options","systemroot"]);
|
|
23
|
+
const selected=Object.entries(nativeEnvironment()).filter(([key])=>keys.has(key.toLowerCase())).map(([key,value])=>[key.toLowerCase(),value]).sort(([a],[b])=>a.localeCompare(b));
|
|
24
|
+
const digest=createHash("sha256").update(JSON.stringify([process.version,artifactId,selected])).digest("hex");
|
|
25
|
+
return "native-v1:"+process.platform+"-"+process.arch+":"+digest;
|
|
26
|
+
}
|
|
27
|
+
function outputBuffer(){
|
|
28
|
+
const rows=[];let seq=0,bytes=0;
|
|
29
|
+
const decoders={stdout:new StringDecoder("utf8"),stderr:new StringDecoder("utf8")};
|
|
30
|
+
function append(stream,text){
|
|
31
|
+
if(!text)return;
|
|
32
|
+
// Bound JSON expansion even for binary/control-character-heavy output.
|
|
33
|
+
for(let offset=0;offset<text.length;){
|
|
34
|
+
let end=Math.min(offset+2048,text.length);
|
|
35
|
+
if(end<text.length&&/[\uD800-\uDBFF]/.test(text[end-1]))end--;
|
|
36
|
+
const part=text.slice(offset,end);offset=end;
|
|
37
|
+
const n=Buffer.byteLength(part);rows.push({seq:++seq,stream,text:part,n});bytes+=n;
|
|
38
|
+
while(bytes>MAX_OUTPUT_BYTES||rows.length>256)bytes-=rows.shift().n;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
add(stream,chunk){append(stream,decoders[stream].write(chunk));},
|
|
43
|
+
end(){for(const stream of ["stdout","stderr"])append(stream,decoders[stream].end());},
|
|
44
|
+
read(afterSeq=0){
|
|
45
|
+
if(afterSeq>seq)throw err("full_invalid_cursor");
|
|
46
|
+
const oldest=rows[0]?.seq??seq+1,items=[];let size=0;
|
|
47
|
+
for(const {n,...row} of rows){
|
|
48
|
+
if(row.seq<=afterSeq)continue;
|
|
49
|
+
const cost=Buffer.byteLength(JSON.stringify(row));
|
|
50
|
+
if(size+cost>MAX_PAGE&&items.length)break;
|
|
51
|
+
items.push(row);size+=cost;
|
|
52
|
+
}
|
|
53
|
+
return {chunks:items,nextSeq:items.at(-1)?.seq??Math.min(seq,Math.max(afterSeq,oldest-1)),oldestSeq:oldest,
|
|
54
|
+
truncated:afterSeq<oldest-1,hasMore:(items.at(-1)?.seq??afterSeq)<seq};
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Framed trusted helper channel, NOT command stdout. Descendants inherit only
|
|
60
|
+
* separate output pipes; text pretending to be a proof is just output data. */
|
|
61
|
+
export function launchNativeJob(helper,program,args,{cwd,timeoutMs,env=nativeEnvironment(),guardPath:recoveryFile,platform=process.platform}={}){
|
|
62
|
+
const provider=nativeJobPlatform(platform);if(!provider)throw err("full_native_provider_unavailable");
|
|
63
|
+
if(!path.isAbsolute(helper)||!path.isAbsolute(program)||!path.isAbsolute(cwd)||!timeout(timeoutMs))throw err("full_invalid_native_job");
|
|
64
|
+
if(recoveryFile!==undefined&&!path.isAbsolute(recoveryFile))throw err("full_invalid_job_recovery");
|
|
65
|
+
const child=spawn(helper,[...(recoveryFile?["--guard",recoveryFile]:[]),String(timeoutMs),program,...args],{cwd,env,windowsHide:true,stdio:["pipe","pipe","pipe"]});
|
|
66
|
+
const output=outputBuffer();
|
|
67
|
+
let readyResolve,readyReject,finish,identity=null,proof=null,bad=false,closed=false,settled=false,cancelRequested=false,buffer=Buffer.alloc(0);
|
|
68
|
+
const ready=new Promise((resolve,reject)=>{readyResolve=resolve;readyReject=reject;});ready.catch(()=>{});
|
|
69
|
+
const completion=new Promise(resolve=>{finish=resolve;});
|
|
70
|
+
function abortProtocol(){
|
|
71
|
+
if(bad)return;
|
|
72
|
+
bad=true;
|
|
73
|
+
readyReject(err("full_native_protocol_error"));
|
|
74
|
+
// Closing only our helper control pipe requests job termination. A forced
|
|
75
|
+
// helper kill is a last resort, never a substitute for stop proof.
|
|
76
|
+
child.stdin.destroy();
|
|
77
|
+
}
|
|
78
|
+
function onData(chunk){
|
|
79
|
+
if(bad)return;
|
|
80
|
+
buffer=buffer.length?Buffer.concat([buffer,chunk]):chunk;
|
|
81
|
+
while(buffer.length>=4){
|
|
82
|
+
const length=buffer.readUInt32LE(0);
|
|
83
|
+
if(length<1||length>MAX_FRAME){abortProtocol();return;}
|
|
84
|
+
if(buffer.length<length+4)break;
|
|
85
|
+
const frame=buffer.subarray(4,4+length);buffer=buffer.subarray(4+length);
|
|
86
|
+
const tag=frame[0],data=frame.subarray(1);
|
|
87
|
+
if(proof){abortProtocol();return;}
|
|
88
|
+
if(tag===82&&data.length===12&&!identity){
|
|
89
|
+
const pid=data.readUInt32LE(0),birth=data.readBigUInt64LE(4).toString();
|
|
90
|
+
if(pid===0||birth==="0"){abortProtocol();return;}
|
|
91
|
+
identity=Object.freeze({state:"present",pid,birth,scheme:provider.identityScheme});readyResolve(identity);
|
|
92
|
+
}else if((tag===79||tag===69)&&identity)output.add(tag===79?"stdout":"stderr",data);
|
|
93
|
+
else if(tag===70&&identity&&data.length===5&&data[0]<=provider.maxReason){
|
|
94
|
+
const reason=["exited","cancelled","timed-out","outcome-unknown"][data[0]];
|
|
95
|
+
proof={identity,treeStopped:true,reason,...(reason==="outcome-unknown"?{}:{exitCode:data.readUInt32LE(1)})};
|
|
96
|
+
}else{abortProtocol();return;}
|
|
97
|
+
}
|
|
98
|
+
if(buffer.length>MAX_FRAME+4)abortProtocol();
|
|
99
|
+
}
|
|
100
|
+
child.stdout.on("data",onData);
|
|
101
|
+
// No raw native error/command text reaches the durable store.
|
|
102
|
+
child.stderr.resume();child.stdin.on("error",()=>{});
|
|
103
|
+
child.once("error",()=>{readyReject(err("full_native_launch_failed"));bad=true;});
|
|
104
|
+
const handshake=setTimeout(()=>{if(!identity)abortProtocol();},10000);handshake.unref();
|
|
105
|
+
const watchdog=setTimeout(()=>{if(!closed){abortProtocol();try{child.kill();}catch{}}},timeoutMs+20000);watchdog.unref();
|
|
106
|
+
child.once("close",(code,signal)=>{
|
|
107
|
+
closed=true;clearTimeout(handshake);clearTimeout(watchdog);output.end();
|
|
108
|
+
if(!identity)readyReject(err("full_native_launch_failed"));
|
|
109
|
+
settled=true;
|
|
110
|
+
finish(!bad&&proof&&buffer.length===0&&code===0&&!signal?Object.freeze(proof):Object.freeze({treeStopped:false,reason:"outcome-unknown"}));
|
|
111
|
+
});
|
|
112
|
+
return Object.freeze({
|
|
113
|
+
ready,completion,read:afterSeq=>output.read(afterSeq),
|
|
114
|
+
get settled(){return settled;},
|
|
115
|
+
cancel(){if(!closed&&!cancelRequested){cancelRequested=true;child.stdin.end(Buffer.from([1]));}},
|
|
116
|
+
// Used only for bounded shutdown of the exact helper child handle. No PID
|
|
117
|
+
// lookup and no fabricated tree proof if the helper failed to settle.
|
|
118
|
+
force(){if(!closed){abortProtocol();try{child.kill();}catch{}}}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
const recoveryProvider=(platform)=>{const value=nativeJobPlatform(platform);if(!value)throw err("full_invalid_job_recovery");return value;};
|
|
124
|
+
async function recoveryFolder(directory,platform=process.platform){
|
|
125
|
+
if(!path.isAbsolute(directory??""))throw err("full_invalid_job_recovery");
|
|
126
|
+
const root=await fs.realpath(directory);
|
|
127
|
+
if(path.relative(root,directory)!==""||(await fs.lstat(directory)).isSymbolicLink())throw err("full_invalid_job_recovery");
|
|
128
|
+
const folder=path.join(root,"native-jobs");await fs.mkdir(folder,{recursive:true,mode:0o700});
|
|
129
|
+
const stat=await fs.lstat(folder);
|
|
130
|
+
if(!stat.isDirectory()||stat.isSymbolicLink()||path.relative(folder,await fs.realpath(folder))!==""||
|
|
131
|
+
(platform==="linux"&&(stat.uid!==process.getuid()||(stat.mode&0o777)!==0o700)))throw err("full_invalid_job_recovery");
|
|
132
|
+
return folder;
|
|
133
|
+
}
|
|
134
|
+
export async function prepareNativeRecovery(directory,{platform=process.platform}={}){
|
|
135
|
+
const provider=recoveryProvider(platform);
|
|
136
|
+
const folder=await recoveryFolder(directory,platform),token=randomBytes(32).toString("hex"),file=path.join(folder,token+".guard");
|
|
137
|
+
const bytes=Buffer.alloc(provider.guardBytes);bytes.write(provider.magic,0,"ascii");bytes[9]=255;bytes.write(token,14,"ascii");
|
|
138
|
+
const handle=await fs.open(file,"wx",0o600);
|
|
139
|
+
let complete=false;
|
|
140
|
+
try{
|
|
141
|
+
await handle.writeFile(bytes);await handle.sync();
|
|
142
|
+
if(platform==="linux"){const directoryHandle=await fs.open(folder,"r");try{await directoryHandle.sync();}finally{await directoryHandle.close();}}
|
|
143
|
+
complete=true;
|
|
144
|
+
}finally{await handle.close();if(!complete)await fs.unlink(file).catch(()=>{});}
|
|
145
|
+
// No launch until this descriptor is acknowledged in the atomic job journal.
|
|
146
|
+
return Object.freeze({protocol:provider.protocol,token});
|
|
147
|
+
}
|
|
148
|
+
async function guardPath(directory,recovery,platform=process.platform){
|
|
149
|
+
const provider=recoveryProvider(platform);
|
|
150
|
+
if(!validNativeRecovery(recovery)||recovery.protocol!==provider.protocol)throw err("full_invalid_job_recovery");
|
|
151
|
+
const file=path.join(await recoveryFolder(directory,platform),recovery.token+".guard"),stat=await fs.lstat(file);
|
|
152
|
+
if(!stat.isFile()||stat.isSymbolicLink()||stat.size!==provider.guardBytes||path.relative(file,await fs.realpath(file))!==""||
|
|
153
|
+
(platform==="linux"&&(stat.uid!==process.getuid()||(stat.mode&0o777)!==0o600)))throw err("full_invalid_job_recovery");
|
|
154
|
+
return file;
|
|
155
|
+
}
|
|
156
|
+
async function discardNativeRecovery(directory,recovery,platform){
|
|
157
|
+
try{await fs.unlink(await guardPath(directory,recovery,platform));}catch{/* retain uncertain evidence; never broad cleanup */}
|
|
158
|
+
}
|
|
159
|
+
export async function reconcileNativeJob(helper,directory,recovery,{platform=process.platform}={}){
|
|
160
|
+
try{
|
|
161
|
+
const provider=recoveryProvider(platform),file=await guardPath(directory,recovery,platform);
|
|
162
|
+
const {stdout}=await new Promise((resolve,reject)=>{
|
|
163
|
+
execFile(helper,["--reconcile",file],{env:nativeEnvironment(),windowsHide:true,encoding:"buffer",maxBuffer:1024,timeout:5000},(error,stdout,stderr)=>error?reject(error):resolve({stdout,stderr}));
|
|
164
|
+
});
|
|
165
|
+
if(stdout.length!==10||stdout.readUInt32LE(0)!==6||stdout[4]!==75||stdout[5]>provider.maxReason)return {treeStopped:false,reason:"outcome-unknown"};
|
|
166
|
+
const reason=["exited","cancelled","timed-out","outcome-unknown"][stdout[5]];
|
|
167
|
+
return Object.freeze({...recovery,treeStopped:true,reason,...(reason==="outcome-unknown"?{}:{exitCode:stdout.readUInt32LE(6)})});
|
|
168
|
+
}catch{return Object.freeze({treeStopped:false,reason:"outcome-unknown"});}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export async function createNativeJobProvider({artifact,recoveryDirectory,platform=process.platform,arch=process.arch}){
|
|
172
|
+
const provider=nativeJobPlatform(platform);
|
|
173
|
+
if(!provider||!["x64","arm64"].includes(arch)||!artifact.capabilities.includes("full.jobs"))return null;
|
|
174
|
+
const helper=path.resolve(path.dirname(artifact.executablePath),"../../../../native",provider.helper);
|
|
175
|
+
let shell="/bin/sh";
|
|
176
|
+
if(platform==="win32"){
|
|
177
|
+
const systemRoot=process.env.SystemRoot??process.env.WINDIR;
|
|
178
|
+
if(!systemRoot||!path.isAbsolute(systemRoot))return null;
|
|
179
|
+
shell=path.join(systemRoot,"System32","WindowsPowerShell","v1.0","powershell.exe");
|
|
180
|
+
}
|
|
181
|
+
try{
|
|
182
|
+
const stat=await fs.lstat(helper);
|
|
183
|
+
if(!stat.isFile()||stat.isSymbolicLink()||path.relative(helper,await fs.realpath(helper))!=="")return null;
|
|
184
|
+
// Exercise the actual provider, not just executable presence. Restrictive
|
|
185
|
+
// parent jobs, disabled user namespaces or unavailable pidfd fail closed.
|
|
186
|
+
const probe=launchNativeJob(helper,process.execPath,["--eval","process.exit(0)"],{cwd:path.dirname(helper),timeoutMs:3000,platform});
|
|
187
|
+
const result=await probe.completion;
|
|
188
|
+
if(!result.treeStopped||result.reason!=="exited"||result.exitCode!==0)return null;
|
|
189
|
+
if(recoveryDirectory!==undefined)await recoveryFolder(recoveryDirectory,platform);
|
|
190
|
+
return Object.freeze({
|
|
191
|
+
containment:provider.containment,
|
|
192
|
+
prepare:recoveryDirectory?()=>prepareNativeRecovery(recoveryDirectory,{platform}):null,
|
|
193
|
+
recover:recoveryDirectory?recovery=>reconcileNativeJob(helper,recoveryDirectory,recovery,{platform}):null,
|
|
194
|
+
discard:recoveryDirectory?recovery=>discardNativeRecovery(recoveryDirectory,recovery,platform):null,
|
|
195
|
+
async launch(command,cwd,timeoutMs,recovery){
|
|
196
|
+
validateCommand(command);
|
|
197
|
+
// Windows uses an ASCII encoded envelope; POSIX argv carries the exact
|
|
198
|
+
// UTF-8 command once. Payload stdin is /dev/null in both providers.
|
|
199
|
+
const args=platform==="win32"?["-NoLogo","-NoProfile","-NonInteractive","-OutputFormat","Text","-Command",powerShellUtf8Script(command)]:["-c",command];
|
|
200
|
+
const recoveryFile=recovery?await guardPath(recoveryDirectory,recovery,platform):undefined;
|
|
201
|
+
return launchNativeJob(helper,shell,args,{cwd,timeoutMs,guardPath:recoveryFile,platform});
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}catch{return null;}
|
|
205
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import {constants} from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import {execFile} from "node:child_process";
|
|
5
|
+
import {promisify} from "node:util";
|
|
6
|
+
import {FullContractError} from "../packages/full-contracts/index.mjs";
|
|
7
|
+
|
|
8
|
+
const exec=promisify(execFile);
|
|
9
|
+
const MAX_FILES=100,MAX_GIT_BYTES=256*1024,MAX_FILE_BYTES=256*1024,MAX_DIFF_CHARS=12000,MAX_VIEW_BYTES=48000;
|
|
10
|
+
const ignoredDirectories=new Set([".git",".workspace",".relay-workspace-owner.json","node_modules",".gradle",".cache",".next","target","coverage"]);
|
|
11
|
+
const sensitive=/^(?:\.env(?:\.|$)|\.npmrc|\.pypirc|\.netrc|\.ssh|id_(?:rsa|ed25519|ecdsa)(?:\.|$)|(?:credentials?|secrets?|passwords?)(?:[._=-]|$))|\.(?:pem|key|p12|pfx|jks|keystore)$/i;
|
|
12
|
+
const require=(ok,code)=>{if(!ok)throw new FullContractError(code);};
|
|
13
|
+
const cancelled=signal=>require(!signal?.aborted,"full_cancelled_before_start");
|
|
14
|
+
const samePath=(a,b)=>process.platform==="win32"?a.toLowerCase()===b.toLowerCase():a===b;
|
|
15
|
+
const stamp=stat=>[stat.dev,stat.ino,stat.mode,stat.size,stat.mtimeNs,stat.ctimeNs].map(String).join(":");
|
|
16
|
+
const missing=error=>["ENOENT","ENOTDIR"].includes(error?.code);
|
|
17
|
+
|
|
18
|
+
/** A display policy, not an execution or general file-read API. */
|
|
19
|
+
export function presentationChangePath(relative){
|
|
20
|
+
if(typeof relative!=="string"||relative.length===0||relative.length>1024||relative.includes("\\")||/[\u0000-\u001f\u007f:]/.test(relative)||relative.startsWith("/"))return false;
|
|
21
|
+
return relative.split("/").every(part=>part&&part!=="."&&part!==".."&&!ignoredDirectories.has(part.toLowerCase())&&!sensitive.test(part)&&
|
|
22
|
+
!(process.platform==="win32"&&(/[. ]$/.test(part)||/^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(part))));
|
|
23
|
+
}
|
|
24
|
+
function parseStatus(raw){
|
|
25
|
+
const parts=raw.split("\0"),files=[];
|
|
26
|
+
let omitted=0;
|
|
27
|
+
for(let index=0;index<parts.length;index++){
|
|
28
|
+
const record=parts[index];if(!record)continue;
|
|
29
|
+
const xy=record.slice(0,2),name=record.slice(3);
|
|
30
|
+
const rename=/[RC]/.test(xy),previousPath=rename?parts[++index]:undefined;
|
|
31
|
+
if(record[2]!==" "||!presentationChangePath(name)||rename&&!presentationChangePath(previousPath)){omitted++;continue;}
|
|
32
|
+
const conflicted=xy.includes("U")||xy==="AA"||xy==="DD";
|
|
33
|
+
const status=conflicted?"conflicted":xy==="??"?"untracked":rename?"renamed":xy.includes("D")?"deleted":xy.includes("A")?"added":xy.includes("T")?"type-changed":"modified";
|
|
34
|
+
files.push({path:name,status,...(previousPath?{previousPath}:{}),additions:null,deletions:null,binary:null});
|
|
35
|
+
}
|
|
36
|
+
return {files,omitted};
|
|
37
|
+
}
|
|
38
|
+
function parseNumstat(raw){
|
|
39
|
+
const records=raw.split("\0"),counts=new Map();
|
|
40
|
+
for(let index=0;index<records.length;index++){
|
|
41
|
+
const record=records[index];if(!record)continue;
|
|
42
|
+
const match=/^(\d+|-)\t(\d+|-)\t(.*)$/s.exec(record);if(!match)continue;
|
|
43
|
+
let name=match[3];
|
|
44
|
+
if(name===""){index++;name=records[++index];}
|
|
45
|
+
if(!presentationChangePath(name))continue;
|
|
46
|
+
const binary=match[1]==="-"||match[2]==="-";
|
|
47
|
+
counts.set(name,{additions:binary?null:Number(match[1]),deletions:binary?null:Number(match[2]),binary});
|
|
48
|
+
}
|
|
49
|
+
return counts;
|
|
50
|
+
}
|
|
51
|
+
function bounded(value){
|
|
52
|
+
while(Buffer.byteLength(JSON.stringify(value))>MAX_VIEW_BYTES&&value.files?.length){value.files.pop();value.truncated=true;}
|
|
53
|
+
require(Buffer.byteLength(JSON.stringify(value))<=MAX_VIEW_BYTES,"full_response_too_large");
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Called only inside the existing Core workspace read admission, after current
|
|
59
|
+
* principal/ownership/allowed-root checks. No path or Git revision comes from
|
|
60
|
+
* the renderer except one validated relative path. Git cannot run filters,
|
|
61
|
+
* external diffs, hooks, fsmonitor, a pager, or an inherited Git environment.
|
|
62
|
+
*/
|
|
63
|
+
export async function readPresentationChanges({root,taskSessionId,workspaceId,relativePath,checkTarget,signal,redact=value=>value}){
|
|
64
|
+
const observedAt=new Date().toISOString();
|
|
65
|
+
const base={taskSessionId,workspaceId,source:"git-working-tree",observedAt,readOnly:true};
|
|
66
|
+
const unavailable=(reason,truncated=false)=>({...base,...(relativePath!==undefined?{relativePath,text:"",additions:null,deletions:null,binary:false}:{files:[]}),state:"unavailable",reason,truncated});
|
|
67
|
+
cancelled(signal);
|
|
68
|
+
require(typeof root==="string"&&path.isAbsolute(root)&&typeof checkTarget==="function","full_unauthorized");
|
|
69
|
+
require(relativePath===undefined||presentationChangePath(relativePath),"full_invalid_presentation_input");
|
|
70
|
+
const canonical=await fs.realpath(root);
|
|
71
|
+
require(samePath(canonical,root)&&await checkTarget(canonical),"full_unauthorized");
|
|
72
|
+
const environment=Object.fromEntries(Object.entries(process.env).filter(([key])=>!/^GIT_/i.test(key)));
|
|
73
|
+
const git=async(args,{allowMissingHead=false}={})=>{
|
|
74
|
+
cancelled(signal);
|
|
75
|
+
try{
|
|
76
|
+
const result=await exec("git",["--no-pager","--no-optional-locks","--literal-pathspecs","-C",root,
|
|
77
|
+
"-c","core.fsmonitor=false","-c","core.untrackedCache=false","-c","gc.auto=0","-c","core.hooksPath="+(process.platform==="win32"?"NUL":"/dev/null"),...args],
|
|
78
|
+
{encoding:"utf8",windowsHide:true,timeout:3000,maxBuffer:MAX_GIT_BYTES,signal,
|
|
79
|
+
env:{...environment,GIT_TERMINAL_PROMPT:"0",GIT_CONFIG_NOSYSTEM:"1"}});
|
|
80
|
+
cancelled(signal);return result.stdout;
|
|
81
|
+
}catch(error){cancelled(signal);if(allowMissingHead&&error.code===1)return null;throw error;}
|
|
82
|
+
};
|
|
83
|
+
const head=()=>git(["rev-parse","--verify","--quiet","HEAD"],{allowMissingHead:true});
|
|
84
|
+
async function locate(relative){
|
|
85
|
+
let current=root;
|
|
86
|
+
const parts=relative.split("/");
|
|
87
|
+
for(let index=0;index<parts.length;index++){
|
|
88
|
+
current=path.join(current,parts[index]);
|
|
89
|
+
let stat;
|
|
90
|
+
try{stat=await fs.lstat(current,{bigint:true});}
|
|
91
|
+
catch(error){if(missing(error))return {state:"missing"};throw error;}
|
|
92
|
+
if(stat.isSymbolicLink()||!samePath(await fs.realpath(current),current)||!await checkTarget(current))throw new FullContractError("full_unauthorized");
|
|
93
|
+
if(index<parts.length-1){if(!stat.isDirectory())return {state:"unsupported"};}
|
|
94
|
+
else return stat.isFile()?{state:"file",target:current,stat,stamp:stamp(stat)}:{state:"unsupported"};
|
|
95
|
+
}
|
|
96
|
+
return {state:"unsupported"};
|
|
97
|
+
}
|
|
98
|
+
async function newFile(found,relative){
|
|
99
|
+
if(found.state!=="file")return null;
|
|
100
|
+
if(found.stat.size>BigInt(MAX_FILE_BYTES))return {tooLarge:true};
|
|
101
|
+
const handle=await fs.open(found.target,constants.O_RDONLY|(constants.O_NOFOLLOW??0));
|
|
102
|
+
try{
|
|
103
|
+
const before=await handle.stat({bigint:true});
|
|
104
|
+
if(stamp(before)!==found.stamp||!before.isFile())return {changed:true};
|
|
105
|
+
const buffer=Buffer.alloc(Number(before.size)+1);
|
|
106
|
+
let used=0;
|
|
107
|
+
while(used<buffer.length){
|
|
108
|
+
cancelled(signal);
|
|
109
|
+
const {bytesRead}=await handle.read(buffer,used,buffer.length-used,used);
|
|
110
|
+
if(!bytesRead)break;used+=bytesRead;
|
|
111
|
+
}
|
|
112
|
+
if(stamp(await handle.stat({bigint:true}))!==found.stamp||BigInt(used)!==before.size)return {changed:true};
|
|
113
|
+
const bytes=buffer.subarray(0,used);
|
|
114
|
+
if(bytes.includes(0))return {binary:true};
|
|
115
|
+
let content;
|
|
116
|
+
try{content=new TextDecoder("utf-8",{fatal:true}).decode(bytes);}catch{return {binary:true};}
|
|
117
|
+
const lines=content?content.split("\n"):[];
|
|
118
|
+
const newline=content.endsWith("\n");if(newline)lines.pop();
|
|
119
|
+
const additions=lines.length;
|
|
120
|
+
return {additions,deletions:0,binary:false,text:"--- /dev/null\n+++ b/"+relative+"\n"+(additions?"@@ -0,0 +1,"+additions+" @@\n"+lines.map(line=>"+"+line).join("\n")+"\n"+(!newline?"\\n":""):"")};
|
|
121
|
+
}finally{await handle.close();}
|
|
122
|
+
}
|
|
123
|
+
try{
|
|
124
|
+
const top=(await git(["rev-parse","--show-toplevel"])).trim();
|
|
125
|
+
require(samePath(await fs.realpath(top),root),"full_unauthorized");
|
|
126
|
+
// status/diff may otherwise invoke clean/process drivers even when
|
|
127
|
+
// --no-ext-diff and --no-textconv are present. Custom filters are an
|
|
128
|
+
// explicit unsupported display case; monitoring must never execute them.
|
|
129
|
+
const filters=await git(["config","--null","--get-regexp","^filter\\..*\\.(clean|process)$"],{allowMissingHead:true});
|
|
130
|
+
if(filters&&filters.split("\0").some(record=>record.slice(record.indexOf("\n")+1).trim()))return unavailable("Diff preview is unavailable for repositories with custom Git filters.");
|
|
131
|
+
const observations=await Promise.allSettled([
|
|
132
|
+
git(["status","--porcelain=v1","-z","--untracked-files=all","--ignore-submodules=all"]),head()
|
|
133
|
+
]);
|
|
134
|
+
const failure=observations.find(result=>result.status==="rejected");if(failure)throw failure.reason;
|
|
135
|
+
const {files,omitted}=parseStatus(observations[0].value),baseline=observations[1].value;
|
|
136
|
+
if(relativePath===undefined){
|
|
137
|
+
let counts=new Map(),countsUnavailable=false;
|
|
138
|
+
if(baseline){
|
|
139
|
+
try{counts=parseNumstat(await git(["diff","--numstat","-z","--find-renames","--no-ext-diff","--no-textconv","--ignore-submodules=all",baseline.trim(),"--"]));}
|
|
140
|
+
catch(error){cancelled(signal);countsUnavailable=true;}
|
|
141
|
+
}
|
|
142
|
+
cancelled(signal);
|
|
143
|
+
require(samePath(await fs.realpath(root),root)&&await checkTarget(root),"full_unauthorized");
|
|
144
|
+
const candidates=files.slice(0,MAX_FILES),safe=[],locations=await Promise.allSettled(candidates.map(file=>locate(file.path)));
|
|
145
|
+
let inaccessible=0;
|
|
146
|
+
for(let index=0;index<candidates.length;index++){
|
|
147
|
+
if(locations[index].status==="rejected"){inaccessible++;continue;}
|
|
148
|
+
const file=candidates[index];safe.push({...file,...(file.status!=="conflicted"?counts.get(file.path):{})});
|
|
149
|
+
}
|
|
150
|
+
cancelled(signal);
|
|
151
|
+
return bounded({...base,state:"ready",files:safe,
|
|
152
|
+
truncated:files.length>MAX_FILES||omitted>0||inaccessible>0,omitted:omitted+inaccessible,countsUnavailable});
|
|
153
|
+
}
|
|
154
|
+
const selected=files.find(file=>file.path===relativePath);
|
|
155
|
+
if(!selected)return unavailable("File is no longer in the changed files list.");
|
|
156
|
+
if(selected.status==="conflicted")return unavailable("Resolve the merge conflict to view a single diff.");
|
|
157
|
+
const found=await locate(relativePath);
|
|
158
|
+
if(found.state==="unsupported")return unavailable("This file type has no text diff.");
|
|
159
|
+
if(selected.previousPath)await locate(selected.previousPath);
|
|
160
|
+
let result;
|
|
161
|
+
if(selected.status==="untracked"||!baseline)result=await newFile(found,relativePath);
|
|
162
|
+
else{
|
|
163
|
+
// Bounded numstat counts use the same HEAD/worktree comparison as the
|
|
164
|
+
// patch. The literal pathspec prevents option/glob interpretation.
|
|
165
|
+
const paths=[...(selected.previousPath?[selected.previousPath]:[]),relativePath];
|
|
166
|
+
const args=["--find-renames","--no-ext-diff","--no-textconv","--ignore-submodules=all",baseline.trim(),"--",...paths];
|
|
167
|
+
const compared=await Promise.allSettled([git(["diff","--numstat","-z",...args]),git(["diff","--no-color","--unified=3",...args])]);
|
|
168
|
+
const failed=compared.find(value=>value.status==="rejected");if(failed)throw failed.reason;
|
|
169
|
+
const counts=parseNumstat(compared[0].value).get(relativePath);
|
|
170
|
+
result={text:compared[1].value,additions:counts?.additions??null,deletions:counts?.deletions??null,binary:counts?.binary===true};
|
|
171
|
+
}
|
|
172
|
+
cancelled(signal);
|
|
173
|
+
const after=await locate(relativePath);
|
|
174
|
+
if(found.state!==after.state||found.stamp!==after.stamp||await head()!==baseline||result?.changed)return unavailable("Files changed while reading. Refresh to try again.");
|
|
175
|
+
require(samePath(await fs.realpath(root),root)&&await checkTarget(root),"full_unauthorized");
|
|
176
|
+
if(!result)return unavailable("File is no longer available.");
|
|
177
|
+
if(result.tooLarge)return unavailable("File exceeds the diff display limit.",true);
|
|
178
|
+
if(result.binary)return {...unavailable("Binary file. No text diff."),binary:true};
|
|
179
|
+
if(!result.text)return unavailable("No text difference from HEAD.");
|
|
180
|
+
// Redact before display truncation so credentials crossing the cut are
|
|
181
|
+
// treated as one source string; never persist raw source in presentation.
|
|
182
|
+
const safe=redact(result.text,result.text.length);
|
|
183
|
+
const text=safe.slice(0,MAX_DIFF_CHARS).toWellFormed();
|
|
184
|
+
return bounded({...base,relativePath,state:"ready",text,additions:result.additions,deletions:result.deletions,binary:false,truncated:safe.length>text.length});
|
|
185
|
+
}catch(error){
|
|
186
|
+
cancelled(signal);
|
|
187
|
+
if(error?.code==="full_unauthorized"||error?.code==="full_invalid_presentation_input")throw error;
|
|
188
|
+
const limited=error?.code==="ERR_CHILD_PROCESS_STDIO_MAXBUFFER";
|
|
189
|
+
return unavailable(limited?"Changes exceed the display limit.":"Changes are unavailable. Refresh to try again.",limited);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import {randomUUID} from "node:crypto";
|
|
2
|
+
import {performance} from "node:perf_hooks";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import {pathToFileURL} from "node:url";
|
|
5
|
+
import {DIAGNOSTICS_OPERATION,REMOTE_DIAGNOSTICS_OPERATIONS} from "../packages/full-contracts/remote-session.mjs";
|
|
6
|
+
|
|
7
|
+
const ID=/^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$/;
|
|
8
|
+
const count=value=>Number.isSafeInteger(value)&&value>=0?value:null;
|
|
9
|
+
const failureKind=code=>/unauthor|permission|scope|grant|denied/.test(code)?"authorization":
|
|
10
|
+
/invalid|too_large/.test(code)?"input":/conflict|stale|mismatch/.test(code)?"conflict":
|
|
11
|
+
/queue_full|capacity|pressure|limit/.test(code)?"capacity":/unavailable|not_ready|closed/.test(code)?"unavailable":
|
|
12
|
+
/job|process|launch|timeout/.test(code)?"execution":"unknown";
|
|
13
|
+
const keyFor=(principal,taskSessionId)=>JSON.stringify([principal.accountId,principal.agentId,taskSessionId]);
|
|
14
|
+
function boundSnapshot(value){
|
|
15
|
+
const bytes=()=>Buffer.byteLength(JSON.stringify(value));
|
|
16
|
+
let omitted=0;
|
|
17
|
+
while(bytes()>56000&&value.activity.events.length){value.activity.events.shift();omitted++;}
|
|
18
|
+
if(omitted){value.activity.gap=true;value.activity.omittedFromResponse=omitted;value.partial=true;}
|
|
19
|
+
for(const key of ["jobs","claims"]){
|
|
20
|
+
const summary=key==="jobs"?"jobSummary":"claimSummary";
|
|
21
|
+
if(value[summary])value[summary]={...value[summary]};
|
|
22
|
+
value[key]=[...(value[key]??[])];
|
|
23
|
+
while(bytes()>56000&&value[key].length){value[key].pop();if(value[summary])value[summary].omitted++;value.partial=true;}
|
|
24
|
+
}
|
|
25
|
+
value.blockers=[...(value.blockers??[])];
|
|
26
|
+
while(bytes()>56000&&value.blockers.length){value.blockers.pop();value.blockersOmitted=(value.blockersOmitted??0)+1;value.partial=true;}
|
|
27
|
+
if(value.task?.steps){
|
|
28
|
+
value.task={...value.task,steps:[...value.task.steps]};
|
|
29
|
+
while(bytes()>56000&&value.task.steps.length){value.task.steps.pop();value.task.stepsOmitted=(value.task.stepsOmitted??0)+1;value.partial=true;}
|
|
30
|
+
}
|
|
31
|
+
if(bytes()>56000)throw Object.assign(new Error("full_response_too_large"),{code:"full_response_too_large"});
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Local disposable diagnostic rings, scoped by authenticated identity. Only
|
|
36
|
+
// the existing host supplies authoritative state; this never writes a store.
|
|
37
|
+
export async function createRemoteDiagnostics({host,artifact,scheduler}){
|
|
38
|
+
if(!artifact.capabilities.includes("full.diagnostics")||!host.operations.includes(DIAGNOSTICS_OPERATION))return null;
|
|
39
|
+
const {createDiagnostics}=await import(pathToFileURL(path.resolve(path.dirname(artifact.executablePath),"../observability/diagnostics.mjs")).href);
|
|
40
|
+
const rings=new Map();
|
|
41
|
+
function entry(principal,taskSessionId){
|
|
42
|
+
const scope={accountId:principal.accountId,agentId:principal.agentId,taskSessionId};
|
|
43
|
+
const key=keyFor(principal,taskSessionId);
|
|
44
|
+
let e=rings.get(key);
|
|
45
|
+
if(e)rings.delete(key);
|
|
46
|
+
else {
|
|
47
|
+
while(rings.size>=16)rings.delete(rings.keys().next().value);
|
|
48
|
+
e={scope,sequence:0,costSequence:0,costs:[],ring:createDiagnostics({scope,capacity:32})};
|
|
49
|
+
}
|
|
50
|
+
rings.set(key,e);return e;
|
|
51
|
+
}
|
|
52
|
+
function completed(parsed,response,start,metadata={}){
|
|
53
|
+
if(REMOTE_DIAGNOSTICS_OPERATIONS.includes(parsed.operation)||parsed.operation==="full.session.delete")return;
|
|
54
|
+
const observedStart=performance.now();
|
|
55
|
+
const taskSessionId=parsed.input.taskSessionId??response.result?.session?.taskSessionId;
|
|
56
|
+
if(!taskSessionId)return;
|
|
57
|
+
// A successful host/broker operation authorizes this task. Denied attempts
|
|
58
|
+
// may only enter an already authorized own-task ring, never seed one from
|
|
59
|
+
// caller-supplied foreign/unknown task IDs.
|
|
60
|
+
if(!response.ok&&!rings.has(keyFor(parsed.principal,taskSessionId)))return;
|
|
61
|
+
const e=entry(parsed.principal,taskSessionId),mode=e.ring.modeStatus({principal:e.scope}).mode;
|
|
62
|
+
const durationMs=Math.max(0,performance.now()-start);
|
|
63
|
+
const jobId=response.result?.job?.jobId??response.result?.jobId;
|
|
64
|
+
const event={type:"tool.completed",requestId:ID.test(metadata.requestId??"")?metadata.requestId:randomUUID(),
|
|
65
|
+
producerEpoch:host.ownerEpoch,sequence:++e.sequence,taskSessionId,action:parsed.operation,ok:response.ok===true,
|
|
66
|
+
...(ID.test(jobId??"")?{jobId}:{}),...(response.ok?{}:{failure:failureKind(String(response.error??""))}),
|
|
67
|
+
durationMs,localMeasurement:{source:"monotonic-local",durationMs}};
|
|
68
|
+
if(mode!=="normal"){
|
|
69
|
+
event.requestBytes=count(metadata.requestBytes)??Buffer.byteLength(JSON.stringify(parsed.input));
|
|
70
|
+
event.responseBytes=count(metadata.responseBytes)??Buffer.byteLength(JSON.stringify(response));
|
|
71
|
+
const resources=scheduler?.fullAdmission?.snapshot({owner:e.scope});
|
|
72
|
+
event.active=resources?.claims.length??null;
|
|
73
|
+
// Global queue totals would reveal another account's workload; omit.
|
|
74
|
+
}
|
|
75
|
+
e.ring.ingest({principal:e.scope,events:[event]});
|
|
76
|
+
const measuredAt=performance.now();
|
|
77
|
+
e.costs[e.costSequence++%128]={at:measuredAt,ms:measuredAt-observedStart,mode};
|
|
78
|
+
}
|
|
79
|
+
function projection(e,cursor){
|
|
80
|
+
const view=e.ring.read({principal:e.scope,cursor}),now=performance.now();
|
|
81
|
+
const costs=e.costs.filter(value=>value.mode===view.mode&&now-value.at<900000).map(value=>value.ms).sort((a,b)=>a-b);
|
|
82
|
+
return {...view,instrumentation:{source:"core-monotonic-observer",scope:"last-128-observations-within-15-minutes",mode:view.mode,
|
|
83
|
+
samples:costs.length,eventProcessingP95Ms:costs.length?costs[Math.ceil(costs.length*0.95)-1]:null,
|
|
84
|
+
maxMs:costs.at(-1)??null,limitations:["Measures local synchronous projection work; excludes IPC, network, queue wait and snapshot export."]}};
|
|
85
|
+
}
|
|
86
|
+
async function authorize(invocation,parsed){
|
|
87
|
+
// Keep the original operation and exact principal scopes. The host parses
|
|
88
|
+
// the same contract and verifies account/agent/task ownership before the
|
|
89
|
+
// Core changes a capture mode or exposes any live projection.
|
|
90
|
+
if(!host.operations.includes(parsed.operation))throw Object.assign(new Error("full_capability_unavailable"),{code:"full_capability_unavailable"});
|
|
91
|
+
const state=await host.request(parsed.operation,invocation,{taskSessionId:parsed.input.taskSessionId,timeoutMs:10000});
|
|
92
|
+
return {state,e:entry(parsed.principal,parsed.input.taskSessionId)};
|
|
93
|
+
}
|
|
94
|
+
function live(e){
|
|
95
|
+
const resources=scheduler?.fullAdmission?.observeResources?.()??null;
|
|
96
|
+
const admission=scheduler?.fullAdmission?.snapshot({owner:e.scope});
|
|
97
|
+
return admission?{scope:"task",activeReservations:admission.claims.length,
|
|
98
|
+
quarantinedReservations:admission.claims.filter(c=>c.state==="quarantined").length,
|
|
99
|
+
agentRecoveryBlocked:admission.recoveryBlocked,agentPressure:admission.pressure,
|
|
100
|
+
resources}:null;
|
|
101
|
+
}
|
|
102
|
+
async function snapshot(invocation,parsed){
|
|
103
|
+
const {state,e}=await authorize(invocation,parsed);
|
|
104
|
+
return boundSnapshot({...state,live:live(e),activity:projection(e,parsed.input.cursor),limitations:[
|
|
105
|
+
"Activity is a bounded, disposable projection of authorized Full requests; it resets after restart or eviction.",
|
|
106
|
+
"Request completion is distinct from job completion. Durable job and claim states come from the session journal.",
|
|
107
|
+
"Failures before any successful task authorization are omitted. No raw command, output, error text or path is retained.",
|
|
108
|
+
"Shared resource samples describe the Core process and system, not a task or the complete managed process tree."
|
|
109
|
+
]});
|
|
110
|
+
}
|
|
111
|
+
async function configure(invocation,parsed){
|
|
112
|
+
const {e}=await authorize(invocation,parsed);
|
|
113
|
+
const mode=e.ring.setMode({principal:e.scope,mode:parsed.input.mode,durationMs:parsed.input.durationMs,confirmed:parsed.input.confirmed});
|
|
114
|
+
e.costSequence=0;e.costs=[];
|
|
115
|
+
return {...mode,taskSessionId:e.scope.taskSessionId,retention:"disposable-local-memory",resources:live(e)};
|
|
116
|
+
}
|
|
117
|
+
async function exportSnapshot(invocation,parsed){
|
|
118
|
+
const {state,e}=await authorize(invocation,parsed);
|
|
119
|
+
if(parsed.input.confirmed!==true)throw Object.assign(new Error("full_diagnostic_export_confirmation_required"),{code:"full_diagnostic_export_confirmation_required"});
|
|
120
|
+
// The explicit result contains scrubbed metadata only. It neither writes
|
|
121
|
+
// a file nor starts an upload; the caller decides whether to save it.
|
|
122
|
+
return {version:1,scope:{...e.scope},activity:projection(e),live:live(e),
|
|
123
|
+
authoritative:{revision:count(state.task?.revision),workspaceReady:state.gates?.workspaceReady===true,
|
|
124
|
+
unresolvedJobs:count(state.gates?.jobsUnresolved),unresolvedClaims:count(state.gates?.claimsUnresolved),
|
|
125
|
+
evidenceCount:count(state.gates?.recordedEvidence),qaStatus:"not-assessed"},
|
|
126
|
+
redaction:"allowlisted-identifiers-and-numeric-metadata",persistence:"none",automaticUpload:false};
|
|
127
|
+
}
|
|
128
|
+
return Object.freeze({completed,snapshot,configure,exportSnapshot,forgetSession:owner=>rings.delete(keyFor(owner,owner.taskSessionId)),close:()=>rings.clear()});
|
|
129
|
+
}
|