maka-agent 0.2.1-dev.90.20261017 → 0.2.2-dev.92.20261019

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 (116) hide show
  1. package/DISCLAIMER-WIP +1 -1
  2. package/LICENSE +8 -4
  3. package/README.md +113 -1
  4. package/README.zh-CN.md +98 -0
  5. package/dist/cli-core.js +1 -0
  6. package/dist/run-command-core.js +175 -8
  7. package/dist/run-session-command.js +458 -0
  8. package/dist/run-session-result.js +38 -0
  9. package/dist/run-turn-outcome.js +205 -0
  10. package/dist/runtime-host-cli.js +32 -17
  11. package/dist/runtime-host-run-command.js +53 -165
  12. package/dist/runtime-host-run-mcp.js +3 -0
  13. package/dist/runtime-host-setup-command.js +114 -7
  14. package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
  15. package/node_modules/@maka/core/dist/bot-chat-settings.js +10 -1
  16. package/node_modules/@maka/core/dist/event-wait-delivery.js +67 -0
  17. package/node_modules/@maka/core/dist/event-wait.js +48 -1
  18. package/node_modules/@maka/core/dist/goal.js +54 -2
  19. package/node_modules/@maka/core/dist/runtime-event-store.js +0 -1
  20. package/node_modules/@maka/core/dist/runtime-event.js +19 -2
  21. package/node_modules/@maka/core/dist/runtime-invocation.js +10 -0
  22. package/node_modules/@maka/core/dist/session.js +2 -1
  23. package/node_modules/@maka/core/dist/tool-ledger-scanner.js +1 -9
  24. package/node_modules/@maka/core/dist/tool-recovery-bundle.js +1 -14
  25. package/node_modules/@maka/core/dist/turn-origin.js +28 -2
  26. package/node_modules/@maka/core/package.json +1 -0
  27. package/node_modules/@maka/runtime/dist/agent-run.js +5 -1
  28. package/node_modules/@maka/runtime/dist/agent-swarm-status-tool.js +0 -1
  29. package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +7 -6
  30. package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +48 -6
  31. package/node_modules/@maka/runtime/dist/bots/bot-registry.js +19 -3
  32. package/node_modules/@maka/runtime/dist/bots/feishu-bridge.js +178 -6
  33. package/node_modules/@maka/runtime/dist/bots/wechat-bridge.js +163 -9
  34. package/node_modules/@maka/runtime/dist/context-budget-policy.js +9 -2
  35. package/node_modules/@maka/runtime/dist/event-wait-tool.js +69 -0
  36. package/node_modules/@maka/runtime/dist/goal-continuation.js +195 -117
  37. package/node_modules/@maka/runtime/dist/goal-state.js +8 -0
  38. package/node_modules/@maka/runtime/dist/history-compact-checkpoint.js +2 -3
  39. package/node_modules/@maka/runtime/dist/memory-extraction.js +0 -2
  40. package/node_modules/@maka/runtime/dist/openai-codex-history-compactor.js +9 -4
  41. package/node_modules/@maka/runtime/dist/plan-tools.js +0 -3
  42. package/node_modules/@maka/runtime/dist/plugin-agent-service.js +7 -1
  43. package/node_modules/@maka/runtime/dist/provider-error-classification.js +2 -0
  44. package/node_modules/@maka/runtime/dist/recovery-resolver.js +2 -1
  45. package/node_modules/@maka/runtime/dist/runtime-event-backfill.js +1 -0
  46. package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +1 -0
  47. package/node_modules/@maka/runtime/dist/sandbox-boundary-path.js +79 -2
  48. package/node_modules/@maka/runtime/dist/session-manager.js +5 -1
  49. package/node_modules/@maka/runtime/dist/stream-graph-supervisor-tools.js +0 -3
  50. package/node_modules/@maka/runtime/dist/tool-runtime.js +3 -2
  51. package/node_modules/@maka/runtime/package.json +1 -0
  52. package/node_modules/@maka/runtime-host/dist/assistant/bot/avatar.js +89 -0
  53. package/node_modules/@maka/runtime-host/dist/assistant/bot/bridge.js +52 -0
  54. package/node_modules/@maka/runtime-host/dist/assistant/bot/capabilities.js +52 -0
  55. package/node_modules/@maka/runtime-host/dist/assistant/bot/controller.js +319 -0
  56. package/node_modules/@maka/runtime-host/dist/assistant/bot/conversation.js +116 -0
  57. package/node_modules/@maka/runtime-host/dist/assistant/bot/host.js +133 -0
  58. package/node_modules/@maka/runtime-host/dist/assistant/bot/store.js +223 -0
  59. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/assistant.js +3 -1
  60. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/controller.js +61 -4
  61. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/host.js +88 -14
  62. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/prompt.js +1 -2
  63. package/node_modules/@maka/runtime-host/dist/assistant/index-initiative/store.js +4 -3
  64. package/node_modules/@maka/runtime-host/dist/assistant/memory-network/controller.js +382 -94
  65. package/node_modules/@maka/runtime-host/dist/assistant/memory-network/host.js +35 -12
  66. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/clarification.js +124 -0
  67. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/controller.js +23 -2
  68. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/delegation.js +31 -11
  69. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/delivery.js +11 -0
  70. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/host.js +2 -7
  71. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/prompt.js +2 -2
  72. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/review.js +67 -13
  73. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/store.js +5 -3
  74. package/node_modules/@maka/runtime-host/dist/assistant/proactive-matters/tools.js +7 -1
  75. package/node_modules/@maka/runtime-host/dist/assistant/service.js +46 -11
  76. package/node_modules/@maka/runtime-host/dist/client/host-profile.js +30 -1
  77. package/node_modules/@maka/runtime-host/dist/client/ssh-operator-activation.js +9 -2
  78. package/node_modules/@maka/runtime-host/dist/protocol/index.js +8 -1
  79. package/node_modules/@maka/runtime-host/dist/protocol/message.js +20 -1
  80. package/node_modules/@maka/runtime-host/dist/protocol/personal-assistant.js +33 -0
  81. package/node_modules/@maka/runtime-host/dist/protocol/turn.js +3 -1
  82. package/node_modules/@maka/runtime-host/dist/server/agent-settings-tools.js +0 -1
  83. package/node_modules/@maka/runtime-host/dist/server/avatar-image-source.js +66 -0
  84. package/node_modules/@maka/runtime-host/dist/server/event-wait-manager.js +88 -8
  85. package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +159 -34
  86. package/node_modules/@maka/runtime-host/dist/server/execution-model-composition.js +11 -0
  87. package/node_modules/@maka/runtime-host/dist/server/external-session-coordinator.js +5 -2
  88. package/node_modules/@maka/runtime-host/dist/server/goal-coordinator.js +219 -51
  89. package/node_modules/@maka/runtime-host/dist/server/goal-event-waits.js +418 -0
  90. package/node_modules/@maka/runtime-host/dist/server/goal-execution-coordinator.js +23 -6
  91. package/node_modules/@maka/runtime-host/dist/server/hosted-execution-recovery.js +5 -1
  92. package/node_modules/@maka/runtime-host/dist/server/interactive-run-composer.js +3 -2
  93. package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +8 -0
  94. package/node_modules/@maka/storage/dist/agent-run-store-contract.js +17 -4
  95. package/node_modules/@maka/storage/dist/agent-run-store.js +10 -0
  96. package/node_modules/@maka/storage/dist/codex-session-adapter.js +20 -3
  97. package/node_modules/@maka/storage/dist/cursor-session-adapter.js +604 -0
  98. package/node_modules/@maka/storage/dist/event-wait-authority.js +18 -1
  99. package/node_modules/@maka/storage/dist/event-wait-bridge.js +336 -0
  100. package/node_modules/@maka/storage/dist/execution-stores.js +3 -0
  101. package/node_modules/@maka/storage/dist/external-session-adapters.js +2 -0
  102. package/node_modules/@maka/storage/dist/external-session-images.js +131 -0
  103. package/node_modules/@maka/storage/dist/external-session-importer.js +12 -2
  104. package/node_modules/@maka/storage/dist/goal-authority.js +2 -0
  105. package/node_modules/@maka/storage/dist/local-execution-persistence.js +1 -1
  106. package/node_modules/@maka/storage/dist/operational-state-store.js +1 -1
  107. package/node_modules/@maka/storage/dist/session-bundle-policy.js +30 -0
  108. package/node_modules/@maka/storage/dist/session-store.js +37 -8
  109. package/node_modules/@maka/storage/dist/sqlite-event-wait-authority.js +81 -8
  110. package/node_modules/@maka/storage/dist/sqlite-event-wait-bridge.js +94 -0
  111. package/node_modules/@maka/storage/dist/sqlite-runtime-schema.js +7 -8
  112. package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +7 -162
  113. package/node_modules/@maka/storage/dist/sqlite-workflow-schema.js +7 -4
  114. package/node_modules/@maka/storage/dist/tool-commit-validation.js +1 -1
  115. package/node_modules/@maka/storage/package.json +1 -0
  116. package/package.json +1 -1
