aisnitch 0.2.23 → 0.2.25

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.cts CHANGED
@@ -508,7 +508,7 @@ declare const NormalizedAdapterHookPayloadSchema: z.ZodObject<{
508
508
  /**
509
509
  * Capture strategies supported by built-in and future community adapters.
510
510
  */
511
- type InterceptionStrategy = 'hooks' | 'jsonl-watch' | 'log-watch' | 'sqlite-watch' | 'stream-json' | 'process-detect' | 'pty-wrap' | 'api-client';
511
+ type InterceptionStrategy = 'hooks' | 'jsonl-watch' | 'log-watch' | 'sqlite-watch' | 'stream-json' | 'process-detect' | 'pty-wrap' | 'api-client' | 'plugin';
512
512
  /**
513
513
  * Extra context that adapters can provide alongside emitted events.
514
514
  */
@@ -1013,8 +1013,17 @@ interface OpenClawAdapterOptions extends AdapterRuntimeOptions {
1013
1013
  }
1014
1014
  /**
1015
1015
  * 📖 OpenClaw has several passive surfaces, but none of them is perfect alone.
1016
- * AISnitch therefore merges the real managed hook path with filesystem and
1017
- * process fallbacks so operators still get signal when setup is partial.
1016
+ * AISnitch therefore merges the real managed hook path with a Plugin SDK
1017
+ * integration, filesystem watchers, and process fallbacks so operators still
1018
+ * get signal when setup is partial.
1019
+ *
1020
+ * The Plugin strategy (via `aisnitch setup openclaw`) installs a managed
1021
+ * OpenClaw plugin at `~/.openclaw/plugins/aisnitch-monitor/` that uses the
1022
+ * Plugin SDK hooks (`before_tool_call`, `after_tool_call`, `agent_end`,
1023
+ * `model_call_started`, `model_call_ended`, etc.) to forward rich real-time
1024
+ * payloads to the AISnitch HTTP receiver. This gives the highest-fidelity
1025
+ * signal — tool names, parameters, results, errors, durations, model info —
1026
+ * without any filesystem polling.
1018
1027
  */
1019
1028
  declare class OpenClawAdapter extends BaseAdapter {
1020
1029
  readonly displayName = "OpenClaw";
package/dist/index.d.ts CHANGED
@@ -508,7 +508,7 @@ declare const NormalizedAdapterHookPayloadSchema: z.ZodObject<{
508
508
  /**
509
509
  * Capture strategies supported by built-in and future community adapters.
510
510
  */
511
- type InterceptionStrategy = 'hooks' | 'jsonl-watch' | 'log-watch' | 'sqlite-watch' | 'stream-json' | 'process-detect' | 'pty-wrap' | 'api-client';
511
+ type InterceptionStrategy = 'hooks' | 'jsonl-watch' | 'log-watch' | 'sqlite-watch' | 'stream-json' | 'process-detect' | 'pty-wrap' | 'api-client' | 'plugin';
512
512
  /**
513
513
  * Extra context that adapters can provide alongside emitted events.
514
514
  */
@@ -1013,8 +1013,17 @@ interface OpenClawAdapterOptions extends AdapterRuntimeOptions {
1013
1013
  }
1014
1014
  /**
1015
1015
  * 📖 OpenClaw has several passive surfaces, but none of them is perfect alone.
1016
- * AISnitch therefore merges the real managed hook path with filesystem and
1017
- * process fallbacks so operators still get signal when setup is partial.
1016
+ * AISnitch therefore merges the real managed hook path with a Plugin SDK
1017
+ * integration, filesystem watchers, and process fallbacks so operators still
1018
+ * get signal when setup is partial.
1019
+ *
1020
+ * The Plugin strategy (via `aisnitch setup openclaw`) installs a managed
1021
+ * OpenClaw plugin at `~/.openclaw/plugins/aisnitch-monitor/` that uses the
1022
+ * Plugin SDK hooks (`before_tool_call`, `after_tool_call`, `agent_end`,
1023
+ * `model_call_started`, `model_call_ended`, etc.) to forward rich real-time
1024
+ * payloads to the AISnitch HTTP receiver. This gives the highest-fidelity
1025
+ * signal — tool names, parameters, results, errors, durations, model info —
1026
+ * without any filesystem polling.
1018
1027
  */
1019
1028
  declare class OpenClawAdapter extends BaseAdapter {
1020
1029
  readonly displayName = "OpenClaw";
package/dist/index.js CHANGED
@@ -6256,6 +6256,7 @@ var OpenClawAdapter = class extends BaseAdapter {
6256
6256
  displayName = "OpenClaw";
6257
6257
  name = "openclaw";
6258
6258
  strategies = [
6259
+ "plugin",
6259
6260
  "hooks",
6260
6261
  "log-watch",
6261
6262
  "jsonl-watch",
@@ -6475,11 +6476,32 @@ var OpenClawAdapter = class extends BaseAdapter {
6475
6476
  await this.emitOpenClawSessionEnd(sharedData, context);
6476
6477
  return;
6477
6478
  }
6478
- case "session:compact:before":
6479
- case "before_compaction": {
6479
+ case "model_call_started": {
6480
6480
  await this.ensureSessionStarted(sharedData, context);
6481
6481
  this.clearThinking(sessionId);
6482
- await this.emitStateChange("agent.compact", sharedData, context);
6482
+ await this.emitStateChange("agent.thinking", sharedData, context);
6483
+ return;
6484
+ }
6485
+ case "model_call_ended": {
6486
+ await this.ensureSessionStarted(sharedData, context);
6487
+ await this.emitStateChange("agent.streaming", {
6488
+ ...sharedData,
6489
+ raw: {
6490
+ ...sharedData.raw ?? {},
6491
+ durationMs: getNumber7(payload, "durationMs"),
6492
+ outcome: getString9(payload, "outcome"),
6493
+ source: "plugin"
6494
+ }
6495
+ }, context);
6496
+ return;
6497
+ }
6498
+ case "before_tool_call": {
6499
+ await this.ensureSessionStarted(sharedData, context);
6500
+ await this.emitStateChange(
6501
+ isOpenClawCodingTool(sharedData.toolName, sharedData.toolInput) ? "agent.coding" : "agent.tool_call",
6502
+ sharedData,
6503
+ context
6504
+ );
6483
6505
  return;
6484
6506
  }
6485
6507
  case "tool_result_persist": {
@@ -6492,6 +6514,13 @@ var OpenClawAdapter = class extends BaseAdapter {
6492
6514
  this.scheduleThinking(sessionId, sharedData, context, POST_TOOL_THINKING_DELAY_MS);
6493
6515
  return;
6494
6516
  }
6517
+ case "session:compact:before":
6518
+ case "before_compaction": {
6519
+ await this.ensureSessionStarted(sharedData, context);
6520
+ this.clearThinking(sessionId);
6521
+ await this.emitStateChange("agent.compact", sharedData, context);
6522
+ return;
6523
+ }
6495
6524
  case "message:received":
6496
6525
  case "message:preprocessed":
6497
6526
  case "session:compact:after":
@@ -6951,6 +6980,7 @@ function buildOpenClawEventData(payload) {
6951
6980
  return {
6952
6981
  activeFile: extractOpenClawActiveFile(payload) ?? toolInput?.filePath,
6953
6982
  cwd,
6983
+ duration: getNumber7(payload, "duration") ?? getNumber7(payload, "durationMs"),
6954
6984
  errorMessage: extractOpenClawErrorMessage(payload),
6955
6985
  errorType: inferOpenClawErrorType(payload),
6956
6986
  model: extractOpenClawModel(payload),
@@ -7015,7 +7045,7 @@ function extractOpenClawToolInput(payload) {
7015
7045
  };
7016
7046
  }
7017
7047
  function extractOpenClawErrorMessage(payload) {
7018
- return getString9(payload, "error") ?? getString9(payload, "message") ?? getString9(getRecord8(payload.error), "message") ?? getString9(getRecord8(payload.result), "error");
7048
+ return getString9(payload, "error") ?? getString9(payload, "errorMessage") ?? getString9(payload, "message") ?? getString9(getRecord8(payload.error), "message") ?? getString9(getRecord8(payload.result), "error") ?? getString9(getRecord8(payload.result), "message");
7019
7049
  }
7020
7050
  function inferOpenClawErrorType(payload) {
7021
7051
  const errorMessage = extractOpenClawErrorMessage(payload);
@@ -9246,7 +9276,7 @@ import { WebSocket, WebSocketServer } from "ws";
9246
9276
 
9247
9277
  // src/package-info.ts
9248
9278
  var AISNITCH_PACKAGE_NAME = "aisnitch";
9249
- var AISNITCH_VERSION = "0.2.23";
9279
+ var AISNITCH_VERSION = "0.2.25";
9250
9280
  var AISNITCH_DESCRIPTION = "Universal bridge for AI coding tool activity \u2014 capture, normalize, stream.";
9251
9281
  function getPackageScaffoldInfo() {
9252
9282
  return {