@zq-silk/yui 0.15.7 → 0.15.9

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.
Files changed (308) hide show
  1. package/ARCHITECTURE.md +194 -399
  2. package/ARCHITECTURE.zh-CN.md +151 -0
  3. package/README.md +306 -1131
  4. package/dist/agent/adapterCatalog.js +15 -2
  5. package/dist/agent/agent.js +23 -3
  6. package/dist/agent/argumentPolicy.js +7 -1
  7. package/dist/agent/connectionPlan.js +62 -0
  8. package/dist/agent/executionComponents.js +158 -0
  9. package/dist/agent/launchEnvironment.js +31 -3
  10. package/dist/agent/managedRuntimeEnvironment.js +3 -5
  11. package/dist/{turn/turn.js → agentRun/agentRun.js} +166 -109
  12. package/dist/{turn/turnIdentity.js → agentRun/runIdentity.js} +4 -4
  13. package/dist/artifacts/artifactCapability.js +74 -0
  14. package/dist/artifacts/artifactCommitLock.js +249 -0
  15. package/dist/artifacts/artifactPaths.js +151 -0
  16. package/dist/artifacts/gitArtifactRef.js +146 -0
  17. package/dist/artifacts/managedGit.js +332 -0
  18. package/dist/artifacts/taskArtifactRepository.js +277 -0
  19. package/dist/brief/taskBrief.js +12 -0
  20. package/dist/cli/agentConfigurationPicker.js +13 -0
  21. package/dist/cli/commandCatalog.js +165 -74
  22. package/dist/cli/interactionCandidates.js +5 -5
  23. package/dist/cli/interactionPolicy.js +38 -8
  24. package/dist/cli/invocationRouter.js +1 -1
  25. package/dist/cli/managedDiagnostics.js +28 -0
  26. package/dist/cli/operatorWizard.js +1 -7
  27. package/dist/cli/roleOptionOrder.js +27 -0
  28. package/dist/cli/roleWizard.js +50 -14
  29. package/dist/cli/updateOrchestrator.js +1 -1
  30. package/dist/cli/updatePorts.js +3 -4
  31. package/dist/cli.js +245 -95
  32. package/dist/commands/agentCommands.js +72 -14
  33. package/dist/commands/capabilityCommands.js +9 -6
  34. package/dist/commands/configCommands.js +20 -20
  35. package/dist/commands/deliveryGuardPreflight.js +2 -2
  36. package/dist/commands/executionAuditCommands.js +24 -24
  37. package/dist/commands/globalRoleCommands.js +1 -1
  38. package/dist/commands/grantCommands.js +4 -4
  39. package/dist/commands/operatorCommands.js +34 -9
  40. package/dist/commands/projectCommands.js +4 -4
  41. package/dist/commands/resourcesCommands.js +2 -2
  42. package/dist/commands/roleConfiguration.js +25 -5
  43. package/dist/commands/roleRuntimeGuard.js +4 -5
  44. package/dist/commands/sessionCommands.js +3 -7
  45. package/dist/commands/taskActivationCommands.js +281 -0
  46. package/dist/commands/taskActor.js +28 -49
  47. package/dist/commands/taskCommands.js +1461 -720
  48. package/dist/commands/taskContextCommand.js +39 -583
  49. package/dist/commands/taskExecutionCommands.js +32 -32
  50. package/dist/commands/taskInputCommands.js +40 -104
  51. package/dist/commands/taskIntegrationCommands.js +3 -2
  52. package/dist/commands/taskIntegrationQueueCommands.js +1 -1
  53. package/dist/commands/taskNextActionCommand.js +8 -8
  54. package/dist/commands/taskOverviewCommand.js +33 -45
  55. package/dist/commands/taskRemoteDeliveryCommand.js +2 -2
  56. package/dist/commands/taskRoleRuntimeStatus.js +133 -102
  57. package/dist/commands/telemetryCommands.js +36 -38
  58. package/dist/config/configCatalog.js +4 -4
  59. package/dist/config/yuiConfig.js +8 -8
  60. package/dist/context/contextSnapshot.js +10 -10
  61. package/dist/context/dispatchContext.js +11 -11
  62. package/dist/context/roleSessionContext.js +6 -3
  63. package/dist/context/{turnContextPack.js → runContextPack.js} +158 -81
  64. package/dist/context/{turnInputContract.js → runInputContract.js} +73 -60
  65. package/dist/context/sessionBootstrapManifest.js +21 -2
  66. package/dist/context/sourceRunContext.js +30 -0
  67. package/dist/context/taskContext.js +481 -0
  68. package/dist/context/wakeNotification.js +27 -27
  69. package/dist/controller/agentRuntimeObserver.js +21 -24
  70. package/dist/controller/capabilityBridge.js +17 -6
  71. package/dist/controller/clientRuntime.js +65 -92
  72. package/dist/controller/controller.js +120 -188
  73. package/dist/controller/fileSchedulerStoreAdapter.js +787 -887
  74. package/dist/controller/jobControl.js +54 -85
  75. package/dist/controller/resourceInventory.js +8 -27
  76. package/dist/controller/resourceInventoryLinux.js +12 -13
  77. package/dist/controller/runtime.js +529 -479
  78. package/dist/controller/runtimeEventInbox.js +55 -25
  79. package/dist/controller/runtimeEventProcessor.js +22 -31
  80. package/dist/controller/{runtimeHookTurnFence.js → runtimeHookRunFence.js} +91 -115
  81. package/dist/controller/runtimeLaunchCoordinator.js +80 -426
  82. package/dist/controller/runtimeObservationHook.js +14 -18
  83. package/dist/controller/sessionNotify.js +16 -24
  84. package/dist/controller/sessionOwnerReconciliation.js +168 -50
  85. package/dist/controller/structuredProviderObservation.js +138 -99
  86. package/dist/coordination/workMailbox.js +3 -3
  87. package/dist/coordination/workMailboxQueue.js +36 -33
  88. package/dist/core/boundedRpc.js +8 -1
  89. package/dist/core/controllerClient.js +20 -1
  90. package/dist/core/controllerServer.js +4 -4
  91. package/dist/doctor/doctor.js +13 -2
  92. package/dist/domain/agentResultTransport.js +9 -9
  93. package/dist/execution/codexThreadNaming.js +2 -8
  94. package/dist/execution/executionHealth.js +51 -63
  95. package/dist/execution/reviewMainRun.js +137 -0
  96. package/dist/execution/workItemExecution.js +28 -29
  97. package/dist/execution/workItemExecutionProjection.js +99 -107
  98. package/dist/execution/workItemMainRun.js +141 -0
  99. package/dist/executor/agentAdapter.js +227 -20
  100. package/dist/executor/agentConfigurationCatalog.js +126 -4
  101. package/dist/executor/agentConfigurationProbe.js +162 -4
  102. package/dist/executor/agentExecutor.js +79 -78
  103. package/dist/executor/effectiveLaunch.js +105 -18
  104. package/dist/executor/executorRegistry.js +29 -44
  105. package/dist/executor/fileRoleLaunchPlanner.js +229 -154
  106. package/dist/executor/workspacePreflightClassification.js +16 -16
  107. package/dist/grant/capabilityGrant.js +6 -3
  108. package/dist/input/inputRequest.js +12 -10
  109. package/dist/integration/gitIntegrationService.js +4 -11
  110. package/dist/integration/integrationQueueService.js +4 -4
  111. package/dist/interaction/operatorPresentation.js +1 -1
  112. package/dist/kernel/builtinCapabilities.js +255 -12
  113. package/dist/kernel/capabilityRegistry.js +64 -18
  114. package/dist/kernel/instanceHost.js +12 -1
  115. package/dist/kernel/kernelPorts.js +2 -2
  116. package/dist/lifecycle/canonicalLifecycleEvent.js +44 -49
  117. package/dist/lifecycle/exactRunTerminalization.js +449 -0
  118. package/dist/message/message.js +118 -6
  119. package/dist/message/messageContinuation.js +204 -0
  120. package/dist/observability/executionAudit.js +70 -72
  121. package/dist/observability/faultClassification.js +2 -2
  122. package/dist/observability/orchestrationMetrics.js +8 -8
  123. package/dist/operator/operatorSessionHistory.js +1 -7
  124. package/dist/output/agentConfigurationPresentation.js +8 -3
  125. package/dist/output/agentRunConfigurationPresentation.js +128 -0
  126. package/dist/output/rolePresentation.js +54 -3
  127. package/dist/plugins/pluginChild.js +104 -0
  128. package/dist/plugins/pluginIntent.js +26 -0
  129. package/dist/plugins/pluginInterpreter.js +43 -0
  130. package/dist/plugins/pluginPackage.js +101 -0
  131. package/dist/plugins/pluginProcess.js +112 -0
  132. package/dist/plugins/pluginService.js +388 -0
  133. package/dist/profile/agentProfile.js +1 -1
  134. package/dist/repository/gitWorkspace.js +26 -4
  135. package/dist/repository/project.js +19 -4
  136. package/dist/repository/taskBaseFreshness.js +13 -13
  137. package/dist/repository/taskWorkspaceCoordinator.js +20 -27
  138. package/dist/repository/taskWorkspacePreparer.js +344 -83
  139. package/dist/resources/autoResourceGc.js +3 -3
  140. package/dist/resources/liveReferences.js +3 -3
  141. package/dist/resources/projectResource.js +75 -0
  142. package/dist/resources/projectResourceService.js +343 -0
  143. package/dist/resources/resourceDiscovery.js +6 -6
  144. package/dist/resources/resourceGc.js +1 -1
  145. package/dist/resources/resourceRegistrar.js +1 -1
  146. package/dist/resources/resourceTypes.js +1 -1
  147. package/dist/review/deltaRecheck.js +3 -3
  148. package/dist/review/reviewAcceptance.js +16 -16
  149. package/dist/review/reviewDecision.js +7 -7
  150. package/dist/review/reviewRound.js +21 -20
  151. package/dist/review/reviewerAvailability.js +2 -2
  152. package/dist/role/role.js +51 -7
  153. package/dist/role/taskRoleUpdate.js +30 -0
  154. package/dist/runtime/acpProtocol.js +425 -0
  155. package/dist/runtime/acpSession.js +731 -0
  156. package/dist/runtime/acpSessionConfiguration.js +260 -0
  157. package/dist/runtime/agentDriver.js +30 -11
  158. package/dist/runtime/agentEndpoint.js +278 -0
  159. package/dist/runtime/agentEndpointIdentity.js +86 -0
  160. package/dist/runtime/agentEndpointOwnership.js +239 -0
  161. package/dist/runtime/agentError.js +2 -10
  162. package/dist/runtime/agentHost.js +565 -314
  163. package/dist/runtime/agentRunConfiguration.js +258 -0
  164. package/dist/runtime/builtinAgentDrivers.js +134 -18
  165. package/dist/runtime/builtinAgentErrorMappers.js +55 -3
  166. package/dist/runtime/builtinTranscriptUsage.js +1 -1
  167. package/dist/runtime/claude-process-owner +0 -0
  168. package/dist/runtime/codexAppServerRuntime.js +38 -30
  169. package/dist/runtime/codexInteractiveHost.js +41 -6
  170. package/dist/runtime/continuationManager.js +2 -6
  171. package/dist/runtime/executionEnvironment.js +30 -0
  172. package/dist/runtime/firstProgressAdvisory.js +11 -11
  173. package/dist/runtime/index.js +4 -3
  174. package/dist/runtime/jsonLineChannel.js +109 -0
  175. package/dist/runtime/launchBroker.js +91 -16
  176. package/dist/runtime/launchDiagnostics.js +2 -2
  177. package/dist/runtime/lifecycleReservation.js +10 -18
  178. package/dist/runtime/managedCaller.js +61 -17
  179. package/dist/runtime/nativeSessionControl.js +102 -0
  180. package/dist/runtime/ports.js +6 -21
  181. package/dist/runtime/processExitObservation.js +8 -7
  182. package/dist/runtime/promptEnvelope.js +17 -6
  183. package/dist/runtime/providerContinuation.js +3 -9
  184. package/dist/runtime/providerContinuationReconciliationService.js +4 -13
  185. package/dist/runtime/providerControl.js +2 -7
  186. package/dist/runtime/providerRuntimeIdentity.js +110 -222
  187. package/dist/runtime/providerRuntimeReconciler.js +5 -9
  188. package/dist/runtime/runtimeBinding.js +0 -1
  189. package/dist/runtime/runtimeContinuationProjection.js +4 -7
  190. package/dist/runtime/runtimeDeadlines.js +9 -0
  191. package/dist/runtime/runtimeHealthPolicy.js +1 -1
  192. package/dist/runtime/runtimeObservation.js +29 -65
  193. package/dist/runtime/runtimeProjection.js +43 -51
  194. package/dist/runtime/runtimeSessionCandidate.js +1 -3
  195. package/dist/runtime/sessionLaunchRequest.js +3 -7
  196. package/dist/runtime/sessionOwnerIdentity.js +7 -54
  197. package/dist/runtime/sessionOwnerRegistry.js +22 -17
  198. package/dist/runtime/sessionReconciliation.js +4 -8
  199. package/dist/runtime/sessionTerminationGuard.js +70 -259
  200. package/dist/runtime/sessionTokenMetrics.js +5 -16
  201. package/dist/runtime/structuredProviderHost.js +237 -117
  202. package/dist/runtime/taskRuntimeIsolation.js +39 -122
  203. package/dist/runtime/tmuxAdapters.js +39 -86
  204. package/dist/scheduler/activeRoleRunDelivery.js +354 -0
  205. package/dist/scheduler/leaderWakeupProcessor.js +75 -266
  206. package/dist/scheduler/operatorInputNotificationProcessor.js +1 -1
  207. package/dist/scheduler/ports.js +80 -9
  208. package/dist/scheduler/{roleTurnLiveness.js → roleRunLiveness.js} +26 -30
  209. package/dist/scheduler/{roleTurnStall.js → roleRunStall.js} +128 -139
  210. package/dist/scheduler/taskExecutionProjection.js +120 -124
  211. package/dist/scheduler/taskObservabilityProjection.js +29 -29
  212. package/dist/scheduler/taskWake.js +11 -4
  213. package/dist/scheduler/wakeReason.js +9 -1
  214. package/dist/setup/setupCommand.js +3 -7
  215. package/dist/storage/migrations/agentRunContract.js +159 -0
  216. package/dist/storage/migrations/artifactsToGit.js +338 -0
  217. package/dist/storage/migrations/removeRuntimeGeneration.js +207 -0
  218. package/dist/storage/migrations/submitIntent.js +126 -0
  219. package/dist/storage/sqliteSchema.js +467 -7
  220. package/dist/storage/sqliteStore.js +355 -220
  221. package/dist/storage/storageVersions.js +1 -1
  222. package/dist/storage/storeRpc.js +10 -5
  223. package/dist/storage/taskStore.js +13 -11
  224. package/dist/storage/upgrade/upgradeOrchestrator.js +5 -7
  225. package/dist/surface/surfaceContributions.js +102 -0
  226. package/dist/task/completionReadiness.js +32 -6
  227. package/dist/task/deliveryGuard.js +16 -16
  228. package/dist/task/draftPlan.js +72 -12
  229. package/dist/task/nextAction.js +144 -128
  230. package/dist/task/remoteDelivery.js +6 -6
  231. package/dist/task/task.js +184 -18
  232. package/dist/task/taskActivation.js +327 -0
  233. package/dist/task/taskActivationService.js +408 -0
  234. package/dist/task/taskRecordReference.js +5 -4
  235. package/dist/task/taskRecordRetirement.js +1 -1
  236. package/dist/task/taskSubmission.js +236 -0
  237. package/dist/telemetry/sqliteTelemetryStore.js +55 -68
  238. package/dist/telemetry/telemetryConfig.js +14 -14
  239. package/dist/telemetry/telemetryWiring.js +2 -2
  240. package/dist/web/assets/assetManifest.js +2 -0
  241. package/dist/web/assets/client/app.js +121 -20
  242. package/dist/web/assets/client/components.js +87 -54
  243. package/dist/web/assets/client/i18n.js +83 -41
  244. package/dist/web/assets/client/markdown.js +1 -1
  245. package/dist/web/assets/client/taskSurface.js +442 -0
  246. package/dist/web/assets/client/view.js +49 -44
  247. package/dist/web/assets/shell.js +1 -1
  248. package/dist/web/assets/styles/cards.js +22 -4
  249. package/dist/web/controllerWeb.js +60 -0
  250. package/dist/web/webMutation.js +28 -0
  251. package/dist/web/webServer.js +133 -8
  252. package/dist/web/webSnapshot.js +81 -74
  253. package/dist/web/webTaskSurface.js +64 -0
  254. package/dist/workItem/dependencyGate.js +1 -1
  255. package/dist/workItem/workItem.js +84 -48
  256. package/dist/workspace/workItemChangeSetManager.js +16 -9
  257. package/docs/agent-result-consumption.md +96 -0
  258. package/docs/agent-result-consumption.zh-CN.md +81 -0
  259. package/docs/agent-runtime-drivers.md +93 -0
  260. package/docs/agent-runtime-drivers.zh-CN.md +77 -0
  261. package/docs/architecture/README.md +50 -0
  262. package/docs/architecture/README.zh-CN.md +43 -0
  263. package/docs/architecture/capabilities-and-resources.md +118 -0
  264. package/docs/architecture/capabilities-and-resources.zh-CN.md +83 -0
  265. package/docs/managed-turn-and-session-runtime.md +224 -0
  266. package/docs/managed-turn-and-session-runtime.zh-CN.md +180 -0
  267. package/docs/observability/README.md +83 -0
  268. package/docs/observability/README.zh-CN.md +71 -0
  269. package/docs/plugin-sdk.md +393 -0
  270. package/docs/plugin-sdk.zh-CN.md +293 -0
  271. package/docs/provider-runtime.md +165 -0
  272. package/docs/provider-runtime.zh-CN.md +132 -0
  273. package/docs/release-workflow.md +305 -0
  274. package/docs/release-workflow.zh-CN.md +237 -0
  275. package/docs/roles-and-configuration.md +115 -0
  276. package/docs/roles-and-configuration.zh-CN.md +96 -0
  277. package/docs/sqlite-control-plane-design.md +78 -0
  278. package/docs/sqlite-control-plane-design.zh-CN.md +62 -0
  279. package/docs/task-dag-semantics.md +80 -0
  280. package/docs/task-dag-semantics.zh-CN.md +59 -0
  281. package/docs/task-delivery.md +105 -0
  282. package/docs/task-delivery.zh-CN.md +82 -0
  283. package/docs/task-local-identity.md +8 -6
  284. package/docs/task-local-identity.zh-CN.md +58 -0
  285. package/docs/testing/verification-levels.md +88 -0
  286. package/docs/testing/verification-levels.zh-CN.md +69 -0
  287. package/i18n/README.zh-CN.md +270 -722
  288. package/package.json +3 -2
  289. package/skills/yui-leader/SKILL.md +88 -304
  290. package/skills/yui-leader/references/execution.md +303 -0
  291. package/skills/yui-leader/references/integration.md +39 -0
  292. package/skills/yui-leader/references/planning.md +109 -0
  293. package/skills/yui-leader/references/replicated-execution.md +42 -0
  294. package/skills/yui-leader/references/task-plugins.md +37 -0
  295. package/skills/yui-operator/SKILL.md +46 -62
  296. package/skills/yui-reviewer/SKILL.md +35 -36
  297. package/skills/yui-runtime/SKILL.md +88 -24
  298. package/skills/yui-runtime/references/publication.md +22 -0
  299. package/skills/yui-runtime/references/recovery.md +64 -0
  300. package/skills/yui-worker/SKILL.md +37 -39
  301. package/dist/cli/roleOptionCatalog.js +0 -68
  302. package/dist/context/sourceTurnContext.js +0 -30
  303. package/dist/execution/reviewMainTurn.js +0 -161
  304. package/dist/execution/workItemMainTurn.js +0 -164
  305. package/dist/lifecycle/exactTurnTerminalization.js +0 -407
  306. package/dist/runtime/preallocatedNativeSession.js +0 -13
  307. package/dist/runtime/runtimeStopReceipt.js +0 -42
  308. package/dist/scheduler/activeRoleTurnDelivery.js +0 -315
