@juspay/neurolink 12.14.5 → 12.14.7
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 +2 -2
- package/dist/browser/neurolink.min.js +412 -412
- package/dist/cli/commands/proxy.d.ts +1 -1
- package/dist/cli/commands/proxy.js +123 -14
- package/dist/cli/commands/proxyRestart.d.ts +3 -0
- package/dist/cli/commands/proxyRestart.js +88 -0
- package/dist/cli/parser.js +3 -1
- package/dist/proxy/bodyCaptureWorker.js +26 -1
- package/dist/proxy/codexUsage.js +83 -2
- package/dist/proxy/otelLogSink.d.ts +13 -0
- package/dist/proxy/otelLogSink.js +62 -1
- package/dist/proxy/proxyTraceContext.d.ts +21 -0
- package/dist/proxy/proxyTraceContext.js +47 -0
- package/dist/proxy/proxyTracer.d.ts +9 -5
- package/dist/proxy/proxyTracer.js +81 -2
- package/dist/proxy/requestLogger.js +24 -18
- package/dist/proxy/restartControl.d.ts +12 -0
- package/dist/proxy/restartControl.js +283 -0
- package/dist/proxy/rollingWorkerSupervisor.js +8 -0
- package/dist/server/routes/codexProxyRoutes.js +414 -332
- package/dist/types/cli.d.ts +7 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/proxy.d.ts +119 -3
- package/dist/types/proxyRestart.d.ts +49 -0
- package/dist/types/proxyRestart.js +1 -0
- package/docs-site/static/search-index.json +1 -1
- package/package.json +2 -1
- package/scripts/observability/check-proxy-telemetry.mjs +29 -241
- package/scripts/observability/proxy-telemetry-backend.mjs +202 -0
- package/scripts/observability/proxy-telemetry-check.mjs +544 -0
- package/scripts/observability/query-proxy-history.mjs +30 -19
package/dist/types/cli.d.ts
CHANGED
|
@@ -834,8 +834,14 @@ export type ProxyGuardArgs = {
|
|
|
834
834
|
};
|
|
835
835
|
/** Arguments accepted by `neurolink proxy telemetry <subcommand>` */
|
|
836
836
|
export type ProxyTelemetryArgs = {
|
|
837
|
-
action?: "setup" | "start" | "stop" | "status" | "logs" | "import-dashboard";
|
|
837
|
+
action?: "setup" | "start" | "stop" | "status" | "logs" | "import-dashboard" | "doctor" | "query";
|
|
838
838
|
quiet?: boolean;
|
|
839
|
+
since?: string;
|
|
840
|
+
until?: string;
|
|
841
|
+
kind?: string;
|
|
842
|
+
format?: "json" | "text";
|
|
843
|
+
maxRows?: number;
|
|
844
|
+
proxyUrl?: string;
|
|
839
845
|
};
|
|
840
846
|
/** A fallback chain entry (serialisable subset of FallbackEntry) */
|
|
841
847
|
export type FallbackInfo = {
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
package/dist/types/proxy.d.ts
CHANGED
|
@@ -555,8 +555,14 @@ export type ProxyAccountSortMetrics = {
|
|
|
555
555
|
scopedSaturated: boolean;
|
|
556
556
|
};
|
|
557
557
|
export type RequestLogEntry = {
|
|
558
|
-
/** First
|
|
558
|
+
/** First text, refusal or populated tool output, excluding SSE control frames. */
|
|
559
559
|
firstUsefulOutputMs?: number;
|
|
560
|
+
/** Why first-useful-output timing is absent; never substitute a zero. */
|
|
561
|
+
firstUsefulOutputStatus?: "observed" | "no_useful_output" | "not_observed";
|
|
562
|
+
/** Native protocol event that established the first useful output. */
|
|
563
|
+
firstUsefulOutputEvent?: string;
|
|
564
|
+
/** Requested reasoning effort retained independently of body capture. */
|
|
565
|
+
reasoningEffort?: string;
|
|
560
566
|
/** Small routing evidence retained even when response bodies are pruned. */
|
|
561
567
|
fallbackPlan?: Array<{
|
|
562
568
|
provider: string;
|
|
@@ -610,6 +616,8 @@ export type RequestLogEntry = {
|
|
|
610
616
|
traceId?: string;
|
|
611
617
|
/** OTel span ID for correlation with distributed traces */
|
|
612
618
|
spanId?: string;
|
|
619
|
+
/** Original OTel sampling flags retained through deferred logging. */
|
|
620
|
+
traceFlags?: number;
|
|
613
621
|
/** Exact secret-free inputs and result of initial account selection. */
|
|
614
622
|
routingDecision?: ProxyAccountRoutingDecision;
|
|
615
623
|
};
|
|
@@ -631,6 +639,16 @@ export type ProcessedProxyBodyCapture = {
|
|
|
631
639
|
error?: string;
|
|
632
640
|
queueWaitMs?: number;
|
|
633
641
|
processingMs?: number;
|
|
642
|
+
admission?: ProxyBodyCaptureAdmission;
|
|
643
|
+
};
|
|
644
|
+
/** Exact bounded-admission state; records no request content. */
|
|
645
|
+
export type ProxyBodyCaptureAdmission = {
|
|
646
|
+
limitingResource: "entry" | "captures" | "bytes" | "worker";
|
|
647
|
+
estimatedBytes?: number;
|
|
648
|
+
pending: number;
|
|
649
|
+
pendingBytes: number;
|
|
650
|
+
maxPending: number;
|
|
651
|
+
maxPendingBytes: number;
|
|
634
652
|
};
|
|
635
653
|
export type ProxyBodyCaptureWorkerSnapshot = {
|
|
636
654
|
attempted: number;
|
|
@@ -641,9 +659,12 @@ export type ProxyBodyCaptureWorkerSnapshot = {
|
|
|
641
659
|
pendingBytes: number;
|
|
642
660
|
maxPending: number;
|
|
643
661
|
maxPendingBytes: number;
|
|
662
|
+
highWaterPending: number;
|
|
663
|
+
highWaterBytes: number;
|
|
644
664
|
/** Admission failures by exact guard, independent of processing failures. */
|
|
645
665
|
rejectionReasons: Record<string, number>;
|
|
646
666
|
lastError?: string;
|
|
667
|
+
lastRejectedAt?: string;
|
|
647
668
|
};
|
|
648
669
|
/** Collector transport evidence; acknowledgement does not prove backend storage. */
|
|
649
670
|
export type ProxyBodyDeliveryResult = {
|
|
@@ -664,6 +685,81 @@ export type ProxyBodyPublicationProgress = {
|
|
|
664
685
|
emitted: number;
|
|
665
686
|
notify?: () => void;
|
|
666
687
|
};
|
|
688
|
+
/** Bounded metadata-only evidence for an unconfirmed or locally rejected OTLP batch. */
|
|
689
|
+
export type ProxyOtelExportFailure = {
|
|
690
|
+
id: string;
|
|
691
|
+
at: string;
|
|
692
|
+
reason: "export_unconfirmed" | "queue_full";
|
|
693
|
+
error?: string;
|
|
694
|
+
records: Array<{
|
|
695
|
+
eventId: string;
|
|
696
|
+
kind?: string;
|
|
697
|
+
requestId?: string;
|
|
698
|
+
captureId?: string;
|
|
699
|
+
}>;
|
|
700
|
+
};
|
|
701
|
+
/** Read adapter configuration; credentials never appear in diagnostic reports. */
|
|
702
|
+
export type ProxyTelemetryBackend = {
|
|
703
|
+
baseUrl: string;
|
|
704
|
+
organization: string;
|
|
705
|
+
stream: string;
|
|
706
|
+
authorization?: string;
|
|
707
|
+
collectorMetricsUrl?: string;
|
|
708
|
+
};
|
|
709
|
+
export type ProxyTelemetryNativeConfig = {
|
|
710
|
+
exporters?: Record<string, {
|
|
711
|
+
endpoint?: string;
|
|
712
|
+
headers?: Record<string, string>;
|
|
713
|
+
}>;
|
|
714
|
+
};
|
|
715
|
+
export type ProxyTelemetryQueryBudget = {
|
|
716
|
+
used: number;
|
|
717
|
+
limit: number;
|
|
718
|
+
};
|
|
719
|
+
export type ProxyTelemetryQueryOptions = {
|
|
720
|
+
sql: string;
|
|
721
|
+
signal?: string;
|
|
722
|
+
startTime: number;
|
|
723
|
+
endTime: number;
|
|
724
|
+
size?: number;
|
|
725
|
+
offset?: number;
|
|
726
|
+
};
|
|
727
|
+
export type ProxyTelemetryDoctorOptions = {
|
|
728
|
+
backend: ProxyTelemetryBackend;
|
|
729
|
+
startTime: number;
|
|
730
|
+
endTime: number;
|
|
731
|
+
proxyUrl?: string;
|
|
732
|
+
maxRows?: number;
|
|
733
|
+
fetchImpl?: typeof fetch;
|
|
734
|
+
};
|
|
735
|
+
export type ProxyTelemetryCheck = {
|
|
736
|
+
name: string;
|
|
737
|
+
status: "pass" | "fail" | "warn" | "unverified";
|
|
738
|
+
evidence: unknown;
|
|
739
|
+
};
|
|
740
|
+
/** Small stored metadata used by the doctor; bodies are queried separately. */
|
|
741
|
+
export type ProxyTelemetryStoredRecord = Partial<RequestLogEntry> & {
|
|
742
|
+
captureId?: string;
|
|
743
|
+
bodySha256?: string;
|
|
744
|
+
redactedBodyBytes?: number;
|
|
745
|
+
bodyDelivery?: {
|
|
746
|
+
status?: string;
|
|
747
|
+
};
|
|
748
|
+
captureError?: string;
|
|
749
|
+
captureAdmission?: ProxyBodyCaptureAdmission;
|
|
750
|
+
bodyTruncated?: boolean;
|
|
751
|
+
phase?: string;
|
|
752
|
+
event?: string;
|
|
753
|
+
telemetryStatus?: string;
|
|
754
|
+
outcomeSource?: string;
|
|
755
|
+
};
|
|
756
|
+
export type ProxyTelemetryFieldCoverage = {
|
|
757
|
+
records: number;
|
|
758
|
+
traceMissing: number;
|
|
759
|
+
durationMissing: number;
|
|
760
|
+
outcomeMissing: number;
|
|
761
|
+
firstOutputUnexplained: number;
|
|
762
|
+
};
|
|
667
763
|
/** Chunk emission stays in the request logger, which owns request attributes. */
|
|
668
764
|
export type ProxyBodyChunkEmitter = (chunk: string, index: number, count: number) => void;
|
|
669
765
|
export type ProxyRequestLoggerSnapshot = {
|
|
@@ -721,9 +817,11 @@ export type RequestAttemptLogEntry = {
|
|
|
721
817
|
traceId?: string;
|
|
722
818
|
/** OTel span ID for correlation with distributed traces */
|
|
723
819
|
spanId?: string;
|
|
820
|
+
/** Original OTel sampling flags retained through deferred logging. */
|
|
821
|
+
traceFlags?: number;
|
|
724
822
|
};
|
|
725
823
|
/** Additional fields recorded when a Codex response becomes client-final. */
|
|
726
|
-
export type CodexFinalLogExtra = Partial<Pick<RequestLogEntry, "errorType" | "errorMessage" | "errorCode" | "transportScope" | "inputTokens" | "outputTokens" | "cacheReadTokens" | "cacheCreationTokens" | "terminalOutcome" | "firstUsefulOutputMs">>;
|
|
824
|
+
export type CodexFinalLogExtra = Partial<Pick<RequestLogEntry, "errorType" | "errorMessage" | "errorCode" | "transportScope" | "inputTokens" | "outputTokens" | "cacheReadTokens" | "cacheCreationTokens" | "terminalOutcome" | "firstUsefulOutputMs" | "firstUsefulOutputStatus" | "firstUsefulOutputEvent">>;
|
|
727
825
|
/** Additional fields recorded for each upstream Codex account attempt. */
|
|
728
826
|
export type CodexAttemptLogExtra = Partial<Pick<RequestAttemptLogEntry, "errorType" | "errorMessage" | "errorCode" | "transportScope" | "retryable" | "rateLimitKind" | "cooldownReason">>;
|
|
729
827
|
/** Minimal persistence contract needed by Codex rotating-token refreshes. */
|
|
@@ -1562,6 +1660,8 @@ export type ProxyRequestContext = {
|
|
|
1562
1660
|
* every non-Anthropic model prices to $0.
|
|
1563
1661
|
*/
|
|
1564
1662
|
provider?: string;
|
|
1663
|
+
/** An internal fallback is an attempt; its parent owns request/token metrics. */
|
|
1664
|
+
recordRequestMetrics?: boolean;
|
|
1565
1665
|
};
|
|
1566
1666
|
/** Response-side details parsed from the upstream reply (model, finish, tools). */
|
|
1567
1667
|
export type ResponseInfoContext = {
|
|
@@ -1998,7 +2098,10 @@ export type CodexStreamUsage = {
|
|
|
1998
2098
|
export type CodexStreamEvidence = {
|
|
1999
2099
|
completed: boolean;
|
|
2000
2100
|
terminalBytes: number;
|
|
2101
|
+
/** Malformed, oversized or undispatched frames prevent proving output absence. */
|
|
2102
|
+
observationIncomplete?: boolean;
|
|
2001
2103
|
firstUsefulOutputAt?: number;
|
|
2104
|
+
firstUsefulOutputEvent?: string;
|
|
2002
2105
|
errorType?: string;
|
|
2003
2106
|
errorMessage?: string;
|
|
2004
2107
|
errorCode?: string;
|
|
@@ -2017,6 +2120,11 @@ export type RuntimeRequestMetadata = {
|
|
|
2017
2120
|
/** Last dispatched attempt, retained until this HTTP request terminates. */
|
|
2018
2121
|
lastUpstreamAttempt?: RequestAttemptLogEntry;
|
|
2019
2122
|
requestId: string;
|
|
2123
|
+
/** Ingress OTel correlation survives detached stream/error callbacks. */
|
|
2124
|
+
traceId?: string;
|
|
2125
|
+
spanId?: string;
|
|
2126
|
+
/** Original OTel sampling flags retained through deferred logging. */
|
|
2127
|
+
traceFlags?: number;
|
|
2020
2128
|
method: string;
|
|
2021
2129
|
path: string;
|
|
2022
2130
|
startedAt: number;
|
|
@@ -2065,6 +2173,8 @@ export type ProxyBodyCaptureEntry = {
|
|
|
2065
2173
|
attempt?: number;
|
|
2066
2174
|
traceId?: string;
|
|
2067
2175
|
spanId?: string;
|
|
2176
|
+
/** Original OTel sampling flags retained through deferred logging. */
|
|
2177
|
+
traceFlags?: number;
|
|
2068
2178
|
metadata?: Record<string, unknown>;
|
|
2069
2179
|
};
|
|
2070
2180
|
/** JSON object retained in deterministic proxy replay artifacts. */
|
|
@@ -2874,7 +2984,7 @@ export type StatusStats = {
|
|
|
2874
2984
|
persistence?: ProxyStatsPersistenceStatus;
|
|
2875
2985
|
};
|
|
2876
2986
|
/** Sub-action of the `proxy telemetry` CLI command. */
|
|
2877
|
-
export type ProxyTelemetryAction = "setup" | "start" | "stop" | "status" | "logs" | "import-dashboard";
|
|
2987
|
+
export type ProxyTelemetryAction = "doctor" | "query" | "setup" | "start" | "stop" | "status" | "logs" | "import-dashboard";
|
|
2878
2988
|
/** Wire format a proxy request is using. */
|
|
2879
2989
|
export type ProxyFormat = "claude" | "openai" | "gemini";
|
|
2880
2990
|
/**
|
|
@@ -3866,3 +3976,9 @@ export type ProxyShareProvisioningBundle = {
|
|
|
3866
3976
|
expiresAt?: number;
|
|
3867
3977
|
};
|
|
3868
3978
|
};
|
|
3979
|
+
/** Log correlation retained independently of the current async context. */
|
|
3980
|
+
export type ProxyLogTraceContext = {
|
|
3981
|
+
traceId: string;
|
|
3982
|
+
spanId: string;
|
|
3983
|
+
traceFlags: number;
|
|
3984
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { RollingProxyServer } from "./proxy.js";
|
|
2
|
+
import type { ProxySupervisorState } from "./cli.js";
|
|
3
|
+
/** Supervisor state with the optional local restart capability. */
|
|
4
|
+
export type ProxyRestartSupervisorState = ProxySupervisorState & {
|
|
5
|
+
restartControl?: ProxyRestartControlIdentity;
|
|
6
|
+
};
|
|
7
|
+
export type ProxyRestartArgs = {
|
|
8
|
+
check: boolean;
|
|
9
|
+
dev: boolean;
|
|
10
|
+
format: "text" | "json";
|
|
11
|
+
};
|
|
12
|
+
/** Local supervisor control identity; contains no account credentials. */
|
|
13
|
+
export type ProxyRestartControlIdentity = {
|
|
14
|
+
protocol: 1;
|
|
15
|
+
socketPath: string;
|
|
16
|
+
instanceId: string;
|
|
17
|
+
};
|
|
18
|
+
/** Terminal result of a local restart check or worker activation. */
|
|
19
|
+
export type ProxyRestartResult = {
|
|
20
|
+
ok: boolean;
|
|
21
|
+
phase: "checked" | "refused" | "failed" | "activated" | "activated_unverified";
|
|
22
|
+
message: string;
|
|
23
|
+
supervisorPid: number;
|
|
24
|
+
previousWorkerPid?: number;
|
|
25
|
+
workerPid?: number;
|
|
26
|
+
version?: string;
|
|
27
|
+
drainingWorkers: number;
|
|
28
|
+
/** Observed during handoff/verification; does not attribute the cause. */
|
|
29
|
+
rejectedSocketsDelta?: number;
|
|
30
|
+
failedTransfersDelta?: number;
|
|
31
|
+
};
|
|
32
|
+
/** CLI failure before a supervisor result can be authenticated or received. */
|
|
33
|
+
export type CliProxyRestartError = {
|
|
34
|
+
ok: false;
|
|
35
|
+
phase: "unverified";
|
|
36
|
+
message: string;
|
|
37
|
+
};
|
|
38
|
+
/** JSON emitted by the restart CLI, including an unknown control outcome. */
|
|
39
|
+
export type CliProxyRestartOutput = ProxyRestartResult | CliProxyRestartError;
|
|
40
|
+
/** Supervisor-owned restart dependencies, injectable for isolated process tests. */
|
|
41
|
+
export type ProxyRestartControlOptions = {
|
|
42
|
+
stateDir: string;
|
|
43
|
+
server: RollingProxyServer;
|
|
44
|
+
getInstalledVersion: () => Promise<string | undefined>;
|
|
45
|
+
isUpdatePending: () => boolean;
|
|
46
|
+
getStatus: () => Promise<unknown>;
|
|
47
|
+
/** Report control-server errors without stopping the serving listener. */
|
|
48
|
+
log?: (message: string) => void;
|
|
49
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|