@wrongstack/core 0.291.0 → 0.291.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 (52) hide show
  1. package/dist/boot.d.ts.map +1 -1
  2. package/dist/chronicle/index.js +20 -1
  3. package/dist/chronicle/index.js.map +2 -2
  4. package/dist/chronicle/tool-adapter.d.ts.map +1 -1
  5. package/dist/coordination/director.d.ts +18 -0
  6. package/dist/coordination/director.d.ts.map +1 -1
  7. package/dist/coordination/fleet-spawn.d.ts.map +1 -1
  8. package/dist/coordination/index.js +37 -15
  9. package/dist/coordination/index.js.map +2 -2
  10. package/dist/core/agent-response.d.ts.map +1 -1
  11. package/dist/defaults/index.js +660 -391
  12. package/dist/defaults/index.js.map +4 -4
  13. package/dist/execution/index.js +61 -12
  14. package/dist/execution/index.js.map +3 -3
  15. package/dist/execution/tool-executor.d.ts.map +1 -1
  16. package/dist/hq/index.js +17 -0
  17. package/dist/hq/index.js.map +2 -2
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +1304 -882
  21. package/dist/index.js.map +4 -4
  22. package/dist/infrastructure/index.js +15 -10
  23. package/dist/infrastructure/index.js.map +2 -2
  24. package/dist/kernel/events/tool-events.d.ts +24 -0
  25. package/dist/kernel/events/tool-events.d.ts.map +1 -1
  26. package/dist/plugins/auto-review-plugin.d.ts +10 -0
  27. package/dist/plugins/auto-review-plugin.d.ts.map +1 -1
  28. package/dist/security/index.js +148 -0
  29. package/dist/security/index.js.map +3 -3
  30. package/dist/security/permission-policy.d.ts +8 -1
  31. package/dist/security/permission-policy.d.ts.map +1 -1
  32. package/dist/storage/config-loader.d.ts +8 -0
  33. package/dist/storage/config-loader.d.ts.map +1 -1
  34. package/dist/storage/index.js +457 -379
  35. package/dist/storage/index.js.map +4 -4
  36. package/dist/storage/provider-config-watcher.d.ts +6 -0
  37. package/dist/storage/provider-config-watcher.d.ts.map +1 -1
  38. package/dist/types/permission.d.ts +38 -0
  39. package/dist/types/permission.d.ts.map +1 -1
  40. package/dist/utils/config-backup.d.ts +20 -0
  41. package/dist/utils/config-backup.d.ts.map +1 -0
  42. package/dist/utils/index.d.ts +2 -1
  43. package/dist/utils/index.d.ts.map +1 -1
  44. package/dist/utils/index.js +172 -106
  45. package/dist/utils/index.js.map +4 -4
  46. package/dist/utils/message-invariants.d.ts +12 -9
  47. package/dist/utils/message-invariants.d.ts.map +1 -1
  48. package/dist/utils/term.d.ts +6 -0
  49. package/dist/utils/term.d.ts.map +1 -1
  50. package/dist/utils/wstack-paths.d.ts +10 -0
  51. package/dist/utils/wstack-paths.d.ts.map +1 -1
  52. package/package.json +2 -2
@@ -359,16 +359,6 @@ function deepEqual(a, b) {
359
359
  }
360
360
 
361
361
  // src/utils/message-invariants.ts
362
- function hasMeaningfulContent(content) {
363
- if (typeof content === "string") return content.trim().length > 0;
364
- return content.some((block) => {
365
- if (block.type === "text") return block.text.trim().length > 0;
366
- if (block.type === "thinking") {
367
- return block.thinking.trim().length > 0 || Boolean(block.signature);
368
- }
369
- return true;
370
- });
371
- }
372
362
  function repairToolUseAdjacency(messages) {
373
363
  const removedToolUses = [];
374
364
  const removedToolResults = [];
@@ -455,6 +445,21 @@ function mapContent(msg, fn) {
455
445
  }
456
446
  return { ...msg, content: next };
457
447
  }
448
+ function hasMeaningfulContent(content) {
449
+ if (typeof content === "string") return content.trim().length > 0;
450
+ for (const block of content) {
451
+ if (block.type === "text") {
452
+ if (block.text.trim().length > 0) return true;
453
+ continue;
454
+ }
455
+ if (block.type === "thinking") {
456
+ if (block.thinking.trim().length > 0 || block.signature) return true;
457
+ continue;
458
+ }
459
+ return true;
460
+ }
461
+ return false;
462
+ }
458
463
  function isEmptyMessage(msg) {
459
464
  return !hasMeaningfulContent(msg.content);
460
465
  }
@@ -1605,6 +1610,22 @@ function resolveWstackPaths(opts) {
1605
1610
  const safe = name.replace(/[/\\:]/g, "_").replace(/\.\./g, "_");
1606
1611
  return path2.join(globalRoot, "profiles", safe || "default", "config.json");
1607
1612
  },
