@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,103 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const startOptionsSchema: z.ZodObject<{
|
|
3
|
+
name: z.ZodOptional<z.ZodString>;
|
|
4
|
+
workers: z.ZodDefault<z.ZodNumber>;
|
|
5
|
+
watch: z.ZodDefault<z.ZodBoolean>;
|
|
6
|
+
watchPaths: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
7
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
8
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
9
|
+
nodeArgs: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
10
|
+
args: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
11
|
+
killTimeout: z.ZodDefault<z.ZodNumber>;
|
|
12
|
+
maxRestarts: z.ZodDefault<z.ZodNumber>;
|
|
13
|
+
minUptime: z.ZodDefault<z.ZodNumber>;
|
|
14
|
+
restartDelay: z.ZodDefault<z.ZodNumber>;
|
|
15
|
+
sticky: z.ZodDefault<z.ZodBoolean>;
|
|
16
|
+
port: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
reloadRetries: z.ZodDefault<z.ZodNumber>;
|
|
18
|
+
healthCheck: z.ZodOptional<z.ZodString>;
|
|
19
|
+
logMaxSize: z.ZodDefault<z.ZodNumber>;
|
|
20
|
+
logMaxFiles: z.ZodDefault<z.ZodNumber>;
|
|
21
|
+
logMaxAge: z.ZodDefault<z.ZodNumber>;
|
|
22
|
+
restartOnMemory: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
framework: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
workers: number;
|
|
26
|
+
watch: boolean;
|
|
27
|
+
nodeArgs: string[];
|
|
28
|
+
args: string[];
|
|
29
|
+
killTimeout: number;
|
|
30
|
+
maxRestarts: number;
|
|
31
|
+
minUptime: number;
|
|
32
|
+
restartDelay: number;
|
|
33
|
+
sticky: boolean;
|
|
34
|
+
reloadRetries: number;
|
|
35
|
+
logMaxSize: number;
|
|
36
|
+
logMaxFiles: number;
|
|
37
|
+
logMaxAge: number;
|
|
38
|
+
env?: Record<string, string> | undefined;
|
|
39
|
+
name?: string | undefined;
|
|
40
|
+
watchPaths?: string[] | undefined;
|
|
41
|
+
cwd?: string | undefined;
|
|
42
|
+
port?: number | undefined;
|
|
43
|
+
healthCheck?: string | undefined;
|
|
44
|
+
restartOnMemory?: number | undefined;
|
|
45
|
+
framework?: string | undefined;
|
|
46
|
+
}, {
|
|
47
|
+
env?: Record<string, string> | undefined;
|
|
48
|
+
name?: string | undefined;
|
|
49
|
+
workers?: number | undefined;
|
|
50
|
+
watch?: boolean | undefined;
|
|
51
|
+
watchPaths?: string[] | undefined;
|
|
52
|
+
cwd?: string | undefined;
|
|
53
|
+
nodeArgs?: string[] | undefined;
|
|
54
|
+
args?: string[] | undefined;
|
|
55
|
+
killTimeout?: number | undefined;
|
|
56
|
+
maxRestarts?: number | undefined;
|
|
57
|
+
minUptime?: number | undefined;
|
|
58
|
+
restartDelay?: number | undefined;
|
|
59
|
+
sticky?: boolean | undefined;
|
|
60
|
+
port?: number | undefined;
|
|
61
|
+
reloadRetries?: number | undefined;
|
|
62
|
+
healthCheck?: string | undefined;
|
|
63
|
+
logMaxSize?: number | undefined;
|
|
64
|
+
logMaxFiles?: number | undefined;
|
|
65
|
+
logMaxAge?: number | undefined;
|
|
66
|
+
restartOnMemory?: number | undefined;
|
|
67
|
+
framework?: string | undefined;
|
|
68
|
+
}>;
|
|
69
|
+
export type StartOptions = z.infer<typeof startOptionsSchema>;
|
|
70
|
+
export declare const targetSchema: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodLiteral<"all">]>;
|
|
71
|
+
export type Target = z.infer<typeof targetSchema>;
|
|
72
|
+
export declare const logsOptionsSchema: z.ZodObject<{
|
|
73
|
+
lines: z.ZodDefault<z.ZodNumber>;
|
|
74
|
+
follow: z.ZodDefault<z.ZodBoolean>;
|
|
75
|
+
}, "strip", z.ZodTypeAny, {
|
|
76
|
+
follow: boolean;
|
|
77
|
+
lines: number;
|
|
78
|
+
}, {
|
|
79
|
+
follow?: boolean | undefined;
|
|
80
|
+
lines?: number | undefined;
|
|
81
|
+
}>;
|
|
82
|
+
export type LogsOptions = z.infer<typeof logsOptionsSchema>;
|
|
83
|
+
export declare function validateStartOptions(options: unknown): StartOptions;
|
|
84
|
+
export declare function validateTarget(target: unknown): Target;
|
|
85
|
+
export declare function validateLogsOptions(options: unknown): LogsOptions;
|
|
86
|
+
export declare const mcpStateSchema: z.ZodObject<{
|
|
87
|
+
transport: z.ZodLiteral<"simple-http">;
|
|
88
|
+
port: z.ZodNumber;
|
|
89
|
+
bind: z.ZodString;
|
|
90
|
+
cors: z.ZodOptional<z.ZodString>;
|
|
91
|
+
}, "strip", z.ZodTypeAny, {
|
|
92
|
+
port: number;
|
|
93
|
+
transport: "simple-http";
|
|
94
|
+
bind: string;
|
|
95
|
+
cors?: string | undefined;
|
|
96
|
+
}, {
|
|
97
|
+
port: number;
|
|
98
|
+
transport: "simple-http";
|
|
99
|
+
bind: string;
|
|
100
|
+
cors?: string | undefined;
|
|
101
|
+
}>;
|
|
102
|
+
export declare function validateMcpState(value: unknown): value is z.infer<typeof mcpStateSchema>;
|
|
103
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { DEFAULT_LOG_MAX_AGE, DEFAULT_LOG_MAX_FILES, DEFAULT_LOG_MAX_SIZE, DEFAULT_MAX_RESTARTS, DEFAULT_MIN_UPTIME, DEFAULT_RELOAD_RETRIES, DEFAULT_RESTART_DELAY, DEFAULT_WORKERS, KILL_TIMEOUT, MIN_LOG_MAX_SIZE, } from '../constants.js';
|
|
3
|
+
export const startOptionsSchema = z.object({
|
|
4
|
+
name: z.string().optional(),
|
|
5
|
+
workers: z.number().int().positive().default(DEFAULT_WORKERS),
|
|
6
|
+
watch: z.boolean().default(false),
|
|
7
|
+
watchPaths: z.array(z.string()).optional(),
|
|
8
|
+
cwd: z.string().optional(),
|
|
9
|
+
env: z.record(z.string()).optional(),
|
|
10
|
+
nodeArgs: z.array(z.string()).default([]),
|
|
11
|
+
args: z.array(z.string()).default([]),
|
|
12
|
+
killTimeout: z.number().int().positive().default(KILL_TIMEOUT),
|
|
13
|
+
maxRestarts: z.number().int().nonnegative().default(DEFAULT_MAX_RESTARTS),
|
|
14
|
+
minUptime: z.number().int().nonnegative().default(DEFAULT_MIN_UPTIME),
|
|
15
|
+
restartDelay: z.number().int().nonnegative().default(DEFAULT_RESTART_DELAY),
|
|
16
|
+
sticky: z.boolean().default(false),
|
|
17
|
+
port: z.number().int().positive().optional(),
|
|
18
|
+
reloadRetries: z.number().int().min(0).max(3).default(DEFAULT_RELOAD_RETRIES),
|
|
19
|
+
healthCheck: z.string().startsWith('/').optional(),
|
|
20
|
+
logMaxSize: z.number().int().min(MIN_LOG_MAX_SIZE).default(DEFAULT_LOG_MAX_SIZE),
|
|
21
|
+
logMaxFiles: z.number().int().min(0).max(10000).default(DEFAULT_LOG_MAX_FILES),
|
|
22
|
+
logMaxAge: z.number().int().nonnegative().default(DEFAULT_LOG_MAX_AGE),
|
|
23
|
+
restartOnMemory: z.number().int().nonnegative().optional(),
|
|
24
|
+
framework: z.string().optional(),
|
|
25
|
+
});
|
|
26
|
+
export const targetSchema = z.union([z.string(), z.number().int().nonnegative(), z.literal('all')]);
|
|
27
|
+
export const logsOptionsSchema = z.object({
|
|
28
|
+
lines: z.number().int().positive().default(100),
|
|
29
|
+
follow: z.boolean().default(false),
|
|
30
|
+
});
|
|
31
|
+
export function validateStartOptions(options) {
|
|
32
|
+
return startOptionsSchema.parse(options);
|
|
33
|
+
}
|
|
34
|
+
export function validateTarget(target) {
|
|
35
|
+
return targetSchema.parse(target);
|
|
36
|
+
}
|
|
37
|
+
export function validateLogsOptions(options) {
|
|
38
|
+
return logsOptionsSchema.parse(options);
|
|
39
|
+
}
|
|
40
|
+
export const mcpStateSchema = z.object({
|
|
41
|
+
transport: z.literal('simple-http'),
|
|
42
|
+
port: z.number().int().positive(),
|
|
43
|
+
bind: z.string().min(1),
|
|
44
|
+
cors: z.string().optional(),
|
|
45
|
+
});
|
|
46
|
+
export function validateMcpState(value) {
|
|
47
|
+
return mcpStateSchema.safeParse(value).success;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export declare const ORKIFY_HOME: string;
|
|
2
|
+
export declare const SNAPSHOT_FILE: string;
|
|
3
|
+
export declare const DAEMON_PID_FILE: string;
|
|
4
|
+
export declare const DAEMON_LOCK_FILE: string;
|
|
5
|
+
export declare const DAEMON_LOG_FILE: string;
|
|
6
|
+
export declare const LOGS_DIR: string;
|
|
7
|
+
export declare const AGENT_NAME_FILE: string;
|
|
8
|
+
export declare const SOCKET_PATH: string;
|
|
9
|
+
export declare const DAEMON_STARTUP_TIMEOUT = 5000;
|
|
10
|
+
export declare const KILL_TIMEOUT = 5000;
|
|
11
|
+
export declare const LAUNCH_TIMEOUT = 30000;
|
|
12
|
+
export declare const IPC_CONNECT_TIMEOUT = 3000;
|
|
13
|
+
export declare const IPC_RESPONSE_TIMEOUT = 120000;
|
|
14
|
+
export declare const IPC_DEPLOY_TIMEOUT = 600000;
|
|
15
|
+
export declare const DEFAULT_WORKERS = 1;
|
|
16
|
+
export declare const DEFAULT_MAX_RESTARTS = 10;
|
|
17
|
+
export declare const DEFAULT_MIN_UPTIME = 1000;
|
|
18
|
+
export declare const DEFAULT_RESTART_DELAY = 100;
|
|
19
|
+
export declare const DEFAULT_RELOAD_RETRIES = 3;
|
|
20
|
+
export declare const MIN_LOG_MAX_SIZE = 1024;
|
|
21
|
+
export declare const DEFAULT_LOG_MAX_SIZE: number;
|
|
22
|
+
export declare const DEFAULT_LOG_MAX_FILES = 90;
|
|
23
|
+
export declare const DEFAULT_LOG_MAX_AGE: number;
|
|
24
|
+
export declare const MEMORY_RESTART_COOLDOWN = 30000;
|
|
25
|
+
export declare const ProcessStatus: {
|
|
26
|
+
readonly ONLINE: "online";
|
|
27
|
+
readonly STOPPING: "stopping";
|
|
28
|
+
readonly STOPPED: "stopped";
|
|
29
|
+
readonly ERRORED: "errored";
|
|
30
|
+
readonly LAUNCHING: "launching";
|
|
31
|
+
};
|
|
32
|
+
export type ProcessStatusType = (typeof ProcessStatus)[keyof typeof ProcessStatus];
|
|
33
|
+
export declare const ExecMode: {
|
|
34
|
+
readonly FORK: "fork";
|
|
35
|
+
readonly CLUSTER: "cluster";
|
|
36
|
+
};
|
|
37
|
+
export type ExecModeType = (typeof ExecMode)[keyof typeof ExecMode];
|
|
38
|
+
export declare const IPCMessageType: {
|
|
39
|
+
readonly UP: "up";
|
|
40
|
+
readonly DOWN: "down";
|
|
41
|
+
readonly RESTART: "restart";
|
|
42
|
+
readonly RELOAD: "reload";
|
|
43
|
+
readonly DELETE: "delete";
|
|
44
|
+
readonly LIST: "list";
|
|
45
|
+
readonly LOGS: "logs";
|
|
46
|
+
readonly SNAP: "snap";
|
|
47
|
+
readonly RESTORE: "restore";
|
|
48
|
+
readonly RESTORE_CONFIGS: "restore_configs";
|
|
49
|
+
readonly DEPLOY_LOCAL: "deploy_local";
|
|
50
|
+
readonly DEPLOY_RESTORE: "deploy_restore";
|
|
51
|
+
readonly KILL_DAEMON: "kill_daemon";
|
|
52
|
+
readonly CONFIGURE_TELEMETRY: "configure_telemetry";
|
|
53
|
+
readonly PING: "ping";
|
|
54
|
+
readonly CRASH_TEST: "crash_test";
|
|
55
|
+
readonly FLUSH: "flush";
|
|
56
|
+
readonly MCP_START: "mcp_start";
|
|
57
|
+
readonly MCP_STOP: "mcp_stop";
|
|
58
|
+
readonly MCP_STATUS: "mcp_status";
|
|
59
|
+
readonly SUCCESS: "success";
|
|
60
|
+
readonly ERROR: "error";
|
|
61
|
+
readonly PROCESS_LIST: "process_list";
|
|
62
|
+
readonly LOG_DATA: "log_data";
|
|
63
|
+
readonly DEPLOY_PROGRESS: "deploy_progress";
|
|
64
|
+
readonly PONG: "pong";
|
|
65
|
+
};
|
|
66
|
+
export type IPCMessageTypeType = (typeof IPCMessageType)[keyof typeof IPCMessageType];
|
|
67
|
+
export declare const METRICS_PROBE_IMPORT: string;
|
|
68
|
+
export declare const MCP_CONFIG_FILE: string;
|
|
69
|
+
export declare const MCP_DEFAULT_PORT = 8787;
|
|
70
|
+
export declare const MCP_TOKEN_PREFIX = "orkify_mcp_";
|
|
71
|
+
export declare const ORKIFY_DEPLOYS_DIR: string;
|
|
72
|
+
export declare const DEPLOY_META_FILE = "orkify-deploy-meta.json";
|
|
73
|
+
export declare const DEPLOY_CRASH_WINDOW_DEFAULT = 30;
|
|
74
|
+
export declare const ORKIFY_CONFIG_FILE = "orkify.yml";
|
|
75
|
+
export declare const TELEMETRY_DEFAULT_API_HOST = "https://api.orkify.com";
|
|
76
|
+
export declare const TELEMETRY_METRICS_INTERVAL = 10000;
|
|
77
|
+
export declare const TELEMETRY_FLUSH_TIMEOUT = 5000;
|
|
78
|
+
export declare const TELEMETRY_MAX_BATCH_SIZE = 100;
|
|
79
|
+
export declare const TELEMETRY_REQUEST_TIMEOUT = 10000;
|
|
80
|
+
export declare const TELEMETRY_LOG_RING_SIZE = 50;
|
|
81
|
+
export declare const TELEMETRY_LOG_FLUSH_MAX_LINES = 20;
|
|
82
|
+
export declare const TELEMETRY_LOG_MAX_LINE_LENGTH = 4000;
|
|
83
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { homedir, userInfo } from 'node:os';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
// Base paths
|
|
4
|
+
export const ORKIFY_HOME = join(homedir(), '.orkify');
|
|
5
|
+
export const SNAPSHOT_FILE = join(ORKIFY_HOME, 'snapshot.yml');
|
|
6
|
+
export const DAEMON_PID_FILE = join(ORKIFY_HOME, 'daemon.pid');
|
|
7
|
+
export const DAEMON_LOCK_FILE = join(ORKIFY_HOME, 'daemon.lock');
|
|
8
|
+
export const DAEMON_LOG_FILE = join(ORKIFY_HOME, 'daemon.log');
|
|
9
|
+
export const LOGS_DIR = join(ORKIFY_HOME, 'logs');
|
|
10
|
+
export const AGENT_NAME_FILE = join(ORKIFY_HOME, 'agent-name');
|
|
11
|
+
// IPC socket path - cross-platform (Unix sockets on Linux/macOS, Named Pipes on Windows)
|
|
12
|
+
// Include username to support multi-user setups
|
|
13
|
+
function getSocketPath() {
|
|
14
|
+
const username = userInfo().username;
|
|
15
|
+
if (process.platform === 'win32') {
|
|
16
|
+
// Windows Named Pipe - namespaced per user
|
|
17
|
+
return `\\\\.\\pipe\\orkify-${username}`;
|
|
18
|
+
}
|
|
19
|
+
// Unix socket in user's home directory
|
|
20
|
+
return join(ORKIFY_HOME, 'orkify.sock');
|
|
21
|
+
}
|
|
22
|
+
export const SOCKET_PATH = getSocketPath();
|
|
23
|
+
// Timeouts (in milliseconds)
|
|
24
|
+
export const DAEMON_STARTUP_TIMEOUT = 5000;
|
|
25
|
+
export const KILL_TIMEOUT = 5000;
|
|
26
|
+
export const LAUNCH_TIMEOUT = 30_000;
|
|
27
|
+
export const IPC_CONNECT_TIMEOUT = 3000;
|
|
28
|
+
export const IPC_RESPONSE_TIMEOUT = 120000; // 2 minutes for long operations like reload
|
|
29
|
+
export const IPC_DEPLOY_TIMEOUT = 600000; // 10 minutes for deploy (install + build)
|
|
30
|
+
// Defaults
|
|
31
|
+
export const DEFAULT_WORKERS = 1;
|
|
32
|
+
export const DEFAULT_MAX_RESTARTS = 10;
|
|
33
|
+
export const DEFAULT_MIN_UPTIME = 1000;
|
|
34
|
+
export const DEFAULT_RESTART_DELAY = 100;
|
|
35
|
+
export const DEFAULT_RELOAD_RETRIES = 3;
|
|
36
|
+
export const MIN_LOG_MAX_SIZE = 1024; // 1 KB floor
|
|
37
|
+
export const DEFAULT_LOG_MAX_SIZE = 100 * 1024 * 1024; // 100 MB
|
|
38
|
+
export const DEFAULT_LOG_MAX_FILES = 90;
|
|
39
|
+
export const DEFAULT_LOG_MAX_AGE = 90 * 24 * 60 * 60 * 1000; // 90 days in ms
|
|
40
|
+
export const MEMORY_RESTART_COOLDOWN = 30_000; // 30s cooldown after memory-triggered restart
|
|
41
|
+
// Process status
|
|
42
|
+
export const ProcessStatus = {
|
|
43
|
+
ONLINE: 'online',
|
|
44
|
+
STOPPING: 'stopping',
|
|
45
|
+
STOPPED: 'stopped',
|
|
46
|
+
ERRORED: 'errored',
|
|
47
|
+
LAUNCHING: 'launching',
|
|
48
|
+
};
|
|
49
|
+
// Execution modes
|
|
50
|
+
export const ExecMode = {
|
|
51
|
+
FORK: 'fork',
|
|
52
|
+
CLUSTER: 'cluster',
|
|
53
|
+
};
|
|
54
|
+
// IPC message types
|
|
55
|
+
export const IPCMessageType = {
|
|
56
|
+
// Commands
|
|
57
|
+
UP: 'up',
|
|
58
|
+
DOWN: 'down',
|
|
59
|
+
RESTART: 'restart',
|
|
60
|
+
RELOAD: 'reload',
|
|
61
|
+
DELETE: 'delete',
|
|
62
|
+
LIST: 'list',
|
|
63
|
+
LOGS: 'logs',
|
|
64
|
+
SNAP: 'snap',
|
|
65
|
+
RESTORE: 'restore',
|
|
66
|
+
RESTORE_CONFIGS: 'restore_configs',
|
|
67
|
+
DEPLOY_LOCAL: 'deploy_local',
|
|
68
|
+
DEPLOY_RESTORE: 'deploy_restore',
|
|
69
|
+
KILL_DAEMON: 'kill_daemon',
|
|
70
|
+
CONFIGURE_TELEMETRY: 'configure_telemetry',
|
|
71
|
+
PING: 'ping',
|
|
72
|
+
CRASH_TEST: 'crash_test',
|
|
73
|
+
FLUSH: 'flush',
|
|
74
|
+
MCP_START: 'mcp_start',
|
|
75
|
+
MCP_STOP: 'mcp_stop',
|
|
76
|
+
MCP_STATUS: 'mcp_status',
|
|
77
|
+
// Responses
|
|
78
|
+
SUCCESS: 'success',
|
|
79
|
+
ERROR: 'error',
|
|
80
|
+
PROCESS_LIST: 'process_list',
|
|
81
|
+
LOG_DATA: 'log_data',
|
|
82
|
+
DEPLOY_PROGRESS: 'deploy_progress',
|
|
83
|
+
PONG: 'pong',
|
|
84
|
+
};
|
|
85
|
+
// Metrics probe — injected into child processes via --import data URL.
|
|
86
|
+
// Wrapped in try/catch so a probe failure never crashes the child process.
|
|
87
|
+
const METRICS_PROBE_SRC = `
|
|
88
|
+
try {
|
|
89
|
+
if (typeof process.send === "function") {
|
|
90
|
+
// Buffer IPC cache messages globally BEFORE any await so that snapshots
|
|
91
|
+
// sent on the 'online' event are captured even if cache/index.ts hasn't
|
|
92
|
+
// loaded yet. The CacheClient constructor drains this buffer on creation.
|
|
93
|
+
const _buf = globalThis.__orkifyCacheBuffer = [];
|
|
94
|
+
const _el = (msg) => {
|
|
95
|
+
if (msg?.__orkify && msg.type?.startsWith("cache:")) _buf.push(msg);
|
|
96
|
+
};
|
|
97
|
+
process.on("message", _el);
|
|
98
|
+
globalThis.__orkifyCacheBufferCleanup = () => process.removeListener("message", _el);
|
|
99
|
+
|
|
100
|
+
const { monitorEventLoopDelay } = await import("node:perf_hooks");
|
|
101
|
+
const { readFileSync } = await import("node:fs");
|
|
102
|
+
const { createHash } = await import("node:crypto");
|
|
103
|
+
const { fileURLToPath } = await import("node:url");
|
|
104
|
+
const { resolve: resolvePath } = await import("node:path");
|
|
105
|
+
const v8 = await import("node:v8");
|
|
106
|
+
const os = await import("node:os");
|
|
107
|
+
const h = monitorEventLoopDelay({ resolution: 100 });
|
|
108
|
+
h.enable();
|
|
109
|
+
const s = process.send.bind(process);
|
|
110
|
+
const t = setInterval(() => {
|
|
111
|
+
try {
|
|
112
|
+
const m = process.memoryUsage();
|
|
113
|
+
const data = {
|
|
114
|
+
heapUsed: m.heapUsed, heapTotal: m.heapTotal,
|
|
115
|
+
external: m.external, arrayBuffers: m.arrayBuffers,
|
|
116
|
+
eventLoopLag: h.mean / 1e6, eventLoopLagP95: h.percentile(95) / 1e6,
|
|
117
|
+
activeHandles: process._getActiveHandles().length
|
|
118
|
+
};
|
|
119
|
+
const _cacheStats = globalThis.__orkifyCacheStats;
|
|
120
|
+
if (typeof _cacheStats === "function") {
|
|
121
|
+
try {
|
|
122
|
+
const cs = _cacheStats();
|
|
123
|
+
data.cacheSize = cs.size;
|
|
124
|
+
data.cacheTotalBytes = cs.totalBytes;
|
|
125
|
+
data.cacheHits = cs.hits;
|
|
126
|
+
data.cacheMisses = cs.misses;
|
|
127
|
+
data.cacheHitRate = cs.hitRate;
|
|
128
|
+
} catch {}
|
|
129
|
+
}
|
|
130
|
+
s({ __orkify: true, type: "metrics", data });
|
|
131
|
+
h.reset();
|
|
132
|
+
} catch {}
|
|
133
|
+
}, 2000);
|
|
134
|
+
t.unref();
|
|
135
|
+
|
|
136
|
+
// Port auto-detection for fork mode: hook net.Server.listen to report
|
|
137
|
+
// the first port the child binds, mirroring cluster mode's worker:listening.
|
|
138
|
+
// Falls back to PORT env var if the monkey-patch fails.
|
|
139
|
+
try {
|
|
140
|
+
const net = await import("node:net");
|
|
141
|
+
const _origListen = net.Server.prototype.listen;
|
|
142
|
+
let _portReported = false;
|
|
143
|
+
net.Server.prototype.listen = function(...args) {
|
|
144
|
+
if (!_portReported) {
|
|
145
|
+
this.once("listening", () => {
|
|
146
|
+
if (!_portReported) {
|
|
147
|
+
const addr = this.address();
|
|
148
|
+
if (addr && typeof addr === "object" && addr.port) {
|
|
149
|
+
_portReported = true;
|
|
150
|
+
s({ __orkify: true, type: "listening", data: { port: addr.port } });
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return _origListen.apply(this, args);
|
|
156
|
+
};
|
|
157
|
+
} catch {
|
|
158
|
+
const envPort = parseInt(process.env.PORT || "", 10);
|
|
159
|
+
if (envPort > 0) {
|
|
160
|
+
s({ __orkify: true, type: "listening", data: { port: envPort } });
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// CVE-2025-29927 / CVE-2024-46982: strip dangerous headers from external requests
|
|
165
|
+
try {
|
|
166
|
+
const _stripHeaders = ["x-middleware-subrequest", "x-now-route-matches"];
|
|
167
|
+
const _isLoopback = (a) => a === "127.0.0.1" || a === "::1" || a === "::ffff:127.0.0.1";
|
|
168
|
+
function _wrapEmit(Server) {
|
|
169
|
+
const orig = Server.prototype.emit;
|
|
170
|
+
Server.prototype.emit = function(event, ...args) {
|
|
171
|
+
if (event === "request") {
|
|
172
|
+
const req = args[0];
|
|
173
|
+
if (!_isLoopback(req?.socket?.remoteAddress || "")) {
|
|
174
|
+
for (const h of _stripHeaders) delete req.headers[h];
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return orig.apply(this, [event, ...args]);
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
const _http = await import("node:http");
|
|
181
|
+
_wrapEmit(_http.Server);
|
|
182
|
+
try { const _https = await import("node:https"); _wrapEmit(_https.Server); } catch {}
|
|
183
|
+
} catch {}
|
|
184
|
+
|
|
185
|
+
// Mirrors parseUserFrames() in src/probe/parse-frames.ts — keep in sync
|
|
186
|
+
function _orkifyParseUserFrames(stack) {
|
|
187
|
+
const frames = [];
|
|
188
|
+
if (!stack) return frames;
|
|
189
|
+
for (const l of stack.split("\\n")) {
|
|
190
|
+
const m = l.match(/at\\s+(?:.*?\\s+)?\\(?(.+?):(\\d+):(\\d+)\\)?$/);
|
|
191
|
+
if (m) {
|
|
192
|
+
let file = m[1];
|
|
193
|
+
if (file.startsWith("file://")) {
|
|
194
|
+
try { file = fileURLToPath(file); } catch {}
|
|
195
|
+
} else if (file.startsWith("webpack-internal://") || file.startsWith("webpack://")) {
|
|
196
|
+
const wp = file.replace(/^webpack(?:-internal)?:\\/\\/\\/(?:[^/]*\\/)?/, "");
|
|
197
|
+
file = resolvePath(process.cwd(), wp);
|
|
198
|
+
} else if (/^[a-z][a-z0-9+.-]+:/i.test(file)) {
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
if (!file.startsWith("node:") && !file.includes("node_modules")) {
|
|
202
|
+
frames.push({ file, line: parseInt(m[2],10), column: parseInt(m[3],10) });
|
|
203
|
+
if (frames.length >= 10) break;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return frames;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function _orkifyCaptureError(err, type) {
|
|
211
|
+
try {
|
|
212
|
+
const message = err?.message || String(err);
|
|
213
|
+
const stack = err?.stack || "";
|
|
214
|
+
const frames = _orkifyParseUserFrames(stack);
|
|
215
|
+
const topFrame = frames.length > 0 ? frames[0] : null;
|
|
216
|
+
const sourceContextArr = [];
|
|
217
|
+
for (const frame of frames) {
|
|
218
|
+
try {
|
|
219
|
+
const lines = readFileSync(frame.file, "utf8").split("\\n");
|
|
220
|
+
const start = Math.max(0, frame.line - 6);
|
|
221
|
+
const end = Math.min(lines.length, frame.line + 5);
|
|
222
|
+
sourceContextArr.push({ file: frame.file, line: frame.line, column: frame.column,
|
|
223
|
+
pre: lines.slice(start, frame.line - 1),
|
|
224
|
+
target: lines[frame.line - 1] || "",
|
|
225
|
+
post: lines.slice(frame.line, end) });
|
|
226
|
+
} catch {}
|
|
227
|
+
}
|
|
228
|
+
const sourceContext = sourceContextArr.length > 0 ? sourceContextArr : null;
|
|
229
|
+
let diagnostics = null;
|
|
230
|
+
try {
|
|
231
|
+
const mem = process.memoryUsage();
|
|
232
|
+
const heap = v8.getHeapStatistics();
|
|
233
|
+
diagnostics = {
|
|
234
|
+
memoryUsage: { rss: mem.rss, heapTotal: mem.heapTotal, heapUsed: mem.heapUsed,
|
|
235
|
+
external: mem.external, arrayBuffers: mem.arrayBuffers },
|
|
236
|
+
processUptime: process.uptime(),
|
|
237
|
+
heapStatistics: { totalHeapSize: heap.total_heap_size, usedHeapSize: heap.used_heap_size,
|
|
238
|
+
heapSizeLimit: heap.heap_size_limit, totalAvailableSize: heap.total_available_size,
|
|
239
|
+
totalPhysicalSize: heap.total_physical_size },
|
|
240
|
+
osFreeMemory: os.freemem(),
|
|
241
|
+
osLoadAvg: os.loadavg(),
|
|
242
|
+
activeResources: typeof process.getActiveResourcesInfo === "function"
|
|
243
|
+
? process.getActiveResourcesInfo() : []
|
|
244
|
+
};
|
|
245
|
+
} catch {}
|
|
246
|
+
const raw = message + (topFrame ? topFrame.file + ":" + topFrame.line : "");
|
|
247
|
+
const fingerprint = createHash("sha256").update(raw).digest("hex").slice(0, 32);
|
|
248
|
+
s({ __orkify: true, type: "error", data: {
|
|
249
|
+
errorType: type, name: err?.name || "Error", message, stack, fingerprint,
|
|
250
|
+
sourceContext, topFrame, diagnostics, timestamp: Date.now(),
|
|
251
|
+
nodeVersion: process.version, pid: process.pid
|
|
252
|
+
}});
|
|
253
|
+
} catch {}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
process.on("uncaughtException", (err) => {
|
|
257
|
+
_orkifyCaptureError(err, "uncaughtException");
|
|
258
|
+
if (process.listenerCount("uncaughtException") === 1) {
|
|
259
|
+
process.exit(1);
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
process.on("unhandledRejection", (reason) => {
|
|
264
|
+
_orkifyCaptureError(reason instanceof Error ? reason : new Error(String(reason)),
|
|
265
|
+
"unhandledRejection");
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
} catch {}
|
|
269
|
+
`.trim();
|
|
270
|
+
export const METRICS_PROBE_IMPORT = `--import=data:text/javascript;base64,${Buffer.from(METRICS_PROBE_SRC).toString('base64')}`;
|
|
271
|
+
// MCP HTTP
|
|
272
|
+
export const MCP_CONFIG_FILE = join(ORKIFY_HOME, 'mcp.yml');
|
|
273
|
+
export const MCP_DEFAULT_PORT = 8787;
|
|
274
|
+
export const MCP_TOKEN_PREFIX = 'orkify_mcp_';
|
|
275
|
+
// Deploy
|
|
276
|
+
export const ORKIFY_DEPLOYS_DIR = join(ORKIFY_HOME, 'deploys');
|
|
277
|
+
export const DEPLOY_META_FILE = 'orkify-deploy-meta.json';
|
|
278
|
+
export const DEPLOY_CRASH_WINDOW_DEFAULT = 30; // seconds
|
|
279
|
+
export const ORKIFY_CONFIG_FILE = 'orkify.yml';
|
|
280
|
+
// Telemetry
|
|
281
|
+
export const TELEMETRY_DEFAULT_API_HOST = 'https://api.orkify.com';
|
|
282
|
+
export const TELEMETRY_METRICS_INTERVAL = 10_000;
|
|
283
|
+
export const TELEMETRY_FLUSH_TIMEOUT = 5_000;
|
|
284
|
+
export const TELEMETRY_MAX_BATCH_SIZE = 100;
|
|
285
|
+
export const TELEMETRY_REQUEST_TIMEOUT = 10_000;
|
|
286
|
+
export const TELEMETRY_LOG_RING_SIZE = 50;
|
|
287
|
+
export const TELEMETRY_LOG_FLUSH_MAX_LINES = 20;
|
|
288
|
+
export const TELEMETRY_LOG_MAX_LINE_LENGTH = 4000;
|
|
289
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Orchestrator } from '../daemon/Orchestrator.js';
|
|
2
|
+
import type { CronJob } from '../types/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Validate a cron schedule string. Returns null if valid,
|
|
5
|
+
* or an error message if invalid, sub-minute, or > 24h.
|
|
6
|
+
*/
|
|
7
|
+
export declare function validateCronSchedule(schedule: string): null | string;
|
|
8
|
+
/**
|
|
9
|
+
* Validate a cron job path. Must be a clean local route path
|
|
10
|
+
* (e.g. "/api/cron/heartbeat-check") — no URLs, hosts, or query strings.
|
|
11
|
+
*/
|
|
12
|
+
export declare function validateCronPath(path: string): null | string;
|
|
13
|
+
export declare class CronScheduler {
|
|
14
|
+
private orchestrator;
|
|
15
|
+
private jobs;
|
|
16
|
+
private timer;
|
|
17
|
+
constructor(orchestrator: Orchestrator);
|
|
18
|
+
register(processName: string, jobs: CronJob[]): void;
|
|
19
|
+
unregister(processName: string): void;
|
|
20
|
+
shutdown(): void;
|
|
21
|
+
private tick;
|
|
22
|
+
private dispatch;
|
|
23
|
+
private computeNextRun;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=CronScheduler.d.ts.map
|