@juspay/neurolink 9.44.0 → 9.48.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 (78) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +230 -5
  3. package/dist/auth/tokenStore.js +4 -2
  4. package/dist/browser/neurolink.min.js +258 -258
  5. package/dist/cli/commands/authProviders.d.ts +1 -1
  6. package/dist/cli/commands/proxy.js +25 -2
  7. package/dist/cli/commands/task.js +1 -1
  8. package/dist/cli/errorHandler.js +1 -1
  9. package/dist/cli/factories/commandFactory.js +8 -2
  10. package/dist/cli/loop/conversationSelector.d.ts +2 -2
  11. package/dist/cli/loop/optionsSchema.d.ts +2 -2
  12. package/dist/cli/loop/session.d.ts +1 -1
  13. package/dist/cli/utils/audioFileUtils.d.ts +1 -1
  14. package/dist/cli/utils/envManager.d.ts +1 -1
  15. package/dist/cli/utils/videoFileUtils.d.ts +1 -1
  16. package/dist/client/auth.d.ts +3 -3
  17. package/dist/client/httpClient.d.ts +20 -20
  18. package/dist/client/index.d.ts +3 -3
  19. package/dist/client/interceptors.d.ts +1 -1
  20. package/dist/client/reactHooks.d.ts +1 -1
  21. package/dist/client/reactHooks.tsx +2 -2
  22. package/dist/client/sseClient.d.ts +1 -1
  23. package/dist/client/streamingClient.d.ts +1 -1
  24. package/dist/client/wsClient.d.ts +1 -1
  25. package/dist/files/fileTools.d.ts +1 -1
  26. package/dist/lib/agent/directTools.d.ts +2 -2
  27. package/dist/lib/auth/tokenStore.js +4 -2
  28. package/dist/lib/client/auth.d.ts +3 -3
  29. package/dist/lib/client/httpClient.d.ts +20 -20
  30. package/dist/lib/client/index.d.ts +3 -3
  31. package/dist/lib/client/interceptors.d.ts +1 -1
  32. package/dist/lib/client/reactHooks.d.ts +1 -1
  33. package/dist/lib/client/sseClient.d.ts +1 -1
  34. package/dist/lib/client/streamingClient.d.ts +1 -1
  35. package/dist/lib/client/wsClient.d.ts +1 -1
  36. package/dist/lib/files/fileTools.d.ts +1 -1
  37. package/dist/lib/rag/types.d.ts +1 -68
  38. package/dist/lib/server/types.d.ts +3 -847
  39. package/dist/lib/server/types.js +3 -64
  40. package/dist/lib/tasks/tools/taskTools.d.ts +1 -1
  41. package/dist/lib/types/analytics.d.ts +1 -1
  42. package/dist/lib/types/cli.d.ts +1 -1
  43. package/dist/lib/types/clientTypes.d.ts +38 -20
  44. package/dist/lib/types/configTypes.d.ts +1 -1
  45. package/dist/lib/types/configTypes.js +0 -1
  46. package/dist/lib/types/index.d.ts +9 -7
  47. package/dist/lib/types/index.js +5 -2
  48. package/dist/lib/types/ragTypes.d.ts +69 -0
  49. package/dist/lib/types/sdkTypes.d.ts +1 -2
  50. package/dist/lib/types/serverTypes.d.ts +858 -0
  51. package/dist/lib/types/serverTypes.js +68 -0
  52. package/dist/lib/types/streamTypes.d.ts +2 -2
  53. package/dist/lib/types/typeAliases.d.ts +1 -37
  54. package/dist/lib/utils/imageProcessor.d.ts +24 -1
  55. package/dist/lib/utils/imageProcessor.js +124 -8
  56. package/dist/lib/utils/messageBuilder.js +18 -6
  57. package/dist/lib/workflow/config.d.ts +3 -3
  58. package/dist/rag/errors/RAGError.d.ts +1 -1
  59. package/dist/rag/types.d.ts +1 -68
  60. package/dist/server/types.d.ts +3 -847
  61. package/dist/server/types.js +3 -64
  62. package/dist/types/analytics.d.ts +1 -1
  63. package/dist/types/cli.d.ts +1 -1
  64. package/dist/types/clientTypes.d.ts +38 -20
  65. package/dist/types/configTypes.d.ts +1 -1
  66. package/dist/types/index.d.ts +8 -6
  67. package/dist/types/index.js +5 -2
  68. package/dist/types/ragTypes.d.ts +69 -0
  69. package/dist/types/sdkTypes.d.ts +1 -2
  70. package/dist/types/serverTypes.d.ts +858 -0
  71. package/dist/types/serverTypes.js +67 -0
  72. package/dist/types/streamTypes.d.ts +2 -2
  73. package/dist/types/typeAliases.d.ts +1 -37
  74. package/dist/utils/imageProcessor.js +124 -8
  75. package/dist/utils/messageBuilder.js +18 -6
  76. package/dist/workflow/config.d.ts +3 -3
  77. package/package.json +1 -1
  78. package/scripts/observability/manage-local-openobserve.sh +30 -2
@@ -1,5 +1,5 @@
1
1
  import type { ArgumentsCamelCase } from "yargs";
2
- import type { AuthProviderType } from "../../lib/types/authTypes.js";
2
+ import type { AuthProviderType } from "../../lib/types/index.js";
3
3
  /**
4
4
  * Auth command argument types
5
5
  */
@@ -11,7 +11,7 @@
11
11
  */
12
12
  import { spawn } from "node:child_process";
13
13
  import { homedir } from "node:os";
14
- import { join, resolve } from "node:path";
14
+ import { dirname, join, resolve } from "node:path";
15
15
  import chalk from "chalk";
16
16
  import ora from "ora";
17
17
  import { buildProxyHealthResponse, createProxyReadinessState, markProxyReady, waitForProxyReadiness, } from "../../lib/proxy/proxyHealth.js";
