@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,48 @@
1
+ import { type ConsolidationMetadata } from './project-agent-consolidation.js';
2
+ import type { LearnedCaptureResult } from './project-agent-identity-types.js';
3
+ import { type ProjectAgentLearningPolicy } from './project-agent-learning-policy.js';
4
+ import { type StructuredLearnedEntry } from './project-agent-learning-structured.js';
5
+ export declare function loadProjectAgentLearned(role: string, projectRoot?: string): string;
6
+ export declare function listProjectAgentLearnedEntries(role: string, projectRoot?: string): string[];
7
+ export declare function parseStructuredLearnedEntries(role: string, projectRoot?: string): StructuredLearnedEntry[];
8
+ export declare function resolveCaptureKey(role: string, projectRoot?: string): string;
9
+ export declare function canCaptureNewLearned(role: string, _existingSize: number, isManual: boolean, projectRoot?: string): string | undefined;
10
+ export interface ProjectAgentLearnStats {
11
+ role: string;
12
+ exists: boolean;
13
+ entryCount: number;
14
+ totalBytes: number;
15
+ lastCapture: string | null;
16
+ lastCaptureTimestamp: number | null;
17
+ cooldownRemainingMs: number;
18
+ sessionCaptureCount: number;
19
+ needsSummarization: boolean;
20
+ learnedPath: string | null;
21
+ identityPath: string | null;
22
+ hasIdentity: boolean;
23
+ hasConfig: boolean;
24
+ hasKnowledge: boolean;
25
+ learningEnabled: boolean;
26
+ lifetimeCaptureCount: number;
27
+ lastCaptureSource: ProjectAgentLearningPolicy['lastCaptureSource'] | null;
28
+ isConsolidated: boolean;
29
+ consolidation?: ConsolidationMetadata | undefined;
30
+ skills: string[];
31
+ skilledEntryCount: number;
32
+ appliedEntryCount: number;
33
+ deadEntryCount: number;
34
+ directiveHitRate: number | null;
35
+ }
36
+ export declare function getProjectAgentLearnStats(role: string, projectRoot?: string): ProjectAgentLearnStats;
37
+ export declare function detectLearnedConflicts(projectRoot?: string): Array<{
38
+ roleA: string;
39
+ roleB: string;
40
+ snippetA: string;
41
+ snippetB: string;
42
+ similarity: number;
43
+ detectedAt: string;
44
+ }>;
45
+ export declare function captureLearnedFromAgentOutput(output: string, role: string, projectRoot?: string, isManual?: boolean): number;
46
+ export declare function captureLearnedFromAgentOutputDetailed(output: string, role: string, projectRoot?: string, isManual?: boolean): LearnedCaptureResult;
47
+ export declare function hintLearnedNeedsSummarization(role: string, projectRoot?: string): string;
48
+ //# sourceMappingURL=project-agent-capture.d.ts.map
@@ -18,12 +18,8 @@
18
18
  * knowledge.md — current-needs checklist (what versions to verify today)
19
19
  */
20
20
  import { existsSync } from 'node:fs';
21
- import type { SubagentConfig } from '../../types/multi-agent.js';
22
21
  import { CAPTURE_COOLDOWN_MS, CAPTURE_MAX_PER_SESSION } from './project-agent-capture-window.js';
23
- import { type ConsolidationMetadata } from './project-agent-consolidation.js';
24
- import type { LearnedCaptureResult, ProjectAgentConfig, RoleKnowledgeManifest } from './project-agent-identity-types.js';
25
- import { type ProjectAgentLearningPolicy } from './project-agent-learning-policy.js';
26
- import { type StructuredLearnedEntry } from './project-agent-learning-structured.js';
22
+ import type { RoleKnowledgeManifest } from './project-agent-identity-types.js';
27
23
  export { type AutoOptimizeDecision, type AutoOptimizeEvent, type AutoOptimizePolicy, type AutoOptimizePolicyOverrides, DEFAULT_AUTO_OPTIMIZE_POLICY, evaluateAutoOptimize, LearningOptimizationScheduler, type LearningOptimizationSchedulerOptions, resolveAutoOptimizePolicy, } from './project-agent-auto-optimize.js';
28
24
  export { CAPTURE_SESSION_WINDOW_MS, resetCaptureWindow, resetCaptureWindows, } from './project-agent-capture-window.js';
29
25
  export { loadProjectAgentConfig } from './project-agent-config-io.js';
