@capybara-hq/kernel 0.1.0-rc.131 → 0.1.0-rc.133
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.js +3 -0
- package/dist/admin/admin.schemas.d.ts +4 -0
- package/dist/admin/health.service.d.ts +2 -2
- package/dist/admin/health.service.js +6 -2
- package/dist/admin/setup.service.js +6 -1
- package/dist/agents/agents.controller.js +3 -2
- package/dist/agents/agents.service.d.ts +2 -0
- package/dist/agents/agents.service.js +7 -0
- package/dist/catalog/catalog.service.d.ts +2 -0
- package/dist/catalog/catalog.service.js +28 -5
- package/dist/catalog/marketplace-fetch.d.ts +2 -0
- package/dist/catalog/marketplace-fetch.js +15 -0
- package/dist/catalog/marketplaces.service.d.ts +4 -4
- package/dist/catalog/marketplaces.service.js +3 -2
- package/dist/catalog/owned-items.d.ts +2 -0
- package/dist/catalog/owned-items.js +30 -31
- package/dist/catalog/ownership.js +40 -38
- package/dist/catalog/plugin-import.d.ts +6 -5
- package/dist/catalog/plugin-import.js +69 -16
- package/dist/catalog/plugin-upgrade.d.ts +8 -0
- package/dist/catalog/plugin-upgrade.js +95 -7
- package/dist/catalog/publisher-policy.d.ts +9 -0
- package/dist/catalog/publisher-policy.js +12 -0
- package/dist/catalog/unshare.js +66 -58
- package/dist/client/client-access.service.js +5 -3
- package/dist/config/schema.d.ts +1 -0
- package/dist/config/schema.js +9 -1
- package/dist/conversations/conversations.controller.js +4 -14
- package/dist/conversations/conversations.service.d.ts +14 -0
- package/dist/conversations/conversations.service.js +20 -2
- package/dist/ctx/create-ctx.d.ts +14 -4
- package/dist/ctx/create-ctx.js +131 -59
- package/dist/ctx/queue.js +7 -4
- package/dist/db/extension-db.d.ts +30 -0
- package/dist/db/extension-db.js +91 -0
- package/dist/db/extension-rls-predicate.d.ts +1 -0
- package/dist/db/extension-rls-predicate.js +8 -0
- package/dist/db/extension-schema-transfer.d.ts +6 -0
- package/dist/db/extension-schema-transfer.js +141 -0
- package/dist/db/kernel-schema.d.ts +50 -4
- package/dist/db/migrator.d.ts +6 -0
- package/dist/db/migrator.js +35 -7
- package/dist/db/pool.d.ts +6 -2
- package/dist/db/pool.js +37 -2
- package/dist/db/sql-statements.d.ts +3 -0
- package/dist/db/sql-statements.js +15 -5
- package/dist/device-access/device-access.module.js +12 -2
- package/dist/device-access/device-access.service.d.ts +30 -2
- package/dist/device-access/device-access.service.js +38 -4
- package/dist/device-access/host-gate.d.ts +45 -0
- package/dist/device-access/host-gate.js +92 -0
- package/dist/device-access/host-service-stop-sweep.d.ts +33 -0
- package/dist/device-access/host-service-stop-sweep.js +112 -0
- package/dist/device-access/host-service-stop.d.ts +78 -0
- package/dist/device-access/host-service-stop.js +144 -0
- package/dist/device-access/host-services.d.ts +211 -0
- package/dist/device-access/host-services.js +803 -0
- package/dist/device-access/person-handles.d.ts +10 -0
- package/dist/device-access/person-handles.js +25 -0
- package/dist/device-access/service-events.d.ts +199 -0
- package/dist/device-access/service-events.js +704 -0
- package/dist/device-access/token.d.ts +5 -0
- package/dist/device-access/token.js +5 -0
- package/dist/devices/devices.service.js +3 -0
- package/dist/dial-in/access.d.ts +5 -5
- package/dist/dial-in/access.js +19 -12
- package/dist/dial-in/gateway.js +6 -2
- package/dist/dial-in/machines.d.ts +9 -2
- package/dist/dial-in/machines.js +27 -4
- package/dist/erasure/device-cleanup.js +12 -0
- package/dist/erasure/org-catalog.js +2 -2
- package/dist/erasure/org-rules.js +9 -0
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +2 -0
- package/dist/extensions/admin-ops.d.ts +3 -1
- package/dist/extensions/admin-ops.js +19 -9
- package/dist/extensions/deployed-snapshots.d.ts +4 -1
- package/dist/extensions/deployed-snapshots.js +7 -2
- package/dist/extensions/extensions.module.js +3 -0
- package/dist/extensions/host.d.ts +11 -3
- package/dist/extensions/host.js +40 -8
- package/dist/extensions/instance.d.ts +6 -0
- package/dist/extensions/instance.js +7 -1
- package/dist/extensions/ledger.d.ts +1 -1
- package/dist/extensions/lifecycle-hooks.js +3 -3
- package/dist/extensions/migrate-lock.d.ts +4 -1
- package/dist/extensions/migrate-lock.js +19 -2
- package/dist/extensions/org-config.js +6 -1
- package/dist/extensions/permission-set.d.ts +7 -0
- package/dist/extensions/permission-set.js +10 -0
- package/dist/extensions/permission-view.d.ts +1 -1
- package/dist/extensions/permission-view.js +10 -1
- package/dist/git/tickets.js +32 -27
- package/dist/http/app.js +5 -3
- package/dist/identity/accounts.d.ts +6 -1
- package/dist/identity/accounts.js +11 -2
- package/dist/identity/api-tokens.js +7 -6
- package/dist/identity/settings.d.ts +9 -1
- package/dist/identity/settings.js +16 -1
- package/dist/inbox/org-notices.js +3 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/infra/database/scoped-dialect.d.ts +3 -2
- package/dist/infra/database/scoped-dialect.js +260 -72
- package/dist/infra/database/startup-activation-transaction.d.ts +2 -0
- package/dist/infra/database/startup-activation-transaction.js +3 -2
- package/dist/infra/outbox/registry.d.ts +28 -14
- package/dist/infra/outbox/registry.js +30 -15
- package/dist/infra/queue/queue-names.d.ts +1 -1
- package/dist/infra/queue/queue-names.js +1 -0
- package/dist/infra/queue/run-job.d.ts +4 -1
- package/dist/infra/queue/run-job.js +10 -2
- package/dist/kernel.js +4 -0
- package/dist/kernel.module.js +3 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +3 -1
- package/dist/lifecycle/kernel-lifecycle.js +26 -21
- package/dist/orgs/offboarding.js +18 -9
- package/dist/orgs/settings.service.js +3 -0
- package/dist/packages/npm-publish-keys.json +27 -0
- package/dist/packages/official-publisher.d.ts +19 -0
- package/dist/packages/official-publisher.js +152 -0
- package/dist/packages/provenance.d.ts +7 -0
- package/dist/packages/provenance.js +22 -19
- package/dist/packages/sigstore-trusted-root.json +126 -0
- package/dist/platform/ops/admin.ops.js +2 -1
- package/dist/platform/ops/orgs.ops.js +1 -0
- package/dist/roles/worker-role.d.ts +6 -3
- package/dist/roles/worker-role.js +12 -4
- package/dist/roles/worker.module.js +7 -6
- package/dist/runtime/maintenance.d.ts +5 -4
- package/dist/runtime/maintenance.js +16 -13
- package/dist/sandbox/device-reports.d.ts +4 -4
- package/dist/sandbox/device-reports.js +40 -30
- package/dist/sandbox/device-services.d.ts +2 -1
- package/dist/sandbox/device-services.js +5 -1
- package/dist/sandbox/permission-ceiling-writes.d.ts +8 -0
- package/dist/sandbox/permission-ceiling-writes.js +21 -0
- package/dist/sandbox/permission-config-publication.js +5 -1
- package/dist/themes/theme-state.js +24 -13
- package/dist/tools/call-scope.d.ts +6 -0
- package/dist/tools/call-scope.js +22 -0
- package/dist/tools/registry.js +20 -2
- package/dist/ui/views.js +36 -8
- package/package.json +9 -4
- package/src/migrations/0219_event_org_constraint_check.sql +29 -0
- package/src/migrations/0220_require_event_org.sql +18 -0
- package/src/migrations/0221_drop_connector_declaration_policy.sql +2 -0
- package/src/migrations/0222_device_host_services.sql +27 -0
- package/src/migrations/0223_device_service_events.sql +54 -0
- package/src/migrations/0224_cache_conversation_rls_settings.sql +33 -0
- package/dist/conversations/event-org-backfill.d.ts +0 -111
- package/dist/conversations/event-org-backfill.js +0 -264
- package/dist/conversations/event-org-backfill.module.d.ts +0 -3
- package/dist/conversations/event-org-backfill.module.js +0 -18
|
@@ -10,12 +10,14 @@ export const PROVENANCE_TIMEOUT_MS = 15_000;
|
|
|
10
10
|
const NPM_NAME_RE = /^(?:@[a-z0-9][a-z0-9._~-]*\/)?[a-z0-9][a-z0-9._~-]*$/;
|
|
11
11
|
const SEMVER_RE = /^[0-9A-Za-z.+-]{1,256}$/;
|
|
12
12
|
const COMMIT_RE = /^[0-9a-f]{40}(?:[0-9a-f]{24})?$/;
|
|
13
|
+
class NpmAttestationsError extends Error {
|
|
14
|
+
}
|
|
13
15
|
const notChecked = (reason) => ({ checked: false, reason });
|
|
14
16
|
const errMsg = (e) => (e instanceof Error ? e.message : String(e));
|
|
15
17
|
const isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
16
18
|
const str = (v) => typeof v === "string" && v.length > 0 && v.length <= 2048 ? v : undefined;
|
|
17
19
|
/** The hex sha512 of a `sha512-<base64>` integrity (undefined for anything else). */
|
|
18
|
-
function sha512Hex(integrity) {
|
|
20
|
+
export function sha512Hex(integrity) {
|
|
19
21
|
for (const part of integrity.trim().split(/\s+/)) {
|
|
20
22
|
const m = /^sha512-([A-Za-z0-9+/]+={0,2})$/.exec(part);
|
|
21
23
|
if (m) {
|
|
@@ -32,13 +34,20 @@ function sha512Hex(integrity) {
|
|
|
32
34
|
* about another tarball is not shown. Never throws (an aborted `signal` included).
|
|
33
35
|
*/
|
|
34
36
|
export async function fetchProvenance(cfg, name, version, signal, opts = {}) {
|
|
37
|
+
try {
|
|
38
|
+
return parseAttestations(await fetchNpmAttestations(cfg, name, version, signal), opts.integrity);
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
return notChecked(e instanceof NpmAttestationsError ? e.message : `cannot read the attestations: ${errMsg(e)}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** Fetches bounded attestation evidence without accepting it as publisher proof. */
|
|
45
|
+
export async function fetchNpmAttestations(cfg, name, version, signal) {
|
|
35
46
|
if (!NPM_NAME_RE.test(name) || name.length > 214 || !SEMVER_RE.test(version)) {
|
|
36
|
-
|
|
47
|
+
throw new NpmAttestationsError("not a valid npm package name and version");
|
|
37
48
|
}
|
|
38
|
-
let body;
|
|
39
49
|
try {
|
|
40
50
|
const registry = new URL(cfg.registry.endsWith("/") ? cfg.registry : `${cfg.registry}/`);
|
|
41
|
-
// the npm client's escaping: a scoped name's `/` is %2f
|
|
42
51
|
const url = new URL(`-/npm/v1/attestations/${name.replace("/", "%2f")}@${encodeURIComponent(version)}`, registry);
|
|
43
52
|
const res = await safeFetch(url.toString(), {
|
|
44
53
|
headers: {
|
|
@@ -47,30 +56,24 @@ export async function fetchProvenance(cfg, name, version, signal, opts = {}) {
|
|
|
47
56
|
},
|
|
48
57
|
signal,
|
|
49
58
|
}, cfg.net, cfg.lookup !== undefined ? { lookup: cfg.lookup } : {});
|
|
50
|
-
if (res.status === 404) {
|
|
51
|
-
await res.body?.cancel().catch(() => { });
|
|
52
|
-
return notChecked("the registry has no provenance for this version");
|
|
53
|
-
}
|
|
54
59
|
if (!res.ok) {
|
|
55
60
|
await res.body?.cancel().catch(() => { });
|
|
56
|
-
|
|
61
|
+
throw new NpmAttestationsError(res.status === 404
|
|
62
|
+
? "the registry has no provenance for this version"
|
|
63
|
+
: `the registry answered HTTP ${res.status} for the attestations`);
|
|
57
64
|
}
|
|
58
65
|
const raw = await readCapped(res, MAX_ATTESTATION_BYTES, () => new Error("the attestations are too large"));
|
|
59
|
-
|
|
66
|
+
return JSON.parse(raw.toString("utf8"));
|
|
60
67
|
}
|
|
61
68
|
catch (e) {
|
|
62
69
|
if (signal.aborted)
|
|
63
|
-
|
|
70
|
+
throw new NpmAttestationsError("the registry did not answer in time", { cause: e });
|
|
64
71
|
if (e instanceof NetDeniedError) {
|
|
65
|
-
|
|
72
|
+
throw new NpmAttestationsError(`the network rules refused the attestations: ${e.message}`, {
|
|
73
|
+
cause: e,
|
|
74
|
+
});
|
|
66
75
|
}
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
try {
|
|
70
|
-
return parseAttestations(body, opts.integrity);
|
|
71
|
-
}
|
|
72
|
-
catch (e) {
|
|
73
|
-
return notChecked(`cannot read the attestations: ${errMsg(e)}`);
|
|
76
|
+
throw e;
|
|
74
77
|
}
|
|
75
78
|
}
|
|
76
79
|
/**
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
{
|
|
2
|
+
"mediaType": "application/vnd.dev.sigstore.trustedroot+json;version=0.1",
|
|
3
|
+
"tlogs": [
|
|
4
|
+
{
|
|
5
|
+
"baseUrl": "https://rekor.sigstore.dev",
|
|
6
|
+
"hashAlgorithm": "SHA2_256",
|
|
7
|
+
"publicKey": {
|
|
8
|
+
"rawBytes": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE2G2Y+2tabdTV5BcGiBIx0a9fAFwrkBbmLSGtks4L3qX6yYY0zufBnhC8Ur/iy55GhWP/9A/bY2LhC30M9+RYtw==",
|
|
9
|
+
"keyDetails": "PKIX_ECDSA_P256_SHA_256",
|
|
10
|
+
"validFor": {
|
|
11
|
+
"start": "2021-01-12T11:53:27Z"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"logId": {
|
|
15
|
+
"keyId": "wNI9atQGlz+VWfO6LRygH4QUfY/8W4RFwiT5i5WRgB0="
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"baseUrl": "https://log2025-1.rekor.sigstore.dev",
|
|
20
|
+
"hashAlgorithm": "SHA2_256",
|
|
21
|
+
"publicKey": {
|
|
22
|
+
"rawBytes": "MCowBQYDK2VwAyEAt8rlp1knGwjfbcXAYPYAkn0XiLz1x8O4t0YkEhie244=",
|
|
23
|
+
"keyDetails": "PKIX_ED25519",
|
|
24
|
+
"validFor": {
|
|
25
|
+
"start": "2025-09-23T00:00:00Z"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"logId": {
|
|
29
|
+
"keyId": "zxGZFVvd0FEmjR8WrFwMdcAJ9vtaY/QXf44Y1wUeP6A="
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"certificateAuthorities": [
|
|
34
|
+
{
|
|
35
|
+
"subject": {
|
|
36
|
+
"organization": "sigstore.dev",
|
|
37
|
+
"commonName": "sigstore"
|
|
38
|
+
},
|
|
39
|
+
"uri": "https://fulcio.sigstore.dev",
|
|
40
|
+
"certChain": {
|
|
41
|
+
"certificates": [
|
|
42
|
+
{
|
|
43
|
+
"rawBytes": "MIIB+DCCAX6gAwIBAgITNVkDZoCiofPDsy7dfm6geLbuhzAKBggqhkjOPQQDAzAqMRUwEwYDVQQKEwxzaWdzdG9yZS5kZXYxETAPBgNVBAMTCHNpZ3N0b3JlMB4XDTIxMDMwNzAzMjAyOVoXDTMxMDIyMzAzMjAyOVowKjEVMBMGA1UEChMMc2lnc3RvcmUuZGV2MREwDwYDVQQDEwhzaWdzdG9yZTB2MBAGByqGSM49AgEGBSuBBAAiA2IABLSyA7Ii5k+pNO8ZEWY0ylemWDowOkNa3kL+GZE5Z5GWehL9/A9bRNA3RbrsZ5i0JcastaRL7Sp5fp/jD5dxqc/UdTVnlvS16an+2Yfswe/QuLolRUCrcOE2+2iA5+tzd6NmMGQwDgYDVR0PAQH/BAQDAgEGMBIGA1UdEwEB/wQIMAYBAf8CAQEwHQYDVR0OBBYEFMjFHQBBmiQpMlEk6w2uSu1KBtPsMB8GA1UdIwQYMBaAFMjFHQBBmiQpMlEk6w2uSu1KBtPsMAoGCCqGSM49BAMDA2gAMGUCMH8liWJfMui6vXXBhjDgY4MwslmN/TJxVe/83WrFomwmNf056y1X48F9c4m3a3ozXAIxAKjRay5/aj/jsKKGIkmQatjI8uupHr/+CxFvaJWmpYqNkLDGRU+9orzh5hI2RrcuaQ=="
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
"validFor": {
|
|
48
|
+
"start": "2021-03-07T03:20:29Z",
|
|
49
|
+
"end": "2022-12-31T23:59:59.999Z"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"subject": {
|
|
54
|
+
"organization": "sigstore.dev",
|
|
55
|
+
"commonName": "sigstore"
|
|
56
|
+
},
|
|
57
|
+
"uri": "https://fulcio.sigstore.dev",
|
|
58
|
+
"certChain": {
|
|
59
|
+
"certificates": [
|
|
60
|
+
{
|
|
61
|
+
"rawBytes": "MIICGjCCAaGgAwIBAgIUALnViVfnU0brJasmRkHrn/UnfaQwCgYIKoZIzj0EAwMwKjEVMBMGA1UEChMMc2lnc3RvcmUuZGV2MREwDwYDVQQDEwhzaWdzdG9yZTAeFw0yMjA0MTMyMDA2MTVaFw0zMTEwMDUxMzU2NThaMDcxFTATBgNVBAoTDHNpZ3N0b3JlLmRldjEeMBwGA1UEAxMVc2lnc3RvcmUtaW50ZXJtZWRpYXRlMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE8RVS/ysH+NOvuDZyPIZtilgUF9NlarYpAd9HP1vBBH1U5CV77LSS7s0ZiH4nE7Hv7ptS6LvvR/STk798LVgMzLlJ4HeIfF3tHSaexLcYpSASr1kS0N/RgBJz/9jWCiXno3sweTAOBgNVHQ8BAf8EBAMCAQYwEwYDVR0lBAwwCgYIKwYBBQUHAwMwEgYDVR0TAQH/BAgwBgEB/wIBADAdBgNVHQ4EFgQU39Ppz1YkEZb5qNjpKFWixi4YZD8wHwYDVR0jBBgwFoAUWMAeX5FFpWapesyQoZMi0CrFxfowCgYIKoZIzj0EAwMDZwAwZAIwPCsQK4DYiZYDPIaDi5HFKnfxXx6ASSVmERfsynYBiX2X6SJRnZU84/9DZdnFvvxmAjBOt6QpBlc4J/0DxvkTCqpclvziL6BCCPnjdlIB3Pu3BxsPmygUY7Ii2zbdCdliiow="
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"rawBytes": "MIIB9zCCAXygAwIBAgIUALZNAPFdxHPwjeDloDwyYChAO/4wCgYIKoZIzj0EAwMwKjEVMBMGA1UEChMMc2lnc3RvcmUuZGV2MREwDwYDVQQDEwhzaWdzdG9yZTAeFw0yMTEwMDcxMzU2NTlaFw0zMTEwMDUxMzU2NThaMCoxFTATBgNVBAoTDHNpZ3N0b3JlLmRldjERMA8GA1UEAxMIc2lnc3RvcmUwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAT7XeFT4rb3PQGwS4IajtLk3/OlnpgangaBclYpsYBr5i+4ynB07ceb3LP0OIOZdxexX69c5iVuyJRQ+Hz05yi+UF3uBWAlHpiS5sh0+H2GHE7SXrk1EC5m1Tr19L9gg92jYzBhMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRYwB5fkUWlZql6zJChkyLQKsXF+jAfBgNVHSMEGDAWgBRYwB5fkUWlZql6zJChkyLQKsXF+jAKBggqhkjOPQQDAwNpADBmAjEAj1nHeXZp+13NWBNa+EDsDP8G1WWg1tCMWP/WHPqpaVo0jhsweNFZgSs0eE7wYI4qAjEA2WB9ot98sIkoF3vZYdd3/VtWB5b9TNMea7Ix/stJ5TfcLLeABLE4BNJOsQ4vnBHJ"
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
"validFor": {
|
|
69
|
+
"start": "2022-04-13T20:06:15Z"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
"ctlogs": [
|
|
74
|
+
{
|
|
75
|
+
"baseUrl": "https://ctfe.sigstore.dev/test",
|
|
76
|
+
"hashAlgorithm": "SHA2_256",
|
|
77
|
+
"publicKey": {
|
|
78
|
+
"rawBytes": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEbfwR+RJudXscgRBRpKX1XFDy3PyudDxz/SfnRi1fT8ekpfBd2O1uoz7jr3Z8nKzxA69EUQ+eFCFI3zeubPWU7w==",
|
|
79
|
+
"keyDetails": "PKIX_ECDSA_P256_SHA_256",
|
|
80
|
+
"validFor": {
|
|
81
|
+
"start": "2021-03-14T00:00:00Z",
|
|
82
|
+
"end": "2022-10-31T23:59:59.999Z"
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"logId": {
|
|
86
|
+
"keyId": "CGCS8ChS/2hF0dFrJ4ScRWcYrBY9wzjSbea8IgY2b3I="
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"baseUrl": "https://ctfe.sigstore.dev/2022",
|
|
91
|
+
"hashAlgorithm": "SHA2_256",
|
|
92
|
+
"publicKey": {
|
|
93
|
+
"rawBytes": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEiPSlFi0CmFTfEjCUqF9HuCEcYXNKAaYalIJmBZ8yyezPjTqhxrKBpMnaocVtLJBI1eM3uXnQzQGAJdJ4gs9Fyw==",
|
|
94
|
+
"keyDetails": "PKIX_ECDSA_P256_SHA_256",
|
|
95
|
+
"validFor": {
|
|
96
|
+
"start": "2022-10-20T00:00:00Z"
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
"logId": {
|
|
100
|
+
"keyId": "3T0wasbHETJjGR4cmWc3AqJKXrjePK3/h4pygC8p7o4="
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
"timestampAuthorities": [
|
|
105
|
+
{
|
|
106
|
+
"subject": {
|
|
107
|
+
"organization": "sigstore.dev",
|
|
108
|
+
"commonName": "sigstore-tsa-selfsigned"
|
|
109
|
+
},
|
|
110
|
+
"uri": "https://timestamp.sigstore.dev/api/v1/timestamp",
|
|
111
|
+
"certChain": {
|
|
112
|
+
"certificates": [
|
|
113
|
+
{
|
|
114
|
+
"rawBytes": "MIICEDCCAZagAwIBAgIUOhNULwyQYe68wUMvy4qOiyojiwwwCgYIKoZIzj0EAwMwOTEVMBMGA1UEChMMc2lnc3RvcmUuZGV2MSAwHgYDVQQDExdzaWdzdG9yZS10c2Etc2VsZnNpZ25lZDAeFw0yNTA0MDgwNjU5NDNaFw0zNTA0MDYwNjU5NDNaMC4xFTATBgNVBAoTDHNpZ3N0b3JlLmRldjEVMBMGA1UEAxMMc2lnc3RvcmUtdHNhMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE4ra2Z8hKNig2T9kFjCAToGG30jky+WQv3BzL+mKvh1SKNR/UwuwsfNCg4sryoYAd8E6isovVA3M4aoNdm9QDi50Z8nTEyvqgfDPtTIwXItfiW/AFf1V7uwkbkAoj0xxco2owaDAOBgNVHQ8BAf8EBAMCB4AwHQYDVR0OBBYEFIn9eUOHz9BlRsMCRscsc1t9tOsDMB8GA1UdIwQYMBaAFJjsAe9/u1H/1JUeb4qImFMHic6/MBYGA1UdJQEB/wQMMAoGCCsGAQUFBwMIMAoGCCqGSM49BAMDA2gAMGUCMDtpsV/6KaO0qyF/UMsX2aSUXKQFdoGTptQGc0ftq1csulHPGG6dsmyMNd3JB+G3EQIxAOajvBcjpJmKb4Nv+2Taoj8Uc5+b6ih6FXCCKraSqupe07zqswMcXJTe1cExvHvvlw=="
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"rawBytes": "MIIB9zCCAXygAwIBAgIUV7f0GLDOoEzIh8LXSW80OJiUp14wCgYIKoZIzj0EAwMwOTEVMBMGA1UEChMMc2lnc3RvcmUuZGV2MSAwHgYDVQQDExdzaWdzdG9yZS10c2Etc2VsZnNpZ25lZDAeFw0yNTA0MDgwNjU5NDNaFw0zNTA0MDYwNjU5NDNaMDkxFTATBgNVBAoTDHNpZ3N0b3JlLmRldjEgMB4GA1UEAxMXc2lnc3RvcmUtdHNhLXNlbGZzaWduZWQwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQUQNtfRT/ou3YATa6wB/kKTe70cfJwyRIBovMnt8RcJph/COE82uyS6FmppLLL1VBPGcPfpQPYJNXzWwi8icwhKQ6W/Qe2h3oebBb2FHpwNJDqo+TMaC/tdfkv/ElJB72jRTBDMA4GA1UdDwEB/wQEAwIBBjASBgNVHRMBAf8ECDAGAQH/AgEAMB0GA1UdDgQWBBSY7AHvf7tR/9SVHm+KiJhTB4nOvzAKBggqhkjOPQQDAwNpADBmAjEAwGEGrfGZR1cen1R8/DTVMI943LssZmJRtDp/i7SfGHmGRP6gRbuj9vOK3b67Z0QQAjEAuT2H673LQEaHTcyQSZrkp4mX7WwkmF+sVbkYY5mXN+RMH13KUEHHOqASaemYWK/E"
|
|
118
|
+
}
|
|
119
|
+
]
|
|
120
|
+
},
|
|
121
|
+
"validFor": {
|
|
122
|
+
"start": "2025-07-04T00:00:00Z"
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
}
|
|
@@ -265,9 +265,10 @@ let AdminOperations = class AdminOperations {
|
|
|
265
265
|
authz: { superAdmin: true },
|
|
266
266
|
mirrors: ["PUT /api/v1/admin/settings"],
|
|
267
267
|
// the per-org override records are orgs.set-limits (one org at a time); compaction is
|
|
268
|
-
// changed in the admin console's settings page
|
|
268
|
+
// changed in the admin console's settings page, as is the publisher trust policy
|
|
269
269
|
omits: [
|
|
270
270
|
"confirmRetentionShortening",
|
|
271
|
+
"officialPublisherProof",
|
|
271
272
|
"runConcurrencyOverrides",
|
|
272
273
|
"sandboxLimitOverrides",
|
|
273
274
|
"subagentLimitOverrides",
|
|
@@ -259,6 +259,7 @@ let OrgsOperations = class OrgsOperations {
|
|
|
259
259
|
// one org's entries of the three override records, keyed by orgId; the deployment-wide
|
|
260
260
|
// settings are admin.update-settings
|
|
261
261
|
omits: [
|
|
262
|
+
"officialPublisherProof",
|
|
262
263
|
"orgCreation",
|
|
263
264
|
"runConcurrencyOverrides",
|
|
264
265
|
"priceCurrency",
|
|
@@ -4,6 +4,7 @@ import { ChannelsProcessor } from "../channels/channels.module.js";
|
|
|
4
4
|
import { ChannelOutbound } from "../channels/outbound.js";
|
|
5
5
|
import { PromptSuggestionQueue } from "../conversations/prompt-suggestions.js";
|
|
6
6
|
import { TitleQueue } from "../conversations/titles.js";
|
|
7
|
+
import { ServiceEventProcessor } from "../device-access/service-events.js";
|
|
7
8
|
import { EvalsProcessor } from "../evals/evals.module.js";
|
|
8
9
|
import { EvalWorker } from "../evals/worker.js";
|
|
9
10
|
import { LifecycleHooksProcessor } from "../extensions/lifecycle-hooks.js";
|
|
@@ -49,13 +50,14 @@ export declare class WorkerRole {
|
|
|
49
50
|
private readonly connectorToolsProcessor;
|
|
50
51
|
private readonly templateConnectorsProcessor;
|
|
51
52
|
private readonly toolWatchProcessor;
|
|
53
|
+
private readonly serviceEventProcessor;
|
|
52
54
|
/** The startup config (the roles). */
|
|
53
55
|
private readonly config;
|
|
54
56
|
/** The run worker was started: the runs phase drains it. */
|
|
55
57
|
private runsStarted;
|
|
56
58
|
/** The eval worker was started: the runs phase drains it. */
|
|
57
59
|
private evalsStarted;
|
|
58
|
-
constructor(config: KernelConfigService, log: KernelLogger, intervals: LockedIntervalScheduler, scheduledRuns: ScheduledRuns, runWorker: RunWorker, evalWorker: EvalWorker, usageReport: UsageReporter, titles: TitleQueue, suggestions: PromptSuggestionQueue, channelOutbound: ChannelOutbound, runsProcessor: RunsProcessor, subagentRunsProcessor: SubagentRunsProcessor, usageProcessor: UsageReportProcessor, titleProcessor: TitleProcessor, suggestionProcessor: PromptSuggestionProcessor, channelsProcessor: ChannelsProcessor, evalsProcessor: EvalsProcessor, maintenanceProcessor: MaintenanceProcessor, scopeProcessor: PluginScopeSyncProcessor, lifecycleProcessor: LifecycleHooksProcessor, pushProcessor: PushProcessor, connectorToolsProcessor: ConnectorToolsProcessor, templateConnectorsProcessor: TemplateConnectorsProcessor, toolWatchProcessor: ToolWatchProcessor);
|
|
60
|
+
constructor(config: KernelConfigService, log: KernelLogger, intervals: LockedIntervalScheduler, scheduledRuns: ScheduledRuns, runWorker: RunWorker, evalWorker: EvalWorker, usageReport: UsageReporter, titles: TitleQueue, suggestions: PromptSuggestionQueue, channelOutbound: ChannelOutbound, runsProcessor: RunsProcessor, subagentRunsProcessor: SubagentRunsProcessor, usageProcessor: UsageReportProcessor, titleProcessor: TitleProcessor, suggestionProcessor: PromptSuggestionProcessor, channelsProcessor: ChannelsProcessor, evalsProcessor: EvalsProcessor, maintenanceProcessor: MaintenanceProcessor, scopeProcessor: PluginScopeSyncProcessor, lifecycleProcessor: LifecycleHooksProcessor, pushProcessor: PushProcessor, connectorToolsProcessor: ConnectorToolsProcessor, templateConnectorsProcessor: TemplateConnectorsProcessor, toolWatchProcessor: ToolWatchProcessor, serviceEventProcessor: ServiceEventProcessor);
|
|
59
61
|
/**
|
|
60
62
|
* Starts the queue consumers (after the extension load), then opens the schedules' start gate:
|
|
61
63
|
* the cron and interval timers were armed at application bootstrap, but every tick before this
|
|
@@ -75,8 +77,9 @@ export declare class WorkerRole {
|
|
|
75
77
|
/**
|
|
76
78
|
* Closes the maintenance queue's worker, the plugin scope sync's (it stops between pairs), the
|
|
77
79
|
* lifecycle hook deliveries' (calls in flight are aborted and retried), the push deliveries'
|
|
78
|
-
* (sends in flight finish, each bounded by the send time limit)
|
|
79
|
-
* listings' (each bounded by the tool timeout)
|
|
80
|
+
* (sends in flight finish, each bounded by the send time limit), the connector tool
|
|
81
|
+
* listings' (each bounded by the tool timeout) and the device service event deliveries' (calls in
|
|
82
|
+
* flight are aborted and retried).
|
|
80
83
|
*/
|
|
81
84
|
closeMaintenance(): Promise<void>;
|
|
82
85
|
}
|
|
@@ -14,6 +14,7 @@ import { ChannelsProcessor } from "../channels/channels.module.js";
|
|
|
14
14
|
import { ChannelOutbound } from "../channels/outbound.js";
|
|
15
15
|
import { PromptSuggestionQueue } from "../conversations/prompt-suggestions.js";
|
|
16
16
|
import { TitleQueue } from "../conversations/titles.js";
|
|
17
|
+
import { ServiceEventProcessor } from "../device-access/service-events.js";
|
|
17
18
|
import { EvalsProcessor } from "../evals/evals.module.js";
|
|
18
19
|
import { EvalWorker } from "../evals/worker.js";
|
|
19
20
|
import { LifecycleHooksProcessor } from "../extensions/lifecycle-hooks.js";
|
|
@@ -59,13 +60,14 @@ let WorkerRole = class WorkerRole {
|
|
|
59
60
|
connectorToolsProcessor;
|
|
60
61
|
templateConnectorsProcessor;
|
|
61
62
|
toolWatchProcessor;
|
|
63
|
+
serviceEventProcessor;
|
|
62
64
|
/** The startup config (the roles). */
|
|
63
65
|
config;
|
|
64
66
|
/** The run worker was started: the runs phase drains it. */
|
|
65
67
|
runsStarted = false;
|
|
66
68
|
/** The eval worker was started: the runs phase drains it. */
|
|
67
69
|
evalsStarted = false;
|
|
68
|
-
constructor(config, log, intervals, scheduledRuns, runWorker, evalWorker, usageReport, titles, suggestions, channelOutbound, runsProcessor, subagentRunsProcessor, usageProcessor, titleProcessor, suggestionProcessor, channelsProcessor, evalsProcessor, maintenanceProcessor, scopeProcessor, lifecycleProcessor, pushProcessor, connectorToolsProcessor, templateConnectorsProcessor, toolWatchProcessor) {
|
|
70
|
+
constructor(config, log, intervals, scheduledRuns, runWorker, evalWorker, usageReport, titles, suggestions, channelOutbound, runsProcessor, subagentRunsProcessor, usageProcessor, titleProcessor, suggestionProcessor, channelsProcessor, evalsProcessor, maintenanceProcessor, scopeProcessor, lifecycleProcessor, pushProcessor, connectorToolsProcessor, templateConnectorsProcessor, toolWatchProcessor, serviceEventProcessor) {
|
|
69
71
|
this.log = log;
|
|
70
72
|
this.intervals = intervals;
|
|
71
73
|
this.scheduledRuns = scheduledRuns;
|
|
@@ -89,6 +91,7 @@ let WorkerRole = class WorkerRole {
|
|
|
89
91
|
this.connectorToolsProcessor = connectorToolsProcessor;
|
|
90
92
|
this.templateConnectorsProcessor = templateConnectorsProcessor;
|
|
91
93
|
this.toolWatchProcessor = toolWatchProcessor;
|
|
94
|
+
this.serviceEventProcessor = serviceEventProcessor;
|
|
92
95
|
this.config = config.get();
|
|
93
96
|
}
|
|
94
97
|
/**
|
|
@@ -112,6 +115,8 @@ let WorkerRole = class WorkerRole {
|
|
|
112
115
|
// watched-wait polls (`cap-kernel-tool-watch`), after the extensions loaded their watchers
|
|
113
116
|
this.toolWatchProcessor.start();
|
|
114
117
|
this.templateConnectorsProcessor.start();
|
|
118
|
+
// device service events, after the extensions registered their handlers
|
|
119
|
+
this.serviceEventProcessor.start();
|
|
115
120
|
this.channelOutbound.startWorker(this.channelsProcessor.worker);
|
|
116
121
|
this.usageReport.startWorker(this.usageProcessor.worker);
|
|
117
122
|
this.titles.startWorker(this.titleProcessor.worker);
|
|
@@ -141,8 +146,9 @@ let WorkerRole = class WorkerRole {
|
|
|
141
146
|
/**
|
|
142
147
|
* Closes the maintenance queue's worker, the plugin scope sync's (it stops between pairs), the
|
|
143
148
|
* lifecycle hook deliveries' (calls in flight are aborted and retried), the push deliveries'
|
|
144
|
-
* (sends in flight finish, each bounded by the send time limit)
|
|
145
|
-
* listings' (each bounded by the tool timeout)
|
|
149
|
+
* (sends in flight finish, each bounded by the send time limit), the connector tool
|
|
150
|
+
* listings' (each bounded by the tool timeout) and the device service event deliveries' (calls in
|
|
151
|
+
* flight are aborted and retried).
|
|
146
152
|
*/
|
|
147
153
|
async closeMaintenance() {
|
|
148
154
|
await Promise.all([
|
|
@@ -153,6 +159,7 @@ let WorkerRole = class WorkerRole {
|
|
|
153
159
|
this.connectorToolsProcessor.close(),
|
|
154
160
|
this.toolWatchProcessor.close(),
|
|
155
161
|
this.templateConnectorsProcessor.close(),
|
|
162
|
+
this.serviceEventProcessor.close(),
|
|
156
163
|
]);
|
|
157
164
|
}
|
|
158
165
|
};
|
|
@@ -181,6 +188,7 @@ WorkerRole = __decorate([
|
|
|
181
188
|
__param(20, Inject(PushProcessor)),
|
|
182
189
|
__param(21, Inject(ConnectorToolsProcessor)),
|
|
183
190
|
__param(22, Inject(TemplateConnectorsProcessor)),
|
|
184
|
-
__param(23, Inject(ToolWatchProcessor))
|
|
191
|
+
__param(23, Inject(ToolWatchProcessor)),
|
|
192
|
+
__param(24, Inject(ServiceEventProcessor))
|
|
185
193
|
], WorkerRole);
|
|
186
194
|
export { WorkerRole };
|
|
@@ -21,11 +21,11 @@ import { ClientReportsCron } from "../client/client-reports.cron.js";
|
|
|
21
21
|
import { AttachmentsModule } from "../conversations/attachments.module.js";
|
|
22
22
|
import { AttachmentCleanupJob } from "../conversations/attachments.service.js";
|
|
23
23
|
import { EventLogModule } from "../conversations/event-log.js";
|
|
24
|
-
import { EventOrgBackfillKickoffJob } from "../conversations/event-org-backfill.js";
|
|
25
|
-
import { EventOrgBackfillModule } from "../conversations/event-org-backfill.module.js";
|
|
26
24
|
import { PromptSuggestionsModule } from "../conversations/prompt-suggestions.js";
|
|
27
25
|
import { TitlesModule } from "../conversations/titles.js";
|
|
28
26
|
import { ConversationNoticeSweepJob, ConversationNoticesModule, } from "../device-access/conversation-notice-delivery.js";
|
|
27
|
+
import { HostServiceStopSweepJob } from "../device-access/host-service-stop-sweep.js";
|
|
28
|
+
import { DeviceServiceEventWorkersModule } from "../device-access/service-events.js";
|
|
29
29
|
import { DeviceSiteGrantsModule } from "../device-access/site-grants.module.js";
|
|
30
30
|
import { ErasureModule } from "../erasure/erasure.module.js";
|
|
31
31
|
import { ErasureSweep } from "../erasure/sweep.job.js";
|
|
@@ -104,6 +104,8 @@ let WorkerModule = WorkerModule_1 = class WorkerModule {
|
|
|
104
104
|
// template connectors an org never had, owed by installs and extension switch-ons
|
|
105
105
|
// (`cap-template-connectors`)
|
|
106
106
|
TemplateConnectorsWorkersModule,
|
|
107
|
+
// device service event deliveries (`cap-device-service-events`) and their 5-minute sweep
|
|
108
|
+
DeviceServiceEventWorkersModule,
|
|
107
109
|
// the domains the fixed-period jobs call
|
|
108
110
|
RuntimeModule,
|
|
109
111
|
RunJobsModule,
|
|
@@ -115,8 +117,6 @@ let WorkerModule = WorkerModule_1 = class WorkerModule {
|
|
|
115
117
|
LibraryFilesModule,
|
|
116
118
|
// the hashing and catch-up copy the kickoff owes
|
|
117
119
|
FileLibraryJobsModule,
|
|
118
|
-
// the batched conversation_events.org_id backfill the kickoff owes
|
|
119
|
-
EventOrgBackfillModule,
|
|
120
120
|
IdentityModule,
|
|
121
121
|
StorageModule,
|
|
122
122
|
SandboxModule,
|
|
@@ -142,8 +142,6 @@ let WorkerModule = WorkerModule_1 = class WorkerModule {
|
|
|
142
142
|
FileDraftCleanupJob,
|
|
143
143
|
// the daily blob sweep and the hourly kickoff of hashing and the catch-up copy (§7, §9)
|
|
144
144
|
FileLibraryKickoffJob,
|
|
145
|
-
// the periodic kickoff of the batched conversation_events.org_id backfill (issue #1175)
|
|
146
|
-
EventOrgBackfillKickoffJob,
|
|
147
145
|
StoragePurgeJob,
|
|
148
146
|
RetentionSweep,
|
|
149
147
|
ErasureSweep,
|
|
@@ -151,6 +149,9 @@ let WorkerModule = WorkerModule_1 = class WorkerModule {
|
|
|
151
149
|
BackgroundTaskPollJob,
|
|
152
150
|
// owed conversation notices to devices' services (close tabs on delete design §4.3)
|
|
153
151
|
ConversationNoticeSweepJob,
|
|
152
|
+
// owed host service stops of connected machines and deleted devices (local agents spec,
|
|
153
|
+
// call 5)
|
|
154
|
+
HostServiceStopSweepJob,
|
|
154
155
|
// loopback port grants past their 24 hours (browser loopback port grants design §4)
|
|
155
156
|
LoopbackExpiryJob,
|
|
156
157
|
ToolJobs,
|
|
@@ -3,8 +3,8 @@ import type { Job, Worker } from "bullmq";
|
|
|
3
3
|
import { EventCoalescer } from "../automations/events/coalesce.js";
|
|
4
4
|
import { TriggerDispatcher } from "../automations/events/dispatcher.js";
|
|
5
5
|
import { AutomationFirer } from "../automations/fire.js";
|
|
6
|
-
import { EventOrgBackfillJob } from "../conversations/event-org-backfill.js";
|
|
7
6
|
import { ConversationNoticeDelivery } from "../device-access/conversation-notice-delivery.js";
|
|
7
|
+
import { HostServiceAccess } from "../device-access/host-services.js";
|
|
8
8
|
import { ErasureWorker } from "../erasure/worker.js";
|
|
9
9
|
import { BlobObjects } from "../files/blob-objects.js";
|
|
10
10
|
import { FileLibraryHashJob } from "../files/hash-job.js";
|
|
@@ -37,7 +37,8 @@ export declare const MAINTENANCE_CONCURRENCY = 5;
|
|
|
37
37
|
* {@link BlobObjects}, `file-library-hash`, `file-library-hash-org` → {@link FileLibraryHashJob},
|
|
38
38
|
* `platform-icon-delete` →
|
|
39
39
|
* {@link PlatformIconObjects}, `device-conversation-notice` → {@link ConversationNoticeDelivery},
|
|
40
|
-
* `idle-compaction` → {@link IdleCompactionJob}, `device-loopback-refresh` → {@link LoopbackGrants}
|
|
40
|
+
* `idle-compaction` → {@link IdleCompactionJob}, `device-loopback-refresh` → {@link LoopbackGrants}, `device-host-services-stop` →
|
|
41
|
+
* {@link HostServiceAccess}). The name of a periodic job (a `@LockedCron` / `@LockedInterval` job,
|
|
41
42
|
* such as `sandbox-suspend-idle`) runs that job's body once ({@link ScheduledRuns.runNow}), as the
|
|
42
43
|
* maintenance handlers did when those jobs were schedulers on this queue: an operator's or a
|
|
43
44
|
* test's one-off run, not a second schedule (decision R23 of the Nest kernel spec). Any other
|
|
@@ -65,10 +66,10 @@ export declare class MaintenanceProcessor extends WorkerHost<Worker> {
|
|
|
65
66
|
private readonly idleCompaction;
|
|
66
67
|
private readonly db;
|
|
67
68
|
private readonly loopback;
|
|
68
|
-
private readonly
|
|
69
|
+
private readonly hostServices;
|
|
69
70
|
private readonly retention;
|
|
70
71
|
private readonly erasure;
|
|
71
|
-
constructor(permissionApprovals: Pick<PermissionApprovalJobs, "recheck">, waits: Pick<Waits, "processTimeout" | "childFinished" | "stopChildren" | "stopDescendantsOfStopped" | "stopTree">, sandbox: Pick<SandboxService, "destroyDevice" | "resetFileSystem" | "revokeDeadHolder">, drift: Pick<ToolDrift, "check">, directory: Pick<DirectorySync, "runSyncJob">, deletion: Pick<RunDeletion, "stopOrg" | "stopTree">, offboarding: Pick<Offboarding, "stopRun">, runs: Pick<RunQueue, "ensureRun">, automations: Pick<AutomationFirer, "fire" | "settle">, scheduled: Pick<ScheduledRuns, "runNow">, log: Pick<KernelLogger, "error" | "warn">, operations: Pick<SandboxOperationReconcileJob, "reconcile" | "revoke" | "settleResumeProof">, blobObjects: Pick<BlobObjects, "deleteBlob" | "deleteStaging" | "releaseFile">, hashing: Pick<FileLibraryHashJob, "dispatch" | "runOrgBatch">, platformIcons: Pick<PlatformIconObjects, "deleteObject">, notices: Pick<ConversationNoticeDelivery, "attempt">, triggers: Pick<TriggerDispatcher, "dispatch">, coalescer: Pick<EventCoalescer, "flush">, idleCompaction: Pick<IdleCompactionJob, "fire">, db: KernelDb, loopback: Pick<LoopbackGrants, "refresh">,
|
|
72
|
+
constructor(permissionApprovals: Pick<PermissionApprovalJobs, "recheck">, waits: Pick<Waits, "processTimeout" | "childFinished" | "stopChildren" | "stopDescendantsOfStopped" | "stopTree">, sandbox: Pick<SandboxService, "destroyDevice" | "resetFileSystem" | "revokeDeadHolder">, drift: Pick<ToolDrift, "check">, directory: Pick<DirectorySync, "runSyncJob">, deletion: Pick<RunDeletion, "stopOrg" | "stopTree">, offboarding: Pick<Offboarding, "stopRun">, runs: Pick<RunQueue, "ensureRun">, automations: Pick<AutomationFirer, "fire" | "settle">, scheduled: Pick<ScheduledRuns, "runNow">, log: Pick<KernelLogger, "error" | "warn">, operations: Pick<SandboxOperationReconcileJob, "reconcile" | "revoke" | "settleResumeProof">, blobObjects: Pick<BlobObjects, "deleteBlob" | "deleteStaging" | "releaseFile">, hashing: Pick<FileLibraryHashJob, "dispatch" | "runOrgBatch">, platformIcons: Pick<PlatformIconObjects, "deleteObject">, notices: Pick<ConversationNoticeDelivery, "attempt">, triggers: Pick<TriggerDispatcher, "dispatch">, coalescer: Pick<EventCoalescer, "flush">, idleCompaction: Pick<IdleCompactionJob, "fire">, db: KernelDb, loopback: Pick<LoopbackGrants, "refresh">, hostServices: Pick<HostServiceAccess, "deliverOwedStops">, retention: Pick<RetentionWorker, "run">, erasure: Pick<ErasureWorker, "run">);
|
|
72
73
|
process(job: Job, token?: string): Promise<void>;
|
|
73
74
|
/** Starts consuming (worker role, after the extensions loaded; built with `autorun: false`). */
|
|
74
75
|
start(): void;
|
|
@@ -16,11 +16,12 @@ import { AUTOMATION_COALESCE_JOB, AUTOMATION_FIRE_JOB, AUTOMATION_SETTLE_JOB, TR
|
|
|
16
16
|
import { BackgroundModule } from "../background/background.module.js";
|
|
17
17
|
import { BG_WAKE_JOB } from "../background/wake-rules.js";
|
|
18
18
|
import { EventLogModule } from "../conversations/event-log.js";
|
|
19
|
-
import { EVENT_ORG_BACKFILL_JOB, EventOrgBackfillJob, } from "../conversations/event-org-backfill.js";
|
|
20
|
-
import { EventOrgBackfillModule } from "../conversations/event-org-backfill.module.js";
|
|
21
19
|
import { resolveConversationOrg, resolveRunOrg } from "../conversations/job-org.js";
|
|
22
20
|
import { ConversationNoticeDelivery, ConversationNoticesModule, NOTICE_PROMPT_TIMEOUT_MS, } from "../device-access/conversation-notice-delivery.js";
|
|
23
21
|
import { CONVERSATION_NOTICE_JOB, } from "../device-access/conversation-notices.js";
|
|
22
|
+
import { ExtensionDeviceAccessModule } from "../device-access/device-access.module.js";
|
|
23
|
+
import { HOST_SERVICES_STOP_JOB, } from "../device-access/host-service-stop.js";
|
|
24
|
+
import { HostServiceAccess } from "../device-access/host-services.js";
|
|
24
25
|
import { DATA_ERASURE_JOB } from "../erasure/jobs.js";
|
|
25
26
|
import { ErasureWorker, ErasureWorkerModule } from "../erasure/worker.js";
|
|
26
27
|
import { BLOB_DELETE_JOB, BlobObjects, BlobObjectsModule, FILE_RELEASE_JOB, FILE_STAGING_DELETE_JOB, } from "../files/blob-objects.js";
|
|
@@ -73,7 +74,8 @@ export const MAINTENANCE_CONCURRENCY = 5;
|
|
|
73
74
|
* {@link BlobObjects}, `file-library-hash`, `file-library-hash-org` → {@link FileLibraryHashJob},
|
|
74
75
|
* `platform-icon-delete` →
|
|
75
76
|
* {@link PlatformIconObjects}, `device-conversation-notice` → {@link ConversationNoticeDelivery},
|
|
76
|
-
* `idle-compaction` → {@link IdleCompactionJob}, `device-loopback-refresh` → {@link LoopbackGrants}
|
|
77
|
+
* `idle-compaction` → {@link IdleCompactionJob}, `device-loopback-refresh` → {@link LoopbackGrants}, `device-host-services-stop` →
|
|
78
|
+
* {@link HostServiceAccess}). The name of a periodic job (a `@LockedCron` / `@LockedInterval` job,
|
|
77
79
|
* such as `sandbox-suspend-idle`) runs that job's body once ({@link ScheduledRuns.runNow}), as the
|
|
78
80
|
* maintenance handlers did when those jobs were schedulers on this queue: an operator's or a
|
|
79
81
|
* test's one-off run, not a second schedule (decision R23 of the Nest kernel spec). Any other
|
|
@@ -101,10 +103,10 @@ let MaintenanceProcessor = class MaintenanceProcessor extends WorkerHost {
|
|
|
101
103
|
idleCompaction;
|
|
102
104
|
db;
|
|
103
105
|
loopback;
|
|
104
|
-
|
|
106
|
+
hostServices;
|
|
105
107
|
retention;
|
|
106
108
|
erasure;
|
|
107
|
-
constructor(permissionApprovals, waits, sandbox, drift, directory, deletion, offboarding, runs, automations, scheduled, log, operations, blobObjects, hashing, platformIcons, notices, triggers, coalescer, idleCompaction, db, loopback,
|
|
109
|
+
constructor(permissionApprovals, waits, sandbox, drift, directory, deletion, offboarding, runs, automations, scheduled, log, operations, blobObjects, hashing, platformIcons, notices, triggers, coalescer, idleCompaction, db, loopback, hostServices, retention, erasure) {
|
|
108
110
|
super();
|
|
109
111
|
this.permissionApprovals = permissionApprovals;
|
|
110
112
|
this.waits = waits;
|
|
@@ -127,7 +129,7 @@ let MaintenanceProcessor = class MaintenanceProcessor extends WorkerHost {
|
|
|
127
129
|
this.idleCompaction = idleCompaction;
|
|
128
130
|
this.db = db;
|
|
129
131
|
this.loopback = loopback;
|
|
130
|
-
this.
|
|
132
|
+
this.hostServices = hostServices;
|
|
131
133
|
this.retention = retention;
|
|
132
134
|
this.erasure = erasure;
|
|
133
135
|
}
|
|
@@ -309,16 +311,17 @@ let MaintenanceProcessor = class MaintenanceProcessor extends WorkerHost {
|
|
|
309
311
|
case LOOPBACK_REFRESH_JOB:
|
|
310
312
|
await this.loopback.refresh(job.data, AbortSignal.timeout(LOOPBACK_REFRESH_TIMEOUT_MS));
|
|
311
313
|
return;
|
|
314
|
+
// a switched-off extension's host services on the machines that run them (local agents
|
|
315
|
+
// spec, call 5)
|
|
316
|
+
case HOST_SERVICES_STOP_JOB:
|
|
317
|
+
await this.hostServices.deliverOwedStops(job.data);
|
|
318
|
+
return;
|
|
312
319
|
// a large idle conversation's compaction before its prompt cache expires (idle compaction §4.3)
|
|
313
320
|
case IDLE_COMPACTION_JOB: {
|
|
314
321
|
const data = job.data;
|
|
315
322
|
await this.inOwnerScope(job, resolveRunOrg(this.db.db, data.runId, data.conversationId), (orgId) => this.idleCompaction.fire({ ...data, orgId }));
|
|
316
323
|
return;
|
|
317
324
|
}
|
|
318
|
-
// batched backfill of conversation_events.org_id from conversations (issue #1175)
|
|
319
|
-
case EVENT_ORG_BACKFILL_JOB:
|
|
320
|
-
await this.eventOrgBackfill.runBatch((job.data ?? { after: null }));
|
|
321
|
-
return;
|
|
322
325
|
default:
|
|
323
326
|
if (await this.scheduled.runNow(job.name))
|
|
324
327
|
return;
|
|
@@ -364,7 +367,7 @@ MaintenanceProcessor = __decorate([
|
|
|
364
367
|
__param(18, Inject(IdleCompactionJob)),
|
|
365
368
|
__param(19, Inject(KernelDb)),
|
|
366
369
|
__param(20, Inject(LoopbackGrants)),
|
|
367
|
-
__param(21, Inject(
|
|
370
|
+
__param(21, Inject(HostServiceAccess)),
|
|
368
371
|
__param(22, Inject(RetentionWorker)),
|
|
369
372
|
__param(23, Inject(ErasureWorker))
|
|
370
373
|
], MaintenanceProcessor);
|
|
@@ -397,14 +400,14 @@ MaintenanceModule = __decorate([
|
|
|
397
400
|
BlobObjectsModule,
|
|
398
401
|
// the file library's hashing
|
|
399
402
|
FileLibraryJobsModule,
|
|
400
|
-
// batched conversation_events.org_id backfill
|
|
401
|
-
EventOrgBackfillModule,
|
|
402
403
|
RetentionWorkerModule,
|
|
403
404
|
ErasureWorkerModule,
|
|
404
405
|
// the platform icon object deletion
|
|
405
406
|
PlatformIconObjectsModule,
|
|
406
407
|
// a deleted conversation's notice to its device's services
|
|
407
408
|
ConversationNoticesModule,
|
|
409
|
+
// a switched-off extension's host services stop
|
|
410
|
+
ExtensionDeviceAccessModule,
|
|
408
411
|
QueueModule.registerQueue(MAINTENANCE_QUEUE_NAME),
|
|
409
412
|
],
|
|
410
413
|
providers: [
|
|
@@ -68,10 +68,10 @@ export declare class DeviceReports {
|
|
|
68
68
|
changed: boolean;
|
|
69
69
|
}>;
|
|
70
70
|
/**
|
|
71
|
-
* `ctx.devices.reportChanged(deviceId)`
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
71
|
+
* `ctx.devices.reportChanged(deviceId)` returns `not-served` unless the device is live, bound to
|
|
72
|
+
* `plugin`, and in the caller's org if the caller has an org scope. Reads the device's report and
|
|
73
|
+
* permission support from `plugin` (with its current instance's handle, if any) outside any
|
|
74
|
+
* transaction and stores them as {@link refresh} does. Throws when the report cannot be read
|
|
75
75
|
* or does not pass, so the provider may tell again; a failed support read stores no support
|
|
76
76
|
* (no crossing enforceable: revocation fails closed).
|
|
77
77
|
*/
|
|
@@ -11,6 +11,7 @@ import { parseDeviceReport, } from "@capybara-hq/plugin-sdk";
|
|
|
11
11
|
import { Inject, Injectable, Optional } from "@nestjs/common";
|
|
12
12
|
import { sql } from "kysely";
|
|
13
13
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
14
|
+
import { asPlatform, currentScope, withOrgScope } from "../infra/database/org-scope.js";
|
|
14
15
|
import { runOutsideTransaction, TransactionHost } from "../infra/database/transaction-host.js";
|
|
15
16
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
16
17
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
@@ -132,42 +133,51 @@ let DeviceReports = class DeviceReports {
|
|
|
132
133
|
}
|
|
133
134
|
}
|
|
134
135
|
/**
|
|
135
|
-
* `ctx.devices.reportChanged(deviceId)`
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
136
|
+
* `ctx.devices.reportChanged(deviceId)` returns `not-served` unless the device is live, bound to
|
|
137
|
+
* `plugin`, and in the caller's org if the caller has an org scope. Reads the device's report and
|
|
138
|
+
* permission support from `plugin` (with its current instance's handle, if any) outside any
|
|
139
|
+
* transaction and stores them as {@link refresh} does. Throws when the report cannot be read
|
|
139
140
|
* or does not pass, so the provider may tell again; a failed support read stores no support
|
|
140
141
|
* (no crossing enforceable: revocation fails closed).
|
|
141
142
|
*/
|
|
142
143
|
async changed(plugin, deviceId, signal = new AbortController().signal) {
|
|
143
144
|
return runOutsideTransaction(async () => {
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (!entry)
|
|
156
|
-
throw new Error(`Device provider ${plugin} is not loaded on this replica`);
|
|
157
|
-
const instance = await this.db
|
|
158
|
-
.selectFrom("device_instances")
|
|
159
|
-
.select("handle")
|
|
160
|
-
.where("device_id", "=", deviceId)
|
|
161
|
-
.where("org_id", "=", device.org_id)
|
|
162
|
-
.where("provider", "=", plugin)
|
|
163
|
-
.executeTakeFirst();
|
|
164
|
-
const ref = {
|
|
165
|
-
deviceId,
|
|
166
|
-
orgId: device.org_id,
|
|
167
|
-
handle: (instance?.handle ?? null),
|
|
145
|
+
const scope = currentScope();
|
|
146
|
+
const lookup = () => {
|
|
147
|
+
const query = this.db
|
|
148
|
+
.selectFrom("devices as d")
|
|
149
|
+
.innerJoin("orgs as o", "o.id", "d.org_id")
|
|
150
|
+
.select("d.org_id")
|
|
151
|
+
.where("d.id", "=", deviceId)
|
|
152
|
+
.where("d.provider", "=", plugin)
|
|
153
|
+
.where("d.deleted_at", "is", null)
|
|
154
|
+
.where("o.deleted_at", "is", null);
|
|
155
|
+
return (scope?.kind === "org" ? query.where("d.org_id", "=", scope.orgId) : query).executeTakeFirst();
|
|
168
156
|
};
|
|
169
|
-
const
|
|
170
|
-
|
|
157
|
+
const device = scope
|
|
158
|
+
? await lookup()
|
|
159
|
+
: await asPlatform("resolve the org of a device served by the notifying provider", lookup);
|
|
160
|
+
if (!device)
|
|
161
|
+
return "not-served";
|
|
162
|
+
return withOrgScope(device.org_id, async () => {
|
|
163
|
+
const entry = this.providers.forDevice(plugin);
|
|
164
|
+
if (!entry)
|
|
165
|
+
throw new Error(`Device provider ${plugin} is not loaded on this replica`);
|
|
166
|
+
const instance = await this.db
|
|
167
|
+
.selectFrom("device_instances")
|
|
168
|
+
.select("handle")
|
|
169
|
+
.where("device_id", "=", deviceId)
|
|
170
|
+
.where("org_id", "=", device.org_id)
|
|
171
|
+
.where("provider", "=", plugin)
|
|
172
|
+
.executeTakeFirst();
|
|
173
|
+
const ref = {
|
|
174
|
+
deviceId,
|
|
175
|
+
orgId: device.org_id,
|
|
176
|
+
handle: (instance?.handle ?? null),
|
|
177
|
+
};
|
|
178
|
+
const answer = await this.ask(entry, ref, signal, true);
|
|
179
|
+
return (await this.store(plugin, ref, answer)).published ? "bumped" : "same";
|
|
180
|
+
});
|
|
171
181
|
});
|
|
172
182
|
}
|
|
173
183
|
/**
|