@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
@@ -0,0 +1,393 @@
1
+ <p align="right"><strong>English</strong> | <a href="./plugin-sdk.zh-CN.md">简体中文</a></p>
2
+
3
+ # Standalone plugin SDK
4
+
5
+ A standalone directory can contribute Task-local capabilities through the
6
+ existing `capability` ingress without modifying the Yui installation. The
7
+ currently authenticated Leader can manage its own Task's plugins, and the global
8
+ Operator can still manage a named Task's plugins; a Worker/Reviewer keeps call
9
+ and read access but gains no management or self-trust authority. This SDK does
10
+ not implement Endpoint registration or automatic upgrades.
11
+
12
+ The Store persists the user's enable/disable selection and the exact
13
+ validation-artifact reference it points to; the Host is the sole authority for
14
+ the live instances and reference lifecycle. After a Controller restart the
15
+ selection and reports are still readable, but activation must be explicit. There
16
+ is no separate writable `active=true` ledger, no automatic execution of author
17
+ code, and no marketplace, signing platform or recovery worker.
18
+
19
+ ## Ingress and environment
20
+
21
+ All management operations reuse the original Controller, CapabilityRegistry,
22
+ InstanceHost and identity ingress. Use the capabilities below inside an
23
+ authenticated managed Leader/Operator Session; an ordinary terminal cannot gain
24
+ authority by declaring `scope:user`. A development checkout must use its absolute
25
+ `output/dev/bin/yui` and explicitly select its own isolated Home; the global
26
+ installation cannot validate it.
27
+
28
+ | Capability | Input (Task bound by `--task`) | Observable result |
29
+ | --- | --- | --- |
30
+ | `plugin.create` | `preparationId, id, kind` | New directory, manifest and sample; no author code runs |
31
+ | `plugin.scan` | `preparationId, directory` | Data-only scan: manifest, file names, SHA-256 |
32
+ | `plugin.validate` | `preparationId, directory` | Immutable validation ID, source/artifact digests, environment and executed checks |
33
+ | `plugin.validation` | `validationId` | Report summary without starting code; readable by a `task:read` caller in this Task |
34
+ | `plugin.inspect` | `id` | This Task's desired selection, actual selection, Host references and most recent management failure; loads no code |
35
+ | `plugin.list` | `{}` | Current view of every explicit selection in this Task, including disabled ones |
36
+ | `plugin.activate` | `validationId` | On admission, saves the enabled selection, prepares and publishes the instance, and returns the current view |
37
+ | `plugin.disable` | `id` | Saves the disabled selection, stops new calls, and waits for actual references to drain and dispose |
38
+
39
+ `directory` may be a relative path inside the environment or an absolute
40
+ canonical path, but not the environment root, an external path, or a directory
41
+ reached through a symlink. First adopt a writable environment explicitly through
42
+ `environment.prepare/adopt`. Scratch is independent directory ownership, **not an
43
+ OS sandbox**; a user directory still needs a specific Resource grant. Every new
44
+ action rechecks the adoption record, the Task's current status, the directory
45
+ identity, the resource intent and the current Resource grant. Environment
46
+ rechecks and mainline native execution share one `resolveExecutionEnvironment`,
47
+ which requires the current grant to include that preparation's adoption record.
48
+ Issuing a single new grant after revocation does not implicitly re-adopt an old
49
+ environment.
50
+
51
+ The SDK's actual build, candidate and live instance references block a public
52
+ `environment.release`. Disable and drain first; releasing an environment never
53
+ deletes a user directory and never force-removes a non-empty scratch. Disabling a
54
+ plugin does not delete source or validation evidence, and there is no automatic
55
+ uninstall/GC.
56
+
57
+ Example (replace `T`, `P` and `V` with the actual Task, adopted preparation and
58
+ validation IDs):
59
+
60
+ ```text
61
+ <checkout>/output/dev/bin/yui capability call plugin.create --task T --request-id create-1 --input '{"preparationId":"P","id":"demo","kind":"declarative"}'
62
+ <checkout>/output/dev/bin/yui capability call plugin.validate --task T --request-id validate-1 --input '{"preparationId":"P","directory":"demo"}'
63
+ <checkout>/output/dev/bin/yui capability call plugin.activate --task T --request-id activate-1 --input '{"validationId":"V"}'
64
+ <checkout>/output/dev/bin/yui capability call demo.echo --task T --input '{"hello":"world"}'
65
+ <checkout>/output/dev/bin/yui capability call plugin.inspect --task T --input '{"id":"demo"}'
66
+ <checkout>/output/dev/bin/yui capability call plugin.disable --task T --request-id disable-1 --input '{"id":"demo"}'
67
+ ```
68
+
69
+ `requestId` is required for capabilities with side effects, but the SDK builds no
70
+ general idempotency ledger. Re-validating produces a new report and re-activating
71
+ adopts a new generation; after a communication error, read the current facts
72
+ before deciding whether to retry.
73
+
74
+ ## Self-extension inside the original Task
75
+
76
+ The Leader first reads the current catalog and contracts through the stable
77
+ `capability search/describe` to judge whether reuse, composition or an ad-hoc
78
+ script is enough; it is not forced to create a separate plugin-development Task or
79
+ to register every script. When it chooses a plugin, it creates, validates,
80
+ repairs and activates it through the ingress above. The next bridge call can
81
+ discover and invoke the new capability without hot-patching the native tool
82
+ schema, replacing its own Endpoint or restarting the Controller.
83
+
84
+ Task-local management authority is not execution trust: an executable package
85
+ still checks the exact `plugin.execute` grant defined below phase by phase, and a
86
+ changed source does not inherit an old digest's authorization. The boundaries
87
+ around resources, network, global configuration and the core namespace are
88
+ unchanged; when existing authority is sufficient it is not re-approved, and when a
89
+ new permission is missing the specific gap is reported rather than impersonating
90
+ the Operator or self-issuing a grant.
91
+
92
+ On validation failure the Agent preserves the original error and judges the fix;
93
+ an unknown or partial effect must not be auto-rerun. After using a new capability
94
+ to obtain a real business result, save independent content as a file artifact
95
+ through `artifact.save` (it commits the `relativePath` into the Task's local Git
96
+ repository) and keep the returned `commit + relativePath` reference in the Task
97
+ result. `artifact.read` does not
98
+ depend on the plugin staying active. A successful load or a retained plugin source
99
+ is not evidence that the business loop is complete. Protocol fixtures can validate
100
+ the engineering boundary but cannot prove that a real Agent autonomously chose,
101
+ wrote and repaired it; real-scenario validation follows the project's
102
+ resource-authorization boundary.
103
+
104
+ ## Desired selection and actual instance
105
+
106
+ `plugin.inspect/list` are `task:read`: they do not acquire, initialize or recover
107
+ a plugin, and they consume no grant and write no Store. In the current view:
108
+
109
+ - `desired` is the persistent selection — enabled, the pinned validationId, an
110
+ internal revision, the selection time and an optional lastFailure. Version and
111
+ digest are derived from the immutable validation report, not stored again.
112
+ - `actual` is the Host implementation the current Controller selects for new
113
+ calls and its validation reference; it is null when there is no selection or it
114
+ cannot be acquired. It is not a child-process health check and does not prove
115
+ the current grant is still valid.
116
+ - `instances` come from the Host's observation of not-yet-released instances: the
117
+ exact implementation, the actual reference count and whether it still accepts
118
+ new acquires. After disable, `actual` can be null while a draining old
119
+ reference is still listed here.
120
+ - `needsActivation` only compares the desired enabled selection with the actual
121
+ selection; it is not an independent work state or an automatic task.
122
+
123
+ The first query of an unconfigured plugin returns `desired: null`. Disabling an
124
+ unknown plugin still saves an explicit disabled selection but with no
125
+ validationId; disabling a configured plugin keeps the original validation
126
+ reference. Every scope is the Task, and querying another Task never leaks this
127
+ Task's selection.
128
+
129
+ Activation first checks the input, the validation record's ownership, the current
130
+ source/environment, the contract/dependencies and permissions; a request that
131
+ fails admission neither creates nor changes intent. The executable grant's
132
+ consumption and the enabled selection commit in one transaction; if the
133
+ transaction fails, no author code runs, no instance is published, and the grant
134
+ consumption rolls back. If initialization or publication fails afterward, the
135
+ legally accepted desired B, the failure reason and the original actual A are
136
+ retained, letting the Agent decide to retry, replace or disable.
137
+
138
+ A failed activate/disable still returns `kind: failed` rather than faking
139
+ success; when state can be read, its `value` carries the current view above. The
140
+ most recent management failure is recorded against the intended revision, and a
141
+ late result cannot overwrite a newer selection. The revision is incremented by
142
+ the internal transaction, so the caller carries no expected token. Each new
143
+ explicit selection clears the previous management failure; existing
144
+ AgentRun/reports and business receipts are unaffected.
145
+
146
+ Disable commits `disabled` first, then synchronously removes the entry point for
147
+ new calls and waits for the original references to drain; a cleanup failure does
148
+ not reverse `disabled`. If the durable commit fails, the original instance stays
149
+ available and cannot be claimed as disabled. A diagnostic read that fails after a
150
+ successful publication also cannot unload the newly published instance. After an
151
+ error, query the current facts instead of retrying automatically. When a plugin
152
+ has concurrent management actions, the exact provider in an operation result
153
+ refers to that operation's instance, while the attached current view may already
154
+ reflect a later explicit selection.
155
+
156
+ A restart keeps only the selection and existing failure diagnosis: it does not
157
+ guess from an old report whether the plugin used to be enabled, does not replay
158
+ operations automatically, and does not pretend a historical actual instance is
159
+ still running. A case that desired B but ran A appears after restart as
160
+ desired=B, actual=null; activating B again must re-pass the current authorization
161
+ and environment checks.
162
+
163
+ ## Package contract
164
+
165
+ A directory scan only parses data; it does not import author code. The current
166
+ package allows at most 256 UTF-8 files totaling 4 MiB; it rejects symlinks,
167
+ special files and binary dependencies. Every file, including dependencies, enters
168
+ the digest and validation artifact, so provide a small, self-contained,
169
+ non-secret directory rather than a tree that contains credentials, user data or a
170
+ whole development environment.
171
+
172
+ ```json
173
+ {
174
+ "id": "demo",
175
+ "version": "1.0.0",
176
+ "apiVersion": "1",
177
+ "kind": "declarative",
178
+ "entry": "entry.json",
179
+ "capabilities": [{
180
+ "name": "demo.echo",
181
+ "contractVersion": "1",
182
+ "summary": "Return JSON input.",
183
+ "inputSchema": {},
184
+ "outputSchema": {},
185
+ "effect": "query",
186
+ "requiredPermissions": []
187
+ }],
188
+ "required": [],
189
+ "permissions": [],
190
+ "reloadMode": "manual"
191
+ }
192
+ ```
193
+
194
+ `id` is a single segment that starts with a lowercase letter and uses only
195
+ lowercase letters, digits and hyphens. A capability name uses the Registry's
196
+ dotted name; the core namespace (including `context`) and Provider identity
197
+ cannot be overridden. The Provider ID is produced by a trusted root from the Task
198
+ plus plugin ID. Same-named capabilities from different Providers keep the
199
+ Registry's ambiguity rule and are not overridden by load order; a call can
200
+ specify `--provider/--version` explicitly.
201
+
202
+ `required` is an exact `{name, contractVersion}` dependency list, not a version
203
+ solver. A missing, unavailable, ambiguous or cyclic dependency rejects
204
+ activation. The schema uses the Registry's existing bounded dialect, and unknown
205
+ keywords are rejected. Every `requiredPermissions` entry must belong to the
206
+ manifest `permissions`; scope is only visibility, and permission still comes from
207
+ the current caller. A Task-local plugin cannot declare `plugin:manage`.
208
+
209
+ A declarative `entry.json` must be complete and contain only the capabilities the
210
+ manifest declares:
211
+
212
+ ```json
213
+ { "demo.echo": { "type": "echo" } }
214
+ ```
215
+
216
+ It supports `echo`, `constant + value`, and
217
+ `call + name + contractVersion + optional providerId`. `call` hands the original
218
+ input and requestId to one explicit dependency, returns its value, and preserves
219
+ the original operations/effect; it is not a multi-step flow engine. A declarative
220
+ package cannot declare a build and never runs arbitrary JavaScript.
221
+
222
+ ## Executable contract and trust
223
+
224
+ A `kind: trusted-local`, `entry: entry.mjs` package runs in a separate Node child
225
+ process, not inside the Controller. The child process uses the explicitly adopted
226
+ environment directory as cwd, reconstructs a minimal set of environment
227
+ variables, and does not inherit the Yui Session, credentials, `NODE_OPTIONS` or
228
+ `NODE_PATH`.
229
+
230
+ The running module is loaded from the captured bytes through `SourceTextModule`;
231
+ it supports only in-package relative module dependencies, not bare package names,
232
+ `node:` or dynamic import — a needed pure-JS dependency must be bundled first.
233
+ This loader bounds where the code comes from; it is **not a malicious-code
234
+ security sandbox**. It cannot promise the host filesystem, network, processes or
235
+ secrets are unreachable. Auto-generated code without specific trust should use the
236
+ declarative path or a genuinely restricted environment instead; this SDK does not
237
+ provide that environment.
238
+
239
+ The author entry exports:
240
+
241
+ ```javascript
242
+ const echo = input => input;
243
+ export function initialize() {
244
+ return {
245
+ handlers: { "demo.echo": async (input, api) => echo(input) },
246
+ dispose() {}
247
+ };
248
+ }
249
+ export function selfTest() {
250
+ return echo("probe") === "probe";
251
+ }
252
+ ```
253
+
254
+ ### The author module's runtime environment
255
+
256
+ The Node child process is the host; that does not mean the author module runs in
257
+ a full Node global environment. The current module uses a separate vm context and
258
+ relies only on ECMAScript built-ins and the SDK ports below:
259
+
260
+ | Category | Current availability |
261
+ | --- | --- |
262
+ | ECMAScript built-ins such as `Promise`, `JSON`, `Math`, `Date` | Available; `async/await` and `Promise.resolve()` work |
263
+ | `console` | Visible, but not an SDK log or receipt port; child stdout/stderr is not forwarded to the caller |
264
+ | `setTimeout`, `setInterval`, `queueMicrotask` | Not provided; do not use ordinary Node timers to drive async flow |
265
+ | `structuredClone`, `process`, `Buffer` | Not provided |
266
+ | `fetch`, `URL`, `TextEncoder`, `AbortController`, `crypto` | Not provided |
267
+ | Business I/O and downstream tools | Use the handler's `api.call`, bounded by the original caller's permissions and effect |
268
+
269
+ So `await Promise.resolve()` works while `await new Promise(r => setTimeout(r, 50))`
270
+ does not. A handler that never settles triggers the 30-second child request
271
+ timeout below. The table describes the normal author API, not a security-isolation
272
+ claim; the absence of some global does not prove malicious trusted-local code
273
+ cannot reach the host. A build script is another trusted Node execution path and
274
+ is not bound by this author-module global table.
275
+
276
+ Initialization may only prepare the complete registration; it must not send,
277
+ publish or modify business data or start a background service. It receives no
278
+ business call port, and a failed initialization only closes the candidate child
279
+ process. A trusted-local author must still honor this contract, and a missing
280
+ port is not an isolation guarantee against arbitrary malicious code with direct
281
+ host access. `selfTest()` actually runs during validation and must return `true`;
282
+ the report does not treat an author test as a security certification.
283
+
284
+ The handler's `api` contains only the original `context`'s credential-free
285
+ identity, its `requestId`, and
286
+ `call({name,input,contractVersion?,providerId?,requestId?})`. There is no Store,
287
+ Host, Registry, authorizer, optional actor or `observe` port. Every nested call
288
+ rechecks the original caller and the current execution grant; permission cannot
289
+ exceed the parent descriptor's declaration, and effect cannot exceed the parent
290
+ effect. For a completed sub-action, even if the parent output schema is wrong,
291
+ throws, or cannot be JSON-serialized, the original operations, effect and receipt
292
+ locator are preserved; the real evidence still belongs to the original business
293
+ owner, such as a Job.
294
+
295
+ Trusted code should produce business effects only through these controlled ports.
296
+ A trusted-local host operation that bypasses the ports directly cannot have its
297
+ real receipt or effect scope derived by the SDK and is not covered by the
298
+ evidence guarantees above. The default single child request limit is 30 seconds;
299
+ a timeout or abnormal exit returns a failure and closes the owned child process
300
+ without retry. `dispose` must release only its own resources and not manage a
301
+ shared daemon. Any author-spawned process or host residue after a crash is not
302
+ falsely claimed as reclaimed, and this SDK provides no cross-Controller-process
303
+ recovery/sweep protocol.
304
+
305
+ ### Execution authorization
306
+
307
+ An adopted directory does not grant execution of author code. Every actual
308
+ `build`, `validate`, `activate` or `call` attempt additionally requires a current
309
+ `plugin.execute` grant that pins all five parameters:
310
+
311
+ | Parameter | Value |
312
+ | --- | --- |
313
+ | `pluginId` | manifest id |
314
+ | `digest` | build/validate use the `plugin.scan` source digest; activate/call use the report's artifact digest |
315
+ | `environmentRef` | `Task/preparation` |
316
+ | `trust` | `trusted-local` |
317
+ | `phase` | an explicitly chosen subset of `build, validate, activate, call` |
318
+
319
+ Use Task scope; a home scope with an exact environment path may be added, but a
320
+ Project/repository/package scope is not accepted as a resource-trust substitute.
321
+ Because trusted-local does not bound direct host effects, this grant must allow
322
+ `irreversibilityCeiling: irreversible`: that is the capability ceiling, not a
323
+ statement that every call actually produces an irreversible effect. `none` or
324
+ `reversible` must not be read as unlimited local execution authority.
325
+
326
+ An Operator explicitly authorized by the user uses the original grant ingress,
327
+ for example to allow a single validation:
328
+
329
+ ```text
330
+ <checkout>/output/dev/bin/yui task grant issue T --action plugin.execute --param pluginId=demo --param digest=SOURCE_SHA256 --param environmentRef=T/P --param trust=trusted-local --param phase=validate --max-uses 1 --irreversibility-ceiling irreversible
331
+ ```
332
+
333
+ A grant is not self-issued by the SDK. Uses are consumed per real execution
334
+ attempt and are not refunded on failure; one validate includes
335
+ initialize/selfTest/dispose. A build is another execution. `call` is a short
336
+ invocation that cannot resume from a persistent step; it only increments usesUsed
337
+ and adds no permanent reservation. Its admission is held by the current call's
338
+ bound closure and cannot be exported, forged or used to continue execution after a
339
+ process restart. build/validate/activate use a persistent reservation; an
340
+ existing key is not truncated or cleaned up. A current call that has already
341
+ consumed its quota can keep rechecking, but revocation/expiry still blocks
342
+ subsequent controlled actions, and an exhausted quota allows no new call.
343
+ Long-term use does not add a new permanent key per call. A not-yet-committed
344
+ enable-intent transaction that fails is not a completed execution attempt, and
345
+ its consumption rolls back with the transaction. An ordinary disable does not
346
+ revoke an original call already executing, and revocation erases neither the
347
+ intent nor an effect that already happened.
348
+
349
+ ### Build and artifacts
350
+
351
+ An executable manifest may add `"build": ["build.mjs", "arg"]`. This is an
352
+ explicit Node script and arguments, not a shell string. The build script must
353
+ live inside the captured source package; it runs in its own new temporary copy
354
+ inside the adopted environment and may use Node APIs, so it likewise requires
355
+ trusted-local trust. The builder must not depend on undeclared user secrets or
356
+ leave a background process behind.
357
+
358
+ Validation saves all bytes and the digest of the actual build artifact and
359
+ records the source digest, the Node version, the environment identity, the actual
360
+ build cwd/argv and the executed checks. A build cannot change the
361
+ manifest/permissions; with no build, the first captured bytes execute directly,
362
+ without a second read before execution. A build does not overwrite the author
363
+ source. Validation rechecks the source directory at the end and refuses to save a
364
+ success report if it has changed.
365
+
366
+ Activation rechecks the source-directory digest, the environment and the current
367
+ authorization, then initializes only from the artifact bytes in the report; it
368
+ does not rebuild or switch to another directory of the same version. A post-build
369
+ validation authorization applies to the artifact produced from the explicitly
370
+ trusted source, while a formal activate/call is authorized separately against that
371
+ actual artifact digest.
372
+
373
+ Publication rechecks the complete contribution, dependencies and permissions
374
+ again. A failure does not change the existing directory; a competing
375
+ activate/disable makes a late candidate refuse to publish. After a successful
376
+ publication, the old generation only serves existing references and is disposed
377
+ once drained; a cleanup failure keeps a diagnostic Artifact and neither rolls
378
+ back the new Provider nor pretends the current instance is still unpublished.
379
+
380
+ ## Storage and other ingress
381
+
382
+ Validation artifacts and enable intent belong to the single Home storage
383
+ contract, and a persistent structural change follows the explicit upgrade/update
384
+ and backup mechanism. Reading a report does not infer or recover an instance, and
385
+ adopting new source does not authorize upgrading the shared Home, restarting the
386
+ Controller or executing the plugin.
387
+
388
+ One Registry projects capabilities into commands and controlled query panels
389
+ without duplicating the SDK Host; a Web query identity does not gain
390
+ `plugin:manage`. A native Session and a plugin share the environment owner, and
391
+ both native execution references and plugin references are checked before release.
392
+ A plugin provides no Project/global scope elevation and no native Endpoint
393
+ registration.