@engenty/wizards-runtime 0.11.4 → 0.11.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/runtime/dist/agents/architect.js +3 -5
- package/apps/runtime/dist/agents/studio-assistant.js +1 -3
- package/apps/runtime/dist/assistant/knows.js +1 -1
- package/apps/runtime/dist/authoring/guide.js +2 -8
- package/apps/runtime/dist/credits/estimate.js +1 -1
- package/apps/runtime/dist/db/migrations/tenant/0025_drop_mcp_servers.sql +1 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0025_snapshot.json +3959 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +7 -0
- package/apps/runtime/dist/db/schema.js +0 -4
- package/apps/runtime/dist/docs/dev/plugins/events.md +2 -2
- package/apps/runtime/dist/docs/dev/wizard-format/agent-steps.md +1 -2
- package/apps/runtime/dist/docs/dev/wizard-format/wizard-file.md +6 -8
- package/apps/runtime/dist/docs/user-guide/cloud-sync.md +2 -2
- package/apps/runtime/dist/docs/user-guide/connectors.md +1 -10
- package/apps/runtime/dist/docs/user-guide/steps.md +2 -3
- package/apps/runtime/dist/engine/steps.js +126 -131
- package/apps/runtime/dist/live/views.js +1 -3
- package/apps/runtime/dist/mcp/tools.js +1 -1
- package/apps/runtime/dist/services/architect.js +0 -1
- package/apps/runtime/dist/services/package-file.js +0 -1
- package/apps/runtime/dist/services/package.js +0 -10
- package/apps/runtime/dist/services/projects.js +1 -31
- package/apps/runtime/dist/services/spaces.js +5 -23
- package/apps/runtime/dist/sync/records.js +0 -9
- package/apps/runtime/dist/tools/index.js +0 -28
- package/apps/web/dist/assets/{AboutDialog-B7ThTqw4.js → AboutDialog-B525L37O.js} +1 -1
- package/apps/web/dist/assets/{ChangelogDialog-DBpXTjxr.js → ChangelogDialog-gInSm1Xe.js} +1 -1
- package/apps/web/dist/assets/{CodeEditor-BTcAUlGY.js → CodeEditor-C0TmdCrb.js} +1 -1
- package/apps/web/dist/assets/EditorPage-7t3vhZi6.js +3 -0
- package/apps/web/dist/assets/{FlowPreview-Sjnlj0OO.js → FlowPreview-BBN-APkG.js} +1 -1
- package/apps/web/dist/assets/{Harness-BKl73EG5.js → Harness-fAoC908y.js} +1 -1
- package/apps/web/dist/assets/Marketplace-CotMMcJ-.js +2 -0
- package/apps/web/dist/assets/{NewWizardChannels-DarxdQRt.js → NewWizardChannels-X32lBGMf.js} +1 -1
- package/apps/web/dist/assets/{NewWizardPage-BCoPZjp5.js → NewWizardPage-DMoqDhsh.js} +1 -1
- package/apps/web/dist/assets/{OnboardingPage-qV_YA_mZ.js → OnboardingPage-BjZy-bhI.js} +1 -1
- package/apps/web/dist/assets/{PreviewPane-B5_GY6Cv.js → PreviewPane-Bt-ForJG.js} +2 -2
- package/apps/web/dist/assets/{ProjectPage-Bcc81_KO.js → ProjectPage-B5a-nod-.js} +1 -1
- package/apps/web/dist/assets/{PublicRunner-hlxaESAv.js → PublicRunner-Cq_XzX54.js} +1 -1
- package/apps/web/dist/assets/{ReadOnly-BUnTzhA3.js → ReadOnly-DX3beZJz.js} +1 -1
- package/apps/web/dist/assets/SettingsPage-DPuwA3QL.js +2 -0
- package/apps/web/dist/assets/{SetupPage-DAgnVxDA.js → SetupPage-BI9bgEkI.js} +1 -1
- package/apps/web/dist/assets/{SharePage-aKBNZDby.js → SharePage-Ch-1oLBs.js} +1 -1
- package/apps/web/dist/assets/changelog-BlJc9UFS.js +1 -0
- package/apps/web/dist/assets/{coins-C8RAtYAu.js → coins-D_yN56kT.js} +1 -1
- package/apps/web/dist/assets/i18n-Dy3fTQM3.js +55 -0
- package/apps/web/dist/assets/{index-BdwA-8jc.js → index-Dt1Ps3ge.js} +5 -5
- package/apps/web/dist/assets/{index-DQc1EITf.css → index-rX7eCvWh.css} +1 -1
- package/apps/web/dist/assets/oss-credits-CZT1KRIp.js +1 -0
- package/apps/web/dist/assets/{phone-DTuPPVhC.js → phone-DxC6eM6O.js} +1 -1
- package/apps/web/dist/assets/{runners-BcK_yEKU.js → runners-SQHfvvNQ.js} +1 -1
- package/apps/web/dist/assets/{session-C7ciCzbV.js → session-4CTNIlai.js} +1 -1
- package/apps/web/dist/assets/{settings-menu-b7am2SP5.js → settings-menu-B0af5EBE.js} +1 -1
- package/apps/web/dist/assets/{theme-BOAjs_xb.js → theme-mtamawa_.js} +1 -1
- package/apps/web/dist/assets/{ui-DKK_O65k.js → ui-CL8v8Goa.js} +1 -1
- package/apps/web/dist/assets/{upload-Cbcw8l_0.js → upload-DXJQU2lL.js} +1 -1
- package/apps/web/dist/assets/{useMutation-D8Bpwvs1.js → useMutation-DwRYrG3V.js} +1 -1
- package/apps/web/dist/assets/{volume-2-CgRP_A7r.js → volume-2-CYbbBiXP.js} +1 -1
- package/apps/web/dist/assets/{wrench-me5bf7bd.js → wrench-D8lG2BH7.js} +1 -1
- package/apps/web/dist/index.html +9 -9
- package/apps/web/dist/mcp/flow.html +3 -3
- package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +0 -4
- package/node_modules/@engenty/wizards-shared/dist/definition.js +0 -3
- package/node_modules/@engenty/wizards-shared/dist/fit.d.ts +1 -1
- package/node_modules/@engenty/wizards-shared/dist/fit.js +0 -4
- package/node_modules/@engenty/wizards-shared/dist/marketplace.js +2 -2
- package/node_modules/@engenty/wizards-shared/dist/run.d.ts +0 -2
- package/node_modules/@engenty/wizards-shared/dist/run.js +0 -4
- package/node_modules/@engenty/wizards-shared/dist/wizard-package.d.ts +0 -4
- package/node_modules/@engenty/wizards-shared/dist/wizard-package.js +0 -5
- package/package.json +1 -2
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/plugin.json +1 -1
- package/apps/web/dist/assets/EditorPage-B_cFXR-B.js +0 -3
- package/apps/web/dist/assets/Marketplace-BNu-Hjzu.js +0 -2
- package/apps/web/dist/assets/SettingsPage-BoA-ykQU.js +0 -2
- package/apps/web/dist/assets/changelog-DwJOKc4z.js +0 -1
- package/apps/web/dist/assets/i18n-Bq6dt_qv.js +0 -55
- package/apps/web/dist/assets/oss-credits-C6bPkfSE.js +0 -1
|
@@ -13,10 +13,6 @@ export const project = sqliteTable("project", {
|
|
|
13
13
|
themes: text("themes", { mode: "json" }).$type().notNull().default([]),
|
|
14
14
|
/** The space's public page at `<organization>.wizards.page/<slug>`; null until it is set up. */
|
|
15
15
|
page: text("page", { mode: "json" }).$type(),
|
|
16
|
-
mcpServers: text("mcp_servers", { mode: "json" })
|
|
17
|
-
.$type()
|
|
18
|
-
.notNull()
|
|
19
|
-
.default([]),
|
|
20
16
|
/**
|
|
21
17
|
* `local`: the project of a local install, synced here when that install publishes. It keeps
|
|
22
18
|
* the ids it has there and is changed only by the next sync. Null: made on this runtime.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Events
|
|
3
3
|
description: Do something when a run ends or a space changes – keep who it was, post a message, read a new document.
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.11.3
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
A plugin can listen to runs that reach their end, and to spaces that change.
|
|
@@ -36,7 +36,7 @@ server.on("run.done", async ({ run, wizard, values }) => {
|
|
|
36
36
|
| Event | A space | Gets |
|
|
37
37
|
|---|---|---|
|
|
38
38
|
| `space.created` | was made here, or arrived from engenty wizards on someone’s computer | `{ space: { id } }` |
|
|
39
|
-
| `space.updated` | changed its name, its brand (Info and Brand)
|
|
39
|
+
| `space.updated` | changed its name, its brand (Info and Brand) or its facts, or arrived again from a computer | `{ space: { id } }` |
|
|
40
40
|
| `space.deleted` | was deleted | `{ space: { id } }` |
|
|
41
41
|
| `space.file.ready` | has a file that was read: a document is in the index now | `{ space: { id }, file: { id, name, kind, mime } }` |
|
|
42
42
|
| `space.file.removed` | lost a file | `{ space: { id }, file: { id, name, kind, mime } }` |
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Agent steps
|
|
3
3
|
description: An AI step's instructions, tools, output, model class, decisions, and one run per entry.
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.11.3
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
An `agent` step is an AI step. It reads its `instructions`, may call tools, and returns its
|
|
@@ -26,7 +26,6 @@ output.
|
|
|
26
26
|
| Key | What the step may use |
|
|
27
27
|
|---|---|
|
|
28
28
|
| `tools` | Built-in tools: `web_search`, `web_fetch`, `browser`, `sandbox`, `image`, `http`, `pages`, `code`. A plugin’s tool by its full id, `<plugin>.<tool>` |
|
|
29
|
-
| `mcp` | Ids of the space’s connected systems (MCP servers) |
|
|
30
29
|
| `connections` | Ids of the wizard’s connections. See [Lists and connections](./lists-and-connections.md) |
|
|
31
30
|
|
|
32
31
|
A wizard that names a plugin’s tool runs only where that plugin is installed. See
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: The .wizard file
|
|
3
3
|
description: The zip a wizard travels in, its folders and manifest, how to make one by hand, and what the import does with it.
|
|
4
|
-
version: 0.11.
|
|
4
|
+
version: 0.11.3
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
A `.wizard` file is a zip with the wizard’s definition and its workspace. The studio exports
|
|
@@ -67,7 +67,6 @@ A path starts with a letter, a digit, `_` or `-`. So hidden files such as `.env`
|
|
|
67
67
|
"connectors": [
|
|
68
68
|
{ "id": "billomat", "name": "Billomat", "domain": "billomat.com", "sourceKind": "openapi" }
|
|
69
69
|
],
|
|
70
|
-
"mcpServers": [{ "id": "notion", "name": "Notion" }],
|
|
71
70
|
"themes": [{ "id": "invoice-calm", "name": "Invoice, calm", "colors": [ … ] }],
|
|
72
71
|
"knowledge": { "pages": 12, "truncated": false }
|
|
73
72
|
}
|
|
@@ -81,12 +80,11 @@ A path starts with a letter, a digit, `_` or `-`. So hidden files such as `.env`
|
|
|
81
80
|
| `exportedAt` | When the file was made |
|
|
82
81
|
| `definition` | The wizard. See [The wizard format](./index.md) |
|
|
83
82
|
| `connectors` | Imported connectors the wizard’s connections name: `id`, `name`, `domain` and `sourceKind` (`openapi` or `mcp`), at most 50 |
|
|
84
|
-
| `mcpServers` | The space’s connected systems its agent steps name: `id` and `name`, at most 10 |
|
|
85
83
|
| `themes` | The space’s themes the definition names, in full, at most 8. See [Themes](./themes.md#in-a-wizard-file) |
|
|
86
84
|
| `knowledge` | Only with Knowledge: how many pages, and whether the cap left some out |
|
|
87
85
|
|
|
88
|
-
`connectors`
|
|
89
|
-
|
|
86
|
+
`connectors` holds names, never addresses, headers or credentials. It lets the import tell you
|
|
87
|
+
what the space you import into still needs.
|
|
90
88
|
|
|
91
89
|
## Knowledge
|
|
92
90
|
|
|
@@ -113,7 +111,7 @@ A `.wizard` file holds the wizard, not what it collected or what the space owns:
|
|
|
113
111
|
- runs, results and uploads
|
|
114
112
|
- the rows of its lists and the accounts people connected
|
|
115
113
|
- the space’s brand, facts and Knowledge, unless Knowledge was asked for
|
|
116
|
-
- the addresses and credentials of connectors
|
|
114
|
+
- the addresses and credentials of connectors
|
|
117
115
|
- translations and the wizard’s published versions
|
|
118
116
|
|
|
119
117
|
The studio’s export holds the draft. The website package and the export over the API hold the
|
|
@@ -142,8 +140,8 @@ file without `"format": "engenty-wizard"` is read as a definition.
|
|
|
142
140
|
1. It checks the zip against the limits before it unpacks anything.
|
|
143
141
|
2. It checks the definition and that every path it names is in the workspace.
|
|
144
142
|
3. It makes a new wizard in the space: a draft, not published, with the workspace’s files.
|
|
145
|
-
4. It tells you which connectors
|
|
143
|
+
4. It tells you which connectors the space still lacks.
|
|
146
144
|
|
|
147
145
|
What belongs to the space is checked only here, because only the space has it: its connectors
|
|
148
|
-
and their actions
|
|
146
|
+
and their actions and its plugins’ tools. A manifest of a newer version
|
|
149
147
|
is refused, with a note that the file comes from a newer version of engenty wizards.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Spaces in the cloud
|
|
3
3
|
description: How engenty wizards on your computer keeps its spaces the same as your organization’s spaces at engenty.ai, both ways, and what happens when both sides change the same thing.
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.11.3
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
With an account signed in, engenty wizards on your computer keeps its spaces the same as your
|
|
@@ -21,7 +21,7 @@ work in another one, sign in again and pick it (Settings → Account, or
|
|
|
21
21
|
| Wizards: the draft, its files, translations and the chat you built it with | Chats with the studio’s assistant |
|
|
22
22
|
| Knowledge: pages, tables and their rows, categories | What wizards keep for people: their lists, files and sign-ins |
|
|
23
23
|
| The space’s files | Connected accounts and keys |
|
|
24
|
-
| Connectors | The model settings
|
|
24
|
+
| Connectors | The model settings |
|
|
25
25
|
|
|
26
26
|
Publishing on your computer publishes the wizard here, then in the cloud, as its next version
|
|
27
27
|
there. Its address at engenty.ai stays the same. If the cloud can’t be reached, the studio
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Connectors
|
|
3
3
|
description: Services a wizard works in for the person who runs it – built in, from the registry or over MCP.
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.11.3
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
Settings → Connectors lists the services the space’s wizards can work in. A wizard uses a connector
|
|
@@ -79,12 +79,3 @@ attachments. It never writes. The person chooses how to connect:
|
|
|
79
79
|
| Any mailbox over IMAP | Nothing |
|
|
80
80
|
| “Gmail” button | The Google client, with the Gmail API enabled and the scope `gmail.readonly`. On your computer without one, your engenty account |
|
|
81
81
|
| “Outlook” button | The Microsoft client, with the delegated permission `Mail.Read` |
|
|
82
|
-
|
|
83
|
-
## Connected systems
|
|
84
|
-
|
|
85
|
-
This section also holds “Connected systems”: MCP servers of your own, each with a name, its MCP
|
|
86
|
-
URL and, if the server wants one, an authorization header. AI steps read from and write to these
|
|
87
|
-
systems only where you allow the server on the step.
|
|
88
|
-
|
|
89
|
-
This is the other direction of [AI apps](./ai-apps.md): here engenty calls other servers, there
|
|
90
|
-
your AI app calls engenty.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Steps
|
|
3
3
|
description: What a wizard is made of – pages, AI steps, generated media, widgets, reviews and the result.
|
|
4
|
-
version: 0.11.
|
|
4
|
+
version: 0.11.3
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
A wizard runs its steps from top to bottom. The last step is always the result.
|
|
@@ -80,12 +80,11 @@ PDFs, scans and photos, Word, Excel, CSV and saved mails. Where the space has Kn
|
|
|
80
80
|
searches it too. Every AI step also knows the space’s Info and Brand: its title, what it says
|
|
81
81
|
about itself, its facts and colours.
|
|
82
82
|
|
|
83
|
-
Further tools come from
|
|
83
|
+
Further tools come from two places:
|
|
84
84
|
|
|
85
85
|
- **The person’s accounts**: connectors the wizard uses, where the person connects their own
|
|
86
86
|
account during the run. The step gets the service’s actions as tools. Reading is free; before
|
|
87
87
|
anything changes in the person’s account, they are asked. See [Connectors](./connectors.md).
|
|
88
|
-
- **Connected systems** (MCP servers) of the space, where you allow them on the step.
|
|
89
88
|
- **Plugins** installed in engenty wizards. See [Plugins](./plugins.md).
|
|
90
89
|
|
|
91
90
|
### Model class
|
|
@@ -483,143 +483,138 @@ export async function runAgentStep(step, ctx) {
|
|
|
483
483
|
}
|
|
484
484
|
const resolved = await textModel(step.model ?? "standard", { ...ctx.call, effort: step.effort });
|
|
485
485
|
const uploads = await personUploads(ctx);
|
|
486
|
-
const { tools, assets, instructions
|
|
486
|
+
const { tools, assets, instructions } = await buildStepTools(step, ctx, resolved, uploads);
|
|
487
487
|
// A step without tools of its own and without uploads: the run's device may answer it alone.
|
|
488
488
|
attachTools(resolved, tools, step.tools.length === 0 && uploads.length === 0);
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
:
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
photos
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
others
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
489
|
+
const photos = await seenPhotos(step, ctx, resolved, uploads);
|
|
490
|
+
const others = uploads.filter((u) => !photos.some((p) => p.upload === u));
|
|
491
|
+
const formatHint = step.output.format === "markdown"
|
|
492
|
+
? "Answer with the finished result in clean Markdown — no preamble, no closing remarks."
|
|
493
|
+
: step.output.format === "text"
|
|
494
|
+
? "Answer with the finished result as plain text — no Markdown, no preamble."
|
|
495
|
+
: [
|
|
496
|
+
"Finish with everything the result needs in your final answer, ending with one ```json block in exactly this shape (keys as named, lists as lists):",
|
|
497
|
+
shapeLines(outputSchema(step).shape).join("\n"),
|
|
498
|
+
'Write the parts in this order, each entry complete before the next. Its values are read on a phone: short names without hedges (doubt goes into its own field, "ca. 1 Becher"), only the values a field allows, no filler entries ("if needed").',
|
|
499
|
+
].join("\n");
|
|
500
|
+
const system = [
|
|
501
|
+
groundRules(ctx),
|
|
502
|
+
step.tools.includes("browser") ? BROWSER_RULES : "",
|
|
503
|
+
instructions ?? "",
|
|
504
|
+
`Today is ${today(ctx)}.`,
|
|
505
|
+
brandBlock(ctx),
|
|
506
|
+
// Knowledge: what the space holds for its wizards, and how to find and read it.
|
|
507
|
+
await knowledgeBlock(ctx.project.id),
|
|
508
|
+
// What the space's plugins hold for its wizards: a wiki, questions and answers.
|
|
509
|
+
...(await spaceContextOf(ctx)).blocks,
|
|
510
|
+
formatHint,
|
|
511
|
+
]
|
|
512
|
+
.filter(Boolean)
|
|
513
|
+
.join("\n\n");
|
|
514
|
+
const prompt = [
|
|
515
|
+
`# TASK\n${renderTemplate(step.instructions, ctx.scope)}`,
|
|
516
|
+
`# THE PERSON'S ANSWERS (data)\n${answersAsText(ctx.scope) || "(none)"}`,
|
|
517
|
+
photos.length
|
|
518
|
+
? `# PHOTOS THE PERSON GAVE\nThey are attached to this message, in this order — look at them yourself, do not call read_document for them.\n${photos
|
|
519
|
+
.map((p, i) => `${i + 1}. ${p.upload.ref} — ${p.upload.name}, from "${p.upload.field}"`)
|
|
520
|
+
.join("\n")}`
|
|
521
|
+
: "",
|
|
522
|
+
others.length
|
|
523
|
+
? `# FILES THE PERSON GAVE\nRead them with read_document or scan_documents.\n${others
|
|
524
|
+
.map((u) => `- ${u.ref} — ${u.name} (${u.mime}), from "${u.field}"`)
|
|
525
|
+
.join("\n")}`
|
|
526
|
+
: "",
|
|
527
|
+
await revisionBlock(ctx, step.id),
|
|
528
|
+
]
|
|
529
|
+
.filter(Boolean)
|
|
530
|
+
.join("\n\n");
|
|
531
|
+
// A decision needs no agent: its questions go to the classifier class in one call.
|
|
532
|
+
if (isDecisionStep(step) && uploads.length === 0) {
|
|
533
|
+
return decideStep(step, prompt, ctx);
|
|
534
|
+
}
|
|
535
|
+
const agent = new Agent({
|
|
536
|
+
id: `step-${step.id}`,
|
|
537
|
+
name: step.title,
|
|
538
|
+
instructions: system,
|
|
539
|
+
model: agentModel(resolved),
|
|
540
|
+
tools,
|
|
541
|
+
});
|
|
542
|
+
// Working through a mailbox or a row of portals takes many small tool calls.
|
|
543
|
+
const maxSteps = step.tools.includes("browser") || step.connections?.length ? 60 : 20;
|
|
544
|
+
for (const [i, photo] of photos.entries()) {
|
|
545
|
+
await ctx.emit("info", { code: "photo", params: { n: i + 1, total: photos.length } }, photo.id);
|
|
546
|
+
}
|
|
547
|
+
const message = photos.length
|
|
548
|
+
? [
|
|
549
|
+
{
|
|
550
|
+
role: "user",
|
|
551
|
+
content: [
|
|
552
|
+
{ type: "text", text: prompt },
|
|
553
|
+
...photos.map((p) => ({
|
|
554
|
+
type: "file",
|
|
555
|
+
data: p.data,
|
|
556
|
+
mediaType: p.mime,
|
|
557
|
+
filename: p.upload.name,
|
|
558
|
+
})),
|
|
559
|
+
],
|
|
560
|
+
},
|
|
529
561
|
]
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
562
|
+
: prompt;
|
|
563
|
+
// A json step streams, so the person sees its entries as they are written (`found`).
|
|
564
|
+
const result = step.output.format === "json"
|
|
565
|
+
? await streamWithProgress(agent, message, { maxSteps, abortSignal: ctx.signal }, step, ctx)
|
|
566
|
+
: await agent.generate(message, { maxSteps, abortSignal: ctx.signal });
|
|
567
|
+
await ctx.chargeUsd(costOf(resolved, await totalUsage(result)));
|
|
568
|
+
// `result.text` strings together what the model said between tool calls ("I open the page …").
|
|
569
|
+
// A written result is its last message; structuring keeps everything, numbers may sit anywhere.
|
|
570
|
+
const closing = String(result.steps?.at?.(-1)?.text ?? "").trim();
|
|
571
|
+
const everything = (result.text ?? "").trim();
|
|
572
|
+
const text = step.output.format === "json" ? everything : closing || everything;
|
|
573
|
+
if (step.output.format !== "json") {
|
|
574
|
+
if (!text && !assets.length) {
|
|
575
|
+
throw new StepError(runNote("stepNotReturnResult"));
|
|
535
576
|
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
const
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
data: p.data,
|
|
557
|
-
mediaType: p.mime,
|
|
558
|
-
filename: p.upload.name,
|
|
559
|
-
})),
|
|
560
|
-
],
|
|
561
|
-
},
|
|
562
|
-
]
|
|
563
|
-
: prompt;
|
|
564
|
-
// A json step streams, so the person sees its entries as they are written (`found`).
|
|
565
|
-
const result = step.output.format === "json"
|
|
566
|
-
? await streamWithProgress(agent, message, { maxSteps, abortSignal: ctx.signal }, step, ctx)
|
|
567
|
-
: await agent.generate(message, { maxSteps, abortSignal: ctx.signal });
|
|
568
|
-
await ctx.chargeUsd(costOf(resolved, await totalUsage(result)));
|
|
569
|
-
// `result.text` strings together what the model said between tool calls ("I open the page …").
|
|
570
|
-
// A written result is its last message; structuring keeps everything, numbers may sit anywhere.
|
|
571
|
-
const closing = String(result.steps?.at?.(-1)?.text ?? "").trim();
|
|
572
|
-
const everything = (result.text ?? "").trim();
|
|
573
|
-
const text = step.output.format === "json" ? everything : closing || everything;
|
|
574
|
-
if (step.output.format !== "json") {
|
|
575
|
-
if (!text && !assets.length) {
|
|
576
|
-
throw new StepError(runNote("stepNotReturnResult"));
|
|
577
|
-
}
|
|
578
|
-
return { text, assets: assets.length ? assets : undefined, at: new Date().toISOString() };
|
|
579
|
-
}
|
|
580
|
-
const { schema, shape } = outputSchema(step);
|
|
581
|
-
// The agent mostly writes the JSON itself; a second model only structures what does not fit.
|
|
582
|
-
// Having it copy kilobytes of JSON again is slow and can fail on its own.
|
|
583
|
-
let output = ownJson(text, schema, shape);
|
|
584
|
-
if (!output) {
|
|
585
|
-
const structurer = await textModel("classifier", ctx.call);
|
|
586
|
-
const structured = await generateText({
|
|
587
|
-
model: structurer.model,
|
|
588
|
-
abortSignal: ctx.signal,
|
|
589
|
-
// The JSON Schema built from the shape, strict: every key required, no other keys.
|
|
590
|
-
output: Output.object({
|
|
591
|
-
schema: jsonSchema(shapeJsonSchema(shape), {
|
|
592
|
-
validate: (value) => {
|
|
593
|
-
const parsed = schema.safeParse(value);
|
|
594
|
-
return parsed.success
|
|
595
|
-
? { success: true, value: parsed.data }
|
|
596
|
-
: { success: false, error: parsed.error };
|
|
597
|
-
},
|
|
598
|
-
}),
|
|
577
|
+
return { text, assets: assets.length ? assets : undefined, at: new Date().toISOString() };
|
|
578
|
+
}
|
|
579
|
+
const { schema, shape } = outputSchema(step);
|
|
580
|
+
// The agent mostly writes the JSON itself; a second model only structures what does not fit.
|
|
581
|
+
// Having it copy kilobytes of JSON again is slow and can fail on its own.
|
|
582
|
+
let output = ownJson(text, schema, shape);
|
|
583
|
+
if (!output) {
|
|
584
|
+
const structurer = await textModel("classifier", ctx.call);
|
|
585
|
+
const structured = await generateText({
|
|
586
|
+
model: structurer.model,
|
|
587
|
+
abortSignal: ctx.signal,
|
|
588
|
+
// The JSON Schema built from the shape, strict: every key required, no other keys.
|
|
589
|
+
output: Output.object({
|
|
590
|
+
schema: jsonSchema(shapeJsonSchema(shape), {
|
|
591
|
+
validate: (value) => {
|
|
592
|
+
const parsed = schema.safeParse(value);
|
|
593
|
+
return parsed.success
|
|
594
|
+
? { success: true, value: parsed.data }
|
|
595
|
+
: { success: false, error: parsed.error };
|
|
596
|
+
},
|
|
599
597
|
}),
|
|
600
|
-
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
const json = recordsOf(shape, output);
|
|
606
|
-
// A view written once is bound to this run's data; `true` asks a model for one.
|
|
607
|
-
const surface = Array.isArray(step.output.surface)
|
|
608
|
-
? { components: step.output.surface, data: json }
|
|
609
|
-
: step.output.surface
|
|
610
|
-
? await composeSurface(step, json, ctx)
|
|
611
|
-
: undefined;
|
|
612
|
-
return {
|
|
613
|
-
text,
|
|
614
|
-
json,
|
|
615
|
-
...(surface ? { surface } : {}),
|
|
616
|
-
assets: assets.length ? assets : undefined,
|
|
617
|
-
at: new Date().toISOString(),
|
|
618
|
-
};
|
|
619
|
-
}
|
|
620
|
-
finally {
|
|
621
|
-
await close();
|
|
598
|
+
}),
|
|
599
|
+
prompt: `Turn this result into the requested structure. Keep every number and source exactly.\n\n${text}`,
|
|
600
|
+
});
|
|
601
|
+
await ctx.chargeUsd(costOf(structurer, structured.usage));
|
|
602
|
+
output = structured.output;
|
|
622
603
|
}
|
|
604
|
+
const json = recordsOf(shape, output);
|
|
605
|
+
// A view written once is bound to this run's data; `true` asks a model for one.
|
|
606
|
+
const surface = Array.isArray(step.output.surface)
|
|
607
|
+
? { components: step.output.surface, data: json }
|
|
608
|
+
: step.output.surface
|
|
609
|
+
? await composeSurface(step, json, ctx)
|
|
610
|
+
: undefined;
|
|
611
|
+
return {
|
|
612
|
+
text,
|
|
613
|
+
json,
|
|
614
|
+
...(surface ? { surface } : {}),
|
|
615
|
+
assets: assets.length ? assets : undefined,
|
|
616
|
+
at: new Date().toISOString(),
|
|
617
|
+
};
|
|
623
618
|
}
|
|
624
619
|
// --- generate ----------------------------------------------------------------
|
|
625
620
|
/** The images a name stands for: an image field's uploads, or the images an earlier step made. */
|
|
@@ -9,7 +9,7 @@ import { cloudLinked, cloudState } from "../services/cloud.js";
|
|
|
9
9
|
import { ServiceError } from "../services/errors.js";
|
|
10
10
|
import { presentIn } from "../services/presence.js";
|
|
11
11
|
import { fileView, projectFiles } from "../services/project-files.js";
|
|
12
|
-
import { listProjects,
|
|
12
|
+
import { listProjects, ownedProject } from "../services/projects.js";
|
|
13
13
|
import { getPage, getRow, getTableHeader } from "../services/space-data.js";
|
|
14
14
|
import { publishedDefinition, translationsOf } from "../services/translations.js";
|
|
15
15
|
import { listWizards, ownedWizard, wizardMessages, wizardState } from "../services/wizards.js";
|
|
@@ -24,7 +24,6 @@ export async function spacesView(r) {
|
|
|
24
24
|
facts: p.facts,
|
|
25
25
|
/** The space's public page; null until it is set up. */
|
|
26
26
|
page: p.page ?? null,
|
|
27
|
-
mcpServers: maskedServers(p),
|
|
28
27
|
wizardCount: p.wizardCount,
|
|
29
28
|
/** `local`: synced from a local install, where it is changed. */
|
|
30
29
|
origin: p.origin,
|
|
@@ -58,7 +57,6 @@ export async function wizardView(r, id) {
|
|
|
58
57
|
source: m.source,
|
|
59
58
|
client: m.client,
|
|
60
59
|
})),
|
|
61
|
-
mcpServers: project.mcpServers.map((s) => ({ id: s.id, name: s.name })),
|
|
62
60
|
};
|
|
63
61
|
}
|
|
64
62
|
/** The languages the published wizard is kept in, each original text with its translation. */
|
|
@@ -171,7 +171,7 @@ export function registerTools(server, who) {
|
|
|
171
171
|
const project = projectId
|
|
172
172
|
? await ownedProject(who.userId, projectId)
|
|
173
173
|
: await defaultProject(who.userId);
|
|
174
|
-
return authoringGuide(
|
|
174
|
+
return authoringGuide(await listConnectors(project.id), await pluginToolsOf(who.tenantId));
|
|
175
175
|
});
|
|
176
176
|
// --- connectors ------------------------------------------------------------
|
|
177
177
|
tool("find_connectors", "wizards:read", {
|
|
@@ -65,7 +65,6 @@ lang, io) {
|
|
|
65
65
|
wizardId: w.id,
|
|
66
66
|
message,
|
|
67
67
|
history: history.map((m) => ({ role: m.role, content: m.content })),
|
|
68
|
-
mcpServers: project.mcpServers.map((s) => ({ id: s.id, name: s.name })),
|
|
69
68
|
connectors: await listConnectors(project.id),
|
|
70
69
|
signal: io.signal,
|
|
71
70
|
onText: io.onText,
|
|
@@ -46,7 +46,6 @@ export async function exportWizard(userId, wizardId, options = {}) {
|
|
|
46
46
|
const definition = live ? live.definition : w.draft;
|
|
47
47
|
const project = await ownedProject(userId, w.projectId);
|
|
48
48
|
const named = new Set((definition.connections ?? []).map((c) => c.connector));
|
|
49
|
-
const servers = new Set(definition.steps.flatMap((s) => (s.type === "agent" ? (s.mcp ?? []) : [])));
|
|
50
49
|
const manifest = {
|
|
51
50
|
$schema: PACKAGE_SCHEMA_URL,
|
|
52
51
|
format: PACKAGE_FORMAT,
|
|
@@ -61,9 +60,6 @@ export async function exportWizard(userId, wizardId, options = {}) {
|
|
|
61
60
|
domain: c.domain,
|
|
62
61
|
sourceKind: c.sourceKind,
|
|
63
62
|
})),
|
|
64
|
-
mcpServers: project.mcpServers
|
|
65
|
-
.filter((s) => servers.has(s.id))
|
|
66
|
-
.map((s) => ({ id: s.id, name: s.name })),
|
|
67
63
|
themes: themesOf(definition.themes, project.themes),
|
|
68
64
|
};
|
|
69
65
|
const entries = {};
|
|
@@ -123,9 +119,6 @@ async function missing(userId, projectId, draft, manifest) {
|
|
|
123
119
|
const project = await ownedProject(userId, projectId);
|
|
124
120
|
const connectors = await listConnectors(project.id);
|
|
125
121
|
const wanted = [...new Set((draft.connections ?? []).flatMap((c) => c.connector ?? []))];
|
|
126
|
-
const servers = [
|
|
127
|
-
...new Set(draft.steps.flatMap((s) => (s.type === "agent" ? (s.mcp ?? []) : []))),
|
|
128
|
-
];
|
|
129
122
|
return [
|
|
130
123
|
...wanted
|
|
131
124
|
.filter((id) => !connectors.some((c) => c.id === id))
|
|
@@ -133,9 +126,6 @@ async function missing(userId, projectId, draft, manifest) {
|
|
|
133
126
|
const told = manifest.connectors.find((c) => c.id === id);
|
|
134
127
|
return `Connector „${told?.name ?? id}“${told?.domain ? ` (${told.domain})` : ""}`;
|
|
135
128
|
}),
|
|
136
|
-
...servers
|
|
137
|
-
.filter((id) => !project.mcpServers.some((s) => s.id === id))
|
|
138
|
-
.map((id) => `MCP-Server „${manifest.mcpServers.find((s) => s.id === id)?.name ?? id}“`),
|
|
139
129
|
];
|
|
140
130
|
}
|
|
141
131
|
/** Makes a new wizard of a package in the project: the draft and its workspace, not published. */
|
|
@@ -16,13 +16,6 @@ import { notFound, ServiceError } from "./errors.js";
|
|
|
16
16
|
import { forgetWizardLinks } from "./links.js";
|
|
17
17
|
import { pushPages } from "./pages.js";
|
|
18
18
|
import { removeProjectFiles } from "./project-files.js";
|
|
19
|
-
const MASK = "••••";
|
|
20
|
-
export const mcpServerSchema = z.object({
|
|
21
|
-
id: z.string().regex(/^[a-z][a-z0-9_]{0,30}$/),
|
|
22
|
-
name: z.string().min(1).max(60),
|
|
23
|
-
url: z.string().url(),
|
|
24
|
-
headers: z.record(z.string(), z.string()).optional(),
|
|
25
|
-
});
|
|
26
19
|
const sectionId = z.string().regex(/^[A-Za-z0-9_-]{1,40}$/);
|
|
27
20
|
export const brandColorSchema = z.object({
|
|
28
21
|
name: z.string().max(120),
|
|
@@ -145,7 +138,6 @@ export const projectPatchSchema = z.object({
|
|
|
145
138
|
})
|
|
146
139
|
.optional(),
|
|
147
140
|
facts: z.array(projectFactSchema).max(PROJECT_LIMITS.facts).optional(),
|
|
148
|
-
mcpServers: z.array(mcpServerSchema).max(10).optional(),
|
|
149
141
|
});
|
|
150
142
|
/**
|
|
151
143
|
* How many projects the tenant works with: the number the Manage-App gives for it, else this
|
|
@@ -255,15 +247,6 @@ export async function listProjects(_userId, lang) {
|
|
|
255
247
|
wizardCount: counts.find((x) => x.projectId === p.id)?.n ?? 0,
|
|
256
248
|
}));
|
|
257
249
|
}
|
|
258
|
-
/** MCP server headers carry the admin's credentials: shown masked, kept when sent back masked. */
|
|
259
|
-
export function maskedServers(p) {
|
|
260
|
-
return p.mcpServers.map((s) => ({
|
|
261
|
-
...s,
|
|
262
|
-
headers: s.headers
|
|
263
|
-
? Object.fromEntries(Object.keys(s.headers).map((k) => [k, MASK]))
|
|
264
|
-
: undefined,
|
|
265
|
-
}));
|
|
266
|
-
}
|
|
267
250
|
export async function createProject(_userId, name) {
|
|
268
251
|
await requireBuild();
|
|
269
252
|
await requireAdmin();
|
|
@@ -276,9 +259,7 @@ export async function createProject(_userId, name) {
|
|
|
276
259
|
throw new ServiceError("refused", limit === 1 ? note("onlyOneSpaceAllowed") : note("mostSpaces", { count: limit }));
|
|
277
260
|
}
|
|
278
261
|
const id = nanoid(12);
|
|
279
|
-
await db
|
|
280
|
-
.insert(schema.project)
|
|
281
|
-
.values({ id, tenantId: currentTenant(), name, brand: {}, mcpServers: [] });
|
|
262
|
+
await db.insert(schema.project).values({ id, tenantId: currentTenant(), name, brand: {} });
|
|
282
263
|
spaceChanged("space.created", id);
|
|
283
264
|
return { id };
|
|
284
265
|
}
|
|
@@ -286,16 +267,6 @@ export async function updateProject(userId, projectId, patch) {
|
|
|
286
267
|
const p = await ownedProject(userId, projectId);
|
|
287
268
|
await requireWritable(p);
|
|
288
269
|
await requireAdmin();
|
|
289
|
-
const mcpServers = patch.mcpServers?.map((s) => {
|
|
290
|
-
const before = p.mcpServers.find((x) => x.id === s.id);
|
|
291
|
-
const headers = s.headers
|
|
292
|
-
? Object.fromEntries(Object.entries(s.headers).map(([k, v]) => [
|
|
293
|
-
k,
|
|
294
|
-
v === MASK ? (before?.headers?.[k] ?? "") : v,
|
|
295
|
-
]))
|
|
296
|
-
: undefined;
|
|
297
|
-
return { ...s, headers };
|
|
298
|
-
});
|
|
299
270
|
if (patch.facts && new Set(patch.facts.map((f) => f.key)).size !== patch.facts.length) {
|
|
300
271
|
throw new ServiceError("invalid", note("twoEntriesSameKey"));
|
|
301
272
|
}
|
|
@@ -309,7 +280,6 @@ export async function updateProject(userId, projectId, patch) {
|
|
|
309
280
|
...(patch.name ? { name: patch.name } : {}),
|
|
310
281
|
...(patch.brand ? { brand: brandAfter(p.brand, patch.brand) } : {}),
|
|
311
282
|
...(patch.facts ? { facts: patch.facts } : {}),
|
|
312
|
-
...(mcpServers ? { mcpServers } : {}),
|
|
313
283
|
...(page ? { page } : {}),
|
|
314
284
|
updatedAt: new Date(),
|
|
315
285
|
})
|