@capybara-hq/kernel 0.1.0-rc.140 → 0.1.0-rc.142

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 (82) hide show
  1. package/dist/agents/models.controller.d.ts +9 -2
  2. package/dist/agents/models.controller.js +35 -4
  3. package/dist/catalog/catalog-scope.service.js +3 -0
  4. package/dist/catalog/catalog.module.js +8 -0
  5. package/dist/catalog/catalog.service.d.ts +2 -2
  6. package/dist/catalog/catalog.service.js +3 -3
  7. package/dist/catalog/component-scope.controller.d.ts +2 -1
  8. package/dist/catalog/component-scope.controller.js +5 -2
  9. package/dist/catalog/component-scope.service.d.ts +16 -0
  10. package/dist/catalog/component-scope.service.js +21 -1
  11. package/dist/catalog/enable-decision.d.ts +34 -0
  12. package/dist/catalog/enable-decision.js +17 -0
  13. package/dist/catalog/enable-requests.d.ts +186 -0
  14. package/dist/catalog/enable-requests.js +767 -0
  15. package/dist/catalog/enable-targets.d.ts +63 -0
  16. package/dist/catalog/enable-targets.js +94 -0
  17. package/dist/catalog/org-catalog.controller.d.ts +11 -3
  18. package/dist/catalog/org-catalog.controller.js +28 -5
  19. package/dist/catalog/org-catalog.schemas.d.ts +38 -0
  20. package/dist/catalog/org-catalog.schemas.js +31 -0
  21. package/dist/catalog/org-catalog.service.js +1 -1
  22. package/dist/catalog/org-extension.controller.d.ts +1 -1
  23. package/dist/catalog/owned-items.js +6 -1
  24. package/dist/catalog/plugin-install.js +7 -2
  25. package/dist/catalog/plugin-upgrade.js +3 -0
  26. package/dist/catalog/request-rules.d.ts +7 -5
  27. package/dist/catalog/request-rules.js +53 -14
  28. package/dist/catalog/requests.service.d.ts +137 -4
  29. package/dist/catalog/requests.service.js +574 -28
  30. package/dist/catalog/scope-writer.d.ts +20 -3
  31. package/dist/catalog/scope-writer.js +32 -3
  32. package/dist/config/schema.d.ts +1 -0
  33. package/dist/config/schema.js +10 -0
  34. package/dist/ctx/bus.js +3 -2
  35. package/dist/db/kernel-schema.d.ts +3 -2
  36. package/dist/errors.d.ts +7 -0
  37. package/dist/errors.js +7 -0
  38. package/dist/extensions/admin-ops.js +2 -0
  39. package/dist/extensions/admin-view.js +2 -1
  40. package/dist/extensions/host.js +1 -1
  41. package/dist/extensions/org-config.d.ts +8 -0
  42. package/dist/extensions/org-config.js +20 -5
  43. package/dist/extensions/permission-view.d.ts +7 -0
  44. package/dist/extensions/plugin-guides.d.ts +1 -1
  45. package/dist/extensions/plugin-guides.js +1 -1
  46. package/dist/extensions/plugin-items.d.ts +8 -0
  47. package/dist/extensions/plugin-items.js +8 -0
  48. package/dist/http/api.module.js +6 -0
  49. package/dist/infra/config/kernel-config.service.js +2 -0
  50. package/dist/infra/queue/run-job.js +3 -1
  51. package/dist/invalidation/hints.d.ts +56 -0
  52. package/dist/invalidation/hints.js +67 -0
  53. package/dist/invalidation/invalidation-hints.d.ts +24 -0
  54. package/dist/invalidation/invalidation-hints.js +59 -0
  55. package/dist/invalidation/invalidation-hints.module.d.ts +8 -0
  56. package/dist/invalidation/invalidation-hints.module.js +23 -0
  57. package/dist/invalidation/me-stream.controller.d.ts +30 -0
  58. package/dist/invalidation/me-stream.controller.js +100 -0
  59. package/dist/invalidation/me-stream.d.ts +67 -0
  60. package/dist/invalidation/me-stream.js +351 -0
  61. package/dist/invalidation/me-stream.module.d.ts +7 -0
  62. package/dist/invalidation/me-stream.module.js +22 -0
  63. package/dist/kernel.module.js +4 -0
  64. package/dist/models/enablement.d.ts +12 -0
  65. package/dist/models/enablement.js +32 -0
  66. package/dist/platform/exclusions.js +5 -0
  67. package/dist/platform/ops/admin.ops.js +2 -2
  68. package/dist/platform/ops/catalog-admin.ops.js +1 -1
  69. package/dist/platform/ops/extensions-admin.ops.js +17 -9
  70. package/dist/platform/ops/extensions.ops.js +6 -3
  71. package/dist/platform/ops/org-plugins.ops.js +1 -1
  72. package/dist/platform/ops/plugins.ops.js +1 -1
  73. package/dist/platform/ops/requests.ops.js +55 -1
  74. package/dist/platform/ops/unavailable.js +2 -2
  75. package/dist/tools/builtins/sandbox/common.d.ts +3 -3
  76. package/dist/tools/builtins/sandbox/common.js +3 -3
  77. package/dist/tools/connectors.controller.d.ts +8 -1
  78. package/dist/tools/connectors.controller.js +14 -1
  79. package/dist/tools/connectors.service.d.ts +7 -0
  80. package/dist/tools/connectors.service.js +30 -0
  81. package/package.json +1 -1
  82. package/src/migrations/0233_enable_request_targets.sql +64 -0
