@sideboard-ai/core 0.1.189 → 0.1.191

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.
@@ -13,14 +13,31 @@ import {
13
13
  // src/integrations/abletime-mcp.ts
14
14
  var DEFAULT_ABLETIME_HOST = "https://track.abletime.com";
15
15
  var ABLETIME_MCP_PATH = "/api/public/v2/mcp";
16
+ var ABLETIME_MCP_PM_PATH = "/api/public/v2/mcp/pm";
16
17
  var MCP_PROTOCOL_VERSION = "2025-03-26";
18
+ var ABLETIME_PM_TOOL_NAMES = [
19
+ "set_task_assignee",
20
+ "set_task_priority",
21
+ "set_task_stage",
22
+ "set_task_dependency",
23
+ "set_task_blocked",
24
+ "set_task_locked",
25
+ "set_task_schedule",
26
+ "clear_task_schedule",
27
+ "archive_task",
28
+ "delete_task"
29
+ ];
30
+ function abletimeToolUsesPm(name) {
31
+ return ABLETIME_PM_TOOL_NAMES.includes(name);
32
+ }
17
33
  function normalizeAbleTimeHost(raw) {
18
34
  const trimmed = raw?.trim() || DEFAULT_ABLETIME_HOST;
19
35
  const withScheme = /^https?:\/\//i.test(trimmed) ? trimmed : `https://${trimmed}`;
20
36
  return withScheme.replace(/\/+$/, "");
21
37
  }
22
- function abletimeMcpUrl(host) {
23
- return `${normalizeAbleTimeHost(host)}${ABLETIME_MCP_PATH}`;
38
+ function abletimeMcpUrl(host, opts) {
39
+ const path = opts?.pm ? ABLETIME_MCP_PM_PATH : ABLETIME_MCP_PATH;
40
+ return `${normalizeAbleTimeHost(host)}${path}`;
24
41
  }
25
42
  function rewriteAbleTimeError(message) {
26
43
  if (/INTEGRATION_AGENT_ACCESS_DISABLED|agent access/i.test(message)) {
@@ -98,7 +115,8 @@ async function abletimeMcpRequest(method, params, opts) {
98
115
  throw new Error("AbleTime is not connected \u2014 paste a personal access token in Account settings");
99
116
  }
100
117
  const url = abletimeMcpUrl(
101
- opts?.host ?? (opts?.token ? DEFAULT_ABLETIME_HOST : getAbleTimeHost())
118
+ opts?.host ?? (opts?.token ? DEFAULT_ABLETIME_HOST : getAbleTimeHost()),
119
+ { pm: opts?.pm }
102
120
  );
103
121
  const res = await httpFetch(url, {
104
122
  method: "POST",
@@ -162,7 +180,8 @@ async function callAbleTimeTool(name, args = {}, opts) {
162
180
  if (!opts?.token && !isAbleTimeConnected()) {
163
181
  throw new Error("AbleTime is not connected \u2014 paste a personal access token in Account settings");
164
182
  }
165
- const call = () => abletimeMcpRequest("tools/call", { name, arguments: args }, opts).then((result) => {
183
+ const requestOpts = { ...opts, pm: opts?.pm ?? abletimeToolUsesPm(name) };
184
+ const call = () => abletimeMcpRequest("tools/call", { name, arguments: args }, requestOpts).then((result) => {
166
185
  return unwrapToolResult(result);
167
186
  });
168
187
  try {
@@ -170,7 +189,7 @@ async function callAbleTimeTool(name, args = {}, opts) {
170
189
  } catch (err) {
171
190
  const message = err instanceof Error ? err.message : String(err);
172
191
  if (/initialize|session|not initialized|-32000/i.test(message)) {
173
- await initializeIfNeeded(opts);
192
+ await initializeIfNeeded(requestOpts);
174
193
  return await call();
175
194
  }
176
195
  throw err instanceof Error ? new Error(rewriteAbleTimeError(err.message)) : err;
@@ -426,39 +445,122 @@ async function commentAbleTimeTask(input, opts) {
426
445
  body: rec ? firstString(rec, ["body", "text", "comment"]) || body : body
427
446
  };
428
447
  }
448
+ function isAbleTimeNoneToken(value) {
449
+ if (value == null) return true;
450
+ const s = value.trim();
451
+ return !s || /^(none|clear|unschedule|null)$/i.test(s);
452
+ }
453
+ function taskIdArgs(id) {
454
+ return { id, task_id: id, task: id };
455
+ }
456
+ function ableTimeDependencyTarget(thisId, type, relatedId) {
457
+ const s = type.trim().toLowerCase().replace(/[\s_-]+/g, "");
458
+ if (s === "none" || s === "clear" || s === "null") {
459
+ return { taskId: thisId, dependsOn: null };
460
+ }
461
+ if (s === "blockedby" || s === "blocked" || s === "dependson" || s === "waiton") {
462
+ return { taskId: thisId, dependsOn: relatedId };
463
+ }
464
+ if (s === "blocks" || s === "blocking") {
465
+ return { taskId: relatedId, dependsOn: thisId };
466
+ }
467
+ throw new Error(
468
+ `AbleTime relation type must be blocks or blockedBy (got ${type}). AbleTime models one wait-on dependency.`
469
+ );
470
+ }
471
+ async function setAbleTimeTaskDependency(taskId, dependsOn, opts) {
472
+ const args = {
473
+ ...taskIdArgs(taskId)
474
+ };
475
+ if (dependsOn) {
476
+ args.depends_on = dependsOn;
477
+ args.depends_on_id = dependsOn;
478
+ args.dependency = dependsOn;
479
+ args.dependency_id = dependsOn;
480
+ args.blocked_by = dependsOn;
481
+ args.wait_on = dependsOn;
482
+ args.related_task_id = dependsOn;
483
+ } else {
484
+ args.depends_on = null;
485
+ args.dependency = null;
486
+ args.blocked_by = null;
487
+ args.clear = true;
488
+ }
489
+ await callAbleTimeTool("set_task_dependency", args, opts);
490
+ }
429
491
  async function updateAbleTimeTask(input, opts) {
430
492
  const id = input.id.trim();
431
493
  if (!id) throw new Error("AbleTime task id is required");
432
494
  const title = input.title?.trim();
433
495
  const description = input.description;
434
496
  const state = input.state?.trim();
435
- if (!title && description === void 0 && !state) {
436
- throw new Error("abletime_update_task needs at least one of title, description, state");
497
+ const addRelations = input.relations?.length ? input.relations : void 0;
498
+ const removeRelations = input.removeRelations?.length ? input.removeRelations : void 0;
499
+ const updateArgs = { ...taskIdArgs(id) };
500
+ if (title) updateArgs.title = title;
501
+ if (description !== void 0) updateArgs.description = description;
502
+ if (input.labels !== void 0) {
503
+ updateArgs.tags = input.labels;
504
+ updateArgs.labels = input.labels;
505
+ updateArgs.tag_names = input.labels;
506
+ }
507
+ if (input.project !== void 0) {
508
+ const projectName = (input.project ?? "").trim();
509
+ if (isAbleTimeNoneToken(projectName)) {
510
+ throw new Error("AbleTime tasks stay in a project \u2014 pass a project name or id");
511
+ }
512
+ const project = await resolveAbleTimeProject(projectName, opts);
513
+ updateArgs.project = project.id;
514
+ updateArgs.project_id = project.id;
515
+ }
516
+ if (input.parent !== void 0) {
517
+ if (isAbleTimeNoneToken(input.parent)) {
518
+ updateArgs.parent = null;
519
+ updateArgs.parent_id = null;
520
+ updateArgs.related_task_id = null;
521
+ } else {
522
+ const parent = (input.parent ?? "").trim();
523
+ updateArgs.parent = parent;
524
+ updateArgs.parent_id = parent;
525
+ updateArgs.related_task_id = parent;
526
+ }
527
+ }
528
+ const hasUpdateFields = Boolean(title) || description !== void 0 || input.labels !== void 0 || input.project !== void 0 || input.parent !== void 0;
529
+ if (!hasUpdateFields && !state && !addRelations && !removeRelations) {
530
+ throw new Error(
531
+ "abletime_update_task needs at least one of title, description, state, labels, project, parent, relations, removeRelations"
532
+ );
437
533
  }
438
534
  if (state) {
439
535
  await callAbleTimeTool(
440
536
  "set_task_state",
441
- { id, task_id: id, task: id, state },
537
+ { ...taskIdArgs(id), state },
442
538
  opts
443
539
  ).catch(async () => {
444
540
  await callAbleTimeTool(
445
541
  "update_task",
446
- { id, task_id: id, title, description, state },
542
+ { ...updateArgs, state },
447
543
  opts
448
544
  );
449
545
  });
450
546
  }
451
- if (title || description !== void 0) {
452
- await callAbleTimeTool(
453
- "update_task",
454
- {
455
- id,
456
- task_id: id,
457
- ...title ? { title } : {},
458
- ...description !== void 0 ? { description } : {}
459
- },
460
- opts
461
- );
547
+ if (hasUpdateFields) {
548
+ await callAbleTimeTool("update_task", updateArgs, opts);
549
+ }
550
+ for (const rel of removeRelations ?? []) {
551
+ const related = rel.issue.trim() || id;
552
+ const target = ableTimeDependencyTarget(id, rel.type, related);
553
+ await setAbleTimeTaskDependency(target.taskId, null, opts);
554
+ }
555
+ for (const rel of addRelations ?? []) {
556
+ const related = rel.issue.trim();
557
+ if (!related) throw new Error("AbleTime relations.issue is required (id or CRM-232)");
558
+ const target = ableTimeDependencyTarget(id, rel.type, related);
559
+ if (!target.dependsOn) {
560
+ await setAbleTimeTaskDependency(target.taskId, null, opts);
561
+ continue;
562
+ }
563
+ await setAbleTimeTaskDependency(target.taskId, target.dependsOn, opts);
462
564
  }
463
565
  return getAbleTimeTask(id, opts);
464
566
  }
@@ -551,6 +653,7 @@ export {
551
653
  getAbleTimeTask,
552
654
  createAbleTimeTask,
553
655
  commentAbleTimeTask,
656
+ ableTimeDependencyTarget,
554
657
  updateAbleTimeTask,
555
658
  ensureAbleTimeTask,
556
659
  listAbleTimeAssignedIssues,