agent-relay 2.0.4 → 2.0.5

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.
Files changed (123) hide show
  1. package/dist/dashboard/out/404.html +1 -1
  2. package/dist/dashboard/out/app/onboarding.html +1 -1
  3. package/dist/dashboard/out/app/onboarding.txt +1 -1
  4. package/dist/dashboard/out/app.html +1 -1
  5. package/dist/dashboard/out/app.txt +1 -1
  6. package/dist/dashboard/out/cloud/link.html +1 -1
  7. package/dist/dashboard/out/cloud/link.txt +1 -1
  8. package/dist/dashboard/out/connect-repos.html +1 -1
  9. package/dist/dashboard/out/connect-repos.txt +1 -1
  10. package/dist/dashboard/out/history.html +1 -1
  11. package/dist/dashboard/out/history.txt +1 -1
  12. package/dist/dashboard/out/index.html +1 -1
  13. package/dist/dashboard/out/index.txt +1 -1
  14. package/dist/dashboard/out/login.html +1 -1
  15. package/dist/dashboard/out/login.txt +1 -1
  16. package/dist/dashboard/out/metrics.html +1 -1
  17. package/dist/dashboard/out/metrics.txt +1 -1
  18. package/dist/dashboard/out/pricing.html +1 -1
  19. package/dist/dashboard/out/pricing.txt +1 -1
  20. package/dist/dashboard/out/providers/setup/claude.html +1 -1
  21. package/dist/dashboard/out/providers/setup/claude.txt +1 -1
  22. package/dist/dashboard/out/providers/setup/codex.html +1 -1
  23. package/dist/dashboard/out/providers/setup/codex.txt +1 -1
  24. package/dist/dashboard/out/providers/setup/cursor.html +1 -1
  25. package/dist/dashboard/out/providers/setup/cursor.txt +1 -1
  26. package/dist/dashboard/out/providers.html +1 -1
  27. package/dist/dashboard/out/providers.txt +1 -1
  28. package/dist/dashboard/out/signup.html +1 -1
  29. package/dist/dashboard/out/signup.txt +1 -1
  30. package/dist/src/cli/index.js +61 -3
  31. package/package.json +14 -12
  32. package/packages/api-types/package.json +1 -1
  33. package/packages/bridge/package.json +7 -7
  34. package/packages/cloud/package.json +6 -6
  35. package/packages/config/package.json +2 -2
  36. package/packages/continuity/package.json +1 -1
  37. package/packages/daemon/dist/router.d.ts +2 -1
  38. package/packages/daemon/dist/router.js +142 -52
  39. package/packages/daemon/dist/server.d.ts +3 -0
  40. package/packages/daemon/dist/server.js +31 -1
  41. package/packages/daemon/dist/spawn-manager.d.ts +5 -0
  42. package/packages/daemon/dist/spawn-manager.js +39 -0
  43. package/packages/daemon/package.json +12 -11
  44. package/packages/dashboard/package.json +12 -12
  45. package/packages/dashboard/ui-dist/404.html +1 -1
  46. package/packages/dashboard/ui-dist/app/onboarding.html +1 -1
  47. package/packages/dashboard/ui-dist/app/onboarding.txt +1 -1
  48. package/packages/dashboard/ui-dist/app.html +1 -1
  49. package/packages/dashboard/ui-dist/app.txt +1 -1
  50. package/packages/dashboard/ui-dist/cloud/link.html +1 -1
  51. package/packages/dashboard/ui-dist/cloud/link.txt +1 -1
  52. package/packages/dashboard/ui-dist/connect-repos.html +1 -1
  53. package/packages/dashboard/ui-dist/connect-repos.txt +1 -1
  54. package/packages/dashboard/ui-dist/history.html +1 -1
  55. package/packages/dashboard/ui-dist/history.txt +1 -1
  56. package/packages/dashboard/ui-dist/index.html +1 -1
  57. package/packages/dashboard/ui-dist/index.txt +1 -1
  58. package/packages/dashboard/ui-dist/login.html +1 -1
  59. package/packages/dashboard/ui-dist/login.txt +1 -1
  60. package/packages/dashboard/ui-dist/metrics.html +1 -1
  61. package/packages/dashboard/ui-dist/metrics.txt +1 -1
  62. package/packages/dashboard/ui-dist/pricing.html +1 -1
  63. package/packages/dashboard/ui-dist/pricing.txt +1 -1
  64. package/packages/dashboard/ui-dist/providers/setup/claude.html +1 -1
  65. package/packages/dashboard/ui-dist/providers/setup/claude.txt +1 -1
  66. package/packages/dashboard/ui-dist/providers/setup/codex.html +1 -1
  67. package/packages/dashboard/ui-dist/providers/setup/codex.txt +1 -1
  68. package/packages/dashboard/ui-dist/providers/setup/cursor.html +1 -1
  69. package/packages/dashboard/ui-dist/providers/setup/cursor.txt +1 -1
  70. package/packages/dashboard/ui-dist/providers.html +1 -1
  71. package/packages/dashboard/ui-dist/providers.txt +1 -1
  72. package/packages/dashboard/ui-dist/signup.html +1 -1
  73. package/packages/dashboard/ui-dist/signup.txt +1 -1
  74. package/packages/dashboard-server/dist/user-bridge.d.ts +7 -3
  75. package/packages/dashboard-server/dist/user-bridge.js +48 -30
  76. package/packages/dashboard-server/package.json +12 -12
  77. package/packages/hooks/package.json +4 -4
  78. package/packages/mcp/README.md +19 -135
  79. package/packages/mcp/dist/client.js +67 -27
  80. package/packages/mcp/dist/cloud.js +1 -18
  81. package/packages/mcp/package.json +2 -1
  82. package/packages/memory/package.json +2 -2
  83. package/packages/policy/package.json +2 -2
  84. package/packages/protocol/package.json +1 -1
  85. package/packages/resiliency/package.json +1 -1
  86. package/packages/sdk/README.md +43 -160
  87. package/packages/sdk/dist/client.d.ts +3 -99
  88. package/packages/sdk/dist/client.js +6 -113
  89. package/packages/sdk/dist/index.d.ts +0 -1
  90. package/packages/sdk/dist/index.js +0 -2
  91. package/packages/sdk/dist/standalone.js +0 -1
  92. package/packages/sdk/package.json +2 -2
  93. package/packages/spawner/package.json +1 -1
  94. package/packages/state/package.json +1 -1
  95. package/packages/storage/package.json +2 -2
  96. package/packages/telemetry/dist/client.d.ts +19 -0
  97. package/packages/telemetry/dist/client.js +125 -0
  98. package/packages/telemetry/dist/config.d.ts +29 -0
  99. package/packages/telemetry/dist/config.js +88 -0
  100. package/packages/telemetry/dist/events.d.ts +106 -0
  101. package/packages/telemetry/dist/events.js +10 -0
  102. package/packages/telemetry/dist/index.d.ts +8 -0
  103. package/packages/telemetry/dist/index.js +7 -0
  104. package/packages/telemetry/dist/machine-id.d.ts +12 -0
  105. package/packages/telemetry/dist/machine-id.js +58 -0
  106. package/packages/telemetry/dist/posthog-config.d.ts +16 -0
  107. package/packages/telemetry/dist/posthog-config.js +33 -0
  108. package/packages/telemetry/package.json +41 -0
  109. package/packages/trajectory/package.json +2 -2
  110. package/packages/user-directory/package.json +2 -2
  111. package/packages/utils/package.json +1 -1
  112. package/packages/wrapper/dist/relay-pty-orchestrator.js +1 -1
  113. package/packages/wrapper/package.json +6 -6
  114. package/packages/sdk/dist/discovery.d.ts +0 -29
  115. package/packages/sdk/dist/discovery.js +0 -126
  116. /package/dist/dashboard/out/_next/static/{72btMIJ64BCAB4UgVkpaq → xtLmZI8Coh2009JpfvOBw}/_buildManifest.js +0 -0
  117. /package/dist/dashboard/out/_next/static/{72btMIJ64BCAB4UgVkpaq → xtLmZI8Coh2009JpfvOBw}/_ssgManifest.js +0 -0
  118. /package/packages/dashboard/ui-dist/_next/static/{0AsOfRemPXJmtynCKT-rx → QWdjV9SGDgz-GkriZP7Ao}/_buildManifest.js +0 -0
  119. /package/packages/dashboard/ui-dist/_next/static/{0AsOfRemPXJmtynCKT-rx → QWdjV9SGDgz-GkriZP7Ao}/_ssgManifest.js +0 -0
  120. /package/packages/dashboard/ui-dist/_next/static/{72btMIJ64BCAB4UgVkpaq → SySrsm8xdGaeJLrZ2RNuf}/_buildManifest.js +0 -0
  121. /package/packages/dashboard/ui-dist/_next/static/{72btMIJ64BCAB4UgVkpaq → SySrsm8xdGaeJLrZ2RNuf}/_ssgManifest.js +0 -0
  122. /package/packages/dashboard/ui-dist/_next/static/{clUN2n0bz9HCjKI0qlOxU → xtLmZI8Coh2009JpfvOBw}/_buildManifest.js +0 -0
  123. /package/packages/dashboard/ui-dist/_next/static/{clUN2n0bz9HCjKI0qlOxU → xtLmZI8Coh2009JpfvOBw}/_ssgManifest.js +0 -0
