@engenty/wizards-runtime 0.9.7 → 0.10.0
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 +4 -2
- package/apps/runtime/dist/agents/company.js +1 -1
- package/apps/runtime/dist/agents/studio-assistant.js +1 -1
- package/apps/runtime/dist/app.js +18 -1
- package/apps/runtime/dist/assistant/primer.js +1 -1
- package/apps/runtime/dist/auth/index.js +10 -1
- package/apps/runtime/dist/authoring/example.js +2 -2
- package/apps/runtime/dist/authoring/guide.js +11 -11
- package/apps/runtime/dist/credits/estimate.js +5 -5
- package/apps/runtime/dist/db/adopt.js +4 -3
- package/apps/runtime/dist/db/client.js +9 -1
- 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/0022_sync.sql +247 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0021_snapshot.json +3475 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0022_snapshot.json +3792 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +14 -0
- package/apps/runtime/dist/db/schema.js +60 -0
- package/apps/runtime/dist/docs/dev/plugins/quick-start.md +2 -2
- package/apps/runtime/dist/docs/dev/plugins/server.md +2 -2
- 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/cloud-sync.md +85 -0
- package/apps/runtime/dist/docs/user-guide/data.md +4 -4
- package/apps/runtime/dist/docs/user-guide/meta.json +1 -0
- package/apps/runtime/dist/docs/user-guide/models.md +22 -13
- package/apps/runtime/dist/docs/user-guide/steps.md +6 -6
- package/apps/runtime/dist/docs/user-guide/test-and-share.md +4 -14
- 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/files/blobs.js +13 -0
- 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 +1 -1
- package/apps/runtime/dist/index.js +7 -1
- package/apps/runtime/dist/mcp/tools.js +6 -3
- package/apps/runtime/dist/models.js +64 -10
- package/apps/runtime/dist/plugins/jobs.js +7 -0
- package/apps/runtime/dist/plugins/loader.js +1 -1
- package/apps/runtime/dist/routes/api.js +107 -0
- package/apps/runtime/dist/routes/studio.js +78 -5
- package/apps/runtime/dist/services/assistant-chats.js +1 -1
- package/apps/runtime/dist/services/brand.js +1 -1
- package/apps/runtime/dist/services/cloud.js +39 -5
- package/apps/runtime/dist/services/knowledge-model.js +1 -1
- package/apps/runtime/dist/services/marketplace.js +3 -1
- package/apps/runtime/dist/services/project-files.js +1 -1
- package/apps/runtime/dist/services/projects.js +11 -0
- package/apps/runtime/dist/services/translations.js +2 -2
- package/apps/runtime/dist/services/wizards.js +2 -2
- package/apps/runtime/dist/sharing/agent.js +1 -1
- package/apps/runtime/dist/sync/apply.js +39 -0
- package/apps/runtime/dist/sync/client.js +828 -0
- package/apps/runtime/dist/sync/hub.js +324 -0
- package/apps/runtime/dist/sync/log.js +74 -0
- package/apps/runtime/dist/sync/records.js +943 -0
- package/apps/runtime/dist/sync/state.js +17 -0
- package/apps/runtime/dist/texts.js +12 -0
- package/apps/web/dist/assets/{AboutDialog-B3tljxg5.js → AboutDialog-D1YHT0jc.js} +1 -1
- package/apps/web/dist/assets/{ChangelogDialog-DfWTNzyl.js → ChangelogDialog-Bv02g8av.js} +1 -1
- package/apps/web/dist/assets/{EditorPage-XDdz2UM4.js → EditorPage-BThoZwqO.js} +4 -4
- package/apps/web/dist/assets/{FlowPreview-CKNVCFbp.js → FlowPreview-dc5C92kK.js} +1 -1
- package/apps/web/dist/assets/{Harness-BCec49Cq.js → Harness-D0nFOIVx.js} +1 -1
- package/apps/web/dist/assets/{Marketplace-BuYeaxK2.js → Marketplace-Cnd8BF3q.js} +2 -2
- package/apps/web/dist/assets/{NewWizardChannels-DRNji-bk.js → NewWizardChannels-i62Y_2DZ.js} +1 -1
- package/apps/web/dist/assets/{NewWizardPage-4TpgYOaI.js → NewWizardPage-BcpRA1fx.js} +1 -1
- package/apps/web/dist/assets/{OnboardingPage-Cf52NOIt.js → OnboardingPage-BcMDEXNq.js} +1 -1
- package/apps/web/dist/assets/PreviewPane-GHcVV2Hu.js +4 -0
- package/apps/web/dist/assets/{ProjectPage-D6Tah3QK.js → ProjectPage-TDywzUOd.js} +1 -1
- package/apps/web/dist/assets/{PublicRunner-Bftc1c4m.js → PublicRunner-B6JINLpR.js} +1 -1
- package/apps/web/dist/assets/{ReadOnly-DVQm9IYx.js → ReadOnly-Mv5M2OV9.js} +1 -1
- package/apps/web/dist/assets/SettingsPage-B-F1dLgt.js +2 -0
- package/apps/web/dist/assets/SetupPage-CVdsdVBW.js +1 -0
- package/apps/web/dist/assets/{SharePage-Cn-bqSyr.js → SharePage-CBSRK0wF.js} +1 -1
- package/apps/web/dist/assets/changelog-BR1lxaWv.js +1 -0
- package/apps/web/dist/assets/{coins-DgDTBbeg.js → coins-BGZKYmu6.js} +1 -1
- package/apps/web/dist/assets/index-D3-kv1WF.js +14 -0
- package/apps/web/dist/assets/index-DcUL6teA.css +1 -0
- package/apps/web/dist/assets/{phone-D1Drdiio.js → phone-BzHhwehj.js} +1 -1
- package/apps/web/dist/assets/{runners-CTd0YAiA.js → runners-C1-zIlry.js} +1 -1
- package/apps/web/dist/assets/{session-DX2BcTfz.js → session-B_JeZnJ0.js} +1 -1
- package/apps/web/dist/assets/{settings-menu-ay9jNbQu.js → settings-menu-BZRGhsIO.js} +1 -1
- package/apps/web/dist/assets/theme-HcCfZDzS.js +11 -0
- package/apps/web/dist/assets/{ui-CJCF3Mhe.js → ui-BI1RPFWT.js} +26 -26
- package/apps/web/dist/assets/{upload-Dj7KPL--.js → upload-CwT8oMz0.js} +1 -1
- package/apps/web/dist/assets/{useMutation-CUSQpD-i.js → useMutation-byk81dDj.js} +1 -1
- package/apps/web/dist/assets/{volume-2-CcHZOU2m.js → volume-2-B1Pz6Iwt.js} +1 -1
- package/apps/web/dist/assets/{wrench-CfJTFnMJ.js → wrench-CvzXRbWN.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-shared/dist/definition.d.ts +872 -18
- package/node_modules/@engenty/wizards-shared/dist/definition.js +52 -11
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +6 -0
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +6 -0
- package/node_modules/@engenty/wizards-shared/dist/json-schema.js +3 -3
- package/node_modules/@engenty/wizards-shared/dist/providers.d.ts +37 -0
- package/node_modules/@engenty/wizards-shared/dist/providers.js +64 -12
- package/node_modules/@engenty/wizards-shared/dist/run.d.ts +6 -0
- package/node_modules/@engenty/wizards-shared/dist/run.js +12 -0
- package/node_modules/@engenty/wizards-shared/dist/sync-merge.d.ts +55 -0
- package/node_modules/@engenty/wizards-shared/dist/sync-merge.js +214 -0
- package/node_modules/@engenty/wizards-shared/dist/sync.d.ts +166 -0
- package/node_modules/@engenty/wizards-shared/dist/sync.js +40 -0
- package/node_modules/@engenty/wizards-shared/dist/text-merge.d.ts +14 -0
- package/node_modules/@engenty/wizards-shared/dist/text-merge.js +137 -0
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/plugin.json +1 -1
- package/apps/web/dist/assets/PreviewPane-C4yMcZPM.js +0 -4
- package/apps/web/dist/assets/SettingsPage-Cd-osLDu.js +0 -2
- package/apps/web/dist/assets/SetupPage-Dc8U5k5P.js +0 -1
- package/apps/web/dist/assets/changelog-CjSBB-a4.js +0 -1
- package/apps/web/dist/assets/index-DS3zUVw_.css +0 -1
- package/apps/web/dist/assets/index-Da7hPToW.js +0 -14
- package/apps/web/dist/assets/theme-DanjuO1H.js +0 -11
|
@@ -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");
|
|
@@ -18,6 +18,7 @@ import { clearRunning, writeRunning } from "./running.js";
|
|
|
18
18
|
import { syncMarketplace } from "./services/marketplace.js";
|
|
19
19
|
import { purgeExpiredRuns } from "./services/shares.js";
|
|
20
20
|
import { purgeUnusedStores } from "./store/index.js";
|
|
21
|
+
import { compactLog } from "./sync/log.js";
|
|
21
22
|
import { forgetRunner, registerRunner } from "./tenants/control.js";
|
|
22
23
|
import { LOCAL_TENANT } from "./tenants/tenant.js";
|
|
23
24
|
import { onRestart, RESTART_EXIT, startUpdateChecks } from "./update.js";
|
|
@@ -93,7 +94,7 @@ if (env.serves.runner) {
|
|
|
93
94
|
async function purge() {
|
|
94
95
|
await purgeSessions();
|
|
95
96
|
for (const id of await knownTenants()) {
|
|
96
|
-
await withTenant(id, () => Promise.all([purgeExpiredRuns(), purgeUnusedStores()])).catch((err) => console.error(`[retention ${id}]`, err));
|
|
97
|
+
await withTenant(id, () => Promise.all([purgeExpiredRuns(), purgeUnusedStores(), compactLog()])).catch((err) => console.error(`[retention ${id}]`, err));
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
void purge().catch((err) => console.error("[retention]", err));
|
|
@@ -103,6 +104,11 @@ if (!managed) {
|
|
|
103
104
|
const { retryFailedSends } = await import("./services/cloud.js");
|
|
104
105
|
const retry = () => withTenant(LOCAL_TENANT, () => retryFailedSends("local")).catch((err) => console.error("[cloud] retry failed:", err));
|
|
105
106
|
setInterval(() => void retry(), 60_000).unref();
|
|
107
|
+
// The two-way sync of the spaces with the account's organization (sync/client.ts).
|
|
108
|
+
const { syncAll } = await import("./sync/client.js");
|
|
109
|
+
const twoWay = () => withTenant(LOCAL_TENANT, () => syncAll()).catch((err) => console.error("[sync]", err));
|
|
110
|
+
setTimeout(() => void twoWay(), 5_000).unref();
|
|
111
|
+
setInterval(() => void twoWay(), 60_000).unref();
|
|
106
112
|
}
|
|
107
113
|
async function shutdown(code = 0) {
|
|
108
114
|
clearRunning(env.dataDir);
|
|
@@ -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";
|
|
@@ -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),
|
|
@@ -763,6 +770,7 @@ export async function systemOneAccess() {
|
|
|
763
770
|
authorization: `Bearer ${access.token}`,
|
|
764
771
|
// Booked under the classifier class; its evaluation model answers.
|
|
765
772
|
"ai-model-id": "wizards/classifier",
|
|
773
|
+
...DEFINITION_HEADER,
|
|
766
774
|
...(access.tenant ? { "x-wizards-tenant": access.tenant } : {}),
|
|
767
775
|
},
|
|
768
776
|
model: null,
|
|
@@ -964,7 +972,7 @@ export async function filmClient(cls) {
|
|
|
964
972
|
/** Whether any text model can answer at all: the studio says so before the first chat turn. */
|
|
965
973
|
export async function hasTextModel() {
|
|
966
974
|
try {
|
|
967
|
-
await textModel("
|
|
975
|
+
await textModel("low");
|
|
968
976
|
return true;
|
|
969
977
|
}
|
|
970
978
|
catch {
|
|
@@ -1049,13 +1057,16 @@ export function waysIn(ways, lang) {
|
|
|
1049
1057
|
/** What the settings page shows: the choices, which keys are there (never the keys), and the ways. */
|
|
1050
1058
|
export async function modelSettings(lang = "en") {
|
|
1051
1059
|
const cfg = await config();
|
|
1060
|
+
const ways = await classWays();
|
|
1052
1061
|
return {
|
|
1053
1062
|
source: cfg.settings.source,
|
|
1054
1063
|
bindings: cfg.settings.bindings,
|
|
1055
1064
|
ollamaUrl: cfg.settings.ollamaUrl ?? env.ollamaUrl,
|
|
1056
1065
|
creditFallback: cfg.settings.creditFallback !== false,
|
|
1057
1066
|
keys: Object.fromEntries(LOCAL_KEYS.map((k) => [k, Boolean(cfg.keys[k])])),
|
|
1058
|
-
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),
|
|
1059
1070
|
/** Apple Intelligence on this Mac: shown where the machine can run it, picked once it answers. */
|
|
1060
1071
|
apple: managed ? null : await appleStatus(),
|
|
1061
1072
|
/** What a class costs on the credits, where they are at hand. */
|
|
@@ -1121,7 +1132,7 @@ function freeClasses(bindings) {
|
|
|
1121
1132
|
const setupOutcome = () => ({
|
|
1122
1133
|
ok: true,
|
|
1123
1134
|
message: null,
|
|
1124
|
-
text: ownRef(local, "
|
|
1135
|
+
text: ownRef(local, "low") || null,
|
|
1125
1136
|
});
|
|
1126
1137
|
/** The setup's test of one key: checked with the provider, stored, and put to use. */
|
|
1127
1138
|
export async function setUpKey(name, key, lang = "en") {
|
|
@@ -1162,7 +1173,7 @@ export async function setUpOllama(url, lang = "en") {
|
|
|
1162
1173
|
if (!models.length) {
|
|
1163
1174
|
return { ok: false, message: serverText(lang, "ollamaNoModel"), text: null };
|
|
1164
1175
|
}
|
|
1165
|
-
const bound = local.settings.bindings.
|
|
1176
|
+
const bound = local.settings.bindings.low?.replace(/^ollama:/, "");
|
|
1166
1177
|
const model = bound && models.includes(bound) ? bound : models[0];
|
|
1167
1178
|
const text = Object.fromEntries(TEXT_CLASSES.map((c) => [c, `ollama:${model}`]));
|
|
1168
1179
|
await saveLocalModels({ ollamaUrl: base, bindings: freeClasses(text) });
|
|
@@ -1193,12 +1204,55 @@ function priceOf(ref) {
|
|
|
1193
1204
|
return (catalog.get(provider === null || provider === "gateway" ? id : `${provider}/${id}`)?.pricing ??
|
|
1194
1205
|
{});
|
|
1195
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
|
+
}
|
|
1196
1219
|
/** A model's context window in tokens, as the AI Gateway's catalog gives it; null where unknown. */
|
|
1197
1220
|
export function contextWindowOf(ref) {
|
|
1198
|
-
const
|
|
1199
|
-
const entry = catalog.get(provider === null || provider === "gateway" ? id : `${provider}/${id}`);
|
|
1221
|
+
const entry = catalogEntryOf(ref);
|
|
1200
1222
|
return typeof entry?.context_window === "number" ? entry.context_window : null;
|
|
1201
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
|
+
}
|
|
1202
1256
|
const n = (v, fallback) => {
|
|
1203
1257
|
const x = Number(v);
|
|
1204
1258
|
return Number.isFinite(x) ? x : fallback;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { and, eq } from "drizzle-orm";
|
|
2
2
|
import { control, controlDb, withTenant } from "../db/client.js";
|
|
3
3
|
import { env } from "../env.js";
|
|
4
|
+
import { twoWayActive } from "../sync/state.js";
|
|
5
|
+
import { LOCAL_TENANT } from "../tenants/tenant.js";
|
|
4
6
|
import { loadedPlugins, pluginIdsOf } from "./registry.js";
|
|
5
7
|
/**
|
|
6
8
|
* Plugins' jobs (`server.every`). A tick looks once a minute which job is due for which tenant
|
|
@@ -21,6 +23,11 @@ export async function runDueJobs(now = new Date()) {
|
|
|
21
23
|
});
|
|
22
24
|
const started = [];
|
|
23
25
|
for (const tenant of tenants) {
|
|
26
|
+
// An install whose spaces sync both ways leaves the jobs to the cloud: both would write the
|
|
27
|
+
// same items of the same spaces (docs/plans/tenant-sync.md).
|
|
28
|
+
if (twoWayActive() && tenant.id === LOCAL_TENANT) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
24
31
|
const has = await pluginIdsOf(tenant.id);
|
|
25
32
|
for (const { plugin, name, job } of jobs) {
|
|
26
33
|
const id = plugin.source.id;
|
|
@@ -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,5 @@
|
|
|
1
1
|
import { note } from "@engenty/wizards-shared/run";
|
|
2
|
+
import { blobHash, missingBlobsSchema, pushSchema } from "@engenty/wizards-shared/sync";
|
|
2
3
|
import { PACKAGE_MIME } from "@engenty/wizards-shared/wizard-package";
|
|
3
4
|
import { Hono } from "hono";
|
|
4
5
|
import { bodyLimit } from "hono/body-limit";
|
|
@@ -19,6 +20,7 @@ import { exportWizard } from "../services/package.js";
|
|
|
19
20
|
import { siteJob, siteSchema, startSiteJob } from "../services/site.js";
|
|
20
21
|
import { checkOnServer, checkSchema, listSyncedSpaces, patchSyncedWizard, removeSyncedSpace, removeSyncedWizard, rotateSyncedLink, syncDataSchema, syncSettingsSchema, syncSpaceData, syncWizard, syncWizardSchema, } from "../services/spaces.js";
|
|
21
22
|
import { createWizard, ownedWizard, publishWizard, writeDraft } from "../services/wizards.js";
|
|
23
|
+
import { adoptSpace, blobBytes, missingBlobs, publishSynced, pullChanges, pushChanges, rotateSynced, syncOverview, takeBlob, } from "../sync/hub.js";
|
|
22
24
|
import { codeOf, tenantStatus } from "../tenants/control.js";
|
|
23
25
|
import { notFoundAnswer, say } from "./lang.js";
|
|
24
26
|
import { dispatchAs } from "./plugins.js";
|
|
@@ -67,6 +69,21 @@ async function caller(c, scopes) {
|
|
|
67
69
|
}
|
|
68
70
|
return who;
|
|
69
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* The two-way sync follows the studio's saves: an install pushes a space at most every few
|
|
74
|
+
* seconds while someone edits, and pulls when a page opens.
|
|
75
|
+
*/
|
|
76
|
+
const TWO_WAY_LIMITS = { push: 1200, pull: 3600 };
|
|
77
|
+
function withinTwoWayLimit(c, who, what) {
|
|
78
|
+
return allowed(`two-way-${what}:${who.tenantId}`, TWO_WAY_LIMITS[what], HOUR)
|
|
79
|
+
? null
|
|
80
|
+
: c.json({ error: say(c, "tooManyTransfersTry"), code: "rate_limited" }, 429);
|
|
81
|
+
}
|
|
82
|
+
/** What one push carries: records, without the files' bytes (they go one by one). */
|
|
83
|
+
const twoWayBody = bodyLimit({
|
|
84
|
+
maxSize: 16 * 1024 * 1024,
|
|
85
|
+
onError: (c) => c.json({ error: "The request is too large.", code: "too_large" }, 413),
|
|
86
|
+
});
|
|
70
87
|
/** A local install sends when it publishes: more than this an hour is not an install at work. */
|
|
71
88
|
function withinSyncLimit(c, who) {
|
|
72
89
|
return allowed(`sync:${who.tenantId}`, 240, HOUR)
|
|
@@ -382,6 +399,96 @@ export const apiRoutes = new Hono()
|
|
|
382
399
|
return who;
|
|
383
400
|
}
|
|
384
401
|
return inTenantAs(who, async () => c.json(await removeSyncedSpace(c.req.param("spaceId"))));
|
|
402
|
+
})
|
|
403
|
+
// --- the two-way sync of a space (docs/manage-contract.md, "Two-way sync of a space") ---
|
|
404
|
+
.get("/sync", async (c) => {
|
|
405
|
+
const who = await caller(c, ["wizards:read"]);
|
|
406
|
+
if (who instanceof Response) {
|
|
407
|
+
return who;
|
|
408
|
+
}
|
|
409
|
+
return inTenantAs(who, async () => c.json(await syncOverview()));
|
|
410
|
+
})
|
|
411
|
+
.get("/sync/spaces/:spaceId/changes", async (c) => {
|
|
412
|
+
const who = await caller(c, ["wizards:read"]);
|
|
413
|
+
if (who instanceof Response) {
|
|
414
|
+
return who;
|
|
415
|
+
}
|
|
416
|
+
const limited = withinTwoWayLimit(c, who, "pull");
|
|
417
|
+
if (limited) {
|
|
418
|
+
return limited;
|
|
419
|
+
}
|
|
420
|
+
const since = Math.max(0, Number.parseInt(c.req.query("since") ?? "0", 10) || 0);
|
|
421
|
+
const cursor = c.req.query("cursor") || undefined;
|
|
422
|
+
return inTenantAs(who, async () => c.json(await pullChanges(c.req.param("spaceId"), since, cursor)));
|
|
423
|
+
})
|
|
424
|
+
.post("/sync/spaces/:spaceId/changes", twoWayBody, async (c) => {
|
|
425
|
+
const who = await caller(c, ["wizards:write"]);
|
|
426
|
+
if (who instanceof Response) {
|
|
427
|
+
return who;
|
|
428
|
+
}
|
|
429
|
+
const limited = withinTwoWayLimit(c, who, "push");
|
|
430
|
+
if (limited) {
|
|
431
|
+
return limited;
|
|
432
|
+
}
|
|
433
|
+
const body = pushSchema.parse(await c.req.json());
|
|
434
|
+
return inTenantAs(who, async () => c.json(await pushChanges(c.req.param("spaceId"), body)));
|
|
435
|
+
})
|
|
436
|
+
.post("/sync/spaces/:spaceId/blobs/missing", async (c) => {
|
|
437
|
+
const who = await caller(c, ["wizards:write"]);
|
|
438
|
+
if (who instanceof Response) {
|
|
439
|
+
return who;
|
|
440
|
+
}
|
|
441
|
+
const body = missingBlobsSchema.parse(await c.req.json());
|
|
442
|
+
return inTenantAs(who, async () => c.json({ missing: await missingBlobs(body.hashes) }));
|
|
443
|
+
})
|
|
444
|
+
.put("/sync/spaces/:spaceId/blobs/:hash", tooLarge, async (c) => {
|
|
445
|
+
const who = await caller(c, ["wizards:write"]);
|
|
446
|
+
if (who instanceof Response) {
|
|
447
|
+
return who;
|
|
448
|
+
}
|
|
449
|
+
const hash = blobHash.parse(c.req.param("hash"));
|
|
450
|
+
const data = new Uint8Array(await c.req.arrayBuffer());
|
|
451
|
+
return inTenantAs(who, async () => {
|
|
452
|
+
await takeBlob(hash, data).catch(() => {
|
|
453
|
+
throw new ServiceError("invalid", "The bytes do not match their hash.");
|
|
454
|
+
});
|
|
455
|
+
return c.json({ ok: true });
|
|
456
|
+
});
|
|
457
|
+
})
|
|
458
|
+
.get("/sync/spaces/:spaceId/blobs/:hash", async (c) => {
|
|
459
|
+
const who = await caller(c, ["wizards:read"]);
|
|
460
|
+
if (who instanceof Response) {
|
|
461
|
+
return who;
|
|
462
|
+
}
|
|
463
|
+
const hash = blobHash.parse(c.req.param("hash"));
|
|
464
|
+
return inTenantAs(who, async () => {
|
|
465
|
+
const data = await blobBytes(hash).catch(() => null);
|
|
466
|
+
if (!data) {
|
|
467
|
+
return c.json({ error: "There are no such bytes here.", code: "not_found" }, 404);
|
|
468
|
+
}
|
|
469
|
+
return c.body(new Uint8Array(data), 200, { "content-type": "application/octet-stream" });
|
|
470
|
+
});
|
|
471
|
+
})
|
|
472
|
+
.post("/sync/spaces/:spaceId/wizards/:wizardId/publish", async (c) => {
|
|
473
|
+
const who = await caller(c, ["wizards:write", "wizards:publish"]);
|
|
474
|
+
if (who instanceof Response) {
|
|
475
|
+
return who;
|
|
476
|
+
}
|
|
477
|
+
return inTenantAs(who, async () => c.json(await publishSynced(who.userId, c.req.param("spaceId"), c.req.param("wizardId"))));
|
|
478
|
+
})
|
|
479
|
+
.post("/sync/spaces/:spaceId/wizards/:wizardId/rotate-link", async (c) => {
|
|
480
|
+
const who = await caller(c, ["wizards:publish"]);
|
|
481
|
+
if (who instanceof Response) {
|
|
482
|
+
return who;
|
|
483
|
+
}
|
|
484
|
+
return inTenantAs(who, async () => c.json(await rotateSynced(who.userId, c.req.param("spaceId"), c.req.param("wizardId"))));
|
|
485
|
+
})
|
|
486
|
+
.post("/sync/spaces/:spaceId/adopt", async (c) => {
|
|
487
|
+
const who = await caller(c, ["wizards:write"]);
|
|
488
|
+
if (who instanceof Response) {
|
|
489
|
+
return who;
|
|
490
|
+
}
|
|
491
|
+
return inTenantAs(who, async () => c.json(await adoptSpace(c.req.param("spaceId"))));
|
|
385
492
|
})
|
|
386
493
|
.post("/wizards/import", tooLarge, async (c) => {
|
|
387
494
|
const authInfo = await authenticate(c.req.raw);
|
|
@@ -4,7 +4,7 @@ import { ASSISTANT_LAYOUTS, ASSISTANT_PAGE_BYTES, ASSISTANT_WIDTH, assistantSign
|
|
|
4
4
|
import { LANGS, MODEL_CLASSES, TEXT_CLASSES, wizardLang, } from "@engenty/wizards-shared/definition";
|
|
5
5
|
import { CATEGORY_TYPES, whereSchema } from "@engenty/wizards-shared/knowledge";
|
|
6
6
|
import { PROJECT_FILE_KINDS } from "@engenty/wizards-shared/projects";
|
|
7
|
-
import { isCreditsRef } from "@engenty/wizards-shared/providers";
|
|
7
|
+
import { CLASS_NAMES, isCreditsRef, modelLabel } from "@engenty/wizards-shared/providers";
|
|
8
8
|
import { note } from "@engenty/wizards-shared/run";
|
|
9
9
|
import { wizardTexts } from "@engenty/wizards-shared/translation";
|
|
10
10
|
import { PACKAGE_EXTENSION, PACKAGE_MAX_BYTES, PACKAGE_MIME, } from "@engenty/wizards-shared/wizard-package";
|
|
@@ -37,7 +37,7 @@ import { seenApps } from "../mcp/seen.js";
|
|
|
37
37
|
import { generateImageMedia, generateSpeechMedia, generateVideoMedia } from "../media/generate.js";
|
|
38
38
|
import { transcribeAudio } from "../media/transcribe.js";
|
|
39
39
|
import { errorText, saidOf } from "../model-errors.js";
|
|
40
|
-
import { CHAT_WAYS, checkKey, classProblem, classWays, embeddingModel, hasTextModel, LOCAL_KEYS, localModelSettings, ModelUnavailableError, modelSettings, saveLocalModels, saveModels, setUpKey, setUpOllama, storedKey, textModel, } from "../models.js";
|
|
40
|
+
import { blockedBinding, CHAT_WAYS, checkKey, classProblem, classWays, embeddingModel, hasTextModel, LOCAL_KEYS, localModelSettings, ModelUnavailableError, modelSettings, saveLocalModels, saveModels, setUpKey, setUpOllama, storedKey, textModel, } from "../models.js";
|
|
41
41
|
import { refreshPro } from "../plugins/pro.js";
|
|
42
42
|
import { HTML_RESPONSE_CSP } from "../render/guard.js";
|
|
43
43
|
import { isAdminRole, mayBuild, mayCreate, projectWritable, requireAdmin, requireWritable, } from "../services/access.js";
|
|
@@ -66,6 +66,7 @@ import { draftWidgetPreview } from "../services/widgets.js";
|
|
|
66
66
|
import { createWizard, deleteWizard, draftChanges, duplicateWizard, listWizards, ownedWizard, rotateShareLink, updateWizardSettings, wizardMessages, wizardState, writableWizard, writeDraft, } from "../services/wizards.js";
|
|
67
67
|
import { deleteSetting, readSetting, writeSetting } from "../settings.js";
|
|
68
68
|
import { projectShareTargets, sharePreview } from "../sharing/index.js";
|
|
69
|
+
import { keepCloudForAll, mergesSeen, proposeMerge, resolveConflict, startSpace, stopSpace, syncAll, syncView, undoMerge, } from "../sync/client.js";
|
|
69
70
|
import { codeOf } from "../tenants/control.js";
|
|
70
71
|
import { currentTenant } from "../tenants/tenant.js";
|
|
71
72
|
import { serverText } from "../texts.js";
|
|
@@ -85,15 +86,15 @@ async function markTested(source) {
|
|
|
85
86
|
}
|
|
86
87
|
/**
|
|
87
88
|
* The chosen source has passed a test call and can still answer: its client is there and signed
|
|
88
|
-
* in. Where Apple Intelligence thinks the short classes, the test ran there; a client behind
|
|
89
|
-
* and
|
|
89
|
+
* in. Where Apple Intelligence thinks the short classes, the test ran there; a client behind
|
|
90
|
+
* Standard and High is no condition then.
|
|
90
91
|
*/
|
|
91
92
|
async function setupDone() {
|
|
92
93
|
const { source, bindings } = localModelSettings();
|
|
93
94
|
if (!(await testedSources()).includes(source)) {
|
|
94
95
|
return false;
|
|
95
96
|
}
|
|
96
|
-
const client = bindings.
|
|
97
|
+
const client = bindings.low.startsWith("apple:") ? null : harness(source);
|
|
97
98
|
if (client) {
|
|
98
99
|
const status = await detectHarness(client.id);
|
|
99
100
|
return Boolean(status?.version) && status?.auth !== "none";
|
|
@@ -216,6 +217,18 @@ const terminalSize = z.object({
|
|
|
216
217
|
cols: z.number().int().min(10).max(500).optional(),
|
|
217
218
|
rows: z.number().int().min(4).max(200).optional(),
|
|
218
219
|
});
|
|
220
|
+
/** How the person settled a conflict: one side, a choice per place, or a version of their own. */
|
|
221
|
+
const resolutionSchema = z.union([
|
|
222
|
+
z.object({ take: z.enum(["local", "remote"]) }),
|
|
223
|
+
z.object({
|
|
224
|
+
choices: z.array(z.union([
|
|
225
|
+
z.object({ take: z.enum(["local", "remote"]) }),
|
|
226
|
+
z.object({ value: z.unknown() }),
|
|
227
|
+
z.null(),
|
|
228
|
+
])),
|
|
229
|
+
}),
|
|
230
|
+
z.object({ record: z.record(z.string(), z.unknown()) }),
|
|
231
|
+
]);
|
|
219
232
|
export const studio = new Hono()
|
|
220
233
|
.get("/me", async (c) => {
|
|
221
234
|
const user = c.get("user");
|
|
@@ -1195,6 +1208,55 @@ export const studio = new Hono()
|
|
|
1195
1208
|
return c.notFound();
|
|
1196
1209
|
}
|
|
1197
1210
|
return c.json(await checkForCloud(c.get("user").id, c.req.param("id")));
|
|
1211
|
+
})
|
|
1212
|
+
// --- the two-way sync of the spaces with the account's organization (sync/client.ts) ---
|
|
1213
|
+
.get("/sync", async (c) => (managed ? c.notFound() : c.json(await syncView())))
|
|
1214
|
+
.post("/sync/now", async (c) => {
|
|
1215
|
+
if (managed) {
|
|
1216
|
+
return c.notFound();
|
|
1217
|
+
}
|
|
1218
|
+
await syncAll();
|
|
1219
|
+
return c.json(await syncView());
|
|
1220
|
+
})
|
|
1221
|
+
.put("/sync/spaces/:id", async (c) => {
|
|
1222
|
+
if (managed) {
|
|
1223
|
+
return c.notFound();
|
|
1224
|
+
}
|
|
1225
|
+
const { on } = z.object({ on: z.boolean() }).parse(await c.req.json());
|
|
1226
|
+
await (on ? startSpace(c.req.param("id")) : stopSpace(c.req.param("id")));
|
|
1227
|
+
return c.json(await syncView());
|
|
1228
|
+
})
|
|
1229
|
+
.post("/sync/spaces/:id/keep-cloud", async (c) => {
|
|
1230
|
+
if (managed) {
|
|
1231
|
+
return c.notFound();
|
|
1232
|
+
}
|
|
1233
|
+
await keepCloudForAll(c.req.param("id"));
|
|
1234
|
+
return c.json(await syncView());
|
|
1235
|
+
})
|
|
1236
|
+
.post("/sync/conflicts/:id/resolve", async (c) => {
|
|
1237
|
+
if (managed) {
|
|
1238
|
+
return c.notFound();
|
|
1239
|
+
}
|
|
1240
|
+
const body = resolutionSchema.parse(await c.req.json());
|
|
1241
|
+
await resolveConflict(c.req.param("id"), body);
|
|
1242
|
+
return c.json(await syncView());
|
|
1243
|
+
})
|
|
1244
|
+
.post("/sync/conflicts/:id/propose", async (c) => managed ? c.notFound() : c.json(await proposeMerge(c.req.param("id"))))
|
|
1245
|
+
.post("/sync/merges/:id/undo", async (c) => {
|
|
1246
|
+
if (managed) {
|
|
1247
|
+
return c.notFound();
|
|
1248
|
+
}
|
|
1249
|
+
const { take } = z.object({ take: z.enum(["local", "remote"]) }).parse(await c.req.json());
|
|
1250
|
+
await undoMerge(c.req.param("id"), take);
|
|
1251
|
+
return c.json(await syncView());
|
|
1252
|
+
})
|
|
1253
|
+
.post("/sync/merges/seen", async (c) => {
|
|
1254
|
+
if (managed) {
|
|
1255
|
+
return c.notFound();
|
|
1256
|
+
}
|
|
1257
|
+
const { ids } = z.object({ ids: z.array(z.string()).max(200) }).parse(await c.req.json());
|
|
1258
|
+
await mergesSeen(ids);
|
|
1259
|
+
return c.json({ ok: true });
|
|
1198
1260
|
})
|
|
1199
1261
|
// The projects of local installs the account's cloud holds.
|
|
1200
1262
|
.get("/cloud/spaces", async (c) => {
|
|
@@ -1399,6 +1461,17 @@ export const studio = new Hono()
|
|
|
1399
1461
|
}, 403);
|
|
1400
1462
|
}
|
|
1401
1463
|
}
|
|
1464
|
+
const blocked = input.bindings ? blockedBinding(input.bindings) : null;
|
|
1465
|
+
if (blocked) {
|
|
1466
|
+
return c.json({
|
|
1467
|
+
error: say(c, "modelLacksForClass", {
|
|
1468
|
+
model: modelLabel(blocked.ref),
|
|
1469
|
+
cls: CLASS_NAMES[blocked.cls],
|
|
1470
|
+
needs: blocked.needs.map((n) => say(c, `need.${n}`)).join(", "),
|
|
1471
|
+
}),
|
|
1472
|
+
code: "model_lacks",
|
|
1473
|
+
}, 400);
|
|
1474
|
+
}
|
|
1402
1475
|
await saveModels(input);
|
|
1403
1476
|
return c.json(await modelSettings(requestLang(c)));
|
|
1404
1477
|
})
|
|
@@ -122,7 +122,7 @@ const SUMMARY_RULES = [
|
|
|
122
122
|
async function summarise(messages, before) {
|
|
123
123
|
const firstAsk = messages.find((m) => m.role === "user")?.content ?? "";
|
|
124
124
|
try {
|
|
125
|
-
const model = await textModel("
|
|
125
|
+
const model = await textModel("low");
|
|
126
126
|
const result = await generateText({
|
|
127
127
|
model: model.model,
|
|
128
128
|
maxOutputTokens: 900,
|
|
@@ -68,7 +68,7 @@ const gradientAnswer = z.object({
|
|
|
68
68
|
* angle and colour stops, in the brand's colours where the words name them.
|
|
69
69
|
*/
|
|
70
70
|
export async function describeGradient(brand, text, current) {
|
|
71
|
-
const model = await textModel("
|
|
71
|
+
const model = await textModel("low");
|
|
72
72
|
const result = await generateText({
|
|
73
73
|
model: model.model,
|
|
74
74
|
maxOutputTokens: 800,
|