pi-fabric 0.63.0 → 0.64.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 (29) hide show
  1. package/dist/chunks/{chunk-GSRA4TLG.js → chunk-725BGPJU.js} +49 -4
  2. package/dist/chunks/{chunk-GSRA4TLG.js.map → chunk-725BGPJU.js.map} +2 -2
  3. package/dist/chunks/{chunk-EPJ43EJL.js → chunk-EBGSP7Q7.js} +3 -3
  4. package/dist/chunks/{chunk-X32MQBTA.js → chunk-GFZYWVIK.js} +24 -1
  5. package/dist/chunks/chunk-GFZYWVIK.js.map +7 -0
  6. package/dist/chunks/{chunk-7ROLP6PW.js → chunk-OKQHLYTU.js} +2 -2
  7. package/dist/chunks/{chunk-XDPWNKQK.js → chunk-UACA2AKF.js} +107 -2
  8. package/dist/chunks/{chunk-XDPWNKQK.js.map → chunk-UACA2AKF.js.map} +3 -3
  9. package/dist/chunks/{fabric-runtime-state-4IOX6EHS.js → fabric-runtime-state-STCXP7AK.js} +6 -6
  10. package/dist/commands/fabric.d.ts.map +1 -1
  11. package/dist/core/action-registry.js +2 -2
  12. package/dist/index.js +62 -5
  13. package/dist/index.js.map +2 -2
  14. package/dist/protocol.d.ts +59 -0
  15. package/dist/protocol.d.ts.map +1 -1
  16. package/dist/protocol.js +9 -1
  17. package/dist/residency/host.js +2 -2
  18. package/dist/topology/participant-directory.d.ts.map +1 -1
  19. package/dist/topology/peer-settle.d.ts +52 -0
  20. package/dist/topology/peer-settle.d.ts.map +1 -0
  21. package/dist/topology/types.d.ts +7 -0
  22. package/dist/topology/types.d.ts.map +1 -1
  23. package/dist/worker.js +0 -0
  24. package/docs/agents.md +11 -0
  25. package/package.json +16 -14
  26. package/dist/chunks/chunk-X32MQBTA.js.map +0 -7
  27. /package/dist/chunks/{chunk-EPJ43EJL.js.map → chunk-EBGSP7Q7.js.map} +0 -0
  28. /package/dist/chunks/{chunk-7ROLP6PW.js.map → chunk-OKQHLYTU.js.map} +0 -0
  29. /package/dist/chunks/{fabric-runtime-state-4IOX6EHS.js.map → fabric-runtime-state-STCXP7AK.js.map} +0 -0
@@ -16,8 +16,9 @@ import {
16
16
  normalizeVedaModel
17
17
  } from "./chunk-VPPIJRNZ.js";
