wizards 0.2.17 → 0.2.19

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 (68) hide show
  1. package/apps/runtime/dist/agents/project-assistant.js +20 -2
  2. package/apps/runtime/dist/authoring/guide.js +6 -3
  3. package/apps/runtime/dist/db/migrations/tenant/0009_knowledge.sql +104 -0
  4. package/apps/runtime/dist/db/migrations/tenant/meta/0009_snapshot.json +2837 -0
  5. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +7 -0
  6. package/apps/runtime/dist/db/schema.js +160 -8
  7. package/apps/runtime/dist/engine/steps.js +3 -11
  8. package/apps/runtime/dist/env.js +2 -0
  9. package/apps/runtime/dist/files/storage.js +15 -0
  10. package/apps/runtime/dist/models.js +38 -0
  11. package/apps/runtime/dist/plugins/loader.js +2 -0
  12. package/apps/runtime/dist/routes/studio.js +147 -6
  13. package/apps/runtime/dist/services/cloud.js +59 -1
  14. package/apps/runtime/dist/services/knowledge-model.js +558 -0
  15. package/apps/runtime/dist/services/knowledge.js +721 -0
  16. package/apps/runtime/dist/services/project-files.js +114 -6
  17. package/apps/runtime/dist/services/project-index.js +632 -94
  18. package/apps/runtime/dist/services/relevance.js +90 -0
  19. package/apps/runtime/dist/services/space-categories.js +882 -0
  20. package/apps/runtime/dist/services/space-data.js +466 -38
  21. package/apps/runtime/dist/services/space-origin.js +164 -0
  22. package/apps/runtime/dist/services/spaces.js +155 -1
  23. package/apps/runtime/dist/tools/pages.js +27 -22
  24. package/apps/runtime/dist/tools/project.js +130 -40
  25. package/apps/web/dist/assets/{Account-LVXhagaS.js → Account-O6OTAY88.js} +1 -1
  26. package/apps/web/dist/assets/{ChangelogDialog-DM0KAoy6.js → ChangelogDialog-DLrXuyLL.js} +1 -1
  27. package/apps/web/dist/assets/{ChatPanel-CxOQmtv-.js → ChatPanel-BPD-iQK0.js} +1 -1
  28. package/apps/web/dist/assets/{CreditsDialog-DkW3YT44.js → CreditsDialog-Ckema8Ss.js} +1 -1
  29. package/apps/web/dist/assets/{EditorPage-hbisE1Wf.js → EditorPage-Dtu9j41h.js} +1 -1
  30. package/apps/web/dist/assets/{FlowPreview-v7or29ku.js → FlowPreview-DB-86F8z.js} +1 -1
  31. package/apps/web/dist/assets/{Harness-RZF-bBmb.js → Harness-D-DSa4ip.js} +1 -1
  32. package/apps/web/dist/assets/{HomePage-mxG-a_KU.js → HomePage-ZrCxIiJT.js} +1 -1
  33. package/apps/web/dist/assets/{ImportWizard-CiPyUt3E.js → ImportWizard-DtZH-PgS.js} +1 -1
  34. package/apps/web/dist/assets/{LocalRuntime-Dqp9wkN3.js → LocalRuntime-o1OAvp7c.js} +1 -1
  35. package/apps/web/dist/assets/NewWizardPage-Bbt-w8tE.js +2 -0
  36. package/apps/web/dist/assets/ProjectPage-MHxFqA98.js +5 -0
  37. package/apps/web/dist/assets/{PublicRunner-TGkOwbAP.js → PublicRunner-CYo2F8H4.js} +1 -1
  38. package/apps/web/dist/assets/{RunnerView-DzHGshZj.js → RunnerView-Bqp0paLi.js} +1 -1
  39. package/apps/web/dist/assets/{SettingsPage-CG3Xtfej.js → SettingsPage-XyRrZeMr.js} +1 -1
  40. package/apps/web/dist/assets/{SetupPage-O1GfPlqX.js → SetupPage-CdBYFmh1.js} +1 -1
  41. package/apps/web/dist/assets/{SharePage-CCNUhtry.js → SharePage-B7ON0pe1.js} +1 -1
  42. package/apps/web/dist/assets/{api-DB22_B7G.js → api-CVG-xDEn.js} +1 -1
  43. package/apps/web/dist/assets/changelog-B2U80Wtl.js +1 -0
  44. package/apps/web/dist/assets/{esm-3TT9i_rv.js → esm-DutMJAod.js} +1 -1
  45. package/apps/web/dist/assets/index-Bwyehu0k.css +1 -0
  46. package/apps/web/dist/assets/{index-CLe9Wrpu.js → index-hpNaR92X.js} +3 -3
  47. package/apps/web/dist/assets/{meta-CEsBCPfA.js → meta--kpiTOS-.js} +1 -1
  48. package/apps/web/dist/assets/{settings-menu-pOcjznGJ.js → settings-menu-BXpT5jOB.js} +1 -1
  49. package/apps/web/dist/assets/ui-BPY2pIh0.js +1 -0
  50. package/apps/web/dist/index.html +4 -4
  51. package/apps/web/dist/mcp/flow.html +2 -2
  52. package/node_modules/@engenty-wizards/plugin-sdk/dist/index.d.ts +164 -0
  53. package/node_modules/@engenty-wizards/shared/dist/knowledge.d.ts +199 -0
  54. package/node_modules/@engenty-wizards/shared/dist/knowledge.js +68 -0
  55. package/node_modules/@engenty-wizards/shared/dist/marketplace.d.ts +13 -1
  56. package/node_modules/@engenty-wizards/shared/dist/marketplace.js +3 -0
  57. package/node_modules/@engenty-wizards/shared/dist/projects.d.ts +1 -16
  58. package/node_modules/@engenty-wizards/shared/dist/projects.js +1 -1
  59. package/node_modules/@engenty-wizards/shared/dist/run.d.ts +8 -0
  60. package/node_modules/@engenty-wizards/shared/dist/run.js +5 -0
  61. package/node_modules/@engenty-wizards/shared/dist/space-data.d.ts +20 -0
  62. package/node_modules/@engenty-wizards/shared/dist/space-data.js +2 -1
  63. package/package.json +1 -1
  64. package/apps/web/dist/assets/NewWizardPage-DHwRsi0_.js +0 -2
  65. package/apps/web/dist/assets/ProjectPage-Bb7jN_6n.js +0 -4
  66. package/apps/web/dist/assets/changelog-BkIJdZ7M.js +0 -1
  67. package/apps/web/dist/assets/index-BPpKz65x.css +0 -1
  68. package/apps/web/dist/assets/ui-I7QYMX0F.js +0 -1
