@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.
Files changed (128) hide show
  1. package/apps/runtime/dist/app.js +2 -0
  2. package/apps/runtime/dist/broker/account.js +20 -1
  3. package/apps/runtime/dist/broker/call.js +116 -20
  4. package/apps/runtime/dist/broker/host.js +8 -2
  5. package/apps/runtime/dist/broker/index.js +3 -2
  6. package/apps/runtime/dist/broker/log.js +149 -14
  7. package/apps/runtime/dist/broker/over.js +38 -0
  8. package/apps/runtime/dist/broker/rights.js +192 -0
  9. package/apps/runtime/dist/broker/rwx.js +295 -51
  10. package/apps/runtime/dist/broker/send.js +25 -12
  11. package/apps/runtime/dist/bundles/fetch.js +119 -0
  12. package/apps/runtime/dist/bundles/index.js +621 -0
  13. package/apps/runtime/dist/bundles/read.js +607 -0
  14. package/apps/runtime/dist/connectors/external.js +532 -61
  15. package/apps/runtime/dist/connectors/person-sign-ins.js +1 -0
  16. package/apps/runtime/dist/connectors/reload.js +73 -0
  17. package/apps/runtime/dist/connectors/space-connections.js +73 -6
  18. package/apps/runtime/dist/db/migrations/tenant/0058_mcp_state_across_roles.sql +26 -0
  19. package/apps/runtime/dist/db/migrations/tenant/0059_space_connection_paused.sql +2 -0
  20. package/apps/runtime/dist/db/migrations/tenant/0060_space_bundle.sql +21 -0
  21. package/apps/runtime/dist/db/migrations/tenant/0061_space_connection_limits.sql +2 -0
  22. package/apps/runtime/dist/db/migrations/tenant/meta/0058_snapshot.json +6696 -0
  23. package/apps/runtime/dist/db/migrations/tenant/meta/0059_snapshot.json +6710 -0
  24. package/apps/runtime/dist/db/migrations/tenant/meta/0060_snapshot.json +6857 -0
  25. package/apps/runtime/dist/db/migrations/tenant/meta/0061_snapshot.json +6871 -0
  26. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +28 -0
  27. package/apps/runtime/dist/db/schema.js +81 -3
  28. package/apps/runtime/dist/docs/dev/broker.md +251 -31
  29. package/apps/runtime/dist/docs/user-guide/capabilities.md +123 -5
  30. package/apps/runtime/dist/docs/user-guide/connectors.md +52 -5
  31. package/apps/runtime/dist/docs/user-guide/protocol.md +15 -4
  32. package/apps/runtime/dist/docs/user-guide/test-and-share.md +1 -1
  33. package/apps/runtime/dist/elements/caller.js +2 -2
  34. package/apps/runtime/dist/engenty/connections-external/build-connector.js +23 -8
  35. package/apps/runtime/dist/engenty/connections-external/import-service.js +18 -9
  36. package/apps/runtime/dist/engenty/connections-external/importer/classify.js +12 -0
  37. package/apps/runtime/dist/engenty/connections-external/invoke/http-invoker.js +1 -0
  38. package/apps/runtime/dist/engenty/connections-external/net/guarded-fetch.js +6 -3
  39. package/apps/runtime/dist/engenty/connections-sdk/oauth2.js +2 -2
  40. package/apps/runtime/dist/engenty/shims/web-ingest.js +64 -0
  41. package/apps/runtime/dist/engine/resources.js +15 -6
  42. package/apps/runtime/dist/engine/runner.js +2 -1
  43. package/apps/runtime/dist/env.js +2 -0
  44. package/apps/runtime/dist/index.js +11 -2
  45. package/apps/runtime/dist/mcp/handler.js +2 -2
  46. package/apps/runtime/dist/mcp/seen.js +71 -51
  47. package/apps/runtime/dist/mcp/tools.js +5 -1
  48. package/apps/runtime/dist/prompts/mcp.md +1 -1
  49. package/apps/runtime/dist/prompts/tools.md +16 -0
  50. package/apps/runtime/dist/routes/broker.js +1 -1
  51. package/apps/runtime/dist/routes/bundles.js +91 -0
  52. package/apps/runtime/dist/routes/connections.js +14 -3
  53. package/apps/runtime/dist/routes/rules.js +53 -9
  54. package/apps/runtime/dist/routes/studio.js +23 -18
  55. package/apps/runtime/dist/services/cloud.js +2 -0
  56. package/apps/runtime/dist/services/draft-events.js +79 -6
  57. package/apps/runtime/dist/services/files.js +2 -2
  58. package/apps/runtime/dist/services/skills.js +61 -5
  59. package/apps/runtime/dist/services/space-index.js +102 -10
  60. package/apps/runtime/dist/services/synced-spaces.js +5 -1
  61. package/apps/runtime/dist/services/wizards.js +48 -2
  62. package/apps/runtime/dist/sharing/jobs.js +6 -2
  63. package/apps/runtime/dist/sync/records.js +6 -1
  64. package/apps/runtime/dist/texts.js +36 -1
  65. package/apps/runtime/dist/tools/connections.js +8 -0
  66. package/apps/runtime/dist/tools/connector.js +13 -1
  67. package/apps/runtime/dist/tools/index.js +8 -3
  68. package/apps/runtime/dist/tools/skills.js +11 -1
  69. package/apps/web/dist/assets/{AboutDialog-B2Xmxyj4.js → AboutDialog-mZCBU7KF.js} +1 -1
  70. package/apps/web/dist/assets/{BlockEditor-D0HoUSih.js → BlockEditor-Dk0QwLSU.js} +1 -1
  71. package/apps/web/dist/assets/CapabilitiesPage-GkpgF-wZ.js +2 -0
  72. package/apps/web/dist/assets/{ChangelogDialog-BIrJbAKi.js → ChangelogDialog-BhyilZWA.js} +1 -1
  73. package/apps/web/dist/assets/{CodeEditor-DUVcXI5P.js → CodeEditor-DULYZbuE.js} +1 -1
  74. package/apps/web/dist/assets/EditorPage-D_mCdYdZ.js +3 -0
  75. package/apps/web/dist/assets/{FlowPreview-BIag8_Be.js → FlowPreview-ykxZxWnk.js} +1 -1
  76. package/apps/web/dist/assets/{LangSwitch-CJ00IgaO.js → LangSwitch-iO54w9AP.js} +1 -1
  77. package/apps/web/dist/assets/{Marketplace-D7-ot9Dz.js → Marketplace-C97fH7UC.js} +2 -2
  78. package/apps/web/dist/assets/{NewWizardChannels-DI3SQ4iS.js → NewWizardChannels-CsSV7sm2.js} +1 -1
  79. package/apps/web/dist/assets/{NewWizardPage-CytheHxX.js → NewWizardPage-Ebgw-Vf_.js} +1 -1
  80. package/apps/web/dist/assets/{OnboardingPage-_91Pa8Ad.js → OnboardingPage-BZlloT7v.js} +1 -1
  81. package/apps/web/dist/assets/PreviewPane-CJuqY5uA.js +7 -0
  82. package/apps/web/dist/assets/ProtocolSection-CPaDKVpZ.js +1 -0
  83. package/apps/web/dist/assets/{PublicRunner-CEgXSk3r.js → PublicRunner-4Lf4SnwB.js} +1 -1
  84. package/apps/web/dist/assets/{ReadOnly-CWf5x74a.js → ReadOnly-CXQ41R9Q.js} +1 -1
  85. package/apps/web/dist/assets/{SettingsPage-Dr8SDk-L.js → SettingsPage-C-8BgK9O.js} +2 -2
  86. package/apps/web/dist/assets/{SetupPage-B68n0l4I.js → SetupPage-4_K083Wl.js} +1 -1
  87. package/apps/web/dist/assets/{SharePage-DfznN7ar.js → SharePage-CQjgMcDI.js} +1 -1
  88. package/apps/web/dist/assets/{SkillEditor-BIcIczRc.js → SkillEditor-DT5hQwbg.js} +1 -1
  89. package/apps/web/dist/assets/{Skills-CN4QE7Kx.js → Skills-D7V_9_xo.js} +1 -1
  90. package/apps/web/dist/assets/SpacePage-D3rYS1bA.js +2 -0
  91. package/apps/web/dist/assets/{UpdateCheck-QhBI3rlQ.js → UpdateCheck-DVgAJmy8.js} +2 -2
  92. package/apps/web/dist/assets/changelog-DzQCUSsx.js +1 -0
  93. package/apps/web/dist/assets/{code-editor-DkPo1C-L.js → code-editor-5T7ilBjd.js} +2 -2
  94. package/apps/web/dist/assets/{host-D6H6Z9Jp.js → host-CCijW1hj.js} +6 -6
  95. package/apps/web/dist/assets/i18n-DCPDesT-.js +55 -0
  96. package/apps/web/dist/assets/{index-De0Wb42y.js → index-C_iWl8iS.js} +3 -3
  97. package/apps/web/dist/assets/index-zcPlodHx.css +1 -0
  98. package/apps/web/dist/assets/minus-BpYkOkYw.js +1 -0
  99. package/apps/web/dist/assets/{read-aloud-CnFwDSGD.js → read-aloud-Qb719not.js} +1 -1
  100. package/apps/web/dist/assets/{runners-0sTPbWzr.js → runners-BeZ84YH_.js} +1 -1
  101. package/apps/web/dist/assets/{session-BMiUrqHg.js → session-CEJRkSP5.js} +1 -1
  102. package/apps/web/dist/assets/{theme-CkNTe-_Z.js → theme-y_owNosi.js} +1 -1
  103. package/apps/web/dist/assets/{ui-DAk_vjrL.js → ui-BacfkQ7Q.js} +1 -1
  104. package/apps/web/dist/assets/{useMutation-isHfB33W.js → useMutation-CgzFr4qH.js} +1 -1
  105. package/apps/web/dist/assets/{viewers-ijNZHJFG.js → viewers-CkyHAjnk.js} +2 -2
  106. package/apps/web/dist/index.html +12 -12
  107. package/apps/web/dist/mcp/flow.html +2 -2
  108. package/node_modules/@engenty/wizards-shared/dist/bundles.d.ts +219 -0
  109. package/node_modules/@engenty/wizards-shared/dist/bundles.js +19 -0
  110. package/node_modules/@engenty/wizards-shared/dist/connectors.d.ts +105 -4
  111. package/node_modules/@engenty/wizards-shared/dist/connectors.js +6 -0
  112. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +8 -0
  113. package/node_modules/@engenty/wizards-shared/dist/run.js +16 -0
  114. package/node_modules/@engenty/wizards-shared/dist/rwx.d.ts +84 -1
  115. package/node_modules/@engenty/wizards-shared/dist/rwx.js +69 -1
  116. package/node_modules/@engenty/wizards-shared/dist/skills.d.ts +20 -3
  117. package/node_modules/@engenty/wizards-shared/dist/skills.js +5 -2
  118. package/package.json +1 -1
  119. package/plugin/.claude-plugin/plugin.json +1 -1
  120. package/plugin/plugin.json +1 -1
  121. package/apps/web/dist/assets/CapabilitiesPage-C1th2cZE.js +0 -2
  122. package/apps/web/dist/assets/EditorPage-56sIqEfF.js +0 -3
  123. package/apps/web/dist/assets/PreviewPane-BDsYm-_K.js +0 -7
  124. package/apps/web/dist/assets/ProtocolSection-D_zaxHEL.js +0 -1
  125. package/apps/web/dist/assets/SpacePage-DiVTwhnJ.js +0 -2
  126. package/apps/web/dist/assets/changelog-a_CuplMX.js +0 -1
  127. package/apps/web/dist/assets/i18n-BaPKbQ1s.js +0 -55
  128. package/apps/web/dist/assets/index-CCUG6Vnh.css +0 -1
