@tomflow/chatloop-tools 0.4.17 → 0.4.18
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 +3 -0
- package/lib/adapters/mcp-child.mjs +2 -2
- package/lib/control.mjs +6 -3
- package/lib/extension-contract.mjs +80 -0
- package/lib/extension-proxy.mjs +7 -72
- package/lib/gateway.mjs +7 -1
- package/lib/tunnel.mjs +1 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,3 +35,6 @@ npx --yes --package=@tomflow/chatloop-tools@latest chatloop-tools upgrade
|
|
|
35
35
|
升级先独立安装新版本、核实 Supervisor 所有权与运行状态,再通过原 Supervisor 停止旧版、将 Tunnel MCP 启动命令固定到新版本并启动;不在 Tunnel 正处理 MCP 调用时直接自我重启。若返回 `BLOCKED`,先核对原任务回执,不要盲重试。`start` 全量入口在正常用户安装环境检测到版本差异时复用此流程;带隔离状态目录的测试不触发升级。详情见 [Local Tools 主文档](../../docs/local-tools.md)。
|
|
36
36
|
|
|
37
37
|
**Start 长页面准备(0.4.17)**:私人 MCP `chat_loop_extension__start` 的 CLI 子调用等待窗口最多 330 秒,仅用于允许 Chrome 安全校验和 ChatGPT 编辑器自然就绪。超时仍返回不确定错误,不重新启动或重发,必须单独查询 Status。
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
**下一源码候选 0.4.18(未发行)**:九个 Extension MCP 接口的名字、参数 Schema、CLI 映射和本机参数准入统一维护于 lib/extension-contract.mjs(纯契约、无进程副作用);extension-proxy.mjs 仅负责 npx 转发、超时和回执验证,Gateway 单独暴露一个安全限定 UUID 的 operation_status 查询。发布工具总数为 36:26 DC + 9 Extension + 1 Runtime 回执。发行/运行版本与源码候选需分开核验。
|
|
@@ -3,7 +3,7 @@ import {createRequire} from 'node:module';
|
|
|
3
3
|
import {dirname,join} from 'node:path';
|
|
4
4
|
import {mkdirSync,readFileSync} from 'node:fs';
|
|
5
5
|
import {randomUUID} from 'node:crypto';
|
|
6
|
-
import {paths,toolCallDeadlineMs} from '../control.mjs';
|
|
6
|
+
import {paths,toolCallDeadlineMs,PACKAGE_VERSION} from '../control.mjs';
|
|
7
7
|
|
|
8
8
|
const require=createRequire(import.meta.url);
|
|
9
9
|
const catalog=JSON.parse(readFileSync(new URL('../desktop-commander-tools.json',import.meta.url),'utf8'));
|
|
@@ -106,7 +106,7 @@ export function createMcpChildAdapter({records,log},options={}){
|
|
|
106
106
|
const handshake=(async()=>{
|
|
107
107
|
try{
|
|
108
108
|
const info=await request(rec,'initialize',{protocolVersion:'2025-03-26',
|
|
109
|
-
capabilities:{},clientInfo:{name:'chat-loop-local-tools',version:
|
|
109
|
+
capabilities:{},clientInfo:{name:'chat-loop-local-tools',version:PACKAGE_VERSION}},null);
|
|
110
110
|
if(!info?.protocolVersion)throw Object.assign(Error('Handshake failed'),{code:'MCP_HANDSHAKE_FAILED'});
|
|
111
111
|
child.stdin.write(JSON.stringify({jsonrpc:'2.0',method:'notifications/initialized'})+'\n');
|
|
112
112
|
const listed=await request(rec,'tools/list',{},null);
|
package/lib/control.mjs
CHANGED
|
@@ -15,7 +15,10 @@ export const toolCallDeadlineMs = args => {
|
|
|
15
15
|
};
|
|
16
16
|
export const ACTIONS = new Set(['start','stop','restart','status']);
|
|
17
17
|
export const directory = () => process.env.CHAT_LOOP_LOCAL_TOOLS_STATE_DIR || join(homedir(), '.chat-loop', 'local-tools');
|
|
18
|
-
export const paths = () =>
|
|
18
|
+
export const paths = () => {
|
|
19
|
+
const dir=directory();
|
|
20
|
+
return {dir,socket:join(dir,'control.sock'),lock:join(dir,'manager.lock'),log:join(dir,'events.jsonl')};
|
|
21
|
+
};
|
|
19
22
|
export function registry() {
|
|
20
23
|
const tools = [{id: 'desktop-commander', enabled: process.env.CHAT_LOOP_LOCAL_TOOLS_FIXTURES !== '1', kind: 'mcp-child'}];
|
|
21
24
|
if (!['1','both'].includes(process.env.CHAT_LOOP_LOCAL_TOOLS_FIXTURES)) {
|
|
@@ -34,8 +37,8 @@ export function ensurePrivateDir() {
|
|
|
34
37
|
if (!s.isDirectory() || s.isSymbolicLink() || (process.getuid && s.uid !== process.getuid()) || (s.mode & 0o077))
|
|
35
38
|
throw Object.assign(new Error('Insecure local-tools state directory'), {code:'INSECURE_STATE_DIR'});
|
|
36
39
|
}
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
function lockPresent() {return existsSync(paths().lock);}
|
|
41
|
+
function verifyOwner(hello) {
|
|
39
42
|
const p=paths();
|
|
40
43
|
const d=lstatSync(p.dir), l=lstatSync(p.lock), s=lstatSync(p.socket);
|
|
41
44
|
if (!d.isDirectory() || d.isSymbolicLink() || (d.mode&0o077) ||
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Pure public API: MCP schemas, CLI routes and their argument gate.
|
|
2
|
+
// No process creation, filesystem access, browser actions or user side effects.
|
|
3
|
+
const PROJECT_ID=/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/;
|
|
4
|
+
const REPLACE_SESSION=/^[0-9a-fA-F]{8}(?:-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}$/;
|
|
5
|
+
const TURN_TOKEN=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
6
|
+
const INTENT_ID=/^[a-f0-9]{32}$/;
|
|
7
|
+
const CONTROL_TOOLS=new Set(['start','continue','handoff']);
|
|
8
|
+
export const isControlTool=name=>CONTROL_TOOLS.has(name);
|
|
9
|
+
const extensionTool = (name,description,readOnlyHint,properties={},required=[]) => ({
|
|
10
|
+
name,description,inputSchema:{type:'object',properties,required,additionalProperties:false},
|
|
11
|
+
annotations:{readOnlyHint}
|
|
12
|
+
});
|
|
13
|
+
const endpoints=[
|
|
14
|
+
[['extension','chat','text'],extensionTool('chat_text','Read text from Chat Loop Extension current unique Chat Owner.',true)],
|
|
15
|
+
[['extension','chat','dom'],extensionTool('chat_dom','Read HTML from Chat Loop Extension current unique Chat Owner.',true)],
|
|
16
|
+
[['extension','chat','screenshot'],extensionTool('chat_screenshot','Capture PNG from Chat Loop Extension current unique Chat Owner; activates its tab.',false)],
|
|
17
|
+
[['extension','clean'],extensionTool('clean','Clear composer text in one exact verified ChatGPT tab; never sends.',false,
|
|
18
|
+
{tabId:{type:'integer',minimum:1}},['tabId'])],
|
|
19
|
+
[['extension','reload'],extensionTool('reload','Request reload of Chat Loop Extension; final health is unverified.',false)],
|
|
20
|
+
[['extension','status'],extensionTool('status','Read the unique current Mac Chrome Web Chat Owner; never starts or sends.',true)],
|
|
21
|
+
[['extension','start'],extensionTool('start','After confirmed intent and preflight, ask Extension to start one unique Web Chat; fails if any task owns it.',false,
|
|
22
|
+
{projectId:{type:'string',minLength:1,maxLength:128,pattern:PROJECT_ID.source},prompt:{type:'string',minLength:1,maxLength:4000,pattern:'\\S'},confirmed:{const:true},
|
|
23
|
+
replaceBlockedSessionId:{type:'string',pattern:REPLACE_SESSION.source}},
|
|
24
|
+
['projectId','prompt','confirmed'])],
|
|
25
|
+
[['extension','continue'],extensionTool('continue','Submit next-turn text with turnToken and nextPrompt; alternatively query its final status with turnToken and intentId. Only the Extension can send after Turn completion.',false,
|
|
26
|
+
{turnToken:{type:'string',pattern:TURN_TOKEN.source},nextPrompt:{type:'string',minLength:1,maxLength:4000,pattern:'\\S'},
|
|
27
|
+
intentId:{type:'string',pattern:INTENT_ID.source},lookup:{type:'boolean'}},['turnToken'])],
|
|
28
|
+
[['extension','handoff'],extensionTool('handoff','Submit an early Handoff with turnToken and optional reason; alternatively query receipt with turnToken and intentId. Extension still owns the timing and send.',false,
|
|
29
|
+
{turnToken:{type:'string',pattern:TURN_TOKEN.source},reason:{type:'string',maxLength:400},
|
|
30
|
+
intentId:{type:'string',pattern:INTENT_ID.source},lookup:{type:'boolean'}},['turnToken'])],
|
|
31
|
+
];
|
|
32
|
+
export const extensionTools=endpoints.map(([,tool])=>tool);
|
|
33
|
+
export const extensionCommand=name=>endpoints.find(([,tool])=>tool.name===name)?.[0]||null;
|
|
34
|
+
// The Native Host independently validates at its own trust boundary.
|
|
35
|
+
export function validExtensionArgs(name,args){
|
|
36
|
+
const endpoint=endpoints.find(([,tool])=>tool.name===name);
|
|
37
|
+
if(!endpoint||!args||typeof args!=='object'||Array.isArray(args))return false;
|
|
38
|
+
const schema=endpoint[1].inputSchema;
|
|
39
|
+
// Required fields must be supplied by the caller, not inherited from a prototype.
|
|
40
|
+
if(schema.required.some(k=>!Object.hasOwn(args,k))
|
|
41
|
+
|| Object.keys(args).some(k=>!Object.hasOwn(schema.properties,k)))
|
|
42
|
+
return false;
|
|
43
|
+
const control=isControlTool(name);
|
|
44
|
+
if(name==='clean'){
|
|
45
|
+
if(Object.keys(args).length!==1||!Number.isSafeInteger(args.tabId)||args.tabId<1)
|
|
46
|
+
return false;
|
|
47
|
+
}else if(!control && Object.keys(args).length)return false;
|
|
48
|
+
if(name==='start'){
|
|
49
|
+
if(!PROJECT_ID.test(args.projectId||'')
|
|
50
|
+
||typeof args.prompt!=='string'||!args.prompt.trim()||args.prompt.length>4000
|
|
51
|
+
||args.confirmed!==true
|
|
52
|
+
||(args.replaceBlockedSessionId!==undefined
|
|
53
|
+
&& !REPLACE_SESSION.test(args.replaceBlockedSessionId)))
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
if(control&&name!=='start'){
|
|
57
|
+
if(typeof args.turnToken!=='string'||!TURN_TOKEN.test(args.turnToken))
|
|
58
|
+
return false;
|
|
59
|
+
const hasId=Object.hasOwn(args,'intentId');
|
|
60
|
+
const hasLookup=Object.hasOwn(args,'lookup');
|
|
61
|
+
// Receipt query and newest-receipt lookup are mutually exclusive.
|
|
62
|
+
if(hasId||hasLookup){
|
|
63
|
+
if(hasId===hasLookup||Object.keys(args).length!==2)return false;
|
|
64
|
+
return hasId
|
|
65
|
+
? typeof args.intentId==='string'&&INTENT_ID.test(args.intentId)
|
|
66
|
+
: args.lookup===true;
|
|
67
|
+
}
|
|
68
|
+
if(name==='continue'){
|
|
69
|
+
return Object.keys(args).length===2
|
|
70
|
+
&& typeof args.nextPrompt==='string' && !!args.nextPrompt.trim()
|
|
71
|
+
&& args.nextPrompt.length<=4000
|
|
72
|
+
&& !/[\x00-\x1f]/.test(args.nextPrompt.replaceAll('\n',''));
|
|
73
|
+
}
|
|
74
|
+
// Handoff only needs the bound token; its short reason is optional.
|
|
75
|
+
return (Object.keys(args).length===1||Object.hasOwn(args,'reason'))
|
|
76
|
+
&& (args.reason===undefined || (typeof args.reason==='string'
|
|
77
|
+
&& args.reason.length<=400 && !/[\x00-\x1f]/.test(args.reason)));
|
|
78
|
+
}
|
|
79
|
+
return true;
|
|
80
|
+
}
|
package/lib/extension-proxy.mjs
CHANGED
|
@@ -3,91 +3,26 @@
|
|
|
3
3
|
import {spawn} from 'node:child_process';
|
|
4
4
|
import {readFileSync,statSync} from 'node:fs';
|
|
5
5
|
import {tmpdir} from 'node:os';
|
|
6
|
+
import {extensionCommand,validExtensionArgs,isControlTool} from './extension-contract.mjs';
|
|
7
|
+
export {extensionTools} from './extension-contract.mjs';
|
|
6
8
|
|
|
7
|
-
// Static signatures are discoverable even when npm is offline; control requests queue, never send in an MCP call.
|
|
8
|
-
// All executable behavior and Native Host integration belong to the Extension npm package.
|
|
9
|
-
const extensionTool = (name,description,readOnlyHint,properties={},required=[]) => ({
|
|
10
|
-
name,description,inputSchema:{type:'object',properties,required,additionalProperties:false},
|
|
11
|
-
annotations:{readOnlyHint}
|
|
12
|
-
});
|
|
13
|
-
export const extensionTools=[
|
|
14
|
-
extensionTool('chat_text','Read text from Chat Loop Extension current unique Chat Owner.',true),
|
|
15
|
-
extensionTool('chat_dom','Read HTML from Chat Loop Extension current unique Chat Owner.',true),
|
|
16
|
-
extensionTool('chat_screenshot','Capture PNG from Chat Loop Extension current unique Chat Owner; activates its tab.',false),
|
|
17
|
-
extensionTool('clean','Clear composer text in one exact verified ChatGPT tab; never sends.',false,
|
|
18
|
-
{tabId:{type:'integer',minimum:1}},['tabId']),
|
|
19
|
-
extensionTool('reload','Request reload of Chat Loop Extension; final health is unverified.',false),
|
|
20
|
-
extensionTool('status','Read the unique current Mac Chrome Web Chat Owner; never starts or sends.',true),
|
|
21
|
-
extensionTool('start','After confirmed intent and preflight, ask Extension to start one unique Web Chat; fails if any task owns it.',false,
|
|
22
|
-
{projectId:{type:'string',minLength:1,maxLength:128},prompt:{type:'string',minLength:1,maxLength:4000},confirmed:{const:true},
|
|
23
|
-
replaceBlockedSessionId:{type:'string',pattern:'^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$'}},
|
|
24
|
-
['projectId','prompt','confirmed']),
|
|
25
|
-
extensionTool('continue','Submit next-turn text with turnToken and nextPrompt; alternatively query its final status with turnToken and intentId. Only the Extension can send after Turn completion.',false,
|
|
26
|
-
{turnToken:{type:'string'},nextPrompt:{type:'string',minLength:1,maxLength:4000},
|
|
27
|
-
intentId:{type:'string',pattern:'^[a-f0-9]{32}$'},lookup:{type:'boolean'}},['turnToken']),
|
|
28
|
-
extensionTool('handoff','Submit an early Handoff with turnToken and optional reason; alternatively query receipt with turnToken and intentId. Extension still owns the timing and send.',false,
|
|
29
|
-
{turnToken:{type:'string'},reason:{type:'string',maxLength:400},
|
|
30
|
-
intentId:{type:'string',pattern:'^[a-f0-9]{32}$'},lookup:{type:'boolean'}},['turnToken']),
|
|
31
|
-
];
|
|
32
9
|
// Public CLI contract only: no require.resolve, extension source path or pinned npm dependency.
|
|
33
10
|
// Explicit @latest enables npm's default cache/revalidation behavior; --yes only accepts
|
|
34
11
|
// npm's install confirmation. No --offline, --no-install or forced network flags.
|
|
35
12
|
const EXTENSION_PACKAGE='@tomflow/chatloop-extension@latest';
|
|
36
13
|
const NPX_COMMAND=process.platform==='win32'?'npx.cmd':'npx';
|
|
37
14
|
export const extensionInvocation=name=>{
|
|
38
|
-
const command=
|
|
15
|
+
const command=extensionCommand(name);
|
|
39
16
|
if(!command)return null;
|
|
40
17
|
return {executable:NPX_COMMAND,
|
|
41
18
|
args:['--yes','--package='+EXTENSION_PACKAGE,'chatloop-extension',...command]};
|
|
42
19
|
};
|
|
43
|
-
const commands={
|
|
44
|
-
chat_text:['extension','chat','text'],
|
|
45
|
-
chat_dom:['extension','chat','dom'],
|
|
46
|
-
chat_screenshot:['extension','chat','screenshot'],
|
|
47
|
-
reload:['extension','reload'],
|
|
48
|
-
status:['extension','status'],
|
|
49
|
-
start:['extension','start'],
|
|
50
|
-
clean:['extension','clean'],
|
|
51
|
-
continue:['extension','continue'],
|
|
52
|
-
handoff:['extension','handoff']
|
|
53
|
-
};
|
|
54
20
|
const fail=code=>({isError:true,content:[{type:'text',text:code}]});
|
|
55
21
|
export async function forwardExtensionAction(name,args={}) {
|
|
56
22
|
const invocation=extensionInvocation(name);
|
|
57
|
-
if(!invocation||!
|
|
58
|
-
const control=
|
|
59
|
-
if(name==='clean')
|
|
60
|
-
if(Object.keys(args).length!==1||!Number.isSafeInteger(args.tabId)||args.tabId<1)
|
|
61
|
-
return fail('INVALID_ARGUMENT');
|
|
62
|
-
invocation.args.push(String(args.tabId));
|
|
63
|
-
}else if(!control && Object.keys(args).length)return fail('INVALID_ARGUMENT');
|
|
64
|
-
if(name==='start'){
|
|
65
|
-
if(Object.keys(args).some(k=>!['projectId','prompt','confirmed','replaceBlockedSessionId'].includes(k))
|
|
66
|
-
||!(/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/).test(args.projectId||'')
|
|
67
|
-
||typeof args.prompt!=='string'||!args.prompt.trim()||args.prompt.length>4000
|
|
68
|
-
||args.confirmed!==true
|
|
69
|
-
||(args.replaceBlockedSessionId!==undefined
|
|
70
|
-
&& !/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i.test(args.replaceBlockedSessionId)))
|
|
71
|
-
return fail('INVALID_ARGUMENT');
|
|
72
|
-
}
|
|
73
|
-
if(control&&name!=='start'){
|
|
74
|
-
const query=Object.hasOwn(args,'intentId')||args.lookup===true;
|
|
75
|
-
if(typeof args.turnToken!=='string' || !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(args.turnToken)
|
|
76
|
-
|| Object.keys(args).some(k=>k!=='turnToken' && (query?
|
|
77
|
-
k!==(args.lookup===true?'lookup':'intentId'):
|
|
78
|
-
name==='continue'?k!=='nextPrompt':k!=='reason'))
|
|
79
|
-
|| (query && args.lookup!==true
|
|
80
|
-
&& (typeof args.intentId!=='string'||!/^[a-f0-9]{32}$/.test(args.intentId))))
|
|
81
|
-
return fail('INVALID_ARGUMENT');
|
|
82
|
-
if(!query){
|
|
83
|
-
if(name==='continue' && (typeof args.nextPrompt!=='string'||!args.nextPrompt.trim()
|
|
84
|
-
|| args.nextPrompt.length>4000||/[\x00-\x1f]/.test(args.nextPrompt.replaceAll('\n',''))))
|
|
85
|
-
return fail('INVALID_ARGUMENT');
|
|
86
|
-
if(name==='handoff' && args.reason!==undefined
|
|
87
|
-
&& (typeof args.reason!=='string'||args.reason.length>400||/[\x00-\x1f]/.test(args.reason)))
|
|
88
|
-
return fail('INVALID_ARGUMENT');
|
|
89
|
-
}
|
|
90
|
-
}
|
|
23
|
+
if(!invocation||!validExtensionArgs(name,args))return fail('INVALID_ARGUMENT');
|
|
24
|
+
const control=isControlTool(name);
|
|
25
|
+
if(name==='clean')invocation.args.push(String(args.tabId));
|
|
91
26
|
const response=await new Promise(resolve=>{
|
|
92
27
|
const child=spawn(invocation.executable,invocation.args,{stdio:[control?'pipe':'ignore','pipe','pipe'],
|
|
93
28
|
cwd:tmpdir(),windowsHide:true,env:process.env});
|
|
@@ -105,7 +40,7 @@ export async function forwardExtensionAction(name,args={}) {
|
|
|
105
40
|
const line=stdout.trim().split('\n').filter(Boolean).at(-1);
|
|
106
41
|
let msg;try{msg=JSON.parse(line);}catch{return settle(fail('INVALID_EXTENSION_REPLY'));}
|
|
107
42
|
if(msg.contract!=='chat-loop.extension-cli.v1'||msg.event!=='RESULT'
|
|
108
|
-
||msg.command!==(name==='clean'?'extension clean '+args.tabId:
|
|
43
|
+
||msg.command!==(name==='clean'?'extension clean '+args.tabId:extensionCommand(name).join(' ')))return settle(fail('INVALID_EXTENSION_REPLY'));
|
|
109
44
|
if(!msg.ok||code!==0)return settle(fail(msg.error?.code||'EXTENSION_ACTION_FAILED'));
|
|
110
45
|
settle(msg.value);
|
|
111
46
|
});
|
package/lib/gateway.mjs
CHANGED
|
@@ -13,10 +13,13 @@ const prefix=id=>id.replaceAll('-','_')+'__';
|
|
|
13
13
|
// The pinned child's UI metadata advertises resources this tools-only Gateway does not serve.
|
|
14
14
|
// Do not expose those references until resources/read is explicitly supported.
|
|
15
15
|
const extEnabled=()=>process.env.CHAT_LOOP_LOCAL_TOOLS_FIXTURES!=='1';
|
|
16
|
+
// The only extra Gateway-owned API: read an existing operation receipt.
|
|
17
|
+
// Its identifier is always a generated UUID, never an arbitrary selector.
|
|
18
|
+
const RECEIPT_ID=/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/;
|
|
16
19
|
const receiptTool={name:'chat_loop_runtime__operation_status',
|
|
17
20
|
description:'Read a previously timed-out MCP request receipt without replaying its side effects.',
|
|
18
21
|
inputSchema:{type:'object',required:['requestId'],additionalProperties:false,
|
|
19
|
-
properties:{requestId:{type:'string'}}}};
|
|
22
|
+
properties:{requestId:{type:'string',pattern:RECEIPT_ID.source}}}};
|
|
20
23
|
const published=()=>[
|
|
21
24
|
...registry().filter(t=>t.enabled).flatMap(t=>
|
|
22
25
|
toolsFor(t).map(({_meta,...x})=>({...x,name:prefix(t.id)+x.name}))),
|
|
@@ -69,6 +72,9 @@ export function runGateway(){
|
|
|
69
72
|
return reply(m.id,failure('INVALID_ARGUMENT'));
|
|
70
73
|
try{
|
|
71
74
|
if(routed.toolId==='runtime'){
|
|
75
|
+
if(Object.keys(args).length!==1 || typeof args.requestId!=='string'
|
|
76
|
+
||!RECEIPT_ID.test(args.requestId))
|
|
77
|
+
return reply(m.id,failure('INVALID_ARGUMENT'));
|
|
72
78
|
const res=await talk({contract:CONTRACT,action:'receipt',requestId:randomUUID(),
|
|
73
79
|
targetRequestId:args.requestId},4000);
|
|
74
80
|
return reply(m.id,res.status==='OK'?{operation:res.operation}:failure('RECEIPT_UNAVAILABLE'));
|
package/lib/tunnel.mjs
CHANGED
|
@@ -37,11 +37,8 @@ export function bundledTunnel(){
|
|
|
37
37
|
}
|
|
38
38
|
export function tunnelDoctor(){
|
|
39
39
|
try{
|
|
40
|
+
// bundledTunnel already verifies both bundled binaries against provenance.
|
|
40
41
|
const b=bundledTunnel();
|
|
41
|
-
const cloudflared=createHash('sha256').update(readFileSync(b.cloudflared)).digest('hex');
|
|
42
|
-
const info=JSON.parse(readFileSync(join(b.base,'provenance.json'),'utf8'));
|
|
43
|
-
if(cloudflared!==info.cloudflaredSha256)
|
|
44
|
-
throw Object.assign(Error('Bundled cloudflared checksum mismatch'),{code:'INVALID_BUNDLE'});
|
|
45
42
|
return {status:'BUNDLED_READY',release:b.release,platform:b.platform,
|
|
46
43
|
executable:b.binary,cloudflared:b.cloudflared,verified:true,connection:'UNVERIFIED'};
|
|
47
44
|
}catch(e){return {status:'BLOCKED',code:e.code||'INVALID_BUNDLE',reason:e.message};}
|