@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
@@ -16,8 +16,10 @@ export type PlanItemKind = "instruction_file" | "description" | "quick_action" |
16
16
  * describes sub-agents, though its allowlist leaves it out); unavailable `plugin_unavailable`
17
17
  * (its plugin is not enabled in the org or not loaded), `unknown_tool`, `connector_key` (a
18
18
  * connector tool key: connectors carry over only through `connectors` entries);
19
- * - skill: `pinned`, `not_pinned_manual_only`, `not_pinned_too_large`, `subagent` (named only by an
20
- * inline sub-agent); unavailable `not_found`;
19
+ * - skill (a name of `skills` or an inline sub-agent's `skills`, or a `disallowedSkills` entry): a
20
+ * carried name is on for the new agent, `subagent` when only an inline sub-agent names it;
21
+ * `disallowed` for a `disallowedSkills` entry turned off; unavailable `not_found` (the org does
22
+ * not have it);
21
23
  * - connector: `several` (the first of several connectors made from the template was bound);
22
24
  * pending `no_connector`, `tools_missing` (the connector made from the template lacks every
23
25
  * named tool), `needs`; unavailable `template_not_found` (also for a template the org may not
@@ -56,7 +58,8 @@ export interface TemplatePlan {
56
58
  * What has no place in the agent or was cut to its limits: `maxSteps`, `effort` when the model
57
59
  * does not declare it, `description` / `instructions` / `quickActions.<i>.title|body` /
58
60
  * `instructionFiles.<i>.content` / `subagents.inline.<name>.description|instructions` when cut to
59
- * the kernel's limits (UTF-16 units), `subagents.inline.<name>.tools.<key>` for a key the agent
61
+ * the kernel's limits (UTF-16 units), `disallowedSkills.<entry>` for an entry that names no skill
62
+ * the org has, `subagents.inline.<name>.tools.<key>` for a key the agent
60
63
  * does not have, `connectors.<key>.tools.<name>` / `connectors.<key>.policies.<name>` for a tool
61
64
  * the bound connector does not offer.
62
65
  */
@@ -3,14 +3,13 @@
3
3
  // create. Pure resolution over read snapshots: the database reads go through `db`, the replica's
4
4
  // extension state and the model lookups through `opts`; nothing is written here.
5
5
  import { createHash } from "node:crypto";
6
- import { connectorToolKey, extensionToolKey, parseToolKey, SKILL_ENTRY_FILE, validateParams, } from "@capybara-hq/plugin-sdk";
6
+ import { connectorToolKey, extensionToolKey, parseToolKey, validateParams, } from "@capybara-hq/plugin-sdk";
7
7
  import { connectorTemplateState } from "../catalog/component-state.js";
8
- import { invocationOf, PINNED_SKILLS_LIMITS } from "../skills/catalog.js";
9
- import { usableSkillVersions } from "../skills/usable.js";
8
+ import { builtinSkillIds, builtinSkillPlugins, usableSkillVersions, } from "../skills/usable.js";
10
9
  import { CONTROL_OR_HIDDEN_RE } from "../text.js";
11
10
  import { AGENT_BUILTIN_NAMES, AGENT_TOOL, BASH_COMPANION_TOOLS, BUILTIN, BUILTIN_TOOL_NAMES, } from "../tools/builtin-names.js";
12
11
  import { canonicalJson } from "../tools/canonical-json.js";
13
- import { AgentDefinitionSchema, builtinDisabled, canonicalDisabledTools, connectorToolDisabled, extensionToolDisabled, SUBAGENT_NAME_RE, SUBAGENT_ROSTER_MAX, } from "./definition.js";
12
+ import { AgentDefinitionSchema, builtinDisabled, canonicalDisabledSkills, canonicalDisabledTools, connectorToolDisabled, extensionToolDisabled, SUBAGENT_NAME_RE, SUBAGENT_ROSTER_MAX, } from "./definition.js";
14
13
  import { INSTRUCTION_FILE_LIMITS, INSTRUCTION_FILE_NAME_RE, joinInstructionFiles, } from "./instruction-files.js";
15
14
  import { sanitizeEndpoint } from "./org-templates.js";
16
15
  import { PROFILE_LIMITS, ProfileInputSchema } from "./profile.js";
@@ -81,6 +80,34 @@ function skillByName(skills, ref, ownPlugin) {
81
80
  const rank = (s) => (ownPlugin !== null && s.plugin === ownPlugin ? 0 : 1);
82
81
  return [...found].sort((a, b) => rank(a) - rank(b) || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0))[0];
83
82
  }
83
+ /**
84
+ * A template's `disallowedSkills` entry as an agent's disabled skill entry (skills default-on spec
85
+ * §6.2): `<plugin>:*` the whole plugin (skills it gains later included), `<plugin>:<name>` that
86
+ * plugin's skill, a bare `<name>` the org's usable skill of that name without a plugin. Null when
87
+ * the agent's save check would refuse it: it names nothing the org has, a builtin plugin
88
+ * (`builtin.plugins`) or a builtin skill (`builtin.ids`, which cannot be turned off).
89
+ */
90
+ function disallowedSkillRef(skills, ref, builtin) {
91
+ const isBuiltin = (s) => builtin.ids.has(s.id) ||
92
+ (s.platformSkillId !== undefined && builtin.ids.has(s.platformSkillId));
93
+ const i = ref.indexOf(":");
94
+ if (i >= 0) {
95
+ const plugin = ref.slice(0, i);
96
+ const name = ref.slice(i + 1);
97
+ if (builtin.plugins.has(plugin))
98
+ return null;
99
+ const ofPlugin = skills.filter((s) => s.plugin === plugin);
100
+ if (name === "*") {
101
+ return ofPlugin.length === 0 ? null : { kind: "plugin", plugin, skills: "all" };
102
+ }
103
+ const s = ofPlugin.find((x) => x.name === name);
104
+ return s === undefined || isBuiltin(s) ? null : { kind: "plugin", plugin, skills: [name] };
105
+ }
106
+ const s = skills
107
+ .filter((x) => x.plugin === null && x.name === ref)
108
+ .sort((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0))[0];
109
+ return s === undefined || isBuiltin(s) ? null : { kind: "skill", skillId: s.id };
110
+ }
84
111
  /**
85
112
  * Whether the org may see platform connector template `row`: usable (on) or offered in the org,
86
113
  * owned by it, or one it has made connectors from (they stay its own, also after the template is
@@ -315,45 +342,34 @@ export async function planFromTemplate(db, orgId, row, opts) {
315
342
  offExtensionTool(parsed.plugin, parsed.tool);
316
343
  // a connector key is matched against the bound connectors below
317
344
  }
318
- // skills: by name against the org's usable skills (P4-5); every name gets its item
345
+ // skills (skills default-on spec §6.2): the new agent has every skill on in the org. Each name
346
+ // in `skills` (and in an inline sub-agent's, below) is checked against the org's usable skills
347
+ // and listed `carried` or `unavailable` (`not_found`); it narrows nothing.
319
348
  const usable = await usableSkillVersions(db, orgId);
320
- const orgSkills = [];
321
- const select = (id) => {
322
- if (!orgSkills.includes(id))
323
- orgSkills.push(id);
324
- };
325
- const pinned = [];
326
- let pinnedBytes = 0;
327
- const preloaded = new Set(t.skills ?? []);
328
- const skillNames = [...new Set([...(t.skills ?? []), ...(t.selectedSkills ?? [])])];
329
- for (const name of skillNames) {
330
- const s = skillByName(usable, name, row.plugin);
331
- if (!s) {
349
+ for (const name of new Set(t.skills ?? [])) {
350
+ if (skillByName(usable, name, row.plugin))
351
+ item("skill", name, "carried");
352
+ else
332
353
  item("skill", name, "unavailable", "not_found");
354
+ }
355
+ // `disallowedSkills` turns skills off: `<plugin>:*` the whole plugin, `<plugin>:<name>` a
356
+ // plugin's skill, a bare `<name>` the org's skill without a plugin; an entry that names nothing
357
+ // the org has, or a builtin plugin or skill (always on), is dropped
358
+ const disabledSkills = [];
359
+ const builtin = (t.disallowedSkills ?? []).length === 0
360
+ ? { plugins: new Set(), ids: new Set() }
361
+ : {
362
+ plugins: await builtinSkillPlugins(db),
363
+ ids: new Set(await builtinSkillIds(db, orgId)),
364
+ };
365
+ for (const ref of new Set(t.disallowedSkills ?? [])) {
366
+ const off = disallowedSkillRef(usable, ref, builtin);
367
+ if (off === null) {
368
+ dropped.push(`disallowedSkills.${ref}`);
333
369
  continue;
334
370
  }
335
- select(s.id);
336
- if (!preloaded.has(name)) {
337
- item("skill", name, "carried", pinned.includes(s.id) ? "pinned" : undefined);
338
- continue;
339
- }
340
- if (pinned.includes(s.id)) {
341
- item("skill", name, "carried", "pinned");
342
- continue;
343
- }
344
- const bytes = s.manifest.files.find((f) => f.path === SKILL_ENTRY_FILE)?.size ?? 0;
345
- if (!invocationOf(s.manifest).model) {
346
- item("skill", name, "carried", "not_pinned_manual_only");
347
- }
348
- else if (pinned.length >= PINNED_SKILLS_LIMITS.count ||
349
- pinnedBytes + bytes > PINNED_SKILLS_LIMITS.totalBytes) {
350
- item("skill", name, "carried", "not_pinned_too_large");
351
- }
352
- else {
353
- pinned.push(s.id);
354
- pinnedBytes += bytes;
355
- item("skill", name, "carried", "pinned");
356
- }
371
+ disabledSkills.push(off);
372
+ item("skill", ref, "carried", "disallowed");
357
373
  }
358
374
  // connectors (P4-5, P4-6)
359
375
  const pendingConnectors = [];
@@ -530,8 +546,7 @@ export async function planFromTemplate(db, orgId, row, opts) {
530
546
  }
531
547
  if (!skillIds.includes(s.id))
532
548
  skillIds.push(s.id);
533
- if (!orgSkills.includes(s.id)) {
534
- select(s.id);
549
+ if (!items.some((i) => i.kind === "skill" && i.name === name)) {
535
550
  item("skill", name, "carried", "subagent");
536
551
  }
537
552
  }
@@ -617,9 +632,7 @@ export async function planFromTemplate(db, orgId, row, opts) {
617
632
  fallbackParams: {},
618
633
  disabledTools: canonicalDisabledTools(disabled),
619
634
  toolPolicies,
620
- ...((orgSkills.length > 0 || pinned.length > 0) && {
621
- skills: { orgSkills, ...(pinned.length > 0 && { pinned }) },
622
- }),
635
+ disabledSkills: canonicalDisabledSkills(disabledSkills),
623
636
  ...(subagents !== undefined && { subagents }),
624
637
  ...(pendingConnectors.length > 0 && { pendingConnectors }),
625
638
  };
@@ -11,7 +11,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
11
  // an org row (`agent_templates`, no plugin, a bare `<name>`, version 1) from an agent, the template
12
12
  // detail reads any template usable in the org, and the owner org's admins write new versions.
13
13
  // Deleting and 可共享 are `OwnedItems`' (the P3 owner rules). No in-process state.
14
- import { AGENT_TEMPLATE_LIMITS, extensionToolKey, parseAgentTemplate, parseToolKey, } from "@capybara-hq/plugin-sdk";
14
+ import { AGENT_TEMPLATE_LIMITS, extensionToolKey, isDisallowedSkillRef, parseAgentTemplate, parseToolKey, } from "@capybara-hq/plugin-sdk";
15
15
  import { Inject, Injectable } from "@nestjs/common";
16
16
  import { offeredNamed } from "../catalog/component-state.js";
17
17
  import { ownerOf, ownersOf } from "../catalog/ownership.js";
@@ -22,12 +22,13 @@ import { KernelDb } from "../infra/database/kernel-db.js";
22
22
  import { TransactionHost } from "../infra/database/transaction-host.js";
23
23
  import { Transactional } from "../infra/database/transactional.decorator.js";
24
24
  import { OrgLock } from "../orgs/org-lock.js";
25
- import { skillVersionsById } from "../skills/usable.js";
25
+ import { builtinSkillIds, builtinSkillPlugins, linkedCopyIds, skillIdsOf, skillVersionsById, usableSkillVersions, } from "../skills/usable.js";
26
26
  import { isRemovedBuiltinKey } from "../tools/builtin-names.js";
27
27
  import { canonicalJson } from "../tools/canonical-json.js";
28
28
  import { ToolRegistry } from "../tools/registry.js";
29
29
  import { AgentLookup } from "./agent-lookup.js";
30
- import { loadTemplates, putTemplateVersionIn, readOwnTemplate, templateTypeOf, templateViewOf, usableTemplates, } from "./templates.js";
30
+ import { canonicalDisabledSkills, } from "./definition.js";
31
+ import { loadTemplates, putTemplateVersionIn, readOwnTemplate, storedTemplate, templateTypeOf, templateViewOf, usableTemplates, } from "./templates.js";
31
32
  /**
32
33
  * Roster names no template may take (ruling T4-R15): `general-purpose`, always the roster's first
33
34
  * entry. Claude Code's other built-in types (`Explore`, `Plan`) are capitalized, which the
@@ -127,6 +128,68 @@ export function canonicalEndpoints(template) {
127
128
  }
128
129
  return template.connectors === undefined ? template : { ...template, connectors };
129
130
  }
131
+ /**
132
+ * An agent's `disabledSkills` as a template's `disallowedSkills` (skills default-on spec §6.2): a
133
+ * plugin entry of `"all"` as `<plugin>:*` while the org has skills of that plugin, its names as
134
+ * `<plugin>:<name>` while the org has that skill, a skill entry as the current name of the usable skill it names (`<plugin>:<name>` for a
135
+ * plugin's skill). What no longer resolves, or is past the template's limit, goes to `omitted`.
136
+ */
137
+ async function disallowedSkillsOf(db, orgId, disabled, omitted) {
138
+ const out = [];
139
+ if (disabled.length === 0)
140
+ return out;
141
+ const usable = await usableSkillVersions(db, orgId);
142
+ const linked = await linkedCopyIds(db, orgId, usable.flatMap((r) => (r.origin === "platform" ? [r.id] : [])));
143
+ // builtin plugins and skills are always on: never in an off-list (the agent save refuses them)
144
+ const builtinPlugins = await builtinSkillPlugins(db);
145
+ const builtinIds = new Set(await builtinSkillIds(db, orgId));
146
+ const isBuiltin = (s) => builtinIds.has(s.id) || (s.platformSkillId !== undefined && builtinIds.has(s.platformSkillId));
147
+ const push = (ref, id) => {
148
+ if (out.includes(ref))
149
+ return;
150
+ if (out.length >= AGENT_TEMPLATE_LIMITS.disallowedSkills) {
151
+ omitted.push({ kind: "skill", name: ref, ...(id !== undefined && { id }), reason: "limit" });
152
+ return;
153
+ }
154
+ out.push(ref);
155
+ };
156
+ for (const r of canonicalDisabledSkills(disabled)) {
157
+ if (r.kind === "plugin" && builtinPlugins.has(r.plugin))
158
+ continue;
159
+ if (r.kind === "plugin") {
160
+ if (r.skills === "all") {
161
+ const ref = `${r.plugin}:*`;
162
+ const ok = isDisallowedSkillRef(ref) && usable.some((s) => s.plugin === r.plugin);
163
+ if (ok)
164
+ push(ref);
165
+ else
166
+ omitted.push({ kind: "skill", name: ref, reason: "unavailable" });
167
+ continue;
168
+ }
169
+ for (const name of r.skills) {
170
+ const ref = `${r.plugin}:${name}`;
171
+ const s = usable.find((u) => u.plugin === r.plugin && u.name === name);
172
+ const ok = isDisallowedSkillRef(ref) && s !== undefined && !isBuiltin(s);
173
+ if (ok)
174
+ push(ref);
175
+ else
176
+ omitted.push({ kind: "skill", name: ref, reason: "unavailable" });
177
+ }
178
+ continue;
179
+ }
180
+ const s = usable.find((u) => skillIdsOf(u, linked).includes(r.skillId));
181
+ const ref = s === undefined || isBuiltin(s) || (s.plugin !== null && builtinPlugins.has(s.plugin))
182
+ ? null
183
+ : s.plugin === null
184
+ ? s.name
185
+ : `${s.plugin}:${s.name}`;
186
+ if (ref !== null && isDisallowedSkillRef(ref))
187
+ push(ref, r.skillId);
188
+ else
189
+ omitted.push({ kind: "skill", name: r.skillId, id: r.skillId, reason: "unavailable" });
190
+ }
191
+ return out;
192
+ }
130
193
  /**
131
194
  * The template an agent is saved as (rulings P4-10, P4-11), with what was left out. Pure reads of
132
195
  * the org's state through `db`.
@@ -229,50 +292,44 @@ extensionTools = []) {
229
292
  // capped with the entry's tools when it is pushed
230
293
  return { policies: Object.fromEntries(list.map((p) => [p.tool, p.policy])) };
231
294
  };
232
- // Skills: ids -> names (pinned -> `skills`, the other selected ones -> `selectedSkills`)
233
- const pinned = def.skills?.pinned ?? [];
234
- const selected = def.skills?.orgSkills ?? [];
295
+ // Skills (skills default-on spec §6.2): the agent has every skill on in the org; its
296
+ // `disabledSkills` become `disallowedSkills` (a whole plugin as `<plugin>:*`, a plugin's skill
297
+ // as `<plugin>:<name>`, a skill entry by its current name); entries that no longer resolve to a
298
+ // usable skill are listed. The agent's own skills are not in the org library: listed.
299
+ const disallowedSkills = await disallowedSkillsOf(db, orgId, def.disabledSkills ?? [], omitted);
235
300
  const inlineSkillIds = (def.subagents?.inline ?? []).flatMap((t) => t.skills ?? []);
236
- const byId = await skillVersionsById(db, orgId, [...pinned, ...selected, ...inlineSkillIds]);
237
- const agentSkillNames = new Map((await db
301
+ const byId = await skillVersionsById(db, orgId, inlineSkillIds);
302
+ const ownSkills = await db
238
303
  .selectFrom("skills")
239
- .select(["id", "name"])
304
+ .select(["id", "name", "agent_id", "deleted_at"])
240
305
  .where("org_id", "=", orgId)
241
306
  .where("scope", "=", "agent")
242
- .where("id", "in", ["", ...pinned, ...selected, ...inlineSkillIds])
243
- .execute()).map((r) => [r.id, r.name]));
307
+ .where((eb) => eb.or([eb("agent_id", "=", agent.id), eb("id", "in", ["", ...inlineSkillIds])]))
308
+ .orderBy("name")
309
+ .orderBy("id")
310
+ .execute();
311
+ const agentSkillNames = new Map(ownSkills.map((r) => [r.id, r.name]));
244
312
  const reportedSkills = new Set();
245
- const skillName = (id, report) => {
313
+ const reportSkill = (id) => {
314
+ if (reportedSkills.has(id))
315
+ return;
316
+ reportedSkills.add(id);
317
+ const own = agentSkillNames.get(id) ?? byId.get(id)?.name;
318
+ omitted.push(own !== undefined
319
+ ? { kind: "skill", name: own, id, reason: "agent_skill" }
320
+ : { kind: "skill", name: id, id, reason: "unavailable" });
321
+ };
322
+ const skillName = (id) => {
246
323
  const s = byId.get(id);
247
324
  if (s && s.scope === "org")
248
325
  return s.name;
249
- if (report && !reportedSkills.has(id)) {
250
- reportedSkills.add(id);
251
- const own = agentSkillNames.get(id) ?? s?.name;
252
- omitted.push(own !== undefined
253
- ? { kind: "skill", name: own, id, reason: "agent_skill" }
254
- : { kind: "skill", name: id, id, reason: "unavailable" });
255
- }
326
+ reportSkill(id);
256
327
  return null;
257
328
  };
258
- const skills = [];
259
- for (const id of pinned) {
260
- const n = skillName(id, true);
261
- if (n !== null && !skills.includes(n) && skills.length < L.skills)
262
- skills.push(n);
263
- }
264
- const selectedSkills = [];
265
- for (const id of selected) {
266
- if (pinned.includes(id))
267
- continue;
268
- const n = skillName(id, true);
269
- if (n === null || skills.includes(n) || selectedSkills.includes(n))
270
- continue;
271
- if (selectedSkills.length >= L.selectedSkills) {
272
- omitted.push({ kind: "skill", name: n, id, reason: "limit" });
273
- continue;
274
- }
275
- selectedSkills.push(n);
329
+ // the agent's own live skills (on for it whatever `disabledSkills` say)
330
+ for (const r of ownSkills) {
331
+ if (r.agent_id === agent.id && r.deleted_at === null)
332
+ reportSkill(r.id);
276
333
  }
277
334
  // Connectors (P4-11), then the agent's pending connectors as they are
278
335
  const connectors = [];
@@ -468,7 +525,7 @@ extensionTools = []) {
468
525
  }
469
526
  const inlineSkills = [];
470
527
  for (const id of t.skills ?? []) {
471
- const n = skillName(id, true);
528
+ const n = skillName(id);
472
529
  if (n === null || inlineSkills.includes(n))
473
530
  continue;
474
531
  if (inlineSkills.length >= L.skills) {
@@ -512,8 +569,7 @@ extensionTools = []) {
512
569
  model: "standard",
513
570
  modelRef: `${def.model.provider}/${def.model.model}`,
514
571
  ...(effort !== undefined && { effort }),
515
- ...(skills.length > 0 && { skills }),
516
- ...(selectedSkills.length > 0 && { selectedSkills }),
572
+ ...(disallowedSkills.length > 0 && { disallowedSkills }),
517
573
  ...(connectors.length > 0 && { connectors }),
518
574
  ...(subagents !== undefined && { subagents }),
519
575
  ...(quickActions.length > 0 && { quickActions }),
@@ -806,7 +862,7 @@ let OrgAgentTemplates = class OrgAgentTemplates {
806
862
  name: own.name,
807
863
  plugin: null,
808
864
  version: row.current_version,
809
- template: row.definition,
865
+ template: storedTemplate(row.definition),
810
866
  sourceFormat: row.source_format,
811
867
  catalogItemId: null,
812
868
  catalogVersion: null,
@@ -61,6 +61,12 @@ export interface TemplateRow {
61
61
  }
62
62
  /** The roster type of a template: `<plugin>:<name>`, the bare `<name>` without a plugin. */
63
63
  export declare const templateTypeOf: (plugin: string | null, name: string) => string;
64
+ /**
65
+ * A stored template definition as the current format reads it: `selectedSkills` (removed with
66
+ * skills on by default, spec §6.2) is dropped. Migration 0116 removed it from org-made versions;
67
+ * versions written from a plugin package keep it as the package wrote it, so every read drops it.
68
+ */
69
+ export declare function storedTemplate(definition: unknown): AgentTemplate;
64
70
  /**
65
71
  * The ids among `ids` of the platform templates on in the org (see {@link platformOn}), whatever
66
72
  * the org's own templates are.
@@ -53,6 +53,20 @@ async function ownedPlatformIds(db, orgId, platformIds) {
53
53
  .execute();
54
54
  return new Set(rows.map((r) => r.id));
55
55
  }
56
+ /**
57
+ * A stored template definition as the current format reads it: `selectedSkills` (removed with
58
+ * skills on by default, spec §6.2) is dropped. Migration 0116 removed it from org-made versions;
59
+ * versions written from a plugin package keep it as the package wrote it, so every read drops it.
60
+ */
61
+ export function storedTemplate(definition) {
62
+ if (definition === null || typeof definition !== "object" || Array.isArray(definition)) {
63
+ return definition;
64
+ }
65
+ if (!("selectedSkills" in definition))
66
+ return definition;
67
+ const { selectedSkills: _s, ...rest } = definition;
68
+ return rest;
69
+ }
56
70
  /**
57
71
  * Stored rows as {@link TemplateRow}s; tool keys read as current keys (tool naming spec §8.3): old
58
72
  * builtin names always, rc `<x>__<tool>` keys with the org's legacy scope, read once when needed.
@@ -63,7 +77,7 @@ async function normalized(db, orgId, rows) {
63
77
  : undefined;
64
78
  return rows.map(({ definition, ...r }) => ({
65
79
  ...r,
66
- template: normalizeToolKeys(definition, scope),
80
+ template: storedTemplate(normalizeToolKeys(definition, scope)),
67
81
  }));
68
82
  }
69
83
  const orgRaw = (r) => ({
@@ -21,7 +21,6 @@ declare const ConfirmBody: z.ZodObject<{
21
21
  optional: "optional";
22
22
  }>>;
23
23
  orgs: z.ZodOptional<z.ZodArray<z.ZodString>>;
24
- pinnedSuggestions: z.ZodOptional<z.ZodArray<z.ZodString>>;
25
24
  }, z.core.$strict>;
26
25
  declare const ConfirmPermissionsBody: z.ZodObject<{
27
26
  permissionsHash: z.ZodString;
@@ -105,9 +104,8 @@ export declare class AdminCatalogController {
105
104
  * by sha256). An unknown field (the removed `deployExtension`) -> 400 `validation_failed`. A foreseeable failure (a downgrade to a version with
106
105
  * unrun migrations) is a 409 `extension.downgrade_unsupported` before anything is written.
107
106
  * Staging missing or expired -> 404 `plugin.staging_not_found`; `reviewHash` differs or the
108
- * extension on the deployment changed -> 409 `plugin.review_stale`. `pinnedSuggestions` (skill
109
- * names of the review) replaces the plugin's suggested pinning; an unknown name -> 400
110
- * `validation_failed`.
107
+ * extension on the deployment changed -> 409 `plugin.review_stale`. The removed `pinnedSuggestions`
108
+ * is an unknown field (400 `validation_failed`).
111
109
  */
112
110
  confirm(principal: Principal, stagingId: string, body: z.infer<typeof ConfirmBody>): Promise<PluginConfirmResult>;
113
111
  /**
@@ -31,8 +31,6 @@ const ConfirmBody = z
31
31
  /** The new item's scope (default `optional`); `orgs` only with `named`. */
32
32
  scope: Scope.optional(),
33
33
  orgs: Orgs.optional(),
34
- /** Skill names suggested as pinned (spec §9.1); omitted keeps the plugin's flags. */
35
- pinnedSuggestions: z.array(z.string().min(1).max(64)).max(50).optional(),
36
34
  })
