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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/bootstrap.json +3 -3
  2. package/dist/catalog/marketplaces.service.d.ts +1 -1
  3. package/dist/catalog/requests.service.d.ts +8 -6
  4. package/dist/catalog/requests.service.js +52 -29
  5. package/dist/channels/inbound.d.ts +0 -25
  6. package/dist/channels/inbound.js +26 -1
  7. package/dist/channels/phrases.d.ts +28 -0
  8. package/dist/channels/phrases.js +28 -0
  9. package/dist/config/schema.d.ts +4 -0
  10. package/dist/config/schema.js +7 -1
  11. package/dist/conversations/conversations.controller.d.ts +4 -1
  12. package/dist/conversations/conversations.controller.js +14 -2
  13. package/dist/conversations/conversations.service.d.ts +43 -3
  14. package/dist/conversations/conversations.service.js +93 -19
  15. package/dist/conversations/event-log.d.ts +3 -3
  16. package/dist/conversations/event-log.js +3 -3
  17. package/dist/conversations/events.d.ts +24 -0
  18. package/dist/conversations/events.js +69 -0
  19. package/dist/db/kernel-schema.d.ts +20 -0
  20. package/dist/devices/conversation-devices.d.ts +57 -3
  21. package/dist/devices/conversation-devices.js +63 -11
  22. package/dist/devices/device-projects.service.d.ts +162 -0
  23. package/dist/devices/device-projects.service.js +503 -0
  24. package/dist/devices/devices.controller.d.ts +15 -2
  25. package/dist/devices/devices.controller.js +60 -3
  26. package/dist/devices/devices.module.js +15 -2
  27. package/dist/devices/devices.schemas.js +9 -1
  28. package/dist/devices/devices.service.js +8 -4
  29. package/dist/devices/dto.d.ts +31 -0
  30. package/dist/devices/dto.js +38 -1
  31. package/dist/devices/working-root.d.ts +41 -0
  32. package/dist/devices/working-root.js +50 -0
  33. package/dist/errors.d.ts +39 -0
  34. package/dist/errors.js +39 -0
  35. package/dist/evals/run-replay.d.ts +9 -1
  36. package/dist/evals/run-replay.js +15 -1
  37. package/dist/local-devices/local-device-provider.d.ts +37 -1
  38. package/dist/local-devices/local-device-provider.js +33 -0
  39. package/dist/local-devices/machines.d.ts +2 -1
  40. package/dist/local-devices/machines.js +4 -1
  41. package/dist/local-devices/network-grants.d.ts +1 -1
  42. package/dist/local-devices/network-grants.js +2 -3
  43. package/dist/local-devices/policy-summary.js +1 -0
  44. package/dist/local-devices/relay.d.ts +2 -0
  45. package/dist/local-devices/relay.js +3 -1
  46. package/dist/local-devices/targets.d.ts +6 -1
  47. package/dist/local-devices/targets.js +14 -0
  48. package/dist/orgs/settings.controller.d.ts +3 -1
  49. package/dist/orgs/settings.controller.js +7 -3
  50. package/dist/orgs/settings.service.d.ts +78 -31
  51. package/dist/orgs/settings.service.js +109 -52
  52. package/dist/overrides.d.ts +4 -0
  53. package/dist/overrides.js +2 -0
  54. package/dist/platform/ops/agent-skills.ops.js +2 -1
  55. package/dist/platform/ops/devices.ops.d.ts +3 -1
  56. package/dist/platform/ops/devices.ops.js +136 -3
  57. package/dist/platform/ops/org-settings.ops.js +20 -10
  58. package/dist/runtime/context/build.d.ts +3 -0
  59. package/dist/runtime/context/build.js +14 -0
  60. package/dist/runtime/context/compaction.js +2 -0
  61. package/dist/runtime/context/project-root.d.ts +43 -0
  62. package/dist/runtime/context/project-root.js +85 -0
  63. package/dist/runtime/model-call.js +25 -1
  64. package/dist/runtime/project/knowledge.d.ts +129 -0
  65. package/dist/runtime/project/knowledge.js +248 -0
  66. package/dist/runtime/project/knowledge.service.d.ts +85 -0
  67. package/dist/runtime/project/knowledge.service.js +288 -0
  68. package/dist/runtime/run-worker.d.ts +5 -0
  69. package/dist/runtime/run-worker.js +27 -6
  70. package/dist/runtime/runtime.module.js +7 -0
  71. package/dist/sandbox/modes.d.ts +31 -19
  72. package/dist/sandbox/modes.js +43 -24
  73. package/dist/sandbox/review/review.service.d.ts +14 -2
  74. package/dist/sandbox/review/review.service.js +2 -0
  75. package/dist/sandbox/review/rules.d.ts +6 -4
  76. package/dist/sandbox/review/rules.js +185 -62
  77. package/dist/sandbox/review/types.d.ts +14 -0
  78. package/dist/sandbox/sandbox.service.d.ts +20 -2
  79. package/dist/sandbox/sandbox.service.js +86 -3
  80. package/dist/schedules/grant-rules.d.ts +2 -0
  81. package/dist/schedules/grant-rules.js +3 -1
  82. package/dist/schedules/schedule-math.js +21 -2
  83. package/dist/schedules/scheduled-tasks.service.js +3 -1
  84. package/dist/skills/catalog.d.ts +6 -1
  85. package/dist/skills/catalog.js +18 -4
  86. package/dist/skills/invoke.d.ts +64 -2
  87. package/dist/skills/invoke.js +214 -6
  88. package/dist/skills/skills.module.js +5 -0
  89. package/dist/tools/approvals.service.d.ts +6 -0
  90. package/dist/tools/builtins/sandbox/bash.js +19 -4
  91. package/dist/tools/builtins/sandbox/common.d.ts +36 -6
  92. package/dist/tools/builtins/sandbox/common.js +69 -8
  93. package/dist/tools/builtins/sandbox/edit.js +2 -2
  94. package/dist/tools/builtins/sandbox/glob.js +3 -2
  95. package/dist/tools/builtins/sandbox/grep.js +2 -1
  96. package/dist/tools/builtins/sandbox/read.js +3 -3
  97. package/dist/tools/builtins/sandbox/write.js +2 -2
  98. package/dist/tools/builtins/skill-load.d.ts +47 -2
  99. package/dist/tools/builtins/skill-load.js +160 -2
  100. package/dist/tools/network-asks.d.ts +7 -0
  101. package/dist/tools/network-asks.js +11 -1
  102. package/dist/tools/pipeline.d.ts +1 -1
  103. package/dist/tools/pipeline.js +60 -9
  104. package/dist/tools/registry.d.ts +6 -0
  105. package/package.json +2 -2
  106. package/src/migrations/0133_project_root.sql +30 -0
  107. package/src/migrations/0134_org_cloud_network_delta.sql +38 -0
