@capybara-hq/kernel 0.1.0-rc.132 → 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.
Files changed (135) hide show
  1. package/bootstrap.json +5 -5
  2. package/dist/admin/admin.module.js +3 -0
  3. package/dist/admin/admin.schemas.d.ts +4 -0
  4. package/dist/admin/health.service.d.ts +2 -2
  5. package/dist/admin/health.service.js +6 -2
  6. package/dist/admin/setup.service.js +6 -1
  7. package/dist/agents/agents.controller.js +3 -2
  8. package/dist/agents/agents.service.d.ts +2 -0
  9. package/dist/agents/agents.service.js +7 -0
  10. package/dist/catalog/catalog.service.d.ts +2 -0
  11. package/dist/catalog/catalog.service.js +28 -5
  12. package/dist/catalog/marketplace-fetch.d.ts +2 -0
  13. package/dist/catalog/marketplace-fetch.js +15 -0
  14. package/dist/catalog/marketplaces.service.d.ts +4 -4
  15. package/dist/catalog/marketplaces.service.js +3 -2
  16. package/dist/catalog/owned-items.d.ts +2 -0
  17. package/dist/catalog/owned-items.js +30 -31
  18. package/dist/catalog/ownership.js +40 -38
  19. package/dist/catalog/plugin-import.d.ts +3 -4
  20. package/dist/catalog/plugin-import.js +50 -1
  21. package/dist/catalog/plugin-upgrade.d.ts +8 -0
  22. package/dist/catalog/plugin-upgrade.js +95 -7
  23. package/dist/catalog/publisher-policy.d.ts +9 -0
  24. package/dist/catalog/publisher-policy.js +12 -0
  25. package/dist/catalog/unshare.js +66 -58
  26. package/dist/client/client-access.service.js +5 -3
  27. package/dist/config/schema.js +1 -1
  28. package/dist/conversations/conversations.controller.js +4 -14
  29. package/dist/conversations/conversations.service.d.ts +14 -0
  30. package/dist/conversations/conversations.service.js +20 -2
  31. package/dist/ctx/create-ctx.d.ts +11 -2
  32. package/dist/ctx/create-ctx.js +121 -52
  33. package/dist/ctx/queue.js +7 -4
  34. package/dist/db/extension-rls-predicate.d.ts +1 -0
  35. package/dist/db/extension-rls-predicate.js +8 -0
  36. package/dist/db/kernel-schema.d.ts +48 -0
  37. package/dist/db/migrator.js +6 -13
  38. package/dist/db/pool.d.ts +2 -2
  39. package/dist/db/pool.js +2 -2
  40. package/dist/db/sql-statements.d.ts +3 -0
  41. package/dist/db/sql-statements.js +15 -5
  42. package/dist/device-access/device-access.module.js +12 -2
  43. package/dist/device-access/device-access.service.d.ts +30 -2
  44. package/dist/device-access/device-access.service.js +38 -4
  45. package/dist/device-access/host-gate.d.ts +45 -0
  46. package/dist/device-access/host-gate.js +92 -0
  47. package/dist/device-access/host-service-stop-sweep.d.ts +33 -0
  48. package/dist/device-access/host-service-stop-sweep.js +112 -0
  49. package/dist/device-access/host-service-stop.d.ts +78 -0
  50. package/dist/device-access/host-service-stop.js +144 -0
  51. package/dist/device-access/host-services.d.ts +211 -0
  52. package/dist/device-access/host-services.js +803 -0
  53. package/dist/device-access/person-handles.d.ts +10 -0
  54. package/dist/device-access/person-handles.js +25 -0
  55. package/dist/device-access/service-events.d.ts +199 -0
  56. package/dist/device-access/service-events.js +704 -0
  57. package/dist/device-access/token.d.ts +5 -0
  58. package/dist/device-access/token.js +5 -0
  59. package/dist/devices/devices.service.js +3 -0
  60. package/dist/dial-in/access.d.ts +5 -5
  61. package/dist/dial-in/access.js +19 -12
  62. package/dist/dial-in/gateway.js +6 -2
  63. package/dist/dial-in/machines.d.ts +9 -2
  64. package/dist/dial-in/machines.js +27 -4
  65. package/dist/erasure/device-cleanup.js +12 -0
  66. package/dist/erasure/org-catalog.js +2 -2
  67. package/dist/erasure/org-rules.js +9 -0
  68. package/dist/errors.d.ts +2 -0
  69. package/dist/errors.js +2 -0
  70. package/dist/extensions/admin-ops.js +8 -2
  71. package/dist/extensions/deployed-snapshots.d.ts +4 -1
  72. package/dist/extensions/deployed-snapshots.js +7 -2
  73. package/dist/extensions/host.d.ts +7 -2
  74. package/dist/extensions/host.js +11 -2
  75. package/dist/extensions/instance.d.ts +3 -0
  76. package/dist/extensions/instance.js +4 -0
  77. package/dist/extensions/ledger.d.ts +1 -1
  78. package/dist/extensions/lifecycle-hooks.js +3 -3
  79. package/dist/extensions/org-config.js +6 -1
  80. package/dist/extensions/permission-set.d.ts +7 -0
  81. package/dist/extensions/permission-set.js +10 -0
  82. package/dist/extensions/permission-view.d.ts +1 -1
  83. package/dist/extensions/permission-view.js +10 -1
  84. package/dist/git/tickets.js +32 -27
  85. package/dist/http/app.js +5 -3
  86. package/dist/identity/accounts.d.ts +6 -1
  87. package/dist/identity/accounts.js +11 -2
  88. package/dist/identity/api-tokens.js +7 -6
  89. package/dist/identity/settings.d.ts +9 -1
  90. package/dist/identity/settings.js +16 -1
  91. package/dist/inbox/org-notices.js +3 -2
  92. package/dist/index.d.ts +1 -0
  93. package/dist/index.js +1 -0
  94. package/dist/infra/database/scoped-dialect.d.ts +3 -2
  95. package/dist/infra/database/scoped-dialect.js +260 -72
  96. package/dist/infra/database/startup-activation-transaction.d.ts +2 -0
  97. package/dist/infra/database/startup-activation-transaction.js +3 -2
  98. package/dist/infra/outbox/registry.d.ts +28 -0
  99. package/dist/infra/outbox/registry.js +30 -0
  100. package/dist/infra/queue/queue-names.d.ts +1 -1
  101. package/dist/infra/queue/queue-names.js +1 -0
  102. package/dist/infra/queue/run-job.d.ts +4 -1
  103. package/dist/infra/queue/run-job.js +10 -2
  104. package/dist/kernel.module.js +3 -0
  105. package/dist/orgs/offboarding.js +18 -9
  106. package/dist/orgs/settings.service.js +3 -0
  107. package/dist/packages/npm-publish-keys.json +27 -0
  108. package/dist/packages/official-publisher.d.ts +19 -0
  109. package/dist/packages/official-publisher.js +152 -0
  110. package/dist/packages/provenance.d.ts +7 -0
  111. package/dist/packages/provenance.js +22 -19
  112. package/dist/packages/sigstore-trusted-root.json +126 -0
  113. package/dist/platform/ops/admin.ops.js +2 -1
  114. package/dist/platform/ops/orgs.ops.js +1 -0
  115. package/dist/roles/worker-role.d.ts +6 -3
  116. package/dist/roles/worker-role.js +12 -4
  117. package/dist/roles/worker.module.js +7 -0
  118. package/dist/runtime/maintenance.d.ts +5 -2
  119. package/dist/runtime/maintenance.js +18 -4
  120. package/dist/sandbox/device-reports.d.ts +4 -4
  121. package/dist/sandbox/device-reports.js +40 -30
  122. package/dist/sandbox/device-services.d.ts +2 -1
  123. package/dist/sandbox/device-services.js +5 -1
  124. package/dist/sandbox/permission-ceiling-writes.d.ts +8 -0
  125. package/dist/sandbox/permission-ceiling-writes.js +21 -0
  126. package/dist/sandbox/permission-config-publication.js +5 -1
  127. package/dist/themes/theme-state.js +24 -13
  128. package/dist/tools/call-scope.d.ts +6 -0
  129. package/dist/tools/call-scope.js +22 -0
  130. package/dist/tools/registry.js +20 -2
  131. package/dist/ui/views.js +36 -8
  132. package/package.json +9 -4
  133. package/src/migrations/0222_device_host_services.sql +27 -0
  134. package/src/migrations/0223_device_service_events.sql +54 -0
  135. package/src/migrations/0224_cache_conversation_rls_settings.sql +33 -0
