@draht/coding-agent 2026.7.7-1 → 2026.7.11

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 (131) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +2 -2
  3. package/agents/advisor.md +44 -0
  4. package/bin/draht-tools.cjs +1808 -988
  5. package/dist/agents/advisor.md +44 -0
  6. package/dist/cli/args.d.ts.map +1 -1
  7. package/dist/cli/args.js +1 -1
  8. package/dist/cli/args.js.map +1 -1
  9. package/dist/core/agent-session.d.ts +16 -3
  10. package/dist/core/agent-session.d.ts.map +1 -1
  11. package/dist/core/agent-session.js +76 -18
  12. package/dist/core/agent-session.js.map +1 -1
  13. package/dist/core/cache-stats.d.ts +49 -0
  14. package/dist/core/cache-stats.d.ts.map +1 -0
  15. package/dist/core/cache-stats.js +101 -0
  16. package/dist/core/cache-stats.js.map +1 -0
  17. package/dist/core/compaction/compaction.d.ts +1 -2
  18. package/dist/core/compaction/compaction.d.ts.map +1 -1
  19. package/dist/core/compaction/compaction.js +51 -73
  20. package/dist/core/compaction/compaction.js.map +1 -1
  21. package/dist/core/extensions/index.d.ts +1 -1
  22. package/dist/core/extensions/index.d.ts.map +1 -1
  23. package/dist/core/extensions/index.js.map +1 -1
  24. package/dist/core/extensions/loader.d.ts.map +1 -1
  25. package/dist/core/extensions/loader.js +23 -4
  26. package/dist/core/extensions/loader.js.map +1 -1
  27. package/dist/core/extensions/runner.d.ts.map +1 -1
  28. package/dist/core/extensions/runner.js +1 -24
  29. package/dist/core/extensions/runner.js.map +1 -1
  30. package/dist/core/extensions/types.d.ts +9 -9
  31. package/dist/core/extensions/types.d.ts.map +1 -1
  32. package/dist/core/extensions/types.js.map +1 -1
  33. package/dist/core/index.d.ts +1 -1
  34. package/dist/core/index.d.ts.map +1 -1
  35. package/dist/core/index.js.map +1 -1
  36. package/dist/core/model-registry.d.ts +4 -6
  37. package/dist/core/model-registry.d.ts.map +1 -1
  38. package/dist/core/model-registry.js +34 -8
  39. package/dist/core/model-registry.js.map +1 -1
  40. package/dist/core/resource-loader.d.ts.map +1 -1
  41. package/dist/core/resource-loader.js +2 -5
  42. package/dist/core/resource-loader.js.map +1 -1
  43. package/dist/core/settings-manager.d.ts +7 -3
  44. package/dist/core/settings-manager.d.ts.map +1 -1
  45. package/dist/core/settings-manager.js +10 -1
  46. package/dist/core/settings-manager.js.map +1 -1
  47. package/dist/core/slash-commands.d.ts +1 -0
  48. package/dist/core/slash-commands.d.ts.map +1 -1
  49. package/dist/core/slash-commands.js +3 -3
  50. package/dist/core/slash-commands.js.map +1 -1
  51. package/dist/gsd/hook-utils.d.ts.map +1 -1
  52. package/dist/gsd/hook-utils.js +3 -1
  53. package/dist/gsd/hook-utils.js.map +1 -1
  54. package/dist/index.d.ts +1 -1
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js.map +1 -1
  57. package/dist/main.d.ts.map +1 -1
  58. package/dist/main.js +1 -0
  59. package/dist/main.js.map +1 -1
  60. package/dist/modes/interactive/components/footer.d.ts +4 -0
  61. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  62. package/dist/modes/interactive/components/footer.js +1 -1
  63. package/dist/modes/interactive/components/footer.js.map +1 -1
  64. package/dist/modes/interactive/components/oauth-selector.d.ts +3 -1
  65. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  66. package/dist/modes/interactive/components/oauth-selector.js +17 -6
  67. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  68. package/dist/modes/interactive/components/settings-selector.d.ts +2 -0
  69. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  70. package/dist/modes/interactive/components/settings-selector.js +10 -0
  71. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  72. package/dist/modes/interactive/interactive-mode.d.ts +10 -0
  73. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  74. package/dist/modes/interactive/interactive-mode.js +247 -47
  75. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  76. package/dist/modes/interactive/theme/theme-schema.json +3 -4
  77. package/dist/modes/interactive/theme/theme.d.ts +2 -1
  78. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  79. package/dist/modes/interactive/theme/theme.js +8 -4
  80. package/dist/modes/interactive/theme/theme.js.map +1 -1
  81. package/dist/modes/print-mode.d.ts.map +1 -1
  82. package/dist/modes/print-mode.js +1 -1
  83. package/dist/modes/print-mode.js.map +1 -1
  84. package/dist/modes/rpc/rpc-client.d.ts +6 -6
  85. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  86. package/dist/modes/rpc/rpc-client.js +3 -3
  87. package/dist/modes/rpc/rpc-client.js.map +1 -1
  88. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  89. package/dist/modes/rpc/rpc-mode.js +4 -1
  90. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  91. package/dist/prompts/commands/execute-phase.md +2 -2
  92. package/dist/prompts/commands/fix.md +1 -1
  93. package/dist/prompts/commands/map-codebase.md +8 -8
  94. package/dist/prompts/commands/next-milestone.md +1 -0
  95. package/dist/prompts/commands/orchestrate-loop.md +99 -0
  96. package/dist/prompts/commands/orchestrate.md +25 -2
  97. package/dist/prompts/commands/pause-work.md +2 -1
  98. package/dist/prompts/commands/plan-phase.md +1 -0
  99. package/dist/prompts/commands/quick.md +2 -2
  100. package/dist/utils/clipboard-image.d.ts.map +1 -1
  101. package/dist/utils/clipboard-image.js +1 -1
  102. package/dist/utils/clipboard-image.js.map +1 -1
  103. package/docs/custom-provider.md +4 -3
  104. package/docs/extensions.md +15 -10
  105. package/docs/models.md +49 -8
  106. package/docs/rpc.md +15 -5
  107. package/docs/sdk.md +1 -1
  108. package/docs/settings.md +3 -2
  109. package/docs/themes.md +5 -3
  110. package/docs/tui.md +1 -1
  111. package/docs/usage.md +2 -2
  112. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  113. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  114. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  115. package/examples/extensions/preset.ts +2 -2
  116. package/examples/extensions/reload-runtime.ts +2 -2
  117. package/examples/extensions/sandbox/package-lock.json +2 -2
  118. package/examples/extensions/sandbox/package.json +1 -1
  119. package/examples/extensions/with-deps/package-lock.json +2 -2
  120. package/examples/extensions/with-deps/package.json +1 -1
  121. package/examples/sdk/README.md +1 -1
  122. package/package.json +5 -5
  123. package/prompts/commands/execute-phase.md +2 -2
  124. package/prompts/commands/fix.md +1 -1
  125. package/prompts/commands/map-codebase.md +8 -8
  126. package/prompts/commands/next-milestone.md +1 -0
  127. package/prompts/commands/orchestrate-loop.md +99 -0
  128. package/prompts/commands/orchestrate.md +25 -2
  129. package/prompts/commands/pause-work.md +2 -1
  130. package/prompts/commands/plan-phase.md +1 -0
  131. package/prompts/commands/quick.md +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"clipboard-image.js","sourceRoot":"","sources":["../../src/utils/clipboard-image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAOzC,MAAM,0BAA0B,GAAG,CAAC,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,CAAU,CAAC;AAEnG,MAAM,uBAAuB,GAAG,IAAI,CAAC;AACrC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AACrC,MAAM,6BAA6B,GAAG,IAAI,CAAC;AAC3C,MAAM,wBAAwB,GAAG,EAAE,GAAG,IAAI,G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K,GAAG,MAAM,oCAAoC,EAAE,CAAC;IACtD,CAAC;IAED,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC;IACb,CAAC;IAED,2DAA2D;IAC3D,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC/C,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACf,OAAO,IAAI,CAAC;QACb,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;IACnD,CAAC;IAED,OAAO,KAAK,CAAC;AAAA,CACb","sourcesContent":["import { spawnSync } from \"child_process\";\nimport { randomUUID } from \"crypto\";\nimport { readFileSync, unlinkSync } from \"fs\";\nimport { tmpdir } from \"os\";\nimport { join } from \"path\";\n\nimport { clipboard } from \"./clipboard-native.ts\";\nimport { loadPhoton } from \"./photon.ts\";\n\nexport type ClipboardImage = {\n\tbytes: Uint8Array;\n\tmimeType: string;\n};\n\nconst SUPPORTED_IMAGE_MIME_TYPES = [\"image/png\", \"image/jpeg\", \"image/webp\", \"image/gif\"] as const;\n\nconst DEFAULT_LIST_TIMEOUT_MS = 1000;\nconst DEFAULT_READ_TIMEOUT_MS = 3000;\nconst DEFAULT_POWERSHELL_TIMEOUT_MS = 5000;\nconst DEFAULT_MAX_BUFFER_BYTES = 50 * 1024 * 1024;\n\nexport function isWaylandSession(env: NodeJS.ProcessEnv = process.env): boolean {\n\treturn Boolean(env.WAYLAND_DISPLAY) || env.XDG_SESSION_TYPE === \"wayland\";\n}\n\nfunction baseMimeType(mimeType: string): string {\n\treturn mimeType.split(\";\")[0]?.trim().toLowerCase() ?? mimeType.toLowerCase();\n}\n\nexport function extensionForImageMimeType(mimeType: string): string | null {\n\tswitch (baseMimeType(mimeType)) {\n\t\tcase \"image/png\":\n\t\t\treturn \"png\";\n\t\tcase \"image/jpeg\":\n\t\t\treturn \"jpg\";\n\t\tcase \"image/webp\":\n\t\t\treturn \"webp\";\n\t\tcase \"image/gif\":\n\t\t\treturn \"gif\";\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\nfunction selectPreferredImageMimeType(mimeTypes: string[]): string | null {\n\tconst normalized = mimeTypes\n\t\t.map((t) => t.trim())\n\t\t.filter(Boolean)\n\t\t.map((t) => ({ raw: t, base: baseMimeType(t) }));\n\n\tfor (const preferred of SUPPORTED_IMAGE_MIME_TYPES) {\n\t\tconst match = normalized.find((t) => t.base === preferred);\n\t\tif (match) {\n\t\t\treturn match.raw;\n\t\t}\n\t}\n\n\tconst anyImage = normalized.find((t) => t.base.startsWith(\"image/\"));\n\treturn anyImage?.raw ?? null;\n}\n\nfunction isSupportedImageMimeType(mimeType: string): boolean {\n\tconst base = baseMimeType(mimeType);\n\treturn SUPPORTED_IMAGE_MIME_TYPES.some((t) => t === base);\n}\n\n/**\n * Convert unsupported image formats to PNG using Photon.\n * Returns null if conversion is unavailable or fails.\n */\nasync function convertToPng(bytes: Uint8Array): Promise<Uint8Array | null> {\n\tconst photon = await loadPhoton();\n\tif (!photon) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst image = photon.PhotonImage.new_from_byteslice(bytes);\n\t\ttry {\n\t\t\treturn image.get_bytes();\n\t\t} finally {\n\t\t\timage.free();\n\t\t}\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction runCommand(\n\tcommand: string,\n\targs: string[],\n\toptions?: { timeoutMs?: number; maxBufferBytes?: number; env?: NodeJS.ProcessEnv },\n): { stdout: Buffer; ok: boolean } {\n\tconst timeoutMs = options?.timeoutMs ?? DEFAULT_READ_TIMEOUT_MS;\n\tconst maxBufferBytes = options?.maxBufferBytes ?? DEFAULT_MAX_BUFFER_BYTES;\n\n\tconst result = spawnSync(command, args, {\n\t\ttimeout: timeoutMs,\n\t\tmaxBuffer: maxBufferBytes,\n\t\tenv: options?.env,\n\t});\n\n\tif (result.error) {\n\t\treturn { ok: false, stdout: Buffer.alloc(0) };\n\t}\n\n\tif (result.status !== 0) {\n\t\treturn { ok: false, stdout: Buffer.alloc(0) };\n\t}\n\n\tconst stdout = Buffer.isBuffer(result.stdout)\n\t\t? result.stdout\n\t\t: Buffer.from(result.stdout ?? \"\", typeof result.stdout === \"string\" ? \"utf-8\" : undefined);\n\n\treturn { ok: true, stdout };\n}\n\nfunction readClipboardImageViaWlPaste(): ClipboardImage | null {\n\tconst list = runCommand(\"wl-paste\", [\"--list-types\"], { timeoutMs: DEFAULT_LIST_TIMEOUT_MS });\n\tif (!list.ok) {\n\t\treturn null;\n\t}\n\n\tconst types = list.stdout\n\t\t.toString(\"utf-8\")\n\t\t.split(/\\r?\\n/)\n\t\t.map((t) => t.trim())\n\t\t.filter(Boolean);\n\n\tconst selectedType = selectPreferredImageMimeType(types);\n\tif (!selectedType) {\n\t\treturn null;\n\t}\n\n\tconst data = runCommand(\"wl-paste\", [\"--type\", selectedType, \"--no-newline\"]);\n\tif (!data.ok || data.stdout.length === 0) {\n\t\treturn null;\n\t}\n\n\treturn { bytes: data.stdout, mimeType: baseMimeType(selectedType) };\n}\n\nfunction isWSL(env: NodeJS.ProcessEnv = process.env): boolean {\n\tif (env.WSL_DISTRO_NAME || env.WSLENV) {\n\t\treturn true;\n\t}\n\n\ttry {\n\t\tconst release = readFileSync(\"/proc/version\", \"utf-8\");\n\t\treturn /microsoft|wsl/i.test(release);\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * On WSL, the Linux clipboard (Wayland/X11) does not receive image data from\n * Windows screenshots (Win+Shift+S). PowerShell can access the Windows clipboard\n * directly, so we use it as a fallback.\n */\nfunction readClipboardImageViaPowerShell(): ClipboardImage | null {\n\tconst tmpFile = join(tmpdir(), `pi-wsl-clip-${randomUUID()}.png`);\n\n\ttry {\n\t\tconst winPathResult = runCommand(\"wslpath\", [\"-w\", tmpFile], { timeoutMs: DEFAULT_LIST_TIMEOUT_MS });\n\t\tif (!winPathResult.ok) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst winPath = winPathResult.stdout.toString(\"utf-8\").trim();\n\t\tif (!winPath) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst psQuotedWinPath = winPath.replaceAll(\"'\", \"''\");\n\t\tconst psScript = [\n\t\t\t\"Add-Type -AssemblyName System.Windows.Forms\",\n\t\t\t\"Add-Type -AssemblyName System.Drawing\",\n\t\t\t`$path = '${psQuotedWinPath}'`,\n\t\t\t\"$img = [System.Windows.Forms.Clipboard]::GetImage()\",\n\t\t\t\"if ($img) { $img.Save($path, [System.Drawing.Imaging.ImageFormat]::Png); Write-Output 'ok' } else { Write-Output 'empty' }\",\n\t\t].join(\"; \");\n\n\t\tconst result = runCommand(\"powershell.exe\", [\"-NoProfile\", \"-Command\", psScript], {\n\t\t\ttimeoutMs: DEFAULT_POWERSHELL_TIMEOUT_MS,\n\t\t});\n\t\tif (!result.ok) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst output = result.stdout.toString(\"utf-8\").trim();\n\t\tif (output !== \"ok\") {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst bytes = readFileSync(tmpFile);\n\t\tif (bytes.length === 0) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn { bytes: new Uint8Array(bytes), mimeType: \"image/png\" };\n\t} catch {\n\t\treturn null;\n\t} finally {\n\t\ttry {\n\t\t\tunlinkSync(tmpFile);\n\t\t} catch {\n\t\t\t// Ignore cleanup errors.\n\t\t}\n\t}\n}\n\nfunction readClipboardImageViaXclip(): ClipboardImage | null {\n\tconst targets = runCommand(\"xclip\", [\"-selection\", \"clipboard\", \"-t\", \"TARGETS\", \"-o\"], {\n\t\ttimeoutMs: DEFAULT_LIST_TIMEOUT_MS,\n\t});\n\n\tlet candidateTypes: string[] = [];\n\tif (targets.ok) {\n\t\tcandidateTypes = targets.stdout\n\t\t\t.toString(\"utf-8\")\n\t\t\t.split(/\\r?\\n/)\n\t\t\t.map((t) => t.trim())\n\t\t\t.filter(Boolean);\n\t}\n\n\tconst preferred = candidateTypes.length > 0 ? selectPreferredImageMimeType(candidateTypes) : null;\n\tconst tryTypes = preferred ? [preferred, ...SUPPORTED_IMAGE_MIME_TYPES] : [...SUPPORTED_IMAGE_MIME_TYPES];\n\n\tfor (const mimeType of tryTypes) {\n\t\tconst data = runCommand(\"xclip\", [\"-selection\", \"clipboard\", \"-t\", mimeType, \"-o\"]);\n\t\tif (data.ok && data.stdout.length > 0) {\n\t\t\treturn { bytes: data.stdout, mimeType: baseMimeType(mimeType) };\n\t\t}\n\t}\n\n\treturn null;\n}\n\nasync function readClipboardImageViaNativeClipboard(): Promise<ClipboardImage | null> {\n\tif (!clipboard || !clipboard.hasImage()) {\n\t\treturn null;\n\t}\n\n\tconst imageData = await clipboard.getImageBinary();\n\tif (!imageData || imageData.length === 0) {\n\t\treturn null;\n\t}\n\n\tconst bytes = imageData instanceof Uint8Array ? imageData : Uint8Array.from(imageData);\n\treturn { bytes, mimeType: \"image/png\" };\n}\n\nexport async function readClipboardImage(options?: {\n\tenv?: NodeJS.ProcessEnv;\n\tplatform?: NodeJS.Platform;\n}): Promise<ClipboardImage | null> {\n\tconst env = options?.env ?? process.env;\n\tconst platform = options?.platform ?? process.platform;\n\n\tif (env.TERMUX_VERSION) {\n\t\treturn null;\n\t}\n\n\tlet image: ClipboardImage | null = null;\n\n\tif (platform === \"linux\") {\n\t\tconst wsl = isWSL(env);\n\t\tconst wayland = isWaylandSession(env);\n\n\t\tif (wayland || wsl) {\n\t\t\timage = readClipboardImageViaWlPaste() ?? readClipboardImageViaXclip();\n\t\t}\n\n\t\tif (!image && wsl) {\n\t\t\timage = readClipboardImageViaPowerShell();\n\t\t}\n\n\t\tif (!image && !wayland) {\n\t\t\timage = await readClipboardImageViaNativeClipboard();\n\t\t}\n\t} else {\n\t\timage = await readClipboardImageViaNativeClipboard();\n\t}\n\n\tif (!image) {\n\t\treturn null;\n\t}\n\n\t// Convert unsupported formats (e.g., BMP from WSLg) to PNG\n\tif (!isSupportedImageMimeType(image.mimeType)) {\n\t\tconst pngBytes = await convertToPng(image.bytes);\n\t\tif (!pngBytes) {\n\t\t\treturn null;\n\t\t}\n\t\treturn { bytes: pngBytes, mimeType: \"image/png\" };\n\t}\n\n\treturn image;\n}\n"]}
