@capybara-hq/kernel 0.1.0-rc.137 → 0.1.0-rc.139

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 (101) hide show
  1. package/bootstrap.json +31 -31
  2. package/dist/admin/extensions.controller.d.ts +5 -2
  3. package/dist/admin/extensions.controller.js +10 -1
  4. package/dist/admin/extensions.schemas.d.ts +4 -0
  5. package/dist/admin/extensions.schemas.js +9 -0
  6. package/dist/admin/health.service.d.ts +1 -1
  7. package/dist/admin/health.service.js +3 -3
  8. package/dist/catalog/catalog-content.d.ts +5 -7
  9. package/dist/catalog/catalog-items.js +1 -1
  10. package/dist/catalog/catalog-scope.service.js +5 -5
  11. package/dist/catalog/catalog.module.js +5 -4
  12. package/dist/catalog/catalog.service.d.ts +7 -1
  13. package/dist/catalog/catalog.service.js +19 -2
  14. package/dist/catalog/effect-work.d.ts +27 -0
  15. package/dist/catalog/effect-work.js +151 -0
  16. package/dist/catalog/jobs.d.ts +4 -1
  17. package/dist/catalog/jobs.js +14 -4
  18. package/dist/catalog/org-catalog.service.d.ts +2 -0
  19. package/dist/catalog/org-catalog.service.js +68 -12
  20. package/dist/catalog/org-intent.d.ts +4 -2
  21. package/dist/catalog/org-intent.js +25 -4
  22. package/dist/catalog/owned-items.d.ts +5 -1
  23. package/dist/catalog/owned-items.js +18 -3
  24. package/dist/catalog/plugin-import.d.ts +4 -2
  25. package/dist/catalog/plugin-import.js +10 -5
  26. package/dist/catalog/plugin-install.d.ts +17 -51
  27. package/dist/catalog/plugin-install.js +209 -235
  28. package/dist/catalog/plugin-upgrade.d.ts +8 -3
  29. package/dist/catalog/plugin-upgrade.js +63 -34
  30. package/dist/catalog/scope-sync-workers.d.ts +7 -11
  31. package/dist/catalog/scope-sync-workers.js +10 -26
  32. package/dist/catalog/scope-sync.d.ts +19 -114
  33. package/dist/catalog/scope-sync.js +220 -239
  34. package/dist/catalog/scope-writer.d.ts +10 -1
  35. package/dist/catalog/scope-writer.js +62 -4
  36. package/dist/catalog/template-connector-ensure.js +1 -1
  37. package/dist/catalog/unshare.js +1 -2
  38. package/dist/config/schema.d.ts +1 -1
  39. package/dist/config/schema.js +7 -4
  40. package/dist/db/kernel-schema.d.ts +18 -17
  41. package/dist/erasure/org-catalog.js +2 -2
  42. package/dist/erasure/org-rules.js +2 -2
  43. package/dist/extensions/admin-ops.d.ts +1 -1
  44. package/dist/extensions/admin-ops.js +1 -1
  45. package/dist/extensions/admin-view.d.ts +4 -1
  46. package/dist/extensions/admin-view.js +27 -11
  47. package/dist/extensions/bootstrap.d.ts +1 -1
  48. package/dist/extensions/bootstrap.js +2 -3
  49. package/dist/extensions/enabled.d.ts +159 -0
  50. package/dist/extensions/enabled.js +7 -0
  51. package/dist/extensions/host.d.ts +1 -0
  52. package/dist/extensions/host.js +5 -2
  53. package/dist/extensions/isolated/authorization.d.ts +8 -0
  54. package/dist/extensions/isolated/authorization.js +56 -11
  55. package/dist/extensions/isolated/broker.js +30 -11
  56. package/dist/extensions/isolated/engine-binds.d.ts +9 -0
  57. package/dist/extensions/isolated/engine-binds.js +82 -0
  58. package/dist/extensions/isolated/engine-policy.d.ts +85 -0
  59. package/dist/extensions/isolated/engine-policy.js +75 -0
  60. package/dist/extensions/isolated/engine-proxy-main.d.ts +1 -0
  61. package/dist/extensions/isolated/engine-proxy-main.js +20 -0
  62. package/dist/extensions/isolated/engine-proxy.d.ts +7 -0
  63. package/dist/extensions/isolated/engine-proxy.js +408 -0
  64. package/dist/extensions/isolated/engine-vaults.d.ts +12 -0
  65. package/dist/extensions/isolated/engine-vaults.js +93 -0
  66. package/dist/extensions/isolated/lanes.d.ts +11 -3
  67. package/dist/extensions/isolated/lanes.js +43 -16
  68. package/dist/extensions/isolated/postgres-gate.d.ts +1 -0
  69. package/dist/extensions/isolated/postgres-gate.js +6 -6
  70. package/dist/extensions/isolated/revision.d.ts +1 -1
  71. package/dist/extensions/isolated/revision.js +3 -2
  72. package/dist/extensions/isolated/sandbox.d.ts +10 -6
  73. package/dist/extensions/isolated/sandbox.js +101 -117
  74. package/dist/extensions/lifecycle-topics.d.ts +1 -0
  75. package/dist/extensions/lifecycle-topics.js +1 -0
  76. package/dist/extensions/lifecycle.js +23 -2
  77. package/dist/extensions/permission-view.d.ts +6 -1
  78. package/dist/inbox/platform-inbox.service.js +16 -27
  79. package/dist/infra/events/kernel-events.d.ts +4 -0
  80. package/dist/infra/outbox/registry.d.ts +3 -36
  81. package/dist/infra/outbox/registry.js +4 -49
  82. package/dist/infra/queue/queue-names.d.ts +1 -1
  83. package/dist/infra/queue/queue-names.js +1 -1
  84. package/dist/orgs/org-lock.d.ts +3 -1
  85. package/dist/orgs/org-lock.js +3 -1
  86. package/dist/orgs/orgs.service.d.ts +3 -1
  87. package/dist/orgs/orgs.service.js +15 -8
  88. package/dist/overrides.d.ts +0 -3
  89. package/dist/overrides.js +0 -2
  90. package/dist/platform/ops/extensions-admin.ops.js +20 -3
  91. package/dist/platform/ops/org-plugins.ops.js +5 -2
  92. package/dist/platform/ops/plugins.ops.js +11 -10
  93. package/dist/tools/registry.d.ts +1 -1
  94. package/dist/tools/registry.js +6 -2
  95. package/package.json +2 -2
  96. package/src/migrations/0231_plugin_effect_work.sql +171 -0
  97. package/src/migrations/0232_contract_plugin_effect_schema.sql +49 -0
  98. package/dist/catalog/install-status.d.ts +0 -5
  99. package/dist/catalog/install-status.js +0 -5
  100. package/dist/catalog/scope-jobs.d.ts +0 -59
  101. package/dist/catalog/scope-jobs.js +0 -78
