webhelm 1.0.49 → 1.0.50
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webhelm",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.50",
|
|
4
4
|
"description": "Agent browser automation in a visible managed Chrome with persistent JavaScript sessions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -12,13 +12,15 @@
|
|
|
12
12
|
"files": [
|
|
13
13
|
"bin/",
|
|
14
14
|
"runtime/",
|
|
15
|
+
"scripts/chatgpt-three-mvps.mjs",
|
|
15
16
|
"README.md",
|
|
16
17
|
"PRIVACY.md"
|
|
17
18
|
],
|
|
18
19
|
"scripts": {
|
|
19
20
|
"test": "node --test test/node/*.test.mjs test/workspace-manager.test.mjs test/skill/*.test.mjs",
|
|
20
21
|
"test:package": "npm pack --dry-run --json",
|
|
21
|
-
"test:e2e:extension": "node test/e2e/extension-control.e2e.mjs"
|
|
22
|
+
"test:e2e:extension": "node test/e2e/extension-control.e2e.mjs",
|
|
23
|
+
"test:e2e:chatgpt-mvps": "node scripts/chatgpt-three-mvps.mjs"
|
|
22
24
|
},
|
|
23
25
|
"license": "MIT",
|
|
24
26
|
"repository": {
|
package/runtime/actions-repo.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import os from 'node:os';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
import {fileURLToPath} from 'node:url';
|
|
4
5
|
import { execFile } from 'node:child_process';
|
|
5
6
|
import { promisify } from 'node:util';
|
|
6
7
|
const run = promisify(execFile);
|
|
@@ -10,6 +11,19 @@ const REMOTE = process.env.WEBHELM_ACTIONS_REPO || 'https://github.com/lalalic/w
|
|
|
10
11
|
const options={timeout:90000,maxBuffer:1048576};
|
|
11
12
|
let initialSetup;
|
|
12
13
|
const git=(...args)=>run('git',args,options).then(r=>r.stdout.trim());
|
|
14
|
+
const realChatGPTMvpScript=fileURLToPath(new URL('../scripts/chatgpt-three-mvps.mjs',import.meta.url));
|
|
15
|
+
// Only site delivery changes trigger external four-message acceptance.
|
|
16
|
+
// Other site publishing must never touch a ChatGPT account.
|
|
17
|
+
export function needsChatGPTRealMvp(status) {
|
|
18
|
+
return String(status).split('\n').some(line=>{
|
|
19
|
+
const index=line.indexOf('platforms/chatgpt/');
|
|
20
|
+
if(index<0)return false;
|
|
21
|
+
const name=line.slice(index+'platforms/chatgpt/'.length);
|
|
22
|
+
return !name || name.startsWith('actions/') || name.startsWith('runtime/') ||
|
|
23
|
+
name.startsWith('queues/') || name==='manifest.yaml';
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
13
27
|
function verifyCheckout(){
|
|
14
28
|
if (!fs.existsSync(path.join(ACTIONS_DIR,'.git')) || !fs.existsSync(path.join(ACTIONS_DIR,'platforms')))
|
|
15
29
|
throw new Error(`Existing ${ACTIONS_DIR} is not a complete WebHelm Actions checkout; do not overwrite it`);
|
|
@@ -52,6 +66,25 @@ export async function publishActions(message){
|
|
|
52
66
|
if(!changed)throw Error('No platform action changes to publish');
|
|
53
67
|
// Run repository contract tests before creating a commit. These must not perform live writes.
|
|
54
68
|
await run('npm',['test'],{cwd:ACTIONS_DIR,...options});
|
|
69
|
+
// Real-browser ChatGPT release gate: run after offline tests and before
|
|
70
|
+
// creating/pushing a commit. The test cannot be silently bypassed by mocks
|
|
71
|
+
// or by the diagnostic --isolated-manual-queue option.
|
|
72
|
+
if(needsChatGPTRealMvp(changed)) {
|
|
73
|
+
if(process.env.WEBHELM_MVP_ALLOW_SEND!=='1')
|
|
74
|
+
throw Error('ChatGPT platform changes require 3 REAL MVPs before publish: set WEBHELM_MVP_ALLOW_SEND=1 (four test sends)');
|
|
75
|
+
if(!fs.existsSync(realChatGPTMvpScript))
|
|
76
|
+
throw Error('missing required ChatGPT 3-MVP script in WebHelm Runtime; publish blocked');
|
|
77
|
+
const before=await git('-C',ACTIONS_DIR,'status','--porcelain','--','platforms/chatgpt');
|
|
78
|
+
const proof=await run(process.execPath,[realChatGPTMvpScript],{
|
|
79
|
+
cwd:ACTIONS_DIR,env:process.env,timeout:300000,maxBuffer:1048576,
|
|
80
|
+
});
|
|
81
|
+
const verified=proof.stdout.split('\n').flatMap(line=>{
|
|
82
|
+
try{return [JSON.parse(line)];}catch{return [];}
|
|
83
|
+
}).find(item=>item.stage==='ALL_3_MVPS_PASS' && item.live_daemon_queue===true);
|
|
84
|
+
if(!verified)throw Error('3-MVP execution did not prove native live Daemon Queue FIFO; publish blocked');
|
|
85
|
+
const after=await git('-C',ACTIONS_DIR,'status','--porcelain','--','platforms/chatgpt');
|
|
86
|
+
if(before!==after)throw Error('ChatGPT files changed during real 3-MVP gate; rerun required');
|
|
87
|
+
}
|
|
55
88
|
await git('-C',ACTIONS_DIR,'add','--','platforms');
|
|
56
89
|
await git('-C',ACTIONS_DIR,'diff','--cached','--check');
|
|
57
90
|
await git('-C',ACTIONS_DIR,'commit','-m',message.trim());
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Mandatory real-browser ChatGPT Actions release gate. Makes four deliberate
|
|
3
|
+
// external sends (one new-thread, one direct new-turn, two queued new-turns).
|
|
4
|
+
// Never executes during npm test; requires explicit opt-in and a signed-in
|
|
5
|
+
// owned Chrome Session. Queue messages use a brand-new test thread only.
|
|
6
|
+
import assert from 'node:assert/strict';
|
|
7
|
+
import {randomUUID} from 'node:crypto';
|
|
8
|
+
import {existsSync,mkdtempSync,mkdirSync,writeFileSync,readFileSync,rmSync} from 'node:fs';
|
|
9
|
+
import {tmpdir,homedir} from 'node:os';
|
|
10
|
+
import {join,resolve} from 'node:path';
|
|
11
|
+
import {fileURLToPath,pathToFileURL} from 'node:url';
|
|
12
|
+
import {DatabaseSync} from 'node:sqlite';
|
|
13
|
+
import {request} from '../runtime/node-daemon.mjs';
|
|
14
|
+
import {PlatformDeliveryQueue} from '../runtime/platform-delivery-queue.mjs';
|
|
15
|
+
import {RUNTIME_DIR} from '../runtime/config-paths.mjs';
|
|
16
|
+
|
|
17
|
+
if(process.env.WEBHELM_MVP_ALLOW_SEND!=='1') {
|
|
18
|
+
throw Error('REAL ChatGPT send test: export WEBHELM_MVP_ALLOW_SEND=1 to authorize four test messages');
|
|
19
|
+
}
|
|
20
|
+
const isolatedManual=process.argv.includes('--isolated-manual-queue');
|
|
21
|
+
const actionsRoot=resolve(process.env.WEBHELM_PLATFORM_DIR || join(homedir(),'.local/webhelm/platforms'));
|
|
22
|
+
const evidenceDir=resolve(process.env.WEBHELM_MVP_EVIDENCE_DIR || join(tmpdir(),'webhelm-chatgpt-mvp-evidence'));
|
|
23
|
+
mkdirSync(evidenceDir,{recursive:true});
|
|
24
|
+
const tag=`WEBHELM_MVP_${Date.now().toString(36).toUpperCase()}_${randomUUID().slice(0,8).toUpperCase()}`;
|
|
25
|
+
const evidenceFile=join(evidenceDir,`${tag}.json`);
|
|
26
|
+
const sleep=ms=>new Promise(resolve=>setTimeout(resolve,ms));
|
|
27
|
+
const evidence={tag,mode:isolatedManual?'isolated-real-browser-queue':'live-daemon-queue',
|
|
28
|
+
started_at:new Date().toISOString(),checks:[],session_ids:[],mvp1:null,mvp2:null,mvp3:null,pass:false};
|
|
29
|
+
const record=(name,data={})=>{
|
|
30
|
+
evidence.checks.push({at:new Date().toISOString(),name,...data});
|
|
31
|
+
writeFileSync(evidenceFile,JSON.stringify(evidence,null,2),{mode:0o600});
|
|
32
|
+
console.log(JSON.stringify({stage:name,...data}));
|
|
33
|
+
};
|
|
34
|
+
async function ipc(op,args={}) {
|
|
35
|
+
const value=await request({op,...args});
|
|
36
|
+
if(value?.error) throw Error(`${op} failed: ${value.error}`);
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
async function sessions() {
|
|
40
|
+
return (await ipc('list')).sessions||[];
|
|
41
|
+
}
|
|
42
|
+
const existing=new Set((await sessions()).map(x=>x.session_id));
|
|
43
|
+
const initial=await ipc('ping');
|
|
44
|
+
record('preflight',{daemon_pid:initial.pid,daemon_version:initial.version,
|
|
45
|
+
existing_sessions:[...(await sessions())].map(x=>x.workspace),
|
|
46
|
+
source:'real Chrome, same signed-in profile'});
|
|
47
|
+
if(!isolatedManual) {
|
|
48
|
+
const expectedVersion=JSON.parse(readFileSync(new URL('../package.json',import.meta.url),'utf8')).version;
|
|
49
|
+
if(initial.version!==expectedVersion)
|
|
50
|
+
throw Error(`native Queue MVP requires active daemon version ${expectedVersion}; running ${initial.version}; no messages sent`);
|
|
51
|
+
const listed=await ipc('queue-list');
|
|
52
|
+
if((listed.items||[]).some(x=>!x.queue || !x.platform)) {
|
|
53
|
+
throw Error('native 3-MVP queue requires new generic daemon; old Queue detected; no messages sent');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
let sid=null,temporaryQueue=null,storeDir=null;
|
|
57
|
+
try {
|
|
58
|
+
const started=await ipc('start',{url:'https://chatgpt.com/',workspace:'WebHelm'});
|
|
59
|
+
sid=started.session_id;
|
|
60
|
+
assert.ok(sid,'failed to create owned real Chrome Session');
|
|
61
|
+
evidence.session_ids.push(sid);
|
|
62
|
+
record('session_started',{session_id:sid});
|
|
63
|
+
async function runDirect(action,config,session_id=sid) {
|
|
64
|
+
const value=await ipc('platform-run',{platform:'chatgpt',action,config,session_id,workspace:'WebHelm'});
|
|
65
|
+
const result=value?.result;
|
|
66
|
+
assert.equal(result?.ok,true,`${action} failed: ${JSON.stringify(result)}`);
|
|
67
|
+
assert.equal(result.value?.status,'submitted',`${action} missing submission receipt`);
|
|
68
|
+
return result.value;
|
|
69
|
+
}
|
|
70
|
+
const one=await runDirect('new-thread',{
|
|
71
|
+
message:`${tag}_MVP1_NEW_THREAD. This is an automated browser Actions acceptance test. Reply ${tag}_MVP1_ACK.`,
|
|
72
|
+
});
|
|
73
|
+
assert.ok(one.thread_id && one.thread_url,'new-thread must return a durable thread ID');
|
|
74
|
+
evidence.thread_id=one.thread_id;evidence.thread_url=one.thread_url;
|
|
75
|
+
evidence.mvp1={status:'PASS',thread_id:one.thread_id,verified_by:one.verified_by};
|
|
76
|
+
record('MVP1_PASS',evidence.mvp1);
|
|
77
|
+
const two=await runDirect('new-turn',{
|
|
78
|
+
thread_id:one.thread_id,
|
|
79
|
+
message:`${tag}_MVP2_DIRECT_TURN. Reply exactly ${tag}_MVP2_ACK.`,
|
|
80
|
+
});
|
|
81
|
+
assert.equal(two.thread_id,one.thread_id,'new-turn redirected to another thread');
|
|
82
|
+
assert.equal(two.verified_by,'send-clicked','new-turn must be confirmed by exactly one Send click');
|
|
83
|
+
evidence.mvp2={status:'PASS',thread_id:two.thread_id,verified_by:two.verified_by};
|
|
84
|
+
record('MVP2_PASS',evidence.mvp2);
|
|
85
|
+
await ipc('stop',{session_id:sid});
|
|
86
|
+
record('direct_session_released',{session_id:sid});
|
|
87
|
+
sid=null;
|
|
88
|
+
// Two distinct messages under one FIFO group; explicitly disable merge.
|
|
89
|
+
const payloads=['A','B'].map(suffix=>({
|
|
90
|
+
thread_id:one.thread_id,
|
|
91
|
+
message:`${tag}_MVP3_QUEUE_${suffix}. Reply exactly ${tag}_MVP3_${suffix}_ACK.`,
|
|
92
|
+
idempotency_key:`${tag}-mvp3-${suffix}`,mergeable:false,
|
|
93
|
+
}));
|
|
94
|
+
let enqueued;
|
|
95
|
+
if(isolatedManual) {
|
|
96
|
+
// This is the actual generic queue implementation (not a mocked worker)
|
|
97
|
+
// delivering through the existing real daemon. Isolated on a disposable
|
|
98
|
+
// SQLite database, never reading/claiming the old ChatGPT queue #281/#282.
|
|
99
|
+
// It is NOT a substitute for the live daemon queue-enqueue RPC cutover.
|
|
100
|
+
storeDir=mkdtempSync(join(tmpdir(),'webhelm-mvp-manual-'));
|
|
101
|
+
const policy=(await import(pathToFileURL(join(actionsRoot,'chatgpt/queues/new-turn.mjs')).href)).default;
|
|
102
|
+
temporaryQueue=new PlatformDeliveryQueue({platform:'chatgpt',queue:'new-turn',definition:policy,
|
|
103
|
+
persistenceRoot:storeDir,
|
|
104
|
+
startSession:async ({url,workspace})=>{
|
|
105
|
+
const session=await ipc('start',{url,workspace});
|
|
106
|
+
if(session.session_id)evidence.session_ids.push(session.session_id);
|
|
107
|
+
return session;
|
|
108
|
+
},
|
|
109
|
+
stopSession:async session_id=>ipc('stop',{session_id}),
|
|
110
|
+
runAction:async ({platform,action,config,session_id})=>ipc('platform-run',{
|
|
111
|
+
platform,action:action==='validate_new_turn_ready' ? 'validate-new-turn-ready' : action,
|
|
112
|
+
config,session_id,workspace:'WebHelm',
|
|
113
|
+
}),
|
|
114
|
+
});
|
|
115
|
+
enqueued=payloads.map(x=>temporaryQueue.enqueue(x));
|
|
116
|
+
} else {
|
|
117
|
+
enqueued=[];
|
|
118
|
+
for(const config of payloads) enqueued.push(await ipc('queue-enqueue',{
|
|
119
|
+
platform:'chatgpt',queue:'new-turn',config,
|
|
120
|
+
}));
|
|
121
|
+
}
|
|
122
|
+
assert.equal(new Set(enqueued.map(x=>x.queue_id)).size,2,'two requests must not merge');
|
|
123
|
+
for(const outcome of enqueued) {
|
|
124
|
+
assert.equal(outcome.group,one.thread_id,'both actions must have same FIFO group');
|
|
125
|
+
}
|
|
126
|
+
record('MVP3_QUEUED',{queue_ids:enqueued.map(x=>x.queue_id),group:one.thread_id});
|
|
127
|
+
const dbPath=isolatedManual?temporaryQueue.dbPath:join(
|
|
128
|
+
process.env.WEBHELM_RUNTIME_DIR||RUNTIME_DIR,'queues/chatgpt/new-turn.sqlite3');
|
|
129
|
+
const deadline=Date.now()+180000;
|
|
130
|
+
const states=new Map();
|
|
131
|
+
const claimed=[];
|
|
132
|
+
while(Date.now()<deadline) {
|
|
133
|
+
if(isolatedManual) {
|
|
134
|
+
const next=temporaryQueue.claim(`mvp-worker-${randomUUID()}`);
|
|
135
|
+
if(next) {
|
|
136
|
+
claimed.push(next.id);
|
|
137
|
+
await temporaryQueue.process(next);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const db=isolatedManual?temporaryQueue.db:new DatabaseSync(dbPath,{readOnly:true});
|
|
141
|
+
try {
|
|
142
|
+
for(const id of enqueued.map(x=>x.queue_id)) {
|
|
143
|
+
const row=db.prepare('SELECT id,seq,group_key,state,receipt,attempts FROM items WHERE id=?').get(id);
|
|
144
|
+
if(row) states.set(id,row);
|
|
145
|
+
}
|
|
146
|
+
} finally {if(!isolatedManual)db.close();}
|
|
147
|
+
const rows=enqueued.map(x=>states.get(x.queue_id));
|
|
148
|
+
if(rows.some(x=>x?.state==='FAILED'||x?.state==='CANCELLED')) throw Error('MVP3 queue failure: '+JSON.stringify(rows));
|
|
149
|
+
if(rows.every(x=>x?.state==='SENT')) break;
|
|
150
|
+
await sleep(2000);
|
|
151
|
+
}
|
|
152
|
+
const a=states.get(enqueued[0].queue_id),b=states.get(enqueued[1].queue_id);
|
|
153
|
+
assert.ok(a&&b,'missing persisted queue receipts');
|
|
154
|
+
assert.equal(a.group_key,one.thread_id);
|
|
155
|
+
assert.equal(b.group_key,one.thread_id);
|
|
156
|
+
assert.ok(a.seq<b.seq,'FIFO seq order reversed');
|
|
157
|
+
assert.equal(a.state,'SENT','queue item A was not sent');
|
|
158
|
+
assert.equal(b.state,'SENT','queue item B was not sent');
|
|
159
|
+
assert.equal(a.receipt,'send-clicked');
|
|
160
|
+
assert.equal(b.receipt,'send-clicked');
|
|
161
|
+
if(isolatedManual)assert.deepEqual(claimed,enqueued.map(x=>x.queue_id),'queue processing order violated');
|
|
162
|
+
evidence.mvp3={status:'PASS',same_thread:one.thread_id,queue_ids:enqueued.map(x=>x.queue_id),
|
|
163
|
+
states:[a.state,b.state],receipts:[a.receipt,b.receipt],
|
|
164
|
+
ordered_seq:[a.seq,b.seq],isolated_harness:isolatedManual};
|
|
165
|
+
record('MVP3_PASS',evidence.mvp3);
|
|
166
|
+
// Let any returned-to-idle queue Session disappear before claiming cleanup.
|
|
167
|
+
for(let i=0;i<10;i++) {
|
|
168
|
+
const remaining=(await sessions()).filter(x=>!existing.has(x.session_id));
|
|
169
|
+
if(!remaining.length) break;
|
|
170
|
+
await sleep(1000);
|
|
171
|
+
}
|
|
172
|
+
const leftovers=(await sessions()).filter(x=>!existing.has(x.session_id));
|
|
173
|
+
assert.equal(leftovers.length,0,'owned Sessions not cleaned: '+JSON.stringify(leftovers));
|
|
174
|
+
evidence.pass=true;
|
|
175
|
+
record('ALL_3_MVPS_PASS',{thread_url:evidence.thread_url,real_browser:true,
|
|
176
|
+
live_daemon_queue:!isolatedManual});
|
|
177
|
+
} catch(error) {
|
|
178
|
+
evidence.error=String(error);
|
|
179
|
+
record('MVP_FAILED',{error:String(error)});
|
|
180
|
+
process.exitCode=1;
|
|
181
|
+
} finally {
|
|
182
|
+
if(sid) {
|
|
183
|
+
try {await ipc('stop',{session_id:sid});record('finally_stopped_session',{session_id:sid});}
|
|
184
|
+
catch(error) {record('session_release_error',{error:String(error)});process.exitCode=1;}
|
|
185
|
+
}
|
|
186
|
+
if(temporaryQueue) {
|
|
187
|
+
await temporaryQueue.shutdown();
|
|
188
|
+
// Store only sanitized evidence outside the repository, never prompts.
|
|
189
|
+
if(storeDir)rmSync(storeDir,{recursive:true,force:true});
|
|
190
|
+
}
|
|
191
|
+
record('finish',{pass:evidence.pass,evidence_file:evidenceFile});
|
|
192
|
+
}
|