@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.
Files changed (281) hide show
  1. package/ARCHITECTURE.md +192 -399
  2. package/README.md +127 -1149
  3. package/dist/agent/adapterCatalog.js +15 -2
  4. package/dist/agent/agent.js +23 -3
  5. package/dist/agent/argumentPolicy.js +7 -1
  6. package/dist/agent/connectionPlan.js +62 -0
  7. package/dist/agent/executionComponents.js +158 -0
  8. package/dist/agent/launchEnvironment.js +31 -3
  9. package/dist/agent/managedRuntimeEnvironment.js +3 -5
  10. package/dist/{turn/turn.js → agentRun/agentRun.js} +166 -109
  11. package/dist/{turn/turnIdentity.js → agentRun/runIdentity.js} +4 -4
  12. package/dist/brief/taskBrief.js +12 -0
  13. package/dist/cli/agentConfigurationPicker.js +13 -0
  14. package/dist/cli/commandCatalog.js +157 -70
  15. package/dist/cli/interactionCandidates.js +5 -5
  16. package/dist/cli/interactionPolicy.js +38 -8
  17. package/dist/cli/invocationRouter.js +1 -1
  18. package/dist/cli/managedDiagnostics.js +28 -0
  19. package/dist/cli/operatorWizard.js +1 -7
  20. package/dist/cli/roleOptionOrder.js +27 -0
  21. package/dist/cli/roleWizard.js +50 -14
  22. package/dist/cli/updateOrchestrator.js +1 -1
  23. package/dist/cli/updatePorts.js +3 -4
  24. package/dist/cli.js +178 -95
  25. package/dist/commands/agentCommands.js +72 -14
  26. package/dist/commands/capabilityCommands.js +9 -6
  27. package/dist/commands/configCommands.js +20 -20
  28. package/dist/commands/deliveryGuardPreflight.js +2 -2
  29. package/dist/commands/executionAuditCommands.js +24 -24
  30. package/dist/commands/globalRoleCommands.js +1 -1
  31. package/dist/commands/grantCommands.js +4 -4
  32. package/dist/commands/operatorCommands.js +1 -7
  33. package/dist/commands/projectCommands.js +4 -4
  34. package/dist/commands/resourcesCommands.js +2 -2
  35. package/dist/commands/roleConfiguration.js +25 -5
  36. package/dist/commands/roleRuntimeGuard.js +4 -5
  37. package/dist/commands/sessionCommands.js +3 -7
  38. package/dist/commands/taskActivationCommands.js +259 -0
  39. package/dist/commands/taskActor.js +28 -49
  40. package/dist/commands/taskCommands.js +1188 -710
  41. package/dist/commands/taskContextCommand.js +39 -583
  42. package/dist/commands/taskExecutionCommands.js +32 -32
  43. package/dist/commands/taskInputCommands.js +40 -104
  44. package/dist/commands/taskIntegrationCommands.js +3 -2
  45. package/dist/commands/taskIntegrationQueueCommands.js +1 -1
  46. package/dist/commands/taskNextActionCommand.js +8 -8
  47. package/dist/commands/taskOverviewCommand.js +33 -45
  48. package/dist/commands/taskRemoteDeliveryCommand.js +2 -2
  49. package/dist/commands/taskRoleRuntimeStatus.js +133 -102
  50. package/dist/commands/telemetryCommands.js +36 -38
  51. package/dist/config/configCatalog.js +4 -4
  52. package/dist/config/yuiConfig.js +8 -8
  53. package/dist/context/contextSnapshot.js +10 -10
  54. package/dist/context/dispatchContext.js +11 -11
  55. package/dist/context/roleSessionContext.js +6 -3
  56. package/dist/context/{turnContextPack.js → runContextPack.js} +146 -81
  57. package/dist/context/{turnInputContract.js → runInputContract.js} +73 -60
  58. package/dist/context/sessionBootstrapManifest.js +21 -2
  59. package/dist/context/sourceRunContext.js +30 -0
  60. package/dist/context/taskContext.js +458 -0
  61. package/dist/context/wakeNotification.js +27 -27
  62. package/dist/controller/agentRuntimeObserver.js +21 -24
  63. package/dist/controller/capabilityBridge.js +17 -6
  64. package/dist/controller/clientRuntime.js +65 -92
  65. package/dist/controller/controller.js +114 -188
  66. package/dist/controller/fileSchedulerStoreAdapter.js +787 -887
  67. package/dist/controller/jobControl.js +54 -85
  68. package/dist/controller/resourceInventory.js +8 -27
  69. package/dist/controller/resourceInventoryLinux.js +12 -13
  70. package/dist/controller/runtime.js +529 -479
  71. package/dist/controller/runtimeEventInbox.js +55 -25
  72. package/dist/controller/runtimeEventProcessor.js +22 -31
  73. package/dist/controller/{runtimeHookTurnFence.js → runtimeHookRunFence.js} +91 -115
  74. package/dist/controller/runtimeLaunchCoordinator.js +80 -426
  75. package/dist/controller/runtimeObservationHook.js +14 -18
  76. package/dist/controller/sessionNotify.js +16 -24
  77. package/dist/controller/sessionOwnerReconciliation.js +168 -50
  78. package/dist/controller/structuredProviderObservation.js +138 -99
  79. package/dist/coordination/workMailbox.js +3 -3
  80. package/dist/coordination/workMailboxQueue.js +36 -33
  81. package/dist/core/boundedRpc.js +8 -1
  82. package/dist/core/controllerClient.js +20 -1
  83. package/dist/core/controllerServer.js +4 -4
  84. package/dist/doctor/doctor.js +13 -2
  85. package/dist/domain/agentResultTransport.js +9 -9
  86. package/dist/execution/codexThreadNaming.js +2 -8
  87. package/dist/execution/executionHealth.js +51 -63
  88. package/dist/execution/reviewMainRun.js +137 -0
  89. package/dist/execution/workItemExecution.js +28 -29
  90. package/dist/execution/workItemExecutionProjection.js +99 -107
  91. package/dist/execution/workItemMainRun.js +141 -0
  92. package/dist/executor/agentAdapter.js +227 -20
  93. package/dist/executor/agentConfigurationCatalog.js +126 -4
  94. package/dist/executor/agentConfigurationProbe.js +162 -4
  95. package/dist/executor/agentExecutor.js +79 -78
  96. package/dist/executor/effectiveLaunch.js +105 -18
  97. package/dist/executor/executorRegistry.js +29 -44
  98. package/dist/executor/fileRoleLaunchPlanner.js +229 -154
  99. package/dist/executor/workspacePreflightClassification.js +16 -16
  100. package/dist/grant/capabilityGrant.js +6 -3
  101. package/dist/input/inputRequest.js +12 -10
  102. package/dist/integration/gitIntegrationService.js +4 -11
  103. package/dist/integration/integrationQueueService.js +4 -4
  104. package/dist/interaction/operatorPresentation.js +1 -1
  105. package/dist/kernel/builtinCapabilities.js +247 -12
  106. package/dist/kernel/capabilityRegistry.js +64 -18
  107. package/dist/kernel/instanceHost.js +12 -1
  108. package/dist/kernel/kernelPorts.js +2 -2
  109. package/dist/lifecycle/canonicalLifecycleEvent.js +44 -49
  110. package/dist/lifecycle/exactRunTerminalization.js +449 -0
  111. package/dist/message/message.js +62 -6
  112. package/dist/message/messageContinuation.js +204 -0
  113. package/dist/observability/executionAudit.js +70 -72
  114. package/dist/observability/faultClassification.js +2 -2
  115. package/dist/observability/orchestrationMetrics.js +8 -8
  116. package/dist/operator/operatorSessionHistory.js +1 -7
  117. package/dist/output/agentConfigurationPresentation.js +8 -3
  118. package/dist/output/agentRunConfigurationPresentation.js +128 -0
  119. package/dist/output/rolePresentation.js +54 -3
  120. package/dist/plugins/pluginChild.js +104 -0
  121. package/dist/plugins/pluginIntent.js +26 -0
  122. package/dist/plugins/pluginInterpreter.js +43 -0
  123. package/dist/plugins/pluginPackage.js +101 -0
  124. package/dist/plugins/pluginProcess.js +112 -0
  125. package/dist/plugins/pluginService.js +380 -0
  126. package/dist/profile/agentProfile.js +1 -1
  127. package/dist/repository/gitWorkspace.js +26 -4
  128. package/dist/repository/project.js +19 -4
  129. package/dist/repository/taskBaseFreshness.js +13 -13
  130. package/dist/repository/taskWorkspaceCoordinator.js +20 -27
  131. package/dist/repository/taskWorkspacePreparer.js +344 -83
  132. package/dist/resources/autoResourceGc.js +3 -3
  133. package/dist/resources/liveReferences.js +3 -3
  134. package/dist/resources/projectResource.js +123 -0
  135. package/dist/resources/projectResourceService.js +421 -0
  136. package/dist/resources/resourceDiscovery.js +6 -6
  137. package/dist/resources/resourceGc.js +1 -1
  138. package/dist/resources/resourceRegistrar.js +1 -1
  139. package/dist/resources/resourceTypes.js +1 -1
  140. package/dist/review/deltaRecheck.js +3 -3
  141. package/dist/review/reviewAcceptance.js +16 -16
  142. package/dist/review/reviewDecision.js +7 -7
  143. package/dist/review/reviewRound.js +21 -20
  144. package/dist/review/reviewerAvailability.js +2 -2
  145. package/dist/role/role.js +51 -7
  146. package/dist/role/taskRoleUpdate.js +30 -0
  147. package/dist/runtime/acpProtocol.js +425 -0
  148. package/dist/runtime/acpSession.js +731 -0
  149. package/dist/runtime/acpSessionConfiguration.js +260 -0
  150. package/dist/runtime/agentDriver.js +30 -11
  151. package/dist/runtime/agentEndpoint.js +278 -0
  152. package/dist/runtime/agentEndpointIdentity.js +86 -0
  153. package/dist/runtime/agentEndpointOwnership.js +239 -0
  154. package/dist/runtime/agentError.js +2 -10
  155. package/dist/runtime/agentHost.js +565 -314
  156. package/dist/runtime/agentRunConfiguration.js +258 -0
  157. package/dist/runtime/builtinAgentDrivers.js +134 -18
  158. package/dist/runtime/builtinAgentErrorMappers.js +55 -3
  159. package/dist/runtime/builtinTranscriptUsage.js +1 -1
  160. package/dist/runtime/claude-process-owner +0 -0
  161. package/dist/runtime/codexAppServerRuntime.js +38 -30
  162. package/dist/runtime/codexInteractiveHost.js +41 -6
  163. package/dist/runtime/continuationManager.js +2 -6
  164. package/dist/runtime/executionEnvironment.js +30 -0
  165. package/dist/runtime/firstProgressAdvisory.js +11 -11
  166. package/dist/runtime/index.js +4 -3
  167. package/dist/runtime/jsonLineChannel.js +109 -0
  168. package/dist/runtime/launchBroker.js +91 -16
  169. package/dist/runtime/launchDiagnostics.js +2 -2
  170. package/dist/runtime/lifecycleReservation.js +10 -18
  171. package/dist/runtime/managedCaller.js +61 -17
  172. package/dist/runtime/nativeSessionControl.js +102 -0
  173. package/dist/runtime/ports.js +6 -21
  174. package/dist/runtime/processExitObservation.js +8 -7
  175. package/dist/runtime/promptEnvelope.js +17 -6
  176. package/dist/runtime/providerContinuation.js +3 -9
  177. package/dist/runtime/providerContinuationReconciliationService.js +4 -13
  178. package/dist/runtime/providerControl.js +2 -7
  179. package/dist/runtime/providerRuntimeIdentity.js +110 -222
  180. package/dist/runtime/providerRuntimeReconciler.js +5 -9
  181. package/dist/runtime/runtimeBinding.js +0 -1
  182. package/dist/runtime/runtimeContinuationProjection.js +4 -7
  183. package/dist/runtime/runtimeDeadlines.js +9 -0
  184. package/dist/runtime/runtimeHealthPolicy.js +1 -1
  185. package/dist/runtime/runtimeObservation.js +29 -65
  186. package/dist/runtime/runtimeProjection.js +43 -51
  187. package/dist/runtime/runtimeSessionCandidate.js +1 -3
  188. package/dist/runtime/sessionLaunchRequest.js +3 -7
  189. package/dist/runtime/sessionOwnerIdentity.js +7 -54
  190. package/dist/runtime/sessionOwnerRegistry.js +22 -17
  191. package/dist/runtime/sessionReconciliation.js +4 -8
  192. package/dist/runtime/sessionTerminationGuard.js +70 -259
  193. package/dist/runtime/sessionTokenMetrics.js +5 -16
  194. package/dist/runtime/structuredProviderHost.js +237 -117
  195. package/dist/runtime/taskRuntimeIsolation.js +39 -122
  196. package/dist/runtime/tmuxAdapters.js +39 -86
  197. package/dist/scheduler/activeRoleRunDelivery.js +354 -0
  198. package/dist/scheduler/leaderWakeupProcessor.js +75 -266
  199. package/dist/scheduler/operatorInputNotificationProcessor.js +1 -1
  200. package/dist/scheduler/ports.js +80 -9
  201. package/dist/scheduler/{roleTurnLiveness.js → roleRunLiveness.js} +26 -30
  202. package/dist/scheduler/{roleTurnStall.js → roleRunStall.js} +128 -139
  203. package/dist/scheduler/taskExecutionProjection.js +120 -124
  204. package/dist/scheduler/taskObservabilityProjection.js +29 -29
  205. package/dist/scheduler/taskWake.js +11 -4
  206. package/dist/scheduler/wakeReason.js +9 -1
  207. package/dist/setup/setupCommand.js +1 -0
  208. package/dist/storage/migrations/agentRunContract.js +159 -0
  209. package/dist/storage/migrations/removeRuntimeGeneration.js +207 -0
  210. package/dist/storage/sqliteSchema.js +431 -5
  211. package/dist/storage/sqliteStore.js +375 -220
  212. package/dist/storage/storageVersions.js +1 -1
  213. package/dist/storage/storeRpc.js +10 -5
  214. package/dist/storage/taskStore.js +13 -11
  215. package/dist/storage/upgrade/upgradeOrchestrator.js +5 -7
  216. package/dist/surface/surfaceContributions.js +102 -0
  217. package/dist/task/completionReadiness.js +32 -6
  218. package/dist/task/deliveryGuard.js +16 -16
  219. package/dist/task/draftPlan.js +72 -12
  220. package/dist/task/nextAction.js +144 -128
  221. package/dist/task/remoteDelivery.js +6 -6
  222. package/dist/task/task.js +184 -18
  223. package/dist/task/taskActivation.js +301 -0
  224. package/dist/task/taskActivationService.js +392 -0
  225. package/dist/task/taskRecordReference.js +5 -4
  226. package/dist/task/taskRecordRetirement.js +1 -1
  227. package/dist/telemetry/sqliteTelemetryStore.js +55 -68
  228. package/dist/telemetry/telemetryConfig.js +14 -14
  229. package/dist/telemetry/telemetryWiring.js +2 -2
  230. package/dist/web/assets/assetManifest.js +2 -0
  231. package/dist/web/assets/client/app.js +120 -20
  232. package/dist/web/assets/client/components.js +87 -54
  233. package/dist/web/assets/client/i18n.js +83 -41
  234. package/dist/web/assets/client/markdown.js +1 -1
  235. package/dist/web/assets/client/taskSurface.js +353 -0
  236. package/dist/web/assets/client/view.js +49 -44
  237. package/dist/web/assets/shell.js +1 -1
  238. package/dist/web/assets/styles/cards.js +22 -4
  239. package/dist/web/controllerWeb.js +60 -0
  240. package/dist/web/webMutation.js +28 -0
  241. package/dist/web/webServer.js +118 -8
  242. package/dist/web/webSnapshot.js +81 -74
  243. package/dist/web/webTaskSurface.js +64 -0
  244. package/dist/workItem/dependencyGate.js +1 -1
  245. package/dist/workItem/workItem.js +80 -48
  246. package/dist/workspace/workItemChangeSetManager.js +16 -9
  247. package/docs/agent-result-consumption.md +94 -0
  248. package/docs/agent-runtime-drivers.md +91 -0
  249. package/docs/architecture/README.md +38 -0
  250. package/docs/architecture/capabilities-and-resources.md +79 -0
  251. package/docs/managed-turn-and-session-runtime.md +222 -0
  252. package/docs/observability/README.md +81 -0
  253. package/docs/plugin-sdk.md +290 -0
  254. package/docs/provider-runtime.md +163 -0
  255. package/docs/release-workflow.md +303 -0
  256. package/docs/roles-and-configuration.md +113 -0
  257. package/docs/sqlite-control-plane-design.md +76 -0
  258. package/docs/task-dag-semantics.md +57 -0
  259. package/docs/task-delivery.md +103 -0
  260. package/docs/task-local-identity.md +6 -6
  261. package/docs/testing/verification-levels.md +86 -0
  262. package/i18n/README.zh-CN.md +98 -739
  263. package/package.json +2 -2
  264. package/skills/yui-leader/SKILL.md +130 -103
  265. package/skills/yui-leader/references/integration.md +39 -0
  266. package/skills/yui-leader/references/replicated-execution.md +42 -0
  267. package/skills/yui-leader/references/task-plugins.md +33 -0
  268. package/skills/yui-operator/SKILL.md +30 -59
  269. package/skills/yui-reviewer/SKILL.md +35 -36
  270. package/skills/yui-runtime/SKILL.md +88 -24
  271. package/skills/yui-runtime/references/publication.md +22 -0
  272. package/skills/yui-runtime/references/recovery.md +64 -0
  273. package/skills/yui-worker/SKILL.md +37 -39
  274. package/dist/cli/roleOptionCatalog.js +0 -68
  275. package/dist/context/sourceTurnContext.js +0 -30
  276. package/dist/execution/reviewMainTurn.js +0 -161
  277. package/dist/execution/workItemMainTurn.js +0 -164
  278. package/dist/lifecycle/exactTurnTerminalization.js +0 -407
  279. package/dist/runtime/preallocatedNativeSession.js +0 -13
  280. package/dist/runtime/runtimeStopReceipt.js +0 -42
  281. package/dist/scheduler/activeRoleTurnDelivery.js +0 -315
