maka-agent 0.2.0-dev.23.20260906 → 0.2.0-dev.25.20260908

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 (215) hide show
  1. package/README.md +38 -19
  2. package/README.zh-CN.md +34 -19
  3. package/dist/acp/maka-acp-agent.js +2 -1
  4. package/dist/acp/session-configuration.js +143 -0
  5. package/dist/acp/session-registry.js +90 -4
  6. package/dist/cli-core.js +2 -0
  7. package/dist/pi-transcript-tools.js +6 -0
  8. package/dist/pi-transcript.js +5 -12
  9. package/dist/pi-tui-layout.js +56 -10
  10. package/dist/pi-tui-pickers.js +102 -1
  11. package/dist/pi-tui-runner.js +230 -46
  12. package/dist/pi-tui-todo.js +221 -0
  13. package/dist/pi-tui-transcript-viewer.js +134 -7
  14. package/dist/runtime-host-cli-context.js +224 -78
  15. package/dist/runtime-host-cli-installation.js +8 -2
  16. package/dist/runtime-host-cli.js +31 -1
  17. package/dist/runtime-host-handoff-surface.js +106 -0
  18. package/dist/runtime-host-installed-update-bootstrap.js +13 -0
  19. package/dist/runtime-host-installed-update-coordinator.js +33 -0
  20. package/dist/runtime-host-lifecycle-transaction.js +9 -1
  21. package/dist/runtime-host-local-handoff.js +48 -5
  22. package/dist/runtime-host-local-managed-activation.js +84 -0
  23. package/dist/runtime-host-local-source-retirement.js +18 -2
  24. package/dist/runtime-host-managed-lifecycle-manager.js +1 -0
  25. package/dist/runtime-host-operator-retirement.js +50 -0
  26. package/dist/runtime-host-service-manager.js +3 -3
  27. package/dist/runtime-host-session-channel.js +13 -0
  28. package/dist/runtime-host-session-driver.js +46 -26
  29. package/dist/runtime-host-session-update.js +62 -0
  30. package/dist/runtime-host-tui-command.js +38 -73
  31. package/dist/runtime-host-tui-context.js +1 -0
  32. package/dist/runtime-host-tui-owner.js +226 -0
  33. package/dist/tui-copy-catalog.js +219 -6
  34. package/dist/tui-host-owner-copy.js +24 -0
  35. package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
  36. package/node_modules/@maka/core/dist/agent-run.js +1 -0
  37. package/node_modules/@maka/core/dist/attachments.js +3 -0
  38. package/node_modules/@maka/core/dist/canonical-json.js +27 -0
  39. package/node_modules/@maka/core/dist/canonical-runtime-event.js +3 -1
  40. package/node_modules/@maka/core/dist/capabilities.js +35 -0
  41. package/node_modules/@maka/core/dist/computer-use.js +0 -1
  42. package/node_modules/@maka/core/dist/display-redaction.js +18 -0
  43. package/node_modules/@maka/core/dist/llm-connections.js +13 -0
  44. package/node_modules/@maka/core/dist/model-call-attempt.js +2 -0
  45. package/node_modules/@maka/core/dist/model-failure.js +40 -0
  46. package/node_modules/@maka/core/dist/model-metadata.generated.js +4 -4
  47. package/node_modules/@maka/core/dist/model-metadata.js +7 -3
  48. package/node_modules/@maka/core/dist/model-web-search.js +5 -4
  49. package/node_modules/@maka/core/dist/provider-registry.js +45 -4
  50. package/node_modules/@maka/core/dist/record-schema.js +9 -2
  51. package/node_modules/@maka/core/dist/redaction.js +35 -0
  52. package/node_modules/@maka/core/dist/run-composition.js +77 -2
  53. package/node_modules/@maka/core/dist/runtime-boundary.js +31 -11
  54. package/node_modules/@maka/core/dist/runtime-event.js +37 -6
  55. package/node_modules/@maka/core/dist/runtime-handoff.js +98 -0
  56. package/node_modules/@maka/core/dist/runtime-invocation.js +1 -1
  57. package/node_modules/@maka/core/dist/runtime-logical-execution.js +112 -0
  58. package/node_modules/@maka/core/dist/session.js +84 -56
  59. package/node_modules/@maka/core/dist/slash-command-catalog.js +3 -0
  60. package/node_modules/@maka/core/dist/tool-result-archive-evidence.js +20 -0
  61. package/node_modules/@maka/core/dist/tool-result-record-schema.js +2 -1
  62. package/node_modules/@maka/core/dist/usage-record-schema.js +26 -35
  63. package/node_modules/@maka/core/package.json +5 -0
  64. package/node_modules/@maka/eval/dist/experiment-directory.js +4 -13
  65. package/node_modules/@maka/mcp/dist/index.js +131 -1
  66. package/node_modules/@maka/runtime/dist/agent-run-inspect.js +0 -13
  67. package/node_modules/@maka/runtime/dist/agent-run.js +351 -105
  68. package/node_modules/@maka/runtime/dist/ai-sdk-backend.js +29 -13
  69. package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +109 -34
  70. package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +184 -183
  71. package/node_modules/@maka/runtime/dist/archive-read-tool.js +2 -2
  72. package/node_modules/@maka/runtime/dist/context-budget-helpers.js +0 -16
  73. package/node_modules/@maka/runtime/dist/context-budget.js +14 -9
  74. package/node_modules/@maka/runtime/dist/conversation-copy.js +158 -15
  75. package/node_modules/@maka/runtime/dist/github-copilot-oauth-enrollment.js +3 -3
  76. package/node_modules/@maka/runtime/dist/goal-continuation.js +36 -4
  77. package/node_modules/@maka/runtime/dist/history-compact-checkpoint.js +18 -9
  78. package/node_modules/@maka/runtime/dist/history-compact-summarizer.js +30 -22
  79. package/node_modules/@maka/runtime/dist/history-compaction.js +29 -4
  80. package/node_modules/@maka/runtime/dist/ledger-tool-result-archive-reader.js +174 -0
  81. package/node_modules/@maka/runtime/dist/mcp-tools.js +7 -2
  82. package/node_modules/@maka/runtime/dist/message-authority.js +9 -0
  83. package/node_modules/@maka/runtime/dist/model-adapter.js +19 -98
  84. package/node_modules/@maka/runtime/dist/model-factory.js +19 -81
  85. package/node_modules/@maka/runtime/dist/model-fetcher.js +49 -2
  86. package/node_modules/@maka/runtime/dist/model-history.js +0 -112
  87. package/node_modules/@maka/runtime/dist/model-runtime.js +85 -111
  88. package/node_modules/@maka/runtime/dist/native-web-search-tool.js +2 -1
  89. package/node_modules/@maka/runtime/dist/openai-codex-history-compactor.js +2 -2
  90. package/node_modules/@maka/runtime/dist/opencode-session-header.js +4 -2
  91. package/node_modules/@maka/runtime/dist/plugin-runtime.js +20 -10
  92. package/node_modules/@maka/runtime/dist/plugin-tool-service.js +205 -0
  93. package/node_modules/@maka/runtime/dist/provider-error-classification.js +84 -123
  94. package/node_modules/@maka/runtime/dist/provider-request-telemetry.js +76 -109
  95. package/node_modules/@maka/runtime/dist/request-shape.js +23 -0
  96. package/node_modules/@maka/runtime/dist/run-handoff-gate.js +97 -0
  97. package/node_modules/@maka/runtime/dist/runtime-event-backfill.js +83 -55
  98. package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +121 -159
  99. package/node_modules/@maka/runtime/dist/runtime-kernel.js +157 -112
  100. package/node_modules/@maka/runtime/dist/runtime-ledger-repair.js +160 -79
  101. package/node_modules/@maka/runtime/dist/runtime-read-model.js +30 -89
  102. package/node_modules/@maka/runtime/dist/runtime-resume.js +80 -4
  103. package/node_modules/@maka/runtime/dist/session-event-runtime-mapper.js +5 -0
  104. package/node_modules/@maka/runtime/dist/session-manager.js +171 -288
  105. package/node_modules/@maka/runtime/dist/session-projection-helpers.js +0 -27
  106. package/node_modules/@maka/runtime/dist/stream-graph-coordinator.js +21 -0
  107. package/node_modules/@maka/runtime/dist/stream-graph-supervisor-tools.js +0 -5
  108. package/node_modules/@maka/runtime/dist/subscription-model-fetch.js +3 -4
  109. package/node_modules/@maka/runtime/dist/test-connection.js +16 -17
  110. package/node_modules/@maka/runtime/dist/tool-activation-identity.js +41 -0
  111. package/node_modules/@maka/runtime/dist/tool-availability.js +11 -1
  112. package/node_modules/@maka/runtime/dist/tool-result-archive-encoding.js +38 -0
  113. package/node_modules/@maka/runtime/dist/tool-result-archive-resource.js +63 -1
  114. package/node_modules/@maka/runtime/dist/tool-result-archive-transition.js +42 -12
  115. package/node_modules/@maka/runtime/dist/tool-result-archive.js +27 -4
  116. package/node_modules/@maka/runtime/dist/tool-runtime.js +3 -61
  117. package/node_modules/@maka/runtime/package.json +2 -0
  118. package/node_modules/@maka/runtime-host/dist/adapter/session-projector.js +35 -0
  119. package/node_modules/@maka/runtime-host/dist/client/connect-or-spawn.js +9 -1
  120. package/node_modules/@maka/runtime-host/dist/client/connection.js +3 -0
  121. package/node_modules/@maka/runtime-host/dist/client/host-handoff-copy.js +179 -0
  122. package/node_modules/@maka/runtime-host/dist/client/host-handoff.js +275 -0
  123. package/node_modules/@maka/runtime-host/dist/client/host-retirement.js +26 -5
  124. package/node_modules/@maka/runtime-host/dist/client/index.js +2 -0
  125. package/node_modules/@maka/runtime-host/dist/client/launcher.js +3 -0
  126. package/node_modules/@maka/runtime-host/dist/client/remote-compatibility-error.js +2 -0
  127. package/node_modules/@maka/runtime-host/dist/client/session-subscription.js +46 -5
  128. package/node_modules/@maka/runtime-host/dist/control/endpoint.js +1 -3
  129. package/node_modules/@maka/runtime-host/dist/node-error.js +22 -0
  130. package/node_modules/@maka/runtime-host/dist/operator/index.js +2 -1
  131. package/node_modules/@maka/runtime-host/dist/operator/managed-deployment.js +1 -3
  132. package/node_modules/@maka/runtime-host/dist/operator/retirement-cancellation.js +20 -0
  133. package/node_modules/@maka/runtime-host/dist/peer-mesh/limits.js +0 -1
  134. package/node_modules/@maka/runtime-host/dist/peer-mesh/model.js +1 -1
  135. package/node_modules/@maka/runtime-host/dist/peer-reachability/publisher.js +1 -3
  136. package/node_modules/@maka/runtime-host/dist/protocol/host-status.js +21 -12
  137. package/node_modules/@maka/runtime-host/dist/protocol/index.js +29 -1
  138. package/node_modules/@maka/runtime-host/dist/protocol/operations.js +1 -0
  139. package/node_modules/@maka/runtime-host/dist/protocol/plan.js +1 -0
  140. package/node_modules/@maka/runtime-host/dist/protocol/plugin-platform.js +27 -5
  141. package/node_modules/@maka/runtime-host/dist/protocol/project-catalog.js +2 -2
  142. package/node_modules/@maka/runtime-host/dist/protocol/session-continuity.js +40 -20
  143. package/node_modules/@maka/runtime-host/dist/protocol/session-transcript.js +0 -5
  144. package/node_modules/@maka/runtime-host/dist/protocol/session-turns.js +29 -58
  145. package/node_modules/@maka/runtime-host/dist/protocol/turn.js +11 -1
  146. package/node_modules/@maka/runtime-host/dist/protocol/workhub-coordination.js +31 -2
  147. package/node_modules/@maka/runtime-host/dist/server/access-credential-store.js +1 -0
  148. package/node_modules/@maka/runtime-host/dist/server/agent-graph-coordinator.js +0 -3
  149. package/node_modules/@maka/runtime-host/dist/server/canonical-turn-snapshot.js +19 -4
  150. package/node_modules/@maka/runtime-host/dist/server/connection-session.js +7 -6
  151. package/node_modules/@maka/runtime-host/dist/server/execution-artifacts.js +32 -32
  152. package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +144 -33
  153. package/node_modules/@maka/runtime-host/dist/server/execution-model-authority.js +5 -5
  154. package/node_modules/@maka/runtime-host/dist/server/execution-model-composition.js +45 -16
  155. package/node_modules/@maka/runtime-host/dist/server/goal-coordinator.js +40 -1
  156. package/node_modules/@maka/runtime-host/dist/server/host-kernel.js +96 -17
  157. package/node_modules/@maka/runtime-host/dist/server/host-residency-registry.js +13 -7
  158. package/node_modules/@maka/runtime-host/dist/server/hosted-execution-admission-registry.js +3 -1
  159. package/node_modules/@maka/runtime-host/dist/server/hosted-execution-recovery.js +124 -62
  160. package/node_modules/@maka/runtime-host/dist/server/interactive-run-composer.js +47 -22
  161. package/node_modules/@maka/runtime-host/dist/server/message-coordinator.js +76 -6
  162. package/node_modules/@maka/runtime-host/dist/server/plugin-platform-coordinator.js +6 -0
  163. package/node_modules/@maka/runtime-host/dist/server/plugin-platform.js +6 -0
  164. package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +325 -73
  165. package/node_modules/@maka/runtime-host/dist/server/scheduled-task-coordinator.js +37 -2
  166. package/node_modules/@maka/runtime-host/dist/server/serial-outbound-writer.js +45 -3
  167. package/node_modules/@maka/runtime-host/dist/server/session-catalog-coordinator.js +50 -7
  168. package/node_modules/@maka/runtime-host/dist/server/session-continuity-coordinator.js +87 -25
  169. package/node_modules/@maka/runtime-host/dist/server/session-retirement-coordinator.js +5 -2
  170. package/node_modules/@maka/runtime-host/dist/server/session-revision-coordinator.js +12 -55
  171. package/node_modules/@maka/runtime-host/dist/server/session-sidecar-purge.js +1 -16
  172. package/node_modules/@maka/runtime-host/dist/server/session-transcript-pager.js +0 -1
  173. package/node_modules/@maka/runtime-host/dist/server/session-transcript-reader.js +460 -70
  174. package/node_modules/@maka/runtime-host/dist/server/shared-session-transcript.js +1 -1
  175. package/node_modules/@maka/runtime-host/dist/server/storage-maintenance.js +109 -0
  176. package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-action-gate.js +20 -2
  177. package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +13 -4
  178. package/node_modules/@maka/runtime-host/dist/server/workhub-message-attachments.js +46 -0
  179. package/node_modules/@maka/storage/dist/artifact-store.js +21 -10
  180. package/node_modules/@maka/storage/dist/artifact-stores.js +1 -1
  181. package/node_modules/@maka/storage/dist/claude-code-session-adapter.js +0 -5
  182. package/node_modules/@maka/storage/dist/codex-session-adapter.js +284 -198
  183. package/node_modules/@maka/storage/dist/context-offload-snapshot.js +325 -0
  184. package/node_modules/@maka/storage/dist/execution-stores.js +9 -7
  185. package/node_modules/@maka/storage/dist/file-session-repository.js +1012 -0
  186. package/node_modules/@maka/storage/dist/git-exec.js +61 -0
  187. package/node_modules/@maka/storage/dist/git-worktree-child-executor.js +8 -35
  188. package/node_modules/@maka/storage/dist/goal-authority.js +2 -2
  189. package/node_modules/@maka/storage/dist/interaction-store.js +2 -2
  190. package/node_modules/@maka/storage/dist/opencode-session-adapter.js +0 -4
  191. package/node_modules/@maka/storage/dist/operational-state-backup.js +9 -5
  192. package/node_modules/@maka/storage/dist/project-catalog.js +2 -23
  193. package/node_modules/@maka/storage/dist/runtime-event-invariants.js +2 -2
  194. package/node_modules/@maka/storage/dist/runtime-event-persistence.js +1 -0
  195. package/node_modules/@maka/storage/dist/runtime-policy/connection-catalog-document.js +8 -3
  196. package/node_modules/@maka/storage/dist/runtime-transcript-query.js +308 -0
  197. package/node_modules/@maka/storage/dist/scheduled-task-store.js +249 -283
  198. package/node_modules/@maka/storage/dist/session-bundle-manifest.js +5 -17
  199. package/node_modules/@maka/storage/dist/session-bundle-policy.js +26 -5
  200. package/node_modules/@maka/storage/dist/session-copy-cleanup.js +2 -1
  201. package/node_modules/@maka/storage/dist/session-message-projection.js +15 -0
  202. package/node_modules/@maka/storage/dist/session-repository.js +767 -0
  203. package/node_modules/@maka/storage/dist/session-store.js +25 -99
  204. package/node_modules/@maka/storage/dist/sqlite-artifact-metadata.js +10 -3
  205. package/node_modules/@maka/storage/dist/sqlite-context-offload-store.js +24 -8
  206. package/node_modules/@maka/storage/dist/sqlite-core-execution-schema.js +7 -1
  207. package/node_modules/@maka/storage/dist/sqlite-runtime-schema.js +44 -1
  208. package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +130 -27
  209. package/node_modules/@maka/storage/dist/sqlite-session-metadata-store.js +109 -892
  210. package/node_modules/@maka/storage/dist/storage-id.js +28 -0
  211. package/node_modules/@maka/storage/dist/tool-result-archive-evidence.js +138 -0
  212. package/node_modules/@maka/storage/dist/workspace-identity.js +2 -15
  213. package/node_modules/@maka/storage/dist/workspace-version-authority-internal.js +1 -8
  214. package/node_modules/@maka/storage/package.json +2 -0
  215. package/package.json +1 -1
