@engenty/wizards-runtime 0.9.6 → 0.9.8
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.
- package/apps/runtime/dist/agents/architect.js +5 -3
- package/apps/runtime/dist/agents/chat-clients.js +299 -0
- package/apps/runtime/dist/agents/company.js +111 -0
- package/apps/runtime/dist/agents/studio-assistant.js +8 -4
- package/apps/runtime/dist/agents/subscription.js +163 -134
- package/apps/runtime/dist/agents/website.js +571 -53
- package/apps/runtime/dist/app.js +6 -3
- package/apps/runtime/dist/assistant/knows.js +5 -5
- package/apps/runtime/dist/assistant/primer.js +4 -4
- package/apps/runtime/dist/auth/account.js +12 -12
- package/apps/runtime/dist/auth/keys.js +18 -8
- package/apps/runtime/dist/authoring/example.js +2 -2
- package/apps/runtime/dist/authoring/guide.js +11 -11
- package/apps/runtime/dist/cli/account.js +20 -18
- package/apps/runtime/dist/cli/features.js +3 -3
- package/apps/runtime/dist/cli/ui.js +6 -0
- package/apps/runtime/dist/credits/estimate.js +5 -5
- package/apps/runtime/dist/db/adopt.js +4 -3
- package/apps/runtime/dist/db/migrations/control/0011_model_classes.sql +11 -0
- package/apps/runtime/dist/db/migrations/control/meta/0011_snapshot.json +600 -0
- package/apps/runtime/dist/db/migrations/control/meta/_journal.json +7 -0
- package/apps/runtime/dist/db/migrations/tenant/0021_model_classes.sql +41 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0021_snapshot.json +3475 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +7 -0
- package/apps/runtime/dist/db/schema.js +1 -1
- package/apps/runtime/dist/docs/dev/plugins/index.md +1 -1
- package/apps/runtime/dist/docs/dev/plugins/quick-start.md +2 -2
- package/apps/runtime/dist/docs/dev/plugins/server.md +4 -4
- package/apps/runtime/dist/docs/dev/plugins/studio.md +1 -1
- package/apps/runtime/dist/docs/dev/wizard-format/agent-steps.md +9 -5
- package/apps/runtime/dist/docs/dev/wizard-format/film-steps.md +2 -2
- package/apps/runtime/dist/docs/dev/wizard-format/index.md +14 -8
- package/apps/runtime/dist/docs/user-guide/ai-apps.md +1 -1
- package/apps/runtime/dist/docs/user-guide/command-line.md +1 -1
- package/apps/runtime/dist/docs/user-guide/create-account.md +6 -6
- package/apps/runtime/dist/docs/user-guide/first-start.md +1 -1
- package/apps/runtime/dist/docs/user-guide/index.md +5 -5
- package/apps/runtime/dist/docs/user-guide/models.md +35 -20
- package/apps/runtime/dist/docs/user-guide/space.md +1 -1
- package/apps/runtime/dist/docs/user-guide/steps.md +6 -6
- package/apps/runtime/dist/documents/parse.js +1 -1
- package/apps/runtime/dist/engine/requirements.js +11 -11
- package/apps/runtime/dist/engine/steps.js +4 -4
- package/apps/runtime/dist/env.js +4 -4
- package/apps/runtime/dist/features.js +4 -4
- package/apps/runtime/dist/film/step.js +1 -1
- package/apps/runtime/dist/harness/antigravity.js +3 -3
- package/apps/runtime/dist/harness/apple.js +1 -1
- package/apps/runtime/dist/harness/claude.js +2 -2
- package/apps/runtime/dist/harness/codex.js +3 -3
- package/apps/runtime/dist/harness/cursor.js +5 -1
- package/apps/runtime/dist/manage.js +4 -4
- package/apps/runtime/dist/mcp/auth.js +1 -1
- package/apps/runtime/dist/mcp/tools.js +6 -3
- package/apps/runtime/dist/models.js +139 -15
- package/apps/runtime/dist/plugins/loader.js +1 -1
- package/apps/runtime/dist/routes/lang.js +13 -4
- package/apps/runtime/dist/routes/runs.js +1 -1
- package/apps/runtime/dist/routes/studio.js +81 -41
- package/apps/runtime/dist/services/access.js +3 -3
- package/apps/runtime/dist/services/architect.js +4 -2
- package/apps/runtime/dist/services/assistant-chats.js +11 -2
- package/apps/runtime/dist/services/brand.js +1 -1
- package/apps/runtime/dist/services/knowledge-model.js +1 -1
- package/apps/runtime/dist/services/marketplace.js +3 -1
- package/apps/runtime/dist/services/onboarding.js +268 -48
- package/apps/runtime/dist/services/pages.js +17 -15
- package/apps/runtime/dist/services/project-files.js +1 -1
- package/apps/runtime/dist/services/translations.js +2 -2
- package/apps/runtime/dist/services/wizards.js +4 -4
- package/apps/runtime/dist/sharing/agent.js +1 -1
- package/apps/runtime/dist/texts.js +54 -8
- package/apps/web/dist/assets/{AboutDialog-CZr1JFvY.js → AboutDialog-B_Ixp_Tb.js} +1 -1
- package/apps/web/dist/assets/{ChangelogDialog-0pKHVdhu.js → ChangelogDialog-BpEIbAZ8.js} +1 -1
- package/apps/web/dist/assets/EditorPage-CKHY4hn4.js +4 -0
- package/apps/web/dist/assets/{FlowPreview-BZZvY5U9.js → FlowPreview-APXdRflR.js} +1 -1
- package/apps/web/dist/assets/{Harness-DPRw6BmX.js → Harness-BsGXMlLg.js} +2 -2
- package/apps/web/dist/assets/Marketplace-Dr-Qnb-F.js +2 -0
- package/apps/web/dist/assets/{NewWizardChannels-K5vfNzaC.js → NewWizardChannels-0JrRdUFd.js} +1 -1
- package/apps/web/dist/assets/NewWizardPage-9igFL5O8.js +7 -0
- package/apps/web/dist/assets/OnboardingPage-BcK9FUnU.js +1 -0
- package/apps/web/dist/assets/PreviewPane-X4LBqA0D.js +4 -0
- package/apps/web/dist/assets/ProjectPage-CG0i-KhR.js +1 -0
- package/apps/web/dist/assets/{PublicRunner-_N7DyvWj.js → PublicRunner-CZR1ziQ4.js} +1 -1
- package/apps/web/dist/assets/{ReadOnly-CQ8lWsnZ.js → ReadOnly-BraZbEG_.js} +1 -1
- package/apps/web/dist/assets/SettingsPage-Bw4tdoV7.js +2 -0
- package/apps/web/dist/assets/SetupPage-CvkE2aKx.js +1 -0
- package/apps/web/dist/assets/{SharePage-BXkykFJC.js → SharePage-Dk7zC5Zo.js} +1 -1
- package/apps/web/dist/assets/changelog-DDXnAaHm.js +1 -0
- package/apps/web/dist/assets/{coins-Bo9_D-7S.js → coins-391m1e4_.js} +1 -1
- package/apps/web/dist/assets/index-BTUtot4r.js +14 -0
- package/apps/web/dist/assets/index-DcUL6teA.css +1 -0
- package/apps/web/dist/assets/{phone-BPybLMSm.js → phone-DvgrtyNO.js} +1 -1
- package/apps/web/dist/assets/{runners-53tvGeez.js → runners-4OBelIgF.js} +1 -1
- package/apps/web/dist/assets/{session-DvW7auj-.js → session-DvnGHbDz.js} +1 -1
- package/apps/web/dist/assets/{settings-menu-tSPDYTfT.js → settings-menu-xK9A-gaP.js} +1 -1
- package/apps/web/dist/assets/theme-D3yDT4QT.js +11 -0
- package/apps/web/dist/assets/ui-BVQk2DtW.js +137 -0
- package/apps/web/dist/assets/{upload-Ct_-rz05.js → upload-BgXbzG6C.js} +1 -1
- package/apps/web/dist/assets/{useMutation-DM9Anfo-.js → useMutation-DkwSQWoD.js} +1 -1
- package/apps/web/dist/assets/{volume-2-CHuzf68z.js → volume-2-DHGoe3Cg.js} +1 -1
- package/apps/web/dist/assets/{wrench-BAgonupx.js → wrench-Cf_aE3O0.js} +1 -1
- package/apps/web/dist/index.html +8 -8
- package/apps/web/dist/mcp/flow.html +56 -56
- package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +2 -2
- package/node_modules/@engenty/wizards/dist/plugin/studio.d.ts +1 -1
- package/node_modules/@engenty/wizards-shared/dist/assistant.d.ts +6 -0
- package/node_modules/@engenty/wizards-shared/dist/assistant.js +2 -0
- package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +876 -18
- package/node_modules/@engenty/wizards-shared/dist/definition.js +61 -11
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +5 -5
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +5 -5
- package/node_modules/@engenty/wizards-shared/dist/features.d.ts +1 -1
- package/node_modules/@engenty/wizards-shared/dist/features.js +1 -1
- package/node_modules/@engenty/wizards-shared/dist/json-schema.js +3 -3
- package/node_modules/@engenty/wizards-shared/dist/projects.d.ts +1 -1
- package/node_modules/@engenty/wizards-shared/dist/projects.js +2 -2
- package/node_modules/@engenty/wizards-shared/dist/providers.d.ts +38 -1
- package/node_modules/@engenty/wizards-shared/dist/providers.js +65 -13
- package/node_modules/@engenty/wizards-shared/dist/run.d.ts +2 -2
- package/node_modules/@engenty/wizards-shared/dist/run.js +4 -4
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/plugin.json +1 -1
- package/apps/web/dist/assets/EditorPage-_qnWDno2.js +0 -4
- package/apps/web/dist/assets/Marketplace-BwbLRU2n.js +0 -2
- package/apps/web/dist/assets/NewWizardPage-zYwDoQTe.js +0 -7
- package/apps/web/dist/assets/OnboardingPage-jFgWaWJV.js +0 -1
- package/apps/web/dist/assets/PreviewPane-D5Kn9Ila.js +0 -4
- package/apps/web/dist/assets/ProjectPage-CyeEBVGi.js +0 -1
- package/apps/web/dist/assets/SettingsPage-haivwaZK.js +0 -2
- package/apps/web/dist/assets/SetupPage-Dy8KeG7z.js +0 -1
- package/apps/web/dist/assets/changelog-XRs8voQT.js +0 -1
- package/apps/web/dist/assets/index-CXA_do-X.js +0 -14
- package/apps/web/dist/assets/index-DG0i3S-z.css +0 -1
- package/apps/web/dist/assets/theme-CWGl7LyL.js +0 -11
- package/apps/web/dist/assets/ui-Bk08zclS.js +0 -137
|
@@ -14,8 +14,8 @@ import { currentTenantOrNull } from "./tenants/tenant.js";
|
|
|
14
14
|
* 1. the defaults the code declares: the core's (packages/shared/src/feature-flags.ts) and the
|
|
15
15
|
* loaded plugins' (their manifests' `features`, under the plugin's id)
|
|
16
16
|
* 2. the `FEATURES` environment variable (`teamPlans=on,site=off`): the cloud image, compose, dev
|
|
17
|
-
* 3. what the Manage-App says — for the
|
|
18
|
-
* local one; a plan's switches and what an admin set for the
|
|
17
|
+
* 3. what the Manage-App says — for the organization of a cloud runtime, for the linked account of a
|
|
18
|
+
* local one; a plan's switches and what an admin set for the organization or for everyone
|
|
19
19
|
* 4. the `.features` file of this install (`~/.engenty/wizards/.features`; a checkout reads
|
|
20
20
|
* the repo root's, a cloud runtime its data folder's) — this machine's word is the last
|
|
21
21
|
*
|
|
@@ -56,7 +56,7 @@ export function declaredFeatures(sources = loadedPlugins().map((p) => p.source))
|
|
|
56
56
|
}
|
|
57
57
|
return out;
|
|
58
58
|
}
|
|
59
|
-
/** The switches, with what the Manage-App said for the
|
|
59
|
+
/** The switches, with what the Manage-App said for the organization or account laid in. */
|
|
60
60
|
export function features(remote) {
|
|
61
61
|
return resolveFeatures(defaultFeatures(declaredFeatures()), envFeatures(), remote, fileFeatures());
|
|
62
62
|
}
|
|
@@ -65,7 +65,7 @@ export function feature(name, remote) {
|
|
|
65
65
|
}
|
|
66
66
|
let accountCache = null;
|
|
67
67
|
/**
|
|
68
|
-
* What the Manage-App says for the tenant at hand: the
|
|
68
|
+
* What the Manage-App says for the tenant at hand: the organization's switches on a cloud runtime
|
|
69
69
|
* (cached a minute by `tenantInfo`), the linked account's on a local one (cached a minute
|
|
70
70
|
* here). Null when nothing is linked or the Manage-App does not answer.
|
|
71
71
|
*/
|
|
@@ -94,7 +94,7 @@ function renderProblem(out) {
|
|
|
94
94
|
/** How many times a failed final render goes back to the client to be fixed. */
|
|
95
95
|
const RENDER_FIXES = 2;
|
|
96
96
|
export async function runFilmStep(step, ctx) {
|
|
97
|
-
const found = await filmClient(step.model ?? "
|
|
97
|
+
const found = await filmClient(step.model ?? "low");
|
|
98
98
|
if ("problem" in found) {
|
|
99
99
|
throw new StepError(found.problem);
|
|
100
100
|
}
|
|
@@ -14,9 +14,9 @@ export const AGY_BIN = process.env.AGY_BIN?.trim() || "agy";
|
|
|
14
14
|
/** The models carry their effort in the name: `gemini-3.8-flash-<low|medium|high>`. */
|
|
15
15
|
const CLASSES = {
|
|
16
16
|
classifier: "gemini-3.8-flash-low",
|
|
17
|
-
|
|
17
|
+
low: "gemini-3.8-flash-medium",
|
|
18
|
+
standard: "gemini-3.8-flash-high",
|
|
18
19
|
high: "gemini-3.8-flash-high",
|
|
19
|
-
highest: "gemini-3.8-flash-high",
|
|
20
20
|
};
|
|
21
21
|
/** The model of that name at the effort a step asks for, where the name carries one. */
|
|
22
22
|
export function withEffort(model, effort) {
|
|
@@ -117,5 +117,5 @@ export const antigravity = {
|
|
|
117
117
|
version: (env) => probeVersion(AGY_BIN, env, (stdout) => stdout.trim().split("\n").pop()?.trim() || null),
|
|
118
118
|
// No login command: the client asks for the Google sign-in when it starts without one.
|
|
119
119
|
login: { args: [], interactive: true },
|
|
120
|
-
model: (alias, effort) => new AntigravityModel(antigravity, alias || CLASSES.
|
|
120
|
+
model: (alias, effort) => new AntigravityModel(antigravity, alias || CLASSES.low, effort),
|
|
121
121
|
};
|
|
@@ -14,7 +14,7 @@ import { HarnessModel, lastJson, runClient, } from "./model.js";
|
|
|
14
14
|
* installed AI client is run. Nothing leaves the machine and nothing is signed in. It is offered
|
|
15
15
|
* where it can run: a Mac with Apple silicon on macOS 26 or later with the helper built, and it
|
|
16
16
|
* answers once Apple Intelligence is switched on. The model is small (about 3B parameters,
|
|
17
|
-
* 4,096 tokens for prompt and answer together): a way for the Classifier and
|
|
17
|
+
* 4,096 tokens for prompt and answer together): a way for the Classifier and Low classes,
|
|
18
18
|
* not for research, long documents or code. `apple:default` is the model; `apple:tagging` is
|
|
19
19
|
* Apple's adapter for tagging and extraction.
|
|
20
20
|
*/
|
|
@@ -9,9 +9,9 @@ import { failureOf, HarnessModel, lastJson, runClient, } from "./model.js";
|
|
|
9
9
|
export const CLAUDE_BIN = process.env.CLAUDE_BIN?.trim() || "claude";
|
|
10
10
|
const CLASSES = {
|
|
11
11
|
classifier: "haiku",
|
|
12
|
-
|
|
12
|
+
low: "sonnet",
|
|
13
|
+
standard: "opus",
|
|
13
14
|
high: "opus",
|
|
14
|
-
highest: "opus",
|
|
15
15
|
};
|
|
16
16
|
const spec = {
|
|
17
17
|
id: "claude",
|
|
@@ -17,9 +17,9 @@ export const CODEX_BIN = process.env.CODEX_BIN?.trim() || "codex";
|
|
|
17
17
|
*/
|
|
18
18
|
const CLASSES = {
|
|
19
19
|
classifier: "gpt-6-luna",
|
|
20
|
+
low: "gpt-6.1-sol",
|
|
20
21
|
standard: "gpt-6.1-sol",
|
|
21
|
-
high: "gpt-6
|
|
22
|
-
highest: "gpt-6-astra",
|
|
22
|
+
high: "gpt-6-astra",
|
|
23
23
|
};
|
|
24
24
|
const spec = {
|
|
25
25
|
id: "codex",
|
|
@@ -173,7 +173,7 @@ class CodexImageModel extends HarnessImageModel {
|
|
|
173
173
|
"-c",
|
|
174
174
|
'web_search="disabled"',
|
|
175
175
|
"-m",
|
|
176
|
-
this.modelId === "image" ? CLASSES.
|
|
176
|
+
this.modelId === "image" ? CLASSES.low : this.modelId,
|
|
177
177
|
];
|
|
178
178
|
for (const file of call.files) {
|
|
179
179
|
args.push("-i", file);
|
|
@@ -11,9 +11,9 @@ export const CURSOR_BIN = process.env.CURSOR_AGENT_BIN?.trim() || "cursor-agent"
|
|
|
11
11
|
/** "auto" = the model the client picks itself; a binding `cursor/<model>` names one. */
|
|
12
12
|
const CLASSES = {
|
|
13
13
|
classifier: "auto",
|
|
14
|
+
low: "auto",
|
|
14
15
|
standard: "auto",
|
|
15
16
|
high: "auto",
|
|
16
|
-
highest: "auto",
|
|
17
17
|
};
|
|
18
18
|
/** The escape sequences a terminal app draws with. */
|
|
19
19
|
const ANSI = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*[A-Za-z]`, "g");
|
|
@@ -45,6 +45,10 @@ class CursorModel extends HarnessModel {
|
|
|
45
45
|
if (call.bridgeUrl) {
|
|
46
46
|
mkdirSync(join(call.dir, ".cursor"), { recursive: true });
|
|
47
47
|
writeFileSync(join(call.dir, ".cursor", "mcp.json"), JSON.stringify({ mcpServers: { step: { url: call.bridgeUrl } } }));
|
|
48
|
+
// The call's tools are all on the bridge: the client runs no commands and writes no files.
|
|
49
|
+
writeFileSync(join(call.dir, ".cursor", "cli.json"), JSON.stringify({
|
|
50
|
+
permissions: { allow: ["Mcp(step:*)"], deny: ["Shell(*)", "Write(**)"] },
|
|
51
|
+
}));
|
|
48
52
|
}
|
|
49
53
|
const args = ["-p", "--output-format", "json", "--workspace", call.dir, "--approve-mcps"];
|
|
50
54
|
if (this.modelId !== "auto") {
|
|
@@ -145,7 +145,7 @@ export async function tenantInfo(id, fresh = false) {
|
|
|
145
145
|
export function forgetTenant(id) {
|
|
146
146
|
tenants.delete(id);
|
|
147
147
|
}
|
|
148
|
-
/** Renames the
|
|
148
|
+
/** Renames the organization at the Manage-App; what it answers is the tenant as it stands now. */
|
|
149
149
|
export async function renameTenant(id, name) {
|
|
150
150
|
const value = await call("PATCH", `/v1/tenants/${encodeURIComponent(id)}`, {
|
|
151
151
|
name,
|
|
@@ -153,14 +153,14 @@ export async function renameTenant(id, name) {
|
|
|
153
153
|
tenants.set(id, { at: Date.now(), value });
|
|
154
154
|
return value;
|
|
155
155
|
}
|
|
156
|
-
export function
|
|
156
|
+
export function saveOrganizationProfile(tenantId, userId, lang, profile) {
|
|
157
157
|
return call("PUT", `/v1/tenants/${encodeURIComponent(tenantId)}/profile`, {
|
|
158
158
|
...profile,
|
|
159
159
|
userId,
|
|
160
160
|
lang,
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
|
-
/** The Manage-App mails the install command and the first steps to one of the
|
|
163
|
+
/** The Manage-App mails the install command and the first steps to one of the organization's people. */
|
|
164
164
|
export function installMail(email, lang) {
|
|
165
165
|
return call("POST", "/v1/install-mail", { email, lang });
|
|
166
166
|
}
|
|
@@ -230,7 +230,7 @@ export function bookChannelUsage(id, input) {
|
|
|
230
230
|
return call("POST", `/v1/tenants/${encodeURIComponent(id)}/channels/usage`, input);
|
|
231
231
|
}
|
|
232
232
|
/**
|
|
233
|
-
* The
|
|
233
|
+
* The organization's public page data, whole (services/pages.ts): Manage keeps it and serves the page at
|
|
234
234
|
* `<slug>.<PAGES_DOMAIN>`. What it answers names the page's address.
|
|
235
235
|
*/
|
|
236
236
|
export function putPages(tenantId, data) {
|
|
@@ -78,7 +78,7 @@ const grantCache = new Map();
|
|
|
78
78
|
const GRANT_TTL = 30_000;
|
|
79
79
|
/**
|
|
80
80
|
* A signed token lives its hour whatever happens; whether the person still allows the app —
|
|
81
|
-
* and is still in the
|
|
81
|
+
* and is still in the organization — the Manage-App knows. Asked at most every 30 seconds per grant;
|
|
82
82
|
* when it cannot be asked, the token is refused.
|
|
83
83
|
*/
|
|
84
84
|
async function grantStands(userId, clientId, tenantId) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DEFINITION_VERSION, upgradeDefinition } from "@engenty/wizards-shared/definition";
|
|
1
2
|
import { z } from "zod";
|
|
2
3
|
import { authoringGuide } from "../authoring/guide.js";
|
|
3
4
|
import { wizardOpSchema } from "../authoring/ops.js";
|
|
@@ -16,6 +17,8 @@ import { FLOW_VIEW_KEY, flowAppMeta, flowView } from "./flow-app.js";
|
|
|
16
17
|
const definition = z
|
|
17
18
|
.record(z.string(), z.unknown())
|
|
18
19
|
.describe("The complete wizard JSON as described by get_authoring_guide.");
|
|
20
|
+
/** A wizard a model wrote from today's authoring guide is of today's version, said or not. */
|
|
21
|
+
const authored = (raw) => upgradeDefinition(raw, DEFINITION_VERSION);
|
|
19
22
|
const note = z
|
|
20
23
|
.string()
|
|
21
24
|
.max(500)
|
|
@@ -244,7 +247,7 @@ export function registerTools(server, who) {
|
|
|
244
247
|
readOnly: true,
|
|
245
248
|
}, async (args) => {
|
|
246
249
|
try {
|
|
247
|
-
const { issues } = parseDraft(args.definition);
|
|
250
|
+
const { issues } = parseDraft(authored(args.definition));
|
|
248
251
|
return { ok: issues.length === 0, issues };
|
|
249
252
|
}
|
|
250
253
|
catch (err) {
|
|
@@ -265,7 +268,7 @@ export function registerTools(server, who) {
|
|
|
265
268
|
note,
|
|
266
269
|
}),
|
|
267
270
|
}, async (args) => {
|
|
268
|
-
const created = await createWizard(who.userId, args, writer);
|
|
271
|
+
const created = await createWizard(who.userId, { ...args, definition: args.definition && authored(args.definition) }, writer);
|
|
269
272
|
return {
|
|
270
273
|
wizardId: created.id,
|
|
271
274
|
revision: created.revision,
|
|
@@ -300,7 +303,7 @@ Returns the new revision and the issues.`,
|
|
|
300
303
|
input: z.object({ wizardId: z.string(), baseRevision, definition, note }),
|
|
301
304
|
destructive: true,
|
|
302
305
|
}, async ({ wizardId, ...input }) => {
|
|
303
|
-
const { revision, issues } = await writeDraft(who.userId, wizardId, input, writer);
|
|
306
|
+
const { revision, issues } = await writeDraft(who.userId, wizardId, { ...input, definition: authored(input.definition) }, writer);
|
|
304
307
|
return { revision, issues };
|
|
305
308
|
});
|
|
306
309
|
// --- publish ---------------------------------------------------------------
|
|
@@ -6,8 +6,8 @@ import { createGateway } from "@ai-sdk/gateway";
|
|
|
6
6
|
import { createGoogle } from "@ai-sdk/google";
|
|
7
7
|
import { createOpenAI } from "@ai-sdk/openai";
|
|
8
8
|
import { createReplicate } from "@ai-sdk/replicate";
|
|
9
|
-
import { MODEL_CLASSES, TEXT_CLASSES, } from "@engenty/wizards-shared/definition";
|
|
10
|
-
import { CAPABILITY_CLASSES, creditsModelOf, isCreditsRef, PROVIDER_IDS, providerInfo, providerOfRef, } from "@engenty/wizards-shared/providers";
|
|
9
|
+
import { DEFINITION_VERSION, MODEL_CLASSES, TEXT_CLASSES, } from "@engenty/wizards-shared/definition";
|
|
10
|
+
import { blockingNeeds, CAPABILITY_CLASSES, creditsModelOf, isCreditsRef, missingNeeds, PROVIDER_IDS, providerInfo, providerOfRef, traitsOf, } from "@engenty/wizards-shared/providers";
|
|
11
11
|
import { note, saidText } from "@engenty/wizards-shared/run";
|
|
12
12
|
import { generateSpeech, generateText, } from "ai";
|
|
13
13
|
import { accountToken, linkedAccount } from "./auth/account.js";
|
|
@@ -70,8 +70,8 @@ export async function loadLocalModels() {
|
|
|
70
70
|
}
|
|
71
71
|
const tenantConfigs = new Map();
|
|
72
72
|
const tenantSetting = (tenant) => `models:${tenant}`;
|
|
73
|
-
/**
|
|
74
|
-
function
|
|
73
|
+
/** An organization thinks on its credits unless it brought a key: `own`, with the credits behind it. */
|
|
74
|
+
function organizationSettings(bindings) {
|
|
75
75
|
return { source: "own", bindings, creditFallback: true };
|
|
76
76
|
}
|
|
77
77
|
async function tenantConfig(tenant) {
|
|
@@ -81,7 +81,7 @@ async function tenantConfig(tenant) {
|
|
|
81
81
|
}
|
|
82
82
|
const stored = await readSetting(tenantSetting(tenant));
|
|
83
83
|
const value = {
|
|
84
|
-
settings:
|
|
84
|
+
settings: organizationSettings(stored?.bindings ?? {}),
|
|
85
85
|
keys: (stored?.keys ? unseal(stored.keys) : null) ?? {},
|
|
86
86
|
};
|
|
87
87
|
tenantConfigs.set(tenant, value);
|
|
@@ -92,7 +92,7 @@ async function config() {
|
|
|
92
92
|
return local;
|
|
93
93
|
}
|
|
94
94
|
const tenant = currentTenantOrNull();
|
|
95
|
-
return tenant ? tenantConfig(tenant) : { settings:
|
|
95
|
+
return tenant ? tenantConfig(tenant) : { settings: organizationSettings({}), keys: {} };
|
|
96
96
|
}
|
|
97
97
|
function mergeBindings(current, changes = {}) {
|
|
98
98
|
const bindings = { ...current };
|
|
@@ -132,7 +132,7 @@ export async function saveLocalModels(input) {
|
|
|
132
132
|
}
|
|
133
133
|
await loadLocalModels();
|
|
134
134
|
}
|
|
135
|
-
/**
|
|
135
|
+
/** An organization's keys and bindings on a runtime of a Manage-App. No client and no local model there. */
|
|
136
136
|
async function saveTenantModels(tenant, input) {
|
|
137
137
|
const current = await tenantConfig(tenant);
|
|
138
138
|
const keys = { ...current.keys };
|
|
@@ -205,7 +205,7 @@ function reachable(cfg, ref) {
|
|
|
205
205
|
/** What a class runs on without credits: a client, an own key or a local model. "" = no way of its own. */
|
|
206
206
|
function ownRef(cfg, cls) {
|
|
207
207
|
const bound = cfg.settings.bindings[cls];
|
|
208
|
-
// A text class bound to Apple Intelligence (Classifier,
|
|
208
|
+
// A text class bound to Apple Intelligence (Classifier, Low) thinks on this Mac whatever
|
|
209
209
|
// the source is: the others keep the installed client, the account's credits or the keys.
|
|
210
210
|
if (isText(cls) && bound && parse(bound).provider === "apple") {
|
|
211
211
|
return reachable(cfg, bound) ? bound : "";
|
|
@@ -237,9 +237,9 @@ function ownRef(cfg, cls) {
|
|
|
237
237
|
/** What a class makes, to say that nothing makes it. */
|
|
238
238
|
const MAKES = {
|
|
239
239
|
classifier: "makesText",
|
|
240
|
+
low: "makesText",
|
|
240
241
|
standard: "makesText",
|
|
241
242
|
high: "makesText",
|
|
242
|
-
highest: "makesText",
|
|
243
243
|
image: "makesImages",
|
|
244
244
|
video: "makesVideos",
|
|
245
245
|
speech: "makesSpeech",
|
|
@@ -306,11 +306,17 @@ function need(cfg, name) {
|
|
|
306
306
|
}
|
|
307
307
|
return key;
|
|
308
308
|
}
|
|
309
|
+
/**
|
|
310
|
+
* Says the class names of this definition version: the gateway reads `wizards/<class>` and
|
|
311
|
+
* answers `/v1/models` in them. A caller without it is a runtime from before version 2.
|
|
312
|
+
*/
|
|
313
|
+
const DEFINITION_HEADER = { "x-wizards-definition": String(DEFINITION_VERSION) };
|
|
309
314
|
function gatewayClient(access, meta) {
|
|
310
315
|
return createGateway({
|
|
311
316
|
baseURL: `${access.baseUrl}/v4/ai`,
|
|
312
317
|
apiKey: access.token,
|
|
313
318
|
headers: {
|
|
319
|
+
...DEFINITION_HEADER,
|
|
314
320
|
...(access.tenant ? { "x-wizards-tenant": access.tenant } : {}),
|
|
315
321
|
...(meta.runId ? { "x-wizards-run": meta.runId } : {}),
|
|
316
322
|
...(meta.stepId ? { "x-wizards-step": meta.stepId } : {}),
|
|
@@ -335,6 +341,7 @@ export async function classCatalog() {
|
|
|
335
341
|
const res = await fetch(`${access.baseUrl}/v1/models`, {
|
|
336
342
|
headers: {
|
|
337
343
|
authorization: `Bearer ${access.token}`,
|
|
344
|
+
...DEFINITION_HEADER,
|
|
338
345
|
...(access.tenant ? { "x-wizards-tenant": access.tenant } : {}),
|
|
339
346
|
},
|
|
340
347
|
signal: AbortSignal.timeout(10_000),
|
|
@@ -434,6 +441,76 @@ async function ownTextModel(cls, meta) {
|
|
|
434
441
|
const { model, gateway } = await ownLanguageModel(route.cfg, route.ref, meta);
|
|
435
442
|
return { model, ref: route.ref, vendor: vendorOf(route.ref), gateway, metered: false };
|
|
436
443
|
}
|
|
444
|
+
/**
|
|
445
|
+
* What answers the studio's chats, Goose and the editor's chat: the text classes as they are set
|
|
446
|
+
* (`models`), an installed client on its subscription, one provider's own key, or the credits.
|
|
447
|
+
*/
|
|
448
|
+
export const CHAT_WAYS = [
|
|
449
|
+
"models",
|
|
450
|
+
"claude",
|
|
451
|
+
"codex",
|
|
452
|
+
"cursor",
|
|
453
|
+
"openai",
|
|
454
|
+
"anthropic",
|
|
455
|
+
"google",
|
|
456
|
+
"gateway",
|
|
457
|
+
"account",
|
|
458
|
+
];
|
|
459
|
+
/** Whether a way can answer now: the client signed in, the key there, the account linked. */
|
|
460
|
+
export async function chatWayReady(way, textModelReady) {
|
|
461
|
+
if (way === "models") {
|
|
462
|
+
return textModelReady;
|
|
463
|
+
}
|
|
464
|
+
if (managed) {
|
|
465
|
+
return false;
|
|
466
|
+
}
|
|
467
|
+
const client = harness(way);
|
|
468
|
+
if (client) {
|
|
469
|
+
const status = await detectHarness(client.id);
|
|
470
|
+
return Boolean(status?.version) && status?.auth !== "none";
|
|
471
|
+
}
|
|
472
|
+
if (way === "account") {
|
|
473
|
+
return Boolean(await linkedAccount());
|
|
474
|
+
}
|
|
475
|
+
return Boolean((await config()).keys[way]);
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* The model a studio chat runs on. `cls` is the text class it takes where the chat follows the
|
|
479
|
+
* classes; a client or a provider runs its own model of that class.
|
|
480
|
+
*/
|
|
481
|
+
export async function chatModel(way, cls) {
|
|
482
|
+
if (way === "models") {
|
|
483
|
+
return textModel(cls);
|
|
484
|
+
}
|
|
485
|
+
const cfg = await config();
|
|
486
|
+
const client = harness(way);
|
|
487
|
+
if (client) {
|
|
488
|
+
if (!(await detectHarness(client.id))?.version) {
|
|
489
|
+
throw new ModelUnavailableError(notInstalled(client));
|
|
490
|
+
}
|
|
491
|
+
const alias = client.classes[cls];
|
|
492
|
+
return {
|
|
493
|
+
model: client.model(alias),
|
|
494
|
+
ref: `${client.id}/${alias}`,
|
|
495
|
+
vendor: client.id,
|
|
496
|
+
gateway: false,
|
|
497
|
+
metered: false,
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
if (way === "account") {
|
|
501
|
+
const access = await creditAccess(cfg, true);
|
|
502
|
+
if (!access) {
|
|
503
|
+
throw new ModelUnavailableError(note("creditsNotSignedIn"));
|
|
504
|
+
}
|
|
505
|
+
return viaCredits({ kind: "credits", access, model: null }, cls, {}, (gateway, id) => gateway(id));
|
|
506
|
+
}
|
|
507
|
+
const ref = providerInfo(way)?.text?.[cls];
|
|
508
|
+
if (!ref) {
|
|
509
|
+
throw new ModelUnavailableError(note("noModelFor", { makes: note("makesText") }));
|
|
510
|
+
}
|
|
511
|
+
const { model, gateway } = await ownLanguageModel(cfg, ref, {});
|
|
512
|
+
return { model, ref, vendor: vendorOf(ref), gateway, metered: false };
|
|
513
|
+
}
|
|
437
514
|
/**
|
|
438
515
|
* Hands the tools an agent will call to a model that runs them itself (an installed AI client).
|
|
439
516
|
* `ignorable`: the step declared no tools and has no uploads — the run's device may answer
|
|
@@ -693,6 +770,7 @@ export async function systemOneAccess() {
|
|
|
693
770
|
authorization: `Bearer ${access.token}`,
|
|
694
771
|
// Booked under the classifier class; its evaluation model answers.
|
|
695
772
|
"ai-model-id": "wizards/classifier",
|
|
773
|
+
...DEFINITION_HEADER,
|
|
696
774
|
...(access.tenant ? { "x-wizards-tenant": access.tenant } : {}),
|
|
697
775
|
},
|
|
698
776
|
model: null,
|
|
@@ -894,7 +972,7 @@ export async function filmClient(cls) {
|
|
|
894
972
|
/** Whether any text model can answer at all: the studio says so before the first chat turn. */
|
|
895
973
|
export async function hasTextModel() {
|
|
896
974
|
try {
|
|
897
|
-
await textModel("
|
|
975
|
+
await textModel("low");
|
|
898
976
|
return true;
|
|
899
977
|
}
|
|
900
978
|
catch {
|
|
@@ -979,13 +1057,16 @@ export function waysIn(ways, lang) {
|
|
|
979
1057
|
/** What the settings page shows: the choices, which keys are there (never the keys), and the ways. */
|
|
980
1058
|
export async function modelSettings(lang = "en") {
|
|
981
1059
|
const cfg = await config();
|
|
1060
|
+
const ways = await classWays();
|
|
982
1061
|
return {
|
|
983
1062
|
source: cfg.settings.source,
|
|
984
1063
|
bindings: cfg.settings.bindings,
|
|
985
1064
|
ollamaUrl: cfg.settings.ollamaUrl ?? env.ollamaUrl,
|
|
986
1065
|
creditFallback: cfg.settings.creditFallback !== false,
|
|
987
1066
|
keys: Object.fromEntries(LOCAL_KEYS.map((k) => [k, Boolean(cfg.keys[k])])),
|
|
988
|
-
ways: waysIn(
|
|
1067
|
+
ways: waysIn(ways, lang),
|
|
1068
|
+
/** Per text class, what of its minimums its model lacks (`CLASS_NEEDS`); null: not checked. */
|
|
1069
|
+
fit: classFit(ways),
|
|
989
1070
|
/** Apple Intelligence on this Mac: shown where the machine can run it, picked once it answers. */
|
|
990
1071
|
apple: managed ? null : await appleStatus(),
|
|
991
1072
|
/** What a class costs on the credits, where they are at hand. */
|
|
@@ -1051,7 +1132,7 @@ function freeClasses(bindings) {
|
|
|
1051
1132
|
const setupOutcome = () => ({
|
|
1052
1133
|
ok: true,
|
|
1053
1134
|
message: null,
|
|
1054
|
-
text: ownRef(local, "
|
|
1135
|
+
text: ownRef(local, "low") || null,
|
|
1055
1136
|
});
|
|
1056
1137
|
/** The setup's test of one key: checked with the provider, stored, and put to use. */
|
|
1057
1138
|
export async function setUpKey(name, key, lang = "en") {
|
|
@@ -1092,7 +1173,7 @@ export async function setUpOllama(url, lang = "en") {
|
|
|
1092
1173
|
if (!models.length) {
|
|
1093
1174
|
return { ok: false, message: serverText(lang, "ollamaNoModel"), text: null };
|
|
1094
1175
|
}
|
|
1095
|
-
const bound = local.settings.bindings.
|
|
1176
|
+
const bound = local.settings.bindings.low?.replace(/^ollama:/, "");
|
|
1096
1177
|
const model = bound && models.includes(bound) ? bound : models[0];
|
|
1097
1178
|
const text = Object.fromEntries(TEXT_CLASSES.map((c) => [c, `ollama:${model}`]));
|
|
1098
1179
|
await saveLocalModels({ ollamaUrl: base, bindings: freeClasses(text) });
|
|
@@ -1123,12 +1204,55 @@ function priceOf(ref) {
|
|
|
1123
1204
|
return (catalog.get(provider === null || provider === "gateway" ? id : `${provider}/${id}`)?.pricing ??
|
|
1124
1205
|
{});
|
|
1125
1206
|
}
|
|
1207
|
+
/**
|
|
1208
|
+
* The AI Gateway's entry of the model a binding names: by the gateway's id, and a provider's own
|
|
1209
|
+
* id by the gateway's name for it (`anthropic:claude-sonnet-5-5` is `anthropic/claude-sonnet-5.5`).
|
|
1210
|
+
*/
|
|
1211
|
+
function catalogEntryOf(ref) {
|
|
1212
|
+
const { provider, id } = parse(ref);
|
|
1213
|
+
if (provider === null || provider === "gateway") {
|
|
1214
|
+
return catalog.get(id);
|
|
1215
|
+
}
|
|
1216
|
+
return (catalog.get(`${provider}/${id}`) ??
|
|
1217
|
+
catalog.get(`${provider}/${id.replace(/(\d)-(\d)/g, "$1.$2")}`));
|
|
1218
|
+
}
|
|
1126
1219
|
/** A model's context window in tokens, as the AI Gateway's catalog gives it; null where unknown. */
|
|
1127
1220
|
export function contextWindowOf(ref) {
|
|
1128
|
-
const
|
|
1129
|
-
const entry = catalog.get(provider === null || provider === "gateway" ? id : `${provider}/${id}`);
|
|
1221
|
+
const entry = catalogEntryOf(ref);
|
|
1130
1222
|
return typeof entry?.context_window === "number" ? entry.context_window : null;
|
|
1131
1223
|
}
|
|
1224
|
+
/** What a bound model can do, by the AI Gateway's catalog; null for a model it does not list. */
|
|
1225
|
+
export function modelTraitsOf(ref) {
|
|
1226
|
+
const entry = ref && !isCreditsRef(ref) ? catalogEntryOf(ref) : undefined;
|
|
1227
|
+
return entry ? traitsOf(entry.tags ?? [], entry.context_window) : null;
|
|
1228
|
+
}
|
|
1229
|
+
/**
|
|
1230
|
+
* Per text class, what of its minimums the model it runs on lacks: a key's or a local model's,
|
|
1231
|
+
* where the catalog lists it. Null where nothing is checked: an installed client, the credits
|
|
1232
|
+
* (the gateway's admin picks those models), a model the catalog does not know.
|
|
1233
|
+
*/
|
|
1234
|
+
export function classFit(ways) {
|
|
1235
|
+
return Object.fromEntries(TEXT_CLASSES.map((cls) => {
|
|
1236
|
+
const way = ways[cls];
|
|
1237
|
+
const traits = way.kind === "key" || way.kind === "local" ? modelTraitsOf(way.ref) : null;
|
|
1238
|
+
return [cls, traits ? missingNeeds(cls, traits) : null];
|
|
1239
|
+
}));
|
|
1240
|
+
}
|
|
1241
|
+
/**
|
|
1242
|
+
* The first binding of these that cannot work at all: a text class bound to a model the catalog
|
|
1243
|
+
* knows to lack what the class cannot do without (Goose and the build chat call tools).
|
|
1244
|
+
*/
|
|
1245
|
+
export function blockedBinding(bindings) {
|
|
1246
|
+
for (const cls of TEXT_CLASSES) {
|
|
1247
|
+
const ref = bindings[cls];
|
|
1248
|
+
const traits = ref ? modelTraitsOf(ref) : null;
|
|
1249
|
+
const needs = traits ? blockingNeeds(cls, missingNeeds(cls, traits)) : [];
|
|
1250
|
+
if (ref && needs.length) {
|
|
1251
|
+
return { cls, ref, needs };
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
return null;
|
|
1255
|
+
}
|
|
1132
1256
|
const n = (v, fallback) => {
|
|
1133
1257
|
const x = Number(v);
|
|
1134
1258
|
return Number.isFinite(x) ? x : fallback;
|
|
@@ -234,7 +234,7 @@ function apiFor(record) {
|
|
|
234
234
|
},
|
|
235
235
|
getTenantDb: () => db,
|
|
236
236
|
async generate(request) {
|
|
237
|
-
const resolved = await textModel(request.model ?? "
|
|
237
|
+
const resolved = await textModel(request.model ?? "low").catch((err) => {
|
|
238
238
|
// Said so a route can pass it on as it is: 503 with the code `no_model`.
|
|
239
239
|
throw err instanceof ModelUnavailableError
|
|
240
240
|
? Object.assign(err, { name: "ModelUnavailableError", status: 503, code: "no_model" })
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { localLang } from "@engenty/wizards-shared/definition";
|
|
1
|
+
import { britishEnglish, britishSpelling, localLang, } from "@engenty/wizards-shared/definition";
|
|
2
2
|
import { serverText } from "../texts.js";
|
|
3
3
|
/**
|
|
4
4
|
* The language a visitor's request asks for, as the studio starts in it (`localLang`): the
|
|
@@ -6,15 +6,24 @@ import { serverText } from "../texts.js";
|
|
|
6
6
|
* browser's `Accept-Language` names them in its order; the server has no time zone to go by.
|
|
7
7
|
*/
|
|
8
8
|
export function requestLang(c) {
|
|
9
|
-
|
|
9
|
+
return localLang(askedLanguages(c)) ?? "en";
|
|
10
|
+
}
|
|
11
|
+
/** The languages a request's `Accept-Language` names, in its order. */
|
|
12
|
+
function askedLanguages(c) {
|
|
13
|
+
return (c.req.header("accept-language") ?? "")
|
|
10
14
|
.split(",")
|
|
11
15
|
.map((part) => part.split(";")[0]?.trim() ?? "")
|
|
12
16
|
.filter(Boolean);
|
|
13
|
-
return localLang(asked) ?? "en";
|
|
14
17
|
}
|
|
15
18
|
/** A line of the server's table the person reads, in the language their request asks for. */
|
|
16
19
|
export function say(c, key, params) {
|
|
17
|
-
return serverText(requestLang(c), key, params);
|
|
20
|
+
return spelledFor(c, serverText(requestLang(c), key, params));
|
|
21
|
+
}
|
|
22
|
+
/** English text as the request's reader spells it: British where their English is en-GB. */
|
|
23
|
+
export function spelledFor(c, text) {
|
|
24
|
+
return requestLang(c) === "en" && britishEnglish(askedLanguages(c))
|
|
25
|
+
? britishSpelling(text)
|
|
26
|
+
: text;
|
|
18
27
|
}
|
|
19
28
|
/** A 404 the person may read: a sentence in their language, the machine code beside it. */
|
|
20
29
|
export function notFoundAnswer(c) {
|
|
@@ -678,7 +678,7 @@ export const runRoutes = new Hono()
|
|
|
678
678
|
.where(eq(schema.run.id, run.id));
|
|
679
679
|
return c.json({ ok: true });
|
|
680
680
|
})
|
|
681
|
-
// A json step's data, edited in the studio by someone of the
|
|
681
|
+
// A json step's data, edited in the studio by someone of the organization the run belongs to.
|
|
682
682
|
.put("/:id/outputs/:stepId", async (c) => {
|
|
683
683
|
const run = await accessibleRun(c, c.req.param("id"));
|
|
684
684
|
const user = await principalOf(c);
|