@@ -0,0 +1,125 @@
1
+ /**
2
+ * PostHog telemetry client singleton.
3
+ */
4
+ import { PostHog } from 'posthog-node';
5
+ import os from 'node:os';
6
+ import fs from 'node:fs';
7
+ import path from 'node:path';
8
+ import { fileURLToPath } from 'node:url';
9
+ import { isTelemetryEnabled, getAnonymousId, wasNotified, markNotified, isDisabledByEnv, loadPrefs, } from './config.js';
10
+ import { getPostHogConfig } from './posthog-config.js';
11
+ let client = null;
12
+ let commonProps = null;
13
+ let anonymousId = null;
14
+ let initialized = false;
15
+ function findPackageJson(startDir) {
16
+ let dir = startDir;
17
+ while (dir !== path.dirname(dir)) {
18
+ const candidate = path.join(dir, 'package.json');
19
+ if (fs.existsSync(candidate)) {
20
+ return candidate;
21
+ }
22
+ dir = path.dirname(dir);
23
+ }
24
+ return null;
25
+ }
26
+ function getVersion() {
27
+ try {
28
+ const __filename = fileURLToPath(import.meta.url);
29
+ const __dirname = path.dirname(__filename);
30
+ const packageJsonPath = findPackageJson(__dirname);
31
+ if (packageJsonPath) {
32
+ const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
33
+ return pkg.version || 'unknown';
34
+ }
35
+ }
36
+ catch {
37
+ // Fall through
38
+ }
39
+ return 'unknown';
40
+ }
41
+ function buildCommonProperties() {
42
+ return {
43
+ agent_relay_version: getVersion(),
44
+ os: process.platform,
45
+ os_version: os.release(),
46
+ node_version: process.version.slice(1),
47
+ arch: process.arch,
48
+ };
49
+ }
50
+ function showFirstRunNotice() {
51
+ if (wasNotified())
52
+ return;
53
+ if (isDisabledByEnv()) {
54
+ markNotified();
55
+ return;
56
+ }
57
+ console.log('');
58
+ console.log('Agent Relay collects anonymous usage data to improve the product.');
59
+ console.log('Run `agent-relay telemetry disable` to opt out.');
60
+ console.log('Learn more: https://agent-relay.com/telemetry');
61
+ console.log('');
62
+ markNotified();
63
+ }
64
+ export function initTelemetry(options = {}) {
65
+ if (initialized)
66
+ return;
67
+ initialized = true;
68
+ if (options.showNotice !== false) {
69
+ showFirstRunNotice();
70
+ }
71
+ if (!isTelemetryEnabled())
72
+ return;
73
+ const posthogConfig = getPostHogConfig();
74
+ if (!posthogConfig)
75
+ return;
76
+ client = new PostHog(posthogConfig.apiKey, {
77
+ host: posthogConfig.host,
78
+ flushAt: 10,
79
+ flushInterval: 10000,
80
+ });
81
+ commonProps = buildCommonProperties();
82
+ anonymousId = getAnonymousId();
83
+ }
84
+ export function track(event, properties) {
85
+ if (!client || !commonProps || !anonymousId)
86
+ return;
87
+ client.capture({
88
+ distinctId: anonymousId,
89
+ event,
90
+ properties: {
91
+ ...commonProps,
92
+ ...properties,
93
+ },
94
+ });
95
+ }
96
+ export async function shutdown() {
97
+ if (!client)
98
+ return;
99
+ try {
100
+ await client.shutdown();
101
+ }
102
+ catch {
103
+ // Ignore
104
+ }
105
+ finally {
106
+ client = null;
107
+ commonProps = null;
108
+ anonymousId = null;
109
+ initialized = false;
110
+ }
111
+ }
112
+ export function isEnabled() {
113
+ return isTelemetryEnabled();
114
+ }
115
+ export { getAnonymousId };
116
+ export function getStatus() {
117
+ const prefs = loadPrefs();
118
+ return {
119
+ enabled: isTelemetryEnabled(),
120
+ disabledByEnv: isDisabledByEnv(),
121
+ anonymousId: prefs.anonymousId,
122
+ notifiedAt: prefs.notifiedAt,
123
+ };
124
+ }
125
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Telemetry preference storage (~/.agent-relay/telemetry.json)
3
+ */
4
+ export interface TelemetryPrefs {
5
+ /** Whether telemetry is enabled (default: true) */
6
+ enabled: boolean;
7
+ /** ISO timestamp when user was shown the first-run notice */
8
+ notifiedAt?: string;
9
+ /** Anonymous ID derived from machine-id hash */
10
+ anonymousId: string;
11
+ }
12
+ export declare function getPrefsPath(): string;
13
+ export declare function loadPrefs(): TelemetryPrefs;
14
+ export declare function savePrefs(prefs: TelemetryPrefs): void;
15
+ export declare function isDisabledByEnv(): boolean;
16
+ /**
17
+ * Check if telemetry is enabled.
18
+ * Order of precedence:
19
+ * 1. AGENT_RELAY_TELEMETRY_DISABLED=1 -> disabled
20
+ * 2. ~/.agent-relay/telemetry.json -> use stored pref
21
+ * 3. Default -> enabled
22
+ */
23
+ export declare function isTelemetryEnabled(): boolean;
24
+ export declare function enableTelemetry(): void;
25
+ export declare function disableTelemetry(): void;
26
+ export declare function markNotified(): void;
27
+ export declare function wasNotified(): boolean;
28
+ export declare function getAnonymousId(): string;
29
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Telemetry preference storage (~/.agent-relay/telemetry.json)
3
+ */
4
+ import fs from 'node:fs';
5
+ import path from 'node:path';
6
+ import os from 'node:os';
7
+ import { createAnonymousId } from './machine-id.js';
8
+ export function getPrefsPath() {
9
+ const configDir = process.env.AGENT_RELAY_DATA_DIR ||
10
+ path.join(os.homedir(), '.agent-relay');
11
+ return path.join(configDir, 'telemetry.json');
12
+ }
13
+ export function loadPrefs() {
14
+ const prefsPath = getPrefsPath();
15
+ try {
16
+ if (fs.existsSync(prefsPath)) {
17
+ const content = fs.readFileSync(prefsPath, 'utf-8');
18
+ const prefs = JSON.parse(content);
19
+ if (!prefs.anonymousId) {
20
+ prefs.anonymousId = createAnonymousId();
21
+ savePrefs(prefs);
22
+ }
23
+ return {
24
+ enabled: prefs.enabled ?? true,
25
+ notifiedAt: prefs.notifiedAt,
26
+ anonymousId: prefs.anonymousId,
27
+ };
28
+ }
29
+ }
30
+ catch {
31
+ // Fall through to defaults
32
+ }
33
+ return {
34
+ enabled: true,
35
+ anonymousId: createAnonymousId(),
36
+ };
37
+ }
38
+ export function savePrefs(prefs) {
39
+ const prefsPath = getPrefsPath();
40
+ const configDir = path.dirname(prefsPath);
41
+ try {
42
+ fs.mkdirSync(configDir, { recursive: true });
43
+ fs.writeFileSync(prefsPath, JSON.stringify(prefs, null, 2), 'utf-8');
44
+ }
45
+ catch (err) {
46
+ // Silently fail - telemetry shouldn't break the app
47
+ console.error('[telemetry] Failed to save preferences:', err);
48
+ }
49
+ }
50
+ export function isDisabledByEnv() {
51
+ const envValue = process.env.AGENT_RELAY_TELEMETRY_DISABLED;
52
+ return envValue === '1' || envValue === 'true';
53
+ }
54
+ /**
55
+ * Check if telemetry is enabled.
56
+ * Order of precedence:
57
+ * 1. AGENT_RELAY_TELEMETRY_DISABLED=1 -> disabled
58
+ * 2. ~/.agent-relay/telemetry.json -> use stored pref
59
+ * 3. Default -> enabled
60
+ */
61
+ export function isTelemetryEnabled() {
62
+ if (isDisabledByEnv()) {
63
+ return false;
64
+ }
65
+ return loadPrefs().enabled;
66
+ }
67
+ export function enableTelemetry() {
68
+ const prefs = loadPrefs();
69
+ prefs.enabled = true;
70
+ savePrefs(prefs);
71
+ }
72
+ export function disableTelemetry() {
73
+ const prefs = loadPrefs();
74
+ prefs.enabled = false;
75
+ savePrefs(prefs);
76
+ }
77
+ export function markNotified() {
78
+ const prefs = loadPrefs();
79
+ prefs.notifiedAt = new Date().toISOString();
80
+ savePrefs(prefs);
81
+ }
82
+ export function wasNotified() {
83
+ return loadPrefs().notifiedAt !== undefined;
84
+ }
85
+ export function getAnonymousId() {
86
+ return loadPrefs().anonymousId;
87
+ }
88
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Type-safe telemetry event definitions.
3
+ *
4
+ * Following PostHog naming best practices:
5
+ * - snake_case for events and properties
6
+ * - Present tense verbs (spawn, not spawned)
7
+ * - object_action pattern
8
+ */
9
+ /** Source of spawn/release action */
10
+ export type ActionSource = 'human_cli' | 'human_dashboard' | 'agent' | 'protocol';
11
+ /** Reason for agent release */
12
+ export type ReleaseReason = 'explicit' | 'crash' | 'timeout' | 'shutdown';
13
+ /**
14
+ * Common properties attached to every event.
15
+ */
16
+ export interface CommonProperties {
17
+ /** Agent Relay version */
18
+ agent_relay_version: string;
19
+ /** Operating system (e.g., darwin, linux, win32) */
20
+ os: string;
21
+ /** OS release version */
22
+ os_version: string;
23
+ /** Node.js version (without 'v' prefix) */
24
+ node_version: string;
25
+ /** CPU architecture (e.g., arm64, x64) */
26
+ arch: string;
27
+ }
28
+ /**
29
+ * daemon_start - Emitted when the daemon starts.
30
+ * No additional properties beyond common props.
31
+ */
32
+ export interface DaemonStartEvent {
33
+ }
34
+ /**
35
+ * daemon_stop - Emitted when the daemon stops.
36
+ */
37
+ export interface DaemonStopEvent {
38
+ /** How long the daemon was running, in seconds */
39
+ uptime_seconds: number;
40
+ /** Total agents spawned during this session */
41
+ agent_spawn_count: number;
42
+ }
43
+ /**
44
+ * agent_spawn - Emitted when an agent is created.
45
+ */
46
+ export interface AgentSpawnEvent {
47
+ /** CLI type (claude, codex, gemini, etc.) */
48
+ cli: string;
49
+ /** Where the spawn originated */
50
+ spawn_source: ActionSource;
51
+ /** Whether a task was provided */
52
+ has_task: boolean;
53
+ /** Whether this is a shadow agent */
54
+ is_shadow: boolean;
55
+ }
56
+ /**
57
+ * agent_release - Emitted when an agent is stopped.
58
+ */
59
+ export interface AgentReleaseEvent {
60
+ /** CLI type (claude, codex, gemini, etc.) */
61
+ cli: string;
62
+ /** Why the agent was released */
63
+ release_reason: ReleaseReason;
64
+ /** How long the agent was alive, in seconds */
65
+ lifetime_seconds: number;
66
+ /** Where the release originated */
67
+ release_source: ActionSource;
68
+ }
69
+ /**
70
+ * agent_crash - Emitted when an agent dies unexpectedly.
71
+ */
72
+ export interface AgentCrashEvent {
73
+ /** CLI type (claude, codex, gemini, etc.) */
74
+ cli: string;
75
+ /** How long the agent was alive, in seconds */
76
+ lifetime_seconds: number;
77
+ /** Exit code if available */
78
+ exit_code?: number;
79
+ }
80
+ /**
81
+ * message_send - Emitted when an agent sends a relay message.
82
+ */
83
+ export interface MessageSendEvent {
84
+ /** Whether this was a broadcast message */
85
+ is_broadcast: boolean;
86
+ /** Whether this message is part of a thread */
87
+ has_thread: boolean;
88
+ }
89
+ /**
90
+ * cli_command_run - Emitted when a CLI command is executed.
91
+ */
92
+ export interface CliCommandRunEvent {
93
+ /** Name of the command (e.g., 'up', 'spawn', 'who') */
94
+ command_name: string;
95
+ }
96
+ export type TelemetryEventName = 'daemon_start' | 'daemon_stop' | 'agent_spawn' | 'agent_release' | 'agent_crash' | 'message_send' | 'cli_command_run';
97
+ export interface TelemetryEventMap {
98
+ daemon_start: DaemonStartEvent;
99
+ daemon_stop: DaemonStopEvent;
100
+ agent_spawn: AgentSpawnEvent;
101
+ agent_release: AgentReleaseEvent;
102
+ agent_crash: AgentCrashEvent;
103
+ message_send: MessageSendEvent;
104
+ cli_command_run: CliCommandRunEvent;
105
+ }
106
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Type-safe telemetry event definitions.
3
+ *
4
+ * Following PostHog naming best practices:
5
+ * - snake_case for events and properties
6
+ * - Present tense verbs (spawn, not spawned)
7
+ * - object_action pattern
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @agent-relay/telemetry - Anonymous usage analytics (opt-out via env or CLI)
3
+ */
4
+ export { initTelemetry, track, shutdown, isEnabled, getAnonymousId, getStatus, } from './client.js';
5
+ export { isTelemetryEnabled, enableTelemetry, disableTelemetry, wasNotified, markNotified, loadPrefs, savePrefs, getPrefsPath, isDisabledByEnv, type TelemetryPrefs, } from './config.js';
6
+ export type { CommonProperties, ActionSource, ReleaseReason, DaemonStartEvent, DaemonStopEvent, AgentSpawnEvent, AgentReleaseEvent, AgentCrashEvent, MessageSendEvent, CliCommandRunEvent, TelemetryEventName, TelemetryEventMap, } from './events.js';
7
+ export { loadMachineId, createAnonymousId, getMachineIdPath, } from './machine-id.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @agent-relay/telemetry - Anonymous usage analytics (opt-out via env or CLI)
3
+ */
4
+ export { initTelemetry, track, shutdown, isEnabled, getAnonymousId, getStatus, } from './client.js';
5
+ export { isTelemetryEnabled, enableTelemetry, disableTelemetry, wasNotified, markNotified, loadPrefs, savePrefs, getPrefsPath, isDisabledByEnv, } from './config.js';
6
+ export { loadMachineId, createAnonymousId, getMachineIdPath, } from './machine-id.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Machine ID utilities for anonymous user identification.
3
+ * Uses existing machine-id file at ~/.local/share/agent-relay/machine-id
4
+ */
5
+ export declare function getMachineIdPath(): string;
6
+ /**
7
+ * Load or generate machine ID using atomic file creation to avoid race conditions.
8
+ */
9
+ export declare function loadMachineId(): string;
10
+ /** SHA256 hash of machine ID, truncated to 16 chars */
11
+ export declare function createAnonymousId(): string;
12
+ //# sourceMappingURL=machine-id.d.ts.map
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Machine ID utilities for anonymous user identification.
3
+ * Uses existing machine-id file at ~/.local/share/agent-relay/machine-id
4
+ */
5
+ import { createHash, randomBytes } from 'node:crypto';
6
+ import fs from 'node:fs';
7
+ import path from 'node:path';
8
+ import os from 'node:os';
9
+ export function getMachineIdPath() {
10
+ const dataDir = process.env.AGENT_RELAY_DATA_DIR ||
11
+ path.join(os.homedir(), '.local', 'share', 'agent-relay');
12
+ return path.join(dataDir, 'machine-id');
13
+ }
14
+ /**
15
+ * Load or generate machine ID using atomic file creation to avoid race conditions.
16
+ */
17
+ export function loadMachineId() {
18
+ const machineIdPath = getMachineIdPath();
19
+ try {
20
+ return fs.readFileSync(machineIdPath, 'utf-8').trim();
21
+ }
22
+ catch (readErr) {
23
+ if (readErr.code !== 'ENOENT') {
24
+ return `${os.hostname()}-${Date.now().toString(36)}`;
25
+ }
26
+ try {
27
+ const dataDir = path.dirname(machineIdPath);
28
+ fs.mkdirSync(dataDir, { recursive: true });
29
+ const machineId = `${os.hostname()}-${randomBytes(8).toString('hex')}`;
30
+ // O_CREAT | O_EXCL fails if file exists - prevents race condition
31
+ const fd = fs.openSync(machineIdPath, fs.constants.O_CREAT | fs.constants.O_EXCL | fs.constants.O_WRONLY, 0o600);
32
+ fs.writeSync(fd, machineId);
33
+ fs.closeSync(fd);
34
+ return machineId;
35
+ }
36
+ catch (writeErr) {
37
+ // Another process created the file first
38
+ if (writeErr.code === 'EEXIST') {
39
+ try {
40
+ return fs.readFileSync(machineIdPath, 'utf-8').trim();
41
+ }
42
+ catch {
43
+ // Fall through
44
+ }
45
+ }
46
+ return `${os.hostname()}-${Date.now().toString(36)}`;
47
+ }
48
+ }
49
+ }
50
+ /** SHA256 hash of machine ID, truncated to 16 chars */
51
+ export function createAnonymousId() {
52
+ const machineId = loadMachineId();
53
+ return createHash('sha256')
54
+ .update(machineId)
55
+ .digest('hex')
56
+ .substring(0, 16);
57
+ }
58
+ //# sourceMappingURL=machine-id.js.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * PostHog configuration.
3
+ *
4
+ * Environment variables:
5
+ * POSTHOG_API_KEY - Override API key (any environment)
6
+ * POSTHOG_HOST - Override host URL
7
+ *
8
+ * Key selection:
9
+ * 1. POSTHOG_API_KEY (if set, always used)
10
+ * 3. PROD_API_KEY (fallback)
11
+ */
12
+ export declare function getPostHogConfig(): {
13
+ apiKey: string;
14
+ host: string;
15
+ } | null;
16
+ //# sourceMappingURL=posthog-config.d.ts.map
@@ -0,0 +1,33 @@
1
+ /**
2
+ * PostHog configuration.
3
+ *
4
+ * Environment variables:
5
+ * POSTHOG_API_KEY - Override API key (any environment)
6
+ * POSTHOG_HOST - Override host URL
7
+ *
8
+ * Key selection:
9
+ * 1. POSTHOG_API_KEY (if set, always used)
10
+ * 3. PROD_API_KEY (fallback)
11
+ */
12
+ // =============================================================================
13
+ // Configure your PostHog production key here
14
+ // =============================================================================
15
+ /** Production PostHog API key (write-only, safe for client-side) */
16
+ const PROD_API_KEY = 'phc_2uDu01GtnLABJpVkWw4ri1OgScLU90aEmXmDjufGdqr';
17
+ const HOST = 'https://us.i.posthog.com';
18
+ // =============================================================================
19
+ // Exports
20
+ // =============================================================================
21
+ export function getPostHogConfig() {
22
+ const host = process.env.POSTHOG_HOST || HOST;
23
+ // Explicit override for any environment
24
+ if (process.env.POSTHOG_API_KEY) {
25
+ return { apiKey: process.env.POSTHOG_API_KEY, host };
26
+ }
27
+ // Fallback to production key
28
+ if (!PROD_API_KEY) {
29
+ return null;
30
+ }
31
+ return { apiKey: PROD_API_KEY, host };
32
+ }
33
+ //# sourceMappingURL=posthog-config.js.map
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@agent-relay/telemetry",
3
+ "version": "2.0.5",
4
+ "description": "Anonymous telemetry for Agent Relay usage analytics",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsc",
21
+ "clean": "rm -rf dist",
22
+ "test": "vitest run",
23
+ "test:watch": "vitest"
24
+ },
25
+ "dependencies": {
26
+ "posthog-node": "^4.0.1"
27
+ },
28
+ "devDependencies": {
29
+ "@types/node": "^22.19.3",
30
+ "typescript": "^5.9.3",
31
+ "vitest": "^3.0.0"
32
+ },
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/AgentWorkforce/relay.git",
39
+ "directory": "packages/telemetry"
40
+ }
41
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-relay/trajectory",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "Trajectory integration utilities (trail/PDERO) for Relay",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -22,7 +22,7 @@
22
22
  "test:watch": "vitest"
