@squirrelnotes.app/mcp 2.7.1-test.381 → 2.7.1-test.385
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/stdio-handler.js +46 -16
- package/package.json +1 -1
package/dist/stdio-handler.js
CHANGED
|
@@ -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
|
|
41680
|
+
"write-conflict": "The note changed on the server since it was read, 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 =
|
|
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;
|
|
@@ -42109,10 +42113,10 @@ function readNoteContent(note, key) {
|
|
|
42109
42113
|
if (!note.body) throw new NoteBodyUnreadableError();
|
|
42110
42114
|
const chunked = readChunkedBody(key, note.id, note.body);
|
|
42111
42115
|
if (note.encryptedContent) throw new NoteBodyUnreadableError();
|
|
42112
|
-
return { text: chunked.text, chunked };
|
|
42116
|
+
return { text: chunked.text, chunked, inlineIv: null };
|
|
42113
42117
|
}
|
|
42114
42118
|
const text = note.encryptedContent && note.contentIv ? decrypt(note.encryptedContent, note.contentIv, key) : "";
|
|
42115
|
-
return { text, chunked: null };
|
|
42119
|
+
return { text, chunked: null, inlineIv: note.contentIv ?? null };
|
|
42116
42120
|
}
|
|
42117
42121
|
function refused(error62, details) {
|
|
42118
42122
|
return details === void 0 ? { kind: "refused", error: error62 } : { kind: "refused", error: error62, details };
|
|
@@ -42120,8 +42124,22 @@ function refused(error62, details) {
|
|
|
42120
42124
|
function lostRace(err) {
|
|
42121
42125
|
return err instanceof SquirrelApiError && err.status === 409 && /NOTE_BODY_(CONFLICT|CHUNKED)/.test(err.responseBody);
|
|
42122
42126
|
}
|
|
42123
|
-
function
|
|
42124
|
-
|
|
42127
|
+
function codeOf(err) {
|
|
42128
|
+
try {
|
|
42129
|
+
const body = JSON.parse(err.responseBody);
|
|
42130
|
+
return typeof body === "object" && body !== null ? body.code : void 0;
|
|
42131
|
+
} catch {
|
|
42132
|
+
return void 0;
|
|
42133
|
+
}
|
|
42134
|
+
}
|
|
42135
|
+
function serverRefusal(err, bytes) {
|
|
42136
|
+
if (!(err instanceof SquirrelApiError)) return null;
|
|
42137
|
+
const code = codeOf(err);
|
|
42138
|
+
if (err.status === 413 && code === "NOTE_OVER_PLAN_LIMIT") {
|
|
42139
|
+
return refused("too-long", bytes === void 0 ? { limit: NOTE_BODY_MAX_BYTES2 } : { bytes, limit: NOTE_BODY_MAX_BYTES2 });
|
|
42140
|
+
}
|
|
42141
|
+
if ((err.status === 422 || err.status === 400) && code === "STORAGE_LIMIT_EXCEEDED") return refused("storage-full");
|
|
42142
|
+
return null;
|
|
42125
42143
|
}
|
|
42126
42144
|
function overThreshold(bytes) {
|
|
42127
42145
|
return bytes > NOTE_CHUNKING_THRESHOLD_BYTES;
|
|
@@ -42140,17 +42158,21 @@ async function writeNoteContent(client, key, noteId, text, current) {
|
|
|
42140
42158
|
return { kind: "written", updatedAt: saved.updatedAt };
|
|
42141
42159
|
} catch (err) {
|
|
42142
42160
|
if (lostRace(err)) return refused("write-conflict");
|
|
42143
|
-
|
|
42161
|
+
const refusal = serverRefusal(err, bytes);
|
|
42162
|
+
if (refusal) return refusal;
|
|
42163
|
+
throw err;
|
|
42144
42164
|
}
|
|
42145
42165
|
}
|
|
42146
42166
|
const capped = overInlineCap(bytes);
|
|
42147
42167
|
if (capped) return capped;
|
|
42148
42168
|
const enc = encrypt(text, key);
|
|
42149
42169
|
try {
|
|
42150
|
-
const saved = await client.updateNote(noteId, inlineContentFields(enc));
|
|
42170
|
+
const saved = await client.updateNote(noteId, { ...inlineContentFields(enc), baseContentIv: current.inlineIv });
|
|
42151
42171
|
return { kind: "written", updatedAt: saved.updatedAt };
|
|
42152
42172
|
} catch (err) {
|
|
42153
42173
|
if (lostRace(err)) return refused("write-conflict");
|
|
42174
|
+
const refusal = serverRefusal(err, bytes);
|
|
42175
|
+
if (refusal) return refusal;
|
|
42154
42176
|
throw err;
|
|
42155
42177
|
}
|
|
42156
42178
|
}
|
|
@@ -42165,20 +42187,26 @@ async function createNoteWithContent(client, key, fields, text) {
|
|
|
42165
42187
|
const bytes = utf8Bytes(text);
|
|
42166
42188
|
if (overThreshold(bytes)) {
|
|
42167
42189
|
const id = randomUUID3();
|
|
42168
|
-
let note
|
|
42190
|
+
let note;
|
|
42169
42191
|
try {
|
|
42170
42192
|
note = await client.createNote({ ...fields, id, body: buildChunkedCommit(key, id, text).commit });
|
|
42171
42193
|
} catch (err) {
|
|
42172
|
-
|
|
42194
|
+
const refusal = serverRefusal(err, bytes);
|
|
42195
|
+
if (refusal) return refusal;
|
|
42196
|
+
throw err;
|
|
42173
42197
|
}
|
|
42174
|
-
if (note
|
|
42198
|
+
if (note.bodyFormat === NOTE_BODY_FORMAT_CHUNKS) return { kind: "created", note };
|
|
42175
42199
|
const capped = overInlineCap(bytes);
|
|
42176
42200
|
if (capped) return capped;
|
|
42177
|
-
|
|
42178
|
-
|
|
42179
|
-
|
|
42201
|
+
return { kind: "created", note: await client.updateNote(note.id, inlineContentFields(encrypt(text, key))) };
|
|
42202
|
+
}
|
|
42203
|
+
try {
|
|
42204
|
+
return { kind: "created", note: await client.createNote({ ...fields, ...inlineContentFields(encrypt(text, key)) }) };
|
|
42205
|
+
} catch (err) {
|
|
42206
|
+
const refusal = serverRefusal(err, bytes);
|
|
42207
|
+
if (refusal) return refusal;
|
|
42208
|
+
throw err;
|
|
42180
42209
|
}
|
|
42181
|
-
return { kind: "created", note: await client.createNote({ ...fields, ...inlineContentFields(encrypt(text, key)) }) };
|
|
42182
42210
|
}
|
|
42183
42211
|
var init_note_content = __esm({
|
|
42184
42212
|
"src/note-content.ts"() {
|
|
@@ -42357,6 +42385,8 @@ function refuseUnreadableBodies(server) {
|
|
|
42357
42385
|
return await handler(...a);
|
|
42358
42386
|
} catch (err) {
|
|
42359
42387
|
if (err instanceof NoteBodyUnreadableError) return refusalResult({ kind: "refused", error: "unreadable" });
|
|
42388
|
+
const refusal = serverRefusal(err);
|
|
42389
|
+
if (refusal) return refusalResult(refusal);
|
|
42360
42390
|
throw err;
|
|
42361
42391
|
}
|
|
42362
42392
|
};
|
package/package.json
CHANGED