@capybara-hq/kernel 0.1.0-rc.36 → 0.1.0-rc.38
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 +5 -5
- package/dist/admin/admin.module.d.ts +3 -2
- package/dist/admin/admin.module.js +9 -5
- package/dist/admin/audit-log.service.d.ts +51 -0
- package/dist/admin/{platform-audit.service.js → audit-log.service.js} +20 -12
- package/dist/admin/audit.controller.d.ts +18 -6
- package/dist/admin/audit.controller.js +36 -6
- package/dist/admin/audit.schemas.d.ts +9 -1
- package/dist/admin/audit.schemas.js +22 -2
- package/dist/admin/org-network.controller.d.ts +30 -0
- package/dist/admin/org-network.controller.js +77 -0
- package/dist/admin/org-network.schemas.d.ts +16 -0
- package/dist/admin/org-network.schemas.js +27 -0
- package/dist/admin/org-network.service.d.ts +41 -0
- package/dist/admin/org-network.service.js +101 -0
- package/dist/admin/outbox-dead.controller.d.ts +4 -6
- package/dist/admin/outbox-dead.controller.js +9 -6
- package/dist/admin/outbox-dead.schemas.d.ts +16 -0
- package/dist/admin/outbox-dead.schemas.js +25 -1
- package/dist/admin/outbox-dead.service.d.ts +16 -7
- package/dist/admin/outbox-dead.service.js +34 -10
- package/dist/admin/overview.service.d.ts +3 -3
- package/dist/admin/overview.service.js +0 -1
- package/dist/agents/agent-lookup.js +2 -10
- package/dist/agents/agents.service.js +9 -20
- package/dist/agents/definition.d.ts +3 -51
- package/dist/agents/definition.js +4 -254
- package/dist/agents/org-templates.js +2 -6
- package/dist/agents/readiness.controller.d.ts +4 -12
- package/dist/agents/readiness.controller.js +4 -12
- package/dist/agents/readiness.service.d.ts +23 -11
- package/dist/agents/readiness.service.js +31 -14
- package/dist/agents/templates.d.ts +0 -6
- package/dist/agents/templates.js +8 -34
- package/dist/background/store.d.ts +2 -0
- package/dist/background/store.js +3 -1
- package/dist/background/wake-rules.js +2 -1
- package/dist/catalog/admin-catalog.controller.d.ts +1 -2
- package/dist/catalog/admin-catalog.controller.js +1 -2
- package/dist/catalog/appearance.service.js +1 -3
- package/dist/catalog/catalog-content.d.ts +1 -1
- package/dist/catalog/catalog-content.js +1 -4
- package/dist/catalog/catalog-items.js +3 -3
- package/dist/catalog/catalog-scope.service.d.ts +10 -28
- package/dist/catalog/catalog-scope.service.js +22 -73
- package/dist/catalog/cli.d.ts +0 -11
- package/dist/catalog/cli.js +0 -20
- package/dist/catalog/component-scope.service.js +0 -2
- package/dist/catalog/component-state.js +2 -2
- package/dist/catalog/install-status.d.ts +6 -0
- package/dist/catalog/install-status.js +6 -0
- package/dist/catalog/job-ids.d.ts +0 -4
- package/dist/catalog/job-ids.js +0 -4
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.service.d.ts +2 -0
- package/dist/catalog/org-catalog.service.js +8 -3
- package/dist/catalog/org-extension-switch.d.ts +7 -2
- package/dist/catalog/org-extension-switch.js +56 -9
- package/dist/catalog/org-plugin-uploads.d.ts +6 -15
- package/dist/catalog/org-plugin-uploads.js +9 -27
- package/dist/catalog/owned-items.js +1 -3
- package/dist/catalog/platform-import-update.js +1 -1
- package/dist/catalog/plugin-import.d.ts +15 -13
- package/dist/catalog/plugin-import.js +21 -30
- package/dist/catalog/plugin-install.d.ts +3 -43
- package/dist/catalog/plugin-install.js +8 -150
- package/dist/catalog/plugin-package.d.ts +5 -10
- package/dist/catalog/plugin-package.js +12 -33
- package/dist/catalog/plugin-upgrade.js +5 -4
- package/dist/catalog/scope-jobs.d.ts +34 -34
- package/dist/catalog/scope-jobs.js +50 -37
- package/dist/catalog/scope-orgs.d.ts +1 -1
- package/dist/catalog/scope-orgs.js +1 -2
- package/dist/catalog/scope-sync-workers.d.ts +4 -3
- package/dist/catalog/scope-sync-workers.js +18 -6
- package/dist/catalog/scope-sync.d.ts +56 -59
- package/dist/catalog/scope-sync.js +96 -166
- package/dist/catalog/unshare.d.ts +3 -4
- package/dist/catalog/unshare.js +5 -8
- package/dist/channels/job-ids.d.ts +2 -6
- package/dist/channels/job-ids.js +2 -6
- package/dist/channels/outbound.d.ts +1 -1
- package/dist/channels/outbound.js +1 -1
- package/dist/channels/supervisor.d.ts +2 -3
- package/dist/channels/supervisor.js +2 -3
- package/dist/client/client-access.service.js +1 -1
- package/dist/config/env.js +19 -1
- package/dist/config/load.d.ts +0 -6
- package/dist/config/load.js +8 -27
- package/dist/config/schema.d.ts +54 -47
- package/dist/config/schema.js +198 -42
- package/dist/conversations/attachments.service.d.ts +10 -3
- package/dist/conversations/attachments.service.js +49 -16
- package/dist/conversations/conversations.controller.d.ts +0 -39
- package/dist/conversations/conversations.controller.js +0 -39
- package/dist/conversations/event-log.js +4 -1
- package/dist/conversations/events.d.ts +71 -46
- package/dist/conversations/events.js +124 -112
- package/dist/conversations/media-types.d.ts +25 -0
- package/dist/conversations/media-types.js +38 -0
- package/dist/conversations/queue.d.ts +3 -1
- package/dist/conversations/queue.service.js +9 -2
- package/dist/conversations/titles.js +6 -0
- package/dist/ctx/create-ctx.d.ts +8 -1
- package/dist/ctx/create-ctx.js +13 -3
- package/dist/ctx/net.d.ts +50 -0
- package/dist/ctx/net.js +67 -0
- package/dist/ctx/secrets.d.ts +24 -7
- package/dist/ctx/secrets.js +97 -30
- package/dist/db/kernel-schema.d.ts +27 -6
- package/dist/devices/devices.service.js +2 -1
- package/dist/errors.d.ts +10 -2
- package/dist/errors.js +10 -2
- package/dist/evals/reconstruct.d.ts +4 -17
- package/dist/evals/reconstruct.js +13 -53
- package/dist/evals/recorded-tools.d.ts +0 -27
- package/dist/evals/recorded-tools.js +2 -92
- package/dist/evals/run-replay.d.ts +1 -6
- package/dist/evals/run-replay.js +10 -17
- package/dist/evals/sets.service.d.ts +17 -5
- package/dist/evals/sets.service.js +33 -12
- package/dist/evals/snapshot.d.ts +1 -2
- package/dist/evals/snapshot.js +4 -17
- package/dist/extensions/admin-ops.d.ts +6 -1
- package/dist/extensions/admin-ops.js +17 -4
- package/dist/extensions/admin-view.d.ts +7 -4
- package/dist/extensions/admin-view.js +27 -21
- package/dist/extensions/bootstrap.js +0 -1
- package/dist/extensions/cli.js +0 -1
- package/dist/extensions/extensions.module.js +3 -0
- package/dist/extensions/host.d.ts +9 -4
- package/dist/extensions/host.js +14 -8
- package/dist/extensions/installs.d.ts +1 -3
- package/dist/extensions/instance.d.ts +0 -2
- package/dist/extensions/instance.js +0 -3
- package/dist/extensions/org-config.d.ts +4 -4
- package/dist/extensions/org-config.js +13 -22
- package/dist/extensions/package.d.ts +6 -6
- package/dist/extensions/package.js +3 -7
- package/dist/extensions/permission-view.d.ts +2 -4
- package/dist/extensions/plugin-items.d.ts +21 -1
- package/dist/extensions/plugin-items.js +28 -0
- package/dist/extensions/sync.js +5 -10
- package/dist/extensions/unavailable.js +0 -1
- package/dist/http/api.module.js +4 -1
- package/dist/identity/audit.d.ts +0 -12
- package/dist/identity/audit.js +0 -27
- package/dist/identity/auth.controller.js +5 -9
- package/dist/identity/cookies.d.ts +4 -9
- package/dist/identity/cookies.js +8 -32
- package/dist/identity/initial-passwords.d.ts +1 -1
- package/dist/identity/initial-passwords.js +1 -2
- package/dist/identity/sessions.d.ts +0 -6
- package/dist/identity/sessions.js +0 -18
- package/dist/inbox/platform-inbox.service.d.ts +33 -1
- package/dist/inbox/platform-inbox.service.js +56 -6
- package/dist/index.d.ts +4 -2
- package/dist/index.js +4 -2
- package/dist/infra/cli/master-key-rewrap.d.ts +15 -0
- package/dist/infra/cli/master-key-rewrap.js +24 -0
- package/dist/infra/config/kernel-config.service.js +0 -17
- package/dist/infra/database/transaction-host.d.ts +32 -1
- package/dist/infra/database/transaction-host.js +30 -4
- package/dist/infra/database/xact-lock.d.ts +16 -0
- package/dist/infra/database/xact-lock.js +28 -1
- package/dist/infra/health/health.controller.js +8 -0
- package/dist/infra/health/process-fault.d.ts +16 -0
- package/dist/infra/health/process-fault.js +49 -0
- package/dist/infra/lifecycle/process-guards.d.ts +8 -2
- package/dist/infra/lifecycle/process-guards.js +12 -3
- package/dist/infra/lifecycle/shutdown-signals.d.ts +10 -1
- package/dist/infra/lifecycle/shutdown-signals.js +28 -13
- package/dist/infra/outbox/outbox.service.d.ts +12 -9
- package/dist/infra/outbox/outbox.service.js +22 -26
- package/dist/infra/outbox/registry.d.ts +15 -7
- package/dist/infra/outbox/registry.js +39 -23
- package/dist/lifecycle/kernel-lifecycle.js +1 -7
- package/dist/models/enablement.d.ts +5 -6
- package/dist/models/enablement.js +7 -14
- package/dist/net/public-address.d.ts +21 -1
- package/dist/net/public-address.js +56 -10
- package/dist/net/safe-fetch.d.ts +4 -1
- package/dist/net/safe-fetch.js +15 -4
- package/dist/orgs/directory-sync.js +2 -0
- package/dist/orgs/members.service.js +5 -0
- package/dist/orgs/network-allowances.service.d.ts +79 -0
- package/dist/orgs/network-allowances.service.js +371 -0
- package/dist/orgs/offboarding.d.ts +3 -1
- package/dist/orgs/offboarding.js +9 -2
- package/dist/orgs/org-lock.d.ts +28 -2
- package/dist/orgs/org-lock.js +59 -4
- package/dist/orgs/orgs.controller.d.ts +11 -2
- package/dist/orgs/orgs.controller.js +19 -3
- package/dist/orgs/orgs.module.d.ts +3 -2
- package/dist/orgs/orgs.module.js +6 -2
- package/dist/orgs/orgs.schemas.d.ts +12 -0
- package/dist/orgs/orgs.schemas.js +5 -0
- package/dist/orgs/orgs.service.js +6 -1
- package/dist/orgs/settings.controller.d.ts +3 -2
- package/dist/orgs/settings.service.d.ts +59 -14
- package/dist/orgs/settings.service.js +102 -20
- package/dist/overrides.d.ts +7 -7
- package/dist/overrides.js +4 -4
- package/dist/packages/tgz.d.ts +0 -2
- package/dist/packages/tgz.js +0 -2
- package/dist/platform/exclusions.js +0 -5
- package/dist/platform/operation.js +1 -1
- package/dist/platform/ops/admin.ops.d.ts +2 -2
- package/dist/platform/ops/admin.ops.js +9 -6
- package/dist/platform/ops/agents.ops.js +1 -1
- package/dist/platform/ops/connectors.ops.js +46 -1
- package/dist/platform/ops/evals.ops.js +1 -64
- package/dist/platform/ops/extensions-admin.ops.js +1 -1
- package/dist/platform/ops/inbox.ops.js +16 -3
- package/dist/platform/ops/org-plugins.ops.js +1 -1
- package/dist/platform/ops/orgs.ops.d.ts +11 -3
- package/dist/platform/ops/orgs.ops.js +139 -5
- package/dist/platform/ops/outbox.ops.js +5 -5
- package/dist/platform/route-schemas.js +3 -0
- package/dist/roles/worker-role.d.ts +2 -3
- package/dist/roles/worker-role.js +3 -13
- package/dist/runtime/checkpointer.d.ts +3 -0
- package/dist/runtime/checkpointer.js +7 -4
- package/dist/runtime/context/build.d.ts +56 -18
- package/dist/runtime/context/build.js +143 -50
- package/dist/runtime/context/compaction.d.ts +1 -3
- package/dist/runtime/context/compaction.js +42 -8
- package/dist/runtime/context/run-context.js +1 -2
- package/dist/runtime/context/skills.d.ts +27 -56
- package/dist/runtime/context/skills.js +42 -114
- package/dist/runtime/context/tool-changes.d.ts +3 -3
- package/dist/runtime/context/tool-changes.js +6 -16
- package/dist/runtime/hook-calls.d.ts +6 -6
- package/dist/runtime/hook-calls.js +7 -7
- package/dist/runtime/langgraph-loop.js +9 -3
- package/dist/runtime/maintenance.d.ts +3 -11
- package/dist/runtime/maintenance.js +5 -20
- package/dist/runtime/model-call.d.ts +5 -0
- package/dist/runtime/model-call.js +48 -36
- package/dist/runtime/providers.d.ts +33 -35
- package/dist/runtime/providers.js +64 -109
- package/dist/runtime/run-context.service.js +7 -22
- package/dist/runtime/run-deletion.d.ts +6 -0
- package/dist/runtime/run-deletion.js +39 -16
- package/dist/runtime/run-execution.d.ts +56 -3
- package/dist/runtime/run-execution.js +81 -11
- package/dist/runtime/run-finish.js +2 -1
- package/dist/runtime/run-liveness.d.ts +11 -0
- package/dist/runtime/run-liveness.js +19 -0
- package/dist/runtime/run-orphan-check.job.js +2 -1
- package/dist/runtime/run-queue.js +8 -16
- package/dist/runtime/run-worker.d.ts +2 -2
- package/dist/runtime/run-worker.js +8 -6
- package/dist/runtime/step-log.d.ts +5 -0
- package/dist/runtime/step-log.js +9 -4
- package/dist/runtime/subagents/definition.d.ts +16 -20
- package/dist/runtime/subagents/definition.js +27 -27
- package/dist/runtime/subagents/dispatch.d.ts +6 -2
- package/dist/runtime/subagents/dispatch.js +17 -3
- package/dist/runtime/subagents/org-agents.js +1 -2
- package/dist/runtime/subagents/preamble.d.ts +3 -2
- package/dist/runtime/subagents/preamble.js +3 -2
- package/dist/runtime/subagents/render.d.ts +1 -2
- package/dist/runtime/subagents/render.js +1 -2
- package/dist/runtime/subagents/skill-fork.d.ts +2 -4
- package/dist/runtime/subagents/template-skills.d.ts +47 -0
- package/dist/runtime/subagents/template-skills.js +76 -0
- package/dist/runtime/waits.js +3 -1
- package/dist/schedules/effective-settings.d.ts +9 -3
- package/dist/schedules/effective-settings.js +5 -4
- package/dist/schedules/fire.js +11 -0
- package/dist/schedules/scheduled-tasks.service.js +5 -0
- package/dist/schedules/unattended.d.ts +2 -0
- package/dist/schedules/unattended.js +6 -1
- package/dist/skills/agent-skills.service.js +1 -2
- package/dist/skills/catalog.d.ts +1 -3
- package/dist/skills/catalog.js +1 -3
- package/dist/skills/conversation-catalog.d.ts +1 -2
- package/dist/skills/conversation-catalog.js +1 -2
- package/dist/skills/usable.js +2 -3
- package/dist/storage/storage.service.js +9 -1
- package/dist/tools/approvals.service.js +2 -4
- package/dist/tools/builtin-names.d.ts +2 -9
- package/dist/tools/builtin-names.js +4 -13
- package/dist/tools/builtins/sandbox/bash.js +3 -3
- package/dist/tools/builtins/sandbox/common.d.ts +7 -13
- package/dist/tools/builtins/sandbox/common.js +8 -115
- package/dist/tools/builtins/sandbox/fetch-attachment.d.ts +10 -0
- package/dist/tools/builtins/sandbox/fetch-attachment.js +119 -0
- package/dist/tools/builtins/sandbox/glob.js +1 -3
- package/dist/tools/builtins/sandbox/grep.js +3 -5
- package/dist/tools/builtins/sandbox/index.d.ts +8 -5
- package/dist/tools/builtins/sandbox/index.js +10 -5
- package/dist/tools/builtins/sandbox/read.js +3 -2
- package/dist/tools/builtins/tool-search.d.ts +4 -7
- package/dist/tools/builtins/tool-search.js +6 -10
- package/dist/tools/connector-account-policies.d.ts +30 -3
- package/dist/tools/connector-account-policies.js +54 -7
- package/dist/tools/connector-content.js +1 -0
- package/dist/tools/connectors.controller.d.ts +24 -11
- package/dist/tools/connectors.controller.js +35 -6
- package/dist/tools/connectors.schemas.d.ts +14 -1
- package/dist/tools/connectors.schemas.js +14 -2
- package/dist/tools/connectors.service.d.ts +22 -0
- package/dist/tools/connectors.service.js +65 -6
- package/dist/tools/drift.d.ts +6 -2
- package/dist/tools/drift.js +10 -5
- package/dist/tools/git-push-policy.d.ts +4 -1
- package/dist/tools/git-push-policy.js +3 -1
- package/dist/tools/info.d.ts +1 -7
- package/dist/tools/info.js +5 -18
- package/dist/tools/job-ids.d.ts +0 -4
- package/dist/tools/job-ids.js +1 -6
- package/dist/tools/pipeline.d.ts +4 -10
- package/dist/tools/pipeline.js +17 -62
- package/dist/tools/policy.d.ts +6 -2
- package/dist/tools/policy.js +14 -12
- package/dist/tools/registry.js +1 -5
- package/dist/ui/views.d.ts +5 -5
- package/dist/ui/views.js +10 -16
- package/package.json +3 -3
- package/src/migrations/0137_audit_org_idx.sql +5 -0
- package/src/migrations/0138_plugin_install_status_no_upgrading.sql +18 -0
- package/src/migrations/0139_retire_legacy_forms.sql +183 -0
- package/src/migrations/0140_retire_history_forms.sql +148 -0
- package/src/migrations/0141_install_ledger_promoted_rows.sql +36 -0
- package/src/migrations/0142_backfill_event_fields.sql +74 -0
- package/src/migrations/0143_backfill_model_call_fields.sql +105 -0
- package/src/migrations/0144_retire_frozen_definition_keys.sql +163 -0
- package/src/migrations/0145_org_network_allowances.sql +12 -0
- package/dist/admin/platform-audit.service.d.ts +0 -41
- package/dist/conversations/job-ids.d.ts +0 -6
- package/dist/conversations/job-ids.js +0 -6
- package/dist/extensions/job-ids.d.ts +0 -6
- package/dist/extensions/job-ids.js +0 -6
- package/dist/infra/queue/retired-schedulers.d.ts +0 -7
- package/dist/infra/queue/retired-schedulers.js +0 -9
- package/dist/orgs/job-ids.d.ts +0 -8
- package/dist/orgs/job-ids.js +0 -8
- package/dist/runtime/context/legacy-text.d.ts +0 -22
- package/dist/runtime/context/legacy-text.js +0 -37
- package/dist/runtime/job-ids.d.ts +0 -10
- package/dist/runtime/job-ids.js +0 -10
- package/dist/runtime/retired-schedulers.d.ts +0 -7
- package/dist/runtime/retired-schedulers.js +0 -31
- package/dist/storage/job-ids.d.ts +0 -6
- package/dist/storage/job-ids.js +0 -6
- package/dist/tools/legacy-data.d.ts +0 -34
- package/dist/tools/legacy-data.js +0 -76
- package/dist/tools/legacy-keys.d.ts +0 -51
- package/dist/tools/legacy-keys.js +0 -114
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type PluginScope } from "../catalog/scope.js";
|
|
2
2
|
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
3
3
|
/** The catalog item (the plugin) an extension ships in. */
|
|
4
4
|
export interface ExtensionPluginItem {
|
|
@@ -19,3 +19,23 @@ export declare function pluginItemsOf(db: KernelSchemaDb, names: readonly string
|
|
|
19
19
|
* one, layering spec §4): its switch cannot go off.
|
|
20
20
|
*/
|
|
21
21
|
export declare const itemLocked: (i: ExtensionPluginItem) => boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Whether an org may see an extension with these live catalog items (`listed`: the items whose
|
|
24
|
+
* `named` list has the org): one visible item is enough; without an item (config-declared, or its
|
|
25
|
+
* items deleted) it is visible. A builtin item counts as `all`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function itemsVisible(items: readonly ExtensionPluginItem[] | undefined, listed: ReadonlySet<string>): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Whether the org's extension list shows an extension (`OrgExtensionConfigs.list`, which the org
|
|
30
|
+
* readiness reads for the model providers an org admin can fix): a required bootstrap plugin
|
|
31
|
+
* always; else under its catalog items' scope, and, while it is off in the org, only when none of
|
|
32
|
+
* its items is disabled (nothing can newly enable it then, Ruling M-5; one already on stays).
|
|
33
|
+
*/
|
|
34
|
+
export declare const offeredToOrg: (e: {
|
|
35
|
+
required: boolean;
|
|
36
|
+
enabled: boolean;
|
|
37
|
+
items: readonly ExtensionPluginItem[] | undefined;
|
|
38
|
+
listed: ReadonlySet<string>;
|
|
39
|
+
}) => boolean;
|
|
40
|
+
/** The ids of the catalog items whose `named` list has `orgId`. `db` may be a transaction. */
|
|
41
|
+
export declare function scopeListedFor(db: KernelSchemaDb, orgId: string): Promise<Set<string>>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { visibleTo } from "../catalog/scope.js";
|
|
1
2
|
/**
|
|
2
3
|
* The live catalog items of each extension in `names`, the one recorded on its install
|
|
3
4
|
* (`extension_installs.catalog_item_id`) first, then its other `extension_catalog_sources` by id.
|
|
@@ -40,3 +41,30 @@ export async function pluginItemsOf(db, names) {
|
|
|
40
41
|
* one, layering spec §4): its switch cannot go off.
|
|
41
42
|
*/
|
|
42
43
|
export const itemLocked = (i) => i.builtin;
|
|
44
|
+
/**
|
|
45
|
+
* Whether an org may see an extension with these live catalog items (`listed`: the items whose
|
|
46
|
+
* `named` list has the org): one visible item is enough; without an item (config-declared, or its
|
|
47
|
+
* items deleted) it is visible. A builtin item counts as `all`.
|
|
48
|
+
*/
|
|
49
|
+
export function itemsVisible(items, listed) {
|
|
50
|
+
if (!items)
|
|
51
|
+
return true;
|
|
52
|
+
return items.some((i) => visibleTo({ scope: i.builtin ? "all" : i.scope }, listed.has(i.id)));
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Whether the org's extension list shows an extension (`OrgExtensionConfigs.list`, which the org
|
|
56
|
+
* readiness reads for the model providers an org admin can fix): a required bootstrap plugin
|
|
57
|
+
* always; else under its catalog items' scope, and, while it is off in the org, only when none of
|
|
58
|
+
* its items is disabled (nothing can newly enable it then, Ruling M-5; one already on stays).
|
|
59
|
+
*/
|
|
60
|
+
export const offeredToOrg = (e) => e.required ||
|
|
61
|
+
(itemsVisible(e.items, e.listed) && (e.enabled || !(e.items ?? []).some((i) => i.disabled)));
|
|
62
|
+
/** The ids of the catalog items whose `named` list has `orgId`. `db` may be a transaction. */
|
|
63
|
+
export async function scopeListedFor(db, orgId) {
|
|
64
|
+
const rows = await db
|
|
65
|
+
.selectFrom("catalog_item_scope_orgs")
|
|
66
|
+
.select("item_id")
|
|
67
|
+
.where("org_id", "=", orgId)
|
|
68
|
+
.execute();
|
|
69
|
+
return new Set(rows.map((r) => r.item_id));
|
|
70
|
+
}
|
package/dist/extensions/sync.js
CHANGED
|
@@ -4,8 +4,8 @@ import { mkdir, readdir, readFile, rename, rm, stat, symlink, writeFile } from "
|
|
|
4
4
|
import { dirname, join, relative, resolve as resolvePath, sep } from "node:path";
|
|
5
5
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
6
6
|
import { HOST_PROVIDED_PACKAGES, isSafePackagePath, PLUGIN_MANIFEST_FILE, } from "@capybara-hq/plugin-sdk";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { packagePath } from "../packages/tgz.js";
|
|
8
|
+
import { extractExtensionPackage } from "./package.js";
|
|
9
9
|
/**
|
|
10
10
|
* 把内容寻址的插件包同步到本副本的本地目录(C13):`<dir>/<name>/<sha256 前 16 位>/`。
|
|
11
11
|
*
|
|
@@ -165,9 +165,8 @@ export async function syncPackage(dir, name, sha, blobs, limits) {
|
|
|
165
165
|
}
|
|
166
166
|
/**
|
|
167
167
|
* The extension entry (relative to the package root) from the unpacked package's
|
|
168
|
-
* `.capybara-plugin/plugin.json`. A package
|
|
169
|
-
*
|
|
170
|
-
* records it as the replica's failure instead of loading).
|
|
168
|
+
* `.capybara-plugin/plugin.json`. A package without plugin.json fails with an ordinary
|
|
169
|
+
* error (the host records it as the replica's failure instead of loading).
|
|
171
170
|
*/
|
|
172
171
|
async function extensionEntryOf(root, name) {
|
|
173
172
|
const read = async (path) => {
|
|
@@ -182,11 +181,7 @@ async function extensionEntryOf(root, name) {
|
|
|
182
181
|
};
|
|
183
182
|
const manifest = (await read(PLUGIN_MANIFEST_FILE));
|
|
184
183
|
if (manifest === undefined) {
|
|
185
|
-
|
|
186
|
-
if (pkg?.capybara !== undefined || existsSync(join(root, "app.yaml"))) {
|
|
187
|
-
throw new ExtensionPackageError([`Package of extension ${name} ${LEGACY_FORMAT_MESSAGE}`], "extension.legacy_format");
|
|
188
|
-
}
|
|
189
|
-
throw new Error(`package ${name}: ${PLUGIN_MANIFEST_FILE} is missing`);
|
|
184
|
+
throw new Error(`package ${name}: ${PLUGIN_MANIFEST_FILE} is missing; a plugin package carries its manifest at that path (build it with \`capybara-plugin pack\`)`);
|
|
190
185
|
}
|
|
191
186
|
const entry = manifest.extension?.entry;
|
|
192
187
|
if (typeof entry !== "string" || !isSafePackagePath(packagePath(entry))) {
|
package/dist/http/api.module.js
CHANGED
|
@@ -10,8 +10,9 @@ import { AdminController } from "../admin/admin.controller.js";
|
|
|
10
10
|
import { AdminModule } from "../admin/admin.module.js";
|
|
11
11
|
import { AdminAgentsController } from "../admin/admin-agents.controller.js";
|
|
12
12
|
import { AdminConnectorsController } from "../admin/admin-connectors.controller.js";
|
|
13
|
-
import { AdminAuditController } from "../admin/audit.controller.js";
|
|
13
|
+
import { AdminAuditController, OrgAuditController } from "../admin/audit.controller.js";
|
|
14
14
|
import { AdminExtensionsController } from "../admin/extensions.controller.js";
|
|
15
|
+
import { AdminOrgNetworkController } from "../admin/org-network.controller.js";
|
|
15
16
|
import { OutboxDeadController } from "../admin/outbox-dead.controller.js";
|
|
16
17
|
import { AdminOverviewController } from "../admin/overview.controller.js";
|
|
17
18
|
import { SetupController } from "../admin/setup.controller.js";
|
|
@@ -108,8 +109,10 @@ const CONTROLLERS = [
|
|
|
108
109
|
AdminAgentsController,
|
|
109
110
|
AdminConnectorsController,
|
|
110
111
|
AdminAuditController,
|
|
112
|
+
OrgAuditController,
|
|
111
113
|
AdminOverviewController,
|
|
112
114
|
OutboxDeadController,
|
|
115
|
+
AdminOrgNetworkController,
|
|
113
116
|
AdminExtensionsController,
|
|
114
117
|
AdminCatalogController,
|
|
115
118
|
AdminComponentsController,
|
package/dist/identity/audit.d.ts
CHANGED
|
@@ -13,15 +13,3 @@ export declare function audit(db: KernelSchemaDb, e: {
|
|
|
13
13
|
target?: string;
|
|
14
14
|
detail?: Record<string, unknown>;
|
|
15
15
|
}): Promise<void>;
|
|
16
|
-
/**
|
|
17
|
-
* Connector audit actions written before the D17 rename (old rows are not rewritten, C27) -> the
|
|
18
|
-
* renamed action. Only these are listed, nothing is inferred from the `app.*` prefix: after D17
|
|
19
|
-
* "app" meant app bundles (`app.installed` etc., `plugin.org_installed` since phase 0a), which are
|
|
20
|
-
* unrelated to connectors (F-X).
|
|
21
|
-
*/
|
|
22
|
-
export declare const LEGACY_AUDIT_ACTIONS: Readonly<Record<string, string>>;
|
|
23
|
-
/**
|
|
24
|
-
* 按 action 查询审计时与之同义的全部 action(含自身):`connector.created` ↔ `app.created` 等,
|
|
25
|
-
* 只按 {@link LEGACY_AUDIT_ACTIONS} 显式映射;其余 action 只有自身。
|
|
26
|
-
*/
|
|
27
|
-
export declare function auditActionAliases(action: string): string[];
|
package/dist/identity/audit.js
CHANGED
|
@@ -16,30 +16,3 @@ export async function audit(db, e) {
|
|
|
16
16
|
})
|
|
17
17
|
.execute();
|
|
18
18
|
}
|
|
19
|
-
/**
|
|
20
|
-
* Connector audit actions written before the D17 rename (old rows are not rewritten, C27) -> the
|
|
21
|
-
* renamed action. Only these are listed, nothing is inferred from the `app.*` prefix: after D17
|
|
22
|
-
* "app" meant app bundles (`app.installed` etc., `plugin.org_installed` since phase 0a), which are
|
|
23
|
-
* unrelated to connectors (F-X).
|
|
24
|
-
*/
|
|
25
|
-
export const LEGACY_AUDIT_ACTIONS = Object.freeze({
|
|
26
|
-
"app.created": "connector.created",
|
|
27
|
-
"app.updated": "connector.updated",
|
|
28
|
-
"app.deleted": "connector.deleted",
|
|
29
|
-
"app.tools_refreshed": "connector.tools_refreshed",
|
|
30
|
-
"app.tools_drifted": "connector.tools_drifted",
|
|
31
|
-
"app.tool_reviewed": "connector.tool_reviewed",
|
|
32
|
-
"app.credential.set": "connector.credential.set",
|
|
33
|
-
"app.credential.cleared": "connector.credential.cleared",
|
|
34
|
-
});
|
|
35
|
-
/**
|
|
36
|
-
* 按 action 查询审计时与之同义的全部 action(含自身):`connector.created` ↔ `app.created` 等,
|
|
37
|
-
* 只按 {@link LEGACY_AUDIT_ACTIONS} 显式映射;其余 action 只有自身。
|
|
38
|
-
*/
|
|
39
|
-
export function auditActionAliases(action) {
|
|
40
|
-
const current = LEGACY_AUDIT_ACTIONS[action] ?? action;
|
|
41
|
-
const legacy = Object.entries(LEGACY_AUDIT_ACTIONS)
|
|
42
|
-
.filter(([, to]) => to === current)
|
|
43
|
-
.map(([from]) => from);
|
|
44
|
-
return [current, ...legacy];
|
|
45
|
-
}
|
|
@@ -15,7 +15,7 @@ import { CredentialThrottler } from "../infra/throttler/credential-throttler.js"
|
|
|
15
15
|
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
16
16
|
import { ZBody } from "../infra/validation/zod-params.js";
|
|
17
17
|
import { AccountsService } from "./accounts.js";
|
|
18
|
-
import { ACCESS_COOKIE, clearSessionCookies,
|
|
18
|
+
import { ACCESS_COOKIE, clearSessionCookies, REFRESH_COOKIE, setSessionCookies, } from "./cookies.js";
|
|
19
19
|
import { Public } from "./principal.js";
|
|
20
20
|
import { SessionService } from "./sessions.js";
|
|
21
21
|
const LoginBodySchema = z.object({ login: z.string().max(256), password: z.string() });
|
|
@@ -74,13 +74,9 @@ let AuthController = class AuthController {
|
|
|
74
74
|
*/
|
|
75
75
|
async refresh(req, reply) {
|
|
76
76
|
try {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (candidates.length === 0) {
|
|
77
|
+
const rt = req.cookies[REFRESH_COOKIE];
|
|
78
|
+
if (!rt)
|
|
80
79
|
throw new ApiError("auth.refresh_invalid", "Refresh token is missing");
|
|
81
|
-
}
|
|
82
|
-
// none is current: the last one (the Path=/ cookie) goes through the usual replay handling
|
|
83
|
-
const rt = (await this.sessions.pickCurrentRefresh(candidates)) ?? candidates.at(-1);
|
|
84
80
|
const session = await this.sessions.refresh(rt, clientMeta(req));
|
|
85
81
|
const account = await this.accounts.get(session.accountId);
|
|
86
82
|
if (!account)
|
|
@@ -98,13 +94,13 @@ let AuthController = class AuthController {
|
|
|
98
94
|
async logout(req, reply) {
|
|
99
95
|
clearSessionCookies(reply);
|
|
100
96
|
const at = req.cookies[ACCESS_COOKIE];
|
|
101
|
-
const
|
|
97
|
+
const rt = req.cookies[REFRESH_COOKIE];
|
|
102
98
|
if (at) {
|
|
103
99
|
const sid = await this.sessions.sessionIdFromAccess(at);
|
|
104
100
|
if (sid !== undefined)
|
|
105
101
|
await this.sessions.revoke(sid);
|
|
106
102
|
}
|
|
107
|
-
|
|
103
|
+
if (rt)
|
|
108
104
|
await this.sessions.revokeByRefresh(rt);
|
|
109
105
|
}
|
|
110
106
|
};
|
|
@@ -15,20 +15,15 @@ export declare const REFRESH_COOKIE = "cap_rt";
|
|
|
15
15
|
* session while rendering on the server.
|
|
16
16
|
*/
|
|
17
17
|
export declare const REFRESH_COOKIE_PATH = "/";
|
|
18
|
-
/** The Path earlier releases set `cap_rt` on; browsers may still hold it, so it is cleared too. */
|
|
19
|
-
export declare const LEGACY_REFRESH_COOKIE_PATH = "/api/v1/auth";
|
|
20
18
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
19
|
+
* The Path earlier builds set `cap_rt` on. Cleared (never read) with every session write, so a
|
|
20
|
+
* browser that still holds it stops sending a stale token. Remove after 2026-12-01.
|
|
23
21
|
*/
|
|
22
|
+
export declare const OLD_REFRESH_COOKIE_PATH = "/api/v1/auth";
|
|
23
|
+
/** Writes the session cookies. Both are HttpOnly, host-only (no Domain), SameSite=Lax and Path=/. */
|
|
24
24
|
export declare function setSessionCookies(reply: FastifyReply, s: IssuedSession, cfg: KernelConfig): void;
|
|
25
25
|
/** 清除会话 Cookie(Path 必须与设置时一致才能覆盖)。 */
|
|
26
26
|
export declare function clearSessionCookies(reply: FastifyReply): void;
|
|
27
|
-
/**
|
|
28
|
-
* Every `cap_rt` value of a raw `cookie` header, in header order. A browser holding the legacy
|
|
29
|
-
* Path cookie and the new one sends both, the more specific Path first.
|
|
30
|
-
*/
|
|
31
|
-
export declare function refreshCookieValues(header: string | undefined): string[];
|
|
32
27
|
/**
|
|
33
28
|
* The startup warning for an http trial that cannot sign in: session cookies are Secure but the
|
|
34
29
|
* configured public URL is plain http, so browsers drop them. Null when cookies are not Secure,
|
package/dist/identity/cookies.js
CHANGED
|
@@ -12,12 +12,12 @@ export const REFRESH_COOKIE = "cap_rt";
|
|
|
12
12
|
* session while rendering on the server.
|
|
13
13
|
*/
|
|
14
14
|
export const REFRESH_COOKIE_PATH = "/";
|
|
15
|
-
/** The Path earlier releases set `cap_rt` on; browsers may still hold it, so it is cleared too. */
|
|
16
|
-
export const LEGACY_REFRESH_COOKIE_PATH = "/api/v1/auth";
|
|
17
15
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
16
|
+
* The Path earlier builds set `cap_rt` on. Cleared (never read) with every session write, so a
|
|
17
|
+
* browser that still holds it stops sending a stale token. Remove after 2026-12-01.
|
|
20
18
|
*/
|
|
19
|
+
export const OLD_REFRESH_COOKIE_PATH = "/api/v1/auth";
|
|
20
|
+
/** Writes the session cookies. Both are HttpOnly, host-only (no Domain), SameSite=Lax and Path=/. */
|
|
21
21
|
export function setSessionCookies(reply, s, cfg) {
|
|
22
22
|
const secure = cfg.auth.cookieSecure;
|
|
23
23
|
reply.setCookie(ACCESS_COOKIE, s.accessToken, {
|
|
@@ -34,39 +34,15 @@ export function setSessionCookies(reply, s, cfg) {
|
|
|
34
34
|
secure,
|
|
35
35
|
maxAge: cfg.auth.refreshTokenTtlDays * 86400,
|
|
36
36
|
});
|
|
37
|
-
|
|
37
|
+
// clears stale client state from earlier builds; remove after 2026-12-01
|
|
38
|
+
reply.clearCookie(REFRESH_COOKIE, { path: OLD_REFRESH_COOKIE_PATH });
|
|
38
39
|
}
|
|
39
40
|
/** 清除会话 Cookie(Path 必须与设置时一致才能覆盖)。 */
|
|
40
41
|
export function clearSessionCookies(reply) {
|
|
41
42
|
reply.clearCookie(ACCESS_COOKIE, { path: "/" });
|
|
42
43
|
reply.clearCookie(REFRESH_COOKIE, { path: REFRESH_COOKIE_PATH });
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Every `cap_rt` value of a raw `cookie` header, in header order. A browser holding the legacy
|
|
47
|
-
* Path cookie and the new one sends both, the more specific Path first.
|
|
48
|
-
*/
|
|
49
|
-
export function refreshCookieValues(header) {
|
|
50
|
-
if (!header)
|
|
51
|
-
return [];
|
|
52
|
-
const out = [];
|
|
53
|
-
for (const part of header.split(";")) {
|
|
54
|
-
const eq = part.indexOf("=");
|
|
55
|
-
if (eq < 0 || part.slice(0, eq).trim() !== REFRESH_COOKIE)
|
|
56
|
-
continue;
|
|
57
|
-
let v = part.slice(eq + 1).trim();
|
|
58
|
-
if (v.startsWith('"') && v.endsWith('"') && v.length >= 2)
|
|
59
|
-
v = v.slice(1, -1);
|
|
60
|
-
try {
|
|
61
|
-
v = decodeURIComponent(v);
|
|
62
|
-
}
|
|
63
|
-
catch {
|
|
64
|
-
// keep the raw value
|
|
65
|
-
}
|
|
66
|
-
if (v)
|
|
67
|
-
out.push(v);
|
|
68
|
-
}
|
|
69
|
-
return out;
|
|
44
|
+
// clears stale client state from earlier builds; remove after 2026-12-01
|
|
45
|
+
reply.clearCookie(REFRESH_COOKIE, { path: OLD_REFRESH_COOKIE_PATH });
|
|
70
46
|
}
|
|
71
47
|
/**
|
|
72
48
|
* The startup warning for an http trial that cannot sign in: session cookies are Secure but the
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Keyring } from "../ctx/secrets.js";
|
|
2
2
|
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
3
3
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
4
4
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
@@ -10,6 +10,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
10
|
import { randomInt } from "node:crypto";
|
|
11
11
|
import { Inject, Injectable } from "@nestjs/common";
|
|
12
12
|
import { sql } from "kysely";
|
|
13
|
+
import { initialPasswordAad as aadOf } from "../ctx/secrets.js";
|
|
13
14
|
import { ApiError } from "../errors.js";
|
|
14
15
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
15
16
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
@@ -35,8 +36,6 @@ export function generateInitialPassword() {
|
|
|
35
36
|
out += ALPHABET[randomInt(ALPHABET.length)];
|
|
36
37
|
return out;
|
|
37
38
|
}
|
|
38
|
-
/** The AAD binding a sealed password to its account (a row moved to another account fails). */
|
|
39
|
-
const aadOf = (accountId) => `capybara:initial-password:${accountId}`;
|
|
40
39
|
/**
|
|
41
40
|
* Accounts created with a kernel-generated one-time password (Platform tool spec §14.5 item 2).
|
|
42
41
|
* The password never leaves the kernel except through {@link reveal}: it is not returned to the
|
|
@@ -42,12 +42,6 @@ export declare class SessionService {
|
|
|
42
42
|
* app then asks to choose or create one).
|
|
43
43
|
*/
|
|
44
44
|
private startingOrg;
|
|
45
|
-
/**
|
|
46
|
-
* Read-only: of several refresh tokens (a cookie header carrying the legacy and the `Path=/`
|
|
47
|
-
* cookie), the first that is the current token of a live session, if any. Choosing before
|
|
48
|
-
* rotating keeps a stale token from tripping replay detection on a still valid session.
|
|
49
|
-
*/
|
|
50
|
-
pickCurrentRefresh(candidates: readonly string[]): Promise<string | undefined>;
|
|
51
45
|
refresh(refreshToken: string, meta: {
|
|
52
46
|
userAgent?: string;
|
|
53
47
|
ip?: string;
|
|
@@ -97,24 +97,6 @@ let SessionService = class SessionService {
|
|
|
97
97
|
return last.orgId;
|
|
98
98
|
return orgs.length === 1 ? (orgs[0]?.orgId ?? null) : null;
|
|
99
99
|
}
|
|
100
|
-
/**
|
|
101
|
-
* Read-only: of several refresh tokens (a cookie header carrying the legacy and the `Path=/`
|
|
102
|
-
* cookie), the first that is the current token of a live session, if any. Choosing before
|
|
103
|
-
* rotating keeps a stale token from tripping replay detection on a still valid session.
|
|
104
|
-
*/
|
|
105
|
-
async pickCurrentRefresh(candidates) {
|
|
106
|
-
if (candidates.length === 0)
|
|
107
|
-
return undefined;
|
|
108
|
-
const rows = await this.db
|
|
109
|
-
.selectFrom("sessions")
|
|
110
|
-
.select("refresh_hash")
|
|
111
|
-
.where("refresh_hash", "in", candidates.map((c) => sha256Hex(c)))
|
|
112
|
-
.where("revoked_at", "is", null)
|
|
113
|
-
.where("expires_at", ">", sql `now()`)
|
|
114
|
-
.execute();
|
|
115
|
-
const live = new Set(rows.map((r) => r.refresh_hash));
|
|
116
|
-
return candidates.find((c) => live.has(sha256Hex(c)));
|
|
117
|
-
}
|
|
118
100
|
async refresh(refreshToken, meta) {
|
|
119
101
|
const oldHash = sha256Hex(refreshToken);
|
|
120
102
|
const next = newRefreshToken();
|
|
@@ -29,6 +29,27 @@ export interface ScopeSyncFailureView {
|
|
|
29
29
|
message: string;
|
|
30
30
|
failedAt: string;
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* A live platform plugin (or an org's own) whose scope turns it on (`all` or `named`) while its
|
|
34
|
+
* extension is installed and approved but disabled on the deployment (a super admin disabled it, or
|
|
35
|
+
* its enable was refused because another enabled extension holds one of its single-provider
|
|
36
|
+
* extension points): the scope sync installs it nowhere until the extension is enabled, whose
|
|
37
|
+
* enable owes the sync. Derived from the current state at every read.
|
|
38
|
+
*/
|
|
39
|
+
export interface ExtensionDisabledView {
|
|
40
|
+
item: {
|
|
41
|
+
id: string;
|
|
42
|
+
name: string;
|
|
43
|
+
displayName: LocalizedName | null;
|
|
44
|
+
};
|
|
45
|
+
/** The extension's name (the plugin's) and its installed version. */
|
|
46
|
+
extension: {
|
|
47
|
+
name: string;
|
|
48
|
+
version: string;
|
|
49
|
+
};
|
|
50
|
+
/** When the extension's install record last changed (its disable, or its install). */
|
|
51
|
+
since: string;
|
|
52
|
+
}
|
|
32
53
|
/**
|
|
33
54
|
* One item of the super admin's inbox (by `type`). Nothing is decided in the inbox: each item is
|
|
34
55
|
* acted on where it lives (the web links to it).
|
|
@@ -39,6 +60,9 @@ export interface ScopeSyncFailureView {
|
|
|
39
60
|
* - `org_upload_pending`: an org-owned plugin whose uploaded version (with an extension) waits for
|
|
40
61
|
* the super admin in 待确认 (ruling P3-22; confirmed or rejected there), `id` = the item's;
|
|
41
62
|
* - `scope_sync_failed`: an open scope sync failure, `id` = `<itemId>/<orgId>`;
|
|
63
|
+
* - `extension_disabled`: a plugin its scope turns on whose extension is disabled on the deployment
|
|
64
|
+
* ({@link ExtensionDisabledView}), `id` = the item's; gone once the extension is enabled (or the
|
|
65
|
+
* scope no longer turns it on);
|
|
42
66
|
* - `ownership_transferred`: a deleted org's shared item now belongs to the platform, until a
|
|
43
67
|
* super admin dismisses it (`POST admin/inbox/notices/:id/dismiss`).
|
|
44
68
|
*/
|
|
@@ -62,6 +86,11 @@ export type PlatformInboxItem = {
|
|
|
62
86
|
id: string;
|
|
63
87
|
createdAt: string;
|
|
64
88
|
failure: ScopeSyncFailureView;
|
|
89
|
+
} | {
|
|
90
|
+
type: "extension_disabled";
|
|
91
|
+
id: string;
|
|
92
|
+
createdAt: string;
|
|
93
|
+
disabled: ExtensionDisabledView;
|
|
65
94
|
} | {
|
|
66
95
|
type: "ownership_transferred";
|
|
67
96
|
id: string;
|
|
@@ -69,7 +98,7 @@ export type PlatformInboxItem = {
|
|
|
69
98
|
notice: PlatformNoticeView;
|
|
70
99
|
};
|
|
71
100
|
/** Every {@link PlatformInboxItem} type, in the order the admin overview lists them. */
|
|
72
|
-
export declare const PLATFORM_INBOX_TYPES: readonly ["catalog_request", "permission_confirmation", "org_upload_pending", "scope_sync_failed", "ownership_transferred"];
|
|
101
|
+
export declare const PLATFORM_INBOX_TYPES: readonly ["catalog_request", "permission_confirmation", "org_upload_pending", "scope_sync_failed", "extension_disabled", "ownership_transferred"];
|
|
73
102
|
/** How many items of each type wait: every type, zeros included. */
|
|
74
103
|
export type PlatformInboxCounts = Record<PlatformInboxItem["type"], number>;
|
|
75
104
|
/** An open platform notice (`platform_notices`, kind `ownership_transferred`). */
|
|
@@ -115,6 +144,9 @@ export declare class PlatformInboxService {
|
|
|
115
144
|
* dismissed is fine; no notice with that id -> `inbox.notice_not_found`.
|
|
116
145
|
*/
|
|
117
146
|
dismissNotice(accountId: string, id: string): Promise<void>;
|
|
147
|
+
private countDisabledExtensions;
|
|
148
|
+
/** The plugins on by scope whose extension is disabled, newest change first. */
|
|
149
|
+
private disabledExtensions;
|
|
118
150
|
/**
|
|
119
151
|
* The open failures still worth a look, joined to their item and org: of a live item and org,
|
|
120
152
|
* and the pair still differs in the failed direction (a person may have converged it meanwhile):
|
|
@@ -10,6 +10,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
10
|
import { Inject, Injectable } from "@nestjs/common";
|
|
11
11
|
import { sql } from "kysely";
|
|
12
12
|
import { CatalogService } from "../catalog/catalog.service.js";
|
|
13
|
+
import { LIVE_INSTALL_STATUSES } from "../catalog/install-status.js";
|
|
13
14
|
import { CatalogRequestsService } from "../catalog/requests.service.js";
|
|
14
15
|
import { ApiError } from "../errors.js";
|
|
15
16
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
@@ -17,14 +18,13 @@ import { KernelDb } from "../infra/database/kernel-db.js";
|
|
|
17
18
|
export const PLATFORM_INBOX_MAX_ITEMS = 100;
|
|
18
19
|
/** The most open scope sync failures one read takes. */
|
|
19
20
|
export const SCOPE_SYNC_FAILURES_LIST_MAX = 200;
|
|
20
|
-
/** Plugin install statuses of a plugin that is on in the org. */
|
|
21
|
-
const LIVE_INSTALL = ["installing", "installed", "upgrading"];
|
|
22
21
|
/** Every {@link PlatformInboxItem} type, in the order the admin overview lists them. */
|
|
23
22
|
export const PLATFORM_INBOX_TYPES = [
|
|
24
23
|
"catalog_request",
|
|
25
24
|
"permission_confirmation",
|
|
26
25
|
"org_upload_pending",
|
|
27
26
|
"scope_sync_failed",
|
|
27
|
+
"extension_disabled",
|
|
28
28
|
"ownership_transferred",
|
|
29
29
|
];
|
|
30
30
|
/**
|
|
@@ -43,12 +43,14 @@ let PlatformInboxService = class PlatformInboxService {
|
|
|
43
43
|
this.kdb = kdb;
|
|
44
44
|
}
|
|
45
45
|
async list() {
|
|
46
|
-
const [requests, requestCount, pending, failures, failureCount, notices, noticeCount] = await Promise.all([
|
|
46
|
+
const [requests, requestCount, pending, failures, failureCount, disabled, disabledCount, notices, noticeCount,] = await Promise.all([
|
|
47
47
|
this.requests.listDeployment(),
|
|
48
48
|
this.requests.countPendingDeployment(),
|
|
49
49
|
this.catalog.list({ pending: true }),
|
|
50
50
|
this.scopeSyncFailures(),
|
|
51
51
|
this.countScopeSyncFailures(),
|
|
52
|
+
this.disabledExtensions(),
|
|
53
|
+
this.countDisabledExtensions(),
|
|
52
54
|
this.notices(),
|
|
53
55
|
this.countNotices(),
|
|
54
56
|
]);
|
|
@@ -71,6 +73,12 @@ let PlatformInboxService = class PlatformInboxService {
|
|
|
71
73
|
createdAt: f.failedAt,
|
|
72
74
|
failure: f,
|
|
73
75
|
})),
|
|
76
|
+
...disabled.map((d) => ({
|
|
77
|
+
type: "extension_disabled",
|
|
78
|
+
id: d.item.id,
|
|
79
|
+
createdAt: d.since,
|
|
80
|
+
disabled: d,
|
|
81
|
+
})),
|
|
74
82
|
...notices.map((n) => ({
|
|
75
83
|
type: "ownership_transferred",
|
|
76
84
|
id: n.id,
|
|
@@ -94,6 +102,7 @@ let PlatformInboxService = class PlatformInboxService {
|
|
|
94
102
|
permission_confirmation: pending.length - orgUploads,
|
|
95
103
|
org_upload_pending: orgUploads,
|
|
96
104
|
scope_sync_failed: failureCount,
|
|
105
|
+
extension_disabled: disabledCount,
|
|
97
106
|
ownership_transferred: noticeCount,
|
|
98
107
|
};
|
|
99
108
|
const total = Object.values(byType).reduce((a, b) => a + b, 0);
|
|
@@ -105,13 +114,14 @@ let PlatformInboxService = class PlatformInboxService {
|
|
|
105
114
|
* requests and the failures; the permission confirmations are the catalog's pending list).
|
|
106
115
|
*/
|
|
107
116
|
async count() {
|
|
108
|
-
const [requests, pending, failures, notices] = await Promise.all([
|
|
117
|
+
const [requests, pending, failures, disabled, notices] = await Promise.all([
|
|
109
118
|
this.requests.countPendingDeployment(),
|
|
110
119
|
this.catalog.list({ pending: true }),
|
|
111
120
|
this.countScopeSyncFailures(),
|
|
121
|
+
this.countDisabledExtensions(),
|
|
112
122
|
this.countNotices(),
|
|
113
123
|
]);
|
|
114
|
-
return requests + pending.length + failures + notices;
|
|
124
|
+
return requests + pending.length + failures + disabled + notices;
|
|
115
125
|
}
|
|
116
126
|
async countNotices() {
|
|
117
127
|
const r = await this.kdb.db
|
|
@@ -161,6 +171,26 @@ let PlatformInboxService = class PlatformInboxService {
|
|
|
161
171
|
if (!exists)
|
|
162
172
|
throw new ApiError("inbox.notice_not_found", "Notice not found");
|
|
163
173
|
}
|
|
174
|
+
async countDisabledExtensions() {
|
|
175
|
+
const r = await disabledExtensionRows(this.kdb)
|
|
176
|
+
.select(sql `count(*)`.as("n"))
|
|
177
|
+
.executeTakeFirstOrThrow();
|
|
178
|
+
return Number(r.n);
|
|
179
|
+
}
|
|
180
|
+
/** The plugins on by scope whose extension is disabled, newest change first. */
|
|
181
|
+
async disabledExtensions() {
|
|
182
|
+
const rows = await disabledExtensionRows(this.kdb)
|
|
183
|
+
.select(["i.id", "i.name", "i.display_name", "e.version", "e.updated_at"])
|
|
184
|
+
.orderBy("e.updated_at", "desc")
|
|
185
|
+
.orderBy("i.id")
|
|
186
|
+
.limit(PLATFORM_INBOX_MAX_ITEMS)
|
|
187
|
+
.execute();
|
|
188
|
+
return rows.map((r) => ({
|
|
189
|
+
item: { id: r.id, name: r.name, displayName: r.display_name },
|
|
190
|
+
extension: { name: r.name, version: r.version },
|
|
191
|
+
since: r.updated_at.toISOString(),
|
|
192
|
+
}));
|
|
193
|
+
}
|
|
164
194
|
/**
|
|
165
195
|
* The open failures still worth a look, joined to their item and org: of a live item and org,
|
|
166
196
|
* and the pair still differs in the failed direction (a person may have converged it meanwhile):
|
|
@@ -180,7 +210,7 @@ let PlatformInboxService = class PlatformInboxService {
|
|
|
180
210
|
.select("p.id")
|
|
181
211
|
.whereRef("p.org_id", "=", "f.org_id")
|
|
182
212
|
.whereRef("p.item_id", "=", "f.item_id")
|
|
183
|
-
.where("p.status", "in", [...
|
|
213
|
+
.where("p.status", "in", [...LIVE_INSTALL_STATUSES]));
|
|
184
214
|
return eb.or([
|
|
185
215
|
eb.and([eb("f.op", "=", "install"), eb.not(live)]),
|
|
186
216
|
eb.and([eb("f.op", "in", ["uninstall", "dependencies"]), live]),
|
|
@@ -229,4 +259,24 @@ PlatformInboxService = __decorate([
|
|
|
229
259
|
__param(2, Inject(KernelDb))
|
|
230
260
|
], PlatformInboxService);
|
|
231
261
|
export { PlatformInboxService };
|
|
262
|
+
/**
|
|
263
|
+
* The rows of {@link ExtensionDisabledView}: a live, usable, not builtin, not disabled item whose
|
|
264
|
+
* scope is not `optional`, joined to its extension's install record (same name) that is disabled
|
|
265
|
+
* and approved (a permission snapshot exists; an unapproved one is a permission confirmation).
|
|
266
|
+
*/
|
|
267
|
+
function disabledExtensionRows(kdb) {
|
|
268
|
+
return kdb.db
|
|
269
|
+
.selectFrom("catalog_items as i")
|
|
270
|
+
.innerJoin("extension_installs as e", "e.name", "i.name")
|
|
271
|
+
.where("i.deleted_at", "is", null)
|
|
272
|
+
.where("i.builtin", "=", false)
|
|
273
|
+
.where("i.disabled", "=", false)
|
|
274
|
+
.where("i.awaiting_confirmation", "=", false)
|
|
275
|
+
.where("i.scope", "<>", "optional")
|
|
276
|
+
.where("e.desired_state", "=", "disabled")
|
|
277
|
+
.where((eb) => eb.exists(eb
|
|
278
|
+
.selectFrom("extension_permission_snapshots as s")
|
|
279
|
+
.select("s.plugin")
|
|
280
|
+
.whereRef("s.plugin", "=", "e.name")));
|
|
281
|
+
}
|
|
232
282
|
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { closeKernelApp, createKernelApp, type KernelAppOptions, kernelAppHttp,
|
|
|
3
3
|
export { type CatalogCli, openCatalogCli } from "./catalog/cli.js";
|
|
4
4
|
export { GitSourceError, type ReadGitTreeOptions, readGitTree, } from "./catalog/git-source.js";
|
|
5
5
|
export type { PluginConfirmResult, PluginReview } from "./catalog/plugin-import.js";
|
|
6
|
-
export {
|
|
6
|
+
export { type PluginPackage, PluginPackageError, type ReadPluginPackageOptions, readPluginPackage, } from "./catalog/plugin-package.js";
|
|
7
7
|
export { gatewayReplicasKey } from "./channels/supervisor.js";
|
|
8
8
|
export { envName, renderConfigDocs } from "./config/docs.js";
|
|
9
9
|
export { envOverrides } from "./config/env.js";
|
|
@@ -19,7 +19,7 @@ export { createExtensionContext, type KernelDeps, pluginSchemaName, type Route,
|
|
|
19
19
|
export { createKv } from "./ctx/kv.js";
|
|
20
20
|
export { createLock } from "./ctx/lock.js";
|
|
21
21
|
export { createQueue } from "./ctx/queue.js";
|
|
22
|
-
export { createKeyring, createSecrets, type DerivedKeys, type Keyring,
|
|
22
|
+
export { createKeyring, createSecrets, type DerivedKeys, type Keyring, REWRAP_BATCH_SIZE, type RewrapResult, rewrapToCurrentMasterKey, } from "./ctx/secrets.js";
|
|
23
23
|
export { type KernelDatabase, type KernelSchemaDb, kernelDb } from "./db/kernel-schema.js";
|
|
24
24
|
export { type MigrationOwner, migrate } from "./db/migrator.js";
|
|
25
25
|
export { createDb } from "./db/pool.js";
|
|
@@ -54,6 +54,8 @@ export { DUMMY_PASSWORD_HASH, hashPassword, verifyPassword } from "./identity/pa
|
|
|
54
54
|
export { type IssuedSession, REFRESH_RACE_GRACE_MS, SessionService, } from "./identity/sessions.js";
|
|
55
55
|
export { DEPLOYMENT_SETTINGS, type DeploymentSettings, SettingsService, } from "./identity/settings.js";
|
|
56
56
|
export { type KernelCliOptions, openKernelCli, openKernelCliOverPool, } from "./infra/cli/kernel-cli.module.js";
|
|
57
|
+
export { rewrapMasterKeys } from "./infra/cli/master-key-rewrap.js";
|
|
58
|
+
export { onProcessFault } from "./infra/health/process-fault.js";
|
|
57
59
|
export { GUARD_CIRCUIT_LIMIT, GUARD_CIRCUIT_WINDOW_MS, installProcessGuards, type ProcessGuardDeps, } from "./infra/lifecycle/process-guards.js";
|
|
58
60
|
export { handleShutdownSignals, type ShutdownSignalHandle, type ShutdownSignalOptions, } from "./infra/lifecycle/shutdown-signals.js";
|
|
59
61
|
export { KERNEL_MIGRATIONS_DIR, KERNEL_SCHEMA, migrateAll } from "./kernel.js";
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export { closeKernelApp, createKernelApp, kernelAppHttp, kernelAppPort, startKer
|
|
|
3
3
|
export { openCatalogCli } from "./catalog/cli.js";
|
|
4
4
|
// The git reader marketplaces use; core's check:bootstrap reads the official marketplace with it.
|
|
5
5
|
export { GitSourceError, readGitTree, } from "./catalog/git-source.js";
|
|
6
|
-
export {
|
|
6
|
+
export { PluginPackageError, readPluginPackage, } from "./catalog/plugin-package.js";
|
|
7
7
|
export { gatewayReplicasKey } from "./channels/supervisor.js";
|
|
8
8
|
export { envName, renderConfigDocs } from "./config/docs.js";
|
|
9
9
|
export { envOverrides } from "./config/env.js";
|
|
@@ -18,7 +18,7 @@ export { createExtensionContext, pluginSchemaName, } from "./ctx/create-ctx.js";
|
|
|
18
18
|
export { createKv } from "./ctx/kv.js";
|
|
19
19
|
export { createLock } from "./ctx/lock.js";
|
|
20
20
|
export { createQueue } from "./ctx/queue.js";
|
|
21
|
-
export { createKeyring, createSecrets,
|
|
21
|
+
export { createKeyring, createSecrets, REWRAP_BATCH_SIZE, rewrapToCurrentMasterKey, } from "./ctx/secrets.js";
|
|
22
22
|
export { kernelDb } from "./db/kernel-schema.js";
|
|
23
23
|
export { migrate } from "./db/migrator.js";
|
|
24
24
|
export { createDb } from "./db/pool.js";
|
|
@@ -52,6 +52,8 @@ export { DUMMY_PASSWORD_HASH, hashPassword, verifyPassword } from "./identity/pa
|
|
|
52
52
|
export { REFRESH_RACE_GRACE_MS, SessionService, } from "./identity/sessions.js";
|
|
53
53
|
export { DEPLOYMENT_SETTINGS, SettingsService, } from "./identity/settings.js";
|
|
54
54
|
export { openKernelCli, openKernelCliOverPool, } from "./infra/cli/kernel-cli.module.js";
|
|
55
|
+
export { rewrapMasterKeys } from "./infra/cli/master-key-rewrap.js";
|
|
56
|
+
export { onProcessFault } from "./infra/health/process-fault.js";
|
|
55
57
|
export { GUARD_CIRCUIT_LIMIT, GUARD_CIRCUIT_WINDOW_MS, installProcessGuards, } from "./infra/lifecycle/process-guards.js";
|
|
56
58
|
export { handleShutdownSignals, } from "./infra/lifecycle/shutdown-signals.js";
|
|
57
59
|
export { KERNEL_MIGRATIONS_DIR, KERNEL_SCHEMA, migrateAll } from "./kernel.js";
|