@tomflow/chatloop-tools 0.9.62 → 0.9.64

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.
Files changed (154) hide show
  1. package/README.md +13 -1
  2. package/index.mjs +7 -7
  3. package/lib/context-control-run.mjs +23 -5
  4. package/lib/extension-proxy.mjs +29 -10
  5. package/lib/native-owner-v2.mjs +128 -0
  6. package/lib/release-health-checks.mjs +29 -5
  7. package/lib/trace-gateway.mjs +3 -1
  8. package/package.json +3 -13
  9. package/providers/extension.mjs +59 -16
  10. package/node_modules/@tomflow/chatloop-context/README.md +0 -240
  11. package/node_modules/@tomflow/chatloop-context/bin/cli.mjs +0 -48
  12. package/node_modules/@tomflow/chatloop-context/capabilities/approval.mjs +0 -151
  13. package/node_modules/@tomflow/chatloop-context/capabilities/context.mjs +0 -376
  14. package/node_modules/@tomflow/chatloop-context/capabilities/document.mjs +0 -266
  15. package/node_modules/@tomflow/chatloop-context/capabilities/evidence.mjs +0 -134
  16. package/node_modules/@tomflow/chatloop-context/capabilities/presentation.mjs +0 -82
  17. package/node_modules/@tomflow/chatloop-context/capabilities/project.mjs +0 -349
  18. package/node_modules/@tomflow/chatloop-context/capabilities/sdk.mjs +0 -72
  19. package/node_modules/@tomflow/chatloop-context/capabilities/start.mjs +0 -73
  20. package/node_modules/@tomflow/chatloop-context/capabilities/task.mjs +0 -507
  21. package/node_modules/@tomflow/chatloop-context/capabilities.generated.mjs +0 -11
  22. package/node_modules/@tomflow/chatloop-context/docs/interfaces.md +0 -192
  23. package/node_modules/@tomflow/chatloop-context/docs/operator-and-migration.md +0 -277
  24. package/node_modules/@tomflow/chatloop-context/index.mjs +0 -236
  25. package/node_modules/@tomflow/chatloop-context/lib/api-log.mjs +0 -86
  26. package/node_modules/@tomflow/chatloop-context/lib/approval-policy.mjs +0 -77
  27. package/node_modules/@tomflow/chatloop-context/lib/capability-catalog.generated.json +0 -1989
  28. package/node_modules/@tomflow/chatloop-context/lib/capability-router.mjs +0 -69
  29. package/node_modules/@tomflow/chatloop-context/lib/cli-commands.mjs +0 -285
  30. package/node_modules/@tomflow/chatloop-context/lib/context-cli.mjs +0 -298
  31. package/node_modules/@tomflow/chatloop-context/lib/context-migration.mjs +0 -286
  32. package/node_modules/@tomflow/chatloop-context/lib/core/context.mjs +0 -115
  33. package/node_modules/@tomflow/chatloop-context/lib/core/evidence.mjs +0 -51
  34. package/node_modules/@tomflow/chatloop-context/lib/core/health.mjs +0 -75
  35. package/node_modules/@tomflow/chatloop-context/lib/core/migration.mjs +0 -262
  36. package/node_modules/@tomflow/chatloop-context/lib/core/project.mjs +0 -246
  37. package/node_modules/@tomflow/chatloop-context/lib/core/review.mjs +0 -147
  38. package/node_modules/@tomflow/chatloop-context/lib/core/run-cancel.mjs +0 -54
  39. package/node_modules/@tomflow/chatloop-context/lib/core/run.mjs +0 -375
  40. package/node_modules/@tomflow/chatloop-context/lib/core/store.mjs +0 -397
  41. package/node_modules/@tomflow/chatloop-context/lib/core/task.mjs +0 -183
  42. package/node_modules/@tomflow/chatloop-context/lib/line-review.mjs +0 -13
  43. package/node_modules/@tomflow/chatloop-context/lib/methods.mjs +0 -111
  44. package/node_modules/@tomflow/chatloop-context/lib/operations.mjs +0 -107
  45. package/node_modules/@tomflow/chatloop-context/lib/orphan-operator.mjs +0 -118
  46. package/node_modules/@tomflow/chatloop-context/lib/process-inventory.mjs +0 -20
  47. package/node_modules/@tomflow/chatloop-context/lib/project-branch.mjs +0 -316
  48. package/node_modules/@tomflow/chatloop-context/lib/project-diagnostic.mjs +0 -153
  49. package/node_modules/@tomflow/chatloop-context/lib/project-guards.mjs +0 -19
  50. package/node_modules/@tomflow/chatloop-context/lib/project-store.mjs +0 -117
  51. package/node_modules/@tomflow/chatloop-context/lib/trusted-run.mjs +0 -97
  52. package/node_modules/@tomflow/chatloop-context/lib/workspace-operator.mjs +0 -169
  53. package/node_modules/@tomflow/chatloop-context/package.json +0 -40
  54. package/node_modules/@tomflow/chatloop-context/scripts/build-capabilities.mjs +0 -114
  55. package/node_modules/@tomflow/chatloop-extension/README.md +0 -124
  56. package/node_modules/@tomflow/chatloop-extension/actions.generated.mjs +0 -13
  57. package/node_modules/@tomflow/chatloop-extension/bin/cli.mjs +0 -153
  58. package/node_modules/@tomflow/chatloop-extension/bin/native-host.mjs +0 -207
  59. package/node_modules/@tomflow/chatloop-extension/capabilities/chat_dom.mjs +0 -1
  60. package/node_modules/@tomflow/chatloop-extension/capabilities/chat_screenshot.mjs +0 -1
  61. package/node_modules/@tomflow/chatloop-extension/capabilities/chat_text.mjs +0 -1
  62. package/node_modules/@tomflow/chatloop-extension/capabilities/clean.mjs +0 -1
  63. package/node_modules/@tomflow/chatloop-extension/capabilities/continue.mjs +0 -1
  64. package/node_modules/@tomflow/chatloop-extension/capabilities/entry_test.mjs +0 -1
  65. package/node_modules/@tomflow/chatloop-extension/capabilities/handoff.mjs +0 -1
  66. package/node_modules/@tomflow/chatloop-extension/capabilities/reload.mjs +0 -1
  67. package/node_modules/@tomflow/chatloop-extension/capabilities/session.mjs +0 -1
  68. package/node_modules/@tomflow/chatloop-extension/capabilities/start.mjs +0 -1
  69. package/node_modules/@tomflow/chatloop-extension/capabilities/status.mjs +0 -1
  70. package/node_modules/@tomflow/chatloop-extension/extension/actions/clean.js +0 -123
  71. package/node_modules/@tomflow/chatloop-extension/extension/actions/common.js +0 -183
  72. package/node_modules/@tomflow/chatloop-extension/extension/actions/continue.js +0 -340
  73. package/node_modules/@tomflow/chatloop-extension/extension/actions/dom.js +0 -2
  74. package/node_modules/@tomflow/chatloop-extension/extension/actions/entry_test.js +0 -241
  75. package/node_modules/@tomflow/chatloop-extension/extension/actions/handoff.js +0 -393
  76. package/node_modules/@tomflow/chatloop-extension/extension/actions/index.js +0 -2
  77. package/node_modules/@tomflow/chatloop-extension/extension/actions/model-intent.js +0 -56
  78. package/node_modules/@tomflow/chatloop-extension/extension/actions/read-mode.js +0 -9
  79. package/node_modules/@tomflow/chatloop-extension/extension/actions/reload.js +0 -20
  80. package/node_modules/@tomflow/chatloop-extension/extension/actions/screenshot.js +0 -77
  81. package/node_modules/@tomflow/chatloop-extension/extension/actions/session.js +0 -52
  82. package/node_modules/@tomflow/chatloop-extension/extension/actions/start.js +0 -295
  83. package/node_modules/@tomflow/chatloop-extension/extension/actions/status.js +0 -24
  84. package/node_modules/@tomflow/chatloop-extension/extension/actions/text.js +0 -2
  85. package/node_modules/@tomflow/chatloop-extension/extension/background.js +0 -17
  86. package/node_modules/@tomflow/chatloop-extension/extension/clean.html +0 -5
  87. package/node_modules/@tomflow/chatloop-extension/extension/content.js +0 -40
  88. package/node_modules/@tomflow/chatloop-extension/extension/continue.html +0 -9
  89. package/node_modules/@tomflow/chatloop-extension/extension/dom.html +0 -17
  90. package/node_modules/@tomflow/chatloop-extension/extension/entry_test.html +0 -6
  91. package/node_modules/@tomflow/chatloop-extension/extension/handoff.html +0 -9
  92. package/node_modules/@tomflow/chatloop-extension/extension/loop/action-catalog.generated.js +0 -2
  93. package/node_modules/@tomflow/chatloop-extension/extension/loop/api-aspect.generated.js +0 -275
  94. package/node_modules/@tomflow/chatloop-extension/extension/loop/api-observation-queue.generated.js +0 -84
  95. package/node_modules/@tomflow/chatloop-extension/extension/loop/core.js +0 -107
  96. package/node_modules/@tomflow/chatloop-extension/extension/loop/index.js +0 -36
  97. package/node_modules/@tomflow/chatloop-extension/extension/loop/observer-approval.js +0 -299
  98. package/node_modules/@tomflow/chatloop-extension/extension/loop/observer-inspect.js +0 -144
  99. package/node_modules/@tomflow/chatloop-extension/extension/loop/observer-poll.js +0 -171
  100. package/node_modules/@tomflow/chatloop-extension/extension/loop/observer-recovery.js +0 -109
  101. package/node_modules/@tomflow/chatloop-extension/extension/loop/observer.js +0 -154
  102. package/node_modules/@tomflow/chatloop-extension/extension/loop/resources.js +0 -259
  103. package/node_modules/@tomflow/chatloop-extension/extension/manifest.json +0 -42
  104. package/node_modules/@tomflow/chatloop-extension/extension/popup.html +0 -25
  105. package/node_modules/@tomflow/chatloop-extension/extension/popup.js +0 -99
  106. package/node_modules/@tomflow/chatloop-extension/extension/reload.html +0 -17
  107. package/node_modules/@tomflow/chatloop-extension/extension/screenshot.html +0 -17
  108. package/node_modules/@tomflow/chatloop-extension/extension/session.html +0 -6
  109. package/node_modules/@tomflow/chatloop-extension/extension/start.html +0 -6
  110. package/node_modules/@tomflow/chatloop-extension/extension/status.html +0 -6
  111. package/node_modules/@tomflow/chatloop-extension/extension/text.html +0 -17
  112. package/node_modules/@tomflow/chatloop-extension/extension/worker/action-result.js +0 -136
  113. package/node_modules/@tomflow/chatloop-extension/extension/worker/action-take.js +0 -218
  114. package/node_modules/@tomflow/chatloop-extension/extension/worker/admission.js +0 -124
  115. package/node_modules/@tomflow/chatloop-extension/extension/worker/adopt-prepare.js +0 -296
  116. package/node_modules/@tomflow/chatloop-extension/extension/worker/adopt-recovery.js +0 -186
  117. package/node_modules/@tomflow/chatloop-extension/extension/worker/adopt-result.js +0 -126
  118. package/node_modules/@tomflow/chatloop-extension/extension/worker/bootstrap.js +0 -230
  119. package/node_modules/@tomflow/chatloop-extension/extension/worker/manual.js +0 -163
  120. package/node_modules/@tomflow/chatloop-extension/extension/worker/readiness.js +0 -345
  121. package/node_modules/@tomflow/chatloop-extension/extension/worker/router.js +0 -192
  122. package/node_modules/@tomflow/chatloop-extension/extension/worker/scheduler.js +0 -161
  123. package/node_modules/@tomflow/chatloop-extension/extension/worker/session-control.js +0 -75
  124. package/node_modules/@tomflow/chatloop-extension/extension/worker/turn-failure.js +0 -197
  125. package/node_modules/@tomflow/chatloop-extension/extension/worker/turn-finished.js +0 -205
  126. package/node_modules/@tomflow/chatloop-extension/index.mjs +0 -71
  127. package/node_modules/@tomflow/chatloop-extension/lib/action-routing.mjs +0 -19
  128. package/node_modules/@tomflow/chatloop-extension/lib/api-observation-queue.mjs +0 -82
  129. package/node_modules/@tomflow/chatloop-extension/lib/bridge.mjs +0 -303
  130. package/node_modules/@tomflow/chatloop-extension/lib/browser-launch.mjs +0 -83
  131. package/node_modules/@tomflow/chatloop-extension/lib/context-binding.mjs +0 -45
  132. package/node_modules/@tomflow/chatloop-extension/lib/context-ipc.mjs +0 -115
  133. package/node_modules/@tomflow/chatloop-extension/lib/owner-evidence.mjs +0 -75
  134. package/node_modules/@tomflow/chatloop-extension/lib/session-file.mjs +0 -185
  135. package/node_modules/@tomflow/chatloop-extension/package.json +0 -38
  136. package/node_modules/@tomflow/chatloop-extension/scripts/build-actions.mjs +0 -138
  137. package/node_modules/@tomflow/chatloop-trace/README.md +0 -118
  138. package/node_modules/@tomflow/chatloop-trace/events/context.api.mjs +0 -23
  139. package/node_modules/@tomflow/chatloop-trace/events/typed.api.call.mjs +0 -22
  140. package/node_modules/@tomflow/chatloop-trace/events.generated.mjs +0 -4
  141. package/node_modules/@tomflow/chatloop-trace/index.mjs +0 -59
  142. package/node_modules/@tomflow/chatloop-trace/lib/api-aspect.mjs +0 -273
  143. package/node_modules/@tomflow/chatloop-trace/lib/trace-reader.mjs +0 -308
  144. package/node_modules/@tomflow/chatloop-trace/lib/trace-retention.mjs +0 -140
  145. package/node_modules/@tomflow/chatloop-trace/lib/trace.mjs +0 -236
  146. package/node_modules/@tomflow/chatloop-trace/package.json +0 -30
  147. package/node_modules/@tomflow/chatloop-trace/scripts/build-events.mjs +0 -68
  148. package/node_modules/ps-list/index.d.ts +0 -76
  149. package/node_modules/ps-list/index.js +0 -366
  150. package/node_modules/ps-list/license +0 -9
  151. package/node_modules/ps-list/package.json +0 -44
  152. package/node_modules/ps-list/readme.md +0 -56
  153. package/node_modules/ps-list/vendor/fastlist-0.3.0-x64.exe +0 -0
  154. package/node_modules/ps-list/vendor/fastlist-0.3.0-x86.exe +0 -0
