@qduc/term2 0.1.2 → 0.1.3

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 (235) hide show
  1. package/dist/agent.lite-mode.test.d.ts +2 -0
  2. package/dist/agent.lite-mode.test.d.ts.map +1 -0
  3. package/dist/agent.lite-mode.test.js +39 -0
  4. package/dist/agent.lite-mode.test.js.map +1 -0
  5. package/dist/app.d.ts.map +1 -1
  6. package/dist/app.js +3 -1
  7. package/dist/app.js.map +1 -1
  8. package/dist/components/ApprovalPrompt.d.ts.map +1 -1
  9. package/dist/components/ApprovalPrompt.js +20 -0
  10. package/dist/components/ApprovalPrompt.js.map +1 -1
  11. package/dist/components/InputBox.d.ts.map +1 -1
  12. package/dist/components/InputBox.js +2 -7
  13. package/dist/components/InputBox.js.map +1 -1
  14. package/dist/components/TextInput.d.ts.map +1 -1
  15. package/dist/components/TextInput.js +2 -1
  16. package/dist/components/TextInput.js.map +1 -1
  17. package/dist/components/TextInput.test.js.map +1 -1
  18. package/dist/debug_ask_mentor.d.ts +2 -0
  19. package/dist/debug_ask_mentor.d.ts.map +1 -0
  20. package/dist/debug_ask_mentor.js +73 -0
  21. package/dist/debug_ask_mentor.js.map +1 -0
  22. package/dist/hooks/use-model-selection.d.ts.map +1 -1
  23. package/dist/hooks/use-model-selection.js +7 -3
  24. package/dist/hooks/use-model-selection.js.map +1 -1
  25. package/dist/hooks/use-settings-completion.d.ts.map +1 -1
  26. package/dist/hooks/use-settings-completion.js +3 -0
  27. package/dist/hooks/use-settings-completion.js.map +1 -1
  28. package/dist/hooks/use-settings-completion.test.js +6 -0
  29. package/dist/hooks/use-settings-completion.test.js.map +1 -1
  30. package/dist/lib/openai-agent-client.d.ts.map +1 -1
  31. package/dist/lib/openai-agent-client.js +35 -15
  32. package/dist/lib/openai-agent-client.js.map +1 -1
  33. package/dist/lib/tool-invoke.test.js +1 -1
  34. package/dist/lib/tool-invoke.test.js.map +1 -1
  35. package/dist/modes/companion/command-index.d.ts +26 -0
  36. package/dist/modes/companion/command-index.d.ts.map +1 -0
  37. package/dist/modes/companion/command-index.js +50 -0
  38. package/dist/modes/companion/command-index.js.map +1 -0
  39. package/dist/modes/companion/command-index.test.d.ts +2 -0
  40. package/dist/modes/companion/command-index.test.d.ts.map +1 -0
  41. package/dist/modes/companion/command-index.test.js +86 -0
  42. package/dist/modes/companion/command-index.test.js.map +1 -0
  43. package/dist/modes/companion/companion-app.d.ts +12 -0
  44. package/dist/modes/companion/companion-app.d.ts.map +1 -0
  45. package/dist/modes/companion/companion-app.js +297 -0
  46. package/dist/modes/companion/companion-app.js.map +1 -0
  47. package/dist/modes/companion/companion-session.d.ts +63 -0
  48. package/dist/modes/companion/companion-session.d.ts.map +1 -0
  49. package/dist/modes/companion/companion-session.js +146 -0
  50. package/dist/modes/companion/companion-session.js.map +1 -0
  51. package/dist/modes/companion/companion-session.test.d.ts +2 -0
  52. package/dist/modes/companion/companion-session.test.d.ts.map +1 -0
  53. package/dist/modes/companion/companion-session.test.js +28 -0
  54. package/dist/modes/companion/companion-session.test.js.map +1 -0
  55. package/dist/modes/companion/components/status-bar.d.ts +13 -0
  56. package/dist/modes/companion/components/status-bar.d.ts.map +1 -0
  57. package/dist/modes/companion/components/status-bar.js +26 -0
  58. package/dist/modes/companion/components/status-bar.js.map +1 -0
  59. package/dist/modes/companion/context-buffer.d.ts +65 -0
  60. package/dist/modes/companion/context-buffer.d.ts.map +1 -0
  61. package/dist/modes/companion/context-buffer.js +156 -0
  62. package/dist/modes/companion/context-buffer.js.map +1 -0
  63. package/dist/modes/companion/context-buffer.test.d.ts +2 -0
  64. package/dist/modes/companion/context-buffer.test.d.ts.map +1 -0
  65. package/dist/modes/companion/context-buffer.test.js +154 -0
  66. package/dist/modes/companion/context-buffer.test.js.map +1 -0
  67. package/dist/modes/companion/event-detector.d.ts +46 -0
  68. package/dist/modes/companion/event-detector.d.ts.map +1 -0
  69. package/dist/modes/companion/event-detector.js +169 -0
  70. package/dist/modes/companion/event-detector.js.map +1 -0
  71. package/dist/modes/companion/event-detector.test.d.ts +2 -0
  72. package/dist/modes/companion/event-detector.test.d.ts.map +1 -0
  73. package/dist/modes/companion/event-detector.test.js +121 -0
  74. package/dist/modes/companion/event-detector.test.js.map +1 -0
  75. package/dist/modes/companion/index.d.ts +33 -0
  76. package/dist/modes/companion/index.d.ts.map +1 -0
  77. package/dist/modes/companion/index.js +21 -0
  78. package/dist/modes/companion/index.js.map +1 -0
  79. package/dist/modes/companion/input-key-mapper.d.ts +3 -0
  80. package/dist/modes/companion/input-key-mapper.d.ts.map +1 -0
  81. package/dist/modes/companion/input-key-mapper.js +31 -0
  82. package/dist/modes/companion/input-key-mapper.js.map +1 -0
  83. package/dist/modes/companion/input-key-mapper.test.d.ts +2 -0
  84. package/dist/modes/companion/input-key-mapper.test.d.ts.map +1 -0
  85. package/dist/modes/companion/input-key-mapper.test.js +26 -0
  86. package/dist/modes/companion/input-key-mapper.test.js.map +1 -0
  87. package/dist/modes/companion/input-parser.d.ts +53 -0
  88. package/dist/modes/companion/input-parser.d.ts.map +1 -0
  89. package/dist/modes/companion/input-parser.js +114 -0
  90. package/dist/modes/companion/input-parser.js.map +1 -0
  91. package/dist/modes/companion/input-parser.test.d.ts +2 -0
  92. package/dist/modes/companion/input-parser.test.d.ts.map +1 -0
  93. package/dist/modes/companion/input-parser.test.js +123 -0
  94. package/dist/modes/companion/input-parser.test.js.map +1 -0
  95. package/dist/modes/companion/mode-manager.d.ts +41 -0
  96. package/dist/modes/companion/mode-manager.d.ts.map +1 -0
  97. package/dist/modes/companion/mode-manager.js +56 -0
  98. package/dist/modes/companion/mode-manager.js.map +1 -0
  99. package/dist/modes/companion/mode-manager.test.d.ts +2 -0
  100. package/dist/modes/companion/mode-manager.test.d.ts.map +1 -0
  101. package/dist/modes/companion/mode-manager.test.js +65 -0
  102. package/dist/modes/companion/mode-manager.test.js.map +1 -0
  103. package/dist/modes/companion/output-classifier.d.ts +15 -0
  104. package/dist/modes/companion/output-classifier.d.ts.map +1 -0
  105. package/dist/modes/companion/output-classifier.js +77 -0
  106. package/dist/modes/companion/output-classifier.js.map +1 -0
  107. package/dist/modes/companion/output-classifier.test.d.ts +2 -0
  108. package/dist/modes/companion/output-classifier.test.d.ts.map +1 -0
  109. package/dist/modes/companion/output-classifier.test.js +133 -0
  110. package/dist/modes/companion/output-classifier.test.js.map +1 -0
  111. package/dist/modes/companion/pty-wrapper.d.ts +46 -0
  112. package/dist/modes/companion/pty-wrapper.d.ts.map +1 -0
  113. package/dist/modes/companion/pty-wrapper.js +143 -0
  114. package/dist/modes/companion/pty-wrapper.js.map +1 -0
  115. package/dist/modes/companion/safety-classifier.d.ts +31 -0
  116. package/dist/modes/companion/safety-classifier.d.ts.map +1 -0
  117. package/dist/modes/companion/safety-classifier.js +140 -0
  118. package/dist/modes/companion/safety-classifier.js.map +1 -0
  119. package/dist/modes/companion/safety-classifier.test.d.ts +2 -0
  120. package/dist/modes/companion/safety-classifier.test.d.ts.map +1 -0
  121. package/dist/modes/companion/safety-classifier.test.js +151 -0
  122. package/dist/modes/companion/safety-classifier.test.js.map +1 -0
  123. package/dist/modes/companion/summarizer.d.ts +24 -0
  124. package/dist/modes/companion/summarizer.d.ts.map +1 -0
  125. package/dist/modes/companion/summarizer.js +132 -0
  126. package/dist/modes/companion/summarizer.js.map +1 -0
  127. package/dist/modes/companion/terminal-history.d.ts +27 -0
  128. package/dist/modes/companion/terminal-history.d.ts.map +1 -0
  129. package/dist/modes/companion/terminal-history.js +142 -0
  130. package/dist/modes/companion/terminal-history.js.map +1 -0
  131. package/dist/prompts/simple-mentor.md +8 -0
  132. package/dist/providers/openai-compatible/model.d.ts.map +1 -1
  133. package/dist/providers/openai-compatible/model.js +13 -2
  134. package/dist/providers/openai-compatible/model.js.map +1 -1
  135. package/dist/providers/openai-compatible/reasoning-content.test.js +2 -2
  136. package/dist/providers/openai-compatible/reasoning-content.test.js.map +1 -1
  137. package/dist/providers/openrouter/reasoning-content.test.js +2 -2
  138. package/dist/providers/openrouter/reasoning-content.test.js.map +1 -1
  139. package/dist/providers/openrouter.test.js +30 -21
  140. package/dist/providers/openrouter.test.js.map +1 -1
  141. package/dist/services/check_mock.d.ts +2 -0
  142. package/dist/services/check_mock.d.ts.map +1 -0
  143. package/dist/services/check_mock.js +22 -0
  144. package/dist/services/check_mock.js.map +1 -0
  145. package/dist/services/conversation-service.test.d.ts +2 -0
  146. package/dist/services/conversation-service.test.d.ts.map +1 -0
  147. package/dist/services/conversation-service.test.js +149 -183
  148. package/dist/services/conversation-service.test.js.map +1 -0
  149. package/dist/services/conversation-store.test.js +12 -11
  150. package/dist/services/conversation-store.test.js.map +1 -1
  151. package/dist/services/settings-service.d.ts +5 -2
  152. package/dist/services/settings-service.d.ts.map +1 -1
  153. package/dist/services/settings-service.js +12 -0
  154. package/dist/services/settings-service.js.map +1 -1
  155. package/dist/tools/ask-mentor.d.ts +1 -1
  156. package/dist/tools/ask-mentor.d.ts.map +1 -1
  157. package/dist/tools/ask-mentor.js +1 -0
  158. package/dist/tools/ask-mentor.js.map +1 -1
  159. package/dist/tools/find-files.d.ts +2 -2
  160. package/dist/tools/find-files.d.ts.map +1 -1
  161. package/dist/tools/find-files.js +2 -0
  162. package/dist/tools/find-files.js.map +1 -1
  163. package/dist/tools/grep.d.ts +1 -1
  164. package/dist/tools/grep.d.ts.map +1 -1
  165. package/dist/tools/grep.js +1 -0
  166. package/dist/tools/grep.js.map +1 -1
  167. package/dist/tools/read-file.d.ts.map +1 -1
  168. package/dist/tools/read-file.js +10 -9
  169. package/dist/tools/read-file.js.map +1 -1
  170. package/dist/tools/read-file.test.js +24 -19
  171. package/dist/tools/read-file.test.js.map +1 -1
  172. package/dist/tools/search-replace.d.ts +1 -1
  173. package/dist/tools/search-replace.d.ts.map +1 -1
  174. package/dist/tools/search-replace.js +129 -1
  175. package/dist/tools/search-replace.js.map +1 -1
  176. package/dist/tools/search-replace.test.js +18 -0
  177. package/dist/tools/search-replace.test.js.map +1 -1
  178. package/dist/tools/search.d.ts +4 -4
  179. package/dist/tools/search.d.ts.map +1 -1
  180. package/dist/tools/search.js +4 -0
  181. package/dist/tools/search.js.map +1 -1
  182. package/dist/tools/shell.d.ts +2 -2
  183. package/dist/tools/shell.d.ts.map +1 -1
  184. package/dist/tools/shell.js +2 -0
  185. package/dist/tools/shell.js.map +1 -1
  186. package/dist/tools/types.d.ts +2 -2
  187. package/dist/tools/types.d.ts.map +1 -1
  188. package/dist/utils/command-safety.d.ts.map +1 -1
  189. package/dist/utils/command-safety.devnull.test.d.ts +2 -0
  190. package/dist/utils/command-safety.devnull.test.d.ts.map +1 -0
  191. package/dist/utils/command-safety.devnull.test.js +13 -0
  192. package/dist/utils/command-safety.devnull.test.js.map +1 -0
  193. package/dist/utils/command-safety.js +10 -364
  194. package/dist/utils/command-safety.js.map +1 -1
  195. package/dist/utils/extract-command-messages.test.d.ts +2 -0
  196. package/dist/utils/extract-command-messages.test.d.ts.map +1 -0
  197. package/dist/utils/extract-command-messages.test.js +58 -51
  198. package/dist/utils/extract-command-messages.test.js.map +1 -0
  199. package/dist/utils/settings-command.d.ts.map +1 -1
  200. package/dist/utils/settings-command.js +13 -4
  201. package/dist/utils/settings-command.js.map +1 -1
  202. package/package.json +2 -2
  203. package/dist/app.model-command-feedback.test.d.ts +0 -2
  204. package/dist/app.model-command-feedback.test.d.ts.map +0 -1
  205. package/dist/app.model-command-feedback.test.js +0 -19
  206. package/dist/app.model-command-feedback.test.js.map +0 -1
  207. package/dist/components/MentorMode.test.d.ts +0 -2
  208. package/dist/components/MentorMode.test.d.ts.map +0 -1
  209. package/dist/components/MentorMode.test.js.map +0 -1
  210. package/dist/debug-schema.d.ts +0 -2
  211. package/dist/debug-schema.d.ts.map +0 -1
  212. package/dist/debug-schema.js +0 -22
  213. package/dist/debug-schema.js.map +0 -1
  214. package/dist/hooks/use-model-selection.test.d.ts +0 -2
  215. package/dist/hooks/use-model-selection.test.d.ts.map +0 -1
  216. package/dist/hooks/use-model-selection.test.js +0 -28
  217. package/dist/hooks/use-model-selection.test.js.map +0 -1
  218. package/dist/hooks/use-path-completion.test.d.ts +0 -2
  219. package/dist/hooks/use-path-completion.test.d.ts.map +0 -1
  220. package/dist/hooks/use-path-completion.test.js +0 -29
  221. package/dist/hooks/use-path-completion.test.js.map +0 -1
  222. package/dist/prompts/default.md.bak +0 -77
  223. package/dist/providers/openrouter.history.test.d.ts +0 -2
  224. package/dist/providers/openrouter.history.test.d.ts.map +0 -1
  225. package/dist/providers/openrouter.history.test.js +0 -533
  226. package/dist/providers/openrouter.history.test.js.map +0 -1
  227. package/dist/test-search-tool.d.ts +0 -2
  228. package/dist/test-search-tool.d.ts.map +0 -1
  229. package/dist/test-search-tool.js +0 -36
  230. package/dist/test-search-tool.js.map +0 -1
  231. package/dist/utils/extract-command-messages.repro.test.d.ts +0 -2
  232. package/dist/utils/extract-command-messages.repro.test.d.ts.map +0 -1
  233. package/dist/utils/extract-command-messages.repro.test.js +0 -31
  234. package/dist/utils/extract-command-messages.repro.test.js.map +0 -1
  235. /package/{README.md → readme.md} +0 -0
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Context buffer for companion mode.
3
+ * Stores recent commands and their outputs in a rolling window.
4
+ */
5
+ export interface CommandEntry {
6
+ command: string;
7
+ output: string;
8
+ exitCode: number;
9
+ timestamp: number;
10
+ outputLines: number;
11
+ }
12
+ export interface CommandIndexEntry {
13
+ index: number;
14
+ command: string;
15
+ exitCode: number;
16
+ relativeTime: string;
17
+ outputLines: number;
18
+ hasErrors: boolean;
19
+ }
20
+ export interface ContextBufferOptions {
21
+ maxSize: number;
22
+ maxCommands: number;
23
+ }
24
+ /**
25
+ * Rolling buffer that stores command history with outputs.
26
+ * Generates lightweight command index for AI context.
27
+ */
28
+ export declare class ContextBuffer {
29
+ #private;
30
+ constructor(options: ContextBufferOptions);
31
+ /**
32
+ * Add a command entry to the buffer.
33
+ */
34
+ addEntry(entry: CommandEntry): void;
35
+ /**
36
+ * Get entry by index (0 = most recent).
37
+ */
38
+ getEntry(index: number): CommandEntry | undefined;
39
+ /**
40
+ * Get the last N entries (most recent first).
41
+ */
42
+ getLastN(n: number): CommandEntry[];
43
+ /**
44
+ * Search entries by command or output text.
45
+ */
46
+ search(pattern: string, limit?: number): CommandEntry[];
47
+ /**
48
+ * Get lightweight command index for AI context.
49
+ * This is always included in the AI's context window.
50
+ */
51
+ getIndex(): CommandIndexEntry[];
52
+ /**
53
+ * Get the total number of entries.
54
+ */
55
+ get length(): number;
56
+ /**
57
+ * Get the current buffer size in bytes.
58
+ */
59
+ get size(): number;
60
+ /**
61
+ * Clear all entries.
62
+ */
63
+ clear(): void;
64
+ }
65
+ //# sourceMappingURL=context-buffer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-buffer.d.ts","sourceRoot":"","sources":["../../../source/modes/companion/context-buffer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,YAAY;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,iBAAiB;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,oBAAoB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,qBAAa,aAAa;;gBAMV,OAAO,EAAE,oBAAoB;IAKzC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IA2BnC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAIjD;;OAEG;IACH,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,YAAY,EAAE;IAInC;;OAEG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,YAAY,EAAE;IAWlD;;;OAGG;IACH,QAAQ,IAAI,iBAAiB,EAAE;IAY/B;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,KAAK,IAAI,IAAI;CAoEhB"}
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Context buffer for companion mode.
3
+ * Stores recent commands and their outputs in a rolling window.
4
+ */
5
+ /**
6
+ * Rolling buffer that stores command history with outputs.
7
+ * Generates lightweight command index for AI context.
8
+ */
9
+ export class ContextBuffer {
10
+ #entries = [];
11
+ #maxSize;
12
+ #maxCommands;
13
+ #currentSize = 0;
14
+ constructor(options) {
15
+ this.#maxSize = options.maxSize;
16
+ this.#maxCommands = options.maxCommands;
17
+ }
18
+ /**
19
+ * Add a command entry to the buffer.
20
+ */
21
+ addEntry(entry) {
22
+ const entrySize = this.#calculateEntrySize(entry);
23
+ // Evict oldest entries if buffer would exceed max size
24
+ while (this.#entries.length > 0 &&
25
+ this.#currentSize + entrySize > this.#maxSize) {
26
+ const removed = this.#entries.pop();
27
+ if (removed) {
28
+ this.#currentSize -= this.#calculateEntrySize(removed);
29
+ }
30
+ }
31
+ // Evict if we'd exceed max commands
32
+ while (this.#entries.length >= this.#maxCommands) {
33
+ const removed = this.#entries.pop();
34
+ if (removed) {
35
+ this.#currentSize -= this.#calculateEntrySize(removed);
36
+ }
37
+ }
38
+ // Add new entry at the beginning (most recent first)
39
+ this.#entries.unshift(entry);
40
+ this.#currentSize += entrySize;
41
+ }
42
+ /**
43
+ * Get entry by index (0 = most recent).
44
+ */
45
+ getEntry(index) {
46
+ return this.#entries[index];
47
+ }
48
+ /**
49
+ * Get the last N entries (most recent first).
50
+ */
51
+ getLastN(n) {
52
+ return this.#entries.slice(0, Math.min(n, this.#entries.length));
53
+ }
54
+ /**
55
+ * Search entries by command or output text.
56
+ */
57
+ search(pattern, limit = 5) {
58
+ const lowerPattern = pattern.toLowerCase();
59
+ return this.#entries
60
+ .filter(entry => entry.command.toLowerCase().includes(lowerPattern) ||
61
+ entry.output.toLowerCase().includes(lowerPattern))
62
+ .slice(0, limit);
63
+ }
64
+ /**
65
+ * Get lightweight command index for AI context.
66
+ * This is always included in the AI's context window.
67
+ */
68
+ getIndex() {
69
+ const now = Date.now();
70
+ return this.#entries.map((entry, index) => ({
71
+ index,
72
+ command: entry.command,
73
+ exitCode: entry.exitCode,
74
+ relativeTime: this.#formatRelativeTime(now - entry.timestamp),
75
+ outputLines: entry.outputLines,
76
+ hasErrors: this.#detectErrors(entry),
77
+ }));
78
+ }
79
+ /**
80
+ * Get the total number of entries.
81
+ */
82
+ get length() {
83
+ return this.#entries.length;
84
+ }
85
+ /**
86
+ * Get the current buffer size in bytes.
87
+ */
88
+ get size() {
89
+ return this.#currentSize;
90
+ }
91
+ /**
92
+ * Clear all entries.
93
+ */
94
+ clear() {
95
+ this.#entries = [];
96
+ this.#currentSize = 0;
97
+ }
98
+ /**
99
+ * Calculate the approximate size of an entry in bytes.
100
+ *
101
+ * Size calculation methodology:
102
+ * - Command string length in bytes
103
+ * - Output string length in bytes
104
+ * - Fixed metadata overhead (100 bytes) accounts for:
105
+ * - exitCode: number (~8 bytes in V8)
106
+ * - timestamp: number (~8 bytes in V8)
107
+ * - outputLines: number (~8 bytes in V8)
108
+ * - Object overhead and references (~76 bytes estimated)
109
+ *
110
+ * This is intentionally conservative to ensure we don't exceed memory limits.
111
+ */
112
+ #calculateEntrySize(entry) {
113
+ const METADATA_OVERHEAD_BYTES = 100;
114
+ return ((entry.command?.length || 0) +
115
+ (entry.output?.length || 0) +
116
+ METADATA_OVERHEAD_BYTES);
117
+ }
118
+ /**
119
+ * Format timestamp as relative time string.
120
+ */
121
+ #formatRelativeTime(ms) {
122
+ const seconds = Math.floor(ms / 1000);
123
+ if (seconds < 60) {
124
+ return `${seconds}s ago`;
125
+ }
126
+ const minutes = Math.floor(seconds / 60);
127
+ if (minutes < 60) {
128
+ return `${minutes}m ago`;
129
+ }
130
+ const hours = Math.floor(minutes / 60);
131
+ return `${hours}h ago`;
132
+ }
133
+ /**
134
+ * Detect if an entry likely contains errors.
135
+ */
136
+ #detectErrors(entry) {
137
+ if (entry.exitCode !== 0) {
138
+ return true;
139
+ }
140
+ const output = entry.output.toLowerCase();
141
+ const errorPatterns = [
142
+ 'error',
143
+ 'fail',
144
+ 'exception',
145
+ 'fatal',
146
+ 'critical',
147
+ 'cannot',
148
+ "can't",
149
+ 'denied',
150
+ 'not found',
151
+ 'no such file',
152
+ ];
153
+ return errorPatterns.some(pattern => output.includes(pattern));
154
+ }
155
+ }
156
+ //# sourceMappingURL=context-buffer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-buffer.js","sourceRoot":"","sources":["../../../source/modes/companion/context-buffer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAwBH;;;GAGG;AACH,MAAM,OAAO,aAAa;IACtB,QAAQ,GAAmB,EAAE,CAAC;IAC9B,QAAQ,CAAS;IACjB,YAAY,CAAS;IACrB,YAAY,GAAG,CAAC,CAAC;IAEjB,YAAY,OAA6B;QACrC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;QAChC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,QAAQ,CAAC,KAAmB;QACxB,MAAM,SAAS,GAAG,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAElD,uDAAuD;QACvD,OACI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;YACxB,IAAI,CAAC,YAAY,GAAG,SAAS,GAAG,IAAI,CAAC,QAAQ,EAC/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AO,GAAG,EAAE,EAAE,CAAC;YACf,OAAO,GAAG,OAAO,OAAO,CAAC;QAC7B,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;QACzC,IAAI,OAAO,GAAG,EAAE,EAAE,CAAC;YACf,OAAO,GAAG,OAAO,OAAO,CAAC;QAC7B,CAAC;QACD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;QACvC,OAAO,GAAG,KAAK,OAAO,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,aAAa,CAAC,KAAmB;QAC7B,IAAI,KAAK,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QAC1C,MAAM,aAAa,GAAG;YAClB,OAAO;YACP,MAAM;YACN,WAAW;YACX,OAAO;YACP,UAAU;YACV,QAAQ;YACR,OAAO;YACP,QAAQ;YACR,WAAW;YACX,cAAc;SACjB,CAAC;QAEF,OAAO,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;IACnE,CAAC;CACJ"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=context-buffer.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-buffer.test.d.ts","sourceRoot":"","sources":["../../../source/modes/companion/context-buffer.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,154 @@
1
+ import test from 'ava';
2
+ import { ContextBuffer } from './context-buffer.js';
3
+ // Helper to create a test entry
4
+ function createEntry(command, output, exitCode = 0, timestamp = Date.now()) {
5
+ return {
6
+ command,
7
+ output,
8
+ exitCode,
9
+ timestamp,
10
+ outputLines: output.split('\n').length,
11
+ };
12
+ }
13
+ test('stores commands with output', t => {
14
+ const buffer = new ContextBuffer({ maxSize: 1024, maxCommands: 5 });
15
+ buffer.addEntry(createEntry('ls -la', 'file1.txt\nfile2.txt'));
16
+ const entries = buffer.getLastN(1);
17
+ t.is(entries[0]?.command, 'ls -la');
18
+ t.is(entries[0]?.output, 'file1.txt\nfile2.txt');
19
+ });
20
+ test('returns entries in most-recent-first order', t => {
21
+ const buffer = new ContextBuffer({ maxSize: 1024, maxCommands: 5 });
22
+ buffer.addEntry(createEntry('cmd1', 'out1', 0, 1));
23
+ buffer.addEntry(createEntry('cmd2', 'out2', 0, 2));
24
+ buffer.addEntry(createEntry('cmd3', 'out3', 0, 3));
25
+ const entries = buffer.getLastN(3);
26
+ t.is(entries[0]?.command, 'cmd3');
27
+ t.is(entries[1]?.command, 'cmd2');
28
+ t.is(entries[2]?.command, 'cmd1');
29
+ });
30
+ test('evicts oldest entries when maxCommands exceeded', t => {
31
+ const buffer = new ContextBuffer({ maxSize: 10000, maxCommands: 2 });
32
+ buffer.addEntry(createEntry('cmd1', 'out1', 0, 1));
33
+ buffer.addEntry(createEntry('cmd2', 'out2', 0, 2));
34
+ buffer.addEntry(createEntry('cmd3', 'out3', 0, 3));
35
+ const entries = buffer.getLastN(10);
36
+ t.is(entries.length, 2);
37
+ t.is(entries[0]?.command, 'cmd3');
38
+ t.is(entries[1]?.command, 'cmd2');
39
+ });
40
+ test('evicts entries when maxSize exceeded', t => {
41
+ // Each entry is ~100 bytes (command + output + overhead)
42
+ const buffer = new ContextBuffer({ maxSize: 200, maxCommands: 10 });
43
+ buffer.addEntry(createEntry('cmd1', 'x'.repeat(80), 0, 1));
44
+ buffer.addEntry(createEntry('cmd2', 'y'.repeat(80), 0, 2));
45
+ buffer.addEntry(createEntry('cmd3', 'z'.repeat(80), 0, 3));
46
+ // Should have evicted some entries due to size
47
+ t.true(buffer.length <= 2);
48
+ });
49
+ test('getEntry returns entry by index', t => {
50
+ const buffer = new ContextBuffer({ maxSize: 1024, maxCommands: 5 });
51
+ buffer.addEntry(createEntry('cmd1', 'out1', 0, 1));
52
+ buffer.addEntry(createEntry('cmd2', 'out2', 0, 2));
53
+ const entry = buffer.getEntry(1);
54
+ t.is(entry?.command, 'cmd1');
55
+ });
56
+ test('getEntry returns undefined for out of bounds index', t => {
57
+ const buffer = new ContextBuffer({ maxSize: 1024, maxCommands: 5 });
58
+ buffer.addEntry(createEntry('cmd1', 'out1'));
59
+ t.is(buffer.getEntry(5), undefined);
60
+ });
61
+ test('search finds entries by command', t => {
62
+ const buffer = new ContextBuffer({ maxSize: 1024, maxCommands: 10 });
63
+ buffer.addEntry(createEntry('npm test', 'passed'));
64
+ buffer.addEntry(createEntry('npm install', 'installed'));
65
+ buffer.addEntry(createEntry('git status', 'clean'));
66
+ const results = buffer.search('npm');
67
+ t.is(results.length, 2);
68
+ t.true(results.some(e => e.command === 'npm test'));
69
+ t.true(results.some(e => e.command === 'npm install'));
70
+ });
71
+ test('search finds entries by output', t => {
72
+ const buffer = new ContextBuffer({ maxSize: 1024, maxCommands: 10 });
73
+ buffer.addEntry(createEntry('test1', 'error: file not found'));
74
+ buffer.addEntry(createEntry('test2', 'success'));
75
+ const results = buffer.search('error');
76
+ t.is(results.length, 1);
77
+ t.is(results[0]?.command, 'test1');
78
+ });
79
+ test('search is case insensitive', t => {
80
+ const buffer = new ContextBuffer({ maxSize: 1024, maxCommands: 10 });
81
+ buffer.addEntry(createEntry('NPM TEST', 'passed'));
82
+ const results = buffer.search('npm');
83
+ t.is(results.length, 1);
84
+ });
85
+ test('search limits results', t => {
86
+ const buffer = new ContextBuffer({ maxSize: 1024, maxCommands: 10 });
87
+ for (let i = 0; i < 10; i++) {
88
+ buffer.addEntry(createEntry(`npm cmd${i}`, 'out'));
89
+ }
90
+ const results = buffer.search('npm', 3);
91
+ t.is(results.length, 3);
92
+ });
93
+ test('getIndex generates lightweight command index', t => {
94
+ const now = Date.now();
95
+ const buffer = new ContextBuffer({ maxSize: 1024, maxCommands: 10 });
96
+ buffer.addEntry(createEntry('npm test', 'FAIL: 2 tests failed', 1, now - 30000));
97
+ buffer.addEntry(createEntry('git diff', '+new line', 0, now - 5000));
98
+ const index = buffer.getIndex();
99
+ // Note: entries are in most-recent-first order, so git diff is first
100
+ t.is(index.length, 2);
101
+ t.is(index[0]?.command, 'git diff');
102
+ t.is(index[0]?.exitCode, 0);
103
+ t.false(index[0]?.hasErrors);
104
+ t.truthy(index[0]?.relativeTime);
105
+ t.is(index[1]?.command, 'npm test');
106
+ t.is(index[1]?.exitCode, 1);
107
+ t.true(index[1]?.hasErrors);
108
+ });
109
+ test('getIndex detects errors from exit code', t => {
110
+ const buffer = new ContextBuffer({ maxSize: 1024, maxCommands: 10 });
111
+ buffer.addEntry(createEntry('cmd', 'no error keywords', 1));
112
+ const index = buffer.getIndex();
113
+ t.true(index[0]?.hasErrors);
114
+ });
115
+ test('getIndex detects errors from output patterns', t => {
116
+ const buffer = new ContextBuffer({ maxSize: 1024, maxCommands: 10 });
117
+ buffer.addEntry(createEntry('cmd', 'fatal: something went wrong', 0));
118
+ const index = buffer.getIndex();
119
+ t.true(index[0]?.hasErrors);
120
+ });
121
+ test('getIndex formats relative time correctly', t => {
122
+ const now = Date.now();
123
+ const buffer = new ContextBuffer({ maxSize: 1024, maxCommands: 10 });
124
+ buffer.addEntry(createEntry('cmd1', 'out', 0, now - 120000)); // 2 minutes ago
125
+ buffer.addEntry(createEntry('cmd2', 'out', 0, now - 5000)); // 5 seconds ago (most recent)
126
+ const index = buffer.getIndex();
127
+ // Note: entries are in most-recent-first order
128
+ // cmd2 is most recent (5s ago), cmd1 is older (2m ago)
129
+ t.regex(index[0]?.relativeTime ?? '', /\d+s ago/);
130
+ t.regex(index[1]?.relativeTime ?? '', /\d+m ago/);
131
+ });
132
+ test('clear removes all entries', t => {
133
+ const buffer = new ContextBuffer({ maxSize: 1024, maxCommands: 10 });
134
+ buffer.addEntry(createEntry('cmd1', 'out1'));
135
+ buffer.addEntry(createEntry('cmd2', 'out2'));
136
+ buffer.clear();
137
+ t.is(buffer.length, 0);
138
+ t.is(buffer.size, 0);
139
+ });
140
+ test('length returns correct count', t => {
141
+ const buffer = new ContextBuffer({ maxSize: 1024, maxCommands: 10 });
142
+ t.is(buffer.length, 0);
143
+ buffer.addEntry(createEntry('cmd1', 'out1'));
144
+ t.is(buffer.length, 1);
145
+ buffer.addEntry(createEntry('cmd2', 'out2'));
146
+ t.is(buffer.length, 2);
147
+ });
148
+ test('size tracks buffer size in bytes', t => {
149
+ const buffer = new ContextBuffer({ maxSize: 10000, maxCommands: 10 });
150
+ t.is(buffer.size, 0);
151
+ buffer.addEntry(createEntry('cmd', 'output'));
152
+ t.true(buffer.size > 0);
153
+ });
154
+ //# sourceMappingURL=context-buffer.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-buffer.test.js","sourceRoot":"","sources":["../../../source/modes/companion/context-buffer.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,KAAK,CAAC;AACvB,OAAO,EAAC,aAAa,EAAoB,MAAM,qBAAqB,CAAC;AAErE,gCAAgC;AAChC,SAAS,WAAW,CAChB,OAAe,EACf,MAAc,EACd,QAAQ,GAAG,CAAC,EACZ,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE;IAEtB,OAAO;QACH,OAAO;QACP,MAAM;QACN,QAAQ;QACR,SAAS;QACT,WAAW,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM;KACzC,CAAC;AACN,CAAC;AAED,IAAI,CAAC,6BAA6B,EAAE,CAAC,CAAC,EAAE;IACpC,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,EAAC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,EAAC,CAAC,CAAC;IAElE,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC,CAAC;IAE/D,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CA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EpE,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAErB,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC9C,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;AAC5B,CAAC,CAAC,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { EventEmitter } from 'events';
2
+ import type { CommandEntry } from './context-buffer.js';
3
+ export type EventPattern = 'error_cascade' | 'retry_loop' | 'long_pause';
4
+ export interface EventDetectorOptions {
5
+ errorCascadeThreshold: number;
6
+ retryLoopThreshold: number;
7
+ pauseHintDelayMs: number;
8
+ }
9
+ export interface DetectedEvent {
10
+ pattern: EventPattern;
11
+ message: string;
12
+ timestamp: number;
13
+ }
14
+ /**
15
+ * Detects patterns in command history that might indicate user needs help.
16
+ * Emits events when patterns are detected.
17
+ */
18
+ export declare class EventDetector extends EventEmitter {
19
+ #private;
20
+ constructor(options?: Partial<EventDetectorOptions>);
21
+ /**
22
+ * Get time since last activity in milliseconds.
23
+ */
24
+ get timeSinceLastActivity(): number;
25
+ /**
26
+ * Process a new command entry and check for patterns.
27
+ */
28
+ processCommand(entry: CommandEntry): DetectedEvent | null;
29
+ /**
30
+ * Mark user activity to reset pause detection.
31
+ */
32
+ markActivity(): void;
33
+ /**
34
+ * Get current detector options.
35
+ */
36
+ getOptions(): EventDetectorOptions;
37
+ /**
38
+ * Update detector options.
39
+ */
40
+ setOptions(options: Partial<EventDetectorOptions>): void;
41
+ /**
42
+ * Clear state.
43
+ */
44
+ clear(): void;
45
+ }
46
+ //# sourceMappingURL=event-detector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-detector.d.ts","sourceRoot":"","sources":["../../../source/modes/companion/event-detector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,QAAQ,CAAC;AACpC,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAC;AAEtD,MAAM,MAAM,YAAY,GAAG,eAAe,GAAG,YAAY,GAAG,YAAY,CAAC;AAEzE,MAAM,WAAW,oBAAoB;IACjC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gBAAgB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,aAAa;IAC1B,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACrB;AAQD;;;GAGG;AACH,qBAAa,aAAc,SAAQ,YAAY;;gBAO/B,OAAO,GAAE,OAAO,CAAC,oBAAoB,CAAM;IAKvD;;OAEG;IACH,IAAI,qBAAqB,IAAI,MAAM,CAElC;IAED;;OAEG;IACH,cAAc,CAAC,KAAK,EAAE,YAAY,GAAG,aAAa,GAAG,IAAI;IAoCzD;;OAEG;IACH,YAAY,IAAI,IAAI;IAQpB;;OAEG;IACH,UAAU,IAAI,oBAAoB;IAIlC;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,IAAI;IAIxD;;OAEG;IACH,KAAK,IAAI,IAAI;CA6FhB"}
@@ -0,0 +1,169 @@
1
+ import { EventEmitter } from 'events';
2
+ const DEFAULT_OPTIONS = {
3
+ errorCascadeThreshold: 3,
4
+ retryLoopThreshold: 2,
5
+ pauseHintDelayMs: 30000,
6
+ };
7
+ /**
8
+ * Detects patterns in command history that might indicate user needs help.
9
+ * Emits events when patterns are detected.
10
+ */
11
+ export class EventDetector extends EventEmitter {
12
+ #options;
13
+ #recentCommands = [];
14
+ #lastActivityTime = Date.now();
15
+ #lastErrorTime = null;
16
+ #pauseTimer = null;
17
+ constructor(options = {}) {
18
+ super();
19
+ this.#options = { ...DEFAULT_OPTIONS, ...options };
20
+ }
21
+ /**
22
+ * Get time since last activity in milliseconds.
23
+ */
24
+ get timeSinceLastActivity() {
25
+ return Date.now() - this.#lastActivityTime;
26
+ }
27
+ /**
28
+ * Process a new command entry and check for patterns.
29
+ */
30
+ processCommand(entry) {
31
+ this.#recentCommands.unshift(entry);
32
+ this.#lastActivityTime = Date.now();
33
+ // Clear pause timer on new activity
34
+ if (this.#pauseTimer) {
35
+ clearTimeout(this.#pauseTimer);
36
+ this.#pauseTimer = null;
37
+ }
38
+ // Keep only recent commands for pattern detection
39
+ if (this.#recentCommands.length > 10) {
40
+ this.#recentCommands = this.#recentCommands.slice(0, 10);
41
+ }
42
+ // Check for error cascade
43
+ const cascadeEvent = this.#checkErrorCascade();
44
+ if (cascadeEvent) {
45
+ return cascadeEvent;
46
+ }
47
+ // Check for retry loop
48
+ const retryEvent = this.#checkRetryLoop();
49
+ if (retryEvent) {
50
+ return retryEvent;
51
+ }
52
+ // Track error time for pause detection
53
+ if (entry.exitCode !== 0) {
54
+ this.#lastErrorTime = Date.now();
55
+ this.#startPauseTimer();
56
+ }
57
+ return null;
58
+ }
59
+ /**
60
+ * Mark user activity to reset pause detection.
61
+ */
62
+ markActivity() {
63
+ this.#lastActivityTime = Date.now();
64
+ if (this.#pauseTimer) {
65
+ clearTimeout(this.#pauseTimer);
66
+ this.#pauseTimer = null;
67
+ }
68
+ }
69
+ /**
70
+ * Get current detector options.
71
+ */
72
+ getOptions() {
73
+ return { ...this.#options };
74
+ }
75
+ /**
76
+ * Update detector options.
77
+ */
78
+ setOptions(options) {
79
+ this.#options = { ...this.#options, ...options };
80
+ }
81
+ /**
82
+ * Clear state.
83
+ */
84
+ clear() {
85
+ this.#recentCommands = [];
86
+ this.#lastActivityTime = Date.now();
87
+ this.#lastErrorTime = null;
88
+ if (this.#pauseTimer) {
89
+ clearTimeout(this.#pauseTimer);
90
+ this.#pauseTimer = null;
91
+ }
92
+ }
93
+ /**
94
+ * Check for consecutive command failures.
95
+ */
96
+ #checkErrorCascade() {
97
+ const threshold = this.#options.errorCascadeThreshold;
98
+ let consecutiveFailures = 0;
99
+ for (const entry of this.#recentCommands) {
100
+ if (entry.exitCode !== 0) {
101
+ consecutiveFailures++;
102
+ }
103
+ else {
104
+ break;
105
+ }
106
+ }
107
+ if (consecutiveFailures >= threshold) {
108
+ return {
109
+ pattern: 'error_cascade',
110
+ message: `Stuck? ${consecutiveFailures} commands failed. Type ?? for help.`,
111
+ timestamp: Date.now(),
112
+ };
113
+ }
114
+ return null;
115
+ }
116
+ /**
117
+ * Check for repeated identical commands.
118
+ */
119
+ #checkRetryLoop() {
120
+ const threshold = this.#options.retryLoopThreshold;
121
+ if (this.#recentCommands.length < threshold) {
122
+ return null;
123
+ }
124
+ const lastCommand = this.#recentCommands[0]?.command;
125
+ if (!lastCommand) {
126
+ return null;
127
+ }
128
+ let repeatCount = 0;
129
+ for (const entry of this.#recentCommands) {
130
+ if (entry.command === lastCommand) {
131
+ repeatCount++;
132
+ }
133
+ else {
134
+ break;
135
+ }
136
+ }
137
+ if (repeatCount >= threshold) {
138
+ return {
139
+ pattern: 'retry_loop',
140
+ message: `Same command run ${repeatCount} times. Try ?? why isn't this working`,
141
+ timestamp: Date.now(),
142
+ };
143
+ }
144
+ return null;
145
+ }
146
+ /**
147
+ * Start timer for detecting long pause after error.
148
+ */
149
+ #startPauseTimer() {
150
+ if (this.#pauseTimer) {
151
+ clearTimeout(this.#pauseTimer);
152
+ }
153
+ this.#pauseTimer = setTimeout(() => {
154
+ if (this.#lastErrorTime !== null) {
155
+ const timeSinceError = Date.now() - this.#lastErrorTime;
156
+ if (timeSinceError >= this.#options.pauseHintDelayMs) {
157
+ const event = {
158
+ pattern: 'long_pause',
159
+ message: 'Need help with that error?',
160
+ timestamp: Date.now(),
161
+ };
162
+ this.emit('hint', event);
163
+ }
164
+ }
165
+ this.#pauseTimer = null;
166
+ }, this.#options.pauseHintDelayMs);
167
+ }
168
+ }
169
+ //# sourceMappingURL=event-detector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-detector.js","sourceRoot":"","sources":["../../../source/modes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,oBAAoB,WAAW,uCAAuC;gBAC/E,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;aACxB,CAAC;QACN,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,gBAAgB;QACZ,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACnC,CAAC;QAED,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,GAAG,EAAE;YAC/B,IAAI,IAAI,CAAC,cAAc,KAAK,IAAI,EAAE,CAAC;gBAC/B,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC;gBACxD,IAAI,cAAc,IAAI,IAAI,CAAC,QAAQ,CAAC,gBAAgB,EAAE,CAAC;oBACnD,MAAM,KAAK,GAAkB;wBACzB,OAAO,EAAE,YAAY;wBACrB,OAAO,EAAE,4BAA4B;wBACrC,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;qBACxB,CAAC;oBACF,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;gBAC7B,CAAC;YACL,CAAC;YACD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAC5B,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IACvC,CAAC;CACJ"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=event-detector.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-detector.test.d.ts","sourceRoot":"","sources":["../../../source/modes/companion/event-detector.test.ts"],"names":[],"mappings":""}