@capybara-hq/kernel 0.1.0-rc.66 → 0.1.0-rc.67

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 (139) hide show
  1. package/bootstrap.json +0 -8
  2. package/dist/admin/admin.schemas.d.ts +3 -0
  3. package/dist/agents/admin-agents.d.ts +2 -2
  4. package/dist/agents/admin-agents.js +2 -1
  5. package/dist/agents/agent-lookup.js +2 -1
  6. package/dist/agents/agent-profile.service.d.ts +5 -2
  7. package/dist/agents/agent-profile.service.js +13 -2
  8. package/dist/agents/agents.controller.d.ts +4 -3
  9. package/dist/agents/agents.controller.js +7 -3
  10. package/dist/agents/agents.module.js +3 -0
  11. package/dist/agents/agents.schemas.d.ts +6 -6
  12. package/dist/agents/agents.service.d.ts +23 -2
  13. package/dist/agents/agents.service.js +61 -6
  14. package/dist/agents/avatar-view.d.ts +8 -0
  15. package/dist/agents/avatar-view.js +12 -0
  16. package/dist/agents/profile.d.ts +38 -13
  17. package/dist/agents/profile.js +31 -20
  18. package/dist/background/poll.job.d.ts +1 -1
  19. package/dist/background/poll.job.js +8 -6
  20. package/dist/background/tasks.service.js +1 -1
  21. package/dist/catalog/marketplaces.service.d.ts +1 -1
  22. package/dist/channels/inbound.d.ts +2 -3
  23. package/dist/channels/inbound.js +2 -3
  24. package/dist/channels/phrases.d.ts +3 -3
  25. package/dist/channels/phrases.js +3 -3
  26. package/dist/config/schema.d.ts +1 -0
  27. package/dist/config/schema.js +14 -1
  28. package/dist/conversations/conversations.service.d.ts +4 -3
  29. package/dist/conversations/conversations.service.js +4 -2
  30. package/dist/ctx/create-ctx.js +5 -2
  31. package/dist/ctx/device-provider-check.d.ts +7 -0
  32. package/dist/ctx/device-provider-check.js +21 -0
  33. package/dist/db/kernel-schema.d.ts +7 -0
  34. package/dist/devices/access.d.ts +16 -46
  35. package/dist/devices/access.js +26 -62
  36. package/dist/devices/access.module.js +2 -2
  37. package/dist/devices/conversation-devices.d.ts +38 -18
  38. package/dist/devices/conversation-devices.js +69 -51
  39. package/dist/devices/default-provider-setting.d.ts +45 -0
  40. package/dist/devices/default-provider-setting.js +59 -0
  41. package/dist/devices/device-projects.service.js +7 -2
  42. package/dist/devices/device-provider-selection.d.ts +37 -0
  43. package/dist/devices/device-provider-selection.js +86 -0
  44. package/dist/devices/device-provider-selection.module.d.ts +3 -0
  45. package/dist/devices/device-provider-selection.module.js +22 -0
  46. package/dist/devices/devices.controller.d.ts +8 -5
  47. package/dist/devices/devices.controller.js +7 -4
  48. package/dist/devices/devices.module.js +3 -1
  49. package/dist/devices/devices.schemas.js +2 -2
  50. package/dist/devices/devices.service.d.ts +72 -83
  51. package/dist/devices/devices.service.js +139 -248
  52. package/dist/devices/dto.d.ts +9 -0
  53. package/dist/devices/dto.js +15 -2
  54. package/dist/devices/label.d.ts +3 -5
  55. package/dist/devices/label.js +3 -14
  56. package/dist/devices/legacy-cleanup.job.d.ts +2 -2
  57. package/dist/devices/legacy-cleanup.job.js +6 -6
  58. package/dist/errors.d.ts +15 -1
  59. package/dist/errors.js +15 -1
  60. package/dist/extensions/guide-places.d.ts +2 -1
  61. package/dist/extensions/guide-places.js +8 -2
  62. package/dist/extensions/locks.d.ts +1 -1
  63. package/dist/extensions/locks.js +1 -1
  64. package/dist/extensions/org-config.d.ts +20 -4
  65. package/dist/extensions/org-config.js +23 -6
  66. package/dist/extensions/permission-view.d.ts +2 -2
  67. package/dist/extensions/permission-view.js +2 -2
  68. package/dist/extensions/plugin-guides.d.ts +1 -1
  69. package/dist/extensions/plugin-guides.js +11 -3
  70. package/dist/extensions/point-defaults.d.ts +14 -0
  71. package/dist/extensions/point-defaults.js +70 -47
  72. package/dist/extensions/resolve.js +7 -2
  73. package/dist/identity/settings.d.ts +8 -0
  74. package/dist/identity/settings.js +24 -1
  75. package/dist/infra/config/kernel-config.service.js +2 -0
  76. package/dist/lifecycle/kernel-lifecycle.js +7 -6
  77. package/dist/local-devices/device-routes.d.ts +1 -1
  78. package/dist/local-devices/device-routes.js +1 -1
  79. package/dist/local-devices/local-device-provider.d.ts +14 -11
  80. package/dist/local-devices/local-device-provider.js +14 -0
  81. package/dist/local-devices/local-devices.module.d.ts +4 -4
  82. package/dist/local-devices/local-devices.module.js +5 -3
  83. package/dist/local-devices/owner-report.js +2 -1
  84. package/dist/local-devices/targets.d.ts +2 -0
  85. package/dist/local-devices/targets.js +10 -0
  86. package/dist/orgs/settings.service.d.ts +26 -1
  87. package/dist/orgs/settings.service.js +44 -3
  88. package/dist/platform/ops/admin.ops.js +8 -3
  89. package/dist/platform/ops/agents.ops.d.ts +6 -1
  90. package/dist/platform/ops/agents.ops.js +38 -11
  91. package/dist/platform/ops/devices.ops.js +25 -20
  92. package/dist/platform/ops/orgs.ops.js +1 -0
  93. package/dist/platform/ops/themes.ops.js +1 -1
  94. package/dist/runtime/plugin-context.service.js +1 -12
  95. package/dist/sandbox/cloud-permission-snapshot.d.ts +2 -2
  96. package/dist/sandbox/cloud-permission-snapshot.js +3 -3
  97. package/dist/sandbox/device-reports.d.ts +50 -0
  98. package/dist/sandbox/device-reports.js +157 -0
  99. package/dist/sandbox/held-operations.d.ts +8 -8
  100. package/dist/sandbox/leases.d.ts +1 -1
  101. package/dist/sandbox/leases.js +1 -1
  102. package/dist/sandbox/operation-authority.d.ts +5 -2
  103. package/dist/sandbox/operation-authority.js +12 -11
  104. package/dist/sandbox/operation-reconcile.job.d.ts +2 -2
  105. package/dist/sandbox/operation-reconcile.job.js +5 -5
  106. package/dist/sandbox/permission-availability.d.ts +2 -2
  107. package/dist/sandbox/permission-call-types.d.ts +5 -0
  108. package/dist/sandbox/permission-facts.d.ts +2 -2
  109. package/dist/sandbox/permission-facts.js +5 -5
  110. package/dist/sandbox/providers.d.ts +23 -24
  111. package/dist/sandbox/providers.js +38 -46
  112. package/dist/sandbox/providers.module.js +3 -3
  113. package/dist/sandbox/sandbox.module.d.ts +1 -1
  114. package/dist/sandbox/sandbox.module.js +7 -2
  115. package/dist/sandbox/sandbox.service.d.ts +95 -68
  116. package/dist/sandbox/sandbox.service.js +212 -208
  117. package/dist/setup/setup-guides.service.d.ts +4 -1
  118. package/dist/setup/setup-guides.service.js +6 -1
  119. package/dist/themes/avatar-preset-key.d.ts +6 -0
  120. package/dist/themes/avatar-preset-key.js +9 -0
  121. package/dist/themes/theme-state.d.ts +29 -1
  122. package/dist/themes/theme-state.js +40 -1
  123. package/dist/themes/themes.service.d.ts +28 -1
  124. package/dist/themes/themes.service.js +36 -2
  125. package/dist/tools/builtins/image/generate.d.ts +3 -0
  126. package/dist/tools/builtins/image/generate.js +21 -11
  127. package/dist/tools/builtins/image/index.d.ts +1 -1
  128. package/dist/tools/builtins/image/index.js +1 -1
  129. package/dist/tools/builtins/sandbox/common.d.ts +36 -12
  130. package/dist/tools/builtins/sandbox/common.js +62 -18
  131. package/dist/tools/builtins/sandbox/read.d.ts +5 -2
  132. package/dist/tools/builtins/sandbox/read.js +9 -6
  133. package/dist/tools/builtins/sandbox/task-output.d.ts +2 -2
  134. package/dist/tools/builtins/sandbox/task-output.js +6 -5
  135. package/dist/tools/builtins/skill-load.js +13 -4
  136. package/dist/until-aborted.d.ts +5 -0
  137. package/dist/until-aborted.js +16 -0
  138. package/package.json +4 -4
  139. package/src/migrations/0176_device_report.sql +6 -0
