minicode-ai 0.9.26 → 0.9.27

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.9.27] - 2026-09-18 — Upstream sync: 10 seam kernel dihilirkan, vendor nol-divergensi
6
+
7
+ ### Fixed
8
+ - **Seluruh seam vendor dihilirkan ke MiniCore (nol divergensi tersisa)**: 10 seam yang dulu hanya ada di `vendor/minicore` kini menjadi kemampuan kernel generik di upstream (`7b546d1` + `ae9d1be`, sudah push): plumbing `cwd` + `permissionMode` (string/getter live, resolve per turn), seed `turnCount`/`stepCount`, side-map `provider_meta`/`thought_signature` + knob `reasoningEffort`, `describeDenial` opsional, estimasi sadar-gambar + `estimateSessionContext` + getter `Session.contextTokens`, dan flag kompaksi terpisah `compactedForBudget`/`compactedForRecovery`. `bun run vendor:minicore` + `bun run vendor:check` kini hijau (`sinkron, 19 file`) dengan kedua worktree bersih — tanpa menghapus perubahan, tanpa force-push.
9
+ - **Cap `retryAfter` upstream terserap**: `minicore@1eceea9` (cap 30 dtk di `recovery.ts`) di-fast-forward sebelum hilirkan — penutup lapis-app (`cappedRecovery` + router) kini redundan dengan kernel, bukan divergen.
10
+ - **Label reason kompaksi digenerikkan (catatan migrasi)**: `context:compacted` reason jalur policy kini `pressure:<p>` / `pressure:<p>:no-op` (dulu `budget:<…>`); `recovery` tetap. Semantik utuh (flag terpisah + `:no-op` tetap ada), prefix `pressure:` sama dengan yang dipakai `BudgetPolicy` kernel — listener yang match prefix `pressure:` yang lama tetap jalan; yang match `budget:` harus pindah. Tidak ada test/layar yang mengunci string lama (`simple.ts` interpolasi generik; `control-plane.test.ts` menguji perilaku, hijau tanpa perubahan).
11
+
12
+ ### Changed
13
+ - **Vendor provenance diregenerasi**: `VENDOR.md` kini pin `ae9d1be` (19 file, hash baru, tanpa daftar seam — tidak ada yang tersisa), worktree dinormalisasi LF sesuai `.gitattributes`, `docs/ARCHITECTURE.html` (pill `v0.9.27`, pin kernel) + `docs/CONTROL-PLANE-MAP.md` (reason generik) diselaraskan.
14
+ - Artefak AI/workbench sibling (`.workbuddy-ai/`, `outputs/`) di-backup di luar repo dan tidak ikut ke upstream — bukan source, bukan patch.
15
+
5
16
  ## [0.9.26] - 2026-09-17 — Rename paket npm: `minicode-ai`
6
17
 
7
18
  ### Changed
@@ -464,7 +464,7 @@ footer.site .spacer { flex: 1; }
464
464
  <span class="mi">search</span><span>Cari modul, simbol, env…</span><kbd>Ctrl K</kbd>
465
465
  </div>
466
466
  <div class="top-actions">
467
- <span class="vpill hide-m">v0.9.24 · Bun-only · 0 deps</span>
467
+ <span class="vpill hide-m">v0.9.27 · Bun-only · 0 deps</span>
468
468
  <button class="iconbtn" id="themeBtn" aria-label="Ganti tema terang/gelap" title="Ganti tema"><span class="mi">dark_mode</span></button>
469
469
  </div>
470
470
  </header>
@@ -543,7 +543,7 @@ footer.site .spacer { flex: 1; }
543
543
  <div class="meta">
544
544
  <span class="pill blue"><span class="dot"></span>entry: cli/index.ts</span>
545
545
  <span class="pill green"><span class="dot"></span>37 tool bawaan</span>
546
- <span class="pill">kernel 05fc595a · lihat vendor/minicore/VENDOR.md</span>
546
+ <span class="pill">kernel ae9d1be · lihat vendor/minicore/VENDOR.md</span>
547
547
  </div>
548
548
 
549
549
  <div class="card-grid">
@@ -578,7 +578,7 @@ footer.site .spacer { flex: 1; }
578
578
  <div class="layer">
579
579
  <div class="lnum">3</div>
