@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,9 +1,9 @@
|
|
|
1
|
-
export { A as AfterIterationHook, a as AfterRunHook, b as AfterToolExecutionHook, d as AgentExtension, B as BeforeIterationHook, h as BeforeRunHook, i as BeforeToolExecutionHook, E as ExtensionRegistry, O as OnErrorHook, s as ProviderRunnerFn, t as ProviderRunnerWrapper } from '../index-
|
|
1
|
+
export { A as AfterIterationHook, a as AfterRunHook, b as AfterToolExecutionHook, d as AgentExtension, B as BeforeIterationHook, h as BeforeRunHook, i as BeforeToolExecutionHook, E as ExtensionRegistry, O as OnErrorHook, s as ProviderRunnerFn, t as ProviderRunnerWrapper } from '../index-oYZeWsuJ.js';
|
|
2
2
|
import '../context-z2x5gv_V.js';
|
|
3
3
|
import '../logger-DDd5C--Z.js';
|
|
4
4
|
import '../system-prompt-CWA6ml-d.js';
|
|
5
5
|
import '../observability-BhnVLBLS.js';
|
|
6
6
|
import '../events-DyhxkstG.js';
|
|
7
|
-
import '../secret-scrubber-
|
|
7
|
+
import '../secret-scrubber-CyE1-EMG.js';
|
|
8
8
|
import '../config-Bi4Q0fnz.js';
|
|
9
9
|
import '../models-registry-BcYJDKLm.js';
|
|
@@ -3,7 +3,7 @@ import { a as Logger } from './logger-DDd5C--Z.js';
|
|
|
3
3
|
import { e as Renderer, a as BuildContext, C as Container, P as Pipeline, R as ReadonlyPipeline } from './system-prompt-CWA6ml-d.js';
|
|
4
4
|
import { T as Tracer } from './observability-BhnVLBLS.js';
|
|
5
5
|
import { E as EventBus, c as EventName, L as Listener } from './events-DyhxkstG.js';
|
|
6
|
-
import { a as PermissionPolicy, S as SecretScrubber } from './secret-scrubber-
|
|
6
|
+
import { a as PermissionPolicy, S as SecretScrubber } from './secret-scrubber-CyE1-EMG.js';
|
|
7
7
|
import { l as ProviderConfig, a as Config } from './config-Bi4Q0fnz.js';
|
|
8
8
|
import { W as WireFamily } from './models-registry-BcYJDKLm.js';
|
|
9
9
|
|
package/dist/index.d.ts
CHANGED
|
@@ -9,22 +9,22 @@ export { P as ProviderRunner, R as RunProviderOptions } from './provider-runner-
|
|
|
9
9
|
import { M as MCPServerConfig, a as Config } from './config-Bi4Q0fnz.js';
|
|
10
10
|
export { C as CONTEXT_WINDOW_MODES, b as ConfigLoader, c as ConfigStore, d as ContextConfig, e as ContextWindowAggressiveOn, f as ContextWindowConfigLike, g as ContextWindowMode, h as ContextWindowModeId, i as ContextWindowPolicy, j as ContextWindowThresholds, D as DEFAULT_CONTEXT_WINDOW_MODE_ID, F as FeaturesConfig, L as LogConfig, P as PluginConfig, k as ProviderApiKey, l as ProviderConfig, T as ToolsConfig, m as formatContextWindowModeList, n as getContextWindowMode, o as isContextWindowModeId, p as listContextWindowModes, r as resolveContextWindowPolicy } from './config-Bi4Q0fnz.js';
|
|
11
11
|
export { C as CompactReport, a as Compactor } from './compactor-Mw7-rNyb.js';
|
|
12
|
-
export { P as PermissionDecision, a as PermissionPolicy, S as SecretScrubber, T as TrustPolicy } from './secret-scrubber-
|
|
12
|
+
export { P as PermissionDecision, a as PermissionPolicy, S as SecretScrubber, T as TrustPolicy } from './secret-scrubber-CyE1-EMG.js';
|
|
13
13
|
export { C as CheckpointInfo, R as RewindResult, a as RewindResultExtended, S as SessionRewinder } from './session-rewinder-C9HnMkhP.js';
|
|
14
14
|
import { e as AttachmentStore, d as AttachmentRef, A as AddAttachmentInput } from './session-reader-DsadjyF9.js';
|
|
15
15
|
export { a as Attachment, b as AttachmentKind, c as AttachmentMeta, D as DefaultSessionReader } from './session-reader-DsadjyF9.js';
|
|
16
16
|
export { D as DEFAULT_CONTEXT_CONFIG, a as DEFAULT_TOOLS_CONFIG } from './default-config-DvRSTELf.js';
|
|
17
|
-
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-
|
|
17
|
+
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';
|
|
18
18
|
export { D as DefaultLogger, a as DefaultLoggerOptions } from './logger-bOzkF5LL.js';
|
|
19
19
|
export { D as DefaultPathResolver, a as DefaultTokenCounter } from './path-resolver-1CIYbH2Q.js';
|
|
20
20
|
import { b as MemoryStore } from './memory-CEXuo7sz.js';
|
|
21
21
|
export { M as MemoryEntry, a as MemoryScope } from './memory-CEXuo7sz.js';
|
|
22
|
-
export { C as CompactorOptions, D as DEFAULT_RECOVERY_STRATEGIES, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, R as RecoveryStrategy, T as ToolExecutor, c as buildRecoveryStrategies } from './tool-executor-
|
|
22
|
+
export { C as CompactorOptions, D as DEFAULT_RECOVERY_STRATEGIES, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, R as RecoveryStrategy, T as ToolExecutor, c as buildRecoveryStrategies } from './tool-executor-QwfWnQZ8.js';
|
|
23
23
|
import { a as SkillLoader } from './skill-CxuWrsKK.js';
|
|
24
24
|
export { S as SkillEntry, b as SkillManifest } from './skill-CxuWrsKK.js';
|
|
25
25
|
export { I as InputReader, P as PromptOption } from './input-reader-E-ffP2ee.js';
|
|
26
|
-
import { u as SlashCommand, w as SystemPromptContributor, k as PluginAPI, n as PluginPipelines, C as ToolRegistryView, r as ProviderRegistryView, M as MCPRegistryView, v as SlashCommandRegistryView, E as ExtensionRegistry, S as SessionWriterView, j as MetricsSinkView, z as ToolRegistry, q as ProviderRegistry, P as Plugin } from './index-
|
|
27
|
-
export { A as AfterIterationHook, a as AfterRunHook, b as AfterToolExecutionHook, c as Agent, d as AgentExtension, e as AgentInit, f as AgentInput, g as AgentPipelines, B as BeforeIterationHook, h as BeforeRunHook, i as BeforeToolExecutionHook, D as DEFAULT_MAX_ITERATIONS, O as OnErrorHook, l as PluginCapabilities, m as PluginDependency, p as ProviderFactory, t as ProviderRunnerWrapper, R as RunResult, F as ToolWrapper, U as UserInputPayload, G as createDefaultPipelines } from './index-
|
|
26
|
+
import { u as SlashCommand, w as SystemPromptContributor, k as PluginAPI, n as PluginPipelines, C as ToolRegistryView, r as ProviderRegistryView, M as MCPRegistryView, v as SlashCommandRegistryView, E as ExtensionRegistry, S as SessionWriterView, j as MetricsSinkView, z as ToolRegistry, q as ProviderRegistry, P as Plugin } from './index-oYZeWsuJ.js';
|
|
27
|
+
export { A as AfterIterationHook, a as AfterRunHook, b as AfterToolExecutionHook, c as Agent, d as AgentExtension, e as AgentInit, f as AgentInput, g as AgentPipelines, B as BeforeIterationHook, h as BeforeRunHook, i as BeforeToolExecutionHook, D as DEFAULT_MAX_ITERATIONS, O as OnErrorHook, l as PluginCapabilities, m as PluginDependency, p as ProviderFactory, t as ProviderRunnerWrapper, R as RunResult, F as ToolWrapper, U as UserInputPayload, G as createDefaultPipelines } from './index-oYZeWsuJ.js';
|
|
28
28
|
export { D as DefaultModelsRegistry, a as DefaultModelsRegistryOptions, c as classifyFamily } from './models-registry-OG_30xqZ.js';
|
|
29
29
|
import { c as ModeStore } from './mode-CV077NjV.js';
|
|
30
30
|
export { D as DEFAULT_MODES, M as Mode, a as ModeConfig, b as ModeManifest } from './mode-CV077NjV.js';
|
|
@@ -36,12 +36,12 @@ export { AtomicWriteOptions, BuildChildEnvOptions, CompileFail, CompileResult, M
|
|
|
36
36
|
export { W as WstackPathOptions, a as WstackPaths, p as projectHash, r as resolveWstackPaths } from './wstack-paths-gCrJ631C.js';
|
|
37
37
|
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';
|
|
38
38
|
export { D as DirectorStateCheckpoint, a as DirectorStateSnapshot, b as DirectorSubagentState, c as DirectorTaskState, l as loadDirectorState } from './director-state-BmYi3DGA.js';
|
|
39
|
-
export { A as AutoApprovePermissionPolicy, D as DefaultPermissionPolicy, P as PermissionPolicyOptions } from './permission-policy-
|
|
39
|
+
export { A as AutoApprovePermissionPolicy, D as DefaultPermissionPolicy, P as PermissionPolicyOptions } from './permission-policy-BBa1M1xc.js';
|
|
40
40
|
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';
|
|
41
41
|
export { DefaultProviderRunner } from './defaults/index.js';
|
|
42
|
-
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, 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-
|
|
43
|
-
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-
|
|
44
|
-
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-
|
|
42
|
+
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, 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';
|
|
43
|
+
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';
|
|
44
|
+
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';
|
|
45
45
|
export { DefaultModeStore, LLMSelector, LLMSelectorOptions, ModeLoaderOptions, loadProjectModes, loadUserModes } from './models/index.js';
|
|
46
46
|
export { AISpecBuilder, AISpecBuilderOptions, AISpecPhase, AISpecSession, AutoExecutor, AutoExecutorOptions, BottleneckTask, CollectedAnswer, CriticalPathAnalysis, DefaultTaskStore, ExecutionSummary, GeneratedTask, SPEC_TEMPLATES, SddParallelRun, SddParallelRunOptions, SddProgress, SddTaskDecomposer, SddTaskDecomposerOptions, SpecDiff, SpecDrivenDev, SpecDrivenDevOptions, SpecIndexEntry, SpecParser, SpecStore, SpecStoreOptions, SpecVersion, SpecVersioning, TaskBatch, TaskExecutionContext, TaskExecutionResult, TaskFlow, TaskFlowEventMap, TaskFlowEventName, TaskFlowExecutionContext, TaskFlowOptions, TaskFlowPhase, TaskGenerator, TaskGeneratorOptions, TaskGraphIndexEntry, TaskGraphStore, TaskGraphStoreOptions, TaskStore, TaskTracker, TaskTrackerOptions, TaskTransition, WaveResult, analyzeCriticalPath, createAutoExecutor, getTemplate, listTemplates, renderProgress, renderSpecAnalysis, renderTaskGraph, renderTaskList, templateToMarkdown } from './sdd/index.js';
|
|
47
47
|
export { DefaultHealthRegistry, InMemoryMetricsSink, MetricsServerHandle, MetricsServerOptions, NoopMetricsSink, NoopTracer, OTelTracer, OtlpMetricsExporterHandle, OtlpMetricsExporterOptions, OtlpTraceExporterHandle, OtlpTraceExporterOptions, PROMETHEUS_CONTENT_TYPE, buildOtlpMetricsRequest, buildOtlpTracesRequest, renderPrometheus, startMetricsServer, startOtlpMetricsExporter, startOtlpTraceExporter, wireMetricsToEvents } from './observability/index.js';
|
package/dist/index.js
CHANGED
|
@@ -6182,10 +6182,36 @@ var DefaultPermissionPolicy = class {
|
|
|
6182
6182
|
return void 0;
|
|
6183
6183
|
}
|
|
6184
6184
|
};
|
|
6185
|
-
var AutoApprovePermissionPolicy = class {
|
|
6185
|
+
var AutoApprovePermissionPolicy = class _AutoApprovePermissionPolicy {
|
|
6186
|
+
/**
|
|
6187
|
+
* Tools that are too dangerous to auto-approve even in a delegated
|
|
6188
|
+
* subagent context. Subagents run non-interactively under a director
|
|
6189
|
+
* and cannot answer prompts, but inherited authorization does not
|
|
6190
|
+
* imply blanket permission for destructive or privilege-escalating
|
|
6191
|
+
* operations. These tools remain at their declared `permission`
|
|
6192
|
+
* level so the leader must explicitly allow them per-spawn.
|
|
6193
|
+
*/
|
|
6194
|
+
static DENY = /* @__PURE__ */ new Set([
|
|
6195
|
+
"bash",
|
|
6196
|
+
// arbitrary shell — use exec for constrained shell
|
|
6197
|
+
"write",
|
|
6198
|
+
// arbitrary file write
|
|
6199
|
+
"scaffold",
|
|
6200
|
+
// arbitrary file generation outside project root
|
|
6201
|
+
"patch",
|
|
6202
|
+
// arbitrary diff application
|
|
6203
|
+
"install",
|
|
6204
|
+
// installs from arbitrary package sources
|
|
6205
|
+
"exec"
|
|
6206
|
+
// restricted shell but with arbitrary command args
|
|
6207
|
+
]);
|
|
6186
6208
|
async evaluate(tool) {
|
|
6187
|
-
if (tool.permission === "deny") {
|
|
6188
|
-
return {
|
|
6209
|
+
if (tool.permission === "deny" || _AutoApprovePermissionPolicy.DENY.has(tool.name)) {
|
|
6210
|
+
return {
|
|
6211
|
+
permission: "deny",
|
|
6212
|
+
source: "subagent_guard",
|
|
6213
|
+
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"
|
|
6214
|
+
};
|
|
6189
6215
|
}
|
|
6190
6216
|
return { permission: "auto", source: "yolo" };
|
|
6191
6217
|
}
|
|
@@ -7262,6 +7288,7 @@ Summarize the following message range:`;
|
|
|
7262
7288
|
};
|
|
7263
7289
|
|
|
7264
7290
|
// src/execution/auto-compaction-middleware.ts
|
|
7291
|
+
var LEVEL_RANK2 = { warn: 0, soft: 1, hard: 2 };
|
|
7265
7292
|
var AutoCompactionMiddleware = class _AutoCompactionMiddleware {
|
|
7266
7293
|
name = "AutoCompaction";
|
|
7267
7294
|
compactor;
|
|
@@ -7282,6 +7309,16 @@ var AutoCompactionMiddleware = class _AutoCompactionMiddleware {
|
|
|
7282
7309
|
* short conversations, causing premature compaction triggers.
|
|
7283
7310
|
*/
|
|
7284
7311
|
static OVERHEAD_FACTOR = 1.3;
|
|
7312
|
+
/**
|
|
7313
|
+
* Once a compaction attempt reduces nothing (preserveK protects everything,
|
|
7314
|
+
* no oversized tool_results remain to elide), retrying on every iteration
|
|
7315
|
+
* just spams `compaction.fired` events without making progress. We remember
|
|
7316
|
+
* the no-op and skip until either the pressure level escalates or context
|
|
7317
|
+
* has grown by at least this many tokens since the failed attempt.
|
|
7318
|
+
*/
|
|
7319
|
+
static NOOP_RETRY_DELTA_TOKENS = 2e3;
|
|
7320
|
+
/** Tracks the most recent no-op attempt so we can avoid re-firing per turn. */
|
|
7321
|
+
lastNoopAttempt = null;
|
|
7285
7322
|
/**
|
|
7286
7323
|
* @param compactor Compactor to use for compaction.
|
|
7287
7324
|
* @param maxContext Provider's max context window in tokens.
|
|
@@ -7323,19 +7360,44 @@ var AutoCompactionMiddleware = class _AutoCompactionMiddleware {
|
|
|
7323
7360
|
hard: this.hardThreshold
|
|
7324
7361
|
};
|
|
7325
7362
|
const aggressiveOn = policy?.aggressiveOn ?? this.aggressiveOn;
|
|
7326
|
-
|
|
7327
|
-
|
|
7328
|
-
|
|
7329
|
-
|
|
7330
|
-
} else if (load >= thresholds.warn) {
|
|
7331
|
-
await this.compact(ctx, aggressiveOn === "warn", { level: "warn", tokens, load });
|
|
7363
|
+
const level = load >= thresholds.hard ? "hard" : load >= thresholds.soft ? "soft" : load >= thresholds.warn ? "warn" : null;
|
|
7364
|
+
if (!level) {
|
|
7365
|
+
this.lastNoopAttempt = null;
|
|
7366
|
+
return next(ctx);
|
|
7332
7367
|
}
|
|
7368
|
+
if (this.shouldSkipNoopRetry(level, tokens)) {
|
|
7369
|
+
return next(ctx);
|
|
7370
|
+
}
|
|
7371
|
+
const aggressive = level === "hard" ? true : level === "soft" ? aggressiveOn !== "hard" : aggressiveOn === "warn";
|
|
7372
|
+
await this.compact(ctx, aggressive, { level, tokens, load });
|
|
7333
7373
|
return next(ctx);
|
|
7334
7374
|
};
|
|
7335
7375
|
}
|
|
7376
|
+
/**
|
|
7377
|
+
* Returns true when the previous compaction at the same or higher pressure
|
|
7378
|
+
* level reduced nothing and context has not grown materially since. Prevents
|
|
7379
|
+
* a stuck preserveK window from spamming compaction events every iteration.
|
|
7380
|
+
*/
|
|
7381
|
+
shouldSkipNoopRetry(level, tokens) {
|
|
7382
|
+
const stuck = this.lastNoopAttempt;
|
|
7383
|
+
if (!stuck) return false;
|
|
7384
|
+
if (LEVEL_RANK2[level] > LEVEL_RANK2[stuck.level]) return false;
|
|
7385
|
+
const delta = tokens - stuck.tokens;
|
|
7386
|
+
return delta < _AutoCompactionMiddleware.NOOP_RETRY_DELTA_TOKENS;
|
|
7387
|
+
}
|
|
7388
|
+
recordAttempt(level, tokens, report) {
|
|
7389
|
+
const reduced = report.before > report.after;
|
|
7390
|
+
const repaired = !!report.repaired;
|
|
7391
|
+
if (reduced || repaired) {
|
|
7392
|
+
this.lastNoopAttempt = null;
|
|
7393
|
+
} else {
|
|
7394
|
+
this.lastNoopAttempt = { level, tokens };
|
|
7395
|
+
}
|
|
7396
|
+
}
|
|
7336
7397
|
async compact(ctx, aggressive, pressure) {
|
|
7337
7398
|
try {
|
|
7338
7399
|
const report = await this.compactor.compact(ctx, { aggressive });
|
|
7400
|
+
this.recordAttempt(pressure.level, pressure.tokens, report);
|
|
7339
7401
|
this.events?.emit("compaction.fired", {
|
|
7340
7402
|
level: pressure.level,
|
|
7341
7403
|
tokens: pressure.tokens,
|