@wrongstack/core 0.6.7 → 0.7.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.
Files changed (56) hide show
  1. package/dist/{agent-bridge-BCVxmrOn.d.ts → agent-bridge-Bji75Iv9.d.ts} +1 -1
  2. package/dist/{compactor-BUJ8550X.d.ts → compactor-BFKGzKd5.d.ts} +1 -1
  3. package/dist/{config-BHkYGzUT.d.ts → config-BXAhlqJb.d.ts} +1 -1
  4. package/dist/{context-C8mBUzBv.d.ts → context-BwxhvyW8.d.ts} +75 -3
  5. package/dist/coordination/index.d.ts +42 -12
  6. package/dist/coordination/index.js +2573 -40
  7. package/dist/coordination/index.js.map +1 -1
  8. package/dist/default-config-DvRSTELf.d.ts +20 -0
  9. package/dist/defaults/index.d.ts +21 -20
  10. package/dist/defaults/index.js +2896 -243
  11. package/dist/defaults/index.js.map +1 -1
  12. package/dist/{director-state-BmYi3DGA.d.ts → director-state-BUB7JRUr.d.ts} +1 -1
  13. package/dist/{events-DounT6pP.d.ts → events-AjrvHJ9V.d.ts} +25 -1
  14. package/dist/execution/index.d.ts +42 -13
  15. package/dist/execution/index.js +2497 -40
  16. package/dist/execution/index.js.map +1 -1
  17. package/dist/extension/index.d.ts +6 -6
  18. package/dist/extension/index.js +3 -1
  19. package/dist/extension/index.js.map +1 -1
  20. package/dist/{index-DiIGZh5I.d.ts → index-B2WWETRP.d.ts} +6 -6
  21. package/dist/index.d.ts +36 -27
  22. package/dist/index.js +2863 -137
  23. package/dist/index.js.map +1 -1
  24. package/dist/infrastructure/index.d.ts +6 -6
  25. package/dist/infrastructure/index.js +12 -0
  26. package/dist/infrastructure/index.js.map +1 -1
  27. package/dist/kernel/index.d.ts +9 -9
  28. package/dist/kernel/index.js +20 -4
  29. package/dist/kernel/index.js.map +1 -1
  30. package/dist/{mcp-servers-CXFfDN_d.d.ts → mcp-servers-BDM2Leff.d.ts} +3 -3
  31. package/dist/models/index.d.ts +2 -2
  32. package/dist/{multi-agent-Iy8YUe3v.d.ts → multi-agent-DenFfUv5.d.ts} +11 -3
  33. package/dist/multi-agent-coordinator-DGUn-5Bb.d.ts +448 -0
  34. package/dist/{index-BlVITqm-.d.ts → null-fleet-bus-DJMbqYhL.d.ts} +105 -107
  35. package/dist/observability/index.d.ts +2 -2
  36. package/dist/{path-resolver-DwJO5XBn.d.ts → path-resolver-C1NM67-u.d.ts} +2 -2
  37. package/dist/{plan-templates-CG_pInJV.d.ts → plan-templates-CNY6f82B.d.ts} +4 -4
  38. package/dist/{provider-runner-DoohzfyD.d.ts → provider-runner-Cmuevptw.d.ts} +3 -3
  39. package/dist/{retry-policy-DOnwHAyz.d.ts → retry-policy-mEBn5qpv.d.ts} +1 -1
  40. package/dist/sdd/index.d.ts +3 -3
  41. package/dist/{secret-scrubber-DcTK9JHC.d.ts → secret-scrubber-BmiGszvl.d.ts} +1 -1
  42. package/dist/{secret-scrubber-C9UJxFCJ.d.ts → secret-scrubber-bZ5AyhwJ.d.ts} +1 -1
  43. package/dist/security/index.d.ts +3 -3
  44. package/dist/{selector-DVo3eT-P.d.ts → selector-BmUma5iG.d.ts} +1 -1
  45. package/dist/{session-reader-BXWxFAhS.d.ts → session-reader-g-FKCyBw.d.ts} +1 -1
  46. package/dist/storage/index.d.ts +6 -6
  47. package/dist/storage/index.js +101 -14
  48. package/dist/storage/index.js.map +1 -1
  49. package/dist/{system-prompt-BBGles-N.d.ts → system-prompt-BKrzd_ci.d.ts} +1 -1
  50. package/dist/{tool-executor-CwpjhwHC.d.ts → tool-executor-BoM0U0qn.d.ts} +6 -5
  51. package/dist/types/index.d.ts +16 -15
  52. package/dist/types/index.js +130 -20
  53. package/dist/types/index.js.map +1 -1
  54. package/dist/utils/index.d.ts +1 -1
  55. package/package.json +1 -1
  56. package/dist/agent-subagent-runner-BTloSwjE.d.ts +0 -174