37
35
  .strict();
38
36
  const ConfirmPermissionsBody = z.object({ permissionsHash: Hash }).strict();
@@ -160,9 +158,8 @@ let AdminCatalogController = class AdminCatalogController {
160
158
  * by sha256). An unknown field (the removed `deployExtension`) -> 400 `validation_failed`. A foreseeable failure (a downgrade to a version with
161
159
  * unrun migrations) is a 409 `extension.downgrade_unsupported` before anything is written.
162
160
  * Staging missing or expired -> 404 `plugin.staging_not_found`; `reviewHash` differs or the
163
- * extension on the deployment changed -> 409 `plugin.review_stale`. `pinnedSuggestions` (skill
164
- * names of the review) replaces the plugin's suggested pinning; an unknown name -> 400
165
- * `validation_failed`.
161
+ * extension on the deployment changed -> 409 `plugin.review_stale`. The removed `pinnedSuggestions`
162
+ * is an unknown field (400 `validation_failed`).
166
163
  */
167
164
  confirm(principal, stagingId, body) {
168
165
  const actor = requireUser(principal);
@@ -170,7 +167,6 @@ let AdminCatalogController = class AdminCatalogController {
170
167
  reviewHash: body.reviewHash,
171
168
  ...(body.scope !== undefined && { scope: body.scope }),
172
169
  ...(body.orgs !== undefined && { orgs: body.orgs }),
173
- ...(body.pinnedSuggestions !== undefined && { pinnedSuggestions: body.pinnedSuggestions }),
174
170
  }, actorOpts(actor));
