@ours.network/sdk 3.0.4 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +19 -0
  2. package/dist/api/contacts.js +1 -1
  3. package/dist/api/files.js +1 -1
  4. package/dist/api/history.js +1 -1
  5. package/dist/api/identity.js +1 -1
  6. package/dist/api/messaging.js +1 -1
  7. package/dist/api/profile.js +1 -1
  8. package/dist/book.js +1 -1
  9. package/dist/boot.js +1 -1
  10. package/dist/chunk-2X5HGMMO.js +5 -0
  11. package/dist/{chunk-63FBQ35M.js → chunk-2ZQPUBE4.js} +1 -1
  12. package/dist/{chunk-3FAS7737.js → chunk-3CPIRV4P.js} +1 -1
  13. package/dist/{chunk-SQWLTVUX.js → chunk-3ZIC5X5I.js} +1 -1
  14. package/dist/{chunk-IOL6KZNO.js → chunk-4QU3AKO6.js} +1 -1
  15. package/dist/{chunk-L57CP5UJ.js → chunk-5JKYJZAR.js} +1 -1
  16. package/dist/{chunk-VD57XFNA.js → chunk-7Q3OCSPV.js} +1 -1
  17. package/dist/{chunk-6ATIPILE.js → chunk-7ZZWD64L.js} +1 -1
  18. package/dist/chunk-AAXXFRZP.js +4 -0
  19. package/dist/{chunk-XEK46DXF.js → chunk-AH3RIV2J.js} +1 -1
  20. package/dist/{chunk-HBHUWDY3.js → chunk-E34QSIVP.js} +1 -1
  21. package/dist/{chunk-O2K2ME7S.js → chunk-FCQYDCQA.js} +1 -1
  22. package/dist/{chunk-QWAZLLE2.js → chunk-IFCOOPD7.js} +2 -2
  23. package/dist/chunk-MGNMJ64X.js +174 -0
  24. package/dist/chunk-N4N4OLEW.js +2 -0
  25. package/dist/{chunk-6DRJYMF2.js → chunk-P2AAWXWI.js} +1 -1
  26. package/dist/{chunk-S6GRTEIM.js → chunk-PMN5M2JA.js} +1 -1
  27. package/dist/{chunk-TKIAVV2O.js → chunk-RL3OEL5W.js} +1 -1
  28. package/dist/{chunk-JV64HCOG.js → chunk-UZF6OB3R.js} +1 -1
  29. package/dist/{chunk-4EICEZ36.js → chunk-VQTATA4V.js} +1 -1
  30. package/dist/{chunk-CBKH6ILH.js → chunk-W34RPHBG.js} +1 -1
  31. package/dist/{chunk-FMQOOSOQ.js → chunk-WBCVUXOI.js} +1 -1
  32. package/dist/{chunk-MR2LCJLF.js → chunk-WD7K5KPL.js} +1 -1
  33. package/dist/{chunk-ULS3S767.js → chunk-WZQNO4PZ.js} +1 -1
  34. package/dist/chunk-XIWAQH6S.js +61 -0
  35. package/dist/{chunk-FP33FQ2P.js → chunk-XKPZWKI4.js} +1 -1
  36. package/dist/{chunk-RFU57I64.js → chunk-Y77ZVHTD.js} +1 -1
  37. package/dist/{chunk-VH4CORJZ.js → chunk-ZOZFAMAX.js} +1 -1
  38. package/dist/client/http.d.ts +3 -0
  39. package/dist/client/http.js +1 -1
  40. package/dist/client/select.js +1 -1
  41. package/dist/client.d.ts +1 -0
  42. package/dist/client.js +1 -1
  43. package/dist/cluster/control.js +1 -1
  44. package/dist/cluster/manifest.js +1 -1
  45. package/dist/config.d.ts +3 -0
  46. package/dist/config.js +1 -1
  47. package/dist/connector.js +1 -1
  48. package/dist/gc.js +1 -1
  49. package/dist/history-retention.d.ts +37 -0
  50. package/dist/history-retention.js +2 -0
  51. package/dist/history.js +1 -1
  52. package/dist/http/api-routes.js +1 -1
  53. package/dist/http/server.js +1 -1
  54. package/dist/identity/hierarchy.js +1 -1
  55. package/dist/identity/lease.js +1 -1
  56. package/dist/identity/lifecycle.js +1 -1
  57. package/dist/identity/migration.js +1 -1
  58. package/dist/identity/model.js +1 -1
  59. package/dist/identity/provision.js +1 -1
  60. package/dist/identity/reaper.js +1 -1
  61. package/dist/identity/release.js +1 -1
  62. package/dist/identity/staged.js +1 -1
  63. package/dist/index.d.ts +1 -0
  64. package/dist/index.js +1 -1
  65. package/dist/internal/daemon.js +1 -1
  66. package/dist/messaging/send.js +1 -1
  67. package/dist/mufl/handlers.js +1 -1
  68. package/dist/mufl/tx.js +1 -1
  69. package/dist/mufl_code/351F16D444E6DAA252D4A8D829D17204360D9015FEF670ACE68FB4747BB3B14E.muflo +0 -0
  70. package/dist/notify.js +1 -1
  71. package/dist/runtime/config-drift.js +1 -1
  72. package/dist/runtime/env.d.ts +1 -0
  73. package/dist/runtime/env.js +1 -1
  74. package/dist/state.js +1 -1
  75. package/dist/sweeps.js +1 -1
  76. package/dist/uploads.js +1 -1
  77. package/package.json +2 -2
  78. package/dist/chunk-6HS337DC.js +0 -4
  79. package/dist/chunk-EHCBEY52.js +0 -2
  80. package/dist/chunk-TXAIJEXA.js +0 -171
  81. package/dist/chunk-WS6UFNKF.js +0 -5
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 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="3.0.4",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(" ")}
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="3.1.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
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/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-4EICEZ36.js";import"./chunk-XEK46DXF.js";import"./chunk-VD57XFNA.js";import"./chunk-YRPUM6JG.js";import"./chunk-TKIAVV2O.js";import"./chunk-L57CP5UJ.js";import"./chunk-QWAZLLE2.js";import"./chunk-ZHH3PWEW.js";import"./chunk-Y3VPZJTG.js";import"./chunk-TXAIJEXA.js";import"./chunk-JTBQO6IT.js";import"./chunk-WS6UFNKF.js";export{a as startGcTimer,b as stopGcTimer};
2
+ import{a,b}from"./chunk-VQTATA4V.js";import"./chunk-AH3RIV2J.js";import"./chunk-YRPUM6JG.js";import"./chunk-7Q3OCSPV.js";import"./chunk-RL3OEL5W.js";import"./chunk-5JKYJZAR.js";import"./chunk-IFCOOPD7.js";import"./chunk-ZHH3PWEW.js";import"./chunk-Y3VPZJTG.js";import"./chunk-MGNMJ64X.js";import"./chunk-XIWAQH6S.js";import"./chunk-JTBQO6IT.js";import"./chunk-2X5HGMMO.js";export{a as startGcTimer,b as stopGcTimer};
@@ -0,0 +1,37 @@
1
+ export type HistoryRetentionState = 'disabled' | 'within_cap' | 'maintenance_pending' | 'protected_overflow' | 'compaction_blocked';
2
+ export interface HistoryStorageStatus {
3
+ state: HistoryRetentionState;
4
+ enabled: boolean;
5
+ max_bytes: number;
6
+ physical_bytes: number;
7
+ overflow_bytes: number;
8
+ protected_logical_bytes: number;
9
+ eligible_logical_bytes: number;
10
+ protected_items: number;
11
+ eligible_items: number;
12
+ newest_item_retained: boolean;
13
+ maintenance_pending: boolean;
14
+ compaction_blocked_identities: string[];
15
+ evicted_messages: number;
16
+ evicted_files: number;
17
+ orphaned_blobs_removed: number;
18
+ last_run_at_ms: number | null;
19
+ }
20
+ export declare function measureHistoryStorage(stateDir?: string | undefined): number;
21
+ /**
22
+ * Migrate a legacy database to bounded incremental compaction. A full VACUUM is
23
+ * permitted only below a fixed 128 MiB input bound; larger legacy stores remain
24
+ * readable and are surfaced as compaction_blocked instead of freezing startup
25
+ * for an unbounded rewrite.
26
+ */
27
+ export declare function prepareHistoryDatabase(path: string): void;
28
+ export declare function initializeHistoryRetention(stateDir: string, maxBytes: number): HistoryStorageStatus;
29
+ export declare function noteHistoryStorageMutation(identityDir: string, payloadBytes?: number): void;
30
+ export declare function enforceHistoryStorageLimit(maxPasses?: number): HistoryStorageStatus;
31
+ /** Read-only body-free telemetry. Refreshes real filesystem measurements. */
32
+ export declare function getHistoryStorageStatus(): HistoryStorageStatus;
33
+ export declare function stopHistoryRetention(): void;
34
+ export declare function pinHistoryItems(identityDir: string, kind: 'message' | 'file', wireIds: readonly string[]): void;
35
+ export declare function unpinHistoryItems(identityDir: string, kind: 'message' | 'file', wireIds: readonly string[]): void;
36
+ /** Test/recovery helper: remove one committed file blob only when no row references it. */
37
+ export declare function cleanupHistoryBlob(identityDir: string, relpath: string): boolean;
@@ -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,i,j}from"./chunk-XIWAQH6S.js";export{j as cleanupHistoryBlob,e as enforceHistoryStorageLimit,f as getHistoryStorageStatus,c as initializeHistoryRetention,a as measureHistoryStorage,d as noteHistoryStorageMutation,h as pinHistoryItems,b as prepareHistoryDatabase,g as stopHistoryRetention,i as unpinHistoryItems};
package/dist/history.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,x,y}from"./chunk-TXAIJEXA.js";export{b as blobRoot,g as closeHistory,e as consumeOutboundHistoryFailure,v as getFileHistoryItem,s as getMessageHistoryItem,t as getMessageHistorySummary,c as historyHealth,a as historyPath,h as ingestApplicationEvent,j as ingestControlEvent,i as ingestMonitoringEvent,u as listFileHistory,p as listIncomingFiles,n as listIncomingMessages,r as listMessageHistory,d as noteHistoryFailure,f as openHistory,k as promotePendingIntroduction,l as rejectPendingIntroduction,w as resolveStoredFile,m as secondaryQueueCounts,q as takeUnreadFiles,o as takeUnreadMessages,y as unreadCounts,x as updateDeliveryState};
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,x,y}from"./chunk-MGNMJ64X.js";import"./chunk-XIWAQH6S.js";export{b as blobRoot,g as closeHistory,e as consumeOutboundHistoryFailure,v as getFileHistoryItem,s as getMessageHistoryItem,t as getMessageHistorySummary,c as historyHealth,a as historyPath,h as ingestApplicationEvent,j as ingestControlEvent,i as ingestMonitoringEvent,u as listFileHistory,p as listIncomingFiles,n as listIncomingMessages,r as listMessageHistory,d as noteHistoryFailure,f as openHistory,k as promotePendingIntroduction,l as rejectPendingIntroduction,w as resolveStoredFile,m as secondaryQueueCounts,q as takeUnreadFiles,o as takeUnreadMessages,y as unreadCounts,x as updateDeliveryState};
@@ -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-MR2LCJLF.js";import"../chunk-VH4CORJZ.js";import"../chunk-6HS337DC.js";import"../chunk-JV64HCOG.js";import"../chunk-FP33FQ2P.js";import"../chunk-IOL6KZNO.js";import"../chunk-VXVW4KJU.js";import"../chunk-FMQOOSOQ.js";import"../chunk-P55RJGZU.js";import"../chunk-SQWLTVUX.js";import"../chunk-3FAS7737.js";import"../chunk-6ATIPILE.js";import"../chunk-63FBQ35M.js";import"../chunk-RFU57I64.js";import"../chunk-JOKNFUW3.js";import"../chunk-DIRW7I4S.js";import"../chunk-65KGEJBX.js";import"../chunk-ULS3S767.js";import"../chunk-HBHUWDY3.js";import"../chunk-XEK46DXF.js";import"../chunk-VD57XFNA.js";import"../chunk-YRPUM6JG.js";import"../chunk-TKIAVV2O.js";import"../chunk-L57CP5UJ.js";import"../chunk-QWAZLLE2.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-TXAIJEXA.js";import"../chunk-JTBQO6IT.js";import"../chunk-WS6UFNKF.js";export{b as API_OPERATIONS,a as API_PREFIX,c as enterApiSession,d as serveApiOperation};
2
+ import{a,b,c,d}from"../chunk-WD7K5KPL.js";import"../chunk-ZOZFAMAX.js";import"../chunk-AAXXFRZP.js";import"../chunk-UZF6OB3R.js";import"../chunk-XKPZWKI4.js";import"../chunk-4QU3AKO6.js";import"../chunk-VXVW4KJU.js";import"../chunk-WBCVUXOI.js";import"../chunk-P55RJGZU.js";import"../chunk-3ZIC5X5I.js";import"../chunk-3CPIRV4P.js";import"../chunk-2ZQPUBE4.js";import"../chunk-7ZZWD64L.js";import"../chunk-Y77ZVHTD.js";import"../chunk-JOKNFUW3.js";import"../chunk-DIRW7I4S.js";import"../chunk-65KGEJBX.js";import"../chunk-WZQNO4PZ.js";import"../chunk-E34QSIVP.js";import"../chunk-AH3RIV2J.js";import"../chunk-YRPUM6JG.js";import"../chunk-7Q3OCSPV.js";import"../chunk-RL3OEL5W.js";import"../chunk-5JKYJZAR.js";import"../chunk-IFCOOPD7.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-MGNMJ64X.js";import"../chunk-XIWAQH6S.js";import"../chunk-JTBQO6IT.js";import"../chunk-2X5HGMMO.js";export{b as API_OPERATIONS,a as API_PREFIX,c as enterApiSession,d as serveApiOperation};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{d as M}from"../chunk-V64IUVSS.js";import{a as G}from"../chunk-37D5PCFY.js";import{a as he}from"../chunk-NBEWKZG4.js";import{a as ue,b as z}from"../chunk-4EICEZ36.js";import{a as ge,d as ye}from"../chunk-MR2LCJLF.js";import{b as me}from"../chunk-S6GRTEIM.js";import"../chunk-EHCBEY52.js";import{a as le,b as fe}from"../chunk-CBKH6ILH.js";import"../chunk-VH4CORJZ.js";import"../chunk-6HS337DC.js";import"../chunk-JV64HCOG.js";import"../chunk-FP33FQ2P.js";import{e as de,f as ce,h as pe}from"../chunk-IOL6KZNO.js";import{b as ae}from"../chunk-VXVW4KJU.js";import"../chunk-FMQOOSOQ.js";import"../chunk-P55RJGZU.js";import"../chunk-SQWLTVUX.js";import"../chunk-3FAS7737.js";import"../chunk-6ATIPILE.js";import{a as re}from"../chunk-63FBQ35M.js";import"../chunk-RFU57I64.js";import"../chunk-JOKNFUW3.js";import"../chunk-DIRW7I4S.js";import"../chunk-65KGEJBX.js";import{b as se}from"../chunk-ULS3S767.js";import"../chunk-HBHUWDY3.js";import{x as ie}from"../chunk-XEK46DXF.js";import{a as te,b as A,n as ne,p as oe}from"../chunk-VD57XFNA.js";import"../chunk-YRPUM6JG.js";import{a as ee,c as h,f as L,g as U}from"../chunk-TKIAVV2O.js";import{c as v,d as Z,u as q}from"../chunk-L57CP5UJ.js";import{a as P,b as Q,c as H,d as W,e as N,g as X,h as D,i as p,m as I,p as Y}from"../chunk-QWAZLLE2.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-TXAIJEXA.js";import"../chunk-JTBQO6IT.js";import"../chunk-WS6UFNKF.js";import{createServer as ke}from"node:http";import{randomUUID as Re}from"node:crypto";import*as b from"node:fs";he();function Ne(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;let l=r;return l.jsonrpc==="2.0"&&l.method==="initialize"}var Oe=["brokerUrl","port","stateDir","gcIntervalMs","apiVisibility"];function we(r){return new Promise((l,f)=>{let O="";r.on("data",m=>O+=m),r.on("end",()=>{try{l(JSON.parse(O))}catch(m){f(m)}}),r.on("error",f)})}async function Ke(r={}){try{return await Ce(r)}catch(l){throw D?.failed(),p(`fatal startup error: ${l?.stack??l}`),l}}async function Ce(r){let l=r.handleSignals!==!1;if(process.env.OURS_TEST_STARTUP_FAIL==="1")throw new Error("forced startup failure (OURS_TEST_STARTUP_FAIL)");if(r.config){let t=Oe.filter(e=>r.config[e]!==Q[e]);if(t.length>0)throw new Error(`startDaemon(config) disagrees with the config resolved at module load (${t.join(", ")}). The engine reads its config when src/runtime/env.ts is imported, so a later override cannot move the state dir, port or broker \u2014 set OURS_* env or config.json before importing the SDK.`)}let f=r.mcp,O=f?.isInitializeRequest??Ne,m=null;if(typeof r.onIdentityNotify=="function"){let t=r.onIdentityNotify;m=(e,i)=>{t(e,i,ee.get(e)?.sid??null)},te(m)}p("booting wrapper\u2026");try{await me(),ue()}catch(t){throw m&&A(m),z(),t}p(`wrapper ready (identities=${v.size}), starting HTTP server\u2026`),D?.update("server");let c={},T=new Map,k=new Map,Se=3e4,J=t=>{let e=k.get(t);e?e.n++:k.set(t,{n:1,since:Date.now()})},B=t=>{let e=k.get(t);e&&--e.n<=0&&k.delete(t)},F=()=>{let t=0;for(let e of[...T.keys()]){if(e==="stdio")continue;let i=h.get(e)?.pid;if(i===void 0||!L(i))continue;let n=k.get(e);if(n&&n.n>0&&Date.now()-n.since<Se)continue;let o=T.get(e);T.delete(e),delete c[e],h.delete(e),k.delete(e),o?.close().catch(()=>{}),f?.onSessionClosed?.(e),t++,p(`session ${e.slice(0,8)}\u2026 reaped (client pid ${i} dead)`)}return t},$=!1,V=setInterval(()=>{$||($=!0,F(),pe(),fe().finally(()=>{$=!1}))},le());V.unref?.();let x=1e3,ve=10*6e4,u=new Map,Ie=(t,e)=>{let i=Array.isArray(e)?e:[e];for(let n of i){let o=n;!o||typeof o!="object"||o.id===void 0||o.id===null||typeof o.method!="string"||u.set(`${t}:${String(o.id)}`,{method:o.method,at:Date.now()})}if(u.size>x){let n=Date.now()-ve;for(let[o,a]of u)if(a.at<n&&u.delete(o),u.size<=x)break;for(;u.size>x;){let o=u.keys().next();if(o.done)break;u.delete(o.value)}}},Te=(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],a=u.get(`${t}:${o}`);u.delete(`${t}:${o}`),p(`UNDELIVERABLE RESPONSE session=${t.slice(0,8)}\u2026 request_id=${o} method=${a?.method??"unknown"} age_ms=${a?Date.now()-a.at:"unknown"} at=${new Date().toISOString()} \u2014 the answer was produced but its stream was already gone`)}catch{}},w=ke(async(t,e)=>{let i=new URL(t.url,`http://localhost:${N}`);if(t.method==="GET"&&i.pathname==="/state-dir"){e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify({stateDir:H,version:P,compat:1}));return}if(t.method==="GET"&&(i.pathname==="/version"||i.pathname==="/info")){e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify({name:"ours",version:P,compat:1,protocol:se,pid:process.pid,stateDir:H}));return}if(t.method==="GET"&&i.pathname==="/identities"){if(!I(t,e))return;e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify({identities:[...v.values()].map(n=>({name:n.name,...n.temp?{temporary:!0,stale:L(n.temp.owner.pid)}:{}})).concat([...Z.entries()].map(([n,o])=>({name:n,status:o.status})))}));return}if(t.method==="GET"&&i.pathname==="/unread"){if(!I(t,e))return;e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify(oe()));return}{let n=/^\/identities\/([^/]+)\/notifications$/.exec(i.pathname);if(t.method==="GET"&&n){if(!I(t,e))return;let o=decodeURIComponent(n[1]);if(Y(o)!==null){e.writeHead(400,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:"invalid identity name"}));return}if(!v.has(o)){e.writeHead(404,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:"no active identity with that name"}));return}await ne(t,e,o,i.searchParams.get("since"),i.searchParams.get("kinds"));return}}if(t.method==="POST"&&i.pathname==="/files/upload"){if(!I(t,e))return;let n=t.headers["x-ours-lease-token"],o=typeof n=="string"&&n?U(n):void 0,a=o?v.get(o.identity):void 0;if(!a){e.writeHead(401,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:"no identity bound to this session"}));return}let S=t.headers["content-length"],g=typeof S=="string"?Number(S):NaN,y=t.headers["x-ours-filename"];try{let s=await ce(a,t,{filename:typeof y=="string"?decodeURIComponent(y):"",mime:typeof t.headers["content-type"]=="string"?t.headers["content-type"]:"",declaredBytes:Number.isInteger(g)&&g>=0?g:null,cap:ae()});e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify(s))}catch(s){let R=s instanceof de?s.status:500;e.headersSent||(e.writeHead(R,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:s instanceof Error?s.message:String(s)})))}return}{let n=/^\/files\/([^/]+)$/.exec(i.pathname);if(t.method==="GET"&&n){if(!I(t,e))return;let o=decodeURIComponent(n[1]),a=t.headers["x-ours-lease-token"],S=typeof a=="string"&&a?U(a):void 0,g=S?v.get(S.identity):void 0;if(!g){e.writeHead(401,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:"no identity bound to this session"}));return}let y=q(g,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 s=b.statSync(y);e.writeHead(200,{"Content-Type":"application/octet-stream","Content-Length":String(s.size)});let R=b.createReadStream(y);R.on("error",()=>{try{e.destroy()}catch{}}),R.pipe(e)}catch(s){e.writeHead(500,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:`failed to read file: ${String(s)}`}))}return}}if(i.pathname.startsWith(ge)){await ye(t,e,i.pathname,we);return}if(i.pathname!=="/mcp"||!f){e.writeHead(404,{"Content-Type":"text/plain"}),e.end("Not found");return}if(I(t,e))try{if(t.method==="POST"){let n=await we(t),o=t.headers["mcp-session-id"],a=t.headers["x-ours-lease-token"],S=t.headers["x-ours-client-pid"],g=S?parseInt(S,10):void 0,y={token:a,pid:Number.isInteger(g)?g:void 0};if(o&&c[o]){h.set(o,y),Ie(o,n),J(o),M(e);try{await c[o].handleRequest(t,e,n)}finally{B(o)}}else if(!o&&O(n)){F();let s=f.createTransport({sessionIdGenerator:()=>Re(),onsessioninitialized:d=>{c[d]=s,h.set(d,y),T.set(d,E),f.onSessionInitialized?.(d,E),p(`session ${d.slice(0,8)}\u2026 initialized`)}}),R={sessionId:()=>s.sessionId??"pending",leaseToken:()=>h.get(s.sessionId??"pending")?.token,clientPid:()=>h.get(s.sessionId??"pending")?.pid},E=f.createServer(R);E.server.onerror=d=>Te(s.sessionId??"pending",d),s.onclose=()=>{let d=s.sessionId;d&&(delete c[d],T.delete(d),h.delete(d),f.onSessionClosed?.(d),p(`session ${d.slice(0,8)}\u2026 closed (lease kept)`))},await E.connect(s),M(e),await s.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||!c[n]){e.writeHead(400,{"Content-Type":"text/plain"}),e.end("Invalid or missing session ID");return}J(n),M(e);try{await c[n].handleRequest(t,e)}finally{B(n)}}else if(t.method==="DELETE"){let n=t.headers["mcp-session-id"];if(!n||!c[n]){e.writeHead(400,{"Content-Type":"text/plain"}),e.end("Invalid or missing session ID");return}let o=h.get(n)?.token??t.headers["x-ours-lease-token"];o&&await re(o),await c[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})))}});w.requestTimeout=0;let K=!1,_=async()=>{if(!K){K=!0,clearInterval(V),z(),m&&A(m);for(let t of Object.keys(c)){try{await c[t].close()}catch{}delete c[t]}T.clear();for(let t of v.values())try{ie(t)}catch(e){p(`[${t.name}] shutdown save failed:`,String(e))}w.closeAllConnections?.()}};try{await new Promise((t,e)=>{let i=n=>e(n);w.once("error",i),w.listen(N,"127.0.0.1",()=>{w.off("error",i),D?.ready(),p(`MCP server v${r.version??P} ready (transport=http, port=${N}, visibility=${X}, identities=${v.size}, state=${H}, broker=${W})`),t()})})}catch(t){throw await _(),t}let C=async()=>{p("shutting down\u2026"),await _(),w.close(),await r.onShutdown?.(),process.exit(0)};l&&(process.on("SIGINT",C),process.on("SIGTERM",C));let j=w.address();return{port:typeof j=="object"&&j!==null?j.port:N,close:async()=>{l&&(process.off("SIGINT",C),process.off("SIGTERM",C)),await _(),await new Promise(t=>w.close(()=>t()))}}}export{Ke as startDaemon};
2
+ import{d as b}from"../chunk-V64IUVSS.js";import{a as G}from"../chunk-37D5PCFY.js";import{a as Ie}from"../chunk-NBEWKZG4.js";import{a as we,b as z}from"../chunk-VQTATA4V.js";import{a as Se,d as ve}from"../chunk-WD7K5KPL.js";import{b as he}from"../chunk-PMN5M2JA.js";import"../chunk-N4N4OLEW.js";import{a as ye,b as ge}from"../chunk-W34RPHBG.js";import"../chunk-ZOZFAMAX.js";import"../chunk-AAXXFRZP.js";import"../chunk-UZF6OB3R.js";import"../chunk-XKPZWKI4.js";import{e as fe,f as me,h as ue}from"../chunk-4QU3AKO6.js";import{b as le}from"../chunk-VXVW4KJU.js";import"../chunk-WBCVUXOI.js";import"../chunk-P55RJGZU.js";import"../chunk-3ZIC5X5I.js";import"../chunk-3CPIRV4P.js";import{a as pe}from"../chunk-2ZQPUBE4.js";import"../chunk-7ZZWD64L.js";import"../chunk-Y77ZVHTD.js";import"../chunk-JOKNFUW3.js";import"../chunk-DIRW7I4S.js";import"../chunk-65KGEJBX.js";import{b as ce}from"../chunk-WZQNO4PZ.js";import"../chunk-E34QSIVP.js";import{x as de}from"../chunk-AH3RIV2J.js";import"../chunk-YRPUM6JG.js";import{a as se,b as U,n as re,p as ae}from"../chunk-7Q3OCSPV.js";import{a as ie,c as h,f as L,g as A}from"../chunk-RL3OEL5W.js";import{c as I,d as ne,u as oe}from"../chunk-5JKYJZAR.js";import{a as P,b as X,c as O,d as Y,e as N,g as Q,h as W,i as M,j as c,n as v,q as Z}from"../chunk-IFCOOPD7.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-MGNMJ64X.js";import{c as q,f as ee,g as te}from"../chunk-XIWAQH6S.js";import"../chunk-JTBQO6IT.js";import"../chunk-2X5HGMMO.js";import{createServer as Ce}from"node:http";import{randomUUID as Ee}from"node:crypto";import*as _ from"node:fs";Ie();function He(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;let l=r;return l.jsonrpc==="2.0"&&l.method==="initialize"}var Pe=["brokerUrl","port","stateDir","gcIntervalMs","historyMaxBytes","apiVisibility"];function Te(r){return new Promise((l,f)=>{let C="";r.on("data",m=>C+=m),r.on("end",()=>{try{l(JSON.parse(C))}catch(m){f(m)}}),r.on("error",f)})}async function Ze(r={}){try{return await Me(r)}catch(l){throw M?.failed(),c(`fatal startup error: ${l?.stack??l}`),l}}async function Me(r){let l=r.handleSignals!==!1;if(process.env.OURS_TEST_STARTUP_FAIL==="1")throw new Error("forced startup failure (OURS_TEST_STARTUP_FAIL)");if(r.config){let t=Pe.filter(e=>r.config[e]!==X[e]);if(t.length>0)throw new Error(`startDaemon(config) disagrees with the config resolved at module load (${t.join(", ")}). The engine reads its config when src/runtime/env.ts is imported, so a later override cannot move the state dir, port or broker \u2014 set OURS_* env or config.json before importing the SDK.`)}let f=r.mcp,C=f?.isInitializeRequest??He,m=null;if(typeof r.onIdentityNotify=="function"){let t=r.onIdentityNotify;m=(e,i)=>{t(e,i,ie.get(e)?.sid??null)},se(m)}c("booting wrapper\u2026");try{await he();let t=q(O,Q);c(`history storage ${t.state} (physical=${t.physical_bytes}, cap=${t.max_bytes}, overflow=${t.overflow_bytes})`),we()}catch(t){throw m&&U(m),z(),t}c(`wrapper ready (identities=${I.size}), starting HTTP server\u2026`),M?.update("server");let p={},T=new Map,k=new Map,ke=3e4,J=t=>{let e=k.get(t);e?e.n++:k.set(t,{n:1,since:Date.now()})},B=t=>{let e=k.get(t);e&&--e.n<=0&&k.delete(t)},F=()=>{let t=0;for(let e of[...T.keys()]){if(e==="stdio")continue;let i=h.get(e)?.pid;if(i===void 0||!L(i))continue;let n=k.get(e);if(n&&n.n>0&&Date.now()-n.since<ke)continue;let o=T.get(e);T.delete(e),delete p[e],h.delete(e),k.delete(e),o?.close().catch(()=>{}),f?.onSessionClosed?.(e),t++,c(`session ${e.slice(0,8)}\u2026 reaped (client pid ${i} dead)`)}return t},$=!1,V=setInterval(()=>{$||($=!0,F(),ue(),ge().finally(()=>{$=!1}))},ye());V.unref?.();let D=1e3,Re=10*6e4,u=new Map,Oe=(t,e)=>{let i=Array.isArray(e)?e:[e];for(let n of i){let o=n;!o||typeof o!="object"||o.id===void 0||o.id===null||typeof o.method!="string"||u.set(`${t}:${String(o.id)}`,{method:o.method,at:Date.now()})}if(u.size>D){let n=Date.now()-Re;for(let[o,a]of u)if(a.at<n&&u.delete(o),u.size<=D)break;for(;u.size>D;){let o=u.keys().next();if(o.done)break;u.delete(o.value)}}},Ne=(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],a=u.get(`${t}:${o}`);u.delete(`${t}:${o}`),c(`UNDELIVERABLE RESPONSE session=${t.slice(0,8)}\u2026 request_id=${o} method=${a?.method??"unknown"} age_ms=${a?Date.now()-a.at:"unknown"} at=${new Date().toISOString()} \u2014 the answer was produced but its stream was already gone`)}catch{}},w=Ce(async(t,e)=>{let i=new URL(t.url,`http://localhost:${N}`);if(t.method==="GET"&&i.pathname==="/state-dir"){e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify({stateDir:O,version:P,compat:1}));return}if(t.method==="GET"&&(i.pathname==="/version"||i.pathname==="/info")){e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify({name:"ours",version:P,compat:1,protocol:ce,pid:process.pid,stateDir:O}));return}if(t.method==="GET"&&i.pathname==="/identities"){if(!v(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:L(n.temp.owner.pid)}:{}})).concat([...ne.entries()].map(([n,o])=>({name:n,status:o.status})))}));return}if(t.method==="GET"&&i.pathname==="/unread"){if(!v(t,e))return;e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify(ae()));return}if(t.method==="GET"&&i.pathname==="/history-storage"){if(!v(t,e))return;e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify(ee()));return}{let n=/^\/identities\/([^/]+)\/notifications$/.exec(i.pathname);if(t.method==="GET"&&n){if(!v(t,e))return;let o=decodeURIComponent(n[1]);if(Z(o)!==null){e.writeHead(400,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:"invalid identity name"}));return}if(!I.has(o)){e.writeHead(404,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:"no active identity with that name"}));return}await re(t,e,o,i.searchParams.get("since"),i.searchParams.get("kinds"));return}}if(t.method==="POST"&&i.pathname==="/files/upload"){if(!v(t,e))return;let n=t.headers["x-ours-lease-token"],o=typeof n=="string"&&n?A(n):void 0,a=o?I.get(o.identity):void 0;if(!a){e.writeHead(401,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:"no identity bound to this session"}));return}let S=t.headers["content-length"],y=typeof S=="string"?Number(S):NaN,g=t.headers["x-ours-filename"];try{let s=await me(a,t,{filename:typeof g=="string"?decodeURIComponent(g):"",mime:typeof t.headers["content-type"]=="string"?t.headers["content-type"]:"",declaredBytes:Number.isInteger(y)&&y>=0?y:null,cap:le()});e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify(s))}catch(s){let R=s instanceof fe?s.status:500;e.headersSent||(e.writeHead(R,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:s instanceof Error?s.message:String(s)})))}return}{let n=/^\/files\/([^/]+)$/.exec(i.pathname);if(t.method==="GET"&&n){if(!v(t,e))return;let o=decodeURIComponent(n[1]),a=t.headers["x-ours-lease-token"],S=typeof a=="string"&&a?A(a):void 0,y=S?I.get(S.identity):void 0;if(!y){e.writeHead(401,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:"no identity bound to this session"}));return}let g=oe(y,o);if(!g){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 s=_.statSync(g);e.writeHead(200,{"Content-Type":"application/octet-stream","Content-Length":String(s.size)});let R=_.createReadStream(g);R.on("error",()=>{try{e.destroy()}catch{}}),R.pipe(e)}catch(s){e.writeHead(500,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:`failed to read file: ${String(s)}`}))}return}}if(i.pathname.startsWith(Se)){await ve(t,e,i.pathname,Te);return}if(i.pathname!=="/mcp"||!f){e.writeHead(404,{"Content-Type":"text/plain"}),e.end("Not found");return}if(v(t,e))try{if(t.method==="POST"){let n=await Te(t),o=t.headers["mcp-session-id"],a=t.headers["x-ours-lease-token"],S=t.headers["x-ours-client-pid"],y=S?parseInt(S,10):void 0,g={token:a,pid:Number.isInteger(y)?y:void 0};if(o&&p[o]){h.set(o,g),Oe(o,n),J(o),b(e);try{await p[o].handleRequest(t,e,n)}finally{B(o)}}else if(!o&&C(n)){F();let s=f.createTransport({sessionIdGenerator:()=>Ee(),onsessioninitialized:d=>{p[d]=s,h.set(d,g),T.set(d,H),f.onSessionInitialized?.(d,H),c(`session ${d.slice(0,8)}\u2026 initialized`)}}),R={sessionId:()=>s.sessionId??"pending",leaseToken:()=>h.get(s.sessionId??"pending")?.token,clientPid:()=>h.get(s.sessionId??"pending")?.pid},H=f.createServer(R);H.server.onerror=d=>Ne(s.sessionId??"pending",d),s.onclose=()=>{let d=s.sessionId;d&&(delete p[d],T.delete(d),h.delete(d),f.onSessionClosed?.(d),c(`session ${d.slice(0,8)}\u2026 closed (lease kept)`))},await H.connect(s),b(e),await s.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||!p[n]){e.writeHead(400,{"Content-Type":"text/plain"}),e.end("Invalid or missing session ID");return}J(n),b(e);try{await p[n].handleRequest(t,e)}finally{B(n)}}else if(t.method==="DELETE"){let n=t.headers["mcp-session-id"];if(!n||!p[n]){e.writeHead(400,{"Content-Type":"text/plain"}),e.end("Invalid or missing session ID");return}let o=h.get(n)?.token??t.headers["x-ours-lease-token"];o&&await pe(o),await p[n].handleRequest(t,e)}else e.writeHead(405,{"Content-Type":"text/plain"}),e.end("Method not allowed")}catch(n){c("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})))}});w.requestTimeout=0;let K=!1,x=async()=>{if(!K){K=!0,clearInterval(V),z(),te(),m&&U(m);for(let t of Object.keys(p)){try{await p[t].close()}catch{}delete p[t]}T.clear();for(let t of I.values())try{de(t)}catch(e){c(`[${t.name}] shutdown save failed:`,String(e))}w.closeAllConnections?.()}};try{await new Promise((t,e)=>{let i=n=>e(n);w.once("error",i),w.listen(N,"127.0.0.1",()=>{w.off("error",i),M?.ready(),c(`MCP server v${r.version??P} ready (transport=http, port=${N}, visibility=${W}, identities=${I.size}, state=${O}, broker=${Y})`),t()})})}catch(t){throw await x(),t}let E=async()=>{c("shutting down\u2026"),await x(),w.close(),await r.onShutdown?.(),process.exit(0)};l&&(process.on("SIGINT",E),process.on("SIGTERM",E));let j=w.address();return{port:typeof j=="object"&&j!==null?j.port:N,close:async()=>{l&&(process.off("SIGINT",E),process.off("SIGTERM",E)),await x(),await new Promise(t=>w.close(()=>t()))}}}export{Ze as startDaemon};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{i as a,j as b,k as c,l as d,m as e,n as f,o as g}from"../chunk-XEK46DXF.js";import"../chunk-VD57XFNA.js";import"../chunk-YRPUM6JG.js";import"../chunk-TKIAVV2O.js";import"../chunk-L57CP5UJ.js";import"../chunk-QWAZLLE2.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-TXAIJEXA.js";import"../chunk-JTBQO6IT.js";import"../chunk-WS6UFNKF.js";export{d as clearRootMarker,f as delegateRole,e as describeIdentity,g as establishRoot,c as readRootMarker,b as rootName,a as setRootName};
2
+ import{i as a,j as b,k as c,l as d,m as e,n as f,o as g}from"../chunk-AH3RIV2J.js";import"../chunk-YRPUM6JG.js";import"../chunk-7Q3OCSPV.js";import"../chunk-RL3OEL5W.js";import"../chunk-5JKYJZAR.js";import"../chunk-IFCOOPD7.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-MGNMJ64X.js";import"../chunk-XIWAQH6S.js";import"../chunk-JTBQO6IT.js";import"../chunk-2X5HGMMO.js";export{d as clearRootMarker,f as delegateRole,e as describeIdentity,g as establishRoot,c as readRootMarker,b as rootName,a as setRootName};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a,b,c,d,e,f,g,h,i,j}from"../chunk-TKIAVV2O.js";import"../chunk-L57CP5UJ.js";import"../chunk-QWAZLLE2.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-TXAIJEXA.js";import"../chunk-WS6UFNKF.js";export{j as bindSession,g as leaseByToken,a as leases,d as outboundRemovalInFlight,h as persistBindings,e as pidAlive,f as pidDefinitelyDead,i as resolveBound,c as sessionHeaders,b as tombstones};
2
+ import{a,b,c,d,e,f,g,h,i,j}from"../chunk-RL3OEL5W.js";import"../chunk-5JKYJZAR.js";import"../chunk-IFCOOPD7.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-MGNMJ64X.js";import"../chunk-XIWAQH6S.js";import"../chunk-2X5HGMMO.js";export{j as bindSession,g as leaseByToken,a as leases,d as outboundRemovalInFlight,h as persistBindings,e as pidAlive,f as pidDefinitelyDead,i 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-RFU57I64.js";import"../chunk-JOKNFUW3.js";import"../chunk-DIRW7I4S.js";import"../chunk-XEK46DXF.js";import"../chunk-VD57XFNA.js";import"../chunk-YRPUM6JG.js";import"../chunk-TKIAVV2O.js";import"../chunk-L57CP5UJ.js";import"../chunk-QWAZLLE2.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-TXAIJEXA.js";import"../chunk-JTBQO6IT.js";import"../chunk-WS6UFNKF.js";export{b as closeTemporaryIdentity,a as deleteIdentityCompletely,d as sweepOrphanTempDirs,c as sweepStaleTempIdentities};
2
+ import{a,b,c,d}from"../chunk-Y77ZVHTD.js";import"../chunk-JOKNFUW3.js";import"../chunk-DIRW7I4S.js";import"../chunk-AH3RIV2J.js";import"../chunk-YRPUM6JG.js";import"../chunk-7Q3OCSPV.js";import"../chunk-RL3OEL5W.js";import"../chunk-5JKYJZAR.js";import"../chunk-IFCOOPD7.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-MGNMJ64X.js";import"../chunk-XIWAQH6S.js";import"../chunk-JTBQO6IT.js";import"../chunk-2X5HGMMO.js";export{b as closeTemporaryIdentity,a as deleteIdentityCompletely,d as sweepOrphanTempDirs,c as sweepStaleTempIdentities};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{p as a,q as b}from"../chunk-XEK46DXF.js";import"../chunk-VD57XFNA.js";import"../chunk-YRPUM6JG.js";import"../chunk-TKIAVV2O.js";import"../chunk-L57CP5UJ.js";import"../chunk-QWAZLLE2.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-TXAIJEXA.js";import"../chunk-JTBQO6IT.js";import"../chunk-WS6UFNKF.js";export{b as adoptQuarantinedIdentities,a as reconcileRestoredIdentity};
2
+ import{p as a,q as b}from"../chunk-AH3RIV2J.js";import"../chunk-YRPUM6JG.js";import"../chunk-7Q3OCSPV.js";import"../chunk-RL3OEL5W.js";import"../chunk-5JKYJZAR.js";import"../chunk-IFCOOPD7.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-MGNMJ64X.js";import"../chunk-XIWAQH6S.js";import"../chunk-JTBQO6IT.js";import"../chunk-2X5HGMMO.js";export{b as adoptQuarantinedIdentities,a as reconcileRestoredIdentity};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m,m as n,n as o,o as p,p as q,q as r,r as s,s as t,t as u,u as v,v as w}from"../chunk-L57CP5UJ.js";import"../chunk-QWAZLLE2.js";import"../chunk-ZHH3PWEW.js";import{a}from"../chunk-Y3VPZJTG.js";import"../chunk-TXAIJEXA.js";import"../chunk-WS6UFNKF.js";export{a as FILE_SELECTION_CAP,l as dataPath,v as findIdentityFile,p as hashLeaseToken,d as identities,j as identityDir,u as isSelectableWireId,t as isWireId,k as keyPath,w as listPersistedNames,m as notifyLogPath,e as quarantinedIdentities,r as readTempMetaFile,f as registrar,g as registrarAdBlob,h as setRegistrar,i as setRegistrarAdBlob,c as setWrapper,o as tempMetaPath,s as tightenIdentityPerms,n as unreadPath,b as wrapper,q as writeTempMetaFile};
2
+ import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m,m as n,n as o,o as p,p as q,q as r,r as s,s as t,t as u,u as v,v as w}from"../chunk-5JKYJZAR.js";import"../chunk-IFCOOPD7.js";import"../chunk-ZHH3PWEW.js";import{a}from"../chunk-Y3VPZJTG.js";import"../chunk-MGNMJ64X.js";import"../chunk-XIWAQH6S.js";import"../chunk-2X5HGMMO.js";export{a as FILE_SELECTION_CAP,l as dataPath,v as findIdentityFile,p as hashLeaseToken,d as identities,j as identityDir,u as isSelectableWireId,t as isWireId,k as keyPath,w as listPersistedNames,m as notifyLogPath,e as quarantinedIdentities,r as readTempMetaFile,f as registrar,g as registrarAdBlob,h as setRegistrar,i as setRegistrarAdBlob,c as setWrapper,o as tempMetaPath,s as tightenIdentityPerms,n as unreadPath,b as wrapper,q as writeTempMetaFile};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{r as a,s as b,t as c,u as d}from"../chunk-XEK46DXF.js";import"../chunk-VD57XFNA.js";import"../chunk-YRPUM6JG.js";import"../chunk-TKIAVV2O.js";import"../chunk-L57CP5UJ.js";import"../chunk-QWAZLLE2.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-TXAIJEXA.js";import"../chunk-JTBQO6IT.js";import"../chunk-WS6UFNKF.js";export{a as createPacket,c as provisionIdentity,b as reservedNames,d as restoreIdentity};
2
+ import{r as a,s as b,t as c,u as d}from"../chunk-AH3RIV2J.js";import"../chunk-YRPUM6JG.js";import"../chunk-7Q3OCSPV.js";import"../chunk-RL3OEL5W.js";import"../chunk-5JKYJZAR.js";import"../chunk-IFCOOPD7.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-MGNMJ64X.js";import"../chunk-XIWAQH6S.js";import"../chunk-JTBQO6IT.js";import"../chunk-2X5HGMMO.js";export{a as createPacket,c as provisionIdentity,b as reservedNames,d as restoreIdentity};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a,b,c}from"../chunk-CBKH6ILH.js";import"../chunk-RFU57I64.js";import"../chunk-JOKNFUW3.js";import"../chunk-DIRW7I4S.js";import"../chunk-XEK46DXF.js";import"../chunk-VD57XFNA.js";import"../chunk-YRPUM6JG.js";import"../chunk-TKIAVV2O.js";import"../chunk-L57CP5UJ.js";import"../chunk-QWAZLLE2.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-TXAIJEXA.js";import"../chunk-JTBQO6IT.js";import"../chunk-WS6UFNKF.js";export{c as reapOrphanTemporaryDirectories,b as reapStaleTemporaryIdentities,a as sessionReaperIntervalMs};
2
+ import{a,b,c}from"../chunk-W34RPHBG.js";import"../chunk-Y77ZVHTD.js";import"../chunk-JOKNFUW3.js";import"../chunk-DIRW7I4S.js";import"../chunk-AH3RIV2J.js";import"../chunk-YRPUM6JG.js";import"../chunk-7Q3OCSPV.js";import"../chunk-RL3OEL5W.js";import"../chunk-5JKYJZAR.js";import"../chunk-IFCOOPD7.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-MGNMJ64X.js";import"../chunk-XIWAQH6S.js";import"../chunk-JTBQO6IT.js";import"../chunk-2X5HGMMO.js";export{c as reapOrphanTemporaryDirectories,b as reapStaleTemporaryIdentities,a as sessionReaperIntervalMs};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a}from"../chunk-63FBQ35M.js";import"../chunk-RFU57I64.js";import"../chunk-JOKNFUW3.js";import"../chunk-DIRW7I4S.js";import"../chunk-65KGEJBX.js";import"../chunk-XEK46DXF.js";import"../chunk-VD57XFNA.js";import"../chunk-YRPUM6JG.js";import"../chunk-TKIAVV2O.js";import"../chunk-L57CP5UJ.js";import"../chunk-QWAZLLE2.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-TXAIJEXA.js";import"../chunk-JTBQO6IT.js";import"../chunk-WS6UFNKF.js";export{a as releaseLeaseByToken};
2
+ import{a}from"../chunk-2ZQPUBE4.js";import"../chunk-Y77ZVHTD.js";import"../chunk-JOKNFUW3.js";import"../chunk-DIRW7I4S.js";import"../chunk-65KGEJBX.js";import"../chunk-AH3RIV2J.js";import"../chunk-YRPUM6JG.js";import"../chunk-7Q3OCSPV.js";import"../chunk-RL3OEL5W.js";import"../chunk-5JKYJZAR.js";import"../chunk-IFCOOPD7.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-MGNMJ64X.js";import"../chunk-XIWAQH6S.js";import"../chunk-JTBQO6IT.js";import"../chunk-2X5HGMMO.js";export{a as releaseLeaseByToken};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a,b,c}from"../chunk-6ATIPILE.js";import"../chunk-XEK46DXF.js";import"../chunk-VD57XFNA.js";import"../chunk-YRPUM6JG.js";import"../chunk-TKIAVV2O.js";import"../chunk-L57CP5UJ.js";import"../chunk-QWAZLLE2.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-TXAIJEXA.js";import"../chunk-JTBQO6IT.js";import"../chunk-WS6UFNKF.js";export{b as activateIdentity,a as provisionIdentityUnexposed,c as rollbackUnexposedIdentity};
2
+ import{a,b,c}from"../chunk-7ZZWD64L.js";import"../chunk-AH3RIV2J.js";import"../chunk-YRPUM6JG.js";import"../chunk-7Q3OCSPV.js";import"../chunk-RL3OEL5W.js";import"../chunk-5JKYJZAR.js";import"../chunk-IFCOOPD7.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-MGNMJ64X.js";import"../chunk-XIWAQH6S.js";import"../chunk-JTBQO6IT.js";import"../chunk-2X5HGMMO.js";export{b as activateIdentity,a as provisionIdentityUnexposed,c as rollbackUnexposedIdentity};
package/dist/index.d.ts CHANGED
@@ -4,4 +4,5 @@ export * from './client/select.js';
4
4
  export * from './version-advisory.js';
