@wildo-ai/dev-companion 1.1.1 → 1.1.3
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/esm/.tsbuildinfo +1 -1
- package/dist/esm/claude-cli/models/coding-agent-dispatch.models.d.ts +12 -1
- package/dist/esm/claude-cli/models/coding-agent-dispatch.models.d.ts.map +1 -1
- package/dist/esm/claude-cli/models/coding-agent-dispatch.models.js +11 -0
- package/dist/esm/claude-cli/models/coding-agent-dispatch.models.js.map +1 -1
- package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.d.ts +153 -1
- package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.d.ts.map +1 -1
- package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.js +408 -38
- package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.js.map +1 -1
- package/dist/esm/claude-cli/services/research-agent-dispatch.companion.service.d.ts +25 -10
- package/dist/esm/claude-cli/services/research-agent-dispatch.companion.service.d.ts.map +1 -1
- package/dist/esm/claude-cli/services/research-agent-dispatch.companion.service.js +65 -24
- package/dist/esm/claude-cli/services/research-agent-dispatch.companion.service.js.map +1 -1
- package/dist/esm/claude-cli/services/research-evidence-store.companion.d.ts +70 -0
- package/dist/esm/claude-cli/services/research-evidence-store.companion.d.ts.map +1 -0
- package/dist/esm/claude-cli/services/research-evidence-store.companion.js +110 -0
- package/dist/esm/claude-cli/services/research-evidence-store.companion.js.map +1 -0
- package/dist/esm/companion-api/companion-api.schemas.d.ts +59 -2
- package/dist/esm/companion-api/companion-api.schemas.d.ts.map +1 -1
- package/dist/esm/companion-api/companion-api.schemas.js +60 -0
- package/dist/esm/companion-api/companion-api.schemas.js.map +1 -1
- package/dist/esm/companion-api/controllers/companion.controller.d.ts +62 -1
- package/dist/esm/companion-api/controllers/companion.controller.d.ts.map +1 -1
- package/dist/esm/companion-api/controllers/companion.controller.js +295 -19
- package/dist/esm/companion-api/controllers/companion.controller.js.map +1 -1
- package/dist/esm/core/inject/models/container.d.ts.map +1 -1
- package/dist/esm/core/inject/models/container.js +11 -0
- package/dist/esm/core/inject/models/container.js.map +1 -1
- package/dist/esm/core/inject/models/service-types.d.ts +5 -0
- package/dist/esm/core/inject/models/service-types.d.ts.map +1 -1
- package/dist/esm/core/inject/models/service-types.js +5 -0
- package/dist/esm/core/inject/models/service-types.js.map +1 -1
- package/dist/esm/core/introspection/behaviors/companion-introspection-behavior-definitions.d.ts.map +1 -1
- package/dist/esm/core/introspection/behaviors/companion-introspection-behavior-definitions.js +81 -0
- package/dist/esm/core/introspection/behaviors/companion-introspection-behavior-definitions.js.map +1 -1
- package/dist/esm/core/introspection/models/companion-introspection.models.d.ts +11 -1
- package/dist/esm/core/introspection/models/companion-introspection.models.d.ts.map +1 -1
- package/dist/esm/core/introspection/models/companion-introspection.models.js +39 -0
- package/dist/esm/core/introspection/models/companion-introspection.models.js.map +1 -1
- package/dist/esm/core/introspection/resources/creation-plane-dispatch.custom-impl.companion.service.d.ts +8 -0
- package/dist/esm/core/introspection/resources/creation-plane-dispatch.custom-impl.companion.service.d.ts.map +1 -0
- package/dist/esm/core/introspection/resources/creation-plane-dispatch.custom-impl.companion.service.js +317 -0
- package/dist/esm/core/introspection/resources/creation-plane-dispatch.custom-impl.companion.service.js.map +1 -0
- package/dist/esm/core/introspection/resources/creation-plane-projection.companion.service.d.ts +45 -0
- package/dist/esm/core/introspection/resources/creation-plane-projection.companion.service.d.ts.map +1 -0
- package/dist/esm/core/introspection/resources/creation-plane-projection.companion.service.js +243 -0
- package/dist/esm/core/introspection/resources/creation-plane-projection.companion.service.js.map +1 -0
- package/dist/esm/core/introspection/resources/introspection-resource-notifier.companion.service.d.ts +123 -0
- package/dist/esm/core/introspection/resources/introspection-resource-notifier.companion.service.d.ts.map +1 -0
- package/dist/esm/core/introspection/resources/introspection-resource-notifier.companion.service.js +298 -0
- package/dist/esm/core/introspection/resources/introspection-resource-notifier.companion.service.js.map +1 -0
- package/dist/esm/core/introspection/resources/introspection-resource-source.companion.service.d.ts +78 -1
- package/dist/esm/core/introspection/resources/introspection-resource-source.companion.service.d.ts.map +1 -1
- package/dist/esm/core/introspection/resources/introspection-resource-source.companion.service.js +155 -6
- package/dist/esm/core/introspection/resources/introspection-resource-source.companion.service.js.map +1 -1
- package/dist/esm/core/introspection/services/companion-introspection.companion.service.d.ts +131 -2
- package/dist/esm/core/introspection/services/companion-introspection.companion.service.d.ts.map +1 -1
- package/dist/esm/core/introspection/services/companion-introspection.companion.service.js +259 -9
- package/dist/esm/core/introspection/services/companion-introspection.companion.service.js.map +1 -1
- package/dist/esm/core/introspection/services/introspection-derivation-state.companion.service.d.ts +243 -0
- package/dist/esm/core/introspection/services/introspection-derivation-state.companion.service.d.ts.map +1 -0
- package/dist/esm/core/introspection/services/introspection-derivation-state.companion.service.js +417 -0
- package/dist/esm/core/introspection/services/introspection-derivation-state.companion.service.js.map +1 -0
- package/dist/esm/core/introspection/services/introspection-source-state.companion.service.d.ts +186 -0
- package/dist/esm/core/introspection/services/introspection-source-state.companion.service.d.ts.map +1 -0
- package/dist/esm/core/introspection/services/introspection-source-state.companion.service.js +368 -0
- package/dist/esm/core/introspection/services/introspection-source-state.companion.service.js.map +1 -0
- package/dist/esm/core/introspection/services/introspection-source-watcher.companion.service.d.ts +101 -0
- package/dist/esm/core/introspection/services/introspection-source-watcher.companion.service.d.ts.map +1 -0
- package/dist/esm/core/introspection/services/introspection-source-watcher.companion.service.js +278 -0
- package/dist/esm/core/introspection/services/introspection-source-watcher.companion.service.js.map +1 -0
- package/dist/esm/core/introspection/subprocess/application-domain-model.behavior.d.ts +370 -0
- package/dist/esm/core/introspection/subprocess/application-domain-model.behavior.d.ts.map +1 -0
- package/dist/esm/core/introspection/subprocess/application-domain-model.behavior.js +167 -0
- package/dist/esm/core/introspection/subprocess/application-domain-model.behavior.js.map +1 -0
- package/dist/esm/core/introspection/subprocess/companion-introspection-behavior-handlers.d.ts.map +1 -1
- package/dist/esm/core/introspection/subprocess/companion-introspection-behavior-handlers.js +332 -3
- package/dist/esm/core/introspection/subprocess/companion-introspection-behavior-handlers.js.map +1 -1
- package/dist/esm/core/introspection/subprocess/family-aspects.behavior.d.ts +40 -0
- package/dist/esm/core/introspection/subprocess/family-aspects.behavior.d.ts.map +1 -0
- package/dist/esm/core/introspection/subprocess/family-aspects.behavior.js +126 -0
- package/dist/esm/core/introspection/subprocess/family-aspects.behavior.js.map +1 -0
- package/dist/esm/core/introspection/subprocess/specification-artifacts.behavior.d.ts +51 -0
- package/dist/esm/core/introspection/subprocess/specification-artifacts.behavior.d.ts.map +1 -0
- package/dist/esm/core/introspection/subprocess/specification-artifacts.behavior.js +391 -0
- package/dist/esm/core/introspection/subprocess/specification-artifacts.behavior.js.map +1 -0
- package/dist/esm/core/runtime/dev-compile-quiet.companion.d.ts +103 -0
- package/dist/esm/core/runtime/dev-compile-quiet.companion.d.ts.map +1 -0
- package/dist/esm/core/runtime/dev-compile-quiet.companion.js +124 -0
- package/dist/esm/core/runtime/dev-compile-quiet.companion.js.map +1 -0
- package/dist/esm/core/runtime/services/start-companion-application.service.d.ts +39 -2
- package/dist/esm/core/runtime/services/start-companion-application.service.d.ts.map +1 -1
- package/dist/esm/core/runtime/services/start-companion-application.service.js +122 -11
- package/dist/esm/core/runtime/services/start-companion-application.service.js.map +1 -1
- package/dist/esm/core/specifications/non-composite-view-specification-context.shared.d.ts +6 -0
- package/dist/esm/core/specifications/non-composite-view-specification-context.shared.d.ts.map +1 -1
- package/dist/esm/core/specifications/non-composite-view-specification-context.shared.js.map +1 -1
- package/dist/esm/core/specifications/specification-context-factory.shared.d.ts +23 -0
- package/dist/esm/core/specifications/specification-context-factory.shared.d.ts.map +1 -1
- package/dist/esm/core/specifications/specification-context-factory.shared.js +26 -4
- package/dist/esm/core/specifications/specification-context-factory.shared.js.map +1 -1
- package/dist/esm/executions/services/companion-executions.companion.service.d.ts.map +1 -1
- package/dist/esm/executions/services/companion-executions.companion.service.js +13 -8
- package/dist/esm/executions/services/companion-executions.companion.service.js.map +1 -1
- package/dist/esm/i18n/components/APP_LAYOUTS_MAIN_CONTAINER.en.d.ts +12 -0
- package/dist/esm/i18n/components/APP_LAYOUTS_MAIN_CONTAINER.en.d.ts.map +1 -0
- package/dist/esm/i18n/components/APP_LAYOUTS_MAIN_CONTAINER.en.js +12 -0
- package/dist/esm/i18n/components/APP_LAYOUTS_MAIN_CONTAINER.en.js.map +1 -0
- package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD.en.d.ts +1 -1
- package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD.en.js +1 -1
- package/dist/esm/i18n/components/LOW_LEVEL_FORM_FIELD.en.js.map +1 -1
- package/dist/esm/i18n/composite_views/app.creation-board.en.d.ts +13 -0
- package/dist/esm/i18n/composite_views/app.creation-board.en.d.ts.map +1 -0
- package/dist/esm/i18n/composite_views/app.creation-board.en.js +91 -0
- package/dist/esm/i18n/composite_views/app.creation-board.en.js.map +1 -0
- package/dist/esm/i18n/composite_views/app.domain-model.en.d.ts +38 -0
- package/dist/esm/i18n/composite_views/app.domain-model.en.d.ts.map +1 -0
- package/dist/esm/i18n/composite_views/app.domain-model.en.js +41 -0
- package/dist/esm/i18n/composite_views/app.domain-model.en.js.map +1 -0
- package/dist/esm/i18n/index.d.ts +3 -3
- package/dist/esm/i18n/index.js +3 -3
- package/dist/esm/i18n/index.js.map +1 -1
- package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.en.d.ts +24 -0
- package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.en.d.ts.map +1 -0
- package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.en.js +20 -0
- package/dist/esm/i18n/resources/wildoApplicationActorSystemExecutions.en.js.map +1 -0
- package/dist/esm/i18n/resources/wildoApplicationActorTasks.en.d.ts +31 -0
- package/dist/esm/i18n/resources/wildoApplicationActorTasks.en.d.ts.map +1 -0
- package/dist/esm/i18n/resources/wildoApplicationActorTasks.en.js +27 -0
- package/dist/esm/i18n/resources/wildoApplicationActorTasks.en.js.map +1 -0
- package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.en.d.ts +24 -0
- package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.en.d.ts.map +1 -0
- package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.en.js +20 -0
- package/dist/esm/i18n/resources/wildoApplicationFlowSystemExecutions.en.js.map +1 -0
- package/dist/esm/i18n/resources/workbenchBuildPlanTasks.en.d.ts +28 -0
- package/dist/esm/i18n/resources/workbenchBuildPlanTasks.en.d.ts.map +1 -0
- package/dist/esm/i18n/resources/workbenchBuildPlanTasks.en.js +24 -0
- package/dist/esm/i18n/resources/workbenchBuildPlanTasks.en.js.map +1 -0
- package/dist/esm/i18n/resources/workbenchDomainResources.en.d.ts +138 -0
- package/dist/esm/i18n/resources/workbenchDomainResources.en.d.ts.map +1 -0
- package/dist/esm/i18n/resources/workbenchDomainResources.en.js +100 -0
- package/dist/esm/i18n/resources/workbenchDomainResources.en.js.map +1 -0
- package/dist/esm/i18n/resources/workbenchPlaybooks.en.d.ts +29 -0
- package/dist/esm/i18n/resources/workbenchPlaybooks.en.d.ts.map +1 -0
- package/dist/esm/i18n/resources/workbenchPlaybooks.en.js +25 -0
- package/dist/esm/i18n/resources/workbenchPlaybooks.en.js.map +1 -0
- package/dist/esm/i18n/resources/workbenchRunWriteRecords.en.d.ts +27 -0
- package/dist/esm/i18n/resources/workbenchRunWriteRecords.en.d.ts.map +1 -0
- package/dist/esm/i18n/resources/workbenchRunWriteRecords.en.js +23 -0
- package/dist/esm/i18n/resources/workbenchRunWriteRecords.en.js.map +1 -0
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.d.ts +806 -0
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.d.ts.map +1 -0
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.js +326 -0
- package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.js.map +1 -0
- package/dist/esm/i18n/resources/workbenchTraceSessions.en.d.ts +26 -0
- package/dist/esm/i18n/resources/workbenchTraceSessions.en.d.ts.map +1 -0
- package/dist/esm/i18n/resources/workbenchTraceSessions.en.js +22 -0
- package/dist/esm/i18n/resources/workbenchTraceSessions.en.js.map +1 -0
- package/dist/esm/i18n/system_enums/market.en.d.ts +202 -0
- package/dist/esm/i18n/system_enums/market.en.d.ts.map +1 -0
- package/dist/esm/i18n/system_enums/market.en.js +209 -0
- package/dist/esm/i18n/system_enums/market.en.js.map +1 -0
- package/dist/esm/meta-workflows/models/application-coding-agent.actors-system.definitions.d.ts +31 -0
- package/dist/esm/meta-workflows/models/application-coding-agent.actors-system.definitions.d.ts.map +1 -1
- package/dist/esm/meta-workflows/models/application-coding-agent.actors-system.definitions.js +91 -8
- package/dist/esm/meta-workflows/models/application-coding-agent.actors-system.definitions.js.map +1 -1
- package/dist/esm/meta-workflows/models/application-research-agent.actors-system.definitions.d.ts +4 -2
- package/dist/esm/meta-workflows/models/application-research-agent.actors-system.definitions.d.ts.map +1 -1
- package/dist/esm/meta-workflows/models/application-research-agent.actors-system.definitions.js +10 -7
- package/dist/esm/meta-workflows/models/application-research-agent.actors-system.definitions.js.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.d.ts +80 -7
- package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.js +261 -24
- package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.d.ts +46 -3
- package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.js +95 -2
- package/dist/esm/meta-workflows/services/application-build-generation-step.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/execution-trace-read.companion.service.d.ts +9 -0
- package/dist/esm/meta-workflows/services/execution-trace-read.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/execution-trace-read.companion.service.js +13 -0
- package/dist/esm/meta-workflows/services/execution-trace-read.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/playbook-run-write-register.companion.service.d.ts +12 -0
- package/dist/esm/meta-workflows/services/playbook-run-write-register.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/playbook-run-write-register.companion.service.js +23 -0
- package/dist/esm/meta-workflows/services/playbook-run-write-register.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/playbook-run.companion.service.d.ts +113 -1
- package/dist/esm/meta-workflows/services/playbook-run.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/playbook-run.companion.service.js +517 -54
- package/dist/esm/meta-workflows/services/playbook-run.companion.service.js.map +1 -1
- package/dist/esm/meta-workflows/services/playbook-suspended-run.companion.service.d.ts +40 -0
- package/dist/esm/meta-workflows/services/playbook-suspended-run.companion.service.d.ts.map +1 -1
- package/dist/esm/meta-workflows/services/playbook-suspended-run.companion.service.js +63 -1
- package/dist/esm/meta-workflows/services/playbook-suspended-run.companion.service.js.map +1 -1
- package/dist/esm/technical-doc/services/technical-doc.companion.service.d.ts +21 -0
- package/dist/esm/technical-doc/services/technical-doc.companion.service.d.ts.map +1 -1
- package/dist/esm/technical-doc/services/technical-doc.companion.service.js +84 -2
- package/dist/esm/technical-doc/services/technical-doc.companion.service.js.map +1 -1
- package/dist/esm/technical-doc/services/technical-documentation-application-derivation.companion.service.d.ts +10 -1
- package/dist/esm/technical-doc/services/technical-documentation-application-derivation.companion.service.d.ts.map +1 -1
- package/dist/esm/technical-doc/services/technical-documentation-application-derivation.companion.service.js +10 -1
- package/dist/esm/technical-doc/services/technical-documentation-application-derivation.companion.service.js.map +1 -1
- package/package.json +17 -17
- package/dist/esm/.builder.pid +0 -9
- package/dist/esm/i18n/resources/workbenchApplicationModules.en.d.ts +0 -36
- package/dist/esm/i18n/resources/workbenchApplicationModules.en.d.ts.map +0 -1
- package/dist/esm/i18n/resources/workbenchApplicationModules.en.js +0 -32
- package/dist/esm/i18n/resources/workbenchApplicationModules.en.js.map +0 -1
- package/dist/esm/i18n/resources/workbenchResourceRelationships.en.d.ts +0 -29
- package/dist/esm/i18n/resources/workbenchResourceRelationships.en.d.ts.map +0 -1
- package/dist/esm/i18n/resources/workbenchResourceRelationships.en.js +0 -25
- package/dist/esm/i18n/resources/workbenchResourceRelationships.en.js.map +0 -1
|
@@ -63,9 +63,10 @@ import { existsSync, realpathSync } from 'node:fs';
|
|
|
63
63
|
import { inject, injectable } from 'inversify';
|
|
64
64
|
import { AgentsBackendService, ErrorBuilderBackendService, LoggerService, SAAS_SERVICE_TYPES, executeBoundedSubprocess, describeCaughtError, } from '@wildo-ai/saas-backend-lib';
|
|
65
65
|
import { Actor_Task_Topics, ErrorCustomMessageReference, ErrorType, FlowsActors_IO_PartKind, FlowsActors_Status, isWildoBackendError, } from '@wildo-ai/saas-models';
|
|
66
|
-
import { CodingAgent_StopReason, } from '@wildo-ai/external-connectors-models';
|
|
66
|
+
import { CodingAgent_SessionSuspensionSchema, CodingAgent_StopReason, } from '@wildo-ai/external-connectors-models';
|
|
67
67
|
import { ApplicationCodingTaskContractSchema, } from '@wildo-ai/saas-specifications/application-creation';
|
|
68
68
|
import { getWorkspaceMutationLockPath as resolveWorkspaceMutationLockPath, withDedicatedFileLock, } from '@wildo-ai/platform-config-lib';
|
|
69
|
+
import { sanitizeWorkbenchCreationPlaneIdentity } from '@wildo-ai/platform-core-shared';
|
|
69
70
|
import { COMPANION_SERVICE_TYPES } from '../../core/inject/models/service-types.js';
|
|
70
71
|
import { CompanionTraceabilityLevel, CompanionTraceAliasKind } from '../../core/traceability/companion-traceability.models.js';
|
|
71
72
|
import { CompanionTraceabilityService } from '../../core/traceability/companion-traceability.service.js';
|
|
@@ -73,7 +74,7 @@ import { CompanionIntrospectionService } from '../../core/introspection/services
|
|
|
73
74
|
import { CompanionExecutionsCompanionService } from '../../executions/services/companion-executions.companion.service.js';
|
|
74
75
|
import { CompanionCreateActorTaskRequestSchema, CompanionUpdateActorTaskRequestSchema, } from '../../companion-api/companion-api.schemas.js';
|
|
75
76
|
import { GitChangeSetCompanionService } from './git-change-set.companion.service.js';
|
|
76
|
-
import { APPLICATION_CODING_AGENT_REF } from '../../meta-workflows/models/application-coding-agent.actors-system.definitions.js';
|
|
77
|
+
import { APPLICATION_CODING_AGENT_REF, APPLICATION_CODING_TURN_CLASSIFIER_AGENT_REF, CodingTurnEndClassificationOutputSchema, } from '../../meta-workflows/models/application-coding-agent.actors-system.definitions.js';
|
|
77
78
|
import { ChangeSetAttributionClass, ApplicationCodingTaskDisposition, DISPATCH_DEFAULT_MAX_CAPTURED_BYTES, DISPATCH_DEFAULT_TIMEOUT_MS, DISPATCH_HARD_MAX_CAPTURED_BYTES, DISPATCH_HARD_MAX_TIMEOUT_MS, VerificationKind, renderApplicationCodingTaskAgentPrompt, resolveApplicationCodingTaskVerificationPlans, } from '../models/coding-agent-dispatch.models.js';
|
|
78
79
|
/** Fixed, non-overridable limits for the verification hook subprocess. */
|
|
79
80
|
const VERIFICATION_TIMEOUT_MS = 10 * 60_000;
|
|
@@ -88,6 +89,10 @@ const RETAINED_CODING_SESSION_EVENT_KINDS = new Set(['tool_call', 'tool_call_upd
|
|
|
88
89
|
const RETAINED_CODING_SESSION_FRAME_LIMIT = 200;
|
|
89
90
|
/** Tail size persisted on the task row; full streams go to traceability artifacts. */
|
|
90
91
|
const OUTPUT_TAIL_CHARS = 16_000;
|
|
92
|
+
/** Local narrow: is this an indexable object (not null, not an array)? */
|
|
93
|
+
function isRecordValue(value) {
|
|
94
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
95
|
+
}
|
|
91
96
|
/**
|
|
92
97
|
* Scope checking is deliberately based on the post-run attribution capture,
|
|
93
98
|
* not only clean-baseline files. A baseline-dirty file changed again during a
|
|
@@ -239,6 +244,19 @@ let CodingAgentDispatchCompanionService = class CodingAgentDispatchCompanionServ
|
|
|
239
244
|
* which is correct — restart reconciliation already terminalized it.
|
|
240
245
|
*/
|
|
241
246
|
applicationCodingTaskSettlements = new Map();
|
|
247
|
+
/**
|
|
248
|
+
* Tasks parked on a question, keyed by task id — the answerable set. A task
|
|
249
|
+
* enters here when a run returns a `suspension` and leaves when it is answered
|
|
250
|
+
* (resumed) or explicitly abandoned. See {@link ParkedCodingSessionState}.
|
|
251
|
+
*/
|
|
252
|
+
parkedCodingSessions = new Map();
|
|
253
|
+
/**
|
|
254
|
+
* Live-frame subscribers keyed by task id. Fed by the coding session's own
|
|
255
|
+
* event stream and the ladder's state transitions while a run is active;
|
|
256
|
+
* drained by the SSE endpoint. Best-effort throughout — a slow or throwing
|
|
257
|
+
* subscriber never touches the run it observes.
|
|
258
|
+
*/
|
|
259
|
+
codingSessionSubscribers = new Map();
|
|
242
260
|
constructor(logger, errorBuilder, companionContext, agentsService, gitChangeSetService, executionsService, traceabilityService, introspectionService) {
|
|
243
261
|
this.logger = logger;
|
|
244
262
|
this.errorBuilder = errorBuilder;
|
|
@@ -376,6 +394,27 @@ let CodingAgentDispatchCompanionService = class CodingAgentDispatchCompanionServ
|
|
|
376
394
|
for (const task of processingTasks) {
|
|
377
395
|
if (task.actors?.actorRef !== APPLICATION_CODING_AGENT_REF)
|
|
378
396
|
continue;
|
|
397
|
+
/*
|
|
398
|
+
* A PARKED task is deliberately PROCESSING with no live child — its agent process is already
|
|
399
|
+
* closed and the answer resumes the persisted session via `session/load`. That is the ONE
|
|
400
|
+
* PROCESSING shape a restart must NOT terminalize: surviving the restart is the suspension's
|
|
401
|
+
* whole design (`reconstructParkedCodingTaskForResume` re-selects it from the build plan).
|
|
402
|
+
* Measured 2026-09-04, first live park on a restart: this sweep terminalized the parked row
|
|
403
|
+
* and nulled its suspension three seconds before the operator's answer arrived, so the
|
|
404
|
+
* restart-durability door refused with "no coding task is awaiting an answer". Only a FRESH,
|
|
405
|
+
* RESUMABLE suspension is exempt — an expired `parkedUntil`, or an agent that cannot
|
|
406
|
+
* `session/load`, leaves a question nobody can answer on the same session, and terminalizing
|
|
407
|
+
* it for review is then the honest outcome.
|
|
408
|
+
*/
|
|
409
|
+
const parkedOutput = task.output;
|
|
410
|
+
if (parkedOutput?.disposition === ApplicationCodingTaskDisposition.AWAITING_OPERATOR_INPUT) {
|
|
411
|
+
const parsedSuspension = CodingAgent_SessionSuspensionSchema.safeParse(parkedOutput.suspension);
|
|
412
|
+
const stillAnswerable = parsedSuspension.success
|
|
413
|
+
&& parsedSuspension.data.resumable
|
|
414
|
+
&& Date.parse(parsedSuspension.data.parkedUntil) > Date.now();
|
|
415
|
+
if (stillAnswerable)
|
|
416
|
+
continue;
|
|
417
|
+
}
|
|
379
418
|
let currentSnapshot = null;
|
|
380
419
|
let captureError = null;
|
|
381
420
|
try {
|
|
@@ -448,7 +487,9 @@ let CodingAgentDispatchCompanionService = class CodingAgentDispatchCompanionServ
|
|
|
448
487
|
// process this service has not started, and a status field that overstates
|
|
449
488
|
// its knowledge is worse than one that is narrow about it.
|
|
450
489
|
codingAgentRegistered: this.agentsService.getAgent(APPLICATION_CODING_AGENT_REF) !== undefined,
|
|
451
|
-
activeRun: this.activeRun ? {
|
|
490
|
+
activeRun: this.activeRun ? { taskId: this.activeRun.taskId, startedAt: this.activeRun.startedAt } : null,
|
|
491
|
+
// The answerable set: what is parked waiting for an operator response.
|
|
492
|
+
pendingQuestions: this.listPendingCodingQuestions(),
|
|
452
493
|
limits: {
|
|
453
494
|
defaultTimeoutMs: DISPATCH_DEFAULT_TIMEOUT_MS,
|
|
454
495
|
hardMaxTimeoutMs: DISPATCH_HARD_MAX_TIMEOUT_MS,
|
|
@@ -479,6 +520,8 @@ let CodingAgentDispatchCompanionService = class CodingAgentDispatchCompanionServ
|
|
|
479
520
|
async createApplicationCodingTask(task, baseline, sessionContext) {
|
|
480
521
|
const payload = CompanionCreateActorTaskRequestSchema.parse({
|
|
481
522
|
title: `Application coding task ${task.taskRef}`,
|
|
523
|
+
/* The cross-plane join key — the board's build-plan row this task executes (Phase 4, R5). */
|
|
524
|
+
workbenchBuildPlanTaskId: sanitizeWorkbenchCreationPlaneIdentity(task.taskRef),
|
|
482
525
|
description: `Typed application coding task for ${task.objectiveRef}; acceptance remains outside the coding host.`,
|
|
483
526
|
topic: Actor_Task_Topics.IMPLEMENTATION,
|
|
484
527
|
status: FlowsActors_Status.PROCESSING,
|
|
@@ -515,7 +558,15 @@ let CodingAgentDispatchCompanionService = class CodingAgentDispatchCompanionServ
|
|
|
515
558
|
* evidence. This method runs inside the worktree lock and therefore is the
|
|
516
559
|
* sole typed path allowed to observe its own before/after Git boundary.
|
|
517
560
|
*/
|
|
518
|
-
async executeApplicationCodingTask(task, renderedPrompt, verificationPlans, durableTask, baseline
|
|
561
|
+
async executeApplicationCodingTask(task, renderedPrompt, verificationPlans, durableTask, baseline,
|
|
562
|
+
/**
|
|
563
|
+
* Present when this run ANSWERS a parked question rather than starting the
|
|
564
|
+
* task: the agent session is resumed by id via `session/load` and the answer
|
|
565
|
+
* is delivered as the next turn. The task's mutation scope, verification plan
|
|
566
|
+
* and original baseline are unchanged — the resume is held to exactly the
|
|
567
|
+
* bounds the first run was.
|
|
568
|
+
*/
|
|
569
|
+
resume) {
|
|
519
570
|
let runSession;
|
|
520
571
|
let runStep;
|
|
521
572
|
const traceabilityErrors = [];
|
|
@@ -560,7 +611,11 @@ let CodingAgentDispatchCompanionService = class CodingAgentDispatchCompanionServ
|
|
|
560
611
|
agentRef: APPLICATION_CODING_AGENT_REF,
|
|
561
612
|
initiator: {},
|
|
562
613
|
invocationContext: [],
|
|
563
|
-
|
|
614
|
+
// A resume delivers the operator's ANSWER as the turn and re-enters the
|
|
615
|
+
// parked session; a first run delivers the rendered task.
|
|
616
|
+
input: resume
|
|
617
|
+
? { prompt: resume.answerPrompt, continuationOfSessionId: resume.continuationOfSessionId }
|
|
618
|
+
: { prompt: renderedPrompt },
|
|
564
619
|
output: { finalMessage: '', stopReason: CodingAgent_StopReason.END_TURN },
|
|
565
620
|
executionContext: { callTimestamp: new Date().toISOString() },
|
|
566
621
|
artifactBindings: [],
|
|
@@ -608,6 +663,16 @@ let CodingAgentDispatchCompanionService = class CodingAgentDispatchCompanionServ
|
|
|
608
663
|
&& RETAINED_CODING_SESSION_EVENT_KINDS.has(event.kind)) {
|
|
609
664
|
retainedCodingSessionFrames.push(event);
|
|
610
665
|
}
|
|
666
|
+
this.publishCodingSessionFrame(durableTask._id, { channel: 'event', payload: event });
|
|
667
|
+
},
|
|
668
|
+
// The JUDGMENT half of the interactive lane: classify each end-of-turn
|
|
669
|
+
// message so the engine ladder can auto-continue a self-pause and park
|
|
670
|
+
// a genuine question. The engine fails OPEN if this throws, so a
|
|
671
|
+
// classifier fault degrades to "the turn is complete" rather than
|
|
672
|
+
// hanging the run — this method may therefore throw freely.
|
|
673
|
+
classifyCodingTurnEnd: (input) => this.classifyCodingTurnEnd(input),
|
|
674
|
+
onCodingSessionStateChange: (state) => {
|
|
675
|
+
this.publishCodingSessionFrame(durableTask._id, { channel: 'state', payload: state });
|
|
611
676
|
},
|
|
612
677
|
...(this.activeRun ? { codingSessionAbortSignal: this.activeRun.abortController.signal } : {}),
|
|
613
678
|
});
|
|
@@ -618,6 +683,31 @@ let CodingAgentDispatchCompanionService = class CodingAgentDispatchCompanionServ
|
|
|
618
683
|
codingPermissionDecisions = codingOutput?.permissionDecisions;
|
|
619
684
|
const text = codingOutput?.finalMessage;
|
|
620
685
|
agentStopReason = codingOutput?.stopReason;
|
|
686
|
+
// A PARKED run stopped WITHOUT finishing to ask the operator a question.
|
|
687
|
+
// Its `finalMessage` is the question and its partial edits are NOT a final
|
|
688
|
+
// change set — so it must skip assessment, verification and the
|
|
689
|
+
// terminal disposition entirely, and instead record an answerable,
|
|
690
|
+
// non-terminal state. Handled here, before the CANCELLED/empty checks,
|
|
691
|
+
// because a question is a non-empty END_TURN message that would otherwise
|
|
692
|
+
// read as a completed working result.
|
|
693
|
+
if (codingOutput?.suspension) {
|
|
694
|
+
await this.recordParkedApplicationCodingTask({
|
|
695
|
+
task,
|
|
696
|
+
verificationPlans,
|
|
697
|
+
durableTask,
|
|
698
|
+
baseline,
|
|
699
|
+
suspension: codingOutput.suspension,
|
|
700
|
+
output: codingOutput,
|
|
701
|
+
usage: codingUsage,
|
|
702
|
+
codingSessionEventCount,
|
|
703
|
+
retainedCodingSessionFrames,
|
|
704
|
+
startedAtMs,
|
|
705
|
+
runSession,
|
|
706
|
+
runStep,
|
|
707
|
+
traceBestEffort,
|
|
708
|
+
});
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
621
711
|
// A CANCELLED turn is not a completed one, and its partial change set must
|
|
622
712
|
// not be read as a working result. Refused here rather than downstream so
|
|
623
713
|
// the disposition names the actual reason.
|
|
@@ -648,39 +738,10 @@ let CodingAgentDispatchCompanionService = class CodingAgentDispatchCompanionServ
|
|
|
648
738
|
// application package/cache if started together. The ordered outcomes are
|
|
649
739
|
// easier to inspect and avoid turning a bounded coding task into an
|
|
650
740
|
// accidental local-build fan-out.
|
|
651
|
-
const
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
try {
|
|
656
|
-
verification.push({
|
|
657
|
-
checkRef: plan.checkRef,
|
|
658
|
-
// The FK-resolution check is not a CLI command: it runs in the companion's
|
|
659
|
-
// introspection subprocess (fresh working-tree import), so it branches before
|
|
660
|
-
// the argv-plan path.
|
|
661
|
-
outcome: plan.kind === VerificationKind.FRONTEND_FK_RESOLUTION
|
|
662
|
-
? await this.runForeignKeyResolutionVerification()
|
|
663
|
-
: plan.kind === VerificationKind.SETTINGS_PLACEMENT_CONTENT
|
|
664
|
-
? await this.runSettingsPlacementContentVerification()
|
|
665
|
-
: await this.runVerification(this.buildVerificationPlan(plan.kind, plan.path ?? undefined)),
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
catch (error) {
|
|
669
|
-
verificationInfrastructureError ??= error;
|
|
670
|
-
verification.push({
|
|
671
|
-
checkRef: plan.checkRef,
|
|
672
|
-
outcome: {
|
|
673
|
-
kind: plan.kind,
|
|
674
|
-
path: plan.path,
|
|
675
|
-
success: false,
|
|
676
|
-
message: describeCaughtError(error),
|
|
677
|
-
stdoutTail: '',
|
|
678
|
-
stderrTail: '',
|
|
679
|
-
},
|
|
680
|
-
});
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
}
|
|
741
|
+
const shouldVerify = !runError && !captureError && scopeAssessment?.allowed === true;
|
|
742
|
+
const { verification, infrastructureError: verificationInfrastructureError } = shouldVerify
|
|
743
|
+
? await this.executeVerificationPlans(verificationPlans)
|
|
744
|
+
: { verification: [], infrastructureError: null };
|
|
684
745
|
const failedVerification = verification.find(({ outcome }) => !outcome.success) ?? null;
|
|
685
746
|
if (agentOutput) {
|
|
686
747
|
await traceBestEffort('write-agent-output', () => this.traceOperationArtifact(runSession, runStep, 'application-coding-task-agent-output.txt', agentOutput));
|
|
@@ -789,6 +850,254 @@ let CodingAgentDispatchCompanionService = class CodingAgentDispatchCompanionServ
|
|
|
789
850
|
payload: output,
|
|
790
851
|
}));
|
|
791
852
|
}
|
|
853
|
+
// ================================================================
|
|
854
|
+
// Interactive lane — classifier, live relay, park & resume
|
|
855
|
+
// ================================================================
|
|
856
|
+
/**
|
|
857
|
+
* Classify a coding agent's end-of-turn message through the dedicated
|
|
858
|
+
* structured classifier agent. Throws on any fault; the ENGINE ladder wraps
|
|
859
|
+
* that into `CLASSIFIER_UNAVAILABLE` and settles, so this never has to invent
|
|
860
|
+
* a safe default of its own.
|
|
861
|
+
*/
|
|
862
|
+
async classifyCodingTurnEnd(input) {
|
|
863
|
+
const prompt = [
|
|
864
|
+
'A coding agent ended its turn with the message below. Classify what the message means so an '
|
|
865
|
+
+ 'autonomous runner can decide whether to continue automatically, or to surface a question to '
|
|
866
|
+
+ 'the operator.',
|
|
867
|
+
'',
|
|
868
|
+
'# Agent end-of-turn message',
|
|
869
|
+
input.finalMessage,
|
|
870
|
+
].join('\n');
|
|
871
|
+
const invocation = {
|
|
872
|
+
agentRef: APPLICATION_CODING_TURN_CLASSIFIER_AGENT_REF,
|
|
873
|
+
initiator: {},
|
|
874
|
+
invocationContext: [],
|
|
875
|
+
input: { prompt, schema: CodingTurnEndClassificationOutputSchema },
|
|
876
|
+
output: { object: {} },
|
|
877
|
+
executionContext: {},
|
|
878
|
+
artifactBindings: [],
|
|
879
|
+
};
|
|
880
|
+
const response = await this.agentsService.invokeAgent(invocation);
|
|
881
|
+
const raw = response.output?.object;
|
|
882
|
+
const parsed = CodingTurnEndClassificationOutputSchema.safeParse(raw);
|
|
883
|
+
if (!parsed.success) {
|
|
884
|
+
// A malformed classifier answer is a classifier fault: let the ladder fail
|
|
885
|
+
// open rather than guess which situation the model meant.
|
|
886
|
+
throw new Error('Coding turn-end classifier returned an unparseable result.');
|
|
887
|
+
}
|
|
888
|
+
return parsed.data.classification;
|
|
889
|
+
}
|
|
890
|
+
/** Fan one live frame out to a task's SSE subscribers. Best-effort, never throws into the run. */
|
|
891
|
+
publishCodingSessionFrame(taskId, frame) {
|
|
892
|
+
const listeners = this.codingSessionSubscribers.get(taskId);
|
|
893
|
+
if (!listeners)
|
|
894
|
+
return;
|
|
895
|
+
for (const listener of listeners) {
|
|
896
|
+
try {
|
|
897
|
+
listener(frame);
|
|
898
|
+
}
|
|
899
|
+
catch {
|
|
900
|
+
// A subscriber must never be able to fail the run it observes.
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
/**
|
|
905
|
+
* Subscribe to a task's live coding frames. Returns an unsubscribe function.
|
|
906
|
+
*
|
|
907
|
+
* Frames flow only while a run is ACTIVE for that task; a subscriber that
|
|
908
|
+
* attaches after the run parked or finished simply receives nothing further,
|
|
909
|
+
* which is why the SSE endpoint sends the current pending question up front.
|
|
910
|
+
*/
|
|
911
|
+
subscribeToCodingSession(taskId, listener) {
|
|
912
|
+
let listeners = this.codingSessionSubscribers.get(taskId);
|
|
913
|
+
if (!listeners) {
|
|
914
|
+
listeners = new Set();
|
|
915
|
+
this.codingSessionSubscribers.set(taskId, listeners);
|
|
916
|
+
}
|
|
917
|
+
listeners.add(listener);
|
|
918
|
+
return () => {
|
|
919
|
+
const set = this.codingSessionSubscribers.get(taskId);
|
|
920
|
+
if (!set)
|
|
921
|
+
return;
|
|
922
|
+
set.delete(listener);
|
|
923
|
+
if (set.size === 0)
|
|
924
|
+
this.codingSessionSubscribers.delete(taskId);
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
/** The questions currently awaiting an operator answer, for status/UX. */
|
|
928
|
+
listPendingCodingQuestions() {
|
|
929
|
+
return [...this.parkedCodingSessions.values()].map((parked) => ({
|
|
930
|
+
taskId: parked.durableTask._id,
|
|
931
|
+
taskRef: parked.task.taskRef,
|
|
932
|
+
question: parked.suspension.question,
|
|
933
|
+
parkedAt: parked.parkedAt,
|
|
934
|
+
resumable: parked.suspension.resumable,
|
|
935
|
+
}));
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* Record a run that parked on a question: persist the non-terminal durable row
|
|
939
|
+
* (status PROCESSING, disposition AWAITING_OPERATOR_INPUT, question on the
|
|
940
|
+
* output) and retain the answerable state in memory for the resume door.
|
|
941
|
+
*
|
|
942
|
+
* Deliberately skips change-set assessment and verification: a parked run's
|
|
943
|
+
* edits are partial by definition, and assessing them as a final change set is
|
|
944
|
+
* exactly the "read a suspended turn as complete" mistake the suspension field
|
|
945
|
+
* exists to prevent.
|
|
946
|
+
*/
|
|
947
|
+
async recordParkedApplicationCodingTask(params) {
|
|
948
|
+
const { task, durableTask, baseline, suspension, output, verificationPlans } = params;
|
|
949
|
+
this.parkedCodingSessions.set(durableTask._id, {
|
|
950
|
+
durableTask,
|
|
951
|
+
task,
|
|
952
|
+
verificationPlans,
|
|
953
|
+
baseline,
|
|
954
|
+
suspension,
|
|
955
|
+
parkedAt: new Date().toISOString(),
|
|
956
|
+
});
|
|
957
|
+
const durableOutput = {
|
|
958
|
+
succeeded: false,
|
|
959
|
+
disposition: ApplicationCodingTaskDisposition.AWAITING_OPERATOR_INPUT,
|
|
960
|
+
durationMs: Date.now() - params.startedAtMs,
|
|
961
|
+
// The question the operator must answer, front and centre.
|
|
962
|
+
pendingQuestion: suspension.question,
|
|
963
|
+
suspension,
|
|
964
|
+
agentOutputTail: (output.finalMessage ?? '').slice(-OUTPUT_TAIL_CHARS),
|
|
965
|
+
...(output.stopReason ? { agentStopReason: output.stopReason } : {}),
|
|
966
|
+
...(output.turnCount ? { turnCount: output.turnCount } : {}),
|
|
967
|
+
...(output.continuations && output.continuations.length > 0 ? { continuations: output.continuations } : {}),
|
|
968
|
+
...(params.codingSessionEventCount > 0 ? { codingSessionEventCount: params.codingSessionEventCount } : {}),
|
|
969
|
+
...(params.retainedCodingSessionFrames.length > 0 ? { codingSessionFrames: params.retainedCodingSessionFrames } : {}),
|
|
970
|
+
...(params.usage ? { usage: params.usage } : {}),
|
|
971
|
+
...(output.deniedPermissionCount !== undefined ? { deniedPermissionCount: output.deniedPermissionCount } : {}),
|
|
972
|
+
...(output.permissionDecisions && output.permissionDecisions.length > 0 ? { permissionDecisions: output.permissionDecisions } : {}),
|
|
973
|
+
};
|
|
974
|
+
// Status stays PROCESSING: the task is genuinely still in flight, waiting on
|
|
975
|
+
// the operator. It is not COMPLETED (nothing was accepted) and not FAILED
|
|
976
|
+
// (nothing went wrong) — the disposition carries the real state.
|
|
977
|
+
const updatePayload = CompanionUpdateActorTaskRequestSchema.parse({
|
|
978
|
+
status: FlowsActors_Status.PROCESSING,
|
|
979
|
+
output: durableOutput,
|
|
980
|
+
});
|
|
981
|
+
await this.executionsService.updateActorTask(durableTask._id, updatePayload, params.runSession);
|
|
982
|
+
await params.traceBestEffort('record-awaiting-input', () => this.traceOperationStart({
|
|
983
|
+
sessionContext: params.runSession,
|
|
984
|
+
step: params.runStep,
|
|
985
|
+
type: 'application-coding-task-awaiting-input',
|
|
986
|
+
summary: `Application coding task ${task.taskRef} is awaiting an operator answer`,
|
|
987
|
+
payload: { taskId: durableTask._id, question: suspension.question, resumable: suspension.resumable },
|
|
988
|
+
}));
|
|
989
|
+
}
|
|
990
|
+
/** The in-process answerable state for a parked task, if this process is the one that parked it. */
|
|
991
|
+
getParkedCodingSessionState(taskId) {
|
|
992
|
+
return this.parkedCodingSessions.get(taskId) ?? null;
|
|
993
|
+
}
|
|
994
|
+
/**
|
|
995
|
+
* Load the DURABLE facts needed to RECONSTRUCT a parked task's answerable state
|
|
996
|
+
* after the in-process map has lost it (a companion restart).
|
|
997
|
+
*
|
|
998
|
+
* Returns the build-plan `taskRef` and the persisted `suspension` — enough for
|
|
999
|
+
* the build-dispatch layer to re-compose the task contract and rebuild a
|
|
1000
|
+
* {@link ParkedCodingSessionState}. `null` when the row is not a parked coding
|
|
1001
|
+
* task (wrong actor, no suspension, or not found).
|
|
1002
|
+
*/
|
|
1003
|
+
async loadPersistedParkedCodingTask(taskId, sessionContext) {
|
|
1004
|
+
let durableTask;
|
|
1005
|
+
try {
|
|
1006
|
+
durableTask = await this.executionsService.getActorTask(taskId, sessionContext);
|
|
1007
|
+
}
|
|
1008
|
+
catch {
|
|
1009
|
+
return null;
|
|
1010
|
+
}
|
|
1011
|
+
const row = durableTask;
|
|
1012
|
+
if (row.actors?.actorRef !== APPLICATION_CODING_AGENT_REF)
|
|
1013
|
+
return null;
|
|
1014
|
+
const taskRef = isRecordValue(row.input) && typeof row.input.taskRef === 'string' ? row.input.taskRef : null;
|
|
1015
|
+
const suspensionRaw = isRecordValue(row.output) ? row.output.suspension : undefined;
|
|
1016
|
+
const parsedSuspension = CodingAgent_SessionSuspensionSchema.safeParse(suspensionRaw);
|
|
1017
|
+
if (!taskRef || !parsedSuspension.success)
|
|
1018
|
+
return null;
|
|
1019
|
+
return { taskRef, suspension: parsedSuspension.data, durableTask };
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
* Answer a parked coding task's question and resume the SAME agent session.
|
|
1023
|
+
*
|
|
1024
|
+
* The IN-PROCESS door: it answers a task THIS process parked. For a task whose
|
|
1025
|
+
* in-process state was lost to a restart, the caller reconstructs a
|
|
1026
|
+
* {@link ParkedCodingSessionState} (from the build plan) and uses
|
|
1027
|
+
* {@link resumeParkedCodingTask} directly.
|
|
1028
|
+
*/
|
|
1029
|
+
async respondToApplicationCodingTaskQuestion(taskId, answer) {
|
|
1030
|
+
// A missing answer is a VALIDATION 400 regardless of whether a task is parked
|
|
1031
|
+
// — it is a malformed request, not a state conflict.
|
|
1032
|
+
this.admitTypedInput(() => {
|
|
1033
|
+
if (answer.trim().length === 0)
|
|
1034
|
+
throw new Error('empty answer');
|
|
1035
|
+
return answer;
|
|
1036
|
+
}, 'An answer is required to resume a parked coding task.');
|
|
1037
|
+
const parked = this.parkedCodingSessions.get(taskId);
|
|
1038
|
+
if (!parked) {
|
|
1039
|
+
throw this.buildDispatchConflictError(`No coding task is awaiting an answer under id ${taskId} in this process. `
|
|
1040
|
+
+ 'A companion restart drops in-flight answerable state; re-dispatch the task instead.');
|
|
1041
|
+
}
|
|
1042
|
+
return this.resumeParkedCodingTask(parked, answer);
|
|
1043
|
+
}
|
|
1044
|
+
/**
|
|
1045
|
+
* Run a resume against an EXPLICIT parked state — from the in-process map or
|
|
1046
|
+
* reconstructed from the build plan after a restart.
|
|
1047
|
+
*
|
|
1048
|
+
* Runs under the worktree mutation lock exactly like a fresh dispatch (a resume
|
|
1049
|
+
* mutates the same worktree) and re-enters the turn ladder through
|
|
1050
|
+
* `session/load`, so the agent continues with its full context. The mutation
|
|
1051
|
+
* scope and verification plan are the parked contract's; a resume is held to the
|
|
1052
|
+
* same bounds as the first run.
|
|
1053
|
+
*/
|
|
1054
|
+
async resumeParkedCodingTask(parked, answer) {
|
|
1055
|
+
const trimmedAnswer = this.admitTypedInput(() => {
|
|
1056
|
+
const value = answer.trim();
|
|
1057
|
+
if (value.length === 0)
|
|
1058
|
+
throw new Error('empty answer');
|
|
1059
|
+
return value;
|
|
1060
|
+
}, 'An answer is required to resume a parked coding task.');
|
|
1061
|
+
const taskId = parked.durableTask._id;
|
|
1062
|
+
if (!parked.suspension.resumable) {
|
|
1063
|
+
throw this.buildDispatchConflictError(`Coding task ${taskId} parked on a question, but its agent does not support session resume, `
|
|
1064
|
+
+ 'so the answer cannot be delivered to the same session. Re-dispatch the task with the answer folded into the objective.');
|
|
1065
|
+
}
|
|
1066
|
+
if (this.activeRun) {
|
|
1067
|
+
throw this.buildDispatchConflictError(`A coding-agent run is already active (task ${this.activeRun.taskId}). Answers are serialized behind the same worktree lock.`);
|
|
1068
|
+
}
|
|
1069
|
+
// Taken out of the answerable set for the duration of the resume; a resume
|
|
1070
|
+
// that parks again re-registers it through the same suspension branch.
|
|
1071
|
+
this.parkedCodingSessions.delete(taskId);
|
|
1072
|
+
const admission = createDeferred();
|
|
1073
|
+
const resumeRun = withDedicatedFileLock(this.getWorkspaceMutationLockPath(), async () => {
|
|
1074
|
+
this.activeRun = { taskId, startedAt: new Date().toISOString(), abortController: new AbortController() };
|
|
1075
|
+
const settlement = createDeferred();
|
|
1076
|
+
this.applicationCodingTaskSettlements.set(taskId, { promise: settlement.promise, resolve: () => settlement.resolve(undefined) });
|
|
1077
|
+
admission.resolve({
|
|
1078
|
+
taskId,
|
|
1079
|
+
status: FlowsActors_Status.PROCESSING,
|
|
1080
|
+
taskRef: parked.task.taskRef,
|
|
1081
|
+
baselineHeadSha: parked.baseline.headSha,
|
|
1082
|
+
baselineDirtyFileCount: Object.keys(parked.baseline.files).length,
|
|
1083
|
+
});
|
|
1084
|
+
try {
|
|
1085
|
+
await this.executeApplicationCodingTask(parked.task, renderApplicationCodingTaskAgentPrompt(parked.task), parked.verificationPlans, parked.durableTask, parked.baseline, { continuationOfSessionId: parked.suspension.sessionId, answerPrompt: trimmedAnswer });
|
|
1086
|
+
}
|
|
1087
|
+
finally {
|
|
1088
|
+
this.activeRun = null;
|
|
1089
|
+
this.applicationCodingTaskSettlements.get(taskId)?.resolve();
|
|
1090
|
+
}
|
|
1091
|
+
}, { retries: { retries: 0 } });
|
|
1092
|
+
resumeRun.catch((error) => {
|
|
1093
|
+
admission.reject(this.mapLockError(error));
|
|
1094
|
+
this.logDebug('Application coding-task resume run terminated with error', {
|
|
1095
|
+
taskId,
|
|
1096
|
+
error: describeCaughtError(error),
|
|
1097
|
+
});
|
|
1098
|
+
});
|
|
1099
|
+
return admission.promise;
|
|
1100
|
+
}
|
|
792
1101
|
buildApplicationCodingTaskTraceSummary(task) {
|
|
793
1102
|
return {
|
|
794
1103
|
taskRef: task.taskRef,
|
|
@@ -914,6 +1223,67 @@ let CodingAgentDispatchCompanionService = class CodingAgentDispatchCompanionServ
|
|
|
914
1223
|
stderrTail: '',
|
|
915
1224
|
};
|
|
916
1225
|
}
|
|
1226
|
+
/**
|
|
1227
|
+
* Run a resolved verification plan set and return one outcome per check.
|
|
1228
|
+
*
|
|
1229
|
+
* Extracted from the coding-task dispatch so the SAME executor serves a second caller: the
|
|
1230
|
+
* `DETERMINISTIC_CLI` playbook tier, which verifies an already-built application and dispatches no
|
|
1231
|
+
* agent (issue #147). The alternative was a second loop that re-derived which kinds branch away
|
|
1232
|
+
* from the argv path — and the two would drift the first time a `VerificationKind` was added,
|
|
1233
|
+
* silently, because a missed kind falls through to a typecheck that passes.
|
|
1234
|
+
*
|
|
1235
|
+
* A thrown error is an INFRASTRUCTURE failure, not a failing check: the subprocess could not be
|
|
1236
|
+
* run at all. It is recorded as a failed outcome so the caller sees which check was affected, and
|
|
1237
|
+
* surfaced separately so a caller can tell "the application is broken" from "we could not ask".
|
|
1238
|
+
*/
|
|
1239
|
+
async executeVerificationPlans(plans) {
|
|
1240
|
+
const verification = [];
|
|
1241
|
+
let infrastructureError = null;
|
|
1242
|
+
for (const plan of plans) {
|
|
1243
|
+
try {
|
|
1244
|
+
verification.push({
|
|
1245
|
+
checkRef: plan.checkRef,
|
|
1246
|
+
// The FK-resolution check is not a CLI command: it runs in the companion's
|
|
1247
|
+
// introspection subprocess (fresh working-tree import), so it branches before
|
|
1248
|
+
// the argv-plan path.
|
|
1249
|
+
outcome: plan.kind === VerificationKind.FRONTEND_FK_RESOLUTION
|
|
1250
|
+
? await this.runForeignKeyResolutionVerification()
|
|
1251
|
+
: plan.kind === VerificationKind.SETTINGS_PLACEMENT_CONTENT
|
|
1252
|
+
? await this.runSettingsPlacementContentVerification()
|
|
1253
|
+
: await this.runVerification(this.buildVerificationPlan(plan.kind, plan.path ?? undefined)),
|
|
1254
|
+
});
|
|
1255
|
+
}
|
|
1256
|
+
catch (error) {
|
|
1257
|
+
infrastructureError ??= error;
|
|
1258
|
+
verification.push({
|
|
1259
|
+
checkRef: plan.checkRef,
|
|
1260
|
+
outcome: {
|
|
1261
|
+
kind: plan.kind,
|
|
1262
|
+
path: plan.path,
|
|
1263
|
+
success: false,
|
|
1264
|
+
message: describeCaughtError(error),
|
|
1265
|
+
stdoutTail: '',
|
|
1266
|
+
stderrTail: '',
|
|
1267
|
+
},
|
|
1268
|
+
});
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
return { verification, infrastructureError };
|
|
1272
|
+
}
|
|
1273
|
+
/**
|
|
1274
|
+
* Run named verification checks against the application, outside any agent dispatch.
|
|
1275
|
+
*
|
|
1276
|
+
* The public door for the `DETERMINISTIC_CLI` tier. Check refs resolve through the same closed
|
|
1277
|
+
* `APPLICATION_CODING_TASK_VERIFICATION_CATALOG` a coding task uses, so an unknown ref is refused
|
|
1278
|
+
* here rather than becoming an unrun check that reports success by absence.
|
|
1279
|
+
*
|
|
1280
|
+
* Deliberately takes NO worktree lock and captures NO change set: this reads the application, and
|
|
1281
|
+
* pretending otherwise would serialize verification against the single-flight coding lane for no
|
|
1282
|
+
* reason.
|
|
1283
|
+
*/
|
|
1284
|
+
async runApplicationVerificationChecks(checkRefs) {
|
|
1285
|
+
return this.executeVerificationPlans(resolveApplicationCodingTaskVerificationPlans(checkRefs));
|
|
1286
|
+
}
|
|
917
1287
|
async runVerification(plan) {
|
|
918
1288
|
try {
|
|
919
1289
|
const result = await executeBoundedSubprocess({
|