175
171
  }
176
172
  /**
@@ -9,6 +9,7 @@ import { ExtensionsModule } from "../extensions/extensions.module.js";
9
9
  import { SuperAdminLockModule } from "../identity/super-admin.js";
10
10
  import { QueueModule } from "../infra/queue/queue.module.js";
11
11
  import { OrgLockModule } from "../orgs/org-lock.js";
12
+ import { OrgSettingsModule } from "../orgs/settings.service.js";
12
13
  import { MAINTENANCE_QUEUE_NAME } from "../runtime/maintenance-queue.js";
13
14
  import { SkillsModule } from "../skills/skills.module.js";
14
15
  import { StorageModule } from "../storage/storage.module.js";
@@ -46,6 +47,8 @@ CatalogModule = __decorate([
46
47
  ExtensionsModule,
47
48
  SuperAdminLockModule,
48
49
  OrgLockModule,
50
+ // approving a network request writes the org's sandboxEgress
51
+ OrgSettingsModule,
49
52
  StorageModule,
50
53
  SkillsModule,
51
54
  ToolsModule,
@@ -27,7 +27,14 @@ export type TranslationCode = "skill_imported" | "agent_imported"
27
27
  /** Phase D: a command that cannot become a skill (`detail.problem`). */
28
28
  | "command_invalid"
