@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
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { and, eq, gte, inArray, isNull, notLike, or } from "drizzle-orm";
|
|
2
2
|
import { db, schema } from "../db/client.js";
|
|
3
3
|
import { channelInGrant, grantOf } from "./grant.js";
|
|
4
|
-
import { summarizeInput, writeLog } from "./log.js";
|
|
4
|
+
import { startOfToday, summarizeInput, writeLog } from "./log.js";
|
|
5
|
+
import { runOver } from "./over.js";
|
|
5
6
|
/*
|
|
6
7
|
* Sends from a guest's run (docs/plans/capabilities.md, A6; rule 7 of the connections plan): a
|
|
7
8
|
* mail leaves only for an address the run itself collected — what the person typed into a page
|
|
@@ -45,8 +46,13 @@ export function guestPostCheck(post) {
|
|
|
45
46
|
: { ok: false, refused: "channel_not_fixed", reason: FIXED_CHANNEL_ONLY };
|
|
46
47
|
}
|
|
47
48
|
const ADDRESS = /^[^\s@<>,;]+@[^\s@<>,;]+\.[^\s@<>,;]+$/;
|
|
48
|
-
/**
|
|
49
|
-
|
|
49
|
+
/**
|
|
50
|
+
* The addresses a send's input names: the field the connector's action names as the recipient's
|
|
51
|
+
* (an imported connector: what an admin said, `body.to` for one inside an HTTP body), and `to`,
|
|
52
|
+
* `cc`, `bcc`, `recipients`, as strings, lists or objects. The named field comes on top of the
|
|
53
|
+
* guess, never in place of it: an address in `cc` is still one the send goes to.
|
|
54
|
+
*/
|
|
55
|
+
export function recipientsOf(input, field) {
|
|
50
56
|
if (!input || typeof input !== "object") {
|
|
51
57
|
return [];
|
|
52
58
|
}
|
|
@@ -71,6 +77,13 @@ export function recipientsOf(input) {
|
|
|
71
77
|
take(o.email ?? o.address ?? o.emailAddress);
|
|
72
78
|
}
|
|
73
79
|
};
|
|
80
|
+
if (field) {
|
|
81
|
+
let value = input;
|
|
82
|
+
for (const part of field.split(".")) {
|
|
83
|
+
value = value && typeof value === "object" ? value[part] : null;
|
|
84
|
+
}
|
|
85
|
+
take(value);
|
|
86
|
+
}
|
|
74
87
|
for (const key of ["to", "cc", "bcc", "recipients", "recipient"]) {
|
|
75
88
|
take(input[key]);
|
|
76
89
|
}
|
|
@@ -106,11 +119,6 @@ export function inMailDomains(address, domains) {
|
|
|
106
119
|
return own && (domain === own || domain.endsWith(`.${own}`));
|
|
107
120
|
}));
|
|
108
121
|
}
|
|
109
|
-
/** Today's first moment, as the per-day count sees it. */
|
|
110
|
-
const startOfToday = () => {
|
|
111
|
-
const now = new Date();
|
|
112
|
-
return new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()));
|
|
113
|
-
};
|
|
114
122
|
/**
|
|
115
123
|
* How often guests sent through this run, and through this wizard today: mails and posts, a
|
|
116
124
|
* guest's own and those of the fixed steps of guests' runs.
|
|
@@ -194,13 +202,13 @@ export async function guestSendCheck(where, send) {
|
|
|
194
202
|
}
|
|
195
203
|
/**
|
|
196
204
|
* A mail from the server's own address, which no account holds: the one send that is not a
|
|
197
|
-
* connector's action. A
|
|
198
|
-
* other, under the connection `mail:server`.
|
|
205
|
+
* connector's action. A run that is over sends nothing (over.ts), asked first; a guest's run is
|
|
206
|
+
* bound by the rules above; the call is logged like any other, under the connection `mail:server`.
|
|
199
207
|
*/
|
|
200
208
|
export async function brokerSend(call) {
|
|
201
209
|
const started = Date.now();
|
|
202
210
|
const { who, where } = call;
|
|
203
|
-
const line = (outcome, reason, result) => writeLog({
|
|
211
|
+
const line = (outcome, reason, result, rule = "guest_send") => writeLog({
|
|
204
212
|
at: new Date(started),
|
|
205
213
|
durationMs: Date.now() - started,
|
|
206
214
|
whoKind: who.kind,
|
|
@@ -215,11 +223,16 @@ export async function brokerSend(call) {
|
|
|
215
223
|
kind: "send",
|
|
216
224
|
inputSummary: summarizeInput(call.input),
|
|
217
225
|
outcome,
|
|
218
|
-
rule
|
|
226
|
+
rule,
|
|
219
227
|
reason,
|
|
220
228
|
result,
|
|
221
229
|
resultSize: null,
|
|
222
230
|
});
|
|
231
|
+
const over = await runOver(where);
|
|
232
|
+
if (over) {
|
|
233
|
+
await line("deny", over.reason, "run_ended", over.rule);
|
|
234
|
+
return { ok: false, refused: "run_ended", reason: over.reason };
|
|
235
|
+
}
|
|
223
236
|
let reason = "The server's address sends for members.";
|
|
224
237
|
if (where.guest) {
|
|
225
238
|
const check = await guestSendCheck(where, { recipients: call.recipients });
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { createGuardedFetch } from "../engenty/connections-external/net/guarded-fetch.js";
|
|
2
|
+
import { ServiceError } from "../services/errors.js";
|
|
3
|
+
import { MAX_ARCHIVE_MB } from "./read.js";
|
|
4
|
+
/**
|
|
5
|
+
* A public repository on GitHub as a zip (docs/plans/capabilities-next.md, piece 4). The address
|
|
6
|
+
* is one a person copies from the browser: the repository, or a folder of it on a branch or tag.
|
|
7
|
+
* The archive comes from GitHub's own download host through the guarded fetch, which follows no
|
|
8
|
+
* redirect into a private network, and is refused before it is read whole where it is too large.
|
|
9
|
+
*/
|
|
10
|
+
const refuse = (server, params) => new ServiceError("invalid", { server, params });
|
|
11
|
+
const PART = /^[A-Za-z0-9_.-]{1,100}$/;
|
|
12
|
+
/**
|
|
13
|
+
* A repository's address on GitHub: `https://github.com/owner/name`, with `.git` or without, and
|
|
14
|
+
* a folder as `…/tree/<branch>/<folder>`. A branch whose name has a slash cannot be told from a
|
|
15
|
+
* folder: its first part is read as the branch. Null for any other address.
|
|
16
|
+
*/
|
|
17
|
+
export function parseRepoAddress(address) {
|
|
18
|
+
const typed = address.trim();
|
|
19
|
+
let url;
|
|
20
|
+
try {
|
|
21
|
+
url = new URL(/^[a-z][a-z0-9+.-]*:\/\//i.test(typed) ? typed : `https://${typed}`);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
if (!/^(www\.)?github\.com$/i.test(url.hostname) || !/^https?:$/.test(url.protocol)) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const [owner, rawName, kind, ref, ...rest] = url.pathname.split("/").filter(Boolean);
|
|
30
|
+
const name = rawName?.replace(/\.git$/i, "");
|
|
31
|
+
if (!(owner && name && PART.test(owner) && PART.test(name))) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const folder = kind === "tree" || kind === "blob";
|
|
35
|
+
let path;
|
|
36
|
+
try {
|
|
37
|
+
path = folder ? rest.map((part) => decodeURIComponent(part)) : [];
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
if (path.some((part) => part === ".." || part === "." || part.includes("\\"))) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
repo: `${owner}/${name}`,
|
|
47
|
+
ref: folder && ref ? decodeURIComponent(ref) : null,
|
|
48
|
+
path: path.join("/"),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** The address a person opens to look at the origin. */
|
|
52
|
+
export function repoUrl(address) {
|
|
53
|
+
const tail = address.ref || address.path
|
|
54
|
+
? `/tree/${address.ref ?? "HEAD"}${address.path ? `/${address.path}` : ""}`
|
|
55
|
+
: "";
|
|
56
|
+
return `https://github.com/${address.repo}${tail}`;
|
|
57
|
+
}
|
|
58
|
+
/** The repository as a zip, as it is on its branch or tag now. */
|
|
59
|
+
export async function fetchRepoZip(address) {
|
|
60
|
+
const guarded = createGuardedFetch();
|
|
61
|
+
const url = `https://codeload.github.com/${address.repo}/zip/${encodeURIComponent(address.ref ?? "HEAD")}`;
|
|
62
|
+
let res;
|
|
63
|
+
try {
|
|
64
|
+
res = await guarded(url, {
|
|
65
|
+
headers: { accept: "application/zip", "user-agent": "engenty-wizards" },
|
|
66
|
+
signal: AbortSignal.timeout(45_000),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
throw new ServiceError("refused", { server: "bundleRepoDown" });
|
|
71
|
+
}
|
|
72
|
+
if (res.status === 404) {
|
|
73
|
+
throw refuse("bundleRepoNotFound", { repo: address.repo });
|
|
74
|
+
}
|
|
75
|
+
if (!res.ok) {
|
|
76
|
+
throw new ServiceError("refused", { server: "bundleRepoDown" });
|
|
77
|
+
}
|
|
78
|
+
const max = MAX_ARCHIVE_MB * 1_000_000;
|
|
79
|
+
const tooLarge = () => refuse("bundleTooLarge", { mb: MAX_ARCHIVE_MB });
|
|
80
|
+
if (Number(res.headers.get("content-length")) > max) {
|
|
81
|
+
throw tooLarge();
|
|
82
|
+
}
|
|
83
|
+
const reader = res.body?.getReader();
|
|
84
|
+
if (!reader) {
|
|
85
|
+
const all = new Uint8Array(await res.arrayBuffer());
|
|
86
|
+
if (all.length > max) {
|
|
87
|
+
throw tooLarge();
|
|
88
|
+
}
|
|
89
|
+
return all;
|
|
90
|
+
}
|
|
91
|
+
const chunks = [];
|
|
92
|
+
let total = 0;
|
|
93
|
+
try {
|
|
94
|
+
while (true) {
|
|
95
|
+
const { done, value } = await reader.read();
|
|
96
|
+
if (done) {
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
total += value.byteLength;
|
|
100
|
+
if (total > max) {
|
|
101
|
+
throw tooLarge();
|
|
102
|
+
}
|
|
103
|
+
chunks.push(value);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
await reader.cancel().catch(() => undefined);
|
|
108
|
+
throw err instanceof ServiceError
|
|
109
|
+
? err
|
|
110
|
+
: new ServiceError("refused", { server: "bundleRepoDown" });
|
|
111
|
+
}
|
|
112
|
+
const all = new Uint8Array(total);
|
|
113
|
+
let at = 0;
|
|
114
|
+
for (const chunk of chunks) {
|
|
115
|
+
all.set(chunk, at);
|
|
116
|
+
at += chunk.byteLength;
|
|
117
|
+
}
|
|
118
|
+
return all;
|
|
119
|
+
}
|