@molecule/api-ai-tools 1.3.0 → 1.4.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/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +18 -24
- package/package.json +2 -2
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;AAoB9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AA+BnE;;;;;;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;AAoB9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AA+BnE;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,gBAAgB,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,MAAM,EAAE,CA+wCxF"}
|
package/dist/tools.js
CHANGED
|
@@ -904,7 +904,19 @@ export function buildTools(backend, config) {
|
|
|
904
904
|
// offset/limit, so a long log is cheap to follow), and an `.exit` file
|
|
905
905
|
// appears when it finishes — so "is it done?" is a read, not a poll that
|
|
906
906
|
// blocks a turn.
|
|
907
|
-
|
|
907
|
+
// A command that declares its OWN budget larger than this tool's ceiling,
|
|
908
|
+
// and whose output is withheld until the pipeline ends, would be stopped
|
|
909
|
+
// at the ceiling having printed nothing. It used to be REFUSED ("Nothing
|
|
910
|
+
// was run") — which cost the executor a whole step in 48 of 48
|
|
911
|
+
// conversations that tried one (production analytics, 2026-09-26). It
|
|
912
|
+
// now runs in the background instead: the step does the work, and the
|
|
913
|
+
// executor gets a handle to wait on.
|
|
914
|
+
const ceilingSeconds = commandBudgetMs ? Math.max(1, Math.round(commandBudgetMs / 1000)) : 0;
|
|
915
|
+
const declaredSeconds = commandBudgetMs ? declaredBudgetSeconds(command, input.timeout) : 0;
|
|
916
|
+
const overCeiling = commandBudgetMs !== undefined &&
|
|
917
|
+
declaredSeconds > ceilingSeconds &&
|
|
918
|
+
outputIsWithheldUntilExit(command);
|
|
919
|
+
if (input.run_in_background === true || overCeiling) {
|
|
908
920
|
const id = `mol-bg-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
909
921
|
const log = `/tmp/${id}.log`;
|
|
910
922
|
const exitFile = `/tmp/${id}.exit`;
|
|
@@ -921,7 +933,11 @@ export function buildTools(backend, config) {
|
|
|
921
933
|
taskId: id,
|
|
922
934
|
log,
|
|
923
935
|
exitFile,
|
|
924
|
-
note:
|
|
936
|
+
note: (overCeiling
|
|
937
|
+
? `This command asks for ${declaredSeconds}s, more than this tool's ${ceilingSeconds}s, and its ` +
|
|
938
|
+
'output only appears when it ends — so it was started in the background instead. '
|
|
939
|
+
: '') +
|
|
940
|
+
`Started in the background. Its output is being written to ${log} — read it with ` +
|
|
925
941
|
`read_file (use offset/limit to follow a long one). When it finishes, ${exitFile} ` +
|
|
926
942
|
`appears and holds the exit code. If you have other work, do it and check back. If ` +
|
|
927
943
|
`you need this result before you can continue, call wait_for_task with this taskId — ` +
|
|
@@ -934,28 +950,6 @@ export function buildTools(backend, config) {
|
|
|
934
950
|
};
|
|
935
951
|
}
|
|
936
952
|
}
|
|
937
|
-
// A command that declares its OWN budget larger than this tool's ceiling,
|
|
938
|
-
// and whose output is withheld until the pipeline ends, cannot produce
|
|
939
|
-
// anything: it will be stopped at the ceiling having printed nothing.
|
|
940
|
-
// Measured across six agent runs, that combination was ten commands and
|
|
941
|
-
// 49 minutes — 11% of all wall clock — each returning a few hundred bytes.
|
|
942
|
-
// Refusing in five seconds, naming both ways out, is strictly better than
|
|
943
|
-
// spending the ceiling to say the same thing afterwards. A command that
|
|
944
|
-
// declares nothing still RUNS: partial output survives an overrun, so
|
|
945
|
-
// there is something to learn either way.
|
|
946
|
-
if (commandBudgetMs) {
|
|
947
|
-
const ceiling = Math.max(1, Math.round(commandBudgetMs / 1000));
|
|
948
|
-
const declared = declaredBudgetSeconds(command, input.timeout);
|
|
949
|
-
if (declared > ceiling && outputIsWithheldUntilExit(command)) {
|
|
950
|
-
return {
|
|
951
|
-
error: `This command asks for ${declared}s and this tool stops at ${ceiling}s — and its output ` +
|
|
952
|
-
'is piped into tail/head/grep, which print nothing until the pipeline ends, so it ' +
|
|
953
|
-
'would spend the whole budget and hand you back nothing. Either run a smaller unit ' +
|
|
954
|
-
'(one spec file, one build step) that finishes inside the limit, or drop the pipe ' +
|
|
955
|
-
'and use a streaming reporter so the output survives being stopped. Nothing was run.',
|
|
956
|
-
};
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
953
|
try {
|
|
960
954
|
// exec_command runs installs/builds/tests — the old 30s hardcap killed
|
|
961
955
|
// those spuriously; use the (generous, caller-configurable) budget.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/api-ai-tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
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",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@molecule/api-ai": "^1.0.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@molecule/api-ai": "1.
|
|
34
|
+
"@molecule/api-ai": "1.3.0",
|
|
35
35
|
"@types/node": "26.1.2",
|
|
36
36
|
"typescript": "6.0.3",
|
|
37
37
|
"vitest": "4.1.11"
|