@caupulican/pi-adaptative 0.81.22 → 0.81.24
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/CHANGELOG.md +13 -0
- package/dist/core/agent-session.d.ts +5 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +28 -20
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/autonomy/status.d.ts +2 -3
- package/dist/core/autonomy/status.d.ts.map +1 -1
- package/dist/core/autonomy/status.js +3 -12
- package/dist/core/autonomy/status.js.map +1 -1
- package/dist/core/autonomy-telemetry.d.ts +3 -8
- package/dist/core/autonomy-telemetry.d.ts.map +1 -1
- package/dist/core/autonomy-telemetry.js +15 -20
- package/dist/core/autonomy-telemetry.js.map +1 -1
- package/dist/core/cost/cost-summary.d.ts +26 -0
- package/dist/core/cost/cost-summary.d.ts.map +1 -0
- package/dist/core/cost/cost-summary.js +85 -0
- package/dist/core/cost/cost-summary.js.map +1 -0
- package/dist/core/cost/session-usage.d.ts.map +1 -1
- package/dist/core/cost/session-usage.js +8 -2
- package/dist/core/cost/session-usage.js.map +1 -1
- package/dist/core/failure-corpus.d.ts +10 -1
- package/dist/core/failure-corpus.d.ts.map +1 -1
- package/dist/core/failure-corpus.js +32 -26
- package/dist/core/failure-corpus.js.map +1 -1
- package/dist/core/session-analytics.d.ts +10 -2
- package/dist/core/session-analytics.d.ts.map +1 -1
- package/dist/core/session-analytics.js +75 -29
- package/dist/core/session-analytics.js.map +1 -1
- package/dist/core/settings-manager.d.ts +1 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/tool-recovery-log-records.d.ts +24 -0
- package/dist/core/tool-recovery-log-records.d.ts.map +1 -0
- package/dist/core/tool-recovery-log-records.js +63 -0
- package/dist/core/tool-recovery-log-records.js.map +1 -0
- package/dist/core/tool-recovery-log-worker.d.ts +2 -0
- package/dist/core/tool-recovery-log-worker.d.ts.map +1 -0
- package/dist/core/tool-recovery-log-worker.js +44 -0
- package/dist/core/tool-recovery-log-worker.js.map +1 -0
- package/dist/core/tool-recovery-logger.d.ts +59 -0
- package/dist/core/tool-recovery-logger.d.ts.map +1 -0
- package/dist/core/tool-recovery-logger.js +197 -0
- package/dist/core/tool-recovery-logger.js.map +1 -0
- package/dist/core/tool-repair-health.d.ts +2 -1
- package/dist/core/tool-repair-health.d.ts.map +1 -1
- package/dist/core/tool-repair-health.js +13 -4
- package/dist/core/tool-repair-health.js.map +1 -1
- package/dist/core/tool-repair-settings.d.ts +1 -0
- package/dist/core/tool-repair-settings.d.ts.map +1 -1
- package/dist/core/tool-repair-settings.js +2 -1
- package/dist/core/tool-repair-settings.js.map +1 -1
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +4 -20
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/report-commands.d.ts.map +1 -1
- package/dist/modes/interactive/report-commands.js +7 -8
- package/dist/modes/interactive/report-commands.js.map +1 -1
- package/dist/modes/interactive/session-flow-commands.d.ts +1 -2
- package/dist/modes/interactive/session-flow-commands.d.ts.map +1 -1
- package/dist/modes/interactive/session-flow-commands.js +8 -4
- package/dist/modes/interactive/session-flow-commands.js.map +1 -1
- package/docs/settings.md +6 -4
- package/docs/tool-repair.md +8 -7
- package/docs/usage.md +6 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +4 -4
|
@@ -44,6 +44,8 @@ import { SessionAnalytics } from "./session-analytics.js";
|
|
|
44
44
|
import { SessionTreeNavigator } from "./session-tree-navigator.js";
|
|
45
45
|
import { SystemPromptBuilder } from "./system-prompt-builder.js";
|
|
46
46
|
import { ToolGateController } from "./tool-gate-controller.js";
|
|
47
|
+
import { TOOL_RECOVERY_EVENT_LOG_FILE } from "./tool-recovery-log-records.js";
|
|
48
|
+
import { ToolRecoveryLogger } from "./tool-recovery-logger.js";
|
|
47
49
|
import { formatToolRepairHealthReport } from "./tool-repair-health.js";
|
|
48
50
|
import { resolveCurrentToolRepairSettings } from "./tool-repair-settings.js";
|
|
49
51
|
// ============================================================================
|
|
@@ -207,6 +209,8 @@ export class AgentSession {
|
|
|
207
209
|
_modelRouter;
|
|
208
210
|
_billingFailover;
|
|
209
211
|
_failureCorpus;
|
|
212
|
+
_toolRecoveryLogger;
|
|
213
|
+
_toolRecoveryEventLogPath;
|
|
210
214
|
_skillCuratorInstance;
|
|
211
215
|
_disposed = false;
|
|
212
216
|
_reflectionAbort = new AbortController();
|
|
@@ -326,9 +330,7 @@ export class AgentSession {
|
|
|
326
330
|
getSessionManager: () => this.sessionManager,
|
|
327
331
|
getLastModelRouterDecision: () => this._modelRouter.getLastDecision(),
|
|
328
332
|
getLastResearchLaneSkipReason: () => this._backgroundLanes.getLastResearchLaneSkipReason(),
|
|
329
|
-
|
|
330
|
-
getSpawnedUsage: () => this.getSpawnedUsage(),
|
|
331
|
-
getDailyUsageTotals: () => this.getDailyUsageTotals?.(),
|
|
333
|
+
getCostSummary: () => this.getCostSummary(),
|
|
332
334
|
getGoalStateSnapshot: () => this.getGoalStateSnapshot(),
|
|
333
335
|
getActiveLaneCount: () => this._backgroundLanes.getActiveLaneCount(),
|
|
334
336
|
getEvidenceBundleSnapshots: () => this.getEvidenceBundleSnapshots(),
|
|
@@ -397,8 +399,17 @@ export class AgentSession {
|
|
|
397
399
|
addSpawnedUsage: (usage, opts) => this.addSpawnedUsage(usage, opts),
|
|
398
400
|
runIsolatedCompletion: (opts) => this.runIsolatedCompletion(opts),
|
|
399
401
|
});
|
|
402
|
+
const failureCorpusPath = join(this._agentDir, "state", "failure-corpus.jsonl");
|
|
403
|
+
this._toolRecoveryEventLogPath = join(this._agentDir, "state", TOOL_RECOVERY_EVENT_LOG_FILE);
|
|
404
|
+
const toolRepairSettings = this._toolRepairSettings();
|
|
400
405
|
this._failureCorpus = new FailureCorpusRecorder({
|
|
401
|
-
filePath:
|
|
406
|
+
filePath: failureCorpusPath,
|
|
407
|
+
});
|
|
408
|
+
this._toolRecoveryLogger = new ToolRecoveryLogger({
|
|
409
|
+
enabled: toolRepairSettings.logging,
|
|
410
|
+
sessionId: this.sessionManager.getSessionId(),
|
|
411
|
+
eventLogPath: this._toolRecoveryEventLogPath,
|
|
412
|
+
failureCorpusPath,
|
|
402
413
|
});
|
|
403
414
|
this._billingFailover = new BillingFailoverController({
|
|
404
415
|
agent: this.agent,
|
|
@@ -538,13 +549,16 @@ export class AgentSession {
|
|
|
538
549
|
getSessionManager: () => this.sessionManager,
|
|
539
550
|
getSettingsManager: () => this.settingsManager,
|
|
540
551
|
getToolDefinition: (name) => this.getToolDefinition(name),
|
|
552
|
+
getToolRecoveryEventLogPath: () => this._toolRecoveryEventLogPath,
|
|
541
553
|
});
|
|
542
554
|
const previousToolArgumentValidation = this.agent.onToolArgumentValidation;
|
|
543
555
|
this.agent.onToolArgumentValidation = (event) => {
|
|
544
556
|
const taggedEvent = this._tagModelAdaptationRuleTeaching(event);
|
|
545
557
|
previousToolArgumentValidation?.(taggedEvent);
|
|
546
|
-
this.
|
|
547
|
-
|
|
558
|
+
const logRecord = this._toolRecoveryLogger.recordToolArgumentValidation(taggedEvent);
|
|
559
|
+
if (!logRecord)
|
|
560
|
+
return;
|
|
561
|
+
this._analytics.recordToolArgumentValidation(logRecord);
|
|
548
562
|
this._handleTextToolProtocolValidationOutcome(taggedEvent);
|
|
549
563
|
this._handleModelAdaptationTelemetry(taggedEvent);
|
|
550
564
|
};
|
|
@@ -920,7 +934,6 @@ export class AgentSession {
|
|
|
920
934
|
}
|
|
921
935
|
_applyToolRepairLayerSettings() {
|
|
922
936
|
const settings = this._toolRepairSettings();
|
|
923
|
-
this.agent.toolArgumentRepairEnabled = settings.repair;
|
|
924
937
|
this.agent.toolArgumentTeachEnabled = settings.teach;
|
|
925
938
|
}
|
|
926
939
|
_getModelAdaptationRulesForPrompt() {
|
|
@@ -1273,18 +1286,6 @@ export class AgentSession {
|
|
|
1273
1286
|
_looksLikeTextToolProtocolAttempt(text) {
|
|
1274
1287
|
return /<pi:call\b|<tool_call\b|```(?:tool|tool_call)[\s\S]*"name"\s*:/i.test(text);
|
|
1275
1288
|
}
|
|
1276
|
-
_recordToolValidationBounce(event) {
|
|
1277
|
-
if (event.outcome !== "bounced" || !event.failureShape || event.failureShape.length === 0)
|
|
1278
|
-
return;
|
|
1279
|
-
this._failureCorpus.recordToolValidation({
|
|
1280
|
-
provider: event.provider ?? this.agent.state.model?.provider,
|
|
1281
|
-
modelId: event.model ?? this.agent.state.model?.id,
|
|
1282
|
-
tool: event.tool,
|
|
1283
|
-
failureModes: event.failureModes,
|
|
1284
|
-
shape: event.failureShape,
|
|
1285
|
-
errorKeywords: event.errorKeywords,
|
|
1286
|
-
});
|
|
1287
|
-
}
|
|
1288
1289
|
_tagModelAdaptationRuleTeaching(event) {
|
|
1289
1290
|
if (!this._toolRepairSettings().teach || event.taught !== "none")
|
|
1290
1291
|
return event;
|
|
@@ -1492,7 +1493,10 @@ export class AgentSession {
|
|
|
1492
1493
|
return formatContextCompositionDashboard(this.getContextCompositionReport());
|
|
1493
1494
|
}
|
|
1494
1495
|
formatToolRepairHealthReport() {
|
|
1495
|
-
return formatToolRepairHealthReport(this._modelAdaptationStore);
|
|
1496
|
+
return formatToolRepairHealthReport(this._modelAdaptationStore, new Date(), this._toolRecoveryLogger.getStats());
|
|
1497
|
+
}
|
|
1498
|
+
async flushToolRecoveryLogsForTests(timeoutMs = 1000) {
|
|
1499
|
+
await this._toolRecoveryLogger.flush(timeoutMs);
|
|
1496
1500
|
}
|
|
1497
1501
|
removeToolRepairRule(model, mode) {
|
|
1498
1502
|
return this._modelAdaptationStore.removeRule(model, mode);
|
|
@@ -1907,6 +1911,7 @@ export class AgentSession {
|
|
|
1907
1911
|
.getMemoryManager()
|
|
1908
1912
|
.shutdownAll()
|
|
1909
1913
|
.catch(() => { });
|
|
1914
|
+
void this._toolRecoveryLogger.shutdown().catch(() => { });
|
|
1910
1915
|
cleanupSessionResources(this.sessionId);
|
|
1911
1916
|
// Best-effort final sweep for any grep/find artifact already released (reference
|
|
1912
1917
|
// count zero) but not yet reclaimed -- e.g. a release whose cleanup() call failed
|
|
@@ -3626,6 +3631,9 @@ export class AgentSession {
|
|
|
3626
3631
|
getDailyUsageTotals(now = new Date()) {
|
|
3627
3632
|
return this._analytics.getDailyUsageTotals(now);
|
|
3628
3633
|
}
|
|
3634
|
+
getCostSummary(now = new Date()) {
|
|
3635
|
+
return this._analytics.getCostSummary(now);
|
|
3636
|
+
}
|
|
3629
3637
|
getDailyUsageBreakdown(formatLabel, now = new Date()) {
|
|
3630
3638
|
return this._analytics.getDailyUsageBreakdown(formatLabel, now);
|
|
3631
3639
|
}
|