package/bootstrap.json CHANGED
@@ -3,103 +3,103 @@
3
3
  "schemaVersion": 1,
4
4
  "marketplace": {
5
5
  "url": "https://github.com/capybara-hq/plugins.git",
6
- "commit": "d5b799da18c7ca44e3b97f9bc13dae6b61495dfd"
6
+ "commit": "ecc903f26ba0d949cc17a7f44dade2ca0316973f"
7
7
  },
8
8
  "plugins": [
9
9
  {
10
10
  "name": "openai-compatible",
11
11
  "source": "npm",
12
12
  "npm": "@capybara-hq/plugin-openai-compatible",
13
- "version": "0.1.0-rc.17",
14
- "integrity": "sha512-ly1FFSEK5uwWqs+TPGmbiGeURqTXRuUjpakcj1wEsryxgueIDe2uyj+yvyIf/jwyTU3728tmxxZmgucGh9b1Qg==",
13
+ "version": "0.1.0-rc.18",
14
+ "integrity": "sha512-u2/gp9oYXINijXSqiLdeKYoHQzTHiZM7bxt8lynrjNGxYtPzV4rwmPk3See1yOTpmJMeKqNPqavudisocZYOBA==",
15
15
  "required": false
16
16
  },
17
17
  {
18
18
  "name": "object-store-s3",
19
19
  "source": "npm",
20
20
  "npm": "@capybara-hq/plugin-object-store-s3",
21
- "version": "0.1.0-rc.13",
22
- "integrity": "sha512-J0bhmRafIoifcZsI6ESTTKClZMSN/cPLVFKfVBIjGTzhGcZobAuTY5+m+j3zMeZCQcEzirBhtF3t76KpslWTZg==",
21
+ "version": "0.1.0-rc.14",
22
+ "integrity": "sha512-SRqBeqzAIuli9kEsdFprO4wQW17mCLxXooheNei0q4UyzPZggtpRORrRCZcgixTsFuzQFP0hPonZcgx3wm0oqQ==",
23
23
  "required": true
24
24
  },
25
25
  {
26
26
  "name": "anthropic",
27
27
  "source": "npm",
28
28
  "npm": "@capybara-hq/plugin-anthropic",
29
- "version": "0.1.0-rc.13",
30
- "integrity": "sha512-9r5EWfkJl6y+MqGTk8dkX4Lz8KuJMrx7Q7o+CQUqaGkhLYZW6ZvvmXjnlpexJdSV0bomUeBpRo1nPSy54lvsNQ==",
29
+ "version": "0.1.0-rc.14",
30
+ "integrity": "sha512-Ygtv1sWffIBX2Vd6q7T71DHkwhAMDPwKEr4TUjp7cZxyUtG2oZvrlRIVxcfRVaF/OSpGrUrf47v8DLWNOwCaxQ==",
31
31
  "required": false
32
32
  },
33
33
  {
34
34
  "name": "openai",
35
35
  "source": "npm",
36
36
  "npm": "@capybara-hq/plugin-openai",
37
- "version": "0.1.0-rc.16",
38
- "integrity": "sha512-QG87aBbF+de82lTAO2H+opusoWhCZYQWU9RljYpsL766v/AivdVW2gZhLhdine60C6dNCEP7zPzeECUxHtmEGA==",
37
+ "version": "0.1.0-rc.17",
38
+ "integrity": "sha512-e5AXAERCCXP4EGLmUwtVH8KmTbTi7W+baaSz3RHY3sMmJEtGQaHcyg9BjjRCDi1/Ic6G8OURhs+SUcgHs/m13Q==",
39
39
  "required": false
40
40
  },
41
41
  {
42
42
  "name": "deepseek",
43
43
  "source": "npm",
44
44
  "npm": "@capybara-hq/plugin-deepseek",
45
- "version": "0.1.0-rc.15",
46
- "integrity": "sha512-96WxB2yo6ohakBtGH1l6unG86e3gR/8T40WNzqcN0P/tyytTkBLFu2+fLDFuHKM2SMViP3HWAwoqFSUE6yDDPQ==",
45
+ "version": "0.1.0-rc.16",
46
+ "integrity": "sha512-WDNjY/MyKp1A2Lf2TfuAucD/GdtP2FNGZRe3yQmBDXn8SMqJ7Plr876P6gL1j667rhbgGGz8w/uUBXcr+smiLg==",
47
47
  "required": false
48
48
  },
49
49
  {
50
50
  "name": "bailian",
51
51
  "source": "npm",
52
52
  "npm": "@capybara-hq/plugin-bailian",
53
- "version": "0.1.0-rc.16",
54
- "integrity": "sha512-rrDYU4ryQvFtb9XTpf5vDJ8EtGR+wtOqp3w8U+U/I4HL+LNSV8ckwtwNHC4bxhqhq3joi2KIdJQswUYkSJYLhA==",
53
+ "version": "0.1.0-rc.17",
54
+ "integrity": "sha512-76rHTjx6ri9+eWpsLDQhAK8V06+FfUdFWrSc1Br/vCF4NQ3HQlvmqwzalJxUiPtTz4UnyBmHf7UC/0N2lnmahw==",
55
55
  "required": false
56
56
  },
57
57
  {
58
58
  "name": "ark",
59
59
  "source": "npm",
60
60
  "npm": "@capybara-hq/plugin-ark",
61
- "version": "0.1.0-rc.16",
62
- "integrity": "sha512-ezWTJn2FJdsbBuWfpuoEbcxnTFlZxIQRA70nKkqf9cCeSXnZCwij2lc+6Og1qeUfSmYnFHcrXicp8RV2mmXjPw==",
61
+ "version": "0.1.0-rc.17",
62
+ "integrity": "sha512-VL6Tphbffn/6jSZaOq2m9W6Z5qglqs7qYCxrNrDRW4JeLFaQtHz6ykIqxJUvGfRQkkSsDX6VO8Gwnpj7B/kKIg==",
63
63
  "required": false
64
64
  },
65
65
  {
66
66
  "name": "connector-mcp",
67
67
  "source": "npm",
68
68
  "npm": "@capybara-hq/plugin-connector-mcp",
69
- "version": "0.1.0-rc.14",
70
- "integrity": "sha512-/dzF1Pw6V2r4lsU1pCmAlAxjVWoX2LSlJ/zVj7nwM8yje90n9+/b17UX9ZSNVXQHs/h/6FH2uearnzM0iYDYxg==",
69
+ "version": "0.1.0-rc.15",
70
+ "integrity": "sha512-BuSf3Igah93ZXWe30dx7nueuwWCPHZtgDtvtZ5EZ877+s4FfnPAufdaPqygzT2aAtD0P1mhy62+cDx67TzPNOg==",
71
71
  "required": false
72
72
  },
73
73
  {
74
74
  "name": "connector-openapi",
75
75
  "source": "npm",
76
76
  "npm": "@capybara-hq/plugin-connector-openapi",
77
- "version": "0.1.0-rc.14",
78
- "integrity": "sha512-Zt881ix9pgLQcyYl9r9HMRWld0pq2o4qi/k9L19ZmIWkDlaYavz6SZ5gocD8jYvzZPKMdA1RXu0Y/HWdYJXpXQ==",
77
+ "version": "0.1.0-rc.15",
78
+ "integrity": "sha512-PiuBDlCHtIIqlapdw5LRRhxIwgPqrsZEZuxvXg9rsBoN1Qygkh0OX2SNv2nx6wJQZ8eXnLXFFysWNaIPslFNUg==",
79
79
  "required": false
80
80
  },
81
81
  {
82
82
  "name": "jina",
83
83
  "source": "npm",
84
84
  "npm": "@capybara-hq/plugin-jina",
85
- "version": "0.1.0-rc.11",
86
- "integrity": "sha512-zmGyRObcS4aEOI1SZoHqMFbeBKvgNNVoYKYk+h69hMheYIiChe+oIXVedysxsXZisucpwzoDPRQ/un0gHIn2XA==",
85
+ "version": "0.1.0-rc.12",
86
+ "integrity": "sha512-LYE+UdX/m2YunIVxzbqj8qpHyOOjDBlaF96WbLPBuDcfNwwtHSHFCwzrjHzJhcZPKn9VF9JCdLrYWRQS4nehqQ==",
87
87
  "required": false
88
88
  },
89
89
  {
90
90
  "name": "device-docker",
91
91
  "source": "npm",
92
92
  "npm": "@capybara-hq/plugin-device-docker",
93
- "version": "0.1.0-rc.36",
94
- "integrity": "sha512-29vne4OcJDkOG0lq4AHEivdgFiAM7v+OnWhShDkLDfI0laet1jYRAglut+OqskoerOyi+gVTFGsBtid/dEuetg==",
93
+ "version": "0.1.0-rc.37",
94
+ "integrity": "sha512-eQbKWWB391h02S8ViOl9SIzHTRjEYGun7LTP/IkMWrkytwr8YR6jFEqUUTB+oYW0a4nBxjWm42gh2UJ0H+6WHw==",
95
95
  "required": false
96
96
  },
97
97
  {
98
98
  "name": "device-local",
99
99
  "source": "npm",
100
100
  "npm": "@capybara-hq/plugin-device-local",
101
- "version": "0.1.0-rc.20",
102
- "integrity": "sha512-oMR3xqkG2x+eX2XCSHmdO6yMHRQxD4oqFVZzGc56vvaUcESPl0Sz9JleMRl+RSa3EQQWcqSgtaP2z6TUcJfKzw==",
101
+ "version": "0.1.0-rc.21",
102
+ "integrity": "sha512-LPwym68E61ZUdgDziwXIpfPO9pXz9tD5aUdMZdoZF6sqea6uDrijz7djo1oCZ+yrGAZhzLBXDqEHJCT8kdRkqw==",
103
103
  "required": false,
104
104
  "scope": "all"
105
105
  },
@@ -107,16 +107,16 @@
107
107
  "name": "todo",
108
108
  "source": "npm",
109
109
  "npm": "@capybara-hq/plugin-todo",
110
- "version": "0.1.0-rc.17",
111
- "integrity": "sha512-LsvKWz3LD+XJNqiXj0RgG6JGT3mPI5ZF2VYuWE93ns0usKzkbiJZ9JlYF4sHsNzHfVhwqCi8uhfY/EOe6vA8gQ==",
110
+ "version": "0.1.0-rc.18",
111
+ "integrity": "sha512-KpIBNLiQAOM8/rRpdVwbUKMVpPwT2MZ1ygjWqTqShtD2xSKEyTJ9yo1buSADPrWTeQfqDx/YRu5+sQ/QYm5cOA==",
112
112
  "required": false
113
113
  },
