@engenty/wizards-runtime 0.17.0 → 0.17.1
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/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 +532 -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 +251 -31
- package/apps/runtime/dist/docs/user-guide/capabilities.md +123 -5
- package/apps/runtime/dist/docs/user-guide/connectors.md +52 -5
- package/apps/runtime/dist/docs/user-guide/protocol.md +15 -4
- 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/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/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 +102 -10
- 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-mZCBU7KF.js} +1 -1
- package/apps/web/dist/assets/{BlockEditor-D0HoUSih.js → BlockEditor-Dk0QwLSU.js} +1 -1
- package/apps/web/dist/assets/CapabilitiesPage-GkpgF-wZ.js +2 -0
- package/apps/web/dist/assets/{ChangelogDialog-BIrJbAKi.js → ChangelogDialog-BhyilZWA.js} +1 -1
- package/apps/web/dist/assets/{CodeEditor-DUVcXI5P.js → CodeEditor-DULYZbuE.js} +1 -1
- package/apps/web/dist/assets/EditorPage-D_mCdYdZ.js +3 -0
- package/apps/web/dist/assets/{FlowPreview-BIag8_Be.js → FlowPreview-ykxZxWnk.js} +1 -1
- package/apps/web/dist/assets/{LangSwitch-CJ00IgaO.js → LangSwitch-iO54w9AP.js} +1 -1
- package/apps/web/dist/assets/{Marketplace-D7-ot9Dz.js → Marketplace-C97fH7UC.js} +2 -2
- package/apps/web/dist/assets/{NewWizardChannels-DI3SQ4iS.js → NewWizardChannels-CsSV7sm2.js} +1 -1
- package/apps/web/dist/assets/{NewWizardPage-CytheHxX.js → NewWizardPage-Ebgw-Vf_.js} +1 -1
- package/apps/web/dist/assets/{OnboardingPage-_91Pa8Ad.js → OnboardingPage-BZlloT7v.js} +1 -1
- package/apps/web/dist/assets/PreviewPane-CJuqY5uA.js +7 -0
- package/apps/web/dist/assets/ProtocolSection-CPaDKVpZ.js +1 -0
- package/apps/web/dist/assets/{PublicRunner-CEgXSk3r.js → PublicRunner-4Lf4SnwB.js} +1 -1
- package/apps/web/dist/assets/{ReadOnly-CWf5x74a.js → ReadOnly-CXQ41R9Q.js} +1 -1
- package/apps/web/dist/assets/{SettingsPage-Dr8SDk-L.js → SettingsPage-C-8BgK9O.js} +2 -2
- package/apps/web/dist/assets/{SetupPage-B68n0l4I.js → SetupPage-4_K083Wl.js} +1 -1
- package/apps/web/dist/assets/{SharePage-DfznN7ar.js → SharePage-CQjgMcDI.js} +1 -1
- package/apps/web/dist/assets/{SkillEditor-BIcIczRc.js → SkillEditor-DT5hQwbg.js} +1 -1
- package/apps/web/dist/assets/{Skills-CN4QE7Kx.js → Skills-D7V_9_xo.js} +1 -1
- package/apps/web/dist/assets/SpacePage-D3rYS1bA.js +2 -0
- package/apps/web/dist/assets/{UpdateCheck-QhBI3rlQ.js → UpdateCheck-DVgAJmy8.js} +2 -2
- package/apps/web/dist/assets/changelog-DzQCUSsx.js +1 -0
- package/apps/web/dist/assets/{code-editor-DkPo1C-L.js → code-editor-5T7ilBjd.js} +2 -2
- package/apps/web/dist/assets/{host-D6H6Z9Jp.js → host-CCijW1hj.js} +6 -6
- package/apps/web/dist/assets/i18n-DCPDesT-.js +55 -0
- package/apps/web/dist/assets/{index-De0Wb42y.js → index-C_iWl8iS.js} +3 -3
- package/apps/web/dist/assets/index-zcPlodHx.css +1 -0
- package/apps/web/dist/assets/minus-BpYkOkYw.js +1 -0
- package/apps/web/dist/assets/{read-aloud-CnFwDSGD.js → read-aloud-Qb719not.js} +1 -1
- package/apps/web/dist/assets/{runners-0sTPbWzr.js → runners-BeZ84YH_.js} +1 -1
- package/apps/web/dist/assets/{session-BMiUrqHg.js → session-CEJRkSP5.js} +1 -1
- package/apps/web/dist/assets/{theme-CkNTe-_Z.js → theme-y_owNosi.js} +1 -1
- package/apps/web/dist/assets/{ui-DAk_vjrL.js → ui-BacfkQ7Q.js} +1 -1
- package/apps/web/dist/assets/{useMutation-isHfB33W.js → useMutation-CgzFr4qH.js} +1 -1
- package/apps/web/dist/assets/{viewers-ijNZHJFG.js → viewers-CkyHAjnk.js} +2 -2
- package/apps/web/dist/index.html +12 -12
- 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/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/PreviewPane-BDsYm-_K.js +0 -7
- package/apps/web/dist/assets/ProtocolSection-D_zaxHEL.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
|
@@ -33,6 +33,8 @@ export class RunResources {
|
|
|
33
33
|
/** The engine this run's sandbox is made on; null until bound, or when the run has none. */
|
|
34
34
|
engine = null;
|
|
35
35
|
scope = null;
|
|
36
|
+
/** Bound for a share job: the one caller of a run that is done (broker/over.ts). */
|
|
37
|
+
share = false;
|
|
36
38
|
/** Changes the person allowed for the rest of this run, as "<connection>:<action>". */
|
|
37
39
|
allowed = new Set();
|
|
38
40
|
watchers = new Set();
|
|
@@ -46,8 +48,9 @@ export class RunResources {
|
|
|
46
48
|
this.runId = runId;
|
|
47
49
|
}
|
|
48
50
|
/** Whose store kept sign-ins are read from and written to, and whose run this is. */
|
|
49
|
-
bind(scope, run) {
|
|
51
|
+
bind(scope, run, share = false) {
|
|
50
52
|
this.scope = scope;
|
|
53
|
+
this.share = share;
|
|
51
54
|
this.engine = runSandboxEngine(run);
|
|
52
55
|
}
|
|
53
56
|
/** What this run's sandbox runs, or null when the run has none (a guest's, or `SANDBOX=off`). */
|
|
@@ -57,17 +60,23 @@ export class RunResources {
|
|
|
57
60
|
async browserContext() {
|
|
58
61
|
if (!this.context) {
|
|
59
62
|
const make = (kept) => webContext({ locale: "de-DE", ...(kept ? { storageState: kept } : {}) });
|
|
60
|
-
// The kept sign-ins are read through the broker: only the browser context sees them.
|
|
63
|
+
// The kept sign-ins are read through the broker: only the browser context sees them. A run
|
|
64
|
+
// that is over gets none: its browser opens signed in nowhere.
|
|
61
65
|
const scope = this.scope;
|
|
62
|
-
|
|
66
|
+
const kept = scope
|
|
63
67
|
? await brokerSecret({
|
|
64
68
|
who: whoOf(scope.holder),
|
|
65
|
-
where: {
|
|
69
|
+
where: {
|
|
70
|
+
runId: this.runId,
|
|
71
|
+
wizardId: scope.wizardId,
|
|
72
|
+
...(this.share ? { share: true } : {}),
|
|
73
|
+
},
|
|
66
74
|
scope,
|
|
67
75
|
slot: SESSION_SLOT,
|
|
68
76
|
handler: make,
|
|
69
|
-
}).catch(() =>
|
|
70
|
-
:
|
|
77
|
+
}).catch(() => null)
|
|
78
|
+
: null;
|
|
79
|
+
this.context = kept?.ok ? kept.result : await make(null);
|
|
71
80
|
}
|
|
72
81
|
return this.context;
|
|
73
82
|
}
|
|
@@ -572,7 +572,7 @@ async function storedLists(run, holder) {
|
|
|
572
572
|
export async function makeContext(run, space, state, signal, own = {}) {
|
|
573
573
|
const store = scopeOf(run);
|
|
574
574
|
const resources = resourcesFor(run.id);
|
|
575
|
-
resources.bind(store, run);
|
|
575
|
+
resources.bind(store, run, own.share);
|
|
576
576
|
const stepId = own.stepId ?? run.cursor ?? "";
|
|
577
577
|
const holder = await runHolder(run);
|
|
578
578
|
return {
|
|
@@ -601,6 +601,7 @@ export async function makeContext(run, space, state, signal, own = {}) {
|
|
|
601
601
|
((ask) => run.unattended ? Promise.resolve(null) : askPerson(run.id, { ...ask, stepId }, signal)),
|
|
602
602
|
emit: own.emit ?? ((type, message, asset) => emitEvent(run.id, run.cursor, type, message, asset)),
|
|
603
603
|
call: { runId: run.id, stepId },
|
|
604
|
+
...(own.share ? { share: true } : {}),
|
|
604
605
|
chargeUsd: (usd) => addLocalCost(run.id, stepId, usd),
|
|
605
606
|
saveAsset: (input) => saveAsset({
|
|
606
607
|
...input,
|
package/apps/runtime/dist/env.js
CHANGED
|
@@ -91,6 +91,8 @@ export const env = {
|
|
|
91
91
|
doors: ["doors", "web", "runner", "all"].includes(role()),
|
|
92
92
|
runner: ["runner", "all"].includes(role()),
|
|
93
93
|
api: ["api", "studio", "web", "runner", "all"].includes(role()),
|
|
94
|
+
/** The index's sweeps, in one process of a runtime: a runner serves the studio's routes too. */
|
|
95
|
+
vectors: ["studio", "web", "all"].includes(role()),
|
|
94
96
|
},
|
|
95
97
|
runner: {
|
|
96
98
|
/** This runner's name in the control database; a new one each start. */
|
|
@@ -10,12 +10,14 @@ import { basePath, env } from "./env.js";
|
|
|
10
10
|
import { pruneLive } from "./live/feed.js";
|
|
11
11
|
import { hookConsole } from "./log.js";
|
|
12
12
|
import { managed } from "./manage.js";
|
|
13
|
+
import { pruneSeen } from "./mcp/seen.js";
|
|
13
14
|
import { checkModelsAtStart, loadCatalog, loadLocalModels } from "./models.js";
|
|
14
15
|
import { startJobs } from "./plugins/jobs.js";
|
|
15
16
|
import { loadPlugins } from "./plugins/loader.js";
|
|
16
17
|
import { loadEntitlement, startProChecks } from "./plugins/pro.js";
|
|
17
18
|
import { closeBrowser } from "./render/chromium.js";
|
|
18
19
|
import { clearRunning, writeRunning } from "./running.js";
|
|
20
|
+
import { pruneDraftChanges } from "./services/draft-events.js";
|
|
19
21
|
import { reportAllWizards } from "./services/manage-reports.js";
|
|
20
22
|
import { syncMarketplace } from "./services/marketplace.js";
|
|
21
23
|
import { purgeExpiredRuns } from "./services/shares.js";
|
|
@@ -105,7 +107,14 @@ if (env.serves.runner) {
|
|
|
105
107
|
async function purge() {
|
|
106
108
|
await purgeSessions();
|
|
107
109
|
for (const id of await knownTenants()) {
|
|
108
|
-
await withTenant(id, () => Promise.all([
|
|
110
|
+
await withTenant(id, () => Promise.all([
|
|
111
|
+
purgeExpiredRuns(),
|
|
112
|
+
purgeUnusedStores(),
|
|
113
|
+
compactLog(),
|
|
114
|
+
pruneLive(),
|
|
115
|
+
pruneSeen(),
|
|
116
|
+
pruneDraftChanges(),
|
|
117
|
+
])).catch((err) => console.error(`[retention ${id}]`, err));
|
|
109
118
|
}
|
|
110
119
|
}
|
|
111
120
|
void purge().catch((err) => console.error("[retention]", err));
|
|
@@ -116,7 +125,7 @@ if (!managed && env.serves.studio) {
|
|
|
116
125
|
void moveFilesAtStart().catch((err) => console.error("[move-files]", err));
|
|
117
126
|
}
|
|
118
127
|
// Assets came into the index later than documents: what is not there yet goes in once.
|
|
119
|
-
if (env.serves.
|
|
128
|
+
if (env.serves.vectors) {
|
|
120
129
|
const { indexMissingAssets } = await import("./services/space-index.js");
|
|
121
130
|
for (const id of await knownTenants()) {
|
|
122
131
|
void withTenant(id, () => indexMissingAssets()).catch((err) => console.error(`[space-index ${id}]`, err));
|
|
@@ -37,7 +37,7 @@ async function appRefusal(who, client, body) {
|
|
|
37
37
|
? policy.apps.local
|
|
38
38
|
: policy.apps.subscriptions
|
|
39
39
|
: false;
|
|
40
|
-
noteChecked(who.tenantId, client, who.name ?? who.email ?? null, allowed, kind);
|
|
40
|
+
await noteChecked(who.tenantId, client, who.name ?? who.email ?? null, allowed, kind);
|
|
41
41
|
if (allowed) {
|
|
42
42
|
return null;
|
|
43
43
|
}
|
|
@@ -99,7 +99,7 @@ export function mcpHandler() {
|
|
|
99
99
|
.clone()
|
|
100
100
|
.json()
|
|
101
101
|
.catch(() => null);
|
|
102
|
-
noteRequest(who.tenantId, authInfo.clientId, who.client, body);
|
|
102
|
+
await noteRequest(who.tenantId, authInfo.clientId, who.client, body);
|
|
103
103
|
const refused = await appRefusal(who, clientNameOf(authInfo.clientId, who.client), body);
|
|
104
104
|
if (refused) {
|
|
105
105
|
return refused;
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import { desc, lt, sql } from "drizzle-orm";
|
|
2
|
+
import { db, withTenant } from "../db/client.js";
|
|
3
|
+
import * as schema from "../db/schema.js";
|
|
1
4
|
/**
|
|
2
|
-
* What each AI client did with the MCP server
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
+
* What each AI client did with the MCP server: the test on the "Integrate" page waits for a client
|
|
6
|
+
* to show up, call a tool and show the widget. In the tenant's database, as the process that
|
|
7
|
+
* answers MCP need not be the one that serves the studio (RUNTIME_ROLE). A note that can't be
|
|
8
|
+
* written is logged: the client's call goes on.
|
|
5
9
|
*/
|
|
10
|
+
/** How long an app stays known without a request. */
|
|
11
|
+
const KEEP_MS = 30 * 24 * 3600_000;
|
|
6
12
|
/** The ids the studio lists the AI apps by, and the names they give themselves (`clientInfo`). */
|
|
7
13
|
const CLIENT_NAMES = [
|
|
8
14
|
// Claude Desktop calls itself claude-ai, as claude.ai does.
|
|
@@ -24,44 +30,45 @@ const CLIENT_NAMES = [
|
|
|
24
30
|
export function appIdsOf(client) {
|
|
25
31
|
return CLIENT_NAMES.filter(([, name]) => name.test(client)).map(([id]) => id);
|
|
26
32
|
}
|
|
27
|
-
const seen = new Map();
|
|
28
33
|
/** The name a client gave on `initialize`, by its sign-in: later requests do not repeat it. */
|
|
29
34
|
const names = new Map();
|
|
30
35
|
/** Notes one MCP request: its JSON-RPC messages, from the client signed in as `signIn`. */
|
|
31
|
-
export function noteRequest(tenantId, signIn, client, body) {
|
|
36
|
+
export async function noteRequest(tenantId, signIn, client, body) {
|
|
32
37
|
const messages = (Array.isArray(body) ? body : [body]).filter((m) => Boolean(m) && typeof m === "object");
|
|
33
38
|
const info = messages.find((m) => m.method === "initialize")?.params?.clientInfo;
|
|
34
39
|
const given = info?.title || info?.name;
|
|
35
40
|
if (given) {
|
|
36
41
|
names.set(signIn, given);
|
|
37
42
|
}
|
|
38
|
-
const
|
|
43
|
+
const apps = appIdsOf(names.get(signIn) ?? client);
|
|
44
|
+
if (!apps.length) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
39
47
|
const now = Date.now();
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
const toolAt = messages.some((m) => m.method === "tools/call") ? now : null;
|
|
49
|
+
const widgetAt = messages.some((m) => m.method === "resources/read" && String(m.params?.uri ?? "").startsWith("ui://"))
|
|
50
|
+
? now
|
|
51
|
+
: null;
|
|
52
|
+
await withTenant(tenantId, async () => {
|
|
53
|
+
for (const app of apps) {
|
|
54
|
+
await db
|
|
55
|
+
.insert(schema.mcpAppSeen)
|
|
56
|
+
.values({ app, at: now, toolAt, widgetAt })
|
|
57
|
+
.onConflictDoUpdate({
|
|
58
|
+
target: schema.mcpAppSeen.app,
|
|
59
|
+
set: {
|
|
60
|
+
at: now,
|
|
61
|
+
toolAt: sql `coalesce(excluded.tool_at, ${schema.mcpAppSeen.toolAt})`,
|
|
62
|
+
widgetAt: sql `coalesce(excluded.widget_at, ${schema.mcpAppSeen.widgetAt})`,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
51
65
|
}
|
|
52
|
-
|
|
53
|
-
}
|
|
66
|
+
}).catch((err) => console.error("[mcp] noting a client:", err.message));
|
|
54
67
|
}
|
|
55
68
|
/** What the tenant's clients did, by app id. */
|
|
56
|
-
export function seenApps(tenantId) {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
const [tenant, id] = key.split("\n");
|
|
60
|
-
if (tenant === tenantId) {
|
|
61
|
-
out[id] = value;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return out;
|
|
69
|
+
export async function seenApps(tenantId) {
|
|
70
|
+
const rows = await withTenant(tenantId, () => db.select().from(schema.mcpAppSeen));
|
|
71
|
+
return Object.fromEntries(rows.map((r) => [r.app, { at: r.at, toolAt: r.toolAt, widgetAt: r.widgetAt }]));
|
|
65
72
|
}
|
|
66
73
|
/** The name a sign-in's client gave on `initialize`, else the one its sign-in carries. */
|
|
67
74
|
export function clientNameOf(signIn, client) {
|
|
@@ -82,31 +89,44 @@ export function appKind(...names) {
|
|
|
82
89
|
const ids = names.flatMap(appIdsOf);
|
|
83
90
|
return ids.length && ids.every((id) => LOCAL_APPS.has(id)) ? "local" : "subscription";
|
|
84
91
|
}
|
|
85
|
-
const checked = new Map();
|
|
86
92
|
/** Counts one tool call of an app the policy allowed or refused. */
|
|
87
|
-
export function noteChecked(tenantId, app, person, allowed, kind) {
|
|
88
|
-
const
|
|
89
|
-
const
|
|
93
|
+
export async function noteChecked(tenantId, app, person, allowed, kind) {
|
|
94
|
+
const now = Date.now();
|
|
95
|
+
const t = schema.mcpAppCheck;
|
|
96
|
+
await withTenant(tenantId, () => db
|
|
97
|
+
.insert(t)
|
|
98
|
+
.values({
|
|
90
99
|
app,
|
|
100
|
+
person: person ?? "",
|
|
91
101
|
kind,
|
|
92
|
-
|
|
93
|
-
allowed:
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
allowed: allowed ? 1 : 0,
|
|
103
|
+
refused: allowed ? 0 : 1,
|
|
104
|
+
at: now,
|
|
105
|
+
})
|
|
106
|
+
.onConflictDoUpdate({
|
|
107
|
+
target: [t.app, t.person],
|
|
108
|
+
set: {
|
|
109
|
+
kind,
|
|
110
|
+
at: now,
|
|
111
|
+
allowed: sql `${t.allowed} + excluded.allowed`,
|
|
112
|
+
refused: sql `${t.refused} + excluded.refused`,
|
|
113
|
+
},
|
|
114
|
+
})).catch((err) => console.error("[mcp] noting an app's check:", err.message));
|
|
115
|
+
}
|
|
116
|
+
/** The apps the tenant's members used on its spaces, latest first. */
|
|
117
|
+
export async function checkedApps(tenantId) {
|
|
118
|
+
const rows = await withTenant(tenantId, () => db.select().from(schema.mcpAppCheck).orderBy(desc(schema.mcpAppCheck.at)));
|
|
119
|
+
return rows.map((r) => ({
|
|
120
|
+
app: r.app,
|
|
121
|
+
kind: r.kind,
|
|
122
|
+
person: r.person || null,
|
|
123
|
+
allowed: r.allowed,
|
|
124
|
+
refused: r.refused,
|
|
125
|
+
at: r.at,
|
|
126
|
+
}));
|
|
105
127
|
}
|
|
106
|
-
/**
|
|
107
|
-
export function
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
.map(([, value]) => value)
|
|
111
|
-
.sort((a, b) => b.at - a.at);
|
|
128
|
+
/** Forgets what is older than `KEEP_MS`, in the current tenant's context: names of people among it. */
|
|
129
|
+
export async function pruneSeen(now = Date.now()) {
|
|
130
|
+
await db.delete(schema.mcpAppSeen).where(lt(schema.mcpAppSeen.at, now - KEEP_MS));
|
|
131
|
+
await db.delete(schema.mcpAppCheck).where(lt(schema.mcpAppCheck.at, now - KEEP_MS));
|
|
112
132
|
}
|
|
@@ -312,6 +312,7 @@ export function registerTools(server, who) {
|
|
|
312
312
|
dirty: s.dirty,
|
|
313
313
|
shareEnabled: s.shareEnabled,
|
|
314
314
|
dailyRunLimit: s.dailyRunLimit,
|
|
315
|
+
dailyMailLimit: s.dailyMailLimit,
|
|
315
316
|
shareUrl: s.shareUrl,
|
|
316
317
|
studioUrl: s.studioUrl,
|
|
317
318
|
};
|
|
@@ -398,19 +399,22 @@ export function registerTools(server, who) {
|
|
|
398
399
|
wizardId: z.string(),
|
|
399
400
|
enabled: z.boolean().optional(),
|
|
400
401
|
dailyRunLimit: z.number().int().min(1).max(10_000).optional(),
|
|
402
|
+
dailyMailLimit: z.number().int().min(0).max(10_000).optional(),
|
|
401
403
|
}),
|
|
402
404
|
destructive: true,
|
|
403
405
|
openWorld: true,
|
|
404
406
|
studio: true,
|
|
405
|
-
}, async ({ wizardId, enabled, dailyRunLimit }) => {
|
|
407
|
+
}, async ({ wizardId, enabled, dailyRunLimit, dailyMailLimit }) => {
|
|
406
408
|
const w = await updateWizardSettings(who.userId, wizardId, {
|
|
407
409
|
shareEnabled: enabled,
|
|
408
410
|
dailyRunLimit,
|
|
411
|
+
dailyMailLimit,
|
|
409
412
|
});
|
|
410
413
|
await pushSharing(who.userId, wizardId);
|
|
411
414
|
return {
|
|
412
415
|
shareEnabled: w.shareEnabled,
|
|
413
416
|
dailyRunLimit: w.dailyRunLimit,
|
|
417
|
+
dailyMailLimit: w.dailyMailLimit,
|
|
414
418
|
shareUrl: shareUrl(w.shareToken),
|
|
415
419
|
};
|
|
416
420
|
});
|
|
@@ -70,7 +70,7 @@ Replace the whole draft: for a new wizard, a rewrite, or anything edit_wizard ca
|
|
|
70
70
|
Publish the draft as a new version behind the share link. Refused while the draft has issues. Only when the person asked for it.
|
|
71
71
|
|
|
72
72
|
<!-- section: tool.set_sharing -->
|
|
73
|
-
Turn the share link on or off, or change how many runs it allows per day.
|
|
73
|
+
Turn the share link on or off, or change how many runs it allows per day and how many emails and messages its guests' runs send per day (0: none).
|
|
74
74
|
|
|
75
75
|
<!-- section: tool.start_test_run -->
|
|
76
76
|
Run the draft once with your answers. Spends the person's credits (short copy + image about 15, research about 150, video about 250). Pages are filled from `answers`, reviews accepted when acceptReviews is true. Follow it with get_test_run. Shows the flow with the run on it.
|
|
@@ -160,6 +160,10 @@ No file "${path}" in ${skill}. Its files: ${files}.
|
|
|
160
160
|
<!-- section: note.skill_folder -->
|
|
161
161
|
This skill's folder is in the sandbox at ${folder}: its SKILL.md and every file. Run its scripts with run_command from the working directory, e.g. python3 ${folder}/scripts/<file>.py, and install what they import first (pip install, npm install). Write what you make outside ${folder}.
|
|
162
162
|
|
|
163
|
+
<!-- In skill_load's answer for a skill a plugin brought together with a connector. `names`: the connectors; `prefixes`: what their tools' names start with. -->
|
|
164
|
+
<!-- section: note.skill_connector -->
|
|
165
|
+
This skill came together with the connector ${names}. Where this step has a connection to it, its actions are the tools whose names start with ${prefixes}. Without such a tool, follow the skill as far as it goes and say what you could not reach.
|
|
166
|
+
|
|
163
167
|
<!-- section: note.skill_scripts_refused -->
|
|
164
168
|
This skill's scripts may not run for whoever this step works for: the space's rules keep them closed. Follow its instructions without them.
|
|
165
169
|
|
|
@@ -235,6 +239,18 @@ The rules of ${service} do not allow this action here. Do not try it again or an
|
|
|
235
239
|
<!-- section: note.connector_needs_approval -->
|
|
236
240
|
This action on ${service} needs the approval of the space's admins, which cannot be asked for here. Do not try it again or another way; say in your result that it waits for them.
|
|
237
241
|
|
|
242
|
+
<!-- section: note.connector_paused -->
|
|
243
|
+
${service} is paused: an admin of the space stopped all use of it for now. Do not try it again or another way; say in your result that it waits until the connection is resumed.
|
|
244
|
+
|
|
245
|
+
<!-- section: note.connector_calls_per_run -->
|
|
246
|
+
${service} takes only so many calls from one run, and this run has made them. Do not try it again or another way; work with what you have, and say in your result what could not be done.
|
|
247
|
+
|
|
248
|
+
<!-- section: note.connector_calls_per_day -->
|
|
249
|
+
${service} takes only so many calls a day, and today's are made. Do not try it again or another way; say in your result that it can be done again tomorrow.
|
|
250
|
+
|
|
251
|
+
<!-- section: note.run_ended -->
|
|
252
|
+
This run has ended, so nothing more is called for it. Stop here; do not try it again or another way.
|
|
253
|
+
|
|
238
254
|
<!-- section: note.connector_ai_step_writes -->
|
|
239
255
|
An AI step only reads ${service}, which signs in as the space. A change there is a fixed step of the wizard, not yours; do not try it another way. Say in your result what should change.
|
|
240
256
|
|
|
@@ -86,7 +86,7 @@ export function logView(row) {
|
|
|
86
86
|
/** The person whose own lines are all they read of the log: a member. Undefined for an admin. */
|
|
87
87
|
const memberOf = (user) => managed && !isAdminRole(currentRole()) ? user.id : undefined;
|
|
88
88
|
/** The organization's people by id, with their role; alone, the one person; for a member, themselves. */
|
|
89
|
-
async function peopleOf(user, own) {
|
|
89
|
+
export async function peopleOf(user, own) {
|
|
90
90
|
if (!managed) {
|
|
91
91
|
return [{ id: user.id, name: (await userProfile(user)).name, role: "owner" }];
|
|
92
92
|
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { note } from "@engenty/wizards-shared/run";
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import { bodyLimit } from "hono/body-limit";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { applyBundleUpdate, bundleRemoval, bundleUpdate, importBundle, listBundles, previewBundle, removeBundle, } from "../bundles/index.js";
|
|
6
|
+
import { MAX_ARCHIVE_MB } from "../bundles/read.js";
|
|
7
|
+
import { actionKindSchema, signInChoiceSchema } from "../connectors/external.js";
|
|
8
|
+
import { ServiceError } from "../services/errors.js";
|
|
9
|
+
import { requestLang, say } from "./lang.js";
|
|
10
|
+
const serverChoice = z.object({
|
|
11
|
+
take: z.boolean().optional(),
|
|
12
|
+
id: z.string().min(2).max(60).optional(),
|
|
13
|
+
toolPrefix: z.string().min(2).max(31).optional(),
|
|
14
|
+
name: z.string().trim().min(1).max(120).optional(),
|
|
15
|
+
signIn: signInChoiceSchema.optional(),
|
|
16
|
+
actionKinds: z.record(z.string().max(200), actionKindSchema).optional(),
|
|
17
|
+
oauthClientId: z.string().max(500).optional(),
|
|
18
|
+
oauthClientSecret: z.string().max(500).optional(),
|
|
19
|
+
});
|
|
20
|
+
const sourceFields = {
|
|
21
|
+
address: z.string().trim().min(1).max(500).optional(),
|
|
22
|
+
path: z.string().max(300).optional(),
|
|
23
|
+
servers: z.record(z.string().max(100), serverChoice).optional(),
|
|
24
|
+
};
|
|
25
|
+
const previewSchema = z.object(sourceFields);
|
|
26
|
+
const importSchema = z.object({
|
|
27
|
+
...sourceFields,
|
|
28
|
+
hash: z.string().max(100).optional(),
|
|
29
|
+
skills: z.array(z.string().max(300)).max(200).optional(),
|
|
30
|
+
});
|
|
31
|
+
const updateSchema = z.object({ hash: z.string().max(100).optional() });
|
|
32
|
+
// A zip may weigh what a repository's archive may, and a little for the form around it.
|
|
33
|
+
const uploadLimit = bodyLimit({
|
|
34
|
+
maxSize: (MAX_ARCHIVE_MB + 4) * 1_000_000,
|
|
35
|
+
onError: (c) => c.json({ error: say(c, "tooLarge"), code: "too_large" }, 413),
|
|
36
|
+
});
|
|
37
|
+
/** A request's JSON, and its file where it came as a form. */
|
|
38
|
+
async function bodyOf(c) {
|
|
39
|
+
if (!(c.req.header("content-type") ?? "").startsWith("multipart/form-data")) {
|
|
40
|
+
return { options: await c.req.json().catch(() => ({})), file: null };
|
|
41
|
+
}
|
|
42
|
+
const form = await c.req.formData();
|
|
43
|
+
const file = form.get("file");
|
|
44
|
+
if (!(file instanceof File)) {
|
|
45
|
+
throw new ServiceError("invalid", note("chooseFile"));
|
|
46
|
+
}
|
|
47
|
+
const raw = form.get("options");
|
|
48
|
+
let options = {};
|
|
49
|
+
if (typeof raw === "string" && raw.trim()) {
|
|
50
|
+
try {
|
|
51
|
+
options = JSON.parse(raw);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
throw new ServiceError("invalid", { server: "bundleUploadKind" });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return { options, file: { name: file.name, data: new Uint8Array(await file.arrayBuffer()) } };
|
|
58
|
+
}
|
|
59
|
+
function sourceOf(input, file) {
|
|
60
|
+
const path = input.path?.trim() ? { path: input.path.trim() } : {};
|
|
61
|
+
if (file) {
|
|
62
|
+
return { file, ...path };
|
|
63
|
+
}
|
|
64
|
+
if (!input.address) {
|
|
65
|
+
throw new ServiceError("invalid", { server: "bundleNotARepository" });
|
|
66
|
+
}
|
|
67
|
+
return { address: input.address, ...path };
|
|
68
|
+
}
|
|
69
|
+
export const bundleRoutes = new Hono()
|
|
70
|
+
.post("/spaces/:id/bundles/preview", uploadLimit, async (c) => {
|
|
71
|
+
const { options, file } = await bodyOf(c);
|
|
72
|
+
const input = previewSchema.parse(options);
|
|
73
|
+
return c.json(await previewBundle(c.get("user").id, c.req.param("id"), sourceOf(input, file), requestLang(c), input.servers));
|
|
74
|
+
})
|
|
75
|
+
.get("/spaces/:id/bundles", async (c) => c.json({ bundles: await listBundles(c.get("user").id, c.req.param("id")) }))
|
|
76
|
+
.post("/spaces/:id/bundles", uploadLimit, async (c) => {
|
|
77
|
+
const { options, file } = await bodyOf(c);
|
|
78
|
+
const { address, path, ...input } = importSchema.parse(options);
|
|
79
|
+
return c.json(await importBundle(c.get("user").id, c.req.param("id"), sourceOf({ address, path }, file), input, requestLang(c)));
|
|
80
|
+
})
|
|
81
|
+
.get("/bundles/:id/update", async (c) => c.json(await bundleUpdate(c.get("user").id, c.req.param("id"), requestLang(c))))
|
|
82
|
+
.post("/bundles/:id/update", uploadLimit, async (c) => {
|
|
83
|
+
const { options, file } = await bodyOf(c);
|
|
84
|
+
const { hash } = updateSchema.parse(options);
|
|
85
|
+
return c.json(await applyBundleUpdate(c.get("user").id, c.req.param("id"), { ...(hash ? { hash } : {}), ...(file ? { file } : {}) }, requestLang(c)));
|
|
86
|
+
})
|
|
87
|
+
.get("/bundles/:id/removal", async (c) => c.json(await bundleRemoval(c.get("user").id, c.req.param("id"))))
|
|
88
|
+
.delete("/bundles/:id", async (c) => {
|
|
89
|
+
await removeBundle(c.get("user").id, c.req.param("id"));
|
|
90
|
+
return c.json({ ok: true });
|
|
91
|
+
});
|
|
@@ -2,7 +2,7 @@ import { Hono } from "hono";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { inAudience } from "../broker/index.js";
|
|
4
4
|
import { namesOf } from "../connectors/person-sign-ins.js";
|
|
5
|
-
import { connectionPatchSchema, createSpaceConnection, newConnectionSchema, removeSignIn, removeSpaceConnection, signInWithCredentials, spaceConnectionViews, startSpaceConnectionOAuth, updateSpaceConnection, } from "../connectors/space-connections.js";
|
|
5
|
+
import { connectionPatchSchema, createSpaceConnection, newConnectionSchema, pauseSpaceConnection, removeSignIn, removeSpaceConnection, signInWithCredentials, spaceConnectionViews, startSpaceConnectionOAuth, updateSpaceConnection, } from "../connectors/space-connections.js";
|
|
6
6
|
import { isAdminRole } from "../services/access.js";
|
|
7
7
|
import { ownedSpace } from "../services/spaces.js";
|
|
8
8
|
import { requestLang } from "./lang.js";
|
|
@@ -19,12 +19,20 @@ async function views(user, spaceId) {
|
|
|
19
19
|
const shown = admin
|
|
20
20
|
? all
|
|
21
21
|
: all.filter((v) => inAudience(v.audience, { kind: "person", id: user.id }));
|
|
22
|
-
const names = shown.some((v) => v.setUpBy) ? await namesOf(user) : null;
|
|
23
|
-
return shown.map((v) => ({
|
|
22
|
+
const names = shown.some((v) => v.setUpBy || v.pausedBy) ? await namesOf(user) : null;
|
|
23
|
+
return shown.map(({ pausedBy, ...v }) => ({
|
|
24
24
|
...v,
|
|
25
25
|
setUpByName: v.setUpBy ? (names?.get(v.setUpBy) ?? null) : null,
|
|
26
|
+
pausedByName: pausedBy ? (names?.get(pausedBy) ?? null) : null,
|
|
26
27
|
}));
|
|
27
28
|
}
|
|
29
|
+
/** Pauses or resumes a connection, and answers with it as the studio shows it. */
|
|
30
|
+
async function pause(c, paused) {
|
|
31
|
+
const user = c.get("user");
|
|
32
|
+
const row = await pauseSpaceConnection(user.id, c.req.param("id") ?? "", paused);
|
|
33
|
+
const [view] = (await views(user, row.spaceId)).filter((v) => v.id === row.id);
|
|
34
|
+
return c.json(view);
|
|
35
|
+
}
|
|
28
36
|
const asMe = (user) => ({ as: "person", userId: user.id, role: user.role });
|
|
29
37
|
export const connectionRoutes = new Hono()
|
|
30
38
|
.get("/spaces/:id/connections", async (c) => {
|
|
@@ -48,6 +56,9 @@ export const connectionRoutes = new Hono()
|
|
|
48
56
|
await removeSpaceConnection(c.get("user").id, c.req.param("id"));
|
|
49
57
|
return c.json({ ok: true });
|
|
50
58
|
})
|
|
59
|
+
// Nobody reaches a connection that pauses; resuming gives it back as it was.
|
|
60
|
+
.post("/connections/:id/pause", (c) => pause(c, true))
|
|
61
|
+
.post("/connections/:id/resume", (c) => pause(c, false))
|
|
51
62
|
// As the space: the admins' sign-in, kept on the connection itself.
|
|
52
63
|
.post("/connections/:id/sign-in", async (c) => signIn(c, asSpace))
|
|
53
64
|
.delete("/connections/:id/sign-in", async (c) => {
|
|
@@ -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"));
|