@yuaone/core 0.9.7 → 0.9.9

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 (193) hide show
  1. package/dist/__tests__/context-manager.test.js +5 -9
  2. package/dist/__tests__/context-manager.test.js.map +1 -1
  3. package/dist/agent-coordinator.d.ts +172 -0
  4. package/dist/agent-coordinator.d.ts.map +1 -0
  5. package/dist/agent-coordinator.js +390 -0
  6. package/dist/agent-coordinator.js.map +1 -0
  7. package/dist/agent-loop.d.ts +83 -29
  8. package/dist/agent-loop.d.ts.map +1 -1
  9. package/dist/agent-loop.js +697 -335
  10. package/dist/agent-loop.js.map +1 -1
  11. package/dist/agent-reputation.d.ts +72 -0
  12. package/dist/agent-reputation.d.ts.map +1 -0
  13. package/dist/agent-reputation.js +222 -0
  14. package/dist/agent-reputation.js.map +1 -0
  15. package/dist/arch-summarizer.d.ts +48 -0
  16. package/dist/arch-summarizer.d.ts.map +1 -0
  17. package/dist/arch-summarizer.js +239 -0
  18. package/dist/arch-summarizer.js.map +1 -0
  19. package/dist/autonomous/explicit-planner.d.ts +45 -0
  20. package/dist/autonomous/explicit-planner.d.ts.map +1 -0
  21. package/dist/autonomous/explicit-planner.js +99 -0
  22. package/dist/autonomous/explicit-planner.js.map +1 -0
  23. package/dist/autonomous/incident-debugger.d.ts +78 -0
  24. package/dist/autonomous/incident-debugger.d.ts.map +1 -0
  25. package/dist/autonomous/incident-debugger.js +324 -0
  26. package/dist/autonomous/incident-debugger.js.map +1 -0
  27. package/dist/autonomous/index.d.ts +15 -0
  28. package/dist/autonomous/index.d.ts.map +1 -0
  29. package/dist/autonomous/index.js +10 -0
  30. package/dist/autonomous/index.js.map +1 -0
  31. package/dist/autonomous/patch-tournament.d.ts +82 -0
  32. package/dist/autonomous/patch-tournament.d.ts.map +1 -0
  33. package/dist/autonomous/patch-tournament.js +150 -0
  34. package/dist/autonomous/patch-tournament.js.map +1 -0
  35. package/dist/autonomous/research-agent.d.ts +66 -0
  36. package/dist/autonomous/research-agent.d.ts.map +1 -0
  37. package/dist/autonomous/research-agent.js +210 -0
  38. package/dist/autonomous/research-agent.js.map +1 -0
  39. package/dist/autonomous/task-memory.d.ts +63 -0
  40. package/dist/autonomous/task-memory.d.ts.map +1 -0
  41. package/dist/autonomous/task-memory.js +143 -0
  42. package/dist/autonomous/task-memory.js.map +1 -0
  43. package/dist/budget-governor-v2.d.ts +93 -0
  44. package/dist/budget-governor-v2.d.ts.map +1 -0
  45. package/dist/budget-governor-v2.js +345 -0
  46. package/dist/budget-governor-v2.js.map +1 -0
  47. package/dist/capability-graph.d.ts +102 -0
  48. package/dist/capability-graph.d.ts.map +1 -0
  49. package/dist/capability-graph.js +397 -0
  50. package/dist/capability-graph.js.map +1 -0
  51. package/dist/capability-self-model.d.ts +144 -0
  52. package/dist/capability-self-model.d.ts.map +1 -0
  53. package/dist/capability-self-model.js +312 -0
  54. package/dist/capability-self-model.js.map +1 -0
  55. package/dist/checkpoint-manager.d.ts +94 -0
  56. package/dist/checkpoint-manager.d.ts.map +1 -0
  57. package/dist/checkpoint-manager.js +225 -0
  58. package/dist/checkpoint-manager.js.map +1 -0
  59. package/dist/continuation-engine.js +1 -1
  60. package/dist/continuation-engine.js.map +1 -1
  61. package/dist/dag-orchestrator.d.ts +0 -3
  62. package/dist/dag-orchestrator.d.ts.map +1 -1
  63. package/dist/dag-orchestrator.js +0 -1
  64. package/dist/dag-orchestrator.js.map +1 -1
  65. package/dist/evidence-chain.d.ts +99 -0
  66. package/dist/evidence-chain.d.ts.map +1 -0
  67. package/dist/evidence-chain.js +200 -0
  68. package/dist/evidence-chain.js.map +1 -0
  69. package/dist/execution-engine.d.ts.map +1 -1
  70. package/dist/execution-engine.js +0 -1
  71. package/dist/execution-engine.js.map +1 -1
  72. package/dist/failure-signature-memory.d.ts +61 -0
  73. package/dist/failure-signature-memory.d.ts.map +1 -0
  74. package/dist/failure-signature-memory.js +278 -0
  75. package/dist/failure-signature-memory.js.map +1 -0
  76. package/dist/index.d.ts +52 -5
  77. package/dist/index.d.ts.map +1 -1
  78. package/dist/index.js +48 -7
  79. package/dist/index.js.map +1 -1
  80. package/dist/language-detector.d.ts.map +1 -1
  81. package/dist/language-detector.js +122 -43
  82. package/dist/language-detector.js.map +1 -1
  83. package/dist/llm-client.d.ts +0 -7
  84. package/dist/llm-client.d.ts.map +1 -1
  85. package/dist/llm-client.js +15 -122
  86. package/dist/llm-client.js.map +1 -1
  87. package/dist/mcp-client.js +1 -1
  88. package/dist/mcp-client.js.map +1 -1
  89. package/dist/memory.d.ts.map +1 -1
  90. package/dist/memory.js +0 -15
  91. package/dist/memory.js.map +1 -1
  92. package/dist/meta-learning-collector.d.ts +64 -0
  93. package/dist/meta-learning-collector.d.ts.map +1 -0
  94. package/dist/meta-learning-collector.js +169 -0
  95. package/dist/meta-learning-collector.js.map +1 -0
  96. package/dist/meta-learning-engine.d.ts +61 -0
  97. package/dist/meta-learning-engine.d.ts.map +1 -0
  98. package/dist/meta-learning-engine.js +250 -0
  99. package/dist/meta-learning-engine.js.map +1 -0
  100. package/dist/overhead-governor.d.ts +105 -0
  101. package/dist/overhead-governor.d.ts.map +1 -0
  102. package/dist/overhead-governor.js +239 -0
  103. package/dist/overhead-governor.js.map +1 -0
  104. package/dist/playbook-library.d.ts +75 -0
  105. package/dist/playbook-library.d.ts.map +1 -0
  106. package/dist/playbook-library.js +241 -0
  107. package/dist/playbook-library.js.map +1 -0
  108. package/dist/project-executive.d.ts +97 -0
  109. package/dist/project-executive.d.ts.map +1 -0
  110. package/dist/project-executive.js +223 -0
  111. package/dist/project-executive.js.map +1 -0
  112. package/dist/research-loop.d.ts +79 -0
  113. package/dist/research-loop.d.ts.map +1 -0
  114. package/dist/research-loop.js +363 -0
  115. package/dist/research-loop.js.map +1 -0
  116. package/dist/resolve-memory-path.d.ts +32 -0
  117. package/dist/resolve-memory-path.d.ts.map +1 -0
  118. package/dist/resolve-memory-path.js +97 -0
  119. package/dist/resolve-memory-path.js.map +1 -0
  120. package/dist/safe-bounds.d.ts +101 -0
  121. package/dist/safe-bounds.d.ts.map +1 -0
  122. package/dist/safe-bounds.js +140 -0
  123. package/dist/safe-bounds.js.map +1 -0
  124. package/dist/sandbox-tiers.d.ts +5 -0
  125. package/dist/sandbox-tiers.d.ts.map +1 -1
  126. package/dist/sandbox-tiers.js +14 -6
  127. package/dist/sandbox-tiers.js.map +1 -1
  128. package/dist/security.d.ts.map +1 -1
  129. package/dist/security.js +3 -0
  130. package/dist/security.js.map +1 -1
  131. package/dist/self-improvement-loop.d.ts +64 -0
  132. package/dist/self-improvement-loop.d.ts.map +1 -0
  133. package/dist/self-improvement-loop.js +156 -0
  134. package/dist/self-improvement-loop.js.map +1 -0
  135. package/dist/session-persistence.d.ts +5 -0
  136. package/dist/session-persistence.d.ts.map +1 -1
  137. package/dist/session-persistence.js +19 -3
  138. package/dist/session-persistence.js.map +1 -1
  139. package/dist/skill-loader.d.ts +16 -9
  140. package/dist/skill-loader.d.ts.map +1 -1
  141. package/dist/skill-loader.js +52 -116
  142. package/dist/skill-loader.js.map +1 -1
  143. package/dist/skill-registry.d.ts +60 -0
  144. package/dist/skill-registry.d.ts.map +1 -0
  145. package/dist/skill-registry.js +162 -0
  146. package/dist/skill-registry.js.map +1 -0
  147. package/dist/stall-detector.d.ts +56 -0
  148. package/dist/stall-detector.d.ts.map +1 -0
  149. package/dist/stall-detector.js +142 -0
  150. package/dist/stall-detector.js.map +1 -0
  151. package/dist/strategy-learner.d.ts +57 -0
  152. package/dist/strategy-learner.d.ts.map +1 -0
  153. package/dist/strategy-learner.js +160 -0
  154. package/dist/strategy-learner.js.map +1 -0
  155. package/dist/strategy-market.d.ts +73 -0
  156. package/dist/strategy-market.d.ts.map +1 -0
  157. package/dist/strategy-market.js +200 -0
  158. package/dist/strategy-market.js.map +1 -0
  159. package/dist/sub-agent.d.ts +0 -3
  160. package/dist/sub-agent.d.ts.map +1 -1
  161. package/dist/sub-agent.js +0 -10
  162. package/dist/sub-agent.js.map +1 -1
  163. package/dist/system-prompt.d.ts +0 -2
  164. package/dist/system-prompt.d.ts.map +1 -1
  165. package/dist/system-prompt.js +97 -490
  166. package/dist/system-prompt.js.map +1 -1
  167. package/dist/task-classifier.d.ts.map +1 -1
  168. package/dist/task-classifier.js +2 -54
  169. package/dist/task-classifier.js.map +1 -1
  170. package/dist/tool-synthesizer.d.ts +149 -0
  171. package/dist/tool-synthesizer.d.ts.map +1 -0
  172. package/dist/tool-synthesizer.js +455 -0
  173. package/dist/tool-synthesizer.js.map +1 -0
  174. package/dist/trace-pattern-extractor.d.ts +76 -0
  175. package/dist/trace-pattern-extractor.d.ts.map +1 -0
  176. package/dist/trace-pattern-extractor.js +321 -0
  177. package/dist/trace-pattern-extractor.js.map +1 -0
  178. package/dist/trace-recorder.d.ts +38 -0
  179. package/dist/trace-recorder.d.ts.map +1 -0
  180. package/dist/trace-recorder.js +94 -0
  181. package/dist/trace-recorder.js.map +1 -0
  182. package/dist/trust-economics.d.ts +50 -0
  183. package/dist/trust-economics.d.ts.map +1 -0
  184. package/dist/trust-economics.js +148 -0
  185. package/dist/trust-economics.js.map +1 -0
  186. package/dist/types.d.ts +272 -3
  187. package/dist/types.d.ts.map +1 -1
  188. package/dist/types.js.map +1 -1
  189. package/dist/yuan-md-loader.d.ts +22 -0
  190. package/dist/yuan-md-loader.d.ts.map +1 -0
  191. package/dist/yuan-md-loader.js +75 -0
  192. package/dist/yuan-md-loader.js.map +1 -0
  193. package/package.json +1 -1
