@wrongstack/core 0.54.1 → 0.63.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 (54) hide show
  1. package/dist/{agent-bridge-Dnhw4tnM.d.ts → agent-bridge-B5rxWrg3.d.ts} +1 -1
  2. package/dist/{agent-subagent-runner-By7jruZ_.d.ts → agent-subagent-runner-Zc3f37Sg.d.ts} +3 -3
  3. package/dist/{compactor-Duhsf0ge.d.ts → compactor-0vjZ8KTk.d.ts} +1 -1
  4. package/dist/{config-bht0txXS.d.ts → config-BdDuaZmB.d.ts} +112 -2
  5. package/dist/{context-DtPKqKYV.d.ts → context-iFMEO2rN.d.ts} +8 -8
  6. package/dist/coordination/index.d.ts +12 -12
  7. package/dist/defaults/index.d.ts +21 -21
  8. package/dist/defaults/index.js +254 -92
  9. package/dist/defaults/index.js.map +1 -1
  10. package/dist/{events-CbHTS4ZZ.d.ts → events-k8CHjcrN.d.ts} +20 -1
  11. package/dist/execution/index.d.ts +14 -14
  12. package/dist/execution/index.js +70 -10
  13. package/dist/execution/index.js.map +1 -1
  14. package/dist/extension/index.d.ts +7 -7
  15. package/dist/{goal-store-DwcTDDiX.d.ts → goal-store-iHltMi5n.d.ts} +1 -1
  16. package/dist/{index-CI271MjL.d.ts → index-Bc6BiP5q.d.ts} +77 -6
  17. package/dist/{index-ge5F2dnc.d.ts → index-CWdW_CJt.d.ts} +10 -8
  18. package/dist/index.d.ts +56 -32
  19. package/dist/index.js +520 -85
  20. package/dist/index.js.map +1 -1
  21. package/dist/infrastructure/index.d.ts +6 -6
  22. package/dist/infrastructure/index.js +1 -1
  23. package/dist/infrastructure/index.js.map +1 -1
  24. package/dist/kernel/index.d.ts +9 -9
  25. package/dist/kernel/index.js +3 -1
  26. package/dist/kernel/index.js.map +1 -1
  27. package/dist/{mcp-servers-DE6gzBry.d.ts → mcp-servers-CwqQDMYy.d.ts} +3 -3
  28. package/dist/models/index.d.ts +2 -2
  29. package/dist/{multi-agent-BmC_xiog.d.ts → multi-agent-SASYOrWA.d.ts} +2 -2
  30. package/dist/{multi-agent-coordinator-CjNX4uBD.d.ts → multi-agent-coordinator-CNUJYq7U.d.ts} +2 -2
  31. package/dist/{null-fleet-bus-BNiSlTna.d.ts → null-fleet-bus-DRoJ0uOY.d.ts} +7 -7
  32. package/dist/observability/index.d.ts +2 -2
  33. package/dist/{path-resolver-Bax85amb.d.ts → path-resolver-C5sPVne8.d.ts} +2 -2
  34. package/dist/{permission-Drm7LpPo.d.ts → permission-Ld-i5ugf.d.ts} +13 -1
  35. package/dist/{permission-policy-CU6sqWxF.d.ts → permission-policy-CL-mPufp.d.ts} +14 -7
  36. package/dist/{plan-templates-CLRcurWN.d.ts → plan-templates-ThBHOjaM.d.ts} +4 -4
  37. package/dist/{provider-runner-BikCxGCx.d.ts → provider-runner-DJQa211J.d.ts} +3 -3
  38. package/dist/{retry-policy-Chtlvr5b.d.ts → retry-policy-BfBScewS.d.ts} +1 -1
  39. package/dist/sdd/index.d.ts +9 -9
  40. package/dist/sdd/index.js +1 -1
  41. package/dist/sdd/index.js.map +1 -1
  42. package/dist/security/index.d.ts +3 -3
  43. package/dist/security/index.js +115 -13
  44. package/dist/security/index.js.map +1 -1
  45. package/dist/{selector-BvSPdJj6.d.ts → selector-DxhW7ML3.d.ts} +1 -1
  46. package/dist/{session-reader-BGhzMir4.d.ts → session-reader-q2ThszgG.d.ts} +1 -1
  47. package/dist/storage/index.d.ts +6 -6
  48. package/dist/{system-prompt-dtzV_mLm.d.ts → system-prompt-7LHyBbIf.d.ts} +32 -2
  49. package/dist/{tool-executor-CgU0yWpB.d.ts → tool-executor-CIjpGaRA.d.ts} +5 -4
  50. package/dist/types/index.d.ts +14 -14
  51. package/dist/types/index.js +62 -6
  52. package/dist/types/index.js.map +1 -1
  53. package/dist/utils/index.d.ts +2 -2
  54. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { $ as Usage, d as Context, X as ToolProgressEvent, Q as Tool } from './context-DtPKqKYV.js';