@@ -65,6 +65,7 @@ export async function personSignIns(user) {
65
65
  : null,
66
66
  setUpBy: row.setUpBy ? (names?.get(row.setUpBy) ?? null) : null,
67
67
  setUpAt: row.setUpAt.toISOString(),
68
+ pausedAt: row.pausedAt?.toISOString() ?? null,
68
69
  });
69
70
  }
70
71
  spaces.push({ id: space.id, name: space.name, connections });
@@ -0,0 +1,73 @@
1
+ import { note } from "@engenty/wizards-shared/run";
2
+ import { eq } from "drizzle-orm";
3
+ import { brokerCall } from "../broker/index.js";
4
+ import { db, schema } from "../db/client.js";
5
+ import { requireAdmin, requireWritableSpace } from "../services/access.js";
6
+ import { ServiceError } from "../services/errors.js";
7
+ import { importedView, refreshConnector, resolveConnector } from "./external.js";
8
+ import { listSpaceConnections } from "./space-connections.js";
9
+ /*
10
+ * „Aktionen neu laden“ in the studio (docs/plans/capabilities-next.md, piece 1): an admin of a
11
+ * space that can be changed here has an imported connector's source read again. An MCP server
12
+ * that lists its tools only to a signed-in account is asked with the sign-in of a connection on
13
+ * that connector: the space's own, or the admin's where each person signs in. The broker reads
14
+ * the sign-in, as for every call, and the reload is a line of the audit.
15
+ */
16
+ export async function reloadConnector(userId, spaceId, id) {
17
+ await requireWritableSpace(spaceId);
18
+ await requireAdmin();
19
+ const current = await importedView(spaceId, id);
20
+ const resolved = current ? await resolveConnector(spaceId, id) : null;
21
+ if (!(current && resolved)) {
22
+ throw new ServiceError("not_found", note("connectorNotExist"));
23
+ }
24
+ const rows = (await listSpaceConnections(spaceId)).filter((row) => row.connectorId === id);
25
+ const own = rows.some((row) => row.signIn === "person")
26
+ ? new Set((await db
27
+ .select({ connectionId: schema.spaceConnectionSignIn.connectionId })
28
+ .from(schema.spaceConnectionSignIn)
29
+ .where(eq(schema.spaceConnectionSignIn.userId, userId))).map((s) => s.connectionId))
30
+ : new Set();
31
+ const signedIn = rows.filter((row) => (row.signIn === "space" ? !!row.secret : own.has(row.id)));
32
+ let failed;
33
+ let refused = null;
34
+ for (const row of signedIn) {
35
+ try {
36
+ const out = await brokerCall({
37
+ who: { kind: "admin", id: userId },
38
+ where: { spaceId },
39
+ // Listing the tools is none of the connector's actions, so a connection that is for a
40
+ // few of them does not narrow it. Its rule for reading still decides.
41
+ connection: {
42
+ kind: "space_connection",
43
+ row: { ...row, actions: [] },
44
+ connector: resolved.connector,
45
+ },
46
+ action: { id: "list_tools", kind: "read" },
47
+ input: {},
48
+ handler: (account) => refreshConnector(spaceId, id, account.ctx.accessToken),
49
+ });
50
+ if (out.ok) {
51
+ return out.result;
52
+ }
53
+ refused ??= out.reason;
54
+ }
55
+ catch (err) {
56
+ failed ??= err;
57
+ }
58
+ }
59
+ try {
60
+ return await refreshConnector(spaceId, id, null);
61
+ }
62
+ catch (err) {
63
+ // A signed-in connection asked and the source failed: that is the answer.
64
+ if (failed) {
65
+ throw failed;
66
+ }
67
+ // The source wants a sign-in, and no connection gave one.
68
+ if (/(^|\D)401(\D|$)|unauthori[sz]ed/i.test(err instanceof Error ? err.message : "")) {
69
+ throw new ServiceError("invalid", refused ?? note("connectorNoSignedInConnection", { name: current.name }));
70
+ }
71
+ throw err;
72
+ }
73
+ }
@@ -4,7 +4,7 @@ import { note } from "@engenty/wizards-shared/run";
4
4
  import { and, asc, eq, inArray } from "drizzle-orm";