5
5
  export { FILE_SELECTION_CAP } from './constants.js';
6
6
  export type { HistoryFile, HistoryMessage, HistoryPage, HistoryQuery, HistorySummary, } from './history.js';
7
+ export type { HistoryRetentionState, HistoryStorageStatus } from './history-retention.js';
7
8
  export type { MessageReceivedRecord, MessengerNotificationEvent, NotificationEvent, ReceiptKind, ReceiptReceivedRecord, SyncRequiredRecord, UnknownNotificationEvent, } from './events.js';
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a as U,b,c as z,d as B,e as D,f as G,g as J,h as V}from"./chunk-O2K2ME7S.js";import{a as T}from"./chunk-6DRJYMF2.js";import{a as W}from"./chunk-5EWCIQH6.js";import{A as I,B as L,C as P,D as _,E as h,F as k,G as l,H as q,I as w,J as A,K,L as O,M as Q,a as o,b as r,c as t,d as i,e as s,f as n,g as c,h as p,i as y,j as f,k as m,l as R,m as a,n as d,o as x,p as v,q as E,r as H,s as g,t as N,u,v as M,w as S,x as j,y as C,z as F}from"./chunk-65KGEJBX.js";import{a as e}from"./chunk-Y3VPZJTG.js";import"./chunk-JTBQO6IT.js";import"./chunk-WS6UFNKF.js";export{B as DAEMON_TOKEN_FILE,z as DEFAULT_DAEMON_PORT,U as DaemonSelectionError,b as DaemonUnavailableError,e as FILE_SELECTION_CAP,T as OursClient,o as OursError,J as assertDaemonStateDir,V as attachOursClient,G as describeDaemonConfig,t as errBindingReassigned,N as errBoundElsewhere,i as errBoundIdentityGone,K as errDuplicateId,k as errFileTooLarge,P as errFileUnreadable,M as errIdentityClosedWithError,j as errIdentityPartiallyRemoved,w as errInvalidSelection,A as errMalformedId,n as errNameTaken,c as errNoLeaseHeaders,v as errNoLeaseToken,F as errNoPolicyArgs,q as errNoRoot,x as errNoSuchIdentity,r as errNotBound,f as errNotBoundNoName,m as errNotTemporary,d as errPathNotAbsolute,C as errPublicInviteNamed,p as errRandomNameExhausted,y as errRootExists,S as errRootHasRoles,l as errSaveFileFallback,I as errSendFileArgs,L as errSendFileFilenameRequired,_ as errSendFileUploadArgs,a as errTempClosedWithError,s as errTempClosingBound,E as errTempClosingChoose,R as errTempOwnedElsewhereClose,u as errTempOwnedElsewhereRemove,H as errTempOwnedLive,g as errTempStale,Q as errTool,O as errUnknownOrStaleId,h as errUploadNotFound,W as formatVersionAdvisory,D as resolveDaemonConfig};
2
+ import{a as U,b,c as z,d as B,e as D,f as G,g as J,h as V}from"./chunk-FCQYDCQA.js";import{a as T}from"./chunk-P2AAWXWI.js";import{a as W}from"./chunk-5EWCIQH6.js";import{A as F,B as I,C as L,D as P,E as _,F as k,G as l,H as q,I as w,J as A,K,L as O,M as Q,a as t,b as o,c as r,d as i,e as s,f as n,g as y,h as p,i as c,j as f,k as a,l as m,m as R,n as x,o as d,p as H,q as v,r as E,s as S,t as g,u,v as N,w as j,x as M,y as h,z as C}from"./chunk-65KGEJBX.js";import{a as e}from"./chunk-Y3VPZJTG.js";import"./chunk-JTBQO6IT.js";import"./chunk-2X5HGMMO.js";export{B as DAEMON_TOKEN_FILE,z as DEFAULT_DAEMON_PORT,U as DaemonSelectionError,b as DaemonUnavailableError,e as FILE_SELECTION_CAP,T as OursClient,t as OursError,J as assertDaemonStateDir,V as attachOursClient,G as describeDaemonConfig,r as errBindingReassigned,g as errBoundElsewhere,i as errBoundIdentityGone,K as errDuplicateId,k as errFileTooLarge,L as errFileUnreadable,N as errIdentityClosedWithError,M as errIdentityPartiallyRemoved,w as errInvalidSelection,A as errMalformedId,n as errNameTaken,y as errNoLeaseHeaders,H as errNoLeaseToken,C as errNoPolicyArgs,q as errNoRoot,d as errNoSuchIdentity,o as errNotBound,f as errNotBoundNoName,a as errNotTemporary,x as errPathNotAbsolute,h as errPublicInviteNamed,p as errRandomNameExhausted,c as errRootExists,j as errRootHasRoles,l as errSaveFileFallback,F as errSendFileArgs,I as errSendFileFilenameRequired,P as errSendFileUploadArgs,R as errTempClosedWithError,s as errTempClosingBound,v as errTempClosingChoose,m as errTempOwnedElsewhereClose,u as errTempOwnedElsewhereRemove,E as errTempOwnedLive,S as errTempStale,Q as errTool,O as errUnknownOrStaleId,_ as errUploadNotFound,W as formatVersionAdvisory,D as resolveDaemonConfig};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a as k,b as w,c as y,d as p}from"../chunk-CHDY74S7.js";import{a as m}from"../chunk-EHCBEY52.js";import{d as l}from"../chunk-WS6UFNKF.js";import*as n from"node:fs";var D=l(),a=null;async function d(){if(m(),a)return{lock:a,acquired:!1};let t=await p(D.stateDir);n.mkdirSync(t.stateDir,{recursive:!0,mode:448});let o=n.realpathSync.native(t.stateDir);if(o!==t.stateDir)throw await t.close(),new Error(`state directory canonical path changed during lock acquisition: locked ${JSON.stringify(t.stateDir)}, created ${JSON.stringify(o)}`);return a=t,{lock:t,acquired:!0}}async function r(t){a===t&&(a=null,await t.close())}async function R(){let{lock:t,acquired:o}=await d();try{let{bootWrapper:e}=await import("../boot.js");await e()}catch(e){throw o&&await r(t),e}}async function O(t={}){let{lock:o,acquired:e}=await d();try{let i=await import("../http/server.js"),{onRuntimeLoaded:u,...f}=t;u?.();let c=await i.startDaemon({...f,onShutdown:async()=>r(o)}),s=!1;return{port:c.port,close:async()=>{if(!s){s=!0;try{await c.close()}finally{await r(o)}}}}}catch(i){throw e&&await r(o),i}}export{k as StateRootLockedError,R as bootKernel,w as canonicalStateDir,O as startDaemon,y as stateRootLockPath};
2
+ import{a as k,b as w,c as y,d as p}from"../chunk-CHDY74S7.js";import{a as m}from"../chunk-N4N4OLEW.js";import{e as l}from"../chunk-2X5HGMMO.js";import*as n from"node:fs";var D=l(),a=null;async function d(){if(m(),a)return{lock:a,acquired:!1};let t=await p(D.stateDir);n.mkdirSync(t.stateDir,{recursive:!0,mode:448});let o=n.realpathSync.native(t.stateDir);if(o!==t.stateDir)throw await t.close(),new Error(`state directory canonical path changed during lock acquisition: locked ${JSON.stringify(t.stateDir)}, created ${JSON.stringify(o)}`);return a=t,{lock:t,acquired:!0}}async function r(t){a===t&&(a=null,await t.close())}async function R(){let{lock:t,acquired:o}=await d();try{let{bootWrapper:e}=await import("../boot.js");await e()}catch(e){throw o&&await r(t),e}}async function O(t={}){let{lock:o,acquired:e}=await d();try{let i=await import("../http/server.js"),{onRuntimeLoaded:u,...f}=t;u?.();let c=await i.startDaemon({...f,onShutdown:async()=>r(o)}),s=!1;return{port:c.port,close:async()=>{if(!s){s=!0;try{await c.close()}finally{await r(o)}}}}}catch(i){throw e&&await r(o),i}}export{k as StateRootLockedError,R as bootKernel,w as canonicalStateDir,O as startDaemon,y as stateRootLockPath};
@@ -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-FMQOOSOQ.js";import"../chunk-XEK46DXF.js";import"../chunk-VD57XFNA.js";import"../chunk-YRPUM6JG.js";import"../chunk-TKIAVV2O.js";import"../chunk-L57CP5UJ.js";import"../chunk-QWAZLLE2.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-TXAIJEXA.js";import"../chunk-JTBQO6IT.js";import"../chunk-WS6UFNKF.js";export{a as findSibling,d as parseSendVerdict,c as sendViaLocalBook,b as sendViaSibling};
2
+ import{a,b,c,d}from"../chunk-WBCVUXOI.js";import"../chunk-AH3RIV2J.js";import"../chunk-YRPUM6JG.js";import"../chunk-7Q3OCSPV.js";import"../chunk-RL3OEL5W.js";import"../chunk-5JKYJZAR.js";import"../chunk-IFCOOPD7.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-MGNMJ64X.js";import"../chunk-XIWAQH6S.js";import"../chunk-JTBQO6IT.js";import"../chunk-2X5HGMMO.js";export{a as findSibling,d as parseSendVerdict,c as sendViaLocalBook,b as sendViaSibling};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{h as a}from"../chunk-XEK46DXF.js";import"../chunk-VD57XFNA.js";import"../chunk-YRPUM6JG.js";import"../chunk-TKIAVV2O.js";import"../chunk-L57CP5UJ.js";import"../chunk-QWAZLLE2.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-TXAIJEXA.js";import"../chunk-JTBQO6IT.js";import"../chunk-WS6UFNKF.js";export{a as wireHandlers};
2
+ import{h as a}from"../chunk-AH3RIV2J.js";import"../chunk-YRPUM6JG.js";import"../chunk-7Q3OCSPV.js";import"../chunk-RL3OEL5W.js";import"../chunk-5JKYJZAR.js";import"../chunk-IFCOOPD7.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-MGNMJ64X.js";import"../chunk-XIWAQH6S.js";import"../chunk-JTBQO6IT.js";import"../chunk-2X5HGMMO.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{A as b,B as c,C as d,D as e,E as f,z as a}from"../chunk-XEK46DXF.js";import"../chunk-VD57XFNA.js";import"../chunk-YRPUM6JG.js";import"../chunk-TKIAVV2O.js";import"../chunk-L57CP5UJ.js";import"../chunk-QWAZLLE2.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-TXAIJEXA.js";import"../chunk-JTBQO6IT.js";import"../chunk-WS6UFNKF.js";export{e as enqueueMutation,f as mutatingTx,c as readonlyTx,d as withLock,a as withScope,b as withScopeAsync};
2
+ import{A as b,B as c,C as d,D as e,E as f,z as a}from"../chunk-AH3RIV2J.js";import"../chunk-YRPUM6JG.js";import"../chunk-7Q3OCSPV.js";import"../chunk-RL3OEL5W.js";import"../chunk-5JKYJZAR.js";import"../chunk-IFCOOPD7.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-MGNMJ64X.js";import"../chunk-XIWAQH6S.js";import"../chunk-JTBQO6IT.js";import"../chunk-2X5HGMMO.js";export{e as enqueueMutation,f as mutatingTx,c as readonlyTx,d as withLock,a as withScope,b as withScopeAsync};
package/dist/notify.js CHANGED
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p}from"./chunk-VD57XFNA.js";import"./chunk-L57CP5UJ.js";import"./chunk-QWAZLLE2.js";import"./chunk-ZHH3PWEW.js";import"./chunk-Y3VPZJTG.js";import"./chunk-TXAIJEXA.js";import"./chunk-JTBQO6IT.js";import"./chunk-WS6UFNKF.js";export{e as NOTIFY_KIND_SETS,j as appendNotifyLog,k as binHexField,b as clearNotifyHook,c as fireNotify,h as fireNotifyWaiters,g as notifyEventMatches,d as notifyHooks,l as notifyLogSize,f as parseNotifyKinds,m as readNotifyRange,o as refreshUnread,n as serveNotifications,a as setNotifyHook,p as unreadSummary,i as waitForNotify};
2
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p}from"./chunk-7Q3OCSPV.js";import"./chunk-5JKYJZAR.js";import"./chunk-IFCOOPD7.js";import"./chunk-ZHH3PWEW.js";import"./chunk-Y3VPZJTG.js";import"./chunk-MGNMJ64X.js";import"./chunk-XIWAQH6S.js";import"./chunk-JTBQO6IT.js";import"./chunk-2X5HGMMO.js";export{e as NOTIFY_KIND_SETS,j as appendNotifyLog,k as binHexField,b as clearNotifyHook,c as fireNotify,h as fireNotifyWaiters,g as notifyEventMatches,d as notifyHooks,l as notifyLogSize,f as parseNotifyKinds,m as readNotifyRange,o as refreshUnread,n as serveNotifications,a as setNotifyHook,p 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}from"../chunk-EHCBEY52.js";import"../chunk-WS6UFNKF.js";export{a as assertConfigNotDrifted};
2
+ import{a}from"../chunk-N4N4OLEW.js";import"../chunk-2X5HGMMO.js";export{a as assertConfigNotDrifted};
@@ -6,6 +6,7 @@ export declare const STATE_DIR: string;
6
6
  export declare const BROKER_URL: string;