1
+ {"version":3,"file":"clipboard-image.js","sourceRoot":"","sources":["../../src/utils/clipboard-image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAOzC,MAAM,0BAA0B,GAAG,CAAC,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,CAAU,CAAC;AAEnG,MAAM,uBAAuB,GAAG,IAAI,CAAC;AACrC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AACrC,MAAM,6BAA6B,GAAG,IAAI,CAAC;AAC3C,MAAM,wBAAwB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAElD,MAAM,UAAU,gBAAgB,CAAC,GAAG,GAAsB,OAAO,CAAC,GAAG,EAAW;IAC/E,OAAO,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,GAAG,CAAC,gBAAgB,KAAK,SAAS,CAAC;AAAA,CAC1E;AAED,SAAS,YAAY,CAAC,QAAgB,EAAU;IAC/C,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,I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AE,CAAC;YACf,OAAO,IAAI,CAAC;QACb,CAAC;QACD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;IACnD,CAAC;IAED,OAAO,KAAK,CAAC;AAAA,CACb","sourcesContent":["import { spawnSync } from \"child_process\";\nimport { randomUUID } from \"crypto\";\nimport { readFileSync, unlinkSync } from \"fs\";\nimport { tmpdir } from \"os\";\nimport { join } from \"path\";\n\nimport { clipboard } from \"./clipboard-native.ts\";\nimport { loadPhoton } from \"./photon.ts\";\n\nexport type ClipboardImage = {\n\tbytes: Uint8Array;\n\tmimeType: string;\n};\n\nconst SUPPORTED_IMAGE_MIME_TYPES = [\"image/png\", \"image/jpeg\", \"image/webp\", \"image/gif\"] as const;\n\nconst DEFAULT_LIST_TIMEOUT_MS = 1000;\nconst DEFAULT_READ_TIMEOUT_MS = 3000;\nconst DEFAULT_POWERSHELL_TIMEOUT_MS = 5000;\nconst DEFAULT_MAX_BUFFER_BYTES = 50 * 1024 * 1024;\n\nexport function isWaylandSession(env: NodeJS.ProcessEnv = process.env): boolean {\n\treturn Boolean(env.WAYLAND_DISPLAY) || env.XDG_SESSION_TYPE === \"wayland\";\n}\n\nfunction baseMimeType(mimeType: string): string {\n\treturn mimeType.split(\";\")[0]?.trim().toLowerCase() ?? mimeType.toLowerCase();\n}\n\nexport function extensionForImageMimeType(mimeType: string): string | null {\n\tswitch (baseMimeType(mimeType)) {\n\t\tcase \"image/png\":\n\t\t\treturn \"png\";\n\t\tcase \"image/jpeg\":\n\t\t\treturn \"jpg\";\n\t\tcase \"image/webp\":\n\t\t\treturn \"webp\";\n\t\tcase \"image/gif\":\n\t\t\treturn \"gif\";\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\nfunction selectPreferredImageMimeType(mimeTypes: string[]): string | null {\n\tconst normalized = mimeTypes\n\t\t.map((t) => t.trim())\n\t\t.filter(Boolean)\n\t\t.map((t) => ({ raw: t, base: baseMimeType(t) }));\n\n\tfor (const preferred of SUPPORTED_IMAGE_MIME_TYPES) {\n\t\tconst match = normalized.find((t) => t.base === preferred);\n\t\tif (match) {\n\t\t\treturn match.raw;\n\t\t}\n\t}\n\n\tconst anyImage = normalized.find((t) => t.base.startsWith(\"image/\"));\n\treturn anyImage?.raw ?? null;\n}\n\nfunction isSupportedImageMimeType(mimeType: string): boolean {\n\tconst base = baseMimeType(mimeType);\n\treturn SUPPORTED_IMAGE_MIME_TYPES.some((t) => t === base);\n}\n\n/**\n * Convert unsupported image formats to PNG using Photon.\n * Returns null if conversion is unavailable or fails.\n */\nasync function convertToPng(bytes: Uint8Array): Promise<Uint8Array | null> {\n\tconst photon = await loadPhoton();\n\tif (!photon) {\n\t\treturn null;\n\t}\n\n\ttry {\n\t\tconst image = photon.PhotonImage.new_from_byteslice(bytes);\n\t\ttry {\n\t\t\treturn image.get_bytes();\n\t\t} finally {\n\t\t\timage.free();\n\t\t}\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction runCommand(\n\tcommand: string,\n\targs: string[],\n\toptions?: { timeoutMs?: number; maxBufferBytes?: number; env?: NodeJS.ProcessEnv },\n): { stdout: Buffer; ok: boolean } {\n\tconst timeoutMs = options?.timeoutMs ?? DEFAULT_READ_TIMEOUT_MS;\n\tconst maxBufferBytes = options?.maxBufferBytes ?? DEFAULT_MAX_BUFFER_BYTES;\n\n\tconst result = spawnSync(command, args, {\n\t\ttimeout: timeoutMs,\n\t\tmaxBuffer: maxBufferBytes,\n\t\tenv: options?.env,\n\t});\n\n\tif (result.error) {\n\t\treturn { ok: false, stdout: Buffer.alloc(0) };\n\t}\n\n\tif (result.status !== 0) {\n\t\treturn { ok: false, stdout: Buffer.alloc(0) };\n\t}\n\n\tconst stdout = Buffer.isBuffer(result.stdout)\n\t\t? result.stdout\n\t\t: Buffer.from(result.stdout ?? \"\", typeof result.stdout === \"string\" ? \"utf-8\" : undefined);\n\n\treturn { ok: true, stdout };\n}\n\nfunction readClipboardImageViaWlPaste(): ClipboardImage | null {\n\tconst list = runCommand(\"wl-paste\", [\"--list-types\"], { timeoutMs: DEFAULT_LIST_TIMEOUT_MS });\n\tif (!list.ok) {\n\t\treturn null;\n\t}\n\n\tconst types = list.stdout\n\t\t.toString(\"utf-8\")\n\t\t.split(/\\r?\\n/)\n\t\t.map((t) => t.trim())\n\t\t.filter(Boolean);\n\n\tconst selectedType = selectPreferredImageMimeType(types);\n\tif (!selectedType) {\n\t\treturn null;\n\t}\n\n\tconst data = runCommand(\"wl-paste\", [\"--type\", selectedType, \"--no-newline\"]);\n\tif (!data.ok || data.stdout.length === 0) {\n\t\treturn null;\n\t}\n\n\treturn { bytes: data.stdout, mimeType: baseMimeType(selectedType) };\n}\n\nfunction isWSL(env: NodeJS.ProcessEnv = process.env): boolean {\n\tif (env.WSL_DISTRO_NAME || env.WSLENV) {\n\t\treturn true;\n\t}\n\n\ttry {\n\t\tconst release = readFileSync(\"/proc/version\", \"utf-8\");\n\t\treturn /microsoft|wsl/i.test(release);\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * On WSL, the Linux clipboard (Wayland/X11) does not receive image data from\n * Windows screenshots (Win+Shift+S). PowerShell can access the Windows clipboard\n * directly, so we use it as a fallback.\n */\nfunction readClipboardImageViaPowerShell(): ClipboardImage | null {\n\tconst tmpFile = join(tmpdir(), `pi-wsl-clip-${randomUUID()}.png`);\n\n\ttry {\n\t\tconst winPathResult = runCommand(\"wslpath\", [\"-w\", tmpFile], { timeoutMs: DEFAULT_LIST_TIMEOUT_MS });\n\t\tif (!winPathResult.ok) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst winPath = winPathResult.stdout.toString(\"utf-8\").trim();\n\t\tif (!winPath) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst psQuotedWinPath = winPath.replaceAll(\"'\", \"''\");\n\t\tconst psScript = [\n\t\t\t\"Add-Type -AssemblyName System.Windows.Forms\",\n\t\t\t\"Add-Type -AssemblyName System.Drawing\",\n\t\t\t`$path = '${psQuotedWinPath}'`,\n\t\t\t\"$img = [System.Windows.Forms.Clipboard]::GetImage()\",\n\t\t\t\"if ($img) { $img.Save($path, [System.Drawing.Imaging.ImageFormat]::Png); Write-Output 'ok' } else { Write-Output 'empty' }\",\n\t\t].join(\"; \");\n\n\t\tconst result = runCommand(\"powershell.exe\", [\"-NoProfile\", \"-Command\", psScript], {\n\t\t\ttimeoutMs: DEFAULT_POWERSHELL_TIMEOUT_MS,\n\t\t});\n\t\tif (!result.ok) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst output = result.stdout.toString(\"utf-8\").trim();\n\t\tif (output !== \"ok\") {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst bytes = readFileSync(tmpFile);\n\t\tif (bytes.length === 0) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn { bytes: new Uint8Array(bytes), mimeType: \"image/png\" };\n\t} catch {\n\t\treturn null;\n\t} finally {\n\t\ttry {\n\t\t\tunlinkSync(tmpFile);\n\t\t} catch {\n\t\t\t// Ignore cleanup errors.\n\t\t}\n\t}\n}\n\nfunction readClipboardImageViaXclip(): ClipboardImage | null {\n\tconst targets = runCommand(\"xclip\", [\"-selection\", \"clipboard\", \"-t\", \"TARGETS\", \"-o\"], {\n\t\ttimeoutMs: DEFAULT_LIST_TIMEOUT_MS,\n\t});\n\n\tlet candidateTypes: string[] = [];\n\tif (targets.ok) {\n\t\tcandidateTypes = targets.stdout\n\t\t\t.toString(\"utf-8\")\n\t\t\t.split(/\\r?\\n/)\n\t\t\t.map((t) => t.trim())\n\t\t\t.filter(Boolean);\n\t}\n\n\tconst preferred = candidateTypes.length > 0 ? selectPreferredImageMimeType(candidateTypes) : null;\n\tconst tryTypes = preferred ? [preferred, ...SUPPORTED_IMAGE_MIME_TYPES] : [...SUPPORTED_IMAGE_MIME_TYPES];\n\n\tfor (const mimeType of tryTypes) {\n\t\tconst data = runCommand(\"xclip\", [\"-selection\", \"clipboard\", \"-t\", mimeType, \"-o\"]);\n\t\tif (data.ok && data.stdout.length > 0) {\n\t\t\treturn { bytes: data.stdout, mimeType: baseMimeType(mimeType) };\n\t\t}\n\t}\n\n\treturn null;\n}\n\nasync function readClipboardImageViaNativeClipboard(): Promise<ClipboardImage | null> {\n\tif (!clipboard || !clipboard.hasImage()) {\n\t\treturn null;\n\t}\n\n\tconst imageData = await clipboard.getImageBinary();\n\tif (!imageData || imageData.length === 0) {\n\t\treturn null;\n\t}\n\n\tconst bytes = imageData instanceof Uint8Array ? imageData : Uint8Array.from(imageData);\n\treturn { bytes, mimeType: \"image/png\" };\n}\n\nexport async function readClipboardImage(options?: {\n\tenv?: NodeJS.ProcessEnv;\n\tplatform?: NodeJS.Platform;\n}): Promise<ClipboardImage | null> {\n\tconst env = options?.env ?? process.env;\n\tconst platform = options?.platform ?? process.platform;\n\n\tif (env.TERMUX_VERSION) {\n\t\treturn null;\n\t}\n\n\tlet image: ClipboardImage | null = null;\n\n\tif (platform === \"linux\") {\n\t\tconst wsl = isWSL(env);\n\t\tconst wayland = isWaylandSession(env);\n\n\t\tif (wayland || wsl) {\n\t\t\timage = readClipboardImageViaWlPaste() ?? readClipboardImageViaXclip();\n\t\t}\n\n\t\tif (!image && wsl) {\n\t\t\timage = readClipboardImageViaPowerShell();\n\t\t}\n\n\t\tif (!image && !wayland) {\n\t\t\timage = (await readClipboardImageViaNativeClipboard()) ?? readClipboardImageViaXclip();\n\t\t}\n\t} else {\n\t\timage = await readClipboardImageViaNativeClipboard();\n\t}\n\n\tif (!image) {\n\t\treturn null;\n\t}\n\n\t// Convert unsupported formats (e.g., BMP from WSLg) to PNG\n\tif (!isSupportedImageMimeType(image.mimeType)) {\n\t\tconst pngBytes = await convertToPng(image.bytes);\n\t\tif (!pngBytes) {\n\t\t\treturn null;\n\t\t}\n\t\treturn { bytes: pngBytes, mimeType: \"image/png\" };\n\t}\n\n\treturn image;\n}\n"]}
@@ -204,7 +204,7 @@ The `api` field determines which streaming implementation is used:
204
204
  | `google-vertex` | Google Vertex AI API |
205
205
  | `bedrock-converse-stream` | Amazon Bedrock Converse API |
206
206
 
207
- Most OpenAI-compatible providers work with `openai-completions`. Use model-level `thinkingLevelMap` for model-specific thinking levels, and `compat` for provider quirks:
207
+ Most OpenAI-compatible providers work with `openai-completions`. Use model-level `thinkingLevelMap` for model-specific thinking levels, and `compat` for provider quirks. The `xhigh` and `max` levels are opt-in, require non-null map entries, and may be separated by unsupported holes:
208
208
 
209
209
  ```typescript
210
210
  models: [{
@@ -216,7 +216,8 @@ models: [{
216
216
  low: null,
217
217
  medium: null,
218
218
  high: "default",
219
- xhigh: "max"
219
+ xhigh: null,
220
+ max: "max"
220
221
  },
221
222
  compat: {
222
223
  supportsDeveloperRole: false, // use "system" instead of "developer"
@@ -684,7 +685,7 @@ interface ProviderModelConfig {
684
685
  reasoning: boolean;
685
686
 
686
687
  /** Maps pi thinking levels to provider/model-specific values; null marks a level unsupported. */
687
- thinkingLevelMap?: Partial<Record<"off" | "minimal" | "low" | "medium" | "high" | "xhigh", string | null>>;
688
+ thinkingLevelMap?: Partial<Record<"off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max", string | null>>;
688
689
 
689
690
  /** Supported input types. */
690
691
  input: ("text" | "image")[];
@@ -300,7 +300,8 @@ user sends prompt ────────────────────
300
300
  │ │ │ │
301
301
  │ └─► turn_end │ │
302
302
  │ │
303
- └─► agent_end │
303
+ ├─► agent_end │
304
+ └─► agent_settled (no retry/compaction/follow-up left) │
304
305
  │
305
306
  user sends another prompt ◄────────────────────────────────┘
306
307
 
@@ -534,15 +535,19 @@ The `systemPromptOptions` field gives extensions access to the same structured d
534
535
 
535
536
  Inside `before_agent_start`, `event.systemPrompt` and `ctx.getSystemPrompt()` both reflect the chained system prompt as of the current handler. Later `before_agent_start` handlers can still modify it again.
536
537
 
537
- #### agent_start / agent_end
538
+ #### agent_start / agent_end / agent_settled
538
539
 
539
- Fired once per user prompt.
540
+ `agent_start` fires when a low-level agent run begins. `agent_end` fires when that run ends, but Pi may still auto-retry, auto-compact and retry, or continue with queued follow-up messages. Use `agent_settled` for status integrations that need to know Pi will not continue running automatically.
540
541
 
541
542
  ```typescript
542
543
  pi.on("agent_start", async (_event, ctx) => {});
543
544
 
544
545
  pi.on("agent_end", async (event, ctx) => {
545
- // event.messages - messages from this prompt
546
+ // event.messages - messages from this low-level run
547
+ });
548
+
549
+ pi.on("agent_settled", async (_event, ctx) => {
550
+ // ctx.isIdle() is true here unless another extension started a new run.
546
551
  });
547
552
  ```
548
553
 
@@ -956,7 +961,7 @@ pi.on("tool_result", async (event, ctx) => {
956
961
 
957
962
  ### ctx.isIdle() / ctx.abort() / ctx.hasPendingMessages()
958
963
 
959
- Control flow helpers.
964
+ Control flow helpers. `ctx.isIdle()` is false while Pi is processing an agent run, automatic retry, auto-compaction retry, or queued continuation.
960
965
 
961
966
  ### ctx.shutdown()
962
967
 
@@ -1038,7 +1043,7 @@ This reports the current base prompt inputs. It does not include per-turn `befor
1038
1043
 
1039
1044
  ### ctx.waitForIdle()
1040
1045
 
1041
- Wait for the agent to finish streaming:
1046
+ Wait for the agent to fully settle, including automatic retries, auto-compaction retries, and queued continuations:
1042
1047
 
1043
1048
  ```typescript
1044
1049
  pi.registerCommand("my-cmd", {
@@ -1219,7 +1224,7 @@ Run the same reload flow as `/reload`.
1219
1224
 
1220
1225
  ```typescript
1221
1226
  pi.registerCommand("reload-runtime", {
1222
- description: "Reload extensions, skills, prompts, and themes",
1227
+ description: "Reload extensions, skills, prompts, themes, and context files",
1223
1228
  handler: async (_args, ctx) => {
1224
1229
  await ctx.reload();
1225
1230
  return;
@@ -1247,7 +1252,7 @@ import { Type } from "typebox";
1247
1252
 
1248
1253
  export default function (pi: ExtensionAPI) {
1249
1254
  pi.registerCommand("reload-runtime", {
1250
- description: "Reload extensions, skills, prompts, and themes",
1255
+ description: "Reload extensions, skills, prompts, themes, and context files",
1251
1256
  handler: async (_args, ctx) => {
1252
1257
  await ctx.reload();
1253
1258
  return;
@@ -1257,7 +1262,7 @@ export default function (pi: ExtensionAPI) {
1257
1262
  pi.registerTool({
1258
1263
  name: "reload_runtime",
1259
1264
  label: "Reload Runtime",
1260
- description: "Reload extensions, skills, prompts, and themes",
1265
+ description: "Reload extensions, skills, prompts, themes, and context files",
1261
1266
  parameters: Type.Object({}),
1262
1267
  async execute() {
1263
1268
  pi.sendUserMessage("/reload-runtime", { deliverAs: "followUp" });
@@ -1608,7 +1613,7 @@ if (model) {
1608
1613
  Get or set the thinking level. Level is clamped to model capabilities (non-reasoning models always use "off"). Changes emit `thinking_level_select`.
1609
1614
 
1610
1615
  ```typescript
1611
- const current = pi.getThinkingLevel(); // "off" | "minimal" | "low" | "medium" | "high" | "xhigh"
1616
+ const current = pi.getThinkingLevel(); // "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max"
1612
1617
  pi.setThinkingLevel("high");
1613
1618
  ```
1614
1619
 
package/docs/models.md CHANGED
@@ -139,7 +139,7 @@ Set `api` at provider level (default for all models) or model level (override pe
139
139
  | `headers` | Custom headers (see value resolution below) |
140
140
  | `authHeader` | Set `true` to add `Authorization: Bearer <apiKey>` automatically |
141
141
  | `models` | Array of model configurations |
142
- | `modelOverrides` | Per-model overrides for built-in models on this provider |
142
+ | `modelOverrides` | Per-model overrides for built-in or extension-registered models on this provider |
143
143
 
144
144
  ### Value Resolution
145
145
 
@@ -205,22 +205,44 @@ If your command is slow, expensive, rate-limited, or should keep using a previou
205
205
  | `input` | No | `["text"]` | Input types: `["text"]` or `["text", "image"]` |
206
206
  | `contextWindow` | No | `128000` | Context window size in tokens |
207
207
  | `maxTokens` | No | `16384` | Maximum output tokens |
208
- | `cost` | No | all zeros | `{"input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0}` (per million tokens) |
208
+ | `cost` | No | all zeros | Per-million-token rates with optional request-wide input pricing tiers |
209
209
  | `compat` | No | provider `compat` | Provider compatibility overrides. Merged with provider-level `compat` when both are set. |
210
210
 
211
+ A cost tier supplies a complete alternate rate set and applies to the full request when total input usage (`input + cacheRead + cacheWrite`) exceeds `inputTokensAbove`. When multiple tiers match, the highest threshold wins.
212
+
213
+ ```json
214
+ {
215
+ "cost": {
216
+ "input": 5,
217
+ "output": 30,
218
+ "cacheRead": 0.5,
219
+ "cacheWrite": 6.25,
220
+ "tiers": [
221
+ {
222
+ "inputTokensAbove": 272000,
223
+ "input": 10,
224
+ "output": 45,
225
+ "cacheRead": 1,
226
+ "cacheWrite": 12.5
227
+ }
228
+ ]
229
+ }
230
+ }
231
+ ```
232
+
211
233
  Current behavior:
212
234
  - `/model`, `--list-models`, and the interactive footer display entries by model `id`.
213
235
  - The configured `name` is used for model matching and secondary model detail text. It does not replace the footer/status-bar model id.
214
236
 
215
237
  ### Thinking Level Map
216
238
 
217
- Use `thinkingLevelMap` on a model to describe model-specific thinking controls. Keys are pi thinking levels: `off`, `minimal`, `low`, `medium`, `high`, `xhigh`.
239
+ Use `thinkingLevelMap` on a model to describe model-specific thinking controls. Keys are pi thinking levels: `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`. Maps may contain holes; for example, a model can expose `high` and `max` without exposing `xhigh`.
218
240
 
219
241
  Values are tristate:
220
242
 
221
243
  | Value | Meaning |
222
244
  |-------|---------|
223
- | omitted | Level is supported and uses the provider's default mapping |
245
+ | omitted | Standard levels through `high` use the provider's default mapping; extended `xhigh` and `max` levels are unsupported |
224
246
  | string | Level is supported and this value is sent to the provider |
225
247
  | `null` | Level is unsupported and hidden/skipped/clamped away |
226
248
 
@@ -235,7 +257,8 @@ Example for a model that only supports off, high, and max reasoning:
235
257
  "low": null,
236
258
  "medium": null,
237
259
  "high": "high",
238
- "xhigh": "max"
260
+ "xhigh": null,
261
+ "max": "max"
239
262
  }
240
263
  }
241
264
  ```
@@ -293,7 +316,7 @@ Merge semantics:
293
316
 
294
317
  ## Per-model Overrides
295
318
 
296
- Use `modelOverrides` to customize specific built-in models without replacing the provider's full model list.
319
+ Use `modelOverrides` to customize built-in models and matching extension-registered models without replacing the provider's full model list.
297
320
 
298
321
  ```json
299
322
  {
@@ -314,10 +337,28 @@ Use `modelOverrides` to customize specific built-in models without replacing the
314
337
  }
315
338
  ```
316
339
 
317
- `modelOverrides` supports these fields per model: `name`, `reasoning`, `input`, `cost` (partial), `contextWindow`, `maxTokens`, `headers`, `compat`.
340
+ `modelOverrides` supports these fields per model: `name`, `reasoning`, `thinkingLevelMap`, `input`, `cost` (partial), `contextWindow`, `maxTokens`, `headers`, `compat`.
341
+
342
+ Direct OpenAI GPT-5.6 Sol, Terra, and Luna default to a `272000` context window so requests remain within OpenAI's short-context pricing tier. To opt into OpenAI's 1.05M context window, increase it for each model you use:
343
+
344
+ ```json
345
+ {
346
+ "providers": {
347
+ "openai": {
348
+ "modelOverrides": {
349
+ "gpt-5.6-sol": {
350
+ "contextWindow": 1050000
351
+ }
352
+ }
353
+ }
354
+ }
355
+ }
356
+ ```
357
+
358
+ The override preserves the built-in pricing metadata. Requests with more than 272K total input tokens use GPT-5.6's long-context rates for the entire request. Apply the same override to `gpt-5.6-terra` or `gpt-5.6-luna` when needed.
318
359
 
319
360
  Behavior notes:
320
- - `modelOverrides` are applied to built-in provider models.
361
+ - `modelOverrides` are applied to built-in provider models and matching extension-registered provider models.
321
362
  - Unknown model IDs are ignored.
322
363
  - You can combine provider-level `baseUrl`/`headers` with `modelOverrides`.
323
364
  - Overriding `name` changes model matching and secondary detail text only; the footer and primary model lists continue to show the model `id`.
package/docs/rpc.md CHANGED
@@ -286,9 +286,9 @@ Set the reasoning/thinking level for models that support it.
286
286
  {"type": "set_thinking_level", "level": "high"}
287
287
  ```
288
288
 
289
- Levels: `"off"`, `"minimal"`, `"low"`, `"medium"`, `"high"`, `"xhigh"`
289
+ Levels: `"off"`, `"minimal"`, `"low"`, `"medium"`, `"high"`, `"xhigh"`, `"max"`
290
290
 
291
- Note: `"xhigh"` is only supported by OpenAI codex-max models.
291
+ `"xhigh"` and `"max"` are exposed only when supported by the selected model. Some models, including GPT-5.6, expose both.
292
292
 
293
293
  Response:
294
294
  ```json
@@ -805,7 +805,8 @@ Events are streamed to stdout as JSON lines during agent operation. Events do NO
805
805
  | Event | Description |
806
806
  |-------|-------------|
807
807
  | `agent_start` | Agent begins processing |
808
- | `agent_end` | Agent completes (includes all generated messages) |
808
+ | `agent_end` | One low-level agent run completes (may still be followed by retry, compaction, or queued continuations) |
809
+ | `agent_settled` | Agent run is fully settled; no automatic retry, compaction retry, or queued continuation remains |
809
810
  | `turn_start` | New turn begins |
810
811
  | `turn_end` | Turn completes (includes assistant message and tool results) |
811
812
  | `message_start` | Message begins |
@@ -831,15 +832,24 @@ Emitted when the agent begins processing a prompt.
831
832
 
832
833
  ### agent_end
833
834
 
834
- Emitted when the agent completes. Contains all messages generated during this run.
835
+ Emitted when one low-level agent run completes. Contains all messages generated during this run. If `willRetry` is true, an automatic retry will follow.
835
836
 
836
837
  ```json
837
838
  {
838
839
  "type": "agent_end",
839
- "messages": [...]
840
+ "messages": [...],
841
+ "willRetry": false
840
842
  }
841
843
  ```
842
844
 
845
+ ### agent_settled
846
+
847
+ Emitted after the full session-level run settles. At this point Pi will not continue automatically through retry, compaction retry, or queued follow-up messages.
848
+
849
+ ```json
850
+ {"type": "agent_settled"}
851
+ ```
852
+
843
853
  ### turn_start / turn_end
844
854
 
845
855
  A turn consists of one assistant response plus any resulting tool calls and results.
package/docs/sdk.md CHANGED
@@ -387,7 +387,7 @@ const available = await modelRegistry.getAvailable();
387
387
 
388
388
  const { session } = await createAgentSession({
389
389
  model: opus,
390
- thinkingLevel: "medium", // off, minimal, low, medium, high, xhigh
390
+ thinkingLevel: "medium", // off, minimal, low, medium, high, xhigh, max
391
391
 
392
392
  // Models for cycling (Ctrl+P in interactive mode)
393
393
  scopedModels: [
package/docs/settings.md CHANGED
@@ -29,8 +29,9 @@ Use `/trust` in interactive mode to save a project trust decision for future ses
29
29
  |---------|------|---------|-------------|
30
30
  | `defaultProvider` | string | - | Default provider (e.g., `"anthropic"`, `"openai"`) |
31
31
  | `defaultModel` | string | - | Default model ID |
32
- | `defaultThinkingLevel` | string | - | `"off"`, `"minimal"`, `"low"`, `"medium"`, `"high"`, `"xhigh"` |
32
+ | `defaultThinkingLevel` | string | - | `"off"`, `"minimal"`, `"low"`, `"medium"`, `"high"`, `"xhigh"`, `"max"` |
33
33
  | `hideThinkingBlock` | boolean | `false` | Hide thinking blocks in output |
34
+ | `showCacheMissNotices` | boolean | `false` | Show transcript notices for significant prompt-cache misses |
34
35
  | `thinkingBudgets` | object | - | Custom token budgets per thinking level |
35
36
 
36
37
  #### thinkingBudgets
@@ -172,7 +173,7 @@ Keep `retry.provider.maxRetries` at `0` unless provider-level retries are explic
172
173
 
173
174
  | Setting | Type | Default | Description |
174
175
  |---------|------|---------|-------------|
175
- | `shellPath` | string | - | Custom shell path (e.g., for Cygwin on Windows) |
176
+ | `shellPath` | string | - | Custom shell path (e.g., for Cygwin on Windows); supports a leading `~` for the home directory |
176
177
  | `shellCommandPrefix` | string | - | Prefix for every bash command (e.g., `"shopt -s expand_aliases"`) |
177
178
  | `npmCommand` | string[] | - | Command argv used for npm package lookup/install operations (e.g., `["mise", "exec", "node@20", "--", "npm"]`) |
178
179
 
package/docs/themes.md CHANGED
@@ -109,6 +109,7 @@ vim ~/.pi/agent/themes/my-theme.json
109
109
  "thinkingMedium": "#00ffff",
110
110
  "thinkingHigh": "#ff00ff",
111
111
  "thinkingXhigh": "#ff0000",
112
+ "thinkingMax": "#ff0088",
112
113
  "bashMode": "#ffaa00"
113
114
  }
114
115
  }
@@ -139,13 +140,13 @@ vim ~/.pi/agent/themes/my-theme.json
139
140
 
140
141
  - `name` is required and must be unique.
141
142
  - `vars` is optional. Define reusable colors here, then reference them in `colors`.
142
- - `colors` must define all 51 required tokens.
143
+ - `colors` must define all 51 required tokens. `thinkingMax` is optional and falls back to `thinkingXhigh`.
143
144
 
144
145
  The `$schema` field enables editor auto-completion and validation.
145
146
 
146
147
  ## Color Tokens
147
148
 
148
- Every theme must define all 51 color tokens. There are no optional colors.
149
+ Every theme must define all 51 required color tokens. `thinkingMax` is optional for compatibility with existing themes; when omitted, it uses `thinkingXhigh`.
149
150
 
150
151
  ### Core UI (11 colors)
151
152
 
@@ -216,7 +217,7 @@ Every theme must define all 51 color tokens. There are no optional colors.
216
217
  | `syntaxOperator` | Operators |
217
218
  | `syntaxPunctuation` | Punctuation |
218
219
 
219
- ### Thinking Level Borders (6 colors)
220
+ ### Thinking Level Borders (6 required, 1 optional)
220
221
 
221
222
  Editor border colors indicating thinking level (visual hierarchy from subtle to prominent):
222
223
 
@@ -228,6 +229,7 @@ Editor border colors indicating thinking level (visual hierarchy from subtle to
228
229
  | `thinkingMedium` | Medium thinking |
229
230
  | `thinkingHigh` | High thinking |
230
231
  | `thinkingXhigh` | Extra high thinking |
232
+ | `thinkingMax` | Maximum thinking; optional, falls back to `thinkingXhigh` |
231
233
 
232
234
  ### Bash Mode (1 color)
233
235
 
package/docs/tui.md CHANGED
@@ -424,7 +424,7 @@ renderResult(result, options, theme, context) {
424
424
  | Diffs | `toolDiffAdded`, `toolDiffRemoved`, `toolDiffContext` |
425
425
  | Markdown | `mdHeading`, `mdLink`, `mdLinkUrl`, `mdCode`, `mdCodeBlock`, `mdCodeBlockBorder`, `mdQuote`, `mdQuoteBorder`, `mdHr`, `mdListBullet` |
426
426
  | Syntax | `syntaxComment`, `syntaxKeyword`, `syntaxFunction`, `syntaxVariable`, `syntaxString`, `syntaxNumber`, `syntaxType`, `syntaxOperator`, `syntaxPunctuation` |
427
- | Thinking | `thinkingOff`, `thinkingMinimal`, `thinkingLow`, `thinkingMedium`, `thinkingHigh`, `thinkingXhigh` |
427
+ | Thinking | `thinkingOff`, `thinkingMinimal`, `thinkingLow`, `thinkingMedium`, `thinkingHigh`, `thinkingXhigh`, `thinkingMax` |
428
428
  | Modes | `bashMode` |
429
429
 
430
430
  **Background colors** (`theme.bg(color, text)`):
package/docs/usage.md CHANGED
@@ -50,7 +50,7 @@ Type `/` in the editor to open command completion. Extensions can register custo
50
50
  | `/copy` | Copy last assistant message to clipboard |
51
51
  | `/export [file]` | Export session to HTML |
52
52
  | `/share` | Upload as private GitHub gist with shareable HTML link |
53
- | `/reload` | Reload keybindings, extensions, skills, prompts, and context files |
53
+ | `/reload` | Reload keybindings, extensions, skills, prompts, themes, and context files |
54
54
  | `/hotkeys` | Show all keyboard shortcuts |
55
55
  | `/changelog` | Display version history |
56
56
  | `/quit` | Quit pi |
@@ -180,7 +180,7 @@ cat README.md | pi -p "Summarize this text"
180
180
  | `--provider <name>` | Provider, such as `anthropic`, `openai`, or `google` |
181
181
  | `--model <pattern>` | Model pattern or ID; supports `provider/id` and optional `:<thinking>` |
182
182
  | `--api-key <key>` | API key, overriding environment variables |
183
- | `--thinking <level>` | `off`, `minimal`, `low`, `medium`, `high`, `xhigh` |
183
+ | `--thinking <level>` | `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max` |
184
184
  | `--models <patterns>` | Comma-separated patterns for Ctrl+P cycling |
185
185
  | `--list-models [search]` | List available models |
186
186
 
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider",
3
- "version": "0.80.3",
3
+ "version": "0.80.6",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-custom-provider",
9
- "version": "0.80.3",
9
+ "version": "0.80.6",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sdk": "^0.52.0"
12
12
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider-anthropic",
3
3
  "private": true,
4
- "version": "0.80.3",
4
+ "version": "0.80.6",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider-gitlab-duo",
3
3
  "private": true,
4
- "version": "0.80.3",
4
+ "version": "0.80.6",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -52,7 +52,7 @@ interface Preset {
52
52
  /** Model ID (e.g., "claude-sonnet-4-5") */
53
53
  model?: string;
54
54
  /** Thinking level */
55
- thinkingLevel?: "off" | "minimal" | "low" | "medium" | "high" | "xhigh";
55
+ thinkingLevel?: "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
56
56
  /** Tools to enable (replaces default set) */
57
57
  tools?: string[];
58
58
  /** Instructions to append to system prompt */
@@ -100,7 +100,7 @@ function loadPresets(cwd: string): PresetsConfig {
100
100
 
101
101
  interface OriginalState {
102
102
  model: Model<Api> | undefined;
103
- thinkingLevel: "off" | "minimal" | "low" | "medium" | "high" | "xhigh";
103
+ thinkingLevel: "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
104
104
  tools: string[];
105
105
  }
106
106
 
@@ -12,7 +12,7 @@ export default function (pi: ExtensionAPI) {
12
12
  // Command entrypoint for reload.
13
13
  // Treat reload as terminal for this handler.
14
14
  pi.registerCommand("reload-runtime", {
15
- description: "Reload extensions, skills, prompts, and themes",
15
+ description: "Reload extensions, skills, prompts, themes, and context files",
16
16
  handler: async (_args, ctx) => {
17
17
  await ctx.reload();
18
18
  return;
@@ -24,7 +24,7 @@ export default function (pi: ExtensionAPI) {
24
24
  pi.registerTool({
25
25
  name: "reload_runtime",
26
26
  label: "Reload Runtime",
27
- description: "Reload extensions, skills, prompts, and themes",
27
+ description: "Reload extensions, skills, prompts, themes, and context files",
28
28
  parameters: Type.Object({}),
29
29
  async execute() {
30
30
  pi.sendUserMessage("/reload-runtime", { deliverAs: "followUp" });
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-sandbox",
3
- "version": "1.10.3",
3
+ "version": "1.10.6",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-sandbox",
9
- "version": "1.10.3",
9
+ "version": "1.10.6",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sandbox-runtime": "^0.0.26"
12
12
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-sandbox",
3
3
  "private": true,
4
- "version": "1.10.3",
4
+ "version": "1.10.6",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-with-deps",
3
- "version": "0.80.3",
3
+ "version": "0.80.6",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-with-deps",
9
- "version": "0.80.3",
9
+ "version": "0.80.6",
10
10
  "dependencies": {
11
11
  "ms": "^2.1.3"
12
12
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-with-deps",
3
3
  "private": true,
4
- "version": "0.80.3",
4
+ "version": "0.80.6",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -119,7 +119,7 @@ await session.prompt("Hello");
119
119
  | `thinkingLevel` | From settings/"off" | off, low, medium, high |
120
120
  | `tools` | `codingTools` | Built-in tools |
121
121
  | `customTools` | `[]` | Additional tool definitions |
122
- | `resourceLoader` | DefaultResourceLoader | Resource loader for extensions, skills, prompts, themes |
122
+ | `resourceLoader` | DefaultResourceLoader | Resource loader for extensions, skills, prompts, themes, and context files |
123
123
  | `sessionManager` | `SessionManager.create(cwd)` | Persistence |
124
124
  | `settingsManager` | `SettingsManager.create(cwd, agentDir)` | Settings overrides |
125
125
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@draht/coding-agent",
3
- "version": "2026.7.7-1",
3
+ "version": "2026.7.11",
4
4
  "description": "Coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "drahtConfig": {
@@ -46,10 +46,10 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@mariozechner/jiti": "^2.6.2",
49
- "@draht/agent-core": "2026.7.7-1",
50
- "@draht/ai": "2026.7.7-1",
51
- "@draht/tools": "2026.7.7-1",
52
- "@draht/tui": "2026.7.7-1",
49
+ "@draht/agent-core": "2026.7.11",
50
+ "@draht/ai": "2026.7.11",
51
+ "@draht/tools": "2026.7.11",
52
+ "@draht/tui": "2026.7.11",
53
53
  "@silvia-odwyer/photon-node": "^0.3.4",
54
54
  "@sinclair/typebox": "^0.34.41",
55
55
  "chalk": "^5.6.2",
@@ -56,13 +56,13 @@ Before executing, decompose this phase execution into atomic reasoning units:
56
56
  Use the `subagent` tool with the `spec-reviewer` agent. ONLY checks "does the diff cover exactly what the spec asked for". Prompt includes the task XML and the diff range.
57
57
  - `DONE` → go to Stage 3.
58
58
  - `DONE_WITH_CONCERNS` → note and proceed.
59
- - `BLOCKED` → re-dispatch implementer with the "Required Fixes" list; repeat Stage 1+2 until `DONE`. Never proceed to Stage 3 with a non-compliant diff.
59
+ - `BLOCKED` → re-dispatch implementer with the "Required Fixes" list; repeat Stage 1+2 until `DONE`. Never proceed to Stage 3 with a non-compliant diff. **Hard cap: 3 implementer re-dispatches per task (across Stage 2 and Stage 3 combined)** — at the cap, record the task as failed and STOP; report the disagreement to the user.
60
60
 
61
61
  ### Stage 3 — Reviewer (code quality)
62
62
  Use the `subagent` tool with the `reviewer` agent for code-quality review. Spec compliance is already ✅.
63
63
  - `DONE` → task complete; move to next task.
64
64
  - `DONE_WITH_CONCERNS` → log `Should fix` items; if any are correctness-critical, re-dispatch implementer.
65
- - `BLOCKED` → `Must fix` issues exist; re-dispatch implementer with the issue list. Repeat until `DONE`.
65
+ - `BLOCKED` → `Must fix` issues exist; re-dispatch implementer with the issue list. Repeat until `DONE` — subject to the same **hard cap of 3 re-dispatches per task**; at the cap, record the task as failed and STOP.
66
66
 
67
67
  5. After all plans complete, run `draht-tools verify-phase $1` yourself (not the subagent)
68
68
  6. Run `draht-tools update-state` yourself