@engenty/wizards-runtime 0.9.5 → 0.9.7

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 (108) hide show
  1. package/apps/runtime/dist/agents/architect.js +2 -2
  2. package/apps/runtime/dist/agents/chat-clients.js +299 -0
  3. package/apps/runtime/dist/agents/company.js +111 -0
  4. package/apps/runtime/dist/agents/studio-assistant.js +8 -4
  5. package/apps/runtime/dist/agents/subscription.js +163 -134
  6. package/apps/runtime/dist/agents/website.js +571 -53
  7. package/apps/runtime/dist/app.js +6 -3
  8. package/apps/runtime/dist/assistant/knows.js +5 -5
  9. package/apps/runtime/dist/assistant/primer.js +3 -3
  10. package/apps/runtime/dist/auth/account.js +12 -12
  11. package/apps/runtime/dist/auth/keys.js +18 -8
  12. package/apps/runtime/dist/cli/account.js +20 -18
  13. package/apps/runtime/dist/cli/features.js +3 -3
  14. package/apps/runtime/dist/cli/ui.js +6 -0
  15. package/apps/runtime/dist/db/schema.js +1 -1
  16. package/apps/runtime/dist/docs/dev/plugins/index.md +1 -1
  17. package/apps/runtime/dist/docs/dev/plugins/server.md +2 -2
  18. package/apps/runtime/dist/docs/dev/plugins/studio.md +1 -1
  19. package/apps/runtime/dist/docs/user-guide/ai-apps.md +1 -1
  20. package/apps/runtime/dist/docs/user-guide/command-line.md +1 -1
  21. package/apps/runtime/dist/docs/user-guide/create-account.md +6 -6
  22. package/apps/runtime/dist/docs/user-guide/first-start.md +1 -1
  23. package/apps/runtime/dist/docs/user-guide/index.md +5 -5
  24. package/apps/runtime/dist/docs/user-guide/models.md +14 -8
  25. package/apps/runtime/dist/docs/user-guide/space.md +1 -1
  26. package/apps/runtime/dist/features.js +4 -4
  27. package/apps/runtime/dist/harness/cursor.js +4 -0
  28. package/apps/runtime/dist/manage.js +4 -4
  29. package/apps/runtime/dist/mcp/auth.js +1 -1
  30. package/apps/runtime/dist/models.js +75 -5
  31. package/apps/runtime/dist/routes/lang.js +13 -4
  32. package/apps/runtime/dist/routes/runs.js +1 -1
  33. package/apps/runtime/dist/routes/studio.js +66 -37
  34. package/apps/runtime/dist/services/access.js +3 -3
  35. package/apps/runtime/dist/services/architect.js +4 -2
  36. package/apps/runtime/dist/services/assistant-chats.js +10 -1
  37. package/apps/runtime/dist/services/onboarding.js +268 -48
  38. package/apps/runtime/dist/services/pages.js +17 -15
  39. package/apps/runtime/dist/services/wizards.js +2 -2
  40. package/apps/runtime/dist/texts.js +42 -8
  41. package/apps/web/dist/assets/{AboutDialog-lUBGgvKu.js → AboutDialog-B3tljxg5.js} +1 -1
  42. package/apps/web/dist/assets/{ChangelogDialog-B2IJbKX8.js → ChangelogDialog-DfWTNzyl.js} +1 -1
  43. package/apps/web/dist/assets/EditorPage-XDdz2UM4.js +4 -0
  44. package/apps/web/dist/assets/{FlowPreview-BUKI8h6o.js → FlowPreview-CKNVCFbp.js} +1 -1
  45. package/apps/web/dist/assets/{Harness-D35I3Jlp.js → Harness-BCec49Cq.js} +2 -2
  46. package/apps/web/dist/assets/Marketplace-BuYeaxK2.js +2 -0
  47. package/apps/web/dist/assets/{NewWizardChannels-PDeL4f5D.js → NewWizardChannels-DRNji-bk.js} +1 -1
  48. package/apps/web/dist/assets/NewWizardPage-4TpgYOaI.js +7 -0
  49. package/apps/web/dist/assets/OnboardingPage-Cf52NOIt.js +1 -0
  50. package/apps/web/dist/assets/PreviewPane-C4yMcZPM.js +4 -0
  51. package/apps/web/dist/assets/ProjectPage-D6Tah3QK.js +1 -0
  52. package/apps/web/dist/assets/{PublicRunner-BnT-zZrI.js → PublicRunner-Bftc1c4m.js} +1 -1
  53. package/apps/web/dist/assets/{ReadOnly-C5fdw_kg.js → ReadOnly-DVQm9IYx.js} +1 -1
  54. package/apps/web/dist/assets/SettingsPage-Cd-osLDu.js +2 -0
  55. package/apps/web/dist/assets/SetupPage-Dc8U5k5P.js +1 -0
  56. package/apps/web/dist/assets/{SharePage-BiPJsotS.js → SharePage-Cn-bqSyr.js} +1 -1
  57. package/apps/web/dist/assets/changelog-CjSBB-a4.js +1 -0
  58. package/apps/web/dist/assets/{coins-DVGgwSrK.js → coins-DgDTBbeg.js} +1 -1
  59. package/apps/web/dist/assets/index-DS3zUVw_.css +1 -0
  60. package/apps/web/dist/assets/index-Da7hPToW.js +14 -0
  61. package/apps/web/dist/assets/oss-credits-C2JUsf2d.js +1 -0
  62. package/apps/web/dist/assets/{phone-DD2g0U0Q.js → phone-D1Drdiio.js} +1 -1
  63. package/apps/web/dist/assets/preload-helper-DpV6A1kQ.js +1 -0
  64. package/apps/web/dist/assets/{qr-scanner.min-C_UI0gH-.js → qr-scanner.min-BGqShvxG.js} +1 -1
  65. package/apps/web/dist/assets/{runners-D6mK0B73.js → runners-CTd0YAiA.js} +1 -1
  66. package/apps/web/dist/assets/{session-BHCBxqVb.js → session-DX2BcTfz.js} +1 -1
  67. package/apps/web/dist/assets/{settings-menu-DGDn2688.js → settings-menu-ay9jNbQu.js} +1 -1
  68. package/apps/web/dist/assets/theme-DanjuO1H.js +11 -0
  69. package/apps/web/dist/assets/ui-CJCF3Mhe.js +137 -0
  70. package/apps/web/dist/assets/{upload-uc9uftDy.js → upload-Dj7KPL--.js} +1 -1
  71. package/apps/web/dist/assets/{useMutation-BfQIRblT.js → useMutation-CUSQpD-i.js} +1 -1
  72. package/apps/web/dist/assets/{volume-2-BlaOos9n.js → volume-2-CcHZOU2m.js} +1 -1
  73. package/apps/web/dist/assets/{wrench-Cfpkphyw.js → wrench-CfJTFnMJ.js} +1 -1
  74. package/apps/web/dist/index.html +9 -9
  75. package/apps/web/dist/mcp/flow.html +56 -56
  76. package/node_modules/@engenty/wizards/dist/plugin/studio.d.ts +1 -1
  77. package/node_modules/@engenty/wizards-shared/dist/assistant.d.ts +6 -0
  78. package/node_modules/@engenty/wizards-shared/dist/assistant.js +2 -0
  79. package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +4 -0
  80. package/node_modules/@engenty/wizards-shared/dist/definition.js +9 -0
  81. package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +5 -5
  82. package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +5 -5
  83. package/node_modules/@engenty/wizards-shared/dist/features.d.ts +1 -1
  84. package/node_modules/@engenty/wizards-shared/dist/features.js +1 -1
  85. package/node_modules/@engenty/wizards-shared/dist/projects.d.ts +1 -1
  86. package/node_modules/@engenty/wizards-shared/dist/projects.js +2 -2
  87. package/node_modules/@engenty/wizards-shared/dist/providers.d.ts +1 -1
  88. package/node_modules/@engenty/wizards-shared/dist/providers.js +1 -1
  89. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +2 -2
  90. package/node_modules/@engenty/wizards-shared/dist/run.js +4 -4
  91. package/package.json +3 -3
  92. package/plugin/.claude-plugin/plugin.json +1 -1
  93. package/plugin/plugin.json +1 -1
  94. package/apps/web/dist/assets/EditorPage-B1syriTz.js +0 -4
  95. package/apps/web/dist/assets/Marketplace-C-ft5u_6.js +0 -2
  96. package/apps/web/dist/assets/NewWizardPage-BHw086HN.js +0 -7
  97. package/apps/web/dist/assets/OnboardingPage-BYa8Xekc.js +0 -1
  98. package/apps/web/dist/assets/PreviewPane-Cuatuhi-.js +0 -4
  99. package/apps/web/dist/assets/ProjectPage-DTbTN9rE.js +0 -1
  100. package/apps/web/dist/assets/SettingsPage-Bkd5LuRn.js +0 -2
  101. package/apps/web/dist/assets/SetupPage-CHnbGccO.js +0 -1
  102. package/apps/web/dist/assets/changelog-Do_saoEi.js +0 -1
  103. package/apps/web/dist/assets/index-C-u3ZXBZ.js +0 -14
  104. package/apps/web/dist/assets/index-DtjKnB3s.css +0 -1
  105. package/apps/web/dist/assets/oss-credits-D7izqI_0.js +0 -1
  106. package/apps/web/dist/assets/preload-helper-CNEI7N0N.js +0 -1
  107. package/apps/web/dist/assets/theme-DQ10nO_L.js +0 -11
  108. package/apps/web/dist/assets/ui-BV4KP5n2.js +0 -137
