@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.
Files changed (247) hide show
  1. package/bootstrap.json +10 -1
  2. package/dist/agents/admin-agents.d.ts +16 -3
  3. package/dist/agents/admin-agents.js +65 -7
  4. package/dist/agents/agents.schemas.d.ts +24 -6
  5. package/dist/agents/agents.service.d.ts +4 -3
  6. package/dist/agents/agents.service.js +39 -26
  7. package/dist/agents/definition.d.ts +44 -6
  8. package/dist/agents/definition.js +86 -18
  9. package/dist/agents/from-template.d.ts +6 -3
  10. package/dist/agents/from-template.js +57 -44
  11. package/dist/agents/org-templates.js +97 -41
  12. package/dist/agents/templates.d.ts +6 -0
  13. package/dist/agents/templates.js +15 -1
  14. package/dist/catalog/admin-catalog.controller.d.ts +2 -4
  15. package/dist/catalog/admin-catalog.controller.js +2 -6
  16. package/dist/catalog/catalog.module.js +3 -0
  17. package/dist/catalog/claude/report.d.ts +9 -2
  18. package/dist/catalog/claude/report.js +1 -0
  19. package/dist/catalog/claude/translate.js +1 -1
  20. package/dist/catalog/component-promotion.js +1 -2
  21. package/dist/catalog/component-state.d.ts +13 -1
  22. package/dist/catalog/component-state.js +14 -5
  23. package/dist/catalog/marketplaces.service.d.ts +1 -1
  24. package/dist/catalog/marketplaces.service.js +2 -1
  25. package/dist/catalog/org-catalog.controller.d.ts +13 -3
  26. package/dist/catalog/org-catalog.controller.js +26 -4
  27. package/dist/catalog/org-catalog.schemas.d.ts +13 -0
  28. package/dist/catalog/org-catalog.schemas.js +34 -0
  29. package/dist/catalog/org-plugin-uploads.controller.js +0 -1
  30. package/dist/catalog/org-plugin-uploads.d.ts +0 -1
  31. package/dist/catalog/org-plugin-uploads.js +0 -3
  32. package/dist/catalog/org-plugin-uploads.schemas.d.ts +0 -1
  33. package/dist/catalog/org-plugin-uploads.schemas.js +0 -2
  34. package/dist/catalog/platform-components.d.ts +0 -1
  35. package/dist/catalog/platform-components.js +3 -8
  36. package/dist/catalog/plugin-import.d.ts +0 -8
  37. package/dist/catalog/plugin-import.js +4 -35
  38. package/dist/catalog/plugin-install.d.ts +2 -2
  39. package/dist/catalog/plugin-install.js +2 -2
  40. package/dist/catalog/plugin-package.d.ts +7 -0
  41. package/dist/catalog/plugin-package.js +27 -1
  42. package/dist/catalog/plugin-upgrade.d.ts +5 -6
  43. package/dist/catalog/plugin-upgrade.js +5 -23
  44. package/dist/catalog/requests.service.d.ts +66 -10
  45. package/dist/catalog/requests.service.js +196 -15
  46. package/dist/channels/actions.d.ts +2 -0
  47. package/dist/channels/actions.js +19 -4
  48. package/dist/channels/cards.d.ts +16 -2
  49. package/dist/channels/cards.js +40 -7
  50. package/dist/channels/channels.module.js +3 -0
  51. package/dist/channels/outbound.d.ts +22 -1
  52. package/dist/channels/outbound.js +116 -7
  53. package/dist/channels/phrases.d.ts +25 -0
  54. package/dist/channels/phrases.js +19 -0
  55. package/dist/channels/threads.d.ts +12 -0
  56. package/dist/channels/threads.js +34 -0
  57. package/dist/config/schema.d.ts +23 -1
  58. package/dist/config/schema.js +105 -5
  59. package/dist/conversations/conversations.service.d.ts +42 -9
  60. package/dist/conversations/conversations.service.js +57 -25
  61. package/dist/conversations/events.d.ts +106 -11
  62. package/dist/conversations/events.js +121 -18
  63. package/dist/conversations/message-context.d.ts +6 -3
  64. package/dist/conversations/message-context.js +14 -10
  65. package/dist/conversations/queue.d.ts +15 -2
  66. package/dist/conversations/queue.js +22 -3
  67. package/dist/conversations/queue.service.d.ts +12 -6
  68. package/dist/conversations/queue.service.js +36 -13
  69. package/dist/db/kernel-schema.d.ts +105 -3
  70. package/dist/devices/conversation-devices.d.ts +8 -1
  71. package/dist/devices/conversation-devices.js +8 -0
  72. package/dist/devices/devices.controller.d.ts +21 -4
  73. package/dist/devices/devices.controller.js +46 -8
  74. package/dist/devices/devices.schemas.d.ts +9 -1
  75. package/dist/devices/devices.schemas.js +11 -3
  76. package/dist/devices/devices.service.d.ts +176 -4
  77. package/dist/devices/devices.service.js +341 -6
  78. package/dist/devices/dto.d.ts +56 -3
  79. package/dist/devices/dto.js +51 -1
  80. package/dist/devices/public-suffix.d.ts +6 -0
  81. package/dist/devices/public-suffix.js +79 -0
  82. package/dist/errors.d.ts +46 -5
  83. package/dist/errors.js +46 -5
  84. package/dist/evals/reconstruct.d.ts +18 -13
  85. package/dist/evals/reconstruct.js +50 -36
  86. package/dist/evals/recorded-tools.d.ts +7 -7
  87. package/dist/evals/recorded-tools.js +4 -3
  88. package/dist/evals/trajectory.d.ts +6 -1
  89. package/dist/evals/trajectory.js +7 -0
  90. package/dist/extensions/bootstrap.d.ts +49 -10
  91. package/dist/extensions/bootstrap.js +104 -27
  92. package/dist/extensions/package.js +2 -2
  93. package/dist/http/api.module.js +5 -0
  94. package/dist/inbox/inbox.module.js +2 -1
  95. package/dist/inbox/inbox.service.d.ts +19 -4
  96. package/dist/inbox/inbox.service.js +14 -3
  97. package/dist/infra/config/kernel-config.service.js +11 -0
  98. package/dist/infra/events/kernel-events.d.ts +2 -1
  99. package/dist/lifecycle/kernel-lifecycle.d.ts +5 -1
  100. package/dist/lifecycle/kernel-lifecycle.js +16 -4
  101. package/dist/local-devices/device-policy.service.d.ts +65 -0
  102. package/dist/local-devices/device-policy.service.js +217 -0
  103. package/dist/local-devices/local-device-gateway.js +4 -1
  104. package/dist/local-devices/local-device-provider.d.ts +40 -3
  105. package/dist/local-devices/local-device-provider.js +109 -7
  106. package/dist/local-devices/local-devices.module.d.ts +2 -1
  107. package/dist/local-devices/local-devices.module.js +19 -3
  108. package/dist/local-devices/machines.d.ts +14 -3
  109. package/dist/local-devices/machines.js +41 -3
  110. package/dist/local-devices/network-grants.d.ts +104 -0
  111. package/dist/local-devices/network-grants.js +288 -0
  112. package/dist/local-devices/policy-summary.d.ts +20 -0
  113. package/dist/local-devices/policy-summary.js +63 -0
  114. package/dist/orgs/orgs.module.js +4 -10
  115. package/dist/orgs/roles.d.ts +1 -1
  116. package/dist/orgs/roles.js +4 -0
  117. package/dist/orgs/settings.controller.js +2 -1
  118. package/dist/orgs/settings.service.d.ts +164 -12
  119. package/dist/orgs/settings.service.js +212 -24
  120. package/dist/platform/exclusions.js +11 -1
  121. package/dist/platform/operation.js +4 -0
  122. package/dist/platform/ops/admin-items.ops.js +1 -1
  123. package/dist/platform/ops/agent-skills.ops.js +2 -2
  124. package/dist/platform/ops/agent-templates.ops.js +2 -2
  125. package/dist/platform/ops/agents.ops.js +11 -15
  126. package/dist/platform/ops/devices.ops.js +3 -1
  127. package/dist/platform/ops/inbox.ops.js +19 -0
  128. package/dist/platform/ops/org-settings.ops.js +14 -5
  129. package/dist/platform/ops/platform.ops.d.ts +9 -1
  130. package/dist/platform/ops/platform.ops.js +34 -12
  131. package/dist/platform/ops/requests.ops.js +3 -2
  132. package/dist/platform/ops/schedules.ops.d.ts +21 -0
  133. package/dist/platform/ops/schedules.ops.js +470 -0
  134. package/dist/platform/ops/skills.ops.js +3 -3
  135. package/dist/platform/platform-ops.module.d.ts +2 -1
  136. package/dist/platform/platform-ops.module.js +5 -0
  137. package/dist/platform/route-schemas.js +3 -0
  138. package/dist/roles/worker.module.js +3 -0
  139. package/dist/runtime/context/build.js +13 -4
  140. package/dist/runtime/context/compaction.js +6 -3
  141. package/dist/runtime/context/device-paths.d.ts +43 -21
  142. package/dist/runtime/context/device-paths.js +104 -21
  143. package/dist/runtime/context/run-context.d.ts +9 -0
  144. package/dist/runtime/context/run-context.js +8 -0
  145. package/dist/runtime/context/skills.d.ts +14 -1
  146. package/dist/runtime/context/skills.js +36 -5
  147. package/dist/runtime/maintenance.d.ts +4 -2
  148. package/dist/runtime/maintenance.js +16 -5
  149. package/dist/runtime/run-finish.d.ts +6 -1
  150. package/dist/runtime/run-finish.js +16 -2
  151. package/dist/runtime/run-queue.js +21 -2
  152. package/dist/runtime/run-worker.js +14 -33
  153. package/dist/runtime/runtime.module.js +3 -0
  154. package/dist/runtime/subagents/definition.d.ts +32 -14
  155. package/dist/runtime/subagents/definition.js +106 -109
  156. package/dist/runtime/subagents/dispatch.js +4 -3
  157. package/dist/runtime/subagents/preamble.d.ts +2 -1
  158. package/dist/runtime/subagents/preamble.js +2 -1
  159. package/dist/runtime/waits.js +14 -4
  160. package/dist/sandbox/sandbox.service.d.ts +120 -10
  161. package/dist/sandbox/sandbox.service.js +335 -28
  162. package/dist/sandbox/tiers.d.ts +86 -0
  163. package/dist/sandbox/tiers.js +96 -0
  164. package/dist/schedules/effective-settings.d.ts +16 -0
  165. package/dist/schedules/effective-settings.js +17 -0
  166. package/dist/schedules/errors.d.ts +8 -0
  167. package/dist/schedules/errors.js +8 -0
  168. package/dist/schedules/fire.d.ts +118 -0
  169. package/dist/schedules/fire.js +625 -0
  170. package/dist/schedules/grant-rules.d.ts +94 -0
  171. package/dist/schedules/grant-rules.js +126 -0
  172. package/dist/schedules/job-ids.d.ts +32 -0
  173. package/dist/schedules/job-ids.js +27 -0
  174. package/dist/schedules/pause.d.ts +9 -0
  175. package/dist/schedules/pause.js +33 -0
  176. package/dist/schedules/run-tracker.d.ts +81 -0
  177. package/dist/schedules/run-tracker.js +333 -0
  178. package/dist/schedules/scan.job.d.ts +64 -0
  179. package/dist/schedules/scan.job.js +303 -0
  180. package/dist/schedules/schedule-math.d.ts +31 -0
  181. package/dist/schedules/schedule-math.js +223 -0
  182. package/dist/schedules/scheduled-tasks.service.d.ts +351 -0
  183. package/dist/schedules/scheduled-tasks.service.js +1193 -0
  184. package/dist/schedules/schedules.controller.d.ts +68 -0
  185. package/dist/schedules/schedules.controller.js +242 -0
  186. package/dist/schedules/schedules.module.d.ts +16 -0
  187. package/dist/schedules/schedules.module.js +65 -0
  188. package/dist/schedules/schedules.schemas.d.ts +316 -0
  189. package/dist/schedules/schedules.schemas.js +186 -0
  190. package/dist/schedules/store.d.ts +81 -0
  191. package/dist/schedules/store.js +390 -0
  192. package/dist/schedules/store.module.d.ts +6 -0
  193. package/dist/schedules/store.module.js +21 -0
  194. package/dist/schedules/types.d.ts +108 -0
  195. package/dist/schedules/types.js +1 -0
  196. package/dist/schedules/unattended.d.ts +117 -0
  197. package/dist/schedules/unattended.js +228 -0
  198. package/dist/setup/oauth-token-probe.js +8 -4
  199. package/dist/skills/agent-skills.service.d.ts +4 -8
  200. package/dist/skills/agent-skills.service.js +18 -53
  201. package/dist/skills/catalog.d.ts +65 -62
  202. package/dist/skills/catalog.js +109 -206
  203. package/dist/skills/conversation-catalog.d.ts +3 -3
  204. package/dist/skills/conversation-catalog.js +5 -12
  205. package/dist/skills/invoke.d.ts +2 -2
  206. package/dist/skills/skills.controller.d.ts +3 -1
  207. package/dist/skills/skills.service.d.ts +38 -37
  208. package/dist/skills/skills.service.js +168 -107
  209. package/dist/skills/usable.d.ts +57 -8
  210. package/dist/skills/usable.js +172 -38
  211. package/dist/tools/approvals.controller.d.ts +4 -2
  212. package/dist/tools/approvals.controller.js +17 -2
  213. package/dist/tools/approvals.schemas.d.ts +1 -0
  214. package/dist/tools/approvals.schemas.js +3 -1
  215. package/dist/tools/approvals.service.d.ts +182 -7
  216. package/dist/tools/approvals.service.js +597 -13
  217. package/dist/tools/builtin-names.d.ts +25 -4
  218. package/dist/tools/builtin-names.js +45 -4
  219. package/dist/tools/builtins/builtin-tools.d.ts +8 -0
  220. package/dist/tools/builtins/builtin-tools.js +23 -2
  221. package/dist/tools/builtins/sandbox/bash.js +16 -7
  222. package/dist/tools/builtins/sandbox/common.d.ts +1 -1
  223. package/dist/tools/builtins/sandbox/common.js +33 -10
  224. package/dist/tools/builtins/sandbox/edit.js +7 -3
  225. package/dist/tools/builtins/sandbox/file-state.d.ts +31 -1
  226. package/dist/tools/builtins/sandbox/file-state.js +33 -3
  227. package/dist/tools/builtins/sandbox/write.js +8 -4
  228. package/dist/tools/builtins/schedules.d.ts +107 -0
  229. package/dist/tools/builtins/schedules.js +789 -0
  230. package/dist/tools/elicitation.d.ts +2 -0
  231. package/dist/tools/elicitation.js +1 -1
  232. package/dist/tools/fixed-ask.d.ts +7 -0
  233. package/dist/tools/fixed-ask.js +9 -0
  234. package/dist/tools/network-asks.d.ts +109 -0
  235. package/dist/tools/network-asks.js +221 -0
  236. package/dist/tools/pipeline.d.ts +53 -6
  237. package/dist/tools/pipeline.js +202 -13
  238. package/dist/tools/policy.d.ts +21 -8
  239. package/dist/tools/policy.js +63 -9
  240. package/dist/tools/registry.d.ts +10 -1
  241. package/dist/tools/tools.module.js +12 -0
  242. package/package.json +2 -2
  243. package/src/migrations/0113_scheduled_tasks.sql +108 -0
  244. package/src/migrations/0114_network_asks.sql +23 -0
  245. package/src/migrations/0115_network_requests.sql +28 -0
  246. package/src/migrations/0116_skills_default_on.sql +37 -0
  247. 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;