@hasna/mementos 0.14.60 → 0.14.62
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/cli/index.js +47 -0
- package/dist/db/relations.d.ts.map +1 -1
- package/dist/db/webhook_hooks.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/lib/project-detect.d.ts.map +1 -1
- package/dist/mcp/index.js +44 -1
- package/dist/pg-sync-worker.js +1 -0
- package/dist/server/index.js +87 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +1 -0
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -2183,6 +2183,7 @@ function translateSql(sql) {
|
|
|
2183
2183
|
});
|
|
2184
2184
|
translated = translated.replace(/lower\s*\(\s*hex\s*\(\s*randomblob\s*\(\s*\d+\s*\)\s*\)\s*\)/gi, "gen_random_uuid()::text");
|
|
2185
2185
|
translated = translated.replace(/\bIFNULL\s*\(/gi, "COALESCE(");
|
|
2186
|
+
translated = translated.replace(/\bINSTR\s*\(/gi, "STRPOS(");
|
|
2186
2187
|
if (/INSERT\s+OR\s+IGNORE\s+INTO/i.test(translated)) {
|
|
2187
2188
|
translated = translated.replace(/INSERT\s+OR\s+IGNORE\s+INTO/gi, "INSERT INTO");
|
|
2188
2189
|
translated = translated.replace(/;?\s*$/, " ON CONFLICT DO NOTHING");
|
|
@@ -7182,6 +7183,11 @@ function deleteRelation(id, db) {
|
|
|
7182
7183
|
throw new Error(`Relation not found: ${id}`);
|
|
7183
7184
|
}
|
|
7184
7185
|
function getRelatedEntities(entityId, relationType, db) {
|
|
7186
|
+
if (!db && isApiMode()) {
|
|
7187
|
+
const q = toQuery({ type: relationType });
|
|
7188
|
+
const { data } = apiJson("GET", `/entities/${encodeURIComponent(entityId)}/related${q}`);
|
|
7189
|
+
return data?.entities ?? [];
|
|
7190
|
+
}
|
|
7185
7191
|
const d = db || getDatabase();
|
|
7186
7192
|
let sql;
|
|
7187
7193
|
const params = [];
|
|
@@ -8064,6 +8070,18 @@ function parseRow(row) {
|
|
|
8064
8070
|
};
|
|
8065
8071
|
}
|
|
8066
8072
|
function createWebhookHook(input, db) {
|
|
8073
|
+
if (!db && isApiMode()) {
|
|
8074
|
+
const { data } = apiJson("POST", "/webhooks", {
|
|
8075
|
+
type: input.type,
|
|
8076
|
+
handler_url: input.handlerUrl,
|
|
8077
|
+
priority: input.priority,
|
|
8078
|
+
blocking: input.blocking,
|
|
8079
|
+
agent_id: input.agentId,
|
|
8080
|
+
project_id: input.projectId,
|
|
8081
|
+
description: input.description
|
|
8082
|
+
});
|
|
8083
|
+
return data;
|
|
8084
|
+
}
|
|
8067
8085
|
const d = db || getDatabase();
|
|
8068
8086
|
const id = shortUuid();
|
|
8069
8087
|
const timestamp = now2();
|
|
@@ -8083,11 +8101,22 @@ function createWebhookHook(input, db) {
|
|
|
8083
8101
|
return getWebhookHook(id, d);
|
|
8084
8102
|
}
|
|
8085
8103
|
function getWebhookHook(id, db) {
|
|
8104
|
+
if (!db && isApiMode()) {
|
|
8105
|
+
const { status, data } = apiJson("GET", `/webhooks/${encodeURIComponent(id)}`);
|
|
8106
|
+
if (status === 404 || !data)
|
|
8107
|
+
return null;
|
|
8108
|
+
return data;
|
|
8109
|
+
}
|
|
8086
8110
|
const d = db || getDatabase();
|
|
8087
8111
|
const row = d.query("SELECT * FROM webhook_hooks WHERE id = ?").get(id);
|
|
8088
8112
|
return row ? parseRow(row) : null;
|
|
8089
8113
|
}
|
|
8090
8114
|
function listWebhookHooks(filter = {}, db) {
|
|
8115
|
+
if (!db && isApiMode()) {
|
|
8116
|
+
const q = toQuery({ type: filter.type, enabled: filter.enabled });
|
|
8117
|
+
const { data } = apiJson("GET", `/webhooks${q}`);
|
|
8118
|
+
return data ?? [];
|
|
8119
|
+
}
|
|
8091
8120
|
const d = db || getDatabase();
|
|
8092
8121
|
const conditions = [];
|
|
8093
8122
|
const params = [];
|
|
@@ -8104,6 +8133,16 @@ function listWebhookHooks(filter = {}, db) {
|
|
|
8104
8133
|
return rows.map(parseRow);
|
|
8105
8134
|
}
|
|
8106
8135
|
function updateWebhookHook(id, updates, db) {
|
|
8136
|
+
if (!db && isApiMode()) {
|
|
8137
|
+
const { status, data } = apiJson("PATCH", `/webhooks/${encodeURIComponent(id)}`, {
|
|
8138
|
+
enabled: updates.enabled,
|
|
8139
|
+
priority: updates.priority,
|
|
8140
|
+
description: updates.description
|
|
8141
|
+
});
|
|
8142
|
+
if (status === 404 || !data)
|
|
8143
|
+
return null;
|
|
8144
|
+
return data;
|
|
8145
|
+
}
|
|
8107
8146
|
const d = db || getDatabase();
|
|
8108
8147
|
const existing = getWebhookHook(id, d);
|
|
8109
8148
|
if (!existing)
|
|
@@ -8129,11 +8168,18 @@ function updateWebhookHook(id, updates, db) {
|
|
|
8129
8168
|
return getWebhookHook(id, d);
|
|
8130
8169
|
}
|
|
8131
8170
|
function deleteWebhookHook(id, db) {
|
|
8171
|
+
if (!db && isApiMode()) {
|
|
8172
|
+
const { status } = apiJson("DELETE", `/webhooks/${encodeURIComponent(id)}`);
|
|
8173
|
+
return status === 204 || status === 200;
|
|
8174
|
+
}
|
|
8132
8175
|
const d = db || getDatabase();
|
|
8133
8176
|
const result = d.run("DELETE FROM webhook_hooks WHERE id = ?", [id]);
|
|
8134
8177
|
return result.changes > 0;
|
|
8135
8178
|
}
|
|
8136
8179
|
function recordWebhookInvocation(id, success, db) {
|
|
8180
|
+
if (!db && isApiMode()) {
|
|
8181
|
+
return;
|
|
8182
|
+
}
|
|
8137
8183
|
const d = db || getDatabase();
|
|
8138
8184
|
if (success) {
|
|
8139
8185
|
d.run("UPDATE webhook_hooks SET invocation_count = invocation_count + 1 WHERE id = ?", [id]);
|
|
@@ -8143,6 +8189,7 @@ function recordWebhookInvocation(id, success, db) {
|
|
|
8143
8189
|
}
|
|
8144
8190
|
var init_webhook_hooks = __esm(() => {
|
|
8145
8191
|
init_database();
|
|
8192
|
+
init_api_mode();
|
|
8146
8193
|
});
|
|
8147
8194
|
|
|
8148
8195
|
// src/db/synthesis.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relations.d.ts","sourceRoot":"","sources":["../../src/db/relations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AAI1D,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAO7F,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,QAAQ,CAUvE;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAWnE;AAMD,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAuClF;AAMD,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAU/D;AAMD,wBAAgB,aAAa,CAC3B,MAAM,EAAE;IACN,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,YAAY,CAAC;IAC7B,SAAS,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,MAAM,CAAC;CAC9C,EACD,EAAE,CAAC,EAAE,QAAQ,GACZ,QAAQ,EAAE,CAwCZ;AAMD,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,IAAI,CAS9D;AAMD;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,YAAY,CAAC,EAAE,YAAY,EAC3B,EAAE,CAAC,EAAE,QAAQ,GACZ,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"relations.d.ts","sourceRoot":"","sources":["../../src/db/relations.ts"],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;CAAE,CA6C/C;AAED;;GAEG;AACH,wBAAgB,QAAQ,CACtB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,QAAQ,GAAE,MAAU,EACpB,EAAE,CAAC,EAAE,QAAQ,GACZ,MAAM,EAAE,GAAG,IAAI,CAsCjB;AAMD,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC;IAC7D,SAAS,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC;IAC9D,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC9E;AAED,wBAAgB,aAAa,CAAC,EAAE,CAAC,EAAE,QAAQ,GAAG,UAAU,CAyCvD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook_hooks.d.ts","sourceRoot":"","sources":["../../src/db/webhook_hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"webhook_hooks.d.ts","sourceRoot":"","sources":["../../src/db/webhook_hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AAI1D,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AA2B/D,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,Q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*\)/gi, "gen_random_uuid()::text");
|
|
135
135
|
translated = translated.replace(/\bIFNULL\s*\(/gi, "COALESCE(");
|
|
136
|
+
translated = translated.replace(/\bINSTR\s*\(/gi, "STRPOS(");
|
|
136
137
|
if (/INSERT\s+OR\s+IGNORE\s+INTO/i.test(translated)) {
|
|
137
138
|
translated = translated.replace(/INSERT\s+OR\s+IGNORE\s+INTO/gi, "INSERT INTO");
|
|
138
139
|
translated = translated.replace(/;?\s*$/, " ON CONFLICT DO NOTHING");
|
|
@@ -53508,6 +53509,11 @@ function deleteRelation(id, db) {
|
|
|
53508
53509
|
throw new Error(`Relation not found: ${id}`);
|
|
53509
53510
|
}
|
|
53510
53511
|
function getRelatedEntities(entityId, relationType, db) {
|
|
53512
|
+
if (!db && isApiMode()) {
|
|
53513
|
+
const q = toQuery({ type: relationType });
|
|
53514
|
+
const { data } = apiJson("GET", `/entities/${encodeURIComponent(entityId)}/related${q}`);
|
|
53515
|
+
return data?.entities ?? [];
|
|
53516
|
+
}
|
|
53511
53517
|
const d = db || getDatabase();
|
|
53512
53518
|
let sql;
|
|
53513
53519
|
const params = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-detect.d.ts","sourceRoot":"","sources":["../../src/lib/project-detect.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"project-detect.d.ts","sourceRoot":"","sources":["../../src/lib/project-detect.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AAI1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAkBjD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,EAAE,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,IAAI,CAgC3D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAExC"}
|
package/dist/mcp/index.js
CHANGED
|
@@ -218,6 +218,7 @@ function translateSql(sql) {
|
|
|
218
218
|
});
|
|
219
219
|
translated = translated.replace(/lower\s*\(\s*hex\s*\(\s*randomblob\s*\(\s*\d+\s*\)\s*\)\s*\)/gi, "gen_random_uuid()::text");
|
|
220
220
|
translated = translated.replace(/\bIFNULL\s*\(/gi, "COALESCE(");
|
|
221
|
+
translated = translated.replace(/\bINSTR\s*\(/gi, "STRPOS(");
|
|
221
222
|
if (/INSERT\s+OR\s+IGNORE\s+INTO/i.test(translated)) {
|
|
222
223
|
translated = translated.replace(/INSERT\s+OR\s+IGNORE\s+INTO/gi, "INSERT INTO");
|
|
223
224
|
translated = translated.replace(/;?\s*$/, " ON CONFLICT DO NOTHING");
|
|
@@ -3373,6 +3374,18 @@ function parseRow(row) {
|
|
|
3373
3374
|
};
|
|
3374
3375
|
}
|
|
3375
3376
|
function createWebhookHook(input, db) {
|
|
3377
|
+
if (!db && isApiMode()) {
|
|
3378
|
+
const { data } = apiJson("POST", "/webhooks", {
|
|
3379
|
+
type: input.type,
|
|
3380
|
+
handler_url: input.handlerUrl,
|
|
3381
|
+
priority: input.priority,
|
|
3382
|
+
blocking: input.blocking,
|
|
3383
|
+
agent_id: input.agentId,
|
|
3384
|
+
project_id: input.projectId,
|
|
3385
|
+
description: input.description
|
|
3386
|
+
});
|
|
3387
|
+
return data;
|
|
3388
|
+
}
|
|
3376
3389
|
const d = db || getDatabase();
|
|
3377
3390
|
const id = shortUuid();
|
|
3378
3391
|
const timestamp = now();
|
|
@@ -3392,11 +3405,22 @@ function createWebhookHook(input, db) {
|
|
|
3392
3405
|
return getWebhookHook(id, d);
|
|
3393
3406
|
}
|
|
3394
3407
|
function getWebhookHook(id, db) {
|
|
3408
|
+
if (!db && isApiMode()) {
|
|
3409
|
+
const { status, data } = apiJson("GET", `/webhooks/${encodeURIComponent(id)}`);
|
|
3410
|
+
if (status === 404 || !data)
|
|
3411
|
+
return null;
|
|
3412
|
+
return data;
|
|
3413
|
+
}
|
|
3395
3414
|
const d = db || getDatabase();
|
|
3396
3415
|
const row = d.query("SELECT * FROM webhook_hooks WHERE id = ?").get(id);
|
|
3397
3416
|
return row ? parseRow(row) : null;
|
|
3398
3417
|
}
|
|
3399
3418
|
function listWebhookHooks(filter = {}, db) {
|
|
3419
|
+
if (!db && isApiMode()) {
|
|
3420
|
+
const q = toQuery({ type: filter.type, enabled: filter.enabled });
|
|
3421
|
+
const { data } = apiJson("GET", `/webhooks${q}`);
|
|
3422
|
+
return data ?? [];
|
|
3423
|
+
}
|
|
3400
3424
|
const d = db || getDatabase();
|
|
3401
3425
|
const conditions = [];
|
|
3402
3426
|
const params = [];
|
|
@@ -3413,6 +3437,16 @@ function listWebhookHooks(filter = {}, db) {
|
|
|
3413
3437
|
return rows.map(parseRow);
|
|
3414
3438
|
}
|
|
3415
3439
|
function updateWebhookHook(id, updates, db) {
|
|
3440
|
+
if (!db && isApiMode()) {
|
|
3441
|
+
const { status, data } = apiJson("PATCH", `/webhooks/${encodeURIComponent(id)}`, {
|
|
3442
|
+
enabled: updates.enabled,
|
|
3443
|
+
priority: updates.priority,
|
|
3444
|
+
description: updates.description
|
|
3445
|
+
});
|
|
3446
|
+
if (status === 404 || !data)
|
|
3447
|
+
return null;
|
|
3448
|
+
return data;
|
|
3449
|
+
}
|
|
3416
3450
|
const d = db || getDatabase();
|
|
3417
3451
|
const existing = getWebhookHook(id, d);
|
|
3418
3452
|
if (!existing)
|
|
@@ -3438,11 +3472,18 @@ function updateWebhookHook(id, updates, db) {
|
|
|
3438
3472
|
return getWebhookHook(id, d);
|
|
3439
3473
|
}
|
|
3440
3474
|
function deleteWebhookHook(id, db) {
|
|
3475
|
+
if (!db && isApiMode()) {
|
|
3476
|
+
const { status } = apiJson("DELETE", `/webhooks/${encodeURIComponent(id)}`);
|
|
3477
|
+
return status === 204 || status === 200;
|
|
3478
|
+
}
|
|
3441
3479
|
const d = db || getDatabase();
|
|
3442
3480
|
const result = d.run("DELETE FROM webhook_hooks WHERE id = ?", [id]);
|
|
3443
3481
|
return result.changes > 0;
|
|
3444
3482
|
}
|
|
3445
3483
|
function recordWebhookInvocation(id, success, db) {
|
|
3484
|
+
if (!db && isApiMode()) {
|
|
3485
|
+
return;
|
|
3486
|
+
}
|
|
3446
3487
|
const d = db || getDatabase();
|
|
3447
3488
|
if (success) {
|
|
3448
3489
|
d.run("UPDATE webhook_hooks SET invocation_count = invocation_count + 1 WHERE id = ?", [id]);
|
|
@@ -3452,6 +3493,7 @@ function recordWebhookInvocation(id, success, db) {
|
|
|
3452
3493
|
}
|
|
3453
3494
|
var init_webhook_hooks = __esm(() => {
|
|
3454
3495
|
init_database();
|
|
3496
|
+
init_api_mode();
|
|
3455
3497
|
});
|
|
3456
3498
|
|
|
3457
3499
|
// src/db/entities.ts
|
|
@@ -56393,6 +56435,7 @@ init_machines();
|
|
|
56393
56435
|
|
|
56394
56436
|
// src/lib/project-detect.ts
|
|
56395
56437
|
init_database();
|
|
56438
|
+
init_api_mode();
|
|
56396
56439
|
import { existsSync as existsSync3 } from "fs";
|
|
56397
56440
|
import { basename, dirname as dirname2, join as join4, resolve as resolve2 } from "path";
|
|
56398
56441
|
function findGitRoot2(startDir) {
|
|
@@ -56411,7 +56454,6 @@ var _cachedProject = undefined;
|
|
|
56411
56454
|
function detectProject(db) {
|
|
56412
56455
|
if (_cachedProject !== undefined)
|
|
56413
56456
|
return _cachedProject;
|
|
56414
|
-
const d = db || getDatabase();
|
|
56415
56457
|
const cwd = process.cwd();
|
|
56416
56458
|
const gitRoot = findGitRoot2(cwd);
|
|
56417
56459
|
if (!gitRoot) {
|
|
@@ -56420,6 +56462,7 @@ function detectProject(db) {
|
|
|
56420
56462
|
}
|
|
56421
56463
|
const repoName = basename(gitRoot);
|
|
56422
56464
|
const absPath = resolve2(gitRoot);
|
|
56465
|
+
const d = db ?? (isApiMode() ? undefined : getDatabase());
|
|
56423
56466
|
const existing = getProject(absPath, d);
|
|
56424
56467
|
if (existing) {
|
|
56425
56468
|
_cachedProject = existing;
|
package/dist/pg-sync-worker.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// src/pg-sync-worker.ts
|
|
3
3
|
import { parentPort, workerData } from "worker_threads";
|
|
4
4
|
import pg from "pg";
|
|
5
|
+
pg.types.setTypeParser(20, (val) => parseInt(val, 10));
|
|
5
6
|
var { dsn, ssl, control, data } = workerData;
|
|
6
7
|
var status = new Int32Array(control);
|
|
7
8
|
var dataView = new Uint8Array(data);
|
package/dist/server/index.js
CHANGED
|
@@ -152,6 +152,7 @@ function translateSql(sql) {
|
|
|
152
152
|
});
|
|
153
153
|
translated = translated.replace(/lower\s*\(\s*hex\s*\(\s*randomblob\s*\(\s*\d+\s*\)\s*\)\s*\)/gi, "gen_random_uuid()::text");
|
|
154
154
|
translated = translated.replace(/\bIFNULL\s*\(/gi, "COALESCE(");
|
|
155
|
+
translated = translated.replace(/\bINSTR\s*\(/gi, "STRPOS(");
|
|
155
156
|
if (/INSERT\s+OR\s+IGNORE\s+INTO/i.test(translated)) {
|
|
156
157
|
translated = translated.replace(/INSERT\s+OR\s+IGNORE\s+INTO/gi, "INSERT INTO");
|
|
157
158
|
translated = translated.replace(/;?\s*$/, " ON CONFLICT DO NOTHING");
|
|
@@ -4189,6 +4190,38 @@ function deleteRelation(id, db) {
|
|
|
4189
4190
|
if (result.changes === 0)
|
|
4190
4191
|
throw new Error(`Relation not found: ${id}`);
|
|
4191
4192
|
}
|
|
4193
|
+
function getRelatedEntities(entityId, relationType, db) {
|
|
4194
|
+
if (!db && isApiMode()) {
|
|
4195
|
+
const q = toQuery({ type: relationType });
|
|
4196
|
+
const { data } = apiJson("GET", `/entities/${encodeURIComponent(entityId)}/related${q}`);
|
|
4197
|
+
return data?.entities ?? [];
|
|
4198
|
+
}
|
|
4199
|
+
const d = db || getDatabase();
|
|
4200
|
+
let sql;
|
|
4201
|
+
const params = [];
|
|
4202
|
+
if (relationType) {
|
|
4203
|
+
sql = `
|
|
4204
|
+
SELECT DISTINCT e.* FROM entities e
|
|
4205
|
+
JOIN relations r ON (
|
|
4206
|
+
(r.source_entity_id = ? AND r.target_entity_id = e.id)
|
|
4207
|
+
OR (r.target_entity_id = ? AND r.source_entity_id = e.id)
|
|
4208
|
+
)
|
|
4209
|
+
WHERE r.relation_type = ?
|
|
4210
|
+
`;
|
|
4211
|
+
params.push(entityId, entityId, relationType);
|
|
4212
|
+
} else {
|
|
4213
|
+
sql = `
|
|
4214
|
+
SELECT DISTINCT e.* FROM entities e
|
|
4215
|
+
JOIN relations r ON (
|
|
4216
|
+
(r.source_entity_id = ? AND r.target_entity_id = e.id)
|
|
4217
|
+
OR (r.target_entity_id = ? AND r.source_entity_id = e.id)
|
|
4218
|
+
)
|
|
4219
|
+
`;
|
|
4220
|
+
params.push(entityId, entityId);
|
|
4221
|
+
}
|
|
4222
|
+
const rows = d.query(sql).all(...params);
|
|
4223
|
+
return rows.map(parseEntityRow3);
|
|
4224
|
+
}
|
|
4192
4225
|
function getEntityGraph(entityId, depth = 2, db) {
|
|
4193
4226
|
if (!db && isApiMode()) {
|
|
4194
4227
|
const q = toQuery({ depth });
|
|
@@ -53527,6 +53560,7 @@ init_hooks();
|
|
|
53527
53560
|
|
|
53528
53561
|
// src/db/webhook_hooks.ts
|
|
53529
53562
|
init_database();
|
|
53563
|
+
init_api_mode();
|
|
53530
53564
|
function parseRow(row) {
|
|
53531
53565
|
return {
|
|
53532
53566
|
id: row["id"],
|
|
@@ -53544,6 +53578,18 @@ function parseRow(row) {
|
|
|
53544
53578
|
};
|
|
53545
53579
|
}
|
|
53546
53580
|
function createWebhookHook(input, db) {
|
|
53581
|
+
if (!db && isApiMode()) {
|
|
53582
|
+
const { data } = apiJson("POST", "/webhooks", {
|
|
53583
|
+
type: input.type,
|
|
53584
|
+
handler_url: input.handlerUrl,
|
|
53585
|
+
priority: input.priority,
|
|
53586
|
+
blocking: input.blocking,
|
|
53587
|
+
agent_id: input.agentId,
|
|
53588
|
+
project_id: input.projectId,
|
|
53589
|
+
description: input.description
|
|
53590
|
+
});
|
|
53591
|
+
return data;
|
|
53592
|
+
}
|
|
53547
53593
|
const d = db || getDatabase();
|
|
53548
53594
|
const id = shortUuid();
|
|
53549
53595
|
const timestamp = now();
|
|
@@ -53563,11 +53609,22 @@ function createWebhookHook(input, db) {
|
|
|
53563
53609
|
return getWebhookHook(id, d);
|
|
53564
53610
|
}
|
|
53565
53611
|
function getWebhookHook(id, db) {
|
|
53612
|
+
if (!db && isApiMode()) {
|
|
53613
|
+
const { status, data } = apiJson("GET", `/webhooks/${encodeURIComponent(id)}`);
|
|
53614
|
+
if (status === 404 || !data)
|
|
53615
|
+
return null;
|
|
53616
|
+
return data;
|
|
53617
|
+
}
|
|
53566
53618
|
const d = db || getDatabase();
|
|
53567
53619
|
const row = d.query("SELECT * FROM webhook_hooks WHERE id = ?").get(id);
|
|
53568
53620
|
return row ? parseRow(row) : null;
|
|
53569
53621
|
}
|
|
53570
53622
|
function listWebhookHooks(filter = {}, db) {
|
|
53623
|
+
if (!db && isApiMode()) {
|
|
53624
|
+
const q = toQuery({ type: filter.type, enabled: filter.enabled });
|
|
53625
|
+
const { data } = apiJson("GET", `/webhooks${q}`);
|
|
53626
|
+
return data ?? [];
|
|
53627
|
+
}
|
|
53571
53628
|
const d = db || getDatabase();
|
|
53572
53629
|
const conditions = [];
|
|
53573
53630
|
const params = [];
|
|
@@ -53584,6 +53641,16 @@ function listWebhookHooks(filter = {}, db) {
|
|
|
53584
53641
|
return rows.map(parseRow);
|
|
53585
53642
|
}
|
|
53586
53643
|
function updateWebhookHook(id, updates, db) {
|
|
53644
|
+
if (!db && isApiMode()) {
|
|
53645
|
+
const { status, data } = apiJson("PATCH", `/webhooks/${encodeURIComponent(id)}`, {
|
|
53646
|
+
enabled: updates.enabled,
|
|
53647
|
+
priority: updates.priority,
|
|
53648
|
+
description: updates.description
|
|
53649
|
+
});
|
|
53650
|
+
if (status === 404 || !data)
|
|
53651
|
+
return null;
|
|
53652
|
+
return data;
|
|
53653
|
+
}
|
|
53587
53654
|
const d = db || getDatabase();
|
|
53588
53655
|
const existing = getWebhookHook(id, d);
|
|
53589
53656
|
if (!existing)
|
|
@@ -53609,11 +53676,18 @@ function updateWebhookHook(id, updates, db) {
|
|
|
53609
53676
|
return getWebhookHook(id, d);
|
|
53610
53677
|
}
|
|
53611
53678
|
function deleteWebhookHook(id, db) {
|
|
53679
|
+
if (!db && isApiMode()) {
|
|
53680
|
+
const { status } = apiJson("DELETE", `/webhooks/${encodeURIComponent(id)}`);
|
|
53681
|
+
return status === 204 || status === 200;
|
|
53682
|
+
}
|
|
53612
53683
|
const d = db || getDatabase();
|
|
53613
53684
|
const result = d.run("DELETE FROM webhook_hooks WHERE id = ?", [id]);
|
|
53614
53685
|
return result.changes > 0;
|
|
53615
53686
|
}
|
|
53616
53687
|
function recordWebhookInvocation(id, success, db) {
|
|
53688
|
+
if (!db && isApiMode()) {
|
|
53689
|
+
return;
|
|
53690
|
+
}
|
|
53617
53691
|
const d = db || getDatabase();
|
|
53618
53692
|
if (success) {
|
|
53619
53693
|
d.run("UPDATE webhook_hooks SET invocation_count = invocation_count + 1 WHERE id = ?", [id]);
|
|
@@ -57112,6 +57186,19 @@ addRoute("GET", "/api/entities/:id/relations", (_req, url, params) => {
|
|
|
57112
57186
|
throw e;
|
|
57113
57187
|
}
|
|
57114
57188
|
});
|
|
57189
|
+
addRoute("GET", "/api/entities/:id/related", (_req, url, params) => {
|
|
57190
|
+
const q = getSearchParams(url);
|
|
57191
|
+
try {
|
|
57192
|
+
getEntity(params["id"]);
|
|
57193
|
+
const entities = getRelatedEntities(params["id"], q["type"]);
|
|
57194
|
+
return json({ entities, count: entities.length });
|
|
57195
|
+
} catch (e) {
|
|
57196
|
+
if (e instanceof EntityNotFoundError) {
|
|
57197
|
+
return errorResponse(e.message, 404);
|
|
57198
|
+
}
|
|
57199
|
+
throw e;
|
|
57200
|
+
}
|
|
57201
|
+
});
|
|
57115
57202
|
addRoute("DELETE", "/api/entities/:entityId/memories/:memoryId", (_req, _url, params) => {
|
|
57116
57203
|
unlinkEntityFromMemory(params["entityId"], params["memoryId"]);
|
|
57117
57204
|
return json({ deleted: true });
|
package/dist/storage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAOtC,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAiB3C,sFAAsF;AACtF,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAED,4DAA4D;AAC5D,wBAAgB,eAAe,IAAI,OAAO,CAEzC;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,GAAG,MAAM,CAAC;CAClC;AAED,MAAM,WAAW,iBAAiB;IAChC,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;IACjC,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;IAC3B,GAAG,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC;IAC7B,QAAQ,IAAI,IAAI,CAAC;CAClB;AAED,MAAM,WAAW,SAAS;IACxB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC;IAC9C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;IACxC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC;IAC1C,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,CAAC,GAAG,EAAE,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;CACrB;AAED,MAAM,WAAW,QAAQ;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,sBAAsB;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAUD,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI,CAEvD;AAqGD,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,MAAM,EAAE,EAChB,OAAO,GAAE,sBAA2B,GACnC,oBAAoB,EAAE,CAExB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,EACjB,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,MAAM,EAAE,EAChB,OAAO,GAAE,sBAA2B,GACnC,oBAAoB,EAAE,CAExB;AA2ED,wBAAgB,cAAc,CAAC,EAAE,EAAE,SAAS,GAAG,QAAQ,EAAE,CAKxD;AAED,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,IAAI,CAEjF;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAGhE;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,SAAS,GAAG,IAAI,CAGpD"}
|
package/dist/storage.js
CHANGED
|
@@ -133,6 +133,7 @@ function translateSql(sql) {
|
|
|
133
133
|
});
|
|
134
134
|
translated = translated.replace(/lower\s*\(\s*hex\s*\(\s*randomblob\s*\(\s*\d+\s*\)\s*\)\s*\)/gi, "gen_random_uuid()::text");
|
|
135
135
|
translated = translated.replace(/\bIFNULL\s*\(/gi, "COALESCE(");
|
|
136
|
+
translated = translated.replace(/\bINSTR\s*\(/gi, "STRPOS(");
|
|
136
137
|
if (/INSERT\s+OR\s+IGNORE\s+INTO/i.test(translated)) {
|
|
137
138
|
translated = translated.replace(/INSERT\s+OR\s+IGNORE\s+INTO/gi, "INSERT INTO");
|
|
138
139
|
translated = translated.replace(/;?\s*$/, " ON CONFLICT DO NOTHING");
|