@koed-labs/server 0.0.0-stage → 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 +64 -2
- package/bin/koed.js +7 -0
- package/package.json +26 -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,153 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// packages/koed-server/dist/app-runtime.js
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
6
|
+
import { dirname, resolve } from "node:path";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
var packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
|
9
|
+
var sourceCheckoutRoot = resolve(packageRoot, "..", "..");
|
|
10
|
+
var isSourceCheckoutControlPlane = () => existsSync(resolve(sourceCheckoutRoot, "pnpm-workspace.yaml")) && existsSync(resolve(packageRoot, "package.json"));
|
|
11
|
+
var resolveKoedAppRuntimeExecution = () => isSourceCheckoutControlPlane() ? "source" : "packaged";
|
|
12
|
+
var resolveKoedRuntimeOwner = () => ({
|
|
13
|
+
kind: "standalone",
|
|
14
|
+
installationId: createHash("sha256").update(realpathSync.native(packageRoot)).digest("hex").slice(0, 32)
|
|
15
|
+
});
|
|
16
|
+
var resolveKoedControlPlaneVersion = () => {
|
|
17
|
+
const value = JSON.parse(readFileSync(resolve(packageRoot, "package.json"), "utf8"));
|
|
18
|
+
if (!value || typeof value !== "object" || !("version" in value) || typeof value.version !== "string" || !/^[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9A-Za-z.-]+)?$/.test(value.version))
|
|
19
|
+
throw new Error("Koed server control-plane version is invalid.");
|
|
20
|
+
return value.version;
|
|
21
|
+
};
|
|
22
|
+
var sourceRuntime = (paths, exists) => {
|
|
23
|
+
const root = paths.repoRoot;
|
|
24
|
+
const apiEntry = resolve(root, "apps/api/dist/index.js");
|
|
25
|
+
const workerEntry = resolve(root, "apps/worker/dist/index.js");
|
|
26
|
+
const embeddingServiceEntry = resolve(root, "apps/embedding-service/dist/index.js");
|
|
27
|
+
const privacyServiceEntry = resolve(root, "apps/privacy-service/dist/index.js");
|
|
28
|
+
const mcpCli = resolve(root, "packages/mcp-server/dist/cli.js");
|
|
29
|
+
const localAiRuntime = resolve(root, "packages/mcp-server/dist/local-runtime-cli.js");
|
|
30
|
+
const captureHook = resolve(root, "packages/mcp-server/dist/capture-hook.js");
|
|
31
|
+
const dbPackageRoot = resolve(root, "packages/db");
|
|
32
|
+
const required = [
|
|
33
|
+
resolve(root, "scripts/setup-env.mjs"),
|
|
34
|
+
resolve(root, "apps/api/package.json"),
|
|
35
|
+
resolve(root, "apps/worker/package.json"),
|
|
36
|
+
resolve(root, "apps/privacy-service/package.json"),
|
|
37
|
+
resolve(root, "packages/db/package.json"),
|
|
38
|
+
resolve(root, "packages/mcp-server/package.json")
|
|
39
|
+
];
|
|
40
|
+
return {
|
|
41
|
+
kind: "source",
|
|
42
|
+
artifactSource: "source-checkout",
|
|
43
|
+
root,
|
|
44
|
+
apiEntry,
|
|
45
|
+
workerEntry,
|
|
46
|
+
embeddingServiceEntry,
|
|
47
|
+
privacyServiceEntry,
|
|
48
|
+
mcpCli,
|
|
49
|
+
localAiRuntime,
|
|
50
|
+
captureHook,
|
|
51
|
+
dbPackageRoot,
|
|
52
|
+
missing: required.filter((entry) => !exists(entry))
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
var requiredProcesses = [
|
|
56
|
+
"api",
|
|
57
|
+
"worker",
|
|
58
|
+
"local-ai-runtime",
|
|
59
|
+
"embedding-service"
|
|
60
|
+
];
|
|
61
|
+
var effectiveRequirements = (requirements) => requirements ?? {
|
|
62
|
+
components: ["base"],
|
|
63
|
+
processes: requiredProcesses,
|
|
64
|
+
queue: "bullmq",
|
|
65
|
+
native: [],
|
|
66
|
+
models: []
|
|
67
|
+
};
|
|
68
|
+
var packagedRuntime = (selection, requirements, exists) => {
|
|
69
|
+
const root = selection?.base.root ?? "";
|
|
70
|
+
const apiEntry = resolve(root, "api/dist/index.js");
|
|
71
|
+
const workerEntry = resolve(root, "worker/dist/index.js");
|
|
72
|
+
const embeddingServiceEntry = resolve(root, "embedding-service/dist/index.js");
|
|
73
|
+
const privacyServiceEntry = selection?.privacy ? resolve(selection.privacy.root, "privacy-service/dist/index.js") : void 0;
|
|
74
|
+
const mcpCli = resolve(root, "mcp-server/dist/cli.js");
|
|
75
|
+
const localAiRuntime = resolve(root, "mcp-server/dist/local-runtime-cli.js");
|
|
76
|
+
const captureHook = resolve(root, "mcp-server/dist/capture-hook.js");
|
|
77
|
+
const dbPackageRoot = resolve(root, "node_modules/@koed/db");
|
|
78
|
+
const required = [
|
|
79
|
+
...selection ? [] : ["authenticated base generation"],
|
|
80
|
+
...requirements.processes.includes("api") ? [apiEntry] : [],
|
|
81
|
+
...requirements.processes.includes("worker") ? [workerEntry] : [],
|
|
82
|
+
...requirements.processes.includes("embedding-service") ? [embeddingServiceEntry] : [],
|
|
83
|
+
...requirements.processes.includes("local-ai-runtime") ? [mcpCli, localAiRuntime, captureHook] : [],
|
|
84
|
+
...requirements.components.includes("privacy") ? [
|
|
85
|
+
...privacyServiceEntry ? [privacyServiceEntry] : ["authenticated privacy generation"]
|
|
86
|
+
] : [],
|
|
87
|
+
...requirements.processes.includes("api") || requirements.processes.includes("worker") ? [
|
|
88
|
+
resolve(dbPackageRoot, "dist/index.js"),
|
|
89
|
+
resolve(dbPackageRoot, "dist/connection.js"),
|
|
90
|
+
resolve(dbPackageRoot, "dist/user-api-token-repository.js"),
|
|
91
|
+
resolve(dbPackageRoot, "drizzle/meta/_journal.json")
|
|
92
|
+
] : []
|
|
93
|
+
];
|
|
94
|
+
return {
|
|
95
|
+
kind: "packaged",
|
|
96
|
+
artifactSource: "verified-generation",
|
|
97
|
+
...selection ? { generationId: selection.id } : {},
|
|
98
|
+
...selection?.privacy ? {
|
|
99
|
+
privacyManifestDigest: selection.privacy.manifestDigest,
|
|
100
|
+
...selection.privacy.manifest.variant ? { privacyVariant: selection.privacy.manifest.variant } : {}
|
|
101
|
+
} : {},
|
|
102
|
+
root,
|
|
103
|
+
apiEntry,
|
|
104
|
+
workerEntry,
|
|
105
|
+
embeddingServiceEntry,
|
|
106
|
+
...privacyServiceEntry ? { privacyServiceEntry } : {},
|
|
107
|
+
mcpCli,
|
|
108
|
+
localAiRuntime,
|
|
109
|
+
captureHook,
|
|
110
|
+
dbPackageRoot,
|
|
111
|
+
missing: required.filter((entry) => entry.startsWith("authenticated ") ? true : !exists(entry))
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
var rejectUntrustedPackagedOverrides = (environment) => {
|
|
115
|
+
const overrideNames = [
|
|
116
|
+
"KOED_JS_RUNTIME_ROOT",
|
|
117
|
+
"KOED_REPO_ROOT",
|
|
118
|
+
"KOED_PACKAGED_RESOURCES_PATH",
|
|
119
|
+
"KOED_ALLOW_PACKAGED_SOURCE_FALLBACK"
|
|
120
|
+
];
|
|
121
|
+
const supplied = overrideNames.filter((name) => environment[name]?.trim());
|
|
122
|
+
if (supplied.length > 0) {
|
|
123
|
+
throw new Error(`Unsupported packaged runtime override: ${supplied.join(", ")}. Packaged services require a verified generation.`);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
var resolveKoedAppRuntimeForExecution = (paths, environment, exists, selection, requirements, execution) => {
|
|
127
|
+
if (execution === "source")
|
|
128
|
+
return sourceRuntime(paths, exists);
|
|
129
|
+
rejectUntrustedPackagedOverrides(environment);
|
|
130
|
+
return packagedRuntime(selection, effectiveRequirements(requirements), exists);
|
|
131
|
+
};
|
|
132
|
+
var resolveKoedAppRuntime = (paths, environment = process.env, exists = existsSync, selection, requirements) => resolveKoedAppRuntimeForExecution(paths, environment, exists, selection, requirements, resolveKoedAppRuntimeExecution());
|
|
133
|
+
var assertKoedAppRuntimeAvailable = (runtime, paths) => {
|
|
134
|
+
if (runtime.missing.length === 0)
|
|
135
|
+
return;
|
|
136
|
+
if (runtime.kind === "packaged") {
|
|
137
|
+
throw new Error([
|
|
138
|
+
"Packaged Koed JS runtime artifacts are missing.",
|
|
139
|
+
`Missing authenticated runtime files under ${runtime.root || "verified generation"}: ${runtime.missing.join(", ")}.`,
|
|
140
|
+
"Install a compatible signed Koed runtime generation; packaged startup never downloads or uses checkout files."
|
|
141
|
+
].join(" "));
|
|
142
|
+
}
|
|
143
|
+
void paths;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export {
|
|
147
|
+
resolveKoedAppRuntimeExecution,
|
|
148
|
+
resolveKoedRuntimeOwner,
|
|
149
|
+
resolveKoedControlPlaneVersion,
|
|
150
|
+
resolveKoedAppRuntimeForExecution,
|
|
151
|
+
resolveKoedAppRuntime,
|
|
152
|
+
assertKoedAppRuntimeAvailable
|
|
153
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
runApplicationSecretProvider
|
|
4
|
+
} from "./chunk-2S3OGPUC.js";
|
|
5
|
+
import "./chunk-K2EIFEQF.js";
|
|
6
|
+
import "./chunk-UI5RLBKQ.js";
|
|
7
|
+
import "./chunk-473OA62O.js";
|
|
8
|
+
import "./chunk-BTS4ZTF3.js";
|
|
9
|
+
|
|
10
|
+
// packages/koed-server/dist/cli-internal-operations.js
|
|
11
|
+
import { readSync } from "node:fs";
|
|
12
|
+
var readSecretStdin = () => {
|
|
13
|
+
const maximum = 2e6;
|
|
14
|
+
const buffer = Buffer.allocUnsafe(maximum + 1);
|
|
15
|
+
let offset = 0;
|
|
16
|
+
try {
|
|
17
|
+
while (offset < buffer.length) {
|
|
18
|
+
const count = readSync(0, buffer, offset, buffer.length - offset, null);
|
|
19
|
+
if (count === 0)
|
|
20
|
+
break;
|
|
21
|
+
offset += count;
|
|
22
|
+
}
|
|
23
|
+
if (offset > maximum)
|
|
24
|
+
return null;
|
|
25
|
+
return buffer.subarray(0, offset).toString("utf8");
|
|
26
|
+
} finally {
|
|
27
|
+
buffer.fill(0);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
var runSecretProviderCommand = async (operation, reference, dependencies) => {
|
|
31
|
+
const stdout = dependencies.stdout ?? process.stdout;
|
|
32
|
+
try {
|
|
33
|
+
const value = operation === "put" ? readSecretStdin() : void 0;
|
|
34
|
+
if (operation === "put" && value === null)
|
|
35
|
+
return 1;
|
|
36
|
+
const result = await runApplicationSecretProvider(operation, reference, value ?? void 0, process.env);
|
|
37
|
+
if (!result.ok)
|
|
38
|
+
return 1;
|
|
39
|
+
if (operation === "get" && result.value !== null)
|
|
40
|
+
stdout.write(result.value);
|
|
41
|
+
return 0;
|
|
42
|
+
} catch {
|
|
43
|
+
return 1;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
export {
|
|
47
|
+
runSecretProviderCommand
|
|
48
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
resolveKoedServerConfig
|
|
4
|
+
} from "./chunk-NM5NXCVM.js";
|
|
5
|
+
import {
|
|
6
|
+
parseEnvFile
|
|
7
|
+
} from "./chunk-W2HNI6AA.js";
|
|
8
|
+
import {
|
|
9
|
+
resolveTeamCollaborationEnabled
|
|
10
|
+
} from "./chunk-473OA62O.js";
|
|
11
|
+
|
|
12
|
+
// packages/koed-server/dist/effective-runtime-config.js
|
|
13
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
14
|
+
import { resolve } from "node:path";
|
|
15
|
+
function resolveEffectiveRuntimeConfig(paths, environment, execution) {
|
|
16
|
+
const envPath = environment.KOED_ENV_PATH?.trim() ? resolve(environment.KOED_ENV_PATH) : execution === "source" ? resolve(paths.repoRoot, ".env") : void 0;
|
|
17
|
+
let fileEnvironment = {};
|
|
18
|
+
if (envPath) {
|
|
19
|
+
if (!existsSync(envPath)) {
|
|
20
|
+
if (environment.KOED_ENV_PATH?.trim()) {
|
|
21
|
+
throw new Error(`Explicit environment file does not exist: ${envPath}`);
|
|
22
|
+
}
|
|
23
|
+
} else {
|
|
24
|
+
fileEnvironment = parseEnvFile(readFileSync(envPath, "utf8"), {
|
|
25
|
+
strict: Boolean(environment.KOED_ENV_PATH?.trim()),
|
|
26
|
+
source: envPath
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const effectiveEnvironment = { ...fileEnvironment, ...environment };
|
|
31
|
+
const config = resolveKoedServerConfig(paths, effectiveEnvironment, {
|
|
32
|
+
strict: execution === "packaged" || Boolean(environment.KOED_ENV_PATH?.trim())
|
|
33
|
+
});
|
|
34
|
+
return {
|
|
35
|
+
config,
|
|
36
|
+
environment: effectiveEnvironment,
|
|
37
|
+
teamEnabled: resolveTeamCollaborationEnabled(effectiveEnvironment),
|
|
38
|
+
explicitWorkQueueBackend: environment.WORK_QUEUE_BACKEND?.trim() || null
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function calculateRuntimeRequirements(effective) {
|
|
42
|
+
const localPrivacy = effective.config.dependencyMode === "bundled-local" && effective.teamEnabled;
|
|
43
|
+
const components = localPrivacy ? ["base", "privacy"] : ["base"];
|
|
44
|
+
const processes = [
|
|
45
|
+
"api",
|
|
46
|
+
"worker"
|
|
47
|
+
];
|
|
48
|
+
if (effective.config.runtimeMode !== "external")
|
|
49
|
+
processes.push("local-ai-runtime");
|
|
50
|
+
if (effective.config.dependencyMode === "bundled-local") {
|
|
51
|
+
processes.push("postgres", "embedding-service");
|
|
52
|
+
if (localPrivacy)
|
|
53
|
+
processes.push("privacy-service");
|
|
54
|
+
}
|
|
55
|
+
const bundled = effective.config.dependencyMode === "bundled-local";
|
|
56
|
+
const queueValue = effective.explicitWorkQueueBackend === null ? bundled ? void 0 : effective.environment.WORK_QUEUE_BACKEND?.trim() : effective.explicitWorkQueueBackend ?? effective.environment.WORK_QUEUE_BACKEND?.trim();
|
|
57
|
+
if (queueValue && queueValue !== "local" && queueValue !== "bullmq") {
|
|
58
|
+
throw new Error('WORK_QUEUE_BACKEND must be "local" or "bullmq"');
|
|
59
|
+
}
|
|
60
|
+
const queue = queueValue === "local" || queueValue === "bullmq" ? queueValue : effective.config.dependencyMode === "bundled-local" ? "local" : "bullmq";
|
|
61
|
+
return {
|
|
62
|
+
components,
|
|
63
|
+
processes,
|
|
64
|
+
queue,
|
|
65
|
+
native: bundled ? ["postgres", "llama-server"] : [],
|
|
66
|
+
models: bundled ? localPrivacy ? ["embedding", "privacy"] : ["embedding"] : []
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export {
|
|
71
|
+
resolveEffectiveRuntimeConfig,
|
|
72
|
+
calculateRuntimeRequirements
|
|
73
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
9
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
10
|
+
}) : x)(function(x) {
|
|
11
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
12
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
+
});
|
|
14
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
15
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
|
+
};
|
|
17
|
+
var __export = (target, all) => {
|
|
18
|
+
for (var name in all)
|
|
19
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
+
};
|
|
21
|
+
var __copyProps = (to, from, except, desc) => {
|
|
22
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(from))
|
|
24
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
+
}
|
|
27
|
+
return to;
|
|
28
|
+
};
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
+
mod
|
|
36
|
+
));
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
__require,
|
|
40
|
+
__commonJS,
|
|
41
|
+
__export,
|
|
42
|
+
__toESM
|
|
43
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
checkCoreSetupNeeded,
|
|
4
|
+
createCliServiceContext,
|
|
5
|
+
deviceRequestCommand,
|
|
6
|
+
printJson
|
|
7
|
+
} from "./chunk-YCDEMYY6.js";
|
|
8
|
+
import "./chunk-HZJK5RWC.js";
|
|
9
|
+
import "./chunk-QT24SAW6.js";
|
|
10
|
+
import "./chunk-SKVYP7NY.js";
|
|
11
|
+
import "./chunk-HFM6ROJL.js";
|
|
12
|
+
import "./chunk-AFLKCQHF.js";
|
|
13
|
+
import "./chunk-NM5NXCVM.js";
|
|
14
|
+
import "./chunk-G4IIVVJO.js";
|
|
15
|
+
import "./chunk-JKOG52PE.js";
|
|
16
|
+
import "./chunk-A4NKL2PK.js";
|
|
17
|
+
import "./chunk-QIIKMG3M.js";
|
|
18
|
+
import "./chunk-2DA7EFZV.js";
|
|
19
|
+
import "./chunk-VPC5NLZG.js";
|
|
20
|
+
import "./chunk-YJWREXN6.js";
|
|
21
|
+
import "./chunk-J2L726BC.js";
|
|
22
|
+
import "./chunk-2S3OGPUC.js";
|
|
23
|
+
import "./chunk-XNFVSVBS.js";
|
|
24
|
+
import "./chunk-7NXKPDF3.js";
|
|
25
|
+
import "./chunk-K2EIFEQF.js";
|
|
26
|
+
import "./chunk-UI5RLBKQ.js";
|
|
27
|
+
import "./chunk-W2HNI6AA.js";
|
|
28
|
+
import "./chunk-473OA62O.js";
|
|
29
|
+
import "./chunk-ZUGNCQZE.js";
|
|
30
|
+
import "./chunk-BTS4ZTF3.js";
|
|
31
|
+
|
|
32
|
+
// packages/koed-server/dist/cli-pair-operations.js
|
|
33
|
+
var runPairCommand = async (subcommand, options, dependencies) => {
|
|
34
|
+
const { startDaemon, collectStartupStatus, resolvePaths, stdout, stderr } = createCliServiceContext(dependencies);
|
|
35
|
+
const deviceRequestCommand2 = dependencies.deviceRequest ?? deviceRequestCommand;
|
|
36
|
+
const wantsJson = options.json;
|
|
37
|
+
try {
|
|
38
|
+
const paths = resolvePaths();
|
|
39
|
+
const setupNeeded = checkCoreSetupNeeded(paths);
|
|
40
|
+
if (subcommand === "status" || subcommand === "cancel") {
|
|
41
|
+
const value = await deviceRequestCommand2(paths, subcommand);
|
|
42
|
+
if (wantsJson)
|
|
43
|
+
printJson(stdout, value);
|
|
44
|
+
else
|
|
45
|
+
stdout.write(`${value.state}
|
|
46
|
+
`);
|
|
47
|
+
return 0;
|
|
48
|
+
}
|
|
49
|
+
if (setupNeeded) {
|
|
50
|
+
stderr.write(`${setupNeeded}
|
|
51
|
+
`);
|
|
52
|
+
return 1;
|
|
53
|
+
}
|
|
54
|
+
let ready = await collectStartupStatus();
|
|
55
|
+
if (!ready.ok) {
|
|
56
|
+
const started = startDaemon();
|
|
57
|
+
if (!started.ok)
|
|
58
|
+
throw new Error(started.error ?? started.message);
|
|
59
|
+
for (let attempt = 0; attempt < 90 && !ready.ok; attempt += 1) {
|
|
60
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
61
|
+
ready = await collectStartupStatus();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (!ready.ok)
|
|
65
|
+
throw new Error("Koed could not start. Run koed doctor for setup guidance.");
|
|
66
|
+
const initial = await deviceRequestCommand2(paths, "create", options.deviceLabel);
|
|
67
|
+
if (wantsJson)
|
|
68
|
+
printJson(stdout, initial);
|
|
69
|
+
else
|
|
70
|
+
stdout.write(initial.link ? `Paste this request into Devices \u2192 Add device on your existing Koed installation:
|
|
71
|
+
|
|
72
|
+
${initial.link}
|
|
73
|
+
|
|
74
|
+
Expires ${initial.expiresAt}. Waiting for approval\u2026
|
|
75
|
+
` : `Enrollment is ${initial.state}. Waiting\u2026
|
|
76
|
+
`);
|
|
77
|
+
if (options.detach)
|
|
78
|
+
return 0;
|
|
79
|
+
let previous = initial.state;
|
|
80
|
+
for (; ; ) {
|
|
81
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
82
|
+
const value = await deviceRequestCommand2(paths, "status");
|
|
83
|
+
if (value.state !== previous) {
|
|
84
|
+
if (wantsJson)
|
|
85
|
+
printJson(stdout, value);
|
|
86
|
+
else
|
|
87
|
+
stdout.write(`${value.state}
|
|
88
|
+
`);
|
|
89
|
+
previous = value.state;
|
|
90
|
+
}
|
|
91
|
+
if (value.state === "connected")
|
|
92
|
+
return 0;
|
|
93
|
+
if (["failed", "expired", "cancelled"].includes(value.state))
|
|
94
|
+
return 1;
|
|
95
|
+
}
|
|
96
|
+
} catch (error) {
|
|
97
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
98
|
+
if (wantsJson)
|
|
99
|
+
printJson(stdout, { ok: false, error: message });
|
|
100
|
+
else
|
|
101
|
+
stderr.write(`${message}
|
|
102
|
+
`);
|
|
103
|
+
return 1;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
export {
|
|
107
|
+
runPairCommand
|
|
108
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
decryptRecoveryKit,
|
|
4
|
+
encryptRecoveryKit,
|
|
5
|
+
parseLoopbackOrigin,
|
|
6
|
+
personalSyncProviderEnvironment,
|
|
7
|
+
redeemPairingLink,
|
|
8
|
+
runPersonalSyncCommand
|
|
9
|
+
} from "./chunk-J2L726BC.js";
|
|
10
|
+
import "./chunk-2S3OGPUC.js";
|
|
11
|
+
import "./chunk-XNFVSVBS.js";
|
|
12
|
+
import "./chunk-7NXKPDF3.js";
|
|
13
|
+
import "./chunk-K2EIFEQF.js";
|
|
14
|
+
import "./chunk-UI5RLBKQ.js";
|
|
15
|
+
import "./chunk-W2HNI6AA.js";
|
|
16
|
+
import "./chunk-473OA62O.js";
|
|
17
|
+
import "./chunk-BTS4ZTF3.js";
|
|
18
|
+
export {
|
|
19
|
+
decryptRecoveryKit,
|
|
20
|
+
encryptRecoveryKit,
|
|
21
|
+
parseLoopbackOrigin,
|
|
22
|
+
personalSyncProviderEnvironment,
|
|
23
|
+
redeemPairingLink,
|
|
24
|
+
runPersonalSyncCommand
|
|
25
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// packages/koed-server/dist/runtime-state.js
|
|
4
|
+
import { readFileSync as nodeReadFileSync } from "node:fs";
|
|
5
|
+
|
|
6
|
+
// packages/koed-server/dist/process-liveness.js
|
|
7
|
+
var isProcessRunning = (pid) => {
|
|
8
|
+
try {
|
|
9
|
+
process.kill(pid, 0);
|
|
10
|
+
return true;
|
|
11
|
+
} catch {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// packages/koed-server/dist/runtime-state.js
|
|
17
|
+
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18
|
+
var validHttpUrl = (value) => {
|
|
19
|
+
if (typeof value !== "string")
|
|
20
|
+
return false;
|
|
21
|
+
try {
|
|
22
|
+
return ["http:", "https:"].includes(new URL(value).protocol);
|
|
23
|
+
} catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var validProcessMap = (value) => value === void 0 || isRecord(value) && Object.values(value).every((pid) => typeof pid === "number" && Number.isInteger(pid) && pid >= 0);
|
|
28
|
+
var validRuntimeState = (value) => {
|
|
29
|
+
if (!isRecord(value))
|
|
30
|
+
return false;
|
|
31
|
+
const validRuntimeMode = value.runtimeMode === void 0 || value.runtimeMode === "local-personal" || value.runtimeMode === "external" || value.runtimeMode === "developer";
|
|
32
|
+
const validDependencyMode = value.dependencyMode === void 0 || value.dependencyMode === "bundled-local" || value.dependencyMode === "external";
|
|
33
|
+
const validAutomaticPorts = value.automaticPorts === void 0 || typeof value.automaticPorts === "boolean";
|
|
34
|
+
return typeof value.pid === "number" && Number.isInteger(value.pid) && value.pid > 0 && typeof value.startedAt === "string" && !Number.isNaN(Date.parse(value.startedAt)) && typeof value.repoRoot === "string" && Boolean(value.repoRoot.trim()) && validHttpUrl(value.apiUrl) && Array.isArray(value.services) && value.services.every((service) => typeof service === "string") && validRuntimeMode && validDependencyMode && validAutomaticPorts && validProcessMap(value.processes);
|
|
35
|
+
};
|
|
36
|
+
var isRuntimeGenerationState = (value) => isRecord(value) && (Object.keys(value).length === 7 || Object.keys(value).length === 8 && ["manifest-pinned-store", "signed-store", "desktop-bundle"].includes(String(value.source))) && value.schemaVersion === 1 && typeof value.generationId === "string" && /^[a-f0-9]{64}$/.test(value.generationId) && typeof value.pid === "number" && Number.isInteger(value.pid) && value.pid > 0 && typeof value.processIdentity === "string" && value.processIdentity.length > 0 && typeof value.startedAt === "string" && !Number.isNaN(Date.parse(value.startedAt)) && isRecord(value.owner) && Object.keys(value.owner).length === 2 && ["cli", "desktop", "standalone"].includes(String(value.owner.kind)) && typeof value.owner.installationId === "string" && /^[A-Za-z0-9._-]{1,128}$/.test(value.owner.installationId) && typeof value.pinToken === "string" && /^[a-f0-9]{64}$/.test(value.pinToken);
|
|
37
|
+
var readActiveRuntimeState = (path, readFileSync = nodeReadFileSync, checkPid = isProcessRunning) => {
|
|
38
|
+
try {
|
|
39
|
+
const parsed = JSON.parse(String(readFileSync(path, "utf8")));
|
|
40
|
+
return validRuntimeState(parsed) && checkPid(parsed.pid) ? parsed : null;
|
|
41
|
+
} catch {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var applyActiveRuntimeUrls = (environment, runtime) => ({
|
|
46
|
+
...environment,
|
|
47
|
+
...runtime?.apiUrl ? { MEMORY_API_URL: runtime.apiUrl } : {},
|
|
48
|
+
...runtime?.automaticPorts ? { KOED_AUTO_PORTS: "1" } : {}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
export {
|
|
52
|
+
isProcessRunning,
|
|
53
|
+
isRuntimeGenerationState,
|
|
54
|
+
readActiveRuntimeState,
|
|
55
|
+
applyActiveRuntimeUrls
|
|
56
|
+
};
|