@zq-silk/yui 0.15.7 → 0.15.8
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/ARCHITECTURE.md +192 -399
- package/README.md +127 -1149
- package/dist/agent/adapterCatalog.js +15 -2
- package/dist/agent/agent.js +23 -3
- package/dist/agent/argumentPolicy.js +7 -1
- package/dist/agent/connectionPlan.js +62 -0
- package/dist/agent/executionComponents.js +158 -0
- package/dist/agent/launchEnvironment.js +31 -3
- package/dist/agent/managedRuntimeEnvironment.js +3 -5
- package/dist/{turn/turn.js → agentRun/agentRun.js} +166 -109
- package/dist/{turn/turnIdentity.js → agentRun/runIdentity.js} +4 -4
- package/dist/brief/taskBrief.js +12 -0
- package/dist/cli/agentConfigurationPicker.js +13 -0
- package/dist/cli/commandCatalog.js +157 -70
- package/dist/cli/interactionCandidates.js +5 -5
- package/dist/cli/interactionPolicy.js +38 -8
- package/dist/cli/invocationRouter.js +1 -1
- package/dist/cli/managedDiagnostics.js +28 -0
- package/dist/cli/operatorWizard.js +1 -7
- package/dist/cli/roleOptionOrder.js +27 -0
- package/dist/cli/roleWizard.js +50 -14
- package/dist/cli/updateOrchestrator.js +1 -1
- package/dist/cli/updatePorts.js +3 -4
- package/dist/cli.js +178 -95
- package/dist/commands/agentCommands.js +72 -14
- package/dist/commands/capabilityCommands.js +9 -6
- package/dist/commands/configCommands.js +20 -20
- package/dist/commands/deliveryGuardPreflight.js +2 -2
- package/dist/commands/executionAuditCommands.js +24 -24
- package/dist/commands/globalRoleCommands.js +1 -1
- package/dist/commands/grantCommands.js +4 -4
- package/dist/commands/operatorCommands.js +1 -7
- package/dist/commands/projectCommands.js +4 -4
- package/dist/commands/resourcesCommands.js +2 -2
- package/dist/commands/roleConfiguration.js +25 -5
- package/dist/commands/roleRuntimeGuard.js +4 -5
- package/dist/commands/sessionCommands.js +3 -7
- package/dist/commands/taskActivationCommands.js +259 -0
- package/dist/commands/taskActor.js +28 -49
- package/dist/commands/taskCommands.js +1188 -710
- package/dist/commands/taskContextCommand.js +39 -583
- package/dist/commands/taskExecutionCommands.js +32 -32
- package/dist/commands/taskInputCommands.js +40 -104
- package/dist/commands/taskIntegrationCommands.js +3 -2
- package/dist/commands/taskIntegrationQueueCommands.js +1 -1
- package/dist/commands/taskNextActionCommand.js +8 -8
- package/dist/commands/taskOverviewCommand.js +33 -45
- package/dist/commands/taskRemoteDeliveryCommand.js +2 -2
- package/dist/commands/taskRoleRuntimeStatus.js +133 -102
- package/dist/commands/telemetryCommands.js +36 -38
- package/dist/config/configCatalog.js +4 -4
- package/dist/config/yuiConfig.js +8 -8
- package/dist/context/contextSnapshot.js +10 -10
- package/dist/context/dispatchContext.js +11 -11
- package/dist/context/roleSessionContext.js +6 -3
- package/dist/context/{turnContextPack.js → runContextPack.js} +146 -81
- package/dist/context/{turnInputContract.js → runInputContract.js} +73 -60
- package/dist/context/sessionBootstrapManifest.js +21 -2
- package/dist/context/sourceRunContext.js +30 -0
- package/dist/context/taskContext.js +458 -0
- package/dist/context/wakeNotification.js +27 -27
- package/dist/controller/agentRuntimeObserver.js +21 -24
- package/dist/controller/capabilityBridge.js +17 -6
- package/dist/controller/clientRuntime.js +65 -92
- package/dist/controller/controller.js +114 -188
- package/dist/controller/fileSchedulerStoreAdapter.js +787 -887
- package/dist/controller/jobControl.js +54 -85
- package/dist/controller/resourceInventory.js +8 -27
- package/dist/controller/resourceInventoryLinux.js +12 -13
- package/dist/controller/runtime.js +529 -479
- package/dist/controller/runtimeEventInbox.js +55 -25
- package/dist/controller/runtimeEventProcessor.js +22 -31
- package/dist/controller/{runtimeHookTurnFence.js → runtimeHookRunFence.js} +91 -115
- package/dist/controller/runtimeLaunchCoordinator.js +80 -426
- package/dist/controller/runtimeObservationHook.js +14 -18
- package/dist/controller/sessionNotify.js +16 -24
- package/dist/controller/sessionOwnerReconciliation.js +168 -50
- package/dist/controller/structuredProviderObservation.js +138 -99
- package/dist/coordination/workMailbox.js +3 -3
- package/dist/coordination/workMailboxQueue.js +36 -33
- package/dist/core/boundedRpc.js +8 -1
- package/dist/core/controllerClient.js +20 -1
- package/dist/core/controllerServer.js +4 -4
- package/dist/doctor/doctor.js +13 -2
- package/dist/domain/agentResultTransport.js +9 -9
- package/dist/execution/codexThreadNaming.js +2 -8
- package/dist/execution/executionHealth.js +51 -63
- package/dist/execution/reviewMainRun.js +137 -0
- package/dist/execution/workItemExecution.js +28 -29
- package/dist/execution/workItemExecutionProjection.js +99 -107
- package/dist/execution/workItemMainRun.js +141 -0
- package/dist/executor/agentAdapter.js +227 -20
- package/dist/executor/agentConfigurationCatalog.js +126 -4
- package/dist/executor/agentConfigurationProbe.js +162 -4
- package/dist/executor/agentExecutor.js +79 -78
- package/dist/executor/effectiveLaunch.js +105 -18
- package/dist/executor/executorRegistry.js +29 -44
- package/dist/executor/fileRoleLaunchPlanner.js +229 -154
- package/dist/executor/workspacePreflightClassification.js +16 -16
- package/dist/grant/capabilityGrant.js +6 -3
- package/dist/input/inputRequest.js +12 -10
- package/dist/integration/gitIntegrationService.js +4 -11
- package/dist/integration/integrationQueueService.js +4 -4
- package/dist/interaction/operatorPresentation.js +1 -1
- package/dist/kernel/builtinCapabilities.js +247 -12
- package/dist/kernel/capabilityRegistry.js +64 -18
- package/dist/kernel/instanceHost.js +12 -1
- package/dist/kernel/kernelPorts.js +2 -2
- package/dist/lifecycle/canonicalLifecycleEvent.js +44 -49
- package/dist/lifecycle/exactRunTerminalization.js +449 -0
- package/dist/message/message.js +62 -6
- package/dist/message/messageContinuation.js +204 -0
- package/dist/observability/executionAudit.js +70 -72
- package/dist/observability/faultClassification.js +2 -2
- package/dist/observability/orchestrationMetrics.js +8 -8
- package/dist/operator/operatorSessionHistory.js +1 -7
- package/dist/output/agentConfigurationPresentation.js +8 -3
- package/dist/output/agentRunConfigurationPresentation.js +128 -0
- package/dist/output/rolePresentation.js +54 -3
- package/dist/plugins/pluginChild.js +104 -0
- package/dist/plugins/pluginIntent.js +26 -0
- package/dist/plugins/pluginInterpreter.js +43 -0
- package/dist/plugins/pluginPackage.js +101 -0
- package/dist/plugins/pluginProcess.js +112 -0
- package/dist/plugins/pluginService.js +380 -0
- package/dist/profile/agentProfile.js +1 -1
- package/dist/repository/gitWorkspace.js +26 -4
- package/dist/repository/project.js +19 -4
- package/dist/repository/taskBaseFreshness.js +13 -13
- package/dist/repository/taskWorkspaceCoordinator.js +20 -27
- package/dist/repository/taskWorkspacePreparer.js +344 -83
- package/dist/resources/autoResourceGc.js +3 -3
- package/dist/resources/liveReferences.js +3 -3
- package/dist/resources/projectResource.js +123 -0
- package/dist/resources/projectResourceService.js +421 -0
- package/dist/resources/resourceDiscovery.js +6 -6
- package/dist/resources/resourceGc.js +1 -1
- package/dist/resources/resourceRegistrar.js +1 -1
- package/dist/resources/resourceTypes.js +1 -1
- package/dist/review/deltaRecheck.js +3 -3
- package/dist/review/reviewAcceptance.js +16 -16
- package/dist/review/reviewDecision.js +7 -7
- package/dist/review/reviewRound.js +21 -20
- package/dist/review/reviewerAvailability.js +2 -2
- package/dist/role/role.js +51 -7
- package/dist/role/taskRoleUpdate.js +30 -0
- package/dist/runtime/acpProtocol.js +425 -0
- package/dist/runtime/acpSession.js +731 -0
- package/dist/runtime/acpSessionConfiguration.js +260 -0
- package/dist/runtime/agentDriver.js +30 -11
- package/dist/runtime/agentEndpoint.js +278 -0
- package/dist/runtime/agentEndpointIdentity.js +86 -0
- package/dist/runtime/agentEndpointOwnership.js +239 -0
- package/dist/runtime/agentError.js +2 -10
- package/dist/runtime/agentHost.js +565 -314
- package/dist/runtime/agentRunConfiguration.js +258 -0
- package/dist/runtime/builtinAgentDrivers.js +134 -18
- package/dist/runtime/builtinAgentErrorMappers.js +55 -3
- package/dist/runtime/builtinTranscriptUsage.js +1 -1
- package/dist/runtime/claude-process-owner +0 -0
- package/dist/runtime/codexAppServerRuntime.js +38 -30
- package/dist/runtime/codexInteractiveHost.js +41 -6
- package/dist/runtime/continuationManager.js +2 -6
- package/dist/runtime/executionEnvironment.js +30 -0
- package/dist/runtime/firstProgressAdvisory.js +11 -11
- package/dist/runtime/index.js +4 -3
- package/dist/runtime/jsonLineChannel.js +109 -0
- package/dist/runtime/launchBroker.js +91 -16
- package/dist/runtime/launchDiagnostics.js +2 -2
- package/dist/runtime/lifecycleReservation.js +10 -18
- package/dist/runtime/managedCaller.js +61 -17
- package/dist/runtime/nativeSessionControl.js +102 -0
- package/dist/runtime/ports.js +6 -21
- package/dist/runtime/processExitObservation.js +8 -7
- package/dist/runtime/promptEnvelope.js +17 -6
- package/dist/runtime/providerContinuation.js +3 -9
- package/dist/runtime/providerContinuationReconciliationService.js +4 -13
- package/dist/runtime/providerControl.js +2 -7
- package/dist/runtime/providerRuntimeIdentity.js +110 -222
- package/dist/runtime/providerRuntimeReconciler.js +5 -9
- package/dist/runtime/runtimeBinding.js +0 -1
- package/dist/runtime/runtimeContinuationProjection.js +4 -7
- package/dist/runtime/runtimeDeadlines.js +9 -0
- package/dist/runtime/runtimeHealthPolicy.js +1 -1
- package/dist/runtime/runtimeObservation.js +29 -65
- package/dist/runtime/runtimeProjection.js +43 -51
- package/dist/runtime/runtimeSessionCandidate.js +1 -3
- package/dist/runtime/sessionLaunchRequest.js +3 -7
- package/dist/runtime/sessionOwnerIdentity.js +7 -54
- package/dist/runtime/sessionOwnerRegistry.js +22 -17
- package/dist/runtime/sessionReconciliation.js +4 -8
- package/dist/runtime/sessionTerminationGuard.js +70 -259
- package/dist/runtime/sessionTokenMetrics.js +5 -16
- package/dist/runtime/structuredProviderHost.js +237 -117
- package/dist/runtime/taskRuntimeIsolation.js +39 -122
- package/dist/runtime/tmuxAdapters.js +39 -86
- package/dist/scheduler/activeRoleRunDelivery.js +354 -0
- package/dist/scheduler/leaderWakeupProcessor.js +75 -266
- package/dist/scheduler/operatorInputNotificationProcessor.js +1 -1
- package/dist/scheduler/ports.js +80 -9
- package/dist/scheduler/{roleTurnLiveness.js → roleRunLiveness.js} +26 -30
- package/dist/scheduler/{roleTurnStall.js → roleRunStall.js} +128 -139
- package/dist/scheduler/taskExecutionProjection.js +120 -124
- package/dist/scheduler/taskObservabilityProjection.js +29 -29
- package/dist/scheduler/taskWake.js +11 -4
- package/dist/scheduler/wakeReason.js +9 -1
- package/dist/setup/setupCommand.js +1 -0
- package/dist/storage/migrations/agentRunContract.js +159 -0
- package/dist/storage/migrations/removeRuntimeGeneration.js +207 -0
- package/dist/storage/sqliteSchema.js +431 -5
- package/dist/storage/sqliteStore.js +375 -220
- package/dist/storage/storageVersions.js +1 -1
- package/dist/storage/storeRpc.js +10 -5
- package/dist/storage/taskStore.js +13 -11
- package/dist/storage/upgrade/upgradeOrchestrator.js +5 -7
- package/dist/surface/surfaceContributions.js +102 -0
- package/dist/task/completionReadiness.js +32 -6
- package/dist/task/deliveryGuard.js +16 -16
- package/dist/task/draftPlan.js +72 -12
- package/dist/task/nextAction.js +144 -128
- package/dist/task/remoteDelivery.js +6 -6
- package/dist/task/task.js +184 -18
- package/dist/task/taskActivation.js +301 -0
- package/dist/task/taskActivationService.js +392 -0
- package/dist/task/taskRecordReference.js +5 -4
- package/dist/task/taskRecordRetirement.js +1 -1
- package/dist/telemetry/sqliteTelemetryStore.js +55 -68
- package/dist/telemetry/telemetryConfig.js +14 -14
- package/dist/telemetry/telemetryWiring.js +2 -2
- package/dist/web/assets/assetManifest.js +2 -0
- package/dist/web/assets/client/app.js +120 -20
- package/dist/web/assets/client/components.js +87 -54
- package/dist/web/assets/client/i18n.js +83 -41
- package/dist/web/assets/client/markdown.js +1 -1
- package/dist/web/assets/client/taskSurface.js +353 -0
- package/dist/web/assets/client/view.js +49 -44
- package/dist/web/assets/shell.js +1 -1
- package/dist/web/assets/styles/cards.js +22 -4
- package/dist/web/controllerWeb.js +60 -0
- package/dist/web/webMutation.js +28 -0
- package/dist/web/webServer.js +118 -8
- package/dist/web/webSnapshot.js +81 -74
- package/dist/web/webTaskSurface.js +64 -0
- package/dist/workItem/dependencyGate.js +1 -1
- package/dist/workItem/workItem.js +80 -48
- package/dist/workspace/workItemChangeSetManager.js +16 -9
- package/docs/agent-result-consumption.md +94 -0
- package/docs/agent-runtime-drivers.md +91 -0
- package/docs/architecture/README.md +38 -0
- package/docs/architecture/capabilities-and-resources.md +79 -0
- package/docs/managed-turn-and-session-runtime.md +222 -0
- package/docs/observability/README.md +81 -0
- package/docs/plugin-sdk.md +290 -0
- package/docs/provider-runtime.md +163 -0
- package/docs/release-workflow.md +303 -0
- package/docs/roles-and-configuration.md +113 -0
- package/docs/sqlite-control-plane-design.md +76 -0
- package/docs/task-dag-semantics.md +57 -0
- package/docs/task-delivery.md +103 -0
- package/docs/task-local-identity.md +6 -6
- package/docs/testing/verification-levels.md +86 -0
- package/i18n/README.zh-CN.md +98 -739
- package/package.json +2 -2
- package/skills/yui-leader/SKILL.md +130 -103
- package/skills/yui-leader/references/integration.md +39 -0
- package/skills/yui-leader/references/replicated-execution.md +42 -0
- package/skills/yui-leader/references/task-plugins.md +33 -0
- package/skills/yui-operator/SKILL.md +30 -59
- package/skills/yui-reviewer/SKILL.md +35 -36
- package/skills/yui-runtime/SKILL.md +88 -24
- package/skills/yui-runtime/references/publication.md +22 -0
- package/skills/yui-runtime/references/recovery.md +64 -0
- package/skills/yui-worker/SKILL.md +37 -39
- package/dist/cli/roleOptionCatalog.js +0 -68
- package/dist/context/sourceTurnContext.js +0 -30
- package/dist/execution/reviewMainTurn.js +0 -161
- package/dist/execution/workItemMainTurn.js +0 -164
- package/dist/lifecycle/exactTurnTerminalization.js +0 -407
- package/dist/runtime/preallocatedNativeSession.js +0 -13
- package/dist/runtime/runtimeStopReceipt.js +0 -42
- package/dist/scheduler/activeRoleTurnDelivery.js +0 -315
|
@@ -22,9 +22,6 @@ const KINDS = [
|
|
|
22
22
|
"session.ended",
|
|
23
23
|
"session.failed",
|
|
24
24
|
"conversation.observed",
|
|
25
|
-
"activation.started",
|
|
26
|
-
"activation.ended",
|
|
27
|
-
"activation.failed",
|
|
28
25
|
"goal.updated",
|
|
29
26
|
"goal.cleared",
|
|
30
27
|
"turn.accepted",
|
|
@@ -40,6 +37,7 @@ const KINDS = [
|
|
|
40
37
|
"continuation.reported",
|
|
41
38
|
"continuation.settled",
|
|
42
39
|
"input.accepted",
|
|
40
|
+
"input.rejected",
|
|
43
41
|
"input.delivery-unknown",
|
|
44
42
|
"activity.observed",
|
|
45
43
|
"observer.health"
|
|
@@ -53,8 +51,8 @@ const AUTHORITIES = [
|
|
|
53
51
|
"diagnostic"
|
|
54
52
|
];
|
|
55
53
|
/** Provider Turn facts always carry native Turn identity. `turnId` is only an
|
|
56
|
-
* optional correlation when that
|
|
57
|
-
const
|
|
54
|
+
* optional correlation when that AgentRun was started for a Yui AgentRun. */
|
|
55
|
+
const RUN_SCOPED = new Set([
|
|
58
56
|
"turn.accepted",
|
|
59
57
|
"turn.waiting",
|
|
60
58
|
"turn.completed",
|
|
@@ -103,19 +101,14 @@ export function createRuntimeObservation(input) {
|
|
|
103
101
|
throw new Error(`${input.kind} requires provider-structured or controller authority.`);
|
|
104
102
|
}
|
|
105
103
|
const fence = normalizeFence(input.fence);
|
|
106
|
-
if (
|
|
104
|
+
if (RUN_SCOPED.has(input.kind) && fence.nativeSessionId === undefined) {
|
|
107
105
|
throw new Error(`${input.kind} requires nativeSessionId.`);
|
|
108
106
|
}
|
|
109
|
-
if (
|
|
107
|
+
if (RUN_SCOPED.has(input.kind) && fence.nativeTurnId === undefined
|
|
110
108
|
&& fence.receiptId === undefined) {
|
|
111
109
|
throw new Error(`${input.kind} requires a native Turn or exact receipt identity.`);
|
|
112
110
|
}
|
|
113
|
-
if ((input.kind
|
|
114
|
-
|| input.kind === "native-work.snapshot")
|
|
115
|
-
&& fence.activationId === undefined) {
|
|
116
|
-
throw new Error(`${input.kind} requires activationId.`);
|
|
117
|
-
}
|
|
118
|
-
if ((input.kind === "conversation.observed" || input.kind.startsWith("activation.")
|
|
111
|
+
if ((input.kind === "conversation.observed"
|
|
119
112
|
|| CONTINUATION_SCOPED.has(input.kind) || input.kind === "native-work.snapshot")
|
|
120
113
|
&& fence.conversationId === undefined) {
|
|
121
114
|
throw new Error(`${input.kind} requires conversationId.`);
|
|
@@ -123,9 +116,6 @@ export function createRuntimeObservation(input) {
|
|
|
123
116
|
if (CONTINUATION_SCOPED.has(input.kind) && fence.continuationId === undefined) {
|
|
124
117
|
throw new Error(`${input.kind} requires continuationId.`);
|
|
125
118
|
}
|
|
126
|
-
if (CONTINUATION_SCOPED.has(input.kind) && fence.continuationGeneration === undefined) {
|
|
127
|
-
throw new Error(`${input.kind} requires continuationGeneration.`);
|
|
128
|
-
}
|
|
129
119
|
const payload = normalizePayload(input.kind, input.payload);
|
|
130
120
|
const sequence = input.sequence;
|
|
131
121
|
if (sequence !== undefined && (!Number.isSafeInteger(sequence) || sequence < 0)) {
|
|
@@ -155,14 +145,11 @@ export function runtimeObservationFenceMatches(expected, actual) {
|
|
|
155
145
|
for (const field of [
|
|
156
146
|
"taskId",
|
|
157
147
|
"roleName",
|
|
158
|
-
"
|
|
148
|
+
"runId",
|
|
159
149
|
"agentId",
|
|
160
150
|
"driverId",
|
|
161
|
-
"runtimeGenerationId",
|
|
162
151
|
"conversationId",
|
|
163
|
-
"activationId",
|
|
164
152
|
"continuationId",
|
|
165
|
-
"continuationGeneration",
|
|
166
153
|
"parentContinuationId",
|
|
167
154
|
"nativeSessionId",
|
|
168
155
|
"nativeTurnId",
|
|
@@ -174,20 +161,19 @@ export function runtimeObservationFenceMatches(expected, actual) {
|
|
|
174
161
|
return true;
|
|
175
162
|
}
|
|
176
163
|
/**
|
|
177
|
-
* Matches observations that belong to one durable
|
|
164
|
+
* Matches observations that belong to one durable AgentRun/Runtime Session.
|
|
178
165
|
* A provider may advance its native Turn while background subagents from an
|
|
179
|
-
* earlier
|
|
166
|
+
* earlier AgentRun are still active and later mailbox activations use their own
|
|
180
167
|
* exactly-once receipt, so nativeTurnId and receiptId are intentionally
|
|
181
168
|
* excluded. Exact acceptance still validates both fields before persistence.
|
|
182
169
|
*/
|
|
183
|
-
export function
|
|
170
|
+
export function runtimeObservationRunFenceMatches(expected, actual) {
|
|
184
171
|
for (const field of [
|
|
185
172
|
"taskId",
|
|
186
173
|
"roleName",
|
|
187
|
-
"
|
|
174
|
+
"runId",
|
|
188
175
|
"agentId",
|
|
189
176
|
"driverId",
|
|
190
|
-
"runtimeGenerationId",
|
|
191
177
|
"nativeSessionId"
|
|
192
178
|
]) {
|
|
193
179
|
if (expected[field] !== actual[field])
|
|
@@ -204,9 +190,8 @@ export function runtimeObservationTaskEventPayload(input) {
|
|
|
204
190
|
roleName: observation.fence.roleName,
|
|
205
191
|
agentId: observation.fence.agentId,
|
|
206
192
|
driverId: observation.fence.driverId,
|
|
207
|
-
runtimeGenerationId: observation.fence.runtimeGenerationId,
|
|
208
193
|
...(observation.fence.taskId === undefined ? {} : { taskId: observation.fence.taskId }),
|
|
209
|
-
...(observation.fence.
|
|
194
|
+
...(observation.fence.runId === undefined ? {} : { runId: observation.fence.runId }),
|
|
210
195
|
...(observation.fence.nativeSessionId === undefined
|
|
211
196
|
? {}
|
|
212
197
|
: { nativeSessionId: observation.fence.nativeSessionId }),
|
|
@@ -229,15 +214,15 @@ export function runtimeObservationFromTaskEvent(event) {
|
|
|
229
214
|
/**
|
|
230
215
|
* Runtime observation events are compacted by operation identity: a terminal
|
|
231
216
|
* operation replaces its matching start. Any retained exact start therefore
|
|
232
|
-
* represents Provider-owned work that is still active for this
|
|
217
|
+
* represents Provider-owned work that is still active for this AgentRun.
|
|
233
218
|
*/
|
|
234
|
-
export function
|
|
219
|
+
export function runHasActiveRuntimeOperations(events, owner) {
|
|
235
220
|
return events.some((event) => {
|
|
236
221
|
const observation = runtimeObservationFromTaskEvent(event);
|
|
237
222
|
return observation?.kind === "operation.started"
|
|
238
223
|
&& observation.fence.taskId === owner.taskId
|
|
239
224
|
&& observation.fence.roleName === owner.roleName
|
|
240
|
-
&& observation.fence.
|
|
225
|
+
&& observation.fence.runId === owner.runId
|
|
241
226
|
&& observation.fence.agentId === owner.agentId;
|
|
242
227
|
});
|
|
243
228
|
}
|
|
@@ -245,10 +230,9 @@ function normalizeFence(input) {
|
|
|
245
230
|
return Object.freeze({
|
|
246
231
|
...(input.taskId === undefined ? {} : { taskId: requireIdentity(input.taskId, "Task id") }),
|
|
247
232
|
roleName: requireIdentity(input.roleName, "Role name"),
|
|
248
|
-
...(input.
|
|
233
|
+
...(input.runId === undefined ? {} : { runId: requireIdentity(input.runId, "AgentRun id") }),
|
|
249
234
|
agentId: requireIdentity(input.agentId, "Agent id"),
|
|
250
235
|
driverId: requireDriverId(input.driverId),
|
|
251
|
-
runtimeGenerationId: requireIdentity(input.runtimeGenerationId, "Runtime generation id"),
|
|
252
236
|
...(input.nativeSessionId === undefined
|
|
253
237
|
? {}
|
|
254
238
|
: { nativeSessionId: requireIdentity(input.nativeSessionId, "Native Session id") }),
|
|
@@ -261,17 +245,9 @@ function normalizeFence(input) {
|
|
|
261
245
|
...(input.conversationId === undefined
|
|
262
246
|
? {}
|
|
263
247
|
: { conversationId: requireIdentity(input.conversationId, "Provider Conversation id") }),
|
|
264
|
-
...(input.activationId === undefined
|
|
265
|
-
? {}
|
|
266
|
-
: { activationId: requireIdentity(input.activationId, "Provider Activation id") }),
|
|
267
248
|
...(input.continuationId === undefined
|
|
268
249
|
? {}
|
|
269
250
|
: { continuationId: requireIdentity(input.continuationId, "Provider Continuation id") }),
|
|
270
|
-
...(input.continuationGeneration === undefined
|
|
271
|
-
? {}
|
|
272
|
-
: {
|
|
273
|
-
continuationGeneration: requireNonNegativeInteger(input.continuationGeneration, 1, "Provider Continuation generation")
|
|
274
|
-
}),
|
|
275
251
|
...(input.parentContinuationId === undefined
|
|
276
252
|
? {}
|
|
277
253
|
: {
|
|
@@ -290,7 +266,7 @@ function normalizePayload(kind, input) {
|
|
|
290
266
|
&& input.reason !== "user"
|
|
291
267
|
&& input.reason !== "permission"
|
|
292
268
|
&& input.reason !== "external") {
|
|
293
|
-
throw new Error("
|
|
269
|
+
throw new Error("run.waiting requires a supported reason.");
|
|
294
270
|
}
|
|
295
271
|
if (kind === "turn.waiting")
|
|
296
272
|
requireIdentity(input.waitId, "Runtime wait id");
|
|
@@ -321,7 +297,7 @@ function normalizePayload(kind, input) {
|
|
|
321
297
|
? undefined
|
|
322
298
|
: normalizeObserverSource(input.observerSource);
|
|
323
299
|
if (kind === "turn.failed" && input.failure === undefined) {
|
|
324
|
-
throw new Error("
|
|
300
|
+
throw new Error("run.failed requires normalized failure evidence.");
|
|
325
301
|
}
|
|
326
302
|
if (input.resultTransportDiagnostic !== undefined && kind !== "turn.completed") {
|
|
327
303
|
throw new Error("Only turn.completed may carry a result transport diagnostic.");
|
|
@@ -412,11 +388,11 @@ function normalizePayload(kind, input) {
|
|
|
412
388
|
...(input.input === undefined ? {} : { input: requireText(input.input, "Provider-visible input") }),
|
|
413
389
|
...(input.output === undefined
|
|
414
390
|
? {}
|
|
415
|
-
: { output: requireResultText(input.output, "Runtime
|
|
391
|
+
: { output: requireResultText(input.output, "Runtime AgentRun output") }),
|
|
416
392
|
...(input.resultTransportDiagnostic === undefined
|
|
417
393
|
? {}
|
|
418
394
|
: {
|
|
419
|
-
resultTransportDiagnostic: requireText(input.resultTransportDiagnostic, "Runtime
|
|
395
|
+
resultTransportDiagnostic: requireText(input.resultTransportDiagnostic, "Runtime AgentRun result diagnostic")
|
|
420
396
|
}),
|
|
421
397
|
...(input.summary === undefined ? {} : { summary: requireText(input.summary, "Runtime summary") }),
|
|
422
398
|
...(input.execution === undefined ? {} : { execution: input.execution }),
|
|
@@ -463,15 +439,13 @@ export function runtimeObservationSemanticKey(input) {
|
|
|
463
439
|
const continuationIdentity = [
|
|
464
440
|
fence.driverId,
|
|
465
441
|
fence.agentId,
|
|
466
|
-
fence.conversationId ?? fence.nativeSessionId ??
|
|
467
|
-
fence.
|
|
468
|
-
fence.continuationId ?? "none",
|
|
469
|
-
fence.continuationGeneration ?? "none"
|
|
442
|
+
fence.conversationId ?? fence.nativeSessionId ?? "none",
|
|
443
|
+
fence.continuationId ?? "none"
|
|
470
444
|
];
|
|
471
445
|
// Terminal boundaries are semantic facts. Providers may replay them with a
|
|
472
446
|
// fresh transport sequence after reconnect, so terminal identity must win
|
|
473
447
|
// over occurrence ordering or one SessionEnd storm becomes many facts.
|
|
474
|
-
if (["session.ended", "session.failed",
|
|
448
|
+
if (["session.ended", "session.failed",
|
|
475
449
|
"goal.cleared", "turn.completed", "turn.failed", "turn.cancelled", "continuation.settled"].includes(input.kind)) {
|
|
476
450
|
return [
|
|
477
451
|
"terminal",
|
|
@@ -480,7 +454,7 @@ export function runtimeObservationSemanticKey(input) {
|
|
|
480
454
|
input.kind,
|
|
481
455
|
input.payload?.outcome ?? input.payload?.failure?.error.code ?? "terminal",
|
|
482
456
|
input.kind === "continuation.settled" ? input.payload?.resultRef ?? "none" : "none",
|
|
483
|
-
input.kind === "turn.failed" && input.payload?.failure?.
|
|
457
|
+
input.kind === "turn.failed" && input.payload?.failure?.runTerminal === true
|
|
484
458
|
? "turn-terminal-failure"
|
|
485
459
|
: "turn-terminal"
|
|
486
460
|
].join(":");
|
|
@@ -489,7 +463,7 @@ export function runtimeObservationSemanticKey(input) {
|
|
|
489
463
|
return [
|
|
490
464
|
"goal-state",
|
|
491
465
|
fence.driverId,
|
|
492
|
-
fence.conversationId ?? fence.nativeSessionId ??
|
|
466
|
+
fence.conversationId ?? fence.nativeSessionId ?? "none",
|
|
493
467
|
input.payload?.goalStatus ?? "unknown",
|
|
494
468
|
input.payload?.goalUpdatedAt ?? "unknown"
|
|
495
469
|
].join(":");
|
|
@@ -514,18 +488,8 @@ export function runtimeObservationSemanticKey(input) {
|
|
|
514
488
|
input.payload?.resultRef ?? "none"
|
|
515
489
|
].join(":");
|
|
516
490
|
}
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
"provider-sequence",
|
|
520
|
-
fence.driverId,
|
|
521
|
-
fence.conversationId ?? fence.nativeSessionId ?? fence.runtimeGenerationId,
|
|
522
|
-
fence.activationId ?? fence.runtimeGenerationId,
|
|
523
|
-
fence.continuationId ?? fence.receiptId ?? fence.nativeTurnId ?? "none",
|
|
524
|
-
fence.continuationGeneration ?? "none",
|
|
525
|
-
input.sequence,
|
|
526
|
-
input.kind
|
|
527
|
-
].join(":");
|
|
528
|
-
}
|
|
491
|
+
// Sequence is transport-local ordering, not identity: it may restart when
|
|
492
|
+
// a Host reconnects to the same Session. Inbox retries retain the event id.
|
|
529
493
|
return `provider-event:${requireIdentity(input.eventId, "Runtime observation event id")}`;
|
|
530
494
|
}
|
|
531
495
|
function normalizeObserverSource(input) {
|
|
@@ -554,9 +518,9 @@ function normalizeFailure(input) {
|
|
|
554
518
|
...(input.lastOutput === undefined
|
|
555
519
|
? {}
|
|
556
520
|
: { lastOutput: requireText(input.lastOutput, "Runtime failure last output") }),
|
|
557
|
-
...(input.
|
|
521
|
+
...(input.runTerminal === undefined
|
|
558
522
|
? {}
|
|
559
|
-
: {
|
|
523
|
+
: { runTerminal: requireBoolean(input.runTerminal, "Runtime failure runTerminal") })
|
|
560
524
|
});
|
|
561
525
|
}
|
|
562
526
|
function requireBoolean(value, label) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRuntimeObservation, runtimeObservationFromTaskEvent,
|
|
1
|
+
import { createRuntimeObservation, runtimeObservationFromTaskEvent, runtimeObservationRunFenceMatches } from "./runtimeObservation.js";
|
|
2
2
|
import { DEFAULT_RUNTIME_HEALTH_POLICY } from "./runtimeHealthPolicy.js";
|
|
3
3
|
export function createRuntimeProjection(fence, createdAt) {
|
|
4
4
|
const timestamp = requireTimestamp(createdAt);
|
|
@@ -6,9 +6,8 @@ export function createRuntimeProjection(fence, createdAt) {
|
|
|
6
6
|
fence: Object.freeze({ ...fence }),
|
|
7
7
|
host: "unknown",
|
|
8
8
|
session: "unknown",
|
|
9
|
-
|
|
9
|
+
run: "none",
|
|
10
10
|
conversation: "unknown",
|
|
11
|
-
activation: "none",
|
|
12
11
|
goal: "none",
|
|
13
12
|
continuations: Object.freeze({}),
|
|
14
13
|
runActivity: "starting",
|
|
@@ -29,7 +28,7 @@ export function createRuntimeProjection(fence, createdAt) {
|
|
|
29
28
|
export function projectRuntimeTaskEvents(fence, createdAt, events) {
|
|
30
29
|
const observations = events
|
|
31
30
|
.map(runtimeObservationFromTaskEvent)
|
|
32
|
-
.filter((event) => (event !== null &&
|
|
31
|
+
.filter((event) => (event !== null && runtimeObservationRunFenceMatches(fence, event.fence)))
|
|
33
32
|
.sort((left, right) => (left.receivedAt.localeCompare(right.receivedAt)
|
|
34
33
|
|| (left.sequence ?? -1) - (right.sequence ?? -1)
|
|
35
34
|
|| (left.ordinal ?? -1) - (right.ordinal ?? -1)
|
|
@@ -38,7 +37,7 @@ export function projectRuntimeTaskEvents(fence, createdAt, events) {
|
|
|
38
37
|
}
|
|
39
38
|
export function projectRuntimeObservation(current, raw) {
|
|
40
39
|
const event = createRuntimeObservation(raw);
|
|
41
|
-
if (!
|
|
40
|
+
if (!runtimeObservationRunFenceMatches(current.fence, event.fence)) {
|
|
42
41
|
throw new Error("Runtime observation fence does not match the projection.");
|
|
43
42
|
}
|
|
44
43
|
const at = event.receivedAt;
|
|
@@ -52,7 +51,6 @@ export function projectRuntimeObservation(current, raw) {
|
|
|
52
51
|
return next(current, {
|
|
53
52
|
session: "started",
|
|
54
53
|
conversation: "recoverable",
|
|
55
|
-
activation: "active",
|
|
56
54
|
stateSince: at
|
|
57
55
|
});
|
|
58
56
|
case "session.ready":
|
|
@@ -60,28 +58,28 @@ export function projectRuntimeObservation(current, raw) {
|
|
|
60
58
|
case "session.ended":
|
|
61
59
|
return next(current, {
|
|
62
60
|
session: "ended",
|
|
63
|
-
|
|
64
|
-
turn: terminalTurn(current.turn),
|
|
61
|
+
run: terminalRun(current.run),
|
|
65
62
|
// A parent provider Session ending is independent from native child
|
|
66
|
-
// operations already observed under the
|
|
63
|
+
// operations already observed under the AgentRun. Keep those children
|
|
67
64
|
// visible until their own terminal facts arrive; host/session loss is
|
|
68
|
-
// health evidence, not proof that child work or the Yui
|
|
65
|
+
// health evidence, not proof that child work or the Yui AgentRun ended.
|
|
69
66
|
operations: activeSubagentOperations(current.operations),
|
|
70
67
|
stateSince: at
|
|
71
68
|
});
|
|
72
69
|
case "session.failed":
|
|
73
70
|
return next(current, {
|
|
74
71
|
session: "failed",
|
|
75
|
-
|
|
76
|
-
turn: current.turn === "none" ? "failed" : terminalTurn(current.turn, "failed"),
|
|
72
|
+
run: current.run === "none" ? "failed" : terminalRun(current.run, "failed"),
|
|
77
73
|
operations: activeSubagentOperations(current.operations),
|
|
78
74
|
stateSince: at
|
|
79
75
|
});
|
|
80
76
|
case "turn.accepted":
|
|
81
77
|
case "input.accepted":
|
|
78
|
+
if (event.fence.receiptId?.startsWith("turn-input:") === true)
|
|
79
|
+
return current;
|
|
82
80
|
return withActivity(next(current, {
|
|
83
81
|
session: "active",
|
|
84
|
-
|
|
82
|
+
run: "accepted",
|
|
85
83
|
waitingReason: undefined,
|
|
86
84
|
waitId: undefined,
|
|
87
85
|
stateSince: at
|
|
@@ -89,7 +87,7 @@ export function projectRuntimeObservation(current, raw) {
|
|
|
89
87
|
case "turn.waiting":
|
|
90
88
|
return next(current, {
|
|
91
89
|
session: "waiting",
|
|
92
|
-
|
|
90
|
+
run: "waiting",
|
|
93
91
|
waitingReason: event.payload.reason,
|
|
94
92
|
waitId: event.payload.waitId,
|
|
95
93
|
stateSince: at
|
|
@@ -97,19 +95,19 @@ export function projectRuntimeObservation(current, raw) {
|
|
|
97
95
|
case "turn.completed":
|
|
98
96
|
return withActivity(next(current, {
|
|
99
97
|
session: "ready",
|
|
100
|
-
|
|
98
|
+
run: "completed",
|
|
101
99
|
waitingReason: undefined,
|
|
102
100
|
waitId: undefined,
|
|
103
101
|
// Tool operations belong to the completed native Turn. Provider-owned
|
|
104
102
|
// background subagents may legitimately outlive it and wake later
|
|
105
|
-
// native Provider activity inside the same durable Yui
|
|
103
|
+
// native Provider activity inside the same durable Yui AgentRun.
|
|
106
104
|
operations: activeSubagentOperations(current.operations),
|
|
107
105
|
stateSince: at
|
|
108
106
|
}), "provider", at);
|
|
109
107
|
case "turn.failed":
|
|
110
108
|
return withActivity(next(current, {
|
|
111
109
|
session: "ready",
|
|
112
|
-
|
|
110
|
+
run: "failed",
|
|
113
111
|
waitingReason: undefined,
|
|
114
112
|
waitId: undefined,
|
|
115
113
|
operations: Object.freeze({}),
|
|
@@ -118,7 +116,7 @@ export function projectRuntimeObservation(current, raw) {
|
|
|
118
116
|
case "turn.cancelled":
|
|
119
117
|
return withActivity(next(current, {
|
|
120
118
|
session: "ready",
|
|
121
|
-
|
|
119
|
+
run: "cancelled",
|
|
122
120
|
waitingReason: undefined,
|
|
123
121
|
waitId: undefined,
|
|
124
122
|
operations: Object.freeze({}),
|
|
@@ -131,7 +129,7 @@ export function projectRuntimeObservation(current, raw) {
|
|
|
131
129
|
session: current.session === "ended" || current.session === "failed"
|
|
132
130
|
? current.session
|
|
133
131
|
: "active",
|
|
134
|
-
|
|
132
|
+
run: current.run === "waiting" ? "accepted" : current.run,
|
|
135
133
|
waitingReason: undefined,
|
|
136
134
|
waitId: undefined,
|
|
137
135
|
operations: Object.freeze({
|
|
@@ -149,7 +147,7 @@ export function projectRuntimeObservation(current, raw) {
|
|
|
149
147
|
session: current.session === "ended" || current.session === "failed"
|
|
150
148
|
? current.session
|
|
151
149
|
: "active",
|
|
152
|
-
|
|
150
|
+
run: current.run === "waiting" ? "accepted" : current.run,
|
|
153
151
|
waitingReason: undefined,
|
|
154
152
|
waitId: undefined,
|
|
155
153
|
operations: Object.freeze(operations),
|
|
@@ -163,8 +161,8 @@ export function projectRuntimeObservation(current, raw) {
|
|
|
163
161
|
const projected = next(current, {
|
|
164
162
|
...(usage === undefined ? {} : { usage: Object.freeze({ ...usage }) }),
|
|
165
163
|
...(lifecycleActivity ? {
|
|
166
|
-
session: current.
|
|
167
|
-
|
|
164
|
+
session: current.run === "waiting" ? "active" : current.session,
|
|
165
|
+
run: current.run === "waiting" ? "accepted" : current.run,
|
|
168
166
|
waitingReason: undefined,
|
|
169
167
|
waitId: undefined
|
|
170
168
|
} : {})
|
|
@@ -192,12 +190,6 @@ export function projectRuntimeObservation(current, raw) {
|
|
|
192
190
|
? "unrecoverable"
|
|
193
191
|
: event.payload.recoverability === "recoverable" ? "recoverable" : "unknown"
|
|
194
192
|
});
|
|
195
|
-
case "activation.started":
|
|
196
|
-
return next(current, { activation: "active", stateSince: at });
|
|
197
|
-
case "activation.ended":
|
|
198
|
-
return next(current, { activation: "ended", stateSince: at });
|
|
199
|
-
case "activation.failed":
|
|
200
|
-
return next(current, { activation: "failed", stateSince: at });
|
|
201
193
|
case "goal.updated":
|
|
202
194
|
return next(current, { goal: event.payload.goalStatus, stateSince: at });
|
|
203
195
|
case "goal.cleared":
|
|
@@ -206,9 +198,7 @@ export function projectRuntimeObservation(current, raw) {
|
|
|
206
198
|
case "continuation.reported":
|
|
207
199
|
case "continuation.settled": {
|
|
208
200
|
const id = [
|
|
209
|
-
event.fence.
|
|
210
|
-
event.fence.continuationId,
|
|
211
|
-
event.fence.continuationGeneration
|
|
201
|
+
event.fence.continuationId
|
|
212
202
|
].join("/");
|
|
213
203
|
const existing = current.continuations[id];
|
|
214
204
|
if (event.kind === "continuation.reported") {
|
|
@@ -263,7 +253,9 @@ export function projectRuntimeObservation(current, raw) {
|
|
|
263
253
|
});
|
|
264
254
|
}
|
|
265
255
|
case "input.delivery-unknown":
|
|
266
|
-
|
|
256
|
+
if (event.fence.receiptId?.startsWith("turn-input:") === true)
|
|
257
|
+
return current;
|
|
258
|
+
return next(current, { run: "delivery-unknown", stateSince: at });
|
|
267
259
|
case "native-work.snapshot":
|
|
268
260
|
return next(current, {});
|
|
269
261
|
default:
|
|
@@ -301,12 +293,12 @@ export function runtimeDisplayStatus(current) {
|
|
|
301
293
|
return "stopped";
|
|
302
294
|
if (operation !== null)
|
|
303
295
|
return `${operation}-active`;
|
|
304
|
-
if (current.
|
|
296
|
+
if (current.run === "waiting")
|
|
305
297
|
return `waiting-${current.waitingReason ?? "external"}`;
|
|
306
|
-
if (current.session === "ready" || current.
|
|
307
|
-
|| current.
|
|
298
|
+
if (current.session === "ready" || current.run === "completed"
|
|
299
|
+
|| current.run === "failed" || current.run === "cancelled")
|
|
308
300
|
return "ready";
|
|
309
|
-
if (current.
|
|
301
|
+
if (current.run === "accepted" || current.session === "active") {
|
|
310
302
|
return current.activity.kind === "model" ? "model-active" : "active-quiet";
|
|
311
303
|
}
|
|
312
304
|
if (current.session === "started")
|
|
@@ -318,7 +310,7 @@ export function runtimeDisplayStatus(current) {
|
|
|
318
310
|
/**
|
|
319
311
|
* Classify one RuntimeProjection into the layered health state shared by CLI,
|
|
320
312
|
* Web, and scheduler. The semantic progress timestamp is the same durable
|
|
321
|
-
* fence the scheduler stall pass consumes (
|
|
313
|
+
* fence the scheduler stall pass consumes (AgentRun creation plus Work/Review/
|
|
322
314
|
* Integration checkpoints), so token/tool/CPU activity can never masquerade
|
|
323
315
|
* as business progress.
|
|
324
316
|
*
|
|
@@ -376,9 +368,14 @@ function classifyLayer(current, operation, runtimeIdleMs, semanticIdleMs, policy
|
|
|
376
368
|
if (current.observer.status === "degraded" || current.observer.status === "unavailable") {
|
|
377
369
|
return "diagnostic-needed";
|
|
378
370
|
}
|
|
379
|
-
if (current.
|
|
371
|
+
if (current.run === "waiting") {
|
|
380
372
|
return `waiting-${current.waitingReason ?? "external"}`;
|
|
381
373
|
}
|
|
374
|
+
if (current.session === "ready"
|
|
375
|
+
|| current.run === "completed"
|
|
376
|
+
|| current.run === "failed"
|
|
377
|
+
|| current.run === "cancelled")
|
|
378
|
+
return "ready";
|
|
382
379
|
// No durable semantic progress past fifteen minutes: display only. The
|
|
383
380
|
// scheduler's coalesced read-only diagnostic remains a separate 30m clock.
|
|
384
381
|
if (semanticIdleMs >= policy.diagnosticAfterMs)
|
|
@@ -386,13 +383,8 @@ function classifyLayer(current, operation, runtimeIdleMs, semanticIdleMs, policy
|
|
|
386
383
|
// A live turn with no recent structured activity is quiet, not dead.
|
|
387
384
|
if (runtimeIdleMs >= policy.quietAfterMs)
|
|
388
385
|
return "quiet";
|
|
389
|
-
if (current.
|
|
386
|
+
if (current.run === "accepted" || current.session === "active")
|
|
390
387
|
return "active-quiet";
|
|
391
|
-
if (current.session === "ready"
|
|
392
|
-
|| current.turn === "completed"
|
|
393
|
-
|| current.turn === "failed"
|
|
394
|
-
|| current.turn === "cancelled")
|
|
395
|
-
return "ready";
|
|
396
388
|
if (current.session === "started")
|
|
397
389
|
return "awaiting-provider-acceptance";
|
|
398
390
|
if (current.host === "alive")
|
|
@@ -404,7 +396,7 @@ function runtimeHealthReason(layer, current) {
|
|
|
404
396
|
case "broken":
|
|
405
397
|
return "the Agent Driver runtime is broken";
|
|
406
398
|
case "stopped":
|
|
407
|
-
return "the Provider
|
|
399
|
+
return "the Provider execution attachment has ended";
|
|
408
400
|
case "subagent-active":
|
|
409
401
|
case "tool-active":
|
|
410
402
|
case "model-active":
|
|
@@ -423,9 +415,9 @@ function runtimeHealthReason(layer, current) {
|
|
|
423
415
|
case "waiting-external":
|
|
424
416
|
return `the Agent Driver is ${layer.replaceAll("-", " ")}`;
|
|
425
417
|
case "ready":
|
|
426
|
-
return "the Provider turn ended
|
|
418
|
+
return "the Provider turn has ended; Task progress is recorded separately";
|
|
427
419
|
case "awaiting-provider-acceptance":
|
|
428
|
-
return "the submitted active
|
|
420
|
+
return "the submitted active AgentRun is awaiting Provider acceptance";
|
|
429
421
|
case "runtime-unobservable":
|
|
430
422
|
return "the host is present but the Agent Driver exposes no current runtime state";
|
|
431
423
|
case "starting":
|
|
@@ -454,7 +446,7 @@ function next(current, patch) {
|
|
|
454
446
|
...activeNativeOperations.map(([id]) => `native-operation:${id}`)
|
|
455
447
|
];
|
|
456
448
|
const attention = [
|
|
457
|
-
...(copy.
|
|
449
|
+
...(copy.run === "delivery-unknown" ? ["delivery-unknown"] : []),
|
|
458
450
|
...continuations.flatMap(([id, continuation]) => (continuation.identityConflict ? [`identity-conflict:${id}`]
|
|
459
451
|
: continuation.observation === "unavailable" ? [`continuation-unresolved:${id}`]
|
|
460
452
|
: [])),
|
|
@@ -469,10 +461,10 @@ function next(current, patch) {
|
|
|
469
461
|
|| copy.session === "ended"
|
|
470
462
|
|| copy.session === "failed"
|
|
471
463
|
? "unobservable"
|
|
472
|
-
: (
|
|
464
|
+
: (["unknown", "ended", "failed"].includes(copy.session) && waitingNative.length > 0)
|
|
473
465
|
? "reconciling"
|
|
474
466
|
: "healthy";
|
|
475
|
-
const runActivity = copy.
|
|
467
|
+
const runActivity = copy.run === "accepted"
|
|
476
468
|
|| copy.session === "active"
|
|
477
469
|
? "running"
|
|
478
470
|
: waitingNative.length > 0 || activeNativeOperations.length > 0 ? "waiting"
|
|
@@ -499,7 +491,7 @@ function dominantOperation(operations) {
|
|
|
499
491
|
function activeSubagentOperations(operations) {
|
|
500
492
|
return Object.freeze(Object.fromEntries(Object.entries(operations).filter(([, operation]) => operation.kind === "subagent")));
|
|
501
493
|
}
|
|
502
|
-
function
|
|
494
|
+
function terminalRun(current, fallback = "cancelled") {
|
|
503
495
|
return current === "completed" || current === "failed" || current === "cancelled"
|
|
504
496
|
? current
|
|
505
497
|
: fallback;
|
|
@@ -15,9 +15,7 @@ export function projectRuntimeSessionCandidate(sessions) {
|
|
|
15
15
|
agentId: active.agentId,
|
|
16
16
|
adapterId: active.adapterId,
|
|
17
17
|
nativeSessionId: active.nativeSessionId,
|
|
18
|
-
|
|
19
|
-
sessionUpdatedAt: active.updatedAt,
|
|
20
|
-
cleanupRequired: active.runtimeGenerationId !== undefined
|
|
18
|
+
sessionUpdatedAt: active.updatedAt
|
|
21
19
|
};
|
|
22
20
|
}
|
|
23
21
|
/** Deterministic owner order shared by all storage backends. */
|
|
@@ -15,23 +15,19 @@ export function createSessionLaunchRequest(input) {
|
|
|
15
15
|
const runtimeIsolation = input.runtimeIsolation === undefined
|
|
16
16
|
? undefined
|
|
17
17
|
: parseTaskRuntimeIsolationDescriptor(JSON.stringify(input.runtimeIsolation));
|
|
18
|
-
if (runtimeIsolation !== undefined && (input.owner.scope !== "task"
|
|
19
|
-
|| runtimeIsolation.taskId !== input.owner.taskId
|
|
20
|
-
|| runtimeIsolation.workspace.root !== workspace
|
|
21
|
-
|| runtimeIsolation.generation.runtimeGenerationId !== input.runtimeGenerationId)) {
|
|
18
|
+
if (runtimeIsolation !== undefined && (input.owner.scope !== "task" || runtimeIsolation.taskId !== input.owner.taskId || runtimeIsolation.workspace.root !== workspace)) {
|
|
22
19
|
throw new TypeError("Session launch request does not match its Task runtime isolation descriptor.");
|
|
23
20
|
}
|
|
24
21
|
const common = {
|
|
25
|
-
runtimeGenerationId: requireSafeIdentity(input.runtimeGenerationId, "Runtime generation id"),
|
|
26
22
|
owner: normalizeRuntimeOwner(input.owner),
|
|
27
23
|
agentId,
|
|
28
24
|
adapterId,
|
|
29
25
|
effective,
|
|
30
26
|
workspace,
|
|
31
27
|
...(runtimeIsolation === undefined ? {} : { runtimeIsolation }),
|
|
32
|
-
...(input.
|
|
28
|
+
...(input.runId === undefined
|
|
33
29
|
? {}
|
|
34
|
-
: {
|
|
30
|
+
: { runId: requireSafeIdentity(input.runId, "AgentRun id") }),
|
|
35
31
|
...(input.environment === undefined
|
|
36
32
|
? {}
|
|
37
33
|
: { environment: copyEnvironment(input.environment) })
|