agent-relay 2.0.23 → 2.0.24

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 (168) hide show
  1. package/dist/src/cli/index.js +66 -13
  2. package/package.json +18 -52
  3. package/packages/api-types/package.json +1 -1
  4. package/packages/bridge/package.json +8 -8
  5. package/packages/cli-tester/package.json +1 -1
  6. package/packages/config/package.json +2 -2
  7. package/packages/continuity/package.json +1 -1
  8. package/packages/daemon/package.json +12 -12
  9. package/packages/hooks/package.json +4 -4
  10. package/packages/mcp/package.json +2 -2
  11. package/packages/memory/package.json +2 -2
  12. package/packages/policy/package.json +2 -2
  13. package/packages/protocol/package.json +1 -1
  14. package/packages/resiliency/package.json +1 -1
  15. package/packages/sdk/package.json +2 -2
  16. package/packages/spawner/package.json +1 -1
  17. package/packages/state/package.json +1 -1
  18. package/packages/storage/package.json +2 -2
  19. package/packages/telemetry/package.json +1 -1
  20. package/packages/trajectory/package.json +2 -2
  21. package/packages/user-directory/package.json +2 -2
  22. package/packages/utils/package.json +1 -1
  23. package/packages/wrapper/package.json +6 -6
  24. package/deploy/init-db.sql +0 -5
  25. package/deploy/scripts/setup-fly-workspaces.sh +0 -69
  26. package/deploy/scripts/setup-railway.sh +0 -75
  27. package/dist/src/cloud/index.d.ts +0 -8
  28. package/dist/src/cloud/index.js +0 -8
  29. package/packages/cloud/dist/api/admin.d.ts +0 -8
  30. package/packages/cloud/dist/api/admin.js +0 -225
  31. package/packages/cloud/dist/api/auth.d.ts +0 -20
  32. package/packages/cloud/dist/api/auth.js +0 -138
  33. package/packages/cloud/dist/api/billing.d.ts +0 -7
  34. package/packages/cloud/dist/api/billing.js +0 -564
  35. package/packages/cloud/dist/api/cli-pty-runner.d.ts +0 -53
  36. package/packages/cloud/dist/api/cli-pty-runner.js +0 -175
  37. package/packages/cloud/dist/api/codex-auth-helper.d.ts +0 -21
  38. package/packages/cloud/dist/api/codex-auth-helper.js +0 -327
  39. package/packages/cloud/dist/api/consensus.d.ts +0 -13
  40. package/packages/cloud/dist/api/consensus.js +0 -261
  41. package/packages/cloud/dist/api/coordinators.d.ts +0 -8
  42. package/packages/cloud/dist/api/coordinators.js +0 -750
  43. package/packages/cloud/dist/api/daemons.d.ts +0 -12
  44. package/packages/cloud/dist/api/daemons.js +0 -535
  45. package/packages/cloud/dist/api/email-auth.d.ts +0 -11
  46. package/packages/cloud/dist/api/email-auth.js +0 -347
  47. package/packages/cloud/dist/api/generic-webhooks.d.ts +0 -8
  48. package/packages/cloud/dist/api/generic-webhooks.js +0 -129
  49. package/packages/cloud/dist/api/git.d.ts +0 -8
  50. package/packages/cloud/dist/api/git.js +0 -269
  51. package/packages/cloud/dist/api/github-app.d.ts +0 -11
  52. package/packages/cloud/dist/api/github-app.js +0 -223
  53. package/packages/cloud/dist/api/middleware/planLimits.d.ts +0 -43
  54. package/packages/cloud/dist/api/middleware/planLimits.js +0 -202
  55. package/packages/cloud/dist/api/monitoring.d.ts +0 -11
  56. package/packages/cloud/dist/api/monitoring.js +0 -578
  57. package/packages/cloud/dist/api/nango-auth.d.ts +0 -9
  58. package/packages/cloud/dist/api/nango-auth.js +0 -741
  59. package/packages/cloud/dist/api/onboarding.d.ts +0 -15
  60. package/packages/cloud/dist/api/onboarding.js +0 -679
  61. package/packages/cloud/dist/api/policy.d.ts +0 -8
  62. package/packages/cloud/dist/api/policy.js +0 -229
  63. package/packages/cloud/dist/api/provider-env.d.ts +0 -26
  64. package/packages/cloud/dist/api/provider-env.js +0 -141
  65. package/packages/cloud/dist/api/providers.d.ts +0 -7
  66. package/packages/cloud/dist/api/providers.js +0 -574
  67. package/packages/cloud/dist/api/repos.d.ts +0 -8
  68. package/packages/cloud/dist/api/repos.js +0 -577
  69. package/packages/cloud/dist/api/sessions.d.ts +0 -11
  70. package/packages/cloud/dist/api/sessions.js +0 -302
  71. package/packages/cloud/dist/api/teams.d.ts +0 -7
  72. package/packages/cloud/dist/api/teams.js +0 -281
  73. package/packages/cloud/dist/api/test-helpers.d.ts +0 -10
  74. package/packages/cloud/dist/api/test-helpers.js +0 -745
  75. package/packages/cloud/dist/api/usage.d.ts +0 -7
  76. package/packages/cloud/dist/api/usage.js +0 -111
  77. package/packages/cloud/dist/api/webhooks.d.ts +0 -8
  78. package/packages/cloud/dist/api/webhooks.js +0 -645
  79. package/packages/cloud/dist/api/workspaces.d.ts +0 -25
  80. package/packages/cloud/dist/api/workspaces.js +0 -1799
  81. package/packages/cloud/dist/billing/index.d.ts +0 -9
  82. package/packages/cloud/dist/billing/index.js +0 -9
  83. package/packages/cloud/dist/billing/plans.d.ts +0 -39
  84. package/packages/cloud/dist/billing/plans.js +0 -245
  85. package/packages/cloud/dist/billing/service.d.ts +0 -80
  86. package/packages/cloud/dist/billing/service.js +0 -388
  87. package/packages/cloud/dist/billing/types.d.ts +0 -141
  88. package/packages/cloud/dist/billing/types.js +0 -7
  89. package/packages/cloud/dist/config.d.ts +0 -5
  90. package/packages/cloud/dist/config.js +0 -5
  91. package/packages/cloud/dist/db/bulk-ingest.d.ts +0 -89
  92. package/packages/cloud/dist/db/bulk-ingest.js +0 -268
  93. package/packages/cloud/dist/db/drizzle.d.ts +0 -290
  94. package/packages/cloud/dist/db/drizzle.js +0 -1422
  95. package/packages/cloud/dist/db/index.d.ts +0 -56
  96. package/packages/cloud/dist/db/index.js +0 -70
  97. package/packages/cloud/dist/db/schema.d.ts +0 -5117
  98. package/packages/cloud/dist/db/schema.js +0 -656
  99. package/packages/cloud/dist/index.d.ts +0 -11
  100. package/packages/cloud/dist/index.js +0 -38
  101. package/packages/cloud/dist/provisioner/index.d.ts +0 -207
  102. package/packages/cloud/dist/provisioner/index.js +0 -2118
  103. package/packages/cloud/dist/server.d.ts +0 -17
  104. package/packages/cloud/dist/server.js +0 -2055
  105. package/packages/cloud/dist/services/auto-scaler.d.ts +0 -152
  106. package/packages/cloud/dist/services/auto-scaler.js +0 -439
  107. package/packages/cloud/dist/services/capacity-manager.d.ts +0 -148
  108. package/packages/cloud/dist/services/capacity-manager.js +0 -449
  109. package/packages/cloud/dist/services/ci-agent-spawner.d.ts +0 -49
  110. package/packages/cloud/dist/services/ci-agent-spawner.js +0 -373
  111. package/packages/cloud/dist/services/cloud-message-bus.d.ts +0 -28
  112. package/packages/cloud/dist/services/cloud-message-bus.js +0 -19
  113. package/packages/cloud/dist/services/compute-enforcement.d.ts +0 -57
  114. package/packages/cloud/dist/services/compute-enforcement.js +0 -175
  115. package/packages/cloud/dist/services/coordinator.d.ts +0 -62
  116. package/packages/cloud/dist/services/coordinator.js +0 -389
  117. package/packages/cloud/dist/services/index.d.ts +0 -17
  118. package/packages/cloud/dist/services/index.js +0 -25
  119. package/packages/cloud/dist/services/intro-expiration.d.ts +0 -60
  120. package/packages/cloud/dist/services/intro-expiration.js +0 -252
  121. package/packages/cloud/dist/services/mention-handler.d.ts +0 -65
  122. package/packages/cloud/dist/services/mention-handler.js +0 -405
  123. package/packages/cloud/dist/services/nango.d.ts +0 -219
  124. package/packages/cloud/dist/services/nango.js +0 -424
  125. package/packages/cloud/dist/services/persistence.d.ts +0 -131
  126. package/packages/cloud/dist/services/persistence.js +0 -200
  127. package/packages/cloud/dist/services/planLimits.d.ts +0 -147
  128. package/packages/cloud/dist/services/planLimits.js +0 -335
  129. package/packages/cloud/dist/services/presence-registry.d.ts +0 -56
  130. package/packages/cloud/dist/services/presence-registry.js +0 -91
  131. package/packages/cloud/dist/services/scaling-orchestrator.d.ts +0 -159
  132. package/packages/cloud/dist/services/scaling-orchestrator.js +0 -502
  133. package/packages/cloud/dist/services/scaling-policy.d.ts +0 -121
  134. package/packages/cloud/dist/services/scaling-policy.js +0 -415
  135. package/packages/cloud/dist/services/ssh-security.d.ts +0 -31
  136. package/packages/cloud/dist/services/ssh-security.js +0 -63
  137. package/packages/cloud/dist/services/workspace-keepalive.d.ts +0 -76
  138. package/packages/cloud/dist/services/workspace-keepalive.js +0 -234
  139. package/packages/cloud/dist/shims/consensus.d.ts +0 -23
  140. package/packages/cloud/dist/shims/consensus.js +0 -5
  141. package/packages/cloud/dist/webhooks/index.d.ts +0 -24
  142. package/packages/cloud/dist/webhooks/index.js +0 -29
  143. package/packages/cloud/dist/webhooks/parsers/github.d.ts +0 -8
  144. package/packages/cloud/dist/webhooks/parsers/github.js +0 -234
  145. package/packages/cloud/dist/webhooks/parsers/index.d.ts +0 -23
  146. package/packages/cloud/dist/webhooks/parsers/index.js +0 -30
  147. package/packages/cloud/dist/webhooks/parsers/linear.d.ts +0 -9
  148. package/packages/cloud/dist/webhooks/parsers/linear.js +0 -258
  149. package/packages/cloud/dist/webhooks/parsers/slack.d.ts +0 -9
  150. package/packages/cloud/dist/webhooks/parsers/slack.js +0 -214
  151. package/packages/cloud/dist/webhooks/responders/github.d.ts +0 -8
  152. package/packages/cloud/dist/webhooks/responders/github.js +0 -73
  153. package/packages/cloud/dist/webhooks/responders/index.d.ts +0 -23
  154. package/packages/cloud/dist/webhooks/responders/index.js +0 -30
  155. package/packages/cloud/dist/webhooks/responders/linear.d.ts +0 -9
  156. package/packages/cloud/dist/webhooks/responders/linear.js +0 -149
  157. package/packages/cloud/dist/webhooks/responders/slack.d.ts +0 -20
  158. package/packages/cloud/dist/webhooks/responders/slack.js +0 -178
  159. package/packages/cloud/dist/webhooks/router.d.ts +0 -25
  160. package/packages/cloud/dist/webhooks/router.js +0 -504
  161. package/packages/cloud/dist/webhooks/rules-engine.d.ts +0 -24
  162. package/packages/cloud/dist/webhooks/rules-engine.js +0 -287
  163. package/packages/cloud/dist/webhooks/types.d.ts +0 -186
  164. package/packages/cloud/dist/webhooks/types.js +0 -8
  165. package/packages/cloud/package.json +0 -60
  166. package/scripts/run-migrations.js +0 -43
  167. package/scripts/setup-stripe-products.ts +0 -312
  168. package/scripts/verify-schema.js +0 -134
