@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.
Files changed (37) hide show
  1. package/dist/neuralgentics/go-backend-client.d.ts +71 -0
  2. package/dist/neuralgentics/go-backend-client.d.ts.map +1 -0
  3. package/dist/neuralgentics/go-backend-client.js +198 -0
  4. package/dist/neuralgentics/go-backend-client.js.map +1 -0
  5. package/dist/neuralgentics/index.d.ts +17 -0
  6. package/dist/neuralgentics/index.d.ts.map +1 -0
  7. package/dist/neuralgentics/index.js +16 -0
  8. package/dist/neuralgentics/index.js.map +1 -0
  9. package/dist/neuralgentics/memory-client.d.ts +68 -0
  10. package/dist/neuralgentics/memory-client.d.ts.map +1 -0
  11. package/dist/neuralgentics/memory-client.js +111 -0
  12. package/dist/neuralgentics/memory-client.js.map +1 -0
  13. package/dist/neuralgentics/orchestrator.d.ts +63 -0
  14. package/dist/neuralgentics/orchestrator.d.ts.map +1 -0
  15. package/dist/neuralgentics/orchestrator.js +154 -0
  16. package/dist/neuralgentics/orchestrator.js.map +1 -0
  17. package/dist/neuralgentics/routing.d.ts +34 -0
  18. package/dist/neuralgentics/routing.d.ts.map +1 -0
  19. package/dist/neuralgentics/routing.js +88 -0
  20. package/dist/neuralgentics/routing.js.map +1 -0
  21. package/dist/neuralgentics/stateless.d.ts +53 -0
  22. package/dist/neuralgentics/stateless.d.ts.map +1 -0
  23. package/dist/neuralgentics/stateless.js +83 -0
  24. package/dist/neuralgentics/stateless.js.map +1 -0
  25. package/dist/neuralgentics/types.d.ts +68 -0
  26. package/dist/neuralgentics/types.d.ts.map +1 -0
  27. package/dist/neuralgentics/types.js +9 -0
  28. package/dist/neuralgentics/types.js.map +1 -0
  29. package/dist/neuralgentics/updater.d.ts +23 -0
  30. package/dist/neuralgentics/updater.d.ts.map +1 -0
  31. package/dist/neuralgentics/updater.js +47 -0
  32. package/dist/neuralgentics/updater.js.map +1 -0
  33. package/dist/server.d.ts +76 -0
  34. package/dist/server.d.ts.map +1 -0
  35. package/dist/server.js +358 -0
  36. package/dist/server.js.map +1 -0
  37. package/package.json +69 -0
