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

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.
@@ -42086,6 +42086,7 @@ var init_note_body = __esm({
42086
42086
  });
42087
42087
 
42088
42088
  // src/note-content.ts
42089
+ import { randomUUID as randomUUID3 } from "node:crypto";
42089
42090
  function inlineContentFields(sealed) {
42090
42091
  return { encryptedContent: sealed.ciphertext, contentIv: sealed.iv };
42091
42092
  }
@@ -42119,21 +42120,31 @@ function refused(error62, details) {
42119
42120
  function lostRace(err) {
42120
42121
  return err instanceof SquirrelApiError && err.status === 409 && /NOTE_BODY_(CONFLICT|CHUNKED)/.test(err.responseBody);
42121
42122
  }
42122
- async function writeNoteContent(client, key, noteId, text, current, options = {}) {
42123
+ function conversionsOff(err) {
42124
+ return err instanceof SquirrelApiError && err.status === 409 && err.responseBody.includes("NOTE_BODY_CONVERSIONS_OFF");
42125
+ }
42126
+ function overThreshold(bytes) {
42127
+ return bytes > NOTE_CHUNKING_THRESHOLD_BYTES;
42128
+ }
42129
+ function overInlineCap(bytes) {
42130
+ return bytes > NOTE_BODY_MAX_BYTES ? refused("too-long", { bytes, limit: NOTE_BODY_MAX_BYTES }) : null;
42131
+ }
42132
+ async function writeNoteContent(client, key, noteId, text, current) {
42133
+ const tooLong = newContentTooLong(text);
42134
+ if (tooLong) return tooLong;
42123
42135
  const bytes = utf8Bytes(text);
42124
- const convert = (options.conversionsOn ?? MCP_CONVERTS_TO_CHUNKS) && bytes > NOTE_CHUNKING_THRESHOLD_BYTES;
42125
- if (current.chunked || convert) {
42126
- if (bytes > NOTE_BODY_MAX_BYTES2) return refused("too-long", { bytes, limit: NOTE_BODY_MAX_BYTES2 });
42136
+ if (current.chunked || overThreshold(bytes)) {
42127
42137
  const { commit } = buildChunkedCommit(key, noteId, text, current.chunked ?? void 0);
42128
42138
  try {
42129
42139
  const saved = await client.putNoteBody(noteId, commit);
42130
42140
  return { kind: "written", updatedAt: saved.updatedAt };
42131
42141
  } catch (err) {
42132
42142
  if (lostRace(err)) return refused("write-conflict");
42133
- throw err;
42143
+ if (current.chunked || !conversionsOff(err)) throw err;
42134
42144
  }
42135
42145
  }
42136
- if (bytes > NOTE_BODY_MAX_BYTES) return refused("too-long", { bytes, limit: NOTE_BODY_MAX_BYTES });
42146
+ const capped = overInlineCap(bytes);
42147
+ if (capped) return capped;
42137
42148
  const enc = encrypt(text, key);
42138
42149
  try {
42139
42150
  const saved = await client.updateNote(noteId, inlineContentFields(enc));
@@ -42143,13 +42154,32 @@ async function writeNoteContent(client, key, noteId, text, current, options = {}
42143
42154
  throw err;
42144
42155
  }
42145
42156
  }
42146
- function newContentTooLong(text, options = {}) {
42157
+ function newContentTooLong(text) {
42158
+ const bytes = utf8Bytes(text);
42159
+ return bytes > NOTE_BODY_MAX_BYTES2 ? refused("too-long", { bytes, limit: NOTE_BODY_MAX_BYTES2 }) : null;
42160
+ }
42161
+ async function createNoteWithContent(client, key, fields, text) {
42162
+ if (text === void 0) return { kind: "created", note: await client.createNote(fields) };
42163
+ const tooLong = newContentTooLong(text);
42164
+ if (tooLong) return tooLong;
42147
42165
  const bytes = utf8Bytes(text);
42148
- const chunked = (options.conversionsOn ?? MCP_CONVERTS_TO_CHUNKS) && bytes > NOTE_CHUNKING_THRESHOLD_BYTES;
42149
- const limit = chunked ? NOTE_BODY_MAX_BYTES2 : NOTE_BODY_MAX_BYTES;
42150
- return bytes > limit ? refused("too-long", { bytes, limit }) : null;
42166
+ if (overThreshold(bytes)) {
42167
+ const id = randomUUID3();
42168
+ let note = null;
42169
+ try {
42170
+ note = await client.createNote({ ...fields, id, body: buildChunkedCommit(key, id, text).commit });
42171
+ } catch (err) {
42172
+ if (!conversionsOff(err)) throw err;
42173
+ }
42174
+ if (note?.bodyFormat === NOTE_BODY_FORMAT_CHUNKS) return { kind: "created", note };
42175
+ const capped = overInlineCap(bytes);
42176
+ if (capped) return capped;
42177
+ if (note) {
42178
+ return { kind: "created", note: await client.updateNote(note.id, inlineContentFields(encrypt(text, key))) };
42179
+ }
42180
+ }
42181
+ return { kind: "created", note: await client.createNote({ ...fields, ...inlineContentFields(encrypt(text, key)) }) };
42151
42182
  }
42152
- var MCP_CONVERTS_TO_CHUNKS;
42153
42183
  var init_note_content = __esm({
42154
42184
  "src/note-content.ts"() {
42155
42185
  "use strict";
@@ -42158,7 +42188,6 @@ var init_note_content = __esm({
42158
42188
  init_note_body();
42159
42189
  init_note_chunks();
42160
42190
  init_note_limits();
42161
- MCP_CONVERTS_TO_CHUNKS = false;
42162
42191
  }
42163
42192
  });
42164
42193
 
@@ -42253,7 +42282,6 @@ __export(server_exports, {
42253
42282
  inferMimeType: () => inferMimeType
42254
42283
  });
42255
42284
  import { basename as basename2, extname, resolve as resolve2 } from "node:path";
42256
- import { randomUUID as randomUUID3 } from "node:crypto";
42257
42285
  async function buildContext(creds, onUnauthorized) {
42258
42286
  const client = new SquirrelApiClient(SQUIRREL_API_BASE_URL, creds.apiKey, { onUnauthorized });
42259
42287
  const { salt, keyCheck, wrappedDek, dekIv } = await client.getEncryption();
@@ -42448,16 +42476,14 @@ function createMcpServer(creds, opts = {}) {
42448
42476
  if (tooLong) return refusalResult(tooLong);
42449
42477
  const { client, key } = await context.get();
42450
42478
  const encTitle = encrypt(title, key);
42451
- const chunked = content !== void 0 && MCP_CONVERTS_TO_CHUNKS && utf8Bytes(content) > NOTE_CHUNKING_THRESHOLD_BYTES;
42452
- const newId = randomUUID3();
42453
- const encContent = content !== void 0 && !chunked ? encrypt(content, key) : null;
42454
- const note = await client.createNote({
42455
- ...chunked ? { id: newId, body: buildChunkedCommit(key, newId, content).commit } : {},
42456
- encryptedTitle: encTitle.ciphertext,
42457
- titleIv: encTitle.iv,
42458
- ...encContent ? inlineContentFields(encContent) : {},
42459
- collectionId: collectionId ?? null
42460
- });
42479
+ const created = await createNoteWithContent(
42480
+ client,
42481
+ key,
42482
+ { encryptedTitle: encTitle.ciphertext, titleIv: encTitle.iv, collectionId: collectionId ?? null },
42483
+ content
42484
+ );
42485
+ if (created.kind === "refused") return refusalResult(created);
42486
+ const { note } = created;
42461
42487
  return {
42462
42488
  content: [
42463
42489
  {
@@ -42486,8 +42512,7 @@ function createMcpServer(creds, opts = {}) {
42486
42512
  dto.encryptedTitle = enc.ciphertext;
42487
42513
  dto.titleIv = enc.iv;
42488
42514
  }
42489
- const converts = content !== void 0 && MCP_CONVERTS_TO_CHUNKS && utf8Bytes(content) > NOTE_CHUNKING_THRESHOLD_BYTES;
42490
- if (content !== void 0 && !bodyTooLong(content) && !converts) {
42515
+ if (content !== void 0 && utf8Bytes(content) <= NOTE_CHUNKING_THRESHOLD_BYTES) {
42491
42516
  const enc = encrypt(content, key);
42492
42517
  try {
42493
42518
  const note = await client.updateNote(id, { ...dto, ...inlineContentFields(enc) });
@@ -42500,14 +42525,12 @@ function createMcpServer(creds, opts = {}) {
42500
42525
  const note = await client.updateNote(id, dto);
42501
42526
  return { content: [{ type: "text", text: JSON.stringify({ id: note.id, updated: true }, null, 2) }] };
42502
42527
  }
42528
+ const tooLong = newContentTooLong(content);
42529
+ if (tooLong) return refusalResult(tooLong);
42503
42530
  const current = readNoteContent(await client.getNote(id), key);
42504
- if (!current.chunked) {
42505
- const tooLong = bodyTooLong(content) ?? newContentTooLong(content);
42506
- if (tooLong) return refusalResult(tooLong);
42507
- }
42508
- if (title !== void 0) await client.updateNote(id, dto);
42509
42531
  const written = await writeNoteContent(client, key, id, content, current);
42510
42532
  if (written.kind === "refused") return refusalResult(written);
42533
+ if (title !== void 0) await client.updateNote(id, dto);
42511
42534
  return { content: [{ type: "text", text: JSON.stringify({ id, updated: true }, null, 2) }] };
42512
42535
  }
42513
42536
  );
@@ -43503,8 +43526,6 @@ var init_server3 = __esm({
43503
43526
  init_note_bodies();
43504
43527
  init_note_content();
43505
43528
  init_note_chunks();
43506
- init_note_body();
43507
- init_note_content();
43508
43529
  init_note_chunks();
43509
43530
  SQUIRREL_API_BASE_URL = process.env.SQUIRREL_API_BASE_URL;
43510
43531
  if (!SQUIRREL_API_BASE_URL) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squirrelnotes.app/mcp",
3
- "version": "2.7.1-test.379",
3
+ "version": "2.7.1-test.380",
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": {