@engenty/wizards-runtime 0.16.2 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/apps/runtime/dist/agents/studio-assistant.js +13 -6
  2. package/apps/runtime/dist/assistant/knows.js +15 -2
  3. package/apps/runtime/dist/broker/call.js +16 -3
  4. package/apps/runtime/dist/broker/grant.js +25 -1
  5. package/apps/runtime/dist/broker/index.js +2 -2
  6. package/apps/runtime/dist/broker/log.js +30 -11
  7. package/apps/runtime/dist/broker/rwx.js +14 -2
  8. package/apps/runtime/dist/broker/send.js +84 -32
  9. package/apps/runtime/dist/connectors/space-connections.js +47 -2
  10. package/apps/runtime/dist/docs/dev/broker.md +72 -26
  11. package/apps/runtime/dist/docs/dev/plugins/space.md +13 -2
  12. package/apps/runtime/dist/docs/user-guide/capabilities.md +51 -7
  13. package/apps/runtime/dist/docs/user-guide/connectors.md +6 -3
  14. package/apps/runtime/dist/docs/user-guide/protocol.md +30 -4
  15. package/apps/runtime/dist/docs/user-guide/together.md +4 -4
  16. package/apps/runtime/dist/elements/knowledge.js +16 -12
  17. package/apps/runtime/dist/engine/steps.js +3 -2
  18. package/apps/runtime/dist/index.js +8 -0
  19. package/apps/runtime/dist/live/hub.js +17 -3
  20. package/apps/runtime/dist/live/origin.js +6 -4
  21. package/apps/runtime/dist/live/views.js +38 -7
  22. package/apps/runtime/dist/models.js +18 -0
  23. package/apps/runtime/dist/prompts/tools.md +1 -1
  24. package/apps/runtime/dist/routes/api.js +2 -2
  25. package/apps/runtime/dist/routes/broker.js +59 -20
  26. package/apps/runtime/dist/routes/live.js +4 -2
  27. package/apps/runtime/dist/routes/studio.js +13 -2
  28. package/apps/runtime/dist/services/api.js +4 -2
  29. package/apps/runtime/dist/services/errors.js +1 -0
  30. package/apps/runtime/dist/services/knowledge.js +93 -27
  31. package/apps/runtime/dist/services/members-studio.js +22 -2
  32. package/apps/runtime/dist/services/space-categories.js +83 -5
  33. package/apps/runtime/dist/services/space-index.js +77 -21
  34. package/apps/runtime/dist/services/space-origin.js +28 -11
  35. package/apps/runtime/dist/services/work-ai.js +15 -5
  36. package/apps/runtime/dist/sharing/jobs.js +2 -0
  37. package/apps/runtime/dist/sync/hub.js +17 -3
  38. package/apps/runtime/dist/texts.js +6 -4
  39. package/apps/runtime/dist/tools/index.js +13 -7
  40. package/apps/runtime/dist/tools/web-search.js +36 -0
  41. package/apps/web/dist/assets/{AboutDialog-BCcD8hKm.js → AboutDialog-B2Xmxyj4.js} +1 -1
  42. package/apps/web/dist/assets/{BlockEditor-DgaUm2pR.js → BlockEditor-D0HoUSih.js} +1 -1
  43. package/apps/web/dist/assets/CapabilitiesPage-C1th2cZE.js +2 -0
  44. package/apps/web/dist/assets/{ChangelogDialog-B08elwyr.js → ChangelogDialog-BIrJbAKi.js} +1 -1
  45. package/apps/web/dist/assets/{CodeEditor-BiyOk_SC.js → CodeEditor-DUVcXI5P.js} +1 -1
  46. package/apps/web/dist/assets/{EditorPage-EMFTHEYD.js → EditorPage-56sIqEfF.js} +1 -1
  47. package/apps/web/dist/assets/{FlowPreview-DF_6TvZ0.js → FlowPreview-BIag8_Be.js} +1 -1
  48. package/apps/web/dist/assets/{LangSwitch-Ba4OWLzJ.js → LangSwitch-CJ00IgaO.js} +1 -1
  49. package/apps/web/dist/assets/{Marketplace-DqziLf66.js → Marketplace-D7-ot9Dz.js} +2 -2
  50. package/apps/web/dist/assets/{NewWizardChannels-CsIGp0nZ.js → NewWizardChannels-DI3SQ4iS.js} +1 -1
  51. package/apps/web/dist/assets/{NewWizardPage-CzQAkKMy.js → NewWizardPage-CytheHxX.js} +1 -1
  52. package/apps/web/dist/assets/{OnboardingPage-B9gr2OX5.js → OnboardingPage-_91Pa8Ad.js} +1 -1
  53. package/apps/web/dist/assets/{PreviewPane-DSOV3o-1.js → PreviewPane-BDsYm-_K.js} +2 -2
  54. package/apps/web/dist/assets/ProtocolSection-D_zaxHEL.js +1 -0
  55. package/apps/web/dist/assets/{PublicRunner-BVs8-Vu3.js → PublicRunner-CEgXSk3r.js} +1 -1
  56. package/apps/web/dist/assets/{ReadOnly--4CIJCDD.js → ReadOnly-CWf5x74a.js} +1 -1
  57. package/apps/web/dist/assets/SettingsPage-Dr8SDk-L.js +2 -0
  58. package/apps/web/dist/assets/{SetupPage-9Zk-KUGA.js → SetupPage-B68n0l4I.js} +1 -1
  59. package/apps/web/dist/assets/{SharePage-D_Ab0gjr.js → SharePage-DfznN7ar.js} +1 -1
  60. package/apps/web/dist/assets/{SkillEditor-DvtameHg.js → SkillEditor-BIcIczRc.js} +1 -1
  61. package/apps/web/dist/assets/{Skills-Cf1Kl4Fy.js → Skills-CN4QE7Kx.js} +1 -1
  62. package/apps/web/dist/assets/{SpacePage-CyqVzX9b.js → SpacePage-DiVTwhnJ.js} +2 -2
  63. package/apps/web/dist/assets/{UpdateCheck-DweZBVP6.js → UpdateCheck-QhBI3rlQ.js} +2 -2
  64. package/apps/web/dist/assets/changelog-a_CuplMX.js +1 -0
  65. package/apps/web/dist/assets/{code-editor-B1RbFTAZ.js → code-editor-DkPo1C-L.js} +2 -2
  66. package/apps/web/dist/assets/{host-CKS5U5Vg.js → host-D6H6Z9Jp.js} +6 -6
  67. package/apps/web/dist/assets/i18n-BaPKbQ1s.js +55 -0
  68. package/apps/web/dist/assets/{index-w-3J3ZJ9.css → index-CCUG6Vnh.css} +1 -1
  69. package/apps/web/dist/assets/{index-Ckcn5vy7.js → index-De0Wb42y.js} +3 -3
  70. package/apps/web/dist/assets/{read-aloud-Bq88XUHC.js → read-aloud-CnFwDSGD.js} +1 -1
  71. package/apps/web/dist/assets/{runners-DvYVe9Dt.js → runners-0sTPbWzr.js} +1 -1
  72. package/apps/web/dist/assets/{session-D2bjiA3P.js → session-BMiUrqHg.js} +1 -1
  73. package/apps/web/dist/assets/{theme-CNJIC2be.js → theme-CkNTe-_Z.js} +1 -1
  74. package/apps/web/dist/assets/{ui-Mplfhz_Z.js → ui-DAk_vjrL.js} +1 -1
  75. package/apps/web/dist/assets/{useMutation-8QRM-z4M.js → useMutation-isHfB33W.js} +1 -1
  76. package/apps/web/dist/assets/{viewers-CEocUV_2.js → viewers-ijNZHJFG.js} +2 -2
  77. package/apps/web/dist/index.html +12 -12
  78. package/apps/web/dist/mcp/flow.html +2 -2
  79. package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +7 -2
  80. package/node_modules/@engenty/wizards-shared/dist/connectors.d.ts +13 -1
  81. package/node_modules/@engenty/wizards-shared/dist/connectors.js +8 -0
  82. package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +12 -0
  83. package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +12 -0
  84. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +3 -0
  85. package/node_modules/@engenty/wizards-shared/dist/run.js +6 -0
  86. package/node_modules/@engenty/wizards-shared/dist/spaces.d.ts +3 -2
  87. package/node_modules/@engenty/wizards-shared/dist/spaces.js +12 -3
  88. package/package.json +1 -1
  89. package/plugin/.claude-plugin/plugin.json +1 -1
  90. package/plugin/plugin.json +1 -1
  91. package/apps/web/dist/assets/CapabilitiesPage-DuJJV1ll.js +0 -2
  92. package/apps/web/dist/assets/SettingsPage-z2u8lSe2.js +0 -2
  93. package/apps/web/dist/assets/changelog-C85v9OWg.js +0 -1
  94. package/apps/web/dist/assets/connection-sign-in-CaVvh5GQ.js +0 -1
  95. package/apps/web/dist/assets/i18n-Bymk5Ev-.js +0 -55
