shennian 0.4.37 → 0.4.38

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.
@@ -556,8 +556,8 @@
556
556
  },
557
557
  {
558
558
  "file": "src/personal-sync/machine-authority.js",
559
- "beforeBytes": 1835,
560
- "afterBytes": 1127
559
+ "beforeBytes": 2742,
560
+ "afterBytes": 1456
561
561
  },
562
562
  {
563
563
  "file": "src/personal-sync/metrics.js",
@@ -9,3 +9,4 @@ export declare function synchronizeMachinePersonalAuthority(input: {
9
9
  machineId?: string | null;
10
10
  fetchImpl?: typeof fetch;
11
11
  }): Promise<MachinePersonalAuthority>;
12
+ export declare function fetchMachineAuthorityResponse(url: string, machineToken: string, request?: typeof fetch): Promise<Response>;
@@ -1 +1 @@
1
- import{SESSION_SYNC_DATA_EPOCH as r}from"@shennian/wire";import{loadConfig as i,saveConfig as t}from"../config/index.js";import{getDaemonInstallationId as h}from"./identity.js";async function d(e){const n=await(e.fetchImpl??fetch)(`${e.serverUrl.replace(/\/+$/,"")}/api/machines/identity`,{headers:{Authorization:`Bearer ${e.machineToken}`},signal:AbortSignal.timeout(1e4)});if(!n.ok)throw new Error(`machine_personal_authority_unavailable:${n.status}`);const a=await n.json();if(typeof a.machineId!="string"||!a.machineId||typeof a.daemonInstallationId!="string"||!a.daemonInstallationId||typeof a.dataEpoch!="number"||!Number.isSafeInteger(a.dataEpoch))throw new Error("machine_personal_authority_invalid_response");if(e.machineId&&a.machineId!==e.machineId)throw new Error("machine_personal_authority_machine_mismatch");if(a.daemonInstallationId!==h())throw new Error("machine_personal_authority_daemon_mismatch");if(a.dataEpoch!==r)throw new Error("machine_personal_authority_epoch_mismatch");const o=i();return o.machineId!==a.machineId&&t({...o,machineId:a.machineId}),a}export{d as synchronizeMachinePersonalAuthority};
1
+ import{setTimeout as h}from"node:timers/promises";import{SESSION_SYNC_DATA_EPOCH as s}from"@shennian/wire";import{loadConfig as m,saveConfig as d}from"../config/index.js";import{getDaemonInstallationId as l}from"./identity.js";async function y(a){const t=await f(`${a.serverUrl.replace(/\/+$/,"")}/api/machines/identity`,a.machineToken,a.fetchImpl);if(!t.ok)throw new Error(`machine_personal_authority_unavailable:${t.status}`);const e=await t.json();if(typeof e.machineId!="string"||!e.machineId||typeof e.daemonInstallationId!="string"||!e.daemonInstallationId||typeof e.dataEpoch!="number"||!Number.isSafeInteger(e.dataEpoch))throw new Error("machine_personal_authority_invalid_response");if(a.machineId&&e.machineId!==a.machineId)throw new Error("machine_personal_authority_machine_mismatch");if(e.daemonInstallationId!==l())throw new Error("machine_personal_authority_daemon_mismatch");if(e.dataEpoch!==s)throw new Error("machine_personal_authority_epoch_mismatch");const o=m();return o.machineId!==e.machineId&&d({...o,machineId:e.machineId}),e}async function f(a,t,e=fetch){const o=AbortSignal.timeout(1e4);for(let n=0;;n+=1)try{return await e(a,{headers:{Authorization:`Bearer ${t}`},signal:o})}catch(r){const i=r,c=i?.cause?.code??i?.code;if(o.aborted||n>=2||!["ECONNRESET","EPIPE","UND_ERR_SOCKET"].includes(c??""))throw r;await h(250*(n+1),void 0,{signal:o})}}export{f as fetchMachineAuthorityResponse,y as synchronizeMachinePersonalAuthority};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shennian",
3
- "version": "0.4.37",
3
+ "version": "0.4.38",
4
4
  "description": "Shennian — AI Agent Control Plane CLI",
5
5
  "type": "module",
6
6
  "bin": {