@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,175 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// packages/koed-server/dist/config.js
|
|
4
|
+
import { existsSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { randomUUID } from "node:crypto";
|
|
6
|
+
import { dirname } from "node:path";
|
|
7
|
+
import { mkdirSync } from "node:fs";
|
|
8
|
+
var defaultKoedServerConfig = {
|
|
9
|
+
runtimeMode: "local-personal",
|
|
10
|
+
dependencyMode: "bundled-local",
|
|
11
|
+
codexTranscriptWatcherEnabled: true,
|
|
12
|
+
claudeTranscriptWatcherEnabled: true,
|
|
13
|
+
piTranscriptWatcherEnabled: true,
|
|
14
|
+
codexGlobalMemoryGuidanceEnabled: true,
|
|
15
|
+
hardwareAcceleration: "auto"
|
|
16
|
+
};
|
|
17
|
+
var trim = (value) => {
|
|
18
|
+
const trimmed = value?.trim();
|
|
19
|
+
return trimmed ? trimmed : void 0;
|
|
20
|
+
};
|
|
21
|
+
var runtimeMode = (value) => value === "local-personal" || value === "external" || value === "developer" ? value : void 0;
|
|
22
|
+
var dependencyMode = (value) => value === "external" || value === "bundled-local" ? value : void 0;
|
|
23
|
+
var codexTranscriptWatcherSetting = (value) => {
|
|
24
|
+
if (value === true || value === "true")
|
|
25
|
+
return true;
|
|
26
|
+
if (value === false || value === "false")
|
|
27
|
+
return false;
|
|
28
|
+
return void 0;
|
|
29
|
+
};
|
|
30
|
+
var claudeTranscriptWatcherSetting = codexTranscriptWatcherSetting;
|
|
31
|
+
var piTranscriptWatcherSetting = codexTranscriptWatcherSetting;
|
|
32
|
+
var booleanSetting = codexTranscriptWatcherSetting;
|
|
33
|
+
var hardwareAccelerationPreference = (value, source) => value === void 0 ? void 0 : value === "auto" || value === "cpu" ? value : (() => {
|
|
34
|
+
throw new Error(`${source} must be auto or cpu`);
|
|
35
|
+
})();
|
|
36
|
+
var readConfig = (paths, deps) => {
|
|
37
|
+
if (!deps.existsSync(paths.serverConfigPath)) {
|
|
38
|
+
return {};
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const parsed = JSON.parse(deps.readFileSync(paths.serverConfigPath, "utf8"));
|
|
42
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
43
|
+
throw new Error("expected a JSON object");
|
|
44
|
+
}
|
|
45
|
+
const record = parsed;
|
|
46
|
+
if (!deps.strict)
|
|
47
|
+
return record;
|
|
48
|
+
const stringFields = ["runtimeMode", "dependencyMode"];
|
|
49
|
+
const booleanFields = [
|
|
50
|
+
"codexTranscriptWatcherEnabled",
|
|
51
|
+
"claudeTranscriptWatcherEnabled",
|
|
52
|
+
"piTranscriptWatcherEnabled",
|
|
53
|
+
"codexGlobalMemoryGuidanceEnabled"
|
|
54
|
+
];
|
|
55
|
+
for (const field of stringFields) {
|
|
56
|
+
if (record[field] !== void 0 && typeof record[field] !== "string") {
|
|
57
|
+
throw new Error(`${field} must be a string`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (record.runtimeMode !== void 0 && !runtimeMode(record.runtimeMode)) {
|
|
61
|
+
throw new Error("runtimeMode must be local-personal, external, or developer");
|
|
62
|
+
}
|
|
63
|
+
if (record.dependencyMode !== void 0 && !dependencyMode(record.dependencyMode)) {
|
|
64
|
+
throw new Error("dependencyMode must be bundled-local or external");
|
|
65
|
+
}
|
|
66
|
+
for (const field of booleanFields) {
|
|
67
|
+
if (record[field] !== void 0 && typeof record[field] !== "boolean") {
|
|
68
|
+
throw new Error(`${field} must be a boolean`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (record.hardwareAcceleration !== void 0) {
|
|
72
|
+
hardwareAccelerationPreference(record.hardwareAcceleration, "server.json hardwareAcceleration");
|
|
73
|
+
}
|
|
74
|
+
if (record.external !== void 0 && (!record.external || typeof record.external !== "object" || Array.isArray(record.external))) {
|
|
75
|
+
throw new Error("external must be an object");
|
|
76
|
+
}
|
|
77
|
+
if (record.external && typeof record.external === "object") {
|
|
78
|
+
const external = record.external;
|
|
79
|
+
const supportedExternalFields = [
|
|
80
|
+
"databaseUrl",
|
|
81
|
+
"redisUrl",
|
|
82
|
+
"embeddingServiceUrl",
|
|
83
|
+
"privacyServiceUrl"
|
|
84
|
+
];
|
|
85
|
+
for (const [field, value] of Object.entries(external)) {
|
|
86
|
+
if (!supportedExternalFields.includes(field)) {
|
|
87
|
+
throw new Error(`external.${field} is not supported`);
|
|
88
|
+
}
|
|
89
|
+
if (value !== void 0 && typeof value !== "string") {
|
|
90
|
+
throw new Error(`external.${field} must be a string`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return record;
|
|
95
|
+
} catch (error) {
|
|
96
|
+
if (!deps.strict)
|
|
97
|
+
return {};
|
|
98
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
99
|
+
throw new Error(`Cannot read ${paths.serverConfigPath}: ${message}`, {
|
|
100
|
+
cause: error
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
var resolveKoedServerConfig = (paths, environment = process.env, deps = {}) => {
|
|
105
|
+
const file = readConfig(paths, {
|
|
106
|
+
existsSync: deps.existsSync ?? existsSync,
|
|
107
|
+
readFileSync: deps.readFileSync ?? readFileSync,
|
|
108
|
+
strict: deps.strict
|
|
109
|
+
});
|
|
110
|
+
if (deps.strict) {
|
|
111
|
+
if (environment.KOED_RUNTIME_MODE !== void 0 && !runtimeMode(environment.KOED_RUNTIME_MODE)) {
|
|
112
|
+
throw new Error("KOED_RUNTIME_MODE must be local-personal, external, or developer");
|
|
113
|
+
}
|
|
114
|
+
if (environment.KOED_DEPENDENCY_MODE !== void 0 && !dependencyMode(environment.KOED_DEPENDENCY_MODE)) {
|
|
115
|
+
throw new Error("KOED_DEPENDENCY_MODE must be bundled-local or external");
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const resolvedRuntimeMode = runtimeMode(environment.KOED_RUNTIME_MODE) ?? runtimeMode(file.runtimeMode) ?? defaultKoedServerConfig.runtimeMode;
|
|
119
|
+
const resolvedTranscriptWatcherSetting = codexTranscriptWatcherSetting(environment.MEMORY_CODEX_TRANSCRIPT_WATCHER_ENABLED) ?? codexTranscriptWatcherSetting(file.codexTranscriptWatcherEnabled);
|
|
120
|
+
const resolvedClaudeTranscriptWatcherSetting = claudeTranscriptWatcherSetting(environment.MEMORY_CLAUDE_TRANSCRIPT_WATCHER_ENABLED) ?? claudeTranscriptWatcherSetting(file.claudeTranscriptWatcherEnabled);
|
|
121
|
+
const resolvedPiTranscriptWatcherSetting = piTranscriptWatcherSetting(environment.MEMORY_PI_TRANSCRIPT_WATCHER_ENABLED) ?? piTranscriptWatcherSetting(file.piTranscriptWatcherEnabled);
|
|
122
|
+
if (resolvedRuntimeMode === "external" && (resolvedTranscriptWatcherSetting === true || resolvedClaudeTranscriptWatcherSetting === true || resolvedPiTranscriptWatcherSetting === true)) {
|
|
123
|
+
throw new Error("Transcript Watchers cannot run in external runtime mode; run capture through a local-personal koed-server.");
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
runtimeMode: resolvedRuntimeMode,
|
|
127
|
+
dependencyMode: dependencyMode(environment.KOED_DEPENDENCY_MODE) ?? dependencyMode(file.dependencyMode) ?? (resolvedRuntimeMode === "local-personal" ? "bundled-local" : "external"),
|
|
128
|
+
codexTranscriptWatcherEnabled: resolvedTranscriptWatcherSetting ?? resolvedRuntimeMode !== "external",
|
|
129
|
+
claudeTranscriptWatcherEnabled: resolvedClaudeTranscriptWatcherSetting ?? resolvedRuntimeMode !== "external",
|
|
130
|
+
piTranscriptWatcherEnabled: resolvedPiTranscriptWatcherSetting ?? resolvedRuntimeMode !== "external",
|
|
131
|
+
codexGlobalMemoryGuidanceEnabled: booleanSetting(environment.KOED_CODEX_GLOBAL_MEMORY_GUIDANCE_ENABLED) ?? booleanSetting(file.codexGlobalMemoryGuidanceEnabled) ?? defaultKoedServerConfig.codexGlobalMemoryGuidanceEnabled,
|
|
132
|
+
hardwareAcceleration: hardwareAccelerationPreference(environment.KOED_HARDWARE_ACCELERATION, "KOED_HARDWARE_ACCELERATION") ?? hardwareAccelerationPreference(file.hardwareAcceleration, "server.json hardwareAcceleration") ?? defaultKoedServerConfig.hardwareAcceleration,
|
|
133
|
+
external: {
|
|
134
|
+
databaseUrl: trim(environment.KOED_EXTERNAL_DATABASE_URL) ?? trim(environment.DATABASE_URL) ?? trim(file.external?.databaseUrl),
|
|
135
|
+
redisUrl: trim(environment.KOED_EXTERNAL_REDIS_URL) ?? trim(environment.REDIS_URL) ?? trim(file.external?.redisUrl),
|
|
136
|
+
embeddingServiceUrl: trim(environment.KOED_EXTERNAL_EMBEDDING_SERVICE_URL) ?? trim(environment.EMBEDDING_SERVICE_URL) ?? trim(file.external?.embeddingServiceUrl),
|
|
137
|
+
privacyServiceUrl: trim(environment.KOED_EXTERNAL_PRIVACY_SERVICE_URL) ?? trim(environment.PRIVACY_SERVICE_URL) ?? trim(file.external?.privacyServiceUrl)
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
var writeServerConfigAtomically = (paths, config, deps = {}) => {
|
|
142
|
+
mkdirSync(dirname(paths.serverConfigPath), { recursive: true, mode: 448 });
|
|
143
|
+
const temporary = `${paths.serverConfigPath}.${process.pid}.${randomUUID()}.tmp`;
|
|
144
|
+
try {
|
|
145
|
+
(deps.writeFileSync ?? writeFileSync)(temporary, `${JSON.stringify(config, null, 2)}
|
|
146
|
+
`, { mode: 384 });
|
|
147
|
+
(deps.renameSync ?? renameSync)(temporary, paths.serverConfigPath);
|
|
148
|
+
} catch (error) {
|
|
149
|
+
(deps.rmSync ?? rmSync)(temporary, { force: true });
|
|
150
|
+
throw error;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
var writeCodexGlobalMemoryGuidancePreference = (paths, enabled, deps = {}) => {
|
|
154
|
+
const fileExists = deps.existsSync ?? existsSync;
|
|
155
|
+
const read = deps.readFileSync ?? readFileSync;
|
|
156
|
+
let existing = {};
|
|
157
|
+
if (fileExists(paths.serverConfigPath)) {
|
|
158
|
+
try {
|
|
159
|
+
const parsed = JSON.parse(read(paths.serverConfigPath, "utf8"));
|
|
160
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
161
|
+
throw new Error("expected a JSON object");
|
|
162
|
+
}
|
|
163
|
+
existing = parsed;
|
|
164
|
+
} catch (error) {
|
|
165
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
166
|
+
throw new Error(`Cannot update Codex memory guidance preference because ${paths.serverConfigPath} is malformed: ${message}.`, { cause: error });
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
writeServerConfigAtomically(paths, { ...existing, codexGlobalMemoryGuidanceEnabled: enabled }, deps);
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export {
|
|
173
|
+
resolveKoedServerConfig,
|
|
174
|
+
writeCodexGlobalMemoryGuidancePreference
|
|
175
|
+
};
|
|
@@ -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-JYK6UL6D.js";
|
|
9
|
+
import "./chunk-BTS4ZTF3.js";
|
|
10
|
+
export {
|
|
11
|
+
collectLocalModelStatus,
|
|
12
|
+
installLocalModel,
|
|
13
|
+
localModelKinds,
|
|
14
|
+
resolveLocalModelManifest,
|
|
15
|
+
sha256File
|
|
16
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
assertKoedAppRuntimeAvailable,
|
|
4
|
+
resolveKoedAppRuntime,
|
|
5
|
+
resolveKoedAppRuntimeExecution,
|
|
6
|
+
resolveKoedAppRuntimeForExecution,
|
|
7
|
+
resolveKoedControlPlaneVersion,
|
|
8
|
+
resolveKoedRuntimeOwner
|
|
9
|
+
} from "./chunk-V67IQB7H.js";
|
|
10
|
+
import "./chunk-BTS4ZTF3.js";
|
|
11
|
+
export {
|
|
12
|
+
assertKoedAppRuntimeAvailable,
|
|
13
|
+
resolveKoedAppRuntime,
|
|
14
|
+
resolveKoedAppRuntimeExecution,
|
|
15
|
+
resolveKoedAppRuntimeForExecution,
|
|
16
|
+
resolveKoedControlPlaneVersion,
|
|
17
|
+
resolveKoedRuntimeOwner
|
|
18
|
+
};
|
|
@@ -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,22 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
PRIVACY_MODEL_FILES,
|
|
4
|
+
PRIVACY_MODEL_ID,
|
|
5
|
+
PRIVACY_MODEL_REVISION,
|
|
6
|
+
collectPrivacyModelStatus,
|
|
7
|
+
installPrivacyModel,
|
|
8
|
+
materializePrivacyModelCacheEntry,
|
|
9
|
+
resolvePrivacyModelPaths
|
|
10
|
+
} from "./chunk-4OO6VAU3.js";
|
|
11
|
+
import "./chunk-ZOHNXUDY.js";
|
|
12
|
+
import "./chunk-FSNLU46W.js";
|
|
13
|
+
import "./chunk-BTS4ZTF3.js";
|
|
14
|
+
export {
|
|
15
|
+
PRIVACY_MODEL_FILES,
|
|
16
|
+
PRIVACY_MODEL_ID,
|
|
17
|
+
PRIVACY_MODEL_REVISION,
|
|
18
|
+
collectPrivacyModelStatus,
|
|
19
|
+
installPrivacyModel,
|
|
20
|
+
materializePrivacyModelCacheEntry,
|
|
21
|
+
resolvePrivacyModelPaths
|
|
22
|
+
};
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { createRequire as createKoedRequire } from "node:module"; const require = createKoedRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
createCliServiceContext,
|
|
4
|
+
printJson
|
|
5
|
+
} from "./chunk-WDFERJG3.js";
|
|
6
|
+
import "./chunk-SHLRINKO.js";
|
|
7
|
+
import "./chunk-CHMH4LH5.js";
|
|
8
|
+
import "./chunk-EA4QDDQA.js";
|
|
9
|
+
import "./chunk-JYK6UL6D.js";
|
|
10
|
+
import "./chunk-WPIEF4LY.js";
|
|
11
|
+
import {
|
|
12
|
+
connectAiClientAfterSetup,
|
|
13
|
+
disconnectAiClientThenRemove,
|
|
14
|
+
verifyAiClientIntegration
|
|
15
|
+
} from "./chunk-6KS67EQE.js";
|
|
16
|
+
import {
|
|
17
|
+
evaluateAiClientReadiness
|
|
18
|
+
} from "./chunk-EDPNYIX5.js";
|
|
19
|
+
import "./chunk-QT24SAW6.js";
|
|
20
|
+
import "./chunk-TISYUUEJ.js";
|
|
21
|
+
import "./chunk-ALJUSOF7.js";
|
|
22
|
+
import "./chunk-SRKIBFOE.js";
|
|
23
|
+
import "./chunk-7FSHVVTZ.js";
|
|
24
|
+
import "./chunk-TSAYTRX3.js";
|
|
25
|
+
import "./chunk-YZLQZU5E.js";
|
|
26
|
+
import "./chunk-W2HNI6AA.js";
|
|
27
|
+
import "./chunk-V67IQB7H.js";
|
|
28
|
+
import "./chunk-FN3HUUO2.js";
|
|
29
|
+
import "./chunk-T6UB5PNX.js";
|
|
30
|
+
import "./chunk-7NXKPDF3.js";
|
|
31
|
+
import "./chunk-ZUDSZGVO.js";
|
|
32
|
+
import "./chunk-ZIOKV2X6.js";
|
|
33
|
+
import "./chunk-QRKHHWJJ.js";
|
|
34
|
+
import "./chunk-7EGSY3E4.js";
|
|
35
|
+
import "./chunk-IY2HRXOZ.js";
|
|
36
|
+
import "./chunk-4OO6VAU3.js";
|
|
37
|
+
import "./chunk-RCR4XPE3.js";
|
|
38
|
+
import "./chunk-ZOHNXUDY.js";
|
|
39
|
+
import "./chunk-FSNLU46W.js";
|
|
40
|
+
import "./chunk-BTS4ZTF3.js";
|
|
41
|
+
|
|
42
|
+
// packages/koed-server/dist/cli-integration-operations.js
|
|
43
|
+
var runIntegrationCommand = async (command, options, dependencies) => {
|
|
44
|
+
const { collectStatus, setupCoreIntegration, setup, setupClaudeIntegration, setupPiIntegration, removeClaudeIntegration, removePiIntegration, removeCodexIntegrationFn, repairCodex, resolvePaths, stdout, stderr } = createCliServiceContext(dependencies);
|
|
45
|
+
const subcommand = options.client;
|
|
46
|
+
const wantsJson = options.json;
|
|
47
|
+
const koedHome = () => resolvePaths(process.env).koedHome;
|
|
48
|
+
const connectAfter = (client, run) => connectAiClientAfterSetup({
|
|
49
|
+
client,
|
|
50
|
+
koedHome: koedHome(),
|
|
51
|
+
run,
|
|
52
|
+
verify: (home) => verifyAiClientIntegration(client, home, process.env, collectStatus)
|
|
53
|
+
});
|
|
54
|
+
try {
|
|
55
|
+
if (command === "setup" && subcommand === "core") {
|
|
56
|
+
const result = await setupCoreIntegration();
|
|
57
|
+
if (wantsJson) {
|
|
58
|
+
printJson(stdout, result);
|
|
59
|
+
} else {
|
|
60
|
+
stdout.write(result.ok ? "Koed core setup completed.\n" : `${result.error ?? "Koed core setup failed."}
|
|
61
|
+
`);
|
|
62
|
+
}
|
|
63
|
+
return result.ok ? 0 : 1;
|
|
64
|
+
}
|
|
65
|
+
if (command === "setup" && subcommand === "codex") {
|
|
66
|
+
const withoutGuidance = Boolean(options.withoutMemoryGuidance);
|
|
67
|
+
const withGuidance = Boolean(options.withMemoryGuidance);
|
|
68
|
+
if (withoutGuidance && withGuidance) {
|
|
69
|
+
throw new Error("Use only one of --with-memory-guidance or --without-memory-guidance.");
|
|
70
|
+
}
|
|
71
|
+
const deferredRecall = Boolean(options.deferredRecall);
|
|
72
|
+
const blockingRecall = Boolean(options.blockingRecall);
|
|
73
|
+
if (deferredRecall && blockingRecall)
|
|
74
|
+
throw new Error("Use only one of --deferred-recall or --blocking-recall.");
|
|
75
|
+
if (deferredRecall || blockingRecall) {
|
|
76
|
+
stderr.write("Legacy recall flags are deprecated; select delivery_mode on memory_answer instead.\n");
|
|
77
|
+
}
|
|
78
|
+
const result = await connectAfter("codex", () => setup({
|
|
79
|
+
environment: {
|
|
80
|
+
...process.env,
|
|
81
|
+
...withoutGuidance || withGuidance ? {
|
|
82
|
+
KOED_CODEX_GLOBAL_MEMORY_GUIDANCE_ENABLED: String(withGuidance)
|
|
83
|
+
} : {},
|
|
84
|
+
...deferredRecall || blockingRecall ? { KOED_CODEX_STOP_DELIVERY: deferredRecall ? "1" : "0" } : {}
|
|
85
|
+
}
|
|
86
|
+
}));
|
|
87
|
+
if (wantsJson) {
|
|
88
|
+
printJson(stdout, result);
|
|
89
|
+
} else {
|
|
90
|
+
stdout.write(result.ok ? "Codex setup completed.\n" : `${result.error ?? "Codex setup failed."}
|
|
91
|
+
`);
|
|
92
|
+
}
|
|
93
|
+
return result.ok ? 0 : 1;
|
|
94
|
+
}
|
|
95
|
+
if (command === "setup" && subcommand === "pi") {
|
|
96
|
+
const result = await connectAfter("pi", () => setupPiIntegration());
|
|
97
|
+
if (wantsJson) {
|
|
98
|
+
printJson(stdout, result);
|
|
99
|
+
} else {
|
|
100
|
+
stdout.write(result.ok ? result.authenticationState === "authenticated" ? "Pi setup completed.\n" : "Pi profile configured. Authenticate at least one model through Pi, then refresh capabilities; Pi-executed work remains unavailable until authentication.\n" : `${result.error ?? "Pi setup failed."}
|
|
101
|
+
`);
|
|
102
|
+
}
|
|
103
|
+
return result.ok ? 0 : 1;
|
|
104
|
+
}
|
|
105
|
+
if (command === "setup" && subcommand === "claude") {
|
|
106
|
+
const result = await connectAfter("claude", () => options.backgroundRecall ? setupClaudeIntegration(void 0, void 0, {
|
|
107
|
+
backgroundRecall: true
|
|
108
|
+
}) : setupClaudeIntegration());
|
|
109
|
+
if (wantsJson) {
|
|
110
|
+
printJson(stdout, result);
|
|
111
|
+
} else {
|
|
112
|
+
stdout.write(result.ok ? result.authenticationState === "authenticated" ? "Claude Code setup completed. Restart Claude Code before verifying capture and recall.\n" : "Claude Code profile configured. Run `claude auth login`, then refresh capabilities; Claude-executed work remains unavailable until sign-in.\n" : `${result.error ?? "Claude Code setup failed."}
|
|
113
|
+
`);
|
|
114
|
+
}
|
|
115
|
+
if (!wantsJson && result.backgroundRecall)
|
|
116
|
+
stdout.write(`${result.backgroundRecall.message}
|
|
117
|
+
`);
|
|
118
|
+
return result.ok ? 0 : 1;
|
|
119
|
+
}
|
|
120
|
+
if (command === "repair" && subcommand === "codex") {
|
|
121
|
+
const result = await connectAfter("codex", () => repairCodex());
|
|
122
|
+
if (wantsJson) {
|
|
123
|
+
printJson(stdout, result);
|
|
124
|
+
} else {
|
|
125
|
+
stdout.write(result.ok ? "Codex integration repaired. Restart Codex and trust updated hooks if prompted.\n" : `${result.error ?? "Codex integration repair failed."}
|
|
126
|
+
`);
|
|
127
|
+
}
|
|
128
|
+
return result.ok ? 0 : 1;
|
|
129
|
+
}
|
|
130
|
+
if (command === "check" && subcommand) {
|
|
131
|
+
const status = await collectStatus(void 0, void 0, {
|
|
132
|
+
capabilitiesRefreshedSince: options.capabilitiesRefreshedSince
|
|
133
|
+
});
|
|
134
|
+
const components = {
|
|
135
|
+
codex: status.codex,
|
|
136
|
+
claude: status.claudeCode,
|
|
137
|
+
pi: status.pi
|
|
138
|
+
};
|
|
139
|
+
const readiness = components[subcommand] ? status.aiClients?.[subcommand] : void 0;
|
|
140
|
+
if (!components[subcommand])
|
|
141
|
+
throw new Error("check client must be codex, claude, or pi.");
|
|
142
|
+
const result = {
|
|
143
|
+
client: subcommand,
|
|
144
|
+
readiness: readiness ?? null,
|
|
145
|
+
...options.includeStatus ? { status } : {},
|
|
146
|
+
...evaluateAiClientReadiness(readiness)
|
|
147
|
+
};
|
|
148
|
+
if (wantsJson)
|
|
149
|
+
printJson(stdout, result);
|
|
150
|
+
else
|
|
151
|
+
stdout.write(`${result.message}
|
|
152
|
+
`);
|
|
153
|
+
return result.ok ? 0 : 1;
|
|
154
|
+
}
|
|
155
|
+
if (command === "repair" && subcommand) {
|
|
156
|
+
const result = subcommand === "codex" ? await connectAfter("codex", () => repairCodex()) : subcommand === "claude" ? await connectAfter("claude", () => setupClaudeIntegration()) : subcommand === "pi" ? await connectAfter("pi", () => setupPiIntegration()) : null;
|
|
157
|
+
if (!result)
|
|
158
|
+
throw new Error("repair client must be codex, claude, or pi.");
|
|
159
|
+
if (wantsJson)
|
|
160
|
+
printJson(stdout, result);
|
|
161
|
+
else
|
|
162
|
+
stdout.write(`${result.ok ? "AI Client integration repaired." : result.error ?? "AI Client integration repair failed."}
|
|
163
|
+
`);
|
|
164
|
+
return result.ok ? 0 : 1;
|
|
165
|
+
}
|
|
166
|
+
if (command === "remove" && subcommand) {
|
|
167
|
+
if (subcommand !== "codex" && subcommand !== "claude" && subcommand !== "pi")
|
|
168
|
+
throw new Error("remove client must be codex, claude, or pi.");
|
|
169
|
+
const result = disconnectAiClientThenRemove({
|
|
170
|
+
client: subcommand,
|
|
171
|
+
koedHome: koedHome(),
|
|
172
|
+
remove: () => subcommand === "codex" ? removeCodexIntegrationFn() : subcommand === "claude" ? removeClaudeIntegration() : removePiIntegration()
|
|
173
|
+
});
|
|
174
|
+
if (wantsJson)
|
|
175
|
+
printJson(stdout, result);
|
|
176
|
+
else
|
|
177
|
+
stdout.write(`${result.ok ? "AI Client integration removed." : result.error ?? "AI Client integration removal failed."}
|
|
178
|
+
`);
|
|
179
|
+
return result.ok ? 0 : 1;
|
|
180
|
+
}
|
|
181
|
+
throw new Error("Unknown AI Client integration operation.");
|
|
182
|
+
} catch (error) {
|
|
183
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
184
|
+
if (wantsJson)
|
|
185
|
+
printJson(stdout, { ok: false, error: message });
|
|
186
|
+
else
|
|
187
|
+
stderr.write(`${message}
|
|
188
|
+
`);
|
|
189
|
+
return 1;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
export {
|
|
193
|
+
runIntegrationCommand
|
|
194
|
+
};
|