23
23
  },
24
24
  "dependencies": {
25
- "@agent-relay/config": "2.0.4"
25
+ "@agent-relay/config": "2.0.5"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "^22.19.3",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-relay/user-directory",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "User directory service for agent-relay (per-user credential storage)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -22,7 +22,7 @@
22
22
  "test:watch": "vitest"
23
23
  },
24
24
  "dependencies": {
25
- "@agent-relay/resiliency": "2.0.4"
25
+ "@agent-relay/resiliency": "2.0.5"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "^22.19.3",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-relay/utils",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "Shared utilities for agent-relay: logging, name generation, command resolution, update checking",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -73,7 +73,7 @@ export class RelayPtyOrchestrator extends BaseWrapper {
73
73
  hasReceivedOutput = false;
74
74
  // Queue monitor for stuck message detection
75
75
  queueMonitorTimer;
76
- QUEUE_MONITOR_INTERVAL_MS = 30000; // Check every 30 seconds
76
+ QUEUE_MONITOR_INTERVAL_MS = 5000; // Check every 5 seconds
77
77
  injectionStartTime = 0; // Track when isInjecting was set to true
78
78
  MAX_INJECTION_STUCK_MS = 60000; // Force reset after 60 seconds
79
79
  // Protocol monitor for detecting agent mistakes (e.g., empty AGENT_RELAY_NAME)
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-relay/wrapper",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "CLI agent wrappers for Agent Relay - tmux, pty integration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -30,11 +30,11 @@
30
30
  "clean": "rm -rf dist"
31
31
  },
