codexgpt 1.0.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/AGENTS.example.md +20 -0
- package/CHANGELOG.md +342 -0
- package/CHATGPT_PROMPT.md +12 -0
- package/CLOUDFLARED_VERIFIED_INSTALL.md +94 -0
- package/CODEX_PROMPT.md +12 -0
- package/CONTRIBUTING.md +62 -0
- package/DOMAIN_SETUP.md +275 -0
- package/FAQ.md +366 -0
- package/FAQ_ZH.md +329 -0
- package/LICENSE +21 -0
- package/PUBLIC_LAUNCH_CHECKLIST.md +111 -0
- package/README.md +490 -0
- package/README_ZH.md +747 -0
- package/SECURITY.md +295 -0
- package/config.example.env +103 -0
- package/dist/access/fullAccessLease.js +148 -0
- package/dist/access/fullAccessLease.js.map +1 -0
- package/dist/access/protectedRoots.js +122 -0
- package/dist/access/protectedRoots.js.map +1 -0
- package/dist/access/rootAdmission.js +347 -0
- package/dist/access/rootAdmission.js.map +1 -0
- package/dist/analysis/cache.js +27 -0
- package/dist/analysis/cache.js.map +1 -0
- package/dist/analysis/classify.js +102 -0
- package/dist/analysis/classify.js.map +1 -0
- package/dist/analysis/extract.js +139 -0
- package/dist/analysis/extract.js.map +1 -0
- package/dist/analysis/graph.js +22 -0
- package/dist/analysis/graph.js.map +1 -0
- package/dist/analysis/impact.js +167 -0
- package/dist/analysis/impact.js.map +1 -0
- package/dist/analysis/index.js +215 -0
- package/dist/analysis/index.js.map +1 -0
- package/dist/analysis/inventory.js +51 -0
- package/dist/analysis/inventory.js.map +1 -0
- package/dist/analysis/providers.js +24 -0
- package/dist/analysis/providers.js.map +1 -0
- package/dist/analysis/rank.js +27 -0
- package/dist/analysis/rank.js.map +1 -0
- package/dist/analysis/types.js +8 -0
- package/dist/analysis/types.js.map +1 -0
- package/dist/audit/canonicalJson.js +79 -0
- package/dist/audit/canonicalJson.js.map +1 -0
- package/dist/audit/diagnostics.js +128 -0
- package/dist/audit/diagnostics.js.map +1 -0
- package/dist/audit/index.js +12 -0
- package/dist/audit/index.js.map +1 -0
- package/dist/audit/lifecycleV3.js +53 -0
- package/dist/audit/lifecycleV3.js.map +1 -0
- package/dist/audit/lifecycleV4.js +70 -0
- package/dist/audit/lifecycleV4.js.map +1 -0
- package/dist/audit/lock.js +195 -0
- package/dist/audit/lock.js.map +1 -0
- package/dist/audit/queryTool.js +120 -0
- package/dist/audit/queryTool.js.map +1 -0
- package/dist/audit/runtime.js +48 -0
- package/dist/audit/runtime.js.map +1 -0
- package/dist/audit/schemas.js +640 -0
- package/dist/audit/schemas.js.map +1 -0
- package/dist/audit/store.js +1309 -0
- package/dist/audit/store.js.map +1 -0
- package/dist/audit/transactionParticipant.js +45 -0
- package/dist/audit/transactionParticipant.js.map +1 -0
- package/dist/audit/types.js +11 -0
- package/dist/audit/types.js.map +1 -0
- package/dist/auth/audit.js +44 -0
- package/dist/auth/audit.js.map +1 -0
- package/dist/auth/authorizationStore.js +333 -0
- package/dist/auth/authorizationStore.js.map +1 -0
- package/dist/auth/challenges.js +25 -0
- package/dist/auth/challenges.js.map +1 -0
- package/dist/auth/clientStore.js +469 -0
- package/dist/auth/clientStore.js.map +1 -0
- package/dist/auth/cloudflareConfig.js +112 -0
- package/dist/auth/cloudflareConfig.js.map +1 -0
- package/dist/auth/configuration.js +167 -0
- package/dist/auth/configuration.js.map +1 -0
- package/dist/auth/credentialStore.js +65 -0
- package/dist/auth/credentialStore.js.map +1 -0
- package/dist/auth/deploymentLock.js +220 -0
- package/dist/auth/deploymentLock.js.map +1 -0
- package/dist/auth/deploymentRegistry.js +149 -0
- package/dist/auth/deploymentRegistry.js.map +1 -0
- package/dist/auth/errors.js +26 -0
- package/dist/auth/errors.js.map +1 -0
- package/dist/auth/grantStore.js +307 -0
- package/dist/auth/grantStore.js.map +1 -0
- package/dist/auth/index.js +39 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/keyManager.js +148 -0
- package/dist/auth/keyManager.js.map +1 -0
- package/dist/auth/localAdminSession.js +173 -0
- package/dist/auth/localAdminSession.js.map +1 -0
- package/dist/auth/metadata.js +69 -0
- package/dist/auth/metadata.js.map +1 -0
- package/dist/auth/oauthProvider.js +589 -0
- package/dist/auth/oauthProvider.js.map +1 -0
- package/dist/auth/ownerApproval.js +51 -0
- package/dist/auth/ownerApproval.js.map +1 -0
- package/dist/auth/policyIdentity.js +189 -0
- package/dist/auth/policyIdentity.js.map +1 -0
- package/dist/auth/rateLimits.js +66 -0
- package/dist/auth/rateLimits.js.map +1 -0
- package/dist/auth/recovery.js +275 -0
- package/dist/auth/recovery.js.map +1 -0
- package/dist/auth/requestContext.js +34 -0
- package/dist/auth/requestContext.js.map +1 -0
- package/dist/auth/resourceMiddleware.js +147 -0
- package/dist/auth/resourceMiddleware.js.map +1 -0
- package/dist/auth/runtimeStatus.js +51 -0
- package/dist/auth/runtimeStatus.js.map +1 -0
- package/dist/auth/schemas.js +84 -0
- package/dist/auth/schemas.js.map +1 -0
- package/dist/auth/stateStore.js +468 -0
- package/dist/auth/stateStore.js.map +1 -0
- package/dist/auth/tokenService.js +631 -0
- package/dist/auth/tokenService.js.map +1 -0
- package/dist/auth/toolSecurity.js +108 -0
- package/dist/auth/toolSecurity.js.map +1 -0
- package/dist/auth/types.js +6 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/auth/windowsDpapi.js +193 -0
- package/dist/auth/windowsDpapi.js.map +1 -0
- package/dist/bashOps.js +292 -0
- package/dist/bashOps.js.map +1 -0
- package/dist/capabilitiesOps.js +412 -0
- package/dist/capabilitiesOps.js.map +1 -0
- package/dist/changesets/crypto.js +92 -0
- package/dist/changesets/crypto.js.map +1 -0
- package/dist/changesets/index.js +9 -0
- package/dist/changesets/index.js.map +1 -0
- package/dist/changesets/moveStore.js +237 -0
- package/dist/changesets/moveStore.js.map +1 -0
- package/dist/changesets/moveUndo.js +386 -0
- package/dist/changesets/moveUndo.js.map +1 -0
- package/dist/changesets/schemas.js +234 -0
- package/dist/changesets/schemas.js.map +1 -0
- package/dist/changesets/store.js +573 -0
- package/dist/changesets/store.js.map +1 -0
- package/dist/changesets/types.js +9 -0
- package/dist/changesets/types.js.map +1 -0
- package/dist/changesets/undo.js +525 -0
- package/dist/changesets/undo.js.map +1 -0
- package/dist/changesets/unifiedUndo.js +31 -0
- package/dist/changesets/unifiedUndo.js.map +1 -0
- package/dist/cliEnvironment.js +85 -0
- package/dist/cliEnvironment.js.map +1 -0
- package/dist/codexSessions.js +733 -0
- package/dist/codexSessions.js.map +1 -0
- package/dist/codexgptSupertool.js +216 -0
- package/dist/codexgptSupertool.js.map +1 -0
- package/dist/codexproSupertool.js +204 -0
- package/dist/codexproSupertool.js.map +1 -0
- package/dist/config.js +733 -0
- package/dist/config.js.map +1 -0
- package/dist/control/localApprovalClient.js +287 -0
- package/dist/control/localApprovalClient.js.map +1 -0
- package/dist/control/localApprovalServer.js +466 -0
- package/dist/control/localApprovalServer.js.map +1 -0
- package/dist/control/runtime.js +178 -0
- package/dist/control/runtime.js.map +1 -0
- package/dist/control/schemas.js +184 -0
- package/dist/control/schemas.js.map +1 -0
- package/dist/control/windowsLocalControl.js +348 -0
- package/dist/control/windowsLocalControl.js.map +1 -0
- package/dist/fsOps.js +541 -0
- package/dist/fsOps.js.map +1 -0
- package/dist/git/admission.js +26 -0
- package/dist/git/admission.js.map +1 -0
- package/dist/git/branchService.js +51 -0
- package/dist/git/branchService.js.map +1 -0
- package/dist/git/capabilities.js +143 -0
- package/dist/git/capabilities.js.map +1 -0
- package/dist/git/commitService.js +344 -0
- package/dist/git/commitService.js.map +1 -0
- package/dist/git/durableState.js +151 -0
- package/dist/git/durableState.js.map +1 -0
- package/dist/git/execution.js +451 -0
- package/dist/git/execution.js.map +1 -0
- package/dist/git/fileTransaction.js +50 -0
- package/dist/git/fileTransaction.js.map +1 -0
- package/dist/git/indexService.js +421 -0
- package/dist/git/indexService.js.map +1 -0
- package/dist/git/integrations.js +653 -0
- package/dist/git/integrations.js.map +1 -0
- package/dist/git/locks.js +287 -0
- package/dist/git/locks.js.map +1 -0
- package/dist/git/mutationContext.js +92 -0
- package/dist/git/mutationContext.js.map +1 -0
- package/dist/git/mutationJournal.js +91 -0
- package/dist/git/mutationJournal.js.map +1 -0
- package/dist/git/mutationService.js +352 -0
- package/dist/git/mutationService.js.map +1 -0
- package/dist/git/normalization.js +57 -0
- package/dist/git/normalization.js.map +1 -0
- package/dist/git/objectQuarantine.js +243 -0
- package/dist/git/objectQuarantine.js.map +1 -0
- package/dist/git/opaqueRecordStore.js +187 -0
- package/dist/git/opaqueRecordStore.js.map +1 -0
- package/dist/git/operationStore.js +287 -0
- package/dist/git/operationStore.js.map +1 -0
- package/dist/git/parsers.js +311 -0
- package/dist/git/parsers.js.map +1 -0
- package/dist/git/privateIndex.js +79 -0
- package/dist/git/privateIndex.js.map +1 -0
- package/dist/git/productionBootstrap.js +39 -0
- package/dist/git/productionBootstrap.js.map +1 -0
- package/dist/git/readService.js +846 -0
- package/dist/git/readService.js.map +1 -0
- package/dist/git/recovery.js +417 -0
- package/dist/git/recovery.js.map +1 -0
- package/dist/git/repositoryIdentity.js +611 -0
- package/dist/git/repositoryIdentity.js.map +1 -0
- package/dist/git/repositoryStore.js +237 -0
- package/dist/git/repositoryStore.js.map +1 -0
- package/dist/git/resources.js +113 -0
- package/dist/git/resources.js.map +1 -0
- package/dist/git/restoreService.js +178 -0
- package/dist/git/restoreService.js.map +1 -0
- package/dist/git/reviewToken.js +86 -0
- package/dist/git/reviewToken.js.map +1 -0
- package/dist/git/stashService.js +566 -0
- package/dist/git/stashService.js.map +1 -0
- package/dist/git/stateToken.js +139 -0
- package/dist/git/stateToken.js.map +1 -0
- package/dist/gitOps.js +147 -0
- package/dist/gitOps.js.map +1 -0
- package/dist/guard.js +608 -0
- package/dist/guard.js.map +1 -0
- package/dist/guidance/diagnostics.js +14 -0
- package/dist/guidance/diagnostics.js.map +1 -0
- package/dist/guidance/instructions.js +167 -0
- package/dist/guidance/instructions.js.map +1 -0
- package/dist/guidance/mode.js +18 -0
- package/dist/guidance/mode.js.map +1 -0
- package/dist/guidance/openaiSkillMetadata.js +29 -0
- package/dist/guidance/openaiSkillMetadata.js.map +1 -0
- package/dist/guidance/safeTextReader.js +171 -0
- package/dist/guidance/safeTextReader.js.map +1 -0
- package/dist/guidance/skillCatalog.js +70 -0
- package/dist/guidance/skillCatalog.js.map +1 -0
- package/dist/guidance/skillDiscovery.js +353 -0
- package/dist/guidance/skillDiscovery.js.map +1 -0
- package/dist/guidance/skillMetadata.js +115 -0
- package/dist/guidance/skillMetadata.js.map +1 -0
- package/dist/guidance/skillResources.js +146 -0
- package/dist/guidance/skillResources.js.map +1 -0
- package/dist/handoffOps.js +449 -0
- package/dist/handoffOps.js.map +1 -0
- package/dist/http/localAdminApp.js +203 -0
- package/dist/http/localAdminApp.js.map +1 -0
- package/dist/http/oauthMcpRuntime.js +294 -0
- package/dist/http/oauthMcpRuntime.js.map +1 -0
- package/dist/http/publicApp.js +350 -0
- package/dist/http/publicApp.js.map +1 -0
- package/dist/http/securityHeaders.js +11 -0
- package/dist/http/securityHeaders.js.map +1 -0
- package/dist/http.js +2076 -0
- package/dist/http.js.map +1 -0
- package/dist/moves/engine.js +1079 -0
- package/dist/moves/engine.js.map +1 -0
- package/dist/moves/index.js +6 -0
- package/dist/moves/index.js.map +1 -0
- package/dist/moves/planner.js +270 -0
- package/dist/moves/planner.js.map +1 -0
- package/dist/moves/recovery.js +557 -0
- package/dist/moves/recovery.js.map +1 -0
- package/dist/moves/service.js +300 -0
- package/dist/moves/service.js.map +1 -0
- package/dist/moves/types.js +11 -0
- package/dist/moves/types.js.map +1 -0
- package/dist/mutations/index.js +4 -0
- package/dist/mutations/index.js.map +1 -0
- package/dist/mutations/lifecycle.js +165 -0
- package/dist/mutations/lifecycle.js.map +1 -0
- package/dist/mutations/localService.js +163 -0
- package/dist/mutations/localService.js.map +1 -0
- package/dist/mutations/runtime.js +322 -0
- package/dist/mutations/runtime.js.map +1 -0
- package/dist/mutations/types.js +2 -0
- package/dist/mutations/types.js.map +1 -0
- package/dist/mutations/writers.js +360 -0
- package/dist/mutations/writers.js.map +1 -0
- package/dist/patchOps.js +420 -0
- package/dist/patchOps.js.map +1 -0
- package/dist/policy/approval.js +306 -0
- package/dist/policy/approval.js.map +1 -0
- package/dist/policy/audit.js +88 -0
- package/dist/policy/audit.js.map +1 -0
- package/dist/policy/authorizationFacts.js +187 -0
- package/dist/policy/authorizationFacts.js.map +1 -0
- package/dist/policy/compat.js +104 -0
- package/dist/policy/compat.js.map +1 -0
- package/dist/policy/context.js +31 -0
- package/dist/policy/context.js.map +1 -0
- package/dist/policy/enforcement.js +46 -0
- package/dist/policy/enforcement.js.map +1 -0
- package/dist/policy/evaluator.js +338 -0
- package/dist/policy/evaluator.js.map +1 -0
- package/dist/policy/executionCapabilities.js +80 -0
- package/dist/policy/executionCapabilities.js.map +1 -0
- package/dist/policy/executionResources.js +192 -0
- package/dist/policy/executionResources.js.map +1 -0
- package/dist/policy/fullAccessResources.js +23 -0
- package/dist/policy/fullAccessResources.js.map +1 -0
- package/dist/policy/hardPolicy.js +50 -0
- package/dist/policy/hardPolicy.js.map +1 -0
- package/dist/policy/identity.js +142 -0
- package/dist/policy/identity.js.map +1 -0
- package/dist/policy/integration.js +331 -0
- package/dist/policy/integration.js.map +1 -0
- package/dist/policy/pendingApprovals.js +301 -0
- package/dist/policy/pendingApprovals.js.map +1 -0
- package/dist/policy/profileStore.js +367 -0
- package/dist/policy/profileStore.js.map +1 -0
- package/dist/policy/resources.js +249 -0
- package/dist/policy/resources.js.map +1 -0
- package/dist/policy/runtime.js +713 -0
- package/dist/policy/runtime.js.map +1 -0
- package/dist/policy/schemas.js +625 -0
- package/dist/policy/schemas.js.map +1 -0
- package/dist/policy/toolPolicy.js +141 -0
- package/dist/policy/toolPolicy.js.map +1 -0
- package/dist/policy/transport.js +10 -0
- package/dist/policy/transport.js.map +1 -0
- package/dist/policy/types.js +31 -0
- package/dist/policy/types.js.map +1 -0
- package/dist/proContext.js +675 -0
- package/dist/proContext.js.map +1 -0
- package/dist/process/authority.js +18 -0
- package/dist/process/authority.js.map +1 -0
- package/dist/process/backendDiscovery.js +83 -0
- package/dist/process/backendDiscovery.js.map +1 -0
- package/dist/process/commandCompiler.js +71 -0
- package/dist/process/commandCompiler.js.map +1 -0
- package/dist/process/outputCursor.js +67 -0
- package/dist/process/outputCursor.js.map +1 -0
- package/dist/process/outputQuota.js +94 -0
- package/dist/process/outputQuota.js.map +1 -0
- package/dist/process/outputRing.js +138 -0
- package/dist/process/outputRing.js.map +1 -0
- package/dist/process/processAuditCoordinator.js +52 -0
- package/dist/process/processAuditCoordinator.js.map +1 -0
- package/dist/process/processManager.js +311 -0
- package/dist/process/processManager.js.map +1 -0
- package/dist/process/runCommand.js +332 -0
- package/dist/process/runCommand.js.map +1 -0
- package/dist/process/streamingRedactor.js +105 -0
- package/dist/process/streamingRedactor.js.map +1 -0
- package/dist/process/types.js +2 -0
- package/dist/process/types.js.map +1 -0
- package/dist/process/windowsHostClient.js +604 -0
- package/dist/process/windowsHostClient.js.map +1 -0
- package/dist/process/windowsHostProtocol.js +270 -0
- package/dist/process/windowsHostProtocol.js.map +1 -0
- package/dist/process/windowsPersistentBackend.js +263 -0
- package/dist/process/windowsPersistentBackend.js.map +1 -0
- package/dist/productionRuntime.js +907 -0
- package/dist/productionRuntime.js.map +1 -0
- package/dist/profileStore.js +231 -0
- package/dist/profileStore.js.map +1 -0
- package/dist/redact.js +124 -0
- package/dist/redact.js.map +1 -0
- package/dist/searchOps.js +186 -0
- package/dist/searchOps.js.map +1 -0
- package/dist/selfTestOps.js +786 -0
- package/dist/selfTestOps.js.map +1 -0
- package/dist/semantic/budgets.js +12 -0
- package/dist/semantic/budgets.js.map +1 -0
- package/dist/semantic/builtin/typescriptAssets.js +68 -0
- package/dist/semantic/builtin/typescriptAssets.js.map +1 -0
- package/dist/semantic/builtin/typescriptProvider.js +211 -0
- package/dist/semantic/builtin/typescriptProvider.js.map +1 -0
- package/dist/semantic/builtin/typescriptWorker.js +365 -0
- package/dist/semantic/builtin/typescriptWorker.js.map +1 -0
- package/dist/semantic/diffPreview.js +36 -0
- package/dist/semantic/diffPreview.js.map +1 -0
- package/dist/semantic/index.js +11 -0
- package/dist/semantic/index.js.map +1 -0
- package/dist/semantic/manager.js +522 -0
- package/dist/semantic/manager.js.map +1 -0
- package/dist/semantic/positions.js +86 -0
- package/dist/semantic/positions.js.map +1 -0
- package/dist/semantic/previewStore.js +276 -0
- package/dist/semantic/previewStore.js.map +1 -0
- package/dist/semantic/projectResolver.js +309 -0
- package/dist/semantic/projectResolver.js.map +1 -0
- package/dist/semantic/sourceSnapshot.js +54 -0
- package/dist/semantic/sourceSnapshot.js.map +1 -0
- package/dist/semantic/status.js +46 -0
- package/dist/semantic/status.js.map +1 -0
- package/dist/semantic/types.js +2 -0
- package/dist/semantic/types.js.map +1 -0
- package/dist/server.js +8676 -0
- package/dist/server.js.map +1 -0
- package/dist/stdio.js +64 -0
- package/dist/stdio.js.map +1 -0
- package/dist/toolCardWidget.js +2000 -0
- package/dist/toolCardWidget.js.map +1 -0
- package/dist/tools/contracts/catalog.js +111 -0
- package/dist/tools/contracts/catalog.js.map +1 -0
- package/dist/tools/contracts/index.js +8 -0
- package/dist/tools/contracts/index.js.map +1 -0
- package/dist/tools/contracts/registration.js +27 -0
- package/dist/tools/contracts/registration.js.map +1 -0
- package/dist/tools/contracts/schemas.js +11 -0
- package/dist/tools/contracts/schemas.js.map +1 -0
- package/dist/tools/contracts/types.js +2 -0
- package/dist/tools/contracts/types.js.map +1 -0
- package/dist/tools/contracts/v3.js +76 -0
- package/dist/tools/contracts/v3.js.map +1 -0
- package/dist/tools/contracts/v4.js +39 -0
- package/dist/tools/contracts/v4.js.map +1 -0
- package/dist/tools/contracts/v5.js +20 -0
- package/dist/tools/contracts/v5.js.map +1 -0
- package/dist/tools/phase3dServer.js +350 -0
- package/dist/tools/phase3dServer.js.map +1 -0
- package/dist/tools/schemas/applyPatch.js +388 -0
- package/dist/tools/schemas/applyPatch.js.map +1 -0
- package/dist/tools/schemas/bash.js +202 -0
- package/dist/tools/schemas/bash.js.map +1 -0
- package/dist/tools/schemas/closeWorkspace.js +105 -0
- package/dist/tools/schemas/closeWorkspace.js.map +1 -0
- package/dist/tools/schemas/codexContext.js +402 -0
- package/dist/tools/schemas/codexContext.js.map +1 -0
- package/dist/tools/schemas/codexSessions.js +328 -0
- package/dist/tools/schemas/codexSessions.js.map +1 -0
- package/dist/tools/schemas/codexgpt.js +1068 -0
- package/dist/tools/schemas/codexgpt.js.map +1 -0
- package/dist/tools/schemas/codexgptInventory.js +359 -0
- package/dist/tools/schemas/codexgptInventory.js.map +1 -0
- package/dist/tools/schemas/codexgptSelfTest.js +563 -0
- package/dist/tools/schemas/codexgptSelfTest.js.map +1 -0
- package/dist/tools/schemas/codexpro.js +917 -0
- package/dist/tools/schemas/codexpro.js.map +1 -0
- package/dist/tools/schemas/codexproInventory.js +352 -0
- package/dist/tools/schemas/codexproInventory.js.map +1 -0
- package/dist/tools/schemas/codexproSelfTest.js +546 -0
- package/dist/tools/schemas/codexproSelfTest.js.map +1 -0
- package/dist/tools/schemas/common.js +21 -0
- package/dist/tools/schemas/common.js.map +1 -0
- package/dist/tools/schemas/createTaskWorktree.js +51 -0
- package/dist/tools/schemas/createTaskWorktree.js.map +1 -0
- package/dist/tools/schemas/edit.js +321 -0
- package/dist/tools/schemas/edit.js.map +1 -0
- package/dist/tools/schemas/execution.js +330 -0
- package/dist/tools/schemas/execution.js.map +1 -0
- package/dist/tools/schemas/exportProContext.js +370 -0
- package/dist/tools/schemas/exportProContext.js.map +1 -0
- package/dist/tools/schemas/getTaskWorktree.js +19 -0
- package/dist/tools/schemas/getTaskWorktree.js.map +1 -0
- package/dist/tools/schemas/gitBranch.js +42 -0
- package/dist/tools/schemas/gitBranch.js.map +1 -0
- package/dist/tools/schemas/gitCommit.js +40 -0
- package/dist/tools/schemas/gitCommit.js.map +1 -0
- package/dist/tools/schemas/gitCreateBranch.js +22 -0
- package/dist/tools/schemas/gitCreateBranch.js.map +1 -0
- package/dist/tools/schemas/gitDiff.js +222 -0
- package/dist/tools/schemas/gitDiff.js.map +1 -0
- package/dist/tools/schemas/gitLog.js +41 -0
- package/dist/tools/schemas/gitLog.js.map +1 -0
- package/dist/tools/schemas/gitRestore.js +47 -0
- package/dist/tools/schemas/gitRestore.js.map +1 -0
- package/dist/tools/schemas/gitStage.js +33 -0
- package/dist/tools/schemas/gitStage.js.map +1 -0
- package/dist/tools/schemas/gitStash.js +102 -0
- package/dist/tools/schemas/gitStash.js.map +1 -0
- package/dist/tools/schemas/gitStatus.js +226 -0
- package/dist/tools/schemas/gitStatus.js.map +1 -0
- package/dist/tools/schemas/gitV4Common.js +205 -0
- package/dist/tools/schemas/gitV4Common.js.map +1 -0
- package/dist/tools/schemas/guidance.js +40 -0
- package/dist/tools/schemas/guidance.js.map +1 -0
- package/dist/tools/schemas/handoffToAgent.js +276 -0
- package/dist/tools/schemas/handoffToAgent.js.map +1 -0
- package/dist/tools/schemas/handoffToCodex.js +137 -0
- package/dist/tools/schemas/handoffToCodex.js.map +1 -0
- package/dist/tools/schemas/inspectWorkspace.js +379 -0
- package/dist/tools/schemas/inspectWorkspace.js.map +1 -0
- package/dist/tools/schemas/listTaskWorktrees.js +21 -0
- package/dist/tools/schemas/listTaskWorktrees.js.map +1 -0
- package/dist/tools/schemas/listWorkspaces.js +134 -0
- package/dist/tools/schemas/listWorkspaces.js.map +1 -0
- package/dist/tools/schemas/loadSkill.js +619 -0
- package/dist/tools/schemas/loadSkill.js.map +1 -0
- package/dist/tools/schemas/mergeTaskWorktree.js +105 -0
- package/dist/tools/schemas/mergeTaskWorktree.js.map +1 -0
- package/dist/tools/schemas/movePaths.js +175 -0
- package/dist/tools/schemas/movePaths.js.map +1 -0
- package/dist/tools/schemas/openCurrentWorkspace.js +174 -0
- package/dist/tools/schemas/openCurrentWorkspace.js.map +1 -0
- package/dist/tools/schemas/openFullAccessWorkspace.js +81 -0
- package/dist/tools/schemas/openFullAccessWorkspace.js.map +1 -0
- package/dist/tools/schemas/openWorkspace.js +193 -0
- package/dist/tools/schemas/openWorkspace.js.map +1 -0
- package/dist/tools/schemas/queryAuditEvents.js +193 -0
- package/dist/tools/schemas/queryAuditEvents.js.map +1 -0
- package/dist/tools/schemas/read.js +199 -0
- package/dist/tools/schemas/read.js.map +1 -0
- package/dist/tools/schemas/readCodexSession.js +353 -0
- package/dist/tools/schemas/readCodexSession.js.map +1 -0
- package/dist/tools/schemas/readHandoff.js +446 -0
- package/dist/tools/schemas/readHandoff.js.map +1 -0
- package/dist/tools/schemas/removeTaskWorktree.js +40 -0
- package/dist/tools/schemas/removeTaskWorktree.js.map +1 -0
- package/dist/tools/schemas/search.js +235 -0
- package/dist/tools/schemas/search.js.map +1 -0
- package/dist/tools/schemas/semantic.js +195 -0
- package/dist/tools/schemas/semantic.js.map +1 -0
- package/dist/tools/schemas/serverConfig.js +157 -0
- package/dist/tools/schemas/serverConfig.js.map +1 -0
- package/dist/tools/schemas/showChanges.js +283 -0
- package/dist/tools/schemas/showChanges.js.map +1 -0
- package/dist/tools/schemas/transactionResult.js +11 -0
- package/dist/tools/schemas/transactionResult.js.map +1 -0
- package/dist/tools/schemas/tree.js +136 -0
- package/dist/tools/schemas/tree.js.map +1 -0
- package/dist/tools/schemas/undoChangeSet.js +152 -0
- package/dist/tools/schemas/undoChangeSet.js.map +1 -0
- package/dist/tools/schemas/waitForHandoff.js +462 -0
- package/dist/tools/schemas/waitForHandoff.js.map +1 -0
- package/dist/tools/schemas/workspaceSnapshot.js +145 -0
- package/dist/tools/schemas/workspaceSnapshot.js.map +1 -0
- package/dist/tools/schemas/write.js +285 -0
- package/dist/tools/schemas/write.js.map +1 -0
- package/dist/transactions/atomicFs.js +438 -0
- package/dist/transactions/atomicFs.js.map +1 -0
- package/dist/transactions/atomicStateFile.js +190 -0
- package/dist/transactions/atomicStateFile.js.map +1 -0
- package/dist/transactions/engine.js +574 -0
- package/dist/transactions/engine.js.map +1 -0
- package/dist/transactions/index.js +12 -0
- package/dist/transactions/index.js.map +1 -0
- package/dist/transactions/installation.js +158 -0
- package/dist/transactions/installation.js.map +1 -0
- package/dist/transactions/manifestV2Store.js +96 -0
- package/dist/transactions/manifestV2Store.js.map +1 -0
- package/dist/transactions/participantRecovery.js +98 -0
- package/dist/transactions/participantRecovery.js.map +1 -0
- package/dist/transactions/recovery.js +513 -0
- package/dist/transactions/recovery.js.map +1 -0
- package/dist/transactions/schemas.js +365 -0
- package/dist/transactions/schemas.js.map +1 -0
- package/dist/transactions/stateRoot.js +63 -0
- package/dist/transactions/stateRoot.js.map +1 -0
- package/dist/transactions/types.js +11 -0
- package/dist/transactions/types.js.map +1 -0
- package/dist/transactions/workspaceLock.js +201 -0
- package/dist/transactions/workspaceLock.js.map +1 -0
- package/dist/workspaceOps.js +924 -0
- package/dist/workspaceOps.js.map +1 -0
- package/dist/worktrees/candidateWorkspace.js +566 -0
- package/dist/worktrees/candidateWorkspace.js.map +1 -0
- package/dist/worktrees/manager.js +258 -0
- package/dist/worktrees/manager.js.map +1 -0
- package/dist/worktrees/materializer.js +60 -0
- package/dist/worktrees/materializer.js.map +1 -0
- package/dist/worktrees/mergeExecute.js +498 -0
- package/dist/worktrees/mergeExecute.js.map +1 -0
- package/dist/worktrees/mergePlanStore.js +247 -0
- package/dist/worktrees/mergePlanStore.js.map +1 -0
- package/dist/worktrees/mergePrepare.js +709 -0
- package/dist/worktrees/mergePrepare.js.map +1 -0
- package/dist/worktrees/recovery.js +294 -0
- package/dist/worktrees/recovery.js.map +1 -0
- package/dist/worktrees/remove.js +296 -0
- package/dist/worktrees/remove.js.map +1 -0
- package/dist/worktrees/remover.js +57 -0
- package/dist/worktrees/remover.js.map +1 -0
- package/dist/worktrees/root.js +47 -0
- package/dist/worktrees/root.js.map +1 -0
- package/dist/worktrees/service.js +245 -0
- package/dist/worktrees/service.js.map +1 -0
- package/dist/worktrees/store.js +156 -0
- package/dist/worktrees/store.js.map +1 -0
- package/dist/worktrees/treeManifest.js +106 -0
- package/dist/worktrees/treeManifest.js.map +1 -0
- package/dist/worktrees/verificationReceipts.js +215 -0
- package/dist/worktrees/verificationReceipts.js.map +1 -0
- package/dist/worktrees/verificationTerminal.js +23 -0
- package/dist/worktrees/verificationTerminal.js.map +1 -0
- package/dist/worktrees/workspaceAuthority.js +64 -0
- package/dist/worktrees/workspaceAuthority.js.map +1 -0
- package/docs/favicon.svg +5 -0
- package/docs/index.html +624 -0
- package/docs/og.svg +52 -0
- package/docs/script.js +33 -0
- package/docs/star.svg +11 -0
- package/docs/styles.css +1571 -0
- package/docs/zh.html +428 -0
- package/package.json +121 -0
- package/scripts/analysis-cli-smoke.mjs +81 -0
- package/scripts/analysis-smoke.mjs +179 -0
- package/scripts/atomic-file.mjs +137 -0
- package/scripts/ci-change-classifier.mjs +59 -0
- package/scripts/ci-failure-summary.mjs +92 -0
- package/scripts/cloudflared-installer.mjs +215 -0
- package/scripts/cloudflared-release.mjs +63 -0
- package/scripts/codexgpt-entry.mjs +235 -0
- package/scripts/codexgpt.mjs +4987 -0
- package/scripts/connector-auth-output-shim.cjs +66 -0
- package/scripts/doctor-smoke.mjs +90 -0
- package/scripts/doctor.mjs +165 -0
- package/scripts/exact-head-ci.mjs +126 -0
- package/scripts/execute-handoff-smoke-platform-compat.mjs +38 -0
- package/scripts/execute-handoff-smoke.mjs +1117 -0
- package/scripts/g8-u-live-probe.mjs +208 -0
- package/scripts/http-smoke-compat.mjs +151 -0
- package/scripts/http-smoke.mjs +776 -0
- package/scripts/long-task-runner.mjs +1037 -0
- package/scripts/oauth-admin.mjs +1608 -0
- package/scripts/output-bounds.mjs +29 -0
- package/scripts/owned-temp-root.d.mts +50 -0
- package/scripts/owned-temp-root.mjs +567 -0
- package/scripts/phase-4a-smoke.mjs +36 -0
- package/scripts/policy-windows-spike.mjs +135 -0
- package/scripts/pro-apply.mjs +152 -0
- package/scripts/pro-bundle.mjs +121 -0
- package/scripts/pro-smoke.mjs +97 -0
- package/scripts/process-identity.mjs +67 -0
- package/scripts/repository-policy.mjs +166 -0
- package/scripts/run-and-summarize.mjs +134 -0
- package/scripts/run-smoke.mjs +52 -0
- package/scripts/run-with-cleanup.mjs +98 -0
- package/scripts/settings-smoke-platform-compat.mjs +85 -0
- package/scripts/settings-smoke.mjs +769 -0
- package/scripts/smoke-platform-compat.mjs +302 -0
- package/scripts/smoke.mjs +1180 -0
- package/scripts/stress-contract-compat.mjs +94 -0
- package/scripts/stress.mjs +882 -0
- package/scripts/test-domains.mjs +247 -0
- package/scripts/test-execution-profile-manifest.mjs +273 -0
- package/scripts/test-execution-profiles.mjs +147 -0
- package/scripts/test-performance-reporter.mjs +291 -0
- package/scripts/toolchain-manager.mjs +266 -0
- package/scripts/toolchains.json +19 -0
- package/scripts/windows-conpty-probe-child.mjs +82 -0
- package/scripts/windows-conpty-worker.ps1 +24 -0
- package/scripts/windows-credential-host-manifest.json +16 -0
- package/scripts/windows-credential-host-protocol-v1.json +16 -0
- package/scripts/windows-credential-host.cs +256 -0
- package/scripts/windows-credential-host.ps1 +26 -0
- package/scripts/windows-local-control-manifest.json +23 -0
- package/scripts/windows-local-control-spike.cs +738 -0
- package/scripts/windows-local-control-spike.mjs +415 -0
- package/scripts/windows-local-control-spike.ps1 +35 -0
- package/scripts/windows-local-control.cs +738 -0
- package/scripts/windows-local-control.ps1 +35 -0
- package/scripts/windows-native-api-inventory-v1.json +90 -0
- package/scripts/windows-process-host-manifest.json +20 -0
- package/scripts/windows-process-host-protocol-v1.json +59 -0
- package/scripts/windows-process-host.cs +2385 -0
- package/scripts/windows-process-host.ps1 +59 -0
- package/scripts/windows-realpath-shim.cjs +78 -0
|
@@ -0,0 +1,907 @@
|
|
|
1
|
+
import { assertAuditConfiguration, assertFileTransactionConfiguration, assertToolContractConfiguration } from "./config.js";
|
|
2
|
+
import { PathGuard } from "./guard.js";
|
|
3
|
+
import { LocalApprovalRuntimeV3 } from "./control/runtime.js";
|
|
4
|
+
import { WindowsProcessHostRuntime } from "./process/windowsHostClient.js";
|
|
5
|
+
import { RunCommandRuntimeV3 } from "./process/runCommand.js";
|
|
6
|
+
import { ProcessManagerV3 } from "./process/processManager.js";
|
|
7
|
+
import { ProcessAuditCoordinatorV3 } from "./process/processAuditCoordinator.js";
|
|
8
|
+
import { WindowsPersistentProcessBackendV3 } from "./process/windowsPersistentBackend.js";
|
|
9
|
+
import { compilePermissionProfileV3, loadPermissionProfileGraphV3 } from "./policy/profileStore.js";
|
|
10
|
+
import { inspectPolicyConfiguration } from "./policy/runtime.js";
|
|
11
|
+
import { semanticDigest } from "./policy/authorizationFacts.js";
|
|
12
|
+
import { PersistentAuditRuntimeV2, PersistentAuditStore, createAuditQueryHandler, createAuditQueryHandlerV3 } from "./audit/index.js";
|
|
13
|
+
import { ChangeSetStore } from "./changesets/store.js";
|
|
14
|
+
import { MoveChangeSetStore } from "./changesets/moveStore.js";
|
|
15
|
+
import { UndoChangeSetService } from "./changesets/undo.js";
|
|
16
|
+
import { MoveUndoChangeSetService } from "./changesets/moveUndo.js";
|
|
17
|
+
import { UnifiedUndoChangeSetService } from "./changesets/unifiedUndo.js";
|
|
18
|
+
import { MovePathsService } from "./moves/service.js";
|
|
19
|
+
import { WorkspaceMutationRuntime } from "./mutations/runtime.js";
|
|
20
|
+
import { ServerMutationLifecycle, installServerMutationLifecycle } from "./mutations/lifecycle.js";
|
|
21
|
+
import { upgradeCodexGPTSupertool } from "./codexgptSupertool.js";
|
|
22
|
+
import { currentPolicyIdentity } from "./policy/identity.js";
|
|
23
|
+
import { ownerIdForPolicyIdentity, policyIdentityOwnershipFacts } from "./auth/policyIdentity.js";
|
|
24
|
+
import { AtomicTransactionEngine, ProcessInstanceRegistry, WorkspaceMutationLock, createDefaultTransactionRecoveryCoordinator, createDurableParticipantRecoveryAdapter, deriveTransactionSubkey, installationMasterKey, loadOrCreateInstallationState, resolveTransactionStateRoot } from "./transactions/index.js";
|
|
25
|
+
import { createCodexGPTServer } from "./server.js";
|
|
26
|
+
import { contractIncludesV3, contractIncludesV4 } from "./tools/contracts/index.js";
|
|
27
|
+
import { assertGitCapabilityEvidence } from "./git/capabilities.js";
|
|
28
|
+
import { RepositoryIdentityRegistry } from "./git/repositoryIdentity.js";
|
|
29
|
+
import { GitStateTokenService } from "./git/stateToken.js";
|
|
30
|
+
import { GitReadServiceV4 as ConcreteGitReadServiceV4 } from "./git/readService.js";
|
|
31
|
+
import { GitMutationContextV4 } from "./git/mutationContext.js";
|
|
32
|
+
import { GitIndexServiceV4, GitIndexTokenServiceV4 } from "./git/indexService.js";
|
|
33
|
+
import { GitBranchServiceV4 } from "./git/branchService.js";
|
|
34
|
+
import { GitCommitServiceV4 } from "./git/commitService.js";
|
|
35
|
+
import { GitReviewTokenServiceV4 } from "./git/reviewToken.js";
|
|
36
|
+
import { GitIntegrationGateV4 } from "./git/integrations.js";
|
|
37
|
+
import { GitRestoreServiceV4 } from "./git/restoreService.js";
|
|
38
|
+
import { GitRepositoryAdmissionV4 } from "./git/admission.js";
|
|
39
|
+
import { GitStashServiceV4 } from "./git/stashService.js";
|
|
40
|
+
import { GitFileTransactionV4 } from "./git/fileTransaction.js";
|
|
41
|
+
import { GitMutationServiceV4 } from "./git/mutationService.js";
|
|
42
|
+
import { GitMutationJournalV4 } from "./git/mutationJournal.js";
|
|
43
|
+
import { GitOperationStore } from "./git/operationStore.js";
|
|
44
|
+
import { GitRepositoryStore } from "./git/repositoryStore.js";
|
|
45
|
+
import { GitLockManager } from "./git/locks.js";
|
|
46
|
+
import { GitGateRRuntimeV4 as ConcreteGitGateRRuntimeV4, GitRecoveryCoordinator } from "./git/recovery.js";
|
|
47
|
+
import { createRecoveryAuditEventV4 } from "./audit/lifecycleV4.js";
|
|
48
|
+
import { TaskWorktreeStoreV1 } from "./worktrees/store.js";
|
|
49
|
+
import { TaskWorktreeManagerV4 } from "./worktrees/manager.js";
|
|
50
|
+
import { TaskWorktreeWorkspaceAuthorityV4 } from "./worktrees/workspaceAuthority.js";
|
|
51
|
+
import { TaskWorktreeServiceV4 } from "./worktrees/service.js";
|
|
52
|
+
import { MergePlanStoreV4 } from "./worktrees/mergePlanStore.js";
|
|
53
|
+
import { TaskWorktreeMergePrepareV4 } from "./worktrees/mergePrepare.js";
|
|
54
|
+
import { TaskWorktreeMergeExecuteV4 } from "./worktrees/mergeExecute.js";
|
|
55
|
+
import { TaskWorktreeRemoveV4 } from "./worktrees/remove.js";
|
|
56
|
+
import { TaskWorktreeRecoveryV4 } from "./worktrees/recovery.js";
|
|
57
|
+
import { VerificationReceiptServiceV4 } from "./worktrees/verificationReceipts.js";
|
|
58
|
+
import { CandidateVerificationWorkspaceV4 } from "./worktrees/candidateWorkspace.js";
|
|
59
|
+
const ATOMIC_MUTATION_TOOL_NAMES = new Set([
|
|
60
|
+
"apply_patch",
|
|
61
|
+
"codexgpt_self_test",
|
|
62
|
+
"edit",
|
|
63
|
+
"export_pro_context",
|
|
64
|
+
"handoff_to_agent",
|
|
65
|
+
"handoff_to_codex",
|
|
66
|
+
"write"
|
|
67
|
+
]);
|
|
68
|
+
function noRuntime(policySessionContextSource, oauthToolSecurity, lifecycle, semanticPreviewStoreV5, semanticWorkerHealthV5) {
|
|
69
|
+
return {
|
|
70
|
+
dependencies: { policySessionContextSource, oauthToolSecurity, semanticPreviewStoreV5, semanticWorkerHealthV5 },
|
|
71
|
+
observation: {
|
|
72
|
+
atomic: false,
|
|
73
|
+
durableAudit: false,
|
|
74
|
+
stateRoot: null,
|
|
75
|
+
registryInstanceId: null,
|
|
76
|
+
mutationRuntime: null,
|
|
77
|
+
auditRuntime: null,
|
|
78
|
+
localApprovalServerId: null,
|
|
79
|
+
processHostConfigured: false,
|
|
80
|
+
gitGateRReady: false
|
|
81
|
+
},
|
|
82
|
+
lifecycle,
|
|
83
|
+
async startup() { },
|
|
84
|
+
async dispose() {
|
|
85
|
+
lifecycle.quiesce();
|
|
86
|
+
await lifecycle.drain();
|
|
87
|
+
if (lifecycle.state() !== "disposed")
|
|
88
|
+
lifecycle.markDisposed();
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function requireAuditReady(store) {
|
|
93
|
+
const diagnostics = store.diagnostics();
|
|
94
|
+
if (diagnostics.state === "integrity_failed") {
|
|
95
|
+
throw new Error("Persistent audit integrity verification failed during production startup.");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function composeRuntime(config, options) {
|
|
99
|
+
const lifecycle = new ServerMutationLifecycle();
|
|
100
|
+
let localApprovalRuntimeV3 = options.localApprovalRuntimeV3;
|
|
101
|
+
let ownsLocalApprovalRuntimeV3 = false;
|
|
102
|
+
const automaticLocalApproval = contractIncludesV4(config.toolContractVersion) && Boolean(options.gitBootstrapV4);
|
|
103
|
+
const atomic = config.fileTransactions === "atomic";
|
|
104
|
+
const writableAtomic = atomic && config.writeMode !== "off";
|
|
105
|
+
const durableAudit = config.auditMode !== "off" && (config.policyEngineMode !== "legacy" || atomic);
|
|
106
|
+
if (localApprovalRuntimeV3 && (!contractIncludesV3(config.toolContractVersion) ||
|
|
107
|
+
config.policyEngineMode !== "enforce" ||
|
|
108
|
+
!durableAudit)) {
|
|
109
|
+
throw new Error("V3 local approval requires contract 3 or 4, Policy Kernel enforce, and durable audit.");
|
|
110
|
+
}
|
|
111
|
+
if (options.rootAdmissionRuntimeV3 && (!contractIncludesV3(config.toolContractVersion) ||
|
|
112
|
+
config.localFileAccess !== "confirmed_roots" ||
|
|
113
|
+
!localApprovalRuntimeV3)) {
|
|
114
|
+
throw new Error("Confirmed-root admission requires contract 3 or 4, confirmed_roots mode, and the local approval runtime.");
|
|
115
|
+
}
|
|
116
|
+
const automaticGitConfigured = Boolean(options.gitBootstrapV4);
|
|
117
|
+
const gitReadConfigured = Boolean(options.gitReadServiceV4) || automaticGitConfigured;
|
|
118
|
+
const gitEvidenceConfigured = Boolean(options.gitCapabilityEvidenceV4) || automaticGitConfigured;
|
|
119
|
+
if (options.gitBootstrapV4 && (options.gitReadServiceV4 ||
|
|
120
|
+
options.gitMutationServiceV4 ||
|
|
121
|
+
options.gitCapabilityEvidenceV4 ||
|
|
122
|
+
options.gitGateRRuntimeV4 ||
|
|
123
|
+
options.taskWorktreeServiceV4 ||
|
|
124
|
+
options.taskWorktreeAuthorityV4)) {
|
|
125
|
+
throw new Error("Automatic Contract V4 Git composition cannot be mixed with injected Git services.");
|
|
126
|
+
}
|
|
127
|
+
if (options.gitBootstrapV4) {
|
|
128
|
+
try {
|
|
129
|
+
const evidence = assertGitCapabilityEvidence(options.gitBootstrapV4.executor.capability);
|
|
130
|
+
if (evidence.capabilityRevision !== options.gitBootstrapV4.executor.capabilityRevision) {
|
|
131
|
+
throw new Error("GIT_CAPABILITY_UNAVAILABLE");
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
throw new Error("Automatic Contract V4 Git bootstrap did not provide valid capability evidence.");
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (config.gitIntegrations === "approved_full_access" && (!automaticGitConfigured ||
|
|
139
|
+
config.executionProfile !== "full_access" ||
|
|
140
|
+
!options.gitBootstrapV4?.executor.runApprovedIntegration)) {
|
|
141
|
+
throw new Error("Approved repository integrations require the automatic Git bootstrap and full_access host.");
|
|
142
|
+
}
|
|
143
|
+
if (gitReadConfigured !== gitEvidenceConfigured) {
|
|
144
|
+
throw new Error("Contract V4 Git reads require both the typed read service and verified capability evidence.");
|
|
145
|
+
}
|
|
146
|
+
if (options.gitCapabilityEvidenceV4) {
|
|
147
|
+
try {
|
|
148
|
+
const evidence = assertGitCapabilityEvidence(options.gitCapabilityEvidenceV4);
|
|
149
|
+
if (options.gitReadServiceV4?.capabilityRevision !== evidence.capabilityRevision) {
|
|
150
|
+
throw new Error("GIT_CAPABILITY_UNAVAILABLE");
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
catch {
|
|
154
|
+
throw new Error("Contract V4 Git capability evidence is invalid or does not match the typed read service.");
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (options.gitMutationServiceV4 && !options.gitGateRRuntimeV4?.isReady()) {
|
|
158
|
+
throw new Error("Contract V4 Git mutations require a ready Gate R recovery runtime.");
|
|
159
|
+
}
|
|
160
|
+
if (options.gitMutationServiceV4 &&
|
|
161
|
+
options.gitMutationServiceV4.gateRBound !== true) {
|
|
162
|
+
throw new Error("Contract V4 Git mutations must execute through the Gate R journal.");
|
|
163
|
+
}
|
|
164
|
+
if (config.gitMode === "local" && !automaticGitConfigured && (!options.gitMutationServiceV4 || !options.gitGateRRuntimeV4?.isReady())) {
|
|
165
|
+
throw new Error("Local Contract V4 Git mode requires Gate I handlers and a ready Gate R recovery runtime.");
|
|
166
|
+
}
|
|
167
|
+
if (config.gitMode !== "local" && (options.gitMutationServiceV4 || (automaticGitConfigured && options.gitBootstrapV4?.managedRoot))) {
|
|
168
|
+
throw new Error("Contract V4 Git mutation handlers require gitMode=local.");
|
|
169
|
+
}
|
|
170
|
+
if (Boolean(options.taskWorktreeServiceV4) !== Boolean(options.taskWorktreeAuthorityV4)) {
|
|
171
|
+
throw new Error("Contract V4 task worktrees require both the owner-bound service and workspace authority.");
|
|
172
|
+
}
|
|
173
|
+
if (options.taskWorktreeServiceV4 &&
|
|
174
|
+
(!contractIncludesV4(config.toolContractVersion) || config.gitMode !== "local" || !options.gitGateRRuntimeV4?.isReady())) {
|
|
175
|
+
throw new Error("Contract V4 task worktrees require local Git mode and a ready Gate R runtime.");
|
|
176
|
+
}
|
|
177
|
+
if (options.gitGateRRuntimeV4) {
|
|
178
|
+
if (!contractIncludesV4(config.toolContractVersion) || !durableAudit || !options.gitGateRRuntimeV4.isReady()) {
|
|
179
|
+
throw new Error("Gate R requires contract 4, durable audit, and completed startup recovery before production wiring.");
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
assertFileTransactionConfiguration(config, {
|
|
183
|
+
workspaceMutatorsAtomic: atomic
|
|
184
|
+
});
|
|
185
|
+
assertAuditConfiguration(config, {
|
|
186
|
+
durableStoreAvailable: durableAudit
|
|
187
|
+
});
|
|
188
|
+
assertToolContractConfiguration(config, {
|
|
189
|
+
durableAuditAvailable: durableAudit,
|
|
190
|
+
stateRootAvailable: atomic || durableAudit,
|
|
191
|
+
movePathsAvailable: atomic,
|
|
192
|
+
stableSessionAvailable: Boolean(options.policySessionContextSource),
|
|
193
|
+
atomicStateReadersAvailable: atomic && durableAudit,
|
|
194
|
+
contractV3MigrationAvailable: true,
|
|
195
|
+
nativeHostIdentityAvailable: gitEvidenceConfigured,
|
|
196
|
+
localApprovalAvailable: Boolean(localApprovalRuntimeV3) || automaticLocalApproval,
|
|
197
|
+
gitCapabilityAvailable: gitReadConfigured && gitEvidenceConfigured,
|
|
198
|
+
contractV4MigrationAvailable: true,
|
|
199
|
+
semanticRuntimeAvailable: config.semanticMode === "standard" &&
|
|
200
|
+
config.semanticProvider === "builtin",
|
|
201
|
+
contractV5MigrationAvailable: true
|
|
202
|
+
});
|
|
203
|
+
if (!atomic && !durableAudit) {
|
|
204
|
+
return noRuntime(options.policySessionContextSource, options.oauthToolSecurity, lifecycle, options.semanticPreviewStoreV5, options.semanticWorkerHealthV5);
|
|
205
|
+
}
|
|
206
|
+
if (writableAtomic && config.auditMode === "off") {
|
|
207
|
+
throw new Error("Writable atomic transactions require persistent audit; CODEXGPT_AUDIT_MODE cannot be off.");
|
|
208
|
+
}
|
|
209
|
+
if ((config.policyEngineMode !== "legacy" || writableAtomic) && !options.policySessionContextSource) {
|
|
210
|
+
throw new Error("Production Policy and atomic audit wiring require a stable session context source.");
|
|
211
|
+
}
|
|
212
|
+
const stateRoot = resolveTransactionStateRoot(options.stateRootOptions);
|
|
213
|
+
const installation = loadOrCreateInstallationState({ stateRoot });
|
|
214
|
+
const masterKey = installationMasterKey(installation);
|
|
215
|
+
let ownerBindingKey = null;
|
|
216
|
+
let registry = null;
|
|
217
|
+
let recovery = null;
|
|
218
|
+
let changeSetStore = null;
|
|
219
|
+
let moveChangeSetStore = null;
|
|
220
|
+
let auditStore = null;
|
|
221
|
+
let auditRuntime = null;
|
|
222
|
+
let mutationRuntime = null;
|
|
223
|
+
let windowsProcessHostRuntime = null;
|
|
224
|
+
let runCommandRuntime = null;
|
|
225
|
+
let processManager = null;
|
|
226
|
+
let executionContextFingerprint = null;
|
|
227
|
+
let executionInspection = null;
|
|
228
|
+
let automaticGitStartup = Promise.resolve();
|
|
229
|
+
let automaticGitRegistry = null;
|
|
230
|
+
let automaticGitStateTokens = null;
|
|
231
|
+
let automaticGitIndexTokens = null;
|
|
232
|
+
let automaticGitReviews = null;
|
|
233
|
+
let automaticGitPlans = null;
|
|
234
|
+
let automaticGitRepositoryStore = null;
|
|
235
|
+
let automaticGitOperationStore = null;
|
|
236
|
+
let automaticGitGateR = null;
|
|
237
|
+
let automaticGitStash = null;
|
|
238
|
+
let automaticVerificationReceipts = null;
|
|
239
|
+
let automaticCandidateWorkspaces = null;
|
|
240
|
+
let atomicEngine = null;
|
|
241
|
+
try {
|
|
242
|
+
registry = new ProcessInstanceRegistry(stateRoot);
|
|
243
|
+
recovery = createDefaultTransactionRecoveryCoordinator(config, {
|
|
244
|
+
stateRoot,
|
|
245
|
+
registry
|
|
246
|
+
});
|
|
247
|
+
const guard = new PathGuard(config);
|
|
248
|
+
if (atomic) {
|
|
249
|
+
atomicEngine = new AtomicTransactionEngine(config, guard, stateRoot, registry, { recoveryCoordinator: recovery });
|
|
250
|
+
}
|
|
251
|
+
const dependencies = {
|
|
252
|
+
policySessionContextSource: options.policySessionContextSource,
|
|
253
|
+
oauthToolSecurity: options.oauthToolSecurity,
|
|
254
|
+
transactionRecoveryCoordinator: recovery,
|
|
255
|
+
localApprovalRuntimeV3,
|
|
256
|
+
rootAdmissionRuntimeV3: options.rootAdmissionRuntimeV3,
|
|
257
|
+
gitReadServiceV4: options.gitReadServiceV4,
|
|
258
|
+
gitMutationServiceV4: options.gitMutationServiceV4,
|
|
259
|
+
taskWorktreeServiceV4: options.taskWorktreeServiceV4,
|
|
260
|
+
taskWorktreeAuthorityV4: options.taskWorktreeAuthorityV4,
|
|
261
|
+
semanticPreviewStoreV5: options.semanticPreviewStoreV5,
|
|
262
|
+
semanticWorkerHealthV5: options.semanticWorkerHealthV5,
|
|
263
|
+
...(contractIncludesV4(config.toolContractVersion) ? {
|
|
264
|
+
v4ContractCapabilities: {
|
|
265
|
+
nativeHostIdentityAvailable: gitEvidenceConfigured,
|
|
266
|
+
localApprovalAvailable: Boolean(localApprovalRuntimeV3) || automaticLocalApproval,
|
|
267
|
+
gitCapabilityAvailable: gitReadConfigured && gitEvidenceConfigured,
|
|
268
|
+
contractV4MigrationAvailable: true
|
|
269
|
+
}
|
|
270
|
+
} : {})
|
|
271
|
+
};
|
|
272
|
+
if (config.executionProfile === "full_access") {
|
|
273
|
+
if (!config.permissionProfileId || !options.policySessionContextSource) {
|
|
274
|
+
throw new Error("Full-access execution requires an explicit Permission Profile V3 and stable session context.");
|
|
275
|
+
}
|
|
276
|
+
windowsProcessHostRuntime = new WindowsProcessHostRuntime();
|
|
277
|
+
dependencies.windowsProcessHostRuntimeV3 = windowsProcessHostRuntime;
|
|
278
|
+
const fullAccessProfile = compilePermissionProfileV3(loadPermissionProfileGraphV3(config.permissionProfileId)).fullAccess;
|
|
279
|
+
const inspection = inspectPolicyConfiguration(config);
|
|
280
|
+
executionInspection = inspection;
|
|
281
|
+
const contextFingerprint = () => semanticDigest({
|
|
282
|
+
serverId: localApprovalRuntimeV3?.serverId ?? "local-server-unavailable",
|
|
283
|
+
contractVersion: 3,
|
|
284
|
+
policyRevision: inspection.policyRevision,
|
|
285
|
+
evidenceRevision: inspection.evidenceRevision,
|
|
286
|
+
transportKind: options.policySessionContextSource.transportKind,
|
|
287
|
+
transportSessionId: options.policySessionContextSource.transportSessionId(),
|
|
288
|
+
identity: policyIdentityOwnershipFacts(currentPolicyIdentity(options.policySessionContextSource))
|
|
289
|
+
});
|
|
290
|
+
executionContextFingerprint = contextFingerprint;
|
|
291
|
+
runCommandRuntime = new RunCommandRuntimeV3({
|
|
292
|
+
config,
|
|
293
|
+
fullAccessProfile,
|
|
294
|
+
hostRuntime: windowsProcessHostRuntime,
|
|
295
|
+
contextFingerprint,
|
|
296
|
+
policyRevision: () => inspection.policyRevision,
|
|
297
|
+
evidenceRevision: () => inspection.evidenceRevision
|
|
298
|
+
});
|
|
299
|
+
dependencies.toolResourceResolver = runCommandRuntime;
|
|
300
|
+
const result = (structured) => ({
|
|
301
|
+
content: [{ type: "text", text: structured.ok === true ? "Command completed." : "Command failed." }],
|
|
302
|
+
structuredContent: structured,
|
|
303
|
+
...(structured.ok === false ? { isError: true } : {})
|
|
304
|
+
});
|
|
305
|
+
dependencies.v3ToolHandlers = {
|
|
306
|
+
run_command: async (args) => result(await runCommandRuntime.runCommand(args)),
|
|
307
|
+
read_process_output: async (args) => result(runCommandRuntime.readProcessOutput(args))
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
if (options.rootAdmissionRuntimeV3) {
|
|
311
|
+
localApprovalRuntimeV3.setApprovalPreparation((record) => options.rootAdmissionRuntimeV3.prepareApproval(record), (record) => options.rootAdmissionRuntimeV3.approvalDisplay(record));
|
|
312
|
+
}
|
|
313
|
+
if (durableAudit) {
|
|
314
|
+
auditStore = PersistentAuditStore.open({
|
|
315
|
+
stateRoot,
|
|
316
|
+
registry,
|
|
317
|
+
retention: config.auditRetention
|
|
318
|
+
});
|
|
319
|
+
requireAuditReady(auditStore);
|
|
320
|
+
if (automaticLocalApproval && !localApprovalRuntimeV3) {
|
|
321
|
+
localApprovalRuntimeV3 = LocalApprovalRuntimeV3.create({
|
|
322
|
+
auditStore,
|
|
323
|
+
stateBaseRoot: stateRoot,
|
|
324
|
+
startNativeControl: false
|
|
325
|
+
});
|
|
326
|
+
ownsLocalApprovalRuntimeV3 = true;
|
|
327
|
+
dependencies.localApprovalRuntimeV3 = localApprovalRuntimeV3;
|
|
328
|
+
automaticGitStartup = localApprovalRuntimeV3.activateNativeControl(stateRoot);
|
|
329
|
+
}
|
|
330
|
+
auditRuntime = new PersistentAuditRuntimeV2(auditStore);
|
|
331
|
+
dependencies.persistentAuditRuntime = auditRuntime;
|
|
332
|
+
dependencies.auditQueryHandler = createAuditQueryHandler(auditStore);
|
|
333
|
+
dependencies.auditQueryHandlerV3 = createAuditQueryHandlerV3(auditStore);
|
|
334
|
+
if (runCommandRuntime && windowsProcessHostRuntime && executionContextFingerprint && executionInspection) {
|
|
335
|
+
const digest = (value) => semanticDigest(value).replace(/^sha256:/, "");
|
|
336
|
+
processManager = new ProcessManagerV3({
|
|
337
|
+
contextFingerprint: executionContextFingerprint,
|
|
338
|
+
startResourceResolver: runCommandRuntime,
|
|
339
|
+
executionRuntime: runCommandRuntime,
|
|
340
|
+
backend: new WindowsPersistentProcessBackendV3({
|
|
341
|
+
hostRuntime: windowsProcessHostRuntime,
|
|
342
|
+
executionRuntime: runCommandRuntime
|
|
343
|
+
}),
|
|
344
|
+
audit: new ProcessAuditCoordinatorV3({
|
|
345
|
+
sink: async (event) => {
|
|
346
|
+
await auditStore.append(event);
|
|
347
|
+
return { eventId: event.eventId, timestamp: event.timestamp };
|
|
348
|
+
},
|
|
349
|
+
context: () => {
|
|
350
|
+
const identity = currentPolicyIdentity(options.policySessionContextSource);
|
|
351
|
+
return {
|
|
352
|
+
credentialRef: identity.credentialRef,
|
|
353
|
+
transportSessionId: options.policySessionContextSource.transportSessionId(),
|
|
354
|
+
policyRevision: executionInspection.policyRevision,
|
|
355
|
+
subjectFingerprint: digest(policyIdentityOwnershipFacts(identity)),
|
|
356
|
+
contextFingerprint: digest({
|
|
357
|
+
serverId: localApprovalRuntimeV3?.serverId ?? "local-server-unavailable",
|
|
358
|
+
contractVersion: 3,
|
|
359
|
+
policyRevision: executionInspection.policyRevision,
|
|
360
|
+
evidenceRevision: executionInspection.evidenceRevision,
|
|
361
|
+
transportKind: options.policySessionContextSource.transportKind,
|
|
362
|
+
transportSessionId: options.policySessionContextSource.transportSessionId(),
|
|
363
|
+
identity: policyIdentityOwnershipFacts(identity)
|
|
364
|
+
})
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
})
|
|
368
|
+
});
|
|
369
|
+
const manager = processManager;
|
|
370
|
+
dependencies.toolResourceResolver = {
|
|
371
|
+
describe(toolName, args) {
|
|
372
|
+
if (toolName === "run_command")
|
|
373
|
+
return runCommandRuntime.describe(toolName, args);
|
|
374
|
+
if (toolName === "start_process")
|
|
375
|
+
return manager.describe(toolName, args);
|
|
376
|
+
if (toolName === "read_process_output" && !manager.owns(String(args.process_id ?? "")))
|
|
377
|
+
return runCommandRuntime.describe(toolName, args);
|
|
378
|
+
return manager.describe(toolName, args);
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
const result = (structured) => ({
|
|
382
|
+
content: [{ type: "text", text: structured.ok === true ? "Process action completed." : "Process action failed." }],
|
|
383
|
+
structuredContent: structured,
|
|
384
|
+
...(structured.ok === false ? { isError: true } : {})
|
|
385
|
+
});
|
|
386
|
+
dependencies.v3ToolHandlers = {
|
|
387
|
+
...dependencies.v3ToolHandlers,
|
|
388
|
+
start_process: async (args) => result(await manager.start(args)),
|
|
389
|
+
read_process_output: async (args) => {
|
|
390
|
+
const processId = String(args.process_id ?? "");
|
|
391
|
+
if (manager.owns(processId))
|
|
392
|
+
return result(manager.read(processId, typeof args.cursor === "string" ? args.cursor : undefined, typeof args.max_bytes === "number" ? args.max_bytes : undefined));
|
|
393
|
+
return result(runCommandRuntime.readProcessOutput(args));
|
|
394
|
+
},
|
|
395
|
+
write_process_input: async (args) => result(await manager.writeResult(args)),
|
|
396
|
+
interrupt_process: async (args) => result(await manager.interruptResult(args)),
|
|
397
|
+
terminate_process: async (args) => result(await manager.terminateResult(args)),
|
|
398
|
+
resize_process_terminal: async (args) => result(await manager.resizeResult(args)),
|
|
399
|
+
list_processes: async () => result(manager.list())
|
|
400
|
+
};
|
|
401
|
+
localApprovalRuntimeV3?.setProcessControl(manager.localControl());
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
if (options.gitBootstrapV4) {
|
|
405
|
+
if (!auditStore || !options.policySessionContextSource) {
|
|
406
|
+
throw new Error("Automatic Contract V4 Git composition requires durable audit and stable session identity.");
|
|
407
|
+
}
|
|
408
|
+
const bootstrap = options.gitBootstrapV4;
|
|
409
|
+
const gitIdentity = currentPolicyIdentity(options.policySessionContextSource);
|
|
410
|
+
const oauthIdentity = gitIdentity.schemaVersion === 2 && gitIdentity.kind === "oauth_subject";
|
|
411
|
+
const stableOwnerId = ownerIdForPolicyIdentity(gitIdentity);
|
|
412
|
+
const contextFingerprint = semanticDigest(oauthIdentity ? {
|
|
413
|
+
serverId: localApprovalRuntimeV3?.serverId ?? "local-server-unavailable",
|
|
414
|
+
contractVersion: 4,
|
|
415
|
+
transportKind: options.policySessionContextSource.transportKind,
|
|
416
|
+
transportSessionId: options.policySessionContextSource.transportSessionId(),
|
|
417
|
+
ownerId: stableOwnerId
|
|
418
|
+
} : {
|
|
419
|
+
serverId: localApprovalRuntimeV3?.serverId ?? "local-server-unavailable",
|
|
420
|
+
contractVersion: 4,
|
|
421
|
+
transportKind: options.policySessionContextSource.transportKind,
|
|
422
|
+
transportSessionId: options.policySessionContextSource.transportSessionId(),
|
|
423
|
+
identity: gitIdentity
|
|
424
|
+
}).replace(/^sha256:/u, "");
|
|
425
|
+
const ownerFingerprint = semanticDigest(oauthIdentity ? {
|
|
426
|
+
ownerBindingVersion: 1,
|
|
427
|
+
ownerId: stableOwnerId
|
|
428
|
+
} : {
|
|
429
|
+
ownerBindingVersion: 1,
|
|
430
|
+
credentialRef: gitIdentity.credentialRef
|
|
431
|
+
}).replace(/^sha256:/u, "");
|
|
432
|
+
automaticGitRegistry = new RepositoryIdentityRegistry({ contextFingerprint });
|
|
433
|
+
automaticGitStateTokens = new GitStateTokenService({
|
|
434
|
+
key: deriveTransactionSubkey(masterKey, "git-v4-state-token"),
|
|
435
|
+
ttlMs: 5 * 60_000
|
|
436
|
+
});
|
|
437
|
+
if (config.gitMode === "local") {
|
|
438
|
+
automaticGitReviews = new GitReviewTokenServiceV4({
|
|
439
|
+
key: deriveTransactionSubkey(masterKey, "git-v4-review-token"),
|
|
440
|
+
stateRoot,
|
|
441
|
+
masterKey
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
const integrationGate = automaticGitReviews
|
|
445
|
+
? new GitIntegrationGateV4({
|
|
446
|
+
executor: bootstrap.executor,
|
|
447
|
+
reviews: automaticGitReviews,
|
|
448
|
+
enabled: config.gitIntegrations === "approved_full_access"
|
|
449
|
+
})
|
|
450
|
+
: undefined;
|
|
451
|
+
const gitAdmission = new GitRepositoryAdmissionV4({
|
|
452
|
+
executor: bootstrap.executor,
|
|
453
|
+
registry: automaticGitRegistry
|
|
454
|
+
});
|
|
455
|
+
const readService = new ConcreteGitReadServiceV4({
|
|
456
|
+
executor: bootstrap.executor,
|
|
457
|
+
registry: automaticGitRegistry,
|
|
458
|
+
stateTokens: automaticGitStateTokens,
|
|
459
|
+
contextFingerprint,
|
|
460
|
+
integrationGate,
|
|
461
|
+
admission: gitAdmission
|
|
462
|
+
});
|
|
463
|
+
dependencies.gitReadServiceV4 = readService;
|
|
464
|
+
dependencies.v4ContractCapabilities = {
|
|
465
|
+
nativeHostIdentityAvailable: true,
|
|
466
|
+
localApprovalAvailable: Boolean(localApprovalRuntimeV3) || automaticLocalApproval,
|
|
467
|
+
gitCapabilityAvailable: true,
|
|
468
|
+
contractV4MigrationAvailable: true
|
|
469
|
+
};
|
|
470
|
+
if (config.gitMode === "local") {
|
|
471
|
+
if (!bootstrap.managedRoot)
|
|
472
|
+
throw new Error("Local Contract V4 Git mode requires an admitted managed task root.");
|
|
473
|
+
automaticGitRepositoryStore = new GitRepositoryStore({ stateRoot, masterKey });
|
|
474
|
+
automaticGitOperationStore = new GitOperationStore({ stateRoot, masterKey });
|
|
475
|
+
const gitLocks = new GitLockManager({ stateRoot, registry });
|
|
476
|
+
const mergeLifecycleLock = new WorkspaceMutationLock(stateRoot, registry);
|
|
477
|
+
const gitRecovery = new GitRecoveryCoordinator({
|
|
478
|
+
operationStore: automaticGitOperationStore,
|
|
479
|
+
repositoryStore: automaticGitRepositoryStore,
|
|
480
|
+
locks: gitLocks,
|
|
481
|
+
async probeParticipant(operation, participant) {
|
|
482
|
+
if (participant === "audit") {
|
|
483
|
+
return await auditStore.findTerminalEventV4(operation.operationId)
|
|
484
|
+
? "present"
|
|
485
|
+
: "absent";
|
|
486
|
+
}
|
|
487
|
+
// Unknown effects are never guessed away. The repository remains frozen
|
|
488
|
+
// until an exact participant-specific recovery adapter proves state.
|
|
489
|
+
return "unknown";
|
|
490
|
+
},
|
|
491
|
+
resolveTerminalAuditEventId(operation) {
|
|
492
|
+
return auditStore.findTerminalEventV4(operation.operationId);
|
|
493
|
+
},
|
|
494
|
+
async recordRecovery({ operation, outcome, resultCode }) {
|
|
495
|
+
await auditStore.append(createRecoveryAuditEventV4({
|
|
496
|
+
timestamp: new Date().toISOString(),
|
|
497
|
+
requestId: operation.requestId,
|
|
498
|
+
authorizationEventId: operation.authorizationEventId,
|
|
499
|
+
decisionId: null,
|
|
500
|
+
toolName: operation.toolName,
|
|
501
|
+
canonicalAction: operation.canonicalAction,
|
|
502
|
+
workspaceId: null,
|
|
503
|
+
policyRevision: operation.policyRevision,
|
|
504
|
+
subjectFingerprint: operation.subjectFingerprint,
|
|
505
|
+
contextFingerprint: operation.contextFingerprint,
|
|
506
|
+
resultCode,
|
|
507
|
+
counts: operation.counts,
|
|
508
|
+
repositoryId: operation.repositoryId,
|
|
509
|
+
taskWorktreeId: null,
|
|
510
|
+
operationId: operation.operationId,
|
|
511
|
+
recoveryAction: outcome === "committed"
|
|
512
|
+
? "committed"
|
|
513
|
+
: outcome === "rolled_back"
|
|
514
|
+
? "rolled_back"
|
|
515
|
+
: "repository_frozen"
|
|
516
|
+
}));
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
const gateR = new ConcreteGitGateRRuntimeV4({
|
|
520
|
+
recovery: gitRecovery,
|
|
521
|
+
operationStore: automaticGitOperationStore,
|
|
522
|
+
repositoryStore: automaticGitRepositoryStore,
|
|
523
|
+
locks: gitLocks,
|
|
524
|
+
appendAuthorization: (event) => auditStore.append(event),
|
|
525
|
+
appendTerminal: (event) => auditStore.append(event)
|
|
526
|
+
});
|
|
527
|
+
automaticGitGateR = gateR;
|
|
528
|
+
const mutationContext = new GitMutationContextV4({
|
|
529
|
+
executor: bootstrap.executor,
|
|
530
|
+
registry: automaticGitRegistry,
|
|
531
|
+
stateTokens: automaticGitStateTokens,
|
|
532
|
+
readService,
|
|
533
|
+
contextFingerprint,
|
|
534
|
+
admission: gitAdmission
|
|
535
|
+
});
|
|
536
|
+
automaticGitIndexTokens = new GitIndexTokenServiceV4({
|
|
537
|
+
key: deriveTransactionSubkey(masterKey, "git-v4-index-token"),
|
|
538
|
+
ttlMs: 5 * 60_000
|
|
539
|
+
});
|
|
540
|
+
if (!automaticGitReviews)
|
|
541
|
+
throw new Error("Local Contract V4 Git mode requires review tokens.");
|
|
542
|
+
const branch = new GitBranchServiceV4(mutationContext);
|
|
543
|
+
const index = new GitIndexServiceV4(mutationContext, automaticGitIndexTokens, {
|
|
544
|
+
integrationGate
|
|
545
|
+
});
|
|
546
|
+
const commit = new GitCommitServiceV4(mutationContext, automaticGitIndexTokens, {
|
|
547
|
+
integrationGate
|
|
548
|
+
});
|
|
549
|
+
if (!atomicEngine)
|
|
550
|
+
throw new Error("Contract V4 Git mutations require atomic file transactions.");
|
|
551
|
+
const gitFileTransactions = new GitFileTransactionV4(atomicEngine);
|
|
552
|
+
const restore = new GitRestoreServiceV4(mutationContext, automaticGitReviews, gitFileTransactions);
|
|
553
|
+
const stash = new GitStashServiceV4(mutationContext, automaticGitReviews, gitFileTransactions, Date.now, {
|
|
554
|
+
stateRoot,
|
|
555
|
+
masterKey,
|
|
556
|
+
ownerFingerprint: () => ownerFingerprint
|
|
557
|
+
});
|
|
558
|
+
automaticGitStash = stash;
|
|
559
|
+
const journal = new GitMutationJournalV4(gateR, GitMutationJournalV4.configurationRevision({
|
|
560
|
+
contractVersion: 4,
|
|
561
|
+
gitMode: config.gitMode,
|
|
562
|
+
integrations: config.gitIntegrations,
|
|
563
|
+
capabilityRevision: bootstrap.executor.capabilityRevision
|
|
564
|
+
}));
|
|
565
|
+
const mutationService = new GitMutationServiceV4({
|
|
566
|
+
branch,
|
|
567
|
+
index,
|
|
568
|
+
commit,
|
|
569
|
+
restore,
|
|
570
|
+
stash,
|
|
571
|
+
journal,
|
|
572
|
+
integrationGate
|
|
573
|
+
});
|
|
574
|
+
const taskStore = new TaskWorktreeStoreV1({ stateRoot, masterKey });
|
|
575
|
+
const manager = new TaskWorktreeManagerV4({
|
|
576
|
+
context: mutationContext,
|
|
577
|
+
journal,
|
|
578
|
+
reviews: automaticGitReviews,
|
|
579
|
+
root: bootstrap.managedRoot,
|
|
580
|
+
store: taskStore,
|
|
581
|
+
maxTasks: config.taskWorktreeMaxCount,
|
|
582
|
+
maxFiles: config.taskWorktreeMaxFiles,
|
|
583
|
+
maxBytes: config.taskWorktreeMaxBytes
|
|
584
|
+
});
|
|
585
|
+
const owner = () => ownerFingerprint;
|
|
586
|
+
const authority = new TaskWorktreeWorkspaceAuthorityV4({
|
|
587
|
+
manager,
|
|
588
|
+
ownerFingerprint: owner
|
|
589
|
+
});
|
|
590
|
+
gitAdmission.setManagedTaskResolver((workspace) => authority.admitGitWorkspace(workspace));
|
|
591
|
+
automaticGitPlans = new MergePlanStoreV4({
|
|
592
|
+
stateRoot,
|
|
593
|
+
masterKey,
|
|
594
|
+
lifecycleLock: mergeLifecycleLock
|
|
595
|
+
});
|
|
596
|
+
automaticVerificationReceipts = new VerificationReceiptServiceV4(deriveTransactionSubkey(masterKey, "git-v4-verification-receipt"), Date.now, { stateRoot, masterKey });
|
|
597
|
+
automaticCandidateWorkspaces = new CandidateVerificationWorkspaceV4({
|
|
598
|
+
manager,
|
|
599
|
+
guard,
|
|
600
|
+
ownerFingerprint: owner,
|
|
601
|
+
contextFingerprint: () => contextFingerprint,
|
|
602
|
+
verificationReceipts: automaticVerificationReceipts,
|
|
603
|
+
stateRoot,
|
|
604
|
+
masterKey
|
|
605
|
+
});
|
|
606
|
+
runCommandRuntime?.setCandidateVerificationWorkspace(automaticCandidateWorkspaces);
|
|
607
|
+
const mergePrepare = new TaskWorktreeMergePrepareV4({
|
|
608
|
+
manager,
|
|
609
|
+
plans: automaticGitPlans,
|
|
610
|
+
reviews: automaticGitReviews,
|
|
611
|
+
ownerFingerprint: owner,
|
|
612
|
+
integrationGate,
|
|
613
|
+
candidateWorkspaces: automaticCandidateWorkspaces
|
|
614
|
+
});
|
|
615
|
+
const mergeExecute = new TaskWorktreeMergeExecuteV4({
|
|
616
|
+
manager,
|
|
617
|
+
plans: automaticGitPlans,
|
|
618
|
+
ownerFingerprint: owner,
|
|
619
|
+
verificationReceipts: automaticVerificationReceipts,
|
|
620
|
+
fileTransactions: gitFileTransactions,
|
|
621
|
+
integrationGate,
|
|
622
|
+
candidateWorkspaces: automaticCandidateWorkspaces
|
|
623
|
+
});
|
|
624
|
+
const remove = new TaskWorktreeRemoveV4({
|
|
625
|
+
manager,
|
|
626
|
+
authority,
|
|
627
|
+
reviews: automaticGitReviews,
|
|
628
|
+
ownerFingerprint: owner,
|
|
629
|
+
hasActiveProcesses: processManager
|
|
630
|
+
? (root) => processManager.hasActiveProcessInRoot(root)
|
|
631
|
+
: undefined,
|
|
632
|
+
drainActiveProcesses: processManager
|
|
633
|
+
? (root) => processManager.drainActiveProcessesInRoot(root)
|
|
634
|
+
: undefined
|
|
635
|
+
});
|
|
636
|
+
const taskService = new TaskWorktreeServiceV4({
|
|
637
|
+
manager,
|
|
638
|
+
authority,
|
|
639
|
+
ownerFingerprint: owner,
|
|
640
|
+
mergePrepare,
|
|
641
|
+
mergeExecute,
|
|
642
|
+
remove,
|
|
643
|
+
integrationGate
|
|
644
|
+
});
|
|
645
|
+
dependencies.gitMutationServiceV4 = mutationService;
|
|
646
|
+
dependencies.taskWorktreeServiceV4 = taskService;
|
|
647
|
+
dependencies.taskWorktreeAuthorityV4 = authority;
|
|
648
|
+
const mergeRecovery = new TaskWorktreeRecoveryV4({
|
|
649
|
+
manager,
|
|
650
|
+
plans: automaticGitPlans,
|
|
651
|
+
candidateWorkspaces: automaticCandidateWorkspaces,
|
|
652
|
+
verificationReceipts: automaticVerificationReceipts,
|
|
653
|
+
ownerFingerprint: owner,
|
|
654
|
+
async recordRecovery(plan, outcome) {
|
|
655
|
+
const operationDigest = semanticDigest({
|
|
656
|
+
kind: "task_worktree_merge_recovery",
|
|
657
|
+
mergePlanId: plan.mergePlanId
|
|
658
|
+
}).replace(/^sha256:/u, "");
|
|
659
|
+
await auditStore.append(createRecoveryAuditEventV4({
|
|
660
|
+
timestamp: new Date().toISOString(),
|
|
661
|
+
requestId: null,
|
|
662
|
+
authorizationEventId: null,
|
|
663
|
+
decisionId: null,
|
|
664
|
+
toolName: "merge_task_worktree",
|
|
665
|
+
canonicalAction: "task_merge_recovery",
|
|
666
|
+
workspaceId: null,
|
|
667
|
+
policyRevision: plan.policyRevision,
|
|
668
|
+
subjectFingerprint: plan.ownerFingerprint,
|
|
669
|
+
contextFingerprint: plan.contextFingerprint,
|
|
670
|
+
resultCode: outcome === "cleanup_completed"
|
|
671
|
+
? "MERGE_CLEANUP_COMPLETED"
|
|
672
|
+
: outcome === "rolled_back"
|
|
673
|
+
? "MERGE_ROLLED_BACK"
|
|
674
|
+
: "GIT_RECOVERY_REQUIRED",
|
|
675
|
+
counts: {
|
|
676
|
+
affectedPathCount: plan.affectedPathCount,
|
|
677
|
+
affectedByteCount: plan.affectedByteCount
|
|
678
|
+
},
|
|
679
|
+
repositoryId: plan.repositoryId,
|
|
680
|
+
taskWorktreeId: plan.taskWorktreeId,
|
|
681
|
+
operationId: `gop_${operationDigest.slice(0, 32)}`,
|
|
682
|
+
recoveryAction: outcome === "cleanup_completed"
|
|
683
|
+
? "committed"
|
|
684
|
+
: outcome === "rolled_back"
|
|
685
|
+
? "rolled_back"
|
|
686
|
+
: "repository_frozen"
|
|
687
|
+
}));
|
|
688
|
+
}
|
|
689
|
+
});
|
|
690
|
+
automaticGitStartup = automaticGitStartup.then(() => gateR.startupRecovery()).then(async () => {
|
|
691
|
+
if (!gateR.isReady())
|
|
692
|
+
throw new Error("GIT_RECOVERY_REQUIRED");
|
|
693
|
+
const recovered = await mergeRecovery.recover();
|
|
694
|
+
if (recovered.some((result) => result.outcome === "recovery_required")) {
|
|
695
|
+
throw new Error("GIT_RECOVERY_REQUIRED");
|
|
696
|
+
}
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
if (atomic) {
|
|
701
|
+
const engine = atomicEngine;
|
|
702
|
+
changeSetStore = new ChangeSetStore({
|
|
703
|
+
stateRoot,
|
|
704
|
+
masterKey,
|
|
705
|
+
retention: config.changeSetRetention
|
|
706
|
+
});
|
|
707
|
+
moveChangeSetStore = new MoveChangeSetStore({
|
|
708
|
+
stateRoot,
|
|
709
|
+
masterKey,
|
|
710
|
+
activeRetentionMs: config.changeSetRetention.activeRetentionMs
|
|
711
|
+
});
|
|
712
|
+
dependencies.movePathsService = new MovePathsService({
|
|
713
|
+
engine,
|
|
714
|
+
changeSetStore: moveChangeSetStore,
|
|
715
|
+
retentionMs: config.changeSetRetention.activeRetentionMs
|
|
716
|
+
});
|
|
717
|
+
if (auditStore) {
|
|
718
|
+
recovery.setParticipantAdapter(createDurableParticipantRecoveryAdapter({
|
|
719
|
+
auditStore,
|
|
720
|
+
changeSetStore,
|
|
721
|
+
moveChangeSetStore
|
|
722
|
+
}));
|
|
723
|
+
}
|
|
724
|
+
mutationRuntime = new WorkspaceMutationRuntime({
|
|
725
|
+
engine,
|
|
726
|
+
changeSetStore
|
|
727
|
+
});
|
|
728
|
+
ownerBindingKey = deriveTransactionSubkey(masterKey, "change-set-owner");
|
|
729
|
+
dependencies.workspaceMutationRuntime = mutationRuntime;
|
|
730
|
+
dependencies.atomicMutationToolNames = ATOMIC_MUTATION_TOOL_NAMES;
|
|
731
|
+
dependencies.changeSetOwnerBindingKey = ownerBindingKey;
|
|
732
|
+
const v1Undo = new UndoChangeSetService({
|
|
733
|
+
engine,
|
|
734
|
+
changeSetStore,
|
|
735
|
+
guard,
|
|
736
|
+
retentionMs: config.changeSetRetention.activeRetentionMs
|
|
737
|
+
});
|
|
738
|
+
const v2Undo = new MoveUndoChangeSetService({
|
|
739
|
+
engine,
|
|
740
|
+
moveChangeSetStore,
|
|
741
|
+
guard,
|
|
742
|
+
retentionMs: config.changeSetRetention.activeRetentionMs
|
|
743
|
+
});
|
|
744
|
+
dependencies.undoChangeSetService = new UnifiedUndoChangeSetService({
|
|
745
|
+
engine,
|
|
746
|
+
changeSetStore,
|
|
747
|
+
v1: v1Undo,
|
|
748
|
+
v2: v2Undo
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
const observation = {
|
|
752
|
+
atomic,
|
|
753
|
+
durableAudit,
|
|
754
|
+
stateRoot,
|
|
755
|
+
registryInstanceId: registry.record.instanceId,
|
|
756
|
+
mutationRuntime,
|
|
757
|
+
auditRuntime,
|
|
758
|
+
localApprovalServerId: localApprovalRuntimeV3?.serverId ?? null,
|
|
759
|
+
processHostConfigured: windowsProcessHostRuntime !== null,
|
|
760
|
+
gitGateRReady: options.gitGateRRuntimeV4?.isReady() ?? automaticGitGateR?.isReady() ?? false
|
|
761
|
+
};
|
|
762
|
+
let disposePromise = null;
|
|
763
|
+
const disposeResources = async () => {
|
|
764
|
+
let failure;
|
|
765
|
+
try {
|
|
766
|
+
await processManager?.close();
|
|
767
|
+
await options.rootAdmissionRuntimeV3?.close();
|
|
768
|
+
if (ownsLocalApprovalRuntimeV3)
|
|
769
|
+
await localApprovalRuntimeV3?.close();
|
|
770
|
+
runCommandRuntime?.close();
|
|
771
|
+
await Promise.all([
|
|
772
|
+
windowsProcessHostRuntime?.close()
|
|
773
|
+
]);
|
|
774
|
+
await options.gitBootstrapV4?.dispose();
|
|
775
|
+
}
|
|
776
|
+
catch (error) {
|
|
777
|
+
failure = error;
|
|
778
|
+
}
|
|
779
|
+
finally {
|
|
780
|
+
automaticGitPlans?.dispose();
|
|
781
|
+
automaticCandidateWorkspaces?.dispose();
|
|
782
|
+
automaticVerificationReceipts?.dispose();
|
|
783
|
+
automaticGitStash?.dispose();
|
|
784
|
+
automaticGitReviews?.dispose();
|
|
785
|
+
automaticGitIndexTokens?.dispose();
|
|
786
|
+
automaticGitStateTokens?.dispose();
|
|
787
|
+
automaticGitRegistry?.dispose();
|
|
788
|
+
automaticGitOperationStore?.dispose();
|
|
789
|
+
automaticGitRepositoryStore?.dispose();
|
|
790
|
+
auditStore?.dispose();
|
|
791
|
+
changeSetStore?.dispose();
|
|
792
|
+
moveChangeSetStore?.dispose();
|
|
793
|
+
ownerBindingKey?.fill(0);
|
|
794
|
+
recovery?.dispose();
|
|
795
|
+
registry?.dispose();
|
|
796
|
+
if (lifecycle.state() !== "disposed")
|
|
797
|
+
lifecycle.markDisposed();
|
|
798
|
+
}
|
|
799
|
+
if (failure)
|
|
800
|
+
throw failure;
|
|
801
|
+
};
|
|
802
|
+
return {
|
|
803
|
+
dependencies,
|
|
804
|
+
observation,
|
|
805
|
+
lifecycle,
|
|
806
|
+
async startup() {
|
|
807
|
+
await automaticGitStartup;
|
|
808
|
+
await automaticCandidateWorkspaces?.cleanupExpiredReviewedCandidates();
|
|
809
|
+
},
|
|
810
|
+
dispose() {
|
|
811
|
+
if (disposePromise)
|
|
812
|
+
return disposePromise;
|
|
813
|
+
lifecycle.quiesce();
|
|
814
|
+
if (lifecycle.isDrained()) {
|
|
815
|
+
disposePromise = disposeResources();
|
|
816
|
+
return disposePromise;
|
|
817
|
+
}
|
|
818
|
+
disposePromise = lifecycle.drain().then(disposeResources);
|
|
819
|
+
return disposePromise;
|
|
820
|
+
}
|
|
821
|
+
};
|
|
822
|
+
}
|
|
823
|
+
catch (error) {
|
|
824
|
+
auditStore?.dispose();
|
|
825
|
+
changeSetStore?.dispose();
|
|
826
|
+
moveChangeSetStore?.dispose();
|
|
827
|
+
ownerBindingKey?.fill(0);
|
|
828
|
+
recovery?.dispose();
|
|
829
|
+
registry?.dispose();
|
|
830
|
+
void processManager?.close();
|
|
831
|
+
void options.rootAdmissionRuntimeV3?.close();
|
|
832
|
+
if (ownsLocalApprovalRuntimeV3)
|
|
833
|
+
void localApprovalRuntimeV3?.close();
|
|
834
|
+
runCommandRuntime?.close();
|
|
835
|
+
void windowsProcessHostRuntime?.close();
|
|
836
|
+
void options.gitBootstrapV4?.dispose();
|
|
837
|
+
automaticGitPlans?.dispose();
|
|
838
|
+
automaticCandidateWorkspaces?.dispose();
|
|
839
|
+
automaticVerificationReceipts?.dispose();
|
|
840
|
+
automaticGitStash?.dispose();
|
|
841
|
+
automaticGitReviews?.dispose();
|
|
842
|
+
automaticGitIndexTokens?.dispose();
|
|
843
|
+
automaticGitStateTokens?.dispose();
|
|
844
|
+
automaticGitRegistry?.dispose();
|
|
845
|
+
automaticGitOperationStore?.dispose();
|
|
846
|
+
automaticGitRepositoryStore?.dispose();
|
|
847
|
+
throw error;
|
|
848
|
+
}
|
|
849
|
+
finally {
|
|
850
|
+
masterKey.fill(0);
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
const productionDisposers = new WeakMap();
|
|
854
|
+
const productionRuntimes = new WeakMap();
|
|
855
|
+
function installRuntimeDisposal(server, runtime) {
|
|
856
|
+
const originalClose = server.close.bind(server);
|
|
857
|
+
let closePromise = null;
|
|
858
|
+
const disposeOnce = () => {
|
|
859
|
+
if (closePromise)
|
|
860
|
+
return closePromise;
|
|
861
|
+
runtime.lifecycle.quiesce();
|
|
862
|
+
productionDisposers.delete(server);
|
|
863
|
+
productionRuntimes.delete(server);
|
|
864
|
+
closePromise = runtime.dispose();
|
|
865
|
+
return closePromise;
|
|
866
|
+
};
|
|
867
|
+
productionDisposers.set(server, disposeOnce);
|
|
868
|
+
productionRuntimes.set(server, runtime);
|
|
869
|
+
server.close = async () => {
|
|
870
|
+
runtime.lifecycle.quiesce();
|
|
871
|
+
try {
|
|
872
|
+
await originalClose();
|
|
873
|
+
}
|
|
874
|
+
finally {
|
|
875
|
+
await disposeOnce();
|
|
876
|
+
}
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
export async function disposeProductionCodexGPTServer(server) {
|
|
880
|
+
await productionDisposers.get(server)?.();
|
|
881
|
+
}
|
|
882
|
+
export async function connectProductionCodexGPTServer(server, transport) {
|
|
883
|
+
try {
|
|
884
|
+
await productionRuntimes.get(server)?.startup();
|
|
885
|
+
await server.connect(transport);
|
|
886
|
+
}
|
|
887
|
+
catch (error) {
|
|
888
|
+
await disposeProductionCodexGPTServer(server);
|
|
889
|
+
throw error;
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
export function createProductionCodexGPTServer(config, options = {}) {
|
|
893
|
+
const runtime = composeRuntime(config, options);
|
|
894
|
+
try {
|
|
895
|
+
options.observeRuntime?.(runtime.observation);
|
|
896
|
+
const server = createCodexGPTServer(config, runtime.dependencies);
|
|
897
|
+
upgradeCodexGPTSupertool(server, config.toolContractVersion);
|
|
898
|
+
installServerMutationLifecycle(server, runtime.lifecycle);
|
|
899
|
+
installRuntimeDisposal(server, runtime);
|
|
900
|
+
return server;
|
|
901
|
+
}
|
|
902
|
+
catch (error) {
|
|
903
|
+
void runtime.dispose();
|
|
904
|
+
throw error;
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
//# sourceMappingURL=productionRuntime.js.map
|