@@ -5,7 +5,8 @@ description: Review the exact frozen WorkItem Candidate or unified Task-final sc
5
5
 
6
6
  # Yui Reviewer
7
7
 
8
- Follow `yui-runtime` first and load the exact current Turn Context Pack. The
8
+ Follow [yui-runtime](../yui-runtime/SKILL.md) first and load the exact current
9
+ AgentRun Context Pack. The
9
10
  ReviewRound, Candidate, workspace, and Snapshot digest returned there are the
10
11
  only review scope; fail closed on any mismatch.
11
12
 
@@ -18,50 +19,48 @@ reinterpret its scope:
18
19
  anchor.
19
20
 
20
21
  A Role is an executor, not a workspace owner: each ReviewRound owns an exact
21
- workspace record. Consecutive Task-final Rounds for the same Reviewer reuse one
22
- clean physical workspace and native Session while Yui updates the checkout and
23
- records the new Round snapshot. Treat the new Turn Context Pack and frozen head
22
+ workspace record. Consecutive Task-final Rounds may reuse a clean physical
23
+ workspace and native Session while Yui records each Round's exact snapshot.
24
+ Treat the new AgentRun Context Pack and frozen head
24
25
  as the authority even when the conversation continues; never reuse an earlier
25
26
  verdict. Review edits are confined to that workspace, never modify the