@@ -0,0 +1,154 @@
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 { ROUTING_MATRIX, validateAgentRouting } from "./routing.js";
13
+ import { MemoryClient } from "./memory-client.js";
14
+ import { StatelessProtocol } from "./stateless.js";
15
+ /**
16
+ * Identity string injected into every agent's system prompt.
17
+ */
18
+ const NEURALGENTICS_IDENTITY = "You are Neuralgentics, powered by OpenCode. Follow the Neuralgentics Stateless Agent Protocol. All tasks MUST go through the routing matrix.";
19
+ /**
20
+ * The canonical Neuralgentics agent roster.
21
+ *
22
+ * Each entry matches the routing matrix so that the orchestrator can
23
+ * look up agent capabilities and dispatch tasks correctly.
24
+ */
25
+ const AGENT_DEFINITIONS = [
26
+ {
27
+ name: "neuralgentics-coder",
28
+ description: "Fast code generation and bug-fix agent.",
29
+ model: "glm-5.1:cloud",
30
+ mode: "subagent",
31
+ steps: 50,
32
+ },
33
+ {
34
+ name: "neuralgentics-architect",
35
+ description: "Design decisions and architecture review agent.",
36
+ model: "deepseek-v4-pro:cloud",
37
+ mode: "subagent",
38
+ steps: 100,
39
+ },
40
+ {
41
+ name: "neuralgentics-explorer",
42
+ description: "Codebase exploration and file-finding agent.",
43
+ model: "devstral-2:123b-cloud",
44
+ mode: "subagent",
45
+ steps: 30,
46
+ },
47
+ {
48
+ name: "neuralgentics-tester",
49
+ description: "Test writing and execution agent.",
50
+ model: "deepseek-v4-flash:cloud",
51
+ mode: "subagent",
52
+ steps: 50,
53
+ },
54
+ {
55
+ name: "neuralgentics-linter",
56
+ description: "Linting, formatting, and style enforcement agent.",
57
+ model: "qwen3-coder-next:cloud",
58
+ mode: "subagent",
59
+ steps: 30,
60
+ },
61
+ {
62
+ name: "neuralgentics-git",
63
+ description: "Version control and git operations agent.",
64
+ model: "minimax-m2.7:cloud",
65
+ mode: "subagent",
66
+ steps: 30,
67
+ },
68
+ {
69
+ name: "neuralgentics-writer",
70
+ description: "Documentation and Markdown writing agent.",
71
+ model: "gemma4:31b-cloud",
72
+ mode: "subagent",
73
+ steps: 50,
74
+ },
75
+ {
76
+ name: "neuralgentics-researcher",
77
+ description: "Web research and data extraction agent.",
78
+ model: "kimi-k2.6:cloud",
79
+ mode: "subagent",
80
+ steps: 50,
81
+ },
82
+ ];
83
+ /**
84
+ * The main orchestrator class for Neuralgentics within OpenCode.
85
+ *
86
+ * Provides three core hooks:
87
+ * 1. **injectSystemPrompt** — appends Neuralgentics identity to agent prompts.
88
+ * 2. **validateRouting** — enforces the mandatory routing matrix.
89
+ * 3. **getAgentList** — returns the full roster of Neuralgentics agents.
90
+ */
91
+ export class NeuralgenticsOrchestrator {
92
+ routing;
93
+ stateless;
94
+ memoryClient;
95
+ /**
96
+ * Create a new NeuralgenticsOrchestrator.
97
+ *
98
+ * @param backend - One of:
99
+ * - A `GoBackendClient` instance (useful for testing with a mock).
100
+ * - A string path to the `neuralgentics-backend` binary.
101
+ * - `undefined` to auto-resolve from env / $PATH.
102
+ */
103
+ constructor(backend) {
104
+ this.memoryClient = new MemoryClient(backend);
105
+ this.stateless = new StatelessProtocol(this.memoryClient);
106
+ this.routing = ROUTING_MATRIX;
107
+ }
108
+ /**
109
+ * Inject the Neuralgentics identity string into an agent's system prompt.
110
+ *
111
+ * The identity string is appended to the existing system prompt array.
112
+ *
113
+ * @param system - The mutable system prompt array to modify in-place.
114
+ * @param _agent - The agent configuration (reserved for future use).
115
+ * @param _session - The active session object (reserved for future use).
116
+ */
117
+ injectSystemPrompt(system, _agent, _session) {
118
+ system.push(NEURALGENTICS_IDENTITY);
119
+ }
120
+ /**
121
+ * Validate that a proposed agent assignment conforms to the routing matrix.
122
+ *
123
+ * @param params - Object containing the subagent type and optional parent/tasks.
124
+ * @returns An error string if routing is violated, or `undefined` if valid.
125
+ */
126
+ validateRouting(params) {
127
+ const { subagentType } = params;
128
+ const taskType = subagentType;
129
+ // Check against every routing rule for the "never" list.
130
+ for (const [type, rule] of Object.entries(this.routing)) {
131
+ if (rule.never.includes(subagentType)) {
132
+ const result = validateAgentRouting(type, subagentType);
133
+ if (!result.valid) {
134
+ return result.reason;
135
+ }
136
+ }
137
+ }
138
+ // Also validate that the specific task type is known.
139
+ const result = validateAgentRouting(taskType, subagentType);
140
+ if (!result.valid) {
141
+ return result.reason;
142
+ }
143
+ return undefined;
144
+ }
145
+ /**
146
+ * Return the full list of Neuralgentics agent definitions.
147
+ *
148
+ * @returns An array of AgentDefinition objects.
149
+ */
150
+ getAgentList() {
151
+ return [...AGENT_DEFINITIONS];
152
+ }
153
+ }
154
+ //# sourceMappingURL=orchestrator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestrator.js","sourceRoot":"","sources":["../../src/neuralgentics/orchestrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;GAEG;AACH,MAAM,sBAAsB,GAC1B,8IAA8I,CAAC;AAEjJ;;;;;GAKG;AACH,MAAM,iBAAiB,GAAsB;IAC3C;QACE,IAAI,EAAE,qBAAqB;QAC3B,WAAW,EAAE,yCAAyC;QACtD,KAAK,EAAE,eAAe;QACtB,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,EAAE;KACV;IACD;QACE,IAAI,EAAE,yBAAyB;QAC/B,WAAW,EAAE,iDAA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,OAAO,GAAG,cAAc,CAAC;IAChC,CAAC;IAED;;;;;;;;OAQG;IACH,kBAAkB,CAChB,MAAgB,EAChB,MAAe,EACf,QAAkB;QAElB,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IACtC,CAAC;IAED;;;;;OAKG;IACH,eAAe,CAAC,MAIf;QACC,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;QAChC,MAAM,QAAQ,GAAG,YAAY,CAAC;QAE9B,yDAAyD;QACzD,KAAK,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAA4B,EAAE,CAAC;YACnF,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;gBACtC,MAAM,MAAM,GAAG,oBAAoB,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;gBACxD,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;oBAClB,OAAO,MAAM,CAAC,MAAM,CAAC;gBACvB,CAAC;YACH,CAAC;QACH,CAAC;QAED,sDAAsD;QACtD,MAAM,MAAM,GAAG,oBAAoB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QAC5D,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAClB,OAAO,MAAM,CAAC,MAAM,CAAC;QACvB,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACH,YAAY;QACV,OAAO,CAAC,GAAG,iBAAiB,CAAC,CAAC;IAChC,CAAC;CACF"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Neuralgentics Routing Matrix — mandatory task-to-agent assignment rules.
3
+ *
4
+ * Every task dispatched by the orchestrator MUST pass through this matrix.
5
+ * Violations result in a rejected routing with a descriptive reason.
6
+ */
7
+ import type { RoutingRule } from "./types.js";
8
+ /**
9
+ * The canonical routing matrix.
10
+ *
11
+ * Keys are task-type identifiers. Each entry names the **primary** agent
12
+ * that MUST handle that task type, plus a list of agents that MUST NOT
13
+ * be assigned to it.
14
+ */
15
+ export declare const ROUTING_MATRIX: Record<string, RoutingRule>;
16
+ /**
17
+ * Validate whether an agent assignment conforms to the routing matrix.
18
+ *
19
+ * @param taskType - The task-type identifier (must match a key in ROUTING_MATRIX).
20
+ * @param agentName - The agent being considered for the task.
21
+ * @returns An object with `valid: true`, or `valid: false` plus a `reason` string.
22
+ */
23
+ export declare function validateAgentRouting(taskType: string, agentName: string): {
24
+ valid: boolean;
25
+ reason?: string;
26
+ };
27
+ /**
28
+ * Look up the primary agent for a task type.
29
+ *
30
+ * @param taskType - The task-type identifier.
31
+ * @returns The primary agent name, or `undefined` if no rule exists.
32
+ */
33
+ export declare function getPrimaryAgent(taskType: string): string | undefined;
34
+ //# sourceMappingURL=routing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/neuralgentics/routing.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAiCtD,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CA4BrC;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEpE"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Neuralgentics Routing Matrix — mandatory task-to-agent assignment rules.
3
+ *
4
+ * Every task dispatched by the orchestrator MUST pass through this matrix.
5
+ * Violations result in a rejected routing with a descriptive reason.
6
+ */
7
+ /**
8
+ * The canonical routing matrix.
9
+ *
10
+ * Keys are task-type identifiers. Each entry names the **primary** agent
11
+ * that MUST handle that task type, plus a list of agents that MUST NOT
12
+ * be assigned to it.
13
+ */
14
+ export const ROUTING_MATRIX = {
15
+ "code-implementation": {
16
+ primary: "neuralgentics-coder",
17
+ never: ["general", "neuralgentics-explorer"],
18
+ },
19
+ "architecture-design": {
20
+ primary: "neuralgentics-architect",
21
+ never: ["general", "neuralgentics-coder"],
22
+ },
23
+ testing: {
24
+ primary: "neuralgentics-tester",
25
+ never: ["general", "neuralgentics-coder"],
26
+ },
27
+ "file-finding": {
28
+ primary: "neuralgentics-explorer",
29
+ never: ["general", "neuralgentics-architect"],
30
+ },
31
+ linting: {
32
+ primary: "neuralgentics-linter",
33
+ never: [],
34
+ },
35
+ "git-operations": {
36
+ primary: "neuralgentics-git",
37
+ never: [],
38
+ },
39
+ documentation: {
40
+ primary: "neuralgentics-writer",
41
+ never: [],
42
+ },
43
+ "web-research": {
44
+ primary: "neuralgentics-researcher",
45
+ never: [],
46
+ },
47
+ };
48
+ /**
49
+ * Validate whether an agent assignment conforms to the routing matrix.
50
+ *
51
+ * @param taskType - The task-type identifier (must match a key in ROUTING_MATRIX).
52
+ * @param agentName - The agent being considered for the task.
53
+ * @returns An object with `valid: true`, or `valid: false` plus a `reason` string.
54
+ */
55
+ export function validateAgentRouting(taskType, agentName) {
56
+ const rule = ROUTING_MATRIX[taskType];
57
+ if (!rule) {
58
+ return {
59
+ valid: false,
60
+ reason: `Unknown task type: "${taskType}". No routing rule defined.`,
61
+ };
62
+ }
63
+ if (rule.never.includes(agentName)) {
64
+ return {
65
+ valid: false,
66
+ reason: `Agent "${agentName}" is forbidden for task type "${taskType}".`,
67
+ };
68
+ }
69
+ if (agentName !== rule.primary && rule.never.length === 0) {
70
+ // Permissive: any agent is allowed when there are no "never" restrictions.
71
+ return { valid: true };
72
+ }
73
+ if (agentName === rule.primary) {
74
+ return { valid: true };
75
+ }
76
+ // Not the primary, but not in the never-list either — allowed with a caveat.
77
+ return { valid: true };
78
+ }
79
+ /**
80
+ * Look up the primary agent for a task type.
81
+ *
82
+ * @param taskType - The task-type identifier.
83
+ * @returns The primary agent name, or `undefined` if no rule exists.
84
+ */
85
+ export function getPrimaryAgent(taskType) {
86
+ return ROUTING_MATRIX[taskType]?.primary;
87
+ }
88
+ //# sourceMappingURL=routing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/neuralgentics/routing.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAgC;IACzD,qBAAqB,EAAE;QACrB,OAAO,EAAE,qBAAqB;QAC9B,KAAK,EAAE,CAAC,SAAS,EAAE,wBAAwB,CAAC;KAC7C;IACD,qBAAqB,EAAE;QACrB,OAAO,EAAE,yBAAyB;QAClC,KAAK,EAAE,CAAC,SAAS,EAAE,qBAAqB,CAAC;KAC1C;IACD,OAAO,EAAE;QACP,OAAO,EAAE,sBAAsB;QAC/B,KAAK,EAAE,CAAC,SAAS,EAAE,qBAAqB,CAAC;KAC1C;IACD,cAAc,EAAE;QACd,OAAO,EAAE,wBAAwB;QACjC,KAAK,EAAE,CAAC,SAAS,EAAE,yBAAyB,CAAC;KAC9C;IACD,OAAO,EAAE;QACP,OAAO,EAAE,sBAAsB;QAC/B,KAAK,EAAE,EAAE;KACV;IACD,gBAAgB,EAAE;QAChB,OAAO,EAAE,mBAAmB;QAC5B,KAAK,EAAE,EAAE;KACV;IACD,aAAa,EAAE;QACb,OAAO,EAAE,sBAAsB;QAC/B,KAAK,EAAE,EAAE;KACV;IACD,cAAc,EAAE;QACd,OAAO,EAAE,0BAA0B;QACnC,KAAK,EAAE,EAAE;KACV;CACF,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAClC,QAAgB,EAChB,SAAiB;IAEjB,MAAM,IAAI,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC;IAEtC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,uBAAuB,QAAQ,6BAA6B;SACrE,CAAC;IACJ,CAAC;IAED,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QACnC,OAAO;YACL,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,UAAU,SAAS,iCAAiC,QAAQ,IAAI;SACzE,CAAC;IACJ,CAAC;IAED,IAAI,SAAS,KAAK,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1D,2EAA2E;QAC3E,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACzB,CAAC;IAED,IAAI,SAAS,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;QAC/B,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IACzB,CAAC;IAED,6EAA6E;IAC7E,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AACzB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,OAAO,cAAc,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Neuralgentics Stateless Agent Protocol.
3
+ *
4
+ * Each agent invocation is fully self-contained. The protocol prepares
5
+ * a context package (storing it in memini-core) and returns a thin
6
+ * reference that the agent can use to pull full context at runtime.
7
+ * After execution, the agent stores a wrap-up record for audit/training.
8
+ */
9
+ import type { ContextPackage } from "./types.js";
10
+ import { MemoryClient } from "./memory-client.js";
11
+ /**
12
+ * Implements the Neuralgentics Stateless Agent Protocol.
13
+ *
14
+ * The protocol has two phases:
15
+ * 1. **Prepare** — stores task context in memini-core and returns a
16
+ * `ContextPackage` referencing the stored memory.
17
+ * 2. **Wrapup** — stores the agent's result alongside the original
18
+ * memory ID for later review, training, or trust scoring.
19
+ */
20
+ export declare class StatelessProtocol {
21
+ private memoryClient;
22
+ /**
23
+ * Create a new StatelessProtocol.
24
+ *
25
+ * @param memoryClient - The MemoryClient used to interact with memini-core.
26
+ */
27
+ constructor(memoryClient: MemoryClient);
28
+ /**
29
+ * Prepare a context package for a stateless agent invocation.
30
+ *
31
+ * The method stores the task context as a memory record and returns
32
+ * a `ContextPackage` containing the memory ID, a seed prompt that
33
+ * instructs the agent to fetch context from memini-core, and the
34
+ * task and agent metadata.
35
+ *
36
+ * @param task - Short description of the task to execute.
37
+ * @param agent - Name of the agent that will receive this package.
38
+ * @param previousMemoryId - Optional memory ID from a prior step to link contexts.
39
+ * @returns A fully populated ContextPackage ready for injection.
40
+ */
41
+ prepareContextPackage(task: string, agent: string, previousMemoryId?: string): Promise<ContextPackage>;
42
+ /**
43
+ * Store the result of a completed agent invocation.
44
+ *
45
+ * Links the result back to the original context memory for traceability.
46
+ *
47
+ * @param memoryId - The memory ID from the original ContextPackage.
48
+ * @param result - The agent's output text.
49
+ * @param metadata - Optional metadata (e.g. trust signal, duration).
50
+ */
51
+ storeWrapup(memoryId: string, result: string, metadata?: Record<string, unknown>): Promise<void>;
52
+ }
53
+ //# sourceMappingURL=stateless.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stateless.d.ts","sourceRoot":"","sources":["../../src/neuralgentics/stateless.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;;;;;;GAQG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,YAAY,CAAe;IAEnC;;;;OAIG;gBACS,YAAY,EAAE,YAAY;IAItC;;;;;;;;;;;;OAYG;IACG,qBAAqB,CACzB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC,cAAc,CAAC;IA6B1B;;;;;;;;OAQG;IACG,WAAW,CACf,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACjC,OAAO,CAAC,IAAI,CAAC;CAYjB"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Neuralgentics Stateless Agent Protocol.
3
+ *
4
+ * Each agent invocation is fully self-contained. The protocol prepares
5
+ * a context package (storing it in memini-core) and returns a thin
6
+ * reference that the agent can use to pull full context at runtime.
7
+ * After execution, the agent stores a wrap-up record for audit/training.
8
+ */
9
+ /**
10
+ * Implements the Neuralgentics Stateless Agent Protocol.
11
+ *
12
+ * The protocol has two phases:
13
+ * 1. **Prepare** — stores task context in memini-core and returns a
14
+ * `ContextPackage` referencing the stored memory.
15
+ * 2. **Wrapup** — stores the agent's result alongside the original
16
+ * memory ID for later review, training, or trust scoring.
17
+ */
18
+ export class StatelessProtocol {
19
+ memoryClient;
20
+ /**
21
+ * Create a new StatelessProtocol.
22
+ *
23
+ * @param memoryClient - The MemoryClient used to interact with memini-core.
24
+ */
25
+ constructor(memoryClient) {
26
+ this.memoryClient = memoryClient;
27
+ }
28
+ /**
29
+ * Prepare a context package for a stateless agent invocation.
30
+ *
31
+ * The method stores the task context as a memory record and returns
32
+ * a `ContextPackage` containing the memory ID, a seed prompt that
33
+ * instructs the agent to fetch context from memini-core, and the
34
+ * task and agent metadata.
35
+ *
36
+ * @param task - Short description of the task to execute.
37
+ * @param agent - Name of the agent that will receive this package.
38
+ * @param previousMemoryId - Optional memory ID from a prior step to link contexts.
39
+ * @returns A fully populated ContextPackage ready for injection.
40
+ */
41
+ async prepareContextPackage(task, agent, previousMemoryId) {
42
+ const content = previousMemoryId
43
+ ? `Task: ${task}\nPrevious context: ${previousMemoryId}`
44
+ : `Task: ${task}`;
45
+ const metadata = {
46
+ agent,
47
+ protocol: "stateless",
48
+ timestamp: new Date().toISOString(),
49
+ };
50
+ if (previousMemoryId) {
51
+ metadata.previousMemoryId = previousMemoryId;
52
+ }
53
+ const memoryId = await this.memoryClient.addMemory(content, metadata);
54
+ const seedPrompt = `Task: ${task}\nMemory ID: ${memoryId}\n` +
55
+ "Action: Fetch context from memini-core using the provided memory ID, then execute the task.";
56
+ return {
57
+ memoryId,
58
+ seedPrompt,
59
+ task,
60
+ agent,
61
+ };
62
+ }
63
+ /**
64
+ * Store the result of a completed agent invocation.
65
+ *
66
+ * Links the result back to the original context memory for traceability.
67
+ *
68
+ * @param memoryId - The memory ID from the original ContextPackage.
69
+ * @param result - The agent's output text.
70
+ * @param metadata - Optional metadata (e.g. trust signal, duration).
71
+ */
72
+ async storeWrapup(memoryId, result, metadata) {
73
+ const content = `Wrapup for memory ${memoryId}:\n${result}`;
74
+ const wrapupMetadata = {
75
+ ...(metadata ?? {}),
76
+ protocol: "stateless-wrapup",
77
+ sourceMemoryId: memoryId,
78
+ timestamp: new Date().toISOString(),
79
+ };
80
+ await this.memoryClient.addMemory(content, wrapupMetadata);
81
+ }
82
+ }
83
+ //# sourceMappingURL=stateless.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stateless.js","sourceRoot":"","sources":["../../src/neuralgentics/stateless.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH;;;;;;;;GAQG;AACH,MAAM,OAAO,iBAAiB;IACpB,YAAY,CAAe;IAEnC;;;;OAIG;IACH,YAAY,YAA0B;QACpC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,qBAAqB,CACzB,IAAY,EACZ,KAAa,EACb,gBAAyB;QAEzB,MAAM,OAAO,GAAG,gBAAgB;YAC9B,CAAC,CAAC,SAAS,IAAI,uBAAuB,gBAAgB,EAAE;YACxD,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC;QAEpB,MAAM,QAAQ,GAA4B;YACxC,KAAK;YACL,QAAQ,EAAE,WAAW;YACrB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC,CAAC;QAEF,IAAI,gBAAgB,EAAE,CAAC;YACrB,QAAQ,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QAC/C,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QAEtE,MAAM,UAAU,GACd,SAAS,IAAI,gBAAgB,QAAQ,IAAI;YACzC,6FAA6F,CAAC;QAEhG,OAAO;YACL,QAAQ;YACR,UAAU;YACV,IAAI;YACJ,KAAK;SACN,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,WAAW,CACf,QAAgB,EAChB,MAAc,EACd,QAAkC;QAElC,MAAM,OAAO,GAAG,qBAAqB,QAAQ,MAAM,MAAM,EAAE,CAAC;QAE5D,MAAM,cAAc,GAA4B;YAC9C,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC;YACnB,QAAQ,EAAE,kBAAkB;YAC5B,cAAc,EAAE,QAAQ;YACxB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC,CAAC;QAEF,MAAM,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAC7D,CAAC;CACF"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Neuralgentics shared type definitions.
3
+ *
4
+ * These types define the data contracts used across the Neuralgentics overlay:
5
+ * agent definitions, routing rules, context packages, memory records,
6
+ * and broker catalog entries.
7
+ */
8
+ /** Describes a Neuralgentics agent and its operational parameters. */
9
+ export interface AgentDefinition {
10
+ /** Unique agent name (e.g. "neuralgentics-coder"). */
11
+ name: string;
12
+ /** Human-readable description of the agent's role. */
13
+ description: string;
14
+ /** Ollama / cloud model identifier the agent should use. */
15
+ model: string;
16
+ /** Execution mode — "all" for full access, "subagent" for delegated, "primary" for top-level. */
17
+ mode: "all" | "subagent" | "primary";
18
+ /** Maximum protocol steps the agent may execute (0 = unlimited). */
19
+ steps?: number;
20
+ }
21
+ /** Encodes a mandatory routing rule — which agent must handle a task type
22
+ * and which agents must NEVER be assigned to it. */
23
+ export interface RoutingRule {
24
+ /** The canonical agent name that MUST handle this task type. */
25
+ primary: string;
26
+ /** Agent names that MUST NOT be assigned this task type. */
27
+ never: string[];
28
+ }
29
+ /** A self-contained context package passed to a stateless agent.
30
+ * Contains a memory reference so the agent can fetch full context at runtime. */
31
+ export interface ContextPackage {
32
+ /** ID of the stored memory record in memoryManager. */
33
+ memoryId: string;
34
+ /** Seed prompt that bootstraps the agent with enough context to start. */
35
+ seedPrompt: string;
36
+ /** Short description of the task. */
37
+ task: string;
38
+ /** Name of the agent this package is prepared for. */
39
+ agent: string;
40
+ }
41
+ /** A record returned from the memoryManager server. */
42
+ export interface MemoryRecord {
43
+ /** Unique memory identifier. */
44
+ id: string;
45
+ /** The memory content text. */
46
+ content: string;
47
+ /** Optional key-value metadata attached to the memory. */
48
+ metadata?: Record<string, unknown>;
49
+ }
50
+ /** An entry in the MCP broker's server catalog. */
51
+ export interface ServerCatalogEntry {
52
+ /** Server name (e.g. "github", "memoryManager"). */
53
+ name: string;
54
+ /** Human-readable description of the server. */
55
+ description: string;
56
+ /** Number of tools this server exposes. */
57
+ toolCount: number;
58
+ }
59
+ /** A tool match result from the broker's intent-matching system. */
60
+ export interface ToolMatch {
61
+ /** The MCP server that owns the matched tool. */
62
+ server: string;
63
+ /** The tool name within the server. */
64
+ tool: string;
65
+ /** Confidence score (0.0 – 1.0) for the match. */
66
+ confidence: number;
67
+ }
68
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/neuralgentics/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,sEAAsE;AACtE,MAAM,WAAW,eAAe;IAC9B,sDAAsD;IAC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
4
+ * These types define the data contracts used across the Neuralgentics overlay:
5
+ * agent definitions, routing rules, context packages, memory records,
6
+ * and broker catalog entries.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/neuralgentics/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Neuralgentics update interceptor.
3
+ *
4
+ * Intercepts OpenCode's built-in auto-updater so that vanilla upstream
5
+ * binaries never overwrite our patched build. When an update is available
6
+ * the user is directed to the Neuralgentics update script instead.
7
+ */
8
+ export declare class NeuralgenticsUpdater {
9
+ static readonly IS_NEURALGENTICS = true;
10
+ static isActive(): boolean;
11
+ /**
12
+ * Check whether the opencode-base remote has newer commits than the local branch.
13
+ *
14
+ * @returns A human-readable message if updates exist, or `undefined` if up-to-date.
15
+ */
16
+ static checkLatest(): string | undefined;
17
+ /**
18
+ * Notify the user that an update is available and direct them to the
19
+ * Neuralgentics update script (does NOT auto-apply).
20
+ */
21
+ static applyUpdate(): void;
22
+ }
23
+ //# sourceMappingURL=updater.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updater.d.ts","sourceRoot":"","sources":["../../src/neuralgentics/updater.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,qBAAa,oBAAoB;IAC/B,MAAM,CAAC,QAAQ,CAAC,gBAAgB,QAAQ;IAExC,MAAM,CAAC,QAAQ,IAAI,OAAO;IAI1B;;;;OAIG;IACH,MAAM,CAAC,WAAW,IAAI,MAAM,GAAG,SAAS;IAuBxC;;;OAGG;IACH,MAAM,CAAC,WAAW,IAAI,IAAI;CAK3B"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Neuralgentics update interceptor.
3
+ *
4
+ * Intercepts OpenCode's built-in auto-updater so that vanilla upstream
5
+ * binaries never overwrite our patched build. When an update is available
6
+ * the user is directed to the Neuralgentics update script instead.
7
+ */
8
+ import { execSync } from "node:child_process";
9
+ /** Base directory for opencode source repository. */
10
+ const OPENCODE_BASE_DIR = process.env.NEURALGENTICS_OPENCODE_BASE_DIR ?? "/home/jcharles/Projects/MCP-Servers/neuralgentics/opencode-base";
11
+ export class NeuralgenticsUpdater {
12
+ static IS_NEURALGENTICS = true;
13
+ static isActive() {
14
+ return this.IS_NEURALGENTICS;
15
+ }
16
+ /**
17
+ * Check whether the opencode-base remote has newer commits than the local branch.
18
+ *
19
+ * @returns A human-readable message if updates exist, or `undefined` if up-to-date.
20
+ */
21
+ static checkLatest() {
22
+ try {
23
+ execSync("git fetch origin", {
24
+ cwd: OPENCODE_BASE_DIR,
25
+ stdio: "pipe",
26
+ timeout: 15_000,
27
+ });
28
+ const output = execSync("git rev-list --count HEAD..origin/dev", { cwd: OPENCODE_BASE_DIR, encoding: "utf-8", timeout: 10_000 }).trim();
29
+ const count = parseInt(output, 10);
30
+ if (count > 0) {
31
+ return `origin/dev is ${count} commit(s) ahead`;
32
+ }
33
+ return undefined;
34
+ }
35
+ catch {
36
+ return undefined;
37
+ }
38
+ }
39
+ /**
40
+ * Notify the user that an update is available and direct them to the
41
+ * Neuralgentics update script (does NOT auto-apply).
42
+ */
43
+ static applyUpdate() {
44
+ console.error("[Neuralgentics] Update available. Run: ./scripts/update-opencode.sh");
45
+ }
46
+ }
47
+ //# sourceMappingURL=updater.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updater.js","sourceRoot":"","sources":["../../src/neuralgentics/updater.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,qDAAqD;AACrD,MAAM,iBAAiB,GACrB,OAAO,CAAC,GAAG,CAAC,+BAA+B,IAAI,iEAAiE,CAAC;AAEnH,MAAM,OAAO,oBAAoB;IAC/B,MAAM,CAAU,gBAAgB,GAAG,IAAI,CAAC;IAExC,MAAM,CAAC,QAAQ;QACb,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,WAAW;QAChB,IAAI,CAAC;YACH,QAAQ,CAAC,kBAAkB,EAAE;gBAC3B,GAAG,EAAE,iBAAiB;gBACtB,KAAK,EAAE,MAAM;gBACb,OAAO,EAAE,MAAM;aAChB,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,QAAQ,CACrB,uCAAuC,EACvC,EAAE,GAAG,EAAE,iBAAiB,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAC/D,CAAC,IAAI,EAAE,CAAC;YAET,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YACnC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;gBACd,OAAO,iBAAiB,KAAK,kBAAkB,CAAC;YAClD,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,WAAW;QAChB,OAAO,CAAC,KAAK,CACX,qEAAqE,CACtE,CAAC;IACJ,CAAC"}