29
29
  /** Phase B only (agents were not imported); no longer emitted, kept for stored reports. */
30
- | "agent_needs_subagents" | "agent_invalid" | "agent_field_ignored" | "hooks_not_run" | "hooks_module" | "mcp_unsupported_transport" | "mcp_invalid" | "skill_invalid" | "not_applicable" | "unknown_field" | "other_harness" | "skill_ignored_restrictions" | "skill_claude_variables" | "session_start_pin_hint" | "mcp_auth_none" | "mcp_type_assumed" | "connector_not_loaded" | "agent_tools_unmapped"
30
+ | "agent_needs_subagents" | "agent_invalid" | "agent_field_ignored" | "hooks_not_run" | "hooks_module" | "mcp_unsupported_transport" | "mcp_invalid" | "skill_invalid" | "not_applicable" | "unknown_field" | "other_harness" | "skill_ignored_restrictions" | "skill_claude_variables"
31
+ /**
32
+ * The plugin runs a SessionStart hook (Capybara runs no hooks; its skills are in every agent's
33
+ * catalog; skills default-on spec §8).
34
+ */
35
+ | "session_start_hook"
36
+ /** Before skills default-on (the pinned suggestion); no longer emitted, kept for stored reports. */
37
+ | "session_start_pin_hint" | "mcp_auth_none" | "mcp_type_assumed" | "connector_not_loaded" | "agent_tools_unmapped"
31
38
  /** A pattern in `disallowedTools` disallows its whole tool (narrower, never wider). */
