@koed-labs/server 0.0.0-bootstrap.0 → 0.10.3
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 +201 -0
- package/README.md +65 -0
- package/bin/koed.js +7 -0
- package/package.json +22 -4
- package/third-party-notices.json +92 -0
- package/vendor/chunk-2BWTLF7A.js +13883 -0
- package/vendor/chunk-2DA7EFZV.js +924 -0
- package/vendor/chunk-2S3OGPUC.js +58 -0
- package/vendor/chunk-473OA62O.js +26827 -0
- package/vendor/chunk-6JRWGOQG.js +236 -0
- package/vendor/chunk-7NOQSX4T.js +14 -0
- package/vendor/chunk-7NXKPDF3.js +1586 -0
- package/vendor/chunk-A4NKL2PK.js +153 -0
- package/vendor/chunk-A6WMU2GG.js +48 -0
- package/vendor/chunk-AFLKCQHF.js +73 -0
- package/vendor/chunk-BTS4ZTF3.js +43 -0
- package/vendor/chunk-C3N4N5HR.js +108 -0
- package/vendor/chunk-DXTAWHY3.js +25 -0
- package/vendor/chunk-G4IIVVJO.js +56 -0
- package/vendor/chunk-GELDEJJ2.js +4337 -0
- package/vendor/chunk-HFM6ROJL.js +188 -0
- package/vendor/chunk-HK2H3MVE.js +328 -0
- package/vendor/chunk-HZJK5RWC.js +5088 -0
- package/vendor/chunk-J2L726BC.js +2497 -0
- package/vendor/chunk-JBGD4JLR.js +3779 -0
- package/vendor/chunk-JJNLH5GA.js +2470 -0
- package/vendor/chunk-JKOG52PE.js +128 -0
- package/vendor/chunk-K2EIFEQF.js +89 -0
- package/vendor/chunk-KUIWH33N.js +16 -0
- package/vendor/chunk-NEWIOOM6.js +34 -0
- package/vendor/chunk-NM5NXCVM.js +2404 -0
- package/vendor/chunk-PT3AUPGE.js +459 -0
- package/vendor/chunk-PY5LYLV7.js +143 -0
- package/vendor/chunk-QIIKMG3M.js +103 -0
- package/vendor/chunk-QT24SAW6.js +110 -0
- package/vendor/chunk-RVYJKKWA.js +22 -0
- package/vendor/chunk-SKVYP7NY.js +1647 -0
- package/vendor/chunk-TSRPHKAC.js +780 -0
- package/vendor/chunk-UI5RLBKQ.js +30 -0
- package/vendor/chunk-VPC5NLZG.js +259 -0
- package/vendor/chunk-W2HNI6AA.js +75 -0
- package/vendor/chunk-X6M525ZJ.js +20 -0
- package/vendor/chunk-XIZVLPHZ.js +18 -0
- package/vendor/chunk-XNFVSVBS.js +242 -0
- package/vendor/chunk-YCDEMYY6.js +2076 -0
- package/vendor/chunk-YJ6XUZT6.js +292 -0
- package/vendor/chunk-YJWREXN6.js +26020 -0
- package/vendor/chunk-YK4F4VY2.js +173 -0
- package/vendor/chunk-YOFI4PCH.js +36 -0
- package/vendor/chunk-ZUGNCQZE.js +247 -0
- package/vendor/chunk-ZXX4ZNJY.js +21 -0
- package/vendor/cli.js +7 -0
- package/vendor/component-manifest-catalog.js +8 -0
- package/vendor/control-plane.js +23 -0
- package/vendor/package.json +1 -0
- package/vendor/privacy-service-bootstrap.js +6 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
resolveKoedServerPaths
|
|
4
|
+
} from "./chunk-K2EIFEQF.js";
|
|
5
|
+
|
|
6
|
+
// packages/koed-server/dist/daemon-start.js
|
|
7
|
+
import { spawn as nodeSpawn } from "node:child_process";
|
|
8
|
+
import { appendFileSync as appendFileSync2, closeSync, mkdirSync, openSync } from "node:fs";
|
|
9
|
+
import { resolve } from "node:path";
|
|
10
|
+
|
|
11
|
+
// packages/koed-server/dist/supervisor-log.js
|
|
12
|
+
import { appendFileSync, statSync, truncateSync } from "node:fs";
|
|
13
|
+
var SUPERVISOR_LOG_MAX_BYTES = 8 * 1024 * 1024;
|
|
14
|
+
var SUPERVISOR_LOG_CHECK_INTERVAL_MS = 5e3;
|
|
15
|
+
var capSupervisorLog = (logPath, maxBytes = SUPERVISOR_LOG_MAX_BYTES) => {
|
|
16
|
+
try {
|
|
17
|
+
if (statSync(logPath).size <= maxBytes)
|
|
18
|
+
return false;
|
|
19
|
+
truncateSync(logPath, 0);
|
|
20
|
+
appendFileSync(logPath, `[${(/* @__PURE__ */ new Date()).toISOString()}] Supervisor log exceeded ${maxBytes} bytes and was truncated.
|
|
21
|
+
`, { mode: 384 });
|
|
22
|
+
return true;
|
|
23
|
+
} catch (error) {
|
|
24
|
+
if (error.code === "ENOENT")
|
|
25
|
+
return false;
|
|
26
|
+
throw error;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var maintainSupervisorLog = (environment, options = {}) => {
|
|
30
|
+
const logPath = environment.KOED_SERVER_SUPERVISOR_LOG_PATH?.trim();
|
|
31
|
+
if (!logPath)
|
|
32
|
+
return () => void 0;
|
|
33
|
+
const maxBytes = options.maxBytes ?? SUPERVISOR_LOG_MAX_BYTES;
|
|
34
|
+
const cap = () => {
|
|
35
|
+
try {
|
|
36
|
+
capSupervisorLog(logPath, maxBytes);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.error(`Could not enforce supervisor log retention: ${error instanceof Error ? error.message : String(error)}`);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
cap();
|
|
42
|
+
const timer = (options.setInterval ?? setInterval)(cap, options.intervalMs ?? SUPERVISOR_LOG_CHECK_INTERVAL_MS);
|
|
43
|
+
timer.unref?.();
|
|
44
|
+
return () => (options.clearInterval ?? clearInterval)(timer);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// packages/koed-server/dist/daemon-start.js
|
|
48
|
+
var configuredDaemonInvocation = (environment) => {
|
|
49
|
+
const command = environment.KOED_SERVER_DAEMON_COMMAND?.trim();
|
|
50
|
+
const argsJson = environment.KOED_SERVER_DAEMON_ARGS_JSON?.trim();
|
|
51
|
+
if (!command || !argsJson) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const parsed = JSON.parse(argsJson);
|
|
56
|
+
if (!Array.isArray(parsed) || !parsed.every((arg) => typeof arg === "string")) {
|
|
57
|
+
throw new Error("KOED_SERVER_DAEMON_ARGS_JSON must be a string array.");
|
|
58
|
+
}
|
|
59
|
+
return { command, args: parsed };
|
|
60
|
+
} catch (error) {
|
|
61
|
+
throw new Error(`Could not parse KOED_SERVER_DAEMON_ARGS_JSON: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var startKoedServerDaemon = ({ environment = process.env, spawn = nodeSpawn, startCommand = process.argv[1], startArgs, cwd, resolvePaths = resolveKoedServerPaths } = {}) => {
|
|
65
|
+
const paths = resolvePaths(environment);
|
|
66
|
+
const configured = configuredDaemonInvocation(environment);
|
|
67
|
+
const command = configured?.command ?? process.execPath;
|
|
68
|
+
const args = configured?.args ?? startArgs ?? (startCommand ? [startCommand, "start"] : []);
|
|
69
|
+
if (args.length === 0) {
|
|
70
|
+
return {
|
|
71
|
+
ok: false,
|
|
72
|
+
state: "needs_attention",
|
|
73
|
+
koedHome: paths.koedHome,
|
|
74
|
+
message: "Could not resolve koed-server CLI path for daemon start.",
|
|
75
|
+
error: "Could not resolve koed-server CLI path for daemon start."
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
const logPath = resolve(paths.logsDir, "supervisor.log");
|
|
79
|
+
let stdoutFd;
|
|
80
|
+
let stderrFd;
|
|
81
|
+
try {
|
|
82
|
+
mkdirSync(paths.logsDir, { recursive: true, mode: 448 });
|
|
83
|
+
capSupervisorLog(logPath);
|
|
84
|
+
appendFileSync2(logPath, `
|
|
85
|
+
[${(/* @__PURE__ */ new Date()).toISOString()}] Starting koed-server supervisor.
|
|
86
|
+
`, { mode: 384 });
|
|
87
|
+
stdoutFd = openSync(logPath, "a", 384);
|
|
88
|
+
stderrFd = openSync(logPath, "a", 384);
|
|
89
|
+
const child = spawn(command, args, {
|
|
90
|
+
cwd: cwd ?? environment.KOED_REPO_ROOT ?? process.cwd(),
|
|
91
|
+
detached: true,
|
|
92
|
+
env: { ...environment, KOED_SERVER_SUPERVISOR_LOG_PATH: logPath },
|
|
93
|
+
stdio: ["ignore", stdoutFd, stderrFd]
|
|
94
|
+
});
|
|
95
|
+
if (!child.pid) {
|
|
96
|
+
throw new Error("koed-server daemon child process did not report a pid.");
|
|
97
|
+
}
|
|
98
|
+
child.unref();
|
|
99
|
+
return {
|
|
100
|
+
ok: true,
|
|
101
|
+
state: "starting",
|
|
102
|
+
koedHome: paths.koedHome,
|
|
103
|
+
message: "Koed server daemon start requested.",
|
|
104
|
+
startedPid: child.pid,
|
|
105
|
+
logPath
|
|
106
|
+
};
|
|
107
|
+
} catch (error) {
|
|
108
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
109
|
+
return {
|
|
110
|
+
ok: false,
|
|
111
|
+
state: "needs_attention",
|
|
112
|
+
koedHome: paths.koedHome,
|
|
113
|
+
message,
|
|
114
|
+
logPath,
|
|
115
|
+
error: message
|
|
116
|
+
};
|
|
117
|
+
} finally {
|
|
118
|
+
if (stdoutFd !== void 0)
|
|
119
|
+
closeSync(stdoutFd);
|
|
120
|
+
if (stderrFd !== void 0)
|
|
121
|
+
closeSync(stderrFd);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export {
|
|
126
|
+
maintainSupervisorLog,
|
|
127
|
+
startKoedServerDaemon
|
|
128
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
isPackagedRuntimeMode,
|
|
4
|
+
resolvePackagedResourcesPath
|
|
5
|
+
} from "./chunk-UI5RLBKQ.js";
|
|
6
|
+
|
|
7
|
+
// packages/koed-server/dist/paths.js
|
|
8
|
+
import { mkdirSync } from "node:fs";
|
|
9
|
+
import { homedir } from "node:os";
|
|
10
|
+
import { dirname, resolve } from "node:path";
|
|
11
|
+
import { fileURLToPath } from "node:url";
|
|
12
|
+
var packageDir = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
13
|
+
var resolveRepoRoot = (environment = process.env) => {
|
|
14
|
+
const fromEnv = environment.KOED_REPO_ROOT?.trim();
|
|
15
|
+
if (fromEnv) {
|
|
16
|
+
return resolve(fromEnv);
|
|
17
|
+
}
|
|
18
|
+
if (isPackagedRuntimeMode(environment)) {
|
|
19
|
+
const resourcesPath = resolvePackagedResourcesPath(environment);
|
|
20
|
+
if (resourcesPath) {
|
|
21
|
+
return resourcesPath;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return resolve(packageDir, "..", "..");
|
|
25
|
+
};
|
|
26
|
+
var documentationPlaceholderPath = (value) => {
|
|
27
|
+
const normalized = resolve(value);
|
|
28
|
+
return normalized === "/path" || normalized === "/path/to" || normalized.startsWith("/path/to/");
|
|
29
|
+
};
|
|
30
|
+
var resolveKoedHome = (environment = process.env) => {
|
|
31
|
+
const configured = environment.KOED_HOME?.trim();
|
|
32
|
+
const expanded = configured === "~" ? homedir() : configured?.startsWith("~/") || configured?.startsWith("~\\") ? resolve(homedir(), configured.slice(2)) : configured;
|
|
33
|
+
if (expanded && documentationPlaceholderPath(expanded)) {
|
|
34
|
+
throw new Error(`KOED_HOME is set to the documentation placeholder ${expanded}. Unset KOED_HOME or set it to a writable local state directory such as ${resolve(`${homedir()}/.koed`)}.`);
|
|
35
|
+
}
|
|
36
|
+
return resolve(expanded || `${homedir()}/.koed`);
|
|
37
|
+
};
|
|
38
|
+
var resolveKoedServerPaths = (environment = process.env) => {
|
|
39
|
+
const koedHome = resolveKoedHome(environment);
|
|
40
|
+
const repoRoot = resolveRepoRoot(environment);
|
|
41
|
+
const modelsDir = environment.KOED_MODELS_DIR?.trim() ? resolve(environment.KOED_MODELS_DIR) : resolve(koedHome, "models");
|
|
42
|
+
return {
|
|
43
|
+
koedHome,
|
|
44
|
+
configDir: resolve(koedHome, "config"),
|
|
45
|
+
logsDir: resolve(koedHome, "logs"),
|
|
46
|
+
runDir: resolve(koedHome, "run"),
|
|
47
|
+
dataDir: resolve(koedHome, "data"),
|
|
48
|
+
modelsDir,
|
|
49
|
+
cacheDir: resolve(koedHome, "cache"),
|
|
50
|
+
componentsDir: resolve(koedHome, "runtime", "components"),
|
|
51
|
+
generationsDir: resolve(koedHome, "runtime", "generations"),
|
|
52
|
+
postgresDataDir: resolve(koedHome, "data", "postgres"),
|
|
53
|
+
postgresRunDir: resolve(koedHome, "run", "postgres"),
|
|
54
|
+
postgresLogPath: resolve(koedHome, "logs", "postgres.log"),
|
|
55
|
+
runtimeStatePath: resolve(koedHome, "run", "koed-server.json"),
|
|
56
|
+
generationStatePath: resolve(koedHome, "run", "runtime-generation.json"),
|
|
57
|
+
lastVerificationPath: resolve(koedHome, "run", "last-verification.json"),
|
|
58
|
+
serverConfigPath: resolve(koedHome, "config", "server.json"),
|
|
59
|
+
localPortsPath: resolve(koedHome, "config", "local-ports.json"),
|
|
60
|
+
localAppCredentialPath: resolve(koedHome, "config", "local-app-credential.json"),
|
|
61
|
+
upstreamBackendsPath: resolve(koedHome, "config", "upstream-backends.json"),
|
|
62
|
+
projectMetadataPath: resolve(koedHome, "config", "projects.json"),
|
|
63
|
+
projectTeamWorkspaceLinksPath: resolve(koedHome, "config", "project-team-workspaces.json"),
|
|
64
|
+
upstreamEnrollmentsPath: resolve(koedHome, "run", "upstream-enrollments.json"),
|
|
65
|
+
upstreamDisconnectCleanupPath: resolve(koedHome, "run", "upstream-disconnect-cleanup.json"),
|
|
66
|
+
repoRoot
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
var ensureKoedHome = (paths) => {
|
|
70
|
+
for (const dir of [
|
|
71
|
+
paths.koedHome,
|
|
72
|
+
paths.configDir,
|
|
73
|
+
paths.logsDir,
|
|
74
|
+
paths.runDir,
|
|
75
|
+
paths.dataDir,
|
|
76
|
+
paths.modelsDir,
|
|
77
|
+
paths.cacheDir,
|
|
78
|
+
paths.postgresDataDir,
|
|
79
|
+
paths.postgresRunDir
|
|
80
|
+
]) {
|
|
81
|
+
mkdirSync(dir, { recursive: true, mode: 448 });
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export {
|
|
86
|
+
resolveKoedHome,
|
|
87
|
+
resolveKoedServerPaths,
|
|
88
|
+
ensureKoedHome
|
|
89
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
collectLocalModelStatus,
|
|
4
|
+
installLocalModel,
|
|
5
|
+
localModelKinds,
|
|
6
|
+
resolveLocalModelManifest,
|
|
7
|
+
sha256File
|
|
8
|
+
} from "./chunk-ZUGNCQZE.js";
|
|
9
|
+
import "./chunk-BTS4ZTF3.js";
|
|
10
|
+
export {
|
|
11
|
+
collectLocalModelStatus,
|
|
12
|
+
installLocalModel,
|
|
13
|
+
localModelKinds,
|
|
14
|
+
resolveLocalModelManifest,
|
|
15
|
+
sha256File
|
|
16
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
clearUpstreamBackendCapabilities,
|
|
4
|
+
collectUpstreamRegistryStatus,
|
|
5
|
+
getActiveUpstreamBackend,
|
|
6
|
+
listUpstreamBackends,
|
|
7
|
+
refreshUpstreamBackendCapabilities,
|
|
8
|
+
registerUpstreamBackend,
|
|
9
|
+
removeUpstreamBackend,
|
|
10
|
+
setActiveUpstreamBackend,
|
|
11
|
+
updateUpstreamBackendCredential,
|
|
12
|
+
updateUpstreamBackendRoutePolicy,
|
|
13
|
+
upstreamBackendAdvertisesCapability,
|
|
14
|
+
upstreamBackendSupportsTeamMemoryAnswerTasks
|
|
15
|
+
} from "./chunk-YJWREXN6.js";
|
|
16
|
+
import {
|
|
17
|
+
isTeamMemoryAnswerTaskCapability
|
|
18
|
+
} from "./chunk-473OA62O.js";
|
|
19
|
+
import "./chunk-BTS4ZTF3.js";
|
|
20
|
+
export {
|
|
21
|
+
clearUpstreamBackendCapabilities,
|
|
22
|
+
collectUpstreamRegistryStatus,
|
|
23
|
+
getActiveUpstreamBackend,
|
|
24
|
+
isTeamMemoryAnswerTaskCapability,
|
|
25
|
+
listUpstreamBackends,
|
|
26
|
+
refreshUpstreamBackendCapabilities,
|
|
27
|
+
registerUpstreamBackend,
|
|
28
|
+
removeUpstreamBackend,
|
|
29
|
+
setActiveUpstreamBackend,
|
|
30
|
+
updateUpstreamBackendCredential,
|
|
31
|
+
updateUpstreamBackendRoutePolicy,
|
|
32
|
+
upstreamBackendAdvertisesCapability,
|
|
33
|
+
upstreamBackendSupportsTeamMemoryAnswerTasks
|
|
34
|
+
};
|