@juspay/neurolink 12.12.6 → 12.12.8

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.
@@ -3,7 +3,7 @@ import type { EvaluationData, GetPromptFunction } from "./evaluation.js";
3
3
  import type { AuthenticatedUser, RouteDefinition, ServerContext } from "./server.js";
4
4
  import type { LanguageModelMiddleware as BaseLanguageModelMiddleware } from "./aiCompat.js";
5
5
  export type { LanguageModelMiddleware } from "./aiCompat.js";
6
- export type { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3Message, LanguageModelV3Prompt, LanguageModelV3StreamPart, LanguageModelV3ToolCall, LanguageModelV3ToolChoice, LanguageModelV3Source, LanguageModelV3Middleware, LanguageModelV3GenerateResult, LanguageModelV3StreamResult, JSONSchema7, } from "./aiCompat.js";
6
+ export type { LanguageModelV3, LanguageModelV3CallOptions, LanguageModelV3Message, LanguageModelV3Prompt, LanguageModelV3StreamPart, LanguageModelV3Content, LanguageModelV3ToolCall, LanguageModelV3ToolChoice, LanguageModelV3Source, LanguageModelV3Middleware, LanguageModelV3GenerateResult, LanguageModelV3StreamResult, JSONSchema7, } from "./aiCompat.js";
7
7
  /**
8
8
  * Metadata type for NeuroLink middleware
9
9
  * Provides additional information about middleware without affecting execution
@@ -555,6 +555,14 @@ export type ProxyAccountSortMetrics = {
555
555
  scopedSaturated: boolean;
556
556
  };
557
557
  export type RequestLogEntry = {
558
+ /** First output text or tool-argument delta, excluding SSE control frames. */
559
+ firstUsefulOutputMs?: number;
560
+ /** Small routing evidence retained even when response bodies are pruned. */
561
+ fallbackPlan?: Array<{
562
+ provider: string;
563
+ model: string;
564
+ reasoningEffort?: string;
565
+ }>;
558
566
  timestamp: string;
559
567
  requestId: string;
560
568
  method: string;
@@ -605,9 +613,31 @@ export type RequestLogEntry = {
605
613
  /** Exact secret-free inputs and result of initial account selection. */
606
614
  routingDecision?: ProxyAccountRoutingDecision;
607
615
  };
616
+ /** File-sink evidence is independent of model/request success counters. */
617
+ export type ProxyRequestLogSinkSnapshot = {
618
+ attempted: number;
619
+ written: number;
620
+ inFlight: number;
621
+ pending: number;
622
+ /** Records not admitted because the bounded writer queue was full. */
623
+ dropped: number;
624
+ writeTimeouts: number;
625
+ unconfirmedWrites: number;
626
+ lastErrorCode?: string;
627
+ };
628
+ export type ProxyRequestLoggerSnapshot = {
629
+ enabled: boolean;
630
+ requests: ProxyRequestLogSinkSnapshot;
631
+ attempts: ProxyRequestLogSinkSnapshot;
632
+ debug: ProxyRequestLogSinkSnapshot;
633
+ };
608
634
  export type RequestAttemptLogEntry = {
609
635
  timestamp: string;
610
636
  requestId: string;
637
+ /** Parent client request for an internal fallback invocation. */
638
+ parentRequestId?: string;
639
+ /** Requested effort retained independently of full body captures. */
640
+ reasoningEffort?: string;
611
641
  attempt: number;
612
642
  method: string;
613
643
  path: string;
@@ -649,7 +679,7 @@ export type RequestAttemptLogEntry = {
649
679
  spanId?: string;
650
680
  };
651
681
  /** Additional fields recorded when a Codex response becomes client-final. */
652
- export type CodexFinalLogExtra = Partial<Pick<RequestLogEntry, "errorType" | "errorMessage" | "errorCode" | "transportScope" | "inputTokens" | "outputTokens" | "cacheReadTokens" | "cacheCreationTokens" | "terminalOutcome">>;
682
+ export type CodexFinalLogExtra = Partial<Pick<RequestLogEntry, "errorType" | "errorMessage" | "errorCode" | "transportScope" | "inputTokens" | "outputTokens" | "cacheReadTokens" | "cacheCreationTokens" | "terminalOutcome" | "firstUsefulOutputMs">>;
653
683
  /** Additional fields recorded for each upstream Codex account attempt. */
654
684
  export type CodexAttemptLogExtra = Partial<Pick<RequestAttemptLogEntry, "errorType" | "errorMessage" | "errorCode" | "transportScope" | "retryable" | "rateLimitKind" | "cooldownReason">>;
655
685
  /** Minimal persistence contract needed by Codex rotating-token refreshes. */
@@ -1580,15 +1610,17 @@ export type ProxyResponseTrackingObserver = {
1580
1610
  }) => void;
