pindrop 0.1.2 → 0.1.4
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/cli.mjs +233 -24
- package/lib/auth.mjs +26 -1
- package/lib/client.mjs +44 -1
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -3,17 +3,20 @@ import { mkdirSync, realpathSync, writeFileSync } from "node:fs";
|
|
|
3
3
|
import { dirname, join, resolve } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import {
|
|
6
|
+
getLinkedProject,
|
|
6
7
|
getSavedProfile,
|
|
7
8
|
loginWithBrowser,
|
|
9
|
+
openInBrowser,
|
|
8
10
|
resolveMcpUrl,
|
|
9
11
|
revokeAndLogout,
|
|
10
12
|
saveApiKeyProfile,
|
|
13
|
+
saveLinkedProject,
|
|
11
14
|
} from "./lib/auth.mjs";
|
|
12
|
-
import { CliError, callPinDropTool } from "./lib/client.mjs";
|
|
15
|
+
import { CliError, callPinDropTool, callSandboxApi } from "./lib/client.mjs";
|
|
13
16
|
import { inferProjectHint, inferSiteUrl } from "./lib/project.mjs";
|
|
14
17
|
import { installSkillFiles } from "./lib/skill.mjs";
|
|
15
18
|
|
|
16
|
-
const VERSION = "0.1.
|
|
19
|
+
const VERSION = "0.1.4";
|
|
17
20
|
|
|
18
21
|
function parseArgv(argv) {
|
|
19
22
|
const positionals = [];
|
|
@@ -27,6 +30,9 @@ function parseArgv(argv) {
|
|
|
27
30
|
"full",
|
|
28
31
|
"resolved",
|
|
29
32
|
"open",
|
|
33
|
+
"watch",
|
|
34
|
+
"w",
|
|
35
|
+
"once",
|
|
30
36
|
"no-browser",
|
|
31
37
|
"no-login",
|
|
32
38
|
"force",
|
|
@@ -137,6 +143,10 @@ function parsePinNumber(raw) {
|
|
|
137
143
|
async function resolveProjectIdForPin({ mcpUrl, flags, autoLogin }) {
|
|
138
144
|
const explicit = flagStr(flags, "project", "p", "project-id");
|
|
139
145
|
if (explicit) return explicit;
|
|
146
|
+
const linked = getLinkedProject(mcpUrl);
|
|
147
|
+
if (linked?.projectId && !flagStr(flags, "hint")) {
|
|
148
|
+
return linked.projectId;
|
|
149
|
+
}
|
|
140
150
|
const hint = flagStr(flags, "hint") || inferProjectHint();
|
|
141
151
|
const res = await callPinDropTool({
|
|
142
152
|
mcpUrl,
|
|
@@ -175,9 +185,20 @@ function formatPinCompact(pin) {
|
|
|
175
185
|
const parts = [`#${num}`, path, JSON.stringify(comment)];
|
|
176
186
|
if (vp) parts.push(vp);
|
|
177
187
|
parts.push(status);
|
|
188
|
+
if (pin.pinShareUrl) parts.push(pin.pinShareUrl);
|
|
178
189
|
return parts.join(" · ");
|
|
179
190
|
}
|
|
180
191
|
|
|
192
|
+
function writeProjectNextSteps(projectId) {
|
|
193
|
+
const flag = projectId ? ` --project ${projectId}` : "";
|
|
194
|
+
process.stdout.write(
|
|
195
|
+
`Next: send the review link (no client account or script tag needed).\n`,
|
|
196
|
+
);
|
|
197
|
+
process.stdout.write(
|
|
198
|
+
`Commands: npx -y pindrop pins${flag} · npx -y pindrop pin <n> --screenshot${flag} · npx -y pindrop resolve <n>${flag} --comment "<what changed>"\n`,
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
181
202
|
function printHelp() {
|
|
182
203
|
process.stdout.write(`pindrop v${VERSION} — visual client feedback pins for your coding agent
|
|
183
204
|
|
|
@@ -188,9 +209,10 @@ Usage:
|
|
|
188
209
|
pindrop status Show connected account, plan, and limits
|
|
189
210
|
|
|
190
211
|
pindrop projects List active PinDrop projects
|
|
191
|
-
pindrop create [url] [--
|
|
192
|
-
pindrop
|
|
193
|
-
|
|
212
|
+
pindrop create [url] [--open] Create (or reuse) a review link for a live URL
|
|
213
|
+
pindrop open [n] [--project <id>] Open the review link (or pin #n) in your browser
|
|
214
|
+
pindrop pins [--watch] [--once] [--project <id>] [--resolved] [--full] [--json]
|
|
215
|
+
List (or live-watch) pins for this repo
|
|
194
216
|
pindrop pin <n> [--screenshot [path]] [--project <id>] [--json]
|
|
195
217
|
Read full context (and optionally save screenshot)
|
|
196
218
|
pindrop comment <n> --body <text> Reply on a pin
|
|
@@ -202,8 +224,10 @@ Usage:
|
|
|
202
224
|
pindrop delete <n> Soft-delete a pin
|
|
203
225
|
pindrop drop --path <p> --x <n> --y <n> --vw <n> --comment <text>
|
|
204
226
|
Drop a new pin from measured coordinates
|
|
205
|
-
pindrop sandbox
|
|
206
|
-
|
|
227
|
+
pindrop sandbox pins <id> <code> List open pins on a /try sandbox (no signup)
|
|
228
|
+
pindrop sandbox resolve <id> <code> <n> --new-text <text>
|
|
229
|
+
Resolve a /try sandbox pin live (no signup)
|
|
230
|
+
pindrop sandbox claim <id> <code> Claim a /try sandbox into your PinDrop account
|
|
207
231
|
pindrop billing [--action trial|upgrade|manage] [--plan pro|studio]
|
|
208
232
|
Get a secure browser checkout/billing link
|
|
209
233
|
pindrop skill install [--global|--local] [--agent <id>] [--force]
|
|
@@ -326,25 +350,37 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
326
350
|
openBrowser,
|
|
327
351
|
onAuthorizeUrl: announceBrowserAuth,
|
|
328
352
|
});
|
|
353
|
+
const p = res.structured || {};
|
|
354
|
+
if (p.projectId) {
|
|
355
|
+
saveLinkedProject(mcpUrl, process.cwd(), {
|
|
356
|
+
projectId: p.projectId,
|
|
357
|
+
shareUrl: p.shareUrl,
|
|
358
|
+
targetUrl: p.targetUrl || targetUrl,
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
const shouldOpen = Boolean((flags.open || p.isFirstProject) && openBrowser && p.shareUrl);
|
|
362
|
+
if (shouldOpen) openInBrowser(p.shareUrl);
|
|
329
363
|
if (asJson) {
|
|
330
364
|
printJson({
|
|
331
365
|
ok: true,
|
|
332
366
|
inferredFrom,
|
|
367
|
+
opened: shouldOpen,
|
|
333
368
|
skills: skillResults,
|
|
334
369
|
project: res.structured,
|
|
335
370
|
});
|
|
336
371
|
} else {
|
|
337
|
-
const p = res.structured || {};
|
|
338
372
|
if (inferredFrom) {
|
|
339
373
|
process.stderr.write(`Detected site URL ${targetUrl} from ${inferredFrom}\n`);
|
|
340
374
|
}
|
|
341
375
|
process.stdout.write(`Review link: ${p.shareUrl || res.text}\n`);
|
|
342
376
|
if (p.projectId) process.stdout.write(`Project ID: ${p.projectId}\n`);
|
|
377
|
+
if (shouldOpen) process.stderr.write(`Opened review link in your browser.\n`);
|
|
343
378
|
for (const r of skillResults) {
|
|
344
379
|
if (r.status === "installed") {
|
|
345
380
|
process.stdout.write(`Installed skill: ${r.path}\n`);
|
|
346
381
|
}
|
|
347
382
|
}
|
|
383
|
+
writeProjectNextSteps(p.projectId);
|
|
348
384
|
}
|
|
349
385
|
return 0;
|
|
350
386
|
}
|
|
@@ -401,22 +437,74 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
401
437
|
openBrowser,
|
|
402
438
|
onAuthorizeUrl: announceBrowserAuth,
|
|
403
439
|
});
|
|
440
|
+
const p = res.structured || {};
|
|
441
|
+
if (p.projectId) {
|
|
442
|
+
saveLinkedProject(mcpUrl, process.cwd(), {
|
|
443
|
+
projectId: p.projectId,
|
|
444
|
+
shareUrl: p.shareUrl,
|
|
445
|
+
targetUrl: p.targetUrl || targetUrl,
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
const shouldOpen = Boolean((flags.open || p.isFirstProject) && openBrowser && p.shareUrl);
|
|
449
|
+
if (shouldOpen) openInBrowser(p.shareUrl);
|
|
404
450
|
if (asJson) {
|
|
405
|
-
printJson({
|
|
451
|
+
printJson({
|
|
452
|
+
...(res.structured || {}),
|
|
453
|
+
...(inferredFrom ? { inferredFrom } : {}),
|
|
454
|
+
...(shouldOpen ? { opened: true } : {}),
|
|
455
|
+
});
|
|
406
456
|
} else {
|
|
407
|
-
const p = res.structured || {};
|
|
408
457
|
if (inferredFrom) {
|
|
409
458
|
process.stderr.write(`Detected site URL ${targetUrl} from ${inferredFrom}\n`);
|
|
410
459
|
}
|
|
411
460
|
process.stdout.write(`Review link: ${p.shareUrl || res.text}\n`);
|
|
412
461
|
if (p.projectId) process.stdout.write(`Project ID: ${p.projectId}\n`);
|
|
462
|
+
if (shouldOpen) process.stderr.write(`Opened review link in your browser.\n`);
|
|
413
463
|
if (p.wasReused) process.stdout.write(`Reused existing project for ${p.targetUrl || targetUrl}\n`);
|
|
464
|
+
writeProjectNextSteps(p.projectId);
|
|
465
|
+
}
|
|
466
|
+
return 0;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
case "open": {
|
|
470
|
+
if (positionals[1]) {
|
|
471
|
+
const pinNumber = parsePinNumber(positionals[1]);
|
|
472
|
+
const projectId = await resolveProjectIdForPin({ mcpUrl, flags, autoLogin });
|
|
473
|
+
const res = await callPinDropTool({
|
|
474
|
+
mcpUrl,
|
|
475
|
+
toolName: "pindrop_get_pin_context",
|
|
476
|
+
args: { projectId, pinNumber },
|
|
477
|
+
autoLogin,
|
|
478
|
+
openBrowser,
|
|
479
|
+
onAuthorizeUrl: announceBrowserAuth,
|
|
480
|
+
});
|
|
481
|
+
const url = res.structured?.pinShareUrl;
|
|
482
|
+
if (!url) throw new CliError(`Could not find share URL for pin #${pinNumber}.`, 3);
|
|
483
|
+
if (openBrowser) openInBrowser(url);
|
|
484
|
+
if (asJson) printJson({ url, projectId, pinNumber });
|
|
485
|
+
else process.stdout.write(`${url}\n`);
|
|
486
|
+
return 0;
|
|
487
|
+
}
|
|
488
|
+
const explicitProject = flagStr(flags, "project", "p", "project-id");
|
|
489
|
+
const linked = !explicitProject ? getLinkedProject(mcpUrl) : null;
|
|
490
|
+
let url = linked?.shareUrl || null;
|
|
491
|
+
let projectId = explicitProject || linked?.projectId || null;
|
|
492
|
+
if (!url) {
|
|
493
|
+
const resolvedId = projectId || (await resolveProjectIdForPin({ mcpUrl, flags, autoLogin }));
|
|
494
|
+
projectId = resolvedId;
|
|
495
|
+
url = `https://www.pindrop.page/s/${encodeURIComponent(resolvedId)}`;
|
|
414
496
|
}
|
|
497
|
+
if (openBrowser) openInBrowser(url);
|
|
498
|
+
if (asJson) printJson({ url, projectId });
|
|
499
|
+
else process.stdout.write(`${url}\n`);
|
|
415
500
|
return 0;
|
|
416
501
|
}
|
|
417
502
|
|
|
418
503
|
case "pins": {
|
|
419
|
-
const
|
|
504
|
+
const explicitProject = flagStr(flags, "project", "p", "project-id");
|
|
505
|
+
const linkedProject =
|
|
506
|
+
!explicitProject && !flagStr(flags, "hint") ? getLinkedProject(mcpUrl)?.projectId : undefined;
|
|
507
|
+
const projectId = explicitProject || linkedProject;
|
|
420
508
|
const hint = projectId ? undefined : flagStr(flags, "hint") || inferProjectHint();
|
|
421
509
|
const limit = flagInt(flags, "limit", "n");
|
|
422
510
|
const toolName = flags.resolved ? "pindrop_list_resolved_pins" : "pindrop_list_open_pins";
|
|
@@ -428,6 +516,73 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
428
516
|
...(flagStr(flags, "path") ? { path: flagStr(flags, "path") } : {}),
|
|
429
517
|
...(flagStr(flags, "priority") ? { priority: flagStr(flags, "priority") } : {}),
|
|
430
518
|
};
|
|
519
|
+
if (flags.watch || flags.w) {
|
|
520
|
+
const intervalSec = Math.max(1, flagNum(flags, "interval") ?? 3);
|
|
521
|
+
const once = Boolean(flags.once);
|
|
522
|
+
const seen = new Map();
|
|
523
|
+
let stopped = false;
|
|
524
|
+
const stop = () => {
|
|
525
|
+
stopped = true;
|
|
526
|
+
};
|
|
527
|
+
process.on("SIGINT", stop);
|
|
528
|
+
process.on("SIGTERM", stop);
|
|
529
|
+
process.stderr.write(
|
|
530
|
+
`Watching ${projectId || hint || "PinDrop"} for pins (every ${intervalSec}s; Ctrl+C to stop)…\n`,
|
|
531
|
+
);
|
|
532
|
+
try {
|
|
533
|
+
while (!stopped) {
|
|
534
|
+
const res = await callPinDropTool({
|
|
535
|
+
mcpUrl,
|
|
536
|
+
toolName,
|
|
537
|
+
args,
|
|
538
|
+
autoLogin,
|
|
539
|
+
openBrowser,
|
|
540
|
+
onAuthorizeUrl: announceBrowserAuth,
|
|
541
|
+
});
|
|
542
|
+
const s = res.structured || {};
|
|
543
|
+
if (s.scope === "unmatched" && Array.isArray(s.candidates) && s.candidates.length > 0) {
|
|
544
|
+
process.stderr.write("No project matched this folder. Pass --project <id>:\n");
|
|
545
|
+
for (const c of s.candidates) {
|
|
546
|
+
process.stderr.write(` ${c.id} · ${c.title || c.targetUrl} (${c.targetUrl})\n`);
|
|
547
|
+
}
|
|
548
|
+
return 3;
|
|
549
|
+
}
|
|
550
|
+
const pins = Array.isArray(s.pins) ? s.pins : [];
|
|
551
|
+
const changed = [];
|
|
552
|
+
for (const pin of pins) {
|
|
553
|
+
const key = String(pin.pinNumber ?? pin.number ?? pin.id ?? "");
|
|
554
|
+
const fp = JSON.stringify([
|
|
555
|
+
pin.status,
|
|
556
|
+
pin.comment,
|
|
557
|
+
Array.isArray(pin.thread) ? pin.thread.length : 0,
|
|
558
|
+
]);
|
|
559
|
+
if (seen.get(key) !== fp) {
|
|
560
|
+
seen.set(key, fp);
|
|
561
|
+
changed.push(pin);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
if (changed.length > 0) {
|
|
565
|
+
if (asJson) {
|
|
566
|
+
for (const pin of changed) {
|
|
567
|
+
process.stdout.write(JSON.stringify(pin) + "\n");
|
|
568
|
+
}
|
|
569
|
+
} else {
|
|
570
|
+
for (const pin of changed) {
|
|
571
|
+
process.stdout.write(formatPinCompact(pin) + "\n");
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
if (once) return 0;
|
|
575
|
+
}
|
|
576
|
+
if (stopped) break;
|
|
577
|
+
await new Promise((r) => setTimeout(r, intervalSec * 1000));
|
|
578
|
+
}
|
|
579
|
+
} finally {
|
|
580
|
+
process.off("SIGINT", stop);
|
|
581
|
+
process.off("SIGTERM", stop);
|
|
582
|
+
}
|
|
583
|
+
return 0;
|
|
584
|
+
}
|
|
585
|
+
|
|
431
586
|
const res = await callPinDropTool({
|
|
432
587
|
mcpUrl,
|
|
433
588
|
toolName,
|
|
@@ -663,20 +818,74 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
663
818
|
|
|
664
819
|
case "sandbox": {
|
|
665
820
|
const sub = positionals[1];
|
|
666
|
-
if (sub
|
|
667
|
-
|
|
821
|
+
if (sub === "pins") {
|
|
822
|
+
const projectId = positionals[2] || flagStr(flags, "project", "p");
|
|
823
|
+
const claimCode = positionals[3] || flagStr(flags, "claim-code", "code");
|
|
824
|
+
if (!projectId || !claimCode) {
|
|
825
|
+
throw new CliError("Usage: pindrop sandbox pins <projectId> <claimCode> [--json]", 1);
|
|
826
|
+
}
|
|
827
|
+
const data = await callSandboxApi({
|
|
828
|
+
mcpUrl,
|
|
829
|
+
method: "GET",
|
|
830
|
+
path: `/api/v1/sandbox/pins?project=${encodeURIComponent(projectId)}`,
|
|
831
|
+
claimCode,
|
|
832
|
+
});
|
|
833
|
+
if (asJson) {
|
|
834
|
+
printJson(data);
|
|
835
|
+
} else {
|
|
836
|
+
const pins = Array.isArray(data?.pins) ? data.pins : [];
|
|
837
|
+
if (pins.length === 0) process.stdout.write("No open pins.\n");
|
|
838
|
+
else for (const pin of pins) process.stdout.write(formatPinCompact(pin) + "\n");
|
|
839
|
+
}
|
|
840
|
+
return 0;
|
|
668
841
|
}
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
842
|
+
if (sub === "resolve") {
|
|
843
|
+
const projectId = positionals[2] || flagStr(flags, "project", "p");
|
|
844
|
+
const claimCode = positionals[3] || flagStr(flags, "claim-code", "code");
|
|
845
|
+
const pinNumber = parsePinNumber(positionals[4]);
|
|
846
|
+
const newText = flagStr(flags, "new-text", "newText");
|
|
847
|
+
const comment = flagStr(flags, "comment", "c", "m");
|
|
848
|
+
const authorName = flagStr(flags, "author") || process.env.PINDROP_AGENT_NAME;
|
|
849
|
+
if (!projectId || !claimCode) {
|
|
850
|
+
throw new CliError(
|
|
851
|
+
'Usage: pindrop sandbox resolve <projectId> <claimCode> <pinNumber> --new-text "<text>"',
|
|
852
|
+
1,
|
|
853
|
+
);
|
|
854
|
+
}
|
|
855
|
+
const data = await callSandboxApi({
|
|
856
|
+
mcpUrl,
|
|
857
|
+
method: "POST",
|
|
858
|
+
path: "/api/v1/sandbox/resolve",
|
|
859
|
+
claimCode,
|
|
860
|
+
body: {
|
|
861
|
+
projectId,
|
|
862
|
+
pinNumber,
|
|
863
|
+
...(newText ? { newText } : {}),
|
|
864
|
+
...(comment ? { comment } : {}),
|
|
865
|
+
...(authorName ? { authorName } : {}),
|
|
866
|
+
},
|
|
867
|
+
});
|
|
868
|
+
if (asJson) printJson(data);
|
|
869
|
+
else process.stdout.write(`${data?.pinShareUrl || `Resolved sandbox pin #${pinNumber}.`}\n`);
|
|
870
|
+
return 0;
|
|
871
|
+
}
|
|
872
|
+
if (sub === "claim" && positionals[2] && positionals[3]) {
|
|
873
|
+
const res = await callPinDropTool({
|
|
874
|
+
mcpUrl,
|
|
875
|
+
toolName: "pindrop_claim_sandbox",
|
|
876
|
+
args: { projectId: positionals[2], claimCode: positionals[3] },
|
|
877
|
+
autoLogin,
|
|
878
|
+
openBrowser,
|
|
879
|
+
onAuthorizeUrl: announceBrowserAuth,
|
|
880
|
+
});
|
|
881
|
+
if (asJson) printJson(res.structured ?? { text: res.text });
|
|
882
|
+
else process.stdout.write((res.text || `Claimed sandbox ${positionals[2]}`) + "\n");
|
|
883
|
+
return 0;
|
|
884
|
+
}
|
|
885
|
+
throw new CliError(
|
|
886
|
+
"Usage: pindrop sandbox <pins|resolve|claim> <projectId> <claimCode> [pinNumber]",
|
|
887
|
+
1,
|
|
888
|
+
);
|
|
680
889
|
}
|
|
681
890
|
|
|
682
891
|
case "billing": {
|
package/lib/auth.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "node:fs";
|
|
12
12
|
import { createServer } from "node:http";
|
|
13
13
|
import { homedir, platform } from "node:os";
|
|
14
|
-
import { dirname, join } from "node:path";
|
|
14
|
+
import { dirname, join, resolve } from "node:path";
|
|
15
15
|
|
|
16
16
|
export const DEFAULT_MCP_URL = "https://mcp.pindrop.page";
|
|
17
17
|
const EXPIRY_BUFFER_MS = 60_000;
|
|
@@ -104,6 +104,31 @@ export function clearProfile(mcpUrl) {
|
|
|
104
104
|
return existed;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
export function getLinkedProject(mcpUrl, cwd = process.cwd()) {
|
|
108
|
+
const store = readAuthStore();
|
|
109
|
+
const byHost = store.projects?.[mcpUrl];
|
|
110
|
+
if (!byHost || typeof byHost !== "object") return null;
|
|
111
|
+
return byHost[resolve(cwd)] ?? null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function saveLinkedProject(mcpUrl, cwd, link) {
|
|
115
|
+
if (!link?.projectId) return;
|
|
116
|
+
const store = readAuthStore();
|
|
117
|
+
if (!store.projects || typeof store.projects !== "object") {
|
|
118
|
+
store.projects = {};
|
|
119
|
+
}
|
|
120
|
+
if (!store.projects[mcpUrl] || typeof store.projects[mcpUrl] !== "object") {
|
|
121
|
+
store.projects[mcpUrl] = {};
|
|
122
|
+
}
|
|
123
|
+
store.projects[mcpUrl][resolve(cwd)] = {
|
|
124
|
+
projectId: link.projectId,
|
|
125
|
+
shareUrl: link.shareUrl || null,
|
|
126
|
+
targetUrl: link.targetUrl || null,
|
|
127
|
+
updatedAt: Date.now(),
|
|
128
|
+
};
|
|
129
|
+
writeAuthStore(store);
|
|
130
|
+
}
|
|
131
|
+
|
|
107
132
|
export function openInBrowser(url) {
|
|
108
133
|
const os = platform();
|
|
109
134
|
let cmd;
|
package/lib/client.mjs
CHANGED
|
@@ -20,7 +20,7 @@ async function postMcp(mcpUrl, token, toolName, args, fetchImpl = fetch) {
|
|
|
20
20
|
"Content-Type": "application/json",
|
|
21
21
|
Accept: "application/json, text/event-stream",
|
|
22
22
|
Authorization: `Bearer ${token}`,
|
|
23
|
-
"User-Agent": "pindrop-cli/0.1.
|
|
23
|
+
"User-Agent": "pindrop-cli/0.1.4",
|
|
24
24
|
},
|
|
25
25
|
body: JSON.stringify({
|
|
26
26
|
jsonrpc: "2.0",
|
|
@@ -139,3 +139,46 @@ export async function callPinDropTool({
|
|
|
139
139
|
content: Array.isArray(result.content) ? result.content : [],
|
|
140
140
|
};
|
|
141
141
|
}
|
|
142
|
+
|
|
143
|
+
export async function callSandboxApi({
|
|
144
|
+
mcpUrl,
|
|
145
|
+
method,
|
|
146
|
+
path,
|
|
147
|
+
claimCode,
|
|
148
|
+
body,
|
|
149
|
+
fetchImpl = fetch,
|
|
150
|
+
}) {
|
|
151
|
+
const base = mcpUrl.replace(/\/mcp$/, "").replace(/\/+$/, "");
|
|
152
|
+
const response = await fetchWithRetry(
|
|
153
|
+
`${base}${path}`,
|
|
154
|
+
{
|
|
155
|
+
method,
|
|
156
|
+
headers: {
|
|
157
|
+
Accept: "application/json",
|
|
158
|
+
Authorization: `Sandbox ${claimCode}`,
|
|
159
|
+
"User-Agent": "pindrop-cli/0.1.4",
|
|
160
|
+
...(body !== undefined ? { "Content-Type": "application/json" } : {}),
|
|
161
|
+
},
|
|
162
|
+
...(body !== undefined ? { body: JSON.stringify(body) } : {}),
|
|
163
|
+
},
|
|
164
|
+
fetchImpl,
|
|
165
|
+
);
|
|
166
|
+
const text = await response.text();
|
|
167
|
+
let payload = null;
|
|
168
|
+
try {
|
|
169
|
+
payload = JSON.parse(text);
|
|
170
|
+
} catch {
|
|
171
|
+
payload = null;
|
|
172
|
+
}
|
|
173
|
+
if (!response.ok) {
|
|
174
|
+
const msg =
|
|
175
|
+
payload?.error?.message ||
|
|
176
|
+
payload?.error ||
|
|
177
|
+
`PinDrop sandbox request failed (${response.status}).`;
|
|
178
|
+
throw new CliError(
|
|
179
|
+
String(msg),
|
|
180
|
+
response.status === 401 ? 2 : response.status === 404 ? 3 : 1,
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
return payload;
|
|
184
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pindrop",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Zero-dependency CLI for PinDrop visual client feedback pins. Browser OAuth login, instant project creation, pin context & screenshots, and agent skill setup.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|