@hasna/conversations 0.2.54 → 0.2.56
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/bin/index.js +11 -7
- package/bin/mcp.js +11 -7
- package/dist/index.js +10 -6
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -14483,6 +14483,11 @@ function guessMimeType(name) {
|
|
|
14483
14483
|
};
|
|
14484
14484
|
return mimeMap[ext || ""] || "application/octet-stream";
|
|
14485
14485
|
}
|
|
14486
|
+
function assertMessageSize(content) {
|
|
14487
|
+
if (Buffer.byteLength(content, "utf8") > MAX_MESSAGE_BYTES) {
|
|
14488
|
+
throw new Error(`Message content exceeds maximum size of ${MAX_MESSAGE_BYTES} bytes (64 KB).`);
|
|
14489
|
+
}
|
|
14490
|
+
}
|
|
14486
14491
|
function checkRateLimit(agentId) {
|
|
14487
14492
|
const dbPath = process.env.CONVERSATIONS_DB_PATH ?? process.env.HASNA_CONVERSATIONS_DB_PATH ?? "";
|
|
14488
14493
|
if (dbPath === ":memory:" || dbPath.includes("test") || dbPath.includes("tmp"))
|
|
@@ -14499,10 +14504,9 @@ function checkRateLimit(agentId) {
|
|
|
14499
14504
|
}
|
|
14500
14505
|
}
|
|
14501
14506
|
function sendMessage(opts) {
|
|
14502
|
-
|
|
14503
|
-
throw new Error(`Message content exceeds maximum size of ${MAX_MESSAGE_BYTES} bytes (64 KB).`);
|
|
14504
|
-
}
|
|
14507
|
+
assertMessageSize(opts.content);
|
|
14505
14508
|
checkRateLimit(opts.from);
|
|
14509
|
+
const validatedAttachments = opts.attachments && opts.attachments.length > 0 ? opts.attachments.map((att) => validateAttachment(att.source_path, att.name)) : [];
|
|
14506
14510
|
const db2 = getDb();
|
|
14507
14511
|
const explicitSession = opts.session_id && opts.session_id.trim().length > 0 ? opts.session_id : undefined;
|
|
14508
14512
|
const sessionId = explicitSession ?? (opts.space ? `space:${opts.space}` : `${[opts.from, opts.to].sort().join("-")}-${randomUUID3().slice(0, 8)}`);
|
|
@@ -14518,12 +14522,11 @@ function sendMessage(opts) {
|
|
|
14518
14522
|
`);
|
|
14519
14523
|
const row = stmt.get(msgUuid, sessionId, opts.from, opts.to, opts.space || null, opts.project_id || null, opts.content, normalizedPriority, opts.working_dir || null, opts.repository || null, opts.branch || null, metadata, blocking, replyTo);
|
|
14520
14524
|
const message = parseMessage(row);
|
|
14521
|
-
if (
|
|
14525
|
+
if (validatedAttachments.length > 0) {
|
|
14522
14526
|
const attachmentsDir = join11(getAttachmentsDir(), String(message.id));
|
|
14523
14527
|
mkdirSync8(attachmentsDir, { recursive: true });
|
|
14524
14528
|
const attachmentInfos = [];
|
|
14525
|
-
for (const
|
|
14526
|
-
const { safeSource, safeName } = validateAttachment(att.source_path, att.name);
|
|
14529
|
+
for (const { safeSource, safeName } of validatedAttachments) {
|
|
14527
14530
|
const destPath = join11(attachmentsDir, safeName);
|
|
14528
14531
|
copyFileSync3(safeSource, destPath);
|
|
14529
14532
|
const stat = statSync2(destPath);
|
|
@@ -14773,6 +14776,7 @@ function deleteMessage(id, agent) {
|
|
|
14773
14776
|
return result.changes > 0;
|
|
14774
14777
|
}
|
|
14775
14778
|
function editMessage(id, agent, newContent) {
|
|
14779
|
+
assertMessageSize(newContent);
|
|
14776
14780
|
const db2 = getDb();
|
|
14777
14781
|
const stmt = db2.prepare(`UPDATE messages SET content = ?, edited_at = strftime('%Y-%m-%dT%H:%M:%f', 'now') WHERE id = ? AND from_agent = ? RETURNING *`);
|
|
14778
14782
|
const row = stmt.get(newContent, id, agent);
|
|
@@ -15549,7 +15553,7 @@ var init_space_notifications = __esm(() => {
|
|
|
15549
15553
|
var require_package = __commonJS((exports, module) => {
|
|
15550
15554
|
module.exports = {
|
|
15551
15555
|
name: "@hasna/conversations",
|
|
15552
|
-
version: "0.2.
|
|
15556
|
+
version: "0.2.56",
|
|
15553
15557
|
description: "Real-time CLI messaging for AI agents",
|
|
15554
15558
|
type: "module",
|
|
15555
15559
|
bin: {
|
package/bin/mcp.js
CHANGED
|
@@ -41141,6 +41141,11 @@ function guessMimeType(name) {
|
|
|
41141
41141
|
return mimeMap[ext || ""] || "application/octet-stream";
|
|
41142
41142
|
}
|
|
41143
41143
|
var MAX_MESSAGE_BYTES = 65536;
|
|
41144
|
+
function assertMessageSize(content) {
|
|
41145
|
+
if (Buffer.byteLength(content, "utf8") > MAX_MESSAGE_BYTES) {
|
|
41146
|
+
throw new Error(`Message content exceeds maximum size of ${MAX_MESSAGE_BYTES} bytes (64 KB).`);
|
|
41147
|
+
}
|
|
41148
|
+
}
|
|
41144
41149
|
var RATE_LIMIT_MAX = 60;
|
|
41145
41150
|
var RATE_LIMIT_WINDOW_MS = 60000;
|
|
41146
41151
|
var _rateLimitCounters = new Map;
|
|
@@ -41160,10 +41165,9 @@ function checkRateLimit(agentId) {
|
|
|
41160
41165
|
}
|
|
41161
41166
|
}
|
|
41162
41167
|
function sendMessage(opts) {
|
|
41163
|
-
|
|
41164
|
-
throw new Error(`Message content exceeds maximum size of ${MAX_MESSAGE_BYTES} bytes (64 KB).`);
|
|
41165
|
-
}
|
|
41168
|
+
assertMessageSize(opts.content);
|
|
41166
41169
|
checkRateLimit(opts.from);
|
|
41170
|
+
const validatedAttachments = opts.attachments && opts.attachments.length > 0 ? opts.attachments.map((att) => validateAttachment(att.source_path, att.name)) : [];
|
|
41167
41171
|
const db2 = getDb();
|
|
41168
41172
|
const explicitSession = opts.session_id && opts.session_id.trim().length > 0 ? opts.session_id : undefined;
|
|
41169
41173
|
const sessionId = explicitSession ?? (opts.space ? `space:${opts.space}` : `${[opts.from, opts.to].sort().join("-")}-${randomUUID().slice(0, 8)}`);
|
|
@@ -41179,12 +41183,11 @@ function sendMessage(opts) {
|
|
|
41179
41183
|
`);
|
|
41180
41184
|
const row = stmt.get(msgUuid, sessionId, opts.from, opts.to, opts.space || null, opts.project_id || null, opts.content, normalizedPriority, opts.working_dir || null, opts.repository || null, opts.branch || null, metadata, blocking, replyTo);
|
|
41181
41185
|
const message = parseMessage(row);
|
|
41182
|
-
if (
|
|
41186
|
+
if (validatedAttachments.length > 0) {
|
|
41183
41187
|
const attachmentsDir = join10(getAttachmentsDir(), String(message.id));
|
|
41184
41188
|
mkdirSync7(attachmentsDir, { recursive: true });
|
|
41185
41189
|
const attachmentInfos = [];
|
|
41186
|
-
for (const
|
|
41187
|
-
const { safeSource, safeName } = validateAttachment(att.source_path, att.name);
|
|
41190
|
+
for (const { safeSource, safeName } of validatedAttachments) {
|
|
41188
41191
|
const destPath = join10(attachmentsDir, safeName);
|
|
41189
41192
|
copyFileSync3(safeSource, destPath);
|
|
41190
41193
|
const stat = statSync2(destPath);
|
|
@@ -41428,6 +41431,7 @@ function deleteMessage(id, agent) {
|
|
|
41428
41431
|
return result.changes > 0;
|
|
41429
41432
|
}
|
|
41430
41433
|
function editMessage(id, agent, newContent) {
|
|
41434
|
+
assertMessageSize(newContent);
|
|
41431
41435
|
const db2 = getDb();
|
|
41432
41436
|
const stmt = db2.prepare(`UPDATE messages SET content = ?, edited_at = strftime('%Y-%m-%dT%H:%M:%f', 'now') WHERE id = ? AND from_agent = ? RETURNING *`);
|
|
41433
41437
|
const row = stmt.get(newContent, id, agent);
|
|
@@ -46900,7 +46904,7 @@ function startMcpHttpServer(options) {
|
|
|
46900
46904
|
// package.json
|
|
46901
46905
|
var package_default = {
|
|
46902
46906
|
name: "@hasna/conversations",
|
|
46903
|
-
version: "0.2.
|
|
46907
|
+
version: "0.2.56",
|
|
46904
46908
|
description: "Real-time CLI messaging for AI agents",
|
|
46905
46909
|
type: "module",
|
|
46906
46910
|
bin: {
|
package/dist/index.js
CHANGED
|
@@ -12142,6 +12142,11 @@ function guessMimeType(name) {
|
|
|
12142
12142
|
return mimeMap[ext || ""] || "application/octet-stream";
|
|
12143
12143
|
}
|
|
12144
12144
|
var MAX_MESSAGE_BYTES = 65536;
|
|
12145
|
+
function assertMessageSize(content) {
|
|
12146
|
+
if (Buffer.byteLength(content, "utf8") > MAX_MESSAGE_BYTES) {
|
|
12147
|
+
throw new Error(`Message content exceeds maximum size of ${MAX_MESSAGE_BYTES} bytes (64 KB).`);
|
|
12148
|
+
}
|
|
12149
|
+
}
|
|
12145
12150
|
var RATE_LIMIT_MAX = 60;
|
|
12146
12151
|
var RATE_LIMIT_WINDOW_MS = 60000;
|
|
12147
12152
|
var _rateLimitCounters = new Map;
|
|
@@ -12161,10 +12166,9 @@ function checkRateLimit(agentId) {
|
|
|
12161
12166
|
}
|
|
12162
12167
|
}
|
|
12163
12168
|
function sendMessage(opts) {
|
|
12164
|
-
|
|
12165
|
-
throw new Error(`Message content exceeds maximum size of ${MAX_MESSAGE_BYTES} bytes (64 KB).`);
|
|
12166
|
-
}
|
|
12169
|
+
assertMessageSize(opts.content);
|
|
12167
12170
|
checkRateLimit(opts.from);
|
|
12171
|
+
const validatedAttachments = opts.attachments && opts.attachments.length > 0 ? opts.attachments.map((att) => validateAttachment(att.source_path, att.name)) : [];
|
|
12168
12172
|
const db2 = getDb();
|
|
12169
12173
|
const explicitSession = opts.session_id && opts.session_id.trim().length > 0 ? opts.session_id : undefined;
|
|
12170
12174
|
const sessionId = explicitSession ?? (opts.space ? `space:${opts.space}` : `${[opts.from, opts.to].sort().join("-")}-${randomUUID().slice(0, 8)}`);
|
|
@@ -12180,12 +12184,11 @@ function sendMessage(opts) {
|
|
|
12180
12184
|
`);
|
|
12181
12185
|
const row = stmt.get(msgUuid, sessionId, opts.from, opts.to, opts.space || null, opts.project_id || null, opts.content, normalizedPriority, opts.working_dir || null, opts.repository || null, opts.branch || null, metadata, blocking, replyTo);
|
|
12182
12186
|
const message = parseMessage(row);
|
|
12183
|
-
if (
|
|
12187
|
+
if (validatedAttachments.length > 0) {
|
|
12184
12188
|
const attachmentsDir = join8(getAttachmentsDir(), String(message.id));
|
|
12185
12189
|
mkdirSync6(attachmentsDir, { recursive: true });
|
|
12186
12190
|
const attachmentInfos = [];
|
|
12187
|
-
for (const
|
|
12188
|
-
const { safeSource, safeName } = validateAttachment(att.source_path, att.name);
|
|
12191
|
+
for (const { safeSource, safeName } of validatedAttachments) {
|
|
12189
12192
|
const destPath = join8(attachmentsDir, safeName);
|
|
12190
12193
|
copyFileSync3(safeSource, destPath);
|
|
12191
12194
|
const stat = statSync2(destPath);
|
|
@@ -12373,6 +12376,7 @@ function deleteMessage(id, agent) {
|
|
|
12373
12376
|
return result.changes > 0;
|
|
12374
12377
|
}
|
|
12375
12378
|
function editMessage(id, agent, newContent) {
|
|
12379
|
+
assertMessageSize(newContent);
|
|
12376
12380
|
const db2 = getDb();
|
|
12377
12381
|
const stmt = db2.prepare(`UPDATE messages SET content = ?, edited_at = strftime('%Y-%m-%dT%H:%M:%f', 'now') WHERE id = ? AND from_agent = ? RETURNING *`);
|
|
12378
12382
|
const row = stmt.get(newContent, id, agent);
|