@wrongstack/core 0.306.4 → 0.307.0

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 (103) hide show
  1. package/dist/chronicle/index.js +957 -953
  2. package/dist/chronicle/metrics-ingest.d.ts +55 -0
  3. package/dist/chronicle/metrics-schema.d.ts +86 -0
  4. package/dist/chronicle/metrics-store.d.ts +5 -120
  5. package/dist/chronicle/project-server.js +1083 -1084
  6. package/dist/chronicle/sqlite-journal-quota.d.ts +39 -0
  7. package/dist/chronicle/sqlite-journal-schema.d.ts +25 -0
  8. package/dist/chronicle/sqlite-journal.d.ts +12 -177
  9. package/dist/coordination/agents/index.js +1738 -1690
  10. package/dist/coordination/agents/project-agent-capture.d.ts +48 -0
  11. package/dist/coordination/agents/project-agent-identity.d.ts +3 -129
  12. package/dist/coordination/agents/project-agent-roster.d.ts +17 -0
  13. package/dist/coordination/index.js +6011 -5894
  14. package/dist/coordination/mail-tools.d.ts +1 -1
  15. package/dist/coordination/mailbox-http-actor-query.d.ts +16 -0
  16. package/dist/coordination/mailbox-http-router.d.ts +0 -48
  17. package/dist/coordination/mailbox-http-sse.d.ts +12 -0
  18. package/dist/coordination/mailbox-message-types.d.ts +71 -0
  19. package/dist/coordination/mailbox-predicates.d.ts +13 -0
  20. package/dist/coordination/mailbox-project-server.js +1 -1
  21. package/dist/coordination/mailbox-session-sync.d.ts +8 -0
  22. package/dist/coordination/mailbox-types.d.ts +6 -793
  23. package/dist/core/agent-loop-context.d.ts +28 -0
  24. package/dist/core/agent-loop-detector.d.ts +25 -0
  25. package/dist/core/fallback-doctor.d.ts +72 -0
  26. package/dist/core/index.d.ts +1 -0
  27. package/dist/core/index.js +1159 -888
  28. package/dist/defaults/index.js +3579 -3545
  29. package/dist/execution/autonomy-brain-llm.d.ts +55 -0
  30. package/dist/execution/autonomy-brain.d.ts +3 -156
  31. package/dist/execution/compaction-budget.d.ts +38 -0
  32. package/dist/execution/compaction-core.d.ts +3 -170
  33. package/dist/execution/compaction-elision.d.ts +58 -0
  34. package/dist/execution/council-orchestrator-helpers.d.ts +39 -0
  35. package/dist/execution/council-orchestrator.d.ts +3 -42
  36. package/dist/execution/council-response-parser.d.ts +56 -0
  37. package/dist/execution/index.js +2415 -2443
  38. package/dist/execution/prompt-enhancer.js +11 -3
  39. package/dist/execution/tool-executor-guard.d.ts +18 -0
  40. package/dist/execution/tool-executor-runner.d.ts +12 -0
  41. package/dist/execution/tool-executor.d.ts +0 -75
  42. package/dist/goal/index.js +19 -6
  43. package/dist/hq/index.js +8 -2
  44. package/dist/index.d.ts +1 -0
  45. package/dist/index.js +7813 -7292
  46. package/dist/infrastructure/index.js +3 -1
  47. package/dist/kernel/events/agent-events.d.ts +2 -0
  48. package/dist/kernel/events/provider-events.d.ts +13 -0
  49. package/dist/plugin/index.js +2590 -2561
  50. package/dist/plugins/auto-review-config.d.ts +53 -0
  51. package/dist/plugins/auto-review-git.d.ts +19 -0
  52. package/dist/plugins/auto-review-plugin.d.ts +2 -140
  53. package/dist/plugins/review-finding-verification.d.ts +7 -0
  54. package/dist/prompts/index.d.ts +1 -0
  55. package/dist/prompts/prompt-journal.d.ts +94 -0
  56. package/dist/security/index.js +627 -652
  57. package/dist/security/permission-explain.d.ts +19 -0
  58. package/dist/security/permission-policy.d.ts +0 -101
  59. package/dist/security/yolo-risk.d.ts +5 -4
  60. package/dist/session-catalog/index.js +220 -212
  61. package/dist/session-catalog/project-server.js +227 -219
  62. package/dist/session-catalog/store-rebuild.d.ts +9 -0
  63. package/dist/session-catalog/store-schema.d.ts +48 -0
  64. package/dist/session-catalog/store.d.ts +0 -17
  65. package/dist/storage/director-state.d.ts +6 -0
  66. package/dist/storage/file-session-writer.d.ts +2 -58
  67. package/dist/storage/index.d.ts +2 -1
  68. package/dist/storage/index.js +2057 -1925
  69. package/dist/storage/orphan-lock-cleaner.d.ts +15 -0
  70. package/dist/storage/session-recovery.d.ts +9 -0
  71. package/dist/storage/session-store/rename-session.d.ts +16 -0
  72. package/dist/storage/session-store/resume-session.d.ts +26 -0
  73. package/dist/storage/session-store/session-store-clear.d.ts +11 -0
  74. package/dist/storage/session-store/session-store-index.d.ts +13 -0
  75. package/dist/storage/session-store.d.ts +1 -129
  76. package/dist/storage/session-summary-tracker.d.ts +39 -0
  77. package/dist/storage/session-write-buffer.d.ts +43 -0
  78. package/dist/storage/session-writer/session-writer-flush.d.ts +4 -0
  79. package/dist/storage/session-writer/session-writer-summary-tracker.d.ts +28 -0
  80. package/dist/tools/fallback-agent-model-assign-tool.d.ts +18 -0
  81. package/dist/tools/fallback-leader-model-set-tool.d.ts +18 -0
  82. package/dist/tools/fallback-manage-tools.d.ts +8 -45
  83. package/dist/tools/fallback-profile-manage-tool.d.ts +16 -0
  84. package/dist/tools/fallback-provider-key-set-tool.d.ts +17 -0
  85. package/dist/tools/fallback-provider-manage-tool.d.ts +26 -0
  86. package/dist/tools/index.js +5070 -5071
  87. package/dist/types/config/root.d.ts +7 -2
  88. package/dist/types/default-config.d.ts +1 -1
  89. package/dist/types/index.d.ts +54 -55
  90. package/dist/types/index.js +953 -932
  91. package/dist/types/runtime-capability-manifest.d.ts +5 -5
  92. package/dist/types/session-markers.d.ts +12 -0
  93. package/dist/types/session-markers.js +19 -0
  94. package/dist/worktree/worktree-manager.d.ts +1 -1
  95. package/instructions/coordination/subagent-baseline.md +2 -2
  96. package/instructions/llm/prompt-enhancer.md +2 -1
  97. package/instructions/sections/tool/common-patterns.md +21 -0
  98. package/instructions/sections/tool/delegation-compact.md +3 -1
  99. package/instructions/sections/tool/delegation-full.md +5 -1
  100. package/instructions/system-lite.md +28 -3
  101. package/instructions/system-pro.md +37 -8
  102. package/instructions/system.md +4 -2
  103. package/package.json +5 -5
