@hotmeshio/long-tail 0.21.2 → 0.22.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/build/lib/db/index.d.ts
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import { Client, Pool } from 'pg';
|
|
1
|
+
import { Client, Pool, type ClientConfig } from 'pg';
|
|
2
|
+
/** `pg.Client` that carries an 'error' listener from construction. */
|
|
3
|
+
declare class GuardedClient extends Client {
|
|
4
|
+
constructor(config?: string | ClientConfig);
|
|
5
|
+
}
|
|
2
6
|
export declare function getPool(): Pool;
|
|
3
7
|
export declare function closePool(): Promise<void>;
|
|
4
8
|
/**
|
|
5
|
-
* HotMesh connection descriptor: `{ class:
|
|
9
|
+
* HotMesh connection descriptor: `{ class: GuardedClient, options: postgres_options }`.
|
|
6
10
|
* Use this everywhere HotMesh / Durable APIs need a connection config
|
|
7
11
|
* instead of importing `pg` and `postgres_options` directly.
|
|
8
12
|
*/
|
|
9
13
|
export declare function getConnection(): {
|
|
10
|
-
class: typeof
|
|
14
|
+
class: typeof GuardedClient;
|
|
11
15
|
options: Record<string, unknown>;
|
|
12
16
|
};
|
|
17
|
+
export {};
|
package/build/lib/db/index.js
CHANGED
|
@@ -5,10 +5,29 @@ exports.closePool = closePool;
|
|
|
5
5
|
exports.getConnection = getConnection;
|
|
6
6
|
const pg_1 = require("pg");
|
|
7
7
|
const config_1 = require("../../modules/config");
|
|
8
|
+
const logger_1 = require("../logger");
|
|
9
|
+
/** A new connection that cannot be established within this window fails instead of hanging. */
|
|
10
|
+
const CONNECT_TIMEOUT_MS = 10_000;
|
|
8
11
|
let pool = null;
|
|
12
|
+
/** A lost socket fails the pending query; its 'error' event must never end the process. */
|
|
13
|
+
function onConnectionError(error) {
|
|
14
|
+
logger_1.loggerRegistry.debug(`[lt-db] connection error: ${error.message}`);
|
|
15
|
+
}
|
|
16
|
+
function onIdleConnectionLost(error) {
|
|
17
|
+
logger_1.loggerRegistry.warn(`[lt-db] pooled connection lost: ${error.message}`);
|
|
18
|
+
}
|
|
19
|
+
/** `pg.Client` that carries an 'error' listener from construction. */
|
|
20
|
+
class GuardedClient extends pg_1.Client {
|
|
21
|
+
constructor(config) {
|
|
22
|
+
super(config);
|
|
23
|
+
this.on('error', onConnectionError);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
9
26
|
function getPool() {
|
|
10
27
|
if (!pool) {
|
|
11
28
|
pool = new pg_1.Pool({
|
|
29
|
+
connectionTimeoutMillis: CONNECT_TIMEOUT_MS,
|
|
30
|
+
keepAlive: true,
|
|
12
31
|
...config_1.postgres_options,
|
|
13
32
|
// Long-tail's shared tables live in public. Postgres's default
|
|
14
33
|
// search_path is `"$user", public`: if any schema shares the connecting
|
|
@@ -20,6 +39,9 @@ function getPool() {
|
|
|
20
39
|
// the engine fully qualifies its app schemas.
|
|
21
40
|
options: '-c search_path=public',
|
|
22
41
|
});
|
|
42
|
+
pool.on('error', onIdleConnectionLost);
|
|
43
|
+
// pg-pool drops its own listener while a client is checked out
|
|
44
|
+
pool.on('connect', (client) => client.on('error', onConnectionError));
|
|
23
45
|
}
|
|
24
46
|
return pool;
|
|
25
47
|
}
|
|
@@ -30,10 +52,10 @@ async function closePool() {
|
|
|
30
52
|
}
|
|
31
53
|
}
|
|
32
54
|
/**
|
|
33
|
-
* HotMesh connection descriptor: `{ class:
|
|
55
|
+
* HotMesh connection descriptor: `{ class: GuardedClient, options: postgres_options }`.
|
|
34
56
|
* Use this everywhere HotMesh / Durable APIs need a connection config
|
|
35
57
|
* instead of importing `pg` and `postgres_options` directly.
|
|
36
58
|
*/
|
|
37
59
|
function getConnection() {
|
|
38
|
-
return { class:
|
|
60
|
+
return { class: GuardedClient, options: config_1.postgres_options };
|
|
39
61
|
}
|
|
@@ -36,7 +36,10 @@ function ensureFacetReady() {
|
|
|
36
36
|
ready = (async () => {
|
|
37
37
|
await (0, client_1.ensureEscalationCompatView)(); // hmsh_escalations + lt_escalations view
|
|
38
38
|
await (0, db_1.getPool)().query(facet_sql_1.ENSURE_ORIGIN_INDEX);
|
|
39
|
-
})()
|
|
39
|
+
})().catch((err) => {
|
|
40
|
+
ready = null;
|
|
41
|
+
throw err;
|
|
42
|
+
});
|
|
40
43
|
}
|
|
41
44
|
return ready;
|
|
42
45
|
}
|
|
@@ -704,13 +704,13 @@ export declare const patchUserPropertiesSchema: z.ZodObject<{
|
|
|
704
704
|
rename: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
705
705
|
}, "strip", z.ZodTypeAny, {
|
|
706
706
|
user_id: string;
|
|
707
|
-
set?: Record<string, any> | undefined;
|
|
708
707
|
remove?: string[] | undefined;
|
|
708
|
+
set?: Record<string, any> | undefined;
|
|
709
709
|
rename?: Record<string, string> | undefined;
|
|
710
710
|
}, {
|
|
711
711
|
user_id: string;
|
|
712
|
-
set?: Record<string, any> | undefined;
|
|
713
712
|
remove?: string[] | undefined;
|
|
713
|
+
set?: Record<string, any> | undefined;
|
|
714
714
|
rename?: Record<string, string> | undefined;
|
|
715
715
|
}>;
|
|
716
716
|
export declare const listRolesSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hotmeshio/long-tail",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "Long Tail Workflows — Durable AI workflows with human-in-the-loop escalation. Powered by PostgreSQL.",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@anthropic-ai/sdk": "^0.92.0",
|
|
76
76
|
"@aws-sdk/client-s3": "^3.1017.0",
|
|
77
77
|
"@aws-sdk/s3-request-presigner": "^3.1045.0",
|
|
78
|
-
"@hotmeshio/hotmesh": "^0.
|
|
78
|
+
"@hotmeshio/hotmesh": "^0.30.0",
|
|
79
79
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
80
80
|
"@opentelemetry/exporter-trace-otlp-proto": "^0.215.0",
|
|
81
81
|
"@opentelemetry/resources": "^2.5.1",
|