@@ -1,56 +0,0 @@
1
- /**
2
- * Presence Registry - Shared registry for tracking online users across cloud server.
3
- *
4
- * This singleton module allows both the WebSocket handler in server.ts and the
5
- * daemons API routes to access the current list of online users.
6
- */
7
- export interface PresenceUserInfo {
8
- username: string;
9
- avatarUrl?: string;
10
- connectedAt: string;
11
- lastSeen: string;
12
- /** Optional workspace context for the user */
13
- workspaceId?: string;
14
- }
15
- /**
16
- * Register a user connection
17
- */
18
- export declare function registerUserPresence(info: PresenceUserInfo): void;
19
- /**
20
- * Update last seen time for a user
21
- */
22
- export declare function updateUserLastSeen(username: string): void;
23
- /**
24
- * Unregister a user connection
25
- */
26
- export declare function unregisterUserPresence(username: string): void;
27
- /**
28
- * Check if a user is online
29
- */
30
- export declare function isUserOnline(username: string): boolean;
31
- /**
32
- * Get info for a specific online user
33
- */
34
- export declare function getOnlineUser(username: string): PresenceUserInfo | undefined;
35
- /**
36
- * Get list of all online users
37
- */
38
- export declare function getOnlineUsers(): PresenceUserInfo[];
39
- /**
40
- * Get online users formatted for remote agent discovery.
41
- * Returns in the same format as RemoteAgent so daemons can route to users.
42
- */
43
- export declare function getOnlineUsersForDiscovery(): Array<{
44
- name: string;
45
- status: string;
46
- daemonId: string;
47
- daemonName: string;
48
- machineId: string;
49
- isHuman: boolean;
50
- avatarUrl?: string;
51
- }>;
52
- /**
53
- * Clear all presence (for testing or shutdown)
54
- */
55
- export declare function clearAllPresence(): void;
56
- //# sourceMappingURL=presence-registry.d.ts.map
@@ -1,91 +0,0 @@
1
- /**
2
- * Presence Registry - Shared registry for tracking online users across cloud server.
3
- *
4
- * This singleton module allows both the WebSocket handler in server.ts and the
5
- * daemons API routes to access the current list of online users.
6
- */
7
- /**
8
- * In-memory registry of online users.
9
- * Key: username
10
- * Value: presence state with connection count
11
- */
12
- const onlineUsers = new Map();
13
- /**
14
- * Register a user connection
15
- */
16
- export function registerUserPresence(info) {
17
- const existing = onlineUsers.get(info.username);
18
- if (existing) {
19
- // Update info and increment connection count
20
- existing.info = { ...existing.info, ...info, lastSeen: new Date().toISOString() };
21
- existing.connectionCount++;
22
- }
23
- else {
24
- onlineUsers.set(info.username, {
25
- info: { ...info, lastSeen: new Date().toISOString() },
26
- connectionCount: 1,
27
- });
28
- }
29
- }
30
- /**
31
- * Update last seen time for a user
32
- */
33
- export function updateUserLastSeen(username) {
34
- const state = onlineUsers.get(username);
35
- if (state) {
36
- state.info.lastSeen = new Date().toISOString();
37
- }
38
- }
39
- /**
40
- * Unregister a user connection
41
- */
42
- export function unregisterUserPresence(username) {
43
- const state = onlineUsers.get(username);
44
- if (state) {
45
- state.connectionCount--;
46
- if (state.connectionCount <= 0) {
47
- onlineUsers.delete(username);
48
- }
49
- }
50
- }
51
- /**
52
- * Check if a user is online
53
- */
54
- export function isUserOnline(username) {
55
- return onlineUsers.has(username);
56
- }
57
- /**
58
- * Get info for a specific online user
59
- */
60
- export function getOnlineUser(username) {
61
- return onlineUsers.get(username)?.info;
62
- }
63
- /**
64
- * Get list of all online users
65
- */
66
- export function getOnlineUsers() {
67
- return Array.from(onlineUsers.values()).map((state) => state.info);
68
- }
69
- /**
70
- * Get online users formatted for remote agent discovery.
71
- * Returns in the same format as RemoteAgent so daemons can route to users.
72
- */
73
- export function getOnlineUsersForDiscovery() {
74
- return getOnlineUsers().map((user) => ({
75
- name: user.username,
76
- status: 'online',
77
- // Use special "cloud" identifier so daemon knows to route via cloud
78
- daemonId: 'cloud',
79
- daemonName: 'Cloud Dashboard',
80
- machineId: 'cloud',
81
- isHuman: true,
82
- avatarUrl: user.avatarUrl,
83
- }));
84
- }
85
- /**
86
- * Clear all presence (for testing or shutdown)
87
- */
88
- export function clearAllPresence() {
89
- onlineUsers.clear();
90
- }
91
- //# sourceMappingURL=presence-registry.js.map
@@ -1,159 +0,0 @@
1
- /**
2
- * Scaling Orchestrator
3
- *
4
- * Main integration layer that connects:
5
- * - AutoScaler (policy evaluation and scaling decisions)
6
- * - CapacityManager (workspace capacity tracking)
7
- * - WorkspaceProvisioner (actual instance provisioning)
8
- * - Monitoring (memory/CPU metrics from agents)
9
- *
10
- * Handles the complete scaling lifecycle:
11
- * 1. Receives metrics from monitoring
12
- * 2. Updates capacity manager
13
- * 3. Triggers auto-scaler evaluation
14
- * 4. Executes scaling via provisioner
15
- * 5. Updates capacity after scaling
16
- */
17
- import { EventEmitter } from 'events';
18
- import { ScalingOperation } from './auto-scaler.js';
19
- import { CapacityForecast } from './capacity-manager.js';
20
- import { ScalingDecision, WorkspaceMetrics } from './scaling-policy.js';
21
- import { ProvisionResult } from '../provisioner/index.js';
22
- export interface ScalingEvent {
23
- type: 'scale_up' | 'scale_down' | 'resize_up' | 'resize_down' | 'increase_agent_limit' | 'migrate_agents' | 'rebalance' | 'alert';
24
- userId: string;
25
- workspaceId?: string;
26
- decision?: ScalingDecision;
27
- operation?: ScalingOperation;
28
- result?: ProvisionResult;
29
- previousTier?: string;
30
- newTier?: string;
31
- previousAgentLimit?: number;
32
- newAgentLimit?: number;
33
- error?: string;
34
- timestamp: Date;
35
- }
36
- export interface OrchestratorConfig {
37
- enabled: boolean;
38
- redisUrl?: string;
39
- autoProvision: boolean;
40
- autoDeprovision: boolean;
41
- idleTimeoutMs: number;
42
- minUserWorkspaces: number;
43
- }
44
- export declare class ScalingOrchestrator extends EventEmitter {
45
- private config;
46
- private autoScaler;
47
- private capacityManager;
48
- private provisioner;
49
- private initialized;
50
- private scalingHistory;
51
- private maxHistorySize;
52
- constructor(config?: Partial<OrchestratorConfig>);
53
- /**
54
- * Initialize the orchestrator with Redis for cross-server coordination
55
- */
56
- initialize(redisUrl?: string): Promise<void>;
57
- /**
58
- * Set up event handlers between components
59
- */
60
- private setupEventHandlers;
61
- /**
62
- * Check if scaling is needed for a user
63
- */
64
- private checkScalingNeeded;
65
- /**
66
- * Execute a scaling operation
67
- */
68
- private executeScaling;
69
- /**
70
- * Handle scale up - provision new workspace
71
- */
72
- private handleScaleUp;
73
- /**
74
- * Handle scale down - deprovision workspace
75
- */
76
- private handleScaleDown;
77
- /**
78
- * Handle rebalance - redistribute agents across workspaces
79
- */
80
- private handleRebalance;
81
- /**
82
- * Handle resize - vertical scaling (increase/decrease workspace resources)
83
- */
84
- private handleResize;
85
- /**
86
- * Handle agent limit increase within a workspace
87
- */
88
- private handleAgentLimitIncrease;
89
- /**
90
- * Handle agent migration between workspaces
91
- */
92
- private handleMigrateAgents;
93
- /**
94
- * Record a scaling event in history
95
- */
96
- private recordEvent;
97
- /**
98
- * Persist scaling event to database
99
- */
100
- private persistScalingEvent;
101
- /**
102
- * Report metrics from monitoring service
103
- * This is the main entry point for metrics from agents
104
- */
105
- reportMetrics(userId: string, workspaces: WorkspaceMetrics[]): Promise<void>;
106
- /**
107
- * Manually trigger scaling evaluation for a user
108
- */
109
- evaluateScaling(userId: string): Promise<ScalingDecision | null>;
110
- /**
111
- * Get capacity forecast for a user
112
- */
113
- getCapacityForecast(userId: string): CapacityForecast | null;
114
- /**
115
- * Get best placement for new agents
116
- */
117
- recommendPlacement(userId: string, agentCount?: number): import("./capacity-manager.js").PlacementRecommendation[];
118
- /**
119
- * Get scaling history for a user
120
- */
121
- getScalingHistory(userId?: string): ScalingEvent[];
122
- /**
123
- * Get current status of the orchestrator
124
- */
125
- getStatus(): {
126
- initialized: boolean;
127
- autoScaler: {
128
- enabled: boolean;
129
- isLeader: boolean;
130
- serverId: string;
131
- pendingOperations: number;
132
- cachedUsers: number;
133
- };
134
- capacity: {
135
- totalWorkspaces: number;
136
- totalAgents: number;
137
- totalMaxAgents: number;
138
- averageUtilization: number;
139
- staleWorkspaces: number;
140
- };
141
- config: {
142
- autoProvision: boolean;
143
- autoDeprovision: boolean;
144
- minUserWorkspaces: number;
145
- };
146
- historySize: number;
147
- };
148
- /**
149
- * Update user's plan tier
150
- */
151
- setUserPlan(userId: string, plan: 'free' | 'pro' | 'team' | 'enterprise'): Promise<void>;
152
- /**
153
- * Clean shutdown
154
- */
155
- shutdown(): Promise<void>;
156
- }
157
- export declare function getScalingOrchestrator(): ScalingOrchestrator;
158
- export declare function createScalingOrchestrator(config?: Partial<OrchestratorConfig>): ScalingOrchestrator;
159
- //# sourceMappingURL=scaling-orchestrator.d.ts.map