cray-code 1.0.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 (252) hide show
  1. package/README.md +316 -0
  2. package/dist/Tool.d.ts +217 -0
  3. package/dist/Tool.d.ts.map +1 -0
  4. package/dist/Tool.js +89 -0
  5. package/dist/Tool.js.map +1 -0
  6. package/dist/branding/logo.d.ts +8 -0
  7. package/dist/branding/logo.d.ts.map +1 -0
  8. package/dist/branding/logo.js +26 -0
  9. package/dist/branding/logo.js.map +1 -0
  10. package/dist/branding/theme.d.ts +27 -0
  11. package/dist/branding/theme.d.ts.map +1 -0
  12. package/dist/branding/theme.js +28 -0
  13. package/dist/branding/theme.js.map +1 -0
  14. package/dist/commands/registry.d.ts +32 -0
  15. package/dist/commands/registry.d.ts.map +1 -0
  16. package/dist/commands/registry.js +759 -0
  17. package/dist/commands/registry.js.map +1 -0
  18. package/dist/components/MessageView.d.ts +12 -0
  19. package/dist/components/MessageView.d.ts.map +1 -0
  20. package/dist/components/MessageView.js +35 -0
  21. package/dist/components/MessageView.js.map +1 -0
  22. package/dist/components/PermissionPrompt.d.ts +11 -0
  23. package/dist/components/PermissionPrompt.d.ts.map +1 -0
  24. package/dist/components/PermissionPrompt.js +6 -0
  25. package/dist/components/PermissionPrompt.js.map +1 -0
  26. package/dist/components/PluginManager.d.ts +27 -0
  27. package/dist/components/PluginManager.d.ts.map +1 -0
  28. package/dist/components/PluginManager.js +391 -0
  29. package/dist/components/PluginManager.js.map +1 -0
  30. package/dist/components/ThinkingBlock.d.ts +27 -0
  31. package/dist/components/ThinkingBlock.d.ts.map +1 -0
  32. package/dist/components/ThinkingBlock.js +29 -0
  33. package/dist/components/ThinkingBlock.js.map +1 -0
  34. package/dist/components/ToolCallBlock.d.ts +14 -0
  35. package/dist/components/ToolCallBlock.d.ts.map +1 -0
  36. package/dist/components/ToolCallBlock.js +83 -0
  37. package/dist/components/ToolCallBlock.js.map +1 -0
  38. package/dist/components/TrustDialog.d.ts +20 -0
  39. package/dist/components/TrustDialog.d.ts.map +1 -0
  40. package/dist/components/TrustDialog.js +80 -0
  41. package/dist/components/TrustDialog.js.map +1 -0
  42. package/dist/context.d.ts +25 -0
  43. package/dist/context.d.ts.map +1 -0
  44. package/dist/context.js +268 -0
  45. package/dist/context.js.map +1 -0
  46. package/dist/cray.d.ts +114 -0
  47. package/dist/cray.d.ts.map +1 -0
  48. package/dist/cray.js +338 -0
  49. package/dist/cray.js.map +1 -0
  50. package/dist/index.d.ts +16 -0
  51. package/dist/index.d.ts.map +1 -0
  52. package/dist/index.js +122 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/plugins/registry.d.ts +106 -0
  55. package/dist/plugins/registry.d.ts.map +1 -0
  56. package/dist/plugins/registry.js +695 -0
  57. package/dist/plugins/registry.js.map +1 -0
  58. package/dist/query.d.ts +31 -0
  59. package/dist/query.d.ts.map +1 -0
  60. package/dist/query.js +637 -0
  61. package/dist/query.js.map +1 -0
  62. package/dist/queryStream.d.ts +36 -0
  63. package/dist/queryStream.d.ts.map +1 -0
  64. package/dist/queryStream.js +704 -0
  65. package/dist/queryStream.js.map +1 -0
  66. package/dist/screens/ReplScreen.d.ts +22 -0
  67. package/dist/screens/ReplScreen.d.ts.map +1 -0
  68. package/dist/screens/ReplScreen.js +763 -0
  69. package/dist/screens/ReplScreen.js.map +1 -0
  70. package/dist/services/agentRunner.d.ts +39 -0
  71. package/dist/services/agentRunner.d.ts.map +1 -0
  72. package/dist/services/agentRunner.js +115 -0
  73. package/dist/services/agentRunner.js.map +1 -0
  74. package/dist/services/compact.d.ts +34 -0
  75. package/dist/services/compact.d.ts.map +1 -0
  76. package/dist/services/compact.js +179 -0
  77. package/dist/services/compact.js.map +1 -0
  78. package/dist/services/loadPluginCommands.d.ts +55 -0
  79. package/dist/services/loadPluginCommands.d.ts.map +1 -0
  80. package/dist/services/loadPluginCommands.js +219 -0
  81. package/dist/services/loadPluginCommands.js.map +1 -0
  82. package/dist/services/mcp/index.d.ts +3 -0
  83. package/dist/services/mcp/index.d.ts.map +1 -0
  84. package/dist/services/mcp/index.js +3 -0
  85. package/dist/services/mcp/index.js.map +1 -0
  86. package/dist/services/mcp/manager.d.ts +24 -0
  87. package/dist/services/mcp/manager.d.ts.map +1 -0
  88. package/dist/services/mcp/manager.js +138 -0
  89. package/dist/services/mcp/manager.js.map +1 -0
  90. package/dist/services/mcp/types.d.ts +52 -0
  91. package/dist/services/mcp/types.d.ts.map +1 -0
  92. package/dist/services/mcp/types.js +5 -0
  93. package/dist/services/mcp/types.js.map +1 -0
  94. package/dist/services/memory.d.ts +38 -0
  95. package/dist/services/memory.d.ts.map +1 -0
  96. package/dist/services/memory.js +181 -0
  97. package/dist/services/memory.js.map +1 -0
  98. package/dist/services/permissionPrompt.d.ts +38 -0
  99. package/dist/services/permissionPrompt.d.ts.map +1 -0
  100. package/dist/services/permissionPrompt.js +83 -0
  101. package/dist/services/permissionPrompt.js.map +1 -0
  102. package/dist/services/permissions.d.ts +15 -0
  103. package/dist/services/permissions.d.ts.map +1 -0
  104. package/dist/services/permissions.js +237 -0
  105. package/dist/services/permissions.js.map +1 -0
  106. package/dist/services/sessionStorage.d.ts +51 -0
  107. package/dist/services/sessionStorage.d.ts.map +1 -0
  108. package/dist/services/sessionStorage.js +266 -0
  109. package/dist/services/sessionStorage.js.map +1 -0
  110. package/dist/setup.d.ts +22 -0
  111. package/dist/setup.d.ts.map +1 -0
  112. package/dist/setup.js +160 -0
  113. package/dist/setup.js.map +1 -0
  114. package/dist/skills/bundledSkills.d.ts +18 -0
  115. package/dist/skills/bundledSkills.d.ts.map +1 -0
  116. package/dist/skills/bundledSkills.js +277 -0
  117. package/dist/skills/bundledSkills.js.map +1 -0
  118. package/dist/skills/index.d.ts +4 -0
  119. package/dist/skills/index.d.ts.map +1 -0
  120. package/dist/skills/index.js +3 -0
  121. package/dist/skills/index.js.map +1 -0
  122. package/dist/skills/loadSkillsDir.d.ts +45 -0
  123. package/dist/skills/loadSkillsDir.d.ts.map +1 -0
  124. package/dist/skills/loadSkillsDir.js +233 -0
  125. package/dist/skills/loadSkillsDir.js.map +1 -0
  126. package/dist/state/AppState.d.ts +70 -0
  127. package/dist/state/AppState.d.ts.map +1 -0
  128. package/dist/state/AppState.js +106 -0
  129. package/dist/state/AppState.js.map +1 -0
  130. package/dist/tools/AgentTool.d.ts +62 -0
  131. package/dist/tools/AgentTool.d.ts.map +1 -0
  132. package/dist/tools/AgentTool.js +133 -0
  133. package/dist/tools/AgentTool.js.map +1 -0
  134. package/dist/tools/AskUserQuestionTool.d.ts +60 -0
  135. package/dist/tools/AskUserQuestionTool.d.ts.map +1 -0
  136. package/dist/tools/AskUserQuestionTool.js +52 -0
  137. package/dist/tools/AskUserQuestionTool.js.map +1 -0
  138. package/dist/tools/BashTool.d.ts +33 -0
  139. package/dist/tools/BashTool.d.ts.map +1 -0
  140. package/dist/tools/BashTool.js +211 -0
  141. package/dist/tools/BashTool.js.map +1 -0
  142. package/dist/tools/EditTool.d.ts +24 -0
  143. package/dist/tools/EditTool.d.ts.map +1 -0
  144. package/dist/tools/EditTool.js +102 -0
  145. package/dist/tools/EditTool.js.map +1 -0
  146. package/dist/tools/GlobTool.d.ts +17 -0
  147. package/dist/tools/GlobTool.d.ts.map +1 -0
  148. package/dist/tools/GlobTool.js +65 -0
  149. package/dist/tools/GlobTool.js.map +1 -0
  150. package/dist/tools/GrepTool.d.ts +30 -0
  151. package/dist/tools/GrepTool.d.ts.map +1 -0
  152. package/dist/tools/GrepTool.js +140 -0
  153. package/dist/tools/GrepTool.js.map +1 -0
  154. package/dist/tools/MCPTool.d.ts +24 -0
  155. package/dist/tools/MCPTool.d.ts.map +1 -0
  156. package/dist/tools/MCPTool.js +67 -0
  157. package/dist/tools/MCPTool.js.map +1 -0
  158. package/dist/tools/NotebookEditTool.d.ts +28 -0
  159. package/dist/tools/NotebookEditTool.d.ts.map +1 -0
  160. package/dist/tools/NotebookEditTool.js +213 -0
  161. package/dist/tools/NotebookEditTool.js.map +1 -0
  162. package/dist/tools/NotebookReadTool.d.ts +19 -0
  163. package/dist/tools/NotebookReadTool.d.ts.map +1 -0
  164. package/dist/tools/NotebookReadTool.js +191 -0
  165. package/dist/tools/NotebookReadTool.js.map +1 -0
  166. package/dist/tools/PlanTools.d.ts +17 -0
  167. package/dist/tools/PlanTools.d.ts.map +1 -0
  168. package/dist/tools/PlanTools.js +65 -0
  169. package/dist/tools/PlanTools.js.map +1 -0
  170. package/dist/tools/ReadTool.d.ts +21 -0
  171. package/dist/tools/ReadTool.d.ts.map +1 -0
  172. package/dist/tools/ReadTool.js +202 -0
  173. package/dist/tools/ReadTool.js.map +1 -0
  174. package/dist/tools/SkillTool.d.ts +32 -0
  175. package/dist/tools/SkillTool.d.ts.map +1 -0
  176. package/dist/tools/SkillTool.js +217 -0
  177. package/dist/tools/SkillTool.js.map +1 -0
  178. package/dist/tools/TodoWriteTool.d.ts +35 -0
  179. package/dist/tools/TodoWriteTool.d.ts.map +1 -0
  180. package/dist/tools/TodoWriteTool.js +58 -0
  181. package/dist/tools/TodoWriteTool.js.map +1 -0
  182. package/dist/tools/WebFetchTool.d.ts +17 -0
  183. package/dist/tools/WebFetchTool.d.ts.map +1 -0
  184. package/dist/tools/WebFetchTool.js +97 -0
  185. package/dist/tools/WebFetchTool.js.map +1 -0
  186. package/dist/tools/WebSearchTool.d.ts +18 -0
  187. package/dist/tools/WebSearchTool.d.ts.map +1 -0
  188. package/dist/tools/WebSearchTool.js +76 -0
  189. package/dist/tools/WebSearchTool.js.map +1 -0
  190. package/dist/tools/WriteTool.d.ts +17 -0
  191. package/dist/tools/WriteTool.d.ts.map +1 -0
  192. package/dist/tools/WriteTool.js +84 -0
  193. package/dist/tools/WriteTool.js.map +1 -0
  194. package/dist/tools/index.d.ts +21 -0
  195. package/dist/tools/index.d.ts.map +1 -0
  196. package/dist/tools/index.js +20 -0
  197. package/dist/tools/index.js.map +1 -0
  198. package/dist/tools.d.ts +34 -0
  199. package/dist/tools.d.ts.map +1 -0
  200. package/dist/tools.js +102 -0
  201. package/dist/tools.js.map +1 -0
  202. package/dist/types/events.d.ts +85 -0
  203. package/dist/types/events.d.ts.map +1 -0
  204. package/dist/types/events.js +12 -0
  205. package/dist/types/events.js.map +1 -0
  206. package/dist/types/index.d.ts +4 -0
  207. package/dist/types/index.d.ts.map +1 -0
  208. package/dist/types/index.js +4 -0
  209. package/dist/types/index.js.map +1 -0
  210. package/dist/types/message.d.ts +71 -0
  211. package/dist/types/message.d.ts.map +1 -0
  212. package/dist/types/message.js +5 -0
  213. package/dist/types/message.js.map +1 -0
  214. package/dist/types/permission.d.ts +56 -0
  215. package/dist/types/permission.d.ts.map +1 -0
  216. package/dist/types/permission.js +46 -0
  217. package/dist/types/permission.js.map +1 -0
  218. package/dist/types/processUserInput.d.ts +18 -0
  219. package/dist/types/processUserInput.d.ts.map +1 -0
  220. package/dist/types/processUserInput.js +8 -0
  221. package/dist/types/processUserInput.js.map +1 -0
  222. package/dist/types/tool.d.ts +32 -0
  223. package/dist/types/tool.d.ts.map +1 -0
  224. package/dist/types/tool.js +5 -0
  225. package/dist/types/tool.js.map +1 -0
  226. package/dist/utils/compactBoundary.d.ts +11 -0
  227. package/dist/utils/compactBoundary.d.ts.map +1 -0
  228. package/dist/utils/compactBoundary.js +26 -0
  229. package/dist/utils/compactBoundary.js.map +1 -0
  230. package/dist/utils/configStore.d.ts +41 -0
  231. package/dist/utils/configStore.d.ts.map +1 -0
  232. package/dist/utils/configStore.js +111 -0
  233. package/dist/utils/configStore.js.map +1 -0
  234. package/dist/utils/forkedAgent.d.ts +40 -0
  235. package/dist/utils/forkedAgent.d.ts.map +1 -0
  236. package/dist/utils/forkedAgent.js +231 -0
  237. package/dist/utils/forkedAgent.js.map +1 -0
  238. package/dist/utils/messages.d.ts +14 -0
  239. package/dist/utils/messages.d.ts.map +1 -0
  240. package/dist/utils/messages.js +29 -0
  241. package/dist/utils/messages.js.map +1 -0
  242. package/dist/utils/sandbox.d.ts +22 -0
  243. package/dist/utils/sandbox.d.ts.map +1 -0
  244. package/dist/utils/sandbox.js +59 -0
  245. package/dist/utils/sandbox.js.map +1 -0
  246. package/dist/utils/sideQuestion.d.ts +29 -0
  247. package/dist/utils/sideQuestion.d.ts.map +1 -0
  248. package/dist/utils/sideQuestion.js +81 -0
  249. package/dist/utils/sideQuestion.js.map +1 -0
  250. package/install.ps1 +86 -0
  251. package/install.sh +92 -0
  252. package/package.json +68 -0
