Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Merge remote-tracking branch 'origin/master' into gbra133-pr2b-pg
garrytan2fa4277c3105
diff --cc patches/[email protected]index 1b3985a5d7,929c9c631c..3151eaef9b--- a/patches/[email protected]+++ b/patches/[email protected]@@@ -1,5 -1,5 +1,5 @@@diff --git a/cjs/src/connection.js b/vendor/postgres/cjs/src/connection.js- index 07f6716..cf56b7c 100644-index 07f6716..c329876 100644++index 07f6716..2978d0b 100644--- a/cjs/src/connection.js+++ b/vendor/postgres/cjs/src/connection.js@@ -20,6 +20,7 @@ const Sync = b().S().end()@@@ -103,9 -94,8 +103,9 @@@build(q)+ mayPipeline = mayPipeline || q.options.onexecute(connection)+ noteBudget(q)++ noteTransaction(q)+ lastWritten = q- + lastExecuted = q+ + lastExecuted = { string: q.string, strings: q.strings }return write(toBuffer(q))&& !q.describeFirst&& !q.cursorFn@@@ -300,15 -255,17 +300,25 @@@if (incomings) {incomings.push(x)remaining -= x.length- @@ -366,6 +544,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose-@@ -330,6 +471,9 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose++@@ -330,6 +508,9 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose+ remaining = 0+ incomings = null+ }+ ++ + if (incoming.length === 0)+ + incoming = Buffer.alloc(0)+ }++ async function connect() {-@@ -379,20 +523,35 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose++@@ -366,6 +547,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose+ try {+ statements = {}+ needsTypes = options.fetch_types++ inTransactionAfterSent = false+ statementId = Math.random().toString(36).slice(2)+ statementCount = 1+ lifeTimer.start()- @@ -379,20 +558,35 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose++@@ -379,20 +561,35 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose}function error(err) {@@@ -344,9 -301,11 +354,11 @@@function queryError(query, err) {if (query.reserve)return query.reject(err)- @@ -438,19 +632,47 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose-@@ -437,20 +596,49 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose++@@ -437,20 +634,49 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose+ incoming = Buffer.alloc(0)remaining = 0incomings = null+ + lastWritten = nullclearImmediate(nextWriteTimer)+ // GBrain (#6355): bytes still waiting for the cleared immediate belonged to this socket. Left in place, the next+ // connection's StartupMessage is appended to them and never scheduled for writing (the timer handle is not@@@ -393,7 -352,7 +405,7 @@@closedTime = performance.now()hadError && options.shared.retries++delay = (typeof backoff === 'function' ? backoff(options.shared.retries) : backoff) * 1000- @@ -459,6 +681,10 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose-@@ -459,6 +647,10 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose++@@ -459,6 +685,10 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose/* Handlers */function handle(xs, x = xs[0]) {@@@ -404,7 -363,7 +416,7 @@@(x === 68 ? DataRow : // Dx === 100 ? CopyData : // d- @@ -489,6 +715,39 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose-@@ -489,6 +681,39 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose++@@ -489,6 +719,39 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose)(xs)}@@@ -444,7 -403,7 +456,7 @@@function DataRow(x) {let index = 7let length- @@ -533,13 +792,25 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose-@@ -533,13 +758,25 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose++@@ -533,13 +796,25 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose}function ReadyForQuery(x) {@@@ -471,7 -430,7 +483,7 @@@} else {query.resolve(results || result)}- @@ -547,9 +818,16 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose-@@ -547,9 +784,16 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose++@@ -547,9 +822,16 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, oncloseerrored(errorResponse)}@@@ -488,18 -447,7 +500,18 @@@if (initial) {if (target_session_attrs) {- @@ -559,28 +837,54 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose-@@ -564,23 +808,43 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose++@@ -559,28 +841,54 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose+ return terminate()+ }+++ // GBrain (#6930): the array types a pool for this database already fetched are applied without a round trip.++ if (needsTypes && options.array_types && options.array_types.rows) {++ needsTypes = false++ options.array_types.rows.forEach(([oid, typarray]) => addArrayType(oid, typarray))++ }+++ if (needsTypes) {+ initial.reserve && (initial = null)return fetchArrayTypes()}@@@ -549,7 -497,7 +561,7 @@@: connection.reserved(): ending? terminate()- @@ -630,7 +934,11 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose-@@ -630,7 +894,11 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose++@@ -630,7 +938,11 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose!query.statement.types[i] && (query.statement.types[i] = x.readUInt32BE(7 + i * 4))query.prepare && (statements[query.signature] = query.statement)@@@ -561,7 -509,7 +573,7 @@@}function RowDescription(x) {- @@ -767,15 +1075,23 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose-@@ -767,14 +1035,21 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose++@@ -767,15 +1079,23 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, oncloseasync function fetchArrayTypes() {needsTypes = false@@@ -589,11 -537,9 +601,11 @@@+ return+ }types.forEach(({ oid, typarray }) => addArrayType(oid, typarray))++ options.array_types && (options.array_types.rows = types.map(({ oid, typarray }) => [oid, typarray]))}-@@ -821,7 +1096,16 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose+ function addArrayType(oid, typarray) {- @@ -821,7 +1137,16 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose++@@ -821,7 +1141,16 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclosefunction retry(q, error) {delete statements[q.signature]q.retried = error@@@ -611,7 -557,7 +623,7 @@@}function NotificationResponse(x) {- @@ -1039,6 +1364,59 @@ function xor(a, b) {-@@ -1039,6 +1323,59 @@ function xor(a, b) {++@@ -1039,6 +1368,59 @@ function xor(a, b) {return buffer}@@@ -1175,7 -1119,7 +1187,7 @@@ index 0578284..e80a868 10064return '$' + (types.push(diff --git a/src/connection.js b/vendor/postgres/src/connection.js- index 1b1cccd..8be7fc0 100644-index 1b1cccd..75e3eba 100644++index 1b1cccd..28f3e50 100644--- a/src/connection.js+++ b/vendor/postgres/src/connection.js@@ -20,6 +20,7 @@ const Sync = b().S().end()@@@ -1279,9 -1214,8 +1291,9 @@@build(q)+ mayPipeline = mayPipeline || q.options.onexecute(connection)+ noteBudget(q)++ noteTransaction(q)+ lastWritten = q- + lastExecuted = q+ + lastExecuted = { string: q.string, strings: q.strings }return write(toBuffer(q))&& !q.describeFirst&& !q.cursorFn@@@ -1476,15 -1375,17 +1488,25 @@@if (incomings) {incomings.push(x)remaining -= x.length- @@ -366,6 +544,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose-@@ -330,6 +471,9 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose++@@ -330,6 +508,9 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose+ remaining = 0+ incomings = null+ }+ ++ + if (incoming.length === 0)+ + incoming = Buffer.alloc(0)+ }++ async function connect() {-@@ -379,20 +523,35 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose++@@ -366,6 +547,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose+ try {+ statements = {}+ needsTypes = options.fetch_types++ inTransactionAfterSent = false+ statementId = Math.random().toString(36).slice(2)+ statementCount = 1+ lifeTimer.start()- @@ -379,20 +558,35 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose++@@ -379,20 +561,35 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose}function error(err) {@@@ -1520,9 -1421,11 +1542,11 @@@function queryError(query, err) {if (query.reserve)return query.reject(err)- @@ -438,19 +632,47 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose-@@ -437,20 +596,49 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose++@@ -437,20 +634,49 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose+ incoming = Buffer.alloc(0)remaining = 0incomings = null+ + lastWritten = nullclearImmediate(nextWriteTimer)+ // GBrain (#6355): bytes still waiting for the cleared immediate belonged to this socket. Left in place, the next+ // connection's StartupMessage is appended to them and never scheduled for writing (the timer handle is not@@@ -1569,7 -1472,7 +1593,7 @@@closedTime = performance.now()hadError && options.shared.retries++delay = (typeof backoff === 'function' ? backoff(options.shared.retries) : backoff) * 1000- @@ -459,6 +681,10 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose-@@ -459,6 +647,10 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose++@@ -459,6 +685,10 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose/* Handlers */function handle(xs, x = xs[0]) {@@@ -1580,7 -1483,7 +1604,7 @@@(x === 68 ? DataRow : // Dx === 100 ? CopyData : // d- @@ -489,6 +715,39 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose-@@ -489,6 +681,39 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose++@@ -489,6 +719,39 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose)(xs)}@@@ -1620,7 -1523,7 +1644,7 @@@function DataRow(x) {let index = 7let length- @@ -533,13 +792,25 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose-@@ -533,13 +758,25 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose++@@ -533,13 +796,25 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose}function ReadyForQuery(x) {@@@ -1647,7 -1550,7 +1671,7 @@@} else {query.resolve(results || result)}- @@ -547,9 +818,16 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose-@@ -547,9 +784,16 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose++@@ -547,9 +822,16 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, oncloseerrored(errorResponse)}@@@ -1664,18 -1567,7 +1688,18 @@@if (initial) {if (target_session_attrs) {- @@ -559,28 +837,54 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose-@@ -564,23 +808,43 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose++@@ -559,28 +841,54 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose+ return terminate()+ }+++ // GBrain (#6930): the array types a pool for this database already fetched are applied without a round trip.++ if (needsTypes && options.array_types && options.array_types.rows) {++ needsTypes = false++ options.array_types.rows.forEach(([oid, typarray]) => addArrayType(oid, typarray))++ }+++ if (needsTypes) {+ initial.reserve && (initial = null)return fetchArrayTypes()}@@@ -1725,7 -1617,7 +1749,7 @@@: connection.reserved(): ending? terminate()- @@ -630,7 +934,11 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose-@@ -630,7 +894,11 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose++@@ -630,7 +938,11 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose!query.statement.types[i] && (query.statement.types[i] = x.readUInt32BE(7 + i * 4))query.prepare && (statements[query.signature] = query.statement)@@@ -1737,7 -1629,7 +1761,7 @@@}function RowDescription(x) {- @@ -767,15 +1075,23 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose-@@ -767,14 +1035,21 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose++@@ -767,15 +1079,23 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, oncloseasync function fetchArrayTypes() {needsTypes = false@@@ -1765,11 -1657,9 +1789,11 @@@+ return+ }types.forEach(({ oid, typarray }) => addArrayType(oid, typarray))++ options.array_types && (options.array_types.rows = types.map(({ oid, typarray }) => [oid, typarray]))}-@@ -821,7 +1096,16 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose+ function addArrayType(oid, typarray) {- @@ -821,7 +1137,16 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose++@@ -821,7 +1141,16 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclosefunction retry(q, error) {delete statements[q.signature]q.retried = error@@@ -1787,7 -1677,7 +1811,7 @@@}function NotificationResponse(x) {- @@ -1039,6 +1364,59 @@ function xor(a, b) {-@@ -1039,6 +1323,59 @@ function xor(a, b) {++@@ -1039,6 +1368,59 @@ function xor(a, b) {return buffer}diff --cc vendor/postgres/cf/src/connection.jsindex ca9ec5c97c,526b51e0eb..17d5d278c1--- a/vendor/postgres/cf/src/connection.js+++ b/vendor/postgres/cf/src/connection.js@@@ -195,9 -193,8 +195,9 @@@ function Connection(options, queues = {build(q)mayPipeline = mayPipeline || q.options.onexecute(connection)noteBudget(q)+ noteTransaction(q)lastWritten = q- lastExecuted = q+ lastExecuted = { string: q.string, strings: q.strings }return write(toBuffer(q))&& !q.describeFirst&& !q.cursorFndiff --cc vendor/postgres/cjs/src/connection.jsindex cf56b7ccc8,c329876649..2978d0bc83--- a/vendor/postgres/cjs/src/connection.js+++ b/vendor/postgres/cjs/src/connection.js@@@ -193,9 -191,8 +193,9 @@@ function Connection(options, queues = {build(q)mayPipeline = mayPipeline || q.options.onexecute(connection)noteBudget(q)+ noteTransaction(q)lastWritten = q- lastExecuted = q+ lastExecuted = { string: q.string, strings: q.strings }return write(toBuffer(q))&& !q.describeFirst&& !q.cursorFndiff --cc vendor/postgres/src/connection.jsindex 8be7fc0121,75e3ebaabc..28f3e50f98--- a/vendor/postgres/src/connection.js+++ b/vendor/postgres/src/connection.js@@@ -193,9 -191,8 +193,9 @@@ function Connection(options, queues = {build(q)mayPipeline = mayPipeline || q.options.onexecute(connection)noteBudget(q)+ noteTransaction(q)lastWritten = q- lastExecuted = q+ lastExecuted = { string: q.string, strings: q.strings }return write(toBuffer(q))&& !q.describeFirst&& !q.cursorFn