@@ -20,6 +20,7 @@ import { randomUUID } from 'node:crypto';
20
20
  import { join } from 'node:path';
21
21
  import { DEFAULT_SESSION_NAME } from '@maka/core/session-name';
22
22
  import { decodeStoredMessage as decodePersistedStoredMessage, deriveTurnRecords, userFacingText, } from '@maka/core/session';
23
+ import { projectSessionTodoItemsForDisplay } from '@maka/core/session-todo';
23
24
  import { markPersisted } from '@maka/core/persisted-value';
24
25
  import { isSideConversationSession } from '@maka/core/side-conversation';
25
26
  import { createSessionCopyCleanupAuthority, } from '@maka/storage/session-copy-cleanup';
@@ -30,6 +31,7 @@ import { isRuntimeHostTerminalTurn as isTerminalTurn } from '@maka/runtime-host/
30
31
  import { projectSessionCatalogSummary, readRuntimeHostResources, readRuntimeHostSessions, RuntimeHostOperationError, RuntimeHostRequestInterruptedError, } from '@maka/runtime-host/client';
31
32
  import { SESSION_TRANSCRIPT_BOOTSTRAP_MAX_BYTES, } from '@maka/runtime-host/protocol';
32
33
  import { RuntimeHostSessionChannel } from './runtime-host-session-channel.js';
