@datename/fastcode-termux 0.1.6-beta → 0.1.6
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 +6 -24
- package/dist/agent/guards.d.ts +0 -8
- package/dist/agent/guards.js +0 -195
- package/dist/agent/protocol.js +1 -4
- package/dist/agent/tools.d.ts +1 -3
- package/dist/agent/tools.js +377 -2
- package/dist/app.js +103 -335
- package/dist/cli.js +311 -362
- package/dist/commands/index.js +0 -22
- package/dist/commands/login.d.ts +2 -4
- package/dist/commands/login.js +10 -12
- package/dist/commands/logout.js +16 -8
- package/dist/commands/model.d.ts +0 -13
- package/dist/commands/model.js +22 -42
- package/dist/commands/provider.d.ts +0 -13
- package/dist/commands/provider.js +9 -20
- package/dist/commands/whoami.js +5 -6
- package/dist/config/store.d.ts +12 -32
- package/dist/config/store.js +65 -117
- package/dist/config/trust.d.ts +8 -21
- package/dist/config/trust.js +13 -99
- package/dist/lib/diagnostics.d.ts +4 -29
- package/dist/lib/diagnostics.js +4 -60
- package/dist/lib/http.d.ts +1 -11
- package/dist/lib/http.js +4 -62
- package/dist/providers/anthropic.d.ts +0 -1
- package/dist/providers/anthropic.js +0 -12
- package/dist/providers/custom.d.ts +0 -9
- package/dist/providers/deepseek.d.ts +0 -10
- package/dist/providers/deepseek.js +1 -2
- package/dist/providers/google.d.ts +0 -9
- package/dist/providers/groq.d.ts +0 -10
- package/dist/providers/groq.js +1 -2
- package/dist/providers/index.d.ts +201 -10
- package/dist/providers/index.js +0 -30
- package/dist/providers/mistral.d.ts +0 -10
- package/dist/providers/mistral.js +1 -2
- package/dist/providers/moonshot.d.ts +0 -10
- package/dist/providers/moonshot.js +1 -2
- package/dist/providers/ollama.d.ts +0 -9
- package/dist/providers/openai.d.ts +0 -10
- package/dist/providers/openai.js +1 -2
- package/dist/providers/openaiCompatible.d.ts +0 -9
- package/dist/providers/openaiCompatible.js +10 -58
- package/dist/providers/openrouter.d.ts +0 -10
- package/dist/providers/openrouter.js +1 -2
- package/dist/providers/qwen.d.ts +0 -10
- package/dist/providers/qwen.js +1 -2
- package/dist/providers/xai.d.ts +0 -10
- package/dist/providers/xai.js +1 -2
- package/dist/providers/zhipu.d.ts +0 -10
- package/dist/providers/zhipu.js +1 -2
- package/dist/session/log.d.ts +12 -35
- package/dist/session/log.js +10 -206
- package/dist/types.d.ts +1 -60
- package/dist/ui/Message.d.ts +7 -1
- package/dist/ui/Message.js +2 -13
- package/dist/ui/Prompt.d.ts +2 -1
- package/dist/ui/Prompt.js +2 -2
- package/dist/ui/Spinner.js +5 -11
- package/dist/ui/StatusBar.d.ts +1 -2
- package/dist/ui/StatusBar.js +5 -6
- package/package.json +1 -1
- package/src/agent/guards.ts +0 -196
- package/src/agent/protocol.ts +1 -4
- package/src/agent/tools.ts +377 -3
- package/src/app.ts +103 -335
- package/src/cli.ts +3 -30
- package/src/commands/index.ts +0 -22
- package/src/commands/login.ts +10 -12
- package/src/commands/logout.ts +16 -8
- package/src/commands/model.ts +22 -42
- package/src/commands/provider.ts +9 -20
- package/src/commands/whoami.ts +5 -6
- package/src/config/store.ts +69 -122
- package/src/config/trust.ts +21 -137
- package/src/lib/diagnostics.ts +4 -60
- package/src/lib/http.ts +4 -66
- package/src/providers/anthropic.ts +1 -13
- package/src/providers/deepseek.ts +1 -2
- package/src/providers/groq.ts +1 -2
- package/src/providers/index.ts +1 -32
- package/src/providers/mistral.ts +1 -2
- package/src/providers/moonshot.ts +1 -2
- package/src/providers/openai.ts +1 -2
- package/src/providers/openaiCompatible.ts +10 -58
- package/src/providers/openrouter.ts +1 -2
- package/src/providers/qwen.ts +1 -2
- package/src/providers/xai.ts +1 -2
- package/src/providers/zhipu.ts +1 -2
- package/src/session/log.ts +28 -267
- package/src/types.ts +1 -63
- package/src/ui/Message.ts +2 -13
- package/src/ui/Prompt.ts +2 -2
- package/src/ui/Spinner.ts +5 -11
- package/src/ui/StatusBar.ts +5 -6
- package/dist/agent/approval.d.ts +0 -50
- package/dist/agent/approval.js +0 -7
- package/dist/agent/compaction.d.ts +0 -39
- package/dist/agent/compaction.js +0 -227
- package/dist/agent/context.d.ts +0 -29
- package/dist/agent/context.js +0 -62
- package/dist/agent/ignore.d.ts +0 -11
- package/dist/agent/ignore.js +0 -129
- package/dist/agent/process-tree.d.ts +0 -2
- package/dist/agent/process-tree.js +0 -31
- package/dist/agent/protocol-mode.d.ts +0 -6
- package/dist/agent/protocol-mode.js +0 -51
- package/dist/agent/registry.d.ts +0 -17
- package/dist/agent/registry.js +0 -90
- package/dist/agent/runner.d.ts +0 -106
- package/dist/agent/runner.js +0 -352
- package/dist/agent/shell-session.d.ts +0 -37
- package/dist/agent/shell-session.js +0 -400
- package/dist/agent/stream.d.ts +0 -29
- package/dist/agent/stream.js +0 -103
- package/dist/agent/tool-schemas.d.ts +0 -2
- package/dist/agent/tool-schemas.js +0 -63
- package/dist/agent/tools/append_file.d.ts +0 -2
- package/dist/agent/tools/append_file.js +0 -26
- package/dist/agent/tools/apply_patch.d.ts +0 -10
- package/dist/agent/tools/apply_patch.js +0 -52
- package/dist/agent/tools/copy_file.d.ts +0 -2
- package/dist/agent/tools/copy_file.js +0 -30
- package/dist/agent/tools/delete_file.d.ts +0 -2
- package/dist/agent/tools/delete_file.js +0 -24
- package/dist/agent/tools/grep.d.ts +0 -2
- package/dist/agent/tools/grep.js +0 -23
- package/dist/agent/tools/index.d.ts +0 -2
- package/dist/agent/tools/index.js +0 -32
- package/dist/agent/tools/list_files.d.ts +0 -2
- package/dist/agent/tools/list_files.js +0 -17
- package/dist/agent/tools/make_dir.d.ts +0 -2
- package/dist/agent/tools/make_dir.js +0 -24
- package/dist/agent/tools/move_path.d.ts +0 -2
- package/dist/agent/tools/move_path.js +0 -47
- package/dist/agent/tools/paths.d.ts +0 -7
- package/dist/agent/tools/paths.js +0 -84
- package/dist/agent/tools/pwd.d.ts +0 -2
- package/dist/agent/tools/pwd.js +0 -10
- package/dist/agent/tools/read_file.d.ts +0 -2
- package/dist/agent/tools/read_file.js +0 -21
- package/dist/agent/tools/read_many.d.ts +0 -2
- package/dist/agent/tools/read_many.js +0 -25
- package/dist/agent/tools/readers.d.ts +0 -6
- package/dist/agent/tools/readers.js +0 -216
- package/dist/agent/tools/replace_in_file.d.ts +0 -2
- package/dist/agent/tools/replace_in_file.js +0 -30
- package/dist/agent/tools/shell.d.ts +0 -2
- package/dist/agent/tools/shell.js +0 -48
- package/dist/agent/tools/stat_path.d.ts +0 -2
- package/dist/agent/tools/stat_path.js +0 -31
- package/dist/agent/tools/types.d.ts +0 -39
- package/dist/agent/tools/types.js +0 -1
- package/dist/agent/tools/validate.d.ts +0 -6
- package/dist/agent/tools/validate.js +0 -29
- package/dist/agent/tools/write_file.d.ts +0 -2
- package/dist/agent/tools/write_file.js +0 -26
- package/dist/commands/attach.d.ts +0 -9
- package/dist/commands/attach.js +0 -15
- package/dist/commands/bg.d.ts +0 -7
- package/dist/commands/bg.js +0 -9
- package/dist/commands/cancel.d.ts +0 -10
- package/dist/commands/cancel.js +0 -10
- package/dist/commands/compact.d.ts +0 -10
- package/dist/commands/compact.js +0 -22
- package/dist/commands/context.d.ts +0 -7
- package/dist/commands/context.js +0 -24
- package/dist/commands/edit.d.ts +0 -10
- package/dist/commands/edit.js +0 -36
- package/dist/commands/effort.d.ts +0 -25
- package/dist/commands/effort.js +0 -48
- package/dist/commands/expand.d.ts +0 -10
- package/dist/commands/expand.js +0 -8
- package/dist/commands/jobs.d.ts +0 -7
- package/dist/commands/jobs.js +0 -16
- package/dist/commands/kill.d.ts +0 -7
- package/dist/commands/kill.js +0 -11
- package/dist/commands/steer.d.ts +0 -11
- package/dist/commands/steer.js +0 -13
- package/dist/lib/model-meta.d.ts +0 -19
- package/dist/lib/model-meta.js +0 -113
- package/dist/lib/native-tools.d.ts +0 -12
- package/dist/lib/native-tools.js +0 -21
- package/dist/lib/net.d.ts +0 -33
- package/dist/lib/net.js +0 -168
- package/dist/patch/apply.d.ts +0 -15
- package/dist/patch/apply.js +0 -172
- package/dist/patch/parse.d.ts +0 -29
- package/dist/patch/parse.js +0 -112
- package/dist/patch/plan.d.ts +0 -49
- package/dist/patch/plan.js +0 -273
- package/dist/session/projection.d.ts +0 -43
- package/dist/session/projection.js +0 -257
- package/dist/ui/Picker.d.ts +0 -8
- package/dist/ui/Picker.js +0 -24
- package/src/agent/approval.ts +0 -47
- package/src/agent/compaction.ts +0 -276
- package/src/agent/context.ts +0 -97
- package/src/agent/ignore.ts +0 -147
- package/src/agent/process-tree.ts +0 -32
- package/src/agent/protocol-mode.ts +0 -59
- package/src/agent/registry.ts +0 -98
- package/src/agent/runner.ts +0 -443
- package/src/agent/shell-session.ts +0 -449
- package/src/agent/stream.ts +0 -143
- package/src/agent/tool-schemas.ts +0 -67
- package/src/agent/tools/append_file.ts +0 -28
- package/src/agent/tools/apply_patch.ts +0 -54
- package/src/agent/tools/copy_file.ts +0 -32
- package/src/agent/tools/delete_file.ts +0 -26
- package/src/agent/tools/grep.ts +0 -25
- package/src/agent/tools/index.ts +0 -34
- package/src/agent/tools/list_files.ts +0 -19
- package/src/agent/tools/make_dir.ts +0 -26
- package/src/agent/tools/move_path.ts +0 -50
- package/src/agent/tools/paths.ts +0 -92
- package/src/agent/tools/pwd.ts +0 -12
- package/src/agent/tools/read_file.ts +0 -23
- package/src/agent/tools/read_many.ts +0 -27
- package/src/agent/tools/readers.ts +0 -228
- package/src/agent/tools/replace_in_file.ts +0 -32
- package/src/agent/tools/shell.ts +0 -53
- package/src/agent/tools/stat_path.ts +0 -33
- package/src/agent/tools/types.ts +0 -42
- package/src/agent/tools/validate.ts +0 -35
- package/src/agent/tools/write_file.ts +0 -28
- package/src/commands/attach.ts +0 -16
- package/src/commands/bg.ts +0 -9
- package/src/commands/cancel.ts +0 -10
- package/src/commands/compact.ts +0 -23
- package/src/commands/context.ts +0 -25
- package/src/commands/edit.ts +0 -37
- package/src/commands/effort.ts +0 -49
- package/src/commands/expand.ts +0 -8
- package/src/commands/jobs.ts +0 -17
- package/src/commands/kill.ts +0 -12
- package/src/commands/steer.ts +0 -13
- package/src/lib/model-meta.ts +0 -138
- package/src/lib/native-tools.ts +0 -32
- package/src/lib/net.ts +0 -204
- package/src/patch/apply.ts +0 -194
- package/src/patch/parse.ts +0 -131
- package/src/patch/plan.ts +0 -317
- package/src/session/projection.ts +0 -308
- package/src/ui/Picker.ts +0 -24
package/README.md
CHANGED
|
@@ -26,9 +26,6 @@ Short alias included:
|
|
|
26
26
|
fc
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
This tree is **0.1.6-beta**. When the beta is published to npm, install it with
|
|
30
|
-
`npm install -g @datename/fastcode-termux@0.1.6-beta`; until then use the repo/portable build.
|
|
31
|
-
|
|
32
29
|
---
|
|
33
30
|
|
|
34
31
|
## 🌈 What Is FastCode?
|
|
@@ -111,7 +108,7 @@ export OPENAI_API_KEY="sk-..."
|
|
|
111
108
|
export OPENROUTER_API_KEY="sk-or-..."
|
|
112
109
|
```
|
|
113
110
|
|
|
114
|
-
Or bind a key from inside FastCode —
|
|
111
|
+
Or bind a key from inside FastCode — scoped to a specific provider + model (input is masked):
|
|
115
112
|
|
|
116
113
|
```text
|
|
117
114
|
/login # guided: provider → model → key
|
|
@@ -249,11 +246,10 @@ Installed plugins live under:
|
|
|
249
246
|
| `/tools` | Show available coding tools |
|
|
250
247
|
| `/cwd` | Show agent sandbox root |
|
|
251
248
|
| `/plugin ...` | Import and manage always-active plugin packs |
|
|
252
|
-
| `/provider [id]` |
|
|
253
|
-
| `/model [id]` |
|
|
254
|
-
| `/
|
|
255
|
-
| `/
|
|
256
|
-
| `/logout <provider>` | Remove the provider's key (`--all` accepted for compatibility) |
|
|
249
|
+
| `/provider [id]` | List or switch provider |
|
|
250
|
+
| `/model [id]` | List or switch model |
|
|
251
|
+
| `/login [provider] [model] [key]` | Bind an API key to a provider + model (guided when omitted) |
|
|
252
|
+
| `/logout <provider> [model]` | Remove a scoped key (`--all` for the whole provider) |
|
|
257
253
|
| `/skills ...` | Search, install, enable, disable, list skills |
|
|
258
254
|
| `/theme [id]` | Switch theme |
|
|
259
255
|
| `/cost` | Show token and cost usage |
|
|
@@ -263,14 +259,6 @@ Installed plugins live under:
|
|
|
263
259
|
| `/clear` | Clear conversation |
|
|
264
260
|
| `/reset` | Reset config |
|
|
265
261
|
| `/about` | Show version and platform |
|
|
266
|
-
| `/context` | Token estimate, compaction threshold, heap |
|
|
267
|
-
| `/compact` | Force local context compaction |
|
|
268
|
-
| `/cancel` | Abort the active run (mobile alternative to Esc) |
|
|
269
|
-
| `/steer <text>` | Guide the next request of an active run |
|
|
270
|
-
| `/jobs` / `/attach <id>` / `/kill <id>` | Background shell sessions |
|
|
271
|
-
| `/expand` | Toggle full/collapsed tool output |
|
|
272
|
-
| `/edit` | Edit the prompt in `$EDITOR` (works around Ink IME bugs) |
|
|
273
|
-
| `/bg` | Explain background shell behaviour |
|
|
274
262
|
| `/exit` | Quit |
|
|
275
263
|
|
|
276
264
|
Keyboard controls:
|
|
@@ -393,7 +381,7 @@ npm publish --access public
|
|
|
393
381
|
|
|
394
382
|
---
|
|
395
383
|
|
|
396
|
-
## Safety, sessions and limits (0.1.6
|
|
384
|
+
## Safety, sessions and limits (0.1.6)
|
|
397
385
|
|
|
398
386
|
| Feature | Behaviour | Override |
|
|
399
387
|
| --- | --- | --- |
|
|
@@ -401,12 +389,6 @@ npm publish --access public
|
|
|
401
389
|
| Dangerous-command guard | rm -rf, del /f, rmdir /s, format / mkfs / diskpart, dd if=, writes to /dev/sd, shutdown / reboot / poweroff and fork bombs are refused before execution | FASTCODE_ALLOW_DANGEROUS=1, FASTCODE_SHELL_ALLOWLIST, FASTCODE_SHELL_DENY_EXTRA |
|
|
402
390
|
| Unified tool-output cap | Output is truncated while it is produced, not sliced afterwards (default 30000 characters) | FASTCODE_TOOL_OUTPUT_LIMIT |
|
|
403
391
|
| Session log | Append-only JSONL in ~/.fastcode/sessions, resumable after a crash (cache cap 256MB by default) | fastcode sessions, fastcode resume, FASTCODE_SESSION_LOG=0, FASTCODE_SESSION_CACHE_MB |
|
|
404
|
-
| Checkpoints/projection | `*.projection.json` (<20KB) with tool/model/cwd fingerprint; unpaired tool calls are completed on resume | FASTCODE_FSYNC, FASTCODE_SESSION_LOG |
|
|
405
|
-
| Patch transaction | parse → plan → apply; CRLF/mode kept; symlinks refused; move never overwrites | `/expand` for the full diff |
|
|
406
|
-
| Process tree | abort or `/kill` kills children/grandchildren | POSIX process group, Windows `taskkill /T` |
|
|
407
|
-
| Compaction | token threshold or heap pressure; summary written to `summary-*.md` | FASTCODE_COMPACTION=0, FASTCODE_HEAP_LIMIT_MB |
|
|
408
|
-
| Background shell | Commands over ~2s return a session id; poll incrementally | `/jobs`, `/attach`, `/kill`, FASTCODE_MAX_SPAWN_PER_TURN |
|
|
409
|
-
| Approval hook | Sensitive/large patches need approval; without a resolver they are denied (fail closed) | pending UI not implemented yet |
|
|
410
392
|
|
|
411
393
|
## 🙏 Credits
|
|
412
394
|
|
package/dist/agent/guards.d.ts
CHANGED
|
@@ -33,11 +33,3 @@ export declare function evaluateShellCommand(command: any): {
|
|
|
33
33
|
bypassed?: undefined;
|
|
34
34
|
pattern?: undefined;
|
|
35
35
|
};
|
|
36
|
-
export declare const READ_ONLY_TOOLS: Set<string>;
|
|
37
|
-
export declare function splitCommandSegments(command: any): any[];
|
|
38
|
-
export declare function isReadOnlyCommand(command: any): boolean;
|
|
39
|
-
export declare function isReadOnlyToolCall(call: any): boolean;
|
|
40
|
-
export declare function loopExemptTools(): Set<string>;
|
|
41
|
-
export declare function isLoopExempt(tool: any): boolean;
|
|
42
|
-
export declare function stableStringify(value: any): any;
|
|
43
|
-
export declare function toolCallFingerprint(call: any, cwd?: string): string;
|
package/dist/agent/guards.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { normalize, resolve } from "node:path";
|
|
2
1
|
/**
|
|
3
2
|
* Dangerous-command guard.
|
|
4
3
|
*
|
|
@@ -73,197 +72,3 @@ export function evaluateShellCommand(command) {
|
|
|
73
72
|
}
|
|
74
73
|
return { allow: true, output: undefined };
|
|
75
74
|
}
|
|
76
|
-
export const READ_ONLY_TOOLS = new Set([
|
|
77
|
-
"pwd", "read_file", "read_many", "list_files", "grep", "stat_path",
|
|
78
|
-
]);
|
|
79
|
-
const READ_ONLY_COMMANDS = new Set([
|
|
80
|
-
"pwd", "ls", "dir", "cat", "head", "tail", "wc", "stat", "file", "du", "df",
|
|
81
|
-
"grep", "rg", "egrep", "fgrep", "which", "whereis", "where", "whoami", "id",
|
|
82
|
-
"groups", "uname", "date", "uptime", "printenv", "echo", "printf",
|
|
83
|
-
"true", "false", "basename", "dirname", "realpath", "readlink", "tree",
|
|
84
|
-
"more", "less", "jq", "cut", "tr",
|
|
85
|
-
]);
|
|
86
|
-
const READ_ONLY_PREFIXES = new Set([
|
|
87
|
-
"git status", "git diff", "git log", "git show", "git rev-parse",
|
|
88
|
-
"git ls-files", "git blame", "git grep", "git describe", "git merge-base",
|
|
89
|
-
"git cat-file", "git rev-list", "git shortlog", "git whatchanged",
|
|
90
|
-
"npm ls", "npm list", "npm view", "npm outdated", "npm explain", "npm why",
|
|
91
|
-
"pnpm list", "pnpm ls", "yarn list", "yarn info",
|
|
92
|
-
"cargo tree", "go list", "pip list", "pip show",
|
|
93
|
-
"docker ps", "docker images", "docker logs",
|
|
94
|
-
]);
|
|
95
|
-
const NON_READ_ONLY_LEADERS = new Set([
|
|
96
|
-
"cd", "sudo", "doas", "env", "xargs", "time", "command", "eval", "exec",
|
|
97
|
-
"source", ".", "sh", "bash", "zsh", "fish", "powershell", "cmd",
|
|
98
|
-
]);
|
|
99
|
-
function scanCommand(command, onChar) {
|
|
100
|
-
let quote = "";
|
|
101
|
-
let escaped = false;
|
|
102
|
-
for (let i = 0; i < command.length; i += 1) {
|
|
103
|
-
const char = command[i];
|
|
104
|
-
if (escaped) {
|
|
105
|
-
escaped = false;
|
|
106
|
-
onChar(char, i, quote);
|
|
107
|
-
continue;
|
|
108
|
-
}
|
|
109
|
-
if (char === "\\") {
|
|
110
|
-
escaped = true;
|
|
111
|
-
onChar(char, i, quote);
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
if (quote) {
|
|
115
|
-
if (char === quote)
|
|
116
|
-
quote = "";
|
|
117
|
-
onChar(char, i, quote);
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
if (char === '"' || char === "'") {
|
|
121
|
-
quote = char;
|
|
122
|
-
onChar(char, i, quote);
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
|
-
onChar(char, i, quote);
|
|
126
|
-
}
|
|
127
|
-
return quote === "";
|
|
128
|
-
}
|
|
129
|
-
function hasWriteRedirection(command) {
|
|
130
|
-
let found = false;
|
|
131
|
-
const balanced = scanCommand(command, (char, index, quote) => {
|
|
132
|
-
if (quote || char !== ">")
|
|
133
|
-
return;
|
|
134
|
-
const previous = command[index - 1];
|
|
135
|
-
if (previous === "=")
|
|
136
|
-
return;
|
|
137
|
-
found = true;
|
|
138
|
-
});
|
|
139
|
-
return !balanced || found;
|
|
140
|
-
}
|
|
141
|
-
function hasCommandSubstitution(command) {
|
|
142
|
-
let found = false;
|
|
143
|
-
const balanced = scanCommand(command, (char, index, quote) => {
|
|
144
|
-
if (quote)
|
|
145
|
-
return;
|
|
146
|
-
if (char === "`" || (char === "$" && command[index + 1] === "("))
|
|
147
|
-
found = true;
|
|
148
|
-
});
|
|
149
|
-
return !balanced || found;
|
|
150
|
-
}
|
|
151
|
-
export function splitCommandSegments(command) {
|
|
152
|
-
const parts = [];
|
|
153
|
-
let current = "";
|
|
154
|
-
let quote = "";
|
|
155
|
-
let escaped = false;
|
|
156
|
-
for (let i = 0; i < command.length; i += 1) {
|
|
157
|
-
const char = command[i];
|
|
158
|
-
if (escaped) {
|
|
159
|
-
current += char;
|
|
160
|
-
escaped = false;
|
|
161
|
-
continue;
|
|
162
|
-
}
|
|
163
|
-
if (char === "\\") {
|
|
164
|
-
current += char;
|
|
165
|
-
escaped = true;
|
|
166
|
-
continue;
|
|
167
|
-
}
|
|
168
|
-
if (quote) {
|
|
169
|
-
current += char;
|
|
170
|
-
if (char === quote)
|
|
171
|
-
quote = "";
|
|
172
|
-
continue;
|
|
173
|
-
}
|
|
174
|
-
if (char === '"' || char === "'") {
|
|
175
|
-
quote = char;
|
|
176
|
-
current += char;
|
|
177
|
-
continue;
|
|
178
|
-
}
|
|
179
|
-
const next = command[i + 1];
|
|
180
|
-
if ((char === "&" && next === "&") || (char === "|" && next === "|")) {
|
|
181
|
-
parts.push(current);
|
|
182
|
-
current = "";
|
|
183
|
-
i += 1;
|
|
184
|
-
continue;
|
|
185
|
-
}
|
|
186
|
-
if (char === ";" || char === "|" || char === "&" || char === "\n") {
|
|
187
|
-
parts.push(current);
|
|
188
|
-
current = "";
|
|
189
|
-
continue;
|
|
190
|
-
}
|
|
191
|
-
current += char;
|
|
192
|
-
}
|
|
193
|
-
parts.push(current);
|
|
194
|
-
return parts.map((part) => part.trim()).filter(Boolean);
|
|
195
|
-
}
|
|
196
|
-
function isReadOnlySegment(segment) {
|
|
197
|
-
const tokens = segment.split(/\s+/).filter(Boolean);
|
|
198
|
-
if (tokens.length === 0)
|
|
199
|
-
return true;
|
|
200
|
-
const first = tokens[0].toLowerCase();
|
|
201
|
-
const second = (tokens[1] ?? "").toLowerCase();
|
|
202
|
-
if (NON_READ_ONLY_LEADERS.has(first))
|
|
203
|
-
return false;
|
|
204
|
-
if (READ_ONLY_PREFIXES.has(first + " " + second))
|
|
205
|
-
return true;
|
|
206
|
-
if (READ_ONLY_COMMANDS.has(first))
|
|
207
|
-
return true;
|
|
208
|
-
return false;
|
|
209
|
-
}
|
|
210
|
-
export function isReadOnlyCommand(command) {
|
|
211
|
-
const cmd = String(command ?? "").trim();
|
|
212
|
-
if (!cmd)
|
|
213
|
-
return false;
|
|
214
|
-
if (hasWriteRedirection(cmd) || hasCommandSubstitution(cmd))
|
|
215
|
-
return false;
|
|
216
|
-
const segments = splitCommandSegments(cmd);
|
|
217
|
-
if (segments.length === 0)
|
|
218
|
-
return false;
|
|
219
|
-
return segments.every(isReadOnlySegment);
|
|
220
|
-
}
|
|
221
|
-
export function isReadOnlyToolCall(call) {
|
|
222
|
-
const tool = typeof call?.tool === "string" ? call.tool : "";
|
|
223
|
-
if (tool === "shell")
|
|
224
|
-
return isReadOnlyCommand(call.command);
|
|
225
|
-
return READ_ONLY_TOOLS.has(tool);
|
|
226
|
-
}
|
|
227
|
-
export function loopExemptTools() {
|
|
228
|
-
const raw = process.env["FASTCODE_LOOP_EXEMPT"] ?? "";
|
|
229
|
-
return new Set(raw.split(",").map((entry) => entry.trim()).filter(Boolean));
|
|
230
|
-
}
|
|
231
|
-
export function isLoopExempt(tool) {
|
|
232
|
-
return loopExemptTools().has(String(tool ?? ""));
|
|
233
|
-
}
|
|
234
|
-
function stableValue(value) {
|
|
235
|
-
if (value === undefined)
|
|
236
|
-
return "null";
|
|
237
|
-
if (value === null || typeof value !== "object")
|
|
238
|
-
return JSON.stringify(value);
|
|
239
|
-
if (Array.isArray(value))
|
|
240
|
-
return "[" + value.map((entry) => stableValue(entry)).join(",") + "]";
|
|
241
|
-
const keys = Object.keys(value).sort().filter((key) => value[key] !== undefined);
|
|
242
|
-
return "{" + keys.map((key) => JSON.stringify(key) + ":" + stableValue(value[key])).join(",") + "}";
|
|
243
|
-
}
|
|
244
|
-
export function stableStringify(value) {
|
|
245
|
-
return stableValue(value);
|
|
246
|
-
}
|
|
247
|
-
function normalizeFingerprintPath(value, cwd) {
|
|
248
|
-
let normalized = normalize(resolve(cwd, value));
|
|
249
|
-
if (normalized.length > 1)
|
|
250
|
-
normalized = normalized.replace(/[\\/]+$/, "");
|
|
251
|
-
return normalized;
|
|
252
|
-
}
|
|
253
|
-
function fingerprintValue(key, value, cwd) {
|
|
254
|
-
if (typeof value === "string" && (key === "path" || key === "from" || key === "to" || key === "cwd"))
|
|
255
|
-
return normalizeFingerprintPath(value, cwd);
|
|
256
|
-
if (key === "paths" && Array.isArray(value))
|
|
257
|
-
return value.map((entry) => typeof entry === "string" ? normalizeFingerprintPath(entry, cwd) : entry);
|
|
258
|
-
return value;
|
|
259
|
-
}
|
|
260
|
-
export function toolCallFingerprint(call, cwd = process.cwd()) {
|
|
261
|
-
const tool = typeof call?.tool === "string" ? call.tool : "unknown";
|
|
262
|
-
const args = {};
|
|
263
|
-
for (const key of Object.keys(call ?? {}).sort()) {
|
|
264
|
-
if (key === "tool" || key === "timeoutMs")
|
|
265
|
-
continue;
|
|
266
|
-
args[key] = fingerprintValue(key, call[key], cwd);
|
|
267
|
-
}
|
|
268
|
-
return tool + ":" + stableStringify(args);
|
|
269
|
-
}
|
package/dist/agent/protocol.js
CHANGED
|
@@ -97,16 +97,13 @@ You can inspect and change the user's machine by emitting exactly one or more to
|
|
|
97
97
|
Available tools:
|
|
98
98
|
- shell: {"tool":"shell","command":"command to run"}
|
|
99
99
|
- shell with timeout: {"tool":"shell","command":"npm test","timeoutMs":120000}
|
|
100
|
-
- shell poll (long commands return a session id): {"tool":"shell","session_id":"sh_..."}
|
|
101
|
-
Polling returns only new output; use waitMs to wait briefly for more.
|
|
102
100
|
- pwd: {"tool":"pwd"}
|
|
103
101
|
- read_file: {"tool":"read_file","path":"path/to/file"}
|
|
104
102
|
- read_many: {"tool":"read_many","paths":["file1","file2"]}
|
|
105
103
|
- write_file: {"tool":"write_file","path":"path/to/file","content":"full file contents"}
|
|
106
104
|
- append_file: {"tool":"append_file","path":"path/to/file","content":"text to append"}
|
|
107
105
|
- apply_patch: {"tool":"apply_patch","patch":"*** Begin Patch\\n*** Update File: path\\n@@\\n-old\\n+new\\n*** End Patch\\n"}
|
|
108
|
-
- list_files: {"tool":"list_files","path":"optional/path","maxDepth":2
|
|
109
|
-
- read_file is capped (default 200KB); grep skips files over 1MB. .fastcodeignore is honored.
|
|
106
|
+
- list_files: {"tool":"list_files","path":"optional/path","maxDepth":2}
|
|
110
107
|
- grep: {"tool":"grep","pattern":"text or regex","path":"optional/path"}
|
|
111
108
|
- replace_in_file: {"tool":"replace_in_file","path":"path/to/file","find":"exact text","replace":"replacement"}
|
|
112
109
|
- stat_path: {"tool":"stat_path","path":"path/to/file"}
|
package/dist/agent/tools.d.ts
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export { TOOLS } from "./tools/index.js";
|
|
3
|
-
export type { RevalidateKey, SideEffects, StateScope, Tool, ToolCall, ToolCtx, ToolResult } from "./tools/types.js";
|
|
1
|
+
export declare function runAgentTool(call: any, cwd?: string): Promise<unknown>;
|