package/DISCLAIMER-WIP CHANGED
@@ -12,7 +12,7 @@ conditions. What follows is a list of issues the project is currently aware of
12
12
  (this list is likely to be incomplete):
13
13
 
14
14
  * The initial-code authorization review remains open at
15
- https://github.com/apache/maka/issues/3268. Since RC1, the ASF has recorded
15
+ https://github.com/apache/maka/issues/3268. Since 0.2.0 RC1, the ASF has recorded
16
16
  the ICLA of contributor Mingqwqqaq, and the Deep Research implementation
17
17
  has been removed. The review still needs to record the authorization basis
18
18
  for the retained initial code; these changes do not establish that an SGA
package/LICENSE CHANGED
@@ -218,7 +218,9 @@ License: Apache-2.0
218
218
  These patches modify the execution time policy and its SDK forwarding. The
219
219
  Apache License, Version 2.0 above applies. The generated run Worker includes
220
220
  embedded third-party code; its upstream notices and license texts are retained
221
- in patches/run-2.1.4-notices.md.
221
+ in patches/run-2.1.4-notices.md. The patch carries no WebAssembly binary:
222
+ postinstall substitutes the unchanged payload from the installed run package
223
+ for `__MAKA_RUN_WASM_BASE64__` before applying the patch.
222
224
 
223
225
  Vercel AI SDK
224
226
 
@@ -240,7 +242,7 @@ License, Version 2.0 above applies to the adapted material.
240
242
  The pinned versions are the ones present when the adaptation was made. The
241
243
  adapted declarations are unchanged through @ai-sdk/provider-utils 5.0.25 and
242
244
  @ai-sdk/provider 4.0.7, the versions recorded by the code origin audit. Maka
243
- also redistributes a patch against @ai-sdk/provider-utils 5.0.40; that patch
245
+ also redistributes a patch against @ai-sdk/provider-utils 5.0.51; that patch
244
246
  modifies Apache-2.0 source and is covered by the license reproduced above.
245
247
 
246
248
  Astryx