26
27
  WorkItem Develop workspace, and never become a ChangeSet source.
27
28
 
28
- For a dispatched Review, the Turn Context Pack identifies the ReviewRound,
29
+ For a dispatched Review, the AgentRun Context Pack identifies the ReviewRound,
29
30
  frozen Project commits, and assigned workspace. Inspect those exact commits.
30
31
  The current mutable Task-main checkout is context only and must never replace,
31
32
  widen, or silently update the assigned Review scope.
32
33
 
33
- The Turn also identifies the execution shape. A direct Review Turn is the main
34
- Reviewer and produces the authoritative Review result. In replicated Review,
35
- a Producer Lane independently inspects the same frozen Assignment in its own
36
- Lane workspace and returns one complete original result. A Producer result is
37
- non-authoritative: do not create a Candidate, ChangeSet, integration, or
38
- completion decision.
39
-
40
- Only the main Reviewer synthesis Turn may interpret all stable successful
41
- Producer results and complete the ReviewRound. Read every exact source Turn's
42
- original result, inspect every supplied result,
43
- resolve disagreement through judgment against the frozen sources, and return
44
- one complete authoritative report. Do not select a winning Lane, mutate
45
- Producer results, rerun successful Producers, or omit a successful result from
46
- the synthesis.
34
+ The AgentRun identifies the execution shape. A direct main Reviewer returns
35
+ the authoritative Review report. For a Producer Lane or main synthesis
36
+ assignment, read [replicated execution](../yui-leader/references/replicated-execution.md)
37
+ before acting. Producer evidence is not an authoritative Review result or an
38
+ acceptance decision. Resolve links relative to this Skill's directory.
39
+
40
+ Clarification for the same ReviewRound may arrive through a Message continuation
41
+ in its exact Context Pack. Preserve the frozen candidate and original results;
42
+ the new execution does not authorize reviewing a newer Task head. Messages for
43
+ an obsolete candidate remain visible but cannot restart the old Review. During
44
+ execution a scoped question may be sent with `task message send <task> "<question>"
45
+ --to leader --review-round <round-id>` (include `--work-item` for WorkItem Review).
47
46
 
