agor-live 0.3.7

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 (297) hide show
  1. package/LICENSE +94 -0
  2. package/README.md +163 -0
  3. package/bin/agor-daemon.js +20 -0
  4. package/bin/agor.js +14 -0
  5. package/dist/cli/base-command.d.ts +29 -0
  6. package/dist/cli/base-command.js +41 -0
  7. package/dist/cli/commands/board/add-session.d.ts +15 -0
  8. package/dist/cli/commands/board/add-session.js +102 -0
  9. package/dist/cli/commands/board/list.d.ts +14 -0
  10. package/dist/cli/commands/board/list.js +74 -0
  11. package/dist/cli/commands/config/clear.d.ts +13 -0
  12. package/dist/cli/commands/config/clear.js +21 -0
  13. package/dist/cli/commands/config/get.d.ts +13 -0
  14. package/dist/cli/commands/config/get.js +41 -0
  15. package/dist/cli/commands/config/index.d.ts +13 -0
  16. package/dist/cli/commands/config/index.js +118 -0
  17. package/dist/cli/commands/config/set.d.ts +14 -0
  18. package/dist/cli/commands/config/set.js +50 -0
  19. package/dist/cli/commands/config/unset.d.ts +13 -0
  20. package/dist/cli/commands/config/unset.js +35 -0
  21. package/dist/cli/commands/daemon/index.d.ts +13 -0
  22. package/dist/cli/commands/daemon/index.js +65 -0
  23. package/dist/cli/commands/daemon/logs.d.ts +13 -0
  24. package/dist/cli/commands/daemon/logs.js +78 -0
  25. package/dist/cli/commands/daemon/restart.d.ts +13 -0
  26. package/dist/cli/commands/daemon/restart.js +177 -0
  27. package/dist/cli/commands/daemon/start.d.ts +13 -0
  28. package/dist/cli/commands/daemon/start.js +193 -0
  29. package/dist/cli/commands/daemon/status.d.ts +13 -0
  30. package/dist/cli/commands/daemon/status.js +93 -0
  31. package/dist/cli/commands/daemon/stop.d.ts +13 -0
  32. package/dist/cli/commands/daemon/stop.js +108 -0
  33. package/dist/cli/commands/init.d.ts +44 -0
  34. package/dist/cli/commands/init.js +459 -0
  35. package/dist/cli/commands/mcp/add.d.ts +26 -0
  36. package/dist/cli/commands/mcp/add.js +162 -0
  37. package/dist/cli/commands/mcp/list.d.ts +16 -0
  38. package/dist/cli/commands/mcp/list.js +89 -0
  39. package/dist/cli/commands/mcp/remove.d.ts +17 -0
  40. package/dist/cli/commands/mcp/remove.js +86 -0
  41. package/dist/cli/commands/mcp/show.d.ts +14 -0
  42. package/dist/cli/commands/mcp/show.js +131 -0
  43. package/dist/cli/commands/repo/add.d.ts +16 -0
  44. package/dist/cli/commands/repo/add.js +105 -0
  45. package/dist/cli/commands/repo/list.d.ts +17 -0
  46. package/dist/cli/commands/repo/list.js +99 -0
  47. package/dist/cli/commands/repo/rm.d.ts +17 -0
  48. package/dist/cli/commands/repo/rm.js +126 -0
  49. package/dist/cli/commands/repo/worktree/add.d.ts +21 -0
  50. package/dist/cli/commands/repo/worktree/add.js +145 -0
  51. package/dist/cli/commands/repo/worktree/list.d.ts +21 -0
  52. package/dist/cli/commands/repo/worktree/list.js +136 -0
  53. package/dist/cli/commands/session/list.d.ts +30 -0
  54. package/dist/cli/commands/session/list.js +204 -0
  55. package/dist/cli/commands/session/load-claude.d.ts +16 -0
  56. package/dist/cli/commands/session/load-claude.js +211 -0
  57. package/dist/cli/commands/user/create-admin.d.ts +13 -0
  58. package/dist/cli/commands/user/create-admin.js +65 -0
  59. package/dist/cli/commands/user/create.d.ts +16 -0
  60. package/dist/cli/commands/user/create.js +126 -0
  61. package/dist/cli/commands/user/delete.d.ts +16 -0
  62. package/dist/cli/commands/user/delete.js +77 -0
  63. package/dist/cli/commands/user/list.d.ts +13 -0
  64. package/dist/cli/commands/user/list.js +78 -0
  65. package/dist/cli/commands/user/update.d.ts +19 -0
  66. package/dist/cli/commands/user/update.js +149 -0
  67. package/dist/cli/hooks/command-not-found.d.ts +9 -0
  68. package/dist/cli/hooks/command-not-found.js +14 -0
  69. package/dist/cli/lib/banner.d.ts +25 -0
  70. package/dist/cli/lib/banner.js +25 -0
  71. package/dist/cli/lib/context.d.ts +27 -0
  72. package/dist/cli/lib/context.js +32 -0
  73. package/dist/cli/lib/daemon-manager.d.ts +48 -0
  74. package/dist/cli/lib/daemon-manager.js +109 -0
  75. package/dist/cli/lib/help.d.ts +13 -0
  76. package/dist/cli/lib/help.js +46 -0
  77. package/dist/core/agentic-tool-B_gFNpk5.d.ts +33 -0
  78. package/dist/core/agentic-tool-DsyX8diw.d.cts +33 -0
  79. package/dist/core/api/index.cjs +98 -0
  80. package/dist/core/api/index.d.cts +174 -0
  81. package/dist/core/api/index.d.ts +174 -0
  82. package/dist/core/api/index.js +62 -0
  83. package/dist/core/board-comment-BUm0fpmD.d.cts +134 -0
  84. package/dist/core/board-comment-gC_-twPx.d.ts +134 -0
  85. package/dist/core/claude/index.cjs +673 -0
  86. package/dist/core/claude/index.d.cts +124 -0
  87. package/dist/core/claude/index.d.ts +124 -0
  88. package/dist/core/claude/index.js +629 -0
  89. package/dist/core/config/browser.cjs +165 -0
  90. package/dist/core/config/browser.d.cts +289 -0
  91. package/dist/core/config/browser.d.ts +289 -0
  92. package/dist/core/config/browser.js +131 -0
  93. package/dist/core/config/index.cjs +518 -0
  94. package/dist/core/config/index.d.cts +246 -0
  95. package/dist/core/config/index.d.ts +246 -0
  96. package/dist/core/config/index.js +451 -0
  97. package/dist/core/db/index.cjs +3726 -0
  98. package/dist/core/db/index.d.cts +631 -0
  99. package/dist/core/db/index.d.ts +631 -0
  100. package/dist/core/db/index.js +3649 -0
  101. package/dist/core/dist/agentic-tool-B_gFNpk5.d.ts +33 -0
  102. package/dist/core/dist/agentic-tool-DsyX8diw.d.cts +33 -0
  103. package/dist/core/dist/api/index.cjs +98 -0
  104. package/dist/core/dist/api/index.d.cts +174 -0
  105. package/dist/core/dist/api/index.d.ts +174 -0
  106. package/dist/core/dist/api/index.js +62 -0
  107. package/dist/core/dist/board-comment-BUm0fpmD.d.cts +134 -0
  108. package/dist/core/dist/board-comment-gC_-twPx.d.ts +134 -0
  109. package/dist/core/dist/claude/index.cjs +673 -0
  110. package/dist/core/dist/claude/index.d.cts +124 -0
  111. package/dist/core/dist/claude/index.d.ts +124 -0
  112. package/dist/core/dist/claude/index.js +629 -0
  113. package/dist/core/dist/config/browser.cjs +165 -0
  114. package/dist/core/dist/config/browser.d.cts +289 -0
  115. package/dist/core/dist/config/browser.d.ts +289 -0
  116. package/dist/core/dist/config/browser.js +131 -0
  117. package/dist/core/dist/config/index.cjs +518 -0
  118. package/dist/core/dist/config/index.d.cts +246 -0
  119. package/dist/core/dist/config/index.d.ts +246 -0
  120. package/dist/core/dist/config/index.js +451 -0
  121. package/dist/core/dist/db/index.cjs +3726 -0
  122. package/dist/core/dist/db/index.d.cts +631 -0
  123. package/dist/core/dist/db/index.d.ts +631 -0
  124. package/dist/core/dist/db/index.js +3649 -0
  125. package/dist/core/dist/environment/variable-resolver.cjs +92 -0
  126. package/dist/core/dist/environment/variable-resolver.d.cts +52 -0
  127. package/dist/core/dist/environment/variable-resolver.d.ts +52 -0
  128. package/dist/core/dist/environment/variable-resolver.js +53 -0
  129. package/dist/core/dist/feathers/index.cjs +66 -0
  130. package/dist/core/dist/feathers/index.d.cts +7 -0
  131. package/dist/core/dist/feathers/index.d.ts +7 -0
  132. package/dist/core/dist/feathers/index.js +25 -0
  133. package/dist/core/dist/feathers-BzHEPnpl.d.cts +228 -0
  134. package/dist/core/dist/feathers-BzHEPnpl.d.ts +228 -0
  135. package/dist/core/dist/git/index.cjs +302 -0
  136. package/dist/core/dist/git/index.d.cts +137 -0
  137. package/dist/core/dist/git/index.d.ts +137 -0
  138. package/dist/core/dist/git/index.js +260 -0
  139. package/dist/core/dist/id-DMqyogFB.d.cts +131 -0
  140. package/dist/core/dist/id-DMqyogFB.d.ts +131 -0
  141. package/dist/core/dist/index.cjs +4653 -0
  142. package/dist/core/dist/index.d.cts +23 -0
  143. package/dist/core/dist/index.d.ts +23 -0
  144. package/dist/core/dist/index.js +4509 -0
  145. package/dist/core/dist/message-BoxZISHg.d.cts +120 -0
  146. package/dist/core/dist/message-DvBzHu7V.d.ts +120 -0
  147. package/dist/core/dist/permissions/index.cjs +112 -0
  148. package/dist/core/dist/permissions/index.d.cts +81 -0
  149. package/dist/core/dist/permissions/index.d.ts +81 -0
  150. package/dist/core/dist/permissions/index.js +85 -0
  151. package/dist/core/dist/repo-3CUrCRbq.d.cts +405 -0
  152. package/dist/core/dist/repo-CnvJ0B6-.d.ts +405 -0
  153. package/dist/core/dist/session-BPjJlVdZ.d.cts +429 -0
  154. package/dist/core/dist/session-wAzjHatv.d.ts +429 -0
  155. package/dist/core/dist/task-BIEgT1DK.d.cts +163 -0
  156. package/dist/core/dist/task-DuIfiUbW.d.ts +163 -0
  157. package/dist/core/dist/templates/handlebars-helpers.cjs +156 -0
  158. package/dist/core/dist/templates/handlebars-helpers.d.cts +45 -0
  159. package/dist/core/dist/templates/handlebars-helpers.d.ts +45 -0
  160. package/dist/core/dist/templates/handlebars-helpers.js +119 -0
  161. package/dist/core/dist/tools/claude/models.cjs +70 -0
  162. package/dist/core/dist/tools/claude/models.d.cts +27 -0
  163. package/dist/core/dist/tools/claude/models.d.ts +27 -0
  164. package/dist/core/dist/tools/claude/models.js +44 -0
  165. package/dist/core/dist/tools/index.cjs +3367 -0
  166. package/dist/core/dist/tools/index.d.cts +967 -0
  167. package/dist/core/dist/tools/index.d.ts +967 -0
  168. package/dist/core/dist/tools/index.js +3314 -0
  169. package/dist/core/dist/tools/models.cjs +119 -0
  170. package/dist/core/dist/tools/models.d.cts +47 -0
  171. package/dist/core/dist/tools/models.d.ts +47 -0
  172. package/dist/core/dist/tools/models.js +86 -0
  173. package/dist/core/dist/types/index.cjs +152 -0
  174. package/dist/core/dist/types/index.d.cts +214 -0
  175. package/dist/core/dist/types/index.d.ts +214 -0
  176. package/dist/core/dist/types/index.js +112 -0
  177. package/dist/core/dist/user-BmL3kFol.d.ts +50 -0
  178. package/dist/core/dist/user-eUuKj7yM.d.cts +50 -0
  179. package/dist/core/dist/utils/pricing.cjs +102 -0
  180. package/dist/core/dist/utils/pricing.d.cts +43 -0
  181. package/dist/core/dist/utils/pricing.d.ts +43 -0
  182. package/dist/core/dist/utils/pricing.js +75 -0
  183. package/dist/core/dist/worktrees-BzIxB1U6.d.cts +2745 -0
  184. package/dist/core/dist/worktrees-CYem1ya2.d.ts +2745 -0
  185. package/dist/core/environment/variable-resolver.cjs +92 -0
  186. package/dist/core/environment/variable-resolver.d.cts +52 -0
  187. package/dist/core/environment/variable-resolver.d.ts +52 -0
  188. package/dist/core/environment/variable-resolver.js +53 -0
  189. package/dist/core/feathers/index.cjs +66 -0
  190. package/dist/core/feathers/index.d.cts +7 -0
  191. package/dist/core/feathers/index.d.ts +7 -0
  192. package/dist/core/feathers/index.js +25 -0
  193. package/dist/core/feathers-BzHEPnpl.d.cts +228 -0
  194. package/dist/core/feathers-BzHEPnpl.d.ts +228 -0
  195. package/dist/core/git/index.cjs +302 -0
  196. package/dist/core/git/index.d.cts +137 -0
  197. package/dist/core/git/index.d.ts +137 -0
  198. package/dist/core/git/index.js +260 -0
  199. package/dist/core/id-DMqyogFB.d.cts +131 -0
  200. package/dist/core/id-DMqyogFB.d.ts +131 -0
  201. package/dist/core/index.cjs +4653 -0
  202. package/dist/core/index.d.cts +23 -0
  203. package/dist/core/index.d.ts +23 -0
  204. package/dist/core/index.js +4509 -0
  205. package/dist/core/message-BoxZISHg.d.cts +120 -0
  206. package/dist/core/message-DvBzHu7V.d.ts +120 -0
  207. package/dist/core/package.json +133 -0
  208. package/dist/core/permissions/index.cjs +112 -0
  209. package/dist/core/permissions/index.d.cts +81 -0
  210. package/dist/core/permissions/index.d.ts +81 -0
  211. package/dist/core/permissions/index.js +85 -0
  212. package/dist/core/repo-3CUrCRbq.d.cts +405 -0
  213. package/dist/core/repo-CnvJ0B6-.d.ts +405 -0
  214. package/dist/core/session-BPjJlVdZ.d.cts +429 -0
  215. package/dist/core/session-wAzjHatv.d.ts +429 -0
  216. package/dist/core/task-BIEgT1DK.d.cts +163 -0
  217. package/dist/core/task-DuIfiUbW.d.ts +163 -0
  218. package/dist/core/templates/handlebars-helpers.cjs +156 -0
  219. package/dist/core/templates/handlebars-helpers.d.cts +45 -0
  220. package/dist/core/templates/handlebars-helpers.d.ts +45 -0
  221. package/dist/core/templates/handlebars-helpers.js +119 -0
  222. package/dist/core/tools/claude/models.cjs +70 -0
  223. package/dist/core/tools/claude/models.d.cts +27 -0
  224. package/dist/core/tools/claude/models.d.ts +27 -0
  225. package/dist/core/tools/claude/models.js +44 -0
  226. package/dist/core/tools/index.cjs +3367 -0
  227. package/dist/core/tools/index.d.cts +967 -0
  228. package/dist/core/tools/index.d.ts +967 -0
  229. package/dist/core/tools/index.js +3314 -0
  230. package/dist/core/tools/models.cjs +119 -0
  231. package/dist/core/tools/models.d.cts +47 -0
  232. package/dist/core/tools/models.d.ts +47 -0
  233. package/dist/core/tools/models.js +86 -0
  234. package/dist/core/types/index.cjs +152 -0
  235. package/dist/core/types/index.d.cts +214 -0
  236. package/dist/core/types/index.d.ts +214 -0
  237. package/dist/core/types/index.js +112 -0
  238. package/dist/core/user-BmL3kFol.d.ts +50 -0
  239. package/dist/core/user-eUuKj7yM.d.cts +50 -0
  240. package/dist/core/utils/pricing.cjs +102 -0
  241. package/dist/core/utils/pricing.d.cts +43 -0
  242. package/dist/core/utils/pricing.d.ts +43 -0
  243. package/dist/core/utils/pricing.js +75 -0
  244. package/dist/core/worktrees-BzIxB1U6.d.cts +2745 -0
  245. package/dist/core/worktrees-CYem1ya2.d.ts +2745 -0
  246. package/dist/daemon/adapters/drizzle.d.ts +114 -0
  247. package/dist/daemon/adapters/drizzle.js +219 -0
  248. package/dist/daemon/declarations.d.ts +101 -0
  249. package/dist/daemon/declarations.js +0 -0
  250. package/dist/daemon/index.d.ts +2 -0
  251. package/dist/daemon/index.js +4093 -0
  252. package/dist/daemon/mcp/routes.d.ts +15 -0
  253. package/dist/daemon/mcp/routes.js +641 -0
  254. package/dist/daemon/mcp/tokens.d.ts +50 -0
  255. package/dist/daemon/mcp/tokens.js +85 -0
  256. package/dist/daemon/services/board-comments.d.ts +97 -0
  257. package/dist/daemon/services/board-comments.js +326 -0
  258. package/dist/daemon/services/board-objects.d.ts +71 -0
  259. package/dist/daemon/services/board-objects.js +117 -0
  260. package/dist/daemon/services/boards.d.ts +64 -0
  261. package/dist/daemon/services/boards.js +286 -0
  262. package/dist/daemon/services/config.d.ts +35 -0
  263. package/dist/daemon/services/config.js +68 -0
  264. package/dist/daemon/services/context.d.ts +55 -0
  265. package/dist/daemon/services/context.js +113 -0
  266. package/dist/daemon/services/health-monitor.d.ts +58 -0
  267. package/dist/daemon/services/health-monitor.js +158 -0
  268. package/dist/daemon/services/mcp-servers.d.ts +42 -0
  269. package/dist/daemon/services/mcp-servers.js +275 -0
  270. package/dist/daemon/services/messages.d.ts +49 -0
  271. package/dist/daemon/services/messages.js +269 -0
  272. package/dist/daemon/services/repos.d.ts +61 -0
  273. package/dist/daemon/services/repos.js +350 -0
  274. package/dist/daemon/services/session-mcp-servers.d.ts +56 -0
  275. package/dist/daemon/services/session-mcp-servers.js +51 -0
  276. package/dist/daemon/services/sessions.d.ts +64 -0
  277. package/dist/daemon/services/sessions.js +398 -0
  278. package/dist/daemon/services/tasks.d.ts +55 -0
  279. package/dist/daemon/services/tasks.js +318 -0
  280. package/dist/daemon/services/terminals.d.ts +75 -0
  281. package/dist/daemon/services/terminals.js +110 -0
  282. package/dist/daemon/services/users.d.ts +98 -0
  283. package/dist/daemon/services/users.js +177 -0
  284. package/dist/daemon/services/worktrees.d.ts +98 -0
  285. package/dist/daemon/services/worktrees.js +719 -0
  286. package/dist/daemon/strategies/anonymous.d.ts +20 -0
  287. package/dist/daemon/strategies/anonymous.js +32 -0
  288. package/dist/ui/assets/cc-CYmbalCD.png +0 -0
  289. package/dist/ui/assets/codex-4sLD1mVS.png +0 -0
  290. package/dist/ui/assets/cursor-BUy5pFVL.png +0 -0
  291. package/dist/ui/assets/gemini-ajOb7iAl.png +0 -0
  292. package/dist/ui/assets/index-Dc4ELxry.css +32 -0
  293. package/dist/ui/assets/index-KfIu8v4V.js +578 -0
  294. package/dist/ui/favicon.png +0 -0
  295. package/dist/ui/index.html +26 -0
  296. package/dist/ui/vite.svg +1 -0
  297. package/package.json +90 -0