@@ -19,8 +19,8 @@ export interface TaskEnv {
19
19
  }
20
20
  /**
21
21
  * The task tools' dependencies; throws the tool's error when they are missing, or when the
22
- * conversation's device cannot run (no cloud provider, and not a registered `@local` one:
23
- * ruling R8).
22
+ * conversation's device cannot run (its provider off in the org, or no provider on there: ruling
23
+ * R8, {@link sandboxUnusableError}).
24
24
  */
25
25
  export declare function taskEnv(deps: SandboxToolDeps, ctx: BuiltinCallContext): Promise<TaskEnv>;
26
26
  /**
@@ -8,7 +8,7 @@ import { formatElapsed, taskReasonText } from "../../../background/render.js";
8
8
  import { notRunningAs, RECREATED } from "../../../background/stop.js";
9
9
  import { isManagedTask } from "../../../background/store.js";
10
10
  import { RetirementPendingError, retirementPending, } from "../../../sandbox/sandbox.service.js";
11
- import { clip, display, mapSandboxError, noSandboxError, runTimeLeftMs, sandboxBaseTimeoutMs, sandboxConversationOf, sandboxUsable, unavailableWhenNoSandbox, } from "./common.js";
11
+ import { clip, display, mapSandboxError, runTimeLeftMs, sandboxBaseTimeoutMs, sandboxConversationOf, sandboxUnusableError, unavailableWhenNoSandbox, } from "./common.js";
12
12
  import { parseDeviceCode } from "./device-code.js";
13
13
  import { assertDeviceOfRunAccount } from "./device-owner.js";
14
14
  /** How long `TaskOutput` waits with `block` when `timeout` is not given (ms). */
