@wrongstack/core 0.6.0 → 0.6.3

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 (41) hide show
  1. package/dist/{agent-bridge-BKNiE1VH.d.ts → agent-bridge-eb7qnNrd.d.ts} +1 -1
  2. package/dist/coordination/index.d.ts +5 -5
  3. package/dist/coordination/index.js +183 -87
  4. package/dist/coordination/index.js.map +1 -1
  5. package/dist/defaults/index.d.ts +10 -10
  6. package/dist/defaults/index.js +596 -114
  7. package/dist/defaults/index.js.map +1 -1
  8. package/dist/{events-DPQKFX7W.d.ts → events-BHuIHekD.d.ts} +27 -4
  9. package/dist/execution/index.d.ts +149 -6
  10. package/dist/execution/index.js +401 -21
  11. package/dist/execution/index.js.map +1 -1
  12. package/dist/extension/index.d.ts +2 -2
  13. package/dist/{goal-store-BQ3YX1h1.d.ts → goal-store-DVCfj7Ff.d.ts} +20 -0
  14. package/dist/{index-B0qTujQW.d.ts → index-BOn9NK7D.d.ts} +1 -1
  15. package/dist/{index-DkdRz6yK.d.ts → index-CPcDqvZh.d.ts} +11 -4
  16. package/dist/index.d.ts +50 -16
  17. package/dist/index.js +831 -125
  18. package/dist/index.js.map +1 -1
  19. package/dist/infrastructure/index.d.ts +2 -2
  20. package/dist/infrastructure/index.js +1 -1
  21. package/dist/infrastructure/index.js.map +1 -1
  22. package/dist/kernel/index.d.ts +2 -2
  23. package/dist/kernel/index.js.map +1 -1
  24. package/dist/{multi-agent-Cpp7FXUl.d.ts → multi-agent-CxSb-9dQ.d.ts} +30 -5
  25. package/dist/observability/index.d.ts +1 -1
  26. package/dist/observability/index.js +1 -1
  27. package/dist/observability/index.js.map +1 -1
  28. package/dist/{path-resolver--g_hKJ7V.d.ts → path-resolver-CMGNadvq.d.ts} +1 -1
  29. package/dist/{plan-templates-CKJs_sYh.d.ts → plan-templates-BJflQY2i.d.ts} +1 -1
  30. package/dist/{provider-runner-hl4Il3xS.d.ts → provider-runner-BFgNXpaP.d.ts} +1 -1
  31. package/dist/sdd/index.d.ts +2 -2
  32. package/dist/storage/index.d.ts +3 -3
  33. package/dist/storage/index.js +3 -0
  34. package/dist/storage/index.js.map +1 -1
  35. package/dist/{tool-executor-B03CRwu-.d.ts → tool-executor-FoxBjULX.d.ts} +1 -1
  36. package/dist/types/index.d.ts +7 -7
  37. package/dist/types/index.js +30 -4
  38. package/dist/types/index.js.map +1 -1
  39. package/dist/utils/index.js +1 -1
  40. package/dist/utils/index.js.map +1 -1
  41. package/package.json +5 -1
