@capybara-hq/kernel 0.1.0-rc.74 → 0.1.0-rc.76

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 (94) hide show
  1. package/bootstrap.json +3 -3
  2. package/dist/agents/readiness.controller.d.ts +4 -3
  3. package/dist/agents/readiness.controller.js +4 -3
  4. package/dist/agents/readiness.service.d.ts +44 -11
  5. package/dist/agents/readiness.service.js +59 -16
  6. package/dist/catalog/catalog-import.module.d.ts +1 -1
  7. package/dist/catalog/catalog-import.module.js +1 -1
  8. package/dist/catalog/cli.d.ts +9 -2
  9. package/dist/catalog/cli.js +10 -4
  10. package/dist/catalog/marketplaces.service.d.ts +1 -1
  11. package/dist/catalog/plugin-upgrade.d.ts +4 -2
  12. package/dist/catalog/plugin-upgrade.js +9 -3
  13. package/dist/db/kernel-schema.d.ts +5 -0
  14. package/dist/devices/device-projects.service.d.ts +3 -12
  15. package/dist/devices/device-projects.service.js +20 -63
  16. package/dist/devices/devices.service.d.ts +15 -12
  17. package/dist/devices/devices.service.js +25 -19
  18. package/dist/dial-in/machines.d.ts +3 -15
  19. package/dist/dial-in/machines.js +4 -60
  20. package/dist/extensions/bootstrap.d.ts +17 -3
  21. package/dist/extensions/bootstrap.js +56 -14
  22. package/dist/http/meta.controller.d.ts +0 -1
  23. package/dist/http/meta.controller.js +2 -6
  24. package/dist/lifecycle/kernel-lifecycle.d.ts +3 -1
  25. package/dist/lifecycle/kernel-lifecycle.js +16 -11
  26. package/dist/overrides.d.ts +0 -5
  27. package/dist/overrides.js +0 -2
  28. package/dist/platform/file-ref.d.ts +6 -5
  29. package/dist/platform/ops/agent-skills.ops.js +1 -1
  30. package/dist/platform/ops/agents.ops.js +1 -1
  31. package/dist/runtime/model-call.d.ts +2 -2
  32. package/dist/runtime/project/knowledge.d.ts +1 -1
  33. package/dist/runtime/project/knowledge.js +1 -1
  34. package/dist/runtime/project/knowledge.service.d.ts +5 -11
  35. package/dist/runtime/project/knowledge.service.js +12 -23
  36. package/dist/runtime/providers.d.ts +34 -1
  37. package/dist/runtime/providers.js +56 -7
  38. package/dist/runtime/run-steps.d.ts +4 -6
  39. package/dist/runtime/run-steps.js +7 -15
  40. package/dist/runtime/runtime.module.js +1 -1
  41. package/dist/sandbox/device-sandbox.d.ts +16 -2
  42. package/dist/sandbox/device-sandbox.js +13 -5
  43. package/dist/sandbox/held-operations.d.ts +2 -5
  44. package/dist/sandbox/held-operations.js +0 -14
  45. package/dist/sandbox/managed-device-context.d.ts +1 -1
  46. package/dist/sandbox/managed-device-context.js +1 -1
  47. package/dist/sandbox/operation-authority.js +3 -1
  48. package/dist/sandbox/permission-authority-lock.d.ts +6 -0
  49. package/dist/sandbox/permission-authority-lock.js +14 -0
  50. package/dist/sandbox/permission-context-types.d.ts +0 -11
  51. package/dist/sandbox/permission-context-types.js +0 -13
  52. package/dist/sandbox/permission-facts.d.ts +4 -0
  53. package/dist/sandbox/permission-facts.js +6 -1
  54. package/dist/sandbox/providers.d.ts +5 -0
  55. package/dist/sandbox/providers.js +1 -1
  56. package/dist/sandbox/review/permission-candidate.d.ts +12 -7
  57. package/dist/sandbox/review/permission-candidate.js +28 -7
  58. package/dist/sandbox/sandbox-file-reader.d.ts +7 -12
  59. package/dist/sandbox/sandbox-file-reader.js +12 -29
  60. package/dist/sandbox/sandbox.service.d.ts +53 -32
  61. package/dist/sandbox/sandbox.service.js +217 -141
  62. package/dist/sandbox/use-context.d.ts +4 -1
  63. package/dist/setup/setup-guides.service.d.ts +1 -2
  64. package/dist/setup/setup-guides.service.js +1 -4
  65. package/dist/shares/sweep.job.d.ts +2 -0
  66. package/dist/shares/sweep.job.js +3 -1
  67. package/dist/skills/invoke.d.ts +13 -35
  68. package/dist/skills/invoke.js +23 -162
  69. package/dist/tools/builtins/builtin-tools.d.ts +2 -11
  70. package/dist/tools/builtins/builtin-tools.js +5 -23
  71. package/dist/tools/builtins/image/generate.js +2 -2
  72. package/dist/tools/builtins/sandbox/common.d.ts +32 -80
  73. package/dist/tools/builtins/sandbox/common.js +61 -173
  74. package/dist/tools/builtins/sandbox/deliver.js +2 -2
  75. package/dist/tools/builtins/sandbox/device-owner.d.ts +4 -5
  76. package/dist/tools/builtins/sandbox/device-owner.js +5 -6
  77. package/dist/tools/builtins/sandbox/fetch-attachment.js +2 -2
  78. package/dist/tools/builtins/sandbox/glob.js +1 -1
  79. package/dist/tools/builtins/sandbox/grep.js +1 -1
  80. package/dist/tools/builtins/sandbox/index.d.ts +2 -2
  81. package/dist/tools/builtins/sandbox/index.js +2 -2
  82. package/dist/tools/builtins/sandbox/read.js +1 -1
  83. package/dist/tools/builtins/sandbox/task-output.d.ts +3 -3
  84. package/dist/tools/builtins/sandbox/task-output.js +4 -4
  85. package/dist/tools/builtins/sandbox/task-stop.js +1 -1
  86. package/dist/tools/builtins/skill-load.js +2 -2
  87. package/dist/tools/connectors.service.d.ts +4 -2
  88. package/dist/tools/connectors.service.js +15 -3
  89. package/dist/tools/pipeline.d.ts +0 -2
  90. package/dist/tools/pipeline.js +7 -14
  91. package/dist/tools/tools.module.js +1 -1
  92. package/package.json +2 -2
  93. package/src/migrations/0179_device_report_limit_text.sql +28 -0
  94. package/src/migrations/0180_device_instance_abandoned.sql +6 -0