@@ -57,12 +57,13 @@ const SPEC = {
57
57
  };
58
58
  /**
59
59
  * The task tools' dependencies; throws the tool's error when they are missing, or when the
60
- * conversation's device cannot run (no cloud provider, and not a registered `@local` one:
61
- * ruling R8).
60
+ * conversation's device cannot run (its provider off in the org, or no provider on there: ruling
61
+ * R8, {@link sandboxUnusableError}).
62
62
  */
63
63
  export async function taskEnv(deps, ctx) {
64
- if (!(await sandboxUsable(deps, ctx.orgId, sandboxConversationOf(ctx))))
65
- throw noSandboxError();
64
+ const unusable = await sandboxUnusableError(deps, ctx.orgId, sandboxConversationOf(ctx));
65
+ if (unusable !== null)
66
+ throw unusable;
66
67
  const { background, tasks } = deps;
67
68
  if (!background || !tasks || !deps.sandbox.ifRunning) {
68
69
  throw new ToolError("Background tasks are not available here; use Bash without run_in_background instead.");
@@ -11,7 +11,7 @@ import { resolveSkillForkType } from "../../runtime/subagents/roster.js";
11
11
  import { invocationOf, resolveSkills } from "../../skills/catalog.js";
12
12
  import { PLATFORM_SOURCE, skillFileStore } from "../../skills/usable.js";
13
13
  import { AGENT_TOOL, SANDBOX_TOOL_NAMES } from "../builtin-names.js";
14
- import { checkToolPath, clip, display, inSandboxPreparation, inToolSandbox, mapSandboxError, sandboxBaseTimeoutMs, sandboxConversationOf, sandboxUsable, withNotices, withPathLease, } from "./sandbox/common.js";
14
+ import { checkToolPath, clip, display, inSandboxPreparation, inToolSandbox, mapSandboxError, sandboxBaseTimeoutMs, sandboxConversationOf, sandboxUnusableReason, withNotices, withPathLease, } from "./sandbox/common.js";
15
15
  /**
16
16
  * Builtin tool `Skill` (M5 T14, ruling M17): resolves the name against the latest skills catalog
17
17
  * snapshot in the log to an id and version, and returns that version's SKILL.md body and file list
@@ -533,6 +533,12 @@ async function loadProjectSkill(deps, ctx, asked, bare, args) {
533
533
  display: display(`加载项目技能 ${asked}`, `Loaded project skill ${asked}`),
534
534
  };
535
535
  }
536
+ /** Why a skill's files cannot reach the device, per {@link DeviceUnusableReason}. */
537
+ const SKILL_NO_DEVICE_CAUSE = {
538
+ "provider-off": "This conversation's device runs on a device provider that is off in this organization or not installed",
539
+ "no-device": "This conversation has no device (its owner has no default device and the organization has no default device provider)",
540
+ none: "No device provider is on in this organization",
541
+ };
536
542
  /** 内置工具 `Skill`(见文件头)。 */
537
543
  export function skillLoadTool(deps) {
538
544
  return {
@@ -603,14 +609,17 @@ export function skillLoadTool(deps) {
603
609
  const others = manifest.files.filter((f) => f.path !== SKILL_ENTRY_FILE);
604
610
  let notices = [];
605
611
  let filesText;
612
+ const unusable = others.length === 0
613
+ ? null
614
+ : await sandboxUnusableReason(deps, ctx.orgId, sandboxConversationOf(ctx));
606
615
  if (others.length === 0) {
607
616
  filesText = "This skill has no files besides its instructions.";
608
617
  }
609
- else if (!(await sandboxUsable(deps, ctx.orgId, sandboxConversationOf(ctx)))) {
618
+ else if (unusable !== null) {
610
619
  filesText =
611
620
  `Skill files (for reference):\n${fileList(manifest.files)}\n` +
612
- "This deployment has no sandbox, so the skill's scripts and other files are not available; " +
613
- "follow the instructions without running them.";
621
+ SKILL_NO_DEVICE_CAUSE[unusable] +
622
+ ", so the skill's scripts and other files are not available; follow the instructions without running them.";
614
623
  }
615
624
  else if (!hasSandboxTools(ctx)) {
616
625
  // 模型跑不了脚本:不为它创建沙箱、不复制
@@ -0,0 +1,5 @@
1
+ /**
2
+ * `p`, or a rejection with `signal.reason` once `signal` aborts, whatever `p` does: an extension
3
+ * call that ignores its signal never holds the caller past it (a late settle of `p` is dropped).
4
+ */
5
+ export declare function untilAborted<T>(p: Promise<T>, signal: AbortSignal): Promise<T>;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * `p`, or a rejection with `signal.reason` once `signal` aborts, whatever `p` does: an extension
3
+ * call that ignores its signal never holds the caller past it (a late settle of `p` is dropped).
4
+ */
5
+ export function untilAborted(p, signal) {
6
+ return new Promise((resolve, reject) => {
7
+ const onAbort = () => reject(signal.reason);
8
+ if (signal.aborted) {
9
+ p.catch(() => { });
10
+ onAbort();
11
+ return;
12
+ }
13
+ signal.addEventListener("abort", onAbort, { once: true });
14
+ p.then(resolve, reject).finally(() => signal.removeEventListener("abort", onAbort));
15
+ });
16
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capybara-hq/kernel",
3
- "version": "0.1.0-rc.66",
3
+ "version": "0.1.0-rc.67",
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": {
@@ -66,7 +66,7 @@
66
66
  "yaml": "^2.9.1",
67
67
  "yauzl": "3.4.0",
68
68
  "zod": "^4.6.7",
69
- "@capybara-hq/plugin-sdk": "^0.1.0-rc.50"
69
+ "@capybara-hq/plugin-sdk": "^0.1.0-rc.51"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@langchain/langgraph-checkpoint-validation": "^1.2.0",
@@ -75,8 +75,8 @@
75
75
  "@types/ws": "^8.18.2",
76
76
  "@types/yauzl": "3.4.0",
77
77
  "ws": "^8.22.0",
78
- "@capybara-hq/device": "0.1.0-rc.26",
79
- "@capybara-hq/testing": "0.1.0-rc.32"
78
+ "@capybara-hq/testing": "0.1.0-rc.33",
79
+ "@capybara-hq/device": "0.1.0-rc.27"
80
80
  },
81
81
  "scripts": {
82
82
  "build": "tsc -b"
@@ -0,0 +1,6 @@
1
+ -- Device providers (spec 2026-11-21-device-provider-design): what a device's provider last told
2
+ -- about it (`device-provider@1` `report()`, a DeviceReport as JSON) and when. Shown to people
3
+ -- only, never used for enforcement; request paths read this copy and never call the provider.
4
+ -- Expand-only, no backfill: null until the device's next create or resume refreshes it.
5
+ ALTER TABLE devices ADD COLUMN IF NOT EXISTS report jsonb;
6
+ ALTER TABLE devices ADD COLUMN IF NOT EXISTS report_at timestamptz;