@a5c-ai/tasks-adapter 5.1.1-staging.0007199a1cb2

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 (202) hide show
  1. package/README.md +125 -0
  2. package/dist/auth/forge-interface.d.ts +67 -0
  3. package/dist/auth/forge-interface.d.ts.map +1 -0
  4. package/dist/auth/forge-interface.js +69 -0
  5. package/dist/auth/github-app.d.ts +64 -0
  6. package/dist/auth/github-app.d.ts.map +1 -0
  7. package/dist/auth/github-app.js +141 -0
  8. package/dist/auth/github-oauth.d.ts +27 -0
  9. package/dist/auth/github-oauth.d.ts.map +1 -0
  10. package/dist/auth/github-oauth.js +89 -0
  11. package/dist/auth/index.d.ts +8 -0
  12. package/dist/auth/index.d.ts.map +1 -0
  13. package/dist/auth/index.js +14 -0
  14. package/dist/auth/jwt.d.ts +24 -0
  15. package/dist/auth/jwt.d.ts.map +1 -0
  16. package/dist/auth/jwt.js +43 -0
  17. package/dist/auth/middleware.d.ts +22 -0
  18. package/dist/auth/middleware.d.ts.map +1 -0
  19. package/dist/auth/middleware.js +36 -0
  20. package/dist/auth/ssh-keys.d.ts +21 -0
  21. package/dist/auth/ssh-keys.d.ts.map +1 -0
  22. package/dist/auth/ssh-keys.js +59 -0
  23. package/dist/auth/types.d.ts +165 -0
  24. package/dist/auth/types.d.ts.map +1 -0
  25. package/dist/auth/types.js +53 -0
  26. package/dist/backend.d.ts +248 -0
  27. package/dist/backend.d.ts.map +1 -0
  28. package/dist/backend.js +40 -0
  29. package/dist/backends/adapters.d.ts +99 -0
  30. package/dist/backends/adapters.d.ts.map +1 -0
  31. package/dist/backends/adapters.js +308 -0
  32. package/dist/backends/external-tracker.d.ts +133 -0
  33. package/dist/backends/external-tracker.d.ts.map +1 -0
  34. package/dist/backends/external-tracker.js +731 -0
  35. package/dist/backends/git-native.d.ts +69 -0
  36. package/dist/backends/git-native.d.ts.map +1 -0
  37. package/dist/backends/git-native.js +797 -0
  38. package/dist/backends/github-issues.d.ts +78 -0
  39. package/dist/backends/github-issues.d.ts.map +1 -0
  40. package/dist/backends/github-issues.js +806 -0
  41. package/dist/backends/index.d.ts +52 -0
  42. package/dist/backends/index.d.ts.map +1 -0
  43. package/dist/backends/index.js +151 -0
  44. package/dist/backends/server.d.ts +42 -0
  45. package/dist/backends/server.d.ts.map +1 -0
  46. package/dist/backends/server.js +305 -0
  47. package/dist/cli/auth-store.d.ts +49 -0
  48. package/dist/cli/auth-store.d.ts.map +1 -0
  49. package/dist/cli/auth-store.js +150 -0
  50. package/dist/cli/client-config.d.ts +10 -0
  51. package/dist/cli/client-config.d.ts.map +1 -0
  52. package/dist/cli/client-config.js +87 -0
  53. package/dist/cli/commands/ask.d.ts +3 -0
  54. package/dist/cli/commands/ask.d.ts.map +1 -0
  55. package/dist/cli/commands/ask.js +171 -0
  56. package/dist/cli/commands/auth.d.ts +3 -0
  57. package/dist/cli/commands/auth.d.ts.map +1 -0
  58. package/dist/cli/commands/auth.js +510 -0
  59. package/dist/cli/commands/breakpoints.d.ts +3 -0
  60. package/dist/cli/commands/breakpoints.d.ts.map +1 -0
  61. package/dist/cli/commands/breakpoints.js +311 -0
  62. package/dist/cli/commands/responder-loop.d.ts +3 -0
  63. package/dist/cli/commands/responder-loop.d.ts.map +1 -0
  64. package/dist/cli/commands/responder-loop.js +78 -0
  65. package/dist/cli/commands/responders.d.ts +3 -0
  66. package/dist/cli/commands/responders.d.ts.map +1 -0
  67. package/dist/cli/commands/responders.js +157 -0
  68. package/dist/cli/commands/rules.d.ts +3 -0
  69. package/dist/cli/commands/rules.d.ts.map +1 -0
  70. package/dist/cli/commands/rules.js +105 -0
  71. package/dist/cli/commands/server.d.ts +3 -0
  72. package/dist/cli/commands/server.d.ts.map +1 -0
  73. package/dist/cli/commands/server.js +34 -0
  74. package/dist/cli/commands/tasks.d.ts +3 -0
  75. package/dist/cli/commands/tasks.d.ts.map +1 -0
  76. package/dist/cli/commands/tasks.js +281 -0
  77. package/dist/cli/commands/templates.d.ts +3 -0
  78. package/dist/cli/commands/templates.d.ts.map +1 -0
  79. package/dist/cli/commands/templates.js +100 -0
  80. package/dist/cli/index.d.ts +4 -0
  81. package/dist/cli/index.d.ts.map +1 -0
  82. package/dist/cli/index.js +9 -0
  83. package/dist/cli/output.d.ts +26 -0
  84. package/dist/cli/output.d.ts.map +1 -0
  85. package/dist/cli/output.js +143 -0
  86. package/dist/cli/program.d.ts +6 -0
  87. package/dist/cli/program.d.ts.map +1 -0
  88. package/dist/cli/program.js +38 -0
  89. package/dist/cli/tasks-adapter.d.ts +3 -0
  90. package/dist/cli/tasks-adapter.d.ts.map +1 -0
  91. package/dist/cli/tasks-adapter.js +4 -0
  92. package/dist/client/answer-poller.d.ts +52 -0
  93. package/dist/client/answer-poller.d.ts.map +1 -0
  94. package/dist/client/answer-poller.js +200 -0
  95. package/dist/client/auth-client.d.ts +200 -0
  96. package/dist/client/auth-client.d.ts.map +1 -0
  97. package/dist/client/auth-client.js +309 -0
  98. package/dist/client/breakpoint-router.d.ts +45 -0
  99. package/dist/client/breakpoint-router.d.ts.map +1 -0
  100. package/dist/client/breakpoint-router.js +45 -0
  101. package/dist/client/index.d.ts +17 -0
  102. package/dist/client/index.d.ts.map +1 -0
  103. package/dist/client/index.js +16 -0
  104. package/dist/client/profile-validator.d.ts +34 -0
  105. package/dist/client/profile-validator.d.ts.map +1 -0
  106. package/dist/client/profile-validator.js +89 -0
  107. package/dist/client/responder-client.d.ts +39 -0
  108. package/dist/client/responder-client.d.ts.map +1 -0
  109. package/dist/client/responder-client.js +72 -0
  110. package/dist/client/responder-matcher.d.ts +49 -0
  111. package/dist/client/responder-matcher.d.ts.map +1 -0
  112. package/dist/client/responder-matcher.js +226 -0
  113. package/dist/client/server-client.d.ts +124 -0
  114. package/dist/client/server-client.d.ts.map +1 -0
  115. package/dist/client/server-client.js +266 -0
  116. package/dist/client/timeout-manager.d.ts +47 -0
  117. package/dist/client/timeout-manager.d.ts.map +1 -0
  118. package/dist/client/timeout-manager.js +77 -0
  119. package/dist/config.d.ts +20 -0
  120. package/dist/config.d.ts.map +1 -0
  121. package/dist/config.js +93 -0
  122. package/dist/harness/index.d.ts +4 -0
  123. package/dist/harness/index.d.ts.map +1 -0
  124. package/dist/harness/index.js +2 -0
  125. package/dist/harness/interaction-provider.d.ts +71 -0
  126. package/dist/harness/interaction-provider.d.ts.map +1 -0
  127. package/dist/harness/interaction-provider.js +124 -0
  128. package/dist/harness/routing-rules.d.ts +7 -0
  129. package/dist/harness/routing-rules.d.ts.map +1 -0
  130. package/dist/harness/routing-rules.js +37 -0
  131. package/dist/index.d.ts +29 -0
  132. package/dist/index.d.ts.map +1 -0
  133. package/dist/index.js +33 -0
  134. package/dist/mcp/backend-resolver.d.ts +43 -0
  135. package/dist/mcp/backend-resolver.d.ts.map +1 -0
  136. package/dist/mcp/backend-resolver.js +111 -0
  137. package/dist/mcp/http-transport.d.ts +37 -0
  138. package/dist/mcp/http-transport.d.ts.map +1 -0
  139. package/dist/mcp/http-transport.js +103 -0
  140. package/dist/mcp/index.d.ts +16 -0
  141. package/dist/mcp/index.d.ts.map +1 -0
  142. package/dist/mcp/index.js +12 -0
  143. package/dist/mcp/server.d.ts +20 -0
  144. package/dist/mcp/server.d.ts.map +1 -0
  145. package/dist/mcp/server.js +259 -0
  146. package/dist/mcp/tools/answer-breakpoint.d.ts +32 -0
  147. package/dist/mcp/tools/answer-breakpoint.d.ts.map +1 -0
  148. package/dist/mcp/tools/answer-breakpoint.js +45 -0
  149. package/dist/mcp/tools/ask-breakpoint.d.ts +58 -0
  150. package/dist/mcp/tools/ask-breakpoint.d.ts.map +1 -0
  151. package/dist/mcp/tools/ask-breakpoint.js +78 -0
  152. package/dist/mcp/tools/check-status.d.ts +16 -0
  153. package/dist/mcp/tools/check-status.d.ts.map +1 -0
  154. package/dist/mcp/tools/check-status.js +18 -0
  155. package/dist/mcp/tools/claim-breakpoint.d.ts +18 -0
  156. package/dist/mcp/tools/claim-breakpoint.d.ts.map +1 -0
  157. package/dist/mcp/tools/claim-breakpoint.js +28 -0
  158. package/dist/mcp/tools/list-breakpoints.d.ts +16 -0
  159. package/dist/mcp/tools/list-breakpoints.d.ts.map +1 -0
  160. package/dist/mcp/tools/list-breakpoints.js +14 -0
  161. package/dist/mcp/tools/list-responders.d.ts +18 -0
  162. package/dist/mcp/tools/list-responders.d.ts.map +1 -0
  163. package/dist/mcp/tools/list-responders.js +37 -0
  164. package/dist/mcp/tools/native-tasks.d.ts +270 -0
  165. package/dist/mcp/tools/native-tasks.d.ts.map +1 -0
  166. package/dist/mcp/tools/native-tasks.js +481 -0
  167. package/dist/mcp/tools/poll-breakpoints.d.ts +18 -0
  168. package/dist/mcp/tools/poll-breakpoints.d.ts.map +1 -0
  169. package/dist/mcp/tools/poll-breakpoints.js +36 -0
  170. package/dist/mcp/tools/verify-answer.d.ts +16 -0
  171. package/dist/mcp/tools/verify-answer.d.ts.map +1 -0
  172. package/dist/mcp/tools/verify-answer.js +38 -0
  173. package/dist/proven/index.d.ts +5 -0
  174. package/dist/proven/index.d.ts.map +1 -0
  175. package/dist/proven/index.js +3 -0
  176. package/dist/proven/keys.d.ts +33 -0
  177. package/dist/proven/keys.d.ts.map +1 -0
  178. package/dist/proven/keys.js +117 -0
  179. package/dist/proven/sign.d.ts +16 -0
  180. package/dist/proven/sign.d.ts.map +1 -0
  181. package/dist/proven/sign.js +60 -0
  182. package/dist/proven/types.d.ts +26 -0
  183. package/dist/proven/types.d.ts.map +1 -0
  184. package/dist/proven/types.js +5 -0
  185. package/dist/proven/verify.d.ts +6 -0
  186. package/dist/proven/verify.d.ts.map +1 -0
  187. package/dist/proven/verify.js +58 -0
  188. package/dist/responders/types.d.ts +38 -0
  189. package/dist/responders/types.d.ts.map +1 -0
  190. package/dist/responders/types.js +1 -0
  191. package/dist/router.d.ts +51 -0
  192. package/dist/router.d.ts.map +1 -0
  193. package/dist/router.js +200 -0
  194. package/dist/types.d.ts +7711 -0
  195. package/dist/types.d.ts.map +1 -0
  196. package/dist/types.js +479 -0
  197. package/package.json +96 -0
  198. package/responder/README.md +42 -0
  199. package/responder/backend-responder.json +9 -0
  200. package/responder/devops-responder.json +9 -0
  201. package/responder/frontend-responder.json +9 -0
  202. package/responder/schema.json +89 -0