@@ -0,0 +1,19 @@
1
+ import type { Context } from '../core/context.js';
2
+ import type { PermissionTrace, TrustPolicy } from '../types/permission.js';
3
+ import type { Tool } from '../types/tool.js';
4
+ export interface PermissionExplainContext {
5
+ policy: TrustPolicy;
6
+ policyInvalid: boolean;
7
+ wildcardEntries: {
8
+ pattern: string;
9
+ value: TrustPolicy[string];
10
+ }[];
11
+ sessionDenied: Map<string, boolean>;
12
+ sessionAllowed: Map<string, boolean>;
13
+ yolo: boolean;
14
+ promptDelegatePresent: boolean;
15
+ isSensitiveReadCall(tool: Tool, input: unknown): boolean;
16
+ yoloBlockedAsDestructive(tool: Tool, input: unknown, ctx: Context): boolean;
17
+ }
18
+ export declare function explainPermissionTrace(state: PermissionExplainContext, tool: Tool, input: unknown, ctx: Context): PermissionTrace;
19
+ //# sourceMappingURL=permission-explain.d.ts.map
@@ -8,11 +8,6 @@ export { alwaysAllowUnavailableReason, matchesTrust, matchesCommandTrust, hasShe
8
8
  export interface PermissionPolicyOptions {
9
9
  trustFile: string;
10
10
  yolo?: boolean | undefined;
11
- /**
12
- * Let YOLO auto-approve destructive shell commands too. Off by default: with
13
- * YOLO on, `rm -rf`, git history rewrites and external publishes still ask
14
- * (WS-008).
15
- */
16
11
  yoloDestructive?: boolean | undefined;
17
12
  promptDelegate?: (tool: Tool, input: unknown, suggestedPattern: string) => Promise<'yes' | 'no' | 'always' | 'deny'>;
18
13
  inputReader?: InputReader | undefined;
@@ -22,110 +17,22 @@ export declare class DefaultPermissionPolicy implements PermissionPolicy {
22
17
  private loaded;
23
18
  private readonly trustFile;
24
19
  private yolo;
25
- /**
26
- * Session-scoped "soft deny" map. When the user presses 'n' (block once),
27
- * the tool+pattern is added here. If the LLM retries in the same session,
28
- * we return deny directly without asking again.
29
- *
30
- * Cleared on reload() since reload = fresh trust file snapshot.
31
- */
32
20
  private sessionDenied;
33
- /**
34
- * Session-scoped one-shot "soft trust" map. When the user presses 'y', the
35
- * tool+pattern is added here so the immediate confirm re-run can proceed.
36
- * The entry is consumed on first use; future calls must ask again unless the
37
- * user chose persistent trust.
38
- *
39
- * Cleared on reload().
40
- */
41
21
  private sessionAllowed;
42
- /**
43
- * Interactive prompt delegate. When set, `evaluate()` calls it to get a
44
- * user decision synchronously (CLI REPL path). When cleared (TUI / WebUI),
45
- * `evaluate()` returns `confirm` so the caller can emit
46
- * `tool.confirm_needed` for the UI layer to handle.
47
- *
48
- * Mutable so the host can switch from CLI-prompt to event-driven
49
- * confirmation at runtime (e.g. when `--goal` forces TUI mode after
50
- * the agent was already constructed).
51
- */
52
22
  private promptDelegate?;
53
- /** Pre-compiled wildcard patterns — rebuilt on reload for O(1) lookup. */
54
23
  private wildcardEntries;
55
- /**
56
- * Evaluate-result cache. Keyed by `tool.name::subject::permissionFingerprint`
57
- * so repeated calls with the same tool+input skip namespace matching,
58
- * subject computation, and pattern matching (matchAny). The fingerprint
59
- * suffix covers the `Tool` fields `evaluate()` reads (`permission`,
60
- * `riskTier`, `mutating`, `capabilities`), so a tool redefined via
61
- * `ToolRegistry.wrap()` misses the cache instead of inheriting a stale
62
- * verdict.
63
- *
64
- * Cleared on any state change (reload, trust, deny, yolo toggle) because
65
- * the result depends on the full policy state. The write-tool smart-bypass
66
- * (step 7 in `evaluate()`) is not cached since `ctx.hasRead()` changes
67
- * dynamically within a session.
68
- *
69
- * P3 #17 (before-release.md): capped at 500 entries via LRU eviction. An
70
- * iteration that evaluates thousands of unique tool+subject combinations
71
- * (e.g. repeated `tool-help` or `bash` with different commands) can grow
72
- * the cache without bound. 500 is far more than any single iteration needs;
73
- * the LRU evicts the least-recently-used entries first.
74
- */
75
24
  private _evalCache;
76
25
  private policyDiagnostics;
77
26
  private policyInvalid;
78
- /**
79
- * When true, YOLO also auto-approves clearly destructive shell commands.
80
- *
81
- * WS-008: `isClearlyDestructiveBashCommand` was exported and heavily tested
82
- * but called from zero production modules, so YOLO returned `auto` for
83
- * everything — including `rm -rf`, git history rewrites, and external
84
- * publishes. The `'yolo_destructive'` decision source, the getter/setter on
85
- * PermissionPolicy, and the TUI branch that reads it all existed; only the
86
- * gate itself was missing. Defaults to false: destructive commands still ask,
87
- * even in YOLO.
88
- */
89
27
  private yoloDestructive;
90
28
  constructor(opts: PermissionPolicyOptions);
91
- /** Allow YOLO to cover destructive shell commands too (off by default). */
92
29
  setYoloDestructive(enabled: boolean): void;
93
- /** Whether YOLO currently extends to destructive shell commands. */
94
30
  getYoloDestructive(): boolean;
95
- /**
96
- * True when this call is an FS_WRITE whose target lands inside WrongStack's
97
- * own state root.
98
- *
99
- * FS_WRITE tools disagree on where the target path lives: write/edit use
100
- * `path`, replace/format/git `files` (string OR array), patch `directory`,
101
- * design `out`, scaffold writes under `cwd`/`template`. Checking only
102
- * `path`/`file_path` let a state-root write merely switch tools, so every
103
- * path-bearing key is inspected.
104
- *
105
- * Shared by the YOLO carve-out and the eval-cache guard so the two cannot
106
- * drift: the carve-out scans all path keys while the cache key fingerprints
107
- * only the subject key, so the cache must consult the same predicate or a
108
- * secondary state-root key can be replayed a cached `auto`.
109
- */
110
31
  private hasAgentStateWriteTarget;
111
- /**
112
- * True when YOLO is on but this specific call is a destructive shell command
113
- * the user has not opted to auto-approve. Shared by `evaluate()` and the
114
- * explain/trace path so the two cannot drift.
115
- */
116
32
  private yoloBlockedAsDestructive;
117
- /**
118
- * Replace (or clear) the interactive prompt delegate at runtime.
119
- * Used by the CLI to switch from inline prompts (REPL) to event-driven
120
- * confirmation (TUI) when the run mode is determined after the policy
121
- * was constructed (e.g. `--goal` auto-flipping to TUI).
122
- */
123
33
  setPromptDelegate(delegate: PermissionPolicyOptions['promptDelegate']): void;
124
- /** Toggle YOLO (auto-approve) mode at runtime. */
125
34
  setYolo(enabled: boolean): void;
126
- /** Check whether YOLO mode is currently active. */
127
35
  getYolo(): boolean;
128
- /** Read-only diagnostics for policy inspector/editor surfaces. */
129
36
  getPolicyDiagnostics(): readonly TrustPolicyDiagnostic[];
130
37
  reload(): Promise<void>;
131
38
  private _logDeny;
@@ -135,26 +42,18 @@ export declare class DefaultPermissionPolicy implements PermissionPolicy {
135
42
  tool: string;
136
43
  pattern: string;
137
44
  }): Promise<void>;
138
- /** Persist a deny rule — this tool+pattern pair is permanently blocked. */
139
45
  deny(rule: {
140
46
  tool: string;
141
47
  pattern: string;
142
48
  }): Promise<void>;
143
- /** Block this tool+pattern for the rest of this session (no trust file). */
144
49
  denyOnce(rule: {
145
50
  tool: string;
146
51
  pattern: string;
147
52
  }): void;
148
- /** Auto-approve this tool+pattern once (no trust file). */
149
53
  allowOnce(rule: {
150
54
  tool: string;
151
55
  pattern: string;
152
56
  }): void;
153
- /**
154
- * Side-effect-free permission evaluation trace. Mirrors `evaluate()`
155
- * step-by-step without prompting the user, writing to trust files, or
156
- * mutating session state. Returns the full ordered trace and winner.
157
- */
158
57
  explain(tool: Tool, input: unknown, ctx: Context): Promise<PermissionTrace>;
159
58
  private findNamespaceEntry;
160
59
  }
@@ -2,10 +2,11 @@ export declare function getInputString(input: unknown, key: string): string | un
2
2
  export declare function pathLooksInsideProject(rawPath: string, projectRoot: string | undefined): boolean;
3
3
  /**
4
4
  * Best-effort detection of a *catastrophic* shell command — system-/disk-/
5
- * home-wide, effectively irreversible destruction. `projectRoot` is accepted
6
- * for signature stability but is intentionally unused: catastrophic targets are
7
- * absolute (filesystem root, a drive root, the home directory, a system
8
- * directory) and so are independent of where the project lives.
5
+ * home-wide, effectively irreversible destruction, OR a write to WrongStack's
6
+ * own trusted state files that could disable security boundaries.
7
+ * `projectRoot` is accepted for signature stability but is intentionally
8
+ * unused for catastrophic targets (they are absolute). It is not used for
9
+ * state-root detection either (those paths are resolved absolutely).
9
10
  */
10
11
  export declare function isClearlyDestructiveBashCommand(command: string, projectRoot: string | undefined): boolean;
11
12
  //# sourceMappingURL=yolo-risk.d.ts.map