@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.
Files changed (56) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +64 -2
  3. package/bin/koed.js +7 -0
  4. package/package.json +26 -4
  5. package/third-party-notices.json +92 -0
  6. package/vendor/chunk-2BWTLF7A.js +13883 -0
  7. package/vendor/chunk-2DA7EFZV.js +924 -0
  8. package/vendor/chunk-2S3OGPUC.js +58 -0
  9. package/vendor/chunk-473OA62O.js +26827 -0
  10. package/vendor/chunk-6JRWGOQG.js +236 -0
  11. package/vendor/chunk-7NOQSX4T.js +14 -0
  12. package/vendor/chunk-7NXKPDF3.js +1586 -0
  13. package/vendor/chunk-A4NKL2PK.js +153 -0
  14. package/vendor/chunk-A6WMU2GG.js +48 -0
  15. package/vendor/chunk-AFLKCQHF.js +73 -0
  16. package/vendor/chunk-BTS4ZTF3.js +43 -0
  17. package/vendor/chunk-C3N4N5HR.js +108 -0
  18. package/vendor/chunk-DXTAWHY3.js +25 -0
  19. package/vendor/chunk-G4IIVVJO.js +56 -0
  20. package/vendor/chunk-GELDEJJ2.js +4337 -0
  21. package/vendor/chunk-HFM6ROJL.js +188 -0
  22. package/vendor/chunk-HK2H3MVE.js +328 -0
  23. package/vendor/chunk-HZJK5RWC.js +5088 -0
  24. package/vendor/chunk-J2L726BC.js +2497 -0
  25. package/vendor/chunk-JBGD4JLR.js +3779 -0
  26. package/vendor/chunk-JJNLH5GA.js +2470 -0
  27. package/vendor/chunk-JKOG52PE.js +128 -0
  28. package/vendor/chunk-K2EIFEQF.js +89 -0
  29. package/vendor/chunk-KUIWH33N.js +16 -0
  30. package/vendor/chunk-NEWIOOM6.js +34 -0
  31. package/vendor/chunk-NM5NXCVM.js +2404 -0
  32. package/vendor/chunk-PT3AUPGE.js +459 -0
  33. package/vendor/chunk-PY5LYLV7.js +143 -0
  34. package/vendor/chunk-QIIKMG3M.js +103 -0
  35. package/vendor/chunk-QT24SAW6.js +110 -0
  36. package/vendor/chunk-RVYJKKWA.js +22 -0
  37. package/vendor/chunk-SKVYP7NY.js +1647 -0
  38. package/vendor/chunk-TSRPHKAC.js +780 -0
  39. package/vendor/chunk-UI5RLBKQ.js +30 -0
  40. package/vendor/chunk-VPC5NLZG.js +259 -0
  41. package/vendor/chunk-W2HNI6AA.js +75 -0
  42. package/vendor/chunk-X6M525ZJ.js +20 -0
  43. package/vendor/chunk-XIZVLPHZ.js +18 -0
  44. package/vendor/chunk-XNFVSVBS.js +242 -0
  45. package/vendor/chunk-YCDEMYY6.js +2076 -0
  46. package/vendor/chunk-YJ6XUZT6.js +292 -0
  47. package/vendor/chunk-YJWREXN6.js +26020 -0
  48. package/vendor/chunk-YK4F4VY2.js +173 -0
  49. package/vendor/chunk-YOFI4PCH.js +36 -0
  50. package/vendor/chunk-ZUGNCQZE.js +247 -0
  51. package/vendor/chunk-ZXX4ZNJY.js +21 -0
  52. package/vendor/cli.js +7 -0
  53. package/vendor/component-manifest-catalog.js +8 -0
  54. package/vendor/control-plane.js +23 -0
  55. package/vendor/package.json +1 -0
  56. package/vendor/privacy-service-bootstrap.js +6 -0
