@bastani/atomic 0.9.25 → 0.9.26-alpha.2

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 (186) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/builtin/intercom/package.json +2 -2
  3. package/dist/builtin/mcp/OAUTH.md +1 -1
  4. package/dist/builtin/mcp/native-client-licenses/NOTICE +2 -2
  5. package/dist/builtin/mcp/package.json +1 -1
  6. package/dist/builtin/subagents/package.json +3 -3
  7. package/dist/builtin/web-access/package.json +2 -2
  8. package/dist/builtin/workflows/CHANGELOG.md +6 -0
  9. package/dist/builtin/workflows/package.json +2 -2
  10. package/dist/builtin/workflows/src/extension/index.bundle.mjs +17 -0
  11. package/dist/builtin/workflows/src/index.js +15 -0
  12. package/dist/cli/args.js +1 -1
  13. package/dist/cli/args.js.map +1 -1
  14. package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
  15. package/dist/core/agent-session-extension-bindings.js +4 -0
  16. package/dist/core/agent-session-extension-bindings.js.map +1 -1
  17. package/dist/core/agent-session-methods.d.ts +5 -1
  18. package/dist/core/agent-session-methods.d.ts.map +1 -1
  19. package/dist/core/agent-session-methods.js.map +1 -1
  20. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  21. package/dist/core/agent-session-prompt.js +1 -0
  22. package/dist/core/agent-session-prompt.js.map +1 -1
  23. package/dist/core/agent-session-state.d.ts +14 -2
  24. package/dist/core/agent-session-state.d.ts.map +1 -1
  25. package/dist/core/agent-session-state.js +31 -6
  26. package/dist/core/agent-session-state.js.map +1 -1
  27. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  28. package/dist/core/agent-session-tool-registry.js +5 -1
  29. package/dist/core/agent-session-tool-registry.js.map +1 -1
  30. package/dist/core/agent-session.d.ts +1 -0
  31. package/dist/core/agent-session.d.ts.map +1 -1
  32. package/dist/core/agent-session.js +2 -2
  33. package/dist/core/agent-session.js.map +1 -1
  34. package/dist/core/extensions/api-types.d.ts +2 -1
  35. package/dist/core/extensions/api-types.d.ts.map +1 -1
  36. package/dist/core/extensions/api-types.js.map +1 -1
  37. package/dist/core/extensions/index.d.ts +1 -1
  38. package/dist/core/extensions/index.d.ts.map +1 -1
  39. package/dist/core/extensions/index.js.map +1 -1
  40. package/dist/core/extensions/loader-api.d.ts.map +1 -1
  41. package/dist/core/extensions/loader-api.js +7 -0
  42. package/dist/core/extensions/loader-api.js.map +1 -1
  43. package/dist/core/extensions/provider-types.d.ts +2 -0
  44. package/dist/core/extensions/provider-types.d.ts.map +1 -1
  45. package/dist/core/extensions/provider-types.js.map +1 -1
  46. package/dist/core/messages.d.ts.map +1 -1
  47. package/dist/core/messages.js +4 -3
  48. package/dist/core/messages.js.map +1 -1
  49. package/dist/core/model-registry.d.ts +2 -1
  50. package/dist/core/model-registry.d.ts.map +1 -1
  51. package/dist/core/model-registry.js +3 -0
  52. package/dist/core/model-registry.js.map +1 -1
  53. package/dist/core/model-runtime-streaming.d.ts +2 -1
  54. package/dist/core/model-runtime-streaming.d.ts.map +1 -1
  55. package/dist/core/model-runtime-streaming.js +4 -1
  56. package/dist/core/model-runtime-streaming.js.map +1 -1
  57. package/dist/core/model-runtime.d.ts +2 -0
  58. package/dist/core/model-runtime.d.ts.map +1 -1
  59. package/dist/core/model-runtime.js +69 -5
  60. package/dist/core/model-runtime.js.map +1 -1
  61. package/dist/core/oauth-login.d.ts +1 -0
  62. package/dist/core/oauth-login.d.ts.map +1 -1
  63. package/dist/core/oauth-login.js.map +1 -1
  64. package/dist/core/oauth-provider-metadata.d.ts.map +1 -1
  65. package/dist/core/oauth-provider-metadata.js +5 -17
  66. package/dist/core/oauth-provider-metadata.js.map +1 -1
  67. package/dist/core/provider-alias.d.ts +8 -0
  68. package/dist/core/provider-alias.d.ts.map +1 -0
  69. package/dist/core/provider-alias.js +119 -0
  70. package/dist/core/provider-alias.js.map +1 -0
  71. package/dist/core/provider-composer-internal.d.ts +1 -0
  72. package/dist/core/provider-composer-internal.d.ts.map +1 -1
  73. package/dist/core/provider-composer-internal.js.map +1 -1
  74. package/dist/core/provider-composer.d.ts.map +1 -1
  75. package/dist/core/provider-composer.js +9 -0
  76. package/dist/core/provider-composer.js.map +1 -1
  77. package/dist/core/sdk.js +2 -1
  78. package/dist/core/sdk.js.map +1 -1
  79. package/dist/core/settings-manager-resource-accessors.d.ts +3 -3
  80. package/dist/core/settings-manager-resource-accessors.d.ts.map +1 -1
  81. package/dist/core/settings-manager-resource-accessors.js +2 -1
  82. package/dist/core/settings-manager-resource-accessors.js.map +1 -1
  83. package/dist/core/settings-manager.d.ts +1 -1
  84. package/dist/core/settings-manager.d.ts.map +1 -1
  85. package/dist/core/settings-manager.js.map +1 -1
  86. package/dist/core/settings-types.d.ts +2 -1
  87. package/dist/core/settings-types.d.ts.map +1 -1
  88. package/dist/core/settings-types.js.map +1 -1
  89. package/dist/core/system-prompt.js +1 -1
  90. package/dist/core/system-prompt.js.map +1 -1
  91. package/dist/extensions/codemode/execute.d.ts.map +1 -1
  92. package/dist/extensions/codemode/execute.js +133 -31
  93. package/dist/extensions/codemode/execute.js.map +1 -1
  94. package/dist/extensions/codemode/tool.d.ts +2 -1
  95. package/dist/extensions/codemode/tool.d.ts.map +1 -1
  96. package/dist/extensions/codemode/tool.js +25 -4
  97. package/dist/extensions/codemode/tool.js.map +1 -1
  98. package/dist/extensions/mcp/cli.js +2 -2
  99. package/dist/extensions/mcp/cli.js.map +1 -1
  100. package/dist/extensions/mcp/client/oauth/flow.d.ts +6 -0
  101. package/dist/extensions/mcp/client/oauth/flow.d.ts.map +1 -1
  102. package/dist/extensions/mcp/client/oauth/flow.js +23 -5
  103. package/dist/extensions/mcp/client/oauth/flow.js.map +1 -1
  104. package/dist/extensions/mcp/client/oauth/index.d.ts +1 -1
  105. package/dist/extensions/mcp/client/oauth/index.d.ts.map +1 -1
  106. package/dist/extensions/mcp/client/oauth/index.js +1 -1
  107. package/dist/extensions/mcp/client/oauth/index.js.map +1 -1
  108. package/dist/extensions/mcp/index.d.ts.map +1 -1
  109. package/dist/extensions/mcp/index.js +22 -12
  110. package/dist/extensions/mcp/index.js.map +1 -1
  111. package/dist/extensions/mcp/oauth.d.ts +12 -7
  112. package/dist/extensions/mcp/oauth.d.ts.map +1 -1
  113. package/dist/extensions/mcp/oauth.js +58 -24
  114. package/dist/extensions/mcp/oauth.js.map +1 -1
  115. package/dist/extensions/mcp/runtime.js +1 -1
  116. package/dist/extensions/mcp/runtime.js.map +1 -1
  117. package/dist/index-extensions.d.ts +1 -1
  118. package/dist/index-extensions.d.ts.map +1 -1
  119. package/dist/index-extensions.js.map +1 -1
  120. package/dist/index.d.ts +1 -1
  121. package/dist/index.d.ts.map +1 -1
  122. package/dist/index.js.map +1 -1
  123. package/dist/main-session-options.d.ts.map +1 -1
  124. package/dist/main-session-options.js +6 -0
  125. package/dist/main-session-options.js.map +1 -1
  126. package/dist/main.js +1 -1
  127. package/dist/main.js.map +1 -1
  128. package/dist/modes/interactive/components/atomic-banner.d.ts +2 -0
  129. package/dist/modes/interactive/components/atomic-banner.d.ts.map +1 -1
  130. package/dist/modes/interactive/components/atomic-banner.js +9 -1
  131. package/dist/modes/interactive/components/atomic-banner.js.map +1 -1
  132. package/dist/modes/interactive/components/oauth-selector.d.ts +2 -0
  133. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  134. package/dist/modes/interactive/components/oauth-selector.js +9 -4
  135. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  136. package/dist/modes/interactive/components/settings-selector-handlers.js +1 -1
  137. package/dist/modes/interactive/components/settings-selector-handlers.js.map +1 -1
  138. package/dist/modes/interactive/components/settings-selector-items.js +3 -3
  139. package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
  140. package/dist/modes/interactive/components/settings-selector-types.d.ts +3 -3
  141. package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
  142. package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
  143. package/dist/modes/interactive/components/startup-identity.js +2 -2
  144. package/dist/modes/interactive/components/startup-identity.js.map +1 -1
  145. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  146. package/dist/modes/interactive/components/user-message.js +3 -4
  147. package/dist/modes/interactive/components/user-message.js.map +1 -1
  148. package/dist/modes/interactive/interactive-auth-login.js +14 -5
  149. package/dist/modes/interactive/interactive-auth-login.js.map +1 -1
  150. package/dist/modes/interactive/interactive-auth-routing.js +38 -17
  151. package/dist/modes/interactive/interactive-auth-routing.js.map +1 -1
  152. package/dist/modes/interactive/interactive-mode-surface.d.ts +6 -4
  153. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  154. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  155. package/dist/modes/interactive/interactive-resource-rendering.js +1 -1
  156. package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
  157. package/dist/modes/interactive/interactive-selectors.js +2 -2
  158. package/dist/modes/interactive/interactive-selectors.js.map +1 -1
  159. package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
  160. package/dist/modes/interactive/interactive-startup.js +12 -4
  161. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  162. package/dist/modes/interactive/login-provider-options.d.ts +2 -1
  163. package/dist/modes/interactive/login-provider-options.d.ts.map +1 -1
  164. package/dist/modes/interactive/login-provider-options.js +11 -6
  165. package/dist/modes/interactive/login-provider-options.js.map +1 -1
  166. package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -1
  167. package/dist/modes/interactive/theme/system-theme.js +10 -4
  168. package/dist/modes/interactive/theme/system-theme.js.map +1 -1
  169. package/docs/codemode.md +214 -0
  170. package/docs/custom-provider/oauth.md +2 -0
  171. package/docs/custom-provider/registration.md +32 -0
  172. package/docs/custom-provider.md +1 -0
  173. package/docs/docs.json +1 -0
  174. package/docs/extensions/api-reference.md +2 -0
  175. package/docs/getting-started/authentication.md +2 -2
  176. package/docs/guides.md +1 -1
  177. package/docs/mcp-servers.md +2 -0
  178. package/docs/providers.md +5 -3
  179. package/docs/reference/cli.md +1 -1
  180. package/docs/settings.md +1 -1
  181. package/docs/terminal-setup.md +2 -0
  182. package/docs/tools.md +1 -3
  183. package/docs/usage.md +1 -1
  184. package/examples/extensions/provider-accounts.ts +11 -0
  185. package/npm-shrinkwrap.json +68 -73
  186. package/package.json +8 -8
