@engenty/wizards-runtime 0.20.4 → 0.20.6

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 (87) hide show
  1. package/README.md +1 -1
  2. package/apps/runtime/dist/agents/subscription.js +19 -11
  3. package/apps/runtime/dist/cli/ollama.js +7 -76
  4. package/apps/runtime/dist/cli/setup.js +5 -4
  5. package/apps/runtime/dist/decision-model.js +1 -4
  6. package/apps/runtime/dist/docs/dev/licensing.md +7 -2
  7. package/apps/runtime/dist/docs/user-guide/command-line.md +2 -2
  8. package/apps/runtime/dist/engine/device.js +3 -2
  9. package/apps/runtime/dist/harness/antigravity.js +11 -7
  10. package/apps/runtime/dist/harness/apple.js +4 -3
  11. package/apps/runtime/dist/harness/clients.js +108 -0
  12. package/apps/runtime/dist/harness/index.js +29 -30
  13. package/apps/runtime/dist/harness/model.js +32 -270
  14. package/apps/runtime/dist/harness/prompt.js +6 -120
  15. package/apps/runtime/dist/harness/types.js +3 -2
  16. package/apps/runtime/dist/local-models.js +17 -37
  17. package/apps/runtime/dist/models.js +8 -5
  18. package/apps/runtime/dist/motion-graphics/step.js +2 -2
  19. package/apps/runtime/dist/routes/studio.js +1 -1
  20. package/apps/runtime/dist/services/work-ai.js +2 -2
  21. package/apps/web/dist/assets/{AboutDialog-CQvfeGqA.js → AboutDialog-BRUwrfQH.js} +1 -1
  22. package/apps/web/dist/assets/{CapabilitiesPage-DJRpCw2_.js → CapabilitiesPage-C30knXsS.js} +1 -1
  23. package/apps/web/dist/assets/{ChangelogDialog-F7gj0WCW.js → ChangelogDialog-BkZQOAdl.js} +1 -1
  24. package/apps/web/dist/assets/{ConnectorsSection-dXmTJOrm.js → ConnectorsSection-CmXQD7zu.js} +1 -1
  25. package/apps/web/dist/assets/{EditorPage-DNox0Po-.js → EditorPage-LEbyNWmG.js} +1 -1
  26. package/apps/web/dist/assets/{NewWizardChannels-BugegWm1.js → NewWizardChannels-CSn-9zHr.js} +1 -1
  27. package/apps/web/dist/assets/{NewWizardPage-Df359wgE.js → NewWizardPage-B4wPfClS.js} +1 -1
  28. package/apps/web/dist/assets/{ProtocolSection-B1tcJgJl.js → ProtocolSection-s4mEL_pu.js} +1 -1
  29. package/apps/web/dist/assets/{ReadOnly-DxC8kALr.js → ReadOnly-CO3ndR23.js} +1 -1
  30. package/apps/web/dist/assets/{Results-D6ecFiSB.js → Results-CC1-mElv.js} +1 -1
  31. package/apps/web/dist/assets/{RunDrawer-oPFk8yHt.js → RunDrawer-DkmSXhad.js} +1 -1
  32. package/apps/web/dist/assets/{SettingsPage-DueaPjW3.js → SettingsPage-DKs_fkNL.js} +2 -2
  33. package/apps/web/dist/assets/{SetupPage-k61GmbIs.js → SetupPage-RvmKCzF2.js} +1 -1
  34. package/apps/web/dist/assets/{SpacePage-z66Mza2y.js → SpacePage-aZqYFttF.js} +1 -1
  35. package/apps/web/dist/assets/{StudioHome-q1f_vqAI.js → StudioHome-Doua9Lyl.js} +1 -1
  36. package/apps/web/dist/assets/{TableEditor-Dfu5Qa-O.js → TableEditor-Dbq3HZZS.js} +1 -1
  37. package/apps/web/dist/assets/{UpdateCheck-y1StF2CW.js → UpdateCheck-B7etUbUf.js} +2 -2
  38. package/apps/web/dist/assets/changelog-BW79cVbx.js +1 -0
  39. package/apps/web/dist/assets/{host-Bh_WJbQv.js → host-BXSxBoOH.js} +3 -3
  40. package/apps/web/dist/assets/{index-CgSUfzBq.js → index-kDKA6ddy.js} +3 -3
  41. package/apps/web/dist/assets/{oss-credits-C4SGbRkz.js → oss-credits-B3PXhamW.js} +1 -1
  42. package/apps/web/dist/index.html +4 -4
  43. package/bin/bot-tunnel.mjs +375 -0
  44. package/bin/bot.mjs +1133 -125
  45. package/node_modules/@engenty/local-models/dist/clients/chat.d.ts +89 -0
  46. package/node_modules/@engenty/local-models/dist/clients/chat.js +22 -0
  47. package/node_modules/@engenty/local-models/dist/clients/claude.d.ts +32 -0
  48. package/node_modules/@engenty/local-models/dist/clients/claude.js +238 -0
  49. package/node_modules/@engenty/local-models/dist/clients/client.d.ts +29 -0
  50. package/node_modules/@engenty/local-models/dist/clients/client.js +2 -0
  51. package/node_modules/@engenty/local-models/dist/clients/codex.d.ts +35 -0
  52. package/node_modules/@engenty/local-models/dist/clients/codex.js +253 -0
  53. package/node_modules/@engenty/local-models/dist/clients/cursor.d.ts +33 -0
  54. package/node_modules/@engenty/local-models/dist/clients/cursor.js +180 -0
  55. package/node_modules/@engenty/local-models/dist/clients/detect.d.ts +18 -0
  56. package/node_modules/@engenty/local-models/dist/clients/detect.js +34 -0
  57. package/node_modules/@engenty/local-models/dist/clients/env.d.ts +66 -0
  58. package/{apps/runtime/dist/harness → node_modules/@engenty/local-models/dist/clients}/env.js +62 -31
  59. package/node_modules/@engenty/local-models/dist/clients/failure.d.ts +26 -0
  60. package/node_modules/@engenty/local-models/dist/clients/failure.js +35 -0
  61. package/node_modules/@engenty/local-models/dist/clients/index.d.ts +14 -0
  62. package/node_modules/@engenty/local-models/dist/clients/index.js +16 -0
  63. package/node_modules/@engenty/local-models/dist/clients/model.d.ts +126 -0
  64. package/node_modules/@engenty/local-models/dist/clients/model.js +225 -0
  65. package/node_modules/@engenty/local-models/dist/clients/prompt.d.ts +36 -0
  66. package/node_modules/@engenty/local-models/dist/clients/prompt.js +123 -0
  67. package/node_modules/@engenty/local-models/dist/clients/run.d.ts +15 -0
  68. package/node_modules/@engenty/local-models/dist/clients/run.js +41 -0
  69. package/node_modules/@engenty/local-models/dist/index.d.ts +3 -0
  70. package/node_modules/@engenty/local-models/dist/index.js +3 -0
  71. package/node_modules/@engenty/local-models/dist/ollama/api.d.ts +70 -0
  72. package/node_modules/@engenty/local-models/dist/ollama/api.js +164 -0
  73. package/node_modules/@engenty/local-models/dist/ollama/index.d.ts +2 -0
  74. package/node_modules/@engenty/local-models/dist/ollama/index.js +2 -0
  75. package/node_modules/@engenty/local-models/dist/ollama/model.d.ts +52 -0
  76. package/node_modules/@engenty/local-models/dist/ollama/model.js +302 -0
  77. package/node_modules/@engenty/local-models/dist/probe.d.ts +54 -0
  78. package/node_modules/@engenty/local-models/dist/probe.js +190 -0
  79. package/node_modules/@engenty/local-models/package.json +12 -0
  80. package/package.json +3 -1
  81. package/plugin/.claude-plugin/plugin.json +1 -1
  82. package/plugin/plugin.json +1 -1
  83. package/apps/runtime/dist/agents/chat-clients.js +0 -344
  84. package/apps/runtime/dist/harness/claude.js +0 -141
  85. package/apps/runtime/dist/harness/codex.js +0 -222
  86. package/apps/runtime/dist/harness/cursor.js +0 -89
  87. package/apps/web/dist/assets/changelog-DoEmFdnI.js +0 -1
