@molecule/api-ai-tools 1.0.3 → 1.0.4
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 +11 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +20 -2
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-
|
|
6
|
+
Generated: 2026-09-13T01:33:38.011Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/api-ai-tools
|
|
@@ -208,6 +208,16 @@ interface ToolBuildConfig {
|
|
|
208
208
|
*/
|
|
209
209
|
execTimeoutMs?: number
|
|
210
210
|
|
|
211
|
+
/**
|
|
212
|
+
* Budget (ms) enforced INSIDE the sandbox for a single `exec_command`: the
|
|
213
|
+
* command runs under `timeout`, so when it overruns it is stopped and the
|
|
214
|
+
* tool still returns everything it printed until then (exit code 124 plus
|
|
215
|
+
* an `error` naming the limit). Without this, an outer per-tool timeout
|
|
216
|
+
* races the run and discards minutes of build or test output along with
|
|
217
|
+
* the result. Set it a little under that outer timeout. Unset = no wrapper.
|
|
218
|
+
*/
|
|
219
|
+
commandBudgetMs?: number
|
|
220
|
+
|
|
211
221
|
/**
|
|
212
222
|
* Directory names `search_files` and `find_files` skip (VS Code
|
|
213
223
|
* `search.exclude` semantics). Defaults to `DEFAULT_SEARCH_EXCLUDED_DIRS`
|
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAG9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAsBnE;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAG9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAsBnE;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,MAAM,EAAE,CAwqBxF"}
|
package/dist/tools.js
CHANGED
|
@@ -16,7 +16,7 @@ import { checkBlockedCommand, DEFAULT_SEARCH_EXCLUDED_DIRS, directoryReadHint, i
|
|
|
16
16
|
* @returns Array of AITool objects ready to pass to an AI provider
|
|
17
17
|
*/
|
|
18
18
|
export function buildTools(backend, config) {
|
|
19
|
-
const { include, exclude, pathGuards = true, symlinkGuards = false, redactSecrets: doRedact = true, blockDangerousCommands = false, blockCommand, execTimeoutMs = 120_000, searchExcludedDirs, onAfterWrite, onFileDiff, onFileChange, } = config ?? {};
|
|
19
|
+
const { include, exclude, pathGuards = true, symlinkGuards = false, redactSecrets: doRedact = true, blockDangerousCommands = false, blockCommand, execTimeoutMs = 120_000, commandBudgetMs, searchExcludedDirs, onAfterWrite, onFileDiff, onFileChange, } = config ?? {};
|
|
20
20
|
const root = backend.projectRoot;
|
|
21
21
|
// One synchronized excluded-dir set for BOTH search tools (VS Code
|
|
22
22
|
// `search.exclude` semantics). Names are validated defensively — they are
|
|
@@ -502,12 +502,30 @@ export function buildTools(backend, config) {
|
|
|
502
502
|
try {
|
|
503
503
|
// exec_command runs installs/builds/tests — the old 30s hardcap killed
|
|
504
504
|
// those spuriously; use the (generous, caller-configurable) budget.
|
|
505
|
-
|
|
505
|
+
// With a command budget, the command runs under `timeout` inside the
|
|
506
|
+
// sandbox: an overrun is stopped there (the whole process group) and
|
|
507
|
+
// everything printed until then comes back with exit code 124, instead
|
|
508
|
+
// of an outer timeout discarding the run and its output together.
|
|
509
|
+
const budgetSeconds = commandBudgetMs ? Math.max(1, Math.round(commandBudgetMs / 1000)) : 0;
|
|
510
|
+
const wrapped = budgetSeconds
|
|
511
|
+
? `timeout -k 5 ${budgetSeconds} bash -c ${shellQuote(command)}`
|
|
512
|
+
: command;
|
|
513
|
+
const result = await backend.run(wrapped, { cwd, timeout: execTimeoutMs });
|
|
506
514
|
// truncateMiddle (not truncate): a failing build/test/migration puts its
|
|
507
515
|
// error at the TAIL, so keep the head AND the tail — head-only truncation
|
|
508
516
|
// strands the executor with passing progress and no failure reason.
|
|
509
517
|
const stdout = sanitizeOutput(truncateMiddle(result.stdout, MAX_OUTPUT_SIZE));
|
|
510
518
|
const stderr = sanitizeOutput(truncateMiddle(result.stderr, MAX_OUTPUT_SIZE));
|
|
519
|
+
if (budgetSeconds && result.exitCode === 124) {
|
|
520
|
+
return {
|
|
521
|
+
stdout,
|
|
522
|
+
stderr,
|
|
523
|
+
exitCode: result.exitCode,
|
|
524
|
+
error: `The command was stopped after ${budgetSeconds}s, this tool's limit; the output above is ` +
|
|
525
|
+
'everything it printed until then. Run a smaller unit per command (one test file, one ' +
|
|
526
|
+
'build step) instead of chaining a build and a whole suite.',
|
|
527
|
+
};
|
|
528
|
+
}
|
|
511
529
|
return { stdout, stderr, exitCode: result.exitCode };
|
|
512
530
|
}
|
|
513
531
|
catch (e) {
|
package/dist/types.d.ts
CHANGED
|
@@ -74,6 +74,15 @@ export interface ToolBuildConfig {
|
|
|
74
74
|
* this is only the ceiling before a wedged command is killed.
|
|
75
75
|
*/
|
|
76
76
|
execTimeoutMs?: number;
|
|
77
|
+
/**
|
|
78
|
+
* Budget (ms) enforced INSIDE the sandbox for a single `exec_command`: the
|
|
79
|
+
* command runs under `timeout`, so when it overruns it is stopped and the
|
|
80
|
+
* tool still returns everything it printed until then (exit code 124 plus
|
|
81
|
+
* an `error` naming the limit). Without this, an outer per-tool timeout
|
|
82
|
+
* races the run and discards minutes of build or test output along with
|
|
83
|
+
* the result. Set it a little under that outer timeout. Unset = no wrapper.
|
|
84
|
+
*/
|
|
85
|
+
commandBudgetMs?: number;
|
|
77
86
|
/**
|
|
78
87
|
* Directory names `search_files` and `find_files` skip (VS Code
|
|
79
88
|
* `search.exclude` semantics). Defaults to `DEFAULT_SEARCH_EXCLUDED_DIRS`
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,yFAAyF;IACzF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAE5B,6CAA6C;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAEvC,qEAAqE;IACrE,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEvD,qBAAqB;IACrB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEvC,mCAAmC;IACnC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAA;KAAE,CAAC,CAAC,CAAA;IAEnF;;;OAGG;IACH,GAAG,CACD,OA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IAAI,CAAC,CAAA;IAE9C,yEAAyE;IACzE,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;IAE3C,wFAAwF;IACxF,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAA;CAChD;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,UAAU,EAAE,MAAM,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,SAAS,GAAG,UAAU,GAAG,SAAS,CAAA;IACxC,IAAI,EAAE,MAAM,CAAA;CACb;AAED,+DAA+D;AAC/D,MAAM,WAAW,UAAU;IACzB,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,yBAAyB;IACzB,WAAW,EAAE,MAAM,CAAA;IACnB,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAA;CACb;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAA;IAEjB,yBAAyB;IACzB,WAAW,EAAE,MAAM,CAAA;IAEnB,+DAA+D;IAC/D,KAAK,EAAE,MAAM,EAAE,CAAA;IAEf,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB,oDAAoD;IACpD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IAEjB,kFAAkF;IAClF,gBAAgB,CAAC,EAAE,UAAU,EAAE,CAAA;IAE/B,+CAA+C;IAC/C,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;CAC1B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/api-ai-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Shared AI agent tools with backend abstraction for sandbox and local execution",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@molecule/api-ai": "1.2.0",
|
|
35
35
|
"@types/node": "26.1.2",
|
|
36
36
|
"typescript": "6.0.3",
|
|
37
|
-
"vitest": "4.1.
|
|
37
|
+
"vitest": "4.1.11"
|
|
38
38
|
},
|
|
39
39
|
"repository": {
|
|
40
40
|
"type": "git",
|