minicode-ai 0.14.5 β†’ 0.15.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 (81) hide show
  1. package/cli/args.ts +20 -8
  2. package/cli/commands/exec.ts +14 -12
  3. package/cli/commands.ts +33 -17
  4. package/cli/index.ts +25 -3
  5. package/cli/router.ts +22 -9
  6. package/cli/setup.ts +27 -8
  7. package/cli/tui.ts +74 -12
  8. package/docs/CONTROL-PLANE-MAP.md +1 -1
  9. package/docs/SUMMARY.md +1 -1
  10. package/docs/TERMINAL_CONTRACT.md +37 -12
  11. package/docs/architecture.md +1 -0
  12. package/docs/choosing-mode.md +3 -1
  13. package/docs/cli.md +7 -5
  14. package/docs/config.md +1 -1
  15. package/docs/environment.md +3 -1
  16. package/docs/getting-started.md +1 -1
  17. package/docs/memory-sessions.md +2 -2
  18. package/docs/repl.md +6 -3
  19. package/docs/security-model.md +3 -1
  20. package/package.json +1 -1
  21. package/scripts/vendor-overlays/minicode-context.patch +1 -1
  22. package/src/app/mentions.ts +1 -1
  23. package/src/app/rag-layer.ts +11 -2
  24. package/src/app/session.ts +104 -7
  25. package/src/constants.ts +1 -1
  26. package/src/daemon/client.ts +11 -6
  27. package/src/daemon/control.ts +2 -9
  28. package/src/daemon/resource.ts +5 -4
  29. package/src/lib/keystore.ts +11 -9
  30. package/src/lib/net.ts +8 -3
  31. package/src/lib/safe-open.ts +29 -5
  32. package/src/lib/trusted-exec.ts +4 -1
  33. package/src/lsp/client.ts +9 -10
  34. package/src/mcp/server.ts +17 -7
  35. package/src/memory/files.ts +2 -1
  36. package/src/memory/vector.ts +25 -16
  37. package/src/policy/bash-guard.ts +33 -11
  38. package/src/policy/bpe.ts +110 -0
  39. package/src/policy/compaction.ts +33 -6
  40. package/src/policy/context-window.ts +19 -0
  41. package/src/policy/context.ts +34 -8
  42. package/src/policy/jail.ts +48 -3
  43. package/src/policy/no-progress.ts +15 -8
  44. package/src/policy/permission.ts +48 -1
  45. package/src/policy/tokenizer-registry.ts +104 -0
  46. package/src/policy/usage.ts +20 -13
  47. package/src/policy/verifier.ts +7 -4
  48. package/src/policy/work-mode.ts +9 -5
  49. package/src/presentation/adapter.ts +7 -3
  50. package/src/presentation/projection.ts +10 -2
  51. package/src/providers/anthropic.ts +13 -3
  52. package/src/providers/responses.ts +16 -6
  53. package/src/runtime/capability.ts +22 -4
  54. package/src/runtime/execution-journal.ts +13 -7
  55. package/src/runtime/production-execution.ts +4 -3
  56. package/src/sandbox/os.ts +4 -3
  57. package/src/session/checkpoint.ts +29 -4
  58. package/src/session/persistence.ts +21 -10
  59. package/src/task/autonomous-context.ts +0 -1
  60. package/src/task/scheduler-observability.ts +1 -0
  61. package/src/tools/git.ts +22 -4
  62. package/src/tools/lsp.ts +10 -8
  63. package/src/tools/web_fetch.ts +6 -2
  64. package/src/tools/web_search.ts +2 -1
  65. package/src/ui/assistant/simple.ts +9 -3
  66. package/src/ui/contract.ts +4 -0
  67. package/src/ui/footer.ts +26 -4
  68. package/src/ui/i18n/en.ts +13 -2
  69. package/src/ui/i18n/id.ts +13 -2
  70. package/src/ui/render/diff.ts +14 -5
  71. package/src/ui/render/highlight.ts +4 -4
  72. package/src/ui/render/markdown.ts +12 -5
  73. package/src/ui/render/session-summary.ts +50 -0
  74. package/src/ui/render/table-grid.ts +134 -6
  75. package/src/ui/render/theme.ts +17 -0
  76. package/src/ui/render/width.ts +89 -2
  77. package/src/ui/runtime/screen.ts +16 -15
  78. package/src/ui/session-state.ts +27 -1
  79. package/src/ui/tui/transcript.ts +90 -18
  80. package/vendor/minicore/VENDOR.md +3 -3
  81. package/vendor/minicore/src/core/loop.ts +1 -1
@@ -137,6 +137,9 @@ export function createResponsesProvider(config: ResponsesConfig): ModelProvider
137
137
  throw new ProviderError("network", e instanceof Error ? e.message : String(e))
138
138
  }
139
139
  if (!res.ok) {
140
+ // Bila request gagal saat membawa previous_response_id, hapus ID tersebut
141
+ // agar turn berikutnya tidak macet permanen pada ID yang kedaluwarsa/ditolak.
142
+ if (prev) lastResponseByModel.delete(modelKey)
140
143
  const txt = await readProviderErrorBody(res).catch(() => "")
141
144
  const retryAfter = res.headers.get("retry-after")
142
145
  if (res.status === 429) {
@@ -375,12 +378,19 @@ export function createResponsesProvider(config: ResponsesConfig): ModelProvider
375
378
  typeof data.arguments === "string" ? data.arguments : "",
376
379
  )
377
380
  }
