@hasna/todos 0.11.46 → 0.11.47

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 (258) hide show
  1. package/README.md +11 -1219
  2. package/dashboard/dist/assets/{index-CVF1vn7Z.js → index-B-w1tUlm.js} +23 -23
  3. package/dashboard/dist/assets/index-BXQ39iMX.css +1 -0
  4. package/dashboard/dist/index.html +2 -2
  5. package/dist/cli/commands/agent-commands.d.ts.map +1 -1
  6. package/dist/cli/commands/cloud-commands.d.ts +3 -0
  7. package/dist/cli/commands/cloud-commands.d.ts.map +1 -0
  8. package/dist/cli/commands/config-serve-commands.d.ts.map +1 -1
  9. package/dist/cli/commands/machines.d.ts.map +1 -1
  10. package/dist/cli/commands/mcp-hooks-commands.d.ts.map +1 -1
  11. package/dist/cli/commands/plan-template-commands.d.ts.map +1 -1
  12. package/dist/cli/commands/project-commands.d.ts.map +1 -1
  13. package/dist/cli/commands/query-commands.d.ts.map +1 -1
  14. package/dist/cli/commands/task-commands.d.ts.map +1 -1
  15. package/dist/cli/components/Dashboard.d.ts.map +1 -1
  16. package/dist/cli/index.js +28793 -46092
  17. package/dist/db/agent-metrics.d.ts +0 -101
  18. package/dist/db/agent-metrics.d.ts.map +1 -1
  19. package/dist/db/agent-names.d.ts +3 -0
  20. package/dist/db/agent-names.d.ts.map +1 -1
  21. package/dist/db/builtin-templates.d.ts +0 -17
  22. package/dist/db/builtin-templates.d.ts.map +1 -1
  23. package/dist/db/comments.d.ts.map +1 -1
  24. package/dist/db/database.d.ts +1 -2
  25. package/dist/db/database.d.ts.map +1 -1
  26. package/dist/db/handoffs.d.ts +1 -52
  27. package/dist/db/handoffs.d.ts.map +1 -1
  28. package/dist/db/machines.d.ts +6 -19
  29. package/dist/db/machines.d.ts.map +1 -1
  30. package/dist/db/migrations.d.ts.map +1 -1
  31. package/dist/db/pg-migrate.d.ts +14 -0
  32. package/dist/db/pg-migrate.d.ts.map +1 -0
  33. package/dist/db/pg-migrations.d.ts +8 -0
  34. package/dist/db/pg-migrations.d.ts.map +1 -0
  35. package/dist/db/plans.d.ts.map +1 -1
  36. package/dist/db/schema.d.ts.map +1 -1
  37. package/dist/db/task-commits.d.ts +0 -51
  38. package/dist/db/task-commits.d.ts.map +1 -1
  39. package/dist/db/task-crud.d.ts.map +1 -1
  40. package/dist/db/task-lifecycle.d.ts +1 -16
  41. package/dist/db/task-lifecycle.d.ts.map +1 -1
  42. package/dist/db/task-relations.d.ts +9 -69
  43. package/dist/db/task-relations.d.ts.map +1 -1
  44. package/dist/db/tasks.d.ts +4 -8
  45. package/dist/db/tasks.d.ts.map +1 -1
  46. package/dist/index.d.ts +14 -133
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +14567 -25774
  49. package/dist/lib/auto-assign.d.ts +5 -3
  50. package/dist/lib/auto-assign.d.ts.map +1 -1
  51. package/dist/lib/config.d.ts +0 -355
  52. package/dist/lib/config.d.ts.map +1 -1
  53. package/dist/lib/extract.d.ts +0 -57
  54. package/dist/lib/extract.d.ts.map +1 -1
  55. package/dist/lib/logger.d.ts +12 -6
  56. package/dist/lib/logger.d.ts.map +1 -1
  57. package/dist/mcp/index.d.ts.map +1 -1
  58. package/dist/mcp/index.js +22566 -30764
  59. package/dist/mcp/token-utils.d.ts +2 -2
  60. package/dist/mcp/token-utils.d.ts.map +1 -1
  61. package/dist/mcp/tools/cloud.d.ts +12 -0
  62. package/dist/mcp/tools/cloud.d.ts.map +1 -0
  63. package/dist/mcp/tools/code-tools.d.ts.map +1 -1
  64. package/dist/mcp/tools/machines.d.ts.map +1 -1
  65. package/dist/mcp/tools/task-adv-tools.d.ts.map +1 -1
  66. package/dist/mcp/tools/task-auto-tools.d.ts.map +1 -1
  67. package/dist/mcp/tools/task-crud.d.ts.map +1 -1
  68. package/dist/mcp/tools/task-meta-tools.d.ts.map +1 -1
  69. package/dist/mcp/tools/task-project-tools.d.ts.map +1 -1
  70. package/dist/mcp/tools/task-rel-tools.d.ts.map +1 -1
  71. package/dist/mcp/tools/task-resources.d.ts.map +1 -1
  72. package/dist/mcp/tools/task-workflow-tools.d.ts.map +1 -1
  73. package/dist/mcp/tools/templates.d.ts.map +1 -1
  74. package/dist/sdk/client.d.ts +1 -1
  75. package/dist/sdk/client.d.ts.map +1 -1
  76. package/dist/sdk/types.d.ts +1 -26
  77. package/dist/sdk/types.d.ts.map +1 -1
  78. package/dist/server/index.js +334 -1874
  79. package/dist/server/routes.d.ts.map +1 -1
  80. package/dist/types/index.d.ts +1 -216
  81. package/dist/types/index.d.ts.map +1 -1
  82. package/package.json +6 -30
  83. package/dashboard/dist/assets/index-DJm6m6Yy.css +0 -1
  84. package/dist/capabilities.d.ts +0 -32
  85. package/dist/capabilities.d.ts.map +0 -1
  86. package/dist/cli/commands/agent-reliability-commands.d.ts +0 -3
  87. package/dist/cli/commands/agent-reliability-commands.d.ts.map +0 -1
  88. package/dist/cli/commands/audit-ledger-commands.d.ts +0 -3
  89. package/dist/cli/commands/audit-ledger-commands.d.ts.map +0 -1
  90. package/dist/cli/commands/capacity-commands.d.ts +0 -3
  91. package/dist/cli/commands/capacity-commands.d.ts.map +0 -1
  92. package/dist/cli/commands/environment-snapshots.d.ts +0 -3
  93. package/dist/cli/commands/environment-snapshots.d.ts.map +0 -1
  94. package/dist/cli/commands/help-commands.d.ts +0 -3
  95. package/dist/cli/commands/help-commands.d.ts.map +0 -1
  96. package/dist/cli/commands/knowledge-commands.d.ts +0 -3
  97. package/dist/cli/commands/knowledge-commands.d.ts.map +0 -1
  98. package/dist/cli/commands/local-backup-commands.d.ts +0 -3
  99. package/dist/cli/commands/local-backup-commands.d.ts.map +0 -1
  100. package/dist/cli/commands/local-snapshot-commands.d.ts +0 -3
  101. package/dist/cli/commands/local-snapshot-commands.d.ts.map +0 -1
  102. package/dist/cli/commands/onboarding-commands.d.ts +0 -3
  103. package/dist/cli/commands/onboarding-commands.d.ts.map +0 -1
  104. package/dist/cli/commands/release-compatibility-commands.d.ts +0 -3
  105. package/dist/cli/commands/release-compatibility-commands.d.ts.map +0 -1
  106. package/dist/cli/commands/retrospective-commands.d.ts +0 -3
  107. package/dist/cli/commands/retrospective-commands.d.ts.map +0 -1
  108. package/dist/cli/commands/review-queue-commands.d.ts +0 -3
  109. package/dist/cli/commands/review-queue-commands.d.ts.map +0 -1
  110. package/dist/cli/commands/risk-commands.d.ts +0 -3
  111. package/dist/cli/commands/risk-commands.d.ts.map +0 -1
  112. package/dist/cli/commands/roadmap-commands.d.ts +0 -3
  113. package/dist/cli/commands/roadmap-commands.d.ts.map +0 -1
  114. package/dist/cli/commands/scale-hardening-commands.d.ts +0 -3
  115. package/dist/cli/commands/scale-hardening-commands.d.ts.map +0 -1
  116. package/dist/cli/commands/sdk-fixture-commands.d.ts +0 -3
  117. package/dist/cli/commands/sdk-fixture-commands.d.ts.map +0 -1
  118. package/dist/cli/commands/usage-ledger-commands.d.ts +0 -3
  119. package/dist/cli/commands/usage-ledger-commands.d.ts.map +0 -1
  120. package/dist/cli-mcp-parity.d.ts +0 -41
  121. package/dist/cli-mcp-parity.d.ts.map +0 -1
  122. package/dist/contracts.d.ts +0 -87
  123. package/dist/contracts.d.ts.map +0 -1
  124. package/dist/contracts.js +0 -18172
  125. package/dist/db/boards.d.ts +0 -56
  126. package/dist/db/boards.d.ts.map +0 -1
  127. package/dist/db/calendar.d.ts +0 -52
  128. package/dist/db/calendar.d.ts.map +0 -1
  129. package/dist/db/inbox.d.ts +0 -47
  130. package/dist/db/inbox.d.ts.map +0 -1
  131. package/dist/db/project-knowledge.d.ts +0 -88
  132. package/dist/db/project-knowledge.d.ts.map +0 -1
  133. package/dist/db/project-risks.d.ts +0 -139
  134. package/dist/db/project-risks.d.ts.map +0 -1
  135. package/dist/db/retrospectives.d.ts +0 -98
  136. package/dist/db/retrospectives.d.ts.map +0 -1
  137. package/dist/db/task-runs.d.ts +0 -133
  138. package/dist/db/task-runs.d.ts.map +0 -1
  139. package/dist/json-contracts.d.ts +0 -56
  140. package/dist/json-contracts.d.ts.map +0 -1
  141. package/dist/lib/activity-timeline.d.ts +0 -43
  142. package/dist/lib/activity-timeline.d.ts.map +0 -1
  143. package/dist/lib/agent-replay-simulator.d.ts +0 -66
  144. package/dist/lib/agent-replay-simulator.d.ts.map +0 -1
  145. package/dist/lib/agent-run-dispatcher.d.ts +0 -62
  146. package/dist/lib/agent-run-dispatcher.d.ts.map +0 -1
  147. package/dist/lib/approval-gates.d.ts +0 -52
  148. package/dist/lib/approval-gates.d.ts.map +0 -1
  149. package/dist/lib/artifact-store.d.ts +0 -68
  150. package/dist/lib/artifact-store.d.ts.map +0 -1
  151. package/dist/lib/audit-ledger.d.ts +0 -59
  152. package/dist/lib/audit-ledger.d.ts.map +0 -1
  153. package/dist/lib/branch-work-plans.d.ts +0 -46
  154. package/dist/lib/branch-work-plans.d.ts.map +0 -1
  155. package/dist/lib/capacity-forecasts.d.ts +0 -70
  156. package/dist/lib/capacity-forecasts.d.ts.map +0 -1
  157. package/dist/lib/cli-help.d.ts +0 -38
  158. package/dist/lib/cli-help.d.ts.map +0 -1
  159. package/dist/lib/context-packs.d.ts +0 -163
  160. package/dist/lib/context-packs.d.ts.map +0 -1
  161. package/dist/lib/doctor.d.ts +0 -46
  162. package/dist/lib/doctor.d.ts.map +0 -1
  163. package/dist/lib/environment-snapshots.d.ts +0 -111
  164. package/dist/lib/environment-snapshots.d.ts.map +0 -1
  165. package/dist/lib/event-hooks.d.ts +0 -58
  166. package/dist/lib/event-hooks.d.ts.map +0 -1
  167. package/dist/lib/external-issue-importers.d.ts +0 -60
  168. package/dist/lib/external-issue-importers.d.ts.map +0 -1
  169. package/dist/lib/local-backups.d.ts +0 -129
  170. package/dist/lib/local-backups.d.ts.map +0 -1
  171. package/dist/lib/local-bridge.d.ts +0 -81
  172. package/dist/lib/local-bridge.d.ts.map +0 -1
  173. package/dist/lib/local-encryption.d.ts +0 -94
  174. package/dist/lib/local-encryption.d.ts.map +0 -1
  175. package/dist/lib/local-extensions.d.ts +0 -92
  176. package/dist/lib/local-extensions.d.ts.map +0 -1
  177. package/dist/lib/local-fields.d.ts +0 -33
  178. package/dist/lib/local-fields.d.ts.map +0 -1
  179. package/dist/lib/local-notifications.d.ts +0 -55
  180. package/dist/lib/local-notifications.d.ts.map +0 -1
  181. package/dist/lib/local-reports.d.ts +0 -149
  182. package/dist/lib/local-reports.d.ts.map +0 -1
  183. package/dist/lib/local-snapshots.d.ts +0 -66
  184. package/dist/lib/local-snapshots.d.ts.map +0 -1
  185. package/dist/lib/mention-resolver.d.ts +0 -43
  186. package/dist/lib/mention-resolver.d.ts.map +0 -1
  187. package/dist/lib/natural-language-intake.d.ts +0 -56
  188. package/dist/lib/natural-language-intake.d.ts.map +0 -1
  189. package/dist/lib/onboarding-fixtures.d.ts +0 -31
  190. package/dist/lib/onboarding-fixtures.d.ts.map +0 -1
  191. package/dist/lib/policy-packs.d.ts +0 -87
  192. package/dist/lib/policy-packs.d.ts.map +0 -1
  193. package/dist/lib/project-bootstrap.d.ts +0 -35
  194. package/dist/lib/project-bootstrap.d.ts.map +0 -1
  195. package/dist/lib/public-release-gate.d.ts +0 -57
  196. package/dist/lib/public-release-gate.d.ts.map +0 -1
  197. package/dist/lib/redaction.d.ts +0 -12
  198. package/dist/lib/redaction.d.ts.map +0 -1
  199. package/dist/lib/release-compatibility.d.ts +0 -59
  200. package/dist/lib/release-compatibility.d.ts.map +0 -1
  201. package/dist/lib/release-notes.d.ts +0 -81
  202. package/dist/lib/release-notes.d.ts.map +0 -1
  203. package/dist/lib/retention-cleanup.d.ts +0 -63
  204. package/dist/lib/retention-cleanup.d.ts.map +0 -1
  205. package/dist/lib/review-queues.d.ts +0 -98
  206. package/dist/lib/review-queues.d.ts.map +0 -1
  207. package/dist/lib/roadmaps.d.ts +0 -133
  208. package/dist/lib/roadmaps.d.ts.map +0 -1
  209. package/dist/lib/runner-sandbox.d.ts +0 -50
  210. package/dist/lib/runner-sandbox.d.ts.map +0 -1
  211. package/dist/lib/saved-search-views.d.ts +0 -60
  212. package/dist/lib/saved-search-views.d.ts.map +0 -1
  213. package/dist/lib/scale-hardening.d.ts +0 -74
  214. package/dist/lib/scale-hardening.d.ts.map +0 -1
  215. package/dist/lib/sdk-integration-fixtures.d.ts +0 -65
  216. package/dist/lib/sdk-integration-fixtures.d.ts.map +0 -1
  217. package/dist/lib/task-contracts.d.ts +0 -75
  218. package/dist/lib/task-contracts.d.ts.map +0 -1
  219. package/dist/lib/task-dedupe.d.ts +0 -45
  220. package/dist/lib/task-dedupe.d.ts.map +0 -1
  221. package/dist/lib/terminal-notifications.d.ts +0 -53
  222. package/dist/lib/terminal-notifications.d.ts.map +0 -1
  223. package/dist/lib/todos-md.d.ts +0 -21
  224. package/dist/lib/todos-md.d.ts.map +0 -1
  225. package/dist/lib/tui-dashboard.d.ts +0 -49
  226. package/dist/lib/tui-dashboard.d.ts.map +0 -1
  227. package/dist/lib/usage-ledger.d.ts +0 -82
  228. package/dist/lib/usage-ledger.d.ts.map +0 -1
  229. package/dist/lib/verification-providers.d.ts +0 -54
  230. package/dist/lib/verification-providers.d.ts.map +0 -1
  231. package/dist/lib/workflow-prompts.d.ts +0 -38
  232. package/dist/lib/workflow-prompts.d.ts.map +0 -1
  233. package/dist/lib/workflow-states.d.ts +0 -70
  234. package/dist/lib/workflow-states.d.ts.map +0 -1
  235. package/dist/lib/workspace-trust.d.ts +0 -38
  236. package/dist/lib/workspace-trust.d.ts.map +0 -1
  237. package/dist/mcp/tools/environment-snapshots.d.ts +0 -8
  238. package/dist/mcp/tools/environment-snapshots.d.ts.map +0 -1
  239. package/dist/mcp/tools/workflow-prompts.d.ts +0 -3
  240. package/dist/mcp/tools/workflow-prompts.d.ts.map +0 -1
  241. package/dist/mcp.d.ts +0 -42
  242. package/dist/mcp.d.ts.map +0 -1
  243. package/dist/mcp.js +0 -554
  244. package/dist/registry.d.ts +0 -35
  245. package/dist/registry.d.ts.map +0 -1
  246. package/dist/registry.js +0 -18345
  247. package/dist/sdk/index.js +0 -635
  248. package/dist/storage/index.d.ts +0 -4
  249. package/dist/storage/index.d.ts.map +0 -1
  250. package/dist/storage/interfaces.d.ts +0 -185
  251. package/dist/storage/interfaces.d.ts.map +0 -1
  252. package/dist/storage/local-sqlite.d.ts +0 -7
  253. package/dist/storage/local-sqlite.d.ts.map +0 -1
  254. package/dist/storage.d.ts +0 -4
  255. package/dist/storage.d.ts.map +0 -1
  256. package/dist/storage.js +0 -8380
  257. package/dist/test/no-network.d.ts +0 -7
  258. package/dist/test/no-network.d.ts.map +0 -1