1
+ import { $ as Usage, d as Context, X as ToolProgressEvent, Q as Tool } from './context-iFMEO2rN.js';
2
2
 
3
3
  /**
4
4
  * Brain coordination primitives.
@@ -210,6 +210,25 @@ interface EventMap {
210
210
  description: string;
211
211
  retryable: boolean;
212
212
  };
213
+ /**
214
+ * Fired by the fallback-model extension when the primary model is overloaded
215
+ * (after its own retries are exhausted) and the agent switches to the next
216
+ * model in the configured `fallbackModels` chain. `providerSwitched` is true
217
+ * when the fallback also changed the active provider (cross-provider). UIs
218
+ * render this as a notice: "⚠ opus overloaded — falling back to sonnet".
219
+ */
220
+ 'provider.fallback': {
221
+ from: {
222
+ providerId: string;
223
+ model: string;
224
+ };
225
+ to: {
226
+ providerId: string;
227
+ model: string;
228
+ };
229
+ status: number;
230
+ providerSwitched: boolean;
231
+ };
213
232
  'tool.started': {
214
233
  name: string;
215
234
  id: string;
@@ -1,23 +1,23 @@
1
- export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, T as ToolExecutor } from '../tool-executor-CgU0yWpB.js';
2
- import { m as Provider, d as Context } from '../context-DtPKqKYV.js';
3
- import { a as Compactor, C as CompactReport } from '../compactor-Duhsf0ge.js';
4
- import { M as MessageSelector } from '../selector-BvSPdJj6.js';
5
- import { E as EventBus } from '../events-CbHTS4ZZ.js';
6
- import { b as MiddlewareHandler } from '../system-prompt-dtzV_mLm.js';
7
- import { a as SessionEventBridge, J as JournalEntry } from '../goal-store-DwcTDDiX.js';
8
- import { e as ContextWindowAggressiveOn, i as ContextWindowPolicy } from '../config-bht0txXS.js';
9
- import { c as Agent, R as RunResult, w as SystemPromptContributor } from '../index-CI271MjL.js';
10
- import { D as DoneCondition } from '../multi-agent-BmC_xiog.js';
11
- import { A as AgentFactory } from '../agent-subagent-runner-By7jruZ_.js';
12
- import { f as DispatchClassifier, d as DefaultMultiAgentCoordinator } from '../multi-agent-coordinator-CjNX4uBD.js';
1
+ export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, T as ToolExecutor } from '../tool-executor-CIjpGaRA.js';
2
+ import { m as Provider, d as Context } from '../context-iFMEO2rN.js';
3
+ import { a as Compactor, C as CompactReport } from '../compactor-0vjZ8KTk.js';
4
+ import { M as MessageSelector } from '../selector-DxhW7ML3.js';
5
+ import { E as EventBus } from '../events-k8CHjcrN.js';
6
+ import { b as MiddlewareHandler } from '../system-prompt-7LHyBbIf.js';
7
+ import { a as SessionEventBridge, J as JournalEntry } from '../goal-store-iHltMi5n.js';
8
+ import { e as ContextWindowAggressiveOn, i as ContextWindowPolicy } from '../config-BdDuaZmB.js';
9
+ import { c as Agent, R as RunResult, C as SystemPromptContributor } from '../index-Bc6BiP5q.js';
10
+ import { D as DoneCondition } from '../multi-agent-SASYOrWA.js';
11
+ import { A as AgentFactory } from '../agent-subagent-runner-Zc3f37Sg.js';
12
+ import { f as DispatchClassifier, d as DefaultMultiAgentCoordinator } from '../multi-agent-coordinator-CNUJYq7U.js';
13
13
  import { a as SkillLoader, b as SkillManifest, S as SkillEntry } from '../skill-CxuWrsKK.js';
14
14
  import { a as WstackPaths } from '../wstack-paths-eMXnY1_X.js';
15
- import '../retry-policy-Chtlvr5b.js';
15
+ import '../retry-policy-BfBScewS.js';
16
16
  import '../models-registry-BcYJDKLm.js';
17
17
  import '../logger-DDd5C--Z.js';
18
18
  import '../observability-BhnVLBLS.js';
19
19
  import '../secret-scrubber-3MHDDAtm.js';
20
- import '../permission-Drm7LpPo.js';
20
+ import '../permission-Ld-i5ugf.js';
21
21
  import 'node:events';
22
22
 
