@juspay/neurolink 9.40.0 → 9.42.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/README.md +7 -1
- package/dist/auth/anthropicOAuth.d.ts +18 -3
- package/dist/auth/anthropicOAuth.js +137 -4
- package/dist/auth/providers/firebase.js +5 -1
- package/dist/auth/providers/jwt.js +5 -1
- package/dist/auth/providers/workos.js +5 -1
- package/dist/auth/sessionManager.d.ts +1 -1
- package/dist/auth/sessionManager.js +58 -27
- package/dist/browser/neurolink.min.js +471 -445
- package/dist/cli/commands/mcp.js +3 -0
- package/dist/cli/commands/proxy.d.ts +2 -1
- package/dist/cli/commands/proxy.js +279 -16
- package/dist/cli/commands/task.d.ts +56 -0
- package/dist/cli/commands/task.js +838 -0
- package/dist/cli/factories/commandFactory.d.ts +2 -0
- package/dist/cli/factories/commandFactory.js +38 -0
- package/dist/cli/parser.js +8 -4
- package/dist/client/aiSdkAdapter.js +3 -0
- package/dist/client/streamingClient.js +30 -10
- package/dist/core/modules/GenerationHandler.js +3 -2
- package/dist/core/redisConversationMemoryManager.js +7 -3
- package/dist/evaluation/BatchEvaluator.js +4 -1
- package/dist/evaluation/hooks/observabilityHooks.js +5 -3
- package/dist/evaluation/pipeline/evaluationPipeline.d.ts +3 -2
- package/dist/evaluation/pipeline/evaluationPipeline.js +20 -8
- package/dist/evaluation/pipeline/strategies/batchStrategy.js +6 -3
- package/dist/evaluation/pipeline/strategies/samplingStrategy.js +18 -10
- package/dist/lib/auth/anthropicOAuth.d.ts +18 -3
- package/dist/lib/auth/anthropicOAuth.js +137 -4
- package/dist/lib/auth/providers/firebase.js +5 -1
- package/dist/lib/auth/providers/jwt.js +5 -1
- package/dist/lib/auth/providers/workos.js +5 -1
- package/dist/lib/auth/sessionManager.d.ts +1 -1
- package/dist/lib/auth/sessionManager.js +58 -27
- package/dist/lib/client/aiSdkAdapter.js +3 -0
- package/dist/lib/client/streamingClient.js +30 -10
- package/dist/lib/core/modules/GenerationHandler.js +3 -2
- package/dist/lib/core/redisConversationMemoryManager.js +7 -3
- package/dist/lib/evaluation/BatchEvaluator.js +4 -1
- package/dist/lib/evaluation/hooks/observabilityHooks.js +5 -3
- package/dist/lib/evaluation/pipeline/evaluationPipeline.d.ts +3 -2
- package/dist/lib/evaluation/pipeline/evaluationPipeline.js +20 -8
- package/dist/lib/evaluation/pipeline/strategies/batchStrategy.js +6 -3
- package/dist/lib/evaluation/pipeline/strategies/samplingStrategy.js +18 -10
- package/dist/lib/neurolink.d.ts +18 -1
- package/dist/lib/neurolink.js +367 -484
- package/dist/lib/observability/otelBridge.d.ts +2 -2
- package/dist/lib/observability/otelBridge.js +12 -3
- package/dist/lib/providers/amazonBedrock.js +2 -4
- package/dist/lib/providers/anthropic.d.ts +9 -5
- package/dist/lib/providers/anthropic.js +19 -14
- package/dist/lib/providers/anthropicBaseProvider.d.ts +3 -3
- package/dist/lib/providers/anthropicBaseProvider.js +5 -4
- package/dist/lib/providers/azureOpenai.d.ts +1 -1
- package/dist/lib/providers/azureOpenai.js +5 -4
- package/dist/lib/providers/googleAiStudio.js +30 -1
- package/dist/lib/providers/googleVertex.js +28 -6
- package/dist/lib/providers/huggingFace.d.ts +3 -3
- package/dist/lib/providers/huggingFace.js +6 -8
- package/dist/lib/providers/litellm.js +41 -29
- package/dist/lib/providers/mistral.js +2 -1
- package/dist/lib/providers/ollama.js +80 -23
- package/dist/lib/providers/openAI.js +3 -2
- package/dist/lib/providers/openRouter.js +2 -1
- package/dist/lib/providers/openaiCompatible.d.ts +4 -4
- package/dist/lib/providers/openaiCompatible.js +4 -4
- package/dist/lib/proxy/claudeFormat.d.ts +3 -2
- package/dist/lib/proxy/claudeFormat.js +25 -20
- package/dist/lib/proxy/cloaking/plugins/sessionIdentity.d.ts +2 -6
- package/dist/lib/proxy/cloaking/plugins/sessionIdentity.js +9 -33
- package/dist/lib/proxy/modelRouter.js +3 -0
- package/dist/lib/proxy/oauthFetch.d.ts +1 -1
- package/dist/lib/proxy/oauthFetch.js +65 -72
- package/dist/lib/proxy/proxyConfig.js +44 -24
- package/dist/lib/proxy/proxyEnv.d.ts +19 -0
- package/dist/lib/proxy/proxyEnv.js +73 -0
- package/dist/lib/proxy/proxyFetch.js +50 -4
- package/dist/lib/proxy/proxyTracer.d.ts +133 -0
- package/dist/lib/proxy/proxyTracer.js +645 -0
- package/dist/lib/proxy/rawStreamCapture.d.ts +10 -0
- package/dist/lib/proxy/rawStreamCapture.js +83 -0
- package/dist/lib/proxy/requestLogger.d.ts +32 -5
- package/dist/lib/proxy/requestLogger.js +406 -37
- package/dist/lib/proxy/sseInterceptor.d.ts +97 -0
- package/dist/lib/proxy/sseInterceptor.js +402 -0
- package/dist/lib/proxy/usageStats.d.ts +4 -3
- package/dist/lib/proxy/usageStats.js +25 -12
- package/dist/lib/rag/chunkers/MarkdownChunker.js +13 -5
- package/dist/lib/rag/chunking/markdownChunker.js +15 -6
- package/dist/lib/server/routes/claudeProxyRoutes.d.ts +7 -2
- package/dist/lib/server/routes/claudeProxyRoutes.js +1737 -508
- package/dist/lib/services/server/ai/observability/instrumentation.d.ts +7 -1
- package/dist/lib/services/server/ai/observability/instrumentation.js +240 -40
- package/dist/lib/tasks/backends/bullmqBackend.d.ts +33 -0
- package/dist/lib/tasks/backends/bullmqBackend.js +196 -0
- package/dist/lib/tasks/backends/nodeTimeoutBackend.d.ts +27 -0
- package/dist/lib/tasks/backends/nodeTimeoutBackend.js +141 -0
- package/dist/lib/tasks/backends/taskBackendRegistry.d.ts +31 -0
- package/dist/lib/tasks/backends/taskBackendRegistry.js +66 -0
- package/dist/lib/tasks/errors.d.ts +31 -0
- package/dist/lib/tasks/errors.js +18 -0
- package/dist/lib/tasks/store/fileTaskStore.d.ts +43 -0
- package/dist/lib/tasks/store/fileTaskStore.js +179 -0
- package/dist/lib/tasks/store/redisTaskStore.d.ts +43 -0
- package/dist/lib/tasks/store/redisTaskStore.js +197 -0
- package/dist/lib/tasks/taskExecutor.d.ts +21 -0
- package/dist/lib/tasks/taskExecutor.js +166 -0
- package/dist/lib/tasks/taskManager.d.ts +63 -0
- package/dist/lib/tasks/taskManager.js +426 -0
- package/dist/lib/tasks/tools/taskTools.d.ts +135 -0
- package/dist/lib/tasks/tools/taskTools.js +274 -0
- package/dist/lib/telemetry/index.d.ts +2 -1
- package/dist/lib/telemetry/index.js +2 -1
- package/dist/lib/telemetry/telemetryService.d.ts +3 -0
- package/dist/lib/telemetry/telemetryService.js +65 -5
- package/dist/lib/types/cli.d.ts +10 -0
- package/dist/lib/types/configTypes.d.ts +3 -0
- package/dist/lib/types/generateTypes.d.ts +13 -0
- package/dist/lib/types/index.d.ts +1 -0
- package/dist/lib/types/proxyTypes.d.ts +37 -5
- package/dist/lib/types/streamTypes.d.ts +25 -3
- package/dist/lib/types/taskTypes.d.ts +275 -0
- package/dist/lib/types/taskTypes.js +37 -0
- package/dist/lib/utils/messageBuilder.js +3 -2
- package/dist/lib/utils/providerHealth.d.ts +18 -0
- package/dist/lib/utils/providerHealth.js +240 -9
- package/dist/lib/utils/providerUtils.js +14 -8
- package/dist/lib/utils/toolChoice.d.ts +4 -0
- package/dist/lib/utils/toolChoice.js +7 -0
- package/dist/neurolink.d.ts +18 -1
- package/dist/neurolink.js +367 -484
- package/dist/observability/otelBridge.d.ts +2 -2
- package/dist/observability/otelBridge.js +12 -3
- package/dist/providers/amazonBedrock.js +2 -4
- package/dist/providers/anthropic.d.ts +9 -5
- package/dist/providers/anthropic.js +19 -14
- package/dist/providers/anthropicBaseProvider.d.ts +3 -3
- package/dist/providers/anthropicBaseProvider.js +5 -4
- package/dist/providers/azureOpenai.d.ts +1 -1
- package/dist/providers/azureOpenai.js +5 -4
- package/dist/providers/googleAiStudio.js +30 -1
- package/dist/providers/googleVertex.js +28 -6
- package/dist/providers/huggingFace.d.ts +3 -3
- package/dist/providers/huggingFace.js +6 -7
- package/dist/providers/litellm.js +41 -29
- package/dist/providers/mistral.js +2 -1
- package/dist/providers/ollama.js +80 -23
- package/dist/providers/openAI.js +3 -2
- package/dist/providers/openRouter.js +2 -1
- package/dist/providers/openaiCompatible.d.ts +4 -4
- package/dist/providers/openaiCompatible.js +4 -3
- package/dist/proxy/claudeFormat.d.ts +3 -2
- package/dist/proxy/claudeFormat.js +25 -20
- package/dist/proxy/cloaking/plugins/sessionIdentity.d.ts +2 -6
- package/dist/proxy/cloaking/plugins/sessionIdentity.js +9 -33
- package/dist/proxy/modelRouter.js +3 -0
- package/dist/proxy/oauthFetch.d.ts +1 -1
- package/dist/proxy/oauthFetch.js +65 -72
- package/dist/proxy/proxyConfig.js +44 -24
- package/dist/proxy/proxyEnv.d.ts +19 -0
- package/dist/proxy/proxyEnv.js +72 -0
- package/dist/proxy/proxyFetch.js +50 -4
- package/dist/proxy/proxyTracer.d.ts +133 -0
- package/dist/proxy/proxyTracer.js +644 -0
- package/dist/proxy/rawStreamCapture.d.ts +10 -0
- package/dist/proxy/rawStreamCapture.js +82 -0
- package/dist/proxy/requestLogger.d.ts +32 -5
- package/dist/proxy/requestLogger.js +406 -37
- package/dist/proxy/sseInterceptor.d.ts +97 -0
- package/dist/proxy/sseInterceptor.js +401 -0
- package/dist/proxy/usageStats.d.ts +4 -3
- package/dist/proxy/usageStats.js +25 -12
- package/dist/rag/chunkers/MarkdownChunker.js +13 -5
- package/dist/rag/chunking/markdownChunker.js +15 -6
- package/dist/server/routes/claudeProxyRoutes.d.ts +7 -2
- package/dist/server/routes/claudeProxyRoutes.js +1737 -508
- package/dist/services/server/ai/observability/instrumentation.d.ts +7 -1
- package/dist/services/server/ai/observability/instrumentation.js +240 -40
- package/dist/tasks/backends/bullmqBackend.d.ts +33 -0
- package/dist/tasks/backends/bullmqBackend.js +195 -0
- package/dist/tasks/backends/nodeTimeoutBackend.d.ts +27 -0
- package/dist/tasks/backends/nodeTimeoutBackend.js +140 -0
- package/dist/tasks/backends/taskBackendRegistry.d.ts +31 -0
- package/dist/tasks/backends/taskBackendRegistry.js +65 -0
- package/dist/tasks/errors.d.ts +31 -0
- package/dist/tasks/errors.js +17 -0
- package/dist/tasks/store/fileTaskStore.d.ts +43 -0
- package/dist/tasks/store/fileTaskStore.js +178 -0
- package/dist/tasks/store/redisTaskStore.d.ts +43 -0
- package/dist/tasks/store/redisTaskStore.js +196 -0
- package/dist/tasks/taskExecutor.d.ts +21 -0
- package/dist/tasks/taskExecutor.js +165 -0
- package/dist/tasks/taskManager.d.ts +63 -0
- package/dist/tasks/taskManager.js +425 -0
- package/dist/tasks/tools/taskTools.d.ts +135 -0
- package/dist/tasks/tools/taskTools.js +273 -0
- package/dist/telemetry/index.d.ts +2 -1
- package/dist/telemetry/index.js +2 -1
- package/dist/telemetry/telemetryService.d.ts +3 -0
- package/dist/telemetry/telemetryService.js +65 -5
- package/dist/types/cli.d.ts +10 -0
- package/dist/types/configTypes.d.ts +3 -0
- package/dist/types/generateTypes.d.ts +13 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/proxyTypes.d.ts +37 -5
- package/dist/types/streamTypes.d.ts +25 -3
- package/dist/types/taskTypes.d.ts +275 -0
- package/dist/types/taskTypes.js +36 -0
- package/dist/utils/messageBuilder.js +3 -2
- package/dist/utils/providerHealth.d.ts +18 -0
- package/dist/utils/providerHealth.js +240 -9
- package/dist/utils/providerUtils.js +14 -8
- package/dist/utils/toolChoice.d.ts +4 -0
- package/dist/utils/toolChoice.js +6 -0
- package/docs/assets/dashboards/neurolink-proxy-observability-dashboard.json +6609 -0
- package/docs/changelog.md +252 -0
- package/package.json +19 -1
- package/scripts/observability/check-proxy-telemetry.mjs +235 -0
- package/scripts/observability/docker-compose.proxy-observability.yaml +55 -0
- package/scripts/observability/import-openobserve-dashboard.mjs +240 -0
- package/scripts/observability/manage-local-openobserve.sh +184 -0
- package/scripts/observability/otel-collector.proxy-observability.yaml +78 -0
- package/scripts/observability/proxy-observability.env.example +23 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in agent tools for TaskManager.
|
|
3
|
+
*
|
|
4
|
+
* These tools allow the AI to self-schedule, manage, and inspect tasks
|
|
5
|
+
* during conversations. Created per-instance via `createTaskTools()` factory,
|
|
6
|
+
* following the same pattern as `createFileTools()` in files/fileTools.ts.
|
|
7
|
+
*
|
|
8
|
+
* @module tasks/tools/taskTools
|
|
9
|
+
*/
|
|
10
|
+
import { tool } from "ai";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
import { logger } from "../../utils/logger.js";
|
|
13
|
+
import { TaskError } from "../errors.js";
|
|
14
|
+
/**
|
|
15
|
+
* Parse a schedule object from tool input.
|
|
16
|
+
* Accepts: { type: "cron", expression } | { type: "interval", every } | { type: "once", at }
|
|
17
|
+
*/
|
|
18
|
+
function parseSchedule(input) {
|
|
19
|
+
const type = input.type;
|
|
20
|
+
if (type === "cron") {
|
|
21
|
+
if (!input.expression || typeof input.expression !== "string") {
|
|
22
|
+
throw TaskError.create("SCHEDULE_FAILED", "Cron schedule requires an 'expression' field");
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
type: "cron",
|
|
26
|
+
expression: input.expression,
|
|
27
|
+
...(input.timezone ? { timezone: input.timezone } : {}),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (type === "interval") {
|
|
31
|
+
if (typeof input.every !== "number" ||
|
|
32
|
+
!isFinite(input.every) ||
|
|
33
|
+
input.every <= 0) {
|
|
34
|
+
throw TaskError.create("SCHEDULE_FAILED", "Interval schedule requires a positive 'every' field (milliseconds)");
|
|
35
|
+
}
|
|
36
|
+
return { type: "interval", every: input.every };
|
|
37
|
+
}
|
|
38
|
+
if (type === "once") {
|
|
39
|
+
if (!input.at) {
|
|
40
|
+
throw TaskError.create("SCHEDULE_FAILED", "Once schedule requires an 'at' field (ISO 8601 date string)");
|
|
41
|
+
}
|
|
42
|
+
return { type: "once", at: input.at };
|
|
43
|
+
}
|
|
44
|
+
throw TaskError.create("SCHEDULE_FAILED", `Invalid schedule type: "${type}". Must be "cron", "interval", or "once".`);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Create task management tools bound to a TaskManager instance.
|
|
48
|
+
*
|
|
49
|
+
* These tools follow the same factory pattern as `createFileTools()` in
|
|
50
|
+
* `src/lib/files/fileTools.ts`. The `manager` is captured via closure,
|
|
51
|
+
* eliminating the need for module-level singleton state.
|
|
52
|
+
*
|
|
53
|
+
* @param manager - The TaskManager instance to bind to
|
|
54
|
+
* @returns Record of tool name to tool definition
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* const manager = new TaskManager(neurolink, config);
|
|
59
|
+
* const tools = createTaskTools(manager);
|
|
60
|
+
* // tools.createTask, tools.listTasks, tools.getTaskRuns, etc.
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export function createTaskTools(manager) {
|
|
64
|
+
return {
|
|
65
|
+
createTask: tool({
|
|
66
|
+
description: 'Schedule a recurring or one-shot task that runs a prompt on a schedule. Use schedule type "cron" for calendar-based (e.g. "0 9 * * *"), "interval" for fixed frequency (every N milliseconds), or "once" for a single future execution.',
|
|
67
|
+
inputSchema: z.object({
|
|
68
|
+
name: z.string().describe("Human-readable task name"),
|
|
69
|
+
prompt: z.string().describe("The prompt to execute on each run"),
|
|
70
|
+
schedule: z
|
|
71
|
+
.object({
|
|
72
|
+
type: z.enum(["cron", "interval", "once"]),
|
|
73
|
+
expression: z
|
|
74
|
+
.string()
|
|
75
|
+
.optional()
|
|
76
|
+
.describe('Cron expression (for type "cron"), e.g. "0 9 * * *"'),
|
|
77
|
+
timezone: z
|
|
78
|
+
.string()
|
|
79
|
+
.optional()
|
|
80
|
+
.describe('IANA timezone for cron, e.g. "America/New_York"'),
|
|
81
|
+
every: z
|
|
82
|
+
.number()
|
|
83
|
+
.optional()
|
|
84
|
+
.describe('Interval in milliseconds (for type "interval")'),
|
|
85
|
+
at: z
|
|
86
|
+
.string()
|
|
87
|
+
.optional()
|
|
88
|
+
.describe('ISO 8601 timestamp (for type "once")'),
|
|
89
|
+
})
|
|
90
|
+
.describe("When to run the task"),
|
|
91
|
+
mode: z
|
|
92
|
+
.enum(["isolated", "continuation"])
|
|
93
|
+
.optional()
|
|
94
|
+
.describe('Execution mode. "isolated" = fresh context per run (default). "continuation" = preserves conversation history across runs.'),
|
|
95
|
+
}),
|
|
96
|
+
execute: async ({ name, prompt, schedule, mode }) => {
|
|
97
|
+
try {
|
|
98
|
+
const parsedSchedule = parseSchedule(schedule);
|
|
99
|
+
const task = await manager.create({
|
|
100
|
+
name,
|
|
101
|
+
prompt,
|
|
102
|
+
schedule: parsedSchedule,
|
|
103
|
+
mode: mode,
|
|
104
|
+
});
|
|
105
|
+
return {
|
|
106
|
+
success: true,
|
|
107
|
+
taskId: task.id,
|
|
108
|
+
name: task.name,
|
|
109
|
+
status: task.status,
|
|
110
|
+
mode: task.mode,
|
|
111
|
+
nextRunAt: task.nextRunAt,
|
|
112
|
+
schedule: task.schedule,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
logger.error("[taskTools] createTask failed", {
|
|
117
|
+
error: String(error),
|
|
118
|
+
});
|
|
119
|
+
return {
|
|
120
|
+
success: false,
|
|
121
|
+
error: error instanceof Error ? error.message : String(error),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
}),
|
|
126
|
+
listTasks: tool({
|
|
127
|
+
description: "List all scheduled tasks and their current status.",
|
|
128
|
+
inputSchema: z.object({
|
|
129
|
+
status: z
|
|
130
|
+
.enum([
|
|
131
|
+
"active",
|
|
132
|
+
"paused",
|
|
133
|
+
"completed",
|
|
134
|
+
"failed",
|
|
135
|
+
"cancelled",
|
|
136
|
+
"pending",
|
|
137
|
+
])
|
|
138
|
+
.optional()
|
|
139
|
+
.describe("Filter by task status"),
|
|
140
|
+
}),
|
|
141
|
+
execute: async ({ status }) => {
|
|
142
|
+
try {
|
|
143
|
+
const tasks = await manager.list(status
|
|
144
|
+
? {
|
|
145
|
+
status: status,
|
|
146
|
+
}
|
|
147
|
+
: undefined);
|
|
148
|
+
return {
|
|
149
|
+
success: true,
|
|
150
|
+
count: tasks.length,
|
|
151
|
+
tasks: tasks.map((t) => ({
|
|
152
|
+
taskId: t.id,
|
|
153
|
+
name: t.name,
|
|
154
|
+
status: t.status,
|
|
155
|
+
mode: t.mode,
|
|
156
|
+
schedule: t.schedule,
|
|
157
|
+
runCount: t.runCount,
|
|
158
|
+
lastRunAt: t.lastRunAt,
|
|
159
|
+
nextRunAt: t.nextRunAt,
|
|
160
|
+
})),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
logger.error("[taskTools] listTasks failed", {
|
|
165
|
+
error: String(error),
|
|
166
|
+
});
|
|
167
|
+
return {
|
|
168
|
+
success: false,
|
|
169
|
+
error: error instanceof Error ? error.message : String(error),
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
}),
|
|
174
|
+
getTaskRuns: tool({
|
|
175
|
+
description: "Get the run history of a scheduled task, showing recent executions and their results.",
|
|
176
|
+
inputSchema: z.object({
|
|
177
|
+
taskId: z.string().describe("The task ID"),
|
|
178
|
+
limit: z
|
|
179
|
+
.number()
|
|
180
|
+
.optional()
|
|
181
|
+
.describe("Max results to return (default: 10)"),
|
|
182
|
+
}),
|
|
183
|
+
execute: async ({ taskId, limit }) => {
|
|
184
|
+
try {
|
|
185
|
+
const runs = await manager.runs(taskId, { limit: limit ?? 10 });
|
|
186
|
+
return {
|
|
187
|
+
success: true,
|
|
188
|
+
taskId,
|
|
189
|
+
count: runs.length,
|
|
190
|
+
runs: runs.map((r) => ({
|
|
191
|
+
runId: r.runId,
|
|
192
|
+
status: r.status,
|
|
193
|
+
output: r.output
|
|
194
|
+
? r.output.length > 500
|
|
195
|
+
? r.output.slice(0, 500) + "..."
|
|
196
|
+
: r.output
|
|
197
|
+
: undefined,
|
|
198
|
+
durationMs: r.durationMs,
|
|
199
|
+
timestamp: r.timestamp,
|
|
200
|
+
error: r.error,
|
|
201
|
+
})),
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
logger.error("[taskTools] getTaskRuns failed", {
|
|
206
|
+
error: String(error),
|
|
207
|
+
});
|
|
208
|
+
return {
|
|
209
|
+
success: false,
|
|
210
|
+
error: error instanceof Error ? error.message : String(error),
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
}),
|
|
215
|
+
deleteTask: tool({
|
|
216
|
+
description: "Cancel and permanently remove a scheduled task.",
|
|
217
|
+
inputSchema: z.object({
|
|
218
|
+
taskId: z.string().describe("The task ID to delete"),
|
|
219
|
+
}),
|
|
220
|
+
execute: async ({ taskId }) => {
|
|
221
|
+
try {
|
|
222
|
+
const task = await manager.get(taskId);
|
|
223
|
+
if (!task) {
|
|
224
|
+
return { success: false, error: `Task not found: ${taskId}` };
|
|
225
|
+
}
|
|
226
|
+
await manager.delete(taskId);
|
|
227
|
+
return { success: true, deletedTask: task.name, taskId };
|
|
228
|
+
}
|
|
229
|
+
catch (error) {
|
|
230
|
+
logger.error("[taskTools] deleteTask failed", {
|
|
231
|
+
error: String(error),
|
|
232
|
+
});
|
|
233
|
+
return {
|
|
234
|
+
success: false,
|
|
235
|
+
error: error instanceof Error ? error.message : String(error),
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
}),
|
|
240
|
+
runTaskNow: tool({
|
|
241
|
+
description: "Immediately execute a scheduled task outside of its normal schedule. Returns the run result.",
|
|
242
|
+
inputSchema: z.object({
|
|
243
|
+
taskId: z.string().describe("The task ID to run"),
|
|
244
|
+
}),
|
|
245
|
+
execute: async ({ taskId }) => {
|
|
246
|
+
try {
|
|
247
|
+
const result = await manager.run(taskId);
|
|
248
|
+
return {
|
|
249
|
+
success: true,
|
|
250
|
+
runId: result.runId,
|
|
251
|
+
status: result.status,
|
|
252
|
+
output: result.output
|
|
253
|
+
? result.output.length > 1000
|
|
254
|
+
? result.output.slice(0, 1000) + "..."
|
|
255
|
+
: result.output
|
|
256
|
+
: undefined,
|
|
257
|
+
durationMs: result.durationMs,
|
|
258
|
+
error: result.error,
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
catch (error) {
|
|
262
|
+
logger.error("[taskTools] runTaskNow failed", {
|
|
263
|
+
error: String(error),
|
|
264
|
+
});
|
|
265
|
+
return {
|
|
266
|
+
success: false,
|
|
267
|
+
error: error instanceof Error ? error.message : String(error),
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
}),
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
//# sourceMappingURL=taskTools.js.map
|
|
@@ -4,7 +4,8 @@ export { withSpan, withClientSpan, type SpanOptions } from "./withSpan.js";
|
|
|
4
4
|
export { ATTR } from "./attributes.js";
|
|
5
5
|
/**
|
|
6
6
|
* Initialize telemetry for NeuroLink
|
|
7
|
-
*
|
|
7
|
+
* Reuses an existing global TracerProvider when one is already registered,
|
|
8
|
+
* otherwise bootstraps Neurolink telemetry when an exporter endpoint is configured.
|
|
8
9
|
*/
|
|
9
10
|
export declare function initializeTelemetry(): Promise<import("./telemetryService.js").TelemetryService>;
|
|
10
11
|
/**
|
|
@@ -6,7 +6,8 @@ export { ATTR } from "./attributes.js";
|
|
|
6
6
|
import { logger } from "../utils/logger.js";
|
|
7
7
|
/**
|
|
8
8
|
* Initialize telemetry for NeuroLink
|
|
9
|
-
*
|
|
9
|
+
* Reuses an existing global TracerProvider when one is already registered,
|
|
10
|
+
* otherwise bootstraps Neurolink telemetry when an exporter endpoint is configured.
|
|
10
11
|
*/
|
|
11
12
|
export async function initializeTelemetry() {
|
|
12
13
|
const { TelemetryService } = await import("./telemetryService.js");
|
|
@@ -11,6 +11,7 @@ export declare class TelemetryService {
|
|
|
11
11
|
private tracerProvider?;
|
|
12
12
|
private enabled;
|
|
13
13
|
private initialized;
|
|
14
|
+
private usingExternalTracerProvider;
|
|
14
15
|
private meter?;
|
|
15
16
|
private tracer?;
|
|
16
17
|
private aiRequestCounter?;
|
|
@@ -29,6 +30,8 @@ export declare class TelemetryService {
|
|
|
29
30
|
private constructor();
|
|
30
31
|
static getInstance(): TelemetryService;
|
|
31
32
|
private isTelemetryEnabled;
|
|
33
|
+
private hasExternalTracerProvider;
|
|
34
|
+
private adoptExternalTracerProvider;
|
|
32
35
|
private initializeTelemetry;
|
|
33
36
|
private initializeMetrics;
|
|
34
37
|
initialize(): Promise<void>;
|
|
@@ -9,6 +9,7 @@ export class TelemetryService {
|
|
|
9
9
|
tracerProvider;
|
|
10
10
|
enabled = false;
|
|
11
11
|
initialized = false;
|
|
12
|
+
usingExternalTracerProvider = false;
|
|
12
13
|
meter;
|
|
13
14
|
tracer;
|
|
14
15
|
// Optional Metrics (only created when enabled)
|
|
@@ -43,11 +44,48 @@ export class TelemetryService {
|
|
|
43
44
|
return TelemetryService.instance;
|
|
44
45
|
}
|
|
45
46
|
isTelemetryEnabled() {
|
|
46
|
-
return (
|
|
47
|
+
return (this.hasExternalTracerProvider() ||
|
|
48
|
+
process.env.NEUROLINK_TELEMETRY_ENABLED === "true" ||
|
|
47
49
|
process.env.OTEL_EXPORTER_OTLP_ENDPOINT !== undefined);
|
|
48
50
|
}
|
|
51
|
+
hasExternalTracerProvider() {
|
|
52
|
+
try {
|
|
53
|
+
const provider = trace.getTracerProvider();
|
|
54
|
+
if (!provider) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
const delegateName = provider._delegate?.constructor?.name || "";
|
|
58
|
+
if (delegateName && delegateName !== "NoopTracerProvider") {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
const providerName = provider.constructor?.name || "";
|
|
62
|
+
return (providerName !== "ProxyTracerProvider" &&
|
|
63
|
+
providerName !== "NoopTracerProvider");
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
logger.warn("[Telemetry] Failed checking for external TracerProvider", {
|
|
67
|
+
error: error instanceof Error ? error.message : String(error),
|
|
68
|
+
});
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
adoptExternalTracerProvider(reason) {
|
|
73
|
+
this.usingExternalTracerProvider = true;
|
|
74
|
+
this.tracerProvider = undefined;
|
|
75
|
+
this.meter = metrics.getMeter("neurolink-ai");
|
|
76
|
+
this.tracer = trace.getTracer("neurolink-ai");
|
|
77
|
+
this.initializeMetrics();
|
|
78
|
+
logger.debug("[Telemetry] Reusing externally managed TracerProvider", {
|
|
79
|
+
reason,
|
|
80
|
+
endpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
49
83
|
initializeTelemetry() {
|
|
50
84
|
try {
|
|
85
|
+
if (this.hasExternalTracerProvider()) {
|
|
86
|
+
this.adoptExternalTracerProvider("global tracer provider already registered");
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
51
89
|
const resource = resourceFromAttributes({
|
|
52
90
|
[ATTR_SERVICE_NAME]: process.env.OTEL_SERVICE_NAME || "neurolink-ai",
|
|
53
91
|
[ATTR_SERVICE_VERSION]: process.env.OTEL_SERVICE_VERSION || "3.0.1",
|
|
@@ -61,13 +99,23 @@ export class TelemetryService {
|
|
|
61
99
|
resource,
|
|
62
100
|
spanProcessors: [new BatchSpanProcessor(exporter)],
|
|
63
101
|
});
|
|
64
|
-
trace.setGlobalTracerProvider(this.tracerProvider);
|
|
65
102
|
this.meter = metrics.getMeter("neurolink-ai");
|
|
66
|
-
this.tracer =
|
|
103
|
+
this.tracer = this.tracerProvider.getTracer("neurolink-ai");
|
|
67
104
|
this.initializeMetrics();
|
|
68
|
-
logger.debug("[Telemetry] Initialized
|
|
105
|
+
logger.debug("[Telemetry] Initialized local telemetry exporter", {
|
|
106
|
+
endpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT,
|
|
107
|
+
globalTracerProviderOwnedBy: "observability/instrumentation",
|
|
108
|
+
});
|
|
69
109
|
}
|
|
70
110
|
catch (error) {
|
|
111
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
112
|
+
const isDuplicateRegistration = errorMessage.includes("duplicate registration") ||
|
|
113
|
+
errorMessage.includes("already registered") ||
|
|
114
|
+
errorMessage.includes("already set");
|
|
115
|
+
if (isDuplicateRegistration && this.hasExternalTracerProvider()) {
|
|
116
|
+
this.adoptExternalTracerProvider("duplicate global tracer registration detected");
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
71
119
|
logger.error("[Telemetry] Failed to initialize:", error);
|
|
72
120
|
this.enabled = false;
|
|
73
121
|
}
|
|
@@ -105,6 +153,16 @@ export class TelemetryService {
|
|
|
105
153
|
if (!this.enabled) {
|
|
106
154
|
return;
|
|
107
155
|
}
|
|
156
|
+
if (this.usingExternalTracerProvider) {
|
|
157
|
+
this.initialized = true;
|
|
158
|
+
logger.debug("[Telemetry] External TracerProvider already initialized by host");
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (!this.tracerProvider) {
|
|
162
|
+
this.initialized = true;
|
|
163
|
+
logger.debug("[Telemetry] Tracer provider already prepared during constructor");
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
108
166
|
try {
|
|
109
167
|
// Register AsyncLocalStorage context manager for proper parent-child
|
|
110
168
|
// span relationships across async boundaries (required for startActiveSpan)
|
|
@@ -308,7 +366,9 @@ export class TelemetryService {
|
|
|
308
366
|
}
|
|
309
367
|
// Cleanup
|
|
310
368
|
async shutdown() {
|
|
311
|
-
if (this.enabled &&
|
|
369
|
+
if (this.enabled &&
|
|
370
|
+
this.tracerProvider &&
|
|
371
|
+
!this.usingExternalTracerProvider) {
|
|
312
372
|
try {
|
|
313
373
|
await this.tracerProvider.shutdown();
|
|
314
374
|
this.initialized = false;
|
package/dist/lib/types/cli.d.ts
CHANGED
|
@@ -763,6 +763,8 @@ export type ProxyStartArgs = {
|
|
|
763
763
|
quiet?: boolean;
|
|
764
764
|
debug?: boolean;
|
|
765
765
|
config?: string;
|
|
766
|
+
envFile?: string;
|
|
767
|
+
passthrough?: boolean;
|
|
766
768
|
};
|
|
767
769
|
/** Arguments accepted by `neurolink proxy status` */
|
|
768
770
|
export type ProxyStatusArgs = {
|
|
@@ -779,6 +781,11 @@ export type ProxyGuardArgs = {
|
|
|
779
781
|
pollIntervalMs?: number;
|
|
780
782
|
quiet?: boolean;
|
|
781
783
|
};
|
|
784
|
+
/** Arguments accepted by `neurolink proxy telemetry <subcommand>` */
|
|
785
|
+
export type ProxyTelemetryArgs = {
|
|
786
|
+
action?: "setup" | "start" | "stop" | "status" | "logs" | "import-dashboard";
|
|
787
|
+
quiet?: boolean;
|
|
788
|
+
};
|
|
782
789
|
/** A fallback chain entry (serialisable subset of FallbackEntry) */
|
|
783
790
|
export type FallbackInfo = {
|
|
784
791
|
provider: string;
|
|
@@ -791,12 +798,15 @@ export type ProxyState = {
|
|
|
791
798
|
host: string;
|
|
792
799
|
strategy: string;
|
|
793
800
|
startTime: string;
|
|
801
|
+
envFile?: string;
|
|
794
802
|
/** Fallback chain from proxy config (persisted at start time) */
|
|
795
803
|
fallbackChain?: FallbackInfo[];
|
|
796
804
|
/** Optional fail-open guard PID that reverts Claude settings if proxy dies */
|
|
797
805
|
guardPid?: number;
|
|
798
806
|
/** How the proxy was launched — "launchd" if installed as service, "manual" otherwise */
|
|
799
807
|
managedBy?: "launchd" | "manual";
|
|
808
|
+
/** Whether the proxy is running in transparent passthrough mode */
|
|
809
|
+
passthrough?: boolean;
|
|
800
810
|
};
|
|
801
811
|
/** Stored credentials for an authenticated provider. */
|
|
802
812
|
export type StoredCredentials = {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Centralized configuration type definitions following the established architecture pattern
|
|
4
4
|
*/
|
|
5
5
|
import { MCPToolRegistry } from "../mcp/toolRegistry.js";
|
|
6
|
+
import type { TaskManagerConfig } from "./taskTypes.js";
|
|
6
7
|
import type { HITLConfig } from "../types/hitlTypes.js";
|
|
7
8
|
import type { ConversationMemoryConfig } from "./conversation.js";
|
|
8
9
|
import type { ObservabilityConfig } from "./observability.js";
|
|
@@ -36,6 +37,8 @@ export type NeurolinkConstructorConfig = {
|
|
|
36
37
|
mcp?: MCPEnhancementsConfig;
|
|
37
38
|
/** Authentication provider configuration */
|
|
38
39
|
auth?: NeuroLinkAuthConfig;
|
|
40
|
+
/** TaskManager configuration (scheduled and self-running tasks) */
|
|
41
|
+
tasks?: TaskManagerConfig;
|
|
39
42
|
};
|
|
40
43
|
/**
|
|
41
44
|
* Configuration for MCP enhancement modules wired into generate()/stream() paths.
|
|
@@ -315,10 +315,23 @@ export type GenerateOptions = {
|
|
|
315
315
|
context?: StandardRecord;
|
|
316
316
|
evaluationDomain?: string;
|
|
317
317
|
toolUsageContext?: string;
|
|
318
|
+
/**
|
|
319
|
+
* @deprecated Use `conversationMessages` instead. This field uses a simple `{role, content}` shape
|
|
320
|
+
* that is not consumed by `buildMessagesArray()` — messages passed here will NOT reach the AI model
|
|
321
|
+
* as proper conversation turns. `conversationMessages` uses the full `ChatMessage` type and is
|
|
322
|
+
* correctly wired through the entire generate pipeline.
|
|
323
|
+
*/
|
|
318
324
|
conversationHistory?: Array<{
|
|
319
325
|
role: string;
|
|
320
326
|
content: string;
|
|
321
327
|
}>;
|
|
328
|
+
/**
|
|
329
|
+
* Previous conversation as a ChatMessage array.
|
|
330
|
+
* Messages are injected as proper multi-turn conversation history before the current prompt,
|
|
331
|
+
* so the AI model sees them as real prior exchanges (not text dumped into the prompt).
|
|
332
|
+
* Used by task continuation mode and available to external callers.
|
|
333
|
+
*/
|
|
334
|
+
conversationMessages?: ChatMessage[];
|
|
322
335
|
factoryConfig?: {
|
|
323
336
|
domainType?: string;
|
|
324
337
|
domainConfig?: StandardRecord;
|
|
@@ -46,3 +46,4 @@ export type { ClientConfig, RequestOptions as ClientRequestOptions, RetryConfig
|
|
|
46
46
|
export type { TokenRefresher } from "./subscriptionTypes.js";
|
|
47
47
|
export * from "./proxyTypes.js";
|
|
48
48
|
export type { AuthProviderType, AuthProviderConfig, MastraAuthProvider, BetterAuthConfig, Auth0Config, ClerkConfig, FirebaseConfig, SupabaseConfig, WorkOSConfig, JWTConfig, OAuth2Config, CognitoConfig, KeycloakConfig, CustomAuthConfig, BaseAuthProviderConfig, AuthUser, AuthSession, TokenType, TokenValidationResult as AuthTokenValidationResult, TokenClaims, JWK, JWKS, TokenRefreshResult, TokenValidationConfig, TokenExtractionConfig, SessionValidationResult, SessionStorage, AuthorizationResult, AuthRequestContext, AuthenticatedContext, TokenExtractionStrategy, SessionConfig, SessionStorageType, RBACConfig, PermissionDefinition, AuthCacheConfig, AuthMiddlewareOptions, AuthMiddlewareConfig, RBACMiddlewareConfig, AuthErrorCode, AuthErrorInfo, AuthErrorInfo as AuthErrorType, AuthEventType, AuthEventData, AuthEventHandler, AuthProviderFactoryFn, AuthProviderRegistration, AuthHealthCheck, AuthProviderHealthCheck, AuthEvents, AuthProviderMetadata, AuthProviderHealthStatus, AuthTokenValidator, AuthUserAuthorizer, AuthSessionManager, AuthRequestHandler, AuthUserManager, AuthLifecycle, } from "./authTypes.js";
|
|
49
|
+
export type { Task, TaskDefinition, TaskSchedule, TaskScheduleType, CronSchedule, IntervalSchedule, OnceSchedule, TaskExecutionMode, TaskStatus, TaskRunResult, TaskRunError, TaskStore, TaskBackend, TaskBackendName, TaskManagerConfig, TaskRetentionConfig, ConversationEntry as TaskConversationEntry, } from "./taskTypes.js";
|
|
@@ -239,10 +239,11 @@ export type ParsedClaudeRequest = {
|
|
|
239
239
|
role: string;
|
|
240
240
|
content: string;
|
|
241
241
|
}>;
|
|
242
|
-
/** Tools
|
|
242
|
+
/** Tools translated to AI SDK-compatible shape for provider fallback. */
|
|
243
243
|
tools: Record<string, {
|
|
244
|
-
description
|
|
245
|
-
|
|
244
|
+
description?: string;
|
|
245
|
+
inputSchema?: unknown;
|
|
246
|
+
execute?: (...args: unknown[]) => unknown;
|
|
246
247
|
}>;
|
|
247
248
|
/**
|
|
248
249
|
* Tool choice mapping from Claude format.
|
|
@@ -421,21 +422,52 @@ export type RequestLogEntry = {
|
|
|
421
422
|
errorMessage?: string;
|
|
422
423
|
inputTokens?: number;
|
|
423
424
|
outputTokens?: number;
|
|
425
|
+
cacheCreationTokens?: number;
|
|
426
|
+
cacheReadTokens?: number;
|
|
427
|
+
/** OTel trace ID for correlation with distributed traces */
|
|
428
|
+
traceId?: string;
|
|
429
|
+
/** OTel span ID for correlation with distributed traces */
|
|
430
|
+
spanId?: string;
|
|
431
|
+
};
|
|
432
|
+
export type RequestAttemptLogEntry = {
|
|
433
|
+
timestamp: string;
|
|
434
|
+
requestId: string;
|
|
435
|
+
attempt: number;
|
|
436
|
+
method: string;
|
|
437
|
+
path: string;
|
|
438
|
+
model: string;
|
|
439
|
+
stream: boolean;
|
|
440
|
+
toolCount: number;
|
|
441
|
+
account: string;
|
|
442
|
+
accountType: string;
|
|
443
|
+
responseStatus: number;
|
|
444
|
+
responseTimeMs: number;
|
|
445
|
+
errorType?: string;
|
|
446
|
+
errorMessage?: string;
|
|
447
|
+
inputTokens?: number;
|
|
448
|
+
outputTokens?: number;
|
|
449
|
+
cacheCreationTokens?: number;
|
|
450
|
+
cacheReadTokens?: number;
|
|
451
|
+
/** OTel trace ID for correlation with distributed traces */
|
|
452
|
+
traceId?: string;
|
|
453
|
+
/** OTel span ID for correlation with distributed traces */
|
|
454
|
+
spanId?: string;
|
|
424
455
|
};
|
|
425
456
|
export type AccountStats = {
|
|
426
457
|
label: string;
|
|
427
458
|
type: string;
|
|
428
|
-
|
|
459
|
+
attemptCount: number;
|
|
429
460
|
successCount: number;
|
|
430
461
|
errorCount: number;
|
|
431
462
|
rateLimitCount: number;
|
|
432
|
-
|
|
463
|
+
lastAttemptAt: number;
|
|
433
464
|
lastErrorAt?: number;
|
|
434
465
|
currentBackoffLevel: number;
|
|
435
466
|
coolingUntil?: number;
|
|
436
467
|
};
|
|
437
468
|
export type ProxyStats = {
|
|
438
469
|
startedAt: number;
|
|
470
|
+
totalAttempts: number;
|
|
439
471
|
totalRequests: number;
|
|
440
472
|
totalSuccess: number;
|
|
441
473
|
totalErrors: number;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type { Tool } from "ai";
|
|
1
|
+
import type { LanguageModel, StepResult, Tool, ToolChoice } from "ai";
|
|
2
2
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
3
|
import type { EvaluationData } from "../index.js";
|
|
4
4
|
import type { RAGConfig } from "../rag/types.js";
|
|
5
5
|
import type { AnalyticsData, ToolExecutionEvent, ToolExecutionSummary } from "../types/index.js";
|
|
6
|
-
import type { MiddlewareFactoryOptions,
|
|
6
|
+
import type { MiddlewareFactoryOptions, OnChunkCallback, OnErrorCallback, OnFinishCallback } from "../types/middlewareTypes.js";
|
|
7
7
|
import type { TokenUsage } from "./analytics.js";
|
|
8
8
|
import type { JsonValue, UnknownRecord } from "./common.js";
|
|
9
9
|
import type { Content, ImageWithAltText } from "./content.js";
|
|
10
10
|
import type { ChatMessage } from "./conversation.js";
|
|
11
|
+
import type { AdditionalMemoryUser } from "./generateTypes.js";
|
|
11
12
|
import type { AIModelProviderConfig } from "./providers.js";
|
|
12
13
|
import type { TTSChunk, TTSOptions } from "./ttsTypes.js";
|
|
13
|
-
import type { AdditionalMemoryUser } from "./generateTypes.js";
|
|
14
14
|
import type { StandardRecord, ValidationSchema } from "./typeAliases.js";
|
|
15
15
|
/**
|
|
16
16
|
* Progress tracking and metadata for streaming operations
|
|
@@ -326,12 +326,34 @@ export type StreamOptions = {
|
|
|
326
326
|
abortSignal?: AbortSignal;
|
|
327
327
|
disableTools?: boolean;
|
|
328
328
|
maxSteps?: number;
|
|
329
|
+
/**
|
|
330
|
+
* Tool choice configuration for streaming generation.
|
|
331
|
+
* Mirrors generate() so translated/fallback requests can preserve forced tool use.
|
|
332
|
+
*/
|
|
333
|
+
toolChoice?: ToolChoice<Record<string, Tool>>;
|
|
334
|
+
/**
|
|
335
|
+
* Optional callback that runs before each stream step in a multi-step generation.
|
|
336
|
+
*/
|
|
337
|
+
prepareStep?: (options: {
|
|
338
|
+
steps: StepResult<Record<string, Tool>>[];
|
|
339
|
+
stepNumber: number;
|
|
340
|
+
maxSteps: number;
|
|
341
|
+
model: LanguageModel;
|
|
342
|
+
}) => PromiseLike<{
|
|
343
|
+
toolChoice?: ToolChoice<Record<string, Tool>>;
|
|
344
|
+
activeTools?: Record<string, Tool>;
|
|
345
|
+
} | undefined>;
|
|
329
346
|
/** Include only these tools by name (whitelist). If set, only matching tools are available. */
|
|
330
347
|
toolFilter?: string[];
|
|
331
348
|
/** Exclude these tools by name (blacklist). Applied after toolFilter. */
|
|
332
349
|
excludeTools?: string[];
|
|
333
350
|
/** Disable tool result caching for this request (overrides global mcp.cache.enabled) */
|
|
334
351
|
disableToolCache?: boolean;
|
|
352
|
+
/**
|
|
353
|
+
* Disable NeuroLink's internal provider fallback for this request.
|
|
354
|
+
* Used by the Claude proxy so the proxy itself can own fallback order.
|
|
355
|
+
*/
|
|
356
|
+
disableInternalFallback?: boolean;
|
|
335
357
|
/**
|
|
336
358
|
* Skip injecting tool schemas into the system prompt.
|
|
337
359
|
* When true, tools are ONLY passed natively via the provider's `tools` parameter,
|