@engenty/wizards-runtime 0.16.0 → 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.
Files changed (102) hide show
  1. package/apps/runtime/dist/assistant/knows.js +3 -1
  2. package/apps/runtime/dist/cli/move-files.js +27 -11
  3. package/apps/runtime/dist/db/control-schema.js +7 -0
  4. package/apps/runtime/dist/db/migrations/control/0014_run_index_generation.sql +1 -0
  5. package/apps/runtime/dist/db/migrations/control/0015_run_index_wake.sql +3 -0
  6. package/apps/runtime/dist/db/migrations/control/meta/0014_snapshot.json +629 -0
  7. package/apps/runtime/dist/db/migrations/control/meta/0015_snapshot.json +650 -0
  8. package/apps/runtime/dist/db/migrations/control/meta/_journal.json +14 -0
  9. package/apps/runtime/dist/db/migrations/tenant/0056_run_claim_rev.sql +2 -0
  10. package/apps/runtime/dist/db/migrations/tenant/0057_run_wake_at.sql +1 -0
  11. package/apps/runtime/dist/db/migrations/tenant/meta/0056_snapshot.json +6520 -0
  12. package/apps/runtime/dist/db/migrations/tenant/meta/0057_snapshot.json +6527 -0
  13. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +14 -0
  14. package/apps/runtime/dist/db/schema.js +17 -3
  15. package/apps/runtime/dist/documents/parse.js +9 -0
  16. package/apps/runtime/dist/elements/knowledge.js +1 -0
  17. package/apps/runtime/dist/engine/runner.js +344 -52
  18. package/apps/runtime/dist/env.js +18 -0
  19. package/apps/runtime/dist/mounts/mounts.js +3 -0
  20. package/apps/runtime/dist/plugins/runs.js +3 -0
  21. package/apps/runtime/dist/prompts/mcp.md +3 -0
  22. package/apps/runtime/dist/routes/runs.js +17 -14
  23. package/apps/runtime/dist/services/api.js +1 -1
  24. package/apps/runtime/dist/services/knowledge.js +2 -1
  25. package/apps/runtime/dist/services/manage-reports.js +2 -0
  26. package/apps/runtime/dist/services/query-vectors.js +60 -0
  27. package/apps/runtime/dist/services/relevance.js +12 -0
  28. package/apps/runtime/dist/services/runs.js +16 -2
  29. package/apps/runtime/dist/services/space-index.js +22 -6
  30. package/apps/runtime/dist/services/work-files.js +25 -1
  31. package/apps/runtime/dist/sharing/index.js +3 -0
  32. package/apps/runtime/dist/tenants/control.js +46 -14
  33. package/apps/web/dist/assets/{AboutDialog-0q4P80yv.js → AboutDialog-BCcD8hKm.js} +1 -1
  34. package/apps/web/dist/assets/{BlockEditor-CUYFH_CU.js → BlockEditor-DgaUm2pR.js} +1 -1
  35. package/apps/web/dist/assets/CapabilitiesPage-DuJJV1ll.js +2 -0
  36. package/apps/web/dist/assets/{ChangelogDialog-CDN7kMs1.js → ChangelogDialog-B08elwyr.js} +1 -1
  37. package/apps/web/dist/assets/{CodeEditor-D-Y16fdk.js → CodeEditor-BiyOk_SC.js} +1 -1
  38. package/apps/web/dist/assets/EditorPage-EMFTHEYD.js +3 -0
  39. package/apps/web/dist/assets/{FlowPreview-DXnk7m9P.js → FlowPreview-DF_6TvZ0.js} +1 -1
  40. package/apps/web/dist/assets/{LangSwitch-Dkd0FBIH.js → LangSwitch-Ba4OWLzJ.js} +1 -1
  41. package/apps/web/dist/assets/Marketplace-DqziLf66.js +2 -0
  42. package/apps/web/dist/assets/{NewWizardChannels-Czool7s1.js → NewWizardChannels-CsIGp0nZ.js} +1 -1
  43. package/apps/web/dist/assets/NewWizardPage-CzQAkKMy.js +7 -0
  44. package/apps/web/dist/assets/OnboardingPage-B9gr2OX5.js +1 -0
  45. package/apps/web/dist/assets/PreviewPane-DSOV3o-1.js +7 -0
  46. package/apps/web/dist/assets/PublicRunner-BVs8-Vu3.js +1 -0
  47. package/apps/web/dist/assets/{ReadOnly-B7MUySpC.js → ReadOnly--4CIJCDD.js} +1 -1
  48. package/apps/web/dist/assets/SettingsPage-z2u8lSe2.js +2 -0
  49. package/apps/web/dist/assets/SetupPage-9Zk-KUGA.js +1 -0
  50. package/apps/web/dist/assets/{SharePage-UwEJBIzq.js → SharePage-D_Ab0gjr.js} +1 -1
  51. package/apps/web/dist/assets/SkillEditor-DvtameHg.js +1 -0
  52. package/apps/web/dist/assets/{Skills-Bv6XbKxc.js → Skills-Cf1Kl4Fy.js} +6 -6
  53. package/apps/web/dist/assets/SpacePage-CyqVzX9b.js +2 -0
  54. package/apps/web/dist/assets/{UpdateCheck-C7I43zFZ.js → UpdateCheck-DweZBVP6.js} +2 -2
  55. package/apps/web/dist/assets/changelog-C85v9OWg.js +1 -0
  56. package/apps/web/dist/assets/{code-editor-Ca5EAxmd.js → code-editor-B1RbFTAZ.js} +2 -2
  57. package/apps/web/dist/assets/connection-sign-in-CaVvh5GQ.js +1 -0
  58. package/apps/web/dist/assets/{host-D5hNHbhF.js → host-CKS5U5Vg.js} +18 -18
  59. package/apps/web/dist/assets/i18n-Bymk5Ev-.js +55 -0
  60. package/apps/web/dist/assets/{index-CyBrvupM.js → index-Ckcn5vy7.js} +4 -4
  61. package/apps/web/dist/assets/{read-aloud-Bfp9_bUY.js → read-aloud-Bq88XUHC.js} +1 -1
  62. package/apps/web/dist/assets/{runners-CUpBpSji.js → runners-DvYVe9Dt.js} +1 -1
  63. package/apps/web/dist/assets/session-D2bjiA3P.js +2 -0
  64. package/apps/web/dist/assets/theme-CNJIC2be.js +12 -0
  65. package/apps/web/dist/assets/ui-Mplfhz_Z.js +16 -0
  66. package/apps/web/dist/assets/{useMutation-1fV4Nnxq.js → useMutation-8QRM-z4M.js} +1 -1
  67. package/apps/web/dist/assets/{viewers-ChriFcRy.js → viewers-CEocUV_2.js} +2 -2
  68. package/apps/web/dist/index.html +11 -11
  69. package/apps/web/dist/mcp/flow.html +65 -65
  70. package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +8 -2
  71. package/node_modules/@engenty/wizards/dist/plugin/thread.js +30 -0
  72. package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +168 -0
  73. package/node_modules/@engenty/wizards-shared/dist/definition.js +52 -0
  74. package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +6 -0
  75. package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +6 -0
  76. package/node_modules/@engenty/wizards-shared/dist/fit.d.ts +2 -0
  77. package/node_modules/@engenty/wizards-shared/dist/fit.js +4 -0
  78. package/node_modules/@engenty/wizards-shared/dist/knowledge.d.ts +5 -0
  79. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +8 -1
  80. package/node_modules/@engenty/wizards-shared/dist/run.js +8 -0
  81. package/node_modules/@engenty/wizards-shared/dist/runner-texts.d.ts +7 -1
  82. package/node_modules/@engenty/wizards-shared/dist/runner-texts.js +6 -0
  83. package/package.json +1 -1
  84. package/plugin/.claude-plugin/plugin.json +1 -1
  85. package/plugin/plugin.json +1 -1
  86. package/apps/web/dist/assets/CapabilitiesPage-BlZP8DYb.js +0 -2
  87. package/apps/web/dist/assets/EditorPage-CrMVsgUt.js +0 -3
  88. package/apps/web/dist/assets/Marketplace-Cty40VwG.js +0 -2
  89. package/apps/web/dist/assets/NewWizardPage-CfVe_4a2.js +0 -7
  90. package/apps/web/dist/assets/OnboardingPage-D3SEpTmt.js +0 -1
  91. package/apps/web/dist/assets/PreviewPane-CQDKQO6z.js +0 -7
  92. package/apps/web/dist/assets/PublicRunner-BDZNnlQw.js +0 -1
  93. package/apps/web/dist/assets/SettingsPage-Bgurv3l2.js +0 -2
  94. package/apps/web/dist/assets/SetupPage-C3km8vqv.js +0 -1
  95. package/apps/web/dist/assets/SkillEditor-BaEiqqXl.js +0 -1
  96. package/apps/web/dist/assets/SpacePage-D9PXLSU_.js +0 -2
  97. package/apps/web/dist/assets/changelog-DwgWiSZb.js +0 -1
  98. package/apps/web/dist/assets/connection-sign-in-hI3HXhq4.js +0 -1
  99. package/apps/web/dist/assets/i18n-BBzMbGoo.js +0 -55
  100. package/apps/web/dist/assets/session-CMQo8P-G.js +0 -2
  101. package/apps/web/dist/assets/theme-CdX0marK.js +0 -11
  102. 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 db
