terminal-smart-cli 0.97.17 → 0.97.19
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/lib/agent.js +16 -4
- package/lib/meta.js +12 -1
- package/package.json +1 -1
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 } };
|
package/lib/meta.js
CHANGED
|
@@ -121,6 +121,12 @@ function directArtifactPlan(item) {
|
|
|
121
121
|
};
|
|
122
122
|
return null;
|
|
123
123
|
}
|
|
124
|
+
|
|
125
|
+
function canGenerateDirectArtifact(item, target) {
|
|
126
|
+
if (!item || !item.directArtifact) return false;
|
|
127
|
+
if (directArtifactPlan(item)) return true;
|
|
128
|
+
return !target || !fs.existsSync(target);
|
|
129
|
+
}
|
|
124
130
|
const WEB_CANVAS_MOVE_MIN = 0.02; // check de MOVIMENTO do canvas web (jogo/cena 3D): diferença MÍNIMA
|
|
125
131
|
// entre 2 quadros pra a cena contar como VIVA. Abaixo disso = parada/congelada (T-pose, mixer parado,
|
|
126
132
|
// loop sem avançar o tempo). SÓ se aplica a canvas de JOGO/3D — dashboard/gráfico pode ficar estático.
|
|
@@ -1393,6 +1399,11 @@ async function run(goal, opts = {}) {
|
|
|
1393
1399
|
// Some providers can generate a large document but refuse to place that
|
|
1394
1400
|
// content inside tool-call arguments. After a proven zero-tool response,
|
|
1395
1401
|
// generate content-only, validate it and let the confined harness persist it.
|
|
1402
|
+
if (item.directArtifact && !canGenerateDirectArtifact(item, expectedOnDisk)) {
|
|
1403
|
+
item.directArtifact = false;
|
|
1404
|
+
delete item.directModel;
|
|
1405
|
+
save(st, dir);
|
|
1406
|
+
}
|
|
1396
1407
|
if (item.directArtifact) {
|
|
1397
1408
|
const directModel = item.directModel || 'glm-5.2';
|
|
1398
1409
|
const plan = directArtifactPlan(item);
|
|
@@ -1762,4 +1773,4 @@ function trailSummary(st, lang) {
|
|
|
1762
1773
|
};
|
|
1763
1774
|
}
|
|
1764
1775
|
|
|
1765
|
-
module.exports = { webRunGate, run, load, notify, stateFile, detectBuild, ensureToolchain, runBuild, escalate, designPhase, archPhase, looksVisual, looksComplex, runApp, visualGate, ensureEmulator, _projKind, _llmVision, toolsForMetaItem, artifactForMetaItem, normalizeMetaArtifact, persistMetaArtifact, directArtifactPlan, verificationLabel, _checkCriteria, trailSummary };
|
|
1776
|
+
module.exports = { webRunGate, run, load, notify, stateFile, detectBuild, ensureToolchain, runBuild, escalate, designPhase, archPhase, looksVisual, looksComplex, runApp, visualGate, ensureEmulator, _projKind, _llmVision, toolsForMetaItem, artifactForMetaItem, normalizeMetaArtifact, persistMetaArtifact, directArtifactPlan, canGenerateDirectArtifact, verificationLabel, _checkCriteria, trailSummary };
|