@okxweb3/a2a-openclaw 0.1.4 → 0.1.5

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/index.js CHANGED
@@ -24,6 +24,6 @@ ${f}`}catch{}}throw d}}async function J(e){return _({method:"sessions.create",pa
24
24
  UPDATE pending_gateway_deliveries
25
25
  SET attempts = attempts + 1, last_error = ?, last_attempt_at = ?
26
26
  WHERE id = ?
27
- `).run(ae,new Date().toISOString(),f.id),u(`[okx-a2a:outbox-drain] delivery failed id=${f.id} kind=${f.kind} attempts=${Dn}: ${ae}`))}return(i>0||d>0)&&g.info(a.SESSION_DISPATCHED,{onchainosAgentId:"*",source:"gateway_outbox_drain",deliveredCount:String(i),failedCount:String(d),abandonedCount:String(c),batchSize:String(o.length)}),{delivered:i,failed:d,abandoned:c,skipped:!1}}finally{s.close()}}function Gt(e={}){let n=e.intervalMs??pr,t=!1,s=async()=>{if(!t){t=!0;try{await Ar({...e.dbPath!==void 0?{dbPath:e.dbPath}:{},...e.limit!==void 0?{limit:e.limit}:{}})}catch(o){u("[okx-a2a:outbox-drain] tick failed:",o)}finally{t=!1}}},r=setInterval(()=>{s()},n);return r.unref?.(),s(),()=>{clearInterval(r)}}D();var hr=process.env.SENTRY_ENV==="dev"?"dev":"prod",jt={projectName:"okx/openclaw-okx-a2a-extension",release:"0.1.4",environment:hr};var j,F,Tr="https://e20ff987c945887733de9ec6cca87aba@sentry.coinall.ltd/apmfe/70295";function wr(e){let n=e?.details?.requestId;return typeof n=="string"&&n.trim()?`openclaw devices approve ${n}`:"openclaw devices approve --latest"}function Rr(e){let n=e?.details??{},t=Ie(e);return["OKX A2A plugin needs OpenClaw gateway `operator.admin` scope before it can create sessions, inject chat messages, and route XMTP conversations.","","Ask the user whether they approve granting this scope to the OKX A2A plugin.","","If the user approves, ask them to run this command on the OpenClaw host:","","```bash",wr(e),"```","",`requestId: ${n.requestId??""}`,`deviceId: ${n.deviceId??""}`,`requestedScopes: ${Array.isArray(n.requestedScopes)?n.requestedScopes.join(","):""}`,`approvedScopes: ${Array.isArray(n.approvedScopes)?n.approvedScopes.join(","):""}`,t?`hint: ${t}`:""].filter(Boolean).join(`
28
- `)}function Nr(){J({key:Zn()}).then(()=>{u("[okx-a2a:service] gateway client admin precheck succeeded"),g.info(a.GATEWAY_STARTED,{source:"gateway_preconnect",outcome:"ok"})},e=>{u("[okx-a2a:service] gateway client admin precheck failed:",e),g.error(a.GATEWAY_CONNECT_FAILED,e instanceof Error?e:new Error(String(e)),{source:"gateway_preconnect",code:String(e?.gatewayCode??e?.details?.code??""),reason:String(e?.details?.reason??""),requestId:String(e?.details?.requestId??"")}),_n(Rr(e),{source:"gateway_preconnect"}).then(({dispatched:n,failed:t})=>{g.info(a.USER_DISPATCHED,{source:"gateway_preconnect",outcome:t.length===0?"all_ok":"partial",dispatchedChannels:n.join(","),failedChannels:t.join(","),dispatchedCount:String(n.length),failedCount:String(t.length)})},n=>{g.error(a.USER_DISPATCH_FAILED,n instanceof Error?n:new Error(String(n)),{source:"gateway_preconnect"})})})}function Dr(){let e=process.env.OKX_A2A_SENTRY_DSN?.trim()||process.env.SENTRY_DSN?.trim()||Tr;Ln({dsn:e,...jt,agentPlatform:"openclaw"})}function Tn(e,n){let t=[e?.sessionKey,e?.context?.sessionKey,e?.ctx?.sessionKey,e?.hookContext?.sessionKey,n?.sessionKey];for(let s of t)if(typeof s=="string"&&s.trim())return s;return null}function wn(e,n){let t=[e?.runId,e?.agentRunId,e?.context?.runId,e?.context?.agentRunId,e?.ctx?.runId,e?.ctx?.agentRunId,e?.hookContext?.runId,e?.hookContext?.agentRunId,n?.runId,n?.agentRunId];for(let s of t)if(typeof s=="string"&&s.trim())return s;return null}function Or(e){let n=br(e),t=new Set([e]);for(let[s,r]of b())s&&s!==n&&r.sessionKey&&t.add(r.sessionKey);return[...t]}function br(e){let n=e.split(":");return n.length>=4&&n[0]==="agent"?n[2]??null:null}function Rn(e,n){let t=e[n];if(typeof t!="string"||!t.trim())throw new Error(`Missing required param ${n}`);return t}function m(e,n){let t=e[n];return typeof t=="string"&&t.trim()?t:void 0}function Nn(e,n){let t=e[n];if(!Array.isArray(t))return;let s=t.filter(r=>typeof r=="string"&&r.trim().length>0).map(r=>r.trim());return s.length>0?s:void 0}function kr(e,n){let t=e[n];return typeof t=="boolean"?t:void 0}var C={id:"okx-a2a",name:"OKX A2A Plugin",version:"0.1.4",register(e){Kn(e.runtime),e.registerChannel({plugin:$n}),e.registerGatewayMethod("okx-a2a.health",async({respond:n})=>{n(!0,{ok:!0,provider:"openclaw",pluginId:C.id,pluginVersion:C.version,startedAt:F??null})},{scope:"operator.admin"}),e.registerGatewayMethod("okx-a2a.dispatch_user",async({params:n,respond:t})=>{try{let s=Rn(n,"content"),r=m(n,"label"),o=m(n,"sessionKey"),i=Nn(n,"sessionKeys"),d=m(n,"jobId"),c=m(n,"currentSessionKey"),l=m(n,"idempotencyKey");t(!0,i?await yn({sessionKeys:i,content:s,label:r,idempotencyKey:l}):o?await mn({sessionKey:o,content:s,label:r,idempotencyKey:l}):await fn({content:s,label:r,jobId:d,currentSessionKey:c,idempotencyKey:l}))}catch(s){t(!1,void 0,{code:"INVALID_REQUEST",message:s instanceof Error?s.message:String(s)})}},{scope:"operator.admin"}),e.registerGatewayMethod("okx-a2a.prompt_user",async({params:n,respond:t})=>{try{let s=Rn(n,"userContent"),r=Rn(n,"llmContent"),o=m(n,"sessionKey"),i=Nn(n,"sessionKeys"),d=m(n,"jobId"),c=m(n,"currentSessionKey"),l=m(n,"idempotencyKey");t(!0,i?await In({sessionKeys:i,userContent:s,llmContent:r,idempotencyKey:l}):o?await Sn({sessionKey:o,userContent:s,llmContent:r,idempotencyKey:l}):await En({userContent:s,llmContent:r,jobId:d,currentSessionKey:c,idempotencyKey:l}))}catch(s){t(!1,void 0,{code:"INVALID_REQUEST",message:s instanceof Error?s.message:String(s)})}},{scope:"operator.admin"}),e.registerGatewayMethod("okx-a2a.delete_sessions",async({params:n,respond:t})=>{try{let s=m(n,"sessionKey"),r=Nn(n,"sessionKeys"),o=m(n,"jobId");if(!s&&!r&&!o)throw new Error("Missing required selector: sessionKey, sessionKeys, or jobId");let i=m(n,"myAgentId"),d=m(n,"toAgentId"),c=m(n,"myXmtpAddress"),l=m(n,"toXmtpAddress"),f=kr(n,"deleteTranscript");t(!0,await ut({...s?{sessionKey:s}:{},...r?{sessionKeys:r}:{},...o?{jobId:o}:{},...i?{myAgentId:i}:{},...d?{toAgentId:d}:{},...c?{myXmtpAddress:c}:{},...l?{toXmtpAddress:l}:{},...f!==void 0?{deleteTranscript:f}:{}}))}catch(s){t(!1,void 0,{code:"INVALID_REQUEST",message:s instanceof Error?s.message:String(s)})}},{scope:"operator.admin"}),e.registerHook("agent:bootstrap",async n=>{let t=n.context,s=t.bootstrapFiles;if(Array.isArray(s))try{let r=s.map(i=>`${i.name}(${i.missing?"missing":`${i.content?.length??0}b`})`).join(", ");u(`[okx-a2a:hook] agent:bootstrap agentId=${t.agentId??"?"} files=[${r}]`);let o=s.reduce((i,d)=>i+(d.content?.length??0),0);g.info(a.BOOTSTRAP_APPLIED,{openclawAgentId:t.agentId??"",promptSize:String(o),fileCount:String(s.length),missingCount:String(s.filter(i=>i.missing).length)})}catch(r){g.error(a.BOOTSTRAP_FAILED,r instanceof Error?r:void 0,{openclawAgentId:t.agentId??""})}},{name:"okx-a2a-agent-bootstrap"}),e.on("before_agent_run",async(n,t)=>{let s=Tn(n,t),r=wn(n,t);if(!s){u("[xmtp_prompt_user:queue] before_agent_run ignored: missing sessionKey");return}let o=Or(s);pt({runId:r,sessionKey:s,routeSessionKeys:o})&&console.log(`[okx-a2a:hook] remembered gateway route origin runId=${r} sessionKey=${s} routeSessionKeys=${o.join(",")}`),rn(s)}),e.on("before_tool_call",async(n,t)=>{let s=Tn(n,t),r=wn(n,t);Xe(s);let o=[...new Set([..._e({sessionKey:s}),...Se({runId:r,sessionKey:s})])],i=ft({toolName:n?.toolName,params:n?.params,sessionKey:s,routeSessionKeys:o});if(i)return console.log(`[okx-a2a:hook] injected gateway session env tool=${n?.toolName??"?"} sessionKey=${s} routeSessionKeys=${o.join(",")}`),{params:i}},{priority:50}),e.on("agent_end",async(n,t)=>{let s=Tn(n,t),r=wn(n,t);if(yt({runId:r,sessionKey:s}),!s){u("[xmtp_prompt_user:queue] agent_end ignored: missing sessionKey");return}on(s)}),e.registerService({id:"okx-a2a:core",start:async()=>{u("[okx-a2a:service] okx-a2a:core starting (multi-identity mode); initializing communication identities..."),F=Date.now(),Dr(),g.info(a.GATEWAY_STARTED,{onchainosAgentId:"*",pid:String(process.pid),pluginId:C.id,pluginVersion:C.version,nodeVersion:process.version,startedAt:String(F)}),Fe(),Nr(),j&&j(),j=Gt(),u("[okx-a2a:service] OpenClaw lightweight gateway initialized; node daemon owns XMTP receive/send/agent sync.")},stop:async()=>{j&&(j(),j=void 0),qe(),u("[okx-a2a:service] okx-a2a:core stopped");let n=Date.now();g.info(a.GATEWAY_STOPPED,{onchainosAgentId:"*",pid:String(process.pid),pluginId:C.id,pluginVersion:C.version,stoppedAt:String(n),uptimeMs:F?String(n-F):"unknown"}),F=void 0}})}},Kr=C;
27
+ `).run(ae,new Date().toISOString(),f.id),u(`[okx-a2a:outbox-drain] delivery failed id=${f.id} kind=${f.kind} attempts=${Dn}: ${ae}`))}return(i>0||d>0)&&g.info(a.SESSION_DISPATCHED,{onchainosAgentId:"*",source:"gateway_outbox_drain",deliveredCount:String(i),failedCount:String(d),abandonedCount:String(c),batchSize:String(o.length)}),{delivered:i,failed:d,abandoned:c,skipped:!1}}finally{s.close()}}function Gt(e={}){let n=e.intervalMs??pr,t=!1,s=async()=>{if(!t){t=!0;try{await Ar({...e.dbPath!==void 0?{dbPath:e.dbPath}:{},...e.limit!==void 0?{limit:e.limit}:{}})}catch(o){u("[okx-a2a:outbox-drain] tick failed:",o)}finally{t=!1}}},r=setInterval(()=>{s()},n);return r.unref?.(),s(),()=>{clearInterval(r)}}D();var hr=process.env.SENTRY_ENV==="dev"?"dev":"prod",jt={projectName:"okx/openclaw-okx-a2a-extension",release:"0.1.5",environment:hr};var j,F,Tr="https://e20ff987c945887733de9ec6cca87aba@sentry.coinall.ltd/apmfe/70295";function wr(e){let n=e?.details?.requestId;return typeof n=="string"&&n.trim()?`openclaw devices approve ${n}`:"openclaw devices approve --latest"}function Rr(e){let n=e?.details??{},t=Ie(e);return["OKX A2A plugin needs OpenClaw gateway `operator.admin` scope before it can create sessions, inject chat messages, and route XMTP conversations.","","Ask the user whether they approve granting this scope to the OKX A2A plugin.","","If the user approves, ask them to run this command on the OpenClaw host:","","```bash",wr(e),"```","",`requestId: ${n.requestId??""}`,`deviceId: ${n.deviceId??""}`,`requestedScopes: ${Array.isArray(n.requestedScopes)?n.requestedScopes.join(","):""}`,`approvedScopes: ${Array.isArray(n.approvedScopes)?n.approvedScopes.join(","):""}`,t?`hint: ${t}`:""].filter(Boolean).join(`
28
+ `)}function Nr(){J({key:Zn()}).then(()=>{u("[okx-a2a:service] gateway client admin precheck succeeded"),g.info(a.GATEWAY_STARTED,{source:"gateway_preconnect",outcome:"ok"})},e=>{u("[okx-a2a:service] gateway client admin precheck failed:",e),g.error(a.GATEWAY_CONNECT_FAILED,e instanceof Error?e:new Error(String(e)),{source:"gateway_preconnect",code:String(e?.gatewayCode??e?.details?.code??""),reason:String(e?.details?.reason??""),requestId:String(e?.details?.requestId??"")}),_n(Rr(e),{source:"gateway_preconnect"}).then(({dispatched:n,failed:t})=>{g.info(a.USER_DISPATCHED,{source:"gateway_preconnect",outcome:t.length===0?"all_ok":"partial",dispatchedChannels:n.join(","),failedChannels:t.join(","),dispatchedCount:String(n.length),failedCount:String(t.length)})},n=>{g.error(a.USER_DISPATCH_FAILED,n instanceof Error?n:new Error(String(n)),{source:"gateway_preconnect"})})})}function Dr(){let e=process.env.OKX_A2A_SENTRY_DSN?.trim()||process.env.SENTRY_DSN?.trim()||Tr;Ln({dsn:e,...jt,agentPlatform:"openclaw"})}function Tn(e,n){let t=[e?.sessionKey,e?.context?.sessionKey,e?.ctx?.sessionKey,e?.hookContext?.sessionKey,n?.sessionKey];for(let s of t)if(typeof s=="string"&&s.trim())return s;return null}function wn(e,n){let t=[e?.runId,e?.agentRunId,e?.context?.runId,e?.context?.agentRunId,e?.ctx?.runId,e?.ctx?.agentRunId,e?.hookContext?.runId,e?.hookContext?.agentRunId,n?.runId,n?.agentRunId];for(let s of t)if(typeof s=="string"&&s.trim())return s;return null}function Or(e){let n=br(e),t=new Set([e]);for(let[s,r]of b())s&&s!==n&&r.sessionKey&&t.add(r.sessionKey);return[...t]}function br(e){let n=e.split(":");return n.length>=4&&n[0]==="agent"?n[2]??null:null}function Rn(e,n){let t=e[n];if(typeof t!="string"||!t.trim())throw new Error(`Missing required param ${n}`);return t}function m(e,n){let t=e[n];return typeof t=="string"&&t.trim()?t:void 0}function Nn(e,n){let t=e[n];if(!Array.isArray(t))return;let s=t.filter(r=>typeof r=="string"&&r.trim().length>0).map(r=>r.trim());return s.length>0?s:void 0}function kr(e,n){let t=e[n];return typeof t=="boolean"?t:void 0}var C={id:"okx-a2a",name:"OKX A2A Plugin",version:"0.1.5",register(e){Kn(e.runtime),e.registerChannel({plugin:$n}),e.registerGatewayMethod("okx-a2a.health",async({respond:n})=>{n(!0,{ok:!0,provider:"openclaw",pluginId:C.id,pluginVersion:C.version,startedAt:F??null})},{scope:"operator.admin"}),e.registerGatewayMethod("okx-a2a.dispatch_user",async({params:n,respond:t})=>{try{let s=Rn(n,"content"),r=m(n,"label"),o=m(n,"sessionKey"),i=Nn(n,"sessionKeys"),d=m(n,"jobId"),c=m(n,"currentSessionKey"),l=m(n,"idempotencyKey");t(!0,i?await yn({sessionKeys:i,content:s,label:r,idempotencyKey:l}):o?await mn({sessionKey:o,content:s,label:r,idempotencyKey:l}):await fn({content:s,label:r,jobId:d,currentSessionKey:c,idempotencyKey:l}))}catch(s){t(!1,void 0,{code:"INVALID_REQUEST",message:s instanceof Error?s.message:String(s)})}},{scope:"operator.admin"}),e.registerGatewayMethod("okx-a2a.prompt_user",async({params:n,respond:t})=>{try{let s=Rn(n,"userContent"),r=Rn(n,"llmContent"),o=m(n,"sessionKey"),i=Nn(n,"sessionKeys"),d=m(n,"jobId"),c=m(n,"currentSessionKey"),l=m(n,"idempotencyKey");t(!0,i?await In({sessionKeys:i,userContent:s,llmContent:r,idempotencyKey:l}):o?await Sn({sessionKey:o,userContent:s,llmContent:r,idempotencyKey:l}):await En({userContent:s,llmContent:r,jobId:d,currentSessionKey:c,idempotencyKey:l}))}catch(s){t(!1,void 0,{code:"INVALID_REQUEST",message:s instanceof Error?s.message:String(s)})}},{scope:"operator.admin"}),e.registerGatewayMethod("okx-a2a.delete_sessions",async({params:n,respond:t})=>{try{let s=m(n,"sessionKey"),r=Nn(n,"sessionKeys"),o=m(n,"jobId");if(!s&&!r&&!o)throw new Error("Missing required selector: sessionKey, sessionKeys, or jobId");let i=m(n,"myAgentId"),d=m(n,"toAgentId"),c=m(n,"myXmtpAddress"),l=m(n,"toXmtpAddress"),f=kr(n,"deleteTranscript");t(!0,await ut({...s?{sessionKey:s}:{},...r?{sessionKeys:r}:{},...o?{jobId:o}:{},...i?{myAgentId:i}:{},...d?{toAgentId:d}:{},...c?{myXmtpAddress:c}:{},...l?{toXmtpAddress:l}:{},...f!==void 0?{deleteTranscript:f}:{}}))}catch(s){t(!1,void 0,{code:"INVALID_REQUEST",message:s instanceof Error?s.message:String(s)})}},{scope:"operator.admin"}),e.registerHook("agent:bootstrap",async n=>{let t=n.context,s=t.bootstrapFiles;if(Array.isArray(s))try{let r=s.map(i=>`${i.name}(${i.missing?"missing":`${i.content?.length??0}b`})`).join(", ");u(`[okx-a2a:hook] agent:bootstrap agentId=${t.agentId??"?"} files=[${r}]`);let o=s.reduce((i,d)=>i+(d.content?.length??0),0);g.info(a.BOOTSTRAP_APPLIED,{openclawAgentId:t.agentId??"",promptSize:String(o),fileCount:String(s.length),missingCount:String(s.filter(i=>i.missing).length)})}catch(r){g.error(a.BOOTSTRAP_FAILED,r instanceof Error?r:void 0,{openclawAgentId:t.agentId??""})}},{name:"okx-a2a-agent-bootstrap"}),e.on("before_agent_run",async(n,t)=>{let s=Tn(n,t),r=wn(n,t);if(!s){u("[xmtp_prompt_user:queue] before_agent_run ignored: missing sessionKey");return}let o=Or(s);pt({runId:r,sessionKey:s,routeSessionKeys:o})&&console.log(`[okx-a2a:hook] remembered gateway route origin runId=${r} sessionKey=${s} routeSessionKeys=${o.join(",")}`),rn(s)}),e.on("before_tool_call",async(n,t)=>{let s=Tn(n,t),r=wn(n,t);Xe(s);let o=[...new Set([..._e({sessionKey:s}),...Se({runId:r,sessionKey:s})])],i=ft({toolName:n?.toolName,params:n?.params,sessionKey:s,routeSessionKeys:o});if(i)return console.log(`[okx-a2a:hook] injected gateway session env tool=${n?.toolName??"?"} sessionKey=${s} routeSessionKeys=${o.join(",")}`),{params:i}},{priority:50}),e.on("agent_end",async(n,t)=>{let s=Tn(n,t),r=wn(n,t);if(yt({runId:r,sessionKey:s}),!s){u("[xmtp_prompt_user:queue] agent_end ignored: missing sessionKey");return}on(s)}),e.registerService({id:"okx-a2a:core",start:async()=>{u("[okx-a2a:service] okx-a2a:core starting (multi-identity mode); initializing communication identities..."),F=Date.now(),Dr(),g.info(a.GATEWAY_STARTED,{onchainosAgentId:"*",pid:String(process.pid),pluginId:C.id,pluginVersion:C.version,nodeVersion:process.version,startedAt:String(F)}),Fe(),Nr(),j&&j(),j=Gt(),u("[okx-a2a:service] OpenClaw lightweight gateway initialized; node daemon owns XMTP receive/send/agent sync.")},stop:async()=>{j&&(j(),j=void 0),qe(),u("[okx-a2a:service] okx-a2a:core stopped");let n=Date.now();g.info(a.GATEWAY_STOPPED,{onchainosAgentId:"*",pid:String(process.pid),pluginId:C.id,pluginVersion:C.version,stoppedAt:String(n),uptimeMs:F?String(n-F):"unknown"}),F=void 0}})}},Kr=C;
29
29
  if(module.exports&&module.exports.__esModule&&module.exports.default){module.exports=module.exports.default;}
@@ -2,7 +2,7 @@
2
2
  "id": "okx-a2a",
3
3
  "name": "OKX A2A",
4
4
  "description": "E2E encrypted wallet-to-agent communication via A2A protocol",
5
- "version": "0.1.4",
5
+ "version": "0.1.5",
6
6
  "activation": {
7
7
  "onStartup": true
8
8
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@okxweb3/a2a-openclaw",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "OpenClaw plugin for E2E encrypted agent-to-agent communication via XMTP",
5
5
  "main": "dist/index.js",
6
6
  "files": [