@snowcone-app/mcp 0.14.0 → 0.14.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @snowcone-app/mcp
2
2
 
3
+ ## 0.14.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#5285](https://github.com/snowcone-app/snowcone-monorepo/pull/5285) [`126e84a`](https://github.com/snowcone-app/snowcone-monorepo/commit/126e84a5ab7e7e5d5cd60e37311bd8c3daca07d8) Thanks [@kevinsproles](https://github.com/kevinsproles)! - The drafts grid shows each draft design at once and its mockup over it when that has loaded (a draft picture loads about a second before its first mockup). `SNOWCONE_HOSTS.drafts` names the host draft designs are stored on.
8
+
9
+ ## 0.14.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#5283](https://github.com/snowcone-app/snowcone-monorepo/pull/5283) [`dc607b7`](https://github.com/snowcone-app/snowcone-monorepo/commit/dc607b7631ea17c8e7a51c447714c3c4303e9a0c) Thanks [@kevinsproles](https://github.com/kevinsproles)! - Using a draft design (rendering it on a product, asking for its buy link) now reports it to the backend, which checks the picture the first time it is used. The report runs beside the tool and never slows it.
14
+
3
15
  ## 0.14.0
4
16
 
5
17
  ### Minor Changes
package/dist/index.js CHANGED
@@ -28,7 +28,9 @@ var SNOWCONE_HOSTS = {
28
28
  /** The storefront site; `/api/launch` says whether orders are open yet. */
29
29
  site: "https://snowcone.app",
30
30
  /** The hosted MCP endpoint; it also serves the photo upload page (`/upload/<token>`). */
31
- mcp: "https://mcp.snowcone.app"
31
+ mcp: "https://mcp.snowcone.app",
32
+ /** Where draft designs made for a search are stored (a draft's `image_url`). */
33
+ drafts: "https://agentdraft.storage.snowcone.app"
32
34
  };
33
35
  var SNOWCONE_REALTIME_WS_URL = `${SNOWCONE_HOSTS.cdn.replace(/^http/, "ws")}/realtime`;
