@kwirthmagnify/kwirth-plugin-pinocchio 0.2.13 → 0.2.14
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/back.js +62 -64
- package/package.json +1 -1
package/back.js
CHANGED
|
@@ -11884,76 +11884,74 @@ Please provide a comprehensive answer based on the above data.`;
|
|
|
11884
11884
|
break;
|
|
11885
11885
|
case "events":
|
|
11886
11886
|
let eventsEvent = event;
|
|
11887
|
-
|
|
11888
|
-
|
|
11889
|
-
for (let
|
|
11890
|
-
|
|
11891
|
-
|
|
11892
|
-
|
|
11893
|
-
|
|
11894
|
-
|
|
11895
|
-
|
|
11896
|
-
continue;
|
|
11897
|
-
}
|
|
11887
|
+
try {
|
|
11888
|
+
for (let t of this.pinocchioConfig.triggers.filter((t2) => t2.trigger === "artifact" && t2.kind === eventsEvent.obj.kind && (!t2.k8sEvent || t2.k8sEvent === eventsEvent.type))) {
|
|
11889
|
+
for (let version of t.versions.filter((v) => v.enabled)) {
|
|
11890
|
+
this.backChannelObject.logInfo?.(`[pinocchio] ${eventsEvent.type} ${eventsEvent.obj.kind} ${eventsEvent.obj.metadata?.name}`);
|
|
11891
|
+
if (eventsEvent.type === "ADDED" && eventsEvent.obj?.metadata?.creationTimestamp) {
|
|
11892
|
+
let creationTs = Date.parse(eventsEvent.obj?.metadata?.creationTimestamp);
|
|
11893
|
+
if (creationTs < this.startTime) {
|
|
11894
|
+
this.backChannelObject.logWarning?.(`[pinocchio] bypass object analysis, creation timestamp is previous for object ${eventsEvent.obj?.metadata?.name} and kind ${t.kind} for LLM ${version.llm}`);
|
|
11895
|
+
continue;
|
|
11898
11896
|
}
|
|
11899
|
-
|
|
11900
|
-
|
|
11897
|
+
}
|
|
11898
|
+
let { llmModelId, llmProviderId, model, temperature, providerOptions, errorPath, system, prompt, tools, toolContext } = await this.buildModelInvocation(t, version, eventsEvent) || {};
|
|
11899
|
+
if (!model) return;
|
|
11900
|
+
try {
|
|
11901
|
+
const { output, usage } = await (0, import_back.runWithToolContext)(toolContext, () => (0, import_back2.generateText)({
|
|
11902
|
+
model,
|
|
11903
|
+
temperature,
|
|
11904
|
+
tools,
|
|
11905
|
+
providerOptions,
|
|
11906
|
+
output: import_back2.Output.object({
|
|
11907
|
+
schema: import_back2.z.object({
|
|
11908
|
+
findings: import_back2.z.array(
|
|
11909
|
+
import_back2.z.object({
|
|
11910
|
+
description: import_back2.z.string().min(1),
|
|
11911
|
+
level: import_back2.z.enum(["low", "medium", "high", "critical"])
|
|
11912
|
+
})
|
|
11913
|
+
),
|
|
11914
|
+
report: import_back2.z.string().min(1),
|
|
11915
|
+
hardened_yaml: import_back2.z.string().min(1)
|
|
11916
|
+
})
|
|
11917
|
+
}),
|
|
11918
|
+
system: system || "You are a very polite AI system",
|
|
11919
|
+
prompt: prompt || "Hi AI, how are you?"
|
|
11920
|
+
}));
|
|
11921
|
+
let analysis = {
|
|
11922
|
+
text: `${eventsEvent.type} ${eventsEvent.obj.kind} '${eventsEvent.obj.metadata.name}' in namespace '${eventsEvent.obj.metadata.namespace}' [LLM:${llmProviderId}/${llmModelId}, IN:${usage.inputTokens}, OUT:${usage.outputTokens}]`,
|
|
11923
|
+
findings: output.findings,
|
|
11924
|
+
...output.report ? { report: output.report } : {},
|
|
11925
|
+
...output.hardened_yaml ? { hardened_yaml: output.hardened_yaml } : {},
|
|
11926
|
+
timestamp: Date.now(),
|
|
11927
|
+
usage: {
|
|
11928
|
+
input: usage.inputTokens,
|
|
11929
|
+
output: usage.outputTokens
|
|
11930
|
+
},
|
|
11931
|
+
pod: eventsEvent.obj
|
|
11932
|
+
};
|
|
11933
|
+
this.analysis.push(analysis);
|
|
11934
|
+
this.broadcastAnalysis(analysis);
|
|
11935
|
+
} catch (err) {
|
|
11936
|
+
let message = `Pinocchio analysis ended in error while processing 'events' when analyzing '${eventsEvent.obj.metadata.name}' in namespace '${eventsEvent.obj.metadata.namespace}' [Kind:${eventsEvent.obj.kind}]`;
|
|
11937
|
+
this.backChannelObject.logError?.(`${message}: ${err}`);
|
|
11901
11938
|
try {
|
|
11902
|
-
|
|
11903
|
-
|
|
11904
|
-
temperature,
|
|
11905
|
-
tools,
|
|
11906
|
-
providerOptions,
|
|
11907
|
-
output: import_back2.Output.object({
|
|
11908
|
-
schema: import_back2.z.object({
|
|
11909
|
-
findings: import_back2.z.array(
|
|
11910
|
-
import_back2.z.object({
|
|
11911
|
-
description: import_back2.z.string().min(1),
|
|
11912
|
-
level: import_back2.z.enum(["low", "medium", "high", "critical"])
|
|
11913
|
-
})
|
|
11914
|
-
),
|
|
11915
|
-
report: import_back2.z.string().min(1),
|
|
11916
|
-
hardened_yaml: import_back2.z.string().min(1)
|
|
11917
|
-
})
|
|
11918
|
-
}),
|
|
11919
|
-
system: system || "You are a very polite AI system",
|
|
11920
|
-
prompt: prompt || "Hi AI, how are you?"
|
|
11921
|
-
}));
|
|
11922
|
-
let analysis = {
|
|
11923
|
-
text: `${eventsEvent.type} ${eventsEvent.obj.kind} '${eventsEvent.obj.metadata.name}' in namespace '${eventsEvent.obj.metadata.namespace}' [LLM:${llmProviderId}/${llmModelId}, IN:${usage.inputTokens}, OUT:${usage.outputTokens}]`,
|
|
11924
|
-
findings: output.findings,
|
|
11925
|
-
...output.report ? { report: output.report } : {},
|
|
11926
|
-
...output.hardened_yaml ? { hardened_yaml: output.hardened_yaml } : {},
|
|
11927
|
-
timestamp: Date.now(),
|
|
11928
|
-
usage: {
|
|
11929
|
-
input: usage.inputTokens,
|
|
11930
|
-
output: usage.outputTokens
|
|
11931
|
-
},
|
|
11932
|
-
pod: eventsEvent.obj
|
|
11933
|
-
};
|
|
11934
|
-
this.analysis.push(analysis);
|
|
11935
|
-
this.broadcastAnalysis(analysis);
|
|
11936
|
-
} catch (err) {
|
|
11937
|
-
let message = `Pinocchio analysis ended in error while processing 'events' when analyzing '${eventsEvent.obj.metadata.name}' in namespace '${eventsEvent.obj.metadata.namespace}' [Kind:${eventsEvent.obj.kind}]`;
|
|
11938
|
-
this.backChannelObject.logError?.(`${message}: ${err}`);
|
|
11939
|
-
try {
|
|
11940
|
-
let msg = _.get(err, errorPath);
|
|
11941
|
-
} catch {
|
|
11942
|
-
}
|
|
11943
|
-
let an = {
|
|
11944
|
-
findings: [
|
|
11945
|
-
{ description: message, level: "critical" },
|
|
11946
|
-
{ description: JSON.stringify(err), level: "critical" }
|
|
11947
|
-
],
|
|
11948
|
-
timestamp: Date.now()
|
|
11949
|
-
};
|
|
11950
|
-
this.broadcastAnalysis(an);
|
|
11939
|
+
let msg = _.get(err, errorPath);
|
|
11940
|
+
} catch {
|
|
11951
11941
|
}
|
|
11942
|
+
let an = {
|
|
11943
|
+
findings: [
|
|
11944
|
+
{ description: message, level: "critical" },
|
|
11945
|
+
{ description: JSON.stringify(err), level: "critical" }
|
|
11946
|
+
],
|
|
11947
|
+
timestamp: Date.now()
|
|
11948
|
+
};
|
|
11949
|
+
this.broadcastAnalysis(an);
|
|
11952
11950
|
}
|
|
11953
11951
|
}
|
|
11954
|
-
} catch (err) {
|
|
11955
|
-
this.backChannelObject.logError?.(`[pinocchio] error in processProviderEvent: ${err}`);
|
|
11956
11952
|
}
|
|
11953
|
+
} catch (err) {
|
|
11954
|
+
this.backChannelObject.logError?.(`[pinocchio] error in processProviderEvent: ${err}`);
|
|
11957
11955
|
}
|
|
11958
11956
|
break;
|
|
11959
11957
|
default:
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "pinocchio",
|
|
3
3
|
"name": "@kwirthmagnify/kwirth-plugin-pinocchio",
|
|
4
4
|
"displayName": "Pinocchio",
|
|
5
|
-
"version": "0.2.
|
|
5
|
+
"version": "0.2.14",
|
|
6
6
|
"description": "Pinocchio AI channel plugin for Kwirth - LLM-based Kubernetes event analysis",
|
|
7
7
|
"icon": "AutoFixHigh",
|
|
8
8
|
"website": "https://kwirthmagnify.dev"
|