@ours.network/sdk 1.3.1 → 1.5.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.
Files changed (63) hide show
  1. package/dist/api/contacts.js +1 -1
  2. package/dist/api/conversations.js +1 -1
  3. package/dist/api/files.js +1 -1
  4. package/dist/api/identity.js +1 -1
  5. package/dist/api/messaging.js +1 -1
  6. package/dist/api/profile.js +1 -1
  7. package/dist/book.js +1 -1
  8. package/dist/boot.js +1 -1
  9. package/dist/{chunk-6D4VEJ7G.js → chunk-25ZST4S3.js} +1 -1
  10. package/dist/{chunk-75SBIMZV.js → chunk-2HB7I5JM.js} +1 -1
  11. package/dist/{chunk-QZA7SEVN.js → chunk-4Q5FJDMI.js} +1 -1
  12. package/dist/{chunk-6TQNPR4I.js → chunk-4UYU3SJ3.js} +1 -1
  13. package/dist/chunk-A7MUL47A.js +2 -0
  14. package/dist/{chunk-KM47NXDZ.js → chunk-AC6ND2CA.js} +1 -1
  15. package/dist/chunk-BL54LJNA.js +2 -0
  16. package/dist/{chunk-UXUO7HJ6.js → chunk-GLMGYTRX.js} +1 -1
  17. package/dist/{chunk-2HS7JGHP.js → chunk-KIIBATGV.js} +1 -1
  18. package/dist/{chunk-UN44T5Z5.js → chunk-LFJI7SYO.js} +1 -1
  19. package/dist/{chunk-7MXGWXS4.js → chunk-LLUMHNBP.js} +1 -1
  20. package/dist/{chunk-KBXZ7WK6.js → chunk-MLISCAHB.js} +1 -1
  21. package/dist/{chunk-HVJRHUSY.js → chunk-OCBN326X.js} +1 -1
  22. package/dist/{chunk-XTYFZQI6.js → chunk-OS7QJTVD.js} +1 -1
  23. package/dist/{chunk-G7RFUBUL.js → chunk-PGG2Y65Y.js} +1 -1
  24. package/dist/{chunk-3RMDFCEE.js → chunk-R7NCFWZO.js} +1 -1
  25. package/dist/{chunk-XYSQZW3X.js → chunk-V63EMP3U.js} +1 -1
  26. package/dist/{chunk-JPG44TVX.js → chunk-VVPDTS5O.js} +1 -1
  27. package/dist/chunk-VXVW4KJU.js +2 -0
  28. package/dist/{chunk-EHZNOPG6.js → chunk-WXVWLASM.js} +1 -1
  29. package/dist/{chunk-ZAI7AWG2.js → chunk-XDMG3N3D.js} +1 -1
  30. package/dist/{chunk-QKNFHB65.js → chunk-XWILWDUO.js} +1 -1
  31. package/dist/{chunk-2G3YBZBM.js → chunk-YQQKPG4Q.js} +1 -1
  32. package/dist/client/http.js +1 -1
  33. package/dist/client.js +1 -1
  34. package/dist/cluster/control.js +1 -1
  35. package/dist/cluster/manifest.js +1 -1
  36. package/dist/connector.js +1 -1
  37. package/dist/daemon.js +1 -1
  38. package/dist/errors.d.ts +10 -2
  39. package/dist/errors.js +1 -1
  40. package/dist/gc.js +1 -1
  41. package/dist/http/api-routes.js +1 -1
  42. package/dist/http/server.js +1 -1
  43. package/dist/identity/hierarchy.js +1 -1
  44. package/dist/identity/lease.js +1 -1
  45. package/dist/identity/lifecycle.js +1 -1
  46. package/dist/identity/model.js +1 -1
  47. package/dist/identity/provision.js +1 -1
  48. package/dist/index.d.ts +1 -0
  49. package/dist/index.js +1 -1
  50. package/dist/messaging/file-limit.d.ts +156 -0
  51. package/dist/messaging/file-limit.js +2 -0
  52. package/dist/messaging/send.js +1 -1
  53. package/dist/mufl/handlers.js +1 -1
  54. package/dist/mufl/tx.js +1 -1
  55. package/dist/mufl_code/7962BB01B1D3E782A1F80B083A900AEC30BAC8F8CE79282B31821802B94A39B6.muflo +0 -0
  56. package/dist/notify.js +1 -1
  57. package/dist/render/adapt-to-json.js +1 -1
  58. package/dist/runtime/env.js +1 -1
  59. package/dist/state.js +1 -1
  60. package/dist/sweeps.js +1 -1
  61. package/package.json +3 -3
  62. package/dist/chunk-3S6XRE6Q.js +0 -2
  63. package/dist/chunk-UM73BGFH.js +0 -2
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+ import{object_to_adapt_value as m}from"@adapt-toolkit/sdk/wrapper";var i="w".repeat(64),y=9,c=2097152;function f(){return c}var a=e=>Buffer.byteLength(e,"utf8");function u(e){let r=e.replyTo?a(e.replyTo.wire_id)+32:0;return 2048+2*(a(e.filename)+a(e.mime)+r)}function s(e){return e.bytes+u(e)>e.cap}function l(e){let r=e.packet.NewBinaryFromBuffer(e.payload).Attach(e.lifetime),t=m({filename:e.filename,mime:e.mime,data:r,wire_id:i,...e.replyTo?{reply_to:e.replyTo}:{},pv:y});return t.Attach(e.lifetime),t.Serialize().length}var b=8;function d(e){let r=n=>l({...e,payload:e.payload.subarray(0,n)}),t=e.payload.length;for(let n=0;n<b;n++){let o=r(t);if(o<=e.cap)break;let p=t-(o-e.cap);if(p<=0)return 0;t=p}if(r(t)>e.cap)return 0;for(;t<e.payload.length&&r(t+1)<=e.cap;)t++;return t}function g(e){let r=e.cap??f(),t=e.payload.length;if(!s({bytes:t,filename:e.filename,mime:e.mime,replyTo:e.replyTo,cap:r}))return{ok:!0};let n=l(e);return n<=r?{ok:!0}:{ok:!1,bytes:t,cap:r,envelopeBytes:n,maxPayloadBytes:d({...e,cap:r})}}export{c as a,f as b,u as c,s as d,l as e,d as f,g};
@@ -1,3 +1,3 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{e as a}from"./chunk-ZHH3PWEW.js";import{d as s,f as i,g as u,h as p}from"./chunk-IB2U7K6Y.js";import{timingSafeEqual as d}from"node:crypto";var b="1.3.1",r=s(),_=r.stateDir,k=r.brokerUrl,g=process.env.OURS_TRANSPORT??"http",E=r.port,A=r.gcIntervalMs,c=r.apiVisibility,R=Number(process.env.OURS_TEST_STARTUP_HEARTBEAT_MS||"")||void 0,N=g==="http"?a(_,{heartbeatMs:R}):null,v=(...e)=>process.stderr.write(`ours: ${e.join(" ")}
2
+ import{e as a}from"./chunk-ZHH3PWEW.js";import{d as s,f as i,g as u,h as p}from"./chunk-IB2U7K6Y.js";import{timingSafeEqual as d}from"node:crypto";var b="1.5.0",r=s(),_=r.stateDir,k=r.brokerUrl,g=process.env.OURS_TRANSPORT??"http",E=r.port,A=r.gcIntervalMs,c=r.apiVisibility,R=Number(process.env.OURS_TEST_STARTUP_HEARTBEAT_MS||"")||void 0,N=g==="http"?a(_,{heartbeatMs:R}):null,v=(...e)=>process.stderr.write(`ours: ${e.join(" ")}
3
3
  `);function S(){if(c==="open")return null;if(c==="shared"){let e=u(r);if(!e)throw new Error(`apiVisibility=shared requires an operator-supplied token so it can be distributed to cross-user agents \u2014 set OURS_API_TOKEN or "apiToken" in config (${i(r)} is not used for shared mode). Use apiVisibility=owner for a same-user-only auto-token, or =open to disable auth.`);return e}return p(r,{generate:!0}).token}var f=S();function T(e){let t=e.headers["x-ours-api-token"];if(typeof t=="string"&&t)return t;let o=e.headers.authorization;if(typeof o=="string"){let n=/^Bearer\s+(.+)$/i.exec(o.trim());if(n)return n[1]}}function h(e){if(f===null)return!0;let t=T(e);if(!t)return!1;let o=Buffer.from(t),n=Buffer.from(f);return o.length===n.length&&d(o,n)}function P(e,t){return h(e)?!0:(t.writeHead(401,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:"unauthorized"})),!1)}var O=/^[A-Za-z0-9 _.@-]{1,64}$/,l="contact-book";function y(e){return O.test(e)?e==="."||e===".."||e.includes("/")||e.includes("\\")?"invalid name":e===l?`"${l}" is reserved for the local contact book`:e==="root.json"||e==="bindings.json"?`"${e}" is reserved for daemon bookkeeping`:null:"name must be 1-64 chars of letters, digits, space, _ . @ or -"}export{b as a,r as b,_ as c,k as d,E as e,A as f,c as g,N as h,v as i,f as j,T as k,h as l,P as m,O as n,l as o,y as p};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a as c}from"./chunk-G7RFUBUL.js";import{J as d}from"./chunk-UM73BGFH.js";import{b as g,e as f,f as p}from"./chunk-KBXZ7WK6.js";import{F as o,J as n}from"./chunk-6TQNPR4I.js";import{c as m}from"./chunk-2HS7JGHP.js";import{i as u}from"./chunk-EHZNOPG6.js";async function h(i,s){let e=c(i),{bio:t}=s;try{await o(async a=>{await n(e,"::a2a_messaging::set_my_bio",{bio:t},a)});let r=0;if(e.name===g){for(let a of m.values())if(a.name!==e.name&&f(a).rootCid===e.cid)try{await p(e,a),r+=1}catch(y){u(`failed to refresh root profile in role "${a.name}":`,String(y))}}return{identity:e.name,rolesRefreshed:r}}catch(r){throw d("set_bio",String(r))}}async function x(i){let s=c(i);try{return await o(async e=>{let t=await n(s,"::a2a_messaging::advertise_migrate",{},e);return{wasAdvertising:t.Reduce("was_advertising").Visualize()==="true",advertising:t.Reduce("advertising").Visualize()==="true",offers:parseInt(t.Reduce("offers_initiated").Visualize(),10)||0}})}catch(e){throw d("advertise_migrate",String(e))}}async function P(i,s){let e=c(i),{persona:t}=s;try{return await o(async r=>{await n(e,"::a2a_messaging::set_my_persona",{persona:t},r)}),{identity:e.name}}catch(r){throw d("set_persona",String(r))}}async function C(i){let s=c(i);try{return{readvertised:await o(async t=>(await n(s,"::a2a_messaging::readvertise_on_upgrade",{},t)).Reduce("readvertised").Visualize())}}catch(e){throw d("readvertise_on_upgrade",String(e))}}export{h as a,x as b,P as c,C as d};
2
+ import{a as c}from"./chunk-PGG2Y65Y.js";import{K as d}from"./chunk-BL54LJNA.js";import{b as g,e as f,f as p}from"./chunk-MLISCAHB.js";import{F as o,J as n}from"./chunk-4UYU3SJ3.js";import{c as m}from"./chunk-KIIBATGV.js";import{i as u}from"./chunk-WXVWLASM.js";async function h(i,s){let e=c(i),{bio:t}=s;try{await o(async a=>{await n(e,"::a2a_messaging::set_my_bio",{bio:t},a)});let r=0;if(e.name===g){for(let a of m.values())if(a.name!==e.name&&f(a).rootCid===e.cid)try{await p(e,a),r+=1}catch(y){u(`failed to refresh root profile in role "${a.name}":`,String(y))}}return{identity:e.name,rolesRefreshed:r}}catch(r){throw d("set_bio",String(r))}}async function x(i){let s=c(i);try{return await o(async e=>{let t=await n(s,"::a2a_messaging::advertise_migrate",{},e);return{wasAdvertising:t.Reduce("was_advertising").Visualize()==="true",advertising:t.Reduce("advertising").Visualize()==="true",offers:parseInt(t.Reduce("offers_initiated").Visualize(),10)||0}})}catch(e){throw d("advertise_migrate",String(e))}}async function P(i,s){let e=c(i),{persona:t}=s;try{return await o(async r=>{await n(e,"::a2a_messaging::set_my_persona",{persona:t},r)}),{identity:e.name}}catch(r){throw d("set_persona",String(r))}}async function C(i){let s=c(i);try{return{readvertised:await o(async t=>(await n(s,"::a2a_messaging::readvertise_on_upgrade",{},t)).Reduce("readvertised").Visualize())}}catch(e){throw d("readvertise_on_upgrade",String(e))}}export{h as a,x as b,P as c,C as d};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a as l}from"./chunk-XYSQZW3X.js";import{e as o}from"./chunk-KBXZ7WK6.js";import{F as p,G as f,J as m}from"./chunk-6TQNPR4I.js";import{c as r}from"./chunk-2HS7JGHP.js";import{i as u}from"./chunk-EHZNOPG6.js";var A=()=>d,d=!0,C=d?2:1;function g(e,n){let a=[];for(let t of r.values()){if(t.name===e.name)continue;let i=o(t);if(i.rootCid!==e.cid)continue;let c=f(t,"::actor::export_address_document_native",n);a.push({cid:c.Reduce("identity").Reduce("container_id"),role_id:i.roleId,name:t.name,bio:i.bio,persona:i.persona,caps:l(t),child_ad:c})}return a}var s=new Set;async function y(e){if(!s.has(e.name)){s.add(e.name);try{await p(async n=>{await m(e,"::a2a_cluster::reconcile",{pending_handle:"",children:g(e,n)},n)})}catch(n){u(`[${e.name}] cluster sweep failed:`,String(n))}finally{s.delete(e.name)}}}var w=6e4;function T(){setInterval(()=>{if(d)for(let e of r.values())o(e).roleId===""&&y(e)},w).unref()}export{A as a,C as b,y as c,T as d};
2
+ import{a as l}from"./chunk-V63EMP3U.js";import{e as o}from"./chunk-MLISCAHB.js";import{F as p,G as f,J as m}from"./chunk-4UYU3SJ3.js";import{c as r}from"./chunk-KIIBATGV.js";import{i as u}from"./chunk-WXVWLASM.js";var A=()=>d,d=!0,C=d?2:1;function g(e,n){let a=[];for(let t of r.values()){if(t.name===e.name)continue;let i=o(t);if(i.rootCid!==e.cid)continue;let c=f(t,"::actor::export_address_document_native",n);a.push({cid:c.Reduce("identity").Reduce("container_id"),role_id:i.roleId,name:t.name,bio:i.bio,persona:i.persona,caps:l(t),child_ad:c})}return a}var s=new Set;async function y(e){if(!s.has(e.name)){s.add(e.name);try{await p(async n=>{await m(e,"::a2a_cluster::reconcile",{pending_handle:"",children:g(e,n)},n)})}catch(n){u(`[${e.name}] cluster sweep failed:`,String(n))}finally{s.delete(e.name)}}}var w=6e4;function T(){setInterval(()=>{if(d)for(let e of r.values())o(e).roleId===""&&y(e)},w).unref()}export{A as a,C as b,y as c,T as d};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a as M,b,c as F,d as w,e as T,f as N,g as L,h as H,i as B,j}from"./chunk-KM47NXDZ.js";import{a as E,b as J,c as _,d as $}from"./chunk-UXUO7HJ6.js";import{a as U,b as V,c as X,d as q}from"./chunk-75SBIMZV.js";import{a as z,b as D,c as G,d as K,e as Q}from"./chunk-3S6XRE6Q.js";import{a as W,b as Y,c as Z,d as ee}from"./chunk-ZAI7AWG2.js";import{b as u,c as v,d as k,e as R,f as C,g as S,h as x,i as h,j as P,k as O}from"./chunk-G7RFUBUL.js";import{a as I}from"./chunk-UM73BGFH.js";import{c as d}from"./chunk-HVJRHUSY.js";import{o as f}from"./chunk-2HS7JGHP.js";import{i as m,m as y}from"./chunk-EHZNOPG6.js";var ne="/api/v1/",e=i=>(t,n)=>i(t,n),s=i=>t=>i(t),oe=i=>(t,n)=>i(n),te={createIdentity:e(u),createTemporaryIdentity:e(v),closeTemporaryIdentityOp:e(k),createRootIdentity:e(R),defineLocalIdentityFile:oe(C),chooseIdentity:e(S),listIdentities:s(x),currentIdentity:s(h),removeIdentity:e(P),releaseLease:s(O),generateInvite:e(M),listInvites:s(b),revokeInvite:e(F),addContact:e(w),listContacts:s(T),listLocalContactBook:s(N),setLocalBookPolicy:e(L),removeContact:e(H),renameContact:e(B),respondToIntroduction:e(j),setBio:e(W),advertiseMigrate:s(Y),readvertiseOnUpgrade:s(ee),setPersona:e(Z),sendMessage:e(z),sendFile:e(D),listIncomingMessages:s(G),getMessages:s(K),deferMessages:e(Q),deferFiles:e(q),getConversation:e(E),getReceipts:e(J),markRead:e(_),setConversationPolicy:e($),listIncomingFiles:s(U),getFiles:e(V),saveFileFallbackNotice:e(X)},l=new Map,ie=(i,t)=>{let n=i.headers[t];return typeof n=="string"&&n!==""?n:void 0};function se(i){let t=ie(i,"x-ours-lease-token"),n=ie(i,"x-ours-client-pid"),A=n?parseInt(n,10):NaN,a=Number.isInteger(A)?A:void 0,o=t?`api:${f(t)}`:"api:anonymous";return d.set(o,{token:t,pid:a}),l.set(o,(l.get(o)??0)+1),{ctx:{sessionId:()=>o,leaseToken:()=>d.get(o)?.token,clientPid:()=>d.get(o)?.pid},release:()=>{let r=(l.get(o)??1)-1;if(r>0){l.set(o,r);return}l.delete(o),d.delete(o)}}}var p=(i,t,n)=>{i.writableEnded||(i.writeHead(t,{"Content-Type":"application/json"}),i.end(JSON.stringify(n??null)))};async function fe(i,t,n,A){let a=n.slice(ne.length);if(!y(i,t))return;if(i.method!=="POST"){p(t,405,{error:"method not allowed: the typed API is POST-only"});return}let o=Object.prototype.hasOwnProperty.call(te,a)?te[a]:void 0;if(!o){p(t,404,{error:`unknown operation "${a}"`});return}let r;try{r=await A(i)}catch{p(t,400,{error:"the request body must be JSON"});return}if(r===null||typeof r!="object"||Array.isArray(r)){p(t,400,{error:"the request body must be a JSON object"});return}let g=se(i);try{p(t,200,await o(g.ctx,r))}catch(c){if(c instanceof I){p(t,400,{error:{code:c.code,message:c.message}});return}m("api handler error:",a,String(c)),p(t,500,{error:`internal error in ${a}: ${String(c)}`})}finally{g.release()}}export{ne as a,te as b,se as c,fe as d};
2
+ import{a as M,b,c as F,d as w,e as T,f as N,g as L,h as H,i as B,j}from"./chunk-AC6ND2CA.js";import{a as E,b as J,c as _,d as $}from"./chunk-GLMGYTRX.js";import{a as U,b as V,c as X,d as q}from"./chunk-2HB7I5JM.js";import{a as z,b as D,c as G,d as K,e as Q}from"./chunk-A7MUL47A.js";import{a as W,b as Y,c as Z,d as ee}from"./chunk-XDMG3N3D.js";import{b as u,c as v,d as k,e as R,f as C,g as S,h as x,i as h,j as P,k as O}from"./chunk-PGG2Y65Y.js";import{a as I}from"./chunk-BL54LJNA.js";import{c as d}from"./chunk-OCBN326X.js";import{o as f}from"./chunk-KIIBATGV.js";import{i as m,m as y}from"./chunk-WXVWLASM.js";var ne="/api/v1/",e=i=>(t,n)=>i(t,n),s=i=>t=>i(t),oe=i=>(t,n)=>i(n),te={createIdentity:e(u),createTemporaryIdentity:e(v),closeTemporaryIdentityOp:e(k),createRootIdentity:e(R),defineLocalIdentityFile:oe(C),chooseIdentity:e(S),listIdentities:s(x),currentIdentity:s(h),removeIdentity:e(P),releaseLease:s(O),generateInvite:e(M),listInvites:s(b),revokeInvite:e(F),addContact:e(w),listContacts:s(T),listLocalContactBook:s(N),setLocalBookPolicy:e(L),removeContact:e(H),renameContact:e(B),respondToIntroduction:e(j),setBio:e(W),advertiseMigrate:s(Y),readvertiseOnUpgrade:s(ee),setPersona:e(Z),sendMessage:e(z),sendFile:e(D),listIncomingMessages:s(G),getMessages:s(K),deferMessages:e(Q),deferFiles:e(q),getConversation:e(E),getReceipts:e(J),markRead:e(_),setConversationPolicy:e($),listIncomingFiles:s(U),getFiles:e(V),saveFileFallbackNotice:e(X)},l=new Map,ie=(i,t)=>{let n=i.headers[t];return typeof n=="string"&&n!==""?n:void 0};function se(i){let t=ie(i,"x-ours-lease-token"),n=ie(i,"x-ours-client-pid"),A=n?parseInt(n,10):NaN,a=Number.isInteger(A)?A:void 0,o=t?`api:${f(t)}`:"api:anonymous";return d.set(o,{token:t,pid:a}),l.set(o,(l.get(o)??0)+1),{ctx:{sessionId:()=>o,leaseToken:()=>d.get(o)?.token,clientPid:()=>d.get(o)?.pid},release:()=>{let r=(l.get(o)??1)-1;if(r>0){l.set(o,r);return}l.delete(o),d.delete(o)}}}var p=(i,t,n)=>{i.writableEnded||(i.writeHead(t,{"Content-Type":"application/json"}),i.end(JSON.stringify(n??null)))};async function fe(i,t,n,A){let a=n.slice(ne.length);if(!y(i,t))return;if(i.method!=="POST"){p(t,405,{error:"method not allowed: the typed API is POST-only"});return}let o=Object.prototype.hasOwnProperty.call(te,a)?te[a]:void 0;if(!o){p(t,404,{error:`unknown operation "${a}"`});return}let r;try{r=await A(i)}catch{p(t,400,{error:"the request body must be JSON"});return}if(r===null||typeof r!="object"||Array.isArray(r)){p(t,400,{error:"the request body must be a JSON object"});return}let g=se(i);try{p(t,200,await o(g.ctx,r))}catch(c){if(c instanceof I){p(t,400,{error:{code:c.code,message:c.message}});return}m("api handler error:",a,String(c)),p(t,500,{error:`internal error in ${a}: ${String(c)}`})}finally{g.release()}}export{ne as a,te as b,se as c,fe as d};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a}from"../chunk-XTYFZQI6.js";import"../chunk-UM73BGFH.js";import"../chunk-XYU2DSWR.js";export{a as OursClient};
2
+ import{a}from"../chunk-OS7QJTVD.js";import"../chunk-BL54LJNA.js";import"../chunk-XYU2DSWR.js";export{a as OursClient};
package/dist/client.js CHANGED
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a as D}from"./chunk-XTYFZQI6.js";import{a as F,b as G,c as H,d as I,e as J,f as L}from"./chunk-IDH22QWU.js";import{A as K,B as S,C as U,D as b,E as h,F as l,G as z,H as A,I as B,J as C,a as e,b as o,c as t,d as i,e as n,f as r,g as c,h as R,i as d,j as f,k as p,l as s,m as v,n as a,o as m,p as x,q as E,r as N,s as g,t as y,u as M,v as j,w as k,x as q,y as u,z as w}from"./chunk-UM73BGFH.js";import"./chunk-XYU2DSWR.js";import"./chunk-IB2U7K6Y.js";export{H as DAEMON_TOKEN_FILE,G as DEFAULT_DAEMON_PORT,F as DaemonSelectionError,D as OursClient,e as OursError,L as assertDaemonStateDir,J as describeDaemonConfig,t as errBindingReassigned,y as errBoundElsewhere,i as errBoundIdentityGone,A as errDuplicateId,U as errFileUnreadable,j as errIdentityClosedWithError,q as errIdentityPartiallyRemoved,l as errInvalidSelection,z as errMalformedId,r as errNameTaken,c as errNoLeaseHeaders,x as errNoLeaseToken,w as errNoPolicyArgs,h as errNoRoot,m as errNoSuchIdentity,o as errNotBound,f as errNotBoundNoName,p as errNotTemporary,a as errPathNotAbsolute,u as errPublicInviteNamed,R as errRandomNameExhausted,d as errRootExists,k as errRootHasRoles,b as errSaveFileFallback,K as errSendFileArgs,S as errSendFileFilenameRequired,v as errTempClosedWithError,n as errTempClosingBound,E as errTempClosingChoose,s as errTempOwnedElsewhereClose,M as errTempOwnedElsewhereRemove,N as errTempOwnedLive,g as errTempStale,C as errTool,B as errUnknownOrStaleId,I as resolveDaemonConfig};
2
+ import{a as F}from"./chunk-OS7QJTVD.js";import{a as G,b as H,c as I,d as J,e as L,f as O}from"./chunk-IDH22QWU.js";import{A as K,B as S,C as U,D as b,E as h,F as l,G as z,H as A,I as B,J as C,K as D,a as e,b as o,c as t,d as i,e as n,f as r,g as c,h as R,i as d,j as f,k as p,l as s,m as v,n as a,o as m,p as x,q as E,r as N,s as g,t as y,u as M,v as j,w as k,x as q,y as u,z as w}from"./chunk-BL54LJNA.js";import"./chunk-XYU2DSWR.js";import"./chunk-IB2U7K6Y.js";export{I as DAEMON_TOKEN_FILE,H as DEFAULT_DAEMON_PORT,G as DaemonSelectionError,F as OursClient,e as OursError,O as assertDaemonStateDir,L as describeDaemonConfig,t as errBindingReassigned,y as errBoundElsewhere,i as errBoundIdentityGone,B as errDuplicateId,b as errFileTooLarge,U as errFileUnreadable,j as errIdentityClosedWithError,q as errIdentityPartiallyRemoved,z as errInvalidSelection,A as errMalformedId,r as errNameTaken,c as errNoLeaseHeaders,x as errNoLeaseToken,w as errNoPolicyArgs,l as errNoRoot,m as errNoSuchIdentity,o as errNotBound,f as errNotBoundNoName,p as errNotTemporary,a as errPathNotAbsolute,u as errPublicInviteNamed,R as errRandomNameExhausted,d as errRootExists,k as errRootHasRoles,h as errSaveFileFallback,K as errSendFileArgs,S as errSendFileFilenameRequired,v as errTempClosedWithError,n as errTempClosingBound,E as errTempClosingChoose,s as errTempOwnedElsewhereClose,M as errTempOwnedElsewhereRemove,N as errTempOwnedLive,g as errTempStale,D as errTool,C as errUnknownOrStaleId,J as resolveDaemonConfig};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a,b,c,d}from"../chunk-QKNFHB65.js";import"../chunk-XYSQZW3X.js";import"../chunk-KBXZ7WK6.js";import"../chunk-6TQNPR4I.js";import"../chunk-YRPUM6JG.js";import"../chunk-JPG44TVX.js";import"../chunk-DIRW7I4S.js";import"../chunk-HVJRHUSY.js";import"../chunk-2HS7JGHP.js";import"../chunk-EHZNOPG6.js";import"../chunk-ZHH3PWEW.js";import"../chunk-LKFYUCN7.js";import"../chunk-P55RJGZU.js";import"../chunk-XYU2DSWR.js";import"../chunk-IB2U7K6Y.js";export{b as PROTOCOL_VERSION,c as clusterSweep,a as envelopeDispatch,d as startClusterSweep};
2
+ import{a,b,c,d}from"../chunk-XWILWDUO.js";import"../chunk-V63EMP3U.js";import"../chunk-MLISCAHB.js";import"../chunk-4UYU3SJ3.js";import"../chunk-YRPUM6JG.js";import"../chunk-VVPDTS5O.js";import"../chunk-DIRW7I4S.js";import"../chunk-OCBN326X.js";import"../chunk-KIIBATGV.js";import"../chunk-WXVWLASM.js";import"../chunk-ZHH3PWEW.js";import"../chunk-LKFYUCN7.js";import"../chunk-P55RJGZU.js";import"../chunk-XYU2DSWR.js";import"../chunk-IB2U7K6Y.js";export{b as PROTOCOL_VERSION,c as clusterSweep,a as envelopeDispatch,d as startClusterSweep};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a,b,c,d}from"../chunk-XYSQZW3X.js";import"../chunk-KBXZ7WK6.js";import"../chunk-6TQNPR4I.js";import"../chunk-YRPUM6JG.js";import"../chunk-JPG44TVX.js";import"../chunk-DIRW7I4S.js";import"../chunk-HVJRHUSY.js";import"../chunk-2HS7JGHP.js";import"../chunk-EHZNOPG6.js";import"../chunk-ZHH3PWEW.js";import"../chunk-LKFYUCN7.js";import"../chunk-P55RJGZU.js";import"../chunk-XYU2DSWR.js";import"../chunk-IB2U7K6Y.js";export{b as buildManifest,d as findAgentOf,c as listAgentsFor,a as manifestCapabilities};
2
+ import{a,b,c,d}from"../chunk-V63EMP3U.js";import"../chunk-MLISCAHB.js";import"../chunk-4UYU3SJ3.js";import"../chunk-YRPUM6JG.js";import"../chunk-VVPDTS5O.js";import"../chunk-DIRW7I4S.js";import"../chunk-OCBN326X.js";import"../chunk-KIIBATGV.js";import"../chunk-WXVWLASM.js";import"../chunk-ZHH3PWEW.js";import"../chunk-LKFYUCN7.js";import"../chunk-P55RJGZU.js";import"../chunk-XYU2DSWR.js";import"../chunk-IB2U7K6Y.js";export{b as buildManifest,d as findAgentOf,c as listAgentsFor,a as manifestCapabilities};
package/dist/connector.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a as ne}from"./chunk-5EWCIQH6.js";import{mkdirSync as te,writeFileSync as Te,readFileSync as ve,readdirSync as ke,statSync as j,unlinkSync as Oe,chmodSync as se,createWriteStream as Me}from"node:fs";import{join as x,dirname as Ie,resolve as Ae}from"node:path";import{homedir as Ee}from"node:os";import{Readable as xe}from"node:stream";import{pipeline as De}from"node:stream/promises";var $e="1.3.1",Ne=new Set(["choose_identity","create_identity","create_root_identity"]),Ue="save_file",Le="get_files",re=a=>new Promise(g=>setTimeout(g,a)),V=a=>typeof a?.method=="string"&&a.id!==void 0&&a.id!==null,Ce=a=>a&&typeof a=="object"&&!("method"in a)&&a.id!==void 0&&a.id!==null,oe=a=>{let g=a.result;return!!a.error||!!(g&&g.isError)},ie=Number(process.env.OURS_RESTORE_TTL_MS)>0?Number(process.env.OURS_RESTORE_TTL_MS):7*24*60*60*1e3,ae=["1","true","yes","on"].includes((process.env.OURS_NO_AUTORESTORE??"").trim().toLowerCase());async function ze(a){let g=new URL(a.url),i=(...e)=>process.stderr.write(`[ours-proxy] ${e.join(" ")}
2
+ import{a as ne}from"./chunk-5EWCIQH6.js";import{mkdirSync as te,writeFileSync as Te,readFileSync as ve,readdirSync as ke,statSync as j,unlinkSync as Oe,chmodSync as se,createWriteStream as Me}from"node:fs";import{join as x,dirname as Ie,resolve as Ae}from"node:path";import{homedir as Ee}from"node:os";import{Readable as xe}from"node:stream";import{pipeline as De}from"node:stream/promises";var $e="1.5.0",Ne=new Set(["choose_identity","create_identity","create_root_identity"]),Ue="save_file",Le="get_files",re=a=>new Promise(g=>setTimeout(g,a)),V=a=>typeof a?.method=="string"&&a.id!==void 0&&a.id!==null,Ce=a=>a&&typeof a=="object"&&!("method"in a)&&a.id!==void 0&&a.id!==null,oe=a=>{let g=a.result;return!!a.error||!!(g&&g.isError)},ie=Number(process.env.OURS_RESTORE_TTL_MS)>0?Number(process.env.OURS_RESTORE_TTL_MS):7*24*60*60*1e3,ae=["1","true","yes","on"].includes((process.env.OURS_NO_AUTORESTORE??"").trim().toLowerCase());async function ze(a){let g=new URL(a.url),i=(...e)=>process.stderr.write(`[ours-proxy] ${e.join(" ")}
3
3
  `),z=e=>Number.isInteger(e)&&e>1,q=Number(process.env.OURS_CLIENT_PID),G=z(q)?q:z(process.ppid)?process.ppid:process.pid,B=(process.env.CLAUDE_CODE_SESSION_ID??"").trim()||`client:${G}`,w=null,M=null,$,f=null,I=new Map,N=new Set,_=null,S=ae?null:(process.env.CLAUDE_CODE_SESSION_ID??"").trim()||null,ce=a.stateDir??process.env.OURS_STATE_DIR??x(Ee(),".ours"),R=x(ce,"session-restore"),W=S&&/^[A-Za-z0-9._-]{1,200}$/.test(S)?S:null,y=W?x(R,`${W}.json`):null,Q=!1,U=null;function de(e){if(y)try{te(R,{recursive:!0,mode:448}),Te(y,JSON.stringify({claudeSessionId:S,identity:e,boundAt:new Date().toISOString()}),{mode:384}),se(R,448),se(y,384)}catch(t){i("restore persist failed (non-fatal):",String(t))}}function ue(){if(!y)return null;try{if(Date.now()-j(y).mtimeMs>ie)return null;let e=JSON.parse(ve(y,"utf8"));return(typeof e.identity=="string"?e.identity.trim():"")||null}catch{return null}}function le(){try{let e=Date.now();for(let t of ke(R)){if(!t.endsWith(".json"))continue;let n=x(R,t);try{e-j(n).mtimeMs>ie&&(Oe(n),i("session-restore: pruned expired record",t))}catch{}}}catch{}}let b=(()=>{let e=(process.env.OURS_REQUEST_TIMEOUT_MS??"").trim();if(e==="")return 12e4;let t=Number(e);return Number.isFinite(t)&&t>=0?t:12e4})(),p=new Map,A=new Map;function L(e,t,n){let o=p.get(e);if(!o)return;p.delete(e),o.progressToken!==void 0&&A.delete(o.progressToken);let s=Date.now()-o.sentAt;i(`FAILING BACK request id=${String(e)} method=${o.method} waited_ms=${s} reason=${n}`),m.send({jsonrpc:"2.0",id:e,error:{code:t,message:`ours proxy: no response from the ours daemon for "${o.method}" after ${s}ms (${n}). The request was NOT retried \u2014 retry it yourself if it is safe to repeat.`,data:{reason:n,method:o.method,waitedMs:s}}}).catch(r=>i("fail-back send failed:",String(r)))}b>0&&setInterval(()=>{let t=Date.now();for(let[n,o]of[...p])o.deadline<=t&&L(n,-32001,"watchdog timeout")},1e3).unref?.();let fe=6e4,X=3,C=0,h=0;function pe(e,t){m.send({jsonrpc:"2.0",method:"notifications/message",params:{level:e,logger:"ours-proxy",data:t}}).catch(n=>i("downstream notify failed:",String(n)))}let l=null,me=()=>l,E=!1,T=!1,v=!1,k=[],ge="__ours_proxy_init__",P=0,O=new Set,J=new Set,m=a.transports.createStdioServer();m.onmessage=e=>{let t=[],n=!1;for(let o of D(e)){let s=o;if(s.method==="notifications/initialized"&&(n=!0),V(s)){if(s.method==="initialize"&&(w=s,M)){i("absorbed re-initialize locally \u2014 upstream session kept stable"),m.send({jsonrpc:"2.0",id:s.id,result:M}).catch(r=>i("local initialize reply failed:",String(r)));continue}if(s.method==="tools/call"){let r=s.params;if(r&&Ne.has(r.name??"")&&typeof r.arguments?.name=="string"&&I.set(s.id,r.arguments.name),r?.name===Le&&N.add(s.id),r?.name===Ue){let c=s.params?.arguments??{};we(s.id,c);continue}}if(b>0){let r=s.id,c=s.params?._meta,d=Date.now();p.set(r,{method:typeof s.method=="string"?s.method:"unknown",sentAt:d,deadline:d+b,transport:null,progressToken:c?.progressToken}),c?.progressToken!==void 0&&A.set(c.progressToken,r)}}t.push(s)}if(t.length){let o=Array.isArray(e)?t:t[0];Y(o)}n&&ye()},m.onclose=()=>void H(0),m.onerror=e=>i("downstream error:",String(e));function ye(){if(Q||!f)return;Q=!0;let e=`__ours_proxy_restore_${++P}__`;O.add(e),U=e,i("session-restore: self-recovering bound identity",`"${f}"`),Y({jsonrpc:"2.0",id:e,method:"tools/call",params:{name:"choose_identity",arguments:{name:f}}})}function he(e,t){if(!(b<=0))for(let n of D(e)){let o=n.id;if(o===void 0)continue;let s=p.get(o);s&&(s.transport=t)}}async function we(e,t){let n=String(t.wire_id??"").trim(),o=String(t.dest_path??"").trim(),s=(r,c=!1)=>m.send({jsonrpc:"2.0",id:e,result:{content:[{type:"text",text:r}],isError:c}}).catch(d=>i("save_file reply failed:",String(d)));if(!n||!o){await s("save_file: both `wire_id` and `dest_path` are required.",!0);return}if(!/^[A-Za-z0-9]+$/.test(n)){await s("save_file: invalid wire_id.",!0);return}try{let r=new URL(g.href);r.pathname=`/files/${encodeURIComponent(n)}`,r.search="";let c={"x-ours-lease-token":B};a.apiToken&&(c["x-ours-api-token"]=a.apiToken);let d=await fetch(r,{headers:c});if(d.status===401||d.status===403){await s("save_file: ours daemon authentication failed; the monitor may be disarmed.",!0);return}if(d.status===404){await s(`save_file: no file with wire_id ${n} is available to the bound identity. Run get_files first; it may already be saved, or it belongs to another identity.`,!0);return}if(!d.ok||!d.body){await s(`save_file: ours daemon returned HTTP ${d.status}. Your ours daemon may be too old to support save_file \u2014 update it, or use get_files and copy the returned path yourself.`,!0);return}let u=Ae(o);te(Ie(u),{recursive:!0}),await De(xe.fromWeb(d.body),Me(u));let be=j(u).size;await s(`Saved file (wire_id ${n}) to ${u} (${be} bytes). The bytes were streamed daemon\u2192proxy\u2192disk and never entered this result.`)}catch(r){await s(`save_file failed: ${String(r)}`,!0)}}function Y(e){if(E&&l){let t=l;he(e,t),l.send(e).catch(n=>{i("upstream send failed:",String(n));let o=D(e),s=o.filter(r=>!V(r));s.length&&k.push(Array.isArray(e)?s:s[0]);for(let r of o){let c=r;V(c)&&p.has(c.id)&&L(c.id,-32e3,"upstream send failed")}F(t,"send failed")})}else k.push(e)}function F(e,t){if(T||v||l!==null&&e!==l)return;i(`upstream dropped (${t}) \u2014 reconnecting`),E=!1;let n=l;l=null;try{n?.close?.()}catch{}if(n)for(let[o,s]of[...p])s.transport===n&&L(o,-32e3,`upstream dropped (${t})`);Se()}function _e(e){e.onmessage=t=>{let n=[];for(let o of D(t)){let s=o;if(s.method==="notifications/progress"){let r=s.params?.progressToken;if(r!==void 0){let c=A.get(r),d=c!==void 0?p.get(c):void 0;d&&(d.deadline=Date.now()+b)}}if(Ce(s)){let r=s.id,c=p.get(r);c&&(p.delete(r),c.progressToken!==void 0&&A.delete(c.progressToken));let d=s.result?.protocolVersion;if(d&&(J.has(r)||Z(r))){$=d;try{l?.setProtocolVersion?.(d)}catch{}if(M==null&&Z(r)&&!O.has(r)){let u=s.result??null;u&&_&&(u.instructions=`${u.instructions?u.instructions+`
4
4
 
5
5
  `:""}${_}`),M=u}J.delete(r)}if(O.has(r)){O.delete(r),r===U&&(U=null,oe(s)&&(f=null,i("session-restore: re-bind refused (identity live elsewhere) \u2014 staying unbound")));continue}if(N.has(r)&&(N.delete(r),a.annotateResult?.(s)&&i("get_files: daemon copy unreadable by this OS user \u2014 asked the agent for a destination")),I.has(r)){let u=I.get(r);I.delete(r),oe(s)||(f=u,i("bound identity tracked:",u),de(u))}}n.push(s)}if(n.length){let o=Array.isArray(t)?n:n[0];m.send(o).catch(s=>i("downstream send failed:",String(s)))}},e.onerror=t=>{let n=String(t);if(i("upstream error:",n),!/Maximum reconnection attempts \(\d+\) exceeded/.test(n))return;let o=Date.now();if(o-C<fe){i(`notification stream exhausted again within cooldown \u2014 not escalating (${Math.round((o-C)/1e3)}s since last)`);return}if(C=o,h++,h>X){i(`NOTIFICATION STREAM DEAD \u2014 ${h-1} reconnect escalations exhausted; server\u2192client notifications are NOT arriving`),pe("error",`ours proxy: the server\u2192client notification stream could not be re-established after ${h-1} attempts. Tool calls still work, but you will NOT receive new-mail or other server notifications until this session reconnects. Treat any "waiting for a message" as unreliable.`);return}i(`notification stream exhausted its retries \u2014 escalating to a full reconnect (${h}/${X})`),F(e,"notification stream exhausted")},e.onclose=()=>F(e,"closed")}let Z=e=>w!=null&&w.id===e;async function K(){a.ensureDaemon&&await a.ensureDaemon().catch(t=>i("ensureDaemon:",String(t)));let e=a.transports.createHttpClient(g,{reconnectionOptions:{initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:5},requestInit:{headers:{"x-ours-lease-token":B,"x-ours-client-pid":String(G),...a.apiToken?{"x-ours-api-token":a.apiToken}:{}}}});if(_e(e),await e.start(),$)try{e.setProtocolVersion?.($)}catch{}l=e}async function ee(e,t){t&&e.id!==void 0&&O.add(e.id),await l.send(e)}async function Se(){if(v||T)return;v=!0;let e=500;for(;;){if(T){v=!1;return}try{if(await K(),w){let n=`${ge}${P}`;J.add(n),await ee({...w,id:n},!0),await l.send({jsonrpc:"2.0",method:"notifications/initialized"})}if(f){let n=`__ours_proxy_rebind_${++P}__`;await ee({jsonrpc:"2.0",id:n,method:"tools/call",params:{name:"choose_identity",arguments:{name:f}}},!0)}E=!0;let t=k.splice(0);for(let n of t)await l.send(n).catch(o=>i("flush failed:",String(o)));i("upstream reconnected",f?`(re-bound "${f}")`:""),h=0,v=!1;return}catch(t){i("reconnect attempt failed:",String(t)),await re(e),e=Math.min(Math.floor(e*1.5),1e4)}}}async function H(e){if(!T){T=!0;try{await l?.close()}catch{}try{await m.close()}catch{}process.exit(e)}}process.on("SIGINT",()=>void H(0)),process.on("SIGTERM",()=>void H(0)),process.on("unhandledRejection",e=>{i("UNHANDLED REJECTION (proxy stays up):",e instanceof Error?e.stack??e.message:String(e))}),process.on("uncaughtException",e=>{i("UNCAUGHT EXCEPTION (proxy stays up):",e?.stack??String(e))});async function Re(){let e=new URL(g.href);e.pathname="/state-dir";let t;try{t=await(await fetch(e,{signal:AbortSignal.timeout(3e3)})).json()}catch(n){i("compat handshake: could not read daemon /state-dir, proceeding:",String(n));return}_=ne({selfVersion:$e,daemonVersion:typeof t?.version=="string"?t.version:null}),_&&i(_)}if((async()=>{a.ensureDaemon&&await a.ensureDaemon().catch(n=>i("ensureDaemon:",String(n))),await Re();let e=500;for(;;)try{await K();break}catch(n){i("initial upstream connect failed, retrying:",String(n)),await re(e),e=Math.min(Math.floor(e*1.5),1e4)}E=!0;let t=k.splice(0);for(let n=0;n<t.length;n++){let o=me();if(!o){k.unshift(...t.slice(n));break}await o.send(t[n]).catch(s=>i("flush failed:",String(s)))}i(`upstream ready \u2014 stdio \u21C4 ${g.href}`)})(),S){le();let e=ue();e&&(f=e,i("session-restore: found prior binding for this session \u2014 will self-recover",`"${e}"`))}else ae&&i("session-restore: disabled via OURS_NO_AUTORESTORE \u2014 pure in-memory binding");await m.start(),i("proxy started (stdio transport up)")}function D(a){return Array.isArray(a)?a:[a]}export{ze as runProxy};
package/dist/daemon.js CHANGED
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a as e}from"./chunk-7MXGWXS4.js";import"./chunk-V64IUVSS.js";import"./chunk-37D5PCFY.js";import"./chunk-NBEWKZG4.js";import"./chunk-QZA7SEVN.js";import"./chunk-2G3YBZBM.js";import{b as t}from"./chunk-3RMDFCEE.js";import"./chunk-IU6MOFTJ.js";import"./chunk-KM47NXDZ.js";import"./chunk-UXUO7HJ6.js";import"./chunk-75SBIMZV.js";import"./chunk-3S6XRE6Q.js";import"./chunk-UN44T5Z5.js";import"./chunk-ZAI7AWG2.js";import"./chunk-G7RFUBUL.js";import"./chunk-6D4VEJ7G.js";import"./chunk-UM73BGFH.js";import"./chunk-QKNFHB65.js";import"./chunk-XYSQZW3X.js";import"./chunk-KBXZ7WK6.js";import"./chunk-6TQNPR4I.js";import"./chunk-YRPUM6JG.js";import"./chunk-JPG44TVX.js";import"./chunk-DIRW7I4S.js";import"./chunk-HVJRHUSY.js";import"./chunk-2HS7JGHP.js";import{h as r}from"./chunk-EHZNOPG6.js";import"./chunk-ZHH3PWEW.js";import"./chunk-LKFYUCN7.js";import"./chunk-P55RJGZU.js";import"./chunk-XYU2DSWR.js";import"./chunk-IB2U7K6Y.js";export{t as bootWrapper,e as startDaemon,r as startupProgress};
2
+ import{a as e}from"./chunk-LLUMHNBP.js";import"./chunk-NBEWKZG4.js";import"./chunk-V64IUVSS.js";import"./chunk-37D5PCFY.js";import"./chunk-4Q5FJDMI.js";import"./chunk-YQQKPG4Q.js";import{b as t}from"./chunk-R7NCFWZO.js";import"./chunk-IU6MOFTJ.js";import"./chunk-AC6ND2CA.js";import"./chunk-GLMGYTRX.js";import"./chunk-2HB7I5JM.js";import"./chunk-A7MUL47A.js";import"./chunk-VXVW4KJU.js";import"./chunk-LFJI7SYO.js";import"./chunk-XDMG3N3D.js";import"./chunk-PGG2Y65Y.js";import"./chunk-25ZST4S3.js";import"./chunk-BL54LJNA.js";import"./chunk-XWILWDUO.js";import"./chunk-V63EMP3U.js";import"./chunk-MLISCAHB.js";import"./chunk-4UYU3SJ3.js";import"./chunk-YRPUM6JG.js";import"./chunk-VVPDTS5O.js";import"./chunk-DIRW7I4S.js";import"./chunk-OCBN326X.js";import"./chunk-KIIBATGV.js";import{h as r}from"./chunk-WXVWLASM.js";import"./chunk-ZHH3PWEW.js";import"./chunk-LKFYUCN7.js";import"./chunk-P55RJGZU.js";import"./chunk-XYU2DSWR.js";import"./chunk-IB2U7K6Y.js";export{t as bootWrapper,e as startDaemon,r as startupProgress};
package/dist/errors.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- export type OursErrorCode = 'NOT_BOUND' | 'BINDING_REASSIGNED' | 'BOUND_IDENTITY_GONE' | 'TEMP_CLOSING' | 'NAME_INVALID' | 'NAME_TAKEN' | 'PROVISION_FAILED' | 'NO_LEASE_HEADERS' | 'NO_LEASE_TOKEN' | 'RANDOM_NAME_EXHAUSTED' | 'NOT_BOUND_NO_NAME' | 'NOT_TEMPORARY' | 'TEMP_OWNED_ELSEWHERE' | 'TEMP_STALE' | 'BOUND_ELSEWHERE' | 'DELETE_PARTIAL' | 'CLOSE_FAILED' | 'ROOT_EXISTS' | 'ROOT_HAS_ROLES' | 'NO_SUCH_IDENTITY' | 'PATH_NOT_ABSOLUTE' | 'WRITE_FAILED' | 'PUBLIC_INVITE_NAMED' | 'INVITE_MALFORMED' | 'NO_POLICY_ARGS' | 'SEND_ARGS' | 'FILE_UNREADABLE' | 'FALLBACK_FAILED' | 'CONNECTOR_TOO_OLD' | 'NO_ROOT' | 'TX_FAILED' | 'INVALID_SELECTION' | 'MALFORMED_ID' | 'DUPLICATE_ID' | 'UNKNOWN_OR_STALE_ID';
1
+ export type OursErrorCode = 'NOT_BOUND' | 'BINDING_REASSIGNED' | 'BOUND_IDENTITY_GONE' | 'TEMP_CLOSING' | 'NAME_INVALID' | 'NAME_TAKEN' | 'PROVISION_FAILED' | 'NO_LEASE_HEADERS' | 'NO_LEASE_TOKEN' | 'RANDOM_NAME_EXHAUSTED' | 'NOT_BOUND_NO_NAME' | 'NOT_TEMPORARY' | 'TEMP_OWNED_ELSEWHERE' | 'TEMP_STALE' | 'BOUND_ELSEWHERE' | 'DELETE_PARTIAL' | 'CLOSE_FAILED' | 'ROOT_EXISTS' | 'ROOT_HAS_ROLES' | 'NO_SUCH_IDENTITY' | 'PATH_NOT_ABSOLUTE' | 'WRITE_FAILED' | 'PUBLIC_INVITE_NAMED' | 'INVITE_MALFORMED' | 'NO_POLICY_ARGS' | 'SEND_ARGS' | 'FILE_UNREADABLE' | 'FILE_TOO_LARGE' | 'FALLBACK_FAILED' | 'CONNECTOR_TOO_OLD' | 'NO_ROOT' | 'TX_FAILED' | 'INVALID_SELECTION' | 'MALFORMED_ID' | 'DUPLICATE_ID' | 'UNKNOWN_OR_STALE_ID';
2
2
  export declare class OursError extends Error {
3
3
  readonly code: OursErrorCode;
4
- constructor(code: OursErrorCode, message: string);
4
+ readonly details?: Readonly<Record<string, unknown>> | undefined;
5
+ constructor(code: OursErrorCode, message: string, details?: Readonly<Record<string, unknown>> | undefined);
5
6
  }
