@capybara-hq/kernel 0.1.0-rc.45 → 0.1.0-rc.47
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/bootstrap.json +3 -3
- package/dist/admin/admin.schemas.d.ts +6 -0
- package/dist/agents/agent-lookup.d.ts +5 -2
- package/dist/agents/agent-lookup.js +3 -0
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/config/schema.d.ts +7 -0
- package/dist/config/schema.js +27 -0
- package/dist/conversations/access.d.ts +14 -5
- package/dist/conversations/access.js +29 -20
- package/dist/conversations/conversations.service.d.ts +6 -1
- package/dist/conversations/conversations.service.js +12 -2
- package/dist/conversations/files.d.ts +43 -0
- package/dist/conversations/files.js +80 -3
- package/dist/ctx/create-ctx.d.ts +7 -0
- package/dist/ctx/create-ctx.js +9 -2
- package/dist/db/kernel-schema.d.ts +30 -0
- package/dist/errors.d.ts +22 -0
- package/dist/errors.js +22 -0
- package/dist/extensions/extensions.module.js +3 -0
- package/dist/extensions/host.d.ts +4 -1
- package/dist/extensions/host.js +15 -10
- package/dist/files/previewers.d.ts +44 -0
- package/dist/files/previewers.js +84 -30
- package/dist/html/csp.d.ts +13 -0
- package/dist/html/csp.js +33 -0
- package/dist/html/html-document.controller.d.ts +31 -0
- package/dist/html/html-document.controller.js +75 -0
- package/dist/html/html-document.service.d.ts +49 -0
- package/dist/html/html-document.service.js +143 -0
- package/dist/html/html-token.d.ts +58 -0
- package/dist/html/html-token.js +154 -0
- package/dist/html/html-type.d.ts +13 -0
- package/dist/html/html-type.js +40 -0
- package/dist/html/html.module.d.ts +6 -0
- package/dist/html/html.module.js +26 -0
- package/dist/http/api.module.js +14 -0
- package/dist/http/error.filter.d.ts +2 -0
- package/dist/http/error.filter.js +9 -2
- package/dist/http/plugin-route-access.d.ts +2 -1
- package/dist/http/plugin-route-access.js +16 -1
- package/dist/identity/settings.d.ts +26 -1
- package/dist/identity/settings.js +88 -2
- package/dist/infra/config/kernel-config.service.js +3 -0
- package/dist/infra/outbox/registry.d.ts +13 -0
- package/dist/infra/outbox/registry.js +8 -0
- package/dist/infra/throttler/credential-throttler.d.ts +4 -1
- package/dist/infra/throttler/credential-throttler.js +5 -2
- package/dist/infra/throttler/named-throttlers.d.ts +1 -0
- package/dist/infra/throttler/named-throttlers.js +14 -0
- package/dist/orgs/offboarding.d.ts +3 -1
- package/dist/orgs/offboarding.js +7 -1
- package/dist/orgs/settings.service.d.ts +21 -4
- package/dist/orgs/settings.service.js +47 -7
- package/dist/overrides.d.ts +3 -0
- package/dist/overrides.js +2 -0
- package/dist/platform/exclusions.js +63 -0
- package/dist/platform/operation.js +1 -1
- package/dist/platform/ops/admin.ops.js +18 -3
- package/dist/platform/ops/org-settings.ops.js +6 -2
- package/dist/platform/ops/orgs.ops.js +3 -0
- package/dist/platform/ops/shares.ops.d.ts +16 -0
- package/dist/platform/ops/shares.ops.js +107 -0
- package/dist/platform/platform-ops.module.d.ts +2 -1
- package/dist/platform/platform-ops.module.js +5 -0
- package/dist/platform/route-schemas.js +3 -0
- package/dist/roles/worker.module.js +6 -0
- package/dist/runtime/maintenance.d.ts +4 -2
- package/dist/runtime/maintenance.js +14 -4
- package/dist/shares/liveness.d.ts +59 -0
- package/dist/shares/liveness.js +163 -0
- package/dist/shares/revoke.d.ts +26 -0
- package/dist/shares/revoke.js +43 -0
- package/dist/shares/settings.d.ts +76 -0
- package/dist/shares/settings.js +117 -0
- package/dist/shares/share-code.d.ts +4 -0
- package/dist/shares/share-code.js +28 -0
- package/dist/shares/share-objects.d.ts +52 -0
- package/dist/shares/share-objects.js +123 -0
- package/dist/shares/share-open.controller.d.ts +35 -0
- package/dist/shares/share-open.controller.js +107 -0
- package/dist/shares/share-open.service.d.ts +107 -0
- package/dist/shares/share-open.service.js +287 -0
- package/dist/shares/share-previews.controller.d.ts +50 -0
- package/dist/shares/share-previews.controller.js +115 -0
- package/dist/shares/shares.controller.d.ts +34 -0
- package/dist/shares/shares.controller.js +114 -0
- package/dist/shares/shares.module.d.ts +8 -0
- package/dist/shares/shares.module.js +41 -0
- package/dist/shares/shares.schemas.d.ts +31 -0
- package/dist/shares/shares.schemas.js +25 -0
- package/dist/shares/shares.service.d.ts +182 -0
- package/dist/shares/shares.service.js +553 -0
- package/dist/shares/sweep.job.d.ts +72 -0
- package/dist/shares/sweep.job.js +330 -0
- package/dist/tools/builtins/sandbox/deliver.js +3 -1
- package/dist/ui/embed-token.d.ts +2 -2
- package/dist/ui/embed-token.js +38 -2
- package/dist/ui/views.d.ts +6 -0
- package/dist/ui/views.js +17 -0
- package/package.json +2 -2
- package/src/migrations/0161_file_shares.sql +35 -0
|
@@ -402,6 +402,69 @@ export const PLATFORM_EXCLUSIONS = [
|
|
|
402
402
|
category: "transport",
|
|
403
403
|
reason: "Serves a rendered file preview",
|
|
404
404
|
},
|
|
405
|
+
// shares of conversation files (file sharing spec §10); listing and revoking are operations
|
|
406
|
+
{
|
|
407
|
+
route: "POST /api/v1/orgs/:orgId/conversations/:id/files/:fileId/shares",
|
|
408
|
+
category: "human-only",
|
|
409
|
+
reason: "Publishing a file outside the conversation is a person's act",
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
route: "POST /api/v1/orgs/:orgId/shares/:shareId/refresh",
|
|
413
|
+
category: "human-only",
|
|
414
|
+
reason: "Publishing a file outside the conversation is a person's act",
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
route: "GET /api/v1/orgs/:orgId/conversations/:id/files/:fileId/shares",
|
|
418
|
+
category: "internal",
|
|
419
|
+
reason: "The right panel's per-file view; conversations.list-shares lists the same shares",
|
|
420
|
+
},
|
|
421
|
+
// the HTML document (file sharing spec §4, §10)
|
|
422
|
+
{
|
|
423
|
+
route: "POST /api/v1/orgs/:orgId/conversations/:id/files/:fileId/html-token",
|
|
424
|
+
category: "transport",
|
|
425
|
+
reason: "Mints the HTML document's load token for the web panel",
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
route: "GET /api/v1/html/*",
|
|
429
|
+
category: "transport",
|
|
430
|
+
reason: "Serves a sandboxed HTML document",
|
|
431
|
+
},
|
|
432
|
+
// public share links (file sharing spec §3, §10): the link's code is the authority
|
|
433
|
+
{
|
|
434
|
+
route: "GET /api/v1/s/:code",
|
|
435
|
+
category: "transport",
|
|
436
|
+
reason: "Public share link: the shared file's metadata for the share page",
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
route: "GET /api/v1/s/:code/content",
|
|
440
|
+
category: "transport",
|
|
441
|
+
reason: "Public share link: streams the shared snapshot's bytes",
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
route: "GET /api/v1/s/:code/text",
|
|
445
|
+
category: "transport",
|
|
446
|
+
reason: "Public share link: the shared text for the share page's preview",
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
route: "GET /api/v1/s/:code/inline",
|
|
450
|
+
category: "transport",
|
|
451
|
+
reason: "Public share link: the shared image shown in place",
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
route: "GET /api/v1/s/:code/html",
|
|
455
|
+
category: "transport",
|
|
456
|
+
reason: "Public share link: redirects to the sandboxed HTML document",
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
route: "POST /api/v1/s/:code/embed-token/:plugin/:previewerId",
|
|
460
|
+
category: "transport",
|
|
461
|
+
reason: "Public share link: a share-scoped embed token for the share page's embed previewer",
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
route: "GET /api/v1/s/:code/previews/:plugin/:previewerId",
|
|
465
|
+
category: "transport",
|
|
466
|
+
reason: "Public share link: a view previewer rendered for the shared snapshot",
|
|
467
|
+
},
|
|
405
468
|
// identity
|
|
406
469
|
{
|
|
407
470
|
route: "POST /api/v1/orgs/:orgId/approvals/:approvalId/initial-password",
|
|
@@ -45,7 +45,7 @@ export const PLATFORM_DOMAINS = [
|
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
47
|
id: "conversations",
|
|
48
|
-
description: "Your own conversations: list, read, rename, archive, delete, read their events, list and stop their background tasks.",
|
|
48
|
+
description: "Your own conversations: list, read, rename, archive, delete, read their events, list and stop their background tasks, list and revoke shared file links.",
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
id: "orgs",
|
|
@@ -46,6 +46,9 @@ const SettingsInput = DEPLOYMENT_SETTINGS_PATCH.pick({
|
|
|
46
46
|
devicesFullAccess: true,
|
|
47
47
|
devicesAutoMode: true,
|
|
48
48
|
attribution: true,
|
|
49
|
+
externalSharing: true,
|
|
50
|
+
shareMaxExpiryDays: true,
|
|
51
|
+
htmlRenderCdnAllowlist: true,
|
|
49
52
|
}).strict();
|
|
50
53
|
const ProviderId = ModelProviderParams.shape.provider.describe("The model provider (models.platform-list), e.g. the plugin name of its extension.");
|
|
51
54
|
/** `provider/model` of a purpose target, or null. */
|
|
@@ -204,7 +207,7 @@ let AdminOperations = class AdminOperations {
|
|
|
204
207
|
}),
|
|
205
208
|
defineOperation({
|
|
206
209
|
id: "admin.settings",
|
|
207
|
-
description: "Read the deployment settings (super admin): who may create orgs (orgCreation), the price currency, whether orgs may create their own connectors and skills, whether org admins may browse the marketplaces, the per-org limit overrides keyed by org id (orgs.get reads one org's), the platform's Full permission switch in effect (devicesFullAccess: permission allowed or off; devicesAutoMode is its old name with mode),
|
|
210
|
+
description: "Read the deployment settings (super admin): who may create orgs (orgCreation), the price currency, whether orgs may create their own connectors and skills, whether org admins may browse the marketplaces, the per-org limit overrides keyed by org id (orgs.get reads one org's), the platform's Full permission switch in effect (devicesFullAccess: permission allowed or off; devicesAutoMode is its old name with mode), the platform's attribution defaults for agent-created git commits and pull requests (attribution: commit, pr, sessionUrl), file sharing (externalSharing: value allow or deny, whether orgs may turn on public links to conversation files; shareMaxExpiryDays: value, the longest expiry a share may take in days) and htmlRenderCdnAllowlist (the https origins a rendered HTML file may load libraries, styles, fonts and images from); the switches each with sources: env, file or nacos are set in the startup config and read-only, db chosen in the admin console, default.",
|
|
208
211
|
input: z.object({}).strict(),
|
|
209
212
|
example: {},
|
|
210
213
|
authz: { superAdmin: true },
|
|
@@ -214,7 +217,7 @@ let AdminOperations = class AdminOperations {
|
|
|
214
217
|
}),
|
|
215
218
|
defineOperation({
|
|
216
219
|
id: "admin.update-settings",
|
|
217
|
-
description: "Change deployment settings (super admin); give only the keys to change: orgCreation (anyone or super_admin), priceCurrency (ISO 4217 code), customConnectors / customSkills (allow or deny: whether orgs may create their own instead of installing from the catalog), orgMarketplaceBrowse (true or false), uiTheme ({ id }: the platform default theme, a platform theme whose scope is all, or null for the built-in theme; it is what every org falls back to and what the sign-in pages show), uiArrangement ({ <slot>: { hidden, order } } for a list slot, { <slot>: { use } } for a single slot: the platform default arrangement of UI slots, with contribution keys <extension>/<contribution>; hidden ones are not listed but still open by URL; use names the contribution that replaces the built-in, null for the built-in; null for a slot removes its entry), clientExtensions ({ enabled?, disabled? }: the kill switch of plugin client code; enabled false stops every plugin's interface code in every browser, disabled is the whole list of plugins whose interface code alone is stopped while their tools keep working; read the current list from admin.settings first), devicesFullAccess ({ permission }: the platform's Full permission switch, allowed or off; null clears it back to the default, allowed; through this tool it may only be turned off, never allowed, and a value set in the startup config is read-only; devicesAutoMode ({ mode }) is its old name, never both), attribution ({ commit?, pr?, sessionUrl? }: the platform's defaults for agent-created git commits and pull requests; null clears a field back to its default, an empty string turns that line off, and fields set in the startup config are read-only). Per-org limits are orgs.set-limits.",
|
|
220
|
+
description: "Change deployment settings (super admin); give only the keys to change: orgCreation (anyone or super_admin), priceCurrency (ISO 4217 code), customConnectors / customSkills (allow or deny: whether orgs may create their own instead of installing from the catalog), orgMarketplaceBrowse (true or false), uiTheme ({ id }: the platform default theme, a platform theme whose scope is all, or null for the built-in theme; it is what every org falls back to and what the sign-in pages show), uiArrangement ({ <slot>: { hidden, order } } for a list slot, { <slot>: { use } } for a single slot: the platform default arrangement of UI slots, with contribution keys <extension>/<contribution>; hidden ones are not listed but still open by URL; use names the contribution that replaces the built-in, null for the built-in; null for a slot removes its entry), clientExtensions ({ enabled?, disabled? }: the kill switch of plugin client code; enabled false stops every plugin's interface code in every browser, disabled is the whole list of plugins whose interface code alone is stopped while their tools keep working; read the current list from admin.settings first), devicesFullAccess ({ permission }: the platform's Full permission switch, allowed or off; null clears it back to the default, allowed; through this tool it may only be turned off, never allowed, and a value set in the startup config is read-only; devicesAutoMode ({ mode }) is its old name, never both), attribution ({ commit?, pr?, sessionUrl? }: the platform's defaults for agent-created git commits and pull requests; null clears a field back to its default, an empty string turns that line off, and fields set in the startup config are read-only), externalSharing (allow or deny: whether orgs may turn on public links to conversation files; null clears it back to the default, deny; externalSharing may only be turned off through this tool, and a value set in the startup config is read-only), shareMaxExpiryDays (1 to 365: the longest expiry a share may take, in days; null clears it back to 30; through this tool it may only be lowered, never raised, and it is read-only when set in the startup config), htmlRenderCdnAllowlist (the whole list of https origins, scheme and host with an optional port and nothing else, that a rendered HTML file may load from; at most 50; through this tool origins may only be removed, never added, so read the current list from admin.settings first and send it without the ones to drop). Per-org limits are orgs.set-limits.",
|
|
218
221
|
input: SettingsInput.refine((b) => Object.keys(b).length > 0, {
|
|
219
222
|
message: "at least one setting is required",
|
|
220
223
|
}),
|
|
@@ -239,6 +242,14 @@ let AdminOperations = class AdminOperations {
|
|
|
239
242
|
code: "deployment.auto_mode_not_allowed",
|
|
240
243
|
next: "Through this tool the platform's Full permission switch may only be turned off; to allow it, ask a super admin to change it in the admin console settings on the web.",
|
|
241
244
|
},
|
|
245
|
+
{
|
|
246
|
+
code: "deployment.external_sharing_not_allowed",
|
|
247
|
+
next: "Through this tool external sharing may only be turned off (deny); to allow it, ask a super admin to change it in the admin console settings on the web.",
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
code: "deployment.sharing_widen_not_allowed",
|
|
251
|
+
next: "Through this tool shareMaxExpiryDays may only be lowered and htmlRenderCdnAllowlist may only lose origins (send the current list from admin.settings minus the ones to drop); to raise the maximum or add an origin, ask a super admin to change it in the admin console settings on the web.",
|
|
252
|
+
},
|
|
242
253
|
{
|
|
243
254
|
code: "deployment.setting_readonly",
|
|
244
255
|
next: "That setting is fixed in the deployment's startup config (environment, file or Nacos; admin.settings shows the field's source); it can only be changed there, by the operator.",
|
|
@@ -261,11 +272,15 @@ let AdminOperations = class AdminOperations {
|
|
|
261
272
|
const full = normalizeDeploymentSettingsPatch(i).devicesFullAccess;
|
|
262
273
|
if (full !== undefined)
|
|
263
274
|
await this.settings.checkDevicesFullAccess(full, { onlyNarrows: true });
|
|
275
|
+
await this.settings.checkSharing(i, { onlyNarrows: true });
|
|
264
276
|
});
|
|
265
277
|
},
|
|
266
278
|
summary: async (i) => {
|
|
267
|
-
const { uiTheme, uiArrangement, clientExtensions, devicesFullAccess, devicesAutoMode, attribution, ...rest } = i;
|
|
279
|
+
const { uiTheme, uiArrangement, clientExtensions, devicesFullAccess, devicesAutoMode, attribution, htmlRenderCdnAllowlist, ...rest } = i;
|
|
268
280
|
const parts = Object.entries(rest).map(([k, v]) => `${k}=${String(v)}`);
|
|
281
|
+
if (htmlRenderCdnAllowlist !== undefined) {
|
|
282
|
+
parts.push(`htmlRenderCdnAllowlist=[${htmlRenderCdnAllowlist.join(", ")}]`);
|
|
283
|
+
}
|
|
269
284
|
const full = devicesFullAccess?.permission ?? devicesAutoMode?.mode;
|
|
270
285
|
if (devicesFullAccess !== undefined || devicesAutoMode !== undefined) {
|
|
271
286
|
parts.push(`devicesFullAccess=${String(full)}`);
|
|
@@ -39,7 +39,7 @@ let OrgSettingsOperations = class OrgSettingsOperations {
|
|
|
39
39
|
this.registry.register([
|
|
40
40
|
defineOperation({
|
|
41
41
|
id: "org-settings.get",
|
|
42
|
-
description: "Read this org's settings: toolSearch, locale, sandboxToolPolicy, platformTool (on, read-only or off), fullAccess (allowed or off: whether the org's devices may run with Full permission; absent follows the deployment's switch, and the org may never exceed it; autoMode is its old name, shown with the same value), cloudNetwork (the org's sandbox-mode network stored as a delta over the platform's allowlist: mode open or allowlist for a cloud device in sandbox mode, absent following the platform; base platform or none; extraHosts the org adds; excludedHosts platform hosts it drops; open means any public host, while loopback, private and cloud metadata addresses stay blocked), wakeOnBackgroundTask (absent means it follows the deployment), theme (the org's default theme id, null or absent following the platform, and personal: allowed or locked), uiArrangement (per list slot, the extension contributions the org hides and their order; per single slot, the contribution that replaces the built-in as use, null for the built-in; a slot not listed follows the platform), the deployment's Full switch (fullAccess; autoMode is its old name) and network (its allowlist, orgHosts: extend lets the org go beyond it, within makes it the ceiling, and off for the platform kill switch), effectiveNetwork (the mode and hosts the org's sandbox mode really gets), and the sandbox cpu / memory limits in effect.",
|
|
42
|
+
description: "Read this org's settings: toolSearch, locale, sandboxToolPolicy, platformTool (on, read-only or off), fullAccess (allowed or off: whether the org's devices may run with Full permission; absent follows the deployment's switch, and the org may never exceed it; autoMode is its old name, shown with the same value), cloudNetwork (the org's sandbox-mode network stored as a delta over the platform's allowlist: mode open or allowlist for a cloud device in sandbox mode, absent following the platform; base platform or none; extraHosts the org adds; excludedHosts platform hosts it drops; open means any public host, while loopback, private and cloud metadata addresses stay blocked), wakeOnBackgroundTask (absent means it follows the deployment), theme (the org's default theme id, null or absent following the platform, and personal: allowed or locked), uiArrangement (per list slot, the extension contributions the org hides and their order; per single slot, the contribution that replaces the built-in as use, null for the built-in; a slot not listed follows the platform), the deployment's Full switch (fullAccess; autoMode is its old name) and network (its allowlist, orgHosts: extend lets the org go beyond it, within makes it the ceiling, and off for the platform kill switch), effectiveNetwork (the mode and hosts the org's sandbox mode really gets), externalSharing (on or off, absent meaning off: whether members may share conversation files through public links; the deployment's externalSharing must be allow too) with the deployment's externalSharing and shareMaxExpiryDays, and the sandbox cpu / memory limits in effect.",
|
|
43
43
|
input: z.object({}).strict(),
|
|
44
44
|
example: {},
|
|
45
45
|
authz: { orgAction: "org.read" },
|
|
@@ -57,7 +57,7 @@ let OrgSettingsOperations = class OrgSettingsOperations {
|
|
|
57
57
|
}),
|
|
58
58
|
defineOperation({
|
|
59
59
|
id: "org-settings.update",
|
|
60
|
-
description: "Change this org's settings (org admins). Give only the settings to change; null clears fullAccess, cloudNetwork or wakeOnBackgroundTask so they follow the deployment again (refused when the deployment value is wider than what this tool may set). fullAccess (allowed or off; the platform must allow it; autoMode is its old name, never both) and cloudNetwork ({ mode?, base?: platform | none, extraHosts?, excludedHosts? }, replaced whole, so send the stored fields you keep) may only narrow the org's devices here: allowing Full where the org has it off, switching the cloud network from allowlist to open, adding an extra host, dropping an exclusion or moving base from none to platform is refused and needs a person in the organization settings on the web. theme: { id, personal } sets the org's default theme (a theme id from themes.list, or null to follow the platform) and whether members may pick their own (allowed) or not (locked); null clears it. uiArrangement: { <slot>: { hidden, order } } (a list slot) or { <slot>: { use } } (a single slot: shell.brand, conversation.empty, conversation.composer.frame) replaces that slot's entry, where hidden, order and use name contribution keys <extension>/<contribution> (hidden ones are not listed in the web UI but their pages still open by URL; use null is the built-in); null for a slot makes it follow the platform again; platform.page is refused. Setting platformTool to off or read-only takes effect from the next call and cuts this Platform tool off in the org, so say so before asking; an org admin switches it back on in the web settings.",
|
|
60
|
+
description: "Change this org's settings (org admins). Give only the settings to change; null clears fullAccess, cloudNetwork or wakeOnBackgroundTask so they follow the deployment again (refused when the deployment value is wider than what this tool may set). fullAccess (allowed or off; the platform must allow it; autoMode is its old name, never both) and cloudNetwork ({ mode?, base?: platform | none, extraHosts?, excludedHosts? }, replaced whole, so send the stored fields you keep) may only narrow the org's devices here: allowing Full where the org has it off, switching the cloud network from allowlist to open, adding an extra host, dropping an exclusion or moving base from none to platform is refused and needs a person in the organization settings on the web. theme: { id, personal } sets the org's default theme (a theme id from themes.list, or null to follow the platform) and whether members may pick their own (allowed) or not (locked); null clears it. uiArrangement: { <slot>: { hidden, order } } (a list slot) or { <slot>: { use } } (a single slot: shell.brand, conversation.empty, conversation.composer.frame) replaces that slot's entry, where hidden, order and use name contribution keys <extension>/<contribution> (hidden ones are not listed in the web UI but their pages still open by URL; use null is the built-in); null for a slot makes it follow the platform again; platform.page is refused. externalSharing (on or off; null clears it, off) may only be turned off through this tool: turning it on needs a person in the organization settings on the web, and the platform must allow it. Setting platformTool to off or read-only takes effect from the next call and cuts this Platform tool off in the org, so say so before asking; an org admin switches it back on in the web settings.",
|
|
61
61
|
input: OrgSettingsPatchSchema.refine((i) => Object.values(i).some((v) => v !== undefined), {
|
|
62
62
|
message: "give at least one setting",
|
|
63
63
|
}),
|
|
@@ -74,6 +74,10 @@ let OrgSettingsOperations = class OrgSettingsOperations {
|
|
|
74
74
|
code: "org.auto_mode_not_allowed",
|
|
75
75
|
next: "Through this tool the org's Full permission (fullAccess) may only be turned off, never allowed (the platform may turn it off too; org-settings.get shows both); to allow it, ask an org admin to change it in the organization settings on the web.",
|
|
76
76
|
},
|
|
77
|
+
{
|
|
78
|
+
code: "org.external_sharing_not_allowed",
|
|
79
|
+
next: "Through this tool external sharing may only be turned off; to turn it on, ask an org admin to change it in the organization settings on the web. When the platform denies external sharing (org-settings.get shows deployment.externalSharing), a super admin must allow it first.",
|
|
80
|
+
},
|
|
77
81
|
{
|
|
78
82
|
code: "theme.not_available",
|
|
79
83
|
next: "Pick a theme id that themes.list shows for this org, or null to follow the platform.",
|
|
@@ -184,6 +184,9 @@ let OrgsOperations = class OrgsOperations {
|
|
|
184
184
|
"devicesAutoMode",
|
|
185
185
|
"attribution",
|
|
186
186
|
"compaction",
|
|
187
|
+
"externalSharing",
|
|
188
|
+
"shareMaxExpiryDays",
|
|
189
|
+
"htmlRenderCdnAllowlist",
|
|
187
190
|
],
|
|
188
191
|
extras: ["orgId", "runConcurrency", "sandbox", "subagents"],
|
|
189
192
|
confirm: "platform",
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type OnModuleInit } from "@nestjs/common";
|
|
2
|
+
import { SharesService } from "../../shares/shares.service.js";
|
|
3
|
+
import { PlatformOperations } from "../registry.js";
|
|
4
|
+
/**
|
|
5
|
+
* Share operations of the `Platform` tool (the conversation domain, file sharing spec §10): list
|
|
6
|
+
* shared file links and revoke one. Creating and refreshing a share publish a file outside the
|
|
7
|
+
* conversation and stay with the person on the web (exclusions, `human-only`).
|
|
8
|
+
*/
|
|
9
|
+
export declare class SharesOperations implements OnModuleInit {
|
|
10
|
+
private readonly registry;
|
|
11
|
+
private readonly shares;
|
|
12
|
+
constructor(registry: PlatformOperations, shares: SharesService);
|
|
13
|
+
/** The share's file name for a card, or its id when it is not visible to the actor. */
|
|
14
|
+
private nameOf;
|
|
15
|
+
onModuleInit(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
|
+
};
|
|
10
|
+
import { Inject, Injectable } from "@nestjs/common";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
import { ListSharesQuery, ShareIdParams } from "../../shares/shares.schemas.js";
|
|
13
|
+
import { SharesService } from "../../shares/shares.service.js";
|
|
14
|
+
import { defineOperation } from "../operation.js";
|
|
15
|
+
import { PlatformOperations } from "../registry.js";
|
|
16
|
+
import { viaAgent } from "./errors.js";
|
|
17
|
+
import { Cursor, pageOf, startOf } from "./paging.js";
|
|
18
|
+
import { named } from "./summary.js";
|
|
19
|
+
const PAGE = 50;
|
|
20
|
+
const row = (s) => ({
|
|
21
|
+
id: s.id,
|
|
22
|
+
name: s.name,
|
|
23
|
+
state: s.state,
|
|
24
|
+
...(s.revokeReason !== null && { reason: s.revokeReason }),
|
|
25
|
+
audience: s.audience,
|
|
26
|
+
expiresAt: s.expiresAt,
|
|
27
|
+
createdBy: s.createdBy.displayName,
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Share operations of the `Platform` tool (the conversation domain, file sharing spec §10): list
|
|
31
|
+
* shared file links and revoke one. Creating and refreshing a share publish a file outside the
|
|
32
|
+
* conversation and stay with the person on the web (exclusions, `human-only`).
|
|
33
|
+
*/
|
|
34
|
+
let SharesOperations = class SharesOperations {
|
|
35
|
+
registry;
|
|
36
|
+
shares;
|
|
37
|
+
constructor(registry, shares) {
|
|
38
|
+
this.registry = registry;
|
|
39
|
+
this.shares = shares;
|
|
40
|
+
}
|
|
41
|
+
/** The share's file name for a card, or its id when it is not visible to the actor. */
|
|
42
|
+
async nameOf(orgId, accountId, shareId) {
|
|
43
|
+
for (const scope of ["mine", "all"]) {
|
|
44
|
+
try {
|
|
45
|
+
const found = (await this.shares.list(orgId, accountId, scope)).shares.find((s) => s.id === shareId);
|
|
46
|
+
if (found !== undefined)
|
|
47
|
+
return found.name;
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// `all` is for org admins only: the card falls back to the id
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return shareId;
|
|
54
|
+
}
|
|
55
|
+
onModuleInit() {
|
|
56
|
+
this.registry.register([
|
|
57
|
+
defineOperation({
|
|
58
|
+
id: "conversations.list-shares",
|
|
59
|
+
description: "List shared links to conversation files, newest first: your own (scope mine, the default) or every member's in the org (scope all, org admins only). Each row has the file name, state (live, suspended, expired, revoked), the audience (internal: signed-in members; external: anyone with the link), the expiry and who shared it; revoked and expired links stay listed for 7 days. Pages by 50: pass the returned next as params.cursor.",
|
|
60
|
+
input: z.object({ scope: ListSharesQuery.shape.scope, cursor: Cursor.optional() }).strict(),
|
|
61
|
+
example: { scope: "mine" },
|
|
62
|
+
authz: { orgAction: "agents.use" },
|
|
63
|
+
mirrors: ["GET /api/v1/orgs/:orgId/shares"],
|
|
64
|
+
extras: ["cursor"],
|
|
65
|
+
confirm: "read",
|
|
66
|
+
errors: [
|
|
67
|
+
{
|
|
68
|
+
code: "forbidden",
|
|
69
|
+
next: "Only org admins list every member's shares; list your own with scope mine.",
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
run: async (input, ctx) => pageOf((await this.shares.list(ctx.orgId, ctx.actorAccountId, input.scope)).shares.map(row), startOf(input.cursor), PAGE),
|
|
73
|
+
}),
|
|
74
|
+
defineOperation({
|
|
75
|
+
id: "conversations.revoke-share",
|
|
76
|
+
description: "Revoke a shared link to a conversation file: the link stops working at once and its snapshot is deleted. Takes the share id from conversations.list-shares. Your own shares, or any member's for org admins. Revoking a link already revoked changes nothing. The person confirms every revoke.",
|
|
77
|
+
input: z.object({ shareId: ShareIdParams.shape.shareId }).strict(),
|
|
78
|
+
example: { shareId: "3f2b8a40-6c1d-4e0b-9a77-5d1e2c8b9f10" },
|
|
79
|
+
authz: { orgAction: "agents.use" },
|
|
80
|
+
mirrors: ["DELETE /api/v1/orgs/:orgId/shares/:shareId"],
|
|
81
|
+
confirm: "org",
|
|
82
|
+
errors: [
|
|
83
|
+
{
|
|
84
|
+
code: "share.not_found",
|
|
85
|
+
next: "Check the id with conversations.list-shares: only your own shares, or any member's for org admins, can be revoked.",
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
summary: async (i, ctx) => {
|
|
89
|
+
const n = named(await this.nameOf(ctx.orgId, ctx.actorAccountId, i.shareId));
|
|
90
|
+
return { zh: `撤销文件「${n}」的分享链接`, en: `Revoke the shared link to "${n}"` };
|
|
91
|
+
},
|
|
92
|
+
run: async (input, ctx) => {
|
|
93
|
+
await this.shares.revoke(ctx.orgId, ctx.actorAccountId, input.shareId, {
|
|
94
|
+
auditDetail: viaAgent("conversations.revoke-share", ctx),
|
|
95
|
+
});
|
|
96
|
+
return { revoked: true, shareId: input.shareId };
|
|
97
|
+
},
|
|
98
|
+
}),
|
|
99
|
+
]);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
SharesOperations = __decorate([
|
|
103
|
+
Injectable(),
|
|
104
|
+
__param(0, Inject(PlatformOperations)),
|
|
105
|
+
__param(1, Inject(SharesService))
|
|
106
|
+
], SharesOperations);
|
|
107
|
+
export { SharesOperations };
|
|
@@ -28,6 +28,7 @@ import { PreviewersOperations } from "./ops/previewers.ops.js";
|
|
|
28
28
|
import { RequestsOperations } from "./ops/requests.ops.js";
|
|
29
29
|
import { SchedulesOperations } from "./ops/schedules.ops.js";
|
|
30
30
|
import { SetupOperations } from "./ops/setup.ops.js";
|
|
31
|
+
import { SharesOperations } from "./ops/shares.ops.js";
|
|
31
32
|
import { SkillsOperations } from "./ops/skills.ops.js";
|
|
32
33
|
import { ThemesOperations } from "./ops/themes.ops.js";
|
|
33
34
|
import { UiOperations } from "./ops/ui.ops.js";
|
|
@@ -35,7 +36,7 @@ import { UiOperations } from "./ops/ui.ops.js";
|
|
|
35
36
|
* One provider per domain, each taking `PlatformOperations` as its first constructor argument:
|
|
36
37
|
* the parity test in `tools/checks` builds the operations from it without a Nest app.
|
|
37
38
|
*/
|
|
38
|
-
export declare const PLATFORM_OPERATION_PROVIDERS: readonly [typeof PlatformOperationsProvider, typeof SkillsOperations, typeof AgentsOperations, typeof AgentTemplatesOperations, typeof PluginsOperations, typeof MarketplacesOperations, typeof RequestsOperations, typeof ConnectorsOperations, typeof ExtensionsOperations, typeof ConversationsOperations, typeof ComponentsOperations, typeof AccountsOperations, typeof OrgsOperations, typeof AdminOperations, typeof CatalogAdminOperations, typeof OrgPluginsOperations, typeof ExtensionsAdminOperations, typeof ModelsOperations, typeof InboxOperations, typeof ApprovalsOperations, typeof ChannelsOperations, typeof OrgSettingsOperations, typeof EvalsOperations, typeof BackgroundOperations, typeof PreviewersOperations, typeof DevicesOperations, typeof AgentSkillsOperations, typeof ThemesOperations, typeof SetupOperations, typeof UiOperations, typeof AdminItemsOperations, typeof SchedulesOperations, typeof OutboxOperations];
|
|
39
|
+
export declare const PLATFORM_OPERATION_PROVIDERS: readonly [typeof PlatformOperationsProvider, typeof SkillsOperations, typeof AgentsOperations, typeof AgentTemplatesOperations, typeof PluginsOperations, typeof MarketplacesOperations, typeof RequestsOperations, typeof ConnectorsOperations, typeof ExtensionsOperations, typeof ConversationsOperations, typeof ComponentsOperations, typeof AccountsOperations, typeof OrgsOperations, typeof AdminOperations, typeof CatalogAdminOperations, typeof OrgPluginsOperations, typeof ExtensionsAdminOperations, typeof ModelsOperations, typeof InboxOperations, typeof ApprovalsOperations, typeof ChannelsOperations, typeof OrgSettingsOperations, typeof EvalsOperations, typeof BackgroundOperations, typeof PreviewersOperations, typeof DevicesOperations, typeof AgentSkillsOperations, typeof ThemesOperations, typeof SetupOperations, typeof UiOperations, typeof AdminItemsOperations, typeof SchedulesOperations, typeof OutboxOperations, typeof SharesOperations];
|
|
39
40
|
/**
|
|
40
41
|
* The `Platform` tool's operations (ruling P2): one provider per domain, each registering its
|
|
41
42
|
* operations into `PlatformOperations` from `onModuleInit`. It imports the domain modules, which
|
|
@@ -23,6 +23,7 @@ import { OrgsModule } from "../orgs/orgs.module.js";
|
|
|
23
23
|
import { ProvidersModule } from "../runtime/providers.js";
|
|
24
24
|
import { SchedulesModule } from "../schedules/schedules.module.js";
|
|
25
25
|
import { SetupModule } from "../setup/setup.module.js";
|
|
26
|
+
import { SharesModule } from "../shares/shares.module.js";
|
|
26
27
|
import { SkillsModule } from "../skills/skills.module.js";
|
|
27
28
|
import { ThemesModule } from "../themes/themes.module.js";
|
|
28
29
|
import { ToolsModule } from "../tools/tools.module.js";
|
|
@@ -56,6 +57,7 @@ import { PreviewersOperations } from "./ops/previewers.ops.js";
|
|
|
56
57
|
import { RequestsOperations } from "./ops/requests.ops.js";
|
|
57
58
|
import { SchedulesOperations } from "./ops/schedules.ops.js";
|
|
58
59
|
import { SetupOperations } from "./ops/setup.ops.js";
|
|
60
|
+
import { SharesOperations } from "./ops/shares.ops.js";
|
|
59
61
|
import { SkillsOperations } from "./ops/skills.ops.js";
|
|
60
62
|
import { ThemesOperations } from "./ops/themes.ops.js";
|
|
61
63
|
import { UiOperations } from "./ops/ui.ops.js";
|
|
@@ -110,6 +112,8 @@ export const PLATFORM_OPERATION_PROVIDERS = [
|
|
|
110
112
|
SchedulesOperations,
|
|
111
113
|
// dead outbox rows (transactional outbox spec §3.4)
|
|
112
114
|
OutboxOperations,
|
|
115
|
+
// shared file links (file sharing spec §10)
|
|
116
|
+
SharesOperations,
|
|
113
117
|
];
|
|
114
118
|
/**
|
|
115
119
|
* The `Platform` tool's operations (ruling P2): one provider per domain, each registering its
|
|
@@ -143,6 +147,7 @@ PlatformOpsModule = __decorate([
|
|
|
143
147
|
ThemesModule,
|
|
144
148
|
SetupModule,
|
|
145
149
|
SchedulesModule,
|
|
150
|
+
SharesModule,
|
|
146
151
|
],
|
|
147
152
|
providers: [...PLATFORM_OPERATION_PROVIDERS],
|
|
148
153
|
})
|
|
@@ -28,6 +28,7 @@ import { ORG_ROUTES, ORG_SETTINGS_ROUTES } from "../orgs/orgs.schemas.js";
|
|
|
28
28
|
import { SCHEDULE_ROUTES } from "../schedules/schedules.schemas.js";
|
|
29
29
|
import { SETUP_CHECK_ROUTES } from "../setup/setup-checks.schemas.js";
|
|
30
30
|
import { SETUP_GUIDE_ROUTES } from "../setup/setup-guides.schemas.js";
|
|
31
|
+
import { SHARE_ROUTES } from "../shares/shares.schemas.js";
|
|
31
32
|
import { SKILL_ROUTES } from "../skills/skills.schemas.js";
|
|
32
33
|
import { THEME_ROUTES } from "../themes/themes.schemas.js";
|
|
33
34
|
import { APPROVAL_ROUTES } from "../tools/approvals.schemas.js";
|
|
@@ -91,4 +92,6 @@ export const ROUTE_SCHEMAS = [
|
|
|
91
92
|
...OUTBOX_DEAD_ROUTES,
|
|
92
93
|
// org network allowances (plugin safe fetch spec)
|
|
93
94
|
...ORG_NETWORK_ROUTES,
|
|
95
|
+
// shares of conversation files (file sharing spec §10)
|
|
96
|
+
...SHARE_ROUTES,
|
|
94
97
|
];
|
|
@@ -40,6 +40,8 @@ import { UsageReportModule } from "../runtime/usage-report.js";
|
|
|
40
40
|
import { SandboxSweepJobs } from "../sandbox/jobs.js";
|
|
41
41
|
import { SandboxModule } from "../sandbox/sandbox.module.js";
|
|
42
42
|
import { ScheduledTaskFireModule } from "../schedules/fire.js";
|
|
43
|
+
import { ShareObjectsModule } from "../shares/share-objects.js";
|
|
44
|
+
import { ShareSweepJob } from "../shares/sweep.job.js";
|
|
43
45
|
import { StoragePurgeJob } from "../storage/purge.js";
|
|
44
46
|
import { StorageModule } from "../storage/storage.module.js";
|
|
45
47
|
import { ToolJobs } from "../tools/jobs.js";
|
|
@@ -88,6 +90,8 @@ let WorkerModule = WorkerModule_1 = class WorkerModule {
|
|
|
88
90
|
ChannelsModule,
|
|
89
91
|
// the scheduled task scanner (`@LockedCron`) and the fire job's body
|
|
90
92
|
ScheduledTaskFireModule,
|
|
93
|
+
// the share snapshots the daily share sweep frees
|
|
94
|
+
ShareObjectsModule,
|
|
91
95
|
],
|
|
92
96
|
providers: [
|
|
93
97
|
// the one repair of a run nobody runs (transactional outbox spec §8.3)
|
|
@@ -107,6 +111,8 @@ let WorkerModule = WorkerModule_1 = class WorkerModule {
|
|
|
107
111
|
DirectoryScanJob,
|
|
108
112
|
PluginsReconcileJob,
|
|
109
113
|
GatewayCheckJob,
|
|
114
|
+
// the daily share sweep (file sharing spec §9)
|
|
115
|
+
ShareSweepJob,
|
|
110
116
|
WorkerRole,
|
|
111
117
|
],
|
|
112
118
|
exports: [WorkerRole],
|
|
@@ -9,6 +9,7 @@ import { CloudPermissionSnapshots } from "../sandbox/cloud-permission-snapshot.j
|
|
|
9
9
|
import { SandboxOperationReconcileJob } from "../sandbox/operation-reconcile.job.js";
|
|
10
10
|
import { SandboxService } from "../sandbox/sandbox.service.js";
|
|
11
11
|
import { ScheduledTaskFirer } from "../schedules/fire.js";
|
|
12
|
+
import { ShareObjects } from "../shares/share-objects.js";
|
|
12
13
|
import { DeviceOpResolver } from "../tools/device-op-resolver.js";
|
|
13
14
|
import { ToolDrift } from "../tools/drift.js";
|
|
14
15
|
import { PermissionApprovalJobs } from "../tools/permission-approval-jobs.js";
|
|
@@ -26,7 +27,7 @@ export declare const MAINTENANCE_CONCURRENCY = 5;
|
|
|
26
27
|
* {@link processStopTree} and `deliver-to-parent` → {@link processDeliverToParent} (both in
|
|
27
28
|
* runtime/subagents/tree-jobs.ts, over {@link Waits}), `owned-plugin-cleanup` →
|
|
28
29
|
* {@link OwnedPluginCleanup}, `sched-fire` and `sched-settle` → {@link ScheduledTaskFirer}, `device-op-resolve` →
|
|
29
|
-
* {@link DeviceOpResolver}). The name of a periodic job (a `@LockedCron` / `@LockedInterval` job,
|
|
30
|
+
* {@link DeviceOpResolver}, `share-object-delete` → {@link ShareObjects}). The name of a periodic job (a `@LockedCron` / `@LockedInterval` job,
|
|
30
31
|
* such as `sandbox-suspend-idle`) runs that job's body once ({@link ScheduledRuns.runNow}), as the
|
|
31
32
|
* maintenance handlers did when those jobs were schedulers on this queue: an operator's or a
|
|
32
33
|
* test's one-off run, not a second schedule (decision R23 of the Nest kernel spec). Any other
|
|
@@ -47,8 +48,9 @@ export declare class MaintenanceProcessor extends WorkerHost<Worker> {
|
|
|
47
48
|
private readonly scheduled;
|
|
48
49
|
private readonly log;
|
|
49
50
|
private readonly operations;
|
|
51
|
+
private readonly shareObjects;
|
|
50
52
|
private readonly snapshots?;
|
|
51
|
-
constructor(permissionApprovals: Pick<PermissionApprovalJobs, "recheck">, waits: Pick<Waits, "processTimeout" | "childFinished" | "stopChildren" | "stopDescendantsOfStopped" | "stopTree">, sandbox: Pick<SandboxService, "destroyDevice" | "resetFileSystem">, drift: Pick<ToolDrift, "check">, directory: Pick<DirectorySync, "runSyncJob">, deletion: Pick<RunDeletion, "stopOrg" | "stopTree">, offboarding: Pick<Offboarding, "stopRun">, runs: Pick<RunQueue, "ensureRun">, ownedCleanup: Pick<OwnedPluginCleanup, "run">, scheduledTasks: Pick<ScheduledTaskFirer, "fire" | "settle">, deviceOps: Pick<DeviceOpResolver, "resolve">, scheduled: Pick<ScheduledRuns, "runNow">, log: Pick<KernelLogger, "error" | "warn">, operations: Pick<SandboxOperationReconcileJob, "reconcile" | "revoke">, snapshots?: Pick<CloudPermissionSnapshots, "reconcileDevice"> | undefined);
|
|
53
|
+
constructor(permissionApprovals: Pick<PermissionApprovalJobs, "recheck">, waits: Pick<Waits, "processTimeout" | "childFinished" | "stopChildren" | "stopDescendantsOfStopped" | "stopTree">, sandbox: Pick<SandboxService, "destroyDevice" | "resetFileSystem">, drift: Pick<ToolDrift, "check">, directory: Pick<DirectorySync, "runSyncJob">, deletion: Pick<RunDeletion, "stopOrg" | "stopTree">, offboarding: Pick<Offboarding, "stopRun">, runs: Pick<RunQueue, "ensureRun">, ownedCleanup: Pick<OwnedPluginCleanup, "run">, scheduledTasks: Pick<ScheduledTaskFirer, "fire" | "settle">, deviceOps: Pick<DeviceOpResolver, "resolve">, scheduled: Pick<ScheduledRuns, "runNow">, log: Pick<KernelLogger, "error" | "warn">, operations: Pick<SandboxOperationReconcileJob, "reconcile" | "revoke">, shareObjects: Pick<ShareObjects, "deleteObject">, snapshots?: Pick<CloudPermissionSnapshots, "reconcileDevice"> | undefined);
|
|
52
54
|
process(job: Job, token?: string): Promise<void>;
|
|
53
55
|
/** Starts consuming (worker role, after the extensions loaded; built with `autorun: false`). */
|
|
54
56
|
start(): void;
|
|
@@ -32,6 +32,7 @@ import { SandboxModule } from "../sandbox/sandbox.module.js";
|
|
|
32
32
|
import { SandboxService } from "../sandbox/sandbox.service.js";
|
|
33
33
|
import { ScheduledTaskFireModule, ScheduledTaskFirer } from "../schedules/fire.js";
|
|
34
34
|
import { SCHED_FIRE_JOB, SCHED_SETTLE_JOB, } from "../schedules/job-ids.js";
|
|
35
|
+
import { SHARE_OBJECT_DELETE_JOB, ShareObjects, ShareObjectsModule, } from "../shares/share-objects.js";
|
|
35
36
|
import { DeviceOpResolver } from "../tools/device-op-resolver.js";
|
|
36
37
|
import { ToolDrift } from "../tools/drift.js";
|
|
37
38
|
import { DRIFT_CONNECTOR_JOB } from "../tools/job-ids.js";
|
|
@@ -54,7 +55,7 @@ export const MAINTENANCE_CONCURRENCY = 5;
|
|
|
54
55
|
* {@link processStopTree} and `deliver-to-parent` → {@link processDeliverToParent} (both in
|
|
55
56
|
* runtime/subagents/tree-jobs.ts, over {@link Waits}), `owned-plugin-cleanup` →
|
|
56
57
|
* {@link OwnedPluginCleanup}, `sched-fire` and `sched-settle` → {@link ScheduledTaskFirer}, `device-op-resolve` →
|
|
57
|
-
* {@link DeviceOpResolver}). The name of a periodic job (a `@LockedCron` / `@LockedInterval` job,
|
|
58
|
+
* {@link DeviceOpResolver}, `share-object-delete` → {@link ShareObjects}). The name of a periodic job (a `@LockedCron` / `@LockedInterval` job,
|
|
58
59
|
* such as `sandbox-suspend-idle`) runs that job's body once ({@link ScheduledRuns.runNow}), as the
|
|
59
60
|
* maintenance handlers did when those jobs were schedulers on this queue: an operator's or a
|
|
60
61
|
* test's one-off run, not a second schedule (decision R23 of the Nest kernel spec). Any other
|
|
@@ -75,8 +76,9 @@ let MaintenanceProcessor = class MaintenanceProcessor extends WorkerHost {
|
|
|
75
76
|
scheduled;
|
|
76
77
|
log;
|
|
77
78
|
operations;
|
|
79
|
+
shareObjects;
|
|
78
80
|
snapshots;
|
|
79
|
-
constructor(permissionApprovals, waits, sandbox, drift, directory, deletion, offboarding, runs, ownedCleanup, scheduledTasks, deviceOps, scheduled, log, operations, snapshots) {
|
|
81
|
+
constructor(permissionApprovals, waits, sandbox, drift, directory, deletion, offboarding, runs, ownedCleanup, scheduledTasks, deviceOps, scheduled, log, operations, shareObjects, snapshots) {
|
|
80
82
|
super();
|
|
81
83
|
this.permissionApprovals = permissionApprovals;
|
|
82
84
|
this.waits = waits;
|
|
@@ -92,6 +94,7 @@ let MaintenanceProcessor = class MaintenanceProcessor extends WorkerHost {
|
|
|
92
94
|
this.scheduled = scheduled;
|
|
93
95
|
this.log = log;
|
|
94
96
|
this.operations = operations;
|
|
97
|
+
this.shareObjects = shareObjects;
|
|
95
98
|
this.snapshots = snapshots;
|
|
96
99
|
}
|
|
97
100
|
process(job, token) {
|
|
@@ -184,6 +187,10 @@ let MaintenanceProcessor = class MaintenanceProcessor extends WorkerHost {
|
|
|
184
187
|
case DEVICE_OP_RESOLVE_JOB:
|
|
185
188
|
await this.deviceOps.resolve(job.data);
|
|
186
189
|
return;
|
|
190
|
+
// a share snapshot a refresh or revoke stopped using (file sharing spec §2)
|
|
191
|
+
case SHARE_OBJECT_DELETE_JOB:
|
|
192
|
+
await this.shareObjects.deleteObject(job.data);
|
|
193
|
+
return;
|
|
187
194
|
default:
|
|
188
195
|
if (await this.scheduled.runNow(job.name))
|
|
189
196
|
return;
|
|
@@ -222,8 +229,9 @@ MaintenanceProcessor = __decorate([
|
|
|
222
229
|
__param(11, Inject(ScheduledRuns)),
|
|
223
230
|
__param(12, Inject(KERNEL_LOGGER)),
|
|
224
231
|
__param(13, Inject(SandboxOperationReconcileJob)),
|
|
225
|
-
__param(14,
|
|
226
|
-
__param(
|
|
232
|
+
__param(14, Inject(ShareObjects)),
|
|
233
|
+
__param(15, Optional()),
|
|
234
|
+
__param(15, Inject(CloudPermissionSnapshots))
|
|
227
235
|
], MaintenanceProcessor);
|
|
228
236
|
export { MaintenanceProcessor };
|
|
229
237
|
/**
|
|
@@ -248,6 +256,8 @@ MaintenanceModule = __decorate([
|
|
|
248
256
|
OwnedPluginCleanupModule,
|
|
249
257
|
// the scheduled task fire job and the scanner (worker-only through this module)
|
|
250
258
|
ScheduledTaskFireModule,
|
|
259
|
+
// the share snapshot deletion
|
|
260
|
+
ShareObjectsModule,
|
|
251
261
|
QueueModule.registerQueue(MAINTENANCE_QUEUE_NAME),
|
|
252
262
|
],
|
|
253
263
|
providers: [
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ShareEmbedClaims } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { type ExpressionBuilder } from "kysely";
|
|
3
|
+
import type { KernelDatabase } from "../db/kernel-schema.js";
|
|
4
|
+
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
5
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
6
|
+
import type { KernelLogger } from "../log.js";
|
|
7
|
+
/** A share that may be opened now ({@link ShareLiveness}). */
|
|
8
|
+
export interface LiveShare {
|
|
9
|
+
id: string;
|
|
10
|
+
orgId: string;
|
|
11
|
+
code: string;
|
|
12
|
+
audience: "internal" | "external";
|
|
13
|
+
conversationId: string;
|
|
14
|
+
createdBy: string;
|
|
15
|
+
createdByName: string;
|
|
16
|
+
name: string;
|
|
17
|
+
contentType: string;
|
|
18
|
+
size: number;
|
|
19
|
+
/** The current generation's snapshot, relative to the org's kernel prefix. */
|
|
20
|
+
objectKey: string;
|
|
21
|
+
generation: number;
|
|
22
|
+
expiresAt: Date | null;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Whether its creator could still open the conversation the share was taken from: the conversation
|
|
26
|
+
* predicate of `ConversationAccess.isAccessible` with the share's `created_by` as the viewer, over
|
|
27
|
+
* the conversation of the share's org (so a row can never reach another org's conversation).
|
|
28
|
+
*/
|
|
29
|
+
export declare const creatorStillHasAccess: (eb: ExpressionBuilder<KernelDatabase, "file_shares">) => import("kysely").ExpressionWrapper<KernelDatabase, "file_shares", import("kysely").SqlBool>;
|
|
30
|
+
/**
|
|
31
|
+
* The live check of a share (file sharing spec §1), the one the open routes, the HTML document
|
|
32
|
+
* token and share-scoped embed tokens use: not revoked, not expired, its snapshot not freed, the
|
|
33
|
+
* org not deleted, its creator passes `ConversationAccess.isAccessible`'s predicates (active
|
|
34
|
+
* account, still a member, the conversation and its tree root not deleted, the agent not deleted
|
|
35
|
+
* and still visible to the creator), and for an external share the effective external sharing
|
|
36
|
+
* switch allows it now. One query (plus the platform switch for an external share, read live), no
|
|
37
|
+
* cache: a cause going away (the switch back on) makes a share not expired live again.
|
|
38
|
+
*/
|
|
39
|
+
export declare class ShareLiveness {
|
|
40
|
+
private readonly db;
|
|
41
|
+
private readonly config;
|
|
42
|
+
private readonly log?;
|
|
43
|
+
constructor(db: KernelDb, config: Pick<KernelConfigService, "get" | "fieldSource">, log?: KernelLogger | undefined);
|
|
44
|
+
/** The live share with this code, or null (unknown, revoked, expired or not live). */
|
|
45
|
+
byCode(code: string): Promise<LiveShare | null>;
|
|
46
|
+
/** The live share with this id (and generation, when given), or null. */
|
|
47
|
+
byId(shareId: string, generation?: number): Promise<LiveShare | null>;
|
|
48
|
+
/**
|
|
49
|
+
* Whether a share-scoped embed token (file sharing spec §7) still holds, checked on every use:
|
|
50
|
+
* the share is live at the token's generation, in the token's org, and `plugin` is enabled in
|
|
51
|
+
* that org (`enabled.ts`: its switch, or always on). One query (plus the platform switch for an
|
|
52
|
+
* external share).
|
|
53
|
+
*/
|
|
54
|
+
embedLive(plugin: string, c: ShareEmbedClaims): Promise<boolean>;
|
|
55
|
+
private find;
|
|
56
|
+
}
|
|
57
|
+
/** The one {@link ShareLiveness} (database and config only): the open routes and tokens use it. */
|
|
58
|
+
export declare class ShareLivenessModule {
|
|
59
|
+
}
|