@@ -13,6 +13,7 @@ import { sql } from "kysely";
13
13
  import { retargetSetupRequests } from "../agents/pending-connector-requests.js";
14
14
  import { EventLog } from "../conversations/event-log.js";
15
15
  import { lockConversationTrees } from "../conversations/tree.js";
16
+ import { oweHostServicesStopOnDevices } from "../device-access/host-service-stop.js";
16
17
  import { revokeSiteGrantsOfDevice } from "../device-access/site-grants.js";
17
18
  import { ApiError } from "../errors.js";
18
19
  import { enabledExtensionsQuery } from "../extensions/enabled.js";
@@ -21,6 +22,7 @@ import { ExtensionRegistry } from "../extensions/registry.js";
21
22
  import { audit } from "../identity/audit.js";
22
23
  import { SessionService } from "../identity/sessions.js";
23
24
  import { KernelDb } from "../infra/database/kernel-db.js";
25
+ import { asPlatform } from "../infra/database/org-scope.js";
24
26
  import { TransactionHost } from "../infra/database/transaction-host.js";
25
27
  import { Transactional } from "../infra/database/transactional.decorator.js";
26
28
  import { OutboxService } from "../infra/outbox/outbox.service.js";
@@ -199,16 +201,18 @@ let Offboarding = class Offboarding {
199
201
  .returning("id")
200
202
  .execute()
201
203
  : [];
202
- // org-filter: removal revokes the person's personal tokens account-wide on purpose (comment above)
203
204
  const tokens = revoke
204
- ? await this.db
205
- .updateTable("api_tokens")
206
- .set({ revoked_at: sql `now()` })
207
- .where("kind", "=", "personal")
208
- .where("account_id", "=", accountId)
209
- .where("revoked_at", "is", null)
210
- .returning("id")
211
- .execute()
205
+ ? await asPlatform("Revoke account-wide personal tokens after member removal", () => {
206
+ // org-filter: personal tokens belong to the account and have a null org_id.
207
+ return this.db
208
+ .updateTable("api_tokens")
209
+ .set({ revoked_at: sql `now()` })
210
+ .where("kind", "=", "personal")
211
+ .where("account_id", "=", accountId)
212
+ .where("revoked_at", "is", null)
213
+ .returning("id")
214
+ .execute();
215
+ })
212
216
  : [];
213
217
  // a registration follows its session (push plan decision 3)
214
218
  await deletePushRegistrationsForSessions(this.db.db, sessions.map((r) => r.id));
@@ -320,6 +324,11 @@ let Offboarding = class Offboarding {
320
324
  await revokeLoopbackGrantsOfDevice(this.db.db, this.outbox, { orgId, deviceId: d.id });
321
325
  await revokeSiteGrantsOfDevice(this.db.db, { orgId, deviceId: d.id });
322
326
  }
327
+ // the person's host services in the org end with their devices (local agents spec, call 5)
328
+ await oweHostServicesStopOnDevices(this.db.db, this.outbox, {
329
+ orgId,
330
+ deviceIds: devices.map((d) => d.id),
331
+ });
323
332
  await this.db
324
333
  .deleteFrom("device_defaults")
325
334
  .where("org_id", "=", orgId)
@@ -940,6 +940,9 @@ let OrgSettingsService = class OrgSettingsService {
940
940
  return after.outsideSandbox === "off";
941
941
  return hostsNarrowed(scope, row, orgHosts, (host) => hostGrantable(grantCeiling, host));
942
942
  }, resetConsent);
