@koed-labs/server 0.0.0-stage → 0.11.1
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-2XKSVKQA.js +49 -0
- package/vendor/chunk-4OO6VAU3.js +259 -0
- package/vendor/chunk-53ZFCDHP.js +332 -0
- package/vendor/chunk-6JRWGOQG.js +236 -0
- package/vendor/chunk-6KS67EQE.js +75 -0
- package/vendor/chunk-7EGSY3E4.js +8 -0
- package/vendor/chunk-7FSHVVTZ.js +128 -0
- package/vendor/chunk-7NOQSX4T.js +14 -0
- package/vendor/chunk-7NXKPDF3.js +1586 -0
- package/vendor/chunk-ALJUSOF7.js +175 -0
- package/vendor/chunk-AVQCUFYQ.js +16 -0
- package/vendor/chunk-BGENSONI.js +18 -0
- package/vendor/chunk-BTS4ZTF3.js +43 -0
- package/vendor/chunk-BUIM2M4R.js +22 -0
- package/vendor/chunk-C4V72GXC.js +194 -0
- package/vendor/chunk-C5SNDPAP.js +2472 -0
- package/vendor/chunk-CHMH4LH5.js +2497 -0
- package/vendor/chunk-EA4QDDQA.js +58 -0
- package/vendor/chunk-EDPNYIX5.js +5448 -0
- package/vendor/chunk-FN3HUUO2.js +1974 -0
- package/vendor/chunk-FSNLU46W.js +14548 -0
- package/vendor/chunk-FYYRFX4U.js +4423 -0
- package/vendor/chunk-GFASBPV2.js +42 -0
- package/vendor/chunk-HC76426R.js +48 -0
- package/vendor/chunk-IY2HRXOZ.js +99 -0
- package/vendor/chunk-JBGD4JLR.js +3779 -0
- package/vendor/chunk-JYK6UL6D.js +261 -0
- package/vendor/chunk-LRP66XEY.js +13907 -0
- package/vendor/chunk-NOU7RHYZ.js +26 -0
- package/vendor/chunk-NVTMIAAF.js +113 -0
- package/vendor/chunk-O7DW2VAV.js +14 -0
- package/vendor/chunk-OCILJ737.js +299 -0
- package/vendor/chunk-PL3LWC5C.js +754 -0
- package/vendor/chunk-QRKHHWJJ.js +104 -0
- package/vendor/chunk-QT24SAW6.js +110 -0
- package/vendor/chunk-RCR4XPE3.js +26020 -0
- package/vendor/chunk-SHLRINKO.js +73 -0
- package/vendor/chunk-SNKWETM5.js +35 -0
- package/vendor/chunk-SRKIBFOE.js +242 -0
- package/vendor/chunk-T6UB5PNX.js +124 -0
- package/vendor/chunk-TG26CZGQ.js +23 -0
- package/vendor/chunk-TISYUUEJ.js +188 -0
- package/vendor/chunk-TSAYTRX3.js +89 -0
- package/vendor/chunk-TVYEB2GN.js +343 -0
- package/vendor/chunk-UB6JCVQ3.js +461 -0
- package/vendor/chunk-V67IQB7H.js +153 -0
- package/vendor/chunk-VGIYSDNU.js +522 -0
- package/vendor/chunk-W2HNI6AA.js +75 -0
- package/vendor/chunk-W2OJZZ6X.js +20 -0
- package/vendor/chunk-WDFERJG3.js +2208 -0
- package/vendor/chunk-WPIEF4LY.js +1647 -0
- package/vendor/chunk-XIZVLPHZ.js +18 -0
- package/vendor/chunk-YZLQZU5E.js +46 -0
- package/vendor/chunk-Z5WCAUA6.js +148 -0
- package/vendor/chunk-ZIOKV2X6.js +1589 -0
- package/vendor/chunk-ZOHNXUDY.js +12501 -0
- package/vendor/chunk-ZUDSZGVO.js +11 -0
- package/vendor/cli.js +7 -0
- package/vendor/component-manifest-catalog.js +9 -0
- package/vendor/control-plane.js +28 -0
- package/vendor/package.json +1 -0
- package/vendor/privacy-service-bootstrap.js +6 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// packages/koed-server/dist/project-team-workspace-links.js
|
|
4
|
+
import { existsSync, readFileSync, renameSync, writeFileSync, mkdirSync } from "node:fs";
|
|
5
|
+
import { dirname, resolve } from "node:path";
|
|
6
|
+
import { createHash } from "node:crypto";
|
|
7
|
+
var depsWithDefaults = (deps = {}) => ({
|
|
8
|
+
existsSync: deps.existsSync ?? existsSync,
|
|
9
|
+
readFileSync: deps.readFileSync ?? readFileSync,
|
|
10
|
+
writeFileSync: deps.writeFileSync ?? writeFileSync,
|
|
11
|
+
renameSync: deps.renameSync ?? renameSync,
|
|
12
|
+
mkdirSync: deps.mkdirSync ?? mkdirSync,
|
|
13
|
+
now: deps.now ?? (() => /* @__PURE__ */ new Date())
|
|
14
|
+
});
|
|
15
|
+
var uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
16
|
+
var normalizeProjectRoot = (projectRoot) => {
|
|
17
|
+
const trimmed = projectRoot.trim();
|
|
18
|
+
if (!trimmed) {
|
|
19
|
+
throw new Error("Project root is required.");
|
|
20
|
+
}
|
|
21
|
+
return resolve(trimmed);
|
|
22
|
+
};
|
|
23
|
+
var validateTeamWorkspaceId = (teamWorkspaceId) => {
|
|
24
|
+
const trimmed = teamWorkspaceId.trim();
|
|
25
|
+
if (!uuidPattern.test(trimmed)) {
|
|
26
|
+
throw new Error("Team Workspace id must be a UUID.");
|
|
27
|
+
}
|
|
28
|
+
return trimmed;
|
|
29
|
+
};
|
|
30
|
+
var validateBackendId = (backendId) => {
|
|
31
|
+
const trimmed = backendId?.trim();
|
|
32
|
+
if (!trimmed) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
if (!/^[a-zA-Z0-9][a-zA-Z0-9_-]{1,63}$/.test(trimmed)) {
|
|
36
|
+
throw new Error("Backend id must be 2-64 characters of letters, numbers, hyphen, or underscore.");
|
|
37
|
+
}
|
|
38
|
+
return trimmed;
|
|
39
|
+
};
|
|
40
|
+
var linkIdForProjectRoot = (projectRoot) => `ptw_${createHash("sha256").update(projectRoot).digest("hex").slice(0, 16)}`;
|
|
41
|
+
var validateLocalProjectId = (value) => {
|
|
42
|
+
if (typeof value !== "string")
|
|
43
|
+
return null;
|
|
44
|
+
const trimmed = value.trim();
|
|
45
|
+
return /^lp_[a-f0-9]{16,64}$/i.test(trimmed) ? trimmed : null;
|
|
46
|
+
};
|
|
47
|
+
var validateIdentityId = (value) => typeof value === "string" && uuidPattern.test(value.trim()) ? value.trim().toLowerCase() : null;
|
|
48
|
+
var normalizeLink = (value) => {
|
|
49
|
+
if (typeof value.projectRoot !== "string" || typeof value.teamWorkspaceId !== "string") {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const projectRoot = normalizeProjectRoot(value.projectRoot);
|
|
53
|
+
const teamWorkspaceId = validateTeamWorkspaceId(value.teamWorkspaceId);
|
|
54
|
+
const backendId = typeof value.backendId === "string" ? validateBackendId(value.backendId) : null;
|
|
55
|
+
const remotePrincipalId = validateIdentityId(value.remotePrincipalId);
|
|
56
|
+
const deviceCredentialId = validateIdentityId(value.deviceCredentialId);
|
|
57
|
+
if (backendId && (!remotePrincipalId || !deviceCredentialId))
|
|
58
|
+
return null;
|
|
59
|
+
return {
|
|
60
|
+
id: typeof value.id === "string" ? value.id : linkIdForProjectRoot(projectRoot),
|
|
61
|
+
projectRoot,
|
|
62
|
+
teamWorkspaceId,
|
|
63
|
+
backendId,
|
|
64
|
+
remotePrincipalId: backendId ? remotePrincipalId : null,
|
|
65
|
+
deviceCredentialId: backendId ? deviceCredentialId : null,
|
|
66
|
+
localProjectId: validateLocalProjectId(value.localProjectId),
|
|
67
|
+
projectDisplayName: typeof value.projectDisplayName === "string" && value.projectDisplayName.trim() ? value.projectDisplayName.trim().slice(0, 120) : null,
|
|
68
|
+
createdAt: typeof value.createdAt === "string" ? value.createdAt : (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
69
|
+
updatedAt: typeof value.updatedAt === "string" ? value.updatedAt : (/* @__PURE__ */ new Date(0)).toISOString()
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
var readStore = (paths, deps) => {
|
|
73
|
+
const now = deps.now().toISOString();
|
|
74
|
+
if (!deps.existsSync(paths.projectTeamWorkspaceLinksPath)) {
|
|
75
|
+
return { schemaVersion: 1, updatedAt: now, links: [] };
|
|
76
|
+
}
|
|
77
|
+
try {
|
|
78
|
+
const parsed = JSON.parse(deps.readFileSync(paths.projectTeamWorkspaceLinksPath, "utf8"));
|
|
79
|
+
return {
|
|
80
|
+
schemaVersion: parsed.schemaVersion === 2 ? 2 : 1,
|
|
81
|
+
updatedAt: typeof parsed.updatedAt === "string" ? parsed.updatedAt : now,
|
|
82
|
+
links: Array.isArray(parsed.links) ? parsed.links.map((link) => normalizeLink(link)).filter((link) => Boolean(link)) : []
|
|
83
|
+
};
|
|
84
|
+
} catch (error) {
|
|
85
|
+
throw new Error("Project Team Workspace link config is malformed.", {
|
|
86
|
+
cause: error
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
var writeStore = (paths, store, deps) => {
|
|
91
|
+
deps.mkdirSync(dirname(paths.projectTeamWorkspaceLinksPath), {
|
|
92
|
+
recursive: true,
|
|
93
|
+
mode: 448
|
|
94
|
+
});
|
|
95
|
+
const tmpPath = `${paths.projectTeamWorkspaceLinksPath}.tmp`;
|
|
96
|
+
deps.writeFileSync(tmpPath, `${JSON.stringify(store, null, 2)}
|
|
97
|
+
`, {
|
|
98
|
+
mode: 384
|
|
99
|
+
});
|
|
100
|
+
deps.renameSync(tmpPath, paths.projectTeamWorkspaceLinksPath);
|
|
101
|
+
};
|
|
102
|
+
var linkProjectTeamWorkspace = (paths, input, depsInput = {}) => {
|
|
103
|
+
const deps = depsWithDefaults(depsInput);
|
|
104
|
+
const now = deps.now().toISOString();
|
|
105
|
+
const projectRoot = normalizeProjectRoot(input.projectRoot);
|
|
106
|
+
const teamWorkspaceId = validateTeamWorkspaceId(input.teamWorkspaceId);
|
|
107
|
+
const backendId = validateBackendId(input.backendId);
|
|
108
|
+
const remotePrincipalId = validateIdentityId(input.remotePrincipalId);
|
|
109
|
+
const deviceCredentialId = validateIdentityId(input.deviceCredentialId);
|
|
110
|
+
if (backendId && (!remotePrincipalId || !deviceCredentialId)) {
|
|
111
|
+
throw new Error("Backend Project links require the remote principal and device credential identity.");
|
|
112
|
+
}
|
|
113
|
+
const store = readStore(paths, deps);
|
|
114
|
+
const existing = store.links.find((link2) => link2.projectRoot === projectRoot);
|
|
115
|
+
const link = {
|
|
116
|
+
id: existing?.id ?? linkIdForProjectRoot(projectRoot),
|
|
117
|
+
projectRoot,
|
|
118
|
+
teamWorkspaceId,
|
|
119
|
+
backendId,
|
|
120
|
+
remotePrincipalId: backendId ? remotePrincipalId : null,
|
|
121
|
+
deviceCredentialId: backendId ? deviceCredentialId : null,
|
|
122
|
+
localProjectId: validateLocalProjectId(input.localProjectId) ?? existing?.localProjectId ?? null,
|
|
123
|
+
projectDisplayName: input.projectDisplayName?.trim() ? input.projectDisplayName.trim().slice(0, 120) : existing?.projectDisplayName ?? null,
|
|
124
|
+
createdAt: existing?.createdAt ?? now,
|
|
125
|
+
updatedAt: now
|
|
126
|
+
};
|
|
127
|
+
const nextLinks = [
|
|
128
|
+
...store.links.filter((candidate) => candidate.projectRoot !== projectRoot),
|
|
129
|
+
link
|
|
130
|
+
].sort((left, right) => left.projectRoot.localeCompare(right.projectRoot));
|
|
131
|
+
writeStore(paths, { schemaVersion: 2, updatedAt: now, links: nextLinks }, deps);
|
|
132
|
+
return {
|
|
133
|
+
ok: true,
|
|
134
|
+
state: "linked",
|
|
135
|
+
message: "Project linked to Team Workspace.",
|
|
136
|
+
link
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
var listProjectTeamWorkspaceLinks = (paths, depsInput = {}) => {
|
|
140
|
+
const store = readStore(paths, depsWithDefaults(depsInput));
|
|
141
|
+
return {
|
|
142
|
+
ok: true,
|
|
143
|
+
state: "listed",
|
|
144
|
+
message: `Found ${store.links.length} Project Team Workspace link(s).`,
|
|
145
|
+
links: store.links
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
var getProjectTeamWorkspaceLink = (paths, projectRoot, depsInput = {}) => {
|
|
149
|
+
const normalizedProjectRoot = normalizeProjectRoot(projectRoot);
|
|
150
|
+
const store = readStore(paths, depsWithDefaults(depsInput));
|
|
151
|
+
const link = store.links.find((candidate) => candidate.projectRoot === normalizedProjectRoot) ?? null;
|
|
152
|
+
if (!link) {
|
|
153
|
+
return {
|
|
154
|
+
ok: false,
|
|
155
|
+
state: "missing",
|
|
156
|
+
message: "Project is not linked to a Team Workspace."
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
ok: true,
|
|
161
|
+
state: "found",
|
|
162
|
+
message: "Project Team Workspace link found.",
|
|
163
|
+
link
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
var removeProjectTeamWorkspaceLink = (paths, projectRoot, depsInput = {}) => {
|
|
167
|
+
const deps = depsWithDefaults(depsInput);
|
|
168
|
+
const normalizedProjectRoot = normalizeProjectRoot(projectRoot);
|
|
169
|
+
const store = readStore(paths, deps);
|
|
170
|
+
const existing = store.links.find((candidate) => candidate.projectRoot === normalizedProjectRoot);
|
|
171
|
+
if (!existing) {
|
|
172
|
+
return {
|
|
173
|
+
ok: false,
|
|
174
|
+
state: "missing",
|
|
175
|
+
message: "Project is not linked to a Team Workspace."
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
const now = deps.now().toISOString();
|
|
179
|
+
writeStore(paths, {
|
|
180
|
+
schemaVersion: 2,
|
|
181
|
+
updatedAt: now,
|
|
182
|
+
links: store.links.filter((candidate) => candidate.projectRoot !== normalizedProjectRoot)
|
|
183
|
+
}, deps);
|
|
184
|
+
return {
|
|
185
|
+
ok: true,
|
|
186
|
+
state: "removed",
|
|
187
|
+
message: "Project Team Workspace link removed.",
|
|
188
|
+
link: existing
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
var removeProjectTeamWorkspaceLinksForBackend = (paths, backendId, depsInput = {}) => {
|
|
192
|
+
const deps = depsWithDefaults(depsInput);
|
|
193
|
+
const normalizedBackendId = validateBackendId(backendId);
|
|
194
|
+
if (!normalizedBackendId)
|
|
195
|
+
return 0;
|
|
196
|
+
const store = readStore(paths, deps);
|
|
197
|
+
const links = store.links.filter((link) => link.backendId !== normalizedBackendId);
|
|
198
|
+
const removed = store.links.length - links.length;
|
|
199
|
+
if (removed === 0)
|
|
200
|
+
return 0;
|
|
201
|
+
writeStore(paths, {
|
|
202
|
+
schemaVersion: 2,
|
|
203
|
+
updatedAt: deps.now().toISOString(),
|
|
204
|
+
links
|
|
205
|
+
}, deps);
|
|
206
|
+
return removed;
|
|
207
|
+
};
|
|
208
|
+
var removeProjectTeamWorkspaceLinksForMismatchedBinding = (paths, input, depsInput = {}) => {
|
|
209
|
+
const deps = depsWithDefaults(depsInput);
|
|
210
|
+
const backendId = validateBackendId(input.backendId);
|
|
211
|
+
const remotePrincipalId = validateIdentityId(input.remotePrincipalId);
|
|
212
|
+
const deviceCredentialId = validateIdentityId(input.deviceCredentialId);
|
|
213
|
+
if (!backendId || !remotePrincipalId || !deviceCredentialId) {
|
|
214
|
+
throw new Error("Project link binding is invalid.");
|
|
215
|
+
}
|
|
216
|
+
const store = readStore(paths, deps);
|
|
217
|
+
const nextLinks = store.links.filter((link) => link.backendId !== backendId || link.remotePrincipalId === remotePrincipalId && link.deviceCredentialId === deviceCredentialId);
|
|
218
|
+
const removed = store.links.length - nextLinks.length;
|
|
219
|
+
if (removed === 0)
|
|
220
|
+
return 0;
|
|
221
|
+
writeStore(paths, {
|
|
222
|
+
schemaVersion: 2,
|
|
223
|
+
updatedAt: deps.now().toISOString(),
|
|
224
|
+
links: nextLinks
|
|
225
|
+
}, deps);
|
|
226
|
+
return removed;
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
export {
|
|
230
|
+
linkProjectTeamWorkspace,
|
|
231
|
+
listProjectTeamWorkspaceLinks,
|
|
232
|
+
getProjectTeamWorkspaceLink,
|
|
233
|
+
removeProjectTeamWorkspaceLink,
|
|
234
|
+
removeProjectTeamWorkspaceLinksForBackend,
|
|
235
|
+
removeProjectTeamWorkspaceLinksForMismatchedBinding
|
|
236
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
aiClientConnectionRevision,
|
|
4
|
+
grantAiClientConnection,
|
|
5
|
+
revokeAiClientConnection
|
|
6
|
+
} from "./chunk-EDPNYIX5.js";
|
|
7
|
+
|
|
8
|
+
// packages/koed-server/dist/ai-client-authorization.js
|
|
9
|
+
var clientNames = {
|
|
10
|
+
codex: "Codex",
|
|
11
|
+
claude: "Claude Code",
|
|
12
|
+
pi: "Pi"
|
|
13
|
+
};
|
|
14
|
+
var failed = (result, error) => ({
|
|
15
|
+
...result,
|
|
16
|
+
ok: false,
|
|
17
|
+
error
|
|
18
|
+
});
|
|
19
|
+
var noteAiClientConnectionRevision = (koedHome, client) => {
|
|
20
|
+
try {
|
|
21
|
+
return aiClientConnectionRevision(koedHome, client);
|
|
22
|
+
} catch {
|
|
23
|
+
revokeAiClientConnection(koedHome, client);
|
|
24
|
+
return aiClientConnectionRevision(koedHome, client);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var connectAiClientAfterSetup = async ({ client, koedHome, run, verify }) => {
|
|
28
|
+
const name = clientNames[client];
|
|
29
|
+
const revision = noteAiClientConnectionRevision(koedHome, client);
|
|
30
|
+
const result = await run();
|
|
31
|
+
if (!result.ok)
|
|
32
|
+
return result;
|
|
33
|
+
if (result.koedHome !== koedHome)
|
|
34
|
+
return failed(result, `${name} was set up for a different KOED_HOME; capture stays off.`);
|
|
35
|
+
let verified = false;
|
|
36
|
+
try {
|
|
37
|
+
verified = await verify(koedHome);
|
|
38
|
+
} catch {
|
|
39
|
+
verified = false;
|
|
40
|
+
}
|
|
41
|
+
if (!verified)
|
|
42
|
+
return failed(result, `Could not verify the ${name} integration for this KOED_HOME; capture stays off.`);
|
|
43
|
+
let granted = false;
|
|
44
|
+
try {
|
|
45
|
+
granted = grantAiClientConnection(koedHome, client, revision);
|
|
46
|
+
} catch (error) {
|
|
47
|
+
return failed(result, `${name} could not be connected; capture stays off. ${error instanceof Error ? error.message : String(error)}`);
|
|
48
|
+
}
|
|
49
|
+
return granted ? result : failed(result, `${name} changed while setup ran (for example, it was removed); capture stays off. Set it up again to connect it.`);
|
|
50
|
+
};
|
|
51
|
+
var disconnectAiClientThenRemove = ({ client, koedHome, remove }) => {
|
|
52
|
+
let revocationError = null;
|
|
53
|
+
try {
|
|
54
|
+
revokeAiClientConnection(koedHome, client);
|
|
55
|
+
} catch (error) {
|
|
56
|
+
revocationError = error instanceof Error ? error.message : String(error);
|
|
57
|
+
}
|
|
58
|
+
const result = remove();
|
|
59
|
+
if (revocationError !== null)
|
|
60
|
+
return failed(result, `${clientNames[client]} could not be disconnected; Koed may still read its conversations. ${revocationError}`);
|
|
61
|
+
return result;
|
|
62
|
+
};
|
|
63
|
+
var verifyAiClientIntegration = async (client, koedHome, environment, collectStatus, dependencies = {}) => {
|
|
64
|
+
const status = await collectStatus({ ...environment, KOED_HOME: koedHome }, { ...dependencies, revokeAiClientConnection: () => false });
|
|
65
|
+
const inspected = client === "codex" ? status.codex : client === "claude" ? status.claudeCode : status.pi;
|
|
66
|
+
const details = inspected?.details;
|
|
67
|
+
return status.koedHome === koedHome && inspected?.configured === true && (client !== "codex" || details?.configuredKoedHome === koedHome && typeof details.mcpAdapter === "string");
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export {
|
|
71
|
+
noteAiClientConnectionRevision,
|
|
72
|
+
connectAiClientAfterSetup,
|
|
73
|
+
disconnectAiClientThenRemove,
|
|
74
|
+
verifyAiClientIntegration
|
|
75
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// packages/koed-server/dist/native-runtime-catalog-data.mjs
|
|
4
|
+
var productionNativeRuntimeCatalog = { "schemaVersion": 1, "minimumCoreVersion": "0.10.3", "core": { "recipeId": "3772839512c2caebac0f9d27b4d2da2bb345ac713dce414019068bcef2e008a5", "runtimeVersion": "0.11.1", "url": "https://github.com/koed-labs/koed/releases/download/v0.11.1/koed-native-core-3772839512c2caebac0f9d27b4d2da2bb345ac713dce414019068bcef2e008a5-linux-x64.tar.gz", "sha256": "eba95ee796f67c3d8f2468e2bb98a313a92f6180144e255a9b127d7783b7b8a7", "manifestSha256": "56da4b6e4870782dda6892e48dbef64226910d2862cfaf23585a71e0651418b6", "target": { "platform": "linux", "architecture": "x64", "libc": { "family": "glibc", "minimumVersion": "2.35" } }, "archiveBytes": 23988984, "expandedBytes": 56990680, "contracts": { "layout": 1, "embedding": 1, "postgres": 1 }, "components": { "postgres": { "major": 17, "version": "17.6" }, "pgvector": { "version": "0.8.3" }, "llamaCpp": { "version": "b10514", "revision": "7221e24f579efbb5fd2a2ced1fffaef1aff2fe0d" } } }, "cuda": { "recipeId": "5fc63b4396c94d35c3f9c30c1ca592e178357cbf1717dac10216c2de37dfda70", "runtimeVersion": "0.11.1", "url": "https://github.com/koed-labs/koed/releases/download/v0.11.1/koed-native-cuda-5fc63b4396c94d35c3f9c30c1ca592e178357cbf1717dac10216c2de37dfda70-linux-x64.tar.gz", "sha256": "da8423ddc84ce0e95b7857a799b2d542dbc188c154cbf6869aaa165dbdc02a86", "manifestSha256": "c4a0bfc9f908d7774009ee6d45e34a54393d23b53ca9b567da73f72e8225cb3e", "target": { "platform": "linux", "architecture": "x64", "libc": { "family": "glibc", "minimumVersion": "2.35" } }, "archiveBytes": 711229069, "expandedBytes": 1467863069, "contracts": { "layout": 1, "embedding": 1 }, "llamaCpp": { "version": "b10514", "revision": "7221e24f579efbb5fd2a2ced1fffaef1aff2fe0d" }, "cuda": { "toolkitVersion": "12.4", "minimumDriverLinux": "550.54.14", "architectures": [75, 80, 86, 89, 90] } } };
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
productionNativeRuntimeCatalog
|
|
8
|
+
};
|
|
@@ -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-TSAYTRX3.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,14 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
environmentWithRepoEnv,
|
|
4
|
+
loadRepoEnv,
|
|
5
|
+
parseEnvFile,
|
|
6
|
+
resolveApiUrl
|
|
7
|
+
} from "./chunk-W2HNI6AA.js";
|
|
8
|
+
import "./chunk-BTS4ZTF3.js";
|
|
9
|
+
export {
|
|
10
|
+
environmentWithRepoEnv,
|
|
11
|
+
loadRepoEnv,
|
|
12
|
+
parseEnvFile,
|
|
13
|
+
resolveApiUrl
|
|
14
|
+
};
|