114
114
  {
115
115
  "name": "skills-core",
116
116
  "source": "npm",
117
117
  "npm": "@capybara-hq/plugin-skills-core",
118
- "version": "0.1.0-rc.3",
119
- "integrity": "sha512-z4vqSFBZnh/Fh0/xHZ55Fw17cjb56i+Yfi8c5pmF5v4BTRCtEPp4416uyvisbLKBZ6oGjNMxI01UBddDXNntrg==",
118
+ "version": "0.1.0-rc.4",
119
+ "integrity": "sha512-uF/tvRQH2eje98tRj15xOkbEWMGT6MVkEXgdrlWNNtH9+/kFE27HtmHRLb9m5bwWFonlXOtxvN9sP2DBE2gGWA==",
120
120
  "required": false,
121
121
  "builtin": true
122
122
  },
@@ -124,8 +124,8 @@
124
124
  "name": "file-preview",
125
125
  "source": "npm",
126
126
  "npm": "@capybara-hq/plugin-file-preview",
127
- "version": "0.1.0-rc.6",
128
- "integrity": "sha512-CNaziqin6RbmFGNesCoBTFcCLhko6DZBmUXsh6XcAoIE7cQvQBzjO8U4SsbGwBaLCQqKiaNrCxowAi3p/2zJVA==",
127
+ "version": "0.1.0-rc.7",
128
+ "integrity": "sha512-0xIyrYnFtw04gVyqw+HxgKoDvsAVqoy+u2C3Wn6+adhCs+58q8miqMB1AGFxV6b9DSUuQT6nqzhWsBH5lLLgkA==",
129
129
  "required": false,