34
+ import { getRuntimeHostSession, requireRuntimeHostSessionProjection as requireSession, updateRuntimeHostSession, } from './runtime-host-session-update.js';
33
35
  import { inspectSessionResumeAvailability, skillInvocationBlockedMessage, } from './session-driver.js';
34
36
  import { cwdRank, firstLine, inspectGitCwdChanges, resolveMoveCwd, } from './session-driver-policy.js';
35
37
  const decodeStoredMessage = (value) => decodePersistedStoredMessage(markPersisted(value));
@@ -87,6 +89,7 @@ class RuntimeHostMakaSessionDriverImpl {
87
89
  #transcriptRefreshSequence = 0;
88
90
  #startedTurnListeners = new Set();
89
91
  #goalListeners = new Set();
92
+ #todoChangeListeners = new Set();
90
93
  #pendingInteractionListeners = new Set();
91
94
  #claimedTurnIds = new Set();
92
95
  #shellRunListeners = new Set();
@@ -380,6 +383,22 @@ class RuntimeHostMakaSessionDriverImpl {
380
383
  const sessionId = await this.#ensureSession();
381
384
  return this.#request('turn.message.query', { sessionId, messageIds });
382
385
  }
386
+ async queryTodo(sessionId) {
387
+ const currentSessionId = this.#requireSession('query Todo');
388
+ if (sessionId !== currentSessionId) {
389
+ throw new Error(`Cannot query Todo for a non-current Session: ${sessionId}`);
390
+ }
391
+ const sessionGeneration = this.#sessionGeneration;
392
+ const result = await this.#request('session.todo.query', { sessionId });
393
+ this.#assertCurrentSession(sessionId, sessionGeneration);
394
+ if (result.sessionId !== sessionId) {
395
+ throw new Error(`Runtime Host returned Todo for an unexpected Session: ${result.sessionId}`);
396
+ }
397
+ return {
398
+ sessionId,
399
+ items: projectSessionTodoItemsForDisplay(result.items),
400
+ };
401
+ }
383
402
  async retractQueued() {
384
403
  if (!this.#sessionId)
385
404
  return { text: '', messageIds: [] };
@@ -502,7 +521,7 @@ class RuntimeHostMakaSessionDriverImpl {
502
521
  sessionId,
503
522
  expectedRevision: current.revision,
504
523
  patch: { name },
505
- }));
524
+ }), { operation: 'session.metadata.update' });
506
525
  return session.name;