6
7
  export declare const errNotBound: () => OursError;
7
8
  export declare const errBindingReassigned: () => OursError;
@@ -31,6 +32,13 @@ export declare const errNoPolicyArgs: () => OursError;
31
32
  export declare const errSendFileArgs: () => OursError;
32
33
  export declare const errSendFileFilenameRequired: () => OursError;
33
34
  export declare const errFileUnreadable: (detail: string) => OursError;
35
+ export declare const errFileTooLarge: (i: {
36
+ filename: string;
37
+ bytes: number;
38
+ limit: number;
39
+ envelopeBytes: number;
40
+ maxPayloadBytes: number;
41
+ }) => OursError;
34
42
  export declare const errSaveFileFallback: (wireId: string, existsOnDisk: boolean) => OursError;
35
43
  export declare const errNoRoot: () => OursError;
36
44
  export declare const errInvalidSelection: (cap: number) => OursError;
package/dist/errors.js CHANGED
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{A,B,C,D,E,F,G,H,I,J,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-UM73BGFH.js";export{a as OursError,c as errBindingReassigned,t as errBoundElsewhere,d as errBoundIdentityGone,H as errDuplicateId,C as errFileUnreadable,v as errIdentityClosedWithError,x as errIdentityPartiallyRemoved,F as errInvalidSelection,G as errMalformedId,f as errNameTaken,g as errNoLeaseHeaders,p as errNoLeaseToken,z as errNoPolicyArgs,E as errNoRoot,o as errNoSuchIdentity,b as errNotBound,j as errNotBoundNoName,k as errNotTemporary,n as errPathNotAbsolute,y as errPublicInviteNamed,h as errRandomNameExhausted,i as errRootExists,w as errRootHasRoles,D as errSaveFileFallback,A as errSendFileArgs,B as errSendFileFilenameRequired,m as errTempClosedWithError,e as errTempClosingBound,q as errTempClosingChoose,l as errTempOwnedElsewhereClose,u as errTempOwnedElsewhereRemove,r as errTempOwnedLive,s as errTempStale,J as errTool,I as errUnknownOrStaleId};
2
+ import{A,B,C,D,E,F,G,H,I,J,K,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"./chunk-BL54LJNA.js";export{a as OursError,c as errBindingReassigned,t as errBoundElsewhere,d as errBoundIdentityGone,I as errDuplicateId,D as errFileTooLarge,C as errFileUnreadable,v as errIdentityClosedWithError,x as errIdentityPartiallyRemoved,G as errInvalidSelection,H as errMalformedId,f as errNameTaken,g as errNoLeaseHeaders,p as errNoLeaseToken,z as errNoPolicyArgs,F as errNoRoot,o as errNoSuchIdentity,b as errNotBound,j as errNotBoundNoName,k as errNotTemporary,n as errPathNotAbsolute,y as errPublicInviteNamed,h as errRandomNameExhausted,i as errRootExists,w as errRootHasRoles,E as errSaveFileFallback,A as errSendFileArgs,B as errSendFileFilenameRequired,m as errTempClosedWithError,e as errTempClosingBound,q as errTempClosingChoose,l as errTempOwnedElsewhereClose,u as errTempOwnedElsewhereRemove,r as errTempOwnedLive,s as errTempStale,K as errTool,J as errUnknownOrStaleId};
package/dist/gc.js CHANGED
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a,b}from"./chunk-QZA7SEVN.js";import"./chunk-6TQNPR4I.js";import"./chunk-YRPUM6JG.js";import"./chunk-JPG44TVX.js";import"./chunk-DIRW7I4S.js";import"./chunk-HVJRHUSY.js";import"./chunk-2HS7JGHP.js";import"./chunk-EHZNOPG6.js";import"./chunk-ZHH3PWEW.js";import"./chunk-LKFYUCN7.js";import"./chunk-P55RJGZU.js";import"./chunk-XYU2DSWR.js";import"./chunk-IB2U7K6Y.js";export{a as startGcTimer,b as stopGcTimer};
2
+ import{a,b}from"./chunk-4Q5FJDMI.js";import"./chunk-4UYU3SJ3.js";import"./chunk-YRPUM6JG.js";import"./chunk-VVPDTS5O.js";import"./chunk-DIRW7I4S.js";import"./chunk-OCBN326X.js";import"./chunk-KIIBATGV.js";import"./chunk-WXVWLASM.js";import"./chunk-ZHH3PWEW.js";import"./chunk-LKFYUCN7.js";import"./chunk-P55RJGZU.js";import"./chunk-XYU2DSWR.js";import"./chunk-IB2U7K6Y.js";export{a as startGcTimer,b as stopGcTimer};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a,b,c,d}from"../chunk-2G3YBZBM.js";import"../chunk-KM47NXDZ.js";import"../chunk-UXUO7HJ6.js";import"../chunk-75SBIMZV.js";import"../chunk-3S6XRE6Q.js";import"../chunk-UN44T5Z5.js";import"../chunk-ZAI7AWG2.js";import"../chunk-G7RFUBUL.js";import"../chunk-6D4VEJ7G.js";import"../chunk-UM73BGFH.js";import"../chunk-QKNFHB65.js";import"../chunk-XYSQZW3X.js";import"../chunk-KBXZ7WK6.js";import"../chunk-6TQNPR4I.js";import"../chunk-YRPUM6JG.js";import"../chunk-JPG44TVX.js";import"../chunk-DIRW7I4S.js";import"../chunk-HVJRHUSY.js";import"../chunk-2HS7JGHP.js";import"../chunk-EHZNOPG6.js";import"../chunk-ZHH3PWEW.js";import"../chunk-LKFYUCN7.js";import"../chunk-P55RJGZU.js";import"../chunk-XYU2DSWR.js";import"../chunk-IB2U7K6Y.js";export{b as API_OPERATIONS,a as API_PREFIX,c as enterApiSession,d as serveApiOperation};
2
+ import{a,b,c,d}from"../chunk-YQQKPG4Q.js";import"../chunk-AC6ND2CA.js";import"../chunk-GLMGYTRX.js";import"../chunk-2HB7I5JM.js";import"../chunk-A7MUL47A.js";import"../chunk-VXVW4KJU.js";import"../chunk-LFJI7SYO.js";import"../chunk-XDMG3N3D.js";import"../chunk-PGG2Y65Y.js";import"../chunk-25ZST4S3.js";import"../chunk-BL54LJNA.js";import"../chunk-XWILWDUO.js";import"../chunk-V63EMP3U.js";import"../chunk-MLISCAHB.js";import"../chunk-4UYU3SJ3.js";import"../chunk-YRPUM6JG.js";import"../chunk-VVPDTS5O.js";import"../chunk-DIRW7I4S.js";import"../chunk-OCBN326X.js";import"../chunk-KIIBATGV.js";import"../chunk-WXVWLASM.js";import"../chunk-ZHH3PWEW.js";import"../chunk-LKFYUCN7.js";import"../chunk-P55RJGZU.js";import"../chunk-XYU2DSWR.js";import"../chunk-IB2U7K6Y.js";export{b as API_OPERATIONS,a as API_PREFIX,c as enterApiSession,d as serveApiOperation};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a}from"../chunk-7MXGWXS4.js";import"../chunk-V64IUVSS.js";import"../chunk-37D5PCFY.js";import"../chunk-NBEWKZG4.js";import"../chunk-QZA7SEVN.js";import"../chunk-2G3YBZBM.js";import"../chunk-3RMDFCEE.js";import"../chunk-IU6MOFTJ.js";import"../chunk-KM47NXDZ.js";import"../chunk-UXUO7HJ6.js";import"../chunk-75SBIMZV.js";import"../chunk-3S6XRE6Q.js";import"../chunk-UN44T5Z5.js";import"../chunk-ZAI7AWG2.js";import"../chunk-G7RFUBUL.js";import"../chunk-6D4VEJ7G.js";import"../chunk-UM73BGFH.js";import"../chunk-QKNFHB65.js";import"../chunk-XYSQZW3X.js";import"../chunk-KBXZ7WK6.js";import"../chunk-6TQNPR4I.js";import"../chunk-YRPUM6JG.js";import"../chunk-JPG44TVX.js";import"../chunk-DIRW7I4S.js";import"../chunk-HVJRHUSY.js";import"../chunk-2HS7JGHP.js";import"../chunk-EHZNOPG6.js";import"../chunk-ZHH3PWEW.js";import"../chunk-LKFYUCN7.js";import"../chunk-P55RJGZU.js";import"../chunk-XYU2DSWR.js";import"../chunk-IB2U7K6Y.js";export{a as startDaemon};
2
+ import{a}from"../chunk-LLUMHNBP.js";import"../chunk-NBEWKZG4.js";import"../chunk-V64IUVSS.js";import"../chunk-37D5PCFY.js";import"../chunk-4Q5FJDMI.js";import"../chunk-YQQKPG4Q.js";import"../chunk-R7NCFWZO.js";import"../chunk-IU6MOFTJ.js";import"../chunk-AC6ND2CA.js";import"../chunk-GLMGYTRX.js";import"../chunk-2HB7I5JM.js";import"../chunk-A7MUL47A.js";import"../chunk-VXVW4KJU.js";import"../chunk-LFJI7SYO.js";import"../chunk-XDMG3N3D.js";import"../chunk-PGG2Y65Y.js";import"../chunk-25ZST4S3.js";import"../chunk-BL54LJNA.js";import"../chunk-XWILWDUO.js";import"../chunk-V63EMP3U.js";import"../chunk-MLISCAHB.js";import"../chunk-4UYU3SJ3.js";import"../chunk-YRPUM6JG.js";import"../chunk-VVPDTS5O.js";import"../chunk-DIRW7I4S.js";import"../chunk-OCBN326X.js";import"../chunk-KIIBATGV.js";import"../chunk-WXVWLASM.js";import"../chunk-ZHH3PWEW.js";import"../chunk-LKFYUCN7.js";import"../chunk-P55RJGZU.js";import"../chunk-XYU2DSWR.js";import"../chunk-IB2U7K6Y.js";export{a as startDaemon};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a,b,c,d,e,f,g}from"../chunk-KBXZ7WK6.js";import"../chunk-6TQNPR4I.js";import"../chunk-YRPUM6JG.js";import"../chunk-JPG44TVX.js";import"../chunk-DIRW7I4S.js";import"../chunk-HVJRHUSY.js";import"../chunk-2HS7JGHP.js";import"../chunk-EHZNOPG6.js";import"../chunk-ZHH3PWEW.js";import"../chunk-LKFYUCN7.js";import"../chunk-P55RJGZU.js";import"../chunk-XYU2DSWR.js";import"../chunk-IB2U7K6Y.js";export{d as clearRootMarker,f as delegateRole,e as describeIdentity,g as establishRoot,c as readRootMarker,b as rootName,a as setRootName};
2
+ import{a,b,c,d,e,f,g}from"../chunk-MLISCAHB.js";import"../chunk-4UYU3SJ3.js";import"../chunk-YRPUM6JG.js";import"../chunk-VVPDTS5O.js";import"../chunk-DIRW7I4S.js";import"../chunk-OCBN326X.js";import"../chunk-KIIBATGV.js";import"../chunk-WXVWLASM.js";import"../chunk-ZHH3PWEW.js";import"../chunk-LKFYUCN7.js";import"../chunk-P55RJGZU.js";import"../chunk-XYU2DSWR.js";import"../chunk-IB2U7K6Y.js";export{d as clearRootMarker,f as delegateRole,e as describeIdentity,g as establishRoot,c as readRootMarker,b as rootName,a as setRootName};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a,b,c,d,e,f,g,h,i}from"../chunk-HVJRHUSY.js";import"../chunk-2HS7JGHP.js";import"../chunk-EHZNOPG6.js";import"../chunk-ZHH3PWEW.js";import"../chunk-IB2U7K6Y.js";export{i as bindSession,f as leaseByToken,a as leases,d as outboundRemovalInFlight,g as persistBindings,e as pidAlive,h as resolveBound,c as sessionHeaders,b as tombstones};
2
+ import{a,b,c,d,e,f,g,h,i}from"../chunk-OCBN326X.js";import"../chunk-KIIBATGV.js";import"../chunk-WXVWLASM.js";import"../chunk-ZHH3PWEW.js";import"../chunk-IB2U7K6Y.js";export{i as bindSession,f as leaseByToken,a as leases,d as outboundRemovalInFlight,g as persistBindings,e as pidAlive,h as resolveBound,c as sessionHeaders,b as tombstones};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a,b,c,d}from"../chunk-6D4VEJ7G.js";import"../chunk-KBXZ7WK6.js";import"../chunk-6TQNPR4I.js";import"../chunk-YRPUM6JG.js";import"../chunk-JPG44TVX.js";import"../chunk-DIRW7I4S.js";import"../chunk-HVJRHUSY.js";import"../chunk-2HS7JGHP.js";import"../chunk-EHZNOPG6.js";import"../chunk-ZHH3PWEW.js";import"../chunk-LKFYUCN7.js";import"../chunk-P55RJGZU.js";import"../chunk-XYU2DSWR.js";import"../chunk-IB2U7K6Y.js";export{b as closeTemporaryIdentity,a as deleteIdentityCompletely,d as sweepOrphanTempDirs,c as sweepStaleTempIdentities};
2
+ import{a,b,c,d}from"../chunk-25ZST4S3.js";import"../chunk-MLISCAHB.js";import"../chunk-4UYU3SJ3.js";import"../chunk-YRPUM6JG.js";import"../chunk-VVPDTS5O.js";import"../chunk-DIRW7I4S.js";import"../chunk-OCBN326X.js";import"../chunk-KIIBATGV.js";import"../chunk-WXVWLASM.js";import"../chunk-ZHH3PWEW.js";import"../chunk-LKFYUCN7.js";import"../chunk-P55RJGZU.js";import"../chunk-XYU2DSWR.js";import"../chunk-IB2U7K6Y.js";export{b as closeTemporaryIdentity,a as deleteIdentityCompletely,d as sweepOrphanTempDirs,c as sweepStaleTempIdentities};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w}from"../chunk-2HS7JGHP.js";import"../chunk-EHZNOPG6.js";import"../chunk-ZHH3PWEW.js";import"../chunk-IB2U7K6Y.js";export{u as FILE_SELECTION_CAP,j as dataPath,m as filesDirFor,v as findIdentityFile,o as hashLeaseToken,c as identities,h as identityDir,t as isSelectableWireId,s as isWireId,i as keyPath,w as listPersistedNames,k as notifyLogPath,q as readTempMetaFile,d as registrar,e as registrarAdBlob,f as setRegistrar,g as setRegistrarAdBlob,b as setWrapper,n as tempMetaPath,r as tightenIdentityPerms,l as unreadPath,a as wrapper,p as writeTempMetaFile};
2
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w}from"../chunk-KIIBATGV.js";import"../chunk-WXVWLASM.js";import"../chunk-ZHH3PWEW.js";import"../chunk-IB2U7K6Y.js";export{u as FILE_SELECTION_CAP,j as dataPath,m as filesDirFor,v as findIdentityFile,o as hashLeaseToken,c as identities,h as identityDir,t as isSelectableWireId,s as isWireId,i as keyPath,w as listPersistedNames,k as notifyLogPath,q as readTempMetaFile,d as registrar,e as registrarAdBlob,f as setRegistrar,g as setRegistrarAdBlob,b as setWrapper,n as tempMetaPath,r as tightenIdentityPerms,l as unreadPath,a as wrapper,p as writeTempMetaFile};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{w as a,x as b,y as c,z as d}from"../chunk-6TQNPR4I.js";import"../chunk-YRPUM6JG.js";import"../chunk-JPG44TVX.js";import"../chunk-DIRW7I4S.js";import"../chunk-HVJRHUSY.js";import"../chunk-2HS7JGHP.js";import"../chunk-EHZNOPG6.js";import"../chunk-ZHH3PWEW.js";import"../chunk-LKFYUCN7.js";import"../chunk-P55RJGZU.js";import"../chunk-XYU2DSWR.js";import"../chunk-IB2U7K6Y.js";export{a as createPacket,c as provisionIdentity,b as reservedNames,d as restoreIdentity};
2
+ import{w as a,x as b,y as c,z as d}from"../chunk-4UYU3SJ3.js";import"../chunk-YRPUM6JG.js";import"../chunk-VVPDTS5O.js";import"../chunk-DIRW7I4S.js";import"../chunk-OCBN326X.js";import"../chunk-KIIBATGV.js";import"../chunk-WXVWLASM.js";import"../chunk-ZHH3PWEW.js";import"../chunk-LKFYUCN7.js";import"../chunk-P55RJGZU.js";import"../chunk-XYU2DSWR.js";import"../chunk-IB2U7K6Y.js";export{a as createPacket,c as provisionIdentity,b as reservedNames,d as restoreIdentity};
package/dist/index.d.ts CHANGED
@@ -10,4 +10,5 @@ export * from './client/http.js';
10
10
  export * from './version-advisory.js';