48
47
  ## Separate infrastructure failure from review judgment
49
48
 
50
- Verify the exact Turn identity, Context Pack, frozen head, and ReviewRound-owned
49
+ Verify the exact AgentRun identity, Context Pack, frozen head, and ReviewRound-owned
51
50
  workspace before inspecting candidate sources. If context loading or workspace
52
51
  binding fails before review begins:
53
52
 
54
53
  - do not inspect the candidate, run candidate checks, invent findings, accept
55
54
  risk, or claim the frozen result was reviewed;
56
- - return the exact infrastructure diagnosis through the assigned Review Turn;
55
+ - return the exact infrastructure diagnosis through the assigned Review AgentRun;
57
56
  - do not recommend a Repair WorkItem—the Leader must recover the same frozen
58
57
  review boundary with Yui's projected same-Round `task review retry` or exact
59
- `task turn retry`;
58
+ `task run retry`;
60
59
  - if any candidate inspection or Reviewer output did occur, report it
61
60
  explicitly so the Leader can judge what remains useful. Core records only
62
61
  the execution boundary and never classifies the meaning of this prose.
63
62
 
64
- The Review scope remains the current Turn's frozen candidate even if the Leader
63
+ The Review scope remains the current AgentRun's frozen candidate even if the Leader
65
64
  handles new user input or advances Task main while this Review is running. Do
66
65
  not switch to the newer head, cancel the current inspection, or claim the
67
66
  result covers anything beyond the frozen candidate.
@@ -72,11 +71,8 @@ material defect, or needs a full Review, and explain why. These are recommended
72
71
  conclusions for the Leader, not machine-readable dispositions. Never create or
73
72
  request a follow-up Round yourself.
74
73
 
75
- Keep the context layers distinct. Yui Core owns ReviewRound identity,
76
- lifecycle, access, workspace, and exact Turn-result correlation; this generic Skill owns
77
- portable review behavior; Agent-native Project Skills and Project Policy and
78
- Knowledge own project-specific checks and review expectations; and the Task
79
- Contract owns the current outcome, scope, acceptance, and required evidence.
74
+ Use Project Skills, Policy and Knowledge for project-specific checks. The
75
+ Task Contract and frozen scope determine acceptance and required evidence.
80
76
 
81
77
  Review design complexity against the current Task Contract and reachable
82
78
  operating paths. Report abstractions, state, indirection, fallback, or module
@@ -86,17 +82,19 @@ future-proofing merely because they are possible. A focused redesign is
86
82
  appropriate when repeated patches expose a wrong responsibility or duplicated
87
83
  authority.
88
84
 
89
- Follow `yui-runtime`'s distinction between normal Agent execution and
90
- real-resource validation. This Reviewer Turn is normal execution; additional
91
- live-provider, paid, shared, or production validation is not implied.
85
+ Tie each finding to a reachable scenario, violated contract and direct
86
+ evidence. Separate confirmed defects, verification gaps and optional
87
+ improvements. A clean review is valid; do not invent findings to justify the
88
+ Round or change delivery sources to demonstrate a preferred design.
92
89
 
93
90
  Complete the assigned frozen-scope review before ending the Provider Turn. Accumulate all
94
91
  reachable findings, verification gaps, checks actually run, and bounded next
95
- actions, then return them together in one Review Turn result; do not stop as
92
+ actions, then return them together in one Review AgentRun result; do not stop as
96
93
  soon as the first finding is discovered. A review result is evidence for Leader
97
94
  judgment; it does not accept the WorkItem or complete the Task. Preserve the
98
- ReviewRound record and explicitly clean its workspace after the round is
99
- terminal.
95
+ ReviewRound record and workspace, and report any diagnostic changes. After
96
+ the Round is terminal, an authorized Leader or Operator owns cleanup through
97
+ Yui; do not attempt to terminate or delete your own managed runtime/workspace.
100
98
 
101
99
  A helpful default result layout is Conclusion, Material findings, Verification,
102
100
  Uncertainty, and Recommended next action. Markdown or JSON are both acceptable.
@@ -113,8 +111,9 @@ specific gap; do not rerun an unchanged complete suite for ceremony.
113
111
 
114
112
  Return each reachable finding to the Leader with direct evidence and a bounded
115
113
  route to the original execution unit: Leader-owned work returns to the Leader,
116
- native work to the same child, and managed work to the same Role and native
117
- Session. Keep the existing WorkItem when its scope remains open. For a small
114
+ native work to its parent for disposition, and managed work to the owning Role.
115
+ Session reuse is optional; preserve the assignment rather than requiring an
116
+ old conversation to survive. Keep the WorkItem when its scope remains open. For a small
118
117
  Task-main fix, return it to the Leader without recommending another WorkItem;
119
118
  recommend a Repair WorkItem only when the repair is itself a substantial,
120
119
  independently owned requirement. Never capture or integrate the ReviewRound's
@@ -1,25 +1,43 @@
1
1
  ---
2
2
  name: yui-runtime
3
- description: Load and use the authorized context for every Yui-managed Leader, Worker, Reviewer, Operator, or custom Role Turn, and complete that Turn through its bounded control-plane protocol.
3
+ description: Use authorized context, durable results, and recovery boundaries in a Yui-managed Session, including global conversation, direct Leader work, and dispatched AgentRuns.
4
4
  ---
5
5
 
6
6
  # Yui Runtime
7
7
 
