@tasqmate/mcp 0.2.0 → 0.3.1

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.
package/README.md CHANGED
@@ -88,9 +88,9 @@ so `tasqmate project share` and the web Share dialog are the only ways in.
88
88
  | `billing_period_mark_invoiced` | `tasqmate clients invoice` | `workspace`, `client`, `month`, `invoiceRef` (admins) |
89
89
  | `billing_period_reopen` | `tasqmate clients reopen` | `workspace`, `client`, `month` (admins) |
90
90
  | `comment_add` | `tasqmate comment add` | `workspace`, `body`, `task`, `project`, `doc`, `propose`, `replyTo`, `thread`, `mentions`, `attach` (absolute paths) |
91
- | `file_add` | `tasqmate file add` | `workspace`, `task`, `paths` (absolute paths, up to 100 MB each) |
91
+ | `file_add` | `tasqmate file add` | `workspace`, `task` or `doc`, `paths` (absolute paths, up to 100 MB each), `inline` (returns each file's Markdown line for the body) |
92
92
  | `file_list` | `tasqmate file list` | `workspace`, `task`: the task's files, then each comment's |
93
- | `file_get` | `tasqmate file get` | `workspace`, `id`, `out` (absolute path), `force`, `link`; with neither, a five-minute link plus the text of a text file up to 256 KB |
93
+ | `file_get` | `tasqmate file get` | `workspace`, `id`, `out` (absolute path), `force`, `link`; with neither, a five-minute link plus the text of a text file up to 256 KB or an image up to 5 MB as image content |
94
94
  | `file_remove` | `tasqmate file remove` | `workspace`, `id` |
95
95
  | `thread_view` | `tasqmate thread view` | `workspace`, `threadId` |
96
96
  | `thread_context` | `tasqmate thread context` | `workspace`, `threadId`, `format` (`markdown` by default) |
@@ -22264,6 +22264,29 @@ function formatFileSize(bytes) {
22264
22264
  const rounded = value >= 10 ? Math.round(value) : Math.round(value * 10) / 10;
22265
22265
  return `${rounded} ${units[unit]}`;
22266
22266
  }
22267
+ var PREVIEWABLE_IMAGE_TYPES = /* @__PURE__ */ new Set([
22268
+ "image/png",
22269
+ "image/jpeg",
22270
+ "image/gif",
22271
+ "image/webp",
22272
+ "image/avif"
22273
+ ]);
22274
+ function isPreviewableImage(contentType) {
22275
+ return PREVIEWABLE_IMAGE_TYPES.has(contentType.toLowerCase());
22276
+ }
22277
+ function escapeLinkText(text) {
22278
+ return text.replace(/[\\[\]]/g, (char) => `\\${char}`);
22279
+ }
22280
+ function fileMarkdown(file2, layout = {}) {
22281
+ const href = `tasq:file/${file2.id}`;
22282
+ if (!isPreviewableImage(file2.contentType)) {
22283
+ return `[${escapeLinkText(file2.fileName)}](${href})`;
22284
+ }
22285
+ const size = layout.size ?? "full";
22286
+ const align = layout.align ?? "center";
22287
+ const title = size === "full" && align === "center" ? "" : ` "${size} ${align}"`;
22288
+ return `![${escapeLinkText(layout.caption ?? "")}](${href}${title})`;
22289
+ }
22267
22290
 
22268
22291
  // ../sdk/src/errors.ts
22269
22292
  var TasqmateApiError = class extends Error {
@@ -22612,7 +22635,9 @@ var TasqmateClient = class _TasqmateClient {
22612
22635
  /**
22613
22636
  * Upload a file in one call: `attachment.begin`, the PUT, then
22614
22637
  * `attachment.finish`. With `forComment`, the file is staged for the
22615
- * next `comment.add` that names it in `attachmentIds`.
22638
+ * next `comment.add` that names it in `attachmentIds`. With `inline`,
22639
+ * it is for the task's description or the doc's body (ATT-2): put
22640
+ * `fileMarkdown(result.attachment)` in the body to show it there.
22616
22641
  */
22617
22642
  upload: async (slug, target, file2, options) => {
22618
22643
  const body = file2.data instanceof Blob ? file2.data : new Blob([file2.data]);
@@ -22622,7 +22647,8 @@ var TasqmateClient = class _TasqmateClient {
22622
22647
  fileName: file2.fileName,
22623
22648
  contentType,
22624
22649
  sizeBytes: body.size,
22625
- forComment: file2.forComment
22650
+ forComment: file2.forComment,
22651
+ inline: file2.inline
22626
22652
  });
22627
22653
  const { upload, attachment } = begun.result;
22628
22654
  const put = await this.#fetch(upload.url, {
@@ -22847,6 +22873,24 @@ var TasqmateClient = class _TasqmateClient {
22847
22873
  `/workspaces/${encodeURIComponent(slug)}/agents/me/bridge/state`,
22848
22874
  { method: "POST", body: JSON.stringify(report) }
22849
22875
  ),
22876
+ /**
22877
+ * One chat turn's request and history, for the agent behind this key
22878
+ * (CHAT-1). `messageId` is the wake's message: `answered` says a reply
22879
+ * already came after it, so there is nothing to run.
22880
+ */
22881
+ chatContext: (slug, chatId, query = {}) => this.#get(
22882
+ `/workspaces/${encodeURIComponent(slug)}/agents/me/chats/${encodeURIComponent(chatId)}/context`,
22883
+ { message: query.messageId }
22884
+ ),
22885
+ /**
22886
+ * Post the agent's reply in a chat (CHAT-1): the Bridge sends the
22887
+ * harness's final message. One reply per wake; posting again for the
22888
+ * same `eventId` returns the first.
22889
+ */
22890
+ replyToChat: (slug, chatId, reply) => this.#request(
22891
+ `/workspaces/${encodeURIComponent(slug)}/agents/me/chats/${encodeURIComponent(chatId)}/reply`,
22892
+ { method: "POST", body: JSON.stringify(reply) }
22893
+ ),
22850
22894
  /** The bridge unpairs itself: its record and this key are revoked. */
22851
22895
  unpairBridge: (slug) => this.#request(
22852
22896
  `/workspaces/${encodeURIComponent(slug)}/agents/me/bridge`,
@@ -31000,7 +31044,7 @@ var EMPTY_COMPLETION_RESULT = {
31000
31044
  // package.json
31001
31045
  var package_default = {
31002
31046
  name: "@tasqmate/mcp",
31003
- version: "0.2.0",
31047
+ version: "0.3.1",
31004
31048
  description: "MCP stdio server for Tasqmate: tasks, threads, comments and mentions for MCP-capable agents",
31005
31049
  keywords: [
31006
31050
  "tasqmate",
@@ -31690,7 +31734,7 @@ function requireAbsolute(path, field) {
31690
31734
  }
31691
31735
  return path;
31692
31736
  }
31693
- async function uploadPaths(client, slug, target, paths, forComment = false) {
31737
+ async function uploadPaths(client, slug, target, paths, options = {}) {
31694
31738
  const uploaded = [];
31695
31739
  for (const path of paths) {
31696
31740
  let data;
@@ -31701,21 +31745,25 @@ async function uploadPaths(client, slug, target, paths, forComment = false) {
31701
31745
  throw new UsageError(`Cannot read "${path}".`);
31702
31746
  }
31703
31747
  const fileName = basename(path);
31748
+ const contentType = contentTypeFor(fileName);
31704
31749
  const done = await client.attachments.upload(slug, target, {
31705
31750
  data,
31706
31751
  fileName,
31707
- contentType: contentTypeFor(fileName),
31708
- forComment
31752
+ contentType,
31753
+ forComment: options.forComment === true,
31754
+ inline: options.inline
31709
31755
  });
31710
31756
  uploaded.push({
31711
31757
  id: done.result.attachment.id,
31712
31758
  fileName,
31759
+ contentType,
31713
31760
  sizeBytes: done.result.attachment.sizeBytes
31714
31761
  });
31715
31762
  }
31716
31763
  return uploaded;
31717
31764
  }
31718
31765
  var INLINE_TEXT_MAX_BYTES = 256 * 1024;
31766
+ var INLINE_IMAGE_MAX_BYTES = 5 * 1024 * 1024;
31719
31767
  function isTextType(contentType) {
31720
31768
  return contentType.startsWith("text/") || ["application/json", "application/yaml", "application/xml"].includes(contentType);
31721
31769
  }
@@ -32362,7 +32410,9 @@ var definitions = [
32362
32410
  }
32363
32411
  const attach = input.attach ?? [];
32364
32412
  if (attach.length > 0) {
32365
- const staged = await uploadPaths(client, slug, target.action, attach, true);
32413
+ const staged = await uploadPaths(client, slug, target.action, attach, {
32414
+ forComment: true
32415
+ });
32366
32416
  action.attachmentIds = staged.map((file2) => file2.id);
32367
32417
  }
32368
32418
  const added = await client.dispatch("comment.add", slug, action);
@@ -32574,20 +32624,40 @@ var definitions = [
32574
32624
  }),
32575
32625
  define({
32576
32626
  name: "file_add",
32577
- description: "Attach local files to a task, up to 100 MB each; to post files with a comment, use comment_add's attach instead.",
32627
+ description: "Attach local files to a task or doc, up to 100 MB each; with inline, get each file's Markdown line to put in the body.",
32578
32628
  schema: external_exports.object({
32579
32629
  ...workspaceFields,
32580
- task: external_exports.string().describe("Task key such as ENG-42, or a task id."),
32581
- paths: external_exports.array(external_exports.string()).min(1).describe("Absolute paths of the files to attach.")
32630
+ task: external_exports.string().optional().describe("Task key such as ENG-42, or a task id."),
32631
+ doc: external_exports.string().optional().describe("Doc id, link or exact title, instead of task."),
32632
+ paths: external_exports.array(external_exports.string()).min(1).describe("Absolute paths of the files to attach."),
32633
+ inline: external_exports.boolean().optional().describe(
32634
+ `For the task description or doc body: returns each file's Markdown line, an image as ![caption](tasq:file/<id> "medium left") (small|medium|full, left|center|right), anything else as [name](tasq:file/<id>), to put in with task_update or doc_update. For a comment, use comment_add's attach.`
32635
+ )
32582
32636
  }),
32583
32637
  run: async ({ client, config: config2 }, input) => {
32584
32638
  const slug = requireWorkspace(config2, input);
32585
- const taskId = await resolveTaskId(client, slug, input.task);
32586
- const uploaded = await uploadPaths(client, slug, { taskId }, input.paths);
32639
+ if (input.task === void 0 === (input.doc === void 0)) {
32640
+ throw new UsageError("Pass either task or doc.");
32641
+ }
32642
+ const target = input.doc === void 0 ? { taskId: await resolveTaskId(client, slug, input.task ?? "") } : { documentId: await resolveDocumentId(client, slug, input.doc) };
32643
+ const uploaded = await uploadPaths(client, slug, target, input.paths, {
32644
+ inline: input.inline
32645
+ });
32646
+ const on = input.task ?? input.doc ?? "";
32647
+ if (input.inline === true) {
32648
+ const files = uploaded.map((file2) => ({ ...file2, markdown: fileMarkdown(file2) }));
32649
+ return {
32650
+ data: files,
32651
+ lines: [
32652
+ `Uploaded for ${on}'s ${input.doc === void 0 ? "description" : "body"}. Put each line where the file should show:`,
32653
+ ...files.map((file2) => file2.markdown)
32654
+ ]
32655
+ };
32656
+ }
32587
32657
  return {
32588
32658
  data: uploaded,
32589
32659
  lines: uploaded.map(
32590
- (file2) => `Attached ${file2.fileName} (${formatFileSize(file2.sizeBytes)}) to ${input.task}.`
32660
+ (file2) => `Attached ${file2.fileName} (${formatFileSize(file2.sizeBytes)}) to ${on}.`
32591
32661
  )
32592
32662
  };
32593
32663
  }
@@ -32615,7 +32685,7 @@ var definitions = [
32615
32685
  }),
32616
32686
  define({
32617
32687
  name: "file_get",
32618
- description: "Read a file: save it to out, or return a five-minute link plus the text itself for a text file up to 256 KB (only the link with link).",
32688
+ description: "Read a file: save it to out, or get a five-minute link plus the text (up to 256 KB) or the image (up to 5 MB) itself.",
32619
32689
  schema: external_exports.object({
32620
32690
  ...workspaceFields,
32621
32691
  id: external_exports.string().describe("File id, from file_list or task_view."),
@@ -32629,11 +32699,20 @@ var definitions = [
32629
32699
  const wantsText = out === void 0 && input.link !== true;
32630
32700
  const link = await client.attachments.link(slug, input.id);
32631
32701
  const textFits = wantsText && isTextType(link.contentType) && link.sizeBytes <= INLINE_TEXT_MAX_BYTES;
32632
- if (out === void 0 && !textFits) return { data: link };
32702
+ const imageFits = wantsText && isPreviewableImage(link.contentType) && link.sizeBytes <= INLINE_IMAGE_MAX_BYTES;
32703
+ if (out === void 0 && !textFits && !imageFits) return { data: link };
32633
32704
  if (out !== void 0 && input.force !== true && existsSync(out)) {
32634
32705
  throw new UsageError(`"${out}" already exists. Pass force to overwrite.`);
32635
32706
  }
32636
32707
  const { data } = await client.attachments.download(slug, input.id);
32708
+ if (out === void 0 && imageFits) {
32709
+ return {
32710
+ data: link,
32711
+ images: [
32712
+ { data: Buffer.from(data).toString("base64"), mimeType: link.contentType }
32713
+ ]
32714
+ };
32715
+ }
32637
32716
  if (out === void 0) {
32638
32717
  return { data: { ...link, text: new TextDecoder().decode(data) } };
32639
32718
  }
@@ -32825,7 +32904,10 @@ function structured(data) {
32825
32904
  function toToolResult(outcome) {
32826
32905
  const text = outcome.text !== void 0 ? outcome.text : [...outcome.lines ?? [], JSON.stringify(outcome.data)].join("\n");
32827
32906
  const result2 = {
32828
- content: [{ type: "text", text }]
32907
+ content: [
32908
+ { type: "text", text },
32909
+ ...(outcome.images ?? []).map((image) => ({ type: "image", ...image }))
32910
+ ]
32829
32911
  };
32830
32912
  const content = structured(outcome.data);
32831
32913
  if (content !== void 0) result2.structuredContent = content;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tasqmate/mcp",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "MCP stdio server for Tasqmate: tasks, threads, comments and mentions for MCP-capable agents",
5
5
  "keywords": [
6
6
  "tasqmate",
@@ -48,7 +48,7 @@
48
48
  "zod": "4.3.6"
49
49
  },
50
50
  "devDependencies": {
51
- "@tasqmate/sdk": "0.2.0",
51
+ "@tasqmate/sdk": "0.3.1",
52
52
  "@types/bun": "^1.3.12",
53
53
  "tsup": "^8.5.0",
54
54
  "typescript": "^5.7.2"