@juspay/neurolink 13.12.4 → 13.12.5

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.
@@ -73,6 +73,14 @@ export declare class FormatScorer extends BaseRuleScorer {
73
73
  * Check list-specific requirements
74
74
  */
75
75
  private _checkListRequirements;
76
+ /**
77
+ * Resolves the JSON Schema draft version from the schema's `$schema` declaration,
78
+ * or defaults to draft '2019-09' when omitted.
79
+ *
80
+ * @param schema - The JSON Schema object to inspect
81
+ * @returns The resolved SchemaDraft or an error message if unsupported
82
+ */
83
+ private _resolveSchemaDraft;
76
84
  /**
77
85
  * Validate JSON against schema (basic validation)
78
86
  */
@@ -2,6 +2,7 @@
2
2
  * @file Format Scorer
3
3
  * Evaluates response format compliance (JSON, markdown, code, etc.)
4
4
  */
5
+ import { Validator } from "@cfworker/json-schema";
5
6
  import { logger } from "../../../utils/logger.js";
6
7
  import { BaseRuleScorer, DEFAULT_RULE_SCORER_CONFIG, } from "./baseRuleScorer.js";
7
8
  /**
@@ -389,20 +390,88 @@ export class FormatScorer extends BaseRuleScorer {
389
390
  const score = passedChecks / totalChecks;
390
391
  return { passed: score >= 0.8, score };
391
392
  }
393
+ /**
394
+ * Resolves the JSON Schema draft version from the schema's `$schema` declaration,
395
+ * or defaults to draft '2019-09' when omitted.
396
+ *
397
+ * @param schema - The JSON Schema object to inspect
398
+ * @returns The resolved SchemaDraft or an error message if unsupported
399
+ */
400
+ _resolveSchemaDraft(schema) {
401
+ if (!("$schema" in schema)) {
402
+ // Documented library default is 2019-09 when $schema is omitted
403
+ return { draft: "2019-09" };
404
+ }
405
+ const declared = schema.$schema;
406
+ // A present-but-non-string $schema (7, null, ...) is malformed, not absent.
407
+ if (typeof declared !== "string") {
408
+ return {
409
+ error: `Unsupported or invalid JSON Schema draft: ${JSON.stringify(declared)}`,
410
+ };
411
+ }
412
+ const raw = declared.trim().toLowerCase();
413
+ // The unversioned meta-schema URL names no draft; use the default.
414
+ if (/^https?:\/\/json-schema\.org\/schema#?$/.test(raw)) {
415
+ return { draft: "2019-09" };
416
+ }
417
+ // The library has no draft-06; draft-07 is a near-superset, so validate
418
+ // draft-06 schemas as draft-07 rather than rejecting them.
419
+ if (/(?:^|\/|#)draft-0?6(?:[/#]|$)/.test(raw) || raw === "6") {
420
+ return { draft: "7" };
421
+ }
422
+ // Match draft-04 / 4
423
+ if (/(?:^|\/|#)draft-0?4(?:[/#]|$)/.test(raw) || raw === "4") {
424
+ return { draft: "4" };
425
+ }
426
+ // Match draft-07 / 7
427
+ if (/(?:^|\/|#)draft-0?7(?:[/#]|$)/.test(raw) || raw === "7") {
428
+ return { draft: "7" };
429
+ }
430
+ // Match draft-2019-09 / 2019-09
431
+ if (/(?:^|\/|#)(?:draft[/-])?2019-09(?:[/#]|$)/.test(raw) ||
432
+ raw === "2019-09") {
433
+ return { draft: "2019-09" };
434
+ }
435
+ // Match draft-2020-12 / 2020-12
436
+ if (/(?:^|\/|#)(?:draft[/-])?2020-12(?:[/#]|$)/.test(raw) ||
437
+ raw === "2020-12") {
438
+ return { draft: "2020-12" };
439
+ }
440
+ // Fail closed: a genuinely unknown draft (e.g. draft-03) cannot be
441
+ // validated faithfully, and passing it unchecked would reintroduce the
442
+ // "any parseable JSON passes" bug this scorer exists to prevent.
443
+ return {
444
+ error: `Unsupported or invalid JSON Schema draft: "${declared}"`,
445
+ };
446
+ }
392
447
  /**
393
448
  * Validate JSON against schema (basic validation)
394
449
  */
395
- _validateJsonSchema(text, _schema) {
396
- // First check if it's valid JSON
450
+ _validateJsonSchema(text, schema) {
451
+ let parsed;
397
452
  try {
398
- JSON.parse(text);
399
- // TODO(#1955): Implement full JSON Schema validation
400
- // For now, just check it's valid JSON
401
- return { passed: true, score: 1.0 };
453
+ parsed = JSON.parse(text);
402
454
  }
403
455
  catch {
404
456
  return { passed: false, score: 0.0 };
405
457
  }
458
+ const { draft, error: draftError } = this._resolveSchemaDraft(schema);
459
+ if (draftError || !draft) {
460
+ logger.warn(`[FormatScorer] ${draftError ?? "Unsupported JSON Schema draft"}`);
461
+ return { passed: false, score: 0.0 };
462
+ }
463
+ try {
464
+ const validator = new Validator(schema, draft, false);
465
+ const result = validator.validate(parsed);
466
+ return {
467
+ passed: result.valid,
468
+ score: result.valid ? 1.0 : 0.0,
469
+ };
470
+ }
471
+ catch (err) {
472
+ logger.warn("[FormatScorer] JSON Schema validation error:", err);
473
+ return { passed: false, score: 0.0 };
474
+ }
406
475
  }
407
476
  /**
408
477
  * Override score to add detailed format analysis
package/dist/neurolink.js CHANGED
@@ -15095,7 +15095,12 @@ Current user's request: ${currentInput}`;
15095
15095
  this.buildTranscribeDeps(options.credentials?.stt),
15096
15096
  import("./voice/transcribe.js"),
15097
15097
  ]);
15098
- return runTranscribe(options, deps);
15098
+ try {
15099
+ return await runTranscribe(options, deps);
15100
+ }
15101
+ finally {
15102
+ await deps.release?.();
15103
+ }
15099
15104
  }
15100
15105
  /**
15101
15106
  * Transcribe a live stream of PCM16LE frames. Engines with a native stream
@@ -15117,7 +15122,12 @@ Current user's request: ${currentInput}`;
15117
15122
  this.buildTranscribeDeps(options.credentials?.stt),
15118
15123
  import("./voice/transcribeStream.js"),
15119
15124
  ]);
15120
- yield* runTranscribeStream(options, deps);
15125
+ try {
15126
+ yield* runTranscribeStream(options, deps);
15127
+ }
15128
+ finally {
15129
+ await deps.release?.();
15130
+ }
15121
15131
  }
15122
15132
  /**
15123
15133
  * Instance `credentials.stt` with a per-call `stt` slice merged on top,
@@ -15179,19 +15189,38 @@ Current user's request: ${currentInput}`;
15179
15189
  // Same precedence as STTProcessor.resolveHandler, synchronously: a
15180
15190
  // credentials slice for the provider builds a handler from it; else the
15181
15191
  // registered handler; else, for a shipped provider, one from the env.
15192
+ // Handlers built here are not the registry's: they are collected and
15193
+ // disposed by `release()` once the request is done.
15194
+ const created = [];
15195
+ const build = (...args) => {
15196
+ const handler = createSTTHandler(...args);
15197
+ created.push(handler);
15198
+ return handler;
15199
+ };
15182
15200
  const getHandler = (name) => {
15183
15201
  if (resolveCallSTTEndpoints(credentials)[name.trim().toLowerCase()]) {
15184
- return createSTTHandler(name, credentials);
15202
+ return build(name, credentials);
15185
15203
  }
15186
15204
  const descriptor = getSTTProviderDescriptor(name);
15187
15205
  if (!descriptor) {
15188
15206
  return STTProcessor.getHandler(name);
15189
15207
  }
15190
15208
  if (credentials?.[descriptor.credentialsKey] !== undefined) {
15191
- return createSTTHandler(descriptor.name, credentials);
15209
+ return build(descriptor.name, credentials);
15210
+ }
15211
+ return STTProcessor.getHandler(descriptor.name) ?? build(descriptor.name);
15212
+ };
15213
+ const release = async () => {
15214
+ const results = await Promise.allSettled(created.splice(0).map(async (handler) => handler.dispose?.()));
15215
+ // One failed disposal must not stop the others, but it stays visible.
15216
+ // Only the error message is logged: the handlers hold the credentials.
15217
+ for (const result of results) {
15218
+ if (result.status === "rejected") {
15219
+ logger.warn(`[NeuroLink] Failed to dispose an STT handler: ${result.reason instanceof Error
15220
+ ? result.reason.message
15221
+ : String(result.reason)}`);
15222
+ }
15192
15223
  }
15193
- return (STTProcessor.getHandler(descriptor.name) ??
15194
- createSTTHandler(descriptor.name));
15195
15224
  };
15196
15225
  return {
15197
15226
  ...this.buildSTTCorrectionDeps(),
@@ -15199,6 +15228,7 @@ Current user's request: ${currentInput}`;
15199
15228
  resolveProvider,
15200
15229
  getHandler,
15201
15230
  attachmentPolicy: this.attachmentPolicy,
15231
+ release,
15202
15232
  };
15203
15233
  }
15204
15234
  /**
@@ -465,6 +465,89 @@ const relaxForcedToolChoice = (modelId, choice) => {
465
465
  : {}),
466
466
  };
467
467
  };
468
+ /**
469
+ * Whether the request continues a tool turn whose tool call was made without
470
+ * thinking: the final assistant message calls a tool (`tool_use`) and does not
471
+ * open with a thinking block.
472
+ *
473
+ * Only user messages follow the final assistant message, and Anthropic merges
474
+ * consecutive user messages into one turn, so that turn still answers the
475
+ * tool call however it is split: one tool-result message per tool (as
476
+ * `messagesToAnthropic` emits them), or tool results followed by a new user
477
+ * prompt when a tool turn was interrupted. Anthropic requires the final
478
+ * assistant message to open with a thinking block whenever thinking is on
479
+ * and that message calls a tool.
480
+ */
481
+ const continuesToolTurnWithoutThinking = (messages) => {
482
+ for (let index = messages.length - 1; index >= 0; index--) {
483
+ const message = messages[index];
484
+ if (message.role !== "assistant") {
485
+ continue;
486
+ }
487
+ if (!Array.isArray(message.content) ||
488
+ !message.content.some((block) => block.type === "tool_use")) {
489
+ return false;
490
+ }
491
+ const first = message.content[0];
492
+ return first?.type !== "thinking" && first?.type !== "redacted_thinking";
493
+ }
494
+ return false;
495
+ };
496
+ /**
497
+ * Make an extended-thinking block fit the request it rides on.
498
+ *
499
+ * - A `tool_choice` that forces tool use (`any`, or a named `tool`) cannot be
500
+ * sent with thinking on: Anthropic answers "Thinking may not be enabled when
501
+ * tool_choice forces tool use." with a 400. The forced choice wins and
502
+ * thinking is omitted, as on the Vertex schema path and in oauthFetch.ts.
503
+ * `none` and `auto` do not force tool use and leave thinking alone.
504
+ * - `budget_tokens` must be at least 1024 and below `max_tokens`. As on the
505
+ * Vertex path, it is clamped to leave 1024 tokens for the answer, and
506
+ * thinking is omitted when no budget of at least 1024 fits.
507
+ *
508
+ * - Thinking cannot be switched on partway through a tool-use turn: when the
509
+ * final assistant message calls a tool and does not start with a thinking
510
+ * block, Anthropic requires one and rejects the request. That is what
511
+ * follows a forced first step, where thinking was omitted, so it stays
512
+ * omitted until the turn ends with an assistant message that calls no tool.
513
+ * - A `budget_tokens` that is not a finite number cannot be sent, so thinking
514
+ * is omitted. A fractional budget is rounded down.
515
+ *
516
+ * `{ type: "disabled" }` and an absent block pass through unchanged. Every
517
+ * omission is logged, since the caller asked for thinking.
518
+ */
519
+ const fitThinkingToRequest = (thinking, toolChoice, maxTokens, messages) => {
520
+ if (thinking?.type !== "enabled") {
521
+ return thinking;
522
+ }
523
+ if (toolChoice?.type === "any" || toolChoice?.type === "tool") {
524
+ logger.warn(`[anthropic] Omitting extended thinking: tool_choice "${toolChoice.type}" forces tool use, which Anthropic rejects alongside thinking`);
525
+ return undefined;
526
+ }
527
+ if (continuesToolTurnWithoutThinking(messages)) {
528
+ logger.warn("[anthropic] Omitting extended thinking: this request continues a tool call made without thinking, and Anthropic does not allow thinking to start mid-turn");
529
+ return undefined;
530
+ }
531
+ // A budget that is not a finite number would survive the comparisons below
532
+ // (NaN compares false against everything) and reach the API as invalid JSON
533
+ // (NaN and Infinity serialize to null), so it is treated as unusable.
534
+ if (typeof thinking.budget_tokens !== "number" ||
535
+ !Number.isFinite(thinking.budget_tokens) ||
536
+ !Number.isFinite(maxTokens)) {
537
+ logger.warn(`[anthropic] Omitting extended thinking: budget_tokens ${String(thinking.budget_tokens)} (max_tokens ${String(maxTokens)}) is not a finite number`);
538
+ return undefined;
539
+ }
540
+ const budget = Math.floor(Math.min(thinking.budget_tokens, maxTokens - 1024));
541
+ if (budget < 1024) {
542
+ logger.warn(`[anthropic] Omitting extended thinking: max_tokens ${maxTokens} leaves no room for a thinking budget of at least 1024 tokens plus an answer`);
543
+ return undefined;
544
+ }
545
+ if (budget !== thinking.budget_tokens) {
546
+ logger.debug(`[anthropic] Clamping thinking budget_tokens ${thinking.budget_tokens} to ${budget} so it stays below max_tokens ${maxTokens}`);
547
+ return { type: "enabled", budget_tokens: budget };
548
+ }
549
+ return thinking;
550
+ };
468
551
  /** Map Anthropic stop_reason onto the V3 unified finish reason. */
469
552
  const mapAnthropicStopReason = (raw) => {
470
553
  switch (raw) {
@@ -1273,8 +1356,10 @@ export class AnthropicProvider extends BaseProvider {
1273
1356
  system = appendFinalResultInstruction(system);
1274
1357
  }
1275
1358
  }
1276
- // Extended thinking passthrough (providerOptions.anthropic.thinking).
1277
- const thinking = options.providerOptions?.anthropic?.thinking;
1359
+ // Extended thinking passthrough (providerOptions.anthropic.thinking),
1360
+ // fitted to the forced tool_choice and max_tokens above.
1361
+ const maxTokens = resolveClaudeMaxTokens(modelId, options.maxOutputTokens);
1362
+ const thinking = fitThinkingToRequest(options.providerOptions?.anthropic?.thinking, toolChoice, maxTokens, messages);
1278
1363
  // `disabled` is sent so a model that thinks by default (claude-sonnet-5
1279
1364
  // does, unasked) is told not to, but it fixes nothing about sampling: only a
1280
1365
  // block that turns thinking ON makes Anthropic reject temperature.
@@ -1318,7 +1403,7 @@ export class AnthropicProvider extends BaseProvider {
1318
1403
  const params = {
1319
1404
  model: modelId,
1320
1405
  messages: cachedMessages,
1321
- max_tokens: resolveClaudeMaxTokens(modelId, options.maxOutputTokens),
1406
+ max_tokens: maxTokens,
1322
1407
  ...(system ? { system } : {}),
1323
1408
  // Extended thinking fixes sampling: Anthropic rejects any
1324
1409
  // temperature but 1 while `thinking` is set, and does not honour
@@ -1940,8 +2025,9 @@ export class AnthropicProvider extends BaseProvider {
1940
2025
  const stepRecords = [];
1941
2026
  // Extended thinking: enabled when the caller supplies an explicit token
1942
2027
  // budget (mirrors the previous experimental_thinking gating). Thinking
1943
- // deltas stream out on the `reasoning` chunk channel.
1944
- const thinking = options.thinkingConfig?.enabled && options.thinkingConfig.budgetTokens
2028
+ // deltas stream out on the `reasoning` chunk channel. Fitted per step in
2029
+ // buildParams, since the step's tool_choice decides whether it may be sent.
2030
+ const requestedThinking = options.thinkingConfig?.enabled && options.thinkingConfig.budgetTokens
1945
2031
  ? {
1946
2032
  type: "enabled",
1947
2033
  budget_tokens: options.thinkingConfig.budgetTokens,
@@ -1949,8 +2035,6 @@ export class AnthropicProvider extends BaseProvider {
1949
2035
  : options.thinkingConfig?.type === "disabled"
1950
2036
  ? { type: "disabled" }
1951
2037
  : undefined;
1952
- // See the generate path: `disabled` is sent, but only ON constrains sampling.
1953
- const thinkingOn = thinking?.type === "enabled";
1954
2038
  const maxSteps = options.maxSteps || DEFAULT_MAX_STEPS;
1955
2039
  const channel = createStreamChannel();
1956
2040
  const { push: pushChunk } = channel;
@@ -2142,13 +2226,17 @@ export class AnthropicProvider extends BaseProvider {
2142
2226
  const streamSamplingParams = resolveSamplingParams("anthropic", modelId, options.temperature !== undefined && options.temperature !== null
2143
2227
  ? { temperature: options.temperature }
2144
2228
  : {}, "anthropic.executeStream");
2229
+ const maxTokens = resolveClaudeMaxTokens(modelId, options.maxTokens);
2230
+ const thinking = fitThinkingToRequest(requestedThinking, anthropicToolChoice, maxTokens, conversation);
2231
+ // See the generate path: `disabled` is sent, but only ON constrains sampling.
2232
+ const thinkingOn = thinking?.type === "enabled";
2145
2233
  if (thinkingOn && streamSamplingParams.temperature !== undefined) {
2146
2234
  logger.debug("[anthropic] extended thinking is enabled, so temperature is omitted on the stream path — Anthropic rejects any temperature but 1 while thinking is set");
2147
2235
  }
2148
2236
  return {
2149
2237
  model: modelId,
2150
2238
  messages: cachedConversation,
2151
- max_tokens: resolveClaudeMaxTokens(modelId, options.maxTokens),
2239
+ max_tokens: maxTokens,
2152
2240
  // No `stream: true` here: executeStep sets it when it calls
2153
2241
  // messages.create, so declaring it made the caller assert a literal
2154
2242
  // the adapter immediately overwrites — and forced this whole params
@@ -915,6 +915,16 @@ export type IndividualProviderConfig = {
915
915
  enableBetaFeatures?: boolean;
916
916
  [key: string]: unknown;
917
917
  };
918
+ /**
919
+ * The `thinking` block of an Anthropic Messages request, as the direct
920
+ * Anthropic provider builds it from `thinkingConfig`.
921
+ */
922
+ export type AnthropicThinkingParam = {
923
+ type: "enabled";
924
+ budget_tokens: number;
925
+ } | {
926
+ type: "disabled";
927
+ };
918
928
  /**
919
929
  * Anthropic-specific provider configuration
920
930
  *
@@ -195,6 +195,12 @@ export type STTHandler = {
195
195
  * before deciding which engine transcribes.
196
196
  */
197
197
  languageProbeModel?(): string | undefined;
198
+ /**
199
+ * Releases what the handler holds (a worker thread, a loaded model). The
200
+ * SDK calls it on handlers it builds for a single call; handlers registered
201
+ * with `STTProcessor.registerHandler` are shared and never disposed by it.
202
+ */
203
+ dispose?(): Promise<void> | void;
198
204
  maxAudioDuration?: number;
199
205
  supportsStreaming?: boolean;
200
206
  };
@@ -787,6 +787,8 @@ export type TranscribeDeps = STTCorrectionDeps & {
787
787
  * environment-derived default applies when absent.
788
788
  */
789
789
  attachmentPolicy?: AttachmentPolicy;
790
+ /** Disposes the handlers `getHandler` built for this request. */
791
+ release?: () => Promise<void>;
790
792
  };
791
793
  /** Resolved endpointer tuning: `STTStreamingOptions` with every default applied, plus the input rate. */
792
794
  export type STTEndpointerConfig = {
@@ -84,6 +84,12 @@ export declare class STTProcessor {
84
84
  * module, so a static import back would be a cycle.
85
85
  */
86
86
  static resolveHandler(provider: string, credentials?: STTCredentials): Promise<STTHandler | undefined>;
87
+ /**
88
+ * {@link resolveHandler} that also says whether the handler was built for
89
+ * this call (`owned`) rather than taken from the registry. The caller of an
90
+ * owned handler is the only one holding it, so it must dispose it.
91
+ */
92
+ private static resolveOwnedHandler;
87
93
  /**
88
94
  * List the names of all registered providers.
89
95
  */
@@ -99,11 +99,19 @@ export class STTProcessor {
99
99
  * module, so a static import back would be a cycle.
100
100
  */
101
101
  static async resolveHandler(provider, credentials) {
102
+ return (await this.resolveOwnedHandler(provider, credentials)).handler;
103
+ }
104
+ /**
105
+ * {@link resolveHandler} that also says whether the handler was built for
106
+ * this call (`owned`) rather than taken from the registry. The caller of an
107
+ * owned handler is the only one holding it, so it must dispose it.
108
+ */
109
+ static async resolveOwnedHandler(provider, credentials) {
102
110
  const endpoint = resolveCallSTTEndpoints(credentials)[provider.trim().toLowerCase()];
103
111
  if (endpoint) {
104
112
  // A per-call named endpoint: a fresh handler, never the registry's.
105
113
  const { createSTTHandler } = await import("../voice/index.js");
106
- return createSTTHandler(provider, credentials);
114
+ return { handler: createSTTHandler(provider, credentials), owned: true };
107
115
  }
108
116
  const descriptor = getSTTProviderDescriptor(provider);
109
117
  const slice = descriptor
@@ -111,14 +119,20 @@ export class STTProcessor {
111
119
  : undefined;
112
120
  if (descriptor && slice !== undefined) {
113
121
  const { createSTTHandler } = await import("../voice/index.js");
114
- return createSTTHandler(descriptor.name, credentials);
122
+ return {
123
+ handler: createSTTHandler(descriptor.name, credentials),
124
+ owned: true,
125
+ };
115
126
  }
116
127
  const registered = this.getHandler(provider);
117
128
  if (registered || !descriptor) {
118
- return registered;
129
+ return { handler: registered, owned: false };
119
130
  }
120
131
  const { createSTTHandler } = await import("../voice/index.js");
121
- return createSTTHandler(descriptor.name, credentials);
132
+ return {
133
+ handler: createSTTHandler(descriptor.name, credentials),
134
+ owned: true,
135
+ };
122
136
  }
123
137
  /**
124
138
  * List the names of all registered providers.
@@ -197,6 +211,7 @@ export class STTProcessor {
197
211
  "stt.language": options.language,
198
212
  "stt.format": options.format,
199
213
  });
214
+ let ownedHandler;
200
215
  try {
201
216
  // 1. Audio validation: reject empty + oversized audio
202
217
  const byteLength = audio instanceof ArrayBuffer ? audio.byteLength : audio.length;
@@ -227,7 +242,14 @@ export class STTProcessor {
227
242
  });
228
243
  }
229
244
  // 2. Handler lookup and error if provider not supported
230
- const handler = await this.resolveHandler(provider, credentials);
245
+ const resolved = await this.resolveOwnedHandler(provider, credentials);
246
+ const handler = resolved.handler;
247
+ // A handler built for this call has no other holder: dispose it when
248
+ // the call ends, or each credentials slice leaks an engine (WhistleSTT
249
+ // starts a worker thread per instance).
250
+ if (handler && resolved.owned) {
251
+ ownedHandler = handler;
252
+ }
231
253
  if (!handler) {
232
254
  logger.error(`[STTProcessor] Provider "${provider}" is not registered`);
233
255
  throw new STTError({
@@ -364,5 +386,17 @@ export class STTProcessor {
364
386
  originalError: err instanceof Error ? err : undefined,
365
387
  });
366
388
  }
389
+ finally {
390
+ if (ownedHandler?.dispose) {
391
+ try {
392
+ await ownedHandler.dispose();
393
+ }
394
+ catch (disposeErr) {
395
+ logger.warn(`[STTProcessor] Failed to dispose the "${provider}" handler: ${disposeErr instanceof Error
396
+ ? disposeErr.message
397
+ : String(disposeErr)}`);
398
+ }
399
+ }
400
+ }
367
401
  }
368
402
  }
@@ -4041,7 +4041,7 @@
4041
4041
  {"objectID":"b09d53aab5231e5f44f2c4df7a1d0cbf1c3f6e07ac586dfe8294eca0948441b1","title":"CLI Equivalent","url":"/docs/features/task-manager#cli-equivalent","content":"CLI Equivalent","hierarchy":{"lvl0":"Features","lvl1":"TaskManager - Scheduled & Self-Running Tasks","lvl2":"CLI Equivalent","lvl3":""}},
4042
4042
  {"objectID":"1ed0cf5cb87ec5d23bf366e3b3d3c81407802f490fb50d3fef44230ef5c3fc6f","title":"Existing Code Impact","url":"/docs/features/task-manager#existing-code-impact","content":"TaskManager is implemented as a new module (src/lib/tasks/). Minimal changes to existing code:\n\n| Existing File | Change | Lines |\n| ------------------------------ | ----------------------------------- | ----- |\n| src/lib/neurolink.ts | Add tasks getter property | ~10 |\n| src/lib/types/index.ts | Re-export task types | ~2 |\n| src/lib/agent/directTools.ts | Import and spread task tools | ~3 |\n| src/cli/index.ts | Register task CLI command | ~1 |\n| package.json | Add bullmq, croner dependencies | ~2 |\n\nEverything else is new files in src/lib/tasks/. No refactoring, no restructuring of existing code.","hierarchy":{"lvl0":"Features","lvl1":"TaskManager - Scheduled & Self-Running Tasks","lvl2":"Existing Code Impact","lvl3":""}},
4043
4043
  {"objectID":"e937a3f76bbe1a5494c610c87139c64ed299320dc8364078c0849a6231a023b8","title":"FAQ","url":"/docs/features/task-manager#faq","content":"Q: Do I need Redis to use TaskManager?\nA: No. Set backend: \"node-timeout\" for a zero-dependency setup. Redis is only required for the BullMQ backend (the default). When using BullMQ, Redis stores both job scheduling state and task definitions/run logs — no file I/O at all.\n\nQ: Will tasks stay in Redis forever?\nA: No. Active/paused tasks persist as long as they're running. Once a task reaches a terminal state (completed, failed, cancelled), it auto-expires based on taskRetention config — defaults: 30 days for completed, 7 days for failed/cancelled. Run logs are capped at maxRunLogs (default 2000) per task via LTRIM, and individual entries can have a TTL. You can also manually delete tasks via tasks.delete() or neurolink task delete.\n\nQ: Can the AI schedule tasks without user intervention?\nA: Yes. The built-in createTask tool allows the AI to self-schedule tasks during any conversation. If HITL is enabled, the user will be prompted for approval.\n\nQ: How does continuation mode handle growing context?\nA: It uses NeuroLink's existing context compaction system. When conversation history exceeds the model's context budget, BudgetChecker triggers automatic summarization.\n\nQ: Can I use TaskManager in a serverless environment?\nA: The BullMQ backend works in serverless with a persistent Redis instance — no local filesystem needed. The NodeTimeout backend requires a long-running process with filesystem access.\n\nQ: What happens when I switch backends?\nA: Tasks stored in Redis (BullMQ) and tasks stored on disk (NodeTimeout) are independent. Switching backends does not migrate data. If you need to migrate, use tasks.list() on the old backend and tasks.create() on the new one.\n\nQ: How do I monitor task health?\nA: Use neurolink.tasks.list() / neurolink task list for status overview, neurolink.tasks.runs(taskId) / neurolink task logs <id> for run history, and subscribe to task:* events for real-time monitoring.","hierarchy":{"lvl0":"Features","lvl1":"TaskManager - Scheduled & Self-Running Tasks","lvl2":"FAQ","lvl3":""}},
4044
- {"objectID":"5597f3996aaaa278b6fc9cb9310ea7f35b65373b35043abf05f0b33ebe8d5d82","title":"Extended Thinking Configuration","url":"/docs/features/thinking-configuration","content":"Extended Thinking Configuration\n\nEnable extended thinking/reasoning modes for AI models that support deeper reasoning capabilities. This feature allows models to \"think through\" complex problems before providing a response.\n\nOverview\n\nNeuroLink supports extended thinking/reasoning configuration for models that provide this capability. Extended thinking enables models to perform more thorough reasoning, particularly useful for complex tasks like mathematical proofs, coding problems, and multi-step analysis.\n\nSupported Models\n\nGemini 3 Models (Google Vertex AI / AI Studio)\ngemini-3.1-pro - Full thinking support with high token budgets (up to 100,000)\ngemini-3-flash-preview - Fast thinking with support for \"minimal\" level (up to 50,000)\n\nGemini 2.5 Models (Google Vertex AI / AI Studio)\ngemini-2.5-pro - Supports thinking configuration (up to 32,000 tokens)\ngemini-2.5-flash - Supports thinking configuration (up to 32,000 tokens)\n\nClaude Models (Anthropic)\n\nAll Claude 4.0+ models support extended thinking via budget tokens:\nclaude-sonnet-4-20250514 (Claude Sonnet 4)\nclaude-opus-4-20250514 (Claude Opus 4)\nclaude-opus-4-1-20250805 (Claude Opus 4.1)\nclaude-sonnet-4-5-20250929 (Claude Sonnet 4.5)\nclaude-opus-4-5-20251101 (Claude Opus 4.5)\nclaude-haiku-4-5-20251001 (Claude Haiku 4.5)\nclaude-sonnet-4-6 (Claude Sonnet 4.6)\nclaude-opus-4-6 (Claude Opus 4.6)\n\nQuick Start\n\nGemini 3 Thinking Configuration\n\nFor Gemini 3 models, use thinkingLevel to control reasoning depth:\n\nThinking Levels\n\n| Level | Description | Best For |\n| --------- | -------------------------------------- | ------------------------------- |\n| minimal | Near-zero thinking (Flash models only) | Simple queries requiring speed |\n| low | Fast reasoning for simple tasks | Quick analysis, summaries |\n| medium | Balanced reasoning/latency trade-off | General-purpose tasks |\n| high | Maximum reasoning depth | Complex reasoning, math, coding |\n\nMaximum Token Budgets by Model\n\n| Model | Max Thinking Budget |\n| --------------------- | ------------------- |\n| gemini-3-pro-* | 100,000 tokens |\n| gemini-3-flash-* | 50,000 tokens |\n| gemini-2.5-* | 32,000 tokens |\n| claude-opus-4-6 | 100,000 tokens |\n| claude-sonnet-4-6 | 100,000 tokens |\n| claude-opus-4-5-* | 100,000 tokens |\n| claude-sonnet-4-5-* | 100,000 tokens |\n| claude-haiku-4-5-* | 100,000 tokens |\n| claude-opus-4-1-* | 100,000 tokens |\n| claude-opus-4-* | 100,000 tokens |\n| claude-sonnet-4-* | 100,000 tokens |\n\nAnthropic Claude Thinking Configuration\n\nFor Claude models, use budgetTokens to set the thinking token budget:\n\nBudget Token Guidelines\nMinimum: 5,000 tokens\nMaximum: 100,000 tokens\nRecommended for simple tasks: 5,000-10,000 tokens\nRecommended for complex reasoning: 20,000-50,000 tokens\nMaximum depth: 50,000-100,000 tokens\n\nTurning thinking off\n\nSome Claude models, claude-sonnet-5 among them, think before answering even when\nno thinkingConfig is given, and that thinking counts against the request's\nmax_tokens. To turn it off for a call, pass type: \"disabled\":\n\nNeuroLink sends thinking: { type: \"disabled\" } on both generate() and\nstream(). Turning thinking off does not change which sampling parameters a\nmodel accepts. On a model that takes a temperature, NeuroLink still sends it\nwith thinking disabled; it is dropped only while thinking is on. Some models,\nclaude-sonnet-5 among them, do not accept a temperature at all, and NeuroLink\nleaves it off for them whatever the thinking setting.\n\nenabled: false, or no thinkingConfig at all, sends nothing, so the model's own\ndefault applies. If enabled: true and budgetTokens are also set, thinking is\nenabled, as before.\n\nConfiguration Options\n\nThe thinkingConfig object supports the following options:\n\nCLI Usage\n\nExtended thinking is also available via the CLI:\n\nCLI Options\n\n| Option | Description | Default |\n| ------------------ | ----------------------------------------------------- | ------- |\n| --thinking | Enable extended thinking | false |\n| --thinkingBudget | Token budget (Anthropic: 5000-100000) | 10000 |\n| --thinkingLevel | Thinking level (Gemini 3: minimal, low, medium, high) | medium |\n\nBest Practices\n\nWhen to Use High Thinking\nComplex mathematical proofs and calculations\nMulti-step coding problems and debugging\nDetailed analysis requiring multiple considerations\nTasks where accuracy is more important than speed\n\nWhen to Use Low/Minimal Thinking\nSimple queries where speed matters\nStraightforward information retrieval\nQuick summaries and formatting tasks\nHigh-volume, latency-sensitive applications\n\nGeneral Guidelines\nStart with medium: Use medium as your default and adjust based on results\nMatch model to task: Use Pro models for complex tasks, ","hierarchy":{"lvl0":"Features","lvl1":"Extended Thinking Configuration","lvl2":"","lvl3":""}},
4044
+ {"objectID":"5597f3996aaaa278b6fc9cb9310ea7f35b65373b35043abf05f0b33ebe8d5d82","title":"Extended Thinking Configuration","url":"/docs/features/thinking-configuration","content":"Extended Thinking Configuration\n\nEnable extended thinking/reasoning modes for AI models that support deeper reasoning capabilities. This feature allows models to \"think through\" complex problems before providing a response.\n\nOverview\n\nNeuroLink supports extended thinking/reasoning configuration for models that provide this capability. Extended thinking enables models to perform more thorough reasoning, particularly useful for complex tasks like mathematical proofs, coding problems, and multi-step analysis.\n\nSupported Models\n\nGemini 3 Models (Google Vertex AI / AI Studio)\ngemini-3.1-pro - Full thinking support with high token budgets (up to 100,000)\ngemini-3-flash-preview - Fast thinking with support for \"minimal\" level (up to 50,000)\n\nGemini 2.5 Models (Google Vertex AI / AI Studio)\ngemini-2.5-pro - Supports thinking configuration (up to 32,000 tokens)\ngemini-2.5-flash - Supports thinking configuration (up to 32,000 tokens)\n\nClaude Models (Anthropic)\n\nAll Claude 4.0+ models support extended thinking via budget tokens:\nclaude-sonnet-4-20250514 (Claude Sonnet 4)\nclaude-opus-4-20250514 (Claude Opus 4)\nclaude-opus-4-1-20250805 (Claude Opus 4.1)\nclaude-sonnet-4-5-20250929 (Claude Sonnet 4.5)\nclaude-opus-4-5-20251101 (Claude Opus 4.5)\nclaude-haiku-4-5-20251001 (Claude Haiku 4.5)\nclaude-sonnet-4-6 (Claude Sonnet 4.6)\nclaude-opus-4-6 (Claude Opus 4.6)\n\nQuick Start\n\nGemini 3 Thinking Configuration\n\nFor Gemini 3 models, use thinkingLevel to control reasoning depth:\n\nThinking Levels\n\n| Level | Description | Best For |\n| --------- | -------------------------------------- | ------------------------------- |\n| minimal | Near-zero thinking (Flash models only) | Simple queries requiring speed |\n| low | Fast reasoning for simple tasks | Quick analysis, summaries |\n| medium | Balanced reasoning/latency trade-off | General-purpose tasks |\n| high | Maximum reasoning depth | Complex reasoning, math, coding |\n\nMaximum Token Budgets by Model\n\n| Model | Max Thinking Budget |\n| --------------------- | ------------------- |\n| gemini-3-pro-* | 100,000 tokens |\n| gemini-3-flash-* | 50,000 tokens |\n| gemini-2.5-* | 32,000 tokens |\n| claude-opus-4-6 | 100,000 tokens |\n| claude-sonnet-4-6 | 100,000 tokens |\n| claude-opus-4-5-* | 100,000 tokens |\n| claude-sonnet-4-5-* | 100,000 tokens |\n| claude-haiku-4-5-* | 100,000 tokens |\n| claude-opus-4-1-* | 100,000 tokens |\n| claude-opus-4-* | 100,000 tokens |\n| claude-sonnet-4-* | 100,000 tokens |\n\nAnthropic Claude Thinking Configuration\n\nFor Claude models, use budgetTokens to set the thinking token budget:\n\nBudget Token Guidelines\nMinimum: 5,000 tokens\nMaximum: 100,000 tokens\nRecommended for simple tasks: 5,000-10,000 tokens\nRecommended for complex reasoning: 20,000-50,000 tokens\nMaximum depth: 50,000-100,000 tokens\n\nTurning thinking off\n\nSome Claude models, claude-sonnet-5 among them, think before answering even when\nno thinkingConfig is given, and that thinking counts against the request's\nmax_tokens. To turn it off for a call, pass type: \"disabled\":\n\nNeuroLink sends thinking: { type: \"disabled\" } on both generate() and\nstream(). Turning thinking off does not change which sampling parameters a\nmodel accepts. On a model that takes a temperature, NeuroLink still sends it\nwith thinking disabled; it is dropped only while thinking is on. Some models,\nclaude-sonnet-5 among them, do not accept a temperature at all, and NeuroLink\nleaves it off for them whatever the thinking setting.\n\nenabled: false, or no thinkingConfig at all, sends nothing, so the model's own\ndefault applies. If enabled: true and budgetTokens are also set, thinking is\nenabled, as before.\n\nWhen thinking is left off a request\n\nAnthropic rejects some requests that carry thinking, so on the anthropic\nprovider NeuroLink drops the thinking block from those requests and logs a\nwarning, instead of sending a request that would fail with a 400. (Claude on\nvertex does the same for generate({ schema }) and caps the budget the same\nway.)\n\nDropping the block is not the same as type: \"disabled\". The request then\ncarries no thinking field, so the model's own default applies, as described\nin Turning thinking off: a model that thinks by\ndefault may still think. NeuroLink never sends type: \"disabled\" in place of a\nbudget you asked for.\nA forced tool choice. toolChoice: \"required\", a named tool, a choice\n forced on a step by prepareStep or toolChoiceSteps, and generate({ schema })\n without tools (which forces a JSON tool) all force tool use, and Anthropic does\n not allow thinking with that. \"auto\" and \"none\" keep thinking.\nThe rest of a tool turn that started without thinking. Thinking cannot\n start partway through a tool call. While the last assistant message calls a\n tool and does not open with a thinking block, the block stays off, including","hierarchy":{"lvl0":"Features","lvl1":"Extended Thinking Configuration","lvl2":"","lvl3":""}},
4045
4045
  {"objectID":"b1a3fc87278e92aa39a0271b6f2eb465b62008b51d064acce63cf3af3f5c9673","title":"Extended Thinking Configuration","url":"/docs/features/thinking-configuration#extended-thinking-configuration","content":"Enable extended thinking/reasoning modes for AI models that support deeper reasoning capabilities. This feature allows models to \"think through\" complex problems before providing a response.","hierarchy":{"lvl0":"Features","lvl1":"Extended Thinking Configuration","lvl2":"Extended Thinking Configuration","lvl3":""}},
4046
4046
  {"objectID":"5e898a7f44534e174e959788be122e3ba4d1ee14def3b6214209393edf08cbae","title":"Overview","url":"/docs/features/thinking-configuration#overview","content":"NeuroLink supports extended thinking/reasoning configuration for models that provide this capability. Extended thinking enables models to perform more thorough reasoning, particularly useful for complex tasks like mathematical proofs, coding problems, and multi-step analysis.","hierarchy":{"lvl0":"Features","lvl1":"Extended Thinking Configuration","lvl2":"Overview","lvl3":""}},
4047
4047
  {"objectID":"3c3340ac962c9488fd2f05b80b29b47a3a272754a135742aa678ed7dc1845462","title":"Gemini 3 Models (Google Vertex AI / AI Studio)","url":"/docs/features/thinking-configuration#gemini-3-models-google-vertex-ai-ai-studio","content":"gemini-3.1-pro - Full thinking support with high token budgets (up to 100,000)\ngemini-3-flash-preview - Fast thinking with support for \"minimal\" level (up to 50,000)","hierarchy":{"lvl0":"Features","lvl1":"Extended Thinking Configuration","lvl2":"Gemini 3 Models (Google Vertex AI / AI Studio)","lvl3":""}},
@@ -4054,6 +4054,7 @@
4054
4054
  {"objectID":"a1b9be5a0a0a16cff259e6051df668ddc07f75a6ae77ebba4121f649746eb25e","title":"Anthropic Claude Thinking Configuration","url":"/docs/features/thinking-configuration#anthropic-claude-thinking-configuration","content":"For Claude models, use budgetTokens to set the thinking token budget:","hierarchy":{"lvl0":"Features","lvl1":"Extended Thinking Configuration","lvl2":"Anthropic Claude Thinking Configuration","lvl3":""}},
4055
4055
  {"objectID":"942ce04a601afc6269d1765ad4da7295a802070a5b036c93dd360e92478e3be3","title":"Budget Token Guidelines","url":"/docs/features/thinking-configuration#budget-token-guidelines","content":"Minimum: 5,000 tokens\nMaximum: 100,000 tokens\nRecommended for simple tasks: 5,000-10,000 tokens\nRecommended for complex reasoning: 20,000-50,000 tokens\nMaximum depth: 50,000-100,000 tokens","hierarchy":{"lvl0":"Features","lvl1":"Extended Thinking Configuration","lvl2":"Budget Token Guidelines","lvl3":""}},
4056
4056
  {"objectID":"43d4815c3e1af5de7858131d9b25bcf7e59ef2dee4327c46cf613cbdd0f704d9","title":"Turning thinking off","url":"/docs/features/thinking-configuration#turning-thinking-off","content":"Some Claude models, claude-sonnet-5 among them, think before answering even when\nno thinkingConfig is given, and that thinking counts against the request's\nmax_tokens. To turn it off for a call, pass type: \"disabled\":\n\nNeuroLink sends thinking: { type: \"disabled\" } on both generate() and\nstream(). Turning thinking off does not change which sampling parameters a\nmodel accepts. On a model that takes a temperature, NeuroLink still sends it\nwith thinking disabled; it is dropped only while thinking is on. Some models,\nclaude-sonnet-5 among them, do not accept a temperature at all, and NeuroLink\nleaves it off for them whatever the thinking setting.\n\nenabled: false, or no thinkingConfig at all, sends nothing, so the model's own\ndefault applies. If enabled: true and budgetTokens are also set, thinking is\nenabled, as before.","hierarchy":{"lvl0":"Features","lvl1":"Extended Thinking Configuration","lvl2":"Turning thinking off","lvl3":""}},
4057
+ {"objectID":"589e6cd4ac1d5c1827711b20f0b060ee0abc8a71533970a146c97fde65dc2672","title":"When thinking is left off a request","url":"/docs/features/thinking-configuration#when-thinking-is-left-off-a-request","content":"Anthropic rejects some requests that carry thinking, so on the anthropic\nprovider NeuroLink drops the thinking block from those requests and logs a\nwarning, instead of sending a request that would fail with a 400. (Claude on\nvertex does the same for generate({ schema }) and caps the budget the same\nway.)\n\nDropping the block is not the same as type: \"disabled\". The request then\ncarries no thinking field, so the model's own default applies, as described\nin Turning thinking off: a model that thinks by\ndefault may still think. NeuroLink never sends type: \"disabled\" in place of a\nbudget you asked for.\nA forced tool choice. toolChoice: \"required\", a named tool, a choice\n forced on a step by prepareStep or toolChoiceSteps, and generate({ schema })\n without tools (which forces a JSON tool) all force tool use, and Anthropic does\n not allow thinking with that. \"auto\" and \"none\" keep thinking.\nThe rest of a tool turn that started without thinking. Thinking cannot\n start partway through a tool call. While the last assistant message calls a\n tool and does not open with a thinking block, the block stays off, including\n when a new prompt follows tool results replayed from history. It comes back\n on the first request after the model answers without calling a tool.\nA budget that cannot fit. budgetTokens is capped at the request's\n maxTokens minus 1,024, which leaves room for the answer. When that cap is\n under Anthropic's 1,024-token minimum, the block is dropped.\nA budget that is not a finite number. A budgetTokens of Infinity, a\n negative number or a non-number is dropped rather than sent. A fractional\n budget is rounded down.","hierarchy":{"lvl0":"Features","lvl1":"Extended Thinking Configuration","lvl2":"When thinking is left off a request","lvl3":""}},
4057
4058
  {"objectID":"2b5576316a6208f5cfec1c81bc1e6fef5b0183103738313b707f4f56e5cfa57a","title":"Configuration Options","url":"/docs/features/thinking-configuration#configuration-options","content":"The thinkingConfig object supports the following options:","hierarchy":{"lvl0":"Features","lvl1":"Extended Thinking Configuration","lvl2":"Configuration Options","lvl3":""}},
4058
4059
  {"objectID":"a8d5868d4d30b359f7c8882f700ef9b1930d1be223f54728849a4634314aa07f","title":"CLI Usage","url":"/docs/features/thinking-configuration#cli-usage","content":"Extended thinking is also available via the CLI:","hierarchy":{"lvl0":"Features","lvl1":"Extended Thinking Configuration","lvl2":"CLI Usage","lvl3":""}},
4059
4060
  {"objectID":"dff15a38f63c9eaa7de8aea3b61211b551702585d6a3eacf6631abd0bf985805","title":"CLI Options","url":"/docs/features/thinking-configuration#cli-options","content":"| Option | Description | Default |\n| ------------------ | ----------------------------------------------------- | ------- |\n| --thinking | Enable extended thinking | false |\n| --thinkingBudget | Token budget (Anthropic: 5000-100000) | 10000 |\n| --thinkingLevel | Thinking level (Gemini 3: minimal, low, medium, high) | medium |","hierarchy":{"lvl0":"Features","lvl1":"Extended Thinking Configuration","lvl2":"CLI Options","lvl3":""}},
@@ -6860,7 +6861,7 @@
6860
6861
  {"objectID":"227e33113855fae825493b60851693beeb2467f4f71008248886477e27fbbd27","title":"Streaming","url":"/docs/getting-started/providers/whistle#streaming","content":"Whistle streams natively. transcribeStream() takes PCM16LE mono frames (at\nsampleRate, default 16 kHz, any frame size), feeds the engine about a second\nat a time, and yields:\na final segment whenever the engine commits words (two consecutive\n passes agreed on them), with word timings measured from the start of the\n stream — join the finals with a space for the transcript;\nan interim segment carrying the unconfirmed tail whenever it changes.\n\nEach stream runs on a worker of its own, so it never interleaves with batch\ncalls on the same handler.","hierarchy":{"lvl0":"Getting Started","lvl1":"Whistle (Built-in Local STT)","lvl2":"Streaming","lvl3":""}},
6861
6862
  {"objectID":"c292466ae8a0e9b28914ed9e6010c07ebb8425559e229ecdd1dfe36c352b0d89","title":"Audio formats","url":"/docs/getting-started/providers/whistle#audio-formats","content":"| Format | Decoded by |\n| --------------------------------------------------------------------- | -------------- |\n| WAV — 8/16/24/32-bit PCM, 32/64-bit float, any rate and channel count | Whistle itself |\n| raw pcm16 | Whistle itself |\n| mp3, m4a, mp4, ogg, opus, webm, flac, mpeg | ffmpeg |\n\nCompressed formats need ffmpeg: FFMPEG_PATH, the optional ffmpeg-static\npackage (pnpm add ffmpeg-static), or ffmpeg on PATH. Without one, the\ncall fails with an error that names the formats Whistle can read by itself.","hierarchy":{"lvl0":"Getting Started","lvl1":"Whistle (Built-in Local STT)","lvl2":"Audio formats","lvl3":""}},
6862
6863
  {"objectID":"9429c5e0a71ffbdc447014b203905467c61b374d5583cb17a0e5cb90d96dcd93","title":"Environment variables","url":"/docs/getting-started/providers/whistle#environment-variables","content":"| Variable | Default | Meaning |\n| --------------------------------- | ------- | --------------------------------------------------------------- |\n| NEUROLINK_WHISTLE_DIR | — | Directory holding the three files |\n| NEUROLINK_MODEL_DIR | — | Parent directory for local models; Whistle uses <dir>/whistle |\n| NEUROLINK_WHISTLE_AUTO_DOWNLOAD | 1 | 0 forbids the first-use download |\n| NEUROLINK_WHISTLE_KEYWORDS | 0 | 1 enables keyword biasing from vocabulary |\n| FFMPEG_PATH | — | ffmpeg binary for compressed formats |","hierarchy":{"lvl0":"Getting Started","lvl1":"Whistle (Built-in Local STT)","lvl2":"Environment variables","lvl3":""}},
6863
- {"objectID":"4b33ae49583501e03d79b64042c6a88b3e5272910a29161dcd353593af1a1424","title":"Runtime behaviour","url":"/docs/getting-started/providers/whistle#runtime-behaviour","content":"One warm worker thread per WhistleSTT instance holds the engine and the\n model (~0.2 s to start); requests are answered in order. The worker is\n unreferenced while idle, so it never keeps your process alive; call\n dispose() to stop it early.\nIf the worker crashes, the requests it held fail with an STTError, and the\n next call starts a fresh worker.","hierarchy":{"lvl0":"Getting Started","lvl1":"Whistle (Built-in Local STT)","lvl2":"Runtime behaviour","lvl3":""}},
6864
+ {"objectID":"4b33ae49583501e03d79b64042c6a88b3e5272910a29161dcd353593af1a1424","title":"Runtime behaviour","url":"/docs/getting-started/providers/whistle#runtime-behaviour","content":"One warm worker thread per WhistleSTT instance holds the engine and the\n model (~0.2 s to start); requests are answered in order. The worker is\n unreferenced while idle, so it never keeps your process alive; call\n dispose() to stop it early.\nA call that passes credentials.stt.whistle builds its own WhistleSTT; the\n SDK disposes it when the call ends. Only a handler you create or register\n yourself needs your dispose().\nIf the worker crashes, the requests it held fail with an STTError, and the\n next call starts a fresh worker.","hierarchy":{"lvl0":"Getting Started","lvl1":"Whistle (Built-in Local STT)","lvl2":"Runtime behaviour","lvl3":""}},
6864
6865
  {"objectID":"4a9a4c2f798b0fcb3745e1c3d957b8e72b8ec103e51747d673f447ed1433e265","title":"Accuracy","url":"/docs/getting-started/providers/whistle#accuracy","content":"Whistle is a 17 MB model. It is accurate on clear speech in its seven\nlanguages, but it is noticeably behind cloud engines (Deepgram, ElevenLabs\nScribe, Google, Azure) and large Whisper-class models on accents,\nbackground noise, overlapping speakers, rare names and domain jargon, and it\ndoes not diarize. It is a sensible default for development, offline use and\nprivacy-sensitive audio; configure a cloud or self-hosted provider where\naccuracy matters, or add a dictionary and the correction layer of\ntranscribe().","hierarchy":{"lvl0":"Getting Started","lvl1":"Whistle (Built-in Local STT)","lvl2":"Accuracy","lvl3":""}},
6865
6866
  {"objectID":"884ee0aaccf14df2941d0048aa7934768312271d2cfbd663d43599769dea63cc","title":"xAI Grok Provider Guide","url":"/docs/getting-started/providers/xai","content":"xAI Grok Provider Guide\n\nText + vision generation with the Grok family through a single API\n\nOverview\n\nxAI hosts Elon Musk's Grok family of models behind an OpenAI-compatible\nchat-completions endpoint. NeuroLink wraps api.x.ai/v1 so the same\ngenerate / stream contract used by every other provider works for Grok\nwithout translation.\ngrok-3 — flagship; best for complex reasoning, math, coding\ngrok-3-mini — faster + cheaper variant of Grok 3\ngrok-2-latest — previous flagship; still supported\ngrok-2-vision-latest — multimodal (text + images)\ngrok-beta — pre-release / experimental access\n\nKey Facts\nProtocol: OpenAI-compatible (/v1/chat/completions)\nDefault base URL: https://api.x.ai/v1\nDefault model: grok-3\nContext window: 131K tokens (32K on grok-2-vision-latest)\nVision: Yes — grok-2-vision-latest accepts image inputs\nStreaming: Supported\nTool calling: Supported\nReasoning trace: Not exposed (use Grok-3 for natively-strong reasoning)\n\nQuick Start\nGet an API Key\n\nSign up at https://console.x.ai/ and create an\nAPI key under API Keys.\nConfigure Environment\n\nAdd to your .env file:\nInstall NeuroLink\nGenerate Your First Response\n\nSupported Models\n\n| Model ID | Family | Context | Vision | Notes |\n| ---------------------- | ------------- | ------- | ------ | -------------------------- |\n| grok-3 | Grok 3 | 131K | No | Default; best reasoning |\n| grok-3-mini | Grok 3 Mini | 131K | No | Faster + cheaper Grok 3 |\n| grok-2-latest | Grok 2 | 131K | No | Previous flagship |\n| grok-2-vision-latest | Grok 2 Vision | 32K | Yes | Multimodal text + image |\n| grok-beta | Beta | 131K | No | Pre-release / experimental |\n\nPass any model ID via --model (CLI) or model: (SDK).\n\nSDK Usage\n\nBasic Generation\n\nVision Input (Grok 2 Vision)\n\nStreaming\n\nTool Calling\n\nPer-Call Credential Override\n\nCLI Usage\n\nBasic Commands\n\nProvider Aliases\n\n| Alias | Example |\n| ------ | ----------------- |\n| xai | --provider xai |\n| grok | --provider grok |\n\nConfiguration Reference\n\n| Environment Variable | Required | Default | Description |\n| -------------------- | -------- | --------------------- | ------------------------------- |\n| XAI_API_KEY | Yes | — | xAI API key |\n| XAI_MODEL | No | grok-3 | Default model to use |\n| XAI_BASE_URL | No | https://api.x.ai/v1 | Base URL (override for proxies) |\n\nFeature Support Matrix\n\n| Feature | grok-3 | grok-3-mini | grok-2-latest | grok-2-vision | grok-beta |\n| ----------------- | ------ | ----------- | ------------- | ------------- | --------- |\n| Text generation | Yes | Yes | Yes | Yes | Yes |\n| Streaming | Yes | Yes | Yes | Yes | Yes |\n| Tool calling | Yes | Yes | Yes | Yes | Yes |\n| Structured output | Yes | Yes | Yes | Yes | Yes |\n| Vision / images | No | No | No | Yes | No |\n| Embeddings | No | No | No | No | No |\n\nTroubleshooting\n\n\"Invalid xAI API key\"\n\nThe XAI_API_KEY is missing or incorrect.\n\nGet or rotate keys at https://console.x.ai/.\n\n\"xAI rate limit exceeded\"\n\nToo many requests in a short window. Implement exponential backoff or\nreduce concurrency. Free-tier limits are tight; consider upgrading at\nhttps://console.x.ai/.\n\n\"xAI account has insufficient quota\"\n\nTop up at https://console.x.ai/.\n\n\"Model not found\"\n\nUse one of the documented model IDs above. Custom fine-tunes are not\nexposed through the public API at this time.\n\nSee Also\nAdding a new LLM provider — internal reference for the integration pattern this provider follows\nDeepSeek Provider — sibling OpenAI-compat provider with reasoning models\nGroq Provider — sibling OpenAI-compat provider with sub-100ms inference\n\nNeed Help? Open a GitHub Discussion or issue.","hierarchy":{"lvl0":"Getting Started","lvl1":"xAI Grok Provider Guide","lvl2":"","lvl3":""}},
6866
6867
  {"objectID":"f15e86375a87a665a10229f6826884c69484bcf7465db56c3c727ea4c881b1f0","title":"xAI Grok Provider Guide","url":"/docs/getting-started/providers/xai#xai-grok-provider-guide","content":"Text + vision generation with the Grok family through a single API","hierarchy":{"lvl0":"Getting Started","lvl1":"xAI Grok Provider Guide","lvl2":"xAI Grok Provider Guide","lvl3":""}},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/neurolink",
3
- "version": "13.12.4",
3
+ "version": "13.12.5",
4
4
  "packageManager": "pnpm@10.34.9+sha512.f49b5a8ea0fdedb44bb3c0c1d6575092a53c2950d95b7ad15df11f17974877a2de3a01c07e934e9b28ce716e51c09a94962c7306d09be2e1e4b18a8c8762fd32",
5
5
  "description": "The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002/call) for routing, tool selection and context budgeting. MCP-native (4 transports), voice TTS/STT/realtime, RAG, agents, memory, compaction, 9 observability exporters. OpenAI · Anthropic · Gemini · Bedrock · Azure · Ollama · TypeSafe Jev and more.",
6
6
  "author": {
@@ -111,6 +111,7 @@
111
111
  "test:anthropic-streaming-retry": "pnpm exec tsx test/continuous-test-suite-anthropic-streaming-retry.ts",
112
112
  "test:anthropic-silent-truncation": "pnpm exec tsx test/continuous-test-suite-anthropic-silent-truncation.ts",
113
113
  "test:anthropic-thinking-disabled": "pnpm exec tsx test/continuous-test-suite-anthropic-thinking-disabled.ts",
114
+ "test:anthropic-thinking-forced-tool": "pnpm exec tsx test/continuous-test-suite-anthropic-thinking-forced-tool.ts",
114
115
  "test:cache-cost-accounting": "pnpm exec tsx test/continuous-test-suite-cache-cost-accounting.ts",
115
116
  "test:agent:cost": "pnpm exec tsx test/continuous-test-suite-agent-cost.ts",
116
117
  "test:adjust-body-after-400": "pnpm exec tsx test/continuous-test-suite-adjust-body-after-400.ts",