minicode-ai 0.11.0 → 0.13.0

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 (221) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/LICENSE +21 -21
  3. package/README.md +4 -4
  4. package/cli/args.ts +46 -0
  5. package/cli/commands/acp.ts +163 -10
  6. package/cli/commands/config.ts +33 -18
  7. package/cli/commands/daemon.ts +515 -0
  8. package/cli/commands/exec.ts +145 -53
  9. package/cli/commands/openwork.ts +986 -0
  10. package/cli/commands/sessions.ts +4 -1
  11. package/cli/commands/stats.ts +34 -4
  12. package/cli/commands.ts +217 -2
  13. package/cli/index.ts +146 -14
  14. package/cli/recovery-warning.ts +115 -0
  15. package/cli/router.ts +32 -1
  16. package/cli/setup.ts +2332 -171
  17. package/cli/tui.ts +113 -7
  18. package/docs/OUTPUT_ARCHITECTURE_AUDIT.md +489 -0
  19. package/docs/OUTPUT_EVENT_MODEL.md +289 -0
  20. package/docs/OUTPUT_IMPLEMENTATION_PLAN.md +391 -0
  21. package/docs/OUTPUT_PROTOCOL_SPEC.md +285 -0
  22. package/docs/OUTPUT_RENDERING_SPEC.md +248 -0
  23. package/docs/OUTPUT_UX_RULES.md +449 -0
  24. package/docs/PLAN_UIUX_V6.md +2 -2
  25. package/docs/README.md +4 -3
  26. package/docs/TERMINAL_CONTRACT.md +278 -66
  27. package/docs/architecture.md +89 -7
  28. package/docs/changelog.md +1 -1
  29. package/docs/choosing-mode.md +2 -2
  30. package/docs/cli.md +9 -5
  31. package/docs/concepts.md +1 -1
  32. package/docs/contributing.md +9 -2
  33. package/docs/environment.md +6 -2
  34. package/docs/exec.md +46 -5
  35. package/docs/memory-sessions.md +2 -0
  36. package/docs/policy-sandbox.md +1 -1
  37. package/docs/pricing-budget.md +1 -1
  38. package/docs/quickstart.md +2 -2
  39. package/docs/repl.md +6 -2
  40. package/docs/security-model.md +1 -1
  41. package/docs/security.md +1 -1
  42. package/docs/skills.md +2 -2
  43. package/docs/terminal.md +9 -5
  44. package/docs/tools.md +1 -1
  45. package/package.json +35 -5
  46. package/src/app/session.ts +261 -15
  47. package/src/app/tool-layer.ts +94 -7
  48. package/src/daemon/approvals.ts +361 -0
  49. package/src/daemon/capability.ts +145 -0
  50. package/src/daemon/children.ts +142 -0
  51. package/src/daemon/client.ts +267 -0
  52. package/src/daemon/control.ts +350 -0
  53. package/src/daemon/discovery.ts +234 -0
  54. package/src/daemon/feed.ts +155 -0
  55. package/src/daemon/framing.ts +94 -0
  56. package/src/daemon/host.ts +316 -0
  57. package/src/daemon/protocol.ts +217 -0
  58. package/src/daemon/resource.ts +170 -0
  59. package/src/daemon/sanitize.ts +57 -0
  60. package/src/daemon/server.ts +627 -0
  61. package/src/daemon/store.ts +317 -0
  62. package/src/daemon/subscription.ts +270 -0
  63. package/src/daemon/telemetry.ts +81 -0
  64. package/src/hooks/run.ts +12 -1
  65. package/src/lib/atomic-write.ts +29 -3
  66. package/src/lib/db-path.ts +26 -0
  67. package/src/lib/keystore.ts +544 -42
  68. package/src/lib/net.ts +43 -1
  69. package/src/lib/safe-open.ts +116 -1
  70. package/src/lib/session-id.ts +15 -0
  71. package/src/lsp/client.ts +123 -5
  72. package/src/mcp/client.ts +139 -17
  73. package/src/mcp/server.ts +177 -50
  74. package/src/mcp/transport.ts +16 -19
  75. package/src/memory/vector.ts +770 -55
  76. package/src/policy/allowlist.ts +14 -2
  77. package/src/policy/bash-guard.ts +105 -10
  78. package/src/policy/compaction.ts +82 -5
  79. package/src/policy/consequence-engine.ts +220 -0
  80. package/src/policy/context.ts +132 -0
  81. package/src/policy/executor.ts +187 -121
  82. package/src/policy/no-progress.ts +559 -0
  83. package/src/policy/permission.ts +4 -8
  84. package/src/policy/pricing.ts +17 -3
  85. package/src/policy/scrub.ts +69 -2
  86. package/src/policy/tool-contract.ts +515 -0
  87. package/src/policy/usage.ts +310 -24
  88. package/src/policy/verifier.ts +6 -3
  89. package/src/policy/work-mode.ts +182 -0
  90. package/src/presentation/adapter.ts +533 -26
  91. package/src/presentation/events.ts +151 -0
  92. package/src/presentation/model.ts +180 -27
  93. package/src/presentation/projection.ts +858 -0
  94. package/src/presentation/reducer.ts +645 -310
  95. package/src/presentation/store.ts +12 -7
  96. package/src/providers/anthropic.ts +18 -10
  97. package/src/providers/responses.ts +17 -7
  98. package/src/runtime/capability.ts +409 -0
  99. package/src/runtime/child-execution.ts +274 -0
  100. package/src/runtime/composition.ts +958 -0
  101. package/src/runtime/dispatch.ts +591 -0
  102. package/src/runtime/execution-backend.ts +632 -0
  103. package/src/runtime/execution-events.ts +272 -0
  104. package/src/runtime/execution-id.ts +230 -0
  105. package/src/runtime/execution-journal.ts +926 -0
  106. package/src/runtime/execution-kernel.ts +456 -0
  107. package/src/runtime/execution-registry.ts +379 -0
  108. package/src/runtime/process-supervision.ts +276 -0
  109. package/src/runtime/production-execution.ts +551 -0
  110. package/src/runtime/production-runtime.ts +217 -0
  111. package/src/runtime/recovery-safety.ts +70 -0
  112. package/src/runtime/recovery.ts +477 -0
  113. package/src/runtime/runtime-capabilities.ts +179 -0
  114. package/src/runtime/runtime-diagnostics.ts +141 -0
  115. package/src/runtime/runtime-host.ts +365 -0
  116. package/src/runtime/runtime-status-facts.ts +222 -0
  117. package/src/runtime/runtime-status-provider.ts +74 -0
  118. package/src/runtime/runtime-status.ts +459 -0
  119. package/src/runtime/runtime-task-admission.ts +101 -0
  120. package/src/runtime/supervisor.ts +444 -0
  121. package/src/session/authority.ts +168 -0
  122. package/src/session/checkpoint.ts +88 -1
  123. package/src/session/context-adapter.ts +251 -0
  124. package/src/session/context-assembly.ts +242 -0
  125. package/src/session/context-identity.ts +389 -0
  126. package/src/session/context-projection.ts +248 -0
  127. package/src/session/context-selector.ts +500 -0
  128. package/src/session/cross-session-adoption.ts +249 -0
  129. package/src/session/full-history-fold.ts +171 -0
  130. package/src/session/identity.ts +192 -0
  131. package/src/session/journal.ts +805 -102
  132. package/src/session/open-work-intent.ts +732 -0
  133. package/src/session/open-work.ts +767 -0
  134. package/src/session/pending-tools.ts +94 -0
  135. package/src/session/persistence.ts +3569 -127
  136. package/src/session/runtime-header.ts +208 -0
  137. package/src/session/shadow-git.ts +13 -5
  138. package/src/session/verification.ts +1623 -0
  139. package/src/task/assignment.ts +136 -0
  140. package/src/task/autonomous-adapter.ts +168 -0
  141. package/src/task/autonomous-context.ts +630 -0
  142. package/src/task/autonomous-policy.ts +490 -0
  143. package/src/task/continuity.ts +179 -0
  144. package/src/task/execution-cancellation.ts +165 -0
  145. package/src/task/graph-validate.ts +379 -0
  146. package/src/task/graph.ts +305 -0
  147. package/src/task/identity.ts +230 -0
  148. package/src/task/model.ts +417 -0
  149. package/src/task/production-scheduler.ts +293 -0
  150. package/src/task/readiness.ts +229 -0
  151. package/src/task/scheduler-observability.ts +387 -0
  152. package/src/task/scheduler.ts +1197 -0
  153. package/src/task/scheduling-policy.ts +165 -0
  154. package/src/task/session-authority.ts +148 -0
  155. package/src/task/session-ownership.ts +211 -0
  156. package/src/task/store.ts +2887 -0
  157. package/src/task/sync.ts +343 -0
  158. package/src/task/trigger.ts +260 -0
  159. package/src/tools/bash.ts +377 -211
  160. package/src/tools/code_run.ts +1 -1
  161. package/src/tools/delete_file.ts +1 -1
  162. package/src/tools/edit.ts +33 -6
  163. package/src/tools/evidence.ts +30 -0
  164. package/src/tools/git.ts +4 -4
  165. package/src/tools/glob.ts +12 -3
  166. package/src/tools/grep.ts +1 -1
  167. package/src/tools/lsp.ts +4 -4
  168. package/src/tools/mcp_call.ts +11 -4
  169. package/src/tools/memory.ts +153 -18
  170. package/src/tools/move_file.ts +1 -1
  171. package/src/tools/patch.ts +1 -1
  172. package/src/tools/read_file.ts +1 -1
  173. package/src/tools/read_image.ts +1 -1
  174. package/src/tools/submit_result.ts +1 -1
  175. package/src/tools/task.ts +437 -41
  176. package/src/tools/todo.ts +662 -35
  177. package/src/tools/web_fetch.ts +4 -2
  178. package/src/tools/web_search.ts +9 -3
  179. package/src/tools/write_file.ts +1 -1
  180. package/src/ui/assistant/simple.ts +123 -50
  181. package/src/ui/assistant/turn-status.ts +17 -3
  182. package/src/ui/contract.ts +184 -0
  183. package/src/ui/footer.ts +54 -18
  184. package/src/ui/i18n/en.ts +62 -6
  185. package/src/ui/i18n/id.ts +62 -6
  186. package/src/ui/input/prompt-engine.ts +120 -25
  187. package/src/ui/render/errors.ts +39 -1
  188. package/src/ui/render/markdown-table.ts +455 -0
  189. package/src/ui/render/markdown.ts +22 -1
  190. package/src/ui/render/table-grid.ts +184 -0
  191. package/src/ui/render/table.ts +15 -76
  192. package/src/ui/runtime/screen.ts +7 -2
  193. package/src/ui/runtime/statusline.ts +25 -6
  194. package/src/ui/tui/app.ts +598 -133
  195. package/src/ui/tui/transcript.ts +531 -89
  196. package/vendor/minicore/VENDOR.md +1 -1
  197. package/vendor/minicore/src/core/budget.ts +25 -25
  198. package/vendor/minicore/src/core/compact.ts +75 -75
  199. package/vendor/minicore/src/core/errors.ts +59 -59
  200. package/vendor/minicore/src/core/events.ts +73 -73
  201. package/vendor/minicore/src/core/executor.ts +139 -139
  202. package/vendor/minicore/src/core/history.ts +31 -31
  203. package/vendor/minicore/src/core/index.ts +41 -41
  204. package/vendor/minicore/src/core/loop.ts +355 -355
  205. package/vendor/minicore/src/core/permission.ts +22 -22
  206. package/vendor/minicore/src/core/provider.ts +39 -39
  207. package/vendor/minicore/src/core/recovery.ts +35 -35
  208. package/vendor/minicore/src/core/session.ts +327 -327
  209. package/vendor/minicore/src/core/snapshot.ts +146 -146
  210. package/vendor/minicore/src/core/tokens.ts +107 -107
  211. package/vendor/minicore/src/core/tool.ts +115 -115
  212. package/vendor/minicore/src/core/types.ts +50 -50
  213. package/vendor/minicore/src/providers/openai-compat.ts +417 -417
  214. package/AGENTS.md +0 -45
  215. package/PLAN.md +0 -491
  216. package/docs/ARCHITECTURE.html +0 -1248
  217. package/docs/CONTROL-PLANE-MAP.md +0 -139
  218. package/docs/HARNESS.md +0 -150
  219. package/docs/SUMMARY.md +0 -52
  220. package/docs/UI_RENDER_PIPELINE.md +0 -165
  221. package/docs/USAGE.md +0 -11