580
580
  <div><div class="ltitle">Kernel MiniCore <span class="chip c3">L3</span></div>
581
- <div class="lpath">vendor/minicore/ · pin 05fc595a</div></div>
581
+ <div class="lpath">vendor/minicore/ · pin ae9d1be</div></div>
582
582
  <div class="ldesc">Loop agen inti. Beku: hanya seam aditif yang boleh diubah (<code>compactAsync</code>, <code>initialMessages</code>, <code>cwd</code>); sinkron via <code>bun run vendor:minicore</code>, cek via <code>bun run vendor:check</code>.</div>
583
583
  </div>
584
584
  </div>
@@ -869,7 +869,7 @@ export const kalkulatorTool: Tool = {
869
869
  <ol>
870
870
  <li><code>bun run vendor:minicore</code> — tarik upstream ke vendor/.</li>
871
871
  <li><code>bun run vendor:check</code> — pastikan vendor == pin di dokumentasi.</li>
872
- <li>Hanya seam aditif yang boleh ditambal (<code>compactAsync</code>, <code>initialMessages</code>, <code>cwd</code>); sisanya upstream.</li>
872
+ <li>Seam lokal: tidak ada yang tersisa (0.9.27 menghilirkan semuanya: <code>cwd</code>, <code>permissionMode</code>, <code>provider_meta</code>, <code>reasoningEffort</code>, <code>describeDenial</code>, estimasi sadar-gambar, <code>estimateSessionContext</code>/<code>contextTokens</code>, flag kompaksi ganda) — perubahan kernel = PR ke upstream lalu sync ulang, bukan tambal vendor.</li>
873
873
  </ol>
874
874
  <div class="guard">guard: perubahan kernel wajib lolos seluruh gate (§6) + bench smoke supaya loop tidak regresi.</div>
875
875
  </div>
@@ -1039,7 +1039,7 @@ bun run bench # benchmark loop agen</pre></div>
1039
1039
  <footer class="site">
1040
1040
  <span>Minicode · Peta struktur hidup — terminal contract FROZEN (<a href="TERMINAL_CONTRACT.md">docs/TERMINAL_CONTRACT.md</a>)</span>
1041
1041
  <span class="spacer"></span>
1042
- <span>v0.9.24 · diperbarui 2026-09-17</span>
1042
+ <span>v0.9.27 · diperbarui 2026-09-18</span>
1043
1043
  </footer>
1044
1044
 
1045
1045
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "minicode-ai",
3
- "version": "0.9.26",
3
+ "version": "0.9.27",
4
4
  "description": "Coding agent CLI built on the frozen MiniCore runtime — tools, MCP, LSP, sandbox, shadow-git checkpoints",
5
5
  "type": "module",
6
6
  "private": false,
@@ -13,10 +13,16 @@
13
13
  "agent",
14
14
  "cli",
15
15
  "coding-agent",
16
+ "coding-assistant",
17
+ "terminal",
16
18
  "llm",
19
+ "llm-agent",
17
20
  "mcp",
18
21
  "lsp",
19
- "bun"
22
+ "bun",
23
+ "openai",
24
+ "anthropic",
25
+ "ollama"
20
26
  ],
21
27
  "homepage": "https://github.com/startupmini/minicode#readme",
22
28
  "repository": {
@@ -78,6 +84,7 @@
78
84
  "web:build": "bun scripts/build-web.ts",
79
85
  "web:serve": "bun --hot scripts/web-serve.ts",
80
86
  "web:check": "bun scripts/web-check.ts",
87
+ "web:indexnow": "bun scripts/web-indexnow.ts",
81
88
  "web:vitals": "bun scripts/web-vitals.ts"
82
89
  },
83
90
  "dependencies": {},
@@ -3,27 +3,9 @@
3
3
  Salinan kernel MiniCore agar `bun install` tidak membutuhkan clone sibling
4
4
  `../minicore`. Sumber kebenaran tetap repo minicore.
5
5
 
6
- - source commit: `05fc595ad07ccbf3c85d9645948a0621bdce0353`
6
+ - source commit: `ae9d1be362d24b685f83858f65ee12cbfa3ca75a`
7
7
  - files: 19