@@ -33,6 +33,7 @@ import { ConversationLock } from "./conversation-lock.js";
33
33
  import { runDeadline, tightestLimit } from "./limits.js";
34
34
  import { RunError } from "./model-call.js";
35
35
  import { PluginContextService } from "./plugin-context.service.js";
36
+ import { ProjectKnowledgeService } from "./project/knowledge.service.js";
36
37
  import { ProviderListError, ProviderRegistry } from "./providers.js";
37
38
  import { ORG_QUOTA_LEASE_MS, orgRunLimit, RUN_QUOTA } from "./quota.js";
38
39
  import { RunContextService } from "./run-context.service.js";
@@ -101,6 +102,7 @@ let RunWorker = class RunWorker {
101
102
  skillsCatalog;
102
103
  runContext;
103
104
  pluginContext;
105
+ projectKnowledge;
104
106
  tools;
105
107
  finisher;
106
108
  txHost;
@@ -132,6 +134,8 @@ let RunWorker = class RunWorker {
132
134
  runContext,
133
135
  /** Run start's plugin context (memory plugin spec §6.1): the `context@1` providers' text. */
134
136
  pluginContext,
137
+ /** Run start's project knowledge (project root spec §4.4): a bound project's AGENTS.md, skills. */
138
+ projectKnowledge,
135
139
  /** The run's resolved tools, for the plugin context's `tools` (chat runs with providers). */
136
140
  tools, finisher, txHost,
137
141
  /** The steps' live drafts this process writes for the runs it executes. */
@@ -155,6 +159,7 @@ let RunWorker = class RunWorker {
155
159
  this.skillsCatalog = skillsCatalog;
156
160
  this.runContext = runContext;
157
161
  this.pluginContext = pluginContext;
162
+ this.projectKnowledge = projectKnowledge;
158
163
  this.tools = tools;
159
164
  this.finisher = finisher;
160
165
  this.txHost = txHost;
@@ -695,6 +700,21 @@ let RunWorker = class RunWorker {
695
700
  });
696
701
  if (!pluginContexted)
697
702
  return "finished";
703
+ // project knowledge (project root spec §4.4): a conversation bound to a project reads its
704
+ // AGENTS.md and skills on the device before the first model call, outside any transaction;
705
+ // a free one reads nothing, a sub-agent copies its root's latest snapshot. Its append
706
+ // re-reads the run under the locks, as above.
707
+ const projectRead = await this.projectKnowledge.record({
708
+ orgId: conv.org_id,
709
+ conversationId,
710
+ runId,
711
+ kind: conv.kind,
712
+ // a sub-agent copies its root's snapshot: it works in the root's project
713
+ ...(parent !== undefined && { rootConversationId: parent.rootConversationId }),
714
+ signal: state.shutdown.signal,
715
+ });
716
+ if (!projectRead)
717
+ return "finished";
698
718
  await this.hooks?.beforeRunning?.(runId, conversationId);
699
719
  // never over a terminal status: a run finished meanwhile stays finished
700
720
  const updated = await this.db
@@ -1199,11 +1219,12 @@ RunWorker = __decorate([
1199
1219
  __param(18, Inject(SkillsCatalogService)),
1200
1220
  __param(19, Inject(RunContextService)),
1201
1221
  __param(20, Inject(PluginContextService)),
1202
- __param(21, Inject(ToolRegistry)),
1203
- __param(22, Inject(RunFinish)),
1204
- __param(23, Inject(TransactionHost)),
1205
- __param(24, Inject(RunDrafts)),
1206
- __param(25, Optional()),
1207
- __param(25, Inject(RUN_HOOKS))
1222
+ __param(21, Inject(ProjectKnowledgeService)),
1223
+ __param(22, Inject(ToolRegistry)),
1224
+ __param(23, Inject(RunFinish)),
1225
+ __param(24, Inject(TransactionHost)),
1226
+ __param(25, Inject(RunDrafts)),
1227
+ __param(26, Optional()),
1228
+ __param(26, Inject(RUN_HOOKS))
1208
1229
  ], RunWorker);
1209
1230
  export { RunWorker };
@@ -11,12 +11,14 @@ import { ConversationAccessModule } from "../conversations/access.js";
11
11
  import { AttachmentsModule } from "../conversations/attachments.module.js";
12
12
  import { EventLogModule } from "../conversations/event-log.js";
13
13
  import { TitlesModule } from "../conversations/titles.js";
14
+ import { DevicesModule } from "../devices/devices.module.js";
14
15
  import { ExtensionsModule } from "../extensions/extensions.module.js";
15
16
  import { GitModule } from "../git/git.module.js";
16
17
  import { IdentityModule } from "../identity/identity.module.js";
17
18
  import { LockService } from "../infra/lock/lock.service.js";
18
19
  import { QueueModule } from "../infra/queue/queue.module.js";
19
20
  import { REDIS } from "../infra/tokens.js";
21
+ import { SandboxModule } from "../sandbox/sandbox.module.js";
20
22
  import { ScheduledTaskTrackerModule } from "../schedules/run-tracker.js";
21
23
  import { SkillsModule } from "../skills/skills.module.js";
22
24
  import { ToolsModule } from "../tools/tools.module.js";
@@ -28,6 +30,7 @@ import { CompactionSettingsService } from "./compaction-settings.service.js";
28
30
  import { ConversationLock } from "./conversation-lock.js";
29
31
  import { MAINTENANCE_QUEUE_NAME } from "./maintenance-queue.js";
30
32
  import { PluginContextService } from "./plugin-context.service.js";
33
+ import { ProjectKnowledgeService } from "./project/knowledge.service.js";
31
34
  import { ProvidersModule } from "./providers.js";
32
35
  import { EVAL_QUOTA, EVAL_QUOTA_PREFIX, OrgQuota, RUN_QUOTA, RUN_QUOTA_PREFIX } from "./quota.js";
33
36
  import { RunContextService } from "./run-context.service.js";
@@ -62,6 +65,9 @@ RuntimeModule = __decorate([
62
65
  IdentityModule,
63
66
  SkillsModule,
64
67
  ToolsModule,
68
+ // a bound conversation's device and project scope (project root spec §4.4)
69
+ DevicesModule,
70
+ SandboxModule,
65
71
  GitModule,
66
72
  ProvidersModule,
67
73
  RunJobsModule,
@@ -90,6 +96,7 @@ RuntimeModule = __decorate([
90
96
  RunSteps,
91
97
  RunContextService,
92
98
  PluginContextService,
99
+ ProjectKnowledgeService,
93
100
  RunWorker,
94
101
  // the org's effective compaction settings, one read per model step
95
102
  CompactionSettingsService,
@@ -1,7 +1,7 @@
1
1
  import type { KernelConfig } from "../config/schema.js";
2
2
  import type { KernelSchemaDb } from "../db/kernel-schema.js";
3
3
  import type { KernelConfigService } from "../infra/config/kernel-config.service.js";
4
- import type { OrgSettings } from "../orgs/settings.service.js";
4
+ import type { CloudNetworkSetting, OrgSettings } from "../orgs/settings.service.js";
5
5
  import { type DevicesAutoMode } from "./platform-auto-mode.js";
6
6
  /**
7
7
  * Device modes (auto mode spec §4.1–§4.3): who may choose auto mode, and the network each mode
@@ -24,8 +24,33 @@ export interface DeviceNetwork {
24
24
  */
25
25
  export interface DeploymentDevicePolicy {
26
26
  autoMode: DevicesAutoMode;
27
- limits: Pick<KernelConfig["sandbox"]["limits"], "egress" | "allowHosts">;
27
+ limits: NetworkLimits;
28
28
  }
29
+ /**
30
+ * The platform's network fields (`sandbox.limits`): the kill switch, the allowlist and whether
31
+ * organizations may go beyond it (org egress ceiling spec §D2).
32
+ */
33
+ export type NetworkLimits = Pick<KernelConfig["sandbox"]["limits"], "egress" | "allowHosts" | "orgHosts">;
34
+ /** Whether the allowlist entry `pattern` admits `host` (`*.x.com`: subdomains, never the apex). */
35
+ export declare const coversHost: (pattern: string, host: string) => boolean;
36
+ /**
37
+ * Whether `host` is beyond the platform's ceiling: `sandbox.limits.orgHosts` is `within` and no
38
+ * entry of `sandbox.limits.allowHosts` covers it (a wildcard host is covered by a wider wildcard).
39
+ * Only a super admin can allow such a host.
40
+ */
41
+ export declare function orgHostOutsideCeiling(limits: NetworkLimits, host: string): boolean;
42
+ /**
43
+ * The org's effective allowlist (org egress ceiling spec §D1): empty under the kill switch; else
44
+ * the org's extras (only those inside the ceiling under `within`) on top of the platform's list
45
+ * minus the org's exclusions, or the extras alone when the org's base is `none`. The one place
46
+ * that combines the platform's hosts with the org's.
47
+ */
48
+ export declare function orgEffectiveHosts(limits: NetworkLimits, org: CloudNetworkSetting | undefined): string[];
49
+ /**
50
+ * The org's cloud network in sandbox mode (spec §D2): the allowlist under the kill switch or the
51
+ * platform ceiling (`orgHosts: within`), else the org's mode (open by default).
52
+ */
53
+ export declare function orgCloudMode(limits: NetworkLimits, org: CloudNetworkSetting | undefined): "open" | "allowlist";
29
54
  /**
30
55
  * The platform side of the policy, read live: the effective auto-mode switch and the
31
56
  * `sandbox.limits` network fields (in the caller's transaction when there is one).
@@ -52,27 +77,14 @@ export interface EffectiveDevicePolicy {
52
77
  }
53
78
  /** The mode the platform and the org allow: `auto` only when neither turns it off. */
54
79
  export declare function allowedDeviceMode(platform: DevicesAutoMode, org: OrgDeviceSettings["autoMode"]): SandboxMode;
55
- /**
56
- * The org's allowlist (the hosts a local device in sandbox mode may reach): the org's own list when
57
- * it gave one, else `sandbox.limits.allowHosts`; empty under the platform kill switch.
58
- */
80
+ /** The org's allowlist (the hosts a local device in sandbox mode may reach): {@link orgEffectiveHosts}. */
59
81
  export declare function orgAllowedDomains(deployment: DeploymentDevicePolicy, org: OrgDeviceSettings): string[];
60
82
  /**
61
- * The cloud network (auto mode spec §4.3): `open-public` in auto mode while the org's
62
- * `cloudNetwork` is `open` (the default), else the org's allowlist. `sandbox.limits.egress: none`
63
- * forces an empty allowlist (the platform kill switch, R20).
83
+ * The cloud network (auto mode spec §4.3): `open-public` in auto mode; in sandbox mode the org's
84
+ * cloud network ({@link orgCloudMode}). `sandbox.limits.egress: none` forces an empty allowlist
85
+ * (the platform kill switch, R20).
64
86
  */
65
87
  export declare function deviceNetwork(deployment: DeploymentDevicePolicy, org: OrgDeviceSettings, mode: SandboxMode): DeviceNetwork;
66
- /**
67
- * The org's sandbox-mode network, from the deployment default, the org's `cloudNetwork` choice and
68
- * the platform kill switch: `sandbox.limits.egress: "none"` forces an empty allowlist (R20, every
69
- * read); otherwise `open-public` when either says open, else the org's hosts over the deployment's
70
- * list.
71
- */
72
- export declare function orgSandboxNetwork(deployment: {
73
- mode: "open" | "allowlist";
74
- allowHosts: string[];
75
- }, org: OrgDeviceSettings["cloudNetwork"], egress?: "none" | "allowlist"): DeviceNetwork;
76
88
  /**
77
89
  * The effective device policy. `deviceMode` is the device's own choice (a local machine's
78
90
  * reported mode; null = follow the platform and the org). A stored mode the ceiling forbids is cut,
@@ -1,4 +1,41 @@
1
1
  import { readDevicesAutoMode } from "./platform-auto-mode.js";
2
+ /** Whether the allowlist entry `pattern` admits `host` (`*.x.com`: subdomains, never the apex). */
3
+ export const coversHost = (pattern, host) => pattern === host || (pattern.startsWith("*.") && host.endsWith(pattern.slice(1)));
4
+ /**
5
+ * Whether `host` is beyond the platform's ceiling: `sandbox.limits.orgHosts` is `within` and no
6
+ * entry of `sandbox.limits.allowHosts` covers it (a wildcard host is covered by a wider wildcard).
7
+ * Only a super admin can allow such a host.
8
+ */
9
+ export function orgHostOutsideCeiling(limits, host) {
10
+ if (limits.orgHosts !== "within")
11
+ return false;
12
+ const h = host.toLowerCase();
13
+ return !limits.allowHosts.some((p) => coversHost(p.toLowerCase(), h));
14
+ }
15
+ /**
16
+ * The org's effective allowlist (org egress ceiling spec §D1): empty under the kill switch; else
17
+ * the org's extras (only those inside the ceiling under `within`) on top of the platform's list
18
+ * minus the org's exclusions, or the extras alone when the org's base is `none`. The one place
19
+ * that combines the platform's hosts with the org's.
20
+ */
21
+ export function orgEffectiveHosts(limits, org) {
22
+ if (limits.egress === "none")
23
+ return [];
24
+ const extra = (org?.extraHosts ?? []).filter((h) => !orgHostOutsideCeiling(limits, h));
25
+ if (org?.base === "none")
26
+ return [...new Set(extra)];
27
+ const excluded = new Set(org?.excludedHosts ?? []);
28
+ return [...new Set([...limits.allowHosts.filter((h) => !excluded.has(h)), ...extra])];
29
+ }
30
+ /**
31
+ * The org's cloud network in sandbox mode (spec §D2): the allowlist under the kill switch or the
32
+ * platform ceiling (`orgHosts: within`), else the org's mode (open by default).
33
+ */
34
+ export function orgCloudMode(limits, org) {
35
+ if (limits.egress === "none" || limits.orgHosts === "within")
36
+ return "allowlist";
37
+ return org?.mode ?? "open";
38
+ }
2
39
  /**
3
40
  * The platform side of the policy, read live: the effective auto-mode switch and the
4
41
  * `sandbox.limits` network fields (in the caller's transaction when there is one).
@@ -11,19 +48,14 @@ export async function readDeploymentDevicePolicy(db, config) {
11
48
  export function allowedDeviceMode(platform, org) {
12
49
  return platform === "allowed" && org !== "off" ? "auto" : "sandbox";
13
50
  }
14
- /**
15
- * The org's allowlist (the hosts a local device in sandbox mode may reach): the org's own list when
16
- * it gave one, else `sandbox.limits.allowHosts`; empty under the platform kill switch.
17
- */
51
+ /** The org's allowlist (the hosts a local device in sandbox mode may reach): {@link orgEffectiveHosts}. */
18
52
  export function orgAllowedDomains(deployment, org) {
19
- if (deployment.limits.egress === "none")
20
- return [];
21
- return [...(org.cloudNetwork?.allowHosts ?? deployment.limits.allowHosts)];
53
+ return orgEffectiveHosts(deployment.limits, org.cloudNetwork);
22
54
  }
23
55
  /**
24
- * The cloud network (auto mode spec §4.3): `open-public` in auto mode while the org's
25
- * `cloudNetwork` is `open` (the default), else the org's allowlist. `sandbox.limits.egress: none`
26
- * forces an empty allowlist (the platform kill switch, R20).
56
+ * The cloud network (auto mode spec §4.3): `open-public` in auto mode; in sandbox mode the org's
57
+ * cloud network ({@link orgCloudMode}). `sandbox.limits.egress: none` forces an empty allowlist
58
+ * (the platform kill switch, R20).
27
59
  */
28
60
  export function deviceNetwork(deployment, org, mode) {
29
61
  if (deployment.limits.egress === "none")
@@ -31,24 +63,11 @@ export function deviceNetwork(deployment, org, mode) {
31
63
  // auto mode is 开放挡内网 whatever the org says; only sandbox mode applies `cloudNetwork`
32
64
  if (mode === "auto")
33
65
  return { kind: "open-public", hosts: [] };
34
- if ((org.cloudNetwork?.mode ?? "open") === "open") {
66
+ if (orgCloudMode(deployment.limits, org.cloudNetwork) === "open") {
35
67
  return { kind: "open-public", hosts: [] };
36
68
  }
37
69
  return { kind: "allowlist", hosts: orgAllowedDomains(deployment, org) };
38
70
  }
39
- /**
40
- * The org's sandbox-mode network, from the deployment default, the org's `cloudNetwork` choice and
41
- * the platform kill switch: `sandbox.limits.egress: "none"` forces an empty allowlist (R20, every
42
- * read); otherwise `open-public` when either says open, else the org's hosts over the deployment's
43
- * list.
44
- */
45
- export function orgSandboxNetwork(deployment, org, egress = "allowlist") {
46
- if (egress === "none")
47
- return { kind: "allowlist", hosts: [] };
48
- if ((org?.mode ?? deployment.mode) === "open")
49
- return { kind: "open-public", hosts: [] };
50
- return { kind: "allowlist", hosts: [...(org?.allowHosts ?? deployment.allowHosts)] };
51
- }
52
71
  /**
53
72
  * The effective device policy. `deviceMode` is the device's own choice (a local machine's
54
73
  * reported mode; null = follow the platform and the org). A stored mode the ceiling forbids is cut,
@@ -42,10 +42,22 @@ export interface ReviewInput {
42
42
  input: unknown;
43
43
  mode: "auto" | "sandbox";
44
44
  /**
45
- * The device's workspace root. Absent: no device is bound, so the tool fails on its own and
46
- * there is nothing to review.
45
+ * The conversation's working root: the device's workspace root, or the bound project's root
46
+ * (project root spec §4.3). Commands start here and a write inside it needs no ask. Absent: no
47
+ * device is bound, so the tool fails on its own and there is nothing to review.
47
48
  */
48
49
  workspace?: string | undefined;
50
+ /**
51
+ * The owner's home directory (the machine's, else the device workspace's prefix), never derived
52
+ * from a project root: `~` and the home-level sensitive paths are judged against it. Absent or
53
+ * null: the rules derive it from `workspace`.
54
+ */
55
+ home?: string | null | undefined;
56
+ /**
57
+ * The home prefix of the device's own workspace, judged beside `home` (a project outside every
58
+ * home still protects it). Absent or null: none.
59
+ */
60
+ deviceHome?: string | null | undefined;
49
61
  /** Whether a person is present to answer an `ask` (rules may read it; the pipeline decides). */
50
62
  attended: boolean;
51
63
  /** Hook payload facts (optional: without enough of them no model hook fires). */
@@ -116,6 +116,8 @@ let CommandReviewService = class CommandReviewService {
116
116
  const facts = {
117
117
  workspace,
118
118
  cwd: workspace,
119
+ home: input.home ?? null,
120
+ deviceHome: input.deviceHome ?? null,
119
121
  mode: input.mode,
120
122
  attended: input.attended,
121
123
  };
@@ -63,8 +63,9 @@
63
63
  */
64
64
  import type { ParsedCommand, ReviewFacts, ReviewResult } from "./types.js";
65
65
  export type { ParsedCommand, Redirect, ReviewFacts, ReviewResult, RuleHit, RuleOutcome, SimpleCommand, } from "./types.js";
66
- /** The public parser: the parsed command, or null when the tokenizer is not confident. */
67
66
  export declare function parseCommand(command: string): ParsedCommand | null;
67
+ /** The home directory a path lies in by its `/home/<u>`, `/Users/<u>` or `/root` prefix, or null. */
68
+ export declare function homeOf(workspace: string): string | null;
68
69
  /**
69
70
  * The absolute paths a command line writes, for the review's record of what a conversation wrote
70
71
  * (hardening spec R1: running one of them later is not a development command). An unparseable line
@@ -78,8 +79,9 @@ export declare function writtenPaths(command: string, facts: ReviewFacts): strin
78
79
  */
79
80
  export declare function reviewRules(command: string, facts: ReviewFacts): ReviewResult;
80
81
  /**
81
- * The same table for a file-tool write: workspace and tmp writes pass; the device's own files are
82
- * denied; git hooks, shell rc files and secret files ask; anything else outside asks to write
83
- * outside.
82
+ * The same table for a file-tool write: the device's own files are denied; git hooks and
83
+ * home-level sensitive paths (shell rc files, SSH, launch agents, credentials) ask wherever they
84
+ * lie, inside the workspace too; other workspace and tmp writes pass; a `.env*` file outside the
85
+ * workspace asks; anything else outside asks to write outside.
84
86
  */
85
87
  export declare function reviewWrite(path: string, facts: ReviewFacts): ReviewResult;