package/src/tools/bash.ts CHANGED
@@ -76,10 +76,34 @@ interface BackgroundJob {
76
76
  chunks: string[]
77
77
  exitCode: number | null
78
78
  done: boolean
79
+ /**
80
+ * F-03 (P5 §C2): sid kanonik pemilik job — diikat saat start dari instans
81
+ * tool yang sudah di-composition (createBashJobTools), BUKAN dari argumen
82
+ * tool. null = instans default tanpa sid (library/test legacy); jalur
83
+ * produksi selalu terikat sid lewat composition root.
84
+ */
85
+ ownerSid: string | null
79
86
  }
80
87
 
81
88
  const jobs = new Map<string, BackgroundJob>()
82
89
 
90
+ // F-03 (P5 §C2): gerbang akses job. Hanya pemilik (sid sama, null==null untuk
91
+ // jalur legacy) yang boleh inspect/cancel. Kegagalan karena kepemilikan
92
+ // menghasilkan TIDAK ADA — pemanggil tak bisa membedakan "job milik sesi lain"
93
+ // dari "id tak dikenal" (non-disclosing).
94
+ function ownedJob(id: string, callerSid: string | null): BackgroundJob | undefined {
95
+ const j = jobs.get(id)
96
+ if (!j || j.ownerSid !== callerSid) return undefined
97
+ return j
98
+ }
99
+
100
+ // Daftar job hidup yang boleh disebut dalam pesan not-found: HANYA milik
101
+ // pemanggil. Daftar proses-wide (lama) membocorkan id sesi lain — itulah
102
+ // kebocoran yang ditutup C2.
103
+ function liveOwnedIds(callerSid: string | null): string[] {
104
+ return [...jobs.values()].filter((j) => !j.done && j.ownerSid === callerSid).map((j) => j.id)
105
+ }
106
+
83
107
  function reapFinishedJobs(): void {
84
108
  const now = Date.now()
85
109
  for (const [id, j] of jobs) {
@@ -87,6 +111,60 @@ function reapFinishedJobs(): void {
87
111
  }
88
112
  }
89
113
 
114
+ /**
115
+ * Sinyal ke SELURUH grup proses (POSIX). Butuh spawn `detached:true` agar
116
+ * shell jadi group leader — tanpa itu `-pid` bukan grup yang valid dan
117
+ * group-kill jadi tak mungkin (cucu selamat). true = sinyal sampai ke grup.
118
+ */
119
+ function signalProcessGroup(p: ReturnType<typeof spawn>, signal: NodeJS.Signals): boolean {
120
+ if (process.platform === "win32" || p.pid === undefined) return false
121
+ try {
122
+ process.kill(-p.pid, signal)
123
+ return true
124
+ } catch {
125
+ return false
126
+ }
127
+ }
128
+
129
+ /**
130
+ * [Fase 2 / LOOP-INV-10] Eskalasi AWAL yang sopan: SIGTERM ke seluruh process
131
+ * group, bukan hanya shell induk.
132
+ *
133
+ * Kenapa penting: `p.kill("SIGTERM")` hanya menyentuh shell wrapper. Cucu
134
+ * (`node -e`, dev server) tetap hidup, menahan pipe, dan baru mati 2 detik
135
+ * kemudian oleh SIGKILL grup — padahal banyak proses menangani SIGTERM dengan
136
+ * flush/cleanup yang benar bila sinyalnya sampai. Helper ini dipakai sebelum
137
+ * timer eskalasi `killTree` (SIGKILL), di jalur timeout DAN abort.
138
+ *
139
+ * `opts` adalah seam deterministik untuk test: perilaku POSIX dapat diuji di
140
+ * Windows tanpa benar-benar mengirim sinyal ke proses nyata.
141
+ */
142
+ export function signalProcessGroupGraceful(
143
+ pid: number | undefined,
144
+ fallback: { kill: (signal?: NodeJS.Signals | number) => boolean },
145
+ opts: {
146
+ platform?: NodeJS.Platform
147
+ killGroup?: (pid: number, signal: NodeJS.Signals) => boolean
148
+ } = {},
149
+ ): "group" | "fallback" {
150
+ const platform = opts.platform ?? process.platform
151
+ if (platform !== "win32" && typeof pid === "number" && pid > 0) {
152
+ const killGroup =
153
+ opts.killGroup ??
154
+ ((target: number, signal: NodeJS.Signals): boolean => process.kill(target, signal))
155
+ try {
156
+ // Negatif = process group id (shell adalah group leader karena detached).
157
+ if (killGroup(-pid, "SIGTERM")) return "group"
158
+ } catch {
159
+ // Grup sudah hilang / ESRCH: jatuh ke sinyal proses tunggal di bawah.
160
+ }
161
+ }
162
+ try {
163
+ fallback.kill("SIGTERM")
164
+ } catch {}
165
+ return "fallback"
166
+ }
167
+
90
168
  /**
91
169
  * Bunuh proses + seluruh subtree-nya. Di Windows `p.kill()` hanya membunuh
92
170
  * wrapper `cmd.exe` — cucu seperti `node -e "while(true){}"` tetap hidup,
@@ -108,14 +186,10 @@ function killTree(p: ReturnType<typeof spawn>): void {
108
186
  },
109
187
  )
110
188
  if (r.status === 0) return
111
- } else if (p.pid !== undefined) {
189
+ } else if (signalProcessGroup(p, "SIGKILL")) {
112
190
  // POSIX: bunuh seluruh grup proses (shell wrapper + cucu seperti
113
- // `node -e`). Spawn foreground memakai detached:true agar shell jadi
114
- // group leader; kill(-pid) menutup tree-nya.
115
- try {
116
- process.kill(-p.pid, "SIGKILL")
117
- return
118
- } catch {}
191
+ // `node -e`). Spawn memakai detached:true agar shell jadi group leader.
192
+ return
119
193
  }
120
194
  } catch {}
121
195
  try {
@@ -123,11 +197,20 @@ function killTree(p: ReturnType<typeof spawn>): void {
123
197
  } catch {}
124
198
  }
125
199
 
126
- /** Hentikan semua job — dipanggil saat CLI keluar agar tidak ada proses yatim. */
200
+ /**
201
+ * Hentikan semua job — dipanggil saat CLI keluar agar tidak ada proses yatim.
202
+ *
203
+ * WAJIB tree-kill, bukan `proc.kill()`: yang dibunuh cuma wrapper shell,
204
+ * sedangkan cucu (dev server, watcher, `node -e`) tetap hidup, menahan pipe
205
+ * stdio, dan jadi proses yatim yang tak pernah dibersihkan. Modul ini sudah
206
+ * punya killTree() untuk itu — jalur shutdown sebelumnya tak memakainya.
207
+ */
127
208
  export function killAllBackgroundJobs(): void {
128
209
  for (const [id, j] of jobs) {
129
210
  try {
130
- if (!j.done) j.proc.kill("SIGKILL")
211
+ // `!j.done` = jangan sentuh pid yang sudah mati (risiko pid dipakai
212
+ // ulang proses lain → taskkill /pid membunuh proses tak berkaitan).
213
+ if (!j.done) killTree(j.proc)
131
214
  } catch {}
132
215
  jobs.delete(id)
133
216
  }
@@ -137,7 +220,7 @@ export function listBackgroundJobs(): { id: string; cmd: string; done: boolean }
137
220
  return [...jobs.values()].map((j) => ({ id: j.id, cmd: j.cmd, done: j.done }))
138
221
  }
139
222
 
140
- function startBackground(cmd: string, cwd: string | undefined): string {
223
+ function startBackground(cmd: string, cwd: string | undefined, ownerSid: string | null): string {
141
224
  reapFinishedJobs()
142
225
  const live = [...jobs.values()].filter((j) => !j.done).length
143
226
  if (live >= LIMITS.BASH_BACKGROUND_MAX_JOBS) {
@@ -151,6 +234,10 @@ function startBackground(cmd: string, cwd: string | undefined): string {
151
234
  cwd,
152
235
  env: sanitizeSpawnEnv(process.env),
153
236
  stdio: ["ignore", "pipe", "pipe"],
237
+ // detached agar shell jadi group leader → killTree bisa menutup SELURUH
238
+ // grup (POSIX kill(-pid)). Tanpa ini yang bisa dibunuh cuma wrapper shell
239
+ // dan cucu (dev server, watcher) jadi yatim saat bash_kill/shutdown.
240
+ detached: process.platform !== "win32",
154
241
  })
155
242
  const job: BackgroundJob = {
156
243
  id,
@@ -162,6 +249,7 @@ function startBackground(cmd: string, cwd: string | undefined): string {
162
249
  chunks: [],
163
250
  exitCode: null,
164
251
  done: false,
252
+ ownerSid,
165
253
  }
166
254
  proc.stdout?.on("data", (d: Buffer) => {
167
255
  const piece = job.buffer.append("out", d)
@@ -183,224 +271,302 @@ function startBackground(cmd: string, cwd: string | undefined): string {
183
271
  return id
184
272
  }
185
273
 
186
- export const bashTool: Tool = {
187
- name: "bash",
188
- description:
189
- "Run a shell command (default timeout 30s, max output 20k chars, exit code prefixed). Set background:true for long-running processes (dev server, watcher), then collect output via bash_output and stop with bash_kill. Prefer git_status/git_diff/git_log tools over raw `git` commands: raw git executes repository-configured hooks, filters and diff drivers. Destructive, network-exfiltrating, env-dumping, and inline-interpreter commands are blocked. If the shell allowlist denies a command: do NOT retry blindly — file reads/writes belong to read_file/write_file/edit, and a full shell needs the operator to rerun with --allow-all or --sandbox docker. On Windows the shell is cmd.exe (use dir, echo %VAR%, type).",
190
- parameters: {
191
- type: "object",
192
- properties: {
193
- cmd: { type: "string", description: "command to run (shell: cmd.exe on Windows)" },
194
- cwd: {
195
- type: "string",
196
- description: "working directory relative to the workspace (default: workspace root)",
197
- },
198
- timeoutMs: { type: "number", description: "timeout in ms (default 30000)" },
199
- background: {
200
- type: "boolean",
201
- description:
202
- "run without waiting for completion; returns a job id for bash_output/bash_kill",
274
+ // F-03: instans tool bash terikat satu sid pemilik. Instans default (export
275
+ // di bawah) memakai null — jalur library/test tanpa komposisi sid; sesi
276
+ // produksi memakai createBashJobTools(sid) lewat composition root.
277
+ function makeBashTool(ownerSid: string | null): Tool {
278
+ return {
279
+ name: "bash",
280
+ description:
281
+ "Run a shell command (default timeout 30s, max output 20k chars, exit code prefixed). Set background:true for long-running processes (dev server, watcher), then collect output via bash_output and stop with bash_kill. Prefer git_status/git_diff/git_log tools over raw `git` commands: raw git executes repository-configured hooks, filters and diff drivers. Destructive, network-exfiltrating, env-dumping, and inline-interpreter commands are blocked. If the shell allowlist denies a command: do NOT retry blindly — file reads/writes belong to read_file/write_file/edit, and a full shell needs the operator to rerun with --allow-all or --sandbox docker. On Windows the shell is cmd.exe (use dir, echo %VAR%, type).",
282
+ parameters: {
283
+ type: "object",
284
+ properties: {
285
+ cmd: { type: "string", description: "command to run (shell: cmd.exe on Windows)" },
286
+ cwd: {
287
+ type: "string",
288
+ description: "working directory relative to the workspace (default: workspace root)",
289
+ },
290
+ timeoutMs: { type: "number", description: "timeout in ms (default 30000)" },
291
+ background: {
292
+ type: "boolean",
293
+ description:
294
+ "run without waiting for completion; returns a job id for bash_output/bash_kill",
295
+ },
203
296
  },
297
+ required: ["cmd"],
298
+ additionalProperties: false,
204
299
  },
205
- required: ["cmd"],
206
- additionalProperties: false,
207
- },
208
- async execute({ cmd, cwd, timeoutMs, background }, ctx) {
209
- const sessionRoot = (ctx as { cwd?: string }).cwd ?? process.cwd()
210
- const c = cwd as string | undefined
211
- if (c && (isCwdOutsideRoot(c, sessionRoot) || isPathOutsideRoot(c, sessionRoot)))
212
- throw new Error(`cwd outside workspace: ${c}`)
213
- const resolvedCwd = c ? resolvePath(sessionRoot, c) : undefined
214
- const effectiveCwd = resolvedCwd ?? sessionRoot
215
- // Catatan TOCTOU (bug-hunt 2026-09-19, tervalidasi e2e): cek-cwd di atas
216
- // (isCwdOutsideRoot = realpath) menutup varian cwd-form — swap setelah
217
- // titik ini masih menang SEBELUM spawn (jendela mikrodetik pada alur
218
- // executor normal; butuh penulis konkuren jahat). Varian redirect-form
219
- // (`> sub/f` tanpa arg cwd) tak punya recheck saat spawn: shell me-resolve
220
- // symlink — tak bisa ditutup murah dari sini (shell mengikuti symlink by
221
- // design; safe-open O_NOFOLLOW hanya untuk tool file). Mitigasi: --sandbox
222
- // untuk isolasi penuh; lihat permission.ts jail + safe-open.ts.
223
- const timeout = timeoutMs ?? LIMITS.BASH_DEFAULT_TIMEOUT_MS
300
+ async execute({ cmd, cwd, timeoutMs, background }, ctx) {
301
+ const sessionRoot = ctx.cwd ?? process.cwd()
302
+ const c = cwd as string | undefined
303
+ if (c && (isCwdOutsideRoot(c, sessionRoot) || isPathOutsideRoot(c, sessionRoot)))
304
+ throw new Error(`cwd outside workspace: ${c}`)
305
+ const resolvedCwd = c ? resolvePath(sessionRoot, c) : undefined
306
+ const effectiveCwd = resolvedCwd ?? sessionRoot
307
+ // Catatan TOCTOU (bug-hunt 2026-09-19, tervalidasi e2e): cek-cwd di atas
308
+ // (isCwdOutsideRoot = realpath) menutup varian cwd-form — swap setelah
309
+ // titik ini masih menang SEBELUM spawn (jendela mikrodetik pada alur
310
+ // executor normal; butuh penulis konkuren jahat). Varian redirect-form
311
+ // (`> sub/f` tanpa arg cwd) tak punya recheck saat spawn: shell me-resolve
312
+ // symlink — tak bisa ditutup murah dari sini (shell mengikuti symlink by
313
+ // design; safe-open O_NOFOLLOW hanya untuk tool file). Mitigasi: --sandbox
314
+ // untuk isolasi penuh; lihat permission.ts jail + safe-open.ts.
315
+ const timeout = timeoutMs ?? LIMITS.BASH_DEFAULT_TIMEOUT_MS
224
316
 
225
- if (background === true) {
226
- // Sandbox tidak diterapkan di jalur background: container/namespace
227
- // ephemeral mati bersama call-nya, jadi menjanjikan isolasi di sini
228
- // akan menyesatkan. Tolak eksplisit daripada diam-diam tanpa sandbox.
229
- if (process.env.MINICODE_SANDBOX) {
230
- throw new Error(
231
- "background:true is not supported while --sandbox is active (the process must outlive the turn)",
232
- )
317
+ if (background === true) {
318
+ // Sandbox tidak diterapkan di jalur background: container/namespace
319
+ // ephemeral mati bersama call-nya, jadi menjanjikan isolasi di sini
320
+ // akan menyesatkan. Tolak eksplisit daripada diam-diam tanpa sandbox.
321
+ if (process.env.MINICODE_SANDBOX) {
322
+ throw new Error(
323
+ "background:true is not supported while --sandbox is active (the process must outlive the turn)",
324
+ )
325
+ }
326
+ const id = startBackground(cmd as string, resolvedCwd, ownerSid)
327
+ // F-07: echo perintah di-scrub seperti output foreground — command line
328
+ // bisa membawa secret (`curl -H "Authorization: Bearer …"`), dan versi
329
+ // lama menaruhnya mentah ke konteks model.
330
+ return `background job started: ${id}\ncmd: ${scrubSecrets(String(cmd)).slice(0, 200)}\ncollect output: bash_output({ id: "${id}" })`
233
331
  }
234
- const id = startBackground(cmd as string, resolvedCwd)
235
- // F-07: echo perintah di-scrub seperti output foreground — command line
236
- // bisa membawa secret (`curl -H "Authorization: Bearer …"`), dan versi
237
- // lama menaruhnya mentah ke konteks model.
238
- return `background job started: ${id}\ncmd: ${scrubSecrets(String(cmd)).slice(0, 200)}\ncollect output: bash_output({ id: "${id}" })`
239
- }
240
332
 
241
- // Docker sandbox mode — run in ephemeral isolated container
242
- if (process.env.MINICODE_SANDBOX === "docker") {
243
- if (dockerAvailable()) {
244
- const res = await runInDocker(cmd as string, effectiveCwd, {
245
- timeoutMs: timeout,
246
- env: sanitizeSpawnEnv(process.env) as Record<string, string>,
247
- })
248
- const text = scrubSecrets(res.output)
249
- if (res.code !== 0 && res.code !== null)
250
- return `exit ${res.code}\n${capMarked(text, LIMITS.BASH_OUTPUT_MAX_CHARS)}`
251
- return capMarked(text, LIMITS.BASH_OUTPUT_MAX_CHARS)
333
+ // Docker sandbox mode — run in ephemeral isolated container
334
+ if (process.env.MINICODE_SANDBOX === "docker") {
335
+ if (dockerAvailable()) {
336
+ const res = await runInDocker(cmd as string, effectiveCwd, {
337
+ timeoutMs: timeout,
338
+ env: sanitizeSpawnEnv(process.env) as Record<string, string>,
339
+ })
340
+ const text = scrubSecrets(res.output)
341
+ if (res.code !== 0 && res.code !== null)
342
+ return `exit ${res.code}\n${capMarked(text, LIMITS.BASH_OUTPUT_MAX_CHARS)}`
343
+ return capMarked(text, LIMITS.BASH_OUTPUT_MAX_CHARS)
344
+ }
345
+ if (sandboxStrict() || !sandboxExplicitFallbackAllowed()) {
346
+ throw new Error(
347
+ "[sandbox] MINICODE_SANDBOX=docker but docker unavailable — refusing direct execution (explicit sandbox request must not silently downgrade; set MINICODE_SANDBOX_ALLOW_FALLBACK=1 to allow host fallback explicitly)",
348
+ )
349
+ }
350
+ process.stderr.write(
351
+ "[warn] MINICODE_SANDBOX=docker but docker unavailable — falling back to direct execution (explicit MINICODE_SANDBOX_ALLOW_FALLBACK=1)\n",
352
+ )
252
353
  }
253
- if (sandboxStrict() || !sandboxExplicitFallbackAllowed()) {
254
- throw new Error(
255
- "[sandbox] MINICODE_SANDBOX=docker but docker unavailable — refusing direct execution (explicit sandbox request must not silently downgrade; set MINICODE_SANDBOX_ALLOW_FALLBACK=1 to allow host fallback explicitly)",
354
+ // OS-native sandbox (Seatbelt macOS / bubblewrap Linux) — Codex/Gemini-like without Docker
355
+ if (
356
+ process.env.MINICODE_SANDBOX === "os" ||
357
+ process.env.MINICODE_SANDBOX === "seatbelt" ||
358
+ process.env.MINICODE_SANDBOX === "bwrap"
359
+ ) {
360
+ if (osSandboxAvailable()) {
361
+ const res = await runInOsSandbox(cmd as string, effectiveCwd, {
362
+ timeoutMs: timeout,
363
+ env: sanitizeSpawnEnv(process.env) as Record<string, string>,
364
+ })
365
+ const text = scrubSecrets(res.output)
366
+ if (res.code !== 0 && res.code !== null)
367
+ return `exit ${res.code}\n${capMarked(text, LIMITS.BASH_OUTPUT_MAX_CHARS)}`
368
+ return capMarked(text, LIMITS.BASH_OUTPUT_MAX_CHARS)
369
+ }
370
+ if (sandboxStrict() || !sandboxExplicitFallbackAllowed()) {
371
+ throw new Error(
372
+ "[sandbox] OS sandbox unavailable — refusing direct execution (explicit sandbox request must not silently downgrade; set MINICODE_SANDBOX_ALLOW_FALLBACK=1 to allow host fallback explicitly)",
373
+ )
374
+ }
375
+ process.stderr.write(
376
+ "[warn] MINICODE_SANDBOX=os but OS sandbox unavailable — falling back to direct execution (explicit MINICODE_SANDBOX_ALLOW_FALLBACK=1)\n",
256
377
  )
257
378
  }
258
- process.stderr.write(
259
- "[warn] MINICODE_SANDBOX=docker but docker unavailable — falling back to direct execution (explicit MINICODE_SANDBOX_ALLOW_FALLBACK=1)\n",
260
- )
261
- }
262
- // OS-native sandbox (Seatbelt macOS / bubblewrap Linux) — Codex/Gemini-like without Docker
263
- if (
264
- process.env.MINICODE_SANDBOX === "os" ||
265
- process.env.MINICODE_SANDBOX === "seatbelt" ||
266
- process.env.MINICODE_SANDBOX === "bwrap"
267
- ) {
268
- if (osSandboxAvailable()) {
269
- const res = await runInOsSandbox(cmd as string, effectiveCwd, {
270
- timeoutMs: timeout,
271
- env: sanitizeSpawnEnv(process.env) as Record<string, string>,
379
+
380
+ return await new Promise((resolveOut, reject) => {
381
+ const startedAt = Date.now()
382
+ // [Fase 2 / LOOP-INV-07] Dua sebab penghentian yang HARUS dibedakan:
383
+ // timeout internal (efek samping = UNKNOWN) vs abort turn (dibatalkan
384
+ // pemanggil). Sebelumnya keduanya hanya terlihat sebagai `exit null`
385
+ // sehingga model tak punya sinyal untuk berhenti mengulang perintah
386
+ // destruktif yang mungkin sudah setengah berjalan.
387
+ let timedOut = false
388
+ const p = spawn(cmd as string, {
389
+ shell: true,
390
+ // F-24: selalu effectiveCwd (sessionRoot bila arg cwd absen), bukan
391
+ // undefined (= inherit process.cwd()). Jail/permission dievaluasi
392
+ // terhadap sessionRoot — eksekusi harus di direktori yang sama.
393
+ cwd: effectiveCwd,
394
+ env: sanitizeSpawnEnv(process.env),
395
+ signal: ctx.signal,
396
+ // detached agar shell jadi group leader → killTree bisa bunuh
397
+ // seluruh grup (POSIX kill(-pid)). Tanpa ini cucu yatim menahan pipe.
398
+ detached: process.platform !== "win32",
272
399
  })
273
- const text = scrubSecrets(res.output)
274
- if (res.code !== 0 && res.code !== null)
275
- return `exit ${res.code}\n${capMarked(text, LIMITS.BASH_OUTPUT_MAX_CHARS)}`
276
- return capMarked(text, LIMITS.BASH_OUTPUT_MAX_CHARS)
277
- }
278
- if (sandboxStrict() || !sandboxExplicitFallbackAllowed()) {
400
+ const buf = new CappedBuffer(LIMITS.BASH_OUTPUT_MAX_CHARS)
401
+ // Progres inkremental: command panjang (bun test, build) tidak lagi
402
+ // membisu sampai selesai. Event ini opsional bagi UI.
403
+ const emitChunk = (piece: string) => {
404
+ if (!piece) return
405
+ try {
406
+ ctx.emit?.({
407
+ type: "provider:extension",
408
+ kind: "bash-output",
409
+ data: { text: scrubSecrets(piece) },
410
+ })
411
+ } catch {}
412
+ }
413
+ p.stdout.on("data", (d: Buffer) => emitChunk(buf.append("out", d)))
414
+ p.stderr.on("data", (d: Buffer) => emitChunk(buf.append("err", d)))
415
+ p.on("error", reject)
416
+ p.on("close", (code) => {
417
+ const text = buf.text()
418
+ if (timedOut) {
419
+ // Prefix deterministik (parsing oleh jurnal/recovery) + instruksi
420
+ // eksplisit. `isError: true` dicapai dengan reject: kernel
421
+ // mengubah message menjadi ToolResult{isError:true}.
422
+ const elapsed = Date.now() - startedAt
423
+ const partial = text.length > 4000 ? `…${text.slice(-4000)}` : text
424
+ reject(
425
+ new Error(
426
+ `[TOOL_OUTCOME state=UNKNOWN reason=TIMEOUT side_effect_tier=LOCAL_ENV_MUTATION ` +
427
+ `duration_ms=${elapsed} timeout_ms=${timeout}]\n` +
428
+ `Command was cut off by the ${timeout} ms timeout. Its side effects are UNKNOWN ` +
429
+ `(the command may have partially run). Do NOT re-run a side-effecting command ` +
430
+ `before inspecting workspace/process state.\n` +
431
+ (partial
432
+ ? `--- partial output ---\n${partial}`
433
+ : "--- partial output ---\n(none)"),
434
+ ),
435
+ )
436
+ return
437
+ }
438
+ if (code !== 0) resolveOut(`exit ${code}\n${text}`)
439
+ else resolveOut(text)
440
+ })
441
+ let killTimer: ReturnType<typeof setTimeout> | undefined
442
+ const t = setTimeout(() => {
443
+ timedOut = true
444
+ // Windows: SIGTERM hanya membunuh cmd.exe wrapper — cucu (node -e)
445
+ // bisa belum lahir (spawn lambat) atau yatim sambil menahan pipe.
446
+ // Eskalasi taskkill /pid-shell-yang-sudah-mati lalu gagal total.
447
+ // Jadi di win32 langsung tree-kill saat timeout, tanpa jeda.
448
+ // POSIX: SIGTERM ke SELURUH grup dulu (LOOP-INV-10) supaya cucu
449
+ // sempat cleanup; SIGKILL grup menyusul bila 2 detik tak cukup.
450
+ if (process.platform === "win32") killTree(p)
451
+ else signalProcessGroupGraceful(p.pid, p)
452
+ killTimer = setTimeout(() => {
453
+ killTree(p)
454
+ }, 2000)
455
+ }, timeout)
456
+ const onAbort = () => {
457
+ clearTimeout(t)
458
+ if (killTimer) clearTimeout(killTimer)
459
+ if (process.platform === "win32") killTree(p)
460
+ else signalProcessGroupGraceful(p.pid, p)
461
+ killTimer = setTimeout(() => {
462
+ killTree(p)
463
+ }, 1000)
464
+ }
465
+ ctx.signal.addEventListener("abort", onAbort, { once: true })
466
+ p.on("close", () => {
467
+ ctx.signal.removeEventListener("abort", onAbort)
468
+ clearTimeout(t)
469
+ if (killTimer) clearTimeout(killTimer)
470
+ })
471
+ })
472
+ },
473
+ }
474
+ }
475
+
476
+ function makeBashOutputTool(ownerSid: string | null): Tool {
477
+ return {
478
+ name: "bash_output",
479
+ description:
480
+ "Get NEW output from a background job (since the last read). Includes the exit status once it has finished.",
481
+ parameters: {
482
+ type: "object",
483
+ properties: {
484
+ id: { type: "string", description: "job id dari bash background:true" },
485
+ },
486
+ required: ["id"],
487
+ additionalProperties: false,
488
+ },
489
+ async execute({ id }, ctx: ToolContext) {
490
+ ctx.signal.throwIfAborted()
491
+ // F-03: kepemilikan diperiksa SEBELUM output/status apa pun dibocorkan;
492
+ // pesan untuk job sesi lain = persis "tidak dikenal", tanpa daftar id asing.
493
+ const job = ownedJob(String(id), ownerSid)
494
+ if (!job) {
495
+ const live = liveOwnedIds(ownerSid)
279
496
  throw new Error(
280
- "[sandbox] OS sandbox unavailable — refusing direct execution (explicit sandbox request must not silently downgrade; set MINICODE_SANDBOX_ALLOW_FALLBACK=1 to allow host fallback explicitly)",
497
+ `job "${id}" not found${live.length ? ` — active: ${live.join(", ")}` : ""}`,
281
498
  )
282
499
  }
283
- process.stderr.write(
284
- "[warn] MINICODE_SANDBOX=os but OS sandbox unavailable — falling back to direct execution (explicit MINICODE_SANDBOX_ALLOW_FALLBACK=1)\n",
285
- )
286
- }
500
+ const fresh = job.chunks.slice(job.cursor)
501
+ job.cursor = job.chunks.length
502
+ const status = job.done ? `finished (exit ${job.exitCode ?? "?"})` : "running"
503
+ if (fresh.length === 0) return `[${job.id}] ${status} — no new output yet`
504
+ return capMarked(`[${job.id}] ${status}\n${fresh.join("")}`, LIMITS.BASH_OUTPUT_MAX_CHARS)
505
+ },
506
+ }
507
+ }
287
508
 
288
- return await new Promise((resolveOut, reject) => {
289
- const p = spawn(cmd as string, {
290
- shell: true,
291
- // F-24: selalu effectiveCwd (sessionRoot bila arg cwd absen), bukan
292
- // undefined (= inherit process.cwd()). Jail/permission dievaluasi
293
- // terhadap sessionRoot — eksekusi harus di direktori yang sama.
294
- cwd: effectiveCwd,
295
- env: sanitizeSpawnEnv(process.env),
296
- signal: ctx.signal,
297
- // detached agar shell jadi group leader → killTree bisa bunuh
298
- // seluruh grup (POSIX kill(-pid)). Tanpa ini cucu yatim menahan pipe.
299
- detached: process.platform !== "win32",
300
- })
301
- const buf = new CappedBuffer(LIMITS.BASH_OUTPUT_MAX_CHARS)
302
- // Progres inkremental: command panjang (bun test, build) tidak lagi
303
- // membisu sampai selesai. Event ini opsional bagi UI.
304
- const emitChunk = (piece: string) => {
305
- if (!piece) return
509
+ function makeBashKillTool(ownerSid: string | null): Tool {
510
+ return {
511
+ name: "bash_kill",
512
+ description: "Stop a background job (SIGTERM then SIGKILL).",
513
+ parameters: {
514
+ type: "object",
515
+ properties: { id: { type: "string", description: "job id" } },
516
+ required: ["id"],
517
+ additionalProperties: false,
518
+ },
519
+ async execute({ id }, ctx: ToolContext) {
520
+ ctx.signal.throwIfAborted()
521
+ // F-03: sama seperti bash_output — penolakan identik dengan id tak dikenal,
522
+ // tanpa mengungkap status (hidup/selesai) milik sesi lain.
523
+ const job = ownedJob(String(id), ownerSid)
524
+ if (!job) throw new Error(`job "${id}" not found`)
525
+ if (job.done) return `[${job.id}] already finished (exit ${job.exitCode ?? "?"})`
526
+ // Bunuh TREE, bukan cuma wrapper shell: `proc.kill()` di Windows hanya
527
+ // menebas cmd.exe — cucu (watcher, `node -e`) tetap hidup, menahan pipe
528
+ // stdio sehingga job tak pernah selesai dan prosesnya yatim.
529
+ // POSIX diberi jeda SIGTERM ke grup dulu (graceful); Windows langsung
530
+ // tree-kill, karena proc.kill hanya menebas cmd.exe sedangkan
531
+ // taskkill /T butuh akar yang masih hidup.
532
+ if (process.platform === "win32") killTree(job.proc)
533
+ else if (!signalProcessGroup(job.proc, "SIGTERM")) {
306
534
  try {
307
- ctx.emit?.({
308
- type: "provider:extension",
309
- kind: "bash-output",
310
- data: { text: scrubSecrets(piece) },
311
- })
535
+ job.proc.kill("SIGTERM")
312
536
  } catch {}
313
537
  }
314
- p.stdout.on("data", (d: Buffer) => emitChunk(buf.append("out", d)))
315
- p.stderr.on("data", (d: Buffer) => emitChunk(buf.append("err", d)))
316
- p.on("error", reject)
317
- p.on("close", (code) => {
318
- const text = buf.text()
319
- if (code !== 0) resolveOut(`exit ${code}\n${text}`)
320
- else resolveOut(text)
321
- })
322
- let killTimer: ReturnType<typeof setTimeout> | undefined
323
- const t = setTimeout(() => {
324
- // Windows: SIGTERM hanya membunuh cmd.exe wrapper — cucu (node -e)
325
- // bisa belum lahir (spawn lambat) atau yatim sambil menahan pipe.
326
- // Eskalasi taskkill /pid-shell-yang-sudah-mati lalu gagal total.
327
- // Jadi di win32 langsung tree-kill saat timeout, tanpa jeda.
328
- if (process.platform === "win32") killTree(p)
329
- else p.kill("SIGTERM")
330
- killTimer = setTimeout(() => {
331
- killTree(p)
332
- }, 2000)
333
- }, timeout)
334
- const onAbort = () => {
335
- clearTimeout(t)
336
- if (killTimer) clearTimeout(killTimer)
337
- if (process.platform === "win32") killTree(p)
338
- else p.kill("SIGTERM")
339
- killTimer = setTimeout(() => {
340
- killTree(p)
341
- }, 1000)
342
- }
343
- ctx.signal.addEventListener("abort", onAbort, { once: true })
344
- p.on("close", () => {
345
- ctx.signal.removeEventListener("abort", onAbort)
346
- clearTimeout(t)
347
- if (killTimer) clearTimeout(killTimer)
348
- })
349
- })
350
- },
351
- }
352
-
353
- export const bashOutputTool: Tool = {
354
- name: "bash_output",
355
- description:
356
- "Get NEW output from a background job (since the last read). Includes the exit status once it has finished.",
357
- parameters: {
358
- type: "object",
359
- properties: {
360
- id: { type: "string", description: "job id dari bash background:true" },
538
+ setTimeout(() => {
539
+ try {
540
+ if (!job.done) killTree(job.proc)
541
+ } catch {}
542
+ }, 1000)
543
+ return `[${job.id}] stopped`
361
544
  },
362
- required: ["id"],
363
- additionalProperties: false,
364
- },
365
- async execute({ id }, ctx: ToolContext) {
366
- ctx.signal.throwIfAborted()
367
- const job = jobs.get(String(id))
368
- if (!job) {
369
- const live = listBackgroundJobs()
370
- throw new Error(
371
- `job "${id}" not found${live.length ? ` — active: ${live.map((j) => j.id).join(", ")}` : ""}`,
372
- )
373
- }
374
- const fresh = job.chunks.slice(job.cursor)
375
- job.cursor = job.chunks.length
376
- const status = job.done ? `finished (exit ${job.exitCode ?? "?"})` : "running"
377
- if (fresh.length === 0) return `[${job.id}] ${status} — no new output yet`
378
- return capMarked(`[${job.id}] ${status}\n${fresh.join("")}`, LIMITS.BASH_OUTPUT_MAX_CHARS)
379
- },
545
+ }
380
546
  }
381
547
 
382
- export const bashKillTool: Tool = {
383
- name: "bash_kill",
384
- description: "Stop a background job (SIGTERM then SIGKILL).",
385
- parameters: {
386
- type: "object",
387
- properties: { id: { type: "string", description: "job id" } },
388
- required: ["id"],
389
- additionalProperties: false,
390
- },
391
- async execute({ id }, ctx: ToolContext) {
392
- ctx.signal.throwIfAborted()
393
- const job = jobs.get(String(id))
394
- if (!job) throw new Error(`job "${id}" not found`)
395
- if (job.done) return `[${job.id}] already finished (exit ${job.exitCode ?? "?"})`
396
- try {
397
- job.proc.kill("SIGTERM")
398
- } catch {}
399
- setTimeout(() => {
400
- try {
401
- if (!job.done) job.proc.kill("SIGKILL")
402
- } catch {}
403
- }, 1000)
404
- return `[${job.id}] stopped`
405
- },
548
+ // Instans default TANPA sid: jalur library/test lama tetap berfungsi (caller
549
+ // null mengakses job null). Sesi produksi WAJIB memakai createBashJobTools.
550
+ export const bashTool: Tool = makeBashTool(null)
551
+ export const bashOutputTool: Tool = makeBashOutputTool(null)
552
+ export const bashKillTool: Tool = makeBashKillTool(null)
553
+
554
+ /**
555
+ * F-03 (P5 §C2): instans bash/bash_output/bash_kill yang menyandang satu sid
556
+ * pemilik kanonik. Dipanggil composition root (tool-layer untuk sesi CLI,
557
+ * serveMcp dengan contextId per-instance) — sid DIJAHIT sebagai closure saat
558
+ * perakitan, bukan dari argumen tool yang bisa dipalsukan pemanggil.
559
+ */
560
+ export function createBashJobTools(ownerSid: string): {
561
+ bash: Tool
562
+ bashOutput: Tool
563
+ bashKill: Tool
564
+ } {
565
+ if (typeof ownerSid !== "string" || !ownerSid)
566
+ throw new Error("createBashJobTools: ownerSid must be a non-empty canonical session id")
567
+ return {
568
+ bash: makeBashTool(ownerSid),
569
+ bashOutput: makeBashOutputTool(ownerSid),
570
+ bashKill: makeBashKillTool(ownerSid),
571
+ }
406
572
  }