32
32
  "dependencies": {
33
- "@agent-relay/api-types": "2.0.4",
34
- "@agent-relay/protocol": "2.0.4",
35
- "@agent-relay/config": "2.0.4",
36
- "@agent-relay/continuity": "2.0.4",
37
- "@agent-relay/resiliency": "2.0.4"
33
+ "@agent-relay/api-types": "2.0.5",
34
+ "@agent-relay/protocol": "2.0.5",
35
+ "@agent-relay/config": "2.0.5",
36
+ "@agent-relay/continuity": "2.0.5",
37
+ "@agent-relay/resiliency": "2.0.5"
38
38
  },
39
39
  "devDependencies": {
40
40
  "typescript": "^5.9.3",
@@ -1,29 +0,0 @@
1
- /**
2
- * Socket Discovery for Agent Relay SDK
3
- *
4
- * Discovers the daemon socket path for local development and cloud environments.
5
- */
6
- export interface DiscoveryResult {
7
- socketPath: string;
8
- projectId: string;
9
- source: 'env' | 'cloud' | 'project' | 'legacy';
10
- }
11
- /**
12
- * Discover the relay daemon socket path.
13
- *
14
- * Discovery order:
15
- * 1. RELAY_SOCKET environment variable (explicit override)
16
- * 2. Cloud workspace socket (if WORKSPACE_ID is set)
17
- * 3. Project-local socket ({projectRoot}/.agent-relay/relay.sock)
18
- * 4. Legacy fallback (/tmp/agent-relay.sock)
19
- *
20
- * @param cwd - Working directory to start search from (default: process.cwd())
21
- * @returns Discovery result with socket path and metadata
22
- */
23
- export declare function discoverSocket(cwd?: string): DiscoveryResult;
24
- /**
25
- * Get the default socket path using discovery.
26
- * Convenience function that returns just the path.
27
- */
28
- export declare function getDefaultSocketPath(cwd?: string): string;
29
- //# sourceMappingURL=discovery.d.ts.map