harnery 0.43.0 → 0.44.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.
- package/README.md +3 -3
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/agents.js +41 -48
- package/dist/commands/browse.d.ts.map +1 -1
- package/dist/commands/browse.js +38 -11
- package/dist/commands/diagnostics.d.ts.map +1 -1
- package/dist/commands/diagnostics.js +10 -0
- package/dist/commands/doctor.d.ts +12 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +22 -7
- package/dist/commands/governor.js +22 -10
- package/dist/commands/inbox.d.ts +1 -1
- package/dist/commands/inbox.d.ts.map +1 -1
- package/dist/commands/inbox.js +55 -2
- package/dist/commands/rm.d.ts.map +1 -1
- package/dist/commands/rm.js +28 -4
- package/dist/commands/servers.d.ts.map +1 -1
- package/dist/commands/servers.js +16 -1
- package/dist/commands/supervisor.d.ts.map +1 -1
- package/dist/commands/supervisor.js +7 -2
- package/dist/commands/toc.d.ts +14 -0
- package/dist/commands/toc.d.ts.map +1 -1
- package/dist/commands/toc.js +7 -4
- package/dist/commands/workflow.js +24 -30
- package/dist/core/agents/live-authority-v3.d.ts +1 -0
- package/dist/core/agents/live-authority-v3.d.ts.map +1 -1
- package/dist/core/agents/live-authority-v3.js +11 -0
- package/dist/core/agents/live-lifecycle-v3.d.ts +4 -2
- package/dist/core/agents/live-lifecycle-v3.d.ts.map +1 -1
- package/dist/core/agents/live-lifecycle-v3.js +28 -7
- package/dist/core/agents/mailbox.d.ts +9 -8
- package/dist/core/agents/mailbox.d.ts.map +1 -1
- package/dist/core/agents/mailbox.js +24 -17
- package/dist/core/agents/render/prompt-context.d.ts +2 -0
- package/dist/core/agents/render/prompt-context.d.ts.map +1 -1
- package/dist/core/agents/render/prompt-context.js +8 -12
- package/dist/core/agents/render/session-context.d.ts +2 -8
- package/dist/core/agents/render/session-context.d.ts.map +1 -1
- package/dist/core/agents/render/session-context.js +7 -30
- package/dist/core/agents/rules/stop-hook.js +3 -3
- package/dist/core/agents/state/heartbeat-writer.d.ts.map +1 -1
- package/dist/core/agents/state/heartbeat-writer.js +25 -14
- package/dist/core/agents/state/live-coordination-writer.d.ts.map +1 -1
- package/dist/core/agents/state/live-coordination-writer.js +5 -0
- package/dist/core/agents/state/pidmap.d.ts.map +1 -1
- package/dist/core/agents/state/pidmap.js +5 -0
- package/dist/core/agents/state/proc-start.d.ts +19 -0
- package/dist/core/agents/state/proc-start.d.ts.map +1 -1
- package/dist/core/agents/state/proc-start.js +41 -0
- package/dist/core/agents/state/stale-sweep.d.ts.map +1 -1
- package/dist/core/agents/state/stale-sweep.js +180 -70
- package/dist/core/agents/state/unchanged-file.d.ts +44 -0
- package/dist/core/agents/state/unchanged-file.d.ts.map +1 -0
- package/dist/core/agents/state/unchanged-file.js +390 -0
- package/dist/core/context/index.d.ts +22 -10
- package/dist/core/context/index.d.ts.map +1 -1
- package/dist/core/context/index.js +381 -119
- package/dist/core/context/observation.d.ts +26 -0
- package/dist/core/context/observation.d.ts.map +1 -0
- package/dist/core/context/observation.js +11 -0
- package/dist/core/diagnostics/bundle.d.ts.map +1 -1
- package/dist/core/diagnostics/bundle.js +25 -14
- package/dist/core/diagnostics/path-identity.d.ts +3 -0
- package/dist/core/diagnostics/path-identity.d.ts.map +1 -0
- package/dist/core/diagnostics/path-identity.js +12 -0
- package/dist/core/diagnostics/sanitize.d.ts.map +1 -1
- package/dist/core/diagnostics/sanitize.js +4 -3
- package/dist/core/events/v3/authority-outbox.d.ts.map +1 -1
- package/dist/core/events/v3/authority-outbox.js +29 -0
- package/dist/core/events/v3/generation-custody.d.ts +5 -0
- package/dist/core/events/v3/generation-custody.d.ts.map +1 -0
- package/dist/core/events/v3/generation-custody.js +50 -0
- package/dist/core/events/v3/producers/coordination-recorder.d.ts +1 -0
- package/dist/core/events/v3/producers/coordination-recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/coordination-recorder.js +7 -0
- package/dist/core/events/v3/producers/recorder.d.ts.map +1 -1
- package/dist/core/events/v3/producers/recorder.js +77 -64
- package/dist/core/governor/planning.d.ts.map +1 -1
- package/dist/core/governor/planning.js +14 -1
- package/dist/core/governor/service-read.d.ts +10 -2
- package/dist/core/governor/service-read.d.ts.map +1 -1
- package/dist/core/governor/service-read.js +105 -22
- package/dist/core/governor/service.d.ts +20 -2
- package/dist/core/governor/service.d.ts.map +1 -1
- package/dist/core/governor/service.js +72 -47
- package/dist/core/hooks/cli.js +33 -5
- package/dist/core/inbox/contract.d.ts +2 -1
- package/dist/core/inbox/contract.d.ts.map +1 -1
- package/dist/core/inbox/index.d.ts +2 -0
- package/dist/core/inbox/index.d.ts.map +1 -1
- package/dist/core/inbox/index.js +2 -0
- package/dist/core/inbox/peer-messages.d.ts +37 -0
- package/dist/core/inbox/peer-messages.d.ts.map +1 -0
- package/dist/core/inbox/peer-messages.js +72 -0
- package/dist/core/inbox/service.d.ts +8 -1
- package/dist/core/inbox/service.d.ts.map +1 -1
- package/dist/core/inbox/service.js +67 -21
- package/dist/core/inbox/targets.d.ts +22 -0
- package/dist/core/inbox/targets.d.ts.map +1 -0
- package/dist/core/inbox/targets.js +108 -0
- package/dist/core/inbox/watcher.js +7 -3
- package/dist/core/journal/index.d.ts.map +1 -1
- package/dist/core/journal/index.js +17 -2
- package/dist/core/resources/contract.d.ts +3 -0
- package/dist/core/resources/contract.d.ts.map +1 -1
- package/dist/core/resources/service-status.d.ts +14 -1
- package/dist/core/resources/service-status.d.ts.map +1 -1
- package/dist/core/resources/service-status.js +23 -13
- package/dist/core/resources/service.d.ts +9 -1
- package/dist/core/resources/service.d.ts.map +1 -1
- package/dist/core/resources/service.js +47 -27
- package/dist/core/resources/status.d.ts +2 -5
- package/dist/core/resources/status.d.ts.map +1 -1
- package/dist/core/resources/status.js +36 -7
- package/dist/core/servers/index.d.ts +24 -13
- package/dist/core/servers/index.d.ts.map +1 -1
- package/dist/core/servers/index.js +132 -92
- package/dist/core/servers/tunnels.d.ts +3 -5
- package/dist/core/servers/tunnels.d.ts.map +1 -1
- package/dist/core/servers/tunnels.js +3 -9
- package/dist/core/supervisor/contract.d.ts +12 -0
- package/dist/core/supervisor/contract.d.ts.map +1 -1
- package/dist/core/supervisor/explanations.d.ts.map +1 -1
- package/dist/core/supervisor/explanations.js +2 -1
- package/dist/core/supervisor/findings.d.ts.map +1 -1
- package/dist/core/supervisor/findings.js +54 -9
- package/dist/core/supervisor/service.d.ts +9 -1
- package/dist/core/supervisor/service.d.ts.map +1 -1
- package/dist/core/supervisor/service.js +59 -29
- package/dist/core/supervisor/services.d.ts.map +1 -1
- package/dist/core/supervisor/services.js +22 -1
- package/dist/core/supervisor/status.d.ts +17 -2
- package/dist/core/supervisor/status.d.ts.map +1 -1
- package/dist/core/supervisor/status.js +70 -12
- package/dist/core/supervisor/timeline.d.ts.map +1 -1
- package/dist/core/supervisor/timeline.js +2 -1
- package/dist/core/work/state.js +7 -7
- package/dist/core/workflow/engine.d.ts.map +1 -1
- package/dist/core/workflow/engine.js +105 -32
- package/dist/core/workflow/failure-evidence.d.ts +16 -0
- package/dist/core/workflow/failure-evidence.d.ts.map +1 -0
- package/dist/core/workflow/failure-evidence.js +114 -0
- package/dist/core/workflow/index.d.ts +1 -1
- package/dist/core/workflow/index.d.ts.map +1 -1
- package/dist/core/workflow/index.js +1 -1
- package/dist/core/workflow/live-session-v3.d.ts +6 -0
- package/dist/core/workflow/live-session-v3.d.ts.map +1 -1
- package/dist/core/workflow/live-session-v3.js +126 -5
- package/dist/core/workflow/proof.d.ts +5 -5
- package/dist/core/workflow/proof.d.ts.map +1 -1
- package/dist/core/workflow/proof.js +115 -20
- package/dist/core/workflow/run-state.d.ts +3 -1
- package/dist/core/workflow/run-state.d.ts.map +1 -1
- package/dist/core/workflow/run-state.js +31 -27
- package/dist/core/workflow/spawn-claude.d.ts.map +1 -1
- package/dist/core/workflow/spawn-claude.js +19 -0
- package/dist/core/workflow/spawn-codex.d.ts.map +1 -1
- package/dist/core/workflow/spawn-codex.js +13 -0
- package/dist/core/workflow/spawn-cursor.d.ts.map +1 -1
- package/dist/core/workflow/spawn-cursor.js +19 -0
- package/dist/core/workflow/spawn-opencode.d.ts.map +1 -1
- package/dist/core/workflow/spawn-opencode.js +14 -0
- package/dist/core/workflow/types.d.ts +64 -17
- package/dist/core/workflow/types.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/index.d.ts +0 -1
- package/dist/core/workflow/workspaces/index.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/index.js +0 -1
- package/dist/core/workflow/workspaces/leases.d.ts +3 -1
- package/dist/core/workflow/workspaces/leases.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/leases.js +30 -16
- package/dist/core/workflow/workspaces/local-git.d.ts +6 -2
- package/dist/core/workflow/workspaces/local-git.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/local-git.js +270 -6
- package/dist/core/workflow/workspaces/ownership.d.ts +11 -0
- package/dist/core/workflow/workspaces/ownership.d.ts.map +1 -0
- package/dist/core/workflow/workspaces/ownership.js +194 -0
- package/dist/core/workflow/workspaces/reclaim.d.ts +35 -0
- package/dist/core/workflow/workspaces/reclaim.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/reclaim.js +14 -0
- package/dist/core/workflow/workspaces/recovery.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/recovery.js +21 -13
- package/dist/core/workflow/workspaces/state.d.ts +1 -0
- package/dist/core/workflow/workspaces/state.d.ts.map +1 -1
- package/dist/core/workflow/workspaces/state.js +21 -1
- package/dist/lib/browser/windows-chrome.d.ts +100 -12
- package/dist/lib/browser/windows-chrome.d.ts.map +1 -1
- package/dist/lib/browser/windows-chrome.js +262 -73
- package/dist/lib/docs-links.d.ts.map +1 -1
- package/dist/lib/docs-links.js +45 -2
- package/dist/lib/guarded-remove.d.ts +7 -0
- package/dist/lib/guarded-remove.d.ts.map +1 -1
- package/dist/lib/guarded-remove.js +106 -12
- package/dist/lib/identities/assume.d.ts.map +1 -1
- package/dist/lib/identities/assume.js +4 -0
- package/dist/lib/zip/index.d.ts +41 -0
- package/dist/lib/zip/index.d.ts.map +1 -0
- package/dist/lib/zip/index.js +398 -0
- package/package.json +7 -1
- package/src/commands/agents.ts +54 -63
- package/src/commands/browse.ts +50 -14
- package/src/commands/diagnostics.ts +10 -0
- package/src/commands/doctor.ts +26 -7
- package/src/commands/governor.ts +23 -10
- package/src/commands/inbox.ts +52 -2
- package/src/commands/rm.ts +43 -4
- package/src/commands/servers.ts +16 -4
- package/src/commands/supervisor.ts +7 -2
- package/src/commands/toc.ts +14 -6
- package/src/commands/workflow.ts +30 -30
- package/src/core/agents/live-authority-v3.ts +17 -0
- package/src/core/agents/live-lifecycle-v3.ts +52 -14
- package/src/core/agents/mailbox.ts +26 -17
- package/src/core/agents/render/prompt-context.ts +10 -12
- package/src/core/agents/render/session-context.ts +9 -32
- package/src/core/agents/rules/stop-hook.ts +3 -3
- package/src/core/agents/state/heartbeat-writer.ts +29 -12
- package/src/core/agents/state/live-coordination-writer.ts +29 -0
- package/src/core/agents/state/pidmap.ts +13 -0
- package/src/core/agents/state/proc-start.ts +57 -0
- package/src/core/agents/state/stale-sweep.ts +247 -82
- package/src/core/agents/state/unchanged-file.ts +456 -0
- package/src/core/context/index.ts +446 -136
- package/src/core/context/observation.ts +29 -0
- package/src/core/diagnostics/bundle.ts +23 -18
- package/src/core/diagnostics/path-identity.ts +15 -0
- package/src/core/diagnostics/sanitize.ts +4 -3
- package/src/core/events/v3/authority-outbox.ts +56 -0
- package/src/core/events/v3/generation-custody.ts +59 -0
- package/src/core/events/v3/producers/coordination-recorder.ts +15 -0
- package/src/core/events/v3/producers/recorder.ts +94 -68
- package/src/core/governor/planning.ts +20 -8
- package/src/core/governor/service-read.ts +128 -20
- package/src/core/governor/service.ts +119 -42
- package/src/core/hooks/cli.ts +33 -5
- package/src/core/inbox/contract.ts +2 -1
- package/src/core/inbox/index.ts +2 -0
- package/src/core/inbox/peer-messages.ts +94 -0
- package/src/core/inbox/service.ts +88 -22
- package/src/core/inbox/targets.ts +148 -0
- package/src/core/inbox/watcher.ts +8 -9
- package/src/core/journal/index.ts +19 -2
- package/src/core/resources/contract.ts +4 -0
- package/src/core/resources/service-status.ts +35 -12
- package/src/core/resources/service.ts +71 -24
- package/src/core/resources/status.ts +57 -8
- package/src/core/servers/index.ts +177 -91
- package/src/core/servers/tunnels.ts +3 -11
- package/src/core/supervisor/contract.ts +13 -0
- package/src/core/supervisor/explanations.ts +4 -1
- package/src/core/supervisor/findings.ts +68 -10
- package/src/core/supervisor/service.ts +88 -26
- package/src/core/supervisor/services.ts +26 -8
- package/src/core/supervisor/status.ts +89 -12
- package/src/core/supervisor/timeline.ts +2 -1
- package/src/core/work/state.ts +7 -7
- package/src/core/workflow/engine.ts +131 -49
- package/src/core/workflow/failure-evidence.ts +141 -0
- package/src/core/workflow/index.ts +0 -1
- package/src/core/workflow/live-session-v3.ts +146 -5
- package/src/core/workflow/proof.ts +134 -26
- package/src/core/workflow/run-state.ts +31 -29
- package/src/core/workflow/spawn-claude.ts +18 -0
- package/src/core/workflow/spawn-codex.ts +13 -0
- package/src/core/workflow/spawn-cursor.ts +18 -0
- package/src/core/workflow/spawn-opencode.ts +14 -0
- package/src/core/workflow/types.ts +51 -17
- package/src/core/workflow/workspaces/index.ts +0 -1
- package/src/core/workflow/workspaces/leases.ts +48 -17
- package/src/core/workflow/workspaces/local-git.ts +315 -5
- package/src/core/workflow/workspaces/ownership.ts +232 -0
- package/src/core/workflow/workspaces/reclaim.ts +58 -0
- package/src/core/workflow/workspaces/recovery.ts +25 -13
- package/src/core/workflow/workspaces/state.ts +20 -0
- package/src/lib/browser/windows-chrome.ts +346 -86
- package/src/lib/docs-links.ts +49 -2
- package/src/lib/guarded-remove.ts +132 -14
- package/src/lib/identities/assume.ts +4 -0
- package/src/lib/zip/index.ts +483 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { type ProcessGenerationVerdict } from "../agents/state/proc-start.js";
|
|
1
2
|
import { type ResourceServiceStatus, type ResourceServiceStatusRecord } from "./contract.js";
|
|
2
3
|
import { sampleResources } from "./sampler.js";
|
|
4
|
+
import { type ResourceProcessDependencies } from "./service-status.js";
|
|
3
5
|
export declare const RESOURCE_SERVICE_DEFAULT_INTERVAL_MS = 2000;
|
|
4
6
|
export interface RunResourceServiceInput {
|
|
5
7
|
coordRoot: string;
|
|
@@ -21,6 +23,12 @@ export declare function spawnResourceService(coordRootRaw: string, options?: {
|
|
|
21
23
|
intervalMs?: number;
|
|
22
24
|
}): Promise<ResourceServiceStatus>;
|
|
23
25
|
export declare function ensureResourceServiceRunning(coordRoot: string): Promise<EnsureResourceServiceResult>;
|
|
24
|
-
export
|
|
26
|
+
export interface ResourceServiceStopResult extends ResourceServiceStatus {
|
|
27
|
+
signal_sent: boolean;
|
|
28
|
+
signal_verdict: ProcessGenerationVerdict;
|
|
29
|
+
}
|
|
30
|
+
export declare function requestResourceServiceStop(coordRootRaw: string, dependencies?: ResourceProcessDependencies & {
|
|
31
|
+
kill?: (pid: number, signal: NodeJS.Signals | number) => unknown;
|
|
32
|
+
}): ResourceServiceStopResult;
|
|
25
33
|
export declare function runResourceService(input: RunResourceServiceInput): Promise<ResourceServiceStatusRecord>;
|
|
26
34
|
//# sourceMappingURL=service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/core/resources/service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/core/resources/service.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,KAAK,wBAAwB,EAG9B,MAAM,+BAA+B,CAAC;AAIvC,OAAO,EAGL,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EACjC,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EACL,KAAK,2BAA2B,EAGjC,MA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C,2BAA2B,CAAC,CA4FtC"}
|
|
@@ -3,12 +3,13 @@ import { randomUUID } from "node:crypto";
|
|
|
3
3
|
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, rmSync, unlinkSync, writeFileSync, } from "node:fs";
|
|
4
4
|
import { hostname, platform } from "node:os";
|
|
5
5
|
import { resolve } from "node:path";
|
|
6
|
-
import {
|
|
6
|
+
import { processStartToken, signalIfSameGeneration, } from "../agents/state/proc-start.js";
|
|
7
|
+
import { resolveBinName } from "../config.js";
|
|
7
8
|
import { closeProcessLoggers, legacyLogFields, processLogger } from "../storage/logger.js";
|
|
8
9
|
import { stateDirMode, stateFileMode } from "../storage/modes.js";
|
|
9
10
|
import { RESOURCE_SERVICE_STATUS_SCHEMA_VERSION, } from "./contract.js";
|
|
10
11
|
import { sampleResources } from "./sampler.js";
|
|
11
|
-
import { readResourceServiceStatus } from "./service-status.js";
|
|
12
|
+
import { readResourceServiceStatus, resourceProcessLiveness, } from "./service-status.js";
|
|
12
13
|
import { resourcePaths, writePrivateJsonAtomic } from "./storage.js";
|
|
13
14
|
export const RESOURCE_SERVICE_DEFAULT_INTERVAL_MS = 2_000;
|
|
14
15
|
const RESOURCE_SERVICE_MIN_INTERVAL_MS = 500;
|
|
@@ -16,13 +17,15 @@ const RESOURCE_SERVICE_MAX_INTERVAL_MS = 60_000;
|
|
|
16
17
|
export async function spawnResourceService(coordRootRaw, options = {}) {
|
|
17
18
|
const coordRoot = resolve(coordRootRaw);
|
|
18
19
|
const current = readResourceServiceStatus(coordRoot);
|
|
19
|
-
if (current.
|
|
20
|
+
if (current.liveness === "unknown")
|
|
21
|
+
throw unknownResourceOwnerError();
|
|
22
|
+
if (current.liveness === "running") {
|
|
20
23
|
throw new Error(`resource observer is already running under pid ${current.record?.pid}`);
|
|
21
24
|
}
|
|
22
25
|
const intervalMs = normalizeInterval(options.intervalMs);
|
|
23
26
|
const paths = resourcePaths(coordRoot);
|
|
27
|
+
assertResourceLeaseAvailable(paths.lease);
|
|
24
28
|
mkdirSync(paths.root, { recursive: true, mode: stateDirMode() });
|
|
25
|
-
rmSync(paths.stop, { force: true });
|
|
26
29
|
const harnBin = new URL("../../../bin/harn", import.meta.url).pathname;
|
|
27
30
|
if (!existsSync(harnBin))
|
|
28
31
|
throw new Error(`cannot find harn executable at ${harnBin}`);
|
|
@@ -77,27 +80,31 @@ export async function ensureResourceServiceRunning(coordRoot) {
|
|
|
77
80
|
};
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
|
-
export function requestResourceServiceStop(coordRootRaw) {
|
|
83
|
+
export function requestResourceServiceStop(coordRootRaw, dependencies = {}) {
|
|
81
84
|
const coordRoot = resolve(coordRootRaw);
|
|
82
85
|
const paths = resourcePaths(coordRoot);
|
|
83
|
-
const status = readResourceServiceStatus(coordRoot);
|
|
86
|
+
const status = readResourceServiceStatus(coordRoot, Date.now(), dependencies);
|
|
84
87
|
mkdirSync(paths.root, { recursive: true, mode: stateDirMode() });
|
|
85
88
|
writePrivateJsonAtomic(paths.stop, {
|
|
86
89
|
requested_at: new Date().toISOString(),
|
|
87
90
|
requested_by_pid: process.pid,
|
|
88
91
|
});
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
return readResourceServiceStatus(coordRoot);
|
|
92
|
+
const signal = status.liveness === "running" && status.record?.host === hostname()
|
|
93
|
+
? signalIfSameGeneration(status.record.pid, status.record.start_token, "SIGTERM", dependencies)
|
|
94
|
+
: { sent: false, verdict: status.generation };
|
|
95
|
+
return {
|
|
96
|
+
...readResourceServiceStatus(coordRoot, Date.now(), dependencies),
|
|
97
|
+
signal_sent: signal.sent,
|
|
98
|
+
signal_verdict: signal.verdict,
|
|
99
|
+
};
|
|
98
100
|
}
|
|
99
101
|
export async function runResourceService(input) {
|
|
100
102
|
const coordRoot = resolve(input.coordRoot);
|
|
103
|
+
const current = readResourceServiceStatus(coordRoot);
|
|
104
|
+
if (current.liveness === "unknown")
|
|
105
|
+
throw unknownResourceOwnerError();
|
|
106
|
+
if (current.liveness === "running")
|
|
107
|
+
throw new Error(`resource observer is already running under pid ${current.record?.pid}`);
|
|
101
108
|
const paths = resourcePaths(coordRoot);
|
|
102
109
|
const intervalMs = normalizeInterval(input.intervalMs);
|
|
103
110
|
const now = input.now ?? (() => new Date());
|
|
@@ -212,7 +219,10 @@ function acquireLease(coordRoot, now) {
|
|
|
212
219
|
if (error.code !== "EEXIST")
|
|
213
220
|
throw error;
|
|
214
221
|
const existing = readLease(paths.lease);
|
|
215
|
-
|
|
222
|
+
const liveness = existing ? leaseIsLive(existing) : "unknown";
|
|
223
|
+
if (liveness === "unknown")
|
|
224
|
+
throw unknownResourceOwnerError();
|
|
225
|
+
if (existing && liveness === "running") {
|
|
216
226
|
throw new Error(`resource observer lease is held by pid ${existing.pid}`);
|
|
217
227
|
}
|
|
218
228
|
try {
|
|
@@ -239,7 +249,13 @@ function releaseLease(path, nonce) {
|
|
|
239
249
|
function readLease(path) {
|
|
240
250
|
try {
|
|
241
251
|
const value = JSON.parse(readFileSync(path, "utf8"));
|
|
242
|
-
return value &&
|
|
252
|
+
return value &&
|
|
253
|
+
Number.isSafeInteger(value.pid) &&
|
|
254
|
+
value.pid > 0 &&
|
|
255
|
+
typeof value.host === "string" &&
|
|
256
|
+
value.host.length > 0 &&
|
|
257
|
+
typeof value.nonce === "string" &&
|
|
258
|
+
value.nonce.length > 0
|
|
243
259
|
? value
|
|
244
260
|
: undefined;
|
|
245
261
|
}
|
|
@@ -248,16 +264,20 @@ function readLease(path) {
|
|
|
248
264
|
}
|
|
249
265
|
}
|
|
250
266
|
function leaseIsLive(lease) {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
267
|
+
return resourceProcessLiveness(lease).liveness;
|
|
268
|
+
}
|
|
269
|
+
function assertResourceLeaseAvailable(path) {
|
|
270
|
+
if (!existsSync(path))
|
|
271
|
+
return;
|
|
272
|
+
const lease = readLease(path);
|
|
273
|
+
const liveness = lease ? leaseIsLive(lease) : "unknown";
|
|
274
|
+
if (liveness === "unknown")
|
|
275
|
+
throw unknownResourceOwnerError();
|
|
276
|
+
if (liveness === "running")
|
|
277
|
+
throw new Error(`resource observer lease is held by pid ${lease?.pid}`);
|
|
278
|
+
}
|
|
279
|
+
function unknownResourceOwnerError() {
|
|
280
|
+
return new Error(`resource observer process identity is unknown; run ${resolveBinName()} supervisor stop to write the durable stop request before starting again`);
|
|
261
281
|
}
|
|
262
282
|
function log(coordRoot, event, fields, error) {
|
|
263
283
|
try {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type PressureAssessment, type PressureHysteresisState } from "../diagnostics/contract.js";
|
|
2
|
-
import { type SupervisorCapability, type SupervisorPressureRecord } from "../supervisor/contract.js";
|
|
2
|
+
import { type SupervisorCapability, type SupervisorPressureRecord, type SupervisorStatus } from "../supervisor/contract.js";
|
|
3
3
|
import { type ResourceDiskSample, type ResourceHostSample, type ResourceIoSample, type ResourceMachineSample, type ResourceOomSample, type ResourcePressureSample, type ResourceProcessSample, type ResourceSnapshot } from "./contract.js";
|
|
4
4
|
export declare const RESOURCE_STATUS_STALE_MS = 15000;
|
|
5
5
|
export declare const RESOURCE_STATUS_MAX_BYTES: number;
|
|
@@ -15,10 +15,7 @@ export interface ResourceStatus {
|
|
|
15
15
|
platform: NodeJS.Platform | null;
|
|
16
16
|
namespace: ResourceSnapshot["namespace"];
|
|
17
17
|
support: ResourceSnapshot["support"] | null;
|
|
18
|
-
writer:
|
|
19
|
-
running: boolean;
|
|
20
|
-
stale: boolean;
|
|
21
|
-
};
|
|
18
|
+
writer: Pick<SupervisorStatus, "running" | "stale" | "generation" | "liveness" | "running_build" | "installed_build" | "restart_needed" | "build_status">;
|
|
22
19
|
/**
|
|
23
20
|
* The one published pressure assessment, read from the observer's record so
|
|
24
21
|
* this surface, the prompt notice, the dashboard, and a diagnostic bundle all
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/core/resources/status.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC7B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/core/resources/status.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC7B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACtB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EAEtB,MAAM,eAAe,CAAC;AAGvB,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAC/C,eAAO,MAAM,yBAAyB,QAAkB,CAAC;AACzD,eAAO,MAAM,6BAA6B,KAAK,CAAC;AAChD,eAAO,MAAM,6BAA6B,QAAS,CAAC;AAGpD,MAAM,WAAW,cAAc;IAC7B,cAAc,EAAE,CAAC,CAAC;IAClB,KAAK,EAAE,OAAO,GAAG,OAAO,GAAG,aAAa,CAAC;IACzC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,QAAQ,GAA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AO,MAAM,yBAAyB,QAAa,CAAC;AAEpD,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,kBAAkB,CAAC;IAC/B,gBAAgB,EAAE,uBAAuB,GAAG,IAAI,CAAC;IACjD,UAAU,EAAE,oBAAoB,CAAC;IACjC,MAAM,EAAE,wBAAwB,GAAG,IAAI,CAAC;CACzC;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EACjB,KAAK,SAAa,EAClB,MAAM,CAAC,EAAE,cAAc,CAAC,QAAQ,CAAC,GAChC,iBAAiB,CAkFnB"}
|
|
@@ -2,7 +2,7 @@ import { closeSync, fstatSync, openSync, readSync, statSync } from "node:fs";
|
|
|
2
2
|
import { unknownPressureAssessment } from "../diagnostics/advice.js";
|
|
3
3
|
import { PRESSURE_ASSESSMENT_SCHEMA_VERSION, PRESSURE_POLICY, } from "../diagnostics/contract.js";
|
|
4
4
|
import { SUPERVISOR_PRESSURE_SCHEMA_VERSION, } from "../supervisor/contract.js";
|
|
5
|
-
import { readSupervisorStatus } from "../supervisor/status.js";
|
|
5
|
+
import { installedSupervisorBuild, readSupervisorStatus } from "../supervisor/status.js";
|
|
6
6
|
import { supervisorPaths } from "../supervisor/storage.js";
|
|
7
7
|
import { RESOURCE_SNAPSHOT_SCHEMA_VERSION, } from "./contract.js";
|
|
8
8
|
import { resourcePaths } from "./storage.js";
|
|
@@ -156,11 +156,13 @@ export function formatResourceSummary(status) {
|
|
|
156
156
|
? "unknown"
|
|
157
157
|
: `${formatBytes(m.memory_available_bytes)} available`;
|
|
158
158
|
const diskText = disk ? `${formatBytes(disk.available_bytes)} available` : "unknown";
|
|
159
|
-
return `${lead} ${status.namespace}/${status.platform}: CPU ${cpu}, RAM ${ram}, disk ${diskText}; ${Math.round((status.sample_age_ms ?? 0) / 1_000)}s old${status.support?.state === "partial" ? "; partial" : ""}${!status.writer.running ? "
|
|
159
|
+
return `${lead} ${status.namespace}/${status.platform}: CPU ${cpu}, RAM ${ram}, disk ${diskText}; ${Math.round((status.sample_age_ms ?? 0) / 1_000)}s old${status.support?.state === "partial" ? "; partial" : ""}${!status.writer.running ? `; writer ${status.writer.liveness === "unknown" ? "unknown" : status.writer.stale ? "stale" : "stopped"}` : ""}.`;
|
|
160
160
|
}
|
|
161
161
|
export function formatResourceStatus(status, bin) {
|
|
162
162
|
const a = status.assessment;
|
|
163
163
|
const lines = [formatResourceSummary(status)];
|
|
164
|
+
const writer = status.writer;
|
|
165
|
+
lines.push(`Writer: ${writer.liveness}; generation ${writer.generation}; running build ${writer.running_build ? `${writer.running_build.version} (${writer.running_build.revision})` : "unknown"}; installed build ${writer.installed_build.version} (${writer.installed_build.revision}); ${writer.build_status}.`);
|
|
164
166
|
lines.push(`Assessment: ${a.state} at ${a.scope} scope; limiting resource ${a.limiting_resource}; trend ${a.trend}; evidence ${a.evidence_state}; recommended action ${a.recommended_action}.`);
|
|
165
167
|
lines.push(`Evidence age: ${a.sample_age_ms === null ? "unknown" : `${Math.round(a.sample_age_ms / 1_000)}s`}; assessment source ${status.assessment_capability.state}${status.assessment_capability.reason_code ? ` (${status.assessment_capability.reason_code})` : ""}.`);
|
|
166
168
|
for (const item of a.reasons)
|
|
@@ -176,7 +178,9 @@ export function formatResourceStatus(status, bin) {
|
|
|
176
178
|
}
|
|
177
179
|
if (a.unattributed_memory_percent !== null)
|
|
178
180
|
lines.push(`Unattributed memory: ${Math.round(a.unattributed_memory_percent)}% of machine memory has no validated owner.`);
|
|
179
|
-
if (status.
|
|
181
|
+
if (status.writer.liveness === "unknown")
|
|
182
|
+
lines.push(`Inspect the writer with ${bin} supervisor status. Run ${bin} supervisor stop to write its durable stop request before starting again.`);
|
|
183
|
+
else if (status.state !== "fresh" || !status.writer.running)
|
|
180
184
|
lines.push(`Start or inspect the writer with ${bin} supervisor start --keep-alive and ${bin} supervisor status.`);
|
|
181
185
|
if (status.host)
|
|
182
186
|
lines.push(`Windows host: ${status.host.state}${status.host.machine ? `; CPU ${status.host.machine.cpu_percent === null ? "warming up" : `${Math.round(status.host.machine.cpu_percent)}%`}, RAM ${status.host.machine.memory_available_bytes === null ? "unknown" : `${formatBytes(status.host.machine.memory_available_bytes)} available`}` : `; ${status.host.reason ?? "unavailable"}`}`);
|
|
@@ -238,7 +242,11 @@ export function readPublishedPressure(coordRoot, nowMs = Date.now(), writer) {
|
|
|
238
242
|
});
|
|
239
243
|
// A record can only be trusted while its writer is alive. Every surface makes
|
|
240
244
|
// the same check here so none of them reports a state the others do not.
|
|
241
|
-
|
|
245
|
+
const observer = writer ?? readWriterState(coordRoot, nowMs);
|
|
246
|
+
if (observer.liveness === "unknown") {
|
|
247
|
+
return gap("error", "pressure_observer_unknown", "Local resource pressure cannot be determined because the resource observer's process identity is unknown.");
|
|
248
|
+
}
|
|
249
|
+
if (!observer.running) {
|
|
242
250
|
return gap("expired", "pressure_observer_not_running", "Local resource pressure cannot be determined because the resource observer is not running.");
|
|
243
251
|
}
|
|
244
252
|
const path = supervisorPaths(coordRoot).pressure;
|
|
@@ -275,20 +283,41 @@ function readWriterState(coordRoot, nowMs) {
|
|
|
275
283
|
// Keep malformed service metadata from making the read expensive. The shared
|
|
276
284
|
// status reader retains ownership of PID/start-token liveness checks.
|
|
277
285
|
if (statSync(supervisorPaths(coordRoot).service).size > 65_536) {
|
|
278
|
-
return
|
|
286
|
+
return unknownWriterState();
|
|
279
287
|
}
|
|
280
288
|
const writer = readSupervisorStatus(coordRoot, nowMs);
|
|
281
289
|
const futureHeartbeat = writer.record && Date.parse(writer.record.heartbeat_at) > nowMs + FUTURE_TOLERANCE_MS;
|
|
282
290
|
return {
|
|
283
291
|
running: writer.running && !futureHeartbeat,
|
|
284
292
|
stale: writer.stale || !!futureHeartbeat,
|
|
293
|
+
generation: writer.generation,
|
|
294
|
+
liveness: writer.liveness,
|
|
295
|
+
running_build: writer.running_build,
|
|
296
|
+
installed_build: writer.installed_build,
|
|
297
|
+
restart_needed: writer.restart_needed,
|
|
298
|
+
build_status: writer.build_status,
|
|
285
299
|
};
|
|
286
300
|
}
|
|
287
|
-
catch {
|
|
301
|
+
catch (error) {
|
|
288
302
|
// A missing writer must not break normal coordination.
|
|
289
|
-
return {
|
|
303
|
+
return {
|
|
304
|
+
...unknownWriterState(),
|
|
305
|
+
liveness: error.code === "ENOENT" ? "stopped" : "unknown",
|
|
306
|
+
};
|
|
290
307
|
}
|
|
291
308
|
}
|
|
309
|
+
function unknownWriterState() {
|
|
310
|
+
return {
|
|
311
|
+
running: false,
|
|
312
|
+
stale: false,
|
|
313
|
+
generation: "unknown",
|
|
314
|
+
liveness: "unknown",
|
|
315
|
+
running_build: null,
|
|
316
|
+
installed_build: installedSupervisorBuild(),
|
|
317
|
+
restart_needed: true,
|
|
318
|
+
build_status: "running build unknown; restart needed",
|
|
319
|
+
};
|
|
320
|
+
}
|
|
292
321
|
function validPressureRecord(v) {
|
|
293
322
|
if (!object(v) ||
|
|
294
323
|
v.schema_version !== SUPERVISOR_PRESSURE_SCHEMA_VERSION ||
|
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
* for `gc` once its starting agent has ended or been unobserved for a long
|
|
15
15
|
* time AND nobody has used the server for the idle window.
|
|
16
16
|
*
|
|
17
|
-
* Fail-closed rules: a record whose pid was recycled is
|
|
18
|
-
*
|
|
17
|
+
* Fail-closed rules: a record whose pid was recycled is never signalled;
|
|
18
|
+
* an unreadable start token or coordination view is `unknown`,
|
|
19
19
|
* which `gc` never stops; a record without an owner is never stopped
|
|
20
20
|
* automatically.
|
|
21
21
|
*/
|
|
22
|
+
import { type ProcessGenerationSignalDependencies, type ProcessGenerationVerdict } from "../agents/state/proc-start.js";
|
|
22
23
|
import { type ScanSupport } from "./net.js";
|
|
23
24
|
export { ancestry, establishedConnectionCounts, listListeningPorts, listListeningSockets, lsofConnectionCounts, lsofListeningSockets, parseElapsed, parseLsofListen, parseProcNetTcp, processStartedAt, psProcessInfo, readProcessInfo, scanSupport, } from "./net.js";
|
|
24
25
|
export { tunnelServerId, tunnelServerInput } from "./tunnels.js";
|
|
@@ -40,13 +41,13 @@ export interface ServerRecord {
|
|
|
40
41
|
start_token?: string;
|
|
41
42
|
/** Further processes that belong to this server (helpers, children). */
|
|
42
43
|
pids?: number[];
|
|
44
|
+
/** Generation witnesses captured when the further processes registered. */
|
|
45
|
+
pids_start_tokens?: Record<string, string>;
|
|
43
46
|
host: string;
|
|
44
47
|
/** What the server serves, usually a directory. */
|
|
45
48
|
scope?: string;
|
|
46
49
|
cwd?: string;
|
|
47
50
|
log?: string;
|
|
48
|
-
/** Graceful stop command; signals are the fallback. */
|
|
49
|
-
stop_argv?: string[];
|
|
50
51
|
owner?: {
|
|
51
52
|
instance_id: string;
|
|
52
53
|
name?: string;
|
|
@@ -63,11 +64,12 @@ export interface RegisterServerInput {
|
|
|
63
64
|
url?: string;
|
|
64
65
|
port?: number;
|
|
65
66
|
pid?: number;
|
|
67
|
+
/** Preserve an observed witness when adopting, rather than probing a new generation. */
|
|
68
|
+
start_token?: string;
|
|
66
69
|
pids?: number[];
|
|
67
70
|
scope?: string;
|
|
68
71
|
cwd?: string;
|
|
69
72
|
log?: string;
|
|
70
|
-
stop_argv?: string[];
|
|
71
73
|
started_at?: string;
|
|
72
74
|
/** `null` records no owner; omitted resolves the calling agent session. */
|
|
73
75
|
owner?: {
|
|
@@ -78,7 +80,7 @@ export interface RegisterServerInput {
|
|
|
78
80
|
export interface ServerOptions {
|
|
79
81
|
coordRoot?: string | null;
|
|
80
82
|
}
|
|
81
|
-
export type ServerState = "running" | "dead" | "other-host";
|
|
83
|
+
export type ServerState = "running" | "dead" | "other-host" | "unknown";
|
|
82
84
|
export type OwnerState = "live" | "abandoned" | "ended" | "unknown" | "none";
|
|
83
85
|
export interface ServerView {
|
|
84
86
|
record: ServerRecord;
|
|
@@ -90,6 +92,8 @@ export interface ServerView {
|
|
|
90
92
|
}
|
|
91
93
|
export interface UnregisteredListener {
|
|
92
94
|
pid: number;
|
|
95
|
+
/** Captured during the scan, before a stop can be authorized. */
|
|
96
|
+
start_token?: string;
|
|
93
97
|
port: number;
|
|
94
98
|
address: string;
|
|
95
99
|
command: string;
|
|
@@ -134,7 +138,7 @@ export declare function touchServer(id: string, options?: ServerOptions & {
|
|
|
134
138
|
export declare function createServerToucher(id: string, options?: ServerOptions): () => void;
|
|
135
139
|
export declare function readServerRecords(options?: ServerOptions): ServerRecord[];
|
|
136
140
|
export declare function pidAlive(pid: number): boolean;
|
|
137
|
-
export declare function serverState(record: ServerRecord): ServerState;
|
|
141
|
+
export declare function serverState(record: ServerRecord, readToken?: (pid: number) => string | null, probePid?: (pid: number) => boolean): ServerState;
|
|
138
142
|
export interface ListServersOptions extends ServerOptions {
|
|
139
143
|
/** Look for listening processes inside the project that never registered. */
|
|
140
144
|
scan?: boolean;
|
|
@@ -147,8 +151,6 @@ export interface ListServersOptions extends ServerOptions {
|
|
|
147
151
|
}
|
|
148
152
|
/** Read every record, observe it, and optionally find unregistered listeners. */
|
|
149
153
|
export declare function listServers(options?: ListServersOptions): ServersReport;
|
|
150
|
-
/** Register running tunnels that have no current record. Returns adopted ids. */
|
|
151
|
-
export declare function adoptRunningTunnels(coordRoot: string): string[];
|
|
152
154
|
/**
|
|
153
155
|
* Listening processes that run inside the project (working directory or
|
|
154
156
|
* command line within the coordination root) but are not covered by any
|
|
@@ -175,16 +177,21 @@ export declare function planServerGc(views: ServerView[], policy?: GcPolicy): Gc
|
|
|
175
177
|
export interface StopResult {
|
|
176
178
|
id: string;
|
|
177
179
|
stopped: boolean;
|
|
178
|
-
method: "not-running" | "
|
|
180
|
+
method: "not-running" | "signal" | "refused";
|
|
181
|
+
generation?: ProcessGenerationVerdict;
|
|
179
182
|
detail?: string;
|
|
180
183
|
}
|
|
184
|
+
export interface ServerProcessDependencies extends ProcessGenerationSignalDependencies {
|
|
185
|
+
probePid?: (pid: number) => boolean;
|
|
186
|
+
}
|
|
181
187
|
/**
|
|
182
|
-
* Stop
|
|
183
|
-
*
|
|
184
|
-
*
|
|
188
|
+
* Stop a verified server with SIGTERM, then SIGKILL after the grace period.
|
|
189
|
+
* Each signal, including the process group and auxiliary processes, requires
|
|
190
|
+
* a fresh generation check. Unknown or different generations retain the record.
|
|
185
191
|
*/
|
|
186
192
|
export declare function stopServer(record: ServerRecord, options?: ServerOptions & {
|
|
187
193
|
graceMs?: number;
|
|
194
|
+
signalDependencies?: ServerProcessDependencies;
|
|
188
195
|
}): Promise<StopResult>;
|
|
189
196
|
/**
|
|
190
197
|
* The first free port in the configured range for `type`
|
|
@@ -200,6 +207,10 @@ export interface AdoptOptions extends ServerOptions {
|
|
|
200
207
|
scope?: string;
|
|
201
208
|
/** `self` (default) records the adopting agent as owner; `none` records no owner. */
|
|
202
209
|
owner?: "self" | "none";
|
|
210
|
+
dependencies?: {
|
|
211
|
+
listServers?: typeof listServers;
|
|
212
|
+
readToken?: (pid: number) => string | null;
|
|
213
|
+
};
|
|
203
214
|
}
|
|
204
215
|
/**
|
|
205
216
|
* Register a running server that never registered itself. Only a pid the scan
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/servers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/servers/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAQH,OAAO,EACL,KAAK,mCAAmC,EACxC,KAAK,wBAAwB,EAI9B,MAAM,+BAA+B,CAAC;AASvC,OAAO,EAOL,KAAK,WAAW,EAEjB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,QAAQ,EACR,2BAA2B,EAC3B,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,WAAW,GACZ,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE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