@intentic/sandbox-contract 1.316.0 → 1.318.0
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.
- package/README.md +12 -4
- package/dist/chores/chores.js +1 -1
- package/dist/chores/chores.js.map +1 -1
- package/dist/chores/probes.js +1 -1
- package/dist/chores/probes.js.map +1 -1
- package/dist/contracts/accounts.contract.d.ts +75 -0
- package/dist/contracts/accounts.contract.d.ts.map +1 -1
- package/dist/contracts/accounts.contract.js +10 -1
- package/dist/contracts/accounts.contract.js.map +1 -1
- package/dist/contracts/agent.contract.d.ts +616 -1
- package/dist/contracts/agent.contract.d.ts.map +1 -1
- package/dist/contracts/agents.contract.d.ts +1134 -29
- package/dist/contracts/agents.contract.d.ts.map +1 -1
- package/dist/contracts/agents.contract.js +12 -12
- package/dist/contracts/agents.contract.js.map +1 -1
- package/dist/contracts/capabilities.contract.d.ts +16 -0
- package/dist/contracts/capabilities.contract.d.ts.map +1 -1
- package/dist/contracts/capabilities.contract.js +10 -1
- package/dist/contracts/capabilities.contract.js.map +1 -1
- package/dist/contracts/ci.contract.d.ts +22 -4
- package/dist/contracts/ci.contract.d.ts.map +1 -1
- package/dist/contracts/device.contract.d.ts +39 -0
- package/dist/contracts/device.contract.d.ts.map +1 -1
- package/dist/contracts/device.contract.js +2 -0
- package/dist/contracts/device.contract.js.map +1 -1
- package/dist/contracts/endpoints.contract.d.ts +23 -0
- package/dist/contracts/endpoints.contract.d.ts.map +1 -1
- package/dist/contracts/endpoints.contract.js +6 -1
- package/dist/contracts/endpoints.contract.js.map +1 -1
- package/dist/contracts/extensions.contract.d.ts +12 -0
- package/dist/contracts/extensions.contract.d.ts.map +1 -1
- package/dist/contracts/needs.contract.d.ts +534 -0
- package/dist/contracts/needs.contract.d.ts.map +1 -0
- package/dist/contracts/needs.contract.js +80 -0
- package/dist/contracts/needs.contract.js.map +1 -0
- package/dist/contracts/providers.contract.d.ts +4 -0
- package/dist/contracts/providers.contract.d.ts.map +1 -1
- package/dist/contracts/runner.contract.d.ts +193 -2
- package/dist/contracts/runner.contract.d.ts.map +1 -1
- package/dist/contracts/secrets.contract.d.ts +53 -0
- package/dist/contracts/secrets.contract.d.ts.map +1 -1
- package/dist/contracts/secrets.contract.js +31 -2
- package/dist/contracts/secrets.contract.js.map +1 -1
- package/dist/contracts/sessions.contract.d.ts +83 -0
- package/dist/contracts/sessions.contract.d.ts.map +1 -1
- package/dist/contracts/settings.contract.d.ts +33 -2
- package/dist/contracts/settings.contract.d.ts.map +1 -1
- package/dist/contracts/settings.contract.js +20 -1
- package/dist/contracts/settings.contract.js.map +1 -1
- package/dist/contracts/system.contract.d.ts +177 -356
- package/dist/contracts/system.contract.d.ts.map +1 -1
- package/dist/contracts/system.contract.js +13 -12
- package/dist/contracts/system.contract.js.map +1 -1
- package/dist/contracts/translator.contract.d.ts +7 -0
- package/dist/contracts/translator.contract.d.ts.map +1 -1
- package/dist/contracts/translator.contract.js.map +1 -1
- package/dist/contracts/webext.contract.d.ts +38 -0
- package/dist/contracts/webext.contract.d.ts.map +1 -1
- package/dist/contracts/webext.contract.js +3 -0
- package/dist/contracts/webext.contract.js.map +1 -1
- package/dist/contracts/workspace.contract.d.ts +1 -80
- package/dist/contracts/workspace.contract.d.ts.map +1 -1
- package/dist/contracts/workspace.contract.js +0 -27
- package/dist/contracts/workspace.contract.js.map +1 -1
- package/dist/events/agent-events.d.ts +330 -0
- package/dist/events/agent-events.d.ts.map +1 -1
- package/dist/events/agent-events.js +13 -0
- package/dist/events/agent-events.js.map +1 -1
- package/dist/events/agent-words.d.ts +1 -0
- package/dist/events/agent-words.d.ts.map +1 -1
- package/dist/events/agent-words.js +3 -2
- package/dist/events/agent-words.js.map +1 -1
- package/dist/events/land-breakage.d.ts.map +1 -1
- package/dist/events/land-breakage.js.map +1 -1
- package/dist/events/need-wake.d.ts +17 -0
- package/dist/events/need-wake.d.ts.map +1 -0
- package/dist/events/need-wake.js +34 -0
- package/dist/events/need-wake.js.map +1 -0
- package/dist/events/resume.d.ts +6 -1
- package/dist/events/resume.d.ts.map +1 -1
- package/dist/events/resume.js +17 -10
- package/dist/events/resume.js.map +1 -1
- package/dist/events/sandbox-notice.d.ts +183 -0
- package/dist/events/sandbox-notice.d.ts.map +1 -0
- package/dist/events/sandbox-notice.js +56 -0
- package/dist/events/sandbox-notice.js.map +1 -0
- package/dist/events/system-events.d.ts +84 -0
- package/dist/events/system-events.d.ts.map +1 -1
- package/dist/events/system-events.js +2 -0
- package/dist/events/system-events.js.map +1 -1
- package/dist/events/transcript.d.ts +508 -0
- package/dist/events/transcript.d.ts.map +1 -1
- package/dist/events/transcript.js +12 -1
- package/dist/events/transcript.js.map +1 -1
- package/dist/ids/conversation-ids.d.ts +1 -3
- package/dist/ids/conversation-ids.d.ts.map +1 -1
- package/dist/ids/conversation-ids.js +1 -3
- package/dist/ids/conversation-ids.js.map +1 -1
- package/dist/ids/project-dir.d.ts +6 -0
- package/dist/ids/project-dir.d.ts.map +1 -0
- package/dist/ids/project-dir.js +43 -0
- package/dist/ids/project-dir.js.map +1 -0
- package/dist/index.d.ts +3474 -1163
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/dist/models/agent-runtimes.d.ts.map +1 -1
- package/dist/models/agent-runtimes.js +2 -2
- package/dist/models/agent-runtimes.js.map +1 -1
- package/dist/models/model-roles.d.ts +1 -9
- package/dist/models/model-roles.d.ts.map +1 -1
- package/dist/models/model-roles.js +1 -9
- package/dist/models/model-roles.js.map +1 -1
- package/dist/policy/command-classes.d.ts.map +1 -1
- package/dist/policy/command-classes.js +52 -3
- package/dist/policy/command-classes.js.map +1 -1
- package/dist/policy/safety-policy.d.ts +7 -1
- package/dist/policy/safety-policy.d.ts.map +1 -1
- package/dist/policy/safety-policy.js +2 -0
- package/dist/policy/safety-policy.js.map +1 -1
- package/dist/policy/secret-hosts.d.ts +13 -0
- package/dist/policy/secret-hosts.d.ts.map +1 -0
- package/dist/policy/secret-hosts.js +41 -0
- package/dist/policy/secret-hosts.js.map +1 -0
- package/dist/policy/turned-away.d.ts.map +1 -1
- package/dist/policy/turned-away.js +1 -0
- package/dist/policy/turned-away.js.map +1 -1
- package/dist/protocol/raw-routes.d.ts +7 -5
- package/dist/protocol/raw-routes.d.ts.map +1 -1
- package/dist/protocol/raw-routes.js +4 -1
- package/dist/protocol/raw-routes.js.map +1 -1
- package/dist/protocol/routes.d.ts +2 -6
- package/dist/protocol/routes.d.ts.map +1 -1
- package/dist/protocol/routes.js +2 -3
- package/dist/protocol/routes.js.map +1 -1
- package/dist/protocol/stream-of.d.ts +6 -0
- package/dist/protocol/stream-of.d.ts.map +1 -0
- package/dist/protocol/stream-of.js +4 -0
- package/dist/protocol/stream-of.js.map +1 -0
- package/dist/schemas/activity.js +1 -1
- package/dist/schemas/activity.js.map +1 -1
- package/dist/schemas/agent.d.ts +19 -2
- package/dist/schemas/agent.d.ts.map +1 -1
- package/dist/schemas/agent.js +2 -1
- package/dist/schemas/agent.js.map +1 -1
- package/dist/schemas/agents.d.ts +119 -0
- package/dist/schemas/agents.d.ts.map +1 -1
- package/dist/schemas/agents.js +45 -0
- package/dist/schemas/agents.js.map +1 -1
- package/dist/schemas/automations.d.ts +37 -0
- package/dist/schemas/automations.d.ts.map +1 -1
- package/dist/schemas/capabilities.d.ts +21 -0
- package/dist/schemas/capabilities.d.ts.map +1 -1
- package/dist/schemas/capabilities.js +50 -4
- package/dist/schemas/capabilities.js.map +1 -1
- package/dist/schemas/ci.d.ts +69 -9
- package/dist/schemas/ci.d.ts.map +1 -1
- package/dist/schemas/ci.js +29 -8
- package/dist/schemas/ci.js.map +1 -1
- package/dist/schemas/context-trim.d.ts +5 -1
- package/dist/schemas/context-trim.d.ts.map +1 -1
- package/dist/schemas/context-trim.js +8 -4
- package/dist/schemas/context-trim.js.map +1 -1
- package/dist/schemas/devices.d.ts +91 -0
- package/dist/schemas/devices.d.ts.map +1 -1
- package/dist/schemas/devices.js +23 -1
- package/dist/schemas/devices.js.map +1 -1
- package/dist/schemas/environment.d.ts +48 -0
- package/dist/schemas/environment.d.ts.map +1 -1
- package/dist/schemas/environment.js +15 -0
- package/dist/schemas/environment.js.map +1 -1
- package/dist/schemas/extension-updates.d.ts +24 -0
- package/dist/schemas/extension-updates.d.ts.map +1 -1
- package/dist/schemas/git/git.d.ts +13 -0
- package/dist/schemas/git/git.d.ts.map +1 -1
- package/dist/schemas/git/git.js +11 -1
- package/dist/schemas/git/git.js.map +1 -1
- package/dist/schemas/hosts.d.ts +4 -0
- package/dist/schemas/hosts.d.ts.map +1 -1
- package/dist/schemas/hosts.js +3 -1
- package/dist/schemas/hosts.js.map +1 -1
- package/dist/schemas/keep-warm.d.ts +4 -0
- package/dist/schemas/keep-warm.d.ts.map +1 -1
- package/dist/schemas/keep-warm.js +15 -5
- package/dist/schemas/keep-warm.js.map +1 -1
- package/dist/schemas/loopback-catch.d.ts +33 -0
- package/dist/schemas/loopback-catch.d.ts.map +1 -0
- package/dist/schemas/loopback-catch.js +20 -0
- package/dist/schemas/loopback-catch.js.map +1 -0
- package/dist/schemas/maintenance.js +1 -1
- package/dist/schemas/maintenance.js.map +1 -1
- package/dist/schemas/needs.d.ts +664 -0
- package/dist/schemas/needs.d.ts.map +1 -0
- package/dist/schemas/needs.js +203 -0
- package/dist/schemas/needs.js.map +1 -0
- package/dist/schemas/personas.d.ts.map +1 -1
- package/dist/schemas/personas.js +6 -3
- package/dist/schemas/personas.js.map +1 -1
- package/dist/schemas/providers/provider-oauth.d.ts +87 -0
- package/dist/schemas/providers/provider-oauth.d.ts.map +1 -1
- package/dist/schemas/providers/provider-oauth.js +20 -0
- package/dist/schemas/providers/provider-oauth.js.map +1 -1
- package/dist/schemas/secrets.d.ts +84 -0
- package/dist/schemas/secrets.d.ts.map +1 -1
- package/dist/schemas/secrets.js +70 -0
- package/dist/schemas/secrets.js.map +1 -1
- package/dist/schemas/settings-history.d.ts +1 -1
- package/dist/schemas/settings-history.d.ts.map +1 -1
- package/dist/schemas/settings-history.js +1 -0
- package/dist/schemas/settings-history.js.map +1 -1
- package/dist/schemas/settings.d.ts +44 -2
- package/dist/schemas/settings.d.ts.map +1 -1
- package/dist/schemas/settings.js +30 -4
- package/dist/schemas/settings.js.map +1 -1
- package/dist/schemas/state-plan.d.ts +1 -0
- package/dist/schemas/state-plan.d.ts.map +1 -1
- package/dist/schemas/state-plan.js +3 -1
- package/dist/schemas/state-plan.js.map +1 -1
- package/dist/schemas/system.d.ts +20 -0
- package/dist/schemas/system.d.ts.map +1 -1
- package/dist/schemas/system.js +7 -0
- package/dist/schemas/system.js.map +1 -1
- package/dist/schemas/terminal.d.ts +2 -3
- package/dist/schemas/terminal.d.ts.map +1 -1
- package/dist/schemas/terminal.js +12 -4
- package/dist/schemas/terminal.js.map +1 -1
- package/dist/schemas/updates.d.ts +39 -0
- package/dist/schemas/updates.d.ts.map +1 -0
- package/dist/schemas/updates.js +31 -0
- package/dist/schemas/updates.js.map +1 -0
- package/dist/schemas/webext.d.ts +3 -0
- package/dist/schemas/webext.d.ts.map +1 -1
- package/dist/schemas/webext.js +1 -0
- package/dist/schemas/webext.js.map +1 -1
- package/dist/schemas/workflows.js +3 -3
- package/dist/schemas/workflows.js.map +1 -1
- package/dist/schemas/workspace/workspace-tree.d.ts +2 -0
- package/dist/schemas/workspace/workspace-tree.d.ts.map +1 -1
- package/dist/schemas/workspace/workspace-tree.js +4 -0
- package/dist/schemas/workspace/workspace-tree.js.map +1 -1
- package/dist/state/definition.d.ts +28 -4
- package/dist/state/definition.d.ts.map +1 -1
- package/dist/state/history-state.d.ts.map +1 -1
- package/dist/state/history-state.js +10 -0
- package/dist/state/history-state.js.map +1 -1
- package/dist/state/runtime-state.d.ts +0 -3
- package/dist/state/runtime-state.d.ts.map +1 -1
- package/dist/state/runtime-state.js +0 -1
- package/dist/state/runtime-state.js.map +1 -1
- package/dist/state/workspace-state.d.ts +4 -5
- package/dist/state/workspace-state.d.ts.map +1 -1
- package/dist/state/workspace-state.js +1 -6
- package/dist/state/workspace-state.js.map +1 -1
- package/dist/text/documents.d.ts +3 -0
- package/dist/text/documents.d.ts.map +1 -1
- package/dist/text/documents.js +14 -0
- package/dist/text/documents.js.map +1 -1
- package/dist/text/transcript-fold.d.ts +4 -3
- package/dist/text/transcript-fold.d.ts.map +1 -1
- package/dist/text/transcript-fold.js +140 -31
- package/dist/text/transcript-fold.js.map +1 -1
- package/dist/webext/index.d.ts +1 -0
- package/dist/webext/index.d.ts.map +1 -1
- package/dist/webext/index.js +1 -0
- package/dist/webext/index.js.map +1 -1
- package/package.json +5 -5
- package/src/chores/chores.ts +2 -2
- package/src/chores/probes.ts +1 -1
- package/src/contracts/accounts.contract.ts +12 -0
- package/src/contracts/agents.contract.ts +13 -13
- package/src/contracts/capabilities.contract.ts +14 -1
- package/src/contracts/device.contract.ts +5 -0
- package/src/contracts/endpoints.contract.ts +20 -4
- package/src/contracts/needs.contract.ts +103 -0
- package/src/contracts/secrets.contract.ts +45 -3
- package/src/contracts/settings.contract.ts +29 -0
- package/src/contracts/system.contract.ts +19 -14
- package/src/contracts/translator.contract.ts +2 -1
- package/src/contracts/webext.contract.ts +7 -1
- package/src/contracts/workspace.contract.ts +0 -37
- package/src/events/agent-events.ts +22 -1
- package/src/events/agent-words.ts +6 -2
- package/src/events/land-breakage.ts +3 -4
- package/src/events/need-wake.test.ts +55 -0
- package/src/events/need-wake.ts +71 -0
- package/src/events/resume.test.ts +13 -2
- package/src/events/resume.ts +25 -12
- package/src/events/sandbox-notice.ts +92 -0
- package/src/events/system-events.ts +7 -0
- package/src/events/transcript.ts +23 -1
- package/src/events/verify-nudge.ts +3 -3
- package/src/ids/conversation-ids.test.ts +2 -26
- package/src/ids/conversation-ids.ts +6 -12
- package/src/ids/project-dir.fixture.json +65 -0
- package/src/ids/project-dir.test.ts +60 -0
- package/src/ids/project-dir.ts +70 -0
- package/src/index.ts +18 -4
- package/src/models/agent-catalog.test.ts +7 -1
- package/src/models/agent-runtimes.ts +7 -5
- package/src/models/model-roles.ts +1 -9
- package/src/policy/command-classes.test.ts +39 -0
- package/src/policy/command-classes.ts +70 -3
- package/src/policy/safety-policy.ts +10 -0
- package/src/policy/secret-hosts.test.ts +89 -0
- package/src/policy/secret-hosts.ts +73 -0
- package/src/policy/turned-away.ts +1 -0
- package/src/protocol/raw-routes.ts +6 -3
- package/src/protocol/routes.test.ts +6 -6
- package/src/protocol/routes.ts +2 -9
- package/src/protocol/stream-of.ts +13 -0
- package/src/schemas/activity.ts +1 -1
- package/src/schemas/agent.ts +4 -1
- package/src/schemas/agents.ts +72 -5
- package/src/schemas/automations.ts +2 -2
- package/src/schemas/capabilities.ts +72 -7
- package/src/schemas/ci.ts +56 -11
- package/src/schemas/context-trim.ts +11 -6
- package/src/schemas/devices.ts +55 -2
- package/src/schemas/environment.ts +39 -0
- package/src/schemas/git/git.ts +20 -2
- package/src/schemas/hosts.ts +7 -1
- package/src/schemas/keep-warm.ts +19 -6
- package/src/schemas/loopback-catch.ts +45 -0
- package/src/schemas/maintenance.ts +1 -1
- package/src/schemas/needs.ts +301 -0
- package/src/schemas/personas.ts +8 -3
- package/src/schemas/providers/provider-oauth.ts +35 -0
- package/src/schemas/secrets.ts +93 -0
- package/src/schemas/settings-history.ts +2 -0
- package/src/schemas/settings.test.ts +19 -1
- package/src/schemas/settings.ts +66 -9
- package/src/schemas/speaker.ts +5 -5
- package/src/schemas/state-plan.ts +8 -1
- package/src/schemas/system.ts +15 -0
- package/src/schemas/terminal.ts +19 -6
- package/src/schemas/updates.ts +56 -0
- package/src/schemas/webext.ts +3 -0
- package/src/schemas/workflows.ts +5 -5
- package/src/schemas/workspace/workspace-tree.ts +7 -0
- package/src/state/fix-attempt-plan.test.ts +1 -1
- package/src/state/fix-stance.ts +1 -1
- package/src/state/history-state.ts +19 -0
- package/src/state/runtime-state.ts +0 -3
- package/src/state/workspace-state.ts +4 -6
- package/src/text/documents.test.ts +25 -1
- package/src/text/documents.ts +24 -0
- package/src/text/title.ts +1 -1
- package/src/text/transcript-fold.test.ts +218 -25
- package/src/text/transcript-fold.ts +170 -45
- package/src/webext/index.ts +1 -0
- package/dist/schemas/workspace/push-checks.d.ts +0 -222
- package/dist/schemas/workspace/push-checks.d.ts.map +0 -1
- package/dist/schemas/workspace/push-checks.js +0 -97
- package/dist/schemas/workspace/push-checks.js.map +0 -1
- package/dist/state/red-streak.d.ts +0 -7
- package/dist/state/red-streak.d.ts.map +0 -1
- package/dist/state/red-streak.js +0 -11
- package/dist/state/red-streak.js.map +0 -1
- package/src/schemas/workspace/push-checks.test.ts +0 -28
- package/src/schemas/workspace/push-checks.ts +0 -155
- package/src/state/red-streak.test.ts +0 -28
- package/src/state/red-streak.ts +0 -28
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { MEMORY_FILE, PUBLIC_DIR, REFERENCE_DIR, WORKSPACE_ROOT } from "@intentic/constants";
|
|
3
|
+
import { STARTER_REPO } from "../state/starter.js";
|
|
4
|
+
import { isProjectDirName, projectDirNameFor, projectDirNameOf, projectRemoteDir, RESERVED_PROJECT_DIR_NAMES } from "./project-dir.js";
|
|
5
|
+
|
|
6
|
+
// The cases `ic` is held to as well (_sandbox/ic/src/sandbox/project_dir.rs), read from the one file both run.
|
|
7
|
+
interface ProjectDirCases {
|
|
8
|
+
readonly names: readonly { readonly name: string; readonly valid: boolean }[];
|
|
9
|
+
readonly folders: readonly { readonly folder: string; readonly dirName: string }[];
|
|
10
|
+
}
|
|
11
|
+
// SAFETY: the fixture is this repository's own file, written to this shape; one that drifted fails every case below.
|
|
12
|
+
const CASES = JSON.parse(readFileSync(new URL("./project-dir.fixture.json", import.meta.url), "utf8")) as ProjectDirCases;
|
|
13
|
+
|
|
14
|
+
test.each([...CASES.names])("the shared name case $name is valid: $valid", ({ name, valid }) => {
|
|
15
|
+
expect(isProjectDirName(name)).toBe(valid);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test.each([...CASES.folders])("the folder $folder syncs into $dirName", ({ folder, dirName }) => {
|
|
19
|
+
expect(projectDirNameFor(folder)).toBe(dirName);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test("every folder name the slug produces is one the validation accepts, and slugging it again changes nothing", () => {
|
|
23
|
+
for (const { folder } of CASES.folders) {
|
|
24
|
+
const name = projectDirNameFor(folder);
|
|
25
|
+
expect(isProjectDirName(name)).toBe(true);
|
|
26
|
+
expect(projectDirNameFor(name)).toBe(name);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test("the reserved names are the ones the daemon keeps at the workspace root", () => {
|
|
31
|
+
expect([...RESERVED_PROJECT_DIR_NAMES].toSorted()).toEqual(
|
|
32
|
+
[
|
|
33
|
+
PUBLIC_DIR,
|
|
34
|
+
REFERENCE_DIR,
|
|
35
|
+
STARTER_REPO,
|
|
36
|
+
MEMORY_FILE,
|
|
37
|
+
"root",
|
|
38
|
+
"intent",
|
|
39
|
+
"desired-state",
|
|
40
|
+
"app",
|
|
41
|
+
"node_modules",
|
|
42
|
+
"dist",
|
|
43
|
+
"venv",
|
|
44
|
+
"claude.json",
|
|
45
|
+
].toSorted(),
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("a project dir is exactly one valid name under the workspace root", () => {
|
|
50
|
+
expect(projectRemoteDir("my-app")).toBe(`${WORKSPACE_ROOT}/my-app`);
|
|
51
|
+
expect(projectDirNameOf(`${WORKSPACE_ROOT}/my-app`)).toBe("my-app");
|
|
52
|
+
expect(projectDirNameOf(WORKSPACE_ROOT)).toBeUndefined();
|
|
53
|
+
expect(projectDirNameOf(`${WORKSPACE_ROOT}/`)).toBeUndefined();
|
|
54
|
+
expect(projectDirNameOf(`${WORKSPACE_ROOT}/my-app/`)).toBeUndefined();
|
|
55
|
+
expect(projectDirNameOf(`${WORKSPACE_ROOT}/my-app/src`)).toBeUndefined();
|
|
56
|
+
expect(projectDirNameOf(`${WORKSPACE_ROOT}/public`)).toBeUndefined();
|
|
57
|
+
expect(projectDirNameOf(`${WORKSPACE_ROOT}/../etc`)).toBeUndefined();
|
|
58
|
+
expect(projectDirNameOf("/workspace/my-app")).toBeUndefined();
|
|
59
|
+
expect(projectDirNameOf("/srv/work/my-app", "/srv/work")).toBe("my-app");
|
|
60
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { MEMORY_FILE, PUBLIC_DIR, REFERENCE_DIR, WORKSPACE_ROOT } from "@intentic/constants";
|
|
2
|
+
import { STARTER_REPO } from "../state/starter.js";
|
|
3
|
+
|
|
4
|
+
// A PROJECT SANDBOX is made for one folder on the owner's computer, synced live into `/work/<name>` rather than into
|
|
5
|
+
// /work itself: the workspace root is the daemon's own, where it keeps its state, seeds its starter repo and serves
|
|
6
|
+
// `public/` to anyone with a link. `<name>` is derived from the folder's name once, on the owner's side, and every
|
|
7
|
+
// later reader (the sync agent, `ic`, the daemon) only validates it. `_sandbox/ic/src/sandbox/project_dir.rs` holds the
|
|
8
|
+
// validation again for the host side; `project-dir.fixture.json` is the one set of cases both run.
|
|
9
|
+
|
|
10
|
+
// Top-level names the daemon treats as its own, so a project can never land on one: the public outbox, the reference
|
|
11
|
+
// shelf, the starter repo seeded on first boot, the root repo's id and the three repo roles repo discovery refuses
|
|
12
|
+
// (`_sandbox/sandbox/src/workspace/layout/repo-discovery.ts`), and the standing-instructions file it writes. Then the
|
|
13
|
+
// names every walk of the workspace skips at any depth (@intentic/workspace-ignore IGNORED_DIRS, and the private file
|
|
14
|
+
// the git scopes leave out), where a project would sync and never be seen; the daemon's tests hold this list to that
|
|
15
|
+
// one. Everything else of either kind starts with a dot (`.intentic`, `.venv`), which the name rule below refuses.
|
|
16
|
+
export const RESERVED_PROJECT_DIR_NAMES: readonly string[] = [
|
|
17
|
+
PUBLIC_DIR,
|
|
18
|
+
REFERENCE_DIR,
|
|
19
|
+
STARTER_REPO,
|
|
20
|
+
"root",
|
|
21
|
+
"intent",
|
|
22
|
+
"desired-state",
|
|
23
|
+
"app",
|
|
24
|
+
MEMORY_FILE,
|
|
25
|
+
"node_modules",
|
|
26
|
+
"dist",
|
|
27
|
+
"venv",
|
|
28
|
+
"claude.json",
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
// Starts alphanumeric, so no dot-file and no leading dash an argv could read as a flag; no separator, so it is always
|
|
32
|
+
// one path segment; bounded, since it also names a git dir and a folder in every view of the workspace.
|
|
33
|
+
const PROJECT_DIR_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
34
|
+
const PROJECT_DIR_NAME_MAX = 64;
|
|
35
|
+
|
|
36
|
+
// Used when nothing of the folder's name survives the slug (a name in another script, or only punctuation).
|
|
37
|
+
const FALLBACK_NAME = "project";
|
|
38
|
+
|
|
39
|
+
// Combining marks, which NFKD splits off an accented letter.
|
|
40
|
+
const COMBINING_MARKS = /[\u0300-\u036f]/g;
|
|
41
|
+
|
|
42
|
+
export const isProjectDirName = (name: string): boolean => PROJECT_DIR_NAME.test(name) && !RESERVED_PROJECT_DIR_NAMES.includes(name);
|
|
43
|
+
|
|
44
|
+
// The workspace-relative name for a folder the owner picked, always one `isProjectDirName` accepts. Accents are folded
|
|
45
|
+
// to their base letter first, so `Café` keeps its `e` rather than losing it to a dash.
|
|
46
|
+
export const projectDirNameFor = (folderBasename: string): string => {
|
|
47
|
+
const slug = folderBasename
|
|
48
|
+
.normalize("NFKD")
|
|
49
|
+
.replace(COMBINING_MARKS, "")
|
|
50
|
+
.replace(/[^A-Za-z0-9._-]+/g, "-")
|
|
51
|
+
.replace(/-{2,}/g, "-")
|
|
52
|
+
.replace(/^[._-]+/, "")
|
|
53
|
+
.slice(0, PROJECT_DIR_NAME_MAX)
|
|
54
|
+
.replace(/[.-]+$/, "");
|
|
55
|
+
const name = slug === "" ? FALLBACK_NAME : slug;
|
|
56
|
+
return RESERVED_PROJECT_DIR_NAMES.includes(name) ? `${name}-project` : name;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// Where a project folder lands in the sandbox, and the name back out of such a path: exactly `<root>/<name>`, anything
|
|
60
|
+
// else (a deeper path, a trailing slash, a reserved name) is not a project dir.
|
|
61
|
+
export const projectRemoteDir = (name: string): string => `${WORKSPACE_ROOT}/${name}`;
|
|
62
|
+
|
|
63
|
+
export const projectDirNameOf = (remoteDir: string, root: string = WORKSPACE_ROOT): string | undefined => {
|
|
64
|
+
const prefix = `${root}/`;
|
|
65
|
+
if (!remoteDir.startsWith(prefix)) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
const name = remoteDir.slice(prefix.length);
|
|
69
|
+
return isProjectDirName(name) ? name : undefined;
|
|
70
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -32,6 +32,7 @@ import { netdiskContract } from "./contracts/netdisk.contract.js";
|
|
|
32
32
|
import { providersContract } from "./contracts/providers.contract.js";
|
|
33
33
|
import { pushContract } from "./contracts/push.contract.js";
|
|
34
34
|
import { safetyContract } from "./contracts/safety.contract.js";
|
|
35
|
+
import { needsContract } from "./contracts/needs.contract.js";
|
|
35
36
|
import { secretsContract } from "./contracts/secrets.contract.js";
|
|
36
37
|
import { sessionsContract } from "./contracts/sessions.contract.js";
|
|
37
38
|
import { settingsContract } from "./contracts/settings.contract.js";
|
|
@@ -57,6 +58,8 @@ export { choresContract } from "./contracts/chores.contract.js";
|
|
|
57
58
|
export { ciContract } from "./contracts/ci.contract.js";
|
|
58
59
|
export {
|
|
59
60
|
endpointsContract,
|
|
61
|
+
type LocalModelDevice,
|
|
62
|
+
LocalModelDeviceSchema,
|
|
60
63
|
LocalModelFitSchema,
|
|
61
64
|
type LocalModelFitResponse,
|
|
62
65
|
type LocalModelGpu,
|
|
@@ -92,6 +95,7 @@ export { publicContract } from "./contracts/public.contract.js";
|
|
|
92
95
|
export { providersContract, type RunnableProviders, RunnableProvidersSchema } from "./contracts/providers.contract.js";
|
|
93
96
|
export { pushContract } from "./contracts/push.contract.js";
|
|
94
97
|
export { safetyContract } from "./contracts/safety.contract.js";
|
|
98
|
+
export { needsContract } from "./contracts/needs.contract.js";
|
|
95
99
|
export { secretsContract } from "./contracts/secrets.contract.js";
|
|
96
100
|
export { sessionsContract } from "./contracts/sessions.contract.js";
|
|
97
101
|
export { settingsContract } from "./contracts/settings.contract.js";
|
|
@@ -109,12 +113,14 @@ export * from "./events/agent-events.js";
|
|
|
109
113
|
export * from "./events/agent-words.js";
|
|
110
114
|
export * from "./events/requests.js";
|
|
111
115
|
export * from "./events/resume.js";
|
|
116
|
+
export * from "./events/sandbox-notice.js";
|
|
112
117
|
export * from "./events/system-events.js";
|
|
113
118
|
export * from "./events/transcript.js";
|
|
114
119
|
export * from "./events/land-breakage.js";
|
|
115
120
|
export * from "./events/land-conflict.js";
|
|
116
121
|
export * from "./events/verify-nudge.js";
|
|
117
122
|
export * from "./events/errands.js";
|
|
123
|
+
export * from "./events/need-wake.js";
|
|
118
124
|
export * from "./events/watch-wake.js";
|
|
119
125
|
export * from "./policy/request-status.js";
|
|
120
126
|
export * from "./events/child-run.js";
|
|
@@ -136,7 +142,6 @@ export * from "./state/history-state.js";
|
|
|
136
142
|
export * from "./state/fix-stance.js";
|
|
137
143
|
export * from "./state/landed-commit.js";
|
|
138
144
|
export * from "./state/fix-attempt-plan.js";
|
|
139
|
-
export * from "./state/red-streak.js";
|
|
140
145
|
// Provider vocabulary bottom-up: agent-runtimes, provider-specs, agent-catalog; three modules since the dependency
|
|
141
146
|
// points one way.
|
|
142
147
|
export * from "./models/agent-runtimes.js";
|
|
@@ -149,6 +154,7 @@ export * from "./policy/safety-policy.js";
|
|
|
149
154
|
export * from "./policy/reserved-servers.js";
|
|
150
155
|
export * from "./policy/credential-material.js";
|
|
151
156
|
export * from "./policy/capability-secrets.js";
|
|
157
|
+
export * from "./policy/secret-hosts.js";
|
|
152
158
|
export * from "./ids/conversation-ids.js";
|
|
153
159
|
export * from "./text/documents.js";
|
|
154
160
|
export * from "./protocol/host-protocol.js";
|
|
@@ -158,6 +164,7 @@ export * from "./protocol/runner-protocol.js";
|
|
|
158
164
|
export * from "./protocol/listener-protocol.js";
|
|
159
165
|
export * from "./protocol/container-requirements.js";
|
|
160
166
|
export * from "./ids/hostnames.js";
|
|
167
|
+
export * from "./ids/project-dir.js";
|
|
161
168
|
export * from "./policy/overlay-lint.js";
|
|
162
169
|
export * from "./models/model-label.js";
|
|
163
170
|
export * from "./models/model-order.js";
|
|
@@ -197,6 +204,7 @@ export * from "./schemas/git/git.js";
|
|
|
197
204
|
export * from "./schemas/git/git-history.js";
|
|
198
205
|
export * from "./schemas/history.js";
|
|
199
206
|
export * from "./schemas/hosts.js";
|
|
207
|
+
export * from "./schemas/loopback-catch.js";
|
|
200
208
|
export * from "./schemas/intentic.js";
|
|
201
209
|
export * from "./schemas/inventory.js";
|
|
202
210
|
export * from "./schemas/issues.js";
|
|
@@ -214,6 +222,7 @@ export * from "./schemas/providers/provider-subscriptions.js";
|
|
|
214
222
|
export * from "./schemas/public.js";
|
|
215
223
|
export * from "./schemas/push.js";
|
|
216
224
|
export * from "./schemas/git/remote-refs.js";
|
|
225
|
+
export * from "./schemas/needs.js";
|
|
217
226
|
export * from "./schemas/secrets.js";
|
|
218
227
|
export * from "./schemas/netdisk.js";
|
|
219
228
|
export * from "./schemas/sessions.js";
|
|
@@ -224,6 +233,7 @@ export * from "./schemas/shared.js";
|
|
|
224
233
|
export * from "./schemas/system-prompt.js";
|
|
225
234
|
export * from "./schemas/system.js";
|
|
226
235
|
export * from "./schemas/state-plan.js";
|
|
236
|
+
export * from "./schemas/updates.js";
|
|
227
237
|
export * from "./schemas/terminal.js";
|
|
228
238
|
export * from "./schemas/turn-break.js";
|
|
229
239
|
export * from "./schemas/keep-warm.js";
|
|
@@ -234,7 +244,6 @@ export * from "./schemas/webext.js";
|
|
|
234
244
|
export * from "./schemas/workflows.js";
|
|
235
245
|
export * from "./schemas/workspace/workspace-repos.js";
|
|
236
246
|
export * from "./schemas/workspace/workspace-search.js";
|
|
237
|
-
export * from "./schemas/workspace/push-checks.js";
|
|
238
247
|
export * from "./schemas/workspace/workspace-setup.js";
|
|
239
248
|
export * from "./schemas/workspace/workspace-tree.js";
|
|
240
249
|
export * from "./state/arrival.js";
|
|
@@ -285,6 +294,7 @@ export const sandboxContract = {
|
|
|
285
294
|
public: publicContract,
|
|
286
295
|
providers: providersContract,
|
|
287
296
|
push: pushContract,
|
|
297
|
+
needs: needsContract,
|
|
288
298
|
secrets: secretsContract,
|
|
289
299
|
system: systemContract,
|
|
290
300
|
translator: translatorContract,
|
|
@@ -302,8 +312,12 @@ export const SANDBOX_ROUTES: readonly ContractRoute[] = contractRoutes(sandboxCo
|
|
|
302
312
|
export const SANDBOX_ROUTE_NAMES: readonly string[] = SANDBOX_ROUTES.map((route) => route.name);
|
|
303
313
|
|
|
304
314
|
// Each route's shape, for the failure names alone can't describe: a route both builds have, but whose payload only one
|
|
305
|
-
// expects. Computed
|
|
306
|
-
|
|
315
|
+
// expects. Computed on the first ask and kept, since it's too expensive to repeat per connection — and too expensive to
|
|
316
|
+
// pay at load: turning every route's schemas into JSON Schema was a third of a second of a phone's startup at 4× CPU
|
|
317
|
+
// throttle, for a comparison a browser only makes when it has a disagreement to explain (the version card). The daemon
|
|
318
|
+
// asks on its first hello.
|
|
319
|
+
let fingerprints: Readonly<Record<string, string>> | undefined;
|
|
320
|
+
export const sandboxRouteFingerprints = (): Readonly<Record<string, string>> => (fingerprints ??= routeShapes(sandboxContract));
|
|
307
321
|
|
|
308
322
|
// The contract route a concrete browser request belongs to, bound to this build's route table.
|
|
309
323
|
export const sandboxRouteName = (method: string, pathWithQuery: string): string | undefined =>
|
|
@@ -126,6 +126,9 @@ test("the ceiling has nothing to disclose; a floor names what it lacks", () => {
|
|
|
126
126
|
expect(grokCaps.steering).toBe(false);
|
|
127
127
|
expect(grokCaps.isolation).toBe("cwd");
|
|
128
128
|
expect(limitationsOf(grokCaps).length).toBeGreaterThan(0);
|
|
129
|
+
// The turn's remote servers, as Codex takes them: mounted on the shared OpenCode server per conversation.
|
|
130
|
+
expect(grokCaps.mcp).toBe("http");
|
|
131
|
+
expect(limitationsOf(grokCaps)).toContain("MCP servers only, none of the daemon's own tools, no plugins");
|
|
129
132
|
|
|
130
133
|
const acpCaps = capabilitiesOf("some-installed-agent", "native");
|
|
131
134
|
expect(acpCaps.mcp).toBe("http");
|
|
@@ -178,7 +181,10 @@ test("the safety axes disclose the middle answer differently from the floor", ()
|
|
|
178
181
|
|
|
179
182
|
expect(codexCaps.rulebook).toBe("approval");
|
|
180
183
|
expect(piCaps.rulebook).toBe("none");
|
|
181
|
-
expect(grokCaps.rulebook).toBe("
|
|
184
|
+
expect(grokCaps.rulebook).toBe("approval");
|
|
185
|
+
// A hold parks on a card now that the turn's watchdog is held while it waits, so nothing says it cannot hold.
|
|
186
|
+
expect(limitationsOf(grokCaps)).toContain("command rules apply only to calls this agent raises");
|
|
187
|
+
expect(limitationsOf(grokCaps)).not.toContain("command rules can refuse but not hold");
|
|
182
188
|
|
|
183
189
|
expect(limitationsOf(claudeCaps).join(" ")).not.toContain("command rules");
|
|
184
190
|
expect(limitationsOf(claudeCaps).join(" ")).not.toContain("stored secrets");
|
|
@@ -102,14 +102,15 @@ export const CODEX: AgentCapabilities = {
|
|
|
102
102
|
secrets: "none",
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
-
// OpenCode (the Grok runtime): its own agentic loop
|
|
106
|
-
// and one system message of ours; no effort scale, no
|
|
105
|
+
// OpenCode (the Grok runtime): its own agentic loop and tools, with the turn's remote MCP servers mounted on the shared
|
|
106
|
+
// server per conversation. Takes a model id, a prompt and one system message of ours; no effort scale, no command list.
|
|
107
107
|
export const OPENCODE: AgentCapabilities = {
|
|
108
108
|
runtime: "opencode",
|
|
109
109
|
steering: false,
|
|
110
110
|
permissions: "plan",
|
|
111
111
|
questions: false,
|
|
112
|
-
|
|
112
|
+
// Added at runtime under the conversation's own names, each prompt showing its session only its own (opencode-mcp.ts).
|
|
113
|
+
mcp: "http",
|
|
113
114
|
execution: ["shell"],
|
|
114
115
|
effort: false,
|
|
115
116
|
fastMode: false,
|
|
@@ -121,8 +122,9 @@ export const OPENCODE: AgentCapabilities = {
|
|
|
121
122
|
// `system` on the prompt body, per message; adds to OpenCode's own prompt, with no seam to replace it.
|
|
122
123
|
instructions: "append",
|
|
123
124
|
skillDiscovery: "prompt",
|
|
124
|
-
//
|
|
125
|
-
|
|
125
|
+
// OpenCode raises its permission asks for the commands its config names; the daemon answers from the rulebook, a
|
|
126
|
+
// hold parked on a card while the turn's inactivity watchdog is held.
|
|
127
|
+
rulebook: "approval",
|
|
126
128
|
secrets: "none",
|
|
127
129
|
};
|
|
128
130
|
|
|
@@ -71,7 +71,7 @@ export const MODEL_ROLES = [
|
|
|
71
71
|
{
|
|
72
72
|
id: "pipeline-fix",
|
|
73
73
|
label: "Pipeline fixes",
|
|
74
|
-
blurb: "The agent started by Fix on a
|
|
74
|
+
blurb: "The agent started by Fix on a failed pipeline.",
|
|
75
75
|
kind: "run",
|
|
76
76
|
trigger: "pressed",
|
|
77
77
|
icon: "wave-pulse",
|
|
@@ -108,14 +108,6 @@ export const MODEL_ROLES = [
|
|
|
108
108
|
trigger: "pressed",
|
|
109
109
|
icon: "list-check",
|
|
110
110
|
},
|
|
111
|
-
{
|
|
112
|
-
id: "pre-push-fix",
|
|
113
|
-
label: "Pre-push fixes",
|
|
114
|
-
blurb: "The fix proposed when a check fails on the way to a push.",
|
|
115
|
-
kind: "run",
|
|
116
|
-
trigger: "pressed",
|
|
117
|
-
icon: "cloud-upload",
|
|
118
|
-
},
|
|
119
111
|
{
|
|
120
112
|
// Pressed trigger: the owner's approval click starts this turn; the queue between is just machinery.
|
|
121
113
|
id: "approval-queue",
|
|
@@ -40,6 +40,22 @@ describe("git.destructive", () => {
|
|
|
40
40
|
test("a -f belonging to the next command in a pipeline is not a force-push", () => {
|
|
41
41
|
expect(classify("git push origin main | grep -f patterns.txt")).not.toContain("git.destructive");
|
|
42
42
|
});
|
|
43
|
+
|
|
44
|
+
test("deleting a checkout's .git, or re-initialising the folder it stands in, cuts it off from its history", () => {
|
|
45
|
+
for (const command of ["rm .git", "rm -f .git", "rm -rf ./.git", "rm -rf tabularium/.git", "rm .git && git init -b main"]) {
|
|
46
|
+
expect(classify(command), command).toContain("git.destructive");
|
|
47
|
+
}
|
|
48
|
+
for (const command of ["git init", "git init .", "git init -b main", "git init --initial-branch main -q ."]) {
|
|
49
|
+
expect(classify(command), command).toContain("git.destructive");
|
|
50
|
+
}
|
|
51
|
+
expect(marked("cd /work && rm .git && git init -b main", "git.destructive")).toEqual(["rm .git", "git init -b main"]);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test("a new project's git init, and files that merely start with .git, are left alone", () => {
|
|
55
|
+
for (const command of ["git init new-project", "git init -b main tools/cli", "rm .gitignore", "rm -f .github/old.yml", "rm .gitmodules"]) {
|
|
56
|
+
expect(classify(command), command).not.toContain("git.destructive");
|
|
57
|
+
}
|
|
58
|
+
});
|
|
43
59
|
});
|
|
44
60
|
|
|
45
61
|
describe("files.destructive", () => {
|
|
@@ -72,6 +88,27 @@ describe("files.destructive", () => {
|
|
|
72
88
|
}
|
|
73
89
|
});
|
|
74
90
|
|
|
91
|
+
test("find deleting what it walks, or handing it to rm, is the same delete as rm -rf", () => {
|
|
92
|
+
for (const command of [
|
|
93
|
+
"find /home/x/PROJECT/cerberus-worktrees/m1-a -depth -delete",
|
|
94
|
+
"find build -name '*.o' -delete",
|
|
95
|
+
"find . -type d -name node_modules -exec rm -rf {} +",
|
|
96
|
+
"find dist -exec /bin/rm -f {} \\;",
|
|
97
|
+
"find tmp -execdir rm {} \\;",
|
|
98
|
+
"find . -name '*.log' -print0 | xargs -0 rm -f",
|
|
99
|
+
"ls old | xargs rm",
|
|
100
|
+
]) {
|
|
101
|
+
expect(classify(command), command).toContain("files.destructive");
|
|
102
|
+
}
|
|
103
|
+
expect(marked("find build -name '*.o' -delete; echo done", "files.destructive")).toEqual(["find build -name '*.o' -delete"]);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test("a find that only lists, and an xargs that runs something else, pass", () => {
|
|
107
|
+
for (const command of ["find . -name '*.ts'", "find . -newer deleted.txt -print", "find src -exec grep -l rm {} +", "ls | xargs wc -l"]) {
|
|
108
|
+
expect(classify(command), command).not.toContain("files.destructive");
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
|
|
75
112
|
test("a script that deletes one file, or nothing, is not recursive deletion", () => {
|
|
76
113
|
for (const code of ['fs.unlinkSync("tmp.txt")', 'await fs.promises.rm("tmp.txt")', "const rmq = queue.rm(job)"]) {
|
|
77
114
|
expect(classify(code), code).not.toContain("files.destructive");
|
|
@@ -113,6 +150,8 @@ describe("system.destructive", () => {
|
|
|
113
150
|
"rm -rf C:\\",
|
|
114
151
|
'fs.rmSync("/", { recursive: true, force: true })',
|
|
115
152
|
'rimraf("/work")',
|
|
153
|
+
"find / -delete",
|
|
154
|
+
"find /home -type f -delete",
|
|
116
155
|
]) {
|
|
117
156
|
expect(classify(command), command).toContain("system.destructive");
|
|
118
157
|
}
|
|
@@ -375,6 +375,66 @@ const recursiveForceRms = (command: string): CommandSpan[] =>
|
|
|
375
375
|
.filter((invocation) => invocation.recursive && invocation.force)
|
|
376
376
|
.map((invocation) => invocation.span);
|
|
377
377
|
|
|
378
|
+
// The same tree delete spelled without `rm -rf`: `find` deleting what it walks, or handing each hit to `rm`, and a list
|
|
379
|
+
// piped into `rm` through xargs. An agent told `rm -rf` needs a card reaches for exactly these.
|
|
380
|
+
const FIND_INVOCATION = /\bfind\s+([^|;&\n]*)/g;
|
|
381
|
+
const FIND_DELETES = /\s(?:-delete\b|-exec(?:dir)?\s+(?:[^\s|;&]*\/)?rm\b)/;
|
|
382
|
+
const XARGS_RM = /\bxargs\b[^|;&\n]*?\s(?:[^\s|;&]*\/)?rm\b/g;
|
|
383
|
+
|
|
384
|
+
interface FindDelete {
|
|
385
|
+
// The paths find starts walking from: the words before its first expression (`-name`, `(`, `!`).
|
|
386
|
+
readonly starts: readonly string[];
|
|
387
|
+
readonly span: CommandSpan;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
const parseFindDeletes = (command: string): FindDelete[] =>
|
|
391
|
+
[...command.matchAll(FIND_INVOCATION)].flatMap((invocation) => {
|
|
392
|
+
const args = invocation[1] as string;
|
|
393
|
+
if (!FIND_DELETES.test(` ${args}`)) {
|
|
394
|
+
return [];
|
|
395
|
+
}
|
|
396
|
+
const words = args.trim().split(/\s+/);
|
|
397
|
+
const expression = words.findIndex((word) => /^[-(!]/.test(word));
|
|
398
|
+
const starts = (expression === -1 ? words : words.slice(0, expression)).filter((word) => word !== "").map(unquote);
|
|
399
|
+
return [{ starts, span: { start: invocation.index, end: invocation.index + invocation[0].trimEnd().length } }];
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
const findAndXargsDeletes = (command: string): CommandSpan[] => [
|
|
403
|
+
...parseFindDeletes(command).map((found) => found.span),
|
|
404
|
+
...spansOf([XARGS_RM], command),
|
|
405
|
+
];
|
|
406
|
+
|
|
407
|
+
// What cuts a checkout off from its repository's history: deleting its `.git` (for a worktree, a one-line pointer
|
|
408
|
+
// whose loss strands every commit the checkout was reading), or `git init` over the folder it stands in, which makes
|
|
409
|
+
// a standalone repository sharing nothing with the one it came from. A `git init <new-dir>` for a new project is not
|
|
410
|
+
// this, so only an init of the current folder counts.
|
|
411
|
+
const GIT_POINTER = /(?:^|[/\\])\.git[/\\]?$/;
|
|
412
|
+
const GIT_INIT = /\bgit\s+init\b([^|;&\n]*)/g;
|
|
413
|
+
const GIT_INIT_VALUED = /^(?:-b|--initial-branch|--template|--separate-git-dir|--object-format|--ref-format)$/;
|
|
414
|
+
|
|
415
|
+
const initsHere = (args: string): boolean => {
|
|
416
|
+
const words = args.trim().split(/\s+/).filter((word) => word !== "");
|
|
417
|
+
const operands: string[] = [];
|
|
418
|
+
for (let index = 0; index < words.length; index += 1) {
|
|
419
|
+
const word = words[index] as string;
|
|
420
|
+
if (GIT_INIT_VALUED.test(word)) {
|
|
421
|
+
index += 1;
|
|
422
|
+
} else if (!word.startsWith("-")) {
|
|
423
|
+
operands.push(unquote(word));
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
return operands.every((operand) => operand === "." || operand === "./");
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
const checkoutUnlinks = (command: string): CommandSpan[] => [
|
|
430
|
+
...parseRm(command)
|
|
431
|
+
.filter((invocation) => invocation.operands.some((operand) => GIT_POINTER.test(operand)))
|
|
432
|
+
.map((invocation) => invocation.span),
|
|
433
|
+
...[...command.matchAll(GIT_INIT)]
|
|
434
|
+
.filter((invocation) => initsHere(invocation[1] as string))
|
|
435
|
+
.map((invocation) => ({ start: invocation.index, end: invocation.index + invocation[0].trimEnd().length })),
|
|
436
|
+
];
|
|
437
|
+
|
|
378
438
|
// A recursive delete aimed at a root, in either spelling the gate is handed (shell or script). Which targets count as
|
|
379
439
|
// roots is the locus's answer.
|
|
380
440
|
const rootDeletes = (program: string, locus: CommandLocus): CommandSpan[] => [
|
|
@@ -384,6 +444,9 @@ const rootDeletes = (program: string, locus: CommandLocus): CommandSpan[] => [
|
|
|
384
444
|
...nodeDeleteTargets(program)
|
|
385
445
|
.filter((delete_) => isRootTarget(delete_.target, locus))
|
|
386
446
|
.map((delete_) => delete_.span),
|
|
447
|
+
...parseFindDeletes(program)
|
|
448
|
+
.filter((found) => found.starts.some((start) => isRootTarget(start, locus)))
|
|
449
|
+
.map((found) => found.span),
|
|
387
450
|
];
|
|
388
451
|
|
|
389
452
|
// The g twins, built once at load: a card is minted per command held, classify runs per command typed.
|
|
@@ -434,10 +497,10 @@ const credentialReads = (command: string, context: CommandContext): CommandSpan[
|
|
|
434
497
|
|
|
435
498
|
// One function per class; empty means the command is not in it, so membership and evidence are the same walk.
|
|
436
499
|
const MATCHES: Readonly<Record<CommandClass, (command: string, context: CommandContext) => CommandSpan[]>> = {
|
|
437
|
-
"git.destructive": (command) => spansOf(GIT_DESTRUCTIVE_G, command),
|
|
500
|
+
"git.destructive": (command) => [...spansOf(GIT_DESTRUCTIVE_G, command), ...checkoutUnlinks(command)],
|
|
438
501
|
// The only class that can answer "not here": in its own copy a conversation's checkout is its own to move.
|
|
439
502
|
"git.branch-switch": (command, context) => (context.ownCheckout === true ? [] : spansOf(GIT_BRANCH_SWITCH_G, command)),
|
|
440
|
-
"files.destructive": (command) => [...recursiveForceRms(command), ...recursiveDeletes(command)],
|
|
503
|
+
"files.destructive": (command) => [...recursiveForceRms(command), ...recursiveDeletes(command), ...findAndXargsDeletes(command)],
|
|
441
504
|
"system.destructive": (command, context) => [...spansOf(BLOCK_DEVICE_G, command), ...rootDeletes(command, context.locus)],
|
|
442
505
|
"container.state": (command) => spansOf(CONTAINER_STATE_G, command),
|
|
443
506
|
"secrets.access": credentialReads,
|
|
@@ -489,6 +552,8 @@ export const COMMAND_CLASS_PATTERNS: Readonly<Record<CommandClass, readonly Comm
|
|
|
489
552
|
{ code: "git clean -f" },
|
|
490
553
|
{ code: "git branch -D" },
|
|
491
554
|
{ code: "git filter-branch" },
|
|
555
|
+
{ code: "rm .git", qualifier: "any flags: a checkout's link to its history" },
|
|
556
|
+
{ code: "git init", qualifier: "only in the current folder, which may already be a checkout" },
|
|
492
557
|
],
|
|
493
558
|
"git.branch-switch": [
|
|
494
559
|
{ code: "git switch <branch>" },
|
|
@@ -498,6 +563,8 @@ export const COMMAND_CLASS_PATTERNS: Readonly<Record<CommandClass, readonly Comm
|
|
|
498
563
|
{ code: "rm -rf <path>" },
|
|
499
564
|
{ code: "fs.rm(<path>, { recursive: true })", qualifier: "also rmSync, rmdir, rmdirSync" },
|
|
500
565
|
{ code: "rimraf(<path>)" },
|
|
566
|
+
{ code: "find <path> -delete", qualifier: "also -exec rm and -execdir rm" },
|
|
567
|
+
{ code: "xargs rm" },
|
|
501
568
|
],
|
|
502
569
|
"system.destructive": [
|
|
503
570
|
{ code: "mkfs" },
|
|
@@ -507,7 +574,7 @@ export const COMMAND_CLASS_PATTERNS: Readonly<Record<CommandClass, readonly Comm
|
|
|
507
574
|
{ code: "dd of=/dev/…" },
|
|
508
575
|
{ code: "shred /dev/…" },
|
|
509
576
|
{ code: "> /dev/sda" },
|
|
510
|
-
{ code: "rm -rf /", qualifier: "only when the target is a root, listed below" },
|
|
577
|
+
{ code: "rm -rf /", qualifier: "also find / -delete; only when the target is a root, listed below" },
|
|
511
578
|
],
|
|
512
579
|
"container.state": [
|
|
513
580
|
{ code: "docker volume rm", qualifier: "also remove, prune, and podman for any of these" },
|
|
@@ -64,6 +64,15 @@ export const COMMAND_RULE_CATALOG: readonly CommandRule[] = CommandClassSchema.o
|
|
|
64
64
|
export const CommandJudgeModeSchema = z.enum(["off", "watch", "on"]);
|
|
65
65
|
export type CommandJudgeMode = z.infer<typeof CommandJudgeModeSchema>;
|
|
66
66
|
|
|
67
|
+
// What an agent's own project-dependency install (`pnpm add`, `npm install`, `uv sync`) does, one answer for every
|
|
68
|
+
// turn. Where the install lands is the sandbox's business, not the owner's: an isolated turn installs into its own copy
|
|
69
|
+
// and a main-tree turn takes the install lane the daemon's own installs take. This only says whether a person is asked:
|
|
70
|
+
// - automatic: it runs
|
|
71
|
+
// - ask: a card in the turn; the turn waits on that one call, and "allow for this conversation" stops the asking
|
|
72
|
+
// - never: refused; the manifest change still lands and the daemon installs it then
|
|
73
|
+
export const ProjectInstallModeSchema = z.enum(["automatic", "ask", "never"]);
|
|
74
|
+
export type ProjectInstallMode = z.infer<typeof ProjectInstallModeSchema>;
|
|
75
|
+
|
|
67
76
|
// What the judge answers, one instruction per verdict:
|
|
68
77
|
// - allow: run it, say nothing, the ordinary answer for a triage false positive
|
|
69
78
|
// - ask: raise the card; the only path to a person, meant to be rare
|
|
@@ -122,6 +131,7 @@ Ask me before:
|
|
|
122
131
|
|
|
123
132
|
- publishing or releasing anything (npm publish, a GitHub release, a container push);
|
|
124
133
|
- force-pushing, hard-resetting or otherwise discarding commits that are not this turn's own work;
|
|
134
|
+
- deleting a checkout's \`.git\` or running \`git init\` in a folder that already is one: in a worktree that cuts it off from my workspace's history, and its work can no longer come back to me;
|
|
125
135
|
- moving a checkout onto another branch (\`git checkout <branch>\`, \`git switch\`) — you only ever see this for a tree that is mine as well as yours, never for a copy of your own, so the worktree paragraph above does not cover it;
|
|
126
136
|
- sending a credential anywhere outside this container.
|
|
127
137
|
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { hostAllowed, hostMatches, normalizeHost, normalizeHostPattern, tightensHostGuard } from "./secret-hosts.js";
|
|
2
|
+
|
|
3
|
+
// The pattern a person writes against the host a use would reach. Every boundary a limit turns on is pinned by value:
|
|
4
|
+
// the apex a wildcard leaves out, the look-alike that only shares a suffix, and which edits take hosts away.
|
|
5
|
+
|
|
6
|
+
describe("normalizeHostPattern", () => {
|
|
7
|
+
it("reads what a person types or pastes as the host it means", () => {
|
|
8
|
+
expect(normalizeHostPattern(" API.GitHub.com. ")).toBe("api.github.com");
|
|
9
|
+
expect(normalizeHostPattern("https://api.github.com/user?per_page=5")).toBe("api.github.com");
|
|
10
|
+
expect(normalizeHostPattern("api.github.com:443")).toBe("api.github.com");
|
|
11
|
+
expect(normalizeHostPattern("*.githubusercontent.com")).toBe("*.githubusercontent.com");
|
|
12
|
+
expect(normalizeHostPattern("localhost")).toBe("localhost");
|
|
13
|
+
expect(normalizeHostPattern("10.0.0.2")).toBe("10.0.0.2");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("refuses what is not one host or one domain's hosts", () => {
|
|
17
|
+
expect(normalizeHostPattern("*")).toBeUndefined();
|
|
18
|
+
expect(normalizeHostPattern("*.com")).toBeUndefined();
|
|
19
|
+
expect(normalizeHostPattern("api.*.com")).toBeUndefined();
|
|
20
|
+
expect(normalizeHostPattern("api.github.com/user")).toBeUndefined();
|
|
21
|
+
expect(normalizeHostPattern("user@api.github.com")).toBeUndefined();
|
|
22
|
+
expect(normalizeHostPattern("-bad.example.com")).toBeUndefined();
|
|
23
|
+
expect(normalizeHostPattern("")).toBeUndefined();
|
|
24
|
+
expect(normalizeHostPattern(`${"a".repeat(64)}.com`)).toBeUndefined();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe("normalizeHost", () => {
|
|
29
|
+
it("takes a plain host or address and nothing shaped like a pattern or a stray token", () => {
|
|
30
|
+
expect(normalizeHost("API.github.com.")).toBe("api.github.com");
|
|
31
|
+
expect(normalizeHost("*.github.com")).toBeUndefined();
|
|
32
|
+
expect(normalizeHost("[::1]")).toBeUndefined();
|
|
33
|
+
expect(normalizeHost("api.github.com\u0001")).toBeUndefined();
|
|
34
|
+
expect(normalizeHost("$host")).toBeUndefined();
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe("hostMatches", () => {
|
|
39
|
+
it("matches an exact host only to itself", () => {
|
|
40
|
+
expect(hostMatches("api.github.com", "api.github.com")).toBe(true);
|
|
41
|
+
expect(hostMatches("api.github.com", "github.com")).toBe(false);
|
|
42
|
+
expect(hostMatches("github.com", "api.github.com")).toBe(false);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("matches a wildcard to every host under the domain, at any depth, and not to the domain itself", () => {
|
|
46
|
+
expect(hostMatches("*.github.com", "api.github.com")).toBe(true);
|
|
47
|
+
expect(hostMatches("*.github.com", "a.b.github.com")).toBe(true);
|
|
48
|
+
expect(hostMatches("*.github.com", "github.com")).toBe(false);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("does not match a host that merely ends in the same letters", () => {
|
|
52
|
+
expect(hostMatches("*.github.com", "evilgithub.com")).toBe(false);
|
|
53
|
+
expect(hostMatches("*.github.com", "github.com.evil.example")).toBe(false);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("allows a host any one pattern in the list matches", () => {
|
|
57
|
+
expect(hostAllowed(["api.github.com", "*.githubusercontent.com"], "raw.githubusercontent.com")).toBe(true);
|
|
58
|
+
expect(hostAllowed(["api.github.com", "*.githubusercontent.com"], "evil.example")).toBe(false);
|
|
59
|
+
expect(hostAllowed([], "api.github.com")).toBe(false);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe("tightensHostGuard", () => {
|
|
64
|
+
const on = (...hosts: string[]) => ({ guard: true, hosts });
|
|
65
|
+
const off = (...hosts: string[]) => ({ guard: false, hosts });
|
|
66
|
+
|
|
67
|
+
it("reads turning the guard on as tightening, whatever the list, and turning it off as loosening", () => {
|
|
68
|
+
expect(tightensHostGuard(undefined, on("api.github.com"))).toBe(true);
|
|
69
|
+
expect(tightensHostGuard(off("api.github.com"), on())).toBe(true);
|
|
70
|
+
expect(tightensHostGuard(on("api.github.com"), off("api.github.com"))).toBe(false);
|
|
71
|
+
expect(tightensHostGuard(undefined, off())).toBe(true);
|
|
72
|
+
expect(tightensHostGuard(off(), off("evil.example"))).toBe(true);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("reads taking a host off a guarded list as tightening, down to none, and adding one as loosening", () => {
|
|
76
|
+
expect(tightensHostGuard(on("api.github.com", "github.com"), on("github.com"))).toBe(true);
|
|
77
|
+
expect(tightensHostGuard(on("api.github.com"), on())).toBe(true);
|
|
78
|
+
expect(tightensHostGuard(on("api.github.com"), on("api.github.com", "evil.example"))).toBe(false);
|
|
79
|
+
expect(tightensHostGuard(on(), on("api.github.com"))).toBe(false);
|
|
80
|
+
expect(tightensHostGuard(on("api.github.com"), on("api.github.com"))).toBe(true);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("counts a host or a deeper wildcard under a held wildcard as covered, and the domain itself as not", () => {
|
|
84
|
+
expect(tightensHostGuard(on("*.github.com"), on("api.github.com"))).toBe(true);
|
|
85
|
+
expect(tightensHostGuard(on("*.github.com"), on("*.api.github.com"))).toBe(true);
|
|
86
|
+
expect(tightensHostGuard(on("*.github.com"), on("github.com"))).toBe(false);
|
|
87
|
+
expect(tightensHostGuard(on("api.github.com"), on("*.api.github.com"))).toBe(false);
|
|
88
|
+
});
|
|
89
|
+
});
|