openhermes 1.13.1 → 2.5.1
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/README.md +123 -208
- package/autorecall.mjs +79 -12
- package/bootstrap.mjs +122 -25
- package/curator.mjs +4 -40
- package/harness/commands/harness-audit.md +1 -1
- package/harness/commands/learn.md +2 -2
- package/harness/commands/memory-search.md +2 -2
- package/harness/constitution/soul.md +16 -4
- package/harness/instructions/RUNTIME.md +6 -3
- package/harness/prompts/architect.txt +14 -0
- package/harness/prompts/build-cpp.md +15 -1
- package/harness/prompts/build-error-resolver.md +15 -9
- package/harness/prompts/build-go.md +14 -0
- package/harness/prompts/build-java.md +15 -1
- package/harness/prompts/build-kotlin.md +15 -1
- package/harness/prompts/build-rust.md +14 -0
- package/harness/prompts/code-reviewer.md +15 -9
- package/harness/prompts/doc-updater.md +13 -0
- package/harness/prompts/docs-lookup.md +11 -0
- package/harness/prompts/e2e-runner.txt +12 -0
- package/harness/prompts/explore.md +16 -4
- package/harness/prompts/harness-optimizer.md +12 -0
- package/harness/prompts/loop-operator.md +11 -0
- package/harness/prompts/planner.md +15 -9
- package/harness/prompts/refactor-cleaner.md +14 -0
- package/harness/prompts/review-cpp.md +14 -1
- package/harness/prompts/review-database.md +13 -0
- package/harness/prompts/review-go.md +13 -0
- package/harness/prompts/review-java.md +14 -1
- package/harness/prompts/review-kotlin.md +13 -0
- package/harness/prompts/review-python.md +14 -1
- package/harness/prompts/review-rust.md +13 -0
- package/harness/prompts/security-reviewer.md +15 -9
- package/harness/prompts/tdd-guide.md +14 -0
- package/harness/rules/audit.md +2 -2
- package/harness/rules/delegation.md +0 -2
- package/harness/rules/handoff.md +267 -0
- package/harness/rules/memory-management.md +4 -4
- package/harness/rules/precedence.md +1 -1
- package/harness/rules/retrieval.md +5 -5
- package/harness/rules/runtime-guards.md +1 -1
- package/harness/rules/self-heal.md +1 -1
- package/harness/rules/session-start.md +5 -5
- package/harness/rules/skills-management.md +2 -2
- package/harness/rules/verification.md +4 -4
- package/index.mjs +6 -2
- package/lib/ambient-memory.mjs +167 -0
- package/lib/handoff.mjs +176 -0
- package/lib/hardening.mjs +13 -8
- package/lib/memory-tools-plugin.mjs +107 -54
- package/lib/ohc/block-sync.mjs +69 -0
- package/lib/ohc/compress/search.mjs +152 -0
- package/lib/ohc/compress/state.mjs +76 -0
- package/lib/ohc/config.mjs +172 -16
- package/lib/ohc/message-ids.mjs +168 -0
- package/lib/ohc/notify.mjs +150 -0
- package/lib/ohc/protected-patterns.mjs +54 -0
- package/lib/ohc/prune-apply.mjs +134 -0
- package/lib/ohc/pruner.mjs +406 -55
- package/lib/ohc/reaper.mjs +12 -3
- package/lib/ohc/state.mjs +246 -15
- package/lib/ohc/strategies/deduplication.mjs +72 -0
- package/lib/ohc/strategies/index.mjs +2 -0
- package/lib/ohc/strategies/purge-errors.mjs +43 -0
- package/lib/ohc/token-utils.mjs +26 -0
- package/lib/ohc/updater.mjs +36 -13
- package/lib/paths.mjs +0 -3
- package/lib/search.mjs +48 -0
- package/package.json +1 -1
- package/schemas/audit.schema.json +22 -1
- package/schemas/backlog.schema.json +23 -2
- package/schemas/checkpoint.schema.json +23 -2
- package/schemas/constraint.schema.json +23 -2
- package/schemas/decision.schema.json +23 -2
- package/schemas/instinct.schema.json +23 -2
- package/schemas/mistake.schema.json +23 -2
- package/schemas/verification_receipt.schema.json +23 -2
- package/skill-builder.mjs +12 -23
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
const PRUNED_OUTPUT_PLACEHOLDER = "[Output removed — information superseded or no longer needed]"
|
|
2
|
+
const PRUNED_ERROR_INPUT_PLACEHOLDER = "[input removed — failed tool call]"
|
|
3
|
+
const PRUNED_QUESTION_INPUT_PLACEHOLDER = "[questions removed — see output for answers]"
|
|
4
|
+
|
|
5
|
+
export function applyPruneTools(state, messages) {
|
|
6
|
+
if (!state.prune.tools.size) return 0
|
|
7
|
+
|
|
8
|
+
let prunedCount = 0
|
|
9
|
+
|
|
10
|
+
for (const msg of messages) {
|
|
11
|
+
if (!Array.isArray(msg.parts)) continue
|
|
12
|
+
|
|
13
|
+
for (const part of msg.parts) {
|
|
14
|
+
if (part.type !== "tool" || !part.callID) continue
|
|
15
|
+
if (!state.prune.tools.has(part.callID)) continue
|
|
16
|
+
|
|
17
|
+
prunedCount++
|
|
18
|
+
|
|
19
|
+
if (part.state?.status === "completed") {
|
|
20
|
+
if (part.tool === "question") {
|
|
21
|
+
if (part.state.input?.questions !== undefined) {
|
|
22
|
+
part.state.input.questions = PRUNED_QUESTION_INPUT_PLACEHOLDER
|
|
23
|
+
}
|
|
24
|
+
} else if (part.tool !== "edit" && part.tool !== "write") {
|
|
25
|
+
part.state = {
|
|
26
|
+
...part.state,
|
|
27
|
+
output: PRUNED_OUTPUT_PLACEHOLDER,
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (part.state?.status === "error") {
|
|
33
|
+
const input = part.state.input
|
|
34
|
+
if (input && typeof input === "object") {
|
|
35
|
+
for (const key of Object.keys(input)) {
|
|
36
|
+
if (typeof input[key] === "string") {
|
|
37
|
+
input[key] = PRUNED_ERROR_INPUT_PLACEHOLDER
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return prunedCount
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function filterCompressedBlocks(state, messages) {
|
|
49
|
+
const ms = state.prune?.messages
|
|
50
|
+
if (!ms || !ms.activeBlockIds?.size || !ms.blocksById?.size) return { removed: 0, injected: 0 }
|
|
51
|
+
|
|
52
|
+
const coveredMessageIds = new Set()
|
|
53
|
+
for (const [rawId, entry] of ms.byMessageId) {
|
|
54
|
+
const hasActive = Array.isArray(entry.activeBlockIds) && entry.activeBlockIds.some(id => ms.activeBlockIds.has(id))
|
|
55
|
+
if (hasActive) coveredMessageIds.add(rawId)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (!coveredMessageIds.size) return { removed: 0, injected: 0 }
|
|
59
|
+
|
|
60
|
+
const activeBlocks = [...ms.activeBlockIds].map(id => ms.blocksById.get(id)).filter(Boolean)
|
|
61
|
+
const summaryByAnchor = new Map()
|
|
62
|
+
for (const block of activeBlocks) {
|
|
63
|
+
if (block.anchorMessageId && !summaryByAnchor.has(block.anchorMessageId)) {
|
|
64
|
+
summaryByAnchor.set(block.anchorMessageId, block)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
let removed = 0
|
|
69
|
+
let injected = 0
|
|
70
|
+
const result = []
|
|
71
|
+
const blocksDeployed = new Set()
|
|
72
|
+
|
|
73
|
+
for (const msg of messages) {
|
|
74
|
+
const mid = msg.info?.id
|
|
75
|
+
|
|
76
|
+
if (mid && coveredMessageIds.has(mid)) {
|
|
77
|
+
if (!blocksDeployed.has(mid)) {
|
|
78
|
+
blocksDeployed.add(mid)
|
|
79
|
+
const block = summaryByAnchor.get(mid)
|
|
80
|
+
if (block) {
|
|
81
|
+
result.push({
|
|
82
|
+
parts: [{ type: "text", text: block.summary }],
|
|
83
|
+
info: { role: "system" },
|
|
84
|
+
})
|
|
85
|
+
injected++
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
removed++
|
|
89
|
+
continue
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
result.push(msg)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
messages.length = 0
|
|
96
|
+
messages.push(...result)
|
|
97
|
+
|
|
98
|
+
return { removed, injected }
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function applyFullToolRemoval(state, messages) {
|
|
102
|
+
if (!state.prune.tools.size) return 0
|
|
103
|
+
|
|
104
|
+
const removed = []
|
|
105
|
+
|
|
106
|
+
for (const msg of messages) {
|
|
107
|
+
if (!Array.isArray(msg.parts)) continue
|
|
108
|
+
|
|
109
|
+
const toRemove = []
|
|
110
|
+
for (const part of msg.parts) {
|
|
111
|
+
if (part.type !== "tool" || !part.callID) continue
|
|
112
|
+
if (!state.prune.tools.has(part.callID)) continue
|
|
113
|
+
if (part.tool !== "edit" && part.tool !== "write") continue
|
|
114
|
+
toRemove.push(part.callID)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (!toRemove.length) continue
|
|
118
|
+
|
|
119
|
+
const before = msg.parts.length
|
|
120
|
+
msg.parts = msg.parts.filter(p => p.type !== "tool" || !toRemove.includes(p.callID))
|
|
121
|
+
const after = msg.parts.length
|
|
122
|
+
if (after === 0 && before > 0) {
|
|
123
|
+
removed.push(msg.info.id)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (removed.length) {
|
|
128
|
+
const result = messages.filter(m => !removed.includes(m.info.id))
|
|
129
|
+
messages.length = 0
|
|
130
|
+
messages.push(...result)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return removed.length
|
|
134
|
+
}
|