ghagga-db 2.8.1 → 3.0.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/LICENSE +21 -0
- package/dist/crypto.d.ts +24 -4
- package/dist/crypto.d.ts.map +1 -1
- package/dist/crypto.js +68 -10
- package/dist/crypto.js.map +1 -1
- package/dist/migrate.js +7 -17
- package/dist/migrate.js.map +1 -1
- package/dist/queries.d.ts +97 -151
- package/dist/queries.d.ts.map +1 -1
- package/dist/queries.js +195 -84
- package/dist/queries.js.map +1 -1
- package/dist/schema.d.ts +83 -353
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +15 -33
- package/dist/schema.js.map +1 -1
- package/package.json +16 -15
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 JNZader & Gentleman Programming Community
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/crypto.d.ts
CHANGED
|
@@ -2,18 +2,38 @@
|
|
|
2
2
|
* AES-256-GCM encryption/decryption for API keys.
|
|
3
3
|
*
|
|
4
4
|
* Uses Node.js crypto module (Web Crypto API compatible).
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
|
+
* ## Formats
|
|
7
|
+
*
|
|
8
|
+
* v1 (legacy, read-only): base64(iv[12] + ciphertext + authTag[16])
|
|
9
|
+
* — compact packed format used by ghagga ≤ v3.x
|
|
10
|
+
*
|
|
11
|
+
* v2 (current): "v2:<base64iv>:<base64cipher>:<base64authtag>"
|
|
12
|
+
* — aligns with mcp-llm-bridge vault/crypto.ts EncryptedData layout;
|
|
13
|
+
* each component is separately base64-encoded and colon-delimited.
|
|
14
|
+
* Canonical implementation: mcp-llm-bridge/src/vault/crypto.ts
|
|
15
|
+
*
|
|
16
|
+
* `decrypt()` auto-detects the format by checking for the "v2:" prefix.
|
|
17
|
+
* `encrypt()` always produces v2. Existing v1 values decrypt transparently.
|
|
18
|
+
*
|
|
19
|
+
* ## Migration
|
|
20
|
+
* ghagga v4 is a fresh deploy — there is no production data to migrate from v1
|
|
21
|
+
* to v2. v2 is the only format `encrypt()` writes; v1 reads are still supported
|
|
22
|
+
* by `decrypt()` for any rare legacy values.
|
|
6
23
|
*
|
|
7
24
|
* ENCRYPTION_KEY env var: 64 hex characters (32 bytes).
|
|
8
25
|
* Generate with: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
|
|
9
26
|
*/
|
|
10
27
|
/**
|
|
11
28
|
* Encrypt plaintext using AES-256-GCM.
|
|
12
|
-
* @returns
|
|
29
|
+
* @returns v2 format: "v2:<base64iv>:<base64cipher>:<base64authtag>"
|
|
13
30
|
*/
|
|
14
31
|
export declare function encrypt(plaintext: string): string;
|
|
15
32
|
/**
|
|
16
|
-
* Decrypt
|
|
33
|
+
* Decrypt a v1 or v2 encrypted string back to plaintext.
|
|
34
|
+
*
|
|
35
|
+
* v1: base64(iv[12] + ciphertext + authTag[16])
|
|
36
|
+
* v2: "v2:<base64iv>:<base64cipher>:<base64authtag>"
|
|
17
37
|
*/
|
|
18
|
-
export declare function decrypt(
|
|
38
|
+
export declare function decrypt(value: string): string;
|
|
19
39
|
//# sourceMappingURL=crypto.d.ts.map
|
package/dist/crypto.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAoBH;;;GAGG;AACH,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CASjD;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQ7C"}
|
package/dist/crypto.js
CHANGED
|
@@ -2,7 +2,24 @@
|
|
|
2
2
|
* AES-256-GCM encryption/decryption for API keys.
|
|
3
3
|
*
|
|
4
4
|
* Uses Node.js crypto module (Web Crypto API compatible).
|
|
5
|
-
*
|
|
5
|
+
*
|
|
6
|
+
* ## Formats
|
|
7
|
+
*
|
|
8
|
+
* v1 (legacy, read-only): base64(iv[12] + ciphertext + authTag[16])
|
|
9
|
+
* — compact packed format used by ghagga ≤ v3.x
|
|
10
|
+
*
|
|
11
|
+
* v2 (current): "v2:<base64iv>:<base64cipher>:<base64authtag>"
|
|
12
|
+
* — aligns with mcp-llm-bridge vault/crypto.ts EncryptedData layout;
|
|
13
|
+
* each component is separately base64-encoded and colon-delimited.
|
|
14
|
+
* Canonical implementation: mcp-llm-bridge/src/vault/crypto.ts
|
|
15
|
+
*
|
|
16
|
+
* `decrypt()` auto-detects the format by checking for the "v2:" prefix.
|
|
17
|
+
* `encrypt()` always produces v2. Existing v1 values decrypt transparently.
|
|
18
|
+
*
|
|
19
|
+
* ## Migration
|
|
20
|
+
* ghagga v4 is a fresh deploy — there is no production data to migrate from v1
|
|
21
|
+
* to v2. v2 is the only format `encrypt()` writes; v1 reads are still supported
|
|
22
|
+
* by `decrypt()` for any rare legacy values.
|
|
6
23
|
*
|
|
7
24
|
* ENCRYPTION_KEY env var: 64 hex characters (32 bytes).
|
|
8
25
|
* Generate with: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
|
|
@@ -11,6 +28,7 @@ import { createCipheriv, createDecipheriv, randomBytes } from 'node:crypto';
|
|
|
11
28
|
const IV_LENGTH = 12;
|
|
12
29
|
const AUTH_TAG_LENGTH = 16;
|
|
13
30
|
const ALGORITHM = 'aes-256-gcm';
|
|
31
|
+
const V2_PREFIX = 'v2:';
|
|
14
32
|
function getEncryptionKey() {
|
|
15
33
|
const key = process.env.ENCRYPTION_KEY;
|
|
16
34
|
if (!key) {
|
|
@@ -23,7 +41,7 @@ function getEncryptionKey() {
|
|
|
23
41
|
}
|
|
24
42
|
/**
|
|
25
43
|
* Encrypt plaintext using AES-256-GCM.
|
|
26
|
-
* @returns
|
|
44
|
+
* @returns v2 format: "v2:<base64iv>:<base64cipher>:<base64authtag>"
|
|
27
45
|
*/
|
|
28
46
|
export function encrypt(plaintext) {
|
|
29
47
|
const key = getEncryptionKey();
|
|
@@ -31,15 +49,22 @@ export function encrypt(plaintext) {
|
|
|
31
49
|
const cipher = createCipheriv(ALGORITHM, key, iv);
|
|
32
50
|
const encrypted = Buffer.concat([cipher.update(plaintext, 'utf8'), cipher.final()]);
|
|
33
51
|
const authTag = cipher.getAuthTag();
|
|
34
|
-
|
|
35
|
-
const combined = Buffer.concat([iv, encrypted, authTag]);
|
|
36
|
-
return combined.toString('base64');
|
|
52
|
+
return `${V2_PREFIX}${iv.toString('base64')}:${encrypted.toString('base64')}:${authTag.toString('base64')}`;
|
|
37
53
|
}
|
|
38
54
|
/**
|
|
39
|
-
* Decrypt
|
|
55
|
+
* Decrypt a v1 or v2 encrypted string back to plaintext.
|
|
56
|
+
*
|
|
57
|
+
* v1: base64(iv[12] + ciphertext + authTag[16])
|
|
58
|
+
* v2: "v2:<base64iv>:<base64cipher>:<base64authtag>"
|
|
40
59
|
*/
|
|
41
|
-
export function decrypt(
|
|
60
|
+
export function decrypt(value) {
|
|
42
61
|
const key = getEncryptionKey();
|
|
62
|
+
if (value.startsWith(V2_PREFIX)) {
|
|
63
|
+
return decryptV2(value.slice(V2_PREFIX.length), key);
|
|
64
|
+
}
|
|
65
|
+
return decryptV1(value, key);
|
|
66
|
+
}
|
|
67
|
+
function decryptV1(base64str, key) {
|
|
43
68
|
const combined = Buffer.from(base64str, 'base64');
|
|
44
69
|
if (combined.length < IV_LENGTH + AUTH_TAG_LENGTH) {
|
|
45
70
|
throw new Error('Invalid encrypted data: too short');
|
|
@@ -47,9 +72,42 @@ export function decrypt(base64str) {
|
|
|
47
72
|
const iv = combined.subarray(0, IV_LENGTH);
|
|
48
73
|
const authTag = combined.subarray(combined.length - AUTH_TAG_LENGTH);
|
|
49
74
|
const ciphertext = combined.subarray(IV_LENGTH, combined.length - AUTH_TAG_LENGTH);
|
|
50
|
-
|
|
75
|
+
// Defense in depth: the length check above already guarantees these, but
|
|
76
|
+
// assert explicitly so a future refactor cannot silently weaken them.
|
|
77
|
+
if (iv.length !== IV_LENGTH) {
|
|
78
|
+
throw new Error('Invalid encrypted data: IV must be exactly 12 bytes');
|
|
79
|
+
}
|
|
80
|
+
if (authTag.length !== AUTH_TAG_LENGTH) {
|
|
81
|
+
throw new Error('Invalid encrypted data: auth tag must be exactly 16 bytes');
|
|
82
|
+
}
|
|
83
|
+
// authTagLength makes Node reject any setAuthTag() of a different length.
|
|
84
|
+
const decipher = createDecipheriv(ALGORITHM, key, iv, { authTagLength: AUTH_TAG_LENGTH });
|
|
85
|
+
decipher.setAuthTag(authTag);
|
|
86
|
+
return Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString('utf8');
|
|
87
|
+
}
|
|
88
|
+
function decryptV2(payload, key) {
|
|
89
|
+
const parts = payload.split(':');
|
|
90
|
+
if (parts.length !== 3) {
|
|
91
|
+
throw new Error('Invalid v2 encrypted data: expected "iv:cipher:authTag"');
|
|
92
|
+
}
|
|
93
|
+
const iv = Buffer.from(parts[0], 'base64');
|
|
94
|
+
const ciphertext = Buffer.from(parts[1], 'base64');
|
|
95
|
+
const authTag = Buffer.from(parts[2], 'base64');
|
|
96
|
+
// SECURITY: enforce exact component lengths. Node's GCM implementation
|
|
97
|
+
// accepts truncated auth tags (e.g. 4 bytes), which would drop forgery
|
|
98
|
+
// resistance from 2^128 to 2^32 for an attacker with DB write access.
|
|
99
|
+
// Arbitrary-length IVs are likewise rejected — only the 96-bit IV that
|
|
100
|
+
// encrypt() produces is valid.
|
|
101
|
+
if (iv.length !== IV_LENGTH) {
|
|
102
|
+
throw new Error('Invalid v2 encrypted data: IV must be exactly 12 bytes');
|
|
103
|
+
}
|
|
104
|
+
if (authTag.length !== AUTH_TAG_LENGTH) {
|
|
105
|
+
throw new Error('Invalid v2 encrypted data: auth tag must be exactly 16 bytes');
|
|
106
|
+
}
|
|
107
|
+
// authTagLength makes Node reject any setAuthTag() of a different length
|
|
108
|
+
// (defense in depth alongside the explicit check above).
|
|
109
|
+
const decipher = createDecipheriv(ALGORITHM, key, iv, { authTagLength: AUTH_TAG_LENGTH });
|
|
51
110
|
decipher.setAuthTag(authTag);
|
|
52
|
-
|
|
53
|
-
return decrypted.toString('utf8');
|
|
111
|
+
return Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString('utf8');
|
|
54
112
|
}
|
|
55
113
|
//# sourceMappingURL=crypto.js.map
|
package/dist/crypto.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../src/crypto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AAC;IAClF,CAAC;IAED,yEAAyE;IACzE,yDAAyD;IACzD,MAAM,QAAQ,GAAG,gBAAgB,CAAC,SAAS,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC,CAAC;IAC1F,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAE7B,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACzF,CAAC"}
|
package/dist/migrate.js
CHANGED
|
@@ -26,23 +26,13 @@ async function main() {
|
|
|
26
26
|
});
|
|
27
27
|
console.log('✅ Drizzle migrations complete');
|
|
28
28
|
// Step 2: Run custom SQL (tsvector, triggers)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
catch (error) {
|
|
37
|
-
// If the file doesn't exist or SQL fails on "already exists", that's fine
|
|
38
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
39
|
-
if (message.includes('ENOENT')) {
|
|
40
|
-
console.log('⏭️ No custom SQL file found, skipping');
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
console.warn('⚠️ Custom SQL warning (may be safe to ignore):', message);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
29
|
+
// The file is idempotent (IF NOT EXISTS, CREATE OR REPLACE, DROP TRIGGER IF EXISTS),
|
|
30
|
+
// so any error here is a real failure and MUST surface — do not swallow.
|
|
31
|
+
const customSqlPath = join(__dirname, '..', 'drizzle', '_custom_tsvector.sql');
|
|
32
|
+
const customSql = readFileSync(customSqlPath, 'utf-8');
|
|
33
|
+
console.log('🔄 Running custom SQL (tsvector + triggers)...');
|
|
34
|
+
await pool.query(customSql);
|
|
35
|
+
console.log('✅ Custom SQL complete');
|
|
46
36
|
await pool.end();
|
|
47
37
|
console.log('🎉 Database ready');
|
|
48
38
|
}
|
package/dist/migrate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE1D,KAAK,UAAU,IAAI;IACjB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;IACrC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAC5C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;IAEhD,MAAM,IAAI,GAAG,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,gBAAgB,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;IAC5D,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzB,yCAAyC;IACzC,MAAM,OAAO,CAAC,EAAE,EAAE;QAChB,gBAAgB,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,SAAS,CAAC;KACnD,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;IAE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8C;IAC9C,qFAAqF;IACrF,yEAAyE;IACzE,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,sBAAsB,CAAC,CAAC;IAC/E,MAAM,SAAS,GAAG,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IACvD,OAAO,CAAC,GAAG,CAAC,gDAAgD,CAAC,CAAC;IAC9D,MAAM,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC5B,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IAErC,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;IACjB,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;AACnC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;IAC1C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/queries.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Database } from './client.js';
|
|
2
|
-
import { type
|
|
2
|
+
import { type DbProviderChainEntry, type RepoSettings, reviews } from './schema.js';
|
|
3
3
|
export declare function upsertInstallation(db: Database, data: {
|
|
4
4
|
githubInstallationId: number;
|
|
5
5
|
accountLogin: string;
|
|
@@ -112,10 +112,11 @@ export declare function getRepositoryById(db: Database, id: number): Promise<{
|
|
|
112
112
|
useGlobalSettings: boolean;
|
|
113
113
|
providerChain: DbProviderChainEntry[];
|
|
114
114
|
aiReviewEnabled: boolean;
|
|
115
|
-
delegatedCiPolicy: DbDelegatedCiPolicy | null;
|
|
116
115
|
encryptedApiKey: string | null;
|
|
117
116
|
llmProvider: string;
|
|
118
117
|
llmModel: string | null;
|
|
118
|
+
workflowInstalledAt: Date | null;
|
|
119
|
+
workflowSha: string | null;
|
|
119
120
|
createdAt: Date;
|
|
120
121
|
updatedAt: Date;
|
|
121
122
|
}>;
|
|
@@ -136,10 +137,11 @@ export declare function upsertRepository(db: Database, data: {
|
|
|
136
137
|
githubRepoId: number;
|
|
137
138
|
fullName: string;
|
|
138
139
|
useGlobalSettings: boolean;
|
|
139
|
-
delegatedCiPolicy: DbDelegatedCiPolicy | null;
|
|
140
140
|
encryptedApiKey: string | null;
|
|
141
141
|
llmProvider: string;
|
|
142
142
|
llmModel: string | null;
|
|
143
|
+
workflowInstalledAt: Date | null;
|
|
144
|
+
workflowSha: string | null;
|
|
143
145
|
}>;
|
|
144
146
|
export declare function getRepoByFullName(db: Database, fullName: string): Promise<{
|
|
145
147
|
id: number;
|
|
@@ -152,10 +154,11 @@ export declare function getRepoByFullName(db: Database, fullName: string): Promi
|
|
|
152
154
|
useGlobalSettings: boolean;
|
|
153
155
|
providerChain: DbProviderChainEntry[];
|
|
154
156
|
aiReviewEnabled: boolean;
|
|
155
|
-
delegatedCiPolicy: DbDelegatedCiPolicy | null;
|
|
156
157
|
encryptedApiKey: string | null;
|
|
157
158
|
llmProvider: string;
|
|
158
159
|
llmModel: string | null;
|
|
160
|
+
workflowInstalledAt: Date | null;
|
|
161
|
+
workflowSha: string | null;
|
|
159
162
|
createdAt: Date;
|
|
160
163
|
updatedAt: Date;
|
|
161
164
|
}>;
|
|
@@ -170,10 +173,11 @@ export declare function getRepoByGithubId(db: Database, githubRepoId: number): P
|
|
|
170
173
|
useGlobalSettings: boolean;
|
|
171
174
|
providerChain: DbProviderChainEntry[];
|
|
172
175
|
aiReviewEnabled: boolean;
|
|
173
|
-
delegatedCiPolicy: DbDelegatedCiPolicy | null;
|
|
174
176
|
encryptedApiKey: string | null;
|
|
175
177
|
llmProvider: string;
|
|
176
178
|
llmModel: string | null;
|
|
179
|
+
workflowInstalledAt: Date | null;
|
|
180
|
+
workflowSha: string | null;
|
|
177
181
|
createdAt: Date;
|
|
178
182
|
updatedAt: Date;
|
|
179
183
|
}>;
|
|
@@ -199,13 +203,18 @@ export declare function getReposByInstallationId(db: Database, installationId: n
|
|
|
199
203
|
useGlobalSettings: boolean;
|
|
200
204
|
providerChain: DbProviderChainEntry[];
|
|
201
205
|
aiReviewEnabled: boolean;
|
|
202
|
-
delegatedCiPolicy: DbDelegatedCiPolicy | null;
|
|
203
206
|
encryptedApiKey: string | null;
|
|
204
207
|
llmProvider: string;
|
|
205
208
|
llmModel: string | null;
|
|
209
|
+
workflowInstalledAt: Date | null;
|
|
210
|
+
workflowSha: string | null;
|
|
206
211
|
createdAt: Date;
|
|
207
212
|
updatedAt: Date;
|
|
208
213
|
}[]>;
|
|
214
|
+
export declare function updateWorkflowStatus(db: Database, repoId: number, data: {
|
|
215
|
+
workflowSha: string;
|
|
216
|
+
workflowInstalledAt: Date;
|
|
217
|
+
}): Promise<void>;
|
|
209
218
|
export declare function saveReview(db: Database, data: {
|
|
210
219
|
repositoryId: number;
|
|
211
220
|
prNumber: number;
|
|
@@ -245,6 +254,36 @@ export declare function getReviewsByRepoId(db: Database, repositoryId: number, o
|
|
|
245
254
|
metadata: unknown;
|
|
246
255
|
createdAt: Date;
|
|
247
256
|
}[]>;
|
|
257
|
+
/**
|
|
258
|
+
* Count all reviews for a specific repository.
|
|
259
|
+
* Used to compute pagination.total for the per-repo review listing.
|
|
260
|
+
*/
|
|
261
|
+
export declare function countReviewsByRepoId(db: Database, repositoryId: number): Promise<number>;
|
|
262
|
+
/**
|
|
263
|
+
* A review row enriched with its repository's full name, for cross-repository
|
|
264
|
+
* listings where the caller needs to label which repo each review belongs to.
|
|
265
|
+
*/
|
|
266
|
+
export type ReviewWithRepo = typeof reviews.$inferSelect & {
|
|
267
|
+
fullName: string;
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* List reviews across ALL repositories belonging to the given installation IDs,
|
|
271
|
+
* ordered by createdAt desc, with limit/offset pagination.
|
|
272
|
+
*
|
|
273
|
+
* Each row carries the repository `fullName` (via the join) so the caller can
|
|
274
|
+
* label reviews by repo. Returns an empty array when installationIds is empty
|
|
275
|
+
* (authz: a caller with no installations sees nothing).
|
|
276
|
+
*/
|
|
277
|
+
export declare function getReviewsByInstallationIds(db: Database, installationIds: number[], options?: {
|
|
278
|
+
limit?: number;
|
|
279
|
+
offset?: number;
|
|
280
|
+
}): Promise<ReviewWithRepo[]>;
|
|
281
|
+
/**
|
|
282
|
+
* Count all reviews across the repositories owned by the given installation IDs.
|
|
283
|
+
* Used to compute pagination.total for the cross-installation review listing.
|
|
284
|
+
* Returns 0 when installationIds is empty.
|
|
285
|
+
*/
|
|
286
|
+
export declare function countReviewsByInstallationIds(db: Database, installationIds: number[]): Promise<number>;
|
|
248
287
|
export declare function getReviewStats(db: Database, repositoryId: number): Promise<{
|
|
249
288
|
total: number;
|
|
250
289
|
passed: number;
|
|
@@ -257,6 +296,22 @@ export declare function getReviewsByDay(db: Database, repositoryId: number): Pro
|
|
|
257
296
|
passed: number;
|
|
258
297
|
failed: number;
|
|
259
298
|
}[]>;
|
|
299
|
+
export interface ReviewCostRow {
|
|
300
|
+
repositoryId: number;
|
|
301
|
+
fullName: string;
|
|
302
|
+
mode: string;
|
|
303
|
+
model: string | null;
|
|
304
|
+
tokens: number;
|
|
305
|
+
count: number;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Aggregate token / review counts across all repositories accessible to the
|
|
309
|
+
* given installation IDs, for the specified number of days back.
|
|
310
|
+
*
|
|
311
|
+
* Returns one row per (repositoryId, mode, model) combination so the caller
|
|
312
|
+
* can pivot into any desired shape (byModel, byMode, byRepo).
|
|
313
|
+
*/
|
|
314
|
+
export declare function getReviewCostStats(db: Database, installationIds: number[], days: number): Promise<ReviewCostRow[]>;
|
|
260
315
|
/**
|
|
261
316
|
* Delete all reviews for a specific repository by its ID.
|
|
262
317
|
* Returns the count of deleted rows.
|
|
@@ -304,6 +359,8 @@ export declare function saveObservation(db: Database, data: {
|
|
|
304
359
|
topicKey?: string;
|
|
305
360
|
filePaths?: string[];
|
|
306
361
|
severity?: string;
|
|
362
|
+
/** Pre-computed embedding vector. NULL when no embedding provider was available. */
|
|
363
|
+
embedding?: number[] | null;
|
|
307
364
|
}): Promise<{
|
|
308
365
|
id: number;
|
|
309
366
|
createdAt: Date;
|
|
@@ -319,14 +376,45 @@ export declare function saveObservation(db: Database, data: {
|
|
|
319
376
|
contentHash: string | null;
|
|
320
377
|
revisionCount: number;
|
|
321
378
|
lastAccessedAt: Date;
|
|
379
|
+
embedding: number[] | null;
|
|
322
380
|
}>;
|
|
381
|
+
/**
|
|
382
|
+
* Build a sanitized tsquery string from free-text input.
|
|
383
|
+
*
|
|
384
|
+
* Each word is quoted as a lexeme and terms are joined with OR ('|') —
|
|
385
|
+
* matching the SQLite backend's behavior. AND ('&') made multi-file diff
|
|
386
|
+
* queries (5-8 unrelated terms) return ~nothing, killing server memory recall.
|
|
387
|
+
*
|
|
388
|
+
* Backslashes are escaped first: inside a quoted lexeme, a trailing '\\' would
|
|
389
|
+
* otherwise escape the closing quote and produce a tsquery syntax error.
|
|
390
|
+
*
|
|
391
|
+
* Exported for unit testing (no live PG needed).
|
|
392
|
+
*/
|
|
393
|
+
export declare function buildTsQuery(query: string): string;
|
|
323
394
|
/**
|
|
324
395
|
* Full-text search observations using PostgreSQL tsvector.
|
|
325
396
|
* The search_observations SQL column is maintained by a trigger.
|
|
397
|
+
*
|
|
398
|
+
* When `embedFn` is provided, performs hybrid search:
|
|
399
|
+
* final_score = 0.7 * cosine_similarity + 0.3 * ts_rank
|
|
400
|
+
* Otherwise falls back to keyword-only tsvector search (original behavior).
|
|
326
401
|
*/
|
|
327
402
|
export declare function searchObservations(db: Database, project: string, query: string, options?: {
|
|
328
403
|
limit?: number;
|
|
329
404
|
type?: string;
|
|
405
|
+
/**
|
|
406
|
+
* Optional embedding function for hybrid search.
|
|
407
|
+
* When provided, semantic re-ranking is applied on top of keyword results.
|
|
408
|
+
* When undefined, falls back to keyword-only tsvector search.
|
|
409
|
+
*/
|
|
410
|
+
embedFn?: (text: string) => Promise<number[]>;
|
|
411
|
+
/**
|
|
412
|
+
* Number of ranked rows to RETURN (after re-ranking). Defaults to `limit`.
|
|
413
|
+
* Callers that post-filter rows (e.g. strength decay in the adapter) pass a
|
|
414
|
+
* larger value so the over-fetched candidates survive ranking and the caller
|
|
415
|
+
* can drop decayed rows without under-delivering below `limit`.
|
|
416
|
+
*/
|
|
417
|
+
fetchLimit?: number;
|
|
330
418
|
}): Promise<{
|
|
331
419
|
id: number;
|
|
332
420
|
sessionId: number | null;
|
|
@@ -342,6 +430,7 @@ export declare function searchObservations(db: Database, project: string, query:
|
|
|
342
430
|
createdAt: Date;
|
|
343
431
|
updatedAt: Date;
|
|
344
432
|
lastAccessedAt: Date;
|
|
433
|
+
embedding: number[] | null;
|
|
345
434
|
}[]>;
|
|
346
435
|
export declare function getObservationsBySession(db: Database, sessionId: number): Promise<{
|
|
347
436
|
id: number;
|
|
@@ -358,6 +447,7 @@ export declare function getObservationsBySession(db: Database, sessionId: number
|
|
|
358
447
|
createdAt: Date;
|
|
359
448
|
updatedAt: Date;
|
|
360
449
|
lastAccessedAt: Date;
|
|
450
|
+
embedding: number[] | null;
|
|
361
451
|
}[]>;
|
|
362
452
|
/**
|
|
363
453
|
* Delete a single observation by ID, scoped to installation.
|
|
@@ -396,6 +486,7 @@ export declare function getMemoryObservation(db: Database, installationId: numbe
|
|
|
396
486
|
createdAt: Date;
|
|
397
487
|
updatedAt: Date;
|
|
398
488
|
lastAccessedAt: Date;
|
|
489
|
+
embedding: number[] | null;
|
|
399
490
|
}>;
|
|
400
491
|
/**
|
|
401
492
|
* List observations with optional filtering, scoped to installation.
|
|
@@ -517,149 +608,4 @@ export declare function deleteMemoryObservationsByIds(db: Database, installation
|
|
|
517
608
|
export declare function clearEmptyMemorySessions(db: Database, installationId: number, project?: string): Promise<{
|
|
518
609
|
deletedCount: number;
|
|
519
610
|
}>;
|
|
520
|
-
export declare function getDelegatedCiPolicy(db: Database, repoId: number): Promise<DbDelegatedCiPolicy | null>;
|
|
521
|
-
export declare function updateDelegatedCiPolicy(db: Database, repoId: number, policy: DbDelegatedCiPolicy | null): Promise<void>;
|
|
522
|
-
export declare function createDelegatedCiRun(db: Database, data: {
|
|
523
|
-
repositoryId: number;
|
|
524
|
-
prNumber?: number;
|
|
525
|
-
jobKey: string;
|
|
526
|
-
classification: string;
|
|
527
|
-
state: string;
|
|
528
|
-
profile: string;
|
|
529
|
-
reasonCode?: string;
|
|
530
|
-
reasonDetail?: string;
|
|
531
|
-
callbackId?: string;
|
|
532
|
-
}): Promise<{
|
|
533
|
-
id: number;
|
|
534
|
-
createdAt: Date;
|
|
535
|
-
updatedAt: Date;
|
|
536
|
-
repositoryId: number;
|
|
537
|
-
prNumber: number | null;
|
|
538
|
-
summary: string | null;
|
|
539
|
-
startedAt: Date | null;
|
|
540
|
-
jobKey: string;
|
|
541
|
-
classification: string;
|
|
542
|
-
state: string;
|
|
543
|
-
reasonCode: string | null;
|
|
544
|
-
reasonDetail: string | null;
|
|
545
|
-
callbackId: string | null;
|
|
546
|
-
workflowRunId: string | null;
|
|
547
|
-
profile: string;
|
|
548
|
-
resultSummary: unknown;
|
|
549
|
-
completedAt: Date | null;
|
|
550
|
-
}>;
|
|
551
|
-
export declare function updateDelegatedCiRunState(db: Database, runId: number, updates: {
|
|
552
|
-
state: string;
|
|
553
|
-
reasonCode?: string;
|
|
554
|
-
reasonDetail?: string;
|
|
555
|
-
callbackId?: string;
|
|
556
|
-
workflowRunId?: string;
|
|
557
|
-
summary?: string;
|
|
558
|
-
resultSummary?: unknown;
|
|
559
|
-
startedAt?: Date;
|
|
560
|
-
completedAt?: Date;
|
|
561
|
-
}): Promise<{
|
|
562
|
-
id: number;
|
|
563
|
-
repositoryId: number;
|
|
564
|
-
prNumber: number | null;
|
|
565
|
-
jobKey: string;
|
|
566
|
-
classification: string;
|
|
567
|
-
state: string;
|
|
568
|
-
reasonCode: string | null;
|
|
569
|
-
reasonDetail: string | null;
|
|
570
|
-
callbackId: string | null;
|
|
571
|
-
workflowRunId: string | null;
|
|
572
|
-
profile: string;
|
|
573
|
-
summary: string | null;
|
|
574
|
-
resultSummary: unknown;
|
|
575
|
-
startedAt: Date | null;
|
|
576
|
-
completedAt: Date | null;
|
|
577
|
-
createdAt: Date;
|
|
578
|
-
updatedAt: Date;
|
|
579
|
-
}>;
|
|
580
|
-
export declare function getDelegatedCiRun(db: Database, runId: number): Promise<{
|
|
581
|
-
id: number;
|
|
582
|
-
repositoryId: number;
|
|
583
|
-
prNumber: number | null;
|
|
584
|
-
jobKey: string;
|
|
585
|
-
classification: string;
|
|
586
|
-
state: string;
|
|
587
|
-
reasonCode: string | null;
|
|
588
|
-
reasonDetail: string | null;
|
|
589
|
-
callbackId: string | null;
|
|
590
|
-
workflowRunId: string | null;
|
|
591
|
-
profile: string;
|
|
592
|
-
summary: string | null;
|
|
593
|
-
resultSummary: unknown;
|
|
594
|
-
startedAt: Date | null;
|
|
595
|
-
completedAt: Date | null;
|
|
596
|
-
createdAt: Date;
|
|
597
|
-
updatedAt: Date;
|
|
598
|
-
}>;
|
|
599
|
-
export declare function getDelegatedCiRunByCallbackId(db: Database, callbackId: string): Promise<{
|
|
600
|
-
id: number;
|
|
601
|
-
repositoryId: number;
|
|
602
|
-
prNumber: number | null;
|
|
603
|
-
jobKey: string;
|
|
604
|
-
classification: string;
|
|
605
|
-
state: string;
|
|
606
|
-
reasonCode: string | null;
|
|
607
|
-
reasonDetail: string | null;
|
|
608
|
-
callbackId: string | null;
|
|
609
|
-
workflowRunId: string | null;
|
|
610
|
-
profile: string;
|
|
611
|
-
summary: string | null;
|
|
612
|
-
resultSummary: unknown;
|
|
613
|
-
startedAt: Date | null;
|
|
614
|
-
completedAt: Date | null;
|
|
615
|
-
createdAt: Date;
|
|
616
|
-
updatedAt: Date;
|
|
617
|
-
}>;
|
|
618
|
-
export declare function updateDelegatedCiRunByCallbackId(db: Database, callbackId: string, updates: {
|
|
619
|
-
state: string;
|
|
620
|
-
summary?: string | null;
|
|
621
|
-
resultSummary?: unknown | null;
|
|
622
|
-
completedAt?: Date;
|
|
623
|
-
}): Promise<{
|
|
624
|
-
id: number;
|
|
625
|
-
repositoryId: number;
|
|
626
|
-
prNumber: number | null;
|
|
627
|
-
jobKey: string;
|
|
628
|
-
classification: string;
|
|
629
|
-
state: string;
|
|
630
|
-
reasonCode: string | null;
|
|
631
|
-
reasonDetail: string | null;
|
|
632
|
-
callbackId: string | null;
|
|
633
|
-
workflowRunId: string | null;
|
|
634
|
-
profile: string;
|
|
635
|
-
summary: string | null;
|
|
636
|
-
resultSummary: unknown;
|
|
637
|
-
startedAt: Date | null;
|
|
638
|
-
completedAt: Date | null;
|
|
639
|
-
createdAt: Date;
|
|
640
|
-
updatedAt: Date;
|
|
641
|
-
}>;
|
|
642
|
-
export declare function getDelegatedCiRunsByRepoId(db: Database, repositoryId: number, options?: {
|
|
643
|
-
limit?: number;
|
|
644
|
-
offset?: number;
|
|
645
|
-
}): Promise<{
|
|
646
|
-
id: number;
|
|
647
|
-
repositoryId: number;
|
|
648
|
-
prNumber: number | null;
|
|
649
|
-
jobKey: string;
|
|
650
|
-
classification: string;
|
|
651
|
-
state: string;
|
|
652
|
-
reasonCode: string | null;
|
|
653
|
-
reasonDetail: string | null;
|
|
654
|
-
callbackId: string | null;
|
|
655
|
-
workflowRunId: string | null;
|
|
656
|
-
profile: string;
|
|
657
|
-
summary: string | null;
|
|
658
|
-
resultSummary: unknown;
|
|
659
|
-
startedAt: Date | null;
|
|
660
|
-
completedAt: Date | null;
|
|
661
|
-
createdAt: Date;
|
|
662
|
-
updatedAt: Date;
|
|
663
|
-
}[]>;
|
|
664
|
-
export declare function countDelegatedCiRunsByRepoId(db: Database, repositoryId: number): Promise<number>;
|
|
665
611
|
//# sourceMappingURL=queries.d.ts.map
|
package/dist/queries.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../src/queries.ts"],"names":[],"m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