@channelfactory/cliend 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/dist/bin/cliend.d.ts +3 -0
  2. package/dist/bin/cliend.d.ts.map +1 -0
  3. package/dist/bin/cliend.js +7 -0
  4. package/dist/bin/cliend.js.map +1 -0
  5. package/dist/src/auth/auth-manager.d.ts +16 -0
  6. package/dist/src/auth/auth-manager.d.ts.map +1 -0
  7. package/dist/src/auth/auth-manager.js +135 -0
  8. package/dist/src/auth/auth-manager.js.map +1 -0
  9. package/dist/src/auth/credentials-store.d.ts +12 -0
  10. package/dist/src/auth/credentials-store.d.ts.map +1 -0
  11. package/dist/src/auth/credentials-store.js +95 -0
  12. package/dist/src/auth/credentials-store.js.map +1 -0
  13. package/dist/src/auth/local-server.d.ts +14 -0
  14. package/dist/src/auth/local-server.d.ts.map +1 -0
  15. package/dist/src/auth/local-server.js +49 -0
  16. package/dist/src/auth/local-server.js.map +1 -0
  17. package/dist/src/config/config-manager.d.ts +11 -0
  18. package/dist/src/config/config-manager.d.ts.map +1 -0
  19. package/dist/src/config/config-manager.js +102 -0
  20. package/dist/src/config/config-manager.js.map +1 -0
  21. package/dist/src/config/config.schema.d.ts +276 -0
  22. package/dist/src/config/config.schema.d.ts.map +1 -0
  23. package/dist/src/config/config.schema.js +46 -0
  24. package/dist/src/config/config.schema.js.map +1 -0
  25. package/dist/src/config/defaults.d.ts +3 -0
  26. package/dist/src/config/defaults.d.ts.map +1 -0
  27. package/dist/src/config/defaults.js +46 -0
  28. package/dist/src/config/defaults.js.map +1 -0
  29. package/dist/src/core/context-builder.d.ts +6 -0
  30. package/dist/src/core/context-builder.d.ts.map +1 -0
  31. package/dist/src/core/context-builder.js +55 -0
  32. package/dist/src/core/context-builder.js.map +1 -0
  33. package/dist/src/core/fan-out-executor.d.ts +16 -0
  34. package/dist/src/core/fan-out-executor.d.ts.map +1 -0
  35. package/dist/src/core/fan-out-executor.js +55 -0
  36. package/dist/src/core/fan-out-executor.js.map +1 -0
  37. package/dist/src/core/judge.d.ts +15 -0
  38. package/dist/src/core/judge.d.ts.map +1 -0
  39. package/dist/src/core/judge.js +133 -0
  40. package/dist/src/core/judge.js.map +1 -0
  41. package/dist/src/core/orchestrator.d.ts +19 -0
  42. package/dist/src/core/orchestrator.d.ts.map +1 -0
  43. package/dist/src/core/orchestrator.js +76 -0
  44. package/dist/src/core/orchestrator.js.map +1 -0
  45. package/dist/src/errors/auth-error.d.ts +16 -0
  46. package/dist/src/errors/auth-error.d.ts.map +1 -0
  47. package/dist/src/errors/auth-error.js +30 -0
  48. package/dist/src/errors/auth-error.js.map +1 -0
  49. package/dist/src/errors/base-error.d.ts +13 -0
  50. package/dist/src/errors/base-error.d.ts.map +1 -0
  51. package/dist/src/errors/base-error.js +13 -0
  52. package/dist/src/errors/base-error.js.map +1 -0
  53. package/dist/src/errors/error-handler.d.ts +7 -0
  54. package/dist/src/errors/error-handler.d.ts.map +1 -0
  55. package/dist/src/errors/error-handler.js +20 -0
  56. package/dist/src/errors/error-handler.js.map +1 -0
  57. package/dist/src/errors/integration-error.d.ts +20 -0
  58. package/dist/src/errors/integration-error.d.ts.map +1 -0
  59. package/dist/src/errors/integration-error.js +29 -0
  60. package/dist/src/errors/integration-error.js.map +1 -0
  61. package/dist/src/errors/provider-error.d.ts +23 -0
  62. package/dist/src/errors/provider-error.d.ts.map +1 -0
  63. package/dist/src/errors/provider-error.js +49 -0
  64. package/dist/src/errors/provider-error.js.map +1 -0
  65. package/dist/src/index.d.ts +2 -0
  66. package/dist/src/index.d.ts.map +1 -0
  67. package/dist/src/index.js +20 -0
  68. package/dist/src/index.js.map +1 -0
  69. package/dist/src/integrations/atlassian/jira-client.d.ts +16 -0
  70. package/dist/src/integrations/atlassian/jira-client.d.ts.map +1 -0
  71. package/dist/src/integrations/atlassian/jira-client.js +100 -0
  72. package/dist/src/integrations/atlassian/jira-client.js.map +1 -0
  73. package/dist/src/integrations/atlassian/oauth.d.ts +2 -0
  74. package/dist/src/integrations/atlassian/oauth.d.ts.map +1 -0
  75. package/dist/src/integrations/atlassian/oauth.js +3 -0
  76. package/dist/src/integrations/atlassian/oauth.js.map +1 -0
  77. package/dist/src/integrations/atlassian/rovo-client.d.ts +13 -0
  78. package/dist/src/integrations/atlassian/rovo-client.d.ts.map +1 -0
  79. package/dist/src/integrations/atlassian/rovo-client.js +17 -0
  80. package/dist/src/integrations/atlassian/rovo-client.js.map +1 -0
  81. package/dist/src/integrations/atlassian/token-store.d.ts +2 -0
  82. package/dist/src/integrations/atlassian/token-store.d.ts.map +1 -0
  83. package/dist/src/integrations/atlassian/token-store.js +3 -0
  84. package/dist/src/integrations/atlassian/token-store.js.map +1 -0
  85. package/dist/src/integrations/bitbucket/bitbucket-client.d.ts +23 -0
  86. package/dist/src/integrations/bitbucket/bitbucket-client.d.ts.map +1 -0
  87. package/dist/src/integrations/bitbucket/bitbucket-client.js +58 -0
  88. package/dist/src/integrations/bitbucket/bitbucket-client.js.map +1 -0
  89. package/dist/src/integrations/bitbucket/obsidian-reader.d.ts +21 -0
  90. package/dist/src/integrations/bitbucket/obsidian-reader.d.ts.map +1 -0
  91. package/dist/src/integrations/bitbucket/obsidian-reader.js +85 -0
  92. package/dist/src/integrations/bitbucket/obsidian-reader.js.map +1 -0
  93. package/dist/src/providers/chatgpt.provider.d.ts +17 -0
  94. package/dist/src/providers/chatgpt.provider.d.ts.map +1 -0
  95. package/dist/src/providers/chatgpt.provider.js +66 -0
  96. package/dist/src/providers/chatgpt.provider.js.map +1 -0
  97. package/dist/src/providers/claude.provider.d.ts +17 -0
  98. package/dist/src/providers/claude.provider.d.ts.map +1 -0
  99. package/dist/src/providers/claude.provider.js +70 -0
  100. package/dist/src/providers/claude.provider.js.map +1 -0
  101. package/dist/src/providers/codex.provider.d.ts +17 -0
  102. package/dist/src/providers/codex.provider.d.ts.map +1 -0
  103. package/dist/src/providers/codex.provider.js +64 -0
  104. package/dist/src/providers/codex.provider.js.map +1 -0
  105. package/dist/src/providers/provider-registry.d.ts +10 -0
  106. package/dist/src/providers/provider-registry.d.ts.map +1 -0
  107. package/dist/src/providers/provider-registry.js +29 -0
  108. package/dist/src/providers/provider-registry.js.map +1 -0
  109. package/dist/src/providers/provider.interface.d.ts +10 -0
  110. package/dist/src/providers/provider.interface.d.ts.map +1 -0
  111. package/dist/src/providers/provider.interface.js +2 -0
  112. package/dist/src/providers/provider.interface.js.map +1 -0
  113. package/dist/src/repl/command-registry.d.ts +25 -0
  114. package/dist/src/repl/command-registry.d.ts.map +1 -0
  115. package/dist/src/repl/command-registry.js +19 -0
  116. package/dist/src/repl/command-registry.js.map +1 -0
  117. package/dist/src/repl/commands/auth.d.ts +3 -0
  118. package/dist/src/repl/commands/auth.d.ts.map +1 -0
  119. package/dist/src/repl/commands/auth.js +17 -0
  120. package/dist/src/repl/commands/auth.js.map +1 -0
  121. package/dist/src/repl/commands/config.d.ts +3 -0
  122. package/dist/src/repl/commands/config.d.ts.map +1 -0
  123. package/dist/src/repl/commands/config.js +39 -0
  124. package/dist/src/repl/commands/config.js.map +1 -0
  125. package/dist/src/repl/commands/help.d.ts +3 -0
  126. package/dist/src/repl/commands/help.d.ts.map +1 -0
  127. package/dist/src/repl/commands/help.js +33 -0
  128. package/dist/src/repl/commands/help.js.map +1 -0
  129. package/dist/src/repl/commands/memory.d.ts +3 -0
  130. package/dist/src/repl/commands/memory.d.ts.map +1 -0
  131. package/dist/src/repl/commands/memory.js +30 -0
  132. package/dist/src/repl/commands/memory.js.map +1 -0
  133. package/dist/src/repl/commands/obsidian.d.ts +3 -0
  134. package/dist/src/repl/commands/obsidian.d.ts.map +1 -0
  135. package/dist/src/repl/commands/obsidian.js +30 -0
  136. package/dist/src/repl/commands/obsidian.js.map +1 -0
  137. package/dist/src/repl/commands/sessions.d.ts +5 -0
  138. package/dist/src/repl/commands/sessions.d.ts.map +1 -0
  139. package/dist/src/repl/commands/sessions.js +77 -0
  140. package/dist/src/repl/commands/sessions.js.map +1 -0
  141. package/dist/src/repl/commands/status.d.ts +3 -0
  142. package/dist/src/repl/commands/status.d.ts.map +1 -0
  143. package/dist/src/repl/commands/status.js +32 -0
  144. package/dist/src/repl/commands/status.js.map +1 -0
  145. package/dist/src/repl/commands/ticket.d.ts +3 -0
  146. package/dist/src/repl/commands/ticket.d.ts.map +1 -0
  147. package/dist/src/repl/commands/ticket.js +38 -0
  148. package/dist/src/repl/commands/ticket.js.map +1 -0
  149. package/dist/src/repl/input-parser.d.ts +13 -0
  150. package/dist/src/repl/input-parser.d.ts.map +1 -0
  151. package/dist/src/repl/input-parser.js +25 -0
  152. package/dist/src/repl/input-parser.js.map +1 -0
  153. package/dist/src/repl/repl.d.ts +34 -0
  154. package/dist/src/repl/repl.d.ts.map +1 -0
  155. package/dist/src/repl/repl.js +180 -0
  156. package/dist/src/repl/repl.js.map +1 -0
  157. package/dist/src/session/history.d.ts +8 -0
  158. package/dist/src/session/history.d.ts.map +1 -0
  159. package/dist/src/session/history.js +26 -0
  160. package/dist/src/session/history.js.map +1 -0
  161. package/dist/src/session/memory-manager.d.ts +20 -0
  162. package/dist/src/session/memory-manager.d.ts.map +1 -0
  163. package/dist/src/session/memory-manager.js +65 -0
  164. package/dist/src/session/memory-manager.js.map +1 -0
  165. package/dist/src/session/session-manager.d.ts +15 -0
  166. package/dist/src/session/session-manager.d.ts.map +1 -0
  167. package/dist/src/session/session-manager.js +139 -0
  168. package/dist/src/session/session-manager.js.map +1 -0
  169. package/dist/src/session/session.d.ts +31 -0
  170. package/dist/src/session/session.d.ts.map +1 -0
  171. package/dist/src/session/session.js +49 -0
  172. package/dist/src/session/session.js.map +1 -0
  173. package/dist/src/types/ai-response.d.ts +40 -0
  174. package/dist/src/types/ai-response.d.ts.map +1 -0
  175. package/dist/src/types/ai-response.js +2 -0
  176. package/dist/src/types/ai-response.js.map +1 -0
  177. package/dist/src/types/config.d.ts +51 -0
  178. package/dist/src/types/config.d.ts.map +1 -0
  179. package/dist/src/types/config.js +2 -0
  180. package/dist/src/types/config.js.map +1 -0
  181. package/dist/src/types/context.d.ts +18 -0
  182. package/dist/src/types/context.d.ts.map +1 -0
  183. package/dist/src/types/context.js +2 -0
  184. package/dist/src/types/context.js.map +1 -0
  185. package/dist/src/types/message.d.ts +13 -0
  186. package/dist/src/types/message.d.ts.map +1 -0
  187. package/dist/src/types/message.js +2 -0
  188. package/dist/src/types/message.js.map +1 -0
  189. package/dist/src/types/session.d.ts +30 -0
  190. package/dist/src/types/session.d.ts.map +1 -0
  191. package/dist/src/types/session.js +2 -0
  192. package/dist/src/types/session.js.map +1 -0
  193. package/dist/src/types/ticket.d.ts +18 -0
  194. package/dist/src/types/ticket.d.ts.map +1 -0
  195. package/dist/src/types/ticket.js +2 -0
  196. package/dist/src/types/ticket.js.map +1 -0
  197. package/dist/src/ui/logger.d.ts +3 -0
  198. package/dist/src/ui/logger.d.ts.map +1 -0
  199. package/dist/src/ui/logger.js +10 -0
  200. package/dist/src/ui/logger.js.map +1 -0
  201. package/dist/src/ui/output-formatter.d.ts +4 -0
  202. package/dist/src/ui/output-formatter.d.ts.map +1 -0
  203. package/dist/src/ui/output-formatter.js +52 -0
  204. package/dist/src/ui/output-formatter.js.map +1 -0
  205. package/dist/src/ui/prompt-line.d.ts +2 -0
  206. package/dist/src/ui/prompt-line.d.ts.map +1 -0
  207. package/dist/src/ui/prompt-line.js +4 -0
  208. package/dist/src/ui/prompt-line.js.map +1 -0
  209. package/dist/src/ui/spinner.d.ts +3 -0
  210. package/dist/src/ui/spinner.d.ts.map +1 -0
  211. package/dist/src/ui/spinner.js +5 -0
  212. package/dist/src/ui/spinner.js.map +1 -0
  213. package/dist/src/ui/welcome.d.ts +2 -0
  214. package/dist/src/ui/welcome.d.ts.map +1 -0
  215. package/dist/src/ui/welcome.js +14 -0
  216. package/dist/src/ui/welcome.js.map +1 -0
  217. package/dist/src/utils/crypto.d.ts +2 -0
  218. package/dist/src/utils/crypto.d.ts.map +1 -0
  219. package/dist/src/utils/crypto.js +3 -0
  220. package/dist/src/utils/crypto.js.map +1 -0
  221. package/dist/src/utils/http-client.d.ts +8 -0
  222. package/dist/src/utils/http-client.d.ts.map +1 -0
  223. package/dist/src/utils/http-client.js +36 -0
  224. package/dist/src/utils/http-client.js.map +1 -0
  225. package/dist/src/utils/retry.d.ts +7 -0
  226. package/dist/src/utils/retry.d.ts.map +1 -0
  227. package/dist/src/utils/retry.js +23 -0
  228. package/dist/src/utils/retry.js.map +1 -0
  229. package/dist/src/utils/validation.d.ts +9 -0
  230. package/dist/src/utils/validation.d.ts.map +1 -0
  231. package/dist/src/utils/validation.js +19 -0
  232. package/dist/src/utils/validation.js.map +1 -0
  233. package/package.json +65 -0