@@ -0,0 +1,363 @@
1
+ /**
2
+ * @module research-loop
3
+ * @description Hypothesis-driven engineering research loop.
4
+ *
5
+ * Takes a problem statement, generates hypotheses (template-based, no LLM),
6
+ * searches code/docs via a caller-supplied searchFn, evaluates evidence,
7
+ * and produces a strategy recommendation.
8
+ *
9
+ * Loop:
10
+ * problem → hypotheses → search (code/docs) → evaluate evidence → update strategy
11
+ *
12
+ * Constraints:
13
+ * - ESM only (no require())
14
+ * - No LLM calls — purely structural, deterministic
15
+ * - Atomic writes (.tmp → renameSync)
16
+ * - All errors caught — never blocks
17
+ * - Emits agent:research_session_complete on completion
18
+ */
19
+ import { EventEmitter } from "node:events";
20
+ import { randomUUID } from "node:crypto";
21
+ import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync, } from "node:fs";
22
+ import { homedir } from "node:os";
23
+ import { join } from "node:path";
24
+ /** Playbook name mapping from conclusion keywords */
25
+ const STRATEGY_PLAYBOOK = [
26
+ { keywords: ["error", "fail", "crash", "exception", "throw"], strategy: "error-diagnosis-playbook" },
27
+ { keywords: ["import", "dependency", "module", "require", "resolve"], strategy: "dependency-resolution-playbook" },
28
+ { keywords: ["config", "configuration", "mismatch", "env", "environment"], strategy: "configuration-audit-playbook" },
29
+ { keywords: ["slow", "perf", "performance", "timeout", "latency", "bottleneck"], strategy: "performance-profiling-playbook" },
30
+ { keywords: ["algorithm", "inefficient", "complexity", "loop", "iteration"], strategy: "algorithm-optimization-playbook" },
31
+ { keywords: ["contention", "resource", "lock", "concurrency", "race"], strategy: "concurrency-analysis-playbook" },
32
+ { keywords: ["test", "assert", "logic", "contract", "expect"], strategy: "test-logic-review-playbook" },
33
+ { keywords: ["missing", "implement", "stub", "not found", "undefined"], strategy: "implementation-scaffold-playbook" },
34
+ { keywords: ["interface", "type", "signature", "mismatch", "incompatible"], strategy: "interface-alignment-playbook" },
35
+ { keywords: ["state", "corruption", "inconsistent", "mutation", "side effect"], strategy: "state-audit-playbook" },
36
+ ];
37
+ const DEFAULT_STRATEGY = "general-investigation-playbook";
38
+ const MAX_STORED_SESSIONS = 100;
39
+ const SNIPPET_TRUNCATE = 300;
40
+ const HYPOTHESIS_TEMPLATES = [
41
+ {
42
+ keywords: ["error", "fail", "crash", "exception", "throw", "broke"],
43
+ statements: [
44
+ "Root cause is a runtime error in the problem domain",
45
+ "Dependency or import is missing or incompatible",
46
+ "Configuration is mismatched between environments",
47
+ ],
48
+ },
49
+ {
50
+ keywords: ["slow", "perf", "performance", "timeout", "latency", "speed"],
51
+ statements: [
52
+ "Bottleneck exists in a hot code path",
53
+ "Algorithm or data structure choice is inefficient",
54
+ "Resource contention or blocking I/O is the limiting factor",
55
+ ],
56
+ },
57
+ {
58
+ keywords: ["test", "spec", "assert", "failing", "jest", "vitest", "mocha"],
59
+ statements: [
60
+ "Logic error exists in the implementation being tested",
61
+ "Test environment or setup is misconfigured",
62
+ "Contract between caller and implementation is violated",
63
+ ],
64
+ },
65
+ ];
66
+ const DEFAULT_HYPOTHESES = [
67
+ "Required implementation is missing or incomplete",
68
+ "Interface or type contract is mismatched",
69
+ "State corruption or unexpected mutation is occurring",
70
+ ];
71
+ function generateHypotheses(problem) {
72
+ const lower = problem.toLowerCase();
73
+ // Find first matching template
74
+ let statements = DEFAULT_HYPOTHESES;
75
+ for (const template of HYPOTHESIS_TEMPLATES) {
76
+ if (template.keywords.some((kw) => lower.includes(kw))) {
77
+ statements = template.statements;
78
+ break;
79
+ }
80
+ }
81
+ return statements.map((stmt) => ({
82
+ id: randomUUID(),
83
+ statement: stmt,
84
+ confidence: 0.3, // start with low prior
85
+ supportingEvidence: [],
86
+ contradictingEvidence: [],
87
+ status: "active",
88
+ }));
89
+ }
90
+ // ─── Query generation from hypothesis ────────────────────────────────────────
91
+ function hypothesisToQuery(hypothesis, problem) {
92
+ // Extract the most specific noun phrases from hypothesis + first 6 words of problem
93
+ const problemWords = problem
94
+ .split(/\s+/)
95
+ .filter((w) => w.length > 3)
96
+ .slice(0, 6)
97
+ .join(" ");
98
+ return `${hypothesis.statement} ${problemWords}`.slice(0, 120);
99
+ }
100
+ // ─── Evidence evaluation ──────────────────────────────────────────────────────
101
+ /** Extract keywords from a hypothesis statement (words >3 chars, no stopwords) */
102
+ function hypothesisKeywords(statement) {
103
+ const STOPWORDS = new Set([
104
+ "root", "cause", "error", "code", "path", "that", "this", "from",
105
+ "into", "when", "where", "with", "have", "been", "will", "does",
106
+ "between", "missing", "existing", "problem", "domain",
107
+ ]);
108
+ return statement
109
+ .toLowerCase()
110
+ .split(/\W+/)
111
+ .filter((w) => w.length > 3 && !STOPWORDS.has(w));
112
+ }
113
+ /** Evaluate snippets against a hypothesis; update confidence and evidence */
114
+ function evaluateEvidence(hypothesis, snippets, query) {
115
+ const keywords = hypothesisKeywords(hypothesis.statement);
116
+ const queryKeywords = query
117
+ .toLowerCase()
118
+ .split(/\W+/)
119
+ .filter((w) => w.length > 3)
120
+ .slice(0, 8);
121
+ const allKeywords = Array.from(new Set([...keywords, ...queryKeywords]));
122
+ for (const snippet of snippets) {
123
+ const lower = snippet.toLowerCase();
124
+ const hits = allKeywords.filter((kw) => lower.includes(kw)).length;
125
+ const hitRatio = allKeywords.length > 0 ? hits / allKeywords.length : 0;
126
+ if (hitRatio >= 0.25) {
127
+ // Supporting evidence: snippet contains ≥25% of keywords
128
+ const truncated = snippet.slice(0, SNIPPET_TRUNCATE);
129
+ if (!hypothesis.supportingEvidence.includes(truncated)) {
130
+ hypothesis.supportingEvidence.push(truncated);
131
+ hypothesis.confidence = Math.min(1.0, hypothesis.confidence + 0.2);
132
+ }
133
+ }
134
+ else if (hitRatio === 0 && snippet.length > 30) {
135
+ // Contradicting evidence: snippet is non-trivial but has no keyword overlap
136
+ const truncated = snippet.slice(0, SNIPPET_TRUNCATE);
137
+ if (hypothesis.contradictingEvidence.length < 3 &&
138
+ !hypothesis.contradictingEvidence.includes(truncated)) {
139
+ hypothesis.contradictingEvidence.push(truncated);
140
+ hypothesis.confidence = Math.max(0.0, hypothesis.confidence - 0.1);
141
+ }
142
+ }
143
+ }
144
+ }
145
+ // ─── Strategy selection from conclusion ──────────────────────────────────────
146
+ function selectStrategy(conclusion) {
147
+ const lower = conclusion.toLowerCase();
148
+ for (const entry of STRATEGY_PLAYBOOK) {
149
+ if (entry.keywords.some((kw) => lower.includes(kw))) {
150
+ return entry.strategy;
151
+ }
152
+ }
153
+ return DEFAULT_STRATEGY;
154
+ }
155
+ // ─── Conclusion generation ────────────────────────────────────────────────────
156
+ function buildConclusion(hypotheses) {
157
+ const sorted = [...hypotheses].sort((a, b) => b.confidence - a.confidence);
158
+ const top = sorted[0];
159
+ if (!top)
160
+ return "No hypothesis reached sufficient confidence.";
161
+ const evidence = top.supportingEvidence.length;
162
+ const contra = top.contradictingEvidence.length;
163
+ if (top.confidence >= 0.75) {
164
+ return `High confidence: ${top.statement}. Supported by ${evidence} evidence snippet(s), ${contra} contradicting.`;
165
+ }
166
+ else if (top.confidence >= 0.5) {
167
+ return `Moderate confidence: ${top.statement}. Supported by ${evidence} evidence snippet(s), ${contra} contradicting. Further investigation recommended.`;
168
+ }
169
+ else {
170
+ return `Low confidence (${(top.confidence * 100).toFixed(0)}%): ${top.statement}. Insufficient evidence found. Manual review required.`;
171
+ }
172
+ }
173
+ // ─── Storage helpers ──────────────────────────────────────────────────────────
174
+ function defaultStorageDir() {
175
+ return join(homedir(), ".yuan", "research");
176
+ }
177
+ function sessionsFilePath(storageDir) {
178
+ return join(storageDir, "sessions.json");
179
+ }
180
+ function loadSessions(storageDir) {
181
+ const file = sessionsFilePath(storageDir);
182
+ if (!existsSync(file))
183
+ return [];
184
+ try {
185
+ const raw = readFileSync(file, "utf8");
186
+ const parsed = JSON.parse(raw);
187
+ return Array.isArray(parsed.sessions) ? parsed.sessions : [];
188
+ }
189
+ catch {
190
+ return [];
191
+ }
192
+ }
193
+ function saveSessions(storageDir, sessions) {
194
+ try {
195
+ mkdirSync(storageDir, { recursive: true });
196
+ const capped = sessions.slice(-MAX_STORED_SESSIONS);
197
+ const file = sessionsFilePath(storageDir);
198
+ const tmp = file + ".tmp";
199
+ writeFileSync(tmp, JSON.stringify({ sessions: capped }, null, 2), "utf8");
200
+ renameSync(tmp, file);
201
+ }
202
+ catch {
203
+ // Non-fatal: storage failure should not crash the loop
204
+ }
205
+ }
206
+ // ─── Similarity helpers ───────────────────────────────────────────────────────
207
+ /** Naive word-overlap similarity between two strings, 0..1 */
208
+ function similarity(a, b) {
209
+ const wordsA = new Set(a.toLowerCase().split(/\W+/).filter((w) => w.length > 3));
210
+ const wordsB = new Set(b.toLowerCase().split(/\W+/).filter((w) => w.length > 3));
211
+ if (wordsA.size === 0 || wordsB.size === 0)
212
+ return 0;
213
+ let intersection = 0;
214
+ for (const w of wordsA) {
215
+ if (wordsB.has(w))
216
+ intersection++;
217
+ }
218
+ return intersection / Math.max(wordsA.size, wordsB.size);
219
+ }
220
+ // ─── ResearchLoop ─────────────────────────────────────────────────────────────
221
+ export class ResearchLoop extends EventEmitter {
222
+ maxIterations;
223
+ minConfidenceToStop;
224
+ storageDir;
225
+ sessions;
226
+ constructor(config = {}) {
227
+ super();
228
+ this.maxIterations = config.maxIterations ?? 5;
229
+ this.minConfidenceToStop = config.minConfidenceToStop ?? 0.75;
230
+ this.storageDir = config.storageDir ?? defaultStorageDir();
231
+ this.sessions = loadSessions(this.storageDir);
232
+ }
233
+ /**
234
+ * Run a hypothesis-driven research session for the given problem.
235
+ * - Generates 2-3 initial hypotheses (template-based, no LLM)
236
+ * - For each iteration, selects the lowest-confidence hypothesis, generates
237
+ * a search query, calls searchFn for "code" and "docs", evaluates evidence
238
+ * - Stops early when minConfidenceToStop is reached
239
+ * - Returns completed ResearchSession with conclusion + recommendedStrategy
240
+ * - Emits agent:research_session_complete on completion
241
+ */
242
+ async research(problem, searchFn, sessionId) {
243
+ const id = sessionId ?? randomUUID();
244
+ const startedAt = new Date().toISOString();
245
+ const hypotheses = generateHypotheses(problem);
246
+ const searchResults = [];
247
+ let iterations = 0;
248
+ let stoppedEarly = false;
249
+ for (let i = 0; i < this.maxIterations; i++) {
250
+ iterations++;
251
+ // Select hypothesis with lowest confidence and fewest evidence
252
+ const active = hypotheses.filter((h) => h.status === "active");
253
+ if (active.length === 0)
254
+ break;
255
+ const target = active.reduce((best, h) => {
256
+ const score = h.confidence + h.supportingEvidence.length * 0.05;
257
+ const bestScore = best.confidence + best.supportingEvidence.length * 0.05;
258
+ return score < bestScore ? h : best;
259
+ });
260
+ // Generate search query
261
+ const query = hypothesisToQuery(target, problem);
262
+ // Search code and docs (errors are non-fatal)
263
+ for (const source of ["code", "docs"]) {
264
+ let snippets = [];
265
+ try {
266
+ snippets = await searchFn(query, source);
267
+ }
268
+ catch {
269
+ snippets = [];
270
+ }
271
+ if (snippets.length > 0) {
272
+ searchResults.push({
273
+ query,
274
+ source,
275
+ snippets: snippets.slice(0, 10),
276
+ timestamp: new Date().toISOString(),
277
+ });
278
+ }
279
+ // Evaluate evidence against all active hypotheses
280
+ for (const hyp of active) {
281
+ evaluateEvidence(hyp, snippets, query);
282
+ }
283
+ }
284
+ // Check early stop: any hypothesis reached minConfidenceToStop?
285
+ const confident = hypotheses.find((h) => h.confidence >= this.minConfidenceToStop);
286
+ if (confident) {
287
+ confident.status = "confirmed";
288
+ stoppedEarly = true;
289
+ break;
290
+ }
291
+ }
292
+ // Finalize hypothesis statuses
293
+ for (const h of hypotheses) {
294
+ if (h.status === "active") {
295
+ if (h.confidence >= this.minConfidenceToStop) {
296
+ h.status = "confirmed";
297
+ }
298
+ else if (h.confidence <= 0.1) {
299
+ h.status = "rejected";
300
+ }
301
+ else {
302
+ h.status = "inconclusive";
303
+ }
304
+ }
305
+ }
306
+ const conclusion = buildConclusion(hypotheses);
307
+ const recommendedStrategy = selectStrategy(conclusion);
308
+ const topConfidence = Math.max(...hypotheses.map((h) => h.confidence));
309
+ const completedAt = new Date().toISOString();
310
+ const session = {
311
+ id,
312
+ problem,
313
+ hypotheses,
314
+ searchResults,
315
+ conclusion,
316
+ recommendedStrategy,
317
+ confidence: Math.round(topConfidence * 100) / 100,
318
+ iterations,
319
+ startedAt,
320
+ completedAt,
321
+ };
322
+ // Persist (atomic write, non-fatal on failure)
323
+ this.sessions.push(session);
324
+ saveSessions(this.storageDir, this.sessions);
325
+ // Emit completion event
326
+ this.emit("event", {
327
+ kind: "agent:research_session_complete",
328
+ sessionId: id,
329
+ problem,
330
+ conclusion,
331
+ recommendedStrategy,
332
+ confidence: session.confidence,
333
+ iterations,
334
+ stoppedEarly,
335
+ timestamp: completedAt,
336
+ });
337
+ return session;
338
+ }
339
+ /**
340
+ * Return all research sessions loaded from storage (+ any run in this instance).
341
+ */
342
+ getSessions() {
343
+ return [...this.sessions];
344
+ }
345
+ /**
346
+ * Find the most relevant past session for a given problem using word-overlap
347
+ * similarity. Returns null if no session has similarity ≥ 0.3.
348
+ */
349
+ findRelevant(problem) {
350
+ const SIMILARITY_THRESHOLD = 0.3;
351
+ let best = null;
352
+ let bestScore = 0;
353
+ for (const session of this.sessions) {
354
+ const score = similarity(problem, session.problem);
355
+ if (score > bestScore) {
356
+ bestScore = score;
357
+ best = session;
358
+ }
359
+ }
360
+ return bestScore >= SIMILARITY_THRESHOLD ? best : null;
361
+ }
362
+ }
363
+ //# sourceMappingURL=research-loop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"research-loop.js","sourceRoot":"","sources":["../src/research-loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,UAAU,EACV,SAAS,EACT,YAAY,EACZ,UAAU,EACV,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AA8CjC,qDAAqD;AACrD,MAAM,iBAAiB,GAAoD;IACzE,EAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,0BAA0B,EAAE;IACpG,EAAE,QAAQ,EAAE,CAAC,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,QAAQ,EAAE,gCAAgC,EAAE;IAClH,EAAE,QAAQ,EAAE,CAAC,QAAQ,EAAE,eAAe,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AS;YACT,WAAW;SACZ,CAAC;QAEF,+CAA+C;QAC/C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5B,YAAY,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QAE7C,wBAAwB;QACxB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,IAAI,EAAE,iCAAiC;YACvC,SAAS,EAAE,EAAE;YACb,OAAO;YACP,UAAU;YACV,mBAAmB;YACnB,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,UAAU;YACV,YAAY;YACZ,SAAS,EAAE,WAAW;SACvB,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,YAAY,CAAC,OAAe;QAC1B,MAAM,oBAAoB,GAAG,GAAG,CAAC;QACjC,IAAI,IAAI,GAA2B,IAAI,CAAC;QACxC,IAAI,SAAS,GAAG,CAAC,CAAC;QAElB,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACpC,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;YACnD,IAAI,KAAK,GAAG,SAAS,EAAE,CAAC;gBACtB,SAAS,GAAG,KAAK,CAAC;gBAClB,IAAI,GAAG,OAAO,CAAC;YACjB,CAAC;QACH,CAAC;QAED,OAAO,SAAS,IAAI,oBAAoB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACzD,CAAC;CACF"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @module resolve-memory-path
3
+ * @description Cross-platform, security-isolated memory path resolver.
4
+ *
5
+ * - Per-user isolation: uses os.userInfo().username for user-scoped subdirectories.
6
+ * - Platform detection: Windows (%APPDATA%), macOS (~/Library/Application Support), Linux (~/.yuan).
7
+ * - Cloud infrastructure detection: GCP, Azure, Oracle, Cloud Run.
8
+ * - Project-scoped path: <projectPath>/.yuan/ for project-level files.
9
+ * - Unix directory permissions: 0o700 (owner-only) for user-level dirs.
10
+ */
11
+ export interface MemoryPaths {
12
+ userBase: string;
13
+ isCloud: boolean;
14
+ platform: "windows" | "macos" | "linux" | "cloud";
15
+ }
16
+ /**
17
+ * Returns the user-level base memory directory and creates it with 0o700 permissions.
18
+ * Path is user-scoped to prevent cross-user data leakage.
19
+ */
20
+ export declare function resolveUserMemoryBase(): MemoryPaths;
21
+ /**
22
+ * Returns the project-scoped memory base directory path.
23
+ * Does NOT create the directory — caller is responsible.
24
+ */
25
+ export declare function resolveProjectMemoryBase(projectPath: string): string;
26
+ /**
27
+ * Resolves a memory file path.
28
+ * If projectPath is given, returns the project-scoped path.
29
+ * Otherwise returns the user-level path (and ensures the user base dir exists).
30
+ */
31
+ export declare function resolveMemoryFile(filename: string, projectPath?: string): string;
32
+ //# sourceMappingURL=resolve-memory-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-memory-path.d.ts","sourceRoot":"","sources":["../src/resolve-memory-path.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;CACnD;AAuBD;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,WAAW,CAwCnD;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAEpE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAMhF"}
@@ -0,0 +1,97 @@
1
+ /**
2
+ * @module resolve-memory-path
3
+ * @description Cross-platform, security-isolated memory path resolver.
4
+ *
5
+ * - Per-user isolation: uses os.userInfo().username for user-scoped subdirectories.
6
+ * - Platform detection: Windows (%APPDATA%), macOS (~/Library/Application Support), Linux (~/.yuan).
7
+ * - Cloud infrastructure detection: GCP, Azure, Oracle, Cloud Run.
8
+ * - Project-scoped path: <projectPath>/.yuan/ for project-level files.
9
+ * - Unix directory permissions: 0o700 (owner-only) for user-level dirs.
10
+ */
11
+ import { homedir, userInfo, platform } from "node:os";
12
+ import { join } from "node:path";
13
+ import { mkdirSync, accessSync, constants } from "node:fs";
14
+ /** Detect cloud infrastructure via environment variables. */
15
+ function detectCloud() {
16
+ return !!(process.env["CLOUD_SHELL"] ||
17
+ process.env["GOOGLE_CLOUD_PROJECT"] ||
18
+ process.env["AZURE_SUBSCRIPTION_ID"] ||
19
+ process.env["OCI_RESOURCE_PRINCIPAL_VERSION"] ||
20
+ process.env["K_SERVICE"]);
21
+ }
22
+ /** Check if a directory is writable. */
23
+ function isWritable(dirPath) {
24
+ try {
25
+ accessSync(dirPath, constants.W_OK);
26
+ return true;
27
+ }
28
+ catch {
29
+ return false;
30
+ }
31
+ }
32
+ /**
33
+ * Returns the user-level base memory directory and creates it with 0o700 permissions.
34
+ * Path is user-scoped to prevent cross-user data leakage.
35
+ */
36
+ export function resolveUserMemoryBase() {
37
+ const username = userInfo().username;
38
+ const isCloud = detectCloud();
39
+ const osPlatform = platform();
40
+ let userBase;
41
+ let resolvedPlatform;
42
+ if (osPlatform === "win32") {
43
+ // Windows: %APPDATA%\yuan\<username>\ or fallback %USERPROFILE%\.yuan\<username>\
44
+ const appData = process.env["APPDATA"];
45
+ if (appData) {
46
+ userBase = join(appData, "yuan", username);
47
+ }
48
+ else {
49
+ userBase = join(homedir(), ".yuan", username);
50
+ }
51
+ resolvedPlatform = "windows";
52
+ }
53
+ else if (osPlatform === "darwin") {
54
+ // macOS: ~/Library/Application Support/yuan/<username>/ if writable, else ~/.yuan/<username>/
55
+ const libAppSupport = join(homedir(), "Library", "Application Support");
56
+ if (isWritable(libAppSupport)) {
57
+ userBase = join(libAppSupport, "yuan", username);
58
+ }
59
+ else {
60
+ userBase = join(homedir(), ".yuan", username);
61
+ }
62
+ resolvedPlatform = isCloud ? "cloud" : "macos";
63
+ }
64
+ else {
65
+ // Linux / Cloud / Other: ~/.yuan/<username>/
66
+ userBase = join(homedir(), ".yuan", username);
67
+ resolvedPlatform = isCloud ? "cloud" : "linux";
68
+ }
69
+ // Create directory with owner-only permissions on Unix
70
+ if (osPlatform !== "win32") {
71
+ mkdirSync(userBase, { recursive: true, mode: 0o700 });
72
+ }
73
+ else {
74
+ mkdirSync(userBase, { recursive: true });
75
+ }
76
+ return { userBase, isCloud, platform: resolvedPlatform };
77
+ }
78
+ /**
79
+ * Returns the project-scoped memory base directory path.
80
+ * Does NOT create the directory — caller is responsible.
81
+ */
82
+ export function resolveProjectMemoryBase(projectPath) {
83
+ return join(projectPath, ".yuan");
84
+ }
85
+ /**
86
+ * Resolves a memory file path.
87
+ * If projectPath is given, returns the project-scoped path.
88
+ * Otherwise returns the user-level path (and ensures the user base dir exists).
89
+ */
90
+ export function resolveMemoryFile(filename, projectPath) {
91
+ if (projectPath) {
92
+ return join(resolveProjectMemoryBase(projectPath), filename);
93
+ }
94
+ const { userBase } = resolveUserMemoryBase();
95
+ return join(userBase, filename);
96
+ }
97
+ //# sourceMappingURL=resolve-memory-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-memory-path.js","sourceRoot":"","sources":["../src/resolve-memory-path.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAQ3D,6DAA6D;AAC7D,SAAS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EAAE,QAAQ,EAAE,GAAG,qBAAqB,EAAE,CAAC;IAC7C,OAAO,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * @module safe-bounds
3
+ * @description Centralized resource bounds to prevent unbounded memory growth,
4
+ * context explosions, and runaway string allocations across the agent system.
5
+ *
6
+ * Every array that grows over time and every string from an external source
7
+ * must be capped here. This is the single source of truth for all size limits.
8
+ *
9
+ * Rule: External data enters → truncate(). Arrays accumulate → cap().
10
+ */
11
+ export declare const BOUNDS: {
12
+ /** Max tracked changed files per agent run */
13
+ readonly changedFiles: 200;
14
+ /** Max tool results kept in memory (allToolResults) */
15
+ readonly allToolResults: 30;
16
+ /** Max tool results since last replan */
17
+ readonly toolResultsSinceReplan: 20;
18
+ /** Max messages in context (pruned by message-pruner) */
19
+ readonly messages: 40;
20
+ /** Max reflexion FIFO entries */
21
+ readonly reflexionEntries: 100;
22
+ /** Max vector store chunks in memory */
23
+ readonly vectorChunks: 500;
24
+ /** Max reasoning tree depth */
25
+ readonly reasoningDepth: 20;
26
+ /** Max reasoning tree total nodes */
27
+ readonly reasoningNodes: 200;
28
+ /** Max session chain length (continuation parent→child) */
29
+ readonly sessionChains: 50;
30
+ /** Max background task steps in TUI */
31
+ readonly bgTaskSteps: 20;
32
+ /** Max background tasks tracked simultaneously */
33
+ readonly bgTasks: 10;
34
+ /** Max deferred fix prompts per iteration */
35
+ readonly deferredFixes: 5;
36
+ /** Max skill-learner pattern entries */
37
+ readonly skillPatterns: 500;
38
+ /** Max MCP servers that can be registered */
39
+ readonly mcpServers: 20;
40
+ /** Shell command stdout (chars) — already enforced in shell-exec.ts */
41
+ readonly shellStdout: 100000;
42
+ /** Shell command stderr (chars) — already enforced in shell-exec.ts */
43
+ readonly shellStderr: 50000;
44
+ /** File read content (chars) — already enforced in file-read.ts */
45
+ readonly fileContent: 50000;
46
+ /** Git diff output (chars) */
47
+ readonly gitDiff: 15000;
48
+ /** Web scrape / fetch result (chars) */
49
+ readonly webContent: 30000;
50
+ /** TSC error output injected into LLM context (chars) */
51
+ readonly tscOutput: 3000;
52
+ /** Single reflexion entry body (chars) */
53
+ readonly reflexionEntryBody: 2000;
54
+ /** Tool result content stored in session persistence (chars) — 4KB */
55
+ readonly toolResultPersistence: 4096;
56
+ /** LLM thinking/reasoning content per message (chars) */
57
+ readonly thinkingContent: 8000;
58
+ /** Single QA issue message (chars) */
59
+ readonly qaIssueMessage: 200;
60
+ /** Architecture summary cache (chars) */
61
+ readonly archSummary: 20000;
62
+ /** Error signature for repeat detection (chars) */
63
+ readonly errorSignature: 500;
64
+ /** Single agent event content (chars) */
65
+ readonly agentEventContent: 2000;
66
+ };
67
+ /**
68
+ * Cap an array to the last `max` elements.
69
+ * Keeps the most recent entries (LIFO window).
70
+ */
71
+ export declare function cap<T>(arr: T[], max: number): T[];
72
+ /**
73
+ * Cap an array to the first `max` elements.
74
+ * Useful for ID lists, file lists, etc. where order matters.
75
+ */
76
+ export declare function capHead<T>(arr: T[], max: number): T[];
77
+ /**
78
+ * Truncate a string to `max` characters.
79
+ * Appends a labeled suffix showing how many chars were removed.
80
+ */
81
+ export declare function truncate(s: string, max: number, label?: string): string;
82
+ /**
83
+ * Truncate from the start of a string (keep the end — useful for logs/output
84
+ * where the most relevant info is at the bottom).
85
+ */
86
+ export declare function truncateHead(s: string, max: number, label?: string): string;
87
+ /**
88
+ * Push an item into an array and cap it in-place.
89
+ * Returns the (possibly truncated) array.
90
+ */
91
+ export declare function pushCapped<T>(arr: T[], item: T, max: number): T[];
92
+ /**
93
+ * Safe JSON stringify that never throws and caps output size.
94
+ * Used for persisting data to disk without pretty-printing (no OOM).
95
+ */
96
+ export declare function safeJsonStringify(value: unknown, maxChars?: number): string;
97
+ /**
98
+ * Safe JSON parse that never throws.
99
+ */
100
+ export declare function safeJsonParse<T = unknown>(s: string, fallback: T): T;
101
+ //# sourceMappingURL=safe-bounds.d.ts.map
@@ -0,0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