@mcoda/mswarm 0.1.57 → 0.1.60

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 (250) hide show
  1. package/README.md +19 -0
  2. package/dist/codali-executor.d.ts +266 -0
  3. package/dist/codali-executor.d.ts.map +1 -0
  4. package/dist/codali-executor.js +227 -0
  5. package/dist/codali-executor.js.map +1 -0
  6. package/dist/runtime.d.ts +36 -1
  7. package/dist/runtime.d.ts.map +1 -1
  8. package/dist/runtime.js +219 -30
  9. package/dist/runtime.js.map +1 -1
  10. package/dist/server.d.ts.map +1 -1
  11. package/dist/server.js +54 -0
  12. package/dist/server.js.map +1 -1
  13. package/dist/vendor/codali/agents/AgentProtocol.d.ts +287 -0
  14. package/dist/vendor/codali/agents/AgentProtocol.d.ts.map +1 -0
  15. package/dist/vendor/codali/agents/AgentProtocol.js +365 -0
  16. package/dist/vendor/codali/agents/AgentResolver.d.ts +23 -0
  17. package/dist/vendor/codali/agents/AgentResolver.d.ts.map +1 -0
  18. package/dist/vendor/codali/agents/AgentResolver.js +77 -0
  19. package/dist/vendor/codali/agents/PhaseAgentSelector.d.ts +23 -0
  20. package/dist/vendor/codali/agents/PhaseAgentSelector.d.ts.map +1 -0
  21. package/dist/vendor/codali/agents/PhaseAgentSelector.js +287 -0
  22. package/dist/vendor/codali/cli/EvalCommand.d.ts +37 -0
  23. package/dist/vendor/codali/cli/EvalCommand.d.ts.map +1 -0
  24. package/dist/vendor/codali/cli/EvalCommand.js +333 -0
  25. package/dist/vendor/codali/cli/FeedbackCommand.d.ts +22 -0
  26. package/dist/vendor/codali/cli/FeedbackCommand.d.ts.map +1 -0
  27. package/dist/vendor/codali/cli/FeedbackCommand.js +163 -0
  28. package/dist/vendor/codali/cli/RunCommand.d.ts +78 -0
  29. package/dist/vendor/codali/cli/RunCommand.d.ts.map +1 -0
  30. package/dist/vendor/codali/cli/RunCommand.js +2261 -0
  31. package/dist/vendor/codali/cli.d.ts +3 -0
  32. package/dist/vendor/codali/cli.d.ts.map +1 -0
  33. package/dist/vendor/codali/cli.js +109 -0
  34. package/dist/vendor/codali/cognitive/ArchitectPlanner.d.ts +107 -0
  35. package/dist/vendor/codali/cognitive/ArchitectPlanner.d.ts.map +1 -0
  36. package/dist/vendor/codali/cognitive/ArchitectPlanner.js +1726 -0
  37. package/dist/vendor/codali/cognitive/BuilderOutputParser.d.ts +25 -0
  38. package/dist/vendor/codali/cognitive/BuilderOutputParser.d.ts.map +1 -0
  39. package/dist/vendor/codali/cognitive/BuilderOutputParser.js +164 -0
  40. package/dist/vendor/codali/cognitive/BuilderRunner.d.ts +76 -0
  41. package/dist/vendor/codali/cognitive/BuilderRunner.d.ts.map +1 -0
  42. package/dist/vendor/codali/cognitive/BuilderRunner.js +1159 -0
  43. package/dist/vendor/codali/cognitive/ContextAssembler.d.ts +91 -0
  44. package/dist/vendor/codali/cognitive/ContextAssembler.d.ts.map +1 -0
  45. package/dist/vendor/codali/cognitive/ContextAssembler.js +4547 -0
  46. package/dist/vendor/codali/cognitive/ContextBudget.d.ts +19 -0
  47. package/dist/vendor/codali/cognitive/ContextBudget.d.ts.map +1 -0
  48. package/dist/vendor/codali/cognitive/ContextBudget.js +35 -0
  49. package/dist/vendor/codali/cognitive/ContextFileLoader.d.ts +30 -0
  50. package/dist/vendor/codali/cognitive/ContextFileLoader.d.ts.map +1 -0
  51. package/dist/vendor/codali/cognitive/ContextFileLoader.js +307 -0
  52. package/dist/vendor/codali/cognitive/ContextManager.d.ts +47 -0
  53. package/dist/vendor/codali/cognitive/ContextManager.d.ts.map +1 -0
  54. package/dist/vendor/codali/cognitive/ContextManager.js +272 -0
  55. package/dist/vendor/codali/cognitive/ContextRedactor.d.ts +18 -0
  56. package/dist/vendor/codali/cognitive/ContextRedactor.d.ts.map +1 -0
  57. package/dist/vendor/codali/cognitive/ContextRedactor.js +53 -0
  58. package/dist/vendor/codali/cognitive/ContextSelector.d.ts +22 -0
  59. package/dist/vendor/codali/cognitive/ContextSelector.d.ts.map +1 -0
  60. package/dist/vendor/codali/cognitive/ContextSelector.js +431 -0
  61. package/dist/vendor/codali/cognitive/ContextSerializer.d.ts +8 -0
  62. package/dist/vendor/codali/cognitive/ContextSerializer.d.ts.map +1 -0
  63. package/dist/vendor/codali/cognitive/ContextSerializer.js +882 -0
  64. package/dist/vendor/codali/cognitive/ContextStore.d.ts +27 -0
  65. package/dist/vendor/codali/cognitive/ContextStore.d.ts.map +1 -0
  66. package/dist/vendor/codali/cognitive/ContextStore.js +79 -0
  67. package/dist/vendor/codali/cognitive/ContextSummarizer.d.ts +16 -0
  68. package/dist/vendor/codali/cognitive/ContextSummarizer.d.ts.map +1 -0
  69. package/dist/vendor/codali/cognitive/ContextSummarizer.js +45 -0
  70. package/dist/vendor/codali/cognitive/CostEstimator.d.ts +31 -0
  71. package/dist/vendor/codali/cognitive/CostEstimator.d.ts.map +1 -0
  72. package/dist/vendor/codali/cognitive/CostEstimator.js +66 -0
  73. package/dist/vendor/codali/cognitive/CriticEvaluator.d.ts +32 -0
  74. package/dist/vendor/codali/cognitive/CriticEvaluator.d.ts.map +1 -0
  75. package/dist/vendor/codali/cognitive/CriticEvaluator.js +297 -0
  76. package/dist/vendor/codali/cognitive/EvidenceGate.d.ts +9 -0
  77. package/dist/vendor/codali/cognitive/EvidenceGate.d.ts.map +1 -0
  78. package/dist/vendor/codali/cognitive/EvidenceGate.js +75 -0
  79. package/dist/vendor/codali/cognitive/GoldenExampleIndexer.d.ts +12 -0
  80. package/dist/vendor/codali/cognitive/GoldenExampleIndexer.d.ts.map +1 -0
  81. package/dist/vendor/codali/cognitive/GoldenExampleIndexer.js +34 -0
  82. package/dist/vendor/codali/cognitive/GoldenSetStore.d.ts +33 -0
  83. package/dist/vendor/codali/cognitive/GoldenSetStore.d.ts.map +1 -0
  84. package/dist/vendor/codali/cognitive/GoldenSetStore.js +159 -0
  85. package/dist/vendor/codali/cognitive/IntentSignals.d.ts +7 -0
  86. package/dist/vendor/codali/cognitive/IntentSignals.d.ts.map +1 -0
  87. package/dist/vendor/codali/cognitive/IntentSignals.js +285 -0
  88. package/dist/vendor/codali/cognitive/LearningGovernance.d.ts +100 -0
  89. package/dist/vendor/codali/cognitive/LearningGovernance.d.ts.map +1 -0
  90. package/dist/vendor/codali/cognitive/LearningGovernance.js +276 -0
  91. package/dist/vendor/codali/cognitive/MemoryWriteback.d.ts +64 -0
  92. package/dist/vendor/codali/cognitive/MemoryWriteback.d.ts.map +1 -0
  93. package/dist/vendor/codali/cognitive/MemoryWriteback.js +287 -0
  94. package/dist/vendor/codali/cognitive/PatchApplier.d.ts +49 -0
  95. package/dist/vendor/codali/cognitive/PatchApplier.d.ts.map +1 -0
  96. package/dist/vendor/codali/cognitive/PatchApplier.js +199 -0
  97. package/dist/vendor/codali/cognitive/PatchInterpreter.d.ts +35 -0
  98. package/dist/vendor/codali/cognitive/PatchInterpreter.d.ts.map +1 -0
  99. package/dist/vendor/codali/cognitive/PatchInterpreter.js +100 -0
  100. package/dist/vendor/codali/cognitive/PatchOutputNormalizer.d.ts +7 -0
  101. package/dist/vendor/codali/cognitive/PatchOutputNormalizer.d.ts.map +1 -0
  102. package/dist/vendor/codali/cognitive/PatchOutputNormalizer.js +59 -0
  103. package/dist/vendor/codali/cognitive/PostMortemAnalyzer.d.ts +17 -0
  104. package/dist/vendor/codali/cognitive/PostMortemAnalyzer.d.ts.map +1 -0
  105. package/dist/vendor/codali/cognitive/PostMortemAnalyzer.js +131 -0
  106. package/dist/vendor/codali/cognitive/PreferenceExtraction.d.ts +3 -0
  107. package/dist/vendor/codali/cognitive/PreferenceExtraction.d.ts.map +1 -0
  108. package/dist/vendor/codali/cognitive/PreferenceExtraction.js +85 -0
  109. package/dist/vendor/codali/cognitive/Prompts.d.ts +15 -0
  110. package/dist/vendor/codali/cognitive/Prompts.d.ts.map +1 -0
  111. package/dist/vendor/codali/cognitive/Prompts.js +326 -0
  112. package/dist/vendor/codali/cognitive/ProviderRouting.d.ts +16 -0
  113. package/dist/vendor/codali/cognitive/ProviderRouting.d.ts.map +1 -0
  114. package/dist/vendor/codali/cognitive/ProviderRouting.js +24 -0
  115. package/dist/vendor/codali/cognitive/QueryExtraction.d.ts +12 -0
  116. package/dist/vendor/codali/cognitive/QueryExtraction.d.ts.map +1 -0
  117. package/dist/vendor/codali/cognitive/QueryExtraction.js +262 -0
  118. package/dist/vendor/codali/cognitive/RunHistoryIndexer.d.ts +13 -0
  119. package/dist/vendor/codali/cognitive/RunHistoryIndexer.d.ts.map +1 -0
  120. package/dist/vendor/codali/cognitive/RunHistoryIndexer.js +125 -0
  121. package/dist/vendor/codali/cognitive/SmartPipeline.d.ts +92 -0
  122. package/dist/vendor/codali/cognitive/SmartPipeline.d.ts.map +1 -0
  123. package/dist/vendor/codali/cognitive/SmartPipeline.js +4804 -0
  124. package/dist/vendor/codali/cognitive/Types.d.ts +474 -0
  125. package/dist/vendor/codali/cognitive/Types.d.ts.map +1 -0
  126. package/dist/vendor/codali/cognitive/Types.js +7 -0
  127. package/dist/vendor/codali/cognitive/ValidationRunner.d.ts +57 -0
  128. package/dist/vendor/codali/cognitive/ValidationRunner.d.ts.map +1 -0
  129. package/dist/vendor/codali/cognitive/ValidationRunner.js +515 -0
  130. package/dist/vendor/codali/config/Config.d.ts +249 -0
  131. package/dist/vendor/codali/config/Config.d.ts.map +1 -0
  132. package/dist/vendor/codali/config/Config.js +200 -0
  133. package/dist/vendor/codali/config/ConfigLoader.d.ts +56 -0
  134. package/dist/vendor/codali/config/ConfigLoader.d.ts.map +1 -0
  135. package/dist/vendor/codali/config/ConfigLoader.js +1246 -0
  136. package/dist/vendor/codali/docdex/DocdexClient.d.ts +113 -0
  137. package/dist/vendor/codali/docdex/DocdexClient.d.ts.map +1 -0
  138. package/dist/vendor/codali/docdex/DocdexClient.js +524 -0
  139. package/dist/vendor/codali/eval/EvalRunner.d.ts +35 -0
  140. package/dist/vendor/codali/eval/EvalRunner.d.ts.map +1 -0
  141. package/dist/vendor/codali/eval/EvalRunner.js +38 -0
  142. package/dist/vendor/codali/eval/EvalTaskExecutor.d.ts +81 -0
  143. package/dist/vendor/codali/eval/EvalTaskExecutor.d.ts.map +1 -0
  144. package/dist/vendor/codali/eval/EvalTaskExecutor.js +371 -0
  145. package/dist/vendor/codali/eval/GateEvaluator.d.ts +31 -0
  146. package/dist/vendor/codali/eval/GateEvaluator.d.ts.map +1 -0
  147. package/dist/vendor/codali/eval/GateEvaluator.js +134 -0
  148. package/dist/vendor/codali/eval/MetricTypes.d.ts +28 -0
  149. package/dist/vendor/codali/eval/MetricTypes.d.ts.map +1 -0
  150. package/dist/vendor/codali/eval/MetricTypes.js +1 -0
  151. package/dist/vendor/codali/eval/MetricsAggregator.d.ts +4 -0
  152. package/dist/vendor/codali/eval/MetricsAggregator.d.ts.map +1 -0
  153. package/dist/vendor/codali/eval/MetricsAggregator.js +97 -0
  154. package/dist/vendor/codali/eval/RegressionComparator.d.ts +29 -0
  155. package/dist/vendor/codali/eval/RegressionComparator.d.ts.map +1 -0
  156. package/dist/vendor/codali/eval/RegressionComparator.js +155 -0
  157. package/dist/vendor/codali/eval/ReportInputAdapter.d.ts +52 -0
  158. package/dist/vendor/codali/eval/ReportInputAdapter.d.ts.map +1 -0
  159. package/dist/vendor/codali/eval/ReportInputAdapter.js +229 -0
  160. package/dist/vendor/codali/eval/ReportSerializer.d.ts +32 -0
  161. package/dist/vendor/codali/eval/ReportSerializer.d.ts.map +1 -0
  162. package/dist/vendor/codali/eval/ReportSerializer.js +33 -0
  163. package/dist/vendor/codali/eval/ReportStore.d.ts +18 -0
  164. package/dist/vendor/codali/eval/ReportStore.d.ts.map +1 -0
  165. package/dist/vendor/codali/eval/ReportStore.js +96 -0
  166. package/dist/vendor/codali/eval/SuiteLoader.d.ts +12 -0
  167. package/dist/vendor/codali/eval/SuiteLoader.d.ts.map +1 -0
  168. package/dist/vendor/codali/eval/SuiteLoader.js +51 -0
  169. package/dist/vendor/codali/eval/SuiteSchema.d.ts +56 -0
  170. package/dist/vendor/codali/eval/SuiteSchema.d.ts.map +1 -0
  171. package/dist/vendor/codali/eval/SuiteSchema.js +357 -0
  172. package/dist/vendor/codali/index.d.ts +11 -0
  173. package/dist/vendor/codali/index.d.ts.map +1 -0
  174. package/dist/vendor/codali/index.js +5 -0
  175. package/dist/vendor/codali/providers/CodexCliProvider.d.ts +8 -0
  176. package/dist/vendor/codali/providers/CodexCliProvider.d.ts.map +1 -0
  177. package/dist/vendor/codali/providers/CodexCliProvider.js +282 -0
  178. package/dist/vendor/codali/providers/OllamaRemoteProvider.d.ts +8 -0
  179. package/dist/vendor/codali/providers/OllamaRemoteProvider.d.ts.map +1 -0
  180. package/dist/vendor/codali/providers/OllamaRemoteProvider.js +300 -0
  181. package/dist/vendor/codali/providers/OpenAiCompatibleProvider.d.ts +8 -0
  182. package/dist/vendor/codali/providers/OpenAiCompatibleProvider.d.ts.map +1 -0
  183. package/dist/vendor/codali/providers/OpenAiCompatibleProvider.js +192 -0
  184. package/dist/vendor/codali/providers/ProviderRegistry.d.ts +12 -0
  185. package/dist/vendor/codali/providers/ProviderRegistry.d.ts.map +1 -0
  186. package/dist/vendor/codali/providers/ProviderRegistry.js +28 -0
  187. package/dist/vendor/codali/providers/ProviderTypes.d.ts +81 -0
  188. package/dist/vendor/codali/providers/ProviderTypes.d.ts.map +1 -0
  189. package/dist/vendor/codali/providers/ProviderTypes.js +1 -0
  190. package/dist/vendor/codali/runtime/CodaliRuntime.d.ts +183 -0
  191. package/dist/vendor/codali/runtime/CodaliRuntime.d.ts.map +1 -0
  192. package/dist/vendor/codali/runtime/CodaliRuntime.js +1363 -0
  193. package/dist/vendor/codali/runtime/DeepInvestigationErrors.d.ts +39 -0
  194. package/dist/vendor/codali/runtime/DeepInvestigationErrors.d.ts.map +1 -0
  195. package/dist/vendor/codali/runtime/DeepInvestigationErrors.js +57 -0
  196. package/dist/vendor/codali/runtime/RunContext.d.ts +27 -0
  197. package/dist/vendor/codali/runtime/RunContext.d.ts.map +1 -0
  198. package/dist/vendor/codali/runtime/RunContext.js +51 -0
  199. package/dist/vendor/codali/runtime/RunLogQuery.d.ts +48 -0
  200. package/dist/vendor/codali/runtime/RunLogQuery.d.ts.map +1 -0
  201. package/dist/vendor/codali/runtime/RunLogQuery.js +36 -0
  202. package/dist/vendor/codali/runtime/RunLogReader.d.ts +19 -0
  203. package/dist/vendor/codali/runtime/RunLogReader.d.ts.map +1 -0
  204. package/dist/vendor/codali/runtime/RunLogReader.js +361 -0
  205. package/dist/vendor/codali/runtime/RunLogger.d.ts +71 -0
  206. package/dist/vendor/codali/runtime/RunLogger.d.ts.map +1 -0
  207. package/dist/vendor/codali/runtime/RunLogger.js +100 -0
  208. package/dist/vendor/codali/runtime/RunTelemetryTypes.d.ts +117 -0
  209. package/dist/vendor/codali/runtime/RunTelemetryTypes.d.ts.map +1 -0
  210. package/dist/vendor/codali/runtime/RunTelemetryTypes.js +299 -0
  211. package/dist/vendor/codali/runtime/Runner.d.ts +66 -0
  212. package/dist/vendor/codali/runtime/Runner.d.ts.map +1 -0
  213. package/dist/vendor/codali/runtime/Runner.js +215 -0
  214. package/dist/vendor/codali/runtime/StoragePaths.d.ts +3 -0
  215. package/dist/vendor/codali/runtime/StoragePaths.d.ts.map +1 -0
  216. package/dist/vendor/codali/runtime/StoragePaths.js +19 -0
  217. package/dist/vendor/codali/runtime/WorkspaceLock.d.ts +30 -0
  218. package/dist/vendor/codali/runtime/WorkspaceLock.d.ts.map +1 -0
  219. package/dist/vendor/codali/runtime/WorkspaceLock.js +141 -0
  220. package/dist/vendor/codali/session/InstructionLoader.d.ts +14 -0
  221. package/dist/vendor/codali/session/InstructionLoader.d.ts.map +1 -0
  222. package/dist/vendor/codali/session/InstructionLoader.js +107 -0
  223. package/dist/vendor/codali/session/SessionStore.d.ts +81 -0
  224. package/dist/vendor/codali/session/SessionStore.d.ts.map +1 -0
  225. package/dist/vendor/codali/session/SessionStore.js +244 -0
  226. package/dist/vendor/codali/subagents/SubagentOrchestrator.d.ts +68 -0
  227. package/dist/vendor/codali/subagents/SubagentOrchestrator.d.ts.map +1 -0
  228. package/dist/vendor/codali/subagents/SubagentOrchestrator.js +150 -0
  229. package/dist/vendor/codali/tools/ToolRegistry.d.ts +9 -0
  230. package/dist/vendor/codali/tools/ToolRegistry.d.ts.map +1 -0
  231. package/dist/vendor/codali/tools/ToolRegistry.js +263 -0
  232. package/dist/vendor/codali/tools/ToolTypes.d.ts +66 -0
  233. package/dist/vendor/codali/tools/ToolTypes.d.ts.map +1 -0
  234. package/dist/vendor/codali/tools/ToolTypes.js +32 -0
  235. package/dist/vendor/codali/tools/diff/DiffTool.d.ts +3 -0
  236. package/dist/vendor/codali/tools/diff/DiffTool.d.ts.map +1 -0
  237. package/dist/vendor/codali/tools/diff/DiffTool.js +34 -0
  238. package/dist/vendor/codali/tools/docdex/DocdexTools.d.ts +4 -0
  239. package/dist/vendor/codali/tools/docdex/DocdexTools.d.ts.map +1 -0
  240. package/dist/vendor/codali/tools/docdex/DocdexTools.js +453 -0
  241. package/dist/vendor/codali/tools/filesystem/FileTools.d.ts +3 -0
  242. package/dist/vendor/codali/tools/filesystem/FileTools.d.ts.map +1 -0
  243. package/dist/vendor/codali/tools/filesystem/FileTools.js +141 -0
  244. package/dist/vendor/codali/tools/search/SearchTool.d.ts +3 -0
  245. package/dist/vendor/codali/tools/search/SearchTool.d.ts.map +1 -0
  246. package/dist/vendor/codali/tools/search/SearchTool.js +46 -0
  247. package/dist/vendor/codali/tools/shell/ShellTool.d.ts +3 -0
  248. package/dist/vendor/codali/tools/shell/ShellTool.d.ts.map +1 -0
  249. package/dist/vendor/codali/tools/shell/ShellTool.js +104 -0
  250. package/package.json +5 -3
