@vietor/agent-core 0.7.0 → 0.7.1
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 +15 -1
- package/dist/util/index.d.ts +2 -2
- package/dist/util/index.js +2 -2
- package/dist/util/subprocess.d.ts +1 -0
- package/dist/util/subprocess.js +14 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -787,6 +787,18 @@ interface ProcessResult {
|
|
|
787
787
|
}
|
|
788
788
|
```
|
|
789
789
|
|
|
790
|
+
### `findCommands`
|
|
791
|
+
|
|
792
|
+
**`findCommands(commands: string[]): string[]`**
|
|
793
|
+
|
|
794
|
+
Return the subset of commands that exist on the PATH (uses `where` on Windows, `command -v` elsewhere). Useful for picking an available interpreter, e.g. `node` vs `bun`.
|
|
795
|
+
|
|
796
|
+
```ts
|
|
797
|
+
import { findCommands } from "@vietor/agent-core/util";
|
|
798
|
+
|
|
799
|
+
findCommands(["python", "python3"]); // e.g. ["python"]
|
|
800
|
+
```
|
|
801
|
+
|
|
790
802
|
## File
|
|
791
803
|
|
|
792
804
|
### `tryReadFileText`
|
|
@@ -839,7 +851,7 @@ const data = await res.json();
|
|
|
839
851
|
|
|
840
852
|
## Constants
|
|
841
853
|
|
|
842
|
-
Default values mirrored by `LLMConfig` — exported so host config types can reference the same defaults.
|
|
854
|
+
Default values mirrored by `LLMConfig` — exported so host config types can reference the same defaults. Tool-call timeouts and empty results also share constants here:
|
|
843
855
|
|
|
844
856
|
| Constant | Value | Meaning |
|
|
845
857
|
|---|---|---|
|
|
@@ -847,3 +859,5 @@ Default values mirrored by `LLMConfig` — exported so host config types can ref
|
|
|
847
859
|
| `DEFAULT_BACKEND` | `"completions"` | Default `LLMConfig.backend` |
|
|
848
860
|
| `DEFAULT_MAX_INPUT_TOKENS` | `1_000_000` | Default `LLMConfig.maxInputTokens` |
|
|
849
861
|
| `DEFAULT_MAX_OUTPUT_TOKENS` | `128_000` | Default `LLMConfig.maxOutputTokens` |
|
|
862
|
+
| `CALL_TIMEOUT_MS` | `300_000` | Default tool-call timeout (Shell, MCP tools) |
|
|
863
|
+
| `NO_OUTPUT` | `"(no output)"` | Content placeholder for empty tool results |
|
package/dist/util/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { AbortedError, backoffDelay, isAbortError, mapWithConcurrency, withAbort, withRetry, withTimeout, withTimeoutFn, type RetryOptions } from "./async.js";
|
|
2
|
-
export { DEFAULT_BACKEND, DEFAULT_MAX_INPUT_TOKENS, DEFAULT_MAX_OUTPUT_TOKENS, DEFAULT_THINKING_EFFORT } from "./constants.js";
|
|
2
|
+
export { DEFAULT_BACKEND, DEFAULT_MAX_INPUT_TOKENS, DEFAULT_MAX_OUTPUT_TOKENS, DEFAULT_THINKING_EFFORT, CALL_TIMEOUT_MS, NO_OUTPUT } from "./constants.js";
|
|
3
3
|
export { tryReadFileText } from "./file.js";
|
|
4
4
|
export { htmlToMarkdown } from "./html.js";
|
|
5
5
|
export { netFetch } from "./net.js";
|
|
6
|
-
export { type ProcessResult, runProcess } from "./subprocess.js";
|
|
6
|
+
export { type ProcessResult, runProcess, findCommands } from "./subprocess.js";
|
|
7
7
|
export { formatCompactNumber, formatDuration, getTextBytes, summarizeText, toErrorMessage } from "./text.js";
|
package/dist/util/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { AbortedError, backoffDelay, isAbortError, mapWithConcurrency, withAbort, withRetry, withTimeout, withTimeoutFn } from "./async.js";
|
|
2
|
-
export { DEFAULT_BACKEND, DEFAULT_MAX_INPUT_TOKENS, DEFAULT_MAX_OUTPUT_TOKENS, DEFAULT_THINKING_EFFORT } from "./constants.js";
|
|
2
|
+
export { DEFAULT_BACKEND, DEFAULT_MAX_INPUT_TOKENS, DEFAULT_MAX_OUTPUT_TOKENS, DEFAULT_THINKING_EFFORT, CALL_TIMEOUT_MS, NO_OUTPUT } from "./constants.js";
|
|
3
3
|
export { tryReadFileText } from "./file.js";
|
|
4
4
|
export { htmlToMarkdown } from "./html.js";
|
|
5
5
|
export { netFetch } from "./net.js";
|
|
6
|
-
export { runProcess } from "./subprocess.js";
|
|
6
|
+
export { runProcess, findCommands } from "./subprocess.js";
|
|
7
7
|
export { formatCompactNumber, formatDuration, getTextBytes, summarizeText, toErrorMessage } from "./text.js";
|
package/dist/util/subprocess.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { spawn, spawnSync } from "node:child_process";
|
|
1
|
+
import { spawn, spawnSync, execSync } from "node:child_process";
|
|
2
2
|
import { MAX_PROCESS_BUFFER_MB, mbToBytes } from "./constants.js";
|
|
3
3
|
const KILL_GRACE_MS = 2000;
|
|
4
4
|
const MAX_PROCESS_BUFFER = mbToBytes(MAX_PROCESS_BUFFER_MB);
|
|
@@ -111,3 +111,16 @@ export function runProcess(cmd, args, opts = {}, signal) {
|
|
|
111
111
|
});
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
|
+
export function findCommands(commands) {
|
|
115
|
+
const isWindows = process.platform === 'win32';
|
|
116
|
+
return commands.filter((cmd) => {
|
|
117
|
+
try {
|
|
118
|
+
const checkCmd = isWindows ? `where ${cmd}` : `command -v ${cmd}`;
|
|
119
|
+
execSync(checkCmd, { stdio: 'ignore' });
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|