18
18
  import {
19
+ peerLabelPrefix,
19
20
  writeHandoffSession
20
- } from "./chunk-XDPWNKQK.js";
21
+ } from "./chunk-UACA2AKF.js";
21
22
  import {
22
23
  FABRIC_ACTOR_HOST_EVENTS,
23
24
  readJsonlPage
@@ -5612,6 +5613,7 @@ var FabricControlPlane = class {
5612
5613
  // src/topology/participant-directory.ts
5613
5614
  import { createHash as createHash3 } from "node:crypto";
5614
5615
  var PARTICIPANT_PREFIX = "topology/participants/";
5616
+ var PEER_SEQ_KEY = "topology/peer-seq";
5615
5617
  var HOST_PREFIX = "topology/hosts/";
5616
5618
  var LEGACY_SESSION_PREFIX = "sessions/";
5617
5619
  var LEGACY_ACTOR_PREFIX = "actors/";
@@ -5663,7 +5665,8 @@ var peerFromParticipant = (participant) => {
5663
5665
  }
5664
5666
  return {
5665
5667
  id: participant.id,
5666
- name: "Peer " + participant.sessionId.slice(0, 8),
5668
+ name: participant.label ?? "Peer " + participant.sessionId.slice(0, 8),
5669
+ ...participant.label ? { label: participant.label } : {},
5667
5670
  kind: "peer",
5668
5671
  status: participant.status,
5669
5672
  runner: "pi",
@@ -5977,6 +5980,7 @@ var ParticipantDirectory = class {
5977
5980
  desired.set(record.id, record);
5978
5981
  }
5979
5982
  }
5983
+ await this.#ensurePeerLabels(desired);
5980
5984
  this.#localRecords.clear();
5981
5985
  for (const [id, record] of desired) this.#localRecords.set(id, record);
5982
5986
  if (!this.options.enabled) return;
@@ -6008,7 +6012,8 @@ var ParticipantDirectory = class {
6008
6012
  key: legacySessionKey,
6009
6013
  value: {
6010
6014
  id: root.id,
6011
- name: `Peer ${root.sessionId.slice(0, 8)}`,
6015
+ name: root.label ?? `Peer ${root.sessionId.slice(0, 8)}`,
6016
+ ...root.label ? { label: root.label } : {},
6012
6017
  kind: "peer",
6013
6018
  status: root.status === "running" ? "running" : "idle",
6014
6019
  runner: "pi",
@@ -6076,6 +6081,46 @@ var ParticipantDirectory = class {
6076
6081
  await this.mesh.delete({ key: entry.key, ifVersion: entry.version }).catch(() => void 0);
6077
6082
  }
6078
6083
  }
6084
+ /**
6085
+ * Mint missing labels for this host's root participants. Labels persist in
6086
+ * the peer's own participant record, so every session computes the same
6087
+ * label and retired numbers are never reused even if a peer record dies.
6088
+ */
6089
+ async #ensurePeerLabels(desired) {
6090
+ if (!this.options.enabled) return;
6091
+ for (const record of desired.values()) {
6092
+ if (record.kind !== "root" || record.id !== this.options.rootId || record.label) continue;
6093
+ const existingEntry = this.mesh.get(keyFor(PARTICIPANT_PREFIX, record.id));
6094
+ const existing = existingEntry ? participantFromEntry(existingEntry) : void 0;
6095
+ if (existing?.label) {
6096
+ record.label = existing.label;
6097
+ continue;
6098
+ }
6099
+ const seq = await this.#claimPeerSeq();
6100
+ if (seq !== void 0) record.label = `${peerLabelPrefix(record.cwd)}-${seq}`;
6101
+ }
6102
+ }
6103
+ /** CAS-claim the next project-wide peer sequence number. ifVersion 0 creates. */
6104
+ async #claimPeerSeq() {
6105
+ for (let attempt = 0; attempt < 8; attempt += 1) {
6106
+ const entry = this.mesh.get(PEER_SEQ_KEY);
6107
+ const current = entry && isObject4(entry.value) && typeof entry.value.next === "number" && Number.isInteger(entry.value.next) && entry.value.next >= 1 ? entry.value.next : 0;
6108
+ try {
6109
+ await this.mesh.put({
6110
+ key: PEER_SEQ_KEY,
6111
+ value: { format: 1, next: current + 1 },
6112
+ identity: this.options.identity,
6113
+ ifVersion: entry?.version ?? 0
6114
+ });
6115
+ return current + 1;
6116
+ } catch (error) {
6117
+ if (!/compare-and-swap/.test(error instanceof Error ? error.message : String(error))) {
6118
+ throw error;
6119
+ }
6120
+ }
6121
+ }
6122
+ return void 0;
6123
+ }
6079
6124
  #legacySessionKey() {
6080
6125
  if (this.options.identity.kind !== "main") return void 0;
6081
6126
  return `sessions/${this.options.identity.sessionId ?? this.options.identity.id}`;
@@ -6186,4 +6231,4 @@ export {
6186
6231
  residentRoot,
6187
6232
  residentDeliveryPrefix
6188
6233
  };
6189
- //# sourceMappingURL=chunk-GSRA4TLG.js.map
6234
+ //# sourceMappingURL=chunk-725BGPJU.js.map