@@ -0,0 +1,215 @@
1
+ export class RunnerBudgetError extends Error {
2
+ constructor(code, metadata) {
3
+ super(code === "runner_timeout_exceeded"
4
+ ? "Runner timeout exceeded"
5
+ : code === "runner_tool_call_limit_exceeded"
6
+ ? "Tool call limit exceeded"
7
+ : "Runner step limit exceeded");
8
+ this.name = "RunnerBudgetError";
9
+ this.code = code;
10
+ this.metadata = {
11
+ reason_code: code,
12
+ ...metadata,
13
+ };
14
+ }
15
+ }
16
+ const buildToolMessage = (call, content) => ({
17
+ role: "tool",
18
+ content,
19
+ toolCallId: call.id,
20
+ name: call.name,
21
+ });
22
+ export class Runner {
23
+ constructor(options) {
24
+ this.provider = options.provider;
25
+ this.tools = options.tools;
26
+ this.context = options.context;
27
+ this.maxSteps = options.maxSteps;
28
+ this.maxToolCalls = options.maxToolCalls;
29
+ this.maxTokens = options.maxTokens;
30
+ this.temperature = options.temperature;
31
+ this.responseFormat = options.responseFormat;
32
+ this.toolChoice = options.toolChoice;
33
+ this.stream = options.stream;
34
+ this.onEvent = options.onEvent;
35
+ this.onToken = options.onToken;
36
+ this.streamFlushMs = options.streamFlushMs;
37
+ this.timeoutMs = options.timeoutMs;
38
+ this.logger = options.logger;
39
+ }
40
+ async run(initialMessages) {
41
+ const messages = [...initialMessages];
42
+ let toolCallsExecuted = 0;
43
+ let usageTotals;
44
+ const deadline = this.timeoutMs ? Date.now() + this.timeoutMs : undefined;
45
+ const emitEvent = (event) => {
46
+ if (this.onEvent) {
47
+ this.onEvent(event);
48
+ return;
49
+ }
50
+ if (event.type === "token") {
51
+ this.onToken?.(event.content);
52
+ }
53
+ };
54
+ const emitStatus = (phase, message) => {
55
+ this.onEvent?.({ type: "status", phase, message });
56
+ };
57
+ const recordUsage = (usage) => {
58
+ if (!usage)
59
+ return;
60
+ if (!usageTotals)
61
+ usageTotals = {};
62
+ if (usage.inputTokens !== undefined) {
63
+ usageTotals.inputTokens = (usageTotals.inputTokens ?? 0) + usage.inputTokens;
64
+ }
65
+ if (usage.outputTokens !== undefined) {
66
+ usageTotals.outputTokens = (usageTotals.outputTokens ?? 0) + usage.outputTokens;
67
+ }
68
+ if (usage.totalTokens !== undefined) {
69
+ usageTotals.totalTokens = (usageTotals.totalTokens ?? 0) + usage.totalTokens;
70
+ }
71
+ };
72
+ const timeRemaining = () => {
73
+ if (!deadline)
74
+ return undefined;
75
+ return deadline - Date.now();
76
+ };
77
+ const throwBudgetError = async (code, step) => {
78
+ const error = new RunnerBudgetError(code, {
79
+ step,
80
+ tool_calls_executed: toolCallsExecuted,
81
+ max_steps: this.maxSteps,
82
+ max_tool_calls: this.maxToolCalls,
83
+ timeout_ms: this.timeoutMs,
84
+ });
85
+ if (this.logger) {
86
+ await this.logger.log("runner_budget_failure", error.metadata);
87
+ }
88
+ throw error;
89
+ };
90
+ const withTimeout = async (promise, label) => {
91
+ const remaining = timeRemaining();
92
+ if (remaining === undefined)
93
+ return promise;
94
+ if (remaining <= 0) {
95
+ await throwBudgetError("runner_timeout_exceeded", -1);
96
+ }
97
+ let timeoutId;
98
+ const timeoutPromise = new Promise((_, reject) => {
99
+ timeoutId = setTimeout(() => reject(new Error("Runner timeout exceeded")), remaining);
100
+ });
101
+ try {
102
+ return await Promise.race([promise, timeoutPromise]);
103
+ }
104
+ catch (error) {
105
+ if (error instanceof Error && /Runner timeout exceeded/i.test(error.message)) {
106
+ await throwBudgetError("runner_timeout_exceeded", -1);
107
+ }
108
+ throw error;
109
+ }
110
+ finally {
111
+ if (timeoutId)
112
+ clearTimeout(timeoutId);
113
+ }
114
+ };
115
+ for (let step = 0; step < this.maxSteps; step += 1) {
116
+ if (deadline && timeRemaining() <= 0) {
117
+ await throwBudgetError("runner_timeout_exceeded", step);
118
+ }
119
+ const toolSpecs = this.tools.describe().map((tool) => ({
120
+ name: tool.name,
121
+ description: tool.description,
122
+ inputSchema: tool.inputSchema,
123
+ }));
124
+ const allowTools = toolSpecs.length > 0 && this.toolChoice !== "none";
125
+ emitStatus("thinking");
126
+ if (this.logger) {
127
+ await this.logger.log("provider_request", {
128
+ provider: this.provider.name,
129
+ messages,
130
+ tools: allowTools ? toolSpecs : [],
131
+ toolChoice: allowTools ? this.toolChoice ?? "auto" : "none",
132
+ responseFormat: this.responseFormat,
133
+ temperature: this.temperature,
134
+ maxTokens: this.maxTokens,
135
+ stream: this.stream ?? false,
136
+ });
137
+ }
138
+ const response = await withTimeout(this.provider.generate({
139
+ messages,
140
+ tools: allowTools ? toolSpecs : undefined,
141
+ toolChoice: allowTools ? this.toolChoice ?? "auto" : undefined,
142
+ maxTokens: this.maxTokens,
143
+ temperature: this.temperature,
144
+ responseFormat: this.responseFormat,
145
+ stream: this.stream,
146
+ onEvent: emitEvent,
147
+ onToken: (token) => emitEvent({ type: "token", content: token }),
148
+ streamFlushMs: this.streamFlushMs,
149
+ }), "provider");
150
+ recordUsage(response.usage);
151
+ messages.push(response.message);
152
+ if (this.logger) {
153
+ await this.logger.log("provider_response", {
154
+ message: response.message,
155
+ toolCalls: response.toolCalls,
156
+ usage: response.usage,
157
+ });
158
+ }
159
+ if (!response.toolCalls || response.toolCalls.length === 0) {
160
+ return {
161
+ finalMessage: response.message,
162
+ messages,
163
+ toolCallsExecuted,
164
+ usage: usageTotals,
165
+ };
166
+ }
167
+ for (const call of response.toolCalls) {
168
+ if (toolCallsExecuted >= this.maxToolCalls) {
169
+ await throwBudgetError("runner_tool_call_limit_exceeded", step);
170
+ }
171
+ toolCallsExecuted += 1;
172
+ emitStatus("executing", call.name);
173
+ this.onEvent?.({ type: "tool_call", name: call.name, args: call.args });
174
+ const result = await withTimeout(this.tools.execute(call.name, call.args, this.context), "tool");
175
+ const toolError = result.error;
176
+ const content = result.ok
177
+ ? result.output
178
+ : `ERROR[${toolError?.code ?? "tool_execution_failed"}]: ${toolError?.message ?? "tool failed"}`;
179
+ messages.push(buildToolMessage(call, content));
180
+ this.onEvent?.({
181
+ type: "tool_result",
182
+ name: call.name,
183
+ output: content,
184
+ ok: result.ok,
185
+ errorCode: toolError?.code,
186
+ retryable: toolError?.retryable,
187
+ });
188
+ if (this.logger) {
189
+ await this.logger.log("tool_call", {
190
+ name: call.name,
191
+ ok: result.ok,
192
+ error: toolError?.message,
193
+ error_code: toolError?.code,
194
+ error_category: toolError?.category,
195
+ error_retryable: toolError?.retryable,
196
+ error_details: toolError?.details,
197
+ });
198
+ if (toolError) {
199
+ await this.logger.logSafetyEvent({
200
+ phase: "act",
201
+ category: "tool",
202
+ code: toolError.code,
203
+ disposition: toolError.retryable ? "retryable" : "non_retryable",
204
+ tool: call.name,
205
+ message: toolError.message,
206
+ details: toolError.details,
207
+ });
208
+ }
209
+ }
210
+ }
211
+ }
212
+ await throwBudgetError("runner_step_limit_exceeded", this.maxSteps);
213
+ throw new Error("unreachable_runner_budget_path");
214
+ }
215
+ }
@@ -0,0 +1,3 @@
1
+ export declare const getGlobalMcodaDir: () => string;
2
+ export declare const getGlobalWorkspaceDir: (workspaceRoot: string) => string;
3
+ //# sourceMappingURL=StoragePaths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StoragePaths.d.ts","sourceRoot":"","sources":["../../src/runtime/StoragePaths.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,iBAAiB,QAAO,MAIpC,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,eAAe,MAAM,KAAG,MAM7D,CAAC"}
@@ -0,0 +1,19 @@
1
+ import os from "node:os";
2
+ import path from "node:path";
3
+ import { createHash } from "node:crypto";
4
+ const normalizePathCase = (value) => {
5
+ const normalized = path.normalize(value);
6
+ return process.platform === "win32" ? normalized.toLowerCase() : normalized;
7
+ };
8
+ export const getGlobalMcodaDir = () => {
9
+ const envHome = process.env.HOME ?? process.env.USERPROFILE;
10
+ const homeDir = envHome && envHome.trim().length > 0 ? envHome : os.homedir();
11
+ return path.join(homeDir, ".mcoda");
12
+ };
13
+ export const getGlobalWorkspaceDir = (workspaceRoot) => {
14
+ const normalizedRoot = normalizePathCase(path.resolve(workspaceRoot));
15
+ const hash = createHash("sha256").update(normalizedRoot).digest("hex").slice(0, 12);
16
+ const rawName = path.basename(normalizedRoot) || "workspace";
17
+ const safeName = rawName.replace(/[^a-zA-Z0-9._-]+/g, "_").slice(0, 32) || "workspace";
18
+ return path.join(getGlobalMcodaDir(), "workspaces", `${safeName}-${hash}`);
19
+ };
@@ -0,0 +1,30 @@
1
+ export interface WorkspaceLockInfo {
2
+ runId: string;
3
+ acquiredAt: number;
4
+ pid?: number;
5
+ hostname?: string;
6
+ }
7
+ export interface WorkspaceLockSignalOptions {
8
+ exitOnSignal?: boolean;
9
+ onSignal?: (signal: NodeJS.Signals) => void | Promise<void>;
10
+ exitCodeForSignal?: (signal: NodeJS.Signals) => number;
11
+ }
12
+ export declare class WorkspaceLock {
13
+ private workspaceRoot;
14
+ private runId;
15
+ private maxAgeMs;
16
+ private lockPath;
17
+ private acquired;
18
+ private readonly hostname;
19
+ constructor(workspaceRoot: string, runId: string, maxAgeMs?: number);
20
+ private readLock;
21
+ private isStale;
22
+ private isSameHost;
23
+ private isProcessAlive;
24
+ private hasTerminalRunLog;
25
+ private shouldClearExisting;
26
+ acquire(): Promise<void>;
27
+ release(): Promise<void>;
28
+ registerSignalHandlers(options?: WorkspaceLockSignalOptions): () => void;
29
+ }
30
+ //# sourceMappingURL=WorkspaceLock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkspaceLock.d.ts","sourceRoot":"","sources":["../../src/runtime/WorkspaceLock.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,0BAA0B;IACzC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,KAAK,MAAM,CAAC;CACxD;AAED,qBAAa,aAAa;IAMtB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,QAAQ;IAPlB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAiB;gBAGhC,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,QAAQ,GAAE,MAAuB;YAK7B,QAAQ;IAStB,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,cAAc;YAcR,iBAAiB;YAuBjB,mBAAmB;IAQ3B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAmBxB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAU9B,sBAAsB,CAAC,OAAO,GAAE,0BAA+B,GAAG,MAAM,IAAI;CAmC7E"}
@@ -0,0 +1,141 @@
1
+ import { promises as fs } from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ export class WorkspaceLock {
5
+ constructor(workspaceRoot, runId, maxAgeMs = 60 * 60 * 1000) {
6
+ this.workspaceRoot = workspaceRoot;
7
+ this.runId = runId;
8
+ this.maxAgeMs = maxAgeMs;
9
+ this.acquired = false;
10
+ this.hostname = os.hostname();
11
+ this.lockPath = path.join(this.workspaceRoot, "locks", "codali.lock");
12
+ }
13
+ async readLock() {
14
+ try {
15
+ const raw = await fs.readFile(this.lockPath, "utf8");
16
+ return JSON.parse(raw);
17
+ }
18
+ catch {
19
+ return undefined;
20
+ }
21
+ }
22
+ isStale(info) {
23
+ return Date.now() - info.acquiredAt > this.maxAgeMs;
24
+ }
25
+ isSameHost(info) {
26
+ return !info.hostname || info.hostname === this.hostname;
27
+ }
28
+ isProcessAlive(info) {
29
+ if (!this.isSameHost(info))
30
+ return undefined;
31
+ if (!Number.isInteger(info.pid) || (info.pid ?? 0) <= 0)
32
+ return undefined;
33
+ try {
34
+ process.kill(info.pid, 0);
35
+ return true;
36
+ }
37
+ catch (error) {
38
+ const code = error.code;
39
+ if (code === "ESRCH")
40
+ return false;
41
+ if (code === "EPERM")
42
+ return true;
43
+ return undefined;
44
+ }
45
+ }
46
+ async hasTerminalRunLog(runId) {
47
+ const logPath = path.join(this.workspaceRoot, "logs", `${runId}.jsonl`);
48
+ try {
49
+ const content = await fs.readFile(logPath, "utf8");
50
+ const lines = content.split("\n");
51
+ for (let index = lines.length - 1; index >= 0; index -= 1) {
52
+ const line = lines[index]?.trim();
53
+ if (!line)
54
+ continue;
55
+ try {
56
+ const parsed = JSON.parse(line);
57
+ if (parsed.type === "run_summary" || parsed.type === "run_failed" || parsed.type === "run_cancelled") {
58
+ return true;
59
+ }
60
+ }
61
+ catch {
62
+ // Ignore malformed log lines and continue scanning older entries.
63
+ }
64
+ }
65
+ }
66
+ catch {
67
+ return false;
68
+ }
69
+ return false;
70
+ }
71
+ async shouldClearExisting(info) {
72
+ if (this.isStale(info))
73
+ return true;
74
+ const processAlive = this.isProcessAlive(info);
75
+ if (processAlive === false)
76
+ return true;
77
+ if (processAlive === true)
78
+ return false;
79
+ return this.hasTerminalRunLog(info.runId);
80
+ }
81
+ async acquire() {
82
+ await fs.mkdir(path.dirname(this.lockPath), { recursive: true });
83
+ const existing = await this.readLock();
84
+ if (existing && !(await this.shouldClearExisting(existing))) {
85
+ throw new Error(`Workspace is locked by run ${existing.runId}`);
86
+ }
87
+ if (existing) {
88
+ await fs.unlink(this.lockPath).catch(() => undefined);
89
+ }
90
+ const payload = {
91
+ runId: this.runId,
92
+ acquiredAt: Date.now(),
93
+ pid: process.pid,
94
+ hostname: this.hostname,
95
+ };
96
+ await fs.writeFile(this.lockPath, JSON.stringify(payload, null, 2), "utf8");
97
+ this.acquired = true;
98
+ }
99
+ async release() {
100
+ if (!this.acquired)
101
+ return;
102
+ const existing = await this.readLock();
103
+ if (existing?.runId && existing.runId !== this.runId) {
104
+ return;
105
+ }
106
+ await fs.unlink(this.lockPath).catch(() => undefined);
107
+ this.acquired = false;
108
+ }
109
+ registerSignalHandlers(options = {}) {
110
+ const exitOnSignal = options.exitOnSignal ?? true;
111
+ const exitCodeForSignal = options.exitCodeForSignal ?? ((signal) => (signal === "SIGTERM" ? 143 : 130));
112
+ let handled = false;
113
+ const listeners = new Map();
114
+ const signals = ["SIGINT", "SIGTERM", "SIGTSTP", "SIGQUIT", "SIGHUP"];
115
+ const handler = (signal) => {
116
+ if (handled)
117
+ return;
118
+ handled = true;
119
+ const releasePromise = this.release().catch(() => undefined);
120
+ // Fire and forget any extra signal handling to avoid delaying unlock/exit.
121
+ Promise.resolve(options.onSignal?.(signal)).catch(() => undefined);
122
+ releasePromise.finally(() => {
123
+ if (exitOnSignal) {
124
+ process.exitCode = exitCodeForSignal(signal);
125
+ process.exit();
126
+ }
127
+ });
128
+ };
129
+ for (const signal of signals) {
130
+ const listener = () => handler(signal);
131
+ listeners.set(signal, listener);
132
+ process.once(signal, listener);
133
+ }
134
+ return () => {
135
+ for (const [signal, listener] of listeners.entries()) {
136
+ process.off(signal, listener);
137
+ }
138
+ listeners.clear();
139
+ };
140
+ }
141
+ }
@@ -0,0 +1,14 @@
1
+ export interface InstructionBlock {
2
+ sourcePath: string;
3
+ scope: string;
4
+ precedence: number;
5
+ content: string;
6
+ }
7
+ export interface InstructionLoadOptions {
8
+ workspaceRoot: string;
9
+ focusPaths?: string[];
10
+ includeLocal?: boolean;
11
+ }
12
+ export declare const loadInstructionBlocks: (options: InstructionLoadOptions) => Promise<InstructionBlock[]>;
13
+ export declare const formatInstructionBlocks: (blocks: InstructionBlock[]) => string;
14
+ //# sourceMappingURL=InstructionLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InstructionLoader.d.ts","sourceRoot":"","sources":["../../src/session/InstructionLoader.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,sBAAsB;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAoED,eAAO,MAAM,qBAAqB,GAChC,SAAS,sBAAsB,KAC9B,OAAO,CAAC,gBAAgB,EAAE,CAiC5B,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAAI,QAAQ,gBAAgB,EAAE,KAAG,MAWpE,CAAC"}
@@ -0,0 +1,107 @@
1
+ import { promises as fs } from "node:fs";
2
+ import path from "node:path";
3
+ const fileExists = async (filePath) => {
4
+ try {
5
+ const stat = await fs.stat(filePath);
6
+ return stat.isFile();
7
+ }
8
+ catch {
9
+ return false;
10
+ }
11
+ };
12
+ const normalizeFocusPath = (workspaceRoot, value) => {
13
+ const resolved = path.resolve(workspaceRoot, value);
14
+ const relative = path.relative(workspaceRoot, resolved);
15
+ if (relative.startsWith("..") || path.isAbsolute(relative)) {
16
+ throw new Error("Instruction focus path is outside workspace root");
17
+ }
18
+ return resolved;
19
+ };
20
+ const focusDirForPath = async (workspaceRoot, value) => {
21
+ const resolved = normalizeFocusPath(workspaceRoot, value);
22
+ try {
23
+ const stat = await fs.stat(resolved);
24
+ return stat.isDirectory() ? resolved : path.dirname(resolved);
25
+ }
26
+ catch {
27
+ return path.extname(resolved) ? path.dirname(resolved) : resolved;
28
+ }
29
+ };
30
+ const ancestorDirs = (workspaceRoot, targetDir) => {
31
+ const dirs = [];
32
+ let current = path.resolve(targetDir);
33
+ const root = path.resolve(workspaceRoot);
34
+ while (true) {
35
+ const relative = path.relative(root, current);
36
+ if (relative.startsWith("..") || path.isAbsolute(relative))
37
+ break;
38
+ dirs.push(current);
39
+ if (current === root)
40
+ break;
41
+ current = path.dirname(current);
42
+ }
43
+ return dirs.reverse();
44
+ };
45
+ const toRepoRelativePath = (workspaceRoot, filePath) => {
46
+ const relative = path.relative(workspaceRoot, filePath) || path.basename(filePath);
47
+ return relative.split(path.sep).join("/");
48
+ };
49
+ const readBlock = async (workspaceRoot, filePath, precedence) => {
50
+ if (!(await fileExists(filePath)))
51
+ return undefined;
52
+ const content = await fs.readFile(filePath, "utf8");
53
+ if (!content.trim())
54
+ return undefined;
55
+ const relative = toRepoRelativePath(workspaceRoot, filePath);
56
+ const sourceDir = path.posix.dirname(relative);
57
+ const scope = sourceDir === "." ? "." : sourceDir;
58
+ return {
59
+ sourcePath: relative,
60
+ scope,
61
+ precedence,
62
+ content,
63
+ };
64
+ };
65
+ export const loadInstructionBlocks = async (options) => {
66
+ const workspaceRoot = path.resolve(options.workspaceRoot);
67
+ const includeLocal = options.includeLocal ?? true;
68
+ const focusPaths = options.focusPaths?.length ? options.focusPaths : ["."];
69
+ const blocks = [];
70
+ const seen = new Set();
71
+ let precedence = 0;
72
+ const addFile = async (filePath) => {
73
+ const resolved = path.resolve(filePath);
74
+ if (seen.has(resolved))
75
+ return;
76
+ seen.add(resolved);
77
+ const block = await readBlock(workspaceRoot, resolved, precedence);
78
+ precedence += 1;
79
+ if (block)
80
+ blocks.push(block);
81
+ };
82
+ await addFile(path.join(workspaceRoot, ".codali", "instructions.md"));
83
+ const dirs = new Set();
84
+ for (const focusPath of focusPaths) {
85
+ const focusDir = await focusDirForPath(workspaceRoot, focusPath);
86
+ for (const dir of ancestorDirs(workspaceRoot, focusDir))
87
+ dirs.add(dir);
88
+ }
89
+ for (const dir of Array.from(dirs).sort((a, b) => a.length - b.length || a.localeCompare(b))) {
90
+ await addFile(path.join(dir, "AGENTS.md"));
91
+ }
92
+ if (includeLocal) {
93
+ await addFile(path.join(workspaceRoot, ".codali", "local.md"));
94
+ }
95
+ return blocks.sort((a, b) => a.precedence - b.precedence);
96
+ };
97
+ export const formatInstructionBlocks = (blocks) => {
98
+ if (!blocks.length)
99
+ return "";
100
+ return blocks
101
+ .map((block) => [
102
+ `Instruction source: ${block.sourcePath}`,
103
+ `Scope: ${block.scope}`,
104
+ block.content.trim(),
105
+ ].join("\n"))
106
+ .join("\n\n---\n\n");
107
+ };
@@ -0,0 +1,81 @@
1
+ export type CodaliSessionStatus = "active" | "paused" | "completed" | "failed";
2
+ export interface CodaliSessionMetadata {
3
+ schemaVersion: 1;
4
+ sessionId: string;
5
+ repoRoot: string;
6
+ task: string;
7
+ status: CodaliSessionStatus;
8
+ branch?: string;
9
+ parentSessionId?: string;
10
+ runIds: string[];
11
+ transcriptRefs: string[];
12
+ summaryRefs: string[];
13
+ contextLaneRefs: string[];
14
+ instructionSources: string[];
15
+ createdAt: string;
16
+ updatedAt: string;
17
+ }
18
+ export type CodaliSessionTranscriptEventType = "run_started" | "provider_request" | "provider_response" | "tool_result" | "codali_response" | "subagent_result" | "final" | "error" | "note";
19
+ export interface CodaliSessionTranscriptEvent {
20
+ schemaVersion: 1;
21
+ sessionId: string;
22
+ type: CodaliSessionTranscriptEventType;
23
+ timestamp: string;
24
+ runId?: string;
25
+ data: Record<string, unknown>;
26
+ }
27
+ export interface CodaliSessionSummary {
28
+ schemaVersion: 1;
29
+ sessionId: string;
30
+ createdAt: string;
31
+ eventCount: number;
32
+ summary: string;
33
+ highlights: string[];
34
+ }
35
+ export interface CodaliResumeBundle {
36
+ metadata: CodaliSessionMetadata;
37
+ latestSummary?: CodaliSessionSummary;
38
+ recentEvents: CodaliSessionTranscriptEvent[];
39
+ }
40
+ export interface SessionStoreOptions {
41
+ workspaceRoot: string;
42
+ storageDir?: string;
43
+ }
44
+ export interface CreateSessionInput {
45
+ sessionId?: string;
46
+ repoRoot: string;
47
+ task: string;
48
+ status?: CodaliSessionStatus;
49
+ branch?: string;
50
+ parentSessionId?: string;
51
+ contextLaneRefs?: string[];
52
+ instructionSources?: string[];
53
+ }
54
+ export declare class SessionStore {
55
+ readonly workspaceRoot: string;
56
+ readonly storageDir: string;
57
+ private lastTimestampMs;
58
+ constructor(options: SessionStoreOptions);
59
+ private rootDir;
60
+ private sessionDir;
61
+ private metadataPath;
62
+ private transcriptPath;
63
+ private summariesDir;
64
+ private nextTimestampIso;
65
+ createSession(input: CreateSessionInput): Promise<CodaliSessionMetadata>;
66
+ readSession(sessionId: string): Promise<CodaliSessionMetadata>;
67
+ getOrCreateSession(input: CreateSessionInput): Promise<CodaliSessionMetadata>;
68
+ updateSession(sessionId: string, patch: Partial<Omit<CodaliSessionMetadata, "schemaVersion" | "sessionId" | "createdAt">>): Promise<CodaliSessionMetadata>;
69
+ addRun(sessionId: string, runId: string): Promise<CodaliSessionMetadata>;
70
+ appendTranscript(sessionId: string, event: Omit<CodaliSessionTranscriptEvent, "schemaVersion" | "sessionId" | "timestamp"> & {
71
+ timestamp?: string;
72
+ }): Promise<CodaliSessionTranscriptEvent>;
73
+ readTranscript(sessionId: string): Promise<CodaliSessionTranscriptEvent[]>;
74
+ listSessions(): Promise<CodaliSessionMetadata[]>;
75
+ compactSession(sessionId: string): Promise<CodaliSessionSummary>;
76
+ readLatestSummary(sessionId: string): Promise<CodaliSessionSummary | undefined>;
77
+ buildResumeBundle(sessionId: string, options?: {
78
+ recentEvents?: number;
79
+ }): Promise<CodaliResumeBundle>;
80
+ }
81
+ //# sourceMappingURL=SessionStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SessionStore.d.ts","sourceRoot":"","sources":["../../src/session/SessionStore.ts"],"names":[],"mappings":"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"}