11
11
  export { FILE_SELECTION_CAP } from './identity/model.js';
12
12
  export * from './events.js';
13
+ export { PINNED_FILE_ENVELOPE_CAP, resolveFileEnvelopeCap, envelopeSkipMargin, needsEnvelopeMeasurement, measureFileEnvelope, maxFilePayloadBytes, checkFileEnvelope, type BinarySource, type ReplyRef, type FileEnvelopeCheck, } from './messaging/file-limit.js';
13
14
  export * from './client/select.js';
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a as ho}from"./chunk-XTYFZQI6.js";import{a as ko,b as lo,c as no,d as qo,e as uo,f as vo}from"./chunk-IDH22QWU.js";import{a as wo}from"./chunk-5EWCIQH6.js";import{a as ro,b as po,c as eo,d as to,e as fo,f as mo,g as xo,h as Eo,i as so,j as yo}from"./chunk-KM47NXDZ.js";import{a as Co,b as Io,c as Lo,d as _o}from"./chunk-UXUO7HJ6.js";import{a as ao,b as io,c as jo,d as Ao}from"./chunk-75SBIMZV.js";import{a as Fo,b as No,c as Oo,d as Po,e as So}from"./chunk-3S6XRE6Q.js";import"./chunk-UN44T5Z5.js";import{a as To,b as bo,c as co,d as go}from"./chunk-ZAI7AWG2.js";import{a as M,b as Q,c as R,d as U,e as V,f as W,g as X,h as Y,i as Z,j as $,k as oo}from"./chunk-G7RFUBUL.js";import"./chunk-6D4VEJ7G.js";import{A as u,B as v,C as w,D as z,E as B,F as D,G,H,I as J,J as K,a as E,b as s,c as y,d as C,e as I,f as L,g as _,h as a,i,j,k as A,l as F,m as N,n as O,o as P,p as S,q as T,r as b,s as c,t as d,u as g,v as h,w as k,x as l,y as n,z as q}from"./chunk-UM73BGFH.js";import"./chunk-QKNFHB65.js";import"./chunk-XYSQZW3X.js";import"./chunk-KBXZ7WK6.js";import"./chunk-6TQNPR4I.js";import"./chunk-YRPUM6JG.js";import"./chunk-JPG44TVX.js";import"./chunk-DIRW7I4S.js";import"./chunk-HVJRHUSY.js";import{u as o}from"./chunk-2HS7JGHP.js";import"./chunk-EHZNOPG6.js";import"./chunk-ZHH3PWEW.js";import"./chunk-LKFYUCN7.js";import"./chunk-P55RJGZU.js";import{a as r,b as p,c as e,d as t,e as f,f as m,g as x}from"./chunk-XYU2DSWR.js";import"./chunk-IB2U7K6Y.js";export{no as DAEMON_TOKEN_FILE,lo as DEFAULT_DAEMON_PORT,ko as DaemonSelectionError,o as FILE_SELECTION_CAP,ho as OursClient,E as OursError,p as VETOABLE_EVENTS,to as addContact,bo as advertiseMigrate,vo as assertDaemonStateDir,X as chooseIdentity,U as closeTemporaryIdentityOp,Q as createIdentity,V as createRootIdentity,R as createTemporaryIdentity,Z as currentIdentity,Ao as deferFiles,So as deferMessages,W as defineLocalIdentityFile,uo as describeDaemonConfig,m as emitDaemonEvent,x as emitDaemonNotification,y as errBindingReassigned,d as errBoundElsewhere,C as errBoundIdentityGone,H as errDuplicateId,w as errFileUnreadable,h as errIdentityClosedWithError,l as errIdentityPartiallyRemoved,D as errInvalidSelection,G as errMalformedId,L as errNameTaken,_ as errNoLeaseHeaders,S as errNoLeaseToken,q as errNoPolicyArgs,B as errNoRoot,P as errNoSuchIdentity,s as errNotBound,j as errNotBoundNoName,A as errNotTemporary,O as errPathNotAbsolute,n as errPublicInviteNamed,a as errRandomNameExhausted,i as errRootExists,k as errRootHasRoles,z as errSaveFileFallback,u as errSendFileArgs,v as errSendFileFilenameRequired,N as errTempClosedWithError,I as errTempClosingBound,T as errTempClosingChoose,F as errTempOwnedElsewhereClose,g as errTempOwnedElsewhereRemove,b as errTempOwnedLive,c as errTempStale,K as errTool,J as errUnknownOrStaleId,wo as formatVersionAdvisory,ro as generateInvite,Co as getConversation,io as getFiles,Po as getMessages,Io as getReceipts,f as isDefaultHandler,fo as listContacts,Y as listIdentities,ao as listIncomingFiles,Oo as listIncomingMessages,po as listInvites,mo as listLocalContactBook,Lo as markRead,r as normalizeNotificationEvent,go as readvertiseOnUpgrade,oo as releaseLease,Eo as removeContact,$ as removeIdentity,so as renameContact,M as requireBound,t as resetDaemonEventHandlers,qo as resolveDaemonConfig,yo as respondToIntroduction,eo as revokeInvite,jo as saveFileFallbackNotice,No as sendFile,Fo as sendMessage,To as setBio,_o as setConversationPolicy,e as setDaemonEventHandler,xo as setLocalBookPolicy,co as setPersona};
2
+ import{a as De}from"./chunk-OS7QJTVD.js";import{a as Te,b as Ve,c as be,d as qe,e as we,f as ze}from"./chunk-IDH22QWU.js";import{a as Ge}from"./chunk-5EWCIQH6.js";import{a as Ee,b as ne,c as ae,d as ie,e as ye,f as se,g as ve,h as Fe,i as Ce,j as Pe}from"./chunk-AC6ND2CA.js";import{a as _e,b as ce,c as Ie,d as Le}from"./chunk-GLMGYTRX.js";import{a as Ne,b as ke,c as ue,d as Se}from"./chunk-2HB7I5JM.js";import{a as de,b as he,c as Ae,d as Be,e as Me}from"./chunk-A7MUL47A.js";import{a as o,b as r,c as p,d as t,e as m,f,g as x}from"./chunk-VXVW4KJU.js";import"./chunk-LFJI7SYO.js";import{a as Oe,b as Re,c as ge,d as je}from"./chunk-XDMG3N3D.js";import{a as Z,b as $,c as ee,d as oe,e as re,f as pe,g as te,h as me,i as fe,j as xe,k as le}from"./chunk-PGG2Y65Y.js";import"./chunk-25ZST4S3.js";import{A as w,B as z,C as G,D as H,E as J,F as K,G as Q,H as U,I as W,J as X,K as Y,a as v,b as F,c as C,d as P,e as _,f as c,g as I,h as L,i as N,j as k,k as u,l as S,m as d,n as h,o as A,p as B,q as M,r as O,s as R,t as g,u as j,v as D,w as T,x as V,y as b,z as q}from"./chunk-BL54LJNA.js";import"./chunk-XWILWDUO.js";import"./chunk-V63EMP3U.js";import"./chunk-MLISCAHB.js";import"./chunk-4UYU3SJ3.js";import"./chunk-YRPUM6JG.js";import"./chunk-VVPDTS5O.js";import"./chunk-DIRW7I4S.js";import"./chunk-OCBN326X.js";import{u as e}from"./chunk-KIIBATGV.js";import"./chunk-WXVWLASM.js";import"./chunk-ZHH3PWEW.js";import"./chunk-LKFYUCN7.js";import"./chunk-P55RJGZU.js";import{a as l,b as E,c as n,d as a,e as i,f as y,g as s}from"./chunk-XYU2DSWR.js";import"./chunk-IB2U7K6Y.js";export{be as DAEMON_TOKEN_FILE,Ve as DEFAULT_DAEMON_PORT,Te as DaemonSelectionError,e as FILE_SELECTION_CAP,De as OursClient,v as OursError,o as PINNED_FILE_ENVELOPE_CAP,E as VETOABLE_EVENTS,ie as addContact,Re as advertiseMigrate,ze as assertDaemonStateDir,x as checkFileEnvelope,te as chooseIdentity,oe as closeTemporaryIdentityOp,$ as createIdentity,re as createRootIdentity,ee as createTemporaryIdentity,fe as currentIdentity,Se as deferFiles,Me as deferMessages,pe as defineLocalIdentityFile,we as describeDaemonConfig,y as emitDaemonEvent,s as emitDaemonNotification,p as envelopeSkipMargin,C as errBindingReassigned,g as errBoundElsewhere,P as errBoundIdentityGone,W as errDuplicateId,H as errFileTooLarge,G as errFileUnreadable,D as errIdentityClosedWithError,V as errIdentityPartiallyRemoved,Q as errInvalidSelection,U as errMalformedId,c as errNameTaken,I as errNoLeaseHeaders,B as errNoLeaseToken,q as errNoPolicyArgs,K as errNoRoot,A as errNoSuchIdentity,F as errNotBound,k as errNotBoundNoName,u as errNotTemporary,h as errPathNotAbsolute,b as errPublicInviteNamed,L as errRandomNameExhausted,N as errRootExists,T as errRootHasRoles,J as errSaveFileFallback,w as errSendFileArgs,z as errSendFileFilenameRequired,d as errTempClosedWithError,_ as errTempClosingBound,M as errTempClosingChoose,S as errTempOwnedElsewhereClose,j as errTempOwnedElsewhereRemove,O as errTempOwnedLive,R as errTempStale,Y as errTool,X as errUnknownOrStaleId,Ge as formatVersionAdvisory,Ee as generateInvite,_e as getConversation,ke as getFiles,Be as getMessages,ce as getReceipts,i as isDefaultHandler,ye as listContacts,me as listIdentities,Ne as listIncomingFiles,Ae as listIncomingMessages,ne as listInvites,se as listLocalContactBook,Ie as markRead,f as maxFilePayloadBytes,m as measureFileEnvelope,t as needsEnvelopeMeasurement,l as normalizeNotificationEvent,je as readvertiseOnUpgrade,le as releaseLease,Fe as removeContact,xe as removeIdentity,Ce as renameContact,Z as requireBound,a as resetDaemonEventHandlers,qe as resolveDaemonConfig,r as resolveFileEnvelopeCap,Pe as respondToIntroduction,ae as revokeInvite,ue as saveFileFallbackNotice,he as sendFile,de as sendMessage,Oe as setBio,Le as setConversationPolicy,n as setDaemonEventHandler,ve as setLocalBookPolicy,ge as setPersona};
@@ -0,0 +1,156 @@
1
+ import type { AdaptValue } from '@adapt-toolkit/sdk/backend';
2
+ import type { AdaptObjectLifetime } from '@adapt-toolkit/sdk/common';
3
+ /**
4
+ * Just enough of `AdaptPacketContext` to build a binary leaf.
5
+ *
6
+ * Deliberately structural rather than the concrete type: it lets the regression
7
+ * drive these helpers against `AdaptEnvironment.EmptyPacket()` — no identity, no
8
+ * compiled .muflo, no state dir, no daemon, no broker — which is what makes the
9
+ * flip-point assertions cheap enough to keep in CI forever.
10
+ */
11
+ export interface BinarySource {
12
+ NewBinaryFromBuffer(buffer: Uint8Array): AdaptValue;
13
+ }
14
+ /** `$reply_to` as the core's `a2a_protocol::reply_ref_t` sees it. */
15
+ export interface ReplyRef {
16
+ wire_id: string;
17
+ sentence?: number;
18
+ }
19
+ /**
20
+ * Compatibility FALLBACK for the cap — not the source of truth.
21
+ * `unacked_file_entry_max_bytes` (a2a_messaging.mm:162).
22
+ */
23
+ export declare const PINNED_FILE_ENVELOPE_CAP = 2097152;
24
+ /**
25
+ * The cap this SDK enforces, behind ONE accessor so the proposed core
26
+ * `trn readonly get_limits` is a drop-in later (query once per identity at bind,
27
+ * cache, fall back to the pin). No core exposes such a transaction today — the
28
+ * only introspection trn is `get_version` (a2a_messaging.mm:2927) — so this
29
+ * returns the pin unconditionally, and behaviour against EVERY shipped core is
30
+ * the pinned path.
31
+ *
32
+ * Skew, both directions, stated plainly:
33
+ *
34
+ * - Core cap HIGHER than the pin → we refuse sends the core would have
35
+ * retained. A false refusal: conservative, visible, fixed by an SDK bump.
36
+ * - Core cap LOWER than the pin → we admit a send the core will not retain,
37
+ * i.e. exactly today's behaviour. Pre-flight CANNOT catch this direction,
38
+ * which is the whole reason `notRetained` must stay on the success result
39
+ * (see api/messaging.ts sendFile). It is the only detector left for it.
40
+ */
41
+ export declare function resolveFileEnvelopeCap(): number;
42
+ /**
43
+ * Bytes of headroom below the cap within which a send MUST be measured rather
44
+ * than assumed to fit.
45
+ *
46
+ * A FIXED threshold here is unsound, and that is a correctness bug rather than a
47
+ * tuning preference: overhead grows with metadata, and nothing bounds
48
+ * `filename`, `mime` or `reply_to.wire_id` at the call site. MEASURED overheads
49
+ * (payload 1,000 bytes; reproduced by test/file-limit.test.mjs):
50
+ *
51
+ * filename 5ch, mime 24ch, no reply_to → 814
52
+ * filename 204ch → 1,047 (+233 for +199 chars)
53
+ * filename 1,000ch → 1,843
54
+ * filename 8,000ch → 8,846 ← past a fixed 8,192
55
+ * filename 60,000ch → 60,846
56
+ * mime 8,000ch → 8,825
57
+ * reply_to {wire_id: 64} → 1,144
58
+ * reply_to {wire_id: 64, sentence} → 1,235
59
+ * reply_to {wire_id: 4,000, sentence} → 5,171
60
+ *
61
+ * A fixed 8,192-byte skip band therefore ADMITS an over-cap send as soon as the
62
+ * filename passes ~8,000 bytes — silently reproducing the very defect this
63
+ * module exists to fix, in the one case a caller cannot see. So the margin is
64
+ * DERIVED per send: a 2,048-byte floor (dominates the 781–820 metadata-free
65
+ * overhead at every payload size) plus 2× the metadata bytes (dominates the
66
+ * measured ~1.0–1.42 bytes of envelope per metadata byte, with room for
67
+ * length-prefix growth).
68
+ *
69
+ * ⚠ UTF-8 BYTES, NOT CHARACTERS. MEASURED: 100 accented characters cost 1,043
70
+ * where 100 ASCII characters cost 943 — the envelope tracks ENCODED bytes.
71
+ * Switching this to `.length` would quietly reintroduce the bug for every
72
+ * non-ASCII filename.
73
+ *
74
+ * Ordinary sends (short name, no reply reference) keep a ~2 KiB skip band, so
75
+ * the hot path never pays for a Serialize(); only sends genuinely near the cap do.
76
+ */
77
+ export declare function envelopeSkipMargin(i: {
78
+ filename: string;
79
+ mime: string;
80
+ replyTo?: ReplyRef;
81
+ }): number;
82
+ /** True when this send is close enough to the cap that it must be measured. */
83
+ export declare function needsEnvelopeMeasurement(i: {
84
+ bytes: number;
85
+ filename: string;
86
+ mime: string;
87
+ replyTo?: ReplyRef;
88
+ cap: number;
89
+ }): boolean;
90
+ /**
91
+ * Serialized length of the EXACT envelope the core will build for this send —
92
+ * the SDK's reproduction of `_binlen (_write $filename,$mime,$data,$wire_id,$reply_to,$pv)`.
93
+ *
94
+ * Two details that are load-bearing:
95
+ * - `payload` is used AS-IS. Callers pass a subarray of the buffer they already
96
+ * hold, so solving for the ceiling never allocates a second multi-MiB copy.
97
+ * - `reply_to` is OMITTED when absent. The core writes `$reply_to -> reply_to`
98
+ * unconditionally with a NIL value there, and a NIL field contributes
99
+ * nothing — MEASURED: omitting it agrees exactly with all four live flip points.
100
+ */
101
+ export declare function measureFileEnvelope(i: {
102
+ packet: BinarySource;
103
+ lifetime: AdaptObjectLifetime;
104
+ filename: string;
105
+ mime: string;
106
+ payload: Uint8Array;
107
+ replyTo?: ReplyRef;
108
+ }): number;
109
+ /**
110
+ * Largest payload THIS exact envelope — same filename, same mime, same reply
111
+ * reference — can carry under `cap`.
112
+ *
113
+ * This is the number a caller can act on ("trim 1,844 bytes" or "shorten the
114
+ * filename"), which a global constant can never be.
115
+ *
116
+ * Newton-style: subtract the overshoot, re-measure, then walk up while the next
117
+ * byte still fits (overhead SHRINKS as the payload does — 820 → 814 → 781 across
118
+ * the range — so a byte or two of slack is left behind otherwise). Every
119
+ * measurement reuses a subarray of `payload`, so the solve allocates no new
120
+ * payload buffers. Returns the last value proven to fit.
121
+ */
122
+ export declare function maxFilePayloadBytes(i: {
123
+ packet: BinarySource;
124
+ lifetime: AdaptObjectLifetime;
125
+ filename: string;
126
+ mime: string;
127
+ payload: Uint8Array;
128
+ replyTo?: ReplyRef;
129
+ cap: number;
130
+ }): number;
131
+ export type FileEnvelopeCheck = {
132
+ ok: true;
133
+ } | {
134
+ ok: false;
135
+ bytes: number;
136
+ cap: number;
137
+ envelopeBytes: number;
138
+ maxPayloadBytes: number;
139
+ };
140
+ /**
141
+ * Pre-flight one sendFile payload: fast-path anything comfortably small, measure
142
+ * the rest, and report the actionable ceiling when it does not fit.
143
+ *
144
+ * The refusal happens before any transaction is emitted, so "nothing was sent"
145
+ * is a real guarantee here — unlike `notRetained`, where the core has already
146
+ * sent by the time it reports the verdict.
147
+ */
148
+ export declare function checkFileEnvelope(i: {
149
+ packet: BinarySource;
150
+ lifetime: AdaptObjectLifetime;
151
+ filename: string;
152
+ mime: string;
153
+ payload: Uint8Array;
154
+ replyTo?: ReplyRef;
155
+ cap?: number;
156
+ }): FileEnvelopeCheck;
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+ import{a,b,c,d,e,f,g}from"../chunk-VXVW4KJU.js";export{a as PINNED_FILE_ENVELOPE_CAP,g as checkFileEnvelope,c as envelopeSkipMargin,f as maxFilePayloadBytes,e as measureFileEnvelope,d as needsEnvelopeMeasurement,b as resolveFileEnvelopeCap};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a,b,c,d}from"../chunk-UN44T5Z5.js";import"../chunk-KBXZ7WK6.js";import"../chunk-6TQNPR4I.js";import"../chunk-YRPUM6JG.js";import"../chunk-JPG44TVX.js";import"../chunk-DIRW7I4S.js";import"../chunk-HVJRHUSY.js";import"../chunk-2HS7JGHP.js";import"../chunk-EHZNOPG6.js";import"../chunk-ZHH3PWEW.js";import"../chunk-LKFYUCN7.js";import"../chunk-P55RJGZU.js";import"../chunk-XYU2DSWR.js";import"../chunk-IB2U7K6Y.js";export{a as findSibling,d as parseSendVerdict,c as sendViaLocalBook,b as sendViaSibling};
2
+ import{a,b,c,d}from"../chunk-LFJI7SYO.js";import"../chunk-MLISCAHB.js";import"../chunk-4UYU3SJ3.js";import"../chunk-YRPUM6JG.js";import"../chunk-VVPDTS5O.js";import"../chunk-DIRW7I4S.js";import"../chunk-OCBN326X.js";import"../chunk-KIIBATGV.js";import"../chunk-WXVWLASM.js";import"../chunk-ZHH3PWEW.js";import"../chunk-LKFYUCN7.js";import"../chunk-P55RJGZU.js";import"../chunk-XYU2DSWR.js";import"../chunk-IB2U7K6Y.js";export{a as findSibling,d as parseSendVerdict,c as sendViaLocalBook,b as sendViaSibling};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{v as a}from"../chunk-6TQNPR4I.js";import"../chunk-YRPUM6JG.js";import"../chunk-JPG44TVX.js";import"../chunk-DIRW7I4S.js";import"../chunk-HVJRHUSY.js";import"../chunk-2HS7JGHP.js";import"../chunk-EHZNOPG6.js";import"../chunk-ZHH3PWEW.js";import"../chunk-LKFYUCN7.js";import"../chunk-P55RJGZU.js";import"../chunk-XYU2DSWR.js";import"../chunk-IB2U7K6Y.js";export{a as wireHandlers};
2
+ import{v as a}from"../chunk-4UYU3SJ3.js";import"../chunk-YRPUM6JG.js";import"../chunk-VVPDTS5O.js";import"../chunk-DIRW7I4S.js";import"../chunk-OCBN326X.js";import"../chunk-KIIBATGV.js";import"../chunk-WXVWLASM.js";import"../chunk-ZHH3PWEW.js";import"../chunk-LKFYUCN7.js";import"../chunk-P55RJGZU.js";import"../chunk-XYU2DSWR.js";import"../chunk-IB2U7K6Y.js";export{a as wireHandlers};
package/dist/mufl/tx.js CHANGED
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{E as a,F as b,G as c,H as d,I as e,J as f}from"../chunk-6TQNPR4I.js";import"../chunk-YRPUM6JG.js";import"../chunk-JPG44TVX.js";import"../chunk-DIRW7I4S.js";import"../chunk-HVJRHUSY.js";import"../chunk-2HS7JGHP.js";import"../chunk-EHZNOPG6.js";import"../chunk-ZHH3PWEW.js";import"../chunk-LKFYUCN7.js";import"../chunk-P55RJGZU.js";import"../chunk-XYU2DSWR.js";import"../chunk-IB2U7K6Y.js";export{e as enqueueMutation,f as mutatingTx,c as readonlyTx,d as withLock,a as withScope,b as withScopeAsync};
2
+ import{E as a,F as b,G as c,H as d,I as e,J as f}from"../chunk-4UYU3SJ3.js";import"../chunk-YRPUM6JG.js";import"../chunk-VVPDTS5O.js";import"../chunk-DIRW7I4S.js";import"../chunk-OCBN326X.js";import"../chunk-KIIBATGV.js";import"../chunk-WXVWLASM.js";import"../chunk-ZHH3PWEW.js";import"../chunk-LKFYUCN7.js";import"../chunk-P55RJGZU.js";import"../chunk-XYU2DSWR.js";import"../chunk-IB2U7K6Y.js";export{e as enqueueMutation,f as mutatingTx,c as readonlyTx,d as withLock,a as withScope,b as withScopeAsync};
package/dist/notify.js CHANGED
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n}from"./chunk-6TQNPR4I.js";import"./chunk-YRPUM6JG.js";import"./chunk-JPG44TVX.js";import"./chunk-DIRW7I4S.js";import"./chunk-HVJRHUSY.js";import"./chunk-2HS7JGHP.js";import"./chunk-EHZNOPG6.js";import"./chunk-ZHH3PWEW.js";import"./chunk-LKFYUCN7.js";import"./chunk-P55RJGZU.js";import"./chunk-XYU2DSWR.js";import"./chunk-IB2U7K6Y.js";export{g as appendNotifyLog,i as binHexField,b as clearNotifyHook,c as fireNotify,e as fireNotifyWaiters,d as notifyHooks,j as notifyLogSize,h as readE2eWireIds,k as readNotifyRange,m as refreshUnread,l as serveNotifications,a as setNotifyHook,n as unreadSummary,f as waitForNotify};
2
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n}from"./chunk-4UYU3SJ3.js";import"./chunk-YRPUM6JG.js";import"./chunk-VVPDTS5O.js";import"./chunk-DIRW7I4S.js";import"./chunk-OCBN326X.js";import"./chunk-KIIBATGV.js";import"./chunk-WXVWLASM.js";import"./chunk-ZHH3PWEW.js";import"./chunk-LKFYUCN7.js";import"./chunk-P55RJGZU.js";import"./chunk-XYU2DSWR.js";import"./chunk-IB2U7K6Y.js";export{g as appendNotifyLog,i as binHexField,b as clearNotifyHook,c as fireNotify,e as fireNotifyWaiters,d as notifyHooks,j as notifyLogSize,h as readE2eWireIds,k as readNotifyRange,m as refreshUnread,l as serveNotifications,a as setNotifyHook,n as unreadSummary,f as waitForNotify};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a,b,c,d,e,f,g,h,i,j,k,l}from"../chunk-JPG44TVX.js";import"../chunk-DIRW7I4S.js";import"../chunk-2HS7JGHP.js";import"../chunk-EHZNOPG6.js";import"../chunk-ZHH3PWEW.js";import"../chunk-P55RJGZU.js";import"../chunk-IB2U7K6Y.js";export{l as adaptValueToJson,k as decodeWireBin,j as encodeWireBin,i as fmtContactRoot,h as renderContactRoots,a as renderContacts,d as renderFileMetadata,e as renderFiles,b as renderImportRenames,c as renderInbox,g as renderPending,f as writeIncomingFiles};
2
+ import{a,b,c,d,e,f,g,h,i,j,k,l}from"../chunk-VVPDTS5O.js";import"../chunk-DIRW7I4S.js";import"../chunk-KIIBATGV.js";import"../chunk-WXVWLASM.js";import"../chunk-ZHH3PWEW.js";import"../chunk-P55RJGZU.js";import"../chunk-IB2U7K6Y.js";export{l as adaptValueToJson,k as decodeWireBin,j as encodeWireBin,i as fmtContactRoot,h as renderContactRoots,a as renderContacts,d as renderFileMetadata,e as renderFiles,b as renderImportRenames,c as renderInbox,g as renderPending,f as writeIncomingFiles};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p}from"../chunk-EHZNOPG6.js";import"../chunk-ZHH3PWEW.js";import"../chunk-IB2U7K6Y.js";export{j as API_TOKEN,g as API_VISIBILITY,o as BOOK_DIR_NAME,d as BROKER_URL,b as CONFIG,f as GC_INTERVAL_MS,n as NAME_RE,e as PORT,c as STATE_DIR,a as VERSION,l as authOk,i as log,m as requireAuth,h as startupProgress,k as tokenFromReq,p as validateName};
2
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p}from"../chunk-WXVWLASM.js";import"../chunk-ZHH3PWEW.js";import"../chunk-IB2U7K6Y.js";export{j as API_TOKEN,g as API_VISIBILITY,o as BOOK_DIR_NAME,d as BROKER_URL,b as CONFIG,f as GC_INTERVAL_MS,n as NAME_RE,e as PORT,c as STATE_DIR,a as VERSION,l as authOk,i as log,m as requireAuth,h as startupProgress,k as tokenFromReq,p as validateName};
package/dist/state.js CHANGED
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{A as a,B as b,C as c,D as d}from"./chunk-6TQNPR4I.js";import"./chunk-YRPUM6JG.js";import"./chunk-JPG44TVX.js";import"./chunk-DIRW7I4S.js";import"./chunk-HVJRHUSY.js";import"./chunk-2HS7JGHP.js";import"./chunk-EHZNOPG6.js";import"./chunk-ZHH3PWEW.js";import"./chunk-LKFYUCN7.js";import"./chunk-P55RJGZU.js";import"./chunk-XYU2DSWR.js";import"./chunk-IB2U7K6Y.js";export{a as ensureRegistrar,b as hasSavedState,c as saveState,d as saveStateFailClosed};
2
+ import{A as a,B as b,C as c,D as d}from"./chunk-4UYU3SJ3.js";import"./chunk-YRPUM6JG.js";import"./chunk-VVPDTS5O.js";import"./chunk-DIRW7I4S.js";import"./chunk-OCBN326X.js";import"./chunk-KIIBATGV.js";import"./chunk-WXVWLASM.js";import"./chunk-ZHH3PWEW.js";import"./chunk-LKFYUCN7.js";import"./chunk-P55RJGZU.js";import"./chunk-XYU2DSWR.js";import"./chunk-IB2U7K6Y.js";export{a as ensureRegistrar,b as hasSavedState,c as saveState,d as saveStateFailClosed};
package/dist/sweeps.js CHANGED
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{o as a,p as b,q as c,r as d,s as e,t as f,u as g}from"./chunk-6TQNPR4I.js";import"./chunk-YRPUM6JG.js";import"./chunk-JPG44TVX.js";import"./chunk-DIRW7I4S.js";import"./chunk-HVJRHUSY.js";import"./chunk-2HS7JGHP.js";import"./chunk-EHZNOPG6.js";import"./chunk-ZHH3PWEW.js";import"./chunk-LKFYUCN7.js";import"./chunk-P55RJGZU.js";import"./chunk-XYU2DSWR.js";import"./chunk-IB2U7K6Y.js";export{e as capabilityReconcileSweep,d as contactRestoreSweep,g as e2eRecoverySweep,c as flushDeferredFor,b as renderDeferredQueues,a as renderDegraded,f as scheduleCapabilityReconcile};
2
+ import{o as a,p as b,q as c,r as d,s as e,t as f,u as g}from"./chunk-4UYU3SJ3.js";import"./chunk-YRPUM6JG.js";import"./chunk-VVPDTS5O.js";import"./chunk-DIRW7I4S.js";import"./chunk-OCBN326X.js";import"./chunk-KIIBATGV.js";import"./chunk-WXVWLASM.js";import"./chunk-ZHH3PWEW.js";import"./chunk-LKFYUCN7.js";import"./chunk-P55RJGZU.js";import"./chunk-XYU2DSWR.js";import"./chunk-IB2U7K6Y.js";export{e as capabilityReconcileSweep,d as contactRestoreSweep,g as e2eRecoverySweep,c as flushDeferredFor,b as renderDeferredQueues,a as renderDegraded,f as scheduleCapabilityReconcile};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ours.network/sdk",
3
- "version": "1.3.1",
3
+ "version": "1.5.0",
4
4
  "types": "./dist/index.d.ts",
