@zq-silk/yui 0.15.9 → 0.15.12

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 (160) hide show
  1. package/ARCHITECTURE.md +8 -4
  2. package/ARCHITECTURE.zh-CN.md +5 -2
  3. package/README.md +13 -5
  4. package/dist/agent/launchEnvironment.js +7 -0
  5. package/dist/agentRun/agentRun.js +3 -0
  6. package/dist/cli/commandCatalog.js +64 -16
  7. package/dist/cli/interactionPolicy.js +7 -3
  8. package/dist/cli/managedDiagnostics.js +1 -1
  9. package/dist/cli/updateOrchestrator.js +24 -1
  10. package/dist/cli/updatePorts.js +7 -3
  11. package/dist/cli/upgradeCommand.js +42 -2
  12. package/dist/cli.js +381 -107
  13. package/dist/commands/executionAuditCommands.js +10 -0
  14. package/dist/commands/globalRoleCommands.js +339 -4
  15. package/dist/commands/projectCommands.js +50 -22
  16. package/dist/commands/releaseCommands.js +18 -0
  17. package/dist/commands/taskActor.js +25 -0
  18. package/dist/commands/taskCommands.js +586 -96
  19. package/dist/commands/taskIntegrationCommands.js +19 -39
  20. package/dist/commands/taskIntegrationQueueCommands.js +1 -1
  21. package/dist/commands/taskOverviewCommand.js +4 -3
  22. package/dist/commands/taskPublicationAdoptCommand.js +127 -0
  23. package/dist/commands/taskPublicationCommands.js +11 -2
  24. package/dist/commands/taskPublicationVerifyCommand.js +23 -39
  25. package/dist/commands/taskRemoteDeliveryCommand.js +22 -11
  26. package/dist/commands/taskRoleRuntimeStatus.js +35 -0
  27. package/dist/context/runContextPack.js +3 -0
  28. package/dist/context/taskCatalog.js +187 -0
  29. package/dist/context/taskContext.js +55 -6
  30. package/dist/controller/agentHostObservation.js +155 -0
  31. package/dist/controller/clientRuntime.js +17 -2
  32. package/dist/controller/controller.js +14 -2
  33. package/dist/controller/fileSchedulerStoreAdapter.js +519 -25
  34. package/dist/controller/globalInputDelivery.js +132 -0
  35. package/dist/controller/jobControl.js +6 -2
  36. package/dist/controller/providerRetryAdmission.js +100 -0
  37. package/dist/controller/providerRetryDelivery.js +218 -0
  38. package/dist/controller/resourceInventory.js +14 -4
  39. package/dist/controller/resourceInventoryLinux.js +2 -6
  40. package/dist/controller/runtime.js +117 -7
  41. package/dist/controller/runtimeEventInbox.js +32 -3
  42. package/dist/controller/runtimeEventProcessor.js +26 -6
  43. package/dist/controller/runtimeHookRunFence.js +75 -19
  44. package/dist/controller/structuredProviderObservation.js +133 -70
  45. package/dist/coordination/workMailboxQueue.js +5 -0
  46. package/dist/execution/workItemExecutionProjection.js +1 -1
  47. package/dist/executor/agentExecutor.js +64 -4
  48. package/dist/executor/executorRegistry.js +3 -0
  49. package/dist/executor/fileRoleLaunchPlanner.js +78 -118
  50. package/dist/integration/deliveryObligation.js +2 -1
  51. package/dist/integration/gitIntegrationService.js +329 -386
  52. package/dist/integration/integrationAttempt.js +30 -4
  53. package/dist/integration/integrationQueueService.js +7 -7
  54. package/dist/integration/integrationSourceApplication.js +323 -0
  55. package/dist/lifecycle/exactRunTerminalization.js +4 -1
  56. package/dist/message/globalInterrupt.js +33 -0
  57. package/dist/message/globalProviderRetry.js +15 -0
  58. package/dist/message/inputControlResolution.js +106 -0
  59. package/dist/message/message.js +367 -0
  60. package/dist/message/messageContinuation.js +126 -3
  61. package/dist/message/taskInterrupt.js +34 -0
  62. package/dist/observability/executionAudit.js +19 -0
  63. package/dist/observability/orchestrationMetrics.js +1 -1
  64. package/dist/release/releaseHandover.js +22 -0
  65. package/dist/release/releaseWorkflowPorts.js +15 -7
  66. package/dist/repository/gitWorkspace.js +430 -107
  67. package/dist/repository/projectMaintenanceLock.js +75 -18
  68. package/dist/repository/taskWorkspaceCoordinator.js +182 -101
  69. package/dist/repository/taskWorkspacePreparer.js +205 -72
  70. package/dist/repository/workItemCandidateSnapshot.js +34 -0
  71. package/dist/repository/workspaceCleanupInspection.js +187 -0
  72. package/dist/resources/resourceDiscovery.js +3 -2
  73. package/dist/runtime/agentError.js +5 -3
  74. package/dist/runtime/agentHost.js +179 -82
  75. package/dist/runtime/agentHostCompatibility.js +127 -0
  76. package/dist/runtime/agentHostProtocol.js +53 -0
  77. package/dist/runtime/builtinAgentErrorMappers.js +91 -0
  78. package/dist/runtime/codexAppServerRuntime.js +34 -3
  79. package/dist/runtime/executionEnvironment.js +0 -19
  80. package/dist/runtime/launchBroker.js +6 -0
  81. package/dist/runtime/providerControl.js +5 -1
  82. package/dist/runtime/providerRetry.js +198 -0
  83. package/dist/runtime/providerRuntimeIdentity.js +28 -2
  84. package/dist/runtime/sessionReconciliation.js +4 -4
  85. package/dist/runtime/sessionTokenMetrics.js +15 -5
  86. package/dist/runtime/structuredProviderHost.js +6 -2
  87. package/dist/runtime/taskRuntimeIsolation.js +30 -6
  88. package/dist/runtime/taskUsageMetrics.js +275 -0
  89. package/dist/runtime/tmuxAdapters.js +5 -3
  90. package/dist/scheduler/activeRoleRunDelivery.js +12 -0
  91. package/dist/scheduler/leaderWakeupProcessor.js +5 -0
  92. package/dist/scheduler/operatorEvent.js +4 -0
  93. package/dist/scheduler/taskExecutionProjection.js +38 -6
  94. package/dist/scheduler/taskObservabilityProjection.js +6 -44
  95. package/dist/scheduler/wakeReason.js +7 -1
  96. package/dist/scheduler/wakeupQueue.js +2 -0
  97. package/dist/setup/setupCommand.js +26 -8
  98. package/dist/storage/homeLayout.js +130 -0
  99. package/dist/storage/migrations/collapseWorktreeLayout.js +963 -0
  100. package/dist/storage/migrations/integrationContinuation.js +104 -0
  101. package/dist/storage/migrations/unifyHomeLayout.js +925 -0
  102. package/dist/storage/sqliteSchema.js +167 -4
  103. package/dist/storage/sqliteStore.js +57 -1
  104. package/dist/storage/storageVersions.js +1 -1
  105. package/dist/storage/storeRpc.js +2 -0
  106. package/dist/storage/taskCatalog.js +123 -0
  107. package/dist/storage/taskStore.js +2 -0
  108. package/dist/storage/upgrade/upgradeOrchestrator.js +95 -2
  109. package/dist/task/archiveDiagnostics.js +129 -0
  110. package/dist/task/archivePreflight.js +124 -0
  111. package/dist/task/nextAction.js +44 -11
  112. package/dist/task/publicationAdoption.js +56 -0
  113. package/dist/task/publicationReference.js +10 -0
  114. package/dist/task/remoteDelivery.js +31 -16
  115. package/dist/web/assets/client/app.js +147 -17
  116. package/dist/web/assets/client/components.js +56 -13
  117. package/dist/web/assets/client/i18n.js +78 -4
  118. package/dist/web/assets/client/taskSurface.js +108 -1
  119. package/dist/web/assets/client/view.js +39 -8
  120. package/dist/web/assets/shell.js +29 -0
  121. package/dist/web/assets/styles/layout.js +8 -1
  122. package/dist/web/assets/styles/widgets.js +12 -0
  123. package/dist/web/webServer.js +131 -4
  124. package/dist/web/webSnapshot.js +16 -6
  125. package/dist/web/webTaskSurface.js +222 -5
  126. package/dist/workspace/cleanupInspection.js +63 -0
  127. package/dist/workspace/workItemChangeSetManager.js +111 -35
  128. package/docs/agent-result-consumption.md +4 -0
  129. package/docs/agent-result-consumption.zh-CN.md +3 -0
  130. package/docs/agent-runtime-drivers.md +7 -0
  131. package/docs/agent-runtime-drivers.zh-CN.md +5 -0
  132. package/docs/architecture/README.md +2 -0
  133. package/docs/architecture/README.zh-CN.md +3 -1
  134. package/docs/architecture/capabilities-and-resources.md +30 -5
  135. package/docs/architecture/capabilities-and-resources.zh-CN.md +23 -3
  136. package/docs/managed-turn-and-session-runtime.md +47 -0
  137. package/docs/managed-turn-and-session-runtime.zh-CN.md +40 -0
  138. package/docs/observability/README.md +62 -0
  139. package/docs/observability/README.zh-CN.md +47 -0
  140. package/docs/project-refresh.md +77 -0
  141. package/docs/project-refresh.zh-CN.md +59 -0
  142. package/docs/provider-retry.md +70 -0
  143. package/docs/release-workflow.md +39 -0
  144. package/docs/release-workflow.zh-CN.md +29 -0
  145. package/docs/sqlite-control-plane-design.md +223 -1
  146. package/docs/task-delivery.md +133 -13
  147. package/docs/task-delivery.zh-CN.md +99 -10
  148. package/docs/task-discovery.md +102 -0
  149. package/docs/task-discovery.zh-CN.md +86 -0
  150. package/docs/testing/verification-levels.md +40 -0
  151. package/docs/testing/verification-levels.zh-CN.md +23 -0
  152. package/i18n/README.zh-CN.md +13 -7
  153. package/package.json +1 -1
  154. package/skills/yui-leader/references/execution.md +154 -51
  155. package/skills/yui-leader/references/integration.md +52 -2
  156. package/skills/yui-operator/SKILL.md +19 -3
  157. package/skills/yui-reviewer/SKILL.md +4 -0
  158. package/skills/yui-runtime/SKILL.md +42 -0
  159. package/skills/yui-runtime/references/publication.md +42 -0
  160. package/skills/yui-runtime/references/recovery.md +24 -0