@@ -232,17 +232,95 @@ export async function listCategories(spaceId) {
232
232
  count: v.n,
233
233
  summary: Boolean(v.summary),
234
234
  })),
235
- range: c.type === "number" && range?.minNum !== null && range?.minNum !== undefined
236
- ? { min: range.minNum, max: range.maxNum ?? range.minNum }
237
- : c.type === "date" && range?.minAt !== null && range?.minAt !== undefined
238
- ? { min: dateText(range.minAt), max: dateText(range.maxAt ?? range.minAt) }
239
- : null,
235
+ range: rangeOf(c.type, range),
240
236
  alike: [],
241
237
  };
242
238
  category.alike = alikeValues(category.values);
243
239
  return category;
244
240
  });
245
241
  }
242
+ /** A number's or a date's lowest and highest value, as a category shows them. */
243
+ function rangeOf(type, of) {
244
+ if (type === "number" && of?.minNum !== null && of?.minNum !== undefined) {
245
+ return { min: of.minNum, max: of.maxNum ?? of.minNum };
246
+ }
247
+ if (type === "date" && of?.minAt !== null && of?.minAt !== undefined) {
248
+ return { min: dateText(of.minAt), max: dateText(of.maxAt ?? of.minAt) };
249
+ }
250
+ return null;
251
+ }
252
+ /** The use of the space's categories by place, for a reader who may not read every place. */
253
+ export async function categoryUse(spaceId) {
254
+ const ids = (await categoryRows(spaceId)).map((c) => c.id);
255
+ if (!ids.length) {
256
+ return { items: [], values: [] };
257
+ }
258
+ const t = schema.spaceItemCategory;
259
+ const row = schema.spaceTableRow;
260
+ const file = schema.spaceMountFile;
261
+ // A row lies in its table, a mounted file in its mount.
262
+ const tableId = sql `coalesce(${t.tableId}, ${row.tableId})`;
263
+ const place = { pageId: t.pageId, tableId, fileId: t.fileId, mountId: file.mountId };
264
+ const [items, values] = await Promise.all([
265
+ db
266
+ .select({
267
+ ...place,
268
+ categoryId: t.categoryId,
269
+ n: sql `count(DISTINCT coalesce(${t.pageId}, ${t.rowId}, ${t.tableId}, ${t.fileId}, ${t.mountFileId}))`,
270
+ minNum: sql `min(${t.num})`,
271
+ maxNum: sql `max(${t.num})`,
272
+ minAt: sql `min(${t.at})`,
273
+ maxAt: sql `max(${t.at})`,
274
+ })
275
+ .from(t)
276
+ .leftJoin(row, eq(row.id, t.rowId))
277
+ .leftJoin(file, eq(file.id, t.mountFileId))
278
+ .where(inArray(t.categoryId, ids))
279
+ .groupBy(t.categoryId, t.pageId, tableId, t.fileId, file.mountId),
280
+ db
281
+ .select({ ...place, valueId: t.valueId, n: sql `count(*)` })
282
+ .from(t)
283
+ .leftJoin(row, eq(row.id, t.rowId))
284
+ .leftJoin(file, eq(file.id, t.mountFileId))
285
+ .where(and(inArray(t.categoryId, ids), isNotNull(t.valueId)))
286
+ .groupBy(t.valueId, t.pageId, tableId, t.fileId, file.mountId),
287
+ ]);
288
+ return { items, values };
289
+ }
290
+ /**
291
+ * The categories counted over a part of their use: how many items have each, a choice's values
292
+ * and the ranges, from `use` alone. A value that only items outside it have is left out; one no
293
+ * item has stays, as the category's own.
294
+ */
295
+ export function categoriesOver(all, use) {
296
+ const byValue = new Map();
297
+ for (const u of use.values) {
298
+ if (u.valueId) {
299
+ byValue.set(u.valueId, (byValue.get(u.valueId) ?? 0) + u.n);
300
+ }
301
+ }
302
+ const least = (list) => list.reduce((m, x) => (x === null ? m : m === null ? x : Math.min(m, x)), null);
303
+ const most = (list) => list.reduce((m, x) => (x === null ? m : m === null ? x : Math.max(m, x)), null);
304
+ return all.map((c) => {
305
+ const mine = use.items.filter((u) => u.categoryId === c.id);
306
+ const values = c.values
307
+ .filter((v) => byValue.has(v.id) || v.count === 0)
308
+ .map((v) => ({ ...v, count: byValue.get(v.id) ?? 0 }));
309
+ const kept = new Set(values.map((v) => v.id));
310
+ return {
311
+ ...c,
312
+ count: mine.reduce((sum, u) => sum + u.n, 0),
313
+ values,
314
+ range: rangeOf(c.type, {
315
+ minNum: least(mine.map((u) => u.minNum)),
316
+ maxNum: most(mine.map((u) => u.maxNum)),
317
+ minAt: least(mine.map((u) => u.minAt)),
318
+ maxAt: most(mine.map((u) => u.maxAt)),
319
+ }),
320
+ alike: c.alike.filter(([a, b]) => kept.has(a) && kept.has(b)),
321
+ };
322
+ });
323
+ }
246
324
  /** Pairs of a choice's values that look like one value written two ways, to offer merging. */
