agentlang 0.8.9 → 0.9.0

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.
@@ -39,6 +39,7 @@ import {
39
39
  } from '../defs.js';
40
40
  import { getMonitor, getMonitorsForEvent, Monitor } from '../monitor.js';
41
41
  import { registerResolver, setResolver } from '../resolvers/registry.js';
42
+ import { base64Encode } from '../../utils/runtime.js';
42
43
 
43
44
  const CoreModuleDefinition = `module ${DefaultModuleName}
44
45
 
@@ -438,9 +439,9 @@ function getMonitoringEventName(inst: Instance): string {
438
439
  }
439
440
 
440
441
  async function saveMonitoringData(m: Monitor) {
441
- const data = btoa(JSON.stringify(m.asObject()));
442
+ const data = base64Encode(JSON.stringify(m.asObject()));
442
443
  const inst = m.getEventInstance();
443
- const eventInstance = inst ? btoa(JSON.stringify(inst.asSerializableObject())) : '';
444
+ const eventInstance = inst ? base64Encode(JSON.stringify(inst.asSerializableObject())) : '';
444
445
  const user = m.getUser() || 'admin';
445
446
  const latency = m.getTotalLatencyMs();
446
447
  const monitorId = m.getId();
@@ -22,6 +22,13 @@ export function isExecGraphEnabled(): boolean {
22
22
  return true;
23
23
  }
24
24
 
25
+ export function base64Encode(str: string): string {
26
+ if (isNodeEnv) {
27
+ return Buffer.from(str, 'utf-8').toString('base64');
28
+ }
29
+ return btoa(String.fromCharCode(...new TextEncoder().encode(str)));
30
+ }
31
+
25
32
  // Browser-compatible path utilities
26
33
  export const browserPath = {
27
34
  extname: (path: string): string => {