8
- - hash: `0e7bf8d16a31d34d`
9
- - seam aditif lokal (belum ada di upstream — JANGAN sync membabi buta,
10
- `bun run vendor:minicore` akan MENGHAPUSnya): `cwd` + `permissionMode`
11
- (session→loop→executor→ToolContext), `turnCount`/`stepCount` seed,
12
- `provider_meta`/`thought_signature` side-map + `reasoningEffort` knob di
13
- openai-compat, `describeDenial` opsional di PermissionHandler + alasan
14
- deny di executor (`permission denied: <reason>`; tanpa method = pesan
15
- polos seperti dulu), estimasi token sadar-gambar di tokens.ts
16
- (`estimateImageTokens` + `estimateMessage` hitung byte gambar alih-alih
17
- placeholder/JSON-blowup). Kontrak control-plane Phase 6: `estimateSessionContext`
18
- (tokens.ts — satu sumber angka konteks untuk loop + Session getter),
19
- `Session.contextTokens` getter (session.ts — ekspos ke driver/UI/budget),
20
- flag kompaksi terpisah `compactedForBudget`/`compactedForRecovery` + event
21
- `context:compacted` reason `budget:<pressure>`/`budget:<pressure>:no-op`/`recovery`
22
- (loop.ts — dulu flag tunggal mengaburkan dua semantics: kompaksi budget
23
- membakar satu-satunya retry recovery). Berkas tersentuh: `src/core/{session,loop,executor,tool,permission,tokens}.ts`,
24
- `src/providers/openai-compat.ts`. (Kernel upstream 1eceea9 punya cap
25
- retryAfter sendiri; vendor ini belum mengambilnya — cap ditutup lapis-app
26
- minicode.) Hilirkan dulu ke repo minicore, baru sync ulang.
8
+ - hash: `96bcd6f7b8b62a4e`
27
9
 
28
10
  Perbarui dengan `bun run vendor:minicore` (butuh `../minicore`).
29
11
  CI memverifikasi kesinkronan lewat `bun run vendor:check`.
@@ -56,9 +56,9 @@ export async function runCall(call: ToolCall, deps: ExecutorDeps): Promise<ToolR
56
56
  }
57
57
  throwIfAborted(deps.signal);
