Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Merge origin/master (v0.60.117.0, #6330) into capy/next-wave-g3-g6-g7

garrytan304afc9acefd
diff --cc patches/[email protected]
index 70f11c53c1,be27516e38..e5d7039813
--- a/patches/[email protected]
+++ b/patches/[email protected]
@@@ -146,10 -146,31 +146,31 @@@ index 07f6716..f6d76e5 10064
}
diff --git a/cjs/src/index.js b/cjs/src/index.js
- index f09c61c..ac84375 100644
-index f09c61c7..28dbe40c 100644
++index f09c61c..694550b 100644
--- a/cjs/src/index.js
+++ b/cjs/src/index.js
- @@ -200,40 +200,134 @@ function Postgres(a, b) {
+ @@ -68,6 +68,20 @@ function Postgres(a, b) {
+
+ Object.assign(sql, {
+ get parameters() { return options.parameters },
+ + // GBrain: the pool's own queue lengths, read-only, for the consumer's pool diagnostics (#6317).
+ + get pool() {
+ + return {
+ + max: options.max,
+ + open: open.length,
+ + busy: busy.length,
+ + full: full.length,
+ + reserved: reserved.length,
+ + connecting: connecting.length,
+ + closed: closed.length,
+ + ended: ended.length,
+ + queued: queries.length
+ + }
+ + },
+ largeObject: largeObject.bind(null, sql),
+ subscribe,
+ CLOSE,
+ @@ -200,40 +214,134 @@ function Postgres(a, b) {
return await sql`select pg_notify(${ channel }, ${ '' + payload })`
}
@@@ -647,10 -668,31 +668,31 @@@ index 1b1cccd..792c83d 10064
}
diff --git a/src/index.js b/src/index.js
- index c7fba3d..9030be5 100644
-index c7fba3da..060e7b84 100644
++index c7fba3d..fc9f766 100644
--- a/src/index.js
+++ b/src/index.js
- @@ -200,40 +200,134 @@ function Postgres(a, b) {
+ @@ -68,6 +68,20 @@ function Postgres(a, b) {
+
+ Object.assign(sql, {
+ get parameters() { return options.parameters },
+ + // GBrain: the pool's own queue lengths, read-only, for the consumer's pool diagnostics (#6317).
+ + get pool() {
+ + return {
+ + max: options.max,
+ + open: open.length,
+ + busy: busy.length,
+ + full: full.length,
+ + reserved: reserved.length,
+ + connecting: connecting.length,
+ + closed: closed.length,
+ + ended: ended.length,
+ + queued: queries.length
+ + }
+ + },
+ largeObject: largeObject.bind(null, sql),
+ subscribe,
+ CLOSE,
+ @@ -200,40 +214,134 @@ function Postgres(a, b) {
return await sql`select pg_notify(${ channel }, ${ '' + payload })`
}
@@@ -1001,7 -1043,7 +1043,7 @@@ index c4ef971..8fba891 10064
const out = xs[index++]
diff --git a/types/index.d.ts b/types/index.d.ts
- index 13c3432..460ffc7 100644
-index 13c3432f..96cba0e0 100644
++index 13c3432..03f1ddf 100644
--- a/types/index.d.ts
+++ b/types/index.d.ts
@@ -119,6 +119,18 @@ interface BaseOptions<T extends Record<string, postgres.PostgresType>> {
diff --cc src/core/db.ts
index 693eb1d861,438b135d55..9c6e7c6f3d
--- a/src/core/db.ts
+++ b/src/core/db.ts
@@@ -377,11 -370,9 +390,9 @@@ export async function connect(config: E
// `gbrain jobs submit --json | ...`). Opt back in with GBRAIN_PG_NOTICES=1.
onnotice: process.env.GBRAIN_PG_NOTICES === '1' ? undefined : () => {},
onpoisoned: hooks.onpoisoned,
- shared_types: resolveSharedTypes(),
+ shared_types: resolveSharedTypes(url),
};
- if (Object.keys(timeouts).length > 0) {
- opts.connection = timeouts;
- }
+ opts.connection = { ...timeouts, application_name: gbrainApplicationName() };
if (typeof prepare === 'boolean') {
opts.prepare = prepare;
if (!prepare) {
diff --cc src/core/postgres-engine.ts
index ac2d7f36ec,8503eb9829..ac0ae0be74
--- a/src/core/postgres-engine.ts
+++ b/src/core/postgres-engine.ts
@@@ -387,11 -388,9 +388,9 @@@ export class PostgresEngine implements
// GBRAIN_PG_NOTICES=1.
onnotice: process.env.GBRAIN_PG_NOTICES === '1' ? undefined : () => {},
onpoisoned: (status: string) => this.onPoisoned('read', status),
- shared_types: db.resolveSharedTypes(),
+ shared_types: db.resolveSharedTypes(url),
};
- if (Object.keys(timeouts).length > 0) {
- opts.connection = timeouts;
- }
+ opts.connection = { ...timeouts, application_name: db.gbrainApplicationName() };
if (typeof prepare === 'boolean') {
opts.prepare = prepare;
}