5
5
  "type": "module",
6
6
  "license": "FSL-1.1-Apache-2.0",
@@ -41,9 +41,9 @@
41
41
  "build:cli": "npm run build --workspace @ours.network/cli",
42
42
  "typecheck": "tsc -p tsconfig.json --noEmit",
43
43
  "pretest": "npm run build --workspace @ours.network/cli",
44
- "test:cli": "node build.mjs && npm run build --workspace @ours.network/cli && node test/cli-operations.test.mjs && node test/cli-lifecycle.test.mjs && node test/cli-command.test.mjs && node test/cli-help.test.mjs",
44
+ "test:cli": "node build.mjs && npm run build --workspace @ours.network/cli && node test/cli-operations.test.mjs && node test/cli-lifecycle.test.mjs && node test/cli-service-instance.test.mjs && node test/cli-command.test.mjs && node test/cli-help.test.mjs",
45
45
  "//test": "test/ux-strings.test.mjs is DELIBERATELY NOT CHAINED HERE: it is red by design until the split completes (687 of 1205 strings still missing — the test prints that number itself) and would make CI permanently red. The missing strings are MCP tool copy and CLI copy that belongs in ours-mcp; the gate only goes green in PR 2, with OURS_MCP_SPLIT pointing at the refactored ours-mcp. Please do not 'helpfully' add it before then.",