58
58
  if (decision === "deny") {
59
- // Additive seam (minicode): alasan deny opsional dari handler agar
60
- // observasi model actionable ("permission denied: bash-guard: ...").
61
- // describeDenial tak boleh menggagalkan denial itu sendiri — bungkus.
59
+ // Optional handler diagnostic, surfaced so the model observes an
60
+ // actionable reason ("permission denied: <reason>"). Diagnostic-only:
61
+ // describeDenial must never fail the denial itself — hence the guard.
62
62
  let suffix = "";
63
63
  try {
64
64
  const r = await deps.permissions.describeDenial?.(snapshotToolCall(safeCall));
@@ -10,8 +10,8 @@ import type { ToolSchema } from "./tool.ts";
10
10
  import type { ToolCall, ToolResult } from "./types.ts";
11
11
  import type { SessionInternal, Step, TurnResult } from "./session.ts";
12
12
 
13
- /** Resolve mode permission sesi untuk deps turn ini (string langsung atau
14
- * getter live). Tak pernah melempar — gagal = undefined. */
13
+ /** Resolve the session permission mode for this turn's deps (a plain
14
+ * string or a live getter). Never throws — failure resolves to undefined. */
15
15
  function resolvePermissionMode(mode: SessionInternal["permissionMode"]): string | undefined {
16
16
  try {
17
17
  if (typeof mode === "function") {
@@ -40,13 +40,13 @@ export async function executeTurn(
40
40
  const steps: Step[] = [];
41
41
  let stepIndex = 0;
42
42
  let finalText: string | undefined;
43
- // Kontrak kompaksi (Phase 6): DUA flag terpisah — budget compaction dan
44
- // recovery compaction punya semantics berbeda. Flag tunggal dulu mengaburkan
45
- // keduanya: kompaksi budget membakar satu-satunya retry recovery (padahal
46
- // recovery belum pernah dicoba), dan sebaliknya. Recovery flag SELALU diset
47
- // (anti loop abadi: force_compact_and_retry tidak dihitung maxProviderRetries);
48
- // budget flag diset saat kompaksi budget dicoba (kompaksi per-turn, anti
49
- // berulang tiap step O(n)).
43
+ // Two separate flags — policy-path and recovery-path compaction have
44
+ // different semantics. A single flag used to conflate them: a policy
45
+ // compaction burned the one recovery retry (though recovery was never
46
+ // tried), and vice versa. The recovery flag is ALWAYS set (a guard
47
+ // against an infinite loop: force_compact_and_retry is exempt from
48
+ // maxProviderRetries); the policy flag is set when a policy compaction
49
+ // is attempted (once per turn, guarding against per-step O(n) repeats).
50
50
  let compactedForBudget = false;
51
51
  let compactedForRecovery = false;
52
52
 
@@ -65,13 +65,14 @@ export async function executeTurn(
65
65
  const before = s.store.messages.length;
66
66
  await compactStore(s, signal);
67
67
  compactedForBudget = true;
68
- // reason membedakan pemicu + apakah kompaksi benar-benar mengurangi
69
- // (no-op = tidak ada yang bisa dibuang dari messages — operator harus
70
- // tahu bedanya dari fixed overhead, bukan dari kompaksi sia-sia).
68
+ // The reason distinguishes the trigger and whether compaction
69
+ // actually shrank the store (no-op = nothing evictable in messages;
70
+ // reporters must tell that apart from fixed system+schema overhead,
71
+ // which compaction never touches).
71
72
  const reduced = s.store.messages.length < before;
72
73
  s.events.emit({
73
74
  type: "context:compacted",
74
- reason: reduced ? `budget:${pressure}` : `budget:${pressure}:no-op`,
75
+ reason: reduced ? `pressure:${pressure}` : `pressure:${pressure}:no-op`,
75
76
  });
76
77
  pressure = s.budget.evaluate({
77
78
  usedTokens: contextTokens(s),
@@ -138,9 +139,8 @@ export async function executeTurn(
138
139
  }
139
140
  if (completed === "length") {
140
141
  errorMessage = "provider output reached length limit";
141
- // Kontrak (Phase 6): onLength membaca flag RECOVERY — bukan flag
142
- // budget. Dulu flag tunggal membuat kompaksi budget membakar
143
- // retry recovery ini.
142
+ // onLength reads the RECOVERY flag — not the policy flag. A single
143
+ // flag used to let a policy compaction burn this recovery retry.
144
144
  action = s.recovery.onLength(compactedForRecovery);
145
145
  } else if (completed === "error") {
146
146
  action = { type: "throw" };
@@ -168,8 +168,9 @@ export async function executeTurn(
168
168
  if (compactedForRecovery)
169
169
  throw new AgentError("budget_exceeded", errorMessage ?? "context too large", { cause: action });
170
170
  await compactStore(s, signal);
171
- // Recovery flag SELALU diset (no-op pun): force_compact_and_retry
172
- // tidak dihitung maxProviderRetries — no-op berulang = loop abadi.
171
+ // The recovery flag is ALWAYS set (even on no-op):
172
+ // force_compact_and_retry is exempt from maxProviderRetries, so a
173
+ // repeated no-op would otherwise loop forever.
173
174
  compactedForRecovery = true;
174
175
  s.events.emit({ type: "context:compacted", reason: "recovery" });
175
176
  break;
@@ -204,8 +205,8 @@ export async function executeTurn(
204
205
  state: snapshotState(s.state),
205
206
  maxResultTokens: s.toolResultMaxTokens,
206
207
  cwd: s.cwd,
207
- // Resolve per turn agar getter live (mis. ganti mode via Shift+Tab)
208
- // tercermin di ctx tool berikutnya. Gagal resolve = undefined (aman).
208
+ // Resolved per turn so a live getter reflects runtime mode changes
209
+ // in the next tool context. Failed resolution is undefined (safe).
209
210
  permissionMode: resolvePermissionMode(s.permissionMode),
210
211
  };
211
212
  let rawResults: readonly ToolResult[];
@@ -320,8 +321,8 @@ function delay(ms: number, signal: AbortSignal): Promise<void> {
320
321
  }
321
322
 
322
323
  function contextTokens(s: SessionInternal): number {
323
- // Kontrak (Phase 6): single source di tokens.ts `estimateSessionContext` —
324
- // dipakai loop DAN Session getter sehingga tidak ada estimator duplikat.
324
+ // Single source in tokens.ts `estimateSessionContext` — shared by the
325
+ // loop and the Session getter so no duplicate estimator can drift.
325
326
  return estimateSessionContext(s.store, s.system, s.registry.list(), s.estimator);
326
327
  }
327
328
 
@@ -14,11 +14,10 @@ export type Decision = "allow" | "deny";
14
14
  export interface PermissionHandler {
15
15
  check(call: ToolCall, deps: ExecutorDeps): Promise<Decision>;
16
16
  /**
17
- * Additive seam (minicode, bukan upstream): alasan deny terakhir untuk
18
- * `call`, agar model bisa koreksi arah alih-alih retry buta sampai
19
- * max_steps. Dipanggil kernel tepat setelah `check` mengembalikan "deny";
20
- * return undefined/"" = pesan deny polos seperti dulu. Opsional — handler
21
- * lama tanpa method ini tetap jalan tanpa perubahan perilaku.
17
+ * Optional diagnostic for the most recent denial of `call`, so the model
18
+ * can steer instead of retrying blindly until max steps. Invoked right
19
+ * after `check` returns "deny"; returning undefined/"" keeps the plain
20
+ * denial message. Optional — handlers without it behave as before.
22
21
  */
23
22
  describeDenial?(call: ToolCall): Promise<string | undefined> | string | undefined;
24
23
  }
@@ -28,7 +28,9 @@ export const defaultRecoveryPolicy: RecoveryPolicy = {
28
28
  },
29
29
  };
30
30
 
31
+ const RETRY_AFTER_MAX_MS = 30_000;
32
+
31
33
  function backoffDelay(attempt: number, retryAfter?: number): number {
32
- if (retryAfter != null) return retryAfter;
34
+ if (retryAfter != null) return Math.min(retryAfter, RETRY_AFTER_MAX_MS);
33
35
  return Math.min(1_000 * 2 ** (attempt - 1), 8_000);
34
36
  }
@@ -38,10 +38,10 @@ export interface SessionConfig {
38
38
  model?: string;
39
39
  cwd?: string;
40
40
  /**
41
- * Mode permission sesi, diteruskan ke ToolContext tiap turn agar tool
42
- * (mis. delegate_task) bisa menyesuaikan perilaku. String atau getter
43
- * live — getter disarankan bila mode bisa berubah saat runtime.
44
- * Opsional; absen = perilaku lama (ctx.permissionMode undefined).
41
+ * Session permission mode, forwarded to each turn's ToolContext so tools
42
+ * can adapt their behavior. Plain string or live getter — prefer the
43
+ * getter when the mode can change at runtime. Optional; absent preserves
44
+ * the legacy behavior (ctx.permissionMode undefined).
45
45
  */
46
46
  permissionMode?: string | (() => string);
47
47
  /**
@@ -120,11 +120,11 @@ export interface Session {
120
120
  readonly state: Readonly<SessionState>;
121
121
  readonly events: EventBus;
122
122
  /**
123
- * Kontrak control-plane (Phase 6): angka konteks SAAT INI dari sumber
124
- * kebenaran yang sama dengan pressure kernel (messages + system + tools,
125
- * estimator sesi). Satu angka untuk driver/UI/budget — tanpa estimator
126
- * duplikat. O(history) per akses (pola state snapshot); setiap akses
127
- * menghitung ulang atas committed store.
123
+ * Current context size from the same source of truth as the loop's
124
+ * pressure evaluation (messages + system + tools under the session
125
+ * estimator). One number for drivers and UI — no duplicate estimator.
126
+ * O(history) per access (snapshot pattern); recomputed over the
127
+ * committed store on every access.
128
128
  */
129
129
  readonly contextTokens: number;
130
130
  run(input: string, opts?: { signal?: AbortSignal; model?: string }): Promise<TurnResult>;
@@ -207,8 +207,8 @@ export function createSession(config: SessionConfig): Session {
207
207
  get events() {
208
208
  return events;
209
209
  },
210
- // Kontrak (Phase 6): angka dari sumber kebenaran yang sama dengan loop —
211
- // estimateSessionContext (tokens.ts), bukan estimator duplikat.
210
+ // Same source of truth as the loop — estimateSessionContext in
211
+ // tokens.ts — never a duplicate estimator.
212
212
  get contextTokens() {
213
213
  return estimateSessionContext(store, config.system, impl.registry.list(), impl.estimator);
214
214
  },
@@ -18,12 +18,10 @@ export function contentToText(content: Content): string {
18
18
  }
19
19
 
20
20
  /**
21
- * Additive seam (minicode): estimasi token sadar-gambar. Gambar inline
22
- * membawa byte base64 (~bytes/3 token) — placeholder `[image:mime]` lama
23
- * membuat gambar 100k hanya ~15 token (tak terlihat budget → kompaksi tak
24
- * jalan sampai konteks benar-benar jebol). Rumus sama dengan
25
- * src/policy/context.ts estimateImageTokens agar laporan read_image dan
26
- * budget konsisten.
21
+ * Token estimate for inline image bytes. The text placeholder above would
22
+ * price a 100KB image at ~15 tokens, hiding it from budget pressure until
23
+ * the context genuinely overflows — so image parts are priced from their
24
+ * base64 wire size instead.
27
25
  */
28
26
  export function estimateImageTokens(byteLength: number): number {
29
27
  return Math.ceil(Math.ceil((byteLength * 4) / 3) / DEFAULT_CHARS_PER_TOKEN);
@@ -60,9 +58,9 @@ export function estimateMessage(message: Message, est: TokenEstimator): number {
60
58
  return estimateContent(message.content, est) + est(safeStringify(message.toolCalls ?? [])) + est(message.reasoning ?? "");
61
59
  case "tool": {
62
60
  const c = message.content;
63
- // Hasil tool biner (mis. gambar): JSON.stringify Uint8Array meledak
64
- // jadi {"0":..} raksasa → tekanan palsu → kompaksi prematur. Estimasi
65
- // sebagai gambar, bukan string JSON.
61
+ // Binary tool results (e.g. images): JSON.stringify of a Uint8Array
62
+ // explodes into a {"0":..} map, faking pressure and triggering
63
+ // premature compaction. Price it as image bytes instead.
66
64
  if (c instanceof Uint8Array) return estimateImageTokens(c.byteLength);
67
65
  return est(typeof c === "string" ? c : safeStringify(c ?? null));
68
66
  }
@@ -90,12 +88,11 @@ export function estimateSystem(system: string | undefined, est: TokenEstimator):
90
88
  }
91
89
 
92
90
  /**
93
- * Seam kontrak control-plane (Phase 6): SATU sumber angka konteks —
94
- * messages + system + tools, semuanya yang dikirim per request. Dipakai
95
- * loop (pressure) DAN Session getter (ekspos ke driver/UI/budget) sehingga
96
- * tidak ada estimator duplikat untuk kebutuhan tampilan. Fungsi murni atas
97
- * argumen — tidak ada ketergantungan SessionInternal (menghindari circular
98
- * import session↔loop).
91
+ * Single source for the current context size: messages + system + tools —
92
+ * everything sent per request. Shared by the loop (pressure evaluation)
93
+ * and the Session getter (observability) so no duplicate estimator can
94
+ * drift. Pure over its arguments; takes the store shape instead of
95
+ * SessionInternal to avoid a session<->loop circular import.
99
96
  */
100
97
  export function estimateSessionContext(
101
98
  store: { messages: readonly Message[] },
@@ -24,12 +24,10 @@ export interface ToolContext {
24
24
  readonly state: Readonly<SessionState>;
25
25
  readonly cwd?: string;
26
26
  /**
27
- * Mode permission sesi saat tool dipanggil (mis. "auto" | "plan").
28
- * Opsional agar backward-compat; tool yang peduli (mis. delegate_task
29
- * yang harus mengunci sub-agen saat parent read-only) membaca ini
30
- * alih-alih menebak dari teks prompt. Di-resolve per turn dari
31
- * SessionConfig (boleh string atau getter live agar Shift+Tab runtime
32
- * ikut tercermin).
27
+ * Session permission mode at dispatch time (e.g. "auto" | "plan").
28
+ * Optional for backward compatibility; tools that adapt to read-only
29
+ * sessions read this instead of guessing from prompt text. Resolved per
30
+ * turn from SessionConfig (plain string or live getter).
33
31
  */
34
32
  readonly permissionMode?: string;
35
33
  emit(event: AgentEvent): void;
@@ -7,16 +7,16 @@ import type { ModelProvider, ProviderEvent, StreamRequest } from "../core/provid
7
7
  import type { ToolSchema } from "../core/tool.ts";
8
8
  import type { Content, Message } from "../core/types.ts";
9
9
 
10
- // P13 M0.1 (revisi S1) — side-map toolCallId → extra_content (mis. Gemini
11
- // thought_signature). Versi sebelumnya menaruhnya di `args` sebagai
12
- // `__extra_content`, tapi executor menolaknya ("unknown property", semua schema
13
- // additionalProperties:false) sehingga tool call Gemini thinking justru gagal
14
- // validasi. Side-map menjaga args bersih; consume-once + cap agar tak bocor.
10
+ // Provider-metadata side-map: toolCallId -> extra provider payload (e.g.
11
+ // Gemini thought_signature / extra_content). It must NOT travel inside
12
+ // `args` — the executor rejects unknown properties (all schemas are
13
+ // additionalProperties:false), so smuggling it there fails validation.
14
+ // Side-map keeps args clean; consume-once + cap so long sessions can't leak.
15
15
  const providerMetaByCallId = new Map<string, unknown>()
16
16
  function stashProviderMeta(id: string, meta: unknown): void {
17
17
  if (!id || meta == null) return
18
18
  providerMetaByCallId.set(id, meta)
19
- // cap: buang yang terlama bila menumpuk (sesi sangat panjang)
19
+ // Cap: drop the oldest entry when a very long session piles up.
20
20
  if (providerMetaByCallId.size > 500) {
21
21
  const first = providerMetaByCallId.keys().next()
22
22
  if (!first.done) providerMetaByCallId.delete(first.value)
@@ -163,9 +163,9 @@ export function createOpenAICompatProvider(config: OpenAICompatConfig): ModelPro
163
163
  calls.set(index, acc);
164
164
  if (order.indexOf(index) < 0) order.push(index);
165
165
  if (typeof td.id === "string" && td.id) acc.id = td.id;
166
- // P13 M0.1 (S1) — preserve Gemini thought_signature (extra_content)
167
- // verbatim di side-map (BUKAN di args — executor menolak properti
168
- // tak dikenal). Di-echo saat replay history di toMessages.
166
+ // Preserve provider metadata (thought_signature / extra_content)
167
+ // verbatim in the side-map — never in args — for echo on
168
+ // history replay in toMessages.
169
169
  const extra =
170
170
  (td as Record<string, unknown>).extra_content ??
171
171
  (td as Record<string, unknown>).thought_signature ??
@@ -199,8 +199,8 @@ export function createOpenAICompatProvider(config: OpenAICompatConfig): ModelPro
199
199
  args = { raw: acc.args };
200
200
  }
201
201
  }
202
- // P13 M0.1 (S1) — args TETAP bersih (executor validateArgs menolak
203
- // properti tak dikenal); signature disimpan di side-map by call id.
202
+ // Args stay clean (the executor rejects unknown properties);
203
+ // provider metadata is filed in the side-map by call id.
204
204
  const callId = acc.id || `call_${index}`
205
205
  if (acc._extra != null) stashProviderMeta(callId, acc._extra);
206
206
  yield { type: "tool_call", id: callId, name: acc.name, args };
@@ -236,9 +236,9 @@ function toMessages(messages: readonly Message[]): unknown[] {
236
236
  // saat thinking mode aktif, agar multi-turn tidak 400.
237
237
  ...((message as { reasoning?: string }).reasoning ? { reasoning_content: (message as { reasoning?: string }).reasoning } : {}),
238
238
  tool_calls: message.toolCalls?.length
239
- ? message.toolCalls.map((call) => {
240
- // P13 M0.1 (S1) — echo signature dari side-map (consume-once),
241
- // args dikirim apa adanya tanpa kunci siluman.
239
+ ? message.toolCalls.map((call) => {
240
+ // Echo provider metadata from the side-map (consume-once);
241
+ // args are sent exactly as received, with no hidden keys.
242
242
  const extra = takeProviderMeta(call.id)
243
243
  return {
244
244
  id: call.id,