kiokuko-dsh 0.2.0 → 0.2.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 (294) hide show
  1. package/PERMISSIONS.md +21 -28
  2. package/README.ja.md +5 -2
  3. package/README.md +8 -2
  4. package/THIRD_PARTY_NOTICES.md +8 -0
  5. package/dist/client.cjs +2248 -1383
  6. package/dist/client.d.ts +3 -1
  7. package/dist/client.d.ts.map +1 -1
  8. package/dist/deep-thinker/configuration.d.ts.map +1 -1
  9. package/dist/deep-thinker/configuration.js +8 -5
  10. package/dist/deep-thinker/configuration.js.map +1 -1
  11. package/dist/deep-thinker/core/contracts.d.ts +107 -13
  12. package/dist/deep-thinker/core/contracts.d.ts.map +1 -1
  13. package/dist/deep-thinker/core/contracts.js +4 -2
  14. package/dist/deep-thinker/core/contracts.js.map +1 -1
  15. package/dist/deep-thinker/memory-finalizer.d.ts +10 -10
  16. package/dist/deep-thinker/memory-finalizer.js +2 -2
  17. package/dist/deep-thinker/memory-finalizer.js.map +1 -1
  18. package/dist/deep-thinker/report.d.ts +1 -1
  19. package/dist/deep-thinker/store.d.ts +10 -10
  20. package/dist/deep-thinker/store.d.ts.map +1 -1
  21. package/dist/deep-thinker/store.js +2 -2
  22. package/dist/deep-thinker/store.js.map +1 -1
  23. package/dist/dsh/agenticreplay-read-service.d.ts.map +1 -1
  24. package/dist/dsh/agenticreplay-read-service.js +2 -1
  25. package/dist/dsh/agenticreplay-read-service.js.map +1 -1
  26. package/dist/dsh/agenticreplay-security.d.ts +2 -0
  27. package/dist/dsh/agenticreplay-security.d.ts.map +1 -1
  28. package/dist/dsh/agenticreplay-security.js +67 -0
  29. package/dist/dsh/agenticreplay-security.js.map +1 -1
  30. package/dist/dsh/completion-verifiers.d.ts +26 -0
  31. package/dist/dsh/completion-verifiers.d.ts.map +1 -0
  32. package/dist/dsh/completion-verifiers.js +9 -0
  33. package/dist/dsh/completion-verifiers.js.map +1 -0
  34. package/dist/dsh/config.d.ts +5 -1
  35. package/dist/dsh/config.d.ts.map +1 -1
  36. package/dist/dsh/core/host.d.ts +1 -1
  37. package/dist/dsh/core/host.d.ts.map +1 -1
  38. package/dist/dsh/core/host.js +49 -4
  39. package/dist/dsh/core/host.js.map +1 -1
  40. package/dist/dsh/core/index.d.ts +4 -4
  41. package/dist/dsh/core/tasks.d.ts.map +1 -1
  42. package/dist/dsh/core/tasks.js +7 -0
  43. package/dist/dsh/core/tasks.js.map +1 -1
  44. package/dist/dsh/core-runtime.d.ts +1 -0
  45. package/dist/dsh/core-runtime.d.ts.map +1 -1
  46. package/dist/dsh/core-runtime.js +4 -1
  47. package/dist/dsh/core-runtime.js.map +1 -1
  48. package/dist/dsh/decisions/config.d.ts +2 -2
  49. package/dist/dsh/enno-delegation.js +2 -2
  50. package/dist/dsh/enno-delegation.js.map +1 -1
  51. package/dist/dsh/execution-command.d.ts +4 -0
  52. package/dist/dsh/execution-command.d.ts.map +1 -0
  53. package/dist/dsh/execution-command.js +52 -0
  54. package/dist/dsh/execution-command.js.map +1 -0
  55. package/dist/dsh/execution-journal.d.ts +17 -0
  56. package/dist/dsh/execution-journal.d.ts.map +1 -0
  57. package/dist/dsh/execution-journal.js +69 -0
  58. package/dist/dsh/execution-journal.js.map +1 -0
  59. package/dist/dsh/execution-result.d.ts +20 -0
  60. package/dist/dsh/execution-result.d.ts.map +1 -0
  61. package/dist/dsh/execution-result.js +7 -0
  62. package/dist/dsh/execution-result.js.map +1 -0
  63. package/dist/dsh/execution-selection.d.ts +149 -22
  64. package/dist/dsh/execution-selection.d.ts.map +1 -1
  65. package/dist/dsh/execution-selection.js +18 -6
  66. package/dist/dsh/execution-selection.js.map +1 -1
  67. package/dist/dsh/host-adapter/admission.d.ts.map +1 -1
  68. package/dist/dsh/host-adapter/admission.js +20 -0
  69. package/dist/dsh/host-adapter/admission.js.map +1 -1
  70. package/dist/dsh/host-adapter/turn-state.js +1 -1
  71. package/dist/dsh/host-adapter/turn-state.js.map +1 -1
  72. package/dist/dsh/host-adapter.d.ts.map +1 -1
  73. package/dist/dsh/host-adapter.js +26 -13
  74. package/dist/dsh/host-adapter.js.map +1 -1
  75. package/dist/dsh/index.d.ts +4 -2
  76. package/dist/dsh/index.d.ts.map +1 -1
  77. package/dist/dsh/index.js +7 -0
  78. package/dist/dsh/index.js.map +1 -1
  79. package/dist/dsh/intake-gate.d.ts +1 -0
  80. package/dist/dsh/intake-gate.d.ts.map +1 -1
  81. package/dist/dsh/intake-gate.js +9 -1
  82. package/dist/dsh/intake-gate.js.map +1 -1
  83. package/dist/dsh/lisp/approval.d.ts +2 -1
  84. package/dist/dsh/lisp/approval.d.ts.map +1 -1
  85. package/dist/dsh/lisp/approval.js +4 -3
  86. package/dist/dsh/lisp/approval.js.map +1 -1
  87. package/dist/dsh/lisp/candidate.d.ts +3 -3
  88. package/dist/dsh/lisp/code-intelligence-contracts.d.ts +78 -0
  89. package/dist/dsh/lisp/code-intelligence-contracts.d.ts.map +1 -0
  90. package/dist/dsh/lisp/code-intelligence-contracts.js +54 -0
  91. package/dist/dsh/lisp/code-intelligence-contracts.js.map +1 -0
  92. package/dist/dsh/lisp/code-intelligence-provider.d.ts +116 -0
  93. package/dist/dsh/lisp/code-intelligence.d.ts +13 -0
  94. package/dist/dsh/lisp/code-intelligence.d.ts.map +1 -0
  95. package/dist/dsh/lisp/code-intelligence.js +181 -0
  96. package/dist/dsh/lisp/code-intelligence.js.map +1 -0
  97. package/dist/dsh/lisp/coding-choice.d.ts +1 -0
  98. package/dist/dsh/lisp/coding-choice.d.ts.map +1 -1
  99. package/dist/dsh/lisp/coding-choice.js +17 -6
  100. package/dist/dsh/lisp/coding-choice.js.map +1 -1
  101. package/dist/dsh/lisp/compiled-cache.d.ts.map +1 -1
  102. package/dist/dsh/lisp/compiled-cache.js +3 -2
  103. package/dist/dsh/lisp/compiled-cache.js.map +1 -1
  104. package/dist/dsh/lisp/contracts.d.ts +4 -0
  105. package/dist/dsh/lisp/contracts.d.ts.map +1 -1
  106. package/dist/dsh/lisp/contracts.js +1 -0
  107. package/dist/dsh/lisp/contracts.js.map +1 -1
  108. package/dist/dsh/lisp/manager.d.ts +8 -1
  109. package/dist/dsh/lisp/manager.d.ts.map +1 -1
  110. package/dist/dsh/lisp/manager.js +78 -24
  111. package/dist/dsh/lisp/manager.js.map +1 -1
  112. package/dist/dsh/lisp/model-result.d.ts.map +1 -1
  113. package/dist/dsh/lisp/model-result.js +35 -1
  114. package/dist/dsh/lisp/model-result.js.map +1 -1
  115. package/dist/dsh/lisp/proposal-batch.d.ts +2 -0
  116. package/dist/dsh/lisp/proposal-batch.d.ts.map +1 -1
  117. package/dist/dsh/lisp/proposal-batch.js +32 -2
  118. package/dist/dsh/lisp/proposal-batch.js.map +1 -1
  119. package/dist/dsh/lisp/sandbox.d.ts +3 -0
  120. package/dist/dsh/lisp/sandbox.d.ts.map +1 -1
  121. package/dist/dsh/lisp/sandbox.js +13 -6
  122. package/dist/dsh/lisp/sandbox.js.map +1 -1
  123. package/dist/dsh/lisp/surface.d.ts +1 -1
  124. package/dist/dsh/lisp/surface.d.ts.map +1 -1
  125. package/dist/dsh/lisp/surface.js +74 -20
  126. package/dist/dsh/lisp/surface.js.map +1 -1
  127. package/dist/dsh/lisp/worker.d.ts +2 -0
  128. package/dist/dsh/lisp/worker.d.ts.map +1 -1
  129. package/dist/dsh/lisp/worker.js +7 -5
  130. package/dist/dsh/lisp/worker.js.map +1 -1
  131. package/dist/dsh/memory-application.d.ts +1 -1
  132. package/dist/dsh/memory-application.d.ts.map +1 -1
  133. package/dist/dsh/memory-application.js +4 -3
  134. package/dist/dsh/memory-application.js.map +1 -1
  135. package/dist/dsh/model-auto/candidates.d.ts.map +1 -1
  136. package/dist/dsh/model-auto/candidates.js +31 -22
  137. package/dist/dsh/model-auto/candidates.js.map +1 -1
  138. package/dist/dsh/model-configuration.d.ts +145 -2
  139. package/dist/dsh/model-configuration.d.ts.map +1 -1
  140. package/dist/dsh/model-configuration.js +10 -3
  141. package/dist/dsh/model-configuration.js.map +1 -1
  142. package/dist/dsh/model-selection-ui.d.ts.map +1 -1
  143. package/dist/dsh/model-selection-ui.js +7 -2
  144. package/dist/dsh/model-selection-ui.js.map +1 -1
  145. package/dist/dsh/models/config-store.d.ts +8 -0
  146. package/dist/dsh/models/config-store.d.ts.map +1 -0
  147. package/dist/dsh/models/config-store.js +49 -0
  148. package/dist/dsh/models/config-store.js.map +1 -0
  149. package/dist/dsh/models/contracts.d.ts +107 -0
  150. package/dist/dsh/models/contracts.d.ts.map +1 -0
  151. package/dist/dsh/models/contracts.js +104 -0
  152. package/dist/dsh/models/contracts.js.map +1 -0
  153. package/dist/dsh/models/metadata.d.ts +7 -0
  154. package/dist/dsh/models/metadata.d.ts.map +1 -0
  155. package/dist/dsh/models/metadata.js +13 -0
  156. package/dist/dsh/models/metadata.js.map +1 -0
  157. package/dist/dsh/models/profiles.d.ts +10 -0
  158. package/dist/dsh/models/profiles.d.ts.map +1 -0
  159. package/dist/dsh/models/profiles.js +176 -0
  160. package/dist/dsh/models/profiles.js.map +1 -0
  161. package/dist/dsh/models/service.d.ts +97 -0
  162. package/dist/dsh/models/service.d.ts.map +1 -0
  163. package/dist/dsh/models/service.js +518 -0
  164. package/dist/dsh/models/service.js.map +1 -0
  165. package/dist/dsh/models/surface.d.ts +8 -0
  166. package/dist/dsh/models/surface.d.ts.map +1 -0
  167. package/dist/dsh/models/surface.js +162 -0
  168. package/dist/dsh/models/surface.js.map +1 -0
  169. package/dist/dsh/models/vendor/THIRD_PARTY_NOTICES.txt +134 -0
  170. package/dist/dsh/models/vendor/abortable.d.ts +3 -0
  171. package/dist/dsh/models/vendor/abortable.d.ts.map +1 -0
  172. package/dist/dsh/models/vendor/abortable.js +10 -0
  173. package/dist/dsh/models/vendor/abortable.js.map +1 -0
  174. package/dist/dsh/models/vendor/auth-contract.d.ts +67 -0
  175. package/dist/dsh/models/vendor/auth-contract.d.ts.map +1 -0
  176. package/dist/dsh/models/vendor/auth-contract.js +2 -0
  177. package/dist/dsh/models/vendor/auth-contract.js.map +1 -0
  178. package/dist/dsh/models/vendor/credentials.d.ts +58 -0
  179. package/dist/dsh/models/vendor/credentials.d.ts.map +1 -0
  180. package/dist/dsh/models/vendor/credentials.js +205 -0
  181. package/dist/dsh/models/vendor/credentials.js.map +1 -0
  182. package/dist/dsh/models/vendor/nous-oauth.d.ts +6 -0
  183. package/dist/dsh/models/vendor/nous-oauth.d.ts.map +1 -0
  184. package/dist/dsh/models/vendor/nous-oauth.js +113 -0
  185. package/dist/dsh/models/vendor/nous-oauth.js.map +1 -0
  186. package/dist/dsh/models/vendor/opencode-adapter.d.ts +38 -0
  187. package/dist/dsh/models/vendor/opencode-adapter.d.ts.map +1 -0
  188. package/dist/dsh/models/vendor/opencode-adapter.js +207 -0
  189. package/dist/dsh/models/vendor/opencode-adapter.js.map +1 -0
  190. package/dist/dsh/models/vendor/opencode-catalog.d.ts +73 -0
  191. package/dist/dsh/models/vendor/opencode-catalog.d.ts.map +1 -0
  192. package/dist/dsh/models/vendor/opencode-catalog.js +253 -0
  193. package/dist/dsh/models/vendor/opencode-catalog.js.map +1 -0
  194. package/dist/dsh/models/vendor/opencode-codec.d.ts +7 -0
  195. package/dist/dsh/models/vendor/opencode-codec.d.ts.map +1 -0
  196. package/dist/dsh/models/vendor/opencode-codec.js +107 -0
  197. package/dist/dsh/models/vendor/opencode-codec.js.map +1 -0
  198. package/dist/dsh/models/vendor/opencode-owned.generated.d.ts +114 -0
  199. package/dist/dsh/models/vendor/opencode-owned.generated.d.ts.map +1 -0
  200. package/dist/dsh/models/vendor/opencode-owned.generated.js +2867 -0
  201. package/dist/dsh/models/vendor/opencode-owned.generated.js.map +1 -0
  202. package/dist/dsh/models/vendor/opencode-replay.d.ts +17 -0
  203. package/dist/dsh/models/vendor/opencode-replay.d.ts.map +1 -0
  204. package/dist/dsh/models/vendor/opencode-replay.js +147 -0
  205. package/dist/dsh/models/vendor/opencode-replay.js.map +1 -0
  206. package/dist/dsh/models/vendor/opencode-sdk.d.ts +6 -0
  207. package/dist/dsh/models/vendor/opencode-sdk.d.ts.map +1 -0
  208. package/dist/dsh/models/vendor/opencode-sdk.js +49915 -0
  209. package/dist/dsh/models/vendor/opencode-sdk.js.map +7 -0
  210. package/dist/dsh/models/vendor/opencode-transport.d.ts +6 -0
  211. package/dist/dsh/models/vendor/opencode-transport.d.ts.map +1 -0
  212. package/dist/dsh/models/vendor/opencode-transport.js +70 -0
  213. package/dist/dsh/models/vendor/opencode-transport.js.map +1 -0
  214. package/dist/dsh/models/vendor/pi-ai.d.ts +23 -0
  215. package/dist/dsh/models/vendor/pi-ai.d.ts.map +1 -0
  216. package/dist/dsh/models/vendor/pi-ai.js +27 -0
  217. package/dist/dsh/models/vendor/pi-ai.js.map +1 -0
  218. package/dist/dsh/modules/lisp.d.ts +1 -1
  219. package/dist/dsh/modules/lisp.d.ts.map +1 -1
  220. package/dist/dsh/modules/lisp.js +1 -1
  221. package/dist/dsh/modules/lisp.js.map +1 -1
  222. package/dist/dsh/native-model-catalog.d.ts.map +1 -1
  223. package/dist/dsh/native-model-catalog.js +4 -3
  224. package/dist/dsh/native-model-catalog.js.map +1 -1
  225. package/dist/dsh/node-tap-summary.d.ts +6 -1
  226. package/dist/dsh/node-tap-summary.d.ts.map +1 -1
  227. package/dist/dsh/node-tap-summary.js +27 -2
  228. package/dist/dsh/node-tap-summary.js.map +1 -1
  229. package/dist/dsh/on-demand-intake.d.ts +1 -1
  230. package/dist/dsh/on-demand-intake.d.ts.map +1 -1
  231. package/dist/dsh/on-demand-intake.js +24 -12
  232. package/dist/dsh/on-demand-intake.js.map +1 -1
  233. package/dist/dsh/owned-evidence.d.ts +49 -0
  234. package/dist/dsh/owned-evidence.d.ts.map +1 -0
  235. package/dist/dsh/owned-evidence.js +69 -0
  236. package/dist/dsh/owned-evidence.js.map +1 -0
  237. package/dist/dsh/owned-execution.d.ts +98 -0
  238. package/dist/dsh/owned-execution.d.ts.map +1 -0
  239. package/dist/dsh/owned-execution.js +523 -0
  240. package/dist/dsh/owned-execution.js.map +1 -0
  241. package/dist/dsh/plan-transition.d.ts +5 -0
  242. package/dist/dsh/plan-transition.d.ts.map +1 -0
  243. package/dist/dsh/plan-transition.js +34 -0
  244. package/dist/dsh/plan-transition.js.map +1 -0
  245. package/dist/dsh/session-memory-finalizer.d.ts.map +1 -1
  246. package/dist/dsh/session-memory-finalizer.js +46 -3
  247. package/dist/dsh/session-memory-finalizer.js.map +1 -1
  248. package/dist/dsh/setup.d.ts +1 -1
  249. package/dist/dsh/setup.d.ts.map +1 -1
  250. package/dist/dsh/setup.js +2 -0
  251. package/dist/dsh/setup.js.map +1 -1
  252. package/dist/dsh/skill-prompts.json +1 -1
  253. package/dist/dsh/task-completion.d.ts +1 -0
  254. package/dist/dsh/task-completion.d.ts.map +1 -1
  255. package/dist/dsh/task-completion.js +19 -19
  256. package/dist/dsh/task-completion.js.map +1 -1
  257. package/dist/enno-oduno/schemas.d.ts +9 -9
  258. package/dist/enno-oduno/store.d.ts.map +1 -1
  259. package/dist/enno-oduno/store.js +12 -0
  260. package/dist/enno-oduno/store.js.map +1 -1
  261. package/dist/locale/en.json +1 -1
  262. package/dist/locale/ja.json +1 -1
  263. package/dist/locale/ko.json +1 -1
  264. package/dist/locale/zh-CN.json +1 -1
  265. package/dist/memory/application.d.ts +2 -1
  266. package/dist/memory/application.d.ts.map +1 -1
  267. package/dist/memory/application.js +26 -12
  268. package/dist/memory/application.js.map +1 -1
  269. package/dist/memory/evidence.d.ts +2 -0
  270. package/dist/memory/evidence.d.ts.map +1 -1
  271. package/dist/memory/evidence.js +3 -1
  272. package/dist/memory/evidence.js.map +1 -1
  273. package/dist/model-tools/contracts.d.ts +4 -4
  274. package/dist/models-client.cjs +635 -0
  275. package/dist/models-client.d.ts +26 -0
  276. package/dist/models-client.d.ts.map +1 -0
  277. package/dist/models-client.js +642 -0
  278. package/dist/models-client.js.map +1 -0
  279. package/docs/agenticreplay-recording.md +14 -0
  280. package/docs/code-intelligence.md +149 -0
  281. package/docs/dsh-auth-LICENSE.txt +22 -0
  282. package/docs/dsh-auth-provenance.md +25 -0
  283. package/docs/dsh-plugin.md +21 -0
  284. package/docs/kiokuko-models.md +66 -0
  285. package/docs/lisp.md +107 -56
  286. package/docs/model-selection.ja.md +7 -9
  287. package/docs/model-selection.md +14 -12
  288. package/docs/owned-execution.md +99 -0
  289. package/lisp/supervisor.mjs +8 -2
  290. package/lisp/tools.lisp +31 -3
  291. package/migrations/035_owned_execution.sql +19 -0
  292. package/package.json +46 -11
  293. package/skills/kiokuko-lisp/SKILL.md +49 -67
  294. package/skills/kiokuko-soul/SKILL.md +7 -26