package/dist/sdk/index.js DELETED
@@ -1,635 +0,0 @@
1
- // @bun
2
- // src/sdk/types.ts
3
- class TodosAPIError extends Error {
4
- status;
5
- statusText;
6
- body;
7
- constructor(message, status, statusText, body) {
8
- super(message);
9
- this.status = status;
10
- this.statusText = statusText;
11
- this.body = body;
12
- this.name = "TodosAPIError";
13
- }
14
- }
15
-
16
- class TodosNotFoundError extends TodosAPIError {
17
- constructor(message, body) {
18
- super(message, 404, "Not Found", body);
19
- this.name = "TodosNotFoundError";
20
- }
21
- }
22
-
23
- class TodosConflictError extends TodosAPIError {
24
- constructor(message, body) {
25
- super(message, 409, "Conflict", body);
26
- this.name = "TodosConflictError";
27
- }
28
- }
29
-
30
- class TodosUnauthorizedError extends TodosAPIError {
31
- constructor(message, body) {
32
- super(message, 401, "Unauthorized", body);
33
- this.name = "TodosUnauthorizedError";
34
- }
35
- }
36
-
37
- class TodosRateLimitError extends TodosAPIError {
38
- retryAfter;
39
- constructor(message, retryAfter, body) {
40
- super(message, 429, "Too Many Requests", body);
41
- this.retryAfter = retryAfter;
42
- this.name = "TodosRateLimitError";
43
- }
44
- }
45
-
46
- class TodosTimeoutError extends Error {
47
- ms;
48
- constructor(ms) {
49
- super(`Request timed out after ${ms}ms`);
50
- this.ms = ms;
51
- this.name = "TodosTimeoutError";
52
- }
53
- }
54
-
55
- // src/lib/config.ts
56
- import { existsSync as existsSync2 } from "fs";
57
- import { dirname, join } from "path";
58
-
59
- // src/lib/sync-utils.ts
60
- import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "fs";
61
- var HOME = process.env["HOME"] || process.env["USERPROFILE"] || "~";
62
- function readJsonFile(path) {
63
- try {
64
- return JSON.parse(readFileSync(path, "utf-8"));
65
- } catch {
66
- return null;
67
- }
68
- }
69
-
70
- // src/lib/config.ts
71
- function getTodosGlobalDir() {
72
- const home = process.env["HOME"] || HOME;
73
- const newDir = join(home, ".hasna", "todos");
74
- const legacyDir = join(home, ".todos");
75
- const newConfig = join(newDir, "config.json");
76
- const legacyConfig = join(legacyDir, "config.json");
77
- if (!existsSync2(newConfig) && existsSync2(legacyConfig))
78
- return legacyDir;
79
- return newDir;
80
- }
81
- function getConfigPath() {
82
- return join(getTodosGlobalDir(), "config.json");
83
- }
84
- var cached = null;
85
- function loadConfig() {
86
- if (cached)
87
- return cached;
88
- if (!existsSync2(getConfigPath())) {
89
- cached = {};
90
- return cached;
91
- }
92
- const config = readJsonFile(getConfigPath()) || {};
93
- if (typeof config.sync_agents === "string") {
94
- config.sync_agents = config.sync_agents.split(",").map((a) => a.trim()).filter(Boolean);
95
- }
96
- cached = config;
97
- return cached;
98
- }
99
- function normalizeApiUrl(value) {
100
- const trimmed = value?.trim();
101
- if (!trimmed)
102
- return null;
103
- return trimmed.replace(/\/+$/, "");
104
- }
105
- function getLocalApiConfig(env = process.env) {
106
- const config = loadConfig();
107
- const envApiUrl = normalizeApiUrl(env["TODOS_URL"]);
108
- const configApiUrl = normalizeApiUrl(config.apiUrl);
109
- const apiUrl = envApiUrl ?? configApiUrl;
110
- const apiKey = env["TODOS_API_KEY"] || config.apiKey || null;
111
- return {
112
- apiUrl,
113
- apiKey,
114
- source: {
115
- apiUrl: envApiUrl ? "TODOS_URL" : configApiUrl ? "config" : "none",
116
- apiKey: env["TODOS_API_KEY"] ? "TODOS_API_KEY" : config.apiKey ? "config" : "none"
117
- }
118
- };
119
- }
120
-
121
- // src/sdk/client.ts
122
- function buildQuery(params) {
123
- const search = new URLSearchParams;
124
- for (const [k, v] of Object.entries(params)) {
125
- if (v !== undefined)
126
- search.set(k, Array.isArray(v) ? v.join(",") : String(v));
127
- }
128
- const s = search.toString();
129
- return s ? `?${s}` : "";
130
- }
131
-
132
- class TasksResource {
133
- client;
134
- constructor(client) {
135
- this.client = client;
136
- }
137
- async list(options) {
138
- return this.client._get("/api/tasks", buildQuery(options || {}));
139
- }
140
- async get(id, options) {
141
- return this.client._get(`/api/tasks/${id}`, buildQuery(options || {}));
142
- }
143
- async getWithRelations(id) {
144
- return this.client._get(`/api/tasks/${id}`, buildQuery({ format: "full" }));
145
- }
146
- async create(data) {
147
- return this.client._post("/api/tasks", data);
148
- }
149
- async update(id, data) {
150
- return this.client._patch(`/api/tasks/${id}`, data);
151
- }
152
- async delete(id) {
153
- return this.client._delete(`/api/tasks/${id}`);
154
- }
155
- async start(id, agentId) {
156
- return this.client._post(`/api/tasks/${id}/start`, { agent_id: agentId });
157
- }
158
- async complete(id, agentId) {
159
- return this.client._post(`/api/tasks/${id}/complete`, { agent_id: agentId });
160
- }
161
- async fail(id, options) {
162
- return this.client._post(`/api/tasks/${id}/fail`, options || {});
163
- }
164
- async logProgress(taskId, message, pctComplete, agentId) {
165
- return this.client._post(`/api/tasks/${taskId}/progress`, {
166
- message,
167
- pct_complete: pctComplete,
168
- agent_id: agentId
169
- });
170
- }
171
- async getProgress(id, options) {
172
- return this.client._get(`/api/tasks/${id}/progress`, buildQuery(options || {}));
173
- }
174
- async getHistory(id, options) {
175
- return this.client._get(`/api/tasks/${id}/history`, buildQuery(options || {}));
176
- }
177
- async getAttachments(id) {
178
- return this.client._get(`/api/tasks/${id}/attachments`);
179
- }
180
- async status(options) {
181
- return this.client._get("/api/tasks/status", buildQuery(options || {}));
182
- }
183
- async next(options) {
184
- return this.client._get("/api/tasks/next", buildQuery(options || {}));
185
- }
186
- async active(projectId) {
187
- return this.client._get("/api/tasks/active", projectId ? `?project_id=${projectId}` : "");
188
- }
189
- async stale(options) {
190
- return this.client._get("/api/tasks/stale", buildQuery(options || {}));
191
- }
192
- async changedSince(since, projectId, options) {
193
- return this.client._get("/api/tasks/changed", buildQuery({ since, project_id: projectId, fields: options?.fields }));
194
- }
195
- async context(options) {
196
- const q = buildQuery({
197
- agent_id: options?.agentId,
198
- project_id: options?.projectId,
199
- format: options?.format,
200
- fields: options?.fields
201
- });
202
- const url = `${this.client.baseUrl}/api/tasks/context${q}`;
203
- const res = await this.client._fetchRaw(url);
204
- if (!res.ok)
205
- return options?.format === "json" ? {} : "";
206
- if (options?.format === "json")
207
- return res.json();
208
- return res.text();
209
- }
210
- async export(options) {
211
- const q = buildQuery(options || {});
212
- const url = `${this.client.baseUrl}/api/tasks/export${q}`;
213
- const res = await this.client._fetchRaw(url);
214
- if (!res.ok)
215
- throw new TodosAPIError("Export failed", res.status, res.statusText, null);
216
- if (options?.format === "csv")
217
- return res.text();
218
- return res.json();
219
- }
220
- async bulk(ids, action) {
221
- return this.client._post("/api/tasks/bulk", { ids, action });
222
- }
223
- async claim(agentId, projectId) {
224
- return this.client._post("/api/tasks/claim", { agent_id: agentId, project_id: projectId });
225
- }
226
- async* subscribe(options = {}) {
227
- const q = buildQuery({
228
- agent_id: options.agentId,
229
- project_id: options.projectId,
230
- events: options.events?.join(",")
231
- });
232
- const url = `${this.client.baseUrl}/api/tasks/stream${q}`;
233
- const resp = await fetch(url);
234
- if (!resp.ok || !resp.body)
235
- throw new Error(`SSE connection failed: ${resp.status}`);
236
- const reader = resp.body.getReader();
237
- const decoder = new TextDecoder;
238
- let buffer = "";
239
- try {
240
- while (true) {
241
- const { done, value } = await reader.read();
242
- if (done)
243
- break;
244
- buffer += decoder.decode(value, { stream: true });
245
- const lines = buffer.split(`
246
- `);
247
- buffer = lines.pop() || "";
248
- for (const line of lines) {
249
- if (line.startsWith("data: ")) {
250
- try {
251
- const data = JSON.parse(line.slice(6));
252
- if (data.type !== "connected")
253
- yield data;
254
- } catch {}
255
- }
256
- }
257
- }
258
- } finally {
259
- reader.releaseLock();
260
- }
261
- }
262
- }
263
-
264
- class AgentsResource {
265
- client;
266
- constructor(client) {
267
- this.client = client;
268
- }
269
- async list(options) {
270
- return this.client._get("/api/agents", buildQuery(options || {}));
271
- }
272
- async register(data) {
273
- return this.client._post("/api/agents", data);
274
- }
275
- async fullRegister(data) {
276
- return this.client._post("/api/agents", data);
277
- }
278
- async update(id, data) {
279
- return this.client._patch(`/api/agents/${id}`, data);
280
- }
281
- async delete(id) {
282
- return this.client._delete(`/api/agents/${id}`);
283
- }
284
- async bulkDelete(ids) {
285
- return this.client._post("/api/agents/bulk", { ids, action: "delete" });
286
- }
287
- async me(name) {
288
- return this.client._get("/api/agents/me", `?name=${encodeURIComponent(name)}`);
289
- }
290
- async queue(agentId) {
291
- return this.client._get(`/api/agents/${encodeURIComponent(agentId)}/queue`);
292
- }
293
- async team(agentId) {
294
- return this.client._get(`/api/agents/${encodeURIComponent(agentId)}/team`);
295
- }
296
- async orgChart() {
297
- return this.client._get("/api/org");
298
- }
299
- }
300
-
301
- class ProjectsResource {
302
- client;
303
- constructor(client) {
304
- this.client = client;
305
- }
306
- async list(options) {
307
- return this.client._get("/api/projects", buildQuery(options || {}));
308
- }
309
- async create(data) {
310
- return this.client._post("/api/projects", data);
311
- }
312
- async delete(id) {
313
- return this.client._delete(`/api/projects/${id}`);
314
- }
315
- async bulkDelete(ids) {
316
- return this.client._post("/api/projects/bulk", { ids, action: "delete" });
317
- }
318
- }
319
-
320
- class PlansResource {
321
- client;
322
- constructor(client) {
323
- this.client = client;
324
- }
325
- async list(projectId) {
326
- return this.client._get("/api/plans", projectId ? `?project_id=${projectId}` : "");
327
- }
328
- async create(data) {
329
- return this.client._post("/api/plans", data);
330
- }
331
- async get(id) {
332
- return this.client._get(`/api/plans/${id}`);
333
- }
334
- async update(id, data) {
335
- return this.client._patch(`/api/plans/${id}`, data);
336
- }
337
- async delete(id) {
338
- return this.client._delete(`/api/plans/${id}`);
339
- }
340
- async bulkDelete(ids) {
341
- return this.client._post("/api/plans/bulk", { ids, action: "delete" });
342
- }
343
- }
344
-
345
- class OrgsResource {
346
- client;
347
- constructor(client) {
348
- this.client = client;
349
- }
350
- async list() {
351
- return this.client._get("/api/orgs");
352
- }
353
- async create(data) {
354
- return this.client._post("/api/orgs", data);
355
- }
356
- async update(id, data) {
357
- return this.client._patch(`/api/orgs/${id}`, data);
358
- }
359
- async delete(id) {
360
- return this.client._delete(`/api/orgs/${id}`);
361
- }
362
- }
363
-
364
- class WebhooksResource {
365
- client;
366
- constructor(client) {
367
- this.client = client;
368
- }
369
- async list() {
370
- return this.client._get("/api/webhooks");
371
- }
372
- async create(data) {
373
- return this.client._post("/api/webhooks", data);
374
- }
375
- async delete(id) {
376
- return this.client._delete(`/api/webhooks/${id}`);
377
- }
378
- }
379
-
380
- class TemplatesResource {
381
- client;
382
- constructor(client) {
383
- this.client = client;
384
- }
385
- async list() {
386
- return this.client._get("/api/templates");
387
- }
388
- async create(data) {
389
- return this.client._post("/api/templates", data);
390
- }
391
- async delete(id) {
392
- return this.client._delete(`/api/templates/${id}`);
393
- }
394
- }
395
-
396
- class TodosClient {
397
- baseUrl;
398
- timeout;
399
- apiKey;
400
- maxRetries;
401
- retryDelay;
402
- tasks;
403
- agents;
404
- projects;
405
- plans;
406
- orgs;
407
- webhooks;
408
- templates;
409
- constructor(options = {}) {
410
- const localConfig = getLocalApiConfig();
411
- this.baseUrl = normalizeApiUrl(options.baseUrl) || localConfig.apiUrl || "http://localhost:19427";
412
- this.timeout = options.timeout ?? 1e4;
413
- this.apiKey = options.apiKey || localConfig.apiKey;
414
- this.maxRetries = options.maxRetries ?? 0;
415
- this.retryDelay = options.retryDelay ?? 1000;
416
- this.tasks = new TasksResource(this);
417
- this.agents = new AgentsResource(this);
418
- this.projects = new ProjectsResource(this);
419
- this.plans = new PlansResource(this);
420
- this.orgs = new OrgsResource(this);
421
- this.webhooks = new WebhooksResource(this);
422
- this.templates = new TemplatesResource(this);
423
- }
424
- static fromEnv(apiKey) {
425
- return new TodosClient({ apiKey });
426
- }
427
- async _fetchRaw(url, init) {
428
- const controller = new AbortController;
429
- const timer = setTimeout(() => controller.abort(), this.timeout);
430
- try {
431
- const headers = this._buildHeaders(init?.headers);
432
- return await fetch(url, { ...init, headers, signal: controller.signal });
433
- } finally {
434
- clearTimeout(timer);
435
- }
436
- }
437
- _buildHeaders(existing) {
438
- const headers = { "Content-Type": "application/json" };
439
- if (this.apiKey)
440
- headers["x-api-key"] = this.apiKey;
441
- if (existing) {
442
- if (existing instanceof Headers) {
443
- existing.forEach((v, k) => {
444
- headers[k] = v;
445
- });
446
- } else if (Array.isArray(existing)) {
447
- for (const [k, v] of existing)
448
- headers[k] = v;
449
- } else {
450
- Object.assign(headers, existing);
451
- }
452
- }
453
- return headers;
454
- }
455
- async _fetchWithRetry(path, init) {
456
- let lastError = null;
457
- const maxAttempts = this.maxRetries + 1;
458
- for (let attempt = 0;attempt < maxAttempts; attempt++) {
459
- try {
460
- return await this._fetch(path, init);
461
- } catch (e) {
462
- lastError = e;
463
- if (e instanceof TodosAPIError && e.status < 500 && e.status !== 429)
464
- throw e;
465
- if (e instanceof TodosUnauthorizedError || e instanceof TodosNotFoundError || e instanceof TodosConflictError)
466
- throw e;
467
- if (attempt < maxAttempts - 1) {
468
- const delay = this.retryDelay * Math.pow(2, attempt);
469
- if (e instanceof TodosRateLimitError) {
470
- await this._sleep(e.retryAfter * 1000);
471
- } else {
472
- await this._sleep(delay);
473
- }
474
- }
475
- }
476
- }
477
- throw lastError || new Error("Request failed after retries");
478
- }
479
- async _fetch(path, init) {
480
- const controller = new AbortController;
481
- const timer = setTimeout(() => controller.abort(), this.timeout);
482
- try {
483
- const url = `${this.baseUrl}${path}`;
484
- const headers = this._buildHeaders(init?.headers);
485
- const res = await fetch(url, { ...init, headers, signal: controller.signal });
486
- if (!res.ok) {
487
- const body = await res.json().catch(() => ({ error: res.statusText }));
488
- const message = body.error || `HTTP ${res.status}: ${res.statusText}`;
489
- if (res.status === 401)
490
- throw new TodosUnauthorizedError(message, body);
491
- if (res.status === 404)
492
- throw new TodosNotFoundError(message, body);
493
- if (res.status === 409)
494
- throw new TodosConflictError(message, body);
495
- if (res.status === 429) {
496
- const retryAfter = parseInt(res.headers.get("retry-after") || "60", 10);
497
- throw new TodosRateLimitError(message, retryAfter, body);
498
- }
499
- throw new TodosAPIError(message, res.status, res.statusText, body);
500
- }
501
- const contentLength = res.headers.get("content-length");
502
- if (contentLength === "0" || contentLength === "4")
503
- return null;
504
- return res.json();
505
- } catch (e) {
506
- if (e instanceof DOMException && e.name === "AbortError") {
507
- throw new TodosTimeoutError(this.timeout);
508
- }
509
- throw e;
510
- } finally {
511
- clearTimeout(timer);
512
- }
513
- }
514
- async _get(path, query = "") {
515
- return this._fetchWithRetry(`${path}${query}`);
516
- }
517
- async _post(path, body) {
518
- return this._fetchWithRetry(path, {
519
- method: "POST",
520
- body: body ? JSON.stringify(body) : undefined
521
- });
522
- }
523
- async _patch(path, body) {
524
- return this._fetchWithRetry(path, {
525
- method: "PATCH",
526
- body: JSON.stringify(body)
527
- });
528
- }
529
- async _delete(path) {
530
- return this._fetchWithRetry(path, { method: "DELETE" });
531
- }
532
- _sleep(ms) {
533
- return new Promise((resolve) => setTimeout(resolve, ms));
534
- }
535
- async getHealth() {
536
- return this._get("/api/health");
537
- }
538
- async isAlive() {
539
- try {
540
- await this._get("/api/stats");
541
- return true;
542
- } catch {
543
- return false;
544
- }
545
- }
546
- async getStats() {
547
- return this._get("/api/stats");
548
- }
549
- async getReport(options) {
550
- return this._get("/api/report", buildQuery({ days: options?.days, project_id: options?.projectId }));
551
- }
552
- async doctor() {
553
- return this._get("/api/doctor");
554
- }
555
- async activity(limit) {
556
- return this._get("/api/activity", limit ? `?limit=${limit}` : "");
557
- }
558
- async listTasks(filter = {}) {
559
- return this.tasks.list(filter);
560
- }
561
- async getTask(id, options) {
562
- return this.tasks.get(id, options);
563
- }
564
- async createTask(data) {
565
- return this.tasks.create(data);
566
- }
567
- async updateTask(id, data) {
568
- return this.tasks.update(id, data);
569
- }
570
- async deleteTask(id) {
571
- await this.tasks.delete(id);
572
- }
573
- async startTask(id, agentId) {
574
- return this.tasks.start(id, agentId);
575
- }
576
- async completeTask(id, agentId) {
577
- return this.tasks.complete(id, agentId);
578
- }
579
- async failTask(id, options = {}) {
580
- return this.tasks.fail(id, options);
581
- }
582
- async logProgress(taskId, message, pctComplete, agentId) {
583
- return this.tasks.logProgress(taskId, message, pctComplete, agentId);
584
- }
585
- async getStatus(projectId, agentId) {
586
- return this.tasks.status({ project_id: projectId, agent_id: agentId });
587
- }
588
- async getActiveWork(projectId) {
589
- const res = await this.tasks.active(projectId);
590
- return res.active;
591
- }
592
- async getTasksChangedSince(since, projectId) {
593
- return this.tasks.changedSince(since, projectId);
594
- }
595
- async getStaleTasks(minutes, projectId) {
596
- return this.tasks.stale({ minutes, project_id: projectId });
597
- }
598
- async getContext(options = {}) {
599
- return this.tasks.context(options);
600
- }
601
- async exportTasks(filter = {}) {
602
- return this.tasks.export(filter);
603
- }
604
- async claimNextTask(agentId, projectId) {
605
- return this.tasks.claim(agentId, projectId);
606
- }
607
- async getTaskHistory(id, options) {
608
- return this.tasks.getHistory(id, options);
609
- }
610
- async getTaskAttachments(id) {
611
- return this.tasks.getAttachments(id);
612
- }
613
- async getTaskProgress(id, options) {
614
- return this.tasks.getProgress(id, options);
615
- }
616
- async* subscribeToStream(options = {}) {
617
- yield* this.tasks.subscribe(options);
618
- }
619
- async getProjects() {
620
- return this.projects.list();
621
- }
622
- }
623
- function createClient(options) {
624
- return new TodosClient(options);
625
- }
626
- export {
627
- createClient,
628
- TodosUnauthorizedError,
629
- TodosTimeoutError,
630
- TodosRateLimitError,
631
- TodosNotFoundError,
632
- TodosConflictError,
633
- TodosClient,
634
- TodosAPIError
635
- };
@@ -1,4 +0,0 @@
1
- export type { MaybePromise, ActiveWorkItem, TodosActiveWorkFilter, TodosAgentUpdateInput, TodosAgentStore, TodosAuditStore, TodosPlanStore, TodosProjectStore, TodosStorageAdapter, TodosStorageCapabilities, TodosStorageContext, TodosStorageImportResult, TodosStorageKind, TodosStorageSnapshot, TodosSyncStore, TodosTaskClaimFilter, TodosTaskCompletionOptions, TodosTaskFailureOptions, TodosTaskFailureResult, TodosTaskListStore, TodosTaskStore, TodosTemplateStore, UpdateTemplateInput, } from "./interfaces.js";
2
- export { createLocalSqliteTodosStorageAdapter } from "./local-sqlite.js";
3
- export type { CreateLocalSqliteTodosStorageAdapterOptions } from "./local-sqlite.js";
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,YAAY,EACZ,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,wBAAwB,EACxB,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,EACvB,sBAAsB,EACtB,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,oCAAoC,EAAE,MAAM,mBAAmB,CAAC;AACzE,YAAY,EAAE,2CAA2C,EAAE,MAAM,mBAAmB,CAAC"}