@squirrelnotes.app/mcp 2.7.1-test.380 → 2.7.1-test.383

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.
@@ -41677,7 +41677,10 @@ var init_note_text = __esm({
41677
41677
  // stored in parts that does not verify is never shown in part or written
41678
41678
  // over; a write that lost a race to another writer writes nothing.
41679
41679
  unreadable: "This note could not be read in full. Nothing has been changed.",
41680
- "write-conflict": "The note changed on the server while this was being written, so nothing was written. Read it again and retry."
41680
+ "write-conflict": "The note changed on the server while this was being written, so nothing was written. Read it again and retry.",
41681
+ // ADR-0523 §7, §8: the account's storage (notes, files and the Trash
41682
+ // until it is emptied) is full. The server's answer carries no size.
41683
+ "storage-full": "The account's storage is full, so nothing was written. Ask the user to free space: delete notes or files, or empty the Trash."
41681
41684
  };
41682
41685
  refuse2 = (error62, details) => details === void 0 ? { kind: "refused", error: error62 } : { kind: "refused", error: error62, details };
41683
41686
  isRefusal = (x) => "kind" in x && x.kind === "refused";
@@ -41910,7 +41913,7 @@ function planChunks(bytes, gear, previous) {
41910
41913
  }
41911
41914
  return planned;
41912
41915
  }