943
+ // running outside the sandbox switched off closes the host gate on the org's devices
944
+ if (effOutside(before) === "allowed" && effOutside(reread) === "off")
945
+ await this.ceilings.oweHostServiceStopsLocked({ orgId }, "org");
943
946
  }
944
947
  return after;
945
948
  }
@@ -0,0 +1,27 @@
1
+ {
2
+ "keys": [
3
+ {
4
+ "keyId": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
5
+ "keyUsage": "npm:attestations",
6
+ "publicKey": {
7
+ "rawBytes": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE1Olb3zMAFFxXKHiIkQO5cJ3Yhl5i6UPp+IhuteBJbuHcA5UogKo0EWtlWwW6KSaKoTNEYL7JlCQiVnkhBktUgg==",
8
+ "keyDetails": "PKIX_ECDSA_P256_SHA_256",
9
+ "validFor": {
10
+ "start": "2022-12-01T00:00:00.000Z",
11
+ "end": "2025-01-29T00:00:00.000Z"
12
+ }
13
+ }
14
+ },
15
+ {
16
+ "keyId": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U",
17
+ "keyUsage": "npm:attestations",
18
+ "publicKey": {
19
+ "rawBytes": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEY6Ya7W++7aUPzvMTrezH6Ycx3c+HOKYCcNGybJZSCJq/fd7Qa8uuAKtdIkUQtQiEKERhAmE5lMMJhP8OkDOa2g==",
20
+ "keyDetails": "PKIX_ECDSA_P256_SHA_256",
21
+ "validFor": {
22
+ "start": "2025-01-13T00:00:00.000Z"
23
+ }
24
+ }
25
+ }
26
+ ]
27
+ }
@@ -0,0 +1,19 @@
1
+ import type { NpmFetchConfig } from "./npm.js";
2
+ import { type Provenance } from "./provenance.js";
3
+ declare const POLICY_VERSION = 1;
4
+ export interface OfficialNpmRevision {
5
+ name: string;
6
+ version: string;
7
+ /** SHA-512 already checked against the fetched artifact bytes. */
8
+ integrity: string;
9
+ }
10
+ export interface OfficialPublisherProof extends Provenance {
11
+ revision: OfficialNpmRevision;
12
+ evidenceDigest: string;
13
+ policyVersion: typeof POLICY_VERSION;
14
+ }
15
+ /** Checks both signatures, transparency evidence and publisher identity with the bundled roots. */
16
+ export declare function verifyOfficialPublisher(body: unknown, revision: OfficialNpmRevision): OfficialPublisherProof;
17
+ /** Uses the same bounded registry client as the review's display-only provenance. */
18
+ export declare function fetchOfficialPublisher(cfg: NpmFetchConfig, revision: OfficialNpmRevision, signal?: AbortSignal): Promise<OfficialPublisherProof>;
19
+ export {};
@@ -0,0 +1,152 @@
1
+ import { createHash } from "node:crypto";
2
+ import { bundleFromJSON } from "@sigstore/bundle";
3
+ import { PublicKey, TrustedRoot } from "@sigstore/protobuf-specs";
4
+ import { toSignedEntity, toTrustMaterial, Verifier } from "@sigstore/verify";
5
+ import { z } from "zod";
6
+ import { canonicalJson } from "../tools/canonical-json.js";
7
+ import npmPublishKeys from "./npm-publish-keys.json" with { type: "json" };
8
+ import { fetchNpmAttestations, PROVENANCE_TIMEOUT_MS, SLSA_PROVENANCE_V1, sha512Hex, } from "./provenance.js";
9
+ import trustedRoot from "./sigstore-trusted-root.json" with { type: "json" };
10
+ const NPM_PUBLISH = "https://github.com/npm/attestation/tree/main/specs/publish/v0.1";
11
+ const REGISTRY = "https://registry.npmjs.org";
12
+ const REPOSITORY = "https://github.com/capybara-hq/plugins";
13
+ const REPOSITORY_ID = "1436732755";
14
+ const OWNER_ID = "343699164";
15
+ const WORKFLOW = ".github/workflows/release.yml";
16
+ const MAIN_REF = "refs/heads/main";
17
+ const WORKFLOW_IDENTITY = [REPOSITORY, "/", WORKFLOW, "@", MAIN_REF].join("");
18
+ const GITHUB_ISSUER = "https://token.actions.githubusercontent.com";
19
+ const BUILD_TYPE = "https://slsa-framework.github.io/github-actions-buildtypes/workflow/v1";
20
+ const POLICY_VERSION = 1;
21
+ // These two files are Sigstore production TUF targets: trusted_root.json and
22
+ // registry.npmjs.org/keys.json (publish keys only). Refresh them from the authenticated
23
+ // TUF repository during review. Verification receives no trust material from the registry.
24
+ const verifier = new Verifier(toTrustMaterial(TrustedRoot.fromJSON(trustedRoot), Object.fromEntries(npmPublishKeys.keys.map((key) => [key.keyId, PublicKey.fromJSON(key.publicKey)]))));
25
+ const attestationsSchema = z.object({
26
+ attestations: z.array(z.object({ predicateType: z.string(), bundle: z.unknown() })).max(16),
27
+ });
28
+ const statementSchema = z.object({
29
+ _type: z.enum(["https://in-toto.io/Statement/v1", "https://in-toto.io/Statement/v0.1"]),
30
+ predicateType: z.string(),
31
+ subject: z
32
+ .array(z.object({ name: z.string(), digest: z.object({ sha512: z.string() }) }))
33
+ .length(1),
34
+ predicate: z.unknown(),
35
+ });
36
+ const buildSchema = z.object({
37
+ buildDefinition: z.object({
38
+ buildType: z.literal(BUILD_TYPE),
39
+ externalParameters: z.object({
40
+ workflow: z.object({
41
+ repository: z.literal(REPOSITORY),
42
+ path: z.literal(WORKFLOW),
43
+ ref: z.literal(MAIN_REF),
44
+ }),
45
+ }),
46
+ internalParameters: z.object({
47
+ github: z.object({
48
+ repository_id: z.literal(REPOSITORY_ID),
49
+ repository_owner_id: z.literal(OWNER_ID),
50
+ }),
51
+ }),
52
+ resolvedDependencies: z
53
+ .array(z.object({ digest: z.object({ gitCommit: z.string().regex(/^[0-9a-f]{40}$/) }) }))
54
+ .min(1),
55
+ }),
56
+ });
57
+ const publishSchema = z.object({
58
+ name: z.string(),
59
+ version: z.string(),
60
+ registry: z.literal(REGISTRY),
61
+ });
62
+ function checkEnvelope(raw, type, revision) {
63
+ const bundle = bundleFromJSON(raw);
64
+ if (bundle.content.$case !== "dsseEnvelope" ||
65
+ bundle.content.dsseEnvelope.payloadType !== "application/vnd.in-toto+json") {
66
+ throw new Error("Expected an in-toto DSSE bundle");
67
+ }
68
+ const entity = toSignedEntity(bundle);
69
+ if (!entity.tlogEntries.some((entry) => entry.inclusionProof !== undefined)) {
70
+ throw new Error("The attestation has no transparency log inclusion proof");
71
+ }
72
+ const statement = statementSchema.parse(JSON.parse(bundle.content.dsseEnvelope.payload.toString("utf8")));
73
+ const [subject] = statement.subject;
74
+ const digest = sha512Hex(revision.integrity);
75
+ const packageUrl = ["pkg:npm/", revision.name.replace(/^@/, "%40"), "@", revision.version].join("");
76
+ if (!digest ||
77
+ statement.predicateType !== type ||
78
+ (type === SLSA_PROVENANCE_V1 && statement._type !== "https://in-toto.io/Statement/v1") ||
79
+ subject?.name !== packageUrl ||
80
+ subject.digest.sha512 !== digest) {
81
+ throw new Error("The attestation does not match this package, version and SHA-512");
82
+ }
83
+ return { entity, predicate: statement.predicate };
84
+ }
85
+ function verifyBuildSigner(entity) {
86
+ if (entity.key.$case !== "certificate") {
87
+ throw new Error("The build attestation has no signing certificate");
88
+ }
89
+ const cert = entity.key.certificate;
90
+ const signer = verifier.verify(entity, { extensions: { issuer: GITHUB_ISSUER } });
91
+ // Fulcio extensions sign these GitHub OIDC claims independently of the predicate.
92
+ const claim = (oid) => cert.extension(`1.3.6.1.4.1.57264.1.${oid}`)?.valueObj.subs[0]?.value.toString("utf8");
93
+ if (claim(14) !== MAIN_REF || !claim(9)?.endsWith(`/${WORKFLOW}@${MAIN_REF}`)) {
94
+ throw new Error("The signing certificate does not match the official release workflow or main ref");
95
+ }
96
+ if (signer.identity?.subjectAlternativeName !== WORKFLOW_IDENTITY ||
97
+ claim(9) !== WORKFLOW_IDENTITY ||
98
+ claim(12) !== REPOSITORY ||
99
+ claim(15) !== REPOSITORY_ID ||
100
+ claim(17) !== OWNER_ID) {
101
+ throw new Error("The signing certificate does not match the official repository identity");
102
+ }
103
+ const commit = claim(13);
104
+ if (!commit)
105
+ throw new Error("The signing certificate names no source commit");
106
+ return commit;
107
+ }
108
+ /** Checks both signatures, transparency evidence and publisher identity with the bundled roots. */
109
+ export function verifyOfficialPublisher(body, revision) {
110
+ const { attestations } = attestationsSchema.parse(body);
111
+ const [publish, ...duplicatePublish] = attestations.filter((a) => a.predicateType === NPM_PUBLISH);
112
+ const [build, ...duplicateBuild] = attestations.filter((a) => a.predicateType === SLSA_PROVENANCE_V1);
113
+ if (!publish || !build || duplicatePublish.length || duplicateBuild.length) {
114
+ throw new Error("Expected one registry publish attestation and one workflow attestation");
115
+ }
116
+ const published = checkEnvelope(publish.bundle, NPM_PUBLISH, revision);
117
+ if (published.entity.key.$case !== "public-key") {
118
+ throw new Error("The publish attestation must be signed by an npm registry key");
119
+ }
120
+ const info = publishSchema.parse(published.predicate);
121
+ if (info.name !== revision.name || info.version !== revision.version) {
122
+ throw new Error("The npm registry attested a different package revision");
123
+ }
124
+ verifier.verify(published.entity);
125
+ const built = checkEnvelope(build.bundle, SLSA_PROVENANCE_V1, revision);
126
+ const commit = verifyBuildSigner(built.entity);
127
+ const [source] = buildSchema.parse(built.predicate).buildDefinition.resolvedDependencies;
128
+ if (source?.digest.gitCommit !== commit) {
129
+ throw new Error("The signing certificate does not match the build's source commit");
130
+ }
131
+ if (!/^@capybara-hq\/plugin-[a-z0-9][a-z0-9-]*$/.test(revision.name)) {
132
+ throw new Error("An official plugin must belong to the Capybara npm namespace");
133
+ }
134
+ return {
135
+ checked: true,
136
+ revision,
137
+ repository: REPOSITORY,
138
+ commit,
139
+ workflow: WORKFLOW,
140
+ buildType: BUILD_TYPE,
141
+ evidenceDigest: createHash("sha256")
142
+ .update(canonicalJson([publish.bundle, build.bundle]))
143
+ .digest("hex"),
144
+ policyVersion: POLICY_VERSION,
145
+ };
146
+ }
147
+ /** Uses the same bounded registry client as the review's display-only provenance. */
148
+ export async function fetchOfficialPublisher(cfg, revision, signal) {
149
+ const timeout = AbortSignal.timeout(PROVENANCE_TIMEOUT_MS);
150
+ const attestations = await fetchNpmAttestations(cfg, revision.name, revision.version, signal ? AbortSignal.any([signal, timeout]) : timeout);
151
+ return verifyOfficialPublisher(attestations, revision);
152
+ }
@@ -21,17 +21,22 @@ export interface Provenance {
21
21
  workflow: string;
22
22
  /** The SLSA build type (which CI system's build definition). */
23
23
  buildType: string;
24
+ /** Present only when the official publisher attestations were verified. */
25
+ evidenceDigest?: string;
24
26
  }
