@oyerinde/caliper 0.2.0 → 0.2.2

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.js CHANGED
@@ -1 +1 @@
1
- export { VERSION, caliperProps, getConfig, createOverlay as init, setConfig } from './chunk-XYBNY4BT.js';
1
+ export { VERSION, caliperProps, getConfig, createOverlay as init, setConfig } from './chunk-YLE25XII.js';
package/dist/mcp.cjs CHANGED
@@ -297,8 +297,20 @@ var SourceHintsSchema = zod.z.object({
297
297
  tagName: zod.z.string()
298
298
  });
299
299
  var CaliperActionResultSchema = zod.z.union([
300
- zod.z.object({ success: zod.z.literal(true), method: zod.z.literal(CALIPER_METHODS.SELECT), selector: zod.z.string(), selection: SelectionMetadataSchema, timestamp: zod.z.number() }),
301
- zod.z.object({ success: zod.z.literal(true), method: zod.z.literal(CALIPER_METHODS.MEASURE), selector: zod.z.string(), measurement: MeasurementResultSchema, timestamp: zod.z.number() }),
300
+ zod.z.object({
301
+ success: zod.z.literal(true),
302
+ method: zod.z.literal(CALIPER_METHODS.SELECT),
303
+ selector: zod.z.string(),
304
+ selection: SelectionMetadataSchema,
305
+ timestamp: zod.z.number()
306
+ }),
307
+ zod.z.object({
308
+ success: zod.z.literal(true),
309
+ method: zod.z.literal(CALIPER_METHODS.MEASURE),
310
+ selector: zod.z.string(),
311
+ measurement: MeasurementResultSchema,
312
+ timestamp: zod.z.number()
313
+ }),
302
314
  zod.z.object({
303
315
  success: zod.z.literal(true),
304
316
  method: zod.z.literal(CALIPER_METHODS.INSPECT),
@@ -319,8 +331,16 @@ var CaliperActionResultSchema = zod.z.union([
319
331
  sourceHints: SourceHintsSchema.optional(),
320
332
  timestamp: zod.z.number()
321
333
  }),
322
- zod.z.object({ success: zod.z.literal(true), method: zod.z.literal(CALIPER_METHODS.FREEZE), timestamp: zod.z.number() }),
323
- zod.z.object({ success: zod.z.literal(true), method: zod.z.literal(CALIPER_METHODS.CLEAR), timestamp: zod.z.number() }),
334
+ zod.z.object({
335
+ success: zod.z.literal(true),
336
+ method: zod.z.literal(CALIPER_METHODS.FREEZE),
337
+ timestamp: zod.z.number()
338
+ }),
339
+ zod.z.object({
340
+ success: zod.z.literal(true),
341
+ method: zod.z.literal(CALIPER_METHODS.CLEAR),
342
+ timestamp: zod.z.number()
343
+ }),
324
344
  zod.z.object({
325
345
  success: zod.z.literal(true),
326
346
  method: zod.z.literal(CALIPER_METHODS.WALK_DOM),
@@ -383,10 +403,18 @@ var RpcFactory = class {
383
403
  return JSONRPCResultResponseSchema.parse({ jsonrpc: "2.0", id, result });
384
404
  }
385
405
  static error(id, code, message, data) {
386
- return JSONRPCErrorResponseSchema.parse({ jsonrpc: "2.0", id, error: { code, message, data } });
406
+ return JSONRPCErrorResponseSchema.parse({
407
+ jsonrpc: "2.0",
408
+ id,
409
+ error: { code, message, data }
410
+ });
387
411
  }
388
412
  static notification(method, params) {
389
- return JSONRPCNotificationSchema.parse({ jsonrpc: "2.0", method, params });
413
+ return JSONRPCNotificationSchema.parse({
414
+ jsonrpc: "2.0",
415
+ method,
416
+ params
417
+ });
390
418
  }
391
419
  };
392
420
  var isId = (value) => {
@@ -427,11 +455,16 @@ var CaliperNotificationSchema = zod.z.union([
427
455
  params: CaliperAgentStateSchema
428
456
  })
429
457
  ]);
430
- var BridgeMessageSchema = zod.z.union([
431
- CaliperResponseSchema,
432
- CaliperNotificationSchema,
433
- JSONRPCResultResponseSchema
434
- ]);
458
+ var BridgeMessageSchema = zod.z.union([CaliperResponseSchema, CaliperNotificationSchema]);
459
+ function isBridgeNotification(msg) {
460
+ return "method" in msg;
461
+ }
462
+ function isBridgeErrorResponse(msg) {
463
+ return "error" in msg;
464
+ }
465
+ function isBridgeResultResponse(msg) {
466
+ return "result" in msg;
467
+ }
435
468
  zod.z.object({
436
469
  selector: zod.z.string()
437
470
  });
@@ -994,8 +1027,7 @@ var BridgeService = class extends events.EventEmitter {
994
1027
  resolve();
995
1028
  });
996
1029
  server2.on("error", (error) => {
997
- const err = error;
998
- if (err.code === "EADDRINUSE" && remaining > 0) {
1030
+ if (error.code === "EADDRINUSE" && remaining > 0) {
999
1031
  const attemptNum = retries - remaining + 1;
1000
1032
  const delay = getExponentialBackoff(attemptNum - 1, 500);
1001
1033
  logger3.warn(
@@ -1007,7 +1039,7 @@ var BridgeService = class extends events.EventEmitter {
1007
1039
  attemptStart(currentPort, remaining - 1).then(resolve).catch(reject);
1008
1040
  }, delay);
1009
1041
  } else {
1010
- const errorMessage = err.code === "EADDRINUSE" ? `Port ${currentPort} is already in use by another process. Please close the other instance of Caliper or use a different port.` : `WebSocket server error: ${String(error)}`;
1042
+ const errorMessage = error.code === "EADDRINUSE" ? `Port ${currentPort} is already in use by another process. Please close the other instance of Caliper or use a different port.` : `WebSocket server error: ${String(error)}`;
1011
1043
  logger3.error(errorMessage);
1012
1044
  this.startupError = errorMessage;
1013
1045
  server2.close();
@@ -1060,40 +1092,7 @@ var BridgeService = class extends events.EventEmitter {
1060
1092
  return;
1061
1093
  }
1062
1094
  const message = result.data;
1063
- if ("id" in message) {
1064
- if ("result" in message) {
1065
- const resolve = this.pendingCalls.get(String(message.id));
1066
- if (resolve) {
1067
- const finalResult = message.result;
1068
- if (isCaliperActionResult(finalResult)) {
1069
- if (finalResult.success && finalResult.method === CALIPER_METHODS.WALK_AND_MEASURE && binaryPayload) {
1070
- try {
1071
- const root = BitBridge.deserialize(binaryPayload);
1072
- if ("walkResult" in finalResult) {
1073
- finalResult.walkResult.root = root;
1074
- }
1075
- } catch (error) {
1076
- logger3.error("Bit-Bridge reconstruction failed:", error);
1077
- }
1078
- }
1079
- resolve(finalResult);
1080
- } else if (finalResult && typeof finalResult === "object" && "error" in finalResult) {
1081
- resolve(finalResult);
1082
- } else {
1083
- resolve({ error: "Unexpected result format received from bridge" });
1084
- }
1085
- this.pendingCalls.delete(String(message.id));
1086
- }
1087
- } else if ("error" in message) {
1088
- if (message.id !== null) {
1089
- const resolve = this.pendingCalls.get(String(message.id));
1090
- if (resolve) {
1091
- resolve({ error: message.error.message });
1092
- this.pendingCalls.delete(String(message.id));
1093
- }
1094
- }
1095
- }
1096
- } else if ("method" in message) {
1095
+ if (isBridgeNotification(message)) {
1097
1096
  if (message.method === CALIPER_METHODS.REGISTER_TAB) {
1098
1097
  const { tabId: newTabId, url, title, isFocused } = message.params;
1099
1098
  tabId = newTabId;
@@ -1110,9 +1109,46 @@ var BridgeService = class extends events.EventEmitter {
1110
1109
  tabManager.updateTab(tabId, isFocused);
1111
1110
  }
1112
1111
  } else if (message.method === CALIPER_METHODS.STATE_UPDATE) {
1113
- const state = message.params;
1114
- this.emit(BRIDGE_EVENTS.STATE, state);
1112
+ this.emit(BRIDGE_EVENTS.STATE, message.params);
1113
+ }
1114
+ return;
1115
+ }
1116
+ if (isBridgeErrorResponse(message)) {
1117
+ if (message.id !== null) {
1118
+ const resolve = this.pendingCalls.get(String(message.id));
1119
+ if (resolve) {
1120
+ resolve({ error: message.error.message });
1121
+ this.pendingCalls.delete(String(message.id));
1122
+ }
1123
+ }
1124
+ return;
1125
+ }
1126
+ if (isBridgeResultResponse(message)) {
1127
+ const resolve = this.pendingCalls.get(String(message.id));
1128
+ if (!resolve) return;
1129
+ const finalResult = message.result;
1130
+ if (isCaliperActionResult(finalResult)) {
1131
+ if ("walkResult" in finalResult && binaryPayload) {
1132
+ try {
1133
+ const raw = BitBridge.deserialize(binaryPayload);
1134
+ const parsed = CaliperNodeSchema.safeParse(raw);
1135
+ if (parsed.success) {
1136
+ finalResult.walkResult.root = parsed.data;
1137
+ } else {
1138
+ logger3.error(
1139
+ "Bit-Bridge deserialized node failed schema validation",
1140
+ zod.z.treeifyError(parsed.error)
1141
+ );
1142
+ }
1143
+ } catch (error) {
1144
+ logger3.error("Bit-Bridge reconstruction failed:", error);
1145
+ }
1146
+ }
1147
+ resolve(finalResult);
1148
+ } else {
1149
+ resolve({ error: "Unexpected result format received from bridge" });
1115
1150
  }
1151
+ this.pendingCalls.delete(String(message.id));
1116
1152
  }
1117
1153
  } catch (error) {
1118
1154
  logger3.error("WS Message Processing Error:", error);
@@ -1634,7 +1670,7 @@ var CaliperMcpServer = class {
1634
1670
  this.port = port2;
1635
1671
  this.server = new mcp_js.McpServer({
1636
1672
  name: "caliper-mcp-server",
1637
- version: "0.2.0"
1673
+ version: "0.2.2"
1638
1674
  });
1639
1675
  this.registerTools();
1640
1676
  this.registerResources();
@@ -2287,7 +2323,7 @@ Options:
2287
2323
  `);
2288
2324
  process.exit(0);
2289
2325
  } else if (args[i] === "--docs" || args[i] === "-d") {
2290
- console.log("\n\u{1F4DA} View Documentation: https://caliper.danieloyerinde.com/\n");
2326
+ console.error("\n\u{1F4DA} View Documentation: https://caliper.danieloyerinde.com/\n");
2291
2327
  process.exit(0);
2292
2328
  }
2293
2329
  }
package/dist/mcp.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
3
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
4
  import { z } from 'zod';
5
- import { JSONRPCErrorResponseSchema as JSONRPCErrorResponseSchema$1, JSONRPCResultResponseSchema as JSONRPCResultResponseSchema$1, JSONRPCRequestSchema as JSONRPCRequestSchema$1, JSONRPCNotificationSchema as JSONRPCNotificationSchema$1 } from '@modelcontextprotocol/sdk/types.js';
5
+ import { JSONRPCErrorResponseSchema as JSONRPCErrorResponseSchema$1, JSONRPCRequestSchema as JSONRPCRequestSchema$1, JSONRPCResultResponseSchema as JSONRPCResultResponseSchema$1, JSONRPCNotificationSchema as JSONRPCNotificationSchema$1 } from '@modelcontextprotocol/sdk/types.js';
6
6
  import { WebSocketServer } from 'ws';
7
7
  import { EventEmitter } from 'events';
8
8
 
@@ -295,8 +295,20 @@ var SourceHintsSchema = z.object({
295
295
  tagName: z.string()
296
296
  });
297
297
  var CaliperActionResultSchema = z.union([
298
- z.object({ success: z.literal(true), method: z.literal(CALIPER_METHODS.SELECT), selector: z.string(), selection: SelectionMetadataSchema, timestamp: z.number() }),
299
- z.object({ success: z.literal(true), method: z.literal(CALIPER_METHODS.MEASURE), selector: z.string(), measurement: MeasurementResultSchema, timestamp: z.number() }),
298
+ z.object({
299
+ success: z.literal(true),
300
+ method: z.literal(CALIPER_METHODS.SELECT),
301
+ selector: z.string(),
302
+ selection: SelectionMetadataSchema,
303
+ timestamp: z.number()
304
+ }),
305
+ z.object({
306
+ success: z.literal(true),
307
+ method: z.literal(CALIPER_METHODS.MEASURE),
308
+ selector: z.string(),
309
+ measurement: MeasurementResultSchema,
310
+ timestamp: z.number()
311
+ }),
300
312
  z.object({
301
313
  success: z.literal(true),
302
314
  method: z.literal(CALIPER_METHODS.INSPECT),
@@ -317,8 +329,16 @@ var CaliperActionResultSchema = z.union([
317
329
  sourceHints: SourceHintsSchema.optional(),
318
330
  timestamp: z.number()
319
331
  }),
320
- z.object({ success: z.literal(true), method: z.literal(CALIPER_METHODS.FREEZE), timestamp: z.number() }),
321
- z.object({ success: z.literal(true), method: z.literal(CALIPER_METHODS.CLEAR), timestamp: z.number() }),
332
+ z.object({
333
+ success: z.literal(true),
334
+ method: z.literal(CALIPER_METHODS.FREEZE),
335
+ timestamp: z.number()
336
+ }),
337
+ z.object({
338
+ success: z.literal(true),
339
+ method: z.literal(CALIPER_METHODS.CLEAR),
340
+ timestamp: z.number()
341
+ }),
322
342
  z.object({
323
343
  success: z.literal(true),
324
344
  method: z.literal(CALIPER_METHODS.WALK_DOM),
@@ -381,10 +401,18 @@ var RpcFactory = class {
381
401
  return JSONRPCResultResponseSchema.parse({ jsonrpc: "2.0", id, result });
382
402
  }
383
403
  static error(id, code, message, data) {
384
- return JSONRPCErrorResponseSchema.parse({ jsonrpc: "2.0", id, error: { code, message, data } });
404
+ return JSONRPCErrorResponseSchema.parse({
405
+ jsonrpc: "2.0",
406
+ id,
407
+ error: { code, message, data }
408
+ });
385
409
  }
386
410
  static notification(method, params) {
387
- return JSONRPCNotificationSchema.parse({ jsonrpc: "2.0", method, params });
411
+ return JSONRPCNotificationSchema.parse({
412
+ jsonrpc: "2.0",
413
+ method,
414
+ params
415
+ });
388
416
  }
389
417
  };
390
418
  var isId = (value) => {
@@ -425,11 +453,16 @@ var CaliperNotificationSchema = z.union([
425
453
  params: CaliperAgentStateSchema
426
454
  })
427
455
  ]);
428
- var BridgeMessageSchema = z.union([
429
- CaliperResponseSchema,
430
- CaliperNotificationSchema,
431
- JSONRPCResultResponseSchema
432
- ]);
456
+ var BridgeMessageSchema = z.union([CaliperResponseSchema, CaliperNotificationSchema]);
457
+ function isBridgeNotification(msg) {
458
+ return "method" in msg;
459
+ }
460
+ function isBridgeErrorResponse(msg) {
461
+ return "error" in msg;
462
+ }
463
+ function isBridgeResultResponse(msg) {
464
+ return "result" in msg;
465
+ }
433
466
  z.object({
434
467
  selector: z.string()
435
468
  });
@@ -992,8 +1025,7 @@ var BridgeService = class extends EventEmitter {
992
1025
  resolve();
993
1026
  });
994
1027
  server2.on("error", (error) => {
995
- const err = error;
996
- if (err.code === "EADDRINUSE" && remaining > 0) {
1028
+ if (error.code === "EADDRINUSE" && remaining > 0) {
997
1029
  const attemptNum = retries - remaining + 1;
998
1030
  const delay = getExponentialBackoff(attemptNum - 1, 500);
999
1031
  logger3.warn(
@@ -1005,7 +1037,7 @@ var BridgeService = class extends EventEmitter {
1005
1037
  attemptStart(currentPort, remaining - 1).then(resolve).catch(reject);
1006
1038
  }, delay);
1007
1039
  } else {
1008
- const errorMessage = err.code === "EADDRINUSE" ? `Port ${currentPort} is already in use by another process. Please close the other instance of Caliper or use a different port.` : `WebSocket server error: ${String(error)}`;
1040
+ const errorMessage = error.code === "EADDRINUSE" ? `Port ${currentPort} is already in use by another process. Please close the other instance of Caliper or use a different port.` : `WebSocket server error: ${String(error)}`;
1009
1041
  logger3.error(errorMessage);
1010
1042
  this.startupError = errorMessage;
1011
1043
  server2.close();
@@ -1058,40 +1090,7 @@ var BridgeService = class extends EventEmitter {
1058
1090
  return;
1059
1091
  }
1060
1092
  const message = result.data;
1061
- if ("id" in message) {
1062
- if ("result" in message) {
1063
- const resolve = this.pendingCalls.get(String(message.id));
1064
- if (resolve) {
1065
- const finalResult = message.result;
1066
- if (isCaliperActionResult(finalResult)) {
1067
- if (finalResult.success && finalResult.method === CALIPER_METHODS.WALK_AND_MEASURE && binaryPayload) {
1068
- try {
1069
- const root = BitBridge.deserialize(binaryPayload);
1070
- if ("walkResult" in finalResult) {
1071
- finalResult.walkResult.root = root;
1072
- }
1073
- } catch (error) {
1074
- logger3.error("Bit-Bridge reconstruction failed:", error);
1075
- }
1076
- }
1077
- resolve(finalResult);
1078
- } else if (finalResult && typeof finalResult === "object" && "error" in finalResult) {
1079
- resolve(finalResult);
1080
- } else {
1081
- resolve({ error: "Unexpected result format received from bridge" });
1082
- }
1083
- this.pendingCalls.delete(String(message.id));
1084
- }
1085
- } else if ("error" in message) {
1086
- if (message.id !== null) {
1087
- const resolve = this.pendingCalls.get(String(message.id));
1088
- if (resolve) {
1089
- resolve({ error: message.error.message });
1090
- this.pendingCalls.delete(String(message.id));
1091
- }
1092
- }
1093
- }
1094
- } else if ("method" in message) {
1093
+ if (isBridgeNotification(message)) {
1095
1094
  if (message.method === CALIPER_METHODS.REGISTER_TAB) {
1096
1095
  const { tabId: newTabId, url, title, isFocused } = message.params;
1097
1096
  tabId = newTabId;
@@ -1108,9 +1107,46 @@ var BridgeService = class extends EventEmitter {
1108
1107
  tabManager.updateTab(tabId, isFocused);
1109
1108
  }
1110
1109
  } else if (message.method === CALIPER_METHODS.STATE_UPDATE) {
1111
- const state = message.params;
1112
- this.emit(BRIDGE_EVENTS.STATE, state);
1110
+ this.emit(BRIDGE_EVENTS.STATE, message.params);
1111
+ }
1112
+ return;
1113
+ }
1114
+ if (isBridgeErrorResponse(message)) {
1115
+ if (message.id !== null) {
1116
+ const resolve = this.pendingCalls.get(String(message.id));
1117
+ if (resolve) {
1118
+ resolve({ error: message.error.message });
1119
+ this.pendingCalls.delete(String(message.id));
1120
+ }
1121
+ }
1122
+ return;
1123
+ }
1124
+ if (isBridgeResultResponse(message)) {
1125
+ const resolve = this.pendingCalls.get(String(message.id));
1126
+ if (!resolve) return;
1127
+ const finalResult = message.result;
1128
+ if (isCaliperActionResult(finalResult)) {
1129
+ if ("walkResult" in finalResult && binaryPayload) {
1130
+ try {
1131
+ const raw = BitBridge.deserialize(binaryPayload);
1132
+ const parsed = CaliperNodeSchema.safeParse(raw);
1133
+ if (parsed.success) {
1134
+ finalResult.walkResult.root = parsed.data;
1135
+ } else {
1136
+ logger3.error(
1137
+ "Bit-Bridge deserialized node failed schema validation",
1138
+ z.treeifyError(parsed.error)
1139
+ );
1140
+ }
1141
+ } catch (error) {
1142
+ logger3.error("Bit-Bridge reconstruction failed:", error);
1143
+ }
1144
+ }
1145
+ resolve(finalResult);
1146
+ } else {
1147
+ resolve({ error: "Unexpected result format received from bridge" });
1113
1148
  }
1149
+ this.pendingCalls.delete(String(message.id));
1114
1150
  }
1115
1151
  } catch (error) {
1116
1152
  logger3.error("WS Message Processing Error:", error);
@@ -1632,7 +1668,7 @@ var CaliperMcpServer = class {
1632
1668
  this.port = port2;
1633
1669
  this.server = new McpServer({
1634
1670
  name: "caliper-mcp-server",
1635
- version: "0.2.0"
1671
+ version: "0.2.2"
1636
1672
  });
1637
1673
  this.registerTools();
1638
1674
  this.registerResources();
@@ -2285,7 +2321,7 @@ Options:
2285
2321
  `);
2286
2322
  process.exit(0);
2287
2323
  } else if (args[i] === "--docs" || args[i] === "-d") {
2288
- console.log("\n\u{1F4DA} View Documentation: https://caliper.danieloyerinde.com/\n");
2324
+ console.error("\n\u{1F4DA} View Documentation: https://caliper.danieloyerinde.com/\n");
2289
2325
  process.exit(0);
2290
2326
  }
2291
2327
  }
package/dist/preset.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkOSQHATBH_cjs = require('./chunk-OSQHATBH.cjs');
4
- var chunk3W2YKDGV_cjs = require('./chunk-3W2YKDGV.cjs');
3
+ var chunkAHX2GS7J_cjs = require('./chunk-AHX2GS7J.cjs');
4
+ var chunk2SVFU7M3_cjs = require('./chunk-2SVFU7M3.cjs');
5
5
 
6
6
  /**
7
7
  * @name @oyerinde/caliper
@@ -16,7 +16,7 @@ var chunk3W2YKDGV_cjs = require('./chunk-3W2YKDGV.cjs');
16
16
 
17
17
  // src/preset.ts
18
18
  function init(configuration, extensions = []) {
19
- const caliperInstance = chunkOSQHATBH_cjs.createOverlay(configuration);
19
+ const caliperInstance = chunkAHX2GS7J_cjs.createOverlay(configuration);
20
20
  if (extensions && Array.isArray(extensions)) {
21
21
  extensions.forEach((extension) => {
22
22
  if (typeof extension === "function") {
@@ -31,14 +31,14 @@ function init(configuration, extensions = []) {
31
31
 
32
32
  Object.defineProperty(exports, "caliperProps", {
33
33
  enumerable: true,
34
- get: function () { return chunkOSQHATBH_cjs.caliperProps; }
34
+ get: function () { return chunkAHX2GS7J_cjs.caliperProps; }
35
35
  });
36
36
  Object.defineProperty(exports, "CaliperAgentStateSchema", {
37
37
  enumerable: true,
38
- get: function () { return chunk3W2YKDGV_cjs.CaliperAgentStateSchema; }
38
+ get: function () { return chunk2SVFU7M3_cjs.CaliperAgentStateSchema; }
39
39
  });
40
40
  Object.defineProperty(exports, "CaliperBridge", {
41
41
  enumerable: true,
42
- get: function () { return chunk3W2YKDGV_cjs.CaliperBridge; }
42
+ get: function () { return chunk2SVFU7M3_cjs.CaliperBridge; }
43
43
  });
44
44
  exports.init = init;
package/dist/preset.d.cts CHANGED
@@ -7,6 +7,8 @@ export declare interface AgentBridgeConfig {
7
7
  wsPort?: number;
8
8
  /** Callback for agent state changes */
9
9
  onStateChange?: (state: CaliperAgentState) => void;
10
+ /** Name of a global window function to call on state changes (IIFE/CDN-safe, JSON-serializable) */
11
+ onStateChangeGlobal?: string;
10
12
  }
11
13
 
12
14
  export declare interface AnimationConfig {
@@ -467,7 +469,7 @@ export declare const CaliperAgentStateSchema: z.ZodObject<{
467
469
  * When installed, this plugin:
468
470
  * 1. Starts a local WebSocket server (or connects to one) to receive agent commands.
469
471
  * 2. Exposes `window.dispatchCaliperIntent` for manual/in-page agentic calls.
470
- * 3. Syncs the overlay state (camera, selection, measurements) back to the agent.
472
+ * 3. Syncs the overlay state (selection, measurements) back to the agent.
471
473
  *
472
474
  * @example
473
475
  * ```ts
@@ -488,9 +490,15 @@ export declare const CaliperAgentStateSchema: z.ZodObject<{
488
490
  */
489
491
  export declare function CaliperBridge(config: AgentBridgeConfig): CaliperPlugin;
490
492
 
491
- export declare interface CaliperCoreSystems {
492
- measurementSystem: MeasurementSystem;
493
- selectionSystem: SelectionSystem;
493
+ export declare interface CaliperConfig {
494
+ /** Customize the visual appearance of the overlay (colors, shadows). */
495
+ theme?: ThemeConfig;
496
+ /** Customize keyboard shortcuts for all interactions. */
497
+ commands?: CommandsConfig;
498
+ /** Control the boundary box lerp animation behavior. */
499
+ animation?: AnimationConfig;
500
+ /** Enable debug logging (default: true). All logs are stripped from production builds. */
501
+ debug?: boolean;
494
502
  }
495
503
 
496
504
  /**
@@ -571,7 +579,7 @@ export declare type Extension = ((instance: OverlayInstance) => void) | CaliperP
571
579
  * @param extensions - An array of functions or plugin objects to install immediately.
572
580
  * @returns The initialized Caliper OverlayInstance.
573
581
  */
574
- export declare function init(configuration?: OverlayConfig, extensions?: Array<Extension>): OverlayInstance;
582
+ export declare function init(configuration?: CaliperConfig, extensions?: Array<Extension>): OverlayInstance;
575
583
 
576
584
  declare type MeasurementResult = Remap<MeasurementResult_2, {
577
585
  primary: DOMRect;
@@ -746,19 +754,6 @@ declare interface MeasurementSystem {
746
754
 
747
755
  declare type MeasurementSystemListener = () => void;
748
756
 
749
- export declare interface OverlayConfig {
750
- /** Customize the visual appearance of the overlay (colors, shadows). */
751
- theme?: ThemeConfig;
752
- /** Customize keyboard shortcuts for all interactions. */
753
- commands?: CommandsConfig;
754
- /** Control the boundary box lerp animation behavior. */
755
- animation?: AnimationConfig;
756
- /** Configure the Agent Bridge for AI/MCP integration. */
757
- bridge?: AgentBridgeConfig;
758
- /** Enable debug logging (default: true). All logs are stripped from production builds. */
759
- debug?: boolean;
760
- }
761
-
762
757
  /**
763
758
  * Handle to a running Caliper overlay.
764
759
  */
@@ -775,12 +770,12 @@ export declare interface OverlayInstance {
775
770
  /**
776
771
  * Synchronously returns the internal systems if they are initialized.
777
772
  */
778
- getSystems: () => CaliperCoreSystems | null;
773
+ getSystems: () => Systems | null;
779
774
  /**
780
775
  * Asynchronous helper that resolves when the internal systems are ready.
781
776
  * Useful for plugins that need to interact with the DOM or state immediately.
782
777
  */
783
- waitForSystems: () => Promise<CaliperCoreSystems>;
778
+ waitForSystems: () => Promise<Systems>;
784
779
  /**
785
780
  * Registers a plugin with this instance.
786
781
  */
@@ -949,6 +944,11 @@ declare interface SelectionSystem {
949
944
  updateRect: (rect: DOMRect) => void;
950
945
  }
951
946
 
947
+ export declare interface Systems {
948
+ measurementSystem: MeasurementSystem;
949
+ selectionSystem: SelectionSystem;
950
+ }
951
+
952
952
  export declare interface ThemeConfig {
953
953
  primary?: string;
954
954
  secondary?: string;
package/dist/preset.d.ts CHANGED
@@ -7,6 +7,8 @@ export declare interface AgentBridgeConfig {
7
7
  wsPort?: number;
8
8
  /** Callback for agent state changes */
9
9
  onStateChange?: (state: CaliperAgentState) => void;
10
+ /** Name of a global window function to call on state changes (IIFE/CDN-safe, JSON-serializable) */
11
+ onStateChangeGlobal?: string;
10
12
  }
11
13
 
12
14
  export declare interface AnimationConfig {
@@ -467,7 +469,7 @@ export declare const CaliperAgentStateSchema: z.ZodObject<{
467
469
  * When installed, this plugin:
468
470
  * 1. Starts a local WebSocket server (or connects to one) to receive agent commands.
469
471
  * 2. Exposes `window.dispatchCaliperIntent` for manual/in-page agentic calls.
470
- * 3. Syncs the overlay state (camera, selection, measurements) back to the agent.
472
+ * 3. Syncs the overlay state (selection, measurements) back to the agent.
471
473
  *
472
474
  * @example
473
475
  * ```ts
@@ -488,9 +490,15 @@ export declare const CaliperAgentStateSchema: z.ZodObject<{
488
490
  */
489
491
  export declare function CaliperBridge(config: AgentBridgeConfig): CaliperPlugin;
490
492
 
491
- export declare interface CaliperCoreSystems {
492
- measurementSystem: MeasurementSystem;
493
- selectionSystem: SelectionSystem;
493
+ export declare interface CaliperConfig {
494
+ /** Customize the visual appearance of the overlay (colors, shadows). */
495
+ theme?: ThemeConfig;
496
+ /** Customize keyboard shortcuts for all interactions. */
497
+ commands?: CommandsConfig;
498
+ /** Control the boundary box lerp animation behavior. */
499
+ animation?: AnimationConfig;
500
+ /** Enable debug logging (default: true). All logs are stripped from production builds. */
501
+ debug?: boolean;
494
502
  }
495
503
 
496
504
  /**
@@ -571,7 +579,7 @@ export declare type Extension = ((instance: OverlayInstance) => void) | CaliperP
571
579
  * @param extensions - An array of functions or plugin objects to install immediately.
572
580
  * @returns The initialized Caliper OverlayInstance.
573
581
  */
574
- export declare function init(configuration?: OverlayConfig, extensions?: Array<Extension>): OverlayInstance;
582
+ export declare function init(configuration?: CaliperConfig, extensions?: Array<Extension>): OverlayInstance;
575
583
 
576
584
  declare type MeasurementResult = Remap<MeasurementResult_2, {
577
585
  primary: DOMRect;
@@ -746,19 +754,6 @@ declare interface MeasurementSystem {
746
754
 
747
755
  declare type MeasurementSystemListener = () => void;
748
756
 
749
- export declare interface OverlayConfig {
750
- /** Customize the visual appearance of the overlay (colors, shadows). */
751
- theme?: ThemeConfig;
752
- /** Customize keyboard shortcuts for all interactions. */
753
- commands?: CommandsConfig;
754
- /** Control the boundary box lerp animation behavior. */
755
- animation?: AnimationConfig;
756
- /** Configure the Agent Bridge for AI/MCP integration. */
757
- bridge?: AgentBridgeConfig;
758
- /** Enable debug logging (default: true). All logs are stripped from production builds. */
759
- debug?: boolean;
760
- }
761
-
762
757
  /**
763
758
  * Handle to a running Caliper overlay.
764
759
  */
@@ -775,12 +770,12 @@ export declare interface OverlayInstance {
775
770
  /**
776
771
  * Synchronously returns the internal systems if they are initialized.
777
772
  */
778
- getSystems: () => CaliperCoreSystems | null;
773
+ getSystems: () => Systems | null;
779
774
  /**
780
775
  * Asynchronous helper that resolves when the internal systems are ready.
781
776
  * Useful for plugins that need to interact with the DOM or state immediately.
782
777
  */
783
- waitForSystems: () => Promise<CaliperCoreSystems>;
778
+ waitForSystems: () => Promise<Systems>;
784
779
  /**
785
780
  * Registers a plugin with this instance.
786
781
  */
@@ -949,6 +944,11 @@ declare interface SelectionSystem {
949
944
  updateRect: (rect: DOMRect) => void;
950
945
  }
951
946
 
947
+ export declare interface Systems {
948
+ measurementSystem: MeasurementSystem;
949
+ selectionSystem: SelectionSystem;
950
+ }
951
+
952
952
  export declare interface ThemeConfig {
953
953
  primary?: string;
954
954
  secondary?: string;
package/dist/preset.js CHANGED
@@ -1,6 +1,6 @@
1
- import { createOverlay } from './chunk-XYBNY4BT.js';
2
- export { caliperProps } from './chunk-XYBNY4BT.js';
3
- export { CaliperAgentStateSchema, CaliperBridge } from './chunk-ACV6FK43.js';
1
+ import { createOverlay } from './chunk-YLE25XII.js';
2
+ export { caliperProps } from './chunk-YLE25XII.js';
3
+ export { CaliperAgentStateSchema, CaliperBridge } from './chunk-PRUCSUJA.js';
4
4
 
5
5
  /**
6
6
  * @name @oyerinde/caliper
package/dist/version.json CHANGED
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "0.2.0",
3
- "timestamp": "2026-02-12T22:43:35.307Z"
2
+ "version": "0.2.2",
3
+ "timestamp": "2026-03-06T19:06:43.224Z"
4
4
  }