32
39
  | "agent_tools_narrowed" | "agent_skills_truncated"
33
40
  /** Phase D: the body has `!`command`` / ```! shell injections, which stay text. */
@@ -55,7 +62,7 @@ export interface TranslationReport {
55
62
  format: "claude-code";
56
63
  /** `.claude-plugin/plugin.json`, or null when the tree has none. */
57
64
  manifestPath: string | null;
58
- /** The plugin has a SessionStart hook: the pinned suggestion is expanded by default (§8.4). */
65
+ /** The plugin has a SessionStart hook (the report then has a `session_start_hook` item). */
59
66
  sessionStart: boolean;
60
67
  /** Items sorted by group order, then component, then name. At most {@link CLAUDE_REPORT_MAX_ITEMS} (then one "unknown_field" item named "…" with detail { more: n }). */
61
68
  items: TranslationItem[];
@@ -42,6 +42,7 @@ export const TRANSLATION_CODE_GROUP = {
42
42
  other_harness: "ignored",
43
43
  skill_ignored_restrictions: "warnings",
44
44
  skill_claude_variables: "warnings",
45
+ session_start_hook: "warnings",
45
46
  session_start_pin_hint: "warnings",
46
47
  mcp_auth_none: "warnings",
47
48
  mcp_type_assumed: "warnings",
@@ -702,7 +702,7 @@ export function translateClaudePlugin(files, o) {
702
702
  add(item("hooks_not_run", "hook", "…", { detail: { more: moreHooks } }));
703
703
  const sessionStart = events.has("SessionStart");
704
704
  if (sessionStart)
705
- add(item("session_start_pin_hint", "hook", "SessionStart"));
705
+ add(item("session_start_hook", "hook", "SessionStart"));
706
706
  // MCP servers: .mcp.json first, then each declaration; a later name replaces an earlier one.
707
707
  // A Map: an untrusted "__proto__" key must never touch an object's prototype.
708
708
  const servers = new Map();
@@ -172,7 +172,7 @@ let ComponentPromotion = class ComponentPromotion {
172
172
  if (p.kind === "skill") {
173
173
  const v = await this.db
174
174
  .selectFrom("skill_versions")
175
- .select(["manifest", "source_format", "suggest_pinned", "created_by"])
175
+ .select(["manifest", "source_format", "created_by"])
176
176
  .where("skill_id", "=", row.id)
177
177
  .where("version", "=", row.version)
178
178
  .executeTakeFirstOrThrow();
@@ -198,7 +198,6 @@ let ComponentPromotion = class ComponentPromotion {
198
198
  object_prefix: p.prefix,
199
199
  catalog_version: null,
200
200
  source_format: v.source_format,
201
- suggest_pinned: v.suggest_pinned,
202
201
  created_by: v.created_by,
203
202
  })
204
203
  .execute();
@@ -110,6 +110,15 @@ export declare function loadScopeState(db: KernelSchemaDb, kind: ComponentKind,
110
110
  id: string;
111
111
  itemId: string | null;
112
112
  }[]): Promise<ScopeState>;
113
+ /**
114
+ * Whether a catalog item is builtin: marked so and owned by the platform. An org-owned item marked
115
+ * builtin (never so in practice) is an ordinary item: never on without an install, never locked,
116
+ * and its skills can be turned off (skills default-on spec §3).
117
+ */
118
+ export declare const platformBuiltin: (item: {
119
+ builtin: boolean | null;
120
+ owner_org_id: string | null;
121
+ }) => boolean;
113
122
  /** The plugin facts of `itemId` for one org from a {@link ScopeState} (null: no plugin). */
114
123
  export declare function pluginFactsOf(st: ScopeState, itemId: string | null, orgId: string): PluginFacts | null;
115
124
  /** The org's switch of a component from a {@link ScopeState}. */
@@ -123,7 +132,10 @@ export interface DefinitionRefs {
123
132
  * one of `orgConnectors` it does not turn off as a whole.
124
133
  */
125
134
  connectors: Set<string>;
126
- /** `skills.orgSkills`, `skills.pinned` and the inline sub-agent templates' `skills`. */
135
+ /**
136
+ * The skills the agent names: the inline sub-agent templates' `skills`. Having a skill on by
137
+ * default is not using it (skills default-on spec §11), so a plugin update can remove it.
138
+ */
127
139
  skills: Set<string>;
128
140
  /** `subagents.templates`. */
129
141
  templates: Set<string>;
@@ -193,12 +193,17 @@ export async function loadScopeState(db, kind, comps) {
193
193
  if (itemIds.length > 0) {
194
194
  const items = await db
195
195
  .selectFrom("catalog_items")
196
- .select(["id", "scope", "builtin", "disabled"])
196
+ .select(["id", "scope", "builtin", "disabled", "owner_org_id"])
197
197
  .where("id", "in", itemIds)
198
198
  .where("deleted_at", "is", null)
199
199
  .execute();
200
- for (const i of items)
201
- state.plugins.set(i.id, i);
200
+ for (const i of items) {
201
+ state.plugins.set(i.id, {
202
+ scope: i.scope,
203
+ builtin: platformBuiltin(i),
204
+ disabled: i.disabled,
205
+ });
206
+ }
202
207
  const listed = await db
203
208
  .selectFrom("catalog_item_scope_orgs")
204
209
  .select(["item_id", "org_id"])
@@ -235,6 +240,12 @@ export async function loadScopeState(db, kind, comps) {
235
240
  }
236
241
  return state;
237
242
  }
243
+ /**
244
+ * Whether a catalog item is builtin: marked so and owned by the platform. An org-owned item marked
245
+ * builtin (never so in practice) is an ordinary item: never on without an install, never locked,
246
+ * and its skills can be turned off (skills default-on spec §3).
247
+ */
248
+ export const platformBuiltin = (item) => item.builtin === true && item.owner_org_id === null;
238
249
  /** The plugin facts of `itemId` for one org from a {@link ScopeState} (null: no plugin). */
239
250
  export function pluginFactsOf(st, itemId, orgId) {
240
251
  if (itemId === null)
@@ -287,8 +298,6 @@ export function definitionRefs(definition, orgConnectors = []) {
287
298
  if (typeof x === "string")
288
299
  into.add(x);
289
300
  };
290
- strings(def?.skills?.orgSkills, skills);
291
- strings(def?.skills?.pinned, skills);
292
301
  const inline = def?.subagents?.inline;
293
302
  if (Array.isArray(inline))
294
303
  for (const t of inline)
@@ -188,7 +188,7 @@ export declare function headsToResolve(entries: readonly MarketplaceEntry[], imp
188
188
  /** The host versions (an entry's `minKernel` is judged against them). */
189
189
  export declare const HOST_VERSIONS: {
190
190
  readonly kernel: string;
191
- readonly sdk: "0.1.0-rc.14";
191
+ readonly sdk: "0.1.0-rc.16";
192
192
  };
193
193
  /** Whether this deployment satisfies the entry's `minKernel`. */
194
194
  export declare const entryCompatible: (e: Pick<MarketplaceEntry, "minKernel">) => boolean;