@usabledev/usable-chat 1.159.0 → 1.160.0
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/cli.js +86 -9
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -104567,18 +104567,56 @@ __export(client_exports, {
|
|
|
104567
104567
|
closeDatabase: () => closeDatabase,
|
|
104568
104568
|
db: () => db
|
|
104569
104569
|
});
|
|
104570
|
+
function databaseLogContext() {
|
|
104571
|
+
const ssl = config2.database.url.includes("localhost") ? false : "require";
|
|
104572
|
+
try {
|
|
104573
|
+
const url2 = new URL(config2.database.url);
|
|
104574
|
+
return {
|
|
104575
|
+
host: url2.hostname,
|
|
104576
|
+
port: url2.port || void 0,
|
|
104577
|
+
database: url2.pathname.replace(/^\//, "") || void 0,
|
|
104578
|
+
ssl
|
|
104579
|
+
};
|
|
104580
|
+
} catch {
|
|
104581
|
+
return {
|
|
104582
|
+
host: "unknown",
|
|
104583
|
+
database: "unknown",
|
|
104584
|
+
ssl
|
|
104585
|
+
};
|
|
104586
|
+
}
|
|
104587
|
+
}
|
|
104570
104588
|
function getClient() {
|
|
104571
104589
|
if (!_client) {
|
|
104572
|
-
|
|
104573
|
-
|
|
104574
|
-
|
|
104590
|
+
const logContext = databaseLogContext();
|
|
104591
|
+
logger.info("database", "Initializing PostgreSQL client", logContext);
|
|
104592
|
+
try {
|
|
104593
|
+
_client = src_default(config2.database.url, {
|
|
104594
|
+
ssl: logContext.ssl
|
|
104595
|
+
});
|
|
104596
|
+
} catch (error41) {
|
|
104597
|
+
logger.error("database", "Failed to initialize PostgreSQL client", {
|
|
104598
|
+
...logContext,
|
|
104599
|
+
error: error41 instanceof Error ? error41.message : String(error41)
|
|
104600
|
+
});
|
|
104601
|
+
throw error41;
|
|
104602
|
+
}
|
|
104575
104603
|
}
|
|
104576
104604
|
return _client;
|
|
104577
104605
|
}
|
|
104578
104606
|
function getDb() {
|
|
104579
104607
|
if (!_db) {
|
|
104608
|
+
const logContext = databaseLogContext();
|
|
104580
104609
|
const client = getClient();
|
|
104581
|
-
|
|
104610
|
+
try {
|
|
104611
|
+
_db = drizzle(client, { schema: schema_exports });
|
|
104612
|
+
logger.info("database", "Drizzle database client initialized", logContext);
|
|
104613
|
+
} catch (error41) {
|
|
104614
|
+
logger.error("database", "Failed to initialize Drizzle database client", {
|
|
104615
|
+
...logContext,
|
|
104616
|
+
error: error41 instanceof Error ? error41.message : String(error41)
|
|
104617
|
+
});
|
|
104618
|
+
throw error41;
|
|
104619
|
+
}
|
|
104582
104620
|
}
|
|
104583
104621
|
return _db;
|
|
104584
104622
|
}
|
|
@@ -104596,7 +104634,19 @@ function createLazyDb() {
|
|
|
104596
104634
|
}
|
|
104597
104635
|
async function closeDatabase() {
|
|
104598
104636
|
if (_client) {
|
|
104599
|
-
|
|
104637
|
+
const logContext = databaseLogContext();
|
|
104638
|
+
try {
|
|
104639
|
+
await _client.end();
|
|
104640
|
+
logger.info("database", "PostgreSQL client connection closed", logContext);
|
|
104641
|
+
_client = null;
|
|
104642
|
+
_db = null;
|
|
104643
|
+
} catch (error41) {
|
|
104644
|
+
logger.error("database", "Failed to close PostgreSQL client connection", {
|
|
104645
|
+
...logContext,
|
|
104646
|
+
error: error41 instanceof Error ? error41.message : String(error41)
|
|
104647
|
+
});
|
|
104648
|
+
throw error41;
|
|
104649
|
+
}
|
|
104600
104650
|
}
|
|
104601
104651
|
}
|
|
104602
104652
|
var _client, _db, db;
|
|
@@ -104606,6 +104656,7 @@ var init_client2 = __esm({
|
|
|
104606
104656
|
init_postgres_js();
|
|
104607
104657
|
init_src();
|
|
104608
104658
|
init_config();
|
|
104659
|
+
init_logger();
|
|
104609
104660
|
init_schema2();
|
|
104610
104661
|
_client = null;
|
|
104611
104662
|
_db = null;
|
|
@@ -201374,6 +201425,14 @@ var init_provider = __esm({
|
|
|
201374
201425
|
});
|
|
201375
201426
|
|
|
201376
201427
|
// src/core/events/multiplexer.ts
|
|
201428
|
+
function envelopeLogContext(envelope) {
|
|
201429
|
+
return {
|
|
201430
|
+
type: envelope.type,
|
|
201431
|
+
sequence: envelope.sequence,
|
|
201432
|
+
messageId: envelope.messageId,
|
|
201433
|
+
correlationId: envelope.correlationId
|
|
201434
|
+
};
|
|
201435
|
+
}
|
|
201377
201436
|
function formatSSEMessage(envelope) {
|
|
201378
201437
|
const lines = [];
|
|
201379
201438
|
lines.push(`event: ${envelope.type}`);
|
|
@@ -201402,6 +201461,7 @@ var SSEMultiplexer;
|
|
|
201402
201461
|
var init_multiplexer = __esm({
|
|
201403
201462
|
"src/core/events/multiplexer.ts"() {
|
|
201404
201463
|
"use strict";
|
|
201464
|
+
init_logger();
|
|
201405
201465
|
SSEMultiplexer = class {
|
|
201406
201466
|
constructor() {
|
|
201407
201467
|
this.controller = null;
|
|
@@ -201426,14 +201486,21 @@ var init_multiplexer = __esm({
|
|
|
201426
201486
|
*/
|
|
201427
201487
|
send(envelope) {
|
|
201428
201488
|
if (this.closed || !this.controller) {
|
|
201429
|
-
|
|
201489
|
+
logger.warn(
|
|
201490
|
+
"stream",
|
|
201491
|
+
"Cannot send SSE message because stream is closed",
|
|
201492
|
+
envelopeLogContext(envelope)
|
|
201493
|
+
);
|
|
201430
201494
|
return;
|
|
201431
201495
|
}
|
|
201432
201496
|
try {
|
|
201433
201497
|
const message = formatSSEMessage(envelope);
|
|
201434
201498
|
this.controller.enqueue(message);
|
|
201435
201499
|
} catch (error41) {
|
|
201436
|
-
|
|
201500
|
+
logger.error("stream", "Failed to send SSE message", {
|
|
201501
|
+
...envelopeLogContext(envelope),
|
|
201502
|
+
error: error41 instanceof Error ? error41.message : String(error41)
|
|
201503
|
+
});
|
|
201437
201504
|
}
|
|
201438
201505
|
}
|
|
201439
201506
|
/**
|
|
@@ -201467,7 +201534,9 @@ var init_multiplexer = __esm({
|
|
|
201467
201534
|
try {
|
|
201468
201535
|
this.controller.close();
|
|
201469
201536
|
} catch (error41) {
|
|
201470
|
-
|
|
201537
|
+
logger.error("stream", "Failed to close SSE stream", {
|
|
201538
|
+
error: error41 instanceof Error ? error41.message : String(error41)
|
|
201539
|
+
});
|
|
201471
201540
|
} finally {
|
|
201472
201541
|
this.closed = true;
|
|
201473
201542
|
this.controller = null;
|
|
@@ -203090,6 +203159,14 @@ If asked to create/update content, respond ONLY with:
|
|
|
203090
203159
|
"I'm in Discussion mode and cannot create or modify content. Please switch to Normal mode to enable writing."
|
|
203091
203160
|
</discussion-mode>
|
|
203092
203161
|
|
|
203162
|
+
${effectiveSystemPrompt}`;
|
|
203163
|
+
}
|
|
203164
|
+
if (subAgent.id === "image-expert" && !Object.prototype.hasOwnProperty.call(filteredTools, "generate-image")) {
|
|
203165
|
+
effectiveSystemPrompt = `<image-generation-unavailable>
|
|
203166
|
+
generate-image is not available in this conversation. Do NOT call generate-image.
|
|
203167
|
+
If the user asks to create or edit an image, explain that image generation is not enabled for this chat/session. You may still analyze existing images with view-image when that tool is available.
|
|
203168
|
+
</image-generation-unavailable>
|
|
203169
|
+
|
|
203093
203170
|
${effectiveSystemPrompt}`;
|
|
203094
203171
|
}
|
|
203095
203172
|
const result = await executeSubagentLoop({
|
|
@@ -309348,7 +309425,7 @@ init_tui_select();
|
|
|
309348
309425
|
init_model_registry();
|
|
309349
309426
|
|
|
309350
309427
|
// package.json
|
|
309351
|
-
var version2 = "1.
|
|
309428
|
+
var version2 = "1.160.0";
|
|
309352
309429
|
|
|
309353
309430
|
// src/adapters/cli/model-catalog.ts
|
|
309354
309431
|
init_codex_auth();
|