@mono-agent/agent-app 0.19.1 → 0.20.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 +304 -32
- package/dist/acp-bridge.d.ts.map +1 -1
- package/dist/acp-bridge.js +113 -54
- package/dist/acp-bridge.js.map +1 -1
- package/dist/acp-session-store.d.ts +12 -0
- package/dist/acp-session-store.d.ts.map +1 -0
- package/dist/acp-session-store.js +74 -0
- package/dist/acp-session-store.js.map +1 -0
- package/dist/agent-artifact-paths.d.ts +8 -0
- package/dist/agent-artifact-paths.d.ts.map +1 -0
- package/dist/agent-artifact-paths.js +11 -0
- package/dist/agent-artifact-paths.js.map +1 -0
- package/dist/agent-root-coordinator.d.ts +101 -0
- package/dist/agent-root-coordinator.d.ts.map +1 -0
- package/dist/agent-root-coordinator.js +470 -0
- package/dist/agent-root-coordinator.js.map +1 -0
- package/dist/app-controller-channels.d.ts +11 -1
- package/dist/app-controller-channels.d.ts.map +1 -1
- package/dist/app-controller-channels.js +145 -20
- package/dist/app-controller-channels.js.map +1 -1
- package/dist/app-controller-continuation.d.ts +2 -0
- package/dist/app-controller-continuation.d.ts.map +1 -1
- package/dist/app-controller-continuation.js.map +1 -1
- package/dist/app-controller-lifecycle.d.ts +5 -0
- package/dist/app-controller-lifecycle.d.ts.map +1 -1
- package/dist/app-controller-lifecycle.js +24 -5
- package/dist/app-controller-lifecycle.js.map +1 -1
- package/dist/app-controller-maintenance.d.ts +2 -0
- package/dist/app-controller-maintenance.d.ts.map +1 -1
- package/dist/app-controller-maintenance.js +32 -2
- package/dist/app-controller-maintenance.js.map +1 -1
- package/dist/app-controller-process-jobs.d.ts +46 -0
- package/dist/app-controller-process-jobs.d.ts.map +1 -0
- package/dist/app-controller-process-jobs.js +281 -0
- package/dist/app-controller-process-jobs.js.map +1 -0
- package/dist/app-controller-responder.d.ts +15 -0
- package/dist/app-controller-responder.d.ts.map +1 -1
- package/dist/app-controller-responder.js +146 -12
- package/dist/app-controller-responder.js.map +1 -1
- package/dist/app-controller-traceability.d.ts +6 -0
- package/dist/app-controller-traceability.d.ts.map +1 -1
- package/dist/app-controller-traceability.js +10 -0
- package/dist/app-controller-traceability.js.map +1 -1
- package/dist/app-controller-utils.d.ts +8 -0
- package/dist/app-controller-utils.d.ts.map +1 -1
- package/dist/app-controller-utils.js +24 -1
- package/dist/app-controller-utils.js.map +1 -1
- package/dist/app-controller.d.ts +40 -1
- package/dist/app-controller.d.ts.map +1 -1
- package/dist/app-controller.js +124 -39
- package/dist/app-controller.js.map +1 -1
- package/dist/background-log-maintenance.d.ts +85 -2
- package/dist/background-log-maintenance.d.ts.map +1 -1
- package/dist/background-log-maintenance.js +407 -136
- package/dist/background-log-maintenance.js.map +1 -1
- package/dist/background-runtime.d.ts.map +1 -1
- package/dist/background-runtime.js +22 -41
- package/dist/background-runtime.js.map +1 -1
- package/dist/background.d.ts +18 -26
- package/dist/background.d.ts.map +1 -1
- package/dist/background.js +83 -138
- package/dist/background.js.map +1 -1
- package/dist/channel-drivers/cron.d.ts +12 -1
- package/dist/channel-drivers/cron.d.ts.map +1 -1
- package/dist/channel-drivers/cron.js +121 -18
- package/dist/channel-drivers/cron.js.map +1 -1
- package/dist/channel-drivers/native-notify.d.ts +3 -0
- package/dist/channel-drivers/native-notify.d.ts.map +1 -1
- package/dist/channel-drivers/native-notify.js +2 -1
- package/dist/channel-drivers/native-notify.js.map +1 -1
- package/dist/channel-drivers/slack.d.ts.map +1 -1
- package/dist/channel-drivers/slack.js +41 -4
- package/dist/channel-drivers/slack.js.map +1 -1
- package/dist/channel-drivers/telegram.d.ts.map +1 -1
- package/dist/channel-drivers/telegram.js +46 -3
- package/dist/channel-drivers/telegram.js.map +1 -1
- package/dist/channel-drivers/tui.d.ts +13 -2
- package/dist/channel-drivers/tui.d.ts.map +1 -1
- package/dist/channel-drivers/tui.js +112 -3
- package/dist/channel-drivers/tui.js.map +1 -1
- package/dist/channels.d.ts +1 -1
- package/dist/channels.d.ts.map +1 -1
- package/dist/channels.js +4 -2
- package/dist/channels.js.map +1 -1
- package/dist/cli-args.d.ts +15 -1
- package/dist/cli-args.d.ts.map +1 -1
- package/dist/cli-args.js +82 -12
- package/dist/cli-args.js.map +1 -1
- package/dist/cli-background-command.d.ts +9 -2
- package/dist/cli-background-command.d.ts.map +1 -1
- package/dist/cli-background-command.js +174 -66
- package/dist/cli-background-command.js.map +1 -1
- package/dist/cli-commands.d.ts.map +1 -1
- package/dist/cli-commands.js +50 -12
- package/dist/cli-commands.js.map +1 -1
- package/dist/cli-help.d.ts.map +1 -1
- package/dist/cli-help.js +21 -1
- package/dist/cli-help.js.map +1 -1
- package/dist/config-reference.d.ts.map +1 -1
- package/dist/config-reference.js +99 -2
- package/dist/config-reference.js.map +1 -1
- package/dist/configured-agent.d.ts +44 -3
- package/dist/configured-agent.d.ts.map +1 -1
- package/dist/configured-agent.js +805 -156
- package/dist/configured-agent.js.map +1 -1
- package/dist/conversation-state-roots.d.ts +59 -0
- package/dist/conversation-state-roots.d.ts.map +1 -0
- package/dist/conversation-state-roots.js +248 -0
- package/dist/conversation-state-roots.js.map +1 -0
- package/dist/cron-control-store.d.ts +91 -0
- package/dist/cron-control-store.d.ts.map +1 -0
- package/dist/cron-control-store.js +1251 -0
- package/dist/cron-control-store.js.map +1 -0
- package/dist/cron-operator-service.d.ts +54 -0
- package/dist/cron-operator-service.d.ts.map +1 -0
- package/dist/cron-operator-service.js +352 -0
- package/dist/cron-operator-service.js.map +1 -0
- package/dist/doctor-session-history.d.ts +9 -0
- package/dist/doctor-session-history.d.ts.map +1 -0
- package/dist/doctor-session-history.js +313 -0
- package/dist/doctor-session-history.js.map +1 -0
- package/dist/doctor.d.ts +2 -1
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +320 -9
- package/dist/doctor.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/interaction-bridge.d.ts +1 -0
- package/dist/interaction-bridge.d.ts.map +1 -1
- package/dist/interaction-bridge.js +54 -6
- package/dist/interaction-bridge.js.map +1 -1
- package/dist/jobs-command.d.ts +17 -0
- package/dist/jobs-command.d.ts.map +1 -0
- package/dist/jobs-command.js +207 -0
- package/dist/jobs-command.js.map +1 -0
- package/dist/launchd-lifecycle-lock.d.ts +36 -0
- package/dist/launchd-lifecycle-lock.d.ts.map +1 -0
- package/dist/launchd-lifecycle-lock.js +124 -0
- package/dist/launchd-lifecycle-lock.js.map +1 -0
- package/dist/launchd-log-monitor-status.d.ts +7 -0
- package/dist/launchd-log-monitor-status.d.ts.map +1 -0
- package/dist/launchd-log-monitor-status.js +224 -0
- package/dist/launchd-log-monitor-status.js.map +1 -0
- package/dist/launchd-logs.d.ts +9 -1
- package/dist/launchd-logs.d.ts.map +1 -1
- package/dist/launchd-logs.js +69 -16
- package/dist/launchd-logs.js.map +1 -1
- package/dist/launchd-maintenance-command.d.ts +10 -0
- package/dist/launchd-maintenance-command.d.ts.map +1 -0
- package/dist/launchd-maintenance-command.js +2 -0
- package/dist/launchd-maintenance-command.js.map +1 -0
- package/dist/launchd-maintenance-entry.d.ts +30 -0
- package/dist/launchd-maintenance-entry.d.ts.map +1 -0
- package/dist/launchd-maintenance-entry.js +206 -0
- package/dist/launchd-maintenance-entry.js.map +1 -0
- package/dist/launchd-maintenance-gate.d.ts +28 -0
- package/dist/launchd-maintenance-gate.d.ts.map +1 -0
- package/dist/launchd-maintenance-gate.js +80 -0
- package/dist/launchd-maintenance-gate.js.map +1 -0
- package/dist/launchd-private-files.d.ts +3 -0
- package/dist/launchd-private-files.d.ts.map +1 -0
- package/dist/launchd-private-files.js +58 -0
- package/dist/launchd-private-files.js.map +1 -0
- package/dist/launchd.d.ts +56 -2
- package/dist/launchd.d.ts.map +1 -1
- package/dist/launchd.js +210 -5
- package/dist/launchd.js.map +1 -1
- package/dist/local-configuration.d.ts.map +1 -1
- package/dist/local-configuration.js +33 -7
- package/dist/local-configuration.js.map +1 -1
- package/dist/managed-launchd-maintenance-environment.d.ts +3 -0
- package/dist/managed-launchd-maintenance-environment.d.ts.map +1 -0
- package/dist/managed-launchd-maintenance-environment.js +12 -0
- package/dist/managed-launchd-maintenance-environment.js.map +1 -0
- package/dist/managed-runtime-launch-proof.d.ts +11 -0
- package/dist/managed-runtime-launch-proof.d.ts.map +1 -0
- package/dist/managed-runtime-launch-proof.js +59 -0
- package/dist/managed-runtime-launch-proof.js.map +1 -0
- package/dist/managed-runtime-maintenance-entry.d.ts +10 -0
- package/dist/managed-runtime-maintenance-entry.d.ts.map +1 -0
- package/dist/managed-runtime-maintenance-entry.js +244 -0
- package/dist/managed-runtime-maintenance-entry.js.map +1 -0
- package/dist/managed-web-logs.d.ts +29 -11
- package/dist/managed-web-logs.d.ts.map +1 -1
- package/dist/managed-web-logs.js +244 -121
- package/dist/managed-web-logs.js.map +1 -1
- package/dist/managed-web-maintenance-environment.d.ts +6 -0
- package/dist/managed-web-maintenance-environment.d.ts.map +1 -0
- package/dist/managed-web-maintenance-environment.js +19 -0
- package/dist/managed-web-maintenance-environment.js.map +1 -0
- package/dist/mcp-apps.d.ts +37 -0
- package/dist/mcp-apps.d.ts.map +1 -0
- package/dist/mcp-apps.js +1753 -0
- package/dist/mcp-apps.js.map +1 -0
- package/dist/memory-command.d.ts +12 -0
- package/dist/memory-command.d.ts.map +1 -1
- package/dist/memory-command.js +510 -1
- package/dist/memory-command.js.map +1 -1
- package/dist/modules/known-tools.d.ts +1 -1
- package/dist/modules/known-tools.d.ts.map +1 -1
- package/dist/modules/known-tools.js +2 -0
- package/dist/modules/known-tools.js.map +1 -1
- package/dist/posted-reply-history.d.ts.map +1 -1
- package/dist/posted-reply-history.js +12 -0
- package/dist/posted-reply-history.js.map +1 -1
- package/dist/proactive-notify.d.ts +4 -1
- package/dist/proactive-notify.d.ts.map +1 -1
- package/dist/proactive-notify.js +43 -5
- package/dist/proactive-notify.js.map +1 -1
- package/dist/process-jobs-config.d.ts +82 -0
- package/dist/process-jobs-config.d.ts.map +1 -0
- package/dist/process-jobs-config.js +423 -0
- package/dist/process-jobs-config.js.map +1 -0
- package/dist/process-jobs-context.d.ts +24 -0
- package/dist/process-jobs-context.d.ts.map +1 -0
- package/dist/process-jobs-context.js +135 -0
- package/dist/process-jobs-context.js.map +1 -0
- package/dist/process-jobs-root-registry.d.ts +115 -0
- package/dist/process-jobs-root-registry.d.ts.map +1 -0
- package/dist/process-jobs-root-registry.js +978 -0
- package/dist/process-jobs-root-registry.js.map +1 -0
- package/dist/process-jobs-runtime.d.ts +35 -0
- package/dist/process-jobs-runtime.d.ts.map +1 -0
- package/dist/process-jobs-runtime.js +177 -0
- package/dist/process-jobs-runtime.js.map +1 -0
- package/dist/process-jobs-service.d.ts +70 -0
- package/dist/process-jobs-service.d.ts.map +1 -0
- package/dist/process-jobs-service.js +1989 -0
- package/dist/process-jobs-service.js.map +1 -0
- package/dist/process-jobs-store.d.ts +151 -0
- package/dist/process-jobs-store.d.ts.map +1 -0
- package/dist/process-jobs-store.js +1290 -0
- package/dist/process-jobs-store.js.map +1 -0
- package/dist/reply-artifacts.d.ts +65 -0
- package/dist/reply-artifacts.d.ts.map +1 -0
- package/dist/reply-artifacts.js +1147 -0
- package/dist/reply-artifacts.js.map +1 -0
- package/dist/reply-part-budget.d.ts +16 -0
- package/dist/reply-part-budget.d.ts.map +1 -0
- package/dist/reply-part-budget.js +57 -0
- package/dist/reply-part-budget.js.map +1 -0
- package/dist/request-model-override.d.ts +19 -0
- package/dist/request-model-override.d.ts.map +1 -1
- package/dist/request-model-override.js +54 -1
- package/dist/request-model-override.js.map +1 -1
- package/dist/request-scoped-mcp.d.ts +31 -0
- package/dist/request-scoped-mcp.d.ts.map +1 -0
- package/dist/request-scoped-mcp.js +197 -0
- package/dist/request-scoped-mcp.js.map +1 -0
- package/dist/run-history.d.ts.map +1 -1
- package/dist/run-history.js +50 -254
- package/dist/run-history.js.map +1 -1
- package/dist/runtime-option-extensions.d.ts +21 -0
- package/dist/runtime-option-extensions.d.ts.map +1 -1
- package/dist/runtime-option-extensions.js +53 -0
- package/dist/runtime-option-extensions.js.map +1 -1
- package/dist/secure-file-replace.d.ts +3 -0
- package/dist/secure-file-replace.d.ts.map +1 -1
- package/dist/secure-file-replace.js +31 -7
- package/dist/secure-file-replace.js.map +1 -1
- package/dist/session-history.d.ts +146 -0
- package/dist/session-history.d.ts.map +1 -0
- package/dist/session-history.js +347 -0
- package/dist/session-history.js.map +1 -0
- package/dist/sessions.d.ts +45 -2
- package/dist/sessions.d.ts.map +1 -1
- package/dist/sessions.js +849 -30
- package/dist/sessions.js.map +1 -1
- package/dist/web-command.d.ts +12 -11
- package/dist/web-command.d.ts.map +1 -1
- package/dist/web-command.js +554 -80
- package/dist/web-command.js.map +1 -1
- package/dist/web-log-maintenance-command.d.ts +7 -0
- package/dist/web-log-maintenance-command.d.ts.map +1 -0
- package/dist/web-log-maintenance-command.js +21 -0
- package/dist/web-log-maintenance-command.js.map +1 -0
- package/dist/web-log-maintenance-status.d.ts +26 -0
- package/dist/web-log-maintenance-status.d.ts.map +1 -0
- package/dist/web-log-maintenance-status.js +171 -0
- package/dist/web-log-maintenance-status.js.map +1 -0
- package/dist/web-log-maintenance.d.ts +32 -0
- package/dist/web-log-maintenance.d.ts.map +1 -0
- package/dist/web-log-maintenance.js +163 -0
- package/dist/web-log-maintenance.js.map +1 -0
- package/dist/web-maintenance-paths.d.ts +12 -0
- package/dist/web-maintenance-paths.d.ts.map +1 -0
- package/dist/web-maintenance-paths.js +24 -0
- package/dist/web-maintenance-paths.js.map +1 -0
- package/dist/wizard/prompts.d.ts.map +1 -1
- package/dist/wizard/prompts.js +1 -0
- package/dist/wizard/prompts.js.map +1 -1
- package/dist/wizard/run.js +1 -1
- package/dist/wizard/run.js.map +1 -1
- package/package.json +15 -15
- package/schema/mono-agent.config.schema.json +102 -1
- package/skills/mono-agent-composer/references/config-blueprint.md +26 -2
- package/skills/mono-agent-composer/references/discovery-questions.md +2 -2
- package/skills/mono-agent-composer/references/feature-coverage.md +6 -4
- package/skills/mono-agent-composer/references/package-map.md +19 -3
- package/skills/mono-agent-composer/references/playbooks.md +3 -3
- package/skills/mono-agent-composer/references/validation.md +4 -2
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { type OwnerPrivateLock } from "./owner-private-lock.js";
|
|
2
|
+
import type { ProcessIncarnation, SameProcessIncarnation } from "./process-incarnation.js";
|
|
3
|
+
export declare const PROCESS_JOBS_GENERATION_DRAIN_TIMEOUT_MS = 30000;
|
|
4
|
+
export declare const AGENT_ROOT_OWNED_ELSEWHERE_ERROR = "Another mono-agent process is already using this agent root. Stop that local agent before trying again.";
|
|
5
|
+
export declare const AGENT_ROOT_REQUIRED_ERROR = "A configured local runtime requires an explicit agent-root cwd.";
|
|
6
|
+
export declare const AGENT_ROOT_WORKSPACE_REQUIRED_ERROR = "runtime.workspace must reference an existing directory before mono-agent starts. Create it or choose an existing workspace.";
|
|
7
|
+
export declare const PROCESS_JOBS_GENERATION_CHANGED_ERROR = "Process-job private-state protection changed before provider execution.";
|
|
8
|
+
export declare const PROCESS_JOBS_GENERATION_DRAIN_TIMEOUT_ERROR = "Process-job private-state protection could not safely finish the live configuration switch.";
|
|
9
|
+
export interface AgentRootProtectionGeneration {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly rootKeys: readonly string[];
|
|
12
|
+
}
|
|
13
|
+
export interface AgentRootRequestLease {
|
|
14
|
+
readonly generation: AgentRootProtectionGeneration;
|
|
15
|
+
releaseAfterSettlement(): void;
|
|
16
|
+
}
|
|
17
|
+
export interface AgentRootMutationGate {
|
|
18
|
+
readonly generation: AgentRootProtectionGeneration;
|
|
19
|
+
release(): void;
|
|
20
|
+
}
|
|
21
|
+
export interface AgentRootOwnership {
|
|
22
|
+
readonly agentRoot: string;
|
|
23
|
+
readonly coordinator: AgentRootCoordinator;
|
|
24
|
+
/** Release this in-process reference; the OS lease remains until every request truly settles. */
|
|
25
|
+
release(): void;
|
|
26
|
+
}
|
|
27
|
+
export interface AcquireAgentRootOwnershipOptions {
|
|
28
|
+
readonly homeDir?: string;
|
|
29
|
+
readonly pid?: number;
|
|
30
|
+
readonly now?: () => number;
|
|
31
|
+
readonly randomToken?: () => string;
|
|
32
|
+
readonly processIncarnation?: ProcessIncarnation;
|
|
33
|
+
readonly isSameProcessIncarnation?: SameProcessIncarnation;
|
|
34
|
+
readonly ownerlessGraceMs?: number;
|
|
35
|
+
readonly hooks?: {
|
|
36
|
+
readonly afterLeaseDirectoryCreated?: () => Promise<void>;
|
|
37
|
+
readonly beforeStaleLeaseRename?: () => Promise<void>;
|
|
38
|
+
/** Test-only fault seam for the final physical owner-lock release. */
|
|
39
|
+
readonly beforeLeaseRelease?: () => Promise<void>;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** Stable owner-record path for an already-canonical agent root. */
|
|
43
|
+
export declare function agentRootLeasePath(canonicalRoot: string, homeDir?: string): string;
|
|
44
|
+
interface ActiveGeneration {
|
|
45
|
+
readonly roots: ReadonlySet<string>;
|
|
46
|
+
count: number;
|
|
47
|
+
}
|
|
48
|
+
interface CoordinatorEntry {
|
|
49
|
+
readonly agentRoot: string;
|
|
50
|
+
readonly lease: OwnerPrivateLock;
|
|
51
|
+
readonly leasePath: string;
|
|
52
|
+
readonly beforeLeaseRelease?: () => Promise<void>;
|
|
53
|
+
readonly active: Map<string, ActiveGeneration>;
|
|
54
|
+
readonly waiters: Set<() => void>;
|
|
55
|
+
ownerRefs: number;
|
|
56
|
+
current?: AgentRootProtectionGeneration;
|
|
57
|
+
mutationPending: boolean;
|
|
58
|
+
closing: boolean;
|
|
59
|
+
closeError?: Error;
|
|
60
|
+
closed: Promise<void>;
|
|
61
|
+
resolveClosed: () => void;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* One process-global coordinator per canonical agent root. It combines the
|
|
65
|
+
* cross-process lifetime lease with in-process registry-generation settlement.
|
|
66
|
+
*/
|
|
67
|
+
export declare class AgentRootCoordinator {
|
|
68
|
+
#private;
|
|
69
|
+
constructor(entry: CoordinatorEntry);
|
|
70
|
+
get agentRoot(): string;
|
|
71
|
+
currentGeneration(): AgentRootProtectionGeneration | undefined;
|
|
72
|
+
publishGeneration(generation: AgentRootProtectionGeneration): void;
|
|
73
|
+
/** Adopt an already-durable generation without allowing a stale constructor to roll it back. */
|
|
74
|
+
synchronizeGeneration(generation: AgentRootProtectionGeneration): void;
|
|
75
|
+
acquireRequestLease(generation: AgentRootProtectionGeneration): AgentRootRequestLease;
|
|
76
|
+
/**
|
|
77
|
+
* Publish the durable generation, then wait only for older leases which did
|
|
78
|
+
* not cover the root about to be opened. Timeout is fail-closed: callers must
|
|
79
|
+
* not open or create the ProcessJobs store after rejection.
|
|
80
|
+
*/
|
|
81
|
+
publishAndAcquireMutationGate(generation: AgentRootProtectionGeneration, requiredRootKey: string, options?: {
|
|
82
|
+
readonly timeoutMs?: number;
|
|
83
|
+
}): Promise<AgentRootMutationGate>;
|
|
84
|
+
/** Test/coordination seam: resolves only when no request lease remains. */
|
|
85
|
+
waitForSettlement(): Promise<void>;
|
|
86
|
+
}
|
|
87
|
+
/** Acquire the reentrant process lifetime owner for one canonical agent root. */
|
|
88
|
+
export declare function acquireAgentRootOwnership(agentRoot: string | undefined, options?: AcquireAgentRootOwnershipOptions): Promise<AgentRootOwnership>;
|
|
89
|
+
/**
|
|
90
|
+
* Release one logical owner and, only when it was the already-idle final
|
|
91
|
+
* reference, wait for the physical cross-process lease to disappear.
|
|
92
|
+
*
|
|
93
|
+
* Active request or mutation leases deliberately make this return `false`
|
|
94
|
+
* immediately. They retain the physical lock until true settlement so bounded
|
|
95
|
+
* app/harness teardown cannot create split ownership.
|
|
96
|
+
*/
|
|
97
|
+
export declare function releaseAgentRootOwnershipWhenIdle(ownership: AgentRootOwnership): Promise<boolean>;
|
|
98
|
+
/** Reject the exceptional case where the global coordination lease is model-workspace reachable. */
|
|
99
|
+
export declare function assertAgentRootLeaseOutsideWorkspace(ownership: AgentRootOwnership, workspace: string): void;
|
|
100
|
+
export {};
|
|
101
|
+
//# sourceMappingURL=agent-root-coordinator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-root-coordinator.d.ts","sourceRoot":"","sources":["../src/agent-root-coordinator.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAM3F,eAAO,MAAM,wCAAwC,QAAS,CAAC;AAE/D,eAAO,MAAM,gCAAgC,4GAC8D,CAAC;AAC5G,eAAO,MAAM,yBAAyB,oEAC6B,CAAC;AACpE,eAAO,MAAM,mCAAmC,gIAC+E,CAAC;AAChI,eAAO,MAAM,qCAAqC,4EACyB,CAAC;AAC5E,eAAO,MAAM,2CAA2C,gGACuC,CAAC;AAEhG,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,UAAU,EAAE,6BAA6B,CAAC;IACnD,sBAAsB,IAAI,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,UAAU,EAAE,6BAA6B,CAAC;IACnD,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,oBAAoB,CAAC;IAC3C,iGAAiG;IACjG,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,GAAG,CAAC,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";
|
|
3
|
+
import { chmod, lstat, mkdir, realpath } from "node:fs/promises";
|
|
4
|
+
import { join, relative, resolve } from "node:path";
|
|
5
|
+
import process from "node:process";
|
|
6
|
+
import { acquireOwnerPrivateLock, validateOwnerPrivateLockInputs, } from "./owner-private-lock.js";
|
|
7
|
+
import { accountHomeDirectory } from "./account-home.js";
|
|
8
|
+
const AGENT_ROOT_LEASE_SCHEMA = "mono-agent.agent-root-lease.v1";
|
|
9
|
+
const AGENT_ROOT_LEASE_OWNERLESS_GRACE_MS = 5 * 60_000;
|
|
10
|
+
const AGENT_ROOT_LEASE_ACQUIRE_ATTEMPTS = 4;
|
|
11
|
+
export const PROCESS_JOBS_GENERATION_DRAIN_TIMEOUT_MS = 30_000;
|
|
12
|
+
export const AGENT_ROOT_OWNED_ELSEWHERE_ERROR = "Another mono-agent process is already using this agent root. Stop that local agent before trying again.";
|
|
13
|
+
export const AGENT_ROOT_REQUIRED_ERROR = "A configured local runtime requires an explicit agent-root cwd.";
|
|
14
|
+
export const AGENT_ROOT_WORKSPACE_REQUIRED_ERROR = "runtime.workspace must reference an existing directory before mono-agent starts. Create it or choose an existing workspace.";
|
|
15
|
+
export const PROCESS_JOBS_GENERATION_CHANGED_ERROR = "Process-job private-state protection changed before provider execution.";
|
|
16
|
+
export const PROCESS_JOBS_GENERATION_DRAIN_TIMEOUT_ERROR = "Process-job private-state protection could not safely finish the live configuration switch.";
|
|
17
|
+
/** Stable owner-record path for an already-canonical agent root. */
|
|
18
|
+
export function agentRootLeasePath(canonicalRoot, homeDir = accountHomeDirectory()) {
|
|
19
|
+
const digest = rootDigest(canonicalRoot);
|
|
20
|
+
return join(resolve(homeDir), ".mono-agent", "agent-root-leases", `${digest}.lease`);
|
|
21
|
+
}
|
|
22
|
+
const entries = new Map();
|
|
23
|
+
const acquisitions = new Map();
|
|
24
|
+
const ownershipEntries = new WeakMap();
|
|
25
|
+
const releasedOwnerships = new WeakSet();
|
|
26
|
+
/**
|
|
27
|
+
* One process-global coordinator per canonical agent root. It combines the
|
|
28
|
+
* cross-process lifetime lease with in-process registry-generation settlement.
|
|
29
|
+
*/
|
|
30
|
+
export class AgentRootCoordinator {
|
|
31
|
+
#entry;
|
|
32
|
+
constructor(entry) {
|
|
33
|
+
this.#entry = entry;
|
|
34
|
+
}
|
|
35
|
+
get agentRoot() {
|
|
36
|
+
return this.#entry.agentRoot;
|
|
37
|
+
}
|
|
38
|
+
currentGeneration() {
|
|
39
|
+
return this.#entry.current;
|
|
40
|
+
}
|
|
41
|
+
publishGeneration(generation) {
|
|
42
|
+
assertGeneration(generation);
|
|
43
|
+
this.#entry.current = frozenGeneration(generation);
|
|
44
|
+
notifyWaiters(this.#entry);
|
|
45
|
+
}
|
|
46
|
+
/** Adopt an already-durable generation without allowing a stale constructor to roll it back. */
|
|
47
|
+
synchronizeGeneration(generation) {
|
|
48
|
+
assertGeneration(generation);
|
|
49
|
+
if (this.#entry.current === undefined) {
|
|
50
|
+
this.publishGeneration(generation);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (!sameGeneration(this.#entry.current, generation)) {
|
|
54
|
+
throw new Error(PROCESS_JOBS_GENERATION_CHANGED_ERROR);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
acquireRequestLease(generation) {
|
|
58
|
+
if (this.#entry.closing) {
|
|
59
|
+
throw this.#entry.closeError
|
|
60
|
+
?? new Error("Agent-root ownership is already being released.");
|
|
61
|
+
}
|
|
62
|
+
assertGeneration(generation);
|
|
63
|
+
const current = this.#entry.current;
|
|
64
|
+
if (current === undefined || !sameGeneration(current, generation)) {
|
|
65
|
+
throw new Error(PROCESS_JOBS_GENERATION_CHANGED_ERROR);
|
|
66
|
+
}
|
|
67
|
+
let active = this.#entry.active.get(generation.id);
|
|
68
|
+
if (active === undefined) {
|
|
69
|
+
active = { roots: new Set(generation.rootKeys), count: 0 };
|
|
70
|
+
this.#entry.active.set(generation.id, active);
|
|
71
|
+
}
|
|
72
|
+
else if (!sameRoots(active.roots, generation.rootKeys)) {
|
|
73
|
+
throw new Error(PROCESS_JOBS_GENERATION_CHANGED_ERROR);
|
|
74
|
+
}
|
|
75
|
+
active.count += 1;
|
|
76
|
+
let released = false;
|
|
77
|
+
return {
|
|
78
|
+
generation: frozenGeneration(generation),
|
|
79
|
+
releaseAfterSettlement: () => {
|
|
80
|
+
if (released)
|
|
81
|
+
return;
|
|
82
|
+
released = true;
|
|
83
|
+
const held = this.#entry.active.get(generation.id);
|
|
84
|
+
if (held === undefined || held.count < 1)
|
|
85
|
+
return;
|
|
86
|
+
held.count -= 1;
|
|
87
|
+
if (held.count === 0)
|
|
88
|
+
this.#entry.active.delete(generation.id);
|
|
89
|
+
notifyWaiters(this.#entry);
|
|
90
|
+
scheduleFinalRelease(this.#entry);
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Publish the durable generation, then wait only for older leases which did
|
|
96
|
+
* not cover the root about to be opened. Timeout is fail-closed: callers must
|
|
97
|
+
* not open or create the ProcessJobs store after rejection.
|
|
98
|
+
*/
|
|
99
|
+
async publishAndAcquireMutationGate(generation, requiredRootKey, options = {}) {
|
|
100
|
+
if (this.#entry.closing) {
|
|
101
|
+
throw this.#entry.closeError
|
|
102
|
+
?? new Error("Agent-root ownership is already being released.");
|
|
103
|
+
}
|
|
104
|
+
if (this.#entry.mutationPending) {
|
|
105
|
+
throw new Error(PROCESS_JOBS_GENERATION_CHANGED_ERROR);
|
|
106
|
+
}
|
|
107
|
+
this.publishGeneration(generation);
|
|
108
|
+
this.#entry.mutationPending = true;
|
|
109
|
+
const timeoutMs = options.timeoutMs ?? PROCESS_JOBS_GENERATION_DRAIN_TIMEOUT_MS;
|
|
110
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs < 1) {
|
|
111
|
+
this.#entry.mutationPending = false;
|
|
112
|
+
throw new TypeError("Process-job generation drain timeout must be a positive finite number.");
|
|
113
|
+
}
|
|
114
|
+
try {
|
|
115
|
+
await waitUntil(this.#entry, () => !hasIncompatibleLease(this.#entry, generation.id, requiredRootKey), timeoutMs);
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
this.#entry.mutationPending = false;
|
|
119
|
+
notifyWaiters(this.#entry);
|
|
120
|
+
scheduleFinalRelease(this.#entry);
|
|
121
|
+
if (error instanceof DrainTimeoutError) {
|
|
122
|
+
throw new Error(PROCESS_JOBS_GENERATION_DRAIN_TIMEOUT_ERROR);
|
|
123
|
+
}
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
let released = false;
|
|
127
|
+
return {
|
|
128
|
+
generation: frozenGeneration(generation),
|
|
129
|
+
release: () => {
|
|
130
|
+
if (released)
|
|
131
|
+
return;
|
|
132
|
+
released = true;
|
|
133
|
+
this.#entry.mutationPending = false;
|
|
134
|
+
notifyWaiters(this.#entry);
|
|
135
|
+
scheduleFinalRelease(this.#entry);
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
/** Test/coordination seam: resolves only when no request lease remains. */
|
|
140
|
+
async waitForSettlement() {
|
|
141
|
+
await waitUntil(this.#entry, () => this.#entry.active.size === 0, undefined);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/** Acquire the reentrant process lifetime owner for one canonical agent root. */
|
|
145
|
+
export async function acquireAgentRootOwnership(agentRoot, options = {}) {
|
|
146
|
+
if (agentRoot === undefined || agentRoot.trim().length === 0) {
|
|
147
|
+
throw new Error(AGENT_ROOT_REQUIRED_ERROR);
|
|
148
|
+
}
|
|
149
|
+
const canonicalRoot = await canonicalAgentRoot(agentRoot);
|
|
150
|
+
for (;;) {
|
|
151
|
+
const existing = entries.get(canonicalRoot);
|
|
152
|
+
if (existing !== undefined) {
|
|
153
|
+
if (existing.closing) {
|
|
154
|
+
await existing.closed;
|
|
155
|
+
if (existing.closeError !== undefined)
|
|
156
|
+
throw existing.closeError;
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
existing.ownerRefs += 1;
|
|
160
|
+
return ownershipHandle(existing);
|
|
161
|
+
}
|
|
162
|
+
const pending = acquisitions.get(canonicalRoot);
|
|
163
|
+
if (pending !== undefined) {
|
|
164
|
+
const entry = await pending;
|
|
165
|
+
if (entry.closing) {
|
|
166
|
+
await entry.closed;
|
|
167
|
+
if (entry.closeError !== undefined)
|
|
168
|
+
throw entry.closeError;
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
entry.ownerRefs += 1;
|
|
172
|
+
return ownershipHandle(entry);
|
|
173
|
+
}
|
|
174
|
+
const acquiring = createEntry(canonicalRoot, options);
|
|
175
|
+
acquisitions.set(canonicalRoot, acquiring);
|
|
176
|
+
try {
|
|
177
|
+
const entry = await acquiring;
|
|
178
|
+
entries.set(canonicalRoot, entry);
|
|
179
|
+
entry.ownerRefs = 1;
|
|
180
|
+
return ownershipHandle(entry);
|
|
181
|
+
}
|
|
182
|
+
finally {
|
|
183
|
+
if (acquisitions.get(canonicalRoot) === acquiring)
|
|
184
|
+
acquisitions.delete(canonicalRoot);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Release one logical owner and, only when it was the already-idle final
|
|
190
|
+
* reference, wait for the physical cross-process lease to disappear.
|
|
191
|
+
*
|
|
192
|
+
* Active request or mutation leases deliberately make this return `false`
|
|
193
|
+
* immediately. They retain the physical lock until true settlement so bounded
|
|
194
|
+
* app/harness teardown cannot create split ownership.
|
|
195
|
+
*/
|
|
196
|
+
export async function releaseAgentRootOwnershipWhenIdle(ownership) {
|
|
197
|
+
const entry = entryFor(ownership);
|
|
198
|
+
if (releasedOwnerships.has(ownership)) {
|
|
199
|
+
if (!entry.closing)
|
|
200
|
+
return false;
|
|
201
|
+
await entry.closed;
|
|
202
|
+
if (entry.closeError !== undefined)
|
|
203
|
+
throw entry.closeError;
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
const shouldWait = releaseOwnershipReference(ownership, entry);
|
|
207
|
+
if (!shouldWait)
|
|
208
|
+
return false;
|
|
209
|
+
await entry.closed;
|
|
210
|
+
if (entry.closeError !== undefined)
|
|
211
|
+
throw entry.closeError;
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
/** Reject the exceptional case where the global coordination lease is model-workspace reachable. */
|
|
215
|
+
export function assertAgentRootLeaseOutsideWorkspace(ownership, workspace) {
|
|
216
|
+
const entry = entryFor(ownership);
|
|
217
|
+
const resolvedWorkspace = resolve(workspace);
|
|
218
|
+
let canonicalWorkspace;
|
|
219
|
+
try {
|
|
220
|
+
canonicalWorkspace = realpathSync(resolvedWorkspace);
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
if (isErrno(error, "ENOENT"))
|
|
224
|
+
throw new Error(AGENT_ROOT_WORKSPACE_REQUIRED_ERROR);
|
|
225
|
+
throw error;
|
|
226
|
+
}
|
|
227
|
+
if (containsPath(resolvedWorkspace, entry.leasePath)
|
|
228
|
+
|| containsPath(canonicalWorkspace, entry.leasePath)) {
|
|
229
|
+
throw new Error("The configured model workspace contains mono-agent's private process-coordination data. Choose a narrower workspace.");
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
function ownershipHandle(entry) {
|
|
233
|
+
const coordinator = new AgentRootCoordinator(entry);
|
|
234
|
+
const handle = {
|
|
235
|
+
agentRoot: entry.agentRoot,
|
|
236
|
+
coordinator,
|
|
237
|
+
release: () => {
|
|
238
|
+
releaseOwnershipReference(handle, entry);
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
ownershipEntries.set(handle, entry);
|
|
242
|
+
return handle;
|
|
243
|
+
}
|
|
244
|
+
function releaseOwnershipReference(ownership, entry) {
|
|
245
|
+
if (releasedOwnerships.has(ownership))
|
|
246
|
+
return false;
|
|
247
|
+
releasedOwnerships.add(ownership);
|
|
248
|
+
entry.ownerRefs = Math.max(0, entry.ownerRefs - 1);
|
|
249
|
+
const shouldWait = entry.ownerRefs === 0
|
|
250
|
+
&& entry.active.size === 0
|
|
251
|
+
&& !entry.mutationPending
|
|
252
|
+
&& !entry.closing;
|
|
253
|
+
scheduleFinalRelease(entry);
|
|
254
|
+
return shouldWait;
|
|
255
|
+
}
|
|
256
|
+
function entryFor(ownership) {
|
|
257
|
+
const entry = ownershipEntries.get(ownership);
|
|
258
|
+
if (entry === undefined)
|
|
259
|
+
throw new Error("Agent-root ownership handle is invalid.");
|
|
260
|
+
return entry;
|
|
261
|
+
}
|
|
262
|
+
async function createEntry(canonicalRoot, options) {
|
|
263
|
+
try {
|
|
264
|
+
const home = resolve(options.homeDir ?? accountHomeDirectory());
|
|
265
|
+
const leaseRoot = await ensurePrivateLeaseRoot(home);
|
|
266
|
+
const digest = rootDigest(canonicalRoot);
|
|
267
|
+
const leasePath = agentRootLeasePath(canonicalRoot, home);
|
|
268
|
+
const pid = options.pid ?? process.pid;
|
|
269
|
+
const ownerlessGraceMs = options.ownerlessGraceMs ?? AGENT_ROOT_LEASE_OWNERLESS_GRACE_MS;
|
|
270
|
+
validateOwnerPrivateLockInputs("Agent-root lease", pid, ownerlessGraceMs);
|
|
271
|
+
const lease = await acquireOwnerPrivateLock({
|
|
272
|
+
path: leasePath,
|
|
273
|
+
label: "Agent-root lease",
|
|
274
|
+
schemaTag: AGENT_ROOT_LEASE_SCHEMA,
|
|
275
|
+
ownerlessGraceMs,
|
|
276
|
+
maxAcquireAttempts: AGENT_ROOT_LEASE_ACQUIRE_ATTEMPTS,
|
|
277
|
+
pid,
|
|
278
|
+
...(options.now === undefined ? {} : { now: options.now }),
|
|
279
|
+
randomToken: options.randomToken ?? (() => randomUUID()),
|
|
280
|
+
...(options.processIncarnation === undefined ? {} : { processIncarnation: options.processIncarnation }),
|
|
281
|
+
...(options.isSameProcessIncarnation === undefined
|
|
282
|
+
? {}
|
|
283
|
+
: { isSameProcessIncarnation: options.isSameProcessIncarnation }),
|
|
284
|
+
ownerFields: () => ({ rootDigest: digest }),
|
|
285
|
+
validateOwnerFields: (record) => record.rootDigest === digest,
|
|
286
|
+
invalidOwner: "error",
|
|
287
|
+
livenessError: () => "assume-live",
|
|
288
|
+
...(options.hooks?.afterLeaseDirectoryCreated === undefined
|
|
289
|
+
? {}
|
|
290
|
+
: { afterDirectoryCreated: options.hooks.afterLeaseDirectoryCreated }),
|
|
291
|
+
...(options.hooks?.beforeStaleLeaseRename === undefined
|
|
292
|
+
? {}
|
|
293
|
+
: { beforeStaleRename: options.hooks.beforeStaleLeaseRename }),
|
|
294
|
+
staleRace: "return",
|
|
295
|
+
stalePath: ({ now, pid: stalePid, token }) => join(leaseRoot, `.${digest}-${now}-${stalePid}-${token}.stale`),
|
|
296
|
+
releasedPath: ({ pid: ownerPid, token }) => join(leaseRoot, `.${digest}-${ownerPid}-${token}.released`),
|
|
297
|
+
abandonedPath: ({ pid: ownerPid, token }) => join(leaseRoot, `.${digest}-${ownerPid}-${token}.abandoned`),
|
|
298
|
+
});
|
|
299
|
+
if (lease === undefined)
|
|
300
|
+
throw new Error(AGENT_ROOT_OWNED_ELSEWHERE_ERROR);
|
|
301
|
+
let resolveClosed;
|
|
302
|
+
const closed = new Promise((resolveClosedPromise) => { resolveClosed = resolveClosedPromise; });
|
|
303
|
+
return {
|
|
304
|
+
agentRoot: canonicalRoot,
|
|
305
|
+
lease,
|
|
306
|
+
leasePath,
|
|
307
|
+
...(options.hooks?.beforeLeaseRelease === undefined
|
|
308
|
+
? {}
|
|
309
|
+
: { beforeLeaseRelease: options.hooks.beforeLeaseRelease }),
|
|
310
|
+
active: new Map(),
|
|
311
|
+
waiters: new Set(),
|
|
312
|
+
ownerRefs: 0,
|
|
313
|
+
mutationPending: false,
|
|
314
|
+
closing: false,
|
|
315
|
+
closed,
|
|
316
|
+
resolveClosed,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
catch (error) {
|
|
320
|
+
if (error instanceof Error && error.message === AGENT_ROOT_OWNED_ELSEWHERE_ERROR)
|
|
321
|
+
throw error;
|
|
322
|
+
throw new Error("Mono-agent could not establish private ownership of this agent root. Check the local owner and permissions, then retry.", { cause: error });
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
function scheduleFinalRelease(entry) {
|
|
326
|
+
if (entry.ownerRefs !== 0 || entry.active.size !== 0 || entry.mutationPending || entry.closing)
|
|
327
|
+
return;
|
|
328
|
+
entry.closing = true;
|
|
329
|
+
void (async () => {
|
|
330
|
+
try {
|
|
331
|
+
await entry.lease.release(entry.beforeLeaseRelease === undefined
|
|
332
|
+
? undefined
|
|
333
|
+
: { beforeRename: entry.beforeLeaseRelease });
|
|
334
|
+
if (entries.get(entry.agentRoot) === entry)
|
|
335
|
+
entries.delete(entry.agentRoot);
|
|
336
|
+
}
|
|
337
|
+
catch (error) {
|
|
338
|
+
// The physical lock may be in an indeterminate release state. Keep this
|
|
339
|
+
// coordinator permanently closed so this process cannot loop or split
|
|
340
|
+
// into a second logical owner. Process restart is the recovery boundary.
|
|
341
|
+
entry.closeError = new Error("Mono-agent could not safely release ownership of this agent root. Restart the local process before retrying.", { cause: error });
|
|
342
|
+
}
|
|
343
|
+
finally {
|
|
344
|
+
entry.resolveClosed();
|
|
345
|
+
}
|
|
346
|
+
})();
|
|
347
|
+
}
|
|
348
|
+
function notifyWaiters(entry) {
|
|
349
|
+
for (const notify of [...entry.waiters])
|
|
350
|
+
notify();
|
|
351
|
+
}
|
|
352
|
+
async function waitUntil(entry, predicate, timeoutMs) {
|
|
353
|
+
if (predicate())
|
|
354
|
+
return;
|
|
355
|
+
await new Promise((resolvePromise, rejectPromise) => {
|
|
356
|
+
let timer;
|
|
357
|
+
const finish = () => {
|
|
358
|
+
if (!predicate())
|
|
359
|
+
return;
|
|
360
|
+
cleanup();
|
|
361
|
+
resolvePromise();
|
|
362
|
+
};
|
|
363
|
+
const cleanup = () => {
|
|
364
|
+
entry.waiters.delete(finish);
|
|
365
|
+
if (timer !== undefined)
|
|
366
|
+
clearTimeout(timer);
|
|
367
|
+
};
|
|
368
|
+
entry.waiters.add(finish);
|
|
369
|
+
if (timeoutMs !== undefined) {
|
|
370
|
+
timer = setTimeout(() => {
|
|
371
|
+
cleanup();
|
|
372
|
+
rejectPromise(new DrainTimeoutError());
|
|
373
|
+
}, timeoutMs);
|
|
374
|
+
timer.unref?.();
|
|
375
|
+
}
|
|
376
|
+
finish();
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
class DrainTimeoutError extends Error {
|
|
380
|
+
}
|
|
381
|
+
function hasIncompatibleLease(entry, currentGenerationId, requiredRootKey) {
|
|
382
|
+
for (const [generationId, active] of entry.active) {
|
|
383
|
+
if (active.count < 1)
|
|
384
|
+
continue;
|
|
385
|
+
if (generationId === currentGenerationId && active.roots.has(requiredRootKey))
|
|
386
|
+
continue;
|
|
387
|
+
if (!active.roots.has(requiredRootKey))
|
|
388
|
+
return true;
|
|
389
|
+
}
|
|
390
|
+
return false;
|
|
391
|
+
}
|
|
392
|
+
function assertGeneration(generation) {
|
|
393
|
+
if (generation.id.length === 0 || generation.rootKeys.some((root) => root.length === 0)) {
|
|
394
|
+
throw new TypeError("Agent-root protection generation is malformed.");
|
|
395
|
+
}
|
|
396
|
+
const sorted = [...new Set(generation.rootKeys)].sort();
|
|
397
|
+
if (!sameStringArrays(sorted, generation.rootKeys)) {
|
|
398
|
+
throw new TypeError("Agent-root protection roots must be unique and sorted.");
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
function frozenGeneration(generation) {
|
|
402
|
+
return Object.freeze({ id: generation.id, rootKeys: Object.freeze([...generation.rootKeys]) });
|
|
403
|
+
}
|
|
404
|
+
function sameGeneration(left, right) {
|
|
405
|
+
return left.id === right.id && sameStringArrays(left.rootKeys, right.rootKeys);
|
|
406
|
+
}
|
|
407
|
+
function sameRoots(left, right) {
|
|
408
|
+
return left.size === right.length && right.every((root) => left.has(root));
|
|
409
|
+
}
|
|
410
|
+
function sameStringArrays(left, right) {
|
|
411
|
+
return left.length === right.length && left.every((value, index) => value === right[index]);
|
|
412
|
+
}
|
|
413
|
+
async function canonicalAgentRoot(path) {
|
|
414
|
+
const canonical = await realpath(resolve(path));
|
|
415
|
+
const details = await lstat(canonical);
|
|
416
|
+
if (!details.isDirectory() || details.isSymbolicLink()) {
|
|
417
|
+
throw new Error("The agent root must be a real directory.");
|
|
418
|
+
}
|
|
419
|
+
assertOwned(details, "The agent root");
|
|
420
|
+
return canonical;
|
|
421
|
+
}
|
|
422
|
+
async function ensurePrivateLeaseRoot(home) {
|
|
423
|
+
const homeDetails = await lstat(home);
|
|
424
|
+
if (!homeDetails.isDirectory() || homeDetails.isSymbolicLink()) {
|
|
425
|
+
throw new Error("The effective-user home must be a real directory.");
|
|
426
|
+
}
|
|
427
|
+
assertOwned(homeDetails, "The effective-user home");
|
|
428
|
+
const managedRoot = join(home, ".mono-agent");
|
|
429
|
+
const leaseRoot = join(managedRoot, "agent-root-leases");
|
|
430
|
+
for (const path of [managedRoot, leaseRoot]) {
|
|
431
|
+
try {
|
|
432
|
+
await mkdir(path, { mode: 0o700 });
|
|
433
|
+
}
|
|
434
|
+
catch (error) {
|
|
435
|
+
if (!isErrno(error, "EEXIST"))
|
|
436
|
+
throw error;
|
|
437
|
+
}
|
|
438
|
+
const before = await lstat(path);
|
|
439
|
+
if (!before.isDirectory() || before.isSymbolicLink()) {
|
|
440
|
+
throw new Error("The agent-root lease parent must be a real directory.");
|
|
441
|
+
}
|
|
442
|
+
assertOwned(before, "The agent-root lease parent");
|
|
443
|
+
await chmod(path, 0o700);
|
|
444
|
+
const after = await lstat(path);
|
|
445
|
+
if (before.dev !== after.dev || before.ino !== after.ino || (after.mode & 0o077) !== 0) {
|
|
446
|
+
throw new Error("The agent-root lease parent changed while it was secured.");
|
|
447
|
+
}
|
|
448
|
+
assertOwned(after, "The agent-root lease parent");
|
|
449
|
+
}
|
|
450
|
+
return leaseRoot;
|
|
451
|
+
}
|
|
452
|
+
function assertOwned(details, label) {
|
|
453
|
+
if (typeof process.getuid === "function" && details.uid !== process.getuid()) {
|
|
454
|
+
throw new Error(`${label} is not owned by the current user.`);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
function containsPath(parent, child) {
|
|
458
|
+
const fromParent = relative(parent, child);
|
|
459
|
+
return fromParent === "" || (!fromParent.startsWith("..") && !isAbsolutePath(fromParent));
|
|
460
|
+
}
|
|
461
|
+
function rootDigest(canonicalRoot) {
|
|
462
|
+
return createHash("sha256").update(resolve(canonicalRoot)).digest("hex");
|
|
463
|
+
}
|
|
464
|
+
function isAbsolutePath(path) {
|
|
465
|
+
return resolve(path) === path;
|
|
466
|
+
}
|
|
467
|
+
function isErrno(error, code) {
|
|
468
|
+
return typeof error === "object" && error !== null && error.code === code;
|
|
469
|
+
}
|
|
470
|
+
//# sourceMappingURL=agent-root-coordinator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-root-coordinator.js","sourceRoot":"","sources":["../src/agent-root-coordinator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,YAAY,EAAc,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EACL,uBAAuB,EACvB,8BAA8B,GAE/B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,uBAAuB,GAAG,gCAAgC,CAAC;AACjE,MAAM,mCAAmC,GAAG,CAAC,GAAG,MAAM,CAAC;AACvD,MAAM,iCAAiC,GAAG,CAAC,CAAC;AAC5C,MAAM,CAAC,MAAM,wCAAwC,GAAG,MAAM,CAAC;AAE/D,MAAM,CA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CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;AAC5F,CAAC;AAED,SAAS,UAAU,CAAC,aAAqB;IACvC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC3E,CAAC;AAED,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;AAChC,CAAC;AAED,SAAS,OAAO,CAAC,KAAc,EAAE,IAAY;IAC3C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAK,KAA4B,CAAC,IAAI,KAAK,IAAI,CAAC;AACpG,CAAC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { MonoAgentConfig } from "@mono-agent/config";
|
|
2
|
-
import type { AgentResponder } from "@mono-agent/agent-contracts";
|
|
2
|
+
import type { AgentResponder, NotifyDeliveryContext } from "@mono-agent/agent-contracts";
|
|
3
3
|
import type { ChannelDriver, ChannelId, MonoAgentAppLogger, RunningChannel, ChannelStatus } from "./channels.js";
|
|
4
4
|
import type { ConfigApplyResult, TraceabilityStatus } from "./app-controller-types.js";
|
|
5
5
|
import type { InteractionBridgeHandle } from "./interaction-bridge.js";
|
|
6
6
|
import type { ContinuationServiceHandle } from "./continuation-service.js";
|
|
7
7
|
import type { NotifyDeliveryResult } from "./proactive-notify.js";
|
|
8
8
|
import type { NotifyDestination } from "./notify-destinations.js";
|
|
9
|
+
import type { ProcessJobsServiceHandle } from "./process-jobs-service.js";
|
|
9
10
|
export interface ChannelsControllerPort {
|
|
10
11
|
readonly env: Record<string, string | undefined>;
|
|
11
12
|
readonly cwd: string;
|
|
@@ -15,8 +16,15 @@ export interface ChannelsControllerPort {
|
|
|
15
16
|
readonly driversById: ReadonlyMap<ChannelId, ChannelDriver>;
|
|
16
17
|
readonly statuses: Map<ChannelId, ChannelStatus>;
|
|
17
18
|
readonly running: Map<ChannelId, RunningChannel>;
|
|
19
|
+
readonly channelStartGenerations: Map<ChannelId, symbol>;
|
|
20
|
+
readonly startsInFlight: Map<ChannelId, Promise<ChannelStatus>>;
|
|
18
21
|
readonly stopped: boolean;
|
|
19
22
|
readonly traceabilityStatusValue: TraceabilityStatus;
|
|
23
|
+
readonly processJobsService: ProcessJobsServiceHandle | undefined;
|
|
24
|
+
readonly processJobsDegradation: {
|
|
25
|
+
readonly stateDir: string;
|
|
26
|
+
readonly reason: string;
|
|
27
|
+
} | undefined;
|
|
20
28
|
setStatus(id: ChannelId, status: ChannelStatus): ChannelStatus;
|
|
21
29
|
rememberSelectedSkills(coreConfig: MonoAgentConfig): void;
|
|
22
30
|
ensureInteractionBridge(coreConfig: MonoAgentConfig): Promise<InteractionBridgeHandle | undefined>;
|
|
@@ -25,6 +33,7 @@ export interface ChannelsControllerPort {
|
|
|
25
33
|
notifyDestination(conversationId: string, text: string, options?: {
|
|
26
34
|
readonly verbatim?: boolean;
|
|
27
35
|
readonly deliveryKey?: string;
|
|
36
|
+
readonly deliveryContext?: NotifyDeliveryContext;
|
|
28
37
|
}): Promise<NotifyDeliveryResult>;
|
|
29
38
|
listNotifyDestinations(): Promise<readonly NotifyDestination[]>;
|
|
30
39
|
observabilityContext(): Promise<{
|
|
@@ -32,6 +41,7 @@ export interface ChannelsControllerPort {
|
|
|
32
41
|
readonly sourceLabel?: string;
|
|
33
42
|
readonly configPath?: string;
|
|
34
43
|
}>;
|
|
44
|
+
refreshTraceSource(reason: string): Promise<void>;
|
|
35
45
|
activeTransports(): readonly string[];
|
|
36
46
|
}
|
|
37
47
|
export declare function startChannel(controller: ChannelsControllerPort, driver: ChannelDriver, reason: string): Promise<ChannelStatus>;
|