@@ -622,6 +624,9 @@ License: MIT
622
624
  adaptations of this component.
623
625
  The following MIT License applies to that material:
624
626
 
627
+ Maka-authored modifications are licensed under the Apache License, Version 2.0
628
+ reproduced above; the upstream portions retain the MIT terms below.
629
+
625
630
  MIT License
626
631
 
627
632
  Copyright (c) 2025 Cua AI, Inc.
@@ -809,8 +814,7 @@ Desktop renderer vendored source assets
809
814
 
810
815
  The source archive includes third-party SVG paths and source assets from
811
816
  Lobe Icons (MIT), LocalAI (MIT), Simple Icons (CC0-1.0), TDesign Icons (MIT),
812
- MingCute (Apache-2.0), Allogo (MIT), Ant Design Icons (MIT), and Semi Design
813
- (MIT), used by the desktop renderer. Their file-by-file inventory, immutable upstream revisions,
817
+ MingCute (Apache-2.0), and Allogo (MIT), used by the desktop renderer. Their file-by-file inventory, immutable upstream revisions,
814
818
  copyright notices, and license texts are in:
815
819
 
816
820
  apps/desktop/src/renderer/public/THIRD_PARTY_LICENSES.txt
package/README.md CHANGED
@@ -48,7 +48,7 @@ conditions. What follows is a list of issues the project is currently aware of
48
48
  (this list is likely to be incomplete):
49
49
 
50
50
  * The initial-code authorization review remains open at
51
- https://github.com/apache/maka/issues/3268. Since RC1, the ASF has recorded
51
+ https://github.com/apache/maka/issues/3268. Since 0.2.0 RC1, the ASF has recorded
52
52
  the ICLA of contributor Mingqwqqaq, and the Deep Research implementation
53
53
  has been removed. The review still needs to record the authorization basis
54
54
  for the retained initial code; these changes do not establish that an SGA
@@ -142,6 +142,118 @@ Maka asks before privileged tool operations by default. `maka run --yolo` grants
142
142
  and network access and should only be used in an environment you are prepared to let the task
143
143
  modify.
144
144
 