716
- .update(schema.run)
717
- .set({
718
- state: {
719
- ...run.state,
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?.state ?? run.state;
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
- await db.update(schema.run).set({ state }).where(eq(schema.run.id, run.id));
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
- : "running";
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` leaves the classifier out. While the `broker` switch is on, a call
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 embed([query]).catch(() => null);
771
+ const embedded = await queryVector(query, opts.check === false ? QUICK_MS : VECTOR_MS);
764
772
  if (embedded) {
765
- const question = vectorBytes(embedded.vectors[0]);
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.vectors[0]), take));
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 { hits: [], candidates: 0, checked: false, filtered: filter?.size ?? null, hidden: [] };
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,5 +1,6 @@
1
1
  import { and, eq, inArray } from "drizzle-orm";
2
2
  import { db, schema } from "../db/client.js";
3
+ import { localText } from "../documents/parse.js";
3
4
  import { ServiceError } from "./errors.js";
4
5
  import { spaceFileContent } from "./space-files.js";
5
6
  /** At most this many files go with one message. */
@@ -14,6 +15,23 @@ const MODEL_READS = {
14
15
  };
15
16
  /** Where an upload goes among the space's files: pictures and media are assets, the rest documents. */
16
17
  export const fileKind = (mime) => /^(image|audio|video)\//.test(mime) ? "asset" : "document";
18
+ /** How much of a file's text a message hands the model; the rest it reads in the space's files. */
19
+ const TEXT_CHARS = 20_000;
20
+ /** Begins the text of a file the model gets beside it; the chat doesn't show it. */
21
+ const TEXT_MARK = "(Text of ";
22
+ /** A file's text for the model, read on this computer (OCR for scans and pictures); none if empty. */
23
+ async function textOf(name, mime, data) {
24
+ const parsed = await localText({ data, name, mime }).catch((err) => {
25
+ console.error("[work-files]", name, err);
26
+ return null;
27
+ });
28
+ const text = parsed?.markdown.trim();
29
+ if (!text) {
30
+ return null;
31
+ }
32
+ const cut = text.length > TEXT_CHARS;
33
+ return `${TEXT_MARK}"${name}", read on this computer${parsed?.via === "ocr" ? " by OCR" : ""}${cut ? ", its start" : ""}:)\n${text.slice(0, TEXT_CHARS)}`;
34
+ }
17
35
  /** The line the model gets for files it does not read itself; the chat doesn't show it. */
18
36
  const elsewhere = (names) => `(Attached: ${names.join(", ")}. In the space's files; search_space finds what they say once they are read.)`;
19
37
  /** The space's files a message names, in its order; one not in the chat's space is refused. */
@@ -55,6 +73,11 @@ who) {
55
73
  filename: row.name,
56
74
  });
57
75
  }
