@mcp-abap-adt/llm-agent-server-libs 19.1.2 → 19.2.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/dist/factories/controller-factory.d.ts +18 -4
- package/dist/factories/controller-factory.d.ts.map +1 -1
- package/dist/factories/controller-factory.js +50 -10
- package/dist/factories/controller-factory.js.map +1 -1
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/pipelines/controller.d.ts.map +1 -1
- package/dist/pipelines/controller.js +41 -0
- package/dist/pipelines/controller.js.map +1 -1
- package/dist/pipelines/dag.d.ts.map +1 -1
- package/dist/pipelines/dag.js +2 -1
- package/dist/pipelines/dag.js.map +1 -1
- package/dist/pipelines/flat.d.ts.map +1 -1
- package/dist/pipelines/flat.js +2 -1
- package/dist/pipelines/flat.js.map +1 -1
- package/dist/pipelines/linear.d.ts.map +1 -1
- package/dist/pipelines/linear.js +2 -1
- package/dist/pipelines/linear.js.map +1 -1
- package/dist/pipelines/register-skill-sources.d.ts +21 -0
- package/dist/pipelines/register-skill-sources.d.ts.map +1 -0
- package/dist/pipelines/register-skill-sources.js +57 -0
- package/dist/pipelines/register-skill-sources.js.map +1 -0
- package/dist/pipelines/server-context.d.ts +37 -1
- package/dist/pipelines/server-context.d.ts.map +1 -1
- package/dist/pipelines/server-context.js.map +1 -1
- package/dist/smart-agent/config.d.ts.map +1 -1
- package/dist/smart-agent/config.js +4 -0
- package/dist/smart-agent/config.js.map +1 -1
- package/dist/smart-agent/controller/artifacts.d.ts +116 -0
- package/dist/smart-agent/controller/artifacts.d.ts.map +1 -0
- package/dist/smart-agent/controller/artifacts.js +192 -0
- package/dist/smart-agent/controller/artifacts.js.map +1 -0
- package/dist/smart-agent/controller/board.d.ts +73 -0
- package/dist/smart-agent/controller/board.d.ts.map +1 -0
- package/dist/smart-agent/controller/board.js +233 -0
- package/dist/smart-agent/controller/board.js.map +1 -0
- package/dist/smart-agent/controller/controller-coordinator-handler.d.ts +67 -7
- package/dist/smart-agent/controller/controller-coordinator-handler.d.ts.map +1 -1
- package/dist/smart-agent/controller/controller-coordinator-handler.js +923 -61
- package/dist/smart-agent/controller/controller-coordinator-handler.js.map +1 -1
- package/dist/smart-agent/controller/finalizer.d.ts +48 -0
- package/dist/smart-agent/controller/finalizer.d.ts.map +1 -0
- package/dist/smart-agent/controller/finalizer.js +126 -0
- package/dist/smart-agent/controller/finalizer.js.map +1 -0
- package/dist/smart-agent/controller/memorizer.d.ts +2 -2
- package/dist/smart-agent/controller/memorizer.d.ts.map +1 -1
- package/dist/smart-agent/controller/memorizer.js +2 -2
- package/dist/smart-agent/controller/memorizer.js.map +1 -1
- package/dist/smart-agent/controller/outcome.d.ts +28 -0
- package/dist/smart-agent/controller/outcome.d.ts.map +1 -0
- package/dist/smart-agent/controller/outcome.js +30 -0
- package/dist/smart-agent/controller/outcome.js.map +1 -0
- package/dist/smart-agent/controller/planner.d.ts +28 -5
- package/dist/smart-agent/controller/planner.d.ts.map +1 -1
- package/dist/smart-agent/controller/planner.js +111 -29
- package/dist/smart-agent/controller/planner.js.map +1 -1
- package/dist/smart-agent/controller/reviewer.d.ts +48 -0
- package/dist/smart-agent/controller/reviewer.d.ts.map +1 -0
- package/dist/smart-agent/controller/reviewer.js +116 -0
- package/dist/smart-agent/controller/reviewer.js.map +1 -0
- package/dist/smart-agent/controller/run-scope.d.ts +50 -0
- package/dist/smart-agent/controller/run-scope.d.ts.map +1 -0
- package/dist/smart-agent/controller/run-scope.js +99 -0
- package/dist/smart-agent/controller/run-scope.js.map +1 -0
- package/dist/smart-agent/controller/session-bundle.d.ts +5 -0
- package/dist/smart-agent/controller/session-bundle.d.ts.map +1 -1
- package/dist/smart-agent/controller/session-bundle.js +27 -0
- package/dist/smart-agent/controller/session-bundle.js.map +1 -1
- package/dist/smart-agent/controller/types.d.ts +117 -7
- package/dist/smart-agent/controller/types.d.ts.map +1 -1
- package/dist/smart-agent/controller/types.js +30 -1
- package/dist/smart-agent/controller/types.js.map +1 -1
- package/dist/smart-agent/embedder-knowledge-index.d.ts +28 -0
- package/dist/smart-agent/embedder-knowledge-index.d.ts.map +1 -0
- package/dist/smart-agent/embedder-knowledge-index.js +71 -0
- package/dist/smart-agent/embedder-knowledge-index.js.map +1 -0
- package/dist/smart-agent/jsonl-knowledge-backend.d.ts +26 -10
- package/dist/smart-agent/jsonl-knowledge-backend.d.ts.map +1 -1
- package/dist/smart-agent/jsonl-knowledge-backend.js +81 -9
- package/dist/smart-agent/jsonl-knowledge-backend.js.map +1 -1
- package/dist/smart-agent/pg-pool.d.ts +58 -0
- package/dist/smart-agent/pg-pool.d.ts.map +1 -0
- package/dist/smart-agent/pg-pool.js +149 -0
- package/dist/smart-agent/pg-pool.js.map +1 -0
- package/dist/smart-agent/skill-plugins-config.d.ts +97 -0
- package/dist/smart-agent/skill-plugins-config.d.ts.map +1 -0
- package/dist/smart-agent/skill-plugins-config.js +318 -0
- package/dist/smart-agent/skill-plugins-config.js.map +1 -0
- package/dist/smart-agent/skill-plugins-config.test.d.ts +2 -0
- package/dist/smart-agent/skill-plugins-config.test.d.ts.map +1 -0
- package/dist/smart-agent/skill-plugins-config.test.js.map +1 -0
- package/dist/smart-agent/skill-plugins-host-factory.d.ts +98 -0
- package/dist/smart-agent/skill-plugins-host-factory.d.ts.map +1 -0
- package/dist/smart-agent/skill-plugins-host-factory.js +284 -0
- package/dist/smart-agent/skill-plugins-host-factory.js.map +1 -0
- package/dist/smart-agent/skill-plugins-host-factory.test.d.ts +2 -0
- package/dist/smart-agent/skill-plugins-host-factory.test.d.ts.map +1 -0
- package/dist/smart-agent/skill-plugins-host-factory.test.js.map +1 -0
- package/dist/smart-agent/smart-server.d.ts +25 -0
- package/dist/smart-agent/smart-server.d.ts.map +1 -1
- package/dist/smart-agent/smart-server.js +139 -6
- package/dist/smart-agent/smart-server.js.map +1 -1
- package/package.json +9 -7
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { appendFile, mkdir, readFile, rm } from 'node:fs/promises';
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
|
+
import { matchesKnowledgeFilter, } from '@mcp-abap-adt/llm-agent-libs';
|
|
3
4
|
export class JsonlKnowledgeBackend {
|
|
4
5
|
logDir;
|
|
5
6
|
semantic;
|
|
6
7
|
constructor(logDir,
|
|
7
|
-
/** Optional semantic index
|
|
8
|
+
/** Optional semantic index; when present query() ranks by similarity and the
|
|
9
|
+
* index is lazily rehydrated from the durable JSONL on first use. */
|
|
8
10
|
semantic) {
|
|
9
11
|
this.logDir = logDir;
|
|
10
12
|
this.semantic = semantic;
|
|
@@ -12,16 +14,80 @@ export class JsonlKnowledgeBackend {
|
|
|
12
14
|
file(sid) {
|
|
13
15
|
return join(this.logDir, 'sessions', sid, 'knowledge.jsonl');
|
|
14
16
|
}
|
|
15
|
-
|
|
17
|
+
// The in-process index is EMPTY after a restart, but the JSONL log is durable, so
|
|
18
|
+
// it is REBUILT from the durable scan on first use per session. Every
|
|
19
|
+
// index-touching op (build / put / query / delete) runs through run(sid, ...) — a
|
|
20
|
+
// per-session promise chain — so none interleaves; the chain entry is dropped once
|
|
21
|
+
// it drains so the Map cannot grow unbounded. `built` records ONLY successful
|
|
22
|
+
// builds so a failed scan/embed retries rather than caching a rejection.
|
|
23
|
+
built = new Set();
|
|
24
|
+
chain = new Map();
|
|
25
|
+
run(sid, fn) {
|
|
26
|
+
const prev = this.chain.get(sid) ?? Promise.resolve();
|
|
27
|
+
const next = prev.then(fn, fn); // run regardless of prior outcome
|
|
28
|
+
const tail = next.then(() => { }, () => { });
|
|
29
|
+
this.chain.set(sid, tail);
|
|
30
|
+
void tail.then(() => {
|
|
31
|
+
if (this.chain.get(sid) === tail)
|
|
32
|
+
this.chain.delete(sid);
|
|
33
|
+
});
|
|
34
|
+
return next;
|
|
35
|
+
}
|
|
36
|
+
/** Lazy rehydration of the in-process index from the durable JSONL. `options`
|
|
37
|
+
* is forwarded into every re-index `upsert` so the embedder receives the
|
|
38
|
+
* triggering request's requestLogger — the lazy rebuild's embedding cost is
|
|
39
|
+
* metered against the request that triggered it (not silently dropped). */
|
|
40
|
+
async build(sid, options) {
|
|
41
|
+
if (!this.semantic || this.built.has(sid))
|
|
42
|
+
return;
|
|
43
|
+
this.semantic.deleteSession(sid); // clear any partial state → idempotent
|
|
44
|
+
for (const e of await this.scan(sid))
|
|
45
|
+
await this.semantic.upsert(sid, e, options);
|
|
46
|
+
this.built.add(sid); // mark built ONLY on success
|
|
47
|
+
}
|
|
48
|
+
async append(sid, entry) {
|
|
16
49
|
const f = this.file(sid);
|
|
17
50
|
await mkdir(dirname(f), { recursive: true });
|
|
18
51
|
await appendFile(f, `${JSON.stringify(entry)}\n`, 'utf8');
|
|
19
|
-
await this.semantic?.upsert(sid, entry);
|
|
20
52
|
}
|
|
21
|
-
async
|
|
22
|
-
if (this.semantic)
|
|
23
|
-
|
|
24
|
-
|
|
53
|
+
async put(sid, entry, options) {
|
|
54
|
+
if (!this.semantic) {
|
|
55
|
+
await this.append(sid, entry);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
// ENTIRE put serialized: build FIRST (indexes the durable JSONL BEFORE this
|
|
59
|
+
// append → the new entry is never double-counted by a rebuild scan), THEN
|
|
60
|
+
// append, THEN upsert once. A durable append is the success point: an index
|
|
61
|
+
// upsert failure does NOT rethrow (that would make the caller retry put() and
|
|
62
|
+
// append the same artifact twice); instead mark the session dirty so the next
|
|
63
|
+
// build re-syncs from the durable JSONL.
|
|
64
|
+
await this.run(sid, async () => {
|
|
65
|
+
await this.build(sid, options);
|
|
66
|
+
await this.append(sid, entry);
|
|
67
|
+
try {
|
|
68
|
+
await this.semantic?.upsert(sid, entry, options);
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
this.built.delete(sid);
|
|
72
|
+
if (process.env.DEBUG_CONTROLLER)
|
|
73
|
+
console.error(`[jsonl-index] upsert failed (will rebuild lazily): ${String(e)}`);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
async semanticQuery(sid, text, k, filter, options) {
|
|
78
|
+
if (this.semantic) {
|
|
79
|
+
// build + query in ONE run() so the query reads a consistent snapshot.
|
|
80
|
+
// options is captured in closure and forwarded into the index query so the
|
|
81
|
+
// embedder receives requestLogger for token metering.
|
|
82
|
+
return this.run(sid, async () => {
|
|
83
|
+
await this.build(sid, options);
|
|
84
|
+
// biome-ignore lint/style/noNonNullAssertion: guarded by the outer check
|
|
85
|
+
return this.semantic.query(sid, text, k, filter, options);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
let all = await this.scan(sid);
|
|
89
|
+
if (filter)
|
|
90
|
+
all = all.filter((e) => matchesKnowledgeFilter(e.metadata, filter));
|
|
25
91
|
return k ? all.slice(-k) : all;
|
|
26
92
|
}
|
|
27
93
|
async scan(sid) {
|
|
@@ -39,8 +105,14 @@ export class JsonlKnowledgeBackend {
|
|
|
39
105
|
}
|
|
40
106
|
}
|
|
41
107
|
async deleteSession(sid) {
|
|
42
|
-
|
|
43
|
-
|
|
108
|
+
await this.run(sid, async () => {
|
|
109
|
+
await rm(dirname(this.file(sid)), { recursive: true, force: true });
|
|
110
|
+
this.semantic?.deleteSession(sid);
|
|
111
|
+
this.built.delete(sid);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
get semanticRecallCapable() {
|
|
115
|
+
return this.semantic !== undefined;
|
|
44
116
|
}
|
|
45
117
|
}
|
|
46
118
|
//# sourceMappingURL=jsonl-knowledge-backend.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonl-knowledge-backend.js","sourceRoot":"","sources":["../../src/smart-agent/jsonl-knowledge-backend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,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C;IACL,CAAC;IAED,IAAI,qBAAqB;QACvB,OAAO,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC;IACrC,CAAC;CACF"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Real `pg.Pool` provider for the skill plugin-host's `postgres` catalog.
|
|
3
|
+
*
|
|
4
|
+
* The catalog store ({@link makePgCatalogStore} in `@mcp-abap-adt/llm-agent-libs`)
|
|
5
|
+
* speaks to the database through the minimal {@link IPgPool} seam
|
|
6
|
+
* (`query(sql, params?) → { rows, rowCount }`) so it carries NO `pg` dependency.
|
|
7
|
+
* That store does INSERT/SELECT/UPDATE on a single-row table but never CREATEs it,
|
|
8
|
+
* so production deployments need (a) a real connection and (b) the catalog table
|
|
9
|
+
* to exist. This module provides BOTH.
|
|
10
|
+
*
|
|
11
|
+
* `pg` is imported DYNAMICALLY (mirroring `@mcp-abap-adt/pg-vector-rag`) so it
|
|
12
|
+
* stays a soft dependency: the module imports with zero I/O, the Pool is created
|
|
13
|
+
* lazily on first `query()`, and unit tests inject a fake pool instead (the
|
|
14
|
+
* factory never touches a real DB).
|
|
15
|
+
*
|
|
16
|
+
* The DDL matches the columns {@link makePgCatalogStore} reads/writes exactly:
|
|
17
|
+
* `id text PRIMARY KEY, revision text NOT NULL, snapshot jsonb NOT NULL`.
|
|
18
|
+
*/
|
|
19
|
+
import type { IPgPool } from '@mcp-abap-adt/llm-agent-libs';
|
|
20
|
+
/** Minimal shape of the `pg.Pool` we consume (a subset of the real driver). */
|
|
21
|
+
interface RawPgPool {
|
|
22
|
+
query(sql: string, params?: unknown[]): Promise<{
|
|
23
|
+
rows: unknown[];
|
|
24
|
+
rowCount: number | null;
|
|
25
|
+
}>;
|
|
26
|
+
/** The real `pg.Pool` exposes this; closes all sockets in the pool. */
|
|
27
|
+
end(): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Build an {@link IPgPool} backed by a real `pg.Pool`. The Pool is created on
|
|
31
|
+
* first use (lazy dynamic import) and the catalog table is ensured exactly once
|
|
32
|
+
* before the first query reaches the catalog store.
|
|
33
|
+
*
|
|
34
|
+
* @param connectionString libpq connection string.
|
|
35
|
+
* @param table catalog table name (defaults to `skills_catalog`, matching the
|
|
36
|
+
* catalog store default; pass the SAME value configured on `catalog.table`).
|
|
37
|
+
*/
|
|
38
|
+
export declare function makePgPool(connectionString: string, table?: string, deps?: {
|
|
39
|
+
createPool?: (cs: string) => Promise<RawPgPool>;
|
|
40
|
+
}): IPgPool & {
|
|
41
|
+
end(): Promise<void>;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Build a READ-ONLY {@link IPgPool} backed by a real `pg.Pool`. Identical lazy
|
|
45
|
+
* dynamic-`import('pg')` Pool construction as {@link makePgPool}, but it NEVER
|
|
46
|
+
* runs DDL (no `CREATE TABLE`). A recall-only process configured with READ-ONLY
|
|
47
|
+
* pg credentials uses THIS pool so it does not crash attempting to create the
|
|
48
|
+
* catalog table it only ever reads.
|
|
49
|
+
*
|
|
50
|
+
* @param connectionString libpq connection string.
|
|
51
|
+
*/
|
|
52
|
+
export declare function makePgReadPool(connectionString: string, deps?: {
|
|
53
|
+
createPool?: (cs: string) => Promise<RawPgPool>;
|
|
54
|
+
}): IPgPool & {
|
|
55
|
+
end(): Promise<void>;
|
|
56
|
+
};
|
|
57
|
+
export {};
|
|
58
|
+
//# sourceMappingURL=pg-pool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pg-pool.d.ts","sourceRoot":"","sources":["../../src/smart-agent/pg-pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAqB5D,+EAA+E;AAC/E,UAAU,SAAS;IACjB,KAAK,CACH,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,OAAO,EAAE,GACjB,OAAO,CAAC;QAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,CAAC;IACzD,uEAAuE;IACvE,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACtB;AAaD;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,gBAAgB,EAAE,MAAM,EACxB,KAAK,GAAE,MAAsB,EAC7B,IAAI,GAAE;IAAE,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,CAAC,CAAA;CAAO,GAC7D,OAAO,GAAG;IAAE,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAsDpC;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,gBAAgB,EAAE,MAAM,EACxB,IAAI,GAAE;IAAE,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,CAAC,CAAA;CAAO,GAC7D,OAAO,GAAG;IAAE,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAiCpC"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Real `pg.Pool` provider for the skill plugin-host's `postgres` catalog.
|
|
3
|
+
*
|
|
4
|
+
* The catalog store ({@link makePgCatalogStore} in `@mcp-abap-adt/llm-agent-libs`)
|
|
5
|
+
* speaks to the database through the minimal {@link IPgPool} seam
|
|
6
|
+
* (`query(sql, params?) → { rows, rowCount }`) so it carries NO `pg` dependency.
|
|
7
|
+
* That store does INSERT/SELECT/UPDATE on a single-row table but never CREATEs it,
|
|
8
|
+
* so production deployments need (a) a real connection and (b) the catalog table
|
|
9
|
+
* to exist. This module provides BOTH.
|
|
10
|
+
*
|
|
11
|
+
* `pg` is imported DYNAMICALLY (mirroring `@mcp-abap-adt/pg-vector-rag`) so it
|
|
12
|
+
* stays a soft dependency: the module imports with zero I/O, the Pool is created
|
|
13
|
+
* lazily on first `query()`, and unit tests inject a fake pool instead (the
|
|
14
|
+
* factory never touches a real DB).
|
|
15
|
+
*
|
|
16
|
+
* The DDL matches the columns {@link makePgCatalogStore} reads/writes exactly:
|
|
17
|
+
* `id text PRIMARY KEY, revision text NOT NULL, snapshot jsonb NOT NULL`.
|
|
18
|
+
*/
|
|
19
|
+
/** Default catalog table — agrees with `makePgCatalogStore`'s default. */
|
|
20
|
+
const DEFAULT_TABLE = 'skills_catalog';
|
|
21
|
+
/**
|
|
22
|
+
* Strict SQL-identifier regex for the catalog table — bare identifier or one
|
|
23
|
+
* optional `schema.table` dot. The table name is interpolated into DDL/queries,
|
|
24
|
+
* so it MUST NOT trust its caller (belt-and-suspenders with the config-layer
|
|
25
|
+
* validation in `skill-plugins-config.ts`).
|
|
26
|
+
*/
|
|
27
|
+
const SQL_IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)?$/;
|
|
28
|
+
function assertSafeTable(table) {
|
|
29
|
+
if (!SQL_IDENTIFIER.test(table)) {
|
|
30
|
+
throw new Error(`pg-pool: invalid catalog table identifier '${table}' (must match ${SQL_IDENTIFIER.source})`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** Lazily resolve the `pg` driver and construct a real Pool. */
|
|
34
|
+
async function createRawPool(connectionString) {
|
|
35
|
+
const mod = (await import('pg'));
|
|
36
|
+
const PoolCtor = mod.Pool ?? mod.default?.Pool;
|
|
37
|
+
if (!PoolCtor)
|
|
38
|
+
throw new Error('pg module did not expose Pool');
|
|
39
|
+
return new PoolCtor({ connectionString });
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Build an {@link IPgPool} backed by a real `pg.Pool`. The Pool is created on
|
|
43
|
+
* first use (lazy dynamic import) and the catalog table is ensured exactly once
|
|
44
|
+
* before the first query reaches the catalog store.
|
|
45
|
+
*
|
|
46
|
+
* @param connectionString libpq connection string.
|
|
47
|
+
* @param table catalog table name (defaults to `skills_catalog`, matching the
|
|
48
|
+
* catalog store default; pass the SAME value configured on `catalog.table`).
|
|
49
|
+
*/
|
|
50
|
+
export function makePgPool(connectionString, table = DEFAULT_TABLE, deps = {}) {
|
|
51
|
+
assertSafeTable(table);
|
|
52
|
+
const create = deps.createPool ?? createRawPool;
|
|
53
|
+
let poolPromise;
|
|
54
|
+
let ensured;
|
|
55
|
+
// The real `pg.Pool` throws on a second `.end()`. Overlapping cleanup paths
|
|
56
|
+
// (initSkillHost on failure + the start() finally + closeFns) may all reach
|
|
57
|
+
// here, so guard so a second end() is a no-op rather than a throw.
|
|
58
|
+
let ended = false;
|
|
59
|
+
const getPool = () => {
|
|
60
|
+
if (!poolPromise)
|
|
61
|
+
poolPromise = create(connectionString);
|
|
62
|
+
return poolPromise;
|
|
63
|
+
};
|
|
64
|
+
const ensureTable = (pool) => {
|
|
65
|
+
if (!ensured) {
|
|
66
|
+
ensured = pool
|
|
67
|
+
.query(`CREATE TABLE IF NOT EXISTS ${table} (` +
|
|
68
|
+
'id text PRIMARY KEY, ' +
|
|
69
|
+
'revision text NOT NULL, ' +
|
|
70
|
+
'snapshot jsonb NOT NULL)')
|
|
71
|
+
.then(() => undefined);
|
|
72
|
+
}
|
|
73
|
+
return ensured;
|
|
74
|
+
};
|
|
75
|
+
return {
|
|
76
|
+
async query(sql, params) {
|
|
77
|
+
// A query after end() is a programming error: getPool() would lazily build a
|
|
78
|
+
// BRAND-NEW pool that the (now no-op) end() can never close → socket leak.
|
|
79
|
+
// Fail loud instead of silently reopening an unclosable pool.
|
|
80
|
+
if (ended)
|
|
81
|
+
throw new Error('pg pool is closed (query after end())');
|
|
82
|
+
const pool = await getPool();
|
|
83
|
+
await ensureTable(pool);
|
|
84
|
+
const res = await pool.query(sql, params);
|
|
85
|
+
return { rows: res.rows, rowCount: res.rowCount ?? 0 };
|
|
86
|
+
},
|
|
87
|
+
// Close the real pool so its sockets do not outlive server shutdown.
|
|
88
|
+
// AWAIT `poolPromise` (not a `createdPool` snapshot): if creation is still
|
|
89
|
+
// IN FLIGHT when end() is called, we wait for it and close the resulting
|
|
90
|
+
// pool — otherwise a pool that finishes creating after end() would leak.
|
|
91
|
+
// Idempotent: a second end() is a no-op (the raw pg.Pool throws on double-end).
|
|
92
|
+
async end() {
|
|
93
|
+
if (ended)
|
|
94
|
+
return;
|
|
95
|
+
ended = true;
|
|
96
|
+
if (poolPromise) {
|
|
97
|
+
const pool = await poolPromise.catch(() => undefined);
|
|
98
|
+
if (pool)
|
|
99
|
+
await pool.end();
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Build a READ-ONLY {@link IPgPool} backed by a real `pg.Pool`. Identical lazy
|
|
106
|
+
* dynamic-`import('pg')` Pool construction as {@link makePgPool}, but it NEVER
|
|
107
|
+
* runs DDL (no `CREATE TABLE`). A recall-only process configured with READ-ONLY
|
|
108
|
+
* pg credentials uses THIS pool so it does not crash attempting to create the
|
|
109
|
+
* catalog table it only ever reads.
|
|
110
|
+
*
|
|
111
|
+
* @param connectionString libpq connection string.
|
|
112
|
+
*/
|
|
113
|
+
export function makePgReadPool(connectionString, deps = {}) {
|
|
114
|
+
const create = deps.createPool ?? createRawPool;
|
|
115
|
+
let poolPromise;
|
|
116
|
+
// The real `pg.Pool` throws on a second `.end()`; guard for idempotency.
|
|
117
|
+
let ended = false;
|
|
118
|
+
const getPool = () => {
|
|
119
|
+
if (!poolPromise)
|
|
120
|
+
poolPromise = create(connectionString);
|
|
121
|
+
return poolPromise;
|
|
122
|
+
};
|
|
123
|
+
return {
|
|
124
|
+
async query(sql, params) {
|
|
125
|
+
// A query after end() is a programming error: getPool() would lazily build a
|
|
126
|
+
// BRAND-NEW pool that the (now no-op) end() can never close → socket leak.
|
|
127
|
+
// Fail loud instead of silently reopening an unclosable pool.
|
|
128
|
+
if (ended)
|
|
129
|
+
throw new Error('pg pool is closed (query after end())');
|
|
130
|
+
const pool = await getPool();
|
|
131
|
+
const res = await pool.query(sql, params);
|
|
132
|
+
return { rows: res.rows, rowCount: res.rowCount ?? 0 };
|
|
133
|
+
},
|
|
134
|
+
// Close the pool, awaiting an IN-FLIGHT creation (see makePgPool.end). A pool
|
|
135
|
+
// that finishes creating after end() must still be closed, not leaked.
|
|
136
|
+
// Idempotent: a second end() is a no-op (the raw pg.Pool throws on double-end).
|
|
137
|
+
async end() {
|
|
138
|
+
if (ended)
|
|
139
|
+
return;
|
|
140
|
+
ended = true;
|
|
141
|
+
if (poolPromise) {
|
|
142
|
+
const pool = await poolPromise.catch(() => undefined);
|
|
143
|
+
if (pool)
|
|
144
|
+
await pool.end();
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=pg-pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pg-pool.js","sourceRoot":"","sources":["../../src/smart-agent/pg-pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,0EAA0E;AAC1E,MAAM,aAAa,GAAG,gBAAgB,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,cAAc,GAAG,qDAAqD,CAAC;AAE7E,SAAS,eAAe,CAAC,KAAa;IACpC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CACb,8CAA8C,KAAK,iBAAiB,cAAc,CAAC,MAAM,GAAG,CAC7F,CAAC;IACJ,CAAC;AACH,CAAC;AAYD,gEAAgE;AAChE,KAAK,UAAU,aAAa,CAAC,gBAAwB;IACnD,MAAM,GAAG,GAAG,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,CAG9B,CAAC;IACF,MAAM,QAAQ,GAAG,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC;IAC/C,IAAI,CAAC,QAAQ;QAAE,MAAM,IAAI,KA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EAAE,GAAG,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,IAAI,CAAC,EAAE,CAAC;QACzD,CAAC;QACD,8EAA8E;QAC9E,uEAAuE;QACvE,gFAAgF;QAChF,KAAK,CAAC,GAAG;YACP,IAAI,KAAK;gBAAE,OAAO;YAClB,KAAK,GAAG,IAAI,CAAC;YACb,IAAI,WAAW,EAAE,CAAC;gBAChB,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;gBACtD,IAAI,IAAI;oBAAE,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;YAC7B,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse + validate the top-level `skillPlugins:` server config key into a
|
|
3
|
+
* normalized {@link SkillPluginsConfig}.
|
|
4
|
+
*
|
|
5
|
+
* This is the skill PLUGIN-HOST config — a NEW key, DISTINCT from the existing
|
|
6
|
+
* `skills:` ({@link SmartServerSkillsConfig}, the FS skill-MANAGER consumed by
|
|
7
|
+
* `resolveSkillManager`). The two are unrelated features and must not collide.
|
|
8
|
+
*
|
|
9
|
+
* The host materialises consumer-supplied domain skills into a grouped
|
|
10
|
+
* skills-RAG and the pipelines recall from it. This module only normalizes +
|
|
11
|
+
* fail-loud validates the deployment config; assembly lives in the host factory.
|
|
12
|
+
*/
|
|
13
|
+
/** Normalized store selection. A persistent (`qdrant`) store carries its URL/auth. */
|
|
14
|
+
export type SkillPluginsStoreConfig = {
|
|
15
|
+
type: 'in-memory';
|
|
16
|
+
} | {
|
|
17
|
+
type: 'qdrant';
|
|
18
|
+
url: string;
|
|
19
|
+
apiKey?: string;
|
|
20
|
+
collection?: string;
|
|
21
|
+
};
|
|
22
|
+
/** Normalized catalog selection. A persistent store requires a `postgres` catalog. */
|
|
23
|
+
export type SkillPluginsCatalogConfig = {
|
|
24
|
+
type: 'in-process';
|
|
25
|
+
} | {
|
|
26
|
+
type: 'postgres';
|
|
27
|
+
connectionString: string;
|
|
28
|
+
table?: string;
|
|
29
|
+
};
|
|
30
|
+
/** A FETCHED source: a marketplace/registry pulled into memory. Requires a
|
|
31
|
+
* non-empty `enabled` plugin list (omitting it is a config error, NOT "load all"). */
|
|
32
|
+
export interface SkillPluginsFetchedSource {
|
|
33
|
+
id: string;
|
|
34
|
+
registry?: string;
|
|
35
|
+
enabled?: readonly string[];
|
|
36
|
+
/** Acquisition/materialisation strategy name (validated via the registry). */
|
|
37
|
+
strategy?: string;
|
|
38
|
+
/** Opaque, strategy-specific config (incl. any placement rules). */
|
|
39
|
+
strategyConfig?: Record<string, unknown>;
|
|
40
|
+
}
|
|
41
|
+
/** A PROGRAMMATIC source: the consumer's pre-filtered, in-memory record set.
|
|
42
|
+
* Carries NO `enabled` (it is already the exact set); each record carries a `group`. */
|
|
43
|
+
export interface SkillPluginsRecordsSource {
|
|
44
|
+
id: string;
|
|
45
|
+
records: readonly unknown[];
|
|
46
|
+
}
|
|
47
|
+
export type SkillPluginsSource = SkillPluginsFetchedSource | SkillPluginsRecordsSource;
|
|
48
|
+
/** The normalized skill plugin-host config (defaults applied). */
|
|
49
|
+
export interface SkillPluginsConfig {
|
|
50
|
+
/** Consumption mode. Only `implicit` is accepted this phase. */
|
|
51
|
+
mode: 'implicit';
|
|
52
|
+
store: SkillPluginsStoreConfig;
|
|
53
|
+
/** Stable vector-space id; MANDATORY for a persistent (qdrant) store. */
|
|
54
|
+
embeddingSpaceId?: string;
|
|
55
|
+
/** Serving embedder selection (provider + optional model). */
|
|
56
|
+
embedder?: {
|
|
57
|
+
provider: string;
|
|
58
|
+
model?: string;
|
|
59
|
+
};
|
|
60
|
+
/** Declared embedding dimension (skips the probe embed when set). */
|
|
61
|
+
dimension?: number;
|
|
62
|
+
catalog: SkillPluginsCatalogConfig;
|
|
63
|
+
/** Max records recalled per query. Default 4. */
|
|
64
|
+
k: number;
|
|
65
|
+
/** Min cosine similarity in [0,1]; below → dropped. Default 0.3. */
|
|
66
|
+
threshold: number;
|
|
67
|
+
/** Self-assembling pipelines' "Relevant skills" block char budget. Default 4000. */
|
|
68
|
+
maxInjectChars: number;
|
|
69
|
+
/** Chunking bound. Default 1500. */
|
|
70
|
+
chunk: {
|
|
71
|
+
maxChars: number;
|
|
72
|
+
};
|
|
73
|
+
/** true → a source failure aborts that group; false → carry-forward. Default false. */
|
|
74
|
+
strict: boolean;
|
|
75
|
+
/** publishCatalog CAS retries on a concurrent-loader conflict. Default 3. */
|
|
76
|
+
catalogCasMaxAttempts: number;
|
|
77
|
+
/** Retired-generation grace before background reclaim (ms). Default 30000 (>= 1000). */
|
|
78
|
+
retiredGraceMs: number;
|
|
79
|
+
/** Orphan-generation grace before crash-resumable reclaim (ms). Default 3600000. */
|
|
80
|
+
orphanGraceMs: number;
|
|
81
|
+
/** Recall deadline (ms) — defaults to floor(retiredGraceMs*0.8) for qdrant; unused in-memory. */
|
|
82
|
+
recallTimeoutMs?: number;
|
|
83
|
+
/** Single collection the controller planner recalls (self-assembling pipelines). */
|
|
84
|
+
controllerSkillGroup?: string;
|
|
85
|
+
/** Which collections assembler pipelines read (implicit). Omit → all produced. */
|
|
86
|
+
serveCollections?: readonly string[];
|
|
87
|
+
/** false = recall-only (no ingest); requires a persistent store. Default true. */
|
|
88
|
+
loadOnStartup: boolean;
|
|
89
|
+
/** Acquisition sources. Absent → recall-only (a persistent store must be present). */
|
|
90
|
+
sources?: readonly SkillPluginsSource[];
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Parse + validate the raw `skillPlugins:` YAML/object into a normalized
|
|
94
|
+
* {@link SkillPluginsConfig}. Throws a fail-loud `Error` on any invalid config.
|
|
95
|
+
*/
|
|
96
|
+
export declare function parseSkillPluginsConfig(raw: unknown): SkillPluginsConfig;
|
|
97
|
+
//# sourceMappingURL=skill-plugins-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1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