5
5
  import { nanoid } from "nanoid";
6
6
  import { z } from "zod";
7
- import { inAudience, logRuleChange } from "../broker/index.js";
7
+ import { callsToday, inAudience, logRuleChange } from "../broker/index.js";
8
8
  import { db, schema } from "../db/client.js";
9
9
  import { buildAuthorizationUrl, createOAuth2Pkce, exchangeAuthorizationCode, } from "../engenty/connections-sdk/oauth2.js";
10
10
  import { currentFeatures } from "../features.js";
@@ -24,11 +24,14 @@ export const newConnectionSchema = z.object({
24
24
  connectorId: z.string().min(1).max(200),
25
25
  name: z.string().trim().min(1).max(CONNECTION_LIMITS.name),
26
26
  signIn: z.enum(CONNECTION_SIGN_INS),
27
- audience: z.enum(CONNECTION_AUDIENCES).default("members"),
27
+ /** Left out: the members, and the admins on a connector that came from a pasted address. */
28
+ audience: z.enum(CONNECTION_AUDIENCES).optional(),
28
29
  rules: rulesSchema.default(DEFAULT_CONNECTION_RULES),
29
30
  /** The connector's actions it is for; left out: every action. */
30
31
  actions: z.array(z.string().max(200)).max(200).default([]),
31
32
  });
