@psiclawops/hypercompositor 0.9.6 → 0.9.9
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.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +115 -13
- package/package.json +10 -6
package/dist/index.d.ts
CHANGED
|
@@ -203,8 +203,8 @@ declare const _default: {
|
|
|
203
203
|
id: string;
|
|
204
204
|
name: string;
|
|
205
205
|
description: string;
|
|
206
|
-
configSchema: import("openclaw/plugin-sdk").OpenClawPluginConfigSchema;
|
|
207
|
-
register: NonNullable<import("openclaw/plugin-sdk/
|
|
208
|
-
} & Pick<import("openclaw/plugin-sdk/
|
|
206
|
+
configSchema: import("openclaw/plugin-sdk/core").OpenClawPluginConfigSchema;
|
|
207
|
+
register: NonNullable<import("openclaw/plugin-sdk/core").OpenClawPluginDefinition["register"]>;
|
|
208
|
+
} & Pick<import("openclaw/plugin-sdk/core").OpenClawPluginDefinition, "kind" | "reload" | "nodeHostCommands" | "securityAuditCollectors">;
|
|
209
209
|
export default _default;
|
|
210
210
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAaH,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,aAAa,EAId,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAUL,kBAAkB,EASnB,MAAM,sBAAsB,CAAC;AAW9B,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC;AAYlG,KAAK,iBAAiB,GAClB,iBAAiB,GACjB,mBAAmB,GACnB,mBAAmB,GACnB,SAAS,GACT,iBAAiB,GACjB,iBAAiB,GACjB,kBAAkB,GA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AE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAU1F;;;;;;;;AA2GD,wBAgGG"}
|
package/dist/index.js
CHANGED
|
@@ -19,8 +19,7 @@
|
|
|
19
19
|
*
|
|
20
20
|
* Session key format expected: "agent:<agentId>:<channel>:<name>"
|
|
21
21
|
*/
|
|
22
|
-
import { definePluginEntry } from 'openclaw/plugin-sdk/
|
|
23
|
-
import { buildPluginConfigSchema } from 'openclaw/plugin-sdk/core';
|
|
22
|
+
import { buildPluginConfigSchema, definePluginEntry } from 'openclaw/plugin-sdk/core';
|
|
24
23
|
import { z } from 'zod';
|
|
25
24
|
import { detectTopicShift, stripMessageMetadata, SessionTopicMap, applyToolGradientToWindow, OPENCLAW_BOOTSTRAP_FILES, rotateSessionContext, TRIM_SOFT_TARGET, TRIM_GROWTH_THRESHOLD, TRIM_HEADROOM_FRACTION, resolveTrimBudgets, resolveAdaptiveLifecyclePolicy, formatToolChainStub, decideReplayRecovery, isReplayState, recordOutputMetrics,
|
|
26
25
|
// Sprint 3: unified pressure signal
|
|
@@ -813,6 +812,67 @@ function extractTextFromInboundContent(content) {
|
|
|
813
812
|
.map(part => part.text ?? '')
|
|
814
813
|
.join('\n');
|
|
815
814
|
}
|
|
815
|
+
function isToolResultRole(role) {
|
|
816
|
+
return role === 'tool' || role === 'tool_result' || role === 'toolResult';
|
|
817
|
+
}
|
|
818
|
+
function isPersistableInboundRole(role) {
|
|
819
|
+
return role === 'user' || role === 'assistant' || role === 'system' || isToolResultRole(role);
|
|
820
|
+
}
|
|
821
|
+
function isSenderMetadataText(text) {
|
|
822
|
+
const trimmed = text.trim();
|
|
823
|
+
if (!trimmed)
|
|
824
|
+
return false;
|
|
825
|
+
if (/^Sender \(untrusted metadata\):/i.test(trimmed))
|
|
826
|
+
return true;
|
|
827
|
+
return stripMessageMetadata(trimmed).trim().length === 0 && /Sender \(untrusted metadata\):/i.test(trimmed);
|
|
828
|
+
}
|
|
829
|
+
function shouldDropInboundMessage(msg) {
|
|
830
|
+
if (isPersistableInboundRole(msg.role))
|
|
831
|
+
return false;
|
|
832
|
+
const text = extractTextFromInboundContent(msg.content);
|
|
833
|
+
// OpenClaw/webchat may carry adjacent sender envelopes as role='custom'. They
|
|
834
|
+
// are transport metadata, not conversation turns. Persisting or replaying them
|
|
835
|
+
// lets the metadata row become the latest assistant-ish history item, which can
|
|
836
|
+
// mask the real user prompt under load.
|
|
837
|
+
if (msg.role === 'custom' && isSenderMetadataText(text))
|
|
838
|
+
return true;
|
|
839
|
+
// Unknown roles are not part of the provider transcript contract. Dropping is
|
|
840
|
+
// safer than casting them to assistant in toNeutralMessage().
|
|
841
|
+
return true;
|
|
842
|
+
}
|
|
843
|
+
function sanitizeInboundMessageForModel(msg) {
|
|
844
|
+
if (shouldDropInboundMessage(msg))
|
|
845
|
+
return null;
|
|
846
|
+
// OpenClaw prepends untrusted inbound metadata directly to user-role text for
|
|
847
|
+
// the current provider prompt. That context is useful for the live inbound
|
|
848
|
+
// turn, but if HyperMem replays it from the message window it becomes duplicate
|
|
849
|
+
// user content and can make the model repeat the previous message. Strip it at
|
|
850
|
+
// the context-engine boundary while preserving the actual user text.
|
|
851
|
+
if (msg.role !== 'user')
|
|
852
|
+
return msg;
|
|
853
|
+
if (typeof msg.content === 'string') {
|
|
854
|
+
const stripped = stripMessageMetadata(msg.content);
|
|
855
|
+
return stripped === msg.content ? msg : { ...msg, content: stripped };
|
|
856
|
+
}
|
|
857
|
+
if (Array.isArray(msg.content)) {
|
|
858
|
+
let changed = false;
|
|
859
|
+
const content = msg.content.map((part) => {
|
|
860
|
+
if (!part || part.type !== 'text' || typeof part.text !== 'string')
|
|
861
|
+
return part;
|
|
862
|
+
const stripped = stripMessageMetadata(part.text);
|
|
863
|
+
if (stripped !== part.text)
|
|
864
|
+
changed = true;
|
|
865
|
+
return stripped === part.text ? part : { ...part, text: stripped };
|
|
866
|
+
});
|
|
867
|
+
return changed ? { ...msg, content } : msg;
|
|
868
|
+
}
|
|
869
|
+
return msg;
|
|
870
|
+
}
|
|
871
|
+
function sanitizeInboundMessagesForModel(messages) {
|
|
872
|
+
return messages
|
|
873
|
+
.map((msg) => sanitizeInboundMessageForModel(msg))
|
|
874
|
+
.filter((msg) => Boolean(msg));
|
|
875
|
+
}
|
|
816
876
|
/**
|
|
817
877
|
* Determine whether a user turn is "topic-bearing" (substantive).
|
|
818
878
|
*
|
|
@@ -1046,7 +1106,7 @@ function toNeutralMessage(msg) {
|
|
|
1046
1106
|
toolCalls = contentBlockToolCalls;
|
|
1047
1107
|
}
|
|
1048
1108
|
// OpenClaw uses role 'toolResult' (camelCase). Support all three spellings.
|
|
1049
|
-
const isToolResultMsg = msg.role
|
|
1109
|
+
const isToolResultMsg = isToolResultRole(msg.role);
|
|
1050
1110
|
// Tool results must stay on the result side of the transcript. If we persist them as
|
|
1051
1111
|
// assistant rows with orphaned toolResults, later replay can retain a tool_result after
|
|
1052
1112
|
// trimming away the matching assistant tool_use, which Anthropic rejects with a 400.
|
|
@@ -1067,6 +1127,27 @@ function toNeutralMessage(msg) {
|
|
|
1067
1127
|
toolResults,
|
|
1068
1128
|
};
|
|
1069
1129
|
}
|
|
1130
|
+
function isPlainUserTurnMessage(msg) {
|
|
1131
|
+
if (msg.role !== 'user' || shouldDropInboundMessage(msg))
|
|
1132
|
+
return false;
|
|
1133
|
+
const neutral = toNeutralMessage(msg);
|
|
1134
|
+
return neutral.role === 'user'
|
|
1135
|
+
&& !neutral.toolResults?.length
|
|
1136
|
+
&& stripMessageMetadata(neutral.textContent ?? '').trim().length > 0;
|
|
1137
|
+
}
|
|
1138
|
+
function findBoundaryPlainUserMessage(messages, prePromptMessageCount) {
|
|
1139
|
+
const start = Math.min(prePromptMessageCount - 1, messages.length - 1);
|
|
1140
|
+
for (let i = start; i >= 0; i--) {
|
|
1141
|
+
const msg = messages[i];
|
|
1142
|
+
if (shouldDropInboundMessage(msg))
|
|
1143
|
+
continue;
|
|
1144
|
+
if (isPlainUserTurnMessage(msg))
|
|
1145
|
+
return msg;
|
|
1146
|
+
if (msg.role === 'assistant' || msg.role === 'system' || isToolResultRole(msg.role))
|
|
1147
|
+
return null;
|
|
1148
|
+
}
|
|
1149
|
+
return null;
|
|
1150
|
+
}
|
|
1070
1151
|
// ─── Context Engine Implementation ─────────────────────────────
|
|
1071
1152
|
/**
|
|
1072
1153
|
* In-flight warm dedup map.
|
|
@@ -1640,7 +1721,7 @@ function createHyperMemEngine() {
|
|
|
1640
1721
|
}
|
|
1641
1722
|
// Skip system messages — they come from the runtime, not the conversation
|
|
1642
1723
|
const msg = message;
|
|
1643
|
-
if (msg.role === 'system') {
|
|
1724
|
+
if (msg.role === 'system' || shouldDropInboundMessage(msg)) {
|
|
1644
1725
|
return { ingested: false };
|
|
1645
1726
|
}
|
|
1646
1727
|
try {
|
|
@@ -1755,7 +1836,7 @@ function createHyperMemEngine() {
|
|
|
1755
1836
|
const agentId = extractAgentId(sk);
|
|
1756
1837
|
for (const message of messages) {
|
|
1757
1838
|
const msg = message;
|
|
1758
|
-
if (msg.role === 'system')
|
|
1839
|
+
if (msg.role === 'system' || shouldDropInboundMessage(msg))
|
|
1759
1840
|
continue;
|
|
1760
1841
|
const neutral = toNeutralMessage(msg);
|
|
1761
1842
|
if (neutral.role === 'user' && !neutral.toolResults?.length) {
|
|
@@ -1785,6 +1866,11 @@ function createHyperMemEngine() {
|
|
|
1785
1866
|
* systemPromptAddition — facts/recall/episodes injected before runtime system prompt
|
|
1786
1867
|
*/
|
|
1787
1868
|
async assemble({ sessionId, sessionKey, messages, tokenBudget, prompt, model }) {
|
|
1869
|
+
// Drop non-provider transcript metadata before any pass-through, token
|
|
1870
|
+
// estimate, or persistence-adjacent decision. The current user prompt is
|
|
1871
|
+
// carried separately as `prompt`; adjacent role='custom' sender envelopes
|
|
1872
|
+
// must never become the final model message.
|
|
1873
|
+
messages = sanitizeInboundMessagesForModel(messages);
|
|
1788
1874
|
// ── Tool-loop guard ──────────────────────────────────────────────────────
|
|
1789
1875
|
// When the last message is a toolResult, the runtime is mid tool-loop:
|
|
1790
1876
|
// the model already has full context from the initial turn assembly.
|
|
@@ -2795,7 +2881,10 @@ ${replayRecovery.emittedText}`
|
|
|
2795
2881
|
*
|
|
2796
2882
|
* IMPORTANT: When afterTurn is defined, the runtime calls ONLY afterTurn —
|
|
2797
2883
|
* it never calls ingest() or ingestBatch(). So we must ingest the new
|
|
2798
|
-
* messages here
|
|
2884
|
+
* messages here. Some OpenClaw runtimes include the current user + adjacent
|
|
2885
|
+
* transport metadata in prePromptMessageCount, leaving only assistant/tool
|
|
2886
|
+
* outputs in messages.slice(prePromptMessageCount). Reconcile the boundary
|
|
2887
|
+
* user turn explicitly so SQLite preserves the real user→assistant order.
|
|
2799
2888
|
*/
|
|
2800
2889
|
async afterTurn({ sessionId, sessionKey, messages, prePromptMessageCount, isHeartbeat, runtimeContext }) {
|
|
2801
2890
|
if (isHeartbeat)
|
|
@@ -2804,12 +2893,25 @@ ${replayRecovery.emittedText}`
|
|
|
2804
2893
|
const hm = await getHyperMem();
|
|
2805
2894
|
const sk = resolveSessionKey(sessionId, sessionKey);
|
|
2806
2895
|
const agentId = extractAgentId(sk);
|
|
2807
|
-
// Ingest only the new messages produced this turn
|
|
2896
|
+
// Ingest only the new messages produced this turn, plus the boundary
|
|
2897
|
+
// user turn when OpenClaw counted it as pre-prompt context. The write
|
|
2898
|
+
// path is idempotent, so if an ingress/runtime variant already persisted
|
|
2899
|
+
// this user message, recordUserMessage() suppresses the duplicate.
|
|
2808
2900
|
const newMessages = messages.slice(prePromptMessageCount);
|
|
2809
|
-
|
|
2901
|
+
const hasNewPlainUserMessage = newMessages
|
|
2902
|
+
.map(m => m)
|
|
2903
|
+
.some(m => isPlainUserTurnMessage(m));
|
|
2904
|
+
const boundaryUserMessage = hasNewPlainUserMessage
|
|
2905
|
+
? null
|
|
2906
|
+
: findBoundaryPlainUserMessage(messages, prePromptMessageCount);
|
|
2907
|
+
const currentTurnMessages = boundaryUserMessage
|
|
2908
|
+
? [boundaryUserMessage, ...newMessages]
|
|
2909
|
+
: newMessages;
|
|
2910
|
+
for (const msg of currentTurnMessages) {
|
|
2810
2911
|
const m = msg;
|
|
2811
|
-
// Skip system messages — they come from the
|
|
2812
|
-
|
|
2912
|
+
// Skip system and non-provider metadata messages — they come from the
|
|
2913
|
+
// runtime/transport, not the conversation.
|
|
2914
|
+
if (m.role === 'system' || shouldDropInboundMessage(m))
|
|
2813
2915
|
continue;
|
|
2814
2916
|
if (m.role === 'toolResult' && extractTextFromInboundContent(m.content).trim() === SYNTHETIC_MISSING_TOOL_RESULT_TEXT) {
|
|
2815
2917
|
const toolCallId = typeof m.toolCallId === 'string' ? m.toolCallId : 'unknown';
|
|
@@ -2845,7 +2947,7 @@ ${replayRecovery.emittedText}`
|
|
|
2845
2947
|
}
|
|
2846
2948
|
}
|
|
2847
2949
|
try {
|
|
2848
|
-
const lastAssistantMessage = [...
|
|
2950
|
+
const lastAssistantMessage = [...currentTurnMessages].reverse().find(m => m.role === 'assistant');
|
|
2849
2951
|
if (lastAssistantMessage) {
|
|
2850
2952
|
const modelState = await hm.cache.getModelState(agentId, sk).catch(() => null);
|
|
2851
2953
|
const promptCacheUsage = runtimeContext?.promptCache?.lastCallUsage;
|
|
@@ -2893,7 +2995,7 @@ ${replayRecovery.emittedText}`
|
|
|
2893
2995
|
// Non-fatal: topic detection never blocks afterTurn
|
|
2894
2996
|
let adaptiveTopicShiftConfidence;
|
|
2895
2997
|
try {
|
|
2896
|
-
const inboundUserMsg =
|
|
2998
|
+
const inboundUserMsg = currentTurnMessages
|
|
2897
2999
|
.map(m => m)
|
|
2898
3000
|
.find(m => m.role === 'user');
|
|
2899
3001
|
if (inboundUserMsg) {
|
|
@@ -2954,7 +3056,7 @@ ${replayRecovery.emittedText}`
|
|
|
2954
3056
|
const modelState = await hm.cache.getModelState(agentId, sk);
|
|
2955
3057
|
const gradientBudget = modelState?.tokenBudget;
|
|
2956
3058
|
const gradientDepth = modelState?.historyDepth;
|
|
2957
|
-
const inboundUserMsg =
|
|
3059
|
+
const inboundUserMsg = currentTurnMessages
|
|
2958
3060
|
.map(m => m)
|
|
2959
3061
|
.find(m => m.role === 'user');
|
|
2960
3062
|
const inboundUserText = inboundUserMsg
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@psiclawops/hypercompositor",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.9",
|
|
4
4
|
"description": "HyperCompositor \u2014 context engine plugin for OpenClaw",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"minGatewayVersion": "2026.4.12"
|
|
30
30
|
},
|
|
31
31
|
"build": {
|
|
32
|
-
"openclawVersion": "2026.
|
|
33
|
-
"pluginSdkVersion": "2026.
|
|
32
|
+
"openclawVersion": "2026.5.7",
|
|
33
|
+
"pluginSdkVersion": "2026.5.7"
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"typecheck": "tsc --noEmit"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@psiclawops/hypermem": "0.9.
|
|
43
|
+
"@psiclawops/hypermem": "0.9.9",
|
|
44
44
|
"zod": "^4.0.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"openclaw": "
|
|
47
|
+
"openclaw": "2026.5.7",
|
|
48
48
|
"typescript": "^5.4.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
@@ -63,5 +63,9 @@
|
|
|
63
63
|
"openclaw.plugin.json",
|
|
64
64
|
"README.md",
|
|
65
65
|
"LICENSE"
|
|
66
|
-
]
|
|
66
|
+
],
|
|
67
|
+
"overrides": {
|
|
68
|
+
"uuid": "14.0.0",
|
|
69
|
+
"fast-xml-builder": "1.2.0"
|
|
70
|
+
}
|
|
67
71
|
}
|