1613
+ profileStatuslineConfig: (name) => {
1614
+ const safe = name.replace(/[/\\:]/g, "_").replace(/\.\./g, "_");
1615
+ return path2.join(globalRoot, "profiles", safe || "default", "statusline.json");
1616
+ },
1617
+ profileModeConfig: (name) => {
1618
+ const safe = name.replace(/[/\\:]/g, "_").replace(/\.\./g, "_");
1619
+ return path2.join(globalRoot, "profiles", safe || "default", "mode.json");
1620
+ },
1621
+ profileProviderStatus: (name) => {
1622
+ const safe = name.replace(/[/\\:]/g, "_").replace(/\.\./g, "_");
1623
+ return path2.join(globalRoot, "profiles", safe || "default", "provider-status.json");
1624
+ },
1625
+ profileUpdateCache: (name) => {
1626
+ const safe = name.replace(/[/\\:]/g, "_").replace(/\.\./g, "_");
1627
+ return path2.join(globalRoot, "profiles", safe || "default", "update-cache.json");
1628
+ },
1608
1629
  secretsKey: path2.join(globalRoot, ".key"),
1609
1630
  globalMemory: path2.join(globalRoot, "memory.md"),
1610
1631
  globalSkills: path2.join(globalRoot, "skills"),
@@ -1644,6 +1665,7 @@ function resolveWstackPaths(opts) {
1644
1665
  projectAutophase: path2.join(projectDir, "autophase"),
1645
1666
  projectSddBoards: path2.join(projectDir, "sdd-boards"),
1646
1667
  syncConfig: path2.join(globalRoot, "sync.json"),
1668
+ configHistoryDir: path2.join(globalRoot, "config-history"),
1647
1669
  projectStatus: (projectHash2) => path2.join(globalRoot, "projects", projectHash2, "status.json")
1648
1670
  };
1649
1671
  }
@@ -13293,7 +13315,7 @@ function readPolicy(ctx) {
13293
13315
  }
13294
13316
 
13295
13317
  // src/execution/tool-executor.ts
13296
- import { randomUUID as randomUUID3 } from "node:crypto";
13318
+ import { createHash as createHash2, randomUUID as randomUUID3 } from "node:crypto";
13297
13319
 
13298
13320
  // src/observability/process-telemetry.ts
13299
13321
  import { AsyncLocalStorage } from "node:async_hooks";
@@ -13708,12 +13730,30 @@ ${errorDetails}`,
13708
13730
  const policy = this.opts.permissionPolicy;
13709
13731
  const yolo = policy.getYolo?.() === true;
13710
13732
  const authoritativeAuto = decision.source === "yolo";
13711
- if (toolDangerousCaps.length > 0 && effectivePermission === "auto" && !yolo && !authoritativeAuto) {
13733
+ const capabilityDowngraded = toolDangerousCaps.length > 0 && effectivePermission === "auto" && !yolo && !authoritativeAuto;
13734
+ if (capabilityDowngraded) {
13712
13735
  effectivePermission = "confirm";
13713
13736
  }
13714
13737
  if (boundary.decision === "confirm" && effectivePermission !== "deny") {
13715
13738
  effectivePermission = "confirm";
13716
13739
  }
13740
+ this.opts.events?.emit("permission.evaluated", {
13741
+ sessionId: ctx.session.id,
13742
+ ...ctx.traceId ? { traceId: ctx.traceId } : {},
13743
+ ...ctx.agentId ? { agentId: ctx.agentId } : {},
13744
+ name: tool.name,
13745
+ id: use.id,
13746
+ inputHash: hashPermissionInput(use.input, this.opts.secretScrubber),
13747
+ policyDecision: decision.permission,
13748
+ effectiveDecision: effectivePermission,
13749
+ decisionSource: decision.source,
13750
+ ...decision.reason ? { reason: decision.reason } : {},
13751
+ ...decision.riskTier ?? tool.riskTier ? { riskTier: decision.riskTier ?? tool.riskTier } : {},
13752
+ yoloEnabled: yolo,
13753
+ boundaryDecision: boundary.decision,
13754
+ ...boundary.reason ? { boundaryReason: boundary.reason } : {},
13755
+ capabilityDowngraded
13756
+ });
13717
13757
  if (effectivePermission === "deny") {
13718
13758
  const result = this.deniedResult(use, decision.reason);
13719
13759
  budget = this.budgetForString(result.content, budget);
@@ -14395,6 +14435,15 @@ ${head}${TOOL_OUTPUT_ARTIFACT_OMISSION}${tail}`;
14395
14435
  return content;
14396
14436
  }
14397
14437
  }
14438
+ function hashPermissionInput(input, scrubber) {
14439
+ let serialized;
14440
+ try {
14441
+ serialized = JSON.stringify(input) ?? "";
14442
+ } catch {
14443
+ serialized = String(input);
14444
+ }
14445
+ return createHash2("sha256").update(scrubber.scrub(serialized), "utf8").digest("hex");
14446
+ }
14398
14447
  function sliceUtf8Prefix(text, maxBytes) {
14399
14448
  if (maxBytes <= 0) return "";
14400
14449
  if (Buffer.byteLength(text, "utf8") <= maxBytes) return text;