agenttwin 0.3.38 → 0.3.39
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/api.js +23053 -14505
- package/dist/cli.js +49 -2
- package/dist/dashboard/assets/next/static/chunks/424-5191e91fec0be2c7.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/_not-found/page-f05b53aa432a7110.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/about/page-8378255082922f7c.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/account/password/page-4db0777af7564cb4.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/api-policy/page-6706d2afc96be601.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/auth/page-6706d2afc96be601.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/blog/layout-d92d0846e7847b0f.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/compare/page-6706d2afc96be601.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/contact/page-6706d2afc96be601.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/dashboard/layout-cbd7e31c6d430a1a.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/dashboard/page-f45f96c066eb9de2.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/demo/{page-31cfcdbb616ad4d4.js → page-db243af5ea4b6376.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/app/developers/page-6706d2afc96be601.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/docs/[[...slug]]/page-83fc0a3aa3425b02.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/dpa/page-6706d2afc96be601.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/enterprise/page-2451558ccbe066c9.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/guides/page-6706d2afc96be601.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/{layout-128b6774e096cd58.js → layout-13d2f06cab6f3ef6.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/app/login/page-589519cc705ec22f.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/not-found-6706d2afc96be601.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/onboarding/{page-f115c111de9d5332.js → page-c4292b08dedb1e5c.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/app/page-bfcf9194963bf52b.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/pricing/page-e65353f9ee62da36.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/privacy/page-6706d2afc96be601.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/sandbox/page-6706d2afc96be601.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/scoreboard/page-6706d2afc96be601.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/security/page-6706d2afc96be601.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/signup/page-589519cc705ec22f.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/status/page-47f0d1533bf1206f.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/subprocessors/page-6706d2afc96be601.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/terms/page-6706d2afc96be601.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/v2/dashboard/layout-76020499f90782bd.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/v2/dashboard/page-cb63082b6709d22e.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/v2/layout-d3227c5987005526.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/v2/login/page-40a3cf0903538784.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/v2/onboarding/page-921ad64530803c42.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/v2/page-d0b682a723aa566f.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/v2/signup/page-40a3cf0903538784.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/what-is-agenttwin/page-6706d2afc96be601.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/{main-app-916068fc13b0fb5b.js → main-app-cc626a1cec570e8f.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/{webpack-2f5d1da47be2abc8.js → webpack-a48857e1e72fd84a.js} +1 -1
- package/dist/dashboard/assets/next/static/css/4bee95c06986ad43.css +1 -0
- package/dist/dashboard/assets/next/static/css/75f812c09155fe4d.css +1 -0
- package/dist/dashboard/assets/next/static/css/923568b6c3a9a99a.css +1 -0
- package/dist/dashboard/index.html +2 -2
- package/dist/discover-worker.js +5800 -0
- package/dist/engine.js +20019 -9500
- package/dist/gateway.js +23043 -14495
- package/dist/scan-worker.js +3312 -0
- package/dist/twins/catalog.json +122 -161
- package/dist/twins/packs/algolia/index.mjs +1 -1
- package/dist/twins/packs/openai/index.mjs +4 -4
- package/dist/twins/packs/polar/index.mjs +1 -1
- package/dist/twins/packs/slack/index.mjs +1 -1
- package/dist/twins/packs/stripe/index.mjs +7 -7
- package/dist/twins/packs/twilio/index.mjs +1 -1
- package/dist/worker.js +2295 -2155
- package/dist/world-host.js +3056 -2891
- package/package.json +2 -1
- package/dist/dashboard/assets/next/static/chunks/424-83736cfafc224fc6.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/_not-found/page-2fd2e381a895d366.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/about/page-40c8beec9496b8b7.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/account/password/page-f73c2b9267b5d7e0.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/api-policy/page-f4b72a7ad1e56298.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/auth/page-f4b72a7ad1e56298.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/blog/layout-50a710e1993b90e4.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/compare/page-f4b72a7ad1e56298.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/contact/page-f4b72a7ad1e56298.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/dashboard/layout-209f837090dfdb78.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/dashboard/page-9599e4d7dbe9d109.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/developers/page-f4b72a7ad1e56298.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/docs/[[...slug]]/page-9d51ad46fff3ed1d.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/dpa/page-f4b72a7ad1e56298.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/enterprise/page-eaf9847de1de035e.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/guides/page-f4b72a7ad1e56298.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/login/page-fd6021c3acb6bfba.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/not-found-f4b72a7ad1e56298.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/page-894aeddae568cc62.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/pricing/page-814d931ab23c41a1.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/privacy/page-f4b72a7ad1e56298.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/sandbox/page-f4b72a7ad1e56298.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/scoreboard/page-f4b72a7ad1e56298.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/security/page-f4b72a7ad1e56298.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/signup/page-fd6021c3acb6bfba.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/status/page-ff7cb74a07e7a9e2.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/subprocessors/page-f4b72a7ad1e56298.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/terms/page-f4b72a7ad1e56298.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/v2/dashboard/layout-b0875609e09201bf.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/v2/dashboard/page-1dac0135be05c7c8.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/v2/layout-7c6be3e291ee6a1d.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/v2/login/page-893f3f867fbaab89.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/v2/onboarding/page-d0d081d4ea987ae2.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/v2/page-cfa46e7717999ca0.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/v2/signup/page-893f3f867fbaab89.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/what-is-agenttwin/page-f4b72a7ad1e56298.js +0 -1
- package/dist/dashboard/assets/next/static/css/2c38dfe54afd9bb6.css +0 -1
- package/dist/dashboard/assets/next/static/css/605ac70c9cf7a260.css +0 -1
- package/dist/dashboard/assets/next/static/css/734b61a26b31f1d1.css +0 -1
- package/dist/twins/packs/vgauth/LICENSE +0 -202
- package/dist/twins/packs/vgauth/NOTICE +0 -7
- package/dist/twins/packs/vgauth/index.mjs +0 -2
- /package/dist/dashboard/assets/next/static/{Jcm2T3zQdpRyYqps7LFDD → KNTxh0SQ8GqNZPTSXNcRe}/_buildManifest.js +0 -0
- /package/dist/dashboard/assets/next/static/{Jcm2T3zQdpRyYqps7LFDD → KNTxh0SQ8GqNZPTSXNcRe}/_ssgManifest.js +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import{createRequire as __atReq}from'node:module';const require=__atReq(import.meta.url);
|
|
2
|
-
import{createHash as v}from"node:crypto";import{applyTwinWrite as J,projectResources as Q,worldNow as Z}from"../../engine/v2/volter_world-core.mjs";import{applyTwinWriteAtomic as Y,projectResources as K,nodeBuiltin as z}from"../../engine/v2/volter_world-core.mjs";function X(){return z("node:crypto")}var R="twilio",E="signing_key",P="signing_key:account";function k(e){return typeof e=="string"&&/^AC[0-9a-fA-F]{32}$/.test(e)}function A(e){return typeof e=="string"&&/^[0-9a-fA-F]{32,}$/.test(e)}function I(e){let t;for(let[u,c]of Object.entries(e??{}))u.toLowerCase()==="authorization"&&(t=c);let n=/^Basic\s+([A-Za-z0-9+/=]+)$/i.exec(t??"");if(!n)return;let o;try{o=Buffer.from(n[1],"base64").toString("utf8")}catch{return}let i=o.indexOf(":");if(i<0)return;let r=o.slice(0,i),s=o.slice(i+1);if(!(!k(r)||!A(s)))return{accountSid:r,authToken:s}}function M(e){let t=e.find(i=>i.type===E&&i.id===P),n=t?._account_sid,o=t?._auth_token;if(!(typeof n!="string"||typeof o!="string")&&!(!n||!o))return{accountSid:n,authToken:o}}function b(e){return M(K(R,e))}function j(e){let t=n=>X().randomBytes(n).toString("hex");return{accountSid:k(e?.accountSid)?e.accountSid:`AC${t(16)}`,authToken:A(e?.authToken)?e.authToken:t(16)}}async function y(e,t){let n=b(e);if(n)return n;let{value:o}=await Y(R,i=>{let r=M(i);if(r)return{kind:"skip",value:r};let s=j(t);return{kind:"write",value:s,write:{operation:"signing_key.create",subjectType:E,subjectId:P,fields:{_account_sid:s.accountSid,_auth_token:s.authToken},actor:{kind:"system"}}}},e);return o}var B="twilio",p="2010-04-01";function q(e){let t={};for(let[n,o]of Object.entries(e??{}))t[n.toLowerCase()]=o;return t}function W(e){let t=q(e.headers),n=(e.path.split("?")[0]??"/").replace(/\/+$/,"")||"/",o=e.host??t.host;return o==="api.twilio.com"?"api":o==="verify.twilio.com"?"verify":o==="lookups.twilio.com"?"lookup":n.includes("/Services/")?"verify":n.includes("/PhoneNumbers/")?"lookup":(n.includes("/Accounts/"),"api")}function S(e,t,n){return{status:n,body:{code:e,message:t,more_info:`https://www.twilio.com/docs/errors/${e}`,status:n}}}function f(){return S(20404,"The requested resource was not found",404)}function ee(e){if(e===void 0||e==="")return{ok:!0,value:{}};let t=e.trim();if(t.startsWith("{")||t.startsWith("["))return{ok:!1};let n=new URLSearchParams(e),o={};for(let[i,r]of n)o[i]=r;return{ok:!0,value:o}}function m(e){return e??Z()}function _(e){return new Date(m(e)).toUTCString().replace("GMT","+0000")}function te(e,t){return`${e}:${t}`}function T(e,t){let n=`${e}:`;return Q(B,t).filter(o=>o.type===e&&o.id.startsWith(n)&&o._deleted!==!0).map(o=>({...o,id:o.id.slice(n.length)}))}function w(e,t,n){return T(e,n).find(o=>o.id===t)}function ne(e){let{type:t,updatedAt:n,...o}=e,i={};for(let[r,s]of Object.entries(o))r.startsWith("_")||(i[r]=s);return i}function g(e){let t=ne(e),{id:n,...o}=t;return{sid:n,...o}}function oe(e){let t=g(e),{number_type:n,...o}=t;return{...o,type:n??null}}async function h(e,t,n,o,i){let{resource:r}=await J(B,{operation:o,subjectType:e,subjectId:te(e,t),fields:n,...i.occurredAt?{occurredAt:i.occurredAt}:{},actor:{kind:"agent"}},i.root);return g({...r,id:t})}function x(e,t){return`${e}${v("sha256").update(t).digest("hex").slice(0,32)}`}function ie(e){return x("SM",`message:${e.occurredAt??""}:${T("message",e.root).length}`)}function re(e){return x("VE",`verification:${e.occurredAt??""}:${T("verification",e.root).length}`)}function se(e){return`PN${v("sha256").update(e).digest("hex").slice(0,32)}`}var N=/^\+[1-9]\d{6,14}$/;function ce(e){return e.length===0||e.length<=160?"1":String(Math.ceil(e.length/153))}function O(e,t){let n=`/${p}/Accounts/${e}/Messages/${t}`;return{uri:`${n}.json`,subresource_uris:{media:`${n}/Media.json`,feedback:`${n}/Feedback.json`}}}async function ue(e,t,n){let o=t.To,i=t.From??"",r=t.Body??"";if(!o)return S(21604,"The destination 'To' phone number is required to send an SMS",400);if(!N.test(o))return S(21211,"Invalid 'To' Phone Number",400);let s=ie(n),u=m(n.occurredAt);await h("message",s,{account_sid:e,api_version:p,body:r,to:o,from:i,direction:"outbound-api",status:"queued",num_segments:ce(r),num_media:"0",messaging_service_sid:t.MessagingServiceSid??null,date_created:_(u),date_updated:_(u),date_sent:null,error_code:null,error_message:null,price:null,price_unit:null,poll_count:0,_status_callback:t.StatusCallback??null},"message.create",n);let c=w("message",s,n.root);return{status:201,body:{...g(c),...O(e,s)}}}async function ae(e,t){let n=w("message",e,t.root);if(!n)return;let o=n.poll_count??0,i=n.status;if(i==="queued"){if(o===0){await h("message",e,{poll_count:o+1},"message.poll",t);return}await h("message",e,{status:"sending",poll_count:o+1},"message.progress",t);return}if(i==="sending"){await h("message",e,{status:"sent",date_sent:_(m(t.occurredAt)),date_updated:_(m(t.occurredAt)),poll_count:o+1},"message.progress",t);return}if(i==="sent"){await h("message",e,{status:"delivered",date_updated:_(m(t.occurredAt)),poll_count:o+1},"message.complete",t);return}}async function le(e,t,n){if(!w("message",t,n.root))return f();n.readOnly||await ae(t,n);let i=w("message",t,n.root);return{status:200,body:{...g(i),...O(e,t)}}}function de(e,t){let n=T("message",t.root).filter(i=>i.account_sid===e).map(i=>({...g(i),...O(e,i.id)})),o=`/${p}/Accounts/${e}/Messages.json`;return{status:200,body:{end:Math.max(n.length-1,0),first_page_uri:`${o}?PageSize=50&Page=0`,next_page_uri:null,page:0,page_size:50,previous_page_uri:null,messages:n,uri:o}}}async function fe(e,t){let n=_(m(t.occurredAt)),o=`/${p}/Accounts/${e}.json`,i=t.readOnly?b(t.root):await y(t.root);return{status:200,body:{sid:e,auth_token:i?.authToken??"",friendly_name:"Twin Account",status:"active",type:"Full",owner_account_sid:e,date_created:n,date_updated:n,uri:o,subresource_uris:{messages:`/${p}/Accounts/${e}/Messages.json`,incoming_phone_numbers:`/${p}/Accounts/${e}/IncomingPhoneNumbers.json`}}}}var pe=[{phone_number:"+15550001111",friendly_name:"Twin Local Number",numberType:"local"},{phone_number:"+18005550100",friendly_name:"Twin Toll-Free Number",numberType:"toll-free"}];async function me(e,t){if(T("phone_number",t.root).length>0)return;let o=_(m(t.occurredAt));for(let i of pe){let r=se(i.phone_number);await h("phone_number",r,{account_sid:e,phone_number:i.phone_number,friendly_name:i.friendly_name,number_type:i.numberType,capabilities:{voice:!0,sms:!0,mms:!0,fax:!1},sms_url:null,voice_url:null,status_callback:null,date_created:o,date_updated:o,uri:`/${p}/Accounts/${e}/IncomingPhoneNumbers/${r}.json`},"phone_number.seed",t)}}async function ge(e,t){await me(e,t);let n=`/${p}/Accounts/${e}/IncomingPhoneNumbers.json`,o=T("phone_number",t.root).filter(i=>i.account_sid===e).map(oe);return{status:200,body:{end:Math.max(o.length-1,0),first_page_uri:`${n}?PageSize=50&Page=0`,next_page_uri:null,page:0,page_size:50,previous_page_uri:null,incoming_phone_numbers:o,uri:n}}}function he(e,t){let n=v("sha256").update(`${e}:${t}`).digest("hex").slice(0,6);return String(parseInt(n,16)%1e6).padStart(6,"0")}function L(e,t){return`${e}::${t}`}function we(e,t,n){return T("verification",n).find(o=>o._lookup_key===L(e,t))}async function _e(e,t,n){let o=t.To,i=t.Channel;if(!o||!i)return S(60200,"Invalid parameter",400);let r=re(n),s=m(n.occurredAt);await h("verification",r,{service_sid:e,account_sid:(await y(n.root)).accountSid,to:o,channel:i,status:"pending",valid:!1,lookup:{},amount:null,payee:null,send_code_attempts:[{time:s,channel:i,attempt_sid:x("VL",`${r}:attempt:0`)}],sna:null,date_created:s,date_updated:s,_lookup_key:L(e,o),_expected_code:he(e,o)},"verification.create",n);let u=w("verification",r,n.root);return{status:201,body:{...g(u),url:`https://verify.twilio.com/v2/Services/${e}/Verifications/${r}`}}}async function Te(e,t,n){let o=t.Code??"",i=t.To,r=t.VerificationSid,s=r?w("verification",r,n.root):void 0;if(!s&&i&&(s=we(e,i,n.root)),!s)return f();let u=s.id;if(s.status==="approved")return{status:200,body:{...g(s),url:`https://verify.twilio.com/v2/Services/${e}/Verifications/${u}`}};let a=s._expected_code;o.length>0&&o===a&&await h("verification",u,{status:"approved",valid:!0,date_updated:m(n.occurredAt)},"verification.check",n);let l=w("verification",u,n.root);return{status:200,body:{...g(l),url:`https://verify.twilio.com/v2/Services/${e}/Verifications/${u}`}}}function ye(e){let t=parseInt(v("sha256").update(e).digest("hex").slice(0,4),16),n=["mobile","landline","voip"];return n[t%n.length]}function Se(e,t,n){if(!N.test(e))return f();let o=e.slice(1),i=o.startsWith("1")&&o.length===11?"US":"XX",r=i==="US"?`(${o.slice(1,4)}) ${o.slice(4,7)}-${o.slice(7)}`:o,s={calling_country_code:o.startsWith("1")?"1":o.slice(0,2),country_code:i,phone_number:e,national_format:r,valid:!0,validation_errors:null,caller_name:null,sim_swap:null,call_forwarding:null,live_activity:null,line_type_intelligence:null,identity_match:null,reassigned_number:null,sms_pumping_risk:null,phone_number_quality_score:null,pre_fill:null,url:`https://lookups.twilio.com/v2/PhoneNumbers/${encodeURIComponent(e)}`};return t.split(",").map(c=>c.trim()).filter(Boolean).includes("line_type_intelligence")&&(s.line_type_intelligence={type:ye(o),mobile_country_code:i==="US"?"310":null,mobile_network_code:i==="US"?"150":null,carrier_name:`Twin Carrier ${o.slice(-3)}`,error_code:null}),{status:200,body:s}}async function C(e){let t=e.method.toUpperCase(),[n,o]=e.path.split("?"),i=(n??"/").replace(/\/+$/,"")||"/",r=W({host:e.host,headers:e.headers,path:i}),s=new URLSearchParams(o??"");if(e.readOnly&&t!=="GET"&&t!=="HEAD")return{status:405,body:{code:20005,message:"twin is read-only; omit readOnly to accept writes",more_info:"https://www.twilio.com/docs/errors/20005",status:405}};if(!e.readOnly){let a=I(e.headers);a&&await y(e.root,a)}let u={};if(t==="POST"||t==="PUT"){let a=ee(e.body);if(!a.ok)return S(60200,"Invalid parameter: request body must be application/x-www-form-urlencoded, not JSON",400);u=a.value}if(i==="/"||i==="")return{status:200,body:{service:"twilio",object:"twin"}};let c=i.replace(/^\/+/,"").split("/").filter(Boolean);if(r==="api"){if(c[0]!==p||c[1]!=="Accounts"||!c[2])return f();let a=decodeURIComponent(c[2]);if(c.length===3&&a.endsWith(".json")&&t==="GET")return await fe(a.slice(0,-5),e);let d=a,l=c.slice(3);if(l.length===1&&l[0]==="Messages.json"&&t==="POST")return ue(d,u,e);if(l.length===1&&l[0]==="Messages.json"&&t==="GET")return de(d,e);if(l.length===2&&l[0]==="Messages"&&l[1].endsWith(".json")&&t==="GET"){let H=l[1].slice(0,-5);return le(d,H,e)}return l.length===1&&l[0]==="IncomingPhoneNumbers.json"&&t==="GET"?ge(d,e):f()}if(r==="verify"){if(c[0]!=="v2"||c[1]!=="Services"||!c[2])return f();let a=decodeURIComponent(c[2]),d=c.slice(3);if(d.length===1&&d[0]==="Verifications"&&t==="POST")return _e(a,u,e);if(d.length===1&&d[0]==="VerificationCheck"&&t==="POST")return Te(a,u,e);if(d.length===2&&d[0]==="Verifications"&&t==="GET"){let l=w("verification",decodeURIComponent(d[1]),e.root);return l?{status:200,body:{...g(l),url:`https://verify.twilio.com/v2/Services/${a}/Verifications/${l.id}`}}:f()}return f()}if(r==="lookup"){if(c[0]!=="v2"||c[1]!=="PhoneNumbers"||!c[2]||t!=="GET")return f();let a=decodeURIComponent(c.slice(2).join("/"));return Se(a,s.get("Fields")??"",e)}return f()}import{serveHttp as Be}from"../../engine/v2/volter_world-core.mjs";import{createTwinFetchFromHandler as be,statefulTwinManifest as ve,withRequestScopes as Ee}from"../../engine/v2/volter_world-core.mjs";function G(e={}){return Ee(be(C,{...e,manifest:ve({vendor:"twilio",twinOf:"the Twilio messaging API",stores:"sent messages progressing queued\u2192sending\u2192sent\u2192delivered, with signed status callbacks"})}))}import{syncPull as Xe}from"../../engine/v2/volter_world-core.mjs";import{declareRateBudget as ke,rateBudgetPath as Ue,rateBudgetWeight as Ve,RateBudget as Fe,RateBudgetError as De}from"../../engine/v2/volter_world-core.mjs";import{RateBudgetError as Ie}from"../../engine/v2/volter_world-core.mjs";var Ae="twilio",U=6e4,V=60,F=300,D={other:2};var $={windowMs:U,ceiling:V,defaultWeight:D.other,maxRetryAfterSeconds:F,rules:[],reason:`Twilio documents the CONCEPT of REST API concurrency without a number: a Twilio-Concurrent-Requests header and error 20429 ("your account exceeds allowed concurrency to Twilio's REST API"), no numeric threshold, and no Retry-After (its guidance is exponential backoff). GET /Messages, this connector's only call, has NO published per-second or per-minute figure. With no documented figure to aim at, this ceiling is pinned to the kernel's conservative fallback (60 units / 60s at weight 2 = 30 calls/min) rather than invented \u2014 no more permissive than an undeclared vendor already gets \u2014 and it happens to sit under the tightest number Twilio publishes anywhere (Verify verification-status polling at 60 requests/minute, alongside 180/hour and 250/day). Weights are flat because no per-endpoint REST rate is published and the one documented tight surface is already above this total. Verify's hour/day tiers are beyond what a 60s rolling window can model and remain the caller's responsibility.`};ke(Ae,$);import{nodeBuiltin as qe}from"../../engine/v2/volter_world-core.mjs";export{G as createTwinFetch};
|
|
2
|
+
import{createHash as k}from"node:crypto";import{applyTwinWrite as Z,projectResources as q,worldNow as ee}from"../../engine/v2/volter_world-core.mjs";import{applyTwinWriteAtomic as z,projectResources as X,nodeBuiltin as J}from"../../engine/v2/volter_world-core.mjs";function Q(){return J("node:crypto")}var M="twilio",A="signing_key",j="signing_key:account";function I(e){return typeof e=="string"&&/^AC[0-9a-fA-F]{32}$/.test(e)}function x(e){return typeof e=="string"&&/^[0-9a-fA-F]{32,}$/.test(e)}function O(e){let t;for(let[a,c]of Object.entries(e??{}))a.toLowerCase()==="authorization"&&(t=c);let n=/^Basic\s+([A-Za-z0-9+/=]+)$/i.exec(t??"");if(!n)return;let o;try{o=Buffer.from(n[1],"base64").toString("utf8")}catch{return}let i=o.indexOf(":");if(i<0)return;let r=o.slice(0,i),s=o.slice(i+1);if(!(!I(r)||!x(s)))return{accountSid:r,authToken:s}}function B(e){let t=e.find(i=>i.type===A&&i.id===j),n=t?._account_sid,o=t?._auth_token;if(!(typeof n!="string"||typeof o!="string")&&!(!n||!o))return{accountSid:n,authToken:o}}function b(e){return B(X(M,e))}function W(e){let t=n=>Q().randomBytes(n).toString("hex");return{accountSid:I(e?.accountSid)?e.accountSid:`AC${t(16)}`,authToken:x(e?.authToken)?e.authToken:t(16)}}async function S(e,t){let n=b(e);if(n)return n;let{value:o}=await z(M,i=>{let r=B(i);if(r)return{kind:"skip",value:r};let s=W(t);return{kind:"write",value:s,write:{operation:"signing_key.create",subjectType:A,subjectId:j,fields:{_account_sid:s.accountSid,_auth_token:s.authToken},actor:{kind:"system"}}}},e);return o}var N="twilio",p="2010-04-01";function te(e){let t={};for(let[n,o]of Object.entries(e??{}))t[n.toLowerCase()]=o;return t}function L(e){let t=te(e.headers),n=(e.path.split("?")[0]??"/").replace(/\/+$/,"")||"/",o=e.host??t.host;return o==="api.twilio.com"?"api":o==="verify.twilio.com"?"verify":o==="lookups.twilio.com"?"lookup":n.includes("/Services/")?"verify":n.includes("/PhoneNumbers/")?"lookup":(n.includes("/Accounts/"),"api")}function v(e,t,n){return{status:n,body:{code:e,message:t,more_info:`https://www.twilio.com/docs/errors/${e}`,status:n}}}function l(){return v(20404,"The requested resource was not found",404)}function ne(e){if(e===void 0||e==="")return{ok:!0,value:{}};let t=e.trim();if(t.startsWith("{")||t.startsWith("["))return{ok:!1};let n=new URLSearchParams(e),o={};for(let[i,r]of n)o[i]=r;return{ok:!0,value:o}}function m(e){return e??ee()}function T(e){return new Date(m(e)).toUTCString().replace("GMT","+0000")}function oe(e,t){return`${e}:${t}`}function y(e,t){let n=`${e}:`;return q(N,t).filter(o=>o.type===e&&o.id.startsWith(n)&&o._deleted!==!0).map(o=>({...o,id:o.id.slice(n.length)}))}function w(e,t,n){return y(e,n).find(o=>o.id===t)}function ie(e){let{type:t,updatedAt:n,...o}=e,i={};for(let[r,s]of Object.entries(o))r.startsWith("_")||(i[r]=s);return i}function g(e){let t=ie(e),{id:n,...o}=t;return{sid:n,...o}}function re(e){let t=g(e),{number_type:n,...o}=t;return{...o,type:n??null}}async function h(e,t,n,o,i){let{resource:r}=await Z(N,{operation:o,subjectType:e,subjectId:oe(e,t),fields:n,...i.occurredAt?{occurredAt:i.occurredAt}:{},actor:{kind:"agent"}},i.root);return g({...r,id:t})}function C(e,t){return`${e}${k("sha256").update(t).digest("hex").slice(0,32)}`}function se(e){return C("SM",`message:${e.occurredAt??""}:${y("message",e.root).length}`)}function ce(e){return C("VE",`verification:${e.occurredAt??""}:${y("verification",e.root).length}`)}function ue(e){return`PN${k("sha256").update(e).digest("hex").slice(0,32)}`}var G=/^\+[1-9]\d{6,14}$/;function ae(e){return e.length===0||e.length<=160?"1":String(Math.ceil(e.length/153))}function $(e,t){let n=`/${p}/Accounts/${e}/Messages/${t}`;return{uri:`${n}.json`,subresource_uris:{media:`${n}/Media.json`,feedback:`${n}/Feedback.json`}}}async function le(e,t,n){let o=t.To,i=t.From??"",r=t.Body??"";if(!o)return v(21604,"The destination 'To' phone number is required to send an SMS",400);if(!G.test(o))return v(21211,"Invalid 'To' Phone Number",400);let s=se(n),a=m(n.occurredAt);await h("message",s,{account_sid:e,api_version:p,body:r,to:o,from:i,direction:"outbound-api",status:"queued",num_segments:ae(r),num_media:"0",messaging_service_sid:t.MessagingServiceSid??null,date_created:T(a),date_updated:T(a),date_sent:null,error_code:null,error_message:null,price:null,price_unit:null,poll_count:0,_status_callback:t.StatusCallback??null},"message.create",n);let c=w("message",s,n.root);return{status:201,body:{...g(c),...$(e,s)}}}async function de(e,t){let n=w("message",e,t.root);if(!n)return;let o=n.poll_count??0,i=n.status;if(i==="queued"){if(o===0){await h("message",e,{poll_count:o+1},"message.poll",t);return}await h("message",e,{status:"sending",poll_count:o+1},"message.progress",t);return}if(i==="sending"){await h("message",e,{status:"sent",date_sent:T(m(t.occurredAt)),date_updated:T(m(t.occurredAt)),poll_count:o+1},"message.progress",t);return}if(i==="sent"){await h("message",e,{status:"delivered",date_updated:T(m(t.occurredAt)),poll_count:o+1},"message.complete",t);return}}async function fe(e,t,n){if(!w("message",t,n.root))return l();n.readOnly||await de(t,n);let i=w("message",t,n.root);return{status:200,body:{...g(i),...$(e,t)}}}function pe(e,t){let n=y("message",t.root).filter(i=>i.account_sid===e).map(i=>({...g(i),...$(e,i.id)})),o=`/${p}/Accounts/${e}/Messages.json`;return{status:200,body:{end:Math.max(n.length-1,0),first_page_uri:`${o}?PageSize=50&Page=0`,next_page_uri:null,page:0,page_size:50,previous_page_uri:null,messages:n,uri:o}}}async function me(e,t){let n=T(m(t.occurredAt)),o=`/${p}/Accounts/${e}.json`,i=t.readOnly?b(t.root):await S(t.root);return{status:200,body:{sid:e,auth_token:i?.authToken??"",friendly_name:"Twin Account",status:"active",type:"Full",owner_account_sid:e,date_created:n,date_updated:n,uri:o,subresource_uris:{messages:`/${p}/Accounts/${e}/Messages.json`,incoming_phone_numbers:`/${p}/Accounts/${e}/IncomingPhoneNumbers.json`}}}}var ge=[{phone_number:"+15550001111",friendly_name:"Twin Local Number",numberType:"local"},{phone_number:"+18005550100",friendly_name:"Twin Toll-Free Number",numberType:"toll-free"}];async function he(e,t){if(y("phone_number",t.root).length>0)return;let o=T(m(t.occurredAt));for(let i of ge){let r=ue(i.phone_number);await h("phone_number",r,{account_sid:e,phone_number:i.phone_number,friendly_name:i.friendly_name,number_type:i.numberType,capabilities:{voice:!0,sms:!0,mms:!0,fax:!1},sms_url:null,voice_url:null,status_callback:null,date_created:o,date_updated:o,uri:`/${p}/Accounts/${e}/IncomingPhoneNumbers/${r}.json`},"phone_number.seed",t)}}async function we(e,t){await he(e,t);let n=`/${p}/Accounts/${e}/IncomingPhoneNumbers.json`,o=y("phone_number",t.root).filter(i=>i.account_sid===e).map(re);return{status:200,body:{end:Math.max(o.length-1,0),first_page_uri:`${n}?PageSize=50&Page=0`,next_page_uri:null,page:0,page_size:50,previous_page_uri:null,incoming_phone_numbers:o,uri:n}}}function _e(e,t){let n=k("sha256").update(`${e}:${t}`).digest("hex").slice(0,6);return String(parseInt(n,16)%1e6).padStart(6,"0")}function U(e,t){return`${e}::${t}`}function Te(e,t,n){return y("verification",n).find(o=>o._lookup_key===U(e,t))}async function ye(e,t,n){let o=t.To,i=t.Channel;if(!o||!i)return v(60200,"Invalid parameter",400);let r=ce(n),s=m(n.occurredAt);await h("verification",r,{service_sid:e,account_sid:(await S(n.root)).accountSid,to:o,channel:i,status:"pending",valid:!1,lookup:{},amount:null,payee:null,send_code_attempts:[{time:s,channel:i,attempt_sid:C("VL",`${r}:attempt:0`)}],sna:null,date_created:s,date_updated:s,_lookup_key:U(e,o),_expected_code:_e(e,o)},"verification.create",n);let a=w("verification",r,n.root);return{status:201,body:{...g(a),url:`https://verify.twilio.com/v2/Services/${e}/Verifications/${r}`}}}async function Se(e,t,n){let o=t.Code??"",i=t.To,r=t.VerificationSid,s=r?w("verification",r,n.root):void 0;if(!s&&i&&(s=Te(e,i,n.root)),!s)return l();let a=s.id;if(s.status==="approved")return{status:200,body:{...g(s),url:`https://verify.twilio.com/v2/Services/${e}/Verifications/${a}`}};let u=s._expected_code;o.length>0&&o===u&&await h("verification",a,{status:"approved",valid:!0,date_updated:m(n.occurredAt)},"verification.check",n);let _=w("verification",a,n.root);return{status:200,body:{...g(_),url:`https://verify.twilio.com/v2/Services/${e}/Verifications/${a}`}}}function be(e){let t=parseInt(k("sha256").update(e).digest("hex").slice(0,4),16),n=["mobile","landline","voip"];return n[t%n.length]}function ve(e,t,n){if(!G.test(e))return l();let o=e.slice(1),i=o.startsWith("1")&&o.length===11?"US":"XX",r=i==="US"?`(${o.slice(1,4)}) ${o.slice(4,7)}-${o.slice(7)}`:o,s={calling_country_code:o.startsWith("1")?"1":o.slice(0,2),country_code:i,phone_number:e,national_format:r,valid:!0,validation_errors:null,caller_name:null,sim_swap:null,call_forwarding:null,live_activity:null,line_type_intelligence:null,identity_match:null,reassigned_number:null,sms_pumping_risk:null,phone_number_quality_score:null,pre_fill:null,url:`https://lookups.twilio.com/v2/PhoneNumbers/${encodeURIComponent(e)}`};return t.split(",").map(c=>c.trim()).filter(Boolean).includes("line_type_intelligence")&&(s.line_type_intelligence={type:be(o),mobile_country_code:i==="US"?"310":null,mobile_network_code:i==="US"?"150":null,carrier_name:`Twin Carrier ${o.slice(-3)}`,error_code:null}),{status:200,body:s}}async function R(e){let t=e.method.toUpperCase(),[n,o]=e.path.split("?"),i=(n??"/").replace(/\/+$/,"")||"/",r=L({host:e.host,headers:e.headers,path:i}),s=new URLSearchParams(o??"");if(e.readOnly&&t!=="GET"&&t!=="HEAD")return{status:405,body:{code:20005,message:"twin is read-only; omit readOnly to accept writes",more_info:"https://www.twilio.com/docs/errors/20005",status:405}};if(!e.readOnly){let u=O(e.headers);u&&await S(e.root,u)}let a={};if(t==="POST"||t==="PUT"){let u=ne(e.body);if(!u.ok)return v(60200,"Invalid parameter: request body must be application/x-www-form-urlencoded, not JSON",400);a=u.value}if(i==="/"||i==="")return{status:200,body:{service:"twilio",object:"twin"}};let c=i.replace(/^\/+/,"").split("/").filter(Boolean);if(r==="api"){if(c[0]!==p||c[1]!=="Accounts"||!c[2])return l();let u=decodeURIComponent(c[2]),d=(e.readOnly?b(e.root):await S(e.root))?.accountSid,_=u.endsWith(".json")?u.slice(0,-5):u;if(d&&_!==d)return l();if(c.length===3&&u.endsWith(".json")&&t==="GET")return await me(u.slice(0,-5),e);let E=u,f=c.slice(3);if(f.length===1&&f[0]==="Messages.json"&&t==="POST")return le(E,a,e);if(f.length===1&&f[0]==="Messages.json"&&t==="GET")return pe(E,e);if(f.length===2&&f[0]==="Messages"&&f[1].endsWith(".json")&&t==="GET"){let K=f[1].slice(0,-5);return fe(E,K,e)}return f.length===1&&f[0]==="IncomingPhoneNumbers.json"&&t==="GET"?we(E,e):l()}if(r==="verify"){if(c[0]!=="v2"||c[1]!=="Services"||!c[2])return l();let u=decodeURIComponent(c[2]),d=c.slice(3);if(d.length===1&&d[0]==="Verifications"&&t==="POST")return ye(u,a,e);if(d.length===1&&d[0]==="VerificationCheck"&&t==="POST")return Se(u,a,e);if(d.length===2&&d[0]==="Verifications"&&t==="GET"){let _=w("verification",decodeURIComponent(d[1]),e.root);return _?{status:200,body:{...g(_),url:`https://verify.twilio.com/v2/Services/${u}/Verifications/${_.id}`}}:l()}return l()}if(r==="lookup"){if(c[0]!=="v2"||c[1]!=="PhoneNumbers"||!c[2]||t!=="GET")return l();let u=decodeURIComponent(c.slice(2).join("/"));return ve(u,s.get("Fields")??"",e)}return l()}import{serveHttp as Ne}from"../../engine/v2/volter_world-core.mjs";import{createTwinFetchFromHandler as Ee,statefulTwinManifest as ke,withRequestScopes as Ae}from"../../engine/v2/volter_world-core.mjs";function V(e={}){return Ae(Ee(R,{...e,manifest:ke({vendor:"twilio",twinOf:"the Twilio messaging API",stores:"sent messages progressing queued\u2192sending\u2192sent\u2192delivered, with signed status callbacks"})}))}import{syncPull as Qe}from"../../engine/v2/volter_world-core.mjs";import{declareRateBudget as Ie,rateBudgetPath as Fe,rateBudgetWeight as De,RateBudget as He,RateBudgetError as Ye}from"../../engine/v2/volter_world-core.mjs";import{RateBudgetError as Oe}from"../../engine/v2/volter_world-core.mjs";var xe="twilio",F=6e4,D=60,H=300,Y={other:2};var P={windowMs:F,ceiling:D,defaultWeight:Y.other,maxRetryAfterSeconds:H,rules:[],reason:`Twilio documents the CONCEPT of REST API concurrency without a number: a Twilio-Concurrent-Requests header and error 20429 ("your account exceeds allowed concurrency to Twilio's REST API"), no numeric threshold, and no Retry-After (its guidance is exponential backoff). GET /Messages, this connector's only call, has NO published per-second or per-minute figure. With no documented figure to aim at, this ceiling is pinned to the kernel's conservative fallback (60 units / 60s at weight 2 = 30 calls/min) rather than invented \u2014 no more permissive than an undeclared vendor already gets \u2014 and it happens to sit under the tightest number Twilio publishes anywhere (Verify verification-status polling at 60 requests/minute, alongside 180/hour and 250/day). Weights are flat because no per-endpoint REST rate is published and the one documented tight surface is already above this total. Verify's hour/day tiers are beyond what a 60s rolling window can model and remain the caller's responsibility.`};Ie(xe,P);import{nodeBuiltin as tt}from"../../engine/v2/volter_world-core.mjs";export{V as createTwinFetch};
|