@capybara-hq/kernel 0.1.0-rc.113 → 0.1.0-rc.114
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/channels/actions.js +2 -0
- package/dist/channels/cards.d.ts +4 -3
- package/dist/channels/cards.js +18 -3
- package/dist/channels/phrases.d.ts +15 -0
- package/dist/channels/phrases.js +9 -0
- package/dist/conversations/conversations.service.js +7 -0
- package/dist/conversations/events.d.ts +13 -0
- package/dist/conversations/events.js +24 -3
- package/dist/ctx/create-ctx.d.ts +1 -1
- package/dist/ctx/create-ctx.js +6 -1
- package/dist/db/kernel-schema.d.ts +26 -0
- package/dist/device-access/device-access.service.d.ts +74 -3
- package/dist/device-access/device-access.service.js +221 -7
- package/dist/devices/devices.service.js +3 -0
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +6 -0
- package/dist/extensions/permission-set.d.ts +11 -1
- package/dist/extensions/permission-set.js +15 -1
- package/dist/extensions/permission-view.d.ts +3 -2
- package/dist/extensions/permission-view.js +15 -2
- package/dist/infra/outbox/registry.d.ts +14 -0
- package/dist/infra/outbox/registry.js +14 -0
- package/dist/orgs/offboarding.js +5 -1
- package/dist/roles/worker.module.js +3 -0
- package/dist/runtime/maintenance.d.ts +4 -2
- package/dist/runtime/maintenance.js +14 -4
- package/dist/sandbox/device-sandbox.d.ts +12 -0
- package/dist/sandbox/device-sandbox.js +2 -0
- package/dist/sandbox/device-services.d.ts +42 -2
- package/dist/sandbox/device-services.js +74 -14
- package/dist/sandbox/loopback-expiry.job.d.ts +21 -0
- package/dist/sandbox/loopback-expiry.job.js +50 -0
- package/dist/sandbox/loopback-grant-records.d.ts +143 -0
- package/dist/sandbox/loopback-grant-records.js +239 -0
- package/dist/sandbox/loopback-grants.d.ts +119 -0
- package/dist/sandbox/loopback-grants.js +454 -0
- package/dist/sandbox/loopback-live-ports.d.ts +12 -0
- package/dist/sandbox/loopback-live-ports.js +43 -0
- package/dist/sandbox/permission-call-types.d.ts +3 -2
- package/dist/sandbox/permission-ceiling-writes.js +13 -1
- package/dist/sandbox/permission-facts.d.ts +4 -0
- package/dist/sandbox/permission-facts.js +4 -0
- package/dist/sandbox/review/classifier.d.ts +26 -4
- package/dist/sandbox/review/classifier.js +31 -4
- package/dist/sandbox/review/index.d.ts +3 -3
- package/dist/sandbox/review/index.js +2 -2
- package/dist/sandbox/review/permission-candidate.d.ts +5 -4
- package/dist/sandbox/review/permission-candidate.js +6 -5
- package/dist/sandbox/review/review.service.d.ts +69 -0
- package/dist/sandbox/review/review.service.js +117 -0
- package/dist/sandbox/sandbox.module.d.ts +1 -1
- package/dist/sandbox/sandbox.module.js +13 -2
- package/dist/tools/approvals.service.d.ts +82 -6
- package/dist/tools/approvals.service.js +233 -11
- package/dist/tools/call-scope.d.ts +9 -1
- package/dist/tools/loopback-asks.d.ts +52 -0
- package/dist/tools/loopback-asks.js +70 -0
- package/dist/tools/network-asks.d.ts +2 -1
- package/dist/tools/network-asks.js +10 -5
- package/dist/tools/pipeline.d.ts +59 -3
- package/dist/tools/pipeline.js +403 -40
- package/dist/tools/tools.module.js +3 -0
- package/package.json +2 -2
- package/src/migrations/0199_device_loopback_grants.sql +59 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
-- A grant letting one extension service of a person's own device reach one loopback port of that
|
|
2
|
+
-- device for one conversation tree (browser loopback port grants design,
|
|
3
|
+
-- docs/superpowers/specs/2026-11-28-browser-loopback-port-grants-design.md §4 and §6).
|
|
4
|
+
-- `conversation_id` is the root conversation; `source` says who decided (the person, the review
|
|
5
|
+
-- model, Full access, or the owner's panel). `run_id`, `call_id` and `attempt` name the call that
|
|
6
|
+
-- asked (null for the owner's panel), so a grant made without a person resumes as the rerun after a
|
|
7
|
+
-- crash. A grant ends by setting `revoked_at` with its `revoke_reason`; at most one live row exists
|
|
8
|
+
-- per (device, service, conversation, port).
|
|
9
|
+
CREATE TABLE IF NOT EXISTS device_loopback_grants (
|
|
10
|
+
id text PRIMARY KEY,
|
|
11
|
+
org_id text NOT NULL REFERENCES orgs(id) ON DELETE CASCADE,
|
|
12
|
+
device_id text NOT NULL REFERENCES devices(id) ON DELETE CASCADE,
|
|
13
|
+
service_id text NOT NULL,
|
|
14
|
+
conversation_id text NOT NULL REFERENCES conversations(id) ON DELETE CASCADE,
|
|
15
|
+
port integer NOT NULL CHECK (port BETWEEN 1 AND 65535),
|
|
16
|
+
source text NOT NULL CHECK (source IN ('human', 'review-model', 'full-access', 'owner-panel')),
|
|
17
|
+
approval_id text REFERENCES approvals(id) ON DELETE SET NULL,
|
|
18
|
+
run_id text,
|
|
19
|
+
call_id text,
|
|
20
|
+
attempt integer,
|
|
21
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
22
|
+
expires_at timestamptz NOT NULL,
|
|
23
|
+
revoked_at timestamptz,
|
|
24
|
+
revoke_reason text CHECK (
|
|
25
|
+
revoke_reason IN ('revoked', 'expired', 'conversation-deleted', 'outside-sandbox-off')
|
|
26
|
+
),
|
|
27
|
+
-- An ended grant always says why; a live one carries no reason.
|
|
28
|
+
CHECK ((revoked_at IS NULL) = (revoke_reason IS NULL)),
|
|
29
|
+
-- The owner's panel asks without a call; every other source names the call that asked.
|
|
30
|
+
CHECK ((source = 'owner-panel') = (run_id IS NULL AND call_id IS NULL AND attempt IS NULL))
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
-- One live grant per (device, service, conversation, port).
|
|
34
|
+
CREATE UNIQUE INDEX IF NOT EXISTS device_loopback_grants_live_uidx
|
|
35
|
+
ON device_loopback_grants (device_id, service_id, conversation_id, port)
|
|
36
|
+
WHERE revoked_at IS NULL;
|
|
37
|
+
|
|
38
|
+
-- The sweep's scan of live grants past their expiry.
|
|
39
|
+
CREATE INDEX IF NOT EXISTS device_loopback_grants_expiry_idx
|
|
40
|
+
ON device_loopback_grants (expires_at)
|
|
41
|
+
WHERE revoked_at IS NULL;
|
|
42
|
+
|
|
43
|
+
-- The retention sweep's scan of ended grants (deleted 30 days after they end).
|
|
44
|
+
CREATE INDEX IF NOT EXISTS device_loopback_grants_ended_idx
|
|
45
|
+
ON device_loopback_grants (revoked_at)
|
|
46
|
+
WHERE revoked_at IS NOT NULL;
|
|
47
|
+
|
|
48
|
+
-- The by-root revocation (conversation deleted) and refresh scans of live grants.
|
|
49
|
+
CREATE INDEX IF NOT EXISTS device_loopback_grants_root_idx
|
|
50
|
+
ON device_loopback_grants (conversation_id)
|
|
51
|
+
WHERE revoked_at IS NULL;
|
|
52
|
+
|
|
53
|
+
-- The rerun's lookup of the grant its call made.
|
|
54
|
+
CREATE INDEX IF NOT EXISTS device_loopback_grants_call_idx
|
|
55
|
+
ON device_loopback_grants (run_id, call_id)
|
|
56
|
+
WHERE run_id IS NOT NULL;
|
|
57
|
+
|
|
58
|
+
DROP POLICY IF EXISTS org_scope ON device_loopback_grants;
|
|
59
|
+
CREATE POLICY org_scope ON device_loopback_grants USING (rls_admits(org_id)) WITH CHECK (rls_admits(org_id));
|