378
- const text = reasoningText
379
- ? undefined
380
- : ((typeof rawDelta === "string" ? rawDelta : undefined) ??
381
- drec.text ??
382
- drec.content ??
383
- drec.output_text)
381
+ const isToolEvent =
382
+ dtype === "response.output_item.added" ||
383
+ dtype === "response.function_call_arguments.delta" ||
384
+ dtype === "response.function_call_arguments.done" ||
385
+ dtype === "response.output_item.done" ||
386
+ dtype === "function_call"
387
+ const text =
388
+ reasoningText || isToolEvent
389
+ ? undefined
390
+ : ((typeof rawDelta === "string" ? rawDelta : undefined) ??
391
+ drec.text ??
392
+ drec.content ??
393
+ drec.output_text)
384
394
  if (typeof text === "string" && text) yield { type: "text", text }
385
395
  const finish =
386
396
  (data as { finish_reason?: string }).finish_reason ??
@@ -119,8 +119,14 @@ export function normalizeScopePath(path: string): string {
119
119
  if (path.includes("\0")) throw new Error("capability: NUL byte in path")
120
120
  const isWin = process.platform === "win32"
121
121
  let p = path.replace(/\\/g, "/")
122
+ // Pertahankan drive prefix Windows (mis. "C:") agar segmen ".." tidak mem-pop
123
+ // huruf drive keluar dari parts dan menghasilkan path relatif palsu.
124
+ const driveMatch = /^([A-Za-z]:)(?:\/|$)/.exec(p)
125
+ const drivePrefix = driveMatch ? driveMatch[1]! : ""
126
+ const rest = drivePrefix ? p.slice(drivePrefix.length) : p
127
+ const isAbs = drivePrefix !== "" || p.startsWith("/")
122
128
  const parts: string[] = []
123
- for (const seg of p.split("/")) {
129
+ for (const seg of rest.split("/")) {
124
130
  if (seg === "" || seg === ".") continue
125
131
  if (seg === "..") {
126
132
  if (parts.length > 0 && parts[parts.length - 1] !== "..") parts.pop()
@@ -129,8 +135,14 @@ export function normalizeScopePath(path: string): string {
129
135
  }
130
136
  parts.push(seg)
131
137
  }
132
- p = (path.startsWith("/") ? "/" : "") + parts.join("/")
133
- if (p === "") p = "."
138
+ const joined = parts.join("/")
139
+ if (drivePrefix) {
140
+ p = joined ? `${drivePrefix}/${joined}` : drivePrefix
141
+ } else if (isAbs) {
142
+ p = `/${joined}`
143
+ } else {
144
+ p = joined || "."
145
+ }
134
146
  return isWin ? p.toLowerCase() : p
135
147
  }
136
148
 
@@ -138,8 +150,14 @@ export function normalizeScopePath(path: string): string {
138
150
  export function isPathWithin(parentPath: string, childPath: string): boolean {
139
151
  const parent = normalizeScopePath(parentPath)
140
152
  const child = normalizeScopePath(childPath)
153
+ // Segmen ".." yang tersisa berarti child meloloskan diri di atas root leksikal.
154
+ if (/(?:^|\/)\.\.(?:\/|$)/.test(child)) return false
141
155
  if (child === parent) return true
142
- if (parent === ".") return !child.startsWith("..")
156
+ if (parent === ".") {
157
+ // Scope "." (workspace relatif) tidak boleh mencakup path absolut ("/etc", "c:/...").
158
+ if (child.startsWith("/") || /^[a-z]:/i.test(child)) return false
159
+ return !child.startsWith("..")
160
+ }
143
161
  return child.startsWith(parent.endsWith("/") ? parent : `${parent}/`)
144
162
  }
145
163
 
@@ -407,14 +407,16 @@ export function openExecutionJournal(
407
407
  const checkpointFn = opts?.checkpoint
408
408
  let db: Database | null = null
409
409
  let openError: JournalError | null = null
410
- // Statement registry di scope fungsi (bukan blok try): semua pemakai
411
- // (insert/fetch/read/flush/close) berbagi; close() finalize semua agar
412
- // Windows file lock lepas (tanpa ini rm tmp macet EBUSY).
413
- const statements: Statement[] = []
410
+ // Statement cache di scope fungsi (bukan blok try): satu prepared statement
411
+ // per SQL string agar tidak bocor ribuan handle pada jurnal berumur panjang,
412
+ // dan close() mem-finalize semuanya agar Windows file lock lepas.
413
+ const statementMap = new Map<string, Statement>()
414
414
  const prep = (sql: string): Statement => {
415
415
  if (!db) throw new Error("journal closed")
416
+ const cached = statementMap.get(sql)
417
+ if (cached) return cached
416
418
  const stmt = db.prepare(sql)
417
- statements.push(stmt)
419
+ statementMap.set(sql, stmt)
418
420
  return stmt
419
421
  }
420
422
  try {
@@ -882,13 +884,16 @@ export function openExecutionJournal(
882
884
 
883
885
  integrityCheck(): { checked: number; mismatched: number[] } {
884
886
  // Mismatch dilaporkan (seq list), TAK PERNAH dibuang diam-diam.
885
- // Reuse storedEventContent agar definisi konten tunggal (anti-drift).
887
+ // Reuse storedEventContent + storedIntentContent agar definisi konten tunggal.
886
888
  const records = api.readAll()
887
889
  const mismatched: number[] = []
888
890
  for (const rec of records) {
889
891
  if (rec.kind === "event") {
890
892
  if (hashRecord(storedEventContent(rec)) !== rec.recordHash)
891
893
  mismatched.push(rec.journalSequence)
894
+ } else if (rec.kind === "intent") {
895
+ if (hashRecord(storedIntentContent(rec)) !== rec.recordHash)
896
+ mismatched.push(rec.journalSequence)
892
897
  }
893
898
  }
894
899
  return { checked: records.length, mismatched }
@@ -901,11 +906,12 @@ export function openExecutionJournal(
901
906
  close(): void {
902
907
  // Idempoten: ganda aman; post-close append = already-closed eksplisit.
903
908
  // Finalize statements DULU (Windows file lock), baru db.close().
904
- for (const stmt of statements.splice(0)) {
909
+ for (const stmt of statementMap.values()) {
905
910
  try {
906
911
  stmt.finalize()
907
912
  } catch {}
908
913
  }
914
+ statementMap.clear()
909
915
  if (db) {
910
916
  try {
911
917
  db.close()
@@ -324,9 +324,6 @@ export function createProductionExecutionRunner(deps: {
324
324
  }
325
325
  const executionId = record.executionId
326
326
  m.admitted++
327
- // Parent lineage (M7): turn anak WAJIB menunjuk turn ini sebagai
328
- // parentExecutionId, bukan menjadi akar sendiri.
329
- if (request.kind === "turn") currentParentExecutionId.value = executionId
330
327
 
331
328
  // Bukti durable: intent dispatch ditulis SETELAH admission sukses dan
332
329
  // DITUNGGU, jadi redelivery lintas proses bisa dibuktikan (bukan
@@ -365,6 +362,10 @@ export function createProductionExecutionRunner(deps: {
365
362
  record,
366
363
  )
367
364
  }
365
+ // Parent lineage (M7): catat sebagai parentExecutionId hanya SETELAH
366
+ // transisi RUNNING komit, agar turn yang ditolak RUNNING tidak menimpa
367
+ // parentExecutionId aktif milik turn sebelumnya.
368
+ if (request.kind === "turn") currentParentExecutionId.value = executionId
368
369
 
369
370
  // track() menutup utang M14: pekerjaan yang masih berjalan saat shutdown
370
371
  // HARUS terdaftar, supaya flush jurnal tak mendahului event terakhirnya.
package/src/sandbox/os.ts CHANGED
@@ -87,11 +87,12 @@ export function runInOsSandbox(
87
87
  const timeout = opts.timeoutMs ?? LIMITS.DOCKER_TIMEOUT_MS
88
88
 
89
89
  if (type === "seatbelt") {
90
- // macOS seatbelt - simple deny network profile
90
+ // macOS seatbelt - simple deny network profile (escape \ dan " pada path)
91
+ const escapedAbs = abs.replace(/\\/g, "\\\\").replace(/"/g, '\\"')
91
92
  const profile = `(version 1)
92
93
  (deny default)
93
94
  (allow process-exec)
94
- (allow file-read* file-write* (subpath "${abs}"))
95
+ (allow file-read* file-write* (subpath "${escapedAbs}"))
95
96
  (allow file-read* (subpath "/usr") (subpath "/bin") (subpath "/private/tmp"))
96
97
  (allow sysctl-read)
97
98
  (deny network*)
@@ -111,7 +112,7 @@ export function runInOsSandbox(
111
112
  "--ro-bind",
112
113
  "/lib",
113
114
  "/lib",
114
- "--ro-bind",
115
+ "--ro-bind-try",
115
116
  "/lib64",
116
117
  "/lib64",
117
118
  "--proc",
@@ -6,7 +6,12 @@ import { LIMITS } from "../constants.ts"
6
6
  import { atomicWriteText } from "../lib/atomic-write.ts"
7
7
  import { GIT_SAFE_BASE } from "../lib/git-hardening.ts"
8
8
  import { sanitizeSessionPart } from "../lib/session-id.ts"
9
- import { isPathOutsideRoot } from "../policy/jail.ts"
9
+ import {
10
+ isOwnedState,
11
+ isPathOutsideRoot,
12
+ isRealPathOutsideRoot,
13
+ isSensitive,
14
+ } from "../policy/jail.ts"
10
15
  import { appendUndoMarker, loadJournal } from "./journal.ts"
11
16
  import { diffTrees, ephemeralTree, isGitRepo, restoreTree, snapshotTree } from "./shadow-git.ts"
12
17
 
@@ -308,7 +313,23 @@ export async function snapshotWorkspace(
308
313
  .slice(0, limit)
309
314
  if (dirty.length > 0) {
310
315
  const snaps: FileSnapshot[] = []
311
- for (const f of dirty) snaps.push(await captureFileSnapshot(resolve(cwd, f), cwd))
316
+ const seen = new Set<string>()
317
+ for (const f of dirty) {
318
+ const snap = await captureFileSnapshot(resolve(cwd, f), cwd)
319
+ seen.add(snap.path)
320
+ snaps.push(snap)
321
+ }
322
+ if (snaps.length < limit) {
323
+ const extra: string[] = []
324
+ await walkFiles(cwd, "", extra, limit)
325
+ for (const f of extra) {
326
+ if (snaps.length >= limit) break
327
+ const snap = await captureFileSnapshot(resolve(cwd, f), cwd)
328
+ if (seen.has(snap.path)) continue
329
+ seen.add(snap.path)
330
+ snaps.push(snap)
331
+ }
332
+ }
312
333
  return snaps
313
334
  }
314
335
  }
@@ -441,16 +462,20 @@ export async function recordCheckpointFromSnapshots(
441
462
  })
442
463
  }
443
464
 
444
- // Terapkan snapshot dengan jail path: path di luar workspace dilewati.
465
+ // Terapkan snapshot dengan jail path: path di luar workspace atau sensitif dilewati.
445
466
  async function applySnapshots(snapshots: FileSnapshot[], cwd: string): Promise<string[]> {
446
467
  const root = resolve(cwd)
447
468
  const applied: string[] = []
448
469
  for (const snap of snapshots) {
449
470
  const absPath = resolve(root, snap.path)
450
- if (isPathOutsideRoot(absPath, root)) {
471
+ if (isPathOutsideRoot(absPath, root) || isRealPathOutsideRoot(absPath, root)) {
451
472
  applied.push(`${snap.path} (skipped: outside workspace)`)
452
473
  continue
453
474
  }
475
+ if (isSensitive(absPath) || isOwnedState(absPath)) {
476
+ applied.push(`${snap.path} (skipped: protected path)`)
477
+ continue
478
+ }
454
479
  if (snap.content === null) {
455
480
  if (existsSync(absPath)) {
456
481
  await rm(absPath, { force: true }).catch(() => {})
@@ -1344,16 +1344,27 @@ export function purgeExpired(db: Database, now = Date.now()): number {
1344
1344
  // than duplicated for exactly that reason: 6O ADR-9's rule is ONE deletion
1345
1345
  // architecture, so the ordering cannot drift between these two entry points.
1346
1346
  const expiring = db
1347
- .prepare(`SELECT id FROM sessions WHERE COALESCE(updated_at, created_at) < ?`)
1348
- .all(cutoff) as { id: string }[]
1349
-
1350
- const { TaskStore } = require("../task/store.ts") as typeof import("../task/store.ts")
1351
- const cwd = sessionCwdOf(db, expiring)
1352
- const tasks = new TaskStore(cwd)
1353
- for (const row of expiring) {
1354
- // 1. invalidate in-flight executions, 2. remove task rows.
1355
- tasks.bumpSessionIncarnation(row.id)
1356
- tasks.deleteSessionTasks(row.id)
1347
+ .prepare(`SELECT id, cwd FROM sessions WHERE COALESCE(updated_at, created_at) < ?`)
1348
+ .all(cutoff) as { id: string; cwd?: string | null }[]
1349
+
1350
+ if (expiring.length > 0) {
1351
+ const { TaskStore } = require("../task/store.ts") as typeof import("../task/store.ts")
1352
+ const fallbackCwd = sessionCwdOf(db, expiring)
1353
+ const byCwd = new Map<string | undefined, string[]>()
1354
+ for (const row of expiring) {
1355
+ const key = row.cwd || fallbackCwd
1356
+ const list = byCwd.get(key) ?? []
1357
+ list.push(row.id)
1358
+ byCwd.set(key, list)
1359
+ }
1360
+ for (const [cwd, ids] of byCwd) {
1361
+ const tasks = new TaskStore(cwd)
1362
+ for (const sid of ids) {
1363
+ // 1. invalidate in-flight executions, 2. remove task rows.
1364
+ tasks.bumpSessionIncarnation(sid)
1365
+ tasks.deleteSessionTasks(sid)
1366
+ }
1367
+ }
1357
1368
  }
1358
1369
 
1359
1370
  const gone = db
@@ -403,7 +403,6 @@ export class AutonomousExecutionContext {
403
403
  if (this.session === null) await this.initialize()
404
404
  const session = this.session!
405
405
  this.state = "executing"
406
- this.emit({ kind: "turn:started", childSessionId: this.childSessionId })
407
406
 
408
407
  const settle = (r: AutonomousTurnResult): AutonomousTurnResult => {
409
408
  this.state = "settled"
@@ -171,6 +171,7 @@ export class SchedulerObservability {
171
171
  break
172
172
 
173
173
  case "task:execution_completed":
174
+ this.hint = "idle"
174
175
  this.record(`execution finished for ${event.taskId}: ok=${String(event.ok)}`)
175
176
  break
176
177
 
package/src/tools/git.ts CHANGED
@@ -11,7 +11,14 @@ import {
11
11
  gitFilterNeutralizers,
12
12
  } from "../lib/git-hardening.ts"
13
13
  import { resolveTrustedExecutable } from "../lib/trusted-exec.ts"
14
- import { isCwdOutsideRoot, isPathOutsideRoot } from "../policy/jail.ts"
14
+ import {
15
+ isCwdOutsideRoot,
16
+ isOwnedState,
17
+ isOwnedStateReal,
18
+ isPathOutsideRoot,
19
+ isRealPathOutsideRoot,
20
+ isSensitive,
21
+ } from "../policy/jail.ts"
15
22
  import { sanitizeSpawnEnv, scrubSecrets } from "../policy/scrub.ts"
16
23
  import { requireToolCwd } from "./context.ts"
17
24
 
@@ -57,16 +64,22 @@ function runGit(
57
64
  if (s.length > room) truncated = true
58
65
  return cur + s.slice(0, Math.max(0, room))
59
66
  }
67
+ const onAbort = () => p.kill("SIGTERM")
60
68
  p.stdout.on("data", (d) => (out = push(out, d)))
61
69
  p.stderr.on("data", (d) => (err = push(err, d)))
62
- p.on("error", reject)
70
+ p.on("error", (e) => {
71
+ signal.removeEventListener("abort", onAbort)
72
+ reject(e)
73
+ })
63
74
  p.on("close", (code) => {
75
+ signal.removeEventListener("abort", onAbort)
64
76
  const text = scrubSecrets((out + (err ? `\n${err}` : "")).trim())
65
77
  const marked = truncated ? `${text}\n… [git output truncated]` : text
66
78
  if (code !== 0 && !marked) reject(new Error(`git ${args.join(" ")} exit ${code}`))
67
79
  else resolve(marked || `(exit ${code})`)
68
80
  })
69
- signal.addEventListener("abort", () => p.kill("SIGTERM"), { once: true })
81
+ if (signal.aborted) onAbort()
82
+ else signal.addEventListener("abort", onAbort, { once: true })
70
83
  })
71
84
  }
72
85
 
@@ -217,7 +230,12 @@ function assertPaths(paths: unknown, cwd: string | undefined, sessionRoot: strin
217
230
  const out: string[] = []
218
231
  for (const p of paths) {
219
232
  if (typeof p !== "string" || !p.trim()) continue
220
- if (isPathOutsideRoot(p, root)) throw new Error(`path outside workspace: ${p}`)
233
+ if (isPathOutsideRoot(p, root) || isRealPathOutsideRoot(p, root))
234
+ throw new Error(`path outside workspace: ${p}`)
235
+ const abs = resolve(root, p)
236
+ if (isSensitive(p) || isSensitive(abs)) throw new Error(`blocked sensitive file: ${p}`)
237
+ if (isOwnedState(p) || isOwnedState(abs) || isOwnedStateReal(p, root))
238
+ throw new Error(`blocked owned state: ${p}`)
221
239
  out.push(p)
222
240
  }
223
241
  return out
package/src/tools/lsp.ts CHANGED
@@ -21,14 +21,16 @@ const SEVERITY = ["Error", "Warn", "Info", "Hint"]
21
21
  // success ke turn yang sudah dibatalkan.
22
22
  function raceAbort<T>(p: Promise<T>, signal: AbortSignal): Promise<T> {
23
23
  if (signal.aborted) return Promise.reject(signal.reason ?? new Error("aborted"))
24
+ let onAbort: (() => void) | undefined
24
25
  return Promise.race([
25
26
  p,
26
- new Promise<never>((_, rej) =>
27
- signal.addEventListener("abort", () => rej(signal.reason ?? new Error("aborted")), {
28
- once: true,
29
- }),
30
- ),
31
- ])
27
+ new Promise<never>((_, rej) => {
28
+ onAbort = () => rej(signal.reason ?? new Error("aborted"))
29
+ signal.addEventListener("abort", onAbort, { once: true })
30
+ }),
31
+ ]).finally(() => {
32
+ if (onAbort) signal.removeEventListener("abort", onAbort)
33
+ })
32
34
  }
33
35
 
34
36
  function toUri(abs: string): string {
@@ -286,9 +288,9 @@ export const lspWorkspaceSymbolsTool: Tool = {
286
288
  const uri = s.location.uri ?? "?"
287
289
  return `[${kind}] ${s.name}${s.containerName ? ` (${s.containerName})` : ""} β€” ${uri}`
288
290
  })
289
- return capLocations(rows, 50)
291
+ return scrubSecrets(capLocations(rows, 50))
290
292
  } catch (e) {
291
- return `[lsp] ${(e as Error).message}`
293
+ return scrubSecrets(`[lsp] ${(e as Error).message}`)
292
294
  }
293
295
  },
294
296
  }
@@ -77,7 +77,7 @@ export const webFetchTool: Tool = {
77
77
  type: "object",
78
78
  properties: {
79
79
  url: { type: "string", description: "https:// URL to fetch" },
80
- maxChars: { type: "number", description: "max chars to return (default 20000, max 50000)" },
80
+ maxChars: { type: "number", description: "max chars to return (default 8000, max 50000)" },
81
81
  },
82
82
  required: ["url"],
83
83
  additionalProperties: false,
@@ -92,7 +92,11 @@ export const webFetchTool: Tool = {
92
92
  throw new Error(`invalid url: ${u}`)
93
93
  }
94
94
 
95
- const limit = Math.min(Math.max(Number(maxChars) || 20000, 1000), 50000)
95
+ // Default 8000 (bukan 20000): hasil web rakus konteks β€” satu fetch `README`
96
+ // /halaman GitHub bisa 17 KB yang menggelembungkan jendela konteks hingga
97
+ // melampaui batas model. 8000 tetap cukup utk membaca section, jauh lebih
98
+ // hemat agar beberapa fetch beruntun tidak menumpuk jadi ~1M token.
99
+ const limit = Math.min(Math.max(Number(maxChars) || 8000, 1000), 50000)
96
100
  const controller = new AbortController()
97
101
  const timeout = setTimeout(() => controller.abort(new Error("fetch timeout 10s")), 10_000)
98
102
  // Link parent signal β€” selalu pasang listener dulu, cek aborted setelahnya
@@ -40,7 +40,8 @@ export const webSearchTool: Tool = {
40
40
  const controller = new AbortController()
41
41
  const t = setTimeout(() => controller.abort(), 8000)
42
42
  const onAbort = () => controller.abort(ctx.signal.reason)
43
- ctx.signal.addEventListener("abort", onAbort, { once: true })
43
+ if (ctx.signal.aborted) onAbort()
44
+ else ctx.signal.addEventListener("abort", onAbort, { once: true })
44
45
  try {
45
46
  const res = await fetch("https://api.tavily.com/search", {
46
47
  method: "POST",
@@ -279,9 +279,15 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
279
279
  return sanitizeAnsiLine(tagged)
280
280
  }
281
281
 
282
+ const indentThinking = (text: string): string =>
283
+ text
284
+ .split("\n")
285
+ .map((line) => (line ? ` ${line}` : line))
286
+ .join("\n")
287
+
282
288
  const flushReasoningTail = () => {
283
289
  if (reasoningLine) {
284
- wErr(c.muted(`${reasoningLine}\n`))
290
+ wErr(c.thinking(` ${reasoningLine}\n`))
285
291
  reasoningLine = ""
286
292
  }
287
293
  }
@@ -695,7 +701,7 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
695
701
  thinkState = "exp"
696
702
  wErr(c.muted(t("one.thinkOpen")))
697
703
  if (thinkingBuf) {
698
- wErr(c.muted(thinkingBuf))
704
+ wErr(c.thinking(indentThinking(thinkingBuf)))
699
705
  thinkingBuf = ""
700
706
  }
701
707
  }
@@ -707,7 +713,7 @@ export function attachSimpleLogger(bus: UiBus, opts: SimpleOptions = {}): () =>
707
713
  // Sadar-stream (F1) + kebijakan pipa (F2) seperti teks model.
708
714
  reasoningLine += cleanUntrusted(reasoningSan.push(text), !!process.stdout.isTTY)
709
715
  const parts = reasoningLine.split("\n")
710
- for (let i = 0; i < parts.length - 1; i++) wErr(c.muted(`${parts[i]}\n`))
716
+ for (let i = 0; i < parts.length - 1; i++) wErr(c.thinking(` ${parts[i]}\n`))
711
717
  reasoningLine = parts[parts.length - 1] ?? ""
712
718
  }
713
719
  } else {
@@ -273,6 +273,10 @@ export interface PresentationPolicy {
273
273
  ) => ActivityPolicyDescription
274
274
  matchTurn: (turns: UiPresentationTurn[], summary: UiTurnSummary) => UiPresentationTurn | undefined
275
275
  elapsedVisible: (tsStart: number, now: number) => boolean
276
+ /** Marker display status verifikasi β€” keputusan policy (ASCII aman). */
277
+ verificationMark: (verification: UiVerificationDisplay | undefined) => string
278
+ /** Marker display provenans (hanya non-live dirender). */
279
+ provenanceMark: (provenance: UiProvenance | undefined) => string
276
280
  }
277
281
 
278
282
  export interface UiPresentationSnapshot {
package/src/ui/footer.ts CHANGED
@@ -16,6 +16,8 @@ export type TimerHighlight = "seconds" | "minutes" | "hours"
16
16
  export interface FooterStatus {
17
17
  /** Permission mode efektif sesi ini (umumnya AUTO atau ASK). */
18
18
  mode: string
19
+ /** Bila true, bash dibatasi ke allow-list (lapis kapabilitas, bukan mode). */
20
+ strictBash?: boolean
19
21
  /** WorkMode aktif sesi; identitas internal EXECUTE ditampilkan sebagai Build. */
20
22
  workMode?: string
21
23
  model: string
@@ -89,14 +91,27 @@ export function paintWorkMode(workMode?: string, style: ModeLabelStyle = "full")
89
91
  )}`
90
92
  }
91
93
 
92
- /** Permission Mode selalu cyan agar terpisah secara visual dari Work Mode. */
94
+ /** Permission Mode selalu cyan agar terpisah secara visual dari Work Mode.
95
+ * `unrestricted` (full akses, /unrestric): label disembunyikan β€” cukup gembok
96
+ * terbuka πŸ”“ sebagai indikator satu-satunya (lihat paintBashStrict). */
93
97
  export function paintPermissionMode(mode: string, style: ModeLabelStyle = "full"): string {
98
+ if (mode === "unrestricted") return ""
94
99
  const value = titleCaseMode(mode, "Auto")
95
100
  if (style === "value") return c.info(value)
96
101
  const prefix = style === "full" ? "Permission Mode: " : "Permission: "
97
102
  return `${c.gray(prefix)}${c.info(value)}`
98
103
  }
99
104
 
105
+ /** Badge pembatas bash allow-list: gembok selalu tampil β€” terang saat aktif,
106
+ * redup saat nonaktif (lapis kapabilitas, terpisah dari mode persetujuan).
107
+ * Saat `unrestricted` aktif, gembok jadi TERBUKA (πŸ”“) β€” satu-satunya penanda,
108
+ * jadi dirender jelas (bukan redup). */
109
+ export function paintBashStrict(strictBash?: boolean, unrestricted = false): string {
110
+ if (unrestricted) return c.info("πŸ”“")
111
+ const lock = "πŸ”’"
112
+ return strictBash ? c.yellow(lock) : c.faint(lock)
113
+ }
114
+
100
115
  /** Spark glyph: redup saat idle, pulse putih↔abu saat busy (frame genap/ganjil). */
101
116
  function sparkGlyph(frame: number): string {
102
117
  const g = glyphs.thinkingIcon
@@ -173,7 +188,13 @@ export function renderFooter(s: FooterStatus, columns: number): string[] {
173
188
  return `${lead}${paintWorkMode(s.workMode, style)}`
174
189
  }
175
190
  const rightFor = (style: ModeLabelStyle): string =>
176
- [...contextParts, paintPermissionMode(s.mode, style)].join(fieldGap)
191
+ [
192
+ ...contextParts,
193
+ paintPermissionMode(s.mode, style),
194
+ paintBashStrict(s.strictBash, s.mode === "unrestricted"),
195
+ ]
196
+ .filter(Boolean)
197
+ .join(fieldGap)
177
198
  const align = (left: string, right: string): string | undefined => {
178
199
  const leftWidth = displayWidth(left)
179
200
  const rightWidth = displayWidth(right)
@@ -224,15 +245,16 @@ export function renderFooter(s: FooterStatus, columns: number): string[] {
224
245
  // timer/model/CWD/label sebelum konteks; potong konteks lebih dahulu.
225
246
  const workValue = paintWorkMode(s.workMode, "value")
226
247
  const permissionValue = paintPermissionMode(s.mode, "value")
248
+ const strictValue = paintBashStrict(s.strictBash, s.mode === "unrestricted")
227
249
  const shortWorkValue = workValue.trimEnd()
228
- const modeOnly = `${spark} ${shortWorkValue} ${permissionValue}`
250
+ const modeOnly = `${spark} ${shortWorkValue} ${[permissionValue, strictValue].filter(Boolean).join(" ")}`
229
251
  if (ctx || metrics) {
230
252
  const context = [ctx, metrics].filter(Boolean).join(" ")
231
253
  const baseWidth = displayWidth(modeOnly)
232
254
  const contextBudget = target - baseWidth - 2
233
255
  if (contextBudget > 0) {
234
256
  const shortenedContext = truncateToWidth(context, contextBudget, "…")
235
- const withContext = `${spark} ${shortWorkValue} ${c.gray(shortenedContext)} ${permissionValue}`
257
+ const withContext = `${spark} ${shortWorkValue} ${c.gray(shortenedContext)} ${[permissionValue, strictValue].filter(Boolean).join(" ")}`
236
258
  if (displayWidth(withContext) <= target) return [withContext]
237
259
  }
238
260
  }
package/src/ui/i18n/en.ts CHANGED
@@ -137,9 +137,17 @@ export const en = {
137
137
  "help.cKeys":
138
138
  "Keys: Tab work-mode Β· Shift+Tab permission Β· ↑↓ history Β· Mouse wheel/PgUp/PgDn scroll Β· Ctrl+R search Β· Ctrl+D exit",
139
139
  "help.cMore": " /help keys = all shortcuts",
140
+ "help.gGeneral": "General",
141
+ "help.gSession": "Session",
142
+ "help.gModel": "Model",
143
+ "help.gMode": "Mode",
144
+ "help.gView": "View",
145
+ "help.gTask": "Task",
140
146
  "help.kHead": "Keyboard:",
141
147
  "help.k.submit": "submit",
142
148
  "help.k.cycleMode": "cycle work mode",
149
+ "help.k.workMode": "cycle work mode (Build/Plan/Discuss)",
150
+ "help.k.permission": "cycle permission mode (Auto/Ask)",
143
151
  "help.k.history": "prompt history (in picker: navigate)",
144
152
  "help.k.mouse": "scroll transcript with mouse wheel",
145
153
  "help.k.scroll": "scroll transcript with PgUp/PgDn (Shift+ = half page)",
@@ -155,7 +163,7 @@ export const en = {
155
163
  "help.k.compact": "toggle compact/expanded tool output",
156
164
  "help.k.thinking": "toggle expand/minimize thinking output",
157
165
  "help.k.esc": "close dropdown / picker / clear line (busy: abort turn)",
158
- "help.k.ctrlC": "clear line / cancel prompt (TUI turn: use Esc)",
166
+ "help.k.ctrlC": "copy selected text / cancel",
159
167
  "help.k.ctrlD": "exit on empty line",
160
168
  "help.desc.help": "Show commands",
161
169
  "help.desc.provider": "Manage providers",
@@ -173,7 +181,7 @@ export const en = {
173
181
  "help.desc.clear": "Clear transcript",
174
182
  "help.desc.copy": "Copy the last 1–10 turns to clipboard (OSC 52)",
175
183
  "help.desc.history": "Show recent prompt history",
176
- "help.desc.scheduler": "Inspect, trigger, or stop the autonomous scheduler",
184
+ "help.desc.scheduler": "Trigger / inspect / stop the scheduler",
177
185
 
178
186
  // [PHASE 6AB] Operator strings for `/scheduler`. The STATE line itself is
179
187
  // deliberately not localised - see `describeOperatorState`, which the
@@ -230,10 +238,13 @@ export const en = {
230
238
  "tui.workModeLine": "work mode: {m}",
231
239
  "tui.workModeUsage": "usage: /work-mode <DISCUSS|PLAN|BUILD> β€” current: {m}",
232
240
  "tui.workModeUnavailable": "work mode is not available in this session",
241
+ "tui.unrestrictedOn": "πŸ”“ unrestricted mode enabled - full access",
242
+ "tui.unrestrictedOff": "πŸ”“ unrestricted disabled β€” permission mode restored to {m}",
233
243
  "tui.langLine": "lang: {v}",
234
244
  "tui.toolCall": "tool call: {v}",
235
245
  "tui.modelSet": "model: {v}",
236
246
  "tui.thinkingSet": "thinking: {v}",
247
+ "tui.activityFold": "activity: {v}",
237
248
  "tui.sectionsMin": "sections: minimized",
238
249
  "tui.sectionsExp": "sections: expanded",
239
250
  "tui.minUse": "usage: /minimize [on|off]",
package/src/ui/i18n/id.ts CHANGED
@@ -138,9 +138,17 @@ export const id: Record<MsgKey, string> = {
138
138
  "help.cKeys":
139
139
  "Tombol: Tab work-mode Β· Shift+Tab izin Β· ↑↓ riwayat Β· Mouse wheel/PgUp/PgDn gulir Β· Ctrl+R cari Β· Ctrl+D keluar",
140
140
  "help.cMore": " /help tombol = semua pintasan",
141
+ "help.gGeneral": "Umum",
142
+ "help.gSession": "Sesi",
143
+ "help.gModel": "Model",
144
+ "help.gMode": "Mode",
145
+ "help.gView": "Tampilan",
146
+ "help.gTask": "Tugas",
141
147
  "help.kHead": "Papan tombol:",
142
148
  "help.k.submit": "kirim",
143
149
  "help.k.cycleMode": "putar work mode",
150
+ "help.k.workMode": "putar work mode (Build/Plan/Discuss)",
151
+ "help.k.permission": "putar mode izin (Auto/Ask)",
144
152
  "help.k.history": "riwayat prompt (di picker: navigasi)",
145
153
  "help.k.mouse": "gulir transkrip dengan mouse wheel",
146
154
  "help.k.scroll": "gulir transkrip dengan PgUp/PgDn (Shift+ = setengah halaman)",
@@ -156,7 +164,7 @@ export const id: Record<MsgKey, string> = {
156
164
  "help.k.compact": "alihkan output tool ringkas/penuh",
157
165
  "help.k.thinking": "alihkan thinking bentang/ringkas",
158
166
  "help.k.esc": "tutup dropdown/picker/hapus baris (busy: batalkan turn)",
159
- "help.k.ctrlC": "hapus baris / batalkan prompt (turn TUI: pakai Esc)",
167
+ "help.k.ctrlC": "salin teks terpilih / batalkan",
160
168
  "help.k.ctrlD": "keluar saat baris kosong",
161
169
  "help.desc.help": "Tampilkan perintah",
162
170
  "help.desc.provider": "Kelola penyedia",
@@ -174,7 +182,7 @@ export const id: Record<MsgKey, string> = {
174
182
  "help.desc.clear": "Bersihkan transkrip",
175
183
  "help.desc.copy": "Salin 1–10 turn terakhir ke clipboard (OSC 52)",
176
184
  "help.desc.history": "Tampilkan riwayat prompt",
177
- "help.desc.scheduler": "Periksa, picu, atau hentikan scheduler otonom",
185
+ "help.desc.scheduler": "Picu / periksa / hentikan scheduler",
178
186
 
179
187
  // [PHASE 6AB] Operator strings for `/scheduler`.
180
188
  "sched.usage": "pakai: /scheduler [status|run|stop]",
@@ -231,10 +239,13 @@ export const id: Record<MsgKey, string> = {
231
239
  "tui.workModeLine": "mode kerja: {m}",
232
240
  "tui.workModeUsage": "pemakaian: /work-mode <DISCUSS|PLAN|BUILD> β€” aktif: {m}",
233
241
  "tui.workModeUnavailable": "work mode tidak tersedia di sesi ini",
242
+ "tui.unrestrictedOn": "πŸ”“ mode unrestricted aktif - akses penuh",
243
+ "tui.unrestrictedOff": "πŸ”“ unrestricted nonaktif β€” mode izin kembali ke {m}",
234
244
  "tui.langLine": "lang: {v}",
235
245
  "tui.toolCall": "pemanggilan tool: {v}",
236
246
  "tui.modelSet": "model: {v}",
237
247
  "tui.thinkingSet": "thinking: {v}",
248
+ "tui.activityFold": "aktivitas: {v}",
238
249
  "tui.sectionsMin": "bagian: diminimalkan",
239
250
  "tui.sectionsExp": "bagian: dibuka",
240
251
  "tui.minUse": "pakai: /minimize [on|off]",