@capybara-hq/kernel 0.1.0-rc.107 → 0.1.0-rc.109
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 +13 -13
- package/dist/automations/acceptance.controller.d.ts +29 -0
- package/dist/automations/acceptance.controller.js +87 -0
- package/dist/automations/automations.module.js +4 -1
- package/dist/automations/automations.schemas.d.ts +46 -0
- package/dist/automations/automations.schemas.js +31 -0
- package/dist/automations/automations.service.js +10 -1
- package/dist/automations/errors.d.ts +5 -0
- package/dist/automations/errors.js +5 -0
- package/dist/automations/events/acceptance.d.ts +205 -0
- package/dist/automations/events/acceptance.js +822 -0
- package/dist/automations/events/deliver.d.ts +39 -0
- package/dist/automations/events/deliver.js +112 -0
- package/dist/automations/events/dispatcher.d.ts +26 -10
- package/dist/automations/events/dispatcher.js +98 -99
- package/dist/automations/events/sweep.job.d.ts +104 -18
- package/dist/automations/events/sweep.job.js +311 -45
- package/dist/automations/events/trigger-events.service.d.ts +31 -2
- package/dist/automations/events/trigger-events.service.js +113 -30
- package/dist/automations/store.d.ts +7 -3
- package/dist/automations/store.js +6 -0
- package/dist/automations/types.d.ts +5 -0
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/config/schema.d.ts +3 -0
- package/dist/config/schema.js +14 -0
- package/dist/ctx/create-ctx.d.ts +24 -4
- package/dist/ctx/create-ctx.js +119 -6
- package/dist/db/kernel-schema.d.ts +89 -1
- package/dist/errors.d.ts +18 -0
- package/dist/errors.js +18 -0
- package/dist/extensions/hooks.d.ts +8 -5
- package/dist/extensions/hooks.js +2 -1
- package/dist/extensions/host.d.ts +12 -2
- package/dist/extensions/host.js +21 -1
- package/dist/extensions/lifecycle-hooks.d.ts +21 -7
- package/dist/extensions/lifecycle-hooks.js +51 -3
- package/dist/extensions/permission-set.d.ts +33 -1
- package/dist/extensions/permission-set.js +28 -1
- package/dist/extensions/permission-view.d.ts +1 -1
- package/dist/extensions/permission-view.js +24 -1
- package/dist/extensions/run-lifecycle-owe.d.ts +67 -0
- package/dist/extensions/run-lifecycle-owe.js +84 -0
- package/dist/http/api.module.js +4 -0
- package/dist/inbox/inbox-item-actions.d.ts +37 -0
- package/dist/inbox/inbox-item-actions.js +69 -0
- package/dist/inbox/inbox-items.controller.d.ts +27 -0
- package/dist/inbox/inbox-items.controller.js +80 -0
- package/dist/inbox/inbox-items.service.d.ts +110 -0
- package/dist/inbox/inbox-items.service.js +324 -0
- package/dist/inbox/inbox.module.d.ts +2 -1
- package/dist/inbox/inbox.module.js +15 -4
- package/dist/inbox/inbox.schemas.d.ts +20 -1
- package/dist/inbox/inbox.schemas.js +16 -1
- package/dist/inbox/inbox.service.d.ts +29 -7
- package/dist/inbox/inbox.service.js +29 -8
- package/dist/inbox/token.d.ts +5 -0
- package/dist/inbox/token.js +5 -0
- package/dist/infra/config/kernel-config.service.js +2 -0
- package/dist/infra/outbox/registry.d.ts +17 -0
- package/dist/infra/outbox/registry.js +15 -0
- package/dist/kernel.module.js +6 -0
- package/dist/orgs/settings.service.d.ts +20 -0
- package/dist/orgs/settings.service.js +4 -0
- package/dist/platform/exclusions.js +15 -0
- package/dist/platform/operation.d.ts +8 -0
- package/dist/platform/ops/automations.ops.d.ts +3 -1
- package/dist/platform/ops/automations.ops.js +45 -3
- package/dist/platform/ops/inbox.ops.d.ts +3 -1
- package/dist/platform/ops/inbox.ops.js +69 -4
- package/dist/platform/ops/platform.ops.js +4 -3
- package/dist/plugin-reads/plugin-reads.service.d.ts +29 -0
- package/dist/plugin-reads/plugin-reads.service.js +210 -0
- package/dist/plugin-reads/token.d.ts +5 -0
- package/dist/plugin-reads/token.js +5 -0
- package/dist/push/jobs.d.ts +5 -0
- package/dist/push/jobs.js +2 -0
- package/dist/push/preferences.service.d.ts +2 -2
- package/dist/push/preferences.service.js +9 -3
- package/dist/push/push-owed.d.ts +2 -0
- package/dist/push/push-owed.js +10 -1
- package/dist/push/push.schemas.d.ts +5 -2
- package/dist/push/push.schemas.js +4 -3
- package/dist/push/recipients.d.ts +2 -0
- package/dist/push/recipients.js +44 -3
- package/dist/push/texts.d.ts +14 -5
- package/dist/push/texts.js +2 -1
- package/dist/push/triggers.d.ts +1 -1
- package/dist/runtime/run-finish.js +19 -1
- package/dist/runtime/run-jobs.d.ts +12 -2
- package/dist/runtime/run-jobs.js +41 -4
- package/dist/runtime/run-queue.js +10 -0
- package/dist/runtime/waits.js +24 -1
- package/dist/tools/builtins/platform.js +2 -0
- package/dist/tools/pipeline.d.ts +5 -0
- package/dist/tools/pipeline.js +13 -1
- package/dist/tools/registry.d.ts +6 -0
- package/package.json +3 -3
- package/src/migrations/0192_inbox_items.sql +50 -0
- package/src/migrations/0193_trigger_cause_handles.sql +49 -0
- package/src/migrations/0194_automation_acceptance.sql +83 -0
|
@@ -184,7 +184,7 @@ export interface PushRegistrationsTable {
|
|
|
184
184
|
/** A person's switch for one push category (migration 0172); an absent row is on. */
|
|
185
185
|
export interface PushPreferencesTable {
|
|
186
186
|
account_id: string;
|
|
187
|
-
category: "waiting" | "replies" | "tasks" | "automations";
|
|
187
|
+
category: "waiting" | "replies" | "tasks" | "automations" | "inbox";
|
|
188
188
|
enabled: boolean;
|
|
189
189
|
updated_at: Ts;
|
|
190
190
|
}
|
|
@@ -1729,6 +1729,90 @@ export interface TriggerEventsTable {
|
|
|
1729
1729
|
created_at: Ts;
|
|
1730
1730
|
}
|
|
1731
1731
|
export type TriggerEventState = "pending" | "dispatched" | "undelivered" | "depth_stopped";
|
|
1732
|
+
/**
|
|
1733
|
+
* 0193: a serializable trigger cause (`ctx.triggers.causeOf`, collaboration spec §4.2): an opaque
|
|
1734
|
+
* id bound to the org, the extension that asked for it and the run of the tool call it was made
|
|
1735
|
+
* from (with the depth and trigger account the run had then), accepted by `emit`
|
|
1736
|
+
* (`cause: { handle }`) until `expires_at`.
|
|
1737
|
+
*/
|
|
1738
|
+
export interface TriggerCauseHandlesTable {
|
|
1739
|
+
id: string;
|
|
1740
|
+
org_id: string;
|
|
1741
|
+
plugin: string;
|
|
1742
|
+
run_id: string;
|
|
1743
|
+
/** The depth an event caused through it gets (the run's at mint time). */
|
|
1744
|
+
depth: number;
|
|
1745
|
+
/** The run's trigger account at mint time. */
|
|
1746
|
+
cause_account_id: NullableText;
|
|
1747
|
+
created_at: Ts;
|
|
1748
|
+
expires_at: Ts;
|
|
1749
|
+
}
|
|
1750
|
+
/** One button of an inbox item as stored (`InboxAction` of the SDK). */
|
|
1751
|
+
export interface StoredInboxAction {
|
|
1752
|
+
id: string;
|
|
1753
|
+
label: {
|
|
1754
|
+
zh: string;
|
|
1755
|
+
en: string;
|
|
1756
|
+
};
|
|
1757
|
+
style?: "primary" | "danger";
|
|
1758
|
+
uiAction: {
|
|
1759
|
+
contribution: string;
|
|
1760
|
+
actionId: string;
|
|
1761
|
+
payload?: unknown;
|
|
1762
|
+
};
|
|
1763
|
+
}
|
|
1764
|
+
export type InboxItemState = "open" | "resolved" | "expired";
|
|
1765
|
+
/** 0192: a personal inbox item (collaboration spec §4.9), for one person in one org. */
|
|
1766
|
+
export interface InboxItemsTable {
|
|
1767
|
+
id: string;
|
|
1768
|
+
org_id: string;
|
|
1769
|
+
account_id: string;
|
|
1770
|
+
source: "kernel" | "plugin";
|
|
1771
|
+
/** The posting extension; null for a kernel item. */
|
|
1772
|
+
plugin: NullableText;
|
|
1773
|
+
kind: string;
|
|
1774
|
+
title: string;
|
|
1775
|
+
body: ColumnType<string, string | undefined, string>;
|
|
1776
|
+
link: NullableText;
|
|
1777
|
+
actions: ColumnType<StoredInboxAction[], string | undefined, string>;
|
|
1778
|
+
dedupe_key: NullableText;
|
|
1779
|
+
state: ColumnType<InboxItemState, InboxItemState | undefined, InboxItemState>;
|
|
1780
|
+
expires_at: Ts;
|
|
1781
|
+
created_at: Ts;
|
|
1782
|
+
resolved_at: TsNullable;
|
|
1783
|
+
/**
|
|
1784
|
+
* Structured facts of a kernel item the web renders in its own copy (a declined offer: who
|
|
1785
|
+
* declined, for which agent, the subject's absolute URL); null for a plugin item.
|
|
1786
|
+
*/
|
|
1787
|
+
detail: ColumnType<Record<string, unknown> | null, string | null | undefined, string | null>;
|
|
1788
|
+
}
|
|
1789
|
+
export type AcceptanceMode = "auto" | "confirm" | "off";
|
|
1790
|
+
/**
|
|
1791
|
+
* 0194: a person's acceptance rule for one trigger source's directed events (collaboration spec
|
|
1792
|
+
* §4.4).
|
|
1793
|
+
*/
|
|
1794
|
+
export interface AutomationAcceptanceTable {
|
|
1795
|
+
org_id: string;
|
|
1796
|
+
account_id: string;
|
|
1797
|
+
source: string;
|
|
1798
|
+
mode: AcceptanceMode;
|
|
1799
|
+
updated_at: Ts;
|
|
1800
|
+
}
|
|
1801
|
+
export type AutomationOfferState = "open" | "accepted" | "declined" | "expired";
|
|
1802
|
+
/** 0194: work offered to a person under a `confirm` rule (collaboration spec §4.4). */
|
|
1803
|
+
export interface AutomationOffersTable {
|
|
1804
|
+
id: string;
|
|
1805
|
+
org_id: string;
|
|
1806
|
+
account_id: string;
|
|
1807
|
+
event_id: string;
|
|
1808
|
+
source: string;
|
|
1809
|
+
agent_id: string;
|
|
1810
|
+
automation_id: NullableText;
|
|
1811
|
+
inbox_item_id: NullableText;
|
|
1812
|
+
state: ColumnType<AutomationOfferState, AutomationOfferState | undefined, AutomationOfferState>;
|
|
1813
|
+
created_at: Ts;
|
|
1814
|
+
decided_at: TsNullable;
|
|
1815
|
+
}
|
|
1732
1816
|
/**
|
|
1733
1817
|
* 0189: an event that reached an automation, and the run that served it (null while it waits:
|
|
1734
1818
|
* events of one subject coalesce, collaboration spec §4.7).
|
|
@@ -1925,6 +2009,10 @@ export interface KernelDatabase {
|
|
|
1925
2009
|
automation_runs: AutomationRunsTable;
|
|
1926
2010
|
automation_grants: AutomationGrantsTable;
|
|
1927
2011
|
trigger_events: TriggerEventsTable;
|
|
2012
|
+
trigger_cause_handles: TriggerCauseHandlesTable;
|
|
2013
|
+
inbox_items: InboxItemsTable;
|
|
2014
|
+
automation_acceptance: AutomationAcceptanceTable;
|
|
2015
|
+
automation_offers: AutomationOffersTable;
|
|
1928
2016
|
automation_event_deliveries: AutomationEventDeliveriesTable;
|
|
1929
2017
|
automation_conversations: AutomationConversationsTable;
|
|
1930
2018
|
file_shares: FileSharesTable;
|
package/dist/errors.d.ts
CHANGED
|
@@ -275,6 +275,13 @@ export declare const ERROR_CODES: {
|
|
|
275
275
|
readonly "catalog.request_not_found": 404;
|
|
276
276
|
/** No open org notice with that id for an admin of the org (inbox). */
|
|
277
277
|
readonly "inbox.notice_not_found": 404;
|
|
278
|
+
/**
|
|
279
|
+
* No open, unexpired personal inbox item of the caller in this org with that id (another
|
|
280
|
+
* person's item, an org admin's included, is not found either).
|
|
281
|
+
*/
|
|
282
|
+
readonly "inbox.item_not_found": 404;
|
|
283
|
+
/** The inbox item has no action with that id. */
|
|
284
|
+
readonly "inbox.action_not_found": 404;
|
|
278
285
|
readonly "catalog.request_decided": 409;
|
|
279
286
|
/** A pending request of the same kind for the same item or entry exists (spec §5.1 rule 5). */
|
|
280
287
|
readonly "catalog.request_pending": 409;
|
|
@@ -627,6 +634,17 @@ export declare const ERROR_CODES: {
|
|
|
627
634
|
readonly "automation.forbidden": 403;
|
|
628
635
|
/** "Run now" and trial runs: an event automation runs only on its events (no run now, no trial). */
|
|
629
636
|
readonly "automation.run_now_unsupported": 409;
|
|
637
|
+
/** An acceptance automation's trigger, agent and target are the kernel's (collaboration §4.4). */
|
|
638
|
+
readonly "automation.acceptance_fixed": 400;
|
|
639
|
+
/** A work offer that is not the caller's, or does not exist. */
|
|
640
|
+
readonly "automation.offer_not_found": 404;
|
|
641
|
+
/** A work offer already accepted, declined or expired. */
|
|
642
|
+
readonly "automation.offer_closed": 409;
|
|
643
|
+
/**
|
|
644
|
+
* A work offer that cannot be accepted now: the source no longer serves the org or shows the
|
|
645
|
+
* item, the agent cannot be used, automations are off, or the acceptance automation is paused.
|
|
646
|
+
*/
|
|
647
|
+
readonly "automation.offer_unavailable": 409;
|
|
630
648
|
readonly "skill.not_found": 404;
|
|
631
649
|
/** The skill's file routes: no such version of the skill, or no such path in that version. */
|
|
632
650
|
readonly "skill.file_not_found": 404;
|
package/dist/errors.js
CHANGED
|
@@ -275,6 +275,13 @@ export const ERROR_CODES = {
|
|
|
275
275
|
"catalog.request_not_found": 404,
|
|
276
276
|
/** No open org notice with that id for an admin of the org (inbox). */
|
|
277
277
|
"inbox.notice_not_found": 404,
|
|
278
|
+
/**
|
|
279
|
+
* No open, unexpired personal inbox item of the caller in this org with that id (another
|
|
280
|
+
* person's item, an org admin's included, is not found either).
|
|
281
|
+
*/
|
|
282
|
+
"inbox.item_not_found": 404,
|
|
283
|
+
/** The inbox item has no action with that id. */
|
|
284
|
+
"inbox.action_not_found": 404,
|
|
278
285
|
"catalog.request_decided": 409,
|
|
279
286
|
/** A pending request of the same kind for the same item or entry exists (spec §5.1 rule 5). */
|
|
280
287
|
"catalog.request_pending": 409,
|
|
@@ -627,6 +634,17 @@ export const ERROR_CODES = {
|
|
|
627
634
|
"automation.forbidden": 403,
|
|
628
635
|
/** "Run now" and trial runs: an event automation runs only on its events (no run now, no trial). */
|
|
629
636
|
"automation.run_now_unsupported": 409,
|
|
637
|
+
/** An acceptance automation's trigger, agent and target are the kernel's (collaboration §4.4). */
|
|
638
|
+
"automation.acceptance_fixed": 400,
|
|
639
|
+
/** A work offer that is not the caller's, or does not exist. */
|
|
640
|
+
"automation.offer_not_found": 404,
|
|
641
|
+
/** A work offer already accepted, declined or expired. */
|
|
642
|
+
"automation.offer_closed": 409,
|
|
643
|
+
/**
|
|
644
|
+
* A work offer that cannot be accepted now: the source no longer serves the org or shows the
|
|
645
|
+
* item, the agent cannot be used, automations are off, or the acceptance automation is paused.
|
|
646
|
+
*/
|
|
647
|
+
"automation.offer_unavailable": 409,
|
|
630
648
|
"skill.not_found": 404,
|
|
631
649
|
/** The skill's file routes: no such version of the skill, or no such path in that version. */
|
|
632
650
|
"skill.file_not_found": 404,
|
|
@@ -70,9 +70,11 @@ export interface HookSource {
|
|
|
70
70
|
export type LifecycleHook = (typeof LIFECYCLE_HOOKS)[number];
|
|
71
71
|
/**
|
|
72
72
|
* Mounts delivered by a queue (at least once, by plugin) instead of {@link HookRegistry.run}:
|
|
73
|
-
* `usage.report` and the lifecycle mounts.
|
|
73
|
+
* `usage.report`, `run.lifecycle` and the lifecycle mounts.
|
|
74
74
|
*/
|
|
75
|
-
export type QueuedHook =
|
|
75
|
+
export type QueuedHook = OrgQueuedHook | LifecycleHook;
|
|
76
|
+
/** Queued mounts called with the plugin's effective config for the payload's org. */
|
|
77
|
+
export type OrgQueuedHook = "usage.report" | "run.lifecycle";
|
|
76
78
|
/** Error text that never throws itself (a hostile `message` getter or `toString`). */
|
|
77
79
|
export declare function errMsg(e: unknown): string;
|
|
78
80
|
/**
|
|
@@ -166,14 +168,15 @@ export declare class HookRegistry {
|
|
|
166
168
|
*/
|
|
167
169
|
private unloadedPolicy;
|
|
168
170
|
/**
|
|
169
|
-
* `usage.report` handlers by plugin name (delivered by the usage queue
|
|
171
|
+
* `usage.report` and `run.lifecycle` handlers by plugin name (delivered by the usage queue and
|
|
172
|
+
* the lifecycle queue, not by {@link run}); each
|
|
170
173
|
* call runs through the instance's `inflight.run` with the plugin's effective config for the
|
|
171
174
|
* payload's organization, and throws {@link HookNeedsConfigError} without calling the handler
|
|
172
175
|
* when that config is not valid (layering spec A §6).
|
|
173
176
|
*/
|
|
174
|
-
handlers(mount:
|
|
177
|
+
handlers<K extends OrgQueuedHook>(mount: K): {
|
|
175
178
|
plugin: string;
|
|
176
|
-
handler: HookHandler<
|
|
179
|
+
handler: HookHandler<K>;
|
|
177
180
|
}[];
|
|
178
181
|
/**
|
|
179
182
|
* Lifecycle handlers by plugin name (delivered by the lifecycle queue, `lifecycle-hooks.ts`, not
|
package/dist/extensions/hooks.js
CHANGED
|
@@ -173,7 +173,8 @@ export class HookRegistry {
|
|
|
173
173
|
.sort();
|
|
174
174
|
}
|
|
175
175
|
/**
|
|
176
|
-
* `usage.report` handlers by plugin name (delivered by the usage queue
|
|
176
|
+
* `usage.report` and `run.lifecycle` handlers by plugin name (delivered by the usage queue and
|
|
177
|
+
* the lifecycle queue, not by {@link run}); each
|
|
177
178
|
* call runs through the instance's `inflight.run` with the plugin's effective config for the
|
|
178
179
|
* payload's organization, and throws {@link HookNeedsConfigError} without calling the handler
|
|
179
180
|
* when that config is not valid (layering spec A §6).
|
|
@@ -4,12 +4,13 @@ import type { core } from "zod";
|
|
|
4
4
|
import type { KernelAppOptions } from "../app.js";
|
|
5
5
|
import { TRIGGER_EVENTS_BACKEND } from "../automations/events/token.js";
|
|
6
6
|
import type { BusSubscriber } from "../ctx/bus.js";
|
|
7
|
-
import { type DeviceAccessBackend, type Route, type TriggersBackend } from "../ctx/create-ctx.js";
|
|
7
|
+
import { type DeviceAccessBackend, type InboxBackend, type PluginReadsBackend, type Route, type TriggersBackend } from "../ctx/create-ctx.js";
|
|
8
8
|
import { type ExtensionNetSeams } from "../ctx/net.js";
|
|
9
9
|
import type { Keyring } from "../ctx/secrets.js";
|
|
10
10
|
import { DEVICE_ACCESS_BACKEND } from "../device-access/token.js";
|
|
11
11
|
import { DialInAccess } from "../dial-in/access.js";
|
|
12
12
|
import type { PluginRouteTable } from "../http/plugin-dispatch.js";
|
|
13
|
+
import { INBOX_ITEMS_BACKEND } from "../inbox/token.js";
|
|
13
14
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
14
15
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
15
16
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
@@ -17,6 +18,7 @@ import type { KernelLogger } from "../log.js";
|
|
|
17
18
|
import { ModelEmbeddings } from "../models/embeddings.js";
|
|
18
19
|
import { ModelImages } from "../models/images.js";
|
|
19
20
|
import { OrgNetworkAllowances } from "../orgs/network-allowances.service.js";
|
|
21
|
+
import { PLUGIN_READS_BACKEND } from "../plugin-reads/token.js";
|
|
20
22
|
import { DeviceReports } from "../sandbox/device-reports.js";
|
|
21
23
|
import { ShareLiveness } from "../shares/liveness.js";
|
|
22
24
|
import { EmbedTokens } from "../ui/embed-token.js";
|
|
@@ -291,7 +293,9 @@ export declare class ExtensionHost {
|
|
|
291
293
|
* of use: its module imports the sandbox, devices and tools modules, which import this one (a
|
|
292
294
|
* module cycle otherwise).
|
|
293
295
|
* Absent (a hand-built host) or not found (the CLI): `ctx.deviceAccess` calls are refused.
|
|
294
|
-
* `TriggerEventsService` (`ctx.triggers`, {@link TRIGGER_EVENTS_BACKEND})
|
|
296
|
+
* `TriggerEventsService` (`ctx.triggers`, {@link TRIGGER_EVENTS_BACKEND}) and
|
|
297
|
+
* `InboxItemsService` (`ctx.inbox`, {@link INBOX_ITEMS_BACKEND}) and `PluginReadsService`
|
|
298
|
+
* (`ctx.agents`, `ctx.conversations`, `ctx.people`, {@link PLUGIN_READS_BACKEND}) likewise.
|
|
295
299
|
*/
|
|
296
300
|
modules?: {
|
|
297
301
|
get(token: typeof DEVICE_ACCESS_BACKEND, opts: {
|
|
@@ -300,6 +304,12 @@ export declare class ExtensionHost {
|
|
|
300
304
|
get(token: typeof TRIGGER_EVENTS_BACKEND, opts: {
|
|
301
305
|
strict: false;
|
|
302
306
|
}): TriggersBackend;
|
|
307
|
+
get(token: typeof INBOX_ITEMS_BACKEND, opts: {
|
|
308
|
+
strict: false;
|
|
309
|
+
}): InboxBackend;
|
|
310
|
+
get(token: typeof PLUGIN_READS_BACKEND, opts: {
|
|
311
|
+
strict: false;
|
|
312
|
+
}): PluginReadsBackend;
|
|
303
313
|
},
|
|
304
314
|
/** Tests only: `ctx.net`'s DNS and dispatcher seams (`EXTENSION_NET_SEAMS`). */
|
|
305
315
|
netSeams?: ExtensionNetSeams);
|
package/dist/extensions/host.js
CHANGED
|
@@ -23,6 +23,7 @@ import { migrate } from "../db/migrator.js";
|
|
|
23
23
|
import { createDb } from "../db/pool.js";
|
|
24
24
|
import { DEVICE_ACCESS_BACKEND } from "../device-access/token.js";
|
|
25
25
|
import { DialInAccess } from "../dial-in/access.js";
|
|
26
|
+
import { INBOX_ITEMS_BACKEND } from "../inbox/token.js";
|
|
26
27
|
import { waitWithin } from "../infra/close-within.js";
|
|
27
28
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
28
29
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
@@ -33,6 +34,7 @@ import { ModelEmbeddings } from "../models/embeddings.js";
|
|
|
33
34
|
import { ModelImages } from "../models/images.js";
|
|
34
35
|
import { OrgNetworkAllowances } from "../orgs/network-allowances.service.js";
|
|
35
36
|
import { packagePath } from "../packages/tgz.js";
|
|
37
|
+
import { PLUGIN_READS_BACKEND } from "../plugin-reads/token.js";
|
|
36
38
|
import { DeviceReports } from "../sandbox/device-reports.js";
|
|
37
39
|
import { ShareLiveness } from "../shares/liveness.js";
|
|
38
40
|
import { EmbedTokens } from "../ui/embed-token.js";
|
|
@@ -435,7 +437,9 @@ let ExtensionHost = class ExtensionHost {
|
|
|
435
437
|
* of use: its module imports the sandbox, devices and tools modules, which import this one (a
|
|
436
438
|
* module cycle otherwise).
|
|
437
439
|
* Absent (a hand-built host) or not found (the CLI): `ctx.deviceAccess` calls are refused.
|
|
438
|
-
* `TriggerEventsService` (`ctx.triggers`, {@link TRIGGER_EVENTS_BACKEND})
|
|
440
|
+
* `TriggerEventsService` (`ctx.triggers`, {@link TRIGGER_EVENTS_BACKEND}) and
|
|
441
|
+
* `InboxItemsService` (`ctx.inbox`, {@link INBOX_ITEMS_BACKEND}) and `PluginReadsService`
|
|
442
|
+
* (`ctx.agents`, `ctx.conversations`, `ctx.people`, {@link PLUGIN_READS_BACKEND}) likewise.
|
|
439
443
|
*/
|
|
440
444
|
modules,
|
|
441
445
|
/** Tests only: `ctx.net`'s DNS and dispatcher seams (`EXTENSION_NET_SEAMS`). */
|
|
@@ -490,6 +494,22 @@ let ExtensionHost = class ExtensionHost {
|
|
|
490
494
|
return undefined;
|
|
491
495
|
}
|
|
492
496
|
},
|
|
497
|
+
inbox: () => {
|
|
498
|
+
try {
|
|
499
|
+
return modules?.get(INBOX_ITEMS_BACKEND, { strict: false });
|
|
500
|
+
}
|
|
501
|
+
catch {
|
|
502
|
+
return undefined;
|
|
503
|
+
}
|
|
504
|
+
},
|
|
505
|
+
pluginReads: () => {
|
|
506
|
+
try {
|
|
507
|
+
return modules?.get(PLUGIN_READS_BACKEND, { strict: false });
|
|
508
|
+
}
|
|
509
|
+
catch {
|
|
510
|
+
return undefined;
|
|
511
|
+
}
|
|
512
|
+
},
|
|
493
513
|
locks,
|
|
494
514
|
runWorkers: c.roles.includes("worker"),
|
|
495
515
|
log,
|
|
@@ -8,8 +8,8 @@ import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
|
8
8
|
import type { KernelLogger } from "../log.js";
|
|
9
9
|
import { type LifecycleHook } from "./hooks.js";
|
|
10
10
|
import { ExtensionHost } from "./host.js";
|
|
11
|
-
|
|
12
|
-
export
|
|
11
|
+
import { LIFECYCLE_QUEUE, type RUN_LIFECYCLE_JOB, type RunLifecycleJob } from "./run-lifecycle-owe.js";
|
|
12
|
+
export { LIFECYCLE_QUEUE };
|
|
13
13
|
/** The job name of every delivery (registered in `infra/outbox/registry.ts`). */
|
|
14
14
|
export declare const LIFECYCLE_JOB = "lifecycle";
|
|
15
15
|
/** One handler call's time limit. */
|
|
@@ -20,6 +20,13 @@ export interface LifecycleJob<K extends LifecycleHook = LifecycleHook> {
|
|
|
20
20
|
plugin: string;
|
|
21
21
|
payload: HookPayloads[K];
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* The job name of a `run.lifecycle` delivery, owed by `run-lifecycle-owe.ts` (which the runtime
|
|
25
|
+
* imports without this module's Nest graph); typed against that constant so the two cannot drift.
|
|
26
|
+
*/
|
|
27
|
+
export declare const RUN_LIFECYCLE_JOB_NAME: typeof RUN_LIFECYCLE_JOB;
|
|
28
|
+
/** Every job of {@link LIFECYCLE_QUEUE}: a deletion notice or a `run.lifecycle` delivery. */
|
|
29
|
+
export type LifecycleQueueJob = LifecycleJob | RunLifecycleJob;
|
|
23
30
|
/**
|
|
24
31
|
* The deterministic job id of one delivery: the mount, the plugin and the payload's ids (no `:`;
|
|
25
32
|
* kernel ids and plugin names carry none). Removing the same member, agent or org again while the
|
|
@@ -67,28 +74,35 @@ export declare class LifecycleHooks {
|
|
|
67
74
|
*/
|
|
68
75
|
recordIn<K extends LifecycleHook>(mount: K, payload: HookPayloads[K]): Promise<string[]>;
|
|
69
76
|
/** One delivery job (the consumer {@link LifecycleHooksProcessor} calls it). */
|
|
70
|
-
process(data:
|
|
77
|
+
process(data: LifecycleQueueJob, stop: AbortSignal): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* One `run.lifecycle` delivery: the plugin's handlers run with its effective config for the
|
|
80
|
+
* payload's org; an org that switched the plugin off since the notice was owed, an org whose
|
|
81
|
+
* config is not valid, or a plugin that registered no handler, is dropped with a log line (the
|
|
82
|
+
* notice is display state, never worth retrying forever).
|
|
83
|
+
*/
|
|
84
|
+
private processRunLifecycle;
|
|
71
85
|
/** One handler call, aborted after {@link LIFECYCLE_HOOK_TIMEOUT_MS} or when the replica stops. */
|
|
72
86
|
private call;
|
|
73
87
|
/** A job failed (the worker's `failed` event): a retry warns, the last attempt logs an error. */
|
|
74
|
-
onFailed(j: Job<
|
|
88
|
+
onFailed(j: Job<LifecycleQueueJob> | undefined, err: Error): void;
|
|
75
89
|
}
|
|
76
90
|
/**
|
|
77
91
|
* The consumer of {@link LIFECYCLE_QUEUE}: {@link LifecycleHooks.process}. Worker role only
|
|
78
92
|
* (`LifecycleHookWorkersModule`); built with `autorun: false`, started by the worker role after the
|
|
79
93
|
* extensions loaded.
|
|
80
94
|
*/
|
|
81
|
-
export declare class LifecycleHooksProcessor extends WorkerHost<Worker<
|
|
95
|
+
export declare class LifecycleHooksProcessor extends WorkerHost<Worker<LifecycleQueueJob>> {
|
|
82
96
|
private readonly hooks;
|
|
83
97
|
private readonly log;
|
|
84
98
|
private readonly stopping;
|
|
85
99
|
constructor(hooks: LifecycleHooks, log: Pick<KernelLogger, "error">);
|
|
86
|
-
process(job: Job<
|
|
100
|
+
process(job: Job<LifecycleQueueJob>): Promise<void>;
|
|
87
101
|
/** Starts consuming (worker role, after the extensions loaded). */
|
|
88
102
|
start(): void;
|
|
89
103
|
/** Aborts the calls in flight and closes the worker. */
|
|
90
104
|
close(): Promise<void>;
|
|
91
|
-
failed(job: Job<
|
|
105
|
+
failed(job: Job<LifecycleQueueJob> | undefined, err: Error): void;
|
|
92
106
|
error(err: Error): void;
|
|
93
107
|
}
|
|
94
108
|
/** Lifecycle hook delivery: owing the jobs, and the queue the outbox adds them to, on every role. */
|
|
@@ -18,17 +18,23 @@ import { QueueModule } from "../infra/queue/queue.module.js";
|
|
|
18
18
|
import { runJob } from "../infra/queue/run-job.js";
|
|
19
19
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
20
20
|
import { deployedSnapshot } from "./deployed-snapshots.js";
|
|
21
|
+
import { isExtensionEnabled } from "./enabled.js";
|
|
21
22
|
import { ExtensionsModule } from "./extensions.module.js";
|
|
22
|
-
import { deepFreeze, errMsg } from "./hooks.js";
|
|
23
|
+
import { deepFreeze, errMsg, HookNeedsConfigError } from "./hooks.js";
|
|
23
24
|
import { ExtensionHost } from "./host.js";
|
|
24
|
-
|
|
25
|
-
export
|
|
25
|
+
import { LIFECYCLE_QUEUE, } from "./run-lifecycle-owe.js";
|
|
26
|
+
export { LIFECYCLE_QUEUE };
|
|
26
27
|
/** The job name of every delivery (registered in `infra/outbox/registry.ts`). */
|
|
27
28
|
export const LIFECYCLE_JOB = "lifecycle";
|
|
28
29
|
/** One handler call's time limit. */
|
|
29
30
|
export const LIFECYCLE_HOOK_TIMEOUT_MS = 5000;
|
|
30
31
|
/** Concurrent deliveries per worker replica. */
|
|
31
32
|
const LIFECYCLE_CONCURRENCY = 4;
|
|
33
|
+
/**
|
|
34
|
+
* The job name of a `run.lifecycle` delivery, owed by `run-lifecycle-owe.ts` (which the runtime
|
|
35
|
+
* imports without this module's Nest graph); typed against that constant so the two cannot drift.
|
|
36
|
+
*/
|
|
37
|
+
export const RUN_LIFECYCLE_JOB_NAME = "hook-run-lifecycle";
|
|
32
38
|
/**
|
|
33
39
|
* The deterministic job id of one delivery: the mount, the plugin and the payload's ids (no `:`;
|
|
34
40
|
* kernel ids and plugin names carry none). Removing the same member, agent or org again while the
|
|
@@ -109,6 +115,8 @@ let LifecycleHooks = class LifecycleHooks {
|
|
|
109
115
|
}
|
|
110
116
|
/** One delivery job (the consumer {@link LifecycleHooksProcessor} calls it). */
|
|
111
117
|
async process(data, stop) {
|
|
118
|
+
if (data.mount === "run.lifecycle")
|
|
119
|
+
return this.processRunLifecycle(data, stop);
|
|
112
120
|
const fields = { mount: data.mount, plugin: data.plugin };
|
|
113
121
|
const handlers = this.host.hooks
|
|
114
122
|
.lifecycleHandlers(data.mount)
|
|
@@ -126,6 +134,46 @@ let LifecycleHooks = class LifecycleHooks {
|
|
|
126
134
|
for (const h of handlers)
|
|
127
135
|
await this.call(h, payload, stop);
|
|
128
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* One `run.lifecycle` delivery: the plugin's handlers run with its effective config for the
|
|
139
|
+
* payload's org; an org that switched the plugin off since the notice was owed, an org whose
|
|
140
|
+
* config is not valid, or a plugin that registered no handler, is dropped with a log line (the
|
|
141
|
+
* notice is display state, never worth retrying forever).
|
|
142
|
+
*/
|
|
143
|
+
async processRunLifecycle(data, stop) {
|
|
144
|
+
const fields = { mount: data.mount, plugin: data.plugin };
|
|
145
|
+
if (!(await isExtensionEnabled(this.kdb.db, data.payload.orgId, data.plugin))) {
|
|
146
|
+
this.log.info("run.lifecycle delivery dropped: the plugin is not enabled in the org", {
|
|
147
|
+
...fields,
|
|
148
|
+
orgId: data.payload.orgId,
|
|
149
|
+
});
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const handlers = this.host.hooks
|
|
153
|
+
.handlers("run.lifecycle")
|
|
154
|
+
.filter((h) => h.plugin === data.plugin)
|
|
155
|
+
.map((h) => h.handler);
|
|
156
|
+
if (handlers.length === 0) {
|
|
157
|
+
if (this.host.current(data.plugin) === undefined) {
|
|
158
|
+
throw new Error(`plugin ${data.plugin} is not loaded on this replica`);
|
|
159
|
+
}
|
|
160
|
+
this.log.warn("run.lifecycle delivery dropped: the plugin registered no handler", fields);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const payload = deepFreeze(structuredClone(data.payload));
|
|
164
|
+
try {
|
|
165
|
+
for (const h of handlers)
|
|
166
|
+
await this.call(h, payload, stop);
|
|
167
|
+
}
|
|
168
|
+
catch (err) {
|
|
169
|
+
if (!(err instanceof HookNeedsConfigError))
|
|
170
|
+
throw err;
|
|
171
|
+
this.log.warn("run.lifecycle delivery dropped: the org's config of the plugin is invalid", {
|
|
172
|
+
...fields,
|
|
173
|
+
orgId: data.payload.orgId,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
129
177
|
/** One handler call, aborted after {@link LIFECYCLE_HOOK_TIMEOUT_MS} or when the replica stops. */
|
|
130
178
|
async call(h, payload, stop) {
|
|
131
179
|
const ac = new AbortController();
|
|
@@ -86,6 +86,24 @@ export interface PermissionSet {
|
|
|
86
86
|
triggers?: {
|
|
87
87
|
emit: string[];
|
|
88
88
|
};
|
|
89
|
+
/**
|
|
90
|
+
* Personal inbox items (`permissions.inbox`, collaboration spec §4.9): one blocking key. Absent
|
|
91
|
+
* when not declared.
|
|
92
|
+
*/
|
|
93
|
+
inbox?: true;
|
|
94
|
+
/**
|
|
95
|
+
* Read-only org facts (`permissions.agents`, `permissions.conversations`,
|
|
96
|
+
* `permissions.people`): one blocking key each. Absent when not declared.
|
|
97
|
+
*/
|
|
98
|
+
agents?: {
|
|
99
|
+
read: true;
|
|
100
|
+
};
|
|
101
|
+
conversations?: {
|
|
102
|
+
subjects: true;
|
|
103
|
+
};
|
|
104
|
+
people?: {
|
|
105
|
+
read: true;
|
|
106
|
+
};
|
|
89
107
|
};
|
|
90
108
|
/**
|
|
91
109
|
* 安装记录包迁移警告的摘要(`warningsDigest`,Ruling P4);没有警告或不是安装记录时省略。
|
|
@@ -134,7 +152,7 @@ export declare function buildPermissionSet(input: {
|
|
|
134
152
|
* `permissions.http.<access>:<METHOD> <path>` (`permissions.http.public:POST /events`),
|
|
135
153
|
* `ui.view:tasks`, `ui.embed:board`, `permissions.client`, `ui.component:hud`,
|
|
136
154
|
* `permissions.dialin:capybara-device/6`, `permissions.deviceaccess:browser`,
|
|
137
|
-
* `permissions.triggers:item.created`.
|
|
155
|
+
* `permissions.triggers:item.created`, `permissions.inbox`.
|
|
138
156
|
* Tolerates old snapshots missing fields (read as empty), so format changes never throw.
|
|
139
157
|
*/
|
|
140
158
|
export declare function permissionKeys(set: PermissionSet): string[];
|
|
@@ -166,6 +184,20 @@ export declare const DEVICE_ACCESS_KEY_PREFIX = "permissions.deviceaccess:";
|
|
|
166
184
|
* (`PERMISSION_KEY_RE`).
|
|
167
185
|
*/
|
|
168
186
|
export declare const TRIGGERS_KEY_PREFIX = "permissions.triggers:";
|
|
187
|
+
/**
|
|
188
|
+
* Permission key of personal inbox items (`permissions.inbox`): blocking, not sensitive (an item
|
|
189
|
+
* reaches only members of orgs that enabled the extension, links only to its own pages, and its
|
|
190
|
+
* buttons call its UI actions as the person who clicks).
|
|
191
|
+
*/
|
|
192
|
+
export declare const INBOX_KEY = "permissions.inbox";
|
|
193
|
+
/**
|
|
194
|
+
* Permission keys of the read-only org facts: blocking, not sensitive (`ctx.agents` lists the
|
|
195
|
+
* agents a member may use, `ctx.conversations` the metadata of the extension's own subjects'
|
|
196
|
+
* conversations, `ctx.people` the members' names and avatars: no content, no email).
|
|
197
|
+
*/
|
|
198
|
+
export declare const AGENTS_KEY = "permissions.agents";
|
|
199
|
+
export declare const CONVERSATIONS_KEY = "permissions.conversations";
|
|
200
|
+
export declare const PEOPLE_KEY = "permissions.people";
|
|
169
201
|
/** Key prefix of a client component (`ui.component:<id>`): sensitive and blocking. */
|
|
170
202
|
export declare const UI_COMPONENT_KEY_PREFIX = "ui.component:";
|
|
171
203
|
/** 渲染 schema 视图的权限键前缀:记入快照但不卡加载(见 {@link blockingKeys})。 */
|
|
@@ -123,6 +123,11 @@ export function buildPermissionSet(input) {
|
|
|
123
123
|
: {}),
|
|
124
124
|
// only when declared, likewise
|
|
125
125
|
...(p.triggers ? { triggers: { emit: sortedUnique(p.triggers.emit) } } : {}),
|
|
126
|
+
// only when declared, likewise
|
|
127
|
+
...(p.inbox === true ? { inbox: true } : {}),
|
|
128
|
+
...(p.agents?.read === true ? { agents: { read: true } } : {}),
|
|
129
|
+
...(p.conversations?.subjects === true ? { conversations: { subjects: true } } : {}),
|
|
130
|
+
...(p.people?.read === true ? { people: { read: true } } : {}),
|
|
126
131
|
},
|
|
127
132
|
...(input.warningsDigest ? { warningsDigest: input.warningsDigest } : {}),
|
|
128
133
|
};
|
|
@@ -133,7 +138,7 @@ export function buildPermissionSet(input) {
|
|
|
133
138
|
* `permissions.http.<access>:<METHOD> <path>` (`permissions.http.public:POST /events`),
|
|
134
139
|
* `ui.view:tasks`, `ui.embed:board`, `permissions.client`, `ui.component:hud`,
|
|
135
140
|
* `permissions.dialin:capybara-device/6`, `permissions.deviceaccess:browser`,
|
|
136
|
-
* `permissions.triggers:item.created`.
|
|
141
|
+
* `permissions.triggers:item.created`, `permissions.inbox`.
|
|
137
142
|
* Tolerates old snapshots missing fields (read as empty), so format changes never throw.
|
|
138
143
|
*/
|
|
139
144
|
export function permissionKeys(set) {
|
|
@@ -186,6 +191,14 @@ export function permissionKeys(set) {
|
|
|
186
191
|
keys.push(`${DEVICE_ACCESS_KEY_PREFIX}${svc}`);
|
|
187
192
|
for (const t of p.triggers?.emit ?? [])
|
|
188
193
|
keys.push(`${TRIGGERS_KEY_PREFIX}${t}`);
|
|
194
|
+
if (p.inbox === true)
|
|
195
|
+
keys.push(INBOX_KEY);
|
|
196
|
+
if (p.agents?.read === true)
|
|
197
|
+
keys.push(AGENTS_KEY);
|
|
198
|
+
if (p.conversations?.subjects === true)
|
|
199
|
+
keys.push(CONVERSATIONS_KEY);
|
|
200
|
+
if (p.people?.read === true)
|
|
201
|
+
keys.push(PEOPLE_KEY);
|
|
189
202
|
if (s.warningsDigest)
|
|
190
203
|
keys.push(`${WARNINGS_KEY_PREFIX}${s.warningsDigest}`);
|
|
191
204
|
return sortedUnique(keys);
|
|
@@ -218,6 +231,20 @@ export const DEVICE_ACCESS_KEY_PREFIX = "permissions.deviceaccess:";
|
|
|
218
231
|
* (`PERMISSION_KEY_RE`).
|
|
219
232
|
*/
|
|
220
233
|
export const TRIGGERS_KEY_PREFIX = "permissions.triggers:";
|
|
234
|
+
/**
|
|
235
|
+
* Permission key of personal inbox items (`permissions.inbox`): blocking, not sensitive (an item
|
|
236
|
+
* reaches only members of orgs that enabled the extension, links only to its own pages, and its
|
|
237
|
+
* buttons call its UI actions as the person who clicks).
|
|
238
|
+
*/
|
|
239
|
+
export const INBOX_KEY = "permissions.inbox";
|
|
240
|
+
/**
|
|
241
|
+
* Permission keys of the read-only org facts: blocking, not sensitive (`ctx.agents` lists the
|
|
242
|
+
* agents a member may use, `ctx.conversations` the metadata of the extension's own subjects'
|
|
243
|
+
* conversations, `ctx.people` the members' names and avatars: no content, no email).
|
|
244
|
+
*/
|
|
245
|
+
export const AGENTS_KEY = "permissions.agents";
|
|
246
|
+
export const CONVERSATIONS_KEY = "permissions.conversations";
|
|
247
|
+
export const PEOPLE_KEY = "permissions.people";
|
|
221
248
|
/** Key prefix of a client component (`ui.component:<id>`): sensitive and blocking. */
|
|
222
249
|
export const UI_COMPONENT_KEY_PREFIX = "ui.component:";
|
|
223
250
|
/** 渲染 schema 视图的权限键前缀:记入快照但不卡加载(见 {@link blockingKeys})。 */
|
|
@@ -13,7 +13,7 @@ import type { ExtensionSource } from "./sources.js";
|
|
|
13
13
|
export declare function reviewHash(set: PermissionSet, warnings?: readonly PackageWarning[]): string;
|
|
14
14
|
/** 权限清单展示用的一组:按类别分组,`sensitive` 标出需要管理员特别留意的类别。 */
|
|
15
15
|
export interface PermissionGroup {
|
|
16
|
-
category: "provides" | "requires" | "optional" | "config" | "tables" | "secrets" | "storage" | "http" | "publicRoutes" | "embedRoutes" | "tools" | "hooks" | "models" | "network" | "ui" | "components" | "client" | "dialIn" | "deviceAccess" | "triggers";
|
|
16
|
+
category: "provides" | "requires" | "optional" | "config" | "tables" | "secrets" | "storage" | "http" | "publicRoutes" | "embedRoutes" | "tools" | "hooks" | "models" | "network" | "ui" | "components" | "client" | "dialIn" | "deviceAccess" | "triggers" | "inbox" | "agents" | "conversations" | "people";
|
|
17
17
|
/**
|
|
18
18
|
* Sensitive category: secrets, public routes, tools, hooks, client components, client code,
|
|
19
19
|
* device services; also
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { pluginSchemaName } from "../ctx/create-ctx.js";
|
|
3
3
|
import { isDestructiveSql, splitSqlStatements } from "../db/sql-statements.js";
|
|
4
|
-
import { CLIENT_KEY, DEVICE_ACCESS_KEY_PREFIX, DIAL_IN_KEY_PREFIX, permissionKeys, TRIGGERS_KEY_PREFIX, UI_COMPONENT_KEY_PREFIX, WARNINGS_KEY_PREFIX, } from "./permission-set.js";
|
|
4
|
+
import { AGENTS_KEY, CLIENT_KEY, CONVERSATIONS_KEY, DEVICE_ACCESS_KEY_PREFIX, DIAL_IN_KEY_PREFIX, INBOX_KEY, PEOPLE_KEY, permissionKeys, TRIGGERS_KEY_PREFIX, UI_COMPONENT_KEY_PREFIX, WARNINGS_KEY_PREFIX, } from "./permission-set.js";
|
|
5
5
|
/**
|
|
6
6
|
* Review digest: the first 16 hex digits of `sha256(permissionKeys(set).join("\n"))`; with migration
|
|
7
7
|
* warnings their digest (kind, file, line and statement) is folded in, without warnings it equals the
|
|
@@ -40,6 +40,12 @@ export const SENSITIVE_EXTENSION_POINTS = [
|
|
|
40
40
|
];
|
|
41
41
|
/** The one item of the "client" group (client extensions spec §5.4). */
|
|
42
42
|
const CLIENT_ITEM = "client code";
|
|
43
|
+
/** The one item of the "inbox" group (collaboration spec §4.9). */
|
|
44
|
+
const INBOX_ITEM = "personal inbox items";
|
|
45
|
+
/** The items of the read-only org fact groups. */
|
|
46
|
+
const AGENTS_ITEM = "agents a member may use";
|
|
47
|
+
const CONVERSATIONS_ITEM = "conversations of its own subjects";
|
|
48
|
+
const PEOPLE_ITEM = "members' names and avatars";
|
|
43
49
|
/** 总是敏感的类别。 */
|
|
44
50
|
const ALWAYS_SENSITIVE = new Set([
|
|
45
51
|
"secrets",
|
|
@@ -95,6 +101,14 @@ function keyItem(key) {
|
|
|
95
101
|
return { category: "secrets", item: "secret store" };
|
|
96
102
|
if (key === CLIENT_KEY)
|
|
97
103
|
return { category: "client", item: CLIENT_ITEM };
|
|
104
|
+
if (key === INBOX_KEY)
|
|
105
|
+
return { category: "inbox", item: INBOX_ITEM };
|
|
106
|
+
if (key === AGENTS_KEY)
|
|
107
|
+
return { category: "agents", item: AGENTS_ITEM };
|
|
108
|
+
if (key === CONVERSATIONS_KEY)
|
|
109
|
+
return { category: "conversations", item: CONVERSATIONS_ITEM };
|
|
110
|
+
if (key === PEOPLE_KEY)
|
|
111
|
+
return { category: "people", item: PEOPLE_ITEM };
|
|
98
112
|
if (/^config\.(deployment|org)\.secret:/.test(key))
|
|
99
113
|
return { category: "secrets", item: key.slice(key.indexOf(":") + 1) };
|
|
100
114
|
const table = [
|
|
@@ -191,6 +205,15 @@ export function permissionGroups(set) {
|
|
|
191
205
|
{ category: "deviceAccess", items: p.deviceAccess?.services ?? [] },
|
|
192
206
|
// the event types it emits for the orgs' event automations (not sensitive)
|
|
193
207
|
{ category: "triggers", items: p.triggers?.emit ?? [] },
|
|
208
|
+
// personal inbox items for the orgs' members (not sensitive)
|
|
209
|
+
{ category: "inbox", items: p.inbox === true ? [INBOX_ITEM] : [] },
|
|
210
|
+
// read-only org facts (not sensitive)
|
|
211
|
+
{ category: "agents", items: p.agents?.read === true ? [AGENTS_ITEM] : [] },
|
|
212
|
+
{
|
|
213
|
+
category: "conversations",
|
|
214
|
+
items: p.conversations?.subjects === true ? [CONVERSATIONS_ITEM] : [],
|
|
215
|
+
},
|
|
216
|
+
{ category: "people", items: p.people?.read === true ? [PEOPLE_ITEM] : [] },
|
|
194
217
|
];
|
|
195
218
|
return groups
|
|
196
219
|
.filter((g) => g.items.length > 0)
|