@orkify/cli 1.0.0-beta.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.
- package/LICENSE +191 -0
- package/README.md +1701 -0
- package/bin/orkify +3 -0
- package/boot/systemd/orkify@.service +30 -0
- package/dist/agent-name.d.ts +4 -0
- package/dist/agent-name.js +42 -0
- package/dist/alerts/AlertEvaluator.d.ts +14 -0
- package/dist/alerts/AlertEvaluator.js +135 -0
- package/dist/cli/commands/autostart.d.ts +3 -0
- package/dist/cli/commands/autostart.js +11 -0
- package/dist/cli/commands/crash-test.d.ts +3 -0
- package/dist/cli/commands/crash-test.js +17 -0
- package/dist/cli/commands/daemon-reload.d.ts +3 -0
- package/dist/cli/commands/daemon-reload.js +72 -0
- package/dist/cli/commands/delete.d.ts +3 -0
- package/dist/cli/commands/delete.js +37 -0
- package/dist/cli/commands/deploy.d.ts +6 -0
- package/dist/cli/commands/deploy.js +266 -0
- package/dist/cli/commands/down.d.ts +3 -0
- package/dist/cli/commands/down.js +36 -0
- package/dist/cli/commands/flush.d.ts +3 -0
- package/dist/cli/commands/flush.js +28 -0
- package/dist/cli/commands/kill.d.ts +3 -0
- package/dist/cli/commands/kill.js +35 -0
- package/dist/cli/commands/list.d.ts +14 -0
- package/dist/cli/commands/list.js +361 -0
- package/dist/cli/commands/logs.d.ts +3 -0
- package/dist/cli/commands/logs.js +107 -0
- package/dist/cli/commands/mcp.d.ts +3 -0
- package/dist/cli/commands/mcp.js +151 -0
- package/dist/cli/commands/reload.d.ts +3 -0
- package/dist/cli/commands/reload.js +54 -0
- package/dist/cli/commands/restart.d.ts +3 -0
- package/dist/cli/commands/restart.js +43 -0
- package/dist/cli/commands/restore.d.ts +3 -0
- package/dist/cli/commands/restore.js +88 -0
- package/dist/cli/commands/run.d.ts +8 -0
- package/dist/cli/commands/run.js +212 -0
- package/dist/cli/commands/snap.d.ts +3 -0
- package/dist/cli/commands/snap.js +30 -0
- package/dist/cli/commands/up.d.ts +3 -0
- package/dist/cli/commands/up.js +125 -0
- package/dist/cli/crash-recovery.d.ts +2 -0
- package/dist/cli/crash-recovery.js +67 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.js +46 -0
- package/dist/cli/parse.d.ts +28 -0
- package/dist/cli/parse.js +97 -0
- package/dist/cluster/ClusterWrapper.d.ts +18 -0
- package/dist/cluster/ClusterWrapper.js +602 -0
- package/dist/config/ConfigStore.d.ts +11 -0
- package/dist/config/ConfigStore.js +21 -0
- package/dist/config/schema.d.ts +103 -0
- package/dist/config/schema.js +49 -0
- package/dist/constants.d.ts +83 -0
- package/dist/constants.js +289 -0
- package/dist/cron/CronScheduler.d.ts +25 -0
- package/dist/cron/CronScheduler.js +149 -0
- package/dist/daemon/GracefulManager.d.ts +8 -0
- package/dist/daemon/GracefulManager.js +29 -0
- package/dist/daemon/ManagedProcess.d.ts +71 -0
- package/dist/daemon/ManagedProcess.js +1020 -0
- package/dist/daemon/Orchestrator.d.ts +51 -0
- package/dist/daemon/Orchestrator.js +416 -0
- package/dist/daemon/RotatingWriter.d.ts +27 -0
- package/dist/daemon/RotatingWriter.js +264 -0
- package/dist/daemon/index.d.ts +2 -0
- package/dist/daemon/index.js +106 -0
- package/dist/daemon/startDaemon.d.ts +30 -0
- package/dist/daemon/startDaemon.js +693 -0
- package/dist/deploy/CommandPoller.d.ts +13 -0
- package/dist/deploy/CommandPoller.js +53 -0
- package/dist/deploy/DeployExecutor.d.ts +33 -0
- package/dist/deploy/DeployExecutor.js +340 -0
- package/dist/deploy/config.d.ts +20 -0
- package/dist/deploy/config.js +161 -0
- package/dist/deploy/env.d.ts +2 -0
- package/dist/deploy/env.js +17 -0
- package/dist/deploy/tarball.d.ts +32 -0
- package/dist/deploy/tarball.js +243 -0
- package/dist/detect/framework.d.ts +2 -0
- package/dist/detect/framework.js +24 -0
- package/dist/ipc/DaemonClient.d.ts +31 -0
- package/dist/ipc/DaemonClient.js +248 -0
- package/dist/ipc/DaemonServer.d.ts +28 -0
- package/dist/ipc/DaemonServer.js +166 -0
- package/dist/ipc/MultiUserClient.d.ts +27 -0
- package/dist/ipc/MultiUserClient.js +203 -0
- package/dist/ipc/protocol.d.ts +7 -0
- package/dist/ipc/protocol.js +53 -0
- package/dist/ipc/restoreDaemon.d.ts +8 -0
- package/dist/ipc/restoreDaemon.js +19 -0
- package/dist/machine-id.d.ts +11 -0
- package/dist/machine-id.js +51 -0
- package/dist/mcp/auth.d.ts +118 -0
- package/dist/mcp/auth.js +245 -0
- package/dist/mcp/http.d.ts +20 -0
- package/dist/mcp/http.js +229 -0
- package/dist/mcp/index.d.ts +3 -0
- package/dist/mcp/index.js +8 -0
- package/dist/mcp/server.d.ts +37 -0
- package/dist/mcp/server.js +413 -0
- package/dist/probe/compute-fingerprint.d.ts +27 -0
- package/dist/probe/compute-fingerprint.js +65 -0
- package/dist/probe/parse-frames.d.ts +21 -0
- package/dist/probe/parse-frames.js +57 -0
- package/dist/probe/resolve-sourcemaps.d.ts +25 -0
- package/dist/probe/resolve-sourcemaps.js +281 -0
- package/dist/state/StateStore.d.ts +11 -0
- package/dist/state/StateStore.js +78 -0
- package/dist/telemetry/TelemetryReporter.d.ts +49 -0
- package/dist/telemetry/TelemetryReporter.js +451 -0
- package/dist/types/index.d.ts +373 -0
- package/dist/types/index.js +2 -0
- package/package.json +148 -0
- package/packages/cache/README.md +114 -0
- package/packages/cache/dist/CacheClient.d.ts +26 -0
- package/packages/cache/dist/CacheClient.d.ts.map +1 -0
- package/packages/cache/dist/CacheClient.js +174 -0
- package/packages/cache/dist/CacheClient.js.map +1 -0
- package/packages/cache/dist/CacheFileStore.d.ts +45 -0
- package/packages/cache/dist/CacheFileStore.d.ts.map +1 -0
- package/packages/cache/dist/CacheFileStore.js +446 -0
- package/packages/cache/dist/CacheFileStore.js.map +1 -0
- package/packages/cache/dist/CachePersistence.d.ts +9 -0
- package/packages/cache/dist/CachePersistence.d.ts.map +1 -0
- package/packages/cache/dist/CachePersistence.js +67 -0
- package/packages/cache/dist/CachePersistence.js.map +1 -0
- package/packages/cache/dist/CachePrimary.d.ts +25 -0
- package/packages/cache/dist/CachePrimary.d.ts.map +1 -0
- package/packages/cache/dist/CachePrimary.js +155 -0
- package/packages/cache/dist/CachePrimary.js.map +1 -0
- package/packages/cache/dist/CacheStore.d.ts +50 -0
- package/packages/cache/dist/CacheStore.d.ts.map +1 -0
- package/packages/cache/dist/CacheStore.js +271 -0
- package/packages/cache/dist/CacheStore.js.map +1 -0
- package/packages/cache/dist/constants.d.ts +6 -0
- package/packages/cache/dist/constants.d.ts.map +1 -0
- package/packages/cache/dist/constants.js +9 -0
- package/packages/cache/dist/constants.js.map +1 -0
- package/packages/cache/dist/index.d.ts +16 -0
- package/packages/cache/dist/index.d.ts.map +1 -0
- package/packages/cache/dist/index.js +86 -0
- package/packages/cache/dist/index.js.map +1 -0
- package/packages/cache/dist/serialize.d.ts +9 -0
- package/packages/cache/dist/serialize.d.ts.map +1 -0
- package/packages/cache/dist/serialize.js +40 -0
- package/packages/cache/dist/serialize.js.map +1 -0
- package/packages/cache/dist/types.d.ts +123 -0
- package/packages/cache/dist/types.d.ts.map +1 -0
- package/packages/cache/dist/types.js +2 -0
- package/packages/cache/dist/types.js.map +1 -0
- package/packages/cache/package.json +27 -0
- package/packages/cache/src/CacheClient.ts +227 -0
- package/packages/cache/src/CacheFileStore.ts +528 -0
- package/packages/cache/src/CachePersistence.ts +89 -0
- package/packages/cache/src/CachePrimary.ts +172 -0
- package/packages/cache/src/CacheStore.ts +308 -0
- package/packages/cache/src/constants.ts +10 -0
- package/packages/cache/src/index.ts +100 -0
- package/packages/cache/src/serialize.ts +49 -0
- package/packages/cache/src/types.ts +156 -0
- package/packages/cache/tsconfig.json +18 -0
- package/packages/cache/tsconfig.tsbuildinfo +1 -0
- package/packages/next/README.md +166 -0
- package/packages/next/dist/error-capture.d.ts +34 -0
- package/packages/next/dist/error-capture.d.ts.map +1 -0
- package/packages/next/dist/error-capture.js +130 -0
- package/packages/next/dist/error-capture.js.map +1 -0
- package/packages/next/dist/error-handler.d.ts +10 -0
- package/packages/next/dist/error-handler.d.ts.map +1 -0
- package/packages/next/dist/error-handler.js +186 -0
- package/packages/next/dist/error-handler.js.map +1 -0
- package/packages/next/dist/isr-cache.d.ts +9 -0
- package/packages/next/dist/isr-cache.d.ts.map +1 -0
- package/packages/next/dist/isr-cache.js +86 -0
- package/packages/next/dist/isr-cache.js.map +1 -0
- package/packages/next/dist/stream.d.ts +5 -0
- package/packages/next/dist/stream.d.ts.map +1 -0
- package/packages/next/dist/stream.js +22 -0
- package/packages/next/dist/stream.js.map +1 -0
- package/packages/next/dist/types.d.ts +33 -0
- package/packages/next/dist/types.d.ts.map +1 -0
- package/packages/next/dist/types.js +6 -0
- package/packages/next/dist/types.js.map +1 -0
- package/packages/next/dist/use-cache.d.ts +4 -0
- package/packages/next/dist/use-cache.d.ts.map +1 -0
- package/packages/next/dist/use-cache.js +86 -0
- package/packages/next/dist/use-cache.js.map +1 -0
- package/packages/next/dist/utils.d.ts +32 -0
- package/packages/next/dist/utils.d.ts.map +1 -0
- package/packages/next/dist/utils.js +88 -0
- package/packages/next/dist/utils.js.map +1 -0
- package/packages/next/package.json +52 -0
- package/packages/next/src/error-capture.ts +177 -0
- package/packages/next/src/error-handler.ts +221 -0
- package/packages/next/src/isr-cache.ts +100 -0
- package/packages/next/src/stream.ts +23 -0
- package/packages/next/src/types.ts +33 -0
- package/packages/next/src/use-cache.ts +99 -0
- package/packages/next/src/utils.ts +102 -0
- package/packages/next/tsconfig.json +19 -0
- package/packages/next/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import type { ExecModeType, IPCMessageTypeType, ProcessStatusType } from '../constants.js';
|
|
2
|
+
export interface CronJob {
|
|
3
|
+
schedule: string;
|
|
4
|
+
path: string;
|
|
5
|
+
method?: string;
|
|
6
|
+
timeout?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface ProcessConfig {
|
|
9
|
+
name: string;
|
|
10
|
+
script: string;
|
|
11
|
+
cwd: string;
|
|
12
|
+
workerCount: number;
|
|
13
|
+
execMode: ExecModeType;
|
|
14
|
+
watch: boolean;
|
|
15
|
+
watchPaths?: string[];
|
|
16
|
+
env: Record<string, string>;
|
|
17
|
+
nodeArgs: string[];
|
|
18
|
+
args: string[];
|
|
19
|
+
killTimeout: number;
|
|
20
|
+
maxRestarts: number;
|
|
21
|
+
minUptime: number;
|
|
22
|
+
restartDelay: number;
|
|
23
|
+
sticky: boolean;
|
|
24
|
+
port?: number;
|
|
25
|
+
reloadRetries?: number;
|
|
26
|
+
healthCheck?: string;
|
|
27
|
+
logMaxSize: number;
|
|
28
|
+
logMaxFiles: number;
|
|
29
|
+
logMaxAge: number;
|
|
30
|
+
restartOnMemory?: number;
|
|
31
|
+
cron?: CronJob[];
|
|
32
|
+
framework?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface WorkerInfo {
|
|
35
|
+
id: number;
|
|
36
|
+
pid: number;
|
|
37
|
+
status: ProcessStatusType;
|
|
38
|
+
restarts: number;
|
|
39
|
+
crashes: number;
|
|
40
|
+
uptime: number;
|
|
41
|
+
memory: number;
|
|
42
|
+
cpu: number;
|
|
43
|
+
createdAt: number;
|
|
44
|
+
stale?: boolean;
|
|
45
|
+
heapUsed?: number;
|
|
46
|
+
heapTotal?: number;
|
|
47
|
+
external?: number;
|
|
48
|
+
arrayBuffers?: number;
|
|
49
|
+
eventLoopLag?: number;
|
|
50
|
+
eventLoopLagP95?: number;
|
|
51
|
+
activeHandles?: number;
|
|
52
|
+
cacheSize?: number;
|
|
53
|
+
cacheTotalBytes?: number;
|
|
54
|
+
cacheHits?: number;
|
|
55
|
+
cacheMisses?: number;
|
|
56
|
+
cacheHitRate?: number;
|
|
57
|
+
}
|
|
58
|
+
export interface ProcessInfo {
|
|
59
|
+
id: number;
|
|
60
|
+
name: string;
|
|
61
|
+
script: string;
|
|
62
|
+
cwd: string;
|
|
63
|
+
execMode: ExecModeType;
|
|
64
|
+
workerCount: number;
|
|
65
|
+
status: ProcessStatusType;
|
|
66
|
+
workers: WorkerInfo[];
|
|
67
|
+
pid?: number;
|
|
68
|
+
createdAt: number;
|
|
69
|
+
restartedAt?: number;
|
|
70
|
+
watch: boolean;
|
|
71
|
+
sticky: boolean;
|
|
72
|
+
port?: number;
|
|
73
|
+
}
|
|
74
|
+
export interface IPCMessage {
|
|
75
|
+
type: IPCMessageTypeType;
|
|
76
|
+
id: string;
|
|
77
|
+
payload?: unknown;
|
|
78
|
+
}
|
|
79
|
+
export interface IPCRequest extends IPCMessage {
|
|
80
|
+
payload?: DeployRestorePayload | KillPayload | LogsPayload | McpStartPayload | ProcessConfig[] | RestorePayload | SnapPayload | TargetPayload | TelemetryConfig | UpPayload;
|
|
81
|
+
}
|
|
82
|
+
export interface IPCResponse extends IPCMessage {
|
|
83
|
+
success: boolean;
|
|
84
|
+
data?: unknown;
|
|
85
|
+
error?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface UpPayload {
|
|
88
|
+
script: string;
|
|
89
|
+
name?: string;
|
|
90
|
+
workers?: number;
|
|
91
|
+
watch?: boolean;
|
|
92
|
+
watchPaths?: string[];
|
|
93
|
+
cwd?: string;
|
|
94
|
+
env?: Record<string, string>;
|
|
95
|
+
nodeArgs?: string[];
|
|
96
|
+
args?: string[];
|
|
97
|
+
killTimeout?: number;
|
|
98
|
+
maxRestarts?: number;
|
|
99
|
+
minUptime?: number;
|
|
100
|
+
restartDelay?: number;
|
|
101
|
+
sticky?: boolean;
|
|
102
|
+
port?: number;
|
|
103
|
+
reloadRetries?: number;
|
|
104
|
+
healthCheck?: string;
|
|
105
|
+
logMaxSize?: number;
|
|
106
|
+
logMaxFiles?: number;
|
|
107
|
+
logMaxAge?: number;
|
|
108
|
+
restartOnMemory?: number;
|
|
109
|
+
cron?: CronJob[];
|
|
110
|
+
framework?: string;
|
|
111
|
+
}
|
|
112
|
+
export interface KillPayload {
|
|
113
|
+
force?: boolean;
|
|
114
|
+
}
|
|
115
|
+
export interface TargetPayload {
|
|
116
|
+
target: 'all' | number | string;
|
|
117
|
+
}
|
|
118
|
+
export interface LogsPayload {
|
|
119
|
+
target?: number | string;
|
|
120
|
+
lines?: number;
|
|
121
|
+
follow?: boolean;
|
|
122
|
+
}
|
|
123
|
+
export interface SnapPayload {
|
|
124
|
+
noEnv?: boolean;
|
|
125
|
+
file?: string;
|
|
126
|
+
}
|
|
127
|
+
export interface RestorePayload {
|
|
128
|
+
file?: string;
|
|
129
|
+
}
|
|
130
|
+
export interface DeployRestorePayload {
|
|
131
|
+
secrets: Record<string, string>;
|
|
132
|
+
downloadUrl: string;
|
|
133
|
+
sha256: string;
|
|
134
|
+
version: number;
|
|
135
|
+
artifactId: string;
|
|
136
|
+
sizeBytes: number;
|
|
137
|
+
deployConfig: DeploySettings;
|
|
138
|
+
}
|
|
139
|
+
export interface SavedState {
|
|
140
|
+
version?: number;
|
|
141
|
+
deploy?: DeploySettings;
|
|
142
|
+
processes: ProcessConfig[];
|
|
143
|
+
mcp?: McpStartPayload;
|
|
144
|
+
}
|
|
145
|
+
export type McpTransport = 'advanced-http' | 'simple-http';
|
|
146
|
+
export interface McpStartPayload {
|
|
147
|
+
transport: McpTransport;
|
|
148
|
+
port: number;
|
|
149
|
+
bind: string;
|
|
150
|
+
cors?: string;
|
|
151
|
+
}
|
|
152
|
+
export interface McpStatusResponse {
|
|
153
|
+
running: boolean;
|
|
154
|
+
transport?: McpTransport;
|
|
155
|
+
port?: number;
|
|
156
|
+
bind?: string;
|
|
157
|
+
cors?: string;
|
|
158
|
+
}
|
|
159
|
+
export interface DaemonStatus {
|
|
160
|
+
pid: number;
|
|
161
|
+
uptime: number;
|
|
162
|
+
processCount: number;
|
|
163
|
+
workerCount: number;
|
|
164
|
+
}
|
|
165
|
+
export type TelemetryEventType = 'error:uncaughtException' | 'error:unhandledRejection' | 'process:deploy-failed' | 'process:deploy-finished' | 'process:deploy-started' | 'process:reload' | 'process:reloaded' | 'process:start' | 'process:stop' | 'worker:crash' | 'worker:exit' | 'worker:maxRestarts' | 'worker:memoryRestart' | 'worker:ready';
|
|
166
|
+
export interface TelemetryEvent {
|
|
167
|
+
type: TelemetryEventType;
|
|
168
|
+
processName: string;
|
|
169
|
+
timestamp: number;
|
|
170
|
+
[key: string]: unknown;
|
|
171
|
+
}
|
|
172
|
+
export interface TelemetryMetricsSnapshot {
|
|
173
|
+
processName: string;
|
|
174
|
+
processId: number;
|
|
175
|
+
execMode: ExecModeType;
|
|
176
|
+
status: ProcessStatusType;
|
|
177
|
+
workers: Array<{
|
|
178
|
+
id: number;
|
|
179
|
+
pid: number;
|
|
180
|
+
cpu: number;
|
|
181
|
+
memory: number;
|
|
182
|
+
uptime: number;
|
|
183
|
+
restarts: number;
|
|
184
|
+
crashes: number;
|
|
185
|
+
status: ProcessStatusType;
|
|
186
|
+
stale?: boolean;
|
|
187
|
+
heapUsed?: number;
|
|
188
|
+
heapTotal?: number;
|
|
189
|
+
external?: number;
|
|
190
|
+
arrayBuffers?: number;
|
|
191
|
+
eventLoopLag?: number;
|
|
192
|
+
eventLoopLagP95?: number;
|
|
193
|
+
activeHandles?: number;
|
|
194
|
+
cacheSize?: number;
|
|
195
|
+
cacheTotalBytes?: number;
|
|
196
|
+
cacheHits?: number;
|
|
197
|
+
cacheMisses?: number;
|
|
198
|
+
cacheHitRate?: number;
|
|
199
|
+
}>;
|
|
200
|
+
timestamp: number;
|
|
201
|
+
}
|
|
202
|
+
export interface TelemetryHostInfo {
|
|
203
|
+
os: string;
|
|
204
|
+
arch: string;
|
|
205
|
+
nodeVersion: string;
|
|
206
|
+
cpuCount: number;
|
|
207
|
+
totalMemory: number;
|
|
208
|
+
}
|
|
209
|
+
export interface SourceContextFrame {
|
|
210
|
+
file: string;
|
|
211
|
+
line: number;
|
|
212
|
+
column: number;
|
|
213
|
+
pre: string[];
|
|
214
|
+
target: string;
|
|
215
|
+
post: string[];
|
|
216
|
+
}
|
|
217
|
+
export interface CrashDiagnostics {
|
|
218
|
+
memoryUsage: {
|
|
219
|
+
rss: number;
|
|
220
|
+
heapTotal: number;
|
|
221
|
+
heapUsed: number;
|
|
222
|
+
external: number;
|
|
223
|
+
arrayBuffers: number;
|
|
224
|
+
};
|
|
225
|
+
processUptime: number;
|
|
226
|
+
heapStatistics: {
|
|
227
|
+
totalHeapSize: number;
|
|
228
|
+
usedHeapSize: number;
|
|
229
|
+
heapSizeLimit: number;
|
|
230
|
+
totalAvailableSize: number;
|
|
231
|
+
totalPhysicalSize: number;
|
|
232
|
+
};
|
|
233
|
+
osFreeMemory: number;
|
|
234
|
+
osLoadAvg: number[];
|
|
235
|
+
activeResources: string[];
|
|
236
|
+
}
|
|
237
|
+
export interface TelemetryErrorEvent {
|
|
238
|
+
processName: string;
|
|
239
|
+
workerId: number;
|
|
240
|
+
timestamp: number;
|
|
241
|
+
errorType: 'browser:error' | 'browser:unhandledRejection' | 'uncaughtException' | 'unhandledRejection';
|
|
242
|
+
name: string;
|
|
243
|
+
message: string;
|
|
244
|
+
stack: string;
|
|
245
|
+
fingerprint: string;
|
|
246
|
+
sourceContext: null | SourceContextFrame[];
|
|
247
|
+
topFrame: null | {
|
|
248
|
+
file: string;
|
|
249
|
+
line: number;
|
|
250
|
+
column: number;
|
|
251
|
+
};
|
|
252
|
+
diagnostics: CrashDiagnostics | null;
|
|
253
|
+
nodeVersion: string;
|
|
254
|
+
pid: number;
|
|
255
|
+
lastLogs: string[];
|
|
256
|
+
resolved?: boolean;
|
|
257
|
+
url?: string;
|
|
258
|
+
userAgent?: string;
|
|
259
|
+
}
|
|
260
|
+
export interface TelemetryLogEntry {
|
|
261
|
+
processName: string;
|
|
262
|
+
workerId: number;
|
|
263
|
+
timestamp: number;
|
|
264
|
+
level: 'error' | 'info' | 'warn';
|
|
265
|
+
message: string;
|
|
266
|
+
}
|
|
267
|
+
export interface DeployStatus {
|
|
268
|
+
deployId: string;
|
|
269
|
+
targetId: string;
|
|
270
|
+
phase: 'building' | 'downloading' | 'extracting' | 'failed' | 'installing' | 'monitoring' | 'reloading' | 'rolled_back' | 'success';
|
|
271
|
+
buildLog?: string;
|
|
272
|
+
error?: string;
|
|
273
|
+
}
|
|
274
|
+
export interface DeploySettings {
|
|
275
|
+
install: string;
|
|
276
|
+
build?: string;
|
|
277
|
+
buildEnv?: Record<string, string>;
|
|
278
|
+
crashWindow?: number;
|
|
279
|
+
sourcemaps?: boolean;
|
|
280
|
+
}
|
|
281
|
+
/** @deprecated Use DeploySettings instead */
|
|
282
|
+
export type DeployConfig = DeploySettings;
|
|
283
|
+
export interface DeployCommand {
|
|
284
|
+
type: 'deploy';
|
|
285
|
+
deployId: string;
|
|
286
|
+
targetId: string;
|
|
287
|
+
artifactId: string;
|
|
288
|
+
version: number;
|
|
289
|
+
sha256: string;
|
|
290
|
+
sizeBytes: number;
|
|
291
|
+
downloadToken: string;
|
|
292
|
+
downloadUrl: string;
|
|
293
|
+
deployConfig: DeploySettings;
|
|
294
|
+
}
|
|
295
|
+
export interface DeployLocalPayload {
|
|
296
|
+
tarballPath: string;
|
|
297
|
+
deployConfig: DeploySettings;
|
|
298
|
+
env?: Record<string, string>;
|
|
299
|
+
}
|
|
300
|
+
export interface DeployOptions {
|
|
301
|
+
localTarball?: string;
|
|
302
|
+
secrets?: Record<string, string>;
|
|
303
|
+
skipInstall?: boolean;
|
|
304
|
+
skipBuild?: boolean;
|
|
305
|
+
skipMonitor?: boolean;
|
|
306
|
+
skipTelemetry?: boolean;
|
|
307
|
+
deploysDir?: string;
|
|
308
|
+
}
|
|
309
|
+
export interface ReconcileResult {
|
|
310
|
+
started: string[];
|
|
311
|
+
reloaded: string[];
|
|
312
|
+
deleted: string[];
|
|
313
|
+
}
|
|
314
|
+
export interface TelemetryPayload {
|
|
315
|
+
daemonPid: number;
|
|
316
|
+
daemonUptime: number;
|
|
317
|
+
hostname: string;
|
|
318
|
+
agentName?: string;
|
|
319
|
+
machineId?: null | string;
|
|
320
|
+
host: TelemetryHostInfo;
|
|
321
|
+
events: TelemetryEvent[];
|
|
322
|
+
metrics: TelemetryMetricsSnapshot[];
|
|
323
|
+
errors: TelemetryErrorEvent[];
|
|
324
|
+
logs: TelemetryLogEntry[];
|
|
325
|
+
alerts?: TelemetryAlertEvent[];
|
|
326
|
+
configHash?: null | string;
|
|
327
|
+
mcpCapable?: boolean;
|
|
328
|
+
deployStatus?: DeployStatus;
|
|
329
|
+
sentAt: number;
|
|
330
|
+
}
|
|
331
|
+
export interface TelemetryConfig {
|
|
332
|
+
apiKey: string;
|
|
333
|
+
apiHost: string;
|
|
334
|
+
}
|
|
335
|
+
export interface AlertRuleCondition {
|
|
336
|
+
metric: 'cpu' | 'heartbeat' | 'memory';
|
|
337
|
+
operator: 'gt';
|
|
338
|
+
threshold: number;
|
|
339
|
+
duration: number;
|
|
340
|
+
}
|
|
341
|
+
export interface AlertRuleConfig {
|
|
342
|
+
id: string;
|
|
343
|
+
name: string;
|
|
344
|
+
condition: AlertRuleCondition;
|
|
345
|
+
is_enabled: boolean;
|
|
346
|
+
}
|
|
347
|
+
export interface McpRemoteKeyConfig {
|
|
348
|
+
name: string;
|
|
349
|
+
key_hash: string;
|
|
350
|
+
tools: string[];
|
|
351
|
+
allowed_ips: string[];
|
|
352
|
+
}
|
|
353
|
+
export interface McpRemoteConfig {
|
|
354
|
+
enabled: boolean;
|
|
355
|
+
keys: McpRemoteKeyConfig[];
|
|
356
|
+
}
|
|
357
|
+
export interface ProjectConfig {
|
|
358
|
+
alert_rules: AlertRuleConfig[];
|
|
359
|
+
mcp: McpRemoteConfig;
|
|
360
|
+
}
|
|
361
|
+
export interface TelemetryAlertEvent {
|
|
362
|
+
type: 'alert:resolved' | 'alert:triggered';
|
|
363
|
+
rule_id: string;
|
|
364
|
+
rule_name: string;
|
|
365
|
+
metric: 'cpu' | 'heartbeat' | 'memory';
|
|
366
|
+
value: number;
|
|
367
|
+
threshold: number;
|
|
368
|
+
process_name: string;
|
|
369
|
+
worker_id: number;
|
|
370
|
+
hostname: string;
|
|
371
|
+
timestamp: number;
|
|
372
|
+
}
|
|
373
|
+
//# sourceMappingURL=index.d.ts.map
|
package/package.json
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@orkify/cli",
|
|
3
|
+
"version": "1.0.0-beta.5",
|
|
4
|
+
"description": "Modern JS process orchestration and deployment for your own infrastructure",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/cli/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./dist/cli/index.js",
|
|
9
|
+
"./cache": {
|
|
10
|
+
"types": "./packages/cache/src/index.ts",
|
|
11
|
+
"import": "./packages/cache/dist/index.js",
|
|
12
|
+
"default": "./packages/cache/dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./next/use-cache": {
|
|
15
|
+
"types": "./packages/next/src/use-cache.ts",
|
|
16
|
+
"import": "./packages/next/dist/use-cache.js",
|
|
17
|
+
"default": "./packages/next/dist/use-cache.js"
|
|
18
|
+
},
|
|
19
|
+
"./next/isr-cache": {
|
|
20
|
+
"types": "./packages/next/src/isr-cache.ts",
|
|
21
|
+
"import": "./packages/next/dist/isr-cache.js",
|
|
22
|
+
"default": "./packages/next/dist/isr-cache.js"
|
|
23
|
+
},
|
|
24
|
+
"./next/error-capture": {
|
|
25
|
+
"types": "./packages/next/src/error-capture.ts",
|
|
26
|
+
"import": "./packages/next/dist/error-capture.js",
|
|
27
|
+
"default": "./packages/next/dist/error-capture.js"
|
|
28
|
+
},
|
|
29
|
+
"./next/error-handler": {
|
|
30
|
+
"types": "./packages/next/src/error-handler.ts",
|
|
31
|
+
"import": "./packages/next/dist/error-handler.js",
|
|
32
|
+
"default": "./packages/next/dist/error-handler.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"bin": {
|
|
36
|
+
"orkify": "./bin/orkify"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"bin/",
|
|
40
|
+
"boot/",
|
|
41
|
+
"dist/**/*.js",
|
|
42
|
+
"dist/**/*.d.ts",
|
|
43
|
+
"packages/"
|
|
44
|
+
],
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "tsc -p packages/cache/tsconfig.json && tsc -p packages/next/tsconfig.json && tsc",
|
|
47
|
+
"dev": "tsc --watch",
|
|
48
|
+
"start": "node dist/cli/index.js",
|
|
49
|
+
"clean": "rm -rf dist coverage packages/cache/dist packages/next/dist",
|
|
50
|
+
"lint": "eslint .",
|
|
51
|
+
"lint:fix": "eslint . --fix",
|
|
52
|
+
"format": "prettier --write .",
|
|
53
|
+
"format:check": "prettier --check .",
|
|
54
|
+
"test": "vitest run --exclude 'tests/integration/**'",
|
|
55
|
+
"test:watch": "vitest --exclude 'tests/integration/**'",
|
|
56
|
+
"test:coverage": "vitest run --coverage --exclude 'tests/integration/**'",
|
|
57
|
+
"test:e2e": "vitest run tests/integration",
|
|
58
|
+
"typecheck": "tsc --noEmit",
|
|
59
|
+
"knip": "knip",
|
|
60
|
+
"check": "npm run build && npm run typecheck && npm run lint && npm run knip && npm run format:check && npm run test:coverage",
|
|
61
|
+
"audit": "npm audit --audit-level=moderate",
|
|
62
|
+
"prepack": "npm run audit && npm run check && npm run build",
|
|
63
|
+
"prepare": "husky"
|
|
64
|
+
},
|
|
65
|
+
"lint-staged": {
|
|
66
|
+
"*.{ts,js}": [
|
|
67
|
+
"eslint --fix",
|
|
68
|
+
"prettier --write"
|
|
69
|
+
],
|
|
70
|
+
"*.{json,md,yml,yaml}": [
|
|
71
|
+
"prettier --write"
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
"keywords": [
|
|
75
|
+
"process-manager",
|
|
76
|
+
"cluster",
|
|
77
|
+
"socket.io",
|
|
78
|
+
"sticky-sessions",
|
|
79
|
+
"zero-downtime",
|
|
80
|
+
"graceful-reload",
|
|
81
|
+
"node",
|
|
82
|
+
"daemon"
|
|
83
|
+
],
|
|
84
|
+
"author": "orkify <ahoy@orkify.com>",
|
|
85
|
+
"license": "Apache-2.0",
|
|
86
|
+
"homepage": "https://orkify.com",
|
|
87
|
+
"repository": {
|
|
88
|
+
"type": "git",
|
|
89
|
+
"url": "https://github.com/orkify/orkify.git"
|
|
90
|
+
},
|
|
91
|
+
"bugs": {
|
|
92
|
+
"url": "https://github.com/orkify/orkify/issues"
|
|
93
|
+
},
|
|
94
|
+
"engines": {
|
|
95
|
+
"node": ">=22.18.0"
|
|
96
|
+
},
|
|
97
|
+
"dependencies": {
|
|
98
|
+
"@modelcontextprotocol/sdk": "^1.25.3",
|
|
99
|
+
"@orkify/cache": "file:./packages/cache",
|
|
100
|
+
"@orkify/next": "file:./packages/next",
|
|
101
|
+
"@socket.io/cluster-adapter": "^0.3.0",
|
|
102
|
+
"@socket.io/sticky": "^1.0.4",
|
|
103
|
+
"chalk": "^5.3.0",
|
|
104
|
+
"chokidar": "^3.5.3",
|
|
105
|
+
"cli-table3": "^0.6.3",
|
|
106
|
+
"commander": "^12.0.0",
|
|
107
|
+
"cron-parser": "^5.5.0",
|
|
108
|
+
"express": "^5.2.1",
|
|
109
|
+
"ignore": "^7.0.5",
|
|
110
|
+
"pidusage": "^3.0.2",
|
|
111
|
+
"socket.io": "^4.8.3",
|
|
112
|
+
"source-map-js": "^1.2.1",
|
|
113
|
+
"tar-stream": "^3.1.7",
|
|
114
|
+
"yaml": "^2.8.2",
|
|
115
|
+
"zod": "^3.22.0"
|
|
116
|
+
},
|
|
117
|
+
"peerDependencies": {
|
|
118
|
+
"react": ">=18"
|
|
119
|
+
},
|
|
120
|
+
"peerDependenciesMeta": {
|
|
121
|
+
"react": {
|
|
122
|
+
"optional": true
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"devDependencies": {
|
|
126
|
+
"@commitlint/cli": "^20.3.1",
|
|
127
|
+
"@commitlint/config-conventional": "^20.3.1",
|
|
128
|
+
"@eslint/js": "^10.0.1",
|
|
129
|
+
"@types/express": "^5.0.0",
|
|
130
|
+
"@types/node": "^22.0.0",
|
|
131
|
+
"@types/pidusage": "^2.0.5",
|
|
132
|
+
"@types/react": "^19.2.14",
|
|
133
|
+
"@types/tar-stream": "^3.1.4",
|
|
134
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
135
|
+
"eslint": "^10.0.0",
|
|
136
|
+
"eslint-config-prettier": "^10.1.8",
|
|
137
|
+
"eslint-plugin-perfectionist": "^5.6.0",
|
|
138
|
+
"husky": "^9.1.7",
|
|
139
|
+
"knip": "^5.82.1",
|
|
140
|
+
"lint-staged": "^16.2.7",
|
|
141
|
+
"prettier": "^3.3.0",
|
|
142
|
+
"react": "^19.2.4",
|
|
143
|
+
"socket.io-client": "^4.8.3",
|
|
144
|
+
"typescript": "^5.9.0",
|
|
145
|
+
"typescript-eslint": "^8.56.0",
|
|
146
|
+
"vitest": "^4.0.18"
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# @orkify/cache
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@orkify/cache)
|
|
4
|
+
[](https://nodejs.org/)
|
|
5
|
+
[](https://github.com/orkify/orkify/blob/main/LICENSE)
|
|
6
|
+
[](https://www.typescriptlang.org/)
|
|
7
|
+
|
|
8
|
+
Framework-agnostic shared cache for [orkify](https://orkify.com)-managed Node.js processes.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @orkify/cache
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { cache } from '@orkify/cache';
|
|
20
|
+
|
|
21
|
+
// Set a value
|
|
22
|
+
cache.set('user:123', { name: 'Alice', role: 'admin' });
|
|
23
|
+
|
|
24
|
+
// Set with TTL (seconds) and tags
|
|
25
|
+
cache.set('post:456', postData, { ttl: 300, tags: ['posts', 'user:123'] });
|
|
26
|
+
|
|
27
|
+
// Get a value (synchronous, local memory)
|
|
28
|
+
const user = cache.get<User>('user:123');
|
|
29
|
+
|
|
30
|
+
// Get with async fallback (checks file-backed cold layer)
|
|
31
|
+
const post = await cache.getAsync<Post>('post:456');
|
|
32
|
+
|
|
33
|
+
// Check existence
|
|
34
|
+
cache.has('user:123');
|
|
35
|
+
|
|
36
|
+
// Delete + broadcast to all workers
|
|
37
|
+
cache.delete('user:123');
|
|
38
|
+
|
|
39
|
+
// Clear all entries + broadcast
|
|
40
|
+
cache.clear();
|
|
41
|
+
|
|
42
|
+
// Invalidate all entries with a tag + record timestamp
|
|
43
|
+
cache.invalidateTag('posts');
|
|
44
|
+
|
|
45
|
+
// Query when a tag was last invalidated
|
|
46
|
+
cache.getTagExpiration(['posts']);
|
|
47
|
+
|
|
48
|
+
// Record a timestamp without deleting entries (stale-while-revalidate)
|
|
49
|
+
cache.updateTagTimestamp('posts');
|
|
50
|
+
|
|
51
|
+
// Cache stats
|
|
52
|
+
const stats = cache.stats();
|
|
53
|
+
// { size, hits, misses, hitRate, totalBytes, diskSize }
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`get()` reads from memory only — always sync, zero overhead. `getAsync()` checks memory first, then falls back to disk if file-backed mode is enabled.
|
|
57
|
+
|
|
58
|
+
## Configuration
|
|
59
|
+
|
|
60
|
+
Optional — call `cache.configure()` before the first use, or defaults apply:
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import { cache } from '@orkify/cache';
|
|
64
|
+
|
|
65
|
+
cache.configure({
|
|
66
|
+
maxEntries: 50_000, // Default: 10,000
|
|
67
|
+
defaultTtl: 300, // Default: undefined (no expiry, seconds)
|
|
68
|
+
maxMemorySize: 128 * 1024 * 1024, // Default: 64 MB per worker
|
|
69
|
+
maxValueSize: 2 << 20, // Default: 1 MB
|
|
70
|
+
fileBacked: true, // Default: true — evicted entries spill to disk
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
| Option | Default | Description |
|
|
75
|
+
| --------------- | ----------------------- | ------------------------------------------------------------------------ |
|
|
76
|
+
| `maxEntries` | `10,000` | Maximum entries before LRU eviction kicks in |
|
|
77
|
+
| `defaultTtl` | `undefined` (no expiry) | Default TTL in seconds for entries without an explicit `ttl` |
|
|
78
|
+
| `maxMemorySize` | `64 MB` | Maximum memory per worker before byte-based LRU eviction |
|
|
79
|
+
| `maxValueSize` | `1 MB` | Maximum byte size of a single value (rejects larger with an error) |
|
|
80
|
+
| `fileBacked` | `true` | Persist evicted entries to disk, survive restarts, read via `getAsync()` |
|
|
81
|
+
|
|
82
|
+
## How It Works
|
|
83
|
+
|
|
84
|
+
| Mode | Behavior |
|
|
85
|
+
| -------------------------- | ------------------------------------------------------- |
|
|
86
|
+
| `npm run dev` (standalone) | Local cache + disk cold layer, no IPC |
|
|
87
|
+
| `orkify up -w 1` (fork) | Local cache + disk cold layer, no IPC |
|
|
88
|
+
| `orkify up -w 4` (cluster) | Broadcast cache — writes sync via IPC, reads stay local |
|
|
89
|
+
| `orkify run` (foreground) | Local cache + disk cold layer, no IPC |
|
|
90
|
+
|
|
91
|
+
The API is identical in every mode. In standalone or fork mode, it degrades gracefully to a plain local cache — no errors, no code changes needed. Deploy with `orkify up -w 4` and the same code syncs across workers automatically.
|
|
92
|
+
|
|
93
|
+
## Features
|
|
94
|
+
|
|
95
|
+
- LRU eviction (entry-count and byte-based)
|
|
96
|
+
- TTL expiration
|
|
97
|
+
- Tag-based group invalidation with timestamps
|
|
98
|
+
- V8 serialization (supports Map, Set, Date, RegExp, Error, ArrayBuffer, TypedArray)
|
|
99
|
+
- Value validation — rejects functions, symbols, and oversized values with descriptive errors
|
|
100
|
+
- Two-tier architecture: hot memory layer + cold file-backed layer
|
|
101
|
+
- Cluster-safe: automatic IPC synchronization across workers
|
|
102
|
+
- Snapshots sent to new workers on spawn
|
|
103
|
+
- Eventual consistency: other workers may read stale values for one IPC round trip after a write
|
|
104
|
+
|
|
105
|
+
For full details on eviction, persistence lifecycle, and cluster behavior, see the [main orkify README](https://github.com/orkify/orkify#shared-cluster-cache).
|
|
106
|
+
|
|
107
|
+
## Requirements
|
|
108
|
+
|
|
109
|
+
- Node.js 22+
|
|
110
|
+
- Must run under [orkify](https://github.com/orkify/orkify) for cluster mode features
|
|
111
|
+
|
|
112
|
+
## License
|
|
113
|
+
|
|
114
|
+
Apache-2.0
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CacheConfig, CacheSetOptions, CacheStats } from './types.js';
|
|
2
|
+
export declare class CacheClient {
|
|
3
|
+
private clusterMode;
|
|
4
|
+
private defaultTtl;
|
|
5
|
+
private maxValueSize;
|
|
6
|
+
private messageHandler;
|
|
7
|
+
private store;
|
|
8
|
+
constructor(config?: CacheConfig, bufferedMessages?: unknown[]);
|
|
9
|
+
/** Configure cache options. Must be called before any other method. Intercepted by the proxy in `cache/index.ts`. */
|
|
10
|
+
configure(_config: CacheConfig): void;
|
|
11
|
+
get<T>(key: string): T | undefined;
|
|
12
|
+
getAsync<T>(key: string): Promise<T | undefined>;
|
|
13
|
+
set(key: string, value: unknown, opts?: CacheSetOptions): void;
|
|
14
|
+
delete(key: string): void;
|
|
15
|
+
clear(): void;
|
|
16
|
+
has(key: string): boolean;
|
|
17
|
+
stats(): CacheStats;
|
|
18
|
+
getTagExpiration(tags: string[]): number;
|
|
19
|
+
invalidateTag(tag: string): void;
|
|
20
|
+
updateTagTimestamp(tag: string, timestamp?: number): void;
|
|
21
|
+
destroy(): void;
|
|
22
|
+
/** Send an IPC message to the cluster primary, silently ignoring failures (e.g. closed channel). */
|
|
23
|
+
private trySend;
|
|
24
|
+
private handleMessage;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=CacheClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CacheClient.d.ts","sourceRoot":"","sources":["../src/CacheClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAMV,WAAW,EACX,eAAe,EAEf,UAAU,EAEX,MAAM,YAAY,CAAC;AAcpB,qBAAa,WAAW;IACtB,OAAO,CAAC,WAAW,CAAU;IAC7B,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,cAAc,CAAuC;IAC7D,OAAO,CAAC,KAAK,CAAc;gBAEf,MAAM,CAAC,EAAE,WAAW,EAAE,gBAAgB,CAAC,EAAE,OAAO,EAAE;IAiE9D,qHAAqH;IACrH,SAAS,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAIrC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAI5B,QAAQ,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAItD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,eAAe,GAAG,IAAI;IAwB9D,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAQzB,KAAK,IAAI,IAAI;IAQb,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;IAIzB,KAAK,IAAI,UAAU;IAInB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM;IAIxC,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAQhC,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IASzD,OAAO,IAAI,IAAI;IAQf,oGAAoG;IACpG,OAAO,CAAC,OAAO;IAQf,OAAO,CAAC,aAAa;CA8BtB"}
|