beeos-claw 0.6.50-staging.4 → 0.6.50
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{randomUUID}from"node:crypto";import{mkdir,readFile}from"node:fs/promises";import{dirname}from"node:path";import{withOwnedDirectoryLock}from"./owned-directory-lock.js";import{MonotonicJournalSegments}from"./monotonic-journal-segments.js";export class RuntimeRegistrationIdentityStore{file;createId;segments;constructor(t,e=randomUUID){this.file=t,this.createId=e,this.segments=new MonotonicJournalSegments(t)}async acquire(t,e){if(!t)throw new Error("invalid runtime registration identity inputs");return await mkdir(dirname(this.file),{recursive:!0,mode:448}),await withOwnedDirectoryLock(`${this.file}.lock`,async
|
|
1
|
+
import{randomUUID}from"node:crypto";import{mkdir,readFile}from"node:fs/promises";import{dirname}from"node:path";import{withOwnedDirectoryLock}from"./owned-directory-lock.js";import{MonotonicJournalSegments}from"./monotonic-journal-segments.js";export class RuntimeRegistrationIdentityStore{file;createId;segments;constructor(t,e=randomUUID){this.file=t,this.createId=e,this.segments=new MonotonicJournalSegments(t)}async acquire(t,e){if(!t)throw new Error("invalid runtime registration identity inputs");return await mkdir(dirname(this.file),{recursive:!0,mode:448}),await withOwnedDirectoryLock(`${this.file}.lock`,async n=>{const r=await this.segments.authorityFloor(),i=await this.read(),o=await e.lineage();if(i&&i.handlerIdentity===t&&i.journalStoreId===o.journalStoreId&&i.journalGeneration===o.journalGeneration)return identityOf(i);if(i&&i.journalStoreId!==o.journalStoreId)throw new Error("runtime registration journal store changed");const a=i&&BigInt(o.journalGeneration)>BigInt(i.journalGeneration)?o:await e.advanceLineageGeneration({journalStoreId:o.journalStoreId,floor:i?.journalGeneration??o.journalGeneration}),s={version:1,registrationId:this.createId(),handlerIdentity:t,...a,updatedAt:(new Date).toISOString()};return await n.assertOwned(),await this.publish(n.epoch,s,r),identityOf(s)},{epochFloor:()=>this.segments.authorityFloor()})}async roll(t,e,n){if(!(t.handlerIdentity&&t.registrationId&&t.journalStoreId&&/^[1-9][0-9]*$/.test(t.journalGeneration)))throw new Error("invalid runtime registration identity inputs");return await mkdir(dirname(this.file),{recursive:!0,mode:448}),await withOwnedDirectoryLock(`${this.file}.lock`,async r=>{const i=await this.segments.authorityFloor(),o=await this.read();if(!o||identityKey(o)!==identityKey(t))throw new Error("runtime registration identity was fenced by a successor");const a=await e.lineage();if(a.journalStoreId!==t.journalStoreId||BigInt(a.journalGeneration)<BigInt(t.journalGeneration))throw new Error("runtime registration journal lineage changed");const s=await nextRollLineage(e,a,t,n),l={version:1,registrationId:this.createId(),handlerIdentity:t.handlerIdentity,...s,updatedAt:(new Date).toISOString()};return await r.assertOwned(),await this.publish(r.epoch,l,i),identityOf(l)},{epochFloor:()=>this.segments.authorityFloor()})}async read(){const t=new Map;try{const e=JSON.parse(await readFile(this.file,"utf8"));if(!(1===e.version&&e.registrationId&&e.handlerIdentity&&e.journalStoreId&&/^[1-9][0-9]*$/.test(e.journalGeneration)))throw new Error("invalid runtime registration identity");t.set("snapshot",{value:e,logicalRevision:e.journalGeneration,publisherEpoch:"0"})}catch(t){if("ENOENT"!==t.code)throw t}return(await this.segments.reduce(t)).get("snapshot")?.value??null}async publish(t,e,n){await this.segments.publish(t,[{key:"snapshot",logicalRevision:e.journalGeneration,value:structuredClone(e)}],n),await this.segments.prune()}}const identityOf=t=>({registrationId:t.registrationId,handlerIdentity:t.handlerIdentity,journalStoreId:t.journalStoreId,journalGeneration:t.journalGeneration}),identityKey=t=>`${t.registrationId}\0${t.handlerIdentity}\0${t.journalStoreId}\0${t.journalGeneration}`;async function nextRollLineage(t,e,n,r){const i=r?.expectedJournalGeneration??(r?.authorityCurrentGeneration?String(BigInt(r.authorityCurrentGeneration)+1n):void 0);if(i){const r=BigInt(e.journalGeneration),o=BigInt(i);if(r===o)return e;if(r>o)throw new Error(`runtime registration journal generation overshot authority (local=${r} expected=${o})`);return await t.advanceLineageGeneration({journalStoreId:n.journalStoreId,floor:String(o-1n)})}return BigInt(e.journalGeneration)>BigInt(n.journalGeneration)?e:await t.advanceLineageGeneration({journalStoreId:n.journalStoreId,floor:n.journalGeneration})}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "beeos-claw",
|
|
3
|
-
"version": "0.6.50
|
|
3
|
+
"version": "0.6.50",
|
|
4
4
|
"description": "OpenClaw plugin that bridges the BeeOS platform with the local OpenClaw Gateway, providing file transfer, ACP bridge, and observability.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "BeeOS <dev@beeos.ai>",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"fast-uri": ">=3.1.4",
|
|
88
88
|
"brace-expansion": ">=5.0.9"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "d9deb49b32657c1bfefc868b9d756fa1fd7f6eb4"
|
|
91
91
|
}
|