@@ -1 +1 @@
1
- {"version":3,"file":"system-theme.js","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/system-theme.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,YAAY,EACZ,YAAY,EAEZ,UAAU,EACV,qBAAqB,EAErB,QAAQ,GACR,MAAM,wBAAwB,CAAC;AAGhC,MAAM,CAAC,MAAM,iBAAiB,GAAG,QAAQ,CAAC;AAQ1C,MAAM,QAAQ,GAAG;IAChB,OAAO,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;IACvE,IAAI,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;IACnE,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;IACpE,GAAG,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;IAC9D,MAAM,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;IACjE,MAAM,EAAE,EAAE,GAA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AU,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACpG,IAAI,OAAO,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,KAAmB,CAAC;YAAE,GAAG,CAAC,IAAI,CAAC,KAAmB,CAAC,CAAC;IAChG,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC;AACpC,CAAC","sourcesContent":["import {\n\tcolorToOkhsl,\n\tcolorToOklch,\n\ttype OkhslChannels,\n\tokhslColor,\n\toklabToOkhslLightness,\n\ttype RgbColor,\n\trgbColor,\n} from \"@earendil-works/pi-tui\";\nimport type { ThemeBg, ThemeColor } from \"./theme-class.ts\";\n\nexport const SYSTEM_THEME_NAME = \"system\";\ntype ThemeAppearance = \"dark\" | \"light\";\ntype ThemeToken = ThemeColor | ThemeBg | \"scrollbarTrack\" | \"thinkingMax\";\ninterface Family {\n\thue: number;\n\tsaturation: { min: number; max: number };\n\tslot: number;\n}\nconst FAMILIES = {\n\tneutral: { hue: 231.49, saturation: { min: 0.02, max: 0.08 }, slot: 8 },\n\tblue: { hue: 231.49, saturation: { min: 0.1, max: 0.68 }, slot: 4 },\n\tgreen: { hue: 158.68, saturation: { min: 0.1, max: 0.76 }, slot: 2 },\n\tred: { hue: 20, saturation: { min: 0.1, max: 0.92 }, slot: 1 },\n\tyellow: { hue: 82.36, saturation: { min: 0.5, max: 1 }, slot: 3 },\n\torange: { hue: 52, saturation: { min: 0.12, max: 0.85 }, slot: 3 },\n\tviolet: { hue: 295, saturation: { min: 0.2, max: 0.6 }, slot: 5 },\n\tcalamine: { hue: 202.43, saturation: { min: 0.1, max: 0.74 }, slot: 6 },\n\tthinkingSlate: { hue: 231.49, saturation: { min: 0.08, max: 0.2 }, slot: 4 },\n\tthinkingBlue: { hue: 231.49, saturation: { min: 0.2, max: 0.45 }, slot: 4 },\n\tthinkingPeriwinkle: { hue: 263.25, saturation: { min: 0.3, max: 0.6 }, slot: 6 },\n\tthinkingViolet: { hue: 295, saturation: { min: 0.4, max: 0.75 }, slot: 5 },\n\tthinkingMagenta: { hue: 337.5, saturation: { min: 0.5, max: 0.85 }, slot: 13 },\n\tthinkingRed: { hue: 20, saturation: { min: 0.95, max: 1 }, slot: 1 },\n} satisfies Record<string, Family>;\ntype FamilyName = keyof typeof FAMILIES;\nconst TOKEN_FAMILIES: Record<ThemeToken, FamilyName> = {\n\tselectedBg: \"blue\",\n\tsearchMatchBg: \"orange\",\n\tuserMessageBg: \"blue\",\n\tcustomMessageBg: \"violet\",\n\ttoolPendingBg: \"neutral\",\n\ttoolSuccessBg: \"green\",\n\ttoolErrorBg: \"red\",\n\ttext: \"neutral\",\n\tuserMessageText: \"neutral\",\n\tcustomMessageText: \"neutral\",\n\ttoolTitle: \"neutral\",\n\tsyntaxOperator: \"neutral\",\n\tsyntaxPunctuation: \"neutral\",\n\tmuted: \"neutral\",\n\tdim: \"neutral\",\n\tthinkingText: \"neutral\",\n\ttoolOutput: \"neutral\",\n\tmdLinkUrl: \"neutral\",\n\tmdQuote: \"neutral\",\n\tmdQuoteBorder: \"neutral\",\n\tmdHr: \"neutral\",\n\tmdCodeBlockBorder: \"neutral\",\n\ttoolDiffContext: \"neutral\",\n\tsyntaxComment: \"neutral\",\n\tscrollbarTrack: \"neutral\",\n\tscrollbarThumb: \"neutral\",\n\tsearchMatchText: \"neutral\",\n\tborderMuted: \"neutral\",\n\taccent: \"violet\",\n\tborderAccent: \"violet\",\n\tcustomMessageLabel: \"violet\",\n\tmdCode: \"violet\",\n\tmdListBullet: \"violet\",\n\tsyntaxType: \"violet\",\n\tborder: \"blue\",\n\tmdLink: \"blue\",\n\tsyntaxKeyword: \"blue\",\n\tsyntaxVariable: \"calamine\",\n\tsuccess: \"green\",\n\tmdCodeBlock: \"green\",\n\ttoolDiffAdded: \"green\",\n\tbashMode: \"green\",\n\tsyntaxNumber: \"green\",\n\terror: \"red\",\n\ttoolDiffRemoved: \"red\",\n\twarning: \"yellow\",\n\tmdHeading: \"yellow\",\n\tsyntaxFunction: \"yellow\",\n\tsyntaxString: \"orange\",\n\tthinkingOff: \"neutral\",\n\tthinkingMinimal: \"thinkingSlate\",\n\tthinkingLow: \"thinkingBlue\",\n\tthinkingMedium: \"thinkingPeriwinkle\",\n\tthinkingHigh: \"thinkingViolet\",\n\tthinkingXhigh: \"thinkingMagenta\",\n\tthinkingMax: \"thinkingRed\",\n};\nconst TOKEN_SLOTS: Partial<Record<ThemeToken, number>> = { syntaxString: 2, syntaxNumber: 5, searchMatchBg: 3 };\ninterface Curve {\n\tcoefficients: number[];\n\treachable: [number, number];\n}\n// Upstream's reviewed target-lightness curves, evaluated in OKLab.\nconst LEVELS = {\n\tpanel: {\n\t\tdark: { coefficients: [0.29131, -0.39746, 2.33185, -0.85524, -1.2076, 0.86276], reachable: [0, 0.979] },\n\t\tlight: { coefficients: [-3.74073, 27.94549, -78.44258, 112.6798, -79.60015, 22.11277], reachable: [0.348, 1] },\n\t},\n\ttrack: {\n\t\tdark: { coefficients: [0.39028, -0.23015, 0.83573, 2.43829, -4.38292, 2.01582], reachable: [0, 0.946] },\n\t\tlight: { coefficients: [-5.24921, 38.37322, -107.28833, 152.10005, -106.17127, 29.18061], reachable: [0.368, 1] },\n\t},\n\tthinking0: {\n\t\tdark: { coefficients: [0.52988, -0.05809, -0.30924, 4.63567, -6.52933, 2.89108], reachable: [0, 0.873] },\n\t\tlight: {\n\t\t\tcoefficients: [-28.27749, 182.85284, -469.62416, 603.15916, -384.59976, 97.35147],\n\t\t\treachable: [0.51, 1],\n\t\t},\n\t},\n\tthinking1: {\n\t\tdark: { coefficients: [0.55278, -0.03667, -0.45659, 4.95347, -6.90265, 3.0706], reachable: [0, 0.858] },\n\t\tlight: {\n\t\t\tcoefficients: [-37.10484, 235.86282, -596.62344, 754.3633, -474.00763, 118.3551],\n\t\t\treachable: [0.535, 1],\n\t\t},\n\t},\n\tthinking2: {\n\t\tdark: { coefficients: [0.57486, -0.01765, -0.58987, 5.25227, -7.27175, 3.25532], reachable: [0, 0.842] },\n\t\tlight: {\n\t\t\tcoefficients: [-59.89653, 377.05024, -945.07843, 1182.03145, -734.96375, 181.68658],\n\t\t\treachable: [0.556, 1],\n\t\t},\n\t},\n\tthinking3: {\n\t\tdark: { coefficients: [0.59621, -0.00062, -0.71148, 5.53588, -7.6392, 3.44606], reachable: [0, 0.827] },\n\t\tlight: {\n\t\t\tcoefficients: [-72.07122, 445.84082, -1099.57352, 1353.88793, -829.53392, 202.26164],\n\t\t\treachable: [0.58, 1],\n\t\t},\n\t},\n\tthinking4: {\n\t\tdark: { coefficients: [0.61691, 0.01462, -0.82288, 5.80651, -8.00641, 3.64333], reachable: [0, 0.811] },\n\t\tlight: {\n\t\t\tcoefficients: [-110.14338, 674.21488, -1645.75941, 2004.32367, -1215.15899, 293.3183],\n\t\t\treachable: [0.6, 1],\n\t\t},\n\t},\n\tthinking5: {\n\t\tdark: { coefficients: [0.63702, 0.02826, -0.92498, 6.06465, -8.37246, 3.84651], reachable: [0, 0.795] },\n\t\tlight: {\n\t\t\tcoefficients: [-175.47701, 1063.54495, -2570.70594, 3098.80776, -1860.15527, 444.76392],\n\t\t\treachable: [0.62, 1],\n\t\t},\n\t},\n\tthinking6: {\n\t\tdark: { coefficients: [0.65658, 0.04044, -1.01835, 6.30989, -8.73529, 4.05439], reachable: [0, 0.779] },\n\t\tlight: {\n\t\t\tcoefficients: [-183.81712, 1094.70055, -2602.68539, 3088.71276, -1826.91131, 430.75931],\n\t\t\treachable: [0.643, 1],\n\t\t},\n\t},\n\tsubtle: {\n\t\tdark: { coefficients: [0.56762, -0.02475, -0.5383, 5.12628, -7.10931, 3.17324], reachable: [0, 0.848] },\n\t\tlight: {\n\t\t\tcoefficients: [-232.85459, 1376.54473, -3249.11801, 3827.91186, -2248.29472, 526.55751],\n\t\t\treachable: [0.657, 1],\n\t\t},\n\t},\n\tthumb: {\n\t\tdark: { coefficients: [0.60323, 0.00278, -0.73328, 5.57157, -7.68067, 3.46933], reachable: [0, 0.823] },\n\t\tlight: {\n\t\t\tcoefficients: [-82.89897, 511.01355, -1255.98095, 1540.76821, -940.68087, 228.58523],\n\t\t\treachable: [0.586, 1],\n\t\t},\n\t},\n\treadable: {\n\t\tdark: { coefficients: [0.66937, 0.04704, -1.06871, 6.43941, -8.9332, 4.17229], reachable: [0, 0.77] },\n\t\tlight: {\n\t\t\tcoefficients: [-1554.52576, 8733.56817, -19604.93507, 21977.72696, -12300.99599, 2749.81288],\n\t\t\treachable: [0.751, 1],\n\t\t},\n\t},\n\temphasis: {\n\t\tdark: { coefficients: [0.7303, 0.07695, -1.31626, 7.1681, -10.14436, 4.92846], reachable: [0, 0.712] },\n\t\tlight: {\n\t\t\tcoefficients: [-4948.31942, 26870.91986, -58334.48399, 63280.17197, -34298.01053, 7430.30146],\n\t\t\treachable: [0.811, 1],\n\t\t},\n\t},\n\ttextOnPanel: {\n\t\tdark: { coefficients: [0.86713, 0.05232, -0.89428, 4.79014, -5.5432, 1.75023], reachable: [0, 0.542] },\n\t\tlight: {\n\t\t\tcoefficients: [-8570.89457, 43954.60805, -90084.00702, 92220.6791, -47152.15802, 9632.27113],\n\t\t\treachable: [0.867, 1],\n\t\t},\n\t},\n\ttext: {\n\t\tdark: { coefficients: [0.89242, 0.02311, -0.44862, 2.34417, -0.06084, -2.63844], reachable: [0, 0.5] },\n\t\tlight: {\n\t\t\tcoefficients: [-2004.67048, 6664.47299, -6060.70202, -1792.61209, 5133.82359, -1939.85583],\n\t\t\treachable: [0.894, 1],\n\t\t},\n\t},\n} satisfies Record<string, Record<ThemeAppearance, Curve>>;\ntype Level = keyof typeof LEVELS;\ntype Surface = ThemeBg | \"background\" | \"scrollbarTrack\";\ninterface Rule {\n\ttoken: ThemeToken;\n\ton: Surface[];\n\tlevel: Level;\n}\nconst TOOL_PANELS: Surface[] = [\"toolPendingBg\", \"toolSuccessBg\", \"toolErrorBg\"];\nconst MESSAGE_PANELS: Surface[] = [\"userMessageBg\", \"customMessageBg\"];\nconst PANELS: ThemeBg[] = [\n\t\"userMessageBg\",\n\t\"toolPendingBg\",\n\t\"toolSuccessBg\",\n\t\"toolErrorBg\",\n\t\"selectedBg\",\n\t\"searchMatchBg\",\n\t\"customMessageBg\",\n];\nconst THINKING: ThemeToken[] = [\n\t\"thinkingOff\",\n\t\"thinkingMinimal\",\n\t\"thinkingLow\",\n\t\"thinkingMedium\",\n\t\"thinkingHigh\",\n\t\"thinkingXhigh\",\n\t\"thinkingMax\",\n];\nconst THINKING_LEVELS: Level[] = [\n\t\"thinking0\",\n\t\"thinking1\",\n\t\"thinking2\",\n\t\"thinking3\",\n\t\"thinking4\",\n\t\"thinking5\",\n\t\"thinking6\",\n];\nconst each = (tokens: ThemeToken[], on: Surface[], level: Level): Rule[] =>\n\ttokens.map((token) => ({ token, on, level }));\nconst RULES: Rule[] = [\n\t...each(PANELS, [\"background\"], \"panel\"),\n\t{ token: \"text\", on: [\"background\"], level: \"text\" },\n\t{ token: \"text\", on: [\"selectedBg\"], level: \"textOnPanel\" },\n\t{ token: \"userMessageText\", on: [\"userMessageBg\"], level: \"textOnPanel\" },\n\t{ token: \"toolTitle\", on: TOOL_PANELS, level: \"textOnPanel\" },\n\t...each([\"accent\", \"success\", \"error\", \"warning\"], [\"background\", \"selectedBg\", ...TOOL_PANELS], \"readable\"),\n\t{ token: \"muted\", on: [\"background\", \"selectedBg\", \"customMessageBg\", ...TOOL_PANELS], level: \"readable\" },\n\t{ token: \"dim\", on: [\"background\", \"selectedBg\", \"customMessageBg\", ...TOOL_PANELS], level: \"subtle\" },\n\t{ token: \"thinkingText\", on: [\"background\"], level: \"readable\" },\n\t{ token: \"customMessageText\", on: [\"customMessageBg\", ...TOOL_PANELS], level: \"readable\" },\n\t{\n\t\ttoken: \"customMessageLabel\",\n\t\ton: [\"background\", \"customMessageBg\", \"selectedBg\", ...TOOL_PANELS],\n\t\tlevel: \"readable\",\n\t},\n\t{ token: \"toolOutput\", on: [\"background\", ...TOOL_PANELS], level: \"readable\" },\n\t...each(\n\t\t[\"mdHeading\", \"mdLink\", \"mdLinkUrl\", \"mdCode\", \"mdQuote\", \"mdCodeBlockBorder\", \"mdListBullet\"],\n\t\t[\"background\", ...MESSAGE_PANELS],\n\t\t\"readable\",\n\t),\n\t{ token: \"mdCodeBlock\", on: [\"background\", ...MESSAGE_PANELS, ...TOOL_PANELS], level: \"readable\" },\n\t...each([\"toolDiffAdded\", \"toolDiffRemoved\", \"toolDiffContext\"], [\"background\", ...TOOL_PANELS], \"readable\"),\n\t...each(\n\t\t[\n\t\t\t\"syntaxComment\",\n\t\t\t\"syntaxKeyword\",\n\t\t\t\"syntaxFunction\",\n\t\t\t\"syntaxVariable\",\n\t\t\t\"syntaxString\",\n\t\t\t\"syntaxNumber\",\n\t\t\t\"syntaxType\",\n\t\t\t\"syntaxOperator\",\n\t\t\t\"syntaxPunctuation\",\n\t\t],\n\t\t[\"background\", ...MESSAGE_PANELS, ...TOOL_PANELS],\n\t\t\"readable\",\n\t),\n\t{ token: \"searchMatchText\", on: [\"searchMatchBg\"], level: \"readable\" },\n\t...each([\"bashMode\", \"border\", \"borderAccent\"], [\"background\"], \"readable\"),\n\t{ token: \"borderMuted\", on: [\"background\"], level: \"subtle\" },\n\t...each([\"mdQuoteBorder\", \"mdHr\"], [\"background\", ...MESSAGE_PANELS, ...TOOL_PANELS], \"readable\"),\n\t{ token: \"scrollbarTrack\", on: [\"background\"], level: \"track\" },\n\t{ token: \"scrollbarThumb\", on: [\"scrollbarTrack\"], level: \"thumb\" },\n\t...THINKING.map((token, index): Rule => ({ token, on: [\"background\"], level: THINKING_LEVELS[index] })),\n];\nconst READABLE_FLOOR: Record<ThemeAppearance, Level> = { dark: \"readable\", light: \"subtle\" };\nconst FOREGROUND_TOKENS: ThemeColor[] = [\"text\", \"userMessageText\", \"toolTitle\"];\nconst TEXT_MINIMUM_WCAG_CONTRAST = 4.5;\nconst SOLVE_ORDER: ThemeToken[] = (() => {\n\tconst order: ThemeToken[] = [];\n\tconst visit = (token: ThemeToken): void => {\n\t\tif (order.includes(token)) return;\n\t\tfor (const rule of RULES)\n\t\t\tif (rule.token === token) for (const surface of rule.on) if (surface !== \"background\") visit(surface);\n\t\torder.push(token);\n\t};\n\tfor (const rule of RULES) visit(rule.token);\n\treturn order;\n})();\nexport interface SystemThemeInput {\n\tforeground?: RgbColor;\n\tbackground?: RgbColor;\n\tpalette?: RgbColor[];\n\tsaturation?: number;\n\tappearanceHint?: ThemeAppearance;\n}\nexport interface SystemThemeColors {\n\tcolors: Record<ThemeToken, string | number>;\n\tdim: ThemeColor[];\n\tappearance: ThemeAppearance | undefined;\n}\nfunction oklabLightness(color: RgbColor): number {\n\treturn colorToOklch(rgbColor(color.r, color.g, color.b)).l;\n}\nexport function relativeLuminance({ r, g, b }: RgbColor): number {\n\tconst linear = (channel: number) => {\n\t\tconst value = channel / 255;\n\t\treturn value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;\n\t};\n\treturn 0.2126 * linear(r) + 0.7152 * linear(g) + 0.0722 * linear(b);\n}\nexport function wcagContrast(first: RgbColor, second: RgbColor): number {\n\tconst a = relativeLuminance(first);\n\tconst b = relativeLuminance(second);\n\treturn (Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05);\n}\nexport function terminalAppearance(background: RgbColor, foreground?: RgbColor): ThemeAppearance {\n\tconst whiteContrast = wcagContrast({ r: 255, g: 255, b: 255 }, background);\n\tconst blackContrast = wcagContrast({ r: 0, g: 0, b: 0 }, background);\n\tif (foreground) {\n\t\tconst foregroundL = oklabLightness(foreground);\n\t\tconst backgroundL = oklabLightness(background);\n\t\tif (Math.abs(foregroundL - backgroundL) > 0.05) {\n\t\t\tconst appearance = foregroundL > backgroundL ? \"dark\" : \"light\";\n\t\t\tif ((appearance === \"dark\" ? whiteContrast : blackContrast) >= TEXT_MINIMUM_WCAG_CONTRAST) return appearance;\n\t\t}\n\t}\n\treturn whiteContrast >= blackContrast ? \"dark\" : \"light\";\n}\nconst clamp = (value: number, min: number, max: number) => Math.min(max, Math.max(min, value));\nfunction hexOf({ r, g, b }: RgbColor): string {\n\treturn `#${[r, g, b].map((channel) => Math.round(channel).toString(16).padStart(2, \"0\")).join(\"\")}`;\n}\nfunction bellWeight(lightness: number): number {\n\tconst gaussian = (x: number): number => Math.exp(-((x - 0.5) ** 2) / (2 * 0.25 ** 2));\n\treturn (gaussian(lightness) - gaussian(0)) / (1 - gaussian(0));\n}\nfunction saturationCurve({ saturation: { min, max } }: Family, lightness: number): number {\n\tconst floor = max > 0 ? min / max : 1;\n\treturn floor + (1 - floor) * bellWeight(lightness);\n}\nfunction levelTarget(level: Level, appearance: ThemeAppearance, surfaceL: number): number | undefined {\n\tconst curve: Curve = LEVELS[level][appearance];\n\tif (surfaceL < curve.reachable[0] || surfaceL > curve.reachable[1]) return undefined;\n\treturn curve.coefficients.reduce((sum, coefficient, power) => sum + coefficient * surfaceL ** power, 0);\n}\nexport function generateSystemThemeColors(input: SystemThemeInput): SystemThemeColors {\n\tconst saturation = clamp(input.saturation ?? 1, 0, 1);\n\tconst { background, foreground } = input;\n\tif (!background) return indexedColors(saturation, input.appearanceHint);\n\tconst palette = input.palette?.length === 16 ? input.palette.map(okhslOf) : undefined;\n\tconst appearance = terminalAppearance(background, foreground);\n\tconst lighter = appearance === \"dark\";\n\tconst extreme = lighter ? 1 : 0;\n\tconst backgroundL = oklabLightness(background);\n\tconst paint = (token: ThemeToken, oklabL: number): RgbColor => {\n\t\tconst lightness = oklabToOkhslLightness(oklabL);\n\t\tconst family: Family = FAMILIES[TOKEN_FAMILIES[token]];\n\t\tif (!palette) {\n\t\t\tconst { min, max } = family.saturation;\n\t\t\treturn okhslColor(family.hue, (min + (max - min) * bellWeight(lightness)) * saturation, lightness);\n\t\t}\n\t\treturn anchored(palette[TOKEN_SLOTS[token] ?? family.slot], family, lightness, saturation);\n\t};\n\tconst target = (level: Level, surfaceL: number, t: number): number | undefined => {\n\t\tconst reached = levelTarget(level, appearance, surfaceL);\n\t\tif (reached === undefined && t === 0) return undefined;\n\t\tconst distance = (reached ?? extreme) - surfaceL;\n\t\tconst floor = (levelTarget(READABLE_FLOOR[appearance], appearance, surfaceL) ?? extreme) - surfaceL;\n\t\tconst compressed =\n\t\t\tMath.abs(distance) > Math.abs(floor) ? distance - (distance - floor) * Math.min(t, 1) : distance;\n\t\treturn surfaceL + compressed * (1 - Math.max(0, t - 1));\n\t};\n\tconst extremeText = lighter ? { r: 255, g: 255, b: 255 } : { r: 0, g: 0, b: 0 };\n\tconst readable = (color: RgbColor) => wcagContrast(extremeText, color) >= TEXT_MINIMUM_WCAG_CONTRAST;\n\tconst limitPanel = (token: ThemeToken, l: number): RgbColor => {\n\t\tconst color = paint(token, l);\n\t\tif (readable(color)) return color;\n\t\tlet [low, high] = [backgroundL, l];\n\t\tfor (let index = 0; index < 20; index++) {\n\t\t\tconst middle = (low + high) / 2;\n\t\t\tif (readable(paint(token, middle))) low = middle;\n\t\t\telse high = middle;\n\t\t}\n\t\treturn paint(token, low);\n\t};\n\tconst solve = (t: number): Map<Surface | ThemeToken, RgbColor> | undefined => {\n\t\tconst colors = new Map<Surface | ThemeToken, RgbColor>([[\"background\", background]]);\n\t\tfor (const token of SOLVE_ORDER) {\n\t\t\tconst targets: number[] = [];\n\t\t\tfor (const rule of RULES) {\n\t\t\t\tif (rule.token !== token) continue;\n\t\t\t\tfor (const surface of rule.on) {\n\t\t\t\t\tconst value = target(rule.level, oklabLightness(colors.get(surface) ?? background), t);\n\t\t\t\t\tif (value === undefined || value < 0 || value > 1) return undefined;\n\t\t\t\t\ttargets.push(value);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst l = lighter ? Math.max(...targets) : Math.min(...targets);\n\t\t\tcolors.set(token, PANELS.includes(token as ThemeBg) ? limitPanel(token, l) : paint(token, l));\n\t\t}\n\t\treturn colors;\n\t};\n\tlet relaxation = 0;\n\tlet colors = solve(0);\n\tif (!colors) {\n\t\tlet [low, high] = [0, 2];\n\t\tcolors = solve(high);\n\t\tfor (let index = 0; index < 20; index++) {\n\t\t\tconst middle = (low + high) / 2;\n\t\t\tconst attempt = solve(middle);\n\t\t\tif (attempt) [high, colors] = [middle, attempt];\n\t\t\telse low = middle;\n\t\t}\n\t\trelaxation = high;\n\t}\n\tconst solved = colors ?? new Map<Surface | ThemeToken, RgbColor>();\n\tconst surfacesOf = (token: ThemeToken) =>\n\t\tRULES.filter((rule) => rule.token === token).flatMap((rule) =>\n\t\t\trule.on.map((surface) => solved.get(surface) ?? background),\n\t\t);\n\tconst result = {} as Record<ThemeToken, string | number>;\n\tfor (const token of Object.keys(TOKEN_FAMILIES) as ThemeToken[]) {\n\t\tconst color = solved.get(token);\n\t\tresult[token] = color ? hexOf(color) : \"\";\n\t}\n\tfor (const token of FOREGROUND_TOKENS) {\n\t\tconst surfaces = surfacesOf(token);\n\t\tlet text = solved.get(token);\n\t\tif (foreground) {\n\t\t\tconst targets = surfaces.map((surface) => target(\"emphasis\", oklabLightness(surface), relaxation));\n\t\t\tif (targets.every((value) => value !== undefined && value >= 0 && value <= 1)) {\n\t\t\t\tconst needed = lighter ? Math.max(...(targets as number[])) : Math.min(...(targets as number[]));\n\t\t\t\tconst foregroundL = oklabLightness(foreground);\n\t\t\t\tif (lighter ? foregroundL >= needed : foregroundL <= needed) {\n\t\t\t\t\tresult[token] = \"\";\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\ttext = anchored(okhslOf(foreground), FAMILIES.neutral, oklabToOkhslLightness(needed), saturation);\n\t\t\t}\n\t\t}\n\t\tif (text) result[token] = hexOf(withTextContrast(text, surfaces, lighter));\n\t}\n\treturn { colors: result, dim: [], appearance };\n}\nfunction okhslOf({ r, g, b }: RgbColor): OkhslChannels {\n\treturn colorToOkhsl(rgbColor(r, g, b));\n}\nfunction anchored(source: OkhslChannels, family: Family, lightness: number, saturation: number): RgbColor {\n\tconst anchor = saturationCurve(family, source.l);\n\tconst falloff = anchor > 0 ? Math.min(1, saturationCurve(family, lightness) / anchor) : 1;\n\treturn okhslColor(source.h, source.s * falloff * saturation, lightness);\n}\nfunction withTextContrast(color: RgbColor, surfaces: RgbColor[], lighter: boolean): RgbColor {\n\tconst meets = (candidate: RgbColor) =>\n\t\tsurfaces.every((surface) => wcagContrast(candidate, surface) >= TEXT_MINIMUM_WCAG_CONTRAST);\n\tif (meets(color)) return color;\n\tconst { h, s, l } = okhslOf(color);\n\tconst at = (lightness: number) => okhslColor(h, s, lightness);\n\tconst extreme = lighter ? 1 : 0;\n\tif (!meets(at(extreme))) return at(extreme);\n\tlet [low, high] = [l, extreme];\n\tfor (let index = 0; index < 20; index++) {\n\t\tconst middle = (low + high) / 2;\n\t\tif (meets(at(middle))) high = middle;\n\t\telse low = middle;\n\t}\n\treturn at(high);\n}\nfunction indexedColors(saturation: number, appearance: ThemeAppearance | undefined): SystemThemeColors {\n\tconst colors = {} as Record<ThemeToken, string | number>;\n\tconst dim: ThemeColor[] = [];\n\tfor (const [token, familyName] of Object.entries(TOKEN_FAMILIES) as [ThemeToken, FamilyName][]) {\n\t\tif (PANELS.includes(token as ThemeBg)) {\n\t\t\tcolors[token] = \"\";\n\t\t\tcontinue;\n\t\t}\n\t\tconst neutral = familyName === \"neutral\";\n\t\tcolors[token] = !neutral && saturation > 0 ? (TOKEN_SLOTS[token] ?? FAMILIES[familyName].slot) : \"\";\n\t\tif (neutral && !FOREGROUND_TOKENS.includes(token as ThemeColor)) dim.push(token as ThemeColor);\n\t}\n\treturn { colors, dim, appearance };\n}\n"]}
1
+ {"version":3,"file":"system-theme.js","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/system-theme.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,YAAY,EACZ,YAAY,EACZ,UAAU,EAEV,UAAU,EACV,qBAAqB,EACrB,UAAU,EAEV,QAAQ,GACR,MAAM,wBAAwB,C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,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;YACnB,SAAS;QACV,CAAC;QACD,MAAM,OAAO,GAAG,UAAU,KAAK,SAAS,CAAC;QACzC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,IAAI,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACpG,IAAI,OAAO,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,KAAmB,CAAC;YAAE,GAAG,CAAC,IAAI,CAAC,KAAmB,CAAC,CAAC;IAChG,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC;AACpC,CAAC","sourcesContent":["import {\n\tcolorToOkhsl,\n\tcolorToOklch,\n\tcolorToRgb,\n\ttype OkhslChannels,\n\tokhslColor,\n\toklabToOkhslLightness,\n\toklchColor,\n\ttype RgbColor,\n\trgbColor,\n} from \"@earendil-works/pi-tui\";\nimport type { ThemeBg, ThemeColor } from \"./theme-class.ts\";\n\nexport const SYSTEM_THEME_NAME = \"system\";\ntype ThemeAppearance = \"dark\" | \"light\";\ntype ThemeToken = ThemeColor | ThemeBg | \"scrollbarTrack\" | \"thinkingMax\";\ninterface Family {\n\thue: number;\n\tsaturation: { min: number; max: number };\n\tslot: number;\n}\nconst FAMILIES = {\n\tneutral: { hue: 231.49, saturation: { min: 0.02, max: 0.08 }, slot: 8 },\n\tblue: { hue: 231.49, saturation: { min: 0.1, max: 0.68 }, slot: 4 },\n\tgreen: { hue: 158.68, saturation: { min: 0.1, max: 0.76 }, slot: 2 },\n\tred: { hue: 20, saturation: { min: 0.1, max: 0.92 }, slot: 1 },\n\tyellow: { hue: 82.36, saturation: { min: 0.5, max: 1 }, slot: 3 },\n\torange: { hue: 52, saturation: { min: 0.12, max: 0.85 }, slot: 3 },\n\tviolet: { hue: 295, saturation: { min: 0.2, max: 0.6 }, slot: 5 },\n\tcalamine: { hue: 202.43, saturation: { min: 0.1, max: 0.74 }, slot: 6 },\n\tthinkingSlate: { hue: 231.49, saturation: { min: 0.08, max: 0.2 }, slot: 4 },\n\tthinkingBlue: { hue: 231.49, saturation: { min: 0.2, max: 0.45 }, slot: 4 },\n\tthinkingPeriwinkle: { hue: 263.25, saturation: { min: 0.3, max: 0.6 }, slot: 6 },\n\tthinkingViolet: { hue: 295, saturation: { min: 0.4, max: 0.75 }, slot: 5 },\n\tthinkingMagenta: { hue: 337.5, saturation: { min: 0.5, max: 0.85 }, slot: 13 },\n\tthinkingRed: { hue: 20, saturation: { min: 0.95, max: 1 }, slot: 1 },\n} satisfies Record<string, Family>;\ntype FamilyName = keyof typeof FAMILIES;\nconst TOKEN_FAMILIES: Record<ThemeToken, FamilyName> = {\n\tselectedBg: \"blue\",\n\tsearchMatchBg: \"orange\",\n\tuserMessageBg: \"blue\",\n\tcustomMessageBg: \"violet\",\n\ttoolPendingBg: \"neutral\",\n\ttoolSuccessBg: \"green\",\n\ttoolErrorBg: \"red\",\n\ttext: \"neutral\",\n\tuserMessageText: \"neutral\",\n\tcustomMessageText: \"neutral\",\n\ttoolTitle: \"neutral\",\n\tsyntaxOperator: \"neutral\",\n\tsyntaxPunctuation: \"neutral\",\n\tmuted: \"neutral\",\n\tdim: \"neutral\",\n\tthinkingText: \"neutral\",\n\ttoolOutput: \"neutral\",\n\tmdLinkUrl: \"neutral\",\n\tmdQuote: \"neutral\",\n\tmdQuoteBorder: \"neutral\",\n\tmdHr: \"neutral\",\n\tmdCodeBlockBorder: \"neutral\",\n\ttoolDiffContext: \"neutral\",\n\tsyntaxComment: \"neutral\",\n\tscrollbarTrack: \"neutral\",\n\tscrollbarThumb: \"neutral\",\n\tsearchMatchText: \"neutral\",\n\tborderMuted: \"neutral\",\n\taccent: \"violet\",\n\tborderAccent: \"violet\",\n\tcustomMessageLabel: \"violet\",\n\tmdCode: \"violet\",\n\tmdListBullet: \"violet\",\n\tsyntaxType: \"violet\",\n\tborder: \"blue\",\n\tmdLink: \"blue\",\n\tsyntaxKeyword: \"blue\",\n\tsyntaxVariable: \"calamine\",\n\tsuccess: \"green\",\n\tmdCodeBlock: \"green\",\n\ttoolDiffAdded: \"green\",\n\tbashMode: \"green\",\n\tsyntaxNumber: \"green\",\n\terror: \"red\",\n\ttoolDiffRemoved: \"red\",\n\twarning: \"yellow\",\n\tmdHeading: \"yellow\",\n\tsyntaxFunction: \"yellow\",\n\tsyntaxString: \"orange\",\n\tthinkingOff: \"neutral\",\n\tthinkingMinimal: \"thinkingSlate\",\n\tthinkingLow: \"thinkingBlue\",\n\tthinkingMedium: \"thinkingPeriwinkle\",\n\tthinkingHigh: \"thinkingViolet\",\n\tthinkingXhigh: \"thinkingMagenta\",\n\tthinkingMax: \"thinkingRed\",\n};\nconst TOKEN_SLOTS: Partial<Record<ThemeToken, number>> = { syntaxString: 2, syntaxNumber: 5, searchMatchBg: 3 };\ninterface Curve {\n\tcoefficients: number[];\n\treachable: [number, number];\n}\n// Upstream's reviewed target-lightness curves, evaluated in OKLab.\nconst LEVELS = {\n\tpanel: {\n\t\tdark: { coefficients: [0.29131, -0.39746, 2.33185, -0.85524, -1.2076, 0.86276], reachable: [0, 0.979] },\n\t\tlight: { coefficients: [-3.74073, 27.94549, -78.44258, 112.6798, -79.60015, 22.11277], reachable: [0.348, 1] },\n\t},\n\ttrack: {\n\t\tdark: { coefficients: [0.39028, -0.23015, 0.83573, 2.43829, -4.38292, 2.01582], reachable: [0, 0.946] },\n\t\tlight: { coefficients: [-5.24921, 38.37322, -107.28833, 152.10005, -106.17127, 29.18061], reachable: [0.368, 1] },\n\t},\n\tthinking0: {\n\t\tdark: { coefficients: [0.52988, -0.05809, -0.30924, 4.63567, -6.52933, 2.89108], reachable: [0, 0.873] },\n\t\tlight: {\n\t\t\tcoefficients: [-28.27749, 182.85284, -469.62416, 603.15916, -384.59976, 97.35147],\n\t\t\treachable: [0.51, 1],\n\t\t},\n\t},\n\tthinking1: {\n\t\tdark: { coefficients: [0.55278, -0.03667, -0.45659, 4.95347, -6.90265, 3.0706], reachable: [0, 0.858] },\n\t\tlight: {\n\t\t\tcoefficients: [-37.10484, 235.86282, -596.62344, 754.3633, -474.00763, 118.3551],\n\t\t\treachable: [0.535, 1],\n\t\t},\n\t},\n\tthinking2: {\n\t\tdark: { coefficients: [0.57486, -0.01765, -0.58987, 5.25227, -7.27175, 3.25532], reachable: [0, 0.842] },\n\t\tlight: {\n\t\t\tcoefficients: [-59.89653, 377.05024, -945.07843, 1182.03145, -734.96375, 181.68658],\n\t\t\treachable: [0.556, 1],\n\t\t},\n\t},\n\tthinking3: {\n\t\tdark: { coefficients: [0.59621, -0.00062, -0.71148, 5.53588, -7.6392, 3.44606], reachable: [0, 0.827] },\n\t\tlight: {\n\t\t\tcoefficients: [-72.07122, 445.84082, -1099.57352, 1353.88793, -829.53392, 202.26164],\n\t\t\treachable: [0.58, 1],\n\t\t},\n\t},\n\tthinking4: {\n\t\tdark: { coefficients: [0.61691, 0.01462, -0.82288, 5.80651, -8.00641, 3.64333], reachable: [0, 0.811] },\n\t\tlight: {\n\t\t\tcoefficients: [-110.14338, 674.21488, -1645.75941, 2004.32367, -1215.15899, 293.3183],\n\t\t\treachable: [0.6, 1],\n\t\t},\n\t},\n\tthinking5: {\n\t\tdark: { coefficients: [0.63702, 0.02826, -0.92498, 6.06465, -8.37246, 3.84651], reachable: [0, 0.795] },\n\t\tlight: {\n\t\t\tcoefficients: [-175.47701, 1063.54495, -2570.70594, 3098.80776, -1860.15527, 444.76392],\n\t\t\treachable: [0.62, 1],\n\t\t},\n\t},\n\tthinking6: {\n\t\tdark: { coefficients: [0.65658, 0.04044, -1.01835, 6.30989, -8.73529, 4.05439], reachable: [0, 0.779] },\n\t\tlight: {\n\t\t\tcoefficients: [-183.81712, 1094.70055, -2602.68539, 3088.71276, -1826.91131, 430.75931],\n\t\t\treachable: [0.643, 1],\n\t\t},\n\t},\n\tsubtle: {\n\t\tdark: { coefficients: [0.56762, -0.02475, -0.5383, 5.12628, -7.10931, 3.17324], reachable: [0, 0.848] },\n\t\tlight: {\n\t\t\tcoefficients: [-232.85459, 1376.54473, -3249.11801, 3827.91186, -2248.29472, 526.55751],\n\t\t\treachable: [0.657, 1],\n\t\t},\n\t},\n\tthumb: {\n\t\tdark: { coefficients: [0.60323, 0.00278, -0.73328, 5.57157, -7.68067, 3.46933], reachable: [0, 0.823] },\n\t\tlight: {\n\t\t\tcoefficients: [-82.89897, 511.01355, -1255.98095, 1540.76821, -940.68087, 228.58523],\n\t\t\treachable: [0.586, 1],\n\t\t},\n\t},\n\treadable: {\n\t\tdark: { coefficients: [0.66937, 0.04704, -1.06871, 6.43941, -8.9332, 4.17229], reachable: [0, 0.77] },\n\t\tlight: {\n\t\t\tcoefficients: [-1554.52576, 8733.56817, -19604.93507, 21977.72696, -12300.99599, 2749.81288],\n\t\t\treachable: [0.751, 1],\n\t\t},\n\t},\n\temphasis: {\n\t\tdark: { coefficients: [0.7303, 0.07695, -1.31626, 7.1681, -10.14436, 4.92846], reachable: [0, 0.712] },\n\t\tlight: {\n\t\t\tcoefficients: [-4948.31942, 26870.91986, -58334.48399, 63280.17197, -34298.01053, 7430.30146],\n\t\t\treachable: [0.811, 1],\n\t\t},\n\t},\n\ttextOnPanel: {\n\t\tdark: { coefficients: [0.86713, 0.05232, -0.89428, 4.79014, -5.5432, 1.75023], reachable: [0, 0.542] },\n\t\tlight: {\n\t\t\tcoefficients: [-8570.89457, 43954.60805, -90084.00702, 92220.6791, -47152.15802, 9632.27113],\n\t\t\treachable: [0.867, 1],\n\t\t},\n\t},\n\ttext: {\n\t\tdark: { coefficients: [0.89242, 0.02311, -0.44862, 2.34417, -0.06084, -2.63844], reachable: [0, 0.5] },\n\t\tlight: {\n\t\t\tcoefficients: [-2004.67048, 6664.47299, -6060.70202, -1792.61209, 5133.82359, -1939.85583],\n\t\t\treachable: [0.894, 1],\n\t\t},\n\t},\n} satisfies Record<string, Record<ThemeAppearance, Curve>>;\ntype Level = keyof typeof LEVELS;\ntype Surface = ThemeBg | \"background\" | \"scrollbarTrack\";\ninterface Rule {\n\ttoken: ThemeToken;\n\ton: Surface[];\n\tlevel: Level;\n}\nconst TOOL_PANELS: Surface[] = [\"toolPendingBg\", \"toolSuccessBg\", \"toolErrorBg\"];\nconst MESSAGE_PANELS: Surface[] = [\"userMessageBg\", \"customMessageBg\"];\nconst PANELS: ThemeBg[] = [\n\t\"userMessageBg\",\n\t\"toolPendingBg\",\n\t\"toolSuccessBg\",\n\t\"toolErrorBg\",\n\t\"selectedBg\",\n\t\"searchMatchBg\",\n\t\"customMessageBg\",\n];\nconst THINKING: ThemeToken[] = [\n\t\"thinkingOff\",\n\t\"thinkingMinimal\",\n\t\"thinkingLow\",\n\t\"thinkingMedium\",\n\t\"thinkingHigh\",\n\t\"thinkingXhigh\",\n\t\"thinkingMax\",\n];\nconst THINKING_LEVELS: Level[] = [\n\t\"thinking0\",\n\t\"thinking1\",\n\t\"thinking2\",\n\t\"thinking3\",\n\t\"thinking4\",\n\t\"thinking5\",\n\t\"thinking6\",\n];\nconst each = (tokens: ThemeToken[], on: Surface[], level: Level): Rule[] =>\n\ttokens.map((token) => ({ token, on, level }));\nconst RULES: Rule[] = [\n\t...each(PANELS, [\"background\"], \"panel\"),\n\t{ token: \"text\", on: [\"background\"], level: \"text\" },\n\t{ token: \"text\", on: [\"selectedBg\"], level: \"textOnPanel\" },\n\t{ token: \"userMessageText\", on: [\"userMessageBg\"], level: \"textOnPanel\" },\n\t{ token: \"toolTitle\", on: TOOL_PANELS, level: \"textOnPanel\" },\n\t...each([\"accent\", \"success\", \"error\", \"warning\"], [\"background\", \"selectedBg\", ...TOOL_PANELS], \"readable\"),\n\t{ token: \"muted\", on: [\"background\", \"selectedBg\", \"customMessageBg\", ...TOOL_PANELS], level: \"readable\" },\n\t{ token: \"dim\", on: [\"background\", \"selectedBg\", \"customMessageBg\", ...TOOL_PANELS], level: \"subtle\" },\n\t{ token: \"thinkingText\", on: [\"background\"], level: \"readable\" },\n\t{ token: \"customMessageText\", on: [\"customMessageBg\", ...TOOL_PANELS], level: \"readable\" },\n\t{\n\t\ttoken: \"customMessageLabel\",\n\t\ton: [\"background\", \"customMessageBg\", \"selectedBg\", ...TOOL_PANELS],\n\t\tlevel: \"readable\",\n\t},\n\t{ token: \"toolOutput\", on: [\"background\", ...TOOL_PANELS], level: \"readable\" },\n\t...each(\n\t\t[\"mdHeading\", \"mdLink\", \"mdLinkUrl\", \"mdCode\", \"mdQuote\", \"mdCodeBlockBorder\", \"mdListBullet\"],\n\t\t[\"background\", ...MESSAGE_PANELS],\n\t\t\"readable\",\n\t),\n\t{ token: \"mdCodeBlock\", on: [\"background\", ...MESSAGE_PANELS, ...TOOL_PANELS], level: \"readable\" },\n\t...each([\"toolDiffAdded\", \"toolDiffRemoved\", \"toolDiffContext\"], [\"background\", ...TOOL_PANELS], \"readable\"),\n\t...each(\n\t\t[\n\t\t\t\"syntaxComment\",\n\t\t\t\"syntaxKeyword\",\n\t\t\t\"syntaxFunction\",\n\t\t\t\"syntaxVariable\",\n\t\t\t\"syntaxString\",\n\t\t\t\"syntaxNumber\",\n\t\t\t\"syntaxType\",\n\t\t\t\"syntaxOperator\",\n\t\t\t\"syntaxPunctuation\",\n\t\t],\n\t\t[\"background\", ...MESSAGE_PANELS, ...TOOL_PANELS],\n\t\t\"readable\",\n\t),\n\t{ token: \"searchMatchText\", on: [\"searchMatchBg\"], level: \"readable\" },\n\t...each([\"bashMode\", \"border\", \"borderAccent\"], [\"background\"], \"readable\"),\n\t{ token: \"borderMuted\", on: [\"background\"], level: \"subtle\" },\n\t...each([\"mdQuoteBorder\", \"mdHr\"], [\"background\", ...MESSAGE_PANELS, ...TOOL_PANELS], \"readable\"),\n\t{ token: \"scrollbarTrack\", on: [\"background\"], level: \"track\" },\n\t{ token: \"scrollbarThumb\", on: [\"scrollbarTrack\"], level: \"thumb\" },\n\t...THINKING.map((token, index): Rule => ({ token, on: [\"background\"], level: THINKING_LEVELS[index] })),\n];\nconst READABLE_FLOOR: Record<ThemeAppearance, Level> = { dark: \"readable\", light: \"subtle\" };\nconst FOREGROUND_TOKENS: ThemeColor[] = [\"text\", \"userMessageText\", \"toolTitle\"];\nconst TEXT_MINIMUM_WCAG_CONTRAST = 4.5;\nconst SOLVE_ORDER: ThemeToken[] = (() => {\n\tconst order: ThemeToken[] = [];\n\tconst visit = (token: ThemeToken): void => {\n\t\tif (order.includes(token)) return;\n\t\tfor (const rule of RULES)\n\t\t\tif (rule.token === token) for (const surface of rule.on) if (surface !== \"background\") visit(surface);\n\t\torder.push(token);\n\t};\n\tfor (const rule of RULES) visit(rule.token);\n\treturn order;\n})();\nexport interface SystemThemeInput {\n\tforeground?: RgbColor;\n\tbackground?: RgbColor;\n\tpalette?: RgbColor[];\n\tsaturation?: number;\n\tappearanceHint?: ThemeAppearance;\n}\nexport interface SystemThemeColors {\n\tcolors: Record<ThemeToken, string | number>;\n\tdim: ThemeColor[];\n\tappearance: ThemeAppearance | undefined;\n}\nfunction oklabLightness(color: RgbColor): number {\n\treturn colorToOklch(rgbColor(color.r, color.g, color.b)).l;\n}\nexport function relativeLuminance({ r, g, b }: RgbColor): number {\n\tconst linear = (channel: number) => {\n\t\tconst value = channel / 255;\n\t\treturn value <= 0.04045 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;\n\t};\n\treturn 0.2126 * linear(r) + 0.7152 * linear(g) + 0.0722 * linear(b);\n}\nexport function wcagContrast(first: RgbColor, second: RgbColor): number {\n\tconst a = relativeLuminance(first);\n\tconst b = relativeLuminance(second);\n\treturn (Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05);\n}\nexport function terminalAppearance(background: RgbColor, foreground?: RgbColor): ThemeAppearance {\n\tconst whiteContrast = wcagContrast({ r: 255, g: 255, b: 255 }, background);\n\tconst blackContrast = wcagContrast({ r: 0, g: 0, b: 0 }, background);\n\tif (foreground) {\n\t\tconst foregroundL = oklabLightness(foreground);\n\t\tconst backgroundL = oklabLightness(background);\n\t\tif (Math.abs(foregroundL - backgroundL) > 0.05) {\n\t\t\tconst appearance = foregroundL > backgroundL ? \"dark\" : \"light\";\n\t\t\tif ((appearance === \"dark\" ? whiteContrast : blackContrast) >= TEXT_MINIMUM_WCAG_CONTRAST) return appearance;\n\t\t}\n\t}\n\treturn whiteContrast >= blackContrast ? \"dark\" : \"light\";\n}\nconst clamp = (value: number, min: number, max: number) => Math.min(max, Math.max(min, value));\nfunction hexOf({ r, g, b }: RgbColor): string {\n\treturn `#${[r, g, b].map((channel) => Math.round(channel).toString(16).padStart(2, \"0\")).join(\"\")}`;\n}\nfunction bellWeight(lightness: number): number {\n\tconst gaussian = (x: number): number => Math.exp(-((x - 0.5) ** 2) / (2 * 0.25 ** 2));\n\treturn (gaussian(lightness) - gaussian(0)) / (1 - gaussian(0));\n}\nfunction saturationCurve({ saturation: { min, max } }: Family, lightness: number): number {\n\tconst floor = max > 0 ? min / max : 1;\n\treturn floor + (1 - floor) * bellWeight(lightness);\n}\nfunction levelTarget(level: Level, appearance: ThemeAppearance, surfaceL: number): number | undefined {\n\tconst curve: Curve = LEVELS[level][appearance];\n\tif (surfaceL < curve.reachable[0] || surfaceL > curve.reachable[1]) return undefined;\n\treturn curve.coefficients.reduce((sum, coefficient, power) => sum + coefficient * surfaceL ** power, 0);\n}\nexport function generateSystemThemeColors(input: SystemThemeInput): SystemThemeColors {\n\tconst saturation = clamp(input.saturation ?? 1, 0, 1);\n\tconst { background, foreground } = input;\n\tif (!background) return indexedColors(saturation, input.appearanceHint);\n\tconst palette = input.palette?.length === 16 ? input.palette.map(sourceOf) : undefined;\n\tconst appearance = terminalAppearance(background, foreground);\n\tconst lighter = appearance === \"dark\";\n\tconst extreme = lighter ? 1 : 0;\n\tconst backgroundL = oklabLightness(background);\n\tconst paint = (token: ThemeToken, oklabL: number): RgbColor => {\n\t\tconst lightness = oklabToOkhslLightness(oklabL);\n\t\tconst family: Family = FAMILIES[TOKEN_FAMILIES[token]];\n\t\tif (!palette) {\n\t\t\tconst { min, max } = family.saturation;\n\t\t\treturn okhslColor(family.hue, (min + (max - min) * bellWeight(lightness)) * saturation, lightness);\n\t\t}\n\t\treturn anchored(palette[TOKEN_SLOTS[token] ?? family.slot], family, lightness, saturation);\n\t};\n\tconst target = (level: Level, surfaceL: number, t: number): number | undefined => {\n\t\tconst reached = levelTarget(level, appearance, surfaceL);\n\t\tif (reached === undefined && t === 0) return undefined;\n\t\tconst distance = (reached ?? extreme) - surfaceL;\n\t\tconst floor = (levelTarget(READABLE_FLOOR[appearance], appearance, surfaceL) ?? extreme) - surfaceL;\n\t\tconst compressed =\n\t\t\tMath.abs(distance) > Math.abs(floor) ? distance - (distance - floor) * Math.min(t, 1) : distance;\n\t\treturn surfaceL + compressed * (1 - Math.max(0, t - 1));\n\t};\n\tconst extremeText = lighter ? { r: 255, g: 255, b: 255 } : { r: 0, g: 0, b: 0 };\n\tconst readable = (color: RgbColor) => wcagContrast(extremeText, color) >= TEXT_MINIMUM_WCAG_CONTRAST;\n\tconst limitPanel = (token: ThemeToken, l: number): RgbColor => {\n\t\tconst color = paint(token, l);\n\t\tif (readable(color)) return color;\n\t\tlet [low, high] = [backgroundL, l];\n\t\tfor (let index = 0; index < 20; index++) {\n\t\t\tconst middle = (low + high) / 2;\n\t\t\tif (readable(paint(token, middle))) low = middle;\n\t\t\telse high = middle;\n\t\t}\n\t\treturn paint(token, low);\n\t};\n\tconst solve = (t: number): Map<Surface | ThemeToken, RgbColor> | undefined => {\n\t\tconst colors = new Map<Surface | ThemeToken, RgbColor>([[\"background\", background]]);\n\t\tfor (const token of SOLVE_ORDER) {\n\t\t\tconst targets: number[] = [];\n\t\t\tfor (const rule of RULES) {\n\t\t\t\tif (rule.token !== token) continue;\n\t\t\t\tfor (const surface of rule.on) {\n\t\t\t\t\tconst value = target(rule.level, oklabLightness(colors.get(surface) ?? background), t);\n\t\t\t\t\tif (value === undefined || value < 0 || value > 1) return undefined;\n\t\t\t\t\ttargets.push(value);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst l = lighter ? Math.max(...targets) : Math.min(...targets);\n\t\t\tcolors.set(token, PANELS.includes(token as ThemeBg) ? limitPanel(token, l) : paint(token, l));\n\t\t}\n\t\treturn colors;\n\t};\n\tlet relaxation = 0;\n\tlet colors = solve(0);\n\tif (!colors) {\n\t\tlet [low, high] = [0, 2];\n\t\tcolors = solve(high);\n\t\tfor (let index = 0; index < 20; index++) {\n\t\t\tconst middle = (low + high) / 2;\n\t\t\tconst attempt = solve(middle);\n\t\t\tif (attempt) [high, colors] = [middle, attempt];\n\t\t\telse low = middle;\n\t\t}\n\t\trelaxation = high;\n\t}\n\tconst solved = colors ?? new Map<Surface | ThemeToken, RgbColor>();\n\tconst surfacesOf = (token: ThemeToken) =>\n\t\tRULES.filter((rule) => rule.token === token).flatMap((rule) =>\n\t\t\trule.on.map((surface) => solved.get(surface) ?? background),\n\t\t);\n\tconst result = {} as Record<ThemeToken, string | number>;\n\tfor (const token of Object.keys(TOKEN_FAMILIES) as ThemeToken[]) {\n\t\tconst color = solved.get(token);\n\t\tresult[token] = color ? hexOf(color) : \"\";\n\t}\n\tfor (const token of FOREGROUND_TOKENS) {\n\t\tconst surfaces = surfacesOf(token);\n\t\tlet text = solved.get(token);\n\t\tif (foreground) {\n\t\t\tconst targets = surfaces.map((surface) => target(\"emphasis\", oklabLightness(surface), relaxation));\n\t\t\tif (targets.every((value) => value !== undefined && value >= 0 && value <= 1)) {\n\t\t\t\tconst needed = lighter ? Math.max(...(targets as number[])) : Math.min(...(targets as number[]));\n\t\t\t\tconst foregroundL = oklabLightness(foreground);\n\t\t\t\tif (lighter ? foregroundL >= needed : foregroundL <= needed) {\n\t\t\t\t\tresult[token] = \"\";\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\ttext = anchored(sourceOf(foreground), FAMILIES.neutral, oklabToOkhslLightness(needed), saturation);\n\t\t\t}\n\t\t}\n\t\tif (text) result[token] = hexOf(withTextContrast(text, surfaces, lighter));\n\t}\n\treturn { colors: result, dim: [], appearance };\n}\nfunction okhslOf({ r, g, b }: RgbColor): OkhslChannels {\n\treturn colorToOkhsl(rgbColor(r, g, b));\n}\ninterface SourceColor extends OkhslChannels {\n\tchroma: number;\n}\nfunction sourceOf(color: RgbColor): SourceColor {\n\treturn { ...okhslOf(color), chroma: colorToOklch(rgbColor(color.r, color.g, color.b)).c };\n}\nfunction anchored(source: SourceColor, family: Family, lightness: number, saturation: number): RgbColor {\n\tconst anchor = saturationCurve(family, source.l);\n\tconst falloff = anchor > 0 ? Math.min(1, saturationCurve(family, lightness) / anchor) : 1;\n\tconst color = okhslColor(source.h, source.s * falloff * saturation, lightness);\n\tconst cap = source.chroma * falloff * saturation;\n\tconst { l, c } = colorToOklch(color);\n\treturn c <= cap ? color : colorToRgb(oklchColor(l, cap, source.h));\n}\nfunction withTextContrast(color: RgbColor, surfaces: RgbColor[], lighter: boolean): RgbColor {\n\tconst meets = (candidate: RgbColor) =>\n\t\tsurfaces.every((surface) => wcagContrast(candidate, surface) >= TEXT_MINIMUM_WCAG_CONTRAST);\n\tif (meets(color)) return color;\n\tconst { h, s, l } = okhslOf(color);\n\tconst at = (lightness: number) => okhslColor(h, s, lightness);\n\tconst extreme = lighter ? 1 : 0;\n\tif (!meets(at(extreme))) return at(extreme);\n\tlet [low, high] = [l, extreme];\n\tfor (let index = 0; index < 20; index++) {\n\t\tconst middle = (low + high) / 2;\n\t\tif (meets(at(middle))) high = middle;\n\t\telse low = middle;\n\t}\n\treturn at(high);\n}\nfunction indexedColors(saturation: number, appearance: ThemeAppearance | undefined): SystemThemeColors {\n\tconst colors = {} as Record<ThemeToken, string | number>;\n\tconst dim: ThemeColor[] = [];\n\tfor (const [token, familyName] of Object.entries(TOKEN_FAMILIES) as [ThemeToken, FamilyName][]) {\n\t\tif (PANELS.includes(token as ThemeBg)) {\n\t\t\tcolors[token] = \"\";\n\t\t\tcontinue;\n\t\t}\n\t\tconst neutral = familyName === \"neutral\";\n\t\tcolors[token] = !neutral && saturation > 0 ? (TOKEN_SLOTS[token] ?? FAMILIES[familyName].slot) : \"\";\n\t\tif (neutral && !FOREGROUND_TOKENS.includes(token as ThemeColor)) dim.push(token as ThemeColor);\n\t}\n\treturn { colors, dim, appearance };\n}\n"]}
@@ -0,0 +1,214 @@
1
+ ---
2
+ title: "Codemode"
3
+ description: "The codemode script reference: globals, tool calls, stored values, classifier and image models, and limits."
4
+ ---
5
+
6
+ # Codemode
7
+
8
+ The `codemode` tool lets the model write a JavaScript script that calls Atomic's other tools and runs non-LLM models, such as classifiers and image models. Only the script's output reaches the model, so a script can run calls in parallel and filter large results before the model sees them. To turn it on, see [`codemode` in Built-in tools](/tools#codemode).
9
+
10
+ ## Scripts
11
+
12
+ The tool input is raw JavaScript source, not JSON and not a markdown code fence. It runs as the body of an async function in a QuickJS sandbox, so top-level `await` and `return` work. The sandbox has no Node APIs, file system, network, or timers; scripts reach the outside world only through tools and `models`.
13
+
14
+ A script may start with an options line:
15
+
16
+ ```js
17
+ // @options: {"max_output_tokens": 2000, "timeout_ms": 60000}
18
+ ```
19
+
20
+ - `max_output_tokens` (default 10000) limits the output. Longer output keeps its start and end, and the full text is written to a temp file whose path is included in the result.
21
+ - `timeout_ms` is a hard deadline for the whole script. It is unset by default. Image generation can take minutes, so do not set a short deadline for scripts that generate images.
22
+
23
+ The result starts with `Script completed` or `Script failed`, the wall time, and the output. A failed script keeps its partial output, followed by `Script error:` and the error. Tool calls are real: calls made before a failure are not undone. Calls still running when the script ends are cancelled, and unawaited promises are discarded.
24
+
25
+ ## Globals
26
+
27
+ | Global | Purpose |
28
+ |---|---|
29
+ | `tools.<name>(args)` | Call a tool. See [Call tools](#call-tools). |
30
+ | `text(value)` | Add a text item to the output. Strings are added as is, other values as JSON. |
31
+ | `image(value)` | Add an image to the output: a base64 `data:` URL, an `{ image_url }` object, or an image block `{ type: "image", data, mimeType }` such as those returned by MCP tools and `models.generateImages()`. Remote URLs are not supported. PNG, JPEG, GIF, and WebP are accepted. |
32
+ | `console.log(...)` | Like `text()`; `info`, `warn`, `error`, and `debug` do the same. |
33
+ | `return value` | A top-level `return` adds the value like `text()`. |
34
+ | `exit()` | End the script successfully. |
35
+ | `store(key, value)` / `load(key)` | Keep small JSON values across `codemode` calls. See [Store values](#store-values). |
36
+ | `ALL_TOOLS` | Every callable tool as `{ name, description }`, including tools the description does not list. |
37
+ | `searchTools(query, { limit?, namespace? })` | Rank callable tools by relevance (BM25, default limit 8). Resolves to `{ name, description }[]`. |
38
+ | `describeTool(name)` | Resolves to a tool's description and TypeScript declaration, or `undefined`. |
39
+ | `describeNamespace(name)` | Resolves to `{ name, description?, instructions?, tools }` for a namespace such as an MCP server, or `undefined`. |
40
+ | `models` | List and run non-LLM models. See [Models](#models). |
41
+
42
+ ## Call tools
43
+
44
+ Every tool the session can call is a method of `tools`, named by its identifier: characters that are not valid in a JavaScript identifier become `_`, so the MCP tool `mcp__dev-docs__search` is `tools.mcp__dev_docs__search`. Each method takes one object with the tool's arguments.
45
+
46
+ What a call resolves to depends on the tool:
47
+
48
+ - Tools with an output schema resolve to a structured value. `bash` resolves to `{ output, truncated, full_output_path?, exit_code, wall_time_seconds }`, also for non-zero exit codes. Its `output` is not limited to what the model sees directly: it holds up to 1 MiB, and longer output keeps its first and last 512 KiB around an omission marker, with `truncated` set and the full output in `full_output_path`.
49
+ - MCP tools resolve to their `CallToolResult`, including `isError` and `structuredContent`.
50
+ - Other tools, such as `read`, `edit`, and `write`, resolve to their text output.
51
+
52
+ A call that fails, is blocked, or gets invalid arguments rejects with an `Error` that carries the tool's error text. Use `Promise.allSettled()` to keep the results of the calls that succeed. Reading a tool that does not exist throws an error that names the close matches, so `tools.Bash` suggests `tools.bash`; check for a tool with `"name" in tools`.
53
+
54
+ The `codemode` description lists tools with their TypeScript declarations, grouped by namespace (for example one MCP server). Tools with `deferred` exposure are not listed, so the description stays the same while they register. Listed declarations share a budget of 3000 estimated tokens (`codemode.inlineBudget` in [settings](/settings#tools)). Scripts find the other tools with `searchTools()`, `describeTool()`, `describeNamespace()`, or by filtering `ALL_TOOLS`.
55
+
56
+ While `codemode` is active, `codemode.mode` in [settings](/settings#tools) decides how the other tools are presented. With `on` (default) declared tools stay declared, and their descriptions say in one line how scripts call them and what the call resolves to. With `only` they are hidden from the model and listed in the `codemode` description instead, so the model calls them through scripts.
57
+
58
+ ## Store values
59
+
60
+ `store(key, value)` keeps a JSON value under a string key for later `codemode` calls; storing `undefined` deletes the key. `load(key)` returns the value, or `undefined`. Writes are kept only when the script succeeds: each successful script that stores values appends a `codemode-store` custom entry to the session, so resumed sessions keep the values and each branch sees only the values written on its path.
61
+
62
+ The store is for small state such as IDs, cursors, or summaries. One value may have at most 262144 characters of JSON and all values together at most 1048576. Do not store image data; show images with `image()` or write them to a file with a tool.
63
+
64
+ ## Models
65
+
66
+ `models` reaches the model catalog and runs non-LLM models with the session's credentials: classifiers, which answer typed questions about JSON state, and image models, which generate images. Chat models are listed but cannot be run from scripts. Classifier models include [TypeSafe Jev](/providers#typesafe-jev) and [local llama.cpp models](/llama-cpp); image models include OpenRouter's, such as `google/gemini-2.5-flash-image` and `black-forest-labs/flux.2-pro`, which use the same `OPENROUTER_API_KEY` or `/login` credential as its chat models. Neither kind appears in `/model`.
67
+
68
+ ```ts
69
+ type ModelType = "chat" | "image" | "classifier";
70
+
71
+ /** A catalog entry. `provider` and `id` identify it; other fields depend on the type. */
72
+ interface ModelInfo {
73
+ type?: ModelType;
74
+ provider: string;
75
+ id: string;
76
+ name: string;
77
+ api: string;
78
+ input: ("text" | "image")[];
79
+ contextWindow?: number;
80
+ [key: string]: unknown;
81
+ }
82
+
83
+ declare const models: {
84
+ /** Every known model of a type, optionally for one provider. */
85
+ getModelsOfType(type: ModelType, provider?: string): Promise<ModelInfo[]>;
86
+ /** Models of a type whose provider has working credentials. */
87
+ getAvailableOfType(type: ModelType, provider?: string): Promise<ModelInfo[]>;
88
+ /** One catalog entry, or undefined. */
89
+ getModelOfType(type: ModelType, provider: string, id: string): Promise<ModelInfo | undefined>;
90
+ /** Answer `context.questions` about `context.state`; answers are in `result.answers` by question ID. */
91
+ classify(model: ModelInfo, context: ClassifierContext): Promise<ClassifierResult>;
92
+ /** Generate images from `context.input` text and image blocks; show `result.output` blocks with image(). Can take minutes. */
93
+ generateImages(model: ModelInfo, context: ImagesContext): Promise<ImagesResult>;
94
+ };
95
+ ```
96
+
97
+ `classify()` and `generateImages()` use only the `provider` and `id` of `model`, so `{ provider, id }` works as well, and a script-supplied `baseUrl` or headers never receive the credentials. They do not throw on provider errors: check `stopReason` and `errorMessage`. A malformed model or context does throw, with the expected shape in the message; an unknown or mistyped model points to `models.getAvailableOfType()`. At most four such calls run at once per script; more calls wait for a free slot, so `Promise.all()` over many items is fine. Their usage is added to the `codemode` tool result and counts toward the session cost.
98
+
99
+ Model IDs differ between providers. Use `models.getAvailableOfType(type)` to find the IDs that work with the current credentials.
100
+
101
+ ### Classify
102
+
103
+ ```ts
104
+ interface ClassifierContext {
105
+ /** The data to classify. */
106
+ state: Record<string, unknown>;
107
+ /** Questions by ID. One call answers all of them. */
108
+ questions: Record<string, ClassifierQuestion>;
109
+ }
110
+
111
+ type ClassifierQuestion =
112
+ /** Pick one label. `criteria` maps each label to what it means. */
113
+ | { type: "choice"; instructions: string; criteria: Record<string, string> }
114
+ /** Score on an ordered scale. `criteria` describes each level, lowest first. */
115
+ | { type: "score"; instructions: string; criteria: string[] }
116
+ /** Yes or no. */
117
+ | { type: "bool"; instructions: string; criteria: { true: string; false: string } };
118
+
119
+ interface ClassifierResult {
120
+ provider: string;
121
+ model: string;
122
+ /** Answers by question ID. */
123
+ answers: Record<string, ClassifierAnswer>;
124
+ usage?: ModelUsage;
125
+ stopReason: "stop" | "error" | "aborted";
126
+ errorMessage?: string;
127
+ }
128
+
129
+ type ClassifierAnswer =
130
+ | { type: "choice"; choice: string; probabilities: Record<string, number>; confidence: number }
131
+ /** `score` is the expected level index, from 0 to `criteria.length - 1`. */
132
+ | { type: "score"; score: number; confidence: number }
133
+ /** Probability of `true`. */
134
+ | { type: "bool"; probability: number };
135
+
136
+ /** Token counts and cost in USD, when the service reports them. */
137
+ type ModelUsage = { input: number; output: number; totalTokens: number; cost: { total: number } };
138
+ ```
139
+
140
+ Classify several items by calling `classify()` once per item. This script sorts feedback messages, for example ones a tool returned earlier in the script:
141
+
142
+ ```js
143
+ const jev = await models.getModelOfType("classifier", "typesafe", "jev-latest");
144
+ const results = await Promise.all(
145
+ messages.map((message) =>
146
+ models.classify(jev, {
147
+ state: { message },
148
+ questions: {
149
+ sentiment: {
150
+ type: "choice",
151
+ instructions: "How does the user feel about the product?",
152
+ criteria: { positive: "Satisfied or happy", negative: "Unhappy or frustrated", neutral: "Neither" },
153
+ },
154
+ urgency: {
155
+ type: "score",
156
+ instructions: "How urgently does this need a reply?",
157
+ criteria: ["no reply needed", "reply this week", "reply today"],
158
+ },
159
+ },
160
+ }),
161
+ ),
162
+ );
163
+ return results.map((result, i) =>
164
+ result.stopReason === "stop"
165
+ ? { message: messages[i], sentiment: result.answers.sentiment.choice, urgency: result.answers.urgency.score }
166
+ : { message: messages[i], error: result.errorMessage },
167
+ );
168
+ ```
169
+
170
+ ### Generate images
171
+
172
+ ```ts
173
+ interface ImagesContext {
174
+ /** The prompt as text blocks, plus image blocks to edit or use as references. */
175
+ input: (TextBlock | ImageBlock)[];
176
+ }
177
+
178
+ interface ImagesResult {
179
+ provider: string;
180
+ model: string;
181
+ /** Generated images, and text blocks for models that also return text. */
182
+ output: (TextBlock | ImageBlock)[];
183
+ usage?: ModelUsage;
184
+ stopReason: "stop" | "error" | "aborted";
185
+ errorMessage?: string;
186
+ }
187
+
188
+ type TextBlock = { type: "text"; text: string };
189
+ /** `data` is base64. */
190
+ type ImageBlock = { type: "image"; data: string; mimeType: string };
191
+ ```
192
+
193
+ Show generated images with `image(block)`. Do not print `data` with `text()`, `console`, or `return`: it is large and the model cannot read it as text. A script that generates images without showing any gets a note saying so. Generated images are not saved to disk; to keep one, write it to a file with a tool.
194
+
195
+ ```js
196
+ // @options: {"timeout_ms": 300000}
197
+ const painter = await models.getModelOfType("image", "openrouter", "google/gemini-2.5-flash-image");
198
+ const result = await models.generateImages(painter, {
199
+ input: [{ type: "text", text: "A red fox in the snow, watercolor" }],
200
+ });
201
+ if (result.stopReason !== "stop") return result.errorMessage;
202
+ for (const block of result.output) {
203
+ if (block.type === "image") image(block);
204
+ else text(block.text);
205
+ }
206
+ ```
207
+
208
+ Extensions call classifiers and image models through `ctx.modelRegistry.classify()` and `ctx.modelRegistry.generateImages()`, without codemode.
209
+
210
+ ## Limits
211
+
212
+ - A script's VM has 256 MB of memory. Running out throws `InternalError: out of memory`; filter or aggregate large data instead of accumulating it.
213
+ - A script that waits on a promise that can never settle (no tool call pending) fails immediately, since there are no timers.
214
+ - Scripts cannot start other `codemode` scripts.
@@ -79,6 +79,8 @@ OAuth callbacks run in the engine in isolated interactive mode. Use the provided
79
79
 
80
80
  `loginLabel` sets the dialog title. `usesCallbackServer: true` offers a redirect-URL paste field alongside the browser callback.
81
81
 
82
+ For the native `pi.registerProvider(provider)` form, set `provider.auth.oauth.usesCallbackServer: true` when the flow races a callback server against `interaction.prompt({ type: "manual_code", message: "Paste redirect URL:" })`. This shows the paste field even under a custom provider ID. The built-in Anthropic, OpenAI, OpenAI Codex, and OpenRouter OAuth objects already carry this flag; preserve it when cloning or wrapping them. Set it explicitly to `false` for a replacement flow that does not use a callback server. Legacy `pi.registerProvider(id, config)` registrations continue to use `config.oauth.usesCallbackServer`.
83
+
82
84
  Successful login persists credentials before refreshing the catalog. Logout removes stored credentials without calling `refreshModels`. Escape or Ctrl+C cancels the matching login and preserves the previous credentials and catalog. Later registrations still override earlier providers by ID.
83
85
 
84
86
  Intentional cancellation is quiet, including native `AbortError`, an aborted signal or its exact reason, nested abort causes, and the legacy exact `Login cancelled` error. Provider denial, timeout, network/protocol errors, malformed responses, token exchange failures, and storage failures remain visible. Catalog-refresh failures are reported by `/model` while cached models remain selectable; they do not turn a persisted login into a failed transaction.
@@ -5,6 +5,38 @@ description: Register and unregister a provider, and the API types a provider im
5
5
 
6
6
  # Register a provider
7
7
 
8
+ ## Multiple accounts for one provider
9
+
10
+ Use `pi.registerProviderAlias()` instead of copying a provider's models, OAuth methods, and transport. Register aliases in the extension factory so they are available at startup:
11
+
12
+ ```typescript
13
+ import type { ExtensionAPI } from "@bastani/atomic";
14
+
15
+ export default function (pi: ExtensionAPI) {
16
+ for (let account = 1; account <= 7; account++) {
17
+ pi.registerProviderAlias({
18
+ id: `openai-${account}`,
19
+ name: `OpenAI account ${account}`,
20
+ provider: "openai",
21
+ });
22
+ }
23
+ }
24
+ ```
25
+
26
+ Run `/login openai-1` and choose **Sign in with ChatGPT**, then select an `openai-1` model with `/model`. Repeat for each account. The source `openai` uses the new OpenAI ChatGPT login, not the separate `openai-codex` login.
27
+
28
+ Each alias stores and refreshes its own credentials. An alias does not borrow the source's stored login or ambient API key. Keeping an existing alias ID, such as `openai-1`, preserves credentials already saved under that ID. Confirm the intended account in the browser when logging into each alias; an alias name does not select a browser account or provide extra quota.
29
+
30
+ Aliases support OAuth credentials and non-empty stored API keys. For ambient-only authentication, such as an AWS profile or environment-based service account, use the original provider or a full custom registration instead.
31
+
32
+ Source endpoint and header configuration is shared too. Do not hard-code account credentials in source headers when using aliases; supply each account through `/login`.
33
+
34
+ Aliases inherit the source's current models, Fast variants, OAuth callback support, and request handling. Callbacks and saved messages retain the alias ID. Source catalog updates are shared, while availability filters receive each alias's own credential. Aliases do not run account-specific catalog discovery with their credentials; use a full provider registration if each account requires a separately discovered catalog.
35
+
36
+ The source must already be registered and cannot itself be an alias. Alias IDs must not replace an existing provider. Configure endpoints and models on the source rather than on the alias. Use `pi.unregisterProvider("openai-1")` to remove an alias without deleting its saved credentials. Aliases follow normal extension reload and rollback behavior.
37
+
38
+ This API requires an Atomic version that includes provider aliases. Older versions report `registerProviderAlias is not a function`; upgrade Atomic before loading an alias extension.
39
+
8
40
  ## Register New Provider
9
41
 
10
42
  To add a completely new provider, specify `models` along with the required configuration.
@@ -17,6 +17,7 @@ Extensions can register custom model providers via `pi.registerProvider()`. This
17
17
  This page gets you to a first working provider extension. Each part of the job has its own page:
18
18
 
19
19
  - [Override an existing provider](/custom-provider/override) — change a provider Atomic already ships.
20
+ - [Multiple accounts for one provider](/custom-provider/registration#multiple-accounts-for-one-provider) — inherit provider behavior with separate logins.
20
21
  - [Register a provider](/custom-provider/registration) — register and unregister a provider, and the API types it implements.
21
22
  - [Provider OAuth](/custom-provider/oauth) — login callbacks, credential storage, and dynamic catalog refresh.
22
23
  - [Provider streaming API](/custom-provider/streaming) — events, content blocks, tool calls, stop reasons, and usage.
package/docs/docs.json CHANGED
@@ -182,6 +182,7 @@
182
182
  "environment-variables",
183
183
  "keybindings",
184
184
  "tools",
185
+ "codemode",
185
186
  "mcp-servers",
186
187
  "web-access",
187
188
  "session-format"
@@ -63,6 +63,8 @@ Access models, auth state, and provider-aware requests.
63
63
 
64
64
  Use `ctx.modelRegistry.complete()` for an extension model request that must use Atomic's provider composition. It dispatches through the active `ModelRuntime`, retaining registered custom providers and resolved request auth: the credential-specific `baseUrl`, headers (including `null` suppression markers), and environment values.
65
65
 
66
+ Use `ctx.modelRegistry.generateImages(model, context, options)` to run an image model with request-time authentication. It resolves to the generated image blocks and usage, and reports provider errors through `stopReason` and `errorMessage` instead of rejecting.
67
+
66
68
  For streaming requests, use `ctx.modelRegistry.streamSimple(model, context, options)` with provider-neutral options, or `stream()` with API-specific options. Both use configured providers and request-time authentication, including extension registrations. Iterate the returned `AssistantMessageEventStream` for events and await `.result()` for the final message. Setup failures produce error events and error results. The global compatibility streaming functions do not see extension provider registrations.
67
69
 
68
70
  ```typescript
@@ -34,7 +34,7 @@ atomic
34
34
 
35
35
  You can also run `/login`, choose **Use an API key**, then select a provider to store the key in `~/.atomic/agent/auth.json`.
36
36
 
37
- See [Providers](/providers) for all supported providers, environment variables, and cloud-provider setup.
37
+ See [Providers](/providers) for all supported providers, environment variables, and provider-specific setup.
38
38
 
39
39
  ## Verify authentication
40
40
 
@@ -49,7 +49,7 @@ The model picker should list selectable models for the provider you configured,
49
49
  - Re-run `/login`.
50
50
  - If using an API key, confirm its environment variable is exported in the shell that launched Atomic.
51
51
 
52
- `/login` opens **Select authentication method:**. Choose **Use a subscription** or **Use an API key** to see the corresponding provider picker and credential-configuration status. That status can reflect stored, environment, runtime, or configuration credentials; it does not test connectivity or prove that a provider will accept a request.
52
+ `/login` opens **Select authentication method:**. Choose **Use a subscription** or **Use an API key** to see the corresponding provider picker and credential-configuration status. That status can reflect stored, environment, runtime, or configuration credentials; it does not test connectivity or prove that a provider will accept a request. OAuth sign-ins that are not backed by a subscription are labeled **account** in the provider pickers and status. Cancelling a sign-in returns to the menu you started it from.
53
53
 
54
54
  Select a model with `/model`, then send a short prompt such as `Reply with hello.` A successful response confirms access for that request. If it fails, check the reported authentication, quota, model-access, or network error before retrying. A configured credential or a listed model alone does not prove access.
55
55
 
package/docs/guides.md CHANGED
@@ -17,7 +17,7 @@ Looking to extend or embed Atomic? Go to [Build with Atomic](/build). Looking up
17
17
  2. [Configure Atomic](/guides/configuration) — write a settings file and override it per project.
18
18
  3. [Sessions](/sessions) — save, resume, name, and branch sessions.
19
19
  4. [Context and compaction](/compaction) — keep long sessions inside the context window.
20
- 5. [Providers](/providers) — subscription logins, API keys, and cloud providers.
20
+ 5. [Providers](/providers) — subscription logins, API keys, and provider-specific setup.
21
21
  6. [Local models](/llama-cpp) — run models locally with llama.cpp.
22
22
  7. [Security](/security) — project trust and sandbox boundaries.
23
23
  8. [Containerization](/containerization) — run Atomic inside a container.
@@ -155,6 +155,8 @@ For a remote OAuth server, configure its URL and run `/mcp login my-server`, or
155
155
 
156
156
  Atomic registers OAuth clients as `atomic`, stores credentials in `~/.atomic/agent/mcp-auth.json`, and refreshes tokens when they expire or are rejected. A successful sign-in reconnects the server. If additional scope is required, sign in again. `/mcp logout my-server` or `atomic mcp logout my-server` deletes stored credentials. Old adapter credential files are not imported; sign in through the native client.
157
157
 
158
+ Credentials belong to a server name and URL. Servers with the same URL under different names, such as one per account, sign in separately; servers with the same name and URL in different `mcp.json` files share one sign-in.
159
+
158
160
  OAuth applies to HTTP servers without an `Authorization` header or provider-token configuration. For a pre-registered client:
159
161
 
160
162
  ```json
package/docs/providers.md CHANGED
@@ -4,7 +4,7 @@ Atomic supports subscription-based providers via OAuth and API-key providers via
4
4
 
5
5
  ## On this page and its reference
6
6
 
7
- This page is provider setup: subscriptions, API keys, cloud providers, and local llama.cpp. The exact contracts — provider stop reasons and credential resolution order — live in the [Provider reference](/providers/reference).
7
+ This page is provider setup: subscriptions, API keys, provider-specific configuration, and local llama.cpp. The exact contracts — provider stop reasons and credential resolution order — live in the [Provider reference](/providers/reference).
8
8
 
9
9
  ## Table of Contents
10
10
 
@@ -12,7 +12,7 @@ This page is provider setup: subscriptions, API keys, cloud providers, and local
12
12
  - [Verify readiness before a session](#verify-readiness-before-a-session)
13
13
  - [API Keys](#api-keys)
14
14
  - [Auth File](#auth-file)
15
- - [Cloud Providers](#cloud-providers)
15
+ - [Provider Specific Config](#provider-specific-config)
16
16
  - [llama.cpp](#llama-cpp)
17
17
  - [Stop Reasons](/providers/reference#stop-reasons)
18
18
  - [Resolution Order](/providers/reference#resolution-order)
@@ -330,7 +330,9 @@ The `key` field supports command execution, environment interpolation, and liter
330
330
 
331
331
  Legacy uppercase env-var-like values such as `MY_API_KEY` are migrated to `$MY_API_KEY` on startup only when that environment variable is present during migration; otherwise the value is preserved as a literal. The same explicit `$ENV_VAR` rule and guarded legacy migration apply to custom provider `apiKey` and header values in `models.json`; see [Custom Models](/models). OAuth credentials are also stored here after `/login` and managed automatically.
332
332
 
333
- ## Cloud Providers
333
+ ## Provider Specific Config
334
+
335
+ The providers below have additional setup, need additional settings, or can use credentials supplied by their platform.
334
336
 
335
337
  ### Azure OpenAI
336
338
 
@@ -120,7 +120,7 @@ When a print-mode turn correctly finishes by calling an opt-in terminating struc
120
120
 
121
121
  | Option | Description |
122
122
  |--------|-------------|
123
- | `--provider <name>` | Provider, such as `anthropic`, `openai`, or `google` |
123
+ | `--provider <name>` | Provider to search for `--model`, such as `anthropic`, `openai`, or `google`; requires `--model` |
124
124
  | `--model <pattern>` | Model pattern or ID; supports `provider/id` and optional `:<thinking>` |
125
125
  | `--api-key <key>` | API key, overriding environment variables |
126
126
  | `--thinking <level>` | `off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`; model capability mapping still governs availability |
package/docs/settings.md CHANGED
@@ -187,7 +187,7 @@ See [Providers](/providers#fast-models) for which providers publish fast variant
187
187
  | `fullscreenExitOutput` | string | `"transcript"` | Fullscreen exit output: `"transcript"` prints the final transcript and session resume hint, while `"resume-hint"` restores the terminal's previous screen and prints only the resume hint. Settable from `/settings` |
188
188
  | `fullscreenCopyOnSelect` | boolean | `true` | Copy fullscreen text selections automatically on mouse release. When `false`, selection only highlights text. Ctrl+X does not copy; `/copy` copies the last assistant message. Settable from `/settings` |
189
189
  | `fullscreenWheelScrollLines` | `"auto"` or number | `"auto"` | Lines per mouse-wheel tick in fullscreen views. `"auto"` uses terminal-aware scrolling; numeric values are clamped to 1–100. Settable from `/settings` |
190
- | `quietStartup` | boolean | `false` | Hide startup header |
190
+ | `quietStartup` | boolean or `"header"` | `false` | `true` hides the startup header. `"header"` keeps the startup header but hides the model scope line |
191
191
  | `defaultProjectTrust` | string | `"ask"` | Fallback project trust behavior: `"ask"`, `"always"`, or `"never"`. Global setting only |
192
192
  | `collapseChangelog` | boolean | `false` | Show condensed changelog after updates |
193
193
  | `enableInstallTelemetry` | boolean | `true` | Send a version-adoption ping on the first interactive launch with fresh settings, and on the first interactive launch after an update whose version has changelog entries. This does not control update checks |
@@ -29,6 +29,8 @@ Atomic enables enhanced key reporting when available. If Terminal.app still send
29
29
 
30
30
  This fallback only works when Atomic runs on the same Mac as Terminal.app. It cannot detect the local keyboard over remote SSH.
31
31
 
32
+ Terminal.app draws gaps between rows of the block-character logo in the startup header. There, Atomic shows a text `∀ Atomic` wordmark with the version and session details instead of the logo.
33
+
32
34
  ## Ghostty
33
35
 
34
36
  Add to your Ghostty config (`~/Library/Application Support/com.mitchellh.ghostty/config` on macOS, `~/.config/ghostty/config` on Linux):