@@ -1,22 +1,30 @@
1
1
  import { spawn } from "node:child_process";
2
- import { mkdirSync, writeFileSync } from "node:fs";
3
- import { join } from "node:path";
2
+ import { randomUUID } from "node:crypto";
3
+ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
4
+ import { homedir } from "node:os";
5
+ import { dirname, join } from "node:path";
4
6
  import { createInterface } from "node:readline";
5
7
  import { internalKey } from "../auth/keys.js";
6
8
  import { env } from "../env.js";
7
- import { CLAUDE_BIN as CLAUDE, claudeEnv } from "../harness/claude.js";
8
- import { detectHarness, signedOut } from "../harness/index.js";
9
- import { localModelSettings } from "../models.js";
9
+ import { resolveEnv } from "../harness/env.js";
10
+ import { detectHarness, harness, signedOut } from "../harness/index.js";
11
+ import { CHAT_WAYS, chatWayReady, localModelSettings } from "../models.js";
10
12
  import { ServiceError } from "../services/errors.js";
11
13
  import { deleteSetting, readSetting, writeSetting } from "../settings.js";
12
14
  import { serverText } from "../texts.js";
15
+ import { CHAT_CLIENTS, CODEX_KEY_VAR, cursorWorkspace, SUBSCRIPTION_CLIENTS, } from "./chat-clients.js";
13
16
  import { thoughtLine } from "./thought.js";