@@ -1,10 +1,11 @@
1
1
  import { existsSync, mkdirSync, realpathSync } from "node:fs";
2
- import { delimiter, dirname, isAbsolute, join, relative, resolve } from "node:path";
2
+ import { delimiter, isAbsolute, join, relative, resolve } from "node:path";
3
3
  import { createInterface } from "node:readline/promises";
4
4
  import { configuredAgentToDefinition, createConfiguredAgent } from "../agent/agent.js";
5
5
  import { assertRoleRuntimeMutationAllowed } from "../commands/roleRuntimeGuard.js";
6
6
  import { resolveTmuxBin } from "../config/yuiConfig.js";
7
7
  import { usageError } from "../errors/cliError.js";
8
+ import { managedGlobalRoleWorkspace } from "../storage/homeLayout.js";
8
9
  import { createGlobalRole, createRoleAgentBinding, updateGlobalRole } from "../role/role.js";
9
10
  import { SYSTEM_LEADER_ROLE, SYSTEM_OPERATOR_ROLE } from "../role/systemRoles.js";
10
11
  import { initializeCurrentTaskStore } from "../storage/currentTaskStore.js";
@@ -48,14 +49,27 @@ export async function runSetupCommand(args, env, executor, io = {}) {
48
49
  const currentOperator = store.getGlobalRole(SYSTEM_OPERATOR_ROLE);
49
50
  const selected = await selectOperatorAgent(choices, currentOperator, store.getConfig().defaultAgent, question, io);
50
51
  const agent = selected.existing ?? createConfiguredAgent(selected.id, selected.adapterId, selected.command, [], [], new Date());
51
- const workspace = resolveWorkspace(store.getConfig().defaultWorkspace ?? join(dirname(resolve(home)), "workspace"), home);
52
- const roleStatus = saveMinimumConfiguration(store, agent, workspace, new Set(choices.map(({ id }) => id)));
52
+ // The built-in Global Operator/Leader run under a Home-internal working
53
+ // directory. Yui never auto-invents an external scratch root here: a user
54
+ // who wants an external project-input root configures `default-workspace`
55
+ // explicitly (kept outside Home by its own guard). An already-configured one
56
+ // is carried forward and normalized; none is fabricated.
57
+ const configuredWorkspace = store.getConfig().defaultWorkspace;
58
+ const externalWorkspace = configuredWorkspace === undefined
59
+ ? undefined
60
+ : resolveWorkspace(configuredWorkspace, home);
61
+ const roleWorkspace = managedGlobalRoleWorkspace(home);
62
+ mkdirSync(roleWorkspace, { recursive: true, mode: 0o700 });
63
+ const roleStatus = saveMinimumConfiguration(store, agent, roleWorkspace, externalWorkspace, new Set(choices.map(({ id }) => id)));
53
64
  return `${[
54
65
  "Yui setup complete.",
55
66
  `Yui home: ${home}.`,
56
67
  `Operator: ${agent.id} (${roleStatus.operator}).`,
57
68
  `Leader: ${roleStatus.leaderAgentId} (${roleStatus.leader}).`,
58
- `Default workspace: ${workspace}.`,
69
+ `Global Role workspace: ${roleWorkspace}.`,
70
+ ...(externalWorkspace === undefined
71
+ ? []
72
+ : [`Default workspace: ${externalWorkspace}.`]),
59
73
  "Run `yui config show` to inspect configuration, or `yui operator enter` to start an Operator session for configuration changes or development tasks."
60
74
  ].join("\n")}\n`;
61
75
  }
