@ours.network/sdk 1.5.1 → 1.6.0
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/contacts.js +1 -1
- package/dist/api/conversations.js +1 -1
- package/dist/api/files.js +1 -1
- package/dist/api/identity.js +1 -1
- package/dist/api/messaging.d.ts +1 -0
- package/dist/api/messaging.js +1 -1
- package/dist/api/profile.js +1 -1
- package/dist/book.js +1 -1
- package/dist/boot.js +1 -1
- package/dist/{chunk-2LPPMBJO.js → chunk-2AGDAI76.js} +1 -1
- package/dist/chunk-3CS6SGYE.js +2 -0
- package/dist/{chunk-BHXHOLIS.js → chunk-4L37F7EA.js} +1 -1
- package/dist/{chunk-V45U6UR6.js → chunk-4TASOWGY.js} +1 -1
- package/dist/{chunk-Q2KM7EML.js → chunk-5UEWBTIG.js} +1 -1
- package/dist/chunk-65KGEJBX.js +2 -0
- package/dist/{chunk-ELU5JE5X.js → chunk-6MGSS5ZO.js} +1 -1
- package/dist/{chunk-5OFCFCOO.js → chunk-AGWCGBCT.js} +1 -1
- package/dist/{chunk-PE62AXC7.js → chunk-D7I2EFNP.js} +1 -1
- package/dist/{chunk-7ARLMLTM.js → chunk-EVP7IDZJ.js} +1 -1
- package/dist/chunk-FC4ERYFN.js +2 -0
- package/dist/{chunk-OJD7HN2X.js → chunk-FNASW6T5.js} +1 -1
- package/dist/chunk-FYYBC5Q4.js +2 -0
- package/dist/{chunk-W636XKOM.js → chunk-G2ODDJ4Z.js} +1 -1
- package/dist/{chunk-6WJFQZDB.js → chunk-JAT7EOYH.js} +1 -1
- package/dist/{chunk-6DGPJGV6.js → chunk-JGOJHX3P.js} +1 -1
- package/dist/{chunk-JSUSHZQC.js → chunk-MGCRONNT.js} +1 -1
- package/dist/chunk-OA7XXAFG.js +2 -0
- package/dist/chunk-POTB37MR.js +5 -0
- package/dist/{chunk-LYS6K3N2.js → chunk-RJ36BIMK.js} +1 -1
- package/dist/{chunk-VSA5JZ2T.js → chunk-RNIN2NDZ.js} +1 -1
- package/dist/chunk-V7OPRCZ3.js +2 -0
- package/dist/chunk-ZNDBLX5J.js +2 -0
- package/dist/client/http.d.ts +27 -0
- package/dist/client/http.js +1 -1
- package/dist/client.js +1 -1
- package/dist/cluster/control.js +1 -1
- package/dist/cluster/manifest.js +1 -1
- package/dist/connector.js +3 -3
- package/dist/daemon.js +1 -1
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +1 -1
- package/dist/gc.js +1 -1
- package/dist/http/api-routes.js +1 -1
- package/dist/http/server.js +1 -1
- package/dist/identity/hierarchy.js +1 -1
- package/dist/identity/lease.js +1 -1
- package/dist/identity/lifecycle.js +1 -1
- package/dist/identity/model.js +1 -1
- package/dist/identity/provision.js +1 -1
- package/dist/index.js +1 -1
- package/dist/messaging/send.js +1 -1
- package/dist/mufl/handlers.js +1 -1
- package/dist/mufl/tx.js +1 -1
- package/dist/mufl_code/7962BB01B1D3E782A1F80B083A900AEC30BAC8F8CE79282B31821802B94A39B6.muflo +0 -0
- package/dist/notify.d.ts +6 -1
- package/dist/notify.js +1 -1
- package/dist/render/adapt-to-json.js +1 -1
- package/dist/runtime/env.js +1 -1
- package/dist/state.js +1 -1
- package/dist/sweeps.js +1 -1
- package/dist/uploads.d.ts +47 -0
- package/dist/uploads.js +2 -0
- package/package.json +2 -2
- package/dist/chunk-BL54LJNA.js +0 -2
- package/dist/chunk-FUQOCQSL.js +0 -2
- package/dist/chunk-H343HSTY.js +0 -5
- package/dist/chunk-OCOEH3BS.js +0 -2
- package/dist/chunk-OS7QJTVD.js +0 -2
- package/dist/chunk-OTPDDDO2.js +0 -2
- package/dist/chunk-RBFKJ6UR.js +0 -2
package/dist/chunk-OCOEH3BS.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as me}from"./chunk-NBEWKZG4.js";import{d as H}from"./chunk-V64IUVSS.js";import{a as z}from"./chunk-37D5PCFY.js";import{a as le,b as G}from"./chunk-PE62AXC7.js";import{a as pe,d as fe}from"./chunk-Q2KM7EML.js";import{b as ce}from"./chunk-6WJFQZDB.js";import{b as re,c as ae}from"./chunk-FUQOCQSL.js";import{b as de}from"./chunk-W636XKOM.js";import{C as se,a as ne,b as A,l as oe,n as ie}from"./chunk-H343HSTY.js";import{a as D,b as q,c as h,e as j,f as ee,g as te}from"./chunk-LYS6K3N2.js";import{c as I,o as Y,v as Z}from"./chunk-OJD7HN2X.js";import{a as P,b as K,c as M,d as Q,e as R,g as W,h as $,i as d,m as k,p as X}from"./chunk-V45U6UR6.js";import{createServer as Se}from"node:http";import{randomUUID as Ie}from"node:crypto";import*as b from"node:fs";me();function ve(s){if(!s||typeof s!="object"||Array.isArray(s))return!1;let p=s;return p.jsonrpc==="2.0"&&p.method==="initialize"}var Te=["brokerUrl","port","stateDir","gcIntervalMs","apiVisibility"];function ue(s){return new Promise((p,f)=>{let O="";s.on("data",m=>O+=m),s.on("end",()=>{try{p(JSON.parse(O))}catch(m){f(m)}}),s.on("error",f)})}async function ze(s={}){try{return await ke(s)}catch(p){throw $?.failed(),d(`fatal startup error: ${p?.stack??p}`),p}}async function ke(s){let p=s.handleSignals!==!1;if(process.env.OURS_TEST_STARTUP_FAIL==="1")throw new Error("forced startup failure (OURS_TEST_STARTUP_FAIL)");if(s.config){let t=Te.filter(e=>s.config[e]!==K[e]);if(t.length>0)throw new Error(`startDaemon(config) disagrees with the config resolved at module load (${t.join(", ")}). The engine reads its config when src/runtime/env.ts is imported, so a later override cannot move the state dir, port or broker \u2014 set OURS_* env or config.json before importing the SDK.`)}let f=s.mcp,O=f?.isInitializeRequest??ve,m=null;if(typeof s.onIdentityNotify=="function"){let t=s.onIdentityNotify;m=(e,i)=>{t(e,i,D.get(e)?.sid??null)},ne(m)}d("booting wrapper\u2026");try{await ce(),le()}catch(t){throw m&&A(m),G(),t}d(`wrapper ready (identities=${I.size}), starting HTTP server\u2026`),$?.update("server");let l={},v=new Map,T=new Map,ge=3e4,U=t=>{let e=T.get(t);e?e.n++:T.set(t,{n:1,since:Date.now()})},J=t=>{let e=T.get(t);e&&--e.n<=0&&T.delete(t)},B=()=>{let t=0;for(let e of[...v.keys()]){if(e==="stdio")continue;let i=h.get(e)?.pid;if(i===void 0||i<=1||j(i))continue;let n=T.get(e);if(n&&n.n>0&&Date.now()-n.since<ge)continue;let o=v.get(e);v.delete(e),delete l[e],h.delete(e),T.delete(e),o?.close().catch(()=>{}),f?.onSessionClosed?.(e),t++,d(`session ${e.slice(0,8)}\u2026 reaped (client pid ${i} dead)`)}return t},F=setInterval(()=>{B(),ae()},6e4);F.unref?.();let _=1e3,he=10*6e4,u=new Map,ye=(t,e)=>{let i=Array.isArray(e)?e:[e];for(let n of i){let o=n;!o||typeof o!="object"||o.id===void 0||o.id===null||typeof o.method!="string"||u.set(`${t}:${String(o.id)}`,{method:o.method,at:Date.now()})}if(u.size>_){let n=Date.now()-he;for(let[o,r]of u)if(r.at<n&&u.delete(o),u.size<=_)break;for(;u.size>_;){let o=u.keys().next();if(o.done)break;u.delete(o.value)}}},we=(t,e)=>{try{let i=e instanceof Error?e.message:String(e),n=/No connection established for request ID:\s*(\S+)/.exec(i);if(!n)return;let o=n[1],r=u.get(`${t}:${o}`);u.delete(`${t}:${o}`),d(`UNDELIVERABLE RESPONSE session=${t.slice(0,8)}\u2026 request_id=${o} method=${r?.method??"unknown"} age_ms=${r?Date.now()-r.at:"unknown"} at=${new Date().toISOString()} \u2014 the answer was produced but its stream was already gone`)}catch{}},y=Se(async(t,e)=>{let i=new URL(t.url,`http://localhost:${R}`);if(t.method==="GET"&&i.pathname==="/state-dir"){e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify({stateDir:M,version:P,compat:1}));return}if(t.method==="GET"&&(i.pathname==="/version"||i.pathname==="/info")){e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify({name:"ours",version:P,compat:1,protocol:de,pid:process.pid,stateDir:M}));return}if(t.method==="GET"&&i.pathname==="/identities"){if(!k(t,e))return;e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify({identities:[...I.values()].map(n=>({name:n.name,...n.temp?{temporary:!0,stale:!j(n.temp.owner.pid)}:{}}))}));return}if(t.method==="GET"&&i.pathname==="/unread"){if(!k(t,e))return;e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify(ie()));return}{let n=/^\/identities\/([^/]+)\/notifications$/.exec(i.pathname);if(t.method==="GET"&&n){if(!k(t,e))return;let o=decodeURIComponent(n[1]);if(X(o)!==null){e.writeHead(400,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:"invalid identity name"}));return}await oe(t,e,o,i.searchParams.get("since"));return}}{let n=/^\/files\/([^/]+)$/.exec(i.pathname);if(t.method==="GET"&&n){if(!k(t,e))return;let o=decodeURIComponent(n[1]),r=t.headers["x-ours-lease-token"],S=typeof r=="string"&&r?ee(r):void 0,g=S?I.get(S.identity):void 0;if(!g){e.writeHead(401,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:"no identity bound to this session"}));return}let w=Z(g,o);if(!w){e.writeHead(404,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:"no such file for the bound identity (run get_files first, or it belongs to another identity)"}));return}try{let c=b.statSync(w);e.writeHead(200,{"Content-Type":"application/octet-stream","Content-Length":String(c.size)});let C=b.createReadStream(w);C.on("error",()=>{try{e.destroy()}catch{}}),C.pipe(e)}catch(c){e.writeHead(500,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:`failed to read file: ${String(c)}`}))}return}}if(i.pathname.startsWith(pe)){await fe(t,e,i.pathname,ue);return}if(i.pathname!=="/mcp"||!f){e.writeHead(404,{"Content-Type":"text/plain"}),e.end("Not found");return}if(k(t,e))try{if(t.method==="POST"){let n=await ue(t),o=t.headers["mcp-session-id"],r=t.headers["x-ours-lease-token"],S=t.headers["x-ours-client-pid"],g=S?parseInt(S,10):void 0,w={token:r,pid:Number.isInteger(g)?g:void 0};if(o&&l[o]){h.set(o,w),ye(o,n),U(o),H(e);try{await l[o].handleRequest(t,e,n)}finally{J(o)}}else if(!o&&O(n)){B();let c=f.createTransport({sessionIdGenerator:()=>Ie(),onsessioninitialized:a=>{l[a]=c,h.set(a,w),v.set(a,N),f.onSessionInitialized?.(a,N),d(`session ${a.slice(0,8)}\u2026 initialized`)}}),C={sessionId:()=>c.sessionId??"pending",leaseToken:()=>h.get(c.sessionId??"pending")?.token,clientPid:()=>h.get(c.sessionId??"pending")?.pid},N=f.createServer(C);N.server.onerror=a=>we(c.sessionId??"pending",a),c.onclose=()=>{let a=c.sessionId;a&&(delete l[a],v.delete(a),h.delete(a),f.onSessionClosed?.(a),d(`session ${a.slice(0,8)}\u2026 closed (lease kept)`))},await N.connect(c),H(e),await c.handleRequest(t,e,n)}else e.writeHead(400,{"Content-Type":"application/json"}),e.end(JSON.stringify({jsonrpc:"2.0",error:{code:-32e3,message:"Bad Request: No valid session ID"},id:null}))}else if(t.method==="GET"){let n=t.headers["mcp-session-id"];if(!n||!l[n]){e.writeHead(400,{"Content-Type":"text/plain"}),e.end("Invalid or missing session ID");return}U(n),H(e);try{await l[n].handleRequest(t,e)}finally{J(n)}}else if(t.method==="DELETE"){let n=t.headers["mcp-session-id"];if(!n||!l[n]){e.writeHead(400,{"Content-Type":"text/plain"}),e.end("Invalid or missing session ID");return}let o=h.get(n)?.token??t.headers["x-ours-lease-token"];if(o){for(let[r,S]of[...D]){if(S.token!==o)continue;D.delete(r);let g=I.get(r);g?.temp&&g.temp.owner.tokenHash===Y(o)&&!g.temp.closing&&re(g,"owning session released its lease").catch(w=>d(`[${r}] close on lease release failed:`,String(w)))}q.delete(o),te(),d(`lease released by token \u2026${o.slice(-6)}`)}await l[n].handleRequest(t,e)}else e.writeHead(405,{"Content-Type":"text/plain"}),e.end("Method not allowed")}catch(n){d("HTTP handler error:",String(n)),e.headersSent||(e.writeHead(500,{"Content-Type":"application/json"}),e.end(JSON.stringify({jsonrpc:"2.0",error:{code:-32603,message:"Internal server error"},id:null})))}});y.requestTimeout=0;let V=!1,x=async()=>{if(!V){V=!0,clearInterval(F),G(),m&&A(m);for(let t of Object.keys(l)){try{await l[t].close()}catch{}delete l[t]}v.clear();for(let t of I.values())try{se(t)}catch(e){d(`[${t.name}] shutdown save failed:`,String(e))}y.closeAllConnections?.()}};try{await new Promise((t,e)=>{let i=n=>e(n);y.once("error",i),y.listen(R,"127.0.0.1",()=>{y.off("error",i),$?.ready(),d(`MCP server v${s.version??P} ready (transport=http, port=${R}, visibility=${W}, identities=${I.size}, state=${M}, broker=${Q})`),t()})})}catch(t){throw await x(),t}let E=async()=>{d("shutting down\u2026"),await x(),y.close(),process.exit(0)};p&&(process.on("SIGINT",E),process.on("SIGTERM",E));let L=y.address();return{port:typeof L=="object"&&L!==null?L.port:R,close:async()=>{p&&(process.off("SIGINT",E),process.off("SIGTERM",E)),await x(),await new Promise(t=>y.close(()=>t()))}}}export{ze as a};
|
package/dist/chunk-OS7QJTVD.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a}from"./chunk-BL54LJNA.js";import{a as n}from"./chunk-XYU2DSWR.js";var p=class{base;leaseToken;clientPid;apiToken;fetchImpl;constructor(e){this.base=e.url.replace(/\/+$/,""),this.leaseToken=e.leaseToken,this.clientPid=e.clientPid??process.pid,this.apiToken=e.apiToken,this.fetchImpl=e.fetch??globalThis.fetch}headers(e={}){return{"x-ours-lease-token":this.leaseToken,"x-ours-client-pid":String(this.clientPid),...this.apiToken?{"x-ours-api-token":this.apiToken}:{},...e}}async post(e,s){let i=await this.fetchImpl(`${this.base}/api/v1/${e}`,{method:"POST",headers:this.headers({"content-type":"application/json"}),body:JSON.stringify(s??{})}),t;try{t=await i.json()}catch{throw new Error(`${e}: the daemon returned a non-JSON response (HTTP ${i.status})`)}if(t&&typeof t=="object"&&!Array.isArray(t)&&"error"in t){let r=t.error,o=r!==null&&typeof r=="object"&&"code"in r&&"message"in r;if(i.status===400&&o){let{code:y,message:d}=r;throw new a(y,d)}let c=o?r.message:String(r);throw new Error(`${e}: ${c} (HTTP ${i.status})`)}if(!i.ok)throw new Error(`${e}: the daemon returned HTTP ${i.status} with no error field`);return t}async get(e,s){let i=await this.fetchImpl(`${this.base}${e}`,{headers:s?this.headers():{}}),t;try{t=await i.json()}catch{throw new Error(`GET ${e}: the daemon returned a non-JSON response (HTTP ${i.status})`)}if(t&&typeof t=="object"&&"error"in t)throw new Error(`GET ${e}: ${String(t.error)} (HTTP ${i.status})`);if(!i.ok)throw new Error(`GET ${e}: the daemon returned HTTP ${i.status} with no error field`);return t}createIdentity(e){return this.post("createIdentity",e)}createTemporaryIdentity(e){return this.post("createTemporaryIdentity",e)}closeTemporaryIdentityOp(e={}){return this.post("closeTemporaryIdentityOp",e)}createRootIdentity(e){return this.post("createRootIdentity",e)}defineLocalIdentityFile(e){return this.post("defineLocalIdentityFile",e)}chooseIdentity(e){return this.post("chooseIdentity",e)}listIdentities(){return this.post("listIdentities",{})}currentIdentity(){return this.post("currentIdentity",{})}removeIdentity(e){return this.post("removeIdentity",e)}releaseLease(){return this.post("releaseLease",{})}generateInvite(e={}){return this.post("generateInvite",e)}listInvites(){return this.post("listInvites",{})}revokeInvite(e){return this.post("revokeInvite",e)}addContact(e){return this.post("addContact",e)}listContacts(){return this.post("listContacts",{})}listLocalContactBook(){return this.post("listLocalContactBook",{})}setLocalBookPolicy(e){return this.post("setLocalBookPolicy",e)}removeContact(e){return this.post("removeContact",e)}renameContact(e){return this.post("renameContact",e)}respondToIntroduction(e){return this.post("respondToIntroduction",e)}setBio(e){return this.post("setBio",e)}advertiseMigrate(){return this.post("advertiseMigrate",{})}readvertiseOnUpgrade(){return this.post("readvertiseOnUpgrade",{})}setPersona(e){return this.post("setPersona",e)}sendMessage(e){return this.post("sendMessage",e)}sendFile(e){return this.post("sendFile",e)}listIncomingMessages(){return this.post("listIncomingMessages",{})}getMessages(){return this.post("getMessages",{})}deferMessages(e){return this.post("deferMessages",e)}deferFiles(e){return this.post("deferFiles",e)}getConversation(e){return this.post("getConversation",e)}getReceipts(e){return this.post("getReceipts",e)}markRead(e){return this.post("markRead",e)}setConversationPolicy(e){return this.post("setConversationPolicy",e)}listIncomingFiles(){return this.post("listIncomingFiles",{})}getFiles(e={}){return this.post("getFiles",e)}saveFileFallbackNotice(e){return this.post("saveFileFallbackNotice",e)}version(){return this.get("/version",!1)}stateDir(){return this.get("/state-dir",!1)}async identities(){return(await this.get("/identities",!0)).identities}unread(){return this.get("/unread",!0)}async*watchNotifications(e,s={}){let i=s.since??"tip",t=`/identities/${encodeURIComponent(e)}/notifications`;for(;!s.signal?.aborted;){let r;try{let o=await this.fetchImpl(`${this.base}${t}?since=${i}`,{headers:this.headers(),signal:s.signal});try{r=await o.json()}catch{throw new Error(`watchNotifications(${e}): the daemon returned a non-JSON response (HTTP ${o.status})`)}}catch(o){if(s.signal?.aborted)return;throw o}if("error"in r)throw new Error(`watchNotifications(${e}): ${r.error}`);i=r.cursor;for(let o of r.events)yield n(o&&typeof o=="object"?o:{})}}async fetchFile(e){let s=await this.fetchImpl(`${this.base}/files/${encodeURIComponent(e)}`,{headers:this.headers()});if(!s.ok){let i=`HTTP ${s.status}`;try{let t=await s.json();t&&t.error!==void 0&&(i=String(t.error))}catch{}throw new Error(`fetchFile(${e}): ${i}`)}return new Uint8Array(await s.arrayBuffer())}};export{p as a};
|
package/dist/chunk-OTPDDDO2.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as O,g as q}from"./chunk-VXVW4KJU.js";import{a as T,b as C,c as N,d as F}from"./chunk-JSUSHZQC.js";import{a as u}from"./chunk-5OFCFCOO.js";import{A as E,B as P,C as A,D as M,K as c,a as v}from"./chunk-BL54LJNA.js";import{E as k,F as _,G as R,J as p,g as S,h as $,m as x}from"./chunk-H343HSTY.js";import{c as b}from"./chunk-6DGPJGV6.js";import{i as m}from"./chunk-V45U6UR6.js";import{d as B}from"./chunk-LKFYUCN7.js";import{a as I}from"./chunk-P55RJGZU.js";import{readFile as U}from"node:fs/promises";import{basename as z}from"node:path";function L(s,i){if(s)return i!==void 0?{wire_id:s,sentence:i}:{wire_id:s}}async function re(s,i){let t=u(s),{contact:o,text:n}=i,a=L(i.reply_to_wire_id,i.reply_to_sentence);try{let r=await _(async d=>F(await p(t,"::a2a_messaging::send_message",{contact:o,text:n,...a?{reply_to:a}:{}},d)));switch(r.kind){case"refused":m(`[e2e-route] refused cid=${r.cid} wire_id=${r.wireId} (downgrade_refused)`);break;case"migrating":m(`[migration] queued cid=${r.cid} wire_id=${r.wireId} (migrating, ${r.queued} queued)`);break;case"e2e":m(`[e2e-route] cid=${r.cid} wire_id=${r.wireId} verdict=e2e (core delivered over migrated session)${r.notRetained?" NOT RETAINED (oversized)":""}`),r.notRetained&&S(t,{event:"send_not_retained",wire_id:r.wireId,kind:"message"});break;default:break}return r}catch(r){if(!/Unknown contact/.test(String(r)))throw c("send_message",String(r));try{let d=T(t,o);return{kind:"introduced",text:d?await C(t,d,n):await N(t,o,n)}}catch(d){throw c("send_message",String(d),"FALLBACK_FAILED")}}}async function ie(s,i){let t=u(s),{contact:o,path:n,data_base64:a,filename:r,mime:d}=i;if((n?1:0)+(a?1:0)!=1)throw E();let f,g;try{if(n)f=await U(n),g=r??z(n);else{if(!r)throw P();f=Buffer.from(a,"base64"),g=r}}catch(e){throw e instanceof v?e:A(String(e))}let y=d??(n?I(n):""),h=L(i.reply_to_wire_id,i.reply_to_sentence),D=O(),l;try{l=k(e=>q({packet:{NewBinaryFromBuffer:w=>t.pw.packet.NewBinaryFromBuffer(w)},lifetime:e,filename:g,mime:y,payload:f,replyTo:h,cap:D}))}catch(e){throw e instanceof v?e:c("send_file",String(e))}if(!l.ok)throw M({filename:g,bytes:l.bytes,limit:l.cap,envelopeBytes:l.envelopeBytes,maxPayloadBytes:l.maxPayloadBytes});try{let e=await _(async w=>{let V=t.pw.packet.NewBinaryFromBuffer(f).Attach(w);return F(await p(t,"::a2a_messaging::send_file",{contact:o,filename:g,mime:y,data:V,...h?{reply_to:h}:{}},w))});switch(e.kind){case"refused":m(`[e2e-route] refused cid=${e.cid} wire_id=${e.wireId} (downgrade_refused, file)`);break;case"migrating":m(`[migration] file-defer cid=${e.cid} wire_id=${e.wireId} (migrating, not queued)`);break;case"e2e":m(`[e2e-route] cid=${e.cid} wire_id=${e.wireId} verdict=e2e file (core delivered over migrated session)${e.notRetained?" NOT RETAINED (oversized)":""}`),e.notRetained&&S(t,{event:"send_not_retained",wire_id:e.wireId,kind:"file"});break;default:break}return{...e,filename:g,bytes:f.length,mime:y}}catch(e){throw c("send_file",String(e))}}async function ne(s){let i=u(s);try{return k(t=>b(R(i,"::actor::list_incoming_messages",t)))}catch(t){throw c("list_incoming_messages",String(t))}}async function se(s){let i=u(s);try{let t=await _(async n=>{let a=await p(i,"::actor::get_messages",{},n);return b(a.Reduce("messages"))});x(i);let o=$(i);return B(t,o)}catch(t){throw c("get_messages",String(t))}}async function oe(s,i){let t=u(s),{msg_ids:o}=i;try{let n=await _(async a=>(await p(t,"::actor::defer_messages",{msg_ids:o},a)).Reduce("deferred").Visualize());return x(t),{deferred:n}}catch(n){throw c("defer_messages",String(n))}}export{re as a,ie as b,ne as c,se as d,oe as e};
|
package/dist/chunk-RBFKJ6UR.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as d}from"./chunk-5OFCFCOO.js";import{K as r,y as T,z as j}from"./chunk-BL54LJNA.js";import{E as y,F as u,G as p,J as l,N,R as L,S as A,m as z,o as P,t as f}from"./chunk-H343HSTY.js";import{a as C,b as V,g as x,h as I,j as S,k as B}from"./chunk-6DGPJGV6.js";import{d as _,f as k}from"./chunk-LYS6K3N2.js";async function U(s,a={}){let e=d(s),{name:i,mode:o}=a;if(o==="public"&&i)throw T();try{return await u(async t=>{let n={};i&&(n.name=i),o&&(n.mode=o);let c=await l(e,"::a2a_messaging::generate_invite",n,t);return{blob:S(Buffer.from(c.Reduce("invite").GetBinary())),inviteId:c.Reduce("invite_id").Visualize(),mode:c.Reduce("mode").Visualize()==="public"?"public":"one_time"}})}catch(t){throw r("generate_invite",String(t))}}async function $(s){let a=d(s);try{return y(e=>{let i=p(a,"::a2a_messaging::list_invites",e),o=[];if(i.IsNil())return o;for(let t of i.GetKeys()){let n=i.Reduce(t);if(n.IsNil())continue;let c=n.Reduce("assigned").Visualize(),m=n.Reduce("created").Visualize();o.push({invite_id:typeof t=="string"?t:t.Visualize(),mode:n.Reduce("mode").Visualize(),assigned:c==="%%NIL"?"":c,created:m==="%%NIL"?"":m})}return o})}catch(e){throw r("list_invites",String(e))}}async function H(s,a){let e=d(s),{invite_id:i}=a;try{return await u(async o=>{let t=await l(e,"::a2a_messaging::revoke_invite",{invite_id:i},o),n=t.Reduce("was_public");return{revoked:t.Reduce("revoked").GetBoolean(),wasPublic:n.IsNil()?!1:n.GetBoolean()}})}catch(o){throw r("revoke_invite",String(o))}}async function J(s,a){let e=d(s),{invite:i,name:o}=a,t;try{if(t=B(i),t.length===0)throw new Error("the invite blob is empty")}catch(n){throw r("add_contact",n instanceof Error?n.message:"the invite blob is not valid.","INVITE_MALFORMED")}try{return await u(async n=>{let m={invite:e.pw.packet.NewBinaryFromBuffer(t).Attach(n)};o&&(m.name=o);let g=await l(e,"::a2a_messaging::add_contact",m,n),R=g.Reduce("container_id").Visualize(),v=g.Reduce("pending").Visualize(),h=g.Reduce("inviter_name").Visualize(),w=b=>!b||b==="%%NIL",G=w(v)?w(h)?R:h:v;return f(e),{display:G,cid:R}})}catch(n){throw r("add_contact",String(n))}}async function Q(s){let a=d(s);try{return y(e=>({contacts:C(p(a,"::a2a_messaging::list_contacts",e)),pending:x(p(a,"::actor::list_pending_introductions",e)),roots:I(p(a,"::a2a_messaging::list_contact_roots",e)),degraded:P(p(a,"::a2a_messaging::list_degraded_contacts",e)),renames:V(p(a,"::a2a_messaging::list_import_renames",e))}))}catch(e){throw r("list_contacts",String(e))}}async function X(s){let a=Object.values(N()),e=s.leaseToken(),i=e?k(e)?.identity:void 0;return a.map(o=>({name:o.name,container_id:o.container_id,published_at:o.published_at,isMine:o.name===i}))}async function Y(s,a){let e=d(s),{expose:i,auto_accept:o}=a;if(i===void 0&&o===void 0)throw j();let t=[];try{return o!==void 0&&(await u(async n=>{await l(e,"::actor::set_local_policy",{auto_accept:o},n)}),t.push(`auto_accept=${o}`)),i===!0?(await L(e),t.push("published in the local contact book")):i===!1&&(A(e),t.push("removed from the local contact book")),{identity:e.name,changes:t}}catch(n){throw r("set_local_book_policy",String(n))}}async function Z(s,a){let e=d(s),{contact:i}=a;try{return _.add(e.name),await u(async o=>{let t=await l(e,"::a2a_messaging::remove_contact",{contact:i},o),n=t.Reduce("removed").Visualize(),c=t.Reduce("container_id").Visualize(),m=t.Reduce("notified"),g=m.IsNil()?void 0:m.GetBoolean();return{name:n,cid:c,notified:g}})}catch(o){throw r("remove_contact",String(o))}finally{_.delete(e.name)}}async function ee(s,a){let e=d(s),{contact:i,name:o}=a;try{return await u(async t=>{let n=await l(e,"::a2a_messaging::rename_contact",{contact:i,name:o},t);return{from:n.Reduce("renamed").Visualize(),cid:n.Reduce("container_id").Visualize()}})}catch(t){throw r("rename_contact",String(t))}}async function te(s,a){let e=d(s),{contact:i,action:o}=a;try{if(o==="approve"){let t=await u(async n=>{let c=await l(e,"::actor::approve_introduction",{contact:i},n);return{action:"approve",name:c.Reduce("approved").Visualize(),cid:c.Reduce("container_id").Visualize(),flushed:c.Reduce("flushed").Visualize()}});return z(e),f(e),t}return await u(async t=>{let n=await l(e,"::actor::reject_introduction",{contact:i},t);return{action:"reject",name:n.Reduce("rejected").Visualize(),dropped:n.Reduce("dropped_messages").Visualize()}})}catch(t){throw r("respond_to_introduction",String(t))}}export{U as a,$ as b,H as c,J as d,Q as e,X as f,Y as g,Z as h,ee as i,te as j};
|