@sideboard-ai/core 0.1.202 → 0.1.204
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/{abletime-KGPD3UUJ.js → abletime-S3UHQZVW.js} +4 -2
- package/dist/{abletime-345SE3B4.js → abletime-TONBQP4O.js} +4 -2
- package/dist/abletime-oauth-AVCEO2DY.js +314 -0
- package/dist/abletime-oauth-SD4SZY5U.js +52 -0
- package/dist/abletime-rest-6ODSXV7G.js +25 -0
- package/dist/abletime-rest-J2OBB4VA.js +24 -0
- package/dist/agents/cursor-runner.js +1 -1
- package/dist/{agents-573ZDIX6.js → agents-67K4BQFJ.js} +4 -4
- package/dist/{agents-OXX3ONVY.js → agents-BVOJNHV6.js} +5 -5
- package/dist/{app-settings-V6IHESEQ.js → app-settings-LGHMNHSP.js} +1 -1
- package/dist/{app-settings-AXCURTZJ.js → app-settings-YEPF46IJ.js} +1 -1
- package/dist/chunk-3K257PCS.js +393 -0
- package/dist/{chunk-54RSAMBH.js → chunk-5SMS6QTO.js} +2 -2
- package/dist/chunk-6Q7DFVDQ.js +309 -0
- package/dist/chunk-CYLDJWRK.js +391 -0
- package/dist/{chunk-PGQGP4FD.js → chunk-FO2NTJ7L.js} +37 -219
- package/dist/{chunk-7NKY2OX7.js → chunk-FO45DMJ5.js} +125 -109
- package/dist/{chunk-CQ5R3VPP.js → chunk-KZ7PI7FE.js} +18 -0
- package/dist/{chunk-7AHAABKN.js → chunk-QAVWH2RQ.js} +37 -229
- package/dist/{chunk-CXFW5LIH.js → chunk-QFBBUFD4.js} +38 -3
- package/dist/{chunk-RPX6VDW7.js → chunk-QUW5D62C.js} +34 -20
- package/dist/chunk-SGUVAK66.js +262 -0
- package/dist/{chunk-27GGXX27.js → chunk-ULZLWQBS.js} +128 -112
- package/dist/{chunk-LJHC62LZ.js → chunk-VIPA75ZA.js} +2 -2
- package/dist/chunk-W6VM36YO.js +272 -0
- package/dist/{chunk-NIVF5NDN.js → chunk-WF33LOP4.js} +44 -6
- package/dist/{chunk-STPZQR5B.js → chunk-WVATAIF4.js} +34 -20
- package/dist/{chunk-ISV5IFH3.js → chunk-X743YN5Y.js} +38 -3
- package/dist/{chunk-A2TAKYSG.js → chunk-YOSTWSNC.js} +27 -7
- package/dist/{coordinator-prompt-BH4EHFOO.js → coordinator-prompt-NPT555BO.js} +3 -3
- package/dist/{coordinator-prompt-TY5FHAXC.js → coordinator-prompt-WEPXXLLX.js} +3 -3
- package/dist/{global-workspace-NLLAPQJI.js → global-workspace-2I2T7FL5.js} +3 -3
- package/dist/{global-workspace-5AZEEQRU.js → global-workspace-NSILADOM.js} +3 -3
- package/dist/index.cjs +1137 -213
- package/dist/index.d.cts +87 -13
- package/dist/index.d.ts +87 -13
- package/dist/index.js +94 -19
- package/dist/mcp/run-stdio.cjs +1023 -180
- package/dist/mcp/run-stdio.js +22 -20
- package/dist/{orchestrator-JNSQDRZI.js → orchestrator-CMAVNELS.js} +6 -6
- package/dist/{orchestrator-NCYKEI3E.js → orchestrator-I7GFXLHF.js} +6 -6
- package/dist/{workspaces-RP76JH3J.js → workspaces-BOC6M7BW.js} +3 -3
- package/dist/{workspaces-PEWYWVHZ.js → workspaces-RFGZBUAR.js} +3 -3
- package/dist/{worktree-72TZWUSH.js → worktree-G3ZLM4DC.js} +4 -2
- package/dist/{worktree-ZQEUKSNE.js → worktree-WSUQMMK4.js} +4 -2
- package/package.json +1 -1
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
httpFetch
|
|
5
|
+
} from "./chunk-VKQGAWHY.js";
|
|
6
|
+
import {
|
|
7
|
+
getAbleTimeHost,
|
|
8
|
+
isAbleTimeConnected
|
|
9
|
+
} from "./chunk-X743YN5Y.js";
|
|
10
|
+
|
|
11
|
+
// src/integrations/abletime-mcp.ts
|
|
12
|
+
var DEFAULT_ABLETIME_HOST = "https://track.abletime.com";
|
|
13
|
+
var ABLETIME_MCP_PATH = "/api/public/v2/mcp";
|
|
14
|
+
var ABLETIME_MCP_PM_PATH = "/api/public/v2/mcp/pm";
|
|
15
|
+
var MCP_PROTOCOL_VERSION = "2025-03-26";
|
|
16
|
+
var ABLETIME_PM_TOOL_NAMES = [
|
|
17
|
+
"set_task_assignee",
|
|
18
|
+
"set_task_priority",
|
|
19
|
+
"set_task_stage",
|
|
20
|
+
"set_task_dependency",
|
|
21
|
+
"set_task_blocked",
|
|
22
|
+
"set_task_locked",
|
|
23
|
+
"set_task_schedule",
|
|
24
|
+
"clear_task_schedule",
|
|
25
|
+
"archive_task",
|
|
26
|
+
"delete_task"
|
|
27
|
+
];
|
|
28
|
+
function abletimeToolUsesPm(name) {
|
|
29
|
+
return ABLETIME_PM_TOOL_NAMES.includes(name);
|
|
30
|
+
}
|
|
31
|
+
function normalizeAbleTimeHost(raw) {
|
|
32
|
+
const trimmed = raw?.trim() || DEFAULT_ABLETIME_HOST;
|
|
33
|
+
const withScheme = /^https?:\/\//i.test(trimmed) ? trimmed : `https://${trimmed}`;
|
|
34
|
+
return withScheme.replace(/\/+$/, "");
|
|
35
|
+
}
|
|
36
|
+
function abletimeMcpUrl(host, opts) {
|
|
37
|
+
const path = opts?.pm ? ABLETIME_MCP_PM_PATH : ABLETIME_MCP_PATH;
|
|
38
|
+
return `${normalizeAbleTimeHost(host)}${path}`;
|
|
39
|
+
}
|
|
40
|
+
var ABLETIME_PAT_PREFIX = "apt_";
|
|
41
|
+
var ABLETIME_ORG_KEY_PREFIX = "atk_";
|
|
42
|
+
var ABLETIME_OAUTH_TOKEN_PREFIX = "acn_";
|
|
43
|
+
var ORG_KEY_HINT = "AbleTime MCP needs a personal access token (apt_\u2026) from Edit Profile \u2192 API Access, not an organization API key (atk_\u2026) from Settings \u2192 Integrations \u2192 API Keys.";
|
|
44
|
+
var REJECTED_CREDENTIAL_HINT = "AbleTime rejected this credential (unknown, revoked, or expired). Reconnect via browser, or paste a personal access token (apt_\u2026) from Edit Profile \u2192 API Access. Organization API keys (atk_\u2026) use REST, not MCP.";
|
|
45
|
+
var REWRITE_APPLIED = /— Enable Agent access \(MCP\)|— AbleTime MCP needs a personal access token|— AbleTime plan does not include API access|— AbleTime rejected this credential/;
|
|
46
|
+
function normalizeAbleTimeCredential(raw) {
|
|
47
|
+
return raw.trim().replace(/^bearer\s+/i, "").trim();
|
|
48
|
+
}
|
|
49
|
+
function ableTimeCredentialKind(raw) {
|
|
50
|
+
const token = normalizeAbleTimeCredential(raw);
|
|
51
|
+
const lower = token.toLowerCase();
|
|
52
|
+
if (lower.startsWith(ABLETIME_PAT_PREFIX)) return "pat";
|
|
53
|
+
if (lower.startsWith(ABLETIME_ORG_KEY_PREFIX)) return "org";
|
|
54
|
+
if (lower.startsWith(ABLETIME_OAUTH_TOKEN_PREFIX) || token.startsWith("eyJ")) return "oauth";
|
|
55
|
+
return "unknown";
|
|
56
|
+
}
|
|
57
|
+
function ableTimeUsesRest(raw) {
|
|
58
|
+
const token = normalizeAbleTimeCredential(raw);
|
|
59
|
+
const kind = ableTimeCredentialKind(token);
|
|
60
|
+
if (kind === "org") return true;
|
|
61
|
+
if (kind === "oauth") return token.startsWith("eyJ");
|
|
62
|
+
return kind === "unknown";
|
|
63
|
+
}
|
|
64
|
+
function isAbleTimeRejectedCredential(message) {
|
|
65
|
+
return /INTEGRATION_KEY_INVALID|INTEGRATION_KEY_MISSING|INTEGRATION_PAT_REQUIRED|\b401\b/i.test(
|
|
66
|
+
message
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
function assertAbleTimeMcpCredential(raw) {
|
|
70
|
+
const token = normalizeAbleTimeCredential(raw);
|
|
71
|
+
if (!token) {
|
|
72
|
+
throw new Error("AbleTime personal access token is required");
|
|
73
|
+
}
|
|
74
|
+
if (ableTimeCredentialKind(token) === "org") {
|
|
75
|
+
throw new Error(ORG_KEY_HINT);
|
|
76
|
+
}
|
|
77
|
+
return token;
|
|
78
|
+
}
|
|
79
|
+
function assertAbleTimeCredential(raw) {
|
|
80
|
+
const token = normalizeAbleTimeCredential(raw);
|
|
81
|
+
if (!token) {
|
|
82
|
+
throw new Error("AbleTime API key or personal access token is required");
|
|
83
|
+
}
|
|
84
|
+
return token;
|
|
85
|
+
}
|
|
86
|
+
function rewriteAbleTimeError(message) {
|
|
87
|
+
if (REWRITE_APPLIED.test(message)) return message;
|
|
88
|
+
if (/INTEGRATION_AGENT_ACCESS_DISABLED/i.test(message)) {
|
|
89
|
+
return `${message} \u2014 Enable Agent access (MCP) in AbleTime Settings \u2192 Integrations \u2192 API Keys.`;
|
|
90
|
+
}
|
|
91
|
+
if (/INTEGRATION_PAT_REQUIRED/i.test(message)) {
|
|
92
|
+
return `${message} \u2014 ${ORG_KEY_HINT}`;
|
|
93
|
+
}
|
|
94
|
+
if (/INTEGRATION_PLAN_REQUIRED/i.test(message)) {
|
|
95
|
+
return `${message} \u2014 AbleTime plan does not include API access.`;
|
|
96
|
+
}
|
|
97
|
+
if (/INTEGRATION_KEY_INVALID|INTEGRATION_KEY_MISSING|401|unauthorized|invalid token/i.test(message)) {
|
|
98
|
+
return `${message} \u2014 ${REJECTED_CREDENTIAL_HINT}`;
|
|
99
|
+
}
|
|
100
|
+
return message;
|
|
101
|
+
}
|
|
102
|
+
function asRecord(value) {
|
|
103
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
104
|
+
}
|
|
105
|
+
function parseSseJson(body) {
|
|
106
|
+
const blocks = body.split(/\n\n+/);
|
|
107
|
+
let last;
|
|
108
|
+
for (const block of blocks) {
|
|
109
|
+
const data = block.split("\n").filter((line) => line.startsWith("data:")).map((line) => line.slice(5).trim()).filter((line) => line && line !== "[DONE]").join("\n");
|
|
110
|
+
if (!data) continue;
|
|
111
|
+
try {
|
|
112
|
+
last = JSON.parse(data);
|
|
113
|
+
} catch {
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (last !== void 0) return last;
|
|
117
|
+
try {
|
|
118
|
+
return JSON.parse(body);
|
|
119
|
+
} catch {
|
|
120
|
+
throw new Error(`AbleTime MCP returned a non-JSON response: ${body.slice(0, 200)}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function unwrapToolResult(result) {
|
|
124
|
+
const record = asRecord(result);
|
|
125
|
+
if (!record) return result;
|
|
126
|
+
const content = record.content;
|
|
127
|
+
if (Array.isArray(content)) {
|
|
128
|
+
const texts = content.map((part) => {
|
|
129
|
+
const item = asRecord(part);
|
|
130
|
+
if (!item) return "";
|
|
131
|
+
return typeof item.text === "string" ? item.text : "";
|
|
132
|
+
}).filter(Boolean);
|
|
133
|
+
if (texts.length === 1) {
|
|
134
|
+
const text = texts[0];
|
|
135
|
+
try {
|
|
136
|
+
return JSON.parse(text);
|
|
137
|
+
} catch {
|
|
138
|
+
return text;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (texts.length > 1) return texts.join("\n");
|
|
142
|
+
}
|
|
143
|
+
if (record.structuredContent != null) return record.structuredContent;
|
|
144
|
+
if (record.isError === true) {
|
|
145
|
+
const message = typeof record.message === "string" ? record.message : textsFromUnknown(result) || "AbleTime tool failed";
|
|
146
|
+
throw new Error(message);
|
|
147
|
+
}
|
|
148
|
+
return result;
|
|
149
|
+
}
|
|
150
|
+
function textsFromUnknown(value) {
|
|
151
|
+
const record = asRecord(value);
|
|
152
|
+
if (!record) return "";
|
|
153
|
+
if (typeof record.message === "string") return record.message;
|
|
154
|
+
if (typeof record.error === "string") return record.error;
|
|
155
|
+
return "";
|
|
156
|
+
}
|
|
157
|
+
async function abletimeMcpRequest(method, params, opts) {
|
|
158
|
+
const rawToken = opts?.token ?? await import("./abletime-oauth-AVCEO2DY.js").then((m) => m.ensureAbleTimeAccessToken());
|
|
159
|
+
if (!rawToken?.trim()) {
|
|
160
|
+
throw new Error("AbleTime is not connected \u2014 paste a personal access token in Account settings");
|
|
161
|
+
}
|
|
162
|
+
const token = assertAbleTimeMcpCredential(rawToken);
|
|
163
|
+
const url = abletimeMcpUrl(
|
|
164
|
+
opts?.host ?? (opts?.token ? DEFAULT_ABLETIME_HOST : getAbleTimeHost()),
|
|
165
|
+
{ pm: opts?.pm }
|
|
166
|
+
);
|
|
167
|
+
const res = await httpFetch(url, {
|
|
168
|
+
method: "POST",
|
|
169
|
+
headers: {
|
|
170
|
+
"Content-Type": "application/json",
|
|
171
|
+
Accept: "application/json, text/event-stream",
|
|
172
|
+
Authorization: `Bearer ${token}`,
|
|
173
|
+
"MCP-Protocol-Version": MCP_PROTOCOL_VERSION
|
|
174
|
+
},
|
|
175
|
+
body: JSON.stringify({
|
|
176
|
+
jsonrpc: "2.0",
|
|
177
|
+
id: 1,
|
|
178
|
+
method,
|
|
179
|
+
...params === void 0 ? {} : { params }
|
|
180
|
+
})
|
|
181
|
+
});
|
|
182
|
+
const body = await res.text().catch(() => "");
|
|
183
|
+
if (!res.ok) {
|
|
184
|
+
throw new Error(
|
|
185
|
+
rewriteAbleTimeError(
|
|
186
|
+
`AbleTime MCP error ${res.status}${body ? `: ${body.slice(0, 240)}` : ""}`
|
|
187
|
+
)
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
const contentType = res.headers.get("content-type") ?? "";
|
|
191
|
+
const parsed = contentType.includes("text/event-stream") ? parseSseJson(body) : (() => {
|
|
192
|
+
try {
|
|
193
|
+
return JSON.parse(body);
|
|
194
|
+
} catch {
|
|
195
|
+
return parseSseJson(body);
|
|
196
|
+
}
|
|
197
|
+
})();
|
|
198
|
+
const rpc = asRecord(parsed);
|
|
199
|
+
if (rpc?.error) {
|
|
200
|
+
const detail = typeof rpc.error.message === "string" && rpc.error.message.trim() ? rpc.error.message : `AbleTime MCP error ${rpc.error.code ?? ""}`.trim();
|
|
201
|
+
throw new Error(rewriteAbleTimeError(detail));
|
|
202
|
+
}
|
|
203
|
+
if (rpc && "result" in rpc) return rpc.result;
|
|
204
|
+
return parsed;
|
|
205
|
+
}
|
|
206
|
+
async function initializeIfNeeded(opts) {
|
|
207
|
+
try {
|
|
208
|
+
await abletimeMcpRequest(
|
|
209
|
+
"initialize",
|
|
210
|
+
{
|
|
211
|
+
protocolVersion: MCP_PROTOCOL_VERSION,
|
|
212
|
+
capabilities: {},
|
|
213
|
+
clientInfo: { name: "sideboard", version: "1.0.0" }
|
|
214
|
+
},
|
|
215
|
+
opts
|
|
216
|
+
);
|
|
217
|
+
} catch (err) {
|
|
218
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
219
|
+
if (/already initialized|not (required|supported)|method not found|-32601/i.test(message)) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
throw err;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
async function callAbleTimeTool(name, args = {}, opts) {
|
|
226
|
+
if (!opts?.token && !isAbleTimeConnected()) {
|
|
227
|
+
throw new Error("AbleTime is not connected \u2014 paste a personal access token in Account settings");
|
|
228
|
+
}
|
|
229
|
+
const rawToken = opts?.token ?? await import("./abletime-oauth-AVCEO2DY.js").then((m) => m.ensureAbleTimeAccessToken());
|
|
230
|
+
if (rawToken && ableTimeUsesRest(rawToken)) {
|
|
231
|
+
const { callAbleTimeRestTool } = await import("./abletime-rest-6ODSXV7G.js");
|
|
232
|
+
return callAbleTimeRestTool(name, args, { ...opts, token: rawToken });
|
|
233
|
+
}
|
|
234
|
+
const requestOpts = { ...opts, pm: opts?.pm ?? abletimeToolUsesPm(name) };
|
|
235
|
+
const call = () => abletimeMcpRequest("tools/call", { name, arguments: args }, requestOpts).then((result) => {
|
|
236
|
+
return unwrapToolResult(result);
|
|
237
|
+
});
|
|
238
|
+
try {
|
|
239
|
+
return await call();
|
|
240
|
+
} catch (err) {
|
|
241
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
242
|
+
if (/initialize|session|not initialized|-32000/i.test(message)) {
|
|
243
|
+
await initializeIfNeeded(requestOpts);
|
|
244
|
+
return await call();
|
|
245
|
+
}
|
|
246
|
+
if (rawToken && ableTimeUsesRest(rawToken) && isAbleTimeRejectedCredential(message)) {
|
|
247
|
+
const { callAbleTimeRestTool } = await import("./abletime-rest-6ODSXV7G.js");
|
|
248
|
+
return callAbleTimeRestTool(name, args, { ...opts, token: rawToken });
|
|
249
|
+
}
|
|
250
|
+
throw err instanceof Error ? new Error(rewriteAbleTimeError(err.message)) : err;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export {
|
|
255
|
+
DEFAULT_ABLETIME_HOST,
|
|
256
|
+
normalizeAbleTimeHost,
|
|
257
|
+
normalizeAbleTimeCredential,
|
|
258
|
+
ableTimeCredentialKind,
|
|
259
|
+
assertAbleTimeCredential,
|
|
260
|
+
rewriteAbleTimeError,
|
|
261
|
+
callAbleTimeTool
|
|
262
|
+
};
|