@@ -42,26 +38,14 @@ export { buildSkillDistillInstruction, clearProjectSkillAugmentation, DEFAULT_EA
42
38
  export { CAPTURE_COOLDOWN_MS, CAPTURE_MAX_PER_SESSION };
43
39
  export { listProjectAgentRoles, refreshProjectAgentIdentity, resetProjectAgentIdentity, updateProjectAgentConfig, updateProjectAgentIdentity, updateProjectAgentKnowledge, updateProjectAgentLearned, } from './project-agent-files.js';
44
40
  export { createProjectAgent, loadProjectAgentProfile, slugifyProjectAgentRole, } from './project-agent-profile.js';
45
- /**
46
- * Live roster overlay. Project policy is resolved lazily for both built-in and
47
- * project-created roles, so WebUI changes take effect on the next spawn without
48
- * rebuilding the Director. Built-in roles keep their safety floors; custom
49
- * roles may opt into a deliberately narrow runtime.
50
- */
51
- export declare function createProjectAgentRoster(baseRoster: Record<string, SubagentConfig>, projectRoot?: string): Record<string, SubagentConfig>;
41
+ export { applyProjectAgentConfig, createProjectAgentRoster, } from './project-agent-roster.js';
42
+ export { canCaptureNewLearned, captureLearnedFromAgentOutput, captureLearnedFromAgentOutputDetailed, detectLearnedConflicts, getProjectAgentLearnStats, hintLearnedNeedsSummarization, listProjectAgentLearnedEntries, loadProjectAgentLearned, parseStructuredLearnedEntries, type ProjectAgentLearnStats, } from './project-agent-capture.js';
52
43
  /**
53
44
  * Load the project-level identity appendix for a given role.
54
45
  * Appended to the subagent prompt after the base role prompt and policy.
55
46
  * Returns the empty string when no identity file exists.
56
47
  */
57
48
  export declare function loadProjectAgentIdentity(role: string, projectRoot?: string): string;
58
- /**
59
- * Load the learning-derived wisdom for a given role.
60
- * Appended to the subagent prompt as a "knowledge from past sessions" block.
61
- * The learning file is auto-generated by the `memory-curator` or
62
- * `self-improving` agent roles and contains de-duplicated, curated findings.
63
- */
64
- export declare function loadProjectAgentLearned(role: string, projectRoot?: string): string;
65
49
  /**
66
50
  * Load the current-knowledge checklist for a given role.
67
51
  * Returns the built-in directive if no project override exists.
@@ -69,13 +53,6 @@ export declare function loadProjectAgentLearned(role: string, projectRoot?: stri
69
53
  * before answering questions in its domain.
70
54
  */
71
55
  export declare function loadRoleKnowledgeManifest(role: string, projectRoot?: string): RoleKnowledgeManifest | undefined;
72
- /**
73
- * Merge a project agent config onto a base `SubagentConfig`.
74
- * Returns a new config; does not mutate either input.
75
- */
76
- export declare function applyProjectAgentConfig(base: SubagentConfig, projectConfig: ProjectAgentConfig | undefined, options?: {
77
- protectSystemRole?: boolean | undefined;
78
- }): SubagentConfig;
79
56
  /**
80
57
  * Build the full project-contextualized prompt for a given role.
81
58
  *
@@ -89,108 +66,5 @@ export declare function applyProjectAgentConfig(base: SubagentConfig, projectCon
89
66
  export declare function buildProjectContextualizedPrompt(basePrompt: string, role: string, projectRoot?: string, options?: {
90
67
  identityOverride?: string | undefined;
91
68
  }): string;
92
- /**
93
- * Check whether a new capture is allowed for this role. Returns a rejection
94
- * reason string when blocked, or undefined when capture may proceed.
95
- *
96
- * `existingSize` is accepted for call-site compatibility but no longer gates
97
- * anything: an over-budget buffer is now trimmed at write time
98
- * (`enforceLearnedBudget`) instead of blocking every future capture. The old
99
- * size gate had no self-clearing path, so the roles with the most learning
100
- * were the ones that had silently stopped learning.
101
- */
102
- export declare function canCaptureNewLearned(role: string, _existingSize: number, isManual: boolean, projectRoot?: string): string | undefined;
103
- /**
104
- * Per-role learning stats for monitoring UIs.
105
- */
106
- export interface ProjectAgentLearnStats {
107
- role: string;
108
- exists: boolean;
109
- entryCount: number;
110
- totalBytes: number;
111
- lastCapture: string | null;
112
- lastCaptureTimestamp: number | null;
113
- cooldownRemainingMs: number;
114
- sessionCaptureCount: number;
115
- needsSummarization: boolean;
116
- learnedPath: string | null;
117
- identityPath: string | null;
118
- hasIdentity: boolean;
119
- hasConfig: boolean;
120
- hasKnowledge: boolean;
121
- learningEnabled: boolean;
122
- lifetimeCaptureCount: number;
123
- lastCaptureSource: ProjectAgentLearningPolicy['lastCaptureSource'] | null;
124
- /** Whether a consolidated document exists for this role. */
125
- isConsolidated: boolean;
126
- /** Consolidation metadata, if a consolidation has been performed. */
127
- consolidation?: ConsolidationMetadata | undefined;
128
- /** Skills this project has developed a dedicated addendum for. */
129
- skills: string[];
130
- /** Directives already routed to a skill and awaiting distillation. */
131
- skilledEntryCount: number;
132
- /**
133
- * How the buffer is actually performing, not just how big it is.
134
- *
135
- * `lifetimeCaptureCount` measures volume, which says nothing about whether
136
- * the role is learning the right things. These three do:
137
- * `provenEntryCount` is directives with a real track record, `deadEntryCount`
138
- * is directives that have never been exercised at all (a high share means the
139
- * agent is writing things nobody uses), and `directiveHitRate` is the share
140
- * of applications that ended in a successful task.
141
- */
142
- appliedEntryCount: number;
143
- deadEntryCount: number;
144
- /** `null` until at least one directive has been exercised. */
145
- directiveHitRate: number | null;
146
- }
147
- export declare function getProjectAgentLearnStats(role: string, projectRoot?: string): ProjectAgentLearnStats;
148
- /**
149
- * Re-export existsSync so callers can check file existence without importing fs.
150
- */
151
69
  export { existsSync };
152
- /**
153
- * Detect semantic conflicts between different roles' learned wisdom.
154
- * Returns entries where token overlap ≥ 0.60, which suggests the two
155
- * roles have learned about the same topic — potentially contradicting.
156
- */
157
- export declare function detectLearnedConflicts(projectRoot?: string): Array<{
158
- roleA: string;
159
- roleB: string;
160
- snippetA: string;
161
- snippetB: string;
162
- similarity: number;
163
- detectedAt: string;
164
- }>;
165
- export declare function listProjectAgentLearnedEntries(role: string, projectRoot?: string): string[];
166
- export declare function parseStructuredLearnedEntries(role: string, projectRoot?: string): StructuredLearnedEntry[];
167
- /**
168
- * Learned-wisdom capture from agent output.
169
- *
170
- * Scans `output` for `## LEARNED` blocks and persists each unique,
171
- * quality-passing block to the role's `learned.md`. Each block is run
172
- * through `normalizeLearnedEntry` so the buffer only accumulates instructive
173
- * directives — narrative session logs are rejected at capture time. Near-
174
- * duplicate entries (token overlap ≥ 0.55) are silently skipped.
175
- *
176
- * When the resulting file would exceed `LEARNED_HARD_LIMIT` (16 KB)
177
- * the oldest entries are rotated out before writing.
178
- *
179
- * @returns the number of **new** items actually persisted (0 if none).
180
- */
181
- export declare function captureLearnedFromAgentOutput(output: string, role: string, projectRoot?: string, isManual?: boolean): number;
182
- export declare function captureLearnedFromAgentOutputDetailed(output: string, role: string, projectRoot?: string, isManual?: boolean): LearnedCaptureResult;
183
- /**
184
- * Signal the host that a background summarisation pass is warranted.
185
- * Called by `captureLearnedFromAgentOutput` when the **new** learned size
186
- * crosses `LEARNED_SOFT_LIMIT`. The host is responsible for scheduling a
187
- * low-priority consolidation task (typically via the Brain or a shadow agent).
188
- *
189
- * The summary _mechanism_ is intentionally shallow here — the real
190
- * summarisation is an LLM call that should run as a deferred, uncritical
191
- * fleet task so it never blocks a user-facing operation.
192
- *
193
- * @returns a summary brief for the host, or '' when no action is needed.
194
- */
195
- export declare function hintLearnedNeedsSummarization(role: string, projectRoot?: string): string;
196
70
  //# sourceMappingURL=project-agent-identity.d.ts.map
@@ -0,0 +1,17 @@
1
+ import type { SubagentConfig } from '../../types/multi-agent.js';
2
+ import type { ProjectAgentConfig } from './project-agent-identity-types.js';
3
+ /**
4
+ * Merge a project agent config onto a base `SubagentConfig`.
5
+ * Returns a new config; does not mutate either input.
6
+ */
7
+ export declare function applyProjectAgentConfig(base: SubagentConfig, projectConfig: ProjectAgentConfig | undefined, options?: {
8
+ protectSystemRole?: boolean | undefined;
9
+ }): SubagentConfig;
10
+ /**
11
+ * Live roster overlay. Project policy is resolved lazily for both built-in and
12
+ * project-created roles, so WebUI changes take effect on the next spawn without
13
+ * rebuilding the Director. Built-in roles keep their safety floors; custom
14
+ * roles may opt into a deliberately narrow runtime.
15
+ */
16
+ export declare function createProjectAgentRoster(baseRoster: Record<string, SubagentConfig>, projectRoot?: string): Record<string, SubagentConfig>;
17
+ //# sourceMappingURL=project-agent-roster.d.ts.map