23
23
  interface SkillLoaderOptions {
@@ -1466,8 +1466,9 @@ var ToolExecutor = class {
1466
1466
  */
1467
1467
  async executeBatch(toolUses, ctx, strategy) {
1468
1468
  let budget = this.opts.perIterationOutputCapBytes ?? 1e5;
1469
- const runOne = async (use) => {
1469
+ const runOne = async (use0) => {
1470
1470
  const start = Date.now();
1471
+ let use = use0;
1471
1472
  const tool = this.registry.get(use.name);
1472
1473
  if (!tool) {
1473
1474
  const result = this.unknownToolResult(use, () => this.registry.list().map((t) => t.name));
@@ -1500,10 +1501,36 @@ Please call the tool again with arguments that match its inputSchema. You can us
1500
1501
  budget = this.decrementBudget(result, budget);
1501
1502
  return { result, tool, durationMs: Date.now() - start };
1502
1503
  }
1504
+ if (this.opts.hookRunner?.has("PreToolUse")) {
1505
+ const pre = await this.opts.hookRunner.preToolUse(tool.name, use.input, ctx);
1506
+ if (pre.block) {
1507
+ const result = this.blockedByHookResult(use, pre.reason);
1508
+ budget = this.decrementBudget(result, budget);
1509
+ return { result, tool, durationMs: Date.now() - start };
1510
+ }
1511
+ if (pre.input) {
1512
+ const reval = validateAgainstSchema(pre.input, tool.inputSchema);
1513
+ if (!reval.ok) {
1514
+ const errorDetails = reval.errors.map((e) => ` - ${e.path || "input"}: ${e.message}`).join("\n");
1515
+ const result = {
1516
+ type: "tool_result",
1517
+ tool_use_id: use.id,
1518
+ content: `A PreToolUse hook rewrote the arguments for "${tool.name}" into an invalid shape.
1519
+
1520
+ Validation errors:
1521
+ ${errorDetails}`,
1522
+ is_error: true
1523
+ };
1524
+ budget = this.decrementBudget(result, budget);
1525
+ return { result, tool, durationMs: Date.now() - start };
1526
+ }
1527
+ use = { ...use, input: pre.input };
1528
+ }
1529
+ }
1503
1530
  const decision = await this.opts.permissionPolicy.evaluate(tool, use.input, ctx);
1504
1531
  let effectivePermission = decision.permission;
1505
1532
  const policy = this.opts.permissionPolicy;
1506
- const yolo = policy.getYolo?.() === true || policy.getForceAllYolo?.() === true;
1533
+ const yolo = policy.getYolo?.() === true || policy.getYoloDestructive?.() === true || policy.getForceAllYolo?.() === true;
1507
1534
  if (toolDangerousCaps.length > 0 && effectivePermission === "auto" && !yolo) {
1508
1535
  effectivePermission = "confirm";
1509
1536
  }
@@ -1546,7 +1573,20 @@ Please call the tool again with arguments that match its inputSchema. You can us
1546
1573
  "tool.has_dangerous_capabilities": toolCapsForAudit.length > 0
1547
1574
  });
1548
1575
  try {
1549
- const result = await this.executeTool(tool, use, ctx, budget);
1576
+ let result = await this.executeTool(tool, use, ctx, budget);
1577
+ if (this.opts.hookRunner?.has("PostToolUse")) {
1578
+ const post = await this.opts.hookRunner.postToolUse(
1579
+ tool.name,
1580
+ use.input,
1581
+ { content: String(result.content), isError: !!result.is_error },
1582
+ ctx
1583
+ );
1584
+ if (post.additionalContext) {
1585
+ result = { ...result, content: `${result.content}
1586
+
1587
+ ${post.additionalContext}` };
1588
+ }
1589
+ }
1550
1590
  budget = this.decrementBudget(result, budget);
1551
1591
  span?.setAttribute("tool.is_error", !!result.is_error);
1552
1592
  span?.setAttribute(
@@ -1735,6 +1775,14 @@ ${excerpt}`;
1735
1775
  is_error: true
1736
1776
  };
1737
1777
  }
1778
+ blockedByHookResult(use, reason) {
1779
+ return {
1780
+ type: "tool_result",
1781
+ tool_use_id: use.id,
1782
+ content: `Tool "${use.name}" was blocked by a PreToolUse hook: ${reason ?? "no reason given"}`,
1783
+ is_error: true
1784
+ };
1785
+ }
1738
1786
  decrementBudget(result, budget) {
1739
1787
  const contentBytes = typeof result.content === "string" ? Buffer.byteLength(result.content, "utf8") : Buffer.byteLength(JSON.stringify(result.content), "utf8");
1740
1788
  return Math.max(0, budget - contentBytes);
@@ -2544,7 +2592,8 @@ ${recentJournal}` : "No prior iterations.",
2544
2592
  " \u2022 When this iteration's Task is finished (real artifact / passing",
2545
2593
  " test / applied diff / clean output), emit `[done]` on its own line.",
2546
2594
  " \u2022 Do not stop on the first obstacle \u2014 try at least 3 distinct",
2547
- " approaches before giving up. YOLO is active; no confirmations.",
2595
+ " approaches before giving up. YOLO is active for normal project work;",
2596
+ " destructive-gated confirmations still belong to the permission flow.",
2548
2597
  "",
2549
2598
  "2. UPDATE TODO STATE (when Source is `todo`)",
2550
2599
  " \u2022 Mark this todo `in_progress` via the todos tool before tool work.",
@@ -6634,7 +6683,8 @@ ${recentJournal}` : "No prior iterations.",
6634
6683
  "\u2500\u2500 EXECUTION PROTOCOL \u2500\u2500",
6635
6684
  "\u2022 Execute the assigned task end-to-end using multiple tool calls.",
6636
6685
  "\u2022 Emit `[done]` on its own line when the task is complete.",
6637
- "\u2022 Do not ask for confirmation \u2014 YOLO is active.",
6686
+ "\u2022 Do not ask before routine in-project tool use \u2014 YOLO is active for normal project work.",
6687
+ "\u2022 If a destructive-gated confirmation appears, wait for the permission flow.",
6638
6688
  "\u2022 If the overall Mission is accomplished, emit `[GOAL_COMPLETE]` followed by a verification recipe.",
6639
6689
  "\u2022 Keep output concise \u2014 summarize findings, do not transcribe files."
6640
6690
  ].join("\n");
@@ -6891,8 +6941,10 @@ ${journalTail.join("\n")}` : "Recent journal: (none \u2014 this is the first ite
6891
6941
  " decide.",
6892
6942
  "",
6893
6943
  "### Operating principles",
6894
- "- YOLO is active. Do NOT ask for confirmation, do NOT propose",
6895
- " options. Pick the best path and execute it.",
6944
+ "- YOLO is active for normal project work. Proceed with routine",
6945
+ " in-project tool use without pre-confirming; pick the best path and execute it.",
6946
+ " If the permission system raises a destructive-gated confirmation, wait",
6947
+ " for that flow instead of trying to bypass it.",
6896
6948
  "- Use tools freely; multiple calls per turn are normal and expected.",
6897
6949
  "- When working on a todo, mark it `in_progress` via the todos tool",
6898
6950
  " before tool work and `completed` (or `cancelled` with a reason)",
@@ -7016,7 +7068,7 @@ var DefaultRetryPolicy = class {
7016
7068
  };
7017
7069
 
7018
7070
  // src/execution/error-handler.ts
7019
- var CONTEXT_OVERFLOW_RE = /context|too long|tokens/i;
7071
+ var CONTEXT_OVERFLOW_RE = /context|too long|tokens|exceeds the context window|context window/i;
7020
7072
  function buildRecoveryStrategies(opts) {
7021
7073
  return [
7022
7074
  {
@@ -7024,7 +7076,7 @@ function buildRecoveryStrategies(opts) {
7024
7076
  compactor: opts?.compactor,
7025
7077
  async attempt(err, ctx) {
7026
7078
  if (!(err instanceof ProviderError)) return null;
7027
- if (err.status !== 413 && !CONTEXT_OVERFLOW_RE.test(err.message)) return null;
7079
+ if (err.status !== 413 && !isContextOverflowError(err)) return null;
7028
7080
  if (this.compactor) {
7029
7081
  try {
7030
7082
  const report = await this.compactor.compact(ctx, { aggressive: true });
@@ -7058,6 +7110,14 @@ function buildRecoveryStrategies(opts) {
7058
7110
  ];
7059
7111
  }
7060
7112
  var DEFAULT_RECOVERY_STRATEGIES = buildRecoveryStrategies();
7113
+ function isContextOverflowError(err) {
7114
+ return CONTEXT_OVERFLOW_RE.test([
7115
+ err.message,
7116
+ err.body?.message,
7117
+ err.body?.type,
7118
+ err.body?.raw
7119
+ ].filter(Boolean).join("\n"));
7120
+ }
7061
7121
  var DefaultErrorHandler = class {
7062
7122
  strategies;
7063
7123
  constructor(strategies = DEFAULT_RECOVERY_STRATEGIES) {
@@ -7074,7 +7134,7 @@ var DefaultErrorHandler = class {
7074
7134
  if (err.status === 429) return { kind: "rate_limit", retryable: true };
7075
7135
  if (err.status === 529) return { kind: "overloaded", retryable: true };
7076
7136
  if (err.status >= 500) return { kind: "server", retryable: true };
7077
- if (err.status === 413 || CONTEXT_OVERFLOW_RE.test(err.message)) {
7137
+ if (err.status === 413 || isContextOverflowError(err)) {
7078
7138
  return { kind: "context_overflow", retryable: false };
7079
7139
  }
7080
7140
  if (err.status >= 400) return { kind: "client", retryable: false };