@capybara-hq/kernel 0.1.0-rc.145 → 0.1.0-rc.147
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/dist/admin/extensions.controller.d.ts +0 -11
- package/dist/admin/extensions.controller.js +0 -28
- package/dist/admin/health.service.d.ts +25 -1
- package/dist/admin/health.service.js +50 -18
- package/dist/audit/full-access.d.ts +78 -0
- package/dist/audit/full-access.js +283 -0
- package/dist/automations/automations.service.d.ts +1 -0
- package/dist/automations/automations.service.js +3 -1
- package/dist/automations/calendar.js +3 -1
- package/dist/automations/grant-rules.d.ts +2 -1
- package/dist/automations/grant-rules.js +8 -1
- package/dist/automations/unattended.d.ts +13 -1
- package/dist/automations/unattended.js +13 -1
- package/dist/catalog/admin-catalog.controller.d.ts +8 -0
- package/dist/catalog/admin-catalog.controller.js +8 -2
- package/dist/catalog/admin-catalog.schemas.d.ts +10 -0
- package/dist/catalog/admin-catalog.schemas.js +8 -1
- package/dist/catalog/catalog-content.d.ts +6 -0
- package/dist/catalog/catalog-scope.service.d.ts +22 -2
- package/dist/catalog/catalog-scope.service.js +27 -3
- package/dist/catalog/catalog.service.js +19 -2
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.service.d.ts +8 -1
- package/dist/catalog/org-catalog.service.js +36 -3
- package/dist/catalog/platform-components.js +3 -2
- package/dist/catalog/platform-import-update.d.ts +2 -0
- package/dist/catalog/platform-import-update.js +8 -1
- package/dist/catalog/plugin-connectors.d.ts +11 -0
- package/dist/catalog/plugin-connectors.js +33 -0
- package/dist/catalog/plugin-import.d.ts +35 -15
- package/dist/catalog/plugin-import.js +110 -35
- package/dist/catalog/plugin-install.js +6 -0
- package/dist/catalog/provenance.d.ts +71 -0
- package/dist/catalog/provenance.js +112 -0
- package/dist/config/auto-approve.d.ts +16 -0
- package/dist/config/auto-approve.js +24 -0
- package/dist/config/capacity-presets.d.ts +243 -0
- package/dist/config/capacity-presets.js +195 -0
- package/dist/config/env.d.ts +2 -1
- package/dist/config/env.js +6 -1
- package/dist/config/load.js +15 -0
- package/dist/config/schema.d.ts +46 -9
- package/dist/config/schema.js +154 -30
- package/dist/ctx/create-ctx.d.ts +16 -0
- package/dist/ctx/create-ctx.js +269 -34
- package/dist/ctx/net.d.ts +5 -1
- package/dist/ctx/net.js +62 -12
- package/dist/db/kernel-schema.d.ts +31 -0
- package/dist/db/migrator.js +0 -36
- package/dist/dial-in/routes.js +1 -1
- package/dist/erasure/org-batches.js +1 -6
- package/dist/erasure/org-catalog.js +6 -2
- package/dist/erasure/org-rules.js +1 -0
- package/dist/erasure/org-worker.js +0 -13
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +6 -0
- package/dist/extensions/admin-ops.d.ts +14 -1
- package/dist/extensions/admin-ops.js +30 -3
- package/dist/extensions/admin-view.d.ts +21 -1
- package/dist/extensions/admin-view.js +43 -0
- package/dist/extensions/bootstrap-packages.d.ts +5 -0
- package/dist/extensions/bootstrap-packages.js +1 -1
- package/dist/extensions/bootstrap-review.d.ts +251 -0
- package/dist/extensions/bootstrap-review.js +676 -0
- package/dist/extensions/bootstrap.d.ts +21 -1
- package/dist/extensions/bootstrap.js +72 -2
- package/dist/extensions/cli.d.ts +6 -0
- package/dist/extensions/cli.js +4 -0
- package/dist/extensions/enabled.d.ts +3 -0
- package/dist/extensions/execution-realm.d.ts +96 -0
- package/dist/extensions/execution-realm.js +141 -0
- package/dist/extensions/extensions.module.js +12 -0
- package/dist/extensions/full-access-disclosure.d.ts +15 -0
- package/dist/extensions/full-access-disclosure.js +57 -0
- package/dist/extensions/grant-epoch.d.ts +9 -2
- package/dist/extensions/grant-epoch.js +13 -2
- package/dist/extensions/host.d.ts +96 -4
- package/dist/extensions/host.js +411 -33
- package/dist/extensions/installs.d.ts +18 -0
- package/dist/extensions/installs.js +28 -0
- package/dist/extensions/instance.d.ts +2 -0
- package/dist/extensions/instance.js +1 -0
- package/dist/extensions/isolated/admission.d.ts +23 -2
- package/dist/extensions/isolated/admission.js +32 -7
- package/dist/extensions/isolated/authorization.d.ts +8 -2
- package/dist/extensions/isolated/authorization.js +11 -3
- package/dist/extensions/isolated/broker.d.ts +3 -0
- package/dist/extensions/isolated/broker.js +50 -14
- package/dist/extensions/isolated/configured-package.d.ts +5 -0
- package/dist/extensions/isolated/configured-package.js +2 -0
- package/dist/extensions/isolated/lanes.d.ts +44 -3
- package/dist/extensions/isolated/lanes.js +263 -80
- package/dist/extensions/isolated/metrics.d.ts +146 -0
- package/dist/extensions/isolated/metrics.js +304 -0
- package/dist/extensions/isolated/revision.d.ts +7 -1
- package/dist/extensions/isolated/revision.js +26 -5
- package/dist/extensions/isolated/rpc.d.ts +5 -0
- package/dist/extensions/isolated/rpc.js +7 -2
- package/dist/extensions/isolated/sandbox.d.ts +23 -0
- package/dist/extensions/isolated/sandbox.js +50 -0
- package/dist/extensions/isolated/status.d.ts +79 -0
- package/dist/extensions/isolated/status.js +216 -0
- package/dist/extensions/isolated/tier.d.ts +127 -2
- package/dist/extensions/isolated/tier.js +266 -7
- package/dist/extensions/isolated/usage.d.ts +134 -0
- package/dist/extensions/isolated/usage.js +322 -0
- package/dist/extensions/ledger.d.ts +5 -0
- package/dist/extensions/ledger.js +16 -0
- package/dist/extensions/lifecycle.d.ts +42 -2
- package/dist/extensions/lifecycle.js +100 -4
- package/dist/extensions/org-config.js +11 -0
- package/dist/extensions/package.d.ts +14 -0
- package/dist/extensions/package.js +23 -0
- package/dist/extensions/permission-view.d.ts +2 -2
- package/dist/extensions/permissions.controller.d.ts +35 -0
- package/dist/extensions/permissions.controller.js +98 -0
- package/dist/extensions/permissions.schemas.d.ts +288 -0
- package/dist/extensions/permissions.schemas.js +96 -0
- package/dist/extensions/permissions.service.d.ts +116 -0
- package/dist/extensions/permissions.service.js +428 -0
- package/dist/extensions/realm-retirement.d.ts +65 -0
- package/dist/extensions/realm-retirement.js +150 -0
- package/dist/extensions/registry.d.ts +6 -0
- package/dist/extensions/registry.js +8 -0
- package/dist/extensions/review-hash.d.ts +114 -0
- package/dist/extensions/review-hash.js +145 -0
- package/dist/extensions/revision-approvals.d.ts +58 -3
- package/dist/extensions/revision-approvals.js +135 -14
- package/dist/extensions/revision-grants.d.ts +10 -0
- package/dist/extensions/revision-review.d.ts +144 -0
- package/dist/extensions/revision-review.js +297 -0
- package/dist/extensions/revocation-leases.d.ts +273 -0
- package/dist/extensions/revocation-leases.js +533 -0
- package/dist/extensions/revocation.d.ts +78 -0
- package/dist/extensions/revocation.js +205 -0
- package/dist/extensions/state.module.js +12 -0
- package/dist/git/run-end.d.ts +35 -7
- package/dist/git/run-end.js +87 -38
- package/dist/http/api.module.js +2 -0
- package/dist/identity/audit.d.ts +2 -1
- package/dist/identity/audit.js +4 -17
- package/dist/index.d.ts +10 -2
- package/dist/index.js +10 -2
- package/dist/infra/config/kernel-config.service.d.ts +6 -0
- package/dist/infra/config/kernel-config.service.js +21 -0
- package/dist/infra/outbox/registry.d.ts +13 -0
- package/dist/infra/outbox/registry.js +8 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +27 -1
- package/dist/lifecycle/kernel-lifecycle.js +83 -22
- package/dist/net/private-endpoint-preflight.d.ts +159 -0
- package/dist/net/private-endpoint-preflight.js +417 -0
- package/dist/net/private-endpoints.d.ts +68 -0
- package/dist/net/private-endpoints.js +164 -0
- package/dist/net/public-address.d.ts +14 -0
- package/dist/net/public-address.js +15 -1
- package/dist/net/safe-fetch.d.ts +2 -1
- package/dist/net/safe-fetch.js +10 -3
- package/dist/overrides.d.ts +9 -1
- package/dist/overrides.js +4 -0
- package/dist/packages/official-publisher.d.ts +65 -1
- package/dist/packages/official-publisher.js +171 -46
- package/dist/packages/provenance.d.ts +11 -0
- package/dist/packages/provenance.js +24 -0
- package/dist/platform/exclusions.js +4 -4
- package/dist/platform/ops/automations.ops.js +1 -1
- package/dist/platform/ops/catalog-admin.ops.js +25 -4
- package/dist/platform/ops/extension-permissions.ops.d.ts +11 -0
- package/dist/platform/ops/extension-permissions.ops.js +159 -0
- package/dist/platform/platform-ops.module.d.ts +2 -1
- package/dist/platform/platform-ops.module.js +2 -0
- package/dist/platform/route-schemas.js +2 -0
- package/dist/retention/purge-batch.js +10 -14
- package/dist/runtime/maintenance.d.ts +4 -2
- package/dist/runtime/maintenance.js +16 -3
- package/dist/runtime/run-finish.d.ts +3 -3
- package/dist/runtime/run-finish.js +7 -3
- package/dist/sandbox/permission-availability.d.ts +17 -2
- package/dist/sandbox/permission-availability.js +22 -1
- package/dist/sandbox/permission-facts.js +7 -1
- package/dist/tools/builtins/sandbox/common.js +2 -0
- package/dist/tools/pipeline.d.ts +2 -1
- package/dist/tools/pipeline.js +7 -2
- package/package.json +4 -3
- package/src/migrations/0238_extension_usage.sql +40 -0
- package/src/migrations/0239_extension_replica_isolation.sql +28 -0
package/dist/config/schema.js
CHANGED
|
@@ -3,20 +3,67 @@ import { CATALOG_ITEM_NAME_RE, DOCUMENT_MEDIA_TYPES, EXTENSION_NAME_RE, IMAGE_ME
|
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { AllowedProfilesSchema } from "../conversations/permission-profiles.schemas.js";
|
|
5
5
|
import { LOG_FORMATS, LOG_LEVELS } from "../log.js";
|
|
6
|
+
import { PRIVATE_ENDPOINT_ALIAS_RE, PRIVATE_ENDPOINT_METHODS, privateEndpointOriginProblem, privateEndpointPathPrefixProblem, } from "../net/private-endpoints.js";
|
|
6
7
|
import { noProxyEntryProblem, proxyUrlProblem } from "../net/proxy.js";
|
|
7
|
-
import { privateHostEntryProblem } from "../net/public-address.js";
|
|
8
|
+
import { isLoopbackAddress, isLoopbackHost, normalizeHost, privateHostEntryProblem, } from "../net/public-address.js";
|
|
9
|
+
import { autoApproveRefusal, isOfficialImage } from "./auto-approve.js";
|
|
10
|
+
import { CAPACITY_FIELD_NAMES, CAPACITY_FIELDS, CAPACITY_PRESETS, capacityDescription, DEFAULT_CAPACITY_PRESET, noteConfigFallback, } from "./capacity-presets.js";
|
|
8
11
|
/**
|
|
9
12
|
* 构造给 Zod 4 `.meta()` 使用的字段元信息。
|
|
10
13
|
* 用法:`z.string().meta(meta({ secret: true, description: "..." }))`。
|
|
11
14
|
*/
|
|
12
|
-
/** Defaults of `extensionHost.capacity`, also used where a hand-built config leaves it out. */
|
|
13
|
-
export const EXTENSION_CAPACITY_DEFAULTS = {
|
|
14
|
-
grantEpochMaxAgeMs: 3000,
|
|
15
|
-
grantCacheEntries: 10_000,
|
|
16
|
-
};
|
|
17
15
|
export function meta(opts) {
|
|
18
16
|
return { ...opts };
|
|
19
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* `extensionHost.capacity` (platform-only: kernel config is never org-overridable). Every field is
|
|
20
|
+
* optional: unset means the preset's value (`resolveCapacity`). An invalid value never fails
|
|
21
|
+
* startup or a hot reload: it is caught per field, noted for the config service's warning and
|
|
22
|
+
* resolved from the preset. An unknown key is dropped with a warning and the valid explicit fields
|
|
23
|
+
* stay; only a section that is not an object at all falls back whole.
|
|
24
|
+
*/
|
|
25
|
+
const capacityShape = {
|
|
26
|
+
preset: z
|
|
27
|
+
.enum(CAPACITY_PRESETS)
|
|
28
|
+
.optional()
|
|
29
|
+
.catch(() => {
|
|
30
|
+
noteConfigFallback("extensionHost.capacity.preset");
|
|
31
|
+
return undefined;
|
|
32
|
+
})
|
|
33
|
+
.meta(meta({
|
|
34
|
+
description: `Capacity preset that sets every default under extensionHost.capacity: dev (laptops and CI), standard (up to 10k members; exactly the isolated host's limits before presets existed) or large (10k to 100k members). Unset or invalid means ${DEFAULT_CAPACITY_PRESET}; a field set explicitly wins over its preset value. Changing it needs a restart`,
|
|
35
|
+
})),
|
|
36
|
+
...Object.fromEntries(CAPACITY_FIELD_NAMES.map((field) => [
|
|
37
|
+
field,
|
|
38
|
+
z
|
|
39
|
+
.number()
|
|
40
|
+
.int()
|
|
41
|
+
.min(CAPACITY_FIELDS[field].min)
|
|
42
|
+
.max(CAPACITY_FIELDS[field].max)
|
|
43
|
+
.optional()
|
|
44
|
+
.catch(() => {
|
|
45
|
+
noteConfigFallback(`extensionHost.capacity.${field}`);
|
|
46
|
+
return undefined;
|
|
47
|
+
})
|
|
48
|
+
.meta(meta({ hot: CAPACITY_FIELDS[field].hot, description: capacityDescription(field) })),
|
|
49
|
+
])),
|
|
50
|
+
};
|
|
51
|
+
const capacityLenient = z.object(capacityShape);
|
|
52
|
+
const capacitySchema = z
|
|
53
|
+
.strictObject(capacityShape)
|
|
54
|
+
.catch((ctx) => {
|
|
55
|
+
const input = ctx.value;
|
|
56
|
+
if (typeof input !== "object" || input === null || Array.isArray(input)) {
|
|
57
|
+
noteConfigFallback("extensionHost.capacity");
|
|
58
|
+
return {};
|
|
59
|
+
}
|
|
60
|
+
for (const key of Object.keys(input)) {
|
|
61
|
+
if (!Object.hasOwn(capacityShape, key))
|
|
62
|
+
noteConfigFallback(`extensionHost.capacity.${key}`);
|
|
63
|
+
}
|
|
64
|
+
return capacityLenient.parse(input);
|
|
65
|
+
})
|
|
66
|
+
.prefault({});
|
|
20
67
|
/** 校验 base64 主密钥解码后恰为 32 字节。 */
|
|
21
68
|
function isValidMasterKey(value) {
|
|
22
69
|
if (!/^[A-Za-z0-9+/]+={0,2}$/.test(value))
|
|
@@ -25,6 +72,8 @@ function isValidMasterKey(value) {
|
|
|
25
72
|
}
|
|
26
73
|
/** Schemes an app redirect URI never uses: the consent page navigates to it. */
|
|
27
74
|
const UNSAFE_REDIRECT_RE = /^\s*(?:javascript|data|vbscript|file):/i;
|
|
75
|
+
/** A bootstrap batch review hash (`extensions/bootstrap-review.ts`): `bootstrap:v1:<sha256 hex>`. */
|
|
76
|
+
export const BOOTSTRAP_REVIEW_HASH_RE = /^bootstrap:v1:[0-9a-f]{64}$/;
|
|
28
77
|
/** `sandbox.limits.maxCommandSeconds` 的默认值。 */
|
|
29
78
|
export const DEFAULT_MAX_COMMAND_SECONDS = 7200;
|
|
30
79
|
/** access token 寿命上限(秒);会话吊销标记的 TTL 按它计算,与实例当前配置无关。 */
|
|
@@ -511,27 +560,7 @@ export const KernelConfigSchema = z.strictObject({
|
|
|
511
560
|
})),
|
|
512
561
|
})
|
|
513
562
|
.optional(),
|
|
514
|
-
capacity:
|
|
515
|
-
.strictObject({
|
|
516
|
-
grantEpochMaxAgeMs: z
|
|
517
|
-
.number()
|
|
518
|
-
.int()
|
|
519
|
-
.min(1500)
|
|
520
|
-
.max(3500)
|
|
521
|
-
.default(EXTENSION_CAPACITY_DEFAULTS.grantEpochMaxAgeMs)
|
|
522
|
-
.meta(meta({
|
|
523
|
-
description: "Milliseconds a replica trusts its cached isolated extension grants after its last successful read of the grant epoch (read every second); when the epoch is older, new isolated calls wait for a fresh read and are refused if it fails. Kept below the 4 s fence deadline, which leaves 1 s of slack under the 5 s revocation bound",
|
|
524
|
-
})),
|
|
525
|
-
grantCacheEntries: z
|
|
526
|
-
.number()
|
|
527
|
-
.int()
|
|
528
|
-
.positive()
|
|
529
|
-
.default(EXTENSION_CAPACITY_DEFAULTS.grantCacheEntries)
|
|
530
|
-
.meta(meta({
|
|
531
|
-
description: "Maximum isolated extension grants (one per running extension instance and org) each replica caches; the least recently used idle grant is evicted first, and a call is refused when every cached grant is in use",
|
|
532
|
-
})),
|
|
533
|
-
})
|
|
534
|
-
.prefault({}),
|
|
563
|
+
capacity: capacitySchema,
|
|
535
564
|
drainSeconds: z
|
|
536
565
|
.number()
|
|
537
566
|
.int()
|
|
@@ -574,6 +603,37 @@ export const KernelConfigSchema = z.strictObject({
|
|
|
574
603
|
})),
|
|
575
604
|
})
|
|
576
605
|
.prefault({}),
|
|
606
|
+
metrics: z
|
|
607
|
+
.strictObject({
|
|
608
|
+
orgLabelMinMembers: z
|
|
609
|
+
.number()
|
|
610
|
+
.int()
|
|
611
|
+
.positive()
|
|
612
|
+
.default(1000)
|
|
613
|
+
.catch(() => {
|
|
614
|
+
noteConfigFallback("metrics.orgLabelMinMembers");
|
|
615
|
+
return 1000;
|
|
616
|
+
})
|
|
617
|
+
.meta(meta({
|
|
618
|
+
hot: true,
|
|
619
|
+
description: 'Members an org needs before kernel metrics that carry an org label (the isolated extension host\'s) name it; smaller orgs report as org="other". Read at the next label refresh (every 5 minutes per replica)',
|
|
620
|
+
})),
|
|
621
|
+
orgLabelMaxOrgs: z
|
|
622
|
+
.number()
|
|
623
|
+
.int()
|
|
624
|
+
.min(0)
|
|
625
|
+
.max(200)
|
|
626
|
+
.default(20)
|
|
627
|
+
.catch(() => {
|
|
628
|
+
noteConfigFallback("metrics.orgLabelMaxOrgs");
|
|
629
|
+
return 20;
|
|
630
|
+
})
|
|
631
|
+
.meta(meta({
|
|
632
|
+
hot: true,
|
|
633
|
+
description: 'At most this many orgs, the largest by member count among those at or above orgLabelMinMembers, get their own org label; every other org reports as org="other", which bounds the label set at orgLabelMaxOrgs + 2 values (with "other" and "none" for deployment work). 0 labels no org',
|
|
634
|
+
})),
|
|
635
|
+
})
|
|
636
|
+
.prefault({}),
|
|
577
637
|
packages: z
|
|
578
638
|
.strictObject({
|
|
579
639
|
npmRegistry: z
|
|
@@ -614,6 +674,15 @@ export const KernelConfigSchema = z.strictObject({
|
|
|
614
674
|
.meta(meta({
|
|
615
675
|
description: "Path of a bootstrap-extra.v1 manifest, resolved against the working directory like bootstrap.dir, that is merged with the built-in bootstrap manifest (extra plugins and marketplaces for a distribution). Absent by default",
|
|
616
676
|
})),
|
|
677
|
+
approvedReviews: z
|
|
678
|
+
.array(z.string().regex(BOOTSTRAP_REVIEW_HASH_RE, {
|
|
679
|
+
message: "a bootstrap review hash looks like bootstrap:v1:<64 lowercase hex>",
|
|
680
|
+
}))
|
|
681
|
+
.max(64)
|
|
682
|
+
.default([])
|
|
683
|
+
.meta(meta({
|
|
684
|
+
description: "Bootstrap review hashes the operator approves in advance (printed by `capybara bootstrap review --print-review`, published in the release notes for the shipped pins). When the review of this deployment's bootstrap pins and config-declared extensions has one of these hashes, `capybara bootstrap approve` and the kernel start grant its revisions, audited as operator (config). The hash binds this deployment's previous approvals (a live grant on another revision of a pinned plugin), so a published hash matches only deployments without one; recompute it with `capybara bootstrap review --print-review`. A hash only becomes consent once it is recorded here; a stale hash grants nothing and the start logs a warning naming the current hash",
|
|
685
|
+
})),
|
|
617
686
|
})
|
|
618
687
|
.prefault({}),
|
|
619
688
|
catalog: z
|
|
@@ -717,7 +786,7 @@ export const KernelConfigSchema = z.strictObject({
|
|
|
717
786
|
.boolean()
|
|
718
787
|
.default(false)
|
|
719
788
|
.meta(meta({
|
|
720
|
-
description: "Testing only: lift every loopback and unspecified-address refusal for extensions' ctx.net.fetch (127.0.0.0/8, ::1, 0.0.0.0/8, ::), including plain http to them (fake servers in test stacks). Link-local and cloud metadata addresses stay refused. Never set it in production",
|
|
789
|
+
description: "Testing only: lift every loopback and unspecified-address refusal for extensions' ctx.net.fetch (127.0.0.0/8, ::1, 0.0.0.0/8, ::), including plain http to them (fake servers in test stacks). Link-local and cloud metadata addresses stay refused. It also lifts the loopback refusal for the extension isolation Engine API's port, so never set it where the Engine listens on loopback. Never set it in production",
|
|
721
790
|
})),
|
|
722
791
|
allowPrivateHosts: z
|
|
723
792
|
.array(z.string().superRefine((entry, ctx) => {
|
|
@@ -755,7 +824,51 @@ export const KernelConfigSchema = z.strictObject({
|
|
|
755
824
|
.max(100)
|
|
756
825
|
.default([])
|
|
757
826
|
.meta(meta({
|
|
758
|
-
description: "Hostnames or IP addresses that bypass net.httpsProxy (an entry also matches its subdomains; a leading dot is allowed). These hosts are resolved locally and must resolve to public addresses unless listed in net.allowPrivateHosts (the kernel's own requests) or in an organization's allowed internal endpoints (ctx.net.fetch). List an organization's allowed internal https hosts here when net.httpsProxy is set, otherwise the proxy resolves them and the allowances do not apply",
|
|
827
|
+
description: "Hostnames or IP addresses that bypass net.httpsProxy (an entry also matches its subdomains; a leading dot is allowed). These hosts are resolved locally and must resolve to public addresses unless listed in net.allowPrivateHosts (the kernel's own requests) or in an organization's allowed internal endpoints (ctx.net.fetch). List an organization's allowed internal https hosts here when net.httpsProxy is set, otherwise the proxy resolves them and the allowances do not apply. net.privateEndpoints origins need no entry: alias requests always bypass the proxy",
|
|
828
|
+
})),
|
|
829
|
+
privateEndpoints: z
|
|
830
|
+
.record(z
|
|
831
|
+
.string()
|
|
832
|
+
.regex(PRIVATE_ENDPOINT_ALIAS_RE, "must be a lower-case alias such as llm-gateway"), z.strictObject({
|
|
833
|
+
origin: z.string().superRefine((value, ctx) => {
|
|
834
|
+
const problem = privateEndpointOriginProblem(value);
|
|
835
|
+
if (problem !== undefined)
|
|
836
|
+
ctx.addIssue({ code: "custom", message: problem });
|
|
837
|
+
}),
|
|
838
|
+
pathPrefix: z
|
|
839
|
+
.string()
|
|
840
|
+
.max(512)
|
|
841
|
+
.superRefine((value, ctx) => {
|
|
842
|
+
const problem = privateEndpointPathPrefixProblem(value);
|
|
843
|
+
if (problem !== undefined)
|
|
844
|
+
ctx.addIssue({ code: "custom", message: problem });
|
|
845
|
+
})
|
|
846
|
+
.default("/"),
|
|
847
|
+
methods: z.array(z.enum(PRIVATE_ENDPOINT_METHODS)).min(1).optional(),
|
|
848
|
+
plugins: z.array(z.string().regex(EXTENSION_NAME_RE)).min(1).max(100),
|
|
849
|
+
allowLoopback: z.boolean().default(false),
|
|
850
|
+
}))
|
|
851
|
+
.superRefine((endpoints, ctx) => {
|
|
852
|
+
for (const [alias, e] of Object.entries(endpoints)) {
|
|
853
|
+
if (privateEndpointOriginProblem(e.origin) !== undefined)
|
|
854
|
+
continue;
|
|
855
|
+
const host = normalizeHost(new URL(e.origin).hostname);
|
|
856
|
+
const loopback = isLoopbackHost(host) || (isIP(host) !== 0 && isLoopbackAddress(host));
|
|
857
|
+
if (loopback && !e.allowLoopback) {
|
|
858
|
+
ctx.addIssue({
|
|
859
|
+
code: "custom",
|
|
860
|
+
path: [alias, "origin"],
|
|
861
|
+
message: "a loopback origin needs allowLoopback: true",
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
if (Object.keys(endpoints).length > 50) {
|
|
866
|
+
ctx.addIssue({ code: "custom", message: "at most 50 private endpoints" });
|
|
867
|
+
}
|
|
868
|
+
})
|
|
869
|
+
.default({})
|
|
870
|
+
.meta(meta({
|
|
871
|
+
description: 'Named private destinations that extensions\' ctx.net.fetch requests made outside an organization may reach, e.g. {"llm-gateway":{"origin":"https://llm.corp.internal:8443","pathPrefix":"/v1","methods":["GET","POST"],"plugins":["anthropic","openai"]}} for a model provider pointed at an internal gateway. A request is admitted when it comes from a listed plugin (its extension name), carries no organization, and goes to exactly the origin (scheme, host and port; http allowed when the origin says http) under pathPrefix (default /; under a narrower prefix, encoded slashes or percent signs, ; parameters and encoded dot segments are refused) with one of methods (unset: any; when set, method-override headers and a _method query parameter are refused). Its host is still resolved and checked and the connection pinned to the checked addresses; link-local and cloud metadata addresses stay refused, loopback unless allowLoopback, and no alias may use the port of the extension isolation Engine API (extensionHost.isolation.engineUrl) on any host. Alias requests never use net.httpsProxy, so no net.noProxy entry is needed. Redirects are not followed. An organization\'s own URLs use its allowed internal endpoints, never an alias. Loopback, link-local, metadata and the Engine are judged on the resolved addresses at request time',
|
|
759
872
|
})),
|
|
760
873
|
})
|
|
761
874
|
.prefault({}),
|
|
@@ -765,8 +878,19 @@ export const KernelConfigSchema = z.strictObject({
|
|
|
765
878
|
.boolean()
|
|
766
879
|
.default(false)
|
|
767
880
|
.meta(meta({
|
|
768
|
-
description: "Approve extension permissions automatically at startup (development and trials only). When false, an extension that is new or whose upgrade asks for more permissions is not loaded until an admin
|
|
881
|
+
description: "Approve extension permissions automatically at startup (development and trials only), including declared full access: each grant is audited with source auto and the start logs a banner naming the approved revisions and realms. Refused (the configuration does not load) in the official images and with NODE_ENV=production. When false, an extension that is new or whose upgrade asks for more permissions is not loaded until an admin approves it (`capybara extensions approve <name>`, `capybara bootstrap approve`)",
|
|
769
882
|
})),
|
|
883
|
+
})
|
|
884
|
+
// Outside production only, also for a config built without resolveConfig (config/auto-approve.ts)
|
|
885
|
+
.superRefine((v, ctx) => {
|
|
886
|
+
if (!v.autoApprove)
|
|
887
|
+
return;
|
|
888
|
+
const refused = autoApproveRefusal({
|
|
889
|
+
nodeEnv: process.env.NODE_ENV,
|
|
890
|
+
officialImage: isOfficialImage(),
|
|
891
|
+
});
|
|
892
|
+
if (refused !== undefined)
|
|
893
|
+
ctx.addIssue({ code: "custom", path: ["autoApprove"], message: refused });
|
|
770
894
|
})
|
|
771
895
|
.default({ autoApprove: false }),
|
|
772
896
|
http: z
|
package/dist/ctx/create-ctx.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import type { ServiceEventHandler, ServiceEventsBackend } from "../device-access
|
|
|
9
9
|
import type { DialInAccess } from "../dial-in/access.js";
|
|
10
10
|
import { type RegisteredHook } from "../extensions/hooks.js";
|
|
11
11
|
import { RegistrationLedger } from "../extensions/ledger.js";
|
|
12
|
+
import type { LeaseOptions, PermissionLease } from "../extensions/revocation-leases.js";
|
|
12
13
|
import type { InboxItemsService } from "../inbox/inbox-items.service.js";
|
|
13
14
|
import type { LockService } from "../infra/lock/lock.service.js";
|
|
14
15
|
import type { ModelEmbeddings } from "../models/embeddings.js";
|
|
@@ -114,6 +115,19 @@ export interface KernelDeps {
|
|
|
114
115
|
* (`streamExternalText` drops its hint).
|
|
115
116
|
*/
|
|
116
117
|
externalConversations?: () => ExternalConversationsBackend | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* The replica's permission leases (`RevisionLeases`, plan task 1.3e): an instance loaded from a
|
|
120
|
+
* package holds one, and `ctx` refuses the keys its revision grant no longer serves. Absent (a
|
|
121
|
+
* ctx built alone in a test, the CLI): nothing is refused for a revocation.
|
|
122
|
+
*/
|
|
123
|
+
leases?: {
|
|
124
|
+
open(opts: LeaseOptions): PermissionLease | undefined;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Called after revoked registrations were withdrawn: derived tables (routes) rebuild and the
|
|
128
|
+
* registry's change listeners refresh.
|
|
129
|
+
*/
|
|
130
|
+
registrationsChanged?: (plugin: string) => void;
|
|
117
131
|
runWorkers: boolean;
|
|
118
132
|
/** 内核 logger(`debug` 可选:插件 Logger 没有它,测试可不给)。 */
|
|
119
133
|
log: Logger & {
|
|
@@ -276,4 +290,6 @@ export declare function createExtensionContext(deps: KernelDeps, manifest: Exten
|
|
|
276
290
|
identity?: {
|
|
277
291
|
sha256: string | null;
|
|
278
292
|
db?: Kysely<any>;
|
|
293
|
+
/** The instance runs in the kernel process (default); false for an isolated instance. */
|
|
294
|
+
inProcess?: boolean;
|
|
279
295
|
}): KernelExtensionContext;
|