130
130
  "builtin": true
131
131
  }
@@ -4,14 +4,14 @@ import { ExtensionAdmin } from "../extensions/admin-view.js";
4
4
  import { type DeploymentConfigView, ExtensionDeploymentConfigService } from "../extensions/deployment-config.js";
5
5
  import { ExtensionInstalls, type PackageReview } from "../extensions/installs.js";
6
6
  import { type OrgOverrideSummary, OrgOverrides } from "../extensions/org-overrides.js";
7
- import type { AdminExtensionView } from "../extensions/permission-view.js";
7
+ import type { AdminExtensionView, ExtensionOrgCounts } from "../extensions/permission-view.js";
8
8
  import { PluginGuides, type RenderedSetupGuide } from "../extensions/plugin-guides.js";
9
9
  import { type Principal } from "../identity/principal.js";
10
10
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
11
11
  import type { SetupCheckState } from "../setup/setup-check-registry.js";
12
12
  import { DeploymentCheckPathParams, DeploymentCheckRunBody, DeploymentGuidePathParams, DeploymentGuidesPathParams, DeploymentGuidesQuery } from "../setup/setup-checks.schemas.js";
13
13
  import { SetupChecksService } from "../setup/setup-checks.service.js";
14
- import { AdminExtensionConfigBody } from "./extensions.schemas.js";
14
+ import { AdminExtensionConfigBody, AdminExtensionOrgCountsQuery } from "./extensions.schemas.js";
15
15
  declare const ApproveSchema: z.ZodObject<{
16
16
  sha256: z.ZodNullable<z.ZodString>;
17
17
  reviewHash: z.ZodString;
@@ -52,6 +52,9 @@ export declare class AdminExtensionsController {
52
52
  extensions: AdminExtensionView[];
53
53
  drainSeconds: number;
54
54
  }>;
55
+ counts(query: z.infer<typeof AdminExtensionOrgCountsQuery>): Promise<{
56
+ counts: ExtensionOrgCounts[];
57
+ }>;
55
58
  /** A single extension; unknown -> 404 `extension.not_found`. */
56
59
  get(name: string): Promise<AdminExtensionView>;
57
60
  /**
@@ -23,7 +23,7 @@ import { createZodDto } from "../infra/validation/create-zod-dto.js";
23
23
  import { ZBody, ZParam, ZQuery } from "../infra/validation/zod-params.js";
24
24
  import { DeploymentCheckPathParams, DeploymentCheckRunBody, DeploymentGuidePathParams, DeploymentGuidesPathParams, DeploymentGuidesQuery, } from "../setup/setup-checks.schemas.js";
25
25
  import { SetupChecksService } from "../setup/setup-checks.service.js";
26
- import { AdminExtensionConfigBody } from "./extensions.schemas.js";
26
+ import { AdminExtensionConfigBody, AdminExtensionOrgCountsQuery } from "./extensions.schemas.js";
27
27
  const ApproveSchema = z.object({
28
28
  /** 安装记录的包(审阅时的 sha256);配置声明的插件为 null。 */
29
29
  sha256: z
@@ -46,6 +46,8 @@ class ExtensionInstallBody extends createZodDto(InstallSchema, "ExtensionInstall
46
46
  }
47
47
  class ExtensionConfigBody extends createZodDto(AdminExtensionConfigBody, "ExtensionConfigBody") {
48
48
  }
49
+ class ExtensionOrgCountsQuery extends createZodDto(AdminExtensionOrgCountsQuery, "ExtensionOrgCountsQuery") {
50
+ }
49
51
  class ExtensionNpmImportBody extends createZodDto(NpmSchema, "ExtensionNpmImportBody") {
50
52
  }
51
53
  /** The `:name` route parameter of the org-overrides list (decision R20). */
@@ -100,6 +102,9 @@ let AdminExtensionsController = class AdminExtensionsController {
100
102
  drainSeconds: this.kernelConfig.get().extensionHost.drainSeconds,
101
103
  };
102
104
  }
