@tomflow/chatloop-tools 0.4.11 → 0.4.12
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/lib/adapters/mcp-child.mjs +6 -3
- package/lib/gateway.mjs +1 -1
- package/package.json +1 -1
|
@@ -11,7 +11,10 @@ const fingerprint=tools=>JSON.stringify(tools.map(({name,inputSchema})=>({name,i
|
|
|
11
11
|
const expected=fingerprint(catalog);
|
|
12
12
|
const err=code=>({code});
|
|
13
13
|
const result=(tool,before,after,outcome,error=null,pid=null,evidence=null)=>({toolId:tool.id,enabled:tool.enabled,before,after,outcome,pid,evidence,error});
|
|
14
|
+
// Cold Desktop Commander initialization can exceed 9s on a busy macOS host.
|
|
15
|
+
// Startup has its own budget; ordinary tool calls keep the stricter deadline.
|
|
14
16
|
const timeout=ctx=>Math.max(0,Math.min(ctx.remaining(),9000));
|
|
17
|
+
export const startupHandshakeBudget=ctx=>Math.max(0,Math.min(ctx.remaining(),24000));
|
|
15
18
|
function entryFor(tool){
|
|
16
19
|
if(tool.id!=='desktop-commander')throw Object.assign(Error('Unknown MCP child'),{code:'UNKNOWN_TOOL'});
|
|
17
20
|
const pkg=require.resolve('@wonderwhy-er/desktop-commander/package.json');
|
|
@@ -69,7 +72,7 @@ export function createMcpChildAdapter({records,log}){
|
|
|
69
72
|
if(health.after==='RUNNING')return result(tool,before,'RUNNING','ALREADY_RUNNING',null,old.pid,'MCP_TOOLS_LIST');
|
|
70
73
|
return result(tool,before,'UNKNOWN','IDENTITY_UNCERTAIN',health.error,old.pid);
|
|
71
74
|
}
|
|
72
|
-
if(
|
|
75
|
+
if(startupHandshakeBudget(ctx)<100)return result(tool,before,before,'DEADLINE_EXPIRED',err('TIMEOUT'));
|
|
73
76
|
const home=join(paths().dir,'tools',tool.id,'home');
|
|
74
77
|
mkdirSync(home,{recursive:true,mode:0o700});
|
|
75
78
|
const env={HOME:home,PATH:process.env.PATH||'/usr/bin:/bin',LANG:process.env.LANG||'en_US.UTF-8',
|
|
@@ -80,10 +83,10 @@ export function createMcpChildAdapter({records,log}){
|
|
|
80
83
|
const rec=setup(tool,child);
|
|
81
84
|
try{
|
|
82
85
|
const info=await request(rec,'initialize',{protocolVersion:'2025-03-26',
|
|
83
|
-
capabilities:{},clientInfo:{name:'chat-loop-local-tools',version:'0.4.4'}},
|
|
86
|
+
capabilities:{},clientInfo:{name:'chat-loop-local-tools',version:'0.4.4'}},startupHandshakeBudget(ctx));
|
|
84
87
|
if(!info?.protocolVersion)throw Object.assign(Error('Handshake failed'),{code:'MCP_HANDSHAKE_FAILED'});
|
|
85
88
|
child.stdin.write(JSON.stringify({jsonrpc:'2.0',method:'notifications/initialized'})+'\n');
|
|
86
|
-
const listed=await request(rec,'tools/list',{},
|
|
89
|
+
const listed=await request(rec,'tools/list',{},startupHandshakeBudget(ctx));
|
|
87
90
|
if(!listed||fingerprint(listed.tools||[])!==expected)
|
|
88
91
|
throw Object.assign(Error('Tool schema changed'),{code:'SCHEMA_MISMATCH'});
|
|
89
92
|
rec.state='RUNNING';log('tool-start',{requestId:ctx.requestId,toolId:tool.id,pid:rec.pid});
|
package/lib/gateway.mjs
CHANGED
|
@@ -46,7 +46,7 @@ export function runGateway(){
|
|
|
46
46
|
return reject(m.id,-32602,'UNSUPPORTED_MCP_VERSION');
|
|
47
47
|
connected=true;
|
|
48
48
|
return reply(m.id,{protocolVersion:m.params.protocolVersion,
|
|
49
|
-
capabilities:{tools:{}},serverInfo:{name:'chat-loop-local-tools',version:'0.4.
|
|
49
|
+
capabilities:{tools:{}},serverInfo:{name:'chat-loop-local-tools',version:'0.4.12'}});
|
|
50
50
|
}
|
|
51
51
|
// A modern MCP client probes discovery before falling back to legacy initialize.
|
|
52
52
|
// We only implement the legacy handshake era, so report unsupported method.
|