@clawchatsai/connector 0.0.84 → 0.0.86
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 +1 -1
- package/dist/index.js +8 -24
- package/package.json +3 -2
- package/server.js +1994 -2417
package/dist/index.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ interface PluginApi {
|
|
|
51
51
|
name: string;
|
|
52
52
|
description?: string;
|
|
53
53
|
}) => void;
|
|
54
|
-
on: (hookName: string, handler: (event: Record<string, unknown>, ctx: Record<string, unknown>) =>
|
|
54
|
+
on: (hookName: string, handler: (event: Record<string, unknown>, ctx: Record<string, unknown>) => unknown | Promise<unknown>, opts?: {
|
|
55
55
|
name?: string;
|
|
56
56
|
description?: string;
|
|
57
57
|
priority?: number;
|
package/dist/index.js
CHANGED
|
@@ -391,7 +391,6 @@ async function stopClawChats(ctx) {
|
|
|
391
391
|
* Injecting a minimal placeholder ensures the agent run proceeds.
|
|
392
392
|
*/
|
|
393
393
|
// Track which ClawChats thread sessions have received the capability note (once per session).
|
|
394
|
-
const _hintedSessions = new Set();
|
|
395
394
|
function normalizeGatewayPayload(raw) {
|
|
396
395
|
try {
|
|
397
396
|
const parsed = JSON.parse(raw);
|
|
@@ -442,16 +441,6 @@ function normalizeGatewayPayload(raw) {
|
|
|
442
441
|
return JSON.stringify(parsed);
|
|
443
442
|
}
|
|
444
443
|
}
|
|
445
|
-
// Capability note: inform the agent that exec stdout lines starting with MEDIA:/path
|
|
446
|
-
// cause that file to appear inline in chat. Phrased descriptively (not imperatively)
|
|
447
|
-
// to avoid triggering prompt-injection scanners. Injected once per session (~8 tokens).
|
|
448
|
-
const sk = parsed.params.sessionKey || '';
|
|
449
|
-
if (sk.includes(':chat:') && !_hintedSessions.has(sk)) {
|
|
450
|
-
_hintedSessions.add(sk);
|
|
451
|
-
parsed.params.message += '\n[ClawChats: exec stdout lines starting with MEDIA:/path/to/file are displayed inline — use this after Write tool or when sharing a file location with the user]';
|
|
452
|
-
console.log(`[clawchats] capability-note injected for session ${sk}`);
|
|
453
|
-
return JSON.stringify(parsed);
|
|
454
|
-
}
|
|
455
444
|
}
|
|
456
445
|
}
|
|
457
446
|
catch {
|
|
@@ -1144,19 +1133,14 @@ const plugin = {
|
|
|
1144
1133
|
// Shared stash: after_tool_call hook populates this; saveAssistantMessage reads + clears it.
|
|
1145
1134
|
// Keyed by sessionKey → absolute paths extracted from MEDIA: lines in exec stdout.
|
|
1146
1135
|
const mediaStash = new Map();
|
|
1147
|
-
//
|
|
1148
|
-
//
|
|
1149
|
-
//
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
if (sessionKey) {
|
|
1156
|
-
_hintedSessions.delete(sessionKey);
|
|
1157
|
-
console.log(`[clawchats] compaction detected — capability note re-armed for ${sessionKey}`);
|
|
1158
|
-
}
|
|
1159
|
-
}, { name: 'clawchats-rearm-after-compaction', description: 'Re-arms MEDIA: capability note after context compaction' });
|
|
1136
|
+
// Inject MEDIA: capability note into the system prompt via before_prompt_build.
|
|
1137
|
+
// Appended to system context (trusted, not user-turn) so it's always present and
|
|
1138
|
+
// never flagged as prompt injection. Survives compaction automatically.
|
|
1139
|
+
api.on('before_prompt_build', (_event, _ctx) => {
|
|
1140
|
+
return {
|
|
1141
|
+
appendSystemContext: 'ClawChats inline preview: after writing a file with the Write tool, run `echo "MEDIA:/absolute/path/to/file"` via the exec tool to display it inline in the chat UI.',
|
|
1142
|
+
};
|
|
1143
|
+
}, { name: 'clawchats-media-hint', description: 'Appends MEDIA: file preview capability note to system prompt' });
|
|
1160
1144
|
api.on('after_tool_call', (event, ctx) => {
|
|
1161
1145
|
if (event.toolName !== 'exec' && event.toolName !== 'process')
|
|
1162
1146
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clawchatsai/connector",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.86",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "ClawChats OpenClaw plugin — P2P tunnel + local API bridge",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"node": ">=18"
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
|
-
"prebuild": "
|
|
20
|
+
"prebuild": "node esbuild.config.mjs",
|
|
21
21
|
"build": "tsc",
|
|
22
22
|
"dev": "tsc --watch",
|
|
23
23
|
"prepublishOnly": "npm run build",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/ws": "^8.0.0",
|
|
39
|
+
"esbuild": "^0.27.4",
|
|
39
40
|
"typescript": "^5.4.0"
|
|
40
41
|
}
|
|
41
42
|
}
|