@christang/keel 5.229.0 → 5.229.1
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/.claude-plugin/plugin.json +1 -1
- package/assets/bootstrap/AGENTS.md +1 -1
- package/npm-shrinkwrap.json +5 -5
- package/package.json +1 -1
- package/plugins/keel/.claude-plugin/plugin.json +1 -1
- package/plugins/keel/.codex-plugin/plugin.json +1 -1
- package/scripts/test_codex_host.js +20 -2
- package/scripts/validation/common.py +2 -2
- package/src/core/codex-host.js +45 -23
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.229.
|
|
3
|
+
"version": "5.229.1",
|
|
4
4
|
"description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "TanglmChris",
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.229.
|
|
3
|
+
"version": "5.229.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@christang/keel",
|
|
9
|
-
"version": "5.229.
|
|
9
|
+
"version": "5.229.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@fission-ai/openspec": "^1.4.1"
|
|
@@ -999,9 +999,9 @@
|
|
|
999
999
|
}
|
|
1000
1000
|
},
|
|
1001
1001
|
"node_modules/zod": {
|
|
1002
|
-
"version": "4.
|
|
1003
|
-
"resolved": "https://registry.npmjs.org/zod/-/zod-4.
|
|
1004
|
-
"integrity": "sha512-
|
|
1002
|
+
"version": "4.6.7",
|
|
1003
|
+
"resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz",
|
|
1004
|
+
"integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==",
|
|
1005
1005
|
"license": "MIT",
|
|
1006
1006
|
"funding": {
|
|
1007
1007
|
"url": "https://github.com/sponsors/colinhacks"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.229.
|
|
3
|
+
"version": "5.229.1",
|
|
4
4
|
"description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "TanglmChris",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.229.
|
|
3
|
+
"version": "5.229.1",
|
|
4
4
|
"description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "TanglmChris",
|
|
@@ -10,8 +10,8 @@ const {spawn}=require('node:child_process');
|
|
|
10
10
|
const cli=path.resolve(__dirname,'../bin/keel.js');
|
|
11
11
|
function run(args,action="status"){return new Promise(resolve=>{const p=spawn(process.execPath,action==='tick'?[cli,'tick',...args]:[cli,'codex',action,...args]);let out='',err='';p.stdout.on('data',b=>out+=b);p.stderr.on('data',b=>err+=b);p.on('close',code=>resolve({code,out,err}));});}
|
|
12
12
|
test('managed CLI lifecycle, mailbox scheduling and frame boundaries',async()=>{
|
|
13
|
-
const dir=fs.mkdtempSync(path.join(os.tmpdir(),'keel-host-'));const sock=path.join(dir,'host.sock');const requests=[];const peers=[];let active=true,serial=0,uncertain=false,invalidHost=false,injectNotice=false;
|
|
14
|
-
const server=http.createServer();server.on('upgrade',(req,s)=>{peers.push(s);s.write('HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: '+crypto.createHash('sha1').update(req.headers['sec-websocket-key']+'258EAFA5-E914-47DA-95CA-C5AB0DC85B11').digest('base64')+'\r\n\r\n');let initialized=false;let buf=Buffer.alloc(0);s.on('data',chunk=>{buf=Buffer.concat([buf,chunk]);while(buf.length>=6){let n=buf[1]&127,off=2;if(n===126){if(buf.length<8)return;n=buf.readUInt16BE(2);off=4;}else if(n===127){if(buf.length<14)return;n=Number(buf.readBigUInt64BE(2));off=10;}if(buf.length<off+4+n)return;const mask=buf.subarray(off,off+4);const data=Buffer.from(buf.subarray(off+4,off+4+n));buf=buf.subarray(off+4+n);for(let i=0;i<data.length;i++)data[i]^=mask[i%4];const x=JSON.parse(data);requests.push(x.method);if(x.method==='initialized'){initialized=true;continue;}if(!x.id)continue;if(x.method!=='initialize'&&!initialized){s.destroy();return;}const result=x.method==='initialize'?(invalidHost?{}:{userAgent:'test-host'}):x.method==='turn/start'?{turn:uncertain?{}:{id:'turn-fixture'}}:{thread:{id:x.method==='thread/start'?`fixture-thread-${++serial}`:(x.params.threadId||'fixture-thread'),status:{type:active?'active':'idle'},cwd:dir}};const b=Buffer.from(JSON.stringify({id:x.id,result}));const h=b.length<126?Buffer.from([129,b.length]):Buffer.from([129,126,b.length>>8,b.length&255]);const split=Math.floor(b.length/2);const frame=(op,body)=>Buffer.concat([body.length<126?Buffer.from([op,body.length]):Buffer.from([op,126,body.length>>8,body.length&255]),body]);if(injectNotice){const notice=Buffer.from(JSON.stringify({id:x.id,method:'server/notice',params:{}}));s.write(frame(129,notice));}s.write(Buffer.concat([frame(1,b.subarray(0,split)),frame(128,b.subarray(split))]));}});});
|
|
13
|
+
const dir=fs.mkdtempSync(path.join(os.tmpdir(),'keel-host-'));const sock=path.join(dir,'host.sock');const requests=[];const requestDetails=[];const peers=[];let active=true,serial=0,uncertain=false,invalidHost=false,injectNotice=false,unloaded=false,resumeActive=false,resumeFails=false,resumeMismatch=false,readMismatch=false,resumeDelay=false;
|
|
14
|
+
const server=http.createServer();server.on('upgrade',(req,s)=>{peers.push(s);s.write('HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: '+crypto.createHash('sha1').update(req.headers['sec-websocket-key']+'258EAFA5-E914-47DA-95CA-C5AB0DC85B11').digest('base64')+'\r\n\r\n');let initialized=false;let buf=Buffer.alloc(0);s.on('data',chunk=>{buf=Buffer.concat([buf,chunk]);while(buf.length>=6){let n=buf[1]&127,off=2;if(n===126){if(buf.length<8)return;n=buf.readUInt16BE(2);off=4;}else if(n===127){if(buf.length<14)return;n=Number(buf.readBigUInt64BE(2));off=10;}if(buf.length<off+4+n)return;const mask=buf.subarray(off,off+4);const data=Buffer.from(buf.subarray(off+4,off+4+n));buf=buf.subarray(off+4+n);for(let i=0;i<data.length;i++)data[i]^=mask[i%4];const x=JSON.parse(data);requests.push(x.method);requestDetails.push(x);if(x.method==='initialized'){initialized=true;continue;}if(!x.id)continue;if(x.method!=='initialize'&&!initialized){s.destroy();return;}if(x.method==='thread/resume'){if(resumeFails){const b=Buffer.from(JSON.stringify({id:x.id,error:{message:'fixture resume failure'}}));s.write(Buffer.concat([Buffer.from([129,b.length]),b]));continue;}unloaded=false;if(resumeActive)active=true;}const result=x.method==='initialize'?(invalidHost?{}:{userAgent:'test-host'}):x.method==='turn/start'?{turn:uncertain?{}:{id:'turn-fixture'}}:{thread:{id:x.method==='thread/start'?`fixture-thread-${++serial}`:(x.params.threadId||'fixture-thread'),status:{type:unloaded?'notLoaded':active?'active':'idle'},cwd:readMismatch||(x.method==='thread/resume'&&resumeMismatch)?'/wrong-worktree':dir}};const b=Buffer.from(JSON.stringify({id:x.id,result}));const h=b.length<126?Buffer.from([129,b.length]):Buffer.from([129,126,b.length>>8,b.length&255]);const split=Math.floor(b.length/2);const frame=(op,body)=>Buffer.concat([body.length<126?Buffer.from([op,body.length]):Buffer.from([op,126,body.length>>8,body.length&255]),body]);if(injectNotice){const notice=Buffer.from(JSON.stringify({id:x.id,method:'server/notice',params:{}}));s.write(frame(129,notice));}const reply=()=>{if(!s.destroyed)s.write(Buffer.concat([frame(1,b.subarray(0,split)),frame(128,b.subarray(split))]));};if(resumeDelay&&x.method==='thread/resume')setTimeout(reply,5500).unref();else reply();}});});
|
|
15
15
|
await new Promise(r=>server.listen(sock,r));
|
|
16
16
|
try{const x=await run(['--socket',sock,'--thread','fixture-thread','--json']);assert.equal(x.code,0,x.err);assert.equal(JSON.parse(x.out).thread.status.type,'active');assert.deepEqual(requests.filter(x=>x!=='initialized'),['initialize','thread/read']);
|
|
17
17
|
active=false;const {spawnSync}=require('node:child_process');spawnSync('git',['init','-q',dir]);
|
|
@@ -43,6 +43,24 @@ test('managed CLI lifecycle, mailbox scheduling and frame boundaries',async()=>{
|
|
|
43
43
|
|
|
44
44
|
uncertain=false;const large=await run(['--repo',dir,'--role','test-role','--record','large-record','--text','x'.repeat(70000),'--json'],'deliver');assert.equal(large.code,0,large.err);
|
|
45
45
|
const raceBefore=requests.filter(x=>x==='turn/start').length;const raceArgs=['--repo',dir,'--role','test-role','--record','concurrent-record','--text','concurrent fixture','--json'];const raced=await Promise.all([run(raceArgs,'deliver'),run(raceArgs,'deliver')]);assert.ok(raced.some(x=>x.code===0));assert.equal(requests.filter(x=>x==='turn/start').length,raceBefore+1);
|
|
46
|
+
// An unloaded owned thread is not an unrelated desktop session.
|
|
47
|
+
const recoveryArgs=record=>['--repo',dir,'--role','test-role','--record',record,'--text','recovery round','--json'];
|
|
48
|
+
const resumes=()=>requests.filter(x=>x==='thread/resume').length;
|
|
49
|
+
const turns=()=>requests.filter(x=>x==='turn/start').length;
|
|
50
|
+
unloaded=true;let rb=resumes(),tb=turns();
|
|
51
|
+
const unloadedDuplicate=await run(recoveryArgs('large-record'),'deliver');assert.equal(unloadedDuplicate.code,0,unloadedDuplicate.err);assert.equal(JSON.parse(unloadedDuplicate.out).state,'already-delivered');assert.equal(resumes(),rb);assert.equal(turns(),tb);
|
|
52
|
+
const recovered=await run(recoveryArgs('recovery-record'),'deliver');assert.equal(recovered.code,0,recovered.err);assert.equal(JSON.parse(recovered.out).state,'delivered');assert.equal(resumes(),rb+1);assert.equal(turns(),tb+1);assert.equal(serial,2);
|
|
53
|
+
const resumeRequest=requestDetails.find(x=>x.method==='thread/resume');assert.deepEqual(resumeRequest.params,{threadId:'fixture-thread-2',serviceName:'keel'});
|
|
54
|
+
unloaded=true;rb=resumes();tb=turns();const recoveredDuplicate=await run(recoveryArgs('recovery-record'),'deliver');assert.equal(recoveredDuplicate.code,0,recoveredDuplicate.err);assert.equal(resumes(),rb);assert.equal(turns(),tb);
|
|
55
|
+
const unknown=await run(recoveryArgs('uncertain-record'),'deliver');assert.notEqual(unknown.code,0);assert.match(unknown.err,/unknown/);assert.equal(resumes(),rb);
|
|
56
|
+
resumeActive=true;const busyRecovery=await run(recoveryArgs('busy-recovery'),'deliver');assert.equal(busyRecovery.code,0,busyRecovery.err);assert.equal(JSON.parse(busyRecovery.out).state,'waiting');assert.equal(turns(),tb);resumeActive=false;active=false;
|
|
57
|
+
unloaded=true;resumeFails=true;const failedRecovery=await run(recoveryArgs('failed-recovery'),'deliver');assert.notEqual(failedRecovery.code,0);assert.match(failedRecovery.err,/fixture resume failure/);assert.equal(turns(),tb);resumeFails=false;
|
|
58
|
+
unloaded=true;resumeMismatch=true;const mismatchRecovery=await run(recoveryArgs('mismatch-recovery'),'deliver');assert.notEqual(mismatchRecovery.code,0);assert.match(mismatchRecovery.err,/identity/);assert.equal(turns(),tb);resumeMismatch=false;
|
|
59
|
+
unloaded=true;readMismatch=true;rb=resumes();const wrongRead=await run(recoveryArgs('wrong-read'),'deliver');assert.notEqual(wrongRead.code,0);assert.equal(resumes(),rb);readMismatch=false;
|
|
60
|
+
unloaded=true;resumeDelay=true;const slowResume=await run(recoveryArgs('cold-recovery'),'deliver');assert.equal(slowResume.code,0,slowResume.err);unloaded=true;const explicitDeadline=await run([...recoveryArgs('short-deadline'),'--timeout','100'],'deliver');assert.notEqual(explicitDeadline.code,0);assert.match(explicitDeadline.err,/thread\/resume timeout/);resumeDelay=false;unloaded=true;rb=resumes();tb=turns();
|
|
61
|
+
const wrongEndpoint=await run([...recoveryArgs('wrong-endpoint'),'--socket',path.join(dir,'other.sock')],'deliver');assert.notEqual(wrongEndpoint.code,0);assert.match(wrongEndpoint.err,/endpoint mismatch/);assert.equal(resumes(),rb);
|
|
62
|
+
const roleFile=path.join(dir,'.git/keel-chat/codex-roles/test-role.json'),savedRole=fs.readFileSync(roleFile);fs.unlinkSync(roleFile);const notOwned=await run(recoveryArgs('not-owned'),'deliver');assert.notEqual(notOwned.code,0);assert.equal(resumes(),rb);fs.writeFileSync(roleFile,savedRole);
|
|
63
|
+
const unloadedHandover=await run(['--repo',dir,'--role','test-role','--note','not an implicit resume'],'handover');assert.notEqual(unloadedHandover.code,0);assert.equal(resumes(),rb);assert.equal(serial,2);unloaded=false;
|
|
46
64
|
injectNotice=true;const notified=await run(['--socket',sock,'--json']);assert.equal(notified.code,0,notified.err);assert.equal(JSON.parse(notified.out).host.userAgent,'test-host');injectNotice=false;
|
|
47
65
|
invalidHost=true;const malformed=await run(['--socket',sock,'--json']);assert.notEqual(malformed.code,0);assert.match(malformed.err,/identity/i);invalidHost=false;
|
|
48
66
|
const bad=await run(['--socket',path.join(dir,'missing'),'--timeout','100']);assert.notEqual(bad.code,0);assert.match(bad.err,/connect|ENOENT/i);}finally{peers.forEach(s=>s.destroy());await new Promise(r=>server.close(r));fs.rmSync(dir,{recursive:true,force:true});}
|
|
@@ -35,10 +35,10 @@ os.environ["KEEL_UPDATE_CLAUDE"] = str(Path(tempfile.gettempdir()) / "keel-suite
|
|
|
35
35
|
os.environ["KEEL_UPDATE_CODEX"] = str(Path(tempfile.gettempdir()) / "keel-suite-has-no-codex")
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
PACKAGE_VERSION = "5.229.
|
|
38
|
+
PACKAGE_VERSION = "5.229.1"
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
PROTOCOL_VERSION = "5.229.
|
|
41
|
+
PROTOCOL_VERSION = "5.229.1"
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
|
package/src/core/codex-host.js
CHANGED
|
@@ -99,11 +99,11 @@ function connect(socketPath, timeout = 5000) {
|
|
|
99
99
|
socket.on('close', () => fail(Error('Codex host disconnected')));
|
|
100
100
|
opened = true;
|
|
101
101
|
resolve({
|
|
102
|
-
call(method, params) {
|
|
102
|
+
call(method, params, callTimeout = timeout) {
|
|
103
103
|
return new Promise((resolveCall, rejectCall) => {
|
|
104
104
|
if (closed) return rejectCall(Error('Codex host disconnected'));
|
|
105
105
|
const id = ++sequence;
|
|
106
|
-
const timer = setTimeout(() => fail(Error(`Codex ${method} timeout`)),
|
|
106
|
+
const timer = setTimeout(() => fail(Error(`Codex ${method} timeout`)), callTimeout);
|
|
107
107
|
pending.set(id, {resolve: resolveCall, reject: rejectCall, timer});
|
|
108
108
|
try {send(1, Buffer.from(JSON.stringify({id, method, params})));}
|
|
109
109
|
catch (error) {fail(error);}
|
|
@@ -127,6 +127,7 @@ async function run(args) {
|
|
|
127
127
|
if (!["status", "start", "deliver", "handover", "drain"].includes(action)) throw Error("Usage: keel codex status|start|deliver|handover|drain [--socket path] [--role name] [--repo path] [--thread id] [--timeout ms] [--json]");
|
|
128
128
|
const options = {socket: path.join(process.env.CODEX_HOME || path.join(os.homedir(), ".codex"), "app-server-control/app-server-control.sock"), timeout: 5000, repo: process.cwd()};
|
|
129
129
|
let explicitSocket = false;
|
|
130
|
+
let explicitTimeout = false;
|
|
130
131
|
while (args.length) {
|
|
131
132
|
const flag = args.shift();
|
|
132
133
|
if (flag === "--json") options.json = true;
|
|
@@ -135,6 +136,7 @@ async function run(args) {
|
|
|
135
136
|
if (!value || value.startsWith("--")) throw Error(`${flag} needs a value`);
|
|
136
137
|
options[flag.slice(2)] = value;
|
|
137
138
|
if (flag === "--socket") explicitSocket = true;
|
|
139
|
+
if (flag === "--timeout") explicitTimeout = true;
|
|
138
140
|
} else throw Error(`Unknown argument ${flag}`);
|
|
139
141
|
}
|
|
140
142
|
const ms = Number(options.timeout);
|
|
@@ -196,31 +198,51 @@ async function run(args) {
|
|
|
196
198
|
store.setRole(where, options.role);
|
|
197
199
|
Object.assign(result, entry);
|
|
198
200
|
} else if (["deliver", "handover"].includes(action)) {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
if (!
|
|
201
|
+
let thread = (await client.call("thread/read", {threadId: recorded.thread, includeTurns: false})).thread;
|
|
202
|
+
const owned = value => value && value.id === recorded.thread && value.cwd === recorded.worktree;
|
|
203
|
+
if (!owned(thread)) throw Error("managed role identity mismatch");
|
|
202
204
|
const claims = recorded.deliveries || {};
|
|
203
205
|
const key = options.record ? crypto.createHash("sha256").update(options.record).digest("hex") : null;
|
|
204
206
|
if (action === "deliver" && claims[key]) {
|
|
205
|
-
|
|
207
|
+
// Deduplication is a recorded outcome, not a reason to load a thread.
|
|
208
|
+
if (claims[key].state !== "delivered" || typeof claims[key].turn !== "string" || !claims[key].turn) {
|
|
209
|
+
throw Error("delivery outcome unknown; claim retained, no retry started");
|
|
210
|
+
}
|
|
206
211
|
Object.assign(result, {state: "already-delivered", turn: claims[key].turn});
|
|
207
|
-
} else if (thread.status.type === "active") {
|
|
208
|
-
Object.assign(result, {state: "waiting", thread: recorded.thread});
|
|
209
|
-
} else if (action === "deliver") {
|
|
210
|
-
claims[key] = {record: options.record, state: "pending"};
|
|
211
|
-
recorded.deliveries = claims; store.writeJsonAtomic(where, file, recorded);
|
|
212
|
-
const turn = (await client.call("turn/start", {threadId: recorded.thread, input: [{type: "text", text: (recorded.note ? `Handover note (context only):\n${recorded.note}\n\n` : "") + options.text}]})).turn;
|
|
213
|
-
if (!turn || !turn.id) throw Error("Codex returned no turn identity; claim retained");
|
|
214
|
-
claims[key] = {record: options.record, state: "delivered", turn: turn.id};
|
|
215
|
-
store.writeJsonAtomic(where, file, recorded); Object.assign(result, {state: "delivered", turn: turn.id});
|
|
216
212
|
} else {
|
|
217
|
-
if (
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
213
|
+
if (action === "deliver" && thread.status && thread.status.type === "notLoaded") {
|
|
214
|
+
// Only this recorded owned identity may be loaded. Keep this same
|
|
215
|
+
// connection alive through the subsequent turn/start and preserve
|
|
216
|
+
// the thread's saved permissions rather than overriding them.
|
|
217
|
+
thread = (await client.call("thread/resume", {threadId: recorded.thread, serviceName: "keel"}, explicitTimeout ? ms : Math.max(ms, 15000))).thread;
|
|
218
|
+
if (!owned(thread)) throw Error("resumed managed role identity mismatch");
|
|
219
|
+
}
|
|
220
|
+
if (!thread.status || !["idle", "active"].includes(thread.status.type)) {
|
|
221
|
+
throw Error("managed role state is not verified idle or active; no work started");
|
|
222
|
+
}
|
|
223
|
+
if (thread.status.type === "active") {
|
|
224
|
+
Object.assign(result, {state: "waiting", thread: recorded.thread});
|
|
225
|
+
} else if (action === "deliver") {
|
|
226
|
+
claims[key] = {record: options.record, state: "pending"};
|
|
227
|
+
recorded.deliveries = claims;
|
|
228
|
+
store.writeJsonAtomic(where, file, recorded);
|
|
229
|
+
const turn = (await client.call("turn/start", {threadId: recorded.thread, input: [{type: "text", text: (recorded.note ? `Handover note (context only):\n${recorded.note}\n\n` : "") + options.text}]})).turn;
|
|
230
|
+
if (!turn || !turn.id) throw Error("Codex returned no turn identity; claim retained");
|
|
231
|
+
claims[key] = {record: options.record, state: "delivered", turn: turn.id};
|
|
232
|
+
store.writeJsonAtomic(where, file, recorded);
|
|
233
|
+
Object.assign(result, {state: "delivered", turn: turn.id});
|
|
234
|
+
} else {
|
|
235
|
+
if (recorded.handover) throw Error("handover outcome unknown; no successor started");
|
|
236
|
+
recorded.handover = {state: "pending", note: options.note};
|
|
237
|
+
store.writeJsonAtomic(where, file, recorded);
|
|
238
|
+
const next = (await client.call("thread/start", {cwd: recorded.worktree, sandbox: "workspace-write", approvalPolicy: "on-request", serviceName: "keel"})).thread;
|
|
239
|
+
if (!next || !next.id || next.cwd !== recorded.worktree) throw Error("successor identity mismatch; handover retained");
|
|
240
|
+
const history = [...(recorded.history || []), {thread: recorded.thread, note: options.note}];
|
|
241
|
+
delete recorded.handover;
|
|
242
|
+
Object.assign(recorded, {thread: next.id, history, note: options.note});
|
|
243
|
+
store.writeJsonAtomic(where, file, recorded);
|
|
244
|
+
Object.assign(result, {state: "handed-over", thread: next.id, note: options.note});
|
|
245
|
+
}
|
|
224
246
|
}
|
|
225
247
|
} else if (options.thread) {
|
|
226
248
|
result.thread = (await client.call("thread/read", {threadId: options.thread, includeTurns: false})).thread;
|
|
@@ -263,7 +285,7 @@ function wakeManaged(where, onlyRole = null) {
|
|
|
263
285
|
const child = require('node:child_process').spawnSync(process.execPath, [
|
|
264
286
|
path.resolve(__dirname, '../../bin/keel.js'), 'codex', 'deliver',
|
|
265
287
|
'--repo', entry.worktree, '--role', role, '--record', record.id, '--text', prompt, '--json',
|
|
266
|
-
], {encoding: 'utf8', timeout:
|
|
288
|
+
], {encoding: 'utf8', timeout: 40000});
|
|
267
289
|
let result;
|
|
268
290
|
try {result = JSON.parse(child.stdout);} catch {result = {};}
|
|
269
291
|
if (child.error || child.status !== 0) result.error = child.error ? child.error.message : child.stderr.trim();
|