@gethmy/mcp 2.12.0 → 2.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +303 -41
- package/dist/index.js +301 -39
- package/dist/lib/api-client.js +21 -0
- package/package.json +1 -1
- package/src/api-client.ts +101 -0
- package/src/server.ts +394 -41
package/dist/cli.js
CHANGED
|
@@ -990,6 +990,7 @@ import { createRequire as createRequire2 } from "node:module";
|
|
|
990
990
|
import { program } from "commander";
|
|
991
991
|
|
|
992
992
|
// src/server.ts
|
|
993
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
993
994
|
import { readFile } from "node:fs/promises";
|
|
994
995
|
import { basename } from "node:path";
|
|
995
996
|
// ../memory/dist/sync.js
|
|
@@ -1496,6 +1497,9 @@ var TIMINGS = {
|
|
|
1496
1497
|
QUERY_STALE_TIME: 1000 * 60 * 5,
|
|
1497
1498
|
QUERY_GC_TIME: 1000 * 60 * 60 * 24
|
|
1498
1499
|
};
|
|
1500
|
+
// ../harmony-shared/dist/stageHandoff.js
|
|
1501
|
+
var HANDOFF_MARKER = "harmony:stage-handoff";
|
|
1502
|
+
var HANDOFF_BLOCK_RE = new RegExp("```json\\s*\\n//\\s*" + HANDOFF_MARKER + "\\s*\\n([\\s\\S]*?)\\n```", "m");
|
|
1499
1503
|
// src/api-client.ts
|
|
1500
1504
|
init_config();
|
|
1501
1505
|
var RETRY_CONFIG = {
|
|
@@ -1855,12 +1859,24 @@ class HarmonyApiClient {
|
|
|
1855
1859
|
async uploadCardAttachment(cardId, data) {
|
|
1856
1860
|
return this.request("POST", `/cards/${cardId}/attachments`, data);
|
|
1857
1861
|
}
|
|
1862
|
+
async requestCardAttachmentUploadUrl(cardId, data) {
|
|
1863
|
+
return this.request("POST", `/cards/${cardId}/attachment-upload-url`, data);
|
|
1864
|
+
}
|
|
1865
|
+
async finalizeCardAttachment(cardId, data) {
|
|
1866
|
+
return this.request("POST", `/cards/${cardId}/attachments/finalize`, data);
|
|
1867
|
+
}
|
|
1858
1868
|
async getCardExternalLinks(cardId) {
|
|
1859
1869
|
return this.request("GET", `/cards/${cardId}/external-links`);
|
|
1860
1870
|
}
|
|
1861
1871
|
async uploadArtifact(data) {
|
|
1862
1872
|
return this.request("POST", "/artifacts", data);
|
|
1863
1873
|
}
|
|
1874
|
+
async requestArtifactUploadUrl(data) {
|
|
1875
|
+
return this.request("POST", "/artifacts/upload-url", data);
|
|
1876
|
+
}
|
|
1877
|
+
async finalizeArtifact(data) {
|
|
1878
|
+
return this.request("POST", "/artifacts/finalize", data);
|
|
1879
|
+
}
|
|
1864
1880
|
async createArtifactShareLink(artifactId, expiresAt) {
|
|
1865
1881
|
return this.request("POST", `/artifacts/${artifactId}/share`, {
|
|
1866
1882
|
expires_at: expiresAt
|
|
@@ -2338,6 +2354,12 @@ ${planContent.trim()}`;
|
|
|
2338
2354
|
async getPlaybook(playbookId) {
|
|
2339
2355
|
return this.request("GET", `/playbooks/${playbookId}`);
|
|
2340
2356
|
}
|
|
2357
|
+
async getPlaybookVersion(playbookId, version) {
|
|
2358
|
+
return this.request("GET", `/playbooks/${encodeURIComponent(playbookId)}/versions/${version}`);
|
|
2359
|
+
}
|
|
2360
|
+
async recordStageGateEvidence(insert) {
|
|
2361
|
+
return this.request("POST", `/cards/${encodeURIComponent(insert.card_id)}/stage-gate-evidence`, insert);
|
|
2362
|
+
}
|
|
2341
2363
|
async createPlaybook(data) {
|
|
2342
2364
|
return this.request("POST", "/playbooks", data);
|
|
2343
2365
|
}
|
|
@@ -3436,6 +3458,52 @@ async function refreshSkills(opts = {}) {
|
|
|
3436
3458
|
}
|
|
3437
3459
|
|
|
3438
3460
|
// src/server.ts
|
|
3461
|
+
var MAX_ARTIFACT_SIZE = 2 * 1024 * 1024;
|
|
3462
|
+
var MAX_ATTACHMENT_SIZE = 5 * 1024 * 1024;
|
|
3463
|
+
function base64ByteLength(base64) {
|
|
3464
|
+
const stripped = base64.replace(/^data:[^,]*,/, "");
|
|
3465
|
+
return Buffer.from(stripped, "base64").byteLength;
|
|
3466
|
+
}
|
|
3467
|
+
function sha256Hex(bytes) {
|
|
3468
|
+
return createHash4("sha256").update(bytes).digest("hex");
|
|
3469
|
+
}
|
|
3470
|
+
async function readFileForUpload(filePath, maxSize, kind) {
|
|
3471
|
+
const bytes = await readFile(filePath);
|
|
3472
|
+
if (bytes.byteLength === 0) {
|
|
3473
|
+
throw new Error(`File is empty: ${filePath}`);
|
|
3474
|
+
}
|
|
3475
|
+
if (bytes.byteLength > maxSize) {
|
|
3476
|
+
const mb = Math.round(maxSize / (1024 * 1024));
|
|
3477
|
+
throw new Error(`File is ${bytes.byteLength} bytes, over the ${maxSize}-byte (${mb}MB) ${kind} limit.`);
|
|
3478
|
+
}
|
|
3479
|
+
return bytes;
|
|
3480
|
+
}
|
|
3481
|
+
function requireExactlyOneScope(scope) {
|
|
3482
|
+
if ([scope.cardId, scope.planId, scope.workspaceId].filter(Boolean).length !== 1) {
|
|
3483
|
+
throw new Error("Provide exactly one of cardId, planId, or workspaceId.");
|
|
3484
|
+
}
|
|
3485
|
+
}
|
|
3486
|
+
var SIGNED_UPLOAD_TIMEOUT_MS = 30000;
|
|
3487
|
+
async function putToSignedUrl(uploadUrl, bytes, contentType) {
|
|
3488
|
+
let res;
|
|
3489
|
+
try {
|
|
3490
|
+
res = await fetch(uploadUrl, {
|
|
3491
|
+
method: "PUT",
|
|
3492
|
+
headers: { "Content-Type": contentType },
|
|
3493
|
+
body: bytes,
|
|
3494
|
+
signal: AbortSignal.timeout(SIGNED_UPLOAD_TIMEOUT_MS)
|
|
3495
|
+
});
|
|
3496
|
+
} catch (err) {
|
|
3497
|
+
if (err instanceof DOMException && err.name === "TimeoutError") {
|
|
3498
|
+
throw new Error(`Direct storage upload timed out after ${SIGNED_UPLOAD_TIMEOUT_MS}ms.`);
|
|
3499
|
+
}
|
|
3500
|
+
throw err;
|
|
3501
|
+
}
|
|
3502
|
+
if (!res.ok) {
|
|
3503
|
+
const detail = await res.text().catch(() => "");
|
|
3504
|
+
throw new Error(`Direct storage upload failed: ${res.status}${detail ? ` — ${detail}` : ""}`);
|
|
3505
|
+
}
|
|
3506
|
+
}
|
|
3439
3507
|
var memorySessions = new Map;
|
|
3440
3508
|
function parseLabelList(raw) {
|
|
3441
3509
|
if (raw === undefined || raw === null)
|
|
@@ -3896,7 +3964,7 @@ var TOOLS = {
|
|
|
3896
3964
|
}
|
|
3897
3965
|
},
|
|
3898
3966
|
harmony_upload_card_attachment: {
|
|
3899
|
-
description: "Upload a file attachment to a card (e.g. a pasted screenshot or a document). Provide the file either as `filePath` (a local path the MCP server can read — works in local/stdio mode) or as `base64Data` (raw base64 bytes — works everywhere, including remote mode). Max 5MB. Allowed: PNG, JPEG, GIF, WebP, HEIC/HEIF, PDF, DOC/DOCX, XLS/XLSX, TXT, CSV. Returns the stored attachment with a short-lived signed URL.",
|
|
3967
|
+
description: "Upload a file attachment to a card (e.g. a pasted screenshot or a document). Provide the file either as `filePath` (a local path the MCP server can read — works in local/stdio mode) or as `base64Data` (raw base64 bytes — works everywhere, including remote mode). With `filePath` the server uploads direct-to-storage (no base64 through the model context); `base64Data` is the small-file fallback. Max 5MB. Allowed: PNG, JPEG, GIF, WebP, HEIC/HEIF, PDF, DOC/DOCX, XLS/XLSX, TXT, CSV. Returns the stored attachment with a short-lived signed URL. For large files on the hosted MCP server (where only base64Data works), prefer the two-step harmony_request_card_attachment_upload_url + harmony_finalize_card_attachment handshake, which keeps bytes out of the model context.",
|
|
3900
3968
|
inputSchema: {
|
|
3901
3969
|
type: "object",
|
|
3902
3970
|
properties: {
|
|
@@ -3921,6 +3989,58 @@ var TOOLS = {
|
|
|
3921
3989
|
required: ["cardId"]
|
|
3922
3990
|
}
|
|
3923
3991
|
},
|
|
3992
|
+
harmony_request_card_attachment_upload_url: {
|
|
3993
|
+
description: "Step 1 of the agent-driven card-attachment upload — use this for large files or when running against the hosted MCP server (which cannot read your local disk). Mints a one-shot signed Supabase Storage upload URL for a server-chosen path under the card. Provide cardId, fileName (with extension), the byte size, and optionally fileType. Returns { uploadUrl, token, storagePath, fileType }. Next: PUT the raw bytes straight to uploadUrl (e.g. `curl -X PUT --data-binary @file.png '<uploadUrl>'`) — no bytes pass through the model context — then call harmony_finalize_card_attachment with the returned storagePath. Max 5MB; allowed: PNG, JPEG, GIF, WebP, HEIC/HEIF, PDF, DOC/DOCX, XLS/XLSX, TXT, CSV.",
|
|
3994
|
+
inputSchema: {
|
|
3995
|
+
type: "object",
|
|
3996
|
+
properties: {
|
|
3997
|
+
cardId: { type: "string", description: "Card UUID" },
|
|
3998
|
+
fileName: {
|
|
3999
|
+
type: "string",
|
|
4000
|
+
description: "File name including extension (e.g. 'screenshot.png')."
|
|
4001
|
+
},
|
|
4002
|
+
fileType: {
|
|
4003
|
+
type: "string",
|
|
4004
|
+
description: "Optional MIME type (e.g. 'image/png'). Inferred from the file extension when omitted."
|
|
4005
|
+
},
|
|
4006
|
+
size: {
|
|
4007
|
+
type: "number",
|
|
4008
|
+
description: "File size in bytes (rejected early if over 5MB)."
|
|
4009
|
+
}
|
|
4010
|
+
},
|
|
4011
|
+
required: ["cardId", "fileName", "size"]
|
|
4012
|
+
}
|
|
4013
|
+
},
|
|
4014
|
+
harmony_finalize_card_attachment: {
|
|
4015
|
+
description: "Step 2 of the agent-driven card-attachment upload. After PUTting the bytes to the signed uploadUrl from harmony_request_card_attachment_upload_url, call this with the returned storagePath to validate and register the attachment. The server re-downloads the object and enforces size, an allowlisted content-type (magic-byte sniff, never the declared type), and — when you pass sha256 — an integrity check, deleting the object and failing on any mismatch. Returns the stored attachment with a short-lived signed URL.",
|
|
4016
|
+
inputSchema: {
|
|
4017
|
+
type: "object",
|
|
4018
|
+
properties: {
|
|
4019
|
+
cardId: { type: "string", description: "Card UUID" },
|
|
4020
|
+
storagePath: {
|
|
4021
|
+
type: "string",
|
|
4022
|
+
description: "The storagePath returned by harmony_request_card_attachment_upload_url."
|
|
4023
|
+
},
|
|
4024
|
+
fileName: {
|
|
4025
|
+
type: "string",
|
|
4026
|
+
description: "File name including extension (e.g. 'screenshot.png')."
|
|
4027
|
+
},
|
|
4028
|
+
fileType: {
|
|
4029
|
+
type: "string",
|
|
4030
|
+
description: "Optional MIME type; inferred from the extension when omitted."
|
|
4031
|
+
},
|
|
4032
|
+
sha256: {
|
|
4033
|
+
type: "string",
|
|
4034
|
+
description: "Optional hex SHA-256 of the uploaded bytes; verified against the stored object."
|
|
4035
|
+
},
|
|
4036
|
+
size: {
|
|
4037
|
+
type: "number",
|
|
4038
|
+
description: "Optional byte size (advisory; re-validated server-side)."
|
|
4039
|
+
}
|
|
4040
|
+
},
|
|
4041
|
+
required: ["cardId", "storagePath", "fileName"]
|
|
4042
|
+
}
|
|
4043
|
+
},
|
|
3924
4044
|
harmony_classify_card: {
|
|
3925
4045
|
description: "Classify a card with the LLM classifier: sets `intent` (plan/think/implement/review), `complexity_score` (0-10), and `model_tier` (simple/advanced/research), stamps `classified_at`, and applies the canonical type label (feature/bug/idea). Use this right after creating a card (e.g. in the `hmy-new` flow) so it's classified in-flow instead of waiting for it to surface on the web board. Idempotent — safe to re-run. Never touches the user-owned `model_override`.",
|
|
3926
4046
|
inputSchema: {
|
|
@@ -3932,7 +4052,7 @@ var TOOLS = {
|
|
|
3932
4052
|
}
|
|
3933
4053
|
},
|
|
3934
4054
|
harmony_upload_artifact: {
|
|
3935
|
-
description: "Host a self-contained HTML document (e.g. a visual design draft or diagram) in Harmony and link it to a card, a plan, or a workspace. The file is stored privately and rendered in-app inside a sandboxed cross-origin iframe. Provide exactly one of cardId, planId, or workspaceId. Supply the HTML as `filePath` (a local path the MCP server can read) or `base64Data
|
|
4055
|
+
description: "Host a self-contained HTML document (e.g. a visual design draft or diagram) in Harmony and link it to a card, a plan, or a workspace. The file is stored privately and rendered in-app inside a sandboxed cross-origin iframe. Provide exactly one of cardId, planId, or workspaceId. Supply the HTML as `filePath` (a local path the MCP server can read — uploaded direct-to-storage, no base64 through the model context) or `base64Data` (the small-file fallback). Only text/html, max 2MB. Returns the stored artifact with a short-lived signed URL; call harmony_share_artifact to mint a public link. For large files on the hosted MCP server (where only base64Data works), prefer the two-step harmony_request_artifact_upload_url + harmony_finalize_artifact handshake, which keeps bytes out of the model context.",
|
|
3936
4056
|
inputSchema: {
|
|
3937
4057
|
type: "object",
|
|
3938
4058
|
properties: {
|
|
@@ -3958,6 +4078,61 @@ var TOOLS = {
|
|
|
3958
4078
|
required: []
|
|
3959
4079
|
}
|
|
3960
4080
|
},
|
|
4081
|
+
harmony_request_artifact_upload_url: {
|
|
4082
|
+
description: "Step 1 of the agent-driven artifact upload — use this for large files or when running against the hosted MCP server (which cannot read your local disk), instead of streaming base64 through the model context. Mints a one-shot signed Supabase Storage upload URL for a server-chosen path. Provide exactly one of cardId/planId/workspaceId, optionally a title and the byte size. Returns { uploadUrl, token, storagePath }. Next: PUT the raw HTML bytes straight to uploadUrl (e.g. `curl -X PUT --data-binary @doc.html '<uploadUrl>'`), then call harmony_finalize_artifact with the returned storagePath. Only text/html, max 2MB.",
|
|
4083
|
+
inputSchema: {
|
|
4084
|
+
type: "object",
|
|
4085
|
+
properties: {
|
|
4086
|
+
title: {
|
|
4087
|
+
type: "string",
|
|
4088
|
+
description: "Display title (defaults to the file basename at finalize)."
|
|
4089
|
+
},
|
|
4090
|
+
cardId: { type: "string", description: "Link to this card (UUID)." },
|
|
4091
|
+
planId: { type: "string", description: "Link to this plan (UUID)." },
|
|
4092
|
+
workspaceId: {
|
|
4093
|
+
type: "string",
|
|
4094
|
+
description: "Attach to this workspace as a standalone artifact (UUID)."
|
|
4095
|
+
},
|
|
4096
|
+
contentType: {
|
|
4097
|
+
type: "string",
|
|
4098
|
+
description: "MIME type; only 'text/html' is accepted (the default)."
|
|
4099
|
+
},
|
|
4100
|
+
size: {
|
|
4101
|
+
type: "number",
|
|
4102
|
+
description: "File size in bytes (rejected early if over 2MB)."
|
|
4103
|
+
}
|
|
4104
|
+
},
|
|
4105
|
+
required: []
|
|
4106
|
+
}
|
|
4107
|
+
},
|
|
4108
|
+
harmony_finalize_artifact: {
|
|
4109
|
+
description: "Step 2 of the agent-driven artifact upload. After PUTting the HTML bytes to the signed uploadUrl from harmony_request_artifact_upload_url, call this with the returned storagePath to validate and register the artifact. The server re-downloads the object and enforces size, the text/html content-type (magic-byte sniff), and — when you pass sha256 — an integrity check, deleting the object and failing on any mismatch. Provide the same one of cardId/planId/workspaceId used for the upload URL. Returns the stored artifact with a short-lived signed URL; call harmony_share_artifact to mint a public link.",
|
|
4110
|
+
inputSchema: {
|
|
4111
|
+
type: "object",
|
|
4112
|
+
properties: {
|
|
4113
|
+
storagePath: {
|
|
4114
|
+
type: "string",
|
|
4115
|
+
description: "The storagePath returned by harmony_request_artifact_upload_url."
|
|
4116
|
+
},
|
|
4117
|
+
title: { type: "string", description: "Display title." },
|
|
4118
|
+
cardId: { type: "string", description: "Link to this card (UUID)." },
|
|
4119
|
+
planId: { type: "string", description: "Link to this plan (UUID)." },
|
|
4120
|
+
workspaceId: {
|
|
4121
|
+
type: "string",
|
|
4122
|
+
description: "Attach to this workspace as a standalone artifact (UUID)."
|
|
4123
|
+
},
|
|
4124
|
+
sha256: {
|
|
4125
|
+
type: "string",
|
|
4126
|
+
description: "Optional hex SHA-256 of the uploaded bytes; verified against the stored object."
|
|
4127
|
+
},
|
|
4128
|
+
size: {
|
|
4129
|
+
type: "number",
|
|
4130
|
+
description: "Optional byte size (advisory; re-validated server-side)."
|
|
4131
|
+
}
|
|
4132
|
+
},
|
|
4133
|
+
required: ["storagePath"]
|
|
4134
|
+
}
|
|
4135
|
+
},
|
|
3961
4136
|
harmony_share_artifact: {
|
|
3962
4137
|
description: "Create a public, unauthenticated share link for a hosted artifact. Anyone with the link can view the rendered HTML without a Harmony account. Returns the share token and the full public URL.",
|
|
3963
4138
|
inputSchema: {
|
|
@@ -5555,70 +5730,157 @@ async function handleToolCall(name, args, deps) {
|
|
|
5555
5730
|
const cardId = z.string().uuid().parse(args.cardId);
|
|
5556
5731
|
const filePath = args.filePath != null ? z.string().parse(args.filePath) : undefined;
|
|
5557
5732
|
const base64Data = args.base64Data != null ? z.string().parse(args.base64Data) : undefined;
|
|
5558
|
-
|
|
5733
|
+
const fileName = args.fileName != null ? z.string().parse(args.fileName) : undefined;
|
|
5559
5734
|
const contentType = args.contentType != null ? z.string().parse(args.contentType) : undefined;
|
|
5560
5735
|
if (filePath && base64Data) {
|
|
5561
5736
|
throw new Error("Provide either filePath or base64Data, not both.");
|
|
5562
5737
|
}
|
|
5563
|
-
let data;
|
|
5564
5738
|
if (filePath) {
|
|
5565
|
-
const bytes = await
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5739
|
+
const bytes = await readFileForUpload(filePath, MAX_ATTACHMENT_SIZE, "attachment");
|
|
5740
|
+
const resolvedName = fileName || basename(filePath);
|
|
5741
|
+
const signed = await client3.requestCardAttachmentUploadUrl(cardId, {
|
|
5742
|
+
fileName: resolvedName,
|
|
5743
|
+
fileType: contentType,
|
|
5744
|
+
size: bytes.byteLength
|
|
5745
|
+
});
|
|
5746
|
+
await putToSignedUrl(signed.uploadUrl, bytes, contentType || signed.fileType || "application/octet-stream");
|
|
5747
|
+
return await client3.finalizeCardAttachment(cardId, {
|
|
5748
|
+
storagePath: signed.storagePath,
|
|
5749
|
+
fileName: resolvedName,
|
|
5750
|
+
fileType: contentType || signed.fileType,
|
|
5751
|
+
sha256: sha256Hex(bytes),
|
|
5752
|
+
size: bytes.byteLength
|
|
5753
|
+
});
|
|
5754
|
+
}
|
|
5755
|
+
if (base64Data) {
|
|
5572
5756
|
if (!fileName) {
|
|
5573
5757
|
throw new Error("fileName is required when using base64Data.");
|
|
5574
5758
|
}
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5759
|
+
if (base64ByteLength(base64Data) > MAX_ATTACHMENT_SIZE) {
|
|
5760
|
+
throw new Error(`File is over the 5MB attachment limit. Use the harmony_request_card_attachment_upload_url + harmony_finalize_card_attachment handshake for large files.`);
|
|
5761
|
+
}
|
|
5762
|
+
return await client3.uploadCardAttachment(cardId, {
|
|
5763
|
+
fileName,
|
|
5764
|
+
data: base64Data,
|
|
5765
|
+
fileType: contentType
|
|
5766
|
+
});
|
|
5578
5767
|
}
|
|
5579
|
-
|
|
5580
|
-
fileName,
|
|
5581
|
-
data,
|
|
5582
|
-
fileType: contentType
|
|
5583
|
-
});
|
|
5584
|
-
return result;
|
|
5768
|
+
throw new Error("Provide either filePath or base64Data.");
|
|
5585
5769
|
}
|
|
5586
5770
|
case "harmony_upload_artifact": {
|
|
5587
5771
|
const title = args.title != null ? z.string().parse(args.title) : undefined;
|
|
5588
5772
|
const cardId = args.cardId != null ? z.string().uuid().parse(args.cardId) : undefined;
|
|
5589
5773
|
const planId = args.planId != null ? z.string().uuid().parse(args.planId) : undefined;
|
|
5590
5774
|
const workspaceId = args.workspaceId != null ? z.string().uuid().parse(args.workspaceId) : undefined;
|
|
5591
|
-
|
|
5592
|
-
if (anchors.length !== 1) {
|
|
5593
|
-
throw new Error("Provide exactly one of cardId, planId, or workspaceId.");
|
|
5594
|
-
}
|
|
5775
|
+
requireExactlyOneScope({ cardId, planId, workspaceId });
|
|
5595
5776
|
const filePath = args.filePath != null ? z.string().parse(args.filePath) : undefined;
|
|
5596
5777
|
const base64Data = args.base64Data != null ? z.string().parse(args.base64Data) : undefined;
|
|
5597
5778
|
if (filePath && base64Data) {
|
|
5598
5779
|
throw new Error("Provide either filePath or base64Data, not both.");
|
|
5599
5780
|
}
|
|
5600
|
-
let data;
|
|
5601
|
-
let inferredTitle = title;
|
|
5602
5781
|
if (filePath) {
|
|
5603
|
-
const bytes = await
|
|
5604
|
-
|
|
5605
|
-
|
|
5782
|
+
const bytes = await readFileForUpload(filePath, MAX_ARTIFACT_SIZE, "artifact");
|
|
5783
|
+
const resolvedTitle = title || basename(filePath);
|
|
5784
|
+
const signed = await client3.requestArtifactUploadUrl({
|
|
5785
|
+
title: resolvedTitle,
|
|
5786
|
+
cardId,
|
|
5787
|
+
planId,
|
|
5788
|
+
workspaceId,
|
|
5789
|
+
contentType: "text/html",
|
|
5790
|
+
size: bytes.byteLength
|
|
5791
|
+
});
|
|
5792
|
+
await putToSignedUrl(signed.uploadUrl, bytes, "text/html");
|
|
5793
|
+
return await client3.finalizeArtifact({
|
|
5794
|
+
storagePath: signed.storagePath,
|
|
5795
|
+
sha256: sha256Hex(bytes),
|
|
5796
|
+
size: bytes.byteLength,
|
|
5797
|
+
title: resolvedTitle,
|
|
5798
|
+
cardId,
|
|
5799
|
+
planId,
|
|
5800
|
+
workspaceId
|
|
5801
|
+
});
|
|
5802
|
+
}
|
|
5803
|
+
if (base64Data) {
|
|
5804
|
+
if (base64ByteLength(base64Data) > MAX_ARTIFACT_SIZE) {
|
|
5805
|
+
throw new Error(`Artifact is over the 2MB limit. Use the harmony_request_artifact_upload_url + harmony_finalize_artifact handshake for large files.`);
|
|
5606
5806
|
}
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5611
|
-
|
|
5612
|
-
|
|
5807
|
+
return await client3.uploadArtifact({
|
|
5808
|
+
title,
|
|
5809
|
+
cardId,
|
|
5810
|
+
planId,
|
|
5811
|
+
workspaceId,
|
|
5812
|
+
data: base64Data
|
|
5813
|
+
});
|
|
5613
5814
|
}
|
|
5614
|
-
|
|
5615
|
-
|
|
5815
|
+
throw new Error("Provide either filePath or base64Data.");
|
|
5816
|
+
}
|
|
5817
|
+
case "harmony_request_artifact_upload_url": {
|
|
5818
|
+
const title = args.title != null ? z.string().parse(args.title) : undefined;
|
|
5819
|
+
const cardId = args.cardId != null ? z.string().uuid().parse(args.cardId) : undefined;
|
|
5820
|
+
const planId = args.planId != null ? z.string().uuid().parse(args.planId) : undefined;
|
|
5821
|
+
const workspaceId = args.workspaceId != null ? z.string().uuid().parse(args.workspaceId) : undefined;
|
|
5822
|
+
requireExactlyOneScope({ cardId, planId, workspaceId });
|
|
5823
|
+
const contentType = args.contentType != null ? z.string().parse(args.contentType) : undefined;
|
|
5824
|
+
const size = args.size != null ? z.number().positive().parse(args.size) : undefined;
|
|
5825
|
+
if (size != null && size > MAX_ARTIFACT_SIZE) {
|
|
5826
|
+
throw new Error(`Declared size ${size} bytes is over the ${MAX_ARTIFACT_SIZE}-byte (2MB) artifact limit.`);
|
|
5827
|
+
}
|
|
5828
|
+
return await client3.requestArtifactUploadUrl({
|
|
5829
|
+
title,
|
|
5616
5830
|
cardId,
|
|
5617
5831
|
planId,
|
|
5618
5832
|
workspaceId,
|
|
5619
|
-
|
|
5833
|
+
contentType,
|
|
5834
|
+
size
|
|
5835
|
+
});
|
|
5836
|
+
}
|
|
5837
|
+
case "harmony_finalize_artifact": {
|
|
5838
|
+
const storagePath = z.string().parse(args.storagePath);
|
|
5839
|
+
const title = args.title != null ? z.string().parse(args.title) : undefined;
|
|
5840
|
+
const cardId = args.cardId != null ? z.string().uuid().parse(args.cardId) : undefined;
|
|
5841
|
+
const planId = args.planId != null ? z.string().uuid().parse(args.planId) : undefined;
|
|
5842
|
+
const workspaceId = args.workspaceId != null ? z.string().uuid().parse(args.workspaceId) : undefined;
|
|
5843
|
+
requireExactlyOneScope({ cardId, planId, workspaceId });
|
|
5844
|
+
const sha256 = args.sha256 != null ? z.string().parse(args.sha256) : undefined;
|
|
5845
|
+
const size = args.size != null ? z.number().positive().parse(args.size) : undefined;
|
|
5846
|
+
return await client3.finalizeArtifact({
|
|
5847
|
+
storagePath,
|
|
5848
|
+
sha256,
|
|
5849
|
+
size,
|
|
5850
|
+
title,
|
|
5851
|
+
cardId,
|
|
5852
|
+
planId,
|
|
5853
|
+
workspaceId
|
|
5854
|
+
});
|
|
5855
|
+
}
|
|
5856
|
+
case "harmony_request_card_attachment_upload_url": {
|
|
5857
|
+
const cardId = z.string().uuid().parse(args.cardId);
|
|
5858
|
+
const fileName = z.string().parse(args.fileName);
|
|
5859
|
+
const fileType = args.fileType != null ? z.string().parse(args.fileType) : undefined;
|
|
5860
|
+
const size = z.number().positive().parse(args.size);
|
|
5861
|
+
if (size > MAX_ATTACHMENT_SIZE) {
|
|
5862
|
+
throw new Error(`Declared size ${size} bytes is over the ${MAX_ATTACHMENT_SIZE}-byte (5MB) attachment limit.`);
|
|
5863
|
+
}
|
|
5864
|
+
return await client3.requestCardAttachmentUploadUrl(cardId, {
|
|
5865
|
+
fileName,
|
|
5866
|
+
fileType,
|
|
5867
|
+
size
|
|
5868
|
+
});
|
|
5869
|
+
}
|
|
5870
|
+
case "harmony_finalize_card_attachment": {
|
|
5871
|
+
const cardId = z.string().uuid().parse(args.cardId);
|
|
5872
|
+
const storagePath = z.string().parse(args.storagePath);
|
|
5873
|
+
const fileName = z.string().parse(args.fileName);
|
|
5874
|
+
const fileType = args.fileType != null ? z.string().parse(args.fileType) : undefined;
|
|
5875
|
+
const sha256 = args.sha256 != null ? z.string().parse(args.sha256) : undefined;
|
|
5876
|
+
const size = args.size != null ? z.number().positive().parse(args.size) : undefined;
|
|
5877
|
+
return await client3.finalizeCardAttachment(cardId, {
|
|
5878
|
+
storagePath,
|
|
5879
|
+
fileName,
|
|
5880
|
+
fileType,
|
|
5881
|
+
sha256,
|
|
5882
|
+
size
|
|
5620
5883
|
});
|
|
5621
|
-
return result;
|
|
5622
5884
|
}
|
|
5623
5885
|
case "harmony_share_artifact": {
|
|
5624
5886
|
const artifactId = z.string().uuid().parse(args.artifactId);
|
|
@@ -6745,7 +7007,7 @@ class HarmonyMCPServer {
|
|
|
6745
7007
|
}
|
|
6746
7008
|
|
|
6747
7009
|
// src/tui/setup.ts
|
|
6748
|
-
import { createHash as
|
|
7010
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
6749
7011
|
import {
|
|
6750
7012
|
existsSync as existsSync8,
|
|
6751
7013
|
lstatSync,
|
|
@@ -7940,7 +8202,7 @@ ${summary}`);
|
|
|
7940
8202
|
}
|
|
7941
8203
|
try {
|
|
7942
8204
|
const updateCheckFetched = await client3.fetchSkill("hmy-update-check");
|
|
7943
|
-
const actualHash =
|
|
8205
|
+
const actualHash = createHash5("sha256").update(updateCheckFetched.content).digest("hex");
|
|
7944
8206
|
if (actualHash !== updateCheckFetched.sha256) {
|
|
7945
8207
|
throw new Error(`hmy-update-check integrity check failed: expected ${updateCheckFetched.sha256}, got ${actualHash}`);
|
|
7946
8208
|
}
|