@@ -5,9 +5,11 @@ import { createTool } from "@mastra/core/tools";
5
5
  import { z } from "zod";
6
6
  import { attachTools, costOf, gatewayTools, textModel } from "../models.js";
7
7
  import { ServiceError } from "../services/errors.js";
8
+ import { knowledgeCounts } from "../services/knowledge.js";
8
9
  import { addProjectFile, projectFileContent, projectFiles, updateProjectFile, } from "../services/project-files.js";
9
10
  import { documentText } from "../services/project-index.js";
10
11
  import { brandColorSchema, ownedProject, updateProject } from "../services/projects.js";
12
+ import { categoryRows } from "../services/space-categories.js";
11
13
  import { currentTenant } from "../tenants/tenant.js";
12
14
  import { safeFetch } from "../tools/net-guard.js";
13
15
  import { assistantToolsOf } from "../tools/plugin.js";
@@ -26,7 +28,13 @@ HOW YOU WORK
26
28
  - Logos: save the best candidate (an SVG or a large PNG rather than a favicon); a second one only if it truly differs (for dark ground, a signet). A few images that show the business (header, team, products) may be saved as assets — a handful, never everything.
27
29
  - Files the admin attached are stored already; the message names them. look_at_file shows you a picture or a document's text. Give a file a description with describe_file when it has none or the admin says what it is. Take facts from a document when the admin asks for it.
28
30
  - Call independent tools together. Work in few steps.