@@ -0,0 +1,642 @@
1
+ function messageOf(error) {
2
+ return error instanceof Error ? error.message : String(error);
3
+ }
4
+ export const inject = ["slots", "locale"];
5
+ export function apply(ctx) {
6
+ mountModelsClient(ctx);
7
+ }
8
+ const MODELS_NS = "kiokuko-models";
9
+ const MODEL_CONNECTION_DEFAULTS = {
10
+ openai: ["OpenAI API", "https://api.openai.com/v1", "responses"],
11
+ codex: ["Codex", "https://chatgpt.com/backend-api/codex", "responses"],
12
+ claude: ["Claude", "https://api.anthropic.com", "messages"],
13
+ xai: ["xAI", "https://api.x.ai/v1", "chat-completions"],
14
+ deepseek: ["DeepSeek", "https://api.deepseek.com/v1", "chat-completions"],
15
+ opencode: ["OpenCode Zen", "https://opencode.ai/zen/v1", "chat-completions"],
16
+ "opencode-go": [
17
+ "OpenCode Go",
18
+ "https://opencode.ai/zen/go/v1",
19
+ "chat-completions",
20
+ ],
21
+ openrouter: [
22
+ "OpenRouter",
23
+ "https://openrouter.ai/api/v1",
24
+ "chat-completions",
25
+ ],
26
+ nous: [
27
+ "Nous / Hermes",
28
+ "https://inference-api.nousresearch.com/v1",
29
+ "chat-completions",
30
+ ],
31
+ infron: ["Infron", "https://llm.onerouter.pro/v1", "chat-completions"],
32
+ ollama: ["Ollama", "http://localhost:11434/v1", "chat-completions"],
33
+ custom: ["Custom connection", "http://localhost:8080/v1", "chat-completions"],
34
+ };
35
+ async function modelsApi(body, query = "") {
36
+ const response = await fetch("/api/kiokuko.models" + query, {
37
+ ...(body
38
+ ? {
39
+ method: "POST",
40
+ headers: { "content-type": "application/json" },
41
+ body: JSON.stringify(body),
42
+ }
43
+ : {}),
44
+ cache: "no-store",
45
+ });
46
+ const value = await response.json();
47
+ if (!response.ok)
48
+ throw new Error(value.error ?? "Kiokuko Models request failed");
49
+ return value;
50
+ }
51
+ /** The Settings page and command dialog render this exact management component. */
52
+ function KiokukoModelsPanel(props) {
53
+ const [state, setState] = useState({ revision: 0, connections: [] }), [connection, setConnection] = useState(null), [models, setModels] = useState([]), [filter, setFilter] = useState("");
54
+ const [busy, setBusy] = useState(false), [error, setError] = useState(""), [notice, setNotice] = useState(""), [key, setKey] = useState(""), [auth, setAuth] = useState(null), [answer, setAnswer] = useState("");
55
+ const [manual, setManual] = useState({
56
+ id: "",
57
+ contextWindow: 262144,
58
+ maxTokens: 32768,
59
+ reasoning: false,
60
+ image: false,
61
+ });
62
+ const operation = useRef(undefined), mounted = useRef(true), working = useRef(false);
63
+ const sessionId = props.sessionId;
64
+ const load = async () => {
65
+ const value = await modelsApi();
66
+ if (mounted.current)
67
+ setState(value);
68
+ return value;
69
+ };
70
+ useEffect(() => {
71
+ mounted.current = true;
72
+ void load().catch((e) => setError(messageOf(e)));
73
+ return () => {
74
+ mounted.current = false;
75
+ if (operation.current)
76
+ void modelsApi({ op: "cancel", id: operation.current }).catch(() => undefined);
77
+ };
78
+ }, []);
79
+ const run = async (action) => {
80
+ if (working.current)
81
+ return;
82
+ working.current = true;
83
+ setBusy(true);
84
+ setError("");
85
+ setNotice("");
86
+ try {
87
+ await action();
88
+ }
89
+ catch (e) {
90
+ if (mounted.current)
91
+ setError(messageOf(e));
92
+ }
93
+ finally {
94
+ working.current = false;
95
+ if (mounted.current)
96
+ setBusy(false);
97
+ }
98
+ };
99
+ const choose = async (c) => {
100
+ setConnection({ ...c });
101
+ setKey("");
102
+ setError("");
103
+ setModels([]);
104
+ try {
105
+ setModels(await modelsApi(undefined, "?op=models&id=" + encodeURIComponent(c.id)));
106
+ }
107
+ catch (e) {
108
+ setError(messageOf(e));
109
+ }
110
+ };
111
+ const save = async () => {
112
+ await modelsApi({
113
+ op: "save",
114
+ connection: {
115
+ id: connection.id,
116
+ kind: connection.kind,
117
+ name: connection.name,
118
+ baseURL: connection.baseURL,
119
+ protocol: connection.protocol,
120
+ serviceTier: connection.serviceTier,
121
+ models: connection.models,
122
+ },
123
+ revision: state.revision,
124
+ });
125
+ const next = await load();
126
+ await choose(next.connections.find((c) => c.id === connection.id));
127
+ setNotice("Connection saved");
128
+ };
129
+ const newConnection = (kind) => {
130
+ const spec = MODEL_CONNECTION_DEFAULTS[kind];
131
+ setConnection({
132
+ id: "kiokuko-" + kind + "-" + crypto.randomUUID().slice(0, 8),
133
+ kind,
134
+ name: spec[0],
135
+ baseURL: spec[1],
136
+ protocol: spec[2],
137
+ serviceTier: "standard",
138
+ models: [],
139
+ });
140
+ setModels([]);
141
+ setKey("");
142
+ setError("");
143
+ };
144
+ const update = (field, value) => setConnection({ ...connection, [field]: value });
145
+ const startLogin = async () => {
146
+ await save();
147
+ const result = await modelsApi({ op: "login", id: connection.id });
148
+ operation.current = result.operationId;
149
+ setAuth({ id: result.operationId, status: "pending", events: [] });
150
+ };
151
+ useEffect(() => {
152
+ if (!auth || auth.status !== "pending")
153
+ return;
154
+ let stopped = false;
155
+ const timer = setInterval(() => {
156
+ void modelsApi(undefined, "?op=auth&id=" + encodeURIComponent(auth.id)).then((next) => {
157
+ if (stopped)
158
+ return;
159
+ setAuth(next);
160
+ if (next.status !== "pending") {
161
+ operation.current = undefined;
162
+ void load()
163
+ .then((value) => {
164
+ if (next.status === "success")
165
+ return choose(value.connections.find((c) => c.id === connection.id));
166
+ setError(next.error ?? "Authentication cancelled");
167
+ })
168
+ .catch((e) => setError(messageOf(e)));
169
+ }
170
+ }, (e) => {
171
+ if (!stopped)
172
+ setError(messageOf(e));
173
+ });
174
+ }, 500);
175
+ return () => {
176
+ stopped = true;
177
+ clearInterval(timer);
178
+ };
179
+ }, [auth?.id, auth?.status]);
180
+ const input = (label, value, onChange, type = "text") => jsx("label", {
181
+ children: jsxs(Fragment, {
182
+ children: [
183
+ jsx("span", { children: label }),
184
+ jsx("input", {
185
+ type,
186
+ value,
187
+ "aria-label": label,
188
+ disabled: busy ||
189
+ (label === "Base URL" &&
190
+ ["codex", "opencode", "opencode-go"].includes(connection?.kind)),
191
+ onChange: (e) => onChange(e.target.value),
192
+ autoComplete: type === "password" ? "new-password" : "off",
193
+ }),
194
+ ],
195
+ }),
196
+ });
197
+ const button = (label, action, disabled = false) => jsx("button", {
198
+ type: "button",
199
+ disabled: busy || disabled,
200
+ onClick: action,
201
+ children: label,
202
+ });
203
+ return jsxs("section", {
204
+ className: "kiokuko-models-panel",
205
+ "aria-label": "Kiokuko Models",
206
+ "aria-busy": busy,
207
+ children: [
208
+ jsx("h2", { children: "Kiokuko Models" }),
209
+ jsx("p", {
210
+ children: "Connect directly for chat, Enno and Deep. Credentials are shared with dsh-cli. Signing out also signs dsh-cli out.",
211
+ }),
212
+ ...(error ? [jsx("p", { role: "alert", children: error })] : []),
213
+ ...(notice ? [jsx("p", { role: "status", children: notice })] : []),
214
+ ...(busy ? [jsx("p", { role: "status", children: "Working…" })] : []),
215
+ button("Reload", () => void run(load)),
216
+ jsx("label", {
217
+ children: jsxs(Fragment, {
218
+ children: [
219
+ "Add connection",
220
+ jsxs("select", {
221
+ "aria-label": "Add connection",
222
+ value: "",
223
+ disabled: busy,
224
+ onChange: (e) => newConnection(e.target.value),
225
+ children: [
226
+ jsx("option", { value: "", children: "Choose provider…" }),
227
+ ...Object.entries(MODEL_CONNECTION_DEFAULTS).map(([id, spec]) => jsx("option", { value: id, children: spec[0] }, id)),
228
+ ],
229
+ }),
230
+ ],
231
+ }),
232
+ }),
233
+ jsx("ul", {
234
+ children: state.connections.map((c) => jsx("li", {
235
+ children: button(c.name + " · " + c.authState, () => void choose(c)),
236
+ }, c.id)),
237
+ }),
238
+ ...(connection
239
+ ? [
240
+ jsxs("div", {
241
+ className: "kiokuko-models-editor",
242
+ children: [
243
+ input("Connection name", connection.name, (value) => update("name", value)),
244
+ input("Base URL", connection.baseURL, (value) => update("baseURL", value)),
245
+ jsx("label", {
246
+ children: jsxs(Fragment, {
247
+ children: [
248
+ "Protocol",
249
+ jsx("select", {
250
+ "aria-label": "Protocol",
251
+ value: connection.protocol,
252
+ disabled: busy ||
253
+ [
254
+ "codex",
255
+ "infron",
256
+ "opencode",
257
+ "opencode-go",
258
+ ].includes(connection.kind),
259
+ onChange: (e) => update("protocol", e.target.value),
260
+ children: [
261
+ ["chat-completions", "Chat Completions"],
262
+ ["responses", "Responses"],
263
+ ["messages", "Messages"],
264
+ ].map(([id, name]) => jsx("option", { value: id, children: name }, id)),
265
+ }),
266
+ ],
267
+ }),
268
+ }),
269
+ ...(connection.kind === "infron"
270
+ ? [
271
+ jsx("label", {
272
+ children: jsxs(Fragment, {
273
+ children: [
274
+ "Service tier",
275
+ jsx("select", {
276
+ "aria-label": "Service tier",
277
+ value: connection.serviceTier,
278
+ disabled: busy,
279
+ onChange: (e) => update("serviceTier", e.target.value),
280
+ children: [
281
+ jsx("option", {
282
+ value: "standard",
283
+ children: "Standard",
284
+ }),
285
+ jsx("option", {
286
+ value: "flex",
287
+ children: "Flex",
288
+ }),
289
+ ],
290
+ }),
291
+ ],
292
+ }),
293
+ }),
294
+ jsx("p", {
295
+ children: "Requested tier: " +
296
+ connection.serviceTier +
297
+ ". Last request: " +
298
+ (connection.lastRequestedTier ?? "none") +
299
+ ". Actual served tier: " +
300
+ (connection.actualTier ?? "unknown") +
301
+ ". Infron may serve Standard for a Flex request.",
302
+ }),
303
+ ]
304
+ : []),
305
+ button("Save connection", () => void run(save)),
306
+ ...(connection.kind !== "codex" && connection.kind !== "ollama"
307
+ ? [
308
+ input("API key / bearer token", key, setKey, "password"),
309
+ button("Save key", () => void run(async () => {
310
+ await save();
311
+ await modelsApi({
312
+ op: "key",
313
+ id: connection.id,
314
+ key,
315
+ });
316
+ setKey("");
317
+ await load();
318
+ await choose(connection);
319
+ setNotice("Key saved");
320
+ }), !key),
321
+ ]
322
+ : []),
323
+ ...([
324
+ "codex",
325
+ "claude",
326
+ "xai",
327
+ "openai",
328
+ "openrouter",
329
+ "nous",
330
+ ].includes(connection.kind)
331
+ ? [
332
+ button("Log in", () => void run(startLogin), auth?.status === "pending"),
333
+ ]
334
+ : []),
335
+ button("Log out (also dsh-cli)", () => void run(async () => {
336
+ await modelsApi({ op: "logout", id: connection.id });
337
+ setKey("");
338
+ setModels([]);
339
+ await load();
340
+ setNotice("Signed out");
341
+ })),
342
+ button("Refresh models", () => void run(async () => {
343
+ await modelsApi({ op: "refresh", id: connection.id });
344
+ const next = await load();
345
+ await choose(next.connections.find((c) => c.id === connection.id));
346
+ setNotice("Models refreshed");
347
+ })),
348
+ ...(auth?.status === "pending"
349
+ ? [
350
+ jsxs("div", {
351
+ "aria-label": "Authentication",
352
+ children: [
353
+ jsx("p", {
354
+ role: "status",
355
+ children: "Waiting for authentication",
356
+ }),
357
+ ...auth.events.map((event, index) => jsx("div", {
358
+ children: event.type === "auth_url"
359
+ ? jsxs(Fragment, {
360
+ children: [
361
+ jsx("a", {
362
+ href: event.url,
363
+ target: "_blank",
364
+ rel: "noopener noreferrer",
365
+ children: "Open authentication link",
366
+ }),
367
+ jsx("p", {
368
+ children: event.instructions,
369
+ }),
370
+ ],
371
+ })
372
+ : event.type === "device_code"
373
+ ? jsxs(Fragment, {
374
+ children: [
375
+ jsx("a", {
376
+ href: event.verificationUri,
377
+ target: "_blank",
378
+ rel: "noopener noreferrer",
379
+ children: "Open sign-in page",
380
+ }),
381
+ jsx("p", {
382
+ children: "Code: " + event.userCode,
383
+ }),
384
+ ],
385
+ })
386
+ : jsxs(Fragment, {
387
+ children: [
388
+ jsx("p", {
389
+ children: event.message,
390
+ }),
391
+ ...(event.links ?? []).map((link) => jsx("a", {
392
+ href: link.url,
393
+ target: "_blank",
394
+ rel: "noopener noreferrer",
395
+ children: link.label ?? "Open link",
396
+ }, link.url)),
397
+ ],
398
+ }),
399
+ }, index)),
400
+ ...(auth.prompt
401
+ ? [
402
+ auth.prompt.type === "select"
403
+ ? jsx("label", {
404
+ children: jsxs(Fragment, {
405
+ children: [
406
+ auth.prompt.message,
407
+ jsxs("select", {
408
+ "aria-label": auth.prompt.message,
409
+ value: answer,
410
+ onChange: (e) => setAnswer(e.target.value),
411
+ children: [
412
+ jsx("option", {
413
+ value: "",
414
+ children: "Choose…",
415
+ }),
416
+ ...auth.prompt.options.map((option) => jsx("option", {
417
+ value: option.id,
418
+ children: option.label,
419
+ }, option.id)),
420
+ ],
421
+ }),
422
+ ],
423
+ }),
424
+ })
425
+ : input(auth.prompt.message, answer, setAnswer, auth.prompt.type === "secret"
426
+ ? "password"
427
+ : "text"),
428
+ button("Submit authentication answer", () => void run(async () => {
429
+ await modelsApi({
430
+ op: "answer",
431
+ id: auth.id,
432
+ answer,
433
+ });
434
+ setAnswer("");
435
+ })),
436
+ ]
437
+ : []),
438
+ button("Cancel authentication", () => void run(async () => {
439
+ await modelsApi({ op: "cancel", id: auth.id });
440
+ operation.current = undefined;
441
+ setAuth(null);
442
+ setNotice("Authentication cancelled");
443
+ })),
444
+ ],
445
+ }),
446
+ ]
447
+ : []),
448
+ ...(!["opencode", "opencode-go"].includes(connection.kind)
449
+ ? [
450
+ jsx("details", {
451
+ children: jsxs(Fragment, {
452
+ children: [
453
+ jsx("summary", {
454
+ children: "Register model manually",
455
+ }),
456
+ input("Model ID", manual.id, (value) => setManual({ ...manual, id: value })),
457
+ input("Context window", manual.contextWindow, (value) => setManual({
458
+ ...manual,
459
+ contextWindow: Number(value),
460
+ }), "number"),
461
+ input("Maximum output tokens", manual.maxTokens, (value) => setManual({
462
+ ...manual,
463
+ maxTokens: Number(value),
464
+ }), "number"),
465
+ jsx("label", {
466
+ children: jsxs(Fragment, {
467
+ children: [
468
+ jsx("input", {
469
+ type: "checkbox",
470
+ checked: manual.reasoning,
471
+ onChange: (e) => setManual({
472
+ ...manual,
473
+ reasoning: e.target.checked,
474
+ }),
475
+ }),
476
+ "Reasoning supported",
477
+ ],
478
+ }),
479
+ }),
480
+ jsx("label", {
481
+ children: jsxs(Fragment, {
482
+ children: [
483
+ jsx("input", {
484
+ type: "checkbox",
485
+ checked: manual.image,
486
+ onChange: (e) => setManual({
487
+ ...manual,
488
+ image: e.target.checked,
489
+ }),
490
+ }),
491
+ "Image input supported",
492
+ ],
493
+ }),
494
+ }),
495
+ button("Add manual model", () => {
496
+ update("models", [
497
+ ...connection.models.filter((m) => m.id !== manual.id),
498
+ { ...manual, name: manual.id },
499
+ ]);
500
+ setNotice("Model added to draft. Save connection to register it.");
501
+ }, !manual.id),
502
+ ],
503
+ }),
504
+ }),
505
+ ]
506
+ : []),
507
+ input("Search models", filter, setFilter),
508
+ jsx("ul", {
509
+ children: models
510
+ .filter((m) => (m.id + " " + m.name)
511
+ .toLowerCase()
512
+ .includes(filter.toLowerCase()))
513
+ .map((m) => jsx("li", {
514
+ children: jsxs(Fragment, {
515
+ children: [
516
+ jsx("span", { children: m.name + " · " + m.id }),
517
+ button("Use in current chat", () => void run(async () => {
518
+ await modelsApi({
519
+ op: "select",
520
+ id: connection.id,
521
+ model: m.id,
522
+ scope: "current",
523
+ sessionId,
524
+ });
525
+ setNotice("Model selected for this chat");
526
+ }), !sessionId),
527
+ button("Default for new chats", () => void run(async () => {
528
+ await modelsApi({
529
+ op: "select",
530
+ id: connection.id,
531
+ model: m.id,
532
+ scope: "default",
533
+ });
534
+ setNotice("Default model saved for new chats");
535
+ })),
536
+ ],
537
+ }),
538
+ }, m.id)),
539
+ }),
540
+ ],
541
+ }),
542
+ ]
543
+ : []),
544
+ ],
545
+ });
546
+ }
547
+ function KiokukoModelsDialog(props) {
548
+ const useModels = props.useKiokukoModels;
549
+ const state = useModels((s) => s), close = props.closeModels;
550
+ return jsx(Modal, {
551
+ open: state.open,
552
+ className: "kiokuko-models-modal",
553
+ title: "Kiokuko Models",
554
+ closeLabel: "Close",
555
+ onClose: close,
556
+ children: state.open
557
+ ? jsx(KiokukoModelsPanel, { sessionId: state.sessionId })
558
+ : null,
559
+ });
560
+ }
561
+ function KiokukoModelsAnchor(props) {
562
+ const active = props.activeModelsSession;
563
+ useEffect(() => {
564
+ active.current = props.sessionId;
565
+ return () => {
566
+ if (active.current === props.sessionId)
567
+ active.current = undefined;
568
+ };
569
+ }, [props.sessionId]);
570
+ return null;
571
+ }
572
+ export function mountModelsClient(ctx) {
573
+ const store = createSnapshotStore({
574
+ open: false,
575
+ }), active = { current: undefined };
576
+ let focusFrame;
577
+ const close = () => {
578
+ store.update((s) => {
579
+ s.open = false;
580
+ });
581
+ if (focusFrame !== undefined)
582
+ cancelAnimationFrame(focusFrame);
583
+ focusFrame = requestAnimationFrame(() => {
584
+ focusFrame = undefined;
585
+ const sessionId = active.current;
586
+ if (!sessionId)
587
+ return;
588
+ const sessions = ctx.get?.("sessions", false);
589
+ const scope = sessions?.scope(sessionId);
590
+ if (!scope)
591
+ return;
592
+ const conversation = scope.get("conversation", false);
593
+ conversation?.input.for(scope).focus();
594
+ });
595
+ };
596
+ ctx.effect(() => () => {
597
+ if (focusFrame !== undefined)
598
+ cancelAnimationFrame(focusFrame);
599
+ }, "kiokuko models focus lifecycle");
600
+ ctx.effect(() => {
601
+ const style = document.createElement("style");
602
+ style.textContent =
603
+ ".kiokuko-models-modal{width:min(900px,calc(100vw - 32px))}.kiokuko-models-panel{box-sizing:border-box;width:100%;max-width:900px;padding:16px;overflow:auto;max-height:75vh}.kiokuko-models-panel label{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin:12px 0}.kiokuko-models-panel input,.kiokuko-models-panel select{max-width:100%;box-sizing:border-box;border:1px solid #888;border-radius:6px;padding:8px;color:inherit;background:transparent}.kiokuko-models-panel button{border:1px solid #888;border-radius:6px;padding:8px;margin:4px;color:inherit}.kiokuko-models-panel button:disabled{opacity:.5}.kiokuko-models-panel li{margin:8px 0}.kiokuko-models-panel :focus-visible{outline:2px solid #3286ff;outline-offset:3px}";
604
+ document.head.append(style);
605
+ return () => style.remove();
606
+ }, "kiokuko models style");
607
+ ctx.slots.inject("settings.section", () => ctx.slots.register({
608
+ name: "settings.section",
609
+ id: MODELS_NS,
610
+ order: 1000,
611
+ label: "Kiokuko Models",
612
+ locale: MODELS_NS,
613
+ }, () => jsx(KiokukoModelsPanel, { sessionId: active.current })));
614
+ ctx.slots.inject("conversation.input.left", () => ctx.slots.register({
615
+ name: "conversation.input.left",
616
+ id: "kiokuko-models-dialog",
617
+ locale: MODELS_NS,
618
+ inject: () => ({
619
+ hooks: { kiokukoModels: store },
620
+ closeModels: close,
621
+ activeModelsSession: active,
622
+ }),
623
+ }, KiokukoModelsAnchor));
624
+ ctx.slots.inject("shell.overlay", () => ctx.slots.register({
625
+ name: "shell.overlay",
626
+ id: "kiokuko-models-overlay",
627
+ locale: MODELS_NS,
628
+ inject: () => ({ hooks: { kiokukoModels: store }, closeModels: close }),
629
+ }, KiokukoModelsDialog));
630
+ ctx.on("command/executed", (sessionId, name, result) => {
631
+ if (name === "kiokuko" && result.kind === "success")
632
+ store.update((s) => {
633
+ s.open = true;
634
+ s.sessionId = sessionId;
635
+ });
636
+ });
637
+ ctx.effect(() => ctx.locale.register(MODELS_NS, {
638
+ en: { "meta.title": "Kiokuko Models" },
639
+ ja: { "meta.title": "Kiokuko Models" },
640
+ }), "kiokuko models labels");
641
+ }
642
+ //# sourceMappingURL=models-client.js.map