8
- Treat the Session Manifest and Turn Bootstrap Envelope as pointers, never as the
8
+ Use this Skill for the shared Yui execution contract. The Role Skill owns
9
+ coordination or delivery judgment; Project Skills, Policy and Knowledge own
10
+ project-specific methods. These instructions grant no additional authority.
11
+ Resolve links relative to this Skill's directory, not the execution workspace.
12
+
13
+ Treat the Session Manifest and AgentRun Bootstrap Envelope as pointers, never as the
9
14
  Task brief. Do not infer Task facts from the launch command, process list,
10
- workspace layout, native transcript, or an earlier Turn.
15
+ workspace layout, native transcript, or an earlier AgentRun.
16
+
17
+ ## Enter through the current context
18
+
19
+ There are two normal Task entry points. A user may continue directly with the
20
+ current, unrevoked Leader Session: read current context using the Session CLI
21
+ with `task context <task-id> --json`. Do not request a self-wake, reopen a Task,
22
+ or reuse an old completed AgentRun snapshot merely to obtain authority. Pending
23
+ delivery, unknown execution evidence and missing reports do not themselves
24
+ revoke Session authority. Task lifecycle, scope, Assignment, workspace and
25
+ resource boundaries still apply; a planning Session does not gain delivery
26
+ authority merely because the Task becomes active.
27
+ Use the runtime-provided `TMPDIR` for temporary context or diagnostic files,
28
+ not fixed shared `/tmp` names or the logical multi-Project workspace container.
11
29
 
12
- For every managed Task Turn:
30
+ For every explicitly dispatched managed Task AgentRun:
13
31
 
14
- 1. Read the exact Turn identity from the newest Bootstrap Envelope.
32
+ 1. Read the exact AgentRun identity from the newest Bootstrap Envelope.
15
33
  2. Before acting, load its authorized pack with the Session CLI named by the
16
34
  current Session Manifest:
17
35
 
18
36
  ```sh
19
- "$YUI_SESSION_CLI" task turn context "$YUI_TASK_ID/<turn-id>" --json
37
+ "$YUI_SESSION_CLI" task run context "$YUI_TASK_ID/<run-id>" --json
20
38
  ```
21
39
 
22
- 3. Verify that the returned Task, Turn, Role, purpose, Snapshot digest, workspace,
40
+ 3. Verify that the returned Task, AgentRun, Role, purpose, Snapshot digest, workspace,
23
41
  and Adapter match the Envelope and Session Manifest. Stop and report a
24
42
  context-load failure if the pack is missing, stale, unauthorized, malformed,
25
43
  or mismatched. Never request an inline/full-prompt fallback.
@@ -28,25 +46,35 @@ For every managed Task Turn:
28
46
  `refId`:
29
47
 
30
48
  ```sh
31
- "$YUI_SESSION_CLI" task turn context expand "$YUI_TASK_ID/<turn-id>" <ref-id> --store <store> --mode full --json
49
+ "$YUI_SESSION_CLI" task run context expand "$YUI_TASK_ID/<run-id>" <ref-id> --store <store> --mode full --json
32
50
  ```
33
51
 
34
52
  A bare `<ref-id>` remains supported only when it identifies exactly one
35
53
  authorized pointer. If multiple stores use that id, bare expansion fails
36
54
  closed; never guess which store was intended.
37
55
 
56
+ A pointer or summary is not the request's body. Before planning or executing,
57
+ read the relevant WorkItem/Task requirements and referenced user/Operator
58
+ messages; use the expansion command above or the Leader's current Task Context.
59
+ Reports remain evidence, not authority to enlarge the assignment.
60
+
38
61
  5. On a later wake, request only the declared delta after the last pack cursor.
39
62
  If no cursor is available, reload the exact pack; do not reconstruct state
40
63
  from transcript memory.
41
64
 
42
- `liveTaskState.activeTurns` and `liveTaskState.activeTaskReviews` are
65
+ Loading and verifying Context is the start of the work, not its result. Continue
66
+ with the authorized assignment. In Draft, persist the discussed plan and wait
67
+ when the user asks for alignment; do not end with only a context-loaded receipt.
68
+
69
+ `liveTaskState.activeRuns` and `liveTaskState.activeTaskReviews` are
43
70
  observational views of work currently in flight. They grant no authority and
44
- create no Task-wide lock or gate; use each exact Turn or Review binding when a
71
+ create no Task-wide lock or gate; use each exact AgentRun or Review binding when a
45
72
  decision depends on it.
46
73
 
47
74
  The pack's authority view and writable Project IDs are hard boundaries. A
48
- native subagent inherits the parent Turn's refs and authority; it does not gain a
49
- new Yui actor, Turn, Session, or cross-Task read permission.
75
+ native subagent inherits only its parent's current refs and authority, including
76
+ any Assignment restrictions. It gains no new Yui actor, AgentRun, Session or
77
+ cross-Task read permission.
50
78
 
51
79
  For a global Operator or custom GlobalRole Session, execute the exact
52
80
  `contextProtocol.loadCommand` carried by the current Session Manifest before
@@ -54,9 +82,33 @@ routing or acting. That command is self-contained because a Global Codex Thread
54
82
  may move between Yui's remote TUI and Desktop; never reconstruct it from
55
83
  `YUI_SESSION_*` process variables.
56
84
 
85
+ If that read fails because the Controller is unavailable, use only authorized
86
+ offline diagnostics and [Controller recovery](references/recovery.md) to restore
87
+ access, then reload context. Failure does not grant Task execution authority,
88
+ but a successful preliminary RPC is not a prerequisite for that recovery.
89
+
57
90
  Global context grants no Task implementation workspace. Read a Task only after
58
91
  the Operator has routed to its public/task-authorized context command; never
59
- invent a Task Turn identity for a GlobalRole.
92
+ invent a Task AgentRun identity for a GlobalRole.
93
+
94
+ ## Preserve intent and authority
95
+
96
+ An analysis, diagnosis, or review request is read-only unless the user also
97
+ requests changes. A request to fix or implement authorizes the bounded work,
98
+ not unrelated configuration, new external effects, or broader cleanup.
99
+ Choose routine legal implementation and recovery actions without asking the
100
+ user to operate Yui mechanically.
101
+
102
+ Tasks, WorkItems, Messages, Decisions, results and managed workspaces hold
103
+ durable intent and progress. Sessions, AgentRuns and runtime observations
104
+ describe execution; their failure is not failed acceptance or permission to
105
+ discard the assignment. Save context that a successor needs in durable records,
106
+ not only in the native conversation.
107
+
108
+ The Leader normally owns Task coordination and acceptance. An authorized
109
+ Operator may perform the same legal Task-management actions; responsibility
110
+ is not an extra permission gate. Worker and Reviewer results remain evidence
111
+ until an authorized acceptance decision.
60
112
 
61
113
  ## Separate execution from real-resource validation
62
114
 
@@ -75,15 +127,27 @@ When such validation was not requested, use deterministic or isolated evidence,
75
127
  state the material gap, and optionally recommend a separate follow-up. Do not
76
128
  create an InputRequest merely to solicit permission for it.
