@1mcp/agent 0.34.4 → 0.35.0-beta.2
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 +1 -0
- package/build/admin/assets/admin-console-C5_zD_qW.css +1 -0
- package/build/admin/assets/admin-console-CbHHoqLr.js +61 -0
- package/build/admin/index.html +13 -0
- package/build/application/services/healthService.d.ts +32 -0
- package/build/application/services/healthService.d.ts.map +1 -1
- package/build/application/services/healthService.js +49 -0
- package/build/application/services/healthService.js.map +1 -1
- package/build/commands/admin/admin.d.ts +90 -0
- package/build/commands/admin/admin.d.ts.map +1 -0
- package/build/commands/admin/admin.js +545 -0
- package/build/commands/admin/admin.js.map +1 -0
- package/build/commands/admin/index.d.ts +3 -0
- package/build/commands/admin/index.d.ts.map +1 -0
- package/build/commands/admin/index.js +99 -0
- package/build/commands/admin/index.js.map +1 -0
- package/build/commands/auth/index.d.ts.map +1 -1
- package/build/commands/auth/index.js +24 -5
- package/build/commands/auth/index.js.map +1 -1
- package/build/commands/auth/login.d.ts +1 -0
- package/build/commands/auth/login.d.ts.map +1 -1
- package/build/commands/auth/login.js +6 -10
- package/build/commands/auth/login.js.map +1 -1
- package/build/commands/auth/logout.d.ts +3 -0
- package/build/commands/auth/logout.d.ts.map +1 -1
- package/build/commands/auth/logout.js +19 -32
- package/build/commands/auth/logout.js.map +1 -1
- package/build/commands/auth/runtimeTargetContext.d.ts +25 -0
- package/build/commands/auth/runtimeTargetContext.d.ts.map +1 -0
- package/build/commands/auth/runtimeTargetContext.js +69 -0
- package/build/commands/auth/runtimeTargetContext.js.map +1 -0
- package/build/commands/auth/status.d.ts +1 -0
- package/build/commands/auth/status.d.ts.map +1 -1
- package/build/commands/auth/status.js +10 -33
- package/build/commands/auth/status.js.map +1 -1
- package/build/commands/inspect/index.d.ts.map +1 -1
- package/build/commands/inspect/index.js +4 -0
- package/build/commands/inspect/index.js.map +1 -1
- package/build/commands/inspect/inspect.d.ts +1 -0
- package/build/commands/inspect/inspect.d.ts.map +1 -1
- package/build/commands/inspect/inspect.js +2 -2
- package/build/commands/inspect/inspect.js.map +1 -1
- package/build/commands/instructions/index.d.ts.map +1 -1
- package/build/commands/instructions/index.js +4 -0
- package/build/commands/instructions/index.js.map +1 -1
- package/build/commands/instructions/instructions.d.ts +1 -0
- package/build/commands/instructions/instructions.d.ts.map +1 -1
- package/build/commands/instructions/instructions.js.map +1 -1
- package/build/commands/instructions/instructionsUtils.js +1 -1
- package/build/commands/instructions/instructionsUtils.js.map +1 -1
- package/build/commands/mcp/enable.d.ts +89 -2
- package/build/commands/mcp/enable.d.ts.map +1 -1
- package/build/commands/mcp/enable.js +555 -35
- package/build/commands/mcp/enable.js.map +1 -1
- package/build/commands/mcp/index.d.ts.map +1 -1
- package/build/commands/mcp/index.js +10 -0
- package/build/commands/mcp/index.js.map +1 -1
- package/build/commands/mcp/restart.d.ts +69 -0
- package/build/commands/mcp/restart.d.ts.map +1 -0
- package/build/commands/mcp/restart.js +259 -0
- package/build/commands/mcp/restart.js.map +1 -0
- package/build/commands/mcp/status.d.ts +24 -1
- package/build/commands/mcp/status.d.ts.map +1 -1
- package/build/commands/mcp/status.js +158 -14
- package/build/commands/mcp/status.js.map +1 -1
- package/build/commands/proxy/index.d.ts +1 -0
- package/build/commands/proxy/index.d.ts.map +1 -1
- package/build/commands/proxy/index.js +4 -0
- package/build/commands/proxy/index.js.map +1 -1
- package/build/commands/run/index.d.ts.map +1 -1
- package/build/commands/run/index.js +4 -0
- package/build/commands/run/index.js.map +1 -1
- package/build/commands/run/run.d.ts +1 -0
- package/build/commands/run/run.d.ts.map +1 -1
- package/build/commands/run/run.js +2 -2
- package/build/commands/run/run.js.map +1 -1
- package/build/commands/serve/index.d.ts +8 -0
- package/build/commands/serve/index.d.ts.map +1 -1
- package/build/commands/serve/index.js +12 -0
- package/build/commands/serve/index.js.map +1 -1
- package/build/commands/serve/serve.d.ts +13 -0
- package/build/commands/serve/serve.d.ts.map +1 -1
- package/build/commands/serve/serve.js +115 -57
- package/build/commands/serve/serve.js.map +1 -1
- package/build/commands/serve/serveBackground.d.ts +48 -26
- package/build/commands/serve/serveBackground.d.ts.map +1 -1
- package/build/commands/serve/serveBackground.js +230 -61
- package/build/commands/serve/serveBackground.js.map +1 -1
- package/build/commands/serve/serveRestart.d.ts +1 -1
- package/build/commands/serve/serveRestart.js +1 -1
- package/build/commands/serve/serveStatus.d.ts +20 -10
- package/build/commands/serve/serveStatus.d.ts.map +1 -1
- package/build/commands/serve/serveStatus.js +174 -13
- package/build/commands/serve/serveStatus.js.map +1 -1
- package/build/commands/serve/serveStop.d.ts +13 -4
- package/build/commands/serve/serveStop.d.ts.map +1 -1
- package/build/commands/serve/serveStop.js +212 -23
- package/build/commands/serve/serveStop.js.map +1 -1
- package/build/commands/shared/apiClient.d.ts +5 -1
- package/build/commands/shared/apiClient.d.ts.map +1 -1
- package/build/commands/shared/apiClient.js +17 -9
- package/build/commands/shared/apiClient.js.map +1 -1
- package/build/commands/shared/clientSurfaceAttachment.d.ts +14 -0
- package/build/commands/shared/clientSurfaceAttachment.d.ts.map +1 -1
- package/build/commands/shared/clientSurfaceAttachment.js +51 -9
- package/build/commands/shared/clientSurfaceAttachment.js.map +1 -1
- package/build/commands/shared/commandRunner.d.ts +3 -1
- package/build/commands/shared/commandRunner.d.ts.map +1 -1
- package/build/commands/shared/commandRunner.js +59 -2
- package/build/commands/shared/commandRunner.js.map +1 -1
- package/build/commands/shared/serveTargetResolver.d.ts +14 -1
- package/build/commands/shared/serveTargetResolver.d.ts.map +1 -1
- package/build/commands/shared/serveTargetResolver.js +145 -3
- package/build/commands/shared/serveTargetResolver.js.map +1 -1
- package/build/commands/target/index.d.ts +3 -0
- package/build/commands/target/index.d.ts.map +1 -0
- package/build/commands/target/index.js +171 -0
- package/build/commands/target/index.js.map +1 -0
- package/build/commands/target/target.d.ts +78 -0
- package/build/commands/target/target.d.ts.map +1 -0
- package/build/commands/target/target.js +471 -0
- package/build/commands/target/target.js.map +1 -0
- package/build/config/configManager.d.ts +2 -0
- package/build/config/configManager.d.ts.map +1 -1
- package/build/config/configManager.js +19 -8
- package/build/config/configManager.js.map +1 -1
- package/build/config/mcpConfigMerge.d.ts.map +1 -1
- package/build/config/mcpConfigMerge.js +13 -2
- package/build/config/mcpConfigMerge.js.map +1 -1
- package/build/constants/mcp.d.ts +1 -1
- package/build/constants/mcp.d.ts.map +1 -1
- package/build/constants/mcp.js +1 -1
- package/build/constants/mcp.js.map +1 -1
- package/build/core/client/clientManager.d.ts +24 -1
- package/build/core/client/clientManager.d.ts.map +1 -1
- package/build/core/client/clientManager.js +268 -2
- package/build/core/client/clientManager.js.map +1 -1
- package/build/core/client/connectionHandler.d.ts.map +1 -1
- package/build/core/client/connectionHandler.js +18 -1
- package/build/core/client/connectionHandler.js.map +1 -1
- package/build/core/configChangeHandler.d.ts +1 -0
- package/build/core/configChangeHandler.d.ts.map +1 -1
- package/build/core/configChangeHandler.js +14 -0
- package/build/core/configChangeHandler.js.map +1 -1
- package/build/core/loading/mcpLoadingManager.d.ts.map +1 -1
- package/build/core/loading/mcpLoadingManager.js +16 -4
- package/build/core/loading/mcpLoadingManager.js.map +1 -1
- package/build/core/runtime/runtimeIdentityService.d.ts +30 -0
- package/build/core/runtime/runtimeIdentityService.d.ts.map +1 -0
- package/build/core/runtime/runtimeIdentityService.js +63 -0
- package/build/core/runtime/runtimeIdentityService.js.map +1 -0
- package/build/core/server/agentConfig.d.ts +4 -0
- package/build/core/server/agentConfig.d.ts.map +1 -1
- package/build/core/server/agentConfig.js +3 -0
- package/build/core/server/agentConfig.js.map +1 -1
- package/build/core/server/backendStdioSupervisor.d.ts +73 -0
- package/build/core/server/backendStdioSupervisor.d.ts.map +1 -0
- package/build/core/server/backendStdioSupervisor.js +191 -0
- package/build/core/server/backendStdioSupervisor.js.map +1 -0
- package/build/core/server/backgroundLaunchConfig.d.ts +15 -0
- package/build/core/server/backgroundLaunchConfig.d.ts.map +1 -0
- package/build/core/server/backgroundLaunchConfig.js +46 -0
- package/build/core/server/backgroundLaunchConfig.js.map +1 -0
- package/build/core/server/backgroundRuntimeSupervisor.d.ts +44 -0
- package/build/core/server/backgroundRuntimeSupervisor.d.ts.map +1 -0
- package/build/core/server/backgroundRuntimeSupervisor.js +252 -0
- package/build/core/server/backgroundRuntimeSupervisor.js.map +1 -0
- package/build/core/server/backgroundRuntimeSupervisorState.d.ts +30 -0
- package/build/core/server/backgroundRuntimeSupervisorState.d.ts.map +1 -0
- package/build/core/server/backgroundRuntimeSupervisorState.js +81 -0
- package/build/core/server/backgroundRuntimeSupervisorState.js.map +1 -0
- package/build/core/server/clientInstanceFactory.d.ts.map +1 -1
- package/build/core/server/clientInstanceFactory.js +1 -0
- package/build/core/server/clientInstanceFactory.js.map +1 -1
- package/build/core/server/clientInstancePool.d.ts +17 -5
- package/build/core/server/clientInstancePool.d.ts.map +1 -1
- package/build/core/server/clientInstancePool.js +198 -33
- package/build/core/server/clientInstancePool.js.map +1 -1
- package/build/core/server/clientInstancePoolTypes.d.ts +7 -1
- package/build/core/server/clientInstancePoolTypes.d.ts.map +1 -1
- package/build/core/server/clientInstancePoolTypes.js.map +1 -1
- package/build/core/server/runtimeScopeOwnership.d.ts +61 -0
- package/build/core/server/runtimeScopeOwnership.d.ts.map +1 -0
- package/build/core/server/runtimeScopeOwnership.js +544 -0
- package/build/core/server/runtimeScopeOwnership.js.map +1 -0
- package/build/core/server/serverManager.d.ts +2 -0
- package/build/core/server/serverManager.d.ts.map +1 -1
- package/build/core/server/serverManager.js +30 -0
- package/build/core/server/serverManager.js.map +1 -1
- package/build/core/server/templateIdentity.d.ts +10 -0
- package/build/core/server/templateIdentity.d.ts.map +1 -1
- package/build/core/server/templateIdentity.js +33 -0
- package/build/core/server/templateIdentity.js.map +1 -1
- package/build/core/server/templateServerCleanup.d.ts.map +1 -1
- package/build/core/server/templateServerCleanup.js +7 -1
- package/build/core/server/templateServerCleanup.js.map +1 -1
- package/build/core/server/templateServerManager.d.ts +13 -0
- package/build/core/server/templateServerManager.d.ts.map +1 -1
- package/build/core/server/templateServerManager.js +129 -4
- package/build/core/server/templateServerManager.js.map +1 -1
- package/build/core/tools/handlers/serverManagementHandler.d.ts +117 -11
- package/build/core/tools/handlers/serverManagementHandler.d.ts.map +1 -1
- package/build/core/tools/handlers/serverManagementHandler.js +103 -45
- package/build/core/tools/handlers/serverManagementHandler.js.map +1 -1
- package/build/core/tools/internal/adapters/helpers/configTransformers.d.ts +2 -2
- package/build/core/tools/internal/adapters/management/managementAdapter.d.ts +2 -2
- package/build/core/tools/internal/adapters/management/managementAdapter.d.ts.map +1 -1
- package/build/core/tools/internal/adapters/management/managementAdapter.js +45 -26
- package/build/core/tools/internal/adapters/management/managementAdapter.js.map +1 -1
- package/build/core/tools/internal/adapters/management/types.d.ts +21 -2
- package/build/core/tools/internal/adapters/management/types.d.ts.map +1 -1
- package/build/core/tools/internal/managementHandlers.d.ts.map +1 -1
- package/build/core/tools/internal/managementHandlers.js +73 -22
- package/build/core/tools/internal/managementHandlers.js.map +1 -1
- package/build/core/tools/internal/schemas/discovery.d.ts +3 -3
- package/build/core/tools/internal/schemas/edit.js +1 -1
- package/build/core/tools/internal/schemas/edit.js.map +1 -1
- package/build/core/tools/internal/schemas/index.d.ts +90 -19
- package/build/core/tools/internal/schemas/index.d.ts.map +1 -1
- package/build/core/tools/internal/schemas/installation.d.ts +7 -7
- package/build/core/tools/internal/schemas/management.d.ts +80 -9
- package/build/core/tools/internal/schemas/management.d.ts.map +1 -1
- package/build/core/tools/internal/schemas/management.js +69 -2
- package/build/core/tools/internal/schemas/management.js.map +1 -1
- package/build/core/types/client.d.ts +9 -2
- package/build/core/types/client.d.ts.map +1 -1
- package/build/core/types/client.js +4 -0
- package/build/core/types/client.js.map +1 -1
- package/build/core/types/transport.d.ts +34 -4
- package/build/core/types/transport.d.ts.map +1 -1
- package/build/core/types/transport.js +26 -3
- package/build/core/types/transport.js.map +1 -1
- package/build/domains/admin/adminBackendRestartService.d.ts +41 -0
- package/build/domains/admin/adminBackendRestartService.d.ts.map +1 -0
- package/build/domains/admin/adminBackendRestartService.js +22 -0
- package/build/domains/admin/adminBackendRestartService.js.map +1 -0
- package/build/domains/admin/adminConfiguredServerService.d.ts +275 -0
- package/build/domains/admin/adminConfiguredServerService.d.ts.map +1 -0
- package/build/domains/admin/adminConfiguredServerService.js +1926 -0
- package/build/domains/admin/adminConfiguredServerService.js.map +1 -0
- package/build/domains/admin/adminConnectivityChecker.d.ts +7 -0
- package/build/domains/admin/adminConnectivityChecker.d.ts.map +1 -0
- package/build/domains/admin/adminConnectivityChecker.js +42 -0
- package/build/domains/admin/adminConnectivityChecker.js.map +1 -0
- package/build/domains/admin/adminDomain.d.ts +36 -0
- package/build/domains/admin/adminDomain.d.ts.map +1 -0
- package/build/domains/admin/adminDomain.js +52 -0
- package/build/domains/admin/adminDomain.js.map +1 -0
- package/build/domains/admin/adminIdentityService.d.ts +75 -0
- package/build/domains/admin/adminIdentityService.d.ts.map +1 -0
- package/build/domains/admin/adminIdentityService.js +321 -0
- package/build/domains/admin/adminIdentityService.js.map +1 -0
- package/build/domains/admin/adminOAuthService.d.ts +26 -0
- package/build/domains/admin/adminOAuthService.d.ts.map +1 -0
- package/build/domains/admin/adminOAuthService.js +71 -0
- package/build/domains/admin/adminOAuthService.js.map +1 -0
- package/build/domains/admin/adminOperationService.d.ts +203 -0
- package/build/domains/admin/adminOperationService.d.ts.map +1 -0
- package/build/domains/admin/adminOperationService.js +749 -0
- package/build/domains/admin/adminOperationService.js.map +1 -0
- package/build/domains/admin/adminPresetService.d.ts +140 -0
- package/build/domains/admin/adminPresetService.d.ts.map +1 -0
- package/build/domains/admin/adminPresetService.js +248 -0
- package/build/domains/admin/adminPresetService.js.map +1 -0
- package/build/domains/admin/runtimeScopeAdminLock.d.ts +22 -0
- package/build/domains/admin/runtimeScopeAdminLock.d.ts.map +1 -0
- package/build/domains/admin/runtimeScopeAdminLock.js +121 -0
- package/build/domains/admin/runtimeScopeAdminLock.js.map +1 -0
- package/build/domains/admin/runtimeServerManagerBackendRestartService.d.ts +20 -0
- package/build/domains/admin/runtimeServerManagerBackendRestartService.d.ts.map +1 -0
- package/build/domains/admin/runtimeServerManagerBackendRestartService.js +78 -0
- package/build/domains/admin/runtimeServerManagerBackendRestartService.js.map +1 -0
- package/build/domains/config-change/configChange.d.ts +6 -1
- package/build/domains/config-change/configChange.d.ts.map +1 -1
- package/build/domains/config-change/configChange.js +344 -0
- package/build/domains/config-change/configChange.js.map +1 -1
- package/build/domains/config-change/types.d.ts +18 -3
- package/build/domains/config-change/types.d.ts.map +1 -1
- package/build/domains/preset/manager/presetManager.d.ts +1 -0
- package/build/domains/preset/manager/presetManager.d.ts.map +1 -1
- package/build/domains/preset/manager/presetManager.js +3 -0
- package/build/domains/preset/manager/presetManager.js.map +1 -1
- package/build/domains/preset/tagAuthoring.d.ts +10 -0
- package/build/domains/preset/tagAuthoring.d.ts.map +1 -0
- package/build/domains/preset/tagAuthoring.js +94 -0
- package/build/domains/preset/tagAuthoring.js.map +1 -0
- package/build/domains/runtime-targets/runtimeIdentityVerification.d.ts +51 -0
- package/build/domains/runtime-targets/runtimeIdentityVerification.d.ts.map +1 -0
- package/build/domains/runtime-targets/runtimeIdentityVerification.js +258 -0
- package/build/domains/runtime-targets/runtimeIdentityVerification.js.map +1 -0
- package/build/domains/runtime-targets/runtimeTargetStore.d.ts +222 -0
- package/build/domains/runtime-targets/runtimeTargetStore.d.ts.map +1 -0
- package/build/domains/runtime-targets/runtimeTargetStore.js +1456 -0
- package/build/domains/runtime-targets/runtimeTargetStore.js.map +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +7 -1
- package/build/index.js.map +1 -1
- package/build/server.d.ts.map +1 -1
- package/build/server.js +18 -2
- package/build/server.js.map +1 -1
- package/build/transport/http/routes/adminRoutes.d.ts +38 -0
- package/build/transport/http/routes/adminRoutes.d.ts.map +1 -0
- package/build/transport/http/routes/adminRoutes.js +1475 -0
- package/build/transport/http/routes/adminRoutes.js.map +1 -0
- package/build/transport/http/routes/healthRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/healthRoutes.js +70 -2
- package/build/transport/http/routes/healthRoutes.js.map +1 -1
- package/build/transport/http/routes/oauthRoutes.d.ts +4 -1
- package/build/transport/http/routes/oauthRoutes.d.ts.map +1 -1
- package/build/transport/http/routes/oauthRoutes.js +12 -190
- package/build/transport/http/routes/oauthRoutes.js.map +1 -1
- package/build/transport/http/routes/runtimeIdentityRoutes.d.ts +7 -0
- package/build/transport/http/routes/runtimeIdentityRoutes.d.ts.map +1 -0
- package/build/transport/http/routes/runtimeIdentityRoutes.js +9 -0
- package/build/transport/http/routes/runtimeIdentityRoutes.js.map +1 -0
- package/build/transport/http/server.d.ts +3 -0
- package/build/transport/http/server.d.ts.map +1 -1
- package/build/transport/http/server.js +102 -4
- package/build/transport/http/server.js.map +1 -1
- package/build/transport/transportFactory.d.ts.map +1 -1
- package/build/transport/transportFactory.js +27 -15
- package/build/transport/transportFactory.js.map +1 -1
- package/build/transport/transportFactory.testSetup.js +2 -0
- package/build/transport/transportFactory.testSetup.js.map +1 -1
- package/build/utils/core/errorTypes.d.ts +3 -0
- package/build/utils/core/errorTypes.d.ts.map +1 -1
- package/build/utils/core/errorTypes.js +7 -0
- package/build/utils/core/errorTypes.js.map +1 -1
- package/build/utils/validation/urlDetection.d.ts +13 -2
- package/build/utils/validation/urlDetection.d.ts.map +1 -1
- package/build/utils/validation/urlDetection.js +37 -6
- package/build/utils/validation/urlDetection.js.map +1 -1
- package/package.json +22 -9
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export type RuntimeScopeClaimantKind = 'foreground-http' | 'foreground-stdio' | 'background-supervisor';
|
|
2
|
+
export interface RuntimeScopeOwnershipRecord {
|
|
3
|
+
version: 1;
|
|
4
|
+
pid: number;
|
|
5
|
+
claimId: string;
|
|
6
|
+
kind: RuntimeScopeClaimantKind;
|
|
7
|
+
claimedAt: string;
|
|
8
|
+
}
|
|
9
|
+
export interface RuntimeScopeOwnership {
|
|
10
|
+
record: RuntimeScopeOwnershipRecord;
|
|
11
|
+
release: () => void;
|
|
12
|
+
}
|
|
13
|
+
export interface RuntimeScopeStopLock {
|
|
14
|
+
release: () => void;
|
|
15
|
+
}
|
|
16
|
+
export interface RuntimeScopeClaimant {
|
|
17
|
+
kind: RuntimeScopeClaimantKind;
|
|
18
|
+
pid?: number;
|
|
19
|
+
}
|
|
20
|
+
export type RuntimeScopeOwnershipFailureReason = 'owned' | 'ambiguous';
|
|
21
|
+
type RuntimeScopeOwnershipIdentity = Pick<RuntimeScopeOwnershipRecord, 'claimId' | 'pid'>;
|
|
22
|
+
export declare class RuntimeScopeOwnedError extends Error {
|
|
23
|
+
readonly ownerPath: string;
|
|
24
|
+
readonly reason: RuntimeScopeOwnershipFailureReason;
|
|
25
|
+
readonly owner: RuntimeScopeOwnershipRecord | null;
|
|
26
|
+
constructor(ownerPath: string, reason: RuntimeScopeOwnershipFailureReason, owner: RuntimeScopeOwnershipRecord | null, detail?: string);
|
|
27
|
+
}
|
|
28
|
+
interface OwnershipDependencies {
|
|
29
|
+
processAlive?: (pid: number) => boolean;
|
|
30
|
+
createClaimId?: () => string;
|
|
31
|
+
now?: () => Date;
|
|
32
|
+
}
|
|
33
|
+
export declare function getRuntimeScopeOwnershipPath(configDir: string): string;
|
|
34
|
+
export declare function getRuntimeScopeStopLockPath(configDir: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Atomically claims one Runtime Scope before runtime setup or transport binding.
|
|
37
|
+
* The complete candidate directory is renamed into the absent canonical path;
|
|
38
|
+
* a creator crash cannot expose partial canonical metadata.
|
|
39
|
+
*/
|
|
40
|
+
export declare function claimRuntimeScope(configDir: string, claimant: RuntimeScopeClaimant, dependencies?: OwnershipDependencies): RuntimeScopeOwnership;
|
|
41
|
+
/** Serializes stop metadata cleanup against ordinary claims and workers. */
|
|
42
|
+
export declare function acquireRuntimeScopeStopLock(configDir: string, expectedOwner: Pick<RuntimeScopeOwnershipRecord, 'claimId' | 'pid'>, dependencies?: OwnershipDependencies): RuntimeScopeStopLock;
|
|
43
|
+
/**
|
|
44
|
+
* Guarded stale cleanup for discovery/status paths. It applies the same
|
|
45
|
+
* supervisor orphan checks as startup and removes only the observed generation.
|
|
46
|
+
*/
|
|
47
|
+
export declare function reclaimStaleRuntimeScopeOwnership(configDir: string, expected: RuntimeScopeOwnershipIdentity, processAlive?: (pid: number) => boolean): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Verifies that a supervised worker was authorized by the live owner of the
|
|
50
|
+
* selected Runtime Scope. This does not transfer or release ownership.
|
|
51
|
+
*/
|
|
52
|
+
export declare function verifyRuntimeScopeOwnership(configDir: string, claimId: string, expectedKind: RuntimeScopeClaimantKind, processAlive?: (pid: number) => boolean): RuntimeScopeOwnershipRecord;
|
|
53
|
+
/** Strictly reads the canonical owner record for lifecycle recovery commands. */
|
|
54
|
+
export declare function readRuntimeScopeOwnership(configDir: string): RuntimeScopeOwnershipRecord | null;
|
|
55
|
+
/**
|
|
56
|
+
* Releases only the owner observed by a lifecycle recovery command. Both PID
|
|
57
|
+
* and claim ID must still match so a replacement owner is never removed.
|
|
58
|
+
*/
|
|
59
|
+
export declare function releaseRuntimeScopeOwnership(configDir: string, expected: RuntimeScopeOwnershipIdentity): boolean;
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=runtimeScopeOwnership.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeScopeOwnership.d.ts","sourceRoot":"","sources":["../../../src/core/server/runtimeScopeOwnership.ts"],"names":[],"mappings":"AAgBA,MAAM,MAAM,wBAAwB,GAAG,iBAAiB,GAAG,kBAAkB,GAAG,uBAAuB,CAAC;AAExG,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,CAAC,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,wB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aAAa,EAAE,IAAI,CAAC,2BAA2B,EAAE,SAAS,GAAG,KAAK,CAAC,EACnE,YAAY,GAAE,qBAA0B,GACvC,oBAAoB,CA+DtB;AAED;;;GAGG;AACH,wBAAgB,iCAAiC,CAC/C,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,6BAA6B,EACvC,YAAY,GAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAwB,GACtD,OAAO,CAMT;AA8FD;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,wBAAwB,EACtC,YAAY,GAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAwB,GACtD,2BAA2B,CAgB7B;AA2JD,iFAAiF;AACjF,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,2BAA2B,GAAG,IAAI,CAE/F;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,6BAA6B,GAAG,OAAO,CAMhH"}
|
|
@@ -0,0 +1,544 @@
|
|
|
1
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { readBackgroundSupervisorState } from '../../core/server/backgroundRuntimeSupervisorState.js';
|
|
5
|
+
import { getPidFilePath, isProcessAlive, readPidFile } from '../../core/server/pidFileManager.js';
|
|
6
|
+
import logger from '../../logger/logger.js';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
const OWNERSHIP_DIR_NAME = 'runtime.owner';
|
|
9
|
+
const STOP_LOCK_NAME = 'runtime.stop';
|
|
10
|
+
const OWNER_RECORD_NAME = 'owner.json';
|
|
11
|
+
const STOP_LOCK_RECORD_NAME = 'lock.json';
|
|
12
|
+
const CLAIM_ATTEMPTS = 8;
|
|
13
|
+
export class RuntimeScopeOwnedError extends Error {
|
|
14
|
+
ownerPath;
|
|
15
|
+
reason;
|
|
16
|
+
owner;
|
|
17
|
+
constructor(ownerPath, reason, owner, detail) {
|
|
18
|
+
const ownerDescription = owner ? ` by ${owner.kind} (PID: ${owner.pid})` : '';
|
|
19
|
+
super(`Runtime Scope is already owned${ownerDescription}${detail ? `: ${detail}` : ''}`);
|
|
20
|
+
this.ownerPath = ownerPath;
|
|
21
|
+
this.reason = reason;
|
|
22
|
+
this.owner = owner;
|
|
23
|
+
this.name = 'RuntimeScopeOwnedError';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const runtimeScopeOwnershipRecordSchema = z.object({
|
|
27
|
+
version: z.literal(1),
|
|
28
|
+
pid: z.number().int().positive(),
|
|
29
|
+
claimId: z.string().min(1),
|
|
30
|
+
kind: z.enum(['foreground-http', 'foreground-stdio', 'background-supervisor']),
|
|
31
|
+
claimedAt: z.string().datetime(),
|
|
32
|
+
});
|
|
33
|
+
const runtimeScopeStopLockSchema = z.object({
|
|
34
|
+
version: z.literal(1),
|
|
35
|
+
operationId: z.string().min(1),
|
|
36
|
+
ownerClaimId: z.string().min(1),
|
|
37
|
+
pid: z.number().int().positive(),
|
|
38
|
+
acquiredAt: z.string().datetime(),
|
|
39
|
+
});
|
|
40
|
+
export function getRuntimeScopeOwnershipPath(configDir) {
|
|
41
|
+
return path.join(configDir, OWNERSHIP_DIR_NAME);
|
|
42
|
+
}
|
|
43
|
+
export function getRuntimeScopeStopLockPath(configDir) {
|
|
44
|
+
return path.join(configDir, STOP_LOCK_NAME);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Atomically claims one Runtime Scope before runtime setup or transport binding.
|
|
48
|
+
* The complete candidate directory is renamed into the absent canonical path;
|
|
49
|
+
* a creator crash cannot expose partial canonical metadata.
|
|
50
|
+
*/
|
|
51
|
+
export function claimRuntimeScope(configDir, claimant, dependencies = {}) {
|
|
52
|
+
const ownerDir = getRuntimeScopeOwnershipPath(configDir);
|
|
53
|
+
const processAlive = dependencies.processAlive ?? isProcessAlive;
|
|
54
|
+
const createClaimId = dependencies.createClaimId ?? randomUUID;
|
|
55
|
+
const now = dependencies.now ?? currentDate;
|
|
56
|
+
const record = {
|
|
57
|
+
version: 1,
|
|
58
|
+
pid: claimant.pid ?? process.pid,
|
|
59
|
+
claimId: createClaimId(),
|
|
60
|
+
kind: claimant.kind,
|
|
61
|
+
claimedAt: now().toISOString(),
|
|
62
|
+
};
|
|
63
|
+
fs.mkdirSync(configDir, { recursive: true });
|
|
64
|
+
const candidateDir = `${ownerDir}.${record.claimId}.candidate`;
|
|
65
|
+
writeCandidate(candidateDir, OWNER_RECORD_NAME, record);
|
|
66
|
+
try {
|
|
67
|
+
for (let attempt = 0; attempt < CLAIM_ATTEMPTS; attempt += 1) {
|
|
68
|
+
assertNoActiveStopLock(configDir, processAlive);
|
|
69
|
+
try {
|
|
70
|
+
fs.renameSync(candidateDir, ownerDir);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
if (!isOwnershipExistsError(error)) {
|
|
74
|
+
throw new RuntimeScopeOwnedError(ownerDir, 'ambiguous', null, errorMessage(error));
|
|
75
|
+
}
|
|
76
|
+
const existing = inspectRuntimeScopeOwnership(configDir);
|
|
77
|
+
if (!existing) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (processAlive(existing.record.pid)) {
|
|
81
|
+
throw new RuntimeScopeOwnedError(ownerDir, 'owned', existing.record);
|
|
82
|
+
}
|
|
83
|
+
reclaimObservedOwnership(configDir, existing, processAlive);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
assertNoActiveStopLock(configDir, processAlive);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
releaseRuntimeScopeOwnership(configDir, record);
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
let released = false;
|
|
94
|
+
return {
|
|
95
|
+
record,
|
|
96
|
+
release: () => {
|
|
97
|
+
if (released) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
released = true;
|
|
101
|
+
releaseRuntimeScopeOwnership(configDir, record);
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
throw new RuntimeScopeOwnedError(ownerDir, 'ambiguous', null, 'ownership changed during claim');
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
removeCandidateDirectoryIfPresent(candidateDir);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/** Serializes stop metadata cleanup against ordinary claims and workers. */
|
|
112
|
+
export function acquireRuntimeScopeStopLock(configDir, expectedOwner, dependencies = {}) {
|
|
113
|
+
const processAlive = dependencies.processAlive ?? isProcessAlive;
|
|
114
|
+
const createOperationId = dependencies.createClaimId ?? randomUUID;
|
|
115
|
+
const now = dependencies.now ?? currentDate;
|
|
116
|
+
const stopLockPath = getRuntimeScopeStopLockPath(configDir);
|
|
117
|
+
const lockRecord = {
|
|
118
|
+
version: 1,
|
|
119
|
+
operationId: createOperationId(),
|
|
120
|
+
ownerClaimId: expectedOwner.claimId,
|
|
121
|
+
pid: process.pid,
|
|
122
|
+
acquiredAt: now().toISOString(),
|
|
123
|
+
};
|
|
124
|
+
fs.mkdirSync(configDir, { recursive: true });
|
|
125
|
+
const candidateDir = `${stopLockPath}.${lockRecord.operationId}.candidate`;
|
|
126
|
+
writeCandidate(candidateDir, STOP_LOCK_RECORD_NAME, lockRecord);
|
|
127
|
+
try {
|
|
128
|
+
for (let attempt = 0; attempt < CLAIM_ATTEMPTS; attempt += 1) {
|
|
129
|
+
assertNoActiveStopLock(configDir, processAlive);
|
|
130
|
+
try {
|
|
131
|
+
fs.renameSync(candidateDir, stopLockPath);
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
if (isOwnershipExistsError(error))
|
|
135
|
+
continue;
|
|
136
|
+
throw new RuntimeScopeOwnedError(stopLockPath, 'ambiguous', null, errorMessage(error));
|
|
137
|
+
}
|
|
138
|
+
let observed;
|
|
139
|
+
try {
|
|
140
|
+
const current = inspectRuntimeScopeOwnership(configDir);
|
|
141
|
+
if (!current || !ownershipMatches(current.record, expectedOwner)) {
|
|
142
|
+
throw new RuntimeScopeOwnedError(stopLockPath, 'ambiguous', current?.record ?? null, 'ownership changed while acquiring stop lock');
|
|
143
|
+
}
|
|
144
|
+
observed = current;
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
rollbackPublishedStopLock(configDir, lockRecord.operationId, error);
|
|
148
|
+
}
|
|
149
|
+
let released = false;
|
|
150
|
+
return {
|
|
151
|
+
release: () => {
|
|
152
|
+
if (released)
|
|
153
|
+
return;
|
|
154
|
+
released = true;
|
|
155
|
+
if (!removeStopLockIfMatches(configDir, lockRecord.operationId)) {
|
|
156
|
+
throw new RuntimeScopeOwnedError(stopLockPath, 'ambiguous', observed.record, 'stop lock changed before release');
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
throw new RuntimeScopeOwnedError(stopLockPath, 'ambiguous', null, 'stop lock changed during acquisition');
|
|
162
|
+
}
|
|
163
|
+
finally {
|
|
164
|
+
removeCandidateDirectoryIfPresent(candidateDir);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Guarded stale cleanup for discovery/status paths. It applies the same
|
|
169
|
+
* supervisor orphan checks as startup and removes only the observed generation.
|
|
170
|
+
*/
|
|
171
|
+
export function reclaimStaleRuntimeScopeOwnership(configDir, expected, processAlive = isProcessAlive) {
|
|
172
|
+
const observed = inspectRuntimeScopeOwnership(configDir);
|
|
173
|
+
if (!observed || !ownershipMatches(observed.record, expected) || processAlive(observed.record.pid)) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
return reclaimObservedOwnership(configDir, observed, processAlive);
|
|
177
|
+
}
|
|
178
|
+
function reclaimObservedOwnership(configDir, observed, processAlive) {
|
|
179
|
+
const ownerDir = getRuntimeScopeOwnershipPath(configDir);
|
|
180
|
+
const stopLock = acquireRuntimeScopeStopLock(configDir, observed.record, { processAlive });
|
|
181
|
+
try {
|
|
182
|
+
const current = inspectRuntimeScopeOwnership(configDir);
|
|
183
|
+
if (!current || !ownershipMatches(current.record, observed.record) || processAlive(current.record.pid)) {
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
assertDeadSupervisorIsReclaimable(configDir, ownerDir, current.record, processAlive);
|
|
187
|
+
return removeObservedOwnership(configDir, current);
|
|
188
|
+
}
|
|
189
|
+
finally {
|
|
190
|
+
stopLock.release();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function assertDeadSupervisorIsReclaimable(configDir, ownerPath, owner, processAlive) {
|
|
194
|
+
if (owner.kind !== 'background-supervisor') {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
let state;
|
|
198
|
+
try {
|
|
199
|
+
state = readBackgroundSupervisorState(configDir);
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
throw new RuntimeScopeOwnedError(ownerPath, 'ambiguous', owner, `background supervisor state cannot be verified: ${errorMessage(error)}`);
|
|
203
|
+
}
|
|
204
|
+
if (state) {
|
|
205
|
+
if (state.supervisorPid !== owner.pid) {
|
|
206
|
+
throw new RuntimeScopeOwnedError(ownerPath, 'ambiguous', owner, 'ownership and supervisor state disagree');
|
|
207
|
+
}
|
|
208
|
+
if (state.runtimePid !== null && processAlive(state.runtimePid)) {
|
|
209
|
+
throw new RuntimeScopeOwnedError(ownerPath, 'owned', owner, `orphaned runtime PID ${state.runtimePid} is still alive`);
|
|
210
|
+
}
|
|
211
|
+
if (state.runtimePid === null &&
|
|
212
|
+
state.status !== 'restarting' &&
|
|
213
|
+
state.status !== 'crash-loop' &&
|
|
214
|
+
state.status !== 'stopping') {
|
|
215
|
+
throw new RuntimeScopeOwnedError(ownerPath, 'ambiguous', owner, `supervisor state ${state.status} may be between worker spawn and state publication`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
const pidFilePath = getPidFilePath(configDir);
|
|
219
|
+
let runtimeInfo;
|
|
220
|
+
try {
|
|
221
|
+
runtimeInfo = readPidFile(configDir);
|
|
222
|
+
}
|
|
223
|
+
catch (error) {
|
|
224
|
+
throw new RuntimeScopeOwnedError(ownerPath, 'ambiguous', owner, `runtime PID metadata is unreadable: ${errorMessage(error)}`);
|
|
225
|
+
}
|
|
226
|
+
if (!runtimeInfo && fs.existsSync(pidFilePath)) {
|
|
227
|
+
throw new RuntimeScopeOwnedError(ownerPath, 'ambiguous', owner, 'runtime PID metadata is malformed');
|
|
228
|
+
}
|
|
229
|
+
if (runtimeInfo && processAlive(runtimeInfo.pid)) {
|
|
230
|
+
throw new RuntimeScopeOwnedError(ownerPath, 'owned', owner, `orphaned runtime PID ${runtimeInfo.pid} is still alive`);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Verifies that a supervised worker was authorized by the live owner of the
|
|
235
|
+
* selected Runtime Scope. This does not transfer or release ownership.
|
|
236
|
+
*/
|
|
237
|
+
export function verifyRuntimeScopeOwnership(configDir, claimId, expectedKind, processAlive = isProcessAlive) {
|
|
238
|
+
assertNoActiveStopLock(configDir, processAlive);
|
|
239
|
+
const ownerDir = getRuntimeScopeOwnershipPath(configDir);
|
|
240
|
+
const observed = inspectRuntimeScopeOwnership(configDir);
|
|
241
|
+
if (!observed) {
|
|
242
|
+
throw new RuntimeScopeOwnedError(ownerDir, 'ambiguous', null, 'ownership metadata is missing');
|
|
243
|
+
}
|
|
244
|
+
const owner = observed.record;
|
|
245
|
+
if (observed.interruptedReclaim) {
|
|
246
|
+
throw new RuntimeScopeOwnedError(ownerDir, 'ambiguous', owner, 'ownership release is incomplete');
|
|
247
|
+
}
|
|
248
|
+
if (owner.claimId !== claimId || owner.kind !== expectedKind || !processAlive(owner.pid)) {
|
|
249
|
+
throw new RuntimeScopeOwnedError(ownerDir, 'owned', owner, 'supervised worker authorization failed');
|
|
250
|
+
}
|
|
251
|
+
assertNoActiveStopLock(configDir, processAlive);
|
|
252
|
+
return owner;
|
|
253
|
+
}
|
|
254
|
+
function assertNoActiveStopLock(configDir, processAlive) {
|
|
255
|
+
const stopLockPath = getRuntimeScopeStopLockPath(configDir);
|
|
256
|
+
const observed = inspectRuntimeScopeStopLock(configDir);
|
|
257
|
+
if (!observed)
|
|
258
|
+
return;
|
|
259
|
+
if (processAlive(observed.record.pid)) {
|
|
260
|
+
throw new RuntimeScopeOwnedError(stopLockPath, 'ambiguous', null, `lifecycle stop is active (PID: ${observed.record.pid})`);
|
|
261
|
+
}
|
|
262
|
+
if (!removeObservedStopLock(configDir, observed)) {
|
|
263
|
+
throw new RuntimeScopeOwnedError(stopLockPath, 'ambiguous', null, 'stop lock changed during stale cleanup');
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
function inspectRuntimeScopeStopLock(configDir) {
|
|
267
|
+
const stopLockDir = getRuntimeScopeStopLockPath(configDir);
|
|
268
|
+
const lockRecordPath = path.join(stopLockDir, STOP_LOCK_RECORD_NAME);
|
|
269
|
+
try {
|
|
270
|
+
return {
|
|
271
|
+
record: readStopLockRecord(lockRecordPath, stopLockDir),
|
|
272
|
+
recordPath: lockRecordPath,
|
|
273
|
+
interruptedRelease: false,
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
catch (error) {
|
|
277
|
+
if (!(error instanceof StopLockRecordMissingError))
|
|
278
|
+
throw error;
|
|
279
|
+
}
|
|
280
|
+
let entries;
|
|
281
|
+
try {
|
|
282
|
+
entries = fs.readdirSync(stopLockDir);
|
|
283
|
+
}
|
|
284
|
+
catch (error) {
|
|
285
|
+
if (isCode(error, 'ENOENT'))
|
|
286
|
+
return null;
|
|
287
|
+
throw new RuntimeScopeOwnedError(stopLockDir, 'ambiguous', null, `stop lock directory is unreadable: ${errorMessage(error)}`);
|
|
288
|
+
}
|
|
289
|
+
const tombstones = entries.filter((entry) => /^lock\.[a-f0-9]{64}\.releasing\.json$/.test(entry));
|
|
290
|
+
if (entries.length !== 1 || tombstones.length !== 1) {
|
|
291
|
+
throw new RuntimeScopeOwnedError(stopLockDir, 'ambiguous', null, 'stop lock directory is incomplete or contains unknown files');
|
|
292
|
+
}
|
|
293
|
+
const tombstonePath = path.join(stopLockDir, tombstones[0]);
|
|
294
|
+
const record = readStopLockRecord(tombstonePath, stopLockDir);
|
|
295
|
+
if (tombstones[0] !== stopLockTombstoneName(record.operationId)) {
|
|
296
|
+
throw new RuntimeScopeOwnedError(stopLockDir, 'ambiguous', null, 'stop lock tombstone generation does not match');
|
|
297
|
+
}
|
|
298
|
+
return { record, recordPath: tombstonePath, interruptedRelease: true };
|
|
299
|
+
}
|
|
300
|
+
function readStopLockRecord(recordPath, stopLockDir) {
|
|
301
|
+
let content;
|
|
302
|
+
try {
|
|
303
|
+
content = fs.readFileSync(recordPath, 'utf8');
|
|
304
|
+
}
|
|
305
|
+
catch (error) {
|
|
306
|
+
if (isCode(error, 'ENOENT'))
|
|
307
|
+
throw new StopLockRecordMissingError();
|
|
308
|
+
throw new RuntimeScopeOwnedError(stopLockDir, 'ambiguous', null, `stop lock is unreadable: ${errorMessage(error)}`);
|
|
309
|
+
}
|
|
310
|
+
try {
|
|
311
|
+
return runtimeScopeStopLockSchema.parse(JSON.parse(content));
|
|
312
|
+
}
|
|
313
|
+
catch (error) {
|
|
314
|
+
throw new RuntimeScopeOwnedError(stopLockDir, 'ambiguous', null, `stop lock is invalid: ${errorMessage(error)}`);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
function removeStopLockIfMatches(configDir, expectedOperationId) {
|
|
318
|
+
const observed = inspectRuntimeScopeStopLock(configDir);
|
|
319
|
+
if (!observed)
|
|
320
|
+
return true;
|
|
321
|
+
if (observed.record.operationId !== expectedOperationId)
|
|
322
|
+
return false;
|
|
323
|
+
return removeObservedStopLock(configDir, observed);
|
|
324
|
+
}
|
|
325
|
+
function removeObservedStopLock(configDir, observed) {
|
|
326
|
+
const stopLockDir = getRuntimeScopeStopLockPath(configDir);
|
|
327
|
+
const tombstonePath = path.join(stopLockDir, stopLockTombstoneName(observed.record.operationId));
|
|
328
|
+
if (!observed.interruptedRelease) {
|
|
329
|
+
try {
|
|
330
|
+
fs.renameSync(observed.recordPath, tombstonePath);
|
|
331
|
+
}
|
|
332
|
+
catch (error) {
|
|
333
|
+
if (isCode(error, 'ENOENT') || isCode(error, 'EEXIST'))
|
|
334
|
+
return false;
|
|
335
|
+
throw new RuntimeScopeOwnedError(stopLockDir, 'ambiguous', null, `stop lock removal failed: ${errorMessage(error)}`);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
try {
|
|
339
|
+
fs.unlinkSync(tombstonePath);
|
|
340
|
+
}
|
|
341
|
+
catch (error) {
|
|
342
|
+
if (!isCode(error, 'ENOENT')) {
|
|
343
|
+
throw new RuntimeScopeOwnedError(stopLockDir, 'ambiguous', null, `stop lock tombstone cleanup failed: ${errorMessage(error)}`);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
try {
|
|
347
|
+
fs.rmdirSync(stopLockDir);
|
|
348
|
+
return true;
|
|
349
|
+
}
|
|
350
|
+
catch (error) {
|
|
351
|
+
if (isCode(error, 'ENOENT'))
|
|
352
|
+
return true;
|
|
353
|
+
if (isCode(error, 'ENOTEMPTY') || isCode(error, 'EEXIST')) {
|
|
354
|
+
const replacement = inspectRuntimeScopeStopLock(configDir);
|
|
355
|
+
if (replacement && !replacement.interruptedRelease)
|
|
356
|
+
return true;
|
|
357
|
+
throw new RuntimeScopeOwnedError(stopLockDir, 'ambiguous', null, 'stop lock directory changed during cleanup');
|
|
358
|
+
}
|
|
359
|
+
throw new RuntimeScopeOwnedError(stopLockDir, 'ambiguous', null, `stop lock directory cleanup failed: ${errorMessage(error)}`);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
function rollbackPublishedStopLock(configDir, operationId, originalError) {
|
|
363
|
+
try {
|
|
364
|
+
if (!removeStopLockIfMatches(configDir, operationId)) {
|
|
365
|
+
throw new Error('published stop lock generation changed');
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
catch (rollbackError) {
|
|
369
|
+
throw new RuntimeScopeOwnedError(getRuntimeScopeStopLockPath(configDir), 'ambiguous', null, `${errorMessage(originalError)}; stop lock rollback failed: ${errorMessage(rollbackError)}`);
|
|
370
|
+
}
|
|
371
|
+
throw originalError;
|
|
372
|
+
}
|
|
373
|
+
function stopLockTombstoneName(operationId) {
|
|
374
|
+
const generation = createHash('sha256').update(operationId).digest('hex');
|
|
375
|
+
return `lock.${generation}.releasing.json`;
|
|
376
|
+
}
|
|
377
|
+
/** Strictly reads the canonical owner record for lifecycle recovery commands. */
|
|
378
|
+
export function readRuntimeScopeOwnership(configDir) {
|
|
379
|
+
return inspectRuntimeScopeOwnership(configDir)?.record ?? null;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Releases only the owner observed by a lifecycle recovery command. Both PID
|
|
383
|
+
* and claim ID must still match so a replacement owner is never removed.
|
|
384
|
+
*/
|
|
385
|
+
export function releaseRuntimeScopeOwnership(configDir, expected) {
|
|
386
|
+
const observed = inspectRuntimeScopeOwnership(configDir);
|
|
387
|
+
if (!observed || !ownershipMatches(observed.record, expected)) {
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
return removeObservedOwnership(configDir, observed);
|
|
391
|
+
}
|
|
392
|
+
function inspectRuntimeScopeOwnership(configDir) {
|
|
393
|
+
const ownerDir = getRuntimeScopeOwnershipPath(configDir);
|
|
394
|
+
const ownerRecordPath = path.join(ownerDir, OWNER_RECORD_NAME);
|
|
395
|
+
try {
|
|
396
|
+
return {
|
|
397
|
+
record: readOwnershipRecord(ownerRecordPath, ownerDir),
|
|
398
|
+
recordPath: ownerRecordPath,
|
|
399
|
+
interruptedReclaim: false,
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
catch (error) {
|
|
403
|
+
if (!(error instanceof OwnershipRecordMissingError)) {
|
|
404
|
+
throw error;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
let entries;
|
|
408
|
+
try {
|
|
409
|
+
entries = fs.readdirSync(ownerDir);
|
|
410
|
+
}
|
|
411
|
+
catch (error) {
|
|
412
|
+
if (isCode(error, 'ENOENT')) {
|
|
413
|
+
return null;
|
|
414
|
+
}
|
|
415
|
+
throw new RuntimeScopeOwnedError(ownerDir, 'ambiguous', null, `ownership directory is unreadable: ${errorMessage(error)}`);
|
|
416
|
+
}
|
|
417
|
+
const tombstones = entries.filter((entry) => /^owner\.[a-f0-9]{64}\.reclaiming\.json$/.test(entry));
|
|
418
|
+
if (entries.length !== 1 || tombstones.length !== 1) {
|
|
419
|
+
throw new RuntimeScopeOwnedError(ownerDir, 'ambiguous', null, 'ownership directory is incomplete or contains unknown files');
|
|
420
|
+
}
|
|
421
|
+
const tombstonePath = path.join(ownerDir, tombstones[0]);
|
|
422
|
+
const record = readOwnershipRecord(tombstonePath, ownerDir);
|
|
423
|
+
if (tombstones[0] !== reclaimTombstoneName(record.claimId)) {
|
|
424
|
+
throw new RuntimeScopeOwnedError(ownerDir, 'ambiguous', record, 'ownership tombstone generation does not match');
|
|
425
|
+
}
|
|
426
|
+
return {
|
|
427
|
+
record,
|
|
428
|
+
recordPath: tombstonePath,
|
|
429
|
+
interruptedReclaim: true,
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
function readOwnershipRecord(recordPath, ownerDir) {
|
|
433
|
+
let content;
|
|
434
|
+
try {
|
|
435
|
+
content = fs.readFileSync(recordPath, 'utf8');
|
|
436
|
+
}
|
|
437
|
+
catch (error) {
|
|
438
|
+
if (isCode(error, 'ENOENT')) {
|
|
439
|
+
throw new OwnershipRecordMissingError();
|
|
440
|
+
}
|
|
441
|
+
throw new RuntimeScopeOwnedError(ownerDir, 'ambiguous', null, `ownership metadata is unreadable: ${errorMessage(error)}`);
|
|
442
|
+
}
|
|
443
|
+
let value;
|
|
444
|
+
try {
|
|
445
|
+
value = JSON.parse(content);
|
|
446
|
+
}
|
|
447
|
+
catch {
|
|
448
|
+
throw new RuntimeScopeOwnedError(ownerDir, 'ambiguous', null, 'ownership metadata is malformed');
|
|
449
|
+
}
|
|
450
|
+
const parsed = runtimeScopeOwnershipRecordSchema.safeParse(value);
|
|
451
|
+
if (!parsed.success) {
|
|
452
|
+
throw new RuntimeScopeOwnedError(ownerDir, 'ambiguous', null, 'ownership metadata is invalid');
|
|
453
|
+
}
|
|
454
|
+
return parsed.data;
|
|
455
|
+
}
|
|
456
|
+
function removeObservedOwnership(configDir, observed) {
|
|
457
|
+
const ownerDir = getRuntimeScopeOwnershipPath(configDir);
|
|
458
|
+
const tombstonePath = path.join(ownerDir, reclaimTombstoneName(observed.record.claimId));
|
|
459
|
+
if (!observed.interruptedReclaim) {
|
|
460
|
+
try {
|
|
461
|
+
fs.renameSync(observed.recordPath, tombstonePath);
|
|
462
|
+
}
|
|
463
|
+
catch (error) {
|
|
464
|
+
if (isCode(error, 'ENOENT') || isCode(error, 'EEXIST')) {
|
|
465
|
+
return false;
|
|
466
|
+
}
|
|
467
|
+
throw new RuntimeScopeOwnedError(ownerDir, 'ambiguous', observed.record, `ownership removal failed: ${errorMessage(error)}`);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
try {
|
|
471
|
+
fs.unlinkSync(tombstonePath);
|
|
472
|
+
}
|
|
473
|
+
catch (error) {
|
|
474
|
+
if (!isCode(error, 'ENOENT')) {
|
|
475
|
+
throw new RuntimeScopeOwnedError(ownerDir, 'ambiguous', observed.record, `ownership tombstone cleanup failed: ${errorMessage(error)}`);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
try {
|
|
479
|
+
fs.rmdirSync(ownerDir);
|
|
480
|
+
return true;
|
|
481
|
+
}
|
|
482
|
+
catch (error) {
|
|
483
|
+
if (isCode(error, 'ENOENT')) {
|
|
484
|
+
return true;
|
|
485
|
+
}
|
|
486
|
+
if (isCode(error, 'ENOTEMPTY') || isCode(error, 'EEXIST')) {
|
|
487
|
+
const replacement = inspectRuntimeScopeOwnership(configDir);
|
|
488
|
+
if (replacement && !replacement.interruptedReclaim) {
|
|
489
|
+
// A replacement generation published after the tombstone was removed.
|
|
490
|
+
return true;
|
|
491
|
+
}
|
|
492
|
+
throw new RuntimeScopeOwnedError(ownerDir, 'ambiguous', observed.record, 'ownership directory changed during cleanup');
|
|
493
|
+
}
|
|
494
|
+
throw new RuntimeScopeOwnedError(ownerDir, 'ambiguous', observed.record, `ownership directory cleanup failed: ${errorMessage(error)}`);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
function reclaimTombstoneName(claimId) {
|
|
498
|
+
const generation = createHash('sha256').update(claimId).digest('hex');
|
|
499
|
+
return `owner.${generation}.reclaiming.json`;
|
|
500
|
+
}
|
|
501
|
+
function writeCandidate(candidateDir, recordName, record) {
|
|
502
|
+
try {
|
|
503
|
+
fs.mkdirSync(candidateDir, { mode: 0o700 });
|
|
504
|
+
fs.writeFileSync(path.join(candidateDir, recordName), `${JSON.stringify(record)}\n`, {
|
|
505
|
+
encoding: 'utf8',
|
|
506
|
+
flag: 'wx',
|
|
507
|
+
mode: 0o600,
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
catch (error) {
|
|
511
|
+
removeCandidateDirectoryIfPresent(candidateDir);
|
|
512
|
+
throw error;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
function ownershipMatches(record, expected) {
|
|
516
|
+
return record.claimId === expected.claimId && record.pid === expected.pid;
|
|
517
|
+
}
|
|
518
|
+
function currentDate() {
|
|
519
|
+
return new Date();
|
|
520
|
+
}
|
|
521
|
+
function removeCandidateDirectoryIfPresent(candidateDir) {
|
|
522
|
+
try {
|
|
523
|
+
fs.rmSync(candidateDir, { recursive: true });
|
|
524
|
+
}
|
|
525
|
+
catch (error) {
|
|
526
|
+
if (!isCode(error, 'ENOENT')) {
|
|
527
|
+
logger.warn(`Runtime ownership candidate cleanup failed (${candidateDir}): ${errorMessage(error)}`);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
function isOwnershipExistsError(error) {
|
|
532
|
+
return isCode(error, 'EEXIST') || isCode(error, 'ENOTEMPTY');
|
|
533
|
+
}
|
|
534
|
+
function isCode(error, code) {
|
|
535
|
+
return error instanceof Error && 'code' in error && error.code === code;
|
|
536
|
+
}
|
|
537
|
+
function errorMessage(error) {
|
|
538
|
+
return error instanceof Error ? error.message : String(error);
|
|
539
|
+
}
|
|
540
|
+
class OwnershipRecordMissingError extends Error {
|
|
541
|
+
}
|
|
542
|
+
class StopLockRecordMissingError extends Error {
|
|
543
|
+
}
|
|
544
|
+
//# sourceMappingURL=runtimeScopeOwnership.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeScopeOwnership.js","sourceRoot":"","sources":["../../../src/core/server/runtimeScopeOwnership.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,6BAA6B,EAAE,MAAM,sDAAsD,CAAC;AACrG,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjG,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAE3C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAC3C,MAAM,cAAc,GAAG,cAAc,CAAC;AACtC,MAAM,iBAAiB,GAAG,YAAY,CAAC;AACvC,MAAM,qBAAqB,GAAG,WAAW,CAAC;AAC1C,MAAM,cAAc,GAAG,CAAC,CAAC;AA8BzB,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAE7B;IACA;IACA;IAHlB,YACkB,SAAiB,EACjB,MAA0C,EAC1C,KAAyC,EACzD,MAAe;Q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|
|
86
86
|
getInboundConnections(): Map<string, InboundConnection>;
|
|
87
87
|
getTemplateServerManager(): TemplateServerManager;
|
|
88
88
|
getServerRegistry(): ServerRegistry;
|
|
89
|
+
/** Notify attached callers that backend capability lists may have changed. */
|
|
90
|
+
notifyBackendCapabilityListsChanged(): Promise<void>;
|
|
89
91
|
updateClientsAndTransports(newClients: OutboundConnections, newTransports: Record<string, Transport>): void;
|
|
90
92
|
executeServerOperation<T>(inboundConn: InboundConnection, operation: (inboundConn: InboundConnection) => Promise<T>, options?: OperationOptions): Promise<T>;
|
|
91
93
|
startServer(serverName: string, config: MCPServerParams): Promise<void>;
|