@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
@@ -8,9 +8,9 @@ export function buildTaskObservabilityProjection(input) {
8
8
  const dag = projectDag(input.workItems);
9
9
  const workItems = input.workItems.map((item) => {
10
10
  const groups = item.executionGroups;
11
- const itemCost = projectWorkItemCost(groups, input.turns, now);
12
- const itemContext = projectContext(groups, input.turns, input.contextSnapshots);
13
- const producerObservability = projectWorkItemProducerObservability(item, input.turns);
11
+ const itemCost = projectWorkItemCost(groups, input.runs, now);
12
+ const itemContext = projectContext(groups, input.runs, input.contextSnapshots);
13
+ const producerObservability = projectWorkItemProducerObservability(item, input.runs);
14
14
  return Object.freeze({
15
15
  workItemId: item.id,
16
16
  title: item.title,
@@ -21,8 +21,8 @@ export function buildTaskObservabilityProjection(input) {
21
21
  resultCount: producerObservability?.resultCount ?? null
22
22
  });
23
23
  });
24
- const cost = projectCost(input.executionGroups, input.turns, input.events, now);
25
- const context = projectContext(input.executionGroups, input.turns, input.contextSnapshots);
24
+ const cost = projectCost(input.executionGroups, input.runs, input.events, now);
25
+ const context = projectContext(input.executionGroups, input.runs, input.contextSnapshots);
26
26
  return Object.freeze({
27
27
  dag,
28
28
  workItems,
@@ -31,21 +31,21 @@ export function buildTaskObservabilityProjection(input) {
31
31
  sessionTokens: Object.freeze([...(input.sessionTokens ?? [])])
32
32
  });
33
33
  }
34
- function projectWorkItemProducerObservability(item, turns) {
34
+ function projectWorkItemProducerObservability(item, runs) {
35
35
  const successfulLanes = item.executionGroups.flatMap((group) => group.lanes.flatMap((lane) => (lane.disposition === "succeeded" ? [{ group, lane }] : [])));
36
36
  let resultCount = 0;
37
37
  for (const { group, lane } of successfulLanes) {
38
- const turn = lane.successfulTurnId === undefined
38
+ const run = lane.successfulRunId === undefined
39
39
  ? undefined
40
- : turns.find(({ id }) => id === lane.successfulTurnId);
41
- if (turn === undefined
42
- || turn.result === undefined
43
- || turn.status !== "completed"
44
- || turn.taskId !== item.taskId
45
- || turn.workItemId !== item.id
46
- || turn.executionGroupId !== group.id
47
- || turn.executionLaneId !== lane.id
48
- || turn.roleName !== lane.roleName)
40
+ : runs.find(({ id }) => id === lane.successfulRunId);
41
+ if (run === undefined
42
+ || run.result === undefined
43
+ || run.status !== "completed"
44
+ || run.taskId !== item.taskId
45
+ || run.workItemId !== item.id
46
+ || run.executionGroupId !== group.id
47
+ || run.executionLaneId !== lane.id
48
+ || run.roleName !== lane.roleName)
49
49
  return null;
50
50
  resultCount += 1;
51
51
  }
@@ -69,7 +69,7 @@ function projectDag(workItems) {
69
69
  const unresolved = item.dependsOn.filter((dependency) => {
70
70
  return !dependencySatisfied(dependency, byId);
71
71
  });
72
- const projectedStatus = item.status === "pending"
72
+ const projectedStatus = item.status === "open"
73
73
  ? unresolved.length === 0 ? "ready" : "blocked"
74
74
  : item.status;
75
75
  return Object.freeze({
@@ -110,13 +110,13 @@ function rootCauses(id, byId) {
110
110
  }
111
111
  const unresolved = item.dependsOn.filter((dependency) => !dependencySatisfied(dependency, byId));
112
112
  if (unresolved.length === 0) {
113
- if (item.status === "failed" || item.status === "awaiting_acceptance")
113
+ if (item.status === "open" && item.currentCandidateId !== undefined)
114
114
  result.push(item.id);
115
115
  return;
116
116
  }
117
117
  for (const dependency of unresolved) {
118
118
  const target = byId.get(dependency);
119
- if (target?.status === "failed" || target?.status === "awaiting_acceptance")
119
+ if (target?.status === "open" && target.currentCandidateId !== undefined)
120
120
  result.push(target.id);
121
121
  else
122
122
  visit(dependency);
@@ -126,7 +126,7 @@ function rootCauses(id, byId) {
126
126
  return [...new Set(result)];
127
127
  }
128
128
  function dependencySatisfied(id, byId) {
129
- return byId.get(id)?.status === "completed";
129
+ return byId.get(id)?.status === "accepted";
130
130
  }
131
131
  function dependencyEdgeStatus(id, byId) {
132
132
  const target = byId.get(id);
@@ -136,14 +136,14 @@ function dependencyEdgeStatus(id, byId) {
136
136
  return "satisfied";
137
137
  if (target.status === "retired")
138
138
  return "dead";
139
- if (target.status === "failed" || target.status === "awaiting_acceptance")
140
- return "failed-open";
139
+ if (target.status === "open" && target.currentCandidateId !== undefined)
140
+ return "active";
141
141
  return "active";
142
142
  }
143
- function projectCost(groups, turns, _events, now) {
143
+ function projectCost(groups, runs, _events, now) {
144
144
  const uniqueGroups = [...new Map(groups.map((group) => [group.id, group])).values()];
145
145
  const groupIds = new Set(uniqueGroups.map(({ id }) => id));
146
- const attempts = turns.filter(({ executionGroupId }) => (executionGroupId !== undefined && groupIds.has(executionGroupId)));
146
+ const attempts = runs.filter(({ executionGroupId }) => (executionGroupId !== undefined && groupIds.has(executionGroupId)));
147
147
  const laneCount = uniqueGroups.reduce((total, group) => total + group.lanes.length, 0);
148
148
  return Object.freeze({
149
149
  tokens: 0,
@@ -158,9 +158,9 @@ function projectCost(groups, turns, _events, now) {
158
158
  marginalValueStatus: "unavailable"
159
159
  });
160
160
  }
161
- function projectWorkItemCost(groups, turns, now) {
161
+ function projectWorkItemCost(groups, runs, now) {
162
162
  const groupIds = new Set(groups.map(({ id }) => id));
163
- const attempts = turns.filter(({ executionGroupId }) => (executionGroupId !== undefined && groupIds.has(executionGroupId)));
163
+ const attempts = runs.filter(({ executionGroupId }) => (executionGroupId !== undefined && groupIds.has(executionGroupId)));
164
164
  const wallClockSeconds = groups.reduce((total, group) => {
165
165
  const started = Date.parse(group.createdAt);
166
166
  const ended = group.lanes.some(({ disposition }) => disposition === "open")
@@ -184,15 +184,15 @@ function projectWorkItemCost(groups, turns, now) {
184
184
  marginalValueStatus: "unavailable"
185
185
  });
186
186
  }
187
- function projectContext(groups, turns, snapshots) {
187
+ function projectContext(groups, runs, snapshots) {
188
188
  const refs = new Map();
189
189
  for (const group of groups) {
190
190
  const ref = group.assignment.contextSnapshotRef;
191
191
  if (ref !== undefined)
192
192
  refs.set(ref.id, ref);
193
193
  }
194
- for (const turn of turns) {
195
- const ref = turn.inputs[0].input.contextSnapshotRef;
194
+ for (const run of runs) {
195
+ const ref = run.inputs[0].input.contextSnapshotRef;
196
196
  if (ref !== undefined)
197
197
  refs.set(ref.id, ref);
198
198
  }
@@ -1,5 +1,6 @@
1
1
  import { requireIdentity, requirePositiveInteger, requireText, requireTimestamp } from "../domain/validation.js";
2
2
  import { TASK_RECORD_ID_PREFIXES } from "../task/taskRecordReference.js";
3
+ import { copyRef } from "../coordination/workMailbox.js";
3
4
  export const CURRENT_TASK_WAKE_SCHEMA_VERSION = 1;
4
5
  export function createTaskWake(input) {
5
6
  const wake = {
@@ -8,16 +9,22 @@ export function createTaskWake(input) {
8
9
  taskId: requireIdentity(input.taskId, "Task id"),
9
10
  seq: wakeSequence(input.id),
10
11
  reasons: Object.freeze(input.reasons.map((reason) => requireText(reason, "Wake reason"))),
12
+ ...(input.refs === undefined ? {} : { refs: Object.freeze(input.refs.map(copyRef)) }),
11
13
  fromCursor: requireTimestamp(input.fromCursor, "Wake fromCursor"),
12
14
  toCursor: requireTimestamp(input.toCursor, "Wake toCursor"),
13
15
  status: "dispatched",
14
- turnId: requireIdentity(input.turnId, "Wake Turn id"),
16
+ ...(input.runId === undefined ? {} : { runId: requireIdentity(input.runId, "Wake AgentRun id") }),
15
17
  createdAt: input.now.toISOString()
16
18
  };
17
19
  validateTaskWake(wake);
18
20
  return wake;
19
21
  }
20
22
  export function validateTaskWake(wake) {
23
+ if (wake.refs !== undefined) {
24
+ if (!Array.isArray(wake.refs))
25
+ throw new Error("Wake references must be an array.");
26
+ wake.refs.forEach(copyRef);
27
+ }
21
28
  if (wake.schemaVersion !== CURRENT_TASK_WAKE_SCHEMA_VERSION) {
22
29
  throw new Error(`Task wake ${wake.id} must use schemaVersion ${CURRENT_TASK_WAKE_SCHEMA_VERSION}.`);
23
30
  }
@@ -55,12 +62,12 @@ export function latestTaskWake(wakes) {
55
62
  return latest;
56
63
  }
57
64
  /**
58
- * The delta lower bound for a Task's first wake: the last Leader Turn's
65
+ * The delta lower bound for a Task's first wake: the last Leader AgentRun's
59
66
  * creation time, preserving the pre-ledger watermark semantics. When no
60
- * Leader Turn exists, the Task's own creation time bounds the window.
67
+ * Leader AgentRun exists, the Task's own creation time bounds the window.
61
68
  */
62
69
  export function fallbackWakeCursor(input) {
63
- return input.leaderTurnCreatedAt ?? input.taskCreatedAt;
70
+ return input.leaderRunCreatedAt ?? input.taskCreatedAt;
64
71
  }
65
72
  function wakeSequence(id) {
66
73
  const prefix = `${TASK_RECORD_ID_PREFIXES.taskWake}-`;
@@ -8,7 +8,7 @@
8
8
  * queue — the wake layer owns the meaning of its tags.
9
9
  *
10
10
  * Tag wire format: `<kind>` or `<kind>:<ref>`. The ref is an exact record
11
- * identifier (InputRequest id, Turn id, ...) or, for `force-wake`, the
11
+ * identifier (InputRequest id, AgentRun id, ...) or, for `force-wake`, the
12
12
  * operator-supplied text. Unknown kinds parse losslessly so a newer producer
13
13
  * can never wedge an older reader.
14
14
  */
@@ -17,6 +17,7 @@ export const WAKE_REASON_KINDS = Object.freeze([
17
17
  "input-timeout",
18
18
  "role-turn-stalled",
19
19
  "agent-error",
20
+ "activation-failed",
20
21
  "agent-session-recovery",
21
22
  "review-failed",
22
23
  "task-reopened",
@@ -27,6 +28,13 @@ export const WAKE_REASON_KINDS = Object.freeze([
27
28
  "force-wake"
28
29
  ]);
29
30
  const IMMEDIATE_KINDS = new Set([
31
+ "operator-input",
32
+ "user-message",
33
+ "task-created",
34
+ "execution-started",
35
+ "session-replaced",
36
+ "force-wake",
37
+ "activation-failed",
30
38
  "task-reopened",
31
39
  "leader-turn-failed",
32
40
  "role-turn-failed"
@@ -53,14 +53,10 @@ export async function runSetupCommand(args, env, executor, io = {}) {
53
53
  return `${[
54
54
  "Yui setup complete.",
55
55
  `Yui home: ${home}.`,
56
- `Operator Agent: ${agent.id}.`,
57
- `Leader Agent: ${roleStatus.leaderAgentId}.`,
56
+ `Operator: ${agent.id} (${roleStatus.operator}).`,
57
+ `Leader: ${roleStatus.leaderAgentId} (${roleStatus.leader}).`,
58
58
  `Default workspace: ${workspace}.`,
59
- `Operator configuration: ${roleStatus.operator}.`,
60
- `Leader configuration: ${roleStatus.leader}.`,
61
- `Tmux: ${tmuxBin}.`,
62
- "Setup did not configure Review, Worker, Profiles, or shell completion.",
63
- "Run `yui operator enter` to continue, or `yui config show` to inspect configuration."
59
+ "Run `yui config show` to inspect configuration, or `yui operator enter` to start an Operator session for configuration changes or development tasks."
64
60
  ].join("\n")}\n`;
65
61
  }
66
62
  finally {
@@ -0,0 +1,159 @@
1
+ import { createContextSnapshot, contextContentDigest } from "../../context/contextSnapshot.js";
2
+ /** Storage 12 -> 13 only. Text, native identities and opaque record/receipt ids
3
+ * are never renamed. Ordinary runtime stores do not interpret old payloads.
4
+ * v13 also introduces optional Message recipient/continuation/handovers.
5
+ * Existing messages have no recipient and remain informational/Leader wakes;
6
+ * migration never guesses an owner or causes historical messages to execute.
7
+ */
8
+ export function migrateAgentRunContract(db) {
9
+ // T08 already stored real planning executions. Use that frozen evidence,
10
+ // never the Task's current status, to classify their shared Session snapshots.
11
+ const planningLaunches = new Set();
12
+ for (const row of db.prepare("SELECT task_id, payload FROM turns").all()) {
13
+ const run = JSON.parse(row.payload);
14
+ if (run.purpose === "planning") {
15
+ planningLaunches.add(`${row.task_id}:${contextContentDigest(run.effective)}`);
16
+ }
17
+ }
18
+ const snapshotDigests = new Map();
19
+ const renameKey = (key) => {
20
+ if (key === "turn")
21
+ return "run";
22
+ if (key === "turns")
23
+ return "runs";
24
+ if (key === "turnId")
25
+ return "runId";
26
+ if (key === "turnIds")
27
+ return "runIds";
28
+ if (/NativeTurn|ProviderTurn|CompletedTurn|nativeTurn|providerTurn/.test(key))
29
+ return key;
30
+ return key.replaceAll("Turn", "Run").replace(/^turn(?=[A-Z])/, "run")
31
+ .replaceAll("TURN_", "RUN_").replaceAll("_TURN", "_RUN");
32
+ };
33
+ const untouched = new Set(["advanced", "metadata", "environment", "raw", "output", "body",
34
+ "description", "summary", "directive", "config"]);
35
+ const migrate = (value, taskId, purpose) => {
36
+ if (Array.isArray(value))
37
+ return value.map((entry) => migrate(entry, taskId, purpose));
38
+ if (value === null || typeof value !== "object")
39
+ return value;
40
+ const input = value;
41
+ const ownerTaskId = typeof input.taskId === "string" ? input.taskId : taskId;
42
+ const executionPurpose = typeof input.purpose === "string" ? input.purpose : purpose;
43
+ const result = {};
44
+ for (const [key, child] of Object.entries(input)) {
45
+ let next = untouched.has(key) ? child : migrate(child, ownerTaskId, executionPurpose);
46
+ if ((key === "type" || key === "recordKind" || key === "store") && child === "turn")
47
+ next = "run";
48
+ if (key === "type" && typeof child === "string" && child.startsWith("turn.")
49
+ && typeof input.id === "string" && input.id.startsWith("event-") && input.createdAt !== undefined) {
50
+ next = child.replace(/^turn\./, "run.");
51
+ }
52
+ if (key === "store" && child === "source-turn")
53
+ next = "source-run";
54
+ // Runtime envelopes are structured evidence encoded inside Task Events,
55
+ // not free-form Provider output.
56
+ if (key === "observation" && typeof child === "string") {
57
+ const parsed = JSON.parse(child);
58
+ next = JSON.stringify(migrate(parsed, ownerTaskId));
59
+ }
60
+ result[renameKey(key)] = next;
61
+ }
62
+ if (typeof input.digest === "string" && typeof input.id === "string"
63
+ && input.id.startsWith("context-snapshot-") && typeof input.sequence === "number") {
64
+ result.digest = snapshotDigests.get(input.digest) ?? input.digest;
65
+ }
66
+ // A Run has its own authoritative purpose. Session copies are classified
67
+ // by the exact planning launch they retain; activation never upgrades them.
68
+ if (input.schemaVersion === 3 && typeof input.agentId === "string"
69
+ && typeof input.sourceDesiredRevision === "number" && input.workspace !== undefined
70
+ && input.context !== undefined && input.permission !== undefined) {
71
+ result.executionAuthority = executionPurpose === "planning"
72
+ || (ownerTaskId !== undefined && planningLaunches.has(`${ownerTaskId}:${contextContentDigest(input)}`))
73
+ ? "planning" : "delivery";
74
+ }
75
+ return result;
76
+ };
77
+ const snapshots = db.prepare("SELECT rowid, payload FROM context_snapshots")
78
+ .all();
79
+ const originals = new Map(snapshots.map((row) => {
80
+ const snapshot = JSON.parse(row.payload);
81
+ return [`${snapshot.taskId}/${snapshot.id}`, { ...row, snapshot }];
82
+ }));
83
+ const visiting = new Set();
84
+ const completed = new Set();
85
+ const migrateSnapshot = (key) => {
86
+ if (completed.has(key))
87
+ return;
88
+ const row = originals.get(key);
89
+ if (row === undefined)
90
+ return; // Preserve unresolved historical references as references.
91
+ if (visiting.has(key))
92
+ throw new Error("Context Snapshot references contain a cycle.");
93
+ visiting.add(key);
94
+ const original = row.snapshot;
95
+ // Dependency order, not wall-clock order: async callers can freeze with
96
+ // an earlier pass timestamp while referencing an already committed parent.
97
+ const visitReferences = (value) => {
98
+ if (value === null || typeof value !== "object")
99
+ return;
100
+ if (Array.isArray(value)) {
101
+ value.forEach(visitReferences);
102
+ return;
103
+ }
104
+ const ref = value;
105
+ if (typeof ref.id === "string" && ref.id.startsWith("context-snapshot-")
106
+ && typeof ref.taskId === "string" && typeof ref.digest === "string"
107
+ && typeof ref.sequence === "number")
108
+ migrateSnapshot(`${ref.taskId}/${ref.id}`);
109
+ for (const [field, child] of Object.entries(ref)) {
110
+ if (!untouched.has(field))
111
+ visitReferences(child);
112
+ }
113
+ };
114
+ visitReferences(original.parentRef);
115
+ visitReferences(original.resources);
116
+ const current = migrate(original);
117
+ const resources = current.resources.map((entry) => ({
118
+ ...entry, ref: { ...entry.ref, digest: contextContentDigest(entry.value) }
119
+ }));
120
+ const refs = current.refs.map((ref) => resources.find((entry) => entry.ref.layer === ref.layer && entry.ref.store === ref.store && entry.ref.refId === ref.refId)?.ref ?? ref);
121
+ const snapshot = createContextSnapshot({ ...current, resources, refs, frozenAt: new Date(current.frozenAt) });
122
+ snapshotDigests.set(original.digest, snapshot.digest);
123
+ db.prepare("UPDATE context_snapshots SET payload = ?, digest = ? WHERE rowid = ?")
124
+ .run(JSON.stringify(snapshot), snapshot.digest, row.rowid);
125
+ visiting.delete(key);
126
+ completed.add(key);
127
+ };
128
+ for (const key of originals.keys())
129
+ migrateSnapshot(key);
130
+ const tables = [
131
+ "config", "agent_profiles", "global_roles", "global_role_session_sets",
132
+ "task_records", "task_roles", "role_session_sets", "work_items", "work_item_candidates",
133
+ "turns", "active_turns", "review_rounds", "change_sets", "integration_attempts",
134
+ "messages", "input_requests", "decisions", "milestones", "events", "task_projections",
135
+ "durable_jobs", "integration_queue", "task_wakes", "telemetry", "telemetry_aggregate"
136
+ ];
137
+ const rewriteColumn = (table, column) => {
138
+ const columns = db.prepare(`PRAGMA table_info("${table}")`).all();
139
+ if (!columns.some((entry) => entry.name === column))
140
+ return;
141
+ const keys = columns.filter((entry) => entry.pk > 0).sort((a, b) => a.pk - b.pk).map((entry) => entry.name);
142
+ if (!keys.length)
143
+ throw new Error(`Migration requires the primary key of ${table}.`);
144
+ const quote = (value) => `"${value.replaceAll('"', '""')}"`;
145
+ const rows = db.prepare(`SELECT * FROM ${quote(table)} WHERE ${quote(column)} IS NOT NULL`)
146
+ .all();
147
+ const update = db.prepare(`UPDATE ${quote(table)} SET ${quote(column)} = ? WHERE ${keys.map((key) => `${quote(key)} = ?`).join(" AND ")}`);
148
+ for (const row of rows) {
149
+ update.run(JSON.stringify(migrate(JSON.parse(row[column]), typeof row.task_id === "string" ? row.task_id : undefined)), ...keys.map((key) => row[key]));
150
+ }
151
+ };
152
+ for (const table of tables) {
153
+ rewriteColumn(table, "payload");
154
+ }
155
+ for (const column of ["pending", "processing"]) {
156
+ rewriteColumn("mailboxes", column);
157
+ }
158
+ db.prepare("UPDATE id_sequences SET kind = 'run' WHERE kind = 'turn'").run();
159
+ }