@engenty/wizards-runtime 0.16.1 → 0.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/runtime/dist/assistant/knows.js +3 -1
- package/apps/runtime/dist/db/control-schema.js +7 -0
- package/apps/runtime/dist/db/migrations/control/0014_run_index_generation.sql +1 -0
- package/apps/runtime/dist/db/migrations/control/0015_run_index_wake.sql +3 -0
- package/apps/runtime/dist/db/migrations/control/meta/0014_snapshot.json +629 -0
- package/apps/runtime/dist/db/migrations/control/meta/0015_snapshot.json +650 -0
- package/apps/runtime/dist/db/migrations/control/meta/_journal.json +14 -0
- package/apps/runtime/dist/db/migrations/tenant/0056_run_claim_rev.sql +2 -0
- package/apps/runtime/dist/db/migrations/tenant/0057_run_wake_at.sql +1 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0056_snapshot.json +6520 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0057_snapshot.json +6527 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +14 -0
- package/apps/runtime/dist/db/schema.js +17 -3
- package/apps/runtime/dist/elements/knowledge.js +1 -0
- package/apps/runtime/dist/engine/runner.js +344 -52
- package/apps/runtime/dist/env.js +18 -0
- package/apps/runtime/dist/mounts/mounts.js +3 -0
- package/apps/runtime/dist/plugins/runs.js +3 -0
- package/apps/runtime/dist/prompts/mcp.md +3 -0
- package/apps/runtime/dist/routes/runs.js +17 -14
- package/apps/runtime/dist/services/api.js +1 -1
- package/apps/runtime/dist/services/knowledge.js +2 -1
- package/apps/runtime/dist/services/manage-reports.js +2 -0
- package/apps/runtime/dist/services/query-vectors.js +60 -0
- package/apps/runtime/dist/services/relevance.js +12 -0
- package/apps/runtime/dist/services/runs.js +16 -2
- package/apps/runtime/dist/services/space-index.js +22 -6
- package/apps/runtime/dist/sharing/index.js +3 -0
- package/apps/runtime/dist/tenants/control.js +46 -14
- package/apps/web/dist/assets/{AboutDialog-C9SnsGno.js → AboutDialog-BCcD8hKm.js} +1 -1
- package/apps/web/dist/assets/{BlockEditor-CUYFH_CU.js → BlockEditor-DgaUm2pR.js} +1 -1
- package/apps/web/dist/assets/CapabilitiesPage-DuJJV1ll.js +2 -0
- package/apps/web/dist/assets/{ChangelogDialog-B28TK333.js → ChangelogDialog-B08elwyr.js} +1 -1
- package/apps/web/dist/assets/{CodeEditor-D-Y16fdk.js → CodeEditor-BiyOk_SC.js} +1 -1
- package/apps/web/dist/assets/EditorPage-EMFTHEYD.js +3 -0
- package/apps/web/dist/assets/{FlowPreview-DXnk7m9P.js → FlowPreview-DF_6TvZ0.js} +1 -1
- package/apps/web/dist/assets/{LangSwitch-Dkd0FBIH.js → LangSwitch-Ba4OWLzJ.js} +1 -1
- package/apps/web/dist/assets/Marketplace-DqziLf66.js +2 -0
- package/apps/web/dist/assets/{NewWizardChannels-B12l2_Jh.js → NewWizardChannels-CsIGp0nZ.js} +1 -1
- package/apps/web/dist/assets/NewWizardPage-CzQAkKMy.js +7 -0
- package/apps/web/dist/assets/OnboardingPage-B9gr2OX5.js +1 -0
- package/apps/web/dist/assets/PreviewPane-DSOV3o-1.js +7 -0
- package/apps/web/dist/assets/PublicRunner-BVs8-Vu3.js +1 -0
- package/apps/web/dist/assets/{ReadOnly-DwewuYi8.js → ReadOnly--4CIJCDD.js} +1 -1
- package/apps/web/dist/assets/SettingsPage-z2u8lSe2.js +2 -0
- package/apps/web/dist/assets/SetupPage-9Zk-KUGA.js +1 -0
- package/apps/web/dist/assets/{SharePage-CZClatA_.js → SharePage-D_Ab0gjr.js} +1 -1
- package/apps/web/dist/assets/SkillEditor-DvtameHg.js +1 -0
- package/apps/web/dist/assets/{Skills-Bv6XbKxc.js → Skills-Cf1Kl4Fy.js} +6 -6
- package/apps/web/dist/assets/SpacePage-CyqVzX9b.js +2 -0
- package/apps/web/dist/assets/{UpdateCheck-CLPUsKVT.js → UpdateCheck-DweZBVP6.js} +2 -2
- package/apps/web/dist/assets/changelog-C85v9OWg.js +1 -0
- package/apps/web/dist/assets/{code-editor-Ca5EAxmd.js → code-editor-B1RbFTAZ.js} +2 -2
- package/apps/web/dist/assets/connection-sign-in-CaVvh5GQ.js +1 -0
- package/apps/web/dist/assets/{host-CJdLkzfY.js → host-CKS5U5Vg.js} +18 -18
- package/apps/web/dist/assets/i18n-Bymk5Ev-.js +55 -0
- package/apps/web/dist/assets/{index-CmonJZHC.js → index-Ckcn5vy7.js} +4 -4
- package/apps/web/dist/assets/{read-aloud-Bfp9_bUY.js → read-aloud-Bq88XUHC.js} +1 -1
- package/apps/web/dist/assets/{runners-CUpBpSji.js → runners-DvYVe9Dt.js} +1 -1
- package/apps/web/dist/assets/session-D2bjiA3P.js +2 -0
- package/apps/web/dist/assets/theme-CNJIC2be.js +12 -0
- package/apps/web/dist/assets/ui-Mplfhz_Z.js +16 -0
- package/apps/web/dist/assets/{useMutation-1fV4Nnxq.js → useMutation-8QRM-z4M.js} +1 -1
- package/apps/web/dist/assets/{viewers-ChriFcRy.js → viewers-CEocUV_2.js} +2 -2
- package/apps/web/dist/index.html +11 -11
- package/apps/web/dist/mcp/flow.html +65 -65
- package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +8 -2
- package/node_modules/@engenty/wizards/dist/plugin/thread.js +30 -0
- package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +168 -0
- package/node_modules/@engenty/wizards-shared/dist/definition.js +52 -0
- 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/fit.d.ts +2 -0
- package/node_modules/@engenty/wizards-shared/dist/fit.js +4 -0
- package/node_modules/@engenty/wizards-shared/dist/knowledge.d.ts +5 -0
- package/node_modules/@engenty/wizards-shared/dist/run.d.ts +8 -1
- package/node_modules/@engenty/wizards-shared/dist/run.js +8 -0
- package/node_modules/@engenty/wizards-shared/dist/runner-texts.d.ts +7 -1
- package/node_modules/@engenty/wizards-shared/dist/runner-texts.js +6 -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/CapabilitiesPage-DvSSybt0.js +0 -2
- package/apps/web/dist/assets/EditorPage-Duu8swX6.js +0 -3
- package/apps/web/dist/assets/Marketplace-Cty40VwG.js +0 -2
- package/apps/web/dist/assets/NewWizardPage-B10K8vND.js +0 -7
- package/apps/web/dist/assets/OnboardingPage-D3SEpTmt.js +0 -1
- package/apps/web/dist/assets/PreviewPane-DhhQ06Ic.js +0 -7
- package/apps/web/dist/assets/PublicRunner-B8ncIxIP.js +0 -1
- package/apps/web/dist/assets/SettingsPage-C-gGIJLJ.js +0 -2
- package/apps/web/dist/assets/SetupPage-CdsrHW-w.js +0 -1
- package/apps/web/dist/assets/SkillEditor-BaEiqqXl.js +0 -1
- package/apps/web/dist/assets/SpacePage-CYhxcjj0.js +0 -2
- package/apps/web/dist/assets/changelog-y5oxYzPd.js +0 -1
- package/apps/web/dist/assets/connection-sign-in-DECedzrs.js +0 -1
- package/apps/web/dist/assets/i18n-BBzMbGoo.js +0 -55
- package/apps/web/dist/assets/session-CMQo8P-G.js +0 -2
- package/apps/web/dist/assets/theme-D6KUBJnh.js +0 -11
- package/apps/web/dist/assets/ui-BCfu5sia.js +0 -16
|
@@ -20,6 +20,7 @@ import { embeddingModel } from "../models.js";
|
|
|
20
20
|
import { onPluginChange, pluginsOf } from "../plugins/registry.js";
|
|
21
21
|
import { currentRole, isAdminRole, MEMBERS_EDIT_ONLY } from "../services/access.js";
|
|
22
22
|
import { notFound, ServiceError } from "../services/errors.js";
|
|
23
|
+
import { searchesFirst } from "../services/query-vectors.js";
|
|
23
24
|
import { itemCategoriesOf, putCategory, setItemCategories } from "../services/space-categories.js";
|
|
24
25
|
import { currentTenant } from "../tenants/tenant.js";
|
|
25
26
|
import { cachedText, keptText } from "./cache.js";
|
|
@@ -690,6 +691,7 @@ async function embedTexts() {
|
|
|
690
691
|
return unitText(texts.get(file.id) ?? "", unit);
|
|
691
692
|
});
|
|
692
693
|
try {
|
|
694
|
+
await searchesFirst();
|
|
693
695
|
const result = await embedMany({
|
|
694
696
|
model: resolved.model,
|
|
695
697
|
values: values.map((v) => v || " "),
|
|
@@ -754,6 +756,7 @@ async function embedPictures() {
|
|
|
754
756
|
await db.delete(u).where(eq(u.id, unit.id));
|
|
755
757
|
continue;
|
|
756
758
|
}
|
|
759
|
+
await searchesFirst();
|
|
757
760
|
await db
|
|
758
761
|
.update(u)
|
|
759
762
|
.set({ embedding: vectorBytes(await embedImage(jpeg)), model: resolved.ref })
|
|
@@ -196,6 +196,9 @@ export function runsApiFor(pluginId) {
|
|
|
196
196
|
if (run.status === "done" || run.status === "cancelled" || run.status === "failed") {
|
|
197
197
|
throw new ServiceError("refused", noteText({ code: "runOver" }, wizardLang(run.definition)));
|
|
198
198
|
}
|
|
199
|
+
if (run.status === "sleeping") {
|
|
200
|
+
throw new ServiceError("refused", noteText({ code: "runSleeps" }, wizardLang(run.definition)));
|
|
201
|
+
}
|
|
199
202
|
const bytes = file.data instanceof Uint8Array ? file.data : new Uint8Array(file.data);
|
|
200
203
|
if (!bytes.length || bytes.length > 10_000_000) {
|
|
201
204
|
throw new ServiceError("invalid", noteText({ code: "recordingTooLarge" }, wizardLang(run.definition)));
|
|
@@ -149,6 +149,9 @@ Ask the person, then answer_ask with allow or skip.
|
|
|
149
149
|
<!-- section: hint.sign_in -->
|
|
150
150
|
A sign-in: the person types it on the run page (browserUrl).
|
|
151
151
|
|
|
152
|
+
<!-- section: hint.sleeping -->
|
|
153
|
+
The run waits until `until` and goes on by itself. Nothing is needed from the person meanwhile.
|
|
154
|
+
|
|
152
155
|
<!-- section: hint.page -->
|
|
153
156
|
Ask the fields in order; skip a field whose `when` does not hold on the answers so far (a hidden one is not required and not kept).
|
|
154
157
|
|
|
@@ -25,7 +25,7 @@ import { fieldErrorsIn } from "../engine/input.js";
|
|
|
25
25
|
import { fromOwner } from "../engine/owner.js";
|
|
26
26
|
import { pushAvailable, setPushDevice } from "../engine/push.js";
|
|
27
27
|
import { liveResources } from "../engine/resources.js";
|
|
28
|
-
import { cancel, createRun, editOutput, GuestBudgetError, goBack, NoCreditsError, RunConflict, RunInputError, retry, reviewStep, runView, spaceIdOf, submitPage, talkAllowed, } from "../engine/runner.js";
|
|
28
|
+
import { cancel, createRun, editOutput, GuestBudgetError, goBack, NoCreditsError, RunConflict, RunInputError, retry, reviewStep, runView, spaceIdOf, submitPage, talkAllowed, writeRunState, } from "../engine/runner.js";
|
|
29
29
|
import { basePath, env } from "../env.js";
|
|
30
30
|
import { loadAsset, saveAsset } from "../files/storage.js";
|
|
31
31
|
import { checkUpload } from "../files/upload-check.js";
|
|
@@ -712,16 +712,11 @@ export const runRoutes = new Hono()
|
|
|
712
712
|
if (JSON.stringify(state).length > MAX_VIEW_STATE) {
|
|
713
713
|
return c.json({ error: "too large" }, 413);
|
|
714
714
|
}
|
|
715
|
-
await
|
|
716
|
-
.
|
|
717
|
-
.
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
outputs: { ...run.state.outputs, [stepId]: { ...output, view: state } },
|
|
721
|
-
},
|
|
722
|
-
})
|
|
723
|
-
.where(eq(schema.run.id, run.id));
|
|
724
|
-
return c.json({ ok: true });
|
|
715
|
+
const kept = await writeRunState(run, {
|
|
716
|
+
...run.state,
|
|
717
|
+
outputs: { ...run.state.outputs, [stepId]: { ...output, view: state } },
|
|
718
|
+
});
|
|
719
|
+
return kept ? c.json({ ok: true }) : c.json({ error: "busy" }, 409);
|
|
725
720
|
})
|
|
726
721
|
// A json step's data, edited in the studio by someone of the organization the run belongs to.
|
|
727
722
|
.put("/:id/outputs/:stepId", async (c) => {
|
|
@@ -861,13 +856,15 @@ export const runRoutes = new Hono()
|
|
|
861
856
|
}
|
|
862
857
|
throw err;
|
|
863
858
|
}
|
|
864
|
-
const fresh = await db.query.run.findFirst({ where: eq(schema.run.id, run.id) });
|
|
865
|
-
const state = fresh
|
|
859
|
+
const fresh = (await db.query.run.findFirst({ where: eq(schema.run.id, run.id) })) ?? run;
|
|
860
|
+
const state = fresh.state;
|
|
866
861
|
state.translated = {
|
|
867
862
|
...state.translated,
|
|
868
863
|
[run.lang]: { ...state.translated?.[run.lang], [stepId]: translated },
|
|
869
864
|
};
|
|
870
|
-
|
|
865
|
+
if (!(await writeRunState(fresh, state))) {
|
|
866
|
+
return refuse(c, { code: "runBusy" }, 409);
|
|
867
|
+
}
|
|
871
868
|
signalChanged(run.id);
|
|
872
869
|
}
|
|
873
870
|
return c.json({ ok: true });
|
|
@@ -881,6 +878,9 @@ export const runRoutes = new Hono()
|
|
|
881
878
|
if (run.status === "done" || run.status === "cancelled" || run.status === "failed") {
|
|
882
879
|
return refuse(c, { code: "runOver" }, 409);
|
|
883
880
|
}
|
|
881
|
+
if (run.status === "sleeping") {
|
|
882
|
+
return refuse(c, { code: "runSleeps" }, 409);
|
|
883
|
+
}
|
|
884
884
|
if (!(await talkAllowed(run))) {
|
|
885
885
|
return refuse(c, { code: "talkOff" }, 403);
|
|
886
886
|
}
|
|
@@ -908,6 +908,9 @@ export const runRoutes = new Hono()
|
|
|
908
908
|
if (run.status === "done" || run.status === "cancelled" || run.status === "failed") {
|
|
909
909
|
return refuse(c, { code: "runOver" }, 409);
|
|
910
910
|
}
|
|
911
|
+
if (run.status === "sleeping") {
|
|
912
|
+
return refuse(c, { code: "runSleeps" }, 409);
|
|
913
|
+
}
|
|
911
914
|
if (!allowed(`transcribe:${run.id}`, 60, 3600_000)) {
|
|
912
915
|
return refuse(c, { code: "tryLater" }, 429);
|
|
913
916
|
}
|
|
@@ -200,7 +200,7 @@ export async function apiRuns(userId, filter = {}) {
|
|
|
200
200
|
const where = and(inArray(schema.run.wizardId, ids), eq(schema.run.mode, "live"), status === "done"
|
|
201
201
|
? eq(schema.run.status, "done")
|
|
202
202
|
: status === "open"
|
|
203
|
-
? inArray(schema.run.status, ["waiting_input", "running"])
|
|
203
|
+
? inArray(schema.run.status, ["waiting_input", "sleeping", "running"])
|
|
204
204
|
: undefined, filter.days
|
|
205
205
|
? gte(schema.run.createdAt, new Date(Date.now() - filter.days * 86_400_000))
|
|
206
206
|
: undefined, like
|
|
@@ -240,8 +240,9 @@ export async function listKnowledge(userId, spaceId, who) {
|
|
|
240
240
|
embeddingModel()
|
|
241
241
|
.then(Boolean)
|
|
242
242
|
.catch(() => false),
|
|
243
|
+
// Clef in Ollama on this computer is too slow for a search (checksRelevance).
|
|
243
244
|
systemOneAccess()
|
|
244
|
-
.then(Boolean)
|
|
245
|
+
.then((access) => Boolean(access && !access.local))
|
|
245
246
|
.catch(() => false),
|
|
246
247
|
]);
|
|
247
248
|
const tPaths = await tablePaths(space.id);
|
|
@@ -110,6 +110,8 @@ export async function reportAllWizards() {
|
|
|
110
110
|
}
|
|
111
111
|
const STATE = {
|
|
112
112
|
waiting_input: "waiting",
|
|
113
|
+
// Manage knows five states; asleep or with a person, the run waits.
|
|
114
|
+
sleeping: "waiting",
|
|
113
115
|
running: "running",
|
|
114
116
|
done: "finished",
|
|
115
117
|
failed: "failed",
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { setTimeout as sleep } from "node:timers/promises";
|
|
2
|
+
import { embedMany } from "ai";
|
|
3
|
+
import { embeddingModel } from "../models.js";
|
|
4
|
+
/**
|
|
5
|
+
* The vector of a search's query. The embedding model is the index's too: in an Ollama that is
|
|
6
|
+
* embedding a folder, a query's call waits behind every passage sent before it (36 s measured).
|
|
7
|
+
* So a query is embedded once (the palette asks twice, a client space's search once per space),
|
|
8
|
+
* the indexers send nothing new while one is on its way (`searchesFirst`), and a search waits
|
|
9
|
+
* only as long as it is given.
|
|
10
|
+
*/
|
|
11
|
+
/** How many queries' vectors are kept. */
|
|
12
|
+
const KEPT = 64;
|
|
13
|
+
/** An embedding model that has not answered in this time is not going to. */
|
|
14
|
+
const GIVE_UP_MS = 120_000;
|
|
15
|
+
const vectors = new Map();
|
|
16
|
+
let pending = 0;
|
|
17
|
+
let waiting = [];
|
|
18
|
+
/**
|
|
19
|
+
* The query's vector and the model it comes from. Null without an embedding model or when it
|
|
20
|
+
* failed; undefined when it did not come within `waitMs` (it is kept for the next ask).
|
|
21
|
+
*/
|
|
22
|
+
export async function queryVector(query, waitMs) {
|
|
23
|
+
const resolved = await embeddingModel().catch(() => null);
|
|
24
|
+
if (!resolved) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
const key = `${resolved.ref}\n${query}`;
|
|
28
|
+
let found = vectors.get(key);
|
|
29
|
+
if (!found) {
|
|
30
|
+
pending++;
|
|
31
|
+
found = embedMany({
|
|
32
|
+
model: resolved.model,
|
|
33
|
+
values: [query],
|
|
34
|
+
abortSignal: AbortSignal.timeout(GIVE_UP_MS),
|
|
35
|
+
})
|
|
36
|
+
.then((r) => ({ vector: Array.from(r.embeddings[0]), model: resolved.ref }))
|
|
37
|
+
.catch(() => {
|
|
38
|
+
vectors.delete(key);
|
|
39
|
+
return null;
|
|
40
|
+
})
|
|
41
|
+
.finally(() => {
|
|
42
|
+
pending--;
|
|
43
|
+
if (!pending) {
|
|
44
|
+
for (const go of waiting) {
|
|
45
|
+
go();
|
|
46
|
+
}
|
|
47
|
+
waiting = [];
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
vectors.set(key, found);
|
|
51
|
+
if (vectors.size > KEPT) {
|
|
52
|
+
vectors.delete(vectors.keys().next().value);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return Promise.race([found, sleep(waitMs, undefined, { ref: false })]);
|
|
56
|
+
}
|
|
57
|
+
/** Resolves once no query's vector is on its way: an indexer calls it before it sends a batch. */
|
|
58
|
+
export function searchesFirst() {
|
|
59
|
+
return pending ? new Promise((resolve) => waiting.push(resolve)) : Promise.resolve();
|
|
60
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { decide } from "../engine/decide.js";
|
|
2
|
+
import { systemOneAccess } from "../models.js";
|
|
2
3
|
import { prompt } from "../prompts.js";
|
|
3
4
|
/**
|
|
4
5
|
* The last step of a search of Knowledge: does each candidate the index found help answer the
|
|
@@ -15,6 +16,14 @@ const clip = (value, max) => {
|
|
|
15
16
|
const s = value.replace(/\s+/g, " ").trim();
|
|
16
17
|
return s.length > max ? `${s.slice(0, max - 1)}…` : s;
|
|
17
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* Whether a search's candidates are checked. Not by Clef in Ollama on this computer: on an M4
|
|
21
|
+
* it took 18 s for one candidate and a minute for eight, never within TIMEOUT_MS, and the
|
|
22
|
+
* embedding model waited behind it. Without a decision model, the classifier class's model answers.
|
|
23
|
+
*/
|
|
24
|
+
export async function checksRelevance() {
|
|
25
|
+
return !(await systemOneAccess().catch(() => null))?.local;
|
|
26
|
+
}
|
|
18
27
|
/**
|
|
19
28
|
* P(relevant) for each candidate, in their order. Null for all of them when no way decided in
|
|
20
29
|
* time: the search then keeps the order the index gave.
|
|
@@ -23,6 +32,9 @@ export async function judgeRelevance(query, candidates, signal) {
|
|
|
23
32
|
if (!candidates.length) {
|
|
24
33
|
return [];
|
|
25
34
|
}
|
|
35
|
+
if (!(await checksRelevance())) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
26
38
|
const questions = {};
|
|
27
39
|
const state = {
|
|
28
40
|
query: clip(query, 600),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FIELD_WAYS, formatsFor, isDecidedField, shownFields, slotText, wizardLang, } from "@engenty/wizards-shared/definition";
|
|
1
|
+
import { FIELD_WAYS, formatsFor, isDecidedField, shownFields, slotText, waitDurationMs, wizardLang, } from "@engenty/wizards-shared/definition";
|
|
2
2
|
import { note } from "@engenty/wizards-shared/run";
|
|
3
3
|
import { and, count, desc, eq, gte, inArray, isNull, max, or, sql } from "drizzle-orm";
|
|
4
4
|
import { canSpend, MICROS_PER_CREDIT } from "../credits/credits.js";
|
|
@@ -232,6 +232,14 @@ async function waitingFor(run, current, draft) {
|
|
|
232
232
|
hint: prompt("mcp", "hint.sign_in"),
|
|
233
233
|
};
|
|
234
234
|
}
|
|
235
|
+
if (run.status === "sleeping" && current) {
|
|
236
|
+
return {
|
|
237
|
+
wait: current.id,
|
|
238
|
+
title: current.title,
|
|
239
|
+
until: run.wakeAt?.toISOString() ?? null,
|
|
240
|
+
hint: prompt("mcp", "hint.sleeping"),
|
|
241
|
+
};
|
|
242
|
+
}
|
|
235
243
|
if (run.status !== "waiting_input" || !current) {
|
|
236
244
|
return undefined;
|
|
237
245
|
}
|
|
@@ -464,7 +472,9 @@ export async function draftStepView(userId, wizardId, stepId, lang) {
|
|
|
464
472
|
? "waiting_input"
|
|
465
473
|
: step.type === "result"
|
|
466
474
|
? "done"
|
|
467
|
-
: "
|
|
475
|
+
: step.type === "wait"
|
|
476
|
+
? "sleeping"
|
|
477
|
+
: "running";
|
|
468
478
|
const now = new Date();
|
|
469
479
|
// That run lends its id too: the outputs' files are reached through it.
|
|
470
480
|
const run = {
|
|
@@ -493,6 +503,9 @@ export async function draftStepView(userId, wizardId, stepId, lang) {
|
|
|
493
503
|
}),
|
|
494
504
|
definition: def,
|
|
495
505
|
status,
|
|
506
|
+
wakeAt: step.type === "wait" && step.for ? new Date(now.getTime() + waitDurationMs(step.for)) : null,
|
|
507
|
+
claim: 0,
|
|
508
|
+
rev: 0,
|
|
496
509
|
cursor: step.id,
|
|
497
510
|
state,
|
|
498
511
|
lang: lang && lang !== wizardLang(def) && (await storedTranslation(w.id, lang)) ? lang : null,
|
|
@@ -525,6 +538,7 @@ export async function listRuns(userId, wizardId) {
|
|
|
525
538
|
id: r.id,
|
|
526
539
|
mode: r.mode,
|
|
527
540
|
status: r.status,
|
|
541
|
+
wakeAt: r.wakeAt?.toISOString() ?? null,
|
|
528
542
|
version: r.version,
|
|
529
543
|
createdAt: r.createdAt.toISOString(),
|
|
530
544
|
credits: Math.ceil(r.costMicros / MICROS_PER_CREDIT),
|
|
@@ -14,6 +14,7 @@ import { pluginIdsOf } from "../plugins/registry.js";
|
|
|
14
14
|
import { currentTenant } from "../tenants/tenant.js";
|
|
15
15
|
import { ServiceError } from "./errors.js";
|
|
16
16
|
import { filePaths, pageTree, tablePaths } from "./knowledge.js";
|
|
17
|
+
import { queryVector, searchesFirst } from "./query-vectors.js";
|
|
17
18
|
import { judgeRelevance, MIN_RELEVANCE } from "./relevance.js";
|
|
18
19
|
import { categoryLines, categoryRows, filterItems, itemCategoriesOf, } from "./space-categories.js";
|
|
19
20
|
const CHUNK = { mode: "paragraph", max_chunk_length: 1200, overlap: 120 };
|
|
@@ -29,12 +30,17 @@ const CANDIDATES = 24;
|
|
|
29
30
|
* has it: the nearest units are near even for a question the space knows nothing of.
|
|
30
31
|
*/
|
|
31
32
|
const MIN_LEAD = 0.08;
|
|
33
|
+
/** The palette's quick ask waits this long for the query's vector, then answers with words. */
|
|
34
|
+
const QUICK_MS = 800;
|
|
35
|
+
/** Any other search waits this long for it: the embedding model may be busy with the index. */
|
|
36
|
+
const VECTOR_MS = 15_000;
|
|
32
37
|
const vectorBytes = (v) => Buffer.from(new Float32Array(v).buffer);
|
|
33
38
|
async function embed(texts) {
|
|
34
39
|
const resolved = await embeddingModel();
|
|
35
40
|
if (!resolved || !texts.length) {
|
|
36
41
|
return null;
|
|
37
42
|
}
|
|
43
|
+
await searchesFirst();
|
|
38
44
|
const result = await embedMany({ model: resolved.model, values: texts, maxParallelCalls: 4 });
|
|
39
45
|
return { vectors: result.embeddings.map((e) => Array.from(e)), model: resolved.ref };
|
|
40
46
|
}
|
|
@@ -549,6 +555,7 @@ async function embedPictures() {
|
|
|
549
555
|
await db.delete(schema.spaceChunk).where(which);
|
|
550
556
|
continue;
|
|
551
557
|
}
|
|
558
|
+
await searchesFirst();
|
|
552
559
|
const vector = await embedImage(jpeg);
|
|
553
560
|
await db
|
|
554
561
|
.update(schema.spaceChunk)
|
|
@@ -722,7 +729,8 @@ async function readableUnits(spaceId, who, units) {
|
|
|
722
729
|
* Searches Knowledge for `who`: items whose categories pass `where` and that they may read, then
|
|
723
730
|
* the units the keywords, the trigrams and the vectors rank best, merged by rank (RRF), then the
|
|
724
731
|
* classifier's judgement of each of the CANDIDATES best. Gives up to `limit` items with their
|
|
725
|
-
* best section. `check: false`
|
|
732
|
+
* best section. `check: false` is the palette's quick ask: no classifier, and the query's vector
|
|
733
|
+
* only if it comes within QUICK_MS (`late` says it did not). While the `broker` switch is on, a call
|
|
726
734
|
* without `who` is refused, and an item they may not read is in no hit, candidate or count.
|
|
727
735
|
*/
|
|
728
736
|
export async function searchKnowledge(spaceId, query, opts = {}) {
|
|
@@ -733,7 +741,7 @@ export async function searchKnowledge(spaceId, query, opts = {}) {
|
|
|
733
741
|
}
|
|
734
742
|
const filter = await filterItems(spaceId, opts.where);
|
|
735
743
|
if (filter && !filter.size) {
|
|
736
|
-
return { hits: [], candidates: 0, checked: false, filtered: 0, hidden: [] };
|
|
744
|
+
return { hits: [], candidates: 0, checked: false, filtered: 0, hidden: [], late: false };
|
|
737
745
|
}
|
|
738
746
|
const plugins = [...(await pluginIdsOf(currentTenant()))];
|
|
739
747
|
const inFilter = filter ? filtered(filter) : null;
|
|
@@ -760,9 +768,9 @@ export async function searchKnowledge(spaceId, query, opts = {}) {
|
|
|
760
768
|
ORDER BY bm25(space_chunk_tri) LIMIT ${take}`)
|
|
761
769
|
.catch(() => []));
|
|
762
770
|
}
|
|
763
|
-
const embedded = await
|
|
771
|
+
const embedded = await queryVector(query, opts.check === false ? QUICK_MS : VECTOR_MS);
|
|
764
772
|
if (embedded) {
|
|
765
|
-
const question = vectorBytes(embedded.
|
|
773
|
+
const question = vectorBytes(embedded.vector);
|
|
766
774
|
lists.push(featureOn(await currentFeatures(), "knowledgeMedia")
|
|
767
775
|
? await byMeaning(CHUNKS, where, embedded.model, question, take)
|
|
768
776
|
: await db.all(sql `
|
|
@@ -791,7 +799,7 @@ export async function searchKnowledge(spaceId, query, opts = {}) {
|
|
|
791
799
|
}
|
|
792
800
|
}
|
|
793
801
|
if (embedded) {
|
|
794
|
-
lists.push(await byMeaning(MOUNT_UNITS, inMounts, embedded.model, vectorBytes(embedded.
|
|
802
|
+
lists.push(await byMeaning(MOUNT_UNITS, inMounts, embedded.model, vectorBytes(embedded.vector), take));
|
|
795
803
|
}
|
|
796
804
|
}
|
|
797
805
|
const allowed = await readableUnits(spaceId, opts.who ?? [], lists.flat());
|
|
@@ -810,7 +818,14 @@ export async function searchKnowledge(spaceId, query, opts = {}) {
|
|
|
810
818
|
}
|
|
811
819
|
const candidates = [...scored.values()].sort((a, b) => b.score - a.score).slice(0, CANDIDATES);
|
|
812
820
|
if (!candidates.length) {
|
|
813
|
-
return {
|
|
821
|
+
return {
|
|
822
|
+
hits: [],
|
|
823
|
+
candidates: 0,
|
|
824
|
+
checked: false,
|
|
825
|
+
filtered: filter?.size ?? null,
|
|
826
|
+
hidden: [],
|
|
827
|
+
late: embedded === undefined,
|
|
828
|
+
};
|
|
814
829
|
}
|
|
815
830
|
const described = await describe(spaceId, candidates.map((c) => c.unit), mounts);
|
|
816
831
|
// The classifier reads text; a picture, found by what it shows, keeps its place.
|
|
@@ -874,6 +889,7 @@ export async function searchKnowledge(spaceId, query, opts = {}) {
|
|
|
874
889
|
checked: judged !== null,
|
|
875
890
|
filtered: filter?.size ?? null,
|
|
876
891
|
hidden,
|
|
892
|
+
late: embedded === undefined,
|
|
877
893
|
};
|
|
878
894
|
}
|
|
879
895
|
/** Where `byMeaning` looks: Knowledge's units, or the mounts'. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { and, count, eq, gte, inArray, isNull, lt, or, sql } from "drizzle-orm";
|
|
1
|
+
import { and, count, eq, gte, inArray, isNull, lt, lte, or, sql } from "drizzle-orm";
|
|
2
2
|
import { control, controlDb } from "../db/client.js";
|
|
3
3
|
import { env } from "../env.js";
|
|
4
4
|
import { currentTenant } from "./tenant.js";
|
|
@@ -116,32 +116,62 @@ export const RUNNER_STALE_MS = 30_000;
|
|
|
116
116
|
export async function wakeRun(runId) {
|
|
117
117
|
await controlDb
|
|
118
118
|
.update(control.runIndex)
|
|
119
|
-
.set({ active: true, owner: null, seen: null })
|
|
119
|
+
.set({ active: true, owner: null, seen: null, wokenAt: new Date() })
|
|
120
120
|
.where(eq(control.runIndex.runId, runId));
|
|
121
121
|
}
|
|
122
|
-
/**
|
|
122
|
+
/**
|
|
123
|
+
* When a run that sleeps wakes, in the copy the clock reads; null: nothing due. Written before the
|
|
124
|
+
* run's own row: a crash in between gives one extra wake, which finds the run as it is, never a
|
|
125
|
+
* lost one.
|
|
126
|
+
*/
|
|
127
|
+
export async function setWake(runId, wakeAt) {
|
|
128
|
+
await controlDb.update(control.runIndex).set({ wakeAt }).where(eq(control.runIndex.runId, runId));
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The clock: what came due goes in line, in one statement over every tenant, so several runners
|
|
132
|
+
* running it are harmless. The run ages from the time it was due. A run that turns out not to be
|
|
133
|
+
* due puts its time back from its own row.
|
|
134
|
+
*/
|
|
135
|
+
export async function wakeDue(now = new Date()) {
|
|
136
|
+
const result = await controlDb
|
|
137
|
+
.update(control.runIndex)
|
|
138
|
+
.set({
|
|
139
|
+
active: true,
|
|
140
|
+
owner: null,
|
|
141
|
+
seen: null,
|
|
142
|
+
wakeAt: null,
|
|
143
|
+
wokenAt: sql `${control.runIndex.wakeAt}`,
|
|
144
|
+
})
|
|
145
|
+
.where(and(eq(control.runIndex.active, false), lte(control.runIndex.wakeAt, now)));
|
|
146
|
+
return result.rowsAffected;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The run is done with runners for now: a page, a review or the end. Only its owner rests it: a
|
|
150
|
+
* wake meanwhile cleared the owner, and the run stays in line.
|
|
151
|
+
*/
|
|
123
152
|
export async function restRun(runId) {
|
|
124
153
|
await controlDb
|
|
125
154
|
.update(control.runIndex)
|
|
126
155
|
.set({ active: false, owner: null, seen: null })
|
|
127
|
-
.where(eq(control.runIndex.runId, runId));
|
|
156
|
+
.where(and(eq(control.runIndex.runId, runId), eq(control.runIndex.owner, env.runner.id)));
|
|
128
157
|
}
|
|
129
158
|
/**
|
|
130
159
|
* Takes a run for this runner, in one statement: only while nobody (alive) holds it and the
|
|
131
|
-
* tenant's owned runs stay under its limit.
|
|
132
|
-
* limit — the run stays in line.
|
|
160
|
+
* tenant's owned runs stay under its limit. Answers the claim's number, higher than any before.
|
|
161
|
+
* Null: someone else has it, or the tenant is at its limit — the run stays in line.
|
|
133
162
|
*/
|
|
134
163
|
export async function claimRun(runId, tenantId, limit) {
|
|
135
164
|
const now = Date.now();
|
|
136
165
|
const stale = now - RUNNER_STALE_MS;
|
|
137
166
|
const result = await controlDb.run(sql `
|
|
138
|
-
UPDATE run_index SET owner = ${env.runner.id}, seen = ${now}
|
|
167
|
+
UPDATE run_index SET owner = ${env.runner.id}, seen = ${now}, generation = generation + 1
|
|
139
168
|
WHERE run_id = ${runId} AND active = 1
|
|
140
169
|
AND (owner IS NULL OR seen IS NULL OR seen < ${stale})
|
|
141
170
|
AND (SELECT count(*) FROM run_index
|
|
142
171
|
WHERE tenant_id = ${tenantId} AND owner IS NOT NULL AND seen >= ${stale}
|
|
143
|
-
AND run_id != ${runId}) < ${limit}
|
|
144
|
-
|
|
172
|
+
AND run_id != ${runId}) < ${limit}
|
|
173
|
+
RETURNING generation`);
|
|
174
|
+
return result.rows.length ? Number(result.rows[0].generation) : null;
|
|
145
175
|
}
|
|
146
176
|
/** This runner still works on these runs. */
|
|
147
177
|
export async function heartbeatRuns(runIds) {
|
|
@@ -159,14 +189,16 @@ export async function disownRuns() {
|
|
|
159
189
|
.set({ owner: null, seen: null })
|
|
160
190
|
.where(eq(control.runIndex.owner, env.runner.id));
|
|
161
191
|
}
|
|
162
|
-
/**
|
|
192
|
+
/** How long a run has been in line for: since it last woke, else since it was made. */
|
|
193
|
+
const inLineSince = sql `coalesce(${control.runIndex.wokenAt}, ${control.runIndex.createdAt})`;
|
|
194
|
+
/** The runs in line, longest in line first: unowned, or whose owner fell silent. */
|
|
163
195
|
export async function waitingRuns() {
|
|
164
196
|
const stale = new Date(Date.now() - RUNNER_STALE_MS);
|
|
165
197
|
return controlDb
|
|
166
198
|
.select({ runId: control.runIndex.runId, tenantId: control.runIndex.tenantId })
|
|
167
199
|
.from(control.runIndex)
|
|
168
200
|
.where(and(eq(control.runIndex.active, true), or(isNull(control.runIndex.owner), isNull(control.runIndex.seen), lt(control.runIndex.seen, stale))))
|
|
169
|
-
.orderBy(
|
|
201
|
+
.orderBy(inLineSince);
|
|
170
202
|
}
|
|
171
203
|
/** Where the runner holding a run is reached; null when none holds it or it named no address. */
|
|
172
204
|
export async function ownerUrl(runId) {
|
|
@@ -207,12 +239,12 @@ export async function lineState() {
|
|
|
207
239
|
.select({ id: control.runner.id, seen: control.runner.seen, lineAt: control.runner.lineAt })
|
|
208
240
|
.from(control.runner);
|
|
209
241
|
const [oldest] = await controlDb
|
|
210
|
-
.select({ createdAt: control.runIndex.createdAt })
|
|
242
|
+
.select({ createdAt: control.runIndex.createdAt, wokenAt: control.runIndex.wokenAt })
|
|
211
243
|
.from(control.runIndex)
|
|
212
244
|
.where(and(eq(control.runIndex.active, true), or(isNull(control.runIndex.owner), isNull(control.runIndex.seen), lt(control.runIndex.seen, new Date(Date.now() - RUNNER_STALE_MS)))))
|
|
213
|
-
.orderBy(
|
|
245
|
+
.orderBy(inLineSince)
|
|
214
246
|
.limit(1);
|
|
215
|
-
return { runners, oldestWaiting: oldest
|
|
247
|
+
return { runners, oldestWaiting: oldest ? (oldest.wokenAt ?? oldest.createdAt) : null };
|
|
216
248
|
}
|
|
217
249
|
export async function forgetRunner() {
|
|
218
250
|
await controlDb.delete(control.runner).where(eq(control.runner.id, env.runner.id));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{Yn as r,an as i,hn as a,in as o,nn as s,pn as c,rn as l,un as u}from"./ui-Mplfhz_Z.js";import{t as d}from"./preload-helper-DpV6A1kQ.js";import{c as f,n as p}from"./marked.esm-DQ7XA7AC.js";import{t as m}from"./logo-BpnjXTRy.js";import{s as h}from"./i18n-Bymk5Ev-.js";import{g,h as _,m as v,t as y,u as b}from"./UpdateCheck-DweZBVP6.js";import{ReleaseNotes as x,loadReleases as S,releaseDate as C,releaseLabel as w}from"./ChangelogDialog-B08elwyr.js";var T=e(t(),1),E=[{name:`engenty wizards`,description:`credit.engenty-wizards`,homepage:`https://github.com/engenty/wizards`,license:`FSL-1.1-MIT`},{name:`engenty`,description:`credit.engenty`,homepage:`https://github.com/engenty/engenty`,license:`FSL-1.1-MIT`}],D=[{name:`Mastra`,description:`credit.mastra`,homepage:`https://github.com/mastra-ai/mastra`,license:`Apache-2.0`},{name:`AI SDK`,description:`credit.ai-sdk`,homepage:`https://github.com/vercel/ai`,license:`Apache-2.0`},{name:`Model Context Protocol`,description:`credit.model-context-protocol`,homepage:`https://github.com/modelcontextprotocol/typescript-sdk`,license:`MIT`},{name:`Hono`,description:`credit.hono`,homepage:`https://github.com/honojs/hono`,license:`MIT`},{name:`Drizzle ORM`,description:`credit.drizzle-orm`,homepage:`https://github.com/drizzle-team/drizzle-orm`,license:`Apache-2.0`},{name:`libSQL`,description:`credit.libsql`,homepage:`https://github.com/tursodatabase/libsql`,license:`MIT`},{name:`Playwright`,description:`credit.playwright`,homepage:`https://github.com/microsoft/playwright`,license:`Apache-2.0`},{name:`React`,description:`credit.react`,homepage:`https://github.com/facebook/react`,license:`MIT`},{name:`Vite`,description:`credit.vite`,homepage:`https://github.com/vitejs/vite`,license:`MIT`},{name:`Tailwind CSS`,description:`credit.tailwind-css`,homepage:`https://github.com/tailwindlabs/tailwindcss`,license:`MIT`},{name:`React Flow`,description:`credit.react-flow`,homepage:`https://github.com/xyflow/xyflow`,license:`MIT`},{name:`TanStack Query`,description:`credit.tanstack-query`,homepage:`https://github.com/TanStack/query`,license:`MIT`},{name:`xterm.js`,description:`credit.xterm-js`,homepage:`https://github.com/xtermjs/xterm.js`,license:`MIT`},{name:`Lucide`,description:`credit.lucide`,homepage:`https://github.com/lucide-icons/lucide`,license:`ISC`},{name:`Geist & Geist Mono`,description:`credit.geist-geist-mono`,homepage:`https://github.com/vercel/geist-font`,license:`OFL-1.1`},{name:`Space Grotesk`,description:`credit.space-grotesk`,homepage:`https://github.com/floriankarsten/space-grotesk`,license:`OFL-1.1`},{name:`git-cliff`,description:`credit.git-cliff`,homepage:`https://github.com/orhun/git-cliff`,license:`MIT OR Apache-2.0`}],O=e(n(),1),k=(e,...t)=>t.some(t=>t?.toLowerCase().includes(e));function A({name:e,homepage:t,version:n,license:r,description:i}){return(0,O.jsxs)(`li`,{className:`py-2.5`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2.5 gap-y-0.5`,children:[t?(0,O.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 font-medium text-[0.875rem] text-ink underline-offset-4 hover:underline`,children:[e,(0,O.jsx)(f,{"aria-hidden":!0,className:`size-3 text-ink-4`})]}):(0,O.jsx)(`span`,{className:`font-medium text-[0.875rem] text-ink`,children:e}),n?(0,O.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:n}):null,(0,O.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:r})]}),i?(0,O.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:i}):null]})}function j({title:e,hint:t,children:n}){return(0,O.jsxs)(`section`,{className:`mt-6`,children:[(0,O.jsx)(`h3`,{className:`border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:e}),t?(0,O.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-ink-3`,children:t}):null,n]})}function M({credits:e}){return(0,O.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:e.map(e=>(0,O.jsx)(A,{name:e.name,homepage:e.homepage,license:e.license,description:h(e.description)},e.name))})}function N({label:e,packages:t}){return(0,O.jsxs)(`div`,{className:`mt-4`,children:[(0,O.jsx)(`h4`,{className:`font-medium text-[0.75rem] text-ink-3 tracking-wide`,children:e}),(0,O.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:t.map(e=>(0,O.jsx)(A,{...e},e.name))})]})}function P({active:e}){let[t,n]=(0,T.useState)(null),[r,a]=(0,T.useState)(``);(0,T.useEffect)(()=>{if(!e||t)return;let r=!1;return d(()=>import(`./oss-credits-BrwV0a4F.js`).then(e=>{r||n(e.default)}),[]),()=>{r=!0}},[e,t]),(0,T.useEffect)(()=>{e||a(``)},[e]);let o=r.trim().toLowerCase(),s=e=>o?e.filter(e=>k(o,e.name,e.license,h(e.description))):e,c=e=>o?e.filter(e=>k(o,e.name,e.license,e.version)):e,f=s(E),p=s(D),m=t?[{id:`shared`,label:h(`about.creditsShared`),packages:c(t.shared)},...t.groups.map(e=>({id:e.id,label:e.label,packages:c(e.packages)}))].filter(e=>e.packages.length>0):[],g=f.length===0&&p.length===0&&m.length===0;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`p`,{className:`mb-4 text-[0.875rem] text-ink-3`,children:h(`about.creditsHint`)}),(0,O.jsx)(i,{type:`search`,value:r,placeholder:h(`about.search`),onChange:e=>a(e.target.value)}),f.length>0?(0,O.jsx)(j,{title:h(`about.creditsProduct`),children:(0,O.jsx)(M,{credits:f})}):null,p.length>0?(0,O.jsx)(j,{title:h(`about.creditsBuiltWith`),children:(0,O.jsx)(M,{credits:p})}):null,t===null?(0,O.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,O.jsx)(u,{})}):m.length>0?(0,O.jsx)(j,{title:h(`about.creditsDeps`),hint:o?void 0:h(`about.creditsDepsHint`),children:m.map(e=>(0,O.jsx)(N,{label:e.label,packages:e.packages},e.id))}):null,t!==null&&g?(0,O.jsx)(l,{children:h(`about.noMatches`)}):null]})}var F=[`new`,`earlier`,`credits`],I=e=>h(e===`new`?`about.tab.new`:e===`earlier`?`about.tab.earlier`:`about.credits`),L=e=>e===1?h(`about.change`):h(`about.changes`,{n:e});function R({me:e,active:t,initialTab:n=`new`}){let i=e?.mode===`local`,{data:o,latest:s}=_(i&&t),[l,d]=(0,T.useState)(null),[f,p]=(0,T.useState)(n);(0,T.useEffect)(()=>p(n),[n]);let E=v(F.indexOf(f)),D=o?.newer&&s?s:g;(0,T.useEffect)(()=>{if(!t)return;let e=!1;return d(null),S(D===`0.16.2`?void 0:D).then(t=>{e||d(t)}),()=>{e=!0}},[t,D]);let k=l?.find(e=>e.version===`v${D}`)??l?.[0]??null,A=l?.filter(e=>e!==k)??[],j=i?o?.kind??null:`cloud`;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`flex flex-col items-center pt-4 text-center`,children:[(0,O.jsx)(m,{size:96}),(0,O.jsxs)(`div`,{className:`mt-4 font-display font-semibold text-[1.5rem] tracking-tight`,children:[`engenty`,(0,O.jsx)(`span`,{className:`text-ember`,children:`.`}),(0,O.jsx)(`span`,{className:`ml-1.5 font-normal text-ink-3`,children:`wizards`})]}),(0,O.jsxs)(`div`,{className:`mt-1 text-[0.9375rem] text-ink-3 tabular-nums`,children:[h(`about.version`,{v:g}),j?` · ${h(`about.kind.${j}`)}`:``]})]}),i?(0,O.jsx)(`div`,{className:`mt-5`,children:(0,O.jsx)(y,{enabled:t})}):null,(0,O.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,O.jsx)(c,{value:f,onChange:p,options:F.map(e=>({id:e,label:I(e)})),label:h(`about.title`)})}),(0,O.jsxs)(`div`,{className:a(`mt-5`,b(E)),children:[f===`new`?l===null?(0,O.jsx)(`div`,{className:`flex justify-center py-6 text-ink-3`,children:(0,O.jsx)(u,{})}):k?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`h3`,{className:`flex items-baseline gap-3 border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:[w(k),(0,O.jsx)(`span`,{className:`font-normal font-sans text-[0.8125rem] text-ink-3 tabular-nums`,children:C(k)})]}),(0,O.jsx)(`div`,{className:`mt-3`,children:(0,O.jsx)(x,{release:k})})]}):(0,O.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:h(`about.changelogEmpty`)}):null,f===`earlier`?(0,O.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:A.map(e=>(0,O.jsxs)(`details`,{className:`group/r py-2`,children:[(0,O.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-baseline gap-3 text-[0.875rem] [&::-webkit-details-marker]:hidden`,children:[(0,O.jsx)(r,{className:`size-3.5 shrink-0 self-center text-ink-4 transition group-open/r:rotate-90`}),(0,O.jsx)(`span`,{className:`font-medium text-ink tabular-nums`,children:w(e)}),(0,O.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:C(e)}),(0,O.jsx)(`span`,{className:`ml-auto text-[0.8125rem] text-ink-4`,children:L(e.commits.length)})]}),(0,O.jsx)(`div`,{className:`mt-2 pl-6`,children:(0,O.jsx)(x,{release:e})})]},e.version??`unreleased`))}):null,f===`credits`?(0,O.jsx)(P,{active:!0}):null]},f)]})}function z({open:e,onClose:t,me:n}){return(0,O.jsxs)(s,{open:e,onClose:t,wide:!0,height:`tall`,children:[(0,O.jsx)(`div`,{className:`-mt-2 -mr-2 sticky top-0 z-10 flex h-0 justify-end`,children:(0,O.jsx)(o,{label:h(`common.close`),onClick:t,children:(0,O.jsx)(p,{className:`size-4`})})}),(0,O.jsx)(R,{me:n,active:e})]})}export{z as AboutDialog,R as AboutPanel};
|