@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
|
@@ -9,7 +9,6 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
9
9
|
};
|
|
10
10
|
import { Inject, Injectable, Optional } from "@nestjs/common";
|
|
11
11
|
import { ApiError } from "../errors.js";
|
|
12
|
-
import { ExtensionLifecycle } from "../extensions/lifecycle.js";
|
|
13
12
|
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
14
13
|
import { audit } from "../identity/audit.js";
|
|
15
14
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
@@ -19,10 +18,11 @@ import { LockService } from "../infra/lock/lock.service.js";
|
|
|
19
18
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
20
19
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
21
20
|
import { connectorTemplatesOn, templateIdOfPath } from "./component-state.js";
|
|
21
|
+
import { LIVE_INSTALL_STATUSES } from "./install-status.js";
|
|
22
22
|
import { isUsable } from "./ownership.js";
|
|
23
23
|
import { PluginInstaller } from "./plugin-install.js";
|
|
24
24
|
import { wantedOn } from "./scope.js";
|
|
25
|
-
import { oweScopeItem, PLUGIN_SCOPE_QUEUE,
|
|
25
|
+
import { oweScopeItem, PLUGIN_SCOPE_QUEUE, SCOPE_CHUNK_JOB, SCOPE_ORG_CHUNK, SCOPE_ORG_CHUNK_SIZE, SCOPE_ORG_JOB, scopeChunkJobId, scopeOrgJobId, } from "./scope-jobs.js";
|
|
26
26
|
import { ScopeNoLongerWanted, ScopeStillWanted } from "./scope-state.js";
|
|
27
27
|
/**
|
|
28
28
|
* The plugin scope sync (plugin and component management spec §5, phase 1): converges every org
|
|
@@ -44,100 +44,84 @@ import { ScopeNoLongerWanted, ScopeStillWanted } from "./scope-state.js";
|
|
|
44
44
|
* extension). A failed install, uninstall or dependency install is logged, audited
|
|
45
45
|
* `plugin.scope_sync_failed`, kept as the pair's open failure (`plugin_scope_sync_failures`, the
|
|
46
46
|
* super admin's inbox, until a later sync of the pair does not fail) and not retried until the next
|
|
47
|
-
*
|
|
48
|
-
* touching the pair's row, so an older failure stays open.
|
|
47
|
+
* sync of the item. An error outside those steps (a read, the failure write itself) ends the attempt
|
|
48
|
+
* without touching the pair's row, so an older failure stays open.
|
|
49
49
|
*
|
|
50
|
-
* Jobs (queue {@link PLUGIN_SCOPE_QUEUE})
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
50
|
+
* Jobs (queue {@link PLUGIN_SCOPE_QUEUE}), all owed through the outbox (transactional outbox spec
|
|
51
|
+
* §8.1), so none is lost:
|
|
52
|
+
* - `scope-item` (`scope-item-<itemId>-x<xact>`, one per owing transaction): owed by every
|
|
53
|
+
* transaction that changes what the item's sync converges to: its scope, disabled flag, list,
|
|
54
|
+
* owner or platform version, an import's commit that deploys no extension, and the deploy of its
|
|
55
|
+
* extension (`oweDeployedExtensionSync`: enabled, a new version of an enabled one, permissions
|
|
56
|
+
* approved). It fans out: one `scope-item-chunk` per chunk of orgs (`<item job id>-c<n>`, at
|
|
57
|
+
* most {@link SCOPE_ORG_CHUNK} orgs each), all owed in one transaction;
|
|
58
|
+
* - `scope-item-chunk`: converges the item in its orgs;
|
|
59
|
+
* - `scope-org` (`scope-org-<orgId>`): every item in one org, owed by the org's creation.
|
|
60
|
+
* A migration that changes a scope inserts its outbox rows itself. One BullMQ retry policy
|
|
61
|
+
* (registry): a chunk or org job whose extension is enabled on the deployment but not loaded on
|
|
62
|
+
* this replica yet fails after converging its other pairs, so BullMQ retries it with its backoff
|
|
63
|
+
* (on any replica); its last attempt installs anyway and records what fails. Pairs of one org are
|
|
64
|
+
* serialized across replicas by a Redis lock per org; the installer's org row lock and its
|
|
65
|
+
* one-live-install rule are the backstop.
|
|
59
66
|
*/
|
|
60
|
-
export { PLUGIN_SCOPE_QUEUE,
|
|
61
|
-
/** How many delayed retries an item job gets while its extension is not loaded here (P3-38). */
|
|
62
|
-
export const SCOPE_LOAD_RETRIES = 6;
|
|
63
|
-
/** The delay of each such retry. */
|
|
64
|
-
export const SCOPE_LOAD_RETRY_DELAY_MS = 5_000;
|
|
65
|
-
/** How long a pair waits for this replica's reconcile before deferring (P3-38). */
|
|
66
|
-
export const SCOPE_RECONCILE_WAIT_MS = 10_000;
|
|
67
|
+
export { PLUGIN_SCOPE_QUEUE, SCOPE_CHUNK_JOB, SCOPE_ITEM_JOB, SCOPE_ORG_CHUNK, SCOPE_ORG_CHUNK_SIZE, SCOPE_ORG_JOB, scopeChunkJobId, scopeItemJobId, scopeOrgJobId, } from "./scope-jobs.js";
|
|
67
68
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
69
|
+
* A chunk or org job with a pair whose extension this replica has not loaded yet (P3-38): thrown
|
|
70
|
+
* after its other pairs converged, so BullMQ retries the job with its backoff.
|
|
70
71
|
*/
|
|
71
|
-
export
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
timer = setTimeout(resolve, ms);
|
|
78
|
-
}),
|
|
79
|
-
]);
|
|
80
|
-
}
|
|
81
|
-
catch (err) {
|
|
82
|
-
log.warn("reconciling extensions on this replica failed", { reason, err });
|
|
83
|
-
}
|
|
84
|
-
finally {
|
|
85
|
-
if (timer !== undefined)
|
|
86
|
-
clearTimeout(timer);
|
|
72
|
+
export class ScopeSyncDeferred extends Error {
|
|
73
|
+
itemIds;
|
|
74
|
+
constructor(itemIds) {
|
|
75
|
+
super(`the extension of catalog item(s) ${itemIds.join(", ")} is enabled on the deployment but not loaded on this replica yet; the scope sync job is retried`);
|
|
76
|
+
this.itemIds = itemIds;
|
|
77
|
+
this.name = "ScopeSyncDeferred";
|
|
87
78
|
}
|
|
88
79
|
}
|
|
89
80
|
/** How long one org's pairs wait for each other (an install can take a while). */
|
|
90
81
|
const ORG_LOCK_TTL_MS = 60_000;
|
|
91
82
|
const ORG_LOCK_WAIT_MS = 10 * 60_000;
|
|
92
|
-
/** The worker's concurrency. */
|
|
83
|
+
/** The worker's concurrency (per replica): how many chunk, item and org jobs run at once. */
|
|
93
84
|
export const PLUGIN_SCOPE_CONCURRENCY = 2;
|
|
94
|
-
|
|
85
|
+
/** `ids` in chunks of `size` (the last one shorter). */
|
|
86
|
+
export function chunked(ids, size) {
|
|
87
|
+
if (!Number.isInteger(size) || size < 1)
|
|
88
|
+
throw new Error(`invalid chunk size ${size}`);
|
|
89
|
+
const out = [];
|
|
90
|
+
for (let i = 0; i < ids.length; i += size)
|
|
91
|
+
out.push(ids.slice(i, i + size));
|
|
92
|
+
return out;
|
|
93
|
+
}
|
|
95
94
|
let PluginScopeSync = class PluginScopeSync {
|
|
96
95
|
kdb;
|
|
97
96
|
outbox;
|
|
98
97
|
installer;
|
|
99
98
|
registry;
|
|
100
|
-
lifecycle;
|
|
101
99
|
locks;
|
|
102
100
|
log;
|
|
103
101
|
txHost;
|
|
104
|
-
|
|
105
|
-
constructor(kdb, outbox, installer, registry,
|
|
106
|
-
/**
|
|
107
|
-
|
|
108
|
-
/** The backstop's delay (a test seam; default {@link SCOPE_BACKSTOP_DELAY_MS}). */
|
|
109
|
-
backstopDelayMs = SCOPE_BACKSTOP_DELAY_MS) {
|
|
102
|
+
chunkSize;
|
|
103
|
+
constructor(kdb, outbox, installer, registry, locks, log, txHost,
|
|
104
|
+
/** Orgs per chunk job (a test seam; default {@link SCOPE_ORG_CHUNK}). */
|
|
105
|
+
chunkSize = SCOPE_ORG_CHUNK) {
|
|
110
106
|
this.kdb = kdb;
|
|
111
107
|
this.outbox = outbox;
|
|
112
108
|
this.installer = installer;
|
|
113
109
|
this.registry = registry;
|
|
114
|
-
this.lifecycle = lifecycle;
|
|
115
110
|
this.locks = locks;
|
|
116
111
|
this.log = log;
|
|
117
112
|
this.txHost = txHost;
|
|
118
|
-
this.
|
|
113
|
+
this.chunkSize = chunkSize;
|
|
119
114
|
}
|
|
120
115
|
get db() {
|
|
121
116
|
return this.kdb.db;
|
|
122
117
|
}
|
|
123
118
|
/**
|
|
124
|
-
* Owes the sync of an item in every org
|
|
125
|
-
*
|
|
119
|
+
* Owes the sync of an item in every org in the transaction in context (one job per
|
|
120
|
+
* transaction), the transaction that changes what it converges to.
|
|
126
121
|
*/
|
|
127
122
|
async enqueueItem(itemId) {
|
|
128
123
|
await oweScopeItem(this.outbox, this.db, itemId);
|
|
129
124
|
}
|
|
130
|
-
/**
|
|
131
|
-
* Owes the delayed backstop of the item's sync (ruling R24) in the transaction in context: a
|
|
132
|
-
* confirmation owes it before (or with) its deploy, so a crash before its post-deploy add still
|
|
133
|
-
* converges the orgs.
|
|
134
|
-
*/
|
|
135
|
-
async enqueueBackstop(itemId) {
|
|
136
|
-
await oweScopeItem(this.outbox, this.db, itemId, {
|
|
137
|
-
backstop: true,
|
|
138
|
-
backstopDelayMs: this.backstopDelayMs,
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
125
|
/** Owes the sync of every item in an org, in the transaction that creates the org. */
|
|
142
126
|
async enqueueOrg(orgId) {
|
|
143
127
|
await this.outbox.add({
|
|
@@ -149,19 +133,17 @@ let PluginScopeSync = class PluginScopeSync {
|
|
|
149
133
|
});
|
|
150
134
|
}
|
|
151
135
|
/**
|
|
152
|
-
* One job:
|
|
153
|
-
*
|
|
136
|
+
* One job: an item job fans out to its chunk jobs; a chunk job converges the item in its orgs,
|
|
137
|
+
* an org job every item in the org. A pair deferred because its extension is not loaded here
|
|
138
|
+
* fails the job after the others ({@link ScopeSyncDeferred}), unless this is its last attempt.
|
|
154
139
|
*/
|
|
155
|
-
async process(data,
|
|
156
|
-
if (data.kind === "item"
|
|
157
|
-
await this.
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
.where("deleted_at", "is", null)
|
|
163
|
-
.orderBy("id")
|
|
164
|
-
.execute()).map((o) => [data.itemId, o.id])
|
|
140
|
+
async process(data, run) {
|
|
141
|
+
if (data.kind === "item") {
|
|
142
|
+
await this.fanOut(data.itemId, run.jobId);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const pairs = data.kind === "chunk"
|
|
146
|
+
? data.orgIds.map((orgId) => [data.itemId, orgId])
|
|
165
147
|
: (await this.db
|
|
166
148
|
.selectFrom("catalog_items")
|
|
167
149
|
.select("id")
|
|
@@ -169,14 +151,15 @@ let PluginScopeSync = class PluginScopeSync {
|
|
|
169
151
|
.where("builtin", "=", false)
|
|
170
152
|
.orderBy("id")
|
|
171
153
|
.execute()).map((i) => [i.id, data.orgId]);
|
|
172
|
-
const retry = data.kind === "item" ? (data.retry ?? 0) : 0;
|
|
173
|
-
const finalTry = data.kind === "item" && retry >= SCOPE_LOAD_RETRIES;
|
|
174
154
|
const deferred = new Set();
|
|
175
155
|
for (const [itemId, orgId] of pairs) {
|
|
176
|
-
|
|
177
|
-
|
|
156
|
+
// Stopped between pairs: failed, so BullMQ retries the job (on this or another replica).
|
|
157
|
+
// On the job's last attempt nothing retries it: the pairs not reached yet are dropped
|
|
158
|
+
// until the next sync of the item or org (a scope change, a deploy, a new org) owes them
|
|
159
|
+
if (run.signal?.aborted)
|
|
160
|
+
throw new Error("the plugin scope worker stopped; the job is retried");
|
|
178
161
|
try {
|
|
179
|
-
const r = await this.syncPair(itemId, orgId, signal, { finalTry });
|
|
162
|
+
const r = await this.syncPair(itemId, orgId, run.signal, { finalTry: run.finalAttempt });
|
|
180
163
|
if (r === "deferred")
|
|
181
164
|
deferred.add(itemId);
|
|
182
165
|
}
|
|
@@ -184,86 +167,41 @@ let PluginScopeSync = class PluginScopeSync {
|
|
|
184
167
|
this.log.warn("plugin scope sync of a pair failed", { itemId, orgId, err });
|
|
185
168
|
}
|
|
186
169
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
try {
|
|
190
|
-
await this.enqueueRetry(itemId, retry + 1);
|
|
191
|
-
}
|
|
192
|
-
catch (err) {
|
|
193
|
-
this.log.warn("enqueueing a delayed plugin scope sync failed", { itemId, err });
|
|
194
|
-
}
|
|
195
|
-
}
|
|
170
|
+
if (deferred.size > 0)
|
|
171
|
+
throw new ScopeSyncDeferred([...deferred]);
|
|
196
172
|
}
|
|
197
173
|
/**
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
* attempts) and no pair records a `catalog.not_deployed` failure that nothing would retry. An item without an
|
|
201
|
-
* extension, or one no longer live (deleted, disabled, still waiting, builtin), passes: its pairs
|
|
202
|
-
* converge (or change nothing) as for an immediate job.
|
|
174
|
+
* Owes one chunk job per {@link chunkSize} live orgs of the item job `jobId`, in one
|
|
175
|
+
* transaction (a redelivered item job owes the same ids again: deduped).
|
|
203
176
|
*/
|
|
204
|
-
async
|
|
177
|
+
async fanOut(itemId, jobId) {
|
|
205
178
|
const item = await this.db
|
|
206
179
|
.selectFrom("catalog_items")
|
|
207
|
-
.select(
|
|
208
|
-
"builtin",
|
|
209
|
-
"disabled",
|
|
210
|
-
"deleted_at",
|
|
211
|
-
"awaiting_confirmation",
|
|
212
|
-
"latest_version",
|
|
213
|
-
"platform_synced_version",
|
|
214
|
-
])
|
|
215
|
-
.where("id", "=", itemId)
|
|
216
|
-
.executeTakeFirst();
|
|
217
|
-
if (!item || item.builtin || !isUsable(item))
|
|
218
|
-
return;
|
|
219
|
-
const version = item.platform_synced_version ?? item.latest_version;
|
|
220
|
-
const v = await this.db
|
|
221
|
-
.selectFrom("catalog_item_versions")
|
|
222
|
-
.select("manifest")
|
|
223
|
-
.where("item_id", "=", itemId)
|
|
224
|
-
.where("version", "=", version)
|
|
225
|
-
.executeTakeFirst();
|
|
226
|
-
const m = v?.manifest;
|
|
227
|
-
if (!m?.extension)
|
|
228
|
-
return;
|
|
229
|
-
// loaded here (a config-declared extension has no install record), or enabled on the
|
|
230
|
-
// deployment (a replica that has not loaded it yet defers as P3-38 says)
|
|
231
|
-
if (this.registry.manifests().some((x) => x.name === m.name))
|
|
232
|
-
return;
|
|
233
|
-
const install = await this.db
|
|
234
|
-
.selectFrom("extension_installs")
|
|
235
|
-
.select("desired_state")
|
|
236
|
-
.where("name", "=", m.name)
|
|
237
|
-
.executeTakeFirst();
|
|
238
|
-
if (install?.desired_state === "enabled")
|
|
239
|
-
return;
|
|
240
|
-
throw new Error(`the extension ${m.name} of catalog item ${itemId} is not enabled on the deployment yet; the scope sync backstop is retried`);
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Owes the delayed retry `n` of an item job (deterministic id, P3-38) in a transaction of its
|
|
244
|
-
* own: the job's own follow-up, delivered by the relay once due.
|
|
245
|
-
*/
|
|
246
|
-
async enqueueRetry(itemId, n) {
|
|
247
|
-
const row = await this.db
|
|
248
|
-
.selectFrom("catalog_items")
|
|
249
|
-
.select("scope_version")
|
|
180
|
+
.select("id")
|
|
250
181
|
.where("id", "=", itemId)
|
|
182
|
+
.where("deleted_at", "is", null)
|
|
251
183
|
.executeTakeFirst();
|
|
252
|
-
if (!
|
|
184
|
+
if (!item)
|
|
253
185
|
return;
|
|
254
|
-
await this.
|
|
186
|
+
const orgs = await this.db
|
|
187
|
+
.selectFrom("orgs")
|
|
188
|
+
.select("id")
|
|
189
|
+
.where("deleted_at", "is", null)
|
|
190
|
+
.orderBy("id")
|
|
191
|
+
.execute();
|
|
192
|
+
const chunks = chunked(orgs.map((o) => o.id), this.chunkSize);
|
|
193
|
+
await this.outbox.addMany(chunks.map((orgIds, n) => ({
|
|
255
194
|
queue: PLUGIN_SCOPE_QUEUE,
|
|
256
|
-
name:
|
|
257
|
-
jobId:
|
|
258
|
-
data: { kind: "
|
|
259
|
-
|
|
260
|
-
});
|
|
195
|
+
name: SCOPE_CHUNK_JOB,
|
|
196
|
+
jobId: scopeChunkJobId(jobId, n),
|
|
197
|
+
data: { kind: "chunk", itemId, orgIds },
|
|
198
|
+
})));
|
|
261
199
|
}
|
|
262
200
|
/**
|
|
263
201
|
* Whether the install of the item's `version` may go ahead on this replica (P3-38): its
|
|
264
202
|
* extension is loaded here, or it is not enabled on the deployment (the install reports
|
|
265
|
-
* `catalog.not_deployed` as before). Enabled but not loaded here
|
|
266
|
-
*
|
|
203
|
+
* `catalog.not_deployed` as before). Enabled but not loaded here (its deploy owed this sync, and
|
|
204
|
+
* this replica's reconcile has not caught up yet) -> false, unless this is the job's last try.
|
|
267
205
|
*/
|
|
268
206
|
async extensionReady(itemId, version, finalTry) {
|
|
269
207
|
const v = await this.db
|
|
@@ -275,18 +213,14 @@ let PluginScopeSync = class PluginScopeSync {
|
|
|
275
213
|
const m = v?.manifest;
|
|
276
214
|
if (!m?.extension)
|
|
277
215
|
return true;
|
|
278
|
-
|
|
279
|
-
if (loaded())
|
|
216
|
+
if (this.registry.manifests().some((x) => x.name === m.name))
|
|
280
217
|
return true;
|
|
281
218
|
const install = await this.db
|
|
282
219
|
.selectFrom("extension_installs")
|
|
283
220
|
.select("desired_state")
|
|
284
221
|
.where("name", "=", m.name)
|
|
285
222
|
.executeTakeFirst();
|
|
286
|
-
|
|
287
|
-
return true;
|
|
288
|
-
await reconcileWithin(this.lifecycle, `scope-sync:${m.name}`, SCOPE_RECONCILE_WAIT_MS, this.log);
|
|
289
|
-
return loaded() || finalTry;
|
|
223
|
+
return install?.desired_state !== "enabled" || finalTry;
|
|
290
224
|
}
|
|
291
225
|
/** Converges one (item, org), under the org's sync lock; `signal` ends the wait for it. */
|
|
292
226
|
syncPair(itemId, orgId, signal, opts = {}) {
|
|
@@ -356,7 +290,7 @@ let PluginScopeSync = class PluginScopeSync {
|
|
|
356
290
|
.select(["id", "status"])
|
|
357
291
|
.where("org_id", "=", orgId)
|
|
358
292
|
.where("item_id", "=", itemId)
|
|
359
|
-
.where("status", "in", [...
|
|
293
|
+
.where("status", "in", [...LIVE_INSTALL_STATUSES])
|
|
360
294
|
.executeTakeFirst(),
|
|
361
295
|
]);
|
|
362
296
|
const wanted = wantedOn(item, listed !== undefined, sw?.enabled ?? null) ||
|
|
@@ -402,8 +336,8 @@ let PluginScopeSync = class PluginScopeSync {
|
|
|
402
336
|
return "unchanged";
|
|
403
337
|
}
|
|
404
338
|
}
|
|
405
|
-
// Wanted off: only a settled install is removed (one still installing
|
|
406
|
-
//
|
|
339
|
+
// Wanted off: only a settled install is removed (one still installing waits for the next
|
|
340
|
+
// enqueue)
|
|
407
341
|
if (live?.status !== "installed")
|
|
408
342
|
return "unchanged";
|
|
409
343
|
const deps = await this.createdDependencies(live.id);
|
|
@@ -432,7 +366,7 @@ let PluginScopeSync = class PluginScopeSync {
|
|
|
432
366
|
.innerJoin("plugin_installs as a", "a.id", "c.install_id")
|
|
433
367
|
.select("a.id")
|
|
434
368
|
.where("a.org_id", "=", orgId)
|
|
435
|
-
.where("a.status", "in", [...
|
|
369
|
+
.where("a.status", "in", [...LIVE_INSTALL_STATUSES])
|
|
436
370
|
.where("c.kind", "=", "plugin")
|
|
437
371
|
.where("c.ref", "=", installId)
|
|
438
372
|
.executeTakeFirst();
|
|
@@ -540,15 +474,12 @@ let PluginScopeSync = class PluginScopeSync {
|
|
|
540
474
|
__decorate([
|
|
541
475
|
Transactional({ propagation: "mandatory" })
|
|
542
476
|
], PluginScopeSync.prototype, "enqueueItem", null);
|
|
543
|
-
__decorate([
|
|
544
|
-
Transactional({ propagation: "mandatory" })
|
|
545
|
-
], PluginScopeSync.prototype, "enqueueBackstop", null);
|
|
546
477
|
__decorate([
|
|
547
478
|
Transactional({ propagation: "mandatory" })
|
|
548
479
|
], PluginScopeSync.prototype, "enqueueOrg", null);
|
|
549
480
|
__decorate([
|
|
550
481
|
Transactional()
|
|
551
|
-
], PluginScopeSync.prototype, "
|
|
482
|
+
], PluginScopeSync.prototype, "fanOut", null);
|
|
552
483
|
__decorate([
|
|
553
484
|
Transactional({ propagation: "requires_new" })
|
|
554
485
|
], PluginScopeSync.prototype, "recordFailure", null);
|
|
@@ -558,11 +489,10 @@ PluginScopeSync = __decorate([
|
|
|
558
489
|
__param(1, Inject(OutboxService)),
|
|
559
490
|
__param(2, Inject(PluginInstaller)),
|
|
560
491
|
__param(3, Inject(ExtensionRegistry)),
|
|
561
|
-
__param(4, Inject(
|
|
562
|
-
__param(5, Inject(
|
|
563
|
-
__param(6, Inject(
|
|
564
|
-
__param(7,
|
|
565
|
-
__param(
|
|
566
|
-
__param(8, Inject(SCOPE_BACKSTOP_DELAY))
|
|
492
|
+
__param(4, Inject(LockService)),
|
|
493
|
+
__param(5, Inject(KERNEL_LOGGER)),
|
|
494
|
+
__param(6, Inject(TransactionHost)),
|
|
495
|
+
__param(7, Optional()),
|
|
496
|
+
__param(7, Inject(SCOPE_ORG_CHUNK_SIZE))
|
|
567
497
|
], PluginScopeSync);
|
|
568
498
|
export { PluginScopeSync };
|
|
@@ -3,8 +3,8 @@ import { type ComponentRow } from "./component-state.js";
|
|
|
3
3
|
import type { PluginScope } from "./scope.js";
|
|
4
4
|
/**
|
|
5
5
|
* Narrows an org-owned plugin (row locked by the caller) whose scope is `optional` / `all` to
|
|
6
|
-
* `named` = owner + the live orgs with a live install or a switch on.
|
|
7
|
-
*
|
|
6
|
+
* `named` = owner + the live orgs with a live install or a switch on. Audits
|
|
7
|
+
* `catalog.scope_changed`; returns whether the scope changed (the caller enqueues the item's
|
|
8
8
|
* scope sync after the commit).
|
|
9
9
|
*/
|
|
10
10
|
export declare function narrowItemOnUnshare(db: KernelSchemaDb, actor: string | null, item: {
|
|
@@ -16,7 +16,6 @@ export declare function narrowItemOnUnshare(db: KernelSchemaDb, actor: string |
|
|
|
16
16
|
/**
|
|
17
17
|
* Narrows an org-owned component with its own `optional` / `all` scope (row locked by the caller)
|
|
18
18
|
* to `named` = owner + the live orgs where it is on now ({@link componentOn}). A component that
|
|
19
|
-
* follows its plugin is narrowed with the plugin.
|
|
20
|
-
* `component.scope_changed`.
|
|
19
|
+
* follows its plugin is narrowed with the plugin. Audits `component.scope_changed`.
|
|
21
20
|
*/
|
|
22
21
|
export declare function narrowComponentOnUnshare(db: KernelSchemaDb, actor: string | null, c: ComponentRow): Promise<boolean>;
|
package/dist/catalog/unshare.js
CHANGED
|
@@ -6,15 +6,15 @@
|
|
|
6
6
|
import { sql } from "kysely";
|
|
7
7
|
import { audit } from "../identity/audit.js";
|
|
8
8
|
import { componentOn, listedIn, loadScopeState, pluginFactsOf, switchOf, } from "./component-state.js";
|
|
9
|
-
|
|
9
|
+
import { LIVE_INSTALL_STATUSES } from "./install-status.js";
|
|
10
10
|
async function liveOrgIds(db) {
|
|
11
11
|
const rows = await db.selectFrom("orgs").select("id").where("deleted_at", "is", null).execute();
|
|
12
12
|
return rows.map((r) => r.id);
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* Narrows an org-owned plugin (row locked by the caller) whose scope is `optional` / `all` to
|
|
16
|
-
* `named` = owner + the live orgs with a live install or a switch on.
|
|
17
|
-
*
|
|
16
|
+
* `named` = owner + the live orgs with a live install or a switch on. Audits
|
|
17
|
+
* `catalog.scope_changed`; returns whether the scope changed (the caller enqueues the item's
|
|
18
18
|
* scope sync after the commit).
|
|
19
19
|
*/
|
|
20
20
|
export async function narrowItemOnUnshare(db, actor, item) {
|
|
@@ -25,7 +25,7 @@ export async function narrowItemOnUnshare(db, actor, item) {
|
|
|
25
25
|
.selectFrom("plugin_installs")
|
|
26
26
|
.select("org_id")
|
|
27
27
|
.where("item_id", "=", item.id)
|
|
28
|
-
.where("status", "in", [...
|
|
28
|
+
.where("status", "in", [...LIVE_INSTALL_STATUSES])
|
|
29
29
|
.execute();
|
|
30
30
|
const switches = await db
|
|
31
31
|
.selectFrom("catalog_item_org_switches")
|
|
@@ -43,7 +43,6 @@ export async function narrowItemOnUnshare(db, actor, item) {
|
|
|
43
43
|
.updateTable("catalog_items")
|
|
44
44
|
.set({
|
|
45
45
|
scope: "named",
|
|
46
|
-
scope_version: sql `scope_version + 1`,
|
|
47
46
|
updated_at: sql `now()`,
|
|
48
47
|
})
|
|
49
48
|
.where("id", "=", item.id)
|
|
@@ -69,8 +68,7 @@ export async function narrowItemOnUnshare(db, actor, item) {
|
|
|
69
68
|
/**
|
|
70
69
|
* Narrows an org-owned component with its own `optional` / `all` scope (row locked by the caller)
|
|
71
70
|
* to `named` = owner + the live orgs where it is on now ({@link componentOn}). A component that
|
|
72
|
-
* follows its plugin is narrowed with the plugin.
|
|
73
|
-
* `component.scope_changed`.
|
|
71
|
+
* follows its plugin is narrowed with the plugin. Audits `component.scope_changed`.
|
|
74
72
|
*/
|
|
75
73
|
export async function narrowComponentOnUnshare(db, actor, c) {
|
|
76
74
|
if (c.ownerOrgId === null || c.scopeMode !== "own" || c.scope === "named")
|
|
@@ -82,7 +80,6 @@ export async function narrowComponentOnUnshare(db, actor, c) {
|
|
|
82
80
|
.updateTable(TABLE[c.kind])
|
|
83
81
|
.set({
|
|
84
82
|
scope: "named",
|
|
85
|
-
scope_version: sql `scope_version + 1`,
|
|
86
83
|
updated_at: sql `now()`,
|
|
87
84
|
})
|
|
88
85
|
.where("id", "=", c.id)
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The channel gateway check's job name
|
|
3
|
-
*
|
|
4
|
-
* scheduler in Redis, so the worker removes it at start (`RETIRED_SCHEDULER_IDS`). A leaf module:
|
|
5
|
-
* the maintenance worker imports it without the channel providers.
|
|
2
|
+
* The channel gateway check's job name. A leaf module: the maintenance worker imports it without
|
|
3
|
+
* the channel providers.
|
|
6
4
|
*/
|
|
7
5
|
/** The gateway check's job name (`@LockedCron`). */
|
|
8
6
|
export declare const GATEWAY_CHECK_JOB = "channel-gateway-check";
|
|
9
|
-
/** The gateway check's old scheduler (every minute). */
|
|
10
|
-
export declare const GATEWAY_CHECK_SCHEDULER_ID = "channel-gateway-check-every";
|
package/dist/channels/job-ids.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The channel gateway check's job name
|
|
3
|
-
*
|
|
4
|
-
* scheduler in Redis, so the worker removes it at start (`RETIRED_SCHEDULER_IDS`). A leaf module:
|
|
5
|
-
* the maintenance worker imports it without the channel providers.
|
|
2
|
+
* The channel gateway check's job name. A leaf module: the maintenance worker imports it without
|
|
3
|
+
* the channel providers.
|
|
6
4
|
*/
|
|
7
5
|
/** The gateway check's job name (`@LockedCron`). */
|
|
8
6
|
export const GATEWAY_CHECK_JOB = "channel-gateway-check";
|
|
9
|
-
/** The gateway check's old scheduler (every minute). */
|
|
10
|
-
export const GATEWAY_CHECK_SCHEDULER_ID = "channel-gateway-check-every";
|
|
@@ -40,7 +40,7 @@ export declare const POISON_FAILURES = 3;
|
|
|
40
40
|
* the `locale` recorded on the conversation's latest `user_message` at or before `uptoSeq`, which
|
|
41
41
|
* already follows the order IM language, latest web message language, org language
|
|
42
42
|
* (`readMessageContext`). In a group thread that is whoever wrote last, i.e. the requester of the
|
|
43
|
-
* approvals and questions that follow. A message
|
|
43
|
+
* approvals and questions that follow. A message without one (a sub-agent's task): its author's
|
|
44
44
|
* language by {@link recipientLocale}; no user message at all: the conversation owner's.
|
|
45
45
|
* Read from PG, so any replica derives the same value.
|
|
46
46
|
*/
|
|
@@ -105,7 +105,7 @@ function isBusMessage(m) {
|
|
|
105
105
|
* the `locale` recorded on the conversation's latest `user_message` at or before `uptoSeq`, which
|
|
106
106
|
* already follows the order IM language, latest web message language, org language
|
|
107
107
|
* (`readMessageContext`). In a group thread that is whoever wrote last, i.e. the requester of the
|
|
108
|
-
* approvals and questions that follow. A message
|
|
108
|
+
* approvals and questions that follow. A message without one (a sub-agent's task): its author's
|
|
109
109
|
* language by {@link recipientLocale}; no user message at all: the conversation owner's.
|
|
110
110
|
* Read from PG, so any replica derives the same value.
|
|
111
111
|
*/
|
|
@@ -179,7 +179,7 @@ export declare class ChannelSupervisor {
|
|
|
179
179
|
/** 停机:停止扫描,中止全部长连接并释放租约。幂等。 */
|
|
180
180
|
stop(): Promise<void>;
|
|
181
181
|
}
|
|
182
|
-
export { GATEWAY_CHECK_JOB
|
|
182
|
+
export { GATEWAY_CHECK_JOB } from "./job-ids.js";
|
|
183
183
|
/** The period of the gateway check (`@LockedCron` every minute). */
|
|
184
184
|
export declare const GATEWAY_CHECK_EVERY_MS = 60000;
|
|
185
185
|
/**
|
|
@@ -187,8 +187,7 @@ export declare const GATEWAY_CHECK_EVERY_MS = 60000;
|
|
|
187
187
|
* {@link checkGatewayPresence}, every minute, once across replicas; a worker-role job
|
|
188
188
|
* (`WorkerModule`), as the maintenance job it replaces was. Silent for one lease TTL after this
|
|
189
189
|
* worker process built its providers (the gateways' first heartbeats; the old handler's grace also
|
|
190
|
-
* started at the worker's kernel construction).
|
|
191
|
-
* `channel-gateway-check-every` (retired at worker start).
|
|
190
|
+
* started at the worker's kernel construction).
|
|
192
191
|
*/
|
|
193
192
|
export declare class GatewayCheckJob {
|
|
194
193
|
private readonly db;
|
|
@@ -629,7 +629,7 @@ ChannelSupervisor = __decorate([
|
|
|
629
629
|
__param(9, Inject(ReplicaStatusStore))
|
|
630
630
|
], ChannelSupervisor);
|
|
631
631
|
export { ChannelSupervisor };
|
|
632
|
-
export { GATEWAY_CHECK_JOB
|
|
632
|
+
export { GATEWAY_CHECK_JOB } from "./job-ids.js";
|
|
633
633
|
/** The period of the gateway check (`@LockedCron` every minute). */
|
|
634
634
|
export const GATEWAY_CHECK_EVERY_MS = 60_000;
|
|
635
635
|
/**
|
|
@@ -637,8 +637,7 @@ export const GATEWAY_CHECK_EVERY_MS = 60_000;
|
|
|
637
637
|
* {@link checkGatewayPresence}, every minute, once across replicas; a worker-role job
|
|
638
638
|
* (`WorkerModule`), as the maintenance job it replaces was. Silent for one lease TTL after this
|
|
639
639
|
* worker process built its providers (the gateways' first heartbeats; the old handler's grace also
|
|
640
|
-
* started at the worker's kernel construction).
|
|
641
|
-
* `channel-gateway-check-every` (retired at worker start).
|
|
640
|
+
* started at the worker's kernel construction).
|
|
642
641
|
*/
|
|
643
642
|
let GatewayCheckJob = class GatewayCheckJob {
|
|
644
643
|
db;
|
|
@@ -34,7 +34,7 @@ function componentsOf(section) {
|
|
|
34
34
|
if (validateUiContributions(manifest.ui, manifest.permissions).length > 0)
|
|
35
35
|
return [];
|
|
36
36
|
return resolveUiSlots(manifest.ui)
|
|
37
|
-
.resolved.filter((r) => r.contribution.kind === "component"
|
|
37
|
+
.resolved.filter((r) => r.contribution.kind === "component")
|
|
38
38
|
.map((r) => ({ id: r.contribution.id, slot: r.slot }));
|
|
39
39
|
}
|
|
40
40
|
/** `/api/v1/client/<plugin>/<build>/<path inside dist/client/>` of a manifest key. */
|
package/dist/config/env.js
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
import { ConfigError } from "./types.js";
|
|
2
2
|
const PREFIX = "CAPYBARA_";
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* `CAPYBARA_*` variables that are not kernel config paths (the config source, the init container,
|
|
5
|
+
* the web app, tests and tooling). Every other `CAPYBARA_*` variable is a config path and must name
|
|
6
|
+
* a known key: the schema is strict.
|
|
7
|
+
*/
|
|
8
|
+
const IGNORED = [
|
|
9
|
+
"CAPYBARA_CONFIG_",
|
|
10
|
+
"CAPYBARA_NACOS_",
|
|
11
|
+
"CAPYBARA_INIT_ADMIN_",
|
|
12
|
+
"CAPYBARA_WEB_",
|
|
13
|
+
"CAPYBARA_TEST_",
|
|
14
|
+
"CAPYBARA_E2E_",
|
|
15
|
+
"CAPYBARA_VISUAL_",
|
|
16
|
+
"CAPYBARA_DEV_UI",
|
|
17
|
+
"CAPYBARA_KERNEL_URL",
|
|
18
|
+
"CAPYBARA_GATEWAY_",
|
|
19
|
+
"CAPYBARA_VERSION",
|
|
20
|
+
"CAPYBARA_IMAGE_PREFIX",
|
|
21
|
+
];
|
|
4
22
|
function snakeToCamel(segment) {
|
|
5
23
|
return segment.toLowerCase().replace(/_([a-z0-9])/g, (_, c) => c.toUpperCase());
|
|
6
24
|
}
|
package/dist/config/load.d.ts
CHANGED
|
@@ -6,12 +6,6 @@ export { ConfigError, type ConfigSource };
|
|
|
6
6
|
export declare function selectConfigSource(env: NodeJS.ProcessEnv): ConfigSource;
|
|
7
7
|
/** 深合并:对象递归合并,其余(含数组)由 override 整体替换。 */
|
|
8
8
|
export declare function deepMerge(base: unknown, override: unknown): unknown;
|
|
9
|
-
/**
|
|
10
|
-
* Removed sandbox keys still present in the loaded config (file, Nacos or environment), each with
|
|
11
|
-
* the setting that replaces it (auto mode hardening spec K3). The schema would strip an unknown
|
|
12
|
-
* key silently, and an ignored security key reads as a widening, so the config fails instead.
|
|
13
|
-
*/
|
|
14
|
-
export declare function removedConfigProblems(merged: unknown): string[];
|
|
15
9
|
/** 原始配置深合并环境变量覆盖(优先级最高)后校验;热更新与启动共用。错误只列路径不列值。 */
|
|
16
10
|
export declare function resolveConfig(raw: unknown, env: NodeJS.ProcessEnv): KernelConfig;
|
|
17
11
|
/** 选来源 → 深合并环境变量覆盖(优先级最高)→ 校验。 */
|