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
package/README.md CHANGED
@@ -24,7 +24,8 @@
24
24
  [简体中文](https://github.com/apache/maka/blob/main/packages/cli/README.zh-CN.md)
25
25
 
26
26
  Maka is a local-first agent workspace. The `maka-agent` npm package installs the interactive
27
- terminal UI, the non-interactive CLI, Runtime Host tooling, and the Eval command.
27
+ terminal UI, the non-interactive CLI, Runtime Host tooling, and the Eval command. That package is
28
+ published under the `nightly` dist-tag; `latest` holds an early alpha stub (see [Install](#install)).
28
29
 
29
30
  ## Apache Incubation Disclaimer
30
31
 
@@ -79,16 +80,24 @@ release gate. Real Eval executor validation currently runs on Linux x64 with Nod
79
80
 
80
81
  ## Install
81
82
 
82
- Install the current beta explicitly from the `next` dist-tag:
83
+ Two dist-tags are live on npm, and they are not interchangeable:
83
84
 
84
- ```sh
85
- npm install --global maka-agent@next
86
- maka --version
87
- maka --help
88
- ```
85
+ - `nightly` carries the complete CLI. The line moves daily — resolve the tag (or query its
86
+ current version) instead of copying a version number from any document:
87
+
88
+ ```sh
89
+ npm install --global maka-agent@nightly
90
+ maka --version
91
+ maka --help
92
+ ```
93
+
94
+ - `latest` points at an early alpha (`0.0.0-alpha.0`) whose command surface is limited to
95
+ `doctor`, help, and version. Because of that split, do not use a bare
96
+ `npm update --global maka-agent`: it follows `latest` and may switch the installation to the
97
+ other release line.
89
98
 
90
99
  The public command is `maka`. For a one-off invocation, use
91
- `npx --yes --package maka-agent@next maka`; the unrelated `maka` package on npm is not this project.
100
+ `npx --yes --package maka-agent@nightly maka`; the unrelated `maka` package on npm is not this project.
92
101
  `runtime-host service install` uses the persistent global installation above; `runtime-host setup`
93
102
  creates its own managed copy from the exact package invoked by `npx`.
94
103
 
@@ -124,26 +133,31 @@ modify.
124
133
 
125
134
  ## Upgrade
126
135
 
127
- While using prereleases, keep the `next` tag explicit:
136
+ Update within the nightly line by pinning the exact release (`--target` accepts `latest`,
137
+ `next`, or an exact Maka version — there is no `nightly` channel name). Resolve the current
138
+ nightly version first and pass that exact value: the updater refuses downgrades, so a copied
139
+ version number goes stale as soon as the nightly line moves on.
128
140
 
129
141
  ```sh
130
- maka update --target next
142
+ version="$(npm view maka-agent@nightly version --registry=https://registry.npmjs.org)"
143
+ maka update --target "$version"
131
144
  maka --version
132
145
  ```
133
146
 
147
+ Do not use a bare `npm update --global maka-agent` to upgrade: it follows `latest`, which holds
148
+ the early alpha stub, and may switch the installation to the other release line.
149
+
134
150
  The update stages and verifies the exact release before replacing the local Runtime Host or the
135
151
  npm-global package. It refuses to interrupt active or durable work by default. Use
136
152
  `--allow-interrupt-active-tasks` only after deciding that interruption is safe. A direct
137
- `npm install --global maka-agent@next` remains available for installation repair; do not use a bare
138
- `npm update --global maka-agent`, because it follows `latest` and may select a different release
139
- line. After a stable release is available, select it with `maka update --target latest`.
153
+ `npm install --global maka-agent@nightly` remains available for installation repair.
140
154
 
141
155
  ## Remote Runtime Host setup
142
156
 
143
157
  To set up a persistent remote Runtime Host from an exact released package on Linux or macOS:
144
158
 
145
159
  ```sh
146
- npx --yes --package maka-agent@next maka runtime-host setup \
160
+ npx --yes --package maka-agent@nightly maka runtime-host setup \
147
161
  --principal my-client \
148
162
  --preset terminal-client
149
163
  ```
@@ -151,10 +165,12 @@ npx --yes --package maka-agent@next maka runtime-host setup \
151
165
  Rerunning setup replaces that Client credential. The service no longer depends on the temporary
152
166
  `npx` cache after setup succeeds.
153
167
 
154
- Check a managed service against a release channel without changing the running Host:
168
+ Check a managed service against the nightly release it should track, without changing the
169
+ running Host — pass the exact version resolved above rather than `latest`, which holds the
170
+ early alpha:
155
171
 
156
172
  ```sh
157
- maka runtime-host service check-update --target next --json
173
+ maka runtime-host service check-update --target "$version" --json
158
174
  ```
159
175
 
160
176
  The result pins the selected channel to an exact version and package integrity. It also reports
@@ -165,10 +181,13 @@ to the existing exact-package update transaction, and does not mutate a candidat
165
181
  manual review.
166
182
 
167
183
  The installation owner can persist one update target and reconcile it with the same verified
168
- transaction:
184
+ transaction. Pin the exact nightly version resolved above: there is no `nightly` target name,
185
+ and `latest` holds the early alpha, which the reconciliation assesses as a downgrade for a
186
+ nightly installation. Following successive nightlies therefore means resolving the current
187
+ version again and re-running `update-policy` with the fresh value:
169
188
 
170
189
  ```sh
171
- maka runtime-host service update-policy --target latest \
190
+ maka runtime-host service update-policy --target "$version" \
172
191
  --expected-service-id <service-id> \
173
192
  --expected-root-path <state-root> \
174
193
  --expected-root-id <root-id>
@@ -182,7 +201,7 @@ bounded one-shot command: it never interrupts active work and does not install a
182
201
 
183
202
  ```sh
184
203
  # When a managed Runtime Host service was installed on Linux or macOS
185
- npx --yes --package maka-agent@next maka runtime-host service uninstall
204
+ npx --yes --package maka-agent@nightly maka runtime-host service uninstall
186
205
 
187
206
  # If Maka was installed globally
188
207
  npm uninstall --global maka-agent
package/README.zh-CN.md CHANGED
@@ -24,7 +24,8 @@
24
24
  [English](./README.md)
25
25
 
26
26
  Maka 是一个本地优先的 Agent 工作空间。`maka-agent` npm 包包含交互式终端界面、非交互
27
- CLI、Runtime Host 工具和 Eval 命令。
27
+ CLI、Runtime Host 工具和 Eval 命令。该包发布在 `nightly` dist-tag 上;`latest` 指向一个
28
+ 早期 alpha stub(见[安装](#安装))。
28
29
 
29
30
  ## Apache 孵化免责声明
30
31
 
@@ -57,15 +58,21 @@ release commit 中的 [DISCLAIMER-WIP](https://github.com/apache/maka/blob/main/
57
58
 
58
59
  ## 安装
59
60
 
60
- Beta 阶段请明确从 `next` dist-tag 安装:
61
+ npm 上有两条 dist-tag,且二者不可互换:
61
62
 
62
- ```sh
63
- npm install --global maka-agent@next
64
- maka --version
65
- maka --help
66
- ```
63
+ - `nightly` 承载完整的 CLI。该发布线每日推进——请解析 tag 本身(或查询其当前版本),不要誊写任何文档里的版本号:
67
64
 
68
- 公开命令只有 `maka`。一次性运行请使用 `npx --yes --package maka-agent@next maka`;npm 上与本项目
65
+ ```sh
66
+ npm install --global maka-agent@nightly
67
+ maka --version
68
+ maka --help
69
+ ```
70
+
71
+ - `latest` 指向一个早期 alpha(`0.0.0-alpha.0`),命令面只有 `doctor`、帮助与版本命令。
72
+ 因此不要使用裸的 `npm update --global maka-agent`:它跟随 `latest`,可能把安装切换到
73
+ 另一条发布线。
74
+
75
+ 公开命令只有 `maka`。一次性运行请使用 `npx --yes --package maka-agent@nightly maka`;npm 上与本项目
69
76
  无关的 `maka` 包不是本项目。`runtime-host service install` 使用上面的持久全局安装;
70
77
  `runtime-host setup` 会从 `npx` 调用的精确 package 创建自己的托管副本。
71
78
 
@@ -98,35 +105,40 @@ Maka 默认会在执行高权限工具操作前询问。`maka run --yolo` 会授
98
105
 
99
106
  ## 升级
100
107
 
101
- 使用预发布版本时,请继续明确指定 `next`:
108
+ nightly 线内更新时固定精确版本(`--target` 只接受 `latest`、`next` 或精确的 Maka
109
+ 版本号——不存在 `nightly` 这个 channel 名)。先解析当前 nightly 版本再传入精确值:
110
+ updater 拒绝降级,nightly 前进之后誊写的旧版本号会被直接拒绝。
102
111
 
103
112
  ```sh
104
- maka update --target next
113
+ version="$(npm view maka-agent@nightly version --registry=https://registry.npmjs.org)"
114
+ maka update --target "$version"
105
115
  maka --version
106
116
  ```
107
117
 
118
+ 不要使用裸的 `npm update --global maka-agent` 来升级:它跟随 `latest`(早期 alpha stub),
119
+ 可能把安装切换到另一条发布线。
120
+
108
121
  更新流程会先 stage 并验证精确 release,再替换本地 Runtime Host 与 npm-global package;
109
122
  默认不会中断 active 或 durable work。只有在你确认可以安全中断后,才使用
110
- `--allow-interrupt-active-tasks`。`npm install --global maka-agent@next` 仍可用于修复安装;
111
- 不要使用不带 tag 的 `npm update --global maka-agent`,因为它会跟随 `latest`,可能选中
112
- 不同的发布线。稳定版发布后,使用 `maka update --target latest`。
123
+ `--allow-interrupt-active-tasks`。`npm install --global maka-agent@nightly` 仍可用于修复安装。
113
124
 
114
125
  ## 设置远程 Runtime Host
115
126
 
116
127
  在 Linux 或 macOS 上从精确的发布 package 设置持久 remote Runtime Host:
117
128
 
118
129
  ```sh
119
- npx --yes --package maka-agent@next maka runtime-host setup \
130
+ npx --yes --package maka-agent@nightly maka runtime-host setup \
120
131
  --principal my-client \
121
132
  --preset terminal-client
122
133
  ```
123
134
 
124
135
  重复设置会替换该 Client credential。设置成功后,service 不再依赖临时 `npx` cache。
125
136
 
126
- 可以在不改变当前 Host 的情况下检查 managed service 对应的发布频道:
137
+ 检查 managed service 应跟随的 nightly 发布,且不改变当前运行中的 Host——传入上面解析出的
138
+ 精确版本,而不是指向早期 alpha 的 `latest`:
127
139
 
128
140
  ```sh
129
- maka runtime-host service check-update --target next --json
141
+ maka runtime-host service check-update --target "$version" --json
130
142
  ```
131
143
 
132
144
  结果会把频道固定为精确版本和 package integrity,并说明 package 是否提供足够的兼容性证据,
@@ -134,10 +146,13 @@ maka runtime-host service check-update --target next --json
134
146
  selector 传给 `service update --target`。该路径会先校验 archive 与解包后的 manifest,再委托给
135
147
  现有的精确 package 更新事务;需要人工审查的候选不会改变当前 Host。
136
148
 
137
- Installation owner 可以持久化一个更新目标,并通过同一套已验证事务执行 reconciliation
149
+ Installation owner 可以持久化一个更新目标,并通过同一套已验证事务执行 reconciliation。持久化
150
+ 上面解析出的精确 nightly 版本:不存在 `nightly` 这个 target 名,而 `latest` 指向早期 alpha,
151
+ reconciliation 会把对一个 nightly 安装而言更旧的候选判为降级。因此要跟随每日推进的 nightly,
152
+ 就需要重新解析当前版本,并用新值再次运行 `update-policy`:
138
153
 
139
154
  ```sh
140
- maka runtime-host service update-policy --target latest \
155
+ maka runtime-host service update-policy --target "$version" \
141
156
  --expected-service-id <service-id> \
142
157
  --expected-root-path <state-root> \
143
158
  --expected-root-id <root-id>
@@ -151,7 +166,7 @@ maka runtime-host service reconcile-update --json
151
166
 
152
167
  ```sh
153
168
  # 仅限安装过 managed Runtime Host service 的 Linux 或 macOS
154
- npx --yes --package maka-agent@next maka runtime-host service uninstall
169
+ npx --yes --package maka-agent@nightly maka runtime-host service uninstall
155
170
 
156
171
  # 如果曾全局安装 Maka
157
172
  npm uninstall --global maka-agent
@@ -26,5 +26,6 @@ export function createMakaAcpAgent(options) {
26
26
  agentInfo: { name: 'maka', title: 'Maka', version: options.version },
27
27
  }))
28
28
  .onRequest(methods.agent.session.new, ({ params }) => options.sessionRegistry.create(params))
29
- .onRequest(methods.agent.session.list, ({ params }) => options.sessionRegistry.list(params));
29
+ .onRequest(methods.agent.session.list, ({ params }) => options.sessionRegistry.list(params))
30
+ .onRequest(methods.agent.session.setConfigOption, ({ params }) => options.sessionRegistry.setConfigOption(params));
30
31
  }
@@ -0,0 +1,143 @@
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 { COLLABORATION_MODES } from '@maka/core/collaboration';
20
+ import { THINKING_LEVELS } from '@maka/core/model-thinking';
21
+ import { ORCHESTRATION_MODES } from '@maka/core/orchestration';
22
+ import { CHAT_DEFAULT_PERMISSION_MODES } from '@maka/core/settings';
23
+ const PERMISSION_NAMES = {
24
+ explore: 'Explore',
25
+ ask: 'Ask',
26
+ bypass: 'Bypass',
27
+ };
28
+ const THINKING_NAMES = {
29
+ default: 'Default',
30
+ off: 'Off',
31
+ minimal: 'Minimal',
32
+ low: 'Low',
33
+ medium: 'Medium',
34
+ high: 'High',
35
+ xhigh: 'Extra high',
36
+ max: 'Max',
37
+ };
38
+ const COLLABORATION_NAMES = {
39
+ agent: 'Agent',
40
+ plan: 'Plan',
41
+ };
42
+ const ORCHESTRATION_NAMES = {
43
+ default: 'Default',
44
+ swarm: 'Swarm',
45
+ graph: 'Graph',
46
+ };
47
+ const PERMISSION_SPEC = {
48
+ id: 'permission_mode',
49
+ name: 'Permission mode',
50
+ category: '_maka/permission_mode',
51
+ options: namedOptions(CHAT_DEFAULT_PERMISSION_MODES, PERMISSION_NAMES),
52
+ };
53
+ const THINKING_SPEC = {
54
+ id: 'thinking_level',
55
+ name: 'Thinking level',
56
+ category: 'thought_level',
57
+ options: namedOptions(['default', ...THINKING_LEVELS], THINKING_NAMES),
58
+ };
59
+ const COLLABORATION_SPEC = {
60
+ id: 'collaboration_mode',
61
+ name: 'Collaboration mode',
62
+ category: 'mode',
63
+ options: namedOptions(COLLABORATION_MODES, COLLABORATION_NAMES),
64
+ };
65
+ const ORCHESTRATION_SPEC = {
66
+ id: 'orchestration_mode',
67
+ name: 'Orchestration mode',
68
+ category: '_maka/orchestration_mode',
69
+ options: namedOptions(ORCHESTRATION_MODES, ORCHESTRATION_NAMES),
70
+ };
71
+ const CONFIG_SPECS = [
72
+ PERMISSION_SPEC,
73
+ THINKING_SPEC,
74
+ COLLABORATION_SPEC,
75
+ ORCHESTRATION_SPEC,
76
+ ];
77
+ export function projectAcpSessionConfigOptions(session, thinkingLevels) {
78
+ return [
79
+ configOption(PERMISSION_SPEC, session.permissionMode),
80
+ ...(thinkingLevels.length === 0
81
+ ? []
82
+ : [
83
+ configOption({
84
+ ...THINKING_SPEC,
85
+ options: namedOptions(['default', ...thinkingLevels], THINKING_NAMES),
86
+ }, session.thinkingLevel ?? 'default'),
87
+ ]),
88
+ configOption(COLLABORATION_SPEC, session.collaborationMode),
89
+ configOption(ORCHESTRATION_SPEC, session.orchestrationMode),
90
+ ];
91
+ }
92
+ function namedOptions(values, names) {
93
+ return values.map((value) => [value, names[value]]);
94
+ }
95
+ function configOption(spec, currentValue) {
96
+ return {
97
+ type: 'select',
98
+ id: spec.id,
99
+ name: spec.name,
100
+ category: spec.category,
101
+ currentValue,
102
+ options: spec.options.map(([value, name]) => ({ value, name })),
103
+ };
104
+ }
105
+ export class AcpSessionConfigInputError extends Error {
106
+ field;
107
+ reason;
108
+ name = 'AcpSessionConfigInputError';
109
+ constructor(field, reason) {
110
+ super(`Invalid ACP Session configuration ${field}`);
111
+ this.field = field;
112
+ this.reason = reason;
113
+ }
114
+ }
115
+ export function validateAcpSessionConfigOptionRequest(request) {
116
+ const spec = CONFIG_SPECS.find(({ id }) => id === request.configId);
117
+ if (!spec)
118
+ throw new AcpSessionConfigInputError('configId', 'unsupported');
119
+ if (typeof request.value !== 'string')
120
+ throw new AcpSessionConfigInputError('value', 'invalid_type');
121
+ if (!spec.options.some(([value]) => value === request.value)) {
122
+ throw new AcpSessionConfigInputError('value', 'unsupported');
123
+ }
124
+ }
125
+ export function createAcpSessionConfigPatch(request) {
126
+ validateAcpSessionConfigOptionRequest(request);
127
+ switch (request.configId) {
128
+ case 'permission_mode':
129
+ return { permissionMode: request.value };
130
+ case 'thinking_level':
131
+ return {
132
+ thinkingLevel: request.value === 'default'
133
+ ? null
134
+ : request.value,
135
+ };
136
+ case 'collaboration_mode':
137
+ return { collaborationMode: request.value };
138
+ case 'orchestration_mode':
139
+ return { orchestrationMode: request.value };
140
+ default:
141
+ throw new AcpSessionConfigInputError('configId', 'unsupported');
142
+ }
143
+ }
@@ -20,14 +20,17 @@ import { randomUUID } from 'node:crypto';
20
20
  import { realpath } from 'node:fs/promises';
21
21
  import { isAbsolute, normalize } from 'node:path';
22
22
  import { RequestError, } from '@agentclientprotocol/sdk';
23
- import { readRuntimeHostSessionCatalogPage, RuntimeHostCatalogReadError, RuntimeHostOperationError, RuntimeHostRequestInterruptedError, RuntimeHostSessionCatalogRevisionChangedError, } from '@maka/runtime-host/client';
23
+ import { readRuntimeHostConnectionCatalog, readRuntimeHostSessionCatalogPage, RuntimeHostCatalogReadError, RuntimeHostOperationError, RuntimeHostRequestInterruptedError, RuntimeHostSessionCatalogRevisionChangedError, } from '@maka/runtime-host/client';
24
24
  import { SESSION_CATALOG_CURSOR_MAX_BYTES, SESSION_CATALOG_CWD_MAX_BYTES, } from '@maka/runtime-host/protocol';
25
+ import { RuntimeHostSessionUpdateError, requireRuntimeHostSessionProjection, updateRuntimeHostSession, } from '../runtime-host-session-update.js';
26
+ import { AcpSessionConfigInputError, createAcpSessionConfigPatch, projectAcpSessionConfigOptions, validateAcpSessionConfigOptionRequest, } from './session-configuration.js';
25
27
  const ACP_SESSION_CURSOR_MAX_BYTES = 8 * 1024;
26
28
  /** Owns all Runtime Host resources associated with one ACP connection. */
27
29
  export class AcpSessionRegistry {
28
30
  #connect;
29
31
  #newSessionId;
30
32
  #inFlightOperations = new Set();
33
+ #ownedSessionIds = new Set();
31
34
  #connection;
32
35
  #connectTask;
33
36
  #connectAbortController;
@@ -47,6 +50,19 @@ export class AcpSessionRegistry {
47
50
  this.#assertOpen('session.catalog.query');
48
51
  return this.#track(this.#list(params));
49
52
  }
53
+ async setConfigOption(params) {
54
+ this.#assertOpen('session.configuration.update');
55
+ if (!this.#ownedSessionIds.has(params.sessionId)) {
56
+ throw RequestError.invalidParams({ reason: 'unknown_session' }, 'Session is not owned by this ACP connection');
57
+ }
58
+ try {
59
+ validateAcpSessionConfigOptionRequest(params);
60
+ }
61
+ catch (error) {
62
+ throw requestErrorFromConfigInput(error);
63
+ }
64
+ return this.#track(this.#setConfigOption(params));
65
+ }
50
66
  dispose() {
51
67
  this.#closing = true;
52
68
  this.#connectAbortController?.abort();
@@ -56,8 +72,9 @@ export class AcpSessionRegistry {
56
72
  async #create(params) {
57
73
  const connection = await this.#getConnection('session.create');
58
74
  const sessionId = this.#newSessionId();
75
+ let result;
59
76
  try {
60
- await connection.request('session.create', {
77
+ result = await connection.request('session.create', {
61
78
  sessionId,
62
79
  workspace: { kind: 'host_path', path: params.cwd },
63
80
  modelTarget: { kind: 'default' },
@@ -66,7 +83,46 @@ export class AcpSessionRegistry {
66
83
  catch (error) {
67
84
  throw requestErrorFromRuntimeHost(error, 'session.create', { sessionId });
68
85
  }
69
- return { sessionId };
86
+ let created;
87
+ try {
88
+ created = requireRuntimeHostSessionProjection(result, 'session.create');
89
+ }
90
+ catch (error) {
91
+ throw requestErrorFromSessionUpdate(error, 'session.create', { sessionId });
92
+ }
93
+ const configOptions = await this.#projectConfigOptions(connection, created);
94
+ this.#ownedSessionIds.add(sessionId);
95
+ return { sessionId, configOptions };
96
+ }
97
+ async #setConfigOption(params) {
98
+ const connection = await this.#getConnection('session.configuration.update');
99
+ let committed;
100
+ try {
101
+ committed = await updateRuntimeHostSession(connection, params.sessionId, (current) => connection.request('session.configuration.update', {
102
+ sessionId: params.sessionId,
103
+ expectedRevision: current.revision,
104
+ patch: createAcpSessionConfigPatch(params),
105
+ }), {
106
+ operation: 'session.configuration.update',
107
+ assertRequestAllowed: () => this.#assertOpen('session.configuration.update'),
108
+ });
109
+ }
110
+ catch (error) {
111
+ throw requestErrorFromSessionUpdate(error, 'session.configuration.update');
112
+ }
113
+ return { configOptions: await this.#projectConfigOptions(connection, committed) };
114
+ }
115
+ async #projectConfigOptions(connection, session) {
116
+ let catalog;
117
+ try {
118
+ catalog = await readRuntimeHostConnectionCatalog(connection);
119
+ }
120
+ catch (error) {
121
+ throw requestErrorFromRuntimeHost(error, 'connection.catalog.query');
122
+ }
123
+ const selectedConnection = catalog.connections.find(({ connectionId }) => connectionId === session.llmConnectionId);
124
+ const selectedModel = selectedConnection?.catalogEntries.find(({ id }) => id === session.model);
125
+ return projectAcpSessionConfigOptions(session, selectedModel?.thinkingLevels ?? []);
70
126
  }
71
127
  async #list(params) {
72
128
  const cursor = params.cursor == null ? undefined : decodeAcpSessionCursor(params.cursor);
@@ -110,6 +166,7 @@ export class AcpSessionRegistry {
110
166
  const connectionClose = this.#closeOwnedConnection();
111
167
  await Promise.allSettled([connectionClose]);
112
168
  await Promise.allSettled([...this.#inFlightOperations]);
169
+ this.#ownedSessionIds.clear();
113
170
  }
114
171
  #closeOwnedConnection() {
115
172
  const connection = this.#connection;
@@ -192,9 +249,38 @@ function validateNewSessionParams(params) {
192
249
  throw RequestError.invalidParams({ field: 'additionalDirectories', reason: 'unsupported' }, 'Additional directories are not supported by this ACP adapter yet');
193
250
  }
194
251
  }
252
+ function requestErrorFromConfigInput(error) {
253
+ if (error instanceof AcpSessionConfigInputError) {
254
+ return RequestError.invalidParams({ field: error.field, reason: error.reason }, 'Invalid Session configuration option');
255
+ }
256
+ return RequestError.internalError({
257
+ source: 'adapter',
258
+ operation: 'session.configuration.update',
259
+ code: 'validation_failed',
260
+ }, 'Session configuration validation failed');
261
+ }
262
+ function requestErrorFromSessionUpdate(error, operation, extra = {}) {
263
+ if (error instanceof RequestError)
264
+ return error;
265
+ if (!(error instanceof RuntimeHostSessionUpdateError)) {
266
+ return requestErrorFromRuntimeHost(error, operation, extra);
267
+ }
268
+ const common = { source: 'runtime_host', operation: error.operation, ...extra };
269
+ switch (error.reason) {
270
+ case 'not_found':
271
+ return RequestError.invalidParams({ ...common, code: 'not_found' }, 'Runtime Host Session was not found');
272
+ case 'invalid_projection':
273
+ return RequestError.internalError({ ...common, code: 'catalog_read_failure', reason: 'invalid_projection' }, 'Runtime Host returned an invalid Session lookup');
274
+ case 'unsupported_session_projection':
275
+ return RequestError.internalError({ ...common, code: 'unsupported_session_projection' }, 'Runtime Host Session cannot be represented in ACP');
276
+ case 'revision_conflict':
277
+ return RequestError.internalError({ ...common, code: 'revision_conflict', attempts: error.attempts }, 'Session configuration kept changing');
278
+ }
279
+ }
195
280
  function requestErrorFromRuntimeHost(error, operation, extra = {}) {
196
281
  const data = { ...runtimeHostErrorData(error, operation), ...extra };
197
- if (error instanceof RuntimeHostOperationError && error.code === 'invalid_request') {
282
+ if (error instanceof RuntimeHostOperationError &&
283
+ (error.code === 'invalid_request' || error.code === 'not_found')) {
198
284
  return RequestError.invalidParams(data, 'Runtime Host rejected the request');
199
285
  }
200
286
  return RequestError.internalError(data, 'Runtime Host request failed');
package/dist/cli-core.js CHANGED
@@ -338,6 +338,7 @@ export async function runMakaCli(argv = process.argv.slice(2), options = RELEASE
338
338
  : { compatibility: command.targetCompatibility }),
339
339
  },
340
340
  allowInterruptActiveTasks: command.allowInterruptActiveTasks,
341
+ ...(command.expectedSource ? { expectedSource: command.expectedSource } : {}),
341
342
  });
342
343
  }
343
344
  case 'runtime-host-local-update-activate': {
@@ -422,6 +423,7 @@ export async function runMakaCli(argv = process.argv.slice(2), options = RELEASE
422
423
  ...(command.expectedConfigFingerprint
423
424
  ? { expectedConfigFingerprint: command.expectedConfigFingerprint }
424
425
  : {}),
426
+ ...(command.expectedHost ? { expectedHost: command.expectedHost } : {}),
425
427
  ...(command.retainManagedDeployment ? { retainManagedDeployment: true } : {}),
426
428
  ...(command.allowInterruptActiveTasks ? { allowInterruptActiveTasks: true } : {}),
427
429
  });
@@ -267,6 +267,12 @@ function compactToolSummary(entry) {
267
267
  isReadBodyResult(result)) {
268
268
  return { text: linesText(readBodyLineCount(text)), protect: true };
269
269
  }
270
+ const status = makaPiToolPresentationStatus(entry);
271
+ // Error-text size is not a successful read's size. Show only the outcome,
272
+ // including under NO_COLOR; the full reason remains in expanded details.
273
+ if (status === 'error' || status === 'failed' || status === 'aborted') {
274
+ return { text: status === 'error' ? 'failed' : status, protect: true };
275
+ }
270
276
  return textResultSummary(text);
271
277
  }
272
278
  function compactTerminalSummary(content) {
@@ -17,7 +17,7 @@
17
17
  * under the License.
18
18
  */
19
19
  import { Markdown, visibleWidth } from '@earendil-works/pi-tui';
20
- import { deriveTurnRecords, STEP_LIMIT_NOTICE_TEXT, } from '@maka/core/session';
20
+ import { deriveTurnRecords, isRuntimeSystemNoteKind, STEP_LIMIT_NOTICE_TEXT, } from '@maka/core/session';
21
21
  import { providerRetryDisplaySeconds } from '@maka/core/provider-retry-countdown';
22
22
  import { defineUiMessageCatalog, resolveUiMessageCatalog, } from '@maka/core/ui-locale';
23
23
  import { TUI_COPY_RESOURCES } from './tui-copy-catalog.js';
@@ -931,14 +931,11 @@ function tokenDelta(before, after) {
931
931
  return Math.max(0, before - after);
932
932
  }
933
933
  function systemNoteText(message) {
934
+ // Retired kinds are still decoded off legacy transcript rows, and none of
935
+ // them ever had a line here worth reading.
936
+ if (!isRuntimeSystemNoteKind(message.kind))
937
+ return undefined;
934
938
  switch (message.kind) {
935
- case 'session_start':
936
- case 'session_resume':
937
- return undefined;
938
- case 'mode_change':
939
- return 'Permission mode changed.';
940
- case 'model_change':
941
- return 'Model changed.';
942
939
  case 'context_compacted':
943
940
  return 'Context compacted to keep this task within the model window.';
944
941
  case 'context_compaction_failed_open':
@@ -984,10 +981,6 @@ function systemNoteText(message) {
984
981
  }
985
982
  case 'step_limit':
986
983
  return STEP_LIMIT_NOTICE_TEXT;
987
- case 'error':
988
- return 'Session recorded an error.';
989
- case 'abort':
990
- return 'Session was stopped.';
991
984
  }
992
985
  }
993
986
  export function renderMakaPiTranscript(state, metadata, width) {