class IntelligentCostAttribution {
private costData: CostDataStore;
const untaggedResources = await this.findUntaggedResources();
const taggedResources = await this.getTaggedResources();
// Inferencja tagów napędzana przez AI
for (const resource of untaggedResources) {
const inferredTags = await this.inferTags(resource, taggedResources);
if (inferredTags.confidence > 0.8) {
await this.applyTags(resource, inferredTags.tags);
// Generowanie raportu alokacji kosztów
return this.generateAllocationReport();
taggedResources: CloudResource[]
resourceType: resource.type,
resourceName: resource.name,
relatedResources: await this.findRelatedResources(resource),
similarTagged: this.findSimilarResources(resource, taggedResources)
const response = await this.ai.messages.create({
model: 'claude-4.1-opus-20240229',
Wywnioskuj odpowiednie tagi alokacji kosztów dla tego zasobu:
Zasób: ${JSON.stringify(resource)}
Kontekst: ${JSON.stringify(context)}
Na podstawie wzorców nazewnictwa, relacji i podobnych zasobów,
zasugeruj tagi dla: Department, Project, Environment, Owner
return this.parseTagInference(response);
// Automatyczny system rozliczeń zwrotnych
class AutomatedChargeback {
async generateChargebacks() {
const costs = await this.getAttributedCosts();
const rules = await this.getChargebackRules();
const chargebacks = new Map<string, Chargeback>();
for (const [resource, cost] of costs) {
const rule = this.matchRule(resource, rules);
const department = resource.tags.department;
if (!chargebacks.has(department)) {
chargebacks.set(department, {
const chargeback = chargebacks.get(department)!;
const amount = this.calculateChargeback(cost, rule);
chargeback.total += amount;
chargeback.breakdown.push({
return this.generateChargebackReports(chargebacks);