@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
|
@@ -15,8 +15,9 @@ import { CurrentPrincipal, patTokenId, requireUser, SessionOnly, } from "../iden
|
|
|
15
15
|
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
16
16
|
import { ZBody } from "../infra/validation/zod-params.js";
|
|
17
17
|
import { MembersService } from "./members.service.js";
|
|
18
|
+
import { OrgNetworkAllowances } from "./network-allowances.service.js";
|
|
18
19
|
import { CurrentOrg, OrgAction } from "./org.guard.js";
|
|
19
|
-
import { OrgUpdateBody } from "./orgs.schemas.js";
|
|
20
|
+
import { networkAllowanceView, OrgUpdateBody } from "./orgs.schemas.js";
|
|
20
21
|
import { OrgsService } from "./orgs.service.js";
|
|
21
22
|
import { ORG_ROLES } from "./roles.js";
|
|
22
23
|
const CreateSchema = z.object({
|
|
@@ -45,10 +46,12 @@ let OrgsController = class OrgsController {
|
|
|
45
46
|
orgs;
|
|
46
47
|
members;
|
|
47
48
|
tokens;
|
|
48
|
-
|
|
49
|
+
allowances;
|
|
50
|
+
constructor(orgs, members, tokens, allowances) {
|
|
49
51
|
this.orgs = orgs;
|
|
50
52
|
this.members = members;
|
|
51
53
|
this.tokens = tokens;
|
|
54
|
+
this.allowances = allowances;
|
|
52
55
|
}
|
|
53
56
|
async create(principal, body) {
|
|
54
57
|
const p = requireUser(principal);
|
|
@@ -84,6 +87,13 @@ let OrgsController = class OrgsController {
|
|
|
84
87
|
async listMembers(org) {
|
|
85
88
|
return { members: await this.members.list(org.orgId) };
|
|
86
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* The internal endpoints a super admin lets this org's extension requests reach (plugin safe
|
|
92
|
+
* fetch spec), read-only for org admins so a refused request is explainable; members get 403.
|
|
93
|
+
*/
|
|
94
|
+
async listNetworkAllowances(org) {
|
|
95
|
+
return { allowances: (await this.allowances.list(org.orgId)).map(networkAllowanceView) };
|
|
96
|
+
}
|
|
87
97
|
async changeRole(principal, org, accountId, body) {
|
|
88
98
|
const p = requireUser(principal);
|
|
89
99
|
await this.members.changeRole(org.orgId, accountId, body.role, p.account.id, patTokenId(p));
|
|
@@ -153,6 +163,11 @@ __decorate([
|
|
|
153
163
|
OrgAction("org.members.read"),
|
|
154
164
|
__param(0, CurrentOrg())
|
|
155
165
|
], OrgsController.prototype, "listMembers", null);
|
|
166
|
+
__decorate([
|
|
167
|
+
Get(":orgId/network-allowances"),
|
|
168
|
+
OrgAction("org.update"),
|
|
169
|
+
__param(0, CurrentOrg())
|
|
170
|
+
], OrgsController.prototype, "listNetworkAllowances", null);
|
|
156
171
|
__decorate([
|
|
157
172
|
Patch(":orgId/members/:accountId"),
|
|
158
173
|
OrgAction("org.members.manage"),
|
|
@@ -196,6 +211,7 @@ OrgsController = __decorate([
|
|
|
196
211
|
Controller("api/v1/orgs"),
|
|
197
212
|
__param(0, Inject(OrgsService)),
|
|
198
213
|
__param(1, Inject(MembersService)),
|
|
199
|
-
__param(2, Inject(ApiTokenService))
|
|
214
|
+
__param(2, Inject(ApiTokenService)),
|
|
215
|
+
__param(3, Inject(OrgNetworkAllowances))
|
|
200
216
|
], OrgsController);
|
|
201
217
|
export { OrgsController };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Organizations: orgs, org settings, members, invitations, offboarding (
|
|
3
|
-
* directory sync (the hourly scan cron, one-off syncs on the maintenance queue)
|
|
2
|
+
* Organizations: orgs, org settings, members, invitations, offboarding (its owed work goes through
|
|
3
|
+
* the outbox), directory sync (the hourly scan cron, one-off syncs on the maintenance queue) and the
|
|
4
|
+
* org network allowances (internal endpoints a super admin lets the org's extension requests reach).
|
|
4
5
|
*/
|
|
5
6
|
export declare class OrgsModule {
|
|
6
7
|
}
|
package/dist/orgs/orgs.module.js
CHANGED
|
@@ -19,13 +19,15 @@ import { ToolsModule } from "../tools/tools.module.js";
|
|
|
19
19
|
import { DirectorySync } from "./directory-sync.js";
|
|
20
20
|
import { InvitationsService } from "./invitations.service.js";
|
|
21
21
|
import { MembersService } from "./members.service.js";
|
|
22
|
+
import { OrgNetworkAllowancesModule } from "./network-allowances.service.js";
|
|
22
23
|
import { Offboarding } from "./offboarding.js";
|
|
23
24
|
import { OrgLockModule } from "./org-lock.js";
|
|
24
25
|
import { OrgsService } from "./orgs.service.js";
|
|
25
26
|
import { OrgSettingsModule } from "./settings.service.js";
|
|
26
27
|
/**
|
|
27
|
-
* Organizations: orgs, org settings, members, invitations, offboarding (
|
|
28
|
-
* directory sync (the hourly scan cron, one-off syncs on the maintenance queue)
|
|
28
|
+
* Organizations: orgs, org settings, members, invitations, offboarding (its owed work goes through
|
|
29
|
+
* the outbox), directory sync (the hourly scan cron, one-off syncs on the maintenance queue) and the
|
|
30
|
+
* org network allowances (internal endpoints a super admin lets the org's extension requests reach).
|
|
29
31
|
*/
|
|
30
32
|
let OrgsModule = class OrgsModule {
|
|
31
33
|
};
|
|
@@ -52,6 +54,7 @@ OrgsModule = __decorate([
|
|
|
52
54
|
CatalogModule,
|
|
53
55
|
// the producer side of directory-sync jobs (the maintenance processor consumes them)
|
|
54
56
|
QueueModule.registerQueue(MAINTENANCE_QUEUE_NAME),
|
|
57
|
+
OrgNetworkAllowancesModule,
|
|
55
58
|
],
|
|
56
59
|
providers: [OrgsService, MembersService, InvitationsService, Offboarding, DirectorySync],
|
|
57
60
|
exports: [
|
|
@@ -62,6 +65,7 @@ OrgsModule = __decorate([
|
|
|
62
65
|
InvitationsService,
|
|
63
66
|
Offboarding,
|
|
64
67
|
DirectorySync,
|
|
68
|
+
OrgNetworkAllowancesModule,
|
|
65
69
|
],
|
|
66
70
|
})
|
|
67
71
|
], OrgsModule);
|
|
@@ -4,5 +4,17 @@ export declare const OrgUpdateBody: z.ZodObject<{
|
|
|
4
4
|
name: z.ZodOptional<z.ZodString>;
|
|
5
5
|
slug: z.ZodOptional<z.ZodString>;
|
|
6
6
|
}, z.core.$strip>;
|
|
7
|
+
/** One org network allowance as the routes and Platform operations return it. */
|
|
8
|
+
export interface NetworkAllowanceView {
|
|
9
|
+
id: string;
|
|
10
|
+
entry: string;
|
|
11
|
+
createdAt: Date;
|
|
12
|
+
}
|
|
13
|
+
/** The view of a stored allowance: who added it stays in the audit log. */
|
|
14
|
+
export declare function networkAllowanceView(a: {
|
|
15
|
+
id: string;
|
|
16
|
+
entry: string;
|
|
17
|
+
createdAt: Date;
|
|
18
|
+
}): NetworkAllowanceView;
|
|
7
19
|
export declare const ORG_ROUTES: readonly RouteSchemas[];
|
|
8
20
|
export declare const ORG_SETTINGS_ROUTES: readonly RouteSchemas[];
|
|
@@ -4,11 +4,16 @@ export const OrgUpdateBody = z.object({
|
|
|
4
4
|
name: z.string().min(1).max(100).optional(),
|
|
5
5
|
slug: z.string().min(1).max(40).optional(),
|
|
6
6
|
});
|
|
7
|
+
/** The view of a stored allowance: who added it stays in the audit log. */
|
|
8
|
+
export function networkAllowanceView(a) {
|
|
9
|
+
return { id: a.id, entry: a.entry, createdAt: a.createdAt };
|
|
10
|
+
}
|
|
7
11
|
export const ORG_ROUTES = [
|
|
8
12
|
{ route: "GET /api/v1/orgs" },
|
|
9
13
|
{ route: "GET /api/v1/orgs/:orgId" },
|
|
10
14
|
{ route: "PATCH /api/v1/orgs/:orgId", body: OrgUpdateBody },
|
|
11
15
|
{ route: "GET /api/v1/orgs/:orgId/members" },
|
|
16
|
+
{ route: "GET /api/v1/orgs/:orgId/network-allowances" },
|
|
12
17
|
];
|
|
13
18
|
export const ORG_SETTINGS_ROUTES = [
|
|
14
19
|
{ route: "GET /api/v1/orgs/:orgId/settings" },
|
|
@@ -241,7 +241,12 @@ let OrgsService = class OrgsService {
|
|
|
241
241
|
await this.softDeleteIn(orgId, actor, actorTokenId);
|
|
242
242
|
}
|
|
243
243
|
async softDeleteIn(orgId, actor, actorTokenId) {
|
|
244
|
-
//
|
|
244
|
+
// the org admission lock exclusively first (it waits for the run writes the fence admitted
|
|
245
|
+
// shared, which see the org deleted after this commits), then the org row, which admits the
|
|
246
|
+
// other fenced run writes (`RunExecution`)
|
|
247
|
+
// an unauthorized call is refused before it holds off the org's run writes
|
|
248
|
+
await this.orgLock.precheck(orgId, actor.id, "org.delete");
|
|
249
|
+
await this.orgLock.lockForRemoval(orgId);
|
|
245
250
|
await this.orgLock.lockAndAuthorize(orgId, actor.id, "org.delete");
|
|
246
251
|
await this.db
|
|
247
252
|
.updateTable("orgs")
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { type Principal } from "../identity/principal.js";
|
|
2
2
|
import { type OrgContext } from "./org.guard.js";
|
|
3
|
-
import { type OrgEffectiveNetwork, type OrgSandboxLimits, type
|
|
3
|
+
import { type OrgEffectiveNetwork, type OrgSandboxLimits, type OrgSettingsDeployment, type OrgSettingsPatch, OrgSettingsService, type OrgSettingsView } from "./settings.service.js";
|
|
4
4
|
/**
|
|
5
5
|
* 组织设置(`/api/v1/orgs/:orgId/settings`):成员可读,修改需 `org.update`(admin)。
|
|
6
6
|
* 响应带 `deployment`(部署默认值,如沙箱出站),设置页据此展示「跟随部署」时的实际取值;
|
|
7
7
|
* 以及只读的 `sandboxLimits`(组织实际生效的沙箱 cpu / 内存与来源,超级管理员在部署设置里覆盖,C19)。
|
|
8
8
|
*/
|
|
9
9
|
type SettingsResponse = {
|
|
10
|
-
|
|
10
|
+
/** `scheduledTasks.forbiddenToolsUnreadable: true` when the stored list cannot be read. */
|
|
11
|
+
settings: OrgSettingsView;
|
|
11
12
|
deployment: OrgSettingsDeployment;
|
|
12
13
|
/** The org's effective sandbox-mode network (org egress ceiling spec §D4). */
|
|
13
14
|
effectiveNetwork: OrgEffectiveNetwork;
|
|
@@ -10,13 +10,18 @@ import type { KernelLogger } from "../log.js";
|
|
|
10
10
|
import { type DevicesAutoModeView } from "../sandbox/platform-auto-mode.js";
|
|
11
11
|
import { OrgLock } from "./org-lock.js";
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* - `
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
13
|
+
* Org settings (`capybara.orgs.settings` jsonb). Read leniently: a missing or invalid field reads
|
|
14
|
+
* as its default and unknown keys are kept (merged with the stored value on update), so a new
|
|
15
|
+
* field needs no migration.
|
|
16
|
+
* - `toolSearch`: whether to switch to a catalog + `ToolSearch` once the tools pass the threshold
|
|
17
|
+
* (D11, default on).
|
|
18
|
+
* - `locale`: the org's default language (`zh` / `en`, default en); the bot's fixed phrases in IM
|
|
19
|
+
* follow it.
|
|
20
|
+
* - `sandboxToolPolicy`: the default policy of the sandbox tools (M5 T8, default allow). With
|
|
21
|
+
* `ask`, every tool but the read-only `Read` / `Glob` / `Grep` needs approval (read live at
|
|
22
|
+
* execution). An invalid stored value reads as `ask` (narrower, never wider) and is logged.
|
|
23
|
+
* - `wakeOnBackgroundTask`: the org's override of `runtime.wakeOnBackgroundTask` (absent follows
|
|
24
|
+
* the deployment), see {@link effectiveWakeOnBackgroundTask}.
|
|
20
25
|
* - `autoMode`: whether devices of the org may run in auto mode (auto mode spec §4.3); absent
|
|
21
26
|
* follows the platform's `devices.autoMode`, and an invalid stored value reads as `off`
|
|
22
27
|
* (narrower, never wider). Setting `allowed` while the platform is `off` is refused.
|
|
@@ -91,7 +96,9 @@ export type OrgThemeSetting = z.infer<typeof OrgThemeSettingSchema>;
|
|
|
91
96
|
export declare const DEFAULT_ORG_THEME: OrgThemeSetting;
|
|
92
97
|
/**
|
|
93
98
|
* Org settings of scheduled tasks (spec §9); every field reads leniently (invalid = default,
|
|
94
|
-
* except `forbiddenTools`, which keeps its valid entries).
|
|
99
|
+
* except `forbiddenTools`, which keeps its valid entries). A stored `forbiddenTools` that is not a
|
|
100
|
+
* list (or a group that is not an object) reads as `[]` here, for display; enforcement checks
|
|
101
|
+
* {@link invalidStoredForbiddenTools} and fails unattended runs instead (never wider).
|
|
95
102
|
*/
|
|
96
103
|
export declare const ScheduledTasksSettingsSchema: z.ZodObject<{
|
|
97
104
|
enabled: z.ZodCatch<z.ZodDefault<z.ZodBoolean>>;
|
|
@@ -215,6 +222,17 @@ export declare const OrgSettingsSchema: z.ZodObject<{
|
|
|
215
222
|
}, z.core.$strip>>>;
|
|
216
223
|
}, z.core.$strip>;
|
|
217
224
|
export type OrgSettings = z.infer<typeof OrgSettingsSchema>;
|
|
225
|
+
/**
|
|
226
|
+
* The settings as the responses carry them: {@link OrgSettings} plus
|
|
227
|
+
* `scheduledTasks.forbiddenToolsUnreadable: true` when the stored list cannot be read
|
|
228
|
+
* ({@link invalidStoredForbiddenTools}; `forbiddenTools` then reads `[]`), so the settings page
|
|
229
|
+
* says so and saves the list. Never stored.
|
|
230
|
+
*/
|
|
231
|
+
export type OrgSettingsView = OrgSettings & {
|
|
232
|
+
scheduledTasks: OrgSettings["scheduledTasks"] & {
|
|
233
|
+
forbiddenToolsUnreadable?: true;
|
|
234
|
+
};
|
|
235
|
+
};
|
|
218
236
|
/** PATCH 体:只改给出的字段;未知字段 → 400。 */
|
|
219
237
|
export declare const OrgSettingsPatchSchema: z.ZodObject<{
|
|
220
238
|
toolSearch: z.ZodOptional<z.ZodEnum<{
|
|
@@ -332,8 +350,34 @@ export interface OrgSettingsDeployment {
|
|
|
332
350
|
}
|
|
333
351
|
/** 把存储的 jsonb 解析为设置(宽松,见 {@link OrgSettingsSchema})。 */
|
|
334
352
|
export declare function parseOrgSettings(raw: unknown): OrgSettings;
|
|
335
|
-
/**
|
|
336
|
-
export declare function
|
|
353
|
+
/** The org's stored settings jsonb, read live; undefined when the org is missing or deleted. */
|
|
354
|
+
export declare function readStoredOrgSettings(db: KernelSchemaDb, orgId: string): Promise<unknown>;
|
|
355
|
+
/**
|
|
356
|
+
* Reads the org settings (live from PG every time, so a change applies at once across replicas);
|
|
357
|
+
* a missing or deleted org reads as the defaults. With `log`, an
|
|
358
|
+
* unreadable security setting ({@link logUnreadableSecuritySettings}) is logged.
|
|
359
|
+
*/
|
|
360
|
+
export declare function readOrgSettings(db: KernelSchemaDb, orgId: string,
|
|
361
|
+
/** Per-call paths (the tool policy) log at debug; the settings reads and the fire warn. */
|
|
362
|
+
log?: Pick<KernelLogger, "debug">): Promise<OrgSettings>;
|
|
363
|
+
/** Whether a stored settings object holds a `sandboxToolPolicy` this version reads as `ask`. */
|
|
364
|
+
export declare function invalidStoredSandboxToolPolicy(raw: unknown): boolean;
|
|
365
|
+
/**
|
|
366
|
+
* Whether the stored scheduled-task `forbiddenTools` cannot be read: the group or the field is
|
|
367
|
+
* present but not an object / a list. Unattended runs of such an org fail
|
|
368
|
+
* ({@link FORBIDDEN_TOOLS_UNREADABLE_ERROR}) rather than run with nothing forbidden. Invalid
|
|
369
|
+
* entries inside a list are dropped instead (the valid ones stay forbidden).
|
|
370
|
+
*/
|
|
371
|
+
export declare function invalidStoredForbiddenTools(raw: unknown): boolean;
|
|
372
|
+
/** The refusal of an unattended run of an org whose `forbiddenTools` cannot be read. */
|
|
373
|
+
export declare const FORBIDDEN_TOOLS_UNREADABLE_ERROR = "The organization's forbidden tool list for scheduled tasks is unreadable, so this scheduled run cannot continue; an org admin must save the list again in the organization's scheduled task settings.";
|
|
374
|
+
/** The refusal of a new task grant while the org's `forbiddenTools` cannot be read. */
|
|
375
|
+
export declare const FORBIDDEN_TOOLS_UNREADABLE_GRANT_ERROR = "The organization's forbidden tool list for scheduled tasks is unreadable, so no tool can be approved for a task now; an org admin must save the list again in the organization's scheduled task settings.";
|
|
376
|
+
/**
|
|
377
|
+
* Logs (through `log`, at the caller's level) the security settings a stored value reads narrower
|
|
378
|
+
* than written, with the org id.
|
|
379
|
+
*/
|
|
380
|
+
export declare function logUnreadableSecuritySettings(log: (msg: string, fields: Record<string, unknown>) => void, orgId: string, raw: unknown): void;
|
|
337
381
|
/** Whether a stored settings object holds an `autoMode` this version reads as `off`. */
|
|
338
382
|
export declare function invalidStoredAutoMode(raw: unknown): boolean;
|
|
339
383
|
/** Whether a stored settings object holds a `cloudNetwork` this version reads as an empty allowlist. */
|
|
@@ -363,8 +407,9 @@ export declare class OrgSettingsService {
|
|
|
363
407
|
* (`devices.autoMode`; the org may follow it, never exceed it).
|
|
364
408
|
*/
|
|
365
409
|
config: Pick<KernelConfigService, "get" | "fieldSource">, log?: KernelLogger | undefined);
|
|
366
|
-
/** Parses stored settings, warning when an invalid `autoMode` narrows to `off
|
|
367
|
-
* `cloudNetwork` to an empty allowlist
|
|
410
|
+
/** Parses stored settings, warning when an invalid `autoMode` narrows to `off`, an invalid
|
|
411
|
+
* `cloudNetwork` to an empty allowlist, or a security setting reads narrower
|
|
412
|
+
* ({@link logUnreadableSecuritySettings}, warn). */
|
|
368
413
|
private parseStored;
|
|
369
414
|
/** 部署默认值(设置页展示「跟随部署」时的实际取值)。 */
|
|
370
415
|
deployment(): Promise<OrgSettingsDeployment>;
|
|
@@ -375,7 +420,7 @@ export declare class OrgSettingsService {
|
|
|
375
420
|
effectiveNetwork(settings: Pick<OrgSettings, "cloudNetwork">): OrgEffectiveNetwork;
|
|
376
421
|
/** 组织实际生效的沙箱 cpu / 内存(只读;由超级管理员在部署设置里覆盖)。 */
|
|
377
422
|
sandboxLimits(orgId: string): Promise<OrgSandboxLimits>;
|
|
378
|
-
get(orgId: string): Promise<
|
|
423
|
+
get(orgId: string): Promise<OrgSettingsView>;
|
|
379
424
|
/**
|
|
380
425
|
* The refusals of {@link update} that need no read of the org (the Platform tool's precheck):
|
|
381
426
|
* auto mode where the platform turned it off.
|
|
@@ -398,7 +443,7 @@ export declare class OrgSettingsService {
|
|
|
398
443
|
*/
|
|
399
444
|
opts?: {
|
|
400
445
|
onlyNarrows?: boolean;
|
|
401
|
-
}): Promise<
|
|
446
|
+
}): Promise<OrgSettingsView>;
|
|
402
447
|
/**
|
|
403
448
|
* Refuses a patch that widens the org's sandbox (auto mode spec §4.3: only a person widens it,
|
|
404
449
|
* never the Platform tool or an API token):
|
|
@@ -26,13 +26,18 @@ import { IanaTimeZone } from "../time-zone.js";
|
|
|
26
26
|
import { mergeArrangement, OrgUiArrangementPatchSchema, UiArrangementSchema, } from "../ui/arrangement.js";
|
|
27
27
|
import { OrgLock, OrgLockModule } from "./org-lock.js";
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* - `
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
29
|
+
* Org settings (`capybara.orgs.settings` jsonb). Read leniently: a missing or invalid field reads
|
|
30
|
+
* as its default and unknown keys are kept (merged with the stored value on update), so a new
|
|
31
|
+
* field needs no migration.
|
|
32
|
+
* - `toolSearch`: whether to switch to a catalog + `ToolSearch` once the tools pass the threshold
|
|
33
|
+
* (D11, default on).
|
|
34
|
+
* - `locale`: the org's default language (`zh` / `en`, default en); the bot's fixed phrases in IM
|
|
35
|
+
* follow it.
|
|
36
|
+
* - `sandboxToolPolicy`: the default policy of the sandbox tools (M5 T8, default allow). With
|
|
37
|
+
* `ask`, every tool but the read-only `Read` / `Glob` / `Grep` needs approval (read live at
|
|
38
|
+
* execution). An invalid stored value reads as `ask` (narrower, never wider) and is logged.
|
|
39
|
+
* - `wakeOnBackgroundTask`: the org's override of `runtime.wakeOnBackgroundTask` (absent follows
|
|
40
|
+
* the deployment), see {@link effectiveWakeOnBackgroundTask}.
|
|
36
41
|
* - `autoMode`: whether devices of the org may run in auto mode (auto mode spec §4.3); absent
|
|
37
42
|
* follows the platform's `devices.autoMode`, and an invalid stored value reads as `off`
|
|
38
43
|
* (narrower, never wider). Setting `allowed` while the platform is `off` is refused.
|
|
@@ -118,7 +123,9 @@ const posInt = (max, def) => z.number().int().min(1).max(max).default(def).catch
|
|
|
118
123
|
const isForbiddenToolEntry = (v) => typeof v === "string" && v.length >= 1 && v.length <= 200;
|
|
119
124
|
/**
|
|
120
125
|
* Org settings of scheduled tasks (spec §9); every field reads leniently (invalid = default,
|
|
121
|
-
* except `forbiddenTools`, which keeps its valid entries).
|
|
126
|
+
* except `forbiddenTools`, which keeps its valid entries). A stored `forbiddenTools` that is not a
|
|
127
|
+
* list (or a group that is not an object) reads as `[]` here, for display; enforcement checks
|
|
128
|
+
* {@link invalidStoredForbiddenTools} and fails unattended runs instead (never wider).
|
|
122
129
|
*/
|
|
123
130
|
export const ScheduledTasksSettingsSchema = z.object({
|
|
124
131
|
enabled: z.boolean().default(true).catch(true),
|
|
@@ -170,7 +177,8 @@ export const GIT_GATEWAY_INVALID = { enabled: false };
|
|
|
170
177
|
export const OrgSettingsSchema = z.object({
|
|
171
178
|
toolSearch: z.enum(["on", "off"]).default("on").catch("on"),
|
|
172
179
|
locale: z.enum(["zh", "en"]).default("en").catch("en"),
|
|
173
|
-
|
|
180
|
+
/** Absent = `allow`; an invalid stored value reads as `ask` (narrower, never wider). */
|
|
181
|
+
sandboxToolPolicy: z.enum(["allow", "ask"]).default("allow").catch("ask"),
|
|
174
182
|
platformTool: z.enum(["on", "read-only", "off"]).default("on").catch("on"),
|
|
175
183
|
/** The org's auto-mode switch (auto mode spec §4.3); absent follows the platform. */
|
|
176
184
|
autoMode: AutoModeSetting.optional().catch("off"),
|
|
@@ -194,6 +202,13 @@ export const OrgSettingsSchema = z.object({
|
|
|
194
202
|
*/
|
|
195
203
|
compaction: COMPACTION_SETTINGS_PARTIAL.optional().catch(undefined),
|
|
196
204
|
});
|
|
205
|
+
/** {@link OrgSettingsView} of `settings`, flagged from the stored value `raw`. */
|
|
206
|
+
const viewOf = (settings, raw) => invalidStoredForbiddenTools(raw)
|
|
207
|
+
? {
|
|
208
|
+
...settings,
|
|
209
|
+
scheduledTasks: { ...settings.scheduledTasks, forbiddenToolsUnreadable: true },
|
|
210
|
+
}
|
|
211
|
+
: settings;
|
|
197
212
|
/** PATCH 体:只改给出的字段;未知字段 → 400。 */
|
|
198
213
|
export const OrgSettingsPatchSchema = z
|
|
199
214
|
.object({
|
|
@@ -259,15 +274,65 @@ const asObject = (v) => v !== null && typeof v === "object" && !Array.isArray(v)
|
|
|
259
274
|
export function parseOrgSettings(raw) {
|
|
260
275
|
return OrgSettingsSchema.parse(asObject(raw));
|
|
261
276
|
}
|
|
262
|
-
/**
|
|
263
|
-
export async function
|
|
277
|
+
/** The org's stored settings jsonb, read live; undefined when the org is missing or deleted. */
|
|
278
|
+
export async function readStoredOrgSettings(db, orgId) {
|
|
264
279
|
const row = await db
|
|
265
280
|
.selectFrom("orgs")
|
|
266
281
|
.select("settings")
|
|
267
282
|
.where("id", "=", orgId)
|
|
268
283
|
.where("deleted_at", "is", null)
|
|
269
284
|
.executeTakeFirst();
|
|
270
|
-
return
|
|
285
|
+
return row?.settings;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Reads the org settings (live from PG every time, so a change applies at once across replicas);
|
|
289
|
+
* a missing or deleted org reads as the defaults. With `log`, an
|
|
290
|
+
* unreadable security setting ({@link logUnreadableSecuritySettings}) is logged.
|
|
291
|
+
*/
|
|
292
|
+
export async function readOrgSettings(db, orgId,
|
|
293
|
+
/** Per-call paths (the tool policy) log at debug; the settings reads and the fire warn. */
|
|
294
|
+
log) {
|
|
295
|
+
const raw = await readStoredOrgSettings(db, orgId);
|
|
296
|
+
if (log !== undefined) {
|
|
297
|
+
logUnreadableSecuritySettings((msg, f) => log.debug(msg, f), orgId, raw);
|
|
298
|
+
}
|
|
299
|
+
return parseOrgSettings(raw);
|
|
300
|
+
}
|
|
301
|
+
/** Whether a stored settings object holds a `sandboxToolPolicy` this version reads as `ask`. */
|
|
302
|
+
export function invalidStoredSandboxToolPolicy(raw) {
|
|
303
|
+
const v = asObject(raw).sandboxToolPolicy;
|
|
304
|
+
return v !== undefined && !OrgSettingsPatchSchema.shape.sandboxToolPolicy.safeParse(v).success;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Whether the stored scheduled-task `forbiddenTools` cannot be read: the group or the field is
|
|
308
|
+
* present but not an object / a list. Unattended runs of such an org fail
|
|
309
|
+
* ({@link FORBIDDEN_TOOLS_UNREADABLE_ERROR}) rather than run with nothing forbidden. Invalid
|
|
310
|
+
* entries inside a list are dropped instead (the valid ones stay forbidden).
|
|
311
|
+
*/
|
|
312
|
+
export function invalidStoredForbiddenTools(raw) {
|
|
313
|
+
const group = asObject(raw).scheduledTasks;
|
|
314
|
+
if (group === undefined)
|
|
315
|
+
return false;
|
|
316
|
+
if (group === null || typeof group !== "object" || Array.isArray(group))
|
|
317
|
+
return true;
|
|
318
|
+
const v = group.forbiddenTools;
|
|
319
|
+
return v !== undefined && !Array.isArray(v);
|
|
320
|
+
}
|
|
321
|
+
/** The refusal of an unattended run of an org whose `forbiddenTools` cannot be read. */
|
|
322
|
+
export const FORBIDDEN_TOOLS_UNREADABLE_ERROR = "The organization's forbidden tool list for scheduled tasks is unreadable, so this scheduled run cannot continue; an org admin must save the list again in the organization's scheduled task settings.";
|
|
323
|
+
/** The refusal of a new task grant while the org's `forbiddenTools` cannot be read. */
|
|
324
|
+
export const FORBIDDEN_TOOLS_UNREADABLE_GRANT_ERROR = "The organization's forbidden tool list for scheduled tasks is unreadable, so no tool can be approved for a task now; an org admin must save the list again in the organization's scheduled task settings.";
|
|
325
|
+
/**
|
|
326
|
+
* Logs (through `log`, at the caller's level) the security settings a stored value reads narrower
|
|
327
|
+
* than written, with the org id.
|
|
328
|
+
*/
|
|
329
|
+
export function logUnreadableSecuritySettings(log, orgId, raw) {
|
|
330
|
+
if (invalidStoredSandboxToolPolicy(raw)) {
|
|
331
|
+
log("org settings: stored sandboxToolPolicy is invalid; it reads as ask", { orgId });
|
|
332
|
+
}
|
|
333
|
+
if (invalidStoredForbiddenTools(raw)) {
|
|
334
|
+
log("org settings: stored scheduledTasks.forbiddenTools is unreadable; unattended runs fail until an org admin saves it again", { orgId });
|
|
335
|
+
}
|
|
271
336
|
}
|
|
272
337
|
const autoModeNotAllowed = (message) => new ApiError("org.auto_mode_not_allowed", message);
|
|
273
338
|
/** Whether a stored settings object holds an `autoMode` this version reads as `off`. */
|
|
@@ -321,8 +386,9 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
321
386
|
this.config = config;
|
|
322
387
|
this.log = log;
|
|
323
388
|
}
|
|
324
|
-
/** Parses stored settings, warning when an invalid `autoMode` narrows to `off
|
|
325
|
-
* `cloudNetwork` to an empty allowlist
|
|
389
|
+
/** Parses stored settings, warning when an invalid `autoMode` narrows to `off`, an invalid
|
|
390
|
+
* `cloudNetwork` to an empty allowlist, or a security setting reads narrower
|
|
391
|
+
* ({@link logUnreadableSecuritySettings}, warn). */
|
|
326
392
|
parseStored(orgId, raw) {
|
|
327
393
|
if (invalidStoredAutoMode(raw)) {
|
|
328
394
|
this.log?.warn("org settings: stored autoMode is invalid; it reads as off", { orgId });
|
|
@@ -332,6 +398,9 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
332
398
|
orgId,
|
|
333
399
|
});
|
|
334
400
|
}
|
|
401
|
+
const log = this.log;
|
|
402
|
+
if (log !== undefined)
|
|
403
|
+
logUnreadableSecuritySettings((m, f) => log.warn(m, f), orgId, raw);
|
|
335
404
|
return parseOrgSettings(raw);
|
|
336
405
|
}
|
|
337
406
|
/** 部署默认值(设置页展示「跟随部署」时的实际取值)。 */
|
|
@@ -384,7 +453,7 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
384
453
|
.executeTakeFirst();
|
|
385
454
|
if (!row)
|
|
386
455
|
throw new ApiError("org.not_found", "Organization not found");
|
|
387
|
-
return this.parseStored(orgId, row.settings);
|
|
456
|
+
return viewOf(this.parseStored(orgId, row.settings), row.settings);
|
|
388
457
|
}
|
|
389
458
|
/**
|
|
390
459
|
* The refusals of {@link update} that need no read of the org (the Platform tool's precheck):
|
|
@@ -518,8 +587,11 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
518
587
|
}
|
|
519
588
|
if (after.compaction === undefined)
|
|
520
589
|
delete after.compaction;
|
|
521
|
-
|
|
522
|
-
|
|
590
|
+
// saving an unreadable security setting writes it even when it equals what it read as
|
|
591
|
+
const repairs = (invalidStoredForbiddenTools(stored) && patch.scheduledTasks?.forbiddenTools !== undefined) ||
|
|
592
|
+
(invalidStoredSandboxToolPolicy(stored) && patch.sandboxToolPolicy !== undefined);
|
|
593
|
+
if (!repairs && sameSettings(before, after))
|
|
594
|
+
return viewOf(before, stored);
|
|
523
595
|
// Lock order: the org row (orgLock above), then the theme's catalog item and its row FOR
|
|
524
596
|
// SHARE (assertThemeOnIn), then the check, so no scope writer changes what it read first
|
|
525
597
|
if (patch.theme?.id != null && patch.theme.id !== before.theme?.id) {
|
|
@@ -528,9 +600,19 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
528
600
|
// Merge with the stored value: keep the keys this version does not know (a cleared autoMode /
|
|
529
601
|
// cloudNetwork is not kept)
|
|
530
602
|
const { autoMode: _oldAutoMode, cloudNetwork: _oldNetwork, wakeOnBackgroundTask: _oldWake, timeZone: _oldZone, theme: _oldTheme, uiArrangement: _oldArrangement, scheduledTasks: _oldScheduled, compaction: _oldCompaction, ...rest } = stored;
|
|
603
|
+
const written = { ...rest, ...after };
|
|
604
|
+
// An unreadable forbiddenTools reads as [] for display only: a write that does not replace the
|
|
605
|
+
// list keeps it unreadable (never healed to "nothing forbidden"); saving the list fixes it
|
|
606
|
+
if (invalidStoredForbiddenTools(stored) && patch.scheduledTasks?.forbiddenTools === undefined) {
|
|
607
|
+
const group = asObject(stored.scheduledTasks);
|
|
608
|
+
written.scheduledTasks = {
|
|
609
|
+
...after.scheduledTasks,
|
|
610
|
+
forbiddenTools: group.forbiddenTools ?? null,
|
|
611
|
+
};
|
|
612
|
+
}
|
|
531
613
|
await this.db
|
|
532
614
|
.updateTable("orgs")
|
|
533
|
-
.set({ settings: JSON.stringify(
|
|
615
|
+
.set({ settings: JSON.stringify(written) })
|
|
534
616
|
.where("id", "=", orgId)
|
|
535
617
|
.execute();
|
|
536
618
|
await audit(this.db.db, {
|
|
@@ -539,9 +621,9 @@ let OrgSettingsService = class OrgSettingsService {
|
|
|
539
621
|
orgId,
|
|
540
622
|
action: "org.settings_updated",
|
|
541
623
|
target: orgId,
|
|
542
|
-
detail: { before, after, ...auditDetail },
|
|
624
|
+
detail: { before, after, ...(repairs && { repaired: true }), ...auditDetail },
|
|
543
625
|
});
|
|
544
|
-
return after;
|
|
626
|
+
return viewOf(after, written);
|
|
545
627
|
}
|
|
546
628
|
};
|
|
547
629
|
__decorate([
|
package/dist/overrides.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { NestInterceptor } from "@nestjs/common";
|
|
2
2
|
import { APP_INTERCEPTOR } from "@nestjs/core";
|
|
3
3
|
import { ADMIN_USAGE_TIMINGS, type AdminUsageTimings } from "./admin/usage.service.js";
|
|
4
|
-
import {
|
|
4
|
+
import { SCOPE_ORG_CHUNK_SIZE } from "./catalog/scope-jobs.js";
|
|
5
5
|
import { CHANNEL_WEBHOOK_TIMINGS, type ChannelWebhookTimings } from "./channels/webhook.js";
|
|
6
|
+
import { EXTENSION_NET_SEAMS, type ExtensionNetSeams } from "./ctx/net.js";
|
|
6
7
|
import type { EvalReplayHooks } from "./evals/run-replay.js";
|
|
7
8
|
import { EVAL_REPLAY_HOOKS } from "./evals/worker.js";
|
|
8
9
|
import { BOOTSTRAP_LOCK_TTL } from "./extensions/bootstrap.js";
|
|
@@ -13,7 +14,6 @@ import { GIT_IDENTITY_API_BASE, type GitIdentityApiBase } from "./git/identity.j
|
|
|
13
14
|
import { PLUGIN_PUBLIC_WRITE_LIMIT } from "./http/plugin-route-access.js";
|
|
14
15
|
import { OUTBOX_DISPATCH_FAILS } from "./infra/outbox/outbox.dispatcher.js";
|
|
15
16
|
import { OUTBOX_FAST_PATH_SETTLED } from "./infra/outbox/outbox.module.js";
|
|
16
|
-
import { OUTBOX_STRICT_CONFLICTS } from "./infra/outbox/outbox.service.js";
|
|
17
17
|
import { PRESENCE_INTERVAL_MS } from "./infra/presence/replica-presence.js";
|
|
18
18
|
import type { KernelQueueName } from "./infra/queue/queue-names.js";
|
|
19
19
|
import { DEVICE_POLICY_AFTER_CALL } from "./local-devices/device-policy.service.js";
|
|
@@ -46,8 +46,6 @@ import { EMBED_TOKEN_CLOCK } from "./ui/embed-token.js";
|
|
|
46
46
|
* `CurrentTime` builtin the time;
|
|
47
47
|
* - `GIT_IDENTITY_API_BASE`: the API base of a git host for the commit identity (a loopback fake);
|
|
48
48
|
* - `GIT_UPSTREAM_ORIGIN`: the origin the git gateway relays a git host to (a loopback fake);
|
|
49
|
-
* - `OUTBOX_STRICT_CONFLICTS`: a reused outbox job id with different data throws (tests) instead
|
|
50
|
-
* of logging an error;
|
|
51
49
|
* - `OUTBOX_DISPATCH_FAILS`: returns true to make the outbox dispatcher's adds to the given queue
|
|
52
50
|
* fail (a Redis outage);
|
|
53
51
|
* - `USAGE_SUBSCRIBERS_CLOCK`: the clock the `usage.report` subscriber cache ages with;
|
|
@@ -59,7 +57,9 @@ import { EMBED_TOKEN_CLOCK } from "./ui/embed-token.js";
|
|
|
59
57
|
* - `PROJECT_KNOWLEDGE_TIMEOUT`: the run-start read of a bound project's time limit, read at every
|
|
60
58
|
* read (a test shortens it for one run);
|
|
61
59
|
* - `PLUGIN_PUBLIC_WRITE_LIMIT`: a lower limit for unsafe methods on `public` extension routes;
|
|
62
|
-
* - `
|
|
60
|
+
* - `SCOPE_ORG_CHUNK_SIZE`: fewer orgs per plugin scope sync chunk job (several chunks in a test);
|
|
61
|
+
* - `EXTENSION_NET_SEAMS`: `ctx.net`'s DNS and dispatcher (a hostname resolving to a private address
|
|
62
|
+
* served by a loopback fake);
|
|
63
63
|
* - `APP_INTERCEPTOR`: one more global interceptor (a probe of the matched routes).
|
|
64
64
|
*/
|
|
65
65
|
interface KernelSeams {
|
|
@@ -80,15 +80,15 @@ interface KernelSeams {
|
|
|
80
80
|
[RUN_CONTEXT_CLOCK]: () => number;
|
|
81
81
|
[GIT_IDENTITY_API_BASE]: GitIdentityApiBase;
|
|
82
82
|
[GIT_UPSTREAM_ORIGIN]: GitUpstreamOrigin;
|
|
83
|
-
[OUTBOX_STRICT_CONFLICTS]: boolean;
|
|
84
83
|
[OUTBOX_DISPATCH_FAILS]: (queue: KernelQueueName) => boolean;
|
|
85
84
|
[USAGE_SUBSCRIBERS_CLOCK]: () => number;
|
|
86
85
|
[OUTBOX_FAST_PATH_SETTLED]: (pass: Promise<void>) => void;
|
|
87
86
|
[ENSURE_RUN_FAILS]: () => boolean;
|
|
88
|
-
[
|
|
87
|
+
[SCOPE_ORG_CHUNK_SIZE]: number;
|
|
89
88
|
[PROJECT_KNOWLEDGE_TIMEOUT]: () => number;
|
|
90
89
|
[PLUGIN_PUBLIC_WRITE_LIMIT]: number;
|
|
91
90
|
[DEVICE_POLICY_AFTER_CALL]: (opId: string) => void;
|
|
91
|
+
[EXTENSION_NET_SEAMS]: ExtensionNetSeams;
|
|
92
92
|
[APP_INTERCEPTOR]: NestInterceptor;
|
|
93
93
|
}
|
|
94
94
|
/**
|
package/dist/overrides.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { APP_INTERCEPTOR } from "@nestjs/core";
|
|
2
2
|
import { ADMIN_USAGE_TIMINGS } from "./admin/usage.service.js";
|
|
3
|
-
import {
|
|
3
|
+
import { SCOPE_ORG_CHUNK_SIZE } from "./catalog/scope-jobs.js";
|
|
4
4
|
import { CHANNEL_WEBHOOK_TIMINGS } from "./channels/webhook.js";
|
|
5
|
+
import { EXTENSION_NET_SEAMS } from "./ctx/net.js";
|
|
5
6
|
import { EVAL_REPLAY_HOOKS } from "./evals/worker.js";
|
|
6
7
|
import { BOOTSTRAP_LOCK_TTL } from "./extensions/bootstrap.js";
|
|
7
8
|
import { USAGE_SUBSCRIBERS_CLOCK } from "./extensions/usage-subscribers.js";
|
|
@@ -11,7 +12,6 @@ import { GIT_IDENTITY_API_BASE } from "./git/identity.js";
|
|
|
11
12
|
import { PLUGIN_PUBLIC_WRITE_LIMIT } from "./http/plugin-route-access.js";
|
|
12
13
|
import { OUTBOX_DISPATCH_FAILS } from "./infra/outbox/outbox.dispatcher.js";
|
|
13
14
|
import { OUTBOX_FAST_PATH_SETTLED } from "./infra/outbox/outbox.module.js";
|
|
14
|
-
import { OUTBOX_STRICT_CONFLICTS } from "./infra/outbox/outbox.service.js";
|
|
15
15
|
import { PRESENCE_INTERVAL_MS } from "./infra/presence/replica-presence.js";
|
|
16
16
|
import { DEVICE_POLICY_AFTER_CALL } from "./local-devices/device-policy.service.js";
|
|
17
17
|
import { PROJECT_KNOWLEDGE_TIMEOUT } from "./runtime/project/knowledge.service.js";
|
|
@@ -44,14 +44,14 @@ const SEAM_TOKENS = [
|
|
|
44
44
|
RUN_CONTEXT_CLOCK,
|
|
45
45
|
GIT_IDENTITY_API_BASE,
|
|
46
46
|
GIT_UPSTREAM_ORIGIN,
|
|
47
|
-
OUTBOX_STRICT_CONFLICTS,
|
|
48
47
|
OUTBOX_DISPATCH_FAILS,
|
|
49
48
|
OUTBOX_FAST_PATH_SETTLED,
|
|
50
49
|
ENSURE_RUN_FAILS,
|
|
51
|
-
|
|
50
|
+
SCOPE_ORG_CHUNK_SIZE,
|
|
52
51
|
PROJECT_KNOWLEDGE_TIMEOUT,
|
|
53
52
|
PLUGIN_PUBLIC_WRITE_LIMIT,
|
|
54
53
|
DEVICE_POLICY_AFTER_CALL,
|
|
54
|
+
EXTENSION_NET_SEAMS,
|
|
55
55
|
APP_INTERCEPTOR,
|
|
56
56
|
];
|
|
57
57
|
const allSeamsListed = true;
|
package/dist/packages/tgz.d.ts
CHANGED
|
@@ -34,8 +34,6 @@ export declare const PACKAGE_TGZ_LIMITS: {
|
|
|
34
34
|
* `syncPackage` links for extensions.
|
|
35
35
|
*/
|
|
36
36
|
export declare const HOST_ZOD_VERSION: string;
|
|
37
|
-
/** The message for a tgz in the pre-0.1.0 format (follows the package's name). */
|
|
38
|
-
export declare const LEGACY_FORMAT_MESSAGE = "uses the pre-0.1.0 package format (capybara section / app.yaml); repack it as a plugin with .capybara-plugin/plugin.json (pnpm pack-plugin)";
|
|
39
37
|
/** `./skills/x` → `skills/x` (manifest paths start with `./`). */
|
|
40
38
|
export declare const packagePath: (p: string) => string;
|
|
41
39
|
/** A tgz or `package.json` problem; `issues` lists them (English, shown to the admin). */
|
package/dist/packages/tgz.js
CHANGED
|
@@ -39,8 +39,6 @@ export const PACKAGE_TGZ_LIMITS = {
|
|
|
39
39
|
* `syncPackage` links for extensions.
|
|
40
40
|
*/
|
|
41
41
|
export const HOST_ZOD_VERSION = createRequire(import.meta.url)("zod/package.json").version;
|
|
42
|
-
/** The message for a tgz in the pre-0.1.0 format (follows the package's name). */
|
|
43
|
-
export const LEGACY_FORMAT_MESSAGE = "uses the pre-0.1.0 package format (capybara section / app.yaml); repack it as a plugin with .capybara-plugin/plugin.json (pnpm pack-plugin)";
|
|
44
42
|
/** `./skills/x` → `skills/x` (manifest paths start with `./`). */
|
|
45
43
|
export const packagePath = (p) => p.replace(/^\.\//, "").replace(/\/+$/, "");
|
|
46
44
|
/** A tgz or `package.json` problem; `issues` lists them (English, shown to the admin). */
|
|
@@ -339,11 +339,6 @@ export const PLATFORM_EXCLUSIONS = [
|
|
|
339
339
|
category: "internal",
|
|
340
340
|
reason: "Deprecated message queue the web no longer uses; leftover items drain until the table is dropped",
|
|
341
341
|
},
|
|
342
|
-
{
|
|
343
|
-
route: "POST /api/v1/orgs/:orgId/conversations/:id/queue",
|
|
344
|
-
category: "internal",
|
|
345
|
-
reason: "Deprecated alias of POST messages, which stays with the person",
|
|
346
|
-
},
|
|
347
342
|
{
|
|
348
343
|
route: "POST /api/v1/orgs/:orgId/conversations/:id/queue/resume",
|
|
349
344
|
category: "internal",
|
|
@@ -49,7 +49,7 @@ export const PLATFORM_DOMAINS = [
|
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
id: "orgs",
|
|
52
|
-
description: "This org (read, rename, members) and, for the super admin, every org and its limits.",
|
|
52
|
+
description: "This org (read, rename, members, its audit log) and, for the super admin, every org and its limits.",
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
55
|
id: "accounts",
|