507
526
  }
508
527
  async #moveSession(rawCwd) {
@@ -602,7 +621,7 @@ class RuntimeHostMakaSessionDriverImpl {
602
621
  sessionId,
603
622
  expectedRevision: current.revision,
604
623
  workspace: { kind: 'host_path', path: cwd },
605
- }));
624
+ }), { operation: 'session.workspace.relocate' });
606
625
  }
607
626
  async listRewindTargets() {
608
627
  if (!this.#sessionId)
@@ -855,6 +874,10 @@ class RuntimeHostMakaSessionDriverImpl {
855
874
  this.#goalListeners.add(listener);
856
875
  return () => this.#goalListeners.delete(listener);
857
876
  }
877
+ subscribeTodoChanges(listener) {
878
+ this.#todoChangeListeners.add(listener);
879
+ return () => this.#todoChangeListeners.delete(listener);
880
+ }
858
881
  async controlGoal(action) {
859
882
  const sessionId = this.#sessionId;
860
883
  if (!sessionId)
@@ -1073,7 +1096,7 @@ class RuntimeHostMakaSessionDriverImpl {
1073
1096
  sessionId,
1074
1097
  expectedRevision: current.revision,
1075
1098
  patch,
1076
- }));
1099
+ }), { operation: 'session.configuration.update' });
1077
1100
  }
1078
1101
  #adoptConfiguration(session) {
1079
1102
  this.#model = session.model;
@@ -1245,6 +1268,7 @@ class RuntimeHostMakaSessionDriverImpl {
1245
1268
  now: this.#now,
1246
1269
  onTurnStarted: (turn) => this.#publishStartedTurn(turn, sessionGeneration),
1247
1270
  onRuntimeResourceChanged: (sourceSessionId, ref) => this.#publishRuntimeResource(sourceSessionId, ref),
1271
+ onSessionDomainChanged: (frame) => this.#publishSessionDomainChanged(frame, sessionId, sessionGeneration),
1248
1272
  onInteractionPending: (pending) => {
1249
1273
  for (const listener of this.#pendingInteractionListeners)
1250
1274
  listener(pending);
@@ -1260,9 +1284,27 @@ class RuntimeHostMakaSessionDriverImpl {
1260
1284
  for (const listener of this.#goalListeners)
1261
1285
  listener(goal);
1262
1286
  },
1263
- onRecovered: () => this.#refreshRuntimeResources(sessionId),
1287
+ onRecovered: () => {
1288
+ this.#refreshRuntimeResources(sessionId);
1289
+ this.#publishTodoChanged(sessionId, sessionGeneration);
1290
+ },
1264
1291
  });
1265
1292
  }
1293
+ #publishSessionDomainChanged(frame, sessionId, sessionGeneration) {
1294
+ if (frame.domain !== 'todo' ||
1295
+ frame.sessionId !== sessionId ||
1296
+ this.#sessionId !== sessionId ||
1297
+ this.#sessionGeneration !== sessionGeneration) {
1298
+ return;
1299
+ }
1300
+ this.#publishTodoChanged(sessionId, sessionGeneration);
1301
+ }
1302
+ #publishTodoChanged(sessionId, sessionGeneration) {
1303
+ if (this.#sessionId !== sessionId || this.#sessionGeneration !== sessionGeneration)
1304
+ return;
1305
+ for (const listener of this.#todoChangeListeners)
1306
+ listener(sessionId);
1307
+ }
1266
1308
  #publishRuntimeResource(sourceSessionId, ref) {
1267
1309
  void this.#request('runtime.resource.query', {
1268
1310
  kind: 'get',
@@ -1369,12 +1411,6 @@ function workspaceTargetForCreate(current, input, location) {
1369
1411
  }
1370
1412
  return current.target;
1371
1413
  }
