@wrongstack/core 0.6.1 → 0.6.4

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 (38) hide show
  1. package/dist/{agent-bridge-DaCvA_uK.d.ts → agent-bridge-eb7qnNrd.d.ts} +1 -1
  2. package/dist/coordination/index.d.ts +5 -5
  3. package/dist/coordination/index.js +5 -33
  4. package/dist/coordination/index.js.map +1 -1
  5. package/dist/defaults/index.d.ts +8 -8
  6. package/dist/defaults/index.js +62 -39
  7. package/dist/defaults/index.js.map +1 -1
  8. package/dist/{events-CzkeaVVl.d.ts → events-BHuIHekD.d.ts} +19 -2
  9. package/dist/execution/index.d.ts +4 -4
  10. package/dist/execution/index.js +56 -5
  11. package/dist/execution/index.js.map +1 -1
  12. package/dist/extension/index.d.ts +2 -2
  13. package/dist/{index-BkKLQjea.d.ts → index-BOn9NK7D.d.ts} +1 -1
  14. package/dist/{index-i9rPR53g.d.ts → index-CPcDqvZh.d.ts} +4 -4
  15. package/dist/index.d.ts +11 -11
  16. package/dist/index.js +62 -39
  17. package/dist/index.js.map +1 -1
  18. package/dist/infrastructure/index.d.ts +2 -2
  19. package/dist/infrastructure/index.js +1 -1
  20. package/dist/infrastructure/index.js.map +1 -1
  21. package/dist/kernel/index.d.ts +2 -2
  22. package/dist/kernel/index.js.map +1 -1
  23. package/dist/{multi-agent-MfI6dmv-.d.ts → multi-agent-CxSb-9dQ.d.ts} +1 -1
  24. package/dist/observability/index.d.ts +1 -1
  25. package/dist/observability/index.js +1 -1
  26. package/dist/observability/index.js.map +1 -1
  27. package/dist/{path-resolver-CWINz5XR.d.ts → path-resolver-CMGNadvq.d.ts} +1 -1
  28. package/dist/{plan-templates-Bne1pB4d.d.ts → plan-templates-BJflQY2i.d.ts} +1 -1
  29. package/dist/{provider-runner-CZYIzeBp.d.ts → provider-runner-BFgNXpaP.d.ts} +1 -1
  30. package/dist/sdd/index.d.ts +2 -2
  31. package/dist/storage/index.d.ts +2 -2
  32. package/dist/{tool-executor-40Q6shR-.d.ts → tool-executor-FoxBjULX.d.ts} +1 -1
  33. package/dist/types/index.d.ts +7 -7
  34. package/dist/types/index.js +14 -3
  35. package/dist/types/index.js.map +1 -1
  36. package/dist/utils/index.js +1 -1
  37. package/dist/utils/index.js.map +1 -1
  38. package/package.json +1 -1
@@ -1,23 +1,23 @@
1
1
  export { D as DefaultLogger, a as DefaultLoggerOptions } from '../logger-BH6AE0W9.js';
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-Bne1pB4d.js';
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-BJflQY2i.js';
3
3
  export { D as DefaultSessionReader } from '../session-reader-CzfRA6Vk.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
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-BzQR5BiL.js';
6
6
  export { AutoApprovePermissionPolicy, DefaultPermissionPolicy, PermissionPolicyOptions } from '../security/index.js';
7
- export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, T as ToolExecutor } from '../tool-executor-40Q6shR-.js';
7
+ export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, T as ToolExecutor } from '../tool-executor-FoxBjULX.js';
8
8
  export { AutoCompactionMiddleware, AutonomousRunner, AutonomousRunnerOptions, AutonomyPromptContributorOptions, DefaultSkillLoader, DoneCheckResult, DoneConditionChecker, EternalAutonomyEngine, EternalAutonomyOptions, EternalEngineState, IntelligentCompactor, IntelligentCompactorOptions, SelectiveCompactor, SelectiveCompactorOptions, SkillLoaderOptions, buildGoalPreamble, makeAutonomyPromptContributor } from '../execution/index.js';
9
- import { P as ProviderRunner, R as RunProviderOptions } from '../provider-runner-CZYIzeBp.js';
9
+ import { P as ProviderRunner, R as RunProviderOptions } from '../provider-runner-BFgNXpaP.js';
10
10
  import { j as Response } from '../context-CDRyrkKQ.js';