7
7
  export declare const PORT: number;
8
8
  export declare const GC_INTERVAL_MS: number;
9
+ export declare const HISTORY_MAX_BYTES: number;
9
10
  export declare const API_VISIBILITY: import("../config").ApiVisibility;
10
11
  export declare const startupProgress: StartupProgressReporter | null;
11
12
  export declare const log: (...parts: unknown[]) => boolean;
@@ -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-QWAZLLE2.js";import"../chunk-ZHH3PWEW.js";import"../chunk-WS6UFNKF.js";export{j as API_TOKEN,g as API_VISIBILITY,o as BOOK_DIR_NAME,d as BROKER_URL,b as CONFIG,f as GC_INTERVAL_MS,n as NAME_RE,e as PORT,c as STATE_DIR,a as VERSION,l as authOk,i as log,m as requireAuth,h as startupProgress,k as tokenFromReq,p as validateName};
2
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q}from"../chunk-IFCOOPD7.js";import"../chunk-ZHH3PWEW.js";import"../chunk-2X5HGMMO.js";export{k as API_TOKEN,h as API_VISIBILITY,p as BOOK_DIR_NAME,d as BROKER_URL,b as CONFIG,f as GC_INTERVAL_MS,g as HISTORY_MAX_BYTES,o as NAME_RE,e as PORT,c as STATE_DIR,a as VERSION,m as authOk,j as log,n as requireAuth,i as startupProgress,l as tokenFromReq,q 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{v as a,w as b,x as c,y as d}from"./chunk-XEK46DXF.js";import"./chunk-VD57XFNA.js";import"./chunk-YRPUM6JG.js";import"./chunk-TKIAVV2O.js";import"./chunk-L57CP5UJ.js";import"./chunk-QWAZLLE2.js";import"./chunk-ZHH3PWEW.js";import"./chunk-Y3VPZJTG.js";import"./chunk-TXAIJEXA.js";import"./chunk-JTBQO6IT.js";import"./chunk-WS6UFNKF.js";export{a as ensureRegistrar,b as hasSavedState,c as saveState,d as saveStateFailClosed};
2
+ import{v as a,w as b,x as c,y as d}from"./chunk-AH3RIV2J.js";import"./chunk-YRPUM6JG.js";import"./chunk-7Q3OCSPV.js";import"./chunk-RL3OEL5W.js";import"./chunk-5JKYJZAR.js";import"./chunk-IFCOOPD7.js";import"./chunk-ZHH3PWEW.js";import"./chunk-Y3VPZJTG.js";import"./chunk-MGNMJ64X.js";import"./chunk-XIWAQH6S.js";import"./chunk-JTBQO6IT.js";import"./chunk-2X5HGMMO.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{a,b,c,d,e,f,g}from"./chunk-XEK46DXF.js";import"./chunk-VD57XFNA.js";import"./chunk-YRPUM6JG.js";import"./chunk-TKIAVV2O.js";import"./chunk-L57CP5UJ.js";import"./chunk-QWAZLLE2.js";import"./chunk-ZHH3PWEW.js";import"./chunk-Y3VPZJTG.js";import"./chunk-TXAIJEXA.js";import"./chunk-JTBQO6IT.js";import"./chunk-WS6UFNKF.js";export{e as capabilityReconcileSweep,d as contactRestoreSweep,g as e2eRecoverySweep,c as flushDeferredFor,b as renderDeferredQueues,a as renderDegraded,f as scheduleCapabilityReconcile};
2
+ import{a,b,c,d,e,f,g}from"./chunk-AH3RIV2J.js";import"./chunk-YRPUM6JG.js";import"./chunk-7Q3OCSPV.js";import"./chunk-RL3OEL5W.js";import"./chunk-5JKYJZAR.js";import"./chunk-IFCOOPD7.js";import"./chunk-ZHH3PWEW.js";import"./chunk-Y3VPZJTG.js";import"./chunk-MGNMJ64X.js";import"./chunk-XIWAQH6S.js";import"./chunk-JTBQO6IT.js";import"./chunk-2X5HGMMO.js";export{e as capabilityReconcileSweep,d as contactRestoreSweep,g as e2eRecoverySweep,c as flushDeferredFor,b as renderDeferredQueues,a as renderDegraded,f as scheduleCapabilityReconcile};
package/dist/uploads.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}from"./chunk-IOL6KZNO.js";import"./chunk-L57CP5UJ.js";import"./chunk-QWAZLLE2.js";import"./chunk-ZHH3PWEW.js";import"./chunk-Y3VPZJTG.js";import"./chunk-TXAIJEXA.js";import"./chunk-WS6UFNKF.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};
2
+ import{a,b,c,d,e,f,g,h}from"./chunk-4QU3AKO6.js";import"./chunk-5JKYJZAR.js";import"./chunk-IFCOOPD7.js";import"./chunk-ZHH3PWEW.js";import"./chunk-Y3VPZJTG.js";import"./chunk-MGNMJ64X.js";import"./chunk-XIWAQH6S.js";import"./chunk-2X5HGMMO.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": "3.0.4",
3
+ "version": "3.1.0",
4
4
  "types": "./dist/index.d.ts",