@@ -116,14 +130,18 @@ async function selectOperatorAgent(choices, currentOperator, defaultAgent, quest
116
130
  }
117
131
  return selected;
118
132
  }
119
- function saveMinimumConfiguration(store, agent, workspace, usableAgentIds) {
133
+ function saveMinimumConfiguration(store, agent, roleWorkspace, externalWorkspace, usableAgentIds) {
120
134
  return store.transaction((tx) => {
121
135
  tx.saveConfiguredAgent(agent);
122
136
  const config = tx.getConfig();
123
137
  tx.saveConfig({
124
138
  ...config,
125
139
  defaultAgent: config.defaultAgent ?? agent.id,
126
- defaultWorkspace: config.defaultWorkspace ?? workspace
140
+ // Only persist a default workspace the user actually configured; setup no
141
+ // longer fabricates an external Home-sibling root.
142
+ ...(externalWorkspace === undefined
143
+ ? {}
144
+ : { defaultWorkspace: config.defaultWorkspace ?? externalWorkspace })
127
145
  });
128
146
  const now = new Date();
129
147
  const leader = tx.getGlobalRole(SYSTEM_LEADER_ROLE);
@@ -135,7 +153,7 @@ function saveMinimumConfiguration(store, agent, workspace, usableAgentIds) {
135
153
  roleName: SYSTEM_LEADER_ROLE
136
154
  }, "creation");
137
155
  const definition = configuredAgentToDefinition(agent);
138
- tx.saveGlobalRole(createGlobalRole(SYSTEM_LEADER_ROLE, [createRoleAgentBinding(definition)], agent.id, workspace, now));
156
+ tx.saveGlobalRole(createGlobalRole(SYSTEM_LEADER_ROLE, [createRoleAgentBinding(definition)], agent.id, roleWorkspace, now));
139
157
  leaderStatus = "created";
140
158
  leaderAgentId = agent.id;
141
159
  }
@@ -161,7 +179,7 @@ function saveMinimumConfiguration(store, agent, workspace, usableAgentIds) {
161
179
  scope: "global",
162
180
  roleName: SYSTEM_OPERATOR_ROLE
163
181
  }, "creation");
164
- tx.saveGlobalRole(createGlobalRole(SYSTEM_OPERATOR_ROLE, [binding], agent.id, workspace, now));
182
+ tx.saveGlobalRole(createGlobalRole(SYSTEM_OPERATOR_ROLE, [binding], agent.id, roleWorkspace, now));
165
183
  return {
166
184
  operator: "created",
167
185
  leader: leaderStatus,
@@ -0,0 +1,130 @@
1
+ import { isAbsolute, join, relative, resolve } from "node:path";
2
+ /**
3
+ * The single authority for every Yui self-managed path derived from a Home.
4
+ *
5
+ * Historically the managed Git worktrees and provider runtimes escaped Home
6
+ * through two different mechanisms: worktree/task roots were derived from the
7
+ * user-facing `defaultWorkspace` (an out-of-Home directory), and provider
8
+ * runtimes/backups were written to string-built siblings of Home
9
+ * (`${home}.task-runtimes`, `${home}-backups`). Both are unified here so that a
10
+ * single canonical YUI_HOME contains all self-managed data, with only the
11
+ * approved short-path IPC sockets (Controller, tmux, Agent Host, integration
12
+ * runtime) remaining outside it for the `sockaddr_un` length budget. Within the
13
+ * managed workspace root, storage v20 further collapses the former
14
+ * physical-worktree/symlink-view split into a single layer of real worktrees
15
+ * under `tasks/` (see {@link managedTaskRoot}).
16
+ *
17
+ * `defaultWorkspace` is intentionally NOT an input to this module: it remains a
18
+ * user-facing cwd for ad-hoc/global Roles and the origin for external Project
19
+ * input, never a second authority for internal managed layout.
20
+ */
21
+ /** Canonicalize a Home string the same way callers already resolve it. */
22
+ function homeRoot(home) {
23
+ const resolved = resolve(home);
24
+ if (!isAbsolute(resolved)) {
25
+ throw new Error("YUI_HOME must be an absolute path.");
26
+ }
27
+ return resolved;
28
+ }
29
+ /**
30
+ * Root that contains every managed Git workspace. Since storage v20 this holds a
31
+ * single layer of real worktrees under `tasks/` (plus the legacy `worktree/`
32
+ * root, preserved by the 19->20 migration as its rollback anchor). A single
33
+ * parent keeps the managed families adjacent and lets the storage migrations
34
+ * relocate them as one subtree.
35
+ */
36
+ export function managedWorkspacesRoot(home) {
37
+ return join(homeRoot(home), "workspaces");
38
+ }
39
+ /**
40
+ * LEGACY physical worktree root: `<home>/workspaces/worktree`. Before storage
41
+ * v20 every managed clone/linked worktree lived here under a per-Project subtree,
42
+ * surfaced to each Task through a symlink view under `tasks/`. The 19->20
43
+ * migration collapses those into real worktrees under `tasks/` and PRESERVES this
44
+ * tree as the rollback anchor, so this path survives only for that migration's
45
+ * inline layout and for post-upgrade cleanup — no current runtime code derives a
46
+ * live worktree path from it.
47
+ */
48
+ export function managedWorktreeRoot(home) {
49
+ return join(managedWorkspacesRoot(home), "worktree");
50
+ }
51
+ /**
52
+ * Managed Git worktrees, one real worktree per Task owner and Project at
53
+ * `<home>/workspaces/tasks/<taskId>/<owner>/<projectDirectory>` (owner being
54
+ * `main`, `work-items/<id>`, `reviews/<name>`, `integrations/<id>`, or
55
+ * `execution-lanes/<g>/<l>`). Before storage v20 these were symlink views over
56
+ * the physical `worktree/` root; the 19->20 migration makes them the worktrees
57
+ * themselves, so the logical entry path and the physical Git worktree coincide.
58
+ */
59
+ export function managedTaskRoot(home) {
60
+ return join(managedWorkspacesRoot(home), "tasks");
61
+ }
62
+ /**
63
+ * Dedicated partition for provider runtime roots (data/cache/tmp) and the
64
+ * planning cwd. This is the ONE Home subtree the Task runtime isolation
65
+ * boundary permits its roots to overlap; every other part of Home (the
66
+ * database, `workspaces/`, `projects/`) stays protected.
67
+ */
68
+ export function managedRuntimeRoot(home) {
69
+ return join(homeRoot(home), "runtime", "task-runtimes");
70
+ }
71
+ /**
72
+ * Dedicated Home partition for the integration check runtime's provider
73
+ * data/cache/tmp. Distinct from `managedRuntimeRoot` so an integration attempt's
74
+ * disposable roots never collide with a Task runtime's, yet still sit inside the
75
+ * one managed runtime subtree the isolation boundary permits to overlap Home.
76
+ * The integration tmux socket endpoint is NOT here — it stays a short `/tmp`
77
+ * path for the `sockaddr_un` budget (see `gitIntegrationService`).
78
+ */
79
+ export function managedIntegrationRuntimeRoot(home) {
80
+ return join(homeRoot(home), "runtime", "integration-runtimes");
81
+ }
82
+ /**
83
+ * Disposable staging prefix for `yui update`'s side-by-side package install
84
+ * (an upgrade artifact): `<home>/runtime/update-staging`. Kept under Home so a
85
+ * staged upgrade never lands in a shared system temp root.
86
+ */
87
+ export function updateStagingRoot(home) {
88
+ return join(homeRoot(home), "runtime", "update-staging");
89
+ }
90
+ /**
91
+ * Disposable scratch parent for the release workflow's Yui-authored artifacts —
92
+ * the fresh-install smoke directory and the verified publish-snapshot tarball
93
+ * (release artifacts): `<home>/runtime/release-workflow`. Kept under Home so a
94
+ * release artifact never lands in a shared system temp root.
95
+ */
96
+ export function releaseWorkflowScratchRoot(home) {
97
+ return join(homeRoot(home), "runtime", "release-workflow");
98
+ }
99
+ /** Disposable planning cwd parent: `<home>/runtime/task-runtimes/planning`. */
100
+ export function planningRuntimeRoot(home) {
101
+ return join(managedRuntimeRoot(home), "planning");
102
+ }
103
+ /** Planning cwd for a single Task, materialized on demand at launch. */
104
+ export function planningRuntimeCwd(home, taskId) {
105
+ return join(planningRuntimeRoot(home), taskId);
106
+ }
107
+ /** Storage-upgrade database backups: `<home>/backups` (was a Home sibling). */
108
+ export function storageBackupRoot(home) {
109
+ return join(homeRoot(home), "backups");
110
+ }
111
+ /**
112
+ * Default working directory for Yui-owned Roles that carry no user-chosen,
113
+ * external cwd: the built-in Global Operator/Leader created by `yui setup` and
114
+ * ad-hoc Global Roles added without an explicit `--workspace`. Historically
115
+ * these fell back to a Home-sibling `workspace/` directory (or `process.cwd()`),
116
+ * which leaked Yui-managed scratch outside the canonical Home. A user who names
117
+ * an external directory keeps external-resource semantics; only the auto-created
118
+ * default lands here, under Home: `<home>/workspaces/global`.
119
+ *
120
+ * This is a plain cwd, NOT a managed Git workspace, so it is deliberately a
121
+ * sibling of `worktree/`+`tasks/` under `workspaces/`, never inside them.
122
+ */
123
+ export function managedGlobalRoleWorkspace(home) {
124
+ return join(managedWorkspacesRoot(home), "global");
125
+ }
126
+ /** True when `child` is strictly inside `parent` (shared with isolation checks). */
127
+ export function isWithinManagedRoot(parent, child) {
128
+ const nested = relative(resolve(parent), resolve(child));
129
+ return nested.length > 0 && !nested.startsWith("..") && !isAbsolute(nested);
130
+ }