wizards 0.2.47 → 0.2.48
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/{project-assistant.js → studio-assistant.js} +199 -69
- package/apps/runtime/dist/agents/website.js +25 -2
- package/apps/runtime/dist/app.js +2 -1
- package/apps/runtime/dist/assistant/browser.js +26 -0
- package/apps/runtime/dist/assistant/docs.js +158 -0
- package/apps/runtime/dist/assistant/knows.js +325 -0
- package/apps/runtime/dist/assistant/primer.js +26 -0
- package/apps/runtime/dist/authoring/guide.js +5 -0
- package/apps/runtime/dist/connectors/plugin-connections.js +123 -29
- package/apps/runtime/dist/db/migrations/tenant/0012_assistant_chat.sql +40 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0012_snapshot.json +3132 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +7 -0
- package/apps/runtime/dist/db/schema.js +30 -0
- package/apps/runtime/dist/docs/dev/index.md +34 -0
- package/apps/runtime/dist/docs/dev/meta.json +7 -0
- package/apps/runtime/dist/docs/dev/plugins/connections.md +70 -0
- package/apps/runtime/dist/docs/dev/plugins/events.md +86 -0
- package/apps/runtime/dist/docs/dev/plugins/examples.md +99 -0
- package/apps/runtime/dist/docs/dev/plugins/index.md +72 -0
- package/apps/runtime/dist/docs/dev/plugins/layout.md +88 -0
- package/apps/runtime/dist/docs/dev/plugins/meta.json +29 -0
- package/apps/runtime/dist/docs/dev/plugins/pro-modules.md +59 -0
- package/apps/runtime/dist/docs/dev/plugins/quick-start.md +92 -0
- package/apps/runtime/dist/docs/dev/plugins/reference.md +298 -0
- package/apps/runtime/dist/docs/dev/plugins/reloading.md +75 -0
- package/apps/runtime/dist/docs/dev/plugins/routes.md +123 -0
- package/apps/runtime/dist/docs/dev/plugins/runners.md +184 -0
- package/apps/runtime/dist/docs/dev/plugins/server.md +191 -0
- package/apps/runtime/dist/docs/dev/plugins/shipping.md +98 -0
- package/apps/runtime/dist/docs/dev/plugins/space.md +260 -0
- package/apps/runtime/dist/docs/dev/plugins/starters.md +62 -0
- package/apps/runtime/dist/docs/dev/plugins/studio.md +261 -0
- package/apps/runtime/dist/docs/dev/plugins/styling.md +109 -0
- package/apps/runtime/dist/docs/dev/plugins/tables.md +102 -0
- package/apps/runtime/dist/docs/dev/plugins/tools.md +128 -0
- package/apps/runtime/dist/docs/meta.json +3 -0
- package/apps/runtime/dist/docs/user/ai-apps.md +99 -0
- package/apps/runtime/dist/docs/user/assistant.md +52 -0
- package/apps/runtime/dist/docs/user/build-a-wizard.md +79 -0
- package/apps/runtime/dist/docs/user/command-line.md +76 -0
- package/apps/runtime/dist/docs/user/connectors.md +80 -0
- package/apps/runtime/dist/docs/user/data.md +61 -0
- package/apps/runtime/dist/docs/user/first-start.md +42 -0
- package/apps/runtime/dist/docs/user/index.md +45 -0
- package/apps/runtime/dist/docs/user/install.md +76 -0
- package/apps/runtime/dist/docs/user/meta.json +29 -0
- package/apps/runtime/dist/docs/user/models.md +100 -0
- package/apps/runtime/dist/docs/user/plugins.md +61 -0
- package/apps/runtime/dist/docs/user/run.md +92 -0
- package/apps/runtime/dist/docs/user/server.md +50 -0
- package/apps/runtime/dist/docs/user/space.md +97 -0
- package/apps/runtime/dist/docs/user/steps.md +196 -0
- package/apps/runtime/dist/docs/user/test-and-share.md +210 -0
- package/apps/runtime/dist/docs/user/troubleshooting.md +57 -0
- package/apps/runtime/dist/engine/runner.js +12 -5
- package/apps/runtime/dist/manage.js +11 -0
- package/apps/runtime/dist/plugins/loader.js +2 -0
- package/apps/runtime/dist/routes/studio.js +119 -68
- package/apps/runtime/dist/services/assistant-chats.js +267 -0
- package/apps/runtime/dist/services/project-index.js +1 -1
- package/apps/runtime/dist/services/space-origin.js +45 -2
- package/apps/web/dist/assets/{AboutDialog-t7bpiasT.js → AboutDialog-CuiVGknS.js} +1 -1
- package/apps/web/dist/assets/{ChangelogDialog-B87yS6aN.js → ChangelogDialog-DCEQD3Jd.js} +1 -1
- package/apps/web/dist/assets/ChatView-DFxrG2PD.js +10 -0
- package/apps/web/dist/assets/EditorPage-B5rzKNMy.js +3 -0
- package/apps/web/dist/assets/{FlowPreview-ChXfiMn_.js → FlowPreview-CYoR5DRY.js} +1 -1
- package/apps/web/dist/assets/{Harness-zKMptCzB.js → Harness-DAR1u4Dk.js} +1 -1
- package/apps/web/dist/assets/HomePage-BnYdh_Nx.js +1 -0
- package/apps/web/dist/assets/Marketplace-BDQNwMDB.js +2 -0
- package/apps/web/dist/assets/{NewWizardPage-C3NqEGmg.js → NewWizardPage-DztTEUlG.js} +1 -1
- package/apps/web/dist/assets/ProjectPage-B7-Lqx9a.js +2 -0
- package/apps/web/dist/assets/PublicRunner-CaH3bHHd.js +1 -0
- package/apps/web/dist/assets/{ReadOnly-C9P9aiU6.js → ReadOnly-DnB47DQC.js} +1 -1
- package/apps/web/dist/assets/RunDrawer-Dv0KRqGA.js +4 -0
- package/apps/web/dist/assets/RunnerView-Bzwv1u4j.js +2 -0
- package/apps/web/dist/assets/SettingsPage-oVO7CKvc.js +1 -0
- package/apps/web/dist/assets/{SetupPage-B3IOQLO3.js → SetupPage-D--8cWA0.js} +1 -1
- package/apps/web/dist/assets/{SharePage-C3QEzicl.js → SharePage-DjU08q7T.js} +1 -1
- package/apps/web/dist/assets/{ThemeSwitch-3IzIOlNz.js → ThemeSwitch-C3EJRN06.js} +1 -1
- package/apps/web/dist/assets/arrow-right-F7X_SjK9.js +1 -0
- package/apps/web/dist/assets/changelog-BRoVI_JJ.js +1 -0
- package/apps/web/dist/assets/{circle-alert-CPo3Naay.js → circle-alert-DdpaAYgd.js} +1 -1
- package/apps/web/dist/assets/{definition-CQGiBQ4X.js → definition-CHacJYmI.js} +2 -2
- package/apps/web/dist/assets/{external-link-CpU8aJY2.js → external-link-Dfc1VFvS.js} +1 -1
- package/apps/web/dist/assets/index-CX_yxZVQ.js +79 -0
- package/apps/web/dist/assets/index-Dr0bv52Q.css +1 -0
- package/apps/web/dist/assets/{lock-C_WlXIQ0.js → lock-Bu1wDFs8.js} +1 -1
- package/apps/web/dist/assets/{refresh-cw-Cli5WGnW.js → refresh-cw-BUDPOT39.js} +1 -1
- package/apps/web/dist/assets/{session-miDEdw2c.js → session-Blj2os_v.js} +1 -1
- package/apps/web/dist/assets/{settings-menu-ROT8Lbbj.js → settings-menu-BvxRnNtf.js} +1 -1
- package/apps/web/dist/assets/{sparkles-CP5H-O1E.js → sparkles-DWGJluyV.js} +1 -1
- package/apps/web/dist/assets/{trash-DU-hZpV0.js → trash-D9UB6TtS.js} +1 -1
- package/apps/web/dist/assets/ui-GsuU9WTj.js +9 -0
- package/apps/web/dist/assets/{upload-DMq5N6Fw.js → upload-BngimDBR.js} +1 -1
- package/apps/web/dist/assets/{volume-2-0SfkvOho.js → volume-2-BZju_bOP.js} +1 -1
- package/apps/web/dist/index.html +11 -11
- package/apps/web/dist/mcp/flow.html +51 -51
- package/node_modules/@engenty-wizards/plugin-sdk/dist/index.d.ts +82 -7
- package/node_modules/@engenty-wizards/plugin-sdk/dist/studio.d.ts +58 -4
- package/node_modules/@engenty-wizards/shared/dist/assistant.d.ts +113 -0
- package/node_modules/@engenty-wizards/shared/dist/assistant.js +55 -0
- package/node_modules/@engenty-wizards/shared/dist/definition.d.ts +56 -1
- package/node_modules/@engenty-wizards/shared/dist/definition.js +94 -4
- package/node_modules/@engenty-wizards/shared/dist/run.d.ts +3 -1
- package/package.json +1 -1
- package/apps/web/dist/assets/ChatView-Dm764bYy.js +0 -10
- package/apps/web/dist/assets/EditorPage-BG_Ue2iC.js +0 -3
- package/apps/web/dist/assets/HomePage-BXSg5P5k.js +0 -1
- package/apps/web/dist/assets/Marketplace-BWhUJ4UX.js +0 -2
- package/apps/web/dist/assets/ProjectPage-D6Fy7uTV.js +0 -2
- package/apps/web/dist/assets/PublicRunner-ChgJs0C9.js +0 -1
- package/apps/web/dist/assets/RunDrawer-CvIKLphz.js +0 -4
- package/apps/web/dist/assets/RunnerView-Bmayop7s.js +0 -2
- package/apps/web/dist/assets/SettingsPage-QkwtRFoD.js +0 -1
- package/apps/web/dist/assets/arrow-right-Dpp_mpHe.js +0 -1
- package/apps/web/dist/assets/changelog-Du2gWzlN.js +0 -1
- package/apps/web/dist/assets/index-Cz6c1S5g.js +0 -78
- package/apps/web/dist/assets/index-DKHClEy3.css +0 -1
- package/apps/web/dist/assets/ui-D92EkdEB.js +0 -9
|
@@ -438,6 +438,36 @@ export const spaceItemCategory = sqliteTable("space_item_category", {
|
|
|
438
438
|
index("space_item_category_table").on(t.tableId),
|
|
439
439
|
index("space_item_category_file").on(t.fileId),
|
|
440
440
|
]);
|
|
441
|
+
export const assistantChat = sqliteTable("assistant_chat", {
|
|
442
|
+
id: text("id").primaryKey(),
|
|
443
|
+
tenantId: text("tenant_id").notNull(),
|
|
444
|
+
userId: text("user_id").notNull(),
|
|
445
|
+
/** Set when the chat is closed; null for the open one. */
|
|
446
|
+
title: text("title"),
|
|
447
|
+
/**
|
|
448
|
+
* Open: what the messages folded away said (`folded` of them, oldest first). Closed: the dense
|
|
449
|
+
* summary of the whole chat — what was asked, what changed, what is still open.
|
|
450
|
+
*/
|
|
451
|
+
summary: text("summary"),
|
|
452
|
+
folded: integer("folded").notNull().default(0),
|
|
453
|
+
createdAt: createdAt(),
|
|
454
|
+
closedAt: integer("closed_at", { mode: "timestamp_ms" }),
|
|
455
|
+
}, (t) => [index("assistant_chat_user").on(t.tenantId, t.userId, t.closedAt)]);
|
|
456
|
+
export const assistantMessage = sqliteTable("assistant_message", {
|
|
457
|
+
id: text("id").primaryKey(),
|
|
458
|
+
chatId: text("chat_id")
|
|
459
|
+
.notNull()
|
|
460
|
+
.references(() => assistantChat.id, { onDelete: "cascade" }),
|
|
461
|
+
role: text("role", { enum: ["user", "assistant"] }).notNull(),
|
|
462
|
+
content: text("content").notNull(),
|
|
463
|
+
/** Cards of plugins' tools, with their data, so an earlier chat shows them again. */
|
|
464
|
+
cards: text("cards", { mode: "json" }).$type(),
|
|
465
|
+
toolCalls: text("tool_calls", { mode: "json" }).$type(),
|
|
466
|
+
/** The page the person wrote from: route and title (the snapshot of that turn, cut short). */
|
|
467
|
+
page: text("page", { mode: "json" }).$type(),
|
|
468
|
+
changed: integer("changed", { mode: "boolean" }).notNull().default(false),
|
|
469
|
+
createdAt: createdAt(),
|
|
470
|
+
}, (t) => [index("assistant_message_chat").on(t.chatId, t.createdAt)]);
|
|
441
471
|
// --- The wizard's store ------------------------------------------------------
|
|
442
472
|
// What a wizard keeps between runs for one person. `holder` is that person: "u:<userId>" for a
|
|
443
473
|
// signed-in admin, "v:<visitorId>" for an end user on a shared link.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Developer
|
|
3
|
+
description: Extend engenty wizards with plugins — tools for AI steps, routes with their own tables, pages in the studio.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
engenty wizards is extended with **plugins**. A plugin adds to a runtime without changing its
|
|
7
|
+
code, and it loads from its files while the app runs.
|
|
8
|
+
|
|
9
|
+
## Start here
|
|
10
|
+
|
|
11
|
+
| | |
|
|
12
|
+
|---|---|
|
|
13
|
+
| [What a plugin is](./plugins/index.md) | The two halves, what each can add, what a plugin may touch |
|
|
14
|
+
| [Quick start](./plugins/quick-start.md) | A tool for AI steps in one file, working in two minutes |
|
|
15
|
+
| [Reference](./plugins/reference.md) | Every call, type, address and setting |
|
|
16
|
+
| [Examples](./plugins/examples.md) | Two plugins to read and copy |
|
|
17
|
+
|
|
18
|
+
## What you need
|
|
19
|
+
|
|
20
|
+
- An install of engenty wizards, or a checkout of
|
|
21
|
+
[engenty/engenty-wizards](https://github.com/engenty/engenty-wizards).
|
|
22
|
+
- TypeScript. A plugin's server half is read as TypeScript, without a build.
|
|
23
|
+
- A checkout, if your plugin draws in the studio: its studio half is built with the studio's
|
|
24
|
+
own tools.
|
|
25
|
+
|
|
26
|
+
## Working on engenty wizards itself
|
|
27
|
+
|
|
28
|
+
These pages are about extending it. The code's own documents are in the repository:
|
|
29
|
+
|
|
30
|
+
| | |
|
|
31
|
+
|---|---|
|
|
32
|
+
| [docs/development.md](https://github.com/engenty/engenty-wizards/blob/main/docs/development.md) | Run it from source, the checks, how it is built, releases |
|
|
33
|
+
| [docs/manage-contract.md](https://github.com/engenty/engenty-wizards/blob/main/docs/manage-contract.md) | What a runtime and a Manage-App speak |
|
|
34
|
+
| [docs/marketplace-contract.md](https://github.com/engenty/engenty-wizards/blob/main/docs/marketplace-contract.md) | What a runtime and the marketplace speak |
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Accounts
|
|
3
|
+
description: Accounts a plugin connects for a space — a calendar, a mailbox — through the runtime's built-in connectors.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
A wizard's connections belong to the person who runs it. A plugin that works for the whole
|
|
7
|
+
space, a calendar that every booking wizard reads, connects an account of its own:
|
|
8
|
+
`server.connections`. It uses the runtime's built-in OAuth connectors (Google, Microsoft, Slack,
|
|
9
|
+
GitHub, HubSpot …), keeps the tokens sealed in the tenant's database, and refreshes them.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
const ACTIONS = ["list_events", "create_event", "delete_event"];
|
|
13
|
+
|
|
14
|
+
// Which of them can be signed in to on this runtime now.
|
|
15
|
+
const offered = await server.connections.available(["google-calendar", "microsoft-outlook"]);
|
|
16
|
+
|
|
17
|
+
// The provider's sign-in page, for a route of the plugin to hand to its studio half.
|
|
18
|
+
const { url } = await server.connections.start({ space, connector: "google-calendar", actions: ACTIONS });
|
|
19
|
+
|
|
20
|
+
// Later, in a route, a tool or a job:
|
|
21
|
+
const [account] = await server.connections.list(space);
|
|
22
|
+
const { events } = await server.connections.call(account.id, "list_events", {
|
|
23
|
+
time_min: from,
|
|
24
|
+
time_max: to,
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
| `server.connections.` | Does |
|
|
29
|
+
|---|---|
|
|
30
|
+
| `available(ids)` | Of these connector ids, the ones a person can connect here now: `{ id, name, auth }`, and for `auth: "api_key"` the `fields` to ask for (`key`, `label`, `placeholder`, `required`, `secret`). An OAuth connector is offered once its client is set up (`GOOGLE_OAUTH_CLIENT_ID` …), and on a local install Google also through the linked account; a connector that takes keys (HubSpot, S3) always |
|
|
31
|
+
| `start({ space, connector, actions })` | An OAuth connector: the provider's sign-in page. Only the rights `actions` need are asked for |
|
|
32
|
+
| `connect({ space, connector, actions, credentials })` | A connector that takes keys: the keys by field key, tried once at the provider, then kept sealed. Keys the provider refuses throw an error with the status `400` and the code `credentials`, whose message says what was wrong. Answers the connection |
|
|
33
|
+
| `list(space)`, `get(id)` | What is connected: `{ id, space, connector, label, actions, createdAt }`, the newest first. `label` is the account as the provider names it |
|
|
34
|
+
| `call(id, action, input)` | Runs one of the connector's actions with the account. A fresh token is fetched first when the old one runs out |
|
|
35
|
+
| `remove(id)` | Forgets the connection and its tokens |
|
|
36
|
+
|
|
37
|
+
## Signing in
|
|
38
|
+
|
|
39
|
+
`start` gives an address; open it in a window from the studio half. The provider sends the
|
|
40
|
+
person back to the runtime (`/api/connect/callback`, the address a wizard's connections use), the
|
|
41
|
+
runtime keeps the account under the plugin and the space, and the window posts a message to the
|
|
42
|
+
studio and closes:
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
const { url } = await studio.api.post<{ url: string }>(`/connect?space=${space.id}`);
|
|
46
|
+
window.open(url, "connect", "width=520,height=700");
|
|
47
|
+
|
|
48
|
+
window.addEventListener("message", (event) => {
|
|
49
|
+
if (event.data?.type === "wizards:connected") {
|
|
50
|
+
refetch();
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
- A second sign-in to the same account for the same space replaces the first one's tokens and
|
|
56
|
+
actions; it does not add a second connection.
|
|
57
|
+
- A local install without a Google client of its own connects Google through the Manage-App of
|
|
58
|
+
the linked account. Without a linked account `start` throws an error with the status `409` and
|
|
59
|
+
the code `account`, whose message says what to do.
|
|
60
|
+
|
|
61
|
+
## What `call` refuses
|
|
62
|
+
|
|
63
|
+
- An action the connection was not made for: connect again with that action in `actions`.
|
|
64
|
+
- What the provider refuses: its error, with the status and the first words of its answer. A
|
|
65
|
+
connection the person removed at the provider answers so on the next call.
|
|
66
|
+
|
|
67
|
+
## Where it is kept
|
|
68
|
+
|
|
69
|
+
The table `plugin_connection` of the tenant's database, by plugin and space. A plugin sees only
|
|
70
|
+
its own connections. Deleting a space deletes them. Unloading or removing the plugin leaves them.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Events
|
|
3
|
+
description: Do something when a run ends or a space changes — keep who it was, post a message, read a new document.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
A plugin can listen to runs that reach their end, and to spaces that change.
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
// A real run ended: keep who it was.
|
|
10
|
+
server.on("run.done", async ({ run, wizard, values }) => {
|
|
11
|
+
const email = typeof values.email === "string" ? values.email.trim().toLowerCase() : "";
|
|
12
|
+
if (run.mode !== "live" || !email) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const seen = {
|
|
16
|
+
name: typeof values.name === "string" ? values.name : null,
|
|
17
|
+
wizard: wizard.title,
|
|
18
|
+
seenAt: new Date(),
|
|
19
|
+
};
|
|
20
|
+
await db()
|
|
21
|
+
.insert(person)
|
|
22
|
+
.values({ email, ...seen })
|
|
23
|
+
.onConflictDoUpdate({ target: person.email, set: seen });
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Events
|
|
28
|
+
|
|
29
|
+
| Event | A run |
|
|
30
|
+
|---|---|
|
|
31
|
+
| `run.done` | reached its result |
|
|
32
|
+
| `run.failed` | stopped with an error |
|
|
33
|
+
| `run.cancelled` | was cancelled |
|
|
34
|
+
|
|
35
|
+
| Event | A space | Gets |
|
|
36
|
+
|---|---|---|
|
|
37
|
+
| `space.created` | was made, here or by a local install's sync | `{ space: { id } }` |
|
|
38
|
+
| `space.updated` | changed its title, about, colours, facts or systems | `{ space: { id } }` |
|
|
39
|
+
| `space.deleted` | was deleted | `{ space: { id } }` |
|
|
40
|
+
| `space.file.ready` | has a file that was read: a document is in the index now | `{ space: { id }, file: { id, name, kind, mime } }` |
|
|
41
|
+
| `space.file.removed` | lost a file | `{ space: { id }, file: { id, name, kind, mime } }` |
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
// A document arrived: read it into the wiki.
|
|
45
|
+
server.on("space.file.ready", async ({ space, file }) => {
|
|
46
|
+
if (file.kind === "document") {
|
|
47
|
+
await queue(space.id, file.id);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The space events are not waited for: the request that changed the space answers before its
|
|
53
|
+
listeners are done.
|
|
54
|
+
|
|
55
|
+
## What a run listener gets
|
|
56
|
+
|
|
57
|
+
| | |
|
|
58
|
+
|---|---|
|
|
59
|
+
| `run.id`, `run.wizardId` | The run and its wizard |
|
|
60
|
+
| `run.mode` | `"live"`: a real run, over the wizard's link or from an AI app. `"test"`: a test run |
|
|
61
|
+
| `run.status` | `"done"`, `"failed"` or `"cancelled"` |
|
|
62
|
+
| `wizard` | `{ id, title, projectId }` |
|
|
63
|
+
| `values` | What the person answered, by field id |
|
|
64
|
+
|
|
65
|
+
`values` holds answers as the wizard asked for them. Which fields exist depends on the wizard: a
|
|
66
|
+
listener that wants an e-mail address looks for a field with the id it expects and does nothing
|
|
67
|
+
when it is missing. Check the type of every value you use.
|
|
68
|
+
|
|
69
|
+
## Rules a listener runs under
|
|
70
|
+
|
|
71
|
+
- **Inside the run's tenant.** `server.getTenantDb()` is that tenant's database.
|
|
72
|
+
- **After the run ended.** A listener cannot change the run or its result.
|
|
73
|
+
- **It cannot fail the run.** A listener that throws is logged with the plugin's id.
|
|
74
|
+
- **It can be told twice.** A finished run that is redone and ends again fires the event again.
|
|
75
|
+
Write listeners so that a second call does no harm: update a row instead of adding one, or
|
|
76
|
+
remember the run's id.
|
|
77
|
+
- **Nobody waits for it.** Give outside calls a time limit:
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
await fetch(url, { method: "POST", body, signal: AbortSignal.timeout(10_000) });
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Test runs
|
|
84
|
+
|
|
85
|
+
Test runs fire the same events with `run.mode === "test"`. A plugin that keeps data about real
|
|
86
|
+
people, or tells someone outside, leaves them out, as the example above does.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Examples
|
|
3
|
+
description: Two plugins in the repository to read, run and copy.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
The repository has two example plugins. Load them from a checkout with one line in `.env.local`:
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
PLUGINS_DIR=examples/plugins
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## notify: one file
|
|
13
|
+
|
|
14
|
+
[examples/plugins/notify.ts](https://github.com/engenty/engenty-wizards/blob/main/examples/plugins/notify.ts)
|
|
15
|
+
posts a line to an address whenever a real run of a wizard reached its end.
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import type { WizardsPluginFactory } from "@engenty-wizards/plugin-sdk";
|
|
19
|
+
|
|
20
|
+
const plugin: WizardsPluginFactory = (wizards) => {
|
|
21
|
+
const url = wizards.config.get("NOTIFY_URL");
|
|
22
|
+
if (!url) {
|
|
23
|
+
wizards.log.warn("NOTIFY_URL is not set: nothing will be sent.");
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
wizards.server.on("run.done", async ({ run, wizard }) => {
|
|
27
|
+
if (run.mode !== "live") {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
await fetch(url, {
|
|
31
|
+
method: "POST",
|
|
32
|
+
headers: { "content-type": "application/json" },
|
|
33
|
+
body: JSON.stringify({ wizard: wizard.title, run: run.id }),
|
|
34
|
+
signal: AbortSignal.timeout(10_000),
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default plugin;
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
| It shows | |
|
|
43
|
+
|---|---|
|
|
44
|
+
| A plugin of one file | Its id is the file's name |
|
|
45
|
+
| A setting | `NOTIFY_URL` in the install's `.env`, read at load time |
|
|
46
|
+
| A listener | Test runs left out, a time limit on the call |
|
|
47
|
+
|
|
48
|
+
## run-log: both halves
|
|
49
|
+
|
|
50
|
+
[examples/plugins/run-log](https://github.com/engenty/engenty-wizards/tree/main/examples/plugins/run-log)
|
|
51
|
+
keeps a line for every run that ended and shows them in the studio.
|
|
52
|
+
|
|
53
|
+
| File | Shows |
|
|
54
|
+
|---|---|
|
|
55
|
+
| `engenty.plugin.json` | A manifest |
|
|
56
|
+
| `migrations/0001_init.sql` | A table, `run_log_entry`, with an index |
|
|
57
|
+
| `migrations/0002_space.sql` | A column added later: the space of each line |
|
|
58
|
+
| `src/schema.ts` | The same table for Drizzle |
|
|
59
|
+
| `src/plugin.ts` | A listener on all three events, two routes (one for admins only, one that filters by space) and a tool, `run-log.recent` |
|
|
60
|
+
| `ui/messages.ts` | Words in German and English |
|
|
61
|
+
| `ui/plugin.tsx` | A section of the space page with the space's last runs, under Ergebnisse, a page with the whole log, and a section of the settings that empties the log |
|
|
62
|
+
| `package.json` | A workspace package whose `build` script builds the studio half |
|
|
63
|
+
|
|
64
|
+
Build its studio half once, or on every save:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
node scripts/build-plugin.mjs examples/plugins/run-log
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
node scripts/build-plugin.mjs examples/plugins/run-log --watch
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Then, in the studio:
|
|
75
|
+
|
|
76
|
+
1. Test a wizard to its end.
|
|
77
|
+
2. The space's tile in the app bar → Ergebnisse shows "Runs" below the results: the last five runs of
|
|
78
|
+
the space's wizards. Its last line opens the page with the whole log.
|
|
79
|
+
3. Settings → Runs shows how many lines are kept and deletes them.
|
|
80
|
+
4. An AI step can list the tool "Run log" and tell how the last runs ended.
|
|
81
|
+
|
|
82
|
+
## The plugin of these pages
|
|
83
|
+
|
|
84
|
+
The `contacts` plugin these pages build up, piece by piece:
|
|
85
|
+
|
|
86
|
+
| Piece | Page |
|
|
87
|
+
|---|---|
|
|
88
|
+
| The table `contacts_person` | [Tables](./tables.md) |
|
|
89
|
+
| The listener that keeps who ran a wizard | [Events](./events.md) |
|
|
90
|
+
| The routes that list and remove contacts | [Routes](./routes.md) |
|
|
91
|
+
| The tool `contacts.lookup` | [Tools](./tools.md) |
|
|
92
|
+
| The page and the settings section | [The studio half](./studio.md) |
|
|
93
|
+
|
|
94
|
+
## Tests to read
|
|
95
|
+
|
|
96
|
+
[apps/runtime/test/plugins.test.ts](https://github.com/engenty/engenty-wizards/blob/main/apps/runtime/test/plugins.test.ts)
|
|
97
|
+
writes small plugins into a folder and exercises them: finding, loading, a plugin that fails,
|
|
98
|
+
routes, tables per tenant, tools in a run, events, reloading. `managed.test.ts` beside it covers
|
|
99
|
+
which tenant has which plugin.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Plugins
|
|
3
|
+
description: What a plugin is, what its two halves can add, and what it may touch.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
A plugin adds to a runtime without changing its code. The runtime finds plugins at start, loads
|
|
7
|
+
them from their files and loads one again when its files change.
|
|
8
|
+
|
|
9
|
+
## What a plugin can add
|
|
10
|
+
|
|
11
|
+
| It adds | Where it shows | Page |
|
|
12
|
+
|---|---|---|
|
|
13
|
+
| A tool for AI steps | In a step's tool list, in the assistant's and the MCP authoring guide | [Tools](./tools.md) |
|
|
14
|
+
| A runner: a door a wizard runs through, with the run API that drives runs from it | In the share dialog's channels, at `/w/<token>/<runner>`, on the wizard's first page | [Runners](./runners.md) |
|
|
15
|
+
| A block and tools for every AI step of a space | In the steps' instructions | [The space](./space.md) |
|
|
16
|
+
| Pages, tables and files of a space's Wissen, with Kategorien | In Wissen, and in what `project_search` finds | [The space](./space.md#wissen-a-plugin-writes) |
|
|
17
|
+
| Texts in a space's search index | In what `project_search` finds | [The space](./space.md#the-search-index) |
|
|
18
|
+
| Tools of the studio's assistant, and their cards | In the assistant's chat, on every page | [The space](./space.md#tools-of-the-space-assistant) |
|
|
19
|
+
| Routes | Below `/api/studio/plugins/<id>`; public ones below `/api/public/plugins/<id>` | [Routes](./routes.md) |
|
|
20
|
+
| Tables | In every tenant's database | [Tables](./tables.md) |
|
|
21
|
+
| A listener on runs that end and spaces that change | Nowhere: it works in the background | [Events](./events.md) |
|
|
22
|
+
| A job, again and again | Nowhere: it works in the background | [The server half](./server.md#jobs) |
|
|
23
|
+
| An account of a space (a calendar, a mailbox), signed in through a built-in connector | Where the plugin's own pages offer it | [Accounts](./connections.md) |
|
|
24
|
+
| A wizard as a template | First among the templates of a new wizard, and in the MCP `list_starters` | [Starters](./starters.md) |
|
|
25
|
+
| A page of the studio | Behind an icon in the app bar, or at its address | [The studio half](./studio.md) |
|
|
26
|
+
| A section of the settings | In the settings' list | [The studio half](./studio.md) |
|
|
27
|
+
| A section of the space page | In one of its parts, below the part's own sections | [The studio half](./studio.md#the-space) |
|
|
28
|
+
|
|
29
|
+
## Two halves
|
|
30
|
+
|
|
31
|
+
| | Server half | Studio half |
|
|
32
|
+
|---|---|---|
|
|
33
|
+
| File | `src/plugin.ts`, or the one file a small plugin is | `ui/plugin.tsx`, built to `dist/client.js` and `dist/client.css` |
|
|
34
|
+
| Runs in | The runtime | The studio, after sign-in |
|
|
35
|
+
| Loaded | As TypeScript, no build | As the built script |
|
|
36
|
+
| Types | `@engenty-wizards/plugin-sdk` | `@engenty-wizards/plugin-sdk/studio` |
|
|
37
|
+
| Adds | Tools, runners, routes, tables, listeners, jobs, starters, Wissen, the space's block, index and assistant tools | Pages, icons in the app bar, sections of the settings and of the space page, cards in the assistant's chat |
|
|
38
|
+
|
|
39
|
+
A plugin has one half or both. The studio half talks to the server half over the plugin's own
|
|
40
|
+
routes.
|
|
41
|
+
|
|
42
|
+
```mermaid
|
|
43
|
+
flowchart LR
|
|
44
|
+
page["Studio half, in the browser<br/>ui/plugin.tsx<br/>pages, app bar, settings"]
|
|
45
|
+
runner["The runtime's step runner"]
|
|
46
|
+
server["Server half, in the runtime<br/>src/plugin.ts<br/>tools, routes, listeners"]
|
|
47
|
+
db[("Tenant database<br/>the plugin's tables")]
|
|
48
|
+
page -- "the plugin's routes" --> server
|
|
49
|
+
runner -- "calls a tool, says a run ended" --> server
|
|
50
|
+
server --> db
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## What a plugin may touch
|
|
54
|
+
|
|
55
|
+
A plugin runs inside the runtime's process with all of its rights. It reads every tenant's data,
|
|
56
|
+
the install's settings and the files of the machine. There is no sandbox and no permission list.
|
|
57
|
+
|
|
58
|
+
- Install only code you know.
|
|
59
|
+
- A plugin for others says in its own description what it reads and where it sends it.
|
|
60
|
+
|
|
61
|
+
## Not the Claude Code plugin
|
|
62
|
+
|
|
63
|
+
The "Claude Code plugin" of engenty wizards is something else: what a runtime hands to Claude
|
|
64
|
+
Code (`plugin/` in the repository). These pages are about plugins of the runtime.
|
|
65
|
+
|
|
66
|
+
## Not there yet
|
|
67
|
+
|
|
68
|
+
- Connectors of its own, tools for MCP clients and AI clients from a plugin. A plugin connects
|
|
69
|
+
accounts through the built-in connectors: [Accounts](./connections.md).
|
|
70
|
+
- New kinds of steps or fields: the public pages of a wizard load no plugin. A plugin's runner
|
|
71
|
+
is served whole at its own sub-path; nothing is loaded into the page or the chat.
|
|
72
|
+
- Building a studio half without a checkout of the repository.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Files and manifest
|
|
3
|
+
description: Where the runtime looks for plugins, what counts as one, and what engenty.plugin.json says.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Where the runtime looks
|
|
7
|
+
|
|
8
|
+
| Folder | What is in it |
|
|
9
|
+
|---|---|
|
|
10
|
+
| `modules/` of the runtime | Plugins that ship with engenty wizards |
|
|
11
|
+
| Each folder of `PLUGINS_DIR` (comma-separated) | Plugins of this install |
|
|
12
|
+
|
|
13
|
+
- An installed app looks in `~/.engenty/wizards/plugins` unless its `.env` names another folder.
|
|
14
|
+
- From a checkout `PLUGINS_DIR` is empty. `PLUGINS_DIR=examples/plugins` in `.env.local` loads
|
|
15
|
+
the examples.
|
|
16
|
+
- A runtime that watches its plugins makes a folder of `PLUGINS_DIR` that is missing.
|
|
17
|
+
|
|
18
|
+
## What counts as a plugin
|
|
19
|
+
|
|
20
|
+
In such a folder:
|
|
21
|
+
|
|
22
|
+
| Entry | Is |
|
|
23
|
+
|---|---|
|
|
24
|
+
| `notify.ts`, `notify.js` | A plugin of one file. Its id is the file's name |
|
|
25
|
+
| `contacts/engenty.plugin.json` | A plugin with a manifest |
|
|
26
|
+
| `hello/index.ts`, `hello/index.js` | A plugin without a manifest. Its id is the folder's name |
|
|
27
|
+
| `node_modules/<package>`, `node_modules/@scope/<package>` | Installed packages that carry a manifest |
|
|
28
|
+
|
|
29
|
+
- Names that begin with `.` or `_` are skipped.
|
|
30
|
+
- `.mjs` files are not read: Node keeps such a file once imported, so it could not load again.
|
|
31
|
+
- Of two plugins with one id the first found stays. The other shows under "Not a plugin" in
|
|
32
|
+
Settings → Plugins, as does a manifest that cannot be read.
|
|
33
|
+
|
|
34
|
+
## A plugin's folder
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
contacts/
|
|
38
|
+
engenty.plugin.json the manifest
|
|
39
|
+
src/
|
|
40
|
+
plugin.ts the server half
|
|
41
|
+
schema.ts its tables, for Drizzle
|
|
42
|
+
migrations/
|
|
43
|
+
0001_init.sql the tables, as SQL
|
|
44
|
+
ui/
|
|
45
|
+
plugin.tsx the studio half, as you write it
|
|
46
|
+
dist/
|
|
47
|
+
client.js the studio half, built
|
|
48
|
+
client.css
|
|
49
|
+
package.json only if it has dependencies of its own
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Only the manifest is required. A plugin with a studio half is a folder with a manifest.
|
|
53
|
+
|
|
54
|
+
## The manifest
|
|
55
|
+
|
|
56
|
+
`engenty.plugin.json` is the file an engenty module has. Fields this runtime does not know are
|
|
57
|
+
kept as they are.
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"id": "contacts",
|
|
62
|
+
"name": "Contacts",
|
|
63
|
+
"version": "0.1.0",
|
|
64
|
+
"description": "Keeps the e-mail address of everyone who ran a wizard to its end."
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
| Field | | Default |
|
|
69
|
+
|---|---|---|
|
|
70
|
+
| `id` | Lower case, digits and `-`, starting with a letter, at most 40 characters. Part of the plugin's addresses and of its tools' ids | required |
|
|
71
|
+
| `name` | Shown in the settings | required |
|
|
72
|
+
| `version` | Shown in the settings | `0.0.0` |
|
|
73
|
+
| `description` | Shown in the settings | |
|
|
74
|
+
| `server` | The server half, from the plugin's folder | `src/plugin.ts`, then `src/plugin.js`, then `dist/plugin.js` |
|
|
75
|
+
| `studio` | The built studio half | `dist/client.js` |
|
|
76
|
+
| `styles` | The built studio half's styles | `dist/client.css` |
|
|
77
|
+
|
|
78
|
+
A path in the manifest must stay inside the plugin's folder.
|
|
79
|
+
|
|
80
|
+
## Dependencies
|
|
81
|
+
|
|
82
|
+
| The plugin imports | It comes from |
|
|
83
|
+
|---|---|
|
|
84
|
+
| `@engenty-wizards/plugin-sdk`, `zod`, `drizzle-orm`, `drizzle-orm/sqlite-core` | The runtime's own copies, wherever the plugin's file is |
|
|
85
|
+
| Its own files | Beside it, as TypeScript |
|
|
86
|
+
| Anything else | A `node_modules` the plugin brings beside it |
|
|
87
|
+
|
|
88
|
+
For the studio half see [The studio half](./studio.md#what-the-studio-shares).
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "Plugins",
|
|
3
|
+
"defaultOpen": true,
|
|
4
|
+
"pages": [
|
|
5
|
+
"index",
|
|
6
|
+
"quick-start",
|
|
7
|
+
"layout",
|
|
8
|
+
"---Server half---",
|
|
9
|
+
"server",
|
|
10
|
+
"tools",
|
|
11
|
+
"runners",
|
|
12
|
+
"routes",
|
|
13
|
+
"tables",
|
|
14
|
+
"events",
|
|
15
|
+
"space",
|
|
16
|
+
"connections",
|
|
17
|
+
"starters",
|
|
18
|
+
"---Studio half---",
|
|
19
|
+
"studio",
|
|
20
|
+
"styling",
|
|
21
|
+
"---Running---",
|
|
22
|
+
"reloading",
|
|
23
|
+
"shipping",
|
|
24
|
+
"pro-modules",
|
|
25
|
+
"---Reference---",
|
|
26
|
+
"reference",
|
|
27
|
+
"examples"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Pro modules
|
|
3
|
+
description: engenty's closed plugins on a local install – signed packages from the linked account, on while its plan includes them.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Some of engenty's plugins are not part of the open product: they come with the Pro and Team
|
|
7
|
+
plans. On engenty.ai they are in the cloud runtime's image. A local install gets them from the
|
|
8
|
+
linked account, in Settings → Plugins → Pro modules.
|
|
9
|
+
|
|
10
|
+
## How a module gets there
|
|
11
|
+
|
|
12
|
+
1. Settings → Account links the install to an engenty account.
|
|
13
|
+
2. The runtime asks the account's Manage-App which modules are built for its release and which
|
|
14
|
+
of them the plan includes (`GET /v1/modules`,
|
|
15
|
+
[contract](https://github.com/engenty/engenty-wizards/blob/main/docs/manage-contract.md)).
|
|
16
|
+
The answer holds an entitlement the Manage-App signed: the team, the plan's modules, an end
|
|
17
|
+
about a week ahead.
|
|
18
|
+
3. "Install" downloads the module's zip. The runtime takes it only when its SHA-256 matches and
|
|
19
|
+
the signature over id, version, release and that hash checks out against the public key it
|
|
20
|
+
ships with (`apps/runtime/src/plugins/pro-keys.ts`). Nothing is unpacked before that.
|
|
21
|
+
4. The module lands in `<DATA_DIR>/pro-modules/<id>/`, apart from the person's own plugins, and
|
|
22
|
+
loads like any other plugin. Its tables are made in the space's database.
|
|
23
|
+
|
|
24
|
+
## When it is on
|
|
25
|
+
|
|
26
|
+
A Pro module loads at start and after every check only when all of these hold:
|
|
27
|
+
|
|
28
|
+
| | Otherwise |
|
|
29
|
+
|---|---|
|
|
30
|
+
| It was installed for this release | Held back; the next check fetches it again for the new release |
|
|
31
|
+
| The entitlement belongs to the account linked now | Held back |
|
|
32
|
+
| The entitlement has not ended | Held back until the install is online again |
|
|
33
|
+
| The entitlement lists it | Held back: not in the plan |
|
|
34
|
+
|
|
35
|
+
The runtime checks at start, once a day, when an account is linked and on "Check plan". Offline,
|
|
36
|
+
what was confirmed lasts until the entitlement ends. Unlinking the account turns every Pro
|
|
37
|
+
module off.
|
|
38
|
+
|
|
39
|
+
A module that goes off unloads; its files and its tables stay. It comes back with its data when
|
|
40
|
+
the plan includes it again. "Remove" deletes its files, not its tables.
|
|
41
|
+
|
|
42
|
+
## What this protects, and what not
|
|
43
|
+
|
|
44
|
+
- **Protected:** only a team whose plan includes a module can download it; a package that engenty
|
|
45
|
+
did not sign, or that was changed after signing, never loads – whatever the Manage-App or the
|
|
46
|
+
network in between hand over.
|
|
47
|
+
- **Not protected:** the code is on the person's machine. Someone who edits the runtime or its
|
|
48
|
+
data can keep a module on. The terms of use cover that; modules whose value is on the server
|
|
49
|
+
(models, the gateway) stay gated there anyway.
|
|
50
|
+
|
|
51
|
+
## Settings
|
|
52
|
+
|
|
53
|
+
| Variable | |
|
|
54
|
+
|---|---|
|
|
55
|
+
| `ACCOUNT_URL` | The Manage-App the account is linked to; the modules come from there |
|
|
56
|
+
| `PRO_MODULES_KEYS` | More public keys (Ed25519, SPKI DER in base64, comma-separated) a package may be signed with – for testing packages signed elsewhere |
|
|
57
|
+
|
|
58
|
+
A runtime of a Manage-App (`MANAGE_URL`) has no Pro modules: its plugins come with its image and
|
|
59
|
+
the Manage-App switches them on per tenant ([Shipping](./shipping)).
|