5
5
  "type": "module",
6
6
  "license": "FSL-1.1-Apache-2.0",
@@ -39,7 +39,7 @@
39
39
  "pretest": "bash scripts/compile-mufl.sh && node test/cli-packed-artifact.test.mjs",
40
40
  "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-service-launchd.test.mjs && node test/cli-command.test.mjs && node test/cli-help.test.mjs",
41
41
  "//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.",
42
- "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/state-root-singleton.test.mjs && 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/temp-reaper-policy.test.mjs && node test/tx-lock.test.mjs && node test/wire-handlers-integrity.test.mjs && node test/moved-blocks-integrity.test.mjs && node test/external-history-boundary.test.mjs && node test/history-store.test.mjs && node test/ux-literals.test.mjs && node test/dist-shared-state.test.mjs && node test/public-boundary.test.mjs && node test/api-error-parity.test.mjs && node test/files-helpers.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-service-launchd.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/api-files.test.mjs && node test/file-upload.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/restore-hierarchy-readiness.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"
42
+ "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/state-root-singleton.test.mjs && 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/temp-reaper-policy.test.mjs && node test/tx-lock.test.mjs && node test/wire-handlers-integrity.test.mjs && node test/moved-blocks-integrity.test.mjs && node test/external-history-boundary.test.mjs && node test/history-store.test.mjs && node test/history-retention.test.mjs && node test/ux-literals.test.mjs && node test/dist-shared-state.test.mjs && node test/public-boundary.test.mjs && node test/api-error-parity.test.mjs && node test/files-helpers.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-service-launchd.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/api-files.test.mjs && node test/file-upload.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/restore-hierarchy-readiness.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"
43
43
  },