@@ -0,0 +1,228 @@
1
+ import { Params, HookContext as HookContext$1, Paginated } from '@feathersjs/feathers';
2
+
3
+ /**
4
+ * FeathersJS Type Abstractions
5
+ *
6
+ * Centralized type definitions for FeathersJS patterns used across Agor.
7
+ * These types provide a consistent interface for both client and server.
8
+ *
9
+ * Re-exports FeathersJS types so daemon doesn't need direct dependencies.
10
+ */
11
+
12
+ /**
13
+ * Authenticated user from JWT/Local strategy
14
+ *
15
+ * Extracted from JWT token or local authentication.
16
+ * Available in hook context and service params after authentication.
17
+ */
18
+ interface AuthenticatedUser {
19
+ /** User ID (UUIDv7) */
20
+ user_id: string;
21
+ /** User email address */
22
+ email: string;
23
+ /** User role (for authorization) */
24
+ role?: string;
25
+ }
26
+ /**
27
+ * Extended params with authentication context
28
+ *
29
+ * All authenticated requests include user information in params.
30
+ */
31
+ interface AuthenticatedParams extends Params {
32
+ /** Authenticated user (undefined for anonymous requests) */
33
+ user?: AuthenticatedUser;
34
+ }
35
+ /**
36
+ * Generic service query parameters with Feathers $ modifiers
37
+ *
38
+ * Supports pagination, sorting, field selection, and entity-specific filters.
39
+ *
40
+ * @template T - Entity type for type-safe filtering
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * interface SessionQuery extends QueryParams<Session> {
45
+ * query?: {
46
+ * status?: Session['status'];
47
+ * agentic_tool?: Session['agentic_tool'];
48
+ * $limit?: number;
49
+ * $skip?: number;
50
+ * };
51
+ * }
52
+ * ```
53
+ */
54
+ interface QueryParams<T = unknown> extends Params {
55
+ query?: {
56
+ /** Maximum number of results to return */
57
+ $limit?: number;
58
+ /** Number of results to skip (for pagination) */
59
+ $skip?: number;
60
+ /** Sort order (1 = ascending, -1 = descending) */
61
+ $sort?: Record<string, 1 | -1>;
62
+ /** Fields to include in results */
63
+ $select?: string[];
64
+ } & Partial<T>;
65
+ }
66
+ /**
67
+ * Hook context for create operations
68
+ *
69
+ * Supports both single objects and arrays for bulk operations.
70
+ * Data can be the full entity or partial (for creates).
71
+ *
72
+ * @template T - Entity type
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * async function validateMessage(context: CreateHookContext<Message>) {
77
+ * // context.data is Message | Message[]
78
+ * const messages = Array.isArray(context.data) ? context.data : [context.data];
79
+ * for (const msg of messages) {
80
+ * if (!msg.content) throw new Error('Message content required');
81
+ * }
82
+ * }
83
+ * ```
84
+ */
85
+ interface CreateHookContext<T = unknown> extends HookContext$1 {
86
+ params: AuthenticatedParams;
87
+ data: T | T[];
88
+ }
89
+ /**
90
+ * Hook context for update/patch operations
91
+ *
92
+ * Data is optional (may be undefined for get/find/remove operations).
93
+ * Supports partial updates via Partial<T>.
94
+ *
95
+ * @template T - Entity type
96
+ */
97
+ interface HookContext<T = unknown> extends HookContext$1 {
98
+ params: AuthenticatedParams;
99
+ data?: Partial<T> | Partial<T>[];
100
+ }
101
+ /**
102
+ * Base Feathers service interface with standard CRUD methods
103
+ *
104
+ * All Agor services implement this interface for consistency.
105
+ * Custom methods can be added via interface extension.
106
+ *
107
+ * @template T - Entity type (e.g., Session, Task, Message)
108
+ * @template D - Data type for create/update (defaults to Partial<T>)
109
+ * @template P - Params type (defaults to Params)
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * interface SessionsService extends BaseService<Session, Partial<Session>, SessionParams> {
114
+ * // Add custom methods
115
+ * fork(id: string, data: { prompt: string }, params?: SessionParams): Promise<Session>;
116
+ * }
117
+ * ```
118
+ */
119
+ interface BaseService<T, D = Partial<T>, P extends Params = Params> {
120
+ /**
121
+ * Find entities matching query criteria
122
+ *
123
+ * Returns paginated results if pagination is enabled, otherwise array.
124
+ */
125
+ find(params?: P): Promise<Paginated<T> | T[]>;
126
+ /**
127
+ * Get a single entity by ID
128
+ *
129
+ * @param id - Entity ID (usually UUIDv7)
130
+ * @param params - Query parameters
131
+ * @throws EntityNotFoundError if not found
132
+ */
133
+ get(id: string, params?: P): Promise<T>;
134
+ /**
135
+ * Create a new entity
136
+ *
137
+ * @param data - Entity data (full or partial)
138
+ * @param params - Request parameters
139
+ * @returns Created entity with generated fields (ID, timestamps)
140
+ */
141
+ create(data: D, params?: P): Promise<T>;
142
+ /**
143
+ * Replace an entity entirely (PUT semantics)
144
+ *
145
+ * @param id - Entity ID
146
+ * @param data - Complete entity data
147
+ * @param params - Request parameters
148
+ * @returns Updated entity
149
+ */
150
+ update(id: string, data: T, params?: P): Promise<T>;
151
+ /**
152
+ * Partially update an entity (PATCH semantics)
153
+ *
154
+ * Supports both single and multi-patch operations.
155
+ *
156
+ * @param id - Entity ID (or null for multi-patch)
157
+ * @param data - Partial entity data
158
+ * @param params - Request parameters
159
+ * @returns Updated entity
160
+ */
161
+ patch(id: string | null, data: D, params?: P): Promise<T>;
162
+ /**
163
+ * Remove an entity
164
+ *
165
+ * @param id - Entity ID
166
+ * @param params - Request parameters
167
+ * @returns Removed entity
168
+ */
169
+ remove(id: string, params?: P): Promise<T>;
170
+ }
171
+ /**
172
+ * Service with event emitter capabilities
173
+ *
174
+ * Feathers services emit events for real-time updates via Socket.IO.
175
+ * Clients can listen to these events for live data synchronization.
176
+ *
177
+ * @template T - Entity type
178
+ */
179
+ interface ServiceWithEvents<T> extends BaseService<T> {
180
+ /**
181
+ * Subscribe to service events
182
+ *
183
+ * Standard events: created, updated, patched, removed
184
+ *
185
+ * @param event - Event name
186
+ * @param handler - Event handler function
187
+ *
188
+ * @example
189
+ * ```ts
190
+ * service.on('created', (session: Session) => {
191
+ * console.log('New session:', session.session_id);
192
+ * });
193
+ * ```
194
+ */
195
+ on(event: string, handler: (data: T) => void): void;
196
+ /**
197
+ * Unsubscribe from service events
198
+ *
199
+ * @param event - Event name
200
+ * @param handler - Event handler to remove
201
+ */
202
+ removeListener(event: string, handler: (data: T) => void): void;
203
+ }
204
+ /**
205
+ * Authentication result from Feathers authentication
206
+ *
207
+ * Returned by authenticate() method after successful login.
208
+ * Contains JWT token and user information.
209
+ */
210
+ interface AuthenticationResult {
211
+ /** JWT access token */
212
+ accessToken: string;
213
+ /** Authentication metadata */
214
+ authentication: {
215
+ /** Strategy used (e.g., 'local', 'jwt', 'anonymous') */
216
+ strategy: string;
217
+ /** Token (may be undefined for anonymous) */
218
+ accessToken?: string;
219
+ /** Decoded JWT payload */
220
+ payload?: Record<string, unknown>;
221
+ };
222
+ /** Authenticated user (if available) */
223
+ user?: AuthenticatedUser;
224
+ /** Additional fields from strategy */
225
+ [key: string]: unknown;
226
+ }
227
+
228
+ export type { AuthenticatedUser as A, BaseService as B, CreateHookContext as C, HookContext as H, QueryParams as Q, ServiceWithEvents as S, AuthenticatedParams as a, AuthenticationResult as b };
@@ -0,0 +1,302 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/git/index.ts
21
+ var git_exports = {};
22
+ __export(git_exports, {
23
+ cloneRepo: () => cloneRepo,
24
+ createWorktree: () => createWorktree,
25
+ extractRepoName: () => extractRepoName,
26
+ getCurrentBranch: () => getCurrentBranch,
27
+ getCurrentSha: () => getCurrentSha,
28
+ getDefaultBranch: () => getDefaultBranch,
29
+ getGitState: () => getGitState,
30
+ getRemoteBranches: () => getRemoteBranches,
31
+ getRemoteUrl: () => getRemoteUrl,
32
+ getReposDir: () => getReposDir,
33
+ getWorktreePath: () => getWorktreePath,
34
+ getWorktreesDir: () => getWorktreesDir,
35
+ hasRemoteBranch: () => hasRemoteBranch,
36
+ isClean: () => isClean,
37
+ isGitRepo: () => isGitRepo,
38
+ listWorktrees: () => listWorktrees,
39
+ pruneWorktrees: () => pruneWorktrees,
40
+ removeWorktree: () => removeWorktree
41
+ });
42
+ module.exports = __toCommonJS(git_exports);
43
+ var import_node_fs = require("fs");
44
+ var import_promises = require("fs/promises");
45
+ var import_node_os = require("os");
46
+ var import_node_path = require("path");
47
+ var import_simple_git = require("simple-git");
48
+ function getGitBinary() {
49
+ const commonPaths = [
50
+ "/opt/homebrew/bin/git",
51
+ // Homebrew on Apple Silicon
52
+ "/usr/local/bin/git",
53
+ // Homebrew on Intel
54
+ "/usr/bin/git"
55
+ // System git (Docker and Linux)
56
+ ];
57
+ for (const path of commonPaths) {
58
+ if ((0, import_node_fs.existsSync)(path)) {
59
+ return path;
60
+ }
61
+ }
62
+ return void 0;
63
+ }
64
+ function createGit(baseDir) {
65
+ const gitBinary = getGitBinary();
66
+ const config = [
67
+ "core.sshCommand=ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
68
+ ];
69
+ return (0, import_simple_git.simpleGit)({
70
+ baseDir,
71
+ binary: gitBinary,
72
+ config
73
+ });
74
+ }
75
+ function getReposDir() {
76
+ return (0, import_node_path.join)((0, import_node_os.homedir)(), ".agor", "repos");
77
+ }
78
+ function extractRepoName(url) {
79
+ const match = url.match(/\/([^/]+?)(?:\.git)?$/);
80
+ if (!match) {
81
+ throw new Error(`Could not extract repo name from URL: ${url}`);
82
+ }
83
+ return match[1];
84
+ }
85
+ async function cloneRepo(options) {
86
+ const repoName = extractRepoName(options.url);
87
+ const reposDir = getReposDir();
88
+ const targetPath = options.targetDir || (0, import_node_path.join)(reposDir, repoName);
89
+ await (0, import_promises.mkdir)(reposDir, { recursive: true });
90
+ if ((0, import_node_fs.existsSync)(targetPath)) {
91
+ const isValid = await isGitRepo(targetPath);
92
+ if (isValid) {
93
+ console.log(`Repository already exists at ${targetPath}, using existing clone`);
94
+ const defaultBranch2 = await getDefaultBranch(targetPath);
95
+ return {
96
+ path: targetPath,
97
+ repoName,
98
+ defaultBranch: defaultBranch2
99
+ };
100
+ } else {
101
+ throw new Error(
102
+ `Directory exists but is not a valid git repository: ${targetPath}
103
+ Please delete this directory manually and try again.`
104
+ );
105
+ }
106
+ }
107
+ const git = createGit();
108
+ if (options.onProgress) {
109
+ git.outputHandler((_command, _stdout, _stderr) => {
110
+ });
111
+ }
112
+ await git.clone(options.url, targetPath, options.bare ? ["--bare"] : []);
113
+ const defaultBranch = await getDefaultBranch(targetPath);
114
+ return {
115
+ path: targetPath,
116
+ repoName,
117
+ defaultBranch
118
+ };
119
+ }
120
+ async function isGitRepo(path) {
121
+ try {
122
+ const git = createGit(path);
123
+ await git.status();
124
+ return true;
125
+ } catch {
126
+ return false;
127
+ }
128
+ }
129
+ async function getCurrentBranch(repoPath) {
130
+ const git = createGit(repoPath);
131
+ const status = await git.status();
132
+ return status.current || "";
133
+ }
134
+ async function getDefaultBranch(repoPath, remote = "origin") {
135
+ const git = createGit(repoPath);
136
+ try {
137
+ const result = await git.raw(["symbolic-ref", `refs/remotes/${remote}/HEAD`]);
138
+ const match = result.trim().match(/refs\/remotes\/[^/]+\/(.+)/);
139
+ if (match && match[1]) {
140
+ return match[1];
141
+ }
142
+ } catch {
143
+ }
144
+ try {
145
+ const branches = await git.branch();
146
+ return branches.current || "main";
147
+ } catch {
148
+ return "main";
149
+ }
150
+ }
151
+ async function getCurrentSha(repoPath) {
152
+ const git = createGit(repoPath);
153
+ const log = await git.log({ maxCount: 1 });
154
+ return log.latest?.hash || "";
155
+ }
156
+ async function isClean(repoPath) {
157
+ const git = createGit(repoPath);
158
+ const status = await git.status();
159
+ return status.isClean();
160
+ }
161
+ async function getRemoteUrl(repoPath, remote = "origin") {
162
+ const git = createGit(repoPath);
163
+ const remotes = await git.getRemotes(true);
164
+ const remoteObj = remotes.find((r) => r.name === remote);
165
+ return remoteObj?.refs.fetch || "";
166
+ }
167
+ function getWorktreesDir() {
168
+ return (0, import_node_path.join)((0, import_node_os.homedir)(), ".agor", "worktrees");
169
+ }
170
+ function getWorktreePath(repoSlug, worktreeName) {
171
+ return (0, import_node_path.join)(getWorktreesDir(), repoSlug, worktreeName);
172
+ }
173
+ async function createWorktree(repoPath, worktreePath, ref, createBranch = false, pullLatest = true, sourceBranch) {
174
+ const git = createGit(repoPath);
175
+ let fetchSucceeded = false;
176
+ if (pullLatest) {
177
+ try {
178
+ await git.fetch(["origin"]);
179
+ fetchSucceeded = true;
180
+ console.log("\u2705 Fetched latest from origin");
181
+ if (!createBranch) {
182
+ try {
183
+ const branches = await git.branch();
184
+ const localBranchExists = branches.all.includes(ref);
185
+ if (localBranchExists) {
186
+ const remoteBranches = await git.branch(["-r"]);
187
+ const remoteBranchExists = remoteBranches.all.includes(`origin/${ref}`);
188
+ if (remoteBranchExists) {
189
+ await git.raw(["branch", "-f", ref, `origin/${ref}`]);
190
+ console.log(`\u2705 Updated local ${ref} to match origin/${ref}`);
191
+ }
192
+ }
193
+ } catch (error) {
194
+ console.warn(
195
+ `\u26A0\uFE0F Failed to update local ${ref} branch:`,
196
+ error instanceof Error ? error.message : String(error)
197
+ );
198
+ }
199
+ }
200
+ } catch (error) {
201
+ console.warn(
202
+ "\u26A0\uFE0F Failed to fetch from origin (will use local refs):",
203
+ error instanceof Error ? error.message : String(error)
204
+ );
205
+ }
206
+ }
207
+ const args = [worktreePath];
208
+ if (createBranch) {
209
+ args.push("-b", ref);
210
+ if (sourceBranch) {
211
+ const baseRef = fetchSucceeded ? `origin/${sourceBranch}` : sourceBranch;
212
+ args.push(baseRef);
213
+ }
214
+ } else {
215
+ args.push(ref);
216
+ }
217
+ await git.raw(["worktree", "add", ...args]);
218
+ }
219
+ async function listWorktrees(repoPath) {
220
+ const git = createGit(repoPath);
221
+ const output = await git.raw(["worktree", "list", "--porcelain"]);
222
+ const worktrees = [];
223
+ const lines = output.split("\n");
224
+ let current = {};
225
+ for (const line of lines) {
226
+ if (line.startsWith("worktree ")) {
227
+ current.path = line.substring(9);
228
+ current.name = (0, import_node_path.basename)(current.path);
229
+ } else if (line.startsWith("HEAD ")) {
230
+ current.sha = line.substring(5);
231
+ } else if (line.startsWith("branch ")) {
232
+ current.ref = line.substring(7).replace("refs/heads/", "");
233
+ current.detached = false;
234
+ } else if (line.startsWith("detached")) {
235
+ current.detached = true;
236
+ } else if (line === "") {
237
+ if (current.path && current.sha) {
238
+ worktrees.push(current);
239
+ }
240
+ current = {};
241
+ }
242
+ }
243
+ if (current.path && current.sha) {
244
+ worktrees.push(current);
245
+ }
246
+ return worktrees;
247
+ }
248
+ async function removeWorktree(repoPath, worktreeName) {
249
+ const git = createGit(repoPath);
250
+ await git.raw(["worktree", "remove", worktreeName]);
251
+ }
252
+ async function pruneWorktrees(repoPath) {
253
+ const git = createGit(repoPath);
254
+ await git.raw(["worktree", "prune"]);
255
+ }
256
+ async function hasRemoteBranch(repoPath, branchName, remote = "origin") {
257
+ const git = createGit(repoPath);
258
+ const branches = await git.branch(["-r"]);
259
+ return branches.all.includes(`${remote}/${branchName}`);
260
+ }
261
+ async function getRemoteBranches(repoPath, remote = "origin") {
262
+ const git = createGit(repoPath);
263
+ const branches = await git.branch(["-r"]);
264
+ return branches.all.filter((b) => b.startsWith(`${remote}/`)).map((b) => b.replace(`${remote}/`, ""));
265
+ }
266
+ async function getGitState(repoPath) {
267
+ try {
268
+ if (!await isGitRepo(repoPath)) {
269
+ return "unknown";
270
+ }
271
+ const sha = await getCurrentSha(repoPath);
272
+ if (!sha) {
273
+ return "unknown";
274
+ }
275
+ const clean = await isClean(repoPath);
276
+ return clean ? sha : `${sha}-dirty`;
277
+ } catch (error) {
278
+ console.warn(`Failed to get git state for ${repoPath}:`, error);
279
+ return "unknown";
280
+ }
281
+ }
282
+ // Annotate the CommonJS export names for ESM import in node:
283
+ 0 && (module.exports = {
284
+ cloneRepo,
285
+ createWorktree,
286
+ extractRepoName,
287
+ getCurrentBranch,
288
+ getCurrentSha,
289
+ getDefaultBranch,
290
+ getGitState,
291
+ getRemoteBranches,
292
+ getRemoteUrl,
293
+ getReposDir,
294
+ getWorktreePath,
295
+ getWorktreesDir,
296
+ hasRemoteBranch,
297
+ isClean,
298
+ isGitRepo,
299
+ listWorktrees,
300
+ pruneWorktrees,
301
+ removeWorktree
302
+ });
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Git Utils for Agor
3
+ *
4
+ * Provides Git operations for repo management and worktree isolation
5
+ */
6
+ interface CloneOptions {
7
+ url: string;
8
+ targetDir?: string;
9
+ bare?: boolean;
10
+ onProgress?: (progress: CloneProgress) => void;
11
+ }
12
+ interface CloneProgress {
13
+ method: string;
14
+ stage: string;
15
+ progress: number;
16
+ processed?: number;
17
+ total?: number;
18
+ }
19
+ interface CloneResult {
20
+ path: string;
21
+ repoName: string;
22
+ defaultBranch: string;
23
+ }
24
+ /**
25
+ * Get default Agor repos directory (~/.agor/repos)
26
+ */
27
+ declare function getReposDir(): string;
28
+ /**
29
+ * Extract repo name from Git URL
30
+ *
31
+ * Examples:
32
+ * - git@github.com:apache/superset.git -> superset
33
+ * - https://github.com/facebook/react.git -> react
34
+ */
35
+ declare function extractRepoName(url: string): string;
36
+ /**
37
+ * Clone a Git repository to ~/.agor/repos/<name>
38
+ *
39
+ * If the repository already exists and is valid, returns existing repo info.
40
+ * If directory exists but is not a valid repo, throws an error with suggestion to delete.
41
+ *
42
+ * @param options - Clone options
43
+ * @returns Clone result with path and metadata
44
+ */
45
+ declare function cloneRepo(options: CloneOptions): Promise<CloneResult>;
46
+ /**
47
+ * Check if a directory is a Git repository
48
+ */
49
+ declare function isGitRepo(path: string): Promise<boolean>;
50
+ /**
51
+ * Get current branch name
52
+ */
53
+ declare function getCurrentBranch(repoPath: string): Promise<string>;
54
+ /**
55
+ * Get repository's default branch
56
+ *
57
+ * This is the branch that the remote HEAD points to (e.g., 'main', 'master', 'develop').
58
+ * Uses git symbolic-ref to determine the default branch accurately.
59
+ *
60
+ * @param repoPath - Path to repository
61
+ * @param remote - Remote name (default: 'origin')
62
+ * @returns Default branch name (e.g., 'main')
63
+ */
64
+ declare function getDefaultBranch(repoPath: string, remote?: string): Promise<string>;
65
+ /**
66
+ * Get current commit SHA
67
+ */
68
+ declare function getCurrentSha(repoPath: string): Promise<string>;
69
+ /**
70
+ * Check if working directory is clean (no uncommitted changes)
71
+ */
72
+ declare function isClean(repoPath: string): Promise<boolean>;
73
+ /**
74
+ * Get remote URL
75
+ */
76
+ declare function getRemoteUrl(repoPath: string, remote?: string): Promise<string>;
77
+ /**
78
+ * Get worktrees directory (~/.agor/worktrees)
79
+ */
80
+ declare function getWorktreesDir(): string;
81
+ /**
82
+ * Get path for a specific worktree
83
+ */
84
+ declare function getWorktreePath(repoSlug: string, worktreeName: string): string;
85
+ interface WorktreeInfo {
86
+ name: string;
87
+ path: string;
88
+ ref: string;
89
+ sha: string;
90
+ detached: boolean;
91
+ }
92
+ /**
93
+ * Create a git worktree
94
+ *
95
+ * @param repoPath - Path to repository
96
+ * @param worktreePath - Path where worktree should be created
97
+ * @param ref - Branch/tag/commit to checkout
98
+ * @param createBranch - Whether to create a new branch
99
+ * @param pullLatest - Whether to fetch from remote before creating worktree (defaults to true)
100
+ * @param sourceBranch - Source branch to base new branch on (used with createBranch)
101
+ */
102
+ declare function createWorktree(repoPath: string, worktreePath: string, ref: string, createBranch?: boolean, pullLatest?: boolean, // Changed default to true - always fetch latest!
103
+ sourceBranch?: string): Promise<void>;
104
+ /**
105
+ * List all worktrees for a repository
106
+ */
107
+ declare function listWorktrees(repoPath: string): Promise<WorktreeInfo[]>;
108
+ /**
109
+ * Remove a git worktree
110
+ */
111
+ declare function removeWorktree(repoPath: string, worktreeName: string): Promise<void>;
112
+ /**
113
+ * Prune stale worktree metadata
114
+ */
115
+ declare function pruneWorktrees(repoPath: string): Promise<void>;
116
+ /**
117
+ * Check if a remote branch exists
118
+ */
119
+ declare function hasRemoteBranch(repoPath: string, branchName: string, remote?: string): Promise<boolean>;
120
+ /**
121
+ * Get list of remote branches
122
+ */
123
+ declare function getRemoteBranches(repoPath: string, remote?: string): Promise<string[]>;
124
+ /**
125
+ * Get git state for a repository (SHA + dirty status)
126
+ *
127
+ * Returns the current commit SHA with "-dirty" suffix if working directory has uncommitted changes.
128
+ * If not in a git repo or SHA cannot be determined, returns "unknown".
129
+ *
130
+ * Examples:
131
+ * - "abc123def456" (clean working directory)
132
+ * - "abc123def456-dirty" (uncommitted changes)
133
+ * - "unknown" (not a git repo or error)
134
+ */
135
+ declare function getGitState(repoPath: string): Promise<string>;
136
+
137
+ export { type CloneOptions, type CloneProgress, type CloneResult, type WorktreeInfo, cloneRepo, createWorktree, extractRepoName, getCurrentBranch, getCurrentSha, getDefaultBranch, getGitState, getRemoteBranches, getRemoteUrl, getReposDir, getWorktreePath, getWorktreesDir, hasRemoteBranch, isClean, isGitRepo, listWorktrees, pruneWorktrees, removeWorktree };