29
- - Finish with one to three sentences: what you filled in, what is still missing, and at most one question.`;
31
+ - Finish with one to three sentences: what you filled in, what is still missing, and at most one question.
32
+
33
+ WISSEN
34
+ - Wissen (German „Wissen“) is what the wizards' steps look things up in: pages, tables and files, kept apart by typed Kategorien (Baustelle, Berichtsdatum, Art der Förderung …). The admin sees it on the page below you.
35
+ - Documents the admin attaches are read into Wissen by themselves: a page, sub-pages for a long structured document, a table per sheet. Say so; do not copy their text into facts unless asked.
36
+ - A website, a sitemap or a folder whose entries should go into Wissen is a source. Where a tool proposes sources, use it: the admin takes the proposal on its card. Where there is none, say that sources need the Sources plugin, and offer to read the site for the space's own details instead.
37
+ - Talking from Wissen, change title, about, logos, colours and facts only when the admin asks.`;
30
38
  function activity(tool, args) {
31
39
  const host = (u) => {
32
40
  try {
@@ -67,7 +75,12 @@ async function attempt(run) {
67
75
  async function projectState(userId, projectId) {
68
76
  const p = await ownedProject(userId, projectId);
69
77
  const files = await projectFiles(projectId);
78
+ const categories = await categoryRows(projectId);
70
79
  return {
80
+ wissen: {
81
+ ...(await knowledgeCounts(projectId)),
82
+ kategorien: categories.map((c) => `${c.name} (${c.type}${c.proposed ? ", proposed" : ""})`),
83
+ },
71
84
  title: p.brand.name ?? "",
72
85
  about: p.brand.about ?? "",
73
86
  colors: p.brand.colors ?? [],
@@ -326,8 +339,13 @@ export async function runProjectAssistant(input) {
326
339
  });
327
340
  const context = [
328
341
  `The project now:\n\`\`\`json\n${JSON.stringify(await projectState(input.userId, input.projectId))}\n\`\`\``,
342
+ input.part === "knowledge"
343
+ ? "The admin talks to you from Wissen: they want the wizards to know something."
344
+ : "",
329
345
  input.message,
330
- ].join("\n\n");
346
+ ]
347
+ .filter(Boolean)
348
+ .join("\n\n");
331
349
  const stream = await agent.stream([
332
350
  ...input.history
333
351
  .slice(-12)
@@ -98,9 +98,11 @@ type AgentStep = {
98
98
  working?: string // shown while it runs ("Recherchiert im Web …")
99
99
  }
100
100
  // Every agent step also has, without listing them: list_read / list_write (the wizard's lists), files_list,
101
- // read_document (PDF, scans and photos, Word, Excel, CSV, saved mails) and scan_documents (invoice / receipt fields, many at once).
101
+ // read_document (PDF, scans and photos, Word, Excel, CSV, saved mails) and scan_documents (invoice / receipt fields, many at once);
102
+ // and where the space has Wissen: project_search (a question, "where" on its typed Kategorien, hits checked for relevance),
103
+ // project_list (by Kategorien), page_read / table_read / project_document (an item whole, by its path).
102
104
  // "pages" brings: page_read / page_write — Markdown pages of the space the wizard keeps for every run (notes, a log
103
- // that grows with append), shown to the admin under Space → Daten; page_read also reads the space's own pages.
105
+ // that grows with append), shown to the admin under Space → Daten; page_read also reads Wissen by path.
104
106
  // "browser" brings: browser_open/click/type, browser_screenshot (the model looks at the page),
105
107
  // browser_request_credentials (the PERSON types a login into the page — the model never sees it; sign-ins can be remembered),
106
108
  // browser_request_user (the person solves a captcha or "continue with Google" in a picture of the page),
@@ -153,7 +155,8 @@ type ResultStep = { type: "result", message?: string, deliverables: { from: step
153
155
  Templates (in instructions/prompt): {{fieldId}} · {{steps.stepId}} (whole output) · {{steps.stepId.key}} (json key)
154
156
  · {{itemsField}} (line items as a table WITH computed net/VAT/total) · {{itemsField.net|vat|gross}} · {{today}}
155
157
  · the project (its settings): {{brand.name}} {{brand.about}} {{brand.colors}} · {{facts.key}} (one fact: address, VAT id, …) · {{facts}} (all facts)
156
- — every AI step already knows them, name one only where the text must carry it; agent steps can also search the project's documents
158
+ — every AI step already knows them, name one only where the text must carry it; agent steps also search the space's Wissen
159
+ and are told its Kategorien: say in a step's instructions which Kategorie to filter by when the task names one
157
160
  · {{lists.listId}} (the stored list as a table, as it is when the step starts) · {{fileField}} (the names of the uploads, for read_document)
158
161
  · {{locationField}} {{locationField.lat|lng|accuracy|label|map}} · {{audioField}} (the transcript) · {{signatureField}} (asset://ID)
159
162
  A template may only use fields asked and steps run EARLIER.`;
@@ -0,0 +1,104 @@
1
+ CREATE TABLE `space_category` (
2
+ `id` text PRIMARY KEY NOT NULL,
3
+ `tenant_id` text NOT NULL,
4
+ `project_id` text NOT NULL,
5
+ `name` text NOT NULL,
6
+ `type` text NOT NULL,
7
+ `unit` text,
8
+ `multiple` integer DEFAULT false NOT NULL,
9
+ `ordered` integer DEFAULT false NOT NULL,
10
+ `hint` text,
11
+ `origin` text,
12
+ `proposed` integer DEFAULT false NOT NULL,
13
+ `table_id` text,
14
+ `column_id` text,
15
+ `position` integer DEFAULT 0 NOT NULL,
16
+ `created_at` integer DEFAULT (unixepoch() * 1000) NOT NULL,
17
+ `updated_at` integer DEFAULT (unixepoch() * 1000) NOT NULL,
18
+ FOREIGN KEY (`project_id`) REFERENCES `project`(`id`) ON UPDATE no action ON DELETE cascade,
19
+ FOREIGN KEY (`table_id`) REFERENCES `space_table`(`id`) ON UPDATE no action ON DELETE set null
20
+ );
21
+ --> statement-breakpoint
22
+ CREATE UNIQUE INDEX `space_category_name` ON `space_category` (`project_id`,`name`);--> statement-breakpoint
23
+ CREATE TABLE `space_category_value` (
24
+ `id` text PRIMARY KEY NOT NULL,
25
+ `category_id` text NOT NULL,
26
+ `value` text NOT NULL,
27
+ `position` integer DEFAULT 0 NOT NULL,
28
+ `summary` text,
29
+ `summary_at` integer,
30
+ `created_at` integer DEFAULT (unixepoch() * 1000) NOT NULL,
31
+ FOREIGN KEY (`category_id`) REFERENCES `space_category`(`id`) ON UPDATE no action ON DELETE cascade
32
+ );
33
+ --> statement-breakpoint
34
+ CREATE UNIQUE INDEX `space_category_value_value` ON `space_category_value` (`category_id`,`value`);--> statement-breakpoint
35
+ CREATE TABLE `space_item_category` (
36
+ `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
37
+ `project_id` text NOT NULL,
38
+ `category_id` text NOT NULL,
39
+ `page_id` text,
40
+ `row_id` text,
41
+ `table_id` text,
42
+ `file_id` text,
43
+ `value_id` text,
44
+ `text` text,
45
+ `num` real,
46
+ `at` integer,
47
+ `bool` integer,
48
+ `by` text DEFAULT 'person' NOT NULL,
49
+ FOREIGN KEY (`project_id`) REFERENCES `project`(`id`) ON UPDATE no action ON DELETE cascade,
50
+ FOREIGN KEY (`category_id`) REFERENCES `space_category`(`id`) ON UPDATE no action ON DELETE cascade,
51
+ FOREIGN KEY (`page_id`) REFERENCES `space_page`(`id`) ON UPDATE no action ON DELETE cascade,
52
+ FOREIGN KEY (`row_id`) REFERENCES `space_table_row`(`id`) ON UPDATE no action ON DELETE cascade,
53
+ FOREIGN KEY (`table_id`) REFERENCES `space_table`(`id`) ON UPDATE no action ON DELETE cascade,
54
+ FOREIGN KEY (`file_id`) REFERENCES `project_file`(`id`) ON UPDATE no action ON DELETE cascade,
55
+ FOREIGN KEY (`value_id`) REFERENCES `space_category_value`(`id`) ON UPDATE no action ON DELETE cascade
56
+ );
57
+ --> statement-breakpoint
58
+ CREATE INDEX `space_item_category_category` ON `space_item_category` (`category_id`,`value_id`);--> statement-breakpoint
59
+ CREATE INDEX `space_item_category_page` ON `space_item_category` (`page_id`);--> statement-breakpoint
60
+ CREATE INDEX `space_item_category_row` ON `space_item_category` (`row_id`);--> statement-breakpoint
61
+ CREATE INDEX `space_item_category_table` ON `space_item_category` (`table_id`);--> statement-breakpoint
62
+ CREATE INDEX `space_item_category_file` ON `space_item_category` (`file_id`);--> statement-breakpoint
63
+ ALTER TABLE `project_chunk` ADD `page_id` text REFERENCES space_page(id) ON DELETE cascade;--> statement-breakpoint
64
+ ALTER TABLE `project_chunk` ADD `row_id` text REFERENCES space_table_row(id) ON DELETE cascade;--> statement-breakpoint
65
+ ALTER TABLE `project_chunk` ADD `table_id` text REFERENCES space_table(id) ON DELETE cascade;--> statement-breakpoint
66
+ ALTER TABLE `project_chunk` ADD `value_id` text REFERENCES space_category_value(id) ON DELETE cascade;--> statement-breakpoint
67
+ ALTER TABLE `project_chunk` ADD `heading` text;--> statement-breakpoint
68
+ ALTER TABLE `project_chunk` ADD `sheet` integer;--> statement-breakpoint
69
+ CREATE INDEX `project_chunk_page` ON `project_chunk` (`page_id`);--> statement-breakpoint
70
+ CREATE INDEX `project_chunk_row` ON `project_chunk` (`row_id`);--> statement-breakpoint
71
+ CREATE INDEX `project_chunk_table` ON `project_chunk` (`table_id`);--> statement-breakpoint
72
+ CREATE INDEX `project_chunk_value` ON `project_chunk` (`value_id`);--> statement-breakpoint
73
+ ALTER TABLE `project_file` ADD `origin` text;--> statement-breakpoint
74
+ ALTER TABLE `project_file` ADD `origin_key` text;--> statement-breakpoint
75
+ ALTER TABLE `project_file` ADD `origin_label` text;--> statement-breakpoint
76
+ CREATE UNIQUE INDEX `project_file_origin` ON `project_file` (`project_id`,`origin`,`origin_key`);--> statement-breakpoint
77
+ ALTER TABLE `space_page` ADD `parent_id` text REFERENCES space_page(id) ON DELETE cascade;--> statement-breakpoint
78
+ ALTER TABLE `space_page` ADD `position` integer DEFAULT 0 NOT NULL;--> statement-breakpoint
79
+ ALTER TABLE `space_page` ADD `slug` text;--> statement-breakpoint
80
+ ALTER TABLE `space_page` ADD `origin` text;--> statement-breakpoint
81
+ ALTER TABLE `space_page` ADD `origin_key` text;--> statement-breakpoint
82
+ ALTER TABLE `space_page` ADD `origin_label` text;--> statement-breakpoint
83
+ ALTER TABLE `space_page` ADD `kept` integer DEFAULT false NOT NULL;--> statement-breakpoint
84
+ ALTER TABLE `space_page` ADD `review` text;--> statement-breakpoint
85
+ ALTER TABLE `space_page` ADD `file_id` text REFERENCES project_file(id) ON DELETE set null;--> statement-breakpoint
86
+ CREATE INDEX `space_page_parent` ON `space_page` (`parent_id`,`position`);--> statement-breakpoint
87
+ CREATE UNIQUE INDEX `space_page_origin` ON `space_page` (`project_id`,`origin`,`origin_key`);--> statement-breakpoint
88
+ ALTER TABLE `space_table` ADD `slug` text;--> statement-breakpoint
89
+ ALTER TABLE `space_table` ADD `format` text;--> statement-breakpoint
90
+ ALTER TABLE `space_table` ADD `origin` text;--> statement-breakpoint
91
+ ALTER TABLE `space_table` ADD `origin_key` text;--> statement-breakpoint
92
+ ALTER TABLE `space_table` ADD `origin_label` text;--> statement-breakpoint
93
+ ALTER TABLE `space_table` ADD `kept` integer DEFAULT false NOT NULL;--> statement-breakpoint
94
+ ALTER TABLE `space_table` ADD `review` text;--> statement-breakpoint
95
+ ALTER TABLE `space_table` ADD `file_id` text REFERENCES project_file(id) ON DELETE set null;--> statement-breakpoint
96
+ CREATE UNIQUE INDEX `space_table_origin` ON `space_table` (`project_id`,`origin`,`origin_key`);--> statement-breakpoint
97
+ CREATE VIRTUAL TABLE `project_chunk_tri` USING fts5(`text`, content='project_chunk', content_rowid='id', tokenize='trigram remove_diacritics 1');--> statement-breakpoint
98
+ INSERT INTO `project_chunk_tri`(`project_chunk_tri`) VALUES ('rebuild');--> statement-breakpoint
99
+ CREATE TRIGGER `project_chunk_tri_ai` AFTER INSERT ON `project_chunk` BEGIN
100
+ INSERT INTO `project_chunk_tri`(rowid, `text`) VALUES (new.id, new.text);
101
+ END;--> statement-breakpoint
102
+ CREATE TRIGGER `project_chunk_tri_ad` AFTER DELETE ON `project_chunk` BEGIN
103
+ INSERT INTO `project_chunk_tri`(`project_chunk_tri`, rowid, `text`) VALUES ('delete', old.id, old.text);
104
+ END;