145
+
146
+ For another agent to drive a Session, request structured output or explicitly submit without waiting:
147
+
148
+ ```sh
149
+ maka run "Inspect this project" --json
150
+ maka run "Inspect this project" --no-wait
151
+ ```
152
+
153
+ Both forms return a `sessionId` in their JSON result. Ordinary runs still wait and print the final
154
+ answer by default. Built-in AskUser is an exception: it returns question JSON and exits 0
155
+ while the Turn waits. Scripts that need a final answer should use `--json` and inspect `status`,
156
+ not treat exit code 0 alone as task completion. `--no-wait` returns after admission; use the
157
+ Session ID to observe the eventual result. Given a returned Session ID in `$session`:
158
+
159
+ ```sh
160
+ maka run --session "$session" --status
161
+ maka run --session "$session" --wait --json
162
+ maka run --session "$session" --answer '["Yes",null]' --wait --json
163
+ maka run --session "$session" "Inspect the tests next" --queue --wait --json
164
+ maka run --session "$session" "Focus on the parser" --steer --no-wait
165
+ maka run --session "$session" --result --json
166
+ maka run --session "$session" --resume --wait --json
167
+ ```
168
+
169
+ Session controls (`--session`) inherit the Host's saved permissions, just as they inherit the
170
+ model and working directory. Continuing, queueing, steering, or answering does not require another
171
+ `--yolo` and does not change the boundary. Add `--yolo` only to explicitly grant full access.
172
+ `--status` reports `executionBoundary`: managed `read_only`/`writable`, bypass, or external.
173
+ A read-only task instruction does not turn a bypass Session into an enforced read-only Session.
174
+ The legacy blocking `--resume <id>` selector retains its explicit `--yolo` requirement for bypass.
175
+
176
+ An ordinary built-in AskUser returns `needs_input`, the questions and options, with exit code 0.
177
+ The Host retains the waiting Turn. `--answer` accepts one string or `null` per question in a JSON
178
+ array and continues the original tool call and Turn. It does not need `--resume`. A failed or
179
+ uncertain answer submission is not automatically retried; read the current questions before
180
+ choosing what to do next. Multiple pending batches are reported, and an answer is refused when
181
+ the current batch cannot be selected uniquely.
182
+
183
+ For Host-owned Session execution, `--wait` and `--status` return `needs_approval` with
184
+ `approvalRequests` when a sandbox expansion is pending. Each entry contains its `kind`, requested
185
+ `expansion`, and `justification`; internal request IDs stay inside the CLI. Review the scope, then:
186
+
187
+ ```sh
188
+ maka run --session "$session" --approve --wait --json
189
+ maka run --session "$session" --deny --wait --json
190
+ ```
191
+
192
+ These are alternative decisions, not a sequence to execute. Both continue the original Turn and
193
+ require exactly one pending sandbox request in the Session; none or multiple are rejected without
194
+ submitting a decision. They do not need `--yolo` and cannot be combined with it. Approval applies
195
+ the requested expansion through the Host's managed boundary; it does not change the Session to
196
+ bypass. The expanded boundary is saved for subsequent execution in the Session. The flags
197
+ target the request pending when that CLI invocation attaches. Do not automatically
198
+ retry a decision after an uncertain result: read the current requests before deciding again.
199
+ Ordinary blocking runs retain their existing sandbox-boundary denial behavior.
200
+
201
+ For coordination, submit follow-ups without blocking, then service the Session's interactions:
202
+
203
+ ```sh
204
+ maka run --session "$session" "Inspect the tests next" --queue --no-wait --json
205
+ maka run --session "$session" --wait --json
206
+ ```
207
+
208
+ Worker admission receipts have `submission: "started"`, `"queued"`, or `"steering"`. Their `status`
209
+ describes the currently observed Session, not completion of the submitted message. A queued receipt
210
+ can include `needs_input` and the current Turn's questions, or `needs_approval` and its sandbox
211
+ request. Answer that interaction before expecting the follow-up to execute. `queued` is the
212
+ observed total of follow-up and steering messages; it is not an exact position. An admission
213
+ receipt omits this count until its queue projection has caught up; use status for a fresh view. Status also reports
214
+ `providerRetry` when the Host has published a retry, without guessing activity from silence.
215
+
216
+ Assistant Inbox conversations instead return `submission: "inbox"`, without a worker result or queue count, even with `--wait`. This confirms Inbox admission only; inspect delegated work through its own worker Session.
217
+
218
+ Queue is the default: each explicit queued message opens its own subsequent Turn. Steer uses the
219
+ Host's existing current-Turn delivery and may carry over if it misses that Turn's last boundary.
220
+ Submitting a queued prompt with `--wait` follows that message's execution. It does not return
221
+ questions from an earlier Turn blocking the queue; service those through a separate Session
222
+ wait/answer call, or use the coordination workflow above. Steer with `--wait`
223
+ observes the Turn selected on attachment; it does not guarantee consumption before that Turn ends. A standalone `--wait` fixes its
224
+ target on attachment; when idle, it reads the latest result. `--result` never waits for an active
225
+ Turn. Status and result queries do not prepare a model or start MCP. Interrupting Session
226
+ observation with Ctrl+C leaves Host execution running; legacy blocking run cancellation retains
227
+ its existing behavior. To stop Host execution explicitly, use `maka run --session "$session" --stop --json`.
228
+ Stop targets the current Turn observed on attachment and needs no `--yolo`; a successful request
229
+ exits 0. A successful explicit or implicit status query also exits 0 even if it reports a failed
230
+ or cancelled Turn; result/wait retain the task's failure exit code. Stop and status are not
231
+ assertions that the assigned task succeeded.
232
+
233
+ Permission requests, MCP forms, and other interactions that this Session CLI cannot answer
234
+ remain waiting in the Host. A wait reports the actual interaction kind and a recovery command: use an
235
+ interactive client on the same Host, or stop the Turn explicitly. Detached admission does not
236
+ promise that subsequent execution will need no interaction.
237
+
238
+ Session commands use the saved configuration. Keep using the legacy `--resume <session-id>`
239
+ selector for blocking runs that supply configuration, cwd, timeout or Graph options; that selector
240
+ continues accepting a new prompt. `--session <id> --resume` instead requests safe continuation of
241
+ stopped execution. An idle Session prompt can use `--max-steps`; a queued or steering message
242
+ cannot attach a step cap to an existing Turn.
243
+
244
+ Returning from client-owned MCP interaction and resuming it in another CLI process is not
245
+ supported. Blocking MCP runs retain their existing behavior; `--no-wait` refuses to detach the
246
+ MCP servers owned by that invocation. Graph interaction handoff is also deferred. Use a persistent
247
+ CLI installation for local Session control execution and detached runs; temporary npx invocations
248
+ may own the Host's lifetime and keep the legacy blocking path.
249
+
250
+ For agent-to-agent CLI workflows, install the repository's `maka-cli` skill after it is available
251
+ on your selected branch. It explains Session coordination; it does not install Maka itself:
252
+
253
+ ```sh
254
+ npx skills add apache/maka --skill maka-cli
255
+ ```
256
+
145
257
  ## Upgrade
146
258
 
