@lunora/agent 1.0.0-alpha.77 → 1.0.0-alpha.79
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/channels.mjs +1 -1
- package/dist/inbound.mjs +1 -1
- package/package.json +7 -7
package/dist/channels.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LunoraError as w}from"@lunora/errors";import{h as b,B as E}from"./packem_shared/branch-marker-boZ00zmk.mjs";const A=300,
|
|
1
|
+
import{LunoraError as w}from"@lunora/errors";import{h as b,B as E}from"./packem_shared/branch-marker-boZ00zmk.mjs";const h=t=>t.toString(16).padStart(4,"0"),A=t=>{let e=8997,n=33826,r=40164,s=52210;for(let a=0;a<t.length;a+=1){const o=t.codePointAt(a)??0;e^=o&65535,n^=o>>>16&65535;const c=e*435,i=n*435,d=r*435+e*256,g=s*435+n*256,u=i+(c>>>16),l=d+(u>>>16),f=g+(l>>>16);e=c&65535,n=u&65535,r=l&65535,s=f&65535}return h(s)+h(r)+h(n)+h(e)},x=300,N=/[^0-9a-f]/iu,R=new TextEncoder,p=t=>new Uint8Array(R.encode(t)),v=t=>{if(t.length%2!==0||N.test(t))throw new w("BAD_REQUEST","@lunora/agent: malformed hex signature");const e=new Uint8Array(t.length/2);for(let n=0;n<e.length;n+=1)e[n]=Number.parseInt(t.slice(n*2,n*2+2),16);return e},m=async(t,e,n)=>{try{const r=await crypto.subtle.importKey("raw",p(t),{hash:"SHA-256",name:"HMAC"},!1,["verify"]);return await crypto.subtle.verify("HMAC",r,v(n),p(e))}catch{return!1}},S=(t,e,n)=>Number.isFinite(t)&&Math.abs(e-t)<=n,k=async t=>{const{body:e,now:n=Date.now()/1e3,signature:r,signingSecret:s,timestamp:a,tolerance:o=x}=t;return!r||!a||!r.startsWith("v0=")||!S(Number(a),n,o)?!1:m(s,`v0:${a}:${e}`,r.slice(3))},T=async t=>{const{body:e,secret:n,signature:r}=t;return r?.startsWith("sha256=")?m(n,e,r.slice(7)):!1},C=async t=>{const{body:e,publicKey:n,signature:r,timestamp:s}=t;if(!r||!s)return!1;try{const a=await crypto.subtle.importKey("raw",v(n),{name:"Ed25519"},!1,["verify"]);return await crypto.subtle.verify({name:"Ed25519"},a,v(r),p(s+e))}catch{return!1}},I=t=>{if(t.has("x-slack-signature"))return"slack";if(t.has("x-hub-signature-256"))return"github";if(t.has("x-signature-ed25519"))return"discord"},_=(t,e)=>{if(typeof t=="function")return t(e);const n=e[t];return typeof n=="string"?n:void 0},B=async(t,e,n,r)=>{switch(t){case"discord":return C({body:r,publicKey:e,signature:n.get("x-signature-ed25519")??void 0,timestamp:n.get("x-signature-timestamp")??void 0});case"github":return T({body:r,secret:e,signature:n.get("x-hub-signature-256")??void 0});case"slack":return k({body:r,signature:n.get("x-slack-signature")??void 0,signingSecret:e,timestamp:n.get("x-slack-request-timestamp")??void 0});default:return!1}},D=(t,e)=>{if(t==="discord")try{if(JSON.parse(e).type===1)return Response.json({type:1})}catch{}},H=/already[\s-]?exists/iu,y=()=>new Response(void 0,{status:200}),M=t=>H.test(t instanceof Error?t.message:String(t)),U=(t,e,n)=>{if(t==="github")return e.get("x-github-delivery")??void 0;try{const r=JSON.parse(n),s=t==="slack"?r.event_id:r.id;return typeof s=="string"?s:void 0}catch{return}},O=async(t,e,n,r)=>{if(b(e))throw new w("BAD_REQUEST",`@lunora/agent: inbound channel run params ${E}`);if(r===void 0||r==="")return await t.create({params:e}),y();try{await t.create({id:`${n}-${A(r)}`,params:e})}catch(s){if(M(s))return y();throw s}return y()},L=t=>async(e,n)=>{const r=await e.text(),s=I(e.headers);if(s===void 0)return new Response("Unrecognized webhook",{status:400});const a=t.map(i=>({config:i.agent.onInbound,target:i})).filter(i=>i.config?.channel===s),o={channel:s,headers:e.headers,json:()=>JSON.parse(r),rawBody:r};let c=!1;for(const{config:i,target:d}of a){const g=_(i.secret,n);if(g===void 0||!await B(s,g,e.headers,r))continue;c=!0;const u=D(s,r);if(u)return u;const l=await i.map(o);if(!l)continue;const f=n[d.binding];if(!f||typeof f.create!="function")throw new w("INTERNAL",`@lunora/agent: no Workflow binding "${d.binding}" on env for an inbound-channel agent — run codegen/dev so wrangler.jsonc declares it`);return await O(f,l,s,U(s,e.headers,r))}return c?new Response(void 0,{status:204}):new Response("Invalid signature",{status:401})};export{L as dispatchAgentChannel,M as isDuplicateInstanceError,C as verifyDiscord,T as verifyGithub,k as verifySlack};
|
package/dist/inbound.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createInboundEmailHandler as u,parseInboundEmail as d}from"@lunora/mail/inbound";import{h as g,B as l}from"./packem_shared/branch-marker-boZ00zmk.mjs";const m="message could not be processed",c=(
|
|
1
|
+
import{createInboundEmailHandler as u,parseInboundEmail as d}from"@lunora/mail/inbound";import{h as g,B as l}from"./packem_shared/branch-marker-boZ00zmk.mjs";const m="message could not be processed",c=(t,s)=>{console.error("@lunora/agent/inbound: bouncing message —",s),t.message.setReject(m)},E=t=>{const s=u({dispatch:async(a,n)=>{for(const e of t){const r=e.agent.onEmail;if(!r)continue;const o=await r(a);if(o==null)continue;const i=n.env[e.binding];if(!i||typeof i.create!="function"){c(n,`@lunora/agent: no Workflow binding "${e.binding}" on env for an inbound agent — run codegen/dev so wrangler.jsonc declares it`);return}if(g(o)){c(n,`@lunora/agent: inbound run params ${l}`);return}await i.create({params:o});return}},parse:d,verify:a=>{const{dkim:n,dmarc:e,spf:r}=a.authentication;return e==="pass"||r==="pass"&&n==="pass"}});return async(a,n,e)=>s(a,n,e)};export{E as dispatchAgentEmail};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/agent",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.79",
|
|
4
4
|
"description": "Durable AI agents for Lunora: defineAgent compiles a replay-safe tool-loop onto Cloudflare Workflows, with DO SQLite threads and live message subscriptions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -84,12 +84,12 @@
|
|
|
84
84
|
"access": "public"
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
|
-
"@lunora/ai": "1.0.0-alpha.
|
|
88
|
-
"@lunora/errors": "1.0.0-alpha.
|
|
89
|
-
"@lunora/mail": "1.0.0-alpha.
|
|
90
|
-
"@lunora/server": "1.0.0-alpha.
|
|
91
|
-
"@lunora/values": "1.0.0-alpha.
|
|
92
|
-
"@lunora/workflow": "1.0.0-alpha.
|
|
87
|
+
"@lunora/ai": "1.0.0-alpha.67",
|
|
88
|
+
"@lunora/errors": "1.0.0-alpha.27",
|
|
89
|
+
"@lunora/mail": "1.0.0-alpha.57",
|
|
90
|
+
"@lunora/server": "1.0.0-alpha.97",
|
|
91
|
+
"@lunora/values": "1.0.0-alpha.35",
|
|
92
|
+
"@lunora/workflow": "1.0.0-alpha.40",
|
|
93
93
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
94
94
|
"ai": "7.0.59",
|
|
95
95
|
"yaml": "^2.9.0"
|