14
- /** The AI clients installed on this machine whose subscription can answer the studio chat. */
17
+ /** The AI clients installed and signed in on this machine whose subscription can answer the studio chat. */
15
18
  export async function subscriptionClients() {
16
- return (await detectHarness("claude"))?.version ? ["claude"] : [];
19
+ const found = await Promise.all(SUBSCRIPTION_CLIENTS.map(async (id) => {
20
+ const h = await detectHarness(id);
21
+ return h?.version && h.auth !== "none" ? id : null;
22
+ }));
23
+ return found.filter((id) => id !== null);
17
24
  }
18
25
  const workDir = join(env.dataDir, "subscription");
19
- /** The MCP config handed to the client: this server only, signed in with a key made for this process. */
26
+ const mcpUrl = () => `http://127.0.0.1:${env.port}/api/mcp`;
27
+ /** Claude's MCP config: this server only, signed in with a key made for this process. */
20
28
  function mcpConfig() {
21
29
  mkdirSync(workDir, { recursive: true });
22
30
  const file = join(workDir, "mcp.json");
@@ -24,13 +32,25 @@ function mcpConfig() {
24
32
  mcpServers: {
25
33
  wizards: {
26
34
  type: "http",
27
- url: `http://127.0.0.1:${env.port}/api/mcp`,
28
- headers: { Authorization: `Bearer ${internalKey()}` },
35
+ url: mcpUrl(),
36
+ headers: { Authorization: `Bearer ${internalKey("Claude")}` },
29
37
  },
30
38
  },
31
39
  }), { mode: 0o600 });
32
40
  return file;
33
41
  }