41913
- var NOTE_CHUNKER, NOTE_BODY_FORMAT_CHUNKS, CHUNK_MIN_BYTES, CHUNK_MAX_BYTES, CHUNK_PAD_BYTES, NOTE_CHUNKING_THRESHOLD_BYTES, NOTE_BODY_MAX_BYTES2, NOTE_MANIFEST_MAX_CHUNKS, NOTE_CHUNKER_INFO, GEAR_TABLE_BYTES, GEAR_ARM_MASK, NEWLINE, NoteBodyUnreadableError, UUID_V4, HEX_64;
41916
+ var NOTE_CHUNKER, NOTE_BODY_FORMAT_CHUNKS, CHUNK_MIN_BYTES, CHUNK_MAX_BYTES, CHUNK_PAD_BYTES, NOTE_CHUNKING_THRESHOLD_BYTES, NOTE_BODY_MAX_BYTES2, NOTE_MANIFEST_MAX_CHUNKS, CHUNK_CIPHERTEXT_OVERHEAD, NOTE_CHUNKER_INFO, GEAR_TABLE_BYTES, GEAR_ARM_MASK, NEWLINE, NoteBodyUnreadableError, UUID_V4, HEX_64;
41914
41917
  var init_note_chunks = __esm({
41915
41918
  "src/note-chunks.ts"() {
41916
41919
  "use strict";
@@ -41921,7 +41924,8 @@ var init_note_chunks = __esm({
41921
41924
  CHUNK_PAD_BYTES = 1024;
41922
41925
  NOTE_CHUNKING_THRESHOLD_BYTES = 256 * 1024;
41923
41926
  NOTE_BODY_MAX_BYTES2 = 3 * 1024 * 1024;
41924
- NOTE_MANIFEST_MAX_CHUNKS = 1024;
41927
+ NOTE_MANIFEST_MAX_CHUNKS = Math.floor(NOTE_BODY_MAX_BYTES2 / CHUNK_MIN_BYTES) + Math.floor(NOTE_BODY_MAX_BYTES2 / (CHUNK_MAX_BYTES + 1)) + 1;
41928
+ CHUNK_CIPHERTEXT_OVERHEAD = CHUNK_PAD_BYTES - 1 + 16 + 2;
41925
41929
  NOTE_CHUNKER_INFO = "sqn-note-chunker-v1";
41926
41930
  GEAR_TABLE_BYTES = 1024;
41927
41931
  GEAR_ARM_MASK = 4294705152;
@@ -42123,6 +42127,23 @@ function lostRace(err) {
42123
42127
  function conversionsOff(err) {
42124
42128
  return err instanceof SquirrelApiError && err.status === 409 && err.responseBody.includes("NOTE_BODY_CONVERSIONS_OFF");
42125
42129
  }
42130
+ function codeOf(err) {
42131
+ try {
42132
+ const body = JSON.parse(err.responseBody);
42133
+ return typeof body === "object" && body !== null ? body.code : void 0;
42134
+ } catch {
42135
+ return void 0;
42136
+ }
42137
+ }
42138
+ function serverRefusal(err, bytes) {
42139
+ if (!(err instanceof SquirrelApiError)) return null;
42140
+ const code = codeOf(err);
42141
+ if (err.status === 413 && code === "NOTE_OVER_PLAN_LIMIT") {
42142
+ return refused("too-long", bytes === void 0 ? { limit: NOTE_BODY_MAX_BYTES2 } : { bytes, limit: NOTE_BODY_MAX_BYTES2 });
42143
+ }
42144
+ if ((err.status === 422 || err.status === 400) && code === "STORAGE_LIMIT_EXCEEDED") return refused("storage-full");
42145
+ return null;
42146
+ }
42126
42147
  function overThreshold(bytes) {
42127
42148
  return bytes > NOTE_CHUNKING_THRESHOLD_BYTES;
42128
42149
  }
@@ -42140,6 +42161,8 @@ async function writeNoteContent(client, key, noteId, text, current) {
42140
42161
  return { kind: "written", updatedAt: saved.updatedAt };
42141
42162
  } catch (err) {
42142
42163
  if (lostRace(err)) return refused("write-conflict");
42164
+ const refusal = serverRefusal(err, bytes);
42165
+ if (refusal) return refusal;
42143
42166
  if (current.chunked || !conversionsOff(err)) throw err;
42144
42167
  }
42145
42168
  }
@@ -42151,6 +42174,8 @@ async function writeNoteContent(client, key, noteId, text, current) {
42151
42174
  return { kind: "written", updatedAt: saved.updatedAt };
42152
42175
  } catch (err) {
42153
42176
  if (lostRace(err)) return refused("write-conflict");
42177
+ const refusal = serverRefusal(err, bytes);
42178
+ if (refusal) return refusal;
42154
42179
  throw err;
42155
42180
  }
42156
42181
  }
@@ -42169,6 +42194,8 @@ async function createNoteWithContent(client, key, fields, text) {
42169
42194
  try {
42170
42195
  note = await client.createNote({ ...fields, id, body: buildChunkedCommit(key, id, text).commit });
42171
42196
  } catch (err) {
42197
+ const refusal = serverRefusal(err, bytes);
42198
+ if (refusal) return refusal;
42172
42199
  if (!conversionsOff(err)) throw err;
42173
42200
  }
42174
42201
  if (note?.bodyFormat === NOTE_BODY_FORMAT_CHUNKS) return { kind: "created", note };
@@ -42178,7 +42205,13 @@ async function createNoteWithContent(client, key, fields, text) {
42178
42205
  return { kind: "created", note: await client.updateNote(note.id, inlineContentFields(encrypt(text, key))) };
42179
42206
  }
42180
42207
  }
42181
- return { kind: "created", note: await client.createNote({ ...fields, ...inlineContentFields(encrypt(text, key)) }) };
42208
+ try {
42209
+ return { kind: "created", note: await client.createNote({ ...fields, ...inlineContentFields(encrypt(text, key)) }) };
42210
+ } catch (err) {
42211
+ const refusal = serverRefusal(err, bytes);
42212
+ if (refusal) return refusal;
42213
+ throw err;
42214
+ }
42182
42215
  }
42183
42216
  var init_note_content = __esm({
42184
42217
  "src/note-content.ts"() {
@@ -42357,6 +42390,8 @@ function refuseUnreadableBodies(server) {
42357
42390
  return await handler(...a);
42358
42391
  } catch (err) {
42359
42392
  if (err instanceof NoteBodyUnreadableError) return refusalResult({ kind: "refused", error: "unreadable" });
42393
+ const refusal = serverRefusal(err);
42394
+ if (refusal) return refusalResult(refusal);
42360
42395
  throw err;
42361
42396
  }
42362
42397
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squirrelnotes.app/mcp",
3
- "version": "2.7.1-test.380",
3
+ "version": "2.7.1-test.383",
4
4
  "description": "MCP stdio CLI for Squirrel Notes — bridges AI agents to the encrypted note-taking API",
5
5
  "type": "module",
6
6
  "repository": {