46
- "test": "node build.mjs && bash scripts/test-receipts-mufl.sh && bash scripts/test-notifications-mufl.sh && bash scripts/test-contact-uniqueness-mufl.sh && bash scripts/test-temp-remove-me-mufl.sh && node test/bump-version.test.mjs && node test/cli-publish-workflow.test.mjs && node test/mufl-integrity.test.mjs && node test/verbatim-moves.test.mjs && node test/errors.test.mjs && node test/validate-name.test.mjs && node test/locate-unit.test.mjs && node test/lease-unit.test.mjs && node test/tx-lock.test.mjs && node test/wire-handlers-integrity.test.mjs && node test/moved-blocks-integrity.test.mjs && node test/ux-literals.test.mjs && node test/dist-shared-state.test.mjs && node test/api-error-parity.test.mjs && node test/files-helpers.test.mjs && node test/inbox-encryption.test.mjs && node test/notification-events.test.mjs && node test/process-state.test.mjs && node test/startup-progress.test.mjs && node test/transcribe-detect.test.mjs && node test/transcribe-stt.test.mjs && node test/voice-setup-config.test.mjs && node test/cli-operations.test.mjs && node test/cli-lifecycle.test.mjs && node test/cli-command.test.mjs && node test/cli-help.test.mjs && node test/mig1867-verify.test.mjs && node test/boot-smoke.test.mjs && node test/boot-guards.test.mjs && node test/api-identity.test.mjs && node test/api-contacts.test.mjs && node test/api-messaging.test.mjs && node test/conversations.test.mjs && node test/conversation-restart.test.mjs && node test/api-files.test.mjs && node test/defer-files.test.mjs && node test/daemon-routes.test.mjs && node test/daemon-lifecycle.test.mjs && node test/notify-hook.test.mjs && node test/daemon-events.test.mjs && node test/cross-entry-singleton.test.mjs && node test/client-parity.test.mjs && node test/daemon-selection.test.mjs && node test/api-auth.test.mjs && node test/release-lease.test.mjs && node test/delegation-survives.test.mjs && node test/proxy-annotate-hook.test.mjs && node test/version-advisory.test.mjs && node test/session-restore.test.mjs && node test/loopback-bind.test.mjs && node test/port-visibility.test.mjs && node test/unread-http-api.test.mjs && node test/lease-binding.test.mjs"
46
+ "test": "node build.mjs && bash scripts/test-receipts-mufl.sh && bash scripts/test-notifications-mufl.sh && bash scripts/test-contact-uniqueness-mufl.sh && bash scripts/test-temp-remove-me-mufl.sh && node test/bump-version.test.mjs && node test/cli-publish-workflow.test.mjs && node test/mufl-integrity.test.mjs && node test/verbatim-moves.test.mjs && node test/errors.test.mjs && node test/file-limit.test.mjs && node test/validate-name.test.mjs && node test/locate-unit.test.mjs && node test/lease-unit.test.mjs && node test/tx-lock.test.mjs && node test/wire-handlers-integrity.test.mjs && node test/moved-blocks-integrity.test.mjs && node test/ux-literals.test.mjs && node test/dist-shared-state.test.mjs && node test/api-error-parity.test.mjs && node test/files-helpers.test.mjs && node test/inbox-encryption.test.mjs && node test/notification-events.test.mjs && node test/process-state.test.mjs && node test/startup-progress.test.mjs && node test/transcribe-detect.test.mjs && node test/transcribe-stt.test.mjs && node test/voice-setup-config.test.mjs && node test/cli-operations.test.mjs && node test/cli-lifecycle.test.mjs && node test/cli-service-instance.test.mjs && node test/cli-command.test.mjs && node test/cli-help.test.mjs && node test/mig1867-verify.test.mjs && node test/boot-smoke.test.mjs && node test/boot-guards.test.mjs && node test/api-identity.test.mjs && node test/api-contacts.test.mjs && node test/api-messaging.test.mjs && node test/conversations.test.mjs && node test/conversation-restart.test.mjs && node test/api-files.test.mjs && node test/defer-files.test.mjs && node test/daemon-routes.test.mjs && node test/daemon-lifecycle.test.mjs && node test/notify-hook.test.mjs && node test/daemon-events.test.mjs && node test/cross-entry-singleton.test.mjs && node test/client-parity.test.mjs && node test/daemon-selection.test.mjs && node test/api-auth.test.mjs && node test/release-lease.test.mjs && node test/delegation-survives.test.mjs && node test/proxy-annotate-hook.test.mjs && node test/version-advisory.test.mjs && node test/session-restore.test.mjs && node test/loopback-bind.test.mjs && node test/port-visibility.test.mjs && node test/unread-http-api.test.mjs && node test/lease-binding.test.mjs"
47
47
  },