@@ -1516,6 +1516,29 @@ function escapeXml(s) {
1516
1516
  .replace(/"/g, """)
1517
1517
  .replace(/'/g, "'");
1518
1518
  }
1519
+ /**
1520
+ * Build a PATH for the launchd plist that includes the current Node/pnpm
1521
+ * bin directories so the guard process can find npm/pnpm for update checks.
1522
+ */
1523
+ function buildLaunchdPath() {
1524
+ const fallback = "/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin";
1525
+ const nodeDir = dirname(process.execPath);
1526
+ const segments = new Set();
1527
+ // Add the directory containing the Node binary that launched this process
1528
+ if (nodeDir && nodeDir !== ".") {
1529
+ segments.add(nodeDir);
1530
+ }
1531
+ // Add pnpm home if available (e.g., ~/.local/share/pnpm)
1532
+ const pnpmHome = process.env.PNPM_HOME;
1533
+ if (pnpmHome) {
1534
+ segments.add(pnpmHome);
1535
+ }
1536
+ // Add the standard system paths
1537
+ for (const p of fallback.split(":")) {
1538
+ segments.add(p);
1539
+ }
1540
+ return [...segments].join(":");
1541
+ }
1519
1542
  function buildPlist(port, host, envFile, configFile) {
1520
1543
  const nodeExec = escapeXml(process.execPath);
1521
1544
  const entryScript = escapeXml(process.argv[1] ?? join(__dirname, "..", "index.js"));
@@ -1573,7 +1596,7 @@ ${configArgs}
1573
1596
  <key>EnvironmentVariables</key>
1574
1597
  <dict>
1575
1598
  <key>PATH</key>
1576
- <string>/usr/local/bin:/opt/homebrew/bin:/usr/bin:/bin</string>
1599
+ <string>${buildLaunchdPath()}</string>
1577
1600
  <key>HOME</key>
1578
1601
  <string>${homedir()}</string>
1579
1602
  </dict>
@@ -22,7 +22,7 @@ import { mkdirSync } from "node:fs";
22
22
  import chalk from "chalk";
23
23
  import { nanoid } from "nanoid";
24
24
  import ora from "ora";
25
- import { TASK_DEFAULTS } from "../../lib/types/taskTypes.js";
25
+ import { TASK_DEFAULTS } from "../../lib/types/index.js";
26
26
  import { StateFileManager, isProcessRunning, formatUptime, getNeuroLinkDir, ensureStateDir, } from "../utils/serverUtils.js";
27
27
  const workerState = new StateFileManager("task-worker-state.json");
28
28
  /**
@@ -1,6 +1,6 @@
1
1
  import chalk from "chalk";
2
2
  import { logger } from "../lib/utils/logger.js";
3
- import { AuthenticationError, AuthorizationError, NetworkError, RateLimitError, } from "../lib/types/errors.js";
3
+ import { AuthenticationError, AuthorizationError, NetworkError, RateLimitError, } from "../lib/types/index.js";
4
4
  import { globalSession } from "../lib/session/globalSessionState.js";
5
5
  export function handleError(_error, context) {
6
6
  logger.error(chalk.red(`❌ ${context} failed: ${_error.message}`));
@@ -5,7 +5,7 @@ import ora from "ora";
5
5
  import { ModelResolver } from "../../lib/models/modelResolver.js";
6
6
  import { globalSession } from "../../lib/session/globalSessionState.js";
7
7
  // Use TokenUsage from standard types - no local interface needed
8
- import { ContextFactory, } from "../../lib/types/contextTypes.js";
8
+ import { ContextFactory, } from "../../lib/types/index.js";
9
9
  import { checkRedisAvailability } from "../../lib/utils/conversationMemory.js";
10
10
  import { normalizeEvaluationData } from "../../lib/utils/evaluationUtils.js";
11
11
  import { logger } from "../../lib/utils/logger.js";
@@ -124,7 +124,10 @@ export class CLICommandFactory {
124
124
  type: "string",
125
125
  choices: ["raw", "markdown", "json"],
126
126
  default: "raw",
127
- description: "CSV output format (raw recommended for large files)",
127
+ description: "CSV output format:\n" +
128
+ " • raw: Plain CSV text (fastest, minimal tokens, best for large files)\n" +
129
+ " • markdown: Formatted table (readable, best for small files <100 rows)\n" +
130
+ " • json: Structured JSON array (best for programmatic use, higher tokens)",
128
131
  },
129
132
  model: {
130
133
  type: "string",
@@ -1081,6 +1084,9 @@ export class CLICommandFactory {
1081
1084
  .example('$0 generate "Futuristic city" --model gemini-2.5-flash-image', "Generate an image")
1082
1085
  .example('$0 generate "Mountain landscape" --model gemini-2.5-flash-image --imageOutput ./my-images/mountain.png', "Generate image with custom path")
1083
1086
  .example('$0 generate "Describe this video" --video path/to/video.mp4', "Analyze video content")
1087
+ .example('$0 generate "Analyze sales" --csv data.csv --csv-format raw', "CSV with raw format (fast, minimal tokens)")
1088
+ .example('$0 generate "Summarize data" --csv small.csv --csv-format markdown', "CSV with markdown table (readable)")
1089
+ .example('$0 generate "Process data" --csv records.csv --csv-format json', "CSV with JSON format (structured)")
1084
1090
  .example('$0 generate "Product showcase video" --image ./product.jpg --outputMode video --videoOutput ./output.mp4', "Generate video from image")
1085
1091
  .example('$0 generate "Smooth camera movement" --image ./input.jpg --provider vertex --model veo-3.1-generate-001 --outputMode video --videoResolution 720p --videoLength 6 --videoAspectRatio 16:9 --videoOutput ./output.mp4', "Video generation with full options")
1086
1092
  .example('$0 generate "AI in Healthcare" --pptPages 10', "Generate a PowerPoint presentation")
@@ -2,8 +2,8 @@
2
2
  * Conversation Selector for Loop Mode
3
3
  * Handles discovery and selection of stored conversations from Redis
4
4
  */
5
- import type { ConversationSummary } from "../../lib/types/conversation.js";
6
- import type { RedisStorageConfig } from "../../lib/types/conversation.js";
5
+ import type { ConversationSummary } from "../../lib/types/index.js";
6
+ import type { RedisStorageConfig } from "../../lib/types/index.js";
7
7
  export declare class ConversationSelector {
8
8
  private redisClient;
9
9
  private redisConfig;
@@ -1,5 +1,5 @@
1
- import type { OptionSchema } from "../../lib/types/cli.js";
2
- import type { TextGenerationOptions } from "../../lib/types/generateTypes.js";
1
+ import type { OptionSchema } from "../../lib/types/index.js";
2
+ import type { TextGenerationOptions } from "../../lib/types/index.js";
3
3
  /**
4
4
  * Master schema for all text generation options.
5
5
  * This object provides metadata for validation and help text in the CLI loop.
@@ -1,5 +1,5 @@
1
1
  import type { Argv } from "yargs";
2
- import type { ConversationMemoryConfig } from "../../lib/types/conversation.js";
2
+ import type { ConversationMemoryConfig } from "../../lib/types/index.js";
3
3
  export declare class LoopSession {
4
4
  private conversationMemoryConfig?;
5
5
  private options?;
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @module cli/utils/audioFileUtils
8
8
  */
9
- import type { TTSResult, AudioSaveResult, AudioFormat } from "../../lib/types/ttsTypes.js";
9
+ import type { TTSResult, AudioSaveResult, AudioFormat } from "../../lib/types/index.js";
10
10
  /**
11
11
  * Format file size in human-readable format
12
12
  *
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Handles .env file operations including backup, update, and validation.
5
5
  */
6
- import type { EnvBackupResult, EnvUpdateResult } from "../../lib/types/cli.js";
6
+ import type { EnvBackupResult, EnvUpdateResult } from "../../lib/types/index.js";
7
7
  /**
8
8
  * Create a timestamped backup of the existing .env file
9
9
  */
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * @module cli/utils/videoFileUtils
9
9
  */
10
- import type { VideoGenerationResult } from "../../lib/types/multimodal.js";
10
+ import type { VideoGenerationResult } from "../../lib/types/index.js";
11
11
  /**
12
12
  * Result of saving video to file
13
13
  */
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @module @neurolink/client/auth
8
8
  */
9
- import type { Middleware, AuthConfig, OAuth2Config, TokenRefreshResult } from "../types/clientTypes.js";
9
+ import type { Middleware, AuthConfig, ClientOAuth2Config, ClientTokenRefreshResult } from "../types/clientTypes.js";
10
10
  /**
11
11
  * OAuth2 Token Manager for client credentials flow
12
12
  *
@@ -38,7 +38,7 @@ export declare class OAuth2TokenManager {
38
38
  private tokenExpiry;
39
39
  private refreshPromise;
40
40
  private refreshBufferMs;
41
- constructor(config: OAuth2Config, options?: {
41
+ constructor(config: ClientOAuth2Config, options?: {
42
42
  refreshBufferMs?: number;
43
43
  });
44
44
  /**
@@ -97,7 +97,7 @@ export declare class JWTTokenManager {
97
97
  constructor(config: {
98
98
  token: string;
99
99
  expiresAt: number;
100
- refreshFn: () => Promise<TokenRefreshResult>;
100
+ refreshFn: () => Promise<ClientTokenRefreshResult>;
101
101
  refreshBufferMs?: number;
102
102
  });
103
103
  /**
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @module @neurolink/client
8
8
  */
9
- import type { ClientConfig, RequestOptions, ApiResponse, ApiError, RetryConfig, Middleware, MiddlewareRequest, MiddlewareResponse, MiddlewareContext, StreamCallbacks, StreamEvent, StreamResult, GenerateRequestOptions, GenerateResponse, StreamRequestOptions, AgentExecuteOptions, AgentExecuteResult, AgentInfo, WorkflowExecuteOptions, WorkflowExecuteResult, WorkflowInfo, ToolInfo, ProviderStatus, WebSocketOptions, WebSocketState, WebSocketMessageHandler } from "../types/clientTypes.js";
9
+ import type { ClientConfig, RequestOptions, ClientApiResponse, ApiError, ClientRetryConfig, Middleware, MiddlewareRequest, MiddlewareResponse, ClientMiddlewareContext, StreamCallbacks, ClientStreamEvent, ClientStreamResult, GenerateRequestOptions, GenerateResponse, StreamRequestOptions, AgentExecuteOptions, AgentExecuteResult, AgentInfo, WorkflowExecuteOptions, WorkflowExecuteResult, WorkflowInfo, ToolInfo, ClientProviderStatus, WebSocketOptions, WebSocketState, WebSocketMessageHandler } from "../types/clientTypes.js";
10
10
  import type { UnknownRecord } from "../types/common.js";
11
11
  import { HttpError, ClientNetworkError, ClientTimeoutError } from "./errors.js";
12
12
  /**
@@ -114,7 +114,7 @@ export declare class NeuroLinkClient {
114
114
  * console.log(response.data.content);
115
115
  * ```
116
116
  */
117
- generate(options: GenerateRequestOptions, requestOptions?: RequestOptions): Promise<ApiResponse<GenerateResponse>>;
117
+ generate(options: GenerateRequestOptions, requestOptions?: RequestOptions): Promise<ClientApiResponse<GenerateResponse>>;
118
118
  /**
119
119
  * Stream text generation
120
120
  *
@@ -129,7 +129,7 @@ export declare class NeuroLinkClient {
129
129
  * );
130
130
  * ```
131
131
  */
132
- stream(options: StreamRequestOptions | GenerateRequestOptions, callbacks?: StreamCallbacks, requestOptions?: RequestOptions): Promise<StreamResult>;
132
+ stream(options: StreamRequestOptions | GenerateRequestOptions, callbacks?: StreamCallbacks, requestOptions?: RequestOptions): Promise<ClientStreamResult>;
133
133
  /**
134
134
  * Handle individual stream events
135
135
  */
@@ -147,19 +147,19 @@ export declare class NeuroLinkClient {
147
147
  * console.log(result.data.content);
148
148
  * ```
149
149
  */
150
- executeAgent(options: AgentExecuteOptions, requestOptions?: RequestOptions): Promise<ApiResponse<AgentExecuteResult>>;
150
+ executeAgent(options: AgentExecuteOptions, requestOptions?: RequestOptions): Promise<ClientApiResponse<AgentExecuteResult>>;
151
151
  /**
152
152
  * Stream agent execution
153
153
  */
154
- streamAgent(options: AgentExecuteOptions, callbacks?: StreamCallbacks, requestOptions?: RequestOptions): Promise<StreamResult>;
154
+ streamAgent(options: AgentExecuteOptions, callbacks?: StreamCallbacks, requestOptions?: RequestOptions): Promise<ClientStreamResult>;
155
155
  /**
156
156
  * List available agents
157
157
  */
158
- listAgents(requestOptions?: RequestOptions): Promise<ApiResponse<AgentInfo[]>>;
158
+ listAgents(requestOptions?: RequestOptions): Promise<ClientApiResponse<AgentInfo[]>>;
159
159
  /**
160
160
  * Get agent details
161
161
  */
162
- getAgent(agentId: string, requestOptions?: RequestOptions): Promise<ApiResponse<AgentInfo>>;
162
+ getAgent(agentId: string, requestOptions?: RequestOptions): Promise<ClientApiResponse<AgentInfo>>;
163
163
  /**
164
164
  * Execute a workflow
165
165
  *
@@ -179,29 +179,29 @@ export declare class NeuroLinkClient {
179
179
  * }
180
180
  * ```
181
181
  */
182
- executeWorkflow(options: WorkflowExecuteOptions, requestOptions?: RequestOptions): Promise<ApiResponse<WorkflowExecuteResult>>;
182
+ executeWorkflow(options: WorkflowExecuteOptions, requestOptions?: RequestOptions): Promise<ClientApiResponse<WorkflowExecuteResult>>;
183
183
  /**
184
184
  * Resume a suspended workflow
185
185
  */
186
- resumeWorkflow(workflowId: string, resumeToken: string, resumeData?: UnknownRecord, requestOptions?: RequestOptions): Promise<ApiResponse<WorkflowExecuteResult>>;
186
+ resumeWorkflow(workflowId: string, resumeToken: string, resumeData?: UnknownRecord, requestOptions?: RequestOptions): Promise<ClientApiResponse<WorkflowExecuteResult>>;
187
187
  /**
188
188
  * Get workflow execution status
189
189
  */
190
- getWorkflowStatus(workflowId: string, runId: string, requestOptions?: RequestOptions): Promise<ApiResponse<WorkflowExecuteResult>>;
190
+ getWorkflowStatus(workflowId: string, runId: string, requestOptions?: RequestOptions): Promise<ClientApiResponse<WorkflowExecuteResult>>;
191
191
  /**
192
192
  * Cancel workflow execution
193
193
  */
194
- cancelWorkflow(workflowId: string, runId: string, requestOptions?: RequestOptions): Promise<ApiResponse<{
194
+ cancelWorkflow(workflowId: string, runId: string, requestOptions?: RequestOptions): Promise<ClientApiResponse<{
195
195
  success: boolean;
196
196
  }>>;
197
197
  /**
198
198
  * List available workflows
199
199
  */
200
- listWorkflows(requestOptions?: RequestOptions): Promise<ApiResponse<WorkflowInfo[]>>;
200
+ listWorkflows(requestOptions?: RequestOptions): Promise<ClientApiResponse<WorkflowInfo[]>>;
201
201
  /**
202
202
  * Get workflow details
203
203
  */
204
- getWorkflow(workflowId: string, requestOptions?: RequestOptions): Promise<ApiResponse<WorkflowInfo>>;
204
+ getWorkflow(workflowId: string, requestOptions?: RequestOptions): Promise<ClientApiResponse<WorkflowInfo>>;
205
205
  /**
206
206
  * List available tools
207
207
  *
@@ -214,27 +214,27 @@ export declare class NeuroLinkClient {
214
214
  listTools(options?: {
215
215
  category?: string;
216
216
  serverId?: string;
217
- }, requestOptions?: RequestOptions): Promise<ApiResponse<ToolInfo[]>>;
217
+ }, requestOptions?: RequestOptions): Promise<ClientApiResponse<ToolInfo[]>>;
218
218
  /**
219
219
  * Execute a tool
220
220
  */
221
- executeTool(toolName: string, params: UnknownRecord, requestOptions?: RequestOptions): Promise<ApiResponse<unknown>>;
221
+ executeTool(toolName: string, params: UnknownRecord, requestOptions?: RequestOptions): Promise<ClientApiResponse<unknown>>;
222
222
  /**
223
223
  * Get tool details
224
224
  */
225
- getTool(toolName: string, requestOptions?: RequestOptions): Promise<ApiResponse<ToolInfo>>;
225
+ getTool(toolName: string, requestOptions?: RequestOptions): Promise<ClientApiResponse<ToolInfo>>;
226
226
  /**
227
227
  * List available providers
228
228
  */
229
- listProviders(requestOptions?: RequestOptions): Promise<ApiResponse<ProviderStatus[]>>;
229
+ listProviders(requestOptions?: RequestOptions): Promise<ClientApiResponse<ClientProviderStatus[]>>;
230
230
  /**
231
231
  * Get provider status
232
232
  */
233
- getProviderStatus(providerName: string, requestOptions?: RequestOptions): Promise<ApiResponse<ProviderStatus>>;
233
+ getProviderStatus(providerName: string, requestOptions?: RequestOptions): Promise<ClientApiResponse<ClientProviderStatus>>;
234
234
  /**
235
235
  * Health check
236
236
  */
237
- health(requestOptions?: RequestOptions): Promise<ApiResponse<{
237
+ health(requestOptions?: RequestOptions): Promise<ClientApiResponse<{
238
238
  status: string;
239
239
  version: string;
240
240
  }>>;
@@ -294,4 +294,4 @@ export declare class NeuroLinkClient {
294
294
  * ```
295
295
  */
296
296
  export declare function createClient(config: ClientConfig): NeuroLinkClient;
297
- export type { ClientConfig, RequestOptions, ApiResponse, ApiError, RetryConfig, Middleware, MiddlewareRequest, MiddlewareResponse, MiddlewareContext, StreamCallbacks, StreamEvent, StreamResult, GenerateRequestOptions, GenerateResponse, StreamRequestOptions, AgentExecuteOptions, AgentExecuteResult, AgentInfo, WorkflowExecuteOptions, WorkflowExecuteResult, WorkflowInfo, ToolInfo, ProviderStatus, WebSocketOptions, WebSocketState, WebSocketMessageHandler, };
297
+ export type { ClientConfig, RequestOptions, ClientApiResponse, ApiError, ClientRetryConfig, Middleware, MiddlewareRequest, MiddlewareResponse, ClientMiddlewareContext, StreamCallbacks, ClientStreamEvent, ClientStreamResult, GenerateRequestOptions, GenerateResponse, StreamRequestOptions, AgentExecuteOptions, AgentExecuteResult, AgentInfo, WorkflowExecuteOptions, WorkflowExecuteResult, WorkflowInfo, ToolInfo, ClientProviderStatus, WebSocketOptions, WebSocketState, WebSocketMessageHandler, };
@@ -92,10 +92,10 @@
92
92
  * ```
93
93
  */
94
94
  export { NeuroLinkClient, createClient, NeuroLinkApiError, } from "./httpClient.js";
95
- export type { ClientConfig, RequestOptions, ApiResponse, ApiError, RetryConfig, Middleware, MiddlewareRequest, MiddlewareResponse, MiddlewareContext, StreamCallbacks, StreamEvent, StreamEventType, StreamResult, GenerateRequestOptions, GenerateResponse, StreamRequestOptions, AgentExecuteOptions, AgentExecuteResult, AgentInfo, WorkflowExecuteOptions, WorkflowExecuteResult, WorkflowInfo, ToolInfo, ProviderStatus, WebSocketOptions, WebSocketState, WebSocketMessageHandler, } from "../types/clientTypes.js";
95
+ export type { ClientConfig, RequestOptions, ClientApiResponse as ApiResponse, ApiError, ClientRetryConfig as RetryConfig, Middleware, MiddlewareRequest, MiddlewareResponse, ClientMiddlewareContext as MiddlewareContext, StreamCallbacks, ClientStreamEvent as StreamEvent, StreamEventType, ClientStreamResult as StreamResult, GenerateRequestOptions, GenerateResponse, StreamRequestOptions, AgentExecuteOptions, AgentExecuteResult, AgentInfo, WorkflowExecuteOptions, WorkflowExecuteResult, WorkflowInfo, ToolInfo, ClientProviderStatus as ProviderStatus, WebSocketOptions, WebSocketState, WebSocketMessageHandler, } from "../types/clientTypes.js";
96
96
  export { NeuroLinkProvider, useNeuroLinkClient, useChat, useAgent, useWorkflow, useVoice, useStream, useTools, } from "./reactHooks.js";
97
97
  export type { NeuroLinkProviderProps } from "./reactHooks.js";
98
- export type { UseChatOptions, UseChatReturn, UseAgentOptions, UseAgentReturn, UseWorkflowOptions, UseWorkflowReturn, UseVoiceOptions, UseVoiceReturn, UseStreamOptions, UseStreamReturn, UseToolsOptions, UseToolsReturn, ChatMessage, NeuroLinkProviderOptions, ModelOptions, LanguageModel, LanguageModelCallOptions, LanguageModelResponse, LanguageModelStreamResponse, } from "../types/clientTypes.js";
98
+ export type { UseChatOptions, UseChatReturn, UseAgentOptions, UseAgentReturn, UseWorkflowOptions, UseWorkflowReturn, UseVoiceOptions, UseVoiceReturn, UseStreamOptions, UseStreamReturn, UseToolsOptions, UseToolsReturn, ClientChatMessage as ChatMessage, NeuroLinkProviderOptions, ModelOptions, LanguageModel, LanguageModelCallOptions, LanguageModelResponse, LanguageModelStreamResponse, } from "../types/clientTypes.js";
99
99
  export { NeuroLinkLanguageModel, NeuroLinkProvider as NeuroLinkAIProvider, createNeuroLinkProvider, createNeuroLinkModel, createStreamingResponse, neurolink, } from "./aiSdkAdapter.js";
100
100
  export { createApiKeyAuthInterceptor, createBearerAuthInterceptor, createDynamicAuthInterceptor, createLoggingInterceptor, createRetryInterceptor, createRateLimitInterceptor, createRequestTransformInterceptor, createResponseTransformInterceptor, createCacheInterceptor, createTimeoutInterceptor, createErrorHandlerInterceptor, composeMiddleware, conditionalMiddleware, } from "./interceptors.js";
101
101
  export type { LoggingInterceptorOptions, RetryInterceptorOptions, RateLimiterOptions, CacheInterceptorOptions, TimeoutInterceptorOptions, ErrorHandlerOptions, } from "./interceptors.js";
@@ -106,6 +106,6 @@ export type { WebSocketConfig, WebSocketMessage, WebSocketEventHandlers, WebSock
106
106
  export { NeuroLinkSSE, createSSEClient } from "./sseClient.js";
107
107
  export type { SSEConfig, SSERequestOptions, SSEEventHandlers, SSEState, } from "./sseClient.js";
108
108
  export { OAuth2TokenManager, JWTTokenManager, createApiKeyMiddleware, createBearerTokenMiddleware, createTokenManagerMiddleware, createAuthWithRetryMiddleware, createMultiAuthMiddleware, OAuth2Error, OAuth2AuthenticationError as OAuth2AuthError, TokenRefreshError, decodeJWTPayload, isJWTExpired, getJWTExpiry, getApiKeyFromEnv, } from "./auth.js";
109
- export type { AuthConfig, OAuth2Config, TokenRefreshResult, SpeechRecognitionResult, SpeechSynthesisOptions, JsonValue, JsonObject, UnknownRecord, ToolCall, ToolResult, } from "../types/clientTypes.js";
109
+ export type { AuthConfig, ClientOAuth2Config as OAuth2Config, ClientTokenRefreshResult as TokenRefreshResult, SpeechRecognitionResult, SpeechSynthesisOptions, JsonValue, JsonObject, UnknownRecord, ToolCall, ToolResult, } from "../types/clientTypes.js";
110
110
  export { ErrorCode, NeuroLinkError, HttpError, ClientRateLimitError, ClientValidationError, ClientAuthenticationError, ClientAuthorizationError, NotFoundError, ClientNetworkError, ClientTimeoutError, ClientConnectionError, AbortError, ClientConfigurationError, StreamError, ClientProviderError, ContextLengthError, ContentFilterError, createErrorFromResponse, createErrorFromNative, mapStatusToErrorCode, isRetryableStatus, isRetryableError, isNeuroLinkError, isApiError, } from "./errors.js";
111
111
  export type { ErrorCodeType } from "./errors.js";
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @module @neurolink/client/interceptors
8
8
  */
9
- import type { Middleware, MiddlewareRequest, MiddlewareResponse, MiddlewareContext, RetryConfig, ApiError } from "../types/clientTypes.js";
9
+ import type { Middleware, MiddlewareRequest, MiddlewareResponse, ClientMiddlewareContext as MiddlewareContext, ClientRetryConfig as RetryConfig, ApiError } from "../types/clientTypes.js";
10
10
  /**
11
11
  * API Key authentication interceptor
12
12
  *
@@ -15,7 +15,7 @@
15
15
  * @module @neurolink/react
16
16
  */
17
17
  import type { ReactNode } from "react";
18
- import type { NeuroLinkProviderProps, UseChatOptions, UseChatReturn, UseAgentOptions, UseAgentReturn, UseWorkflowOptions, UseWorkflowReturn, UseVoiceOptions, UseVoiceReturn, UseStreamOptions, UseStreamReturn, UseToolsOptions, UseToolsReturn, ChatMessage, SpeechRecognitionInternal } from "../types/clientTypes.js";
18
+ import type { NeuroLinkProviderProps, UseChatOptions, UseChatReturn, UseAgentOptions, UseAgentReturn, UseWorkflowOptions, UseWorkflowReturn, UseVoiceOptions, UseVoiceReturn, UseStreamOptions, UseStreamReturn, UseToolsOptions, UseToolsReturn, ClientChatMessage as ChatMessage, SpeechRecognitionInternal } from "../types/clientTypes.js";
19
19
  import { NeuroLinkClient } from "./httpClient.js";
20
20
  /**
21
21
  * Provider component for NeuroLink client
@@ -42,13 +42,13 @@ import type {
42
42
  UseStreamReturn,
43
43
  UseToolsOptions,
44
44
  UseToolsReturn,
45
- ChatMessage,
45
+ ClientChatMessage as ChatMessage,
46
46
  AgentExecuteOptions,
47
47
  AgentExecuteResult,
48
48
  WorkflowExecuteOptions,
49
49
  WorkflowExecuteResult,
50
50
  StreamCallbacks,
51
- StreamEvent,
51
+ ClientStreamEvent as StreamEvent,
52
52
  ToolInfo,
53
53
  SpeechRecognitionInternal,
54
54
  SpeechRecognitionEventInternal,
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * @module @neurolink/client/sseClient
9
9
  */
10
- import type { ClientConfig, StreamCallbacks, StreamEvent, StreamResult, ApiError } from "../types/clientTypes.js";
10
+ import type { ClientConfig, StreamCallbacks, ClientStreamEvent as StreamEvent, ClientStreamResult as StreamResult, ApiError } from "../types/clientTypes.js";
11
11
  /**
12
12
  * SSE connection state
13
13
  */
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @module @neurolink/client/streaming
8
8
  */
9
- import type { StreamEvent, StreamCallbacks, StreamResult, ApiError, WebSocketOptions, WebSocketState, WebSocketMessageHandler } from "../types/clientTypes.js";
9
+ import type { ClientStreamEvent as StreamEvent, StreamCallbacks, ClientStreamResult as StreamResult, ApiError, WebSocketOptions, WebSocketState, WebSocketMessageHandler } from "../types/clientTypes.js";
10
10
  import type { JsonObject, UnknownRecord } from "../types/common.js";
11
11
  import type { ToolCall, ToolResult } from "../types/streamTypes.js";
12
12
  /**
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * @module @neurolink/client/wsClient
9
9
  */
10
- import type { StreamCallbacks, StreamEvent, StreamResult, ApiError, WSClientState, WSClientConfig, WSClientMessage, WSClientEventHandlers } from "../types/clientTypes.js";
10
+ import type { StreamCallbacks, ClientStreamEvent as StreamEvent, ClientStreamResult as StreamResult, ApiError, WSClientState, WSClientConfig, WSClientMessage, WSClientEventHandlers } from "../types/clientTypes.js";
11
11
  /** @see WSClientState */
12
12
  export type WebSocketState = WSClientState;
13
13
  /** @see WSClientConfig */
@@ -173,7 +173,7 @@ export declare function createFileTools(registry: FileReferenceRegistry): {
173
173
  } | undefined;
174
174
  columns?: string[] | undefined;
175
175
  entry_path?: string | undefined;
176
- format?: "text" | "summary" | "detailed" | undefined;
176
+ format?: "detailed" | "text" | "summary" | undefined;
177
177
  }, {
178
178
  success: false;
179
179
  error: string | undefined;
@@ -101,7 +101,7 @@ export declare const directAgentTools: {
101
101
  writeFile: import("ai").Tool<{
102
102
  path: string;
103
103
  content: string;
104
- mode: "create" | "overwrite" | "append";
104
+ mode: "create" | "append" | "overwrite";
105
105
  }, {
106
106
  success: boolean;
107
107
  error: string;
@@ -112,7 +112,7 @@ export declare const directAgentTools: {
112
112
  } | {
113
113
  success: boolean;
114
114
  path: string;
115
- mode: "create" | "overwrite" | "append";
115
+ mode: "create" | "append" | "overwrite";
116
116
  size: number;
117
117
  written: number;
118
118
  error?: undefined;
@@ -148,7 +148,8 @@ export class TokenStore {
148
148
  ? this.obfuscate(JSON.stringify(storageData))
149
149
  : JSON.stringify(storageData, null, 2);
150
150
  // Write to temporary file first for atomic operation
151
- const tempPath = `${this.storagePath}.tmp`;
151
+ // Use PID-scoped temp file to avoid cross-process race conditions
152
+ const tempPath = `${this.storagePath}.tmp.${process.pid}`;
152
153
  await writeFile(tempPath, content, "utf-8");
153
154
  // Set restrictive permissions before moving to final location
154
155
  await chmod(tempPath, TokenStore.FILE_PERMISSIONS);
@@ -681,7 +682,8 @@ export class TokenStore {
681
682
  const content = this.encryptionEnabled
682
683
  ? this.obfuscate(JSON.stringify(data))
683
684
  : JSON.stringify(data, null, 2);
684
- const tmpPath = `${this.storagePath}.tmp`;
685
+ // Use PID-scoped temp file to avoid cross-process race conditions
686
+ const tmpPath = `${this.storagePath}.tmp.${process.pid}`;
685
687
  await writeFile(tmpPath, content, "utf-8");
686
688
  await chmod(tmpPath, TokenStore.FILE_PERMISSIONS);
687
689
  await rename(tmpPath, this.storagePath);
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @module @neurolink/client/auth
8
8
  */
9
- import type { Middleware, AuthConfig, OAuth2Config, TokenRefreshResult } from "../types/clientTypes.js";
9
+ import type { Middleware, AuthConfig, ClientOAuth2Config, ClientTokenRefreshResult } from "../types/clientTypes.js";
10
10
  /**
11
11
  * OAuth2 Token Manager for client credentials flow
12
12
  *
@@ -38,7 +38,7 @@ export declare class OAuth2TokenManager {
38
38
  private tokenExpiry;
39
39
  private refreshPromise;
40
40
  private refreshBufferMs;
41
- constructor(config: OAuth2Config, options?: {
41
+ constructor(config: ClientOAuth2Config, options?: {
42
42
  refreshBufferMs?: number;
43
43
  });
44
44
  /**
@@ -97,7 +97,7 @@ export declare class JWTTokenManager {
97
97
  constructor(config: {
98
98
  token: string;
99
99
  expiresAt: number;
100
- refreshFn: () => Promise<TokenRefreshResult>;
100
+ refreshFn: () => Promise<ClientTokenRefreshResult>;
101
101
  refreshBufferMs?: number;
102
102
  });
103
103
  /**
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @module @neurolink/client
8
8
  */
9
- import type { ClientConfig, RequestOptions, ApiResponse, ApiError, RetryConfig, Middleware, MiddlewareRequest, MiddlewareResponse, MiddlewareContext, StreamCallbacks, StreamEvent, StreamResult, GenerateRequestOptions, GenerateResponse, StreamRequestOptions, AgentExecuteOptions, AgentExecuteResult, AgentInfo, WorkflowExecuteOptions, WorkflowExecuteResult, WorkflowInfo, ToolInfo, ProviderStatus, WebSocketOptions, WebSocketState, WebSocketMessageHandler } from "../types/clientTypes.js";
9
+ import type { ClientConfig, RequestOptions, ClientApiResponse, ApiError, ClientRetryConfig, Middleware, MiddlewareRequest, MiddlewareResponse, ClientMiddlewareContext, StreamCallbacks, ClientStreamEvent, ClientStreamResult, GenerateRequestOptions, GenerateResponse, StreamRequestOptions, AgentExecuteOptions, AgentExecuteResult, AgentInfo, WorkflowExecuteOptions, WorkflowExecuteResult, WorkflowInfo, ToolInfo, ClientProviderStatus, WebSocketOptions, WebSocketState, WebSocketMessageHandler } from "../types/clientTypes.js";
10
10
  import type { UnknownRecord } from "../types/common.js";
11
11
  import { HttpError, ClientNetworkError, ClientTimeoutError } from "./errors.js";
12
12
  /**
@@ -114,7 +114,7 @@ export declare class NeuroLinkClient {
114
114
  * console.log(response.data.content);
115
115
  * ```
116
116
  */
117
- generate(options: GenerateRequestOptions, requestOptions?: RequestOptions): Promise<ApiResponse<GenerateResponse>>;
117
+ generate(options: GenerateRequestOptions, requestOptions?: RequestOptions): Promise<ClientApiResponse<GenerateResponse>>;
118
118
  /**
119
119
  * Stream text generation
120
120
  *
@@ -129,7 +129,7 @@ export declare class NeuroLinkClient {
129
129
  * );
130
130
  * ```
131
131
  */
132
- stream(options: StreamRequestOptions | GenerateRequestOptions, callbacks?: StreamCallbacks, requestOptions?: RequestOptions): Promise<StreamResult>;
132
+ stream(options: StreamRequestOptions | GenerateRequestOptions, callbacks?: StreamCallbacks, requestOptions?: RequestOptions): Promise<ClientStreamResult>;
133
133
  /**
134
134
  * Handle individual stream events
135
135
  */
@@ -147,19 +147,19 @@ export declare class NeuroLinkClient {
147
147
  * console.log(result.data.content);
148
148
  * ```
149
149
  */
150
- executeAgent(options: AgentExecuteOptions, requestOptions?: RequestOptions): Promise<ApiResponse<AgentExecuteResult>>;
150
+ executeAgent(options: AgentExecuteOptions, requestOptions?: RequestOptions): Promise<ClientApiResponse<AgentExecuteResult>>;
151
151
  /**
152
152
  * Stream agent execution
153
153
  */
154
- streamAgent(options: AgentExecuteOptions, callbacks?: StreamCallbacks, requestOptions?: RequestOptions): Promise<StreamResult>;
154
+ streamAgent(options: AgentExecuteOptions, callbacks?: StreamCallbacks, requestOptions?: RequestOptions): Promise<ClientStreamResult>;
155
155
  /**
156
156
  * List available agents
157
157
  */
158
- listAgents(requestOptions?: RequestOptions): Promise<ApiResponse<AgentInfo[]>>;
158
+ listAgents(requestOptions?: RequestOptions): Promise<ClientApiResponse<AgentInfo[]>>;
159
159
  /**
160
160
  * Get agent details
161
161
  */
162
- getAgent(agentId: string, requestOptions?: RequestOptions): Promise<ApiResponse<AgentInfo>>;
162
+ getAgent(agentId: string, requestOptions?: RequestOptions): Promise<ClientApiResponse<AgentInfo>>;
163
163
  /**
164
164
  * Execute a workflow
165
165
  *
@@ -179,29 +179,29 @@ export declare class NeuroLinkClient {
179
179
  * }
180
180
  * ```
181
181
  */
182
- executeWorkflow(options: WorkflowExecuteOptions, requestOptions?: RequestOptions): Promise<ApiResponse<WorkflowExecuteResult>>;
182
+ executeWorkflow(options: WorkflowExecuteOptions, requestOptions?: RequestOptions): Promise<ClientApiResponse<WorkflowExecuteResult>>;
183
183
  /**
184
184
  * Resume a suspended workflow
185
185
  */
186
- resumeWorkflow(workflowId: string, resumeToken: string, resumeData?: UnknownRecord, requestOptions?: RequestOptions): Promise<ApiResponse<WorkflowExecuteResult>>;
186
+ resumeWorkflow(workflowId: string, resumeToken: string, resumeData?: UnknownRecord, requestOptions?: RequestOptions): Promise<ClientApiResponse<WorkflowExecuteResult>>;
187
187
  /**
188
188
  * Get workflow execution status
189
189
  */
190
- getWorkflowStatus(workflowId: string, runId: string, requestOptions?: RequestOptions): Promise<ApiResponse<WorkflowExecuteResult>>;
190
+ getWorkflowStatus(workflowId: string, runId: string, requestOptions?: RequestOptions): Promise<ClientApiResponse<WorkflowExecuteResult>>;
191
191
  /**
192
192
  * Cancel workflow execution
193
193
  */
194
- cancelWorkflow(workflowId: string, runId: string, requestOptions?: RequestOptions): Promise<ApiResponse<{
194
+ cancelWorkflow(workflowId: string, runId: string, requestOptions?: RequestOptions): Promise<ClientApiResponse<{
195
195
  success: boolean;
196
196
  }>>;
197
197
  /**
198
198
  * List available workflows
199
199
  */
200
- listWorkflows(requestOptions?: RequestOptions): Promise<ApiResponse<WorkflowInfo[]>>;
200
+ listWorkflows(requestOptions?: RequestOptions): Promise<ClientApiResponse<WorkflowInfo[]>>;
201
201
  /**
202
202
  * Get workflow details
203
203
  */
204
- getWorkflow(workflowId: string, requestOptions?: RequestOptions): Promise<ApiResponse<WorkflowInfo>>;
204
+ getWorkflow(workflowId: string, requestOptions?: RequestOptions): Promise<ClientApiResponse<WorkflowInfo>>;
205
205
  /**
206
206
  * List available tools
207
207
  *
@@ -214,27 +214,27 @@ export declare class NeuroLinkClient {
214
214
  listTools(options?: {
215
215
  category?: string;
216
216
  serverId?: string;
217
- }, requestOptions?: RequestOptions): Promise<ApiResponse<ToolInfo[]>>;
217
+ }, requestOptions?: RequestOptions): Promise<ClientApiResponse<ToolInfo[]>>;
218
218
  /**
219
219
  * Execute a tool
220
220
  */
221
- executeTool(toolName: string, params: UnknownRecord, requestOptions?: RequestOptions): Promise<ApiResponse<unknown>>;
221
+ executeTool(toolName: string, params: UnknownRecord, requestOptions?: RequestOptions): Promise<ClientApiResponse<unknown>>;
222
222
  /**
223
223
  * Get tool details
224
224
  */
225
- getTool(toolName: string, requestOptions?: RequestOptions): Promise<ApiResponse<ToolInfo>>;
225
+ getTool(toolName: string, requestOptions?: RequestOptions): Promise<ClientApiResponse<ToolInfo>>;
226
226
  /**
227
227
  * List available providers
228
228
  */
229
- listProviders(requestOptions?: RequestOptions): Promise<ApiResponse<ProviderStatus[]>>;
229
+ listProviders(requestOptions?: RequestOptions): Promise<ClientApiResponse<ClientProviderStatus[]>>;
230
230
  /**
231
231
  * Get provider status
232
232
  */
233
- getProviderStatus(providerName: string, requestOptions?: RequestOptions): Promise<ApiResponse<ProviderStatus>>;
233
+ getProviderStatus(providerName: string, requestOptions?: RequestOptions): Promise<ClientApiResponse<ClientProviderStatus>>;
234
234
  /**
235
235
  * Health check
236
236
  */
237
- health(requestOptions?: RequestOptions): Promise<ApiResponse<{
237
+ health(requestOptions?: RequestOptions): Promise<ClientApiResponse<{
238
238
  status: string;
239
239
  version: string;
240
240
  }>>;
@@ -294,4 +294,4 @@ export declare class NeuroLinkClient {
294
294
  * ```
295
295
  */
296
296
  export declare function createClient(config: ClientConfig): NeuroLinkClient;
297
- export type { ClientConfig, RequestOptions, ApiResponse, ApiError, RetryConfig, Middleware, MiddlewareRequest, MiddlewareResponse, MiddlewareContext, StreamCallbacks, StreamEvent, StreamResult, GenerateRequestOptions, GenerateResponse, StreamRequestOptions, AgentExecuteOptions, AgentExecuteResult, AgentInfo, WorkflowExecuteOptions, WorkflowExecuteResult, WorkflowInfo, ToolInfo, ProviderStatus, WebSocketOptions, WebSocketState, WebSocketMessageHandler, };
297
+ export type { ClientConfig, RequestOptions, ClientApiResponse, ApiError, ClientRetryConfig, Middleware, MiddlewareRequest, MiddlewareResponse, ClientMiddlewareContext, StreamCallbacks, ClientStreamEvent, ClientStreamResult, GenerateRequestOptions, GenerateResponse, StreamRequestOptions, AgentExecuteOptions, AgentExecuteResult, AgentInfo, WorkflowExecuteOptions, WorkflowExecuteResult, WorkflowInfo, ToolInfo, ClientProviderStatus, WebSocketOptions, WebSocketState, WebSocketMessageHandler, };