@@ -0,0 +1,133 @@
1
+ import Anthropic from '@anthropic-ai/sdk';
2
+ export class Judge {
3
+ config;
4
+ apiKey;
5
+ logger;
6
+ client = null;
7
+ constructor(config, apiKey, logger) {
8
+ this.config = config;
9
+ this.apiKey = apiKey;
10
+ this.logger = logger;
11
+ }
12
+ async evaluate(taskDescription, responses) {
13
+ const successful = responses.filter((r) => r.success && r.output);
14
+ // If only one succeeded, auto-select
15
+ if (successful.length === 1) {
16
+ const winner = successful[0];
17
+ return {
18
+ scores: [
19
+ {
20
+ providerName: winner.providerName,
21
+ readability: 0,
22
+ performance: 0,
23
+ standards: 0,
24
+ completeness: 0,
25
+ security: 0,
26
+ totalScore: 0,
27
+ reasoning: 'Only provider that responded successfully.',
28
+ },
29
+ ],
30
+ winner: winner.providerName,
31
+ winningOutput: winner.output,
32
+ summary: `${winner.providerName} was the only provider that responded.`,
33
+ };
34
+ }
35
+ if (successful.length === 0) {
36
+ return {
37
+ scores: [],
38
+ winner: 'none',
39
+ winningOutput: { code: '', explanation: 'All providers failed.' },
40
+ summary: 'All providers failed to generate a response.',
41
+ };
42
+ }
43
+ // Use Claude to judge
44
+ return this.judgeWithAI(taskDescription, successful);
45
+ }
46
+ async judgeWithAI(taskDescription, responses) {
47
+ if (!this.client) {
48
+ this.client = new Anthropic({ apiKey: this.apiKey });
49
+ }
50
+ const w = this.config.weights;
51
+ const systemPrompt = `You are an expert code reviewer. You will receive multiple code outputs from different AI systems for the same task. Score each output on 5 dimensions (0-10 scale):
52
+
53
+ 1. **Readability** (weight: ${w.readability}): Code clarity, naming, structure
54
+ 2. **Performance** (weight: ${w.performance}): Algorithm efficiency, resource usage
55
+ 3. **Standards** (weight: ${w.standards}): Adherence to project conventions and best practices
56
+ 4. **Completeness** (weight: ${w.completeness}): How fully the task is addressed, edge cases handled
57
+ 5. **Security** (weight: ${w.security}): Input validation, no introduced vulnerabilities
58
+
59
+ Respond ONLY with valid JSON matching this schema:
60
+ {
61
+ "scores": [
62
+ {
63
+ "providerName": "string",
64
+ "readability": number,
65
+ "performance": number,
66
+ "standards": number,
67
+ "completeness": number,
68
+ "security": number,
69
+ "reasoning": "string"
70
+ }
71
+ ],
72
+ "summary": "string"
73
+ }`;
74
+ const userMessage = this.buildJudgePrompt(taskDescription, responses);
75
+ const response = await this.client.messages.create({
76
+ model: this.config.model,
77
+ max_tokens: 4096,
78
+ system: systemPrompt,
79
+ messages: [{ role: 'user', content: userMessage }],
80
+ });
81
+ const text = response.content
82
+ .filter((block) => block.type === 'text')
83
+ .map((block) => block.text)
84
+ .join('');
85
+ try {
86
+ const parsed = JSON.parse(text);
87
+ const scores = parsed.scores.map((s) => ({
88
+ ...s,
89
+ totalScore: this.computeTotal(s),
90
+ }));
91
+ scores.sort((a, b) => b.totalScore - a.totalScore);
92
+ const winnerName = scores[0].providerName;
93
+ const winnerResponse = responses.find((r) => r.providerName === winnerName);
94
+ return {
95
+ scores,
96
+ winner: winnerName,
97
+ winningOutput: winnerResponse?.output ?? { code: '', explanation: '' },
98
+ summary: parsed.summary,
99
+ };
100
+ }
101
+ catch (error) {
102
+ this.logger.error({ err: error, raw: text }, 'Failed to parse judge response');
103
+ // Fallback: pick the first successful response
104
+ const fallback = responses[0];
105
+ return {
106
+ scores: [],
107
+ winner: fallback.providerName,
108
+ winningOutput: fallback.output,
109
+ summary: 'Judge failed to evaluate. Using first provider output.',
110
+ };
111
+ }
112
+ }
113
+ buildJudgePrompt(taskDescription, responses) {
114
+ const parts = [`## Task\n${taskDescription}\n`];
115
+ for (const r of responses) {
116
+ parts.push(`## Output from: ${r.providerName}`);
117
+ parts.push('```');
118
+ parts.push(r.output.code);
119
+ parts.push('```\n');
120
+ }
121
+ return parts.join('\n');
122
+ }
123
+ computeTotal(scores) {
124
+ const w = this.config.weights;
125
+ return Math.round((scores.readability * w.readability +
126
+ scores.performance * w.performance +
127
+ scores.standards * w.standards +
128
+ scores.completeness * w.completeness +
129
+ scores.security * w.security) *
130
+ 10);
131
+ }
132
+ }
133
+ //# sourceMappingURL=judge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"judge.js","sourceRoot":"","sources":["../../../src/core/judge.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAK1C,MAAM,OAAO,KAAK;IAIG;IACA;IACA;IALX,MAAM,GAAqB,IAAI,CAAC;IAExC,YACmB,MAAmB,EACnB,MAAc,EACd,MAAc;QAFd,WAAM,GAAN,MAAM,CAAa;QACnB,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,CAAQ;IAC9B,CAAC;IAEJ,KAAK,CAAC,QAAQ,CACZ,eAAuB,EACvB,SAA+B;QAE/B,MAAM,UAAU,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;QAElE,qCAAqC;QACrC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5B,MAAM,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;YAC7B,OAAO;gBACL,MAAM,EAAE;oBACN;wBACE,YAAY,EAAE,MAAM,CAAC,YAAY;wBACjC,WAAW,EAAE,CAAC;wBACd,WAA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,MAAM,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC;YAC7B,EAAE,CACL,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,19 @@
1
+ import type { Logger } from 'pino';
2
+ import type { AppConfig } from '../types/config.js';
3
+ import type { SessionInstance } from '../session/session.js';
4
+ import type { MessageMetadata } from '../types/message.js';
5
+ export interface OrchestratorResult {
6
+ content: string;
7
+ metadata?: MessageMetadata;
8
+ }
9
+ export declare class Orchestrator {
10
+ private readonly config;
11
+ private readonly logger;
12
+ private readonly contextBuilder;
13
+ private readonly fanOut;
14
+ private readonly judge;
15
+ private readonly registry;
16
+ constructor(config: AppConfig, logger: Logger);
17
+ process(session: SessionInstance, userMessage: string): Promise<OrchestratorResult>;
18
+ }
19
+ //# sourceMappingURL=orchestrator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../../src/core/orchestrator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAO3D,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC5B;AAED,qBAAa,YAAY;IAOrB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAPzB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAChD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAmB;gBAGzB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,MAAM;IAQ3B,OAAO,CAAC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA8D1F"}
@@ -0,0 +1,76 @@
1
+ import chalk from 'chalk';
2
+ import { ContextBuilder } from './context-builder.js';
3
+ import { FanOutExecutor } from './fan-out-executor.js';
4
+ import { Judge } from './judge.js';
5
+ import { ProviderRegistry } from '../providers/provider-registry.js';
6
+ import { renderScoreTable, renderWinnerCode } from '../ui/output-formatter.js';
7
+ export class Orchestrator {
8
+ config;
9
+ logger;
10
+ contextBuilder;
11
+ fanOut;
12
+ judge;
13
+ registry;
14
+ constructor(config, logger) {
15
+ this.config = config;
16
+ this.logger = logger;
17
+ this.contextBuilder = new ContextBuilder();
18
+ this.fanOut = new FanOutExecutor(logger);
19
+ this.judge = new Judge(config.judge, config.providers.claude.apiKey, logger);
20
+ this.registry = new ProviderRegistry(config.providers);
21
+ }
22
+ async process(session, userMessage) {
23
+ // Step 1: Build context from session state
24
+ const context = this.contextBuilder.build(session, userMessage);
25
+ // Step 2: Get available providers
26
+ const providers = await this.registry.getAvailable();
27
+ if (providers.length === 0) {
28
+ return {
29
+ content: 'No AI providers are configured or available. Check /config and ensure API keys are set.',
30
+ };
31
+ }
32
+ console.log(chalk.dim(` Sending to ${providers.length} AI provider${providers.length > 1 ? 's' : ''}...`));
33
+ // Step 3: Fan-out to all providers in parallel
34
+ const responses = await this.fanOut.execute(providers, context, session.history);
35
+ const successful = responses.filter((r) => r.success);
36
+ const failed = responses.filter((r) => !r.success);
37
+ // Report failures
38
+ for (const f of failed) {
39
+ console.log(chalk.yellow(` ${f.providerName}: failed — ${f.error}`));
40
+ }
41
+ if (successful.length === 0) {
42
+ return {
43
+ content: 'All AI providers failed to respond. Check /status for connectivity.',
44
+ };
45
+ }
46
+ // Step 4: Judge and score (if multiple succeeded)
47
+ let result;
48
+ if (successful.length === 1) {
49
+ const winner = successful[0];
50
+ console.log(chalk.dim(` Only ${winner.providerName} responded. Skipping judge.\n`));
51
+ result = {
52
+ scores: [],
53
+ winner: winner.providerName,
54
+ winningOutput: winner.output,
55
+ summary: `${winner.providerName} was the only responder.`,
56
+ };
57
+ }
58
+ else {
59
+ console.log(chalk.dim(' Evaluating outputs...\n'));
60
+ result = await this.judge.evaluate(userMessage, responses);
61
+ // Display score table
62
+ if (result.scores.length > 0) {
63
+ renderScoreTable(result.scores);
64
+ }
65
+ }
66
+ // Step 5: Display winning output
67
+ renderWinnerCode(result.winner, result.winningOutput);
68
+ return {
69
+ content: result.winningOutput.code,
70
+ metadata: {
71
+ providerScores: result,
72
+ },
73
+ };
74
+ }
75
+ }
76
+ //# sourceMappingURL=orchestrator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestrator.js","sourceRoot":"","sources":["../../../src/core/orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAO/E,MAAM,OAAO,YAAY;IAOJ;IACA;IAPF,cAAc,CAAiB;IAC/B,MAAM,CAAiB;IACvB,KAAK,CAAQ;IACb,QAAQ,CAAmB;IAE5C,YACmB,MAAiB,EACjB,MAAc;QADd,WAAM,GAAN,MAAM,CAAW;QACjB,WAAM,GAAN,MAAM,CAAQ;QAE/B,IAAI,CAAC,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC;QAC3C,IAAI,CAAC,MAAM,GAAG,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC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from './base-error.js';
2
+ export declare class AuthenticationError extends CliendError {
3
+ constructor(options: {
4
+ code: string;
5
+ message: string;
6
+ userMessage: string;
7
+ cause?: Error;
8
+ });
9
+ }
10
+ export declare class TokenExpiredError extends AuthenticationError {
11
+ constructor(cause?: Error);
12
+ }
13
+ export declare class OAuthFlowError extends AuthenticationError {
14
+ constructor(message: string, cause?: Error);
15
+ }
16
+ //# sourceMappingURL=auth-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-error.d.ts","sourceRoot":"","sources":["../../../src/errors/auth-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,qBAAa,mBAAoB,SAAQ,WAAW;gBACtC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,KAAK,CAAA;KAAE;CAI3F;AAED,qBAAa,iBAAkB,SAAQ,mBAAmB;gBAC5C,KAAK,CAAC,EAAE,KAAK;CAS1B;AAED,qBAAa,cAAe,SAAQ,mBAAmB;gBACzC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAS3C"}
@@ -0,0 +1,30 @@
1
+ import { CliendError } from './base-error.js';
2
+ export class AuthenticationError extends CliendError {
3
+ constructor(options) {
4
+ super({ ...options, recoverable: true });
5
+ this.name = 'AuthenticationError';
6
+ }
7
+ }
8
+ export class TokenExpiredError extends AuthenticationError {
9
+ constructor(cause) {
10
+ super({
11
+ code: 'AUTH_TOKEN_EXPIRED',
12
+ message: 'OAuth access token has expired',
13
+ userMessage: 'Your session has expired. Attempting to refresh...',
14
+ cause,
15
+ });
16
+ this.name = 'TokenExpiredError';
17
+ }
18
+ }
19
+ export class OAuthFlowError extends AuthenticationError {
20
+ constructor(message, cause) {
21
+ super({
22
+ code: 'AUTH_OAUTH_FAILED',
23
+ message,
24
+ userMessage: 'Authentication failed. Run /auth to re-authenticate.',
25
+ cause,
26
+ });
27
+ this.name = 'OAuthFlowError';
28
+ }
29
+ }
30
+ //# sourceMappingURL=auth-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-error.js","sourceRoot":"","sources":["../../../src/errors/auth-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,OAAO,mBAAoB,SAAQ,WAAW;IAClD,YAAY,OAA8E;QACxF,KAAK,CAAC,EAAE,GAAG,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;QACzC,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED,MAAM,OAAO,iBAAkB,SAAQ,mBAAmB;IACxD,YAAY,KAAa;QACvB,KAAK,CAAC;YACJ,IAAI,EAAE,oBAAoB;YAC1B,OAAO,EAAE,gCAAgC;YACzC,WAAW,EAAE,oDAAoD;YACjE,KAAK;SACN,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,mBAAmB;IACrD,YAAY,OAAe,EAAE,KAAa;QACxC,KAAK,CAAC;YACJ,IAAI,EAAE,mBAAmB;YACzB,OAAO;YACP,WAAW,EAAE,sDAAsD;YACnE,KAAK;SACN,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF"}
@@ -0,0 +1,13 @@
1
+ export declare class CliendError extends Error {
2
+ readonly code: string;
3
+ readonly userMessage: string;
4
+ readonly recoverable: boolean;
5
+ constructor(options: {
6
+ code: string;
7
+ message: string;
8
+ userMessage: string;
9
+ recoverable?: boolean;
10
+ cause?: Error;
11
+ });
12
+ }
13
+ //# sourceMappingURL=base-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-error.d.ts","sourceRoot":"","sources":["../../../src/errors/base-error.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAY,SAAQ,KAAK;IACpC,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,WAAW,EAAE,MAAM,CAAC;IACpC,SAAgB,WAAW,EAAE,OAAO,CAAC;gBAEzB,OAAO,EAAE;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,KAAK,CAAC,EAAE,KAAK,CAAC;KACf;CAOF"}
@@ -0,0 +1,13 @@
1
+ export class CliendError extends Error {
2
+ code;
3
+ userMessage;
4
+ recoverable;
5
+ constructor(options) {
6
+ super(options.message, { cause: options.cause });
7
+ this.name = 'CliendError';
8
+ this.code = options.code;
9
+ this.userMessage = options.userMessage;
10
+ this.recoverable = options.recoverable ?? false;
11
+ }
12
+ }
13
+ //# sourceMappingURL=base-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-error.js","sourceRoot":"","sources":["../../../src/errors/base-error.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpB,IAAI,CAAS;IACb,WAAW,CAAS;IACpB,WAAW,CAAU;IAErC,YAAY,OAMX;QACC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;QACvC,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,KAAK,CAAC;IAClD,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ import type { Logger } from 'pino';
2
+ export declare class ErrorHandler {
3
+ private readonly logger;
4
+ constructor(logger: Logger);
5
+ handle(error: unknown): string;
6
+ }
7
+ //# sourceMappingURL=error-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../../src/errors/error-handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAE3C,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM;CAc/B"}
@@ -0,0 +1,20 @@
1
+ import { CliendError } from './base-error.js';
2
+ export class ErrorHandler {
3
+ logger;
4
+ constructor(logger) {
5
+ this.logger = logger;
6
+ }
7
+ handle(error) {
8
+ if (error instanceof CliendError) {
9
+ this.logger.error({ code: error.code, cause: error.cause }, error.message);
10
+ return error.userMessage;
11
+ }
12
+ if (error instanceof Error) {
13
+ this.logger.error({ err: error }, 'Unexpected error');
14
+ return `Something went wrong: ${error.message}`;
15
+ }
16
+ this.logger.error({ err: error }, 'Unknown error');
17
+ return 'An unexpected error occurred.';
18
+ }
19
+ }
20
+ //# sourceMappingURL=error-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../../src/errors/error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,MAAM,OAAO,YAAY;IACM;IAA7B,YAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAE/C,MAAM,CAAC,KAAc;QACnB,IAAI,KAAK,YAAY,WAAW,EAAE,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;YAC3E,OAAO,KAAK,CAAC,WAAW,CAAC;QAC3B,CAAC;QAED,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,kBAAkB,CAAC,CAAC;YACtD,OAAO,yBAAyB,KAAK,CAAC,OAAO,EAAE,CAAC;QAClD,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,eAAe,CAAC,CAAC;QACnD,OAAO,+BAA+B,CAAC;IACzC,CAAC;CACF"}
@@ -0,0 +1,20 @@
1
+ import { CliendError } from './base-error.js';
2
+ export declare class IntegrationError extends CliendError {
3
+ constructor(options: {
4
+ code: string;
5
+ message: string;
6
+ userMessage: string;
7
+ recoverable?: boolean;
8
+ cause?: Error;
9
+ });
10
+ }
11
+ export declare class JiraApiError extends IntegrationError {
12
+ constructor(code: string, message: string, userMessage: string, cause?: Error);
13
+ static issueNotFound(key: string): JiraApiError;
14
+ static forbidden(key: string): JiraApiError;
15
+ }
16
+ export declare class BitbucketApiError extends IntegrationError {
17
+ constructor(code: string, message: string, userMessage: string, cause?: Error);
18
+ static repoNotFound(workspace: string, slug: string): BitbucketApiError;
19
+ }
20
+ //# sourceMappingURL=integration-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"integration-error.d.ts","sourceRoot":"","sources":["../../../src/errors/integration-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,qBAAa,gBAAiB,SAAQ,WAAW;gBACnC,OAAO,EAAE;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,KAAK,CAAC,EAAE,KAAK,CAAC;KACf;CAIF;AAED,qBAAa,YAAa,SAAQ,gBAAgB;gBACpC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;IAK7E,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY;IAQ/C,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY;CAO5C;AAED,qBAAa,iBAAkB,SAAQ,gBAAgB;gBACzC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;IAK7E,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,iBAAiB;CAOxE"}
@@ -0,0 +1,29 @@
1
+ import { CliendError } from './base-error.js';
2
+ export class IntegrationError extends CliendError {
3
+ constructor(options) {
4
+ super(options);
5
+ this.name = 'IntegrationError';
6
+ }
7
+ }
8
+ export class JiraApiError extends IntegrationError {
9
+ constructor(code, message, userMessage, cause) {
10
+ super({ code, message, userMessage, recoverable: true, cause });
11
+ this.name = 'JiraApiError';
12
+ }
13
+ static issueNotFound(key) {
14
+ return new JiraApiError('JIRA_ISSUE_NOT_FOUND', `Jira issue ${key} not found`, `Ticket ${key} was not found. Check the ticket ID and try again.`);
15
+ }
16
+ static forbidden(key) {
17
+ return new JiraApiError('JIRA_FORBIDDEN', `No permission to access ${key}`, `No permission to access ${key}. Run /auth to re-authenticate.`);
18
+ }
19
+ }
20
+ export class BitbucketApiError extends IntegrationError {
21
+ constructor(code, message, userMessage, cause) {
22
+ super({ code, message, userMessage, recoverable: true, cause });
23
+ this.name = 'BitbucketApiError';
24
+ }
25
+ static repoNotFound(workspace, slug) {
26
+ return new BitbucketApiError('BITBUCKET_REPO_NOT_FOUND', `Repository ${workspace}/${slug} not found`, `Bitbucket repo ${workspace}/${slug} not found. Check /config.`);
27
+ }
28
+ }
29
+ //# sourceMappingURL=integration-error.js.map
@@ -0,0 +1 @@
1
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AY,EAC3C,kBAAkB,SAAS,IAAI,IAAI,4BAA4B,CAChE,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,23 @@
1
+ import { CliendError } from './base-error.js';
2
+ export declare class AIProviderError extends CliendError {
3
+ readonly providerName: string;
4
+ constructor(options: {
5
+ code: string;
6
+ providerName: string;
7
+ message: string;
8
+ userMessage: string;
9
+ recoverable?: boolean;
10
+ cause?: Error;
11
+ });
12
+ }
13
+ export declare class ProviderTimeoutError extends AIProviderError {
14
+ constructor(providerName: string, timeoutMs: number);
15
+ }
16
+ export declare class ProviderRateLimitError extends AIProviderError {
17
+ constructor(providerName: string, cause?: Error);
18
+ }
19
+ export declare class AllProvidersFailedError extends CliendError {
20
+ readonly errors: AIProviderError[];
21
+ constructor(errors: AIProviderError[]);
22
+ }
23
+ //# sourceMappingURL=provider-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-error.d.ts","sourceRoot":"","sources":["../../../src/errors/provider-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,qBAAa,eAAgB,SAAQ,WAAW;IAC9C,SAAgB,YAAY,EAAE,MAAM,CAAC;gBAEzB,OAAO,EAAE;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,YAAY,EAAE,MAAM,CAAC;QACrB,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,KAAK,CAAC,EAAE,KAAK,CAAC;KACf;CAKF;AAED,qBAAa,oBAAqB,SAAQ,eAAe;gBAC3C,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAUpD;AAED,qBAAa,sBAAuB,SAAQ,eAAe;gBAC7C,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAWhD;AAED,qBAAa,uBAAwB,SAAQ,WAAW;IACtD,SAAgB,MAAM,EAAE,eAAe,EAAE,CAAC;gBAE9B,MAAM,EAAE,eAAe,EAAE;CAWtC"}
@@ -0,0 +1,49 @@
1
+ import { CliendError } from './base-error.js';
2
+ export class AIProviderError extends CliendError {
3
+ providerName;
4
+ constructor(options) {
5
+ super(options);
6
+ this.name = 'AIProviderError';
7
+ this.providerName = options.providerName;
8
+ }
9
+ }
10
+ export class ProviderTimeoutError extends AIProviderError {
11
+ constructor(providerName, timeoutMs) {
12
+ super({
13
+ code: 'PROVIDER_TIMEOUT',
14
+ providerName,
15
+ message: `${providerName} timed out after ${timeoutMs}ms`,
16
+ userMessage: `${providerName} took too long to respond. Skipping.`,
17
+ recoverable: true,
18
+ });
19
+ this.name = 'ProviderTimeoutError';
20
+ }
21
+ }
22
+ export class ProviderRateLimitError extends AIProviderError {
23
+ constructor(providerName, cause) {
24
+ super({
25
+ code: 'PROVIDER_RATE_LIMITED',
26
+ providerName,
27
+ message: `${providerName} rate limited`,
28
+ userMessage: `${providerName} rate limit hit. Will retry.`,
29
+ recoverable: true,
30
+ cause,
31
+ });
32
+ this.name = 'ProviderRateLimitError';
33
+ }
34
+ }
35
+ export class AllProvidersFailedError extends CliendError {
36
+ errors;
37
+ constructor(errors) {
38
+ const names = errors.map((e) => e.providerName).join(', ');
39
+ super({
40
+ code: 'PROVIDER_ALL_FAILED',
41
+ message: `All AI providers failed: ${names}`,
42
+ userMessage: 'All AI providers failed to respond. Please try again.',
43
+ recoverable: false,
44
+ });
45
+ this.name = 'AllProvidersFailedError';
46
+ this.errors = errors;
47
+ }
48
+ }
49
+ //# sourceMappingURL=provider-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-error.js","sourceRoot":"","sources":["../../../src/errors/provider-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,OAAO,eAAgB,SAAQ,WAAW;IAC9B,YAAY,CAAS;IAErC,YAAY,OAOX;QACC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf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,0 +1,2 @@
1
+ export declare function main(argv: string[]): Promise<void>;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAMA,wBAAsB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBxD"}
@@ -0,0 +1,20 @@
1
+ import { Repl } from './repl/repl.js';
2
+ import { ConfigManager } from './config/config-manager.js';
3
+ import { SessionManager } from './session/session-manager.js';
4
+ import { AuthManager } from './auth/auth-manager.js';
5
+ import { createLogger } from './ui/logger.js';
6
+ export async function main(argv) {
7
+ const logger = createLogger();
8
+ const configManager = new ConfigManager();
9
+ const config = await configManager.load();
10
+ const authManager = new AuthManager(config, logger);
11
+ const sessionManager = new SessionManager(process.cwd(), logger);
12
+ const repl = new Repl({
13
+ config,
14
+ authManager,
15
+ sessionManager,
16
+ logger,
17
+ });
18
+ await repl.start();
19
+ }
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,IAAc;IACvC,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;IAC9B,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC;IAC1C,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,IAAI,EAAE,CAAC;IAE1C,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpD,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,CAAC;IAEjE,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC;QACpB,MAAM;QACN,WAAW;QACX,cAAc;QACd,MAAM;KACP,CAAC,CAAC;IAEH,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;AACrB,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { Logger } from 'pino';
2
+ import type { AppConfig } from '../../types/config.js';
3
+ import type { JiraTicket } from '../../types/ticket.js';
4
+ export declare class JiraClient {
5
+ private readonly config;
6
+ private readonly logger;
7
+ private readonly authManager;
8
+ constructor(config: AppConfig, logger: Logger);
9
+ getIssue(issueKey: string): Promise<JiraTicket>;
10
+ private getCloudId;
11
+ private request;
12
+ private mapIssue;
13
+ private extractText;
14
+ private extractCustomField;
15
+ }
16
+ //# sourceMappingURL=jira-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jira-client.d.ts","sourceRoot":"","sources":["../../../../src/integrations/atlassian/jira-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAMxD,qBAAa,UAAU;IAInB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAJzB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAc;gBAGvB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,MAAM;IAK3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;YAwBvC,UAAU;YAgCV,OAAO;IAUrB,OAAO,CAAC,QAAQ;IAgBhB,OAAO,CAAC,WAAW;IAWnB,OAAO,CAAC,kBAAkB;CAc3B"}