247
325
  function alikeValues(list) {
248
326
  const pairs = [];
@@ -1,7 +1,7 @@
1
1
  import { formatTableCell } from "@engenty/wizards-shared/engenty/data-tables";
2
2
  import { featureOn } from "@engenty/wizards-shared/features";
3
3
  import { embedMany } from "ai";
4
- import { and, eq, inArray, isNotNull, isNull, ne, notInArray, or, sql, } from "drizzle-orm";
4
+ import { and, asc, eq, gt, inArray, isNotNull, isNull, ne, notInArray, or, sql, } from "drizzle-orm";
5
5
  import { brokerOn, forbidden, pageResources, readable, readsEverything, tableResources, } from "../broker/rwx.js";
6
6
  import { db, schema, withTenant } from "../db/client.js";
7
7
  import { createSearchChunks } from "../engenty/search-index/chunks.js";
@@ -106,7 +106,7 @@ async function writeUnits(scope, units) {
106
106
  }));
107
107
  }
108
108
  if (units.some((u) => u.kind && !pictures.has(pictureKey(u)))) {
109
- queuePictures();
109
+ queueVectors();
110
110
  }
111
111
  }
112
112
  const SHEET = /^\s*<!--\s*S\.\s*(\d+)\s*-->\s*$/;
@@ -484,30 +484,86 @@ export async function flushIndex() {
484
484
  await working;
485
485
  }
