@junando/core 0.12.3 → 0.13.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/dist/index.d.ts +14 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +107 -84
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -556,6 +556,13 @@ interface IAlertQueue {
|
|
|
556
556
|
interface ITraceRepository {
|
|
557
557
|
findByTraceId(traceId: string): Promise<Record<string, unknown>[]>;
|
|
558
558
|
}
|
|
559
|
+
/**
|
|
560
|
+
* Reason a parse attempt could not produce a diagnosis.
|
|
561
|
+
* `unparseable_response` — non-empty raw text that neither JSON nor regex
|
|
562
|
+
* stage could extract a usable analysis from.
|
|
563
|
+
* `empty_response` — the provider returned an empty (or whitespace-only) string.
|
|
564
|
+
*/
|
|
565
|
+
type LlmDegradedReason = 'unparseable_response' | 'empty_response';
|
|
559
566
|
/**
|
|
560
567
|
* Structured result of an LLM analysis call.
|
|
561
568
|
* Carries the diagnosis plus the observability metadata that feeds the
|
|
@@ -563,7 +570,8 @@ interface ITraceRepository {
|
|
|
563
570
|
* total tokens = promptTokens + completionTokens).
|
|
564
571
|
*/
|
|
565
572
|
interface LLMResult {
|
|
566
|
-
analysis: LLMAnalysis;
|
|
573
|
+
analysis: LLMAnalysis | null;
|
|
574
|
+
degradedReason?: LlmDegradedReason;
|
|
567
575
|
provider: string;
|
|
568
576
|
model: string;
|
|
569
577
|
latencyMs: number;
|
|
@@ -776,7 +784,10 @@ interface LlmSection {
|
|
|
776
784
|
provider: string;
|
|
777
785
|
model: string;
|
|
778
786
|
latencyMs: number;
|
|
779
|
-
|
|
787
|
+
/** Present only when parseAnalysis produced a diagnosis. */
|
|
788
|
+
urgency?: string;
|
|
789
|
+
/** Present only when analysis is null — why no diagnosis was produced. */
|
|
790
|
+
degradedReason?: string;
|
|
780
791
|
tokens: number;
|
|
781
792
|
}
|
|
782
793
|
interface NotifySection {
|
|
@@ -1258,5 +1269,5 @@ export declare class FactoryRegistry<T> {
|
|
|
1258
1269
|
*/
|
|
1259
1270
|
export declare function flushLoki(): Promise<void>;
|
|
1260
1271
|
//#endregion
|
|
1261
|
-
export { type Config, type DedupResult, type IAlertQueue, type IDeduplicationStore, type IIndexer, type ILLMProvider, type INotifier, type IRollbackActionHandler, type IRuleEngine, type ITraceRepository, type LLMResult, type Logger, type LoggerOptions, type NotifyResult, type OpenSearchHttpFetcher, type OpenSearchHttpResponse, type OpenSearchIndexerDeps, type RollbackActionRequest, type RollbackActionResult, type RuleActionResult, type SignedHttpRequest, type TraceabilityDocument, index_d_exports as metrics };
|
|
1272
|
+
export { type Config, type DedupResult, type IAlertQueue, type IDeduplicationStore, type IIndexer, type ILLMProvider, type INotifier, type IRollbackActionHandler, type IRuleEngine, type ITraceRepository, type LLMResult, type LlmDegradedReason, type Logger, type LoggerOptions, type NotifyResult, type OpenSearchHttpFetcher, type OpenSearchHttpResponse, type OpenSearchIndexerDeps, type RollbackActionRequest, type RollbackActionResult, type RuleActionResult, type SignedHttpRequest, type TraceabilityDocument, index_d_exports as metrics };
|
|
1262
1273
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/shared/constants.ts","../src/domain/entities/alert.ts","../src/domain/entities/cluster.ts","../src/domain/entities/incident.ts","../src/domain/entities/rule.ts","../src/domain/entities/traceability.ts","../src/domain/value-objects/fingerprint.ts","../src/domain/ports/index.ts","../src/domain/services/clustering.service.ts","../src/application/dtos/normalize-payload.ts","../src/shared/logger/enums.ts","../src/shared/logger/wide-event-builder.ts","../src/shared/logger/index.ts","../src/application/use-cases/process-incident.use-case.ts","../src/infrastructure/dedup/redis-dedup.adapter.ts","../src/infrastructure/indexer/opensearch.adapter.ts","../src/infrastructure/llm/llm.adapter.ts","../src/shared/config/index.ts","../src/infrastructure/rules/channel-registry.ts","../src/infrastructure/notifier/factory.ts","../src/infrastructure/rollback/factory.ts","../src/infrastructure/rollback/noop-rollback-action.handler.ts","../src/infrastructure/notifier/slack.adapter.ts","../src/infrastructure/notifier/teams.adapter.ts","../src/infrastructure/notifier/routing-notifier.ts","../src/infrastructure/queue/sqs.adapter.ts","../src/infrastructure/queue/sqs-lag-poller.ts","../src/infrastructure/traces/loki-trace.adapter.ts","../src/infrastructure/rules/yaml-rule-loader.ts","../src/infrastructure/rules/condition-evaluator.ts","../src/infrastructure/rules/action-dispatcher.ts","../src/infrastructure/rules/rule-engine.ts","../src/shared/factory-registry.ts","../src/shared/logger/loki-transport.ts"],"mappings":";;;;;;oBAMY;EACV;EACA;EACA;;UAGQ;WACC;WACA;WACA,UAAU,iBAAiB,WAAW;;cAG3C,mBAAmB,OAAO,WAAW;qBAmB9B,mBAAmB,gBAAgB;oBAIpC;EACV;EACA;EACA;EACA;;qBAIW,iBAAe;;;;;;qBAOf,iBAAe;;;;;qBAMf;qBAGA,cAAY;;;;qBAMZ;qBAGA;qBAGA;qBAGA,uBAAqB;;EAM3B;;qBAIM,YAAU;;;;;qBAOV;qBACA;qBAGA;cAEP,eAAe;qBAMR,eAAe,gBAAgB;qBAG/B;qBAGA,kBAAgB;;;;qBAKhB,kBAAgB;;;;;;;qBC/GhB,mBAAiB,EAAA;;;;qBAEjB,uBAAqB,EAAA;;;;;;;;;;;;;;;GAYhC,EAAA,KAAA;qBAIW,2BAAyB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;GAsBpC,EAAA,KAAA;YAEU,cAAc,EAAE,aAAa;YAC7B,kBAAkB,EAAE,aAAa;YACjC,sBAAsB,EAAE,aAAa;YAGrC,iBAAiB;;;qBC9ChB,oBAAkB,EAAA;;;;;;;;;;;;;;;;GAa7B,EAAA,KAAA;YAEU,eAAe,EAAE,aAAa;;;qBCtB7B,oBAAkB,EAAA;;;;;;qBAGlB,mBAAiB,EAAA;;;;;;;;;;;GAM5B,EAAA,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;;UChJvC;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;;qBCLW;WACkB;UAAtB;SAEA,UAAU,OAAO,kBAAkB;EAW1C,OAAO,OAAO;EAId;;;;;;;;UCNe;EACf;EACA;;EAEA;;;;;;;UAQe;EACf,MAAM,qBAAqB,qBAAqB,QAAQ;EACxD,MAAM,sBAAsB;;;;;;;UAQb;EACf,QAAQ,OAAO,kBAAkB;;;;;;;UAQlB;EACf,cAAc,kBAAkB,QAAQ;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/shared/constants.ts","../src/domain/entities/alert.ts","../src/domain/entities/cluster.ts","../src/domain/entities/incident.ts","../src/domain/entities/rule.ts","../src/domain/entities/traceability.ts","../src/domain/value-objects/fingerprint.ts","../src/domain/ports/index.ts","../src/domain/services/clustering.service.ts","../src/application/dtos/normalize-payload.ts","../src/shared/logger/enums.ts","../src/shared/logger/wide-event-builder.ts","../src/shared/logger/index.ts","../src/application/use-cases/process-incident.use-case.ts","../src/infrastructure/dedup/redis-dedup.adapter.ts","../src/infrastructure/indexer/opensearch.adapter.ts","../src/infrastructure/llm/llm.adapter.ts","../src/shared/config/index.ts","../src/infrastructure/rules/channel-registry.ts","../src/infrastructure/notifier/factory.ts","../src/infrastructure/rollback/factory.ts","../src/infrastructure/rollback/noop-rollback-action.handler.ts","../src/infrastructure/notifier/slack.adapter.ts","../src/infrastructure/notifier/teams.adapter.ts","../src/infrastructure/notifier/routing-notifier.ts","../src/infrastructure/queue/sqs.adapter.ts","../src/infrastructure/queue/sqs-lag-poller.ts","../src/infrastructure/traces/loki-trace.adapter.ts","../src/infrastructure/rules/yaml-rule-loader.ts","../src/infrastructure/rules/condition-evaluator.ts","../src/infrastructure/rules/action-dispatcher.ts","../src/infrastructure/rules/rule-engine.ts","../src/shared/factory-registry.ts","../src/shared/logger/loki-transport.ts"],"mappings":";;;;;;oBAMY;EACV;EACA;EACA;;UAGQ;WACC;WACA;WACA,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xC,QAAQ,OAAO,kBAAkB;;qBAqB5B,8BAA8B;WAChC,WAAW;EAEd,QAAQ,OAAO,kBAAkB;;;;wBC7DzB,kBACd,kBACA,oBACA;;;qBCLW,+BAA+B;mBAEvB;mBACA;EAFnB,YACmB,iBACA;EAGb,cAAc,kBAAkB,QAAQ;UAmBtC;UASA;;qBAaG,+BAA+B;mBACb;EAA7B,YAA6B,WAAU,YAAY;EAE7C,cAAc,kBAAkB,QAAQ;EAI9C,WAAW,iBAAiB,OAAO;;;;;;;;;;wBChDrB,gBAAgB,qBAAqB;;;KCLhD,aAAa,SAAS,cAAc,WAAW;;;;;;;;;wBA6FpC,iBAAiB,WAAW,yBAAyB;;;;;;;;;;wBC7DrD,gBAAgB,SAAS,eAAe;;;qBCrB3C,sBAAsB;mBAChB;mBACA;EAEjB,YAAY,QAAQ;;;;;;EAUpB,eAAe,SAAS,eAAe;;;;;;EASvC,gBACE,SAAS,cACT,UAAU,cACT;UAMK;UAQA;;;;qBCxDG,gBAAgB;mBACV;UACT;;;;;EAQR,SAAS,aAAa,eAAe;;;;EAOrC,gBAAgB,eAAe;;;;;EAQ/B,QAAQ,cAAc;;;;EAWtB,IAAI;;;;EAOJ;;;;;;;;;wBCkDoB,aAAa"}
|
package/dist/index.js
CHANGED
|
@@ -487,6 +487,58 @@ var WideEventBuilder = class {
|
|
|
487
487
|
};
|
|
488
488
|
}
|
|
489
489
|
};
|
|
490
|
+
//#endregion
|
|
491
|
+
//#region src/shared/logger/enums.ts
|
|
492
|
+
/**
|
|
493
|
+
* Pipeline component taxonomy.
|
|
494
|
+
*
|
|
495
|
+
* `component` (not `service`) distinguishes pipeline stages in wide events.
|
|
496
|
+
* `service` stays constant ("junando"); `component` tells you WHERE the event
|
|
497
|
+
* was emitted from.
|
|
498
|
+
*/
|
|
499
|
+
const Component = {
|
|
500
|
+
Webhook: "webhook",
|
|
501
|
+
Worker: "worker",
|
|
502
|
+
UseCase: "useCase",
|
|
503
|
+
Llm: "llm",
|
|
504
|
+
Notifier: "notifier",
|
|
505
|
+
Dedup: "dedup",
|
|
506
|
+
Traces: "traces",
|
|
507
|
+
Ingest: "ingest",
|
|
508
|
+
Rollback: "rollback"
|
|
509
|
+
};
|
|
510
|
+
/**
|
|
511
|
+
* Pipeline stages that write their results into the WideEventBuilder.
|
|
512
|
+
*/
|
|
513
|
+
const Stage = {
|
|
514
|
+
Dedup: "dedup",
|
|
515
|
+
RulesPre: "rulesPre",
|
|
516
|
+
Traces: "traces",
|
|
517
|
+
Llm: "llm",
|
|
518
|
+
RulesPost: "rulesPost",
|
|
519
|
+
Notify: "notify"
|
|
520
|
+
};
|
|
521
|
+
/**
|
|
522
|
+
* Terminal outcomes for a wide event across all entry points.
|
|
523
|
+
*/
|
|
524
|
+
const Outcome = {
|
|
525
|
+
Success: "success",
|
|
526
|
+
Suppressed: "suppressed",
|
|
527
|
+
Degraded: "degraded",
|
|
528
|
+
Error: "error",
|
|
529
|
+
Accepted: "accepted",
|
|
530
|
+
Empty: "empty",
|
|
531
|
+
ParseError: "parse_error"
|
|
532
|
+
};
|
|
533
|
+
/**
|
|
534
|
+
* Reason recorded for a tail-sampling decision.
|
|
535
|
+
*/
|
|
536
|
+
const SamplingDecision = {
|
|
537
|
+
Error: "error",
|
|
538
|
+
Slow: "slow",
|
|
539
|
+
Random: "random",
|
|
540
|
+
Skipped: "skipped"
|
|
541
|
+
};
|
|
490
542
|
/** Probability of sampling a normal (non-error, non-slow) event. */
|
|
491
543
|
const NORMAL_SAMPLE_RATE = .05;
|
|
492
544
|
/**
|
|
@@ -498,6 +550,7 @@ const NORMAL_SAMPLE_RATE = .05;
|
|
|
498
550
|
function shouldSample(event) {
|
|
499
551
|
if (event.error != null) return true;
|
|
500
552
|
if (event.durationMs !== void 0 && event.durationMs > 1e4) return true;
|
|
553
|
+
if (event.outcome === Outcome.Degraded) return true;
|
|
501
554
|
return Math.random() < NORMAL_SAMPLE_RATE;
|
|
502
555
|
}
|
|
503
556
|
//#endregion
|
|
@@ -568,58 +621,6 @@ function redact(obj) {
|
|
|
568
621
|
}));
|
|
569
622
|
}
|
|
570
623
|
//#endregion
|
|
571
|
-
//#region src/shared/logger/enums.ts
|
|
572
|
-
/**
|
|
573
|
-
* Pipeline component taxonomy.
|
|
574
|
-
*
|
|
575
|
-
* `component` (not `service`) distinguishes pipeline stages in wide events.
|
|
576
|
-
* `service` stays constant ("junando"); `component` tells you WHERE the event
|
|
577
|
-
* was emitted from.
|
|
578
|
-
*/
|
|
579
|
-
const Component = {
|
|
580
|
-
Webhook: "webhook",
|
|
581
|
-
Worker: "worker",
|
|
582
|
-
UseCase: "useCase",
|
|
583
|
-
Llm: "llm",
|
|
584
|
-
Notifier: "notifier",
|
|
585
|
-
Dedup: "dedup",
|
|
586
|
-
Traces: "traces",
|
|
587
|
-
Ingest: "ingest",
|
|
588
|
-
Rollback: "rollback"
|
|
589
|
-
};
|
|
590
|
-
/**
|
|
591
|
-
* Pipeline stages that write their results into the WideEventBuilder.
|
|
592
|
-
*/
|
|
593
|
-
const Stage = {
|
|
594
|
-
Dedup: "dedup",
|
|
595
|
-
RulesPre: "rulesPre",
|
|
596
|
-
Traces: "traces",
|
|
597
|
-
Llm: "llm",
|
|
598
|
-
RulesPost: "rulesPost",
|
|
599
|
-
Notify: "notify"
|
|
600
|
-
};
|
|
601
|
-
/**
|
|
602
|
-
* Terminal outcomes for a wide event across all entry points.
|
|
603
|
-
*/
|
|
604
|
-
const Outcome = {
|
|
605
|
-
Success: "success",
|
|
606
|
-
Suppressed: "suppressed",
|
|
607
|
-
Degraded: "degraded",
|
|
608
|
-
Error: "error",
|
|
609
|
-
Accepted: "accepted",
|
|
610
|
-
Empty: "empty",
|
|
611
|
-
ParseError: "parse_error"
|
|
612
|
-
};
|
|
613
|
-
/**
|
|
614
|
-
* Reason recorded for a tail-sampling decision.
|
|
615
|
-
*/
|
|
616
|
-
const SamplingDecision = {
|
|
617
|
-
Error: "error",
|
|
618
|
-
Slow: "slow",
|
|
619
|
-
Random: "random",
|
|
620
|
-
Skipped: "skipped"
|
|
621
|
-
};
|
|
622
|
-
//#endregion
|
|
623
624
|
//#region src/shared/logger/index.ts
|
|
624
625
|
let _root = buildLogger({});
|
|
625
626
|
function buildLogger(opts) {
|
|
@@ -689,12 +690,14 @@ function toErrorSection(err) {
|
|
|
689
690
|
}
|
|
690
691
|
/**
|
|
691
692
|
* Terminal outcome for a processed cluster. Early returns — no switch/case.
|
|
692
|
-
* Notify failure is fatal (the batch is retried via SQS); LLM
|
|
693
|
-
* degraded
|
|
693
|
+
* Notify failure is fatal (the batch is retried via SQS); LLM transport
|
|
694
|
+
* failure and a parse-degraded diagnosis both leave the cluster degraded
|
|
695
|
+
* (notification still went out, with or without a diagnosis).
|
|
694
696
|
*/
|
|
695
|
-
function resolveOutcome({ llmError, notifyError }) {
|
|
697
|
+
function resolveOutcome({ llmError, notifyError, llmDegradedReason }) {
|
|
696
698
|
if (notifyError != null) return Outcome.Error;
|
|
697
699
|
if (llmError != null) return Outcome.Degraded;
|
|
700
|
+
if (llmDegradedReason != null) return Outcome.Degraded;
|
|
698
701
|
return Outcome.Success;
|
|
699
702
|
}
|
|
700
703
|
var ProcessIncidentUseCase = class {
|
|
@@ -762,14 +765,17 @@ var ProcessIncidentUseCase = class {
|
|
|
762
765
|
});
|
|
763
766
|
let analysis = null;
|
|
764
767
|
let llmError = null;
|
|
768
|
+
let llmDegradedReason = null;
|
|
765
769
|
try {
|
|
766
770
|
const llmResult = await llm.analyze(cluster, allSpans);
|
|
767
771
|
analysis = llmResult.analysis;
|
|
772
|
+
llmDegradedReason = llmResult.degradedReason ?? null;
|
|
768
773
|
builder.set("llm", {
|
|
769
774
|
provider: llmResult.provider,
|
|
770
775
|
model: llmResult.model,
|
|
771
776
|
latencyMs: llmResult.latencyMs,
|
|
772
|
-
urgency: llmResult.analysis.urgency_level,
|
|
777
|
+
...llmResult.analysis && { urgency: llmResult.analysis.urgency_level },
|
|
778
|
+
...llmResult.degradedReason && { degradedReason: llmResult.degradedReason },
|
|
773
779
|
tokens: llmResult.promptTokens + llmResult.completionTokens
|
|
774
780
|
});
|
|
775
781
|
} catch (err) {
|
|
@@ -808,7 +814,8 @@ var ProcessIncidentUseCase = class {
|
|
|
808
814
|
if (llmError != null) builder.set("error", toErrorSection(llmError));
|
|
809
815
|
this.emit(builder, resolveOutcome({
|
|
810
816
|
llmError,
|
|
811
|
-
notifyError: null
|
|
817
|
+
notifyError: null,
|
|
818
|
+
llmDegradedReason
|
|
812
819
|
}), clusterStartMs);
|
|
813
820
|
}
|
|
814
821
|
}
|
|
@@ -961,20 +968,22 @@ function buildUserPrompt(cluster, traces) {
|
|
|
961
968
|
}
|
|
962
969
|
/**
|
|
963
970
|
* Extracts LLMAnalysis from raw LLM response text.
|
|
964
|
-
*
|
|
965
|
-
*
|
|
971
|
+
* Two-stage parsing: JSON → regex fallback. Never fabricates a diagnosis —
|
|
972
|
+
* returns null when neither stage produces a usable analysis.
|
|
966
973
|
*/
|
|
967
974
|
function parseAnalysis(raw, correlationId) {
|
|
968
975
|
const startIdx = raw.indexOf("{");
|
|
969
976
|
const endIdx = raw.lastIndexOf("}");
|
|
977
|
+
let stage1Succeeded = false;
|
|
970
978
|
if (startIdx !== -1 && endIdx !== -1 && endIdx > startIdx) try {
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
979
|
+
const analysis = LLMAnalysisSchema.parse(JSON.parse(raw.slice(startIdx, endIdx + 1)));
|
|
980
|
+
stage1Succeeded = true;
|
|
981
|
+
return analysis;
|
|
982
|
+
} catch {}
|
|
983
|
+
if (!stage1Succeeded) logger$5.warn({
|
|
984
|
+
rawResponse: raw.slice(0, 500),
|
|
985
|
+
correlationId
|
|
986
|
+
}, "llm:parse:failed");
|
|
978
987
|
const probableCauseMatch = RE_PROBABLE_CAUSE.exec(raw);
|
|
979
988
|
const urgencyMatch = RE_URGENCY_LEVEL.exec(raw);
|
|
980
989
|
const rollbackMatch = RE_REQUIRES_ROLLBACK.exec(raw);
|
|
@@ -991,20 +1000,34 @@ function parseAnalysis(raw, correlationId) {
|
|
|
991
1000
|
urgency_level: urgency,
|
|
992
1001
|
requires_rollback: rollbackMatch?.[1] === "true"
|
|
993
1002
|
};
|
|
994
|
-
|
|
1003
|
+
const parsed = LLMAnalysisSchema.parse(analysis);
|
|
1004
|
+
logger$5.warn({
|
|
1005
|
+
matchedFields: ["probable_cause", "urgency_level"],
|
|
1006
|
+
correlationId
|
|
1007
|
+
}, "llm:parse:partial");
|
|
1008
|
+
return parsed;
|
|
995
1009
|
}
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1010
|
+
logger$5.warn({ correlationId }, "llm:parse:unusable");
|
|
1011
|
+
return null;
|
|
1012
|
+
}
|
|
1013
|
+
/**
|
|
1014
|
+
* Shared entry point for turning provider text into a diagnosis (or a
|
|
1015
|
+
* degradedReason explaining why not). Detects empty responses once, here,
|
|
1016
|
+
* before delegating to parseAnalysis.
|
|
1017
|
+
*/
|
|
1018
|
+
function parseLlmText(raw, correlationId) {
|
|
1019
|
+
if (raw.trim() === "") {
|
|
1020
|
+
logger$5.warn({ correlationId }, "llm:parse:empty");
|
|
1021
|
+
return {
|
|
1022
|
+
analysis: null,
|
|
1023
|
+
degradedReason: "empty_response"
|
|
1024
|
+
};
|
|
1025
|
+
}
|
|
1026
|
+
const analysis = parseAnalysis(raw, correlationId);
|
|
1027
|
+
return analysis ? { analysis } : {
|
|
1028
|
+
analysis: null,
|
|
1029
|
+
degradedReason: "unparseable_response"
|
|
1030
|
+
};
|
|
1008
1031
|
}
|
|
1009
1032
|
/**
|
|
1010
1033
|
* Gemini LLM provider using Google Generative AI SDK.
|
|
@@ -1043,7 +1066,7 @@ var GeminiProvider = class {
|
|
|
1043
1066
|
}).generateContent(buildUserPrompt(cluster, traces));
|
|
1044
1067
|
const usage = result.response.usageMetadata;
|
|
1045
1068
|
return {
|
|
1046
|
-
|
|
1069
|
+
...parseLlmText(result.response.text()),
|
|
1047
1070
|
promptTokens: usage?.promptTokenCount ?? 0,
|
|
1048
1071
|
completionTokens: usage?.candidatesTokenCount ?? 0
|
|
1049
1072
|
};
|
|
@@ -1073,7 +1096,7 @@ var ClaudeProvider = class {
|
|
|
1073
1096
|
}]
|
|
1074
1097
|
});
|
|
1075
1098
|
return {
|
|
1076
|
-
|
|
1099
|
+
...parseLlmText(message.content.find((b) => b.type === "text")?.text ?? ""),
|
|
1077
1100
|
provider: "claude",
|
|
1078
1101
|
model: this.model,
|
|
1079
1102
|
latencyMs: Date.now() - startMs,
|
|
@@ -1190,7 +1213,7 @@ var OpenRouterProvider = class {
|
|
|
1190
1213
|
errors: parsed.error.format(),
|
|
1191
1214
|
correlationId
|
|
1192
1215
|
}, "llm:validation:failed");
|
|
1193
|
-
const
|
|
1216
|
+
const parsedAnalysis = parseLlmText(parsed.success ? parsed.data.choices?.[0]?.message?.content ?? "" : "", correlationId);
|
|
1194
1217
|
const usage = parsed.success ? parsed.data.usage : void 0;
|
|
1195
1218
|
if (usage) {
|
|
1196
1219
|
const { prompt_tokens, completion_tokens, total_tokens } = usage;
|
|
@@ -1208,7 +1231,7 @@ var OpenRouterProvider = class {
|
|
|
1208
1231
|
llmInferenceTotal.inc({ status: "success" });
|
|
1209
1232
|
llmInferenceDuration.observe({ model: this.model }, latencyMs / 1e3);
|
|
1210
1233
|
return {
|
|
1211
|
-
|
|
1234
|
+
...parsedAnalysis,
|
|
1212
1235
|
provider: this.providerName,
|
|
1213
1236
|
model: this.model,
|
|
1214
1237
|
latencyMs,
|
|
@@ -1258,7 +1281,7 @@ var OpenRouterProvider = class {
|
|
|
1258
1281
|
const text = parsed.success ? parsed.data.choices?.[0]?.message?.content ?? "" : "";
|
|
1259
1282
|
const usage = parsed.success ? parsed.data.usage : void 0;
|
|
1260
1283
|
return {
|
|
1261
|
-
|
|
1284
|
+
...parseLlmText(text, correlationId),
|
|
1262
1285
|
provider: this.providerName,
|
|
1263
1286
|
model: toModel,
|
|
1264
1287
|
latencyMs: Date.now() - startMs,
|