25
27
  /** Provenance was not checked (no attestation, offline, or an answer that could not be read). */
26
28
  export interface ProvenanceNotChecked {
27
29
  checked: false;
28
30
  reason: string;
31
+ reasonCode?: "official_pin_only";
29
32
  }
30
33
  export type ProvenanceResult = Provenance | ProvenanceNotChecked;
31
34
  /** The predicate type of an SLSA v1 provenance statement. */
32
35
  export declare const SLSA_PROVENANCE_V1 = "https://slsa.dev/provenance/v1";
33
36
  /** Provenance must not hold up an import: a slow registry gives "not checked". */
34
37
  export declare const PROVENANCE_TIMEOUT_MS = 15000;
38
+ /** The hex sha512 of a `sha512-<base64>` integrity (undefined for anything else). */
39
+ export declare function sha512Hex(integrity: string): string | undefined;
35
40
  /**
36
41
  * Reads the SLSA provenance of `name@version` from the configured registry. `integrity` (the
37
42
  * tarball's `sha512-…`, when known) must be among the statement's subject digests, so a statement
@@ -40,6 +45,8 @@ export declare const PROVENANCE_TIMEOUT_MS = 15000;
40
45
  export declare function fetchProvenance(cfg: NpmFetchConfig, name: string, version: string, signal: AbortSignal, opts?: {
41
46
  integrity?: string;
42
47
  }): Promise<ProvenanceResult>;
48
+ /** Fetches bounded attestation evidence without accepting it as publisher proof. */
49
+ export declare function fetchNpmAttestations(cfg: NpmFetchConfig, name: string, version: string, signal: AbortSignal): Promise<unknown>;
43
50
  /**
44
51
  * Parses an attestations answer (`{ attestations: [{ predicateType, bundle: { dsseEnvelope } }] }`).
45
52
  * Exported for tests.
@@ -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
- return notChecked("not a valid npm package name and version");
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
- return notChecked(`the registry answered HTTP ${res.status} for the attestations`);
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
- body = JSON.parse(raw.toString("utf8"));
66
+ return JSON.parse(raw.toString("utf8"));
60
67
  }
61
68
  catch (e) {
62
69
  if (signal.aborted)
63
- return notChecked("the registry did not answer in time");
70
+ throw new NpmAttestationsError("the registry did not answer in time", { cause: e });
64
71
  if (e instanceof NetDeniedError) {
65
- return notChecked(`the network rules refused the attestations: ${e.message}`);
72
+ throw new NpmAttestationsError(`the network rules refused the attestations: ${e.message}`, {
73
+ cause: e,
74
+ });
66
75
  }
67
- return notChecked(`cannot read the attestations: ${errMsg(e)}`);
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) and the connector tool
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) and the connector tool
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 };