77
129
 
78
- Provider acceptance, Context load, Turn completion, and Task completion are
79
- separate facts. For a managed Task Turn, end the Provider Turn with one truthful
130
+ ## Return evidence and recover within scope
131
+
132
+ Provider acceptance, Context load, AgentRun completion, and Task completion are
133
+ separate facts. For an explicitly dispatched managed Task AgentRun, end with one truthful
80
134
  final report. Yui automatically correlates that native terminal with the exact
81
- current Turn and persists the report; no completion command is required. The
82
- Leader alone decides whether the WorkItem or Task is complete.
83
-
84
- After a failed Provider Turn, read the referenced `runtime.agent-error` fact.
85
- The failed Turn is immutable; a recovery is always a new Turn. Continue on the
86
- same native Session when it remains recoverable, and load only the current Turn
87
- delta instead of replaying its original Assignment. A new Host process does not
88
- imply a new Session, and a new Session must never be substituted silently for
89
- the persisted native Session id.
135
+ current AgentRun and persists the report; no completion command is required. The
136
+ report itself does not accept the WorkItem or complete the Task.
137
+
138
+ Ordinary native conversation is not an implicit managed assignment and does
139
+ not require a separate execution report. Result Messages reference the
140
+ execution's original report; read them with `task message show <task/message>`
141
+ instead of asking the producer to copy or resend the report.
142
+
143
+ Session reuse is a preference, not a prerequisite for progress. Before retry,
144
+ replacement, or intervention in uncertain execution, read
145
+ [runtime recovery](references/recovery.md). Preserve pending intent, exact
146
+ runtime identity and workspace progress; never edit Run status or substitute
147
+ a native Session behind Yui's back. A timeout is not proof of quiescence and
148
+ does not authorize replay of unknown input.
149
+
150
+ After an authorized external PR/MR operation, use the shared
151
+ [publication recording contract](references/publication.md). Recording delivery
152
+ facts does not authorize the external operation, imply acceptance, or grant
153
+ permission to archive.
@@ -0,0 +1,22 @@
1
+ # Record external delivery
2
+
3
+ Use this after creating, updating, closing, reopening or merging a PR/MR
4
+ within existing user authorization. This procedure does not grant permission
5
+ to push, publish, merge, query an external provider or archive.
6
+
7
+ Immediately record the confirmed operation with `yui task publication upsert`.
8
+ Supply only facts already known from the operation; do not defer recording to
9
+ another Role or depend on provider-specific discovery.
10
+
11
+ Track PR/MR identity, state, commits, URL, merge time and evidence, not CI or
12
+ deployment status. After merge, use `yui task publication verify` only when
13
+ current authorization covers that external provider read. Otherwise retain
14
+ reported evidence and state the verification gap.
15
+
16
+ Use `yui task remote-delivery <task>` to explain external delivery. Publication
17
+ is not Candidate acceptance, Review, Integration or Task completion.
18
+
19
+ Completion does not authorize archive. The Operator obtains authorization for
20
+ the exact Task, checks archive eligibility, then uses `--integrated` for verified
21
+ merged delivery or `--abandon` for deliberate non-delivery. General archive
22
+ approval never implies `--force` authority. Preserve the Task record.
@@ -0,0 +1,64 @@
1
+ # Runtime recovery
2
+
3
+ Read this when a native Turn fails, delivery acceptance is unknown, the
4
+ Controller is unavailable, or an authorized supervisor chooses Session
5
+ replacement. Workers and Reviewers report exact evidence; they do not acquire
6
+ supervisor authority by reading this procedure.
7
+
8
+ ## Inspect the failed execution
9
+
10
+ Read the referenced `runtime.agent-error`, exact AgentRun, Role Session and
11
+ affected WorkItem, ReviewRound or Integration. Use `task next-action` and
12
+ `execution audit` as decision support, not as an automatic plan.
13
+ Active or quiet observations are not a Task-wide lock or proof of failure.
14
+
15
+ A failed AgentRun is immutable; retry creates a new attempt. Reuse a recoverable
16
+ Session when useful and load the new attempt's current context, not an old
17
+ Assignment from memory. A new Host process need not mean a new native Session.
18
+ Preserve frozen Review candidates and selected synthesis sources on retry.
19
+ An infrastructure failure is not a defect in the business result.
20
+
21
+ ## Replace a Session deliberately
22
+
23
+ An authorized Leader or Operator may request:
24
+
25
+ ```sh
26
+ yui task role session new <task> <role> --reason "<reason>"
27
+ ```
28
+
29
+ The old Run may still be active, the Session may already be released, or fresh
30
+ context may simply be preferable. Save necessary requirements, decisions,
31
+ progress and results first. Yui persists replacement intent, stops the exact
32
+ execution and retires its engineering attempts while retaining Task history and
33
+ workspaces. Do not manipulate Run status, delete context or change models to
34
+ make replacement legal.
35
+
36
+ When replacing yourself, end the native turn. The successor reads durable Task
37
+ context and fixed notification references, then chooses which still-valid
38
+ assignment to continue. Released Leaders retain scoped diagnostic reads but
39
+ cannot regain write authority.
40
+
41
+ ## Handle uncertainty and failed cleanup
42
+
43
+ Never replay a notification whose acceptance is unknown. After evidence
44
+ establishes shared-native quiescence, an authorized supervisor can use:
45
+
46
+ ```sh
47
+ yui task wake resolve <task> <wake> --reason "<quiescence evidence>"
48
+ ```
49
+
50
+ This releases only the claim, preserves the original unknown record, and lets
51
+ independent later inputs proceed. It neither asserts acceptance nor implements
52
+ the Message. Uncertain native activity still blocks conflicting execution;
53
+ unrelated authorized local work can continue.
54
+
55
+ If the Controller is unresponsive, an authorized Operator can use
56
+ `controller status` and explicit `controller restart` without a successful
57
+ preliminary RPC. Preserve the resource and restart authorization boundary.
58
+ If exact native stop or inspection fails, read the persisted diagnostic and
59
+ resolve that resource boundary; do not kill arbitrary processes, clear unknown
60
+ execution records, or modify managed refs, tmux Sessions or state files.
61
+
62
+ After repeated failure of the same bounded recovery, report the observed
63
+ cause, impact and smallest remaining options. Do not broaden cleanup or add
64
+ a private retry loop. A failed recovery does not erase the pending requirement.
@@ -1,37 +1,41 @@
1
1
  ---
2
2
  name: yui-worker
3
- description: Complete one bounded WorkItem as a native subagent or Task Role Turn, then return honest evidence through the assigned protocol.
3
+ description: Complete a bounded Yui WorkItem AgentRun or native child assignment and return evidence without taking over Task coordination.
4
4
  ---
5
5
 
6
6
  # Yui Worker
7
7
 