@@ -3,12 +3,10 @@ import { type AgentDefinition } from "../agents/definition.js";
3
3
  import { EventLog } from "../conversations/event-log.js";
4
4
  import type { EventPayload } from "../conversations/events.js";
5
5
  import type { KernelSchemaDb } from "../db/kernel-schema.js";
6
- import { ConversationDevices } from "../devices/conversation-devices.js";
7
6
  import { ApiError } from "../errors.js";
8
7
  import { KernelDb } from "../infra/database/kernel-db.js";
9
8
  import type { KernelLogger } from "../log.js";
10
9
  import { type ProjectRootPayload } from "../runtime/context/project-root.js";
11
- import { SandboxService } from "../sandbox/sandbox.service.js";
12
10
  import { StorageService } from "../storage/storage.service.js";
13
11
  import { type ResolvedSkill } from "./catalog.js";
14
12
  /**
@@ -103,12 +101,12 @@ export declare function recordedSkillBlocked(db: KernelSchemaDb, a: {
103
101
  /** The model-visible text of a fork invocation in the parent's log (spec §6.3, frozen). */
104
102
  export declare const forkLeadText: (name: string, agentType: string, args: string) => string;
105
103
  /**
106
- * A person's `/project:<name>` invocation once the activation gate is on (permission activation
107
- * L2, Hook 2): no device read at send time (a person's send has no run, so nothing could admit
108
- * it). The message is a stub rendered from the conversation's latest `project_root` (the skill's
109
- * name, its recorded digest, its directory in the project and the person's arguments) telling the
110
- * agent to load `project:<name>` with its `Skill` tool, which reads it under the run's admission.
111
- * Model-visible, so English; tags in the arguments stay inert. Always inline, as before.
104
+ * A person's `/project:<name>` invocation (permission activation L2, Hook 2): no device read at
105
+ * send time (a person's send has no run, so nothing could admit it). The message is a stub
106
+ * rendered from the conversation's latest `project_root` (the skill's name, its recorded digest,
107
+ * its directory in the project and the person's arguments) telling the agent to load
108
+ * `project:<name>` with its `Skill` tool, which reads it under the run's admission. Model-visible,
109
+ * so English; tags in the arguments stay inert. Always inline, as before.
112
110
  */
