@wrongstack/core 0.8.0 → 0.8.2
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/dist/{agent-subagent-runner-Bzeueq2J.d.ts → agent-subagent-runner-Cav3yEJM.d.ts} +1 -1
- package/dist/coordination/index.d.ts +6 -6
- package/dist/defaults/index.d.ts +8 -8
- package/dist/defaults/index.js +71 -9
- package/dist/defaults/index.js.map +1 -1
- package/dist/execution/index.d.ts +22 -5
- package/dist/execution/index.js +42 -6
- package/dist/execution/index.js.map +1 -1
- package/dist/extension/index.d.ts +2 -2
- package/dist/{index-BciJeH8g.d.ts → index-oYZeWsuJ.d.ts} +1 -1
- package/dist/index.d.ts +9 -9
- package/dist/index.js +71 -9
- package/dist/index.js.map +1 -1
- package/dist/kernel/index.d.ts +1 -1
- package/dist/{multi-agent-coordinator-tlSWD4cE.d.ts → multi-agent-coordinator-IQKrMfXz.d.ts} +1 -1
- package/dist/{null-fleet-bus-DXEvZKHW.d.ts → null-fleet-bus-sKnVwEd8.d.ts} +2 -2
- package/dist/{permission-policy-D5Gj1o2K.d.ts → permission-policy-BBa1M1xc.d.ts} +10 -1
- package/dist/sdd/index.d.ts +3 -3
- package/dist/{secret-scrubber-DXkhwuka.d.ts → secret-scrubber-C0n1EqrC.d.ts} +1 -1
- package/dist/{secret-scrubber-nI8qjaqW.d.ts → secret-scrubber-CyE1-EMG.d.ts} +1 -1
- package/dist/security/index.d.ts +3 -3
- package/dist/security/index.js +29 -3
- package/dist/security/index.js.map +1 -1
- package/dist/{tool-executor-Cx2ndr0L.d.ts → tool-executor-QwfWnQZ8.d.ts} +1 -1
- package/dist/types/index.d.ts +4 -4
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as Agent, f as AgentInput } from './index-
|
|
1
|
+
import { c as Agent, f as AgentInput } from './index-oYZeWsuJ.js';
|
|
2
2
|
import { E as EventBus } from './events-DyhxkstG.js';
|
|
3
3
|
import { n as SubagentConfig, v as TaskSpec, t as SubagentRunner } from './multi-agent-CRMznZmf.js';
|
|
4
4
|
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export { A as ACP_AGENTS, a as AGENTS_BY_PHASE, b as AGENT_CATALOG, c as ALL_AGENT_DEFINITIONS, d as ALL_FLEET_AGENTS, e as AUDIT_LOG_AGENT, f as AutoExtendCeiling, g as AutoExtendPolicy, B as BUG_HUNTER_AGENT, C as CreateDelegateToolOptions, D as DEFAULT_DIRECTOR_PREAMBLE, h as DEFAULT_SUBAGENT_BASELINE, i as DelegateHost, j as Director, k as DirectorPromptParts, l as DirectorSessionFactory, m as DirectorSessionFactoryOptions, F as FLEET_ROSTER, n as FLEET_ROSTER_BUDGETS, o as FLEET_ROSTER_WITHACP, p as FleetCostCapError, q as FleetManager, r as FleetManagerOptions, s as FleetRosterBudget, t as FleetSpawnBudgetError, I as ICoordinator, u as IFleetManager, N as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, S as SECURITY_SCANNER_AGENT, v as SubagentPromptParts, w as applyRosterBudget, x as attachAutoExtend, y as composeDirectorPrompt, z as composeSubagentPrompt, E as createDelegateTool, G as getAgentDefinition, H as makeDirectorSessionFactory, J as rosterSummaryFromConfigs } from '../null-fleet-bus-
|
|
2
|
-
import { b as AgentDefinition } from '../multi-agent-coordinator-
|
|
3
|
-
export { T as AGENT_TOOL_PRESETS, A as AgentBudgetTier, a as AgentCapability, c as AgentPhase, D as DEFAULT_DISPATCH_ROLE, d as DefaultMultiAgentCoordinator, e as DispatchCandidate, f as DispatchClassifier, g as DispatchMethod, h as DispatchOptions, i as DispatchResult, H as HEAVY_BUDGET, L as LIGHT_BUDGET, M as MEDIUM_BUDGET, j as MultiAgentCoordinatorOptions, k as dispatchAgent, m as makeLLMClassifier, s as scoreAgents } from '../multi-agent-coordinator-
|
|
1
|
+
export { A as ACP_AGENTS, a as AGENTS_BY_PHASE, b as AGENT_CATALOG, c as ALL_AGENT_DEFINITIONS, d as ALL_FLEET_AGENTS, e as AUDIT_LOG_AGENT, f as AutoExtendCeiling, g as AutoExtendPolicy, B as BUG_HUNTER_AGENT, C as CreateDelegateToolOptions, D as DEFAULT_DIRECTOR_PREAMBLE, h as DEFAULT_SUBAGENT_BASELINE, i as DelegateHost, j as Director, k as DirectorPromptParts, l as DirectorSessionFactory, m as DirectorSessionFactoryOptions, F as FLEET_ROSTER, n as FLEET_ROSTER_BUDGETS, o as FLEET_ROSTER_WITHACP, p as FleetCostCapError, q as FleetManager, r as FleetManagerOptions, s as FleetRosterBudget, t as FleetSpawnBudgetError, I as ICoordinator, u as IFleetManager, N as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, S as SECURITY_SCANNER_AGENT, v as SubagentPromptParts, w as applyRosterBudget, x as attachAutoExtend, y as composeDirectorPrompt, z as composeSubagentPrompt, E as createDelegateTool, G as getAgentDefinition, H as makeDirectorSessionFactory, J as rosterSummaryFromConfigs } from '../null-fleet-bus-sKnVwEd8.js';
|
|
2
|
+
import { b as AgentDefinition } from '../multi-agent-coordinator-IQKrMfXz.js';
|
|
3
|
+
export { T as AGENT_TOOL_PRESETS, A as AgentBudgetTier, a as AgentCapability, c as AgentPhase, D as DEFAULT_DISPATCH_ROLE, d as DefaultMultiAgentCoordinator, e as DispatchCandidate, f as DispatchClassifier, g as DispatchMethod, h as DispatchOptions, i as DispatchResult, H as HEAVY_BUDGET, L as LIGHT_BUDGET, M as MEDIUM_BUDGET, j as MultiAgentCoordinatorOptions, k as dispatchAgent, m as makeLLMClassifier, s as scoreAgents } from '../multi-agent-coordinator-IQKrMfXz.js';
|
|
4
4
|
export { c as BudgetExceededError, d as BudgetKind, e as BudgetLimits, f as BudgetNegotiationMode, g as BudgetThresholdDecision, h as BudgetThresholdHandler, i as BudgetThresholdSignal, j as BudgetUsage, m as SubagentBudget } from '../multi-agent-CRMznZmf.js';
|
|
5
|
-
export { A as AgentFactory, a as AgentFactoryResult, b as AgentRunnerOptions, F as FleetBus, c as FleetEvent, d as FleetHandler, e as FleetUsage, f as FleetUsageAggregator, S as SubagentUsageSnapshot, m as makeAgentSubagentRunner } from '../agent-subagent-runner-
|
|
5
|
+
export { A as AgentFactory, a as AgentFactoryResult, b as AgentRunnerOptions, F as FleetBus, c as FleetEvent, d as FleetHandler, e as FleetUsage, f as FleetUsageAggregator, S as SubagentUsageSnapshot, m as makeAgentSubagentRunner } from '../agent-subagent-runner-Cav3yEJM.js';
|
|
6
6
|
export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-DPxcUVkn.js';
|
|
7
7
|
import '../context-z2x5gv_V.js';
|
|
8
8
|
import '../director-state-BmYi3DGA.js';
|
|
9
9
|
import '../events-DyhxkstG.js';
|
|
10
10
|
import 'node:events';
|
|
11
|
-
import '../index-
|
|
11
|
+
import '../index-oYZeWsuJ.js';
|
|
12
12
|
import '../logger-DDd5C--Z.js';
|
|
13
13
|
import '../system-prompt-CWA6ml-d.js';
|
|
14
14
|
import '../observability-BhnVLBLS.js';
|
|
15
|
-
import '../secret-scrubber-
|
|
15
|
+
import '../secret-scrubber-CyE1-EMG.js';
|
|
16
16
|
import '../config-Bi4Q0fnz.js';
|
|
17
17
|
import '../models-registry-BcYJDKLm.js';
|
|
18
18
|
|
package/dist/defaults/index.d.ts
CHANGED
|
@@ -2,16 +2,16 @@ export { D as DefaultLogger, a as DefaultLoggerOptions } from '../logger-bOzkF5L
|
|
|
2
2
|
export { A as AbandonedSession, a as AttachmentStoreOptions, C as ConfigLoaderOptions, b as ConfigMigration, c as ConfigMigrationError, d as ConfigSource, D as DEFAULT_CONFIG_MIGRATIONS, e as DefaultAttachmentStore, f as DefaultConfigLoader, g as DefaultConfigStore, h as DefaultMemoryStore, i as DefaultSessionStore, M as MemoryStoreOptions, j as MigrationContext, k as MigrationResult, P as PersistedQueueItem, l as PlanFile, m as PlanItem, n as PlanTemplate, Q as QueueStore, R as RecoveryLock, o as RecoveryLockOptions, S as SessionAnalyzer, p as SessionStoreOptions, T as TodosCheckpointFile, q as addPlanItem, r as attachPlanCheckpoint, s as attachTodosCheckpoint, t as clearPlan, u as deriveTodosFromPlanItem, v as emptyPlan, w as formatPlan, x as formatPlanTemplates, y as getPlanTemplate, z as listPlanTemplates, B as loadPlan, E as loadTodosCheckpoint, F as removePlanItem, G as runConfigMigrations, H as savePlan, I as saveTodosCheckpoint, J as setPlanItemStatus } from '../plan-templates-BnlpEkX8.js';
|
|
3
3
|
export { D as DefaultSessionReader } from '../session-reader-DsadjyF9.js';
|
|
4
4
|
export { D as DirectorStateCheckpoint, a as DirectorStateSnapshot, b as DirectorSubagentState, c as DirectorTaskState, l as loadDirectorState } from '../director-state-BmYi3DGA.js';
|
|
5
|
-
export { D as DefaultSecretScrubber, a as DefaultSecretVault, S as SecretVaultOptions, d as decryptConfigSecrets, e as encryptConfigSecrets, m as migratePlaintextSecrets, r as rewriteConfigEncrypted } from '../secret-scrubber-
|
|
6
|
-
export { A as AutoApprovePermissionPolicy, D as DefaultPermissionPolicy, P as PermissionPolicyOptions } from '../permission-policy-
|
|
7
|
-
export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, T as ToolExecutor } from '../tool-executor-
|
|
5
|
+
export { D as DefaultSecretScrubber, a as DefaultSecretVault, S as SecretVaultOptions, d as decryptConfigSecrets, e as encryptConfigSecrets, m as migratePlaintextSecrets, r as rewriteConfigEncrypted } from '../secret-scrubber-C0n1EqrC.js';
|
|
6
|
+
export { A as AutoApprovePermissionPolicy, D as DefaultPermissionPolicy, P as PermissionPolicyOptions } from '../permission-policy-BBa1M1xc.js';
|
|
7
|
+
export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, T as ToolExecutor } from '../tool-executor-QwfWnQZ8.js';
|
|
8
8
|
export { AutoCompactionMiddleware, AutonomousRunner, AutonomousRunnerOptions, AutonomyPromptContributorOptions, DefaultSkillLoader, DoneCheckResult, DoneConditionChecker, EternalAutonomyEngine, EternalAutonomyOptions, EternalEngineState, IntelligentCompactor, IntelligentCompactorOptions, ParallelEngineState, ParallelEternalEngine, ParallelEternalOptions, SelectiveCompactor, SelectiveCompactorOptions, SkillLoaderOptions, buildGoalPreamble, makeAutonomyPromptContributor } from '../execution/index.js';
|
|
9
9
|
import { P as ProviderRunner, R as RunProviderOptions } from '../provider-runner-BrA0XR-l.js';
|
|
10
10
|
import { q as Response } from '../context-z2x5gv_V.js';
|
|
11
|
-
export { a as AGENTS_BY_PHASE, b as AGENT_CATALOG, c as ALL_AGENT_DEFINITIONS, d as ALL_FLEET_AGENTS, e as AUDIT_LOG_AGENT, f as AutoExtendCeiling, g as AutoExtendPolicy, B as BUG_HUNTER_AGENT, C as CreateDelegateToolOptions, D as DEFAULT_DIRECTOR_PREAMBLE, h as DEFAULT_SUBAGENT_BASELINE, i as DelegateHost, j as Director, k as DirectorPromptParts, l as DirectorSessionFactory, m as DirectorSessionFactoryOptions, F as FLEET_ROSTER, n as FLEET_ROSTER_BUDGETS, s as FleetRosterBudget, t as FleetSpawnBudgetError, I as ICoordinator, u as IFleetManager, N as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, S as SECURITY_SCANNER_AGENT, v as SubagentPromptParts, w as applyRosterBudget, x as attachAutoExtend, y as composeDirectorPrompt, z as composeSubagentPrompt, E as createDelegateTool, G as getAgentDefinition, H as makeDirectorSessionFactory, J as rosterSummaryFromConfigs } from '../null-fleet-bus-
|
|
12
|
-
export { A as AgentBudgetTier, a as AgentCapability, b as AgentDefinition, c as AgentPhase, D as DEFAULT_DISPATCH_ROLE, d as DefaultMultiAgentCoordinator, e as DispatchCandidate, f as DispatchClassifier, g as DispatchMethod, h as DispatchOptions, i as DispatchResult, j as MultiAgentCoordinatorOptions, k as dispatchAgent, m as makeLLMClassifier, s as scoreAgents } from '../multi-agent-coordinator-
|
|
11
|
+
export { a as AGENTS_BY_PHASE, b as AGENT_CATALOG, c as ALL_AGENT_DEFINITIONS, d as ALL_FLEET_AGENTS, e as AUDIT_LOG_AGENT, f as AutoExtendCeiling, g as AutoExtendPolicy, B as BUG_HUNTER_AGENT, C as CreateDelegateToolOptions, D as DEFAULT_DIRECTOR_PREAMBLE, h as DEFAULT_SUBAGENT_BASELINE, i as DelegateHost, j as Director, k as DirectorPromptParts, l as DirectorSessionFactory, m as DirectorSessionFactoryOptions, F as FLEET_ROSTER, n as FLEET_ROSTER_BUDGETS, s as FleetRosterBudget, t as FleetSpawnBudgetError, I as ICoordinator, u as IFleetManager, N as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, S as SECURITY_SCANNER_AGENT, v as SubagentPromptParts, w as applyRosterBudget, x as attachAutoExtend, y as composeDirectorPrompt, z as composeSubagentPrompt, E as createDelegateTool, G as getAgentDefinition, H as makeDirectorSessionFactory, J as rosterSummaryFromConfigs } from '../null-fleet-bus-sKnVwEd8.js';
|
|
12
|
+
export { A as AgentBudgetTier, a as AgentCapability, b as AgentDefinition, c as AgentPhase, D as DEFAULT_DISPATCH_ROLE, d as DefaultMultiAgentCoordinator, e as DispatchCandidate, f as DispatchClassifier, g as DispatchMethod, h as DispatchOptions, i as DispatchResult, j as MultiAgentCoordinatorOptions, k as dispatchAgent, m as makeLLMClassifier, s as scoreAgents } from '../multi-agent-coordinator-IQKrMfXz.js';
|
|
13
13
|
export { c as BudgetExceededError, d as BudgetKind, e as BudgetLimits, j as BudgetUsage, m as SubagentBudget } from '../multi-agent-CRMznZmf.js';
|
|
14
|
-
export { A as AgentFactory, a as AgentFactoryResult, b as AgentRunnerOptions, F as FleetBus, c as FleetEvent, d as FleetHandler, e as FleetUsage, f as FleetUsageAggregator, S as SubagentUsageSnapshot, m as makeAgentSubagentRunner } from '../agent-subagent-runner-
|
|
14
|
+
export { A as AgentFactory, a as AgentFactoryResult, b as AgentRunnerOptions, F as FleetBus, c as FleetEvent, d as FleetHandler, e as FleetUsage, f as FleetUsageAggregator, S as SubagentUsageSnapshot, m as makeAgentSubagentRunner } from '../agent-subagent-runner-Cav3yEJM.js';
|
|
15
15
|
export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-DPxcUVkn.js';
|
|
16
16
|
export { D as DefaultModelsRegistry, a as DefaultModelsRegistryOptions, c as classifyFamily } from '../models-registry-OG_30xqZ.js';
|
|
17
17
|
export { DefaultModeStore, LLMSelector, LLMSelectorOptions, ModeLoaderOptions, loadProjectModes, loadUserModes } from '../models/index.js';
|
|
@@ -26,11 +26,11 @@ import '../wstack-paths-gCrJ631C.js';
|
|
|
26
26
|
import '../config-Bi4Q0fnz.js';
|
|
27
27
|
import '../models-registry-BcYJDKLm.js';
|
|
28
28
|
import '../secret-vault-DoISxaKO.js';
|
|
29
|
-
import '../secret-scrubber-
|
|
29
|
+
import '../secret-scrubber-CyE1-EMG.js';
|
|
30
30
|
import '../input-reader-E-ffP2ee.js';
|
|
31
31
|
import '../compactor-Mw7-rNyb.js';
|
|
32
32
|
import '../retry-policy-OwtKNxo8.js';
|
|
33
|
-
import '../index-
|
|
33
|
+
import '../index-oYZeWsuJ.js';
|
|
34
34
|
import '../system-prompt-CWA6ml-d.js';
|
|
35
35
|
import '../observability-BhnVLBLS.js';
|
|
36
36
|
import '../selector-DkvgYVS4.js';
|
package/dist/defaults/index.js
CHANGED
|
@@ -3213,10 +3213,36 @@ var DefaultPermissionPolicy = class {
|
|
|
3213
3213
|
return void 0;
|
|
3214
3214
|
}
|
|
3215
3215
|
};
|
|
3216
|
-
var AutoApprovePermissionPolicy = class {
|
|
3216
|
+
var AutoApprovePermissionPolicy = class _AutoApprovePermissionPolicy {
|
|
3217
|
+
/**
|
|
3218
|
+
* Tools that are too dangerous to auto-approve even in a delegated
|
|
3219
|
+
* subagent context. Subagents run non-interactively under a director
|
|
3220
|
+
* and cannot answer prompts, but inherited authorization does not
|
|
3221
|
+
* imply blanket permission for destructive or privilege-escalating
|
|
3222
|
+
* operations. These tools remain at their declared `permission`
|
|
3223
|
+
* level so the leader must explicitly allow them per-spawn.
|
|
3224
|
+
*/
|
|
3225
|
+
static DENY = /* @__PURE__ */ new Set([
|
|
3226
|
+
"bash",
|
|
3227
|
+
// arbitrary shell — use exec for constrained shell
|
|
3228
|
+
"write",
|
|
3229
|
+
// arbitrary file write
|
|
3230
|
+
"scaffold",
|
|
3231
|
+
// arbitrary file generation outside project root
|
|
3232
|
+
"patch",
|
|
3233
|
+
// arbitrary diff application
|
|
3234
|
+
"install",
|
|
3235
|
+
// installs from arbitrary package sources
|
|
3236
|
+
"exec"
|
|
3237
|
+
// restricted shell but with arbitrary command args
|
|
3238
|
+
]);
|
|
3217
3239
|
async evaluate(tool) {
|
|
3218
|
-
if (tool.permission === "deny") {
|
|
3219
|
-
return {
|
|
3240
|
+
if (tool.permission === "deny" || _AutoApprovePermissionPolicy.DENY.has(tool.name)) {
|
|
3241
|
+
return {
|
|
3242
|
+
permission: "deny",
|
|
3243
|
+
source: "subagent_guard",
|
|
3244
|
+
reason: _AutoApprovePermissionPolicy.DENY.has(tool.name) ? `tool ${tool.name} is not auto-approved for subagents \u2014 ask the leader to allow it explicitly` : "tool default deny"
|
|
3245
|
+
};
|
|
3220
3246
|
}
|
|
3221
3247
|
return { permission: "auto", source: "yolo" };
|
|
3222
3248
|
}
|
|
@@ -4801,6 +4827,7 @@ Summarize the following message range:`;
|
|
|
4801
4827
|
};
|
|
4802
4828
|
|
|
4803
4829
|
// src/execution/auto-compaction-middleware.ts
|
|
4830
|
+
var LEVEL_RANK2 = { warn: 0, soft: 1, hard: 2 };
|
|
4804
4831
|
var AutoCompactionMiddleware = class _AutoCompactionMiddleware {
|
|
4805
4832
|
name = "AutoCompaction";
|
|
4806
4833
|
compactor;
|
|
@@ -4821,6 +4848,16 @@ var AutoCompactionMiddleware = class _AutoCompactionMiddleware {
|
|
|
4821
4848
|
* short conversations, causing premature compaction triggers.
|
|
4822
4849
|
*/
|
|
4823
4850
|
static OVERHEAD_FACTOR = 1.3;
|
|
4851
|
+
/**
|
|
4852
|
+
* Once a compaction attempt reduces nothing (preserveK protects everything,
|
|
4853
|
+
* no oversized tool_results remain to elide), retrying on every iteration
|
|
4854
|
+
* just spams `compaction.fired` events without making progress. We remember
|
|
4855
|
+
* the no-op and skip until either the pressure level escalates or context
|
|
4856
|
+
* has grown by at least this many tokens since the failed attempt.
|
|
4857
|
+
*/
|
|
4858
|
+
static NOOP_RETRY_DELTA_TOKENS = 2e3;
|
|
4859
|
+
/** Tracks the most recent no-op attempt so we can avoid re-firing per turn. */
|
|
4860
|
+
lastNoopAttempt = null;
|
|
4824
4861
|
/**
|
|
4825
4862
|
* @param compactor Compactor to use for compaction.
|
|
4826
4863
|
* @param maxContext Provider's max context window in tokens.
|
|
@@ -4862,19 +4899,44 @@ var AutoCompactionMiddleware = class _AutoCompactionMiddleware {
|
|
|
4862
4899
|
hard: this.hardThreshold
|
|
4863
4900
|
};
|
|
4864
4901
|
const aggressiveOn = policy?.aggressiveOn ?? this.aggressiveOn;
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
} else if (load >= thresholds.warn) {
|
|
4870
|
-
await this.compact(ctx, aggressiveOn === "warn", { level: "warn", tokens, load });
|
|
4902
|
+
const level = load >= thresholds.hard ? "hard" : load >= thresholds.soft ? "soft" : load >= thresholds.warn ? "warn" : null;
|
|
4903
|
+
if (!level) {
|
|
4904
|
+
this.lastNoopAttempt = null;
|
|
4905
|
+
return next(ctx);
|
|
4871
4906
|
}
|
|
4907
|
+
if (this.shouldSkipNoopRetry(level, tokens)) {
|
|
4908
|
+
return next(ctx);
|
|
4909
|
+
}
|
|
4910
|
+
const aggressive = level === "hard" ? true : level === "soft" ? aggressiveOn !== "hard" : aggressiveOn === "warn";
|
|
4911
|
+
await this.compact(ctx, aggressive, { level, tokens, load });
|
|
4872
4912
|
return next(ctx);
|
|
4873
4913
|
};
|
|
4874
4914
|
}
|
|
4915
|
+
/**
|
|
4916
|
+
* Returns true when the previous compaction at the same or higher pressure
|
|
4917
|
+
* level reduced nothing and context has not grown materially since. Prevents
|
|
4918
|
+
* a stuck preserveK window from spamming compaction events every iteration.
|
|
4919
|
+
*/
|
|
4920
|
+
shouldSkipNoopRetry(level, tokens) {
|
|
4921
|
+
const stuck = this.lastNoopAttempt;
|
|
4922
|
+
if (!stuck) return false;
|
|
4923
|
+
if (LEVEL_RANK2[level] > LEVEL_RANK2[stuck.level]) return false;
|
|
4924
|
+
const delta = tokens - stuck.tokens;
|
|
4925
|
+
return delta < _AutoCompactionMiddleware.NOOP_RETRY_DELTA_TOKENS;
|
|
4926
|
+
}
|
|
4927
|
+
recordAttempt(level, tokens, report) {
|
|
4928
|
+
const reduced = report.before > report.after;
|
|
4929
|
+
const repaired = !!report.repaired;
|
|
4930
|
+
if (reduced || repaired) {
|
|
4931
|
+
this.lastNoopAttempt = null;
|
|
4932
|
+
} else {
|
|
4933
|
+
this.lastNoopAttempt = { level, tokens };
|
|
4934
|
+
}
|
|
4935
|
+
}
|
|
4875
4936
|
async compact(ctx, aggressive, pressure) {
|
|
4876
4937
|
try {
|
|
4877
4938
|
const report = await this.compactor.compact(ctx, { aggressive });
|
|
4939
|
+
this.recordAttempt(pressure.level, pressure.tokens, report);
|
|
4878
4940
|
this.events?.emit("compaction.fired", {
|
|
4879
4941
|
level: pressure.level,
|
|
4880
4942
|
tokens: pressure.tokens,
|