@cfio/cohort-sync 0.27.0 → 0.28.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.js +70 -1
- package/dist/openclaw.plugin.json +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13135,6 +13135,48 @@ function buildActivityEntry(agentName, hook, context) {
|
|
|
13135
13135
|
model
|
|
13136
13136
|
};
|
|
13137
13137
|
}
|
|
13138
|
+
case "model_call_ended": {
|
|
13139
|
+
const outcome = context.outcome;
|
|
13140
|
+
if (outcome !== "error") return null;
|
|
13141
|
+
const errorCategory = context.errorCategory;
|
|
13142
|
+
const provider = context.provider;
|
|
13143
|
+
const failureKind = context.failureKind;
|
|
13144
|
+
const durationMs = context.durationMs;
|
|
13145
|
+
let text;
|
|
13146
|
+
let summary;
|
|
13147
|
+
const where = provider ?? "the LLM provider";
|
|
13148
|
+
if (errorCategory === "auth") {
|
|
13149
|
+
text = `${name} couldn't reach ${where} \u2014 API key rejected. Update it in Settings.`;
|
|
13150
|
+
summary = `${where} API key invalid`;
|
|
13151
|
+
} else if (errorCategory === "rate_limit") {
|
|
13152
|
+
text = `${name} was rate-limited by ${where}.`;
|
|
13153
|
+
summary = `${where} rate limit`;
|
|
13154
|
+
} else if (errorCategory === "overloaded" || errorCategory === "unavailable") {
|
|
13155
|
+
text = `${name} couldn't reach ${where} \u2014 service unavailable.`;
|
|
13156
|
+
summary = `${where} unavailable`;
|
|
13157
|
+
} else if (failureKind === "timeout") {
|
|
13158
|
+
text = `${name}'s LLM call to ${where} timed out.`;
|
|
13159
|
+
summary = `${where} timeout`;
|
|
13160
|
+
} else if (failureKind) {
|
|
13161
|
+
text = `${name}'s LLM call to ${where} failed (${failureKind}).`;
|
|
13162
|
+
summary = `${where} ${failureKind}`;
|
|
13163
|
+
} else {
|
|
13164
|
+
text = `${name}'s LLM call to ${where} failed${errorCategory ? ` (${errorCategory})` : ""}.`;
|
|
13165
|
+
summary = `${where} error${errorCategory ? `: ${errorCategory}` : ""}`;
|
|
13166
|
+
}
|
|
13167
|
+
return {
|
|
13168
|
+
agentName,
|
|
13169
|
+
text,
|
|
13170
|
+
category: "system",
|
|
13171
|
+
timestamp: ts,
|
|
13172
|
+
hook,
|
|
13173
|
+
sessionKey,
|
|
13174
|
+
model,
|
|
13175
|
+
durationMs,
|
|
13176
|
+
error: true,
|
|
13177
|
+
errorSummary: summary
|
|
13178
|
+
};
|
|
13179
|
+
}
|
|
13138
13180
|
default:
|
|
13139
13181
|
return null;
|
|
13140
13182
|
}
|
|
@@ -13431,7 +13473,7 @@ function dumpCtx(ctx) {
|
|
|
13431
13473
|
function dumpEvent(event) {
|
|
13432
13474
|
return dumpCtx(event);
|
|
13433
13475
|
}
|
|
13434
|
-
var PLUGIN_VERSION = true ? "0.
|
|
13476
|
+
var PLUGIN_VERSION = true ? "0.28.0" : "unknown";
|
|
13435
13477
|
function resolveGatewayToken(api) {
|
|
13436
13478
|
const token = api.config?.gateway?.auth?.token;
|
|
13437
13479
|
return typeof token === "string" ? token : null;
|
|
@@ -13805,6 +13847,33 @@ function registerHookHandlers(api, logger, getState) {
|
|
|
13805
13847
|
log.warn(`cohort-sync: agent_end sync failed: ${String(err)}`);
|
|
13806
13848
|
}
|
|
13807
13849
|
});
|
|
13850
|
+
api.on("model_call_ended", async (event, ctx) => {
|
|
13851
|
+
const state = getState();
|
|
13852
|
+
if (!state) return;
|
|
13853
|
+
if (event?.outcome !== "error") return;
|
|
13854
|
+
const { logger: log } = state;
|
|
13855
|
+
log.debug("cohort-sync: hook: model_call_ended (error)", {
|
|
13856
|
+
provider: event.provider,
|
|
13857
|
+
errorCategory: event.errorCategory,
|
|
13858
|
+
failureKind: event.failureKind
|
|
13859
|
+
});
|
|
13860
|
+
try {
|
|
13861
|
+
const agentId = ctx.agentId ?? "main";
|
|
13862
|
+
const agentName = state.resolveAgentName(agentId);
|
|
13863
|
+
const entry = buildActivityEntry(agentName, "model_call_ended", {
|
|
13864
|
+
outcome: event.outcome,
|
|
13865
|
+
errorCategory: event.errorCategory,
|
|
13866
|
+
failureKind: event.failureKind,
|
|
13867
|
+
provider: event.provider,
|
|
13868
|
+
model: event.model,
|
|
13869
|
+
durationMs: event.durationMs,
|
|
13870
|
+
sessionKey: ctx.sessionKey
|
|
13871
|
+
});
|
|
13872
|
+
if (entry) state.activityBatch.add(entry);
|
|
13873
|
+
} catch (err) {
|
|
13874
|
+
log.warn(`cohort-sync: model_call_ended sync failed: ${String(err)}`);
|
|
13875
|
+
}
|
|
13876
|
+
});
|
|
13808
13877
|
api.on("llm_output", async (event, ctx) => {
|
|
13809
13878
|
const state = getState();
|
|
13810
13879
|
if (!state) return;
|
package/dist/package.json
CHANGED
package/package.json
CHANGED