34
36
  var PARAMS = {
@@ -238,6 +240,7 @@ var IMG_BASE = stripSlash(process.env.SNOWCONE_IMG_BASE ?? SNOWCONE_HOSTS.img);
238
240
  var BUY_BASE = stripSlash(process.env.SNOWCONE_BUY_BASE ?? SNOWCONE_HOSTS.buy);
239
241
  var LAUNCH_URL = process.env.SNOWCONE_LAUNCH_URL ?? `${stripSlash(SNOWCONE_HOSTS.site)}/api/launch`;
240
242
  var UPLOAD_PAGE_BASE = stripSlash(process.env.SNOWCONE_UPLOAD_PAGE_BASE ?? SNOWCONE_HOSTS.mcp);
243
+ var DRAFTS_BASE = stripSlash(process.env.SNOWCONE_DRAFTS_BASE ?? SNOWCONE_HOSTS.drafts);
241
244
  var MEILI_HOST = stripSlash(process.env.SNOWCONE_MEILI_HOST ?? SNOWCONE_HOSTS.search);
242
245
  var MEILI_KEY = process.env.SNOWCONE_MEILI_KEY ?? "73f573ead9be75531c56ee89d104caa49d79154db387f119a013d33eccfe654b";
243
246
  var MEILI_INDEX = process.env.SNOWCONE_MEILI_INDEX ?? "snowcone";
@@ -252,7 +255,7 @@ function stripSlash(s) {
252
255
  // package.json
253
256
  var package_default = {
254
257
  name: "@snowcone-app/mcp",
255
- version: "0.14.0",
258
+ version: "0.14.2",
256
259
  mcpName: "io.github.snowcone-app/snowcone",
257
260
  description: "Snowcone MCP server \u2014 the agent-native quickstart. Mint a sandbox shop, browse the catalog, and turn any image into a buyable printed-merch mockup URL, all as callable tools.",
258
261
  keywords: [
@@ -879,6 +882,36 @@ async function searchDrafts(query, forwardedFor) {
879
882
  return none("unreachable", `Draft designs could not be reached (${why.slice(0, 120)}). The catalog results are unaffected.`);
880
883
  }
881
884
  }
885
+ var DRAFT_PICTURE = /^https:\/\/[^\s?#]+\/agent-drafts\/drf_[A-Za-z0-9_-]{12}\.webp$/;
886
+ function draftPicturesIn(...artwork) {
887
+ const found = /* @__PURE__ */ new Set();
888
+ const walk = (value, depth) => {
889
+ if (found.size >= 4 || depth > 4) return;
890
+ if (typeof value === "string") {
891
+ if (value.length <= 400 && DRAFT_PICTURE.test(value)) found.add(value);
892
+ } else if (Array.isArray(value)) {
893
+ for (const v of value) walk(v, depth + 1);
894
+ } else if (value && typeof value === "object") {
895
+ for (const v of Object.values(value)) walk(v, depth + 1);
896
+ }
897
+ };
898
+ for (const a of artwork) walk(a, 0);
899
+ return [...found];
900
+ }
901
+ async function markDraftUsed(imageUrl) {
902
+ try {
903
+ const res = await fetch(`${API_BASE}/agent-drafts/used`, {
904
+ method: "POST",
905
+ headers: { "Content-Type": "application/json", Accept: "application/json" },
906
+ body: JSON.stringify({ image_url: imageUrl }),
907
+ signal: AbortSignal.timeout(15e3)
908
+ });
909
+ await res.arrayBuffer();
910
+ if (!res.ok) console.error(`drafts: could not report a used draft (HTTP ${res.status})`);
911
+ } catch (err) {
912
+ console.error("drafts: could not report a used draft", err instanceof Error ? err.message : err);
913
+ }
914
+ }
882
915
  var money = (cents) => `$${(cents / 100).toFixed(2)}`;
883
916
  function draftsText(query, a) {
884
917
  if (a.status === "ok" && a.drafts.length > 0) {
@@ -905,7 +938,7 @@ var GRID_TOOL_META = {
905
938
  "openai/toolInvocation/invoked": "Ideas ready"
906
939
  };
907
940
  function gridResourceMeta(opts = {}) {
908
- const domains = [new URL(IMG_BASE).origin];
941
+ const domains = [new URL(IMG_BASE).origin, new URL(DRAFTS_BASE).origin];
909
942
  if (opts.beaconUrl) domains.push(new URL(opts.beaconUrl).origin);
910
943
  return {
911
944
  ui: { csp: { resourceDomains: domains, connectDomains: [] }, prefersBorder: true },
@@ -940,7 +973,7 @@ function buildGrid(query, drafted, catalogCount) {
940
973
  return { query, status, note: tiles.length > 0 ? "" : NOTES[status], tiles, catalog_count: catalogCount };
941
974
  }
942
975
  function gridHtml(opts = {}) {
943
- return GRID_HTML.replace("__VERSION__", VERSION).replace("__BEACON__", opts.beaconUrl ? JSON.stringify(opts.beaconUrl).slice(1, -1) : "");
976
+ return GRID_HTML.replace("__VERSION__", VERSION).replace("__BEACON__", opts.beaconUrl ? JSON.stringify(opts.beaconUrl).slice(1, -1) : "").replace("__DRAFTS_ORIGIN__", new URL(DRAFTS_BASE).origin);
944
977
  }
945
978
  var GRID_HTML = `<!doctype html>
946
979
  <html lang="en">
@@ -960,8 +993,11 @@ var GRID_HTML = `<!doctype html>
960
993
  .title { font-weight: 600; font-size: 15px; margin: 0 2px 10px; }
961
994
  .tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
962
995
  .tile { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
963
- .pic { position: relative; background: var(--well); aspect-ratio: 16 / 9; }
964
- .pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
996
+ /* The draft design shows in the tile at once (a small picture, about 0.2 s); the mockup, which takes a second or two the first time, fades in over it. */
997
+ .pic { position: relative; background: var(--well) center / contain no-repeat; aspect-ratio: 16 / 9; }
998
+ .pic img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .18s ease-out; }
999
+ .pic img.in { opacity: 1; }
1000
+ @media (prefers-reduced-motion: reduce) { .pic img { transition: none; } }
965
1001
  .badge { position: absolute; top: 8px; left: 8px; background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 999px; font-size: 11px; font-weight: 600; padding: 2px 8px; }
966
1002
  .meta { padding: 8px 10px 0; flex: 1; }
967
1003
  .pname { font-size: 13px; font-weight: 600; line-height: 1.3; }
@@ -985,6 +1021,7 @@ var GRID_HTML = `<!doctype html>
985
1021
  const $ = (id) => document.getElementById(id);
986
1022
  const root = $("grid");
987
1023
  const BEACON = "__BEACON__";
1024
+ const DRAFTS_ORIGIN = "__DRAFTS_ORIGIN__";
988
1025
  let beaconSent = false;
989
1026
  let bridge = false;
990
1027
  let nextId = 1;
@@ -1061,10 +1098,21 @@ var GRID_HTML = `<!doctype html>
1061
1098
  tile.dataset.product = t.product_id;
1062
1099
  const pic = document.createElement("div");
1063
1100
  pic.className = "pic";
1101
+ // What the tile shows right now: the design alone, then the mockup. Only a picture from the drafts store is used.
1102
+ tile.dataset.shown = "none";
1103
+ if (typeof t.image_url === "string" && t.image_url.startsWith(DRAFTS_ORIGIN + "/") && !/["\\\\()\\s]/.test(t.image_url)) {
1104
+ pic.style.backgroundImage = 'url("' + t.image_url + '")';
1105
+ tile.dataset.shown = "design";
1106
+ }
1064
1107
  const img = document.createElement("img");
1065
1108
  img.alt = "Draft " + n + " on " + t.product_name;
1066
1109
  img.loading = "lazy";
1067
- img.onload = () => { if (BEACON && !beaconSent) { beaconSent = true; new Image().src = BEACON; } resize(); };
1110
+ img.onload = () => {
1111
+ img.className = "in";
1112
+ tile.dataset.shown = "mockup";
1113
+ if (BEACON && !beaconSent) { beaconSent = true; new Image().src = BEACON; }
1114
+ resize();
1115
+ };
1068
1116
  img.src = t.mockup_url;
1069
1117
  const badge = document.createElement("div");
1070
1118
  badge.className = "badge";
@@ -1459,6 +1507,13 @@ var renderUrl = (input) => buildUrl(input, IMG_BASE);
1459
1507
  var buyUrl = (input) => buildUrl(input, BUY_BASE);
1460
1508
 
1461
1509
  // src/server.ts
1510
+ function noteDraftUse(ctx, args) {
1511
+ for (const picture of draftPicturesIn(args.asset, args.design)) {
1512
+ const work = markDraftUsed(picture);
1513
+ if (ctx.background) ctx.background(work);
1514
+ else void work;
1515
+ }
1516
+ }
1462
1517
  function createServer(ctx = {}) {
1463
1518
  const server2 = new McpServer({ name: "snowcone-mcp-server", version: VERSION });
1464
1519
  registerCard(server2, ctx);
@@ -1939,6 +1994,7 @@ Use it as "asset" in snowcone_render_mockup (with your shop) to show it on a pro
1939
1994
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true }
1940
1995
  },
1941
1996
  async (args) => {
1997
+ noteDraftUse(ctx, args);
1942
1998
  try {
1943
1999
  const url = await renderUrl(toUrlInput(args));
1944
2000
  const img_html = `<img src="${url}" style="object-fit:cover" alt="mockup" />`;
@@ -2010,6 +2066,7 @@ ${ordersLine(orders)}`
2010
2066
  annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true }
2011
2067
  },
2012
2068
  async (args) => {
2069
+ noteDraftUse(ctx, args);
2013
2070
  try {
2014
2071
  const url = await buyUrl(toUrlInput(args));
2015
2072
  const ordersP = readOrdersState();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snowcone-app/mcp",
3
- "version": "0.14.0",
3
+ "version": "0.14.2",
4
4
  "mcpName": "io.github.snowcone-app/snowcone",
5
5
  "description": "Snowcone MCP server — the agent-native quickstart. Mint a sandbox shop, browse the catalog, and turn any image into a buyable printed-merch mockup URL, all as callable tools.",
6
6
  "keywords": [
@@ -44,7 +44,7 @@
44
44
  "typescript": "^5.5.4",
45
45
  "vitest": "^2.1.9",
46
46
  "wrangler": "^3.91.0",
47
- "@snowcone-app/mockup-url": "0.6.0"
47
+ "@snowcone-app/mockup-url": "0.6.1"
48
48
  },
49
49
  "publishConfig": {
50
50
  "access": "public"