@ours.network/sdk 1.5.1 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/contacts.js +1 -1
- package/dist/api/conversations.js +1 -1
- package/dist/api/files.js +1 -1
- package/dist/api/identity.js +1 -1
- package/dist/api/messaging.d.ts +1 -0
- package/dist/api/messaging.js +1 -1
- package/dist/api/profile.js +1 -1
- package/dist/book.js +1 -1
- package/dist/boot.js +1 -1
- package/dist/{chunk-2LPPMBJO.js → chunk-2AGDAI76.js} +1 -1
- package/dist/chunk-3CS6SGYE.js +2 -0
- package/dist/{chunk-BHXHOLIS.js → chunk-4L37F7EA.js} +1 -1
- package/dist/{chunk-V45U6UR6.js → chunk-4TASOWGY.js} +1 -1
- package/dist/{chunk-Q2KM7EML.js → chunk-5UEWBTIG.js} +1 -1
- package/dist/chunk-65KGEJBX.js +2 -0
- package/dist/{chunk-ELU5JE5X.js → chunk-6MGSS5ZO.js} +1 -1
- package/dist/{chunk-5OFCFCOO.js → chunk-AGWCGBCT.js} +1 -1
- package/dist/{chunk-PE62AXC7.js → chunk-D7I2EFNP.js} +1 -1
- package/dist/{chunk-7ARLMLTM.js → chunk-EVP7IDZJ.js} +1 -1
- package/dist/chunk-FC4ERYFN.js +2 -0
- package/dist/{chunk-OJD7HN2X.js → chunk-FNASW6T5.js} +1 -1
- package/dist/chunk-FYYBC5Q4.js +2 -0
- package/dist/{chunk-W636XKOM.js → chunk-G2ODDJ4Z.js} +1 -1
- package/dist/{chunk-6WJFQZDB.js → chunk-JAT7EOYH.js} +1 -1
- package/dist/{chunk-6DGPJGV6.js → chunk-JGOJHX3P.js} +1 -1
- package/dist/{chunk-JSUSHZQC.js → chunk-MGCRONNT.js} +1 -1
- package/dist/chunk-OA7XXAFG.js +2 -0
- package/dist/chunk-POTB37MR.js +5 -0
- package/dist/{chunk-LYS6K3N2.js → chunk-RJ36BIMK.js} +1 -1
- package/dist/{chunk-VSA5JZ2T.js → chunk-RNIN2NDZ.js} +1 -1
- package/dist/chunk-V7OPRCZ3.js +2 -0
- package/dist/chunk-ZNDBLX5J.js +2 -0
- package/dist/client/http.d.ts +27 -0
- package/dist/client/http.js +1 -1
- package/dist/client.js +1 -1
- package/dist/cluster/control.js +1 -1
- package/dist/cluster/manifest.js +1 -1
- package/dist/connector.js +3 -3
- package/dist/daemon.js +1 -1
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +1 -1
- package/dist/gc.js +1 -1
- package/dist/http/api-routes.js +1 -1
- package/dist/http/server.js +1 -1
- package/dist/identity/hierarchy.js +1 -1
- package/dist/identity/lease.js +1 -1
- package/dist/identity/lifecycle.js +1 -1
- package/dist/identity/model.js +1 -1
- package/dist/identity/provision.js +1 -1
- package/dist/index.js +1 -1
- package/dist/messaging/send.js +1 -1
- package/dist/mufl/handlers.js +1 -1
- package/dist/mufl/tx.js +1 -1
- package/dist/mufl_code/7962BB01B1D3E782A1F80B083A900AEC30BAC8F8CE79282B31821802B94A39B6.muflo +0 -0
- package/dist/notify.d.ts +6 -1
- package/dist/notify.js +1 -1
- package/dist/render/adapt-to-json.js +1 -1
- package/dist/runtime/env.js +1 -1
- package/dist/state.js +1 -1
- package/dist/sweeps.js +1 -1
- package/dist/uploads.d.ts +47 -0
- package/dist/uploads.js +2 -0
- package/package.json +2 -2
- package/dist/chunk-BL54LJNA.js +0 -2
- package/dist/chunk-FUQOCQSL.js +0 -2
- package/dist/chunk-H343HSTY.js +0 -5
- package/dist/chunk-OCOEH3BS.js +0 -2
- package/dist/chunk-OS7QJTVD.js +0 -2
- package/dist/chunk-OTPDDDO2.js +0 -2
- package/dist/chunk-RBFKJ6UR.js +0 -2
package/dist/client/http.d.ts
CHANGED
|
@@ -33,6 +33,15 @@ export interface DaemonIdentityRow {
|
|
|
33
33
|
temporary?: boolean;
|
|
34
34
|
stale?: boolean;
|
|
35
35
|
}
|
|
36
|
+
/** The receipt `POST /files/upload` returns — mirrors `StagedUpload` in src/uploads.ts. */
|
|
37
|
+
export interface StagedUploadReceipt {
|
|
38
|
+
upload_id: string;
|
|
39
|
+
filename: string;
|
|
40
|
+
mime: string;
|
|
41
|
+
size: number;
|
|
42
|
+
sha256: string;
|
|
43
|
+
at: string;
|
|
44
|
+
}
|
|
36
45
|
/** One page of `GET /identities/<name>/notifications`. */
|
|
37
46
|
export interface NotificationPage {
|
|
38
47
|
cursor: number;
|
|
@@ -173,6 +182,7 @@ export declare class OursClient {
|
|
|
173
182
|
*/
|
|
174
183
|
watchNotifications(identity: string, opts?: {
|
|
175
184
|
since?: number | 'tip';
|
|
185
|
+
kinds?: readonly string[];
|
|
176
186
|
signal?: AbortSignal;
|
|
177
187
|
}): AsyncGenerator<NotificationEvent, void, undefined>;
|
|
178
188
|
/**
|
|
@@ -182,5 +192,22 @@ export declare class OursClient {
|
|
|
182
192
|
* what is already on disk.
|
|
183
193
|
*/
|
|
184
194
|
fetchFile(wireId: string): Promise<Uint8Array>;
|
|
195
|
+
/**
|
|
196
|
+
* `GET /files/<wireId>`, STREAMED. The route always streamed, and save_file’s
|
|
197
|
+
* contract is that the bytes never become fully resident; `fetchFile` buffers.
|
|
198
|
+
* The ~2 MB envelope cap is a PIN that can differ from the core’s real value in
|
|
199
|
+
* either direction, so it is not a bound a client may rely on.
|
|
200
|
+
*/
|
|
201
|
+
openFile(wireId: string): Promise<ReadableStream<Uint8Array>>;
|
|
202
|
+
/**
|
|
203
|
+
* `POST /files/upload` — stage bytes for a later `sendFile({upload_id})`. Reads
|
|
204
|
+
* the file as YOUR OS user; `sendFile({path})` reads it as the daemon’s.
|
|
205
|
+
* Consumed by the first send that names it, including a failed one.
|
|
206
|
+
*/
|
|
207
|
+
uploadFile(body: Uint8Array | ReadableStream<Uint8Array>, meta: {
|
|
208
|
+
filename: string;
|
|
209
|
+
mime?: string;
|
|
210
|
+
size?: number;
|
|
211
|
+
}): Promise<StagedUploadReceipt>;
|
|
185
212
|
}
|
|
186
213
|
export {};
|
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-OA7XXAFG.js";import"../chunk-65KGEJBX.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
|
|
2
|
+
import{a as H}from"./chunk-OA7XXAFG.js";import{a as I,b as J,c as L,d as O,e as P,f as Q}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,L as F,M as G,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-65KGEJBX.js";import"./chunk-XYU2DSWR.js";import"./chunk-IB2U7K6Y.js";export{L as DAEMON_TOKEN_FILE,J as DEFAULT_DAEMON_PORT,I as DaemonSelectionError,H as OursClient,e as OursError,Q as assertDaemonStateDir,P as describeDaemonConfig,t as errBindingReassigned,y as errBoundElsewhere,i as errBoundIdentityGone,D as errDuplicateId,l as errFileTooLarge,U as errFileUnreadable,j as errIdentityClosedWithError,q as errIdentityPartiallyRemoved,B as errInvalidSelection,C as errMalformedId,r as errNameTaken,c as errNoLeaseHeaders,x as errNoLeaseToken,w as errNoPolicyArgs,A 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,z as errSaveFileFallback,K as errSendFileArgs,S as errSendFileFilenameRequired,b as errSendFileUploadArgs,v as errTempClosedWithError,n as errTempClosingBound,E as errTempClosingChoose,s as errTempOwnedElsewhereClose,M as errTempOwnedElsewhereRemove,N as errTempOwnedLive,g as errTempStale,G as errTool,F as errUnknownOrStaleId,h as errUploadNotFound,O 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-G2ODDJ4Z.js";import"../chunk-2AGDAI76.js";import"../chunk-6MGSS5ZO.js";import"../chunk-POTB37MR.js";import"../chunk-YRPUM6JG.js";import"../chunk-JGOJHX3P.js";import"../chunk-DIRW7I4S.js";import"../chunk-RJ36BIMK.js";import"../chunk-FNASW6T5.js";import"../chunk-4TASOWGY.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-2AGDAI76.js";import"../chunk-6MGSS5ZO.js";import"../chunk-POTB37MR.js";import"../chunk-YRPUM6JG.js";import"../chunk-JGOJHX3P.js";import"../chunk-DIRW7I4S.js";import"../chunk-RJ36BIMK.js";import"../chunk-FNASW6T5.js";import"../chunk-4TASOWGY.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
|
|
3
|
-
`),
|
|
2
|
+
import{a as oe}from"./chunk-5EWCIQH6.js";import{mkdirSync as ie,writeFileSync as Me,readFileSync as Ae,readdirSync as Ie,statSync as z,unlinkSync as De,chmodSync as ae,createWriteStream as xe}from"node:fs";import{join as $,dirname as Ne,resolve as $e}from"node:path";import{homedir as Ue}from"node:os";import{Readable as Le}from"node:stream";import{pipeline as Ce}from"node:stream/promises";var Pe="1.6.0",Je=new Set(["choose_identity","create_identity","create_root_identity"]),Fe="save_file",He="get_files",ce=a=>new Promise(g=>setTimeout(g,a)),q=a=>typeof a?.method=="string"&&a.id!==void 0&&a.id!==null,je=a=>a&&typeof a=="object"&&!("method"in a)&&a.id!==void 0&&a.id!==null,de=a=>{let g=a.result;return!!a.error||!!(g&&g.isError)},ue=Number(process.env.OURS_RESTORE_TTL_MS)>0?Number(process.env.OURS_RESTORE_TTL_MS):7*24*60*60*1e3,le=["1","true","yes","on"].includes((process.env.OURS_NO_AUTORESTORE??"").trim().toLowerCase());async function Ye(a){let g=new URL(a.url),S=!1,o=(...e)=>{if(!S)try{process.stderr.write(`[ours-proxy] ${e.join(" ")}
|
|
3
|
+
`)}catch{S=!0,y(0)}},G=()=>{S=!0,y(0)};process.stderr.on("error",G),process.stdout.on("error",G);let B=e=>Number.isInteger(e)&&e>1,W=Number(process.env.OURS_CLIENT_PID),R=B(W)?W:B(process.ppid)?process.ppid:process.pid,Y=(process.env.CLAUDE_CODE_SESSION_ID??"").trim()||`client:${R}`,b=null,I=null,L,f=null,D=new Map,C=new Set,T=null,v=le?null:(process.env.CLAUDE_CODE_SESSION_ID??"").trim()||null,fe=a.stateDir??process.env.OURS_STATE_DIR??$(Ue(),".ours"),k=$(fe,"session-restore"),Q=v&&/^[A-Za-z0-9._-]{1,200}$/.test(v)?v:null,h=Q?$(k,`${Q}.json`):null,X=!1,P=null;function pe(e){if(h)try{ie(k,{recursive:!0,mode:448}),Me(h,JSON.stringify({claudeSessionId:v,identity:e,boundAt:new Date().toISOString()}),{mode:384}),ae(k,448),ae(h,384)}catch(n){o("restore persist failed (non-fatal):",String(n))}}function me(){if(!h)return null;try{if(Date.now()-z(h).mtimeMs>ue)return null;let e=JSON.parse(Ae(h,"utf8"));return(typeof e.identity=="string"?e.identity.trim():"")||null}catch{return null}}function ge(){try{let e=Date.now();for(let n of Ie(k)){if(!n.endsWith(".json"))continue;let t=$(k,n);try{e-z(t).mtimeMs>ue&&(De(t),o("session-restore: pruned expired record",n))}catch{}}}catch{}}let E=(()=>{let e=(process.env.OURS_REQUEST_TIMEOUT_MS??"").trim();if(e==="")return 12e4;let n=Number(e);return Number.isFinite(n)&&n>=0?n:12e4})(),p=new Map,x=new Map;function J(e,n,t){let i=p.get(e);if(!i)return;p.delete(e),i.progressToken!==void 0&&x.delete(i.progressToken);let s=Date.now()-i.sentAt;o(`FAILING BACK request id=${String(e)} method=${i.method} waited_ms=${s} reason=${t}`),m.send({jsonrpc:"2.0",id:e,error:{code:n,message:`ours proxy: no response from the ours daemon for "${i.method}" after ${s}ms (${t}). The request was NOT retried \u2014 retry it yourself if it is safe to repeat.`,data:{reason:t,method:i.method,waitedMs:s}}}).catch(r=>o("fail-back send failed:",String(r)))}E>0&&setInterval(()=>{let n=Date.now();for(let[t,i]of[...p])i.deadline<=n&&J(t,-32001,"watchdog timeout")},1e3).unref?.();let ye=6e4,Z=3,F=0,w=0;function he(e,n){m.send({jsonrpc:"2.0",method:"notifications/message",params:{level:e,logger:"ours-proxy",data:n}}).catch(t=>o("downstream notify failed:",String(t)))}let l=null,we=()=>l,N=!1,O=!1,_=!1,M=[],_e="__ours_proxy_init__",H=0,A=new Set,j=new Set,m=a.transports.createStdioServer();m.onmessage=e=>{let n=[],t=!1;for(let i of U(e)){let s=i;if(s.method==="notifications/initialized"&&(t=!0),q(s)){if(s.method==="initialize"&&(b=s,I)){o("absorbed re-initialize locally \u2014 upstream session kept stable"),m.send({jsonrpc:"2.0",id:s.id,result:I}).catch(r=>o("local initialize reply failed:",String(r)));continue}if(s.method==="tools/call"){let r=s.params;if(r&&Je.has(r.name??"")&&typeof r.arguments?.name=="string"&&D.set(s.id,r.arguments.name),r?.name===He&&C.add(s.id),r?.name===Fe){let c=s.params?.arguments??{};be(s.id,c);continue}}if(E>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+E,transport:null,progressToken:c?.progressToken}),c?.progressToken!==void 0&&x.set(c.progressToken,r)}}n.push(s)}if(n.length){let i=Array.isArray(e)?n:n[0];ee(i)}t&&Se()},m.onclose=()=>void y(0),m.onerror=e=>o("downstream error:",String(e));let K=e=>{o(`stdin ${e} \u2014 the client is gone; shutting down`),y(0)};process.stdin.once("end",()=>K("reached EOF")),process.stdin.once("close",()=>K("closed"));function Se(){if(X||!f)return;X=!0;let e=`__ours_proxy_restore_${++H}__`;A.add(e),P=e,o("session-restore: self-recovering bound identity",`"${f}"`),ee({jsonrpc:"2.0",id:e,method:"tools/call",params:{name:"choose_identity",arguments:{name:f}}})}function Re(e,n){if(!(E<=0))for(let t of U(e)){let i=t.id;if(i===void 0)continue;let s=p.get(i);s&&(s.transport=n)}}async function be(e,n){let t=String(n.wire_id??"").trim(),i=String(n.dest_path??"").trim(),s=(r,c=!1)=>m.send({jsonrpc:"2.0",id:e,result:{content:[{type:"text",text:r}],isError:c}}).catch(d=>o("save_file reply failed:",String(d)));if(!t||!i){await s("save_file: both `wire_id` and `dest_path` are required.",!0);return}if(!/^[A-Za-z0-9]+$/.test(t)){await s("save_file: invalid wire_id.",!0);return}try{let r=new URL(g.href);r.pathname=`/files/${encodeURIComponent(t)}`,r.search="";let c={"x-ours-lease-token":Y};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 ${t} 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=$e(i);ie(Ne(u),{recursive:!0}),await Ce(Le.fromWeb(d.body),xe(u));let Oe=z(u).size;await s(`Saved file (wire_id ${t}) to ${u} (${Oe} bytes). The bytes were streamed daemon\u2192proxy\u2192disk and never entered this result.`)}catch(r){await s(`save_file failed: ${String(r)}`,!0)}}function ee(e){if(N&&l){let n=l;Re(e,n),l.send(e).catch(t=>{o("upstream send failed:",String(t));let i=U(e),s=i.filter(r=>!q(r));s.length&&M.push(Array.isArray(e)?s:s[0]);for(let r of i){let c=r;q(c)&&p.has(c.id)&&J(c.id,-32e3,"upstream send failed")}V(n,"send failed")})}else M.push(e)}function V(e,n){if(O||_||l!==null&&e!==l)return;o(`upstream dropped (${n}) \u2014 reconnecting`),N=!1;let t=l;l=null;try{t?.close?.()}catch{}if(t)for(let[i,s]of[...p])s.transport===t&&J(i,-32e3,`upstream dropped (${n})`);ke()}function Te(e){e.onmessage=n=>{let t=[];for(let i of U(n)){let s=i;if(s.method==="notifications/progress"){let r=s.params?.progressToken;if(r!==void 0){let c=x.get(r),d=c!==void 0?p.get(c):void 0;d&&(d.deadline=Date.now()+E)}}if(je(s)){let r=s.id,c=p.get(r);c&&(p.delete(r),c.progressToken!==void 0&&x.delete(c.progressToken));let d=s.result?.protocolVersion;if(d&&(j.has(r)||ne(r))){L=d;try{l?.setProtocolVersion?.(d)}catch{}if(I==null&&ne(r)&&!A.has(r)){let u=s.result??null;u&&T&&(u.instructions=`${u.instructions?u.instructions+`
|
|
4
4
|
|
|
5
|
-
`:""}${
|
|
5
|
+
`:""}${T}`),I=u}j.delete(r)}if(A.has(r)){A.delete(r),r===P&&(P=null,de(s)&&(f=null,o("session-restore: re-bind refused (identity live elsewhere) \u2014 staying unbound")));continue}if(C.has(r)&&(C.delete(r),a.annotateResult?.(s)&&o("get_files: daemon copy unreadable by this OS user \u2014 asked the agent for a destination")),D.has(r)){let u=D.get(r);D.delete(r),de(s)||(f=u,o("bound identity tracked:",u),pe(u))}}t.push(s)}if(t.length){let i=Array.isArray(n)?t:t[0];m.send(i).catch(s=>o("downstream send failed:",String(s)))}},e.onerror=n=>{let t=String(n);if(o("upstream error:",t),!/Maximum reconnection attempts \(\d+\) exceeded/.test(t))return;let i=Date.now();if(i-F<ye){o(`notification stream exhausted again within cooldown \u2014 not escalating (${Math.round((i-F)/1e3)}s since last)`);return}if(F=i,w++,w>Z){o(`NOTIFICATION STREAM DEAD \u2014 ${w-1} reconnect escalations exhausted; server\u2192client notifications are NOT arriving`),he("error",`ours proxy: the server\u2192client notification stream could not be re-established after ${w-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}o(`notification stream exhausted its retries \u2014 escalating to a full reconnect (${w}/${Z})`),V(e,"notification stream exhausted")},e.onclose=()=>V(e,"closed")}let ne=e=>b!=null&&b.id===e;async function te(){a.ensureDaemon&&await a.ensureDaemon().catch(n=>o("ensureDaemon:",String(n)));let e=a.transports.createHttpClient(g,{reconnectionOptions:{initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:5},requestInit:{headers:{"x-ours-lease-token":Y,"x-ours-client-pid":String(R),...a.apiToken?{"x-ours-api-token":a.apiToken}:{}}}});if(Te(e),await e.start(),L)try{e.setProtocolVersion?.(L)}catch{}l=e}async function se(e,n){n&&e.id!==void 0&&A.add(e.id),await l.send(e)}let ve=()=>{if(R===process.pid)return!0;try{return process.kill(R,0),!0}catch(e){return e.code!=="ESRCH"}};async function ke(){if(_||O)return;_=!0;let e=500;for(;;){if(O){_=!1;return}if(!ve()){o(`client pid ${R} is gone \u2014 abandoning reconnect instead of churning the daemon's sessions`),_=!1,y(0);return}try{if(await te(),b){let t=`${_e}${H}`;j.add(t),await se({...b,id:t},!0),await l.send({jsonrpc:"2.0",method:"notifications/initialized"})}if(f){let t=`__ours_proxy_rebind_${++H}__`;await se({jsonrpc:"2.0",id:t,method:"tools/call",params:{name:"choose_identity",arguments:{name:f}}},!0)}N=!0;let n=M.splice(0);for(let t of n)await l.send(t).catch(i=>o("flush failed:",String(i)));o("upstream reconnected",f?`(re-bound "${f}")`:""),w=0,_=!1;return}catch(n){o("reconnect attempt failed:",String(n)),await ce(e),e=Math.min(Math.floor(e*1.5),1e4)}}}async function y(e){if(!O){O=!0;try{await l?.close()}catch{}try{await m.close()}catch{}process.exit(e)}}process.on("SIGINT",()=>void y(0)),process.on("SIGTERM",()=>void y(0));let re=e=>{let n=e?.code;return n==="EPIPE"||n==="ECONNRESET"||n==="ERR_STREAM_DESTROYED"||n==="ERR_STREAM_WRITE_AFTER_END"};process.on("unhandledRejection",e=>{if(re(e)){S=!0,y(0);return}o("UNHANDLED REJECTION (proxy stays up):",e instanceof Error?e.stack??e.message:String(e))}),process.on("uncaughtException",e=>{if(re(e)){S=!0,y(0);return}o("UNCAUGHT EXCEPTION (proxy stays up):",e?.stack??String(e))});async function Ee(){let e=new URL(g.href);e.pathname="/state-dir";let n;try{n=await(await fetch(e,{signal:AbortSignal.timeout(3e3)})).json()}catch(t){o("compat handshake: could not read daemon /state-dir, proceeding:",String(t));return}T=oe({selfVersion:Pe,daemonVersion:typeof n?.version=="string"?n.version:null}),T&&o(T)}if((async()=>{a.ensureDaemon&&await a.ensureDaemon().catch(t=>o("ensureDaemon:",String(t))),await Ee();let e=500;for(;;)try{await te();break}catch(t){o("initial upstream connect failed, retrying:",String(t)),await ce(e),e=Math.min(Math.floor(e*1.5),1e4)}N=!0;let n=M.splice(0);for(let t=0;t<n.length;t++){let i=we();if(!i){M.unshift(...n.slice(t));break}await i.send(n[t]).catch(s=>o("flush failed:",String(s)))}o(`upstream ready \u2014 stdio \u21C4 ${g.href}`)})(),v){ge();let e=me();e&&(f=e,o("session-restore: found prior binding for this session \u2014 will self-recover",`"${e}"`))}else le&&o("session-restore: disabled via OURS_NO_AUTORESTORE \u2014 pure in-memory binding");await m.start(),o("proxy started (stdio transport up)")}function U(a){return Array.isArray(a)?a:[a]}export{Ye 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-V7OPRCZ3.js";import"./chunk-NBEWKZG4.js";import"./chunk-V64IUVSS.js";import"./chunk-37D5PCFY.js";import"./chunk-D7I2EFNP.js";import"./chunk-5UEWBTIG.js";import{b as t}from"./chunk-JAT7EOYH.js";import"./chunk-IU6MOFTJ.js";import"./chunk-ZNDBLX5J.js";import"./chunk-RNIN2NDZ.js";import"./chunk-4L37F7EA.js";import"./chunk-3CS6SGYE.js";import"./chunk-FC4ERYFN.js";import"./chunk-VXVW4KJU.js";import"./chunk-MGCRONNT.js";import"./chunk-EVP7IDZJ.js";import"./chunk-AGWCGBCT.js";import"./chunk-FYYBC5Q4.js";import"./chunk-65KGEJBX.js";import"./chunk-G2ODDJ4Z.js";import"./chunk-2AGDAI76.js";import"./chunk-6MGSS5ZO.js";import"./chunk-POTB37MR.js";import"./chunk-YRPUM6JG.js";import"./chunk-JGOJHX3P.js";import"./chunk-DIRW7I4S.js";import"./chunk-RJ36BIMK.js";import"./chunk-FNASW6T5.js";import{h as r}from"./chunk-4TASOWGY.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
|
@@ -32,6 +32,8 @@ export declare const errNoPolicyArgs: () => OursError;
|
|
|
32
32
|
export declare const errSendFileArgs: () => OursError;
|
|
33
33
|
export declare const errSendFileFilenameRequired: () => OursError;
|
|
34
34
|
export declare const errFileUnreadable: (detail: string) => OursError;
|
|
35
|
+
export declare const errSendFileUploadArgs: () => OursError;
|
|
36
|
+
export declare const errUploadNotFound: (uploadId: string) => OursError;
|
|
35
37
|
export declare const errFileTooLarge: (i: {
|
|
36
38
|
filename: string;
|
|
37
39
|
bytes: number;
|
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,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-
|
|
2
|
+
import{A,B,C,D,E,F,G,H,I,J,K,L,M,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-65KGEJBX.js";export{a as OursError,c as errBindingReassigned,t as errBoundElsewhere,d as errBoundIdentityGone,K as errDuplicateId,F as errFileTooLarge,C as errFileUnreadable,v as errIdentityClosedWithError,x as errIdentityPartiallyRemoved,I as errInvalidSelection,J as errMalformedId,f as errNameTaken,g as errNoLeaseHeaders,p as errNoLeaseToken,z as errNoPolicyArgs,H 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,G as errSaveFileFallback,A as errSendFileArgs,B as errSendFileFilenameRequired,D as errSendFileUploadArgs,m as errTempClosedWithError,e as errTempClosingBound,q as errTempClosingChoose,l as errTempOwnedElsewhereClose,u as errTempOwnedElsewhereRemove,r as errTempOwnedLive,s as errTempStale,M as errTool,L as errUnknownOrStaleId,E as errUploadNotFound};
|
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-D7I2EFNP.js";import"./chunk-POTB37MR.js";import"./chunk-YRPUM6JG.js";import"./chunk-JGOJHX3P.js";import"./chunk-DIRW7I4S.js";import"./chunk-RJ36BIMK.js";import"./chunk-FNASW6T5.js";import"./chunk-4TASOWGY.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-5UEWBTIG.js";import"../chunk-ZNDBLX5J.js";import"../chunk-RNIN2NDZ.js";import"../chunk-4L37F7EA.js";import"../chunk-3CS6SGYE.js";import"../chunk-FC4ERYFN.js";import"../chunk-VXVW4KJU.js";import"../chunk-MGCRONNT.js";import"../chunk-EVP7IDZJ.js";import"../chunk-AGWCGBCT.js";import"../chunk-FYYBC5Q4.js";import"../chunk-65KGEJBX.js";import"../chunk-G2ODDJ4Z.js";import"../chunk-2AGDAI76.js";import"../chunk-6MGSS5ZO.js";import"../chunk-POTB37MR.js";import"../chunk-YRPUM6JG.js";import"../chunk-JGOJHX3P.js";import"../chunk-DIRW7I4S.js";import"../chunk-RJ36BIMK.js";import"../chunk-FNASW6T5.js";import"../chunk-4TASOWGY.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.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-V7OPRCZ3.js";import"../chunk-NBEWKZG4.js";import"../chunk-V64IUVSS.js";import"../chunk-37D5PCFY.js";import"../chunk-D7I2EFNP.js";import"../chunk-5UEWBTIG.js";import"../chunk-JAT7EOYH.js";import"../chunk-IU6MOFTJ.js";import"../chunk-ZNDBLX5J.js";import"../chunk-RNIN2NDZ.js";import"../chunk-4L37F7EA.js";import"../chunk-3CS6SGYE.js";import"../chunk-FC4ERYFN.js";import"../chunk-VXVW4KJU.js";import"../chunk-MGCRONNT.js";import"../chunk-EVP7IDZJ.js";import"../chunk-AGWCGBCT.js";import"../chunk-FYYBC5Q4.js";import"../chunk-65KGEJBX.js";import"../chunk-G2ODDJ4Z.js";import"../chunk-2AGDAI76.js";import"../chunk-6MGSS5ZO.js";import"../chunk-POTB37MR.js";import"../chunk-YRPUM6JG.js";import"../chunk-JGOJHX3P.js";import"../chunk-DIRW7I4S.js";import"../chunk-RJ36BIMK.js";import"../chunk-FNASW6T5.js";import"../chunk-4TASOWGY.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-6MGSS5ZO.js";import"../chunk-POTB37MR.js";import"../chunk-YRPUM6JG.js";import"../chunk-JGOJHX3P.js";import"../chunk-DIRW7I4S.js";import"../chunk-RJ36BIMK.js";import"../chunk-FNASW6T5.js";import"../chunk-4TASOWGY.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-RJ36BIMK.js";import"../chunk-FNASW6T5.js";import"../chunk-4TASOWGY.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-FYYBC5Q4.js";import"../chunk-6MGSS5ZO.js";import"../chunk-POTB37MR.js";import"../chunk-YRPUM6JG.js";import"../chunk-JGOJHX3P.js";import"../chunk-DIRW7I4S.js";import"../chunk-RJ36BIMK.js";import"../chunk-FNASW6T5.js";import"../chunk-4TASOWGY.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-FNASW6T5.js";import"../chunk-4TASOWGY.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{
|
|
2
|
+
import{A as b,B as c,C as d,z as a}from"../chunk-POTB37MR.js";import"../chunk-YRPUM6JG.js";import"../chunk-JGOJHX3P.js";import"../chunk-DIRW7I4S.js";import"../chunk-RJ36BIMK.js";import"../chunk-FNASW6T5.js";import"../chunk-4TASOWGY.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 Ve}from"./chunk-OA7XXAFG.js";import{a as be,b as qe,c as we,d as ze,e as Ge,f as He}from"./chunk-IDH22QWU.js";import{a as Je}from"./chunk-5EWCIQH6.js";import{a as ae,b as ie,c as ye,d as se,e as ve,f as Fe,g as Ce,h as Pe,i as _e,j as ce}from"./chunk-ZNDBLX5J.js";import{a as Ie,b as Le,c as Ne,d as ke}from"./chunk-RNIN2NDZ.js";import{a as ue,b as Se,c as de,d as he}from"./chunk-4L37F7EA.js";import{a as Ae,b as Be,c as Me,d as Oe,e as Re}from"./chunk-3CS6SGYE.js";import"./chunk-FC4ERYFN.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-MGCRONNT.js";import{a as ge,b as je,c as De,d as Te}from"./chunk-EVP7IDZJ.js";import{a as ee,b as oe,c as re,d as pe,e as te,f as me,g as fe,h as xe,i as le,j as Ee,k as ne}from"./chunk-AGWCGBCT.js";import"./chunk-FYYBC5Q4.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,L as Z,M as $,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-65KGEJBX.js";import"./chunk-G2ODDJ4Z.js";import"./chunk-2AGDAI76.js";import"./chunk-6MGSS5ZO.js";import"./chunk-POTB37MR.js";import"./chunk-YRPUM6JG.js";import"./chunk-JGOJHX3P.js";import"./chunk-DIRW7I4S.js";import"./chunk-RJ36BIMK.js";import{u as e}from"./chunk-FNASW6T5.js";import"./chunk-4TASOWGY.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{we as DAEMON_TOKEN_FILE,qe as DEFAULT_DAEMON_PORT,be as DaemonSelectionError,e as FILE_SELECTION_CAP,Ve as OursClient,v as OursError,o as PINNED_FILE_ENVELOPE_CAP,E as VETOABLE_EVENTS,se as addContact,je as advertiseMigrate,He as assertDaemonStateDir,x as checkFileEnvelope,fe as chooseIdentity,pe as closeTemporaryIdentityOp,oe as createIdentity,te as createRootIdentity,re as createTemporaryIdentity,le as currentIdentity,he as deferFiles,Re as deferMessages,me as defineLocalIdentityFile,Ge as describeDaemonConfig,y as emitDaemonEvent,s as emitDaemonNotification,p as envelopeSkipMargin,C as errBindingReassigned,g as errBoundElsewhere,P as errBoundIdentityGone,Y as errDuplicateId,K as errFileTooLarge,G as errFileUnreadable,D as errIdentityClosedWithError,V as errIdentityPartiallyRemoved,W as errInvalidSelection,X as errMalformedId,c as errNameTaken,I as errNoLeaseHeaders,B as errNoLeaseToken,q as errNoPolicyArgs,U 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,Q as errSaveFileFallback,w as errSendFileArgs,z as errSendFileFilenameRequired,H as errSendFileUploadArgs,d as errTempClosedWithError,_ as errTempClosingBound,M as errTempClosingChoose,S as errTempOwnedElsewhereClose,j as errTempOwnedElsewhereRemove,O as errTempOwnedLive,R as errTempStale,$ as errTool,Z as errUnknownOrStaleId,J as errUploadNotFound,Je as formatVersionAdvisory,ae as generateInvite,Ie as getConversation,Se as getFiles,Oe as getMessages,Le as getReceipts,i as isDefaultHandler,ve as listContacts,xe as listIdentities,ue as listIncomingFiles,Me as listIncomingMessages,ie as listInvites,Fe as listLocalContactBook,Ne as markRead,f as maxFilePayloadBytes,m as measureFileEnvelope,t as needsEnvelopeMeasurement,l as normalizeNotificationEvent,Te as readvertiseOnUpgrade,ne as releaseLease,Pe as removeContact,Ee as removeIdentity,_e as renameContact,ee as requireBound,a as resetDaemonEventHandlers,ze as resolveDaemonConfig,r as resolveFileEnvelopeCap,ce as respondToIntroduction,ye as revokeInvite,de as saveFileFallbackNotice,Be as sendFile,Ae as sendMessage,ge as setBio,ke as setConversationPolicy,n as setDaemonEventHandler,Ce as setLocalBookPolicy,De 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-MGCRONNT.js";import"../chunk-6MGSS5ZO.js";import"../chunk-POTB37MR.js";import"../chunk-YRPUM6JG.js";import"../chunk-JGOJHX3P.js";import"../chunk-DIRW7I4S.js";import"../chunk-RJ36BIMK.js";import"../chunk-FNASW6T5.js";import"../chunk-4TASOWGY.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{
|
|
2
|
+
import{y as a}from"../chunk-POTB37MR.js";import"../chunk-YRPUM6JG.js";import"../chunk-JGOJHX3P.js";import"../chunk-DIRW7I4S.js";import"../chunk-RJ36BIMK.js";import"../chunk-FNASW6T5.js";import"../chunk-4TASOWGY.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{
|
|
2
|
+
import{H as a,I as b,J as c,K as d,L as e,M as f}from"../chunk-POTB37MR.js";import"../chunk-YRPUM6JG.js";import"../chunk-JGOJHX3P.js";import"../chunk-DIRW7I4S.js";import"../chunk-RJ36BIMK.js";import"../chunk-FNASW6T5.js";import"../chunk-4TASOWGY.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/mufl_code/7962BB01B1D3E782A1F80B083A900AEC30BAC8F8CE79282B31821802B94A39B6.muflo
CHANGED
|
Binary file
|
package/dist/notify.d.ts
CHANGED
|
@@ -7,6 +7,11 @@ export declare function setNotifyHook(fn: NotifyHook | null): void;
|
|
|
7
7
|
export declare function clearNotifyHook(fn: NotifyHook): void;
|
|
8
8
|
export declare function fireNotify(identityName: string, summary: string): void;
|
|
9
9
|
export declare const notifyHooks: WireHooks;
|
|
10
|
+
/** The named event sets `?kinds=` accepts, and the only classification of what a notification IS. */
|
|
11
|
+
export declare const NOTIFY_KIND_SETS: Readonly<Record<string, readonly string[]>>;
|
|
12
|
+
/** `null` = no filter, which is what an ABSENT parameter means. Throws the bad token. */
|
|
13
|
+
export declare function parseNotifyKinds(kindsParam: string | null): Set<string> | null;
|
|
14
|
+
export declare function notifyEventMatches(event: Record<string, unknown>, keep: Set<string> | null): boolean;
|
|
10
15
|
export declare function fireNotifyWaiters(name: string): void;
|
|
11
16
|
export declare function waitForNotify(name: string, ms: number): Promise<void>;
|
|
12
17
|
export declare function appendNotifyLog(id: Identity, event: Record<string, unknown>): void;
|
|
@@ -17,7 +22,7 @@ export declare function readNotifyRange(logPath: string, from: number, to: numbe
|
|
|
17
22
|
events: Record<string, unknown>[];
|
|
18
23
|
cursor: number;
|
|
19
24
|
};
|
|
20
|
-
export declare function serveNotifications(req: IncomingMessage, res: ServerResponse, name: string, sinceParam: string | null): Promise<void>;
|
|
25
|
+
export declare function serveNotifications(req: IncomingMessage, res: ServerResponse, name: string, sinceParam: string | null, kindsParam?: string | null): Promise<void>;
|
|
21
26
|
export declare function refreshUnread(id: Identity): void;
|
|
22
27
|
export declare function unreadSummary(): {
|
|
23
28
|
identities: Array<Record<string, unknown>>;
|
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,o,p,q}from"./chunk-POTB37MR.js";import"./chunk-YRPUM6JG.js";import"./chunk-JGOJHX3P.js";import"./chunk-DIRW7I4S.js";import"./chunk-RJ36BIMK.js";import"./chunk-FNASW6T5.js";import"./chunk-4TASOWGY.js";import"./chunk-ZHH3PWEW.js";import"./chunk-LKFYUCN7.js";import"./chunk-P55RJGZU.js";import"./chunk-XYU2DSWR.js";import"./chunk-IB2U7K6Y.js";export{e as NOTIFY_KIND_SETS,j as appendNotifyLog,l as binHexField,b as clearNotifyHook,c as fireNotify,h as fireNotifyWaiters,g as notifyEventMatches,d as notifyHooks,m as notifyLogSize,f as parseNotifyKinds,k as readE2eWireIds,n as readNotifyRange,p as refreshUnread,o as serveNotifications,a as setNotifyHook,q as unreadSummary,i 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-JGOJHX3P.js";import"../chunk-DIRW7I4S.js";import"../chunk-FNASW6T5.js";import"../chunk-4TASOWGY.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-4TASOWGY.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{
|
|
2
|
+
import{D as a,E as b,F as c,G as d}from"./chunk-POTB37MR.js";import"./chunk-YRPUM6JG.js";import"./chunk-JGOJHX3P.js";import"./chunk-DIRW7I4S.js";import"./chunk-RJ36BIMK.js";import"./chunk-FNASW6T5.js";import"./chunk-4TASOWGY.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{
|
|
2
|
+
import{r as a,s as b,t as c,u as d,v as e,w as f,x as g}from"./chunk-POTB37MR.js";import"./chunk-YRPUM6JG.js";import"./chunk-JGOJHX3P.js";import"./chunk-DIRW7I4S.js";import"./chunk-RJ36BIMK.js";import"./chunk-FNASW6T5.js";import"./chunk-4TASOWGY.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};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Readable } from 'node:stream';
|
|
2
|
+
import { type Identity } from './identity/model.js';
|
|
3
|
+
/** Per-identity staging area for bytes a client has uploaded but not yet sent. */
|
|
4
|
+
export declare const uploadsDirFor: (id: Identity) => string;
|
|
5
|
+
/**
|
|
6
|
+
* How long an unsent staged upload survives. Generous, because the legitimate
|
|
7
|
+
* window is "the agent uploads, then asks the user who to send it to" and a
|
|
8
|
+
* human is in that loop. Configurable for tests.
|
|
9
|
+
*/
|
|
10
|
+
export declare const UPLOAD_TTL_MS: number;
|
|
11
|
+
/** Metadata recorded beside the staged bytes. Content-free: no payload, ever. */
|
|
12
|
+
export interface StagedUpload {
|
|
13
|
+
upload_id: string;
|
|
14
|
+
filename: string;
|
|
15
|
+
mime: string;
|
|
16
|
+
size: number;
|
|
17
|
+
sha256: string;
|
|
18
|
+
at: string;
|
|
19
|
+
}
|
|
20
|
+
export declare const isUploadId: (s: string) => boolean;
|
|
21
|
+
/** Metadata only — the bytes are named by the upload id. */
|
|
22
|
+
export declare function sanitizeUploadFilename(raw: string): string;
|
|
23
|
+
export declare class UploadRefused extends Error {
|
|
24
|
+
readonly status: number;
|
|
25
|
+
constructor(status: number, message: string);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Stream `body` into the bound identity's staging area.
|
|
29
|
+
*
|
|
30
|
+
* Content-Length is a CLAIM: it gates the cap before a byte is stored, and is
|
|
31
|
+
* re-checked while streaming. The cap here is the payload against the envelope
|
|
32
|
+
* cap — coarse on purpose, since a payload at or over it cannot fit whatever the
|
|
33
|
+
* metadata is. The measured refusal stays in sendFile.
|
|
34
|
+
*/
|
|
35
|
+
export declare function stageUpload(id: Identity, body: Readable, meta: {
|
|
36
|
+
filename: string;
|
|
37
|
+
mime: string;
|
|
38
|
+
declaredBytes: number | null;
|
|
39
|
+
cap: number;
|
|
40
|
+
}): Promise<StagedUpload>;
|
|
41
|
+
/** Read and REMOVE — consume-once holds by construction, not by convention. */
|
|
42
|
+
export declare function consumeStagedUpload(id: Identity, uploadId: string): {
|
|
43
|
+
meta: StagedUpload;
|
|
44
|
+
buf: Buffer;
|
|
45
|
+
} | null;
|
|
46
|
+
/** Rides the daemon's existing 60s sweep rather than adding a second clock. */
|
|
47
|
+
export declare function sweepStaleUploads(): number;
|
package/dist/uploads.js
ADDED
|
@@ -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,h}from"./chunk-FC4ERYFN.js";import"./chunk-FNASW6T5.js";import"./chunk-4TASOWGY.js";import"./chunk-ZHH3PWEW.js";import"./chunk-IB2U7K6Y.js";export{b as UPLOAD_TTL_MS,e as UploadRefused,g as consumeStagedUpload,c as isUploadId,d as sanitizeUploadFilename,f as stageUpload,h as sweepStaleUploads,a as uploadsDirFor};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ours.network/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
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-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/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"
|
|
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/notify-kinds.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/file-upload.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/connector-exit-on-stdin-eof.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-BL54LJNA.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
var t=class extends Error{constructor(o,r,i){super(r);this.code=o;this.details=i;this.name="OursError"}},s=()=>new t("NOT_BOUND","No identity bound to this session. Call choose_identity (or create_identity) first."),a=()=>new t("BINDING_REASSIGNED","Your identity binding was reassigned to another session. Call choose_identity again to continue."),d=e=>new t("BOUND_IDENTITY_GONE",`The bound identity "${e}" no longer exists. Choose another with choose_identity.`),l=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,n)=>new t("NAME_TAKEN",`${e} failed: an identity named "${n}" 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`)."),E=()=>new t("RANDOM_NAME_EXHAUSTED","create_temporary_identity failed: could not pick a free random name after 5 attempts \u2014 retry."),y=e=>new t("ROOT_EXISTS",`create_root_identity failed: a root identity already exists ("${e}") \u2014 one root per host. Nothing to do.`),p=()=>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.`),O=(e,n)=>new t("TEMP_OWNED_ELSEWHERE",`close_temporary_identity failed: "${e}" is owned by another LIVE session (owner pid ${n}) \u2014 one session cannot delete another's temporary identity.`),h=(e,n,o)=>new t("DELETE_PARTIAL",`Temporary identity "${e}" closed with an error: ${n}. ${o}`),T=e=>new t("PATH_NOT_ABSOLUTE",`define_local_identity_file failed: path must be absolute (got "${e}").`),m=e=>new t("NO_SUCH_IDENTITY",`choose_identity failed: no identity named "${e}". Create it with create_identity.`),u=()=>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`)."),w=e=>new t("TEMP_CLOSING",`choose_identity failed: temporary identity "${e}" is closing \u2014 its state is being deleted.`),A=(e,n)=>new t("TEMP_OWNED_ELSEWHERE",`choose_identity failed: "${e}" is a TEMPORARY identity owned by another live session (owner pid ${n}). Ownership is exclusive and cannot be overridden \u2014 not even with force. Create your own with create_temporary_identity.`),I=(e,n)=>new t("TEMP_STALE",`choose_identity failed: temporary identity "${e}" is STALE \u2014 its owning session (pid ${n}) 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.`),L=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.`),g=(e,n)=>new t("TEMP_OWNED_ELSEWHERE",`remove_identity failed: "${e}" is a TEMPORARY identity owned by another LIVE session (owner pid ${n}) \u2014 one session cannot delete another's temporary identity.`),f=(e,n,o)=>new t("DELETE_PARTIAL",`Temporary identity "${e}" closed with an error: ${n}.${o}`),R=(e,n)=>new t("ROOT_HAS_ROLES",`remove_identity failed: "${e}" is the root identity and still has ${n.length} role(s): ${n.join(", ")}. Remove the roles first.`),D=(e,n)=>new t("DELETE_PARTIAL",`Identity "${e}" removed from memory, but ${n}`),S=()=>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."),x=()=>new t("NO_POLICY_ARGS","set_local_book_policy: pass expose and/or auto_accept."),b=()=>new t("SEND_ARGS","send_file: provide exactly one of `path` or `data_base64`."),$=()=>new t("SEND_ARGS","send_file: `filename` is required with `data_base64`."),C=e=>new t("FILE_UNREADABLE",`send_file: cannot read file: ${e}`),M=e=>new t("FILE_TOO_LARGE",`send_file: "${e.filename}" is ${e.bytes} bytes. This send's envelope would serialize to ${e.envelopeBytes} bytes, over the transport's ${e.limit}-byte budget \u2014 the largest payload it can carry with this filename, MIME and reply reference is ${e.maxPayloadBytes} bytes. Nothing was sent.`,e),v=(e,n)=>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`)."+(n?"":` (Also note: no file with wire_id ${e} is currently on disk for this identity \u2014 run get_files first.)`)),P=()=>new t("NO_ROOT","No root identity exists on this host \u2014 create one with create_root_identity first."),B=e=>new t("INVALID_SELECTION",`get_files failed: wire_ids must contain 1-${e} items.`),U=()=>new t("MALFORMED_ID","get_files failed: every selected wire_id must be exactly 64 hexadecimal characters."),F=()=>new t("DUPLICATE_ID","get_files failed: wire_ids must not contain duplicates."),H=()=>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."),G=(e,n,o="TX_FAILED")=>new t(o,`${e} failed: ${n}`);export{t as a,s as b,a as c,d,l as e,_ as f,c as g,E as h,y as i,p as j,N as k,O as l,h as m,T as n,m as o,u as p,w as q,A as r,I as s,L as t,g as u,f as v,R as w,D as x,S as y,x as z,b as A,$ as B,C,M as D,v as E,P as F,B as G,U as H,F as I,H as J,G as K};
|
package/dist/chunk-FUQOCQSL.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as E,b as k,d as A}from"./chunk-ELU5JE5X.js";import{E as T,F as I,G as _,J as R,S as x,x as y}from"./chunk-H343HSTY.js";import{a as S}from"./chunk-6DGPJGV6.js";import{a as l,d as u,e as d,g as w}from"./chunk-LYS6K3N2.js";import{a as $,c as m,q as v}from"./chunk-OJD7HN2X.js";import{c as s,i as r}from"./chunk-V45U6UR6.js";import{join as b}from"node:path";import*as i from"node:fs";function D(e){try{$.remove_packet(e.cid)}catch(t){r(`remove_packet(${e.cid}) failed:`,String(t))}m.delete(e.name);try{x(e)}catch(t){r(`failed to unpublish "${e.name}" from the contact book:`,String(t))}l.has(e.name)&&(l.delete(e.name),w()),e.name===k&&(E(null),A());try{i.rmSync(e.dir,{recursive:!0,force:!0}),y.delete(e.name)}catch(t){return`deleting ${e.dir} failed: ${String(t)}`}return null}function F(e,t){let n=e.temp;return n?(n.closing||(n.closing=(async()=>{r(`[${e.name}] closing temporary identity (${t})`);let o=[];try{o=T(a=>S(_(e,"::a2a_messaging::list_contacts",a)))}catch(a){r(`[${e.name}] contact snapshot failed during close (continuing with local cleanup):`,String(a))}let p=0,c=0;u.add(e.name);try{for(let a of o)try{await I(async C=>{let h=(await R(e,"::a2a_messaging::remove_contact",{contact:a.container_id},C)).Reduce("notified");return h.IsNil()?!1:h.GetBoolean()})?p++:c++}catch(g){c++,r(`[${e.name}] remove-me to ${a.container_id} failed (continuing):`,String(g))}}finally{u.delete(e.name)}let f=D(e);return f?r(`[${e.name}] temporary identity close: LOCAL DELETE FAILED \u2014 ${f}`):r(`[${e.name}] temporary identity closed: ${o.length} contact(s), ${p} remove-me notice(s) queued, ${c} not sent (delivery unverified by design)`),{attempted:o.length,notified:p,failed:c,deleteError:f}})()),n.closing):Promise.reject(new Error(`identity "${e.name}" is not temporary`))}function H(){for(let e of[...m.values()]){let t=e.temp;if(!t||t.closing||d(t.owner.pid))continue;let n=l.get(e.name);n&&d(n.pid)||F(e,`stale lease \u2014 owner pid ${t.owner.pid} is dead`).catch(o=>r(`[${e.name}] stale-temp reclaim failed:`,String(o)))}}function J(){if(i.existsSync(s))for(let e of i.readdirSync(s,{withFileTypes:!0})){if(!e.isDirectory()||m.has(e.name))continue;let t=b(s,e.name),n=v(t);if(!(!n||d(n.owner.pid)))try{i.rmSync(t,{recursive:!0,force:!0}),y.delete(e.name),r(`[${e.name}] removed orphaned temporary-identity dir (owner pid ${n.owner.pid} dead, no live packet)`)}catch(o){r(`[${e.name}] failed to remove orphaned temporary-identity dir:`,String(o))}}}export{D as a,F as b,H as c,J as d};
|
package/dist/chunk-H343HSTY.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as H}from"./chunk-YRPUM6JG.js";import{c as me}from"./chunk-6DGPJGV6.js";import{d as de}from"./chunk-LYS6K3N2.js";import{a as L,c as x,d as k,e as J,f as se,g as oe,h as G,i as D,j as I,k as B,l as M,p as ae,w as ce}from"./chunk-OJD7HN2X.js";import{c as V,i as l,o as j,p as ne}from"./chunk-V45U6UR6.js";import{a as ue}from"./chunk-LKFYUCN7.js";import{c as le,f as fe,g as pe}from"./chunk-XYU2DSWR.js";import{join as ke}from"node:path";import*as _ from"node:fs";import{AdaptObjectLifetime as $e}from"@adapt-toolkit/sdk/common";import{object_to_adapt_value as be}from"@adapt-toolkit/sdk/wrapper";import*as y from"node:fs";import{randomBytes as ze}from"node:crypto";import*as $ from"node:fs";import{randomBytes as Ve}from"node:crypto";import{PacketWrapperConfigurator as Te}from"@adapt-toolkit/sdk/wrappers";import{AdaptObjectLifetime as xe}from"@adapt-toolkit/sdk/common";function qe(e){let t=[],o=e.Reduce("degraded");if(o.IsNil())return t;for(let n=0;;n++){let a=o.Reduce(n);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 Ie(e){let t=[],o=e.Reduce("queues");if(o.IsNil())return t;for(let n=0;;n++){let a=o.Reduce(n);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 Y(e,t){try{let o=await h(async n=>{let a=await v(e,"::a2a_messaging::flush_deferred",{contact:t},n);return Number(a.Reduce("flushed").Visualize())});o>0&&l(`[${e.name}] flushed ${o} deferred message(s) to ${t.slice(0,12)}\u2026`)}catch(o){l(`[${e.name}] deferred flush to ${t.slice(0,12)}\u2026 failed:`,String(o))}}async function ge(e){try{let t=await h(async n=>{let a=await v(e,"::a2a_messaging::restore_degraded_contacts",{},n);return Number(a.Reduce("requested").Visualize())});t>0&&l(`[${e.name}] contact restore requested for ${t} degraded contact(s)`);let o=S(n=>Ie(R(e,"::a2a_messaging::list_deferred_queues",n)));for(let n of o)n.degraded||await Y(e,n.cid)}catch(t){l(`[${e.name}] contact-restore sweep failed:`,String(t))}}async function Ne(e){try{let t=await h(async o=>{let n=await v(e,"::a2a_messaging::reconcile_advertise",{},o),a=u=>n.Reduce(u).IsNil()?0:Number(n.Reduce(u).Visualize());return{changed:/true/i.test(n.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 K=new Set;function q(e){if(!K.has(e.name)){K.add(e.name);for(let t of[2e3,15e3])setTimeout(()=>{t===15e3&&K.delete(e.name);let o=x.get(e.name);o&&Ne(o)},t)}}async function Ce(e){try{let t=await h(async o=>{let n=await v(e,"::a2a_messaging::readvertise_e2e_recovery",{},o);return Number(n.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 h(async t=>{await v(e,"::a2a_messaging::sweep_e2e_migrations",{},t)})}catch(t){l(`[${e.name}] e2e migration sweep failed:`,String(t))}try{let t=await h(async o=>{let n=await v(e,"::a2a_messaging::redrive_unacked_sweep",{},o),a=u=>n.Reduce(u).IsNil()?0:Number(n.Reduce(u).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 ye(e,t){e.pw.on_return_data=o=>{let n=new xe;o.Attach(n);try{let a=o.Reduce("kind").Visualize();if(a==="save_state"){z(e);return}if(a==="notify_agent"){let i=o.Reduce("payload"),f=i.Reduce("event").Visualize();if(f==="message_received"){let s=i.Reduce("sender_name").Visualize(),r=i.Reduce("sender_id"),c=r.IsNil()?"":r.Visualize(),d=i.Reduce("msg_id").Visualize(),p=i.Reduce("wire_id"),m=p.IsNil()?"":p.Visualize(),w=i.Reduce("date").Visualize();g(e,{event:"message_received",from:s,sender_name:s,sender_id:c,msg_id:d,wire_id:m,date:w}),P(e),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] new message from ${s} (#${d})`))}else if(f==="receipt_received"){let s=i.Reduce("sender_id"),r=s.IsNil()?"":String(s.Visualize()),c=i.Reduce("kind"),d=c.IsNil()?"":String(c.Visualize()),p=[],m=i.Reduce("wire_ids");if(!m.IsNil())for(let O=0;;O++){let re=m.Reduce(O);if(re.IsNil())break;p.push(String(re.Visualize()))}let w=i.Reduce("date"),b=w.IsNil()?new Date().toISOString():String(w.Visualize());g(e,{event:"receipt_received",sender_id:r,kind:d,wire_ids:p,date:b})}else if(f==="file_received"){let s=i.Reduce("sender_name").Visualize(),r=i.Reduce("sender_id").Visualize(),c=i.Reduce("file_id").Visualize(),d=i.Reduce("wire_id").Visualize(),p=i.Reduce("filename").Visualize(),m=i.Reduce("mime").Visualize(),w=i.Reduce("bytes").Visualize(),b=i.Reduce("date").Visualize();g(e,{event:"file_received",from:s,sender_id:r,file_id:c,wire_id:d,filename:p,mime:m,bytes:w,date:b}),P(e),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] new file ${p} (${w} B) from ${s} (sender_id ${r}, file_id ${c}, wire_id ${d})`))}else if(f==="contact_accepted"){let s=i.Reduce("name").Visualize(),r=i.Reduce("container_id").Visualize();q(e),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] contact "${s}" (${r}) accepted your invite.`))}else if(f==="local_contact_added"){let s=i.Reduce("name").Visualize(),r=i.Reduce("container_id").Visualize();q(e),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] local contact "${s}" (${r}) connected via the contact book.`))}else if(f==="contact_name_collision"){let s=i.Reduce("message").Visualize(),r=i.Reduce("desired").Visualize(),c=i.Reduce("assigned").Visualize(),d=i.Reduce("existing_container_id").Visualize(),p=i.Reduce("container_id").Visualize();g(e,{event:"contact_name_collision",desired:r,assigned:c,existing_container_id:d,container_id:p}),l(`[${e.name}] CONTACT NAME COLLISION \u2014 ${s}`),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] \u26A0 ${s}`))}else if(f==="sibling_contact_added"){let s=i.Reduce("name").Visualize(),r=i.Reduce("container_id").Visualize();g(e,{event:"sibling_contact_added",from:s}),q(e),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] sibling "${s}" (${r}) connected (intra-root auto-accept).`))}else if(f==="local_contact_request"){let s=i.Reduce("name").Visualize(),r=i.Reduce("container_id").Visualize();g(e,{event:"local_contact_request",from:s}),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] pending local introduction from "${s}" (${r}) \u2014 approve or reject with respond_to_introduction.`))}else if(f==="pending_message"){let s=i.Reduce("sender_name").Visualize(),r=i.Reduce("queued").Visualize();g(e,{event:"pending_message",from:s,queued:r}),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] "${s}" queued a message awaiting introduction approval (${r} 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 s=i.Reduce("name").Visualize(),r=i.Reduce("container_id").Visualize();g(e,{event:"contact_restored",from:s}),l(`[${e.name}] contact "${s}" restored (re-keyed)`),process.nextTick(()=>void Y(e,String(r)))}else if(f==="migration_active"){let s=i.Reduce("cid").Visualize(),r=i.Reduce("role").Visualize(),c=T(i,"epoch"),d=T(i,"session_id");g(e,{event:"migration_active",cid:String(s),role:String(r),...c?{epoch:c}:{},...d?{session_id:d}:{}}),l(`[migration] active cid=${s} role=${r}${c?` epoch=${c}`:""}${d?` session_id=${d}`:""}`)}else if(f==="e2e_app_send"){let s=i.Reduce("cid").Visualize(),r=T(i,"session_id"),c=i.Reduce("olm_type").Visualize(),d=i.Reduce("wire_id").Visualize(),p=i.Reduce("retained").IsNil()?void 0:i.Reduce("retained").GetBoolean(),m=[],w=i.Reduce("evicted");if(!w.IsNil())for(let b=0;;b++){let O=w.Reduce(b);if(O.IsNil())break;m.push(String(O.Visualize()))}g(e,{event:"e2e_app_send",cid:String(s),session_id:r,olm_type:String(c),wire_id:String(d),...p===!1?{retained:!1}:{},...m.length?{evicted:m}:{}}),l(`[${e.name}] [e2e-app] send cid=${s} session_id=${r} olm_type=${c} wire_id=${d}${p===!1?" retained=false":""}${m.length?` evicted=${m.join(",")}`:""}`),m.length&&process.nextTick(()=>t.onNotify(e.name,`[${e.name}] redrive window overflow: ${m.length} older unacked send(s) lost their auto-resend guarantee (${m.join(", ")})`))}else if(f==="dedup_degraded"){let s=i.Reduce("cid").Visualize(),r=i.Reduce("dropped_wire_id").Visualize();g(e,{event:"dedup_degraded",cid:String(s),dropped_wire_id:String(r)}),l(`[${e.name}] [e2e-app] DEDUP DEGRADED cid=${s} dropped_wire_id=${r} (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(s).slice(0,12)}\u2026 \u2014 one oldest entry dropped (guarantee loss surfaced)`))}else if(f==="e2e_delivery_expired"){let s=i.Reduce("cid").Visualize(),r=[],c=i.Reduce("wire_ids");if(!c.IsNil())for(let d=0;;d++){let p=c.Reduce(d);if(p.IsNil())break;r.push(String(p.Visualize()))}g(e,{event:"e2e_delivery_expired",cid:String(s),wire_ids:r}),l(`[${e.name}] [e2e-app] delivery EXPIRED (2-day TTL, receipt never arrived) cid=${s} wire_ids=${r.join(",")}`),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] ${r.length} message(s)/file(s) to ${String(s).slice(0,12)}\u2026 expired undelivered (no receipt within 2 days)`))}else if(f==="e2e_app_recv"){let s=i.Reduce("cid").Visualize(),r=T(i,"session_id"),c=i.Reduce("ok").GetBoolean(),d=i.Reduce("wire_id").Visualize(),p=i.Reduce("code").IsNil()?void 0:String(i.Reduce("code").Visualize()),m=!i.Reduce("duplicate").IsNil(),w=!i.Reduce("file").IsNil();g(e,{event:"e2e_app_recv",cid:String(s),session_id:r,ok:c,wire_id:String(d),...p?{code:p}:{},...m?{duplicate:!0}:{},...w?{file:!0}:{}}),l(`[${e.name}] [e2e-app] recv cid=${s} session_id=${r} ok=${c} wire_id=${d}${p?` code=${p}`:""}${m?" duplicate=true":""}${w?" file=true":""}`)}else if(f==="e2e_rekey"){let s=i.Reduce("cid").Visualize(),r=i.Reduce("role").Visualize(),c=T(i,"session_id"),d=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()),m=i.Reduce("rejected").IsNil()?void 0:String(i.Reduce("rejected").Visualize());g(e,{event:"e2e_rekey",cid:String(s),role:String(r),...c?{session_id:c}:{},...d?{attempts:d}:{},...p?{peer_supports:p}:{},...m?{rejected:m}:{}}),l(`[${e.name}] [e2e-rekey] cid=${s} role=${r}${c?` session_id=${c}`:""}${d?` attempts=${d}`:""}${p?` peer_supports=${p}`:""}${m?` rejected=${m}`:""}`)}else if(f==="migration_deferred_flush"){let s=i.Reduce("cid").Visualize(),r=i.Reduce("wire_id").Visualize();g(e,{event:"migration_deferred_flush",cid:String(s),wire_id:String(r)}),l(`[migration] flush-notify cid=${s} wire_id=${r} (deferred\u2192e2e; core delivers)`)}else if(f==="migration_stalled"){let s=i.Reduce("cid").Visualize(),r=i.Reduce("phase").Visualize(),c=i.Reduce("attempts").Visualize();g(e,{event:"migration_stalled",cid:String(s),phase:String(r),attempts:String(c)}),l(`[migration] stalled-notify cid=${s} phase=${r} attempts=${c} (core re-drives via sweep)`)}else if(f==="downgrade_refused"){let s=i.Reduce("cid").Visualize(),r=i.Reduce("wire_id"),c=r.IsNil()?"":String(r.Visualize());g(e,{event:"downgrade_refused",cid:String(s),...c?{wire_id:c}:{}}),l(`[e2e-route] downgrade-dropped cid=${s}${c?` wire_id=${c}`:""} (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 s=String(i.Reduce("cid").Visualize()),r=de.has(e.name);g(e,{event:"contact_removed",cid:s,by:r?"local":"peer"}),r||(l(`[${e.name}] contact ${s} removed you (authenticated peer removal notice) \u2014 dropped from contacts`),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] contact ${s.slice(0,12)}\u2026 removed you as a contact (the removal was applied locally too).`)))}else if(f==="monitoring_disabled"){let s=String(i.Reduce("cid").Visualize()),r=i.Reduce("cause"),c=r.IsNil()?"":String(r.Visualize());g(e,{event:"monitoring_disabled",cid:s,...c?{cause:c}:{}}),l(`[${e.name}] monitoring disabled (cid=${s}${c?` cause=${c}`:""})`),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] the monitoring/control-plane binding was disabled${c==="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`):g(e,{event:f});return}let u=e.pending.shift();if(!u)return;clearTimeout(u.timer),u.resolve(o.Reduce("payload").Detach())}finally{n.Finalize()}},e.pw.on_transaction_failure=o=>{let n=e.pending.shift();n?(clearTimeout(n.timer),n.reject(new Error(o))):(l(`[${e.name}] inbound transaction rejected:`,o),g(e,{event:"inbound_error",message:o}),process.nextTick(()=>t.onNotify(e.name,`[${e.name}] inbound transaction rejected: ${o}`)))}}import{join as Q}from"node:path";import*as N from"node:fs";var E=()=>Q(V,j),Z=()=>Q(E(),"registrar.key"),X=()=>Q(E(),"book.json");function _e(){try{let e=JSON.parse(N.readFileSync(X(),"utf8"));return e&&typeof e.entries=="object"?e.entries:{}}catch{return{}}}function we(e){N.mkdirSync(E(),{recursive:!0});let t=`${X()}.tmp`;N.writeFileSync(t,JSON.stringify({v:1,entries:e},null,2),{mode:384}),N.renameSync(t,X())}function ee(e){return S(t=>Buffer.from(R(e,"::actor::export_address_document",t).GetBinary()))}function C(e){return S(t=>Buffer.from(R(e,"::actor::export_signing_secret",t).Serialize()).toString("hex"))}async function he(e){if(!k)throw new Error("registrar is not available");let t=ee(e),o=await h(async a=>{let u=await v(k,"::actor::sign_book_entry",{name:e.name,ad:k.pw.packet.NewBinaryFromBuffer(t).Attach(a)},a);return Buffer.from(u.Reduce("sig").GetBinary()).toString("base64url")}),n=_e();n[e.name]={v:1,name:e.name,container_id:e.cid,address_document:t.toString("base64url"),published_at:new Date().toISOString(),registrar_sig:o},we(n),l(`[${e.name}] published to the local contact book`)}function rt(e){let t=_e(),o=Object.entries(t).find(([,n])=>n.container_id===e.cid);o&&(delete t[o[0]],we(t),l(`[${e.name}] removed from the local contact book (entry "${o[0]}")`))}async function ve(e){if(!J)throw new Error("registrar is not available");await h(async t=>{await v(e,"::actor::pin_registrar",{registrar_ad:e.pw.packet.NewBinaryFromBuffer(J).Attach(t)},t)})}function U(e,t,o,n=!0,a,u=!1){let i=new Te;i.deferred_exposure=u;let f=["--unit_hash",H.hash,"--seed_phrase",t,"--unit_dir_path",H.dir];return a&&f.push("--init_trn_argument",JSON.stringify(a)),i.process_arguments(f),new Promise((s,r)=>{let c=setTimeout(()=>r(new Error(`packet creation for "${e}" timed out`)),3e4);L.packet_manager.create_packet(i,d=>{clearTimeout(c);let p={name:e,cid:S(m=>d.packet.GetContainerID().Attach(m).Visualize()),pw:d,dir:o,pending:[],lock:Promise.resolve()};ye(p,Se),n&&x.set(e,p),l(`[${e}] packet created \u2014 container id ${p.cid}`),s(p)},H.contents)})}var A=new Set(ce());A.size>0&&l(`reserved ${A.size} persisted identity name(s) at module load: ${[...A].join(", ")}`);async function yt(e,t={exposeLocal:!0,localAutoAccept:!0}){if(A.has(e)||x.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 o=G(e);$.mkdirSync(o,{recursive:!0,mode:448});let n;t.temp&&(n={owner:{tokenHash:t.temp.tokenHash,pid:t.temp.pid},createdAt:Date.now()},ae(o,n));let a=Ve(24).toString("hex"),u=await U(e,a,o);return n&&(u.temp=n),$.writeFileSync(D(o),C(u),{mode:384}),await h(async i=>{await v(u,"::a2a_messaging::set_my_name",{name:e},i)}),await ve(u),t.localAutoAccept||await h(async i=>{await v(u,"::actor::set_local_policy",{auto_accept:!1},i)}),t.exposeLocal&&await he(u),z(u),u}catch(o){throw A.delete(e),o}}async function _t(e){let t=G(e),o=$.readFileSync(D(t),"utf8").trim(),n=await U(e,"",t,!1,o,!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(s=>setTimeout(s,a)));let u=s=>/timed out waiting for the transaction result/.test(String(s)),i=(s,r,c)=>{l(`[${e}] ${s} ${r} \u2014 identity left UNEXPOSED and UNTRACKED (fail-closed)`);try{g(n,{event:"restore_fail_closed",step:s,error:String(c).slice(0,300)})}catch{}x.delete(e);try{L.remove_packet(n.cid)}catch(d){l(`[${e}] quarantined-packet teardown failed:`,String(d))}throw new Error(`identity "${e}": ${s} failed during restore (${r}) \u2014 left unexposed (fail-closed)`)},f=(s,r)=>i(s,"outcome UNKNOWN (timeout): the transaction may still execute and exposure would race it",r);if(Re(t)){let s=!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 r=$.readFileSync(I(t));await h(async c=>{let d=n.pw.packet.ParseValue(new Uint8Array(r)).Attach(c),p=Number(process.env.OURS_IMPORT_TIMEOUT_MS||"")||void 0;await v(n,"::actor::import_state",d,c,p)}),s=!0,l(`[${e}] state import completed (positively observed)`)}catch(r){u(r)&&f("import_state",r),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(r)),g(n,{event:"state_import_failed",error:String(r).slice(0,300)});try{let c=`${I(t)}.failed-${Date.now()}`;$.renameSync(I(t),c),$.chmodSync(c,384),l(`[${e}] unreadable state blob preserved as state_data.bin.failed-*`)}catch{}}if(s){try{let d=await h(async p=>{let m=await v(n,"::a2a_messaging::commit_e2e_restore",{},p),w=m.Reduce("status").Visualize(),b=m.Reduce("sessions").IsNil()?"0":m.Reduce("sessions").Visualize();return{status:String(w),sessions:String(b)}});l(`[${e}] e2e restore commit: status=${d.status} sessions=${d.sessions}`)}catch(d){u(d)&&f("commit_e2e_restore",d),l(`[${e}] E2E RESTORE REJECTED \u2014 staged session blob failed pickle_key validation; discarding it, fresh account + self-heal fallback take over: ${String(d).slice(0,260)}`),g(n,{event:"e2e_restore_rejected",origin:"restore",error:String(d).slice(0,300)});try{await h(async p=>{await v(n,"::a2a_messaging::reject_e2e_restore",{},p)})}catch(p){u(p)&&f("reject_e2e_restore",p),l(`[${e}] reject_e2e_restore failed (staging is transient; continuing):`,String(p))}}try{n.pw.refresh_identity_proof_document(),l(`[${e}] transport IPD refreshed from post-import state`)}catch(d){i("ipd_refresh","FAILED (IPD would advertise a stale bundle)",d)}let r=!1,c="";try{if(process.env.OURS_TEST_FORCE_IPD_INCOHERENT==="1")throw new Error("forced incoherent (OURS_TEST_FORCE_IPD_INCOHERENT)");let d=S(w=>String(R(n,"::a2a_messaging::e2e_self_fp",w).Reduce("ik").Visualize())),p=n.pw.identity_proof_document.Visualize(),m=d.replace(/^0x/i,"");r=m.length>=32&&p.toLowerCase().includes(m.toLowerCase()),c=d.slice(0,18),g(n,{event:"ipd_coherence",ik:d,coherent:r})}catch(d){i("ipd_coherence","probe FAILED (coherence unprovable)",d)}l(`[${e}] IPD/e2e coherence: account_ik=${c}\u2026 ipd_advertises_it=${r}`),r||i("ipd_coherence","IPD does NOT advertise the live account ik",new Error("incoherent transport IPD"))}}return L.expose_packet(n.cid),x.set(e,n),l(`[${e}] EXPOSED (routing + broker registration) \u2014 import phase complete`),await ge(n),P(n),n}async function It(){y.mkdirSync(E(),{recursive:!0});let e;try{e=y.readFileSync(Z(),"utf8").trim()}catch{}let t=ze(24).toString("hex");se(await U(j,t,E(),!1,e)),e||y.writeFileSync(Z(),C(k),{mode:384}),oe(ee(k)),l(`contact-book registrar ready (${k.cid})`)}function Re(e){try{return y.existsSync(I(e))&&y.statSync(I(e)).size>0}catch{return!1}}function Ee(e){let t=S(u=>Buffer.from(R(e,"::actor::export_state",u).Serialize()));y.mkdirSync(e.dir,{recursive:!0,mode:448});let o=I(e.dir),n=`${o}.tmp`,a;try{a=y.openSync(n,"w",384),y.fchmodSync(a,384),y.writeFileSync(a,t),y.fsyncSync(a),y.closeSync(a),a=void 0,y.renameSync(n,o),y.chmodSync(o,384);try{y.chmodSync(D(e.dir),384)}catch{}let u=y.openSync(e.dir,"r");try{y.fsyncSync(u)}finally{y.closeSync(u)}}catch(u){if(a!==void 0)try{y.closeSync(a)}catch{}try{y.rmSync(n,{force:!0})}catch{}throw u}}function z(e){try{Ee(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(()=>te(e.name,`[${e.name}] PERSIST FAILED \u2014 messaging quarantined until the state file is writable again`)),t}}function S(e){let t=new $e;try{return e(t)}finally{t.Finalize()}}async function h(e){let t=new $e;try{return await e(t)}finally{t.Finalize()}}function R(e,t,o,n){let a=be({name:t,targ:n}),u=e.pw.packet.ExecuteTransaction(a);return a.Destroy(),o?u.Attach(o):u}async function Ae(e,t){let o=e.lock,n;e.lock=new Promise(a=>n=a),await o;try{return await t()}finally{n()}}function Oe(e,t,o=25e3){return new Promise((n,a)=>{let u=setTimeout(()=>{let i=e.pending.findIndex(f=>f.timer===u);i>=0&&e.pending.splice(i,1),a(new Error("timed out waiting for the transaction result"))},o);e.pending.push({resolve:n,reject:a,timer:u}),e.pw.add_client_message(t)})}function v(e,t,o,n,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 u=be({name:t,targ:o});return Ae(e,()=>Oe(e,u,a)).then(i=>{if(u.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 n?i.Attach(n):i},i=>{try{u.Destroy()}catch{}throw i})}var F=null;function Lt(e){F?.uninstall(),F=e===null?null:{hook:e,uninstall:le("notification",e)}}function Bt(e){F?.hook===e&&(F.uninstall(),F=null)}function te(e,t){pe(e,t)}var Se={onNotify:(e,t)=>te(e,t)},W=new Map;function De(e){let t=W.get(e);if(!(!t||t.size===0))for(let o of[...t])try{o()}catch{}}function Pe(e,t){return new Promise(o=>{let n=W.get(e);n||(n=new Set,W.set(e,n));let a=!1,u=()=>{a||(a=!0,n.delete(i),n.size===0&&W.delete(e),clearTimeout(f),o())},i=u,f=setTimeout(u,t);n.add(i)})}function g(e,t){try{_.mkdirSync(e.dir,{recursive:!0,mode:448}),_.appendFileSync(B(e.dir),JSON.stringify(t)+`
|
|
3
|
-
`)}catch(o){l(`[${e.name}] failed to append notifications.log:`,String(o))}De(e.name),fe(e,t)}function Mt(e){let t=B(e.dir),o="";try{o=_.readFileSync(t,"utf8")}catch{return new Set}let n=[];for(let a of o.split(`
|
|
4
|
-
`))if(a.trim())try{n.push(JSON.parse(a))}catch{}return ue(n)}function T(e,t){let o=e.Reduce(t);return o.IsNil()?"":Buffer.from(o.GetBinary()).toString("hex")}var Fe=Number(process.env.OURS_NOTIFY_LONGPOLL_MS)>0?Number(process.env.OURS_NOTIFY_LONGPOLL_MS):25e3,je=250;function ie(e){try{return _.statSync(e).size}catch{return 0}}function Le(e,t,o){if(o<=t)return{events:[],cursor:t};let n=Buffer.alloc(o-t),a=0;try{let s=_.openSync(e,"r");try{a=_.readSync(s,n,0,n.length,t)}finally{_.closeSync(s)}}catch{return{events:[],cursor:t}}let u=n.subarray(0,a),i=u.lastIndexOf(10);if(i===-1)return{events:[],cursor:t};let f=[];for(let s of u.subarray(0,i+1).toString("utf8").split(`
|
|
5
|
-
`))if(s.trim())try{f.push(JSON.parse(s))}catch{}return{events:f,cursor:t+i+1}}async function Ht(e,t,o,n){let a=B(ke(V,o)),u=(r,c)=>{t.writableEnded||(t.writeHead(200,{"Content-Type":"application/json"}),t.end(JSON.stringify({cursor:r,events:c})))};if(n===null||n==="tip"){u(ie(a),[]);return}let i=parseInt(n,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 s=Date.now()+Fe;for(;!f;){let r=ie(a);if(i>r&&(i=0),r>i){let{events:c,cursor:d}=Le(a,i,r);if(c.length>0){u(d,c);return}i=d}if(Date.now()>=s)break;await Pe(o,Math.min(je,s-Date.now()))}f||u(ie(a),[])}function P(e){try{let{unread:t,unreadFiles:o}=S(u=>{let f=me(R(e,"::actor::list_incoming_messages",u)).filter(c=>c.status==="unread"),s=R(e,"::actor::list_incoming_files",u),r=[];if(!s.IsNil())for(let c=0;;c++){let d=s.Reduce(c);if(d.IsNil())break;d.Reduce("status").Visualize()==="unread"&&r.push({file_id:d.Reduce("file_id").Visualize(),sender_id:d.Reduce("sender_id").Visualize(),from:d.Reduce("sender_name").Visualize(),filename:d.Reduce("filename").Visualize(),mime:d.Reduce("mime").Visualize(),bytes:d.Reduce("size").Visualize(),date:d.Reduce("date").Visualize(),wire_id:d.Reduce("wire_id").Visualize()})}return{unread:f,unreadFiles:r}}),n={count:t.length,recent:t.slice(-10).map(u=>({from:u.sender_name,msg_id:u.msg_id,date:u.date})),files:o.length,unread_files:o.slice(-10)};_.mkdirSync(e.dir,{recursive:!0,mode:448});let a=`${M(e.dir)}.tmp`;_.writeFileSync(a,JSON.stringify(n)),_.renameSync(a,M(e.dir))}catch(t){l(`[${e.name}] failed to refresh unread snapshot:`,String(t))}}function qt(){let e=[],t=[];try{t=_.readdirSync(V,{withFileTypes:!0})}catch{return{identities:e}}for(let o of t){if(!o.isDirectory()||ne(o.name)!==null)continue;let n;try{n=JSON.parse(_.readFileSync(M(ke(V,o.name)),"utf8"))}catch{continue}let a=Number.isSafeInteger(n.count)&&Number(n.count)>=0?Number(n.count):0,u=Number.isSafeInteger(n.files)&&Number(n.files)>=0?Number(n.files):0;if(a===0&&u===0)continue;let i=Array.isArray(n.recent)?n.recent.slice(-10).flatMap(s=>{if(!s||typeof s!="object")return[];let r=s;return typeof r.from!="string"||!["string","number"].includes(typeof r.msg_id)||typeof r.date!="string"?[]:[{from:r.from,msg_id:r.msg_id,date:r.date}]}):[],f=Array.isArray(n.unread_files)?n.unread_files.slice(-10).flatMap(s=>{if(!s||typeof s!="object")return[];let r=s;return typeof r.from!="string"||typeof r.filename!="string"||typeof r.mime!="string"||typeof r.wire_id!="string"?[]:[{from:r.from,filename:r.filename,mime:r.mime,wire_id:r.wire_id,...typeof r.sender_id=="string"?{sender_id:r.sender_id}:{},...["string","number"].includes(typeof r.file_id)?{file_id:r.file_id}:{},...["string","number"].includes(typeof r.bytes)?{bytes:r.bytes}:{},...typeof r.date=="string"?{date:r.date}:{}}]}):[];e.push({name:o.name,count:a,recent:i,files:u,unread_files:f})}return e.sort((o,n)=>String(o.name).localeCompare(String(n.name))),{identities:e}}export{Lt as a,Bt as b,te as c,Se as d,De as e,Pe as f,g,Mt as h,T as i,ie as j,Le as k,Ht as l,P as m,qt as n,qe as o,Ie as p,Y as q,ge as r,Ne as s,q as t,Ce as u,ye as v,U as w,A as x,yt as y,_t as z,It as A,Re as B,Ee as C,z as D,S as E,h as F,R as G,Ae as H,Oe as I,v as J,E as K,Z as L,X as M,_e as N,we as O,ee as P,C as Q,he as R,rt as S,ve as T};
|