44
44
  "dependencies": {
45
45
  "@adapt-toolkit/sdk": "0.10.12",
@@ -1,4 +0,0 @@
1
- import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{a as d}from"./chunk-3FAS7737.js";import{h as F,j as S,k,l as v}from"./chunk-DIRW7I4S.js";import{I,J as x,K as $,L as C,M as p}from"./chunk-65KGEJBX.js";import{o as b}from"./chunk-VD57XFNA.js";import{t as w,u as y}from"./chunk-L57CP5UJ.js";import{b as f}from"./chunk-QWAZLLE2.js";import{a as u}from"./chunk-Y3VPZJTG.js";import{p as g,q as _}from"./chunk-TXAIJEXA.js";import{readFile as O}from"node:fs/promises";async function D(s){let r=d(s);try{return g(r)}catch(o){throw p("list_incoming_files",String(o))}}async function G(s,r={}){let o=d(s),{wire_ids:i}=r;if(i!==void 0){if(i.length<1||i.length>32)throw I(32);if(i.some(n=>!w(n)))throw x();if(new Set(i).size!==i.length)throw $()}try{let n=_(o,{wire_ids:i,limit:r.limit}),l=[],a=[];for(let e of n.files){let h={file_id:e.file_id,wire_id:e.wire_id,from:e.from,filename:e.filename,path:e.blob_path,mime:e.mime,size:e.byte_length,sha256:e.sha256,status:"processed",date:e.date,kind:e.kind,sender:e.from.name};if(e.kind==="voice_message"){let c=F(f.stt),m;if(!c.ready)m={kind:"unconfigured",reason:c.reason};else try{let t=await S(await O(e.blob_path),e.filename,e.mime,f.stt);m=t.ok?{kind:"transcript",text:t.text}:{kind:"failed",error:t.error}}catch(t){m={kind:"failed",error:t instanceof Error?t.message:String(t)}}h.transcription=k(c,m,{audioPath:e.blob_path,wireId:e.wire_id}),a.push(v({sender:e.from.name,wire:e.wire_id,savedPath:e.blob_path,sizeBytes:e.byte_length},m))}else a.push(` \u2022 ${e.filename} (${e.mime}, ${e.byte_length} B, sha256 ${e.sha256}) from ${e.from.name} \u2192 ${e.blob_path} {${e.wire_id}}`);l.push(h)}return b(o),{files:l,text:a.length===0?"No new files.":`${a.length} new file(s) available from immutable identity blob storage (bytes stay on disk, never in this result):
3
- ${a.join(`
4
- `)}`,mode:i===void 0?"all_unread":"selected",requested:i??null,remaining:n.remaining}}catch(n){let l=String(n);throw i!==void 0&&/unknown, stale, or no longer unread/i.test(l)?C():p("get_files",l)}}function L(s,r){let o=d(s);return{existsOnDisk:y(o,r.wire_id)!==null}}export{D as a,G as b,L as c};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
- import{d as o}from"./chunk-WS6UFNKF.js";var n=["OURS_STATE_DIR","OURS_BROKER_URL","OURS_PORT","OURS_API_VISIBILITY","OURS_CONFIG"],i=Object.fromEntries(n.map(e=>[e,process.env[e]])),{stateDir:s,brokerUrl:a}=o();function c(){let e=n.filter(t=>process.env[t]!==i[t]);if(e.length===0)return;let r=e.map(t=>`${t}: was ${JSON.stringify(i[t]??"(unset)")} at import, is now ${JSON.stringify(process.env[t]??"(unset)")}`).join("; ");throw new Error(`configuration changed after @ours.network/sdk was imported (${r}). The SDK reads its config ONCE, at module load, because CONFIG and STATE_DIR back process-wide singletons that cannot be re-pointed once identities exist. Setting these after the import does not fail and does not take effect \u2014 without this check the daemon would boot against ${JSON.stringify(s)} and broker ${JSON.stringify(a)} and look like it worked. Set every OURS_* config variable BEFORE the first import of this package.`)}export{c as a};