@taskforcehq/taskforce 0.3.328 → 0.3.330
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Taskforce.module.css +523 -79
- package/dist/TaskforceCore.js +237 -230
- package/dist/annotatedAttachments/AnnotatedAttachmentSessionStore.js +1 -1
- package/dist/cli.js +34 -0
- package/dist/cliCloudTargetGuard.d.ts +5 -0
- package/dist/cliCloudTargetGuard.js +11 -0
- package/dist/components/features/AiProfilesModule.js +3 -5
- package/dist/components/features/AnnotatedAttachmentWorkspace.js +24 -8
- package/dist/components/features/TaskSettings.d.ts +12 -1
- package/dist/components/features/TaskSettings.js +217 -54
- package/dist/components/features/TaskforceAgentsModule.d.ts +1 -2
- package/dist/components/features/TaskforceAgentsModule.js +586 -116
- package/dist/components/features/agentCapabilities/AgentCapabilitiesPrototype.d.ts +1 -1
- package/dist/components/features/agentConnections/AgentConnectionControl.d.ts +15 -0
- package/dist/components/features/agentConnections/AgentConnectionControl.js +125 -0
- package/dist/components/features/agentConnections/ModelConnectionsPanel.d.ts +18 -0
- package/dist/components/features/agentConnections/ModelConnectionsPanel.js +393 -0
- package/dist/components/features/agentConnections/modelConnectionsApi.d.ts +65 -0
- package/dist/components/features/agentConnections/modelConnectionsApi.js +129 -0
- package/dist/components/features/planning/PlanningModule.js +2 -5
- package/dist/components/features/planning/PlanningTaskOrderList.d.ts +1 -1
- package/dist/components/features/planning/PlanningTaskOrderList.js +17 -6
- package/dist/components/features/planning/planningTaskArrangement.d.ts +1 -0
- package/dist/components/features/planning/planningTaskArrangement.js +5 -5
- package/dist/components/features/taskforceAgentAssignments/AgentBehaviorAssignments.js +15 -24
- package/dist/components/features/taskforceAgentEditorModel.d.ts +2 -1
- package/dist/components/features/taskforceAgentEditorModel.js +5 -1
- package/dist/components/features/workflowManager/workflowManagerApi.d.ts +1 -1
- package/dist/components/features/workflowManager/workflowManagerApi.js +3 -0
- package/dist/components/task/TaskCard.d.ts +5 -0
- package/dist/components/task/TaskCard.js +65 -10
- package/dist/components/task/TaskImageReviews.js +14 -5
- package/dist/components/task/TaskKanban.d.ts +6 -1
- package/dist/components/task/TaskKanban.js +152 -6
- package/dist/components/task/TaskList.d.ts +5 -0
- package/dist/components/task/TaskList.js +3 -3
- package/dist/components/task/TaskWorkflowAssignmentField.js +68 -10
- package/dist/components/ui/PasswordInput.d.ts +6 -0
- package/dist/components/ui/PasswordInput.js +11 -0
- package/dist/components/ui/TopNoticeLayer.js +1 -1
- package/dist/components/views/AppShellHeader.js +32 -11
- package/dist/components/views/PlanComparisonPage.js +12 -0
- package/dist/components/views/StandaloneLayout.js +32 -55
- package/dist/components/views/WidgetView.js +3 -3
- package/dist/components/views/panels/PlanningDrawer.js +5 -12
- package/dist/components/views/standalone/modals/AccountSettingsModal.js +26 -17
- package/dist/components/views/standalone/modals/SyncStatusModal.d.ts +4 -3
- package/dist/components/views/standalone/modals/SyncStatusModal.js +33 -38
- package/dist/config/envSchema.js +60 -1
- package/dist/config/localServiceRuntimeContract.d.ts +13 -0
- package/dist/config/localServiceRuntimeContract.js +135 -0
- package/dist/core/AiProfileService.js +46 -8
- package/dist/core/DeletedTaskLifecycleService.d.ts +1 -0
- package/dist/core/DeletedTaskLifecycleService.js +37 -6
- package/dist/core/McpTokenService.d.ts +23 -1
- package/dist/core/McpTokenService.js +93 -10
- package/dist/core/TaskAttachmentLinksDurableMutationService.d.ts +3 -2
- package/dist/core/TaskAttachmentLinksDurableMutationService.js +33 -9
- package/dist/core/TaskChecklistCommandService.d.ts +27 -0
- package/dist/core/TaskChecklistCommandService.js +83 -5
- package/dist/core/TaskLifecycleCommandService.d.ts +3 -1
- package/dist/core/TaskLifecycleCommandService.js +6 -2
- package/dist/core/Taskforce.d.ts +94 -2
- package/dist/core/Taskforce.js +760 -36
- package/dist/core/types.d.ts +14 -0
- package/dist/documentReviews/commandService.d.ts +2 -1
- package/dist/documentReviews/commandService.js +6 -3
- package/dist/hooks/sync/orchestratorShared.d.ts +1 -0
- package/dist/hooks/sync/orchestratorShared.js +2 -0
- package/dist/hooks/sync/useDurableLocalOutboxDrain.d.ts +1 -1
- package/dist/hooks/sync/useDurableTaskCreateMutation.js +1 -1
- package/dist/hooks/sync/useDurableTaskMetadataMutation.d.ts +1 -0
- package/dist/hooks/sync/useDurableTaskMetadataMutation.js +1 -0
- package/dist/hooks/sync/useDurableTaskStatusMutation.d.ts +1 -0
- package/dist/hooks/sync/useLocalSyncCoordinatorSnapshot.d.ts +3 -0
- package/dist/hooks/sync/useLocalSyncCoordinatorSnapshot.js +85 -9
- package/dist/hooks/sync/useSyncStatusControls.d.ts +4 -1
- package/dist/hooks/sync/useSyncStatusControls.js +47 -11
- package/dist/hooks/tasks/taskHttpMutation.js +1 -0
- package/dist/hooks/tasks/useCloudTaskSearch.d.ts +12 -0
- package/dist/hooks/tasks/useCloudTaskSearch.js +71 -0
- package/dist/hooks/tasks/useTaskDescriptionImageDraftRecovery.d.ts +16 -0
- package/dist/hooks/tasks/useTaskDescriptionImageDraftRecovery.js +197 -0
- package/dist/hooks/tasks/useTaskEditorNavigation.d.ts +16 -3
- package/dist/hooks/tasks/useTaskEditorNavigation.js +72 -13
- package/dist/hooks/tasks/useTaskFormActions.d.ts +6 -0
- package/dist/hooks/tasks/useTaskFormActions.js +65 -12
- package/dist/hooks/ui/useSettingsModel.d.ts +24 -2
- package/dist/hooks/ui/useSettingsModel.js +13 -2
- package/dist/hooks/ui/useSettingsPersistence.d.ts +12 -1
- package/dist/hooks/ui/useSettingsPersistence.js +74 -47
- package/dist/hooks/useFilterSort.d.ts +7 -3
- package/dist/hooks/useFilterSort.js +15 -5
- package/dist/hooks/useSyncOrchestrator.d.ts +3 -0
- package/dist/hooks/useSyncOrchestrator.js +111 -2
- package/dist/hooks/useTaskData.d.ts +40 -1
- package/dist/hooks/useTaskData.js +240 -9
- package/dist/hooks/useTaskMutations.d.ts +12 -2
- package/dist/hooks/useTaskMutations.js +266 -52
- package/dist/hooks/useTaskforce.d.ts +39 -9
- package/dist/hooks/useTaskforce.js +359 -40
- package/dist/hooks/useUiNotice.d.ts +4 -0
- package/dist/hooks/useUiNotice.js +4 -0
- package/dist/mcp/adminWorkspaceRegistrar.js +3 -3
- package/dist/mcp/clientRegistry.d.ts +2 -2
- package/dist/mcp/clientRegistry.js +1 -1
- package/dist/mcp/documentAssetRegistrar.js +53 -41
- package/dist/mcp/documentHelpers.d.ts +1 -0
- package/dist/mcp/documentHelpers.js +7 -3
- package/dist/mcp/durableTaskMutationRouter.d.ts +4 -1
- package/dist/mcp/durableTaskMutationRouter.js +10 -0
- package/dist/mcp/durableTaskRelationshipMutationRouter.js +4 -0
- package/dist/mcp/httpProtocolRouting.d.ts +10 -0
- package/dist/mcp/httpProtocolRouting.js +19 -0
- package/dist/mcp/localCliHealth.d.ts +2 -2
- package/dist/mcp/localCliHealth.js +2 -2
- package/dist/mcp/localServiceProxy.d.ts +1 -0
- package/dist/mcp/localServiceProxy.js +530 -68
- package/dist/mcp/planningAttachmentCommandAdapter.d.ts +3 -1
- package/dist/mcp/planningAttachmentCommandAdapter.js +20 -2
- package/dist/mcp/runtime.d.ts +54 -79
- package/dist/mcp/runtime.js +556 -139
- package/dist/mcp/taskPlanningRegistrar.js +64 -42
- package/dist/mcp/toolCallCompatibility.js +38 -1
- package/dist/mcp/toolCatalog.d.ts +1 -0
- package/dist/mcp/toolProfiles.d.ts +2 -0
- package/dist/mcp/toolProfiles.js +10 -0
- package/dist/mcp/toolRegistry.d.ts +1 -0
- package/dist/mcp/toolRegistry.js +1 -0
- package/dist/mcp/workflowExecutionRegistrar.js +4 -4
- package/dist/migrations/taskSchemaMigrations.d.ts +5 -0
- package/dist/migrations/taskSchemaMigrations.js +427 -0
- package/dist/runtime/appGateDefinitions.d.ts +30 -6
- package/dist/runtime/appGateDefinitions.js +6 -6
- package/dist/runtime/appGates.d.ts +13 -13
- package/dist/runtime/appGates.js +36 -13
- package/dist/runtime/nodeAppGates.d.ts +8 -0
- package/dist/runtime/nodeAppGates.js +27 -0
- package/dist/server/cloudCollectionRead.d.ts +1 -1
- package/dist/server/cloudCollectionRead.js +2 -2
- package/dist/server/index.d.ts +6 -0
- package/dist/server/index.js +123 -14
- package/dist/server/localDatabaseIdentity.js +4 -1
- package/dist/server/localServiceLease.d.ts +3 -0
- package/dist/server/localServiceLease.js +11 -2
- package/dist/server/localServiceSessions.d.ts +14 -17
- package/dist/server/localServiceSessions.js +308 -94
- package/dist/server/localWorkspaceSyncServerRuntime.js +12 -7
- package/dist/server/rateLimit.d.ts +1 -0
- package/dist/server/rateLimit.js +4 -0
- package/dist/server/realtimeSyncWs.js +36 -12
- package/dist/server/routes/admin.d.ts +4 -0
- package/dist/server/routes/admin.js +113 -3
- package/dist/server/routes/agentRoles.js +3 -2
- package/dist/server/routes/agentSkills.js +3 -2
- package/dist/server/routes/agents.d.ts +7 -0
- package/dist/server/routes/agents.js +394 -39
- package/dist/server/routes/annotatedAttachments.js +3 -2
- package/dist/server/routes/auth.js +3 -1
- package/dist/server/routes/billing.js +5 -1
- package/dist/server/routes/durableTaskHttpRouters.d.ts +11 -2
- package/dist/server/routes/executorPhaseAApprovals.d.ts +19 -0
- package/dist/server/routes/executorPhaseAApprovals.js +140 -0
- package/dist/server/routes/executorPhaseAIssuerRedemptions.d.ts +11 -0
- package/dist/server/routes/executorPhaseAIssuerRedemptions.js +24 -0
- package/dist/server/routes/githubReviewEvidence.d.ts +19 -0
- package/dist/server/routes/githubReviewEvidence.js +116 -0
- package/dist/server/routes/localService.d.ts +15 -4
- package/dist/server/routes/localService.js +138 -40
- package/dist/server/routes/modelConnections.d.ts +24 -0
- package/dist/server/routes/modelConnections.js +205 -0
- package/dist/server/routes/primitives.d.ts +2 -0
- package/dist/server/routes/shared.d.ts +19 -0
- package/dist/server/routes/shared.js +95 -19
- package/dist/server/routes/sync.js +1 -0
- package/dist/server/routes/syncAuxRoutes.js +9 -2
- package/dist/server/routes/syncPullApplyRoutes.js +23 -4
- package/dist/server/routes/syncPushRoutes.d.ts +1 -0
- package/dist/server/routes/syncPushRoutes.js +1 -0
- package/dist/server/routes/syncV3FeedRoutes.js +27 -16
- package/dist/server/routes/syncV3LocalCaptureRoutes.js +28 -2
- package/dist/server/routes/syncV3LocalFeedApplyRoutes.d.ts +1 -0
- package/dist/server/routes/syncV3LocalFeedApplyRoutes.js +26 -0
- package/dist/server/routes/syncV3OperationRoutes.js +45 -9
- package/dist/server/routes/tasks.js +124 -13
- package/dist/server/routes/workflows.js +9 -1
- package/dist/server/routes/workspaces.js +43 -1
- package/dist/server/routes.js +59 -0
- package/dist/server/workspaceDeletionAdmission.d.ts +23 -0
- package/dist/server/workspaceDeletionAdmission.js +50 -0
- package/dist/service/localServiceCli.js +16 -0
- package/dist/service/localServiceClientLifecycle.js +36 -10
- package/dist/services/codexAppServerModelGateway.d.ts +161 -0
- package/dist/services/codexAppServerModelGateway.js +663 -0
- package/dist/services/codexDeviceCodeLoginManager.d.ts +39 -0
- package/dist/services/codexDeviceCodeLoginManager.js +265 -0
- package/dist/services/codexModelProviderConnectionLifecycle.d.ts +8 -0
- package/dist/services/codexModelProviderConnectionLifecycle.js +73 -0
- package/dist/services/executorPhaseAApprovalRuntime.d.ts +14 -0
- package/dist/services/executorPhaseAApprovalRuntime.js +24 -0
- package/dist/services/executorPhaseAApprovalService.d.ts +40 -0
- package/dist/services/executorPhaseAApprovalService.js +609 -0
- package/dist/services/executorPhaseADriftEvaluator.d.ts +78 -0
- package/dist/services/executorPhaseADriftEvaluator.js +93 -0
- package/dist/services/executorPhaseAIssuerCore.d.ts +126 -0
- package/dist/services/executorPhaseAIssuerCore.js +295 -0
- package/dist/services/executorPhaseAIssuerRedemptionService.d.ts +34 -0
- package/dist/services/executorPhaseAIssuerRedemptionService.js +158 -0
- package/dist/services/githubReviewEvidenceRuntime.d.ts +14 -0
- package/dist/services/githubReviewEvidenceRuntime.js +30 -0
- package/dist/services/githubReviewEvidenceService.d.ts +93 -0
- package/dist/services/githubReviewEvidenceService.js +336 -0
- package/dist/services/modelGateway.d.ts +7 -0
- package/dist/services/modelProviderConnectionService.d.ts +71 -0
- package/dist/services/modelProviderConnectionService.js +279 -0
- package/dist/services/modelProviderCredentialHome.d.ts +32 -0
- package/dist/services/modelProviderCredentialHome.js +271 -0
- package/dist/services/ownerScopedModelConnectionGateway.d.ts +12 -0
- package/dist/services/ownerScopedModelConnectionGateway.js +30 -0
- package/dist/services/taskforceAgentConnectionBindingService.d.ts +66 -0
- package/dist/services/taskforceAgentConnectionBindingService.js +185 -0
- package/dist/services/taskforceAgentMcpBridge.d.ts +8 -2
- package/dist/services/taskforceAgentMcpBridge.js +30 -27
- package/dist/shared/adminEdgeProxy.d.ts +5 -0
- package/dist/shared/adminEdgeProxy.js +94 -0
- package/dist/shared/adminProxySessionCookies.d.ts +16 -0
- package/dist/shared/adminProxySessionCookies.js +86 -0
- package/dist/shared/aiProfileColors.d.ts +31 -1
- package/dist/shared/aiProfileColors.js +14 -6
- package/dist/shared/executorPhaseAApprovalGoldenVector.json +269 -0
- package/dist/shared/executorPhaseAApprovalReceipt.d.ts +112 -0
- package/dist/shared/executorPhaseAApprovalReceipt.js +58 -0
- package/dist/shared/executorPhaseAApprovalTrustPolicy.json +10 -0
- package/dist/shared/executorPhaseADriftContracts.d.ts +37 -0
- package/dist/shared/executorPhaseADriftContracts.js +63 -0
- package/dist/shared/executorPhaseAIssuerContracts.d.ts +75 -0
- package/dist/shared/executorPhaseAIssuerContracts.js +90 -0
- package/dist/shared/executorPhaseARunAuthorization.d.ts +120 -0
- package/dist/shared/executorPhaseARunAuthorization.js +232 -0
- package/dist/shared/executorPhaseASchemaValidation.d.ts +7 -0
- package/dist/shared/executorPhaseASchemaValidation.js +53 -0
- package/dist/shared/executorPhaseASchemas/approval-receipt.schema.json +106 -0
- package/dist/shared/executorPhaseASchemas/drift-attestation.schema.json +54 -0
- package/dist/shared/executorPhaseASchemas/drift-request.schema.json +47 -0
- package/dist/shared/executorPhaseASchemas/foundation-manifest.schema.json +29 -0
- package/dist/shared/executorPhaseASchemas/issuer-audit-record.schema.json +24 -0
- package/dist/shared/executorPhaseASchemas/issuer-proof.schema.json +43 -0
- package/dist/shared/executorPhaseASchemas/issuer-redemption-request.schema.json +18 -0
- package/dist/shared/executorPhaseASchemas/issuer-redemption-response.schema.json +39 -0
- package/dist/shared/executorPhaseASchemas/logical-envelope.schema.json +149 -0
- package/dist/shared/executorPhaseASchemas/preflight-report.schema.json +216 -0
- package/dist/shared/executorPhaseASchemas/run-capability.schema.json +111 -0
- package/dist/shared/executorPhaseASchemas/sender-proof.schema.json +37 -0
- package/dist/shared/executorPhaseASchemas/workload-grant.schema.json +68 -0
- package/dist/shared/executorPhaseASchemas/workload-jwt-claims.schema.json +67 -0
- package/dist/shared/executorPhaseATiming.d.ts +1 -0
- package/dist/shared/executorPhaseATiming.js +1 -0
- package/dist/shared/planningIdentity.js +1 -1
- package/dist/shared/productLogoKeys.d.ts +2 -0
- package/dist/shared/productLogoKeys.js +18 -0
- package/dist/shared/taskforceAgentDefinition.d.ts +0 -1
- package/dist/shared/taskforceAgentDefinition.js +6 -3
- package/dist/shared/taskforceAgentModels.d.ts +1 -0
- package/dist/shared/taskforceAgentModels.js +36 -3
- package/dist/shared/userFeatureGrants.d.ts +4 -0
- package/dist/shared/userFeatureGrants.js +7 -0
- package/dist/storage/executorPhaseAApprovalReceiptStore.d.ts +37 -0
- package/dist/storage/executorPhaseAApprovalReceiptStore.js +81 -0
- package/dist/storage/executorPhaseARunAuthorizationStore.d.ts +103 -0
- package/dist/storage/executorPhaseARunAuthorizationStore.js +492 -0
- package/dist/storage/githubReviewEvidenceInstallationStore.d.ts +26 -0
- package/dist/storage/githubReviewEvidenceInstallationStore.js +89 -0
- package/dist/storage/modelProviderConnectionStore.d.ts +99 -0
- package/dist/storage/modelProviderConnectionStore.js +446 -0
- package/dist/storage/postgresAdapter.d.ts +24 -3
- package/dist/storage/postgresAdapter.js +117 -14
- package/dist/storage/postgresWorker.js +22 -5
- package/dist/storage/postgresWorkerProtocol.d.ts +30 -0
- package/dist/storage/postgresWorkerProtocol.js +30 -0
- package/dist/storage/taskforceAgentConnectionBindingStore.d.ts +31 -0
- package/dist/storage/taskforceAgentConnectionBindingStore.js +84 -0
- package/dist/sync/cloudSyncApi.d.ts +4 -1
- package/dist/sync/cloudSyncApi.js +7 -2
- package/dist/sync/contentSyncState.d.ts +1 -1
- package/dist/sync/coordinator/localSyncExecutionPermitStore.d.ts +1 -0
- package/dist/sync/coordinator/localSyncExecutionPermitStore.js +67 -30
- package/dist/sync/coordinator/localWorkspaceSyncPendingV2PushProgress.d.ts +10 -0
- package/dist/sync/coordinator/localWorkspaceSyncPendingV2PushProgress.js +29 -0
- package/dist/sync/coordinator/localWorkspaceSyncRunner.js +6 -2
- package/dist/sync/coordinator/localWorkspaceSyncRunnerState.d.ts +15 -1
- package/dist/sync/coordinator/localWorkspaceSyncRunnerState.js +99 -2
- package/dist/sync/coordinator/workspaceSyncCredentialBroker.d.ts +1 -0
- package/dist/sync/coordinator/workspaceSyncCredentialBroker.js +33 -4
- package/dist/sync/engine/workspaceSyncContentLifecycleAdapter.d.ts +2 -1
- package/dist/sync/engine/workspaceSyncContentVersionStore.d.ts +38 -0
- package/dist/sync/engine/workspaceSyncContentVersionStore.js +50 -1
- package/dist/sync/engine/workspaceSyncEngineBrowserGatewayRemoteServices.js +20 -2
- package/dist/sync/engine/workspaceSyncEngineLifecyclePolicy.js +6 -6
- package/dist/sync/engine/workspaceSyncEngineLocalServices.d.ts +4 -0
- package/dist/sync/engine/workspaceSyncEngineLocalServices.js +11 -0
- package/dist/sync/engine/workspaceSyncEnginePushCompletion.d.ts +14 -0
- package/dist/sync/engine/workspaceSyncEnginePushCompletion.js +84 -0
- package/dist/sync/engine/workspaceSyncEngineRecovery.js +1 -0
- package/dist/sync/engine/workspaceSyncEngineRemoteServices.d.ts +11 -0
- package/dist/sync/engine/workspaceSyncEngineRemoteServices.js +2 -1
- package/dist/sync/engine/workspaceSyncEngineRuntime.d.ts +1 -0
- package/dist/sync/engine/workspaceSyncEngineRuntime.js +1 -0
- package/dist/sync/engine/workspaceSyncEngineServerRemoteServices.js +31 -4
- package/dist/sync/engine/workspaceSyncEngineServerRunnerOperations.d.ts +3 -1
- package/dist/sync/engine/workspaceSyncEngineServerRunnerOperations.js +134 -43
- package/dist/sync/engine/workspaceSyncEngineServerSnapshotReader.js +6 -0
- package/dist/sync/engine/workspaceSyncEngineTransfers.d.ts +1 -1
- package/dist/sync/engine/workspaceSyncEngineTransfers.js +11 -4
- package/dist/sync/engine/workspaceSyncV2ChangeDispatcher.d.ts +1 -0
- package/dist/sync/engine/workspaceSyncV2ChangeDispatcher.js +29 -0
- package/dist/sync/syncApplyHandlers.d.ts +2 -0
- package/dist/sync/syncApplyHandlers.js +10 -1
- package/dist/sync/syncService.d.ts +17 -0
- package/dist/sync/syncService.js +87 -19
- package/dist/sync/taskforceAgentSyncAuthorization.d.ts +16 -0
- package/dist/sync/taskforceAgentSyncAuthorization.js +20 -0
- package/dist/sync/v3/combinedFeedCapability.js +8 -0
- package/dist/sync/v3/durableInitiativeMutationRouter.js +18 -10
- package/dist/sync/v3/durableOperationReplay.d.ts +14 -0
- package/dist/sync/v3/durableOperationReplay.js +18 -0
- package/dist/sync/v3/durableTaskAttachmentLinksMutationRouter.d.ts +2 -0
- package/dist/sync/v3/durableTaskAttachmentLinksMutationRouter.js +14 -1
- package/dist/sync/v3/durableTaskChecklistMutationRouter.d.ts +4 -1
- package/dist/sync/v3/durableTaskChecklistMutationRouter.js +62 -15
- package/dist/sync/v3/durableTaskCommentMutationRouter.js +3 -0
- package/dist/sync/v3/durableTaskHttpBulkMutationRouter.d.ts +1 -0
- package/dist/sync/v3/durableTaskHttpBulkMutationRouter.js +30 -8
- package/dist/sync/v3/durableTaskHttpRootMutationRouter.d.ts +5 -3
- package/dist/sync/v3/durableTaskHttpRootMutationRouter.js +37 -2
- package/dist/sync/v3/durableTaxonomyMutationRouter.js +5 -0
- package/dist/sync/v3/durableWorkflowRuntimeMutationRouter.d.ts +11 -0
- package/dist/sync/v3/durableWorkflowRuntimeMutationRouter.js +39 -10
- package/dist/sync/v3/durableWorkstreamMutationRouter.js +18 -10
- package/dist/sync/v3/durableWorkstreamTaskOrderMutationRouter.js +16 -5
- package/dist/sync/v3/localOutboxDispatchRuntime.js +2 -2
- package/dist/sync/v3/localTaskAttachmentLinksOutboxService.d.ts +2 -0
- package/dist/sync/v3/localTaskAttachmentLinksOutboxService.js +47 -7
- package/dist/sync/v3/localTaskChecklistOutboxHandler.js +16 -2
- package/dist/sync/v3/localTaskChecklistOutboxService.d.ts +4 -0
- package/dist/sync/v3/localTaskChecklistOutboxService.js +14 -1
- package/dist/sync/v3/localTaskCreateOutboxService.js +15 -6
- package/dist/sync/v3/localTaskMetadataClient.d.ts +1 -0
- package/dist/sync/v3/localTaskMetadataClient.js +1 -0
- package/dist/sync/v3/localTaskMetadataOutboxHandler.js +5 -1
- package/dist/sync/v3/localTaskMetadataOutboxService.d.ts +2 -0
- package/dist/sync/v3/localTaskMetadataOutboxService.js +7 -0
- package/dist/sync/v3/localTaskRestoreOutboxService.js +14 -6
- package/dist/sync/v3/localTaskStatusClient.d.ts +1 -0
- package/dist/sync/v3/localTaskStatusClient.js +6 -1
- package/dist/sync/v3/localTaskStatusOutboxService.d.ts +10 -0
- package/dist/sync/v3/localTaskStatusOutboxService.js +272 -24
- package/dist/sync/v3/syncDurabilityStore.d.ts +41 -0
- package/dist/sync/v3/syncDurabilityStore.js +199 -13
- package/dist/sync/v3/taskAttachmentLinksMutationService.d.ts +6 -4
- package/dist/sync/v3/taskAttachmentLinksMutationService.js +19 -10
- package/dist/sync/v3/taskChecklistMutationService.d.ts +15 -2
- package/dist/sync/v3/taskChecklistMutationService.js +48 -1
- package/dist/sync/v3/taskCreateMutationService.d.ts +2 -2
- package/dist/sync/v3/taskCreateMutationService.js +7 -4
- package/dist/sync/v3/taskMetadataMutationService.d.ts +3 -0
- package/dist/sync/v3/taskMetadataMutationService.js +4 -0
- package/dist/sync/v3/taskRestoreMutationService.d.ts +2 -2
- package/dist/sync/v3/taskRestoreMutationService.js +7 -4
- package/dist/sync/v3/taskStatusMutationService.d.ts +31 -1
- package/dist/sync/v3/taskStatusMutationService.js +123 -3
- package/dist/sync/v3/workflowAssignmentSync.d.ts +6 -0
- package/dist/sync/v3/workflowAssignmentSync.js +30 -0
- package/dist/sync/v3/workspaceSyncJournalReader.js +1 -1
- package/dist/sync/v3/workspaceSyncOperationRetentionService.d.ts +16 -0
- package/dist/sync/v3/workspaceSyncOperationRetentionService.js +83 -0
- package/dist/sync/v3/workspaceSyncV2ProjectionExclusions.d.ts +1 -1
- package/dist/sync/v3/workspaceSyncV2ProjectionExclusions.js +13 -3
- package/dist/sync/v3/workspaceSyncV3AttachmentApplyObligationStore.d.ts +11 -0
- package/dist/sync/v3/workspaceSyncV3AttachmentApplyObligationStore.js +27 -10
- package/dist/sync/v3/workspaceSyncV3AttachmentAssetHydration.d.ts +2 -1
- package/dist/sync/v3/workspaceSyncV3AttachmentAssetHydration.js +52 -10
- package/dist/sync/v3/workspaceSyncV3CloudOperationHandler.d.ts +1 -0
- package/dist/sync/v3/workspaceSyncV3CloudOperationHandler.js +18 -3
- package/dist/sync/v3/workspaceSyncV3CombinedFeedOrchestrator.js +8 -3
- package/dist/sync/v3/workspaceSyncV3CombinedLocalApply.js +51 -10
- package/dist/sync/v3/workspaceSyncV3CombinedRepairBaseline.d.ts +14 -0
- package/dist/sync/v3/workspaceSyncV3CombinedRepairBaseline.js +49 -25
- package/dist/sync/v3/workspaceSyncV3CombinedRepairMaterialization.d.ts +13 -4
- package/dist/sync/v3/workspaceSyncV3CombinedRepairMaterialization.js +124 -57
- package/dist/sync/v3/workspaceSyncV3CombinedRepairSnapshot.d.ts +20 -0
- package/dist/sync/v3/workspaceSyncV3CombinedRepairSnapshot.js +106 -30
- package/dist/sync/v3/workspaceSyncV3CombinedWireContract.d.ts +4 -1
- package/dist/sync/v3/workspaceSyncV3CombinedWireContract.js +34 -0
- package/dist/sync/v3/workspaceSyncV3CoverageRegistry.js +12 -0
- package/dist/sync/v3/workspaceSyncV3FeedProfile.d.ts +1 -1
- package/dist/sync/v3/workspaceSyncV3LegacyBoundaryAttestation.d.ts +1 -0
- package/dist/sync/v3/workspaceSyncV3LegacyBoundaryAttestation.js +23 -10
- package/dist/sync/v3/workspaceSyncV3NestedTaskApply.d.ts +3 -0
- package/dist/sync/v3/workspaceSyncV3NestedTaskApply.js +64 -13
- package/dist/sync/v3/workspaceSyncV3NestedTaskCodecs.d.ts +9 -0
- package/dist/sync/v3/workspaceSyncV3NestedTaskCodecs.js +26 -0
- package/dist/sync/v3/workspaceSyncV3NestedTaskProjection.d.ts +15 -5
- package/dist/sync/v3/workspaceSyncV3NestedTaskProjection.js +50 -14
- package/dist/sync/v3/workspaceSyncV3NestedTaskRepairSnapshot.d.ts +2 -1
- package/dist/sync/v3/workspaceSyncV3NestedTaskRepairSnapshot.js +11 -3
- package/dist/sync/v3/workspaceSyncV3OperationProtocol.d.ts +5 -0
- package/dist/sync/v3/workspaceSyncV3OperatorDiagnostics.d.ts +7 -0
- package/dist/sync/v3/workspaceSyncV3OperatorDiagnostics.js +55 -9
- package/dist/sync/v3/workspaceSyncV3RepairSnapshotRetentionService.d.ts +17 -0
- package/dist/sync/v3/workspaceSyncV3RepairSnapshotRetentionService.js +64 -0
- package/dist/sync/v3/workspaceSyncV3TaskCommentAudit.js +9 -2
- package/dist/sync/v3/workspaceSyncV3TaskCoverCoverage.d.ts +7 -0
- package/dist/sync/v3/workspaceSyncV3TaskCoverCoverage.js +37 -0
- package/dist/sync/v3/workspaceSyncV3TaskCoverWireContract.d.ts +6 -0
- package/dist/sync/v3/workspaceSyncV3TaskCoverWireContract.js +9 -0
- package/dist/sync/v3/workspaceSyncV3WorkflowTaskCoverCoverage.d.ts +7 -0
- package/dist/sync/v3/workspaceSyncV3WorkflowTaskCoverCoverage.js +33 -0
- package/dist/sync/v3/workspaceSyncV3WorkflowTaskCoverWireContract.d.ts +7 -0
- package/dist/sync/v3/workspaceSyncV3WorkflowTaskCoverWireContract.js +8 -0
- package/dist/sync/workspacePullFeed.js +2 -1
- package/dist/sync/workspaceRepair.d.ts +8 -2
- package/dist/sync/workspaceRepair.js +222 -6
- package/dist/sync/workspaceSyncModel.d.ts +21 -0
- package/dist/sync/workspaceSyncModel.js +35 -7
- package/dist/sync/workspaceSyncState.d.ts +1 -0
- package/dist/sync/workspaceSyncV2SnapshotBuilder.d.ts +6 -0
- package/dist/sync/workspaceSyncV2SnapshotBuilder.js +5 -0
- package/dist/types.d.ts +47 -1
- package/dist/types.js +6 -0
- package/dist/ui/assets/AiIdentityRosterCard-OcSz1PkK.js +1 -0
- package/dist/ui/assets/AiProfilesModule-ByhYW5Xi.js +1 -0
- package/dist/ui/assets/AnnotatedAttachmentWorkspace-BTM6nIg_.js +3 -0
- package/dist/ui/assets/AnnotatedAttachmentWorkspace-TzYu7pkG.css +1 -0
- package/dist/ui/assets/{AssetTraySortControl-Kf1pelSy.js → AssetTraySortControl-DabEG8L4.js} +1 -1
- package/dist/ui/assets/{ContextAttachmentManager-B8boOs6Q.js → ContextAttachmentManager-Coa8yVGM.js} +2 -2
- package/dist/ui/assets/{DocumentWorkspace-DXH4XUsB.js → DocumentWorkspace-BB0qhdix.js} +1 -1
- package/dist/ui/assets/{EntityActivityTimeline-BtSTq0ON.js → EntityActivityTimeline-CZ8x4UJE.js} +1 -1
- package/dist/ui/assets/PlanningModule-pRPjR7v5.js +1 -0
- package/dist/ui/assets/PlansPage-D86pZSSl.js +1 -0
- package/dist/ui/assets/TaskContextUpload-BVIkU9yT.js +1 -0
- package/dist/ui/assets/TaskSettings-Cv1mNhv_.js +12 -0
- package/dist/ui/assets/TaskforceAgentsModule-b-8R25cJ.css +1 -0
- package/dist/ui/assets/TaskforceAgentsModule-gmH-PD2q.js +24 -0
- package/dist/ui/assets/{WorkflowManagerModule-DWFspC-o.js → WorkflowManagerModule-DbfnHJ-f.js} +1 -1
- package/dist/ui/assets/index-BZ-hdZSk.css +1 -0
- package/dist/ui/assets/index-CTsDBaef.js +7 -0
- package/dist/ui/assets/{vendor-icons-BkFLXavV.js → vendor-icons-Bsq-mcEn.js} +1 -1
- package/dist/ui/branding/logos/letterhead_dark.png +0 -0
- package/dist/ui/branding/logos/letterhead_light.png +0 -0
- package/dist/ui/branding/logos/signature_dark.png +0 -0
- package/dist/ui/branding/logos/signature_light.png +0 -0
- package/dist/ui/index.html +3 -3
- package/dist/utils/aiProfileDefaultLogo.js +16 -48
- package/dist/utils/httpSetCookie.d.ts +1 -0
- package/dist/utils/httpSetCookie.js +4 -1
- package/dist/utils/localRuntimeUrl.d.ts +1 -0
- package/dist/utils/localRuntimeUrl.js +14 -0
- package/dist/utils/productLogoRegistry.d.ts +2 -0
- package/dist/utils/productLogoRegistry.js +36 -0
- package/dist/utils/syncStatusPresentation.d.ts +4 -0
- package/dist/utils/syncStatusPresentation.js +17 -0
- package/dist/utils/taskActivity.d.ts +3 -2
- package/dist/utils/taskActivity.js +19 -2
- package/dist/utils/taskEditorReconciliation.d.ts +40 -0
- package/dist/utils/taskEditorReconciliation.js +217 -0
- package/dist/utils/taskEvents.d.ts +2 -0
- package/dist/utils/taskNormalization.d.ts +1 -0
- package/dist/utils/taskNormalization.js +39 -0
- package/dist/utils/taskSearch.js +2 -2
- package/dist/utils/uiNotice.d.ts +4 -0
- package/dist/utils/workspaceSyncPresentation.d.ts +1 -1
- package/dist/utils/workspaceSyncPresentation.js +23 -17
- package/package.json +36 -6
- package/dist/ui/assets/AiIdentityRosterCard-MZs7lVED.js +0 -1
- package/dist/ui/assets/AiProfilesModule-C3i0LOxe.js +0 -1
- package/dist/ui/assets/AnnotatedAttachmentWorkspace-CBRZ8rca.css +0 -1
- package/dist/ui/assets/AnnotatedAttachmentWorkspace-DVZk5Tln.js +0 -3
- package/dist/ui/assets/PlanningModule-BPVyEa-f.js +0 -1
- package/dist/ui/assets/PlansPage-ChqgxALc.js +0 -1
- package/dist/ui/assets/TaskContextUpload-CB3ol0sN.js +0 -1
- package/dist/ui/assets/TaskSettings-g4ECKNOz.js +0 -12
- package/dist/ui/assets/TaskforceAgentsModule-BazdUwxZ.js +0 -21
- package/dist/ui/assets/TaskforceAgentsModule-D6IC0S7Q.css +0 -1
- package/dist/ui/assets/index-BUplSsv_.js +0 -7
- package/dist/ui/assets/index-gz2EXuoK.css +0 -1
|
@@ -0,0 +1,663 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
import { existsSync, realpathSync } from 'fs';
|
|
3
|
+
import { tmpdir } from 'os';
|
|
4
|
+
import { dirname, isAbsolute, join, resolve } from 'path';
|
|
5
|
+
import { createRequire } from 'module';
|
|
6
|
+
import readline from 'readline';
|
|
7
|
+
import { ModelGatewayConfigurationError } from './modelGateway.js';
|
|
8
|
+
import { TASKFORCE_AGENT_MODEL_OPTIONS, isTaskforceAgentSubscriptionDevModelsEnabled } from '../shared/taskforceAgentModels.js';
|
|
9
|
+
const CODEX_APP_SERVER_STDERR_LIMIT = 4_096;
|
|
10
|
+
export const PINNED_CODEX_APP_SERVER_VERSION = '0.148.0-alpha.9';
|
|
11
|
+
const require = createRequire(import.meta.url);
|
|
12
|
+
export class CodexAppServerCompatibilityError extends Error {
|
|
13
|
+
reason;
|
|
14
|
+
constructor(reason, message) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.reason = reason;
|
|
17
|
+
this.name = 'CodexAppServerCompatibilityError';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export function resolveBundledCodexCommand() {
|
|
21
|
+
try {
|
|
22
|
+
const packageVersion = String(require('@openai/codex/package.json')?.version || '');
|
|
23
|
+
if (packageVersion !== PINNED_CODEX_APP_SERVER_VERSION)
|
|
24
|
+
throw new Error('version mismatch');
|
|
25
|
+
const target = (() => {
|
|
26
|
+
if (process.platform === 'linux' && process.arch === 'x64') {
|
|
27
|
+
return ['@openai/codex-linux-x64', 'x86_64-unknown-linux-musl'];
|
|
28
|
+
}
|
|
29
|
+
if (process.platform === 'linux' && process.arch === 'arm64') {
|
|
30
|
+
return ['@openai/codex-linux-arm64', 'aarch64-unknown-linux-musl'];
|
|
31
|
+
}
|
|
32
|
+
if (process.platform === 'darwin' && process.arch === 'x64') {
|
|
33
|
+
return ['@openai/codex-darwin-x64', 'x86_64-apple-darwin'];
|
|
34
|
+
}
|
|
35
|
+
if (process.platform === 'darwin' && process.arch === 'arm64') {
|
|
36
|
+
return ['@openai/codex-darwin-arm64', 'aarch64-apple-darwin'];
|
|
37
|
+
}
|
|
38
|
+
if (process.platform === 'win32' && process.arch === 'x64') {
|
|
39
|
+
return ['@openai/codex-win32-x64', 'x86_64-pc-windows-msvc'];
|
|
40
|
+
}
|
|
41
|
+
if (process.platform === 'win32' && process.arch === 'arm64') {
|
|
42
|
+
return ['@openai/codex-win32-arm64', 'aarch64-pc-windows-msvc'];
|
|
43
|
+
}
|
|
44
|
+
throw new Error('unsupported platform');
|
|
45
|
+
})();
|
|
46
|
+
const platformPackageJson = require.resolve(`${target[0]}/package.json`);
|
|
47
|
+
const platformVersion = String(require(platformPackageJson)?.version || '');
|
|
48
|
+
const expectedPlatformVersion = `${PINNED_CODEX_APP_SERVER_VERSION}-${target[0].slice('@openai/codex-'.length)}`;
|
|
49
|
+
if (platformVersion !== expectedPlatformVersion)
|
|
50
|
+
throw new Error('platform version mismatch');
|
|
51
|
+
const executable = join(dirname(platformPackageJson), 'vendor', target[1], 'bin', process.platform === 'win32' ? 'codex.exe' : 'codex');
|
|
52
|
+
if (!existsSync(executable))
|
|
53
|
+
throw new Error('binary missing');
|
|
54
|
+
return executable;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
throw new CodexAppServerCompatibilityError('version', `Unsupported Codex app-server version; Taskforce requires ${PINNED_CODEX_APP_SERVER_VERSION}.`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function normalizedPath(value) {
|
|
61
|
+
try {
|
|
62
|
+
return realpathSync(value);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return resolve(value);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export function assertCodexAppServerCompatibility(result, expectedCodexHome) {
|
|
69
|
+
const userAgent = readStringPath(result, ['userAgent']);
|
|
70
|
+
const codexHome = readStringPath(result, ['codexHome']);
|
|
71
|
+
const version = userAgent.match(/\/([0-9]+\.[0-9]+\.[0-9]+(?:-[A-Za-z0-9.-]+)?)(?:\s|\()/)?.[1];
|
|
72
|
+
if (version !== PINNED_CODEX_APP_SERVER_VERSION) {
|
|
73
|
+
throw new CodexAppServerCompatibilityError('version', `Unsupported Codex app-server version; Taskforce requires ${PINNED_CODEX_APP_SERVER_VERSION}.`);
|
|
74
|
+
}
|
|
75
|
+
if (!codexHome || !isAbsolute(codexHome)) {
|
|
76
|
+
throw new CodexAppServerCompatibilityError('credential_home', 'Unsupported Codex app-server credential home response.');
|
|
77
|
+
}
|
|
78
|
+
const expected = String(expectedCodexHome || '').trim();
|
|
79
|
+
if (expected && normalizedPath(codexHome) !== normalizedPath(expected)) {
|
|
80
|
+
throw new CodexAppServerCompatibilityError('credential_home', 'Unsupported Codex app-server credential home response.');
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export const DEFAULT_CODEX_APP_SERVER_MODEL_KEY_IDS = {
|
|
84
|
+
...Object.fromEntries(TASKFORCE_AGENT_MODEL_OPTIONS
|
|
85
|
+
.filter((model) => model.runtime === 'subscription-dev' && model.providerKey === 'openai')
|
|
86
|
+
.map((model) => [model.key, model.runtimeModelId])),
|
|
87
|
+
};
|
|
88
|
+
const CODEX_APP_SERVER_ENV_ALLOWLIST = [
|
|
89
|
+
'HOME',
|
|
90
|
+
'USER',
|
|
91
|
+
'LOGNAME',
|
|
92
|
+
'PATH',
|
|
93
|
+
'SHELL',
|
|
94
|
+
'TMPDIR',
|
|
95
|
+
'TEMP',
|
|
96
|
+
'TMP',
|
|
97
|
+
'LANG',
|
|
98
|
+
'LC_ALL',
|
|
99
|
+
'LC_CTYPE',
|
|
100
|
+
'TERM',
|
|
101
|
+
'COLORTERM',
|
|
102
|
+
'NO_COLOR',
|
|
103
|
+
'CODEX_HOME',
|
|
104
|
+
'XDG_CONFIG_HOME',
|
|
105
|
+
'XDG_CACHE_HOME',
|
|
106
|
+
'XDG_DATA_HOME',
|
|
107
|
+
];
|
|
108
|
+
export function buildCodexAppServerEnv(source = process.env) {
|
|
109
|
+
const env = {};
|
|
110
|
+
for (const key of CODEX_APP_SERVER_ENV_ALLOWLIST) {
|
|
111
|
+
const value = source[key];
|
|
112
|
+
if (typeof value === 'string' && value.length > 0)
|
|
113
|
+
env[key] = value;
|
|
114
|
+
}
|
|
115
|
+
return env;
|
|
116
|
+
}
|
|
117
|
+
export function sanitizeCodexAppServerStderr(value, credentialPaths = []) {
|
|
118
|
+
let sanitized = String(value || '')
|
|
119
|
+
.replace(/\\+(?=["'])/g, '')
|
|
120
|
+
.replace(/(["']?(?:api[_-]?key|access[_-]?token|refresh[_-]?token|id[_-]?token|client[_-]?secret)["']?\s*[:=]\s*)(["'])[^"'\r\n]*\2/gi, '$1$2[redacted]$2')
|
|
121
|
+
.replace(/((?:api[_-]?key|access[_-]?token|refresh[_-]?token|id[_-]?token|client[_-]?secret)\s*[:=]\s*)[^\s,}\]]+/gi, '$1[redacted]')
|
|
122
|
+
.replace(/sk-[A-Za-z0-9_-]{8,}/g, '[redacted OpenAI credential]')
|
|
123
|
+
.replace(/(Bearer\s+)[^\s]+/gi, '$1[redacted]')
|
|
124
|
+
.replace(/\beyJ[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{5,}\b/g, '[redacted JWT]')
|
|
125
|
+
.replace(/[^\x09\x0A\x0D\x20-\x7E]/g, '?');
|
|
126
|
+
for (const credentialPath of credentialPaths) {
|
|
127
|
+
const normalized = String(credentialPath || '').trim();
|
|
128
|
+
if (normalized)
|
|
129
|
+
sanitized = sanitized.split(normalized).join('[redacted credential path]');
|
|
130
|
+
}
|
|
131
|
+
return sanitized.slice(0, CODEX_APP_SERVER_STDERR_LIMIT);
|
|
132
|
+
}
|
|
133
|
+
export function collectCodexAppServerStderr(current, chunk) {
|
|
134
|
+
return (current + String(chunk || '')).slice(-CODEX_APP_SERVER_STDERR_LIMIT);
|
|
135
|
+
}
|
|
136
|
+
export function assertCodexChatGptSubscriptionAccount(result) {
|
|
137
|
+
const accountType = readStringPath(result, ['account', 'type']);
|
|
138
|
+
if (accountType !== 'chatgpt') {
|
|
139
|
+
throw new ModelGatewayConfigurationError('Codex is not signed in with a ChatGPT subscription. Run codex login on this machine and choose Sign in with ChatGPT.', 'MODEL_SOURCE_UNAVAILABLE');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
export function extractCodexAccountLoginCompletion(messages, loginId, credentialPaths = []) {
|
|
143
|
+
for (const message of messages) {
|
|
144
|
+
if (message.method !== 'account/login/completed')
|
|
145
|
+
continue;
|
|
146
|
+
const completedLoginId = readStringPath(message.params, ['loginId']);
|
|
147
|
+
if (completedLoginId !== loginId)
|
|
148
|
+
continue;
|
|
149
|
+
const params = message.params;
|
|
150
|
+
const success = params?.success === true;
|
|
151
|
+
const error = sanitizeCodexAppServerStderr(params?.error, credentialPaths).trim();
|
|
152
|
+
return {
|
|
153
|
+
loginId,
|
|
154
|
+
success,
|
|
155
|
+
...(error ? { error } : {}),
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
export function isCodexSubscriptionDevRuntimeAllowed(source = process.env) {
|
|
161
|
+
const runtimeMode = String(source.TASKFORCE_RUNTIME_MODE || '').trim().toLowerCase();
|
|
162
|
+
return runtimeMode === 'local';
|
|
163
|
+
}
|
|
164
|
+
function resolveCodexAppServerCwd(cwd) {
|
|
165
|
+
return String(cwd || process.env.TASKFORCE_CODEX_APP_SERVER_CWD || tmpdir()).trim() || tmpdir();
|
|
166
|
+
}
|
|
167
|
+
function buildCodexAppServerRuntimePolicy(cwd) {
|
|
168
|
+
return {
|
|
169
|
+
cwd,
|
|
170
|
+
approvalPolicy: 'never',
|
|
171
|
+
sandbox: 'read-only',
|
|
172
|
+
sandboxPolicy: {
|
|
173
|
+
type: 'readOnly',
|
|
174
|
+
networkAccess: false,
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
export function extractCodexTurnCompletion(messages, credentialPaths = []) {
|
|
179
|
+
const jsonMessages = messages;
|
|
180
|
+
const completed = jsonMessages.find((message) => message.method === 'turn/completed');
|
|
181
|
+
if (!completed)
|
|
182
|
+
return null;
|
|
183
|
+
const stopReason = readStringPath(completed.params, ['turn', 'status'])
|
|
184
|
+
|| readStringPath(completed.params, ['status'])
|
|
185
|
+
|| 'completed';
|
|
186
|
+
if (stopReason !== 'completed') {
|
|
187
|
+
const errorMessage = readStringPath(completed.params, ['turn', 'error', 'message'])
|
|
188
|
+
|| readStringPath(completed.params, ['error', 'message'])
|
|
189
|
+
|| `Codex app-server turn ended with status ${stopReason}.`;
|
|
190
|
+
throw new Error(sanitizeCodexAppServerStderr(errorMessage, credentialPaths));
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
193
|
+
text: extractAgentText(jsonMessages),
|
|
194
|
+
stopReason,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
export class CodexAppServerJsonRpcClient {
|
|
198
|
+
process;
|
|
199
|
+
pending = new Map();
|
|
200
|
+
notifications = [];
|
|
201
|
+
nextId = 1;
|
|
202
|
+
initialized = false;
|
|
203
|
+
lineReader;
|
|
204
|
+
requestTimeoutMs;
|
|
205
|
+
terminalRejectors = new Set();
|
|
206
|
+
loginNotificationStart = new Map();
|
|
207
|
+
terminalError = null;
|
|
208
|
+
stderrTail = '';
|
|
209
|
+
credentialPaths;
|
|
210
|
+
expectedCodexHome;
|
|
211
|
+
processExited;
|
|
212
|
+
closePromise = null;
|
|
213
|
+
constructor(options = {}) {
|
|
214
|
+
const command = options.command
|
|
215
|
+
|| process.env.TASKFORCE_CODEX_APP_SERVER_COMMAND
|
|
216
|
+
|| resolveBundledCodexCommand();
|
|
217
|
+
const args = options.args || ['app-server', '--listen', 'stdio://'];
|
|
218
|
+
const cwd = resolveCodexAppServerCwd(options.cwd);
|
|
219
|
+
this.requestTimeoutMs = options.requestTimeoutMs ?? 30_000;
|
|
220
|
+
this.credentialPaths = options.credentialPaths || [];
|
|
221
|
+
const childEnvironment = options.env || buildCodexAppServerEnv();
|
|
222
|
+
this.expectedCodexHome = String(childEnvironment.CODEX_HOME || '').trim();
|
|
223
|
+
this.process = spawn(command, args, {
|
|
224
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
225
|
+
env: childEnvironment,
|
|
226
|
+
cwd,
|
|
227
|
+
});
|
|
228
|
+
this.processExited = new Promise((resolveExit) => {
|
|
229
|
+
let settled = false;
|
|
230
|
+
const finish = () => {
|
|
231
|
+
if (settled)
|
|
232
|
+
return;
|
|
233
|
+
settled = true;
|
|
234
|
+
resolveExit();
|
|
235
|
+
};
|
|
236
|
+
this.process.once('exit', finish);
|
|
237
|
+
this.process.once('error', finish);
|
|
238
|
+
});
|
|
239
|
+
this.lineReader = readline.createInterface({ input: this.process.stdout });
|
|
240
|
+
this.lineReader.on('line', (line) => this.handleLine(line));
|
|
241
|
+
this.process.on('error', (error) => {
|
|
242
|
+
this.fail(new Error(`Codex app-server failed to start: ${error.message}`));
|
|
243
|
+
});
|
|
244
|
+
this.process.on('exit', (code, signal) => {
|
|
245
|
+
const reason = signal ? `signal ${signal}` : `exit code ${code ?? 'unknown'}`;
|
|
246
|
+
const details = sanitizeCodexAppServerStderr(this.stderrTail, this.credentialPaths).trim();
|
|
247
|
+
this.fail(new Error(`Codex app-server stopped before completing the request (${reason}).${details ? ` ${details}` : ''}`));
|
|
248
|
+
});
|
|
249
|
+
this.process.stderr.on('data', (chunk) => {
|
|
250
|
+
this.stderrTail = collectCodexAppServerStderr(this.stderrTail, chunk);
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
async initialize() {
|
|
254
|
+
if (this.initialized)
|
|
255
|
+
return;
|
|
256
|
+
const result = await this.request('initialize', {
|
|
257
|
+
clientInfo: {
|
|
258
|
+
name: 'taskforce_dev',
|
|
259
|
+
title: 'Taskforce Dev',
|
|
260
|
+
version: '0.1.0',
|
|
261
|
+
},
|
|
262
|
+
capabilities: {
|
|
263
|
+
experimentalApi: true,
|
|
264
|
+
requestAttestation: false,
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
assertCodexAppServerCompatibility(result, this.expectedCodexHome);
|
|
268
|
+
this.sendNotification('initialized', {});
|
|
269
|
+
this.initialized = true;
|
|
270
|
+
}
|
|
271
|
+
async assertChatGptSubscriptionAuth() {
|
|
272
|
+
const result = await this.request('account/read', { refreshToken: false });
|
|
273
|
+
assertCodexChatGptSubscriptionAccount(result);
|
|
274
|
+
}
|
|
275
|
+
async startChatGptDeviceCodeLogin() {
|
|
276
|
+
const notificationStart = this.notifications.length;
|
|
277
|
+
const result = await this.request('account/login/start', { type: 'chatgptDeviceCode' });
|
|
278
|
+
const type = readStringPath(result, ['type']);
|
|
279
|
+
const loginId = readStringPath(result, ['loginId']);
|
|
280
|
+
const userCode = readStringPath(result, ['userCode']);
|
|
281
|
+
const verificationUrl = readStringPath(result, ['verificationUrl']);
|
|
282
|
+
if (type !== 'chatgptDeviceCode' || !loginId || !userCode || !verificationUrl) {
|
|
283
|
+
throw new Error('Codex app-server returned an invalid device-code login response.');
|
|
284
|
+
}
|
|
285
|
+
this.loginNotificationStart.set(loginId, notificationStart);
|
|
286
|
+
return { loginId, userCode, verificationUrl };
|
|
287
|
+
}
|
|
288
|
+
async waitForAccountLoginCompleted(input) {
|
|
289
|
+
const startIndex = this.loginNotificationStart.get(input.loginId) ?? 0;
|
|
290
|
+
try {
|
|
291
|
+
return await this.waitForNotification(() => extractCodexAccountLoginCompletion(this.notifications.slice(startIndex), input.loginId, this.credentialPaths), input.timeoutMs, 'Timed out waiting for Codex device-code authorization.', input.signal);
|
|
292
|
+
}
|
|
293
|
+
finally {
|
|
294
|
+
this.loginNotificationStart.delete(input.loginId);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
async cancelAccountLogin(loginId) {
|
|
298
|
+
const result = await this.request('account/login/cancel', { loginId });
|
|
299
|
+
const status = readStringPath(result, ['status']);
|
|
300
|
+
return status === 'canceled' ? 'canceled' : 'notFound';
|
|
301
|
+
}
|
|
302
|
+
async readAccount(refreshToken = false) {
|
|
303
|
+
const result = await this.request('account/read', { refreshToken });
|
|
304
|
+
const type = readStringPath(result, ['account', 'type']);
|
|
305
|
+
if (!type)
|
|
306
|
+
return null;
|
|
307
|
+
const email = readStringPath(result, ['account', 'email']);
|
|
308
|
+
const planType = readStringPath(result, ['account', 'planType']);
|
|
309
|
+
return { type, ...(email ? { email } : {}), ...(planType ? { planType } : {}) };
|
|
310
|
+
}
|
|
311
|
+
async logoutAccount() {
|
|
312
|
+
await this.request('account/logout', {});
|
|
313
|
+
}
|
|
314
|
+
async startThread(input) {
|
|
315
|
+
const result = await this.request('thread/start', {
|
|
316
|
+
model: input.model,
|
|
317
|
+
cwd: input.cwd,
|
|
318
|
+
approvalPolicy: input.approvalPolicy,
|
|
319
|
+
sandbox: input.sandbox,
|
|
320
|
+
serviceName: 'taskforce_agent_manager_dev',
|
|
321
|
+
...(input.developerInstructions
|
|
322
|
+
? { developerInstructions: input.developerInstructions }
|
|
323
|
+
: {}),
|
|
324
|
+
});
|
|
325
|
+
const threadId = readStringPath(result, ['thread', 'id']) || readStringPath(result, ['id']);
|
|
326
|
+
if (!threadId)
|
|
327
|
+
throw new Error('Codex app-server did not return a thread id.');
|
|
328
|
+
return { threadId };
|
|
329
|
+
}
|
|
330
|
+
async startTurnAndCollectText(input) {
|
|
331
|
+
const startedAt = this.notifications.length;
|
|
332
|
+
await this.request('turn/start', {
|
|
333
|
+
threadId: input.threadId,
|
|
334
|
+
input: [{ type: 'text', text: input.prompt }],
|
|
335
|
+
cwd: input.cwd,
|
|
336
|
+
approvalPolicy: input.approvalPolicy,
|
|
337
|
+
sandboxPolicy: input.sandboxPolicy,
|
|
338
|
+
model: input.model,
|
|
339
|
+
});
|
|
340
|
+
return this.waitForTurnCompletion(startedAt, input.timeoutMs);
|
|
341
|
+
}
|
|
342
|
+
async close() {
|
|
343
|
+
if (this.closePromise)
|
|
344
|
+
return this.closePromise;
|
|
345
|
+
this.closePromise = (async () => {
|
|
346
|
+
this.lineReader.close();
|
|
347
|
+
if (this.process.exitCode !== null || this.process.signalCode !== null) {
|
|
348
|
+
await this.processExited;
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
this.process.kill('SIGTERM');
|
|
352
|
+
let timeout;
|
|
353
|
+
const exitedGracefully = await Promise.race([
|
|
354
|
+
this.processExited.then(() => true),
|
|
355
|
+
new Promise((resolveTimeout) => {
|
|
356
|
+
timeout = setTimeout(() => resolveTimeout(false), 2_000);
|
|
357
|
+
timeout.unref?.();
|
|
358
|
+
}),
|
|
359
|
+
]);
|
|
360
|
+
if (timeout)
|
|
361
|
+
clearTimeout(timeout);
|
|
362
|
+
if (!exitedGracefully && this.process.exitCode === null && this.process.signalCode === null) {
|
|
363
|
+
this.process.kill('SIGKILL');
|
|
364
|
+
await this.processExited;
|
|
365
|
+
}
|
|
366
|
+
})();
|
|
367
|
+
return this.closePromise;
|
|
368
|
+
}
|
|
369
|
+
request(method, params) {
|
|
370
|
+
const id = this.nextId++;
|
|
371
|
+
const message = { jsonrpc: '2.0', id, method, params };
|
|
372
|
+
return new Promise((resolve, reject) => {
|
|
373
|
+
const timeout = setTimeout(() => {
|
|
374
|
+
this.pending.delete(id);
|
|
375
|
+
reject(new Error(`Timed out waiting for Codex app-server ${method} response.`));
|
|
376
|
+
}, this.requestTimeoutMs);
|
|
377
|
+
this.pending.set(id, {
|
|
378
|
+
resolve: (value) => {
|
|
379
|
+
clearTimeout(timeout);
|
|
380
|
+
resolve(value);
|
|
381
|
+
},
|
|
382
|
+
reject: (error) => {
|
|
383
|
+
clearTimeout(timeout);
|
|
384
|
+
reject(error);
|
|
385
|
+
},
|
|
386
|
+
});
|
|
387
|
+
this.process.stdin.write(JSON.stringify(message) + '\n', (error) => {
|
|
388
|
+
if (error) {
|
|
389
|
+
const pending = this.pending.get(id);
|
|
390
|
+
if (!pending)
|
|
391
|
+
return;
|
|
392
|
+
this.pending.delete(id);
|
|
393
|
+
pending.reject(error);
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
sendNotification(method, params) {
|
|
399
|
+
this.process.stdin.write(JSON.stringify({ jsonrpc: '2.0', method, params }) + '\n');
|
|
400
|
+
}
|
|
401
|
+
handleLine(line) {
|
|
402
|
+
const trimmed = line.trim();
|
|
403
|
+
if (!trimmed)
|
|
404
|
+
return;
|
|
405
|
+
let message;
|
|
406
|
+
try {
|
|
407
|
+
message = JSON.parse(trimmed);
|
|
408
|
+
}
|
|
409
|
+
catch {
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
if (typeof message.id === 'number') {
|
|
413
|
+
const pending = this.pending.get(message.id);
|
|
414
|
+
if (!pending) {
|
|
415
|
+
if (message.method) {
|
|
416
|
+
this.sendResponseError(message.id, -32601, `Taskforce does not support Codex app-server request ${message.method}.`);
|
|
417
|
+
}
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
this.pending.delete(message.id);
|
|
421
|
+
if (message.error) {
|
|
422
|
+
pending.reject(new Error(sanitizeCodexAppServerStderr(message.error.message || 'Codex app-server request failed.', this.credentialPaths)));
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
pending.resolve(message.result);
|
|
426
|
+
}
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
if (message.method)
|
|
430
|
+
this.notifications.push(message);
|
|
431
|
+
}
|
|
432
|
+
sendResponseError(id, code, message) {
|
|
433
|
+
this.process.stdin.write(JSON.stringify({
|
|
434
|
+
jsonrpc: '2.0',
|
|
435
|
+
id,
|
|
436
|
+
error: { code, message },
|
|
437
|
+
}) + '\n');
|
|
438
|
+
}
|
|
439
|
+
waitForTurnCompletion(startIndex, timeoutMs) {
|
|
440
|
+
const startedAt = Date.now();
|
|
441
|
+
return new Promise((resolve, reject) => {
|
|
442
|
+
let settled = false;
|
|
443
|
+
const rejectTurn = (error) => {
|
|
444
|
+
if (settled)
|
|
445
|
+
return;
|
|
446
|
+
settled = true;
|
|
447
|
+
this.terminalRejectors.delete(rejectTurn);
|
|
448
|
+
reject(error);
|
|
449
|
+
};
|
|
450
|
+
const resolveTurn = (value) => {
|
|
451
|
+
if (settled)
|
|
452
|
+
return;
|
|
453
|
+
settled = true;
|
|
454
|
+
this.terminalRejectors.delete(rejectTurn);
|
|
455
|
+
resolve(value);
|
|
456
|
+
};
|
|
457
|
+
this.terminalRejectors.add(rejectTurn);
|
|
458
|
+
if (this.terminalError) {
|
|
459
|
+
rejectTurn(this.terminalError);
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
const poll = () => {
|
|
463
|
+
if (settled)
|
|
464
|
+
return;
|
|
465
|
+
const messages = this.notifications.slice(startIndex);
|
|
466
|
+
try {
|
|
467
|
+
const completion = extractCodexTurnCompletion(messages, this.credentialPaths);
|
|
468
|
+
if (completion) {
|
|
469
|
+
resolveTurn(completion);
|
|
470
|
+
return;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
catch (error) {
|
|
474
|
+
rejectTurn(error instanceof Error ? error : new Error(String(error)));
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
if (Date.now() - startedAt > timeoutMs) {
|
|
478
|
+
rejectTurn(new Error('Timed out waiting for Codex app-server turn completion.'));
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
setTimeout(poll, 50);
|
|
482
|
+
};
|
|
483
|
+
poll();
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
waitForNotification(readValue, timeoutMs, timeoutMessage, signal) {
|
|
487
|
+
const startedAt = Date.now();
|
|
488
|
+
return new Promise((resolve, reject) => {
|
|
489
|
+
let settled = false;
|
|
490
|
+
const finish = (callback) => {
|
|
491
|
+
if (settled)
|
|
492
|
+
return;
|
|
493
|
+
settled = true;
|
|
494
|
+
this.terminalRejectors.delete(rejectWaiter);
|
|
495
|
+
signal?.removeEventListener('abort', abortWaiter);
|
|
496
|
+
callback();
|
|
497
|
+
};
|
|
498
|
+
const rejectWaiter = (error) => finish(() => reject(error));
|
|
499
|
+
const abortWaiter = () => rejectWaiter(new Error('Codex device-code authorization was cancelled.'));
|
|
500
|
+
this.terminalRejectors.add(rejectWaiter);
|
|
501
|
+
signal?.addEventListener('abort', abortWaiter, { once: true });
|
|
502
|
+
if (signal?.aborted)
|
|
503
|
+
return abortWaiter();
|
|
504
|
+
if (this.terminalError)
|
|
505
|
+
return rejectWaiter(this.terminalError);
|
|
506
|
+
const poll = () => {
|
|
507
|
+
if (settled)
|
|
508
|
+
return;
|
|
509
|
+
const value = readValue();
|
|
510
|
+
if (value !== null)
|
|
511
|
+
return finish(() => resolve(value));
|
|
512
|
+
if (Date.now() - startedAt > timeoutMs)
|
|
513
|
+
return rejectWaiter(new Error(timeoutMessage));
|
|
514
|
+
setTimeout(poll, 50);
|
|
515
|
+
};
|
|
516
|
+
poll();
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
rejectAll(error) {
|
|
520
|
+
for (const pending of this.pending.values())
|
|
521
|
+
pending.reject(error);
|
|
522
|
+
this.pending.clear();
|
|
523
|
+
}
|
|
524
|
+
fail(error) {
|
|
525
|
+
if (!this.terminalError)
|
|
526
|
+
this.terminalError = error;
|
|
527
|
+
this.rejectAll(this.terminalError);
|
|
528
|
+
for (const rejectWaiter of [...this.terminalRejectors])
|
|
529
|
+
rejectWaiter(this.terminalError);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
export class CodexAppServerModelGateway {
|
|
533
|
+
client;
|
|
534
|
+
clientFactory;
|
|
535
|
+
modelKeyIds;
|
|
536
|
+
timeoutMs;
|
|
537
|
+
cwd;
|
|
538
|
+
constructor(options = {}) {
|
|
539
|
+
this.client = options.client;
|
|
540
|
+
this.cwd = resolveCodexAppServerCwd(options.cwd);
|
|
541
|
+
this.clientFactory = options.clientFactory || (() => new CodexAppServerJsonRpcClient({
|
|
542
|
+
command: options.command,
|
|
543
|
+
args: options.args,
|
|
544
|
+
cwd: this.cwd,
|
|
545
|
+
env: options.env,
|
|
546
|
+
requestTimeoutMs: options.requestTimeoutMs,
|
|
547
|
+
credentialPaths: options.credentialPaths,
|
|
548
|
+
}));
|
|
549
|
+
this.modelKeyIds = {
|
|
550
|
+
...DEFAULT_CODEX_APP_SERVER_MODEL_KEY_IDS,
|
|
551
|
+
...(options.modelKeyIds ?? {}),
|
|
552
|
+
};
|
|
553
|
+
this.timeoutMs = options.timeoutMs ?? 120_000;
|
|
554
|
+
}
|
|
555
|
+
async generate(input) {
|
|
556
|
+
if (!isTaskforceAgentSubscriptionDevModelsEnabled()) {
|
|
557
|
+
throw new ModelGatewayConfigurationError('OpenAI Codex subscription-dev models are disabled. Set TASKFORCE_AGENT_SUBSCRIPTION_DEV_MODELS=true for this development runtime.', 'MODEL_SOURCE_UNAVAILABLE');
|
|
558
|
+
}
|
|
559
|
+
if (!isCodexSubscriptionDevRuntimeAllowed()) {
|
|
560
|
+
throw new ModelGatewayConfigurationError('OpenAI Codex subscription-dev models are only available in the local Taskforce runtime.', 'MODEL_SOURCE_UNAVAILABLE');
|
|
561
|
+
}
|
|
562
|
+
const modelId = this.resolveModelId(input);
|
|
563
|
+
const client = this.client || this.clientFactory();
|
|
564
|
+
const shouldClose = !this.client;
|
|
565
|
+
const runtimePolicy = buildCodexAppServerRuntimePolicy(this.cwd);
|
|
566
|
+
const startedAt = Date.now();
|
|
567
|
+
try {
|
|
568
|
+
await client.initialize();
|
|
569
|
+
await client.assertChatGptSubscriptionAuth();
|
|
570
|
+
const thread = await client.startThread({
|
|
571
|
+
model: modelId,
|
|
572
|
+
developerInstructions: input.system,
|
|
573
|
+
...runtimePolicy,
|
|
574
|
+
});
|
|
575
|
+
const result = await client.startTurnAndCollectText({
|
|
576
|
+
threadId: thread.threadId,
|
|
577
|
+
prompt: this.formatMessages(input),
|
|
578
|
+
model: modelId,
|
|
579
|
+
timeoutMs: this.timeoutMs,
|
|
580
|
+
...runtimePolicy,
|
|
581
|
+
});
|
|
582
|
+
return {
|
|
583
|
+
text: result.text.trim(),
|
|
584
|
+
provider: 'openai-codex-subscription-dev',
|
|
585
|
+
modelId,
|
|
586
|
+
stopReason: result.stopReason,
|
|
587
|
+
latencyMs: Date.now() - startedAt,
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
finally {
|
|
591
|
+
if (shouldClose)
|
|
592
|
+
await client.close();
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
resolveModelId(input) {
|
|
596
|
+
const modelKey = String(input.modelKey || '').trim();
|
|
597
|
+
if (!modelKey)
|
|
598
|
+
throw new Error('No OpenAI Codex subscription-dev model selected.');
|
|
599
|
+
const modelId = this.modelKeyIds[modelKey];
|
|
600
|
+
if (!modelId)
|
|
601
|
+
throw new Error('No OpenAI Codex subscription-dev model configured for the selected model.');
|
|
602
|
+
return modelId;
|
|
603
|
+
}
|
|
604
|
+
formatMessages(input) {
|
|
605
|
+
return input.messages
|
|
606
|
+
.map((message) => `${message.role === 'assistant' ? 'Assistant' : 'User'}: ${message.content}`)
|
|
607
|
+
.join('\n\n');
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
function readStringPath(value, path) {
|
|
611
|
+
let cursor = value;
|
|
612
|
+
for (const segment of path) {
|
|
613
|
+
if (!cursor || typeof cursor !== 'object')
|
|
614
|
+
return '';
|
|
615
|
+
cursor = cursor[segment];
|
|
616
|
+
}
|
|
617
|
+
return typeof cursor === 'string' ? cursor.trim() : '';
|
|
618
|
+
}
|
|
619
|
+
function readTextPath(value, path) {
|
|
620
|
+
let cursor = value;
|
|
621
|
+
for (const segment of path) {
|
|
622
|
+
if (!cursor || typeof cursor !== 'object')
|
|
623
|
+
return '';
|
|
624
|
+
cursor = cursor[segment];
|
|
625
|
+
}
|
|
626
|
+
return typeof cursor === 'string' ? cursor : '';
|
|
627
|
+
}
|
|
628
|
+
function extractAgentText(messages) {
|
|
629
|
+
const deltaTextParts = [];
|
|
630
|
+
const finalAnswerTextParts = [];
|
|
631
|
+
const legacyCompletedTextParts = [];
|
|
632
|
+
for (const message of messages) {
|
|
633
|
+
if (message.method === 'item/agentMessage/delta') {
|
|
634
|
+
const text = readTextPath(message.params, ['delta'])
|
|
635
|
+
|| readTextPath(message.params, ['text'])
|
|
636
|
+
|| readTextPath(message.params, ['message', 'delta']);
|
|
637
|
+
if (text)
|
|
638
|
+
deltaTextParts.push(text);
|
|
639
|
+
}
|
|
640
|
+
if (message.method === 'item/completed') {
|
|
641
|
+
const itemType = readStringPath(message.params, ['item', 'type']);
|
|
642
|
+
if (itemType && itemType !== 'agentMessage')
|
|
643
|
+
continue;
|
|
644
|
+
const phase = readStringPath(message.params, ['item', 'phase']);
|
|
645
|
+
if (phase === 'commentary')
|
|
646
|
+
continue;
|
|
647
|
+
const text = readTextPath(message.params, ['item', 'text'])
|
|
648
|
+
|| readTextPath(message.params, ['item', 'content', 'text']);
|
|
649
|
+
if (!text)
|
|
650
|
+
continue;
|
|
651
|
+
if (phase === 'final_answer')
|
|
652
|
+
finalAnswerTextParts.push(text);
|
|
653
|
+
else
|
|
654
|
+
legacyCompletedTextParts.push(text);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
const textParts = finalAnswerTextParts.length > 0
|
|
658
|
+
? finalAnswerTextParts
|
|
659
|
+
: legacyCompletedTextParts.length > 0
|
|
660
|
+
? legacyCompletedTextParts
|
|
661
|
+
: deltaTextParts;
|
|
662
|
+
return textParts.join('').trim();
|
|
663
|
+
}
|