147
259
  Update within the nightly line by pinning the exact release (`--target` accepts `latest`,
package/README.zh-CN.md CHANGED
@@ -108,6 +108,104 @@ maka run --help
108
108
  Maka 默认会在执行高权限工具操作前询问。`maka run --yolo` 会授予该任务完整的文件和网络
109
109
  权限,只应在你允许任务修改的环境中使用。
110
110
 
111
+
112
+ 主代理可以请求结构化结果,或显式提交后返回:
113
+
114
+ ```sh
115
+ maka run "检查这个项目" --json
116
+ maka run "检查这个项目" --no-wait
117
+ ```
118
+
119
+ 这两种调用的 JSON 结果都包含 `sessionId`。普通调用仍默认等待并输出最终答案。
120
+ `--no-wait` 在提交被接收后返回;使用会话 ID 查询后续结果。假设返回的会话 ID 保存在
121
+ `$session` 中:
122
+
123
+ ```sh
124
+ maka run --session "$session" --status
125
+ maka run --session "$session" --wait --json
126
+ maka run --session "$session" --answer '["是",null]' --wait --json
127
+ maka run --session "$session" "接下来检查测试" --queue --wait --json
128
+ maka run --session "$session" "重点检查参数解析" --steer --no-wait
129
+ maka run --session "$session" --result --json
130
+ maka run --session "$session" --resume --wait --json
131
+ ```
132
+
133
+ 会话控制(`--session`)与继承模型、工作目录一样,继承 Host 已保存的权限。续跑、queue、
134
+ steer 和回答问题不需要重复 `--yolo`,也不会改变执行边界;只有要显式授予完整权限时才加
135
+ `--yolo`。`--status` 会报告 `executionBoundary`:受管 `read_only`/`writable`、bypass 或 external。
136
+ 只读任务描述不等于强制只读沙箱,继承 bypass 的会话依然是完整权限。旧阻塞选择器
137
+ `--resume <id>` 对 bypass 会话仍保留显式 `--yolo` 要求。
138
+
139
+ 内置 AskUser 是普通阻塞运行的例外:它会输出问题 JSON 而不是最终答案。脚本应使用 `--json`
140
+ 并检查 `status`,不能仅凭退出码 0 判断任务完成。普通内置 AskUser 会以退出码 0 返回
141
+ `needs_input`、问题及选项,Host 保留等待中的 Turn。
142
+ `--answer` 使用 JSON 数组,为每个问题提供一个字符串或 `null`,回答后原工具调用和原 Turn
143
+ 继续执行,无需 `--resume`。答案提交失败或结果不确定时不会自动重发;先重新读取当前问题,
144
+ 再决定下一步。存在多批待回答问题时会如实报告,无法唯一选择当前批次时拒绝提交答案。
145
+
146
+ 对于 Host 持有的会话执行,`--wait` 和 `--status` 遇到沙箱扩展请求会返回 `needs_approval`,
147
+ 并在 `approvalRequests` 中列出 `kind`、扩展范围 `expansion` 和理由 `justification`;内部请求
148
+ ID 不暴露。查看范围后,选择批准或拒绝:
149
+
150
+ ```sh
151
+ maka run --session "$session" --approve --wait --json
152
+ maka run --session "$session" --deny --wait --json
153
+ ```
154
+
155
+ 上面两条命令是二选一,不能顺序执行。它们都继续原 Turn,要求会话中恰好有一个待处理沙箱
156
+ 请求;没有请求或存在多个请求时拒绝提交决定。它们无需 `--yolo`,也不能与之混用。批准通过
157
+ Host 扩展受管沙箱边界,并保存供该会话后续执行使用,不会将会话切换为 bypass。命令针对
158
+ 本次连接时待处理的请求;结果
159
+ 不确定时不要自动重试,应先读取当前请求,再决定下一步。普通阻塞运行仍保留原有的沙箱
160
+ 边界自动拒绝行为。
161
+
162
+ 协调线程推荐先后台入队,再处理会话交互:
163
+
164
+ ```sh
165
+ maka run --session "$session" "接下来检查测试" --queue --no-wait --json
166
+ maka run --session "$session" --wait --json
167
+ ```
168
+
169
+ 工作会话提交回执中的 `submission` 为 `started`、`queued` 或 `steering`,只表示接收方式;`status`
170
+ 描述当前观察到的会话,不表示刚提交的消息已完成。排队回执可同时带有 `needs_input` 和当前
171
+ Turn 的问题,或 `needs_approval` 和沙箱请求;先回答交互,后续消息才能执行。`queued` 是观察到
172
+ 的后续消息与 steer 总数,不是精确排队位置;回执快照未追上接收结果时省略该计数,
173
+ 可用 status 读取新状态。Host 发布重试状态时,status 还会带上
174
+ `providerRetry`,不会根据静默时间猜测活动。
175
+
176
+ 助手 Inbox 会话返回 `submission: "inbox"`,不包含工作 Turn 的结果或队列计数,即使指定 `--wait` 也立即返回接收回执。这仅确认消息已进入 Inbox;委派工作的结果需通过对应工作会话查询。
177
+
178
+ 默认使用 queue,每条显式排队消息对应一个独立后续 Turn。steer 沿用 Host 当前 Turn 的追加
179
+ 机制,错过最后处理边界时可能进入后续 Turn。提交排队消息时的 `--wait` 跟踪该消息对应的执行,不会返回前一 Turn 阻塞队列的问题;
180
+ 这类问题要通过独立的会话 wait/answer 处理,或采用上面的协调流程。steer 配合 `--wait` 观察连接时选定的
181
+ Turn,不保证追加消息一定在该 Turn 结束前消费。
182
+ 单独 `--wait` 在连接时固定目标,空闲时读取最近结果。`--result` 不等待仍在执行的 Turn。
183
+ 状态和结果查询不准备模型、不启动 MCP。用 Ctrl+C 退出会话观察会让 Host 继续执行;旧阻塞
184
+ run 的取消行为保持原样。显式停止 Host 执行可用 `maka run --session "$session" --stop --json`。
185
+ 停止操作针对连接时观察到的当前 Turn,不需要 `--yolo`,请求成功退出 0。显式或隐式的 status
186
+ 查询成功时也退出 0,即使它报告的 Turn 已失败或取消;result/wait 仍以任务失败返回非零退出码。
187
+ 停止或查询成功不代表分配的任务已完成。
188
+
189
+ 权限请求、MCP 表单等会话 CLI 无法回答的交互会留在 Host 中等待。wait 会报告实际交互类型和恢复
190
+ 命令:使用同一 Host 的交互式客户端处理,或显式停止该 Turn。后台提交成功不保证后续执行
191
+ 不会请求交互。
192
+
193
+ 会话控制使用已保存的配置。需要指定配置、cwd、timeout 或 Graph 选项的阻塞运行,继续使用
194
+ 兼容入口 `--resume <session-id>` 选择会话并提供新 prompt。`--session <id> --resume` 则表示
195
+ 安全恢复已停止的执行。空闲会话的新 prompt 可以使用 `--max-steps`,排队或 steer 消息不能
196
+ 给已有 Turn 附加步数上限。
197
+
198
+ 当前不支持客户端 MCP 交互返回后由另一个 CLI 进程续接。阻塞 MCP 运行保留现有行为;
199
+ `--no-wait` 会拒绝脱离本次调用持有的 MCP servers。Graph 交互交接也暂缓。执行本地会话控制
200
+ 及后台提交时使用持久 CLI 安装;临时 npx 调用可能持有 Host 生命周期,继续使用旧阻塞路径。
201
+
202
+ 仓库的 `maka-cli` skill 提供主/子代理 CLI 协作指引;待其进入所选分支后可安装。
203
+ skill 本身不安装 Maka CLI:
204
+
205
+ ```sh
206
+ npx skills add apache/maka --skill maka-cli
207
+ ```
208
+
111
209
  ## 升级
112
210
 
113
211
  在 nightly 线内更新时固定精确版本(`--target` 只接受 `latest`、`next` 或精确的 Maka
package/dist/cli-core.js CHANGED
@@ -316,6 +316,7 @@ export async function runMakaCli(argv = process.argv.slice(2), options = RELEASE
316
316
  ...(command.repairRootAfterRemount ? { repairRootAfterRemount: true } : {}),
317
317
  updateExisting: command.updateExisting,
318
318
  reuseExistingEnvironment: command.reuseExistingEnvironment,
319
+ ...(command.expectedExisting ? { expectedExisting: command.expectedExisting } : {}),
319
320
  allowInterruptActiveTasks: command.allowInterruptActiveTasks,
320
321
  ...(command.rootPath ? { rootPath: command.rootPath } : {}),
321
322
  ...(command.projectDirectoryRoots
@@ -16,6 +16,7 @@
16
16
  * specific language governing permissions and limitations
17
17
  * under the License.
18
18
  */
19
+ import { RunQuestionAvailable, RunSessionInterrupted, } from './run-session-result.js';
19
20
  import { randomUUID } from 'node:crypto';
20
21
  import { realpath, stat } from 'node:fs/promises';
21
22
  import { resolve } from 'node:path';
@@ -25,6 +26,8 @@ import { selectMakaRunSession } from './run-session-selection.js';
25
26
  import { sessionEventSandboxBoundaryFailureReason } from './sandbox-boundary-failure.js';
26
27
  import { resolveMakaWorkspaceRoot } from './workspace-root.js';
27
28
  const VALUE_FLAGS = new Set([
29
+ 'session',
30
+ 'answer',
28
31
  'cwd',
29
32
  'connection',
30
33
  'model',
@@ -36,12 +39,28 @@ const VALUE_FLAGS = new Set([
36
39
  'project',
37
40
  ]);
38
41
  const REPEATABLE_VALUE_FLAGS = new Set();
39
- const BOOLEAN_FLAGS = new Set(['continue', 'yolo', 'graph']);
42
+ const BOOLEAN_FLAGS = new Set([
43
+ 'continue',
44
+ 'yolo',
45
+ 'graph',
46
+ 'wait',
47
+ 'no-wait',
48
+ 'json',
49
+ 'status',
50
+ 'result',
51
+ 'queue',
52
+ 'steer',
53
+ 'stop',
54
+ 'approve',
55
+ 'deny',
56
+ ]);
40
57
  export function parseMakaRunArgs(argv) {
41
58
  const positional = [];
42
59
  const flags = new Map();
43
60
  const booleanFlags = new Set();
44
61
  let literal = false;
62
+ const optionArgs = argv.includes('--') ? argv.slice(0, argv.indexOf('--')) : argv;
63
+ const selectsSession = optionArgs.includes('--session');
45
64
  for (let index = 0; index < argv.length; index += 1) {
46
65
  const arg = argv[index];
47
66
  if (!literal && (arg === '--help' || arg === '-h'))
@@ -52,7 +71,7 @@ export function parseMakaRunArgs(argv) {
52
71
  }
53
72
  if (!literal && arg.startsWith('--')) {
54
73
  const name = arg.slice(2);
55
- if (BOOLEAN_FLAGS.has(name)) {
74
+ if (BOOLEAN_FLAGS.has(name) || (name === 'resume' && selectsSession)) {
56
75
  if (booleanFlags.has(name))
57
76
  return { kind: 'error', message: `option repeated: ${arg}` };
58
77
  booleanFlags.add(name);
@@ -79,6 +98,71 @@ export function parseMakaRunArgs(argv) {
79
98
  if (positional.length > 1) {
80
99
  return { kind: 'error', message: 'maka run accepts at most one positional prompt' };
81
100
  }
101
+ const sessionId = flags.get('session');
102
+ const resumeExecution = booleanFlags.has('resume');
103
+ if (sessionId !== undefined && !sessionId.trim())
104
+ return { kind: 'error', message: '--session requires a non-empty Session ID' };
105
+ if (booleanFlags.has('wait') && booleanFlags.has('no-wait')) {
106
+ return { kind: 'error', message: '--wait and --no-wait cannot be used together' };
107
+ }
108
+ if (booleanFlags.has('queue') && booleanFlags.has('steer')) {
109
+ return { kind: 'error', message: '--queue and --steer cannot be used together' };
110
+ }
111
+ const actions = Number(booleanFlags.has('status')) +
112
+ Number(booleanFlags.has('result')) +
113
+ Number(flags.has('answer')) +
114
+ Number(resumeExecution) +
115
+ Number(booleanFlags.has('stop')) +
116
+ Number(booleanFlags.has('approve')) +
117
+ Number(booleanFlags.has('deny'));
118
+ if (actions > 1)
119
+ return {
120
+ kind: 'error',
121
+ message: 'choose one of --status, --result, --answer, --approve, --deny, --resume or --stop',
122
+ };
123
+ if ((booleanFlags.has('approve') || booleanFlags.has('deny')) && booleanFlags.has('yolo'))
124
+ return {
125
+ kind: 'error',
126
+ message: '--approve/--deny answer only the current sandbox request; do not combine with --yolo',
127
+ };
128
+ if (!sessionId && (actions || booleanFlags.has('queue') || booleanFlags.has('steer'))) {
129
+ return { kind: 'error', message: 'session operations require --session <session-id>' };
130
+ }
131
+ if (sessionId && (booleanFlags.has('continue') || flags.has('project'))) {
132
+ return {
133
+ kind: 'error',
134
+ message: '--session cannot be combined with --continue or --project',
135
+ };
136
+ }
137
+ if (actions && positional.length)
138
+ return { kind: 'error', message: 'session actions do not accept a prompt' };
139
+ if ((booleanFlags.has('queue') || booleanFlags.has('steer')) && (!positional.length || actions)) {
140
+ return { kind: 'error', message: '--queue and --steer require a prompt' };
141
+ }
142
+ if ((booleanFlags.has('status') || booleanFlags.has('result') || booleanFlags.has('stop')) &&
143
+ (booleanFlags.has('wait') || booleanFlags.has('no-wait'))) {
144
+ return { kind: 'error', message: '--status, --result and --stop do not accept wait options' };
145
+ }
146
+ if (booleanFlags.has('graph') && booleanFlags.has('no-wait')) {
147
+ return { kind: 'error', message: '--graph must wait for its final result' };
148
+ }
149
+ let answers;
150
+ if (flags.has('answer')) {
151
+ try {
152
+ const value = JSON.parse(flags.get('answer'));
153
+ if (!Array.isArray(value) ||
154
+ value.length === 0 ||
155
+ value.some((v) => v !== null && typeof v !== 'string'))
156
+ throw new Error();
157
+ answers = value;
158
+ }
159
+ catch {
160
+ return {
161
+ kind: 'error',
162
+ message: '--answer expects a JSON array of strings or null, e.g. ["Yes"]',
163
+ };
164
+ }
165
+ }
82
166
  const prompt = positional[0];
83
167
  const timeout = flags.get('timeout');
84
168
  const maxSteps = flags.get('max-steps');
@@ -112,6 +196,25 @@ export function parseMakaRunArgs(argv) {
112
196
  return {
113
197
  kind: 'run',
114
198
  options: {
199
+ ...(sessionId !== undefined ? { sessionId } : {}),
200
+ ...(booleanFlags.has('wait') ? { wait: true } : {}),
201
+ ...(booleanFlags.has('no-wait') ? { noWait: true } : {}),
202
+ ...(booleanFlags.has('json') ? { json: true } : {}),
203
+ ...(booleanFlags.has('status') ? { status: true } : {}),
204
+ ...(booleanFlags.has('result') ? { result: true } : {}),
205
+ ...(resumeExecution ? { resumeExecution: true } : {}),
206
+ ...(booleanFlags.has('stop') ? { stop: true } : {}),
207
+ ...(booleanFlags.has('approve')
208
+ ? { sandboxDecision: 'allow' }
209
+ : booleanFlags.has('deny')
210
+ ? { sandboxDecision: 'deny' }
211
+ : {}),
212
+ ...(answers ? { answers } : {}),
213
+ ...(booleanFlags.has('steer')
214
+ ? { placement: 'current_turn' }
215
+ : booleanFlags.has('queue')
216
+ ? { placement: 'next_turn' }
217
+ : {}),
115
218
  ...(prompt !== undefined && prompt !== '-' ? { prompt } : {}),
116
219
  stdinPrompt: prompt === '-',
117
220
  ...(flags.get('cwd') !== undefined ? { cwd: flags.get('cwd') } : {}),
@@ -140,6 +243,29 @@ export async function runMakaTextCliCore(argv, adapter, overrides = {}) {
140
243
  deps.writeStderr(`maka run: ${parsed.message}\n\n${makaRunHelpText(deps.cliCommand())}\n`);
141
244
  return 2;
142
245
  }
246
+ if (parsed.options.sessionId) {
247
+ try {
248
+ if (!deps.runSession)
249
+ throw new Error('Session operations are unavailable in this CLI runtime');
250
+ const options = { ...parsed.options };
251
+ // Queries and answers must not block reading an unrelated stdin stream.
252
+ if (options.prompt !== undefined || options.stdinPrompt)
253
+ options.prompt = await resolveRunPrompt(options, deps);
254
+ const result = await deps.runSession(options, deps);
255
+ writeSessionResult(result, deps, options.json === true);
256
+ const returnsTaskOutcome = options.prompt !== undefined ||
257
+ options.answers !== undefined ||
258
+ options.resumeExecution ||
259
+ options.sandboxDecision !== undefined ||
260
+ options.wait ||
261
+ options.result;
262
+ return result.status === 'failed' && returnsTaskOutcome ? 1 : 0;
263
+ }
264
+ catch (error) {
265
+ deps.writeStderr(`maka run: ${errorMessage(error)}\n`);
266
+ return error instanceof RunSessionInterrupted ? 130 : 1;
267
+ }
268
+ }
143
269
  let prompt;
144
270
  let selection;
145
271
  const workspaceRoot = deps.workspaceRoot();
@@ -176,6 +302,7 @@ export async function runMakaTextCliCore(argv, adapter, overrides = {}) {
176
302
  let context;
177
303
  try {
178
304
  context = await deps.createContext({
305
+ ...(parsed.options.noWait ? { noWait: true } : {}),
179
306
  workspaceRoot,
180
307
  cwd: selection.cwd,
181
308
  ...(selection.kind === 'existing' || parsed.options.connection
@@ -249,6 +376,7 @@ export async function runMakaTextCliCore(argv, adapter, overrides = {}) {
249
376
  let interrupted = false;
250
377
  let timedOut = false;
251
378
  let streamFailed = false;
379
+ let question;
252
380
  let stopPromise;
253
381
  let resolveStopSignal;
254
382
  const stopSignal = new Promise((resolve) => {
@@ -310,10 +438,11 @@ export async function runMakaTextCliCore(argv, adapter, overrides = {}) {
310
438
  await stopPromise;
311
439
  }
312
440
  catch (error) {
313
- streamFailed = true;
441
+ question = error instanceof RunQuestionAvailable ? error : undefined;
442
+ streamFailed = !question;
314
443
  graphActivity?.release();
315
444
  await stopPromise?.catch(() => undefined);
316
- if (!interrupted && !timedOut) {
445
+ if (!interrupted && !timedOut && !question) {
317
446
  deps.writeStderr(`maka run: ${errorMessage(error)}\n`);
318
447
  }
319
448
  }
@@ -329,6 +458,10 @@ export async function runMakaTextCliCore(argv, adapter, overrides = {}) {
329
458
  deps.writeStderr(`maka run: timed out after ${parsed.options.timeoutMs}ms\n`);
330
459
  return 1;
331
460
  }
461
+ if (question) {
462
+ writeSessionResult(question.result(), deps, true);
463
+ return 0;
464
+ }
332
465
  if (streamFailed)
333
466
  return 1;
334
467
  if (boundaryFailure)
@@ -337,14 +470,30 @@ export async function runMakaTextCliCore(argv, adapter, overrides = {}) {
337
470
  deps.writeStderr('maka run: runtime produced no outcome\n');
338
471
  return 1;
339
472
  }
473
+ if (outcome.status === 'running') {
474
+ writeSessionResult({ sessionId: session.id, status: 'running', submission: 'started' }, deps, true);
475
+ return 0;
476
+ }
340
477
  if (outcome.status !== 'completed' || outcome.finalOutput === undefined) {
341
478
  const detail = outcome.failure?.message ?? outcome.failure?.class ?? 'runtime failure';
342
- deps.writeStderr(`maka run: ${detail}\n`);
479
+ if (parsed.options.json) {
480
+ writeSessionResult({ sessionId: session.id, status: 'failed', error: detail }, deps, true);
481
+ }
482
+ else
483
+ deps.writeStderr(`maka run: ${detail}\n`);
343
484
  return 1;
344
485
  }
345
- deps.writeStdout(withTrailingNewline(outcome.finalOutput));
486
+ writeSessionResult({ sessionId: session.id, status: 'completed', finalOutput: outcome.finalOutput }, deps, parsed.options.json === true);
346
487
  return 0;
347
488
  }
489
+ export function writeSessionResult(result, deps, json) {
490
+ if (json || result.status !== 'completed' || result.finalOutput === undefined)
491
+ deps.writeStdout(`${JSON.stringify(result)}\n`);
492
+ else
493
+ deps.writeStdout(withTrailingNewline(result.finalOutput));
494
+ if (result.status === 'failed' && result.error)
495
+ deps.writeStderr(`maka run: ${result.error}\n`);
496
+ }
348
497
  async function resolveRunPrompt(options, deps) {
349
498
  const shouldReadStdin = options.stdinPrompt || !deps.stdinIsTTY();
350
499
  const stdin = shouldReadStdin ? await deps.readStdin() : '';
@@ -381,11 +530,29 @@ function makaRunHelpText(cliCommand) {
381
530
  ' --thinking <level> off|on|minimal|low|medium|high|xhigh|max|default',
382
531
  ' --timeout <seconds> Invocation timeout',
383
532
  ' --max-steps <count> Tool-step cap',
384
- ' --yolo Give this task full access to your files and network',
385
- ' --resume <session-id> Continue an explicit compatible task',
533
+ ' --yolo Grant full access; Session controls otherwise inherit saved access',
534
+ ' --session <session-id> Select a Session (without a prompt: show its status)',
535
+ ' --wait Wait for this message/current Turn; return input/approval early',
536
+ ' --no-wait Submit and return (Host-owned execution only)',
537
+ ' --status Read current Session status without executing',
538
+ ' --result Read the latest Turn result without waiting',
539
+ ' --stop Request stop for the current Turn (no --yolo needed)',
540
+ ' --answer <json-array> Answer the current AskUser, e.g. ["Yes",null]',
541
+ ' --approve Approve the single pending sandbox expansion',
542
+ ' --deny Deny the single pending sandbox expansion',
543
+ ' --queue Queue this prompt as its own next Turn (default)',
544
+ ' --steer Add this prompt to the current execution',
545
+ ' --json Return a structured result, including the Session ID',
546
+ ' --session <id> --resume Safely resume stopped execution',
547
+ ' --resume <session-id> Legacy Session selector (prefer --session)',
386
548
  ' --continue Continue the latest compatible task for cwd',
387
549
  ' --graph Run this turn in Graph Mode and wait for graph completion',
388
550
  ' -h, --help Show help',
551
+ '',
552
+ 'Session controls inherit saved permissions; --yolo explicitly grants full access.',
553
+ '--status reports the execution boundary; a read-only prompt does not restrict permissions.',
554
+ 'Legacy --resume <id> still requires --yolo for a full-access Session.',
555
+ '--approve/--deny decide a sandbox request without changing the Session to full access.',
389
556
  ].join('\n');
390
557
  }
391
558
  function defaultMakaRunEnvironmentDeps() {