11
- export { A as ALL_FLEET_AGENTS, a as AUDIT_LOG_AGENT, b as AgentFactory, c as AgentFactoryResult, d as AgentRunnerOptions, B as BUG_HUNTER_AGENT, C as CreateDelegateToolOptions, D as DEFAULT_DIRECTOR_PREAMBLE, e as DEFAULT_SUBAGENT_BASELINE, f as DefaultMultiAgentCoordinator, g as DelegateHost, h as Director, i as DirectorPromptParts, j as DirectorSessionFactory, k as DirectorSessionFactoryOptions, F as FLEET_ROSTER, l as FLEET_ROSTER_BUDGETS, m as FleetBus, n as FleetEvent, o as FleetHandler, r as FleetSpawnBudgetError, s as FleetUsage, t as FleetUsageAggregator, I as ICoordinator, u as IFleetManager, M as MultiAgentCoordinatorOptions, N as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, S as SECURITY_SCANNER_AGENT, v as SubagentPromptParts, w as SubagentUsageSnapshot, x as applyRosterBudget, y as composeDirectorPrompt, z as composeSubagentPrompt, E as createDelegateTool, G as makeAgentSubagentRunner, H as makeDirectorSessionFactory, J as rosterSummaryFromConfigs } from '../index-i9rPR53g.js';
12
- export { n as BudgetExceededError, o as BudgetKind, p as BudgetLimits, q as BudgetUsage, r as SubagentBudget } from '../multi-agent-MfI6dmv-.js';
13
- export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-DaCvA_uK.js';
11
+ export { A as ALL_FLEET_AGENTS, a as AUDIT_LOG_AGENT, b as AgentFactory, c as AgentFactoryResult, d as AgentRunnerOptions, B as BUG_HUNTER_AGENT, C as CreateDelegateToolOptions, D as DEFAULT_DIRECTOR_PREAMBLE, e as DEFAULT_SUBAGENT_BASELINE, f as DefaultMultiAgentCoordinator, g as DelegateHost, h as Director, i as DirectorPromptParts, j as DirectorSessionFactory, k as DirectorSessionFactoryOptions, F as FLEET_ROSTER, l as FLEET_ROSTER_BUDGETS, m as FleetBus, n as FleetEvent, o as FleetHandler, r as FleetSpawnBudgetError, s as FleetUsage, t as FleetUsageAggregator, I as ICoordinator, u as IFleetManager, M as MultiAgentCoordinatorOptions, N as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, S as SECURITY_SCANNER_AGENT, v as SubagentPromptParts, w as SubagentUsageSnapshot, x as applyRosterBudget, y as composeDirectorPrompt, z as composeSubagentPrompt, E as createDelegateTool, G as makeAgentSubagentRunner, H as makeDirectorSessionFactory, J as rosterSummaryFromConfigs } from '../index-CPcDqvZh.js';
12
+ export { n as BudgetExceededError, o as BudgetKind, p as BudgetLimits, q as BudgetUsage, r as SubagentBudget } from '../multi-agent-CxSb-9dQ.js';
13
+ export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-eb7qnNrd.js';
14
14
  export { D as DefaultModelsRegistry, a as DefaultModelsRegistryOptions, c as classifyFamily } from '../models-registry-DqzwpBQy.js';
15
15
  export { DefaultModeStore, LLMSelector, LLMSelectorOptions, ModeLoaderOptions, loadProjectModes, loadUserModes } from '../models/index.js';
16
16
  export { AISpecBuilder, AISpecBuilderOptions, AISpecPhase, AISpecSession, AutoExecutor, AutoExecutorOptions, BottleneckTask, CollectedAnswer, CriticalPathAnalysis, DefaultTaskStore, ExecutionSummary, GeneratedTask, SPEC_TEMPLATES, SpecDiff, SpecDrivenDev, SpecDrivenDevOptions, SpecIndexEntry, SpecParser, SpecStore, SpecStoreOptions, SpecVersion, SpecVersioning, TaskExecutionContext, TaskExecutionResult, TaskFlow, TaskFlowEventMap, TaskFlowEventName, TaskFlowExecutionContext, TaskFlowOptions, TaskFlowPhase, TaskGenerator, TaskGeneratorOptions, TaskGraphIndexEntry, TaskGraphStore, TaskGraphStoreOptions, TaskStore, TaskTracker, TaskTrackerOptions, TaskTransition, analyzeCriticalPath, createAutoExecutor, getTemplate, listTemplates, renderProgress, renderSpecAnalysis, renderTaskGraph, renderTaskList, templateToMarkdown } from '../sdd/index.js';
17
17
  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';
18
18
  export { C as ContextManagerAction, a as ContextManagerInput, b as ContextManagerResult, c as ContextManagerToolOptions, d as allServers, e as awsServer, f as blockServer, g as braveSearchServer, h as context7Server, i as contextManagerTool, j as createContextManagerTool, k as everArtServer, l as filesystemServer, m as githubServer, n as googleMapsServer, o as miniMaxVisionServer, s as sentinelServer, p as slackServer, z as zaiVisionServer } from '../mcp-servers-DBdh3cee.js';
19
19
  import '../logger-BMQgxvdy.js';
