praxis-agent 0.10.0 → 0.12.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 +20 -3
- package/dist/application/session-service.d.ts +5 -2
- package/dist/application/session-service.js +23 -0
- package/dist/application/subagent-service.d.ts +4 -2
- package/dist/application/subagent-service.js +4 -0
- package/dist/cli/interactive.d.ts +6 -3
- package/dist/cli/interactive.js +650 -59
- package/dist/cli/tui/claude-command-inventory.d.ts +368 -0
- package/dist/cli/tui/claude-command-inventory.js +220 -0
- package/dist/cli/tui/mcp-elicitation.d.ts +75 -0
- package/dist/cli/tui/mcp-elicitation.js +497 -0
- package/dist/cli/tui/open-url.d.ts +2 -0
- package/dist/cli/tui/open-url.js +13 -0
- package/dist/cli/tui/permission-settings.d.ts +6 -0
- package/dist/cli/tui/permission-settings.js +84 -0
- package/dist/cli/tui/sandbox-dashboard.d.ts +10 -0
- package/dist/cli/tui/sandbox-dashboard.js +78 -0
- package/dist/cli/tui/sandbox-settings.d.ts +32 -0
- package/dist/cli/tui/sandbox-settings.js +146 -0
- package/dist/cli/tui/slash-commands.js +8 -28
- package/dist/cli/tui/tool-permission.d.ts +36 -0
- package/dist/cli/tui/tool-permission.js +386 -0
- package/dist/cli.d.ts +3 -2
- package/dist/cli.js +53 -14
- package/dist/core/runtime.d.ts +50 -2
- package/dist/core/runtime.js +30 -3
- package/dist/extensions/claude-extension-tools.d.ts +3 -2
- package/dist/extensions/claude-extension-tools.js +15 -5
- package/dist/extensions/claude-extensions.d.ts +1 -0
- package/dist/extensions/claude-extensions.js +10 -0
- package/dist/hooks/claude-hook-tools.js +1 -1
- package/dist/mcp/claude-mcp-tools.js +12 -6
- package/dist/permissions/bash-ast.d.ts +39 -0
- package/dist/permissions/bash-ast.js +1046 -0
- package/dist/permissions/bash-normalization.d.ts +5 -0
- package/dist/permissions/bash-normalization.js +241 -0
- package/dist/permissions/bash-path-safety.d.ts +30 -0
- package/dist/permissions/bash-path-safety.js +582 -0
- package/dist/permissions/claude-permission-resolver.d.ts +18 -0
- package/dist/permissions/claude-permission-resolver.js +366 -40
- package/dist/permissions/claude-shell-permission.d.ts +4 -0
- package/dist/permissions/claude-shell-permission.js +108 -0
- package/dist/permissions/permission-updates.d.ts +16 -0
- package/dist/permissions/permission-updates.js +320 -0
- package/dist/permissions/sed-safety.d.ts +9 -0
- package/dist/permissions/sed-safety.js +172 -0
- package/dist/permissions/shell-rule-matching.d.ts +14 -0
- package/dist/permissions/shell-rule-matching.js +76 -0
- package/dist/sandbox/claude-sandbox-runtime.d.ts +54 -0
- package/dist/sandbox/claude-sandbox-runtime.js +175 -0
- package/dist/sandbox/claude-sandbox-settings.d.ts +23 -0
- package/dist/sandbox/claude-sandbox-settings.js +286 -0
- package/dist/tools/claude-interactive-tools.d.ts +10 -1
- package/dist/tools/claude-interactive-tools.js +10 -4
- package/dist/tools/local-tools.d.ts +18 -0
- package/dist/tools/local-tools.js +69 -10
- package/package.json +4 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function isClaudeSafeShellEnvironmentName(name: string): boolean;
|
|
2
|
+
export declare function stripSafeShellWrappers(command: string): string;
|
|
3
|
+
export declare function stripAllLeadingShellEnvironment(command: string): string;
|
|
4
|
+
export declare function shellPermissionMatchCandidates(command: string, stripAllEnvironment?: boolean): readonly string[];
|
|
5
|
+
//# sourceMappingURL=bash-normalization.d.ts.map
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
const SAFE_ENVIRONMENT_NAMES = new Set([
|
|
2
|
+
'GOEXPERIMENT',
|
|
3
|
+
'GOOS',
|
|
4
|
+
'GOARCH',
|
|
5
|
+
'CGO_ENABLED',
|
|
6
|
+
'GO111MODULE',
|
|
7
|
+
'RUST_BACKTRACE',
|
|
8
|
+
'RUST_LOG',
|
|
9
|
+
'NODE_ENV',
|
|
10
|
+
'PYTHONUNBUFFERED',
|
|
11
|
+
'PYTHONDONTWRITEBYTECODE',
|
|
12
|
+
'PYTEST_DISABLE_PLUGIN_AUTOLOAD',
|
|
13
|
+
'PYTEST_DEBUG',
|
|
14
|
+
'ANTHROPIC_API_KEY',
|
|
15
|
+
'LANG',
|
|
16
|
+
'LANGUAGE',
|
|
17
|
+
'LC_ALL',
|
|
18
|
+
'LC_CTYPE',
|
|
19
|
+
'LC_TIME',
|
|
20
|
+
'CHARSET',
|
|
21
|
+
'TERM',
|
|
22
|
+
'COLORTERM',
|
|
23
|
+
'NO_COLOR',
|
|
24
|
+
'FORCE_COLOR',
|
|
25
|
+
'TZ',
|
|
26
|
+
'LS_COLORS',
|
|
27
|
+
'LSCOLORS',
|
|
28
|
+
'GREP_COLOR',
|
|
29
|
+
'GREP_COLORS',
|
|
30
|
+
'GCC_COLORS',
|
|
31
|
+
'TIME_STYLE',
|
|
32
|
+
'BLOCK_SIZE',
|
|
33
|
+
'BLOCKSIZE',
|
|
34
|
+
]);
|
|
35
|
+
export function isClaudeSafeShellEnvironmentName(name) {
|
|
36
|
+
return SAFE_ENVIRONMENT_NAMES.has(name);
|
|
37
|
+
}
|
|
38
|
+
const SAFE_VALUE = '[A-Za-z0-9_./:-]+';
|
|
39
|
+
const SAFE_ASSIGNMENT = new RegExp(`^([A-Za-z_][A-Za-z0-9_]*)=${SAFE_VALUE}[ \\t]+`, 'u');
|
|
40
|
+
const SAFE_OPTION_VALUE = /^[A-Za-z0-9_.+-]+$/u;
|
|
41
|
+
const TIMEOUT_DURATION = /^\d+(?:\.\d+)?[smhd]?$/u;
|
|
42
|
+
const ENV_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/u;
|
|
43
|
+
const ENV_ASSIGNMENT = /^[A-Za-z_][A-Za-z0-9_]*=[^\s$`;|&()<>\\'"]+$/u;
|
|
44
|
+
function stripFullLineComments(command) {
|
|
45
|
+
const remaining = command
|
|
46
|
+
.split('\n')
|
|
47
|
+
.filter((line) => line.trim() !== '' && !line.trim().startsWith('#'));
|
|
48
|
+
return remaining.length > 0 ? remaining.join('\n') : command;
|
|
49
|
+
}
|
|
50
|
+
function horizontalTokens(command) {
|
|
51
|
+
if (/[\r\n]/u.test(command))
|
|
52
|
+
return [];
|
|
53
|
+
return [...command.matchAll(/[^ \t]+/gu)].map((match) => ({
|
|
54
|
+
value: match[0],
|
|
55
|
+
start: match.index,
|
|
56
|
+
end: match.index + match[0].length,
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
function remainderAfter(command, tokens, index) {
|
|
60
|
+
const token = tokens[index];
|
|
61
|
+
return token ? command.slice(token.start) : undefined;
|
|
62
|
+
}
|
|
63
|
+
function stripTimeout(command) {
|
|
64
|
+
const tokens = horizontalTokens(command);
|
|
65
|
+
if (tokens[0]?.value !== 'timeout')
|
|
66
|
+
return undefined;
|
|
67
|
+
let index = 1;
|
|
68
|
+
while (index < tokens.length) {
|
|
69
|
+
const value = tokens[index]?.value ?? '';
|
|
70
|
+
const next = tokens[index + 1]?.value;
|
|
71
|
+
if (value === '--foreground' ||
|
|
72
|
+
value === '--preserve-status' ||
|
|
73
|
+
value === '--verbose' ||
|
|
74
|
+
value === '-v') {
|
|
75
|
+
index += 1;
|
|
76
|
+
}
|
|
77
|
+
else if (/^--(?:kill-after|signal)=[A-Za-z0-9_.+-]+$/u.test(value)) {
|
|
78
|
+
index += 1;
|
|
79
|
+
}
|
|
80
|
+
else if ((value === '--kill-after' ||
|
|
81
|
+
value === '--signal' ||
|
|
82
|
+
value === '-k' ||
|
|
83
|
+
value === '-s') &&
|
|
84
|
+
next &&
|
|
85
|
+
SAFE_OPTION_VALUE.test(next)) {
|
|
86
|
+
index += 2;
|
|
87
|
+
}
|
|
88
|
+
else if (/^-[ks][A-Za-z0-9_.+-]+$/u.test(value)) {
|
|
89
|
+
index += 1;
|
|
90
|
+
}
|
|
91
|
+
else if (value === '--') {
|
|
92
|
+
index += 1;
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
else if (value.startsWith('-')) {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (!TIMEOUT_DURATION.test(tokens[index]?.value ?? ''))
|
|
103
|
+
return undefined;
|
|
104
|
+
return remainderAfter(command, tokens, index + 1);
|
|
105
|
+
}
|
|
106
|
+
function stripNice(command) {
|
|
107
|
+
const tokens = horizontalTokens(command);
|
|
108
|
+
if (tokens[0]?.value !== 'nice')
|
|
109
|
+
return undefined;
|
|
110
|
+
let index = 1;
|
|
111
|
+
if (tokens[index]?.value === '-n') {
|
|
112
|
+
if (!/^-?\d+$/u.test(tokens[index + 1]?.value ?? ''))
|
|
113
|
+
return undefined;
|
|
114
|
+
index += 2;
|
|
115
|
+
}
|
|
116
|
+
else if (/^-\d+$/u.test(tokens[index]?.value ?? '')) {
|
|
117
|
+
index += 1;
|
|
118
|
+
}
|
|
119
|
+
else if ((tokens[index]?.value ?? '').startsWith('-')) {
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
if (tokens[index]?.value === '--')
|
|
123
|
+
index += 1;
|
|
124
|
+
return remainderAfter(command, tokens, index);
|
|
125
|
+
}
|
|
126
|
+
function stripStdbuf(command) {
|
|
127
|
+
const tokens = horizontalTokens(command);
|
|
128
|
+
if (tokens[0]?.value !== 'stdbuf')
|
|
129
|
+
return undefined;
|
|
130
|
+
let index = 1;
|
|
131
|
+
let options = 0;
|
|
132
|
+
while (index < tokens.length) {
|
|
133
|
+
const value = tokens[index]?.value ?? '';
|
|
134
|
+
if (/^-[ioe][LN0-9]+$/u.test(value)) {
|
|
135
|
+
index += 1;
|
|
136
|
+
options += 1;
|
|
137
|
+
}
|
|
138
|
+
else if (/^-[ioe]$/u.test(value) && tokens[index + 1]) {
|
|
139
|
+
index += 2;
|
|
140
|
+
options += 1;
|
|
141
|
+
}
|
|
142
|
+
else if (/^--(?:input|output|error)=[LN0-9]+$/u.test(value)) {
|
|
143
|
+
index += 1;
|
|
144
|
+
options += 1;
|
|
145
|
+
}
|
|
146
|
+
else if (value === '--') {
|
|
147
|
+
index += 1;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
else if (value.startsWith('-')) {
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return options > 0 ? remainderAfter(command, tokens, index) : undefined;
|
|
158
|
+
}
|
|
159
|
+
function stripEnv(command) {
|
|
160
|
+
const tokens = horizontalTokens(command);
|
|
161
|
+
if (tokens[0]?.value !== 'env')
|
|
162
|
+
return undefined;
|
|
163
|
+
let index = 1;
|
|
164
|
+
while (index < tokens.length) {
|
|
165
|
+
const value = tokens[index]?.value ?? '';
|
|
166
|
+
if (ENV_ASSIGNMENT.test(value) || ['-i', '-0', '-v'].includes(value)) {
|
|
167
|
+
index += 1;
|
|
168
|
+
}
|
|
169
|
+
else if (value === '-u' &&
|
|
170
|
+
ENV_NAME.test(tokens[index + 1]?.value ?? '')) {
|
|
171
|
+
index += 2;
|
|
172
|
+
}
|
|
173
|
+
else if (value.startsWith('-')) {
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return remainderAfter(command, tokens, index);
|
|
181
|
+
}
|
|
182
|
+
function stripOneWrapper(command) {
|
|
183
|
+
if (/^(?:time|nohup)[ \t]+/u.test(command)) {
|
|
184
|
+
return command.replace(/^(?:time|nohup)[ \t]+(?:--[ \t]+)?/u, '');
|
|
185
|
+
}
|
|
186
|
+
return (stripTimeout(command) ??
|
|
187
|
+
stripNice(command) ??
|
|
188
|
+
stripStdbuf(command) ??
|
|
189
|
+
stripEnv(command));
|
|
190
|
+
}
|
|
191
|
+
export function stripSafeShellWrappers(command) {
|
|
192
|
+
let normalized = command.trim();
|
|
193
|
+
let previous = '';
|
|
194
|
+
while (normalized !== previous) {
|
|
195
|
+
previous = normalized;
|
|
196
|
+
normalized = stripFullLineComments(normalized);
|
|
197
|
+
const assignment = SAFE_ASSIGNMENT.exec(normalized);
|
|
198
|
+
if (assignment?.[1] && isClaudeSafeShellEnvironmentName(assignment[1])) {
|
|
199
|
+
normalized = normalized.slice(assignment[0].length);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
previous = '';
|
|
203
|
+
while (normalized !== previous) {
|
|
204
|
+
previous = normalized;
|
|
205
|
+
normalized = stripFullLineComments(normalized);
|
|
206
|
+
normalized = stripOneWrapper(normalized)?.trim() ?? normalized;
|
|
207
|
+
}
|
|
208
|
+
return normalized.trim();
|
|
209
|
+
}
|
|
210
|
+
export function stripAllLeadingShellEnvironment(command) {
|
|
211
|
+
const assignment = /^([A-Za-z_][A-Za-z0-9_]*(?:\[[^\]]*\])?)\+?=(?:'[^'\n\r]*'|"(?:\\.|[^"$`\\\n\r])*"|\\.|[^ \t\n\r$`;|&()<>\\'"])*[ \t]+/u;
|
|
212
|
+
let normalized = command.trim();
|
|
213
|
+
let previous = '';
|
|
214
|
+
while (normalized !== previous) {
|
|
215
|
+
previous = normalized;
|
|
216
|
+
normalized = stripFullLineComments(normalized);
|
|
217
|
+
const match = assignment.exec(normalized);
|
|
218
|
+
if (match)
|
|
219
|
+
normalized = normalized.slice(match[0].length);
|
|
220
|
+
}
|
|
221
|
+
return normalized.trim();
|
|
222
|
+
}
|
|
223
|
+
export function shellPermissionMatchCandidates(command, stripAllEnvironment = false) {
|
|
224
|
+
const candidates = [command.trim()];
|
|
225
|
+
const seen = new Set(candidates);
|
|
226
|
+
for (let index = 0; index < candidates.length; index += 1) {
|
|
227
|
+
const candidate = candidates[index] ?? '';
|
|
228
|
+
const normalized = [stripSafeShellWrappers(candidate)];
|
|
229
|
+
if (stripAllEnvironment) {
|
|
230
|
+
normalized.push(stripAllLeadingShellEnvironment(candidate));
|
|
231
|
+
}
|
|
232
|
+
for (const value of normalized) {
|
|
233
|
+
if (value && !seen.has(value)) {
|
|
234
|
+
seen.add(value);
|
|
235
|
+
candidates.push(value);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return candidates;
|
|
240
|
+
}
|
|
241
|
+
//# sourceMappingURL=bash-normalization.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { FsWriteRestrictionConfig } from '@anthropic-ai/sandbox-runtime';
|
|
2
|
+
import type { PermissionUpdate } from '../core/runtime.js';
|
|
3
|
+
type FileOperation = 'read' | 'write' | 'create';
|
|
4
|
+
type RuleOutcome = 'allow' | 'deny' | null;
|
|
5
|
+
export interface BashPathSafetyOptions {
|
|
6
|
+
cwd: string;
|
|
7
|
+
homeDirectory: string;
|
|
8
|
+
readRoots: readonly string[];
|
|
9
|
+
writeRoots: readonly string[];
|
|
10
|
+
internalEditableRoots?: readonly string[];
|
|
11
|
+
internalReadableRoots?: readonly string[];
|
|
12
|
+
sandboxWriteConfig?: FsWriteRestrictionConfig;
|
|
13
|
+
permissionMode: 'acceptEdits' | 'auto' | 'bypassPermissions' | 'manual' | 'dontAsk' | 'plan' | 'default';
|
|
14
|
+
fileRule?: (operation: FileOperation, absolutePath: string) => RuleOutcome;
|
|
15
|
+
platform?: NodeJS.Platform;
|
|
16
|
+
}
|
|
17
|
+
export type BashPathSafetyResult = {
|
|
18
|
+
safe: true;
|
|
19
|
+
} | {
|
|
20
|
+
safe: false;
|
|
21
|
+
behavior: 'ask' | 'deny';
|
|
22
|
+
reason: string;
|
|
23
|
+
path?: string;
|
|
24
|
+
operation?: FileOperation;
|
|
25
|
+
suggestions?: readonly PermissionUpdate[];
|
|
26
|
+
};
|
|
27
|
+
export declare function pathIsInsideRoots(candidate: string, roots: readonly string[]): boolean;
|
|
28
|
+
export declare function validateBashPathSafety(source: string, options: BashPathSafetyOptions): BashPathSafetyResult;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=bash-path-safety.d.ts.map
|