@@ -1,10 +1,11 @@
1
- import { isRoleTurnStalled, latestTurnDurableProgressAt } from "../scheduler/roleTurnStall.js";
1
+ import { isRoleRunStalled, latestRunDurableProgressAt } from "../scheduler/roleRunStall.js";
2
2
  import { retiredTaskRecordIds } from "../task/taskRecordRetirement.js";
3
3
  import { buildTaskExecutionProjection } from "../scheduler/taskExecutionProjection.js";
4
4
  import { projectWorkItemExecution } from "../execution/workItemExecutionProjection.js";
5
5
  import { classifyRuntimeHealth, projectRuntimeTaskEvents } from "../runtime/runtimeProjection.js";
6
6
  import { builtinDriverIdForAdapter } from "../runtime/builtinAgentDrivers.js";
7
- import { formatTurnReceiptId } from "../task/taskRecordReference.js";
7
+ import { formatRunReceiptId } from "../task/taskRecordReference.js";
8
+ import { runExecutionObservation } from "../agentRun/agentRun.js";
8
9
  import { resolveRuntimeHealth } from "../config/yuiConfig.js";
9
10
  import { projectSessionTokenMetrics, resolveSessionTokenIdentity } from "../runtime/sessionTokenMetrics.js";
10
11
  import { projectTaskRemoteDelivery } from "../task/remoteDelivery.js";
