@wrongstack/core 0.3.1 → 0.3.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/{compactor-BUU6Zm_3.d.ts → compactor-DpJBI1YH.d.ts} +7 -1
- package/dist/{config-CKLYPkCi.d.ts → config-D2qvAxVd.d.ts} +38 -1
- package/dist/coordination/index.d.ts +3 -3
- package/dist/coordination/index.js +283 -244
- package/dist/coordination/index.js.map +1 -1
- package/dist/defaults/index.d.ts +7 -7
- package/dist/defaults/index.js +803 -524
- package/dist/defaults/index.js.map +1 -1
- package/dist/{events-CNB9PALO.d.ts → events-BHIQs4o1.d.ts} +7 -0
- package/dist/execution/index.d.ts +10 -7
- package/dist/execution/index.js +166 -18
- package/dist/execution/index.js.map +1 -1
- package/dist/extension/index.d.ts +3 -3
- package/dist/extension/index.js +14 -7
- package/dist/extension/index.js.map +1 -1
- package/dist/{index-BDb0cAMP.d.ts → index-hWNybrNZ.d.ts} +3 -5
- package/dist/index.d.ts +12 -12
- package/dist/index.js +629 -299
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/index.d.ts +5 -5
- package/dist/infrastructure/index.js +191 -20
- package/dist/infrastructure/index.js.map +1 -1
- package/dist/kernel/index.d.ts +4 -4
- package/dist/kernel/index.js.map +1 -1
- package/dist/{mcp-servers-DR35ojJZ.d.ts → mcp-servers-C2OopXOn.d.ts} +20 -4
- package/dist/observability/index.d.ts +1 -1
- package/dist/{path-resolver-Cl_q0u-R.d.ts → path-resolver--59rCou3.d.ts} +1 -1
- package/dist/{provider-runner-BXuADQqQ.d.ts → provider-runner-B39miKRw.d.ts} +1 -1
- package/dist/sdd/index.d.ts +1 -1
- package/dist/storage/index.d.ts +4 -3
- package/dist/storage/index.js +180 -13
- package/dist/storage/index.js.map +1 -1
- package/dist/{tool-executor-DKu4A6nB.d.ts → tool-executor-HsBLGRaA.d.ts} +2 -2
- package/dist/types/index.d.ts +7 -7
- package/dist/types/index.js +206 -9
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.d.ts +23 -2
- package/dist/utils/index.js +93 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { a0 as Context, h as ProviderError, u as Tool, D as ToolUseBlock, z as ToolResultBlock } from './context-IovtuTf8.js';
|
|
2
|
-
import {
|
|
2
|
+
import { a as Compactor, C as CompactReport } from './compactor-DpJBI1YH.js';
|
|
3
3
|
import { c as RecoveryDecision, E as ErrorHandler, R as RetryPolicy } from './skill-C_7znCIC.js';
|
|
4
4
|
import { M as ModelsRegistry } from './models-registry-Y2xbog0E.js';
|
|
5
|
-
import { k as ToolExecutorOptions, l as ToolExecutorStrategy, m as ToolBatchResult } from './index-
|
|
5
|
+
import { k as ToolExecutorOptions, l as ToolExecutorStrategy, m as ToolBatchResult } from './index-hWNybrNZ.js';
|
|
6
6
|
|
|
7
7
|
interface CompactorOptions {
|
|
8
8
|
preserveK?: number;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
export { A as AgentError, C as Capabilities, a as ConfigError, b as ContentBlock, E as ErrorCode, c as ErrorSeverity, d as ErrorSubsystem, I as ImageBlock, J as JSONSchema, M as Message, e as MessageRole, P as Permission, f as PluginError, g as Provider, h as ProviderError, i as ProviderErrorBody, R as Request, j as Response, k as ResumedSession, S as SessionData, l as SessionError, m as SessionEvent, n as SessionMetadata, o as SessionStore, p as SessionSummary, q as SessionWriter, r as StopReason, s as StreamEvent, T as TextBlock, t as ThinkingBlock, u as Tool, v as ToolCallContext, w as ToolError, x as ToolFinalEvent, y as ToolProgressEvent, z as ToolResultBlock, B as ToolStreamEvent, D as ToolUseBlock, U as Usage, W as WrongStackError, F as asBlocks, G as asText, H as isAgentError, K as isConfigError, L as isImageBlock, N as isPluginError, O as isSessionError, Q as isTextBlock, V as isThinkingBlock, X as isToolError, Y as isToolResultBlock, Z as isToolUseBlock, _ as isWrongStackError, $ as toWrongStackError } from '../context-IovtuTf8.js';
|
|
2
|
-
export { P as ProviderRunner, R as RunProviderOptions } from '../provider-runner-
|
|
3
|
-
export { C as
|
|
2
|
+
export { P as ProviderRunner, R as RunProviderOptions } from '../provider-runner-B39miKRw.js';
|
|
3
|
+
export { C as CONTEXT_WINDOW_MODES, a as Config, 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, M as MCPServerConfig, 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-D2qvAxVd.js';
|
|
4
|
+
export { C as CompactReport, a as Compactor } from '../compactor-DpJBI1YH.js';
|
|
4
5
|
export { P as PermissionDecision, a as PermissionPolicy, T as TrustPolicy } from '../secret-scrubber-CgG2tV2B.js';
|
|
5
6
|
export { A as AddAttachmentInput, a as Attachment, b as AttachmentKind, c as AttachmentMeta, d as AttachmentRef, e as AttachmentStore, D as DefaultSessionReader } from '../session-reader-CcPi4BQ8.js';
|
|
6
7
|
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-Cuy5afaQ.js';
|
|
7
8
|
export { D as DefaultLogger, a as DefaultLoggerOptions } from '../logger-BH6AE0W9.js';
|
|
8
|
-
export { D as DefaultPathResolver, a as DefaultTokenCounter } from '../path-resolver
|
|
9
|
+
export { D as DefaultPathResolver, a as DefaultTokenCounter } from '../path-resolver--59rCou3.js';
|
|
9
10
|
export { M as MemoryEntry, a as MemoryScope, b as MemoryStore } from '../memory-CEXuo7sz.js';
|
|
10
|
-
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-
|
|
11
|
+
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-HsBLGRaA.js';
|
|
11
12
|
export { S as SkillEntry, a as SkillLoader, b as SkillManifest } from '../skill-C_7znCIC.js';
|
|
12
13
|
export { B as BuildContext, M as ModelCapabilities, R as Renderer, S as SystemPromptBuilder } from '../system-prompt-Dk1qm8ey.js';
|
|
13
14
|
export { I as InputReader, P as PromptOption } from '../input-reader-E-ffP2ee.js';
|
|
14
|
-
export { M as MCPRegistryView, a as MetricsSinkView, P as Plugin, b as PluginAPI, c as PluginCapabilities, d as PluginDependency, e as PluginPipelines, f as ProviderFactory, g as ProviderRegistryView, S as SessionWriterView, h as SlashCommand, i as SlashCommandRegistryView, j as SystemPromptContributor, T as ToolRegistryView } from '../index-
|
|
15
|
+
export { M as MCPRegistryView, a as MetricsSinkView, P as Plugin, b as PluginAPI, c as PluginCapabilities, d as PluginDependency, e as PluginPipelines, f as ProviderFactory, g as ProviderRegistryView, S as SessionWriterView, h as SlashCommand, i as SlashCommandRegistryView, j as SystemPromptContributor, T as ToolRegistryView } from '../index-hWNybrNZ.js';
|
|
15
16
|
export { D as DefaultModelsRegistry, a as DefaultModelsRegistryOptions, c as classifyFamily } from '../models-registry-DqzwpBQy.js';
|
|
16
17
|
export { D as DEFAULT_MODES, M as Mode, a as ModeConfig, b as ModeManifest, c as ModeStore } from '../mode-CV077NjV.js';
|
|
17
18
|
export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-C3DUGjSb.js';
|
|
18
19
|
export { C as CoordinatorEvents, a as CoordinatorStatus, D as DoneCondition, M as MultiAgentConfig, b as MultiAgentCoordinator, S as SpawnResult, c as SubagentConfig, d as SubagentContext, e as SubagentError, f as SubagentErrorKind, g as SubagentRunContext, h as SubagentRunOutcome, i as SubagentRunner, T as TaskDelegation, j as TaskResult, k as TaskSpec } from '../multi-agent-B9a6sflH.js';
|
|
19
20
|
export { C as CriticalPathResult, D as DEFAULT_SPEC_TEMPLATE, S as SpecAnalysis, a as SpecApiEndpoint, b as SpecRequirement, c as SpecSection, d as SpecSectionType, e as SpecStatus, f as SpecTemplate, g as SpecValidationResult, h as Specification, T as TaskAssignment, i as TaskDependency, j as TaskEdge, k as TaskFilter, l as TaskGraph, m as TaskNode, n as TaskPriority, o as TaskProgress, p as TaskSort, q as TaskStatus, r as TaskType, s as computeTaskProgress, t as findCriticalPath, u as topologicalSort } from '../task-graph-BITvWt4t.js';
|
|
20
21
|
export { A as AggregateHealth, H as HealthCheck, a as HealthCheckResult, b as HealthRegistry, c as HealthStatus, M as MetricLabels, d as MetricSeries, e as MetricsSink, f as MetricsSnapshot, S as Span, T as Tracer } from '../observability-BhnVLBLS.js';
|
|
21
|
-
import '../events-
|
|
22
|
+
import '../events-BHIQs4o1.js';
|
|
22
23
|
import '../logger-BMQgxvdy.js';
|
|
23
24
|
import '../models-registry-Y2xbog0E.js';
|
|
24
25
|
import '../secret-vault-DoISxaKO.js';
|
|
25
26
|
import '../path-resolver-CPRj4bFY.js';
|
|
26
|
-
import '../compactor-BUU6Zm_3.js';
|
package/dist/types/index.js
CHANGED
|
@@ -682,6 +682,98 @@ function estimateTextTokens(text) {
|
|
|
682
682
|
return RoughTokenEstimate(text);
|
|
683
683
|
}
|
|
684
684
|
|
|
685
|
+
// src/utils/message-invariants.ts
|
|
686
|
+
function repairToolUseAdjacency(messages) {
|
|
687
|
+
const removedToolUses = [];
|
|
688
|
+
const removedToolResults = [];
|
|
689
|
+
let removedMessages = 0;
|
|
690
|
+
let changed = false;
|
|
691
|
+
const out = [];
|
|
692
|
+
for (let i = 0; i < messages.length; i++) {
|
|
693
|
+
const original = messages[i];
|
|
694
|
+
let msg = original;
|
|
695
|
+
if (hasToolUse(msg)) {
|
|
696
|
+
const nextIds = toolResultIds(messages[i + 1]);
|
|
697
|
+
const filtered = mapContent(msg, (blocks) => {
|
|
698
|
+
const next = [];
|
|
699
|
+
for (const block of blocks) {
|
|
700
|
+
if (block.type === "tool_use" && !nextIds.has(block.id)) {
|
|
701
|
+
removedToolUses.push(block.id);
|
|
702
|
+
changed = true;
|
|
703
|
+
continue;
|
|
704
|
+
}
|
|
705
|
+
next.push(block);
|
|
706
|
+
}
|
|
707
|
+
return next;
|
|
708
|
+
});
|
|
709
|
+
msg = filtered ?? msg;
|
|
710
|
+
}
|
|
711
|
+
if (hasToolResult(msg)) {
|
|
712
|
+
const allowed = toolUseIds(out[out.length - 1]);
|
|
713
|
+
const filtered = mapContent(msg, (blocks) => {
|
|
714
|
+
const next = [];
|
|
715
|
+
for (const block of blocks) {
|
|
716
|
+
if (block.type === "tool_result" && !allowed.has(block.tool_use_id)) {
|
|
717
|
+
removedToolResults.push(block.tool_use_id);
|
|
718
|
+
changed = true;
|
|
719
|
+
continue;
|
|
720
|
+
}
|
|
721
|
+
next.push(block);
|
|
722
|
+
}
|
|
723
|
+
return next;
|
|
724
|
+
});
|
|
725
|
+
msg = filtered ?? msg;
|
|
726
|
+
}
|
|
727
|
+
if (isEmptyMessage(msg)) {
|
|
728
|
+
removedMessages++;
|
|
729
|
+
changed = true;
|
|
730
|
+
continue;
|
|
731
|
+
}
|
|
732
|
+
out.push(msg);
|
|
733
|
+
}
|
|
734
|
+
return {
|
|
735
|
+
messages: changed ? out : messages,
|
|
736
|
+
report: { changed, removedToolUses, removedToolResults, removedMessages }
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
function hasToolUse(msg) {
|
|
740
|
+
return contentBlocks(msg).some((b) => b.type === "tool_use");
|
|
741
|
+
}
|
|
742
|
+
function hasToolResult(msg) {
|
|
743
|
+
return contentBlocks(msg).some((b) => b.type === "tool_result");
|
|
744
|
+
}
|
|
745
|
+
function toolUseIds(msg) {
|
|
746
|
+
const ids = /* @__PURE__ */ new Set();
|
|
747
|
+
if (!msg || msg.role !== "assistant") return ids;
|
|
748
|
+
for (const block of contentBlocks(msg)) {
|
|
749
|
+
if (block.type === "tool_use") ids.add(block.id);
|
|
750
|
+
}
|
|
751
|
+
return ids;
|
|
752
|
+
}
|
|
753
|
+
function toolResultIds(msg) {
|
|
754
|
+
const ids = /* @__PURE__ */ new Set();
|
|
755
|
+
if (!msg || msg.role !== "user") return ids;
|
|
756
|
+
for (const block of contentBlocks(msg)) {
|
|
757
|
+
if (block.type === "tool_result") ids.add(block.tool_use_id);
|
|
758
|
+
}
|
|
759
|
+
return ids;
|
|
760
|
+
}
|
|
761
|
+
function contentBlocks(msg) {
|
|
762
|
+
return msg && Array.isArray(msg.content) ? msg.content : [];
|
|
763
|
+
}
|
|
764
|
+
function mapContent(msg, fn) {
|
|
765
|
+
if (!Array.isArray(msg.content)) return msg;
|
|
766
|
+
const next = fn(msg.content);
|
|
767
|
+
if (next.length === msg.content.length && next.every((b, idx) => b === msg.content[idx])) {
|
|
768
|
+
return msg;
|
|
769
|
+
}
|
|
770
|
+
return { ...msg, content: next };
|
|
771
|
+
}
|
|
772
|
+
function isEmptyMessage(msg) {
|
|
773
|
+
if (typeof msg.content === "string") return msg.content.trim().length === 0;
|
|
774
|
+
return msg.content.length === 0;
|
|
775
|
+
}
|
|
776
|
+
|
|
685
777
|
// src/execution/compactor.ts
|
|
686
778
|
var HybridCompactor = class {
|
|
687
779
|
preserveK;
|
|
@@ -695,20 +787,36 @@ var HybridCompactor = class {
|
|
|
695
787
|
async compact(ctx, opts = {}) {
|
|
696
788
|
const beforeTokens = this.estimateMessages(ctx.messages);
|
|
697
789
|
const reductions = [];
|
|
698
|
-
const
|
|
790
|
+
const policy = readContextWindowPolicy(ctx);
|
|
791
|
+
const preserveK = policy?.preserveK ?? this.preserveK;
|
|
792
|
+
const eliseThreshold = policy?.eliseThreshold ?? this.eliseThreshold;
|
|
793
|
+
const phase1Saved = this.eliseOldToolResults(ctx, preserveK, eliseThreshold);
|
|
699
794
|
if (phase1Saved > 0) reductions.push({ phase: "elision", saved: phase1Saved });
|
|
700
795
|
if (opts.aggressive) {
|
|
701
|
-
const phase2Saved = this.collapseAncientTurns(ctx);
|
|
796
|
+
const phase2Saved = this.collapseAncientTurns(ctx, preserveK);
|
|
702
797
|
if (phase2Saved > 0) reductions.push({ phase: "summary", saved: phase2Saved });
|
|
703
798
|
}
|
|
799
|
+
const repaired = repairToolUseAdjacency(ctx.messages);
|
|
800
|
+
if (repaired.report.changed) {
|
|
801
|
+
ctx.state.replaceMessages(repaired.messages);
|
|
802
|
+
}
|
|
704
803
|
const afterTokens = this.estimateMessages(ctx.messages);
|
|
705
|
-
return {
|
|
804
|
+
return {
|
|
805
|
+
before: beforeTokens,
|
|
806
|
+
after: afterTokens,
|
|
807
|
+
reductions,
|
|
808
|
+
repaired: repaired.report.changed ? {
|
|
809
|
+
removedToolUses: repaired.report.removedToolUses,
|
|
810
|
+
removedToolResults: repaired.report.removedToolResults,
|
|
811
|
+
removedMessages: repaired.report.removedMessages
|
|
812
|
+
} : void 0
|
|
813
|
+
};
|
|
706
814
|
}
|
|
707
|
-
eliseOldToolResults(ctx) {
|
|
815
|
+
eliseOldToolResults(ctx, preserveK = this.preserveK, eliseThreshold = this.eliseThreshold) {
|
|
708
816
|
const messages = ctx.messages;
|
|
709
817
|
let pairCount = 0;
|
|
710
818
|
let preserveStart = messages.length;
|
|
711
|
-
for (let i = messages.length - 1; i >= 0 && pairCount <
|
|
819
|
+
for (let i = messages.length - 1; i >= 0 && pairCount < preserveK; i--) {
|
|
712
820
|
const m = messages[i];
|
|
713
821
|
if (!m) continue;
|
|
714
822
|
if (m.role === "user" || m.role === "assistant") {
|
|
@@ -732,7 +840,7 @@ var HybridCompactor = class {
|
|
|
732
840
|
const newContent = msg.content.map((b) => {
|
|
733
841
|
if (b.type !== "tool_result") return b;
|
|
734
842
|
const tokens = estimateToolResultTokens(b.content);
|
|
735
|
-
if (tokens <
|
|
843
|
+
if (tokens < eliseThreshold) return b;
|
|
736
844
|
saved += tokens;
|
|
737
845
|
const elided = {
|
|
738
846
|
type: "tool_result",
|
|
@@ -752,9 +860,9 @@ var HybridCompactor = class {
|
|
|
752
860
|
if (changed) ctx.state.replaceMessages(nextMessages);
|
|
753
861
|
return saved;
|
|
754
862
|
}
|
|
755
|
-
collapseAncientTurns(ctx) {
|
|
863
|
+
collapseAncientTurns(ctx, preserveK = this.preserveK) {
|
|
756
864
|
const messages = ctx.messages;
|
|
757
|
-
const cutTarget = Math.max(0, messages.length -
|
|
865
|
+
const cutTarget = Math.max(0, messages.length - preserveK * 2);
|
|
758
866
|
if (cutTarget <= 0) return 0;
|
|
759
867
|
let boundary = -1;
|
|
760
868
|
for (let i = cutTarget; i < messages.length; i++) {
|
|
@@ -795,6 +903,15 @@ var HybridCompactor = class {
|
|
|
795
903
|
return total;
|
|
796
904
|
}
|
|
797
905
|
};
|
|
906
|
+
function readContextWindowPolicy(ctx) {
|
|
907
|
+
const policy = ctx.meta?.["contextWindowPolicy"];
|
|
908
|
+
if (!policy || typeof policy !== "object") return null;
|
|
909
|
+
const candidate = policy;
|
|
910
|
+
if (typeof candidate.preserveK !== "number" || typeof candidate.eliseThreshold !== "number") {
|
|
911
|
+
return null;
|
|
912
|
+
}
|
|
913
|
+
return candidate;
|
|
914
|
+
}
|
|
798
915
|
function hasTextContent(m) {
|
|
799
916
|
if (typeof m.content === "string") return m.content.trim().length > 0;
|
|
800
917
|
return m.content.some((b) => b.type === "text" && b.text.trim().length > 0);
|
|
@@ -1457,6 +1574,85 @@ When refactoring code:
|
|
|
1457
1574
|
}
|
|
1458
1575
|
];
|
|
1459
1576
|
|
|
1577
|
+
// src/types/context-window.ts
|
|
1578
|
+
var DEFAULT_CONTEXT_WINDOW_MODE_ID = "balanced";
|
|
1579
|
+
var CONTEXT_WINDOW_MODES = Object.freeze([
|
|
1580
|
+
{
|
|
1581
|
+
id: "balanced",
|
|
1582
|
+
name: "Balanced",
|
|
1583
|
+
description: "Default rolling compaction: recent work stays verbatim, old tool output is trimmed.",
|
|
1584
|
+
thresholds: { warn: 0.6, soft: 0.75, hard: 0.9 },
|
|
1585
|
+
aggressiveOn: "soft",
|
|
1586
|
+
preserveK: 10,
|
|
1587
|
+
eliseThreshold: 2e3,
|
|
1588
|
+
targetLoad: 0.65
|
|
1589
|
+
},
|
|
1590
|
+
{
|
|
1591
|
+
id: "frugal",
|
|
1592
|
+
name: "Frugal",
|
|
1593
|
+
description: "Token-saver mode: compacts early and keeps a tighter verbatim tail.",
|
|
1594
|
+
thresholds: { warn: 0.45, soft: 0.6, hard: 0.75 },
|
|
1595
|
+
aggressiveOn: "warn",
|
|
1596
|
+
preserveK: 6,
|
|
1597
|
+
eliseThreshold: 700,
|
|
1598
|
+
targetLoad: 0.5
|
|
1599
|
+
},
|
|
1600
|
+
{
|
|
1601
|
+
id: "deep",
|
|
1602
|
+
name: "Deep",
|
|
1603
|
+
description: "Long-reasoning mode: delays compaction and keeps more recent turns intact.",
|
|
1604
|
+
thresholds: { warn: 0.72, soft: 0.86, hard: 0.96 },
|
|
1605
|
+
aggressiveOn: "hard",
|
|
1606
|
+
preserveK: 18,
|
|
1607
|
+
eliseThreshold: 5e3,
|
|
1608
|
+
targetLoad: 0.78
|
|
1609
|
+
},
|
|
1610
|
+
{
|
|
1611
|
+
id: "archival",
|
|
1612
|
+
name: "Archival",
|
|
1613
|
+
description: "Decision-preserving mode: compacts steadily while keeping summaries prominent.",
|
|
1614
|
+
thresholds: { warn: 0.55, soft: 0.7, hard: 0.84 },
|
|
1615
|
+
aggressiveOn: "soft",
|
|
1616
|
+
preserveK: 8,
|
|
1617
|
+
eliseThreshold: 1200,
|
|
1618
|
+
targetLoad: 0.58
|
|
1619
|
+
}
|
|
1620
|
+
]);
|
|
1621
|
+
function listContextWindowModes() {
|
|
1622
|
+
return CONTEXT_WINDOW_MODES.map((m) => ({ ...m, thresholds: { ...m.thresholds } }));
|
|
1623
|
+
}
|
|
1624
|
+
function getContextWindowMode(id) {
|
|
1625
|
+
if (!id) return null;
|
|
1626
|
+
const mode = CONTEXT_WINDOW_MODES.find((m) => m.id === id);
|
|
1627
|
+
return mode ? { ...mode, thresholds: { ...mode.thresholds } } : null;
|
|
1628
|
+
}
|
|
1629
|
+
function isContextWindowModeId(id) {
|
|
1630
|
+
return CONTEXT_WINDOW_MODES.some((m) => m.id === id);
|
|
1631
|
+
}
|
|
1632
|
+
function resolveContextWindowPolicy(config = {}, overrideMode) {
|
|
1633
|
+
const requested = overrideMode ?? config.mode ?? DEFAULT_CONTEXT_WINDOW_MODE_ID;
|
|
1634
|
+
const mode = getContextWindowMode(requested) ?? getContextWindowMode(DEFAULT_CONTEXT_WINDOW_MODE_ID);
|
|
1635
|
+
if (mode.id !== DEFAULT_CONTEXT_WINDOW_MODE_ID) {
|
|
1636
|
+
return mode;
|
|
1637
|
+
}
|
|
1638
|
+
return {
|
|
1639
|
+
...mode,
|
|
1640
|
+
thresholds: {
|
|
1641
|
+
warn: config.warnThreshold ?? mode.thresholds.warn,
|
|
1642
|
+
soft: config.softThreshold ?? mode.thresholds.soft,
|
|
1643
|
+
hard: config.hardThreshold ?? mode.thresholds.hard
|
|
1644
|
+
},
|
|
1645
|
+
preserveK: config.preserveK ?? mode.preserveK,
|
|
1646
|
+
eliseThreshold: config.eliseThreshold ?? mode.eliseThreshold
|
|
1647
|
+
};
|
|
1648
|
+
}
|
|
1649
|
+
function formatContextWindowModeList(activeId) {
|
|
1650
|
+
return CONTEXT_WINDOW_MODES.map((m) => {
|
|
1651
|
+
const marker = m.id === activeId ? "*" : " ";
|
|
1652
|
+
return `${marker} ${m.id.padEnd(9)} ${m.name} - ${m.description}`;
|
|
1653
|
+
}).join("\n");
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1460
1656
|
// src/coordination/in-memory-transport.ts
|
|
1461
1657
|
var InMemoryBridgeTransport = class {
|
|
1462
1658
|
subs = /* @__PURE__ */ new Map();
|
|
@@ -1576,6 +1772,7 @@ var InMemoryAgentBridge = class {
|
|
|
1576
1772
|
this.stopped = true;
|
|
1577
1773
|
for (const [, p] of this.pendingRequests) {
|
|
1578
1774
|
clearTimeout(p.timer);
|
|
1775
|
+
p.reject(new Error("Bridge stopped"));
|
|
1579
1776
|
}
|
|
1580
1777
|
this.pendingRequests.clear();
|
|
1581
1778
|
this.inflightGuards.clear();
|
|
@@ -2264,6 +2461,6 @@ function renderPlainText(meta, events) {
|
|
|
2264
2461
|
return lines.join("\n");
|
|
2265
2462
|
}
|
|
2266
2463
|
|
|
2267
|
-
export { AgentError, ConfigError, DEFAULT_MODES, DEFAULT_RECOVERY_STRATEGIES, DEFAULT_SPEC_TEMPLATE, DefaultErrorHandler, DefaultLogger, DefaultModelsRegistry, DefaultPathResolver, DefaultRetryPolicy, DefaultSecretScrubber, DefaultSecretVault, DefaultSessionReader, DefaultTokenCounter, HybridCompactor, InMemoryAgentBridge, InMemoryBridgeTransport, PluginError, ProviderError, SessionError, ToolError, ToolExecutor, WrongStackError, asBlocks, asText, buildRecoveryStrategies, classifyFamily, computeTaskProgress, createMessage, decryptConfigSecrets, encryptConfigSecrets, findCriticalPath, isAgentError, isConfigError, isImageBlock, isPluginError, isSessionError, isTextBlock, isThinkingBlock, isToolError, isToolResultBlock, isToolUseBlock, isWrongStackError, migratePlaintextSecrets, rewriteConfigEncrypted, toWrongStackError, topologicalSort };
|
|
2464
|
+
export { AgentError, CONTEXT_WINDOW_MODES, ConfigError, DEFAULT_CONTEXT_WINDOW_MODE_ID, DEFAULT_MODES, DEFAULT_RECOVERY_STRATEGIES, DEFAULT_SPEC_TEMPLATE, DefaultErrorHandler, DefaultLogger, DefaultModelsRegistry, DefaultPathResolver, DefaultRetryPolicy, DefaultSecretScrubber, DefaultSecretVault, DefaultSessionReader, DefaultTokenCounter, HybridCompactor, InMemoryAgentBridge, InMemoryBridgeTransport, PluginError, ProviderError, SessionError, ToolError, ToolExecutor, WrongStackError, asBlocks, asText, buildRecoveryStrategies, classifyFamily, computeTaskProgress, createMessage, decryptConfigSecrets, encryptConfigSecrets, findCriticalPath, formatContextWindowModeList, getContextWindowMode, isAgentError, isConfigError, isContextWindowModeId, isImageBlock, isPluginError, isSessionError, isTextBlock, isThinkingBlock, isToolError, isToolResultBlock, isToolUseBlock, isWrongStackError, listContextWindowModes, migratePlaintextSecrets, resolveContextWindowPolicy, rewriteConfigEncrypted, toWrongStackError, topologicalSort };
|
|
2268
2465
|
//# sourceMappingURL=index.js.map
|
|
2269
2466
|
//# sourceMappingURL=index.js.map
|