package/README.md CHANGED
@@ -234,7 +234,7 @@ The wizard format, the runner and four libraries are MIT. The rest of the code i
234
234
  |---|---|
235
235
  | The wizard format: the eighteen files of `packages/shared` that define a wizard, read it and pack it as a `.wizard` file | MIT or FSL-1.1-MIT, your choice ([LICENSE-MIT](packages/shared/LICENSE-MIT)) |
236
236
  | The runner, `packages/runner` | MIT ([LICENSE](packages/runner/LICENSE)) |
237
- | The libraries `@engenty/decision-model`, `@engenty/search-index`, `@engenty/search-libsql`, `@engenty/goose`, `@engenty/vault`, `@engenty/plugins` and `@engenty/browser` on npm, in `packages/decision-model`, `packages/search-index`, `packages/search-libsql`, `packages/goose`, `packages/vault`, `packages/plugins` and `packages/browser` | MIT (the `LICENSE` in each folder) |
237
+ | The libraries `@engenty/decision-model`, `@engenty/search-index`, `@engenty/search-libsql`, `@engenty/goose`, `@engenty/vault`, `@engenty/plugins`, `@engenty/browser` and `@engenty/local-models` on npm, in `packages/decision-model`, `packages/search-index`, `packages/search-libsql`, `packages/goose`, `packages/vault`, `packages/plugins`, `packages/browser` and `packages/local-models` | MIT (the `LICENSE` in each folder) |
238
238
  | The plugin for the AI apps, `plugin/`, without the engenty figures in it | MIT ([LICENSE](plugin/LICENSE)) |
239
239
  | Everything else: the studio, the runtime, the `wizards` command, `@engenty/wizards` on npm | FSL-1.1-MIT ([LICENSE](LICENSE)) |
240
240
  | The engenty figures as artwork | CC BY 4.0 ([LICENSE-FIGURES](LICENSE-FIGURES)) |
@@ -4,11 +4,12 @@ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node
4
4
  import { homedir } from "node:os";
5
5
  import { dirname, join } from "node:path";
6
6
  import { createInterface } from "node:readline";
7
+ import { CLIENT_IDS, CLIENTS, cursorWorkspace, resolveEnv, } from "@engenty/local-models/clients";
7
8
  import { note } from "@engenty/wizards-shared/run";
8
9
  import { internalKey } from "../auth/keys.js";
9
10
  import { env } from "../env.js";
10
- import { resolveEnv } from "../harness/env.js";
11
- import { detectHarness, harness, signedOut } from "../harness/index.js";
11
+ import { detectHarness, harness } from "../harness/index.js";
12
+ import { signedOut } from "../harness/model.js";
12
13
  import { ModelUnavailableError } from "../model-errors.js";
13
14
  import { CHAT_WAYS, chatWayReady, localModelSettings, } from "../models.js";
14
15
  import { prompt } from "../prompts.js";
@@ -17,8 +18,13 @@ import { chatModelId } from "../services/chat-models.js";
17
18
  import { ServiceError } from "../services/errors.js";
18
19
  import { deleteSetting, readSetting, writeSetting } from "../settings.js";
19
20
  import { serverText } from "../texts.js";
20
- import { CHAT_CLIENTS, CODEX_KEY_VAR, cursorWorkspace, SUBSCRIPTION_CLIENTS, } from "./chat-clients.js";
21
21
  import { thoughtLine } from "./thought.js";