@@ -2,7 +2,7 @@ import { a2 as Context, h as ProviderError, v as Tool, G as ToolUseBlock, B as T
2
2
  import { a as Compactor, C as CompactReport } from './compactor-RIPuTtWK.js';
3
3
  import { a as RecoveryDecision, E as ErrorHandler, R as RetryPolicy } from './retry-policy-LKS8MHsB.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-B0qTujQW.js';
5
+ import { k as ToolExecutorOptions, l as ToolExecutorStrategy, m as ToolBatchResult } from './index-BOn9NK7D.js';
6
6
 
7
7
  interface CompactorOptions {
8
8
  preserveK?: number;
@@ -1,5 +1,5 @@
1
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-CDRyrkKQ.js';
2
- export { P as ProviderRunner, R as RunProviderOptions } from '../provider-runner-hl4Il3xS.js';
2
+ export { P as ProviderRunner, R as RunProviderOptions } from '../provider-runner-BFgNXpaP.js';
3
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-BGGuP_Ar.js';
4
4
  export { C as CompactReport, a as Compactor } from '../compactor-RIPuTtWK.js';
5
5
  export { P as PermissionDecision, a as PermissionPolicy, T as TrustPolicy } from '../secret-scrubber-CfMdAJ_l.js';
@@ -7,20 +7,20 @@ export { C as CheckpointInfo, R as RewindResult, a as RewindResultExtended, S as
7
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-CzfRA6Vk.js';
8
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-BzQR5BiL.js';
9
9
  export { D as DefaultLogger, a as DefaultLoggerOptions } from '../logger-BH6AE0W9.js';
10
- export { D as DefaultPathResolver, a as DefaultTokenCounter } from '../path-resolver--g_hKJ7V.js';
10
+ export { D as DefaultPathResolver, a as DefaultTokenCounter } from '../path-resolver-CMGNadvq.js';
11
11
  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-B03CRwu-.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-FoxBjULX.js';
13
13
  export { S as SkillEntry, a as SkillLoader, b as SkillManifest } from '../skill-CxuWrsKK.js';
14
14
  export { B as BuildContext, M as ModelCapabilities, R as Renderer, S as SystemPromptBuilder } from '../system-prompt-Dl2QY1_B.js';
15
15
  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-B0qTujQW.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-BOn9NK7D.js';
17
17
  export { D as DefaultModelsRegistry, a as DefaultModelsRegistryOptions, c as classifyFamily } from '../models-registry-DqzwpBQy.js';
18
18
  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-BKNiE1VH.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-Cpp7FXUl.js';
19
+ export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-eb7qnNrd.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-CxSb-9dQ.js';
21
21
  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';
22
22
  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-DPQKFX7W.js';
23
+ import '../events-BHuIHekD.js';
24
24
  import '../logger-BMQgxvdy.js';
25
25
  import '../retry-policy-LKS8MHsB.js';
26
26
  import '../models-registry-Y2xbog0E.js';
@@ -728,7 +728,7 @@ function round4(n) {
728
728
  }
729
729
 
730
730
  // src/utils/token-estimate.ts
731
- var RoughTokenEstimate = (text) => Math.max(1, Math.ceil(text.length / 4));
731
+ var RoughTokenEstimate = (text, charsPerToken = 3.5) => Math.max(1, Math.ceil(text.length / charsPerToken));
732
732
  var ESTIMATE_CACHE = /* @__PURE__ */ new Map();
733
733
  var ESTIMATE_CACHE_MAX_SIZE = 1e4;
734
734
  function getCachedEstimate(key, compute) {
@@ -859,7 +859,7 @@ var HybridCompactor = class {
859
859
  eliseThreshold;
860
860
  estimator;
861
861
  constructor(opts = {}) {
862
- this.preserveK = opts.preserveK ?? 10;
862
+ this.preserveK = opts.preserveK ?? 5;
863
863
  this.eliseThreshold = opts.eliseThreshold ?? 2e3;
864
864
  this.estimator = opts.estimator ?? estimateTextTokens;
865
865
  }
@@ -903,6 +903,17 @@ var HybridCompactor = class {
903
903
  preserveStart = i;
904
904
  }
905
905
  }
906
+ for (let i = preserveStart; i < messages.length; i++) {
907
+ const m = messages[i];
908
+ if (!m || typeof m.content === "string" || !Array.isArray(m.content)) continue;
909
+ const hasToolUse2 = m.content.some((b) => b.type === "tool_use");
910
+ if (hasToolUse2 && i + 1 < messages.length) {
911
+ const next = messages[i + 1];
912
+ if (next && next.role === "user" && typeof next.content !== "string" && Array.isArray(next.content) && next.content.some((b) => b.type === "tool_result")) {
913
+ preserveStart = i + 1;
914
+ }
915
+ }
916
+ }
906
917
  let saved = 0;
907
918
  let changed = false;
908
919
  const nextMessages = new Array(messages.length);
@@ -924,7 +935,7 @@ var HybridCompactor = class {
924
935
  const elided = {
925
936
  type: "tool_result",
926
937
  tool_use_id: b.tool_use_id,
927
- content: `[elided: ~${tokens} tokens removed. Call the tool again if needed.]`,
938
+ content: `[elided: ~${tokens} tokens]`,
928
939
  is_error: b.is_error
929
940
  };
930
941
  return elided;
@@ -2264,13 +2275,17 @@ var ToolExecutor = class {
2264
2275
  const ctrl = new AbortController();
2265
2276
  const timer = setTimeout(() => ctrl.abort(new Error("tool timeout")), timeoutMs);
2266
2277
  const combined = AbortSignal.any([parentSignal, ctrl.signal]);
2278
+ let cleanupCalled = false;
2279
+ let caught = false;
2267
2280
  try {
2268
2281
  if (typeof tool.executeStream === "function") {
2269
2282
  return await this.runStreamedTool(tool, input, ctx, combined, toolUseId);
2270
2283
  }
2271
2284
  return await tool.execute(input, ctx, { signal: combined });
2272
2285
  } catch (err) {
2286
+ caught = true;
2273
2287
  if (combined.aborted && typeof tool.cleanup === "function") {
2288
+ cleanupCalled = true;
2274
2289
  try {
2275
2290
  await tool.cleanup(input, ctx);
2276
2291
  } catch {
@@ -2279,6 +2294,16 @@ var ToolExecutor = class {
2279
2294
  throw err;
2280
2295
  } finally {
2281
2296
  clearTimeout(timer);
2297
+ if (combined.aborted && !caught) {
2298
+ if (!cleanupCalled && typeof tool.cleanup === "function") {
2299
+ try {
2300
+ await tool.cleanup(input, ctx);
2301
+ } catch {
2302
+ }
2303
+ }
2304
+ const reason = combined.reason instanceof Error ? combined.reason : new Error(typeof combined.reason === "string" ? combined.reason : "aborted");
2305
+ throw reason;
2306
+ }
2282
2307
  }
2283
2308
  }
2284
2309
  async runStreamedTool(tool, input, ctx, signal, toolUseId) {
@@ -2336,7 +2361,8 @@ var ToolExecutor = class {
2336
2361
  if (subjectKey) {
2337
2362
  const v = obj[subjectKey];
2338
2363
  if (typeof v === "string") {
2339
- return subjectKey === "path" || subjectKey === "file" || subjectKey === "files" ? normalizePath(v) : escapeGlob(v);
2364
+ const isPathKey = subjectKey === "path" || subjectKey === "file" || subjectKey === "files";
2365
+ return isPathKey ? normalizePath(v) : escapeGlob(v);
2340
2366
  }
2341
2367
  }
2342
2368
  if (toolName === "bash" && typeof obj.command === "string") {