20
- import '../events-CzkeaVVl.js';
20
+ import '../events-BHuIHekD.js';
21
21
  import '../memory-CEXuo7sz.js';
22
22
  import '../wstack-paths-86YPFktR.js';
23
23
  import '../config-BGGuP_Ar.js';
@@ -27,7 +27,7 @@ import '../secret-scrubber-CfMdAJ_l.js';
27
27
  import '../input-reader-E-ffP2ee.js';
28
28
  import '../compactor-RIPuTtWK.js';
29
29
  import '../retry-policy-LKS8MHsB.js';
30
- import '../index-BkKLQjea.js';
30
+ import '../index-BOn9NK7D.js';
31
31
  import '../system-prompt-Dl2QY1_B.js';
32
32
  import '../observability-BhnVLBLS.js';
33
33
  import '../selector-C7HqnZJU.js';
@@ -3834,7 +3834,7 @@ var DefaultProviderRunner = class {
3834
3834
  };
3835
3835
 
3836
3836
  // src/utils/token-estimate.ts
3837
- var RoughTokenEstimate = (text) => Math.max(1, Math.ceil(text.length / 4));
3837
+ var RoughTokenEstimate = (text, charsPerToken = 3.5) => Math.max(1, Math.ceil(text.length / charsPerToken));
3838
3838
  var ESTIMATE_CACHE = /* @__PURE__ */ new Map();
3839
3839
  var ESTIMATE_CACHE_MAX_SIZE = 1e4;
