@plur-ai/core 0.9.5 → 0.9.6
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/index.d.ts +10 -0
- package/dist/index.js +38 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2252,6 +2252,16 @@ declare class Plur {
|
|
|
2252
2252
|
* freshness and closes the race. See issue #25.
|
|
2253
2253
|
*/
|
|
2254
2254
|
private _writeEngrams;
|
|
2255
|
+
/**
|
|
2256
|
+
* Resolve a remote store for a write scope. Returns the RemoteStore driver
|
|
2257
|
+
* if the engram's scope matches a registered remote entry, else null.
|
|
2258
|
+
*
|
|
2259
|
+
* Match rule (pilot scope): exact-match `entry.scope === engramScope`. We
|
|
2260
|
+
* intentionally don't do prefix-match yet — agents that want to write to a
|
|
2261
|
+
* narrower scope than they registered must explicitly register the narrower
|
|
2262
|
+
* scope. Keeps routing predictable and prevents accidental cross-team writes.
|
|
2263
|
+
*/
|
|
2264
|
+
private _resolveRemoteStoreForScope;
|
|
2255
2265
|
/** Find which store owns an engram by ID. For namespaced IDs, strips prefix to find in store. */
|
|
2256
2266
|
private _findEngramStore;
|
|
2257
2267
|
/** Content hash fast-path dedup. */
|
package/dist/index.js
CHANGED
|
@@ -3442,6 +3442,31 @@ var Plur = class {
|
|
|
3442
3442
|
saveEngrams(path3, engrams);
|
|
3443
3443
|
this._engramCache.delete(path3);
|
|
3444
3444
|
}
|
|
3445
|
+
/**
|
|
3446
|
+
* Resolve a remote store for a write scope. Returns the RemoteStore driver
|
|
3447
|
+
* if the engram's scope matches a registered remote entry, else null.
|
|
3448
|
+
*
|
|
3449
|
+
* Match rule (pilot scope): exact-match `entry.scope === engramScope`. We
|
|
3450
|
+
* intentionally don't do prefix-match yet — agents that want to write to a
|
|
3451
|
+
* narrower scope than they registered must explicitly register the narrower
|
|
3452
|
+
* scope. Keeps routing predictable and prevents accidental cross-team writes.
|
|
3453
|
+
*/
|
|
3454
|
+
_resolveRemoteStoreForScope(scope) {
|
|
3455
|
+
const stores = this.config.stores ?? [];
|
|
3456
|
+
for (const entry of stores) {
|
|
3457
|
+
if (!entry.url) continue;
|
|
3458
|
+
if (entry.readonly === true) continue;
|
|
3459
|
+
if (entry.scope !== scope) continue;
|
|
3460
|
+
const key = `${entry.url}::${entry.scope}`;
|
|
3461
|
+
let driver = this._remoteStores.get(key);
|
|
3462
|
+
if (!driver) {
|
|
3463
|
+
driver = new RemoteStore(entry.url, entry.token ?? "", entry.scope);
|
|
3464
|
+
this._remoteStores.set(key, driver);
|
|
3465
|
+
}
|
|
3466
|
+
return driver;
|
|
3467
|
+
}
|
|
3468
|
+
return null;
|
|
3469
|
+
}
|
|
3445
3470
|
/** Find which store owns an engram by ID. For namespaced IDs, strips prefix to find in store. */
|
|
3446
3471
|
_findEngramStore(id) {
|
|
3447
3472
|
const primaryEngrams = this._loadCached(this.paths.engrams);
|
|
@@ -3572,6 +3597,19 @@ var Plur = class {
|
|
|
3572
3597
|
} : void 0,
|
|
3573
3598
|
pinned: context?.pinned === true ? true : void 0
|
|
3574
3599
|
};
|
|
3600
|
+
const remoteDriver = this._resolveRemoteStoreForScope(scope);
|
|
3601
|
+
if (remoteDriver) {
|
|
3602
|
+
void remoteDriver.append(engram).catch((err) => {
|
|
3603
|
+
logger.error(`[plur:learn] remote append failed for ${engram.id} (scope=${scope}): ${err.message}`);
|
|
3604
|
+
});
|
|
3605
|
+
appendHistory(this.paths.root, {
|
|
3606
|
+
event: "engram_created",
|
|
3607
|
+
engram_id: engram.id,
|
|
3608
|
+
timestamp: now,
|
|
3609
|
+
data: { type: engram.type, scope: engram.scope, source: engram.source, routed_to: "remote" }
|
|
3610
|
+
});
|
|
3611
|
+
return engram;
|
|
3612
|
+
}
|
|
3575
3613
|
engrams.push(engram);
|
|
3576
3614
|
this._writeEngrams(this.paths.engrams, engrams);
|
|
3577
3615
|
this._syncIndex();
|