@aerostack/gateway 0.15.28 → 0.15.29
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/dist/aerostack-connector.js +18 -0
- package/dist/index.js +26 -39
- package/dist/openclaw-connector.js +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import{homedir as Y}from"node:os";import{readFile as V}from"node:fs/promises";import{join as Q}from"node:path";import{execFile as H}from"node:child_process";const Z=process.env.AEROSTACK_WORKSPACE_URL||"https://api.aerostack.dev/api/gateway/ws/notification",m=process.env.AEROSTACK_TOKEN||"",v=parseInt(process.env.AEROSTACK_OPENCLAW_PORT||"18789",10),ee=6e4,te=1e3,ne=3e4,se=3e4,L=12e4,x=`aerostack-connector-${Date.now().toString(36)}`,h=Z.replace(/\/+$/,"");function o(e,t){const n=new Date().toISOString(),s=t?` ${JSON.stringify(t)}`:"";process.stderr.write(`[${n}] [INFO] ${e}${s}
|
|
4
|
+
`)}function g(e,t){const n=new Date().toISOString(),s=t?` ${JSON.stringify(t)}`:"";process.stderr.write(`[${n}] [WARN] ${e}${s}
|
|
5
|
+
`)}function p(e,t){const n=new Date().toISOString(),s=t?` ${JSON.stringify(t)}`:"";process.stderr.write(`[${n}] [ERROR] ${e}${s}
|
|
6
|
+
`)}async function w(e,t={},n=se){const s=new AbortController,a=setTimeout(()=>s.abort(),n);try{return await fetch(e,{...t,signal:s.signal})}finally{clearTimeout(a)}}let C=null,S=!1,$=null,E=0,D=0;const _=new Map,ae=100,oe=2e3,re=3e4,ie=3e4;let M=null;async function ce(){try{const e=Q(Y(),".openclaw","openclaw.json"),t=await V(e,"utf-8");return JSON.parse(t)?.gateway?.auth?.token??null}catch{return null}}async function b(){const e=await ce();if(!e)return g("No OpenClaw gateway token found, skipping WS control"),!1;const t=`ws://127.0.0.1:${v}`;return new Promise(n=>{try{const s=new WebSocket(t);C=s;const a=setTimeout(()=>{o("Gateway WS connect timeout");try{s.close()}catch{}n(!1)},1e4);s.onopen=()=>{clearTimeout(a),o("Gateway WS connected, sending handshake"),K({type:"req",id:String(++D),method:"connect",params:{minProtocol:3,maxProtocol:3,client:{id:"openclaw-tui",displayName:"Aerostack Connector",version:"1.0.0",platform:process.platform,mode:"cli"},auth:{token:e},scopes:["operator.read","operator.write","operator.admin"],caps:["tool-events","sessions"]}})},s.onmessage=c=>{try{const i=JSON.parse(String(c.data));le(i,n)}catch{}},s.onerror=()=>{clearTimeout(a),n(!1)},s.onclose=()=>{clearTimeout(a),C=null,S=!1,I||ge()}}catch{n(!1)}})}function K(e){try{C?.send(JSON.stringify(e))}catch{}}function le(e,t){if(e.type==="res"&&!S){e.ok?(S=!0,E=0,o("Gateway WS authenticated",{port:v}),t?.(!0),N("sessions.subscribe").then(n=>{n.ok&&o("Subscribed to gateway session events")})):(g("Gateway WS auth rejected",{error:e.error?.message}),t?.(!1));return}if(e.type==="res"&&e.id&&_.has(e.id)){const n=_.get(e.id);_.delete(e.id),n(e);return}e.type==="event"&&ue(e)}const T=new Map;function ue(e){const t=e.event,n=e.payload??{};if(t==="session.tool"){const s=n.data,a=s?.name??n.toolName??"unknown",c=s?.phase??"";(c==="start"||c==="end")&&me(a,c,"tool_call")}else if(t==="session.message"){const s=n.sessionKey??"",a=n.message,c=typeof a=="object"?a?.role:void 0;let i="";if(typeof a=="string")i=a;else if(a){const u=a.content;typeof u=="string"?i=u:Array.isArray(u)&&(i=u.map(f=>typeof f=="string"?f:f?.text??"").join("")),i||(i=a.text??n.text??"")}o("session.message",{sessionKey:s,role:c,textLength:i?.length??0});const r=T.get(s);r&&i&&c!=="user"&&(o("WS fast path: got agent response",{sessionKey:s,textLength:i.length}),r({text:i}))}else t==="sessions.changed"&&o("Gateway session changed",{key:n.sessionKey})}function N(e,t){return fe(e,t,1e4)}function fe(e,t,n=1e4){return new Promise(s=>{const a=String(++D),c=setTimeout(()=>{_.delete(a),s({type:"res",id:a,ok:!1,error:{code:"TIMEOUT",message:"timeout"}})},n);_.set(a,i=>{clearTimeout(c),s(i)}),K({type:"req",id:a,method:e,params:t})})}async function de(){if(!S){W("disconnected");return}const e=await N("health");e.ok?W("healthy",e.payload):W("unhealthy",{error:e.error?.message})}async function W(e,t){try{await w(`${h}/chat/heartbeat`,{method:"POST",headers:{Authorization:`Bearer ${m}`,"Content-Type":"application/json"},body:JSON.stringify({agent_type:"openclaw-connector",user_agent:"aerostack-connector/1.0.0",bridge_id:x,gateway_status:e,gateway_data:t})})}catch{}}function ge(){if(I||$||E>=ae)return;const e=Math.min(oe*Math.pow(2,Math.min(E,5)),re);E++,o(`Gateway WS reconnecting in ${e/1e3}s`,{attempt:E}),$=setTimeout(async()=>{$=null,S=!1,_.clear(),await b()},e)}function ye(){return new Promise(e=>{o("Restarting OpenClaw gateway"),H("openclaw",["gateway","restart"],{timeout:3e4},t=>{t?(p("Gateway restart failed",{error:t.message}),e(!1)):(o("Gateway restart triggered"),setTimeout(()=>{b()},5e3),e(!0))})})}async function he(e,t){const n=Date.now();o("Agent turn starting",{sessionKey:e,messageLength:t.length});const s="agent:main:main";if(S)try{const a=`aerostack-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,c=new Promise(r=>{const u=setTimeout(()=>{T.delete(s),r(null)},L);T.set(s,f=>{clearTimeout(u),T.delete(s),r(f)})});N("sessions.messages.subscribe",{key:s});const i=await N("sessions.send",{key:s,message:t,idempotencyKey:a});if(!i.ok)T.delete(s),g("Gateway WS sessions.send rejected, falling back to CLI",{error:i.error?.message});else{const r=await c,u=Date.now()-n;if(r?.text)return o("Agent turn completed (WS fast path)",{sessionKey:e,durationMs:u}),[{text:r.text}];g("No response received via WS events, falling back to CLI",{durationMs:u})}}catch(a){T.delete(s),g("Gateway WS fast path error, falling back to CLI",{error:a?.message})}return S||(g("Gateway disconnected, attempting reconnect before agent turn"),await b()||(g("Gateway unreachable, attempting restart"),await ye(),await new Promise(c=>setTimeout(c,8e3)))),new Promise((a,c)=>{H("openclaw",["agent","--agent","main","--json","--session-id",e,"-m",t],{timeout:L},(r,u)=>{const f=Date.now()-n;if(r){p("Agent turn failed",{sessionKey:e,durationMs:f,error:r.message}),c(r);return}let l=[];if(u)try{const d=JSON.parse(u.trim()),y=d?.result?.payloads;Array.isArray(y)&&y.length>0?l=y:(d.text||d.reply||d.message)&&(l=[{text:d.text||d.reply||d.message}])}catch{const d=u.trim().split(`
|
|
7
|
+
`).pop()||"";try{const y=JSON.parse(d);l=[{text:y.text||y.reply||y.message||d}]}catch{d&&(l=[{text:d}])}}l.length===0&&(l=[{text:`Processed your message (${f}ms).`}]),o("Agent turn completed (CLI fallback)",{sessionKey:e,durationMs:f,payloads:l.length}),a(l)})})}let I=!1,G=null;async function J(){try{const e=await w(`${h}/chat/heartbeat`,{method:"POST",headers:{Authorization:`Bearer ${m}`,"Content-Type":"application/json"},body:JSON.stringify({agent_type:"openclaw-connector",user_agent:"aerostack-connector/1.0.0",bridge_id:x})});e.ok?o("Heartbeat OK"):g("Heartbeat failed",{status:e.status})}catch(e){g("Heartbeat error",{error:e?.message})}}async function z(e,t){try{const n=await w(`${h}/chat/messages`,{method:"POST",headers:{Authorization:`Bearer ${m}`,"Content-Type":"application/json"},body:JSON.stringify({content:e.slice(0,1e4),session_id:t||G})});n.ok?o("Reply sent",{length:e.length,sessionId:t}):g("Reply failed",{status:n.status})}catch(n){p("Reply error",{error:n?.message})}}async function me(e,t,n){try{await w(`${h}/chat/tool-status`,{method:"POST",headers:{Authorization:`Bearer ${m}`,"Content-Type":"application/json"},body:JSON.stringify({tool_name:e,phase:t,category:n})})}catch{}}const P=new Map,U=50,F=10;function j(e,t,n){let s=P.get(e);s||(s=[],P.set(e,s)),s.push({role:t,content:n,ts:Date.now()}),s.length>U&&s.splice(0,s.length-U)}function pe(e){const t=P.get(e);return!t||t.length===0?"":`Previous conversation:
|
|
8
|
+
`+t.slice(-F).map(n=>`[${n.role==="user"?"Admin":"You (Agent)"}] ${n.content}`).join(`
|
|
9
|
+
`)+`
|
|
10
|
+
|
|
11
|
+
`}async function we(e){try{const t=await w(`${h}/chat/history?limit=${F}`,{headers:{Authorization:`Bearer ${m}`}});if(!t.ok)return;const n=await t.json();n.session_id&&(G=n.session_id);for(const s of n.messages??[]){const a=s.sender_type==="agent"?"agent":"user";j(n.session_id||e,a,s.content)}o("History seeded",{sessionId:n.session_id,count:n.messages?.length??0})}catch{}}let R=null,k=0,O=null,A=!1;function Se(e){return(e||"").replace(/[\r\n]+/g," ").replace(/\[/g,"(").replace(/\]/g,")").replace(/---/g,"\u2014")}async function _e(e,t){try{const n=await w(`${h}/chat/media/${e}/${t.filename}`,{headers:{Authorization:`Bearer ${m}`}},15e3);if(!n.ok)return g("Media fetch failed",{messageId:e,filename:t.filename,status:n.status}),null;const s=Buffer.from(await n.arrayBuffer());return`data:${t.mime_type};base64,${s.toString("base64")}`}catch(n){return g("Media fetch error",{messageId:e,filename:t.filename,error:n?.message}),null}}function Te(e,t){return`
|
|
12
|
+
[Attached files]
|
|
13
|
+
${e.map(s=>{const a=Math.round(s.size/1024),c=`${h}/chat/media/${t}/${s.filename}`;return`- ${s.filename} (${s.mime_type}, ${a}KB) \u2192 ${c}`}).join(`
|
|
14
|
+
`)}`}async function Ae(e){try{const t=JSON.parse(e);if(t.type!=="chat_message")return;const n=t.session_id,s=Se(t.sender_name||"Admin"),a=t.content||"",c=t.content_type||"text",i=t.message_id;let r=[];if(t.metadata_json)try{const l=JSON.parse(t.metadata_json);l?.v===1&&Array.isArray(l.attachments)&&(r=l.attachments)}catch{}if(!a&&r.length===0)return;o("Chat message received",{sender:s,sessionId:n,contentType:c,textLength:a.length,attachments:r.length}),n&&(G=n);const u=`aerostack-chat-${n||"_default"}`;let f=`[${s} via Aerostack Dashboard]:`;if(a&&(f+=` ${a}`),r.length>0&&i){f+=Te(r,i);const l=r.filter(d=>d.mime_type.startsWith("image/"));if(l.length>0){const y=(await Promise.all(l.slice(0,3).map(X=>_e(i,X)))).filter(Boolean);y.length>0&&(f+=`
|
|
15
|
+
[Image data (base64)]
|
|
16
|
+
${y.join(`
|
|
17
|
+
`)}`)}}j(n||"_default","user",a||`[${r.map(l=>l.filename).join(", ")}]`);try{const l=await he(u,f);for(const d of l){const y=(typeof d.text=="string"?d.text:String(d.text??"")).trim();y&&y.length>=2&&(j(n||"_default","agent",y),await z(y,n))}}catch(l){p("Agent turn failed, sending fallback",{error:l?.message}),await z("I received your message but encountered an error processing it. Please try again.",n)}}catch(t){p("handleChatMessage error",{error:t?.message})}}async function q(){if(!A){A=!0,R?.abort(),R=new AbortController;try{o("SSE connecting",{url:h});const e=await fetch(h,{method:"GET",headers:{Authorization:`Bearer ${m}`,Accept:"text/event-stream"},signal:R.signal});if(!e.ok||!e.body){g("SSE connect failed",{status:e.status}),k++,A=!1,B();return}o("SSE connected"),k=0;const t=e.body.getReader(),n=new TextDecoder;let s="";for(;;){const{done:a,value:c}=await t.read();if(a)break;s+=n.decode(c,{stream:!0});const i=s.split(`
|
|
18
|
+
`);s=i.pop()??"";let r="",u="";for(const f of i)f.startsWith("event: ")?r=f.slice(7).trim():f.startsWith("data: ")?u=f.slice(6):f===""&&r&&u&&(r==="aerostack_event"&&Ae(u),r="",u="")}o("SSE stream ended, reconnecting"),A=!1,B()}catch(e){if(e?.name==="AbortError"){A=!1;return}g("SSE error",{error:e?.message}),k++,A=!1,B()}}}function B(){if(O)return;const e=Math.min(te*Math.pow(2,k),ne);o(`SSE reconnecting in ${e/1e3}s`,{failures:k}),O=setTimeout(()=>{O=null,q()},e)}async function $e(){try{const e=await w(`${h}/chat/connection-test`,{headers:{Authorization:`Bearer ${m}`}},1e4);if(e.ok){const t=await e.json();return o(`Connected to "${t.workspace}"`,{tools:t.mcp_servers,token:t.token_name,role:t.token_role}),!0}else return e.status===401?(p("Token invalid \u2014 regenerate at dashboard \u2192 Workspace \u2192 Tokens"),!1):(g("Connection check failed",{status:e.status}),!1)}catch(e){return p("Connection check error",{error:e?.message}),!1}}async function Ee(){o("Aerostack Connector starting",{workspace:h,openclawPort:v,bridgeId:x}),m||(p("AEROSTACK_TOKEN is required"),process.exit(1)),await $e()||g("Connection verification failed, continuing anyway (will retry)"),await we("_default"),await b()?o("Gateway WS control layer active"):g("Gateway WS not reachable \u2014 will keep retrying"),M=setInterval(de,ie),await J();const n=setInterval(J,ee);q(),o("Connector ready \u2014 listening for dashboard chat messages");const s=()=>{I=!0,o("Shutting down"),clearInterval(n),M&&clearInterval(M),R?.abort(),O&&clearTimeout(O),$&&clearTimeout($);try{C?.close(1e3)}catch{}process.exit(0)};process.on("SIGTERM",s),process.on("SIGINT",s)}Ee().catch(e=>{p("Fatal error",{error:e?.message}),process.exit(1)});
|
package/dist/index.js
CHANGED
|
@@ -1,28 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import{Server as
|
|
4
|
-
`),process.exit(1)),
|
|
5
|
-
`),process.exit(1));let
|
|
6
|
-
`),process.exit(1)}
|
|
7
|
-
`);const
|
|
8
|
-
`);let
|
|
9
|
-
${
|
|
3
|
+
import{Server as he}from"@modelcontextprotocol/sdk/server/index.js";import{StdioServerTransport as fe}from"@modelcontextprotocol/sdk/server/stdio.js";import{ListToolsRequestSchema as ge,CallToolRequestSchema as _e,ListResourcesRequestSchema as ye,ReadResourceRequestSchema as we,ListPromptsRequestSchema as Ae,GetPromptRequestSchema as Ee}from"@modelcontextprotocol/sdk/types.js";import{readFile as Te,writeFile as Se}from"node:fs/promises";import{join as ke}from"node:path";import{homedir as Re}from"node:os";import{resolveApproval as Y}from"./resolution.js";import{startHookServer as Oe,installClaudeHook as Ce,stopHookServer as ve}from"./hook-server.js";import{OpenClawConnector as $e,resolveOpenClawToken as be}from"./openclaw-connector.js";import{info as u,warn as _,error as Ne}from"./logger.js";const se=ke(Re(),".openclaw","pre-authorized.json");async function xe(e){try{let s={};try{s=JSON.parse(await Te(se,"utf-8"))}catch{}s[e]=Date.now(),await Se(se,JSON.stringify(s))}catch{}}const X=process.env.AEROSTACK_WORKSPACE_URL,d=process.env.AEROSTACK_TOKEN;function H(e,s,o){const t=parseInt(e??String(s),10);return Number.isFinite(t)&&t>=o?t:s}const Q=H(process.env.AEROSTACK_APPROVAL_POLL_MS,3e3,500),Z=H(process.env.AEROSTACK_APPROVAL_TIMEOUT_MS,864e5,5e3),oe=H(process.env.AEROSTACK_REQUEST_TIMEOUT_MS,3e4,1e3),Pe=process.env.AEROSTACK_HOOK_SERVER!=="false",Ie=H(process.env.AEROSTACK_HOOK_PORT,18321,1024),Ue=process.env.AEROSTACK_HOOK_AUTO_INSTALL!=="false",Le=process.env.AEROSTACK_OPENCLAW_ENABLED!=="false",ae=H(process.env.AEROSTACK_OPENCLAW_PORT,18789,1024),De=process.env.AEROSTACK_OPENCLAW_TOKEN;X||(process.stderr.write(`ERROR: AEROSTACK_WORKSPACE_URL is required
|
|
4
|
+
`),process.exit(1)),d||(process.stderr.write(`ERROR: AEROSTACK_TOKEN is required
|
|
5
|
+
`),process.exit(1));let B;try{if(B=new URL(X),B.protocol!=="https:"&&B.protocol!=="http:")throw new Error("must be http or https")}catch{process.stderr.write(`ERROR: AEROSTACK_WORKSPACE_URL must be a valid HTTP(S) URL
|
|
6
|
+
`),process.exit(1)}B.protocol==="http:"&&!B.hostname.match(/^(localhost|127\.0\.0\.1)$/)&&process.stderr.write(`WARNING: Using HTTP (not HTTPS) \u2014 token will be sent in plaintext
|
|
7
|
+
`);const p=X.replace(/\/+$/,""),ne=crypto.randomUUID();function je(){return process.env.AEROSTACK_AGENT_TYPE?process.env.AEROSTACK_AGENT_TYPE:process.env.CLAUDECODE||process.env.CLAUDE_CODE?"claude-code":process.env.MCP_TRANSPORT==="stdio"?"mcp-stdio":"unknown"}const re=je();let b=null,L=Date.now();const Ke=3e4;async function v(e,s){const o={jsonrpc:"2.0",id:Date.now(),method:e,params:s??{}},t=new AbortController,n=setTimeout(()=>t.abort(),oe);try{const a=await fetch(p,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${d}`,"User-Agent":"aerostack-gateway/0.15.14","X-Agent-Id":"aerostack-gateway","X-Bridge-Id":ne,"X-Agent-Type":re},body:JSON.stringify(o),signal:t.signal});if(clearTimeout(n),(a.headers.get("content-type")??"").includes("text/event-stream")){const c=await a.text();return Me(c,o.id)}return await a.json()}catch(a){clearTimeout(n);const r=a instanceof Error?a.message:"Unknown error";return a instanceof Error&&a.name==="AbortError"?{jsonrpc:"2.0",id:o.id,error:{code:-32603,message:"Request timed out"}}:{jsonrpc:"2.0",id:o.id,error:{code:-32603,message:`HTTP error: ${r}`}}}}function Me(e,s){const o=e.split(`
|
|
8
|
+
`);let t=null;for(const n of o)if(n.startsWith("data: "))try{t=JSON.parse(n.slice(6))}catch{}return t??{jsonrpc:"2.0",id:s,error:{code:-32603,message:"Empty SSE response"}}}const He=new Set(["aerostack__guardian_report","aerostack__check_approval","aerostack__guardian_check"]);function Be(e,s){if(He.has(e))return;let o="other";const t=e.toLowerCase();t.includes("exec")||t.includes("bash")||t.includes("shell")||t.includes("command")||t.includes("run")?o="exec_command":t.includes("write")||t.includes("edit")||t.includes("create")||t.includes("patch")?o="file_write":t.includes("delete")||t.includes("remove")||t.includes("trash")||t.includes("unlink")?o="file_delete":t.includes("fetch")||t.includes("http")||t.includes("request")||t.includes("api")||t.includes("get")||t.includes("post")?o="api_call":t.includes("install")||t.includes("package")||t.includes("npm")||t.includes("pip")?o="package_install":t.includes("config")||t.includes("setting")||t.includes("env")?o="config_change":t.includes("deploy")||t.includes("publish")||t.includes("release")?o="deploy":t.includes("send")||t.includes("message")||t.includes("email")||t.includes("notify")||t.includes("slack")||t.includes("telegram")?o="message_send":(t.includes("read")||t.includes("query")||t.includes("search")||t.includes("list")||t.includes("get"))&&(o="data_access");let n;try{const a=JSON.stringify(s);n=a.length>500?a.slice(0,500)+"...":a}catch{n="(unable to serialize)"}v("tools/call",{name:"aerostack__guardian_report",arguments:{action:`${e}(${Object.keys(s).join(", ")})`,category:o,risk_level:"low",details:n}}).catch(()=>{})}const We=new Set(["aerostack__check_approval"]),ie=[{name:"aerostack__chat_check",description:"Check for new messages from the workspace owner. Call this periodically or when asked to check for instructions.",inputSchema:{type:"object",properties:{},required:[]}},{name:"aerostack__chat_reply",description:"Send a reply message to the workspace owner via Agent Chat.",inputSchema:{type:"object",properties:{message:{type:"string",description:"Your reply message to the workspace owner"}},required:["message"]}}],ze=new Set(ie.map(e=>e.name));function A(e){return e.replace(/[\r\n]+/g," ").replace(/\[/g,"(").replace(/\]/g,")").replace(/---/g,"\u2014")}const Fe=new Set(["image/jpeg","image/png","image/gif","image/webp"]),qe=2*1024*1024;async function ee(e,s,o,t,n){if(o!=="media"&&o!=="rich")return[{type:"text",text:`${A(n)}: ${A(t)}`}];let a=[];if(s)try{const c=JSON.parse(s);c?.v===1&&Array.isArray(c.attachments)&&(a=c.attachments)}catch{}if(a.length===0)return[{type:"text",text:`${A(n)}: ${A(t)}`}];const r=[];o==="rich"&&t?r.push({type:"text",text:`${A(n)}: ${A(t)}`}):a.length>0&&r.push({type:"text",text:`${A(n)} sent ${a.length} file(s):`});const i=e&&/^[a-zA-Z0-9_-]{1,128}$/.test(e)?e:null;for(const c of a){if(Fe.has(c.mime_type)&&c.size<=qe&&i)try{const C=`${p}/chat/media/${i}/${encodeURIComponent(c.filename)}`,w=await E(C,{headers:{Authorization:`Bearer ${d}`}});if(w.ok){const N=Buffer.from(await w.arrayBuffer()).toString("base64");r.push({type:"image",data:N,mimeType:c.mime_type});continue}}catch{}const T=Math.round(c.size/1024),O=T>=1024?`${(T/1024).toFixed(1)} MB`:`${T} KB`,f=A(c.filename.slice(0,200)),$=A(c.mime_type.slice(0,100)),S=i?`${p}/chat/media/${i}/${encodeURIComponent(c.filename)}`:"(unavailable)";r.push({type:"text",text:`Attached: ${f} (${$}, ${O}) \u2014 ${S}`})}return r}const W=[],Ge=100,x=new Map,ce=50,Je=100,le=10;let j=null;const ue=new Set,z=new Map;let P=null;function K(e,s,o){let t=x.get(e);if(!t){if(x.size>=Je){const n=x.keys().next().value;n&&x.delete(n)}t=[],x.set(e,t)}t.push({role:s,content:o,ts:Date.now()}),t.length>ce&&t.splice(0,t.length-ce)}async function Ve(e){if(!ue.has(e))try{const s=await E(`${p}/chat/history?limit=${le}`,{headers:{Authorization:`Bearer ${d}`}});if(!s.ok)return;const o=await s.json();o.session_id&&(j=o.session_id);for(const t of o.messages??[]){const n=t.sender_type==="agent"?"agent":"user",a=o.session_id||e;let r=x.get(a);r||(r=[],x.set(a,r));const i=t.content_type==="media"||t.content_type==="rich"?`${t.content} [has media attachment]`:t.content;r.push({role:n,content:i,ts:t.created_at,content_type:t.content_type})}ue.add(e),u("Thread history seeded from D1",{sessionId:o.session_id,count:o.messages?.length??0})}catch{}}function de(e){const s=x.get(e);return!s||s.length===0?"":`Previous conversation:
|
|
9
|
+
${s.slice(-le).map(n=>`[${n.role==="user"?"Admin":"You (Agent)"}] ${n.content}`).join(`
|
|
10
10
|
`)}
|
|
11
11
|
|
|
12
|
-
`}async function
|
|
13
|
-
|
|
14
|
-
`);return[
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
`);return[{type:"text",text:`${n}New messages from workspace owner:
|
|
19
|
-
|
|
20
|
-
${a}`}]}catch{return[{type:"text",text:"Failed to check messages."}]}}async function Ye(e){const t=typeof e.message=="string"?e.message.trim().slice(0,1e4):"";if(!t)return[{type:"text",text:"Error: message is required."}];try{const o=await T(`${d}/chat/messages`,{method:"POST",headers:{Authorization:`Bearer ${u}`,"Content-Type":"application/json"},body:JSON.stringify({content:t,session_id:x})});return o.ok?(H(x||"_default","agent",t),[{type:"text",text:"Reply sent to workspace owner."}]):[{type:"text",text:`Failed to send reply (HTTP ${o.status}).`}]}catch{return[{type:"text",text:"Failed to send reply."}]}}async function Xe(e,t){ze(e,t);const o=await _("tools/call",{name:e,arguments:t});if(o.error?.code===-32050){const n=o.error.data,a=n?.approval_id;if(!a||!/^[a-zA-Z0-9_-]{4,128}$/.test(a))return{jsonrpc:"2.0",id:o.id,error:{code:-32603,message:"Approval required but no approval_id returned"}};l("Tool gate: blocking until approval resolves",{tool:e,approvalId:a});const i=await Q({approvalId:a,wsUrl:n?.ws_url,pollUrl:n?.polling_url??`${d}/approval-status/${a}`,pollIntervalMs:ee,timeoutMs:te,token:u});l("Tool gate resolved",{tool:e,status:i.status}),W({approvalId:a,toolName:e,toolArgs:t,sessionKey:null,gate:"tool_gate",pollUrl:"",authToken:u},i.status,!0);const p=oe({approvalId:a,toolName:e,toolArgs:t,sessionKey:null,gate:"tool_gate",pollUrl:"",authToken:u},i);return{jsonrpc:"2.0",id:o.id,result:{content:[{type:"text",text:p}]}}}const r=o.result?._meta;if(r?.approval_id&&r?.status==="pending"){const n=r.approval_id;if(!/^[a-zA-Z0-9_-]{4,128}$/.test(n))return o;l("Permission gate: blocking until approval resolves",{tool:e,approvalId:n});const a=await Q({approvalId:n,wsUrl:r.ws_url,pollUrl:r.polling_url??`${d}/approval-status/${n}`,pollIntervalMs:ee,timeoutMs:te,token:u});l("Permission gate resolved",{tool:e,status:a.status}),W({approvalId:n,toolName:e,toolArgs:t,sessionKey:null,gate:"permission_gate",pollUrl:"",authToken:u},a.status,!0);const i=oe({approvalId:n,toolName:e,toolArgs:t,sessionKey:null,gate:"permission_gate",pollUrl:"",authToken:u},a);return{jsonrpc:"2.0",id:o.id,result:{content:[{type:"text",text:i}]}}}return o}function yt(e){Q({approvalId:e.approvalId,wsUrl:e.wsUrl,pollUrl:e.pollUrl,pollIntervalMs:ee,timeoutMs:te,token:e.authToken}).then(async t=>{l("Approval resolved",{tool:e.toolName,status:t.status,session:e.sessionKey});const o=oe(e,t),s=e.sessionKey??v?.getLastActiveSession()??null;if((t.status==="approved"||t.status==="executed")&&s&&xe(s).catch(()=>{}),s&&v){if(await v.sendToSession(s,o)){l("Agent resumed via sessions.send",{session:s,status:t.status}),W(e,t.status,!0);return}m("sessions.send failed, falling back to channel notification",{session:s})}try{await R.notification({method:"notifications/claude/channel",params:{content:o,meta:{tool_name:e.toolName,approval_id:e.approvalId,status:t.status,gate:e.gate}}}),l("Agent resumed via channel notification",{tool:e.toolName,status:t.status}),W(e,t.status,!0)}catch(r){m("Channel notification failed",{error:r instanceof Error?r.message:String(r)}),W(e,t.status,!1)}}).catch(t=>{m("Background approval resolver error",{error:t instanceof Error?t.message:String(t)})})}function W(e,t,o){const s=typeof e.toolArgs.action=="string"?e.toolArgs.action:null,r=s??e.toolName.replace(/^(?:\w+__)*aerostack__/,"")??e.toolName,n=s?`${r}`:`${r}(${Object.keys(e.toolArgs).join(", ")})`,a=o?"resume sent to agent":"session unavailable \u2014 resume not delivered";let i;t==="approved"||t==="executed"?i=o?`[RESUMED] ${n} \u2014 ${a}`:`[RESUME FAILED] ${n} \u2014 ${a}`:t==="rejected"?i=`[REJECTED] ${n} \u2014 rejection sent to agent`:t==="changes_requested"?i=`[CHANGES REQUESTED] ${n} \u2014 feedback sent to agent`:i=`[EXPIRED] ${n} \u2014 approval timed out, expiry sent to agent`,_("tools/call",{name:"aerostack__guardian_report",arguments:{action:i.slice(0,500),category:"approval",risk_level:"low",details:JSON.stringify({tool:e.toolName,approvalId:e.approvalId,status:t,delivered:o,session:e.sessionKey}).slice(0,500)}}).catch(()=>{})}function oe(e,t){const o=t.reviewer_note?.trim()||null,s=`${e.toolName}(${Object.keys(e.toolArgs).join(", ")})`;switch(t.status){case"approved":case"executed":return e.gate==="tool_gate"?["[APPROVAL RECEIVED] Your pending action has been approved.","",`Action: ${s}`,o?`Reviewer note: "${o}"`:null,"",`Please now execute this action: call ${e.toolName} with the same parameters as before.`].filter(r=>r!==null).join(`
|
|
21
|
-
`):["[APPROVAL RECEIVED] Your request has been approved by the workspace owner.",o?`Reviewer note: "${o}"`:null,"","You may now proceed with the action you requested approval for."].filter(r=>r!==null).join(`
|
|
22
|
-
`);case"changes_requested":return["[CHANGES REQUESTED] The workspace owner reviewed your action and requested changes.","",`Original action: ${s}`,`Reviewer feedback: "${o??"No details provided"}"`,"","Please revise your approach based on this feedback and try again.","Do NOT proceed with the original plan."].join(`
|
|
23
|
-
`);case"rejected":return["[REJECTED] The workspace owner denied this action.","",`Action: ${s}`,o?`Reason: "${o}"`:"No reason provided.","","Do not retry this action. If you believe this was a mistake, inform the user."].join(`
|
|
24
|
-
`);case"expired":return[`[EXPIRED] The approval request for "${s}" timed out \u2014 no decision was made.`,"","You may resubmit the request if the action is still needed."].join(`
|
|
25
|
-
`);default:return`[APPROVAL UPDATE] Status for "${s}": ${t.status}.`}}const B=`
|
|
12
|
+
`}async function E(e,s){const o=new AbortController,t=setTimeout(()=>o.abort(),oe);try{return await fetch(e,{...s,signal:o.signal})}finally{clearTimeout(t)}}async function Ye(){const e=j||"_default";if(await Ve(e),W.length>0){const s=W.splice(0);L=Date.now();const o=de(e),t=[];o&&t.push({type:"text",text:o}),t.push({type:"text",text:"New messages from workspace owner:"});for(const n of s){const a=await ee(n.message_id??null,n.metadata_json??null,n.content_type,n.content,n.sender_name);t.push(...a)}return t}try{const o=await E(`${p}/chat/pending?since=${L}`,{headers:{Authorization:`Bearer ${d}`}});if(!o.ok)return[{type:"text",text:"No new messages."}];const n=(await o.json()).messages??[];if(L=Date.now(),n.length===0)return[{type:"text",text:"No new messages from the workspace owner."}];for(const i of n)K(e,"user",i.content);const a=de(e),r=[];a&&r.push({type:"text",text:a}),r.push({type:"text",text:"New messages from workspace owner:"});for(const i of n){const c=await ee(i.id??null,i.metadata_json??null,i.content_type,i.content,i.sender_name);r.push(...c)}return r}catch{return[{type:"text",text:"Failed to check messages."}]}}async function Xe(e){const s=typeof e.message=="string"?e.message.trim().slice(0,1e4):"";if(!s)return[{type:"text",text:"Error: message is required."}];try{const o=await E(`${p}/chat/messages`,{method:"POST",headers:{Authorization:`Bearer ${d}`,"Content-Type":"application/json"},body:JSON.stringify({content:s,session_id:j})});return o.ok?(K(j||"_default","agent",s),[{type:"text",text:"Reply sent to workspace owner."}]):[{type:"text",text:`Failed to send reply (HTTP ${o.status}).`}]}catch{return[{type:"text",text:"Failed to send reply."}]}}async function Qe(e,s){Be(e,s);const o=await v("tools/call",{name:e,arguments:s});if(o.error?.code===-32050){const a=o.error.data,r=a?.approval_id;if(!r||!/^[a-zA-Z0-9_-]{4,128}$/.test(r))return{jsonrpc:"2.0",id:o.id,error:{code:-32603,message:"Approval required but no approval_id returned"}};u("Tool gate: blocking until approval resolves",{tool:e,approvalId:r});const i=await Y({approvalId:r,wsUrl:a?.ws_url,pollUrl:a?.polling_url??`${p}/approval-status/${r}`,pollIntervalMs:Q,timeoutMs:Z,token:d});u("Tool gate resolved",{tool:e,status:i.status}),F({approvalId:r,toolName:e,toolArgs:s,sessionKey:null,gate:"tool_gate",pollUrl:"",authToken:d},i.status,!0);const c=te({approvalId:r,toolName:e,toolArgs:s,sessionKey:null,gate:"tool_gate",pollUrl:"",authToken:d},i);return{jsonrpc:"2.0",id:o.id,result:{content:[{type:"text",text:c}]}}}const n=o.result?._meta;if(n?.approval_id&&n?.status==="pending"){const a=n.approval_id;if(!/^[a-zA-Z0-9_-]{4,128}$/.test(a))return o;u("Permission gate: blocking until approval resolves",{tool:e,approvalId:a});const r=await Y({approvalId:a,wsUrl:n.ws_url,pollUrl:n.polling_url??`${p}/approval-status/${a}`,pollIntervalMs:Q,timeoutMs:Z,token:d});u("Permission gate resolved",{tool:e,status:r.status}),F({approvalId:a,toolName:e,toolArgs:s,sessionKey:null,gate:"permission_gate",pollUrl:"",authToken:d},r.status,!0);const i=te({approvalId:a,toolName:e,toolArgs:s,sessionKey:null,gate:"permission_gate",pollUrl:"",authToken:d},r);return{jsonrpc:"2.0",id:o.id,result:{content:[{type:"text",text:i}]}}}return o}function yt(e){Y({approvalId:e.approvalId,wsUrl:e.wsUrl,pollUrl:e.pollUrl,pollIntervalMs:Q,timeoutMs:Z,token:e.authToken}).then(async s=>{u("Approval resolved",{tool:e.toolName,status:s.status,session:e.sessionKey});const o=te(e,s),t=e.sessionKey??b?.getLastActiveSession()??null;if((s.status==="approved"||s.status==="executed")&&t&&xe(t).catch(()=>{}),t&&b){if(await b.sendToSession(t,o)){u("Agent resumed via sessions.send",{session:t,status:s.status}),F(e,s.status,!0);return}_("sessions.send failed, falling back to channel notification",{session:t})}try{await I.notification({method:"notifications/claude/channel",params:{content:o,meta:{tool_name:e.toolName,approval_id:e.approvalId,status:s.status,gate:e.gate}}}),u("Agent resumed via channel notification",{tool:e.toolName,status:s.status}),F(e,s.status,!0)}catch(n){_("Channel notification failed",{error:n instanceof Error?n.message:String(n)}),F(e,s.status,!1)}}).catch(s=>{_("Background approval resolver error",{error:s instanceof Error?s.message:String(s)})})}function F(e,s,o){const t=typeof e.toolArgs.action=="string"?e.toolArgs.action:null,n=t??e.toolName.replace(/^(?:\w+__)*aerostack__/,"")??e.toolName,a=t?`${n}`:`${n}(${Object.keys(e.toolArgs).join(", ")})`,r=o?"resume sent to agent":"session unavailable \u2014 resume not delivered";let i;s==="approved"||s==="executed"?i=o?`[RESUMED] ${a} \u2014 ${r}`:`[RESUME FAILED] ${a} \u2014 ${r}`:s==="rejected"?i=`[REJECTED] ${a} \u2014 rejection sent to agent`:s==="changes_requested"?i=`[CHANGES REQUESTED] ${a} \u2014 feedback sent to agent`:i=`[EXPIRED] ${a} \u2014 approval timed out, expiry sent to agent`,v("tools/call",{name:"aerostack__guardian_report",arguments:{action:i.slice(0,500),category:"approval",risk_level:"low",details:JSON.stringify({tool:e.toolName,approvalId:e.approvalId,status:s,delivered:o,session:e.sessionKey}).slice(0,500)}}).catch(()=>{})}function te(e,s){const o=s.reviewer_note?.trim()||null,t=`${e.toolName}(${Object.keys(e.toolArgs).join(", ")})`;switch(s.status){case"approved":case"executed":return e.gate==="tool_gate"?["[APPROVAL RECEIVED] Your pending action has been approved.","",`Action: ${t}`,o?`Reviewer note: "${o}"`:null,"",`Please now execute this action: call ${e.toolName} with the same parameters as before.`].filter(n=>n!==null).join(`
|
|
13
|
+
`):["[APPROVAL RECEIVED] Your request has been approved by the workspace owner.",o?`Reviewer note: "${o}"`:null,"","You may now proceed with the action you requested approval for."].filter(n=>n!==null).join(`
|
|
14
|
+
`);case"changes_requested":return["[CHANGES REQUESTED] The workspace owner reviewed your action and requested changes.","",`Original action: ${t}`,`Reviewer feedback: "${o??"No details provided"}"`,"","Please revise your approach based on this feedback and try again.","Do NOT proceed with the original plan."].join(`
|
|
15
|
+
`);case"rejected":return["[REJECTED] The workspace owner denied this action.","",`Action: ${t}`,o?`Reason: "${o}"`:"No reason provided.","","Do not retry this action. If you believe this was a mistake, inform the user."].join(`
|
|
16
|
+
`);case"expired":return[`[EXPIRED] The approval request for "${t}" timed out \u2014 no decision was made.`,"","You may resubmit the request if the action is still needed."].join(`
|
|
17
|
+
`);default:return`[APPROVAL UPDATE] Status for "${t}": ${s.status}.`}}const q=`
|
|
26
18
|
=== AEROSTACK GUARDIAN POLICY (MANDATORY) ===
|
|
27
19
|
|
|
28
20
|
You are operating under Aerostack workspace monitoring. These rules apply to ALL actions:
|
|
@@ -50,32 +42,27 @@ or before starting a new one, call aerostack__chat_check to see if the owner sen
|
|
|
50
42
|
If there are messages, read them carefully and respond using aerostack__chat_reply. This keeps
|
|
51
43
|
the owner informed and allows them to steer your work in real time.
|
|
52
44
|
=== END WORKSPACE CHAT ===
|
|
53
|
-
`.trim(),
|
|
45
|
+
`.trim(),Ze=["delete","remove","drop","truncate","destroy","wipe","reset","deploy","publish","release","push","exec","shell","bash","run","command","terminal","install","uninstall","send","email","notify","webhook"];function et(e,s){const o=e.toLowerCase(),t=Ze.some(a=>o.includes(a)),n=s??"";return t?`[REQUIRES GUARDIAN APPROVAL] ${n}`.trim():n}let pe=null;async function M(){if(pe)return;const e=await v("initialize",{protocolVersion:"2024-11-05",capabilities:{},clientInfo:{name:"aerostack-gateway",version:"0.15.14"}});if(e.result){const s=e.result,o=s.instructions??"";pe={protocolVersion:s.protocolVersion??"2024-11-05",instructions:o?`${o}
|
|
54
46
|
|
|
55
|
-
${
|
|
56
|
-
`);n.unshift({type:"text",text:`--- WORKSPACE OWNER MESSAGE ---
|
|
57
|
-
${O}
|
|
58
|
-
--- END MESSAGE \u2014 please acknowledge ---`})}}}catch{}return{content:n}});const et={uri:"aerostack://guardian/policy",name:"Aerostack Guardian Policy",description:"Mandatory workspace monitoring policy. Read this to understand required approval workflows.",mimeType:"text/plain"};R.setRequestHandler(we,async()=>{await U();const e=await _("resources/list");if(e.error)throw new Error(e.error.message);const t=e.result;return{resources:[et,...t.resources??[]]}}),R.setRequestHandler(Ae,async e=>{if(await U(),e.params.uri==="aerostack://guardian/policy")return{contents:[{uri:e.params.uri,text:B,mimeType:"text/plain"}]};const t=await _("resources/read",{uri:e.params.uri});if(t.error)throw new Error(t.error.message);return{contents:t.result.contents??[]}}),R.setRequestHandler(Ee,async()=>{await U();const e=await _("prompts/list");if(e.error)throw new Error(e.error.message);return{prompts:e.result.prompts??[]}}),R.setRequestHandler(Te,async e=>{await U();const t=await _("prompts/get",{name:e.params.name,arguments:e.params.arguments});if(t.error)throw new Error(t.error.message);return{messages:t.result.messages??[]}});async function tt(){const e=t=>process.stderr.write(t+`
|
|
47
|
+
${q}`:q}}}const I=new he({name:"aerostack-gateway",version:"0.15.14"},{capabilities:{tools:{},resources:{},prompts:{},experimental:{"claude/channel":{}}},instructions:q});I.setRequestHandler(ge,async()=>{await M();const e=await v("tools/list");if(e.error)throw new Error(e.error.message);const o=(e.result.tools??[]).filter(t=>!We.has(t.name)).map(t=>({...t,description:et(t.name,t.description)}));return o.push(...ie),{tools:o}}),I.setRequestHandler(_e,async e=>{await M();const{name:s,arguments:o}=e.params;if(ze.has(s))return{content:s==="aerostack__chat_check"?await Ye():await Xe(o??{})};const t=await Qe(s,o??{});if(t.error)return{content:[{type:"text",text:`Error: ${t.error.message}`}],isError:!0};const a=t.result.content??[{type:"text",text:JSON.stringify(t.result)}];if(Date.now()-L>Ke)try{const i=await E(`${p}/chat/pending?since=${L}`,{headers:{Authorization:`Bearer ${d}`}});if(i.ok){const R=(await i.json()).messages??[];if(L=Date.now(),R.length>0){const T=[];for(const f of R){const $=await ee(f.id??null,f.metadata_json??null,f.content_type,f.content,f.sender_name);T.push(...$)}const O=[{type:"text",text:"--- WORKSPACE OWNER MESSAGE ---"},...T,{type:"text",text:"--- END MESSAGE \u2014 please acknowledge ---"}];a.unshift(...O)}}}catch{}return{content:a}});const tt={uri:"aerostack://guardian/policy",name:"Aerostack Guardian Policy",description:"Mandatory workspace monitoring policy. Read this to understand required approval workflows.",mimeType:"text/plain"};I.setRequestHandler(ye,async()=>{await M();const e=await v("resources/list");if(e.error)throw new Error(e.error.message);const s=e.result;return{resources:[tt,...s.resources??[]]}}),I.setRequestHandler(we,async e=>{if(await M(),e.params.uri==="aerostack://guardian/policy")return{contents:[{uri:e.params.uri,text:q,mimeType:"text/plain"}]};const s=await v("resources/read",{uri:e.params.uri});if(s.error)throw new Error(s.error.message);return{contents:s.result.contents??[]}}),I.setRequestHandler(Ae,async()=>{await M();const e=await v("prompts/list");if(e.error)throw new Error(e.error.message);return{prompts:e.result.prompts??[]}}),I.setRequestHandler(Ee,async e=>{await M();const s=await v("prompts/get",{name:e.params.name,arguments:e.params.arguments});if(s.error)throw new Error(s.error.message);return{messages:s.result.messages??[]}});async function st(){const e=s=>process.stderr.write(s+`
|
|
59
48
|
`);e(`
|
|
60
49
|
Aerostack Connection Check
|
|
61
|
-
`);try{const
|
|
50
|
+
`);try{const s=await fetch(`${p}/chat/connection-test`,{headers:{Authorization:`Bearer ${d}`},signal:AbortSignal.timeout(1e4)});s.ok||(s.status===401&&(e(" \u2705 Workspace URL reachable"),e(" \u274C Token invalid (HTTP 401)"),e(`
|
|
62
51
|
Fix: Regenerate token at your dashboard \u2192 Workspace \u2192 Tokens
|
|
63
|
-
`),process.exit(1)),e(` \u274C Workspace unreachable (HTTP ${
|
|
52
|
+
`),process.exit(1)),e(` \u274C Workspace unreachable (HTTP ${s.status})`),e(`
|
|
64
53
|
Fix: Check AEROSTACK_WORKSPACE_URL is correct
|
|
65
|
-
`),process.exit(1));const o=await
|
|
54
|
+
`),process.exit(1));const o=await s.json();e(` \u2705 Workspace URL reachable (${p})`),e(` \u2705 Token valid (${o.token_name}, role: ${o.token_role})`),e(` \u2705 Workspace connected ("${o.workspace}")`),e(` \u2705 Tools available (${o.mcp_servers} tools)`);try{const t=await fetch(`${p}/chat/heartbeat`,{method:"POST",headers:{Authorization:`Bearer ${d}`,"Content-Type":"application/json"},body:JSON.stringify({agent_type:"check",user_agent:"aerostack-gateway/check",bridge_id:"check"}),signal:AbortSignal.timeout(1e4)});e(t.ok?" \u2705 Dashboard registration (bridge visible in admin)":` \u26A0\uFE0F Dashboard registration (returned ${t.status})`)}catch{e(" \u26A0\uFE0F Dashboard registration (heartbeat failed \u2014 non-fatal)")}e(`
|
|
66
55
|
All checks passed. Your agent is connected.`),e(` Dashboard: ${o.dashboard_url||"https://app.aerostack.dev"}
|
|
67
56
|
`),o.mcp_servers===0&&e(` Note: 0 tools found. Add MCP servers or functions to your workspace first.
|
|
68
|
-
`),process.exit(0)}catch(
|
|
57
|
+
`),process.exit(0)}catch(s){s?.name==="TimeoutError"||s?.name==="AbortError"?(e(" \u274C Workspace unreachable (timeout after 10s)"),e(`
|
|
69
58
|
Fix: Check AEROSTACK_WORKSPACE_URL and your network connection
|
|
70
|
-
`)):(e(` \u274C Connection failed (${
|
|
59
|
+
`)):(e(` \u274C Connection failed (${s?.message??"unknown error"})`),e(`
|
|
71
60
|
Fix: Check AEROSTACK_WORKSPACE_URL is correct
|
|
72
|
-
`)),process.exit(1)}}async function
|
|
73
|
-
`);
|
|
61
|
+
`)),process.exit(1)}}async function ot(){try{const e=await fetch(`${p}/chat/connection-test`,{headers:{Authorization:`Bearer ${d}`},signal:AbortSignal.timeout(5e3)});if(e.ok){const s=await e.json();u(`Connected to "${s.workspace}" (${s.mcp_servers} tools)`,{dashboard:"https://app.aerostack.dev"})}else e.status===401?_("Token invalid \u2014 regenerate at dashboard \u2192 Workspace \u2192 Tokens"):_("Connection check failed",{status:e.status})}catch{_("Could not verify connection (non-fatal)")}}async function at(){u("Connecting to workspace",{url:p});const e=new fe;await I.connect(e),u("Ready",{url:p}),ot().catch(()=>{});const s=()=>{E(`${p}/chat/heartbeat`,{method:"POST",headers:{Authorization:`Bearer ${d}`,"Content-Type":"application/json"},body:JSON.stringify({agent_type:re,user_agent:"aerostack-gateway/0.15.14",bridge_id:ne})}).catch(()=>{})};s();const o=setInterval(s,12e4);if(process.on("exit",()=>clearInterval(o)),Pe)try{const n=await Oe(async a=>{try{const r=await fetch(`${p}/guardian-batch`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${d}`,"User-Agent":"aerostack-gateway/0.15.14","X-Agent-Id":"aerostack-gateway"},body:JSON.stringify({events:a})});return r.ok?(await r.json()).config?.hook_tracking??null:null}catch{return null}},Ie);Ue&&await Ce(n)&&u("Claude Code hook auto-installed",{port:n})}catch(t){_("Hook server failed to start (non-fatal)",{error:t instanceof Error?t.message:String(t)})}if(Le)try{const t=De??await be();t?(b=new $e({port:ae,token:t,rpcCall:v,onToolEvent:a=>{const r=P;if(!r)return;const i=z.get(r);if(i){if(a.phase==="start")i.push({name:a.toolName,category:a.category,started_at:Date.now(),ended_at:null,duration_ms:null,status:"running",args_summary:a.summary});else if(a.phase==="end"){const c=[...i].reverse().find(R=>R.name===a.toolName&&R.status==="running");c&&(c.ended_at=Date.now(),c.duration_ms=c.ended_at-c.started_at,c.status=a.error?"error":"success",a.error&&(c.error=a.error))}E(`${p}/chat/tool-status`,{method:"POST",headers:{Authorization:`Bearer ${d}`,"Content-Type":"application/json"},body:JSON.stringify({tool_name:a.toolName,phase:a.phase,category:a.category})}).catch(()=>{})}}}),await b.connect()?u("OpenClaw connector started",{port:ae}):(u("OpenClaw gateway not reachable, skipping connector"),b=null)):u("OpenClaw integration skipped (no token found)")}catch(t){_("OpenClaw connector failed (non-fatal)",{error:t instanceof Error?t.message:String(t)})}process.env.AEROSTACK_CHAT_LISTENER!=="false"&&nt()}let G=null,J=!1;function nt(){J=!1,G&&G.abort();let e=null,s=0;const o=async()=>{if(J)return;const n=new AbortController;G=n;try{const a=await fetch(p,{method:"GET",headers:{Authorization:`Bearer ${d}`,Accept:"text/event-stream"},signal:n.signal});if(!a.ok||!a.body){_("Chat event listener: failed to connect",{status:a.status}),s++,t();return}u("Chat event listener connected"),s=0;const r=a.body.getReader(),i=new TextDecoder;let c="";for(;;){const{done:R,value:T}=await r.read();if(R)break;c+=i.decode(T,{stream:!0});const O=c.split(`
|
|
62
|
+
`);c=O.pop()??"";let f="",$="";for(const S of O)S.startsWith("event: ")?f=S.slice(7).trim():S.startsWith("data: ")?$=S.slice(6):S===""&&f&&$&&(f==="aerostack_event"&&it($),f="",$="")}u("Chat event listener: stream ended, reconnecting"),t()}catch(a){if(a?.name==="AbortError")return;_("Chat event listener error",{error:a?.message}),s++,t()}},t=()=>{if(J||e)return;const n=Math.min(2e3*Math.pow(2,s),3e4);u(`Chat event listener: reconnecting in ${n/1e3}s (failures: ${s})`),e=setTimeout(()=>{e=null,o()},n)};o()}function rt(){J=!0,G?.abort()}async function it(e){try{const s=JSON.parse(e);if(s.type!=="chat_message")return;let o=[];if(s.metadata_json)try{const y=JSON.parse(s.metadata_json);y?.v===1&&Array.isArray(y.attachments)&&(o=y.attachments)}catch{}const t=!!s.content&&s.content_type!=="media",n=o.length>0;if(!t&&!n)return;const a=s.session_id;u("Chat message received from admin",{sender:s.sender_name,sessionId:a,contentType:s.content_type,attachments:o.length});const r=/^[a-zA-Z0-9_-]{1,128}$/.test(s.message_id??"")?s.message_id:null,i=o.map(y=>{const N=Math.round(y.size/1024),V=N>=1024?`${(N/1024).toFixed(1)} MB`:`${N} KB`,D=A((y.filename||"file").slice(0,200)),k=A((y.mime_type||"application/octet-stream").slice(0,100)),m=r?`${p}/chat/media/${r}/${encodeURIComponent(y.filename)}`:"(unavailable)";return`[Attached: ${D} (${k}, ${V}) \u2014 ${m}]`}),c=i.length>0?`
|
|
74
63
|
`+i.join(`
|
|
75
|
-
`):"",
|
|
76
|
-
`+i.map(
|
|
64
|
+
`):"",R=t?s.content+(c?`
|
|
65
|
+
`+i.map(y=>y).join(`
|
|
77
66
|
`):""):i.join(`
|
|
78
|
-
`);
|
|
79
|
-
|
|
80
|
-
`,Y=`${V}${J}[${O}]: ${D}`;f("openclaw",["agent","--agent","main","--json","--session-id",S,"-m",Y],{timeout:12e4},async(X,z)=>{let P=[];if(!X&&z)try{const c=JSON.parse(z.trim()),g=c?.result?.payloads;Array.isArray(g)&&g.length>0?P=g:(c.text||c.reply||c.message)&&(P=[{text:c.text||c.reply||c.message}])}catch{const c=z.trim().split(`
|
|
81
|
-
`).pop()||z.trim();c&&(P=[{text:c}])}P.length===0&&(P=[{text:`Message received. I'll process "${E.slice(0,100)}" shortly.`}]),await new Promise(c=>setTimeout(c,500));for(const c of N)c.status==="running"&&(c.status="timeout",c.ended_at=Date.now(),c.duration_ms=c.ended_at-c.started_at);if(N.length>0){const c=N.reduce((h,C)=>h+(C.duration_ms||0),0),g=N.length;try{await T(`${d}/chat/messages`,{method:"POST",headers:{Authorization:`Bearer ${u}`,"Content-Type":"application/json"},body:JSON.stringify({content:`Used ${g} tool${g>1?"s":""}`,content_type:"tool_activity",session_id:n,metadata:JSON.stringify({v:1,tools:N.map(h=>({name:h.name,category:h.category,duration_ms:h.duration_ms,status:h.status,args_summary:h.args_summary?.slice(0,500),error:h.error?.slice(0,500)})),total_duration_ms:c})})})}catch{}}q.delete(b),I===b&&(I=null);for(const c of P){const g=c.text?.trim()||"";if(c.mediaUrl){let h=!1;try{h=new URL(c.mediaUrl).protocol==="https:"}catch{}if(h)try{const C=await T(`${d}/chat/media`,{method:"POST",headers:{Authorization:`Bearer ${u}`,"Content-Type":"application/json"},body:JSON.stringify({media_url:c.mediaUrl,content:g||void 0,session_id:n})});C.ok?l("Chat media sent to workspace",{mediaUrl:c.mediaUrl}):m("Chat media upload failed",{status:C.status})}catch(C){m("Failed to send chat media",{error:C?.message})}else m("Skipping invalid media URL",{mediaUrl:c.mediaUrl});H(y,"agent",g||`[media: ${c.mediaUrl}]`)}else if(g&&g.length>=2){H(y,"agent",g);try{const h=await T(`${d}/chat/messages`,{method:"POST",headers:{Authorization:`Bearer ${u}`,"Content-Type":"application/json"},body:JSON.stringify({content:g.slice(0,1e4),session_id:n})});h.ok?l("Chat reply sent to workspace"):m("Chat reply failed",{status:h.status})}catch(h){m("Failed to send chat reply",{error:h?.message})}}}})}catch(f){m("Failed to spawn agent turn",{error:f?.message}),q.delete(b),I===b&&(I=null)}}catch{}}function me(){rt(),v?.stop(),$e(),process.exit(0)}process.on("SIGTERM",()=>{me()}),process.on("SIGINT",()=>{me()}),process.argv.includes("--check")?tt():ot().catch(e=>{Pe("Fatal error",{error:e instanceof Error?e.message:String(e)}),process.exit(1)});
|
|
67
|
+
`);a&&(j=a,K(a,"user",R)),W.length>=Ge&&W.shift(),W.push({sender_name:s.sender_name??"Admin",content:t?s.content:i.join(", "),created_at:Date.now(),session_id:a,content_type:s.content_type,metadata_json:s.metadata_json,message_id:s.message_id}),L=Date.now();const T=A(s.sender_name??"Admin"),O=t?A(s.content):"",f=a||j||"_default",S=`aerostack-chat-${/^[a-zA-Z0-9_-]{1,64}$/.test(f)?f:"_default"}`,C=`turn-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,w=[];z.set(C,w),P=C;try{const y=O?O+c:c.trim(),N=`[${T} via Aerostack Dashboard]: ${y}`;if(b){u("Trying WS fast path for chat",{session:S});const D=await b.sendChatMessage(N);if(D){const k=D.trim();u("WS fast path succeeded",{responseLength:k.length}),await new Promise(m=>setTimeout(m,500));for(const m of w)m.status==="running"&&(m.status="timeout",m.ended_at=Date.now(),m.duration_ms=m.ended_at-m.started_at);if(w.length>0){const m=w.reduce((h,g)=>h+(g.duration_ms||0),0),l=w.length;try{await E(`${p}/chat/messages`,{method:"POST",headers:{Authorization:`Bearer ${d}`,"Content-Type":"application/json"},body:JSON.stringify({content:`Used ${l} tool${l>1?"s":""}`,content_type:"tool_activity",session_id:a,metadata:JSON.stringify({v:1,tools:w.map(h=>({name:h.name,category:h.category,duration_ms:h.duration_ms,status:h.status,args_summary:h.args_summary?.slice(0,500),error:h.error?.slice(0,500)})),total_duration_ms:m})})})}catch{}}if(z.delete(C),P===C&&(P=null),k.length>=2){K(f,"agent",k);try{const m=await E(`${p}/chat/messages`,{method:"POST",headers:{Authorization:`Bearer ${d}`,"Content-Type":"application/json"},body:JSON.stringify({content:k.slice(0,1e4),session_id:a})});m.ok?u("Chat reply sent via WS fast path"):_("Chat reply failed (WS fast path)",{status:m.status})}catch(m){_("Failed to send chat reply (WS fast path)",{error:m?.message})}}return}u("WS fast path failed, falling back to CLI subprocess")}const{execFile:V}=await import("child_process");u("Spawning agent turn via CLI for chat",{sender:T,session:S}),V("openclaw",["agent","--agent","main","--json","--session-id",S,"-m",N],{timeout:12e4},async(D,k)=>{let m=[];if(!D&&k)try{const l=JSON.parse(k.trim()),h=l?.result?.payloads;Array.isArray(h)&&h.length>0?m=h:(l.text||l.reply||l.message)&&(m=[{text:l.text||l.reply||l.message}])}catch{const l=k.trim().split(`
|
|
68
|
+
`).pop()||k.trim();l&&(m=[{text:l}])}m.length===0&&(m=[{text:`Message received. I'll process "${O.slice(0,100)}" shortly.`}]),await new Promise(l=>setTimeout(l,500));for(const l of w)l.status==="running"&&(l.status="timeout",l.ended_at=Date.now(),l.duration_ms=l.ended_at-l.started_at);if(w.length>0){const l=w.reduce((g,U)=>g+(U.duration_ms||0),0),h=w.length;try{await E(`${p}/chat/messages`,{method:"POST",headers:{Authorization:`Bearer ${d}`,"Content-Type":"application/json"},body:JSON.stringify({content:`Used ${h} tool${h>1?"s":""}`,content_type:"tool_activity",session_id:a,metadata:JSON.stringify({v:1,tools:w.map(g=>({name:g.name,category:g.category,duration_ms:g.duration_ms,status:g.status,args_summary:g.args_summary?.slice(0,500),error:g.error?.slice(0,500)})),total_duration_ms:l})})})}catch{}}z.delete(C),P===C&&(P=null);for(const l of m){const h=l.text?.trim()||"";if(l.mediaUrl){let g=!1;try{g=new URL(l.mediaUrl).protocol==="https:"}catch{}if(g)try{const U=await E(`${p}/chat/media`,{method:"POST",headers:{Authorization:`Bearer ${d}`,"Content-Type":"application/json"},body:JSON.stringify({media_url:l.mediaUrl,content:h||void 0,session_id:a})});U.ok?u("Chat media sent to workspace",{mediaUrl:l.mediaUrl}):_("Chat media upload failed",{status:U.status})}catch(U){_("Failed to send chat media",{error:U?.message})}else _("Skipping invalid media URL",{mediaUrl:l.mediaUrl});K(f,"agent",h||`[media: ${l.mediaUrl}]`)}else if(h&&h.length>=2){K(f,"agent",h);try{const g=await E(`${p}/chat/messages`,{method:"POST",headers:{Authorization:`Bearer ${d}`,"Content-Type":"application/json"},body:JSON.stringify({content:h.slice(0,1e4),session_id:a})});g.ok?u("Chat reply sent to workspace"):_("Chat reply failed",{status:g.status})}catch(g){_("Failed to send chat reply",{error:g?.message})}}}})}catch(y){_("Failed to spawn agent turn",{error:y?.message}),z.delete(C),P===C&&(P=null)}}catch{}}function me(){rt(),b?.stop(),ve(),process.exit(0)}process.on("SIGTERM",()=>{me()}),process.on("SIGINT",()=>{me()}),process.argv.includes("--check")?st():at().catch(e=>{Ne("Fatal error",{error:e instanceof Error?e.message:String(e)}),process.exit(1)});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readFile as m}from"node:fs/promises";import{join as f}from"node:path";import{homedir as
|
|
1
|
+
import{readFile as m}from"node:fs/promises";import{join as f}from"node:path";import{homedir as w}from"node:os";import{info as u,warn as c,debug as d}from"./logger.js";import{addToBatch as p,detectCategory as b,summarizeToolInput as y}from"./hook-server.js";function S(l){return l.replace(/^(?:\w+__)*aerostack__/,"").replace(/__/g,":")||l}async function N(){try{const l=f(w(),".openclaw","openclaw.json"),e=await m(l,"utf-8");return JSON.parse(e)?.gateway?.auth?.token??null}catch{return null}}async function R(){try{const l=f(w(),".openclaw","exec-approvals.json"),e=await m(l,"utf-8");return JSON.parse(e)?.socket?.token??null}catch{return null}}const k=1e3,_=3e4;class A{opts;ws=null;destroyed=!1;reconnectMs=k;reconnectTimer=null;requestId=0;seenSessions=new Set;pendingRequests=new Map;lastActiveSession=null;pendingChatTurns=new Map;constructor(e){this.opts=e}async connect(){if(this.destroyed)return!1;const e=await this.getWebSocket(),s=`ws://127.0.0.1:${this.opts.port}`;return new Promise(t=>{try{const n=new e(s);this.ws=n;const o=setTimeout(()=>{d("OpenClaw connect timeout");try{n.close()}catch{}t(!1)},1e4);n.onopen=()=>{clearTimeout(o),d("OpenClaw WS connected, sending handshake"),this.sendHandshake()},n.onmessage=i=>{try{const r=JSON.parse(String(i.data));this.handleFrame(r,t)}catch{}},n.onerror=()=>{clearTimeout(o),t(!1)},n.onclose=()=>{clearTimeout(o),this.ws=null,this.destroyed||this.scheduleReconnect()}}catch{t(!1)}})}getLastActiveSession(){return this.lastActiveSession}async sendToSession(e,s){if(!this.ws||!this.connected)return!1;const t=await this.sendRequest("sessions.send",{key:e,message:s,idempotencyKey:`aerostack-${Date.now()}`});return t.ok||c("sendToSession failed",{key:e,error:t.error?.message}),t.ok??!1}async sendChatMessage(e,s=12e4){if(!this.ws||!this.connected)return null;const t="agent:main:main";this.subscribeToSessionMessages(t);const n=new Promise(i=>{const r=setTimeout(()=>{this.pendingChatTurns.delete(t),i(null)},s);this.pendingChatTurns.set(t,a=>{clearTimeout(r),i(a)})}),o=await this.sendRequest("sessions.send",{key:t,message:e,idempotencyKey:`aerostack-${Date.now()}-${Math.random().toString(36).slice(2,8)}`});return o.ok?n:(this.pendingChatTurns.delete(t),c("sendChatMessage: sessions.send rejected",{error:o.error?.message}),null)}stop(){if(this.destroyed=!0,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.ws){try{this.ws.close(1e3)}catch{}this.ws=null}this.pendingRequests.clear(),this.pendingChatTurns.clear()}sendHandshake(){this.send({type:"req",id:String(++this.requestId),method:"connect",params:{minProtocol:3,maxProtocol:3,client:{id:"openclaw-tui",displayName:"Aerostack Guardian",version:"0.15.8",platform:process.platform,mode:"cli"},auth:{token:this.opts.token},scopes:["operator.read","operator.write"],caps:["tool-events"]}})}connected=!1;subscribedSessions=new Set;handleFrame(e,s){if(e.type==="res"&&!this.connected){e.ok?(this.connected=!0,this.reconnectMs=k,u("OpenClaw connector connected",{port:this.opts.port}),s?.(!0),this.subscribeAllSessions().catch(t=>c("subscribeAllSessions failed",{error:t?.message}))):(c("OpenClaw connect rejected",{error:e.error?.message}),s?.(!1));return}if(e.type==="res"&&e.id&&this.pendingRequests.has(e.id)){const t=this.pendingRequests.get(e.id);this.pendingRequests.delete(e.id),t(e);return}if(e.type==="res"&&e.ok===!1&&e.error){c("OpenClaw RPC error",{error:e.error.message,code:e.error.code});return}e.type==="event"&&this.handleEvent(e)}subscribeToSessionMessages(e){if(this.subscribedSessions.has(e))return;this.subscribedSessions.add(e);const s=String(++this.requestId);this.pendingRequests.set(s,t=>{t.ok?d("OpenClaw subscribed to session messages",{key:e}):c("OpenClaw messages.subscribe failed",{key:e,error:t.error?.message})}),this.send({type:"req",id:s,method:"sessions.messages.subscribe",params:{key:e}}),setTimeout(()=>this.pendingRequests.delete(s),1e4)}async subscribeAllSessions(){const e=await this.sendRequest("sessions.subscribe");e.ok?u("OpenClaw subscribed to all session events (tool + lifecycle)"):c("OpenClaw sessions.subscribe failed",{error:e.error?.message});const s=await this.sendRequest("sessions.list",{limit:50});if(!s.ok){c("OpenClaw sessions.list failed",{error:s.error?.message});return}const t=s.payload?.sessions,n=Array.isArray(t)?t:[];u("OpenClaw active sessions",{count:n.length});for(const o of n)o.key&&this.subscribeToSessionMessages(o.key)}sendRequest(e,s){return new Promise(t=>{const n=String(++this.requestId),o=setTimeout(()=>{this.pendingRequests.delete(n),t({type:"res",id:n,ok:!1,error:{code:"TIMEOUT",message:"request timeout"}})},1e4);this.pendingRequests.set(n,i=>{clearTimeout(o),t(i)}),this.send({type:"req",id:n,method:e,params:s})})}handleEvent(e){const s=e.event,t=e.payload??{};s==="agent"?this.handleAgentEvent(t):s==="session.tool"?this.handleToolEvent(t):s==="session.message"?this.handleMessageEvent(t):s==="sessions.changed"?this.handleSessionChanged(t):(s==="exec.approval"||s==="exec.request"||s==="tool.approval")&&this.handleExecApprovalEvent(t)}handleAgentEvent(e){const s=e.stream,t=e.data,n=e.sessionKey??"";if(n&&this.seenSessions.add(n),s==="tool"){const o=t?.name??t?.toolName??e.toolName??"unknown",i=t?.phase??"",r=t?.args??e.args??{};if(i==="start"){const{category:a,risk:h}=b(o,r),g=y(o,r);p({action:`OpenClaw ${S(o)}: ${g}`.slice(0,500),category:a,risk_level:h,details:JSON.stringify({tool:o,session:n,...r}).slice(0,500),agent_name:"OpenClaw"}),d("OpenClaw agent tool event",{tool:o,category:a,risk:h})}}if(s==="lifecycle"&&t){const o=t.phase??"";(o==="start"||o==="end")&&d("OpenClaw agent lifecycle",{phase:o,session:n})}}handleToolEvent(e){const s=e.data,t=s?.name??s?.toolName??e.toolName??"unknown",n=s?.phase??"",o=s?.args??e.args??{},i=e.sessionKey??"";if(n!=="start"&&n!=="end")return;const{category:r,risk:a}=b(t,o),h=y(t,o);if(n==="start"&&p({action:`OpenClaw ${S(t)}: ${h}`.slice(0,500),category:r,risk_level:a,details:JSON.stringify({tool:t,session:i,...o}).slice(0,500),agent_name:"OpenClaw"}),d("OpenClaw tool event",{tool:t,phase:n,category:r,risk:a,session:i}),!new Set(["aerostack__guardian_report","aerostack__chat_check","aerostack__chat_reply","aerostack__check_approval","aerostack__local_guardian","aerostack__guardian_check"]).has(t)){const T=s?.error??e.error??void 0;this.opts.onToolEvent?.({toolName:t,phase:n,category:r,summary:h,error:T})}i&&(this.seenSessions.add(i),this.lastActiveSession=i)}handleExecApprovalEvent(e){const s=e.command??e.cmd??"",t=e.sessionKey??"",n=e.agentId??"";if(!s)return;const o=s.toLowerCase();let i="medium",r="exec_command";/\brm\s+-rf?\b|\bdrop\b|\bdelete\b|\btruncate\b/.test(o)?(i="critical",r="file_delete"):/\brm\b|\bgit\s+push\b|\bgit\s+reset\b|\bdeploy\b|\bkill\b/.test(o)?(i="high",r="deploy"):/\binstall\b|\bpip\b|\bnpm\b|\bcurl\b|\bwget\b/.test(o)&&(i="medium",r="package_install"),p({action:`[approval requested] exec: ${s}`.slice(0,500),category:r,risk_level:i,details:JSON.stringify({command:s,agent:n,session:t,source:"exec.approval"}).slice(0,500),agent_name:"OpenClaw"}),this.opts.rpcCall("tools/call",{name:"aerostack__guardian_report",arguments:{action:`OpenClaw exec approval: ${s}`.slice(0,500),category:r,risk_level:i,details:JSON.stringify({command:s,agent:n,session:t}).slice(0,500)}}).catch(()=>{}),u("OpenClaw exec approval event",{command:s.slice(0,100),risk:i})}handleMessageEvent(e){const s=e.sessionKey??"";s&&(this.seenSessions.add(s),this.lastActiveSession=s);const t=this.pendingChatTurns.get(s);if(!t)return;const n=e.message,o=typeof n=="object"?n?.role:void 0;let i="";if(typeof n=="string")i=n;else if(n){const r=n.content;typeof r=="string"?i=r:Array.isArray(r)&&(i=r.map(a=>typeof a=="string"?a:a?.text??"").join(""))}i&&o!=="user"&&(this.pendingChatTurns.delete(s),t(i))}handleSessionChanged(e){const s=e.sessionKey??"";s&&(this.seenSessions.add(s),this.subscribeToSessionMessages(s))}send(e){if(this.ws)try{this.ws.send(JSON.stringify(e))}catch{}}scheduleReconnect(){this.destroyed||this.reconnectTimer||(d("OpenClaw reconnecting in",{ms:this.reconnectMs}),this.reconnectTimer=setTimeout(async()=>{this.reconnectTimer=null,this.connected=!1,this.seenSessions.clear(),this.subscribedSessions.clear(),this.pendingRequests.clear(),await this.connect()},this.reconnectMs),this.reconnectMs=Math.min(this.reconnectMs*2,_))}async getWebSocket(){return typeof globalThis.WebSocket<"u"?globalThis.WebSocket:(await import("ws")).default}}export{A as OpenClawConnector,R as resolveExecApprovalToken,N as resolveOpenClawToken};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aerostack/gateway",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.29",
|
|
4
4
|
"description": "stdio-to-HTTP bridge connecting any MCP client to Aerostack Workspaces",
|
|
5
5
|
"author": "Aerostack",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"types": "dist/index.d.ts",
|
|
10
10
|
"bin": {
|
|
11
11
|
"aerostack-gateway": "dist/index.js",
|
|
12
|
-
"aerostack-exec-daemon": "dist/exec-approval-daemon.js"
|
|
12
|
+
"aerostack-exec-daemon": "dist/exec-approval-daemon.js",
|
|
13
|
+
"aerostack-connector": "dist/aerostack-connector.js"
|
|
13
14
|
},
|
|
14
15
|
"files": [
|
|
15
16
|
"dist/**/*.js",
|