@capybara-hq/kernel 0.1.0-rc.33 → 0.1.0-rc.34

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.
@@ -54,6 +54,10 @@ export const alwaysRefusedNote = (hosts) => `${blockedLead(hosts)} The user allo
54
54
  export const orgLayerNote = (hosts) => one(hosts)
55
55
  ? `[network] ${list(hosts)} is not in the organization's network allowlist. Only an organization admin can add it; the user can ask an admin from the conversation. Continue without it or tell the user.`
56
56
  : `[network] ${list(hosts)} are not in the organization's network allowlist. Only an organization admin can add them; the user can ask an admin from the conversation. Continue without them or tell the user.`;
57
+ /** An org-layer host beyond the platform's ceiling (org egress ceiling spec §D2): only a super admin. */
58
+ export const platformCeilingNote = (hosts) => one(hosts)
59
+ ? `[network] ${list(hosts)} is not in the platform's network allowlist, which limits this organization. Only a super admin can add it; organization admins cannot. Continue without it or tell the user.`
60
+ : `[network] ${list(hosts)} are not in the platform's network allowlist, which limits this organization. Only a super admin can add them; organization admins cannot. Continue without them or tell the user.`;
57
61
  /** The address layer (spec §6.6): nobody can lift it. */
58
62
  export const addressLayerNote = (hosts) => one(hosts)
59
63
  ? `[network] ${list(hosts)} is a private or local address, which commands can never reach.`
@@ -102,6 +106,7 @@ export function blockedEventHosts(blocked) {
102
106
  export function planNetworkAsk(blocked, run, ctx) {
103
107
  const address = [];
104
108
  const org = [];
109
+ const platform = [];
105
110
  const refused = [];
106
111
  const unattended = [];
107
112
  const taskIgnored = [];
@@ -115,7 +120,10 @@ export function planNetworkAsk(blocked, run, ctx) {
115
120
  if (b.layer === "address")
116
121
  address.push(b.host);
117
122
  else if (b.layer === "org") {
118
- org.push(b.host);
123
+ if (ctx.outsideCeiling?.(b.host) === true)
124
+ platform.push(b.host);
125
+ else
126
+ org.push(b.host);
119
127
  if (unattendedRules(ctx.unattended))
120
128
  missingGrants.push(networkGrantKey(b.host));
121
129
  }
@@ -157,6 +165,8 @@ export function planNetworkAsk(blocked, run, ctx) {
157
165
  }
158
166
  if (org.length > 0)
159
167
  notes.push(orgLayerNote(org));
168
+ if (platform.length > 0)
169
+ notes.push(platformCeilingNote(platform));
160
170
  if (address.length > 0)
161
171
  notes.push(addressLayerNote(address));
162
172
  return { ask, scopes: ["once", "always"], notes, missingGrants };
@@ -35,6 +35,7 @@ import { rootSurfaceOf } from "../runtime/subagents/child.js";
35
35
  import { SubagentMessages } from "../runtime/subagents/messages.js";
36
36
  import { pairStoppedForks } from "../runtime/subagents/skill-fork.js";
37
37
  import { SubagentsService } from "../runtime/subagents/subagents.service.js";
38
+ import { orgHostOutsideCeiling } from "../sandbox/modes.js";
38
39
  import { isSessionGrantableRule, } from "../sandbox/review/index.js";
39
40
  import { CommandReviewService } from "../sandbox/review/review.service.js";
40
41
  import { appendMissingGrant, connectionGrantKey, UNATTENDED_CONNECTION_ERROR, UNATTENDED_ELICITATION_NOTE, UNATTENDED_QUESTION_ERROR, unattendedFails, unattendedRunOf, } from "../schedules/unattended.js";
@@ -1191,7 +1192,12 @@ let ToolPipeline = class ToolPipeline {
1191
1192
  const run = hosts.some((h) => h.layer === "device")
1192
1193
  ? await network.grants.runState(ctx.runId, report.deviceId)
1193
1194
  : null;
1194
- const plan = planNetworkAsk(hosts, run, { device, unattended: ctx.unattended });
1195
+ const limits = this.config.get().sandbox.limits;
1196
+ const plan = planNetworkAsk(hosts, run, {
1197
+ device,
1198
+ unattended: ctx.unattended,
1199
+ outsideCeiling: (h) => orgHostOutsideCeiling(limits, h),
1200
+ });
1195
1201
  if (ctx.unattended != null) {
1196
1202
  for (const key of plan.missingGrants) {
1197
1203
  await appendMissingGrant(this.deps.db, ctx.unattended.taskRunId, key);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capybara-hq/kernel",
3
- "version": "0.1.0-rc.33",
3
+ "version": "0.1.0-rc.34",
4
4
  "description": "Capybara kernel: config, database, plugin host and HTTP API of the Capybara agent platform",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -0,0 +1,38 @@
1
+ -- Org egress ceiling (spec 2026-11-15-org-egress-ceiling-design.md §D5): an org's cloudNetwork
2
+ -- stops replacing the platform's allowlist with a copy (`allowHosts`) and stores a delta over it
3
+ -- (`base`, `extraHosts`, `excludedHosts`). A migration cannot read the deployment's config, so a
4
+ -- stored list is kept exactly: `base: none` (only the org's own hosts) with the list as its extras,
5
+ -- never wider than before. An org admin re-attaches to the platform by following it again.
6
+ --
7
+ -- Only an object cloudNetwork whose allowHosts is an array of distinct strings is converted, in its
8
+ -- order. Anything else (a non-array allowHosts copied in by 0130, duplicates, non-string elements)
9
+ -- is left alone: the old reader already read it as invalid, the empty allowlist, and so does the
10
+ -- new one; converting it would widen it. Idempotent: a converted row has no allowHosts left.
11
+ UPDATE orgs
12
+ SET settings = jsonb_set(
13
+ settings,
14
+ '{cloudNetwork}',
15
+ ((settings->'cloudNetwork') - 'allowHosts')
16
+ || '{"base":"none"}'::jsonb
17
+ || COALESCE(
18
+ (
19
+ SELECT jsonb_build_object('extraHosts', jsonb_agg(h ORDER BY first_pos))
20
+ FROM (
21
+ SELECT e.value AS h, min(e.pos) AS first_pos
22
+ FROM jsonb_array_elements(settings->'cloudNetwork'->'allowHosts')
23
+ WITH ORDINALITY AS e(value, pos)
24
+ WHERE jsonb_typeof(e.value) = 'string'
25
+ GROUP BY e.value
26
+ ) AS uniq
27
+ HAVING count(*) > 0
28
+ ),
29
+ '{}'::jsonb
30
+ )
31
+ )
32
+ WHERE jsonb_typeof(settings->'cloudNetwork') = 'object'
33
+ AND jsonb_typeof(settings->'cloudNetwork'->'allowHosts') = 'array'
34
+ AND jsonb_array_length(settings->'cloudNetwork'->'allowHosts') = (
35
+ SELECT count(DISTINCT e.value)
36
+ FROM jsonb_array_elements(settings->'cloudNetwork'->'allowHosts') AS e(value)
37
+ WHERE jsonb_typeof(e.value) = 'string'
38
+ );