@@ -0,0 +1,64 @@
1
+ -- Point-of-use enable requests (org-usable spec 2026-12-02, `catalog_requests` row): an `enable`
2
+ -- request names the switch it asks the org admins to turn on in `detail.target` (`{ kind, id }`,
3
+ -- kinds plugin, extension, skill, agent_template, connector_template, connector and model; a model
4
+ -- id is the JSON tuple `["<provider>","<model>"]`), plus the picker subject it was resolved from
5
+ -- in `detail.subject`. Only a plugin target carries `item_id`. One pending enable request per
6
+ -- (org, target); the other kinds keep their pending (org, kind, item) uniqueness.
7
+ --
8
+ -- Runs as the kernel owner (the migrator's session has no `capybara.rls = enforce`, so the
9
+ -- `org_scope` policy admits every row); the runtime role keeps its grants on the table and the
10
+ -- existing policy; no table is added. catalog_requests is small (requests people file by hand):
11
+ -- re-adding the check constraint takes an ACCESS EXCLUSIVE lock and scans the table, and the
12
+ -- plain CREATE INDEX statements hold a SHARE lock while they build; at this size each lasts a
13
+ -- moment, so no maintenance window is needed. The lock wait is bounded so a busy table fails the
14
+ -- migration instead of queueing writers behind it.
15
+ SET LOCAL lock_timeout = '5s';
16
+
17
+ -- Legacy enable rows (a member asking for a plugin) target that plugin. Idempotent: only rows
18
+ -- without a target are touched.
19
+ UPDATE catalog_requests
20
+ SET detail = coalesce(detail, '{}'::jsonb)
21
+ || jsonb_build_object('target', jsonb_build_object('kind', 'plugin', 'id', item_id::text))
22
+ WHERE kind = 'enable'
23
+ AND item_id IS NOT NULL
24
+ AND (detail IS NULL OR jsonb_typeof(detail -> 'target') IS DISTINCT FROM 'object');
25
+
26
+ -- capybara:allow-destructive the check is added back in the next statement with the enable branch; every row satisfies it after the backfill above
27
+ ALTER TABLE catalog_requests DROP CONSTRAINT IF EXISTS catalog_requests_target_check;
28
+ ALTER TABLE catalog_requests ADD CONSTRAINT catalog_requests_target_check
29
+ CHECK (
30
+ kind = 'import' AND entry_name IS NOT NULL
31
+ OR kind = 'connector_setup' AND agent_id IS NOT NULL
32
+ AND item_id IS NULL AND entry_name IS NULL
33
+ OR kind = 'network_allowlist' AND detail IS NOT NULL
34
+ AND item_id IS NULL AND agent_id IS NULL AND entry_name IS NULL
35
+ OR kind = 'enable' AND detail IS NOT NULL
36
+ AND jsonb_typeof(detail -> 'target') = 'object'
37
+ AND detail -> 'target' ->> 'kind' IN ('plugin', 'extension', 'skill', 'agent_template',
38
+ 'connector_template', 'connector', 'model')
39
+ AND coalesce(detail -> 'target' ->> 'id', '') <> ''
40
+ AND (detail -> 'target' ->> 'kind' <> 'plugin' OR item_id::text = detail -> 'target' ->> 'id')
41
+ AND agent_id IS NULL AND entry_name IS NULL
42
+ OR kind NOT IN ('import', 'connector_setup', 'network_allowlist', 'enable')
43
+ AND item_id IS NOT NULL
44
+ );
45
+
46
+ -- Pending item uniqueness for the kinds other than enable (access), under a new name, before the
47
+ -- old index (which also covered enable) goes.
48
+ CREATE UNIQUE INDEX IF NOT EXISTS catalog_requests_pending_item_kind_uq
49
+ ON catalog_requests (org_id, kind, item_id)
50
+ WHERE status = 'pending' AND item_id IS NOT NULL AND kind <> 'enable';
51
+
52
+ -- One pending enable request per (org, target). It also serves the lookups by target.
53
+ CREATE UNIQUE INDEX IF NOT EXISTS catalog_requests_pending_enable_uq
54
+ ON catalog_requests (org_id, (detail -> 'target' ->> 'kind'), (detail -> 'target' ->> 'id'))
55
+ WHERE status = 'pending' AND kind = 'enable';
56
+
57
+ -- capybara:allow-destructive replaced by catalog_requests_pending_item_kind_uq and catalog_requests_pending_enable_uq above, created in this transaction
58
+ DROP INDEX IF EXISTS catalog_requests_pending_item_uq;
59
+
60
+ -- The requester's inbox notices: decided requests, now including enable requests a switch change
61
+ -- cancelled (`cancelReason: target_changed`); the 0077 index covers approved and rejected only.
62
+ CREATE INDEX IF NOT EXISTS catalog_requests_requester_decided_idx
63
+ ON catalog_requests (org_id, requested_by)
64
+ WHERE status IN ('approved', 'rejected', 'cancelled');