1372
- async function getRuntimeHostSession(connection, sessionId) {
1373
- const result = await connection.request('session.catalog.query', { kind: 'get', sessionId });
1374
- if (result.kind !== 'session')
1375
- throw new Error('Runtime Host returned an invalid Session lookup');
1376
- return result.session === null ? null : requireSession(result.session);
1377
- }
1378
1414
  function representableSession(item) {
1379
1415
  return 'kind' in item ? [] : [item];
1380
1416
  }
@@ -1426,11 +1462,6 @@ function visibleTranscriptMessages(messages, hiddenThroughTurnId) {
1426
1462
  }
1427
1463
  return boundary < 0 ? messages : messages.slice(boundary + 1);
1428
1464
  }
1429
- function requireSession(item) {
1430
- if (!('kind' in item))
1431
- return item;
1432
- throw new Error(`Runtime Host Session is not representable by this CLI: ${item.id}`);
1433
- }
1434
1465
  function inspectRuntimeHostSessionResumeAvailability(summary, location) {
1435
1466
  if (!summary.cwd) {
1436
1467
  return Promise.resolve({ available: false, reason: 'Missing working directory' });
@@ -1445,17 +1476,6 @@ async function assertSessionResumeAvailable(summary, location) {
1445
1476
  throw new Error(summary.cwd ? `Session cwd no longer exists: ${summary.cwd}` : availability.reason);
1446
1477
  }
1447
1478
  }
1448
- async function updateRuntimeHostSession(connection, sessionId, update) {
1449
- for (let attempt = 0; attempt < MAX_CATALOG_ATTEMPTS; attempt += 1) {
1450
- const current = await getRuntimeHostSession(connection, sessionId);
1451
- if (!current)
1452
- throw new Error(`Session not found: ${sessionId}`);
1453
- const result = await update(current);
1454
- if (result.kind === 'committed')
1455
- return requireSession(result.session);
1456
- }
1457
- throw new Error(`Session kept changing while updating: ${sessionId}`);
1458
- }
1459
1479
  async function loadCurrentMessages(connection, sessionId) {
1460
1480
  const subscription = await connection.openSessionSubscription({
1461
1481
  sessionId,
@@ -0,0 +1,62 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ const MAX_UPDATE_ATTEMPTS = 3;
20
+ export class RuntimeHostSessionUpdateError extends Error {
21
+ operation;
22
+ reason;
23
+ sessionId;
24
+ attempts;
25
+ name = 'RuntimeHostSessionUpdateError';
26
+ constructor(operation, reason, sessionId, attempts) {
27
+ super(`Runtime Host Session update failed for session ${sessionId}: ${reason}`);
28
+ this.operation = operation;
29
+ this.reason = reason;
30
+ this.sessionId = sessionId;
31
+ this.attempts = attempts;
32
+ }
33
+ }
34
+ export async function getRuntimeHostSession(connection, sessionId) {
35
+ const result = await connection.request('session.catalog.query', { kind: 'get', sessionId });
36
+ if (result.kind !== 'session') {
37
+ throw new RuntimeHostSessionUpdateError('session.catalog.query', 'invalid_projection', sessionId);
38
+ }
39
+ return result.session === null
40
+ ? null
41
+ : requireRuntimeHostSessionProjection(result.session, 'session.catalog.query');
42
+ }
43
+ export async function updateRuntimeHostSession(connection, sessionId, update, options) {
44
+ for (let attempt = 0; attempt < MAX_UPDATE_ATTEMPTS; attempt += 1) {
45
+ options.assertRequestAllowed?.();
46
+ const current = await getRuntimeHostSession(connection, sessionId);
47
+ if (!current) {
48
+ throw new RuntimeHostSessionUpdateError('session.catalog.query', 'not_found', sessionId);
49
+ }
50
+ options.assertRequestAllowed?.();
51
+ const result = await update(current);
52
+ if (result.kind === 'committed') {
53
+ return requireRuntimeHostSessionProjection(result.session, options.operation);
54
+ }
55
+ }
56
+ throw new RuntimeHostSessionUpdateError(options.operation, 'revision_conflict', sessionId, MAX_UPDATE_ATTEMPTS);
57
+ }
58
+ export function requireRuntimeHostSessionProjection(session, operation = 'session.catalog.query') {
59
+ if (!('kind' in session))
60
+ return session;
61
+ throw new RuntimeHostSessionUpdateError(operation, 'unsupported_session_projection', session.id);
62
+ }
@@ -17,21 +17,23 @@
17
17
  * under the License.
18
18
  */
19
19
  import { parseNoRealConnectionError } from '@maka/core/connection-error-copy';
20
- import { createInterface } from 'node:readline/promises';
21
20
  import { SessionActivityRegistry } from '@maka/runtime/goal-turn-lifecycle';
22
- import { readRuntimeHostConnectionCatalog } from '@maka/runtime-host/client';
21
+ import { readRuntimeHostConnectionCatalog, HostHandoffCancelledError, } from '@maka/runtime-host/client';
23
22
  import { runtimeHostProfileUsesHostWorkspace } from '@maka/runtime-host/profile-kind';
24
23
  import { createForeignSessionStore } from '@maka/storage/foreign-session-store';
25
24
  import { formatMakaResumeHint } from './cli-invocation.js';
26
- import { connectRuntimeHostCli, resolveRuntimeHostCliConflictDecision, RuntimeHostCliConflictError, } from './runtime-host-cli-context.js';
27
- import { resolveRuntimeHostNpmGlobalInstallation } from './runtime-host-cli-installation.js';
28
- import { restartRuntimeHostNpmGlobalDeployment } from './runtime-host-local-handoff.js';
25
+ import { connectRuntimeHostCli } from './runtime-host-cli-context.js';
26
+ import { createCliHostHandoffSurface } from './runtime-host-handoff-surface.js';
29
27
  import { createRuntimeHostOnboardingSurface } from './runtime-host-onboarding.js';
30
28
  import { runMakaPiTui } from './pi-tui-runner.js';
31
29
  import { createRuntimeHostTuiContext } from './runtime-host-tui-context.js';
30
+ import { describeTuiHost, prepareTuiHostOwnerAction } from './runtime-host-tui-owner.js';
31
+ import { getTuiHostOwnerCopy } from './tui-host-owner-copy.js';
32
32
  export async function runRuntimeHostTui(input) {
33
+ const ownerCopy = getTuiHostOwnerCopy(input.locale);
33
34
  const foreignSessions = createForeignSessionStore();
34
35
  const contextInput = {
36
+ ...(process.stdin.isTTY ? { handoffSurface: createCliHostHandoffSurface(input.locale) } : {}),
35
37
  clientDataRoot: input.clientDataRoot,
36
38
  rootPath: input.workspaceRoot,
37
39
  cwd: input.cwd,
@@ -41,11 +43,11 @@ export async function runRuntimeHostTui(input) {
41
43
  };
42
44
  let context;
43
45
  try {
44
- context = await createTuiContextWithHostConflictPrompt(contextInput);
45
- if (!context)
46
- return 1;
46
+ context = await createRuntimeHostTuiContext(contextInput);
47
47
  }
48
48
  catch (error) {
49
+ if (error instanceof HostHandoffCancelledError)
50
+ return 1;
49
51
  if (!isMissingDefaultConnection(error) || input.resumeSessionId)
50
52
  throw error;
51
53
  const configured = await runFirstRunOnboarding(input.clientDataRoot, input.workspaceRoot, input.cwd, input.locale, input.hostProfileId);
@@ -53,6 +55,8 @@ export async function runRuntimeHostTui(input) {
53
55
  throw error;
54
56
  context = await createRuntimeHostTuiContext(contextInput);
55
57
  }
58
+ let ownerAction;
59
+ let contextOpen = true;
56
60
  try {
57
61
  await runMakaPiTui({
58
62
  driver: context.driver,
@@ -79,6 +83,27 @@ export async function runRuntimeHostTui(input) {
79
83
  onboarding: context.onboarding,
80
84
  ...(context.mcp ? { mcp: context.mcp } : {}),
81
85
  recap: context.recap,
86
+ hostControl: {
87
+ status: () => describeTuiHost({ ...context, locale: input.locale }),
88
+ prepare: async (action, confirm) => {
89
+ if (ownerAction || !contextOpen)
90
+ throw new Error(ownerCopy.pending);
91
+ const execute = await prepareTuiHostOwnerAction({
92
+ profile: context.profile,
93
+ connection: context.connection,
94
+ rootPath: input.workspaceRoot,
95
+ locale: input.locale,
96
+ action,
97
+ confirm,
98
+ });
99
+ if (!execute)
100
+ return false;
101
+ if (!contextOpen || ownerAction)
102
+ throw new Error(ownerCopy.disconnected);
103
+ ownerAction = execute;
104
+ return true;
105
+ },
106
+ },
82
107
  ...(runtimeHostProfileUsesHostWorkspace(context.profile.kind)
83
108
  ? {
84
109
  sessionListScope: 'all',
@@ -103,82 +128,22 @@ export async function runRuntimeHostTui(input) {
103
128
  });
104
129
  if (hint)
105
130
  process.stdout.write(`${hint}\n`);
106
- return 0;
107
131
  }
108
132
  finally {
133
+ contextOpen = false;
109
134
  await context.driver.cleanupOwnedSideConversations().catch(() => undefined);
110
135
  await context.close();
111
136
  }
112
- }
113
- async function createTuiContextWithHostConflictPrompt(input) {
114
- const blockedRestartEpochs = new Set();
115
- while (true) {
116
- try {
117
- return await createRuntimeHostTuiContext(input);
118
- }
119
- catch (error) {
120
- if (!(error instanceof RuntimeHostCliConflictError) || !process.stdin.isTTY)
121
- throw error;
122
- process.stderr.write(`${error.message}\n`);
123
- const canRestart = error.registration.lifecycleMode === 'ephemeral' &&
124
- !blockedRestartEpochs.has(error.registration.hostEpoch) &&
125
- (await isPersistentNpmGlobalCli());
126
- const readline = createInterface({ input: process.stdin, output: process.stderr });
127
- let decision;
128
- try {
129
- const answer = await readline.question(canRestart
130
- ? 'Restart this local Host if it is idle, wait for it to exit, or cancel? [r/w/C] '
131
- : 'Wait only if the existing Host is expected to exit, or cancel? [w/C] ');
132
- decision = resolveRuntimeHostCliConflictDecision(answer, canRestart);
133
- }
134
- finally {
135
- readline.close();
136
- }
137
- if (decision === 'cancel')
138
- return null;
139
- if (decision === 'restart') {
140
- const result = await restartRuntimeHostNpmGlobalDeployment({
141
- rootPath: input.rootPath,
142
- registration: error.registration,
143
- });
144
- if (result.kind === 'completed')
145
- continue;
146
- if (result.kind === 'active_work') {
147
- blockedRestartEpochs.add(error.registration.hostEpoch);
148
- process.stderr.write('The existing Runtime Host still owns active or durable work and was not interrupted.\n');
149
- continue;
150
- }
151
- if (result.kind === 'operator_required') {
152
- blockedRestartEpochs.add(error.registration.hostEpoch);
153
- continue;
154
- }
155
- if (result.kind === 'rejected')
156
- continue;
157
- throw new Error(`Local Runtime Host restart requires recovery at ${result.phase}`, {
158
- cause: result.cause,
159
- });
160
- }
161
- await waitForHostRetry();
162
- }
163
- }
164
- }
165
- async function isPersistentNpmGlobalCli() {
166
- try {
167
- await resolveRuntimeHostNpmGlobalInstallation();
168
- return true;
169
- }
170
- catch {
171
- return false;
172
- }
173
- }
174
- function waitForHostRetry() {
175
- return new Promise((resolve) => setTimeout(resolve, 2_000));
137
+ // No reconnecting client remains to respawn a stopped Host, and an updater
138
+ // can use the restored terminal without competing with the TUI renderer.
139
+ return ownerAction ? ownerAction() : 0;
176
140
  }
177
141
  async function runFirstRunOnboarding(clientDataRoot, rootPath, cwd, locale, hostProfileId) {
178
142
  const connected = await connectRuntimeHostCli({
179
143
  clientDataRoot,
180
144
  rootPath,
181
145
  interactiveSsh: true,
146
+ ...(process.stdin.isTTY ? { handoffSurface: createCliHostHandoffSurface(locale) } : {}),
182
147
  ...(hostProfileId ? { profileId: hostProfileId } : {}),
183
148
  });
184
149
  try {
@@ -34,6 +34,7 @@ export async function createRuntimeHostTuiContext(input) {
34
34
  clientDataRoot: input.clientDataRoot,
35
35
  rootPath: input.rootPath,
36
36
  interactiveSsh: true,
37
+ ...(input.handoffSurface ? { handoffSurface: input.handoffSurface } : {}),
37
38
  ...(input.hostProfileId ? { profileId: input.hostProfileId } : {}),
38
39
  });
39
40
  const connection = connected.connection;
@@ -0,0 +1,226 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+ import { randomUUID } from 'node:crypto';
20
+ import { isDeepStrictEqual } from 'node:util';
21
+ import { formatUiMessage } from '@maka/core/ui-locale';
22
+ import { connectExistingRuntimeHost, } from '@maka/runtime-host/client';
23
+ import { readLocalHostDeploymentRecord, resolveRuntimeHostManagedDeploymentAuthority, withLocalHostDeploymentAuthority, } from '@maka/runtime-host/operator';
24
+ import { isProductReleaseVersion } from '@maka/runtime-host/operator/update-package-evidence';
25
+ import { INTERACTIVE_RUNTIME_HOST_COMPOSITION_ID, RUNTIME_HOST_PROTOCOL_VERSION, } from '@maka/runtime-host/protocol';
26
+ import { resolveRuntimeHostNpmGlobalInstallation } from './runtime-host-cli-installation.js';
27
+ import { runRuntimeHostInstalledUpdateBootstrap } from './runtime-host-installed-update-bootstrap.js';
28
+ import { retireRuntimeHostLifecycleOwner } from './runtime-host-lifecycle-transaction.js';
29
+ import { openRuntimeHostNpmGlobalStagedDeployment } from './runtime-host-local-handoff.js';
30
+ import { launchRuntimeHostTargetActivator } from './runtime-host-local-target-activation.js';
31
+ import { getTuiHostOwnerCopy } from './tui-host-owner-copy.js';
32
+ /** A thin owner adapter. The caller disconnects its reconnecting client before execute. */
33
+ export async function prepareTuiHostOwnerAction(input, overrides = {}) {
34
+ const locale = input.locale ?? 'en';
35
+ const copy = getTuiHostOwnerCopy(locale);
36
+ if (input.profile.kind !== 'local') {
37
+ throw new Error(copy.foreign);
38
+ }
39
+ const deps = {
40
+ resolveInstallation: resolveRuntimeHostNpmGlobalInstallation,
41
+ readRecord: readLocalHostDeploymentRecord,
42
+ resolveManagedAuthority: resolveRuntimeHostManagedDeploymentAuthority,
43
+ connectExisting: connectExistingRuntimeHost,
44
+ withAuthority: withLocalHostDeploymentAuthority,
45
+ retire: retireRuntimeHostLifecycleOwner,
46
+ openStaged: openRuntimeHostNpmGlobalStagedDeployment,
47
+ activate: launchRuntimeHostTargetActivator,
48
+ update: runRuntimeHostInstalledUpdateBootstrap,
49
+ ...overrides,
50
+ };
51
+ const installation = await deps.resolveInstallation();
52
+ const rootId = input.connection.rootId;
53
+ const hostEpoch = input.connection.hostEpoch;
54
+ if (await deps.resolveManagedAuthority(rootId))
55
+ throw new Error(copy.notOwner);
56
+ const record = await deps.readRecord(rootId);
57
+ if (record?.state.kind !== 'owned' ||
58
+ record.state.owner.kind !== 'cli' ||
59
+ record.state.owner.installationId !== installation.owner.installationId) {
60
+ throw new Error(copy.notOwner);
61
+ }
62
+ const observed = await deps.connectExisting({
63
+ rootPath: input.rootPath,
64
+ protocol: { min: RUNTIME_HOST_PROTOCOL_VERSION, max: RUNTIME_HOST_PROTOCOL_VERSION },
65
+ compositionId: INTERACTIVE_RUNTIME_HOST_COMPOSITION_ID,
66
+ });
67
+ try {
68
+ if (observed.kind !== 'connected' ||
69
+ observed.registration.rootId !== rootId ||
70
+ observed.registration.hostEpoch !== hostEpoch ||
71
+ observed.registration.lifecycleMode !== 'ephemeral') {
72
+ throw new Error(copy.hostChanged);
73
+ }
74
+ }
75
+ finally {
76
+ if (observed.kind === 'connected')
77
+ await observed.connection.close();
78
+ }
79
+ const diagnostics = await input.connection
80
+ .request('host.diagnostics.query', {})
81
+ .catch(() => undefined);
82
+ const fingerprint = activityFingerprint(diagnostics);
83
+ let allowInterruptActiveTasks = false;
84
+ if (!diagnostics || diagnostics.upgradeBlockingActivity) {
85
+ const choice = await input.confirm([
86
+ formatUiMessage(copy.actionSummary, { action: copy[`action_${input.action.action}`], name: input.profile.name }, locale),
87
+ formatUiMessage(copy.owner, { owner: installation.owner.installationId }, locale),
88
+ formatUiMessage(copy.root, { root: rootId }, locale),
89
+ formatUiMessage(copy.epoch, { epoch: hostEpoch }, locale),
90
+ diagnostics
91
+ ? formatUiMessage(copy.activity, {
92
+ connections: diagnostics.connections,
93
+ operations: diagnostics.activeOperations,
94
+ residencies: JSON.stringify(diagnostics.residencies),
95
+ }, locale)
96
+ : copy.unknownActivity,
97
+ input.action.action === 'update' ? copy.updateSafeOnly : '',
98
+ ]
99
+ .filter(Boolean)
100
+ .join('\n'));
101
+ if (choice === 'cancel')
102
+ return undefined;
103
+ allowInterruptActiveTasks = choice === 'interrupt';
104
+ }
105
+ const target = input.action.target ?? 'latest';
106
+ if (input.action.action === 'update' &&
107
+ target !== 'latest' &&
108
+ target !== 'next' &&
109
+ !isProductReleaseVersion(target))
110
+ throw new Error(copy.invalidTarget);
111
+ if (input.action.action === 'update' && allowInterruptActiveTasks) {
112
+ throw new Error(copy.updateRequiresSafe);
113
+ }
114
+ return async () => {
115
+ if (!isDeepStrictEqual(await deps.resolveInstallation(), installation)) {
116
+ throw new Error(copy.installationChanged);
117
+ }
118
+ if (input.action.action === 'update') {
119
+ if (await deps.resolveManagedAuthority(rootId))
120
+ throw new Error(copy.notOwner);
121
+ return deps.update({
122
+ rootPath: input.rootPath,
123
+ selector: target === 'latest' || target === 'next'
124
+ ? { kind: 'channel', channel: target }
125
+ : { kind: 'exact', version: target },
126
+ allowInterruptActiveTasks: false,
127
+ expectedSource: {
128
+ rootId,
129
+ deploymentRevision: record.revision,
130
+ ownerInstallationId: installation.owner.installationId,
131
+ hostEpoch,
132
+ },
133
+ });
134
+ }
135
+ return deps.withAuthority(rootId, async (authority, inheritableAuthorityLeaseFd) => {
136
+ if (!isDeepStrictEqual(await authority.read(), record)) {
137
+ throw new Error(copy.ownerChanged);
138
+ }
139
+ // Same-artifact restart is a process lifecycle operation, not an update.
140
+ // Open the already verified selected package; never restage/reinstall it.
141
+ const staged = input.action.action === 'restart'
142
+ ? await deps.openStaged({
143
+ rootId,
144
+ owner: installation.owner,
145
+ target: record.state.selected,
146
+ transactionId: `tui-restart:${randomUUID()}`,
147
+ })
148
+ : undefined;
149
+ if (await deps.resolveManagedAuthority(rootId))
150
+ throw new Error(copy.notOwner);
151
+ const retired = await deps.retire({
152
+ rootPath: input.rootPath,
153
+ rootId,
154
+ allowInterruptActiveTasks,
155
+ connectExisting: async (request) => {
156
+ const current = await deps.connectExisting(request);
157
+ if (current.kind !== 'connected' ||
158
+ current.registration.rootId !== rootId ||
159
+ current.registration.hostEpoch !== hostEpoch ||
160
+ current.registration.lifecycleMode !== 'ephemeral') {
161
+ if (current.kind === 'connected')
162
+ await current.connection.close();
163
+ throw new Error(copy.retirementHostChanged);
164
+ }
165
+ const currentDiagnostics = await current.connection
166
+ .request('host.diagnostics.query', {})
167
+ .catch(() => undefined);
168
+ if (allowInterruptActiveTasks &&
169
+ activityFingerprint(currentDiagnostics) !== fingerprint) {
170
+ await current.connection.close();
171
+ throw new Error(copy.activityChanged);
172
+ }
173
+ return current;
174
+ },
175
+ });
176
+ if (retired.kind === 'active_tasks') {
177
+ throw new Error(formatUiMessage(copy.stillActive, { action: input.action.action }, locale));
178
+ }
179
+ await retired.owner.close();
180
+ if (staged) {
181
+ const activated = await deps.activate({
182
+ rootPath: input.rootPath,
183
+ rootId,
184
+ staged,
185
+ ownerInstallationId: installation.owner.installationId,
186
+ target: record.state.selected,
187
+ inheritableAuthorityLeaseFd,
188
+ });
189
+ if (activated.kind !== 'ready')
190
+ throw new Error(formatUiMessage(copy.restartFailed, { detail: activated.kind }, locale));
191
+ await activated.settle();
192
+ }
193
+ return 0;
194
+ });
195
+ };
196
+ }
197
+ function activityFingerprint(diagnostics) {
198
+ if (!diagnostics)
199
+ return 'unknown';
200
+ return JSON.stringify([
201
+ diagnostics.hostEpoch,
202
+ diagnostics.pid,
203
+ diagnostics.state,
204
+ diagnostics.connections,
205
+ diagnostics.activeOperations,
206
+ diagnostics.residencies,
207
+ diagnostics.upgradeBlockingActivity,
208
+ ]);
209
+ }
210
+ export async function describeTuiHost(input) {
211
+ const locale = input.locale ?? 'en';
212
+ const copy = getTuiHostOwnerCopy(locale);
213
+ const status = await input.connection.status();
214
+ return [
215
+ formatUiMessage(copy.status, { name: input.profile.name, state: copy[`state_${status.state}`] }, locale),
216
+ formatUiMessage(copy.root, { root: input.connection.rootId }, locale),
217
+ formatUiMessage(copy.epoch, { epoch: status.hostEpoch }, locale),
218
+ formatUiMessage(copy.composition, { composition: status.compositionId, revision: status.compositionRevision }, locale),
219
+ formatUiMessage(copy.activity, {
220
+ connections: status.connections,
221
+ operations: status.activeOperations,
222
+ residencies: status.activeResidencies,
223
+ }, locale),
224
+ input.profile.kind === 'local' ? copy.localOwnerHint : copy.attachedOwnerHint,
225
+ ].join('\n');
226
+ }