3840
3840
  function getCachedEstimate(key, compute) {
@@ -3921,7 +3921,7 @@ var HybridCompactor = class {
3921
3921
  eliseThreshold;
3922
3922
  estimator;
3923
3923
  constructor(opts = {}) {
3924
- this.preserveK = opts.preserveK ?? 10;
3924
+ this.preserveK = opts.preserveK ?? 5;
3925
3925
  this.eliseThreshold = opts.eliseThreshold ?? 2e3;
3926
3926
  this.estimator = opts.estimator ?? estimateTextTokens;
3927
3927
  }
@@ -3965,6 +3965,17 @@ var HybridCompactor = class {
3965
3965
  preserveStart = i;
3966
3966
  }
3967
3967
  }
3968
+ for (let i = preserveStart; i < messages.length; i++) {
3969
+ const m = messages[i];
3970
+ if (!m || typeof m.content === "string" || !Array.isArray(m.content)) continue;
3971
+ const hasToolUse2 = m.content.some((b) => b.type === "tool_use");
3972
+ if (hasToolUse2 && i + 1 < messages.length) {
3973
+ const next = messages[i + 1];
3974
+ if (next && next.role === "user" && typeof next.content !== "string" && Array.isArray(next.content) && next.content.some((b) => b.type === "tool_result")) {
3975
+ preserveStart = i + 1;
3976
+ }
3977
+ }
3978
+ }
3968
3979
  let saved = 0;
3969
3980
  let changed = false;
3970
3981
  const nextMessages = new Array(messages.length);
@@ -3986,7 +3997,7 @@ var HybridCompactor = class {
3986
3997
  const elided = {
3987
3998
  type: "tool_result",
3988
3999
  tool_use_id: b.tool_use_id,
3989
- content: `[elided: ~${tokens} tokens removed. Call the tool again if needed.]`,
4000
+ content: `[elided: ~${tokens} tokens]`,
3990
4001
  is_error: b.is_error
3991
4002
  };
3992
4003
  return elided;
@@ -4125,7 +4136,28 @@ var IntelligentCompactor = class {
4125
4136
  try {
4126
4137
  summaryText = await this.callSummarizer(toSummarize, ctx);
4127
4138
  } catch {
4128
- summaryText = `[${toSummarize.length} earlier turns omitted \u2014 key decisions and file states preserved in context]`;
4139
+ const toolNames = /* @__PURE__ */ new Set();
4140
+ const filePaths = /* @__PURE__ */ new Set();
4141
+ let userTurns = 0, assistantTurns = 0;
4142
+ for (const m of toSummarize) {
4143
+ if (m.role === "user") userTurns++;
4144
+ else if (m.role === "assistant") {
4145
+ assistantTurns++;
4146
+ if (Array.isArray(m.content)) {
4147
+ for (const b of m.content) {
4148
+ if (b.type === "tool_use") toolNames.add(b.name ?? "unknown");
4149
+ }
4150
+ }
4151
+ }
4152
+ const text = typeof m.content === "string" ? m.content : "";
4153
+ const matches = text.matchAll(/(?:[\w.,\-/@]+\/)*[\w.,\-/@]+\.\w+/g);
4154
+ for (const m_ of matches) filePaths.add(m_[0]);
4155
+ }
4156
+ const parts = [`${toSummarize.length} turns (${userTurns} user, ${assistantTurns} assistant)`];
4157
+ if (toolNames.size > 0) parts.push(`tools: ${[...toolNames].join(", ")}`);
4158
+ if (filePaths.size > 0) parts.push(`files: ${[...filePaths].slice(0, 10).join(", ")}`);
4159
+ summaryText = parts.join(" | ");
4160
+ if (!summaryText) summaryText = `${toSummarize.length} earlier turns omitted`;
4129
4161
  }
4130
4162
  const summaryMsg = {
4131
4163
  role: "system",
@@ -4209,6 +4241,17 @@ var IntelligentCompactor = class {
4209
4241
  preserveStart = i;
4210
4242
  }
4211
4243
  }
4244
+ for (let i = preserveStart; i < messages.length; i++) {
4245
+ const m = messages[i];
4246
+ if (!m || typeof m.content === "string" || !Array.isArray(m.content)) continue;
4247
+ const hasToolUse2 = m.content.some((b) => b.type === "tool_use");
4248
+ if (hasToolUse2 && i + 1 < messages.length) {
4249
+ const next = messages[i + 1];
4250
+ if (next && next.role === "user" && typeof next.content !== "string" && Array.isArray(next.content) && next.content.some((b) => b.type === "tool_result")) {
4251
+ preserveStart = i + 1;
4252
+ }
4253
+ }
4254
+ }
4212
4255
  let saved = 0;
4213
4256
  let changed = false;
4214
4257
  const nextMessages = new Array(messages.length);
@@ -4723,7 +4766,15 @@ var AutoCompactionMiddleware = class {
4723
4766
  }
4724
4767
  async compact(ctx, aggressive, pressure) {
4725
4768
  try {
4726
- await this.compactor.compact(ctx, { aggressive });
4769
+ const report = await this.compactor.compact(ctx, { aggressive });
4770
+ this.events?.emit("compaction.fired", {
4771
+ level: pressure.level,
4772
+ tokens: pressure.tokens,
4773
+ load: pressure.load,
4774
+ maxContext: this._maxContext,
4775
+ report,
4776
+ aggressive
4777
+ });
4727
4778
  } catch (err) {
4728
4779
  const error = err instanceof Error ? err : new Error(String(err));
4729
4780
  const fatal = this.failureMode === "throw" || this.failureMode === "throw_on_hard" && pressure.level === "hard";
@@ -6210,40 +6261,12 @@ var FleetBus = class {
6210
6261
  * subagent teardown so the listeners don't outlive the run.
6211
6262
  */
6212
6263
  attach(subagentId, bus, taskId) {
6213
- const FORWARDED_TYPES = [
6214
- "tool.started",
6215
- "tool.executed",
6216
- "tool.progress",
6217
- "tool.confirm_needed",
6218
- "iteration.started",
6219
- "iteration.completed",
6220
- "provider.text_delta",
6221
- // Subagent extended-thinking output. Forwarded so the FleetPanel /
6222
- // /fleet log can surface "the planner is thinking…" instead of a
6223
- // silent gap between iteration.started and the first text_delta.
6224
- "provider.thinking_delta",
6225
- "provider.response",
6226
- "provider.retry",
6227
- "provider.error",
6228
- "session.started",
6229
- "session.ended",
6230
- "session.damaged",
6231
- "compaction.fired",
6232
- "compaction.failed",
6233
- "token.threshold",
6234
- // Subagent hit a soft budget limit — coordinator can extend or stop.
6235
- "budget.threshold_reached"
6236
- ];
6237
- const offs = [];
6238
- for (const t of FORWARDED_TYPES) {
6239
- offs.push(
6240
- bus.on(t, (payload) => {
6241
- this.emit({ subagentId, taskId, ts: Date.now(), type: t, payload });
6242
- })
6243
- );
6244
- }
6264
+ const off = bus.onPattern("*", (type, payload) => {
6265
+ if (type.startsWith("subagent.")) return;
6266
+ this.emit({ subagentId, taskId, ts: Date.now(), type, payload });
6267
+ });
6245
6268
  return () => {
6246
- for (const off of offs) off();
6269
+ off();
6247
6270
  };
6248
6271
  }
6249
6272
  /** Subscribe to every event from one subagent. */
@@ -11917,7 +11940,7 @@ function wireMetricsToEvents(events, sink) {
11917
11940
  events.on("token.threshold", (e) => sink.gauge("agent.tokens.used", e.used)),
11918
11941
  events.on("compaction.fired", (e) => {
11919
11942
  sink.counter("compaction.fired.total");
11920
- sink.histogram("compaction.reduction_tokens", e.before - e.after);
11943
+ sink.histogram("compaction.reduction_tokens", e.report.before - e.report.after);
11921
11944
  }),
11922
11945
  events.on(
11923
11946
  "mcp.server.connected",