@@ -0,0 +1,85 @@
1
+ /**
2
+ * events.ts — Query event types for Cray Code.
3
+ *
4
+ * Mirrors Claude Code's pattern: query() yields typed events that the
5
+ * React/Ink REPL consumes via for-await and dispatches to state updates.
6
+ *
7
+ * Event flow:
8
+ * thinking_delta (repeat) → text_delta (repeat) → tool_use → tool_result
9
+ * → [repeat tool_use/tool_result per turn] → done
10
+ */
11
+ import type { Message, TokenUsage } from './message.js';
12
+ export interface ThinkingDeltaEvent {
13
+ type: 'thinking_delta';
14
+ text: string;
15
+ turn: number;
16
+ }
17
+ export interface ThinkingDoneEvent {
18
+ type: 'thinking_done';
19
+ fullText: string;
20
+ elapsed: number;
21
+ turn: number;
22
+ }
23
+ export interface TextDeltaEvent {
24
+ type: 'text_delta';
25
+ text: string;
26
+ turn: number;
27
+ }
28
+ export interface ToolStartEvent {
29
+ type: 'tool_start';
30
+ toolId: string;
31
+ toolName: string;
32
+ input: Record<string, unknown>;
33
+ turn: number;
34
+ }
35
+ export interface ToolProgressEvent {
36
+ type: 'tool_progress';
37
+ toolId: string;
38
+ toolName: string;
39
+ output: string;
40
+ turn: number;
41
+ }
42
+ export interface ToolEndEvent {
43
+ type: 'tool_end';
44
+ toolId: string;
45
+ toolName: string;
46
+ result: string;
47
+ isError: boolean;
48
+ newMessages?: Message[];
49
+ contextModifier?: (ctx: any) => any;
50
+ turn: number;
51
+ }
52
+ export interface TurnEndEvent {
53
+ type: 'turn_end';
54
+ turn: number;
55
+ usage: TokenUsage;
56
+ totalInputTokens: number;
57
+ totalOutputTokens: number;
58
+ }
59
+ export interface RequestStartEvent {
60
+ type: 'request_start';
61
+ turn: number;
62
+ model: string;
63
+ }
64
+ export interface ErrorEvent {
65
+ type: 'error';
66
+ message: string;
67
+ }
68
+ export interface CancelledEvent {
69
+ type: 'cancelled';
70
+ message?: string;
71
+ }
72
+ export interface DoneEvent {
73
+ type: 'done';
74
+ messages: Message[];
75
+ totalTurns: number;
76
+ }
77
+ export interface PermissionAskEvent {
78
+ type: 'permission_ask';
79
+ toolName: string;
80
+ message: string;
81
+ /** The UI must resolve this promise with the user's answer */
82
+ resolve: (answer: 'allow' | 'deny' | 'allowAll') => void;
83
+ }
84
+ export type QueryEvent = ThinkingDeltaEvent | ThinkingDoneEvent | TextDeltaEvent | ToolStartEvent | ToolProgressEvent | ToolEndEvent | TurnEndEvent | RequestStartEvent | ErrorEvent | CancelledEvent | DoneEvent | PermissionAskEvent;
85
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAkB,MAAM,cAAc,CAAC;AAIxE,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,gBAAgB,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,eAAe,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAID,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAID,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM,EAAE,MAA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CAAC;CACpB;AAID,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,gBAAgB,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,8DAA8D;IAC9D,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,UAAU,KAAK,IAAI,CAAC;CAC1D;AAID,MAAM,MAAM,UAAU,GAClB,kBAAkB,GAClB,iBAAiB,GACjB,cAAc,GACd,cAAc,GACd,iBAAiB,GACjB,YAAY,GACZ,YAAY,GACZ,iBAAiB,GACjB,UAAU,GACV,cAAc,GACd,SAAS,GACT,kBAAkB,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * events.ts — Query event types for Cray Code.
3
+ *
4
+ * Mirrors Claude Code's pattern: query() yields typed events that the
5
+ * React/Ink REPL consumes via for-await and dispatches to state updates.
6
+ *
7
+ * Event flow:
8
+ * thinking_delta (repeat) → text_delta (repeat) → tool_use → tool_result
9
+ * → [repeat tool_use/tool_result per turn] → done
10
+ */
11
+ export {};
12
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
@@ -0,0 +1,4 @@
1
+ export * from './message.js';
2
+ export * from './permission.js';
3
+ export * from './tool.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './message.js';
2
+ export * from './permission.js';
3
+ export * from './tool.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Core message types for the Cray Code agent system.
3
+ */
4
+ export type Role = 'user' | 'assistant' | 'system';
5
+ export interface BaseMessage {
6
+ role: Role;
7
+ id: string;
8
+ timestamp: number;
9
+ }
10
+ export interface TextContent {
11
+ type: 'text';
12
+ text: string;
13
+ }
14
+ export interface ToolUseContent {
15
+ type: 'tool_use';
16
+ id: string;
17
+ name: string;
18
+ input: Record<string, unknown>;
19
+ }
20
+ export interface ToolResultContent {
21
+ type: 'tool_result';
22
+ tool_use_id: string;
23
+ content: string | Array<TextContent | ImageContent>;
24
+ is_error?: boolean;
25
+ }
26
+ export interface ImageContent {
27
+ type: 'image';
28
+ source: {
29
+ type: 'base64';
30
+ media_type: string;
31
+ data: string;
32
+ };
33
+ }
34
+ export interface ThinkingContent {
35
+ type: 'thinking';
36
+ thinking: string;
37
+ signature: string;
38
+ }
39
+ export interface RedactedThinkingContent {
40
+ type: 'redacted_thinking';
41
+ data: string;
42
+ }
43
+ export type ContentBlock = TextContent | ToolUseContent | ToolResultContent | ImageContent | ThinkingContent | RedactedThinkingContent;
44
+ export interface UserMessage extends BaseMessage {
45
+ role: 'user';
46
+ content: string | ContentBlock[];
47
+ }
48
+ export interface AssistantMessage extends BaseMessage {
49
+ role: 'assistant';
50
+ content: ContentBlock[];
51
+ model: string;
52
+ stopReason: 'end_turn' | 'tool_use' | 'max_tokens' | 'stop_sequence';
53
+ usage: TokenUsage;
54
+ }
55
+ export interface SystemMessage extends BaseMessage {
56
+ role: 'system';
57
+ content: string | ContentBlock[];
58
+ }
59
+ export type Message = UserMessage | AssistantMessage | SystemMessage;
60
+ export interface TokenUsage {
61
+ inputTokens: number;
62
+ outputTokens: number;
63
+ cacheCreationInputTokens?: number;
64
+ cacheReadInputTokens?: number;
65
+ }
66
+ export interface ConversationState {
67
+ messages: Message[];
68
+ summary?: string;
69
+ tokenUsage: TokenUsage;
70
+ }
71
+ //# sourceMappingURL=message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/types/message.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;AAEnD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,IAAI,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,aAAa,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC,WAAW,GAAG,YAAY,CAAC,CAAC;IACpD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,YAAY,GACpB,WAAW,GACX,cAAc,GACd,iBAAiB,GACjB,YAAY,GACZ,eAAe,GACf,uBAAuB,CAAC;AAE5B,MAAM,WAAW,WAAY,SAAQ,WAAW;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,YAAY,EAAE,CAAC;CAClC;AAED,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,UAAU,GAAG,UAAU,GAAG,YAAY,GAAG,eAAe,CAAC;IACrE,KAAK,EAAE,UAAU,CAAC;CACnB;AAED,MAAM,WAAW,aAAc,SAAQ,WAAW;IAChD,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,YAAY,EAAE,CAAC;CAClC;AAED,MAAM,MAAM,OAAO,GAAG,WAAW,GAAG,gBAAgB,GAAG,aAAa,CAAC;AAErE,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC;CACxB"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Core message types for the Cray Code agent system.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message.js","sourceRoot":"","sources":["../../src/types/message.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Permission types for Cray Code — mirrors Claude Code's permission system.
3
+ *
4
+ * Key additions vs. the old types:
5
+ * - PermissionDecisionReason for transparency (why was this prompted?)
6
+ * - PermissionSuggestion for "don't ask again" offers
7
+ * - Content-specific ask rules that survive even bypass mode
8
+ * - Safety checks that are immune to bypass
9
+ */
10
+ export type PermissionMode = 'default' | 'acceptEdits' | 'bypass' | 'plan';
11
+ export type PermissionBehavior = 'allow' | 'deny' | 'ask' | 'passthrough';
12
+ export type PermissionDecisionReasonType = 'mode' | 'rule' | 'toolCheck' | 'safetyCheck' | 'requiresInteraction' | 'workingDir' | 'contentAsk' | 'other';
13
+ export interface PermissionDecisionReason {
14
+ type: PermissionDecisionReasonType;
15
+ message?: string;
16
+ ruleSource?: string;
17
+ }
18
+ export interface PermissionSuggestion {
19
+ label: string;
20
+ description: string;
21
+ behavior: 'allow' | 'allowAlways' | 'deny';
22
+ }
23
+ export interface PermissionResult {
24
+ behavior: PermissionBehavior;
25
+ message?: string;
26
+ decisionReason?: PermissionDecisionReason;
27
+ suggestions?: PermissionSuggestion[];
28
+ /** Input override — set when the tool implementation transforms the input */
29
+ updatedInput?: Record<string, unknown>;
30
+ /** If true, this permission request survives even bypass mode */
31
+ requireExplicitUserApproval?: boolean;
32
+ }
33
+ export type PermissionRuleSource = 'userSettings' | 'projectSettings' | 'session';
34
+ export interface PermissionRule {
35
+ toolName: string;
36
+ /** Optional pattern for content-specific matching (e.g., "rm " for bash) */
37
+ pattern?: string;
38
+ behavior: 'allow' | 'deny' | 'ask';
39
+ source?: PermissionRuleSource;
40
+ }
41
+ export interface ToolPermissionContext {
42
+ mode: PermissionMode;
43
+ alwaysAllowRules: PermissionRule[];
44
+ alwaysDenyRules: PermissionRule[];
45
+ /** Content-specific ask rules that survive even bypass mode */
46
+ alwaysAskRules: PermissionRule[];
47
+ workingDirectories: string[];
48
+ /** Previous mode before entering plan mode (so we can restore) */
49
+ prePlanMode?: PermissionMode;
50
+ }
51
+ export declare function getDefaultPermissionContext(): ToolPermissionContext;
52
+ export declare const PERMISSION_MODE_ORDER: PermissionMode[];
53
+ export declare function nextPermissionMode(current: PermissionMode): PermissionMode;
54
+ export declare function modeLabel(mode: PermissionMode): string;
55
+ export declare function modeSymbol(mode: PermissionMode): string;
56
+ //# sourceMappingURL=permission.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission.d.ts","sourceRoot":"","sources":["../../src/types/permission.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,MAAM,cAAc,GACtB,SAAS,GACT,aAAa,GACb,QAAQ,GACR,MAAM,CAAC;AAIX,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,aAAa,CAAC;AAE1E,MAAM,MAAM,4BAA4B,GACpC,MAAM,GACN,MAAM,GACN,WAAW,GACX,aAAa,GACb,qBAAqB,GACrB,YAAY,GACZ,YAAY,GACZ,OAAO,CAAC;AAEZ,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,GAAG,aAAa,GAAG,MAAM,CAAC;CAC5C;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,wBAAwB,CAAC;IAC1C,WAAW,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACrC,6EAA6E;IAC7E,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC,iEAAiE;IACjE,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC;AAID,MAAM,MAAM,oBAAoB,GAC5B,cAAc,GACd,iBAAiB,GACjB,SAAS,CAAC;AAEd,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;IACnC,MAAM,CAAC,EAAE,oBAAoB,CAAC;CAC/B;AAID,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,cAAc,CAAC;IACrB,gBAAgB,EAAE,cAAc,EAAE,CAAC;IACnC,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,+DAA+D;IAC/D,cAAc,EAAE,cAAc,EAAE,CAAC;IACjC,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,kEAAkE;IAClE,WAAW,CAAC,EAAE,cAAc,CAAC;CAC9B;AAED,wBAAgB,2BAA2B,IAAI,qBAAqB,CAQnE;AAID,eAAO,MAAM,qBAAqB,EAAE,cAAc,EAKjD,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,cAAc,GAAG,cAAc,CAG1E;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAOtD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAOvD"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Permission types for Cray Code — mirrors Claude Code's permission system.
3
+ *
4
+ * Key additions vs. the old types:
5
+ * - PermissionDecisionReason for transparency (why was this prompted?)
6
+ * - PermissionSuggestion for "don't ask again" offers
7
+ * - Content-specific ask rules that survive even bypass mode
8
+ * - Safety checks that are immune to bypass
9
+ */
10
+ export function getDefaultPermissionContext() {
11
+ return {
12
+ mode: 'default',
13
+ alwaysAllowRules: [],
14
+ alwaysDenyRules: [],
15
+ alwaysAskRules: [],
16
+ workingDirectories: [],
17
+ };
18
+ }
19
+ // ─── Mode Helpers ──────────────────────────────────────────────────
20
+ export const PERMISSION_MODE_ORDER = [
21
+ 'default',
22
+ 'acceptEdits',
23
+ 'bypass',
24
+ 'plan',
25
+ ];
26
+ export function nextPermissionMode(current) {
27
+ const idx = PERMISSION_MODE_ORDER.indexOf(current);
28
+ return PERMISSION_MODE_ORDER[(idx + 1) % PERMISSION_MODE_ORDER.length];
29
+ }
30
+ export function modeLabel(mode) {
31
+ switch (mode) {
32
+ case 'default': return 'Default (ask)';
33
+ case 'acceptEdits': return 'Accept Edits';
34
+ case 'bypass': return 'Bypass (auto)';
35
+ case 'plan': return 'Plan Mode';
36
+ }
37
+ }
38
+ export function modeSymbol(mode) {
39
+ switch (mode) {
40
+ case 'default': return '🔒';
41
+ case 'acceptEdits': return '✏️';
42
+ case 'bypass': return '🔓';
43
+ case 'plan': return '📋';
44
+ }
45
+ }
46
+ //# sourceMappingURL=permission.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission.js","sourceRoot":"","sources":["../../src/types/permission.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAyEH,MAAM,UAAU,2BAA2B;IACzC,OAAO;QACL,IAAI,EAAE,SAAS;QACf,gBAAgB,EAAE,EAAE;QACpB,eAAe,EAAE,EAAE;QACnB,cAAc,EAAE,EAAE;QAClB,kBAAkB,EAAE,EAAE;KACvB,CAAC;AACJ,CAAC;AAED,sEAAsE;AAEtE,MAAM,CAAC,MAAM,qBAAqB,GAAqB;IACrD,SAAS;IACT,aAAa;IACb,QAAQ;IACR,MAAM;CACP,CAAC;AAEF,MAAM,UAAU,kBAAkB,CAAC,OAAuB;IACxD,MAAM,GAAG,GAAG,qBAAqB,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACnD,OAAO,qBAAqB,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;AACzE,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAoB;IAC5C,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,SAAS,CAAC,CAAC,OAAO,eAAe,CAAC;QACvC,KAAK,aAAa,CAAC,CAAC,OAAO,cAAc,CAAC;QAC1C,KAAK,QAAQ,CAAC,CAAC,OAAO,eAAe,CAAC;QACtC,KAAK,MAAM,CAAC,CAAC,OAAO,WAAW,CAAC;IAClC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,IAAoB;IAC7C,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,SAAS,CAAC,CAAC,OAAO,IAAI,CAAC;QAC5B,KAAK,aAAa,CAAC,CAAC,OAAO,IAAI,CAAC;QAChC,KAAK,QAAQ,CAAC,CAAC,OAAO,IAAI,CAAC;QAC3B,KAAK,MAAM,CAAC,CAAC,OAAO,IAAI,CAAC;IAC3B,CAAC;AACH,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * processUserInput.ts — Type for user input processing context.
3
+ *
4
+ * Mirrors Claude Code's ProcessUserInputContext — the context
5
+ * available during /btw side question invocation.
6
+ */
7
+ import type { ToolUseContext } from '../Tool.js';
8
+ import type { Message } from './message.js';
9
+ export interface ProcessUserInputContext {
10
+ messages: Message[];
11
+ options: {
12
+ tools: any[];
13
+ mainLoopModel: string;
14
+ mcpClients: Map<string, any>;
15
+ };
16
+ toolUseContext: ToolUseContext;
17
+ }
18
+ //# sourceMappingURL=processUserInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processUserInput.d.ts","sourceRoot":"","sources":["../../src/types/processUserInput.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,OAAO,EAAE;QACP,KAAK,EAAE,GAAG,EAAE,CAAC;QACb,aAAa,EAAE,MAAM,CAAC;QACtB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC9B,CAAC;IACF,cAAc,EAAE,cAAc,CAAC;CAChC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * processUserInput.ts — Type for user input processing context.
3
+ *
4
+ * Mirrors Claude Code's ProcessUserInputContext — the context
5
+ * available during /btw side question invocation.
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=processUserInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processUserInput.js","sourceRoot":"","sources":["../../src/types/processUserInput.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Tool-related type definitions for Cray Code.
3
+ */
4
+ export interface ToolProgressData {
5
+ type: string;
6
+ [key: string]: unknown;
7
+ }
8
+ export interface BashProgress extends ToolProgressData {
9
+ type: 'bash';
10
+ command: string;
11
+ output: string;
12
+ isComplete: boolean;
13
+ }
14
+ export interface AgentProgress extends ToolProgressData {
15
+ type: 'agent';
16
+ agentId: string;
17
+ status: 'running' | 'completed' | 'failed';
18
+ message?: string;
19
+ }
20
+ export interface MCPProgress extends ToolProgressData {
21
+ type: 'mcp';
22
+ serverName: string;
23
+ toolName: string;
24
+ status: string;
25
+ }
26
+ export interface SkillProgress extends ToolProgressData {
27
+ type: 'skill';
28
+ skillName: string;
29
+ status: string;
30
+ }
31
+ export type AnyToolProgress = BashProgress | AgentProgress | MCPProgress | SkillProgress;
32
+ //# sourceMappingURL=tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../../src/types/tool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,YAAa,SAAQ,gBAAgB;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACrD,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAY,SAAQ,gBAAgB;IACnD,IAAI,EAAE,KAAK,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACrD,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,aAAa,GAAG,WAAW,GAAG,aAAa,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Tool-related type definitions for Cray Code.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.js","sourceRoot":"","sources":["../../src/types/tool.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * compactBoundary.ts — Track compact boundary in message history.
3
+ */
4
+ import type { Message } from '../types/message.js';
5
+ /**
6
+ * Return messages after the last compact boundary marker.
7
+ * For now, we return all messages since compact is not yet
8
+ * integrated into the forked agent messaging path.
9
+ */
10
+ export declare function getMessagesAfterCompactBoundary(messages: Message[]): Message[];
11
+ //# sourceMappingURL=compactBoundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compactBoundary.d.ts","sourceRoot":"","sources":["../../src/utils/compactBoundary.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,CAY9E"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * compactBoundary.ts — Track compact boundary in message history.
3
+ */
4
+ /**
5
+ * Return messages after the last compact boundary marker.
6
+ * For now, we return all messages since compact is not yet
7
+ * integrated into the forked agent messaging path.
8
+ */
9
+ export function getMessagesAfterCompactBoundary(messages) {
10
+ // Find the last compact marker
11
+ const lastCompactIndex = findLastIndex(messages, (m) => m.role === 'system' &&
12
+ typeof m.content === 'string' &&
13
+ m.content.includes('[COMPACT'));
14
+ if (lastCompactIndex >= 0) {
15
+ return messages.slice(lastCompactIndex + 1);
16
+ }
17
+ return messages;
18
+ }
19
+ function findLastIndex(arr, predicate) {
20
+ for (let i = arr.length - 1; i >= 0; i--) {
21
+ if (predicate(arr[i]))
22
+ return i;
23
+ }
24
+ return -1;
25
+ }
26
+ //# sourceMappingURL=compactBoundary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compactBoundary.js","sourceRoot":"","sources":["../../src/utils/compactBoundary.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;GAIG;AACH,MAAM,UAAU,+BAA+B,CAAC,QAAmB;IACjE,+BAA+B;IAC/B,MAAM,gBAAgB,GAAG,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CACrD,CAAC,CAAC,IAAI,KAAK,QAAQ;QACnB,OAAO,CAAC,CAAC,OAAO,KAAK,QAAQ;QAC7B,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAC/B,CAAC;IAEF,IAAI,gBAAgB,IAAI,CAAC,EAAE,CAAC;QAC1B,OAAO,QAAQ,CAAC,KAAK,CAAC,gBAAgB,GAAG,CAAC,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,aAAa,CAAI,GAAQ,EAAE,SAA+B;IACjE,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QACzC,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAAE,OAAO,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,CAAC,CAAC,CAAC;AACZ,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * ConfigStore — Persistent configuration for Cray Code.
3
+ *
4
+ * Reads/writes `.cray/settings.json` in the project directory.
5
+ * Stores provider, model, API key, and preferences across sessions.
6
+ */
7
+ export interface CrayConfig {
8
+ /** LLM provider: 'anthropic' | 'openai' | 'ollama' | 'custom' */
9
+ provider: string;
10
+ /** Model name (e.g., 'claude-sonnet-4-6', 'gpt-4o', 'llama3.1') */
11
+ model: string;
12
+ /** API key for the provider */
13
+ apiKey: string;
14
+ /** Custom API base URL (for Ollama, vLLM, etc.) */
15
+ baseUrl?: string;
16
+ /** Permission mode */
17
+ permissionMode: string;
18
+ /** Max agent loop turns */
19
+ maxTurns: number;
20
+ /** Verbose logging */
21
+ verbose: boolean;
22
+ /** Whether setup has been completed */
23
+ setupComplete: boolean;
24
+ }
25
+ export declare const DEFAULT_CONFIG: CrayConfig;
26
+ export declare const KNOWN_PROVIDERS: Record<string, {
27
+ label: string;
28
+ models: string[];
29
+ defaultBaseUrl: string;
30
+ needsApiKey: boolean;
31
+ needsBaseUrl: boolean;
32
+ }>;
33
+ /** Load config from disk, merging with defaults */
34
+ export declare function loadConfig(cwd?: string): CrayConfig;
35
+ /** Save config to disk */
36
+ export declare function saveConfig(config: CrayConfig): void;
37
+ /** Check if setup has been completed */
38
+ export declare function isSetupComplete(cwd?: string): boolean;
39
+ /** Mask API key for display */
40
+ export declare function maskApiKey(key: string): string;
41
+ //# sourceMappingURL=configStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configStore.d.ts","sourceRoot":"","sources":["../../src/utils/configStore.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,MAAM,WAAW,UAAU;IACzB,iEAAiE;IACjE,QAAQ,EAAE,MAAM,CAAC;IAEjB,mEAAmE;IACnE,KAAK,EAAE,MAAM,CAAC;IAEd,+BAA+B;IAC/B,MAAM,EAAE,MAAM,CAAC;IAEf,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,sBAAsB;IACtB,cAAc,EAAE,MAAM,CAAC;IAEvB,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAC;IAEjB,sBAAsB;IACtB,OAAO,EAAE,OAAO,CAAC;IAEjB,uCAAuC;IACvC,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,cAAc,EAAE,UAS5B,CAAC;AAIF,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;CACvB,CA2CA,CAAC;AAoBF,mDAAmD;AACnD,wBAAgB,UAAU,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,UAAU,CAcnD;AAED,0BAA0B;AAC1B,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAInD;AAED,wCAAwC;AACxC,wBAAgB,eAAe,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAGrD;AAED,+BAA+B;AAC/B,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG9C"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * ConfigStore — Persistent configuration for Cray Code.
3
+ *
4
+ * Reads/writes `.cray/settings.json` in the project directory.
5
+ * Stores provider, model, API key, and preferences across sessions.
6
+ */
7
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
8
+ import { join } from 'path';
9
+ import { homedir } from 'os';
10
+ export const DEFAULT_CONFIG = {
11
+ provider: '',
12
+ model: '',
13
+ apiKey: '',
14
+ baseUrl: '',
15
+ permissionMode: 'default',
16
+ maxTurns: 25,
17
+ verbose: false,
18
+ setupComplete: false,
19
+ };
20
+ // ─── Known Providers ──────────────────────────────────────────────────
21
+ export const KNOWN_PROVIDERS = {
22
+ anthropic: {
23
+ label: 'Anthropic (Claude)',
24
+ models: ['claude-sonnet-4-6', 'claude-opus-4-7', 'claude-haiku-4-5-20251001'],
25
+ defaultBaseUrl: '',
26
+ needsApiKey: true,
27
+ needsBaseUrl: false,
28
+ },
29
+ openai: {
30
+ label: 'OpenAI (GPT-4o)',
31
+ models: ['gpt-4o', 'gpt-4o-mini', 'gpt-4-turbo', 'o3-mini'],
32
+ defaultBaseUrl: '',
33
+ needsApiKey: true,
34
+ needsBaseUrl: false,
35
+ },
36
+ ollama: {
37
+ label: 'Ollama (本地)',
38
+ models: ['llama3.1', 'qwen2.5', 'deepseek-r1', 'mistral', 'gemma3'],
39
+ defaultBaseUrl: 'http://localhost:11434/v1',
40
+ needsApiKey: false,
41
+ needsBaseUrl: true,
42
+ },
43
+ openrouter: {
44
+ label: 'OpenRouter',
45
+ models: ['anthropic/claude-sonnet-4', 'openai/gpt-4o', 'google/gemini-2.5-pro', 'meta-llama/llama-4-maverick'],
46
+ defaultBaseUrl: 'https://openrouter.ai/api/v1',
47
+ needsApiKey: true,
48
+ needsBaseUrl: false,
49
+ },
50
+ deepseek: {
51
+ label: 'DeepSeek',
52
+ models: ['deepseek-chat', 'deepseek-reasoner'],
53
+ defaultBaseUrl: 'https://api.deepseek.com/v1',
54
+ needsApiKey: true,
55
+ needsBaseUrl: false,
56
+ },
57
+ custom: {
58
+ label: '自定义 (OpenAI 兼容 API)',
59
+ models: ['gpt-4o', 'claude-sonnet-4-6', 'custom-model'],
60
+ defaultBaseUrl: '',
61
+ needsApiKey: true,
62
+ needsBaseUrl: true,
63
+ },
64
+ };
65
+ // ─── Path Resolution ─────────────────────────────────────────────────
66
+ function getConfigPath(cwd) {
67
+ // Project-level config takes precedence over home directory
68
+ // Always use home directory for global Cray settings
69
+ const crayDir = join(homedir(), '.cray');
70
+ return join(crayDir, 'settings.json');
71
+ }
72
+ function ensureConfigDir() {
73
+ const crayDir = join(homedir(), '.cray');
74
+ if (!existsSync(crayDir)) {
75
+ mkdirSync(crayDir, { recursive: true });
76
+ }
77
+ }
78
+ // ─── Read/Write ───────────────────────────────────────────────────────
79
+ /** Load config from disk, merging with defaults */
80
+ export function loadConfig(cwd) {
81
+ const configPath = getConfigPath(cwd);
82
+ if (!existsSync(configPath)) {
83
+ return { ...DEFAULT_CONFIG };
84
+ }
85
+ try {
86
+ const raw = readFileSync(configPath, 'utf-8');
87
+ const parsed = JSON.parse(raw);
88
+ return { ...DEFAULT_CONFIG, ...parsed };
89
+ }
90
+ catch {
91
+ return { ...DEFAULT_CONFIG };
92
+ }
93
+ }
94
+ /** Save config to disk */
95
+ export function saveConfig(config) {
96
+ ensureConfigDir();
97
+ const configPath = getConfigPath();
98
+ writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf-8');
99
+ }
100
+ /** Check if setup has been completed */
101
+ export function isSetupComplete(cwd) {
102
+ const config = loadConfig(cwd);
103
+ return config.setupComplete && config.provider !== '' && config.apiKey !== '';
104
+ }
105
+ /** Mask API key for display */
106
+ export function maskApiKey(key) {
107
+ if (!key || key.length < 12)
108
+ return '****';
109
+ return key.slice(0, 6) + '...' + key.slice(-4);
110
+ }
111
+ //# sourceMappingURL=configStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configStore.js","sourceRoot":"","sources":["../../src/utils/configStore.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AA8B7B,MAAM,CAAC,MAAM,cAAc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