goatchain 0.0.26 → 0.0.28
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 +3 -21
- package/dist/index.js +290 -294
- package/dist/tool/builtin/bash.d.ts +0 -24
- package/dist/tool/builtin/edit.d.ts +0 -12
- package/dist/tool/builtin/write.d.ts +0 -13
- package/package.json +1 -1
- package/dist/tool/builtin/pathProtection.d.ts +0 -25
|
@@ -2,7 +2,6 @@ import type { ChildProcess } from 'node:child_process';
|
|
|
2
2
|
import type { CallToolResult, ToolInputSchema } from '../../types';
|
|
3
3
|
import type { ToolExecutionContext } from '../types';
|
|
4
4
|
import { BaseTool } from '../base';
|
|
5
|
-
import { type ReadOnlyPathEntry } from './pathProtection';
|
|
6
5
|
/**
|
|
7
6
|
* Information about a tracked background process
|
|
8
7
|
*/
|
|
@@ -96,12 +95,9 @@ export declare class BashTool extends BaseTool {
|
|
|
96
95
|
private cwd;
|
|
97
96
|
/** Shell to use for command execution */
|
|
98
97
|
private shell;
|
|
99
|
-
/** Optional read-only path rules */
|
|
100
|
-
private readOnlyPaths?;
|
|
101
98
|
constructor(options?: {
|
|
102
99
|
cwd?: string;
|
|
103
100
|
shell?: string;
|
|
104
|
-
readOnlyPaths?: ReadOnlyPathEntry[];
|
|
105
101
|
});
|
|
106
102
|
/**
|
|
107
103
|
* Set the current working directory
|
|
@@ -111,14 +107,6 @@ export declare class BashTool extends BaseTool {
|
|
|
111
107
|
* Get the current working directory
|
|
112
108
|
*/
|
|
113
109
|
getCwd(): string;
|
|
114
|
-
/**
|
|
115
|
-
* Set read-only paths for write-like shell commands.
|
|
116
|
-
*/
|
|
117
|
-
setReadOnlyPaths(paths: ReadonlyArray<ReadOnlyPathEntry> | undefined): void;
|
|
118
|
-
/**
|
|
119
|
-
* Get configured read-only paths.
|
|
120
|
-
*/
|
|
121
|
-
getReadOnlyPaths(): ReadonlyArray<ReadOnlyPathEntry> | undefined;
|
|
122
110
|
/**
|
|
123
111
|
* Execute a bash command
|
|
124
112
|
*
|
|
@@ -135,18 +123,6 @@ export declare class BashTool extends BaseTool {
|
|
|
135
123
|
* Validate and parse arguments
|
|
136
124
|
*/
|
|
137
125
|
private validateArgs;
|
|
138
|
-
/**
|
|
139
|
-
* Validate read-only path policy for write-like shell commands.
|
|
140
|
-
*
|
|
141
|
-
* This is intentionally heuristic: commands that appear read-only are skipped.
|
|
142
|
-
* For write-like commands, we block when:
|
|
143
|
-
* 1) effective cwd is under a protected path, or
|
|
144
|
-
* 2) command text explicitly references a protected path.
|
|
145
|
-
*/
|
|
146
|
-
private validateReadOnlyPathPolicy;
|
|
147
|
-
private findReferencedReadOnlyRule;
|
|
148
|
-
private buildCommandPathCandidates;
|
|
149
|
-
private commandMentionsPath;
|
|
150
126
|
/**
|
|
151
127
|
* Execute command synchronously with timeout
|
|
152
128
|
*/
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { CallToolResult, ToolInputSchema } from '../../types';
|
|
2
2
|
import type { ToolExecutionContext } from '../types';
|
|
3
3
|
import { BaseTool } from '../base';
|
|
4
|
-
import { type ReadOnlyPathEntry } from './pathProtection';
|
|
5
4
|
/**
|
|
6
5
|
* Result of an edit operation
|
|
7
6
|
*/
|
|
@@ -62,13 +61,10 @@ export declare class EditTool extends BaseTool {
|
|
|
62
61
|
private fileBlacklist?;
|
|
63
62
|
/** Disable file blacklist checks */
|
|
64
63
|
private disableBlacklist;
|
|
65
|
-
/** Optional read-only path rules */
|
|
66
|
-
private readOnlyPaths?;
|
|
67
64
|
constructor(options?: {
|
|
68
65
|
cwd?: string;
|
|
69
66
|
fileBlacklist?: string[];
|
|
70
67
|
disableBlacklist?: boolean;
|
|
71
|
-
readOnlyPaths?: ReadOnlyPathEntry[];
|
|
72
68
|
});
|
|
73
69
|
/**
|
|
74
70
|
* Set the current working directory
|
|
@@ -78,14 +74,6 @@ export declare class EditTool extends BaseTool {
|
|
|
78
74
|
* Get the current working directory
|
|
79
75
|
*/
|
|
80
76
|
getCwd(): string;
|
|
81
|
-
/**
|
|
82
|
-
* Set read-only paths for file operations.
|
|
83
|
-
*/
|
|
84
|
-
setReadOnlyPaths(paths: ReadonlyArray<ReadOnlyPathEntry> | undefined): void;
|
|
85
|
-
/**
|
|
86
|
-
* Get configured read-only paths.
|
|
87
|
-
*/
|
|
88
|
-
getReadOnlyPaths(): ReadonlyArray<ReadOnlyPathEntry> | undefined;
|
|
89
77
|
/**
|
|
90
78
|
* Execute file edit
|
|
91
79
|
*
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { CallToolResult, ToolInputSchema } from '../../types';
|
|
2
2
|
import type { ToolExecutionContext } from '../types';
|
|
3
3
|
import { BaseTool } from '../base';
|
|
4
|
-
import { type ReadOnlyPathEntry } from './pathProtection';
|
|
5
4
|
/**
|
|
6
5
|
* Result of a write operation
|
|
7
6
|
*/
|
|
@@ -71,8 +70,6 @@ export declare class WriteTool extends BaseTool {
|
|
|
71
70
|
private _fileBlacklist?;
|
|
72
71
|
/** Disable file blacklist checks */
|
|
73
72
|
private _disableBlacklist;
|
|
74
|
-
/** Optional read-only path rules */
|
|
75
|
-
private _readOnlyPaths?;
|
|
76
73
|
constructor(options?: {
|
|
77
74
|
cwd?: string;
|
|
78
75
|
/** If set, restricts all file writes to this directory. Paths outside will be rejected. */
|
|
@@ -81,8 +78,6 @@ export declare class WriteTool extends BaseTool {
|
|
|
81
78
|
fileBlacklist?: string[];
|
|
82
79
|
/** Disable file blacklist checks entirely. */
|
|
83
80
|
disableBlacklist?: boolean;
|
|
84
|
-
/** Optional read-only path list. Writes into these paths will be rejected. */
|
|
85
|
-
readOnlyPaths?: ReadOnlyPathEntry[];
|
|
86
81
|
});
|
|
87
82
|
/**
|
|
88
83
|
* Dynamic description that includes allowed directory info if configured
|
|
@@ -108,14 +103,6 @@ export declare class WriteTool extends BaseTool {
|
|
|
108
103
|
* Get the allowed directory for file operations
|
|
109
104
|
*/
|
|
110
105
|
getAllowedDirectory(): string | undefined;
|
|
111
|
-
/**
|
|
112
|
-
* Set read-only paths for file operations.
|
|
113
|
-
*/
|
|
114
|
-
setReadOnlyPaths(paths: ReadonlyArray<ReadOnlyPathEntry> | undefined): void;
|
|
115
|
-
/**
|
|
116
|
-
* Get configured read-only paths.
|
|
117
|
-
*/
|
|
118
|
-
getReadOnlyPaths(): ReadonlyArray<ReadOnlyPathEntry> | undefined;
|
|
119
106
|
/**
|
|
120
107
|
* Execute file write
|
|
121
108
|
*
|
package/package.json
CHANGED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export interface ReadOnlyPathRule {
|
|
2
|
-
path: string;
|
|
3
|
-
reason?: string;
|
|
4
|
-
}
|
|
5
|
-
export type ReadOnlyPathEntry = string | ReadOnlyPathRule;
|
|
6
|
-
export interface ResolvedReadOnlyPathRule {
|
|
7
|
-
path: string;
|
|
8
|
-
reason?: string;
|
|
9
|
-
absolutePath: string;
|
|
10
|
-
}
|
|
11
|
-
export interface ReadOnlyPathCheckOptions {
|
|
12
|
-
cwd?: string;
|
|
13
|
-
readOnlyPaths?: ReadonlyArray<ReadOnlyPathEntry>;
|
|
14
|
-
originalPath?: string;
|
|
15
|
-
action?: string;
|
|
16
|
-
}
|
|
17
|
-
export interface ReadOnlyPathCheckResult {
|
|
18
|
-
isBlocked: boolean;
|
|
19
|
-
rule?: ResolvedReadOnlyPathRule;
|
|
20
|
-
message?: string;
|
|
21
|
-
}
|
|
22
|
-
export declare function resolveReadOnlyPathRules(readOnlyPaths: ReadonlyArray<ReadOnlyPathEntry> | undefined, cwd?: string): ResolvedReadOnlyPathRule[];
|
|
23
|
-
export declare function findMatchingReadOnlyPath(targetPath: string, rules: ReadonlyArray<ResolvedReadOnlyPathRule>): ResolvedReadOnlyPathRule | undefined;
|
|
24
|
-
export declare function formatReadOnlyPathError(displayPath: string, rule?: Pick<ResolvedReadOnlyPathRule, 'path' | 'absolutePath' | 'reason'>, action?: string): string;
|
|
25
|
-
export declare function checkReadOnlyPath(targetPath: string, options?: ReadOnlyPathCheckOptions): Promise<ReadOnlyPathCheckResult>;
|