113
111
  export declare function projectSkillStub(a: {
114
112
  name: string;
@@ -128,18 +126,9 @@ export declare class SkillInvoker {
128
126
  private readonly log;
129
127
  /** A bound conversation's latest `project_root` (its project skills). */
130
128
  private readonly eventLog;
131
- /** A project skill's SKILL.md is read through the conversation's device. */
132
- private readonly sandbox;
133
- private readonly devices;
134
- /** The paired activation gate: once on, no raw device use reads a project skill. */
135
- private readonly activation?;
136
129
  constructor(db: KernelDb, storage: StorageService, agents: Pick<AgentLookup, "get">, log: KernelLogger,
137
130
  /** A bound conversation's latest `project_root` (its project skills). */
138
- eventLog: Pick<EventLog, "latestOfType">,
139
- /** A project skill's SKILL.md is read through the conversation's device. */
140
- sandbox: Pick<SandboxService, "withSandbox">, devices: Pick<ConversationDevices, "forTool" | "modeLevel" | "workingFacts">,
141
- /** The paired activation gate: once on, no raw device use reads a project skill. */
142
- activation?: boolean | undefined);
131
+ eventLog: Pick<EventLog, "latestOfType">);
143
132
  /**
144
133
  * The `/` menu for `accountId`: the agent must be usable by them (`agent.not_found`), and with
145
134
  * `conversationId` the conversation must be theirs and the agent's (`conversation.not_found`);
@@ -177,25 +166,14 @@ export declare class SkillInvoker {
177
166
  }): Promise<RenderedInvocation>;
178
167
  /**
179
168
  * A person's invocation of `project:<name>` (project root spec §4.6): resolved from the
180
- * conversation's latest `project_root` (what the model saw), then its SKILL.md is read through
181
- * the conversation's device as `Skill` reads it ({@link readProjectSkill}) and rendered like any
182
- * invocation, `${CLAUDE_SKILL_DIR}` being the skill's directory in the project. Always inline
183
- * (`context: fork` is not honoured for project skills, as in `Skill`). Refusals:
184
- * `skill.not_invocable` `not_found` (no conversation yet, no project, a name it does not list),
185
- * `skill.project_unavailable` with its reason (the latest project is unavailable, or its file
186
- * cannot be used), the device's own refusals as they are (`device.offline`, ...),
187
- * `device.projects_unavailable` when the device cannot be asked. Once the activation gate is on
188
- * the device is not read at send time: the invocation is the recorded stub
189
- * ({@link projectSkillStub}) and only the first two refusals remain, plus
190
- * `skill.project_unavailable` `skill_tool_off` for an agent without the `Skill` tool.
169
+ * conversation's latest `project_root` (what the model saw). The device is not read at send
170
+ * time: the invocation is the recorded stub ({@link projectSkillStub}), which the agent's
171
+ * `Skill` tool loads. Refusals: `skill.not_invocable` `not_found` (no conversation yet, no
172
+ * project, a name it does not list), `skill.project_unavailable` with its reason (the latest
173
+ * project is unavailable), and `skill.project_unavailable` `skill_tool_off` for an agent without
174
+ * the `Skill` tool.
191
175
  */
192
176
  private prepareProject;
193
- /**
194
- * {@link readProjectSkill} in a silent use of the conversation's device, as its owner (gate off
195
- * only: once activated a person's invocation renders {@link projectSkillStub} and never reads
196
- * the device at send time).
197
- */
198
- private readProjectFile;
199
177
  /**
200
178
  * The task of a fork invocation's sub-agent (spec §6.2), rendered at dispatch from the version
201
179
  * the person's message recorded (`skill.{id, source, version, arguments}`), never by name, so a
@@ -7,26 +7,20 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __param = (this && this.__param) || function (paramIndex, decorator) {
8
8
  return function (target, key) { decorator(target, key, paramIndex); }
9
9
  };
10
- import { escapeSkillInvocationTags, hasShellInjection, parseSkillMd, renderSkillBody, renderSkillInvocation, SKILL_ENTRY_FILE, SKILL_INVOCATION_LIMITS, skillDigest, skillSandboxDir, } from "@capybara-hq/plugin-sdk";
11
- import { Inject, Injectable, Optional } from "@nestjs/common";
10
+ import { escapeSkillInvocationTags, hasShellInjection, parseSkillMd, renderSkillBody, renderSkillInvocation, SKILL_ENTRY_FILE, SKILL_INVOCATION_LIMITS, skillDigest, } from "@capybara-hq/plugin-sdk";
11
+ import { Inject, Injectable } from "@nestjs/common";
12
12
  import { AgentLookup } from "../agents/agent-lookup.js";
13
13
  import { builtinDisabled } from "../agents/definition.js";
14
14
  import { EventLog } from "../conversations/event-log.js";
15
- import { ConversationDevices } from "../devices/conversation-devices.js";
16
- import { providerUnreachable } from "../devices/device-projects.service.js";
17
15
  import { ApiError } from "../errors.js";
18
16
  import { KernelDb } from "../infra/database/kernel-db.js";
19
17
  import { KERNEL_LOGGER } from "../infra/tokens.js";
20
18
  import { callableProjectSkills, projectSkillName, projectSkillOf, } from "../runtime/context/project-root.js";
21
19
  import { isGeneralAlias, resolveSkillForkType } from "../runtime/subagents/roster.js";
22
20
  import { PROJECT_SKILLS_DIR } from "../sandbox/kernel-read.js";
23
- import { PERMISSION_CONTEXT_ACTIVATION, permissionContextActive, } from "../sandbox/permission-context-types.js";
24
- import { SandboxService } from "../sandbox/sandbox.service.js";
25
- import { SandboxProviderUnreachableError } from "../sandbox/unreachable.js";
26
21
  import { StorageService } from "../storage/storage.service.js";
27
22
  import { BUILTIN } from "../tools/builtin-names.js";
28
- import { sessionPathBound, sessionWorkingRoot } from "../tools/builtins/sandbox/common.js";
29
- import { findSkillVersion, PROJECT_DIR_DIGEST, ProjectSkillReadError, readProjectSkill, readSkillFile, SkillIntegrityError, } from "../tools/builtins/skill-load.js";
23
+ import { findSkillVersion, readSkillFile, SkillIntegrityError, } from "../tools/builtins/skill-load.js";
30
24
  import { invocationOf, resolveSkills } from "./catalog.js";
31
25
  import { skillFileStore } from "./usable.js";
32
26
  /** A leading `/<name>` or `/<plugin>:<name>`, then whitespace or the end (spec §3.2). */
@@ -55,21 +49,6 @@ export const notInvocable = (reason, name) => new ApiError("skill.not_invocable"
55
49
  : `Skill "${name}" cannot be invoked by a person`, [{ reason }]);
56
50
  /** A project skill the project lists but cannot be used now: the person is told why. */
57
51
  const projectUnavailable = (reason, message) => new ApiError("skill.project_unavailable", message, [{ reason }]);
58
- /** The refusal of a {@link ProjectSkillProblem}: its reason and the person's text. */
59
- function projectProblemRefusal(name, p) {
60
- switch (p.kind) {
61
- case "outside_mode":
62
- return projectUnavailable("outside_mode", `Skill "${name}" cannot be invoked: ${p.path} is outside what the device can read in ${p.mode} mode now`);
63
- case "gone":
64
- return projectUnavailable("gone", `Skill "${name}" cannot be invoked: ${p.path} is no longer on the device`);
65
- case "read_failed":
66
- return projectUnavailable("unreadable", `Skill "${name}" cannot be invoked: reading ${p.path} on the device failed (${p.why.slice(0, 300)})`);
67
- case "invalid":
68
- return projectUnavailable("unparsable", `Skill "${name}" cannot be invoked: ${p.path} is not a valid SKILL.md (${p.why.slice(0, 300)})`);
69
- }
70
- }
71
- /** The longest a person's invocation waits for its project skill's SKILL.md on the device. */
72
- const PROJECT_SKILL_READ_TIMEOUT_MS = 30_000;
73
52
  /** Where an effective skill comes from, for the `/` menu ({@link InvocableSource}). */
74
53
  export const invocableSource = (r) => r.scope === "agent" ? "agent" : r.skill.plugin !== undefined ? "plugin" : "platform";
75
54
  /**
@@ -130,12 +109,12 @@ export async function recordedSkillBlocked(db, a) {
130
109
  /** The model-visible text of a fork invocation in the parent's log (spec §6.3, frozen). */
131
110
  export const forkLeadText = (name, agentType, args) => escapeSkillInvocationTags(`The user ran the skill "${name}" in a sub-agent (${agentType}) with /${name}${args === "" ? "" : ` ${args}`}. The sub-agent gets the skill's instructions as its task; its report follows. Do not do the task yourself.`);
132
111
  /**
133
- * A person's `/project:<name>` invocation once the activation gate is on (permission activation
134
- * L2, Hook 2): no device read at send time (a person's send has no run, so nothing could admit
135
- * it). The message is a stub rendered from the conversation's latest `project_root` (the skill's
136
- * name, its recorded digest, its directory in the project and the person's arguments) telling the
137
- * agent to load `project:<name>` with its `Skill` tool, which reads it under the run's admission.
138
- * Model-visible, so English; tags in the arguments stay inert. Always inline, as before.
112
+ * A person's `/project:<name>` invocation (permission activation L2, Hook 2): no device read at
113
+ * send time (a person's send has no run, so nothing could admit it). The message is a stub
114
+ * rendered from the conversation's latest `project_root` (the skill's name, its recorded digest,
115
+ * its directory in the project and the person's arguments) telling the agent to load
116
+ * `project:<name>` with its `Skill` tool, which reads it under the run's admission. Model-visible,
117
+ * so English; tags in the arguments stay inert. Always inline, as before.
139
118
  */
140
119
  export function projectSkillStub(a, latest, bare) {
141
120
  const skill = latest.skills.find((s) => s.name === bare);
@@ -182,24 +161,14 @@ let SkillInvoker = class SkillInvoker {
182
161
  agents;
183
162
  log;
184
163
  eventLog;
185
- sandbox;
186
- devices;
187
- activation;
188
164
  constructor(db, storage, agents, log,
189
165
  /** A bound conversation's latest `project_root` (its project skills). */
190
- eventLog,
191
- /** A project skill's SKILL.md is read through the conversation's device. */
192
- sandbox, devices,
193
- /** The paired activation gate: once on, no raw device use reads a project skill. */
194
- activation) {
166
+ eventLog) {
195
167
  this.db = db;
196
168
  this.storage = storage;
197
169
  this.agents = agents;
198
170
  this.log = log;
199
171
  this.eventLog = eventLog;
200
- this.sandbox = sandbox;
201
- this.devices = devices;
202
- this.activation = activation;
203
172
  }
204
173
  /**
205
174
  * The `/` menu for `accountId`: the agent must be usable by them (`agent.not_found`), and with
@@ -230,8 +199,8 @@ let SkillInvoker = class SkillInvoker {
230
199
  });
231
200
  if (conversationId === undefined)
232
201
  return skills;
233
- // once activated a project skill is loaded by the agent's Skill tool: none without it
234
- if (permissionContextActive(this.activation) && !hasBuiltin(agent.definition, BUILTIN.Skill))
202
+ // a project skill is loaded by the agent's Skill tool: none without it
203
+ if (!hasBuiltin(agent.definition, BUILTIN.Skill))
235
204
  return skills;
236
205
  const latest = await this.eventLog.latestOfType(conversationId, "project_root");
237
206
  return [...skills, ...projectInvocables(latest?.payload)];
@@ -327,17 +296,12 @@ let SkillInvoker = class SkillInvoker {
327
296
  }
328
297
  /**
329
298
  * A person's invocation of `project:<name>` (project root spec §4.6): resolved from the
330
- * conversation's latest `project_root` (what the model saw), then its SKILL.md is read through
331
- * the conversation's device as `Skill` reads it ({@link readProjectSkill}) and rendered like any
332
- * invocation, `${CLAUDE_SKILL_DIR}` being the skill's directory in the project. Always inline
333
- * (`context: fork` is not honoured for project skills, as in `Skill`). Refusals:
334
- * `skill.not_invocable` `not_found` (no conversation yet, no project, a name it does not list),
335
- * `skill.project_unavailable` with its reason (the latest project is unavailable, or its file
336
- * cannot be used), the device's own refusals as they are (`device.offline`, ...),
337
- * `device.projects_unavailable` when the device cannot be asked. Once the activation gate is on
338
- * the device is not read at send time: the invocation is the recorded stub
339
- * ({@link projectSkillStub}) and only the first two refusals remain, plus
340
- * `skill.project_unavailable` `skill_tool_off` for an agent without the `Skill` tool.
299
+ * conversation's latest `project_root` (what the model saw). The device is not read at send
300
+ * time: the invocation is the recorded stub ({@link projectSkillStub}), which the agent's
301
+ * `Skill` tool loads. Refusals: `skill.not_invocable` `not_found` (no conversation yet, no
302
+ * project, a name it does not list), `skill.project_unavailable` with its reason (the latest
303
+ * project is unavailable), and `skill.project_unavailable` `skill_tool_off` for an agent without
304
+ * the `Skill` tool.
341
305
  */
342
306
  async prepareProject(a, bare) {
343
307
  const { conversationId } = a;
@@ -350,109 +314,10 @@ let SkillInvoker = class SkillInvoker {
350
314
  if (projectSkillBlocked(latest, a.name) !== null || latest === undefined) {
351
315
  throw notInvocable("not_found", a.name);
352
316
  }
353
- // once activated: no device read at send time, the agent loads the skill with Skill
354
- if (permissionContextActive(this.activation)) {
355
- if (!hasBuiltin(a.agent, BUILTIN.Skill))
356
- throw projectUnavailable("skill_tool_off", `Skill "${a.name}" cannot be invoked: this agent cannot load project skills; turn on its ${BUILTIN.Skill} tool`);
357
- return projectSkillStub(a, latest, bare);
358
- }
359
- const file = await this.readProjectFile({ ...a, conversationId }, latest.root, bare);
360
- const args = a.args.trim();
361
- // the renderer's skills-root directory becomes the skill's directory in the project (a closing
362
- // tag in the path stays inert, as in the body)
363
- const dir = file.dir.replace(/<\//g, "<\\/");
364
- const text = rendered(() => renderSkillInvocation({
365
- name: a.name,
366
- skillName: bare,
367
- digest: PROJECT_DIR_DIGEST,
368
- version: 0,
369
- body: file.body,
370
- invocation: file.invocation,
371
- args: a.args,
372
- lines: {
373
- ...(hasShellInjection(file.body) &&
374
- hasBuiltin(a.agent, BUILTIN.Bash) && { shellHint: true }),
375
- },
376
- })).replaceAll(skillSandboxDir(bare, PROJECT_DIR_DIGEST), dir);
377
- const full = [
378
- text,
379
- ...(file.truncated
380
- ? [
381
- `Its SKILL.md was cut at 1 MiB when it was read; the rest of its instructions is missing.`,
382
- ]
383
- : []),
384
- `Its other files, if any, are in ${dir}/ on the device; use them there.`,
385
- ].join("\n\n");
386
- // the closing lines count toward the limit too
387
- if (full.length > SKILL_INVOCATION_LIMITS.renderedMaxChars) {
388
- throw new ApiError("validation_failed", "Request validation failed", [
389
- {
390
- path: "text",
391
- message: `the rendered skill must be at most ${SKILL_INVOCATION_LIMITS.renderedMaxChars} characters; shorten the arguments`,
392
- },
393
- ]);
394
- }
395
- return {
396
- text: full,
397
- skill: {
398
- id: a.name,
399
- version: 0,
400
- source: "project",
401
- name: a.name,
402
- arguments: args,
403
- mode: "inline",
404
- },
405
- };
406
- }
407
- /**
408
- * {@link readProjectSkill} in a silent use of the conversation's device, as its owner (gate off
409
- * only: once activated a person's invocation renders {@link projectSkillStub} and never reads
410
- * the device at send time).
411
- */
412
- async readProjectFile(a, root, bare) {
413
- try {
414
- const deviceId = await this.devices.forTool(a.orgId, a.conversationId);
415
- // a person invokes in a root conversation: it is its own sandbox conversation
416
- const [level, working] = await Promise.all([
417
- this.devices.modeLevel(a.orgId, deviceId),
418
- this.devices.workingFacts(a.orgId, a.conversationId, a.conversationId, deviceId),
419
- ]);
420
- // unknown mode: the strict (sandbox) path checks stay (fail closed), as in a tool call
421
- const mode = level?.mode ?? "sandbox";
422
- return await this.sandbox.withSandbox({
423
- orgId: a.orgId,
424
- deviceId,
425
- holderConversationId: a.conversationId,
426
- // tells the model nothing: its next tool call still learns what the device did
427
- silent: true,
428
- actor: { accountId: a.accountId, conversationId: a.conversationId },
429
- }, (h, p, info, signal) => readProjectSkill({
430
- deviceId,
431
- // the legacy route (gate off): the fixed roots unless the device runs in auto mode
432
- pathBound: sessionPathBound(false, mode),
433
- h,
434
- roots: info.roots,
435
- // the working root a tool call of this conversation would get (one rule)
436
- workingRoot: sessionWorkingRoot(working, info.roots.workspace),
437
- p,
438
- signal,
439
- }, root, bare), AbortSignal.timeout(PROJECT_SKILL_READ_TIMEOUT_MS));
440
- }
441
- catch (e) {
442
- if (e instanceof ProjectSkillReadError)
443
- throw projectProblemRefusal(a.name, e.problem);
444
- if (e instanceof ApiError)
445
- throw e;
446
- if (e instanceof SandboxProviderUnreachableError)
447
- throw providerUnreachable();
448
- this.log.warn("project skill unreadable: the device could not be asked", {
449
- orgId: a.orgId,
450
- conversationId: a.conversationId,
451
- skill: a.name,
452
- err: e,
453
- });
454
- throw new ApiError("device.projects_unavailable", "The device could not be reached to read the project skill; retry later");
455
- }
317
+ // no device read at send time: the agent loads the skill with Skill
318
+ if (!hasBuiltin(a.agent, BUILTIN.Skill))
319
+ throw projectUnavailable("skill_tool_off", `Skill "${a.name}" cannot be invoked: this agent cannot load project skills; turn on its ${BUILTIN.Skill} tool`);
320
+ return projectSkillStub(a, latest, bare);
456
321
  }
457
322
  /**
458
323
  * The task of a fork invocation's sub-agent (spec §6.2), rendered at dispatch from the version
@@ -556,11 +421,7 @@ SkillInvoker = __decorate([
556
421
  __param(1, Inject(StorageService)),
557
422
  __param(2, Inject(AgentLookup)),
558
423
  __param(3, Inject(KERNEL_LOGGER)),
559
- __param(4, Inject(EventLog)),
560
- __param(5, Inject(SandboxService)),
561
- __param(6, Inject(ConversationDevices)),
562
- __param(7, Optional()),
563
- __param(7, Inject(PERMISSION_CONTEXT_ACTIVATION))
424
+ __param(4, Inject(EventLog))
564
425
  ], SkillInvoker);
565
426
  export { SkillInvoker };
566
427
  /**
@@ -18,13 +18,12 @@ import { SealedInputs } from "../../platform/sealed-inputs.js";
18
18
  import type { HookRunner } from "../../runtime/hook-calls.js";
19
19
  import { ProviderRegistry } from "../../runtime/providers.js";
20
20
  import { StepLog } from "../../runtime/step-log.js";
21
- import { type ManagedDeviceContextPort, ManagedDeviceContextRecorder } from "../../sandbox/managed-device-context.js";
21
+ import { ManagedDeviceContextRecorder } from "../../sandbox/managed-device-context.js";
22
22
  import { SandboxService } from "../../sandbox/sandbox.service.js";
23
23
  import { ScheduledTaskStore } from "../../schedules/store.js";
24
24
  import { StorageService } from "../../storage/storage.service.js";
25
25
  import { ToolOutputs } from "../outputs.js";
26
26
  import type { BuiltinCallContext, BuiltinTool } from "../registry.js";
27
- import type { SandboxToolDeps } from "./sandbox/common.js";
28
27
  import { ScheduleToolsPort, ScheduleUpdates } from "./schedules.js";
29
28
  import { WebPages } from "./web/index.js";
30
29
  /**
@@ -54,18 +53,10 @@ export declare class BuiltinTools {
54
53
  images: ModelImages, providers: ProviderRegistry,
55
54
  /** The clock `CurrentTime` reads (the run context's clock seam; `Date.now` by default). */
56
55
  /** The managed sandbox route's device context writer (permission context replay spec B3). */
57
- managedDeviceContext: ManagedDeviceContextRecorder, now?: () => number,
58
- /** The paired activation gate (one switch with the runtime's request boundary). */
59
- activation?: boolean);
56
+ managedDeviceContext: ManagedDeviceContextRecorder, now?: () => number);
60
57
  /** The builtin tools, in a fixed order. */
61
58
  list(): readonly BuiltinTool[];
62
59
  }
63
- /**
64
- * The managed device context fields of the builtin sandbox tools' deps (spec B3): the injected
65
- * writer, required, only when the one activation gate is on; otherwise no keys at all, and the
66
- * legacy writer stays.
67
- */
68
- export declare function managedSandboxDeps(recorder: ManagedDeviceContextPort, activation: boolean | undefined): Pick<SandboxToolDeps, "managedDeviceContext" | "managedDeviceContextRequired">;
69
60
  /**
70
61
  * Whether "the chat model" of a `Read` call can view images (vision-read design §1.2): the model
71
62
  * of the latest `model_call` of the call's run (a fallback step's model when the step fell back),
@@ -33,8 +33,7 @@ import { SealedInputs } from "../../platform/sealed-inputs.js";
33
33
  import { ProviderListError, ProviderRegistry } from "../../runtime/providers.js";
34
34
  import { conversationTimeZone, RUN_CONTEXT_CLOCK } from "../../runtime/run-context.service.js";
35
35
  import { StepLog } from "../../runtime/step-log.js";
36
- import { ManagedDeviceContextRecorder, } from "../../sandbox/managed-device-context.js";
37
- import { PERMISSION_CONTEXT_ACTIVATION, permissionContextActive, } from "../../sandbox/permission-context-types.js";
36
+ import { ManagedDeviceContextRecorder } from "../../sandbox/managed-device-context.js";
38
37
  import { SandboxService } from "../../sandbox/sandbox.service.js";
39
38
  import { ScheduledTaskStore } from "../../schedules/store.js";
40
39
  import { StorageService } from "../../storage/storage.service.js";
@@ -77,12 +76,7 @@ let BuiltinTools = class BuiltinTools {
77
76
  images, providers,
78
77
  /** The clock `CurrentTime` reads (the run context's clock seam; `Date.now` by default). */
79
78
  /** The managed sandbox route's device context writer (permission context replay spec B3). */
80
- managedDeviceContext, now,
81
- /** The paired activation gate (one switch with the runtime's request boundary). */
82
- activation) {
83
- // dormant: the builtins keep the legacy route until the paired activation turns the gate on;
84
- // then every builtin entering a device (the skill tool too) takes the managed route
85
- const managed = managedSandboxDeps(managedDeviceContext, activation);
79
+ managedDeviceContext, now) {
86
80
  // `Read` beyond the device (vision-read design §1): files by id, the vision read with its
87
81
  // hooks (as the WebFetch extraction), the stored copies and the chat model's capabilities
88
82
  const vision = { purposes, eventLog, stepLog, config, log, hooks: host?.hooks };
@@ -112,7 +106,7 @@ let BuiltinTools = class BuiltinTools {
112
106
  eventLog,
113
107
  config,
114
108
  log,
115
- ...managed,
109
+ managedDeviceContext,
116
110
  read,
117
111
  };
118
112
  this.tools = [
@@ -135,7 +129,7 @@ let BuiltinTools = class BuiltinTools {
135
129
  attachments,
136
130
  eventLog,
137
131
  log,
138
- ...managed,
132
+ managedDeviceContext,
139
133
  get db() {
140
134
  return db.db;
141
135
  },
@@ -265,21 +259,9 @@ BuiltinTools = __decorate([
265
259
  __param(26, Inject(ProviderRegistry)),
266
260
  __param(27, Inject(ManagedDeviceContextRecorder)),
267
261
  __param(28, Optional()),
268
- __param(28, Inject(RUN_CONTEXT_CLOCK)),
269
- __param(29, Optional()),
270
- __param(29, Inject(PERMISSION_CONTEXT_ACTIVATION))
262
+ __param(28, Inject(RUN_CONTEXT_CLOCK))
271
263
  ], BuiltinTools);
272
264
  export { BuiltinTools };
273
- /**
274
- * The managed device context fields of the builtin sandbox tools' deps (spec B3): the injected
275
- * writer, required, only when the one activation gate is on; otherwise no keys at all, and the
276
- * legacy writer stays.
277
- */
278
- export function managedSandboxDeps(recorder, activation) {
279
- if (!permissionContextActive(activation))
280
- return {};
281
- return { managedDeviceContext: recorder, managedDeviceContextRequired: true };
282
- }
283
265
  /**
284
266
  * Whether "the chat model" of a `Read` call can view images (vision-read design §1.2): the model
285
267
  * of the latest `model_call` of the call's run (a fallback step's model when the step fell back),
@@ -442,8 +442,8 @@ async function recordDenial(deps, ctx, runId, verdict) {
442
442
  /**
443
443
  * Writes the images into the call's device at `filePath` (several: `-1`, `-2`… before the
444
444
  * extension, {@link generateImagePaths}) with `Write`'s checks (spec §5.3): the device entry every
445
- * builtin takes ({@link inToolSandbox}: the managed route and its marked device paths once
446
- * activated), each path checked as `Write` checks it, and under its path lease a directory refused
445
+ * builtin takes ({@link inToolSandbox}: the managed route and its marked device paths),
446
+ * each path checked as `Write` checks it, and under its path lease a directory refused
447
447
  * and an existing file replaced only when this conversation read it and it is unchanged
448
448
  * ({@link assertReadAndUnchanged}). The images are already delivered, so a copy that cannot be made
449
449
  * is a line of the result, not a tool error: no device, or the reason the copy stopped, after the