@resolveio/server-lib 22.3.196 → 22.3.198
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/package.json +1 -1
- package/util/ai-run-evidence-adapters.js +115 -1
- package/util/ai-run-evidence-adapters.js.map +1 -1
- package/util/ai-run-evidence-dashboard.d.ts +5 -1
- package/util/ai-run-evidence-dashboard.js +10 -3
- package/util/ai-run-evidence-dashboard.js.map +1 -1
- package/util/support-runner-v5.d.ts +39 -2
- package/util/support-runner-v5.js +203 -10
- package/util/support-runner-v5.js.map +1 -1
package/package.json
CHANGED
|
@@ -964,6 +964,88 @@ function collectUsageEvents(entries, events) {
|
|
|
964
964
|
}
|
|
965
965
|
return (0, ai_run_evidence_1.buildAIRunCost)(entries);
|
|
966
966
|
}
|
|
967
|
+
function costObservabilityGate(cost, source, now) {
|
|
968
|
+
var manualEstimatedUsd = Number((cost === null || cost === void 0 ? void 0 : cost.manualEstimatedUsd) || 0);
|
|
969
|
+
var untrackedEstimatedUsd = Number((cost === null || cost === void 0 ? void 0 : cost.untrackedEstimatedUsd) || 0);
|
|
970
|
+
var warnings = cleanStringList(cost === null || cost === void 0 ? void 0 : cost.untrackedWarnings, 20, 500);
|
|
971
|
+
var manualSources = Object.entries((cost === null || cost === void 0 ? void 0 : cost.sources) || {})
|
|
972
|
+
.filter(function (_a) {
|
|
973
|
+
var _b = __read(_a, 2), value = _b[1];
|
|
974
|
+
return Number(value.manualCount || 0) > 0;
|
|
975
|
+
})
|
|
976
|
+
.map(function (_a) {
|
|
977
|
+
var _b = __read(_a, 1), key = _b[0];
|
|
978
|
+
return key;
|
|
979
|
+
});
|
|
980
|
+
var untrackedSources = Object.entries((cost === null || cost === void 0 ? void 0 : cost.sources) || {})
|
|
981
|
+
.filter(function (_a) {
|
|
982
|
+
var _b = __read(_a, 2), value = _b[1];
|
|
983
|
+
return Number(value.untrackedCount || 0) > 0;
|
|
984
|
+
})
|
|
985
|
+
.map(function (_a) {
|
|
986
|
+
var _b = __read(_a, 1), key = _b[0];
|
|
987
|
+
return key;
|
|
988
|
+
});
|
|
989
|
+
var missingLedger = !cost;
|
|
990
|
+
var externalCodexMonitorUsed = manualEstimatedUsd > 0
|
|
991
|
+
|| untrackedEstimatedUsd > 0
|
|
992
|
+
|| manualSources.some(function (sourceKey) { return /codex|manual/i.test(sourceKey); })
|
|
993
|
+
|| warnings.some(function (warning) { return /codex|sidecar|monitor/i.test(warning); });
|
|
994
|
+
var status = missingLedger
|
|
995
|
+
? 'skipped'
|
|
996
|
+
: (manualEstimatedUsd > 0 || untrackedEstimatedUsd > 0 || warnings.length ? 'warn' : 'pass');
|
|
997
|
+
return {
|
|
998
|
+
key: 'cost_observability',
|
|
999
|
+
label: 'Cost observability',
|
|
1000
|
+
status: status,
|
|
1001
|
+
reason: missingLedger
|
|
1002
|
+
? 'No usage ledger was supplied for this run, so cost per accepted run cannot be fully evaluated.'
|
|
1003
|
+
: status === 'warn'
|
|
1004
|
+
? "Runner cost includes manual or untracked usage: manual=$".concat(manualEstimatedUsd.toFixed(2), ", untracked=$").concat(untrackedEstimatedUsd.toFixed(2), ".")
|
|
1005
|
+
: 'Runner usage is tracked in the unified cost ledger.',
|
|
1006
|
+
evidenceRefs: warnings,
|
|
1007
|
+
recordedAt: isoNow(now),
|
|
1008
|
+
metadata: {
|
|
1009
|
+
source: source,
|
|
1010
|
+
missingLedger: missingLedger,
|
|
1011
|
+
estimatedUsd: Number((cost === null || cost === void 0 ? void 0 : cost.estimatedUsd) || 0),
|
|
1012
|
+
manualEstimatedUsd: manualEstimatedUsd,
|
|
1013
|
+
untrackedEstimatedUsd: untrackedEstimatedUsd,
|
|
1014
|
+
externalCodexMonitorUsed: externalCodexMonitorUsed,
|
|
1015
|
+
manualSources: manualSources,
|
|
1016
|
+
untrackedSources: untrackedSources,
|
|
1017
|
+
models: cleanStringList(cost === null || cost === void 0 ? void 0 : cost.models, 40, 120),
|
|
1018
|
+
categories: Object.keys((cost === null || cost === void 0 ? void 0 : cost.categories) || {}).slice(0, 40),
|
|
1019
|
+
surfaces: Object.keys((cost === null || cost === void 0 ? void 0 : cost.surfaces) || {}).slice(0, 40),
|
|
1020
|
+
warnings: warnings
|
|
1021
|
+
}
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
function costObservabilityMetadata(gate) {
|
|
1025
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
1026
|
+
if (!gate) {
|
|
1027
|
+
return undefined;
|
|
1028
|
+
}
|
|
1029
|
+
return {
|
|
1030
|
+
status: gate.status,
|
|
1031
|
+
missingLedger: ((_a = gate.metadata) === null || _a === void 0 ? void 0 : _a.missingLedger) === true,
|
|
1032
|
+
estimatedUsd: Number(((_b = gate.metadata) === null || _b === void 0 ? void 0 : _b.estimatedUsd) || 0),
|
|
1033
|
+
manualEstimatedUsd: Number(((_c = gate.metadata) === null || _c === void 0 ? void 0 : _c.manualEstimatedUsd) || 0),
|
|
1034
|
+
untrackedEstimatedUsd: Number(((_d = gate.metadata) === null || _d === void 0 ? void 0 : _d.untrackedEstimatedUsd) || 0),
|
|
1035
|
+
externalCodexMonitorUsed: ((_e = gate.metadata) === null || _e === void 0 ? void 0 : _e.externalCodexMonitorUsed) === true,
|
|
1036
|
+
manualSources: cleanStringList((_f = gate.metadata) === null || _f === void 0 ? void 0 : _f.manualSources, 20, 120),
|
|
1037
|
+
untrackedSources: cleanStringList((_g = gate.metadata) === null || _g === void 0 ? void 0 : _g.untrackedSources, 20, 120),
|
|
1038
|
+
models: cleanStringList((_h = gate.metadata) === null || _h === void 0 ? void 0 : _h.models, 40, 120),
|
|
1039
|
+
categories: cleanStringList((_j = gate.metadata) === null || _j === void 0 ? void 0 : _j.categories, 40, 120),
|
|
1040
|
+
surfaces: cleanStringList((_k = gate.metadata) === null || _k === void 0 ? void 0 : _k.surfaces, 40, 120),
|
|
1041
|
+
warnings: cleanStringList((_l = gate.metadata) === null || _l === void 0 ? void 0 : _l.warnings, 20, 500),
|
|
1042
|
+
nextAction: gate.status === 'warn'
|
|
1043
|
+
? 'Record manual Codex sidecar usage in the unified ledger and replace external monitoring with a validated next-action contract.'
|
|
1044
|
+
: gate.status === 'skipped'
|
|
1045
|
+
? 'Attach runner, assistant, manual Codex, retry, and deploy usage rows before comparing cost per accepted run.'
|
|
1046
|
+
: 'Continue tracking cost in the unified ledger.'
|
|
1047
|
+
};
|
|
1048
|
+
}
|
|
967
1049
|
function collectCommitEvents(commits, events) {
|
|
968
1050
|
var e_18, _a;
|
|
969
1051
|
try {
|
|
@@ -3407,6 +3489,16 @@ function buildSupportAIRunFromEvidence(input) {
|
|
|
3407
3489
|
});
|
|
3408
3490
|
}
|
|
3409
3491
|
var cost = collectUsageEvents(asArray(input.usageLedger), events);
|
|
3492
|
+
var costGate = costObservabilityGate(cost, 'support_ticket', input.now);
|
|
3493
|
+
gates.push(costGate);
|
|
3494
|
+
pushEvent(events, {
|
|
3495
|
+
type: 'usage',
|
|
3496
|
+
category: 'cost_observability',
|
|
3497
|
+
message: costGate.reason,
|
|
3498
|
+
artifactPaths: costGate.evidenceRefs,
|
|
3499
|
+
recordedAt: costGate.recordedAt,
|
|
3500
|
+
metadata: costGate.metadata
|
|
3501
|
+
});
|
|
3410
3502
|
var preflightGateSource = supportPreflightGateObject(ticket, job, evidence);
|
|
3411
3503
|
var preflightGate = supportPreflightGateResult(preflightGateSource, input.now);
|
|
3412
3504
|
if (preflightGate) {
|
|
@@ -3537,6 +3629,7 @@ function buildSupportAIRunFromEvidence(input) {
|
|
|
3537
3629
|
metadata: {
|
|
3538
3630
|
versionCount: asArray(input.versions).length,
|
|
3539
3631
|
buildPlanCount: asArray(input.buildPlans).length,
|
|
3632
|
+
costObservability: costObservabilityMetadata(costGate),
|
|
3540
3633
|
hotfixDurability: hotfixDurabilityMetadata(gates),
|
|
3541
3634
|
managerNoBlindLoopPolicy: managerNoBlindLoopMetadata(noBlindLoopGate),
|
|
3542
3635
|
diagnosisBeforeRepair: diagnosisBeforeRepairGate ? {
|
|
@@ -3727,6 +3820,16 @@ function buildAICoderAIRunFromEvidence(input) {
|
|
|
3727
3820
|
});
|
|
3728
3821
|
}
|
|
3729
3822
|
var cost = collectUsageEvents(asArray(input.usageLedger), events);
|
|
3823
|
+
var costGate = costObservabilityGate(cost, 'aicoder_app', input.now);
|
|
3824
|
+
gates.push(costGate);
|
|
3825
|
+
pushEvent(events, {
|
|
3826
|
+
type: 'usage',
|
|
3827
|
+
category: 'cost_observability',
|
|
3828
|
+
message: costGate.reason,
|
|
3829
|
+
artifactPaths: costGate.evidenceRefs,
|
|
3830
|
+
recordedAt: costGate.recordedAt,
|
|
3831
|
+
metadata: costGate.metadata
|
|
3832
|
+
});
|
|
3730
3833
|
var journeyContractValidation = aicoderJourneyContractValidationFromEvidence(evidence);
|
|
3731
3834
|
var journeyContractGate = aicoderJourneyContractGate(journeyContractValidation, evidence, input.now);
|
|
3732
3835
|
gates.push(journeyContractGate);
|
|
@@ -3843,6 +3946,7 @@ function buildAICoderAIRunFromEvidence(input) {
|
|
|
3843
3946
|
domain: app.domain || app.customDomain || job.domain,
|
|
3844
3947
|
wowScore: (_g = evidence.wowScore) !== null && _g !== void 0 ? _g : job.wowScore,
|
|
3845
3948
|
score: (_h = evidence.score) !== null && _h !== void 0 ? _h : evidence.qualityScore,
|
|
3949
|
+
costObservability: costObservabilityMetadata(costGate),
|
|
3846
3950
|
hotfixDurability: hotfixDurabilityMetadata(gates),
|
|
3847
3951
|
managerNoBlindLoopPolicy: managerNoBlindLoopMetadata(noBlindLoopGate),
|
|
3848
3952
|
journeyContract: {
|
|
@@ -3977,6 +4081,15 @@ function buildAssistantAIRunFromEvidence(input) {
|
|
|
3977
4081
|
finally { if (e_36) throw e_36.error; }
|
|
3978
4082
|
}
|
|
3979
4083
|
var cost = collectUsageEvents(asArray(input.usageLedger), events);
|
|
4084
|
+
var costGate = costObservabilityGate(cost, 'ai_assistant', input.now);
|
|
4085
|
+
pushEvent(events, {
|
|
4086
|
+
type: 'usage',
|
|
4087
|
+
category: 'cost_observability',
|
|
4088
|
+
message: costGate.reason,
|
|
4089
|
+
artifactPaths: costGate.evidenceRefs,
|
|
4090
|
+
recordedAt: costGate.recordedAt,
|
|
4091
|
+
metadata: costGate.metadata
|
|
4092
|
+
});
|
|
3980
4093
|
var answerQuality = assistantQualityObject(input);
|
|
3981
4094
|
try {
|
|
3982
4095
|
for (var _m = __values(assistantQueryExecutions(answerQuality).slice(0, 40)), _o = _m.next(); !_o.done; _o = _m.next()) {
|
|
@@ -4080,7 +4193,7 @@ function buildAssistantAIRunFromEvidence(input) {
|
|
|
4080
4193
|
startedAt: dateValue(conversation, ['startedAt', 'createdAt']),
|
|
4081
4194
|
completedAt: dateValue(conversation, ['completedAt', 'closedAt', 'updatedAt']),
|
|
4082
4195
|
events: events,
|
|
4083
|
-
gates: [answerActionabilityGate],
|
|
4196
|
+
gates: [answerActionabilityGate, costGate],
|
|
4084
4197
|
qa: qa,
|
|
4085
4198
|
cost: cost,
|
|
4086
4199
|
rejected: failedReports.length > 0 || conversation.rejected === true,
|
|
@@ -4092,6 +4205,7 @@ function buildAssistantAIRunFromEvidence(input) {
|
|
|
4092
4205
|
metadata: {
|
|
4093
4206
|
issueReportCount: asArray(input.issueReports).length,
|
|
4094
4207
|
correctnessCheckCount: correctnessChecks.length,
|
|
4208
|
+
costObservability: costObservabilityMetadata(costGate),
|
|
4095
4209
|
answerQuality: {
|
|
4096
4210
|
ready: answerQualityDecision.ready,
|
|
4097
4211
|
status: answerQualityDecision.status,
|