@ours.network/sdk 1.2.1 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -0
- package/dist/api/contacts.js +1 -1
- package/dist/api/conversations.js +1 -1
- package/dist/api/files.js +1 -1
- package/dist/api/identity.js +1 -1
- package/dist/api/messaging.js +1 -1
- package/dist/api/profile.js +1 -1
- package/dist/book.js +1 -1
- package/dist/boot.js +1 -1
- package/dist/{chunk-BE77DLV3.js → chunk-2G3YBZBM.js} +1 -1
- package/dist/{chunk-FXHIUVFI.js → chunk-2HS7JGHP.js} +1 -1
- package/dist/{chunk-BWALN5H4.js → chunk-3RMDFCEE.js} +1 -1
- package/dist/{chunk-LQKA5E4H.js → chunk-3S6XRE6Q.js} +1 -1
- package/dist/{chunk-7EDGK5KR.js → chunk-6D4VEJ7G.js} +1 -1
- package/dist/chunk-6TQNPR4I.js +5 -0
- package/dist/{chunk-IAPTCIGI.js → chunk-75SBIMZV.js} +1 -1
- package/dist/chunk-7MXGWXS4.js +2 -0
- package/dist/{chunk-47KSJAVX.js → chunk-EHZNOPG6.js} +1 -1
- package/dist/{chunk-ASEVOBRO.js → chunk-G7RFUBUL.js} +1 -1
- package/dist/{chunk-XYPZUKWU.js → chunk-HVJRHUSY.js} +1 -1
- package/dist/{chunk-T3VDJXH3.js → chunk-JPG44TVX.js} +1 -1
- package/dist/{chunk-3Y4OEP7H.js → chunk-KBXZ7WK6.js} +1 -1
- package/dist/{chunk-7JSO763H.js → chunk-KM47NXDZ.js} +1 -1
- package/dist/chunk-NBEWKZG4.js +2 -0
- package/dist/{chunk-MORSFKSX.js → chunk-QKNFHB65.js} +1 -1
- package/dist/{chunk-LLBTV276.js → chunk-QZA7SEVN.js} +1 -1
- package/dist/{chunk-2WUWEJEU.js → chunk-UN44T5Z5.js} +1 -1
- package/dist/{chunk-74775UI4.js → chunk-UXUO7HJ6.js} +1 -1
- package/dist/chunk-XTYFZQI6.js +2 -0
- package/dist/{chunk-W3HW7ZSG.js → chunk-XYSQZW3X.js} +1 -1
- package/dist/chunk-XYU2DSWR.js +2 -0
- package/dist/{chunk-NFZS32HS.js → chunk-ZAI7AWG2.js} +1 -1
- package/dist/client/http.d.ts +2 -1
- package/dist/client/http.js +1 -1
- package/dist/client.d.ts +1 -0
- package/dist/client.js +1 -1
- package/dist/cluster/control.js +1 -1
- package/dist/cluster/manifest.js +1 -1
- package/dist/connector.js +1 -1
- package/dist/daemon.js +1 -1
- package/dist/events.d.ts +41 -1
- package/dist/events.js +1 -1
- package/dist/gc.js +1 -1
- package/dist/http/api-routes.js +1 -1
- package/dist/http/server.d.ts +6 -0
- package/dist/http/server.js +1 -1
- package/dist/identity/hierarchy.js +1 -1
- package/dist/identity/lease.js +1 -1
- package/dist/identity/lifecycle.js +1 -1
- package/dist/identity/model.js +1 -1
- package/dist/identity/provision.js +1 -1
- package/dist/index.js +1 -1
- package/dist/messaging/send.js +1 -1
- package/dist/mufl/handlers.js +1 -1
- package/dist/mufl/tx.js +1 -1
- package/dist/mufl_code/{BA0A735540100231BFCF10693CE306421C026F86BD42A14CE7CBBDD7645F9899.muflo → 7962BB01B1D3E782A1F80B083A900AEC30BAC8F8CE79282B31821802B94A39B6.muflo} +0 -0
- package/dist/notify.js +1 -1
- package/dist/render/adapt-to-json.js +1 -1
- package/dist/runtime/env.js +1 -1
- package/dist/runtime/sdk-signal-ownership.d.ts +9 -0
- package/dist/runtime/sdk-signal-ownership.js +2 -0
- package/dist/state.js +1 -1
- package/dist/sweeps.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-A27DA5GZ.js +0 -5
- package/dist/chunk-HH4NDU7C.js +0 -2
- package/dist/chunk-UJGRFV4J.js +0 -2
- package/dist/chunk-XA7LBPKN.js +0 -2
package/dist/client/http.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type * as identityApi from '../api/identity.js';
|
|
|
5
5
|
import type * as messagingApi from '../api/messaging.js';
|
|
6
6
|
import type * as profileApi from '../api/profile.js';
|
|
7
7
|
import type { SessionContext } from '../api/types.js';
|
|
8
|
+
import { type NotificationEvent } from '../events.js';
|
|
8
9
|
/** The argument object of an `OursApi` operation, with `ctx` dropped. */
|
|
9
10
|
type Arg<F> = F extends (ctx: SessionContext, a: infer A) => unknown ? A : never;
|
|
10
11
|
/** The argument object of the one operation that takes no `ctx`. */
|
|
@@ -173,7 +174,7 @@ export declare class OursClient {
|
|
|
173
174
|
watchNotifications(identity: string, opts?: {
|
|
174
175
|
since?: number | 'tip';
|
|
175
176
|
signal?: AbortSignal;
|
|
176
|
-
}): AsyncGenerator<
|
|
177
|
+
}): AsyncGenerator<NotificationEvent, void, undefined>;
|
|
177
178
|
/**
|
|
178
179
|
* `GET /files/<wireId>` — the raw bytes of a received file, resolved STRICTLY
|
|
179
180
|
* within THIS session's bound identity's own folder (the identity comes from
|
package/dist/client/http.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a}from"../chunk-
|
|
2
|
+
import{a}from"../chunk-XTYFZQI6.js";import"../chunk-UM73BGFH.js";import"../chunk-XYU2DSWR.js";export{a as OursClient};
|
package/dist/client.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export * from './errors.js';
|
|
2
2
|
export * from './client/http.js';
|
|
3
3
|
export * from './client/select.js';
|
|
4
|
+
export type { MessageReceivedRecord, MessengerNotificationEvent, NotificationEvent, ReceiptKind, ReceiptReceivedRecord, SyncRequiredRecord, UnknownNotificationEvent, } from './events.js';
|
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
|
|
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};
|
package/dist/cluster/control.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}from"../chunk-
|
|
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};
|
package/dist/cluster/manifest.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}from"../chunk-
|
|
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};
|
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.
|
|
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(" ")}
|
|
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-
|
|
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};
|
package/dist/events.d.ts
CHANGED
|
@@ -8,12 +8,52 @@ export interface DaemonEvent {
|
|
|
8
8
|
record: Record<string, unknown>;
|
|
9
9
|
}
|
|
10
10
|
/** `on_message_received` (actor.mu:347) — emitted at +19/+31, saved at +20/+32. */
|
|
11
|
-
export interface MessageReceivedRecord {
|
|
11
|
+
export interface MessageReceivedRecord extends Record<string, unknown> {
|
|
12
12
|
event: 'message_received';
|
|
13
|
+
/** Authenticated container id from the receive callback. */
|
|
14
|
+
sender_id: string;
|
|
15
|
+
/** Display-only label. Never use this field to infer `sender_id`. */
|
|
16
|
+
sender_name: string;
|
|
17
|
+
/** @deprecated Compatibility alias for `sender_name`. */
|
|
13
18
|
from: string;
|
|
14
19
|
msg_id: string;
|
|
20
|
+
/** Stable cross-peer correlation id. */
|
|
21
|
+
wire_id: string;
|
|
22
|
+
date: string;
|
|
23
|
+
}
|
|
24
|
+
export type ReceiptKind = 'delivered' | 'read';
|
|
25
|
+
/** An authenticated peer confirmed one or more outbound wire ids. */
|
|
26
|
+
export interface ReceiptReceivedRecord extends Record<string, unknown> {
|
|
27
|
+
event: 'receipt_received';
|
|
28
|
+
sender_id: string;
|
|
29
|
+
kind: ReceiptKind;
|
|
30
|
+
wire_ids: string[];
|
|
31
|
+
/** Protocol time when supplied by core; otherwise host observation time. */
|
|
15
32
|
date: string;
|
|
16
33
|
}
|
|
34
|
+
/** A known event could not be correlated safely; consumers must refresh state. */
|
|
35
|
+
export interface SyncRequiredRecord extends Record<string, unknown> {
|
|
36
|
+
event: 'sync_required';
|
|
37
|
+
reason: 'legacy_or_malformed_event';
|
|
38
|
+
source_event: 'message_received' | 'receipt_received' | 'unknown';
|
|
39
|
+
}
|
|
40
|
+
/** The closed, discriminated messenger invalidation contract. */
|
|
41
|
+
export type MessengerNotificationEvent = MessageReceivedRecord | ReceiptReceivedRecord | SyncRequiredRecord;
|
|
42
|
+
/** Opaque forward-compatible record from a newer daemon/actor. */
|
|
43
|
+
export type UnknownNotificationEvent = Record<string, unknown> & {
|
|
44
|
+
event: string;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Events delivered by `watchNotifications`. The open member is intentional:
|
|
48
|
+
* a newer daemon may add an event without making an older watcher terminate.
|
|
49
|
+
*/
|
|
50
|
+
export type NotificationEvent = MessengerNotificationEvent | UnknownNotificationEvent;
|
|
51
|
+
/**
|
|
52
|
+
* Validate identity-bearing notification records at the SDK boundary.
|
|
53
|
+
* Display names are never promoted to authenticated ids. Unknown future event
|
|
54
|
+
* names remain opaque records so a watcher can continue across version skew.
|
|
55
|
+
*/
|
|
56
|
+
export declare function normalizeNotificationEvent(record: Record<string, unknown>): NotificationEvent;
|
|
17
57
|
/** `on_message_received`'s pre-introduction arm (actor.mu:347, emit +19). */
|
|
18
58
|
export interface PendingMessageRecord {
|
|
19
59
|
event: 'pending_message';
|
package/dist/events.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}from"./chunk-
|
|
2
|
+
import{a,b,c,d,e,f,g}from"./chunk-XYU2DSWR.js";export{b as VETOABLE_EVENTS,f as emitDaemonEvent,g as emitDaemonNotification,e as isDefaultHandler,a as normalizeNotificationEvent,d as resetDaemonEventHandlers,c as setDaemonEventHandler};
|
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-
|
|
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};
|
package/dist/http/api-routes.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}from"../chunk-
|
|
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};
|
package/dist/http/server.d.ts
CHANGED
|
@@ -106,6 +106,12 @@ export interface DaemonOptions {
|
|
|
106
106
|
* announces the SDK's version, which is not the number a user installed.
|
|
107
107
|
*/
|
|
108
108
|
version?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Whether the daemon owns process SIGINT/SIGTERM handling. Defaults to true
|
|
111
|
+
* for standalone compatibility. Embedded hosts should pass false and own
|
|
112
|
+
* both signal policy and process termination themselves.
|
|
113
|
+
*/
|
|
114
|
+
handleSignals?: boolean;
|
|
109
115
|
/**
|
|
110
116
|
* Notification sink. Wired into src/notify.ts's `setNotifyHook`; the third
|
|
111
117
|
* argument is `leases.get(identityName)?.sid ?? null`, RESOLVED WHEN THE
|
package/dist/http/server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a}from"../chunk-
|
|
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};
|
|
@@ -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-
|
|
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};
|
package/dist/identity/lease.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}from"../chunk-
|
|
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};
|
|
@@ -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-
|
|
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};
|
package/dist/identity/model.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,o,p,q,r,s,t,u,v,w}from"../chunk-
|
|
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};
|
|
@@ -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-
|
|
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};
|
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
|
|
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};
|
package/dist/messaging/send.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}from"../chunk-
|
|
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};
|
package/dist/mufl/handlers.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{v as a}from"../chunk-
|
|
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};
|
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-
|
|
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};
|
|
Binary file
|
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-
|
|
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};
|
|
@@ -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-
|
|
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};
|
package/dist/runtime/env.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,o,p}from"../chunk-
|
|
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};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface SdkSignalOwnershipAudit {
|
|
2
|
+
sdkVersion: string;
|
|
3
|
+
outcome: 'neutralized' | 'ambiguous';
|
|
4
|
+
exitListenerCount: number;
|
|
5
|
+
exitListenerReferencesPreserved: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function neutralizePinnedSdkSignalHandlers(): void;
|
|
8
|
+
/** Test/diagnostic view: contains counts and identity checks, never listeners. */
|
|
9
|
+
export declare function sdkSignalOwnershipAudit(): SdkSignalOwnershipAudit | null;
|
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-
|
|
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};
|
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-
|
|
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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ours.network/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"types": "./dist/index.d.ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "FSL-1.1-Apache-2.0",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"pretest": "npm run build --workspace @ours.network/cli",
|
|
44
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",
|
|
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/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/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/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"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@adapt-toolkit/sdk": "0.10.12",
|
package/dist/chunk-A27DA5GZ.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{c as pe}from"./chunk-T3VDJXH3.js";import{b as M}from"./chunk-YRPUM6JG.js";import{d as ce}from"./chunk-XYPZUKWU.js";import{a as j,c as N,d as b,e as W,f as ne,g as oe,h as J,i as O,j as k,k as L,l as B,p as se,w as ae}from"./chunk-FXHIUVFI.js";import{c as T,i as l,o as F,p as re}from"./chunk-47KSJAVX.js";import{a as de}from"./chunk-LKFYUCN7.js";import{b as ue,e as le,f as fe}from"./chunk-UJGRFV4J.js";import{join as be}from"node:path";import*as _ from"node:fs";import{AdaptObjectLifetime as Re}from"@adapt-toolkit/sdk/common";import{object_to_adapt_value as $e}from"@adapt-toolkit/sdk/wrapper";import*as m from"node:fs";import{randomBytes as Ve}from"node:crypto";import*as $ from"node:fs";import{randomBytes as Ie}from"node:crypto";import{PacketWrapperConfigurator as Te}from"@adapt-toolkit/sdk/wrappers";import{AdaptObjectLifetime as Ne}from"@adapt-toolkit/sdk/common";function He(e){let t=[],s=e.Reduce("degraded");if(s.IsNil())return t;for(let r=0;;r++){let a=s.Reduce(r);if(a.IsNil())break;t.push({cid:a.Reduce("container_id").Visualize(),name:a.Reduce("name").Visualize(),attempts:Number(a.Reduce("attempts").Visualize()),queued:Number(a.Reduce("queued").Visualize())})}return t}function ke(e){let t=[],s=e.Reduce("queues");if(s.IsNil())return t;for(let r=0;;r++){let a=s.Reduce(r);if(a.IsNil())break;t.push({cid:a.Reduce("container_id").Visualize(),queued:Number(a.Reduce("queued").Visualize()),degraded:a.Reduce("degraded").GetBoolean()})}return t}async function K(e,t){try{let s=await w(async r=>{let a=await h(e,"::a2a_messaging::flush_deferred",{contact:t},r);return Number(a.Reduce("flushed").Visualize())});s>0&&l(`[${e.name}] flushed ${s} deferred message(s) to ${t.slice(0,12)}\u2026`)}catch(s){l(`[${e.name}] deferred flush to ${t.slice(0,12)}\u2026 failed:`,String(s))}}async function me(e){try{let t=await w(async r=>{let a=await h(e,"::a2a_messaging::restore_degraded_contacts",{},r);return Number(a.Reduce("requested").Visualize())});t>0&&l(`[${e.name}] contact restore requested for ${t} degraded contact(s)`);let s=S(r=>ke(R(e,"::a2a_messaging::list_deferred_queues",r)));for(let r of s)r.degraded||await K(e,r.cid)}catch(t){l(`[${e.name}] contact-restore sweep failed:`,String(t))}}async function xe(e){try{let t=await w(async s=>{let r=await h(e,"::a2a_messaging::reconcile_advertise",{},s),a=c=>r.Reduce(c).IsNil()?0:Number(r.Reduce(c).Visualize());return{changed:/true/i.test(r.Reduce("changed").Visualize()),capabilityAdvertised:a("capability_advertised"),legacyReadvertised:a("legacy_readvertised")}});(t.capabilityAdvertised>0||t.legacyReadvertised>0)&&l(`[${e.name}] capability reconcile: changed=${t.changed} advertised=${t.capabilityAdvertised} legacy_migration_bootstrap=${t.legacyReadvertised}`)}catch(t){l(`[${e.name}] capability reconcile sweep failed:`,String(t))}}var G=new Set;function H(e){if(!G.has(e.name)){G.add(e.name);for(let t of[2e3,15e3])setTimeout(()=>{t===15e3&&G.delete(e.name);let s=N.get(e.name);s&&xe(s)},t)}}async function qe(e){try{let t=await w(async s=>{let r=await h(e,"::a2a_messaging::readvertise_e2e_recovery",{},s);return Number(r.Reduce("readvertised").Visualize())});t>0&&l(`[${e.name}] re-advertised fresh AD to ${t} e2e contact(s) (session recovery)`)}catch(t){l(`[${e.name}] e2e recovery re-advertise failed:`,String(t))}try{await w(async t=>{await h(e,"::a2a_messaging::sweep_e2e_migrations",{},t)})}catch(t){l(`[${e.name}] e2e migration sweep failed:`,String(t))}try{let t=await w(async s=>{let r=await h(e,"::a2a_messaging::redrive_unacked_sweep",{},s),a=c=>r.Reduce(c).IsNil()?0:Number(r.Reduce(c).Visualize());return{redriven:a("redriven_contacts"),purged:a("purged_contacts"),deferred:a("deferred_contacts")}});(t.redriven>0||t.purged>0||t.deferred>0)&&l(`[${e.name}] unacked sweep: redriven=${t.redriven} ttl_purged=${t.purged} deferred=${t.deferred} contact(s)`)}catch(t){l(`[${e.name}] unacked redrive sweep failed:`,String(t))}}function ge(e,t){e.pw.on_return_data=s=>{let r=new Ne;s.Attach(r);try{let a=s.Reduce("kind").Visualize();if(a==="save_state"){z(e);return}if(a==="notify_agent"){let i=s.Reduce("payload"),f=i.Reduce("event").Visualize();if(f==="message_received"){let o=i.Reduce("sender_name").Visualize(),n=i.Reduce("msg_id").Visualize(),d=i.Reduce("date").Visualize();g(e,{event:"message_received",from:o,msg_id:n,date:d}),P(e),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] new message from ${o} (#${n})`))}else if(f==="file_received"){let o=i.Reduce("sender_name").Visualize(),n=i.Reduce("sender_id").Visualize(),d=i.Reduce("file_id").Visualize(),u=i.Reduce("wire_id").Visualize(),p=i.Reduce("filename").Visualize(),y=i.Reduce("mime").Visualize(),v=i.Reduce("bytes").Visualize(),I=i.Reduce("date").Visualize();g(e,{event:"file_received",from:o,sender_id:n,file_id:d,wire_id:u,filename:p,mime:y,bytes:v,date:I}),P(e),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] new file ${p} (${v} B) from ${o} (sender_id ${n}, file_id ${d}, wire_id ${u})`))}else if(f==="contact_accepted"){let o=i.Reduce("name").Visualize(),n=i.Reduce("container_id").Visualize();H(e),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] contact "${o}" (${n}) accepted your invite.`))}else if(f==="local_contact_added"){let o=i.Reduce("name").Visualize(),n=i.Reduce("container_id").Visualize();H(e),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] local contact "${o}" (${n}) connected via the contact book.`))}else if(f==="contact_name_collision"){let o=i.Reduce("message").Visualize(),n=i.Reduce("desired").Visualize(),d=i.Reduce("assigned").Visualize(),u=i.Reduce("existing_container_id").Visualize(),p=i.Reduce("container_id").Visualize();g(e,{event:"contact_name_collision",desired:n,assigned:d,existing_container_id:u,container_id:p}),l(`[${e.name}] CONTACT NAME COLLISION \u2014 ${o}`),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] \u26A0 ${o}`))}else if(f==="sibling_contact_added"){let o=i.Reduce("name").Visualize(),n=i.Reduce("container_id").Visualize();g(e,{event:"sibling_contact_added",from:o}),H(e),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] sibling "${o}" (${n}) connected (intra-root auto-accept).`))}else if(f==="local_contact_request"){let o=i.Reduce("name").Visualize(),n=i.Reduce("container_id").Visualize();g(e,{event:"local_contact_request",from:o}),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] pending local introduction from "${o}" (${n}) \u2014 approve or reject with respond_to_introduction.`))}else if(f==="pending_message"){let o=i.Reduce("sender_name").Visualize(),n=i.Reduce("queued").Visualize();g(e,{event:"pending_message",from:o,queued:n}),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] "${o}" queued a message awaiting introduction approval (${n} queued).`))}else if(f==="e2e_restore_rejected")g(e,{event:"e2e_restore_rejected"}),l(`[${e.name}] E2E RESTORE REJECTED \u2014 corrupt session blob failed pickle_key validation; reset to empty e2e state, self-heal fallback will re-establish`),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] persisted e2e sessions were corrupt \u2014 rejected cleanly, sessions re-establishing`));else if(f==="contact_restored"){let o=i.Reduce("name").Visualize(),n=i.Reduce("container_id").Visualize();g(e,{event:"contact_restored",from:o}),l(`[${e.name}] contact "${o}" restored (re-keyed)`),process.nextTick(()=>void K(e,String(n)))}else if(f==="migration_active"){let o=i.Reduce("cid").Visualize(),n=i.Reduce("role").Visualize(),d=V(i,"epoch"),u=V(i,"session_id");g(e,{event:"migration_active",cid:String(o),role:String(n),...d?{epoch:d}:{},...u?{session_id:u}:{}}),l(`[migration] active cid=${o} role=${n}${d?` epoch=${d}`:""}${u?` session_id=${u}`:""}`)}else if(f==="e2e_app_send"){let o=i.Reduce("cid").Visualize(),n=V(i,"session_id"),d=i.Reduce("olm_type").Visualize(),u=i.Reduce("wire_id").Visualize(),p=i.Reduce("retained").IsNil()?void 0:i.Reduce("retained").GetBoolean(),y=[],v=i.Reduce("evicted");if(!v.IsNil())for(let I=0;;I++){let ie=v.Reduce(I);if(ie.IsNil())break;y.push(String(ie.Visualize()))}g(e,{event:"e2e_app_send",cid:String(o),session_id:n,olm_type:String(d),wire_id:String(u),...p===!1?{retained:!1}:{},...y.length?{evicted:y}:{}}),l(`[${e.name}] [e2e-app] send cid=${o} session_id=${n} olm_type=${d} wire_id=${u}${p===!1?" retained=false":""}${y.length?` evicted=${y.join(",")}`:""}`),y.length&&process.nextTick(()=>t.onNotify(e.name,`[${e.name}] redrive window overflow: ${y.length} older unacked send(s) lost their auto-resend guarantee (${y.join(", ")})`))}else if(f==="dedup_degraded"){let o=i.Reduce("cid").Visualize(),n=i.Reduce("dropped_wire_id").Visualize();g(e,{event:"dedup_degraded",cid:String(o),dropped_wire_id:String(n)}),l(`[${e.name}] [e2e-app] DEDUP DEGRADED cid=${o} dropped_wire_id=${n} (storage ceiling \u2014 a late redrive of that id could re-deposit)`),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] dedup window overflowed for ${String(o).slice(0,12)}\u2026 \u2014 one oldest entry dropped (guarantee loss surfaced)`))}else if(f==="e2e_delivery_expired"){let o=i.Reduce("cid").Visualize(),n=[],d=i.Reduce("wire_ids");if(!d.IsNil())for(let u=0;;u++){let p=d.Reduce(u);if(p.IsNil())break;n.push(String(p.Visualize()))}g(e,{event:"e2e_delivery_expired",cid:String(o),wire_ids:n}),l(`[${e.name}] [e2e-app] delivery EXPIRED (2-day TTL, receipt never arrived) cid=${o} wire_ids=${n.join(",")}`),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] ${n.length} message(s)/file(s) to ${String(o).slice(0,12)}\u2026 expired undelivered (no receipt within 2 days)`))}else if(f==="e2e_app_recv"){let o=i.Reduce("cid").Visualize(),n=V(i,"session_id"),d=i.Reduce("ok").GetBoolean(),u=i.Reduce("wire_id").Visualize(),p=i.Reduce("code").IsNil()?void 0:String(i.Reduce("code").Visualize()),y=!i.Reduce("duplicate").IsNil(),v=!i.Reduce("file").IsNil();g(e,{event:"e2e_app_recv",cid:String(o),session_id:n,ok:d,wire_id:String(u),...p?{code:p}:{},...y?{duplicate:!0}:{},...v?{file:!0}:{}}),l(`[${e.name}] [e2e-app] recv cid=${o} session_id=${n} ok=${d} wire_id=${u}${p?` code=${p}`:""}${y?" duplicate=true":""}${v?" file=true":""}`)}else if(f==="e2e_rekey"){let o=i.Reduce("cid").Visualize(),n=i.Reduce("role").Visualize(),d=V(i,"session_id"),u=i.Reduce("attempts").IsNil()?void 0:String(i.Reduce("attempts").Visualize()),p=i.Reduce("peer_supports").IsNil()?void 0:String(i.Reduce("peer_supports").Visualize()),y=i.Reduce("rejected").IsNil()?void 0:String(i.Reduce("rejected").Visualize());g(e,{event:"e2e_rekey",cid:String(o),role:String(n),...d?{session_id:d}:{},...u?{attempts:u}:{},...p?{peer_supports:p}:{},...y?{rejected:y}:{}}),l(`[${e.name}] [e2e-rekey] cid=${o} role=${n}${d?` session_id=${d}`:""}${u?` attempts=${u}`:""}${p?` peer_supports=${p}`:""}${y?` rejected=${y}`:""}`)}else if(f==="migration_deferred_flush"){let o=i.Reduce("cid").Visualize(),n=i.Reduce("wire_id").Visualize();g(e,{event:"migration_deferred_flush",cid:String(o),wire_id:String(n)}),l(`[migration] flush-notify cid=${o} wire_id=${n} (deferred\u2192e2e; core delivers)`)}else if(f==="migration_stalled"){let o=i.Reduce("cid").Visualize(),n=i.Reduce("phase").Visualize(),d=i.Reduce("attempts").Visualize();g(e,{event:"migration_stalled",cid:String(o),phase:String(n),attempts:String(d)}),l(`[migration] stalled-notify cid=${o} phase=${n} attempts=${d} (core re-drives via sweep)`)}else if(f==="downgrade_refused"){let o=i.Reduce("cid").Visualize(),n=i.Reduce("wire_id"),d=n.IsNil()?"":String(n.Visualize());g(e,{event:"downgrade_refused",cid:String(o),...d?{wire_id:d}:{}}),l(`[e2e-route] downgrade-dropped cid=${o}${d?` wire_id=${d}`:""} (legacy plaintext from a migrated peer \u2014 dropped by core)`),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] a message from a migrated contact was rejected as an unsafe downgrade (dropped).`))}else if(f==="contact_removed"){let o=String(i.Reduce("cid").Visualize()),n=ce.has(e.name);g(e,{event:"contact_removed",cid:o,by:n?"local":"peer"}),n||(l(`[${e.name}] contact ${o} removed you (authenticated peer removal notice) \u2014 dropped from contacts`),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] contact ${o.slice(0,12)}\u2026 removed you as a contact (the removal was applied locally too).`)))}else if(f==="monitoring_disabled"){let o=String(i.Reduce("cid").Visualize()),n=i.Reduce("cause"),d=n.IsNil()?"":String(n.Visualize());g(e,{event:"monitoring_disabled",cid:o,...d?{cause:d}:{}}),l(`[${e.name}] monitoring disabled (cid=${o}${d?` cause=${d}`:""})`),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] the monitoring/control-plane binding was disabled${d==="control_plane_removed_contact"?" \u2014 the control plane removed you as a contact":""}.`))}else(f==="control_request"||f==="host_provision_child"||f==="host_destroy_child"||f==="host_mint_child_invite"||f==="host_set_child_monitoring")&&l(`[${e.name}] ${f}: the daemon-side control plane is removed \u2014 ignoring`);return}let c=e.pending.shift();if(!c)return;clearTimeout(c.timer),c.resolve(s.Reduce("payload").Detach())}finally{r.Finalize()}},e.pw.on_transaction_failure=s=>{let r=e.pending.shift();r?(clearTimeout(r.timer),r.reject(new Error(s))):(l(`[${e.name}] inbound transaction rejected:`,s),g(e,{event:"inbound_error",message:s}),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] inbound transaction rejected: ${s}`)))}}import{join as X}from"node:path";import*as x from"node:fs";var E=()=>X(T,F),Q=()=>X(E(),"registrar.key"),Y=()=>X(E(),"book.json");function ye(){try{let e=JSON.parse(x.readFileSync(Y(),"utf8"));return e&&typeof e.entries=="object"?e.entries:{}}catch{return{}}}function _e(e){x.mkdirSync(E(),{recursive:!0});let t=`${Y()}.tmp`;x.writeFileSync(t,JSON.stringify({v:1,entries:e},null,2),{mode:384}),x.renameSync(t,Y())}function Z(e){return S(t=>Buffer.from(R(e,"::actor::export_address_document",t).GetBinary()))}function q(e){return S(t=>Buffer.from(R(e,"::actor::export_signing_secret",t).Serialize()).toString("hex"))}async function we(e){if(!b)throw new Error("registrar is not available");let t=Z(e),s=await w(async a=>{let c=await h(b,"::actor::sign_book_entry",{name:e.name,ad:b.pw.packet.NewBinaryFromBuffer(t).Attach(a)},a);return Buffer.from(c.Reduce("sig").GetBinary()).toString("base64url")}),r=ye();r[e.name]={v:1,name:e.name,container_id:e.cid,address_document:t.toString("base64url"),published_at:new Date().toISOString(),registrar_sig:s},_e(r),l(`[${e.name}] published to the local contact book`)}function it(e){let t=ye(),s=Object.entries(t).find(([,r])=>r.container_id===e.cid);s&&(delete t[s[0]],_e(t),l(`[${e.name}] removed from the local contact book (entry "${s[0]}")`))}async function he(e){if(!W)throw new Error("registrar is not available");await w(async t=>{await h(e,"::actor::pin_registrar",{registrar_ad:e.pw.packet.NewBinaryFromBuffer(W).Attach(t)},t)})}function C(e,t,s,r=!0,a,c=!1){let i=new Te;i.deferred_exposure=c;let f=["--unit_hash",M.hash,"--seed_phrase",t,"--unit_dir_path",M.dir];return a&&f.push("--init_trn_argument",JSON.stringify(a)),i.process_arguments(f),new Promise((o,n)=>{let d=setTimeout(()=>n(new Error(`packet creation for "${e}" timed out`)),3e4);j.packet_manager.create_packet(i,u=>{clearTimeout(d);let p={name:e,cid:S(y=>u.packet.GetContainerID().Attach(y).Visualize()),pw:u,dir:s,pending:[],lock:Promise.resolve()};ge(p,ve),r&&N.set(e,p),l(`[${e}] packet created \u2014 container id ${p.cid}`),o(p)},M.contents)})}var A=new Set(ae());A.size>0&&l(`reserved ${A.size} persisted identity name(s) at module load: ${[...A].join(", ")}`);async function gt(e,t={exposeLocal:!0,localAutoAccept:!0}){if(A.has(e)||N.has(e))throw new Error(`identity name "${e}" is reserved \u2014 a persisted identity with this name is restoring, present, or being provisioned; refusing to provision over it`);A.add(e);try{let s=J(e);$.mkdirSync(s,{recursive:!0,mode:448});let r;t.temp&&(r={owner:{tokenHash:t.temp.tokenHash,pid:t.temp.pid},createdAt:Date.now()},se(s,r));let a=Ie(24).toString("hex"),c=await C(e,a,s);return r&&(c.temp=r),$.writeFileSync(O(s),q(c),{mode:384}),await w(async i=>{await h(c,"::a2a_messaging::set_my_name",{name:e},i)}),await he(c),t.localAutoAccept||await w(async i=>{await h(c,"::actor::set_local_policy",{auto_accept:!1},i)}),t.exposeLocal&&await we(c),z(c),c}catch(s){throw A.delete(e),s}}async function yt(e){let t=J(e),s=$.readFileSync(O(t),"utf8").trim(),r=await C(e,"",t,!1,s,!0);l(`[${e}] created QUARANTINED (no routing/broker registration, not client-bindable) \u2014 importing state before exposure`);let a=Number(process.env.OURS_TEST_RESTORE_HOLD_MS||"")||0;a>0&&(l(`[${e}] TEST HOLD: keeping restore open ${a}ms (OURS_TEST_RESTORE_HOLD_MS)`),await new Promise(o=>setTimeout(o,a)));let c=o=>/timed out waiting for the transaction result/.test(String(o)),i=(o,n,d)=>{l(`[${e}] ${o} ${n} \u2014 identity left UNEXPOSED and UNTRACKED (fail-closed)`);try{g(r,{event:"restore_fail_closed",step:o,error:String(d).slice(0,300)})}catch{}N.delete(e);try{j.remove_packet(r.cid)}catch(u){l(`[${e}] quarantined-packet teardown failed:`,String(u))}throw new Error(`identity "${e}": ${o} failed during restore (${n}) \u2014 left unexposed (fail-closed)`)},f=(o,n)=>i(o,"outcome UNKNOWN (timeout): the transaction may still execute and exposure would race it",n);if(Se(t)){let o=!1;try{if(process.env.OURS_TEST_FORCE_IMPORT_TIMEOUT==="1")throw new Error("timed out waiting for the transaction result (forced by OURS_TEST_FORCE_IMPORT_TIMEOUT)");let n=$.readFileSync(k(t));await w(async d=>{let u=r.pw.packet.ParseValue(new Uint8Array(n)).Attach(d),p=Number(process.env.OURS_IMPORT_TIMEOUT_MS||"")||void 0;await h(r,"::actor::import_state",u,d,p)}),o=!0,l(`[${e}] state import completed (positively observed)`)}catch(n){c(n)&&f("import_state",n),l(`[${e}] FAILED TO IMPORT SAVED STATE \u2014 continuing with the reseeded identity; surviving contacts (if the blob was partially migrated) self-heal via contact restore:`,String(n)),g(r,{event:"state_import_failed",error:String(n).slice(0,300)});try{let d=`${k(t)}.failed-${Date.now()}`;$.renameSync(k(t),d),$.chmodSync(d,384),l(`[${e}] unreadable state blob preserved as state_data.bin.failed-*`)}catch{}}if(o){try{let u=await w(async p=>{let y=await h(r,"::a2a_messaging::commit_e2e_restore",{},p),v=y.Reduce("status").Visualize(),I=y.Reduce("sessions").IsNil()?"0":y.Reduce("sessions").Visualize();return{status:String(v),sessions:String(I)}});l(`[${e}] e2e restore commit: status=${u.status} sessions=${u.sessions}`)}catch(u){c(u)&&f("commit_e2e_restore",u),l(`[${e}] E2E RESTORE REJECTED \u2014 staged session blob failed pickle_key validation; discarding it, fresh account + self-heal fallback take over: ${String(u).slice(0,260)}`),g(r,{event:"e2e_restore_rejected",origin:"restore",error:String(u).slice(0,300)});try{await w(async p=>{await h(r,"::a2a_messaging::reject_e2e_restore",{},p)})}catch(p){c(p)&&f("reject_e2e_restore",p),l(`[${e}] reject_e2e_restore failed (staging is transient; continuing):`,String(p))}}try{r.pw.refresh_identity_proof_document(),l(`[${e}] transport IPD refreshed from post-import state`)}catch(u){i("ipd_refresh","FAILED (IPD would advertise a stale bundle)",u)}let n=!1,d="";try{if(process.env.OURS_TEST_FORCE_IPD_INCOHERENT==="1")throw new Error("forced incoherent (OURS_TEST_FORCE_IPD_INCOHERENT)");let u=S(v=>String(R(r,"::a2a_messaging::e2e_self_fp",v).Reduce("ik").Visualize())),p=r.pw.identity_proof_document.Visualize(),y=u.replace(/^0x/i,"");n=y.length>=32&&p.toLowerCase().includes(y.toLowerCase()),d=u.slice(0,18),g(r,{event:"ipd_coherence",ik:u,coherent:n})}catch(u){i("ipd_coherence","probe FAILED (coherence unprovable)",u)}l(`[${e}] IPD/e2e coherence: account_ik=${d}\u2026 ipd_advertises_it=${n}`),n||i("ipd_coherence","IPD does NOT advertise the live account ik",new Error("incoherent transport IPD"))}}return j.expose_packet(r.cid),N.set(e,r),l(`[${e}] EXPOSED (routing + broker registration) \u2014 import phase complete`),await me(r),P(r),r}async function kt(){m.mkdirSync(E(),{recursive:!0});let e;try{e=m.readFileSync(Q(),"utf8").trim()}catch{}let t=Ve(24).toString("hex");ne(await C(F,t,E(),!1,e)),e||m.writeFileSync(Q(),q(b),{mode:384}),oe(Z(b)),l(`contact-book registrar ready (${b.cid})`)}function Se(e){try{return m.existsSync(k(e))&&m.statSync(k(e)).size>0}catch{return!1}}function ze(e){let t=S(c=>Buffer.from(R(e,"::actor::export_state",c).Serialize()));m.mkdirSync(e.dir,{recursive:!0,mode:448});let s=k(e.dir),r=`${s}.tmp`,a;try{a=m.openSync(r,"w",384),m.fchmodSync(a,384),m.writeFileSync(a,t),m.fsyncSync(a),m.closeSync(a),a=void 0,m.renameSync(r,s),m.chmodSync(s,384);try{m.chmodSync(O(e.dir),384)}catch{}let c=m.openSync(e.dir,"r");try{m.fsyncSync(c)}finally{m.closeSync(c)}}catch(c){if(a!==void 0)try{m.closeSync(a)}catch{}try{m.rmSync(r,{force:!0})}catch{}throw c}}function z(e){try{ze(e),e.persistFailed&&(e.persistFailed=!1,l(`[${e.name}] persist recovered \u2014 quarantine lifted`),g(e,{event:"persist_recovered"}))}catch(t){e.persistFailed=!0,l(`[${e.name}] PERSIST FAILED \u2014 identity quarantined (fail-closed), outbound of this txn withheld:`,String(t));try{g(e,{event:"persist_failed",error:String(t).slice(0,300)})}catch{}throw process.nextTick(()=>ee(e.name,`[${e.name}] PERSIST FAILED \u2014 messaging quarantined until the state file is writable again`)),t}}function S(e){let t=new Re;try{return e(t)}finally{t.Finalize()}}async function w(e){let t=new Re;try{return await e(t)}finally{t.Finalize()}}function R(e,t,s,r){let a=$e({name:t,targ:r}),c=e.pw.packet.ExecuteTransaction(a);return a.Destroy(),s?c.Attach(s):c}async function Ee(e,t){let s=e.lock,r;e.lock=new Promise(a=>r=a),await s;try{return await t()}finally{r()}}function Ae(e,t,s=25e3){return new Promise((r,a)=>{let c=setTimeout(()=>{let i=e.pending.findIndex(f=>f.timer===c);i>=0&&e.pending.splice(i,1),a(new Error("timed out waiting for the transaction result"))},s);e.pending.push({resolve:r,reject:a,timer:c}),e.pw.add_client_message(t)})}function h(e,t,s,r,a){if(e.persistFailed)try{z(e)}catch(i){return Promise.reject(new Error(`identity "${e.name}" is quarantined: state persist is failing (${String(i)}) \u2014 mutations are rejected until state_data.bin is writable again`))}let c=$e({name:t,targ:s});return Ee(e,()=>Ae(e,c,a)).then(i=>{if(c.Destroy(),e.persistFailed){try{i.Destroy()}catch{}throw new Error(`identity "${e.name}": state persist FAILED \u2014 this transaction's outbound was withheld (fail-closed); fix the state directory and retry`)}return r?i.Attach(r):i},i=>{try{c.Destroy()}catch{}throw i})}var D=null;function jt(e){D?.uninstall(),D=e===null?null:{hook:e,uninstall:ue("notification",e)}}function Lt(e){D?.hook===e&&(D.uninstall(),D=null)}function ee(e,t){fe(e,t)}var ve={onNotify:(e,t)=>ee(e,t)},U=new Map;function Oe(e){let t=U.get(e);if(!(!t||t.size===0))for(let s of[...t])try{s()}catch{}}function Pe(e,t){return new Promise(s=>{let r=U.get(e);r||(r=new Set,U.set(e,r));let a=!1,c=()=>{a||(a=!0,r.delete(i),r.size===0&&U.delete(e),clearTimeout(f),s())},i=c,f=setTimeout(c,t);r.add(i)})}function g(e,t){try{_.mkdirSync(e.dir,{recursive:!0,mode:448}),_.appendFileSync(L(e.dir),JSON.stringify(t)+`
|
|
3
|
-
`)}catch(s){l(`[${e.name}] failed to append notifications.log:`,String(s))}Oe(e.name),le(e,t)}function Bt(e){let t=L(e.dir),s="";try{s=_.readFileSync(t,"utf8")}catch{return new Set}let r=[];for(let a of s.split(`
|
|
4
|
-
`))if(a.trim())try{r.push(JSON.parse(a))}catch{}return de(r)}function V(e,t){let s=e.Reduce(t);return s.IsNil()?"":Buffer.from(s.GetBinary()).toString("hex")}var De=Number(process.env.OURS_NOTIFY_LONGPOLL_MS)>0?Number(process.env.OURS_NOTIFY_LONGPOLL_MS):25e3,Fe=250;function te(e){try{return _.statSync(e).size}catch{return 0}}function je(e,t,s){if(s<=t)return{events:[],cursor:t};let r=Buffer.alloc(s-t),a=0;try{let o=_.openSync(e,"r");try{a=_.readSync(o,r,0,r.length,t)}finally{_.closeSync(o)}}catch{return{events:[],cursor:t}}let c=r.subarray(0,a),i=c.lastIndexOf(10);if(i===-1)return{events:[],cursor:t};let f=[];for(let o of c.subarray(0,i+1).toString("utf8").split(`
|
|
5
|
-
`))if(o.trim())try{f.push(JSON.parse(o))}catch{}return{events:f,cursor:t+i+1}}async function Mt(e,t,s,r){let a=L(be(T,s)),c=(n,d)=>{t.writableEnded||(t.writeHead(200,{"Content-Type":"application/json"}),t.end(JSON.stringify({cursor:n,events:d})))};if(r===null||r==="tip"){c(te(a),[]);return}let i=parseInt(r,10);if(!Number.isFinite(i)||i<0){t.writableEnded||(t.writeHead(400,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:"invalid since cursor"})));return}let f=!1;e.on("close",()=>{f=!0});let o=Date.now()+De;for(;!f;){let n=te(a);if(i>n&&(i=0),n>i){let{events:d,cursor:u}=je(a,i,n);if(d.length>0){c(u,d);return}i=u}if(Date.now()>=o)break;await Pe(s,Math.min(Fe,o-Date.now()))}f||c(te(a),[])}function P(e){try{let{unread:t,unreadFiles:s}=S(c=>{let f=pe(R(e,"::actor::list_incoming_messages",c)).filter(d=>d.status==="unread"),o=R(e,"::actor::list_incoming_files",c),n=[];if(!o.IsNil())for(let d=0;;d++){let u=o.Reduce(d);if(u.IsNil())break;u.Reduce("status").Visualize()==="unread"&&n.push({file_id:u.Reduce("file_id").Visualize(),sender_id:u.Reduce("sender_id").Visualize(),from:u.Reduce("sender_name").Visualize(),filename:u.Reduce("filename").Visualize(),mime:u.Reduce("mime").Visualize(),bytes:u.Reduce("size").Visualize(),date:u.Reduce("date").Visualize(),wire_id:u.Reduce("wire_id").Visualize()})}return{unread:f,unreadFiles:n}}),r={count:t.length,recent:t.slice(-10).map(c=>({from:c.sender_name,msg_id:c.msg_id,date:c.date})),files:s.length,unread_files:s.slice(-10)};_.mkdirSync(e.dir,{recursive:!0,mode:448});let a=`${B(e.dir)}.tmp`;_.writeFileSync(a,JSON.stringify(r)),_.renameSync(a,B(e.dir))}catch(t){l(`[${e.name}] failed to refresh unread snapshot:`,String(t))}}function Ht(){let e=[],t=[];try{t=_.readdirSync(T,{withFileTypes:!0})}catch{return{identities:e}}for(let s of t){if(!s.isDirectory()||re(s.name)!==null)continue;let r;try{r=JSON.parse(_.readFileSync(B(be(T,s.name)),"utf8"))}catch{continue}let a=Number.isSafeInteger(r.count)&&Number(r.count)>=0?Number(r.count):0,c=Number.isSafeInteger(r.files)&&Number(r.files)>=0?Number(r.files):0;if(a===0&&c===0)continue;let i=Array.isArray(r.recent)?r.recent.slice(-10).flatMap(o=>{if(!o||typeof o!="object")return[];let n=o;return typeof n.from!="string"||!["string","number"].includes(typeof n.msg_id)||typeof n.date!="string"?[]:[{from:n.from,msg_id:n.msg_id,date:n.date}]}):[],f=Array.isArray(r.unread_files)?r.unread_files.slice(-10).flatMap(o=>{if(!o||typeof o!="object")return[];let n=o;return typeof n.from!="string"||typeof n.filename!="string"||typeof n.mime!="string"||typeof n.wire_id!="string"?[]:[{from:n.from,filename:n.filename,mime:n.mime,wire_id:n.wire_id,...typeof n.sender_id=="string"?{sender_id:n.sender_id}:{},...["string","number"].includes(typeof n.file_id)?{file_id:n.file_id}:{},...["string","number"].includes(typeof n.bytes)?{bytes:n.bytes}:{},...typeof n.date=="string"?{date:n.date}:{}}]}):[];e.push({name:s.name,count:a,recent:i,files:c,unread_files:f})}return e.sort((s,r)=>String(s.name).localeCompare(String(r.name))),{identities:e}}export{jt as a,Lt as b,ee as c,ve as d,Oe as e,Pe as f,g,Bt as h,V as i,te as j,je as k,Mt as l,P as m,Ht as n,He as o,ke as p,K as q,me as r,xe as s,H as t,qe as u,ge as v,C as w,A as x,gt as y,yt as z,kt as A,Se as B,ze as C,z as D,S as E,w as F,R as G,Ee as H,Ae as I,h as J,E as K,Q as L,Y as M,ye as N,_e as O,Z as P,q as Q,we as R,it as S,he as T};
|
package/dist/chunk-HH4NDU7C.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as n}from"./chunk-UM73BGFH.js";var a=class{base;leaseToken;clientPid;apiToken;fetchImpl;constructor(e){this.base=e.url.replace(/\/+$/,""),this.leaseToken=e.leaseToken,this.clientPid=e.clientPid??process.pid,this.apiToken=e.apiToken,this.fetchImpl=e.fetch??globalThis.fetch}headers(e={}){return{"x-ours-lease-token":this.leaseToken,"x-ours-client-pid":String(this.clientPid),...this.apiToken?{"x-ours-api-token":this.apiToken}:{},...e}}async post(e,s){let i=await this.fetchImpl(`${this.base}/api/v1/${e}`,{method:"POST",headers:this.headers({"content-type":"application/json"}),body:JSON.stringify(s??{})}),t;try{t=await i.json()}catch{throw new Error(`${e}: the daemon returned a non-JSON response (HTTP ${i.status})`)}if(t&&typeof t=="object"&&!Array.isArray(t)&&"error"in t){let r=t.error,o=r!==null&&typeof r=="object"&&"code"in r&&"message"in r;if(i.status===400&&o){let{code:c,message:d}=r;throw new n(c,d)}let p=o?r.message:String(r);throw new Error(`${e}: ${p} (HTTP ${i.status})`)}if(!i.ok)throw new Error(`${e}: the daemon returned HTTP ${i.status} with no error field`);return t}async get(e,s){let i=await this.fetchImpl(`${this.base}${e}`,{headers:s?this.headers():{}}),t;try{t=await i.json()}catch{throw new Error(`GET ${e}: the daemon returned a non-JSON response (HTTP ${i.status})`)}if(t&&typeof t=="object"&&"error"in t)throw new Error(`GET ${e}: ${String(t.error)} (HTTP ${i.status})`);if(!i.ok)throw new Error(`GET ${e}: the daemon returned HTTP ${i.status} with no error field`);return t}createIdentity(e){return this.post("createIdentity",e)}createTemporaryIdentity(e){return this.post("createTemporaryIdentity",e)}closeTemporaryIdentityOp(e={}){return this.post("closeTemporaryIdentityOp",e)}createRootIdentity(e){return this.post("createRootIdentity",e)}defineLocalIdentityFile(e){return this.post("defineLocalIdentityFile",e)}chooseIdentity(e){return this.post("chooseIdentity",e)}listIdentities(){return this.post("listIdentities",{})}currentIdentity(){return this.post("currentIdentity",{})}removeIdentity(e){return this.post("removeIdentity",e)}releaseLease(){return this.post("releaseLease",{})}generateInvite(e={}){return this.post("generateInvite",e)}listInvites(){return this.post("listInvites",{})}revokeInvite(e){return this.post("revokeInvite",e)}addContact(e){return this.post("addContact",e)}listContacts(){return this.post("listContacts",{})}listLocalContactBook(){return this.post("listLocalContactBook",{})}setLocalBookPolicy(e){return this.post("setLocalBookPolicy",e)}removeContact(e){return this.post("removeContact",e)}renameContact(e){return this.post("renameContact",e)}respondToIntroduction(e){return this.post("respondToIntroduction",e)}setBio(e){return this.post("setBio",e)}advertiseMigrate(){return this.post("advertiseMigrate",{})}readvertiseOnUpgrade(){return this.post("readvertiseOnUpgrade",{})}setPersona(e){return this.post("setPersona",e)}sendMessage(e){return this.post("sendMessage",e)}sendFile(e){return this.post("sendFile",e)}listIncomingMessages(){return this.post("listIncomingMessages",{})}getMessages(){return this.post("getMessages",{})}deferMessages(e){return this.post("deferMessages",e)}deferFiles(e){return this.post("deferFiles",e)}getConversation(e){return this.post("getConversation",e)}getReceipts(e){return this.post("getReceipts",e)}markRead(e){return this.post("markRead",e)}setConversationPolicy(e){return this.post("setConversationPolicy",e)}listIncomingFiles(){return this.post("listIncomingFiles",{})}getFiles(e={}){return this.post("getFiles",e)}saveFileFallbackNotice(e){return this.post("saveFileFallbackNotice",e)}version(){return this.get("/version",!1)}stateDir(){return this.get("/state-dir",!1)}async identities(){return(await this.get("/identities",!0)).identities}unread(){return this.get("/unread",!0)}async*watchNotifications(e,s={}){let i=s.since??"tip",t=`/identities/${encodeURIComponent(e)}/notifications`;for(;!s.signal?.aborted;){let r;try{let o=await this.fetchImpl(`${this.base}${t}?since=${i}`,{headers:this.headers(),signal:s.signal});try{r=await o.json()}catch{throw new Error(`watchNotifications(${e}): the daemon returned a non-JSON response (HTTP ${o.status})`)}}catch(o){if(s.signal?.aborted)return;throw o}if("error"in r)throw new Error(`watchNotifications(${e}): ${r.error}`);i=r.cursor;for(let o of r.events)yield o}}async fetchFile(e){let s=await this.fetchImpl(`${this.base}/files/${encodeURIComponent(e)}`,{headers:this.headers()});if(!s.ok){let i=`HTTP ${s.status}`;try{let t=await s.json();t&&t.error!==void 0&&(i=String(t.error))}catch{}throw new Error(`fetchFile(${e}): ${i}`)}return new Uint8Array(await s.arrayBuffer())}};export{a};
|
package/dist/chunk-UJGRFV4J.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
var r=new Set(["message_received","file_received","contact_name_collision","sibling_contact_added","local_contact_request","pending_message","e2e_restore_rejected","contact_restored","migration_active","e2e_app_send","dedup_degraded","e2e_delivery_expired","e2e_app_recv","e2e_rekey","migration_deferred_flush","migration_stalled","downgrade_refused","contact_removed","monitoring_disabled","inbound_error"]),i={event:()=>{},notification:()=>{}},t={...i};function o(e,n){return t[e]=n,()=>{t[e]===n&&(t[e]=i[e])}}function d(){Object.assign(t,i)}function s(e){return t[e]===i[e]}function a(e,n){t.event({identity:e.name,event:typeof n.event=="string"?n.event:"",record:n})}function c(e,n){t.notification(e,n)}export{r as a,o as b,d as c,s as d,a as e,c as f};
|
package/dist/chunk-XA7LBPKN.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{d as D}from"./chunk-V64IUVSS.js";import{a as L}from"./chunk-37D5PCFY.js";import{a as de,b as ce}from"./chunk-LLBTV276.js";import{a as pe,d as le}from"./chunk-BE77DLV3.js";import{b as ae}from"./chunk-BWALN5H4.js";import{b as ie,c as se}from"./chunk-7EDGK5KR.js";import{b as re}from"./chunk-MORSFKSX.js";import{C as oe,a as q,b as ee,l as te,n as ne}from"./chunk-A27DA5GZ.js";import{a as $,b as X,c as u,e as x,f as Y,g as Z}from"./chunk-XYPZUKWU.js";import{c as I,o as Q,v as W}from"./chunk-FXHIUVFI.js";import{a as N,b as B,c as M,d as F,e as k,g as V,h as P,i as p,m as T,p as K}from"./chunk-47KSJAVX.js";import{createServer as he}from"node:http";import{randomUUID as we}from"node:crypto";import*as H from"node:fs";function Ie(s){if(!s||typeof s!="object"||Array.isArray(s))return!1;let r=s;return r.jsonrpc==="2.0"&&r.method==="initialize"}var Se=["brokerUrl","port","stateDir","gcIntervalMs","apiVisibility"];function fe(s){return new Promise((r,R)=>{let h="";s.on("data",a=>h+=a),s.on("end",()=>{try{r(JSON.parse(h))}catch(a){R(a)}}),s.on("error",R)})}async function Le(s={}){try{return await ve(s)}catch(r){throw P?.failed(),p(`fatal startup error: ${r?.stack??r}`),r}}async function ve(s){if(process.env.OURS_TEST_STARTUP_FAIL==="1")throw new Error("forced startup failure (OURS_TEST_STARTUP_FAIL)");if(s.config){let t=Se.filter(e=>s.config[e]!==B[e]);if(t.length>0)throw new Error(`startDaemon(config) disagrees with the config resolved at module load (${t.join(", ")}). The engine reads its config when src/runtime/env.ts is imported, so a later override cannot move the state dir, port or broker \u2014 set OURS_* env or config.json before importing the SDK.`)}let r=s.mcp,R=r?.isInitializeRequest??Ie,h=null;if(typeof s.onIdentityNotify=="function"){let t=s.onIdentityNotify;h=(e,i)=>{t(e,i,$.get(e)?.sid??null)},q(h)}p("booting wrapper\u2026"),await ae(),de(),p(`wrapper ready (identities=${I.size}), starting HTTP server\u2026`),P?.update("server");let a={},S=new Map,v=new Map,me=3e4,j=t=>{let e=v.get(t);e?e.n++:v.set(t,{n:1,since:Date.now()})},A=t=>{let e=v.get(t);e&&--e.n<=0&&v.delete(t)},G=()=>{let t=0;for(let e of[...S.keys()]){if(e==="stdio")continue;let i=u.get(e)?.pid;if(i===void 0||i<=1||x(i))continue;let n=v.get(e);if(n&&n.n>0&&Date.now()-n.since<me)continue;let o=S.get(e);S.delete(e),delete a[e],u.delete(e),v.delete(e),o?.close().catch(()=>{}),r?.onSessionClosed?.(e),t++,p(`session ${e.slice(0,8)}\u2026 reaped (client pid ${i} dead)`)}return t},U=setInterval(()=>{G(),se()},6e4);U.unref?.();let _=1e3,ue=10*6e4,f=new Map,ge=(t,e)=>{let i=Array.isArray(e)?e:[e];for(let n of i){let o=n;!o||typeof o!="object"||o.id===void 0||o.id===null||typeof o.method!="string"||f.set(`${t}:${String(o.id)}`,{method:o.method,at:Date.now()})}if(f.size>_){let n=Date.now()-ue;for(let[o,d]of f)if(d.at<n&&f.delete(o),f.size<=_)break;for(;f.size>_;){let o=f.keys().next();if(o.done)break;f.delete(o.value)}}},ye=(t,e)=>{try{let i=e instanceof Error?e.message:String(e),n=/No connection established for request ID:\s*(\S+)/.exec(i);if(!n)return;let o=n[1],d=f.get(`${t}:${o}`);f.delete(`${t}:${o}`),p(`UNDELIVERABLE RESPONSE session=${t.slice(0,8)}\u2026 request_id=${o} method=${d?.method??"unknown"} age_ms=${d?Date.now()-d.at:"unknown"} at=${new Date().toISOString()} \u2014 the answer was produced but its stream was already gone`)}catch{}},g=he(async(t,e)=>{let i=new URL(t.url,`http://localhost:${k}`);if(t.method==="GET"&&i.pathname==="/state-dir"){e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify({stateDir:M,version:N,compat:1}));return}if(t.method==="GET"&&(i.pathname==="/version"||i.pathname==="/info")){e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify({name:"ours",version:N,compat:1,protocol:re,pid:process.pid,stateDir:M}));return}if(t.method==="GET"&&i.pathname==="/identities"){if(!T(t,e))return;e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify({identities:[...I.values()].map(n=>({name:n.name,...n.temp?{temporary:!0,stale:!x(n.temp.owner.pid)}:{}}))}));return}if(t.method==="GET"&&i.pathname==="/unread"){if(!T(t,e))return;e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify(ne()));return}{let n=/^\/identities\/([^/]+)\/notifications$/.exec(i.pathname);if(t.method==="GET"&&n){if(!T(t,e))return;let o=decodeURIComponent(n[1]);if(K(o)!==null){e.writeHead(400,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:"invalid identity name"}));return}await te(t,e,o,i.searchParams.get("since"));return}}{let n=/^\/files\/([^/]+)$/.exec(i.pathname);if(t.method==="GET"&&n){if(!T(t,e))return;let o=decodeURIComponent(n[1]),d=t.headers["x-ours-lease-token"],w=typeof d=="string"&&d?Y(d):void 0,m=w?I.get(w.identity):void 0;if(!m){e.writeHead(401,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:"no identity bound to this session"}));return}let y=W(m,o);if(!y){e.writeHead(404,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:"no such file for the bound identity (run get_files first, or it belongs to another identity)"}));return}try{let l=H.statSync(y);e.writeHead(200,{"Content-Type":"application/octet-stream","Content-Length":String(l.size)});let E=H.createReadStream(y);E.on("error",()=>{try{e.destroy()}catch{}}),E.pipe(e)}catch(l){e.writeHead(500,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:`failed to read file: ${String(l)}`}))}return}}if(i.pathname.startsWith(pe)){await le(t,e,i.pathname,fe);return}if(i.pathname!=="/mcp"||!r){e.writeHead(404,{"Content-Type":"text/plain"}),e.end("Not found");return}if(T(t,e))try{if(t.method==="POST"){let n=await fe(t),o=t.headers["mcp-session-id"],d=t.headers["x-ours-lease-token"],w=t.headers["x-ours-client-pid"],m=w?parseInt(w,10):void 0,y={token:d,pid:Number.isInteger(m)?m:void 0};if(o&&a[o]){u.set(o,y),ge(o,n),j(o),D(e);try{await a[o].handleRequest(t,e,n)}finally{A(o)}}else if(!o&&R(n)){G();let l=r.createTransport({sessionIdGenerator:()=>we(),onsessioninitialized:c=>{a[c]=l,u.set(c,y),S.set(c,C),r.onSessionInitialized?.(c,C),p(`session ${c.slice(0,8)}\u2026 initialized`)}}),E={sessionId:()=>l.sessionId??"pending",leaseToken:()=>u.get(l.sessionId??"pending")?.token,clientPid:()=>u.get(l.sessionId??"pending")?.pid},C=r.createServer(E);C.server.onerror=c=>ye(l.sessionId??"pending",c),l.onclose=()=>{let c=l.sessionId;c&&(delete a[c],S.delete(c),u.delete(c),r.onSessionClosed?.(c),p(`session ${c.slice(0,8)}\u2026 closed (lease kept)`))},await C.connect(l),D(e),await l.handleRequest(t,e,n)}else e.writeHead(400,{"Content-Type":"application/json"}),e.end(JSON.stringify({jsonrpc:"2.0",error:{code:-32e3,message:"Bad Request: No valid session ID"},id:null}))}else if(t.method==="GET"){let n=t.headers["mcp-session-id"];if(!n||!a[n]){e.writeHead(400,{"Content-Type":"text/plain"}),e.end("Invalid or missing session ID");return}j(n),D(e);try{await a[n].handleRequest(t,e)}finally{A(n)}}else if(t.method==="DELETE"){let n=t.headers["mcp-session-id"];if(!n||!a[n]){e.writeHead(400,{"Content-Type":"text/plain"}),e.end("Invalid or missing session ID");return}let o=u.get(n)?.token??t.headers["x-ours-lease-token"];if(o){for(let[d,w]of[...$]){if(w.token!==o)continue;$.delete(d);let m=I.get(d);m?.temp&&m.temp.owner.tokenHash===Q(o)&&!m.temp.closing&&ie(m,"owning session released its lease").catch(y=>p(`[${d}] close on lease release failed:`,String(y)))}X.delete(o),Z(),p(`lease released by token \u2026${o.slice(-6)}`)}await a[n].handleRequest(t,e)}else e.writeHead(405,{"Content-Type":"text/plain"}),e.end("Method not allowed")}catch(n){p("HTTP handler error:",String(n)),e.headersSent||(e.writeHead(500,{"Content-Type":"application/json"}),e.end(JSON.stringify({jsonrpc:"2.0",error:{code:-32603,message:"Internal server error"},id:null})))}});g.requestTimeout=0,await new Promise((t,e)=>{let i=n=>e(n);g.once("error",i),g.listen(k,"127.0.0.1",()=>{g.off("error",i),P?.ready(),p(`MCP server v${s.version??N} ready (transport=http, port=${k}, visibility=${V}, identities=${I.size}, state=${M}, broker=${F})`),t()})});let z=!1,J=async()=>{if(!z){z=!0,clearInterval(U),ce();for(let t of Object.keys(a)){try{await a[t].close()}catch{}delete a[t]}S.clear();for(let t of I.values())try{oe(t)}catch(e){p(`[${t.name}] shutdown save failed:`,String(e))}g.closeAllConnections?.()}},O=async()=>{p("shutting down\u2026"),await J(),g.close(),process.exit(0)};process.on("SIGINT",O),process.on("SIGTERM",O);let b=g.address();return{port:typeof b=="object"&&b!==null?b.port:k,close:async()=>{process.off("SIGINT",O),process.off("SIGTERM",O),h&&ee(h),await J(),await new Promise(t=>g.close(()=>t()))}}}export{Le as a};
|