48
48
  "dependencies": {
49
49
  "@adapt-toolkit/sdk": "0.10.12",
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a as P,b as B,c as C,d as b}from"./chunk-UN44T5Z5.js";import{a as g}from"./chunk-G7RFUBUL.js";import{A as M,B as A,C as E,J as m,a as R}from"./chunk-UM73BGFH.js";import{E as v,F as u,G as F,J as _,g as p,h as $,m as y}from"./chunk-6TQNPR4I.js";import{c as w}from"./chunk-JPG44TVX.js";import{i as c}from"./chunk-EHZNOPG6.js";import{d as k}from"./chunk-LKFYUCN7.js";import{a as I}from"./chunk-P55RJGZU.js";import{readFile as q}from"node:fs/promises";import{basename as N}from"node:path";function O(s,r){if(s)return r!==void 0?{wire_id:s,sentence:r}:{wire_id:s}}async function Q(s,r){let e=g(s),{contact:o,text:n}=r,a=O(r.reply_to_wire_id,r.reply_to_sentence);try{let t=await u(async d=>b(await _(e,"::a2a_messaging::send_message",{contact:o,text:n,...a?{reply_to:a}:{}},d)));switch(t.kind){case"refused":c(`[e2e-route] refused cid=${t.cid} wire_id=${t.wireId} (downgrade_refused)`);break;case"migrating":c(`[migration] queued cid=${t.cid} wire_id=${t.wireId} (migrating, ${t.queued} queued)`);break;case"e2e":c(`[e2e-route] cid=${t.cid} wire_id=${t.wireId} verdict=e2e (core delivered over migrated session)${t.notRetained?" NOT RETAINED (oversized)":""}`),t.notRetained&&p(e,{event:"send_not_retained",wire_id:t.wireId,kind:"message"});break;default:break}return t}catch(t){if(!/Unknown contact/.test(String(t)))throw m("send_message",String(t));try{let d=P(e,o);return{kind:"introduced",text:d?await B(e,d,n):await C(e,o,n)}}catch(d){throw m("send_message",String(d),"FALLBACK_FAILED")}}}async function X(s,r){let e=g(s),{contact:o,path:n,data_base64:a,filename:t,mime:d}=r;if((n?1:0)+(a?1:0)!=1)throw M();let f,l;try{if(n)f=await q(n),l=t??N(n);else{if(!t)throw A();f=Buffer.from(a,"base64"),l=t}}catch(i){throw i instanceof R?i:E(String(i))}let h=d??(n?I(n):""),S=O(r.reply_to_wire_id,r.reply_to_sentence);try{let i=await u(async x=>{let T=e.pw.packet.NewBinaryFromBuffer(f).Attach(x);return b(await _(e,"::a2a_messaging::send_file",{contact:o,filename:l,mime:h,data:T,...S?{reply_to:S}:{}},x))});switch(i.kind){case"refused":c(`[e2e-route] refused cid=${i.cid} wire_id=${i.wireId} (downgrade_refused, file)`);break;case"migrating":c(`[migration] file-defer cid=${i.cid} wire_id=${i.wireId} (migrating, not queued)`);break;case"e2e":c(`[e2e-route] cid=${i.cid} wire_id=${i.wireId} verdict=e2e file (core delivered over migrated session)${i.notRetained?" NOT RETAINED (oversized)":""}`),i.notRetained&&p(e,{event:"send_not_retained",wire_id:i.wireId,kind:"file"});break;default:break}return{...i,filename:l,bytes:f.length,mime:h}}catch(i){throw m("send_file",String(i))}}async function Y(s){let r=g(s);try{return v(e=>w(F(r,"::actor::list_incoming_messages",e)))}catch(e){throw m("list_incoming_messages",String(e))}}async function Z(s){let r=g(s);try{let e=await u(async n=>{let a=await _(r,"::actor::get_messages",{},n);return w(a.Reduce("messages"))});y(r);let o=$(r);return k(e,o)}catch(e){throw m("get_messages",String(e))}}async function ee(s,r){let e=g(s),{msg_ids:o}=r;try{let n=await u(async a=>(await _(e,"::actor::defer_messages",{msg_ids:o},a)).Reduce("deferred").Visualize());return y(e),{deferred:n}}catch(n){throw m("defer_messages",String(n))}}export{Q as a,X as b,Y as c,Z as d,ee as e};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- var t=class extends Error{constructor(n,r){super(r);this.code=n;this.name="OursError"}},i=()=>new t("NOT_BOUND","No identity bound to this session. Call choose_identity (or create_identity) first."),s=()=>new t("BINDING_REASSIGNED","Your identity binding was reassigned to another session. Call choose_identity again to continue."),a=e=>new t("BOUND_IDENTITY_GONE",`The bound identity "${e}" no longer exists. Choose another with choose_identity.`),d=e=>new t("TEMP_CLOSING",`The temporary identity "${e}" is closing and no longer accepts work. Its contacts are being notified and its local state deleted.`),_=(e,o)=>new t("NAME_TAKEN",`${e} failed: an identity named "${o}" already exists.`),c=()=>new t("NO_LEASE_HEADERS","create_temporary_identity failed: this client is not connected through the ours connector (no lease token / client pid headers), so there is no session lease to own the identity. Launch ours via the connector (`ours-mcp proxy`)."),l=()=>new t("RANDOM_NAME_EXHAUSTED","create_temporary_identity failed: could not pick a free random name after 5 attempts \u2014 retry."),E=e=>new t("ROOT_EXISTS",`create_root_identity failed: a root identity already exists ("${e}") \u2014 one root per host. Nothing to do.`),y=()=>new t("NOT_BOUND_NO_NAME","close_temporary_identity failed: no identity is bound to this session and no name was given."),N=e=>new t("NOT_TEMPORARY",`close_temporary_identity failed: "${e}" is a permanent identity. Use remove_identity if you really mean to delete it.`),p=(e,o)=>new t("TEMP_OWNED_ELSEWHERE",`close_temporary_identity failed: "${e}" is owned by another LIVE session (owner pid ${o}) \u2014 one session cannot delete another's temporary identity.`),O=(e,o,n)=>new t("DELETE_PARTIAL",`Temporary identity "${e}" closed with an error: ${o}. ${n}`),h=e=>new t("PATH_NOT_ABSOLUTE",`define_local_identity_file failed: path must be absolute (got "${e}").`),T=e=>new t("NO_SUCH_IDENTITY",`choose_identity failed: no identity named "${e}". Create it with create_identity.`),w=()=>new t("NO_LEASE_TOKEN","choose_identity failed: this client is not connected through the ours connector (no lease token header). Launch ours via the connector (`ours-mcp proxy`)."),u=e=>new t("TEMP_CLOSING",`choose_identity failed: temporary identity "${e}" is closing \u2014 its state is being deleted.`),m=(e,o)=>new t("TEMP_OWNED_ELSEWHERE",`choose_identity failed: "${e}" is a TEMPORARY identity owned by another live session (owner pid ${o}). Ownership is exclusive and cannot be overridden \u2014 not even with force. Create your own with create_temporary_identity.`),A=(e,o)=>new t("TEMP_STALE",`choose_identity failed: temporary identity "${e}" is STALE \u2014 its owning session (pid ${o}) is gone and it is pending automatic cleanup. It cannot be adopted by another session; use close_temporary_identity to reclaim (clean it up) now.`),I=e=>new t("BOUND_ELSEWHERE",`choose_identity declined: "${e}" is currently bound to another live session. Do not retry with force=true on your own \u2014 tell the user it is in use elsewhere and ask whether to forcibly rebind it here; only retry with force=true after they explicitly confirm.`),L=(e,o)=>new t("TEMP_OWNED_ELSEWHERE",`remove_identity failed: "${e}" is a TEMPORARY identity owned by another LIVE session (owner pid ${o}) \u2014 one session cannot delete another's temporary identity.`),g=(e,o,n)=>new t("DELETE_PARTIAL",`Temporary identity "${e}" closed with an error: ${o}.${n}`),D=(e,o)=>new t("ROOT_HAS_ROLES",`remove_identity failed: "${e}" is the root identity and still has ${o.length} role(s): ${o.join(", ")}. Remove the roles first.`),f=(e,o)=>new t("DELETE_PARTIAL",`Identity "${e}" removed from memory, but ${o}`),R=()=>new t("PUBLIC_INVITE_NAMED","generate_invite failed: a public invite cannot pre-assign a contact name \u2014 every redeemer would be registered under it. Omit `name` for a public invite."),S=()=>new t("NO_POLICY_ARGS","set_local_book_policy: pass expose and/or auto_accept."),x=()=>new t("SEND_ARGS","send_file: provide exactly one of `path` or `data_base64`."),b=()=>new t("SEND_ARGS","send_file: `filename` is required with `data_base64`."),$=e=>new t("FILE_UNREADABLE",`send_file: cannot read file: ${e}`),C=(e,o)=>new t("CONNECTOR_TOO_OLD","save_file could not be completed by your ours connector: it reached the daemon directly, which means the connector is too old to stream the bytes and write them as your OS user. Update the ours connector to use save_file, or fall back to get_files and copy the returned path yourself (`cp`)."+(o?"":` (Also note: no file with wire_id ${e} is currently on disk for this identity \u2014 run get_files first.)`)),M=()=>new t("NO_ROOT","No root identity exists on this host \u2014 create one with create_root_identity first."),P=e=>new t("INVALID_SELECTION",`get_files failed: wire_ids must contain 1-${e} items.`),v=()=>new t("MALFORMED_ID","get_files failed: every selected wire_id must be exactly 64 hexadecimal characters."),U=()=>new t("DUPLICATE_ID","get_files failed: wire_ids must not contain duplicates."),B=()=>new t("UNKNOWN_OR_STALE_ID","get_files failed: one or more selected wire_ids is unknown, stale, or no longer unread; no files were retrieved."),F=(e,o,n="TX_FAILED")=>new t(n,`${e} failed: ${o}`);export{t as a,i as b,s as c,a as d,d as e,_ as f,c as g,l as h,E as i,y as j,N as k,p as l,O as m,h as n,T as o,w as p,u as q,m as r,A as s,I as t,L as u,g as v,D as w,f as x,R as y,S as z,x as A,b as B,$ as C,C as D,M as E,P as F,v as G,U as H,B as I,F as J};