22
+ /** The clients whose subscription can answer the studio chat. */
23
+ const SUBSCRIPTION_CLIENTS = CLIENT_IDS;
24
+ /** The environment variable Codex reads this server's bearer key from. */
25
+ const CODEX_KEY_VAR = "WIZARDS_MCP_KEY";
26
+ /** This server's MCP server, as the clients know it. */
27
+ const MCP_NAME = "wizards";
22
28
  /** The AI clients installed and signed in on this machine whose subscription can answer the studio chat. */
23
29
  export async function subscriptionClients() {
24
30
  const found = await Promise.all(SUBSCRIPTION_CLIENTS.map(async (id) => {
@@ -35,7 +41,7 @@ function mcpConfig() {
35
41
  const file = join(workDir, "mcp.json");
36
42
  writeFileSync(file, JSON.stringify({
37
43
  mcpServers: {
38
- wizards: {
44
+ [MCP_NAME]: {
39
45
  type: "http",
40
46
  url: mcpUrl(),
41
47
  headers: { Authorization: `Bearer ${internalKey("Claude")}` },
@@ -84,7 +90,7 @@ const EXT = {
84
90
  };
85
91
  /** One chat turn on a subscription. The client keeps the conversation; we keep its id. */
86
92
  export async function subscriptionTurn(input) {
87
- const client = CHAT_CLIENTS[input.client];
93
+ const client = CLIENTS[input.client];
88
94
  const key = sessionKey(input.client, input.wizardId);
89
95
  // Cursor Agent keeps its chats per workspace: one folder per wizard.
90
96
  const dir = input.client === "cursor" ? join(workDir, "cursor", input.wizardId) : workDir;
@@ -93,7 +99,7 @@ export async function subscriptionTurn(input) {
93
99
  if (input.client === "cursor") {
94
100
  for (const [path, text] of Object.entries(cursorWorkspace({
95
101
  system,
96
- mcpUrl: mcpUrl(),
102
+ mcp: { name: MCP_NAME, url: mcpUrl() },
97
103
  key: internalKey("Cursor"),
98
104
  ownServers: ownCursorServers(),
99
105
  }))) {
@@ -117,9 +123,13 @@ export async function subscriptionTurn(input) {
117
123
  system,
118
124
  message: input.message,
119
125
  session: await readSetting(key),
120
- mcpUrl: mcpUrl(),
121
126
  dir,
122
- mcpConfigFile: input.client === "claude" ? mcpConfig() : undefined,
127
+ mcp: {
128
+ name: MCP_NAME,
129
+ url: mcpUrl(),
130
+ keyVar: CODEX_KEY_VAR,
131
+ configFile: input.client === "claude" ? mcpConfig() : undefined,
132
+ },
123
133
  model: (await chatModelId(input.client, input.extra === false ? "normal" : "extra")) ?? undefined,
124
134
  images,
125
135
  };
@@ -257,7 +267,7 @@ export async function chatEngine() {
257
267
  * hands it over: Claude Code streams it, Codex and Cursor Agent give a message once it is done.
258
268
  */
259
269
  export async function subscriptionText(input) {
260
- const client = CHAT_CLIENTS[input.client];
270
+ const client = CLIENTS[input.client];
261
271
  const dir = join(workDir, "bare", input.client);
262
272
  mkdirSync(dir, { recursive: true });
263
273
  if (input.client === "cursor") {
@@ -268,11 +278,9 @@ export async function subscriptionText(input) {
268
278
  system: input.system,
269
279
  message: input.message,
270
280
  session: null,
271
- mcpUrl: mcpUrl(),
272
281
  dir,
273
282
  model: (await chatModelId(input.client, "normal")) ?? undefined,
274
283
  images: [],
275
- bare: true,
276
284
  };
277
285
  input.clock?.runsOn(call.model);
278
286
  input.onModel?.(call.model);
@@ -4,7 +4,8 @@ import { statfs } from "node:fs/promises";
4
4
  import { homedir, tmpdir } from "node:os";
5
5
  import { join } from "node:path";
6
6
  import { setTimeout as sleep } from "node:timers/promises";
7
- import { decisionModelIn, ollamaRoot } from "../decision-model.js";
7
+ import { ollamaAddress, ollamaState } from "@engenty/local-models/ollama";
8
+ import { decisionModelIn } from "../decision-model.js";
8
9
  import { runLogged } from "./exec.js";
9
10
  import { findOnPath } from "./machine.js";
10
11
  /** The first Ollama that answers decision questions at /v1/systemone. */
@@ -29,10 +30,6 @@ const LINUX_ZSTD = [
29
30
  " fi",
30
31
  "fi",
31
32
  ].join("\n");
32
- /** Where Ollama answers: OLLAMA_URL as the runtime takes it (…/v1), without the /v1. */
33
- export function ollamaAddress(env = process.env) {
34
- return ollamaRoot(env.OLLAMA_URL || "http://127.0.0.1:11434/v1");
35
- }
36
33
  function executable(file) {
37
34
  try {
38
35
  accessSync(file, constants.X_OK);
@@ -50,24 +47,10 @@ export function findOllama(env = process.env) {
50
47
  }
51
48
  return (MAC_APPS.map((app) => join(app, "Contents", "Resources", "ollama")).find(executable) ?? null);
52
49
  }
53
- async function getJson(url) {
54
- try {
55
- const res = await fetch(url, { signal: AbortSignal.timeout(2000) });
56
- return res.ok ? (await res.json()) : null;
57
- }
58
- catch {
59
- return null;
60
- }
61
- }
62
- export async function ollamaState(env = process.env) {
63
- const root = ollamaAddress(env);
64
- const version = (await getJson(`${root}/api/version`))?.version ?? null;
65
- const tags = version ? await getJson(`${root}/api/tags`) : null;
66
- return {
67
- path: findOllama(env),
68
- version,
69
- model: decisionModelIn((tags?.models ?? []).map((m) => m.name)),
70
- };
50
+ /** Ollama on this computer: its command, the server that answers at OLLAMA_URL, and its decision model. */
51
+ export async function localOllama(env = process.env) {
52
+ const { version, models } = await ollamaState(ollamaAddress(env));
53
+ return { path: findOllama(env), version, model: decisionModelIn(models) };
71
54
  }
72
55
  /** Whether this Ollama is new enough to answer decision questions. */
73
56
  export function servesDecisions(version) {
@@ -208,7 +191,7 @@ export async function startOllama(path, paths) {
208
191
  }
209
192
  const deadline = Date.now() + (app ? 180_000 : 30_000);
210
193
  while (Date.now() < deadline) {
211
- const { version } = await ollamaState();
194
+ const { version } = await localOllama();
212
195
  if (version) {
213
196
  return version;
214
197
  }
@@ -248,55 +231,3 @@ export async function decisionModelProblem(model, env = process.env) {
248
231
  return error.message;
249
232
  }
250
233
  }
251
- /**
252
- * Pulls a model into the running Ollama; `onProgress` hears the bytes so far and in all as they
253
- * come. Rejects with Ollama's own reason.
254
- */
255
- export async function pullModel(model, onProgress, env = process.env) {
256
- const res = await fetch(`${ollamaAddress(env)}/api/pull`, {
257
- method: "POST",
258
- headers: { "content-type": "application/json" },
259
- body: JSON.stringify({ model, stream: true }),
260
- });
261
- if (!(res.ok && res.body)) {
262
- throw new Error(`Ollama answered ${res.status}. ${await res.text().catch(() => "")}`.trim());
263
- }
264
- // Each part of the model reports on its own; the sum is the download.
265
- const parts = new Map();
266
- const reader = res.body.getReader();
267
- const decoder = new TextDecoder();
268
- let pending = "";
269
- let finished = false;
270
- for (;;) {
271
- const { done, value } = await reader.read();
272
- if (done) {
273
- break;
274
- }
275
- pending += decoder.decode(value, { stream: true });
276
- const lines = pending.split("\n");
277
- pending = lines.pop() ?? "";
278
- for (const line of lines) {
279
- if (!line.trim()) {
280
- continue;
281
- }
282
- const event = JSON.parse(line);
283
- if (event.error) {
284
- throw new Error(event.error);
285
- }
286
- if (event.digest && event.total) {
287
- parts.set(event.digest, { total: event.total, completed: event.completed ?? 0 });
288
- let sum = 0;
289
- let all = 0;
290
- for (const part of parts.values()) {
291
- sum += part.completed;
292
- all += part.total;
293
- }
294
- onProgress(sum, all);
295
- }
296
- finished ||= event.status === "success";
297
- }
298
- }
299
- if (!finished) {
300
- throw new Error("The download broke off.");
301
- }
302
- }
@@ -2,6 +2,7 @@ import { appendFileSync, existsSync, readFileSync } from "node:fs";
2
2
  import { homedir, totalmem } from "node:os";
3
3
  import { delimiter, join } from "node:path";
4
4
  import * as p from "@clack/prompts";
5
+ import { ollamaAddress, pullModel } from "@engenty/local-models/ollama";
5
6
  import { LOCAL_DECISION_MODEL } from "../decision-model.js";
6
7
  import { installAll, ON_DEMAND } from "../on-demand.js";
7
8
  import { accountStep } from "./account.js";
@@ -11,7 +12,7 @@ import { appStates, connectApps } from "./connect.js";
11
12
  import { runLogged } from "./exec.js";
12
13
  import { command, installedByScript, isCheckout, layout, packageVersion, readInstallNote, writeInstallNote, } from "./home.js";
13
14
  import { CLIENTS, detectClients, findChrome, findFfmpeg, findOnPath, suggestedClient, vendorApp, } from "./machine.js";
14
- import { appAsksForPassword, DECISION_MODEL_GB, decisionModelProblem, freeGb, installOllama, ollamaState, pullModel, servesDecisions, startOllama, } from "./ollama.js";
15
+ import { appAsksForPassword, DECISION_MODEL_GB, decisionModelProblem, freeGb, installOllama, localOllama, servesDecisions, startOllama, } from "./ollama.js";
15
16
  import { runningRuntime, settings } from "./start.js";
16
17
  import { badge, busy, cmd, cyan, dim, tilde } from "./ui.js";
17
18
  /** The studio as an app of its own: Chrome (or Edge) installs it from the page. */
@@ -186,7 +187,7 @@ const gb = (bytes) => (bytes / 2 ** 30).toFixed(1);
186
187
  * download of about 11 GB.
187
188
  */
188
189
  async function decisionModelStep(paths, interactive) {
189
- const state = await ollamaState();
190
+ const state = await localOllama();
190
191
  if (state.version && !servesDecisions(state.version)) {
191
192
  p.log.warn(`Ollama ${state.version} is too old for a decision model (it needs 0.35 or newer).\n${dim(`Update Ollama, then run ${cmd("setup")} again.`)}`);
192
193
  return;
@@ -245,7 +246,7 @@ async function decisionModelStep(paths, interactive) {
245
246
  const installed = `Ollama installed ${dim(tilde(outcome.message))}`;
246
247
  task ? task.success(installed) : p.log.success(installed);
247
248
  // Linux's installer starts it as a service already.
248
- ({ path: ollama, version } = await ollamaState());
249
+ ({ path: ollama, version } = await localOllama());
249
250
  }
250
251
  if (!version) {
251
252
  if (appAsksForPassword(ollama)) {
@@ -267,7 +268,7 @@ async function decisionModelStep(paths, interactive) {
267
268
  const spinner = p.spinner();
268
269
  spinner.start(`Downloading ${model}`);
269
270
  try {
270
- await pullModel(model, (done, total) => spinner.message(`Downloading ${model} ${gb(done)} of ${gb(total)} GB`));
271
+ await pullModel(ollamaAddress(), model, (done, total) => spinner.message(`Downloading ${model} ${gb(done)} of ${gb(total)} GB`));
271
272
  spinner.stop(`Decision model: ${model} ${dim(`in Ollama ${version}`)}`);
272
273
  }
273
274
  catch (error) {
@@ -1,3 +1,4 @@
1
+ import { ollamaRoot } from "@engenty/local-models/ollama";
1
2
  /**
2
3
  * A decision model on the person's own machine: Cloudflare's Clef-flash (open weights, Apache
3
4
  * 2.0), which Ollama 0.35 and newer serves at /v1/systemone with the same questions and answers
@@ -6,10 +7,6 @@
6
7
  */
7
8
  /** The model the setup pulls. Clef, its larger sibling, is taken as well where it is there. */
8
9
  export const LOCAL_DECISION_MODEL = "clef-flash";
9
- /** Ollama's own address from the one the runtime uses for its OpenAI-style API (…/v1). */
10
- export function ollamaRoot(url) {
11
- return url.trim().replace(/\/+$/, "").replace(/\/v1$/, "");
12
- }
13
10
  /** The decision model among the models Ollama lists: Clef-flash, else Clef. */
14
11
  export function decisionModelIn(names) {
15
12
  const named = (base) => names.find((n) => n === base || n.startsWith(`${base}:`));
@@ -17,7 +17,7 @@ Use it, change it and share it in any app, open or closed. Keep the licence text
17
17
  | The wizard format | eighteen files in `packages/shared/src` | MIT or FSL-1.1-MIT, your choice ([LICENSE-MIT](https://github.com/engenty/wizards/blob/main/packages/shared/LICENSE-MIT)) |
18
18
  | The runner | `@engenty/wizards-runner` in `packages/runner` | MIT ([LICENSE](https://github.com/engenty/wizards/blob/main/packages/runner/LICENSE)) |
19
19
  | The plugin for the AI apps | `plugin/`, without the engenty figures in it | MIT ([LICENSE](https://github.com/engenty/wizards/blob/main/plugin/LICENSE)) |
20
- | The libraries | `@engenty/decision-model`, `@engenty/search-index`, `@engenty/search-libsql`, `@engenty/goose`, `@engenty/vault`, `@engenty/plugins` and `@engenty/browser` in `packages/` | MIT (the `LICENSE` in each folder) |
20
+ | The libraries | `@engenty/decision-model`, `@engenty/search-index`, `@engenty/search-libsql`, `@engenty/goose`, `@engenty/vault`, `@engenty/plugins`, `@engenty/browser` and `@engenty/local-models` in `packages/` | MIT (the `LICENSE` in each folder) |
21
21
 
22
22
  ### The wizard format
23
23
 
@@ -44,7 +44,7 @@ MIT, the format files it bundles included. Your own app can draw runs with it
44
44
 
45
45
  ### The libraries
46
46
 
47
- Seven libraries go to npm with each release, at its version:
47
+ Eight libraries go to npm with each release, at its version:
48
48
 
49
49
  - `@engenty/decision-model`: one request to a decision model, by whichever way is set up (the
50
50
  Vercel AI Gateway, TypeSafe’s API or Ollama)
@@ -62,6 +62,11 @@ Seven libraries go to npm with each release, at its version:
62
62
  - `@engenty/browser`: a browser for agents on Mastra’s agent-browser provider: its tools for any
63
63
  tool system, none that runs the model’s JavaScript, and a private fill that types a password
64
64
  or a code only into a field on the expected website
65
+ - `@engenty/local-models`: the models on a person’s own computer: Ollama (its models, what each
66
+ can do, which fits the memory, downloads, and a model on its own chat API with the context
67
+ length set), the AI clients signed in on their subscription (Claude Code, Codex, Cursor
68
+ Agent: found, signed in, run headless as a model or as a chat with one MCP server), and a
69
+ short real call that says whether each answers
65
70
 
66
71
  They depend only on each other and on packages under MIT or a licence as permissive.
67
72
 
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  title: Command line
3
3
  description: The wizards command – start, setup, status, update – and the settings file on your computer.
4
- version: 0.20.0
4
+ version: 0.20.5
5
5
  ---
6
6
 
7
7
  ## Commands
@@ -28,7 +28,7 @@ version: 0.20.0
28
28
  | `wizards disconnect [app …]` | Takes them out again |
29
29
  | `wizards mcp` | Runs the MCP server over stdio. AI apps start it; you don’t |
30
30
  | `wizards uninstall` | Takes engenty wizards off this computer. It shows what it will remove first and asks about your data on its own; your data is kept unless you choose to delete it. `--dry-run` only shows the plan, `--yes` asks nothing and keeps your data, `--yes --delete-data` deletes it too. See [Remove](./install.md#remove) |
31
- | `wizards bot` | Installs [wizards.bot](https://github.com/engenty/wizards-bot), your own agent in a home of your own, on this computer. It doesn’t need engenty wizards: `npx wizards bot install` works on its own. `install` puts the home into `~/.engenty/wizards/bot`, starts it with your computer on port 4747 (or the next free one) and opens its setup. `setup` opens the setup again and shows a code for your phone. `setup --link <address> <code>` links this computer to your home on wizards.bot, so it uses this computer’s models while this computer is on. `status`, `update` and `uninstall` do what they say. Your home’s data stays in `~/.wizards-bot` unless you add `--purge`, which asks first. On Windows it isn’t available yet |
31
+ | `wizards bot` | Installs [wizards.bot](https://github.com/engenty/wizards-bot), your own agent in a home of your own, on this computer. It doesn’t need engenty wizards: `npx wizards bot install` works on its own. `install` puts the home into `~/.engenty/wizards/bot`, starts it with your computer on port 4748 (or the next free one; 4747 stays free for the wizards.bot Mac app) and opens its setup. `install <folder>`, for example `install .` or `install ./test01`, puts a home of its own into that folder, beside the others: its program, its data, its port and its service. Every other command takes the folder after it too; without one, it means the home in `~/.engenty/wizards`. `setup` opens the setup again and shows a code for your phone. `setup --link <address> <code>` links this computer to your home on wizards.bot, so it uses this computer’s models while this computer is on. `status` shows the home and a line for each home in a folder. `stop` stops a home until you log in again or `start` it. `tunnel` puts a home on the internet at `https://<name>.wizards.host`, once a device is paired with it. It needs no account: the name, like `k7qf2mxd3a.wizards.host`, comes from a key the tunnel keeps in the home’s `tunnel/claim.pem`, and the same key gets the same name back after `tunnel --off`. `tunnel --account` gives the home your team’s address instead, after you sign in to your wizards account (`--name test01` with it gives a second home `test01.<team>.wizards.host`). The connection goes out from your computer through our relay, and its encryption ends on your computer, so the relay can’t read it. `tunnel --tailscale` uses Tailscale Funnel instead, and `tunnel --off` takes either off again. `update` and `uninstall` do what they say. Your home’s data stays unless you add `--purge`, which asks first. On Windows it isn’t available yet |
32
32
  | `wizards move-files` | Once, after the update to 0.16: moves the files of your spaces (logos, assets, documents) to where they are kept now, by their content, so the same file is stored once. Until then they don’t open. Running it again moves only what is left |
33
33
  | `wizards move-folder-sources` | Once, with Dateien and the new Wissen switched on: each folder the Sources plugin read into Wissen becomes a mounted folder in Dateien, and Wissen takes it from there. What you changed by hand stays yours. Running it again converts only what is left |
34
34
  | `wizards validate <path …>` | Checks wizards without the studio: `.wizard` files, unpacked wizard files, or a wizard’s JSON. `--json` prints the problems as JSON |
@@ -1,7 +1,8 @@
1
+ import { parseJsonAnswer, renderPrompt } from "@engenty/local-models/clients";
1
2
  import { and, asc, eq, isNull } from "drizzle-orm";
2
3
  import { nanoid } from "nanoid";
3
4
  import { db, schema } from "../db/client.js";
4
- import { parseJsonAnswer, renderPrompt } from "../harness/prompt.js";
5
+ import { CLIENT_WORDS } from "../harness/prompt.js";
5
6
  /** An offer not renewed for this long is forgotten: the person left the run. */
6
7
  const OFFER_TTL_MS = 30 * 60_000;
7
8
  /** How long the phone has to answer before the runtime thinks on its own. */
@@ -117,7 +118,7 @@ export class DeviceModel {
117
118
  if (format !== "text" && format !== "json") {
118
119
  return null;
119
120
  }
120
- const { system, prompt, warnings } = renderPrompt(options.prompt);
121
+ const { system, prompt, warnings } = renderPrompt(options.prompt, undefined, CLIENT_WORDS);
121
122
  if (warnings.length || system.length + prompt.length > this.maxChars) {
122
123
  return null;
123
124
  }
@@ -1,7 +1,7 @@
1
1
  import { writeFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
- import { probeVersion, resolveEnv, run } from "./env.js";
4
- import { failureOf, HarnessModel, runClient, } from "./model.js";
3
+ import { ClientModel, clientFailure, probeVersion, resolveEnv, run, runClient, } from "@engenty/local-models/clients";
4
+ import { modelOptions } from "./model.js";
5
5
  /**
6
6
  * Antigravity CLI: `agy` answers on the Google sign-in it cached — the Google AI subscription,
7
7
  * which Gemini CLI no longer serves. The prompt goes on stdin as one stream-json message, the
@@ -58,14 +58,14 @@ export function antigravityMessage(system, request) {
58
58
  const content = system ? `<instructions>\n${system}\n</instructions>\n\n${request}` : request;
59
59
  return `${JSON.stringify({ event: "user", message: { content } })}\n`;
60
60
  }
61
- class AntigravityModel extends HarnessModel {
61
+ class AntigravityModel extends ClientModel {
62
62
  provider = "antigravity";
63
63
  nativeSchema = true;
64
64
  usesTools = false;
65
65
  async invoke(call) {
66
66
  const { env, auth } = await resolveEnv(spec);
67
67
  if (auth === "none") {
68
- throw failureOf(this.harness, "not logged in");
68
+ throw clientFailure(this.client, "not logged in");
69
69
  }
70
70
  const args = [
71
71
  "--input-format",
@@ -89,10 +89,10 @@ class AntigravityModel extends HarnessModel {
89
89
  });
90
90
  const result = antigravityAnswer(stdout);
91
91
  if (!result) {
92
- throw failureOf(this.harness, stderr.trim() || `exit ${code}`);
92
+ throw clientFailure(this.client, stderr.trim() || `exit ${code}`);
93
93
  }
94
94
  if (result.status !== "SUCCESS") {
95
- throw failureOf(this.harness, result.error || stderr.trim() || result.status || "error");
95
+ throw clientFailure(this.client, result.error || stderr.trim() || result.status || "error");
96
96
  }
97
97
  const u = result.usage ?? {};
98
98
  return {
@@ -111,11 +111,15 @@ class AntigravityModel extends HarnessModel {
111
111
  }
112
112
  export const antigravity = {
113
113
  ...spec,
114
+ id: "antigravity",
114
115
  name: "Antigravity",
115
116
  bin: AGY_BIN,
116
117
  classes: CLASSES,
117
118
  version: (env) => probeVersion(AGY_BIN, env, (stdout) => stdout.trim().split("\n").pop()?.trim() || null),
118
119
  // No login command: the client asks for the Google sign-in when it starts without one.
119
120
  login: { args: [], interactive: true },
120
- model: (alias, effort) => new AntigravityModel(antigravity, alias || CLASSES.low, effort),
121
+ model: (alias, effort) => new AntigravityModel(antigravity, alias || CLASSES.low, {
122
+ ...modelOptions(antigravity),
123
+ effort,
124
+ }),
121
125
  };
@@ -2,13 +2,14 @@ import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
2
2
  import { release } from "node:os";
3
3
  import { dirname, join, resolve } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
+ import { ClientModel, lastJson, runClient, } from "@engenty/local-models/clients";
5
6
  import { langOf, SPEECH_LOCALES } from "@engenty/wizards-shared/definition";
6
7
  import { nanoid } from "nanoid";
7
8
  import { env } from "../env.js";
8
9
  import { ffmpeg, hasFfmpeg } from "../media/ffmpeg.js";
9
10
  import { ModelUnavailableError, NotedError } from "../model-errors.js";
10
11
  import { prompt } from "../prompts.js";
11
- import { HarnessModel, lastJson, runClient, } from "./model.js";
12
+ import { modelOptions } from "./model.js";
12
13
  /**
13
14
  * Apple Intelligence on this Mac as a model: the on-device foundation model of macOS 26, run
14
15
  * through `wizards-apple` (apps/runtime/apple/main.swift) — one process per call, as every
@@ -130,7 +131,7 @@ export function appleFailure(error) {
130
131
  function appleFailed(detail) {
131
132
  return new NotedError({ code: "appleFailed", params: { detail: detail.slice(0, 480) } });
132
133
  }
133
- class AppleModel extends HarnessModel {
134
+ class AppleModel extends ClientModel {
134
135
  provider = "apple";
135
136
  /** The model keeps to the schema itself (guided generation). */
136
137
  nativeSchema = true;
@@ -163,7 +164,7 @@ class AppleModel extends HarnessModel {
163
164
  }
164
165
  /** `apple:default` or `apple:tagging` as a language model. */
165
166
  export function appleModel(alias) {
166
- return new AppleModel(APPLE, alias || "default");
167
+ return new AppleModel(APPLE, alias || "default", modelOptions(APPLE));
167
168
  }
168
169
  /** The Mac's own language: what a voice note is most likely in, unless the call names one. */
169
170
  function systemLocale() {
@@ -0,0 +1,108 @@
1
+ import { existsSync, readdirSync, readFileSync, rmSync, statSync } from "node:fs";
2
+ import { homedir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { CLIENTS, ClientImageModel, CODEX_BIN, clientFailure, codexAnswer, codexExecArgs, resolveEnv, runClient, } from "@engenty/local-models/clients";
5
+ import { note } from "@engenty/wizards-shared/run";
6
+ import { prompt } from "../prompts.js";
7
+ import { modelOptions } from "./model.js";
8
+ /**
9
+ * Claude Code, Codex and Cursor Agent as the runtime runs them: the clients of
10
+ * @engenty/local-models/clients with the model each text class runs on, what the person reads
11
+ * when the account cannot pay, and Codex's images.
12
+ */
13
+ /** A client of the package as a harness of the runtime. */
14
+ function harnessOf(client, extra) {
15
+ const h = {
16
+ id: client.id,
17
+ name: client.name,
18
+ bin: client.bin,
19
+ passThrough: client.passThrough,
20
+ keyVars: client.keyVars,
21
+ auth: (env) => client.auth(env),
22
+ version: (env) => client.version(env),
23
+ login: client.login,
24
+ model: (alias, effort) => client.model(alias, { ...modelOptions(h), effort }),
25
+ ...extra,
26
+ };
27
+ return h;
28
+ }
29
+ export const claude = harnessOf(CLIENTS.claude, {
30
+ classes: { classifier: "haiku", low: "sonnet", standard: "opus", high: "opus" },
31
+ exhausted: note("anthropicAccountClaudeCode"),
32
+ });
33
+ /**
34
+ * Models a ChatGPT sign-in runs (checked 2026-10-04): Luna for small calls, Sol as the
35
+ * workhorse, Astra for the hardest work. A binding `codex/<model>` names another;
36
+ * `codex/default` = the model the client picks itself.
37
+ */
38
+ const CODEX_CLASSES = {
39
+ classifier: "gpt-6-luna",
40
+ low: "gpt-6.1-sol",
41
+ standard: "gpt-6.1-sol",
42
+ high: "gpt-6-astra",
43
+ };
44
+ /**
45
+ * Images: `codex exec` with the built-in image tool, the reference photos attached with `-i`.
46
+ * Codex keeps what it made under CODEX_HOME/generated_images/<thread>; the file is read from
47
+ * there and that folder removed. `codex/image` runs the tool on the low class's model.
48
+ */
49
+ class CodexImageModel extends ClientImageModel {
50
+ provider = "codex";
51
+ async invoke(call) {
52
+ const request = [
53
+ call.prompt,
54
+ call.files.length ? prompt("services", "harness.codex_image.edit") : "",
55
+ call.aspectRatio ? `Aspect ratio: ${call.aspectRatio}.` : "",
56
+ prompt("services", "harness.codex_image.once"),
57
+ ]
58
+ .filter(Boolean)
59
+ .join("\n\n");
60
+ const args = [
61
+ ...codexExecArgs(call.dir, false),
62
+ "-m",
63
+ this.modelId === "image" ? CODEX_CLASSES.low : this.modelId,
64
+ ];
65
+ for (const file of call.files) {
66
+ args.push("-i", file);
67
+ }
68
+ const { env } = await resolveEnv(CLIENTS.codex);
69
+ const { stdout, stderr, code } = await runClient(CODEX_BIN, args, {
70
+ cwd: call.dir,
71
+ env,
72
+ signal: call.signal,
73
+ stdin: request,
74
+ });
75
+ const { answer, failure } = codexAnswer(stdout);
76
+ if (failure || !answer?.sessionId) {
77
+ throw clientFailure(this.client, failure ?? stderr.trim() ?? `exit ${code}`);
78
+ }
79
+ const folder = join(env.CODEX_HOME?.trim() || join(homedir(), ".codex"), "generated_images", answer.sessionId);
80
+ try {
81
+ const made = existsSync(folder)
82
+ ? readdirSync(folder)
83
+ .filter((f) => /\.(png|jpe?g|webp)$/i.test(f))
84
+ .map((f) => join(folder, f))
85
+ .sort((a, b) => statSync(b).mtimeMs - statSync(a).mtimeMs)
86
+ : [];
87
+ if (!made[0]) {
88
+ throw new Error(`Codex made no image: ${answer.text.slice(0, 300)}`);
89
+ }
90
+ return new Uint8Array(readFileSync(made[0]));
91
+ }
92
+ finally {
93
+ rmSync(folder, { recursive: true, force: true });
94
+ }
95
+ }
96
+ }
97
+ export const codex = harnessOf(CLIENTS.codex, {
98
+ classes: CODEX_CLASSES,
99
+ exhausted: note("chatgptAccountCodexSigned"),
100
+ image: {
101
+ alias: "image",
102
+ model: (alias) => new CodexImageModel(codex, alias || "image", modelOptions(codex)),
103
+ },
104
+ });
105
+ /** "auto" = the model the client picks itself; a binding `cursor/<model>` names one. */
106
+ export const cursor = harnessOf(CLIENTS.cursor, {
107
+ classes: { classifier: "auto", low: "auto", standard: "auto", high: "auto" },
108
+ });
@@ -1,15 +1,29 @@
1
1
  import { mkdirSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { detectClient, loginShellEnv, setClientFolders, } from "@engenty/local-models/clients";
2
4
  import { installCommand, POWERSHELL } from "../cli/clients.js";
3
5
  import { inherited, runtimePath } from "../cli/environment.js";
4
6
  import { layout } from "../cli/home.js";
5
7
  import { CLIENTS, vendorApp } from "../cli/machine.js";
6
8
  import { antigravity } from "./antigravity.js";
7
- import { claude } from "./claude.js";
8
- import { codex } from "./codex.js";
9
- import { cursor } from "./cursor.js";
10
- import { forgetEnv, loginShellEnv, ProbeUndecided, resolveEnv } from "./env.js";
11
- export { HarnessModel, notInstalled, signedOut } from "./model.js";
9
+ import { claude, codex, cursor } from "./clients.js";
12
10
  export { HARNESS_IDS } from "./types.js";
11
+ /**
12
+ * Where the setup installs clients, whoever started this runtime: npm's prefix (on Windows the
13
+ * prefix itself), and on Windows where Claude Code and Cursor Agent put themselves. A client's
14
+ * environment finds them before the shell's PATH.
15
+ */
16
+ setClientFolders(() => {
17
+ if (process.platform !== "win32") {
18
+ return [join(layout().clients, "bin")];
19
+ }
20
+ const { USERPROFILE: home, LOCALAPPDATA: local } = process.env;
21
+ return [
22
+ layout().clients,
23
+ ...(home ? [join(home, ".local", "bin")] : []),
24
+ ...(local ? [join(local, "cursor-agent"), join(local, "agy", "bin")] : []),
25
+ ];
26
+ });
13
27
  /**
14
28
  * The AI clients this runtime can run as a model, in the order the setup offers them. The first
15
29
  * one installed is the one the setup recommends.
@@ -22,46 +36,31 @@ export function harness(id) {
22
36
  export function isHarnessVendor(vendor) {
23
37
  return HARNESSES.some((h) => h.id === vendor);
24
38
  }
25
- const detected = new Map();
39
+ /** The status last made of each client's detection, kept while the detection holds. */
40
+ const statuses = new Map();
26
41
  /** One client, as it is now; asked again after a minute — it may get installed or signed in meanwhile. */
27
42
  export async function detectHarness(id, force = false) {
28
43
  const h = harness(id);
29
44
  if (!h) {
30
45
  return null;
31
46
  }
32
- const hit = detected.get(id);
33
- if (!force && hit && Date.now() - hit.at < 60_000) {
34
- return hit.value;
35
- }
36
- if (force) {
37
- // The person may just have signed in or set a key in their shell.
38
- forgetEnv(id);
47
+ const status = await detectClient(h, force);
48
+ const kept = statuses.get(id);
49
+ if (kept?.of === status) {
50
+ return kept.value;
39
51
  }
40
52
  const client = CLIENTS.find((c) => c.id === id);
41
- let value = {
53
+ const value = {
42
54
  id,
43
55
  name: h.name,
44
56
  install: client ? installCommand(client, layout()) : "",
45
57
  app: client ? vendorApp(client) : null,
46
- version: null,
47
- auth: "none",
58
+ version: status.version,
59
+ auth: status.auth,
48
60
  interactiveLogin: h.login.interactive,
49
61
  images: Boolean(h.image),
50
62
  };
51
- try {
52
- const { env, auth } = await resolveEnv(h);
53
- const version = await h.version(env);
54
- if (version) {
55
- value = { ...value, version, auth };
56
- }
57
- }
58
- catch (err) {
59
- if (err instanceof ProbeUndecided && hit?.value.version) {
60
- // The machine is busy (another client is working): the client was there, it still is.
61
- value = hit.value;
62
- }
63
- }
64
- detected.set(id, { at: Date.now(), value });
63
+ statuses.set(id, { of: status, value });
65
64
  return value;
66
65
  }
67
66
  /** Every client this runtime knows, installed or not. */