pi-fabric 0.134.2 → 0.134.3
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/capture/catalog.d.ts +2 -0
- package/dist/capture/catalog.d.ts.map +1 -1
- package/dist/capture/interceptor.d.ts.map +1 -1
- package/dist/chunks/{chunk-TJZYM2SP.js → chunk-73PJDZEW.js} +7 -2
- package/dist/chunks/{chunk-TJZYM2SP.js.map → chunk-73PJDZEW.js.map} +2 -2
- package/dist/chunks/{chunk-2PGWCW3U.js → chunk-7CUJ2LSZ.js} +5 -4
- package/dist/chunks/chunk-7CUJ2LSZ.js.map +7 -0
- package/dist/chunks/{chunk-Y5G7FIMS.js → chunk-HX24MUUW.js} +69 -2
- package/dist/chunks/{chunk-Y5G7FIMS.js.map → chunk-HX24MUUW.js.map} +2 -2
- package/dist/chunks/{chunk-3MOY6WIB.js → chunk-INWD6VB2.js} +2 -2
- package/dist/chunks/{chunk-77VTDEMK.js → chunk-JQRYL27I.js} +2 -1
- package/dist/chunks/chunk-JQRYL27I.js.map +7 -0
- package/dist/chunks/{chunk-2OHH3LEE.js → chunk-OR44GYXD.js} +10 -1
- package/dist/chunks/chunk-OR44GYXD.js.map +7 -0
- package/dist/chunks/{chunk-ERBER25H.js → chunk-PPTFUSAA.js} +2 -2
- package/dist/chunks/{chunk-3IECLMEY.js → chunk-UUGA3BMX.js} +1 -1
- package/dist/chunks/{chunk-AP5QMWFD.js → chunk-YUTHVQH2.js} +13 -9
- package/dist/chunks/chunk-YUTHVQH2.js.map +7 -0
- package/dist/cli/decisions.js +1 -1
- package/dist/cli/mesh.js +2 -2
- package/dist/core/prompt-guidance.js +1 -1
- package/dist/core/prompt-guidance.js.map +2 -2
- package/dist/durable-extension.js +1 -1
- package/dist/durable-extension.js.map +1 -1
- package/dist/extension-bootstrap.js +2 -2
- package/dist/fabric-runtime-state.js +14 -11
- package/dist/fabric-runtime-state.js.map +2 -2
- package/dist/index.js +2 -2
- package/dist/jev.js +1 -1
- package/dist/mesh/store.d.ts +2 -1
- package/dist/mesh/store.d.ts.map +1 -1
- package/dist/providers/jev-provider.js +1 -1
- package/dist/providers/pi-tools-provider.d.ts +7 -0
- package/dist/providers/pi-tools-provider.d.ts.map +1 -1
- package/dist/providers/sessions-provider.d.ts +1 -1
- package/dist/providers/sessions-provider.d.ts.map +1 -1
- package/dist/residency/host.d.ts.map +1 -1
- package/dist/residency/host.js +3 -3
- package/dist/residency/pi-entry.js +3 -3
- package/dist/runtime/core-override-guest-types.js +2 -2
- package/dist/runtime/guest-types.d.ts +1 -1
- package/dist/runtime/guest-types.d.ts.map +1 -1
- package/dist/runtime/guest-types.js +1 -1
- package/dist/runtime/typescript-kernel.js +2 -2
- package/dist/topology/participant-directory.d.ts.map +1 -1
- package/dist/type-error-guidance.js +1 -1
- package/dist/ui/conversation-native-reader.d.ts.map +1 -1
- package/dist/ui/conversation-native-reader.js +1 -1
- package/dist/ui/conversation-native-reader.js.map +2 -2
- package/docs/agents.md +1 -1
- package/docs/background-tasks.md +2 -1
- package/docs/configuration.md +1 -1
- package/package.json +1 -1
- package/skillsets/python/fabric-council/SKILL.md +36 -9
- package/skillsets/python/fabric-exec/SKILL.md +1 -1
- package/skillsets/typescript/fabric-council/SKILL.md +38 -5
- package/skillsets/typescript/fabric-exec/SKILL.md +1 -1
- package/dist/chunks/chunk-2OHH3LEE.js.map +0 -7
- package/dist/chunks/chunk-2PGWCW3U.js.map +0 -7
- package/dist/chunks/chunk-77VTDEMK.js.map +0 -7
- package/dist/chunks/chunk-AP5QMWFD.js.map +0 -7
- /package/dist/chunks/{chunk-3MOY6WIB.js.map → chunk-INWD6VB2.js.map} +0 -0
- /package/dist/chunks/{chunk-ERBER25H.js.map → chunk-PPTFUSAA.js.map} +0 -0
- /package/dist/chunks/{chunk-3IECLMEY.js.map → chunk-UUGA3BMX.js.map} +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/residency/host.ts"],
|
|
4
|
+
"sourcesContent": ["#!/usr/bin/env node\n\nimport { randomUUID } from \"node:crypto\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport {\n writeJsonAtomic,\n ownerHeartbeatFields,\n recordOwnerLiveness,\n startOwnerHeartbeat,\n} from \"../core/atomic-write.js\";\nimport {\n normalizeModelAliases,\n resolvePiModelSelector,\n type FabricModelCandidate,\n type FabricModelMatch,\n} from \"../core/model-resolution.js\";\nimport { loadModelUsage } from \"../core/model-usage.js\";\nimport {\n parseFabricOwnedModelGuidance,\n resolveFabricModelGuidance,\n} from \"../components/model-guidance.js\";\nimport { ActorDirectory } from \"../actors/directory.js\";\nimport type { FabricActorInfo } from \"../actors/types.js\";\nimport { AgentManager } from \"../agents/manager.js\";\nimport { cancelOrphanedChildQuestions, routeChildQuestion } from \"../decisions/host.js\";\nimport { DecisionStore } from \"../decisions/store.js\";\nimport { launchScope } from \"../scope.js\";\nimport { useBudgetLedger } from \"../agents/budget-ledger.js\";\nimport { LifecycleBroker } from \"../lifecycle/broker.js\";\nimport { lifecycleSourceIdentity, type FabricLifecycleEvent, type FabricLifecycleSubscription } from \"../lifecycle/types.js\";\nimport { MeshStore, type MeshIdentity } from \"../mesh/store.js\";\nimport { FabricControlPlane, type FabricControlAcceptance, type FabricControlCommand } from \"../topology/control-plane.js\";\nimport { ParticipantDirectory } from \"../topology/participant-directory.js\";\nimport { actorParticipantRecord, agentParticipantRecords } from \"../topology/records.js\";\nimport {\n RESIDENT_HOST_FORMAT,\n residentDeliveryPrefix,\n residentHostId,\n type ResidentAgentMetadata,\n type ResidentCommand,\n type ResidentCommandResponse,\n type ResidentDeliveryRecord,\n type ResidentHostConfig,\n type ResidentHostOwner,\n} from \"./protocol.js\";\n\nconst REQUEST_POLL_MS = 50;\nconst IDLE_EXIT_MS = 30_000;\nconst COMPLETION_MAX_CHARS = 8_000;\n\nconst delay = (ms: number): Promise<void> =>\n new Promise((resolve) => setTimeout(resolve, ms));\n\nconst atomicWrite = (filePath: string, value: unknown): void => {\n writeJsonAtomic(filePath, value, { space: 2 });\n};\n\nconst readJson = <T>(filePath: string): T | undefined => {\n try {\n return JSON.parse(fs.readFileSync(filePath, \"utf8\")) as T;\n } catch {\n return undefined;\n }\n};\n\nconst errorMessage = (error: unknown): string =>\n error instanceof Error ? error.message : String(error);\n\nconst processAlive = (pid: number): boolean => {\n if (!Number.isSafeInteger(pid) || pid <= 0) return false;\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n // On Windows, EPERM means the process exists but cannot be opened for\n // signaling; only ESRCH (or other errors) mean it is gone.\n return error instanceof Error && \"code\" in error && (error as NodeJS.ErrnoException).code === \"EPERM\";\n }\n};\n\n// Identity-less (pre-heartbeat) owners keep the plain signal probe; an owner\n// in another PID namespace is judged by its heartbeat, and \"unknown\" is not death.\nconst ownerAlive = (record: unknown): boolean =>\n recordOwnerLiveness(record, { legacyAlive: processAlive }) !== \"dead\";\n\n// The resident host runs Pi with --no-extensions, so a custom runner is only\n// registered here when its residentModule is imported (once per process).\nconst runnerModules = new Map<string, Promise<void>>();\nconst loadRunnerModule = (specifier: string): Promise<void> => {\n if (!/^(?:\\/|[A-Za-z]:[\\\\/]|file:)/.test(specifier)) {\n return Promise.reject(new Error(`Fabric runner module must be absolute: ${specifier}`));\n }\n const url = specifier.startsWith(\"file:\") ? specifier : pathToFileURL(specifier).href;\n let pending = runnerModules.get(url);\n if (!pending) {\n pending = import(url).then(() => undefined);\n runnerModules.set(url, pending);\n pending.catch(() => runnerModules.delete(url));\n }\n return pending;\n};\n\nclass ResidentHostAlreadyRunning extends Error {}\n\nconst parseResidentHostConfigPath = (argv: readonly string[]): string => {\n const index = argv.indexOf(\"--config\");\n const value = index >= 0 ? argv[index + 1] : undefined;\n if (!value) throw new Error(\"Missing resident host argument: --config\");\n return path.resolve(value);\n};\n\nconst validateResidentHostConfig = (value: unknown, configPath: string): ResidentHostConfig => {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n throw new Error(\"Invalid Fabric resident host config\");\n }\n const config = value as Partial<ResidentHostConfig>;\n if (\n config.format !== RESIDENT_HOST_FORMAT ||\n typeof config.rootId !== \"string\" ||\n typeof config.sessionId !== \"string\" ||\n typeof config.cwd !== \"string\" ||\n typeof config.projectRoot !== \"string\" ||\n typeof config.meshRoot !== \"string\" ||\n typeof config.actorRoot !== \"string\" ||\n (config.sessionActorRoot !== undefined && typeof config.sessionActorRoot !== \"string\") ||\n typeof config.residencyRoot !== \"string\" ||\n typeof config.fullCodeMode !== \"boolean\" ||\n (config.kernel !== undefined && config.kernel !== \"typescript\" && config.kernel !== \"python\") ||\n (config.pythonRuntime !== undefined && config.pythonRuntime !== \"cpython\" && config.pythonRuntime !== \"monty\") ||\n typeof config.agents !== \"object\" ||\n config.agents === null ||\n typeof config.mesh !== \"object\" ||\n config.mesh === null ||\n typeof config.retention !== \"object\" ||\n config.retention === null ||\n typeof config.workerPath !== \"string\" ||\n typeof config.fabricExtensionPath !== \"string\" ||\n typeof config.piBinary !== \"string\" ||\n typeof config.claudeBinary !== \"string\" ||\n typeof config.vedaBinary !== \"string\"\n ) {\n throw new Error(\"Fabric resident host config is incomplete\");\n }\n if (path.resolve(config.residencyRoot) !== path.dirname(configPath)) {\n throw new Error(\"Fabric resident host config is outside its residency root\");\n }\n if (!config.mesh.enabled) throw new Error(\"Durable residency requires the Fabric mesh\");\n return config as ResidentHostConfig;\n};\n\n/**\n * The resident host's idle rule. Live durable participants, queued work or a\n * pending request keep it alive; pending mesh schedules do too while at least\n * one durable participant could receive them, and `wakeAt` names the next due\n * time so the host releases it on time. Without durable participants a\n * schedule waits for the next Fabric process that touches the mesh.\n */\nexport const residentIdleDecision = (input: {\n now: number;\n idleSince: number;\n activeActor: boolean;\n activeAgent: boolean;\n pendingRequest: boolean;\n durableParticipants: boolean;\n nextScheduleDueAt: number | undefined;\n idleExitMs?: number;\n}): { busy: boolean; exit: boolean; wakeAt?: number } => {\n const holdsSchedules = input.nextScheduleDueAt !== undefined && input.durableParticipants;\n const wakeAt = holdsSchedules ? input.nextScheduleDueAt : undefined;\n const busy = input.activeActor || input.activeAgent || input.pendingRequest || holdsSchedules;\n const exit = !busy && input.now - input.idleSince >= (input.idleExitMs ?? IDLE_EXIT_MS);\n return { busy, exit, ...(wakeAt !== undefined ? { wakeAt } : {}) };\n};\n\nclass ResidentHost {\n readonly hostId: string;\n readonly identity: MeshIdentity;\n readonly mesh: MeshStore;\n readonly participants: ParticipantDirectory;\n readonly control: FabricControlPlane;\n readonly agents: AgentManager;\n readonly actors: ActorDirectory;\n readonly lifecycle: LifecycleBroker;\n readonly #decisions: DecisionStore;\n readonly #ownerPath: string;\n readonly #lockPath: string;\n readonly #errorPath: string;\n readonly #requestsPath: string;\n readonly #processingPath: string;\n readonly #responsesPath: string;\n readonly #agentsPath: string;\n readonly #deliveryPrefix: string;\n readonly #token = randomUUID();\n #requestTimer: NodeJS.Timeout | undefined;\n #scheduleTimer: NodeJS.Timeout | undefined;\n #scheduleWakeAt: number | undefined;\n #stopHeartbeat: (() => void) | undefined;\n #pollingRequests = false;\n #closed = false;\n #started = false;\n #idleSince = Date.now();\n\n constructor(\n readonly config: ResidentHostConfig,\n readonly onIdle: () => void = () => {},\n ) {\n this.hostId = residentHostId(config.rootId);\n this.identity = { id: this.hostId, name: \"Fabric resident host\", kind: \"agent\" };\n this.#ownerPath = path.join(config.residencyRoot, \"owner.json\");\n this.#lockPath = path.join(config.residencyRoot, \"host.lock\");\n this.#errorPath = path.join(config.residencyRoot, \"error.json\");\n this.#requestsPath = path.join(config.residencyRoot, \"requests\");\n this.#processingPath = path.join(config.residencyRoot, \"processing\");\n this.#responsesPath = path.join(config.residencyRoot, \"responses\");\n this.#agentsPath = path.join(config.residencyRoot, \"agents\");\n this.#deliveryPrefix = residentDeliveryPrefix(config.rootId);\n this.mesh = new MeshStore(config.meshRoot, config.mesh.maxEventBytes, config.mesh.maxReadEvents, {\n durability: config.mesh.durability,\n });\n this.control = new FabricControlPlane(this.mesh, this.identity, {\n enabled: true,\n hostId: this.hostId,\n pollMs: config.mesh.actorPollMs,\n });\n this.participants = new ParticipantDirectory(this.mesh, {\n enabled: true,\n hostId: this.hostId,\n rootId: config.rootId,\n identity: this.identity,\n ownerIncarnation: this.control.incarnation,\n departedRetentionMs: config.mesh.departedRetentionMs,\n });\n if (config.agents.budgetUsd > 0) {\n const budgetFile = path.join(config.residencyRoot, \"budget.jsonl\");\n fs.mkdirSync(path.dirname(budgetFile), { recursive: true, mode: 0o700 });\n if (!fs.existsSync(budgetFile)) fs.writeFileSync(budgetFile, \"\", { mode: 0o600 });\n useBudgetLedger({\n budget: config.agents.budgetUsd,\n file: budgetFile,\n id: this.hostId,\n });\n }\n const guidanceConfigPath = path.join(config.residencyRoot, \"config.json\");\n const currentConfig = (): Partial<ResidentHostConfig> =>\n readJson<Partial<ResidentHostConfig>>(guidanceConfigPath) ?? config;\n const currentModelGuidance = () =>\n parseFabricOwnedModelGuidance(currentConfig().modelGuidance ?? config.modelGuidance);\n const resolveResidentPiModel = (selector?: string, modelMatch?: FabricModelMatch): string => {\n const state = currentConfig().piModels ?? config.piModels;\n const available: FabricModelCandidate[] = Array.isArray(state?.available)\n ? state.available.flatMap((candidate) =>\n typeof candidate?.provider === \"string\" && typeof candidate.id === \"string\"\n ? [{\n provider: candidate.provider,\n id: candidate.id,\n ...(typeof candidate.name === \"string\" ? { name: candidate.name } : {}),\n }]\n : [],\n )\n : [];\n const query = selector?.trim() || state?.defaultModel?.trim() || \"\";\n const resolved = resolvePiModelSelector(query, {\n aliases: normalizeModelAliases(state?.aliases),\n available,\n lastUsed: loadModelUsage(),\n }, modelMatch);\n return `${resolved.provider}/${resolved.id}`;\n };\n // agents.childQuestions \"route\": this host has no UI, so a durable child's\n // dialog always becomes a root-held decision in the project mesh, answered\n // by a root session or the decisions CLI. The run's settlement cancels it, and\n // so does detaching a durable hosted run at shutdown (see #startOwned for a\n // host that died instead).\n this.#decisions = new DecisionStore(this.mesh, {\n id: this.identity.id,\n name: this.identity.name,\n kind: this.identity.kind,\n sessionId: config.sessionId,\n });\n this.agents = new AgentManager(config.cwd, config.agents, {\n workerPath: config.workerPath,\n fabricExtensionPath: config.fabricExtensionPath,\n piBinary: config.piBinary,\n claudeBinary: config.claudeBinary,\n vedaBinary: config.vedaBinary,\n runRoot: path.join(config.residencyRoot, \"runs\"),\n fullCodeMode: config.fullCodeMode,\n kernel: () => currentConfig().kernel ?? config.kernel ?? \"typescript\",\n pythonRuntime: () => currentConfig().pythonRuntime ?? config.pythonRuntime ?? \"monty\",\n mainAgentId: config.rootId,\n fabricSessionId: config.sessionId,\n meshRoot: config.meshRoot,\n projectRoot: config.projectRoot,\n hostId: this.hostId,\n identityId: this.identity.id,\n retention: config.retention,\n preparePiModel: async (model, options) => resolveResidentPiModel(model, options?.modelMatch),\n resolveParticipantGuidance: ({ model }) => {\n if (!model) return undefined;\n return resolveFabricModelGuidance(currentModelGuidance(), {\n model,\n target: \"participant\",\n includeSlots: false,\n }).appendText || undefined;\n },\n onLifecycle: (event) => void this.lifecycle?.publish(event).catch(() => undefined),\n onChildQuestion: (request) => routeChildQuestion(request, { store: this.#decisions }),\n onBackgroundComplete: (result) => {\n if (!config.agents.notifyOnComplete) return;\n const durationMs = Math.max(0, (result.finishedAt ?? Date.now()) - result.startedAt);\n const summary = (result.text || result.error || \"no result\").slice(0, COMPLETION_MAX_CHARS);\n void this.#queueDelivery(\n { id: result.id, name: result.name, kind: \"agent\" },\n `Fabric agent ${result.id.slice(0, 8)} ${result.status} after ${Math.round(durationMs / 1_000)}s: ${summary}`,\n \"steer\",\n true,\n result,\n result.id,\n ).catch(() => undefined);\n },\n });\n const canManageActor = (id: string): boolean | undefined => {\n const participant = this.participants.get(id);\n return participant ? participant.ownerHostId === this.hostId : undefined;\n };\n const lineageAlive = (rootId: string): boolean =>\n this.participants.get(rootId) !== undefined;\n const actorRoots = config.sessionActorRoot\n ? { project: config.actorRoot, session: config.sessionActorRoot }\n : config.mesh.actorScope === \"session\"\n ? { project: path.dirname(config.actorRoot), session: config.actorRoot }\n : { project: config.actorRoot, session: path.join(config.actorRoot, config.sessionId) };\n this.actors = new ActorDirectory([\n config.sessionId,\n this.identity,\n this.mesh,\n config.mesh,\n this.agents,\n ({ actor, message, delivery, triggerTurn }) => {\n if (!message.text) return;\n const mode = delivery === \"steer\" ? \"steer\" : \"followUp\";\n const triggers = delivery === \"nextTurn\" ? false : triggerTurn;\n void this.#queueDelivery(\n { id: actor.id, name: actor.name, kind: \"actor\" },\n message.text,\n mode,\n triggers,\n message.data,\n ).catch(() => undefined);\n },\n {\n persistent: true,\n canManageActor,\n lineageAlive,\n claimResidency: \"durable\",\n rootId: config.rootId,\n meshCursorPath: path.join(config.residencyRoot, \"actor-mesh-cursor.json\"),\n retention: config.retention,\n resolvePiModel: resolveResidentPiModel,\n },\n ], actorRoots, config.mesh.actorScope);\n this.lifecycle = new LifecycleBroker(\n this.mesh,\n this.identity,\n this.participants,\n {\n enabled: true,\n pollMs: config.mesh.actorPollMs,\n maxReadEvents: config.mesh.maxReadEvents,\n },\n (subscription, event) => this.#deliverLifecycle(subscription, event),\n );\n }\n\n async start(): Promise<void> {\n if (this.#started) return;\n this.#acquireLock();\n this.#started = true;\n this.#stopHeartbeat = startOwnerHeartbeat((heartbeatAt) => this.#refreshHeartbeat(heartbeatAt));\n try {\n await this.#startOwned();\n } catch (error) {\n this.#stopHeartbeat();\n this.#stopHeartbeat = undefined;\n throw error;\n }\n }\n\n async #startOwned(): Promise<void> {\n fs.mkdirSync(this.#requestsPath, { recursive: true, mode: 0o700 });\n fs.mkdirSync(this.#processingPath, { recursive: true, mode: 0o700 });\n fs.mkdirSync(this.#responsesPath, { recursive: true, mode: 0o700 });\n fs.mkdirSync(this.#agentsPath, { recursive: true, mode: 0o700 });\n this.#recoverInterruptedRequests();\n // An earlier host that died left its routed questions open, and their answers\n // would reach nothing. Cancel them before re-attaching runs, whose runners ask\n // again through this host. A failure must not stop startup, but it leaves those\n // decisions open, so report it on stderr; the launcher keeps it in child-stderr.log.\n await cancelOrphanedChildQuestions(this.#decisions).catch((error: unknown) => {\n process.stderr.write(\n `[pi-fabric] resident host ${this.hostId} could not cancel orphaned child questions at startup: ${errorMessage(error)}\\n`,\n );\n return [];\n });\n await this.#recoverHostedRuns();\n const firstSeenAgents = new Map<string, number>();\n this.participants.registerSource(() =>\n agentParticipantRecords(\n this.agents.listForUi(),\n this.config.rootId,\n this.hostId,\n this.identity.id,\n this.config.rootId,\n firstSeenAgents,\n ),\n );\n this.participants.registerSource(() =>\n this.actors.listOwned().map((actor) =>\n actorParticipantRecord(\n actor,\n this.config.rootId,\n this.hostId,\n this.identity.id,\n this.config.rootId,\n ),\n ),\n );\n this.agents.subscribeUi(() => this.participants.scheduleRefresh());\n this.actors.subscribe(() => this.participants.scheduleRefresh());\n this.control.start((command, from, signal) =>\n this.#acceptControl(command, from, signal));\n await this.participants.start().catch(() => undefined);\n this.lifecycle.start();\n this.#requestTimer = setInterval(\n () => void this.#pollRequests().catch(() => undefined),\n REQUEST_POLL_MS,\n );\n const now = Date.now();\n const owner: ResidentHostOwner = {\n format: RESIDENT_HOST_FORMAT,\n hostId: this.hostId,\n pid: process.pid,\n token: this.#token,\n startedAt: now,\n readyAt: now,\n ...ownerHeartbeatFields(now),\n };\n atomicWrite(this.#ownerPath, owner);\n fs.rmSync(this.#errorPath, { force: true });\n await this.#pollRequests();\n }\n\n async close(): Promise<void> {\n if (this.#closed) return;\n this.#closed = true;\n if (this.#requestTimer) clearInterval(this.#requestTimer);\n this.#requestTimer = undefined;\n if (this.#scheduleTimer) clearTimeout(this.#scheduleTimer);\n this.#scheduleTimer = undefined;\n this.#stopHeartbeat?.();\n this.#stopHeartbeat = undefined;\n while (this.#pollingRequests) await delay(10);\n await this.participants.quiesce().catch(() => undefined);\n await this.lifecycle.close().catch(() => undefined);\n await this.control.close().catch(() => undefined);\n try {\n await this.actors.close();\n } finally {\n await this.agents.close();\n await this.participants.close().catch(() => undefined);\n this.#releaseLock();\n }\n }\n\n async #acceptControl(\n command: FabricControlCommand,\n _from: MeshIdentity,\n signal?: AbortSignal,\n ): Promise<FabricControlAcceptance> {\n if (command.operation === \"cancel\") {\n return { accepted: false, error: \"Cancel commands are handled by the control plane\" };\n }\n if (command.operation === \"stop\") {\n try {\n await this.agents.stop(command.targetId);\n this.participants.scheduleRefresh();\n return { accepted: true, messageId: command.commandId };\n } catch (error) {\n if (!(error instanceof Error && /Unknown Fabric agent/.test(error.message))) {\n return { accepted: false, error: errorMessage(error) };\n }\n }\n try {\n if (!this.actors.owns(command.targetId)) {\n return { accepted: false, error: `Resident host does not own ${command.targetId}` };\n }\n await this.actors.stop(command.targetId);\n this.participants.scheduleRefresh();\n return { accepted: true, messageId: command.commandId };\n } catch (error) {\n return { accepted: false, error: errorMessage(error) };\n }\n }\n const message = command.message?.trim();\n if (!message) return { accepted: false, error: \"Fabric control message must not be empty\" };\n if (command.operation === \"ask\") {\n try {\n if (!this.actors.owns(command.targetId)) {\n return { accepted: false, error: `Resident host does not own ${command.targetId}` };\n }\n const result = await this.actors.ask(\n command.targetId,\n message,\n command.data,\n signal,\n { ...(command.binding !== undefined ? { binding: command.binding } : {}), sender: command.sender ?? null },\n );\n return { accepted: true, messageId: result.id, result };\n } catch (error) {\n return { accepted: false, error: errorMessage(error) };\n }\n }\n try {\n this.agents.status(command.targetId);\n const result = command.operation === \"steer\"\n ? this.agents.steer(command.targetId, message, command.data)\n : this.agents.followUp(command.targetId, message, command.data);\n return { accepted: true, messageId: result.messageId };\n } catch (error) {\n if (!(error instanceof Error && /Unknown Fabric agent/.test(error.message))) {\n return { accepted: false, error: errorMessage(error) };\n }\n }\n try {\n if (!this.actors.owns(command.targetId)) {\n return { accepted: false, error: `Resident host does not own ${command.targetId}` };\n }\n const result = this.actors.tell(\n command.targetId,\n message,\n command.data,\n { ...(command.binding !== undefined ? { binding: command.binding } : {}), sender: command.sender ?? null },\n );\n return { accepted: true, messageId: result.messageId };\n } catch (error) {\n return { accepted: false, error: errorMessage(error) };\n }\n }\n\n async #deliverLifecycle(\n subscription: FabricLifecycleSubscription,\n event: FabricLifecycleEvent,\n ): Promise<void> {\n const message = `Fabric lifecycle ${event.event} from ${event.source.name} (${event.source.id})${event.status ? ` with status ${event.status}` : \"\"}.`;\n if (subscription.to === this.config.rootId) {\n await this.#queueDelivery(\n lifecycleSourceIdentity(event.source),\n message,\n subscription.delivery,\n subscription.triggerTurn,\n event,\n );\n return;\n }\n try {\n this.agents.status(subscription.to);\n if (subscription.delivery === \"steer\") this.agents.steer(subscription.to, message, event);\n else this.agents.followUp(subscription.to, message, event);\n return;\n } catch (error) {\n if (!(error instanceof Error && /Unknown Fabric agent/.test(error.message))) throw error;\n }\n try {\n if (this.actors.owns(subscription.to)) {\n this.actors.tell(subscription.to, message, event);\n return;\n }\n } catch {\n // Route through the current remote owner below.\n }\n const target = this.participants.get(subscription.to);\n if (!target) throw new Error(`Unknown Fabric lifecycle target: ${subscription.to}`);\n await this.control.request(\n target.ownerHostId,\n target.id,\n subscription.delivery,\n {\n message,\n data: event,\n triggerTurn: subscription.triggerTurn,\n ...(target.ownerIncarnation ? { ownerIncarnation: target.ownerIncarnation } : {}),\n },\n target.ownerIdentityId,\n );\n }\n\n async #queueDelivery(\n from: MeshIdentity,\n message: string,\n delivery: \"steer\" | \"followUp\",\n triggerTurn: boolean,\n data?: unknown,\n agentCompletionId?: string,\n ): Promise<void> {\n const id = randomUUID();\n const record: ResidentDeliveryRecord = {\n format: RESIDENT_HOST_FORMAT,\n id,\n rootId: this.config.rootId,\n from,\n delivery,\n triggerTurn,\n message,\n ...(data === undefined ? {} : { data }),\n ...(agentCompletionId ? { agentCompletionId } : {}),\n createdAt: Date.now(),\n };\n try {\n await this.mesh.put({\n key: `${this.#deliveryPrefix}${id}`,\n value: record,\n identity: this.identity,\n ifVersion: 0,\n });\n } catch {\n await this.mesh.put({\n key: `${this.#deliveryPrefix}${id}`,\n value: {\n ...record,\n message: message.slice(0, Math.max(1, this.config.mesh.eventContextChars)),\n data: { fabricTruncated: true },\n },\n identity: this.identity,\n ifVersion: 0,\n });\n }\n }\n\n async #pollRequests(): Promise<void> {\n if (this.#pollingRequests || this.#closed) return;\n this.#pollingRequests = true;\n try {\n let entries: string[];\n try {\n entries = fs.readdirSync(this.#requestsPath).filter((entry) => entry.endsWith(\".json\"));\n } catch {\n return;\n }\n for (const entry of entries.slice(0, 32)) {\n const source = path.join(this.#requestsPath, entry);\n const processing = path.join(this.#processingPath, entry);\n try {\n fs.renameSync(source, processing);\n } catch {\n continue;\n }\n await this.#processRequest(processing);\n }\n } finally {\n this.#pollingRequests = false;\n this.#checkIdle();\n }\n }\n\n #checkIdle(): void {\n const activeActor = this.actors\n .listOwned()\n .some((actor) => actor.residency === \"durable\" && actor.status !== \"stopped\");\n const activeAgent = this.agents\n .listForUi()\n .some((agent) => agent.status === \"queued\" || agent.status === \"running\");\n let pendingRequest = false;\n try {\n pendingRequest = fs.readdirSync(this.#requestsPath).some((entry) => entry.endsWith(\".json\"));\n } catch {\n // Missing request directory is empty.\n }\n let nextScheduleDueAt: number | undefined;\n try {\n nextScheduleDueAt = this.mesh.nextScheduleDueAt();\n } catch {\n // Unreadable schedules neither keep the host alive nor stop it.\n }\n const now = Date.now();\n const decision = residentIdleDecision({\n now,\n idleSince: this.#idleSince,\n activeActor,\n activeAgent,\n pendingRequest,\n durableParticipants: activeActor || activeAgent,\n nextScheduleDueAt,\n });\n this.#armScheduleWake(decision.wakeAt);\n if (decision.busy) {\n this.#idleSince = now;\n return;\n }\n if (decision.exit) this.onIdle();\n }\n\n // Re-armed on every idle check: the due time of the earliest pending\n // schedule, released here even if no actor monitor polls in time.\n #armScheduleWake(wakeAt: number | undefined): void {\n if (wakeAt === this.#scheduleWakeAt) return;\n if (this.#scheduleTimer) clearTimeout(this.#scheduleTimer);\n this.#scheduleTimer = undefined;\n this.#scheduleWakeAt = wakeAt;\n if (wakeAt === undefined || this.#closed) return;\n this.#scheduleTimer = setTimeout(() => {\n this.#scheduleTimer = undefined;\n this.#scheduleWakeAt = undefined;\n void this.mesh.releaseDueSchedules().catch(() => undefined).finally(() => {\n if (!this.#closed) this.#checkIdle();\n });\n }, Math.min(Math.max(0, wakeAt - Date.now()), 2_147_000_000));\n this.#scheduleTimer.unref();\n }\n\n async #processRequest(filePath: string): Promise<void> {\n const command = readJson<ResidentCommand>(filePath);\n const requestId = command?.requestId ?? path.basename(filePath, \".json\");\n let response: ResidentCommandResponse;\n try {\n if (\n command?.format !== RESIDENT_HOST_FORMAT ||\n command.rootId !== this.config.rootId ||\n command.requestId !== requestId\n ) {\n throw new Error(\"Invalid Fabric residency request\");\n }\n if (command.operation === \"spawn\") {\n if (\n command.request.sessionSeed ||\n command.request.forkSeed ||\n command.request.sessionFile ||\n command.request.actorId ||\n command.request.actorName ||\n command.request.meshRoot ||\n command.request.runnerSessionId ||\n command.request.systemPrompt ||\n command.request.images\n ) {\n throw new Error(\"Durable agents.spawn accepts only its public task and run settings\");\n }\n if (command.runnerModule) await loadRunnerModule(command.runnerModule);\n const handle = await this.agents.spawn({ ...command.request, residency: \"durable\" });\n // spawn already validated the forwarded scope; record what the child received.\n const scope = launchScope(command.request.scope, command.request.inheritedScope);\n const runDirectory = this.agents.runDirectory(handle.id);\n if (!runDirectory) throw new Error(`Resident agent ${handle.id} has no run directory`);\n const worktreeGitRoot = this.agents.worktreeGitRoot(handle.id);\n const metadata: ResidentAgentMetadata = {\n format: RESIDENT_HOST_FORMAT,\n rootId: this.config.rootId,\n id: handle.id,\n runDirectory,\n handle: { ...handle, residency: \"durable\" },\n ...(worktreeGitRoot ? { worktreeGitRoot } : {}),\n ...(command.runnerModule ? { runnerModule: command.runnerModule } : {}),\n ...(scope ? { scope } : {}),\n createdAt: Date.now(),\n updatedAt: Date.now(),\n };\n atomicWrite(path.join(this.#agentsPath, `${handle.id}.json`), metadata);\n // Publish ownership before a fast, already-settled spawn can notify Main.\n this.agents.detachSignal(handle.id);\n response = {\n format: RESIDENT_HOST_FORMAT,\n requestId,\n ok: true,\n handle: metadata.handle,\n completedAt: Date.now(),\n };\n } else if (command.operation === \"foreground\") {\n this.agents.markForeground(command.id);\n response = {\n format: RESIDENT_HOST_FORMAT,\n requestId,\n ok: true,\n completedAt: Date.now(),\n };\n } else if (command.operation === \"cleanup\") {\n await this.agents.wait(command.id);\n await this.agents.cleanup(command.id, command.deleteBranch);\n fs.rmSync(path.join(this.#agentsPath, `${command.id}.json`), { force: true });\n response = {\n format: RESIDENT_HOST_FORMAT,\n requestId,\n ok: true,\n completedAt: Date.now(),\n };\n } else if (command.operation === \"createActor\") {\n if (command.request.residency !== \"durable\") {\n throw new Error(\"Resident host createActor only supports durable residency\");\n }\n // This handler already runs inside the authoritative durable host.\n // Keep the new actor locally owned; ceding it here created a needless\n // self-transfer window that blocked the next recruitment request.\n const actor = await this.actors.create(command.request, { asRegistryOwner: true });\n response = {\n format: RESIDENT_HOST_FORMAT,\n requestId,\n ok: true,\n actor: actor as FabricActorInfo,\n completedAt: Date.now(),\n };\n } else {\n if (!this.actors.owns(command.id)) {\n throw new Error(`Resident host does not own ${command.id}`);\n }\n await this.actors.remove(command.id);\n response = {\n format: RESIDENT_HOST_FORMAT,\n requestId,\n ok: true,\n completedAt: Date.now(),\n };\n }\n } catch (error) {\n response = {\n format: RESIDENT_HOST_FORMAT,\n requestId,\n ok: false,\n error: errorMessage(error),\n completedAt: Date.now(),\n };\n }\n atomicWrite(path.join(this.#responsesPath, `${requestId}.json`), response);\n fs.rmSync(filePath, { force: true });\n this.participants.scheduleRefresh();\n }\n\n /**\n * Re-import the runner modules recorded for this host's durable runs, then\n * re-attach their hosted runs from the persisted locators. A run whose\n * runner cannot be loaded settles indeterminate; nothing is re-submitted.\n */\n async #recoverHostedRuns(): Promise<void> {\n let entries: string[];\n try {\n entries = fs.readdirSync(this.#agentsPath).filter((entry) => entry.endsWith(\".json\"));\n } catch {\n entries = [];\n }\n const modules = new Set<string>();\n for (const entry of entries) {\n const metadata = readJson<ResidentAgentMetadata>(path.join(this.#agentsPath, entry));\n if (metadata?.rootId === this.config.rootId && typeof metadata.runnerModule === \"string\") {\n modules.add(metadata.runnerModule);\n }\n }\n for (const module of modules) await loadRunnerModule(module).catch(() => undefined);\n await this.agents.recoverHostedRuns().catch(() => []);\n // Opted-in pi-durable worker runs (agents.durableWorkerRecovery at launch).\n await this.agents.recoverWorkerRuns().catch(() => []);\n }\n\n #recoverInterruptedRequests(): void {\n let entries: string[];\n try {\n entries = fs.readdirSync(this.#processingPath).filter((entry) => entry.endsWith(\".json\"));\n } catch {\n return;\n }\n for (const entry of entries) {\n const requestId = path.basename(entry, \".json\");\n const response: ResidentCommandResponse = {\n format: RESIDENT_HOST_FORMAT,\n requestId,\n ok: false,\n error: \"Fabric residency outcome is indeterminate after resident host restart\",\n outcome: \"indeterminate\",\n completedAt: Date.now(),\n };\n atomicWrite(path.join(this.#responsesPath, entry), response);\n fs.rmSync(path.join(this.#processingPath, entry), { force: true });\n }\n }\n\n #acquireLock(): void {\n fs.mkdirSync(this.config.residencyRoot, { recursive: true, mode: 0o700 });\n const existing = readJson<ResidentHostOwner>(this.#ownerPath);\n if (existing && ownerAlive(existing)) {\n throw new ResidentHostAlreadyRunning(`Fabric resident host is already running (${existing.pid})`);\n }\n try {\n const descriptor = fs.openSync(this.#lockPath, \"wx\", 0o600);\n fs.writeFileSync(descriptor, JSON.stringify({ token: this.#token, pid: process.pid, ...ownerHeartbeatFields() }));\n fs.closeSync(descriptor);\n } catch (error) {\n if (error instanceof Error && \"code\" in error && error.code === \"EEXIST\") {\n const locked = readJson<{ pid?: unknown }>(this.#lockPath);\n if (typeof locked?.pid === \"number\" && ownerAlive(locked)) {\n throw new ResidentHostAlreadyRunning(`Fabric resident host is starting (${locked.pid})`);\n }\n fs.rmSync(this.#lockPath, { force: true });\n const descriptor = fs.openSync(this.#lockPath, \"wx\", 0o600);\n fs.writeFileSync(descriptor, JSON.stringify({ token: this.#token, pid: process.pid, ...ownerHeartbeatFields() }));\n fs.closeSync(descriptor);\n } else {\n throw error;\n }\n }\n }\n\n // Long-lived ownership: refresh both the start lock and owner.json while\n // they are still ours, so readers in other PID namespaces can judge us.\n #refreshHeartbeat(heartbeatAt: number): void {\n const lock = readJson<Record<string, unknown>>(this.#lockPath);\n if (lock?.token === this.#token) atomicWrite(this.#lockPath, { ...lock, heartbeatAt });\n const owner = readJson<ResidentHostOwner>(this.#ownerPath);\n if (owner?.token === this.#token) atomicWrite(this.#ownerPath, { ...owner, heartbeatAt });\n }\n\n #releaseLock(): void {\n const lock = readJson<{ token?: unknown }>(this.#lockPath);\n if (lock?.token === this.#token) fs.rmSync(this.#lockPath, { force: true });\n const owner = readJson<ResidentHostOwner>(this.#ownerPath);\n if (owner?.token === this.#token) fs.rmSync(this.#ownerPath, { force: true });\n }\n}\n\nconst runResidentHost = async (\n config: ResidentHostConfig,\n signal?: AbortSignal,\n): Promise<void> => {\n let finishIdle: (() => void) | undefined;\n const idle = new Promise<void>((resolve) => {\n finishIdle = resolve;\n });\n const host = new ResidentHost(config, () => finishIdle?.());\n await host.start();\n if (signal?.aborted) {\n await host.close();\n return;\n }\n await Promise.race([\n idle,\n new Promise<void>((resolve) => {\n const finish = (): void => resolve();\n signal?.addEventListener(\"abort\", finish, { once: true });\n process.once(\"SIGTERM\", finish);\n process.once(\"SIGINT\", finish);\n }),\n ]);\n await host.close();\n};\n\nexport const runResidentHostFromConfigPath = async (\n configPath: string,\n signal?: AbortSignal,\n): Promise<void> => {\n let config: ResidentHostConfig | undefined;\n try {\n config = validateResidentHostConfig(readJson<unknown>(configPath), configPath);\n await runResidentHost(config, signal);\n } catch (error) {\n if (error instanceof ResidentHostAlreadyRunning) return;\n const residencyRoot = config?.residencyRoot ?? path.dirname(configPath);\n try {\n atomicWrite(path.join(residencyRoot, \"error.json\"), {\n error: errorMessage(error),\n occurredAt: Date.now(),\n });\n } catch {\n // Startup diagnostics are best-effort.\n }\n throw error;\n }\n};\n\nconst isMain = process.argv[1] && path.resolve(process.argv[1]) === path.resolve(fileURLToPath(import.meta.url));\nif (isMain) {\n const configPath = parseResidentHostConfigPath(process.argv);\n try {\n await runResidentHostFromConfigPath(configPath);\n } catch {\n process.exitCode = 1;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,kBAAkB;AAC3B,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,eAAe,qBAAqB;AA2C7C,IAAM,kBAAkB;AACxB,IAAM,eAAe;AACrB,IAAM,uBAAuB;AAE7B,IAAM,QAAQ,CAAC,OACb,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AAElD,IAAM,cAAc,CAAC,UAAkB,UAAyB;AAC9D,kBAAgB,UAAU,OAAO,EAAE,OAAO,EAAE,CAAC;AAC/C;AAEA,IAAM,WAAW,CAAI,aAAoC;AACvD,MAAI;AACF,WAAO,KAAK,MAAM,GAAG,aAAa,UAAU,MAAM,CAAC;AAAA,EACrD,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,IAAM,eAAe,CAAC,UACpB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAEvD,IAAM,eAAe,CAAC,QAAyB;AAC7C,MAAI,CAAC,OAAO,cAAc,GAAG,KAAK,OAAO,EAAG,QAAO;AACnD,MAAI;AACF,YAAQ,KAAK,KAAK,CAAC;AACnB,WAAO;AAAA,EACT,SAAS,OAAO;AAGd,WAAO,iBAAiB,SAAS,UAAU,SAAU,MAAgC,SAAS;AAAA,EAChG;AACF;AAIA,IAAM,aAAa,CAAC,WAClB,oBAAoB,QAAQ,EAAE,aAAa,aAAa,CAAC,MAAM;AAIjE,IAAM,gBAAgB,oBAAI,IAA2B;AACrD,IAAM,mBAAmB,CAAC,cAAqC;AAC7D,MAAI,CAAC,+BAA+B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,KAAK,CAAC,KAAK,KAAK,QAAQ,QAAQ,KAAK,CAAC,CAAC,MAAM,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC;AAC/G,IAAI,QAAQ;AACV,QAAM,aAAa,4BAA4B,QAAQ,IAAI;AAC3D,MAAI;AACF,UAAM,8BAA8B,UAAU;AAAA,EAChD,QAAQ;AACN,YAAQ,WAAW;AAAA,EACrB;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -8428,6 +8428,8 @@ var PARTICIPANT_LEASE_MS = 15e3;
|
|
|
8428
8428
|
var TOMBSTONE_PREFIX = "topology/tombstones/";
|
|
8429
8429
|
var DEPARTED_LIMIT = 32;
|
|
8430
8430
|
var DEPARTED_RETENTION_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
8431
|
+
var REAP_INTERVAL_MS = 5 * 60 * 1e3;
|
|
8432
|
+
var REAP_BATCH = 100;
|
|
8431
8433
|
var keyFor = (prefix, id) => prefix + createHash3("sha256").update(id).digest("hex");
|
|
8432
8434
|
var isObject4 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8433
8435
|
var participantKind = (value) => value === "root" || value === "agent" || value === "actor" || value === "provider" ? value : void 0;
|
|
@@ -8609,6 +8611,8 @@ var ParticipantDirectory = class {
|
|
|
8609
8611
|
#refreshScheduled = false;
|
|
8610
8612
|
#refreshAgain = false;
|
|
8611
8613
|
#quiescing = false;
|
|
8614
|
+
#reapedAt = 0;
|
|
8615
|
+
#reaping;
|
|
8612
8616
|
registerSource(source) {
|
|
8613
8617
|
this.#sources.add(source);
|
|
8614
8618
|
if (this.#timer) this.scheduleRefresh();
|
|
@@ -8626,7 +8630,7 @@ var ParticipantDirectory = class {
|
|
|
8626
8630
|
} catch (error) {
|
|
8627
8631
|
initialError = error;
|
|
8628
8632
|
}
|
|
8629
|
-
if (this.options.enabled) {
|
|
8633
|
+
if (this.options.enabled && !this.#closed) {
|
|
8630
8634
|
this.#timer = setInterval(() => void this.refresh().catch(() => void 0), this.#heartbeatMs);
|
|
8631
8635
|
this.#timer.unref();
|
|
8632
8636
|
}
|
|
@@ -8842,6 +8846,7 @@ var ParticipantDirectory = class {
|
|
|
8842
8846
|
if (this.#timer) clearInterval(this.#timer);
|
|
8843
8847
|
this.#timer = void 0;
|
|
8844
8848
|
await this.#refreshing?.catch(() => void 0);
|
|
8849
|
+
await this.#reaping;
|
|
8845
8850
|
if (!this.options.enabled) return;
|
|
8846
8851
|
const owned = this.mesh.listAll(PARTICIPANT_PREFIX).flatMap((entry) => {
|
|
8847
8852
|
const participant = participantFromEntry(entry);
|
|
@@ -9001,6 +9006,68 @@ var ParticipantDirectory = class {
|
|
|
9001
9006
|
value: host,
|
|
9002
9007
|
identity: this.options.identity
|
|
9003
9008
|
});
|
|
9009
|
+
if (!this.#closed && !this.#quiescing && !this.#reaping && leaseAt - this.#reapedAt >= REAP_INTERVAL_MS) {
|
|
9010
|
+
this.#reapedAt = leaseAt;
|
|
9011
|
+
this.#reaping = this.#reapDeparted(leaseAt).then((more) => {
|
|
9012
|
+
if (more) this.#reapedAt = 0;
|
|
9013
|
+
}).catch(() => void 0).finally(() => {
|
|
9014
|
+
this.#reaping = void 0;
|
|
9015
|
+
});
|
|
9016
|
+
}
|
|
9017
|
+
}
|
|
9018
|
+
/**
|
|
9019
|
+
* Delete records whose owner lease has been dead longer than the departed
|
|
9020
|
+
* window. Close removes a host's own records, but a killed or crashed host
|
|
9021
|
+
* never closes, and every heartbeat in the project re-reads what it left.
|
|
9022
|
+
* Lost roots inside the window stay, so departed() still reports them.
|
|
9023
|
+
* Returns true when records were left for a later batch.
|
|
9024
|
+
*/
|
|
9025
|
+
async #reapDeparted(now) {
|
|
9026
|
+
const cutoff = now - this.#departedRetentionMs;
|
|
9027
|
+
const hosts = this.#hosts();
|
|
9028
|
+
const retainedOwners = /* @__PURE__ */ new Set();
|
|
9029
|
+
const reap = [];
|
|
9030
|
+
for (const entry of this.mesh.listAll(PARTICIPANT_PREFIX)) {
|
|
9031
|
+
const participant = participantFromEntry(entry);
|
|
9032
|
+
if (!participant) continue;
|
|
9033
|
+
const owner = hosts.get(participant.ownerHostId);
|
|
9034
|
+
const heartbeat = owner?.identity.id === participant.ownerIdentityId ? owner.updatedAt : 0;
|
|
9035
|
+
if (!liveOwner(participant, hosts, now) && Math.max(participant.updatedAt, heartbeat) < cutoff) {
|
|
9036
|
+
reap.push(entry);
|
|
9037
|
+
} else {
|
|
9038
|
+
retainedOwners.add(participant.ownerHostId);
|
|
9039
|
+
}
|
|
9040
|
+
}
|
|
9041
|
+
for (const entry of this.mesh.listAll(HOST_PREFIX)) {
|
|
9042
|
+
const host = hostFromEntry(entry);
|
|
9043
|
+
if (host && host.expiresAt < cutoff && !retainedOwners.has(host.id)) reap.push(entry);
|
|
9044
|
+
}
|
|
9045
|
+
for (const entry of reap.slice(0, REAP_BATCH)) {
|
|
9046
|
+
if (this.#closed || this.#quiescing) return false;
|
|
9047
|
+
try {
|
|
9048
|
+
await this.mesh.delete({ key: entry.key, ifVersion: entry.version }, (entries) => {
|
|
9049
|
+
if (this.#closed || this.#quiescing) return false;
|
|
9050
|
+
const currentNow = Date.now();
|
|
9051
|
+
const currentCutoff = currentNow - this.#departedRetentionMs;
|
|
9052
|
+
const participant = participantFromEntry(entry);
|
|
9053
|
+
if (participant) {
|
|
9054
|
+
const ownerKey = keyFor(HOST_PREFIX, participant.ownerHostId);
|
|
9055
|
+
const ownerEntry = entries.find((item) => item.key === ownerKey);
|
|
9056
|
+
const owner = ownerEntry && hostFromEntry(ownerEntry);
|
|
9057
|
+
if (ownerEntry && !owner) return false;
|
|
9058
|
+
const owners = new Map(owner ? [[owner.id, owner]] : []);
|
|
9059
|
+
const heartbeat = owner?.identity.id === participant.ownerIdentityId ? owner.updatedAt : 0;
|
|
9060
|
+
return !liveOwner(participant, owners, currentNow) && Math.max(participant.updatedAt, heartbeat) < currentCutoff;
|
|
9061
|
+
}
|
|
9062
|
+
const host = hostFromEntry(entry);
|
|
9063
|
+
return !!host && host.expiresAt < currentCutoff && !entries.some((item) => item.key.startsWith(PARTICIPANT_PREFIX) && isObject4(item.value) && item.value.ownerHostId === host.id);
|
|
9064
|
+
});
|
|
9065
|
+
} catch {
|
|
9066
|
+
if (this.mesh.get(entry.key)?.version === entry.version) return true;
|
|
9067
|
+
}
|
|
9068
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
9069
|
+
}
|
|
9070
|
+
return reap.length > REAP_BATCH;
|
|
9004
9071
|
}
|
|
9005
9072
|
/**
|
|
9006
9073
|
* Mint missing labels for this host's root participants. Labels persist in
|
|
@@ -9182,4 +9249,4 @@ export {
|
|
|
9182
9249
|
agentParticipantRecords,
|
|
9183
9250
|
actorParticipantRecord
|
|
9184
9251
|
};
|
|
9185
|
-
//# sourceMappingURL=chunk-
|
|
9252
|
+
//# sourceMappingURL=chunk-HX24MUUW.js.map
|