@veedubin/neuralgentics 0.9.1
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/neuralgentics/go-backend-client.d.ts +71 -0
- package/dist/neuralgentics/go-backend-client.d.ts.map +1 -0
- package/dist/neuralgentics/go-backend-client.js +198 -0
- package/dist/neuralgentics/go-backend-client.js.map +1 -0
- package/dist/neuralgentics/index.d.ts +17 -0
- package/dist/neuralgentics/index.d.ts.map +1 -0
- package/dist/neuralgentics/index.js +16 -0
- package/dist/neuralgentics/index.js.map +1 -0
- package/dist/neuralgentics/memory-client.d.ts +68 -0
- package/dist/neuralgentics/memory-client.d.ts.map +1 -0
- package/dist/neuralgentics/memory-client.js +111 -0
- package/dist/neuralgentics/memory-client.js.map +1 -0
- package/dist/neuralgentics/orchestrator.d.ts +63 -0
- package/dist/neuralgentics/orchestrator.d.ts.map +1 -0
- package/dist/neuralgentics/orchestrator.js +154 -0
- package/dist/neuralgentics/orchestrator.js.map +1 -0
- package/dist/neuralgentics/routing.d.ts +34 -0
- package/dist/neuralgentics/routing.d.ts.map +1 -0
- package/dist/neuralgentics/routing.js +88 -0
- package/dist/neuralgentics/routing.js.map +1 -0
- package/dist/neuralgentics/stateless.d.ts +53 -0
- package/dist/neuralgentics/stateless.d.ts.map +1 -0
- package/dist/neuralgentics/stateless.js +83 -0
- package/dist/neuralgentics/stateless.js.map +1 -0
- package/dist/neuralgentics/types.d.ts +68 -0
- package/dist/neuralgentics/types.d.ts.map +1 -0
- package/dist/neuralgentics/types.js +9 -0
- package/dist/neuralgentics/types.js.map +1 -0
- package/dist/neuralgentics/updater.d.ts +23 -0
- package/dist/neuralgentics/updater.d.ts.map +1 -0
- package/dist/neuralgentics/updater.js +47 -0
- package/dist/neuralgentics/updater.js.map +1 -0
- package/dist/server.d.ts +76 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +358 -0
- package/dist/server.js.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GoBackendClient — JSON-RPC 2.0 client over stdio for the Neuralgentics Go backend.
|
|
3
|
+
*
|
|
4
|
+
* Spawns the `neuralgentics-backend` binary as a child process and communicates
|
|
5
|
+
* via newline-delimited JSON-RPC over stdin/stdout. Stderr is inherited so the
|
|
6
|
+
* backend's logs appear in the parent process' console.
|
|
7
|
+
*
|
|
8
|
+
* This replaces the previous HTTP transport to the Python memini-core server,
|
|
9
|
+
* achieving sub-millisecond latency on the same machine with zero port management.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* JSON-RPC 2.0 client that talks to the Go backend over stdio.
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
* ```ts
|
|
16
|
+
* const backend = new GoBackendClient("neuralgentics-backend");
|
|
17
|
+
* await backend.waitForReady();
|
|
18
|
+
* const result = await backend.call("memory.add", { content: "hello" });
|
|
19
|
+
* await backend.shutdown();
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare class GoBackendClient {
|
|
23
|
+
private process;
|
|
24
|
+
private nextId;
|
|
25
|
+
private pending;
|
|
26
|
+
private ready;
|
|
27
|
+
private readyPromise;
|
|
28
|
+
private readyResolve;
|
|
29
|
+
private readyReject;
|
|
30
|
+
/**
|
|
31
|
+
* Spawn the Go backend binary and begin reading its stdout.
|
|
32
|
+
*
|
|
33
|
+
* @param binaryPath - Absolute or relative path to the `neuralgentics-backend` binary.
|
|
34
|
+
* Falls back to $PATH lookup if just the binary name is given.
|
|
35
|
+
*/
|
|
36
|
+
constructor(binaryPath: string);
|
|
37
|
+
/**
|
|
38
|
+
* Wait for the backend to be ready (after first stdout line, which is
|
|
39
|
+
* the {"method":"ready"} notification the backend emits post-init).
|
|
40
|
+
*
|
|
41
|
+
* @param timeoutMs - Maximum time to wait before giving up (default 10 000).
|
|
42
|
+
* If the backend is slow to start (or crashes silently),
|
|
43
|
+
* this prevents the OpenCode plugin from hanging forever.
|
|
44
|
+
* On timeout, the promise rejects so callers can decide
|
|
45
|
+
* whether to abort or continue with a broken backend.
|
|
46
|
+
*/
|
|
47
|
+
waitForReady(timeoutMs?: number): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Send a JSON-RPC request and await the response.
|
|
50
|
+
*
|
|
51
|
+
* @param method - JSON-RPC method name (e.g. "memory.add", "thought.startChain").
|
|
52
|
+
* @param params - Request parameters object.
|
|
53
|
+
* @param timeoutMs - Request timeout in milliseconds (default 30 000).
|
|
54
|
+
* @returns The `result` field of the JSON-RPC response.
|
|
55
|
+
*/
|
|
56
|
+
call(method: string, params?: Record<string, unknown>, timeoutMs?: number): Promise<unknown>;
|
|
57
|
+
/** Shutdown the backend process gracefully. */
|
|
58
|
+
shutdown(): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Handle a single line from the Go backend's stdout.
|
|
61
|
+
*
|
|
62
|
+
* The first valid JSON line marks the backend as ready.
|
|
63
|
+
* Subsequent lines are routed to their pending calls by `id`.
|
|
64
|
+
*/
|
|
65
|
+
private handleLine;
|
|
66
|
+
/** Handle stdout close — reject all pending calls. */
|
|
67
|
+
private handleClose;
|
|
68
|
+
/** Reject every pending call with the same error. */
|
|
69
|
+
private rejectAll;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=go-backend-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"go-backend-client.d.ts","sourceRoot":"","sources":["../../src/neuralgentics/go-backend-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAiCH;;;;;;;;;;GAUG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,OAAO,CAAkC;IACjD,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,YAAY,CAAc;IAClC,OAAO,CAAC,WAAW,CAAwB;IAE3C;;;;;OAKG;gBACS,UAAU,EAAE,MAAM;IAsC9B;;;;;;;;;OASG;IACG,YAAY,CAAC,SAAS,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBrD;;;;;;;OAOG;IACG,IAAI,CACR,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,SAAS,SAAS,GACjB,OAAO,CAAC,OAAO,CAAC;IAgCnB,+CAA+C;IACzC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAS/B;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IAqClB,sDAAsD;IACtD,OAAO,CAAC,WAAW;IAInB,qDAAqD;IACrD,OAAO,CAAC,SAAS;CAOlB"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GoBackendClient — JSON-RPC 2.0 client over stdio for the Neuralgentics Go backend.
|
|
3
|
+
*
|
|
4
|
+
* Spawns the `neuralgentics-backend` binary as a child process and communicates
|
|
5
|
+
* via newline-delimited JSON-RPC over stdin/stdout. Stderr is inherited so the
|
|
6
|
+
* backend's logs appear in the parent process' console.
|
|
7
|
+
*
|
|
8
|
+
* This replaces the previous HTTP transport to the Python memini-core server,
|
|
9
|
+
* achieving sub-millisecond latency on the same machine with zero port management.
|
|
10
|
+
*/
|
|
11
|
+
import { spawn } from "node:child_process";
|
|
12
|
+
import { createInterface } from "node:readline";
|
|
13
|
+
/**
|
|
14
|
+
* Default database URL the Go backend connects to.
|
|
15
|
+
*
|
|
16
|
+
* IMPORTANT: lib/pq (the Go postgres driver) defaults `sslmode` to `require`
|
|
17
|
+
* when no `sslmode` is specified in the connection string. That works against
|
|
18
|
+
* databases with `ssl = on` but fails against databases with `ssl = off`
|
|
19
|
+
* (e.g. the user's prod timescale-pg18 on 5434). The dev test DB on 6000
|
|
20
|
+
* has SSL enabled, so `?sslmode=require` matches the server's capability
|
|
21
|
+
* and lets the migrator + queries succeed without any CA verification.
|
|
22
|
+
*
|
|
23
|
+
* Override at spawn time by setting `NEURALGENTICS_DB_URL` in the parent
|
|
24
|
+
* process's environment before OpenCode launches the plugin.
|
|
25
|
+
*/
|
|
26
|
+
const DEFAULT_DB_URL = "postgresql://postgres:testpassword@localhost:6000/neuralgentics_test?sslmode=require";
|
|
27
|
+
/** Resolve the DB URL — explicit env override wins, otherwise the dev DB. */
|
|
28
|
+
function resolveDbUrl() {
|
|
29
|
+
return process.env.NEURALGENTICS_DB_URL ?? DEFAULT_DB_URL;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* JSON-RPC 2.0 client that talks to the Go backend over stdio.
|
|
33
|
+
*
|
|
34
|
+
* Usage:
|
|
35
|
+
* ```ts
|
|
36
|
+
* const backend = new GoBackendClient("neuralgentics-backend");
|
|
37
|
+
* await backend.waitForReady();
|
|
38
|
+
* const result = await backend.call("memory.add", { content: "hello" });
|
|
39
|
+
* await backend.shutdown();
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export class GoBackendClient {
|
|
43
|
+
process;
|
|
44
|
+
nextId = 1;
|
|
45
|
+
pending = new Map();
|
|
46
|
+
ready = false;
|
|
47
|
+
readyPromise;
|
|
48
|
+
readyResolve;
|
|
49
|
+
readyReject;
|
|
50
|
+
/**
|
|
51
|
+
* Spawn the Go backend binary and begin reading its stdout.
|
|
52
|
+
*
|
|
53
|
+
* @param binaryPath - Absolute or relative path to the `neuralgentics-backend` binary.
|
|
54
|
+
* Falls back to $PATH lookup if just the binary name is given.
|
|
55
|
+
*/
|
|
56
|
+
constructor(binaryPath) {
|
|
57
|
+
// Set NEURALGENTICS_DB_URL so the backend doesn't fall back to its
|
|
58
|
+
// 5434 default (which has no SSL and breaks lib/pq's implicit
|
|
59
|
+
// sslmode=require). Override the env var before launch to point at
|
|
60
|
+
// any database; default is the dev/test DB on 6000 with SSL.
|
|
61
|
+
const childEnv = {
|
|
62
|
+
...process.env,
|
|
63
|
+
NEURALGENTICS_DB_URL: resolveDbUrl(),
|
|
64
|
+
};
|
|
65
|
+
this.process = spawn(binaryPath, [], {
|
|
66
|
+
stdio: ["pipe", "pipe", "inherit"],
|
|
67
|
+
env: childEnv,
|
|
68
|
+
});
|
|
69
|
+
this.readyPromise = new Promise((resolve, reject) => {
|
|
70
|
+
this.readyResolve = resolve;
|
|
71
|
+
this.readyReject = reject;
|
|
72
|
+
});
|
|
73
|
+
// Read stdout line-by-line and route responses to pending calls.
|
|
74
|
+
const rl = createInterface({ input: this.process.stdout });
|
|
75
|
+
rl.on("line", (line) => this.handleLine(line));
|
|
76
|
+
rl.on("close", () => this.handleClose());
|
|
77
|
+
// Detect binary failure to start.
|
|
78
|
+
this.process.on("error", (err) => {
|
|
79
|
+
this.readyReject(err);
|
|
80
|
+
this.rejectAll(err);
|
|
81
|
+
});
|
|
82
|
+
this.process.on("exit", (code) => {
|
|
83
|
+
const error = new Error(`Go backend exited with code ${code ?? "unknown"}`);
|
|
84
|
+
this.rejectAll(error);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Wait for the backend to be ready (after first stdout line, which is
|
|
89
|
+
* the {"method":"ready"} notification the backend emits post-init).
|
|
90
|
+
*
|
|
91
|
+
* @param timeoutMs - Maximum time to wait before giving up (default 10 000).
|
|
92
|
+
* If the backend is slow to start (or crashes silently),
|
|
93
|
+
* this prevents the OpenCode plugin from hanging forever.
|
|
94
|
+
* On timeout, the promise rejects so callers can decide
|
|
95
|
+
* whether to abort or continue with a broken backend.
|
|
96
|
+
*/
|
|
97
|
+
async waitForReady(timeoutMs = 10_000) {
|
|
98
|
+
if (this.ready)
|
|
99
|
+
return;
|
|
100
|
+
await Promise.race([
|
|
101
|
+
this.readyPromise,
|
|
102
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error(`Go backend did not emit 'ready' within ${timeoutMs}ms — it may have crashed or the binary path is wrong`)), timeoutMs)),
|
|
103
|
+
]);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Send a JSON-RPC request and await the response.
|
|
107
|
+
*
|
|
108
|
+
* @param method - JSON-RPC method name (e.g. "memory.add", "thought.startChain").
|
|
109
|
+
* @param params - Request parameters object.
|
|
110
|
+
* @param timeoutMs - Request timeout in milliseconds (default 30 000).
|
|
111
|
+
* @returns The `result` field of the JSON-RPC response.
|
|
112
|
+
*/
|
|
113
|
+
async call(method, params, timeoutMs = 30_000) {
|
|
114
|
+
await this.waitForReady();
|
|
115
|
+
const id = this.nextId++;
|
|
116
|
+
const request = {
|
|
117
|
+
jsonrpc: "2.0",
|
|
118
|
+
id,
|
|
119
|
+
method,
|
|
120
|
+
params: params ?? {},
|
|
121
|
+
};
|
|
122
|
+
const body = JSON.stringify(request) + "\n";
|
|
123
|
+
return new Promise((resolve, reject) => {
|
|
124
|
+
const timer = setTimeout(() => {
|
|
125
|
+
this.pending.delete(id);
|
|
126
|
+
reject(new Error(`JSON-RPC timeout: ${method} after ${timeoutMs}ms`));
|
|
127
|
+
}, timeoutMs);
|
|
128
|
+
this.pending.set(id, { resolve, reject, timer });
|
|
129
|
+
this.process.stdin.write(body, (err) => {
|
|
130
|
+
if (err) {
|
|
131
|
+
clearTimeout(timer);
|
|
132
|
+
this.pending.delete(id);
|
|
133
|
+
reject(new Error(`Failed to write JSON-RPC request: ${err.message}`));
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
/** Shutdown the backend process gracefully. */
|
|
139
|
+
async shutdown() {
|
|
140
|
+
try {
|
|
141
|
+
await this.call("shutdown", {});
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
// Ignore errors during shutdown — the process may already be exiting.
|
|
145
|
+
}
|
|
146
|
+
this.process.kill();
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Handle a single line from the Go backend's stdout.
|
|
150
|
+
*
|
|
151
|
+
* The first valid JSON line marks the backend as ready.
|
|
152
|
+
* Subsequent lines are routed to their pending calls by `id`.
|
|
153
|
+
*/
|
|
154
|
+
handleLine(line) {
|
|
155
|
+
// On first line, mark ready (the backend has finished initialisation).
|
|
156
|
+
if (!this.ready) {
|
|
157
|
+
this.ready = true;
|
|
158
|
+
this.readyResolve();
|
|
159
|
+
}
|
|
160
|
+
let response;
|
|
161
|
+
try {
|
|
162
|
+
response = JSON.parse(line);
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
// Skip malformed / non-JSON lines (e.g. debug output).
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
// Ignore notifications (no id).
|
|
169
|
+
if (response.id == null)
|
|
170
|
+
return;
|
|
171
|
+
const id = response.id;
|
|
172
|
+
const pending = this.pending.get(id);
|
|
173
|
+
if (!pending)
|
|
174
|
+
return;
|
|
175
|
+
this.pending.delete(id);
|
|
176
|
+
clearTimeout(pending.timer);
|
|
177
|
+
if (response.error != null) {
|
|
178
|
+
const err = response.error;
|
|
179
|
+
pending.reject(new Error(`JSON-RPC error ${err.code ?? "unknown"}: ${err.message ?? "unknown error"}`));
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
pending.resolve(response.result);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/** Handle stdout close — reject all pending calls. */
|
|
186
|
+
handleClose() {
|
|
187
|
+
this.rejectAll(new Error("Go backend stdout closed"));
|
|
188
|
+
}
|
|
189
|
+
/** Reject every pending call with the same error. */
|
|
190
|
+
rejectAll(reason) {
|
|
191
|
+
for (const [id, pending] of this.pending.entries()) {
|
|
192
|
+
clearTimeout(pending.timer);
|
|
193
|
+
pending.reject(reason);
|
|
194
|
+
this.pending.delete(id);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=go-backend-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"go-backend-client.js","sourceRoot":"","sources":["../../src/neuralgentics/go-backend-client.ts"],"names":[],"mappings":"A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I,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;YACnD,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YAC5B,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACvB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Neuralgentics overlay — public API surface.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports every module so consumers can import from a single entry point:
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { NeuralgenticsOrchestrator, GoBackendClient, ROUTING_MATRIX } from "./neuralgentics";
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
export { NeuralgenticsOrchestrator } from "./orchestrator.js";
|
|
11
|
+
export { MemoryClient } from "./memory-client.js";
|
|
12
|
+
export { GoBackendClient } from "./go-backend-client.js";
|
|
13
|
+
export { ROUTING_MATRIX, validateAgentRouting, getPrimaryAgent } from "./routing.js";
|
|
14
|
+
export { StatelessProtocol } from "./stateless.js";
|
|
15
|
+
export { NeuralgenticsUpdater } from "./updater.js";
|
|
16
|
+
export type { AgentDefinition, RoutingRule, ContextPackage, MemoryRecord, ServerCatalogEntry, ToolMatch, } from "./types.js";
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/neuralgentics/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,YAAY,EACV,eAAe,EACf,WAAW,EACX,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,SAAS,GACV,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Neuralgentics overlay — public API surface.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports every module so consumers can import from a single entry point:
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* import { NeuralgenticsOrchestrator, GoBackendClient, ROUTING_MATRIX } from "./neuralgentics";
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
export { NeuralgenticsOrchestrator } from "./orchestrator.js";
|
|
11
|
+
export { MemoryClient } from "./memory-client.js";
|
|
12
|
+
export { GoBackendClient } from "./go-backend-client.js";
|
|
13
|
+
export { ROUTING_MATRIX, validateAgentRouting, getPrimaryAgent } from "./routing.js";
|
|
14
|
+
export { StatelessProtocol } from "./stateless.js";
|
|
15
|
+
export { NeuralgenticsUpdater } from "./updater.js";
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/neuralgentics/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Neuralgentics Memory Client — thin wrapper over GoBackendClient.
|
|
3
|
+
*
|
|
4
|
+
* Routes all memory and thought-chain operations through the Go backend
|
|
5
|
+
* via JSON-RPC over stdio (child process). This replaces the previous
|
|
6
|
+
* HTTP transport to the Python memini-core server, achieving sub-millisecond
|
|
7
|
+
* latency on the same machine with zero port management.
|
|
8
|
+
*
|
|
9
|
+
* The underlying `GoBackendClient` spawns the `neuralgentics-backend` binary
|
|
10
|
+
* and communicates via newline-delimited JSON-RPC 2.0.
|
|
11
|
+
*/
|
|
12
|
+
import type { MemoryRecord } from "./types.js";
|
|
13
|
+
import { GoBackendClient } from "./go-backend-client.js";
|
|
14
|
+
/**
|
|
15
|
+
* High-level client for Neuralgentics memory operations.
|
|
16
|
+
*
|
|
17
|
+
* Delegates to a `GoBackendClient` instance that talks to the Go backend
|
|
18
|
+
* over stdio. Consumers can supply their own `GoBackendClient` instance
|
|
19
|
+
* (useful for testing with a mock) or let this class create one
|
|
20
|
+
* automatically.
|
|
21
|
+
*/
|
|
22
|
+
export declare class MemoryClient {
|
|
23
|
+
private backend;
|
|
24
|
+
/**
|
|
25
|
+
* Create a new MemoryClient.
|
|
26
|
+
*
|
|
27
|
+
* @param backendOrPath - One of:
|
|
28
|
+
* - A `GoBackendClient` instance (typically a mock in tests).
|
|
29
|
+
* - A string path to the `neuralgentics-backend` binary.
|
|
30
|
+
* - `undefined` to auto-resolve from `NEURALGENTICS_BACKEND_PATH` env
|
|
31
|
+
* or fall back to `"neuralgentics-backend"` (looked up on $PATH).
|
|
32
|
+
*/
|
|
33
|
+
constructor(backendOrPath?: GoBackendClient | string);
|
|
34
|
+
/**
|
|
35
|
+
* Store a new memory entry via the Go backend.
|
|
36
|
+
*
|
|
37
|
+
* @param content - The memory text to store.
|
|
38
|
+
* @param metadata - Optional key-value metadata attached to the memory.
|
|
39
|
+
* @returns The ID of the newly created memory record.
|
|
40
|
+
*/
|
|
41
|
+
addMemory(content: string, metadata?: Record<string, unknown>): Promise<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Query memories via semantic search through the Go backend.
|
|
44
|
+
*
|
|
45
|
+
* @param query - Natural-language search string.
|
|
46
|
+
* @param limit - Maximum number of results to return (default 10).
|
|
47
|
+
* @returns An array of matching memory records.
|
|
48
|
+
*/
|
|
49
|
+
queryMemories(query: string, limit?: number): Promise<MemoryRecord[]>;
|
|
50
|
+
/**
|
|
51
|
+
* Add a thought to an existing (or new) thought chain.
|
|
52
|
+
*
|
|
53
|
+
* @param thought - The thought text.
|
|
54
|
+
* @param thoughtNumber - 1-based index of this thought within the chain.
|
|
55
|
+
* @param totalThoughts - Expected total number of thoughts.
|
|
56
|
+
* @param nextThoughtNeeded - Whether more thoughts follow after this one.
|
|
57
|
+
* @param chainId - Existing chain UUID to continue, or undefined to auto-create.
|
|
58
|
+
* @returns The chain ID (useful when auto-creating).
|
|
59
|
+
*/
|
|
60
|
+
addThought(thought: string, thoughtNumber: number, totalThoughts: number, nextThoughtNeeded: boolean, chainId?: string): Promise<string>;
|
|
61
|
+
/**
|
|
62
|
+
* Start a new thought chain and return its UUID.
|
|
63
|
+
*
|
|
64
|
+
* @returns The UUID of the newly created thought chain.
|
|
65
|
+
*/
|
|
66
|
+
startThoughtChain(): Promise<string>;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=memory-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-client.d.ts","sourceRoot":"","sources":["../../src/neuralgentics/memory-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAUzD;;;;;;;GAOG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAkB;IAEjC;;;;;;;;OAQG;gBACS,aAAa,CAAC,EAAE,eAAe,GAAG,MAAM;IAapD;;;;;;OAMG;IACG,SAAS,CACb,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,OAAO,CAAC,MAAM,CAAC;IAQlB;;;;;;OAMG;IACG,aAAa,CACjB,KAAK,EAAE,MAAM,EACb,KAAK,GAAE,MAAW,GACjB,OAAO,CAAC,YAAY,EAAE,CAAC;IAU1B;;;;;;;;;OASG;IACG,UAAU,CACd,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,EACrB,iBAAiB,EAAE,OAAO,EAC1B,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC;IAkBlB;;;;OAIG;IACG,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;CAM3C"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Neuralgentics Memory Client — thin wrapper over GoBackendClient.
|
|
3
|
+
*
|
|
4
|
+
* Routes all memory and thought-chain operations through the Go backend
|
|
5
|
+
* via JSON-RPC over stdio (child process). This replaces the previous
|
|
6
|
+
* HTTP transport to the Python memini-core server, achieving sub-millisecond
|
|
7
|
+
* latency on the same machine with zero port management.
|
|
8
|
+
*
|
|
9
|
+
* The underlying `GoBackendClient` spawns the `neuralgentics-backend` binary
|
|
10
|
+
* and communicates via newline-delimited JSON-RPC 2.0.
|
|
11
|
+
*/
|
|
12
|
+
import { GoBackendClient } from "./go-backend-client.js";
|
|
13
|
+
/** Resolve the Go backend binary path from env var or fallback. */
|
|
14
|
+
function resolveBinaryPath() {
|
|
15
|
+
if (process.env.NEURALGENTICS_BACKEND_PATH) {
|
|
16
|
+
return process.env.NEURALGENTICS_BACKEND_PATH;
|
|
17
|
+
}
|
|
18
|
+
return "neuralgentics-backend";
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* High-level client for Neuralgentics memory operations.
|
|
22
|
+
*
|
|
23
|
+
* Delegates to a `GoBackendClient` instance that talks to the Go backend
|
|
24
|
+
* over stdio. Consumers can supply their own `GoBackendClient` instance
|
|
25
|
+
* (useful for testing with a mock) or let this class create one
|
|
26
|
+
* automatically.
|
|
27
|
+
*/
|
|
28
|
+
export class MemoryClient {
|
|
29
|
+
backend;
|
|
30
|
+
/**
|
|
31
|
+
* Create a new MemoryClient.
|
|
32
|
+
*
|
|
33
|
+
* @param backendOrPath - One of:
|
|
34
|
+
* - A `GoBackendClient` instance (typically a mock in tests).
|
|
35
|
+
* - A string path to the `neuralgentics-backend` binary.
|
|
36
|
+
* - `undefined` to auto-resolve from `NEURALGENTICS_BACKEND_PATH` env
|
|
37
|
+
* or fall back to `"neuralgentics-backend"` (looked up on $PATH).
|
|
38
|
+
*/
|
|
39
|
+
constructor(backendOrPath) {
|
|
40
|
+
if (backendOrPath instanceof GoBackendClient) {
|
|
41
|
+
this.backend = backendOrPath;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
const path = backendOrPath ?? resolveBinaryPath();
|
|
45
|
+
this.backend = new GoBackendClient(path);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// ---------------------------------------------------------------
|
|
49
|
+
// Memory operations
|
|
50
|
+
// ---------------------------------------------------------------
|
|
51
|
+
/**
|
|
52
|
+
* Store a new memory entry via the Go backend.
|
|
53
|
+
*
|
|
54
|
+
* @param content - The memory text to store.
|
|
55
|
+
* @param metadata - Optional key-value metadata attached to the memory.
|
|
56
|
+
* @returns The ID of the newly created memory record.
|
|
57
|
+
*/
|
|
58
|
+
async addMemory(content, metadata) {
|
|
59
|
+
const result = (await this.backend.call("memory.add", {
|
|
60
|
+
content,
|
|
61
|
+
metadata,
|
|
62
|
+
}));
|
|
63
|
+
return result.id;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Query memories via semantic search through the Go backend.
|
|
67
|
+
*
|
|
68
|
+
* @param query - Natural-language search string.
|
|
69
|
+
* @param limit - Maximum number of results to return (default 10).
|
|
70
|
+
* @returns An array of matching memory records.
|
|
71
|
+
*/
|
|
72
|
+
async queryMemories(query, limit = 10) {
|
|
73
|
+
return this.backend.call("memory.query", { query, limit });
|
|
74
|
+
}
|
|
75
|
+
// ---------------------------------------------------------------
|
|
76
|
+
// Thought-chain operations
|
|
77
|
+
// ---------------------------------------------------------------
|
|
78
|
+
/**
|
|
79
|
+
* Add a thought to an existing (or new) thought chain.
|
|
80
|
+
*
|
|
81
|
+
* @param thought - The thought text.
|
|
82
|
+
* @param thoughtNumber - 1-based index of this thought within the chain.
|
|
83
|
+
* @param totalThoughts - Expected total number of thoughts.
|
|
84
|
+
* @param nextThoughtNeeded - Whether more thoughts follow after this one.
|
|
85
|
+
* @param chainId - Existing chain UUID to continue, or undefined to auto-create.
|
|
86
|
+
* @returns The chain ID (useful when auto-creating).
|
|
87
|
+
*/
|
|
88
|
+
async addThought(thought, thoughtNumber, totalThoughts, nextThoughtNeeded, chainId) {
|
|
89
|
+
const params = {
|
|
90
|
+
thought,
|
|
91
|
+
thoughtNumber,
|
|
92
|
+
totalThoughts,
|
|
93
|
+
nextThoughtNeeded,
|
|
94
|
+
};
|
|
95
|
+
if (chainId !== undefined) {
|
|
96
|
+
params.chainId = chainId;
|
|
97
|
+
}
|
|
98
|
+
const result = (await this.backend.call("thought.add", params));
|
|
99
|
+
return result.chainId;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Start a new thought chain and return its UUID.
|
|
103
|
+
*
|
|
104
|
+
* @returns The UUID of the newly created thought chain.
|
|
105
|
+
*/
|
|
106
|
+
async startThoughtChain() {
|
|
107
|
+
const result = (await this.backend.call("thought.startChain", {}));
|
|
108
|
+
return result.chainId;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=memory-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-client.js","sourceRoot":"","sources":["../../src/neuralgent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B,aAAqB,EACrB,iBAA0B,EAC1B,OAAgB;QAEhB,MAAM,MAAM,GAA4B;YACtC,OAAO;YACP,aAAa;YACb,aAAa;YACb,iBAAiB;SAClB,CAAC;QACF,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;QAC3B,CAAC;QAED,MAAM,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CACrC,aAAa,EACb,MAAM,CACP,CAAwB,CAAC;QAC1B,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,iBAAiB;QACrB,MAAM,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAEhE,CAAC;QACF,OAAO,MAAM,CAAC,OAAO,CAAC;IACxB,CAAC;CACF"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Neuralgentics Orchestrator — main hook into OpenCode's agent lifecycle.
|
|
3
|
+
*
|
|
4
|
+
* The orchestrator injects identity strings into system prompts, validates
|
|
5
|
+
* routing decisions against the mandatory matrix, and exposes the list of
|
|
6
|
+
* available Neuralgentics agents.
|
|
7
|
+
*
|
|
8
|
+
* The orchestrator now communicates with the Go backend via JSON-RPC over
|
|
9
|
+
* stdio (GoBackendClient), replacing the previous HTTP transport to the
|
|
10
|
+
* Python memini-core server.
|
|
11
|
+
*/
|
|
12
|
+
import type { AgentDefinition } from "./types.js";
|
|
13
|
+
import { GoBackendClient } from "./go-backend-client.js";
|
|
14
|
+
/**
|
|
15
|
+
* The main orchestrator class for Neuralgentics within OpenCode.
|
|
16
|
+
*
|
|
17
|
+
* Provides three core hooks:
|
|
18
|
+
* 1. **injectSystemPrompt** — appends Neuralgentics identity to agent prompts.
|
|
19
|
+
* 2. **validateRouting** — enforces the mandatory routing matrix.
|
|
20
|
+
* 3. **getAgentList** — returns the full roster of Neuralgentics agents.
|
|
21
|
+
*/
|
|
22
|
+
export declare class NeuralgenticsOrchestrator {
|
|
23
|
+
private routing;
|
|
24
|
+
private stateless;
|
|
25
|
+
private memoryClient;
|
|
26
|
+
/**
|
|
27
|
+
* Create a new NeuralgenticsOrchestrator.
|
|
28
|
+
*
|
|
29
|
+
* @param backend - One of:
|
|
30
|
+
* - A `GoBackendClient` instance (useful for testing with a mock).
|
|
31
|
+
* - A string path to the `neuralgentics-backend` binary.
|
|
32
|
+
* - `undefined` to auto-resolve from env / $PATH.
|
|
33
|
+
*/
|
|
34
|
+
constructor(backend?: GoBackendClient | string);
|
|
35
|
+
/**
|
|
36
|
+
* Inject the Neuralgentics identity string into an agent's system prompt.
|
|
37
|
+
*
|
|
38
|
+
* The identity string is appended to the existing system prompt array.
|
|
39
|
+
*
|
|
40
|
+
* @param system - The mutable system prompt array to modify in-place.
|
|
41
|
+
* @param _agent - The agent configuration (reserved for future use).
|
|
42
|
+
* @param _session - The active session object (reserved for future use).
|
|
43
|
+
*/
|
|
44
|
+
injectSystemPrompt(system: string[], _agent: unknown, _session?: unknown): void;
|
|
45
|
+
/**
|
|
46
|
+
* Validate that a proposed agent assignment conforms to the routing matrix.
|
|
47
|
+
*
|
|
48
|
+
* @param params - Object containing the subagent type and optional parent/tasks.
|
|
49
|
+
* @returns An error string if routing is violated, or `undefined` if valid.
|
|
50
|
+
*/
|
|
51
|
+
validateRouting(params: {
|
|
52
|
+
subagentType: string;
|
|
53
|
+
parentAgent?: string;
|
|
54
|
+
tasks?: unknown[];
|
|
55
|
+
}): string | void;
|
|
56
|
+
/**
|
|
57
|
+
* Return the full list of Neuralgentics agent definitions.
|
|
58
|
+
*
|
|
59
|
+
* @returns An array of AgentDefinition objects.
|
|
60
|
+
*/
|
|
61
|
+
getAgentList(): AgentDefinition[];
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=orchestrator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrator.d.ts","sourceRoot":"","sources":["../../src/neuralgentics/orchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,YAAY,CAAC;AAG/D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AA0EzD;;;;;;;GAOG;AACH,qBAAa,yBAAyB;IACpC,OAAO,CAAC,OAAO,CAAwB;IACvC,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,YAAY,CAAe;IAEnC;;;;;;;OAOG;gBACS,OAAO,CAAC,EAAE,eAAe,GAAG,MAAM;IAM9C;;;;;;;;OAQG;IACH,kBAAkB,CAChB,MAAM,EAAE,MAAM,EAAE,EAChB,MAAM,EAAE,OAAO,EACf,QAAQ,CAAC,EAAE,OAAO,GACjB,IAAI;IAIP;;;;;OAKG;IACH,eAAe,CAAC,MAAM,EAAE;QACtB,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;KACnB,GAAG,MAAM,GAAG,IAAI;IAuBjB;;;;OAIG;IACH,YAAY,IAAI,eAAe,EAAE;CAGlC"}
|