@@ -0,0 +1,34 @@
1
+ import { Command } from "commander";
2
+ import { printError } from "../output.js";
3
+ export function createServerCommand() {
4
+ const cmd = new Command("server").description("Server management commands");
5
+ cmd
6
+ .command("start")
7
+ .description("Start the tasks-adapter MCP server (stdio)")
8
+ .action(async (_opts, command) => {
9
+ const allOpts = command.optsWithGlobals();
10
+ const jsonMode = allOpts.json === true;
11
+ try {
12
+ if (allOpts.responderDir) {
13
+ process.env.BMUX_RESPONDER_DIR = allOpts.responderDir;
14
+ }
15
+ if (allOpts.repoRoot) {
16
+ process.env.BMUX_REPO_ROOT = allOpts.repoRoot;
17
+ }
18
+ if (allOpts.configRoot) {
19
+ process.env.BMUX_CONFIG_ROOT = allOpts.configRoot;
20
+ }
21
+ // Dynamically import the MCP server to avoid heavy dependency at load time
22
+ const { startBreakpointMcpServer } = await import("../../mcp/index.js");
23
+ if (!jsonMode) {
24
+ console.error("Starting tasks-adapter MCP server on stdio...");
25
+ }
26
+ await startBreakpointMcpServer();
27
+ }
28
+ catch (error) {
29
+ printError(error, jsonMode);
30
+ process.exitCode = 1;
31
+ }
32
+ });
33
+ return cmd;
34
+ }
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare function createTasksCommand(): Command;
3
+ //# sourceMappingURL=tasks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tasks.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/tasks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA6BpC,wBAAgB,kBAAkB,IAAI,OAAO,CAqQ5C"}
@@ -0,0 +1,281 @@
1
+ import { Command } from "commander";
2
+ import { GitNativeBackend } from "../../backends/git-native.js";
3
+ import { formatTable, printError } from "../output.js";
4
+ function backend(opts) {
5
+ return new GitNativeBackend({ breakpointsDir: opts.breakpointsDir });
6
+ }
7
+ function splitCsv(value) {
8
+ return value?.split(",").map((item) => item.trim()).filter(Boolean);
9
+ }
10
+ function printResult(value, jsonMode) {
11
+ if (jsonMode) {
12
+ console.log(JSON.stringify(value, null, 2));
13
+ return;
14
+ }
15
+ console.log(JSON.stringify(value, null, 2));
16
+ }
17
+ export function createTasksCommand() {
18
+ const cmd = new Command("tasks")
19
+ .description("Manage task-like breakpoints with git-native task-management features")
20
+ .option("--breakpoints-dir <path>", "Path to .breakpoints directory");
21
+ cmd
22
+ .command("search")
23
+ .description("Search task-like breakpoints")
24
+ .option("-q, --query <text>", "Text query")
25
+ .option("--status <csv>", "Comma-separated statuses")
26
+ .option("--priority <csv>", "Comma-separated priorities")
27
+ .option("--assignee <id>", "Assignee responder id")
28
+ .option("--responder <id>", "Target/claimed/answering responder id")
29
+ .option("--tag <csv>", "Comma-separated tags")
30
+ .option("--domain <domain>", "Domain filter")
31
+ .option("--limit <n>", "Maximum result count")
32
+ .action(async (opts, command) => {
33
+ const allOpts = command.optsWithGlobals();
34
+ const jsonMode = allOpts.json === true;
35
+ try {
36
+ const result = await backend(allOpts).searchBreakpoints({
37
+ query: opts.query,
38
+ status: splitCsv(opts.status),
39
+ priority: splitCsv(opts.priority),
40
+ assigneeId: opts.assignee,
41
+ responderId: opts.responder,
42
+ tags: splitCsv(opts.tag),
43
+ domain: opts.domain,
44
+ limit: opts.limit ? Number.parseInt(opts.limit, 10) : undefined,
45
+ });
46
+ if (jsonMode) {
47
+ printResult(result, true);
48
+ }
49
+ else {
50
+ const rows = result.items.map((task) => [
51
+ task.id,
52
+ task.status,
53
+ task.priority ?? "medium",
54
+ task.assigneeId ?? "",
55
+ task.text,
56
+ ]);
57
+ console.log(formatTable(rows, ["ID", "Status", "Priority", "Assignee", "Task"]));
58
+ }
59
+ }
60
+ catch (error) {
61
+ printError(error, jsonMode);
62
+ process.exitCode = 1;
63
+ }
64
+ });
65
+ cmd
66
+ .command("assign")
67
+ .description("Assign or reassign a task-like breakpoint")
68
+ .argument("<taskId>")
69
+ .requiredOption("--assignee <id>", "Assignee responder id")
70
+ .option("--assignee-name <name>", "Assignee display name")
71
+ .option("--actor <id>", "Actor id")
72
+ .action(async (taskId, opts, command) => {
73
+ const allOpts = command.optsWithGlobals();
74
+ const jsonMode = allOpts.json === true;
75
+ try {
76
+ const result = await backend(allOpts).assignBreakpoint(taskId, {
77
+ assigneeId: opts.assignee ?? "",
78
+ assigneeName: opts.assigneeName,
79
+ actorId: opts.actor,
80
+ });
81
+ printResult(result, jsonMode);
82
+ }
83
+ catch (error) {
84
+ printError(error, jsonMode);
85
+ process.exitCode = 1;
86
+ }
87
+ });
88
+ cmd
89
+ .command("close")
90
+ .description("Mark a task-like breakpoint completed")
91
+ .argument("<taskId>")
92
+ .option("--actor <id>", "Actor id")
93
+ .option("--message <text>", "History message")
94
+ .action(async (taskId, opts, command) => {
95
+ const allOpts = command.optsWithGlobals();
96
+ const jsonMode = allOpts.json === true;
97
+ try {
98
+ const result = await backend(allOpts).transitionBreakpoint(taskId, {
99
+ status: "completed",
100
+ actorId: opts.actor,
101
+ message: opts.message,
102
+ });
103
+ printResult(result, jsonMode);
104
+ }
105
+ catch (error) {
106
+ printError(error, jsonMode);
107
+ process.exitCode = 1;
108
+ }
109
+ });
110
+ cmd
111
+ .command("comment")
112
+ .description("Add a discussion comment to a task-like breakpoint")
113
+ .argument("<taskId>")
114
+ .requiredOption("--author <id>", "Author id")
115
+ .requiredOption("--text <text>", "Comment text")
116
+ .option("--author-name <name>", "Author display name")
117
+ .action(async (taskId, opts, command) => {
118
+ const allOpts = command.optsWithGlobals();
119
+ const jsonMode = allOpts.json === true;
120
+ try {
121
+ const result = await backend(allOpts).addBreakpointComment(taskId, {
122
+ authorId: opts.author ?? "",
123
+ authorName: opts.authorName,
124
+ text: opts.text ?? "",
125
+ });
126
+ printResult(result, jsonMode);
127
+ }
128
+ catch (error) {
129
+ printError(error, jsonMode);
130
+ process.exitCode = 1;
131
+ }
132
+ });
133
+ cmd
134
+ .command("approve")
135
+ .description("Approve a task-like breakpoint by submitting an approved answer")
136
+ .argument("<taskId>")
137
+ .requiredOption("--responder <id>", "Approving responder id")
138
+ .requiredOption("--responder-name <name>", "Approving responder display name")
139
+ .requiredOption("--text <text>", "Approval answer text")
140
+ .option("--actor <id>", "Actor id")
141
+ .action(async (taskId, opts, command) => {
142
+ const allOpts = command.optsWithGlobals();
143
+ const jsonMode = allOpts.json === true;
144
+ try {
145
+ const result = await backend(allOpts).bulkUpdateBreakpoints({
146
+ ids: [taskId],
147
+ action: "approve",
148
+ actorId: opts.actor,
149
+ answer: {
150
+ responderId: opts.responder ?? "",
151
+ responderName: opts.responderName ?? "",
152
+ text: opts.text ?? "",
153
+ approved: true,
154
+ },
155
+ });
156
+ printResult(result, jsonMode);
157
+ if (result.failed > 0)
158
+ process.exitCode = 1;
159
+ }
160
+ catch (error) {
161
+ printError(error, jsonMode);
162
+ process.exitCode = 1;
163
+ }
164
+ });
165
+ cmd
166
+ .command("cancel")
167
+ .description("Cancel a task-like breakpoint")
168
+ .argument("<taskId>")
169
+ .action(async (taskId, _opts, command) => {
170
+ const allOpts = command.optsWithGlobals();
171
+ const jsonMode = allOpts.json === true;
172
+ try {
173
+ const result = await backend(allOpts).bulkUpdateBreakpoints({
174
+ ids: [taskId],
175
+ action: "cancel",
176
+ });
177
+ printResult(result, jsonMode);
178
+ if (result.failed > 0)
179
+ process.exitCode = 1;
180
+ }
181
+ catch (error) {
182
+ printError(error, jsonMode);
183
+ process.exitCode = 1;
184
+ }
185
+ });
186
+ cmd
187
+ .command("transition")
188
+ .description("Transition a task-like breakpoint to a lifecycle status")
189
+ .argument("<taskId>")
190
+ .requiredOption("--status <status>", "Target breakpoint status")
191
+ .option("--actor <id>", "Actor id")
192
+ .option("--message <text>", "History message")
193
+ .action(async (taskId, opts, command) => {
194
+ const allOpts = command.optsWithGlobals();
195
+ const jsonMode = allOpts.json === true;
196
+ try {
197
+ const result = await backend(allOpts).transitionBreakpoint(taskId, {
198
+ status: opts.status,
199
+ actorId: opts.actor,
200
+ message: opts.message,
201
+ });
202
+ printResult(result, jsonMode);
203
+ }
204
+ catch (error) {
205
+ printError(error, jsonMode);
206
+ process.exitCode = 1;
207
+ }
208
+ });
209
+ cmd
210
+ .command("bulk")
211
+ .description("Apply a bulk task operation with per-item results")
212
+ .requiredOption("--ids <csv>", "Comma-separated task ids")
213
+ .requiredOption("--action <action>", "approve, close, cancel, reassign, or transition")
214
+ .option("--actor <id>", "Actor id")
215
+ .option("--assignee <id>", "Assignee responder id for reassign")
216
+ .option("--assignee-name <name>", "Assignee display name for reassign")
217
+ .option("--status <status>", "Target status for transition")
218
+ .option("--message <text>", "History message")
219
+ .option("--responder <id>", "Approving responder id")
220
+ .option("--responder-name <name>", "Approving responder display name")
221
+ .option("--text <text>", "Approval answer text")
222
+ .action(async (opts, command) => {
223
+ const allOpts = command.optsWithGlobals();
224
+ const jsonMode = allOpts.json === true;
225
+ try {
226
+ const result = await backend(allOpts).bulkUpdateBreakpoints({
227
+ ids: splitCsv(opts.ids) ?? [],
228
+ action: opts.action,
229
+ actorId: opts.actor,
230
+ assigneeId: opts.assignee,
231
+ assigneeName: opts.assigneeName,
232
+ status: opts.status,
233
+ message: opts.message,
234
+ answer: opts.action === "approve"
235
+ ? {
236
+ responderId: opts.responder ?? opts.actor ?? "cli",
237
+ responderName: opts.responderName ?? opts.responder ?? opts.actor ?? "CLI",
238
+ text: opts.text ?? opts.message ?? "Approved",
239
+ approved: true,
240
+ }
241
+ : undefined,
242
+ });
243
+ printResult(result, jsonMode);
244
+ if (result.failed > 0)
245
+ process.exitCode = 1;
246
+ }
247
+ catch (error) {
248
+ printError(error, jsonMode);
249
+ process.exitCode = 1;
250
+ }
251
+ });
252
+ cmd
253
+ .command("stats")
254
+ .description("Show task metrics grouped by status and priority")
255
+ .action(async (_opts, command) => {
256
+ const allOpts = command.optsWithGlobals();
257
+ const jsonMode = allOpts.json === true;
258
+ try {
259
+ printResult(await backend(allOpts).getBreakpointMetrics(), jsonMode);
260
+ }
261
+ catch (error) {
262
+ printError(error, jsonMode);
263
+ process.exitCode = 1;
264
+ }
265
+ });
266
+ cmd
267
+ .command("export")
268
+ .description("Export task-like breakpoints with credential redaction")
269
+ .action(async (_opts, command) => {
270
+ const allOpts = command.optsWithGlobals();
271
+ const jsonMode = allOpts.json === true;
272
+ try {
273
+ printResult(await backend(allOpts).exportBreakpoints(), jsonMode);
274
+ }
275
+ catch (error) {
276
+ printError(error, jsonMode);
277
+ process.exitCode = 1;
278
+ }
279
+ });
280
+ return cmd;
281
+ }
@@ -0,0 +1,3 @@
1
+ import { Command } from "commander";
2
+ export declare function createTemplatesCommand(): Command;
3
+ //# sourceMappingURL=templates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/templates.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA+CpC,wBAAgB,sBAAsB,IAAI,OAAO,CAgEhD"}
@@ -0,0 +1,100 @@
1
+ import { promises as fs } from "node:fs";
2
+ import * as path from "node:path";
3
+ import { Command } from "commander";
4
+ import { resolveConfigRoot } from "../../config.js";
5
+ import { printError } from "../output.js";
6
+ function templatesPath(opts) {
7
+ return path.join(resolveConfigRoot({
8
+ repoRoot: opts.repoRoot,
9
+ configRoot: opts.configRoot,
10
+ }), "tasks-adapter", "templates.json");
11
+ }
12
+ async function readTemplates(filePath) {
13
+ try {
14
+ const raw = await fs.readFile(filePath, "utf-8");
15
+ return JSON.parse(raw);
16
+ }
17
+ catch (error) {
18
+ if (error.code === "ENOENT")
19
+ return [];
20
+ throw error;
21
+ }
22
+ }
23
+ async function writeTemplates(filePath, templates) {
24
+ await fs.mkdir(path.dirname(filePath), { recursive: true });
25
+ await fs.writeFile(filePath, JSON.stringify(templates, null, 2) + "\n", "utf-8");
26
+ }
27
+ function printValue(value, jsonMode) {
28
+ if (jsonMode || Array.isArray(value) || typeof value === "object") {
29
+ console.log(JSON.stringify(value, null, 2));
30
+ return;
31
+ }
32
+ console.log(String(value));
33
+ }
34
+ export function createTemplatesCommand() {
35
+ const cmd = new Command("templates").description("Manage reusable task templates");
36
+ cmd
37
+ .command("list")
38
+ .description("List task templates")
39
+ .action(async (_opts, command) => {
40
+ const allOpts = command.optsWithGlobals();
41
+ const jsonMode = allOpts.json === true;
42
+ try {
43
+ printValue(await readTemplates(templatesPath(allOpts)), jsonMode);
44
+ }
45
+ catch (error) {
46
+ printError(error, jsonMode);
47
+ process.exitCode = 1;
48
+ }
49
+ });
50
+ cmd
51
+ .command("show")
52
+ .description("Show a task template")
53
+ .argument("<templateId>", "Template id")
54
+ .action(async (templateId, _opts, command) => {
55
+ const allOpts = command.optsWithGlobals();
56
+ const jsonMode = allOpts.json === true;
57
+ try {
58
+ const template = (await readTemplates(templatesPath(allOpts))).find((item) => item.id === templateId);
59
+ if (!template)
60
+ throw new Error(`Template not found: ${templateId}`);
61
+ printValue(template, jsonMode);
62
+ }
63
+ catch (error) {
64
+ printError(error, jsonMode);
65
+ process.exitCode = 1;
66
+ }
67
+ });
68
+ cmd
69
+ .command("create")
70
+ .description("Create or replace a task template")
71
+ .argument("<templateId>", "Template id")
72
+ .requiredOption("--title <title>", "Template title")
73
+ .requiredOption("--body <body>", "Template body")
74
+ .action(async (templateId, opts, command) => {
75
+ const allOpts = command.optsWithGlobals();
76
+ const jsonMode = allOpts.json === true;
77
+ try {
78
+ const filePath = templatesPath(allOpts);
79
+ const templates = await readTemplates(filePath);
80
+ const next = {
81
+ id: templateId,
82
+ title: opts.title,
83
+ body: opts.body,
84
+ createdAt: new Date().toISOString(),
85
+ };
86
+ const existingIndex = templates.findIndex((item) => item.id === templateId);
87
+ if (existingIndex === -1)
88
+ templates.push(next);
89
+ else
90
+ templates[existingIndex] = next;
91
+ await writeTemplates(filePath, templates);
92
+ printValue(next, jsonMode);
93
+ }
94
+ catch (error) {
95
+ printError(error, jsonMode);
96
+ process.exitCode = 1;
97
+ }
98
+ });
99
+ return cmd;
100
+ }
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ export { createProgram } from "./program.js";
3
+ export declare const CLI_VERSION = "5.0.0";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,eAAO,MAAM,WAAW,UAAU,CAAC"}
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ import { createProgram } from "./program.js";
3
+ export { createProgram } from "./program.js";
4
+ export const CLI_VERSION = "5.0.0";
5
+ const program = createProgram();
6
+ program.parseAsync(process.argv).catch((err) => {
7
+ console.error(err);
8
+ process.exit(1);
9
+ });
@@ -0,0 +1,26 @@
1
+ import type { Breakpoint, BreakpointAnswer, ResponderProfile } from "../types.js";
2
+ /**
3
+ * Format a breakpoint for display.
4
+ */
5
+ export declare function formatBreakpoint(breakpoint: Breakpoint, jsonMode: boolean): string;
6
+ /**
7
+ * Format an answer for display.
8
+ */
9
+ export declare function formatAnswer(answer: BreakpointAnswer, jsonMode: boolean): string;
10
+ /**
11
+ * Format a responder profile for display.
12
+ */
13
+ export declare function formatResponder(responder: ResponderProfile, jsonMode: boolean): string;
14
+ /**
15
+ * Format data as a simple table.
16
+ */
17
+ export declare function formatTable(rows: string[][], headers: string[]): string;
18
+ /**
19
+ * Print output, handling JSON mode.
20
+ */
21
+ export declare function printOutput(data: unknown, jsonMode: boolean): void;
22
+ /**
23
+ * Print an error, handling JSON mode.
24
+ */
25
+ export declare function printError(error: unknown, jsonMode: boolean): void;
26
+ //# sourceMappingURL=output.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/cli/output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAmBlF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,CAuBlF;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,gBAAgB,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,CA8BhF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,gBAAgB,EAAE,QAAQ,EAAE,OAAO,GAAG,MAAM,CAqBtF;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CA2BvE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,CAQlE;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,CAQlE"}
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Format a duration in milliseconds as a human-readable string.
3
+ */
4
+ function formatDuration(ms) {
5
+ if (ms < 1000)
6
+ return `${ms}ms`;
7
+ const seconds = Math.floor(ms / 1000);
8
+ if (seconds < 60)
9
+ return `${seconds}s`;
10
+ const minutes = Math.floor(seconds / 60);
11
+ const remainingSeconds = seconds % 60;
12
+ if (minutes < 60) {
13
+ return remainingSeconds > 0 ? `${minutes}m ${remainingSeconds}s` : `${minutes}m`;
14
+ }
15
+ const hours = Math.floor(minutes / 60);
16
+ const remainingMinutes = minutes % 60;
17
+ return remainingMinutes > 0 ? `${hours}h ${remainingMinutes}m` : `${hours}h`;
18
+ }
19
+ /**
20
+ * Format a breakpoint for display.
21
+ */
22
+ export function formatBreakpoint(breakpoint, jsonMode) {
23
+ if (jsonMode) {
24
+ return JSON.stringify(breakpoint, null, 2);
25
+ }
26
+ const lines = [];
27
+ lines.push(`Breakpoint: ${breakpoint.id}`);
28
+ lines.push(`Status: ${breakpoint.status}`);
29
+ lines.push(`Text: ${breakpoint.text}`);
30
+ lines.push(`Strategy: ${breakpoint.routing.strategy}`);
31
+ lines.push(`Responders: ${breakpoint.routing.targetResponders.join(", ") || "(none)"}`);
32
+ lines.push(`Created: ${breakpoint.createdAt}`);
33
+ lines.push(`Expires: ${breakpoint.expiresAt}`);
34
+ if (breakpoint.context.tags.length > 0) {
35
+ lines.push(`Tags: ${breakpoint.context.tags.join(", ")}`);
36
+ }
37
+ if (breakpoint.answers.length > 0) {
38
+ lines.push(`Answers: ${breakpoint.answers.length}`);
39
+ }
40
+ return lines.join("\n");
41
+ }
42
+ /**
43
+ * Format an answer for display.
44
+ */
45
+ export function formatAnswer(answer, jsonMode) {
46
+ if (jsonMode) {
47
+ return JSON.stringify(answer, null, 2);
48
+ }
49
+ const lines = [];
50
+ lines.push(`Answer: ${answer.id}`);
51
+ lines.push(`Breakpoint: ${answer.breakpointId}`);
52
+ lines.push(`Responder: ${answer.responderName} (${answer.responderId})`);
53
+ lines.push(`Confidence: ${answer.confidence}%`);
54
+ lines.push(`Answered: ${answer.answeredAt}`);
55
+ lines.push(`---`);
56
+ lines.push(answer.text);
57
+ if (answer.references.length > 0) {
58
+ lines.push(`---`);
59
+ lines.push(`References:`);
60
+ for (const ref of answer.references) {
61
+ lines.push(` - ${ref}`);
62
+ }
63
+ }
64
+ if (answer.followUpQuestions.length > 0) {
65
+ lines.push(`Follow-up questions:`);
66
+ for (const q of answer.followUpQuestions) {
67
+ lines.push(` - ${q}`);
68
+ }
69
+ }
70
+ return lines.join("\n");
71
+ }
72
+ /**
73
+ * Format a responder profile for display.
74
+ */
75
+ export function formatResponder(responder, jsonMode) {
76
+ if (jsonMode) {
77
+ return JSON.stringify(responder, null, 2);
78
+ }
79
+ const lines = [];
80
+ lines.push(`Responder: ${responder.id}`);
81
+ lines.push(`Name: ${responder.name}`);
82
+ lines.push(`Title: ${responder.title}`);
83
+ lines.push(`Available: ${responder.availability ? "yes" : "no"}`);
84
+ lines.push(`Response SLA: ${formatDuration(responder.responseTimeSla)}`);
85
+ if (responder.domains.length > 0) {
86
+ lines.push(`Domains: ${responder.domains.join(", ")}`);
87
+ }
88
+ if (responder.tags.length > 0) {
89
+ lines.push(`Tags: ${responder.tags.join(", ")}`);
90
+ }
91
+ return lines.join("\n");
92
+ }
93
+ /**
94
+ * Format data as a simple table.
95
+ */
96
+ export function formatTable(rows, headers) {
97
+ if (rows.length === 0) {
98
+ return "(no results)";
99
+ }
100
+ // Calculate column widths
101
+ const widths = headers.map((h, i) => {
102
+ const maxDataWidth = rows.reduce((max, row) => Math.max(max, (row[i] ?? "").length), 0);
103
+ return Math.max(h.length, maxDataWidth);
104
+ });
105
+ const pad = (str, width) => str.padEnd(width);
106
+ const lines = [];
107
+ // Header row
108
+ lines.push(headers.map((h, i) => pad(h, widths[i])).join(" "));
109
+ // Separator
110
+ lines.push(widths.map((w) => "-".repeat(w)).join(" "));
111
+ // Data rows
112
+ for (const row of rows) {
113
+ lines.push(row.map((cell, i) => pad(cell ?? "", widths[i])).join(" "));
114
+ }
115
+ return lines.join("\n");
116
+ }
117
+ /**
118
+ * Print output, handling JSON mode.
119
+ */
120
+ export function printOutput(data, jsonMode) {
121
+ if (jsonMode) {
122
+ console.log(JSON.stringify(data, null, 2));
123
+ }
124
+ else if (typeof data === "string") {
125
+ console.log(data);
126
+ }
127
+ else {
128
+ console.log(data);
129
+ }
130
+ }
131
+ /**
132
+ * Print an error, handling JSON mode.
133
+ */
134
+ export function printError(error, jsonMode) {
135
+ if (jsonMode) {
136
+ const message = error instanceof Error ? error.message : String(error);
137
+ console.error(JSON.stringify({ error: message }));
138
+ }
139
+ else {
140
+ const message = error instanceof Error ? error.message : String(error);
141
+ console.error(`Error: ${message}`);
142
+ }
143
+ }
@@ -0,0 +1,6 @@
1
+ import { Command } from "commander";
2
+ /**
3
+ * Create and configure the main CLI program.
4
+ */
5
+ export declare function createProgram(): Command;
6
+ //# sourceMappingURL=program.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../../src/cli/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAYpC;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAsCvC"}
@@ -0,0 +1,38 @@
1
+ import { Command } from "commander";
2
+ import { createAskCommand } from "./commands/ask.js";
3
+ import { createRespondersCommand } from "./commands/responders.js";
4
+ import { createBreakpointsCommand } from "./commands/breakpoints.js";
5
+ import { createServerCommand } from "./commands/server.js";
6
+ import { createResponderLoopCommand } from "./commands/responder-loop.js";
7
+ import { createAuthCommand } from "./commands/auth.js";
8
+ import { createTasksCommand } from "./commands/tasks.js";
9
+ import { createTemplatesCommand } from "./commands/templates.js";
10
+ import { createRulesCommand } from "./commands/rules.js";
11
+ import { DEFAULT_BMUX_SERVER_URL } from "../client/index.js";
12
+ /**
13
+ * Create and configure the main CLI program.
14
+ */
15
+ export function createProgram() {
16
+ const program = new Command();
17
+ program
18
+ .name("adapters-tasks")
19
+ .version("5.0.0")
20
+ .description("CLI for Breakpoints Adapter - route breakpoints to domain responders")
21
+ .option("--server-url <url>", `Server URL (defaults to ${DEFAULT_BMUX_SERVER_URL})`)
22
+ .option("--auth-token <token>", "Bearer token for BMUX API access")
23
+ .option("--json", "Output in JSON format", false)
24
+ .option("--responder-dir <path>", "Responder profile directory, relative to the associated repo or config root when not absolute")
25
+ .option("--repo-root <path>", "Associated repository root for resolving .a5c-based configuration")
26
+ .option("--config-root <path>", "Associated configuration root (.a5c) for resolving repo-scoped responder config");
27
+ // Register subcommands
28
+ program.addCommand(createAskCommand());
29
+ program.addCommand(createRespondersCommand());
30
+ program.addCommand(createBreakpointsCommand());
31
+ program.addCommand(createTasksCommand());
32
+ program.addCommand(createTemplatesCommand());
33
+ program.addCommand(createRulesCommand());
34
+ program.addCommand(createServerCommand());
35
+ program.addCommand(createResponderLoopCommand());
36
+ program.addCommand(createAuthCommand());
37
+ return program;
38
+ }