terminal-smart-cli 0.97.53 → 0.97.54
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 +34 -7
- package/package.json +2 -2
package/lib/agent.js
CHANGED
|
@@ -145,6 +145,27 @@ function canCloseFromProofs(verifyReport, actions) {
|
|
|
145
145
|
return !!(verifyReport && verifyReport.allOk && verifyReport.total > 0 && Array.isArray(actions) && actions.length > 0);
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
+
// Assinaturas pessoais executam cada papel por um processo separado do Codex/
|
|
149
|
+
// Claude CLI. Para uma alteração local simples, chamar outro modelo apenas para
|
|
150
|
+
// reler o mesmo ledger de ferramentas adiciona bastante contexto sem acrescentar
|
|
151
|
+
// uma prova independente. Nesses casos o harness (resultado da escrita + gates
|
|
152
|
+
// determinísticos) encerra a missão; tarefas complexas, comandos, ações externas,
|
|
153
|
+
// erros ou lotes maiores continuam recebendo o inspetor de IA.
|
|
154
|
+
function independentInspectorDecision({ personalSubscription = false, complexTask = false,
|
|
155
|
+
actions = [], verifyReport = null, unresolvedErrors = [] } = {}) {
|
|
156
|
+
if (!personalSubscription) return { run:true, reason:'managed_plan' };
|
|
157
|
+
if (complexTask) return { run:true, reason:'complex_task' };
|
|
158
|
+
if (Array.isArray(unresolvedErrors) && unresolvedErrors.length) return { run:true, reason:'tool_errors' };
|
|
159
|
+
const rows = Array.isArray(actions) ? actions : [];
|
|
160
|
+
const mutations = rows.filter(a => ['escrever_arquivo', 'editar_arquivo', 'editar_documento', 'editar_planilha'].includes(a && a.name));
|
|
161
|
+
if (!mutations.length) return { run:true, reason:'non_file_action' };
|
|
162
|
+
if (mutations.length > 2 || rows.some(a => ['executar_comando', 'executar_remoto'].includes(a && a.name))) {
|
|
163
|
+
return { run:true, reason:'broader_change' };
|
|
164
|
+
}
|
|
165
|
+
if (verifyReport && verifyReport.total > 0 && !verifyReport.allOk) return { run:true, reason:'failed_proof' };
|
|
166
|
+
return { run:false, reason:verifyReport && verifyReport.total > 0 ? 'deterministic_proof' : 'simple_file_ledger' };
|
|
167
|
+
}
|
|
168
|
+
|
|
148
169
|
function missionBudgetSuggestion({ limit = 0, spent = 0, required = 0, available = 0 } = {}) {
|
|
149
170
|
const missing = Math.max(0, Number(required) - Number(available));
|
|
150
171
|
return Math.max(Number(limit) + 1, Number(spent) + Number(required), Number(limit) + missing);
|
|
@@ -1715,19 +1736,25 @@ async function run(task, opts = {}) {
|
|
|
1715
1736
|
// INSPETOR independente: recebe apenas objetivo, plano e EVIDÊNCIAS. Não tem
|
|
1716
1737
|
// ferramentas nem pode alterar o projeto. Se confirmar uma falha, o próximo
|
|
1717
1738
|
// turno muda para o papel corretor e recebe somente essas falhas.
|
|
1718
|
-
|
|
1739
|
+
const recoveredTools = new Set(actions.map(a => a.name));
|
|
1740
|
+
const unresolvedErrors = _toolErrs.filter(e => !recoveredTools.has(e.tool)).slice(-8);
|
|
1741
|
+
const inspectorDecision = independentInspectorDecision({
|
|
1742
|
+
personalSubscription:!!opts.personalSubscription, complexTask:_complexTask,
|
|
1743
|
+
actions, verifyReport, unresolvedErrors,
|
|
1744
|
+
});
|
|
1745
|
+
if (!roMode && _actionExpected && actions.length && !guardStopped && opts.orchestrate !== false
|
|
1746
|
+
&& _inspectorAttempts < 2 && inspectorDecision.run) {
|
|
1719
1747
|
_inspectorAttempts++;
|
|
1720
1748
|
const proofEvidence = (verifyReport && verifyReport.results || []).map(p => ({ ok: p.ok, label: p.label || p.type, detail: p.detail })).slice(0, 12);
|
|
1721
1749
|
const mutationActions = actions.filter(a => ['escrever_arquivo', 'editar_arquivo', 'editar_documento', 'editar_planilha'].includes(a.name));
|
|
1722
|
-
const recoveredTools = new Set(actions.map(a => a.name));
|
|
1723
|
-
const unresolvedErrors = _toolErrs.filter(e => !recoveredTools.has(e.tool)).slice(-8);
|
|
1724
1750
|
const inspector = await _callRole('inspector',
|
|
1725
1751
|
'Responda APENAS JSON válido: {"verdict":"pass|fail","confirmed_failures":[],"summary":""}. '
|
|
1726
|
-
+ 'Falhe somente por divergência concreta entre pedido/critério e evidência. Não invente requisito, não peça melhoria opcional e não aceite narrativa sem prova.'
|
|
1727
|
-
+ '
|
|
1752
|
+
+ 'Falhe somente por divergência concreta entre pedido/critério e evidência. Não invente requisito, não peça melhoria opcional e não aceite narrativa sem prova. '
|
|
1753
|
+
+ 'O ledger de ferramentas e runFacts é evidência determinística do harness: fileMutationCount=0 prova zero mutações por ferramentas de arquivo nesta rodada. Alvos de comando são resumos de telemetria; não falhe apenas por corte visual se a evidência registra exit 0.',
|
|
1728
1754
|
JSON.stringify({ task: taskText, auditPack: _auditPack && _auditPack.id, plan: _planDecision, actions, proofs: proofEvidence,
|
|
1729
1755
|
runFacts: { fileMutationCount: mutationActions.length, fileMutations: mutationActions },
|
|
1730
|
-
unresolvedToolErrors: unresolvedErrors, executorSummary: candidateText.slice(0, 4000) })
|
|
1756
|
+
unresolvedToolErrors: unresolvedErrors, executorSummary: candidateText.slice(0, 4000) }),
|
|
1757
|
+
value => !!(value && /^(?:pass|fail)$/i.test(String(value.verdict || ''))));
|
|
1731
1758
|
const inspection = normalizeInspectorDecision(inspector && inspector.json);
|
|
1732
1759
|
_inspectionTrace.push(Object.assign({ model: inspector && inspector.model || '' }, inspection));
|
|
1733
1760
|
if (!inspection.passed && inspection.failures.length && !_guard()) {
|
|
@@ -2450,4 +2477,4 @@ async function run(task, opts = {}) {
|
|
|
2450
2477
|
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, observability: _observability, report: _finalReport, orchestration: { plan: _planDecision, roles: _roleTrace, inspections: _inspectionTrace, phaseBudgets: _phaseBudgets, phaseUsage: _phaseUsage }, missionCache: _missionCache.stats() };
|
|
2451
2478
|
}
|
|
2452
2479
|
|
|
2453
|
-
module.exports = { run, llm, _test: { systemPrompt, projectBrief, inspectionGateDecision, candidateAdmitsIncomplete, isInspectionCommand, parseStageJson, materialDecisionPreflight, actionExpectedForTask, requiresActionEvidence, shouldRunPlanner, isComplexTask, validatePlannerDecision, planUpgradeLimit, commandRecoveryHint, windowsUnsupportedUnixCommand, mutationBatchConflicts, normalizePlannerDecision, normalizeInspectorDecision, winFor, estMsgsTok, COMPACT_AT, KEEP_TAIL, loopSig, isCycle, loopDecision, decideApproval, failureFingerprint, missionGuardDecision, missionBudgetSuggestion, missionTokenCap, missionTimeCap, modelCallWindow, executorFallbackChain, forcedModelMismatch, isTransientModelError, executorCompletionCap, completionGateDecision, canCloseFromProofs, taskScopedToolDefs, explicitTaskWorkdir, restrictedGatewayDecision, validarModeloByok, scopeToolDefs, parseTextToolCalls, isUntrustedToolOutput, untrustedToolEnvelope, isRemoteDeployCommand, browserApprovalRequest } };
|
|
2480
|
+
module.exports = { run, llm, _test: { systemPrompt, projectBrief, inspectionGateDecision, independentInspectorDecision, candidateAdmitsIncomplete, isInspectionCommand, parseStageJson, materialDecisionPreflight, actionExpectedForTask, requiresActionEvidence, shouldRunPlanner, isComplexTask, validatePlannerDecision, planUpgradeLimit, commandRecoveryHint, windowsUnsupportedUnixCommand, mutationBatchConflicts, normalizePlannerDecision, normalizeInspectorDecision, winFor, estMsgsTok, COMPACT_AT, KEEP_TAIL, loopSig, isCycle, loopDecision, decideApproval, failureFingerprint, missionGuardDecision, missionBudgetSuggestion, missionTokenCap, missionTimeCap, modelCallWindow, executorFallbackChain, forcedModelMismatch, isTransientModelError, executorCompletionCap, completionGateDecision, canCloseFromProofs, taskScopedToolDefs, explicitTaskWorkdir, restrictedGatewayDecision, validarModeloByok, scopeToolDefs, parseTextToolCalls, isUntrustedToolOutput, untrustedToolEnvelope, isRemoteDeployCommand, browserApprovalRequest } };
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "terminal-smart-cli",
|
|
3
|
-
"version": "0.97.
|
|
3
|
+
"version": "0.97.54",
|
|
4
4
|
"description": "Terminal Smart no seu terminal — pergunte, analise logs por pipe e orquestre agentes de IA. Comando: ts",
|
|
5
5
|
"bin": {
|
|
6
6
|
"ts": "bin/ts.js"
|
|
7
7
|
},
|
|
8
8
|
"scripts": {
|
|
9
|
-
"test": "node test/durable-operation.test.js && node test/content-quality-runtime-files.test.js && node test/personal-agent-llm.test.js && node test/planner-fallback.test.js"
|
|
9
|
+
"test": "node test/durable-operation.test.js && node test/content-quality-runtime-files.test.js && node test/personal-agent-llm.test.js && node test/personal-inspector-efficiency.test.js && node test/planner-fallback.test.js"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
12
|
"bin",
|