@@ -1,115 +0,0 @@
1
- // Browser Native Host -> existing Local Tools Supervisor narrow IPC.
2
- // This file deliberately does not import Local Tools internals or create
3
- // another Context service. A same-UID shell remains within the trusted local boundary.
4
- import {createHmac,randomUUID} from 'node:crypto';
5
- import {connect} from 'node:net';
6
- import {existsSync,lstatSync,readFileSync} from 'node:fs';
7
- import {homedir} from 'node:os';
8
- import {join} from 'node:path';
9
- const fail=code=>Object.assign(new Error(code),{code});
10
- const base=()=>process.env.CHAT_LOOP_LOCAL_TOOLS_STATE_DIR||
11
- join(homedir(),'.chat-loop','local-tools');
12
- function privateFile(path,type){
13
- if(!existsSync(path))throw fail('CONTEXT_CONTROL_NOT_INSTALLED');
14
- const st=lstatSync(path);
15
- if((type==='socket'?!st.isSocket():!st.isFile())
16
- ||st.isSymbolicLink()||(st.mode&0o077)
17
- ||(process.getuid && st.uid!==process.getuid()))
18
- throw fail('CONTEXT_CONTROL_UNTRUSTED');
19
- return st;
20
- }
21
- const ipc=(request,timeout=4000)=>new Promise((resolve,reject)=>{
22
- const socket=connect(join(base(),'control.sock'));
23
- socket.setEncoding('utf8'); // Preserve JSON code points split by socket chunks.
24
- let text='',done=false;
25
- const timer=setTimeout(()=>finish(fail('CONTEXT_CONTROL_TIMEOUT')),timeout);
26
- function finish(error,value){
27
- if(done)return;done=true;clearTimeout(timer);socket.destroy();
28
- error?reject(error):resolve(value);
29
- }
30
- socket.on('connect',()=>socket.write(JSON.stringify(request)+'\n'));
31
- socket.on('error',e=>finish(e));
32
- socket.on('end',()=>{if(!done)finish(fail('CONTEXT_CONTROL_UNCONFIRMED'))});
33
- socket.on('data',chunk=>{
34
- text+=chunk;
35
- if(Buffer.byteLength(text,'utf8')>1_000_000)return finish(fail('CONTEXT_CONTROL_REPLY_TOO_LARGE'));
36
- const n=text.indexOf('\n');if(n<0)return;
37
- try{finish(null,JSON.parse(text.slice(0,n)))}catch{finish(fail('CONTEXT_CONTROL_REPLY_INVALID'))}
38
- });
39
- });
40
- export async function nativeContextControl(command,args){
41
- const dir=base();
42
- const st=lstatSync(dir);
43
- if(!st.isDirectory()||st.isSymbolicLink()||(st.mode&0o077)
44
- ||(process.getuid&&st.uid!==process.getuid()))
45
- throw fail('CONTEXT_CONTROL_UNTRUSTED');
46
- privateFile(join(dir,'control.sock'),'socket');
47
- privateFile(join(dir,'manager.lock'),'file');
48
- const key=join(dir,'context-control.secret');
49
- const secretStats=privateFile(key,'file');
50
- if(secretStats.size!==32)throw fail('CONTEXT_CONTROL_UNTRUSTED');
51
- const hello=await ipc({action:'__ping'},2000);
52
- const lock=JSON.parse(readFileSync(join(dir,'manager.lock'),'utf8'));
53
- if(hello.contract!=='chat-loop.local-control.v1'
54
- ||lock.nonce!==hello.ownerNonce||lock.pid!==hello.managerPid
55
- ||lock.version!==hello.version||hello.version!==hello.packageVersion)
56
- throw fail('CONTEXT_CONTROL_OWNER_MISMATCH');
57
- const secret=readFileSync(key);
58
- const signed={contract:'chat-loop.context-control.v1',
59
- requestId:randomUUID(),issuedAt:Date.now(),payload:{command,args}};
60
- const mac=createHmac('sha256',secret).update(JSON.stringify(signed)).digest('hex');
61
- const reply=await ipc({...signed,action:'context-control',mac},6000);
62
- if(reply.contract!==hello.contract||reply.requestId!==signed.requestId)
63
- throw fail('CONTEXT_CONTROL_REPLY_INVALID');
64
- if(reply.status!=='OK'){
65
- const code=reply.error?.code;
66
- throw fail(typeof code==='string'&&/^[A-Z][A-Z0-9_]{1,95}$/.test(code)
67
- ?code:'CONTEXT_CONTROL_FAILED');
68
- }
69
- return reply.result;
70
- }
71
-
72
- // Independent, best-effort observation channel. No business data.
73
- // A separate identity ping for every event (or a shared ping for a burst)
74
- // caused the observed Supervisor IPC timeout fan-out. The existing private
75
- // manager.lock contains the current Manager identity: include it on the
76
- // observation itself, then let the Supervisor verify it atomically on receipt.
77
- const API_UUID=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
78
- const API_NAME=/^extension\.[A-Za-z][A-Za-z0-9_.:-]{1,119}$/;
79
- const API_CODE=/^[A-Z][A-Z0-9_]{1,95}$/;
80
- export async function nativeApiObservation(record){
81
- if(!record||typeof record!=='object'||Array.isArray(record)||
82
- Object.keys(record).some(key=>!['callId','traceId','spanId','parentSpanId',
83
- 'apiName','phase','durationMs','errorCode'].includes(key))||
84
- !API_UUID.test(record.callId||'')||
85
- !API_UUID.test(record.traceId||'')||
86
- record.spanId!==record.callId||
87
- (record.parentSpanId!==undefined&&
88
- (!API_UUID.test(record.parentSpanId)||record.parentSpanId===record.spanId))||
89
- !API_NAME.test(record.apiName||'')||
90
- !['BEGIN','OK','FAILED'].includes(record.phase)||
91
- (record.phase==='BEGIN'
92
- ?record.durationMs!==undefined||record.errorCode!==undefined
93
- :!Number.isSafeInteger(record.durationMs)||record.durationMs<0||
94
- (record.phase==='FAILED'?!API_CODE.test(record.errorCode||'')
95
- :record.errorCode!==undefined)))
96
- throw fail('API_OBSERVATION_INVALID');
97
- const dir=base(),stat=lstatSync(dir);
98
- if(!stat.isDirectory()||stat.isSymbolicLink()||(stat.mode&0o077)||
99
- (process.getuid&&stat.uid!==process.getuid()))
100
- throw fail('API_OBSERVATION_UNTRUSTED');
101
- privateFile(join(dir,'control.sock'),'socket');
102
- const lockFile=join(dir,'manager.lock');
103
- privateFile(lockFile,'file');
104
- const manager=JSON.parse(readFileSync(lockFile,'utf8'));
105
- if(!API_UUID.test(manager.nonce||'')||!Number.isSafeInteger(manager.pid)
106
- ||manager.pid<1||typeof manager.version!=='string')
107
- throw fail('API_OBSERVATION_OWNER_UNTRUSTED');
108
- const request={contract:'chat-loop.local-control.v1',action:'__api_observation',
109
- requestId:randomUUID(),ownerNonce:manager.nonce,managerPid:manager.pid,...record};
110
- // The Supervisor verifies ownerNonce and managerPid before appending.
111
- // This is one socket and one ACK per event, never an Action retry.
112
- const response=await ipc(request,3500);
113
- return response.contract===request.contract&&
114
- response.requestId===request.requestId&&response.status==='OK';
115
- }
@@ -1,75 +0,0 @@
1
- // Official Extension/Native owner-evidence contract for Context's reviewed
2
- // orphan fence. Browser Owner remains Extension's authority, not Context's.
3
- import {execFileSync} from 'node:child_process';
4
- import {createHash} from 'node:crypto';
5
- import {readFileSync,lstatSync} from 'node:fs';
6
- let readSession,sessionPath,cliPath;
7
- export function configureOwnerEvidence(api){
8
- if(readSession)throw Error('EXTENSION_MODULE_ALREADY_COMPOSED');
9
- for(const name of ['readSession','sessionPath','cliPath'])
10
- if(typeof api?.[name]!=='function')throw Error('EXTENSION_PORT_MISSING:'+name);
11
- ({readSession,sessionPath,cliPath}=api);
12
- }
13
-
14
- const fail=code=>Object.assign(new Error(code),{code});
15
- const ensure=(ok,code)=>{if(!ok)throw fail(code)};
16
- const sha=raw=>createHash('sha256').update(raw).digest('hex');
17
- const packageVersion=JSON.parse(readFileSync(new URL('../package.json',import.meta.url),'utf8')).version;
18
-
19
- function checkedNative(){
20
- const session=readSession();
21
- ensure(session?.phase==='DONE'&&typeof session.sessionId==='string'
22
- &&Number.isSafeInteger(session.updatedAt),'NATIVE_NOT_TERMINAL');
23
- const raw=readFileSync(sessionPath());
24
- ensure(sha(Buffer.from(JSON.stringify(session)))===
25
- sha(Buffer.from(JSON.stringify(JSON.parse(raw.toString('utf8'))))),
26
- 'NATIVE_POINTER_UNTRUSTED');
27
- return {sessionId:session.sessionId,projectId:session.projectId,
28
- taskId:session.taskId||null,phase:session.phase,
29
- updatedAt:session.updatedAt,rawHash:sha(raw)};
30
- }
31
-
32
- function checkedExtensionIdle(){
33
- // This is the Extension-owned CLI, resolved from this installed package.
34
- // Context never composes an Extension install path or parses its CLI output.
35
- const cli=cliPath();
36
- const st=lstatSync(cli);
37
- ensure(st.isFile()&&!st.isSymbolicLink(),'EXTENSION_CLI_UNTRUSTED');
38
- const out=execFileSync(process.execPath,[cli,'extension','status'],{
39
- encoding:'utf8',timeout:14000,maxBuffer:524288,stdio:['ignore','pipe','pipe']});
40
- const rows=out.trim().split('\n').map(s=>JSON.parse(s));
41
- const result=rows.findLast(x=>x.event==='RESULT');
42
- ensure(result?.contract==='chat-loop.extension-cli.v1'
43
- &&result.command==='extension status'
44
- &&result.providerVersion===packageVersion
45
- &&result.ok===true&&result.value?.verified===true
46
- &&result.value?.truncated===false,'EXTENSION_STATUS_UNVERIFIED');
47
- const v=JSON.parse(result.value.content||'{}');
48
- ensure(v.status==='OK'&&v.state==='IDLE'
49
- &&v.lastSession?.phase==='DONE','EXTENSION_OWNER_NOT_IDLE');
50
- return v;
51
- }
52
-
53
- /**
54
- * Read-only owner proof; NEVER grants execution or signs R/P approval.
55
- * Re-run before the final Context fence to detect Native/Worker drift.
56
- */
57
- export function verifyOrphanOwnerIdle({oldRunRef,projectId}){
58
- const native=checkedNative(),extension=checkedExtensionIdle();
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),
65
- 'ORPHAN_OWNER_STILL_CURRENT');
66
- const live=readSession();
67
- ensure(live?.phase==='DONE'&&
68
- extension.lastSession.sessionId===native.sessionId
69
- &&extension.lastSession.projectId===native.projectId
70
- &&extension.lastSession.updatedAt===native.updatedAt
71
- &&extension.lastSession.activeChatId===live.activeChatId
72
- &&checkedNative().rawHash===native.rawHash,
73
- 'EXTENSION_NATIVE_POINTER_MISMATCH');
74
- return native;
75
- }
@@ -1,185 +0,0 @@
1
- // Single-Mac durable session pointer. Extension Worker is the only admission/sending authority.
2
- // This file is a checked, minimal projection, not a second executor or task engine.
3
- import {openSync,closeSync,readFileSync,writeFileSync,renameSync,unlinkSync,lstatSync,mkdirSync} from 'node:fs';
4
- import {homedir} from 'node:os';
5
- import {join,dirname} from 'node:path';
6
- import {randomUUID} from 'node:crypto';
7
-
8
- const ID=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
9
- const CHAT=/^[0-9a-f-]{12,}$/i;
10
- const PROJECT=/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/;
11
- const PHASE=new Set(['STARTING','RESERVED','PENDING','WAITING_REPLY','DONE','BLOCKED','CANCELLED']);
12
- const fail=code=>Object.assign(Error(code),{code});
13
- export const sessionPath=()=>join(homedir(),'.chat-loop','session','active-session.json');
14
- // An absent path differs from a dangling symlink: existsSync follows the
15
- // link and would otherwise silently erase the Native Owner projection.
16
- const entryOrMissing=path=>{
17
- try{return lstatSync(path)}
18
- catch(error){if(error.code==='ENOENT')return null;throw error}
19
- };
20
- const verifyPrivateDirectory=dir=>{
21
- const st=entryOrMissing(dir);
22
- if(st&&(!st.isDirectory()||st.isSymbolicLink()
23
- ||(process.getuid&&st.uid!==process.getuid())
24
- ||(process.platform!=='win32'&&(st.mode&0o077))))
25
- throw fail('SESSION_DIRECTORY_UNTRUSTED');
26
- return Boolean(st);
27
- };
28
- const ensurePrivate=dir=>{
29
- if(!verifyPrivateDirectory(dir))mkdirSync(dir,{recursive:true,mode:0o700});
30
- if(!verifyPrivateDirectory(dir))throw fail('SESSION_DIRECTORY_UNTRUSTED');
31
- };
32
- const validate=r=>{
33
- if(!r||typeof r!=='object'||Array.isArray(r)||
34
- !ID.test(r.sessionId||'')||!PROJECT.test(r.projectId||'')||
35
- (r.taskId!==undefined && !PROJECT.test(r.taskId))||
36
- !PHASE.has(r.phase)||!Number.isSafeInteger(r.generation)||r.generation<0||
37
- !Number.isSafeInteger(r.updatedAt)||r.updatedAt<=0)
38
- throw fail('SESSION_INVALID');
39
- if(r.activeChatId!==null&&(typeof r.activeChatId!=='string'||!CHAT.test(r.activeChatId)))
40
- throw fail('SESSION_CHAT_INVALID');
41
- if(r.activeChatUrl!==null&&(typeof r.activeChatUrl!=='string'
42
- || !/^https:\/\/chatgpt\.com\/(?:c\/[0-9a-f-]{12,}|g\/[^/]+\/c\/[0-9a-f-]{12,})$/i.test(r.activeChatUrl)))
43
- throw fail('SESSION_CHAT_INVALID');
44
- if((r.activeChatId===null)!==(r.activeChatUrl===null))
45
- throw fail('SESSION_CHAT_INVALID');
46
- if(r.activeChatUrl!==null&&!r.activeChatUrl.endsWith('/'+r.activeChatId))
47
- throw fail('SESSION_CHAT_INVALID');
48
- if(r.activeChatId===null&&r.phase==='WAITING_REPLY')throw fail('SESSION_CHAT_INVALID');
49
- const keys=['sessionId','projectId','phase','generation','activeChatId','activeChatUrl','updatedAt','taskId'];
50
- if(Object.keys(r).some(k=>!keys.includes(k)))throw fail('SESSION_EXTRA_FIELDS');
51
- return Object.fromEntries(keys.filter(k=>Object.hasOwn(r,k)).map(k=>[k,r[k]]));
52
- };
53
- export function readSession(){
54
- const file=sessionPath();
55
- if(!verifyPrivateDirectory(dirname(file)))return null;
56
- const st=entryOrMissing(file);
57
- if(!st)return null;
58
- if(!st.isFile()||st.isSymbolicLink()||(process.getuid&&st.uid!==process.getuid())
59
- ||(process.platform!=='win32'&&(st.mode&0o077)))throw fail('SESSION_FILE_UNTRUSTED');
60
- try{return validate(JSON.parse(readFileSync(file,'utf8')));}
61
- catch(e){if(e.code)throw e;throw fail('SESSION_FILE_CORRUPT');}
62
- }
63
- export function writeSession(input,replaceBlockedSessionId=null,resumeBlockedSessionId=null,resumeBlockedUpdatedAt=null,sameTaskPrePermitUpdatedAt=null,cancelBlockedUpdatedAt=null,
64
- cancelFreezeExpectedAt=null){
65
- const next=validate(input),file=sessionPath(),dir=dirname(file),lock=file+'.lock';
66
- ensurePrivate(dir);
67
- let fd;
68
- try{fd=openSync(lock,'wx',0o600);}catch{throw fail('SESSION_CONCURRENT_UPDATE');}
69
- try{
70
- const old=readSession();
71
- // A canceled idle Adopt is terminal only after Context writer fencing.
72
- // The Native Host independently verifies the authoritative Context
73
- // cancellation receipt before passing this exact timestamp CAS.
74
- const cancelCas=Number.isSafeInteger(cancelBlockedUpdatedAt)
75
- &&cancelBlockedUpdatedAt>0&&old?.updatedAt===cancelBlockedUpdatedAt
76
- &&old.phase==='BLOCKED'&&next.phase==='CANCELLED'
77
- &&old.sessionId===next.sessionId&&old.projectId===next.projectId
78
- &&old.taskId===next.taskId&&old.generation===next.generation
79
- &&old.activeChatId===next.activeChatId
80
- &&old.activeChatUrl===next.activeChatUrl;
81
- if(cancelBlockedUpdatedAt!==null&&!cancelCas)
82
- throw fail('SESSION_CANCEL_CAS_MISMATCH');
83
- const freezeCas=Number.isSafeInteger(cancelFreezeExpectedAt)
84
- &&cancelFreezeExpectedAt>0&&old?.updatedAt===cancelFreezeExpectedAt
85
- &&old.phase==='WAITING_REPLY'&&next.phase==='BLOCKED'
86
- &&old.sessionId===next.sessionId&&old.projectId===next.projectId
87
- &&old.taskId===next.taskId&&old.generation===next.generation
88
- &&old.activeChatId===next.activeChatId
89
- &&old.activeChatUrl===next.activeChatUrl;
90
- if(cancelFreezeExpectedAt!==null&&!freezeCas)
91
- throw fail('SESSION_CANCEL_FREEZE_CAS_MISMATCH');
92
- if(resumeBlockedSessionId){
93
- // A BLOCKED session is terminal except for an exact-same-owner,
94
- // same-Chat, same-generation, one-shot recovery CAS. No new Chat,
95
- // task, project, approval or Handoff may be smuggled into recovery.
96
- if(replaceBlockedSessionId || !old || old.phase!=='BLOCKED'
97
- ||!Number.isSafeInteger(resumeBlockedUpdatedAt)
98
- ||resumeBlockedUpdatedAt<=0
99
- ||old.updatedAt!==resumeBlockedUpdatedAt
100
- ||old.sessionId!==resumeBlockedSessionId
101
- ||next.sessionId!==old.sessionId
102
- ||next.projectId!==old.projectId
103
- ||next.taskId!==old.taskId
104
- ||next.generation!==old.generation
105
- ||next.activeChatId!==old.activeChatId
106
- ||next.activeChatUrl!==old.activeChatUrl
107
- ||next.phase!=='RESERVED')
108
- throw fail('SESSION_RECOVERY_MISMATCH');
109
- }
110
- if(replaceBlockedSessionId && (!old||old.sessionId!==next.sessionId
111
- && (old.phase!=='BLOCKED'||old.sessionId!==replaceBlockedSessionId)))
112
- throw fail('SESSION_REPLACEMENT_MISMATCH');
113
- // The Worker alone identifies the pre-permit failure. Native requires
114
- // an independent one-shot disk CAS before allowing the SAME scoped Task
115
- // to replace its unsent BLOCKED session; other BLOCKED phases stay locked.
116
- const prePermitCas=Number.isSafeInteger(sameTaskPrePermitUpdatedAt)
117
- &&sameTaskPrePermitUpdatedAt>0&&old?.updatedAt===sameTaskPrePermitUpdatedAt
118
- &&old.phase==='BLOCKED'&&old.sessionId===replaceBlockedSessionId
119
- &&old.projectId===next.projectId&&typeof old.taskId==='string'
120
- &&old.taskId===next.taskId&&next.sessionId!==old.sessionId
121
- &&old.generation===0&&next.generation===0&&next.phase==='STARTING'
122
- &&old.activeChatId===null&&old.activeChatUrl===null
123
- &&next.activeChatId===null&&next.activeChatUrl===null;
124
- if(sameTaskPrePermitUpdatedAt!==null&&!prePermitCas)
125
- throw fail('SESSION_PRE_PERMIT_CAS_MISMATCH');
126
- if(old&&old.sessionId!==next.sessionId
127
- &&!['DONE','CANCELLED'].includes(old.phase)
128
- && !(old.phase==='BLOCKED' && next.phase==='STARTING'
129
- && replaceBlockedSessionId===old.sessionId
130
- && (next.projectId!==old.projectId
131
- ||next.taskId!==undefined&&next.taskId!==old.taskId
132
- ||prePermitCas)))
133
- throw fail('SESSION_ALREADY_ACTIVE');
134
- if(old&&old.sessionId===next.sessionId){
135
- if(next.projectId!==old.projectId)throw fail('SESSION_PROJECT_CHANGED');
136
- if(next.taskId!==old.taskId)throw fail('SESSION_TASK_CHANGED');
137
- if(next.generation<old.generation)throw fail('SESSION_STALE_GENERATION');
138
- // One verified Handoff advances exactly one generation. A skipped
139
- // generation cannot become a durable Owner identity.
140
- if(next.generation>old.generation+1)throw fail('SESSION_GENERATION_GAP');
141
- if(next.generation===old.generation+1
142
- &&(old.activeChatId===null||next.activeChatId===null
143
- ||next.activeChatId===old.activeChatId))
144
- throw fail('SESSION_HANDOFF_IDENTITY_UNVERIFIED');
145
- // A terminal session may be re-read or fenced, not reassigned to
146
- // another Chat or generation under the same sessionId.
147
- if(['DONE','BLOCKED','CANCELLED'].includes(old.phase)
148
- &&(next.generation!==old.generation
149
- ||next.activeChatId!==old.activeChatId
150
- ||next.activeChatUrl!==old.activeChatUrl))
151
- throw fail('SESSION_TERMINAL_IDENTITY_CHANGED');
152
- if(old.phase==='DONE'&&next.phase!=='DONE'
153
- ||old.phase==='CANCELLED'&&next.phase!=='CANCELLED'
154
- ||old.phase==='BLOCKED'
155
- && !['BLOCKED','DONE'].includes(next.phase)
156
- &&!(resumeBlockedSessionId===old.sessionId&&next.phase==='RESERVED')
157
- &&!cancelCas)
158
- throw fail('SESSION_TERMINAL_LOCKED');
159
- if(old.activeChatId!==null&&next.generation===old.generation&&
160
- next.activeChatId!==null&&old.activeChatId!==next.activeChatId)
161
- throw fail('SESSION_CHAT_CHANGED_WITHOUT_HANDOFF');
162
- }
163
- // A read-only Status query and non-authoritative Worker diagnostics can
164
- // re-sync the SAME durable projection. These are not a new Session
165
- // transition: preserve Native's CAS timestamp and avoid rewriting disk.
166
- // A genuine phase/identity/generation change still advances the record.
167
- if(old && !replaceBlockedSessionId && !resumeBlockedSessionId
168
- && ['sessionId','projectId','taskId','phase','generation',
169
- 'activeChatId','activeChatUrl'].every(key=>old[key]===next[key]))
170
- return old;
171
- // updatedAt is the Native recovery CAS value, not merely display time.
172
- // Two Worker transitions can occur inside one millisecond. Every actual
173
- // write must advance that version; an identical projection returned above
174
- // deliberately keeps the previous value.
175
- const committed=old&&next.updatedAt<=old.updatedAt
176
- ?{...next,updatedAt:old.updatedAt+1}:next;
177
- if(!Number.isSafeInteger(committed.updatedAt))
178
- throw fail('SESSION_CLOCK_EXHAUSTED');
179
- const temp=join(dir,'.active-session-'+randomUUID()+'.tmp');
180
- try{writeFileSync(temp,JSON.stringify(committed,null,2)+'\n',{flag:'wx',mode:0o600});
181
- renameSync(temp,file);
182
- }catch(e){try{unlinkSync(temp);}catch{}throw e;}
183
- return committed;
184
- }finally{closeSync(fd);unlinkSync(lock);}
185
- }
@@ -1,38 +0,0 @@
1
- {
2
- "name": "@tomflow/chatloop-extension",
3
- "version": "0.4.33",
4
- "type": "module",
5
- "description": "Chat Loop Extension: reviewed formal Action pages, including TEST_ONLY native App entry",
6
- "bin": {
7
- "chatloop-extension": "bin/cli.mjs"
8
- },
9
- "engines": {
10
- "node": ">=20"
11
- },
12
- "publishConfig": {
13
- "access": "public"
14
- },
15
- "files": [
16
- "index.mjs",
17
- "actions.generated.mjs",
18
- "capabilities/",
19
- "scripts/",
20
- "extension/",
21
- "bin/",
22
- "lib/",
23
- "README.md"
24
- ],
25
- "scripts": {
26
- "build:actions": "node ./scripts/build-actions.mjs",
27
- "build:actions:check": "node ./scripts/build-actions.mjs --check",
28
- "pretest": "node ./scripts/build-actions.mjs --check",
29
- "prepack": "node ./scripts/build-actions.mjs --check",
30
- "test": "node --test ./test/*.test.mjs"
31
- },
32
- "exports": {
33
- ".": "./index.mjs"
34
- },
35
- "dependencies": {
36
- "@tomflow/chatloop-trace": "0.4.6"
37
- }
38
- }
@@ -1,138 +0,0 @@
1
- // Extension action definitions are assembled at build time, never discovered
2
- // by a privileged running Chrome Worker or Native Host.
3
- import {readFileSync,readdirSync,writeFileSync,unlinkSync,existsSync} from 'node:fs';
4
- import {dirname,join,resolve} from 'node:path';
5
- import {fileURLToPath,pathToFileURL} from 'node:url';
6
- import {createHash} from 'node:crypto';
7
- const root=dirname(dirname(fileURLToPath(import.meta.url)));
8
- const fail=code=>Object.assign(Error(code),{code});
9
- const originals=['chat_text','chat_dom','chat_screenshot','reload',
10
- 'continue','handoff','clean','status','start','session'];
11
- const privilegedKinds=Object.freeze({chat_text:'eye-read',chat_dom:'eye-read',
12
- chat_screenshot:'eye-screenshot',reload:'eye-reload',
13
- continue:'owner-intent',handoff:'owner-intent',clean:'owner-clean',
14
- status:'owner-status',start:'owner-start',session:'owner-session'});
15
- // Existing timeout and receipt projection are part of the public action
16
- // behavior; a descriptor edit must not silently change side-effect handling.
17
- const builtinBehavior=Object.freeze({
18
- chat_text:[27000,true],chat_dom:[27000,true],
19
- chat_screenshot:[27000,false],reload:[27000,false],
20
- continue:[27000,true],handoff:[27000,true],clean:[27000,true],
21
- status:[27000,true],start:[310000,true],session:[90000,true]
22
- });
23
- const builtinRoute=Object.freeze({
24
- chat_text:['text.html','chat text'],chat_dom:['dom.html','chat dom'],
25
- chat_screenshot:['screenshot.html','chat screenshot'],
26
- reload:['reload.html','reload'],continue:['continue.html','continue'],
27
- handoff:['handoff.html','handoff'],clean:['clean.html','clean'],
28
- status:['status.html','status'],start:['start.html','start'],
29
- session:['session.html','session']
30
- });
31
- const generatedMarker='<!-- GENERATED BY build-actions.mjs -->';
32
- export async function compileActions(source=join(root,'capabilities'),
33
- extension=join(root,'extension')){
34
- const files=readdirSync(source).filter(f=>f.endsWith('.mjs')).sort();
35
- const ids=new Set(),pages=new Set(),clis=new Set(),actions=[];
36
- if(!files.length)throw fail('EXTENSION_ACTIONS_EMPTY');
37
- for(const file of files){
38
- if(!/^[a-z][a-z0-9_]*\.mjs$/.test(file))
39
- throw fail('EXTENSION_CAPABILITY_FILENAME_INVALID');
40
- const path=join(source,file);
41
- const hash=createHash('sha256').update(readFileSync(path)).digest('hex');
42
- const {capability:c}=await import(pathToFileURL(path).href+'?sha256='+hash);
43
- if(!c||c.id!==file.slice(0,-4)||
44
- !/^[a-z][a-z0-9_]*$/.test(c.id)||
45
- !/^[a-z][a-z0-9_-]*\.html$/.test(c.page)||
46
- !Array.isArray(c.cli)||!c.cli.length||
47
- c.cli.some(t=>typeof t!=='string'||!/^[a-z][a-z0-9-]*$/.test(t))||
48
- !Number.isSafeInteger(c.waitMs)||c.waitMs<1||c.waitMs>310000||
49
- typeof c.textResult!=='boolean'||typeof c.description!=='string'||
50
- !c.description.trim()||ids.has(c.id)||pages.has(c.page)||
51
- clis.has(c.cli.join(' ')))
52
- throw fail('EXTENSION_CAPABILITY_INVALID');
53
- ids.add(c.id);pages.add(c.page);clis.add(c.cli.join(' '));
54
- const newAction=!originals.includes(c.id);
55
- if(!newAction && privilegedKinds[c.id]!==c.kind)
56
- throw fail('EXTENSION_ACTION_AUTHORITY_CHANGED');
57
- if(!newAction && (c.page!==builtinRoute[c.id][0]||
58
- c.cli.join(' ')!==builtinRoute[c.id][1]))
59
- throw fail('EXTENSION_BUILTIN_ROUTE_CHANGED');
60
- if(!newAction && (c.waitMs!==builtinBehavior[c.id][0]||
61
- c.textResult!==builtinBehavior[c.id][1]))
62
- throw fail('EXTENSION_BUILTIN_BEHAVIOR_CHANGED');
63
- if(newAction && !c.textResult)
64
- throw fail('EXTENSION_READ_RESULT_REQUIRED');
65
- if(c.kind==='eye-read'&&(!c.id.startsWith('chat_')||
66
- !['text','dom'].includes(c.readMode)))
67
- throw fail('EXTENSION_EYE_READ_MODE_INVALID');
68
- const reviewedEntry=c.id==='entry_test' && c.kind==='entry-test'
69
- &&c.page==='entry_test.html' &&c.cli.join(' ')==='entry test'
70
- &&c.waitMs===310000 &&c.textResult===true;
71
- if(newAction && c.kind!=='eye-read' && !reviewedEntry)
72
- throw fail('EXTENSION_PRIVILEGED_ACTION_REVIEW_REQUIRED');
73
- if((c.id==='chat_text'&&c.readMode!=='text')||
74
- (c.id==='chat_dom'&&c.readMode!=='dom'))
75
- throw fail('EXTENSION_BUILTIN_EYE_MODE_CHANGED');
76
- const page=join(extension,c.page);
77
- if(reviewedEntry&&!existsSync(page))throw fail('EXTENSION_ENTRY_ACTION_PAGE_MISSING');
78
- const generated=existsSync(page)&&
79
- readFileSync(page,'utf8').startsWith(generatedMarker);
80
- if(!existsSync(page) && !newAction)
81
- throw fail('EXTENSION_ACTION_PAGE_MISSING');
82
- if(existsSync(page)&&!generated){
83
- const expected='actions/'+(c.id.startsWith('chat_')?c.id.slice(5):c.id)+'.js';
84
- if(!readFileSync(page,'utf8').includes(expected))
85
- throw fail('EXTENSION_ACTION_EXECUTOR_MISMATCH');
86
- }
87
- actions.push({...c,file,generated:newAction && c.kind==='eye-read'});
88
- }
89
- actions.sort((a,b)=>(
90
- (originals.indexOf(a.id)<0?99:originals.indexOf(a.id))-
91
- (originals.indexOf(b.id)<0?99:originals.indexOf(b.id))
92
- ||a.id.localeCompare(b.id)));
93
- const imports=actions.map((a,i)=>
94
- "import {capability as a"+i+"} from './capabilities/"+a.file+"';").join('\n');
95
- const node='// GENERATED by scripts/build-actions.mjs — do not edit.\n'+
96
- imports+'\nexport const actionCapabilities=Object.freeze(['+
97
- actions.map((_,i)=>'a'+i).join(',')+']);\n';
98
- const eye=Object.fromEntries(actions.filter(a=>a.kind.startsWith('eye-'))
99
- .map(a=>[a.id,{page:a.page,kind:a.kind,readMode:a.readMode??null}]));
100
- const browser='// GENERATED by scripts/build-actions.mjs — do not edit.\n'+
101
- 'globalThis.ChatLoopEyeCatalogV1=Object.freeze('+JSON.stringify(eye)+');\n';
102
- const aliases={};
103
- for(const a of actions.filter(a=>a.generated)){
104
- aliases[a.page]=generatedMarker+'\n<!doctype html><html><head><meta charset="utf-8">'+
105
- '<title>Chat Loop read action</title></head><body>'+
106
- '<p id="status"></p><p id="details"></p>'+
107
- '<script src="actions/common.js"></script>'+
108
- '<script src="actions/read-mode.js" data-action="'+a.id+
109
- '" data-read-mode="'+a.readMode+'"></script></body></html>\n';
110
- }
111
- return {node,browser,aliases};
112
- }
113
- async function main(){
114
- const ext=join(root,'extension'),expected=await compileActions();
115
- const manifest=JSON.parse(readFileSync(join(ext,'manifest.json'),'utf8'));
116
- const pkg=JSON.parse(readFileSync(join(root,'package.json'),'utf8'));
117
- if(manifest.version!==pkg.version||manifest.manifest_version!==3)
118
- throw fail('EXTENSION_PACKAGE_VERSION_MISMATCH');
119
- const targets=[[join(root,'actions.generated.mjs'),expected.node],
120
- [join(ext,'loop','action-catalog.generated.js'),expected.browser],
121
- ...Object.entries(expected.aliases).map(([page,html])=>[join(ext,page),html])];
122
- const orphan=readdirSync(ext).filter(f=>f.endsWith('.html')&&
123
- !Object.hasOwn(expected.aliases,f)&&
124
- readFileSync(join(ext,f),'utf8').startsWith(generatedMarker));
125
- if(process.argv.includes('--check')){
126
- if(orphan.length||targets.some(([file,value])=>!existsSync(file)||
127
- readFileSync(file,'utf8')!==value))
128
- throw fail('EXTENSION_ACTIONS_STALE');
129
- if(process.env.npm_lifecycle_event!=='prepack')
130
- console.log('EXTENSION_ACTIONS_CURRENT');
131
- }else{
132
- for(const page of orphan)unlinkSync(join(ext,page));
133
- for(const [file,value] of targets)writeFileSync(file,value);
134
- console.log('EXTENSION_ACTIONS_BUILT');
135
- }
136
- }
137
- if(process.argv[1]&&resolve(process.argv[1])===fileURLToPath(import.meta.url))
138
- await main();