8
- Follow `yui-runtime` first. For a managed Turn, load its exact Context Pack and
8
+ Follow [yui-runtime](../yui-runtime/SKILL.md) first. For a managed AgentRun,
9
+ load its exact Context Pack and
9
10
  use only the returned WorkItem, refs, workspace, writable Project IDs, and
10
11
  completion actions. The launch Envelope is a pointer, not an execution brief.
11
12
 
12
- Complete only the assigned substantial, independently owned WorkItem. The Leader owns Task direction,
13
- decomposition, acceptance, integration, scope expansion, and conflict
13
+ Complete the assigned WorkItem, or the bounded parent brief for a native child
14
+ without its own WorkItem. Do not create records merely to fit this Skill.
15
+ The Leader owns Task direction, decomposition, acceptance, integration, scope expansion, and conflict
14
16
  decisions. A Worker must not create or rebind Yui worktrees, Sessions, Roles,
15
- Turns, WorkItems, ReviewRounds, or integration state.
17
+ AgentRuns, WorkItems, ReviewRounds, or integration state.
16
18
 
17
- Keep the layers distinct:
18
-
19
- - Yui Core supplies durable identity, lifecycle, authority, workspace, and
20
- exact handoff safety.
21
- - This Skill supplies portable Worker behavior.
22
- - Agent-native Project Skills plus Project Policy and Knowledge supply build,
23
- test, migration, release, and review rules.
24
- - The exact WorkItem and Context Snapshot supply this Turn's objective, scope,
25
- acceptance, dependencies, and evidence contract.
26
-
27
- Do not promote a Project convention into generic Worker policy or infer Task
28
- facts by scanning the workspace. Expand only Context refs authorized by the
29
- pack.
19
+ Use Project Skills, Policy and Knowledge for implementation and checks, and
20
+ the exact WorkItem for acceptance. Do not turn a Project convention into
21
+ generic Worker policy or infer Task requirements from workspace contents.
22
+ Resolve Skill links relative to this Skill's directory.
30
23
 
31
24
  ## Execute within the exact boundary
32
25
 
33
- - Preserve the Task, WorkItem, Role, Turn, native Session, and workspace
34
- identities supplied by Yui. A new Turn is another attempt or continuation of
26
+ Leader clarification and continuation arrive as Messages in the exact bounded
27
+ Context Pack. Read those authorized refs; do not request pack-external Leader
28
+ messages or require redispatch/status changes merely to answer a question.
29
+ Continuation preserves the original Assignment, effective permissions and
30
+ workspace, including unfinished files. If you need clarification, preserve
31
+ those files and report the question; a final question is not WorkItem completion
32
+ and does not require a Candidate. While executing, `task message send <task>
33
+ "<question>" --to leader --work-item <work-id>` saves scoped collaboration.
34
+ Do not interpret Message delivery or Context reading as implementation or
35
+ acceptance, and never treat a Message as an expanded grant.
36
+
37
+ - Preserve the Task, WorkItem, Role, AgentRun, native Session, and workspace
38
+ identities supplied by Yui. A new AgentRun is another attempt or continuation of
35
39
  the same delivery unit; do not request a fresh Role or Session merely because
36
40
  implementation entered another step or repair round.
37
41
  - Follow the configured Profile's responsibilities, constraints, access
@@ -49,12 +53,12 @@ pack.
49
53
  exact Project, reason, impact, and Leader decision needed. Continue only
50
54
  after a new exact dispatch authorizes it.
51
55
 
52
- Implement the smallest coherent design that satisfies the current WorkItem.
53
- Reuse established responsibilities and patterns when they fit. Use a bounded
54
- refactor when repeated patches expose the wrong boundary, but do not add
55
- frameworks, configuration, fallbacks, compatibility paths, or abstractions for
56
- hypothetical future variants. Keep coupled changes together and avoid turning
57
- small helpers into independently managed architecture.
56
+ Before changing behavior, trace the existing implementation and establish how
57
+ it violates the current WorkItem contract. Distinguish a product defect from
58
+ different test inputs, configuration or resources. Reuse the existing authority
59
+ and mechanism when they fit; make a bounded redesign when the responsibility
60
+ itself is wrong. Keep unrelated improvements and hypothetical variants out of
61
+ the assignment.
58
62
 
59
63
  For Project-backed delivery, commit the Develop workspace changes and leave it
60
64
  clean before handoff so Yui can freeze the exact Candidate head. ReviewRound
@@ -70,10 +74,6 @@ changed behavior; do not repeat an unchanged successful check. Follow Project
70
74
  Policy for required validation and state passed, failed, and intentionally
71
75
  skipped checks honestly.
72
76
 
73
- Follow `yui-runtime`'s distinction between normal Agent execution and
74
- real-resource validation. Ordinary Worker implementation is authorized by this
75
- Turn; additional live-provider, paid, shared, or production validation is not.
76
-
77
77
  ## Return a useful result
78
78
 
79
79
  A native child result is best-effort until Yui externalizes it: the result
@@ -81,28 +81,26 @@ returns through the parent Conversation, and if that Session is lost before
81
81
  the Leader consumes it, the child may need to rerun. Do not claim Yui
82
82
  durability for a native result you only emitted in the provider transcript.
83
83
  When the child brief requires a durable, independently recoverable result,
84
- the Leader must dispatch the work as a managed Yui WorkItem Turn instead. A
85
- direct WorkItem Turn already owns its durable Turn, receipt, and workspace;
84
+ the Leader must dispatch the work as a managed Yui WorkItem AgentRun instead. A
85
+ direct WorkItem AgentRun already owns its durable AgentRun, receipt, and workspace;
86
86
  replicated Lanes are needed only for multiple independent attempts. Native
87
- subagents never own a Yui Turn, receipt, or workspace.
88
-
89
- ## Task Role Turn
87
+ subagents never own a Yui AgentRun, receipt, or workspace.
90
88
 
91
89
  Summarize the outcome for the Leader's next judgment, not as a transcript or
92
90
  file-by-file log. Include the observable result, important mechanism and
93
91
  boundary, changed paths and commit state, checks, skipped validation, blockers,
94
92
  residual risk, and bounded next action. Use a checkpoint only for material
95
- semantic progress during a long Turn; it does not replace the final handoff.
93
+ semantic progress during a long AgentRun; it does not replace the final handoff.
96
94
 
97
95
  For a native subagent, return one consolidated child result through the native
98
96
  child-result mechanism. Do not run Yui lifecycle commands or invent a child
99
- Yui Session/Turn.
97
+ Yui Session/AgentRun.
100
98
 
101
99
  For a managed Task Role, end the Provider Turn with one complete, truthful
102
- result. Yui persists it automatically on the exact Turn. That result does not
100
+ result. Yui persists it automatically on the exact AgentRun. That result does not
103
101
  accept, capture, integrate, or complete the WorkItem; the Leader decides its
104
102
  disposition. If context or scope is stale or mismatched, report that blocker
105
- once and stop without wrappers, permission broadening, or another Turn target.
103
+ once and stop without wrappers, permission broadening, or another AgentRun target.
106
104
 
