@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
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type ExtensionNet, type Logger } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import type { Agent } from "undici";
|
|
3
|
+
import type { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
4
|
+
import { type LookupFn } from "../net/public-address.js";
|
|
5
|
+
import type { OrgNetworkAllowances } from "../orgs/network-allowances.service.js";
|
|
6
|
+
/** Tests only: `safeFetch`'s DNS and dispatcher seams for `ctx.net`. */
|
|
7
|
+
export type ExtensionNetSeams = {
|
|
8
|
+
lookup?: LookupFn;
|
|
9
|
+
dispatcherFor?: (ips: string[]) => Agent;
|
|
10
|
+
proxyDispatcherFor?: (proxyUrl: string) => Agent;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Optional provider (a test seam, `KernelAppOptions.overrides`; the kernel never provides it):
|
|
14
|
+
* `ctx.net`'s DNS and dispatcher seams for every extension the host loads, so a kernel test can
|
|
15
|
+
* reach a fake server through a hostname that resolves to a private address.
|
|
16
|
+
*/
|
|
17
|
+
export declare const EXTENSION_NET_SEAMS: unique symbol;
|
|
18
|
+
/** The kernel services `ctx.net` reads per call (built once by the extension host). */
|
|
19
|
+
export type ExtensionNetServices = {
|
|
20
|
+
config: Pick<KernelConfigService, "get">;
|
|
21
|
+
allowances: Pick<OrgNetworkAllowances, "policyFor">;
|
|
22
|
+
/** Tests only: `safeFetch`'s DNS and dispatcher seams. */
|
|
23
|
+
seams?: ExtensionNetSeams;
|
|
24
|
+
};
|
|
25
|
+
/** What a refused private address tells the reader of an org-bound request. */
|
|
26
|
+
export declare const ORG_PRIVATE_HINT = "ask a super admin to allow this internal endpoint for the organization";
|
|
27
|
+
/** What a refused private address tells the reader of a request made outside an organization. */
|
|
28
|
+
export declare const NO_ORG_PRIVATE_HINT = "a request made outside an organization reaches public addresses only";
|
|
29
|
+
/**
|
|
30
|
+
* `ctx.net` (plugin safe fetch spec): the kernel's guarded client (`safeFetch`) for URLs a person
|
|
31
|
+
* supplied. Per call:
|
|
32
|
+
* - the policy is built fresh: `net.allowInsecureLoopback` (tests), the org's allowances read from
|
|
33
|
+
* PG when `opts.orgId` is given (no cache: a removal applies to the next request on every
|
|
34
|
+
* replica; another org's allowances never apply), public addresses only without an org, and the
|
|
35
|
+
* deployment's egress proxy (`net.httpsProxy` / `net.noProxy`: a proxied https request is
|
|
36
|
+
* resolved by the proxy, which then owns SSRF protection; IP-literal targets are still checked);
|
|
37
|
+
* - loopback, link-local and cloud metadata addresses are refused whatever the allowances
|
|
38
|
+
* (loopback allowed only under `net.allowInsecureLoopback`);
|
|
39
|
+
* - redirects are never followed: `redirect: "manual"` returns the 3xx response, otherwise a 3xx
|
|
40
|
+
* rejects with `net.redirect`;
|
|
41
|
+
* - no body size cap (bodies stream); `init.signal` is combined with `ctx.signal`;
|
|
42
|
+
* - a refusal rejects with the SDK's `NetDeniedError` and is logged at `warn` with the plugin, org,
|
|
43
|
+
* host and code (never the URL's path, query or headers).
|
|
44
|
+
*/
|
|
45
|
+
export declare function createExtensionNet(deps: ExtensionNetServices & {
|
|
46
|
+
log: Pick<Logger, "warn">;
|
|
47
|
+
plugin: string;
|
|
48
|
+
/** `ctx.signal`: aborts every request of the instance. */
|
|
49
|
+
signal: AbortSignal;
|
|
50
|
+
}): ExtensionNet;
|
package/dist/ctx/net.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { NetDeniedError as SdkNetDeniedError, } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { NetDeniedError } from "../net/public-address.js";
|
|
3
|
+
import { safeFetch } from "../net/safe-fetch.js";
|
|
4
|
+
/**
|
|
5
|
+
* Optional provider (a test seam, `KernelAppOptions.overrides`; the kernel never provides it):
|
|
6
|
+
* `ctx.net`'s DNS and dispatcher seams for every extension the host loads, so a kernel test can
|
|
7
|
+
* reach a fake server through a hostname that resolves to a private address.
|
|
8
|
+
*/
|
|
9
|
+
export const EXTENSION_NET_SEAMS = Symbol("EXTENSION_NET_SEAMS");
|
|
10
|
+
/** What a refused private address tells the reader of an org-bound request. */
|
|
11
|
+
export const ORG_PRIVATE_HINT = "ask a super admin to allow this internal endpoint for the organization";
|
|
12
|
+
/** What a refused private address tells the reader of a request made outside an organization. */
|
|
13
|
+
export const NO_ORG_PRIVATE_HINT = "a request made outside an organization reaches public addresses only";
|
|
14
|
+
/**
|
|
15
|
+
* `ctx.net` (plugin safe fetch spec): the kernel's guarded client (`safeFetch`) for URLs a person
|
|
16
|
+
* supplied. Per call:
|
|
17
|
+
* - the policy is built fresh: `net.allowInsecureLoopback` (tests), the org's allowances read from
|
|
18
|
+
* PG when `opts.orgId` is given (no cache: a removal applies to the next request on every
|
|
19
|
+
* replica; another org's allowances never apply), public addresses only without an org, and the
|
|
20
|
+
* deployment's egress proxy (`net.httpsProxy` / `net.noProxy`: a proxied https request is
|
|
21
|
+
* resolved by the proxy, which then owns SSRF protection; IP-literal targets are still checked);
|
|
22
|
+
* - loopback, link-local and cloud metadata addresses are refused whatever the allowances
|
|
23
|
+
* (loopback allowed only under `net.allowInsecureLoopback`);
|
|
24
|
+
* - redirects are never followed: `redirect: "manual"` returns the 3xx response, otherwise a 3xx
|
|
25
|
+
* rejects with `net.redirect`;
|
|
26
|
+
* - no body size cap (bodies stream); `init.signal` is combined with `ctx.signal`;
|
|
27
|
+
* - a refusal rejects with the SDK's `NetDeniedError` and is logged at `warn` with the plugin, org,
|
|
28
|
+
* host and code (never the URL's path, query or headers).
|
|
29
|
+
*/
|
|
30
|
+
export function createExtensionNet(deps) {
|
|
31
|
+
return {
|
|
32
|
+
async fetch(url, init, opts) {
|
|
33
|
+
const orgId = opts?.orgId;
|
|
34
|
+
const net = deps.config.get().net;
|
|
35
|
+
const exemptions = orgId
|
|
36
|
+
? await deps.allowances.policyFor(orgId)
|
|
37
|
+
: { allowPrivateHosts: [], trustedOrigins: [] };
|
|
38
|
+
const policy = {
|
|
39
|
+
allowInsecureLoopback: net.allowInsecureLoopback,
|
|
40
|
+
allowPrivateHosts: exemptions.allowPrivateHosts,
|
|
41
|
+
trustedOrigins: exemptions.trustedOrigins,
|
|
42
|
+
...(net.httpsProxy !== undefined && {
|
|
43
|
+
proxy: { url: net.httpsProxy, noProxy: net.noProxy },
|
|
44
|
+
}),
|
|
45
|
+
extension: { privateHint: orgId ? ORG_PRIVATE_HINT : NO_ORG_PRIVATE_HINT },
|
|
46
|
+
};
|
|
47
|
+
const signal = init?.signal ? AbortSignal.any([deps.signal, init.signal]) : deps.signal;
|
|
48
|
+
try {
|
|
49
|
+
return await safeFetch(url, { ...init, signal }, policy, {
|
|
50
|
+
redirects: init?.redirect === "manual" ? "return" : "refuse",
|
|
51
|
+
...deps.seams,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
if (!(e instanceof NetDeniedError))
|
|
56
|
+
throw e;
|
|
57
|
+
deps.log.warn("ctx.net.fetch refused a request", {
|
|
58
|
+
plugin: deps.plugin,
|
|
59
|
+
orgId: orgId ?? null,
|
|
60
|
+
host: e.host,
|
|
61
|
+
code: e.code,
|
|
62
|
+
});
|
|
63
|
+
throw new SdkNetDeniedError(e.code, e.host, e.message, e.status);
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
package/dist/ctx/secrets.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExtensionContext } from "@capybara-hq/plugin-sdk";
|
|
2
|
-
import type
|
|
2
|
+
import { type Kysely } from "kysely";
|
|
3
3
|
import type { KernelDb } from "../infra/database/kernel-db.js";
|
|
4
4
|
import type { TransactionHost } from "../infra/database/transaction-host.js";
|
|
5
5
|
/** 主密钥环:current 用于新包装,previous 仅用于解包。原始密钥只存在于闭包内。 */
|
|
@@ -42,12 +42,29 @@ export type KernelSecrets = ExtensionContext["secrets"] & {
|
|
|
42
42
|
* `db` 可以是 Kysely 事务:此时读写(含首次创建组织数据密钥)都在该事务内。
|
|
43
43
|
*/
|
|
44
44
|
export declare function createSecrets(db: AnyDb, keyring: Keyring, namespace: string): KernelSecrets;
|
|
45
|
-
/**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
/** What {@link rewrapToCurrentMasterKey} rewrapped. */
|
|
46
|
+
export interface RewrapResult {
|
|
47
|
+
/** Org data keys (`org_data_keys`) now wrapped with the current master key. */
|
|
48
|
+
dataKeys: number;
|
|
49
|
+
/** Unexpired one-time initial passwords (`account_initial_passwords`) now sealed with it. */
|
|
50
|
+
initialPasswords: number;
|
|
51
|
+
}
|
|
52
|
+
/** Rows rewrapped per transaction by default. */
|
|
53
|
+
export declare const REWRAP_BATCH_SIZE = 500;
|
|
54
|
+
/** The AAD binding a sealed initial password to its account (a row moved to another one fails). */
|
|
55
|
+
export declare const initialPasswordAad: (accountId: string) => string;
|
|
56
|
+
type RewrapHandles = {
|
|
50
57
|
db: Pick<KernelDb, "db">;
|
|
51
58
|
txHost: Pick<TransactionHost, "run">;
|
|
52
|
-
}
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Rewraps everything sealed with a master key other than the keyring's current one (org data keys
|
|
62
|
+
* and unexpired initial passwords) with the current key, `batchSize` rows per transaction, until
|
|
63
|
+
* none is left. Checks first that the keyring holds every master key in use and throws (naming row
|
|
64
|
+
* ids and key ids, never key material) before writing anything when it does not. Idempotent: a
|
|
65
|
+
* second run finds nothing; concurrent runs lock the same rows and skip the ones already done.
|
|
66
|
+
*/
|
|
67
|
+
export declare function rewrapToCurrentMasterKey(handles: RewrapHandles, keyring: Keyring, opts?: {
|
|
68
|
+
batchSize?: number;
|
|
69
|
+
}): Promise<RewrapResult>;
|
|
53
70
|
export {};
|
package/dist/ctx/secrets.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createCipheriv, createDecipheriv, createHash, hkdfSync, randomBytes } from "node:crypto";
|
|
2
|
+
import { sql } from "kysely";
|
|
2
3
|
import { assertNamespace } from "./namespace.js";
|
|
3
4
|
const IV_LEN = 12;
|
|
4
5
|
const TAG_LEN = 16;
|
|
@@ -142,38 +143,104 @@ export function createSecrets(db, keyring, namespace) {
|
|
|
142
143
|
},
|
|
143
144
|
};
|
|
144
145
|
}
|
|
146
|
+
/** Rows rewrapped per transaction by default. */
|
|
147
|
+
export const REWRAP_BATCH_SIZE = 500;
|
|
148
|
+
/** The AAD binding a sealed initial password to its account (a row moved to another one fails). */
|
|
149
|
+
export const initialPasswordAad = (accountId) => `capybara:initial-password:${accountId}`;
|
|
150
|
+
const MASTER_KEYED = [
|
|
151
|
+
{
|
|
152
|
+
table: "org_data_keys",
|
|
153
|
+
idColumn: "org_id",
|
|
154
|
+
dataColumn: "wrapped_key",
|
|
155
|
+
aad: dekAad,
|
|
156
|
+
hasExpiresAt: false,
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
table: "account_initial_passwords",
|
|
160
|
+
idColumn: "account_id",
|
|
161
|
+
dataColumn: "ciphertext",
|
|
162
|
+
aad: initialPasswordAad,
|
|
163
|
+
hasExpiresAt: true,
|
|
164
|
+
},
|
|
165
|
+
];
|
|
166
|
+
function staleRows(db, t, keyring) {
|
|
167
|
+
let q = db
|
|
168
|
+
.withSchema("capybara")
|
|
169
|
+
.selectFrom(t.table)
|
|
170
|
+
.where("master_key_id", "!=", keyring.currentId);
|
|
171
|
+
if (t.hasExpiresAt)
|
|
172
|
+
q = q.where("expires_at", ">", sql `now()`);
|
|
173
|
+
return q;
|
|
174
|
+
}
|
|
175
|
+
function assertKnown(t, keyring, rows) {
|
|
176
|
+
const unknown = rows.filter((r) => !keyring.has(r.mk));
|
|
177
|
+
if (unknown.length === 0)
|
|
178
|
+
return;
|
|
179
|
+
const shown = unknown.slice(0, 20).map((r) => `${r.id}(master_key_id=${r.mk})`);
|
|
180
|
+
throw new Error(`secrets: master key not in keyring for ${t.table}.${t.idColumn}: ${shown.join(", ")}`);
|
|
181
|
+
}
|
|
145
182
|
/**
|
|
146
|
-
*
|
|
147
|
-
*
|
|
183
|
+
* Rewraps everything sealed with a master key other than the keyring's current one (org data keys
|
|
184
|
+
* and unexpired initial passwords) with the current key, `batchSize` rows per transaction, until
|
|
185
|
+
* none is left. Checks first that the keyring holds every master key in use and throws (naming row
|
|
186
|
+
* ids and key ids, never key material) before writing anything when it does not. Idempotent: a
|
|
187
|
+
* second run finds nothing; concurrent runs lock the same rows and skip the ones already done.
|
|
148
188
|
*/
|
|
149
|
-
export async function
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
.
|
|
158
|
-
.
|
|
189
|
+
export async function rewrapToCurrentMasterKey(handles, keyring, opts = {}) {
|
|
190
|
+
const batchSize = opts.batchSize ?? REWRAP_BATCH_SIZE;
|
|
191
|
+
if (!Number.isInteger(batchSize) || batchSize < 1) {
|
|
192
|
+
throw new RangeError("rewrap batch size must be a positive integer");
|
|
193
|
+
}
|
|
194
|
+
const db = () => handles.db.db;
|
|
195
|
+
for (const t of MASTER_KEYED) {
|
|
196
|
+
const rows = await staleRows(db(), t, keyring)
|
|
197
|
+
.select([`${t.idColumn} as id`, "master_key_id as mk"])
|
|
198
|
+
.orderBy(t.idColumn)
|
|
159
199
|
.execute();
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
200
|
+
assertKnown(t, keyring, rows);
|
|
201
|
+
}
|
|
202
|
+
const counts = new Map();
|
|
203
|
+
for (const t of MASTER_KEYED) {
|
|
204
|
+
let total = 0;
|
|
205
|
+
for (;;) {
|
|
206
|
+
const done = await handles.txHost.run(async () => {
|
|
207
|
+
const trx = db();
|
|
208
|
+
const rows = await staleRows(trx, t, keyring)
|
|
209
|
+
.select([`${t.idColumn} as id`, "master_key_id as mk", `${t.dataColumn} as data`])
|
|
210
|
+
.orderBy(t.idColumn)
|
|
211
|
+
.limit(batchSize)
|
|
212
|
+
.forUpdate()
|
|
213
|
+
.execute();
|
|
214
|
+
// a row written meanwhile by a replica that runs an older config
|
|
215
|
+
assertKnown(t, keyring, rows);
|
|
216
|
+
for (const r of rows) {
|
|
217
|
+
let plain;
|
|
218
|
+
try {
|
|
219
|
+
plain = keyring.unwrap(r.mk, Buffer.from(r.data), t.aad(r.id));
|
|
220
|
+
}
|
|
221
|
+
catch (e) {
|
|
222
|
+
const why = e instanceof Error ? e.message : String(e);
|
|
223
|
+
throw new Error(`secrets: cannot unwrap ${t.table}.${t.idColumn}=${r.id}: ${why}`);
|
|
224
|
+
}
|
|
225
|
+
const w = keyring.wrap(plain, t.aad(r.id));
|
|
226
|
+
plain.fill(0);
|
|
227
|
+
await trx
|
|
228
|
+
.withSchema("capybara")
|
|
229
|
+
.updateTable(t.table)
|
|
230
|
+
.set({ [t.dataColumn]: w.data, master_key_id: w.masterKeyId })
|
|
231
|
+
.where(t.idColumn, "=", r.id)
|
|
232
|
+
.execute();
|
|
233
|
+
}
|
|
234
|
+
return rows.length;
|
|
235
|
+
});
|
|
236
|
+
total += done;
|
|
237
|
+
if (done === 0)
|
|
238
|
+
break;
|
|
176
239
|
}
|
|
177
|
-
|
|
178
|
-
}
|
|
240
|
+
counts.set(t.table, total);
|
|
241
|
+
}
|
|
242
|
+
return {
|
|
243
|
+
dataKeys: counts.get("org_data_keys") ?? 0,
|
|
244
|
+
initialPasswords: counts.get("account_initial_passwords") ?? 0,
|
|
245
|
+
};
|
|
179
246
|
}
|
|
@@ -156,6 +156,15 @@ export interface OrgToolSwitchesTable {
|
|
|
156
156
|
updated_by: string | null;
|
|
157
157
|
updated_at: Ts;
|
|
158
158
|
}
|
|
159
|
+
/** 0145: an internal endpoint a super admin lets the org's extension requests reach. */
|
|
160
|
+
export interface OrgNetworkAllowancesTable {
|
|
161
|
+
id: string;
|
|
162
|
+
org_id: string;
|
|
163
|
+
/** A hostname, `*.domain`, IP, CIDR or origin `http(s)://host[:port]`, normalized. */
|
|
164
|
+
entry: string;
|
|
165
|
+
created_by: string | null;
|
|
166
|
+
created_at: Ts;
|
|
167
|
+
}
|
|
159
168
|
export interface AuditEventsTable {
|
|
160
169
|
id: Generated<string>;
|
|
161
170
|
at: Ts;
|
|
@@ -1294,8 +1303,16 @@ export interface ScheduledTaskGrantsTable {
|
|
|
1294
1303
|
connector_id: string | null;
|
|
1295
1304
|
created_at: Ts;
|
|
1296
1305
|
}
|
|
1306
|
+
/** 0001: the per-org data key, wrapped by the master key (ctx/secrets.ts reads it untyped). */
|
|
1307
|
+
export interface OrgDataKeysTable {
|
|
1308
|
+
org_id: string;
|
|
1309
|
+
wrapped_key: Buffer;
|
|
1310
|
+
master_key_id: string;
|
|
1311
|
+
created_at: Ts;
|
|
1312
|
+
}
|
|
1297
1313
|
export interface KernelDatabase {
|
|
1298
1314
|
accounts: AccountsTable;
|
|
1315
|
+
org_data_keys: OrgDataKeysTable;
|
|
1299
1316
|
account_initial_passwords: AccountInitialPasswordsTable;
|
|
1300
1317
|
identities: IdentitiesTable;
|
|
1301
1318
|
local_passwords: LocalPasswordsTable;
|
|
@@ -1308,6 +1325,7 @@ export interface KernelDatabase {
|
|
|
1308
1325
|
extension_org_configs: ExtensionOrgConfigsTable;
|
|
1309
1326
|
extension_org_overrides: ExtensionOrgOverridesTable;
|
|
1310
1327
|
org_tool_switches: OrgToolSwitchesTable;
|
|
1328
|
+
org_network_allowances: OrgNetworkAllowancesTable;
|
|
1311
1329
|
audit_events: AuditEventsTable;
|
|
1312
1330
|
secrets: SecretsTable;
|
|
1313
1331
|
agents: AgentsTable;
|
|
@@ -1531,7 +1549,7 @@ export interface CatalogItemsTable {
|
|
|
1531
1549
|
builtin: ColumnType<boolean, boolean | undefined, boolean>;
|
|
1532
1550
|
/** 0075: switched off for every org by the super admin. */
|
|
1533
1551
|
disabled: ColumnType<boolean, boolean | undefined, boolean>;
|
|
1534
|
-
/** 0075:
|
|
1552
|
+
/** 0075: unused since design review 2026-11-16; dropped by a later contract migration. */
|
|
1535
1553
|
scope_version: ColumnType<number, number | undefined, number>;
|
|
1536
1554
|
/** 0077: orgs outside a `named` item's list see it as requestable (never usable). */
|
|
1537
1555
|
shown_to_others: ColumnType<boolean, boolean | undefined, boolean>;
|
|
@@ -1572,6 +1590,7 @@ interface PlatformScopeColumns {
|
|
|
1572
1590
|
scope: Dflt<ComponentScope>;
|
|
1573
1591
|
disabled: Dflt<boolean>;
|
|
1574
1592
|
shown_to_others: Dflt<boolean>;
|
|
1593
|
+
/** Unused since design review 2026-11-16; dropped by a later contract migration. */
|
|
1575
1594
|
scope_version: Dflt<number>;
|
|
1576
1595
|
}
|
|
1577
1596
|
/** 0081: a skill owned by the deployment (ruling A2). */
|
|
@@ -1894,20 +1913,22 @@ export interface CatalogOrgGrantsTable {
|
|
|
1894
1913
|
granted_by: string | null;
|
|
1895
1914
|
granted_at: Generated<Date>;
|
|
1896
1915
|
}
|
|
1897
|
-
/**
|
|
1916
|
+
/** 0049 / 0138: the states of a plugin install (`LIVE_INSTALL_STATUSES` are the live ones). */
|
|
1917
|
+
export type PluginInstallStatus = "installing" | "installed" | "failed" | "uninstalling";
|
|
1918
|
+
/** 0037: a plugin's install in an org. */
|
|
1898
1919
|
export interface PluginInstallsTable {
|
|
1899
1920
|
id: string;
|
|
1900
1921
|
org_id: string;
|
|
1901
1922
|
item_id: string;
|
|
1902
1923
|
version: string;
|
|
1903
|
-
/** 0049
|
|
1904
|
-
status:
|
|
1924
|
+
/** 0138 dropped 0049's `upgrading` (no per-org upgrade since ruling F2). */
|
|
1925
|
+
status: PluginInstallStatus;
|
|
1905
1926
|
installed_by: string | null;
|
|
1906
1927
|
installed_at: Generated<Date>;
|
|
1907
1928
|
error: ColumnType<unknown, string | null | undefined, string | null>;
|
|
1908
1929
|
/**
|
|
1909
|
-
* 0049: the journal of
|
|
1910
|
-
*
|
|
1930
|
+
* 0049: the journal of a per-org upgrade. Unused since 0138 (no code reads or writes it, every
|
|
1931
|
+
* row null); kept for the replicas of the previous release, dropped by a later migration.
|
|
1911
1932
|
*/
|
|
1912
1933
|
upgrade: ColumnType<unknown, string | null | undefined, string | null>;
|
|
1913
1934
|
}
|
|
@@ -15,7 +15,7 @@ import { ExtensionDisplayNames } from "../extensions/display-name.js";
|
|
|
15
15
|
import { audit } from "../identity/audit.js";
|
|
16
16
|
import { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
17
17
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
18
|
-
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
18
|
+
import { assertNotSharedAdmission, TransactionHost } from "../infra/database/transaction-host.js";
|
|
19
19
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
20
20
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
21
21
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
@@ -896,6 +896,7 @@ let DevicesService = class DevicesService {
|
|
|
896
896
|
* member (any more) → `org.not_found`, as the org guard answers.
|
|
897
897
|
*/
|
|
898
898
|
async lockMember(orgId, accountId, mode = "update") {
|
|
899
|
+
assertNotSharedAdmission("locking a membership");
|
|
899
900
|
const org = await this.db
|
|
900
901
|
.selectFrom("orgs")
|
|
901
902
|
.select("id")
|
package/dist/errors.d.ts
CHANGED
|
@@ -37,6 +37,11 @@ export declare const ERROR_CODES: {
|
|
|
37
37
|
readonly "org.sandbox_egress_not_allowed": 400;
|
|
38
38
|
/** The org asked for auto mode where the platform turned it off, or widened it through a token. */
|
|
39
39
|
readonly "org.auto_mode_not_allowed": 400;
|
|
40
|
+
/** An org network allowance entry that is malformed, names a link-local address, or is over the cap. */
|
|
41
|
+
readonly "org.network_allowance_invalid": 400;
|
|
42
|
+
readonly "org.network_allowance_not_found": 404;
|
|
43
|
+
/** Adding an org network allowance through an API token or the Platform tool (a person widens). */
|
|
44
|
+
readonly "org.network_allowance_widen_not_allowed": 400;
|
|
40
45
|
/** A deployment setting set in the startup config (file, Nacos or env): read-only in the admin console. */
|
|
41
46
|
readonly "deployment.setting_readonly": 409;
|
|
42
47
|
/** Turning the platform's auto mode on through an API token or the Platform tool (only off). */
|
|
@@ -61,7 +66,6 @@ export declare const ERROR_CODES: {
|
|
|
61
66
|
readonly "extension.has_dependents": 409;
|
|
62
67
|
readonly "extension.not_enabled": 409;
|
|
63
68
|
readonly "extension.package_invalid": 400;
|
|
64
|
-
readonly "extension.legacy_format": 422;
|
|
65
69
|
readonly "extension.no_extension": 400;
|
|
66
70
|
readonly "extension.package_too_large": 413;
|
|
67
71
|
readonly "extension.config_declared": 409;
|
|
@@ -89,7 +93,6 @@ export declare const ERROR_CODES: {
|
|
|
89
93
|
readonly "bootstrap.download_failed": 502;
|
|
90
94
|
readonly "bootstrap.missing_file": 500;
|
|
91
95
|
readonly "catalog.invalid_manifest": 422;
|
|
92
|
-
readonly "catalog.legacy_format": 422;
|
|
93
96
|
readonly "catalog.no_extension": 409;
|
|
94
97
|
readonly "catalog.dependency_unresolved": 409;
|
|
95
98
|
readonly "catalog.dependency_disabled": 409;
|
|
@@ -303,6 +306,11 @@ export declare const ERROR_CODES: {
|
|
|
303
306
|
readonly "connector.resources_disabled": 409;
|
|
304
307
|
/** Per-member tool policies on a connector with one org credential (decision 2026-11-09). */
|
|
305
308
|
readonly "connector.not_personal": 409;
|
|
309
|
+
/**
|
|
310
|
+
* Loosening a connector's default git push policy through the Platform tool or an API token:
|
|
311
|
+
* only a person in a session widens it.
|
|
312
|
+
*/
|
|
313
|
+
readonly "connector.git_push_widen_not_allowed": 400;
|
|
306
314
|
readonly "approval.not_found": 404;
|
|
307
315
|
readonly "approval.already_decided": 409;
|
|
308
316
|
readonly "approval.scope_not_allowed": 409;
|
package/dist/errors.js
CHANGED
|
@@ -37,6 +37,11 @@ export const ERROR_CODES = {
|
|
|
37
37
|
"org.sandbox_egress_not_allowed": 400,
|
|
38
38
|
/** The org asked for auto mode where the platform turned it off, or widened it through a token. */
|
|
39
39
|
"org.auto_mode_not_allowed": 400,
|
|
40
|
+
/** An org network allowance entry that is malformed, names a link-local address, or is over the cap. */
|
|
41
|
+
"org.network_allowance_invalid": 400,
|
|
42
|
+
"org.network_allowance_not_found": 404,
|
|
43
|
+
/** Adding an org network allowance through an API token or the Platform tool (a person widens). */
|
|
44
|
+
"org.network_allowance_widen_not_allowed": 400,
|
|
40
45
|
/** A deployment setting set in the startup config (file, Nacos or env): read-only in the admin console. */
|
|
41
46
|
"deployment.setting_readonly": 409,
|
|
42
47
|
/** Turning the platform's auto mode on through an API token or the Platform tool (only off). */
|
|
@@ -61,7 +66,6 @@ export const ERROR_CODES = {
|
|
|
61
66
|
"extension.has_dependents": 409,
|
|
62
67
|
"extension.not_enabled": 409,
|
|
63
68
|
"extension.package_invalid": 400,
|
|
64
|
-
"extension.legacy_format": 422,
|
|
65
69
|
"extension.no_extension": 400,
|
|
66
70
|
"extension.package_too_large": 413,
|
|
67
71
|
"extension.config_declared": 409,
|
|
@@ -89,7 +93,6 @@ export const ERROR_CODES = {
|
|
|
89
93
|
"bootstrap.download_failed": 502,
|
|
90
94
|
"bootstrap.missing_file": 500,
|
|
91
95
|
"catalog.invalid_manifest": 422,
|
|
92
|
-
"catalog.legacy_format": 422,
|
|
93
96
|
"catalog.no_extension": 409,
|
|
94
97
|
"catalog.dependency_unresolved": 409,
|
|
95
98
|
"catalog.dependency_disabled": 409,
|
|
@@ -303,6 +306,11 @@ export const ERROR_CODES = {
|
|
|
303
306
|
"connector.resources_disabled": 409,
|
|
304
307
|
/** Per-member tool policies on a connector with one org credential (decision 2026-11-09). */
|
|
305
308
|
"connector.not_personal": 409,
|
|
309
|
+
/**
|
|
310
|
+
* Loosening a connector's default git push policy through the Platform tool or an API token:
|
|
311
|
+
* only a person in a session widens it.
|
|
312
|
+
*/
|
|
313
|
+
"connector.git_push_widen_not_allowed": 400,
|
|
306
314
|
"approval.not_found": 404,
|
|
307
315
|
"approval.already_decided": 409,
|
|
308
316
|
"approval.scope_not_allowed": 409,
|
|
@@ -13,17 +13,10 @@ import { type CaseSnapshot } from "./snapshot.js";
|
|
|
13
13
|
* - `system_hash` / `tools_changed`(只在基线判定):system 指纹、工具序列(tools 与 catalog)与记录不同;
|
|
14
14
|
* - `tool_spec_missing`:快照里缺某个工具定义(从请求里去掉);
|
|
15
15
|
* - `definition_missing`:快照里缺该 agent 版本的定义(用空指令);
|
|
16
|
-
* - `pinned_changed` (phase B, never for a baseline, not with `definition_missing`): the
|
|
17
|
-
* `skills_catalog` snapshot in effect at the call pinned skills (`pinned` non-empty). No candidate
|
|
18
|
-
* can pin any more (skills default-on spec §9), so any candidate differs from such a call; the
|
|
19
|
-
* request still renders the recorded pinned bodies (Decision 1);
|
|
20
16
|
* - `subagent_changed` (phase C, never for a baseline): a sub-agent's (child) case with a candidate
|
|
21
17
|
* whose effective definition differs from the one frozen in its `subagent_started` (see
|
|
22
18
|
* {@link subagentChanged}); the request still renders the logged definition and preamble. A child
|
|
23
|
-
* case never consults `definitions` (no `definition_missing`)
|
|
24
|
-
* logged child definition that pinned counts as `subagent_changed`);
|
|
25
|
-
* - `legacy_event`:记录缺 `tools` / `params` / `absorbedUpToSeq` / `maxOutputTokens`,或还原出媒体而记录里没有
|
|
26
|
-
* `media` / `mediaBudgetBytes`(较早的事件);
|
|
19
|
+
* case never consults `definitions` (no `definition_missing`);
|
|
27
20
|
* - `params_changed`:没给候选参数时,记录的参数按所用模型的声明清洗后有键被丢弃或值变了(换了模型或模型声明变了);
|
|
28
21
|
* - `media_missing`:某附件记录里不是「不再可用」,还原时却取不到;
|
|
29
22
|
* - `media_changed`(只在基线判定):其余任何媒体结果与记录不同(按附件 id 比 outcome 与 etag:预算省略、
|
|
@@ -34,13 +27,8 @@ import { type CaseSnapshot } from "./snapshot.js";
|
|
|
34
27
|
*/
|
|
35
28
|
/** 还原结果与原请求不一致的原因。 */
|
|
36
29
|
export type DriftReason = "system_hash" | "tools_changed" | "tool_spec_missing" | "definition_missing"
|
|
37
|
-
/**
|
|
38
|
-
* The call rendered pinned skills (phase B), which no candidate has any more (skills default-on
|
|
39
|
-
* spec §9).
|
|
40
|
-
*/
|
|
41
|
-
| "pinned_changed"
|
|
42
30
|
/** A child case's candidate has another effective definition than the logged one (phase C). */
|
|
43
|
-
| "subagent_changed" | "
|
|
31
|
+
| "subagent_changed" | "params_changed"
|
|
44
32
|
/**
|
|
45
33
|
* UI refresh B: a non-baseline reconstruction whose run used a person's mid-conversation model
|
|
46
34
|
* switch (`model_switched`) and whose candidate model (`modelRef`) replaces it.
|
|
@@ -66,7 +54,7 @@ export interface ReconstructOptions {
|
|
|
66
54
|
/** 附件行信息与字节(调用方按 {@link snapshotMediaRefs} 取);缺省表示都取不到。 */
|
|
67
55
|
mediaInfo?: ReadonlyMap<string, MediaInfo>;
|
|
68
56
|
media?: ReadonlyMap<string, MediaBytes | null>;
|
|
69
|
-
/**
|
|
57
|
+
/** The request's media byte budget; defaults to the recorded `mediaBudgetBytes` (recorded only when the request had media). */
|
|
70
58
|
mediaBudgetBytes?: number;
|
|
71
59
|
/** The candidate's model (a non-baseline reconstruction): checked against the run's switch. */
|
|
72
60
|
modelRef?: ModelRef;
|
|
@@ -116,8 +104,7 @@ export interface SubagentTemplateRef {
|
|
|
116
104
|
* Does a candidate change what a sub-agent (child) case would run (`subagent_changed`, spec
|
|
117
105
|
* §15.1)? Pure, from the snapshot alone, comparing the model-visible parts of the effective
|
|
118
106
|
* definition (instructions, turned-off skills, tools) with the logged one (`logged`, from its
|
|
119
|
-
* `subagent_started`).
|
|
120
|
-
* differs from every candidate: none pins any more (skills default-on spec §9).
|
|
107
|
+
* `subagent_started`).
|
|
121
108
|
* - the same agent version (`sameVersion`): the candidate is the logged definition with
|
|
122
109
|
* overrides (instructions, model, params), compared field by field;
|
|
123
110
|
* - another version of the case's agent: for an org agent child (`source: "agent"`) that agent's
|