33
+ /** A limit on a connection's calls: a whole number from 1, or null for none. */
34
+ const callLimit = z.number().int().min(1).max(CONNECTION_LIMITS.calls).nullable();
32
35
  export const connectionPatchSchema = z.object({
33
36
  name: z.string().trim().min(1).max(CONNECTION_LIMITS.name).optional(),
34
37
  /** How it signs in: a change forgets the sign-ins of the way it leaves. */
@@ -36,6 +39,9 @@ export const connectionPatchSchema = z.object({
36
39
  audience: z.enum(CONNECTION_AUDIENCES).optional(),
37
40
  rules: rulesSchema.optional(),
38
41
  actions: z.array(z.string().max(200)).max(200).optional(),
42
+ /** The calls one run makes through it at most, and the calls it takes per day; null: no limit. */
43
+ callsPerRun: callLimit.optional(),
44
+ callsPerDay: callLimit.optional(),
39
45
  });
40
46
  // --- reading ---------------------------------------------------------------------------------
41
47
  /** A connection by id, in this tenant; not found where the id is another tenant's or nobody's. */
@@ -108,8 +114,10 @@ export async function spaceConnectionViews(spaceId, userId) {
108
114
  .from(schema.spaceConnectionSignIn)
109
115
  .where(inArray(schema.spaceConnectionSignIn.connectionId, rows.map((row) => row.id)))
110
116
  : [];
117
+ const today = await callsToday(rows.map((row) => row.id));
111
118
  return Promise.all(rows.map(async (row) => {
112
- const connector = (await resolveConnector(spaceId, row.connectorId))?.connector ?? null;
119
+ const found = await resolveConnector(spaceId, row.connectorId);
120
+ const connector = found?.connector ?? null;
113
121
  const theirs = row.signIn === "person" ? signIns.filter((s) => s.connectionId === row.id) : [];
114
122
  const mine = theirs.find((s) => s.userId === userId);
115
123
  return {
@@ -125,6 +133,7 @@ export async function spaceConnectionViews(spaceId, userId) {
125
133
  ...(connector.auth.kind === "api_key"
126
134
  ? { fields: connector.auth.apiKey.fields }
127
135
  : {}),
136
+ ...(found?.fromAddress ? { fromAddress: true } : {}),
128
137
  }
129
138
  : null,
130
139
  name: row.name,
@@ -136,6 +145,7 @@ export async function spaceConnectionViews(spaceId, userId) {
136
145
  pluginName: row.plugin
137
146
  ? (loadedPlugin(row.plugin)?.source.manifest.name ?? row.plugin)
138
147
  : null,
148
+ bundleId: row.bundleId,
139
149
  account: row.signIn === "space" && row.secret
140
150
  ? {
141
151
  label: row.label ?? connector?.name ?? row.name,
@@ -149,6 +159,11 @@ export async function spaceConnectionViews(spaceId, userId) {
149
159
  setUpAt: row.setUpAt.toISOString(),
150
160
  lastUsedAt: row.lastUsedAt?.toISOString() ?? null,
151
161
  signedIn: theirs.length,
162
+ pausedAt: row.pausedAt?.toISOString() ?? null,
163
+ pausedBy: row.pausedBy,
164
+ callsPerRun: row.callsPerRun,
165
+ callsPerDay: row.callsPerDay,
166
+ callsToday: today.get(row.id) ?? 0,
152
167
  };
153
168
  }));
154
169
  }
@@ -198,9 +213,12 @@ plugin = null) {
198
213
  spaceId,
199
214
  connectorId: found.connector.id,
200
215
  plugin,
216
+ // Its connector came with a plugin for Claude Code or Cursor: it goes with that, too.
217
+ bundleId: found.bundleId,
201
218
  name: input.name,
202
219
  signIn: input.signIn,
203
- audience: input.audience,
220
+ // A server nobody checked reaches the AI with its own texts: the admins use it first.
221
+ audience: input.audience ?? (found.fromAddress ? "admins" : "members"),
204
222
  rules: input.rules,
205
223
  actions: knownActions(found.connector, input.actions),
206
224
  setUpBy: userId,
@@ -233,6 +251,8 @@ export async function updateSpaceConnection(userId, id, patch) {
233
251
  ...(patch.audience !== undefined ? { audience: patch.audience } : {}),
234
252
  ...(patch.rules !== undefined ? { rules: patch.rules } : {}),
235
253
  ...(actions !== undefined ? { actions } : {}),
254
+ ...(patch.callsPerRun !== undefined ? { callsPerRun: patch.callsPerRun } : {}),
255
+ ...(patch.callsPerDay !== undefined ? { callsPerDay: patch.callsPerDay } : {}),
236
256
  updatedAt: new Date(),
237
257
  })
238
258
  .where(eq(schema.spaceConnection.id, row.id))
@@ -242,10 +262,12 @@ export async function updateSpaceConnection(userId, id, patch) {
242
262
  .delete(schema.spaceConnectionSignIn)
243
263
  .where(eq(schema.spaceConnectionSignIn.connectionId, row.id));
244
264
  }
245
- // How it signs in, who may use it, and what each kind of action may do: a change there is heard of.
265
+ // How it signs in, who may use it, what each kind of action may do and how many calls it takes:
266
+ // a change there is heard of.
246
267
  const rulesChanged = patch.rules !== undefined && JSON.stringify(patch.rules) !== JSON.stringify(row.rules);
247
268
  const audienceChanged = patch.audience !== undefined && patch.audience !== row.audience;
248
- if (rulesChanged || audienceChanged || signInChanged) {
269
+ const limits = changedLimits(row, updated);
270
+ if (rulesChanged || audienceChanged || signInChanged || limits) {
249
271
  await logRuleChange({
250
272
  userId,
251
273
  spaceId: row.spaceId,
@@ -254,6 +276,7 @@ export async function updateSpaceConnection(userId, id, patch) {
254
276
  ...(signInChanged ? { signIn: `${row.signIn} → ${updated.signIn}` } : {}),
255
277
  ...(audienceChanged ? { audience: `${row.audience} → ${updated.audience}` } : {}),
256
278
  ...(rulesChanged ? { rules: changedRules(row.rules, updated.rules) } : {}),
279
+ ...(limits ? { limits } : {}),
257
280
  },
258
281
  reason: [
259
282
  signInChanged
@@ -263,6 +286,7 @@ export async function updateSpaceConnection(userId, id, patch) {
263
286
  : "",
264
287
  audienceChanged ? `The audience is now ${updated.audience}.` : "",
265
288
  rulesChanged ? `The rules changed: ${changedRules(row.rules, updated.rules)}.` : "",
289
+ limits ? `The limits changed: ${limits}.` : "",
266
290
  ]
267
291
  .filter(Boolean)
268
292
  .join(" "),
@@ -277,6 +301,49 @@ function changedRules(before, after) {
277
301
  .map((k) => `${k}: ${before[k]} → ${after[k]}`)
278
302
  .join(", ");
279
303
  }
304
+ /** "calls per run: none → 20, calls per day: 500 → none"; empty where no limit changed. */
305
+ function changedLimits(before, after) {
306
+ const said = (limit) => (limit === null ? "none" : String(limit));
307
+ return [
308
+ ["calls per run", before.callsPerRun, after.callsPerRun],
309
+ ["calls per day", before.callsPerDay, after.callsPerDay],
310
+ ]
311
+ .filter(([, was, is]) => was !== is)
312
+ .map(([name, was, is]) => `${name}: ${said(was)} → ${said(is)}`)
313
+ .join(", ");
314
+ }
315
+ /**
316
+ * Pauses a connection, or resumes it (docs/plans/capabilities-next.md, 2a): while it pauses the
317
+ * broker refuses every call through it, whoever calls, at the call (broker/call.ts reads the
318
+ * pause each time). Nothing is lost: its sign-ins, rules and audience stay. Heard of as a changed
319
+ * rule, with who did it. Pausing what pauses, or resuming what does not, changes nothing.
320
+ */
321
+ export async function pauseSpaceConnection(userId, id, paused) {
322
+ const row = await spaceConnectionById(id);
323
+ await ownedSpace(userId, row.spaceId);
324
+ await requireWritableSpace(row.spaceId);
325
+ await requireAdmin();
326
+ if (Boolean(row.pausedAt) === paused) {
327
+ return row;
328
+ }
329
+ const [updated] = await db
330
+ .update(schema.spaceConnection)
331
+ .set({
332
+ pausedAt: paused ? new Date() : null,
333
+ pausedBy: paused ? userId : null,
334
+ updatedAt: new Date(),
335
+ })
336
+ .where(eq(schema.spaceConnection.id, row.id))
337
+ .returning();
338
+ await logRuleChange({
339
+ userId,
340
+ spaceId: row.spaceId,
341
+ connectionId: row.id,
342
+ summary: { paused: paused ? "yes" : "no" },
343
+ reason: paused ? "The connection is paused: nobody reaches it." : "The connection is resumed.",
344
+ });
345
+ return updated;
346
+ }
280
347
  export async function removeSpaceConnection(userId, id) {
281
348
  const row = await spaceConnectionById(id);
282
349
  await ownedSpace(userId, row.spaceId);
@@ -0,0 +1,26 @@
1
+ CREATE TABLE `draft_change` (
2
+ `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
3
+ `wizard_id` text NOT NULL,
4
+ `change` text NOT NULL,
5
+ `created_at` integer DEFAULT (unixepoch() * 1000) NOT NULL,
6
+ FOREIGN KEY (`wizard_id`) REFERENCES `wizard`(`id`) ON UPDATE no action ON DELETE cascade
7
+ );
8
+ --> statement-breakpoint
9
+ CREATE INDEX `draft_change_wizard` ON `draft_change` (`wizard_id`,`id`);--> statement-breakpoint
10
+ CREATE INDEX `draft_change_at` ON `draft_change` (`created_at`);--> statement-breakpoint
11
+ CREATE TABLE `mcp_app_check` (
12
+ `app` text NOT NULL,
13
+ `person` text NOT NULL,
14
+ `kind` text NOT NULL,
15
+ `allowed` integer DEFAULT 0 NOT NULL,
16
+ `refused` integer DEFAULT 0 NOT NULL,
17
+ `at` integer NOT NULL,
18
+ PRIMARY KEY(`app`, `person`)
19
+ );
20
+ --> statement-breakpoint
21
+ CREATE TABLE `mcp_app_seen` (
22
+ `app` text PRIMARY KEY NOT NULL,
23
+ `at` integer NOT NULL,
24
+ `tool_at` integer,
25
+ `widget_at` integer
26
+ );
@@ -0,0 +1,2 @@
1
+ ALTER TABLE `space_connection` ADD `paused_at` integer;--> statement-breakpoint
2
+ ALTER TABLE `space_connection` ADD `paused_by` text;
@@ -0,0 +1,21 @@
1
+ CREATE TABLE `space_bundle` (
2
+ `id` text PRIMARY KEY NOT NULL,
3
+ `tenant_id` text NOT NULL,
4
+ `space_id` text NOT NULL,
5
+ `name` text NOT NULL,
6
+ `version` text,
7
+ `description` text,
8
+ `format` text NOT NULL,
9
+ `origin` text NOT NULL,
10
+ `hash` text NOT NULL,
11
+ `left_out` text DEFAULT '[]' NOT NULL,
12
+ `added_by` text,
13
+ `created_at` integer DEFAULT (unixepoch() * 1000) NOT NULL,
14
+ `updated_at` integer DEFAULT (unixepoch() * 1000) NOT NULL,
15
+ FOREIGN KEY (`space_id`) REFERENCES `space`(`id`) ON UPDATE no action ON DELETE cascade
16
+ );
17
+ --> statement-breakpoint
18
+ CREATE INDEX `space_bundle_space` ON `space_bundle` (`space_id`);--> statement-breakpoint
19
+ ALTER TABLE `space_connection` ADD `bundle_id` text;--> statement-breakpoint
20
+ ALTER TABLE `space_connector` ADD `bundle_id` text;--> statement-breakpoint
21
+ ALTER TABLE `space_skill` ADD `bundle_id` text;
@@ -0,0 +1,2 @@
1
+ ALTER TABLE `space_connection` ADD `calls_per_run` integer;--> statement-breakpoint
2
+ ALTER TABLE `space_connection` ADD `calls_per_day` integer;