76
+ // Its text as well: a model that takes no files, or a scan, still gets what it says.
77
+ const said = await textOf(row.name, row.mime, data);
78
+ if (said) {
79
+ parts.push({ type: "text", text: said });
80
+ }
58
81
  kept.push({ ...file, read });
59
82
  }
60
83
  const told = kept.filter((f) => !f.read).map((f) => f.name);
@@ -73,7 +96,8 @@ export function viewParts(spaceId, parts, files) {
73
96
  }
74
97
  const line = elsewhere(files.filter((f) => !f.read).map((f) => f.name));
75
98
  return [
76
- ...parts.filter((p) => p.type !== "file" && !(p.type === "text" && p.text === line)),
99
+ ...parts.filter((p) => p.type !== "file" &&
100
+ !(p.type === "text" && (p.text === line || String(p.text).startsWith(TEXT_MARK)))),
77
101
  ...files.map((f) => ({
78
102
  type: "file",
79
103
  fileId: f.id,
@@ -225,6 +225,9 @@ function standIn(wizard, userId) {
225
225
  origin: null,
226
226
  client: null,
227
227
  status: "done",
228
+ wakeAt: null,
229
+ claim: 0,
230
+ rev: 0,
228
231
  cursor: null,
229
232
  state: { values: {}, outputs: {}, history: [], notes: {} },
230
233
  error: null,
@@ -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
- /** The run is done with runners for now: a page, a review or the end. */
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. False: someone else has it, or the tenant is at its
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
- return result.rowsAffected > 0;
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
- /** The runs in line: unowned, or whose owner fell silent. */
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(control.runIndex.createdAt);
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(control.runIndex.createdAt)
245
+ .orderBy(inLineSince)
214
246
  .limit(1);
215
- return { runners, oldestWaiting: oldest?.createdAt ?? null };
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{Jn as r,fn as i,in as a,ln as o,mn as s,nn as c,rn as l,tn as u}from"./ui-BCfu5sia.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-BBzMbGoo.js";import{g,h as _,m as v,t as y,u as b}from"./UpdateCheck-C7I43zFZ.js";import{ReleaseNotes as x,loadReleases as S,releaseDate as C,releaseLabel as w}from"./ChangelogDialog-CDN7kMs1.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,i]=(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||i(``)},[e]);let s=r.trim().toLowerCase(),l=e=>s?e.filter(e=>k(s,e.name,e.license,h(e.description))):e,u=e=>s?e.filter(e=>k(s,e.name,e.license,e.version)):e,f=l(E),p=l(D),m=t?[{id:`shared`,label:h(`about.creditsShared`),packages:u(t.shared)},...t.groups.map(e=>({id:e.id,label:e.label,packages:u(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)(a,{type:`search`,value:r,placeholder:h(`about.search`),onChange:e=>i(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)(o,{})}):m.length>0?(0,O.jsx)(j,{title:h(`about.creditsDeps`),hint:s?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)(c,{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 a=e?.mode===`local`,{data:c,latest:l}=_(a&&t),[u,d]=(0,T.useState)(null),[f,p]=(0,T.useState)(n);(0,T.useEffect)(()=>p(n),[n]);let E=v(F.indexOf(f)),D=c?.newer&&l?l:g;(0,T.useEffect)(()=>{if(!t)return;let e=!1;return d(null),S(D===`0.16.0`?void 0:D).then(t=>{e||d(t)}),()=>{e=!0}},[t,D]);let k=u?.find(e=>e.version===`v${D}`)??u?.[0]??null,A=u?.filter(e=>e!==k)??[],j=a?c?.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}`)}`:``]})]}),a?(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)(i,{value:f,onChange:p,options:F.map(e=>({id:e,label:I(e)})),label:h(`about.title`)})}),(0,O.jsxs)(`div`,{className:s(`mt-5`,b(E)),children:[f===`new`?u===null?(0,O.jsx)(`div`,{className:`flex justify-center py-6 text-ink-3`,children:(0,O.jsx)(o,{})}):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)(u,{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)(l,{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};
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};