1581
1611
  onTerminal?: (details: {
1582
1612
  outcome: ProxyResponseTerminalOutcome;
1613
+ /** Underlying read failure for structured transport diagnostics. */
1614
+ error?: unknown;
1583
1615
  /** Decoded response-body bytes observed by the adapter. */
1584
1616
  observedBodyBytes: number;
1585
1617
  responseChunks: number;
1586
- }) => void;
1618
+ }) => unknown;
1587
1619
  };
1588
1620
  /** Versioned lifecycle event names persisted by the proxy adapter. */
1589
1621
  export type ProxyLifecycleEventName = "request_accepted" | "response_headers" | "response_first_chunk" | "request_terminal";
1590
1622
  /** Client-facing terminal classifications recorded by lifecycle metadata. */
1591
- export type ProxyLifecycleTerminalOutcome = ProxyResponseTerminalOutcome | "handler_error";
1623
+ export type ProxyLifecycleTerminalOutcome = ProxyResponseTerminalOutcome | "handler_error" | "unknown";
1592
1624
  /** Content-free lifecycle event accepted by the bounded metadata logger. */
1593
1625
  export type ProxyLifecycleEventInput = {
1594
1626
  event: ProxyLifecycleEventName;
@@ -1601,6 +1633,13 @@ export type ProxyLifecycleEventInput = {
1601
1633
  sessionHash?: string;
1602
1634
  requestBytes?: number;
1603
1635
  responseStatus?: number;
1636
+ /** Semantic final status; the HTTP status may already have been committed. */
1637
+ finalStatus?: number;
1638
+ /** Terminal bookkeeping health, separate from the model outcome. */
1639
+ telemetryStatus?: "complete" | "timeout" | "observer_error" | "missing_final";
1640
+ /** Transport completion is independent of successful model completion. */
1641
+ transportOutcome?: ProxyResponseTerminalOutcome;
1642
+ outcomeSource?: "final_request" | "transport_error" | "http_status" | "unknown";
1604
1643
  /** Decoded response-body bytes observed by the adapter. */
1605
1644
  observedBodyBytes?: number;
1606
1645
  responseChunks?: number;
@@ -1627,6 +1666,10 @@ export type ProxyLifecycleLoggerSnapshot = {
1627
1666
  writeFailures: number;
1628
1667
  /** Events requeued after a transient lifecycle metadata write failure. */
1629
1668
  writeRetries: number;
1669
+ /** Slow appends still owned by the original writer, never replayed on timeout. */
1670
+ writeTimeouts: number;
1671
+ /** Records in failed appends that may have partially reached the file. */
1672
+ unconfirmedWrites: number;
1630
1673
  pending: number;
1631
1674
  inFlight: number;
1632
1675
  flushing: boolean;
@@ -1698,6 +1741,12 @@ export type ProxyAnalysisReport = {
1698
1741
  unsupportedLifecycleLines: number;
1699
1742
  lifecycleSequenceGaps: number;
1700
1743
  lifecycleSequenceDuplicates: number;
1744
+ conflictingLifecycleDuplicates: number;
1745
+ duplicateAttempts: number;
1746
+ finalOutcomeConflicts: number;
1747
+ /** Missing evidence; may include in-flight or interrupted requests. */
1748
+ acceptedWithoutFinal: number;
1749
+ terminalWithoutFinal: number;
1701
1750
  streams: Record<ProxyAnalysisStreamName, {
1702
1751
  observedFrom: string | null;
1703
1752
  observedTo: string | null;
@@ -1755,6 +1804,7 @@ export type ProxyAnalysisReport = {
1755
1804
  latencyMs: {
1756
1805
  headers: ProxyLatencySummary;
1757
1806
  firstChunk: ProxyLatencySummary;
1807
+ firstUsefulOutput: ProxyLatencySummary;
1758
1808
  terminal: ProxyLatencySummary;
1759
1809
  finalRequest: ProxyLatencySummary;
1760
1810
  attempt: ProxyLatencySummary;
@@ -1817,6 +1867,7 @@ export type ProxyAnalysisAttemptRecord = {
1817
1867
  };
1818
1868
  /** Final request fields retained while joining offline proxy log records. */
1819
1869
  export type ProxyAnalysisFinalRequestRecord = {
1870
+ firstUsefulOutputMs: number | null;
1820
1871
  timestamp: string;
1821
1872
  status: number;
1822
1873
  durationMs: number | null;
@@ -1861,6 +1912,15 @@ export type CodexStreamUsage = {
1861
1912
  cacheCreationTokens: number;
1862
1913
  reasoningTokens: number;
1863
1914
  };
1915
+ /** Semantic completion evidence observed in native Codex SSE bytes. */
1916
+ export type CodexStreamEvidence = {
1917
+ completed: boolean;
1918
+ terminalBytes: number;
1919
+ firstUsefulOutputAt?: number;
1920
+ errorType?: string;
1921
+ errorMessage?: string;
1922
+ errorCode?: string;
1923
+ };
1864
1924
  /** Validated account-routing evidence joined to a final request log. */
1865
1925
  export type ProxyAnalysisRoutingRecord = {
1866
1926
  requestId: string;
@@ -1883,6 +1943,8 @@ export type RuntimeRequestMetadata = {
1883
1943
  rejectForUpdate?: boolean;
1884
1944
  terminalErrorType?: string;
1885
1945
  terminalErrorCode?: string;
1946
+ /** Canonical final record, populated synchronously before asynchronous I/O. */
1947
+ terminalResult?: RequestLogEntry;
1886
1948
  /** Releases this request's peer-share concurrency slot. Set by the share
1887
1949
  * gate for borrowed traffic; invoked once the response body completes, so a
1888
1950
  * long stream holds its slot for as long as it is actually streaming. */
@@ -2073,6 +2135,8 @@ export type SSEContentBlock = {
2073
2135
  };
2074
2136
  /** Aggregated telemetry resolved when an SSE stream completes. */
2075
2137
  export type SSETelemetry = {
2138
+ messageStopReceived: boolean;
2139
+ firstUsefulOutputAt?: number;
2076
2140
  messageId: string;
2077
2141
  model: string;
2078
2142
  usage: {
@@ -2115,6 +2179,8 @@ export type StreamTerminalOutcomeTracker = {
2115
2179
  };
2116
2180
  /** Mutable accumulator the SSE interceptor uses internally. */
2117
2181
  export type TelemetryAccumulator = {
2182
+ messageStopReceived: boolean;
2183
+ firstUsefulOutputAt?: number;
2118
2184
  messageId: string;
2119
2185
  model: string;
2120
2186
  inputTokens: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/neurolink",
3
- "version": "12.12.6",
3
+ "version": "12.12.8",
4
4
  "packageManager": "pnpm@10.15.1",
5
5
  "description": "TypeScript AI SDK with 24+ LLM providers behind one consistent API. MCP-native (connect any MCP server), voice TTS/STT/realtime, RAG, agents, memory, context compaction. OpenAI · Anthropic · Gemini · Bedrock · Azure · Ollama · DeepSeek · NVIDIA NIM and more.",
6
6
  "author": {
@@ -112,6 +112,7 @@
112
112
  "test:mcp:spans": "pnpm exec tsx test/continuous-test-suite-mcp-spans.ts",
113
113
  "test:mcp:infra": "pnpm exec tsx test/continuous-test-suite-mcp-infra.ts",
114
114
  "test:vendor-recovery": "pnpm exec tsx test/continuous-test-suite-native-vendor-recovery.ts",
115
+ "test:browser-bundle": "pnpm exec tsx test/continuous-test-suite-browser-bundle.ts",
115
116
  "test:providers-mocked": "pnpm exec tsx test/continuous-test-suite-providers-mocked.ts",
116
117
  "scaffold:provider": "pnpm exec tsx tools/scaffold-provider.ts",
117
118
  "verify:provider-onboarding": "pnpm exec tsx tools/verify-provider-onboarding.ts",
@@ -143,6 +144,7 @@
143
144
  "test:dynamic": "pnpm exec tsx test/continuous-test-suite-dynamic.ts",
144
145
  "test:proxy": "pnpm exec tsx test/continuous-test-suite-proxy.ts",
145
146
  "test:proxy-connect-retry": "pnpm exec tsx test/continuous-test-suite-proxy-connect-retry.ts",
147
+ "test:proxy-telemetry": "pnpm exec tsx test/continuous-test-suite-proxy-telemetry.ts",
146
148
  "test:codex": "pnpm exec tsx test/continuous-test-suite-codex.ts",
147
149
  "test:bugfixes": "pnpm exec tsx test/continuous-test-suite-bugfixes.ts",
148
150
  "test:json-e2e": "pnpm exec tsx test/continuous-test-suite-json-e2e.ts",