@grackle-ai/core 0.97.0 → 0.99.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/index.d.ts +0 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -3
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/dist/knowledge-health.d.ts +0 -53
- package/dist/knowledge-health.d.ts.map +0 -1
- package/dist/knowledge-health.js +0 -92
- package/dist/knowledge-health.js.map +0 -1
- package/dist/knowledge-init.d.ts +0 -29
- package/dist/knowledge-init.d.ts.map +0 -1
- package/dist/knowledge-init.js +0 -220
- package/dist/knowledge-init.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -19,7 +19,6 @@ export type { ResolveEnvironmentDeps } from "./resolve-dispatch-environment.js";
|
|
|
19
19
|
export { checkBudget, costUsdToMillicents } from "./budget-checker.js";
|
|
20
20
|
export type { BudgetExceeded } from "./budget-checker.js";
|
|
21
21
|
export { sendInputToSession, deliverSignalToTask } from "./signals/signal-delivery.js";
|
|
22
|
-
export { isKnowledgeEnabled, initKnowledge, neo4jHealthCheck, getKnowledgeEmbedder } from "./knowledge-init.js";
|
|
23
22
|
export { ReconciliationManager } from "./reconciliation-manager.js";
|
|
24
23
|
export type { ReconciliationPhase } from "./reconciliation-manager.js";
|
|
25
24
|
export { checkVersionStatus, clearVersionCache, type VersionStatus } from "./version-check.js";
|
|
@@ -44,8 +43,6 @@ export { ensureLifecycleStream, cleanupLifecycleStream } from "./lifecycle-strea
|
|
|
44
43
|
export { ensureAsyncDeliveryListener } from "./pipe-delivery.js";
|
|
45
44
|
export { readLastTextEntry } from "./log-writer.js";
|
|
46
45
|
export { routeEscalation, deliverPendingEscalations } from "./notification-router.js";
|
|
47
|
-
export { createKnowledgeHealthPhase, isNeo4jHealthy, getKnowledgeReadinessCheck, resetKnowledgeHealthState, } from "./knowledge-health.js";
|
|
48
|
-
export type { KnowledgeHealthPhaseDeps, KnowledgeReadinessCheck } from "./knowledge-health.js";
|
|
49
46
|
export { buildMcpServersJson, personaMcpServersToJson } from "./grpc-mcp-config.js";
|
|
50
47
|
export { toDialableHost, validatePipeInputs, resolveAncestorEnvironmentId, VALID_PIPE_MODES } from "./grpc-shared-utils.js";
|
|
51
48
|
export { toPersonaResolveInput, buildOrchestratorContextInput } from "./persona-mapper.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAG7E,OAAO,EACL,eAAe,EAAE,UAAU,EAC3B,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAC/D,cAAc,EAAE,aAAa,GAC9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAGzD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACjD,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjF,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG1F,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,6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BAAyB,CAAC;AAC7D,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,YAAY,MAAM,oBAAoB,CAAC;AAGnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC5F,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAGpD,OAAO,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC5H,OAAO,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -18,8 +18,6 @@ export { hasCapacity, getEffectiveLimit } from "./concurrency.js";
|
|
|
18
18
|
export { resolveDispatchEnvironment } from "./resolve-dispatch-environment.js";
|
|
19
19
|
export { checkBudget, costUsdToMillicents } from "./budget-checker.js";
|
|
20
20
|
export { sendInputToSession, deliverSignalToTask } from "./signals/signal-delivery.js";
|
|
21
|
-
// ─── Knowledge ───────────────────────────────────────────────
|
|
22
|
-
export { isKnowledgeEnabled, initKnowledge, neo4jHealthCheck, getKnowledgeEmbedder } from "./knowledge-init.js";
|
|
23
21
|
// ─── Reconciliation Manager ─────────────────────────────────
|
|
24
22
|
export { ReconciliationManager } from "./reconciliation-manager.js";
|
|
25
23
|
// ─── Version Check ───────────────────────────────────────────
|
|
@@ -51,7 +49,6 @@ export { ensureAsyncDeliveryListener } from "./pipe-delivery.js";
|
|
|
51
49
|
export { readLastTextEntry } from "./log-writer.js";
|
|
52
50
|
// ─── Shared Utilities (used by both core and plugin-core) ────
|
|
53
51
|
export { routeEscalation, deliverPendingEscalations } from "./notification-router.js";
|
|
54
|
-
export { createKnowledgeHealthPhase, isNeo4jHealthy, getKnowledgeReadinessCheck, resetKnowledgeHealthState, } from "./knowledge-health.js";
|
|
55
52
|
export { buildMcpServersJson, personaMcpServersToJson } from "./grpc-mcp-config.js";
|
|
56
53
|
export { toDialableHost, validatePipeInputs, resolveAncestorEnvironmentId, VALID_PIPE_MODES } from "./grpc-shared-utils.js";
|
|
57
54
|
export { toPersonaResolveInput, buildOrchestratorContextInput } from "./persona-mapper.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAGhE,gEAAgE;AAChE,OAAO,EACL,eAAe,EAAE,UAAU,EAC3B,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAC/D,cAAc,EAAE,aAAa,GAC9B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,gEAAgE;AAChE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAMjD,gEAAgE;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,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M,sBAAsB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC5F,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,gEAAgE;AAChE,OAAO,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC5H,OAAO,EAAE,qBAAqB,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grackle-ai/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.99.0",
|
|
4
4
|
"description": "Core gRPC business logic for Grackle — RPC handlers, event system, streaming, session lifecycle",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -36,13 +36,13 @@
|
|
|
36
36
|
"pino": "^10.3.1",
|
|
37
37
|
"ulid": "^2.3.0",
|
|
38
38
|
"uuid": "^11.0.0",
|
|
39
|
-
"@grackle-ai/adapter-sdk": "0.
|
|
40
|
-
"@grackle-ai/
|
|
41
|
-
"@grackle-ai/
|
|
42
|
-
"@grackle-ai/database": "0.
|
|
43
|
-
"@grackle-ai/
|
|
44
|
-
"@grackle-ai/knowledge": "0.
|
|
45
|
-
"@grackle-ai/prompt": "0.
|
|
39
|
+
"@grackle-ai/adapter-sdk": "0.99.0",
|
|
40
|
+
"@grackle-ai/common": "0.99.0",
|
|
41
|
+
"@grackle-ai/plugin-sdk": "0.99.0",
|
|
42
|
+
"@grackle-ai/database": "0.99.0",
|
|
43
|
+
"@grackle-ai/auth": "0.99.0",
|
|
44
|
+
"@grackle-ai/knowledge": "0.99.0",
|
|
45
|
+
"@grackle-ai/prompt": "0.99.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@rushstack/heft": "1.2.7",
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Knowledge graph health monitoring.
|
|
3
|
-
*
|
|
4
|
-
* Provides a {@link ReconciliationPhase} that periodically checks Neo4j
|
|
5
|
-
* connectivity and tracks state transitions. Exposes the current health
|
|
6
|
-
* state for use by gRPC handlers, the event sync circuit breaker, and
|
|
7
|
-
* the `/readyz` endpoint.
|
|
8
|
-
*
|
|
9
|
-
* @module
|
|
10
|
-
*/
|
|
11
|
-
import type { ReconciliationPhase } from "./reconciliation-manager.js";
|
|
12
|
-
/** Dependencies injected into the knowledge health phase for testability. */
|
|
13
|
-
export interface KnowledgeHealthPhaseDeps {
|
|
14
|
-
/** Check Neo4j connectivity. Returns `true` if reachable. */
|
|
15
|
-
healthCheck: () => Promise<boolean>;
|
|
16
|
-
}
|
|
17
|
-
/** Readiness check result compatible with the web-server ReadinessCheck type. */
|
|
18
|
-
export interface KnowledgeReadinessCheck {
|
|
19
|
-
/** Whether Neo4j is reachable. */
|
|
20
|
-
ok: boolean;
|
|
21
|
-
/** Human-readable detail when unhealthy. */
|
|
22
|
-
message?: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Create a reconciliation phase that monitors Neo4j health.
|
|
26
|
-
*
|
|
27
|
-
* Calls `healthCheck()` on every tick and updates the module-level state.
|
|
28
|
-
* Logs only on state transitions (healthy to unhealthy or vice versa) to
|
|
29
|
-
* avoid log flooding during sustained outages.
|
|
30
|
-
*/
|
|
31
|
-
export declare function createKnowledgeHealthPhase(deps: KnowledgeHealthPhaseDeps): ReconciliationPhase;
|
|
32
|
-
/**
|
|
33
|
-
* Whether Neo4j is currently considered healthy.
|
|
34
|
-
*
|
|
35
|
-
* Returns `true` before the first health check has completed (optimistic
|
|
36
|
-
* default — `initKnowledge()` verifies connectivity at startup).
|
|
37
|
-
*/
|
|
38
|
-
export declare function isNeo4jHealthy(): boolean;
|
|
39
|
-
/**
|
|
40
|
-
* Get a readiness check result for the `/readyz` endpoint.
|
|
41
|
-
*
|
|
42
|
-
* Returns `{ ok: true }` when Neo4j is reachable (or before the first check
|
|
43
|
-
* completes, using the optimistic default), or `{ ok: false, message }` when
|
|
44
|
-
* Neo4j has been observed unreachable.
|
|
45
|
-
*/
|
|
46
|
-
export declare function getKnowledgeReadinessCheck(): KnowledgeReadinessCheck;
|
|
47
|
-
/**
|
|
48
|
-
* Reset health state for testing.
|
|
49
|
-
*
|
|
50
|
-
* @internal
|
|
51
|
-
*/
|
|
52
|
-
export declare function resetKnowledgeHealthState(): void;
|
|
53
|
-
//# sourceMappingURL=knowledge-health.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"knowledge-health.d.ts","sourceRoot":"","sources":["../src/knowledge-health.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAuBvE,6EAA6E;AAC7E,MAAM,WAAW,wBAAwB;IACvC,6DAA6D;IAC7D,WAAW,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CACrC;AAED,iFAAiF;AACjF,MAAM,WAAW,uBAAuB;IACtC,kCAAkC;IAClC,EAAE,EAAE,OAAO,CAAC;IACZ,4CAA4C;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,wBAAwB,GAC7B,mBAAmB,CAwBrB;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAExC;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,IAAI,uBAAuB,CAQpE;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,IAAI,IAAI,CAGhD"}
|
package/dist/knowledge-health.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Knowledge graph health monitoring.
|
|
3
|
-
*
|
|
4
|
-
* Provides a {@link ReconciliationPhase} that periodically checks Neo4j
|
|
5
|
-
* connectivity and tracks state transitions. Exposes the current health
|
|
6
|
-
* state for use by gRPC handlers, the event sync circuit breaker, and
|
|
7
|
-
* the `/readyz` endpoint.
|
|
8
|
-
*
|
|
9
|
-
* @module
|
|
10
|
-
*/
|
|
11
|
-
import { logger } from "./logger.js";
|
|
12
|
-
// ---------------------------------------------------------------------------
|
|
13
|
-
// Module-level state
|
|
14
|
-
// ---------------------------------------------------------------------------
|
|
15
|
-
/**
|
|
16
|
-
* Whether Neo4j was healthy on the last check.
|
|
17
|
-
*
|
|
18
|
-
* Defaults to `true` (optimistic) because `initKnowledge()` verifies
|
|
19
|
-
* connectivity via `openNeo4j()` before subscribing to events. This
|
|
20
|
-
* avoids a startup gap where events would be dropped before the first
|
|
21
|
-
* reconciliation tick (~10s).
|
|
22
|
-
*/
|
|
23
|
-
let healthy = true;
|
|
24
|
-
/** Whether at least one health check has completed. */
|
|
25
|
-
let initialized = false;
|
|
26
|
-
/**
|
|
27
|
-
* Create a reconciliation phase that monitors Neo4j health.
|
|
28
|
-
*
|
|
29
|
-
* Calls `healthCheck()` on every tick and updates the module-level state.
|
|
30
|
-
* Logs only on state transitions (healthy to unhealthy or vice versa) to
|
|
31
|
-
* avoid log flooding during sustained outages.
|
|
32
|
-
*/
|
|
33
|
-
export function createKnowledgeHealthPhase(deps) {
|
|
34
|
-
return {
|
|
35
|
-
name: "knowledge-health",
|
|
36
|
-
execute: async () => {
|
|
37
|
-
let result;
|
|
38
|
-
try {
|
|
39
|
-
result = await deps.healthCheck();
|
|
40
|
-
}
|
|
41
|
-
catch {
|
|
42
|
-
result = false;
|
|
43
|
-
}
|
|
44
|
-
const previous = healthy;
|
|
45
|
-
const wasInitialized = initialized;
|
|
46
|
-
healthy = result;
|
|
47
|
-
initialized = true;
|
|
48
|
-
// Log on state transitions and on first-check failures
|
|
49
|
-
if (previous && !result) {
|
|
50
|
-
logger.warn("Neo4j became unreachable — knowledge graph operations will be skipped");
|
|
51
|
-
}
|
|
52
|
-
else if (wasInitialized && !previous && result) {
|
|
53
|
-
logger.info("Neo4j recovered — knowledge graph operations resumed");
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Whether Neo4j is currently considered healthy.
|
|
60
|
-
*
|
|
61
|
-
* Returns `true` before the first health check has completed (optimistic
|
|
62
|
-
* default — `initKnowledge()` verifies connectivity at startup).
|
|
63
|
-
*/
|
|
64
|
-
export function isNeo4jHealthy() {
|
|
65
|
-
return healthy;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Get a readiness check result for the `/readyz` endpoint.
|
|
69
|
-
*
|
|
70
|
-
* Returns `{ ok: true }` when Neo4j is reachable (or before the first check
|
|
71
|
-
* completes, using the optimistic default), or `{ ok: false, message }` when
|
|
72
|
-
* Neo4j has been observed unreachable.
|
|
73
|
-
*/
|
|
74
|
-
export function getKnowledgeReadinessCheck() {
|
|
75
|
-
if (!initialized) {
|
|
76
|
-
return { ok: true, message: "Neo4j health check has not run yet" };
|
|
77
|
-
}
|
|
78
|
-
if (!healthy) {
|
|
79
|
-
return { ok: false, message: "Neo4j is unreachable" };
|
|
80
|
-
}
|
|
81
|
-
return { ok: true };
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Reset health state for testing.
|
|
85
|
-
*
|
|
86
|
-
* @internal
|
|
87
|
-
*/
|
|
88
|
-
export function resetKnowledgeHealthState() {
|
|
89
|
-
healthy = true;
|
|
90
|
-
initialized = false;
|
|
91
|
-
}
|
|
92
|
-
//# sourceMappingURL=knowledge-health.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"knowledge-health.js","sourceRoot":"","sources":["../src/knowledge-health.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E;AAE9E;;;;;;;GAOG;AACH,IAAI,OAAO,GAAY,IAAI,CAAC;AAE5B,uDAAuD;AACvD,IAAI,WAAW,GAAY,KAAK,CAAC;AAoBjC;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CACxC,IAA8B;IAE9B,OAAO;QACL,IAAI,EAAE,kBAAkB;QACxB,OAAO,EAAE,KAAK,IAAmB,EAAE;YACjC,IAAI,MAAe,CAAC;YACpB,IAAI,CAAC;gBACH,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;YACpC,CAAC;YAAC,MAAM,CAAC;gBACP,MAAM,GAAG,KAAK,CAAC;YACjB,CAAC;YAED,MAAM,QAAQ,GAAY,OAAO,CAAC;YAClC,MAAM,cAAc,GAAY,WAAW,CAAC;YAC5C,OAAO,GAAG,MAAM,CAAC;YACjB,WAAW,GAAG,IAAI,CAAC;YAEnB,uDAAuD;YACvD,IAAI,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;gBACxB,MAAM,CAAC,IAAI,CAAC,uEAAuE,CAAC,CAAC;YACvF,CAAC;iBAAM,IAAI,cAAc,IAAI,CAAC,QAAQ,IAAI,MAAM,EAAE,CAAC;gBACjD,MAAM,CAAC,IAAI,CAAC,sDAAsD,CAAC,CAAC;YACtE,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B;IACxC,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,oCAAoC,EAAE,CAAC;IACrE,CAAC;IACD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,sBAAsB,EAAE,CAAC;IACxD,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AACtB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB;IACvC,OAAO,GAAG,IAAI,CAAC;IACf,WAAW,GAAG,KAAK,CAAC;AACtB,CAAC"}
|
package/dist/knowledge-init.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Knowledge graph subsystem initialization and lifecycle management.
|
|
3
|
-
*
|
|
4
|
-
* Wires Neo4j, the local embedder, and event-driven reference node sync
|
|
5
|
-
* into the Grackle server. Opt-in via `GRACKLE_KNOWLEDGE_ENABLED=true`.
|
|
6
|
-
*
|
|
7
|
-
* @module
|
|
8
|
-
*/
|
|
9
|
-
import { healthCheck as neo4jHealthCheck, type Embedder } from "@grackle-ai/knowledge";
|
|
10
|
-
/** Re-export Neo4j health check for use by the reconciliation health phase. */
|
|
11
|
-
export { neo4jHealthCheck };
|
|
12
|
-
/** Whether the knowledge graph subsystem is enabled. */
|
|
13
|
-
export declare function isKnowledgeEnabled(): boolean;
|
|
14
|
-
/** Get the knowledge embedder. Returns undefined if knowledge is not initialized. */
|
|
15
|
-
export declare function getKnowledgeEmbedder(): Embedder | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* Initialize the knowledge graph subsystem.
|
|
18
|
-
*
|
|
19
|
-
* Opens Neo4j, initializes the schema, creates the local embedder,
|
|
20
|
-
* injects it into MCP tools, and subscribes to the event bus for
|
|
21
|
-
* automatic reference node sync.
|
|
22
|
-
*
|
|
23
|
-
* If any step after Neo4j connection fails, cleans up the connection
|
|
24
|
-
* before re-throwing.
|
|
25
|
-
*
|
|
26
|
-
* @returns A cleanup function that closes Neo4j and unsubscribes from events.
|
|
27
|
-
*/
|
|
28
|
-
export declare function initKnowledge(): Promise<() => Promise<void>>;
|
|
29
|
-
//# sourceMappingURL=knowledge-init.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"knowledge-init.d.ts","sourceRoot":"","sources":["../src/knowledge-init.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAIL,WAAW,IAAI,gBAAgB,EAS/B,KAAK,QAAQ,EACd,MAAM,uBAAuB,CAAC;AAU/B,+EAA+E;AAC/E,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,wDAAwD;AACxD,wBAAgB,kBAAkB,IAAI,OAAO,CAE5C;AAKD,qFAAqF;AACrF,wBAAgB,oBAAoB,IAAI,QAAQ,GAAG,SAAS,CAE3D;AAsLD;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CA6BlE"}
|
package/dist/knowledge-init.js
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Knowledge graph subsystem initialization and lifecycle management.
|
|
3
|
-
*
|
|
4
|
-
* Wires Neo4j, the local embedder, and event-driven reference node sync
|
|
5
|
-
* into the Grackle server. Opt-in via `GRACKLE_KNOWLEDGE_ENABLED=true`.
|
|
6
|
-
*
|
|
7
|
-
* @module
|
|
8
|
-
*/
|
|
9
|
-
import { openNeo4j, initSchema, closeNeo4j, healthCheck as neo4jHealthCheck, createLocalEmbedder, syncReferenceNode, deleteReferenceNodeBySource, findReferenceNodeBySource, createEdge, deriveTaskText, deriveFindingText, EDGE_TYPE, } from "@grackle-ai/knowledge";
|
|
10
|
-
import { subscribe } from "./event-bus.js";
|
|
11
|
-
import { taskStore, findingStore, safeParseJsonArray } from "@grackle-ai/database";
|
|
12
|
-
import { logger } from "./logger.js";
|
|
13
|
-
import { isNeo4jHealthy } from "./knowledge-health.js";
|
|
14
|
-
// ---------------------------------------------------------------------------
|
|
15
|
-
// Configuration
|
|
16
|
-
// ---------------------------------------------------------------------------
|
|
17
|
-
/** Re-export Neo4j health check for use by the reconciliation health phase. */
|
|
18
|
-
export { neo4jHealthCheck };
|
|
19
|
-
/** Whether the knowledge graph subsystem is enabled. */
|
|
20
|
-
export function isKnowledgeEnabled() {
|
|
21
|
-
return process.env.GRACKLE_KNOWLEDGE_ENABLED === "true";
|
|
22
|
-
}
|
|
23
|
-
/** Module-level embedder, available after initKnowledge() completes. */
|
|
24
|
-
let knowledgeEmbedder;
|
|
25
|
-
/** Get the knowledge embedder. Returns undefined if knowledge is not initialized. */
|
|
26
|
-
export function getKnowledgeEmbedder() {
|
|
27
|
-
return knowledgeEmbedder;
|
|
28
|
-
}
|
|
29
|
-
// ---------------------------------------------------------------------------
|
|
30
|
-
// Event handler
|
|
31
|
-
// ---------------------------------------------------------------------------
|
|
32
|
-
/**
|
|
33
|
-
* Create an event bus subscriber that syncs reference nodes.
|
|
34
|
-
*
|
|
35
|
-
* Sync is fire-and-forget — errors are logged but never propagated.
|
|
36
|
-
*/
|
|
37
|
-
function createEntitySyncHandler(embedder) {
|
|
38
|
-
return (event) => {
|
|
39
|
-
// Fire-and-forget async — errors handled inside handleEvent
|
|
40
|
-
handleEvent(embedder, event).catch(() => { });
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Ensure a task's reference node exists in the knowledge graph.
|
|
45
|
-
*
|
|
46
|
-
* If the node already exists, returns its ID. Otherwise syncs it from
|
|
47
|
-
* the task store and returns the new ID. Returns `undefined` if the
|
|
48
|
-
* task is not found in the store.
|
|
49
|
-
*/
|
|
50
|
-
async function ensureTaskReferenceNode(embedder, taskId) {
|
|
51
|
-
const existing = await findReferenceNodeBySource("task", taskId);
|
|
52
|
-
if (existing) {
|
|
53
|
-
return existing.id;
|
|
54
|
-
}
|
|
55
|
-
const task = taskStore.getTask(taskId);
|
|
56
|
-
if (!task) {
|
|
57
|
-
return undefined;
|
|
58
|
-
}
|
|
59
|
-
return syncReferenceNode(embedder, {
|
|
60
|
-
sourceType: "task",
|
|
61
|
-
sourceId: taskId,
|
|
62
|
-
label: task.title,
|
|
63
|
-
text: deriveTaskText(task.title, task.description),
|
|
64
|
-
workspaceId: task.workspaceId ?? "",
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Create edges from a task reference node to its parent and dependencies.
|
|
69
|
-
*
|
|
70
|
-
* Best-effort — edge creation failures are logged but don't block sync.
|
|
71
|
-
*/
|
|
72
|
-
async function syncTaskEdges(embedder, taskNodeId, task) {
|
|
73
|
-
// Parent task → PART_OF edge
|
|
74
|
-
if (task.parentTaskId) {
|
|
75
|
-
try {
|
|
76
|
-
const parentNodeId = await ensureTaskReferenceNode(embedder, task.parentTaskId);
|
|
77
|
-
if (parentNodeId) {
|
|
78
|
-
await createEdge(taskNodeId, parentNodeId, EDGE_TYPE.PART_OF);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
catch (err) {
|
|
82
|
-
logger.warn({ taskNodeId, parentTaskId: task.parentTaskId, err }, "Failed to create PART_OF edge");
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
// Dependencies → DEPENDS_ON edges
|
|
86
|
-
const deps = safeParseJsonArray(task.dependsOn);
|
|
87
|
-
for (const depId of deps) {
|
|
88
|
-
try {
|
|
89
|
-
const depNodeId = await ensureTaskReferenceNode(embedder, depId);
|
|
90
|
-
if (depNodeId) {
|
|
91
|
-
await createEdge(taskNodeId, depNodeId, EDGE_TYPE.DEPENDS_ON);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
catch (err) {
|
|
95
|
-
logger.warn({ taskNodeId, depId, err }, "Failed to create DEPENDS_ON edge");
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
/** Handle a single entity event. */
|
|
100
|
-
async function handleEvent(embedder, event) {
|
|
101
|
-
// Circuit breaker: skip sync when Neo4j is known-unreachable
|
|
102
|
-
if (!isNeo4jHealthy()) {
|
|
103
|
-
logger.debug({ eventType: event.type }, "Knowledge sync skipped — Neo4j unhealthy");
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
try {
|
|
107
|
-
const payload = event.payload;
|
|
108
|
-
switch (event.type) {
|
|
109
|
-
case "task.created":
|
|
110
|
-
case "task.updated": {
|
|
111
|
-
const taskId = payload.taskId;
|
|
112
|
-
if (typeof taskId !== "string" || !taskId) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
const task = taskStore.getTask(taskId);
|
|
116
|
-
if (!task) {
|
|
117
|
-
logger.warn({ taskId }, "Knowledge sync: task not found, skipping");
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
const taskNodeId = await syncReferenceNode(embedder, {
|
|
121
|
-
sourceType: "task",
|
|
122
|
-
sourceId: taskId,
|
|
123
|
-
label: task.title,
|
|
124
|
-
text: deriveTaskText(task.title, task.description),
|
|
125
|
-
workspaceId: task.workspaceId ?? "",
|
|
126
|
-
});
|
|
127
|
-
await syncTaskEdges(embedder, taskNodeId, task);
|
|
128
|
-
break;
|
|
129
|
-
}
|
|
130
|
-
case "task.deleted": {
|
|
131
|
-
const taskId = payload.taskId;
|
|
132
|
-
if (typeof taskId !== "string" || !taskId) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
await deleteReferenceNodeBySource("task", taskId);
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
case "finding.posted": {
|
|
139
|
-
const findingId = payload.findingId;
|
|
140
|
-
if (typeof findingId !== "string" || !findingId) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
const workspaceId = typeof payload.workspaceId === "string" ? payload.workspaceId : "";
|
|
144
|
-
const findings = findingStore.queryFindings(workspaceId);
|
|
145
|
-
const finding = findings.find((f) => f.id === findingId);
|
|
146
|
-
if (!finding) {
|
|
147
|
-
logger.warn({ findingId }, "Knowledge sync: finding not found, skipping");
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
const tags = safeParseJsonArray(typeof finding.tags === "string" ? finding.tags : null);
|
|
151
|
-
const findingNodeId = await syncReferenceNode(embedder, {
|
|
152
|
-
sourceType: "finding",
|
|
153
|
-
sourceId: findingId,
|
|
154
|
-
label: finding.title,
|
|
155
|
-
text: deriveFindingText(finding.title, finding.content, tags),
|
|
156
|
-
workspaceId,
|
|
157
|
-
});
|
|
158
|
-
// Link finding to its task
|
|
159
|
-
if (finding.taskId) {
|
|
160
|
-
try {
|
|
161
|
-
const taskNodeId = await ensureTaskReferenceNode(embedder, finding.taskId);
|
|
162
|
-
if (taskNodeId) {
|
|
163
|
-
await createEdge(findingNodeId, taskNodeId, EDGE_TYPE.DERIVED_FROM);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
catch (err) {
|
|
167
|
-
logger.warn({ findingNodeId, taskId: finding.taskId, err }, "Failed to create DERIVED_FROM edge");
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
break;
|
|
171
|
-
}
|
|
172
|
-
default:
|
|
173
|
-
// Ignore events we don't handle
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
catch (err) {
|
|
178
|
-
logger.error({ err, eventType: event.type, eventId: event.id }, "Knowledge sync failed for entity event");
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
// ---------------------------------------------------------------------------
|
|
182
|
-
// Lifecycle
|
|
183
|
-
// ---------------------------------------------------------------------------
|
|
184
|
-
/**
|
|
185
|
-
* Initialize the knowledge graph subsystem.
|
|
186
|
-
*
|
|
187
|
-
* Opens Neo4j, initializes the schema, creates the local embedder,
|
|
188
|
-
* injects it into MCP tools, and subscribes to the event bus for
|
|
189
|
-
* automatic reference node sync.
|
|
190
|
-
*
|
|
191
|
-
* If any step after Neo4j connection fails, cleans up the connection
|
|
192
|
-
* before re-throwing.
|
|
193
|
-
*
|
|
194
|
-
* @returns A cleanup function that closes Neo4j and unsubscribes from events.
|
|
195
|
-
*/
|
|
196
|
-
export async function initKnowledge() {
|
|
197
|
-
logger.info("Initializing knowledge graph subsystem");
|
|
198
|
-
const embedder = createLocalEmbedder();
|
|
199
|
-
await openNeo4j();
|
|
200
|
-
try {
|
|
201
|
-
await initSchema(embedder.dimensions);
|
|
202
|
-
knowledgeEmbedder = embedder;
|
|
203
|
-
const unsubscribe = subscribe(createEntitySyncHandler(embedder));
|
|
204
|
-
logger.info("Knowledge graph subsystem ready");
|
|
205
|
-
return async () => {
|
|
206
|
-
logger.info("Shutting down knowledge graph subsystem");
|
|
207
|
-
unsubscribe();
|
|
208
|
-
knowledgeEmbedder = undefined;
|
|
209
|
-
await closeNeo4j();
|
|
210
|
-
logger.info("Knowledge graph subsystem stopped");
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
catch (err) {
|
|
214
|
-
// Clean up Neo4j if a later step fails
|
|
215
|
-
knowledgeEmbedder = undefined;
|
|
216
|
-
await closeNeo4j().catch(() => { });
|
|
217
|
-
throw err;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
//# sourceMappingURL=knowledge-init.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"knowledge-init.js","sourceRoot":"","sources":["../src/knowledge-init.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,SAAS,EACT,UAAU,EACV,UAAU,EACV,WAAW,IAAI,gBAAgB,EAC/B,mBAAmB,EACnB,iBAAiB,EACjB,2BAA2B,EAC3B,yBAAyB,EACz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