@@ -1,4 +1,4 @@
1
- import { T as TextBlock, b as ContentBlock, v as Tool } from './context-C8mBUzBv.js';
1
+ import { T as TextBlock, b as ContentBlock, x as Tool } from './context-BwxhvyW8.js';
2
2
 
3
3
  /**
4
4
  * Container — dependency injection with explicit bind / override / decorate.
@@ -1,14 +1,15 @@
1
- import { a2 as Context, h as ProviderError, v as Tool, G as ToolUseBlock, B as ToolResultBlock } from './context-C8mBUzBv.js';
2
- import { a as Compactor, C as CompactReport } from './compactor-BUJ8550X.js';
3
- import { a as RecoveryDecision, E as ErrorHandler, R as RetryPolicy } from './retry-policy-DOnwHAyz.js';
1
+ import { a5 as Context, j as ProviderError, x as Tool, K as ToolUseBlock, G as ToolResultBlock } from './context-BwxhvyW8.js';
2
+ import { a as Compactor, C as CompactReport } from './compactor-BFKGzKd5.js';
3
+ import { a as RecoveryDecision, E as ErrorHandler, R as RetryPolicy } from './retry-policy-mEBn5qpv.js';
4
4
  import { M as ModelsRegistry } from './models-registry-Y2xbog0E.js';
5
- import { l as ToolExecutorOptions, m as ToolExecutorStrategy, n as ToolBatchResult } from './index-DiIGZh5I.js';
5
+ import { k as ToolExecutorOptions, l as ToolExecutorStrategy, m as ToolBatchResult } from './index-B2WWETRP.js';
6
6
 
7
7
  interface CompactorOptions {
8
8
  preserveK?: number;
9
9
  eliseThreshold?: number;
10
10
  estimator?: (text: string) => number;
11
11
  }
12
+
12
13
  declare class HybridCompactor implements Compactor {
13
14
  private readonly preserveK;
14
15
  private readonly eliseThreshold;
@@ -54,7 +55,6 @@ declare class DefaultErrorHandler implements ErrorHandler {
54
55
  }
55
56
 
56
57
  declare class DefaultRetryPolicy implements RetryPolicy {
57
- private static readonly NETWORK_ERR_RE;
58
58
  shouldRetry(err: Error | ProviderError, attempt: number): boolean;
59
59
  maxAttempts(err: Error | ProviderError): number;
60
60
  delayMs(attempt: number): number;
@@ -91,6 +91,7 @@ declare class ToolExecutor {
91
91
  private runWithTimeout;
92
92
  private runStreamedTool;
93
93
  private unknownToolResult;
94
+ private malformedInputResult;
94
95
  private deniedResult;
95
96
  private decrementBudget;
96
97
  /**
@@ -1,28 +1,29 @@
1
- export { A as AgentError, C as Capabilities, a as ConfigError, b as ContentBlock, E as ErrorCode, c as ErrorSeverity, d as ErrorSubsystem, F as FileSnapshot, 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, l as RiskTier, S as SessionData, m as SessionError, n as SessionEvent, o as SessionMetadata, p as SessionStore, q as SessionSummary, r as SessionWriter, s as StopReason, t as StreamEvent, T as TextBlock, u as ThinkingBlock, v as Tool, w as ToolCallContext, x as ToolError, y as ToolFinalEvent, z as ToolProgressEvent, B as ToolResultBlock, D as ToolStreamEvent, G as ToolUseBlock, U as Usage, W as WrongStackError, H as asBlocks, K as asText, L as isAgentError, N as isConfigError, O as isImageBlock, Q as isPluginError, V as isSessionError, X as isTextBlock, Y as isThinkingBlock, Z as isToolError, _ as isToolResultBlock, $ as isToolUseBlock, a0 as isWrongStackError, a1 as toWrongStackError } from '../context-C8mBUzBv.js';
2
- export { P as ProviderRunner, R as RunProviderOptions } from '../provider-runner-DoohzfyD.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-BHkYGzUT.js';
4
- export { C as CompactReport, a as Compactor } from '../compactor-BUJ8550X.js';
5
- export { P as PermissionDecision, a as PermissionPolicy, T as TrustPolicy } from '../secret-scrubber-C9UJxFCJ.js';
1
+ export { A as AgentError, C as Capabilities, a as ConfigError, b as ContentBlock, E as ERROR_CODES, c as ErrorCode, d as ErrorSeverity, e as ErrorSubsystem, F as FileSnapshot, f as FsError, I as ImageBlock, J as JSONSchema, M as Message, g as MessageRole, P as Permission, h as PluginError, i as Provider, j as ProviderError, k as ProviderErrorBody, R as Request, l as Response, m as ResumedSession, n as RiskTier, S as SessionData, o as SessionError, p as SessionEvent, q as SessionMetadata, r as SessionStore, s as SessionSummary, t as SessionWriter, u as StopReason, v as StreamEvent, T as TextBlock, w as ThinkingBlock, x as Tool, y as ToolCallContext, z as ToolError, B as ToolFinalEvent, D as ToolProgressEvent, G as ToolResultBlock, H as ToolStreamEvent, K as ToolUseBlock, U as Usage, W as WrongStackError, L as asBlocks, N as asText, O as isAgentError, Q as isConfigError, V as isFsError, X as isImageBlock, Y as isPluginError, Z as isSessionError, _ as isTextBlock, $ as isThinkingBlock, a0 as isToolError, a1 as isToolResultBlock, a2 as isToolUseBlock, a3 as isWrongStackError, a4 as toWrongStackError } from '../context-BwxhvyW8.js';
2
+ export { P as ProviderRunner, R as RunProviderOptions } from '../provider-runner-Cmuevptw.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-BXAhlqJb.js';
4
+ export { C as CompactReport, a as Compactor } from '../compactor-BFKGzKd5.js';
5
+ export { P as PermissionDecision, a as PermissionPolicy, T as TrustPolicy } from '../secret-scrubber-bZ5AyhwJ.js';
6
6
  export { C as CheckpointInfo, R as RewindResult, a as RewindResultExtended, S as SessionRewinder } from '../session-rewinder-C9HnMkhP.js';
7
- 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-BXWxFAhS.js';
8
- 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-DcTK9JHC.js';
7
+ 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-g-FKCyBw.js';
8
+ export { D as DEFAULT_CONTEXT_CONFIG, a as DEFAULT_TOOLS_CONFIG } from '../default-config-DvRSTELf.js';
9
+ 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-BmiGszvl.js';
9
10
  export { D as DefaultLogger, a as DefaultLoggerOptions } from '../logger-BH6AE0W9.js';
10
- export { D as DefaultPathResolver, a as DefaultTokenCounter } from '../path-resolver-DwJO5XBn.js';
11
+ export { D as DefaultPathResolver, a as DefaultTokenCounter } from '../path-resolver-C1NM67-u.js';
11
12
  export { M as MemoryEntry, a as MemoryScope, b as MemoryStore } from '../memory-CEXuo7sz.js';
12
- 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-CwpjhwHC.js';
13
+ 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-BoM0U0qn.js';
13
14
  export { S as SkillEntry, a as SkillLoader, b as SkillManifest } from '../skill-CxuWrsKK.js';
14
- export { B as BuildContext, M as ModelCapabilities, R as Renderer, S as SystemPromptBuilder } from '../system-prompt-BBGles-N.js';
15
+ export { B as BuildContext, M as ModelCapabilities, R as Renderer, S as SystemPromptBuilder } from '../system-prompt-BKrzd_ci.js';
15
16
  export { I as InputReader, P as PromptOption } from '../input-reader-E-ffP2ee.js';
16
- 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-DiIGZh5I.js';
17
+ 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-B2WWETRP.js';
17
18
  export { D as DefaultModelsRegistry, a as DefaultModelsRegistryOptions, c as classifyFamily } from '../models-registry-DqzwpBQy.js';
18
19
  export { D as DEFAULT_MODES, M as Mode, a as ModeConfig, b as ModeManifest, c as ModeStore } from '../mode-CV077NjV.js';
19
- export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-BCVxmrOn.js';
20
- 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-Iy8YUe3v.js';
20
+ export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-Bji75Iv9.js';
21
+ 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-DenFfUv5.js';
21
22
  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-D1YQbpxF.js';
22
23
  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';
23
- import '../events-DounT6pP.js';
24
+ import '../events-AjrvHJ9V.js';
24
25
  import '../logger-BMQgxvdy.js';
25
- import '../retry-policy-DOnwHAyz.js';
26
+ import '../retry-policy-mEBn5qpv.js';
26
27
  import '../models-registry-Y2xbog0E.js';
27
28
  import '../secret-vault-DoISxaKO.js';
28
29
  import '../path-resolver-CPRj4bFY.js';
@@ -30,6 +30,53 @@ function asText(content) {
30
30
  }
31
31
 
32
32
  // src/types/errors.ts
33
+ var ERROR_CODES = {
34
+ // Provider
35
+ PROVIDER_RATE_LIMITED: "PROVIDER_RATE_LIMITED",
36
+ PROVIDER_AUTH_FAILED: "PROVIDER_AUTH_FAILED",
37
+ PROVIDER_OVERLOADED: "PROVIDER_OVERLOADED",
38
+ PROVIDER_INVALID_REQUEST: "PROVIDER_INVALID_REQUEST",
39
+ PROVIDER_SERVER_ERROR: "PROVIDER_SERVER_ERROR",
40
+ PROVIDER_NETWORK_ERROR: "PROVIDER_NETWORK_ERROR",
41
+ PROVIDER_CONTEXT_OVERFLOW: "PROVIDER_CONTEXT_OVERFLOW",
42
+ // Tool
43
+ TOOL_NOT_FOUND: "TOOL_NOT_FOUND",
44
+ TOOL_PERMISSION_DENIED: "TOOL_PERMISSION_DENIED",
45
+ TOOL_EXECUTION_FAILED: "TOOL_EXECUTION_FAILED",
46
+ TOOL_TIMEOUT: "TOOL_TIMEOUT",
47
+ TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID",
48
+ // Config
49
+ CONFIG_INVALID: "CONFIG_INVALID",
50
+ CONFIG_NOT_FOUND: "CONFIG_NOT_FOUND",
51
+ CONFIG_PARSE_FAILED: "CONFIG_PARSE_FAILED",
52
+ CONFIG_MIGRATION_NEEDED: "CONFIG_MIGRATION_NEEDED",
53
+ // Plugin
54
+ PLUGIN_LOAD_FAILED: "PLUGIN_LOAD_FAILED",
55
+ PLUGIN_API_MISMATCH: "PLUGIN_API_MISMATCH",
56
+ PLUGIN_MISSING_DEPENDENCY: "PLUGIN_MISSING_DEPENDENCY",
57
+ // Agent
58
+ AGENT_ITERATION_LIMIT: "AGENT_ITERATION_LIMIT",
59
+ AGENT_CONTEXT_OVERFLOW: "AGENT_CONTEXT_OVERFLOW",
60
+ AGENT_ABORTED: "AGENT_ABORTED",
61
+ AGENT_RUN_FAILED: "AGENT_RUN_FAILED",
62
+ // Session
63
+ SESSION_NOT_FOUND: "SESSION_NOT_FOUND",
64
+ SESSION_CORRUPTED: "SESSION_CORRUPTED",
65
+ SESSION_WRITE_FAILED: "SESSION_WRITE_FAILED",
66
+ // Container / Registry
67
+ CONTAINER_TOKEN_ALREADY_BOUND: "CONTAINER_TOKEN_ALREADY_BOUND",
68
+ CONTAINER_TOKEN_NOT_BOUND: "CONTAINER_TOKEN_NOT_BOUND",
69
+ REGISTRY_DUPLICATE: "REGISTRY_DUPLICATE",
70
+ REGISTRY_NOT_FOUND: "REGISTRY_NOT_FOUND",
71
+ // File system
72
+ FS_READ_FAILED: "FS_READ_FAILED",
73
+ FS_WRITE_FAILED: "FS_WRITE_FAILED",
74
+ FS_MKDIR_FAILED: "FS_MKDIR_FAILED",
75
+ FS_DELETE_FAILED: "FS_DELETE_FAILED",
76
+ FS_ATOMIC_WRITE_FAILED: "FS_ATOMIC_WRITE_FAILED",
77
+ // General
78
+ UNKNOWN: "UNKNOWN"
79
+ };
33
80
  var WrongStackError = class extends Error {
34
81
  code;
35
82
  subsystem;
@@ -95,7 +142,7 @@ var PluginError = class extends WrongStackError {
95
142
  code: opts.code,
96
143
  subsystem: "plugin",
97
144
  severity: "error",
98
- recoverable: opts.code === "PLUGIN_MISSING_DEPENDENCY",
145
+ recoverable: opts.code === ERROR_CODES.PLUGIN_MISSING_DEPENDENCY,
99
146
  context: { plugin: opts.pluginName, ...opts.context },
100
147
  cause: opts.cause
101
148
  });
@@ -109,20 +156,20 @@ var AgentError = class extends WrongStackError {
109
156
  message: opts.message,
110
157
  code: opts.code,
111
158
  subsystem: "agent",
112
- severity: opts.code === "AGENT_ABORTED" ? "warning" : "error",
113
- recoverable: opts.recoverable ?? opts.code === "AGENT_ITERATION_LIMIT",
159
+ severity: opts.code === ERROR_CODES.AGENT_ABORTED ? "warning" : "error",
160
+ recoverable: opts.recoverable ?? opts.code === ERROR_CODES.AGENT_ITERATION_LIMIT,
114
161
  context: opts.context,
115
162
  cause: opts.cause
116
163
  });
117
164
  this.name = "AgentError";
118
165
  }
119
166
  };
120
- function toWrongStackError(err, code = "AGENT_RUN_FAILED") {
167
+ function toWrongStackError(err, code = ERROR_CODES.AGENT_RUN_FAILED) {
121
168
  if (err instanceof WrongStackError) return err;
122
169
  const message = err instanceof Error ? err.message : String(err);
123
170
  return new AgentError({
124
171
  message,
125
- code: code === "UNKNOWN" ? "AGENT_RUN_FAILED" : code,
172
+ code: code === "UNKNOWN" ? ERROR_CODES.AGENT_RUN_FAILED : code,
126
173
  cause: err
127
174
  });
128
175
  }
@@ -133,8 +180,8 @@ var SessionError = class extends WrongStackError {
133
180
  message: opts.message,
134
181
  code: opts.code,
135
182
  subsystem: "session",
136
- severity: opts.code === "SESSION_WRITE_FAILED" ? "error" : "warning",
137
- recoverable: opts.code !== "SESSION_CORRUPTED",
183
+ severity: opts.code === ERROR_CODES.SESSION_WRITE_FAILED ? "error" : "warning",
184
+ recoverable: opts.code !== ERROR_CODES.SESSION_CORRUPTED,
138
185
  context: { sessionId: opts.sessionId, ...opts.context },
139
186
  cause: opts.cause
140
187
  });
@@ -142,6 +189,22 @@ var SessionError = class extends WrongStackError {
142
189
  this.sessionId = opts.sessionId;
143
190
  }
144
191
  };
192
+ var FsError = class extends WrongStackError {
193
+ path;
194
+ constructor(opts) {
195
+ super({
196
+ message: opts.message,
197
+ code: opts.code,
198
+ subsystem: "fs",
199
+ severity: "error",
200
+ recoverable: opts.code !== ERROR_CODES.FS_READ_FAILED,
201
+ context: { path: opts.path, ...opts.context },
202
+ cause: opts.cause
203
+ });
204
+ this.name = "FsError";
205
+ this.path = opts.path;
206
+ }
207
+ };
145
208
  function isWrongStackError(err) {
146
209
  return err instanceof WrongStackError;
147
210
  }
@@ -160,6 +223,9 @@ function isSessionError(err) {
160
223
  function isAgentError(err) {
161
224
  return err instanceof AgentError;
162
225
  }
226
+ function isFsError(err) {
227
+ return err instanceof FsError;
228
+ }
163
229
 
164
230
  // src/types/provider.ts
165
231
  var ProviderError = class extends WrongStackError {
@@ -223,16 +289,30 @@ function truncate(s, n) {
223
289
  return s.length <= n ? s : `${s.slice(0, n - 1)}\u2026`;
224
290
  }
225
291
  function providerStatusToCode(status, type) {
226
- if (status === 0) return "PROVIDER_NETWORK_ERROR";
227
- if (type === "rate_limit_error" || status === 429) return "PROVIDER_RATE_LIMITED";
228
- if (type === "authentication_error" || status === 401) return "PROVIDER_AUTH_FAILED";
229
- if (type === "overloaded_error" || status === 529) return "PROVIDER_OVERLOADED";
230
- if (type === "invalid_request_error" || status === 400) return "PROVIDER_INVALID_REQUEST";
231
- if (status === 408) return "PROVIDER_NETWORK_ERROR";
232
- if (status >= 500) return "PROVIDER_SERVER_ERROR";
233
- return "PROVIDER_INVALID_REQUEST";
292
+ if (status === 0) return ERROR_CODES.PROVIDER_NETWORK_ERROR;
293
+ if (type === "rate_limit_error" || status === 429) return ERROR_CODES.PROVIDER_RATE_LIMITED;
294
+ if (type === "authentication_error" || status === 401) return ERROR_CODES.PROVIDER_AUTH_FAILED;
295
+ if (type === "overloaded_error" || status === 529) return ERROR_CODES.PROVIDER_OVERLOADED;
296
+ if (type === "invalid_request_error" || status === 400) return ERROR_CODES.PROVIDER_INVALID_REQUEST;
297
+ if (status === 408) return ERROR_CODES.PROVIDER_NETWORK_ERROR;
298
+ if (status >= 500) return ERROR_CODES.PROVIDER_SERVER_ERROR;
299
+ return ERROR_CODES.PROVIDER_INVALID_REQUEST;
234
300
  }
235
301
 
302
+ // src/types/default-config.ts
303
+ var DEFAULT_TOOLS_CONFIG = Object.freeze({
304
+ defaultExecutionStrategy: "smart",
305
+ maxIterations: 100,
306
+ iterationTimeoutMs: 3e5,
307
+ sessionTimeoutMs: 18e5,
308
+ perIterationOutputCapBytes: 1e5,
309
+ autoExtendLimit: true
310
+ });
311
+ var DEFAULT_CONTEXT_CONFIG = Object.freeze({
312
+ preserveK: 10,
313
+ eliseThreshold: 2e3
314
+ });
315
+
236
316
  // src/types/secret-vault.ts
237
317
  var ENCRYPTED_PREFIX = "enc:v1:";
238
318
  async function atomicWrite(targetPath, content, opts = {}) {
@@ -611,6 +691,7 @@ function formatCtx(ctx) {
611
691
  }
612
692
 
613
693
  // src/infrastructure/token-counter.ts
694
+ var PRICE_CACHE_MAX_SIZE = 100;
614
695
  var DefaultTokenCounter = class {
615
696
  input = 0;
616
697
  output = 0;
@@ -641,6 +722,10 @@ var DefaultTokenCounter = class {
641
722
  if (price) {
642
723
  this.applyPrice(usage, price);
643
724
  } else if (this.registry && this.providerId && model) {
725
+ if (this.priceCache.size >= PRICE_CACHE_MAX_SIZE) {
726
+ const keys = [...this.priceCache.keys()];
727
+ this.priceCache.delete(keys[0]);
728
+ }
644
729
  void this.registry.getModel(this.providerId, model).then((m) => {
645
730
  if (m) {
646
731
  const p = priceFromModel(m);
@@ -662,6 +747,10 @@ var DefaultTokenCounter = class {
662
747
  this.lastInput = usage.input;
663
748
  this.lastCacheRead = usage.cacheRead ?? 0;
664
749
  const price = priceFromModel(resolved);
750
+ if (this.priceCache.size >= PRICE_CACHE_MAX_SIZE) {
751
+ const keys = [...this.priceCache.keys()];
752
+ this.priceCache.delete(keys[0]);
753
+ }
665
754
  this.priceCache.set(resolved.modelId, price);
666
755
  this.applyPrice(usage, price);
667
756
  }
@@ -1069,9 +1158,11 @@ var DefaultPathResolver = class {
1069
1158
  }
1070
1159
  };
1071
1160
 
1161
+ // src/execution/regex-patterns.ts
1162
+ var NETWORK_ERR_RE = /ECONN|ETIMEDOUT|ETIME|ENOTFOUND|EAI_AGAIN|fetch failed/i;
1163
+
1072
1164
  // src/execution/error-handler.ts
1073
1165
  var CONTEXT_OVERFLOW_RE = /context|too long|tokens/i;
1074
- var NETWORK_ERR_RE = /ECONN|ETIMEDOUT|ETIME|ENOTFOUND|EAI_AGAIN|fetch failed/i;
1075
1166
  function buildRecoveryStrategies(opts) {
1076
1167
  return [
1077
1168
  {
@@ -1178,15 +1269,14 @@ var DefaultErrorHandler = class {
1178
1269
  };
1179
1270
 
1180
1271
  // src/execution/retry-policy.ts
1181
- var DefaultRetryPolicy = class _DefaultRetryPolicy {
1182
- static NETWORK_ERR_RE = /ECONN|ETIMEDOUT|ETIME|ENOTFOUND|EAI_AGAIN|fetch failed/i;
1272
+ var DefaultRetryPolicy = class {
1183
1273
  shouldRetry(err, attempt) {
1184
1274
  if (err instanceof ProviderError) {
1185
1275
  if (!err.retryable) return false;
1186
1276
  return attempt < this.maxAttempts(err);
1187
1277
  }
1188
1278
  const msg = err.message ?? "";
1189
- const isNetwork = _DefaultRetryPolicy.NETWORK_ERR_RE.test(msg);
1279
+ const isNetwork = NETWORK_ERR_RE.test(msg);
1190
1280
  if (isNetwork) return attempt < 2;
1191
1281
  return false;
1192
1282
  }
@@ -2119,6 +2209,11 @@ var ToolExecutor = class {
2119
2209
  budget = this.decrementBudget(result, budget);
2120
2210
  return { result, tool, durationMs: Date.now() - start };
2121
2211
  }
2212
+ if (hasMalformedArguments(use.input)) {
2213
+ const result = this.malformedInputResult(use);
2214
+ budget = this.decrementBudget(result, budget);
2215
+ return { result, tool, durationMs: Date.now() - start };
2216
+ }
2122
2217
  const decision = await this.opts.permissionPolicy.evaluate(tool, use.input, ctx);
2123
2218
  if (decision.permission === "deny") {
2124
2219
  const result = this.deniedResult(use, decision.reason);
@@ -2322,6 +2417,14 @@ var ToolExecutor = class {
2322
2417
  is_error: true
2323
2418
  };
2324
2419
  }
2420
+ malformedInputResult(use) {
2421
+ return {
2422
+ type: "tool_result",
2423
+ tool_use_id: use.id,
2424
+ content: `Tool "${use.name}" received arguments that were not a valid JSON object, so they could not be parsed. Re-issue the call with the arguments encoded as a single well-formed JSON object matching the tool's input schema.`,
2425
+ is_error: true
2426
+ };
2427
+ }
2325
2428
  deniedResult(use, reason) {
2326
2429
  return {
2327
2430
  type: "tool_result",
@@ -2367,6 +2470,13 @@ var ToolExecutor = class {
2367
2470
  return void 0;
2368
2471
  }
2369
2472
  };
2473
+ var MALFORMED_ARG_MARKERS = ["__raw", "__raw_arguments", "_raw"];
2474
+ function hasMalformedArguments(input) {
2475
+ if (!input || typeof input !== "object" || Array.isArray(input)) return false;
2476
+ const obj = input;
2477
+ const keys = Object.keys(obj);
2478
+ return keys.length === 1 && MALFORMED_ARG_MARKERS.includes(keys[0]);
2479
+ }
2370
2480
 
2371
2481
  // src/utils/regex-guard.ts
2372
2482
  var MAX_PATTERN_LEN = 512;
@@ -2664,6 +2774,6 @@ function renderPlainText(meta, events) {
2664
2774
  return lines.join("\n");
2665
2775
  }
2666
2776
 
2667
- 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 };
2777
+ export { AgentError, CONTEXT_WINDOW_MODES, ConfigError, DEFAULT_CONTEXT_CONFIG, DEFAULT_CONTEXT_WINDOW_MODE_ID, DEFAULT_MODES, DEFAULT_RECOVERY_STRATEGIES, DEFAULT_SPEC_TEMPLATE, DEFAULT_TOOLS_CONFIG, DefaultErrorHandler, DefaultLogger, DefaultModelsRegistry, DefaultPathResolver, DefaultRetryPolicy, DefaultSecretScrubber, DefaultSecretVault, DefaultSessionReader, DefaultTokenCounter, ERROR_CODES, FsError, HybridCompactor, InMemoryAgentBridge, InMemoryBridgeTransport, PluginError, ProviderError, SessionError, ToolError, ToolExecutor, WrongStackError, asBlocks, asText, buildRecoveryStrategies, classifyFamily, computeTaskProgress, createMessage, decryptConfigSecrets, encryptConfigSecrets, findCriticalPath, formatContextWindowModeList, getContextWindowMode, isAgentError, isConfigError, isContextWindowModeId, isFsError, isImageBlock, isPluginError, isSessionError, isTextBlock, isThinkingBlock, isToolError, isToolResultBlock, isToolUseBlock, isWrongStackError, listContextWindowModes, migratePlaintextSecrets, resolveContextWindowPolicy, rewriteConfigEncrypted, toWrongStackError, topologicalSort };
2668
2778
  //# sourceMappingURL=index.js.map
2669
2779
  //# sourceMappingURL=index.js.map