@@ -0,0 +1,103 @@
1
+ import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
2
+
3
+ // packages/koed-server/dist/component-manifest-catalog.js
4
+ var record = (value, keys) => {
5
+ if (!value || typeof value !== "object" || Array.isArray(value))
6
+ throw new Error("Invalid component pin catalog record.");
7
+ const result = value;
8
+ if (Object.keys(result).length !== keys.length || keys.some((key) => !Object.hasOwn(result, key)))
9
+ throw new Error("Invalid component pin catalog fields.");
10
+ return result;
11
+ };
12
+ var validVersion = (value) => typeof value === "string" && /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(value);
13
+ var manifestPinKey = ({ component, target, variant }) => JSON.stringify([
14
+ component,
15
+ target.platform,
16
+ target.architecture,
17
+ target.libc?.family ?? null,
18
+ target.libc?.minimumVersion ?? null,
19
+ ...variant === void 0 ? [] : [variant]
20
+ ]);
21
+ function validateEntry(value) {
22
+ const entry = record(value, [
23
+ "component",
24
+ "target",
25
+ "manifestSha256",
26
+ ...value && typeof value === "object" && Object.hasOwn(value, "variant") ? ["variant"] : []
27
+ ]);
28
+ if (entry.component !== "base" && entry.component !== "privacy" || typeof entry.manifestSha256 !== "string" || !/^[a-f0-9]{64}$/.test(entry.manifestSha256))
29
+ throw new Error("Invalid component pin catalog entry.");
30
+ if (Object.hasOwn(entry, "variant") && (entry.component !== "privacy" || !["cpu", "cuda"].includes(String(entry.variant))))
31
+ throw new Error("Invalid component pin variant.");
32
+ const rawTarget = entry.target;
33
+ const target = record(rawTarget, rawTarget && Object.hasOwn(rawTarget, "libc") ? ["platform", "architecture", "libc"] : ["platform", "architecture"]);
34
+ if (target.platform !== "linux" && target.platform !== "macos" || target.architecture !== "arm64" && target.architecture !== "x64")
35
+ throw new Error("Invalid component pin target.");
36
+ if (entry.variant !== void 0 && (target.platform !== "linux" || target.architecture !== "x64"))
37
+ throw new Error("Invalid component pin variant target.");
38
+ let libc;
39
+ if (Object.hasOwn(target, "libc")) {
40
+ const value2 = record(target.libc, ["family", "minimumVersion"]);
41
+ if (target.platform !== "linux" || value2.family !== "glibc" || typeof value2.minimumVersion !== "string" || !/^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:\.(?:0|[1-9]\d*))?$/.test(value2.minimumVersion))
42
+ throw new Error("Invalid component pin libc target.");
43
+ libc = Object.freeze({
44
+ family: "glibc",
45
+ minimumVersion: value2.minimumVersion
46
+ });
47
+ }
48
+ return Object.freeze({
49
+ component: entry.component,
50
+ ...entry.variant === void 0 ? {} : { variant: entry.variant },
51
+ manifestSha256: entry.manifestSha256,
52
+ target: Object.freeze({
53
+ platform: target.platform,
54
+ architecture: target.architecture,
55
+ ...libc ? { libc } : {}
56
+ })
57
+ });
58
+ }
59
+ function validateManifestCatalog(value) {
60
+ const input = record(value, ["schemaVersion", "productVersion", "entries"]);
61
+ if (input.schemaVersion !== 1 && input.schemaVersion !== 2 || !validVersion(input.productVersion) || !Array.isArray(input.entries) || input.entries.length === 0)
62
+ throw new Error("Invalid component pin catalog identity or entries.");
63
+ const entries = input.entries.map(validateEntry);
64
+ const identities = new Set(entries.map(manifestPinKey));
65
+ if (identities.size !== entries.length)
66
+ throw new Error("Duplicate component pin catalog identity.");
67
+ const variants = entries.filter((entry) => entry.variant !== void 0);
68
+ if (input.schemaVersion === 1 && variants.length)
69
+ throw new Error("Legacy component catalog cannot authenticate variants.");
70
+ if (input.schemaVersion === 2) {
71
+ if (variants.length === 0)
72
+ throw new Error("Privacy variant catalog is incomplete.");
73
+ for (const entry of entries.filter((entry2) => entry2.component === "privacy" && entry2.target.platform === "linux")) {
74
+ if (entry.variant === void 0 || !["cpu", "cuda"].every((variant) => entries.some((other) => other.component === "privacy" && other.variant === variant && manifestPinKey({ ...other, variant: void 0 }) === manifestPinKey({ ...entry, variant: void 0 }))))
75
+ throw new Error("Privacy variant catalog is incomplete or ambiguous.");
76
+ }
77
+ }
78
+ return Object.freeze({
79
+ schemaVersion: input.schemaVersion,
80
+ productVersion: input.productVersion,
81
+ entries: Object.freeze(entries)
82
+ });
83
+ }
84
+ function lookupManifestPin(catalog, identity) {
85
+ if (!catalog)
86
+ throw new Error("Component manifest pin catalog is unavailable; use a trusted versioned control plane.");
87
+ if (catalog.productVersion !== identity.productVersion)
88
+ throw new Error("Component pin catalog version mismatch.");
89
+ const key = manifestPinKey(identity);
90
+ const entry = catalog.entries.find((entry2) => manifestPinKey(entry2) === key);
91
+ if (!entry)
92
+ throw new Error("Required component manifest pin is missing from this control plane.");
93
+ return entry.manifestSha256;
94
+ }
95
+
96
+ // packages/koed-server/dist/component-manifest-catalog-data.js
97
+ var productionComponentManifestCatalog = validateManifestCatalog({ "schemaVersion": 2, "productVersion": "0.10.3", "entries": [{ "component": "base", "manifestSha256": "cfa106faf481eb5a62e5dbe9c90a7447037adbee1996ddca7cd614b142364000", "target": { "platform": "linux", "architecture": "x64", "libc": { "family": "glibc", "minimumVersion": "2.35" } } }, { "component": "base", "manifestSha256": "c4c9052f81cbcd51285c0e35afedffa7e4db976f9e6a2fb45c9658004e84214c", "target": { "platform": "macos", "architecture": "arm64" } }, { "component": "privacy", "variant": "cpu", "manifestSha256": "ae4188f582c5bc6018f76f8e4c830b3cf2ea8baccaa2fb9bc850efc4fd0bd328", "target": { "platform": "linux", "architecture": "x64", "libc": { "family": "glibc", "minimumVersion": "2.35" } } }, { "component": "privacy", "variant": "cuda", "manifestSha256": "6d93a1e8d30643b5afa365a2cd48e3b6554e930b2ca0e71caa9b2fcc1a6f1819", "target": { "platform": "linux", "architecture": "x64", "libc": { "family": "glibc", "minimumVersion": "2.35" } } }, { "component": "privacy", "manifestSha256": "cf6f8fd24cfc42519fcbcd8ff072fc89aa1166aa37acd54add46fdce1f460857", "target": { "platform": "macos", "architecture": "arm64" } }] });
98
+
99
+ export {
100
+ validateManifestCatalog,
101
+ lookupManifestPin,
102
+ productionComponentManifestCatalog
103
+ };
@@ -0,0 +1,110 @@
1
+ import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
2
+
3
+ // packages/koed-server/dist/credentials.js
4
+ import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
5
+ import { randomUUID } from "node:crypto";
6
+ import { dirname, resolve } from "node:path";
7
+ var usableToken = (value) => {
8
+ const trimmed = value?.trim();
9
+ return trimmed && !trimmed.startsWith("replace_with_") ? trimmed : null;
10
+ };
11
+ var tokenFrom = (values) => {
12
+ for (const value of values) {
13
+ const token = usableToken(value);
14
+ if (token) {
15
+ return token;
16
+ }
17
+ }
18
+ return null;
19
+ };
20
+ var resolveLocalApiToken = (environment, repoEnv) => {
21
+ const envToken = tokenFrom([
22
+ environment.MEMORY_API_TOKEN,
23
+ environment.CODEX_MEMORY_API_TOKEN
24
+ ]);
25
+ if (envToken) {
26
+ return { token: envToken, source: "environment" };
27
+ }
28
+ const repoToken = tokenFrom([
29
+ repoEnv.MEMORY_API_TOKEN,
30
+ repoEnv.CODEX_MEMORY_API_TOKEN
31
+ ]);
32
+ if (repoToken) {
33
+ return { token: repoToken, source: "repo-env" };
34
+ }
35
+ return null;
36
+ };
37
+ var writeLocalAppCredential = (paths, credential) => {
38
+ const target = resolve(paths.localAppCredentialPath);
39
+ mkdirSync(dirname(target), { recursive: true, mode: 448 });
40
+ try {
41
+ if (lstatSync(target).isSymbolicLink()) {
42
+ throw new Error("Local API Token credential must not be a symbolic link.");
43
+ }
44
+ } catch (error) {
45
+ if (error.code !== "ENOENT")
46
+ throw error;
47
+ }
48
+ const temporary = `${target}.${process.pid}.${randomUUID()}.tmp`;
49
+ try {
50
+ writeFileSync(temporary, `${JSON.stringify(credential, null, 2)}
51
+ `, {
52
+ mode: 384,
53
+ flag: "wx"
54
+ });
55
+ chmodSync(temporary, 384);
56
+ renameSync(temporary, target);
57
+ chmodSync(target, 384);
58
+ } catch (error) {
59
+ try {
60
+ unlinkSync(temporary);
61
+ } catch {
62
+ }
63
+ throw error;
64
+ }
65
+ };
66
+ var loadLocalAppCredential = (paths) => {
67
+ if (!existsSync(paths.localAppCredentialPath)) {
68
+ return null;
69
+ }
70
+ try {
71
+ const parsed = JSON.parse(readFileSync(paths.localAppCredentialPath, "utf8"));
72
+ if (typeof parsed?.apiToken !== "string" || !parsed.apiToken.trim()) {
73
+ return null;
74
+ }
75
+ return {
76
+ apiToken: parsed.apiToken.trim(),
77
+ provisionedAt: parsed.provisionedAt ?? "unknown",
78
+ source: parsed.source ?? "repo-env"
79
+ };
80
+ } catch {
81
+ return null;
82
+ }
83
+ };
84
+ var resolveActiveIntegrationApiToken = (paths, environment, repoEnv) => {
85
+ const localAppCredential = loadLocalAppCredential(paths);
86
+ if (environment.KOED_AUTO_PORTS === "1" && localAppCredential?.apiToken) {
87
+ return {
88
+ token: localAppCredential.apiToken,
89
+ source: "local-app-credential"
90
+ };
91
+ }
92
+ const localToken = resolveLocalApiToken(environment, repoEnv);
93
+ if (localToken) {
94
+ return localToken;
95
+ }
96
+ if (localAppCredential?.apiToken) {
97
+ return {
98
+ token: localAppCredential.apiToken,
99
+ source: "local-app-credential"
100
+ };
101
+ }
102
+ return null;
103
+ };
104
+
105
+ export {
106
+ resolveLocalApiToken,
107
+ writeLocalAppCredential,
108
+ loadLocalAppCredential,
109
+ resolveActiveIntegrationApiToken
110
+ };
@@ -0,0 +1,22 @@
1
+ import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
2
+ import {
3
+ cancelUpstreamEnrollment,
4
+ disconnectUpstreamBackendEnrollment,
5
+ getUpstreamEnrollmentStatus,
6
+ invalidateUpstreamEnrollmentReferences,
7
+ readUpstreamEnrollmentBinding,
8
+ startUpstreamEnrollment
9
+ } from "./chunk-SKVYP7NY.js";
10
+ import "./chunk-YJWREXN6.js";
11
+ import "./chunk-XNFVSVBS.js";
12
+ import "./chunk-7NXKPDF3.js";
13
+ import "./chunk-473OA62O.js";
14
+ import "./chunk-BTS4ZTF3.js";
15
+ export {
16
+ cancelUpstreamEnrollment,
17
+ disconnectUpstreamBackendEnrollment,
18
+ getUpstreamEnrollmentStatus,
19
+ invalidateUpstreamEnrollmentReferences,
20
+ readUpstreamEnrollmentBinding,
21
+ startUpstreamEnrollment
22
+ };