@capybara-hq/kernel 0.1.0-rc.20 → 0.1.0-rc.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bootstrap.json +10 -1
- package/dist/agents/admin-agents.d.ts +16 -3
- package/dist/agents/admin-agents.js +65 -7
- package/dist/agents/agents.schemas.d.ts +24 -6
- package/dist/agents/agents.service.d.ts +4 -3
- package/dist/agents/agents.service.js +39 -26
- package/dist/agents/definition.d.ts +44 -6
- package/dist/agents/definition.js +86 -18
- package/dist/agents/from-template.d.ts +6 -3
- package/dist/agents/from-template.js +57 -44
- package/dist/agents/org-templates.js +97 -41
- package/dist/agents/templates.d.ts +6 -0
- package/dist/agents/templates.js +15 -1
- package/dist/catalog/admin-catalog.controller.d.ts +2 -4
- package/dist/catalog/admin-catalog.controller.js +2 -6
- package/dist/catalog/catalog.module.js +3 -0
- package/dist/catalog/claude/report.d.ts +9 -2
- package/dist/catalog/claude/report.js +1 -0
- package/dist/catalog/claude/translate.js +1 -1
- package/dist/catalog/component-promotion.js +1 -2
- package/dist/catalog/component-state.d.ts +13 -1
- package/dist/catalog/component-state.js +14 -5
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/marketplaces.service.js +2 -1
- package/dist/catalog/org-catalog.controller.d.ts +13 -3
- package/dist/catalog/org-catalog.controller.js +26 -4
- package/dist/catalog/org-catalog.schemas.d.ts +13 -0
- package/dist/catalog/org-catalog.schemas.js +34 -0
- package/dist/catalog/org-plugin-uploads.controller.js +0 -1
- package/dist/catalog/org-plugin-uploads.d.ts +0 -1
- package/dist/catalog/org-plugin-uploads.js +0 -3
- package/dist/catalog/org-plugin-uploads.schemas.d.ts +0 -1
- package/dist/catalog/org-plugin-uploads.schemas.js +0 -2
- package/dist/catalog/platform-components.d.ts +0 -1
- package/dist/catalog/platform-components.js +3 -8
- package/dist/catalog/plugin-import.d.ts +0 -8
- package/dist/catalog/plugin-import.js +4 -35
- package/dist/catalog/plugin-install.d.ts +2 -2
- package/dist/catalog/plugin-install.js +2 -2
- package/dist/catalog/plugin-package.d.ts +7 -0
- package/dist/catalog/plugin-package.js +27 -1
- package/dist/catalog/plugin-upgrade.d.ts +5 -6
- package/dist/catalog/plugin-upgrade.js +5 -23
- package/dist/catalog/requests.service.d.ts +66 -10
- package/dist/catalog/requests.service.js +196 -15
- package/dist/channels/actions.d.ts +2 -0
- package/dist/channels/actions.js +19 -4
- package/dist/channels/cards.d.ts +16 -2
- package/dist/channels/cards.js +40 -7
- package/dist/channels/channels.module.js +3 -0
- package/dist/channels/outbound.d.ts +22 -1
- package/dist/channels/outbound.js +116 -7
- package/dist/channels/phrases.d.ts +25 -0
- package/dist/channels/phrases.js +19 -0
- package/dist/channels/threads.d.ts +12 -0
- package/dist/channels/threads.js +34 -0
- package/dist/config/schema.d.ts +23 -1
- package/dist/config/schema.js +105 -5
- package/dist/conversations/conversations.service.d.ts +42 -9
- package/dist/conversations/conversations.service.js +57 -25
- package/dist/conversations/events.d.ts +106 -11
- package/dist/conversations/events.js +121 -18
- package/dist/conversations/message-context.d.ts +6 -3
- package/dist/conversations/message-context.js +14 -10
- package/dist/conversations/queue.d.ts +15 -2
- package/dist/conversations/queue.js +22 -3
- package/dist/conversations/queue.service.d.ts +12 -6
- package/dist/conversations/queue.service.js +36 -13
- package/dist/db/kernel-schema.d.ts +105 -3
- package/dist/devices/conversation-devices.d.ts +8 -1
- package/dist/devices/conversation-devices.js +8 -0
- package/dist/devices/devices.controller.d.ts +21 -4
- package/dist/devices/devices.controller.js +46 -8
- package/dist/devices/devices.schemas.d.ts +9 -1
- package/dist/devices/devices.schemas.js +11 -3
- package/dist/devices/devices.service.d.ts +176 -4
- package/dist/devices/devices.service.js +341 -6
- package/dist/devices/dto.d.ts +56 -3
- package/dist/devices/dto.js +51 -1
- package/dist/devices/public-suffix.d.ts +6 -0
- package/dist/devices/public-suffix.js +79 -0
- package/dist/errors.d.ts +46 -5
- package/dist/errors.js +46 -5
- package/dist/evals/reconstruct.d.ts +18 -13
- package/dist/evals/reconstruct.js +50 -36
- package/dist/evals/recorded-tools.d.ts +7 -7
- package/dist/evals/recorded-tools.js +4 -3
- package/dist/evals/trajectory.d.ts +6 -1
- package/dist/evals/trajectory.js +7 -0
- package/dist/extensions/bootstrap.d.ts +49 -10
- package/dist/extensions/bootstrap.js +104 -27
- package/dist/extensions/package.js +2 -2
- package/dist/http/api.module.js +5 -0
- package/dist/inbox/inbox.module.js +2 -1
- package/dist/inbox/inbox.service.d.ts +19 -4
- package/dist/inbox/inbox.service.js +14 -3
- package/dist/infra/config/kernel-config.service.js +11 -0
- package/dist/infra/events/kernel-events.d.ts +2 -1
- package/dist/lifecycle/kernel-lifecycle.d.ts +5 -1
- package/dist/lifecycle/kernel-lifecycle.js +16 -4
- package/dist/local-devices/device-policy.service.d.ts +65 -0
- package/dist/local-devices/device-policy.service.js +217 -0
- package/dist/local-devices/local-device-gateway.js +4 -1
- package/dist/local-devices/local-device-provider.d.ts +40 -3
- package/dist/local-devices/local-device-provider.js +109 -7
- package/dist/local-devices/local-devices.module.d.ts +2 -1
- package/dist/local-devices/local-devices.module.js +19 -3
- package/dist/local-devices/machines.d.ts +14 -3
- package/dist/local-devices/machines.js +41 -3
- package/dist/local-devices/network-grants.d.ts +104 -0
- package/dist/local-devices/network-grants.js +288 -0
- package/dist/local-devices/policy-summary.d.ts +20 -0
- package/dist/local-devices/policy-summary.js +63 -0
- package/dist/orgs/orgs.module.js +4 -10
- package/dist/orgs/roles.d.ts +1 -1
- package/dist/orgs/roles.js +4 -0
- package/dist/orgs/settings.controller.js +2 -1
- package/dist/orgs/settings.service.d.ts +164 -12
- package/dist/orgs/settings.service.js +212 -24
- package/dist/platform/exclusions.js +11 -1
- package/dist/platform/operation.js +4 -0
- package/dist/platform/ops/admin-items.ops.js +1 -1
- package/dist/platform/ops/agent-skills.ops.js +2 -2
- package/dist/platform/ops/agent-templates.ops.js +2 -2
- package/dist/platform/ops/agents.ops.js +11 -15
- package/dist/platform/ops/devices.ops.js +3 -1
- package/dist/platform/ops/inbox.ops.js +19 -0
- package/dist/platform/ops/org-settings.ops.js +14 -5
- package/dist/platform/ops/platform.ops.d.ts +9 -1
- package/dist/platform/ops/platform.ops.js +34 -12
- package/dist/platform/ops/requests.ops.js +3 -2
- package/dist/platform/ops/schedules.ops.d.ts +21 -0
- package/dist/platform/ops/schedules.ops.js +470 -0
- package/dist/platform/ops/skills.ops.js +3 -3
- package/dist/platform/platform-ops.module.d.ts +2 -1
- package/dist/platform/platform-ops.module.js +5 -0
- package/dist/platform/route-schemas.js +3 -0
- package/dist/roles/worker.module.js +3 -0
- package/dist/runtime/context/build.js +13 -4
- package/dist/runtime/context/compaction.js +6 -3
- package/dist/runtime/context/device-paths.d.ts +43 -21
- package/dist/runtime/context/device-paths.js +104 -21
- package/dist/runtime/context/run-context.d.ts +9 -0
- package/dist/runtime/context/run-context.js +8 -0
- package/dist/runtime/context/skills.d.ts +14 -1
- package/dist/runtime/context/skills.js +36 -5
- package/dist/runtime/maintenance.d.ts +4 -2
- package/dist/runtime/maintenance.js +16 -5
- package/dist/runtime/run-finish.d.ts +6 -1
- package/dist/runtime/run-finish.js +16 -2
- package/dist/runtime/run-queue.js +21 -2
- package/dist/runtime/run-worker.js +14 -33
- package/dist/runtime/runtime.module.js +3 -0
- package/dist/runtime/subagents/definition.d.ts +32 -14
- package/dist/runtime/subagents/definition.js +106 -109
- package/dist/runtime/subagents/dispatch.js +4 -3
- package/dist/runtime/subagents/preamble.d.ts +2 -1
- package/dist/runtime/subagents/preamble.js +2 -1
- package/dist/runtime/waits.js +14 -4
- package/dist/sandbox/sandbox.service.d.ts +120 -10
- package/dist/sandbox/sandbox.service.js +335 -28
- package/dist/sandbox/tiers.d.ts +86 -0
- package/dist/sandbox/tiers.js +96 -0
- package/dist/schedules/effective-settings.d.ts +16 -0
- package/dist/schedules/effective-settings.js +17 -0
- package/dist/schedules/errors.d.ts +8 -0
- package/dist/schedules/errors.js +8 -0
- package/dist/schedules/fire.d.ts +118 -0
- package/dist/schedules/fire.js +625 -0
- package/dist/schedules/grant-rules.d.ts +94 -0
- package/dist/schedules/grant-rules.js +126 -0
- package/dist/schedules/job-ids.d.ts +32 -0
- package/dist/schedules/job-ids.js +27 -0
- package/dist/schedules/pause.d.ts +9 -0
- package/dist/schedules/pause.js +33 -0
- package/dist/schedules/run-tracker.d.ts +81 -0
- package/dist/schedules/run-tracker.js +333 -0
- package/dist/schedules/scan.job.d.ts +64 -0
- package/dist/schedules/scan.job.js +303 -0
- package/dist/schedules/schedule-math.d.ts +31 -0
- package/dist/schedules/schedule-math.js +223 -0
- package/dist/schedules/scheduled-tasks.service.d.ts +351 -0
- package/dist/schedules/scheduled-tasks.service.js +1193 -0
- package/dist/schedules/schedules.controller.d.ts +68 -0
- package/dist/schedules/schedules.controller.js +242 -0
- package/dist/schedules/schedules.module.d.ts +16 -0
- package/dist/schedules/schedules.module.js +65 -0
- package/dist/schedules/schedules.schemas.d.ts +316 -0
- package/dist/schedules/schedules.schemas.js +186 -0
- package/dist/schedules/store.d.ts +81 -0
- package/dist/schedules/store.js +390 -0
- package/dist/schedules/store.module.d.ts +6 -0
- package/dist/schedules/store.module.js +21 -0
- package/dist/schedules/types.d.ts +108 -0
- package/dist/schedules/types.js +1 -0
- package/dist/schedules/unattended.d.ts +117 -0
- package/dist/schedules/unattended.js +228 -0
- package/dist/setup/oauth-token-probe.js +8 -4
- package/dist/skills/agent-skills.service.d.ts +4 -8
- package/dist/skills/agent-skills.service.js +18 -53
- package/dist/skills/catalog.d.ts +65 -62
- package/dist/skills/catalog.js +109 -206
- package/dist/skills/conversation-catalog.d.ts +3 -3
- package/dist/skills/conversation-catalog.js +5 -12
- package/dist/skills/invoke.d.ts +2 -2
- package/dist/skills/skills.controller.d.ts +3 -1
- package/dist/skills/skills.service.d.ts +38 -37
- package/dist/skills/skills.service.js +168 -107
- package/dist/skills/usable.d.ts +57 -8
- package/dist/skills/usable.js +172 -38
- package/dist/tools/approvals.controller.d.ts +4 -2
- package/dist/tools/approvals.controller.js +17 -2
- package/dist/tools/approvals.schemas.d.ts +1 -0
- package/dist/tools/approvals.schemas.js +3 -1
- package/dist/tools/approvals.service.d.ts +182 -7
- package/dist/tools/approvals.service.js +597 -13
- package/dist/tools/builtin-names.d.ts +25 -4
- package/dist/tools/builtin-names.js +45 -4
- package/dist/tools/builtins/builtin-tools.d.ts +8 -0
- package/dist/tools/builtins/builtin-tools.js +23 -2
- package/dist/tools/builtins/sandbox/bash.js +16 -7
- package/dist/tools/builtins/sandbox/common.d.ts +1 -1
- package/dist/tools/builtins/sandbox/common.js +33 -10
- package/dist/tools/builtins/sandbox/edit.js +7 -3
- package/dist/tools/builtins/sandbox/file-state.d.ts +31 -1
- package/dist/tools/builtins/sandbox/file-state.js +33 -3
- package/dist/tools/builtins/sandbox/write.js +8 -4
- package/dist/tools/builtins/schedules.d.ts +107 -0
- package/dist/tools/builtins/schedules.js +789 -0
- package/dist/tools/elicitation.d.ts +2 -0
- package/dist/tools/elicitation.js +1 -1
- package/dist/tools/fixed-ask.d.ts +7 -0
- package/dist/tools/fixed-ask.js +9 -0
- package/dist/tools/network-asks.d.ts +109 -0
- package/dist/tools/network-asks.js +221 -0
- package/dist/tools/pipeline.d.ts +53 -6
- package/dist/tools/pipeline.js +202 -13
- package/dist/tools/policy.d.ts +21 -8
- package/dist/tools/policy.js +63 -9
- package/dist/tools/registry.d.ts +10 -1
- package/dist/tools/tools.module.js +12 -0
- package/package.json +2 -2
- package/src/migrations/0113_scheduled_tasks.sql +108 -0
- package/src/migrations/0114_network_asks.sql +23 -0
- package/src/migrations/0115_network_requests.sql +28 -0
- package/src/migrations/0116_skills_default_on.sql +37 -0
- package/src/migrations/0117_sandbox_tiers.sql +11 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
-- Scheduled tasks (spec 2026-11-11-scheduled-tasks-design.md §4).
|
|
2
|
+
-- A task belongs to its org; the creator, agent and target conversation carry no foreign key: when
|
|
3
|
+
-- they go, the fire job pauses the task with a reason (creator_inactive / agent_gone /
|
|
4
|
+
-- conversation_gone) instead of the row vanishing.
|
|
5
|
+
CREATE TABLE IF NOT EXISTS scheduled_tasks (
|
|
6
|
+
id text PRIMARY KEY,
|
|
7
|
+
org_id text NOT NULL REFERENCES orgs(id) ON DELETE CASCADE,
|
|
8
|
+
account_id text NOT NULL,
|
|
9
|
+
agent_id text NOT NULL,
|
|
10
|
+
name text NOT NULL,
|
|
11
|
+
prompt text NOT NULL,
|
|
12
|
+
-- { kind: 'cron', expr, timeZone } or { kind: 'once', at, timeZone }; timeZone is an IANA name
|
|
13
|
+
trigger jsonb NOT NULL,
|
|
14
|
+
mode text NOT NULL CHECK (mode IN ('new', 'conversation', 'chat')),
|
|
15
|
+
-- conversation mode only
|
|
16
|
+
conversation_id text,
|
|
17
|
+
-- chat mode only: { connectionId, chatId, chatType }
|
|
18
|
+
chat jsonb,
|
|
19
|
+
-- null = the agent's defaults
|
|
20
|
+
model jsonb,
|
|
21
|
+
effort text,
|
|
22
|
+
-- null = the default pick for new conversations
|
|
23
|
+
device_id text,
|
|
24
|
+
status text NOT NULL DEFAULT 'active' CHECK (status IN ('active', 'paused', 'ended')),
|
|
25
|
+
pause_reason text CHECK (pause_reason IN ('creator', 'admin', 'failures', 'creator_inactive',
|
|
26
|
+
'agent_gone', 'target_gone', 'conversation_gone', 'org_disabled', 'expired',
|
|
27
|
+
'invalid_schedule')),
|
|
28
|
+
paused_by text,
|
|
29
|
+
-- null when not active; jitter included
|
|
30
|
+
next_run_at timestamptz,
|
|
31
|
+
jitter_seconds integer NOT NULL DEFAULT 0,
|
|
32
|
+
expires_at timestamptz,
|
|
33
|
+
consecutive_failures integer NOT NULL DEFAULT 0,
|
|
34
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
35
|
+
updated_at timestamptz NOT NULL DEFAULT now(),
|
|
36
|
+
deleted_at timestamptz
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
-- the scanner's due query
|
|
40
|
+
CREATE INDEX IF NOT EXISTS scheduled_tasks_due_idx ON scheduled_tasks (next_run_at)
|
|
41
|
+
WHERE status = 'active' AND deleted_at IS NULL;
|
|
42
|
+
-- a creator's list and the per-member cap
|
|
43
|
+
CREATE INDEX IF NOT EXISTS scheduled_tasks_account_idx ON scheduled_tasks (org_id, account_id)
|
|
44
|
+
WHERE deleted_at IS NULL;
|
|
45
|
+
|
|
46
|
+
-- One row per tick (and per trial run). scheduled_for is the tick before jitter.
|
|
47
|
+
CREATE TABLE IF NOT EXISTS scheduled_task_runs (
|
|
48
|
+
id text PRIMARY KEY,
|
|
49
|
+
task_id text NOT NULL REFERENCES scheduled_tasks(id) ON DELETE CASCADE,
|
|
50
|
+
org_id text NOT NULL REFERENCES orgs(id) ON DELETE CASCADE,
|
|
51
|
+
scheduled_for timestamptz NOT NULL,
|
|
52
|
+
fired_at timestamptz,
|
|
53
|
+
trial boolean NOT NULL DEFAULT false,
|
|
54
|
+
-- a person's "run now" (trial or not), outside the schedule: it runs even while the task is paused
|
|
55
|
+
manual boolean NOT NULL DEFAULT false,
|
|
56
|
+
conversation_id text,
|
|
57
|
+
run_id text,
|
|
58
|
+
status text NOT NULL DEFAULT 'pending'
|
|
59
|
+
CHECK (status IN ('pending', 'running', 'completed', 'failed', 'skipped')),
|
|
60
|
+
skip_reason text CHECK (skip_reason IN ('missed', 'overlap', 'rate_limited', 'queue_paused',
|
|
61
|
+
'removed', 'device_offline', 'creator_inactive', 'agent_gone', 'target_gone',
|
|
62
|
+
'conversation_gone', 'org_disabled', 'unsupported_target', 'task_deleted', 'task_paused')),
|
|
63
|
+
error text,
|
|
64
|
+
-- tool keys refused for lack of a grant (§7)
|
|
65
|
+
missing_grants jsonb NOT NULL DEFAULT '[]'::jsonb,
|
|
66
|
+
-- when the scanner's repair last found this started run still in flight (rotates its rechecks)
|
|
67
|
+
rechecked_at timestamptz
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
-- the exactly-once guard: one scheduled run per tick (trial runs are free of it)
|
|
71
|
+
CREATE UNIQUE INDEX IF NOT EXISTS scheduled_task_runs_tick_uq ON scheduled_task_runs (task_id, scheduled_for)
|
|
72
|
+
WHERE NOT trial;
|
|
73
|
+
-- the scanner's repair of lost fire jobs (pending runs never fired)
|
|
74
|
+
CREATE INDEX IF NOT EXISTS scheduled_task_runs_pending_idx ON scheduled_task_runs (scheduled_for)
|
|
75
|
+
WHERE status = 'pending';
|
|
76
|
+
-- a task's history and its latest run
|
|
77
|
+
CREATE INDEX IF NOT EXISTS scheduled_task_runs_task_idx ON scheduled_task_runs (task_id, scheduled_for DESC);
|
|
78
|
+
-- the org's maxRunsPerHour count
|
|
79
|
+
CREATE INDEX IF NOT EXISTS scheduled_task_runs_fired_idx ON scheduled_task_runs (org_id, fired_at)
|
|
80
|
+
WHERE fired_at IS NOT NULL;
|
|
81
|
+
|
|
82
|
+
-- A task's "always allow" grants: the shape and meaning of conversation_tool_grants (a grant stops
|
|
83
|
+
-- applying when spec_hash changes or the connector is not the same one).
|
|
84
|
+
CREATE TABLE IF NOT EXISTS scheduled_task_grants (
|
|
85
|
+
task_id text NOT NULL REFERENCES scheduled_tasks(id) ON DELETE CASCADE,
|
|
86
|
+
tool_key text NOT NULL,
|
|
87
|
+
spec_hash text NOT NULL,
|
|
88
|
+
connector_id text,
|
|
89
|
+
created_at timestamptz NOT NULL DEFAULT now(),
|
|
90
|
+
PRIMARY KEY (task_id, tool_key)
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
-- Marks a run as unattended and links it to its task run; inherited by the runs that descend from
|
|
94
|
+
-- it without a person (sub-agents, wakes caused by an unattended run).
|
|
95
|
+
ALTER TABLE runs ADD COLUMN IF NOT EXISTS scheduled_task_run_id text;
|
|
96
|
+
-- Set on the conversations a new-mode task creates.
|
|
97
|
+
ALTER TABLE conversations ADD COLUMN IF NOT EXISTS scheduled_task_id text;
|
|
98
|
+
CREATE INDEX IF NOT EXISTS conversations_scheduled_task_idx ON conversations (scheduled_task_id)
|
|
99
|
+
WHERE scheduled_task_id IS NOT NULL;
|
|
100
|
+
-- The schedule marker of a queued task message (ScheduleMarker); null for a person's message.
|
|
101
|
+
ALTER TABLE conversation_queue ADD COLUMN IF NOT EXISTS schedule jsonb;
|
|
102
|
+
-- A group chat run's delivery whose thread is not bound yet (§8): the account its thread row gets
|
|
103
|
+
-- once outbound has the run's first post (thread key = that message's id); null afterwards.
|
|
104
|
+
ALTER TABLE channel_deliveries ADD COLUMN IF NOT EXISTS pending_thread_account_id text;
|
|
105
|
+
-- The chats a person can point a chat task at (`GET …/schedules/chat-targets`) and the fire's
|
|
106
|
+
-- thread checks read their thread rows by account; anonymous visitors' rows (no account) never.
|
|
107
|
+
CREATE INDEX IF NOT EXISTS channel_threads_account_idx ON channel_threads (account_id, connection_id)
|
|
108
|
+
WHERE account_id IS NOT NULL;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
-- Network asks (network ask-to-allow spec §6.1): an approval of kind 'network' asks the device owner
|
|
2
|
+
-- to allow domains a command was refused. `detail` holds the hosts, the command, the kept command
|
|
3
|
+
-- result and, once decided, what took effect. A network ask shares the (run_id, call_id, attempt)
|
|
4
|
+
-- numbering of its call with the call's tool approvals: it takes the next attempt after them, and
|
|
5
|
+
-- is only asked after the command ran, so no tool approval of the call can follow it.
|
|
6
|
+
ALTER TABLE approvals ADD COLUMN IF NOT EXISTS kind text NOT NULL DEFAULT 'tool';
|
|
7
|
+
ALTER TABLE approvals DROP CONSTRAINT IF EXISTS approvals_kind_check;
|
|
8
|
+
ALTER TABLE approvals ADD CONSTRAINT approvals_kind_check CHECK (kind IN ('tool', 'network'));
|
|
9
|
+
ALTER TABLE approvals ADD COLUMN IF NOT EXISTS detail jsonb;
|
|
10
|
+
|
|
11
|
+
-- A message from the run's starter skips a pending network ask (spec §6.7). Widening the inline
|
|
12
|
+
-- CHECK of 0010 (PG's default name approvals_status_check), like 0108 did for questions.
|
|
13
|
+
ALTER TABLE approvals DROP CONSTRAINT IF EXISTS approvals_status_check;
|
|
14
|
+
ALTER TABLE approvals ADD CONSTRAINT approvals_status_check
|
|
15
|
+
CHECK (status IN ('pending', 'approved', 'denied', 'expired', 'cancelled', 'skipped'));
|
|
16
|
+
|
|
17
|
+
-- Run grants and the per-run caps read the network asks of a run tree.
|
|
18
|
+
CREATE INDEX IF NOT EXISTS approvals_network_run_idx ON approvals (run_id) WHERE kind = 'network';
|
|
19
|
+
|
|
20
|
+
-- What the machine's program reported in its hello (spec §5.4): the features it supports and a
|
|
21
|
+
-- summary of its local network policy, refreshed by each `policy` operation.
|
|
22
|
+
ALTER TABLE device_machines ADD COLUMN IF NOT EXISTS features text[] NOT NULL DEFAULT '{}';
|
|
23
|
+
ALTER TABLE device_machines ADD COLUMN IF NOT EXISTS local_policy jsonb;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
-- Org-layer network requests (network ask-to-allow spec §5.3, plan decision P-D6): a member asks the
|
|
2
|
+
-- org admins to add hosts to the org's sandbox egress allowlist. A `network_allowlist` request names
|
|
3
|
+
-- no item, entry or agent; `detail` holds what it asks for ({ hosts, conversationId, agentId }).
|
|
4
|
+
-- Expand-only: the new column is nullable and the dropped checks are added back, wider, in this file.
|
|
5
|
+
|
|
6
|
+
ALTER TABLE catalog_requests ADD COLUMN IF NOT EXISTS detail jsonb;
|
|
7
|
+
|
|
8
|
+
-- capybara:allow-destructive the check is added back with `network_allowlist` in the next statement; existing rows satisfy it
|
|
9
|
+
ALTER TABLE catalog_requests DROP CONSTRAINT IF EXISTS catalog_requests_kind_check;
|
|
10
|
+
ALTER TABLE catalog_requests ADD CONSTRAINT catalog_requests_kind_check
|
|
11
|
+
CHECK (kind IN ('access', 'import', 'enable', 'connector_setup', 'network_allowlist'));
|
|
12
|
+
|
|
13
|
+
-- capybara:allow-destructive the check is added back with the network_allowlist branch in the next statement; existing rows satisfy its other branches
|
|
14
|
+
ALTER TABLE catalog_requests DROP CONSTRAINT IF EXISTS catalog_requests_target_check;
|
|
15
|
+
ALTER TABLE catalog_requests ADD CONSTRAINT catalog_requests_target_check
|
|
16
|
+
CHECK (
|
|
17
|
+
kind = 'import' AND entry_name IS NOT NULL
|
|
18
|
+
OR kind = 'connector_setup' AND agent_id IS NOT NULL
|
|
19
|
+
AND item_id IS NULL AND entry_name IS NULL
|
|
20
|
+
OR kind = 'network_allowlist' AND detail IS NOT NULL
|
|
21
|
+
AND item_id IS NULL AND agent_id IS NULL AND entry_name IS NULL
|
|
22
|
+
OR kind NOT IN ('import', 'connector_setup', 'network_allowlist') AND item_id IS NOT NULL
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
-- `detail` is a JSON object when set.
|
|
26
|
+
ALTER TABLE catalog_requests DROP CONSTRAINT IF EXISTS catalog_requests_detail_check;
|
|
27
|
+
ALTER TABLE catalog_requests ADD CONSTRAINT catalog_requests_detail_check
|
|
28
|
+
CHECK (detail IS NULL OR jsonb_typeof(detail) = 'object');
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
-- Skills are on by default and pinning is gone (spec 2026-11-12-skills-default-on-design.md §4,
|
|
2
|
+
-- §5): an agent stores only what it turns off (`disabledSkills`), not selected (`skills.orgSkills`)
|
|
3
|
+
-- or pinned (`skills.pinned`) skills. Every stored agent version, older ones included (a rollback
|
|
4
|
+
-- reads the same shape), becomes "nothing turned off"; `skills` stays only while it still holds
|
|
5
|
+
-- something (`writePolicy`). Idempotent: rows already rewritten match neither statement.
|
|
6
|
+
UPDATE agent_versions
|
|
7
|
+
SET definition = CASE
|
|
8
|
+
WHEN ((definition -> 'skills') - 'orgSkills' - 'pinned') = '{}'::jsonb
|
|
9
|
+
THEN definition - 'skills'
|
|
10
|
+
ELSE jsonb_set(definition, '{skills}', (definition -> 'skills') - 'orgSkills' - 'pinned')
|
|
11
|
+
END
|
|
12
|
+
WHERE jsonb_typeof(definition -> 'skills') = 'object'
|
|
13
|
+
AND ((definition -> 'skills') ? 'orgSkills' OR (definition -> 'skills') ? 'pinned');
|
|
14
|
+
|
|
15
|
+
UPDATE agent_versions
|
|
16
|
+
SET definition = definition || jsonb_build_object('disabledSkills', '[]'::jsonb)
|
|
17
|
+
WHERE NOT definition ? 'disabledSkills';
|
|
18
|
+
|
|
19
|
+
-- Org-made agent templates (saved from an agent by an org admin: no plugin, no catalog item) lose
|
|
20
|
+
-- `selectedSkills`: with skills on by default there is nothing to select. Templates from plugin
|
|
21
|
+
-- packages keep what the package wrote (the kernel's template reader drops the field).
|
|
22
|
+
UPDATE agent_template_versions AS v
|
|
23
|
+
SET definition = v.definition - 'selectedSkills'
|
|
24
|
+
FROM agent_templates AS t
|
|
25
|
+
WHERE t.id = v.template_id
|
|
26
|
+
AND t.plugin_name IS NULL
|
|
27
|
+
AND t.catalog_item_id IS NULL
|
|
28
|
+
AND v.definition ? 'selectedSkills';
|
|
29
|
+
|
|
30
|
+
UPDATE platform_agent_template_versions AS v
|
|
31
|
+
SET definition = v.definition - 'selectedSkills'
|
|
32
|
+
FROM platform_agent_templates AS t
|
|
33
|
+
WHERE t.id = v.template_id
|
|
34
|
+
AND t.plugin_name IS NULL
|
|
35
|
+
AND t.catalog_item_id IS NULL
|
|
36
|
+
AND v.object_prefix IS NULL
|
|
37
|
+
AND v.definition ? 'selectedSkills';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
-- Sandbox tiers (sandbox dev tiers spec §7.2, §12). A cloud device's own tier: null follows the
|
|
2
|
+
-- org's default. A local device keeps its tier in its machine's policy.json, never here.
|
|
3
|
+
ALTER TABLE devices ADD COLUMN IF NOT EXISTS tier text;
|
|
4
|
+
ALTER TABLE devices DROP CONSTRAINT IF EXISTS devices_tier_check;
|
|
5
|
+
ALTER TABLE devices ADD CONSTRAINT devices_tier_check CHECK (tier IN ('strict', 'dev', 'open'));
|
|
6
|
+
|
|
7
|
+
-- The limits in force on the device's instance, `{ tier, egress }`, written by the fenced create
|
|
8
|
+
-- (or the file system create, for a provider whose limits apply there) and by an applied
|
|
9
|
+
-- `update`. Null (instances made before this migration) differs from every effective tier, so
|
|
10
|
+
-- the first use after the upgrade applies the new one.
|
|
11
|
+
ALTER TABLE device_instances ADD COLUMN IF NOT EXISTS instance_limits jsonb;
|