terminal-smart-cli 0.97.18 → 0.97.20
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/bin/ts.js +1 -1
- package/lib/agent.js +16 -4
- package/package.json +1 -1
package/bin/ts.js
CHANGED
|
@@ -1940,7 +1940,7 @@ async function metaCmd() {
|
|
|
1940
1940
|
} else if (st.pause_reason === 'timeout') {
|
|
1941
1941
|
console.log(ui.infoLine('Tempo limite atingido. Retome com "ts meta".'));
|
|
1942
1942
|
} else if (st.pause_reason === 'model_no_action') {
|
|
1943
|
-
console.log(ui.infoLine('O executor
|
|
1943
|
+
console.log(ui.infoLine('O executor não persistiu o artefato esperado. A retomada usará outro executor; geração direta só é permitida para arquivo novo. Rode "ts meta".'));
|
|
1944
1944
|
} else if (st.pause_reason === 'connection') {
|
|
1945
1945
|
console.log(ui.infoLine('O provedor interrompeu a geração. O progresso foi salvo; rode "ts meta" para retomar.'));
|
|
1946
1946
|
} else if (st.pause_reason === 'invalid_artifact') {
|
package/lib/agent.js
CHANGED
|
@@ -131,6 +131,11 @@ function missionTimeCap(requested, maxIter) {
|
|
|
131
131
|
return Math.max(DEFAULT_MISSION_TIME_MS, Math.min(scaled, 3600000));
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
function modelCallWindow({ maxDurationMs, elapsedMs, capMs = 60000, minMs = 10000 } = {}) {
|
|
135
|
+
const remaining = Math.max(0, Number(maxDurationMs) - Number(elapsedMs));
|
|
136
|
+
return remaining < minMs ? 0 : Math.min(Number(capMs) || 60000, remaining);
|
|
137
|
+
}
|
|
138
|
+
|
|
134
139
|
function inspectionGateDecision({ actionExpected = false, hasMutation = false, calls = 0, warnAt = 6, max = 8 } = {}) {
|
|
135
140
|
if (!actionExpected || hasMutation) return 'ok';
|
|
136
141
|
if (calls > max) return 'block';
|
|
@@ -945,11 +950,16 @@ async function run(task, opts = {}) {
|
|
|
945
950
|
|
|
946
951
|
async function _callMainModel(extra = {}) {
|
|
947
952
|
for (;;) {
|
|
953
|
+
const signalMs = modelCallWindow({ maxDurationMs, elapsedMs:Date.now() - missionStartedAt });
|
|
954
|
+
if (!signalMs) {
|
|
955
|
+
guardStopped = { kind:'time', elapsedMs:Date.now() - missionStartedAt, maxMs:maxDurationMs };
|
|
956
|
+
return { msg:{ content:'' }, usage:{}, model:selectedModel, billing:null };
|
|
957
|
+
}
|
|
948
958
|
try {
|
|
949
959
|
return await llm({
|
|
950
960
|
baseUrl: k.baseUrl, key: k.key, messages, model: selectedModel,
|
|
951
961
|
toolsOverride: mainTools, creditBudget: Math.max(1, maxCredits - charged - _visionCredits),
|
|
952
|
-
tries:
|
|
962
|
+
...extra, signalMs, tries: 1,
|
|
953
963
|
});
|
|
954
964
|
} catch (e) {
|
|
955
965
|
const next = _modelChain[_modelIndex + 1];
|
|
@@ -979,10 +989,12 @@ async function run(task, opts = {}) {
|
|
|
979
989
|
const candidates = (model || k.source === 'byok') ? [selectedModel] : [...contract.candidates];
|
|
980
990
|
let last = null;
|
|
981
991
|
for (const roleModel of candidates) {
|
|
992
|
+
const signalMs = modelCallWindow({ maxDurationMs, elapsedMs:Date.now() - missionStartedAt });
|
|
993
|
+
if (!signalMs) break;
|
|
982
994
|
try {
|
|
983
995
|
onStep({ name: 'agente_' + role, detail: roleModel });
|
|
984
|
-
const r = await llm({ baseUrl: k.baseUrl, key: k.key, model: roleModel, noTools: true, signalMs
|
|
985
|
-
creditBudget: Math.max(1, maxCredits - charged - _visionCredits), tries:
|
|
996
|
+
const r = await llm({ baseUrl: k.baseUrl, key: k.key, model: roleModel, noTools: true, signalMs,
|
|
997
|
+
creditBudget: Math.max(1, maxCredits - charged - _visionCredits), tries: 1,
|
|
986
998
|
messages: [{ role: 'system', content: contract.prompt + '\n' + system }, { role: 'user', content: user }] });
|
|
987
999
|
const u = r.usage || {};
|
|
988
1000
|
acc.inTok += u.prompt_tokens || 0; acc.outTok += u.completion_tokens || 0;
|
|
@@ -1779,4 +1791,4 @@ async function run(task, opts = {}) {
|
|
|
1779
1791
|
return { text: finalText, steps, credits: charged + _visionCredits, tokens: acc, model: usedModel, actions, messages, cwd, context: lastCtx, toolErrors: _toolErrs, lastToolError: _lastErr, guard: guardStopped, completion, verification: verifyReport, orchestration: { plan: _planDecision, roles: _roleTrace, inspections: _inspectionTrace }, missionCache: _missionCache.stats() };
|
|
1780
1792
|
}
|
|
1781
1793
|
|
|
1782
|
-
module.exports = { run, llm, _test: { systemPrompt, projectBrief, inspectionGateDecision, isInspectionCommand, parseStageJson, materialDecisionPreflight, actionExpectedForTask, shouldRunPlanner, commandRecoveryHint, mutationBatchConflicts, normalizePlannerDecision, normalizeInspectorDecision, winFor, estMsgsTok, COMPACT_AT, KEEP_TAIL, loopSig, isCycle, loopDecision, decideApproval, failureFingerprint, missionGuardDecision, missionBudgetSuggestion, missionTokenCap, missionTimeCap, executorFallbackChain, isTransientModelError, completionGateDecision, canCloseFromProofs, taskScopedToolDefs, validarModeloByok, scopeToolDefs, parseTextToolCalls } };
|
|
1794
|
+
module.exports = { run, llm, _test: { systemPrompt, projectBrief, inspectionGateDecision, isInspectionCommand, parseStageJson, materialDecisionPreflight, actionExpectedForTask, shouldRunPlanner, commandRecoveryHint, mutationBatchConflicts, normalizePlannerDecision, normalizeInspectorDecision, winFor, estMsgsTok, COMPACT_AT, KEEP_TAIL, loopSig, isCycle, loopDecision, decideApproval, failureFingerprint, missionGuardDecision, missionBudgetSuggestion, missionTokenCap, missionTimeCap, modelCallWindow, executorFallbackChain, isTransientModelError, completionGateDecision, canCloseFromProofs, taskScopedToolDefs, validarModeloByok, scopeToolDefs, parseTextToolCalls } };
|