107
105
  Use clear prose. A helpful default is Outcome, Changes, Verification, Risks or
108
106
  blockers, and Recommended next action. This is a communication convention, not
@@ -1,68 +0,0 @@
1
- const BOTH_ADAPTERS = Object.freeze(["codex", "claude"]);
2
- const CODEX_ONLY = Object.freeze(["codex"]);
3
- const CLAUDE_ONLY = Object.freeze(["claude"]);
4
- export const ROLE_AGENT_OPTION_SPECS = Object.freeze([
5
- roleAgentOption("--model", "model", "model", false, BOTH_ADAPTERS),
6
- roleAgentOption("--effort", "effort", "effort", false, BOTH_ADAPTERS),
7
- roleAgentOption("--permission-strategy", "permission.strategy", "strategy", false, BOTH_ADAPTERS, { staticValues: ["default", "bypass", "configured"] }),
8
- roleAgentOption("--sandbox", "permission.sandbox", "mode", false, CODEX_ONLY),
9
- roleAgentOption("--approval", "permission.approval", "policy", false, CODEX_ONLY),
10
- roleAgentOption("--permission-mode", "permission.mode", "mode", false, CLAUDE_ONLY),
11
- roleAgentOption("--allowed-tool", "permission.allowedTools", "tool", true, CLAUDE_ONLY),
12
- roleAgentOption("--disallowed-tool", "permission.disallowedTools", "tool", true, CLAUDE_ONLY),
13
- roleAgentOption("--search", "search", "true", false, CODEX_ONLY, { staticValues: ["true"] }),
14
- roleAgentOption("--profile", "profile", "profile", false, CODEX_ONLY),
15
- roleAgentOption("--add-dir", "additionalDirectories", "path", true, BOTH_ADAPTERS, { fileValue: true }),
16
- roleAgentOption("--settings", "settingsFile", "file", false, CLAUDE_ONLY, { fileValue: true }),
17
- roleAgentOption("--setting-source", "settingsSources", "source", true, CLAUDE_ONLY),
18
- roleAgentOption("--raw-arg", "advanced.rawArgs", "arg", true, BOTH_ADAPTERS, { allowOptionLikeValue: true })
19
- ]);
20
- export const ROLE_AGENT_INHERIT_OPTION = "--inherit";
21
- export const ROLE_EXPECT_UPDATED_AT_OPTION = "--expect-updated-at";
22
- export const ROLE_AGENT_INHERITABLE_FIELDS = Object.freeze(ROLE_AGENT_OPTION_SPECS.map(({ fieldKey }) => fieldKey));
23
- export const ROLE_PROFILE_INHERITABLE_FIELDS = Object.freeze(["systemPrompt"]);
24
- export const ROLE_INHERITABLE_FIELDS = Object.freeze([
25
- ...ROLE_AGENT_INHERITABLE_FIELDS,
26
- ...ROLE_PROFILE_INHERITABLE_FIELDS
27
- ]);
28
- export const ROLE_AGENT_SCRIPTED_OPTIONS = Object.freeze([
29
- ...ROLE_AGENT_OPTION_SPECS.map(({ option }) => option),
30
- ROLE_AGENT_INHERIT_OPTION
31
- ]);
32
- export const ROLE_AGENT_FILE_OPTIONS = Object.freeze(ROLE_AGENT_OPTION_SPECS.filter(({ fileValue }) => fileValue === true).map(({ option }) => option));
33
- export function roleAgentOptionSpecsForAdapter(adapterId) {
34
- return ROLE_AGENT_OPTION_SPECS.filter(({ adapters }) => adapters.includes(adapterId));
35
- }
36
- export function roleAgentOptionUsage() {
37
- return [
38
- ...ROLE_AGENT_OPTION_SPECS.map(({ option, valueLabel, repeatable }) => `[${option} <${valueLabel}>${repeatable ? " ..." : ""}]`),
39
- `[${ROLE_AGENT_INHERIT_OPTION} <field-key> ...]`
40
- ].join(" ");
41
- }
42
- function roleAgentOption(option, fieldKey, valueLabel, repeatable, adapters, extra = {}) {
43
- return Object.freeze({ option, fieldKey, valueLabel, arity: "value", repeatable, adapters, ...extra });
44
- }
45
- export const FIRST_CLASS_AGENT_OPTIONS = Object.freeze([
46
- Object.freeze({ id: "codex", label: "Codex" }),
47
- Object.freeze({ id: "claude", label: "Claude" })
48
- ]);
49
- export function orderRoleOptions(roles) {
50
- return [...roles].sort((left, right) => {
51
- const rank = roleRank(left) - roleRank(right);
52
- if (rank !== 0)
53
- return rank;
54
- return roleName(left).localeCompare(roleName(right));
55
- });
56
- }
57
- function roleRank(role) {
58
- const kind = role.kind?.toLowerCase();
59
- const name = roleName(role).toLowerCase();
60
- if (kind === "operator" || name === "operator")
61
- return 0;
62
- if (kind === "leader" || name === "leader")
63
- return 1;
64
- return 2;
65
- }
66
- function roleName(role) {
67
- return role.name ?? role.id ?? "";
68
- }
@@ -1,30 +0,0 @@
1
- import { MAX_TURN_RESULT_OUTPUT_BYTES } from "../domain/agentResultTransport.js";
2
- export const MAX_SYNTHESIS_SOURCE_TURNS = 8;
3
- export const MAX_CONTEXT_SOURCE_TURNS = MAX_SYNTHESIS_SOURCE_TURNS + 1;
4
- export const MAX_CONTEXT_SOURCE_TURN_BYTES = MAX_CONTEXT_SOURCE_TURNS * (MAX_TURN_RESULT_OUTPUT_BYTES + 16 * 1024);
5
- /**
6
- * Frozen input for synthesis. The main Agent needs the producer identity and
7
- * exact result, not another copy of its prompt history, launch configuration,
8
- * or workspace descriptor.
9
- */
10
- export function sourceTurnContextValue(turn) {
11
- if (turn.result === undefined) {
12
- throw new Error(`Source Turn has no result: ${turn.id}.`);
13
- }
14
- return Object.freeze({
15
- schemaVersion: 1,
16
- id: turn.id,
17
- taskId: turn.taskId,
18
- roleName: turn.roleName,
19
- purpose: turn.purpose,
20
- ...(turn.workItemId === undefined ? {} : { workItemId: turn.workItemId }),
21
- ...(turn.reviewRoundId === undefined ? {} : { reviewRoundId: turn.reviewRoundId }),
22
- ...(turn.executionGroupId === undefined
23
- ? {}
24
- : { executionGroupId: turn.executionGroupId }),
25
- ...(turn.executionLaneId === undefined ? {} : { executionLaneId: turn.executionLaneId }),
26
- result: turn.result,
27
- createdAt: turn.createdAt,
28
- updatedAt: turn.updatedAt
29
- });
30
- }