@hasna/mementos 0.6.0 → 0.7.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/cli/index.js +496 -9
- package/dist/db/database.d.ts.map +1 -1
- package/dist/db/entities.d.ts.map +1 -1
- package/dist/db/memories.d.ts.map +1 -1
- package/dist/db/relations.d.ts.map +1 -1
- package/dist/db/webhook_hooks.d.ts +25 -0
- package/dist/db/webhook_hooks.d.ts.map +1 -0
- package/dist/index.js +160 -9
- package/dist/lib/built-in-hooks.d.ts +12 -0
- package/dist/lib/built-in-hooks.d.ts.map +1 -0
- package/dist/lib/focus.d.ts.map +1 -1
- package/dist/lib/hooks.d.ts +50 -0
- package/dist/lib/hooks.d.ts.map +1 -0
- package/dist/mcp/index.js +6805 -6178
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +2263 -1682
- package/dist/types/hooks.d.ts +136 -0
- package/dist/types/hooks.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -2432,6 +2432,25 @@ var init_database = __esm(() => {
|
|
|
2432
2432
|
ALTER TABLE memories ADD COLUMN recall_count INTEGER NOT NULL DEFAULT 0;
|
|
2433
2433
|
CREATE INDEX IF NOT EXISTS idx_memories_recall_count ON memories(recall_count DESC);
|
|
2434
2434
|
INSERT OR IGNORE INTO _migrations (id) VALUES (9);
|
|
2435
|
+
`,
|
|
2436
|
+
`
|
|
2437
|
+
CREATE TABLE IF NOT EXISTS webhook_hooks (
|
|
2438
|
+
id TEXT PRIMARY KEY,
|
|
2439
|
+
type TEXT NOT NULL,
|
|
2440
|
+
handler_url TEXT NOT NULL,
|
|
2441
|
+
priority INTEGER NOT NULL DEFAULT 50,
|
|
2442
|
+
blocking INTEGER NOT NULL DEFAULT 0,
|
|
2443
|
+
agent_id TEXT,
|
|
2444
|
+
project_id TEXT,
|
|
2445
|
+
description TEXT,
|
|
2446
|
+
enabled INTEGER NOT NULL DEFAULT 1,
|
|
2447
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
2448
|
+
invocation_count INTEGER NOT NULL DEFAULT 0,
|
|
2449
|
+
failure_count INTEGER NOT NULL DEFAULT 0
|
|
2450
|
+
);
|
|
2451
|
+
CREATE INDEX IF NOT EXISTS idx_webhook_hooks_type ON webhook_hooks(type);
|
|
2452
|
+
CREATE INDEX IF NOT EXISTS idx_webhook_hooks_enabled ON webhook_hooks(enabled);
|
|
2453
|
+
INSERT OR IGNORE INTO _migrations (id) VALUES (10);
|
|
2435
2454
|
`
|
|
2436
2455
|
];
|
|
2437
2456
|
});
|
|
@@ -2511,6 +2530,93 @@ var init_redact = __esm(() => {
|
|
|
2511
2530
|
];
|
|
2512
2531
|
});
|
|
2513
2532
|
|
|
2533
|
+
// src/lib/hooks.ts
|
|
2534
|
+
var exports_hooks = {};
|
|
2535
|
+
__export(exports_hooks, {
|
|
2536
|
+
hookRegistry: () => hookRegistry
|
|
2537
|
+
});
|
|
2538
|
+
function generateHookId() {
|
|
2539
|
+
return `hook_${++_idCounter}_${Date.now().toString(36)}`;
|
|
2540
|
+
}
|
|
2541
|
+
|
|
2542
|
+
class HookRegistry {
|
|
2543
|
+
hooks = new Map;
|
|
2544
|
+
register(reg) {
|
|
2545
|
+
const id = generateHookId();
|
|
2546
|
+
const hook = {
|
|
2547
|
+
...reg,
|
|
2548
|
+
id,
|
|
2549
|
+
priority: reg.priority ?? 50
|
|
2550
|
+
};
|
|
2551
|
+
this.hooks.set(id, hook);
|
|
2552
|
+
return id;
|
|
2553
|
+
}
|
|
2554
|
+
unregister(hookId) {
|
|
2555
|
+
const hook = this.hooks.get(hookId);
|
|
2556
|
+
if (!hook)
|
|
2557
|
+
return false;
|
|
2558
|
+
if (hook.builtin)
|
|
2559
|
+
return false;
|
|
2560
|
+
this.hooks.delete(hookId);
|
|
2561
|
+
return true;
|
|
2562
|
+
}
|
|
2563
|
+
list(type) {
|
|
2564
|
+
const all = [...this.hooks.values()];
|
|
2565
|
+
if (!type)
|
|
2566
|
+
return all;
|
|
2567
|
+
return all.filter((h) => h.type === type);
|
|
2568
|
+
}
|
|
2569
|
+
async runHooks(type, context) {
|
|
2570
|
+
const matching = this.getMatchingHooks(type, context);
|
|
2571
|
+
if (matching.length === 0)
|
|
2572
|
+
return true;
|
|
2573
|
+
matching.sort((a, b) => a.priority - b.priority);
|
|
2574
|
+
for (const hook of matching) {
|
|
2575
|
+
if (hook.blocking) {
|
|
2576
|
+
try {
|
|
2577
|
+
const result = await hook.handler(context);
|
|
2578
|
+
if (result === false)
|
|
2579
|
+
return false;
|
|
2580
|
+
} catch (err) {
|
|
2581
|
+
console.error(`[hooks] blocking hook ${hook.id} (${type}) threw:`, err);
|
|
2582
|
+
}
|
|
2583
|
+
} else {
|
|
2584
|
+
Promise.resolve().then(() => hook.handler(context)).catch((err) => console.error(`[hooks] non-blocking hook ${hook.id} (${type}) threw:`, err));
|
|
2585
|
+
}
|
|
2586
|
+
}
|
|
2587
|
+
return true;
|
|
2588
|
+
}
|
|
2589
|
+
getMatchingHooks(type, context) {
|
|
2590
|
+
const ctx = context;
|
|
2591
|
+
return [...this.hooks.values()].filter((hook) => {
|
|
2592
|
+
if (hook.type !== type)
|
|
2593
|
+
return false;
|
|
2594
|
+
if (hook.agentId && hook.agentId !== ctx.agentId)
|
|
2595
|
+
return false;
|
|
2596
|
+
if (hook.projectId && hook.projectId !== ctx.projectId)
|
|
2597
|
+
return false;
|
|
2598
|
+
return true;
|
|
2599
|
+
});
|
|
2600
|
+
}
|
|
2601
|
+
stats() {
|
|
2602
|
+
const all = [...this.hooks.values()];
|
|
2603
|
+
const byType = {};
|
|
2604
|
+
for (const hook of all) {
|
|
2605
|
+
byType[hook.type] = (byType[hook.type] ?? 0) + 1;
|
|
2606
|
+
}
|
|
2607
|
+
return {
|
|
2608
|
+
total: all.length,
|
|
2609
|
+
byType,
|
|
2610
|
+
blocking: all.filter((h) => h.blocking).length,
|
|
2611
|
+
nonBlocking: all.filter((h) => !h.blocking).length
|
|
2612
|
+
};
|
|
2613
|
+
}
|
|
2614
|
+
}
|
|
2615
|
+
var _idCounter = 0, hookRegistry;
|
|
2616
|
+
var init_hooks = __esm(() => {
|
|
2617
|
+
hookRegistry = new HookRegistry;
|
|
2618
|
+
});
|
|
2619
|
+
|
|
2514
2620
|
// src/db/entity-memories.ts
|
|
2515
2621
|
function parseEntityMemoryRow(row) {
|
|
2516
2622
|
return {
|
|
@@ -2566,6 +2672,22 @@ var init_entity_memories = __esm(() => {
|
|
|
2566
2672
|
});
|
|
2567
2673
|
|
|
2568
2674
|
// src/db/memories.ts
|
|
2675
|
+
var exports_memories = {};
|
|
2676
|
+
__export(exports_memories, {
|
|
2677
|
+
updateMemory: () => updateMemory,
|
|
2678
|
+
touchMemory: () => touchMemory,
|
|
2679
|
+
parseMemoryRow: () => parseMemoryRow,
|
|
2680
|
+
listMemories: () => listMemories,
|
|
2681
|
+
incrementRecallCount: () => incrementRecallCount,
|
|
2682
|
+
getMemoryVersions: () => getMemoryVersions,
|
|
2683
|
+
getMemoryByKey: () => getMemoryByKey,
|
|
2684
|
+
getMemory: () => getMemory,
|
|
2685
|
+
getMemoriesByKey: () => getMemoriesByKey,
|
|
2686
|
+
deleteMemory: () => deleteMemory,
|
|
2687
|
+
createMemory: () => createMemory,
|
|
2688
|
+
cleanExpiredMemories: () => cleanExpiredMemories,
|
|
2689
|
+
bulkDeleteMemories: () => bulkDeleteMemories
|
|
2690
|
+
});
|
|
2569
2691
|
function runEntityExtraction(_memory, _projectId, _d) {}
|
|
2570
2692
|
function parseMemoryRow(row) {
|
|
2571
2693
|
return {
|
|
@@ -2668,9 +2790,15 @@ function createMemory(input, dedupeMode = "merge", db) {
|
|
|
2668
2790
|
insertTag.run(id, tag);
|
|
2669
2791
|
}
|
|
2670
2792
|
const memory = getMemory(id, d);
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2793
|
+
runEntityExtraction(memory, input.project_id, d);
|
|
2794
|
+
hookRegistry.runHooks("PostMemorySave", {
|
|
2795
|
+
memory,
|
|
2796
|
+
wasUpdated: false,
|
|
2797
|
+
agentId: input.agent_id,
|
|
2798
|
+
projectId: input.project_id,
|
|
2799
|
+
sessionId: input.session_id,
|
|
2800
|
+
timestamp: Date.now()
|
|
2801
|
+
});
|
|
2674
2802
|
return memory;
|
|
2675
2803
|
}
|
|
2676
2804
|
function getMemory(id, db) {
|
|
@@ -2894,20 +3022,33 @@ function updateMemory(id, input, db) {
|
|
|
2894
3022
|
params.push(id);
|
|
2895
3023
|
d.run(`UPDATE memories SET ${sets.join(", ")} WHERE id = ?`, params);
|
|
2896
3024
|
const updated = getMemory(id, d);
|
|
2897
|
-
|
|
2898
|
-
|
|
3025
|
+
if (input.value !== undefined) {
|
|
3026
|
+
try {
|
|
2899
3027
|
const oldLinks = getEntityMemoryLinks(undefined, updated.id, d);
|
|
2900
3028
|
for (const link of oldLinks) {
|
|
2901
3029
|
unlinkEntityFromMemory(link.entity_id, updated.id, d);
|
|
2902
3030
|
}
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
3031
|
+
} catch {}
|
|
3032
|
+
}
|
|
3033
|
+
hookRegistry.runHooks("PostMemoryUpdate", {
|
|
3034
|
+
memory: updated,
|
|
3035
|
+
previousValue: existing.value,
|
|
3036
|
+
agentId: existing.agent_id ?? undefined,
|
|
3037
|
+
projectId: existing.project_id ?? undefined,
|
|
3038
|
+
sessionId: existing.session_id ?? undefined,
|
|
3039
|
+
timestamp: Date.now()
|
|
3040
|
+
});
|
|
2906
3041
|
return updated;
|
|
2907
3042
|
}
|
|
2908
3043
|
function deleteMemory(id, db) {
|
|
2909
3044
|
const d = db || getDatabase();
|
|
2910
3045
|
const result = d.run("DELETE FROM memories WHERE id = ?", [id]);
|
|
3046
|
+
if (result.changes > 0) {
|
|
3047
|
+
hookRegistry.runHooks("PostMemoryDelete", {
|
|
3048
|
+
memoryId: id,
|
|
3049
|
+
timestamp: Date.now()
|
|
3050
|
+
});
|
|
3051
|
+
}
|
|
2911
3052
|
return result.changes > 0;
|
|
2912
3053
|
}
|
|
2913
3054
|
function bulkDeleteMemories(ids, db) {
|
|
@@ -2926,6 +3067,20 @@ function touchMemory(id, db) {
|
|
|
2926
3067
|
const d = db || getDatabase();
|
|
2927
3068
|
d.run("UPDATE memories SET access_count = access_count + 1, accessed_at = ? WHERE id = ?", [now(), id]);
|
|
2928
3069
|
}
|
|
3070
|
+
function incrementRecallCount(id, db) {
|
|
3071
|
+
const d = db || getDatabase();
|
|
3072
|
+
try {
|
|
3073
|
+
d.run("UPDATE memories SET recall_count = recall_count + 1, access_count = access_count + 1, accessed_at = ? WHERE id = ?", [now(), id]);
|
|
3074
|
+
const row = d.query("SELECT recall_count, importance FROM memories WHERE id = ?").get(id);
|
|
3075
|
+
if (!row)
|
|
3076
|
+
return;
|
|
3077
|
+
const promotions = Math.floor(row.recall_count / RECALL_PROMOTE_THRESHOLD);
|
|
3078
|
+
if (promotions > 0 && row.importance < 10) {
|
|
3079
|
+
const newImportance = Math.min(10, row.importance + 1);
|
|
3080
|
+
d.run("UPDATE memories SET importance = ? WHERE id = ? AND importance < 10", [newImportance, id]);
|
|
3081
|
+
}
|
|
3082
|
+
} catch {}
|
|
3083
|
+
}
|
|
2929
3084
|
function cleanExpiredMemories(db) {
|
|
2930
3085
|
const d = db || getDatabase();
|
|
2931
3086
|
const timestamp = now();
|
|
@@ -2958,10 +3113,12 @@ function getMemoryVersions(memoryId, db) {
|
|
|
2958
3113
|
return [];
|
|
2959
3114
|
}
|
|
2960
3115
|
}
|
|
3116
|
+
var RECALL_PROMOTE_THRESHOLD = 3;
|
|
2961
3117
|
var init_memories = __esm(() => {
|
|
2962
3118
|
init_types();
|
|
2963
3119
|
init_database();
|
|
2964
3120
|
init_redact();
|
|
3121
|
+
init_hooks();
|
|
2965
3122
|
init_entity_memories();
|
|
2966
3123
|
});
|
|
2967
3124
|
|
|
@@ -3012,6 +3169,13 @@ function createEntity(input, db) {
|
|
|
3012
3169
|
timestamp,
|
|
3013
3170
|
timestamp
|
|
3014
3171
|
]);
|
|
3172
|
+
hookRegistry.runHooks("PostEntityCreate", {
|
|
3173
|
+
entityId: id,
|
|
3174
|
+
name: input.name,
|
|
3175
|
+
entityType: input.type,
|
|
3176
|
+
projectId: input.project_id,
|
|
3177
|
+
timestamp: Date.now()
|
|
3178
|
+
});
|
|
3015
3179
|
return getEntity(id, d);
|
|
3016
3180
|
}
|
|
3017
3181
|
function getEntity(id, db) {
|
|
@@ -3097,6 +3261,7 @@ function mergeEntities(sourceId, targetId, db) {
|
|
|
3097
3261
|
var init_entities = __esm(() => {
|
|
3098
3262
|
init_database();
|
|
3099
3263
|
init_types();
|
|
3264
|
+
init_hooks();
|
|
3100
3265
|
});
|
|
3101
3266
|
|
|
3102
3267
|
// src/lib/search.ts
|
|
@@ -3696,7 +3861,15 @@ function createRelation(input, db) {
|
|
|
3696
3861
|
DO UPDATE SET weight = excluded.weight, metadata = excluded.metadata`, [id, input.source_entity_id, input.target_entity_id, input.relation_type, weight, metadata, timestamp]);
|
|
3697
3862
|
const row = d.query(`SELECT * FROM relations
|
|
3698
3863
|
WHERE source_entity_id = ? AND target_entity_id = ? AND relation_type = ?`).get(input.source_entity_id, input.target_entity_id, input.relation_type);
|
|
3699
|
-
|
|
3864
|
+
const relation = parseRelationRow(row);
|
|
3865
|
+
hookRegistry.runHooks("PostRelationCreate", {
|
|
3866
|
+
relationId: relation.id,
|
|
3867
|
+
sourceEntityId: relation.source_entity_id,
|
|
3868
|
+
targetEntityId: relation.target_entity_id,
|
|
3869
|
+
relationType: relation.relation_type,
|
|
3870
|
+
timestamp: Date.now()
|
|
3871
|
+
});
|
|
3872
|
+
return relation;
|
|
3700
3873
|
}
|
|
3701
3874
|
function listRelations(filter, db) {
|
|
3702
3875
|
const d = db || getDatabase();
|
|
@@ -3805,6 +3978,7 @@ function findPath(fromEntityId, toEntityId, maxDepth = 5, db) {
|
|
|
3805
3978
|
}
|
|
3806
3979
|
var init_relations = __esm(() => {
|
|
3807
3980
|
init_database();
|
|
3981
|
+
init_hooks();
|
|
3808
3982
|
});
|
|
3809
3983
|
|
|
3810
3984
|
// src/lib/poll.ts
|
|
@@ -4646,6 +4820,216 @@ var init_auto_memory = __esm(() => {
|
|
|
4646
4820
|
autoMemoryQueue.setHandler(processJob);
|
|
4647
4821
|
});
|
|
4648
4822
|
|
|
4823
|
+
// src/db/webhook_hooks.ts
|
|
4824
|
+
var exports_webhook_hooks = {};
|
|
4825
|
+
__export(exports_webhook_hooks, {
|
|
4826
|
+
updateWebhookHook: () => updateWebhookHook,
|
|
4827
|
+
recordWebhookInvocation: () => recordWebhookInvocation,
|
|
4828
|
+
listWebhookHooks: () => listWebhookHooks,
|
|
4829
|
+
getWebhookHook: () => getWebhookHook,
|
|
4830
|
+
deleteWebhookHook: () => deleteWebhookHook,
|
|
4831
|
+
createWebhookHook: () => createWebhookHook
|
|
4832
|
+
});
|
|
4833
|
+
function parseRow(row) {
|
|
4834
|
+
return {
|
|
4835
|
+
id: row["id"],
|
|
4836
|
+
type: row["type"],
|
|
4837
|
+
handlerUrl: row["handler_url"],
|
|
4838
|
+
priority: row["priority"],
|
|
4839
|
+
blocking: Boolean(row["blocking"]),
|
|
4840
|
+
agentId: row["agent_id"] || undefined,
|
|
4841
|
+
projectId: row["project_id"] || undefined,
|
|
4842
|
+
description: row["description"] || undefined,
|
|
4843
|
+
enabled: Boolean(row["enabled"]),
|
|
4844
|
+
createdAt: row["created_at"],
|
|
4845
|
+
invocationCount: row["invocation_count"],
|
|
4846
|
+
failureCount: row["failure_count"]
|
|
4847
|
+
};
|
|
4848
|
+
}
|
|
4849
|
+
function createWebhookHook(input, db) {
|
|
4850
|
+
const d = db || getDatabase();
|
|
4851
|
+
const id = shortUuid();
|
|
4852
|
+
const timestamp = now();
|
|
4853
|
+
d.run(`INSERT INTO webhook_hooks
|
|
4854
|
+
(id, type, handler_url, priority, blocking, agent_id, project_id, description, enabled, created_at, invocation_count, failure_count)
|
|
4855
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1, ?, 0, 0)`, [
|
|
4856
|
+
id,
|
|
4857
|
+
input.type,
|
|
4858
|
+
input.handlerUrl,
|
|
4859
|
+
input.priority ?? 50,
|
|
4860
|
+
input.blocking ? 1 : 0,
|
|
4861
|
+
input.agentId ?? null,
|
|
4862
|
+
input.projectId ?? null,
|
|
4863
|
+
input.description ?? null,
|
|
4864
|
+
timestamp
|
|
4865
|
+
]);
|
|
4866
|
+
return getWebhookHook(id, d);
|
|
4867
|
+
}
|
|
4868
|
+
function getWebhookHook(id, db) {
|
|
4869
|
+
const d = db || getDatabase();
|
|
4870
|
+
const row = d.query("SELECT * FROM webhook_hooks WHERE id = ?").get(id);
|
|
4871
|
+
return row ? parseRow(row) : null;
|
|
4872
|
+
}
|
|
4873
|
+
function listWebhookHooks(filter = {}, db) {
|
|
4874
|
+
const d = db || getDatabase();
|
|
4875
|
+
const conditions = [];
|
|
4876
|
+
const params = [];
|
|
4877
|
+
if (filter.type) {
|
|
4878
|
+
conditions.push("type = ?");
|
|
4879
|
+
params.push(filter.type);
|
|
4880
|
+
}
|
|
4881
|
+
if (filter.enabled !== undefined) {
|
|
4882
|
+
conditions.push("enabled = ?");
|
|
4883
|
+
params.push(filter.enabled ? 1 : 0);
|
|
4884
|
+
}
|
|
4885
|
+
const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
4886
|
+
const rows = d.query(`SELECT * FROM webhook_hooks ${where} ORDER BY priority ASC, created_at ASC`).all(...params);
|
|
4887
|
+
return rows.map(parseRow);
|
|
4888
|
+
}
|
|
4889
|
+
function updateWebhookHook(id, updates, db) {
|
|
4890
|
+
const d = db || getDatabase();
|
|
4891
|
+
const existing = getWebhookHook(id, d);
|
|
4892
|
+
if (!existing)
|
|
4893
|
+
return null;
|
|
4894
|
+
const sets = [];
|
|
4895
|
+
const params = [];
|
|
4896
|
+
if (updates.enabled !== undefined) {
|
|
4897
|
+
sets.push("enabled = ?");
|
|
4898
|
+
params.push(updates.enabled ? 1 : 0);
|
|
4899
|
+
}
|
|
4900
|
+
if (updates.description !== undefined) {
|
|
4901
|
+
sets.push("description = ?");
|
|
4902
|
+
params.push(updates.description);
|
|
4903
|
+
}
|
|
4904
|
+
if (updates.priority !== undefined) {
|
|
4905
|
+
sets.push("priority = ?");
|
|
4906
|
+
params.push(updates.priority);
|
|
4907
|
+
}
|
|
4908
|
+
if (sets.length > 0) {
|
|
4909
|
+
params.push(id);
|
|
4910
|
+
d.run(`UPDATE webhook_hooks SET ${sets.join(", ")} WHERE id = ?`, params);
|
|
4911
|
+
}
|
|
4912
|
+
return getWebhookHook(id, d);
|
|
4913
|
+
}
|
|
4914
|
+
function deleteWebhookHook(id, db) {
|
|
4915
|
+
const d = db || getDatabase();
|
|
4916
|
+
const result = d.run("DELETE FROM webhook_hooks WHERE id = ?", [id]);
|
|
4917
|
+
return result.changes > 0;
|
|
4918
|
+
}
|
|
4919
|
+
function recordWebhookInvocation(id, success, db) {
|
|
4920
|
+
const d = db || getDatabase();
|
|
4921
|
+
if (success) {
|
|
4922
|
+
d.run("UPDATE webhook_hooks SET invocation_count = invocation_count + 1 WHERE id = ?", [id]);
|
|
4923
|
+
} else {
|
|
4924
|
+
d.run("UPDATE webhook_hooks SET invocation_count = invocation_count + 1, failure_count = failure_count + 1 WHERE id = ?", [id]);
|
|
4925
|
+
}
|
|
4926
|
+
}
|
|
4927
|
+
var init_webhook_hooks = __esm(() => {
|
|
4928
|
+
init_database();
|
|
4929
|
+
});
|
|
4930
|
+
|
|
4931
|
+
// src/lib/built-in-hooks.ts
|
|
4932
|
+
var exports_built_in_hooks = {};
|
|
4933
|
+
__export(exports_built_in_hooks, {
|
|
4934
|
+
reloadWebhooks: () => reloadWebhooks,
|
|
4935
|
+
loadWebhooksFromDb: () => loadWebhooksFromDb
|
|
4936
|
+
});
|
|
4937
|
+
async function getAutoMemory() {
|
|
4938
|
+
if (!_processConversationTurn) {
|
|
4939
|
+
const mod = await Promise.resolve().then(() => (init_auto_memory(), exports_auto_memory));
|
|
4940
|
+
_processConversationTurn = mod.processConversationTurn;
|
|
4941
|
+
}
|
|
4942
|
+
return _processConversationTurn;
|
|
4943
|
+
}
|
|
4944
|
+
function loadWebhooksFromDb() {
|
|
4945
|
+
if (_webhooksLoaded)
|
|
4946
|
+
return;
|
|
4947
|
+
_webhooksLoaded = true;
|
|
4948
|
+
try {
|
|
4949
|
+
const webhooks = listWebhookHooks({ enabled: true });
|
|
4950
|
+
for (const wh of webhooks) {
|
|
4951
|
+
hookRegistry.register({
|
|
4952
|
+
type: wh.type,
|
|
4953
|
+
blocking: wh.blocking,
|
|
4954
|
+
priority: wh.priority,
|
|
4955
|
+
agentId: wh.agentId,
|
|
4956
|
+
projectId: wh.projectId,
|
|
4957
|
+
description: wh.description ?? `Webhook: ${wh.handlerUrl}`,
|
|
4958
|
+
handler: makeWebhookHandler(wh.id, wh.handlerUrl)
|
|
4959
|
+
});
|
|
4960
|
+
}
|
|
4961
|
+
if (webhooks.length > 0) {
|
|
4962
|
+
console.log(`[hooks] Loaded ${webhooks.length} webhook(s) from DB`);
|
|
4963
|
+
}
|
|
4964
|
+
} catch (err) {
|
|
4965
|
+
console.error("[hooks] Failed to load webhooks from DB:", err);
|
|
4966
|
+
}
|
|
4967
|
+
}
|
|
4968
|
+
function makeWebhookHandler(webhookId, url) {
|
|
4969
|
+
return async (context) => {
|
|
4970
|
+
try {
|
|
4971
|
+
const res = await fetch(url, {
|
|
4972
|
+
method: "POST",
|
|
4973
|
+
headers: { "Content-Type": "application/json" },
|
|
4974
|
+
body: JSON.stringify(context),
|
|
4975
|
+
signal: AbortSignal.timeout(1e4)
|
|
4976
|
+
});
|
|
4977
|
+
recordWebhookInvocation(webhookId, res.ok);
|
|
4978
|
+
} catch {
|
|
4979
|
+
recordWebhookInvocation(webhookId, false);
|
|
4980
|
+
}
|
|
4981
|
+
};
|
|
4982
|
+
}
|
|
4983
|
+
function reloadWebhooks() {
|
|
4984
|
+
_webhooksLoaded = false;
|
|
4985
|
+
loadWebhooksFromDb();
|
|
4986
|
+
}
|
|
4987
|
+
var _processConversationTurn = null, _webhooksLoaded = false;
|
|
4988
|
+
var init_built_in_hooks = __esm(() => {
|
|
4989
|
+
init_hooks();
|
|
4990
|
+
init_webhook_hooks();
|
|
4991
|
+
hookRegistry.register({
|
|
4992
|
+
type: "PostMemorySave",
|
|
4993
|
+
blocking: false,
|
|
4994
|
+
builtin: true,
|
|
4995
|
+
priority: 100,
|
|
4996
|
+
description: "Trigger async LLM entity extraction when a memory is saved",
|
|
4997
|
+
handler: async (ctx) => {
|
|
4998
|
+
if (ctx.wasUpdated)
|
|
4999
|
+
return;
|
|
5000
|
+
const processConversationTurn2 = await getAutoMemory();
|
|
5001
|
+
processConversationTurn2(`${ctx.memory.key}: ${ctx.memory.value}`, {
|
|
5002
|
+
agentId: ctx.agentId,
|
|
5003
|
+
projectId: ctx.projectId,
|
|
5004
|
+
sessionId: ctx.sessionId
|
|
5005
|
+
});
|
|
5006
|
+
}
|
|
5007
|
+
});
|
|
5008
|
+
hookRegistry.register({
|
|
5009
|
+
type: "OnSessionStart",
|
|
5010
|
+
blocking: false,
|
|
5011
|
+
builtin: true,
|
|
5012
|
+
priority: 100,
|
|
5013
|
+
description: "Record session start as a history memory for analytics",
|
|
5014
|
+
handler: async (ctx) => {
|
|
5015
|
+
const { createMemory: createMemory2 } = await Promise.resolve().then(() => (init_memories(), exports_memories));
|
|
5016
|
+
try {
|
|
5017
|
+
createMemory2({
|
|
5018
|
+
key: `session-start-${ctx.agentId}`,
|
|
5019
|
+
value: `Agent ${ctx.agentId} started session on project ${ctx.projectId} at ${new Date(ctx.timestamp).toISOString()}`,
|
|
5020
|
+
category: "history",
|
|
5021
|
+
scope: "shared",
|
|
5022
|
+
importance: 3,
|
|
5023
|
+
source: "system",
|
|
5024
|
+
agent_id: ctx.agentId,
|
|
5025
|
+
project_id: ctx.projectId,
|
|
5026
|
+
session_id: ctx.sessionId
|
|
5027
|
+
});
|
|
5028
|
+
} catch {}
|
|
5029
|
+
}
|
|
5030
|
+
});
|
|
5031
|
+
});
|
|
5032
|
+
|
|
4649
5033
|
// node_modules/commander/esm.mjs
|
|
4650
5034
|
var import__ = __toESM(require_commander(), 1);
|
|
4651
5035
|
var {
|
|
@@ -8148,4 +8532,107 @@ autoMemory.command("disable").description("Disable auto-memory extraction").acti
|
|
|
8148
8532
|
configureAutoMemory2({ enabled: false });
|
|
8149
8533
|
console.log(chalk.yellow("\u26A0 Auto-memory disabled"));
|
|
8150
8534
|
});
|
|
8535
|
+
var hooksCmd = program2.command("hooks").description("Hook registry and webhook management");
|
|
8536
|
+
hooksCmd.command("list").description("List registered hooks in the in-memory registry").option("--type <type>", "Filter by hook type").action(async (opts) => {
|
|
8537
|
+
const { hookRegistry: hookRegistry2 } = await Promise.resolve().then(() => (init_hooks(), exports_hooks));
|
|
8538
|
+
const hooks = hookRegistry2.list(opts.type);
|
|
8539
|
+
if (hooks.length === 0) {
|
|
8540
|
+
console.log(chalk.gray("No hooks registered."));
|
|
8541
|
+
return;
|
|
8542
|
+
}
|
|
8543
|
+
for (const h of hooks) {
|
|
8544
|
+
const builtinTag = h.builtin ? chalk.blue(" [builtin]") : "";
|
|
8545
|
+
const blockingTag = h.blocking ? chalk.red(" [blocking]") : chalk.gray(" [non-blocking]");
|
|
8546
|
+
console.log(`${chalk.cyan(h.id)} ${chalk.bold(h.type)}${builtinTag}${blockingTag} priority=${h.priority}`);
|
|
8547
|
+
if (h.description)
|
|
8548
|
+
console.log(` ${chalk.gray(h.description)}`);
|
|
8549
|
+
}
|
|
8550
|
+
});
|
|
8551
|
+
hooksCmd.command("stats").description("Show hook registry statistics").action(async () => {
|
|
8552
|
+
const { hookRegistry: hookRegistry2 } = await Promise.resolve().then(() => (init_hooks(), exports_hooks));
|
|
8553
|
+
const stats = hookRegistry2.stats();
|
|
8554
|
+
console.log(chalk.bold("Hook Registry Stats"));
|
|
8555
|
+
console.log(` Total: ${chalk.cyan(stats.total)}`);
|
|
8556
|
+
console.log(` Blocking: ${chalk.red(stats.blocking)}`);
|
|
8557
|
+
console.log(` Non-blocking:${chalk.green(stats.nonBlocking)}`);
|
|
8558
|
+
if (Object.keys(stats.byType).length > 0) {
|
|
8559
|
+
console.log(chalk.bold(`
|
|
8560
|
+
By type:`));
|
|
8561
|
+
for (const [type, count] of Object.entries(stats.byType)) {
|
|
8562
|
+
console.log(` ${type}: ${count}`);
|
|
8563
|
+
}
|
|
8564
|
+
}
|
|
8565
|
+
});
|
|
8566
|
+
var webhooksCmd = hooksCmd.command("webhooks").alias("wh").description("Manage persistent HTTP webhook hooks");
|
|
8567
|
+
webhooksCmd.command("list").description("List all persisted webhook hooks").option("--type <type>", "Filter by hook type").option("--disabled", "Show only disabled webhooks").action(async (opts) => {
|
|
8568
|
+
const { listWebhookHooks: listWebhookHooks2 } = await Promise.resolve().then(() => (init_webhook_hooks(), exports_webhook_hooks));
|
|
8569
|
+
const webhooks = listWebhookHooks2({
|
|
8570
|
+
type: opts.type,
|
|
8571
|
+
enabled: opts.disabled ? false : undefined
|
|
8572
|
+
});
|
|
8573
|
+
if (webhooks.length === 0) {
|
|
8574
|
+
console.log(chalk.gray("No webhooks registered."));
|
|
8575
|
+
return;
|
|
8576
|
+
}
|
|
8577
|
+
for (const wh of webhooks) {
|
|
8578
|
+
const enabledTag = wh.enabled ? chalk.green("enabled") : chalk.red("disabled");
|
|
8579
|
+
const blockingTag = wh.blocking ? chalk.red("blocking") : chalk.gray("non-blocking");
|
|
8580
|
+
console.log(`${chalk.cyan(wh.id)} [${enabledTag}] ${chalk.bold(wh.type)} \u2192 ${wh.handlerUrl}`);
|
|
8581
|
+
console.log(` ${blockingTag} | priority=${wh.priority} | invocations=${wh.invocationCount} failures=${wh.failureCount}`);
|
|
8582
|
+
if (wh.description)
|
|
8583
|
+
console.log(` ${chalk.gray(wh.description)}`);
|
|
8584
|
+
}
|
|
8585
|
+
});
|
|
8586
|
+
webhooksCmd.command("create <type> <url>").description("Create a persistent webhook hook").option("--blocking", "Block the operation until the webhook responds").option("--priority <n>", "Hook priority (default 50)", "50").option("--agent <id>", "Scope to specific agent").option("--project <id>", "Scope to specific project").option("--description <text>", "Human-readable description").action(async (type, url, opts) => {
|
|
8587
|
+
const { createWebhookHook: createWebhookHook2 } = await Promise.resolve().then(() => (init_webhook_hooks(), exports_webhook_hooks));
|
|
8588
|
+
const { reloadWebhooks: reloadWebhooks2 } = await Promise.resolve().then(() => (init_built_in_hooks(), exports_built_in_hooks));
|
|
8589
|
+
const wh = createWebhookHook2({
|
|
8590
|
+
type,
|
|
8591
|
+
handlerUrl: url,
|
|
8592
|
+
blocking: opts.blocking ?? false,
|
|
8593
|
+
priority: parseInt(opts.priority, 10),
|
|
8594
|
+
agentId: opts.agent,
|
|
8595
|
+
projectId: opts.project,
|
|
8596
|
+
description: opts.description
|
|
8597
|
+
});
|
|
8598
|
+
reloadWebhooks2();
|
|
8599
|
+
console.log(chalk.green("\u2713 Webhook created"));
|
|
8600
|
+
console.log(` ID: ${chalk.cyan(wh.id)}`);
|
|
8601
|
+
console.log(` Type: ${wh.type}`);
|
|
8602
|
+
console.log(` URL: ${wh.handlerUrl}`);
|
|
8603
|
+
});
|
|
8604
|
+
webhooksCmd.command("delete <id>").description("Delete a webhook by ID").action(async (id) => {
|
|
8605
|
+
const { deleteWebhookHook: deleteWebhookHook2 } = await Promise.resolve().then(() => (init_webhook_hooks(), exports_webhook_hooks));
|
|
8606
|
+
const deleted = deleteWebhookHook2(id);
|
|
8607
|
+
if (deleted) {
|
|
8608
|
+
console.log(chalk.green(`\u2713 Webhook ${id} deleted`));
|
|
8609
|
+
} else {
|
|
8610
|
+
console.error(chalk.red(`Webhook not found: ${id}`));
|
|
8611
|
+
process.exit(1);
|
|
8612
|
+
}
|
|
8613
|
+
});
|
|
8614
|
+
webhooksCmd.command("enable <id>").description("Enable a webhook").action(async (id) => {
|
|
8615
|
+
const { updateWebhookHook: updateWebhookHook2 } = await Promise.resolve().then(() => (init_webhook_hooks(), exports_webhook_hooks));
|
|
8616
|
+
const { reloadWebhooks: reloadWebhooks2 } = await Promise.resolve().then(() => (init_built_in_hooks(), exports_built_in_hooks));
|
|
8617
|
+
const updated = updateWebhookHook2(id, { enabled: true });
|
|
8618
|
+
if (updated) {
|
|
8619
|
+
reloadWebhooks2();
|
|
8620
|
+
console.log(chalk.green(`\u2713 Webhook ${id} enabled`));
|
|
8621
|
+
} else {
|
|
8622
|
+
console.error(chalk.red(`Webhook not found: ${id}`));
|
|
8623
|
+
process.exit(1);
|
|
8624
|
+
}
|
|
8625
|
+
});
|
|
8626
|
+
webhooksCmd.command("disable <id>").description("Disable a webhook (without deleting it)").action(async (id) => {
|
|
8627
|
+
const { updateWebhookHook: updateWebhookHook2 } = await Promise.resolve().then(() => (init_webhook_hooks(), exports_webhook_hooks));
|
|
8628
|
+
const { reloadWebhooks: reloadWebhooks2 } = await Promise.resolve().then(() => (init_built_in_hooks(), exports_built_in_hooks));
|
|
8629
|
+
const updated = updateWebhookHook2(id, { enabled: false });
|
|
8630
|
+
if (updated) {
|
|
8631
|
+
reloadWebhooks2();
|
|
8632
|
+
console.log(chalk.yellow(`\u2298 Webhook ${id} disabled`));
|
|
8633
|
+
} else {
|
|
8634
|
+
console.error(chalk.red(`Webhook not found: ${id}`));
|
|
8635
|
+
process.exit(1);
|
|
8636
|
+
}
|
|
8637
|
+
});
|
|
8151
8638
|
program2.parse(process.argv);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/db/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAmCtC,wBAAgB,SAAS,IAAI,MAAM,CAkBlC;
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/db/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAmCtC,wBAAgB,SAAS,IAAI,MAAM,CAkBlC;AAiSD,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,CAerD;AA+BD,wBAAgB,aAAa,IAAI,IAAI,CAKpC;AAED,wBAAgB,aAAa,IAAI,IAAI,CAEpC;AAED,wBAAgB,GAAG,IAAI,MAAM,CAE5B;AAED,wBAAgB,IAAI,IAAI,MAAM,CAE7B;AAED,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED,wBAAgB,gBAAgB,CAC9B,EAAE,EAAE,QAAQ,EACZ,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,GAChB,MAAM,GAAG,IAAI,CAef"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../src/db/entities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAyB,MAAM,YAAY,CAAC;AAE7D,OAAO,KAAK,EACV,MAAM,EACN,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACX,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../src/db/entities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAyB,MAAM,YAAY,CAAC;AAE7D,OAAO,KAAK,EACV,MAAM,EACN,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACX,MAAM,mBAAmB,CAAC;AAQ3B,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAWnE;AAMD,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,MAAM,CA+D5E;AAMD,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,MAAM,CAO3D;AAED,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,UAAU,EACjB,SAAS,CAAC,EAAE,MAAM,EAClB,EAAE,CAAC,EAAE,QAAQ,GACZ,MAAM,GAAG,IAAI,CAoBf;AAMD,wBAAgB,YAAY,CAC1B,MAAM,GAAE;IACN,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACZ,EACN,EAAE,CAAC,EAAE,QAAQ,GACZ,MAAM,EAAE,CAoCV;AAMD,wBAAgB,YAAY,CAC1B,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,iBAAiB,EACxB,EAAE,CAAC,EAAE,QAAQ,GACZ,MAAM,CAiCR;AAMD,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,IAAI,CAI5D;AAMD,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,EAAE,CAAC,EAAE,QAAQ,GACZ,MAAM,CA0CR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memories.d.ts","sourceRoot":"","sources":["../../src/db/memories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAyB,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EACV,MAAM,EACN,YAAY,EACZ,aAAa,EACb,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"memories.d.ts","sourceRoot":"","sources":["../../src/db/memories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAyB,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EACV,MAAM,EACN,YAAY,EACZ,aAAa,EACb,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;AA6B3B,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAwBnE;AAMD,wBAAgB,YAAY,CAC1B,KAAK,EAAE,iBAAiB,EACxB,UAAU,GAAE,UAAoB,EAChC,EAAE,CAAC,EAAE,QAAQ,GACZ,MAAM,CAqIR;AAMD,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAOlE;AAED,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,EACX,KAAK,CAAC,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM,EAClB,EAAE,CAAC,EAAE,QAAQ,GACZ,MAAM,GAAG,IAAI,CA4Bf;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,KAAK,CAAC,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,MAAM,EAClB,EAAE,CAAC,EAAE,QAAQ,GACZ,MAAM,EAAE,CAuBV;AAMD,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,MAAM,EAAE,CA4G3E;AAMD,wBAAgB,YAAY,CAC1B,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,iBAAiB,EACxB,EAAE,CAAC,EAAE,QAAQ,GACZ,MAAM,CAiHR;AAMD,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,OAAO,CAW/D;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,MAAM,CAmBvE;AAMD,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,IAAI,CAM3D;AAUD,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,IAAI,CAsBpE;AAMD,wBAAgB,oBAAoB,CAAC,EAAE,CAAC,EAAE,QAAQ,GAAG,MAAM,CAiB1D;AAMD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,aAAa,EAAE,CAwBlF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relations.d.ts","sourceRoot":"","sources":["../../src/db/relations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAyB,MAAM,YAAY,CAAC;AAE7D,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"relations.d.ts","sourceRoot":"","sources":["../../src/db/relations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAyB,MAAM,YAAY,CAAC;AAE7D,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,CAmClF;AAMD,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAK/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,CA2BZ;AAMD,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,IAAI,CAI9D;AAMD;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,YAAY,CAAC,EAAE,YAAY,EAC3B,EAAE,CAAC,EAAE,QAAQ,GACZ,MAAM,EAAE,CA6BV;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,KAAK,GAAE,MAAU,EACjB,EAAE,CAAC,EAAE,QAAQ,GACZ;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,SAAS,EAAE,QAAQ,EAAE,CAAA;CAAE,CAqC/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,CAgCjB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Database } from "bun:sqlite";
|
|
2
|
+
import type { WebhookHook, HookType } from "../types/hooks.js";
|
|
3
|
+
export interface CreateWebhookHookInput {
|
|
4
|
+
type: HookType;
|
|
5
|
+
handlerUrl: string;
|
|
6
|
+
priority?: number;
|
|
7
|
+
blocking?: boolean;
|
|
8
|
+
agentId?: string;
|
|
9
|
+
projectId?: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function createWebhookHook(input: CreateWebhookHookInput, db?: Database): WebhookHook;
|
|
13
|
+
export declare function getWebhookHook(id: string, db?: Database): WebhookHook | null;
|
|
14
|
+
export declare function listWebhookHooks(filter?: {
|
|
15
|
+
type?: HookType;
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
}, db?: Database): WebhookHook[];
|
|
18
|
+
export declare function updateWebhookHook(id: string, updates: {
|
|
19
|
+
enabled?: boolean;
|
|
20
|
+
description?: string;
|
|
21
|
+
priority?: number;
|
|
22
|
+
}, db?: Database): WebhookHook | null;
|
|
23
|
+
export declare function deleteWebhookHook(id: string, db?: Database): boolean;
|
|
24
|
+
export declare function recordWebhookInvocation(id: string, success: boolean, db?: Database): void;
|
|
25
|
+
//# sourceMappingURL=webhook_hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook_hooks.d.ts","sourceRoot":"","sources":["../../src/db/webhook_hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAyB,MAAM,YAAY,CAAC;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AA2B/D,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,sBAAsB,EAC7B,EAAE,CAAC,EAAE,QAAQ,GACZ,WAAW,CAuBb;AAMD,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,WAAW,GAAG,IAAI,CAM5E;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,GAAE;IAAE,IAAI,CAAC,EAAE,QAAQ,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,EACnD,EAAE,CAAC,EAAE,QAAQ,GACZ,WAAW,EAAE,CAoBf;AAMD,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,MAAM,EACV,OAAO,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,EACvE,EAAE,CAAC,EAAE,QAAQ,GACZ,WAAW,GAAG,IAAI,CA2BpB;AAMD,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,QAAQ,GAAG,OAAO,CAIpE;AAMD,wBAAgB,uBAAuB,CACrC,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,OAAO,EAChB,EAAE,CAAC,EAAE,QAAQ,GACZ,IAAI,CAaN"}
|