@juspay/neurolink 9.51.3 → 9.52.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/CHANGELOG.md +12 -0
- package/dist/artifacts/artifactStore.d.ts +56 -0
- package/dist/artifacts/artifactStore.js +143 -0
- package/dist/browser/neurolink.min.js +311 -298
- package/dist/cli/commands/mcp.d.ts +6 -0
- package/dist/cli/commands/mcp.js +128 -86
- package/dist/cli/loop/optionsSchema.d.ts +1 -1
- package/dist/core/factory.d.ts +2 -2
- package/dist/core/factory.js +4 -4
- package/dist/core/redisConversationMemoryManager.js +20 -0
- package/dist/factories/providerFactory.d.ts +4 -4
- package/dist/factories/providerFactory.js +20 -7
- package/dist/factories/providerRegistry.d.ts +5 -0
- package/dist/factories/providerRegistry.js +45 -26
- package/dist/lib/artifacts/artifactStore.d.ts +56 -0
- package/dist/lib/artifacts/artifactStore.js +144 -0
- package/dist/lib/core/factory.d.ts +2 -2
- package/dist/lib/core/factory.js +4 -4
- package/dist/lib/core/redisConversationMemoryManager.js +20 -0
- package/dist/lib/factories/providerFactory.d.ts +4 -4
- package/dist/lib/factories/providerFactory.js +20 -7
- package/dist/lib/factories/providerRegistry.d.ts +5 -0
- package/dist/lib/factories/providerRegistry.js +45 -26
- package/dist/lib/mcp/externalServerManager.d.ts +6 -0
- package/dist/lib/mcp/externalServerManager.js +9 -0
- package/dist/lib/mcp/mcpOutputNormalizer.d.ts +49 -0
- package/dist/lib/mcp/mcpOutputNormalizer.js +182 -0
- package/dist/lib/mcp/toolDiscoveryService.d.ts +10 -0
- package/dist/lib/mcp/toolDiscoveryService.js +32 -1
- package/dist/lib/memory/memoryRetrievalTools.d.ts +64 -9
- package/dist/lib/memory/memoryRetrievalTools.js +77 -9
- package/dist/lib/neurolink.d.ts +23 -0
- package/dist/lib/neurolink.js +128 -86
- package/dist/lib/providers/amazonBedrock.d.ts +6 -1
- package/dist/lib/providers/amazonBedrock.js +14 -2
- package/dist/lib/providers/amazonSagemaker.d.ts +7 -1
- package/dist/lib/providers/amazonSagemaker.js +21 -3
- package/dist/lib/providers/anthropic.d.ts +4 -1
- package/dist/lib/providers/anthropic.js +18 -5
- package/dist/lib/providers/azureOpenai.d.ts +2 -1
- package/dist/lib/providers/azureOpenai.js +10 -5
- package/dist/lib/providers/googleAiStudio.d.ts +4 -1
- package/dist/lib/providers/googleAiStudio.js +6 -7
- package/dist/lib/providers/googleVertex.d.ts +3 -1
- package/dist/lib/providers/googleVertex.js +96 -17
- package/dist/lib/providers/huggingFace.d.ts +2 -1
- package/dist/lib/providers/huggingFace.js +4 -4
- package/dist/lib/providers/litellm.d.ts +5 -1
- package/dist/lib/providers/litellm.js +14 -9
- package/dist/lib/providers/mistral.d.ts +2 -1
- package/dist/lib/providers/mistral.js +2 -2
- package/dist/lib/providers/ollama.d.ts +3 -1
- package/dist/lib/providers/ollama.js +2 -2
- package/dist/lib/providers/openAI.d.ts +5 -1
- package/dist/lib/providers/openAI.js +15 -5
- package/dist/lib/providers/openRouter.d.ts +5 -1
- package/dist/lib/providers/openRouter.js +17 -5
- package/dist/lib/providers/openaiCompatible.d.ts +4 -1
- package/dist/lib/providers/openaiCompatible.js +15 -3
- package/dist/lib/session/globalSessionState.js +44 -1
- package/dist/lib/types/artifactTypes.d.ts +63 -0
- package/dist/lib/types/artifactTypes.js +11 -0
- package/dist/lib/types/configTypes.d.ts +39 -0
- package/dist/lib/types/conversation.d.ts +7 -0
- package/dist/lib/types/generateTypes.d.ts +13 -0
- package/dist/lib/types/index.d.ts +2 -0
- package/dist/lib/types/mcpOutputTypes.d.ts +40 -0
- package/dist/lib/types/mcpOutputTypes.js +9 -0
- package/dist/lib/types/providers.d.ts +75 -0
- package/dist/lib/types/streamTypes.d.ts +7 -1
- package/dist/mcp/externalServerManager.d.ts +6 -0
- package/dist/mcp/externalServerManager.js +9 -0
- package/dist/mcp/mcpOutputNormalizer.d.ts +49 -0
- package/dist/mcp/mcpOutputNormalizer.js +181 -0
- package/dist/mcp/toolDiscoveryService.d.ts +10 -0
- package/dist/mcp/toolDiscoveryService.js +32 -1
- package/dist/memory/memoryRetrievalTools.d.ts +64 -9
- package/dist/memory/memoryRetrievalTools.js +77 -9
- package/dist/neurolink.d.ts +23 -0
- package/dist/neurolink.js +128 -86
- package/dist/providers/amazonBedrock.d.ts +6 -1
- package/dist/providers/amazonBedrock.js +14 -2
- package/dist/providers/amazonSagemaker.d.ts +7 -1
- package/dist/providers/amazonSagemaker.js +21 -3
- package/dist/providers/anthropic.d.ts +4 -1
- package/dist/providers/anthropic.js +18 -5
- package/dist/providers/azureOpenai.d.ts +2 -1
- package/dist/providers/azureOpenai.js +10 -5
- package/dist/providers/googleAiStudio.d.ts +4 -1
- package/dist/providers/googleAiStudio.js +6 -7
- package/dist/providers/googleVertex.d.ts +3 -1
- package/dist/providers/googleVertex.js +96 -17
- package/dist/providers/huggingFace.d.ts +2 -1
- package/dist/providers/huggingFace.js +4 -4
- package/dist/providers/litellm.d.ts +5 -1
- package/dist/providers/litellm.js +14 -9
- package/dist/providers/mistral.d.ts +2 -1
- package/dist/providers/mistral.js +2 -2
- package/dist/providers/ollama.d.ts +3 -1
- package/dist/providers/ollama.js +2 -2
- package/dist/providers/openAI.d.ts +5 -1
- package/dist/providers/openAI.js +15 -5
- package/dist/providers/openRouter.d.ts +5 -1
- package/dist/providers/openRouter.js +17 -5
- package/dist/providers/openaiCompatible.d.ts +4 -1
- package/dist/providers/openaiCompatible.js +15 -3
- package/dist/session/globalSessionState.js +44 -1
- package/dist/types/artifactTypes.d.ts +63 -0
- package/dist/types/artifactTypes.js +10 -0
- package/dist/types/configTypes.d.ts +39 -0
- package/dist/types/conversation.d.ts +7 -0
- package/dist/types/generateTypes.d.ts +13 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/mcpOutputTypes.d.ts +40 -0
- package/dist/types/mcpOutputTypes.js +8 -0
- package/dist/types/providers.d.ts +75 -0
- package/dist/types/streamTypes.d.ts +7 -1
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## [9.52.0](https://github.com/juspay/neurolink/compare/v9.51.4...v9.52.0) (2026-04-12)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
- **(credentials):** add per-request and per-instance credential support for all providers ([edd07bb](https://github.com/juspay/neurolink/commit/edd07bb5475d4ef33a9ce29915913ebcd8a6904b))
|
|
6
|
+
|
|
7
|
+
## [9.51.4](https://github.com/juspay/neurolink/compare/v9.51.3...v9.51.4) (2026-04-12)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
- **(mcp):** large-response externalization, retrieve_context tool, and exec cleanup ([8e802d9](https://github.com/juspay/neurolink/commit/8e802d99782b7c365557fbaeeb67bc77a8aab9f1))
|
|
12
|
+
|
|
1
13
|
## [9.51.3](https://github.com/juspay/neurolink/compare/v9.51.2...v9.51.3) (2026-04-12)
|
|
2
14
|
|
|
3
15
|
### Bug Fixes
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact Store
|
|
3
|
+
*
|
|
4
|
+
* Pluggable storage for externalized MCP tool outputs.
|
|
5
|
+
*
|
|
6
|
+
* When `mcp.outputLimits.strategy = "externalize"` the full tool payload is
|
|
7
|
+
* written here instead of being sent inline to the LLM. The model receives a
|
|
8
|
+
* compact surrogate with a preview and an artifact ID. The full payload can be
|
|
9
|
+
* retrieved on demand via the `retrieve_context` tool.
|
|
10
|
+
*
|
|
11
|
+
* Architecture:
|
|
12
|
+
* ArtifactStore (interface) — canonical types in src/lib/types/artifactTypes.ts
|
|
13
|
+
* LocalTempArtifactStore — single-process, filesystem-backed implementation
|
|
14
|
+
*
|
|
15
|
+
* Distributed backends (S3, Redis blobs) can be added later by implementing
|
|
16
|
+
* ArtifactStore from types/artifactTypes.ts.
|
|
17
|
+
*
|
|
18
|
+
* @module artifacts/artifactStore
|
|
19
|
+
*/
|
|
20
|
+
import type { ArtifactMeta, ArtifactRef, ArtifactStore } from "../types/artifactTypes.js";
|
|
21
|
+
export type { ArtifactMeta, ArtifactRef, ArtifactStore, } from "../types/artifactTypes.js";
|
|
22
|
+
/**
|
|
23
|
+
* Filesystem-backed artifact store using the OS temp directory.
|
|
24
|
+
*
|
|
25
|
+
* Files are written with mode 0o600 (owner read/write only).
|
|
26
|
+
* An in-memory index tracks metadata without a separate index file.
|
|
27
|
+
*
|
|
28
|
+
* Suitable for:
|
|
29
|
+
* - CLI usage
|
|
30
|
+
* - Single-process SDK deployments
|
|
31
|
+
* - Multi-process deployments where each process manages its own artifacts
|
|
32
|
+
* (artifacts created in one process are not visible to others)
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const store = new LocalTempArtifactStore();
|
|
37
|
+
* const ref = await store.store(largeJson, {
|
|
38
|
+
* toolName: "list_files",
|
|
39
|
+
* serverId: "filesystem-server",
|
|
40
|
+
* sizeBytes: Buffer.byteLength(largeJson),
|
|
41
|
+
* contentType: "json",
|
|
42
|
+
* });
|
|
43
|
+
* // Later, via retrieve_context:
|
|
44
|
+
* const full = await store.retrieve(ref.id);
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare class LocalTempArtifactStore implements ArtifactStore {
|
|
48
|
+
private readonly dir;
|
|
49
|
+
private readonly index;
|
|
50
|
+
constructor(dir?: string);
|
|
51
|
+
generatePreview(payload: string): string;
|
|
52
|
+
store(payload: string, meta: Omit<ArtifactMeta, "createdAt">): Promise<ArtifactRef>;
|
|
53
|
+
retrieve(id: string): Promise<string | null>;
|
|
54
|
+
delete(id: string): Promise<void>;
|
|
55
|
+
cleanup(olderThanMs: number): Promise<number>;
|
|
56
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact Store
|
|
3
|
+
*
|
|
4
|
+
* Pluggable storage for externalized MCP tool outputs.
|
|
5
|
+
*
|
|
6
|
+
* When `mcp.outputLimits.strategy = "externalize"` the full tool payload is
|
|
7
|
+
* written here instead of being sent inline to the LLM. The model receives a
|
|
8
|
+
* compact surrogate with a preview and an artifact ID. The full payload can be
|
|
9
|
+
* retrieved on demand via the `retrieve_context` tool.
|
|
10
|
+
*
|
|
11
|
+
* Architecture:
|
|
12
|
+
* ArtifactStore (interface) — canonical types in src/lib/types/artifactTypes.ts
|
|
13
|
+
* LocalTempArtifactStore — single-process, filesystem-backed implementation
|
|
14
|
+
*
|
|
15
|
+
* Distributed backends (S3, Redis blobs) can be added later by implementing
|
|
16
|
+
* ArtifactStore from types/artifactTypes.ts.
|
|
17
|
+
*
|
|
18
|
+
* @module artifacts/artifactStore
|
|
19
|
+
*/
|
|
20
|
+
import { randomUUID } from "node:crypto";
|
|
21
|
+
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
22
|
+
import { tmpdir } from "node:os";
|
|
23
|
+
import { join } from "node:path";
|
|
24
|
+
import { logger } from "../utils/logger.js";
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
// LocalTempArtifactStore
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
/** Characters used for the quick preview embedded in surrogate results. */
|
|
29
|
+
const DEFAULT_PREVIEW_CHARS = 500;
|
|
30
|
+
/**
|
|
31
|
+
* Filesystem-backed artifact store using the OS temp directory.
|
|
32
|
+
*
|
|
33
|
+
* Files are written with mode 0o600 (owner read/write only).
|
|
34
|
+
* An in-memory index tracks metadata without a separate index file.
|
|
35
|
+
*
|
|
36
|
+
* Suitable for:
|
|
37
|
+
* - CLI usage
|
|
38
|
+
* - Single-process SDK deployments
|
|
39
|
+
* - Multi-process deployments where each process manages its own artifacts
|
|
40
|
+
* (artifacts created in one process are not visible to others)
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const store = new LocalTempArtifactStore();
|
|
45
|
+
* const ref = await store.store(largeJson, {
|
|
46
|
+
* toolName: "list_files",
|
|
47
|
+
* serverId: "filesystem-server",
|
|
48
|
+
* sizeBytes: Buffer.byteLength(largeJson),
|
|
49
|
+
* contentType: "json",
|
|
50
|
+
* });
|
|
51
|
+
* // Later, via retrieve_context:
|
|
52
|
+
* const full = await store.retrieve(ref.id);
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export class LocalTempArtifactStore {
|
|
56
|
+
dir;
|
|
57
|
+
index = new Map();
|
|
58
|
+
constructor(dir) {
|
|
59
|
+
this.dir = dir ?? join(tmpdir(), "neurolink-artifacts");
|
|
60
|
+
}
|
|
61
|
+
generatePreview(payload) {
|
|
62
|
+
if (payload.length <= DEFAULT_PREVIEW_CHARS) {
|
|
63
|
+
return payload;
|
|
64
|
+
}
|
|
65
|
+
return `${payload.slice(0, DEFAULT_PREVIEW_CHARS)}…`;
|
|
66
|
+
}
|
|
67
|
+
async store(payload, meta) {
|
|
68
|
+
await mkdir(this.dir, { recursive: true, mode: 0o700 });
|
|
69
|
+
const id = randomUUID();
|
|
70
|
+
const ext = meta.contentType === "json" ? ".json" : ".txt";
|
|
71
|
+
const filePath = join(this.dir, `${id}${ext}`);
|
|
72
|
+
await writeFile(filePath, payload, { encoding: "utf-8", mode: 0o600 });
|
|
73
|
+
const fullMeta = {
|
|
74
|
+
...meta,
|
|
75
|
+
createdAt: Date.now(),
|
|
76
|
+
path: filePath,
|
|
77
|
+
};
|
|
78
|
+
this.index.set(id, fullMeta);
|
|
79
|
+
logger.debug(`[ArtifactStore] Stored artifact ${id} for tool "${meta.toolName}" ` +
|
|
80
|
+
`(${formatBytes(meta.sizeBytes)})`);
|
|
81
|
+
return {
|
|
82
|
+
id,
|
|
83
|
+
preview: this.generatePreview(payload),
|
|
84
|
+
sizeBytes: meta.sizeBytes,
|
|
85
|
+
meta: { ...meta, createdAt: fullMeta.createdAt },
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
async retrieve(id) {
|
|
89
|
+
const entry = this.index.get(id);
|
|
90
|
+
if (!entry) {
|
|
91
|
+
logger.debug(`[ArtifactStore] Artifact ${id} not in index`);
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
try {
|
|
95
|
+
const content = await readFile(entry.path, "utf-8");
|
|
96
|
+
logger.debug(`[ArtifactStore] Retrieved artifact ${id} (${formatBytes(entry.sizeBytes)})`);
|
|
97
|
+
return content;
|
|
98
|
+
}
|
|
99
|
+
catch (err) {
|
|
100
|
+
logger.warn(`[ArtifactStore] Failed to read artifact ${id}: ${err instanceof Error ? err.message : String(err)}`);
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async delete(id) {
|
|
105
|
+
const entry = this.index.get(id);
|
|
106
|
+
if (!entry) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
await rm(entry.path, { force: true });
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
// Suppress — file may already be gone
|
|
114
|
+
}
|
|
115
|
+
this.index.delete(id);
|
|
116
|
+
}
|
|
117
|
+
async cleanup(olderThanMs) {
|
|
118
|
+
const cutoff = Date.now() - olderThanMs;
|
|
119
|
+
let count = 0;
|
|
120
|
+
for (const [id, entry] of this.index.entries()) {
|
|
121
|
+
if (entry.createdAt < cutoff) {
|
|
122
|
+
await this.delete(id);
|
|
123
|
+
count++;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (count > 0) {
|
|
127
|
+
logger.debug(`[ArtifactStore] Cleaned up ${count} expired artifact(s)`);
|
|
128
|
+
}
|
|
129
|
+
return count;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
// ---------------------------------------------------------------------------
|
|
133
|
+
// Helpers
|
|
134
|
+
// ---------------------------------------------------------------------------
|
|
135
|
+
function formatBytes(bytes) {
|
|
136
|
+
if (bytes < 1024) {
|
|
137
|
+
return `${bytes} B`;
|
|
138
|
+
}
|
|
139
|
+
if (bytes < 1024 * 1024) {
|
|
140
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
141
|
+
}
|
|
142
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
143
|
+
}
|