seclaw-agent 0.1.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/LICENSE +21 -0
- package/README.md +668 -0
- package/SECURITY.md +253 -0
- package/assets/logo.png +0 -0
- package/dist/agent/context.d.ts +37 -0
- package/dist/agent/context.d.ts.map +1 -0
- package/dist/agent/context.js +211 -0
- package/dist/agent/context.js.map +1 -0
- package/dist/agent/docker_sandbox.d.ts +41 -0
- package/dist/agent/docker_sandbox.d.ts.map +1 -0
- package/dist/agent/docker_sandbox.js +239 -0
- package/dist/agent/docker_sandbox.js.map +1 -0
- package/dist/agent/loop.d.ts +86 -0
- package/dist/agent/loop.d.ts.map +1 -0
- package/dist/agent/loop.js +858 -0
- package/dist/agent/loop.js.map +1 -0
- package/dist/agent/memory.d.ts +21 -0
- package/dist/agent/memory.d.ts.map +1 -0
- package/dist/agent/memory.js +128 -0
- package/dist/agent/memory.js.map +1 -0
- package/dist/agent/security/execution_audit.d.ts +17 -0
- package/dist/agent/security/execution_audit.d.ts.map +1 -0
- package/dist/agent/security/execution_audit.js +126 -0
- package/dist/agent/security/execution_audit.js.map +1 -0
- package/dist/agent/security/input_validation/entity.d.ts +57 -0
- package/dist/agent/security/input_validation/entity.d.ts.map +1 -0
- package/dist/agent/security/input_validation/entity.js +121 -0
- package/dist/agent/security/input_validation/entity.js.map +1 -0
- package/dist/agent/security/input_validation/index.d.ts +114 -0
- package/dist/agent/security/input_validation/index.d.ts.map +1 -0
- package/dist/agent/security/input_validation/index.js +971 -0
- package/dist/agent/security/input_validation/index.js.map +1 -0
- package/dist/agent/security/input_validation/lattice.d.ts +33 -0
- package/dist/agent/security/input_validation/lattice.d.ts.map +1 -0
- package/dist/agent/security/input_validation/lattice.js +61 -0
- package/dist/agent/security/input_validation/lattice.js.map +1 -0
- package/dist/agent/security/input_validation/program_graph.d.ts +51 -0
- package/dist/agent/security/input_validation/program_graph.d.ts.map +1 -0
- package/dist/agent/security/input_validation/program_graph.js +285 -0
- package/dist/agent/security/input_validation/program_graph.js.map +1 -0
- package/dist/agent/security/input_validation/security_policy.d.ts +29 -0
- package/dist/agent/security/input_validation/security_policy.d.ts.map +1 -0
- package/dist/agent/security/input_validation/security_policy.js +256 -0
- package/dist/agent/security/input_validation/security_policy.js.map +1 -0
- package/dist/agent/security/memory_audit.d.ts +14 -0
- package/dist/agent/security/memory_audit.d.ts.map +1 -0
- package/dist/agent/security/memory_audit.js +126 -0
- package/dist/agent/security/memory_audit.js.map +1 -0
- package/dist/agent/security/skill_audit.d.ts +15 -0
- package/dist/agent/security/skill_audit.d.ts.map +1 -0
- package/dist/agent/security/skill_audit.js +112 -0
- package/dist/agent/security/skill_audit.js.map +1 -0
- package/dist/agent/security/snapshot_and_rollback/base.d.ts +10 -0
- package/dist/agent/security/snapshot_and_rollback/base.d.ts.map +1 -0
- package/dist/agent/security/snapshot_and_rollback/base.js +10 -0
- package/dist/agent/security/snapshot_and_rollback/base.js.map +1 -0
- package/dist/agent/security/snapshot_and_rollback/docker_snapshot.d.ts +52 -0
- package/dist/agent/security/snapshot_and_rollback/docker_snapshot.d.ts.map +1 -0
- package/dist/agent/security/snapshot_and_rollback/docker_snapshot.js +358 -0
- package/dist/agent/security/snapshot_and_rollback/docker_snapshot.js.map +1 -0
- package/dist/agent/security/snapshot_and_rollback/index.d.ts +7 -0
- package/dist/agent/security/snapshot_and_rollback/index.d.ts.map +1 -0
- package/dist/agent/security/snapshot_and_rollback/index.js +450 -0
- package/dist/agent/security/snapshot_and_rollback/index.js.map +1 -0
- package/dist/agent/skills.d.ts +35 -0
- package/dist/agent/skills.d.ts.map +1 -0
- package/dist/agent/skills.js +235 -0
- package/dist/agent/skills.js.map +1 -0
- package/dist/agent/subagent.d.ts +39 -0
- package/dist/agent/subagent.d.ts.map +1 -0
- package/dist/agent/subagent.js +151 -0
- package/dist/agent/subagent.js.map +1 -0
- package/dist/agent/tools/base.d.ts +32 -0
- package/dist/agent/tools/base.d.ts.map +1 -0
- package/dist/agent/tools/base.js +91 -0
- package/dist/agent/tools/base.js.map +1 -0
- package/dist/agent/tools/cron.d.ts +46 -0
- package/dist/agent/tools/cron.d.ts.map +1 -0
- package/dist/agent/tools/cron.js +95 -0
- package/dist/agent/tools/cron.js.map +1 -0
- package/dist/agent/tools/filesystem.d.ts +102 -0
- package/dist/agent/tools/filesystem.d.ts.map +1 -0
- package/dist/agent/tools/filesystem.js +257 -0
- package/dist/agent/tools/filesystem.js.map +1 -0
- package/dist/agent/tools/message.d.ts +40 -0
- package/dist/agent/tools/message.d.ts.map +1 -0
- package/dist/agent/tools/message.js +55 -0
- package/dist/agent/tools/message.js.map +1 -0
- package/dist/agent/tools/registry.d.ts +16 -0
- package/dist/agent/tools/registry.d.ts.map +1 -0
- package/dist/agent/tools/registry.js +47 -0
- package/dist/agent/tools/registry.js.map +1 -0
- package/dist/agent/tools/shell.d.ts +40 -0
- package/dist/agent/tools/shell.d.ts.map +1 -0
- package/dist/agent/tools/shell.js +166 -0
- package/dist/agent/tools/shell.js.map +1 -0
- package/dist/agent/tools/spawn.d.ts +30 -0
- package/dist/agent/tools/spawn.d.ts.map +1 -0
- package/dist/agent/tools/spawn.js +50 -0
- package/dist/agent/tools/spawn.js.map +1 -0
- package/dist/agent/tools/web.d.ts +59 -0
- package/dist/agent/tools/web.d.ts.map +1 -0
- package/dist/agent/tools/web.js +167 -0
- package/dist/agent/tools/web.js.map +1 -0
- package/dist/bus/events.d.ts +31 -0
- package/dist/bus/events.d.ts.map +1 -0
- package/dist/bus/events.js +28 -0
- package/dist/bus/events.js.map +1 -0
- package/dist/bus/queue.d.ts +32 -0
- package/dist/bus/queue.d.ts.map +1 -0
- package/dist/bus/queue.js +104 -0
- package/dist/bus/queue.js.map +1 -0
- package/dist/channels/base.d.ts +25 -0
- package/dist/channels/base.d.ts.map +1 -0
- package/dist/channels/base.js +54 -0
- package/dist/channels/base.js.map +1 -0
- package/dist/channels/dingtalk.d.ts +31 -0
- package/dist/channels/dingtalk.d.ts.map +1 -0
- package/dist/channels/dingtalk.js +177 -0
- package/dist/channels/dingtalk.js.map +1 -0
- package/dist/channels/discord.d.ts +30 -0
- package/dist/channels/discord.d.ts.map +1 -0
- package/dist/channels/discord.js +197 -0
- package/dist/channels/discord.js.map +1 -0
- package/dist/channels/email.d.ts +41 -0
- package/dist/channels/email.d.ts.map +1 -0
- package/dist/channels/email.js +210 -0
- package/dist/channels/email.js.map +1 -0
- package/dist/channels/feishu.d.ts +32 -0
- package/dist/channels/feishu.d.ts.map +1 -0
- package/dist/channels/feishu.js +109 -0
- package/dist/channels/feishu.js.map +1 -0
- package/dist/channels/manager.d.ts +24 -0
- package/dist/channels/manager.d.ts.map +1 -0
- package/dist/channels/manager.js +205 -0
- package/dist/channels/manager.js.map +1 -0
- package/dist/channels/mochat.d.ts +38 -0
- package/dist/channels/mochat.d.ts.map +1 -0
- package/dist/channels/mochat.js +201 -0
- package/dist/channels/mochat.js.map +1 -0
- package/dist/channels/qq.d.ts +40 -0
- package/dist/channels/qq.d.ts.map +1 -0
- package/dist/channels/qq.js +280 -0
- package/dist/channels/qq.js.map +1 -0
- package/dist/channels/slack.d.ts +27 -0
- package/dist/channels/slack.d.ts.map +1 -0
- package/dist/channels/slack.js +118 -0
- package/dist/channels/slack.js.map +1 -0
- package/dist/channels/telegram.d.ts +31 -0
- package/dist/channels/telegram.d.ts.map +1 -0
- package/dist/channels/telegram.js +218 -0
- package/dist/channels/telegram.js.map +1 -0
- package/dist/channels/whatsapp.d.ts +29 -0
- package/dist/channels/whatsapp.d.ts.map +1 -0
- package/dist/channels/whatsapp.js +117 -0
- package/dist/channels/whatsapp.js.map +1 -0
- package/dist/cli/commands.d.ts +8 -0
- package/dist/cli/commands.d.ts.map +1 -0
- package/dist/cli/commands.js +537 -0
- package/dist/cli/commands.js.map +1 -0
- package/dist/config/loader.d.ts +24 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +182 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/schema.d.ts +2921 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +257 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/cron/service.d.ts +38 -0
- package/dist/cron/service.d.ts.map +1 -0
- package/dist/cron/service.js +336 -0
- package/dist/cron/service.js.map +1 -0
- package/dist/cron/types.d.ts +46 -0
- package/dist/cron/types.d.ts.map +1 -0
- package/dist/cron/types.js +6 -0
- package/dist/cron/types.js.map +1 -0
- package/dist/heartbeat/service.d.ts +26 -0
- package/dist/heartbeat/service.d.ts.map +1 -0
- package/dist/heartbeat/service.js +142 -0
- package/dist/heartbeat/service.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/base.d.ts +38 -0
- package/dist/providers/base.d.ts.map +1 -0
- package/dist/providers/base.js +21 -0
- package/dist/providers/base.js.map +1 -0
- package/dist/providers/litellm_provider.d.ts +35 -0
- package/dist/providers/litellm_provider.d.ts.map +1 -0
- package/dist/providers/litellm_provider.js +205 -0
- package/dist/providers/litellm_provider.js.map +1 -0
- package/dist/providers/registry.d.ts +44 -0
- package/dist/providers/registry.d.ts.map +1 -0
- package/dist/providers/registry.js +252 -0
- package/dist/providers/registry.js.map +1 -0
- package/dist/providers/transcription.d.ts +10 -0
- package/dist/providers/transcription.d.ts.map +1 -0
- package/dist/providers/transcription.js +83 -0
- package/dist/providers/transcription.js.map +1 -0
- package/dist/session/manager.d.ts +35 -0
- package/dist/session/manager.d.ts.map +1 -0
- package/dist/session/manager.js +193 -0
- package/dist/session/manager.js.map +1 -0
- package/dist/utils/helpers.d.ts +15 -0
- package/dist/utils/helpers.d.ts.map +1 -0
- package/dist/utils/helpers.js +100 -0
- package/dist/utils/helpers.js.map +1 -0
- package/dist/utils/logger.d.ts +7 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +25 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +58 -0
- package/templates/AGENTS.md +51 -0
- package/templates/HEARTBEAT.md +16 -0
- package/templates/SOUL.md +36 -0
- package/templates/TOOLS.md +150 -0
- package/templates/USER.md +17 -0
- package/templates/memory/MEMORY.md +23 -0
package/SECURITY.md
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
# 🛡️ SeClaw Security
|
|
2
|
+
|
|
3
|
+
This document describes the security mechanisms implemented in the current SeClaw codebase.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1) Security Goals and Boundaries
|
|
8
|
+
|
|
9
|
+
SeClaw focuses on four practical goals:
|
|
10
|
+
|
|
11
|
+
1. **Constrain unsafe agent actions** before tool execution.
|
|
12
|
+
2. **Isolate execution** (when Docker sandbox is enabled).
|
|
13
|
+
3. **Detect and sanitize prompt-injection content** in tool outputs.
|
|
14
|
+
4. **Keep actions auditable and reversible** via logs, audits, and snapshots.
|
|
15
|
+
|
|
16
|
+
Key boundary conditions:
|
|
17
|
+
|
|
18
|
+
- If Docker sandbox is disabled, tools execute on the host.
|
|
19
|
+
- Several controls are **LLM-assisted** (probabilistic), not formal verification.
|
|
20
|
+
- Security is strongest when hardening options in config are enabled together.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 2) Runtime Security Pipeline
|
|
25
|
+
|
|
26
|
+
For each user task, SeClaw applies the following sequence:
|
|
27
|
+
|
|
28
|
+
1. *(Optional)* Pre-task snapshot (when Docker snapshotting is enabled).
|
|
29
|
+
2. Task analysis, control-flow integrity (CFI), and information-flow integrity (IFI) validation.
|
|
30
|
+
3. Tool execution.
|
|
31
|
+
4. Tool output sanitization.
|
|
32
|
+
5. Execution logging and post-task risk audit.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## 3) Prompt Injection Defense (Input Validation)
|
|
37
|
+
|
|
38
|
+
Implemented in `src/agent/security/input_validation/`.
|
|
39
|
+
|
|
40
|
+
### 3.1 Control-Flow Integrity (CFI)
|
|
41
|
+
|
|
42
|
+
- Before tool execution, SeClaw builds an expected tool-call trajectory from:
|
|
43
|
+
- The current conversation history (excluding system prompt and tool output)
|
|
44
|
+
- Static tool definitions
|
|
45
|
+
- The validator then checks each actual tool call against this expected trajectory.
|
|
46
|
+
- For `exec` and `spawn`, **key parameters** must also match expected values:
|
|
47
|
+
- `exec.command`
|
|
48
|
+
- `spawn.message`
|
|
49
|
+
|
|
50
|
+
### 3.2 Information-Flow Integrity (IFI)
|
|
51
|
+
|
|
52
|
+
- Tool parameters are validated against source/type/value constraints represented in a program graph.
|
|
53
|
+
- Supported constraint types include: `email`, `url`, `file_path`, `directory`, `integer`, `string`, `boolean`, `json`.
|
|
54
|
+
- If required source data has not been produced yet, the user confirmation is required.
|
|
55
|
+
|
|
56
|
+
### 3.3 Deviation Handling
|
|
57
|
+
|
|
58
|
+
- If a call is not in the expected trajectory:
|
|
59
|
+
- Read-only deviations can proceed.
|
|
60
|
+
- Write/execute deviations go through intent-alignment validation.
|
|
61
|
+
- Non-aligned deviations trigger `USER_CONFIRMATION_REQUEST`.
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
### 3.4 Prohibited Command Gate
|
|
65
|
+
|
|
66
|
+
- `security.prohibitedCommands` is matched against tool name/arguments.
|
|
67
|
+
- Matching calls require explicit user approval; otherwise execution is blocked with confirmation request.
|
|
68
|
+
|
|
69
|
+
### 3.5 Resume-on-Confirmation
|
|
70
|
+
|
|
71
|
+
- When confirmation is needed, the pending execution state is saved at:
|
|
72
|
+
`~/.seclaw/security/EXECUTION_RESUME.json`
|
|
73
|
+
|
|
74
|
+
This allows the execution to be resumed after the user responds.
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 4) Prompt Injection Defense (Output Validation)
|
|
80
|
+
|
|
81
|
+
After each tool returns output, SeClaw can run a guard-model pass (using the configured provider/model) to detect and sanitize injection content.
|
|
82
|
+
|
|
83
|
+
Detection covers patterns such as:
|
|
84
|
+
|
|
85
|
+
- Attempts to override original task goals
|
|
86
|
+
- Requests to reveal internal prompts/state
|
|
87
|
+
- Behavior-manipulation instructions (e.g., “ignore previous instructions”)
|
|
88
|
+
- Social-engineering style bypass attempts
|
|
89
|
+
|
|
90
|
+
When detected, sanitized output is fed back to the reasoning loop with a security notice.
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## 5) Execution Isolation (Docker Sandbox)
|
|
95
|
+
|
|
96
|
+
Implemented in `src/agent/docker_sandbox.ts`.
|
|
97
|
+
|
|
98
|
+
When enabled, SeClaw can run tool execution in a Docker container with controlled mounts/env/network.
|
|
99
|
+
|
|
100
|
+
Important current behavior:
|
|
101
|
+
|
|
102
|
+
- Workspace mount is read-only by default (`workspaceReadOnly = true`, mount mode `:ro`).
|
|
103
|
+
- You can allow writes by setting `security.dockerSandbox.workspaceReadOnly = false` (mount mode `:rw`).
|
|
104
|
+
- Additional writable mounts must be explicitly granted via `extraMounts`.
|
|
105
|
+
- `exec` and filesystem tools use container execution when sandbox is active.
|
|
106
|
+
|
|
107
|
+
Mode caveat:
|
|
108
|
+
|
|
109
|
+
- `seclaw gateway` initializes Docker sandbox (if enabled in config).
|
|
110
|
+
- `seclaw agent` currently runs without Docker sandbox initialization.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## 6) Snapshot & Rollback
|
|
115
|
+
|
|
116
|
+
Implemented in `src/agent/security/snapshot_and_rollback/` and Docker snapshot manager.
|
|
117
|
+
|
|
118
|
+
### 6.1 Automatic task snapshots (gateway flow)
|
|
119
|
+
|
|
120
|
+
- If Docker sandbox snapshotting is enabled, SeClaw snapshots before processing user messages.
|
|
121
|
+
- Snapshot includes:
|
|
122
|
+
- Docker container image (`docker commit`)
|
|
123
|
+
- Optional host-dir snapshots for configured mounts (backend-dependent)
|
|
124
|
+
- Snapshot frequency is throttled by ```security.dockerSandbox.snapshotMinIntervalSeconds```. For efficiency, snapshots are only taken when the time interval between the current conversation and the previous conversation is greater than ```security.dockerSandbox.snapshotMinIntervalSeconds```. You can also use `/take_snapshot` to manually take the snapshot.
|
|
125
|
+
|
|
126
|
+
### 6.2 Snapshot Frequency
|
|
127
|
+
|
|
128
|
+
- ```security.dockerSandbox.```
|
|
129
|
+
|
|
130
|
+
### 6.3 Host snapshot backends
|
|
131
|
+
|
|
132
|
+
- **macOS:** APFS local snapshot backend (`tmutil localsnapshot`, restore via `mount_apfs` + `rsync`)
|
|
133
|
+
- **Linux:** btrfs CoW snapshot backend (`btrfs subvolume snapshot -r`, restore via `rsync`)
|
|
134
|
+
- **Other platforms:** `rsync` backend if available
|
|
135
|
+
- If platform-preferred backend is unavailable, SeClaw falls back to `rsync` (when installed)
|
|
136
|
+
- If no host backend exists, Docker image snapshot still works (host-dir rollback unavailable)
|
|
137
|
+
|
|
138
|
+
### 6.4 User-facing snapshot commands
|
|
139
|
+
|
|
140
|
+
In chat channels:
|
|
141
|
+
|
|
142
|
+
- `/take_snapshot [label]`
|
|
143
|
+
- `/snapshot_list`
|
|
144
|
+
- `/snapshot_restore <TAG>`
|
|
145
|
+
|
|
146
|
+
CLI:
|
|
147
|
+
|
|
148
|
+
- `seclaw snapshot list`
|
|
149
|
+
- `seclaw snapshot take [label]`
|
|
150
|
+
- `seclaw snapshot restore <tag>`
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## 7) Auditing and Logging
|
|
156
|
+
|
|
157
|
+
### 7.1 Execution logs
|
|
158
|
+
|
|
159
|
+
- Trajectory logs are written during execution every `executionLogStep` iterations.
|
|
160
|
+
- Final execution trace is also saved at task completion.
|
|
161
|
+
|
|
162
|
+
### 7.2 Post-execution risk audit
|
|
163
|
+
|
|
164
|
+
- If enabled and tools were used, SeClaw launches an execution trace audit after the task finished.
|
|
165
|
+
- Detected risks can produce a channel alert and a JSON report.
|
|
166
|
+
|
|
167
|
+
### 7.3 On-demand security audits
|
|
168
|
+
|
|
169
|
+
- `/skill_audit`
|
|
170
|
+
- Scans loaded skill definitions for risky instructions.
|
|
171
|
+
- `/memory_audit`
|
|
172
|
+
- Scans `MEMORY.md`, `HISTORY.md`, and recent daily memory notes.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## 8) Security Configuration Reference
|
|
177
|
+
|
|
178
|
+
Config file:
|
|
179
|
+
|
|
180
|
+
- `~/.seclaw/config.json`
|
|
181
|
+
|
|
182
|
+
### 8.1 `security` fields
|
|
183
|
+
|
|
184
|
+
| Field | Type | Default | Effect |
|
|
185
|
+
|---|---|---:|---|
|
|
186
|
+
| `prohibitedCommands` | `string[]` | `[]` | Tokens that require explicit user confirmation before execution |
|
|
187
|
+
| `inputValidationEnabled` | `boolean` | `true` | Enables CFI/IFI + deviation validation gate |
|
|
188
|
+
| `outputValidationEnabled` | `boolean` | `true` | Enables tool-output guard-model sanitization |
|
|
189
|
+
| `executionLogEnabled` | `boolean` | `true` | Persists execution trajectory logs |
|
|
190
|
+
| `executionLogStep` | `number` | `1` | Log every N loop iterations |
|
|
191
|
+
| `postExecutionAuditEnabled` | `boolean` | `true` | Runs post-task risk audit |
|
|
192
|
+
| `skillAuditEnabled` | `boolean` | `true` | Present in schema (currently not used as a gate in runtime flow) |
|
|
193
|
+
|
|
194
|
+
### 8.2 `security.dockerSandbox` fields
|
|
195
|
+
|
|
196
|
+
| Field | Type | Default | Effect |
|
|
197
|
+
|---|---|---:|---|
|
|
198
|
+
| `enabled` | `boolean` | `false` | Enables Docker sandbox mode |
|
|
199
|
+
| `image` | `string` | `ubuntu:22.04` | Container image |
|
|
200
|
+
| `containerName` | `string` | `seclaw` | Container name |
|
|
201
|
+
| `workspaceContainer` | `string` | `/workspace` | Workspace path inside container |
|
|
202
|
+
| `workspaceReadOnly` | `boolean` | `true` | Mount workspace as read-only (`true`) or read-write (`false`) |
|
|
203
|
+
| `extraMounts` | `string[]` | `[]` | Extra bind mounts (`host:container:mode`) |
|
|
204
|
+
| `extraEnv` | `Record<string,string>` | `{}` | Extra environment variables |
|
|
205
|
+
| `memoryLimit` | `string \| null` | `null` | Optional memory cap |
|
|
206
|
+
| `network` | `string` | `bridge` | Docker network mode |
|
|
207
|
+
| `snapshotEnabled` | `boolean` | `true` | Enables Docker snapshot manager |
|
|
208
|
+
| `snapshotMax` | `number` | `10` | Max retained snapshots |
|
|
209
|
+
| `snapshotMinIntervalSeconds` | `number` | `1800` | Minimum interval between auto-snapshots |
|
|
210
|
+
|
|
211
|
+
> Onboarding note: `seclaw onboard` overrides some defaults in generated config (for example enabling docker sandbox and setting snapshot/prohibited command starter values).
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## 9) Security Artifacts and Paths
|
|
216
|
+
|
|
217
|
+
SeClaw writes security artifacts to both the data root and workspace.
|
|
218
|
+
|
|
219
|
+
Common paths:
|
|
220
|
+
|
|
221
|
+
- `~/.seclaw/config.json`
|
|
222
|
+
- `~/.seclaw/security/execution_logs/`
|
|
223
|
+
- `~/.seclaw/security/audit_reports/`
|
|
224
|
+
- `~/.seclaw/security/graphs/expected_trajectory.md`
|
|
225
|
+
- `~/.seclaw/security/graphs/expected_trajectory.json`
|
|
226
|
+
- `~/.seclaw/security/EXECUTION_RESUME.json`
|
|
227
|
+
- `~/.seclaw/snapshots/docker_snapshots.json`
|
|
228
|
+
- `~/.seclaw/snapshots/<timestamp>/...` (host snapshots, backend-dependent)
|
|
229
|
+
- `~/.seclaw/workspace/security/SECURITY_POLICY.md` (policy file used by input-validation policy manager)
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## 10) Hardening Recommendations
|
|
234
|
+
|
|
235
|
+
For production-like deployment:
|
|
236
|
+
|
|
237
|
+
1. Keep `security.inputValidationEnabled = true`.
|
|
238
|
+
2. Keep `security.outputValidationEnabled = true`.
|
|
239
|
+
3. Keep `security.executionLogEnabled = true` and `security.postExecutionAuditEnabled = true`.
|
|
240
|
+
4. Enable Docker sandbox and avoid writable broad mounts.
|
|
241
|
+
5. Set `tools.restrictToWorkspace = true`.
|
|
242
|
+
6. Define a strict `security.prohibitedCommands` list.
|
|
243
|
+
7. Restrict channel senders using each channel’s `allowFrom` controls.
|
|
244
|
+
8. Run `/skill_audit` and `/memory_audit` regularly.
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## 11) Current Limitations (Important)
|
|
249
|
+
|
|
250
|
+
- LLM-based validators/guards can reduce risk, but cannot guarantee perfect detection.
|
|
251
|
+
- `security.skillAuditEnabled` exists in config schema, but the current runtime does not use it to block/allow `/skill_audit`.
|
|
252
|
+
- Without Docker sandbox (or when running direct agent mode), execution is host-level.
|
|
253
|
+
- `prohibitedCommands` matching is token/string-based, not full shell AST parsing.
|
package/assets/logo.png
ADDED
|
Binary file
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Context builder
|
|
3
|
+
*/
|
|
4
|
+
import { MemoryStore } from "./memory";
|
|
5
|
+
import { SkillsLoader } from "./skills";
|
|
6
|
+
export interface DockerSandboxConfig {
|
|
7
|
+
image: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class ContextBuilder {
|
|
10
|
+
static BOOTSTRAP_FILES: string[];
|
|
11
|
+
workspace: string;
|
|
12
|
+
effectiveWorkspace: string;
|
|
13
|
+
dockerSandbox?: DockerSandboxConfig;
|
|
14
|
+
memory: MemoryStore;
|
|
15
|
+
skills: SkillsLoader;
|
|
16
|
+
constructor(opts: {
|
|
17
|
+
workspace: string;
|
|
18
|
+
containerWorkspace?: string;
|
|
19
|
+
pathTranslator?: (p: string) => string;
|
|
20
|
+
dockerSandbox?: DockerSandboxConfig;
|
|
21
|
+
});
|
|
22
|
+
buildSystemPrompt(skillNames?: string[]): string;
|
|
23
|
+
private getIdentity;
|
|
24
|
+
private loadBootstrapFiles;
|
|
25
|
+
buildMessages(opts: {
|
|
26
|
+
history: Record<string, unknown>[];
|
|
27
|
+
currentMessage: string;
|
|
28
|
+
skillNames?: string[];
|
|
29
|
+
media?: string[];
|
|
30
|
+
channel?: string;
|
|
31
|
+
chatId?: string;
|
|
32
|
+
}): Record<string, unknown>[];
|
|
33
|
+
private buildUserContent;
|
|
34
|
+
addToolResult(messages: Record<string, unknown>[], toolCallId: string, toolName: string, result: string): Record<string, unknown>[];
|
|
35
|
+
addAssistantMessage(messages: Record<string, unknown>[], content: string | null, toolCalls?: Record<string, unknown>[], reasoningContent?: string): Record<string, unknown>[];
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/agent/context.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAwBxC,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,cAAc;IACzB,MAAM,CAAC,eAAe,WAAkE;IAExF,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,mBAAmB,CAAC;IACpC,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,YAAY,CAAC;gBAET,IAAI,EAAE;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;QACvC,aAAa,CAAC,EAAE,mBAAmB,CAAC;KACrC;IAaD,iBAAiB,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM;IA8BhD,OAAO,CAAC,WAAW;IAiDnB,OAAO,CAAC,kBAAkB;IAY1B,aAAa,CAAC,IAAI,EAAE;QAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;QACnC,cAAc,EAAE,MAAM,CAAC;QACvB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;QACtB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;IAiB7B,OAAO,CAAC,gBAAgB;IAiBxB,aAAa,CACX,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EACnC,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;IAK5B,mBAAmB,CACjB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EACnC,OAAO,EAAE,MAAM,GAAG,IAAI,EACtB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EACrC,gBAAgB,CAAC,EAAE,MAAM,GACxB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE;CAO7B"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Context builder
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.ContextBuilder = void 0;
|
|
40
|
+
const fs = __importStar(require("fs"));
|
|
41
|
+
const path = __importStar(require("path"));
|
|
42
|
+
const os = __importStar(require("os"));
|
|
43
|
+
const mime = __importStar(require("mime-types"));
|
|
44
|
+
const memory_1 = require("./memory");
|
|
45
|
+
const skills_1 = require("./skills");
|
|
46
|
+
function runtimeFromImage(image) {
|
|
47
|
+
const name = image.split("/").pop() ?? image;
|
|
48
|
+
const colonIdx = name.indexOf(":");
|
|
49
|
+
const base = colonIdx > 0 ? name.slice(0, colonIdx) : name;
|
|
50
|
+
const tag = colonIdx > 0 ? name.slice(colonIdx + 1) : "latest";
|
|
51
|
+
const OS_MAP = {
|
|
52
|
+
ubuntu: "Ubuntu",
|
|
53
|
+
debian: "Debian",
|
|
54
|
+
alpine: "Alpine Linux",
|
|
55
|
+
fedora: "Fedora",
|
|
56
|
+
centos: "CentOS",
|
|
57
|
+
rockylinux: "Rocky Linux",
|
|
58
|
+
almalinux: "AlmaLinux",
|
|
59
|
+
amazonlinux: "Amazon Linux",
|
|
60
|
+
archlinux: "Arch Linux",
|
|
61
|
+
python: "Python",
|
|
62
|
+
node: "Node.js",
|
|
63
|
+
};
|
|
64
|
+
const osName = OS_MAP[base.toLowerCase()] ?? (base.charAt(0).toUpperCase() + base.slice(1));
|
|
65
|
+
return `${osName} ${tag} (Docker)`;
|
|
66
|
+
}
|
|
67
|
+
class ContextBuilder {
|
|
68
|
+
static BOOTSTRAP_FILES = ["AGENTS.md", "SOUL.md", "USER.md", "TOOLS.md", "IDENTITY.md"];
|
|
69
|
+
workspace;
|
|
70
|
+
effectiveWorkspace;
|
|
71
|
+
dockerSandbox;
|
|
72
|
+
memory;
|
|
73
|
+
skills;
|
|
74
|
+
constructor(opts) {
|
|
75
|
+
this.workspace = opts.workspace;
|
|
76
|
+
this.effectiveWorkspace =
|
|
77
|
+
opts.containerWorkspace ?? path.resolve(opts.workspace.replace(/^~/, os.homedir()));
|
|
78
|
+
this.dockerSandbox = opts.dockerSandbox;
|
|
79
|
+
this.memory = new memory_1.MemoryStore(opts.workspace, opts.containerWorkspace);
|
|
80
|
+
this.skills = new skills_1.SkillsLoader({
|
|
81
|
+
workspace: opts.workspace,
|
|
82
|
+
containerWorkspace: opts.containerWorkspace,
|
|
83
|
+
pathTranslator: opts.pathTranslator,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
buildSystemPrompt(skillNames) {
|
|
87
|
+
const parts = [];
|
|
88
|
+
parts.push(this.getIdentity());
|
|
89
|
+
const bootstrap = this.loadBootstrapFiles();
|
|
90
|
+
if (bootstrap)
|
|
91
|
+
parts.push(bootstrap);
|
|
92
|
+
const memoryCtx = this.memory.getMemoryContext();
|
|
93
|
+
if (memoryCtx)
|
|
94
|
+
parts.push(`# Memory\n\n${memoryCtx}`);
|
|
95
|
+
const alwaysSkills = this.skills.getAlwaysSkills();
|
|
96
|
+
if (alwaysSkills.length > 0) {
|
|
97
|
+
const alwaysContent = this.skills.loadSkillsForContext(alwaysSkills);
|
|
98
|
+
if (alwaysContent)
|
|
99
|
+
parts.push(`# Active Skills\n\n${alwaysContent}`);
|
|
100
|
+
}
|
|
101
|
+
const skillsSummary = this.skills.buildSkillsSummary();
|
|
102
|
+
if (skillsSummary) {
|
|
103
|
+
parts.push(`# Skills\n\nThe following skills extend your capabilities. ` +
|
|
104
|
+
`To use a skill, read its SKILL.md file using the read_file tool.\n` +
|
|
105
|
+
`Skills with available="false" need dependencies installed first - ` +
|
|
106
|
+
`you can try installing them with apt/brew.\n\n${skillsSummary}`);
|
|
107
|
+
}
|
|
108
|
+
return parts.join("\n\n---\n\n");
|
|
109
|
+
}
|
|
110
|
+
getIdentity() {
|
|
111
|
+
const now = new Date().toLocaleString("en-US", {
|
|
112
|
+
year: "numeric",
|
|
113
|
+
month: "2-digit",
|
|
114
|
+
day: "2-digit",
|
|
115
|
+
hour: "2-digit",
|
|
116
|
+
minute: "2-digit",
|
|
117
|
+
weekday: "long",
|
|
118
|
+
});
|
|
119
|
+
const workspacePath = this.effectiveWorkspace;
|
|
120
|
+
const runtime = this.dockerSandbox
|
|
121
|
+
? runtimeFromImage(this.dockerSandbox.image)
|
|
122
|
+
: `${process.platform === "darwin" ? "macOS" : process.platform} ${process.arch}, Node.js ${process.version}`;
|
|
123
|
+
const homePath = this.dockerSandbox ? "/root" : os.homedir();
|
|
124
|
+
return `# seclaw 🦾
|
|
125
|
+
|
|
126
|
+
You are seclaw, a helpful AI assistant. You have access to tools that allow you to:
|
|
127
|
+
- Read, write, and edit files
|
|
128
|
+
- Execute shell commands
|
|
129
|
+
- Search the web and fetch web pages
|
|
130
|
+
- Send messages to users on chat channels
|
|
131
|
+
- Spawn subagents for complex background tasks
|
|
132
|
+
|
|
133
|
+
You have been deployed on the user's personal computer and have permission to access the user's machine. You should utilize the provided tools to help the user accomplish their tasks.
|
|
134
|
+
|
|
135
|
+
## Current Time
|
|
136
|
+
${now}
|
|
137
|
+
|
|
138
|
+
## Runtime
|
|
139
|
+
${runtime}
|
|
140
|
+
|
|
141
|
+
## HOME
|
|
142
|
+
$HOME is at: ${homePath}
|
|
143
|
+
|
|
144
|
+
## Workspace
|
|
145
|
+
Your workspace is at: ${workspacePath}
|
|
146
|
+
- Memory files: ${workspacePath}/memory/MEMORY.md
|
|
147
|
+
- Daily notes: ${workspacePath}/memory/YYYY-MM-DD.md
|
|
148
|
+
- Custom skills: ${workspacePath}/skills/{skill-name}/SKILL.md
|
|
149
|
+
|
|
150
|
+
IMPORTANT: When responding to direct questions or conversations, reply directly with your text response.
|
|
151
|
+
Only use the 'message' tool when you need to send a message to a specific chat channel (like WhatsApp).
|
|
152
|
+
For normal conversation, just respond with text - do not call the message tool.
|
|
153
|
+
|
|
154
|
+
Always be helpful, accurate, and concise. When using tools, explain what you're doing.
|
|
155
|
+
When remembering something, write to ${workspacePath}/memory/MEMORY.md`;
|
|
156
|
+
}
|
|
157
|
+
loadBootstrapFiles() {
|
|
158
|
+
const parts = [];
|
|
159
|
+
for (const filename of ContextBuilder.BOOTSTRAP_FILES) {
|
|
160
|
+
const filePath = path.join(this.workspace, filename);
|
|
161
|
+
if (fs.existsSync(filePath)) {
|
|
162
|
+
const content = fs.readFileSync(filePath, "utf-8");
|
|
163
|
+
parts.push(`## ${filename}\n\n${content}`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return parts.join("\n\n");
|
|
167
|
+
}
|
|
168
|
+
buildMessages(opts) {
|
|
169
|
+
const { history, currentMessage, media, channel, chatId } = opts;
|
|
170
|
+
const messages = [];
|
|
171
|
+
let systemPrompt = this.buildSystemPrompt(opts.skillNames);
|
|
172
|
+
if (channel && chatId) {
|
|
173
|
+
systemPrompt += `\n\n## Current Session\nChannel: ${channel}\nChat ID: ${chatId}`;
|
|
174
|
+
}
|
|
175
|
+
messages.push({ role: "system", content: systemPrompt });
|
|
176
|
+
messages.push(...history);
|
|
177
|
+
const userContent = this.buildUserContent(currentMessage, media);
|
|
178
|
+
messages.push({ role: "user", content: userContent });
|
|
179
|
+
return messages;
|
|
180
|
+
}
|
|
181
|
+
buildUserContent(text, media) {
|
|
182
|
+
if (!media || media.length === 0)
|
|
183
|
+
return text;
|
|
184
|
+
const images = [];
|
|
185
|
+
for (const filePath of media) {
|
|
186
|
+
const mimeType = mime.lookup(filePath) || "";
|
|
187
|
+
if (!fs.existsSync(filePath) || !mimeType.startsWith("image/"))
|
|
188
|
+
continue;
|
|
189
|
+
const b64 = fs.readFileSync(filePath).toString("base64");
|
|
190
|
+
images.push({ type: "image_url", image_url: { url: `data:${mimeType};base64,${b64}` } });
|
|
191
|
+
}
|
|
192
|
+
if (images.length === 0)
|
|
193
|
+
return text;
|
|
194
|
+
return [...images, { type: "text", text }];
|
|
195
|
+
}
|
|
196
|
+
addToolResult(messages, toolCallId, toolName, result) {
|
|
197
|
+
messages.push({ role: "tool", tool_call_id: toolCallId, name: toolName, content: result });
|
|
198
|
+
return messages;
|
|
199
|
+
}
|
|
200
|
+
addAssistantMessage(messages, content, toolCalls, reasoningContent) {
|
|
201
|
+
const msg = { role: "assistant", content: content ?? "" };
|
|
202
|
+
if (toolCalls)
|
|
203
|
+
msg["tool_calls"] = toolCalls;
|
|
204
|
+
if (reasoningContent)
|
|
205
|
+
msg["reasoning_content"] = reasoningContent;
|
|
206
|
+
messages.push(msg);
|
|
207
|
+
return messages;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
exports.ContextBuilder = ContextBuilder;
|
|
211
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/agent/context.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;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,gBAAyB;QAEzB,MAAM,GAAG,GAA4B,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,IAAI,EAAE,EAAE,CAAC;QACnF,IAAI,SAAS;YAAE,GAAG,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC;QAC7C,IAAI,gBAAgB;YAAE,GAAG,CAAC,mBAAmB,CAAC,GAAG,gBAAgB,CAAC;QAClE,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,OAAO,QAAQ,CAAC;IAClB,CAAC;;AApLH,wCAqLC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Docker sandbox
|
|
3
|
+
*/
|
|
4
|
+
export interface DockerSandboxOptions {
|
|
5
|
+
image?: string;
|
|
6
|
+
containerName?: string;
|
|
7
|
+
workspaceHost?: string;
|
|
8
|
+
workspaceContainer?: string;
|
|
9
|
+
workspaceReadOnly?: boolean;
|
|
10
|
+
extraMounts?: string[];
|
|
11
|
+
extraEnv?: Record<string, string>;
|
|
12
|
+
memoryLimit?: string;
|
|
13
|
+
network?: string;
|
|
14
|
+
snapshotEnabled?: boolean;
|
|
15
|
+
snapshotMax?: number;
|
|
16
|
+
}
|
|
17
|
+
export declare class DockerSandbox {
|
|
18
|
+
image: string;
|
|
19
|
+
containerName: string;
|
|
20
|
+
workspaceHost?: string;
|
|
21
|
+
workspaceContainer: string;
|
|
22
|
+
workspaceReadOnly: boolean;
|
|
23
|
+
extraMounts: string[];
|
|
24
|
+
extraEnv: Record<string, string>;
|
|
25
|
+
memoryLimit?: string;
|
|
26
|
+
network: string;
|
|
27
|
+
snapshotEnabled: boolean;
|
|
28
|
+
snapshotMax: number;
|
|
29
|
+
private containerId;
|
|
30
|
+
constructor(opts?: DockerSandboxOptions);
|
|
31
|
+
get isRunning(): boolean;
|
|
32
|
+
start(): void;
|
|
33
|
+
stop(): void;
|
|
34
|
+
destroy(): void;
|
|
35
|
+
buildRunCmd(imageOverride?: string): string[];
|
|
36
|
+
exec(command: string, workingDir?: string, timeout?: number): Promise<[string, string, number]>;
|
|
37
|
+
execWithStdin(command: string, stdinData: Buffer, workingDir?: string, timeout?: number): Promise<[string, string, number]>;
|
|
38
|
+
hostToContainer(hostPath: string): string;
|
|
39
|
+
containerToHost(containerPath: string): string;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=docker_sandbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docker_sandbox.d.ts","sourceRoot":"","sources":["../../src/agent/docker_sandbox.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,aAAa;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,OAAO,CAAC;IAC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