@@ -14,7 +15,7 @@ export function buildWebDashboardSnapshot(store, now = new Date()) {
14
15
  draft: 0,
15
16
  active: 0,
16
17
  completed: 0,
17
- retired: 0,
18
+ cancelled: 0,
18
19
  archived: 0
19
20
  };
20
21
  const projectNames = new Map(reader.listProjects().map((project) => [project.id, project.name]));
@@ -31,8 +32,8 @@ export function buildWebDashboardSnapshot(store, now = new Date()) {
31
32
  attention.push({ taskId: task.id, taskTitle: task.title, request });
32
33
  }
33
34
  const events = reader.listEvents?.(task.id) ?? [];
34
- const needsAttentionCount = reader.listTurns(task.id)
35
- .filter((turn) => turn.status === "active" && isRoleTurnStalled(events, turn.id))
35
+ const needsAttentionCount = reader.listRuns(task.id)
36
+ .filter((run) => run.status === "active" && isRoleRunStalled(events, run.id))
36
37
  .length;
37
38
  const execution = buildTaskExecutionProjection(reader, task.id, task, now);
38
39
  const names = task.projectBindings.flatMap(({ projectId }) => {
@@ -69,41 +70,51 @@ export function buildWebTaskDetail(store, taskId, now = new Date()) {
69
70
  const name = projectNamesById.get(projectId);
70
71
  return name === undefined ? [] : [name];
71
72
  });
72
- const turns = reader.listTurns(taskId);
73
+ const runs = reader.listRuns(taskId);
73
74
  const events = reader.listEvents?.(taskId) ?? [];
74
75
  const retiredMessageIds = retiredTaskRecordIds(events, "message");
75
- const needsAttentionTurns = turns
76
- .filter((turn) => turn.status === "active" && isRoleTurnStalled(events, turn.id))
77
- .map((turn) => ({
78
- turnId: turn.id,
79
- roleName: turn.roleName,
80
- progressAt: latestStallProgress(events, turn.id),
81
- kind: latestStallField(events, turn.id, "kind") ?? "workflow-not-progressing",
82
- classification: latestStallField(events, turn.id, "classification") ?? "truly-stalled"
76
+ const needsAttentionRuns = runs
77
+ .filter((run) => run.status === "active" && isRoleRunStalled(events, run.id))
78
+ .map((run) => ({
79
+ runId: run.id,
80
+ roleName: run.roleName,
81
+ progressAt: latestStallProgress(events, run.id),
82
+ kind: latestStallField(events, run.id, "kind") ?? "workflow-not-progressing",
83
+ classification: latestStallField(events, run.id, "classification") ?? "truly-stalled"
83
84
  }));
84
- const activeTurns = new Map(turns
85
- .filter((turn) => turn.status === "active")
86
- .map((turn) => [turn.roleName, turn]));
87
- const activeTurnHealth = turns
88
- .filter((turn) => turn.status === "active")
89
- .map((turn) => projectWebTurnRuntimeHealth(reader, taskId, turn, events, now, resolveRuntimeHealth(reader.getConfig().runtimeHealth)));
85
+ const activeRuns = new Map(runs
86
+ .filter((run) => run.status === "active")
87
+ .map((run) => [run.roleName, run]));
88
+ const activeRunHealth = runs
89
+ .filter((run) => run.status === "active")
90
+ .map((run) => projectWebRunRuntimeHealth(reader, taskId, run, events, now, resolveRuntimeHealth(reader.getConfig().runtimeHealth)));
90
91
  const roles = reader.listRoles(taskId).map((role) => {
91
- const activeTurn = activeTurns.get(role.name);
92
+ const activeRun = activeRuns.get(role.name);
92
93
  const sessions = reader.getTaskRoleSessionSet(taskId, role.name);
93
- const activeSession = sessions?.sessions[sessions.activeAgentId];
94
- const effectiveLaunch = activeTurn?.effective ?? activeSession?.effective ?? null;
94
+ const activeSession = sessions?.sessions[activeRun?.effective.agentId ?? sessions.activeAgentId];
95
+ const effectiveLaunch = activeRun?.effective ?? activeSession?.effective ?? null;
96
+ const delivery = sessions?.providerBinding?.run?.status;
95
97
  return {
96
98
  ...role,
97
- // Presentation only: workflow activity is derived from Turn; the
98
- // native Session contributes lifecycle detail when no Turn is active.
99
- status: activeTurn === undefined ? activeSession?.status ?? "idle" : "running",
99
+ // An open record is not proof that its Agent is running.
100
+ status: delivery === "accepted" ? "running"
101
+ : delivery === "submitting" || delivery === "deferred" ? "waiting"
102
+ : activeSession === undefined && activeRun === undefined ? "idle" : "unknown",
100
103
  sessionTokens: projectSessionTokenMetrics(events, resolveSessionTokenIdentity(activeSession === undefined
101
104
  ? null
102
105
  : { taskId, roleName: role.name, ...activeSession })),
103
106
  effectiveLaunch,
104
- effectiveLaunchSource: activeTurn === undefined
107
+ observedAt: now.toISOString(),
108
+ runtimeSession: activeSession === undefined ? null : {
109
+ agentId: activeSession.agentId,
110
+ adapterId: activeSession.adapterId,
111
+ nativeSessionId: activeSession.nativeSessionId ?? null,
112
+ status: activeSession.status,
113
+ endpointImplementation: activeSession.endpointImplementation ?? null
114
+ },
115
+ effectiveLaunchSource: activeRun === undefined
105
116
  ? activeSession === undefined ? null : "session"
106
- : "turn",
117
+ : "run",
107
118
  launchDrift: effectiveLaunch !== null
108
119
  && effectiveLaunch.sourceDesiredRevision !== role.launchRevision
109
120
  };
@@ -128,10 +139,10 @@ export function buildWebTaskDetail(store, taskId, now = new Date()) {
128
139
  workItems: workItems.map((item) => ({
129
140
  ...item,
130
141
  observability: workItemObservability.get(item.id),
131
- execution: projectWorkItemExecution(item, turns, roleSessionSets)
142
+ execution: projectWorkItemExecution(item, runs, roleSessionSets, reader)
132
143
  })),
133
- turns,
134
- runtimeHealth: { needsAttentionTurns, activeTurns: activeTurnHealth },
144
+ runs: runs.map((run) => ({ ...run, execution: runExecutionObservation(run, reader.getTaskRoleSessionSet(taskId, run.roleName)?.providerBinding, events) })),
145
+ runtimeHealth: { needsAttentionRuns, activeRuns: activeRunHealth },
135
146
  reviewRounds: reader.listReviewRounds(taskId),
136
147
  openInputs: inputs.filter((request) => request.status === "open"),
137
148
  messages: reader.listMessages(taskId).map((message) => ({
@@ -149,69 +160,68 @@ function webRemoteDelivery(reader, task) {
149
160
  events: reader.listEvents?.(task.id) ?? [],
150
161
  publications: reader.listPublicationReferences(task.id),
151
162
  managedWorkspaces: reader.listManagedWorkspaces(task.id),
152
- turns: reader.listTurns(task.id),
163
+ runs: reader.listRuns(task.id),
153
164
  currentCandidate: null
154
165
  });
155
166
  }
156
- function latestStallProgress(events, turnId) {
157
- return latestStallField(events, turnId, "progressAt");
167
+ function latestStallProgress(events, runId) {
168
+ return latestStallField(events, runId, "progressAt");
158
169
  }
159
170
  /**
160
- * Layered runtime health for one active Turn, computed from the same stored
171
+ * Layered runtime health for one active AgentRun, computed from the same stored
161
172
  * observations and durable semantic fold as the CLI status projection. The
162
173
  * Web snapshot has no live tmux pane, so host state stays "unknown"; the
163
174
  * classifier still surfaces session/turn/operation/observer layers and the
164
175
  * scheduler's durable `turn.stalled` episode is surfaced as
165
176
  * `stalled-candidate`.
166
177
  */
167
- function projectWebTurnRuntimeHealth(reader, taskId, turn, events, now, policy) {
168
- const stalled = isRoleTurnStalled(events, turn.id);
169
- const sessions = reader.getTaskRoleSessionSet(taskId, turn.roleName);
170
- const session = sessions?.sessions[turn.effective.agentId];
171
- const stallReason = "the live active Turn has no durable progress in the configured stall window";
172
- if (session?.runtimeGenerationId === undefined) {
178
+ function projectWebRunRuntimeHealth(reader, taskId, run, events, now, policy) {
179
+ const stalled = isRoleRunStalled(events, run.id);
180
+ const sessions = reader.getTaskRoleSessionSet(taskId, run.roleName);
181
+ const session = sessions?.sessions[run.effective.agentId];
182
+ const stallReason = "the live active AgentRun has no durable progress in the configured stall window";
183
+ if (session?.nativeSessionId === undefined) {
173
184
  return {
174
- turnId: turn.id,
175
- roleName: turn.roleName,
185
+ runId: run.id,
186
+ roleName: run.roleName,
176
187
  layer: stalled ? "stalled-candidate" : "awaiting-provider-acceptance",
177
- reason: stalled ? stallReason : "the active Turn is awaiting a Provider Session",
188
+ reason: stalled ? stallReason : "the active AgentRun is awaiting a Provider Session",
178
189
  stalled,
179
- lastSemanticProgressAt: turn.createdAt
190
+ lastSemanticProgressAt: run.createdAt
180
191
  };
181
192
  }
182
193
  let driverId;
183
194
  try {
184
- driverId = builtinDriverIdForAdapter(turn.effective.adapterId);
195
+ driverId = builtinDriverIdForAdapter(run.effective.adapterId);
185
196
  }
186
197
  catch {
187
198
  return {
188
- turnId: turn.id,
189
- roleName: turn.roleName,
199
+ runId: run.id,
200
+ roleName: run.roleName,
190
201
  layer: stalled ? "stalled-candidate" : "runtime-unobservable",
191
202
  reason: stalled ? stallReason : "the Agent Driver is not a built-in driver",
192
203
  stalled,
193
- lastSemanticProgressAt: turn.createdAt
204
+ lastSemanticProgressAt: run.createdAt
194
205
  };
195
206
  }
196
- const providerTurn = sessions?.providerBinding?.turn;
207
+ const providerTurn = sessions?.providerBinding?.run;
197
208
  const fence = {
198
209
  taskId,
199
- roleName: turn.roleName,
200
- turnId: turn.id,
201
- agentId: turn.effective.agentId,
210
+ roleName: run.roleName,
211
+ runId: run.id,
212
+ agentId: run.effective.agentId,
202
213
  driverId,
203
- runtimeGenerationId: session.runtimeGenerationId,
204
214
  nativeSessionId: session.nativeSessionId,
205
- nativeTurnId: providerTurn?.turnId === turn.id
206
- ? providerTurn.nativeTurnId ?? turn.id
207
- : turn.id,
208
- receiptId: providerTurn?.turnId === turn.id
215
+ nativeTurnId: providerTurn?.runId === run.id
216
+ ? providerTurn.nativeTurnId ?? run.id
217
+ : run.id,
218
+ receiptId: providerTurn?.runId === run.id
209
219
  ? providerTurn.attemptId
210
- : formatTurnReceiptId(taskId, turn.id)
220
+ : formatRunReceiptId(taskId, run.id)
211
221
  };
212
- const projection = projectRuntimeTaskEvents(fence, turn.createdAt, events);
222
+ const projection = projectRuntimeTaskEvents(fence, run.createdAt, events);
213
223
  const view = {
214
- getTurn: (taskId, turnId) => reader.listTurns(taskId).find((candidate) => candidate.id === turnId) ?? null,
224
+ getRun: (taskId, runId) => reader.listRuns(taskId).find((candidate) => candidate.id === runId) ?? null,
215
225
  listEvents: () => events,
216
226
  getWorkItem: (workItemTaskId, workItemId) => reader.listWorkItems(workItemTaskId).find((item) => item.id === workItemId) ?? null,
217
227
  listReviewRounds: (taskId) => reader.listReviewRounds(taskId),
@@ -219,8 +229,8 @@ function projectWebTurnRuntimeHealth(reader, taskId, turn, events, now, policy)
219
229
  listIntegrationAttempts: (taskId) => reader.listIntegrationAttempts(taskId),
220
230
  listInputRequests: (taskId) => reader.listInputRequests(taskId)
221
231
  };
222
- const semanticProgress = latestTurnDurableProgressAt(view, taskId, turn.roleName, turn.id)
223
- ?? { progressAt: turn.createdAt };
232
+ const semanticProgress = latestRunDurableProgressAt(view, taskId, run.roleName, run.id)
233
+ ?? { progressAt: run.createdAt };
224
234
  const classification = classifyRuntimeHealth({
225
235
  projection,
226
236
  semanticProgressAt: semanticProgress.progressAt,
@@ -228,8 +238,8 @@ function projectWebTurnRuntimeHealth(reader, taskId, turn, events, now, policy)
228
238
  policy
229
239
  });
230
240
  return {
231
- turnId: turn.id,
232
- roleName: turn.roleName,
241
+ runId: run.id,
242
+ roleName: run.roleName,
233
243
  layer: stalled ? "stalled-candidate" : classification.layer,
234
244
  reason: stalled ? stallReason : classification.reason,
235
245
  stalled,
@@ -239,10 +249,10 @@ function projectWebTurnRuntimeHealth(reader, taskId, turn, events, now, policy)
239
249
  lastSemanticProgressAt: classification.lastSemanticProgressAt
240
250
  };
241
251
  }
242
- function latestStallField(events, turnId, field) {
252
+ function latestStallField(events, runId, field) {
243
253
  const stalled = events
244
- .filter((event) => event.type === "turn.stalled"
245
- && event.payload.turnId === turnId
254
+ .filter((event) => event.type === "run.stalled"
255
+ && event.payload.runId === runId
246
256
  && event.payload.status !== "diagnostic-only")
247
257
  .sort((left, right) => Date.parse(right.createdAt) - Date.parse(left.createdAt))[0];
248
258
  return stalled?.payload[field];
@@ -250,11 +260,8 @@ function latestStallField(events, turnId, field) {
250
260
  function countWorkItems(items) {
251
261
  const counts = {
252
262
  total: items.length,
253
- pending: 0,
254
- running: 0,
255
- awaiting_acceptance: 0,
256
- completed: 0,
257
- failed: 0,
263
+ open: 0,
264
+ accepted: 0,
258
265
  retired: 0
259
266
  };
260
267
  const mutable = counts;
@@ -268,7 +275,7 @@ function compareDashboardTasks(left, right) {
268
275
  active: 0,
269
276
  draft: 1,
270
277
  completed: 2,
271
- retired: 3,
278
+ cancelled: 3,
272
279
  archived: 4
273
280
  };
274
281
  return statusOrder[left.status] - statusOrder[right.status]
@@ -0,0 +1,64 @@
1
+ import { readTaskContext, readTaskContextDelta, inspectTaskContext, withContextObservations } from "../context/taskContext.js";
2
+ import { BUILTIN_CAPABILITIES } from "../kernel/builtinCapabilities.js";
3
+ import { capabilitySchemaError } from "../kernel/capabilitySchema.js";
4
+ import { updateTaskMetadataCommand, sendTaskMessageCommand } from "../commands/taskCommands.js";
5
+ import { webLocalMutation, WebRequestRejected } from "./webMutation.js";
6
+ import { runTaskInputCommand } from "../commands/taskInputCommands.js";
7
+ /** Installed only by the local-user Web composition root. HTTP authenticates
8
+ * its token before using this port; input never supplies a caller or Role.
9
+ * Managed capability RPC keeps its own Session authentication unchanged.
10
+ */
11
+ export function createWebTaskSurface(store, options = {}, observations = []) {
12
+ const environment = {};
13
+ const commandOptions = { ...options, environment, runtime: undefined };
14
+ // Notifications are after the outer transaction. Their failure must not be
15
+ // reclassified as a rejection of a mutation that already committed.
16
+ const notify = (taskId, leader = false) => {
17
+ if (options.runtime?.notifyMailboxChanged) {
18
+ void options.runtime.notifyMailboxChanged(leader
19
+ ? { kind: "role", taskId, roleName: "leader" } : { kind: "task", taskId });
20
+ }
21
+ else
22
+ options.runtime?.notifyStateChanged(taskId);
23
+ };
24
+ return {
25
+ message: (taskId, body, intent, requestId) => {
26
+ // With no explicit intent the Web surface submits `discuss` like every other
27
+ // client (§2.5), through the one shared service; the requestId is threaded as
28
+ // the submission key (§2.3) and the structured feedback is returned verbatim.
29
+ const { message, task, queuedForLeader, feedback } = webLocalMutation(store, (tx) => sendTaskMessageCommand(tx, taskId, body, undefined, commandOptions, undefined, intent, requestId));
30
+ notify(taskId, queuedForLeader);
31
+ return { record: message, revision: message.createdAt,
32
+ disposition: queuedForLeader ? "queued" : "saved",
33
+ planning: task.status === "draft",
34
+ ...(feedback === undefined ? {} : { submission: feedback }),
35
+ target: { scope: "task", taskId, roleName: "leader" } };
36
+ },
37
+ read: async (taskId) => withContextObservations(readTaskContext(store, taskId, environment), observations),
38
+ delta: (taskId, input) => readTaskContextDelta(store, taskId, input, environment),
39
+ inspect: (taskId, input) => inspectTaskContext(store, taskId, input, environment),
40
+ update: (taskId, input) => {
41
+ const descriptor = BUILTIN_CAPABILITIES.find((entry) => entry.name === "task.update");
42
+ const error = capabilitySchemaError(descriptor.inputSchema, { taskId, patch: input });
43
+ if (error)
44
+ throw new WebRequestRejected(error);
45
+ const patch = input;
46
+ const record = webLocalMutation(store, (tx) => updateTaskMetadataCommand(tx, taskId, {
47
+ ...patch,
48
+ ...(patch.description === "" ? { description: null } : {}),
49
+ ...(patch.tags?.length === 0 ? { tags: null } : {})
50
+ }, commandOptions));
51
+ notify(taskId);
52
+ return { record, revision: record.updatedAt };
53
+ },
54
+ answer: (taskId, inputId, answer) => {
55
+ const result = webLocalMutation(store, (tx) => runTaskInputCommand([
56
+ "answer", inputId, "--task", taskId,
57
+ ...("choiceKey" in answer ? ["--choice", answer.choiceKey] : ["--text", answer.text])
58
+ ], tx, commandOptions));
59
+ const data = result.data;
60
+ notify(taskId, true);
61
+ return data.request;
62
+ }
63
+ };
64
+ }
@@ -21,7 +21,7 @@ export class WorkItemDependencyGateError extends Error {
21
21
  export function assertWorkItemDependenciesCompleted(store, item) {
22
22
  const unmetDependencies = item.dependsOn.flatMap((dependencyId) => {
23
23
  const dependency = store.getWorkItem(item.taskId, dependencyId);
24
- if (dependency?.status === "completed")
24
+ if (dependency?.status === "accepted")
25
25
  return [];
26
26
  return [{
27
27
  id: dependencyId,