42
+ /** The server names in the person's own Cursor config, which the chat's workspace denies. */
43
+ function ownCursorServers() {
44
+ const file = join(homedir(), ".cursor", "mcp.json");
45
+ try {
46
+ return existsSync(file)
47
+ ? Object.keys(JSON.parse(readFileSync(file, "utf8")).mcpServers ?? {})
48
+ : [];
49
+ }
50
+ catch {
51
+ return [];
52
+ }
53
+ }
34
54
  const SYSTEM = (wizardId) => [
35
55
  "You are the architect in the engenty wizards studio. The admin talks to you in the studio's chat panel, next to a diagram of the wizard.",
36
56
  `You work on exactly one wizard: id "${wizardId}". Read it with get_wizard before you change it; change it with edit_wizard and the file tools; never create another wizard and never publish unless the admin asks.`,
@@ -54,154 +74,163 @@ function activity(name, args, lang = "en") {
54
74
  const about = [args.path, args.query].find((v) => typeof v === "string" && v.trim());
55
75
  return about ? `${label}: ${String(about)} …` : `${label} …`;
56
76
  }
57
- const sessionKey = (wizardId) => `chat-session:${wizardId}`;
58
- /** One chat turn on the Claude subscription. The client keeps the conversation; we keep its id. */
77
+ /** One conversation per wizard and client: another client cannot continue it. */
78
+ const sessionKey = (client, wizardId) => client === "claude" ? `chat-session:${wizardId}` : `chat-session:${client}:${wizardId}`;
79
+ const EXT = {
80
+ "image/png": "png",
81
+ "image/jpeg": "jpg",
82
+ "image/webp": "webp",
83
+ "image/gif": "gif",
84
+ };
85
+ /** One chat turn on a subscription. The client keeps the conversation; we keep its id. */
59
86
  export async function subscriptionTurn(input) {
60
- const session = await readSetting(sessionKey(input.wizardId));
61
- const args = [
62
- // The message comes on stdin, so pictures can go with it.
63
- "-p",
64
- "--input-format",
65
- "stream-json",
66
- "--output-format",
67
- "stream-json",
68
- "--verbose",
69
- // Names a tool as it starts and streams the thinking; whole messages still follow.
70
- "--include-partial-messages",
71
- // No built-in tools: `--allowedTools` alone would not take them away.
72
- "--tools",
73
- "",
74
- "--strict-mcp-config",
75
- "--mcp-config",
76
- mcpConfig(),
77
- "--allowedTools",
78
- "mcp__wizards",
79
- "--disable-slash-commands",
80
- "--setting-sources",
81
- "",
82
- "--append-system-prompt",
83
- SYSTEM(input.wizardId),
84
- ...(session ? ["--resume", session] : []),
85
- ];
86
- const child = spawn(CLAUDE, args, {
87
- cwd: workDir,
88
- stdio: ["pipe", "pipe", "pipe"],
89
- signal: input.signal,
90
- // The client's own sign-in, as the person's terminal has it; no key of ours reaches it.
91
- env: await claudeEnv(),
92
- });
93
- child.stdin.on("error", () => {
94
- // A client that is gone already says so on stdout and in its exit code.
95
- });
96
- child.stdin.end(`${JSON.stringify({
97
- type: "user",
98
- message: {
99
- role: "user",
100
- content: [
101
- { type: "text", text: input.message },
102
- ...(input.images ?? []).map((i) => ({
103
- type: "image",
104
- source: {
105
- type: "base64",
106
- media_type: i.mime,
107
- data: Buffer.from(i.data).toString("base64"),
108
- },
109
- })),
110
- ],
111
- },
112
- })}\n`);
113
- let reply = "";
114
- let changed = false;
115
- let failure = "";
116
- let thinking = "";
117
- let thought = null;
118
- let stderr = "";
119
- child.stderr.on("data", (chunk) => {
120
- stderr = (stderr + String(chunk)).slice(-2000);
121
- });
122
- for await (const line of createInterface({ input: child.stdout })) {
123
- let event;
124
- try {
125
- event = JSON.parse(line);
126
- }
127
- catch {
128
- continue;
87
+ const client = CHAT_CLIENTS[input.client];
88
+ const key = sessionKey(input.client, input.wizardId);
89
+ // Cursor Agent keeps its chats per workspace: one folder per wizard.
90
+ const dir = input.client === "cursor" ? join(workDir, "cursor", input.wizardId) : workDir;
91
+ mkdirSync(dir, { recursive: true });
92
+ const system = SYSTEM(input.wizardId);
93
+ if (input.client === "cursor") {
94
+ for (const [path, text] of Object.entries(cursorWorkspace({
95
+ system,
96
+ mcpUrl: mcpUrl(),
97
+ key: internalKey("Cursor"),
98
+ ownServers: ownCursorServers(),
99
+ }))) {
100
+ mkdirSync(dirname(join(dir, path)), { recursive: true });
101
+ writeFileSync(join(dir, path), text, { mode: 0o600 });
129
102
  }
130
- if (event.type === "stream_event") {
131
- const e = event.event ?? {};
132
- if (e.type === "content_block_start" && e.content_block?.type === "tool_use") {
133
- input.onActivity(activity(String(e.content_block.name ?? ""), {}, input.lang));
134
- }
135
- else if (e.type === "content_block_start" && e.content_block?.type === "thinking") {
136
- thinking = "";
137
- }
138
- else if (e.type === "content_block_delta" && e.delta?.type === "thinking_delta") {
139
- thinking += e.delta.thinking ?? "";
140
- const next = thoughtLine(thinking);
141
- if (next && next !== thought) {
142
- thought = next;
143
- input.onThought?.(next);
144
- }
145
- }
103
+ }
104
+ // Codex attaches pictures as files; they go once the turn ends.
105
+ const images = (input.images ?? []).map((i) => ({
106
+ mime: i.mime,
107
+ base64: Buffer.from(i.data).toString("base64"),
108
+ file: join(workDir, "images", `${randomUUID()}.${EXT[i.mime] ?? "png"}`),
109
+ }));
110
+ if (input.client === "codex") {
111
+ for (const [n, image] of images.entries()) {
112
+ mkdirSync(dirname(image.file), { recursive: true });
113
+ writeFileSync(image.file, input.images?.[n]?.data ?? new Uint8Array());
146
114
  }
147
- else if (event.type === "assistant") {
148
- for (const block of event.message?.content ?? []) {
149
- if (block.type === "text" && block.text) {
150
- const text = reply ? `\n\n${block.text}` : block.text;
115
+ }
116
+ const call = {
117
+ system,
118
+ message: input.message,
119
+ session: await readSetting(key),
120
+ mcpUrl: mcpUrl(),
121
+ dir,
122
+ mcpConfigFile: input.client === "claude" ? mcpConfig() : undefined,
123
+ images,
124
+ };
125
+ const h = harness(input.client);
126
+ // The client's own sign-in, as the person's terminal has it; no key of ours reaches it.
127
+ const childEnv = h ? (await resolveEnv(h)).env : process.env;
128
+ try {
129
+ const child = spawn(client.bin, client.args(call), {
130
+ cwd: dir,
131
+ stdio: ["pipe", "pipe", "pipe"],
132
+ signal: input.signal,
133
+ env: input.client === "codex"
134
+ ? { ...childEnv, [CODEX_KEY_VAR]: internalKey("Codex") }
135
+ : childEnv,
136
+ });
137
+ child.stdin.on("error", () => {
138
+ // A client that is gone already says so on stdout and in its exit code.
139
+ });
140
+ child.stdin.end(client.stdin(call));
141
+ let reply = "";
142
+ let changed = false;
143
+ let failure = "";
144
+ let thinking = "";
145
+ let thought = null;
146
+ let stderr = "";
147
+ child.stderr.on("data", (chunk) => {
148
+ stderr = (stderr + String(chunk)).slice(-2000);
149
+ });
150
+ for await (const line of createInterface({ input: child.stdout })) {
151
+ for (const event of client.events(line)) {
152
+ if (event.kind === "text") {
153
+ const text = reply ? `\n\n${event.text}` : event.text;
151
154
  reply += text;
152
155
  input.onText(text);
153
156
  }
154
- else if (block.type === "tool_use") {
155
- const name = String(block.name ?? "");
156
- if (BUILDING.test(name)) {
157
+ else if (event.kind === "tool") {
158
+ if (event.started && BUILDING.test(event.name)) {
157
159
  changed = true;
158
160
  input.onBuilding();
159
161
  }
160
- input.onActivity(activity(name, block.input ?? {}, input.lang));
162
+ input.onActivity(activity(event.name, event.args, input.lang));
163
+ }
164
+ else if (event.kind === "thinkingStart") {
165
+ thinking = "";
166
+ }
167
+ else if (event.kind === "thinking") {
168
+ thinking += event.text;
169
+ const next = thoughtLine(thinking);
170
+ if (next && next !== thought) {
171
+ thought = next;
172
+ input.onThought?.(next);
173
+ }
174
+ }
175
+ else if (event.kind === "session") {
176
+ await writeSetting(key, event.id);
177
+ }
178
+ else if (event.kind === "failure") {
179
+ failure = event.detail;
180
+ }
181
+ else if (event.kind === "result" && !reply && event.text) {
182
+ reply = event.text;
183
+ input.onText(reply);
161
184
  }
162
185
  }
163
186
  }
164
- else if (event.type === "result") {
165
- if (event.session_id) {
166
- await writeSetting(sessionKey(input.wizardId), event.session_id);
187
+ const code = await new Promise((resolve) => {
188
+ if (child.exitCode !== null || child.signalCode !== null) {
189
+ resolve(child.exitCode);
167
190
  }
168
- if (event.is_error) {
169
- failure = String(event.result ?? "error");
191
+ else {
192
+ child.once("close", resolve);
170
193
  }
171
- else if (!reply && typeof event.result === "string") {
172
- reply = event.result;
173
- input.onText(reply);
194
+ });
195
+ if (failure || (code !== 0 && !reply)) {
196
+ // A conversation the client no longer has starts afresh next time.
197
+ await deleteSetting(key);
198
+ const detail = failure || stderr.trim() || `exit ${code}`;
199
+ if (client.signedOut(detail)) {
200
+ throw new ServiceError("refused", signedOut({ id: client.id, name: client.name }));
174
201
  }
202
+ throw new Error(`${client.name}: ${detail}`.slice(0, 500));
175
203
  }
204
+ return { reply: reply.trim(), changed };
176
205
  }
177
- const code = await new Promise((resolve) => child.once("close", resolve));
178
- if (failure || (code !== 0 && !reply)) {
179
- // A conversation the client no longer has starts afresh next time.
180
- await deleteSetting(sessionKey(input.wizardId));
181
- const detail = failure || stderr || `exit ${code}`;
182
- if (/authenticat|log ?in|oauth|credential/i.test(detail)) {
183
- throw new ServiceError("refused", signedOut({ id: "claude", name: "Claude Code" }));
206
+ finally {
207
+ for (const image of images) {
208
+ rmSync(image.file, { force: true });
184
209
  }
185
- throw new Error(`Claude Code: ${detail}`.slice(0, 500));
186
210
  }
187
- return { reply: reply.trim(), changed };
188
211
  }
212
+ /** The ways that can answer the studio's chats now, in the order the settings offer them. */
213
+ export async function chatWays(textModelReady) {
214
+ const ready = await Promise.all(CHAT_WAYS.map((w) => chatWayReady(w, textModelReady)));
215
+ return CHAT_WAYS.filter((_, i) => ready[i]);
216
+ }
217
+ /**
218
+ * What answers the studio's chats, Goose and the editor's chat, on a runtime that runs alone: the
219
+ * way chosen while it can answer, else the text classes, or Claude Code where it is the source.
220
+ */
189
221
  export async function chatEngine(textModelReady) {
190
- const clients = await subscriptionClients();
191
222
  const chosen = await readSetting("chat-engine");
192
- if (chosen === "claude" && clients.includes("claude")) {
193
- return "claude";
194
- }
195
- if (chosen === "models" && textModelReady) {
196
- return "models";
223
+ if (chosen && CHAT_WAYS.includes(chosen) && (await chatWayReady(chosen, textModelReady))) {
224
+ return chosen;
197
225
  }
198
- // Nothing chosen: where the client is the source of models, it answers the chat too.
199
- if (clients.includes("claude") && localModelSettings().source === "claude") {
226
+ const claude = await chatWayReady("claude", textModelReady);
227
+ // Nothing chosen: where Claude Code is the source of models, it answers the chat too.
228
+ if (claude && localModelSettings().source === "claude") {
200
229
  return "claude";
201
230
  }
202
- // Else a configured model answers; without one, the subscription does.
203
- return textModelReady || !clients.includes("claude") ? "models" : "claude";
231
+ // Else a configured model answers; without one, the Claude subscription does.
232
+ return textModelReady || !claude ? "models" : "claude";
204
233
  }
205
- export function setChatEngine(engine) {
206
- return writeSetting("chat-engine", engine);
234
+ export function setChatEngine(way) {
235
+ return writeSetting("chat-engine", way);
207
236
  }