105
+ async counts(query) {
106
+ return { counts: await this.admin.orgCounts(query.names.split(",")) };
107
+ }
103
108
  /** A single extension; unknown -> 404 `extension.not_found`. */
104
109
  get(name) {
105
110
  return this.admin.get(name);
@@ -244,6 +249,10 @@ let AdminExtensionsController = class AdminExtensionsController {
244
249
  __decorate([
245
250
  Get()
246
251
  ], AdminExtensionsController.prototype, "list", null);
252
+ __decorate([
253
+ Get("counts/orgs"),
254
+ __param(0, ZQuery(ExtensionOrgCountsQuery))
255
+ ], AdminExtensionsController.prototype, "counts", null);
247
256
  __decorate([
248
257
  Get(":name"),
249
258
  __param(0, Param("name"))
@@ -25,4 +25,8 @@ export declare const AdminExtensionConfigBody: z.ZodObject<{
25
25
  renameFrom: z.ZodOptional<z.ZodString>;
26
26
  }, z.core.$strict>>>;
27
27
  }, z.core.$strip>;
28
+ export declare const EXTENSION_ORG_COUNT_PAGE_SIZE = 20;
29
+ export declare const AdminExtensionOrgCountsQuery: z.ZodObject<{
30
+ names: z.ZodString;
31
+ }, z.core.$strict>;
28
32
  export declare const ADMIN_EXTENSION_ROUTES: readonly RouteSchemas[];
@@ -31,10 +31,19 @@ export const AdminExtensionConfigBody = z.object({
31
31
  /** Single keys of hinted secret records (extension config forms spec §4.3), applied in order. */
32
32
  secretEntries: z.array(AdminExtensionSecretEntry).max(200).optional(),
33
33
  });
34
+ export const EXTENSION_ORG_COUNT_PAGE_SIZE = 20;
35
+ export const AdminExtensionOrgCountsQuery = z
36
+ .object({
37
+ names: z
38
+ .string()
39
+ .regex(/^[a-z0-9][a-z0-9_-]{0,63}(,[a-z0-9][a-z0-9_-]{0,63}){0,19}$/, "Pass one to 20 comma-separated extension names"),
40
+ })
41
+ .strict();
34
42
  export const ADMIN_EXTENSION_ROUTES = [
35
43
  // the extension package is the raw body (no schema)
36
44
  { route: "POST /api/v1/admin/extensions/packages/file" },
37
45
  { route: "GET /api/v1/admin/extensions" },
46
+ { route: "GET /api/v1/admin/extensions/counts/orgs", query: AdminExtensionOrgCountsQuery },
38
47
  { route: "GET /api/v1/admin/extensions/:name", params: AdminExtensionNamePathParams },
39
48
  { route: "POST /api/v1/admin/extensions/:name/enable", params: AdminExtensionNamePathParams },
40
49
  { route: "POST /api/v1/admin/extensions/:name/disable", params: AdminExtensionNamePathParams },
@@ -5,7 +5,7 @@ import { type LiveReplica, ReplicaPresence } from "../infra/presence/replica-pre
5
5
  import type { KernelLogger } from "../log.js";
6
6
  import { DeviceProviders } from "../sandbox/providers.js";
7
7
  /** The kernel's own queues, in the order the overview lists them (extension queues are not read). */
8
- export declare const KERNEL_QUEUE_NAMES: readonly ["cap-kernel-runs", "cap-kernel-subagent-runs", "cap-kernel-channels", "cap-kernel-maintenance", "cap-kernel-tool-watch", "cap-kernel-plugin-scope", "cap-kernel-titles", "cap-kernel-suggestions", "cap-kernel-usage-report", "cap-kernel-evals", "cap-kernel-lifecycle", "cap-push-deliver", "cap-connector-tools", "cap-template-connectors", "cap-device-service-events", "cap-external-calls"];
8
+ export declare const KERNEL_QUEUE_NAMES: readonly ["cap-kernel-runs", "cap-kernel-subagent-runs", "cap-kernel-channels", "cap-kernel-maintenance", "cap-kernel-tool-watch", "cap-kernel-plugin-effects", "cap-kernel-titles", "cap-kernel-suggestions", "cap-kernel-usage-report", "cap-kernel-evals", "cap-kernel-lifecycle", "cap-push-deliver", "cap-connector-tools", "cap-template-connectors", "cap-device-service-events", "cap-external-calls"];
9
9
  /** How long each source's reads may take before the answer marks it unavailable. */
10
10
  export declare const HEALTH_READ_TIMEOUT_MS = 3000;
11
11
  /** A live replica as the overview shows it. */
@@ -10,7 +10,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
10
10
  import { getQueueToken } from "@nestjs/bullmq";
11
11
  import { Inject, Injectable } from "@nestjs/common";
12
12
  import { sql } from "kysely";
13
- import { PLUGIN_SCOPE_QUEUE } from "../catalog/scope-sync.js";
13
+ import { PLUGIN_EFFECT_QUEUE } from "../catalog/scope-sync.js";
14
14
  import { TEMPLATE_CONNECTORS_QUEUE } from "../catalog/template-connector-jobs.js";
15
15
  import { CHANNEL_QUEUE_NAME } from "../channels/jobs.js";
16
16
  import { EXTERNAL_CALLS_QUEUE } from "../conversations/external/external-calls.js";
@@ -38,7 +38,7 @@ export const KERNEL_QUEUE_NAMES = [
38
38
  CHANNEL_QUEUE_NAME,
39
39
  MAINTENANCE_QUEUE_NAME,
40
40
  TOOL_WATCH_QUEUE,
41
- PLUGIN_SCOPE_QUEUE,
41
+ PLUGIN_EFFECT_QUEUE,
42
42
  TITLE_QUEUE,
43
43
  PROMPT_SUGGESTION_QUEUE,
44
44
  USAGE_REPORT_QUEUE,
@@ -305,7 +305,7 @@ AdminHealthService = __decorate([
305
305
  __param(7, Inject(getQueueToken(CHANNEL_QUEUE_NAME))),
306
306
  __param(8, Inject(getQueueToken(MAINTENANCE_QUEUE_NAME))),
307
307
  __param(9, Inject(getQueueToken(TOOL_WATCH_QUEUE))),
308
- __param(10, Inject(getQueueToken(PLUGIN_SCOPE_QUEUE))),
308
+ __param(10, Inject(getQueueToken(PLUGIN_EFFECT_QUEUE))),
309
309
  __param(11, Inject(getQueueToken(TITLE_QUEUE))),
310
310
  __param(12, Inject(getQueueToken(PROMPT_SUGGESTION_QUEUE))),
311
311
  __param(13, Inject(getQueueToken(USAGE_REPORT_QUEUE))),
@@ -36,11 +36,9 @@ export interface OrgCatalogItem extends Omit<CatalogItemView, "installs" | "mark
36
36
  switchable: boolean;
37
37
  /** The plugin's extension (or a template's connector extension) is not on the deployment. */
38
38
  notDeployed: boolean;
39
- /**
40
- * This org's live plugin install of the item (installing or installed);
41
- * `upgradeAvailable` is always null since plugin scope phase 2 (no per-org upgrade, ruling F2;
42
- * kept for the web until its upgrade dialog goes).
43
- */
39
+ /** Pending work or the latest failed effect, independent of whether the plugin can be used. */
40
+ setup?: "pending" | "install_failed";
41
+ /** The version of this plugin's applied org resources, when it owns any. */
44
42
  installed: {
45
43
  pluginInstallId: string;
46
44
  version: string;
@@ -192,10 +190,10 @@ export interface OrgInstallResult {
192
190
  installed: {
193
191
  itemId: string;
194
192
  version: string;
195
- pluginInstallId: string;
193
+ pluginInstallId: string | null;
196
194
  };
197
195
  /** The install view (its components, dependency installs included). */
198
- install: PluginInstallView;
196
+ install: PluginInstallView | null;
199
197
  }
200
198
  /**
201
199
  * The org actions installing / uninstalling a plugin needs: the union over its components (an
@@ -458,7 +458,7 @@ export async function countInstalls(db, itemIds) {
458
458
  .innerJoin("orgs as org", "org.id", "install.org_id")
459
459
  .select(["install.item_id", (eb) => eb.fn.count("install.org_id").distinct().as("n")])
460
460
  .where("install.item_id", "in", itemIds)
461
- .where("install.status", "=", "installed")
461
+ .where("install.version", "is not", null)
462
462
  .where("org.deleted_at", "is", null)
463
463
  .groupBy("install.item_id")
464
464
  .execute();
@@ -24,7 +24,6 @@ import { CatalogService } from "./catalog.service.js";
24
24
  import { assertOrgsExist } from "./catalog-items.js";
25
25
  import { nameConflictError } from "./component-scope.service.js";
26
26
  import { agentsUsing, COMPONENT_KINDS, componentOffered, componentOn, listedIn, loadComponents, loadScopeState, pluginFactsOf, skillNameClashes, switchOf, themeIdClashes, } from "./component-state.js";
27
- import { LIVE_INSTALL_STATUSES } from "./install-status.js";
28
27
  import { orgUsable } from "./org-intent.js";
29
28
  import { assertOwnerListed, assertShareable, assertShareableTarget, newlySharedWith, } from "./ownership.js";
30
29
  import { PluginImport } from "./plugin-import.js";
@@ -287,7 +286,7 @@ let CatalogScopeService = class CatalogScopeService {
287
286
  ...opts.auditDetail,
288
287
  },
289
288
  });
290
- await this.enqueue(itemId);
289
+ await this.enqueue(itemId, from);
291
290
  },
292
291
  };
293
292
  });
@@ -370,6 +369,7 @@ let CatalogScopeService = class CatalogScopeService {
370
369
  }
371
370
  if (narrowed)
372
371
  await this.enqueue(itemId);
372
+ this.scopeWriter.refreshIsolatedOrgIntent();
373
373
  }
374
374
  /**
375
375
  * Adds one org to a `named` item's list in the caller's transaction (an approved `access`
@@ -392,8 +392,8 @@ let CatalogScopeService = class CatalogScopeService {
392
392
  await this.enqueue(itemId);
393
393
  }
394
394
  /** Owes the item's scope sync in the transaction that changes its scope (outbox spec §8.1). */
395
- async enqueue(itemId) {
396
- await this.sync.enqueueItem(itemId);
395
+ async enqueue(itemId, previousOrgs = []) {
396
+ await this.sync.enqueueItem(itemId, previousOrgs);
397
397
  }
398
398
  /**
399
399
  * 409 `theme.platform_default` when a live theme of the item is the platform default and `after`
@@ -484,7 +484,7 @@ let CatalogScopeService = class CatalogScopeService {
484
484
  .selectFrom("plugin_installs")
485
485
  .select(["id", "org_id"])
486
486
  .where("item_id", "=", item.id)
487
- .where("status", "in", [...LIVE_INSTALL_STATUSES])
487
+ .where("version", "is not", null)
488
488
  .execute();
489
489
  const live = new Map(installs.map((install) => [install.org_id, install.id]));
490
490
  const affected = [];
@@ -17,6 +17,7 @@ import { ToolsModule } from "../tools/tools.module.js";
17
17
  import { CatalogImportModule } from "./catalog-import.module.js";
18
18
  import { CatalogScopeService } from "./catalog-scope.service.js";
19
19
  import { ComponentScopeService } from "./component-scope.service.js";
20
+ import { PLUGIN_EFFECT_QUEUE } from "./effect-work.js";
20
21
  import { OrgCatalogService } from "./org-catalog.service.js";
21
22
  import { OrgPluginUploads } from "./org-plugin-uploads.js";
22
23
  import { OwnedItems } from "./owned-items.js";
@@ -24,13 +25,13 @@ import { PlatformImportUpdate } from "./platform-import-update.js";
24
25
  import { PluginInstaller } from "./plugin-install.js";
25
26
  import { PlatformPluginUpdater } from "./plugin-upgrade.js";
26
27
  import { CatalogRequestsService } from "./requests.service.js";
27
- import { PLUGIN_SCOPE_QUEUE, PluginScopeSync } from "./scope-sync.js";
28
+ import { PluginScopeSync } from "./scope-sync.js";
28
29
  import { ScopeWriter } from "./scope-writer.js";
29
30
  import { TemplateConnectorEnsurer } from "./template-connector-ensure.js";
30
31
  import { TemplateConnectorsQueueModule } from "./template-connector-jobs.js";
31
32
  export { CatalogImportModule };
32
33
  /** The plugin scope sync's queue registration (re-exported: the admin health reads its counts). */
33
- const PLUGIN_SCOPE_QUEUE_MODULE = QueueModule.registerQueue(PLUGIN_SCOPE_QUEUE);
34
+ const PLUGIN_EFFECT_QUEUE_MODULE = QueueModule.registerQueue(PLUGIN_EFFECT_QUEUE);
34
35
  /** This module's maintenance queue registration (re-exported for the admin health). */
35
36
  const MAINTENANCE_QUEUE_MODULE = QueueModule.registerQueue(MAINTENANCE_QUEUE_NAME);
36
37
  /**
@@ -57,7 +58,7 @@ CatalogModule = __decorate([
57
58
  ToolsModule,
58
59
  // the plugin scope sync's queue: the outbox dispatcher adds the owed jobs through it
59
60
  // (`PluginScopeWorkersModule` consumes it)
60
- PLUGIN_SCOPE_QUEUE_MODULE,
61
+ PLUGIN_EFFECT_QUEUE_MODULE,
61
62
  // the queue of a removed org plugin's owed cleanup job (`OwnedItems`, `CatalogScopeService`;
62
63
  // consumed by the worker role's `MaintenanceProcessor`)
63
64
  MAINTENANCE_QUEUE_MODULE,
@@ -80,7 +81,7 @@ CatalogModule = __decorate([
80
81
  TemplateConnectorEnsurer,
81
82
  ],
82
83
  exports: [
83
- PLUGIN_SCOPE_QUEUE_MODULE,
84
+ PLUGIN_EFFECT_QUEUE_MODULE,
84
85
  TemplateConnectorsQueueModule,
85
86
  MAINTENANCE_QUEUE_MODULE,
86
87
  CatalogImportModule,
@@ -7,6 +7,9 @@ import { SuperAdminLock } from "../identity/super-admin.js";
7
7
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
8
8
  import { KernelDb } from "../infra/database/kernel-db.js";
9
9
  import { TransactionHost } from "../infra/database/transaction-host.js";
10
+ import { XactLock } from "../infra/database/xact-lock.js";
11
+ import { KernelEvents } from "../infra/events/kernel-events.js";
12
+ import { OutboxService } from "../infra/outbox/outbox.service.js";
10
13
  import { OrgLock } from "../orgs/org-lock.js";
11
14
  import type { OfficialPublisherProof } from "../packages/official-publisher.js";
12
15
  import type { TranslationReport } from "./claude/report.js";
@@ -257,6 +260,9 @@ export declare class CatalogService {
257
260
  /** The orgs whose connectors a delete switches off, locked before the item (ruling P3-50). */
258
261
  private readonly orgLock;
259
262
  readonly txHost: TransactionHost;
263
+ private readonly xactLock;
264
+ private readonly outbox;
265
+ private readonly events;
260
266
  constructor(kdb: KernelDb,
261
267
  /** The super admin lock (identity/super-admin.ts): joins the caller's transaction. */
262
268
  adminLock: SuperAdminLock, config: KernelConfigService, installs: ExtensionInstalls,
@@ -269,7 +275,7 @@ export declare class CatalogService {
269
275
  /** Serializes a claim release with an install of that name still committing (F10). */
270
276
  installLock: PluginInstallLock,
271
277
  /** The orgs whose connectors a delete switches off, locked before the item (ruling P3-50). */
272
- orgLock: OrgLock, txHost: TransactionHost);
278
+ orgLock: OrgLock, txHost: TransactionHost, xactLock: XactLock, outbox: OutboxService, events: KernelEvents);
273
279
  /** The kernel-schema handle of the current context (the transaction, else the pool). */
274
280
  private get db();
275
281
  /** Downloads a marketplace archive source, verified against its integrity. */
@@ -19,14 +19,19 @@ import { captureSourceIntent, restoreSourceIntent } from "../extensions/source-i
19
19
  import { audit } from "../identity/audit.js";
20
20
  import { SuperAdminLock } from "../identity/super-admin.js";
21
21
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
22
+ import { afterCommit } from "../infra/database/after-commit.js";
22
23
  import { KernelDb } from "../infra/database/kernel-db.js";
23
24
  import { TransactionHost } from "../infra/database/transaction-host.js";
24
25
  import { Transactional } from "../infra/database/transactional.decorator.js";
26
+ import { XactLock } from "../infra/database/xact-lock.js";
27
+ import { KernelEvents } from "../infra/events/kernel-events.js";
28
+ import { OutboxService } from "../infra/outbox/outbox.service.js";
25
29
  import { OrgLock } from "../orgs/org-lock.js";
26
30
  import { sameRepository } from "../packages/provenance.js";
27
31
  import { assertNotPlatformDefault } from "../themes/theme-usage.js";
28
32
  import { countInstalls, inAuthorOrder, itemConfirmations, itemScopeFacts, itemView, marketplaceLatest, versionUsable, } from "./catalog-items.js";
29
33
  import { retireCatalogDependencyEdges } from "./dependency-edges.js";
34
+ import { EFFECT_CANDIDATES_LOCK, oweEffectWork } from "./effect-work.js";
30
35
  import { expandGitUrl, GitSourceError, gitErrorDetails, normalGitPath, readGitTreeAndOids, resolveGitCommit, } from "./git-source.js";
31
36
  import { fetchMarketplaceArchive, marketplaceNetPolicy, marketplaceUrlProblem, requireMarketplacePublisher, } from "./marketplace-fetch.js";
32
37
  import { assertEntryNotDeprecated, entryCompatible, entrySourceHost, HOST_VERSIONS, hostAllowed, loadMarketplaceEntry, MarketplacesService, pluginNameFrom, } from "./marketplaces.service.js";
@@ -106,6 +111,9 @@ let CatalogService = class CatalogService {
106
111
  installLock;
107
112
  orgLock;
108
113
  txHost;
114
+ xactLock;
115
+ outbox;
116
+ events;
109
117
  constructor(kdb,
110
118
  /** The super admin lock (identity/super-admin.ts): joins the caller's transaction. */
111
119
  adminLock, config, installs,
@@ -118,7 +126,7 @@ let CatalogService = class CatalogService {
118
126
  /** Serializes a claim release with an install of that name still committing (F10). */
119
127
  installLock,
120
128
  /** The orgs whose connectors a delete switches off, locked before the item (ruling P3-50). */
121
- orgLock, txHost) {
129
+ orgLock, txHost, xactLock, outbox, events) {
122
130
  this.kdb = kdb;
123
131
  this.adminLock = adminLock;
124
132
  this.config = config;
@@ -129,6 +137,9 @@ let CatalogService = class CatalogService {
129
137
  this.installLock = installLock;
130
138
  this.orgLock = orgLock;
131
139
  this.txHost = txHost;
140
+ this.xactLock = xactLock;
141
+ this.outbox = outbox;
142
+ this.events = events;
132
143
  }
133
144
  /** The kernel-schema handle of the current context (the transaction, else the pool). */
134
145
  get db() {
@@ -526,6 +537,7 @@ let CatalogService = class CatalogService {
526
537
  await this.assertExtensionDisabled(this.kdb.db, itemId);
527
538
  }
528
539
  async writeRemove(actor, itemId, opts) {
540
+ await this.xactLock.lock(EFFECT_CANDIDATES_LOCK);
529
541
  await this.adminLock.lockAndAuthorize(actor);
530
542
  // The orgs whose connectors the delete switches off, sorted, before the item (the global lock
531
543
  // order, ruling P3-50, as the platform plugin update takes them)
@@ -673,7 +685,9 @@ let CatalogService = class CatalogService {
673
685
  for (const [plugin, before] of sourceIntent) {
674
686
  await restoreSourceIntent(t, plugin, before, actor);
675
687
  }
688
+ await oweEffectWork(this.outbox, t, { itemIds: [itemId] });
676
689
  await retireCatalogDependencyEdges(t, itemId);
690
+ afterCommit(() => this.events.emit("catalog.org-intent-changed", {}));
677
691
  return { name: row.name };
678
692
  }
679
693
  };
@@ -694,6 +708,9 @@ CatalogService = __decorate([
694
708
  __param(6, Inject(MarketplacesService)),
695
709
  __param(7, Inject(PluginInstallLock)),
696
710
  __param(8, Inject(OrgLock)),
697
- __param(9, Inject(TransactionHost))
711
+ __param(9, Inject(TransactionHost)),
712
+ __param(10, Inject(XactLock)),
713
+ __param(11, Inject(OutboxService)),
714
+ __param(12, Inject(KernelEvents))
698
715
  ], CatalogService);
699
716
  export { CatalogService };
@@ -0,0 +1,27 @@
1
+ import type { KernelSchemaDb } from "../db/kernel-schema.js";
2
+ import type { OutboxService } from "../infra/outbox/outbox.service.js";
3
+ export declare const PLUGIN_EFFECT_QUEUE = "cap-kernel-plugin-effects";
4
+ export declare const PLUGIN_EFFECT_JOB = "plugin-effect";
5
+ export declare const EFFECT_CANDIDATES_LOCK = "capybara.plugin-effect-candidates";
6
+ export type EffectJob = {
7
+ kind: "chunk";
8
+ itemId: string;
9
+ orgIds: [string];
10
+ };
11
+ type Outbox = Pick<OutboxService, "addMany">;
12
+ export declare function effectGeneration(jobId: string, { itemId, orgIds }: EffectJob): string;
13
+ type EffectMutation = {
14
+ itemIds: readonly string[];
15
+ previousOrgs?: readonly string[];
16
+ orgId?: string;
17
+ includeDependents?: boolean;
18
+ } | {
19
+ orgId: string;
20
+ };
21
+ /** Selects sparse intent or ownership first. Only an all-scope root needs the org census. */
22
+ export declare function oweEffectWork(outbox: Outbox, db: KernelSchemaDb, mutation: EffectMutation): Promise<void>;
23
+ /** Re-owes the same generation if a worker did not settle it. */
24
+ export declare function recoverEffectWork(outbox: Outbox, db: KernelSchemaDb): Promise<void>;
25
+ /** Resolve a deployed extension's live catalog item before owing its affected pairs. */
26
+ export declare function oweDeployedExtensionSync(outbox: Outbox, db: KernelSchemaDb, extensionName: string): Promise<void>;
27
+ export {};