@tomflow/chatloop-tools 0.9.50 → 0.9.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.mjs +1 -1
- package/lib/control.mjs +4 -1
- package/lib/supervisor-runtime.mjs +2 -1
- package/node_modules/@tomflow/chatloop-context/lib/core/run.mjs +3 -1
- package/node_modules/@tomflow/chatloop-context/lib/orphan-operator.mjs +2 -1
- package/node_modules/@tomflow/chatloop-context/package.json +2 -2
- package/node_modules/@tomflow/chatloop-extension/extension/loop/core.js +1 -1
- package/node_modules/@tomflow/chatloop-extension/extension/manifest.json +1 -1
- package/node_modules/@tomflow/chatloop-extension/extension/worker/adopt-prepare.js +11 -3
- package/node_modules/@tomflow/chatloop-extension/lib/owner-evidence.mjs +6 -2
- package/node_modules/@tomflow/chatloop-extension/lib/session-file.mjs +3 -1
- package/node_modules/@tomflow/chatloop-extension/package.json +1 -1
- package/package.json +3 -3
package/index.mjs
CHANGED
|
@@ -253,7 +253,7 @@ async function runtime(){
|
|
|
253
253
|
phase:event.phase,
|
|
254
254
|
...(event.durationMs!==null?{durationMs:event.durationMs}:{}),
|
|
255
255
|
...(event.errorCode?{errorCode:event.errorCode}:{})
|
|
256
|
-
},
|
|
256
|
+
},3000).then(reply=>{
|
|
257
257
|
// A transport ACK is not proof that the Writer persisted this span.
|
|
258
258
|
if(reply?.status!=='OK'||!OBSERVER_UUID.test(reply.eventId||'')){
|
|
259
259
|
const code=/^[A-Z][A-Z0-9_]{1,95}$/.test(reply?.error?.code||'')
|
package/lib/control.mjs
CHANGED
|
@@ -100,7 +100,10 @@ const verifiedBusinessReply=(reply,request)=>{
|
|
|
100
100
|
return reply;
|
|
101
101
|
};
|
|
102
102
|
export async function talk(request,timeout=12000){
|
|
103
|
-
|
|
103
|
+
// The owner handshake is still required for every IPC call. Only skip the
|
|
104
|
+
// unrelated Writer health snapshot: telemetry calls already have their own
|
|
105
|
+
// persisted receipt and health is queried explicitly via __trace_health.
|
|
106
|
+
const hello=await send({action:'__ping',omitTraceHealth:true},1200);
|
|
104
107
|
if(hello.contract!==CONTRACT||hello.version!==VERSION||hello.packageVersion!==PACKAGE_VERSION||
|
|
105
108
|
hello.registrySignature!==registry().map(t=>t.id+':'+t.enabled).join('|'))
|
|
106
109
|
throw Object.assign(new Error('Version or registry mismatch'),{code:'INCOMPATIBLE_VERSION'});
|
|
@@ -293,7 +293,8 @@ async function main(){
|
|
|
293
293
|
let work;
|
|
294
294
|
try{work=req?.action==='__ping'?
|
|
295
295
|
Promise.resolve({contract:CONTRACT,version:VERSION,packageVersion:PACKAGE_VERSION,registrySignature:catalog.map(t=>t.id+':'+t.enabled).join('|'),ownerNonce:nonce,
|
|
296
|
-
managerPid:process.pid,
|
|
296
|
+
managerPid:process.pid,
|
|
297
|
+
...(req.omitTraceHealth===true?{}:{traceHealth:traceHealth()})}):req?.action==='__trace_health'
|
|
297
298
|
?Promise.resolve(req.contract===CONTRACT
|
|
298
299
|
&&REQUEST_ID.test(req.requestId||'')
|
|
299
300
|
?{contract:CONTRACT,requestId:req.requestId,
|
|
@@ -167,7 +167,8 @@ export function createRunMethods(values) {
|
|
|
167
167
|
assert(typeof a.nativeSessionId==='string'
|
|
168
168
|
&&a.nativeSessionId!==a.oldSessionId
|
|
169
169
|
&&typeof a.nativeProjectId==='string'
|
|
170
|
-
&&a.nativeProjectId!==a.projectId
|
|
170
|
+
&&(a.nativeProjectId!==a.projectId
|
|
171
|
+
||typeof a.nativeTaskId==='string'&&a.nativeTaskId!==a.taskId)
|
|
171
172
|
&&a.nativePhase==='DONE'
|
|
172
173
|
&&Number.isSafeInteger(a.nativeUpdatedAt),
|
|
173
174
|
'ORPHAN_NATIVE_NOT_TERMINAL');
|
|
@@ -194,6 +195,7 @@ export function createRunMethods(values) {
|
|
|
194
195
|
const orphanRef={runRef:a.expectedRunRef,oldSessionId:a.oldSessionId,
|
|
195
196
|
currentNativeSessionId:a.nativeSessionId,
|
|
196
197
|
currentNativeProjectId:a.nativeProjectId,
|
|
198
|
+
currentNativeTaskId:a.nativeTaskId??null,
|
|
197
199
|
currentNativeUpdatedAt:a.nativeUpdatedAt,
|
|
198
200
|
evidenceDocumentId:a.evidenceDocumentId,
|
|
199
201
|
evidenceVersion:a.evidenceVersion,evidenceHash:a.evidenceHash,
|
|
@@ -100,7 +100,8 @@ export async function fenceOrphanRunOperator({
|
|
|
100
100
|
expectedRunRef,expectedTaskRevision,expectedBindingRevision,
|
|
101
101
|
expectedStoreEpoch,evidenceDocumentId,evidenceVersion,evidenceHash,
|
|
102
102
|
nativeSessionId:last.sessionId,nativeProjectId:last.projectId,
|
|
103
|
-
|
|
103
|
+
nativeTaskId:last.taskId,nativePhase:last.phase,
|
|
104
|
+
nativeUpdatedAt:last.updatedAt,writeRequestId});
|
|
104
105
|
const checked=db.get(projectId,taskId);
|
|
105
106
|
assert(checked.runRef===null
|
|
106
107
|
&&checked.bindingRevision===result.bindingRevision
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomflow/chatloop-context",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Independent local Context SDK and short-lived CLI for Chat Loop projects",
|
|
6
6
|
"publishConfig": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"ps-list": "9.0.0",
|
|
37
|
-
"@tomflow/chatloop-extension": "0.4.
|
|
37
|
+
"@tomflow/chatloop-extension": "0.4.22",
|
|
38
38
|
"@tomflow/chatloop-trace": "0.4.6"
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
||proof.status!=='VERIFIED'
|
|
81
81
|
||typeof proof.page!=='string'
|
|
82
82
|
||pathOf('https://chatgpt.com'+proof.page)!==proof.page
|
|
83
|
-
||!/^user:[
|
|
83
|
+
||!/^user:[^\s]{8,}$/.test(proof.userKey||'')
|
|
84
84
|
||!/^R[1-9][0-9]*$/.test(proof.rVersion||'')
|
|
85
85
|
||!/^P[1-9][0-9]*$/.test(proof.pVersion||''))
|
|
86
86
|
return null;
|
|
@@ -41,8 +41,14 @@ async function sessionStartPrepare(message,sender){
|
|
|
41
41
|
|| prior.phase==='DONE'&&!terminalFenceVerified(prior)))
|
|
42
42
|
return {status:'DENIED',code:'CONTEXT_TERMINAL_FENCE_UNVERIFIED'};
|
|
43
43
|
const replace=intent.replaceBlockedSessionId||null;
|
|
44
|
+
// Project is shared context, not Task identity. Same-Project replacement
|
|
45
|
+
// requires a freshly approved, Context-backed Adopt into a distinct Task.
|
|
46
|
+
// Legacy sessions without taskId can only yield to that verified new Task.
|
|
47
|
+
const independentTask=Boolean(intent.mode==='adopt'&&intent.contextLeaseRef
|
|
48
|
+
&&intent.taskId && (!prior?.taskId && !prior?.contextManaged
|
|
49
|
+
||prior?.taskId&&prior.taskId!==intent.taskId));
|
|
44
50
|
const matchingBlocked=prior?.phase==='BLOCKED' && prior.sessionId===replace
|
|
45
|
-
&& prior.projectId!==intent.projectId;
|
|
51
|
+
&& (prior.projectId!==intent.projectId || independentTask);
|
|
46
52
|
if(replace&&!matchingBlocked)return {status:'DENIED',code:'BLOCKED_REPLACEMENT_MISMATCH'};
|
|
47
53
|
if(prior&&prior.phase!=='DONE'&&!matchingBlocked)
|
|
48
54
|
return {status:'DENIED',code:'LOOP_ALREADY_ACTIVE'};
|
|
@@ -80,6 +86,8 @@ async function sessionStartPrepare(message,sender){
|
|
|
80
86
|
:await approvedAdoptionTarget(intent.chatUrl||null,
|
|
81
87
|
intent.contextLeaseRef?intent.taskId:null):null;
|
|
82
88
|
if(adoption?.error)return {status:'DENIED',code:adoption.error};
|
|
89
|
+
if(matchingBlocked&&adoption?.target?.page===prior.page&&prior.page)
|
|
90
|
+
return {status:'DENIED',code:'BLOCKED_REPLACEMENT_CHAT_REUSE'};
|
|
83
91
|
// A Project-scoped Chat cannot safely hand off to the ordinary home route:
|
|
84
92
|
// reject BEFORE claiming Owner instead of failing after four hours.
|
|
85
93
|
// Explicit /g/ intent remains Project-scoped even if Chrome aliases the
|
|
@@ -88,8 +96,8 @@ async function sessionStartPrepare(message,sender){
|
|
|
88
96
|
pathOf(intent.chatUrl||'').startsWith('/g/')
|
|
89
97
|
||adoption?.target?.page?.startsWith('/g/')))
|
|
90
98
|
return {status:'DENIED',code:'AUTO_HANDOFF_ROUTE_UNSUPPORTED'};
|
|
91
|
-
//
|
|
92
|
-
//
|
|
99
|
+
// Replacement must not replay the old Task. A new independent Task may
|
|
100
|
+
// share its Project after exact blocked Owner and Context-fence checks.
|
|
93
101
|
const promptDigest=adoption?null:await startPromptFingerprint(intent.prompt);
|
|
94
102
|
const next={sessionId:crypto.randomUUID(),projectId:intent.projectId,
|
|
95
103
|
...(intent.taskId?{taskId:intent.taskId}:{}),
|
|
@@ -56,8 +56,12 @@ function checkedExtensionIdle(){
|
|
|
56
56
|
*/
|
|
57
57
|
export function verifyOrphanOwnerIdle({oldRunRef,projectId}){
|
|
58
58
|
const native=checkedNative(),extension=checkedExtensionIdle();
|
|
59
|
-
const oldId=oldRunRef.split(':')
|
|
60
|
-
ensure(
|
|
59
|
+
const [oldId,oldTaskId,oldGeneration,...extra]=oldRunRef.split(':');
|
|
60
|
+
ensure(extra.length===0&&oldTaskId&&/^\d+$/.test(oldGeneration),
|
|
61
|
+
'ORPHAN_RUN_REF_INVALID');
|
|
62
|
+
ensure(native.sessionId!==oldId
|
|
63
|
+
&&(native.projectId!==projectId
|
|
64
|
+
||typeof native.taskId==='string'&&native.taskId!==oldTaskId),
|
|
61
65
|
'ORPHAN_OWNER_STILL_CURRENT');
|
|
62
66
|
const live=readSession();
|
|
63
67
|
ensure(live?.phase==='DONE'&&
|
|
@@ -90,7 +90,9 @@ export function writeSession(input,replaceBlockedSessionId=null,resumeBlockedSes
|
|
|
90
90
|
throw fail('SESSION_REPLACEMENT_MISMATCH');
|
|
91
91
|
if(old&&old.sessionId!==next.sessionId&&old.phase!=='DONE'
|
|
92
92
|
&& !(old.phase==='BLOCKED' && next.phase==='STARTING'
|
|
93
|
-
&& replaceBlockedSessionId===old.sessionId
|
|
93
|
+
&& replaceBlockedSessionId===old.sessionId
|
|
94
|
+
&& (next.projectId!==old.projectId
|
|
95
|
+
||next.taskId!==undefined&&next.taskId!==old.taskId)))
|
|
94
96
|
throw fail('SESSION_ALREADY_ACTIVE');
|
|
95
97
|
if(old&&old.sessionId===next.sessionId){
|
|
96
98
|
if(next.projectId!==old.projectId)throw fail('SESSION_PROJECT_CHANGED');
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.9.
|
|
6
|
+
"version": "0.9.52",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"description": "Chat Loop local tools: MCP gateway, isolated bundled tunnel-client and unified CLI",
|
|
9
9
|
"bin": {
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"prepack": "node ./scripts/build-providers.mjs --check && node ./scripts/build-form-app.mjs --check && node ./scripts/build-document-app.mjs --check"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@tomflow/chatloop-context": "0.6.
|
|
36
|
+
"@tomflow/chatloop-context": "0.6.16",
|
|
37
37
|
"@tomflow/chatloop-trace": "0.4.6",
|
|
38
38
|
"@wonderwhy-er/desktop-commander": "0.2.44",
|
|
39
39
|
"ps-list": "9.0.0",
|
|
40
|
-
"@tomflow/chatloop-extension": "0.4.
|
|
40
|
+
"@tomflow/chatloop-extension": "0.4.22"
|
|
41
41
|
},
|
|
42
42
|
"bundleDependencies": [
|
|
43
43
|
"@tomflow/chatloop-context",
|