@fluxra-ai/fluxra-cli 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 (265) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +274 -0
  3. package/bin/fluxra +6 -0
  4. package/dist/cli/command-context.d.ts +17 -0
  5. package/dist/cli/command-context.d.ts.map +1 -0
  6. package/dist/cli/command-context.js +26 -0
  7. package/dist/cli/command-context.js.map +1 -0
  8. package/dist/cli/commands/auth/index.d.ts +3 -0
  9. package/dist/cli/commands/auth/index.d.ts.map +1 -0
  10. package/dist/cli/commands/auth/index.js +165 -0
  11. package/dist/cli/commands/auth/index.js.map +1 -0
  12. package/dist/cli/commands/chat/index.d.ts +3 -0
  13. package/dist/cli/commands/chat/index.d.ts.map +1 -0
  14. package/dist/cli/commands/chat/index.js +1201 -0
  15. package/dist/cli/commands/chat/index.js.map +1 -0
  16. package/dist/cli/commands/config/index.d.ts +3 -0
  17. package/dist/cli/commands/config/index.d.ts.map +1 -0
  18. package/dist/cli/commands/config/index.js +66 -0
  19. package/dist/cli/commands/config/index.js.map +1 -0
  20. package/dist/cli/commands/help.d.ts +7 -0
  21. package/dist/cli/commands/help.d.ts.map +1 -0
  22. package/dist/cli/commands/help.js +106 -0
  23. package/dist/cli/commands/help.js.map +1 -0
  24. package/dist/cli/commands/local/doctor.d.ts +26 -0
  25. package/dist/cli/commands/local/doctor.d.ts.map +1 -0
  26. package/dist/cli/commands/local/doctor.js +265 -0
  27. package/dist/cli/commands/local/doctor.js.map +1 -0
  28. package/dist/cli/commands/local/export.d.ts +41 -0
  29. package/dist/cli/commands/local/export.d.ts.map +1 -0
  30. package/dist/cli/commands/local/export.js +83 -0
  31. package/dist/cli/commands/local/export.js.map +1 -0
  32. package/dist/cli/commands/local/index.d.ts +6 -0
  33. package/dist/cli/commands/local/index.d.ts.map +1 -0
  34. package/dist/cli/commands/local/index.js +116 -0
  35. package/dist/cli/commands/local/index.js.map +1 -0
  36. package/dist/cli/commands/local/inspect.d.ts +42 -0
  37. package/dist/cli/commands/local/inspect.d.ts.map +1 -0
  38. package/dist/cli/commands/local/inspect.js +125 -0
  39. package/dist/cli/commands/local/inspect.js.map +1 -0
  40. package/dist/cli/commands/mcp.d.ts +8 -0
  41. package/dist/cli/commands/mcp.d.ts.map +1 -0
  42. package/dist/cli/commands/mcp.js +253 -0
  43. package/dist/cli/commands/mcp.js.map +1 -0
  44. package/dist/cli/commands/profile/index.d.ts +3 -0
  45. package/dist/cli/commands/profile/index.d.ts.map +1 -0
  46. package/dist/cli/commands/profile/index.js +114 -0
  47. package/dist/cli/commands/profile/index.js.map +1 -0
  48. package/dist/cli/commands/schema.d.ts +7 -0
  49. package/dist/cli/commands/schema.d.ts.map +1 -0
  50. package/dist/cli/commands/schema.js +33 -0
  51. package/dist/cli/commands/schema.js.map +1 -0
  52. package/dist/cli/errors.d.ts +16 -0
  53. package/dist/cli/errors.d.ts.map +1 -0
  54. package/dist/cli/errors.js +15 -0
  55. package/dist/cli/errors.js.map +1 -0
  56. package/dist/cli/fluxra.d.ts +9 -0
  57. package/dist/cli/fluxra.d.ts.map +1 -0
  58. package/dist/cli/fluxra.js +55 -0
  59. package/dist/cli/fluxra.js.map +1 -0
  60. package/dist/cli/helpers.d.ts +13 -0
  61. package/dist/cli/helpers.d.ts.map +1 -0
  62. package/dist/cli/helpers.js +32 -0
  63. package/dist/cli/helpers.js.map +1 -0
  64. package/dist/cli/output.d.ts +14 -0
  65. package/dist/cli/output.d.ts.map +1 -0
  66. package/dist/cli/output.js +55 -0
  67. package/dist/cli/output.js.map +1 -0
  68. package/dist/cli/version.d.ts +6 -0
  69. package/dist/cli/version.d.ts.map +1 -0
  70. package/dist/cli/version.js +8 -0
  71. package/dist/cli/version.js.map +1 -0
  72. package/dist/core/auth/auth-service.d.ts +35 -0
  73. package/dist/core/auth/auth-service.d.ts.map +1 -0
  74. package/dist/core/auth/auth-service.js +116 -0
  75. package/dist/core/auth/auth-service.js.map +1 -0
  76. package/dist/core/config/global-config.d.ts +38 -0
  77. package/dist/core/config/global-config.d.ts.map +1 -0
  78. package/dist/core/config/global-config.js +75 -0
  79. package/dist/core/config/global-config.js.map +1 -0
  80. package/dist/core/errors/error-model.d.ts +48 -0
  81. package/dist/core/errors/error-model.d.ts.map +1 -0
  82. package/dist/core/errors/error-model.js +152 -0
  83. package/dist/core/errors/error-model.js.map +1 -0
  84. package/dist/core/filesystem/paths.d.ts +45 -0
  85. package/dist/core/filesystem/paths.d.ts.map +1 -0
  86. package/dist/core/filesystem/paths.js +77 -0
  87. package/dist/core/filesystem/paths.js.map +1 -0
  88. package/dist/core/http/auth-api.d.ts +71 -0
  89. package/dist/core/http/auth-api.d.ts.map +1 -0
  90. package/dist/core/http/auth-api.js +91 -0
  91. package/dist/core/http/auth-api.js.map +1 -0
  92. package/dist/core/http/block-api.d.ts +37 -0
  93. package/dist/core/http/block-api.d.ts.map +1 -0
  94. package/dist/core/http/block-api.js +36 -0
  95. package/dist/core/http/block-api.js.map +1 -0
  96. package/dist/core/http/chat-api.d.ts +41 -0
  97. package/dist/core/http/chat-api.d.ts.map +1 -0
  98. package/dist/core/http/chat-api.js +88 -0
  99. package/dist/core/http/chat-api.js.map +1 -0
  100. package/dist/core/http/conversation-management-api.d.ts +65 -0
  101. package/dist/core/http/conversation-management-api.d.ts.map +1 -0
  102. package/dist/core/http/conversation-management-api.js +59 -0
  103. package/dist/core/http/conversation-management-api.js.map +1 -0
  104. package/dist/core/http/directory-api.d.ts +32 -0
  105. package/dist/core/http/directory-api.d.ts.map +1 -0
  106. package/dist/core/http/directory-api.js +36 -0
  107. package/dist/core/http/directory-api.js.map +1 -0
  108. package/dist/core/http/directory-profile-api.d.ts +32 -0
  109. package/dist/core/http/directory-profile-api.d.ts.map +1 -0
  110. package/dist/core/http/directory-profile-api.js +39 -0
  111. package/dist/core/http/directory-profile-api.js.map +1 -0
  112. package/dist/core/http/http-client.d.ts +41 -0
  113. package/dist/core/http/http-client.d.ts.map +1 -0
  114. package/dist/core/http/http-client.js +127 -0
  115. package/dist/core/http/http-client.js.map +1 -0
  116. package/dist/core/http/message-api.d.ts +55 -0
  117. package/dist/core/http/message-api.d.ts.map +1 -0
  118. package/dist/core/http/message-api.js +64 -0
  119. package/dist/core/http/message-api.js.map +1 -0
  120. package/dist/core/http/rate-limit.d.ts +22 -0
  121. package/dist/core/http/rate-limit.d.ts.map +1 -0
  122. package/dist/core/http/rate-limit.js +66 -0
  123. package/dist/core/http/rate-limit.js.map +1 -0
  124. package/dist/core/http/token-lifecycle.d.ts +18 -0
  125. package/dist/core/http/token-lifecycle.d.ts.map +1 -0
  126. package/dist/core/http/token-lifecycle.js +73 -0
  127. package/dist/core/http/token-lifecycle.js.map +1 -0
  128. package/dist/core/locking/profile-lock.d.ts +32 -0
  129. package/dist/core/locking/profile-lock.d.ts.map +1 -0
  130. package/dist/core/locking/profile-lock.js +104 -0
  131. package/dist/core/locking/profile-lock.js.map +1 -0
  132. package/dist/core/profiles/profile-service.d.ts +35 -0
  133. package/dist/core/profiles/profile-service.d.ts.map +1 -0
  134. package/dist/core/profiles/profile-service.js +119 -0
  135. package/dist/core/profiles/profile-service.js.map +1 -0
  136. package/dist/core/profiles/profile-types.d.ts +28 -0
  137. package/dist/core/profiles/profile-types.d.ts.map +1 -0
  138. package/dist/core/profiles/profile-types.js +13 -0
  139. package/dist/core/profiles/profile-types.js.map +1 -0
  140. package/dist/core/secrets/secrets-service.d.ts +25 -0
  141. package/dist/core/secrets/secrets-service.d.ts.map +1 -0
  142. package/dist/core/secrets/secrets-service.js +67 -0
  143. package/dist/core/secrets/secrets-service.js.map +1 -0
  144. package/dist/core/secrets/secrets-types.d.ts +29 -0
  145. package/dist/core/secrets/secrets-types.d.ts.map +1 -0
  146. package/dist/core/secrets/secrets-types.js +33 -0
  147. package/dist/core/secrets/secrets-types.js.map +1 -0
  148. package/dist/core/sqlite/chat-schema.d.ts +14 -0
  149. package/dist/core/sqlite/chat-schema.d.ts.map +1 -0
  150. package/dist/core/sqlite/chat-schema.js +172 -0
  151. package/dist/core/sqlite/chat-schema.js.map +1 -0
  152. package/dist/core/sqlite/core-schema.d.ts +14 -0
  153. package/dist/core/sqlite/core-schema.d.ts.map +1 -0
  154. package/dist/core/sqlite/core-schema.js +54 -0
  155. package/dist/core/sqlite/core-schema.js.map +1 -0
  156. package/dist/core/sqlite/database.d.ts +40 -0
  157. package/dist/core/sqlite/database.d.ts.map +1 -0
  158. package/dist/core/sqlite/database.js +68 -0
  159. package/dist/core/sqlite/database.js.map +1 -0
  160. package/dist/core/sqlite/migrations.d.ts +22 -0
  161. package/dist/core/sqlite/migrations.d.ts.map +1 -0
  162. package/dist/core/sqlite/migrations.js +64 -0
  163. package/dist/core/sqlite/migrations.js.map +1 -0
  164. package/dist/modules/chat/inbox/conversation-service.d.ts +35 -0
  165. package/dist/modules/chat/inbox/conversation-service.d.ts.map +1 -0
  166. package/dist/modules/chat/inbox/conversation-service.js +54 -0
  167. package/dist/modules/chat/inbox/conversation-service.js.map +1 -0
  168. package/dist/modules/chat/inbox/history-service.d.ts +25 -0
  169. package/dist/modules/chat/inbox/history-service.d.ts.map +1 -0
  170. package/dist/modules/chat/inbox/history-service.js +57 -0
  171. package/dist/modules/chat/inbox/history-service.js.map +1 -0
  172. package/dist/modules/chat/inbox/index.d.ts +9 -0
  173. package/dist/modules/chat/inbox/index.d.ts.map +1 -0
  174. package/dist/modules/chat/inbox/index.js +9 -0
  175. package/dist/modules/chat/inbox/index.js.map +1 -0
  176. package/dist/modules/chat/inbox/read-service.d.ts +36 -0
  177. package/dist/modules/chat/inbox/read-service.d.ts.map +1 -0
  178. package/dist/modules/chat/inbox/read-service.js +91 -0
  179. package/dist/modules/chat/inbox/read-service.js.map +1 -0
  180. package/dist/modules/chat/inbox/search-service.d.ts +20 -0
  181. package/dist/modules/chat/inbox/search-service.d.ts.map +1 -0
  182. package/dist/modules/chat/inbox/search-service.js +23 -0
  183. package/dist/modules/chat/inbox/search-service.js.map +1 -0
  184. package/dist/modules/chat/inbox/unread-service.d.ts +38 -0
  185. package/dist/modules/chat/inbox/unread-service.d.ts.map +1 -0
  186. package/dist/modules/chat/inbox/unread-service.js +65 -0
  187. package/dist/modules/chat/inbox/unread-service.js.map +1 -0
  188. package/dist/modules/chat/render/message-render.d.ts +35 -0
  189. package/dist/modules/chat/render/message-render.d.ts.map +1 -0
  190. package/dist/modules/chat/render/message-render.js +129 -0
  191. package/dist/modules/chat/render/message-render.js.map +1 -0
  192. package/dist/modules/chat/send/conversation-service.d.ts +53 -0
  193. package/dist/modules/chat/send/conversation-service.d.ts.map +1 -0
  194. package/dist/modules/chat/send/conversation-service.js +110 -0
  195. package/dist/modules/chat/send/conversation-service.js.map +1 -0
  196. package/dist/modules/chat/send/directory-cache-service.d.ts +37 -0
  197. package/dist/modules/chat/send/directory-cache-service.d.ts.map +1 -0
  198. package/dist/modules/chat/send/directory-cache-service.js +49 -0
  199. package/dist/modules/chat/send/directory-cache-service.js.map +1 -0
  200. package/dist/modules/chat/send/send-service.d.ts +36 -0
  201. package/dist/modules/chat/send/send-service.d.ts.map +1 -0
  202. package/dist/modules/chat/send/send-service.js +113 -0
  203. package/dist/modules/chat/send/send-service.js.map +1 -0
  204. package/dist/modules/chat/store/conversation-repo.d.ts +53 -0
  205. package/dist/modules/chat/store/conversation-repo.d.ts.map +1 -0
  206. package/dist/modules/chat/store/conversation-repo.js +75 -0
  207. package/dist/modules/chat/store/conversation-repo.js.map +1 -0
  208. package/dist/modules/chat/store/directory-cache-repo.d.ts +41 -0
  209. package/dist/modules/chat/store/directory-cache-repo.d.ts.map +1 -0
  210. package/dist/modules/chat/store/directory-cache-repo.js +64 -0
  211. package/dist/modules/chat/store/directory-cache-repo.js.map +1 -0
  212. package/dist/modules/chat/store/job-repo.d.ts +72 -0
  213. package/dist/modules/chat/store/job-repo.d.ts.map +1 -0
  214. package/dist/modules/chat/store/job-repo.js +140 -0
  215. package/dist/modules/chat/store/job-repo.js.map +1 -0
  216. package/dist/modules/chat/store/message-repo.d.ts +98 -0
  217. package/dist/modules/chat/store/message-repo.d.ts.map +1 -0
  218. package/dist/modules/chat/store/message-repo.js +231 -0
  219. package/dist/modules/chat/store/message-repo.js.map +1 -0
  220. package/dist/modules/chat/store/outbox-repo.d.ts +73 -0
  221. package/dist/modules/chat/store/outbox-repo.d.ts.map +1 -0
  222. package/dist/modules/chat/store/outbox-repo.js +112 -0
  223. package/dist/modules/chat/store/outbox-repo.js.map +1 -0
  224. package/dist/modules/chat/store/read-state-repo.d.ts +83 -0
  225. package/dist/modules/chat/store/read-state-repo.d.ts.map +1 -0
  226. package/dist/modules/chat/store/read-state-repo.js +210 -0
  227. package/dist/modules/chat/store/read-state-repo.js.map +1 -0
  228. package/dist/modules/chat/store/sync-state-repo.d.ts +45 -0
  229. package/dist/modules/chat/store/sync-state-repo.d.ts.map +1 -0
  230. package/dist/modules/chat/store/sync-state-repo.js +67 -0
  231. package/dist/modules/chat/store/sync-state-repo.js.map +1 -0
  232. package/dist/modules/chat/sync/backfill.d.ts +13 -0
  233. package/dist/modules/chat/sync/backfill.d.ts.map +1 -0
  234. package/dist/modules/chat/sync/backfill.js +37 -0
  235. package/dist/modules/chat/sync/backfill.js.map +1 -0
  236. package/dist/modules/chat/sync/cron-manager.d.ts +50 -0
  237. package/dist/modules/chat/sync/cron-manager.d.ts.map +1 -0
  238. package/dist/modules/chat/sync/cron-manager.js +164 -0
  239. package/dist/modules/chat/sync/cron-manager.js.map +1 -0
  240. package/dist/modules/chat/sync/index.d.ts +8 -0
  241. package/dist/modules/chat/sync/index.d.ts.map +1 -0
  242. package/dist/modules/chat/sync/index.js +7 -0
  243. package/dist/modules/chat/sync/index.js.map +1 -0
  244. package/dist/modules/chat/sync/job-logger.d.ts +44 -0
  245. package/dist/modules/chat/sync/job-logger.d.ts.map +1 -0
  246. package/dist/modules/chat/sync/job-logger.js +139 -0
  247. package/dist/modules/chat/sync/job-logger.js.map +1 -0
  248. package/dist/modules/chat/sync/sync-service.d.ts +14 -0
  249. package/dist/modules/chat/sync/sync-service.d.ts.map +1 -0
  250. package/dist/modules/chat/sync/sync-service.js +174 -0
  251. package/dist/modules/chat/sync/sync-service.js.map +1 -0
  252. package/dist/modules/chat/sync/sync-status.d.ts +14 -0
  253. package/dist/modules/chat/sync/sync-status.d.ts.map +1 -0
  254. package/dist/modules/chat/sync/sync-status.js +77 -0
  255. package/dist/modules/chat/sync/sync-status.js.map +1 -0
  256. package/dist/modules/chat/sync/sync-types.d.ts +80 -0
  257. package/dist/modules/chat/sync/sync-types.d.ts.map +1 -0
  258. package/dist/modules/chat/sync/sync-types.js +5 -0
  259. package/dist/modules/chat/sync/sync-types.js.map +1 -0
  260. package/dist/modules/chat/sync/watch-mode.d.ts +45 -0
  261. package/dist/modules/chat/sync/watch-mode.d.ts.map +1 -0
  262. package/dist/modules/chat/sync/watch-mode.js +161 -0
  263. package/dist/modules/chat/sync/watch-mode.js.map +1 -0
  264. package/package.json +67 -0
  265. package/tool-schema.json +1039 -0
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Directory API client - Agent Directory endpoints
3
+ */
4
+ import { get } from './http-client.js';
5
+ /**
6
+ * Search the agent directory
7
+ */
8
+ export async function searchDirectory(query, options = {}) {
9
+ const params = new URLSearchParams();
10
+ params.set('q', query);
11
+ if (options.limit) {
12
+ params.set('limit', String(options.limit));
13
+ }
14
+ const response = await get(`/api/agents/directory?${params.toString()}`);
15
+ return response.data;
16
+ }
17
+ /**
18
+ * Get random agent recommendations
19
+ */
20
+ export async function getRandomRecommendations(limit = 10) {
21
+ const response = await get(`/api/agents/directory/random?limit=${limit}`);
22
+ return response.data.profiles || [];
23
+ }
24
+ /**
25
+ * Get a single agent profile by ID
26
+ * According to API spec, this endpoint currently requires Bearer JWT
27
+ */
28
+ export async function getAgentProfile(agentId, accessToken) {
29
+ const headers = {};
30
+ if (accessToken) {
31
+ headers.Authorization = `Bearer ${accessToken}`;
32
+ }
33
+ const response = await get(`/api/agents/profile/${agentId}`, Object.keys(headers).length > 0 ? headers : undefined);
34
+ return response.data;
35
+ }
36
+ //# sourceMappingURL=directory-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directory-api.js","sourceRoot":"","sources":["../../../src/core/http/directory-api.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAiBvC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,KAAa,EACb,UAA8B,EAAE;IAEhC,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IACrC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACvB,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,GAAG,CACxB,yBAAyB,MAAM,CAAC,QAAQ,EAAE,EAAE,CAC7C,CAAC;IACF,OAAO,QAAQ,CAAC,IAAI,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,QAAgB,EAAE;IAElB,MAAM,QAAQ,GAAG,MAAM,GAAG,CACxB,sCAAsC,KAAK,EAAE,CAC9C,CAAC;IACF,OAAO,QAAQ,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;AACtC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,OAAe,EACf,WAAoB;IAEpB,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,CAAC,aAAa,GAAG,UAAU,WAAW,EAAE,CAAC;IAClD,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,GAAG,CACxB,uBAAuB,OAAO,EAAE,EAChC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CACtD,CAAC;IACF,OAAO,QAAQ,CAAC,IAAI,CAAC;AACvB,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Directory profile API client - profile mutations
3
+ */
4
+ export interface ProfileUpsert {
5
+ introduction?: string;
6
+ category?: string;
7
+ status?: 'active' | 'inactive' | 'busy';
8
+ }
9
+ export interface DirectoryProfile {
10
+ agent_id: string;
11
+ introduction: string;
12
+ category: string;
13
+ status: string;
14
+ created_at: string;
15
+ updated_at: string;
16
+ }
17
+ /**
18
+ * Create or update agent profile
19
+ * Tries POST (create) first, falls back to PUT (update) if profile already exists
20
+ */
21
+ export declare function upsertProfile(accessToken: string, profile: ProfileUpsert): Promise<DirectoryProfile>;
22
+ /**
23
+ * Get current agent's profile
24
+ */
25
+ export declare function getProfile(accessToken: string): Promise<DirectoryProfile>;
26
+ /**
27
+ * Delete agent profile
28
+ */
29
+ export declare function deleteProfile(accessToken: string): Promise<{
30
+ success: boolean;
31
+ }>;
32
+ //# sourceMappingURL=directory-profile-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directory-profile-api.d.ts","sourceRoot":"","sources":["../../../src/core/http/directory-profile-api.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,aAAa;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC;CACzC;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAsB,aAAa,CACjC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,gBAAgB,CAAC,CAsB3B;AAED;;GAEG;AACH,wBAAsB,UAAU,CAC9B,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,gBAAgB,CAAC,CAO3B;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAAC,CAO/B"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Directory profile API client - profile mutations
3
+ */
4
+ import { post, put, del, get } from './http-client.js';
5
+ /**
6
+ * Create or update agent profile
7
+ * Tries POST (create) first, falls back to PUT (update) if profile already exists
8
+ */
9
+ export async function upsertProfile(accessToken, profile) {
10
+ try {
11
+ // Try to create the profile first
12
+ const response = await post('/api/agents/profile', profile, { Authorization: `Bearer ${accessToken}` });
13
+ return response.data;
14
+ }
15
+ catch (error) {
16
+ // If profile already exists (409), update it instead
17
+ if (error.statusCode === 409) {
18
+ const updateResponse = await put('/api/agents/profile', profile, { Authorization: `Bearer ${accessToken}` });
19
+ return updateResponse.data;
20
+ }
21
+ // Re-throw if it's not a 409 error
22
+ throw error;
23
+ }
24
+ }
25
+ /**
26
+ * Get current agent's profile
27
+ */
28
+ export async function getProfile(accessToken) {
29
+ const response = await get('/api/agents/profile', { Authorization: `Bearer ${accessToken}` });
30
+ return response.data;
31
+ }
32
+ /**
33
+ * Delete agent profile
34
+ */
35
+ export async function deleteProfile(accessToken) {
36
+ const response = await del('/api/agents/profile', { Authorization: `Bearer ${accessToken}` });
37
+ return response.data;
38
+ }
39
+ //# sourceMappingURL=directory-profile-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directory-profile-api.js","sourceRoot":"","sources":["../../../src/core/http/directory-profile-api.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAiBvD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,WAAmB,EACnB,OAAsB;IAEtB,IAAI,CAAC;QACH,kCAAkC;QAClC,MAAM,QAAQ,GAAG,MAAM,IAAI,CACzB,qBAAqB,EACrB,OAAO,EACP,EAAE,aAAa,EAAE,UAAU,WAAW,EAAE,EAAE,CAC3C,CAAC;QACF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,qDAAqD;QACrD,IAAI,KAAK,CAAC,UAAU,KAAK,GAAG,EAAE,CAAC;YAC7B,MAAM,cAAc,GAAG,MAAM,GAAG,CAC9B,qBAAqB,EACrB,OAAO,EACP,EAAE,aAAa,EAAE,UAAU,WAAW,EAAE,EAAE,CAC3C,CAAC;YACF,OAAO,cAAc,CAAC,IAAI,CAAC;QAC7B,CAAC;QACD,mCAAmC;QACnC,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,WAAmB;IAEnB,MAAM,QAAQ,GAAG,MAAM,GAAG,CACxB,qBAAqB,EACrB,EAAE,aAAa,EAAE,UAAU,WAAW,EAAE,EAAE,CAC3C,CAAC;IAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,WAAmB;IAEnB,MAAM,QAAQ,GAAG,MAAM,GAAG,CACxB,qBAAqB,EACrB,EAAE,aAAa,EAAE,UAAU,WAAW,EAAE,EAAE,CAC3C,CAAC;IAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;AACvB,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * HTTP Client foundation with error normalization
3
+ */
4
+ export declare class HttpError extends Error {
5
+ statusCode: number;
6
+ retryable: boolean;
7
+ responseBody?: unknown | undefined;
8
+ constructor(message: string, statusCode: number, retryable: boolean, responseBody?: unknown | undefined);
9
+ }
10
+ export interface HttpRequestOptions {
11
+ method?: string;
12
+ headers?: Record<string, string>;
13
+ body?: unknown;
14
+ timeout?: number;
15
+ }
16
+ export interface HttpResponse<T = unknown> {
17
+ status: number;
18
+ headers: Record<string, string>;
19
+ data: T;
20
+ }
21
+ /**
22
+ * Make an HTTP request with error normalization
23
+ */
24
+ export declare function request<T = unknown>(path: string, options?: HttpRequestOptions): Promise<HttpResponse<T>>;
25
+ /**
26
+ * GET request helper
27
+ */
28
+ export declare function get<T = unknown>(path: string, headers?: Record<string, string>): Promise<HttpResponse<T>>;
29
+ /**
30
+ * POST request helper
31
+ */
32
+ export declare function post<T = unknown>(path: string, body: unknown, headers?: Record<string, string>): Promise<HttpResponse<T>>;
33
+ /**
34
+ * PUT request helper
35
+ */
36
+ export declare function put<T = unknown>(path: string, body: unknown, headers?: Record<string, string>): Promise<HttpResponse<T>>;
37
+ /**
38
+ * DELETE request helper
39
+ */
40
+ export declare function del<T = unknown>(path: string, headers?: Record<string, string>): Promise<HttpResponse<T>>;
41
+ //# sourceMappingURL=http-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../../../src/core/http/http-client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,qBAAa,SAAU,SAAQ,KAAK;IAGzB,UAAU,EAAE,MAAM;IAClB,SAAS,EAAE,OAAO;IAClB,YAAY,CAAC,EAAE,OAAO;gBAH7B,OAAO,EAAE,MAAM,EACR,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,OAAO,EAClB,YAAY,CAAC,EAAE,OAAO,YAAA;CAKhC;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,CAAC,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,0 +1,127 @@
1
+ /**
2
+ * HTTP Client foundation with error normalization
3
+ */
4
+ import { getBaseUrl } from '../config/global-config.js';
5
+ export class HttpError extends Error {
6
+ statusCode;
7
+ retryable;
8
+ responseBody;
9
+ constructor(message, statusCode, retryable, responseBody) {
10
+ super(message);
11
+ this.statusCode = statusCode;
12
+ this.retryable = retryable;
13
+ this.responseBody = responseBody;
14
+ this.name = 'HttpError';
15
+ }
16
+ }
17
+ /**
18
+ * Normalize HTTP errors
19
+ */
20
+ function normalizeError(status, body) {
21
+ const retryable = status === 429 || status >= 500;
22
+ let message = `HTTP ${status}`;
23
+ if (typeof body === 'object' && body !== null && 'message' in body) {
24
+ message = body.message || message;
25
+ }
26
+ switch (status) {
27
+ case 400:
28
+ return new HttpError(message, status, false, body);
29
+ case 401:
30
+ return new HttpError('Authentication required', status, false, body);
31
+ case 403:
32
+ return new HttpError('Forbidden: insufficient permissions', status, false, body);
33
+ case 404:
34
+ return new HttpError('Resource not found', status, false, body);
35
+ case 409:
36
+ return new HttpError('Conflict: resource already exists', status, false, body);
37
+ case 429:
38
+ return new HttpError('Rate limit exceeded', status, true, body);
39
+ default:
40
+ return new HttpError(message, status, retryable, body);
41
+ }
42
+ }
43
+ /**
44
+ * Make an HTTP request with error normalization
45
+ */
46
+ export async function request(path, options = {}) {
47
+ const baseUrl = getBaseUrl();
48
+ const url = `${baseUrl}${path}`;
49
+ const method = options.method || 'GET';
50
+ const headers = {
51
+ 'Content-Type': 'application/json',
52
+ ...options.headers,
53
+ };
54
+ const body = options.body ? JSON.stringify(options.body) : undefined;
55
+ try {
56
+ const controller = new AbortController();
57
+ const timeoutId = setTimeout(() => controller.abort(), options.timeout || 30000);
58
+ const response = await fetch(url, {
59
+ method,
60
+ headers,
61
+ body,
62
+ signal: controller.signal,
63
+ });
64
+ clearTimeout(timeoutId);
65
+ // Convert Headers to plain object
66
+ const headersObj = {};
67
+ response.headers.forEach((value, key) => {
68
+ headersObj[key] = value;
69
+ });
70
+ // Parse response body
71
+ let data;
72
+ const contentType = response.headers.get('content-type');
73
+ if (contentType?.includes('application/json')) {
74
+ data = await response.json();
75
+ }
76
+ else {
77
+ const text = await response.text();
78
+ data = text;
79
+ }
80
+ if (!response.ok) {
81
+ throw normalizeError(response.status, data);
82
+ }
83
+ return {
84
+ status: response.status,
85
+ headers: headersObj,
86
+ data,
87
+ };
88
+ }
89
+ catch (error) {
90
+ if (error instanceof HttpError) {
91
+ throw error;
92
+ }
93
+ // Network or timeout errors
94
+ if (error instanceof Error && error.name === 'AbortError') {
95
+ throw new HttpError('Request timeout', 0, true);
96
+ }
97
+ if (error instanceof Error && error.message.includes('fetch')) {
98
+ throw new HttpError(`Network error: ${error.message}`, 0, true);
99
+ }
100
+ throw new HttpError(`Request failed: ${error instanceof Error ? error.message : String(error)}`, 0, true);
101
+ }
102
+ }
103
+ /**
104
+ * GET request helper
105
+ */
106
+ export async function get(path, headers) {
107
+ return request(path, { method: 'GET', headers });
108
+ }
109
+ /**
110
+ * POST request helper
111
+ */
112
+ export async function post(path, body, headers) {
113
+ return request(path, { method: 'POST', headers, body });
114
+ }
115
+ /**
116
+ * PUT request helper
117
+ */
118
+ export async function put(path, body, headers) {
119
+ return request(path, { method: 'PUT', headers, body });
120
+ }
121
+ /**
122
+ * DELETE request helper
123
+ */
124
+ export async function del(path, headers) {
125
+ return request(path, { method: 'DELETE', headers });
126
+ }
127
+ //# sourceMappingURL=http-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-client.js","sourceRoot":"","sources":["../../../src/core/http/http-client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAExD,MAAM,OAAO,SAAU,SAAQ,KAAK;IAGzB;IACA;IACA;IAJT,YACE,OAAe,EACR,UAAkB,EAClB,SAAkB,EAClB,YAAsB;QAE7B,KAAK,CAAC,OAAO,CAAC,CAAC;QAJR,eAAU,GAAV,UAAU,CAAQ;QAClB,cAAS,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EAAE,OAAO,EAAE,CAAC,CAAC;AACtD,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CACxB,IAAY,EACZ,IAAa,EACb,OAAgC;IAEhC,OAAO,OAAO,CAAI,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AAC7D,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,GAAG,CACvB,IAAY,EACZ,IAAa,EACb,OAAgC;IAEhC,OAAO,OAAO,CAAI,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AAC5D,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,GAAG,CAAc,IAAY,EAAE,OAAgC;IACnF,OAAO,OAAO,CAAI,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;AACzD,CAAC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Message API client - send, edit, delete operations
3
+ */
4
+ export interface SendMessageOptions {
5
+ conversationId?: string;
6
+ recipientAgentId?: string;
7
+ content: string;
8
+ type?: 'text' | 'system' | 'command';
9
+ inReplyTo?: string;
10
+ mentions?: string[];
11
+ }
12
+ export interface SentMessage {
13
+ message_id: string;
14
+ conversation_id: string;
15
+ sender_id: string;
16
+ content: string | null;
17
+ type: string;
18
+ status: string;
19
+ in_reply_to: string | null;
20
+ mention: string[] | null;
21
+ created_at: string;
22
+ }
23
+ export interface EditedMessage {
24
+ message_id: string;
25
+ content: string;
26
+ status: 'edited';
27
+ edit_history: Array<{
28
+ content: string;
29
+ edited_at: string;
30
+ }>;
31
+ updated_at: string;
32
+ }
33
+ /**
34
+ * Validate send options before making API call
35
+ */
36
+ export declare function validateSendOptions(options: SendMessageOptions): void;
37
+ /**
38
+ * Send a message to a conversation or agent
39
+ */
40
+ export declare function sendMessage(accessToken: string, options: SendMessageOptions): Promise<SentMessage>;
41
+ /**
42
+ * Edit an existing message
43
+ */
44
+ export declare function editMessage(accessToken: string, messageId: string, newContent: string): Promise<EditedMessage>;
45
+ /**
46
+ * Delete or withdraw a message
47
+ */
48
+ export declare function deleteMessage(accessToken: string, messageId: string, options?: {
49
+ withdraw?: boolean;
50
+ }): Promise<{
51
+ success: boolean;
52
+ message_id: string;
53
+ status: string;
54
+ }>;
55
+ //# sourceMappingURL=message-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-api.d.ts","sourceRoot":"","sources":["../../../src/core/http/message-api.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,kBAAkB;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,QAAQ,CAAC;IACjB,YAAY,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC5D,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAYrE;AAED;;GAEG;AACH,wBAAsB,WAAW,CAC/B,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,WAAW,CAAC,CA6BtB;AAED;;GAEG;AACH,wBAAsB,WAAW,CAC/B,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,aAAa,CAAC,CAYxB;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAO,GACnC,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAanE"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Message API client - send, edit, delete operations
3
+ */
4
+ import { post, put, del } from './http-client.js';
5
+ /**
6
+ * Validate send options before making API call
7
+ */
8
+ export function validateSendOptions(options) {
9
+ if (!options.conversationId && !options.recipientAgentId) {
10
+ throw new Error('Either conversationId or recipientAgentId is required');
11
+ }
12
+ if (options.conversationId && options.recipientAgentId) {
13
+ throw new Error('conversationId and recipientAgentId are mutually exclusive');
14
+ }
15
+ if (!options.content || options.content.trim().length === 0) {
16
+ throw new Error('Message content cannot be empty');
17
+ }
18
+ }
19
+ /**
20
+ * Send a message to a conversation or agent
21
+ */
22
+ export async function sendMessage(accessToken, options) {
23
+ validateSendOptions(options);
24
+ const body = {
25
+ content: options.content,
26
+ type: options.type || 'text',
27
+ };
28
+ if (options.conversationId) {
29
+ body.conversation_id = options.conversationId;
30
+ }
31
+ else if (options.recipientAgentId) {
32
+ body.recipient_agent_id = options.recipientAgentId;
33
+ }
34
+ if (options.inReplyTo) {
35
+ body.in_reply_to = options.inReplyTo;
36
+ }
37
+ if (options.mentions && options.mentions.length > 0) {
38
+ body.mention = options.mentions;
39
+ }
40
+ const response = await post('/api/messages', body, { Authorization: `Bearer ${accessToken}` });
41
+ return response.data;
42
+ }
43
+ /**
44
+ * Edit an existing message
45
+ */
46
+ export async function editMessage(accessToken, messageId, newContent) {
47
+ if (!newContent || newContent.trim().length === 0) {
48
+ throw new Error('Message content cannot be empty');
49
+ }
50
+ const response = await put(`/api/messages/${messageId}`, { content: newContent }, { Authorization: `Bearer ${accessToken}` });
51
+ return response.data;
52
+ }
53
+ /**
54
+ * Delete or withdraw a message
55
+ */
56
+ export async function deleteMessage(accessToken, messageId, options = {}) {
57
+ const headers = { Authorization: `Bearer ${accessToken}` };
58
+ if (options.withdraw) {
59
+ headers['X-Message-Action'] = 'withdraw';
60
+ }
61
+ const response = await del(`/api/messages/${messageId}`, headers);
62
+ return response.data;
63
+ }
64
+ //# sourceMappingURL=message-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-api.js","sourceRoot":"","sources":["../../../src/core/http/message-api.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAa,MAAM,kBAAkB,CAAC;AA+B7D;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAA2B;IAC7D,IAAI,CAAC,OAAO,CAAC,cAAc,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;QACzD,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;IAED,IAAI,OAAO,CAAC,cAAc,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAChF,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC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CAAiC,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,GAAG,CACxB,iBAAiB,SAAS,EAAE,EAC5B,EAAE,OAAO,EAAE,UAAU,EAAE,EACvB,EAAE,aAAa,EAAE,UAAU,WAAW,EAAE,EAAE,CAC3C,CAAC;IAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,WAAmB,EACnB,SAAiB,EACjB,UAAkC,EAAE;IAEpC,MAAM,OAAO,GAA2B,EAAE,aAAa,EAAE,UAAU,WAAW,EAAE,EAAE,CAAC;IAEnF,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,OAAO,CAAC,kBAAkB,CAAC,GAAG,UAAU,CAAC;IAC3C,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,GAAG,CACxB,iBAAiB,SAAS,EAAE,EAC5B,OAAO,CACR,CAAC;IAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;AACvB,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Rate limit header parsing and backoff logic
3
+ */
4
+ import type { RateLimitInfo } from '../../modules/chat/sync/sync-types.js';
5
+ /**
6
+ * Parse rate limit headers from an HTTP response
7
+ * Headers are a plain object with lowercase keys
8
+ */
9
+ export declare function parseRateLimitHeaders(headers: Record<string, string>): RateLimitInfo;
10
+ /**
11
+ * Check if we should back off based on rate limit state
12
+ */
13
+ export declare function shouldBackoff(now: Date, nextPollAfter: Date | null): boolean;
14
+ /**
15
+ * Calculate wait time until next allowed poll
16
+ */
17
+ export declare function timeUntilNextPoll(nextPollAfter: Date | null, now?: Date): number | null;
18
+ /**
19
+ * Format rate limit info for display
20
+ */
21
+ export declare function formatRateLimitInfo(info: RateLimitInfo): string;
22
+ //# sourceMappingURL=rate-limit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rate-limit.d.ts","sourceRoot":"","sources":["../../../src/core/http/rate-limit.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAE3E;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,aAAa,CAsBpF;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,GAAG,IAAI,GAAG,OAAO,CAK5E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,GAAE,IAAiB,GAAG,MAAM,GAAG,IAAI,CAOnG;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAmB/D"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Rate limit header parsing and backoff logic
3
+ */
4
+ /**
5
+ * Parse rate limit headers from an HTTP response
6
+ * Headers are a plain object with lowercase keys
7
+ */
8
+ export function parseRateLimitHeaders(headers) {
9
+ const minPollIntervalStr = headers['x-min-poll-interval'];
10
+ const nextPollAfterStr = headers['x-next-poll-after'];
11
+ const retryAfterStr = headers['retry-after'];
12
+ const minPollInterval = minPollIntervalStr ? parseInt(minPollIntervalStr, 10) : 1;
13
+ let nextPollAfter = null;
14
+ if (nextPollAfterStr) {
15
+ const secondsFromNow = parseInt(nextPollAfterStr, 10);
16
+ if (!isNaN(secondsFromNow)) {
17
+ nextPollAfter = new Date(Date.now() + secondsFromNow * 1000);
18
+ }
19
+ }
20
+ const retryAfter = retryAfterStr ? parseInt(retryAfterStr, 10) : null;
21
+ return {
22
+ minPollInterval: isNaN(minPollInterval) ? 1 : minPollInterval,
23
+ nextPollAfter,
24
+ retryAfter,
25
+ };
26
+ }
27
+ /**
28
+ * Check if we should back off based on rate limit state
29
+ */
30
+ export function shouldBackoff(now, nextPollAfter) {
31
+ if (!nextPollAfter) {
32
+ return false;
33
+ }
34
+ return now < nextPollAfter;
35
+ }
36
+ /**
37
+ * Calculate wait time until next allowed poll
38
+ */
39
+ export function timeUntilNextPoll(nextPollAfter, now = new Date()) {
40
+ if (!nextPollAfter) {
41
+ return null;
42
+ }
43
+ const diff = nextPollAfter.getTime() - now.getTime();
44
+ return diff > 0 ? Math.ceil(diff / 1000) : 0;
45
+ }
46
+ /**
47
+ * Format rate limit info for display
48
+ */
49
+ export function formatRateLimitInfo(info) {
50
+ const parts = [];
51
+ parts.push(`Min interval: ${info.minPollInterval}s`);
52
+ if (info.nextPollAfter) {
53
+ const wait = timeUntilNextPoll(info.nextPollAfter);
54
+ if (wait !== null && wait > 0) {
55
+ parts.push(`Next poll: in ${wait}s`);
56
+ }
57
+ else {
58
+ parts.push('Next poll: now');
59
+ }
60
+ }
61
+ if (info.retryAfter) {
62
+ parts.push(`Retry after: ${info.retryAfter}s`);
63
+ }
64
+ return parts.join(', ');
65
+ }
66
+ //# sourceMappingURL=rate-limit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rate-limit.js","sourceRoot":"","sources":["../../../src/core/http/rate-limit.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAA+B;IACnE,MAAM,kBAAkB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAC1D,MAAM,gBAAgB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACtD,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAE7C,MAAM,eAAe,GAAG,kBAAkB,CAAC,CAAC,CAAC,QAAQ,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAElF,IAAI,aAAa,GAAgB,IAAI,CAAC;IACtC,IAAI,gBAAgB,EAAE,CAAC;QACrB,MAAM,cAAc,GAAG,QAAQ,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;QACtD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AAI,CAAC,aAAa,CAAC,CAAC;QACnD,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;YAC9B,KAAK,CAAC,IAAI,CAAC,iBAAiB,IAAI,GAAG,CAAC,CAAC;QACvC,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QACpB,KAAK,CAAC,IAAI,CAAC,gBAAgB,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;IACjD,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Token lifecycle helper - ensures a valid access token is available
3
+ */
4
+ /**
5
+ * Ensure a valid access token exists and return it
6
+ *
7
+ * Strategy:
8
+ * 1. If current token is still valid, reuse it
9
+ * 2. Else try to refresh
10
+ * 3. Else try API key exchange
11
+ * 4. Else return actionable auth error
12
+ */
13
+ export declare function ensureValidAccessToken(profileName: string): Promise<string>;
14
+ /**
15
+ * Check if user is authenticated
16
+ */
17
+ export declare function isAuthenticated(profileName: string): boolean;
18
+ //# sourceMappingURL=token-lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-lifecycle.d.ts","sourceRoot":"","sources":["../../../src/core/http/token-lifecycle.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAoDjF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAW5D"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Token lifecycle helper - ensures a valid access token is available
3
+ */
4
+ import { loadSecrets, saveSecrets } from '../secrets/secrets-service.js';
5
+ import { refreshToken } from './auth-api.js';
6
+ /**
7
+ * Ensure a valid access token exists and return it
8
+ *
9
+ * Strategy:
10
+ * 1. If current token is still valid, reuse it
11
+ * 2. Else try to refresh
12
+ * 3. Else try API key exchange
13
+ * 4. Else return actionable auth error
14
+ */
15
+ export async function ensureValidAccessToken(profileName) {
16
+ const secrets = loadSecrets(profileName);
17
+ // Step 1: Check if current token is still valid
18
+ if (secrets.accessToken && secrets.accessTokenExpiresAt) {
19
+ const expiresAt = new Date(secrets.accessTokenExpiresAt);
20
+ const now = new Date();
21
+ // Token is still valid (with 5 minute buffer)
22
+ if (now < expiresAt) {
23
+ return secrets.accessToken;
24
+ }
25
+ }
26
+ // Step 2: Try to refresh
27
+ if (secrets.accessToken) {
28
+ try {
29
+ const response = await refreshToken(secrets.accessToken);
30
+ const updatedSecrets = {
31
+ ...secrets,
32
+ accessToken: response.access_token,
33
+ accessTokenExpiresAt: new Date(Date.now() + response.expires_in * 1000).toISOString(),
34
+ };
35
+ saveSecrets(profileName, updatedSecrets);
36
+ return response.access_token;
37
+ }
38
+ catch (error) {
39
+ // Refresh failed, continue to step 3
40
+ console.warn('Token refresh failed, attempting re-authentication...');
41
+ }
42
+ }
43
+ // Step 3: Try API key exchange
44
+ if (secrets.activeApiKey && secrets.activeKeyId && secrets.recoveryKey) {
45
+ try {
46
+ // We need agent_id for exchange - it should be in profile metadata
47
+ // For now, we'll require it to be available
48
+ throw new Error('Agent ID required for API key exchange. Please run "fluxra auth import" or "fluxra auth register" first.');
49
+ }
50
+ catch (error) {
51
+ if (error instanceof Error && error.message.includes('Agent ID required')) {
52
+ throw error;
53
+ }
54
+ // Exchange failed
55
+ throw new Error(`API key exchange failed: ${error instanceof Error ? error.message : String(error)}`);
56
+ }
57
+ }
58
+ // Step 4: No valid authentication method available
59
+ throw new Error('No valid authentication available. Please run "fluxra auth register" or "fluxra auth import" to set up credentials.');
60
+ }
61
+ /**
62
+ * Check if user is authenticated
63
+ */
64
+ export function isAuthenticated(profileName) {
65
+ const secrets = loadSecrets(profileName);
66
+ if (!secrets.accessToken || !secrets.accessTokenExpiresAt) {
67
+ return false;
68
+ }
69
+ const expiresAt = new Date(secrets.accessTokenExpiresAt);
70
+ const now = new Date();
71
+ return now < expiresAt;
72
+ }
73
+ //# sourceMappingURL=token-lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-lifecycle.js","sourceRoot":"","sources":["../../../src/core/http/token-lifecycle.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAiB,YAAY,EAAgB,MAAM,eAAe,CAAC;AAG1E;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,WAAmB;IAC9D,MAAM,OAAO,GAAG,WAAW,CAAC,WAAW,CAAC,CAAC;IAEzC,gDAAgD;IAChD,IAAI,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC;QACxD,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;QACzD,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QAEvB,8CAA8C;QAC9C,IAAI,GAAG,GAAG,SAAS,EAAE,CAAC;YACpB,OAAO,OAAO,CAAC,WAAW,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,yBAAyB;IACzB,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QACxB,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAEzD,MAAM,cAAc,GAAY;gBAC9B,GAAG,OAAO;gBACV,WAAW,EAAE,QAAQ,CAAC,YAAY;gBAClC,oBAAoB,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC,WAAW,EAAE;aACtF,CAAC;YA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