@engenty/wizards-runtime 0.17.0 → 0.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/runtime/dist/app.js +2 -0
- package/apps/runtime/dist/broker/account.js +20 -1
- package/apps/runtime/dist/broker/call.js +116 -20
- package/apps/runtime/dist/broker/host.js +8 -2
- package/apps/runtime/dist/broker/index.js +3 -2
- package/apps/runtime/dist/broker/log.js +149 -14
- package/apps/runtime/dist/broker/over.js +38 -0
- package/apps/runtime/dist/broker/rights.js +192 -0
- package/apps/runtime/dist/broker/rwx.js +295 -51
- package/apps/runtime/dist/broker/send.js +25 -12
- package/apps/runtime/dist/bundles/discover.js +133 -0
- package/apps/runtime/dist/bundles/fetch.js +119 -0
- package/apps/runtime/dist/bundles/index.js +621 -0
- package/apps/runtime/dist/bundles/read.js +607 -0
- package/apps/runtime/dist/connectors/external.js +540 -61
- package/apps/runtime/dist/connectors/person-sign-ins.js +1 -0
- package/apps/runtime/dist/connectors/reload.js +73 -0
- package/apps/runtime/dist/connectors/space-connections.js +73 -6
- package/apps/runtime/dist/db/migrations/tenant/0058_mcp_state_across_roles.sql +26 -0
- package/apps/runtime/dist/db/migrations/tenant/0059_space_connection_paused.sql +2 -0
- package/apps/runtime/dist/db/migrations/tenant/0060_space_bundle.sql +21 -0
- package/apps/runtime/dist/db/migrations/tenant/0061_space_connection_limits.sql +2 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0058_snapshot.json +6696 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0059_snapshot.json +6710 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0060_snapshot.json +6857 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0061_snapshot.json +6871 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +28 -0
- package/apps/runtime/dist/db/schema.js +81 -3
- package/apps/runtime/dist/docs/dev/broker.md +312 -32
- package/apps/runtime/dist/docs/dev/skills.md +8 -1
- package/apps/runtime/dist/docs/user-guide/capabilities.md +127 -5
- package/apps/runtime/dist/docs/user-guide/connectors.md +103 -5
- package/apps/runtime/dist/docs/user-guide/protocol.md +15 -4
- package/apps/runtime/dist/docs/user-guide/skills.md +11 -1
- package/apps/runtime/dist/docs/user-guide/test-and-share.md +1 -1
- package/apps/runtime/dist/elements/caller.js +2 -2
- package/apps/runtime/dist/engenty/connections-external/build-connector.js +23 -8
- package/apps/runtime/dist/engenty/connections-external/import-service.js +18 -9
- package/apps/runtime/dist/engenty/connections-external/importer/classify.js +12 -0
- package/apps/runtime/dist/engenty/connections-external/invoke/http-invoker.js +1 -0
- package/apps/runtime/dist/engenty/connections-external/net/guarded-fetch.js +6 -3
- package/apps/runtime/dist/engenty/connections-sdk/oauth2.js +2 -2
- package/apps/runtime/dist/engenty/shims/web-ingest.js +64 -0
- package/apps/runtime/dist/engine/resources.js +15 -6
- package/apps/runtime/dist/engine/runner.js +2 -1
- package/apps/runtime/dist/env.js +2 -0
- package/apps/runtime/dist/index.js +11 -2
- package/apps/runtime/dist/mcp/handler.js +2 -2
- package/apps/runtime/dist/mcp/seen.js +71 -51
- package/apps/runtime/dist/mcp/tools.js +5 -1
- package/apps/runtime/dist/prompts/mcp.md +1 -1
- package/apps/runtime/dist/prompts/tools.md +16 -0
- package/apps/runtime/dist/routes/broker.js +1 -1
- package/apps/runtime/dist/routes/bundles.js +91 -0
- package/apps/runtime/dist/routes/connections.js +14 -3
- package/apps/runtime/dist/routes/discover.js +1 -0
- package/apps/runtime/dist/routes/rules.js +53 -9
- package/apps/runtime/dist/routes/studio.js +23 -18
- package/apps/runtime/dist/services/cloud.js +2 -0
- package/apps/runtime/dist/services/discover.js +9 -3
- package/apps/runtime/dist/services/draft-events.js +79 -6
- package/apps/runtime/dist/services/files.js +2 -2
- package/apps/runtime/dist/services/skills.js +61 -5
- package/apps/runtime/dist/services/space-index.js +113 -11
- package/apps/runtime/dist/services/synced-spaces.js +5 -1
- package/apps/runtime/dist/services/wizards.js +48 -2
- package/apps/runtime/dist/sharing/jobs.js +6 -2
- package/apps/runtime/dist/sync/records.js +6 -1
- package/apps/runtime/dist/texts.js +36 -1
- package/apps/runtime/dist/tools/connections.js +8 -0
- package/apps/runtime/dist/tools/connector.js +13 -1
- package/apps/runtime/dist/tools/index.js +8 -3
- package/apps/runtime/dist/tools/skills.js +11 -1
- package/apps/web/dist/assets/{AboutDialog-B2Xmxyj4.js → AboutDialog-NzB-GEj_.js} +1 -1
- package/apps/web/dist/assets/{BlockEditor-D0HoUSih.js → BlockEditor-HyDf8fOb.js} +1 -1
- package/apps/web/dist/assets/Bundle-B0Bhs0By.js +1 -0
- package/apps/web/dist/assets/CapabilitiesPage-CQSaMsWK.js +2 -0
- package/apps/web/dist/assets/{ChangelogDialog-BIrJbAKi.js → ChangelogDialog-Ngxuqubx.js} +1 -1
- package/apps/web/dist/assets/{CodeEditor-DUVcXI5P.js → CodeEditor-C2LBf4pS.js} +1 -1
- package/apps/web/dist/assets/EditorPage-Dysvvadu.js +3 -0
- package/apps/web/dist/assets/{FlowPreview-BIag8_Be.js → FlowPreview-CGfSaeYu.js} +1 -1
- package/apps/web/dist/assets/LangSwitch-B7UQlGh5.js +1 -0
- package/apps/web/dist/assets/Marketplace-BkIxd1PW.js +2 -0
- package/apps/web/dist/assets/{NewWizardChannels-DI3SQ4iS.js → NewWizardChannels-BWLaVFld.js} +1 -1
- package/apps/web/dist/assets/NewWizardPage-BpRd8tDF.js +7 -0
- package/apps/web/dist/assets/OnboardingPage-ScEcQcR0.js +1 -0
- package/apps/web/dist/assets/PreviewPane-CaC1FYxZ.js +7 -0
- package/apps/web/dist/assets/ProtocolSection-CILRCYLD.js +1 -0
- package/apps/web/dist/assets/PublicRunner-DHX431Pr.js +1 -0
- package/apps/web/dist/assets/{ReadOnly-CWf5x74a.js → ReadOnly-DqS1UDQs.js} +1 -1
- package/apps/web/dist/assets/SettingsPage-Dp2-rHXu.js +2 -0
- package/apps/web/dist/assets/SetupPage-mzMLQcD5.js +1 -0
- package/apps/web/dist/assets/SharePage-CBDgqEH7.js +1 -0
- package/apps/web/dist/assets/SkillEditor-Cf6FqkkU.js +1 -0
- package/apps/web/dist/assets/{Skills-CN4QE7Kx.js → Skills-DqV5Oqqu.js} +5 -5
- package/apps/web/dist/assets/SpacePage-C3SXe2hs.js +2 -0
- package/apps/web/dist/assets/{UpdateCheck-QhBI3rlQ.js → UpdateCheck-B51jMIhp.js} +2 -2
- package/apps/web/dist/assets/brand-CG35IRgr.js +2 -0
- package/apps/web/dist/assets/changelog-DN6sziTl.js +1 -0
- package/apps/web/dist/assets/{code-editor-DkPo1C-L.js → code-editor-Bsyy7cuT.js} +2 -2
- package/apps/web/dist/assets/{host-D6H6Z9Jp.js → host-DaDyLfqT.js} +16 -16
- package/apps/web/dist/assets/i18n-CyrHWeGk.js +55 -0
- package/apps/web/dist/assets/index-Db9JthZr.css +1 -0
- package/apps/web/dist/assets/index-LjwVRoki.js +10 -0
- package/apps/web/dist/assets/minus-BpYkOkYw.js +1 -0
- package/apps/web/dist/assets/plug-De3mHDFV.js +1 -0
- package/apps/web/dist/assets/{read-aloud-CnFwDSGD.js → read-aloud-DCTouK7J.js} +1 -1
- package/apps/web/dist/assets/{runners-0sTPbWzr.js → runners-DtiBHvG7.js} +1 -1
- package/apps/web/dist/assets/session-DKGZUy6h.js +1 -0
- package/apps/web/dist/assets/{theme-CkNTe-_Z.js → theme-Bcj8TXQr.js} +2 -2
- package/apps/web/dist/assets/{ui-DAk_vjrL.js → ui-C6vSmisV.js} +1 -1
- package/apps/web/dist/assets/{useMutation-isHfB33W.js → useMutation-B8hJ5Z6N.js} +1 -1
- package/apps/web/dist/assets/{viewers-ijNZHJFG.js → viewers-b9FdC42r.js} +2 -2
- package/apps/web/dist/assets/{volume-2-BqlBtCIJ.js → volume-2-B1roRk6x.js} +1 -1
- package/apps/web/dist/index.html +15 -13
- package/apps/web/dist/mcp/flow.html +2 -2
- package/node_modules/@engenty/wizards-shared/dist/bundles.d.ts +219 -0
- package/node_modules/@engenty/wizards-shared/dist/bundles.js +19 -0
- package/node_modules/@engenty/wizards-shared/dist/connectors.d.ts +105 -4
- package/node_modules/@engenty/wizards-shared/dist/connectors.js +6 -0
- package/node_modules/@engenty/wizards-shared/dist/discover.d.ts +28 -1
- package/node_modules/@engenty/wizards-shared/dist/run.d.ts +8 -0
- package/node_modules/@engenty/wizards-shared/dist/run.js +16 -0
- package/node_modules/@engenty/wizards-shared/dist/rwx.d.ts +84 -1
- package/node_modules/@engenty/wizards-shared/dist/rwx.js +69 -1
- package/node_modules/@engenty/wizards-shared/dist/skills.d.ts +20 -3
- package/node_modules/@engenty/wizards-shared/dist/skills.js +5 -2
- package/package.json +1 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/plugin.json +1 -1
- package/apps/web/dist/assets/CapabilitiesPage-C1th2cZE.js +0 -2
- package/apps/web/dist/assets/EditorPage-56sIqEfF.js +0 -3
- package/apps/web/dist/assets/LangSwitch-CJ00IgaO.js +0 -1
- package/apps/web/dist/assets/Marketplace-D7-ot9Dz.js +0 -2
- package/apps/web/dist/assets/NewWizardPage-CytheHxX.js +0 -7
- package/apps/web/dist/assets/OnboardingPage-_91Pa8Ad.js +0 -1
- package/apps/web/dist/assets/PreviewPane-BDsYm-_K.js +0 -7
- package/apps/web/dist/assets/ProtocolSection-D_zaxHEL.js +0 -1
- package/apps/web/dist/assets/PublicRunner-CEgXSk3r.js +0 -1
- package/apps/web/dist/assets/SettingsPage-Dr8SDk-L.js +0 -2
- package/apps/web/dist/assets/SetupPage-B68n0l4I.js +0 -1
- package/apps/web/dist/assets/SharePage-DfznN7ar.js +0 -1
- package/apps/web/dist/assets/SkillEditor-BIcIczRc.js +0 -1
- package/apps/web/dist/assets/SpacePage-DiVTwhnJ.js +0 -2
- package/apps/web/dist/assets/changelog-a_CuplMX.js +0 -1
- package/apps/web/dist/assets/i18n-BaPKbQ1s.js +0 -55
- package/apps/web/dist/assets/index-CCUG6Vnh.css +0 -1
- package/apps/web/dist/assets/index-De0Wb42y.js +0 -10
- package/apps/web/dist/assets/session-BMiUrqHg.js +0 -2
|
@@ -1,24 +1,68 @@
|
|
|
1
|
-
import { RWX_FLAGS, RWX_LIMITS, RWX_RESOURCE_KINDS, RWX_SUBJECT_KINDS, } from "@engenty/wizards-shared/rwx";
|
|
1
|
+
import { RWX_ASK_KINDS, RWX_ASK_WHO, RWX_FLAGS, RWX_LIMITS, RWX_PERMS, RWX_RESOURCE_KINDS, RWX_SUBJECT_KINDS, } from "@engenty/wizards-shared/rwx";
|
|
2
2
|
import { Hono } from "hono";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
import {
|
|
4
|
+
import { describeRules, ruleChoices } from "../broker/rights.js";
|
|
5
|
+
import { addRule, askRule, changeRule, deleteRule, listRules, rulesSpace } from "../broker/rwx.js";
|
|
6
|
+
import { peopleOf } from "./broker.js";
|
|
5
7
|
const flag = z.enum(RWX_FLAGS).nullable();
|
|
6
8
|
const ruleSchema = z.object({
|
|
7
9
|
subjectKind: z.enum(RWX_SUBJECT_KINDS),
|
|
8
|
-
subjectId: z.string().min(1).max(RWX_LIMITS.id).nullable(),
|
|
10
|
+
subjectId: z.string().min(1).max(RWX_LIMITS.id).nullable().default(null),
|
|
9
11
|
resourceKind: z.enum(RWX_RESOURCE_KINDS),
|
|
10
12
|
resourceId: z.string().min(1).max(RWX_LIMITS.id),
|
|
11
13
|
r: flag.default(null),
|
|
12
14
|
w: flag.default(null),
|
|
13
15
|
x: flag.default(null),
|
|
14
16
|
});
|
|
17
|
+
/** The flags to set; one left out stays as it is. */
|
|
18
|
+
const flagsSchema = z
|
|
19
|
+
.object({ r: flag.optional(), w: flag.optional(), x: flag.optional() })
|
|
20
|
+
.refine((f) => RWX_PERMS.some((p) => f[p] !== undefined), "Name at least one of r, w and x.");
|
|
21
|
+
const askSchema = z.object({
|
|
22
|
+
who: z.enum(RWX_ASK_WHO),
|
|
23
|
+
/** A person's id (a person, Goose or an AI for them), a wizard's, a plugin's. */
|
|
24
|
+
id: z.string().min(1).max(RWX_LIMITS.id).optional(),
|
|
25
|
+
/** A wizard's run: the person it is held for; left out, a guest. */
|
|
26
|
+
for: z.string().min(1).max(RWX_LIMITS.id).optional(),
|
|
27
|
+
resource: z.enum(RWX_ASK_KINDS),
|
|
28
|
+
resourceId: z.string().min(1).max(RWX_LIMITS.id).optional(),
|
|
29
|
+
perm: z.enum(RWX_PERMS),
|
|
30
|
+
});
|
|
15
31
|
export const ruleRoutes = new Hono()
|
|
16
|
-
.get("/spaces/:id/rules", async (c) =>
|
|
17
|
-
.
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
32
|
+
.get("/spaces/:id/rules", async (c) => {
|
|
33
|
+
const user = c.get("user");
|
|
34
|
+
const space = await rulesSpace(user.id, c.req.param("id"));
|
|
35
|
+
const rules = await listRules(user.id, space.id);
|
|
36
|
+
return c.json({ rules: await describeRules(space.id, rules, await peopleOf(user)) });
|
|
37
|
+
})
|
|
38
|
+
// What a rule and the question pick from. Before `:ruleId`, which would take it for a rule.
|
|
39
|
+
.get("/spaces/:id/rules/choices", async (c) => {
|
|
40
|
+
const user = c.get("user");
|
|
41
|
+
const space = await rulesSpace(user.id, c.req.param("id"));
|
|
42
|
+
return c.json(await ruleChoices(space.id, await peopleOf(user)));
|
|
43
|
+
})
|
|
44
|
+
.get("/spaces/:id/rules/ask", async (c) => {
|
|
45
|
+
const user = c.get("user");
|
|
46
|
+
const space = await rulesSpace(user.id, c.req.param("id"));
|
|
47
|
+
const { decision, rule } = await askRule(user.id, space.id, askSchema.parse(c.req.query()));
|
|
48
|
+
const [described] = rule ? await describeRules(space.id, [rule], await peopleOf(user)) : [];
|
|
49
|
+
const answer = { ok: decision.ok, rule: described ?? null, reason: decision.reason };
|
|
50
|
+
return c.json(answer);
|
|
51
|
+
})
|
|
52
|
+
.post("/spaces/:id/rules", async (c) => {
|
|
53
|
+
const user = c.get("user");
|
|
54
|
+
const space = await rulesSpace(user.id, c.req.param("id"));
|
|
55
|
+
const rule = await addRule(user.id, space.id, ruleSchema.parse(await c.req.json()));
|
|
56
|
+
const [described] = await describeRules(space.id, [rule], await peopleOf(user));
|
|
57
|
+
return c.json({ rule: described });
|
|
58
|
+
})
|
|
59
|
+
.patch("/spaces/:id/rules/:ruleId", async (c) => {
|
|
60
|
+
const user = c.get("user");
|
|
61
|
+
const space = await rulesSpace(user.id, c.req.param("id"));
|
|
62
|
+
const flags = flagsSchema.parse(await c.req.json());
|
|
63
|
+
const rule = await changeRule(user.id, space.id, c.req.param("ruleId"), flags);
|
|
64
|
+
const [described] = await describeRules(space.id, [rule], await peopleOf(user));
|
|
65
|
+
return c.json({ rule: described });
|
|
22
66
|
})
|
|
23
67
|
.delete("/spaces/:id/rules/:ruleId", async (c) => {
|
|
24
68
|
await deleteRule(c.get("user").id, c.req.param("id"), c.req.param("ruleId"));
|
|
@@ -25,7 +25,8 @@ import { createLocalKey, deleteLocalKey, listLocalKeys } from "../auth/keys.js";
|
|
|
25
25
|
import { assertRwx, folderAudience, setFolderAudience, subjectsOfPerson } from "../broker/rwx.js";
|
|
26
26
|
import { appStates, connectApps } from "../cli/connect.js";
|
|
27
27
|
import { layout } from "../cli/home.js";
|
|
28
|
-
import { connectorImportSchema, importConnector, previewSource,
|
|
28
|
+
import { actionKindsPatchSchema, connectorImportSchema, connectorPreviewSchema, importConnector, previewSource, registryService, removeConnector, searchRegistry, setActionKinds, } from "../connectors/external.js";
|
|
29
|
+
import { reloadConnector } from "../connectors/reload.js";
|
|
29
30
|
import { balanceCredits, canSpend } from "../credits/credits.js";
|
|
30
31
|
import { estimateRun } from "../credits/estimate.js";
|
|
31
32
|
import { missingModels, stepsWithoutModel } from "../engine/requirements.js";
|
|
@@ -833,15 +834,10 @@ export const studio = new Hono()
|
|
|
833
834
|
return c.json(await searchRegistry(query));
|
|
834
835
|
})
|
|
835
836
|
.get("/connectors/registry/:domain", async (c) => c.json(await registryService(c.req.param("domain"))))
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
sourceKind: z.enum(["openapi", "mcp"]),
|
|
841
|
-
sourceUrl: z.string().url(),
|
|
842
|
-
})
|
|
843
|
-
.parse(await c.req.json());
|
|
844
|
-
return c.json(await previewSource(body));
|
|
837
|
+
// Reads an address before it is imported: for admins of a space that can be changed here.
|
|
838
|
+
.post("/spaces/:id/connectors/preview", async (c) => {
|
|
839
|
+
const space = await ownedSpace(c.get("user").id, c.req.param("id"));
|
|
840
|
+
return c.json(await previewSource(space.id, connectorPreviewSchema.parse(await c.req.json())));
|
|
845
841
|
})
|
|
846
842
|
.get("/spaces/:id/connectors", async (c) => c.json(await connectorsView(reader(c), c.req.param("id"))))
|
|
847
843
|
.post("/spaces/:id/connectors", async (c) => {
|
|
@@ -850,8 +846,16 @@ export const studio = new Hono()
|
|
|
850
846
|
return c.json(await importConnector(user.id, space.id, connectorImportSchema.parse(await c.req.json())));
|
|
851
847
|
})
|
|
852
848
|
.post("/spaces/:id/connectors/:connectorId/refresh", async (c) => {
|
|
853
|
-
const
|
|
854
|
-
|
|
849
|
+
const user = c.get("user");
|
|
850
|
+
const space = await ownedSpace(user.id, c.req.param("id"));
|
|
851
|
+
return c.json(await reloadConnector(user.id, space.id, c.req.param("connectorId")));
|
|
852
|
+
})
|
|
853
|
+
// What single actions of an imported connector do, as an admin says it.
|
|
854
|
+
.patch("/spaces/:id/connectors/:connectorId/actions", async (c) => {
|
|
855
|
+
const user = c.get("user");
|
|
856
|
+
const space = await ownedSpace(user.id, c.req.param("id"));
|
|
857
|
+
const { actions } = actionKindsPatchSchema.parse(await c.req.json());
|
|
858
|
+
return c.json(await setActionKinds(user.id, space.id, c.req.param("connectorId"), actions));
|
|
855
859
|
})
|
|
856
860
|
.delete("/spaces/:id/connectors/:connectorId", async (c) => {
|
|
857
861
|
const space = await ownedSpace(c.get("user").id, c.req.param("id"));
|
|
@@ -1258,8 +1262,8 @@ export const studio = new Hono()
|
|
|
1258
1262
|
const body = z
|
|
1259
1263
|
.object({ definition: z.unknown(), baseRevision: z.number().int().min(0) })
|
|
1260
1264
|
.parse(await c.req.json());
|
|
1261
|
-
const { revision, issues } = await writeDraft(c.get("user").id, c.req.param("id"), body);
|
|
1262
|
-
return c.json({ ok: true, revision, issues });
|
|
1265
|
+
const { revision, issues, warnings } = await writeDraft(c.get("user").id, c.req.param("id"), body);
|
|
1266
|
+
return c.json({ ok: true, revision, issues, warnings });
|
|
1263
1267
|
})
|
|
1264
1268
|
.patch("/wizards/:id", async (c) => {
|
|
1265
1269
|
const patch = z
|
|
@@ -1276,6 +1280,7 @@ export const studio = new Hono()
|
|
|
1276
1280
|
// The copy in the cloud of a linked account is shared the same way.
|
|
1277
1281
|
if (patch.shareEnabled !== undefined ||
|
|
1278
1282
|
patch.dailyRunLimit !== undefined ||
|
|
1283
|
+
patch.dailyMailLimit !== undefined ||
|
|
1279
1284
|
patch.runners !== undefined ||
|
|
1280
1285
|
patch.translate !== undefined) {
|
|
1281
1286
|
await pushSharing(c.get("user").id, c.req.param("id"));
|
|
@@ -1602,16 +1607,16 @@ export const studio = new Hono()
|
|
|
1602
1607
|
// Not done is an answer too: the app's file is no plain JSON, here is what to paste.
|
|
1603
1608
|
return c.json(done.outcome);
|
|
1604
1609
|
})
|
|
1605
|
-
// What each AI client did with the MCP server
|
|
1606
|
-
.get("/integrations/seen", (c) => c.json(seenApps(c.get("user").tenantId)))
|
|
1610
|
+
// What each AI client did with the MCP server: the test on "Integrate".
|
|
1611
|
+
.get("/integrations/seen", async (c) => c.json(await seenApps(c.get("user").tenantId)))
|
|
1607
1612
|
// The apps members used on the spaces, allowed or refused by the organization's model policy.
|
|
1608
1613
|
// Who used which app is for the organization's owners and admins.
|
|
1609
|
-
.get("/model-policy/apps", (c) => {
|
|
1614
|
+
.get("/model-policy/apps", async (c) => {
|
|
1610
1615
|
const user = c.get("user");
|
|
1611
1616
|
if (!mayChangeModels(user)) {
|
|
1612
1617
|
return c.json({ error: say(c, "onlyOrganizationAdminsChange"), code: "forbidden" }, 403);
|
|
1613
1618
|
}
|
|
1614
|
-
return c.json({ apps: checkedApps(user.tenantId) });
|
|
1619
|
+
return c.json({ apps: await checkedApps(user.tenantId) });
|
|
1615
1620
|
})
|
|
1616
1621
|
.get("/local/models", (c) => (managed ? c.notFound() : c.json(localModelSettings())))
|
|
1617
1622
|
.put("/local/models", async (c) => {
|
|
@@ -255,6 +255,7 @@ export async function syncToCloud(userId, wizardId) {
|
|
|
255
255
|
files,
|
|
256
256
|
shareEnabled: w.shareEnabled,
|
|
257
257
|
dailyRunLimit: w.dailyRunLimit,
|
|
258
|
+
dailyMailLimit: w.dailyMailLimit,
|
|
258
259
|
themes: themesOf(version.definition.themes, (await ownedSpace(userId, w.spaceId)).themes),
|
|
259
260
|
}, 120_000);
|
|
260
261
|
if (!answer.ok || !answer.body.shareUrl) {
|
|
@@ -323,6 +324,7 @@ export async function pushSharing(userId, wizardId) {
|
|
|
323
324
|
await call("PATCH", `/spaces/${w.spaceId}/wizards/${w.id}`, {
|
|
324
325
|
shareEnabled: w.shareEnabled,
|
|
325
326
|
dailyRunLimit: w.dailyRunLimit,
|
|
327
|
+
dailyMailLimit: w.dailyMailLimit,
|
|
326
328
|
translate: w.translate,
|
|
327
329
|
...(w.runners ? { runners: w.runners } : {}),
|
|
328
330
|
}).catch((err) => console.error("[cloud] sharing not sent:", err.message));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { featureOn } from "@engenty/wizards-shared/features";
|
|
2
2
|
import { eq } from "drizzle-orm";
|
|
3
|
+
import { discoverBundles } from "../bundles/discover.js";
|
|
3
4
|
import { searchRegistry } from "../connectors/external.js";
|
|
4
5
|
import { db, schema } from "../db/client.js";
|
|
5
6
|
import { currentFeatures } from "../features.js";
|
|
@@ -11,6 +12,8 @@ import { ownedSpace } from "./spaces.js";
|
|
|
11
12
|
* Fähigkeiten › Entdecken (docs/plans/capabilities.md, part B6): one search over skills.sh and
|
|
12
13
|
* integrations.sh. Both are asked at once, each with its own time to answer; one that fails or
|
|
13
14
|
* takes too long leaves its list empty and says so, and the other still shows what it found.
|
|
15
|
+
* A repository among the skills that is a plugin with a server over http is named as one hit
|
|
16
|
+
* (`bundles/discover.ts`); where GitHub does not answer in time, the lists stand as they are.
|
|
14
17
|
*/
|
|
15
18
|
/** How long one directory may take before the search goes on without it. */
|
|
16
19
|
const WAIT_MS = 10_000;
|
|
@@ -63,7 +66,7 @@ export async function discover(userId, spaceId, query) {
|
|
|
63
66
|
const space = await ownedSpace(userId, spaceId);
|
|
64
67
|
const q = query.trim().slice(0, 100);
|
|
65
68
|
if (q.length < 2) {
|
|
66
|
-
return { skills: [], connectors: [], errors: {} };
|
|
69
|
+
return { skills: [], connectors: [], bundles: [], errors: {} };
|
|
67
70
|
}
|
|
68
71
|
const [skills, connectors] = await Promise.allSettled([
|
|
69
72
|
// Skills stay out while their own switch is off.
|
|
@@ -77,9 +80,12 @@ export async function discover(userId, spaceId, query) {
|
|
|
77
80
|
if (connectors.status === "rejected") {
|
|
78
81
|
errors.connectors = "connectorsRegistryDown";
|
|
79
82
|
}
|
|
83
|
+
const foundSkills = skills.status === "fulfilled" ? skills.value : [];
|
|
84
|
+
const foundConnectors = connectors.status === "fulfilled" ? connectors.value : [];
|
|
80
85
|
return {
|
|
81
|
-
skills:
|
|
82
|
-
connectors:
|
|
86
|
+
skills: foundSkills,
|
|
87
|
+
connectors: foundConnectors,
|
|
88
|
+
bundles: await within(discoverBundles(space.id, foundSkills, foundConnectors)).catch(() => []),
|
|
83
89
|
errors,
|
|
84
90
|
};
|
|
85
91
|
}
|
|
@@ -1,12 +1,85 @@
|
|
|
1
|
+
import { AsyncResource } from "node:async_hooks";
|
|
1
2
|
import { EventEmitter } from "node:events";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { and, asc, eq, gt, lt, max } from "drizzle-orm";
|
|
4
|
+
import { db } from "../db/client.js";
|
|
5
|
+
import * as schema from "../db/schema.js";
|
|
6
|
+
/** How often a subscriber looks for what another process wrote. */
|
|
7
|
+
const LOOK_MS = 2000;
|
|
8
|
+
/** A subscriber reads a change within seconds; a reconnect catches up on the revision. */
|
|
9
|
+
const KEEP_MS = 3600_000;
|
|
10
|
+
/** Wakes this process's subscribers at once; those of another process find the row on their look. */
|
|
11
|
+
const wake = new EventEmitter();
|
|
12
|
+
wake.setMaxListeners(0);
|
|
13
|
+
/**
|
|
14
|
+
* In the tenant's database, so the studio hears what the process answering MCP wrote
|
|
15
|
+
* (RUNTIME_ROLE). A notice lost is a notice lost: the write it tells of stands.
|
|
16
|
+
*/
|
|
17
|
+
export async function emitDraftChanged(change) {
|
|
18
|
+
try {
|
|
19
|
+
await db.insert(schema.draftChange).values({ wizardId: change.wizardId, change });
|
|
20
|
+
wake.emit(change.wizardId);
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
console.error("[draft-events]", err.message);
|
|
24
|
+
}
|
|
6
25
|
}
|
|
26
|
+
/** Hears the changes to a wizard from now on, in the current tenant's context. */
|
|
7
27
|
export function subscribeDraft(wizardId, listener) {
|
|
8
|
-
|
|
9
|
-
|
|
28
|
+
const t = schema.draftChange;
|
|
29
|
+
let stopped = false;
|
|
30
|
+
let reading = false;
|
|
31
|
+
let again = false;
|
|
32
|
+
let seen = null;
|
|
33
|
+
// The tenant's context stays with the reader, whoever wakes it: ids are unique per tenant only.
|
|
34
|
+
const read = AsyncResource.bind(async () => {
|
|
35
|
+
if (reading) {
|
|
36
|
+
again = true;
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
reading = true;
|
|
40
|
+
try {
|
|
41
|
+
if (seen === null) {
|
|
42
|
+
const [newest] = await db.select({ id: max(t.id) }).from(t);
|
|
43
|
+
seen = newest?.id ?? 0;
|
|
44
|
+
}
|
|
45
|
+
do {
|
|
46
|
+
again = false;
|
|
47
|
+
const after = seen ?? 0;
|
|
48
|
+
const rows = await db
|
|
49
|
+
.select()
|
|
50
|
+
.from(t)
|
|
51
|
+
.where(and(eq(t.wizardId, wizardId), gt(t.id, after)))
|
|
52
|
+
.orderBy(asc(t.id));
|
|
53
|
+
for (const row of rows) {
|
|
54
|
+
seen = row.id;
|
|
55
|
+
if (!stopped) {
|
|
56
|
+
listener(row.change);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
} while (again && !stopped);
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
console.error("[draft-events]", err.message);
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
reading = false;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
const timer = setInterval(() => void read(), LOOK_MS);
|
|
69
|
+
timer.unref();
|
|
70
|
+
wake.on(wizardId, read);
|
|
71
|
+
void read();
|
|
72
|
+
return () => {
|
|
73
|
+
stopped = true;
|
|
74
|
+
clearInterval(timer);
|
|
75
|
+
wake.off(wizardId, read);
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** Deletes notices nobody needs any more, in the current tenant's context. */
|
|
79
|
+
export async function pruneDraftChanges(now = Date.now()) {
|
|
80
|
+
await db
|
|
81
|
+
.delete(schema.draftChange)
|
|
82
|
+
.where(lt(schema.draftChange.createdAt, new Date(now - KEEP_MS)));
|
|
10
83
|
}
|
|
11
84
|
/** Steps that are new or differ in `after`. */
|
|
12
85
|
export function changedSteps(before, after) {
|
|
@@ -73,7 +73,7 @@ export async function writeFile(userId, wizardId, rawPath, content, mime) {
|
|
|
73
73
|
set: { hash: file.hash, mime: file.mime, size: file.size, updatedAt: new Date() },
|
|
74
74
|
});
|
|
75
75
|
await touch(w.id);
|
|
76
|
-
emitDraftChanged(filesChanged(w, path));
|
|
76
|
+
await emitDraftChanged(filesChanged(w, path));
|
|
77
77
|
return file;
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
@@ -136,7 +136,7 @@ export async function deleteFile(userId, wizardId, rawPath) {
|
|
|
136
136
|
throw notFound();
|
|
137
137
|
}
|
|
138
138
|
await touch(w.id);
|
|
139
|
-
emitDraftChanged(filesChanged(w, path));
|
|
139
|
+
await emitDraftChanged(filesChanged(w, path));
|
|
140
140
|
}
|
|
141
141
|
/** Copies a workspace onto another wizard (duplicate). Blobs are shared, only rows are new. */
|
|
142
142
|
export async function copyFiles(fromWizardId, toWizardId) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { featureOn } from "@engenty/wizards-shared/features";
|
|
3
3
|
import { byteLength, officialSkill, parseSkillMd, SKILL_LIMITS, SKILL_NAME, SkillMdError, skillMd, skillPathOk, skillTextPath, } from "@engenty/wizards-shared/skills";
|
|
4
|
-
import { and, asc, count, eq, ne } from "drizzle-orm";
|
|
4
|
+
import { and, asc, count, eq, isNotNull, ne } from "drizzle-orm";
|
|
5
5
|
import { unzipSync, zipSync } from "fflate";
|
|
6
6
|
import { nanoid } from "nanoid";
|
|
7
7
|
import { db, schema } from "../db/client.js";
|
|
@@ -128,7 +128,49 @@ export async function checkAlways(spaceId, id, mode, body) {
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
// --- views ----------------------------------------------------------------------------------
|
|
131
|
-
|
|
131
|
+
/**
|
|
132
|
+
* What the space's skills came with, by the record's id: the plugin's name and the connectors
|
|
133
|
+
* that came with it.
|
|
134
|
+
*/
|
|
135
|
+
export async function skillBundles(spaceId) {
|
|
136
|
+
const bundles = await db
|
|
137
|
+
.select({ id: schema.spaceBundle.id, name: schema.spaceBundle.name })
|
|
138
|
+
.from(schema.spaceBundle)
|
|
139
|
+
.where(eq(schema.spaceBundle.spaceId, spaceId));
|
|
140
|
+
if (!bundles.length) {
|
|
141
|
+
return new Map();
|
|
142
|
+
}
|
|
143
|
+
const connectors = await db.query.spaceConnector.findMany({
|
|
144
|
+
where: and(eq(schema.spaceConnector.spaceId, spaceId), isNotNull(schema.spaceConnector.bundleId)),
|
|
145
|
+
orderBy: [asc(schema.spaceConnector.createdAt)],
|
|
146
|
+
});
|
|
147
|
+
return new Map(bundles.map((b) => [
|
|
148
|
+
b.id,
|
|
149
|
+
{
|
|
150
|
+
id: b.id,
|
|
151
|
+
name: b.name,
|
|
152
|
+
connectors: connectors
|
|
153
|
+
.filter((c) => c.bundleId === b.id)
|
|
154
|
+
.map((c) => ({ id: c.id, name: c.record.name }))
|
|
155
|
+
.sort((x, y) => x.name.localeCompare(y.name)),
|
|
156
|
+
},
|
|
157
|
+
]));
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* The connectors a skill came with, as a step names them: by name and by what their tools'
|
|
161
|
+
* names start with.
|
|
162
|
+
*/
|
|
163
|
+
export async function skillConnectors(row) {
|
|
164
|
+
if (!row.bundleId) {
|
|
165
|
+
return [];
|
|
166
|
+
}
|
|
167
|
+
const connectors = await db.query.spaceConnector.findMany({
|
|
168
|
+
where: and(eq(schema.spaceConnector.spaceId, row.spaceId), eq(schema.spaceConnector.bundleId, row.bundleId)),
|
|
169
|
+
orderBy: [asc(schema.spaceConnector.createdAt)],
|
|
170
|
+
});
|
|
171
|
+
return connectors.map((c) => ({ name: c.record.name, toolPrefix: c.record.tool_prefix }));
|
|
172
|
+
}
|
|
173
|
+
function summaryOf(row, bundles) {
|
|
132
174
|
return {
|
|
133
175
|
id: row.id,
|
|
134
176
|
name: row.name,
|
|
@@ -137,6 +179,7 @@ function summaryOf(row) {
|
|
|
137
179
|
source: row.source,
|
|
138
180
|
origin: row.origin,
|
|
139
181
|
official: row.source === "skills.sh" && officialSkill(row.origin),
|
|
182
|
+
bundle: (row.bundleId ? bundles.get(row.bundleId) : null) ?? null,
|
|
140
183
|
runScripts: row.runScripts,
|
|
141
184
|
files: row.files.length + row.blobFiles.length,
|
|
142
185
|
chars: row.body.length,
|
|
@@ -159,14 +202,18 @@ export async function listSkills(userId, spaceId) {
|
|
|
159
202
|
where: eq(schema.spaceSkill.spaceId, space.id),
|
|
160
203
|
orderBy: [asc(schema.spaceSkill.name)],
|
|
161
204
|
});
|
|
162
|
-
|
|
205
|
+
const bundles = rows.some((r) => r.bundleId) ? await skillBundles(space.id) : new Map();
|
|
206
|
+
return {
|
|
207
|
+
skills: rows.map((r) => summaryOf(r, bundles)),
|
|
208
|
+
readOnly: !(await spaceWritable(space)),
|
|
209
|
+
};
|
|
163
210
|
}
|
|
164
211
|
export async function getSkill(userId, id) {
|
|
165
212
|
await requireSkills();
|
|
166
213
|
const row = await skillRow(id);
|
|
167
214
|
const space = await ownedSpace(userId, row.spaceId);
|
|
168
215
|
return {
|
|
169
|
-
...summaryOf(row),
|
|
216
|
+
...summaryOf(row, row.bundleId ? await skillBundles(row.spaceId) : new Map()),
|
|
170
217
|
spaceId: row.spaceId,
|
|
171
218
|
body: row.body,
|
|
172
219
|
meta: row.meta,
|
|
@@ -226,6 +273,7 @@ export async function insertSkill(spaceId, content, options) {
|
|
|
226
273
|
source: options.source,
|
|
227
274
|
origin: options.origin ?? null,
|
|
228
275
|
originHash: options.originHash ?? null,
|
|
276
|
+
bundleId: options.bundleId ?? null,
|
|
229
277
|
});
|
|
230
278
|
return { id, name };
|
|
231
279
|
}
|
|
@@ -245,7 +293,8 @@ export async function createSkill(userId, spaceId, input) {
|
|
|
245
293
|
}
|
|
246
294
|
/**
|
|
247
295
|
* Changes a skill: when it counts and whether its scripts run, always; its content only when it
|
|
248
|
-
* is the space's own, since one from skills.sh stays as it came (an
|
|
296
|
+
* is the space's own, since one from skills.sh or one a plugin brought stays as it came (an
|
|
297
|
+
* update replaces it whole).
|
|
249
298
|
*/
|
|
250
299
|
export async function updateSkill(userId, id, patch) {
|
|
251
300
|
await requireSkills();
|
|
@@ -260,6 +309,9 @@ export async function updateSkill(userId, id, patch) {
|
|
|
260
309
|
if (touches && row.source === "skills.sh") {
|
|
261
310
|
throw refuse("skillReadOnly");
|
|
262
311
|
}
|
|
312
|
+
if (touches && row.bundleId) {
|
|
313
|
+
throw refuse("skillOfBundleReadOnly");
|
|
314
|
+
}
|
|
263
315
|
const next = checkContent({
|
|
264
316
|
name: content.name ?? row.name,
|
|
265
317
|
description: content.description ?? row.description,
|
|
@@ -284,6 +336,10 @@ export async function deleteSkill(userId, id) {
|
|
|
284
336
|
const row = await skillRow(id);
|
|
285
337
|
await ownedSpace(userId, row.spaceId);
|
|
286
338
|
await requireWritableSpace(row.spaceId);
|
|
339
|
+
// What a plugin brought goes with it, all at once (`bundles/`): until then it is switched off.
|
|
340
|
+
if (row.bundleId) {
|
|
341
|
+
throw refuse("skillOfBundleStays");
|
|
342
|
+
}
|
|
287
343
|
await db.delete(schema.spaceSkill).where(eq(schema.spaceSkill.id, row.id));
|
|
288
344
|
}
|
|
289
345
|
/**
|