iranti-control-plane 0.5.2 → 0.5.4
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/README.md +3 -3
- package/bin/iranti-cp.js +83 -1
- package/dist/server/bundle.cjs +112 -41
- package/package.json +1 -1
- package/public/control-plane/assets/{index-CPsDyW96.css → index-CPcXaBi0.css} +1 -1
- package/public/control-plane/assets/index-VQDPvyqf.js +77 -0
- package/public/control-plane/index.html +2 -2
- package/public/control-plane/assets/index-C4_wD-R6.js +0 -77
package/README.md
CHANGED
|
@@ -57,8 +57,8 @@ npm run migrate
|
|
|
57
57
|
npm run dev
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
Open http://localhost:5173 for the frontend dev server.
|
|
61
|
-
|
|
60
|
+
Open http://localhost:5173 for the frontend dev server.
|
|
61
|
+
|
|
62
62
|
### Port model
|
|
63
63
|
|
|
64
64
|
The control plane has two common local startup modes:
|
|
@@ -145,4 +145,4 @@ See `docs/specs/control-plane-api.md` for the full API spec and `docs/prd/contro
|
|
|
145
145
|
For release and manual publish checks, see [`docs/guides/releasing.md`](docs/guides/releasing.md).
|
|
146
146
|
|
|
147
147
|
If npm publish is run from GitHub Actions, the repo `NPM_TOKEN` secret must be an npm **Automation token**. A standard token that still requires OTP will fail with `EOTP`.
|
|
148
|
-
|
|
148
|
+
|
package/bin/iranti-cp.js
CHANGED
|
@@ -31,6 +31,9 @@ Usage:
|
|
|
31
31
|
iranti-cp doctor [iranti doctor args...]
|
|
32
32
|
iranti-cp upgrade [self]
|
|
33
33
|
iranti-cp upgrade iranti [iranti upgrade args...]
|
|
34
|
+
iranti-cp config [get]
|
|
35
|
+
iranti-cp config set port <n>
|
|
36
|
+
iranti-cp config unset port
|
|
34
37
|
|
|
35
38
|
Commands:
|
|
36
39
|
open Open an existing Control Plane if one is running, otherwise start it in the background.
|
|
@@ -41,9 +44,13 @@ Commands:
|
|
|
41
44
|
version Print the installed iranti-control-plane version.
|
|
42
45
|
doctor Proxy to "iranti doctor".
|
|
43
46
|
upgrade Upgrade iranti-control-plane itself, or proxy to "iranti upgrade" for core Iranti.
|
|
47
|
+
config Read or write persistent Control Plane configuration.
|
|
48
|
+
get Show current config.
|
|
49
|
+
set port <n> Set the default startup port (1024–65535).
|
|
50
|
+
unset port Clear the default port, reverting to the 3000–3010 auto-range.
|
|
44
51
|
|
|
45
52
|
Options:
|
|
46
|
-
--port <n> Prefer a specific Control Plane port for open/start/status.
|
|
53
|
+
--port <n> Prefer a specific Control Plane port for open/start/status (one-time override).
|
|
47
54
|
--json Emit machine-readable output for status.
|
|
48
55
|
-h, --help Show this help.
|
|
49
56
|
`);
|
|
@@ -86,6 +93,26 @@ function parseArgs(argv) {
|
|
|
86
93
|
return { help, port, json, positionals };
|
|
87
94
|
}
|
|
88
95
|
|
|
96
|
+
function getUserConfigPath() {
|
|
97
|
+
return path.join(require('os').homedir(), '.iranti-runtime', 'iranti-cp-config.json');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function readUserConfig() {
|
|
101
|
+
try {
|
|
102
|
+
const raw = fs.readFileSync(getUserConfigPath(), 'utf8');
|
|
103
|
+
const parsed = JSON.parse(raw);
|
|
104
|
+
return typeof parsed === 'object' && parsed !== null ? parsed : {};
|
|
105
|
+
} catch {
|
|
106
|
+
return {};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function writeUserConfig(config) {
|
|
111
|
+
const configPath = getUserConfigPath();
|
|
112
|
+
fs.mkdirSync(path.dirname(configPath), { recursive: true });
|
|
113
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n', 'utf8');
|
|
114
|
+
}
|
|
115
|
+
|
|
89
116
|
function preferredPorts(explicitPort) {
|
|
90
117
|
const seen = new Set();
|
|
91
118
|
const ordered = [];
|
|
@@ -100,11 +127,64 @@ function preferredPorts(explicitPort) {
|
|
|
100
127
|
|
|
101
128
|
add(explicitPort);
|
|
102
129
|
add(process.env.CONTROL_PLANE_PORT);
|
|
130
|
+
add(readUserConfig().defaultPort);
|
|
103
131
|
for (let port = 3000; port <= 3010; port += 1) add(port);
|
|
104
132
|
add(3002);
|
|
105
133
|
return ordered;
|
|
106
134
|
}
|
|
107
135
|
|
|
136
|
+
async function handleConfig(subcommands) {
|
|
137
|
+
const sub = subcommands[0];
|
|
138
|
+
|
|
139
|
+
if (!sub || sub === 'get') {
|
|
140
|
+
const config = readUserConfig();
|
|
141
|
+
const portDisplay = config.defaultPort != null
|
|
142
|
+
? String(config.defaultPort)
|
|
143
|
+
: '(not set — uses 3000–3010 auto-range)';
|
|
144
|
+
console.log(`defaultPort: ${portDisplay}`);
|
|
145
|
+
return 0;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (sub === 'set') {
|
|
149
|
+
const key = subcommands[1];
|
|
150
|
+
const value = subcommands[2];
|
|
151
|
+
if (key === 'port') {
|
|
152
|
+
if (!value) {
|
|
153
|
+
console.error('iranti-cp config set port: missing port number');
|
|
154
|
+
return 1;
|
|
155
|
+
}
|
|
156
|
+
const parsed = Number.parseInt(value, 10);
|
|
157
|
+
if (!Number.isFinite(parsed) || parsed < 1024 || parsed > 65535) {
|
|
158
|
+
console.error(`iranti-cp config set port: "${value}" is not a valid port (1024–65535)`);
|
|
159
|
+
return 1;
|
|
160
|
+
}
|
|
161
|
+
const config = readUserConfig();
|
|
162
|
+
config.defaultPort = parsed;
|
|
163
|
+
writeUserConfig(config);
|
|
164
|
+
console.log(`Default port set to ${parsed}. Takes effect on next iranti-cp start.`);
|
|
165
|
+
return 0;
|
|
166
|
+
}
|
|
167
|
+
console.error(`iranti-cp config set: unknown key "${key !== undefined ? key : ''}". Supported: port`);
|
|
168
|
+
return 1;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (sub === 'unset') {
|
|
172
|
+
const key = subcommands[1];
|
|
173
|
+
if (key === 'port') {
|
|
174
|
+
const config = readUserConfig();
|
|
175
|
+
delete config.defaultPort;
|
|
176
|
+
writeUserConfig(config);
|
|
177
|
+
console.log('Default port cleared. Will use 3000–3010 auto-range on next start.');
|
|
178
|
+
return 0;
|
|
179
|
+
}
|
|
180
|
+
console.error(`iranti-cp config unset: unknown key "${key !== undefined ? key : ''}". Supported: port`);
|
|
181
|
+
return 1;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
console.error(`iranti-cp config: unknown subcommand "${sub}". Use get, set, or unset.`);
|
|
185
|
+
return 1;
|
|
186
|
+
}
|
|
187
|
+
|
|
108
188
|
async function fetchJson(url, timeoutMs = 1500) {
|
|
109
189
|
const controller = new AbortController();
|
|
110
190
|
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
@@ -527,6 +607,8 @@ async function main() {
|
|
|
527
607
|
exitCode = await runIrantiProxy(['doctor', ...rest]);
|
|
528
608
|
} else if (command === 'upgrade') {
|
|
529
609
|
exitCode = await handleUpgrade(rest[0] || 'self', rest.slice(1));
|
|
610
|
+
} else if (command === 'config') {
|
|
611
|
+
exitCode = await handleConfig(rest);
|
|
530
612
|
} else {
|
|
531
613
|
console.error(`iranti-cp: unknown command "${command}".`);
|
|
532
614
|
printHelp();
|
package/dist/server/bundle.cjs
CHANGED
|
@@ -18410,7 +18410,7 @@ var require_view = __commonJS({
|
|
|
18410
18410
|
var dirname10 = path3.dirname;
|
|
18411
18411
|
var basename7 = path3.basename;
|
|
18412
18412
|
var extname3 = path3.extname;
|
|
18413
|
-
var
|
|
18413
|
+
var join14 = path3.join;
|
|
18414
18414
|
var resolve10 = path3.resolve;
|
|
18415
18415
|
module2.exports = View;
|
|
18416
18416
|
function View(name, options) {
|
|
@@ -18458,12 +18458,12 @@ var require_view = __commonJS({
|
|
|
18458
18458
|
};
|
|
18459
18459
|
View.prototype.resolve = function resolve11(dir, file2) {
|
|
18460
18460
|
var ext = this.ext;
|
|
18461
|
-
var path4 =
|
|
18461
|
+
var path4 = join14(dir, file2);
|
|
18462
18462
|
var stat2 = tryStat(path4);
|
|
18463
18463
|
if (stat2 && stat2.isFile()) {
|
|
18464
18464
|
return path4;
|
|
18465
18465
|
}
|
|
18466
|
-
path4 =
|
|
18466
|
+
path4 = join14(dir, basename7(file2, ext), "index" + ext);
|
|
18467
18467
|
stat2 = tryStat(path4);
|
|
18468
18468
|
if (stat2 && stat2.isFile()) {
|
|
18469
18469
|
return path4;
|
|
@@ -19096,7 +19096,7 @@ var require_send = __commonJS({
|
|
|
19096
19096
|
var Stream = require("stream");
|
|
19097
19097
|
var util2 = require("util");
|
|
19098
19098
|
var extname3 = path3.extname;
|
|
19099
|
-
var
|
|
19099
|
+
var join14 = path3.join;
|
|
19100
19100
|
var normalize = path3.normalize;
|
|
19101
19101
|
var resolve10 = path3.resolve;
|
|
19102
19102
|
var sep = path3.sep;
|
|
@@ -19315,7 +19315,7 @@ var require_send = __commonJS({
|
|
|
19315
19315
|
return res;
|
|
19316
19316
|
}
|
|
19317
19317
|
parts = path4.split(sep);
|
|
19318
|
-
path4 = normalize(
|
|
19318
|
+
path4 = normalize(join14(root, path4));
|
|
19319
19319
|
} else {
|
|
19320
19320
|
if (UP_PATH_REGEXP.test(path4)) {
|
|
19321
19321
|
debug('malicious path "%s"', path4);
|
|
@@ -19450,7 +19450,7 @@ var require_send = __commonJS({
|
|
|
19450
19450
|
if (err) return self.onStatError(err);
|
|
19451
19451
|
return self.error(404);
|
|
19452
19452
|
}
|
|
19453
|
-
var p =
|
|
19453
|
+
var p = join14(path4, self._index[i]);
|
|
19454
19454
|
debug('stat "%s"', p);
|
|
19455
19455
|
fs2.stat(p, function(err2, stat2) {
|
|
19456
19456
|
if (err2) return next(err2);
|
|
@@ -20589,7 +20589,7 @@ var require_application = __commonJS({
|
|
|
20589
20589
|
"src/server/node_modules/express/lib/application.js"(exports2, module2) {
|
|
20590
20590
|
"use strict";
|
|
20591
20591
|
var finalhandler = require_finalhandler();
|
|
20592
|
-
var
|
|
20592
|
+
var Router34 = require_router();
|
|
20593
20593
|
var methods = require_methods();
|
|
20594
20594
|
var middleware = require_init();
|
|
20595
20595
|
var query2 = require_query();
|
|
@@ -20654,7 +20654,7 @@ var require_application = __commonJS({
|
|
|
20654
20654
|
};
|
|
20655
20655
|
app2.lazyrouter = function lazyrouter() {
|
|
20656
20656
|
if (!this._router) {
|
|
20657
|
-
this._router = new
|
|
20657
|
+
this._router = new Router34({
|
|
20658
20658
|
caseSensitive: this.enabled("case sensitive routing"),
|
|
20659
20659
|
strict: this.enabled("strict routing")
|
|
20660
20660
|
});
|
|
@@ -22518,7 +22518,7 @@ var require_express = __commonJS({
|
|
|
22518
22518
|
var mixin = require_merge_descriptors();
|
|
22519
22519
|
var proto = require_application();
|
|
22520
22520
|
var Route = require_route();
|
|
22521
|
-
var
|
|
22521
|
+
var Router34 = require_router();
|
|
22522
22522
|
var req = require_request();
|
|
22523
22523
|
var res = require_response();
|
|
22524
22524
|
exports2 = module2.exports = createApplication;
|
|
@@ -22541,7 +22541,7 @@ var require_express = __commonJS({
|
|
|
22541
22541
|
exports2.request = req;
|
|
22542
22542
|
exports2.response = res;
|
|
22543
22543
|
exports2.Route = Route;
|
|
22544
|
-
exports2.Router =
|
|
22544
|
+
exports2.Router = Router34;
|
|
22545
22545
|
exports2.json = bodyParser.json;
|
|
22546
22546
|
exports2.query = require_query();
|
|
22547
22547
|
exports2.raw = bodyParser.raw;
|
|
@@ -28044,12 +28044,24 @@ function ancestorBindingCandidates(startDir) {
|
|
|
28044
28044
|
}
|
|
28045
28045
|
return candidates;
|
|
28046
28046
|
}
|
|
28047
|
+
function discoverInstanceEnvCandidates(homeDir) {
|
|
28048
|
+
const explicitName = (process.env["IRANTI_INSTANCE"] ?? process.env["IRANTI_INSTANCE_NAME"] ?? "").trim();
|
|
28049
|
+
const instancesDir = resolvePortable(homeDir, ".iranti-runtime", "instances");
|
|
28050
|
+
if (explicitName) {
|
|
28051
|
+
return [resolvePortable(instancesDir, explicitName, ".env")];
|
|
28052
|
+
}
|
|
28053
|
+
try {
|
|
28054
|
+
return (0, import_fs.readdirSync)(instancesDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => resolvePortable(instancesDir, entry.name, ".env"));
|
|
28055
|
+
} catch {
|
|
28056
|
+
return [resolvePortable(instancesDir, "local", ".env")];
|
|
28057
|
+
}
|
|
28058
|
+
}
|
|
28047
28059
|
function envFileCandidates(startDir, homeDir = (0, import_os.homedir)(), isSea = false, execPath = process.execPath) {
|
|
28048
28060
|
return [
|
|
28049
28061
|
...isSea ? [resolvePortable(dirnamePortable(execPath), ".env.iranti")] : [],
|
|
28050
28062
|
...ancestorBindingCandidates(startDir),
|
|
28051
28063
|
resolvePortable(homeDir, ".iranti-runtime", ".env.iranti"),
|
|
28052
|
-
|
|
28064
|
+
...discoverInstanceEnvCandidates(homeDir)
|
|
28053
28065
|
];
|
|
28054
28066
|
}
|
|
28055
28067
|
function loadEnv() {
|
|
@@ -35370,11 +35382,11 @@ __export(runner_exports, {
|
|
|
35370
35382
|
});
|
|
35371
35383
|
function resolveMigrationPath(file2) {
|
|
35372
35384
|
const candidates = [
|
|
35373
|
-
(0,
|
|
35374
|
-
(0,
|
|
35385
|
+
(0, import_path20.resolve)(__dirname2, file2),
|
|
35386
|
+
(0, import_path20.resolve)(__dirname2, "..", "..", "migrations", file2)
|
|
35375
35387
|
];
|
|
35376
35388
|
for (const candidate of candidates) {
|
|
35377
|
-
if ((0,
|
|
35389
|
+
if ((0, import_fs14.existsSync)(candidate)) return candidate;
|
|
35378
35390
|
}
|
|
35379
35391
|
return candidates[0];
|
|
35380
35392
|
}
|
|
@@ -35388,7 +35400,7 @@ async function run() {
|
|
|
35388
35400
|
];
|
|
35389
35401
|
try {
|
|
35390
35402
|
for (const file2 of migrations) {
|
|
35391
|
-
const sql = (0,
|
|
35403
|
+
const sql = (0, import_fs14.readFileSync)(resolveMigrationPath(file2), "utf8");
|
|
35392
35404
|
console.log(`[migrate] Running ${file2}`);
|
|
35393
35405
|
await migrationPool.query(sql);
|
|
35394
35406
|
console.log(`[migrate] Done: ${file2}`);
|
|
@@ -35398,17 +35410,17 @@ async function run() {
|
|
|
35398
35410
|
await migrationPool.end();
|
|
35399
35411
|
}
|
|
35400
35412
|
}
|
|
35401
|
-
var
|
|
35413
|
+
var import_fs14, import_path20, import_url2, __dirname2;
|
|
35402
35414
|
var init_runner = __esm({
|
|
35403
35415
|
"src/server/migrations/runner.ts"() {
|
|
35404
35416
|
"use strict";
|
|
35405
|
-
|
|
35406
|
-
|
|
35417
|
+
import_fs14 = require("fs");
|
|
35418
|
+
import_path20 = require("path");
|
|
35407
35419
|
import_url2 = require("url");
|
|
35408
35420
|
init_esm();
|
|
35409
35421
|
init_db();
|
|
35410
|
-
__dirname2 = (0,
|
|
35411
|
-
if (process.argv[1] && (0,
|
|
35422
|
+
__dirname2 = (0, import_path20.dirname)((0, import_url2.fileURLToPath)(__importmeta_url));
|
|
35423
|
+
if (process.argv[1] && (0, import_path20.resolve)(process.argv[1]) === (0, import_url2.fileURLToPath)(__importmeta_url)) {
|
|
35412
35424
|
run().catch((err) => {
|
|
35413
35425
|
console.error("[migrate] Failed:", err);
|
|
35414
35426
|
process.exitCode = 1;
|
|
@@ -35762,16 +35774,16 @@ __export(index_exports, {
|
|
|
35762
35774
|
VERSION: () => VERSION
|
|
35763
35775
|
});
|
|
35764
35776
|
module.exports = __toCommonJS(index_exports);
|
|
35765
|
-
var
|
|
35777
|
+
var import_express34 = __toESM(require_express2(), 1);
|
|
35766
35778
|
var import_cors = __toESM(require_lib3(), 1);
|
|
35767
35779
|
var import_net = __toESM(require("net"), 1);
|
|
35768
|
-
var
|
|
35769
|
-
var
|
|
35780
|
+
var import_path21 = require("path");
|
|
35781
|
+
var import_fs15 = require("fs");
|
|
35770
35782
|
var import_url3 = require("url");
|
|
35771
35783
|
var import_module = require("module");
|
|
35772
35784
|
|
|
35773
35785
|
// src/server/routes/control-plane/index.ts
|
|
35774
|
-
var
|
|
35786
|
+
var import_express33 = __toESM(require_express2(), 1);
|
|
35775
35787
|
|
|
35776
35788
|
// src/server/routes/control-plane/kb.ts
|
|
35777
35789
|
var import_express = __toESM(require_express2(), 1);
|
|
@@ -55984,7 +55996,10 @@ init_db();
|
|
|
55984
55996
|
var chatRouter = (0, import_express10.Router)();
|
|
55985
55997
|
var inFlightControllers = /* @__PURE__ */ new Map();
|
|
55986
55998
|
function getIrantiUrl() {
|
|
55987
|
-
|
|
55999
|
+
const explicit = env["IRANTI_URL"] ?? process.env["IRANTI_URL"] ?? "";
|
|
56000
|
+
if (explicit.trim()) return explicit.trim().replace(/\/$/, "");
|
|
56001
|
+
const port = env["IRANTI_PORT"] ?? process.env["IRANTI_PORT"] ?? "3001";
|
|
56002
|
+
return `http://localhost:${port}`;
|
|
55988
56003
|
}
|
|
55989
56004
|
function getIrantiApiKey2() {
|
|
55990
56005
|
return env["IRANTI_API_KEY"] ?? process.env["IRANTI_API_KEY"] ?? "";
|
|
@@ -56479,7 +56494,10 @@ var import_express12 = __toESM(require_express2(), 1);
|
|
|
56479
56494
|
init_db();
|
|
56480
56495
|
var agentsRouter = (0, import_express12.Router)();
|
|
56481
56496
|
function getIrantiUrl2() {
|
|
56482
|
-
|
|
56497
|
+
const explicit = env["IRANTI_URL"] ?? process.env["IRANTI_URL"] ?? "";
|
|
56498
|
+
if (explicit.trim()) return explicit.trim().replace(/\/$/, "");
|
|
56499
|
+
const port = env["IRANTI_PORT"] ?? process.env["IRANTI_PORT"] ?? "3001";
|
|
56500
|
+
return `http://localhost:${port}`;
|
|
56483
56501
|
}
|
|
56484
56502
|
function getIrantiApiKey3() {
|
|
56485
56503
|
return env["IRANTI_API_KEY"] ?? process.env["IRANTI_API_KEY"] ?? "";
|
|
@@ -57785,7 +57803,10 @@ async function fetchOverviewAgentDetails(baseUrl, headers, agentId) {
|
|
|
57785
57803
|
}
|
|
57786
57804
|
}
|
|
57787
57805
|
function getIrantiUrl4() {
|
|
57788
|
-
|
|
57806
|
+
const explicit = env["IRANTI_URL"] ?? process.env["IRANTI_URL"] ?? "";
|
|
57807
|
+
if (explicit.trim()) return explicit.trim().replace(/\/$/, "");
|
|
57808
|
+
const port = env["IRANTI_PORT"] ?? process.env["IRANTI_PORT"] ?? "3001";
|
|
57809
|
+
return `http://localhost:${port}`;
|
|
57789
57810
|
}
|
|
57790
57811
|
function getIrantiApiKey5() {
|
|
57791
57812
|
return env["IRANTI_API_KEY"] ?? process.env["IRANTI_API_KEY"] ?? "";
|
|
@@ -57883,7 +57904,10 @@ var import_express17 = __toESM(require_express2(), 1);
|
|
|
57883
57904
|
init_db();
|
|
57884
57905
|
var sessionsRouter = (0, import_express17.Router)();
|
|
57885
57906
|
function getIrantiUrl5() {
|
|
57886
|
-
|
|
57907
|
+
const explicit = env["IRANTI_URL"] ?? process.env["IRANTI_URL"] ?? "";
|
|
57908
|
+
if (explicit.trim()) return explicit.trim().replace(/\/$/, "");
|
|
57909
|
+
const port = env["IRANTI_PORT"] ?? process.env["IRANTI_PORT"] ?? "3001";
|
|
57910
|
+
return `http://localhost:${port}`;
|
|
57887
57911
|
}
|
|
57888
57912
|
function getIrantiApiKey6() {
|
|
57889
57913
|
return env["IRANTI_API_KEY"] ?? process.env["IRANTI_API_KEY"] ?? "";
|
|
@@ -62183,8 +62207,54 @@ sessionLedgerRouter.use((err, _req, res, _next) => {
|
|
|
62183
62207
|
});
|
|
62184
62208
|
});
|
|
62185
62209
|
|
|
62210
|
+
// src/server/routes/control-plane/cp-config.ts
|
|
62211
|
+
var import_express32 = __toESM(require_express2(), 1);
|
|
62212
|
+
var import_os6 = require("os");
|
|
62213
|
+
var import_fs13 = require("fs");
|
|
62214
|
+
var import_path19 = require("path");
|
|
62215
|
+
var cpConfigRouter = (0, import_express32.Router)();
|
|
62216
|
+
function getConfigPath() {
|
|
62217
|
+
return (0, import_path19.join)((0, import_os6.homedir)(), ".iranti-runtime", "iranti-cp-config.json");
|
|
62218
|
+
}
|
|
62219
|
+
function readConfig() {
|
|
62220
|
+
try {
|
|
62221
|
+
const raw = (0, import_fs13.readFileSync)(getConfigPath(), "utf8");
|
|
62222
|
+
const parsed = JSON.parse(raw);
|
|
62223
|
+
return typeof parsed === "object" && parsed !== null ? parsed : {};
|
|
62224
|
+
} catch {
|
|
62225
|
+
return {};
|
|
62226
|
+
}
|
|
62227
|
+
}
|
|
62228
|
+
function writeConfig(config2) {
|
|
62229
|
+
(0, import_fs13.mkdirSync)((0, import_path19.join)((0, import_os6.homedir)(), ".iranti-runtime"), { recursive: true });
|
|
62230
|
+
(0, import_fs13.writeFileSync)(getConfigPath(), JSON.stringify(config2, null, 2) + "\n", "utf8");
|
|
62231
|
+
}
|
|
62232
|
+
cpConfigRouter.get("/cp-config", (_req, res) => {
|
|
62233
|
+
const config2 = readConfig();
|
|
62234
|
+
res.json({ defaultPort: config2.defaultPort ?? null });
|
|
62235
|
+
});
|
|
62236
|
+
cpConfigRouter.patch("/cp-config", (req, res) => {
|
|
62237
|
+
const { defaultPort } = req.body;
|
|
62238
|
+
if (defaultPort === null || defaultPort === void 0) {
|
|
62239
|
+
const config3 = readConfig();
|
|
62240
|
+
delete config3.defaultPort;
|
|
62241
|
+
writeConfig(config3);
|
|
62242
|
+
res.json({ ok: true, defaultPort: null });
|
|
62243
|
+
return;
|
|
62244
|
+
}
|
|
62245
|
+
const parsed = Number.parseInt(String(defaultPort), 10);
|
|
62246
|
+
if (!Number.isFinite(parsed) || parsed < 1024 || parsed > 65535) {
|
|
62247
|
+
res.status(400).json({ error: `Invalid port: "${defaultPort}". Must be 1024\u201365535.` });
|
|
62248
|
+
return;
|
|
62249
|
+
}
|
|
62250
|
+
const config2 = readConfig();
|
|
62251
|
+
config2.defaultPort = parsed;
|
|
62252
|
+
writeConfig(config2);
|
|
62253
|
+
res.json({ ok: true, defaultPort: parsed });
|
|
62254
|
+
});
|
|
62255
|
+
|
|
62186
62256
|
// src/server/routes/control-plane/index.ts
|
|
62187
|
-
var controlPlaneRouter = (0,
|
|
62257
|
+
var controlPlaneRouter = (0, import_express33.Router)();
|
|
62188
62258
|
controlPlaneRouter.use("/", archivistRouter);
|
|
62189
62259
|
controlPlaneRouter.use("/", kbRouter);
|
|
62190
62260
|
controlPlaneRouter.use("/", whoknowsRouter);
|
|
@@ -62217,6 +62287,7 @@ controlPlaneRouter.use("/auth-keys", authKeysRouter);
|
|
|
62217
62287
|
controlPlaneRouter.use("/", instanceLifecycleRouter);
|
|
62218
62288
|
controlPlaneRouter.use("/integrations", codexIntegrationRouter);
|
|
62219
62289
|
controlPlaneRouter.use("/debug", attendantDebugRouter);
|
|
62290
|
+
controlPlaneRouter.use("/", cpConfigRouter);
|
|
62220
62291
|
|
|
62221
62292
|
// src/server/lib/staff-event-adapter.ts
|
|
62222
62293
|
init_db();
|
|
@@ -62619,18 +62690,18 @@ function buildPortSelectionPlan(params) {
|
|
|
62619
62690
|
|
|
62620
62691
|
// src/server/index.ts
|
|
62621
62692
|
var _isSea = typeof process.isSea === "function" && process.isSea();
|
|
62622
|
-
var __dirname3 = _isSea ? (0,
|
|
62623
|
-
var clientDistCandidates = process.env.IRANTI_CP_ASSETS_DIR ? [(0,
|
|
62624
|
-
(0,
|
|
62625
|
-
(0,
|
|
62626
|
-
(0,
|
|
62627
|
-
(0,
|
|
62693
|
+
var __dirname3 = _isSea ? (0, import_path21.dirname)(process.execPath) : (0, import_path21.dirname)((0, import_url3.fileURLToPath)(__importmeta_url));
|
|
62694
|
+
var clientDistCandidates = process.env.IRANTI_CP_ASSETS_DIR ? [(0, import_path21.resolve)(process.env.IRANTI_CP_ASSETS_DIR)] : _isSea ? [(0, import_path21.resolve)((0, import_path21.dirname)(process.execPath), "public", "control-plane")] : [
|
|
62695
|
+
(0, import_path21.resolve)(__dirname3, "../../../public/control-plane"),
|
|
62696
|
+
(0, import_path21.resolve)(__dirname3, "../../public/control-plane"),
|
|
62697
|
+
(0, import_path21.resolve)(process.cwd(), "../../public/control-plane"),
|
|
62698
|
+
(0, import_path21.resolve)(process.cwd(), "../public/control-plane")
|
|
62628
62699
|
];
|
|
62629
|
-
var clientDist = clientDistCandidates.find((candidate) => (0,
|
|
62700
|
+
var clientDist = clientDistCandidates.find((candidate) => (0, import_fs15.existsSync)((0, import_path21.resolve)(candidate, "index.html"))) ?? clientDistCandidates[0];
|
|
62630
62701
|
var _version = "0.0.0";
|
|
62631
62702
|
try {
|
|
62632
62703
|
if (_isSea) {
|
|
62633
|
-
const pkgPath = (0,
|
|
62704
|
+
const pkgPath = (0, import_path21.resolve)((0, import_path21.dirname)(process.execPath), "package.json");
|
|
62634
62705
|
const _require = (0, import_module.createRequire)((0, import_url3.pathToFileURL)(process.execPath).href);
|
|
62635
62706
|
const pkg = _require(pkgPath);
|
|
62636
62707
|
_version = pkg.version ?? "0.0.0";
|
|
@@ -62673,9 +62744,9 @@ async function findAvailablePort(start, end) {
|
|
|
62673
62744
|
`[iranti-cp] No available port in range ${start}\u2013${end}. Free one of those ports and try again.`
|
|
62674
62745
|
);
|
|
62675
62746
|
}
|
|
62676
|
-
var app = (0,
|
|
62747
|
+
var app = (0, import_express34.default)();
|
|
62677
62748
|
app.use((0, import_cors.default)({ origin: `http://localhost:5173` }));
|
|
62678
|
-
app.use(
|
|
62749
|
+
app.use(import_express34.default.json());
|
|
62679
62750
|
app.get("/api/control-plane/ping", (_req, res) => {
|
|
62680
62751
|
res.json({
|
|
62681
62752
|
ok: true,
|
|
@@ -62684,9 +62755,9 @@ app.get("/api/control-plane/ping", (_req, res) => {
|
|
|
62684
62755
|
});
|
|
62685
62756
|
});
|
|
62686
62757
|
app.use("/api/control-plane", controlPlaneRouter);
|
|
62687
|
-
app.use("/control-plane",
|
|
62758
|
+
app.use("/control-plane", import_express34.default.static(clientDist));
|
|
62688
62759
|
app.get("/control-plane/*", (_req, res) => {
|
|
62689
|
-
res.sendFile((0,
|
|
62760
|
+
res.sendFile((0, import_path21.resolve)(clientDist, "index.html"));
|
|
62690
62761
|
});
|
|
62691
62762
|
app.get("/", (_req, res) => res.redirect("/control-plane"));
|
|
62692
62763
|
app.use(
|