getprismo 0.1.56 → 0.1.58
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/prismo-dev/agent.js +18 -11
- package/lib/prismo-dev/enforce.js +13 -4
- package/package.json +1 -1
package/lib/prismo-dev/agent.js
CHANGED
|
@@ -575,17 +575,24 @@ module.exports = function createAgent(deps) {
|
|
|
575
575
|
try {
|
|
576
576
|
await sendHeartbeat(config, { mode, status: "online", lastPollAt: pollTime }, options);
|
|
577
577
|
} catch (_) {}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
578
|
+
|
|
579
|
+
// Presence heartbeat above runs every poll (cheap upsert). The live-event
|
|
580
|
+
// feed and loop/context publishing only need the slower sync cadence, so
|
|
581
|
+
// gate them on syncTelemetry to avoid a burst of small writes every poll.
|
|
582
|
+
const publishLive = options.syncTelemetry !== false;
|
|
583
|
+
if (publishLive) {
|
|
584
|
+
await sendLiveEvent(config, {
|
|
585
|
+
eventId: `heartbeat-${repo.pathBasename}-${pollTime.slice(0, 16)}`,
|
|
586
|
+
phase: "watching",
|
|
587
|
+
eventType: "heartbeat",
|
|
588
|
+
headline: "Connector is watching this repo",
|
|
589
|
+
detail: `Mode: ${mode}. Polling for safe repairs and syncing telemetry.`,
|
|
590
|
+
repo,
|
|
591
|
+
}, options);
|
|
592
|
+
await publishClaudeLoopStops(config, rootDir, repo, options);
|
|
593
|
+
await publishClaudeContextBlocks(config, rootDir, repo, options);
|
|
594
|
+
await publishAgentLoopSignals(config, rootDir, repo, options);
|
|
595
|
+
}
|
|
589
596
|
|
|
590
597
|
let autoDetectResult = null;
|
|
591
598
|
if (options.autoDetect) {
|
|
@@ -13,9 +13,16 @@ module.exports = function createEnforce(deps) {
|
|
|
13
13
|
const MAX_COMMAND_FAILURES = 3;
|
|
14
14
|
const MAX_TRACKED_SESSIONS = 8;
|
|
15
15
|
const DENIAL_LOG_LIMIT = 50;
|
|
16
|
-
//
|
|
17
|
-
//
|
|
16
|
+
// Tokens a denied retry keeps out of context. A repeated quiet command saves
|
|
17
|
+
// little; a repeated noisy one (tests, builds, installs) would have dumped a
|
|
18
|
+
// full round of output, so it saves far more.
|
|
18
19
|
const LOOP_DENY_TOKEN_ESTIMATE = 2000;
|
|
20
|
+
const NOISY_LOOP_TOKEN_ESTIMATE = 12000;
|
|
21
|
+
const NOISY_LOOP_RE = /\b(test|jest|vitest|pytest|build|webpack|vite|tsc|install|lint|eslint|playwright|cypress|coverage)\b/i;
|
|
22
|
+
|
|
23
|
+
function loopTokenEstimate(command) {
|
|
24
|
+
return NOISY_LOOP_RE.test(String(command || "")) ? NOISY_LOOP_TOKEN_ESTIMATE : LOOP_DENY_TOKEN_ESTIMATE;
|
|
25
|
+
}
|
|
19
26
|
|
|
20
27
|
function blockedContextPath(root) {
|
|
21
28
|
return path.join(root, ".prismo", "blocked-context.txt");
|
|
@@ -106,7 +113,7 @@ module.exports = function createEnforce(deps) {
|
|
|
106
113
|
reason,
|
|
107
114
|
failures: payload.failures || 0,
|
|
108
115
|
attempts: payload.attempts || 0,
|
|
109
|
-
estimatedTokensSaved: LOOP_DENY_TOKEN_ESTIMATE,
|
|
116
|
+
estimatedTokensSaved: Number(payload.estimatedTokensSaved) || LOOP_DENY_TOKEN_ESTIMATE,
|
|
110
117
|
sessionId,
|
|
111
118
|
}, ...loopStops].slice(0, DENIAL_LOG_LIMIT);
|
|
112
119
|
writeState(root, state);
|
|
@@ -232,10 +239,12 @@ module.exports = function createEnforce(deps) {
|
|
|
232
239
|
const deniedByFailures = !record.succeeded && record.outcomes > 0 && record.failures >= MAX_COMMAND_FAILURES;
|
|
233
240
|
const deniedByAttempts = record.outcomes === 0 && record.attempts >= MAX_IDENTICAL_COMMANDS;
|
|
234
241
|
if (deniedByFailures || deniedByAttempts) {
|
|
235
|
-
|
|
242
|
+
const loopTokens = loopTokenEstimate(command);
|
|
243
|
+
recordDenial(root, state, "loop", command, loopTokens);
|
|
236
244
|
recordLoopStop(root, state, {
|
|
237
245
|
command,
|
|
238
246
|
sessionId,
|
|
247
|
+
estimatedTokensSaved: loopTokens,
|
|
239
248
|
reason: deniedByFailures ? "repeated-failing-command" : "repeated-identical-command",
|
|
240
249
|
failures: record.failures,
|
|
241
250
|
attempts: record.attempts,
|
package/package.json
CHANGED