486
486
  await working;
487
- await picturesRunning;
487
+ await vectorsRunning;
488
488
  }
489
- // --- pictures -----------------------------------------------------------------------------
489
+ // --- vectors in the background ------------------------------------------------------------
490
490
  // A picture's vector comes after its unit: a picture of a PDF page takes a second or more to
491
- // make and embed, and the index of a page someone types in must not wait for it. Tenant after
492
- // tenant, file after file, units without a vector of the embedding model at hand.
493
- const picturesWaiting = new Set();
494
- let picturesRunning = null;
495
- /** Gives the pictures of the tenant at hand their vectors, soon. */
496
- export function queuePictures() {
497
- picturesWaiting.add(currentTenant());
498
- if (picturesRunning) {
491
+ // make and embed, and the index of a page someone types in must not wait for it. A text's comes
492
+ // with its unit, unless the model failed, none was set up then, or another one is now: on a
493
+ // Manage-App's runtime the binding changes without a word to the runtime. Tenant after tenant,
494
+ // units without a vector of the embedding model at hand.
495
+ const vectorsWaiting = new Set();
496
+ let vectorsRunning = null;
497
+ /** Gives the units of the tenant at hand the vectors they lack, soon. */
498
+ export function queueVectors() {
499
+ vectorsWaiting.add(currentTenant());
500
+ if (vectorsRunning) {
499
501
  return;
500
502
  }
501
- picturesRunning = (async () => {
502
- while (picturesWaiting.size) {
503
- const [tenant] = picturesWaiting;
504
- picturesWaiting.delete(tenant);
505
- await withTenant(tenant, embedPictures).catch((err) => console.error("[space-index] pictures", err));
503
+ vectorsRunning = (async () => {
504
+ while (vectorsWaiting.size) {
505
+ const [tenant] = vectorsWaiting;
506
+ vectorsWaiting.delete(tenant);
507
+ await withTenant(tenant, async () => {
508
+ await embedTexts();
509
+ await embedPictures();
510
+ }).catch((err) => console.error("[space-index] vectors", err));
506
511
  }
507
512
  })().finally(() => {
508
- picturesRunning = null;
513
+ vectorsRunning = null;
509
514
  });
510
515
  }
516
+ /** Texts sent at once: a search's question waits behind them in a busy Ollama. */
517
+ const TEXT_BATCH = 32;
518
+ /** The vectors of the text units that lack one of the model at hand. */
519
+ async function embedTexts() {
520
+ const resolved = await embeddingModel().catch(() => null);
521
+ if (!resolved) {
522
+ return;
523
+ }
524
+ // Past a batch that failed: the next round tries it again.
525
+ let after = 0;
526
+ let inRow = 0;
527
+ const started = Date.now();
528
+ let done = 0;
529
+ for (;;) {
530
+ const todo = await db
531
+ .select({ id: schema.spaceChunk.id, text: schema.spaceChunk.text })
532
+ .from(schema.spaceChunk)
533
+ .where(and(isNull(schema.spaceChunk.kind), gt(schema.spaceChunk.id, after), or(isNull(schema.spaceChunk.model), ne(schema.spaceChunk.model, resolved.ref))))
534
+ .orderBy(asc(schema.spaceChunk.id))
535
+ .limit(TEXT_BATCH);
536
+ if (!todo.length) {
537
+ break;
538
+ }
539
+ after = todo[todo.length - 1].id;
540
+ try {
541
+ const embedded = await embed(todo.map((u) => u.text));
542
+ if (!embedded) {
543
+ break;
544
+ }
545
+ // A unit written again in the meantime has a new id, and its vector already.
546
+ for (const [i, u] of todo.entries()) {
547
+ await db
548
+ .update(schema.spaceChunk)
549
+ .set({ embedding: vectorBytes(embedded.vectors[i]), model: embedded.model })
550
+ .where(eq(schema.spaceChunk.id, u.id));
551
+ }
552
+ done += todo.length;
553
+ inRow = 0;
554
+ }
555
+ catch (err) {
556
+ // The model is not there or not working: the next round tries again.
557
+ if (++inRow >= 3) {
558
+ console.error("[space-index] embedding texts failed", err.message);
559
+ break;
560
+ }
561
+ }
562
+ }
563
+ if (done) {
564
+ console.log(`[space-index] embedded ${done} texts with ${resolved.ref} in ${Math.round((Date.now() - started) / 1000)} s`);
565
+ }
566
+ }
511
567
  /** The pictures of the bytes `hash`, by page (0: a picture file itself), made when asked for. */
512
568
  async function picturesOf(hash, pdf) {
513
569
  const data = hash ? await getBlob(hash).catch(() => null) : null;
@@ -1126,8 +1182,8 @@ export async function reindexAll() {
1126
1182
  }
1127
1183
  /**
1128
1184
  * What the index lacks, added at start: image, video and sound assets it does not hold yet; where
1129
- * the embedding model takes pictures, the picture files and PDFs without picture units, and the
1130
- * pictures without a vector of the model at hand.
1185
+ * the embedding model takes pictures, the picture files and PDFs without picture units; and the
1186
+ * units without a vector of the model at hand.
1131
1187
  */
1132
1188
  export async function indexMissingAssets() {
1133
1189
  const rows = await db.all(sql `
@@ -1137,6 +1193,7 @@ export async function indexMissingAssets() {
1137
1193
  for (const row of rows.filter(indexedFile)) {
1138
1194
  queueIndex(`f:${row.id}`);
1139
1195
  }
1196
+ queueVectors();
1140
1197
  if (!(await embeddingModel().catch(() => null))?.embedImage) {
1141
1198
  return;
1142
1199
  }
@@ -1148,5 +1205,4 @@ export async function indexMissingAssets() {
1148
1205
  for (const row of unseen.filter(indexedFile)) {
1149
1206
  queueIndex(`f:${row.id}`);
1150
1207
  }
1151
- queuePictures();
1152
1208
  }
@@ -1,6 +1,6 @@
1
1
  import { and, desc, eq, isNull } from "drizzle-orm";
2
2
  import { currentCaller } from "../broker/caller.js";
3
- import { currentReader, subjectsOfCaller } from "../broker/rwx.js";
3
+ import { currentReader, readable, subjectsOfCaller } from "../broker/rwx.js";
4
4
  import { db, schema } from "../db/client.js";
5
5
  import { UnreadableDocument } from "../documents/parse.js";
6
6
  import { ServiceError } from "./errors.js";
@@ -11,9 +11,21 @@ import { putCategory, setItemCategories } from "./space-categories.js";
11
11
  import { listOrigin, putOriginPage, putOriginTable, removeOrigin } from "./space-data.js";
12
12
  import { putOriginFile, spaceFileContent } from "./space-files.js";
13
13
  import { queueIndex } from "./space-index.js";
14
+ /**
15
+ * As whom a plugin reads the space's Knowledge: as whom it was called for, and as itself. A tool
16
+ * in a step or a Work chat reads as its caller, an HTTP route as the person it answers, a job as
17
+ * the runtime itself (readingAs). Anything else reads as the plugin alone, which no seed allows.
18
+ * A deny for the plugin always wins.
19
+ */
20
+ async function readerOf(origin) {
21
+ const caller = currentCaller();
22
+ const plugin = { kind: "plugin", id: origin };
23
+ return [...(caller ? await subjectsOfCaller(caller) : currentReader()), plugin];
24
+ }
14
25
  /**
15
26
  * `server.spaceData` of a plugin: Knowledge it writes under keys of its own, with categories. The
16
- * plugin's id is the origin of everything it writes; a person who changes an item keeps it.
27
+ * plugin's id is the origin of everything it writes; a person who changes an item keeps it. What
28
+ * it reads of the space (`readPages`, `files`, `readFile`), it reads as `readerOf` says.
17
29
  */
18
30
  export function originData(origin) {
19
31
  return {
@@ -176,7 +188,11 @@ export function originData(origin) {
176
188
  where: and(eq(schema.spacePage.spaceId, space), isNull(schema.spacePage.wizardId), opts?.parent ? eq(schema.spacePage.parentId, opts.parent) : undefined),
177
189
  orderBy: [schema.spacePage.position, schema.spacePage.title],
178
190
  });
179
- return rows.map((r) => ({
191
+ // Only the pages its reader may read: a page, the document behind it, the folders it lies in.
192
+ const ok = await readable(space, await readerOf(origin), rows.map((r) => ({ kind: "page", id: r.id, fileId: r.fileId })));
193
+ return rows
194
+ .filter((r) => ok.has(r.id))
195
+ .map((r) => ({
180
196
  id: r.id,
181
197
  title: r.title,
182
198
  path: tree.get(r.id)?.path ?? `pages/${r.slug ?? r.id}`,
@@ -192,7 +208,14 @@ export function originData(origin) {
192
208
  where: and(eq(schema.spaceFile.spaceId, space), eq(schema.spaceFile.kind, kind), eq(schema.spaceFile.status, "ready")),
193
209
  orderBy: [desc(schema.spaceFile.updatedAt)],
194
210
  });
195
- return rows.map((r) => ({
211
+ // A document is listed to whom may read it; a logo, pattern or asset is the brand's, not
212
+ // Knowledge, and asks nobody (space-files.ts).
213
+ const ok = kind === "document"
214
+ ? await readable(space, await readerOf(origin), rows.map((r) => ({ kind: "document", id: r.id })))
215
+ : null;
216
+ return rows
217
+ .filter((r) => !ok || ok.has(r.id))
218
+ .map((r) => ({
196
219
  id: r.id,
197
220
  name: r.name,
198
221
  mime: r.mime,
@@ -202,13 +225,7 @@ export function originData(origin) {
202
225
  }));
203
226
  },
204
227
  async readFile(space, fileId) {
205
- // As whom the plugin was called for, and as itself: a tool in a step or a Work chat as its
206
- // caller, an HTTP route as the person it answers, a job as the runtime itself (readingAs).
207
- // Anything else reads as the plugin alone, which no seed allows. A deny for it always wins.
208
- const caller = currentCaller();
209
- const plugin = { kind: "plugin", id: origin };
210
- const who = [...(caller ? await subjectsOfCaller(caller) : currentReader()), plugin];
211
- const { row, data } = await spaceFileContent(space, fileId, who);
228
+ const { row, data } = await spaceFileContent(space, fileId, await readerOf(origin));
212
229
  return {
213
230
  id: row.id,
214
231
  name: row.name,
@@ -9,7 +9,7 @@ import { elementTools } from "../elements/catalogue.js";
9
9
  import { currentFeatures } from "../features.js";
10
10
  import { HarnessModel } from "../harness/index.js";
11
11
  import { managed } from "../manage.js";
12
- import { attachTools, chatModel, gatewayTools } from "../models.js";
12
+ import { attachTools, chatModel, gatewayTools, toolAccess, } from "../models.js";
13
13
  import { pluginsOf } from "../plugins/registry.js";
14
14
  import { prompt } from "../prompts.js";
15
15
  import { sandboxCapabilities, shellToolDescription } from "../sandbox/index.js";
@@ -17,6 +17,7 @@ import { currentTenant } from "../tenants/tenant.js";
17
17
  import { assistantToolPlugin, assistantToolRisk, assistantToolsOf } from "../tools/plugin.js";
18
18
  import { clip } from "../tools/shared.js";
19
19
  import { skillsBlock } from "../tools/skills.js";
20
+ import { gatewayWebSearch } from "../tools/web-search.js";
20
21
  import { roleOf } from "./access.js";
21
22
  import { ClientSteps } from "./client-steps.js";
22
23
  import { activeSkills } from "./skills.js";
@@ -137,7 +138,7 @@ async function clientTools(space, userId, signal, chatId) {
137
138
  * and the web the person turned off (`choice`) left out. A client gets `clientTools` alone.
138
139
  * `role`: the person's, where the session knows it; else the organization's list says.
139
140
  */
140
- async function toolsFor(resolved, space, userId, signal, choice = {}, chatId = null, approved = null, known = null) {
141
+ async function toolsFor(resolved, space, userId, signal, choice = {}, chatId = null, approved = null, known = null, web = null) {
141
142
  const role = known ?? (await roleOf(userId));
142
143
  if (role === "client") {
143
144
  return clientTools(space, userId, signal, chatId ?? approved?.chatId ?? null);
@@ -184,7 +185,12 @@ async function toolsFor(resolved, space, userId, signal, choice = {}, chatId = n
184
185
  delete tools[name];
185
186
  }
186
187
  }
187
- if (choice.web !== false && resolved?.vendor === "anthropic") {
188
+ // The gateway's search where the gateway is reached, for every model; else the model's own.
189
+ const access = choice.web !== false ? web : null;
190
+ if (access) {
191
+ tools.web_search = gatewayWebSearch(access);
192
+ }
193
+ else if (choice.web !== false && resolved?.vendor === "anthropic") {
188
194
  tools.web_search = anthropic.tools.webSearch_20250305({ maxUses: 5 });
189
195
  }
190
196
  else if (choice.web !== false && resolved?.gateway) {
@@ -253,9 +259,13 @@ export async function toolToRun(space, userId, name, signal, approved) {
253
259
  * composer.
254
260
  */
255
261
  export async function workTurn(turn, signal, steps, choice = {}) {
256
- const resolved = await chatModel(await chatTurnWay(managed), choice.extra ? "high" : "standard");
262
+ // The gateway's way for web search, asked beside the model rather than after it.
263
+ const [resolved, web] = await Promise.all([
264
+ chatTurnWay(managed).then((way) => chatModel(way, choice.extra ? "high" : "standard")),
265
+ choice.web !== false ? toolAccess() : null,
266
+ ]);
257
267
  const client = turn.role === "client";
258
- const made = gated(await toolsFor(resolved, turn.space, turn.userId, signal, choice, turn.chatId, null, turn.role ?? null), turn);
268
+ const made = gated(await toolsFor(resolved, turn.space, turn.userId, signal, choice, turn.chatId, null, turn.role ?? null, web), turn);
259
269
  const tools = resolved.model instanceof HarnessModel ? steps.wrap(made) : made;
260
270
  attachTools(resolved, tools);
261
271
  const skills = client ? null : await spaceSkills(turn.space.id);
@@ -100,6 +100,8 @@ function refusalLine(refused) {
100
100
  switch (refused) {
101
101
  case "not_allowed_recipient":
102
102
  return line("shareGuestRecipient");
103
+ case "channel_not_fixed":
104
+ return line("shareGuestChannel");
103
105
  case "run_limit":
104
106
  return line("shareGuestRunMails", { mails: GUEST_MAILS_PER_RUN });
105
107
  case "day_limit":
@@ -5,6 +5,7 @@ import { getBlob, hasBlob, putBlobOf } from "../files/blobs.js";
5
5
  import { managed, tenantInfo } from "../manage.js";
6
6
  import { currentRole, isAdminRole, MEMBERS_EDIT_ONLY, mayBuild } from "../services/access.js";
7
7
  import { ServiceError } from "../services/errors.js";
8
+ import { studioSpaces } from "../services/members-studio.js";
8
9
  import { spaceLimit } from "../services/spaces.js";
9
10
  import { publishWizard, rotateShareLink, shareUrl } from "../services/wizards.js";
10
11
  import { codeOf } from "../tenants/control.js";
@@ -26,13 +27,18 @@ function requireSchema(theirs) {
26
27
  throw new ServiceError("refused", order(theirs) < order(tenantSchemaVersion) ? note("syncUpdateHere") : note("syncUpdateCloud"), { reason: "schema_mismatch", schema: tenantSchemaVersion });
27
28
  }
28
29
  }
29
- /** The organization as an install meets it: its schema, its number of spaces, its spaces. */
30
+ /**
31
+ * The organization as an install meets it: its schema, its number of spaces, its spaces. The
32
+ * install of a member meets the spaces whose Studio is open to members; the others refuse its
33
+ * pulls and pushes (services/members-studio.ts), so they are not offered to it.
34
+ */
30
35
  export async function syncOverview() {
31
- const spaces = await db.query.space.findMany({
36
+ const open = await studioSpaces();
37
+ const spaces = (await db.query.space.findMany({
32
38
  where: eq(schema.space.tenantId, currentTenant()),
33
39
  columns: { id: true, name: true, origin: true },
34
40
  orderBy: [schema.space.createdAt],
35
- });
41
+ })).filter((s) => !open || open.has(s.id));
36
42
  const info = managed ? await tenantInfo(currentTenant()).catch(() => null) : null;
37
43
  const limit = await spaceLimit();
38
44
  return {
@@ -45,6 +51,14 @@ export async function syncOverview() {
45
51
  spaces: await Promise.all(spaces.map(async (s) => ({ id: s.id, name: s.name, seq: await spaceSeq(s.id) }))),
46
52
  };
47
53
  }
54
+ /**
55
+ * What of the feed's changes an install hears as spaces to pull (`GET /sync/live`): for a
56
+ * member's install, none of a space whose Studio is closed to members.
57
+ */
58
+ export async function syncHears(changes) {
59
+ const open = await studioSpaces();
60
+ return open ? changes.filter((x) => !x.spaceId || open.has(x.spaceId)) : changes;
61
+ }
48
62
  /**
49
63
  * What changed in a space after `since`. From 0 it is every item of the space, a page at a
50
64
  * time (`cursor`); `next` then is the number the log stood at when the listing began.
@@ -152,8 +152,9 @@ const EN = {
152
152
  shareMailboxLimit: "The attachments are too large for this mailbox (at most 3 MB). Choose fewer files or share the link.",
153
153
  shareVisitorRecipients: "From here, an email goes to at most {recipients} addresses.",
154
154
  shareGuestRecipient: "From here, an email goes only to the address you gave in the wizard or to the team’s own addresses.",
155
- shareGuestRunMails: "This run has sent its {mails} emails.",
156
- shareGuestDayMails: "This wizard has sent its emails for today. Try again tomorrow.",
155
+ shareGuestChannel: "From here, no message goes to a Slack channel.",
156
+ shareGuestRunMails: "This run has sent its {mails} emails and messages.",
157
+ shareGuestDayMails: "This wizard has sent its emails and messages for today. Try again tomorrow.",
157
158
  shareConnectMailbox: "Connect a mailbox first.",
158
159
  shareSendingFrom: "Sending from {account}",
159
160
  shareSentTo: "Sent to {to}",
@@ -378,8 +379,9 @@ const DE = {
378
379
  shareMailboxLimit: "Die Anhänge sind zu groß für dieses Postfach (höchstens 3 MB). Wähle weniger Dateien oder teile den Link.",
379
380
  shareVisitorRecipients: "Von hier geht eine E-Mail an höchstens {recipients} Adressen.",
380
381
  shareGuestRecipient: "Von hier geht eine E-Mail nur an die Adresse, die du im Wizard angegeben hast, oder an Adressen des Teams.",
381
- shareGuestRunMails: "Dieser Lauf hat seine {mails} E-Mails gesendet.",
382
- shareGuestDayMails: "Dieser Wizard hat seine E-Mails für heute gesendet. Versuch es morgen wieder.",
382
+ shareGuestChannel: "Von hier geht keine Nachricht in einen Slack-Kanal.",
383
+ shareGuestRunMails: "Dieser Lauf hat seine {mails} E-Mails und Nachrichten gesendet.",
384
+ shareGuestDayMails: "Dieser Wizard hat seine E-Mails und Nachrichten für heute gesendet. Versuch es morgen wieder.",
383
385
  shareConnectMailbox: "Verbinde zuerst ein Postfach.",
384
386
  shareSendingFrom: "Sendet von {account}",
385
387
  shareSentTo: "Gesendet an {to}",
@@ -8,7 +8,7 @@ import { stepCaller } from "../elements/caller.js";
8
8
  import { elementTools } from "../elements/catalogue.js";
9
9
  import { generateImageMedia } from "../media/generate.js";
10
10
  import { markMedia } from "../media/marking.js";
11
- import { gatewayTools, isHarnessVendor, searchAllowed } from "../models.js";
11
+ import { gatewayTools, isHarnessVendor, searchAllowed, toolAccess, } from "../models.js";
12
12
  import { prompt } from "../prompts.js";
13
13
  import { htmlToMarkdown } from "../render/convert.js";
14
14
  import { shellToolDescription } from "../sandbox/index.js";
@@ -24,6 +24,7 @@ import { pluginTools, spaceContextOf } from "./plugin.js";
24
24
  import { clip, FileKeeper } from "./shared.js";
25
25
  import { skillsOf } from "./skills.js";
26
26
  import { storeTools } from "./store.js";
27
+ import { gatewayWebSearch } from "./web-search.js";
27
28
  // A request to a host is a send to that host; the broker holds a guest's run to the hosts in its grant.
28
29
  reachesOutside("http_request", { connection: "host", action: "http_request", kind: "send" });
29
30
  /**
@@ -65,12 +66,11 @@ export async function buildStepTools(step, ctx, resolved, uploads) {
65
66
  const allowed = new Set(step.tools);
66
67
  // A tier without web search leaves the tool out; the builder says so before a run.
67
68
  if (allowed.has("web_search") && (await searchAllowed())) {
68
- // Anthropic models search natively; other models search through the AI Gateway's tool.
69
- if (resolved.vendor === "anthropic") {
70
- tools.web_search = anthropic.tools.webSearch_20250305({ maxUses: 8 });
71
- }
72
- else if (isHarnessVendor(resolved.vendor)) {
73
- // An installed client searches with its own tool; naming it here switches it on.
69
+ // An installed client searches with its own tool; naming it here switches it on. Else the
70
+ // gateway's search where it is reached, for every model alike; else Anthropic models search
71
+ // natively, other models through the AI Gateway's tool.
72
+ const access = isHarnessVendor(resolved.vendor) ? null : await toolAccess();
73
+ if (isHarnessVendor(resolved.vendor)) {
74
74
  tools.web_search = createTool({
75
75
  id: "web_search",
76
76
  description: prompt("tools", "tool.web_search"),
@@ -78,6 +78,12 @@ export async function buildStepTools(step, ctx, resolved, uploads) {
78
78
  execute: async () => ({ error: "The client searches itself." }),
79
79
  });
80
80
  }
81
+ else if (access) {
82
+ tools.web_search = gatewayWebSearch(access, { runId: ctx.runId });
83
+ }
84
+ else if (resolved.vendor === "anthropic") {
85
+ tools.web_search = anthropic.tools.webSearch_20250305({ maxUses: 8 });
86
+ }
81
87
  else if (resolved.gateway) {
82
88
  tools.web_search = gatewayTools.perplexitySearch({ maxResults: 8 });
83
89
  }
@@ -0,0 +1,36 @@
1
+ import { createTool } from "@mastra/core/tools";
2
+ import { z } from "zod";
3
+ import { prompt } from "../prompts.js";
4
+ /**
5
+ * `web_search` through the gateway: the same tool for every model and client (a Work chat,
6
+ * Goose, a step, a local AI client), metered and booked there, its provider the gateway's
7
+ * business. Reading a result's page is `web_fetch`, the runtime's own.
8
+ */
9
+ export function gatewayWebSearch(access, meta = {}) {
10
+ return createTool({
11
+ id: "web_search",
12
+ description: prompt("tools", "tool.web_search"),
13
+ inputSchema: z.object({
14
+ query: z.string().min(1).max(500).describe("What to search for, as one would type it"),
15
+ num: z.number().int().min(1).max(10).optional().describe("How many results, 6 by default"),
16
+ }),
17
+ execute: async ({ query, num }, options) => {
18
+ const res = await fetch(`${access.baseUrl}/v1/web/search`, {
19
+ method: "POST",
20
+ signal: options?.abortSignal,
21
+ headers: {
22
+ authorization: `Bearer ${access.token}`,
23
+ "content-type": "application/json",
24
+ ...(access.tenant ? { "x-wizards-tenant": access.tenant } : {}),
25
+ ...(meta.runId ? { "x-wizards-run": meta.runId } : {}),
26
+ },
27
+ body: JSON.stringify({ query, ...(num ? { num } : {}) }),
28
+ });
29
+ const body = (await res.json().catch(() => null));
30
+ if (!res.ok) {
31
+ return { error: body?.error?.message ?? `The web search answered ${res.status}.` };
32
+ }
33
+ return { results: body?.results ?? [] };
34
+ },
35
+ });
36
+ }
@@ -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{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};
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-DAk_vjrL.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-BaPKbQ1s.js";import{g,h as _,m as v,t as y,u as b}from"./UpdateCheck-QhBI3rlQ.js";import{ReleaseNotes as x,loadReleases as S,releaseDate as C,releaseLabel as w}from"./ChangelogDialog-BIrJbAKi.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.17.0`?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};