@clawchatsai/connector 0.0.83 → 0.0.85

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 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>) => void | Promise<void>, opts?: {
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
- // Capture MEDIA: paths from exec tool results before the gateway strips them from message text.
1148
- // Fires after every tool call; we filter to exec only and check for MEDIA: lines.
1149
- // Uses api.on() the correct public API for typed lifecycle hooks (NOT registerTypedHook).
1150
- // Re-arm the capability note after compaction so the agent regains MEDIA: knowledge.
1151
- // Post-compaction the injected note is gone from context; clearing the session key
1152
- // causes it to re-inject on the next user message.
1153
- api.on('after_compaction', (_event, ctx) => {
1154
- const sessionKey = ctx.sessionKey;
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.83",
3
+ "version": "0.0.85",
4
4
  "type": "module",
5
5
  "description": "ClawChats OpenClaw plugin — P2P tunnel + local API bridge",
6
6
  "main": "dist/index.js",