@joshuaswarren/openclaw-engram 8.3.19 → 8.3.20
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 +258 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13914,6 +13914,22 @@ function mergeIdentityAnchor(existingRaw, updates) {
|
|
|
13914
13914
|
}
|
|
13915
13915
|
return lines.join("\n").replace(/\n{3,}/g, "\n\n").trimEnd() + "\n";
|
|
13916
13916
|
}
|
|
13917
|
+
function formatContinuityIncidentSummary(incident, index) {
|
|
13918
|
+
const prefix = typeof index === "number" ? `### [${index + 1}] ` : "### ";
|
|
13919
|
+
const lines = [
|
|
13920
|
+
`${prefix}${incident.id} (${incident.state})`,
|
|
13921
|
+
`Opened: ${incident.openedAt}`
|
|
13922
|
+
];
|
|
13923
|
+
if (incident.closedAt) lines.push(`Closed: ${incident.closedAt}`);
|
|
13924
|
+
if (incident.triggerWindow) lines.push(`Window: ${incident.triggerWindow}`);
|
|
13925
|
+
lines.push("", `Symptom: ${incident.symptom}`);
|
|
13926
|
+
if (incident.suspectedCause) lines.push(`Suspected Cause: ${incident.suspectedCause}`);
|
|
13927
|
+
if (incident.fixApplied) lines.push(`Fix Applied: ${incident.fixApplied}`);
|
|
13928
|
+
if (incident.verificationResult) lines.push(`Verification: ${incident.verificationResult}`);
|
|
13929
|
+
if (incident.preventiveRule) lines.push(`Preventive Rule: ${incident.preventiveRule}`);
|
|
13930
|
+
if (incident.filePath) lines.push(`Path: ${incident.filePath}`);
|
|
13931
|
+
return lines.join("\n");
|
|
13932
|
+
}
|
|
13917
13933
|
function registerTools(api, orchestrator) {
|
|
13918
13934
|
const actionTypes = [
|
|
13919
13935
|
"store_episode",
|
|
@@ -13995,6 +14011,149 @@ ${formatted}`
|
|
|
13995
14011
|
},
|
|
13996
14012
|
{ name: "memory_search" }
|
|
13997
14013
|
);
|
|
14014
|
+
api.registerTool(
|
|
14015
|
+
{
|
|
14016
|
+
name: "continuity_incident_open",
|
|
14017
|
+
label: "Open Continuity Incident",
|
|
14018
|
+
description: "Create a new continuity incident record in append-only storage.",
|
|
14019
|
+
parameters: Type.Object({
|
|
14020
|
+
symptom: Type.String({
|
|
14021
|
+
description: "Observed continuity failure symptom."
|
|
14022
|
+
}),
|
|
14023
|
+
triggerWindow: Type.Optional(
|
|
14024
|
+
Type.String({
|
|
14025
|
+
description: "Optional time window when incident occurred."
|
|
14026
|
+
})
|
|
14027
|
+
),
|
|
14028
|
+
suspectedCause: Type.Optional(
|
|
14029
|
+
Type.String({
|
|
14030
|
+
description: "Optional suspected root cause."
|
|
14031
|
+
})
|
|
14032
|
+
)
|
|
14033
|
+
}),
|
|
14034
|
+
async execute(_toolCallId, params) {
|
|
14035
|
+
if (!orchestrator.config.identityContinuityEnabled) {
|
|
14036
|
+
return toolResult(
|
|
14037
|
+
"Identity continuity is disabled. Enable `identityContinuityEnabled: true` to open incidents."
|
|
14038
|
+
);
|
|
14039
|
+
}
|
|
14040
|
+
if (!orchestrator.config.continuityIncidentLoggingEnabled) {
|
|
14041
|
+
return toolResult(
|
|
14042
|
+
"Continuity incident logging is disabled. Enable `continuityIncidentLoggingEnabled: true` to open incidents."
|
|
14043
|
+
);
|
|
14044
|
+
}
|
|
14045
|
+
const symptom = typeof params.symptom === "string" ? params.symptom.trim() : "";
|
|
14046
|
+
if (!symptom) {
|
|
14047
|
+
return toolResult("Missing required field: symptom");
|
|
14048
|
+
}
|
|
14049
|
+
const created = await orchestrator.storage.appendContinuityIncident({
|
|
14050
|
+
symptom,
|
|
14051
|
+
triggerWindow: typeof params.triggerWindow === "string" ? params.triggerWindow : void 0,
|
|
14052
|
+
suspectedCause: typeof params.suspectedCause === "string" ? params.suspectedCause : void 0
|
|
14053
|
+
});
|
|
14054
|
+
log.info(`continuity-incident open id=${created.id}`);
|
|
14055
|
+
return toolResult(`Continuity incident opened.
|
|
14056
|
+
|
|
14057
|
+
${formatContinuityIncidentSummary(created)}`);
|
|
14058
|
+
}
|
|
14059
|
+
},
|
|
14060
|
+
{ name: "continuity_incident_open" }
|
|
14061
|
+
);
|
|
14062
|
+
api.registerTool(
|
|
14063
|
+
{
|
|
14064
|
+
name: "continuity_incident_close",
|
|
14065
|
+
label: "Close Continuity Incident",
|
|
14066
|
+
description: "Close an open continuity incident with required verification details.",
|
|
14067
|
+
parameters: Type.Object({
|
|
14068
|
+
id: Type.String({
|
|
14069
|
+
description: "Incident ID to close."
|
|
14070
|
+
}),
|
|
14071
|
+
fixApplied: Type.String({
|
|
14072
|
+
description: "What fix was applied."
|
|
14073
|
+
}),
|
|
14074
|
+
verificationResult: Type.String({
|
|
14075
|
+
description: "How closure was verified."
|
|
14076
|
+
}),
|
|
14077
|
+
preventiveRule: Type.Optional(
|
|
14078
|
+
Type.String({
|
|
14079
|
+
description: "Optional preventive follow-up rule."
|
|
14080
|
+
})
|
|
14081
|
+
)
|
|
14082
|
+
}),
|
|
14083
|
+
async execute(_toolCallId, params) {
|
|
14084
|
+
if (!orchestrator.config.identityContinuityEnabled) {
|
|
14085
|
+
return toolResult(
|
|
14086
|
+
"Identity continuity is disabled. Enable `identityContinuityEnabled: true` to close incidents."
|
|
14087
|
+
);
|
|
14088
|
+
}
|
|
14089
|
+
if (!orchestrator.config.continuityIncidentLoggingEnabled) {
|
|
14090
|
+
return toolResult(
|
|
14091
|
+
"Continuity incident logging is disabled. Enable `continuityIncidentLoggingEnabled: true` to close incidents."
|
|
14092
|
+
);
|
|
14093
|
+
}
|
|
14094
|
+
const id = typeof params.id === "string" ? params.id.trim() : "";
|
|
14095
|
+
const fixApplied = typeof params.fixApplied === "string" ? params.fixApplied.trim() : "";
|
|
14096
|
+
const verificationResult = typeof params.verificationResult === "string" ? params.verificationResult.trim() : "";
|
|
14097
|
+
const preventiveRule = typeof params.preventiveRule === "string" ? params.preventiveRule.trim() : void 0;
|
|
14098
|
+
if (!id) return toolResult("Missing required field: id");
|
|
14099
|
+
if (!fixApplied) return toolResult("Missing required field: fixApplied");
|
|
14100
|
+
if (!verificationResult) return toolResult("Missing required field: verificationResult");
|
|
14101
|
+
const closed = await orchestrator.storage.closeContinuityIncident(id, {
|
|
14102
|
+
fixApplied,
|
|
14103
|
+
verificationResult,
|
|
14104
|
+
preventiveRule
|
|
14105
|
+
});
|
|
14106
|
+
if (!closed) return toolResult(`Incident not found: ${id}`);
|
|
14107
|
+
log.info(`continuity-incident close id=${id}`);
|
|
14108
|
+
return toolResult(`Continuity incident closed.
|
|
14109
|
+
|
|
14110
|
+
${formatContinuityIncidentSummary(closed)}`);
|
|
14111
|
+
}
|
|
14112
|
+
},
|
|
14113
|
+
{ name: "continuity_incident_close" }
|
|
14114
|
+
);
|
|
14115
|
+
api.registerTool(
|
|
14116
|
+
{
|
|
14117
|
+
name: "continuity_incident_list",
|
|
14118
|
+
label: "List Continuity Incidents",
|
|
14119
|
+
description: "List continuity incidents and optionally filter by state.",
|
|
14120
|
+
parameters: Type.Object({
|
|
14121
|
+
state: Type.Optional(
|
|
14122
|
+
Type.String({
|
|
14123
|
+
enum: ["open", "closed", "all"],
|
|
14124
|
+
description: "Incident state filter (default: open)."
|
|
14125
|
+
})
|
|
14126
|
+
),
|
|
14127
|
+
limit: Type.Optional(
|
|
14128
|
+
Type.Number({
|
|
14129
|
+
description: "Max incidents to return (default: 25, max: 200).",
|
|
14130
|
+
minimum: 1,
|
|
14131
|
+
maximum: 200
|
|
14132
|
+
})
|
|
14133
|
+
)
|
|
14134
|
+
}),
|
|
14135
|
+
async execute(_toolCallId, params) {
|
|
14136
|
+
if (!orchestrator.config.identityContinuityEnabled) {
|
|
14137
|
+
return toolResult(
|
|
14138
|
+
"Identity continuity is disabled. Enable `identityContinuityEnabled: true` to list incidents."
|
|
14139
|
+
);
|
|
14140
|
+
}
|
|
14141
|
+
const state = params.state === "closed" || params.state === "all" ? params.state : "open";
|
|
14142
|
+
const limitRaw = typeof params.limit === "number" ? params.limit : 25;
|
|
14143
|
+
const limit = Math.max(1, Math.min(200, Math.floor(limitRaw)));
|
|
14144
|
+
const incidents = await orchestrator.storage.readContinuityIncidents(limit);
|
|
14145
|
+
const filtered = state === "all" ? incidents : incidents.filter((incident) => incident.state === state);
|
|
14146
|
+
if (filtered.length === 0) {
|
|
14147
|
+
return toolResult(`No continuity incidents found for state=${state}.`);
|
|
14148
|
+
}
|
|
14149
|
+
const body = filtered.map((incident, index) => formatContinuityIncidentSummary(incident, index)).join("\n\n");
|
|
14150
|
+
return toolResult(`## Continuity Incidents (${filtered.length}, state=${state})
|
|
14151
|
+
|
|
14152
|
+
${body}`);
|
|
14153
|
+
}
|
|
14154
|
+
},
|
|
14155
|
+
{ name: "continuity_incident_list" }
|
|
14156
|
+
);
|
|
13998
14157
|
api.registerTool(
|
|
13999
14158
|
{
|
|
14000
14159
|
name: "identity_anchor_get",
|
|
@@ -15482,6 +15641,21 @@ async function readAllMemoryFiles(memoryDir) {
|
|
|
15482
15641
|
}
|
|
15483
15642
|
return out;
|
|
15484
15643
|
}
|
|
15644
|
+
function formatContinuityIncidentCli(incident) {
|
|
15645
|
+
const lines = [
|
|
15646
|
+
`${incident.id} [${incident.state}]`,
|
|
15647
|
+
` opened: ${incident.openedAt}`
|
|
15648
|
+
];
|
|
15649
|
+
if (incident.closedAt) lines.push(` closed: ${incident.closedAt}`);
|
|
15650
|
+
if (incident.triggerWindow) lines.push(` window: ${incident.triggerWindow}`);
|
|
15651
|
+
lines.push(` symptom: ${incident.symptom}`);
|
|
15652
|
+
if (incident.suspectedCause) lines.push(` suspected-cause: ${incident.suspectedCause}`);
|
|
15653
|
+
if (incident.fixApplied) lines.push(` fix-applied: ${incident.fixApplied}`);
|
|
15654
|
+
if (incident.verificationResult) lines.push(` verification: ${incident.verificationResult}`);
|
|
15655
|
+
if (incident.preventiveRule) lines.push(` preventive-rule: ${incident.preventiveRule}`);
|
|
15656
|
+
if (incident.filePath) lines.push(` path: ${incident.filePath}`);
|
|
15657
|
+
return lines.join("\n");
|
|
15658
|
+
}
|
|
15485
15659
|
function registerCli(api, orchestrator) {
|
|
15486
15660
|
api.registerCli(
|
|
15487
15661
|
({ program }) => {
|
|
@@ -15868,6 +16042,90 @@ function registerCli(api, orchestrator) {
|
|
|
15868
16042
|
}
|
|
15869
16043
|
console.log(identity);
|
|
15870
16044
|
});
|
|
16045
|
+
const continuityCmd = cmd.command("continuity").description("Identity continuity incident workflow commands");
|
|
16046
|
+
continuityCmd.command("incidents").description("List continuity incidents").option("--state <state>", "Filter by state: open|closed|all", "open").option("--limit <number>", "Maximum incidents to list", "25").action(async (...args) => {
|
|
16047
|
+
if (!orchestrator.config.identityContinuityEnabled) {
|
|
16048
|
+
console.log("Identity continuity is disabled.");
|
|
16049
|
+
return;
|
|
16050
|
+
}
|
|
16051
|
+
const options = args[0] ?? {};
|
|
16052
|
+
const stateRaw = String(options.state ?? "open").toLowerCase();
|
|
16053
|
+
const state = stateRaw === "closed" || stateRaw === "all" ? stateRaw : "open";
|
|
16054
|
+
const limit = Math.max(1, Math.min(200, parseInt(String(options.limit ?? "25"), 10) || 25));
|
|
16055
|
+
const incidents = await orchestrator.storage.readContinuityIncidents(limit);
|
|
16056
|
+
const filtered = state === "all" ? incidents : incidents.filter((incident) => incident.state === state);
|
|
16057
|
+
if (filtered.length === 0) {
|
|
16058
|
+
console.log(`No continuity incidents found for state=${state}.`);
|
|
16059
|
+
return;
|
|
16060
|
+
}
|
|
16061
|
+
console.log(`=== Continuity Incidents (${filtered.length}, state=${state}) ===
|
|
16062
|
+
`);
|
|
16063
|
+
for (const incident of filtered) {
|
|
16064
|
+
console.log(formatContinuityIncidentCli(incident));
|
|
16065
|
+
console.log();
|
|
16066
|
+
}
|
|
16067
|
+
});
|
|
16068
|
+
continuityCmd.command("incident-open").description("Open a continuity incident").option("--symptom <text>", "Required symptom description").option("--trigger-window <window>", "Optional incident trigger window").option("--suspected-cause <text>", "Optional suspected cause").action(async (...args) => {
|
|
16069
|
+
if (!orchestrator.config.identityContinuityEnabled) {
|
|
16070
|
+
console.log("Identity continuity is disabled.");
|
|
16071
|
+
return;
|
|
16072
|
+
}
|
|
16073
|
+
if (!orchestrator.config.continuityIncidentLoggingEnabled) {
|
|
16074
|
+
console.log("Continuity incident logging is disabled.");
|
|
16075
|
+
return;
|
|
16076
|
+
}
|
|
16077
|
+
const options = args[0] ?? {};
|
|
16078
|
+
const symptom = String(options.symptom ?? "").trim();
|
|
16079
|
+
if (!symptom) {
|
|
16080
|
+
console.log("Missing required --symptom.");
|
|
16081
|
+
return;
|
|
16082
|
+
}
|
|
16083
|
+
const created = await orchestrator.storage.appendContinuityIncident({
|
|
16084
|
+
symptom,
|
|
16085
|
+
triggerWindow: options.triggerWindow ? String(options.triggerWindow) : void 0,
|
|
16086
|
+
suspectedCause: options.suspectedCause ? String(options.suspectedCause) : void 0
|
|
16087
|
+
});
|
|
16088
|
+
console.log("Opened continuity incident:\n");
|
|
16089
|
+
console.log(formatContinuityIncidentCli(created));
|
|
16090
|
+
});
|
|
16091
|
+
continuityCmd.command("incident-close").description("Close a continuity incident").option("--id <id>", "Required incident ID").option("--fix-applied <text>", "Required fix description").option("--verification-result <text>", "Required verification result").option("--preventive-rule <text>", "Optional preventive rule").action(async (...args) => {
|
|
16092
|
+
if (!orchestrator.config.identityContinuityEnabled) {
|
|
16093
|
+
console.log("Identity continuity is disabled.");
|
|
16094
|
+
return;
|
|
16095
|
+
}
|
|
16096
|
+
if (!orchestrator.config.continuityIncidentLoggingEnabled) {
|
|
16097
|
+
console.log("Continuity incident logging is disabled.");
|
|
16098
|
+
return;
|
|
16099
|
+
}
|
|
16100
|
+
const options = args[0] ?? {};
|
|
16101
|
+
const id = String(options.id ?? "").trim();
|
|
16102
|
+
const fixApplied = String(options.fixApplied ?? "").trim();
|
|
16103
|
+
const verificationResult = String(options.verificationResult ?? "").trim();
|
|
16104
|
+
const preventiveRule = options.preventiveRule ? String(options.preventiveRule).trim() : void 0;
|
|
16105
|
+
if (!id) {
|
|
16106
|
+
console.log("Missing required --id.");
|
|
16107
|
+
return;
|
|
16108
|
+
}
|
|
16109
|
+
if (!fixApplied) {
|
|
16110
|
+
console.log("Missing required --fix-applied.");
|
|
16111
|
+
return;
|
|
16112
|
+
}
|
|
16113
|
+
if (!verificationResult) {
|
|
16114
|
+
console.log("Missing required --verification-result.");
|
|
16115
|
+
return;
|
|
16116
|
+
}
|
|
16117
|
+
const closed = await orchestrator.storage.closeContinuityIncident(id, {
|
|
16118
|
+
fixApplied,
|
|
16119
|
+
verificationResult,
|
|
16120
|
+
preventiveRule
|
|
16121
|
+
});
|
|
16122
|
+
if (!closed) {
|
|
16123
|
+
console.log(`Incident not found: ${id}`);
|
|
16124
|
+
return;
|
|
16125
|
+
}
|
|
16126
|
+
console.log("Closed continuity incident:\n");
|
|
16127
|
+
console.log(formatContinuityIncidentCli(closed));
|
|
16128
|
+
});
|
|
15871
16129
|
cmd.command("access").description("Show memory access statistics").option("-n, --top <number>", "Show top N most accessed", "20").action(async (...args) => {
|
|
15872
16130
|
const options = args[0] ?? {};
|
|
15873
16131
|
const top = parseInt(options.top ?? "20", 10);
|