octopi-agent 0.55.0 → 0.56.0
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/dist/cli/commands.js +1 -1
- package/dist/cli/daemon.d.ts +48 -1
- package/dist/cli/daemon.js +276 -38
- package/dist/cli/helpers.d.ts +13 -1
- package/dist/cli/helpers.js +17 -1
- package/dist/cli/process-utils.d.ts +2 -0
- package/dist/cli/process-utils.js +57 -1
- package/dist/cli/serve-webui.js +20 -3
- package/dist/cli/webui.d.ts +27 -3
- package/dist/cli/webui.js +75 -27
- package/dist/config-schema/index.d.ts +76 -0
- package/dist/config-schema/webui.d.ts +1 -0
- package/dist/config-schema/webui.js +2 -0
- package/dist/init.js +1 -1
- package/dist/integration/tui/app.d.ts +1 -1
- package/octopi.example.json +21 -2
- package/octopi.schema.json +150 -0
- package/package.json +7 -5
package/dist/cli/commands.js
CHANGED
|
@@ -109,7 +109,7 @@ export async function chatCommand(args) {
|
|
|
109
109
|
}
|
|
110
110
|
const channels = config.channels ?? [];
|
|
111
111
|
const httpChannel = channels.find((c) => c.type === "http");
|
|
112
|
-
const port = httpChannel?.port ??
|
|
112
|
+
const port = httpChannel?.port ?? 18180;
|
|
113
113
|
writePidFile({
|
|
114
114
|
pid: child.pid,
|
|
115
115
|
config: configPath ?? join(getOctopiHome(), 'octopi.json'),
|
package/dist/cli/daemon.d.ts
CHANGED
|
@@ -30,10 +30,57 @@ export declare function resolveGatewayPid(args: Pick<CliArgs, 'port' | 'config'>
|
|
|
30
30
|
port: number;
|
|
31
31
|
source: 'port' | 'pidfile' | 'none';
|
|
32
32
|
};
|
|
33
|
+
/** 端口占用者三态:空闲 / 自己的 Gateway / 其他进程 / 无法识别 */
|
|
34
|
+
export type PortOccupantState = 'free' | 'own-gateway' | 'foreign' | 'unknown';
|
|
35
|
+
export interface PortOccupant {
|
|
36
|
+
state: PortOccupantState;
|
|
37
|
+
port: number;
|
|
38
|
+
/** 端口监听进程 PID(探测不到时为 null) */
|
|
39
|
+
pid: number | null;
|
|
40
|
+
/** foreign 时尽力获取的进程名(如 node.exe) */
|
|
41
|
+
processName?: string;
|
|
42
|
+
/** own-gateway:进程存活但 health 尚未响应(启动中 / 卡住) */
|
|
43
|
+
healthy: boolean;
|
|
44
|
+
/** own-gateway:来自 pid 文件 */
|
|
45
|
+
startedAt?: string;
|
|
46
|
+
config?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 识别端口占用者,供 `serve start` 决策:
|
|
50
|
+
*
|
|
51
|
+
* 1. health 是 octopi → 自己的 Gateway(幂等,不是错误)
|
|
52
|
+
* 2. 监听者 pid 与 pid 文件一致 → 自己的 Gateway(health 未响应 = 启动中/卡住)
|
|
53
|
+
* 3. 监听者是其他进程 → foreign(错误:给出占用者身份 + 出路)
|
|
54
|
+
* 4. 无监听者但 pid 文件进程存活且端口一致 → 自己的 Gateway(启动窗口期,防双开)
|
|
55
|
+
* 5. 有 HTTP 响应但拿不到 pid → unknown(警告后继续,失败由子进程日志上浮)
|
|
56
|
+
* 6. 其余 → free
|
|
57
|
+
*
|
|
58
|
+
* @param port 待检查的监听端口
|
|
59
|
+
*/
|
|
60
|
+
export declare function identifyPortOccupant(port: number): Promise<PortOccupant>;
|
|
61
|
+
/** Gateway 守护进程日志路径(`OCTOPI_HOME/logs/gateway.log`) */
|
|
62
|
+
export declare function getGatewayLogPath(): string;
|
|
63
|
+
/** 读取日志尾部若干非空行 */
|
|
64
|
+
export declare function readLogTail(logPath: string, maxLines?: number): string[];
|
|
65
|
+
/**
|
|
66
|
+
* 把子进程日志尾部翻译成用户可执行的结论(原因 + 出路 + 证据位置)
|
|
67
|
+
*
|
|
68
|
+
* @param opts.logTail 日志尾部行(readLogTail 结果)
|
|
69
|
+
* @param opts.port Gateway 监听端口
|
|
70
|
+
* @param opts.configPath 本次使用的配置路径
|
|
71
|
+
* @param opts.logPath 完整日志路径
|
|
72
|
+
* @returns 逐行输出的诊断文本
|
|
73
|
+
*/
|
|
74
|
+
export declare function diagnoseStartupFailure(opts: {
|
|
75
|
+
logTail: string[];
|
|
76
|
+
port: number;
|
|
77
|
+
configPath?: string;
|
|
78
|
+
logPath: string;
|
|
79
|
+
}): string[];
|
|
33
80
|
export declare function createProvider(name: string, cfg: ModelProviderConfig): ModelProvider | null;
|
|
34
81
|
export declare function ensureDaemonConfig(args: CliArgs): Promise<string | undefined>;
|
|
35
82
|
export declare function serveStartCommand(args: CliArgs): Promise<void>;
|
|
36
|
-
export declare function serveStopCommand(args?: Pick<CliArgs, 'port'>): Promise<void>;
|
|
83
|
+
export declare function serveStopCommand(args?: Pick<CliArgs, 'port' | 'config'>): Promise<void>;
|
|
37
84
|
export declare function serveRestartCommand(args: CliArgs): Promise<void>;
|
|
38
85
|
export declare function serveStatusCommand(args?: Pick<CliArgs, 'port' | 'config'>): Promise<void>;
|
|
39
86
|
export declare function serveFgCommand(args: CliArgs): Promise<void>;
|
package/dist/cli/daemon.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* CLI 守护进程管理
|
|
3
3
|
*/
|
|
4
4
|
import { resolve, dirname, join } from 'node:path';
|
|
5
|
-
import {
|
|
6
|
-
import { readFileSync, writeFileSync, unlinkSync, existsSync, mkdirSync } from 'node:fs';
|
|
5
|
+
import { spawn } from 'node:child_process';
|
|
6
|
+
import { readFileSync, writeFileSync, unlinkSync, existsSync, mkdirSync, openSync, closeSync, writeSync, } from 'node:fs';
|
|
7
7
|
import { getOctopiHome, isInitialized, initOctopi, formatInitReport } from '../init.js';
|
|
8
8
|
import { loadConfig, toGatewayConfig } from '../config.js';
|
|
9
9
|
import { createToolSet } from '@octopi-agent/engine/harness/extension/plugin-ecosystem/tools/tool-set.js';
|
|
@@ -11,7 +11,7 @@ import { OpenAIProvider } from '@octopi-agent/engine/integration/providers/opena
|
|
|
11
11
|
import { AnthropicProvider } from '@octopi-agent/engine/integration/providers/anthropic.js';
|
|
12
12
|
import { Gateway } from '@octopi-agent/gateway/gateway/gateway.js';
|
|
13
13
|
import { webuiStartCommand, webuiStopCommand } from './webui.js';
|
|
14
|
-
import { delay, findPidOnPort, isProcessAlive, killProcess, killProcessOnPort, } from './process-utils.js';
|
|
14
|
+
import { delay, findPidOnPort, getProcessName, isProcessAlive, killProcess, killProcessOnPort, } from './process-utils.js';
|
|
15
15
|
// Re-export for existing importers (commands.ts / helpers.ts)
|
|
16
16
|
export { findPidOnPort, isProcessAlive, killProcessOnPort };
|
|
17
17
|
export function getPidPath() {
|
|
@@ -54,7 +54,7 @@ export function resolveListenPort(args, configPath) {
|
|
|
54
54
|
return httpChannel.port;
|
|
55
55
|
}
|
|
56
56
|
catch { /* fall through */ }
|
|
57
|
-
return
|
|
57
|
+
return 18180;
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
60
|
* 解析当前 Gateway 的真实 PID
|
|
@@ -75,27 +75,178 @@ export function resolveGatewayPid(args, configPath) {
|
|
|
75
75
|
}
|
|
76
76
|
return { pid: null, port, source: 'none' };
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
/**
|
|
79
|
+
* 探测端口上的 HTTP 服务是否为 Octopi Gateway
|
|
80
|
+
*
|
|
81
|
+
* - `octopi`:`/health` 返回 200 且 body 形如 `{status:"ok"}`
|
|
82
|
+
* - `other`:有 HTTP 响应但不是 octopi health 形状(被别的服务占用)
|
|
83
|
+
* - `none`:无响应(端口空闲 / 非 HTTP 服务 / 连接被拒)
|
|
84
|
+
*/
|
|
85
|
+
async function probeGatewayHealth(port) {
|
|
86
|
+
try {
|
|
87
|
+
const res = await fetch(`http://127.0.0.1:${port}/health`, {
|
|
88
|
+
signal: AbortSignal.timeout(800),
|
|
89
|
+
});
|
|
90
|
+
if (!res.ok)
|
|
91
|
+
return 'other';
|
|
92
|
+
const body = await res.json().catch(() => null);
|
|
93
|
+
if (typeof body === 'object' &&
|
|
94
|
+
body !== null &&
|
|
95
|
+
body.status === 'ok') {
|
|
96
|
+
return 'octopi';
|
|
97
|
+
}
|
|
98
|
+
return 'other';
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
return 'none';
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* 识别端口占用者,供 `serve start` 决策:
|
|
106
|
+
*
|
|
107
|
+
* 1. health 是 octopi → 自己的 Gateway(幂等,不是错误)
|
|
108
|
+
* 2. 监听者 pid 与 pid 文件一致 → 自己的 Gateway(health 未响应 = 启动中/卡住)
|
|
109
|
+
* 3. 监听者是其他进程 → foreign(错误:给出占用者身份 + 出路)
|
|
110
|
+
* 4. 无监听者但 pid 文件进程存活且端口一致 → 自己的 Gateway(启动窗口期,防双开)
|
|
111
|
+
* 5. 有 HTTP 响应但拿不到 pid → unknown(警告后继续,失败由子进程日志上浮)
|
|
112
|
+
* 6. 其余 → free
|
|
113
|
+
*
|
|
114
|
+
* @param port 待检查的监听端口
|
|
115
|
+
*/
|
|
116
|
+
export async function identifyPortOccupant(port) {
|
|
117
|
+
const probe = await probeGatewayHealth(port);
|
|
118
|
+
const pid = findPidOnPort(port);
|
|
119
|
+
const pidFile = readPidFile();
|
|
120
|
+
const base = { port, healthy: probe === 'octopi' };
|
|
121
|
+
if (probe === 'octopi') {
|
|
122
|
+
return {
|
|
123
|
+
...base,
|
|
124
|
+
state: 'own-gateway',
|
|
125
|
+
pid,
|
|
126
|
+
startedAt: pidFile?.startedAt,
|
|
127
|
+
config: pidFile?.config,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
if (pid !== null) {
|
|
131
|
+
if (pidFile && pidFile.pid === pid && isProcessAlive(pidFile.pid)) {
|
|
132
|
+
return {
|
|
133
|
+
...base,
|
|
134
|
+
state: 'own-gateway',
|
|
135
|
+
pid,
|
|
136
|
+
startedAt: pidFile.startedAt,
|
|
137
|
+
config: pidFile.config,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
...base,
|
|
142
|
+
state: 'foreign',
|
|
143
|
+
pid,
|
|
144
|
+
processName: getProcessName(pid) ?? undefined,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
if (pidFile && isProcessAlive(pidFile.pid) && (pidFile.port ?? port) === port) {
|
|
148
|
+
return {
|
|
149
|
+
...base,
|
|
150
|
+
state: 'own-gateway',
|
|
151
|
+
pid: pidFile.pid,
|
|
152
|
+
startedAt: pidFile.startedAt,
|
|
153
|
+
config: pidFile.config,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
if (probe === 'other') {
|
|
157
|
+
return { ...base, state: 'unknown', pid: null };
|
|
158
|
+
}
|
|
159
|
+
return { ...base, state: 'free', pid: null };
|
|
160
|
+
}
|
|
161
|
+
/** serve start 等待子进程就绪的超时 */
|
|
162
|
+
const STARTUP_TIMEOUT_MS = 20_000;
|
|
163
|
+
/**
|
|
164
|
+
* 等待子进程的 Gateway 就绪
|
|
165
|
+
*
|
|
166
|
+
* 就绪判定(任一满足):
|
|
167
|
+
* 1. 端口持有者 === child.pid(直连 spawn,pid 可信)
|
|
168
|
+
* 2. `/health` 返回 octopi 形状(端口表探测失效时兜底;pid 取端口探测值或 child.pid)
|
|
169
|
+
*
|
|
170
|
+
* 端口被外来者占据时不视为就绪——等子进程退出(race 由上层捕获)或超时,
|
|
171
|
+
* 由 diagnoseStartupFailure 给出结论,避免把外来实例误判为成功。
|
|
172
|
+
*
|
|
173
|
+
* @param port 监听端口
|
|
174
|
+
* @param childPid spawn 返回的子进程 pid
|
|
175
|
+
* @param timeoutMs 最长等待时间
|
|
176
|
+
* @returns 就绪实例 pid;超时返回 null
|
|
177
|
+
*/
|
|
178
|
+
async function waitGatewayReady(port, childPid, timeoutMs = STARTUP_TIMEOUT_MS) {
|
|
79
179
|
const deadline = Date.now() + timeoutMs;
|
|
80
180
|
while (Date.now() < deadline) {
|
|
81
181
|
const portPid = findPidOnPort(port);
|
|
82
|
-
if (portPid
|
|
83
|
-
return
|
|
182
|
+
if (portPid === childPid)
|
|
183
|
+
return childPid;
|
|
184
|
+
if ((await probeGatewayHealth(port)) === 'octopi') {
|
|
185
|
+
return portPid ?? childPid;
|
|
84
186
|
}
|
|
85
|
-
// health 探测兜底(端口表可能稍慢)
|
|
86
|
-
try {
|
|
87
|
-
const res = await fetch(`http://127.0.0.1:${port}/health`, {
|
|
88
|
-
signal: AbortSignal.timeout(800),
|
|
89
|
-
});
|
|
90
|
-
if (res.ok) {
|
|
91
|
-
return findPidOnPort(port);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
catch { /* not ready */ }
|
|
95
187
|
await delay(300);
|
|
96
188
|
}
|
|
97
189
|
return null;
|
|
98
190
|
}
|
|
191
|
+
/** Gateway 守护进程日志路径(`OCTOPI_HOME/logs/gateway.log`) */
|
|
192
|
+
export function getGatewayLogPath() {
|
|
193
|
+
return join(getOctopiHome(), 'logs', 'gateway.log');
|
|
194
|
+
}
|
|
195
|
+
/** 读取日志尾部若干非空行 */
|
|
196
|
+
export function readLogTail(logPath, maxLines = 20) {
|
|
197
|
+
try {
|
|
198
|
+
const lines = readFileSync(logPath, 'utf-8').split(/\r?\n/);
|
|
199
|
+
return lines.filter((l) => l.trim().length > 0).slice(-maxLines);
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
// fork 前失败 / 日志未创建 / 无读权限:降级为“空日志”,诊断走通用提示
|
|
203
|
+
return [];
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* 把子进程日志尾部翻译成用户可执行的结论(原因 + 出路 + 证据位置)
|
|
208
|
+
*
|
|
209
|
+
* @param opts.logTail 日志尾部行(readLogTail 结果)
|
|
210
|
+
* @param opts.port Gateway 监听端口
|
|
211
|
+
* @param opts.configPath 本次使用的配置路径
|
|
212
|
+
* @param opts.logPath 完整日志路径
|
|
213
|
+
* @returns 逐行输出的诊断文本
|
|
214
|
+
*/
|
|
215
|
+
export function diagnoseStartupFailure(opts) {
|
|
216
|
+
const { logTail, port, configPath, logPath } = opts;
|
|
217
|
+
const tail = logTail.join('\n');
|
|
218
|
+
const lines = [];
|
|
219
|
+
if (/EADDRINUSE/i.test(tail)) {
|
|
220
|
+
lines.push(`Port ${port} was taken by another process after the preflight check (EADDRINUSE).`);
|
|
221
|
+
lines.push(` Re-run 'octopi serve start', or start on another port with --port <other>.`);
|
|
222
|
+
}
|
|
223
|
+
else if (/\bEACCES\b|\bEPERM\b/i.test(tail)) {
|
|
224
|
+
lines.push(`Not allowed to bind port ${port} (EACCES) — ports below 1024 may require elevated privileges.`);
|
|
225
|
+
}
|
|
226
|
+
else if (/Cannot find module|ERR_MODULE_NOT_FOUND/i.test(tail)) {
|
|
227
|
+
lines.push('A required module failed to load — the installation may be incomplete or out of sync.');
|
|
228
|
+
lines.push(' Reinstall: npm install (project) or npm install -g octopi-agent (global).');
|
|
229
|
+
}
|
|
230
|
+
else if (/Config file not found/i.test(tail)) {
|
|
231
|
+
lines.push(`Config file not found (searched cwd and ${configPath ?? join(getOctopiHome(), 'octopi.json')}).`);
|
|
232
|
+
lines.push(" Run 'octopi init' to create one, or pass -c <path>.");
|
|
233
|
+
}
|
|
234
|
+
else if (/Config validation failed/i.test(tail)) {
|
|
235
|
+
lines.push(`Configuration is invalid: ${configPath ?? join(getOctopiHome(), 'octopi.json')}`);
|
|
236
|
+
lines.push(' Fix the field reported in the log, then re-run.');
|
|
237
|
+
}
|
|
238
|
+
else if (logTail.length > 0) {
|
|
239
|
+
lines.push('Last lines from the Gateway log:');
|
|
240
|
+
for (const line of logTail)
|
|
241
|
+
lines.push(` ${line}`);
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
lines.push('The Gateway log is empty — the child process produced no output.');
|
|
245
|
+
}
|
|
246
|
+
lines.push(`Full log: ${logPath}`);
|
|
247
|
+
lines.push(`Foreground debug: octopi serve fg${configPath ? ` -c ${configPath}` : ''}`);
|
|
248
|
+
return lines;
|
|
249
|
+
}
|
|
99
250
|
export function createProvider(name, cfg) {
|
|
100
251
|
const apiType = cfg.api === 'anthropic-messages' ? 'anthropic' : 'openai';
|
|
101
252
|
const models = cfg.models.map((m) => ({
|
|
@@ -136,45 +287,123 @@ export async function ensureDaemonConfig(args) {
|
|
|
136
287
|
}
|
|
137
288
|
export async function serveStartCommand(args) {
|
|
138
289
|
const configPath = await ensureDaemonConfig(args);
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
290
|
+
const port = resolveListenPort(args, configPath);
|
|
291
|
+
const logPath = getGatewayLogPath();
|
|
292
|
+
const occupant = await identifyPortOccupant(port);
|
|
293
|
+
// 幂等:自己的 Gateway 已在跑 → 引导 status/restart,不报错
|
|
294
|
+
if (occupant.state === 'own-gateway') {
|
|
295
|
+
console.log(`⚠️ Gateway is already running (PID: ${occupant.pid ?? 'unknown'}, port ${port}).`);
|
|
296
|
+
if (occupant.healthy) {
|
|
297
|
+
console.log(' Health: OK');
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
console.log(' Health: process alive but not responding yet (starting or stuck).');
|
|
301
|
+
console.log(" If it stays this way, run 'octopi serve restart'.");
|
|
302
|
+
}
|
|
303
|
+
if (occupant.startedAt)
|
|
304
|
+
console.log(` Started: ${occupant.startedAt}`);
|
|
305
|
+
if (occupant.config)
|
|
306
|
+
console.log(` Config: ${occupant.config}`);
|
|
307
|
+
console.log(`\nUse 'octopi serve status' to inspect, 'octopi serve restart' to restart, or 'octopi serve stop' to stop.`);
|
|
144
308
|
await webuiStartCommand(configPath, { soft: true });
|
|
145
309
|
process.exit(0);
|
|
146
310
|
}
|
|
311
|
+
// 被无关进程占用 → 明确报错 + 三条出路,绝不静默
|
|
312
|
+
if (occupant.state === 'foreign') {
|
|
313
|
+
const who = [
|
|
314
|
+
occupant.processName ?? 'unknown process',
|
|
315
|
+
occupant.pid ? `PID ${occupant.pid}` : null,
|
|
316
|
+
]
|
|
317
|
+
.filter(Boolean)
|
|
318
|
+
.join(', ');
|
|
319
|
+
console.error(`❌ Cannot start Gateway: port ${port} is occupied by ${who}.`);
|
|
320
|
+
console.error(' The occupant is not an Octopi Gateway.');
|
|
321
|
+
console.error('\n How to resolve:');
|
|
322
|
+
console.error(" 1. Stop the occupying process, then run 'octopi serve start' again");
|
|
323
|
+
console.error(` 2. Start on another port: octopi serve start --port ${port + 1}`);
|
|
324
|
+
console.error(` 3. Change the port permanently: set channels[type=http].port in ${configPath ?? 'your config'}`);
|
|
325
|
+
process.exit(1);
|
|
326
|
+
}
|
|
327
|
+
if (occupant.state === 'unknown') {
|
|
328
|
+
console.warn(`⚠️ Port ${port} has an HTTP service that could not be identified; attempting to start anyway.`);
|
|
329
|
+
console.warn(` If startup fails, the reason will be shown here and in ${logPath}.`);
|
|
330
|
+
}
|
|
331
|
+
// pid 文件是单槽设计:换端口启动时若旧实例仍存活,先明示再接管,避免静默变孤儿
|
|
332
|
+
const prevPidFile = readPidFile();
|
|
333
|
+
if (prevPidFile &&
|
|
334
|
+
isProcessAlive(prevPidFile.pid) &&
|
|
335
|
+
prevPidFile.port !== undefined &&
|
|
336
|
+
prevPidFile.port !== port) {
|
|
337
|
+
console.warn(`⚠️ A tracked Gateway (PID ${prevPidFile.pid}, port ${prevPidFile.port}) is still alive.`);
|
|
338
|
+
console.warn(` Its PID file will be replaced. To stop the old instance: octopi serve stop --port ${prevPidFile.port}`);
|
|
339
|
+
}
|
|
147
340
|
removePidFile();
|
|
341
|
+
mkdirSync(dirname(logPath), { recursive: true });
|
|
342
|
+
const logFd = openSync(logPath, 'a');
|
|
343
|
+
writeSync(logFd, `\n--- octopi serve start ${new Date().toISOString()} port=${port} ---\n`);
|
|
148
344
|
const cliPath = resolve(process.argv[1]);
|
|
149
345
|
const childArgs = ['serve', 'fg'];
|
|
150
346
|
if (configPath)
|
|
151
347
|
childArgs.push('--config', configPath);
|
|
152
|
-
|
|
153
|
-
childArgs.push('--port', String(args.port));
|
|
348
|
+
childArgs.push('--port', String(port));
|
|
154
349
|
if (args.verbose)
|
|
155
350
|
childArgs.push('--verbose');
|
|
156
|
-
|
|
351
|
+
// 子进程 stdout/stderr 落日志:失败原因不再随 stdio:ignore 丢弃
|
|
352
|
+
const child = spawn(process.execPath, [cliPath, ...childArgs], {
|
|
157
353
|
detached: true,
|
|
158
|
-
stdio: 'ignore',
|
|
159
|
-
execArgv: [],
|
|
354
|
+
stdio: ['ignore', logFd, logFd],
|
|
160
355
|
env: { ...process.env, OCTOPI_DAEMON: '1' },
|
|
161
356
|
});
|
|
357
|
+
closeSync(logFd);
|
|
162
358
|
child.unref();
|
|
163
359
|
if (!child.pid) {
|
|
164
360
|
console.error('❌ Failed to start Gateway daemon');
|
|
165
361
|
process.exit(1);
|
|
166
362
|
}
|
|
167
|
-
|
|
363
|
+
let childExitCode = null;
|
|
364
|
+
let spawnError = null;
|
|
365
|
+
const exited = new Promise((resolveExit) => {
|
|
366
|
+
child.once('exit', (code) => {
|
|
367
|
+
childExitCode = code;
|
|
368
|
+
resolveExit();
|
|
369
|
+
});
|
|
370
|
+
// spawn 本身失败(权限/资源等)只走 error 不走 exit:不挂监听会以裸栈 uncaughtException 收场
|
|
371
|
+
child.once('error', (err) => {
|
|
372
|
+
spawnError = err instanceof Error ? err.message : String(err);
|
|
373
|
+
resolveExit();
|
|
374
|
+
});
|
|
375
|
+
});
|
|
168
376
|
console.log(`⏳ Waiting for Gateway on port ${port}...`);
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
377
|
+
const outcome = await Promise.race([
|
|
378
|
+
waitGatewayReady(port, child.pid).then((pid) => ({ kind: 'ready', pid })),
|
|
379
|
+
exited.then(() => ({ kind: 'exited', pid: null })),
|
|
380
|
+
]);
|
|
381
|
+
if (outcome.kind !== 'ready' || !outcome.pid) {
|
|
382
|
+
if (outcome.kind === 'exited') {
|
|
383
|
+
if (spawnError) {
|
|
384
|
+
console.error(`❌ Failed to launch Gateway child process: ${spawnError}`);
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
console.error(`❌ Gateway exited during startup (exit code ${childExitCode ?? 'unknown'}).`);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
else {
|
|
391
|
+
console.error(`❌ Gateway did not become ready within ${STARTUP_TIMEOUT_MS / 1000}s.`);
|
|
392
|
+
// 尽量回收 spawn 出的子进程树
|
|
393
|
+
await killProcess(child.pid, { timeoutMs: 2000 }).catch(() => undefined);
|
|
394
|
+
}
|
|
395
|
+
for (const line of diagnoseStartupFailure({
|
|
396
|
+
logTail: readLogTail(logPath),
|
|
397
|
+
port,
|
|
398
|
+
configPath,
|
|
399
|
+
logPath,
|
|
400
|
+
})) {
|
|
401
|
+
console.error(line);
|
|
402
|
+
}
|
|
175
403
|
process.exit(1);
|
|
176
404
|
}
|
|
177
|
-
|
|
405
|
+
const realPid = outcome.pid;
|
|
406
|
+
// 以端口探测到的真实 PID 为准(与 spawn 返回的 pid 可能不一致)
|
|
178
407
|
writePidFile({
|
|
179
408
|
pid: realPid,
|
|
180
409
|
config: configPath ?? join(getOctopiHome(), 'octopi.json'),
|
|
@@ -184,6 +413,7 @@ export async function serveStartCommand(args) {
|
|
|
184
413
|
console.log(`✅ Gateway started (PID: ${realPid})`);
|
|
185
414
|
console.log(` Config: ${configPath ?? join(getOctopiHome(), 'octopi.json')}`);
|
|
186
415
|
console.log(` Port: ${port}`);
|
|
416
|
+
console.log(` Log: ${logPath}`);
|
|
187
417
|
// Web UI 为可选:失败不拖垮 Gateway(跨平台/无 web 依赖时仍可 serve)
|
|
188
418
|
await webuiStartCommand(configPath, { soft: true });
|
|
189
419
|
console.log(`\nUse 'octopi serve stop' to stop, 'octopi serve status' to check.`);
|
|
@@ -202,7 +432,7 @@ export async function serveStopCommand(args = {}) {
|
|
|
202
432
|
removePidFile();
|
|
203
433
|
console.log('ℹ️ No running Gateway found (cleaned PID file if any).');
|
|
204
434
|
}
|
|
205
|
-
await webuiStopCommand();
|
|
435
|
+
await webuiStopCommand(args.config);
|
|
206
436
|
return;
|
|
207
437
|
}
|
|
208
438
|
let anyStillAlive = false;
|
|
@@ -244,7 +474,7 @@ export async function serveStopCommand(args = {}) {
|
|
|
244
474
|
console.warn(` taskkill /PID ${keepPid} /F`);
|
|
245
475
|
}
|
|
246
476
|
console.log(anyStillAlive ? '⚠️ Gateway not fully stopped.' : '✅ Gateway stopped.');
|
|
247
|
-
await webuiStopCommand();
|
|
477
|
+
await webuiStopCommand(args.config);
|
|
248
478
|
}
|
|
249
479
|
export async function serveRestartCommand(args) {
|
|
250
480
|
await serveStopCommand(args);
|
|
@@ -283,6 +513,12 @@ export async function serveFgCommand(args) {
|
|
|
283
513
|
const port = resolveListenPort(args, configPath);
|
|
284
514
|
const portPid = findPidOnPort(port);
|
|
285
515
|
if (portPid && portPid !== process.pid) {
|
|
516
|
+
// 守护模式下 preflight 已做过占用者识别:静默杀进程与「失败上浮」契约冲突,
|
|
517
|
+
// 直接失败让父进程按日志给出结论(EADDRINUSE / 占用者信息)
|
|
518
|
+
if (process.env.OCTOPI_DAEMON === '1') {
|
|
519
|
+
console.error(`❌ Port ${port} is already occupied by PID ${portPid} (appeared after preflight).`);
|
|
520
|
+
process.exit(1);
|
|
521
|
+
}
|
|
286
522
|
console.log(`⚠️ Port ${port} is occupied by PID ${portPid}. Killing...`);
|
|
287
523
|
const killed = await killProcess(portPid, { timeoutMs: 3000 });
|
|
288
524
|
if (!killed && findPidOnPort(port) === portPid) {
|
|
@@ -471,10 +707,12 @@ async function startGatewayBlocking(configPath, args) {
|
|
|
471
707
|
catch (err) {
|
|
472
708
|
console.warn(`[CLI] session history tools unavailable: ${err instanceof Error ? err.message : String(err)}`);
|
|
473
709
|
}
|
|
710
|
+
const documentPort = await gateway.getDocumentPort().catch(() => null);
|
|
474
711
|
const { all } = createToolSet({
|
|
475
712
|
webSearch: webSearchToolCfg,
|
|
476
713
|
summary: summarySupport,
|
|
477
714
|
sessionHistory: sessionHistoryPort,
|
|
715
|
+
documentPort,
|
|
478
716
|
askUser: (question, options, context) => gateway.askUser({
|
|
479
717
|
sessionId: context.sessionId,
|
|
480
718
|
agentId: context.agentId,
|
|
@@ -513,7 +751,7 @@ async function startGatewayBlocking(configPath, args) {
|
|
|
513
751
|
agentSignal: mountAgentSignal,
|
|
514
752
|
});
|
|
515
753
|
const httpConfig = config.channels?.find((c) => c.type === 'http');
|
|
516
|
-
const listenPort = args.port ?? httpConfig?.port ??
|
|
754
|
+
const listenPort = args.port ?? httpConfig?.port ?? 18180;
|
|
517
755
|
// web.host 可作 Gateway HTTP 的缺省(局域网访问两者都要放开);channels[].host 优先
|
|
518
756
|
const listenHostConfig = httpConfig?.host ?? config.web?.host;
|
|
519
757
|
if (httpConfig || args.port) {
|
package/dist/cli/helpers.d.ts
CHANGED
|
@@ -25,11 +25,23 @@ export declare function findWebDir(configPath?: string, configWebDir?: string):
|
|
|
25
25
|
export interface StartWebUiOptions {
|
|
26
26
|
/** listen host(local → 127.0.0.1,lan → 0.0.0.0) */
|
|
27
27
|
hostArg?: string;
|
|
28
|
-
/** listen port(默认
|
|
28
|
+
/** listen port(默认 8180) */
|
|
29
29
|
port?: number;
|
|
30
|
+
/** 网关端口:透传给 serve-webui 动态下发 /octopi-config.js(缺省不下发) */
|
|
31
|
+
gatewayPort?: number;
|
|
30
32
|
}
|
|
31
33
|
export declare function startWebUi(distDir: string, options?: StartWebUiOptions): number | null;
|
|
32
34
|
export declare function stopWebUi(pid: number): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* `/octopi-config.js` 响应体:把网关端口运行时下发给前端。
|
|
37
|
+
*
|
|
38
|
+
* 唯一真相源是 `octopi.json`——serve-webui 启动时读取,前端加载本脚本后
|
|
39
|
+
* 优先使用其中的端口,构建期兜底仅作回退。
|
|
40
|
+
*
|
|
41
|
+
* @param port 网关端口;undefined 时下发 null(前端走默认)
|
|
42
|
+
* @returns JavaScript 赋值语句
|
|
43
|
+
*/
|
|
44
|
+
export declare function gatewayConfigScript(port?: number): string;
|
|
33
45
|
export declare function getWebUiPidPath(): string;
|
|
34
46
|
export declare function readWebUiPidRecord(): WebUiPidRecord | null;
|
|
35
47
|
export declare function readWebUiPidFile(): number | null;
|
package/dist/cli/helpers.js
CHANGED
|
@@ -85,11 +85,27 @@ export function startWebUi(distDir, options) {
|
|
|
85
85
|
args.push('--host', options.hostArg);
|
|
86
86
|
if (options?.port)
|
|
87
87
|
args.push('--port', String(options.port));
|
|
88
|
+
if (options?.gatewayPort)
|
|
89
|
+
args.push('--gateway-port', String(options.gatewayPort));
|
|
88
90
|
return spawnDetached(process.execPath, args, { cwd: distDir });
|
|
89
91
|
}
|
|
90
92
|
export async function stopWebUi(pid) {
|
|
91
93
|
await killProcess(pid, { timeoutMs: 3000 });
|
|
92
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* `/octopi-config.js` 响应体:把网关端口运行时下发给前端。
|
|
97
|
+
*
|
|
98
|
+
* 唯一真相源是 `octopi.json`——serve-webui 启动时读取,前端加载本脚本后
|
|
99
|
+
* 优先使用其中的端口,构建期兜底仅作回退。
|
|
100
|
+
*
|
|
101
|
+
* @param port 网关端口;undefined 时下发 null(前端走默认)
|
|
102
|
+
* @returns JavaScript 赋值语句
|
|
103
|
+
*/
|
|
104
|
+
export function gatewayConfigScript(port) {
|
|
105
|
+
return port !== undefined
|
|
106
|
+
? `window.__OCTOPI_GATEWAY__=${JSON.stringify({ port })};\n`
|
|
107
|
+
: 'window.__OCTOPI_GATEWAY__=null;\n';
|
|
108
|
+
}
|
|
93
109
|
export function getWebUiPidPath() {
|
|
94
110
|
return join(getOctopiHome(), 'webui.pid');
|
|
95
111
|
}
|
|
@@ -154,5 +170,5 @@ export function resolveGatewayUrl(config) {
|
|
|
154
170
|
if (httpChannel?.port) {
|
|
155
171
|
return `http://localhost:${httpChannel.port}`;
|
|
156
172
|
}
|
|
157
|
-
return 'http://localhost:
|
|
173
|
+
return 'http://localhost:18180';
|
|
158
174
|
}
|
|
@@ -18,6 +18,8 @@ export declare function isProcessAlive(pid: number): boolean;
|
|
|
18
18
|
export declare function isSelfOrAncestorPid(pid: number): boolean;
|
|
19
19
|
/** 查找监听指定 TCP 端口的进程 PID(排除自身) */
|
|
20
20
|
export declare function findPidOnPort(port: number): number | null;
|
|
21
|
+
/** 尽力获取进程可执行名(Windows: tasklist;Unix: ps)。失败返回 null */
|
|
22
|
+
export declare function getProcessName(pid: number): string | null;
|
|
21
23
|
/**
|
|
22
24
|
* 终结进程(Windows 用 taskkill 杀进程树,避免 vite/cmd 残留子进程)
|
|
23
25
|
*
|
|
@@ -129,6 +129,34 @@ export function findPidOnPort(port) {
|
|
|
129
129
|
? findPidOnPortWindows(port)
|
|
130
130
|
: findPidOnPortUnix(port);
|
|
131
131
|
}
|
|
132
|
+
/** 尽力获取进程可执行名(Windows: tasklist;Unix: ps)。失败返回 null */
|
|
133
|
+
export function getProcessName(pid) {
|
|
134
|
+
if (!Number.isInteger(pid) || pid <= 0)
|
|
135
|
+
return null;
|
|
136
|
+
try {
|
|
137
|
+
if (process.platform === 'win32') {
|
|
138
|
+
const out = execFileSync('tasklist', ['/FI', `PID eq ${pid}`, '/FO', 'CSV', '/NH'], {
|
|
139
|
+
encoding: 'utf-8',
|
|
140
|
+
timeout: 5000,
|
|
141
|
+
stdio: 'pipe',
|
|
142
|
+
}).trim();
|
|
143
|
+
if (!out || out.startsWith('INFO'))
|
|
144
|
+
return null;
|
|
145
|
+
const name = out.split(',')[0]?.replace(/^"|"$/g, '').trim();
|
|
146
|
+
return name || null;
|
|
147
|
+
}
|
|
148
|
+
const out = execFileSync('ps', ['-p', String(pid), '-o', 'comm='], {
|
|
149
|
+
encoding: 'utf-8',
|
|
150
|
+
timeout: 5000,
|
|
151
|
+
stdio: 'pipe',
|
|
152
|
+
}).trim();
|
|
153
|
+
return out || null;
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
// 进程可能已退出或无权限查询:名字是锦上添花,缺失不阻塞主流程
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
132
160
|
/**
|
|
133
161
|
* 终结进程(Windows 用 taskkill 杀进程树,避免 vite/cmd 残留子进程)
|
|
134
162
|
*
|
|
@@ -242,9 +270,37 @@ export function spawnDetached(command, args, options = {}) {
|
|
|
242
270
|
function psQuote(value) {
|
|
243
271
|
return `'${value.replace(/'/g, "''")}'`;
|
|
244
272
|
}
|
|
273
|
+
/**
|
|
274
|
+
* 按 CommandLineToArgvW 规则给单个参数加双引号。
|
|
275
|
+
*
|
|
276
|
+
* `Start-Process -ArgumentList` 会把数组元素按空格拼接且不补引号,
|
|
277
|
+
* 不预先 quoting 的话,含空格/引号的参数(长 -e 脚本、带空格的用户路径)
|
|
278
|
+
* 传到子进程会被拆碎。
|
|
279
|
+
*/
|
|
280
|
+
function winQuoteArg(arg) {
|
|
281
|
+
if (arg.length > 0 && !/[\s"]/.test(arg))
|
|
282
|
+
return arg;
|
|
283
|
+
let result = '"';
|
|
284
|
+
let backslashes = 0;
|
|
285
|
+
for (const ch of arg) {
|
|
286
|
+
if (ch === '\\') {
|
|
287
|
+
backslashes++;
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
if (ch === '"') {
|
|
291
|
+
result += '\\'.repeat(backslashes * 2 + 1) + '"';
|
|
292
|
+
backslashes = 0;
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
result += '\\'.repeat(backslashes) + ch;
|
|
296
|
+
backslashes = 0;
|
|
297
|
+
}
|
|
298
|
+
result += '\\'.repeat(backslashes * 2) + '"';
|
|
299
|
+
return result;
|
|
300
|
+
}
|
|
245
301
|
function spawnDetachedWindows(command, args, options) {
|
|
246
302
|
const cwd = typeof options.cwd === 'string' && options.cwd ? options.cwd : undefined;
|
|
247
|
-
const argArray = args.map(psQuote).join(', ');
|
|
303
|
+
const argArray = args.map((a) => psQuote(winQuoteArg(a))).join(', ');
|
|
248
304
|
const workDir = cwd ? ` -WorkingDirectory ${psQuote(cwd)}` : '';
|
|
249
305
|
const script = `$p = Start-Process -FilePath ${psQuote(command)} -ArgumentList @(${argArray})${workDir} -WindowStyle Hidden -PassThru; ` +
|
|
250
306
|
`if ($p) { Write-Output $p.Id }`;
|
package/dist/cli/serve-webui.js
CHANGED
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Static file server for prebuilt WebUI dist (product path — no Vite).
|
|
3
3
|
*
|
|
4
|
-
* Spawn: node dist/cli/serve-webui.js <distDir> [--host <host>] [--port <port>]
|
|
4
|
+
* Spawn: node dist/cli/serve-webui.js <distDir> [--host <host>] [--port <port>] [--gateway-port <port>]
|
|
5
5
|
*/
|
|
6
6
|
import { createServer } from 'node:http';
|
|
7
7
|
import { readFile, stat } from 'node:fs/promises';
|
|
8
8
|
import { join, normalize, extname, resolve, sep } from 'node:path';
|
|
9
|
+
import { gatewayConfigScript } from './helpers.js';
|
|
9
10
|
const distArg = process.argv[2];
|
|
10
11
|
if (!distArg) {
|
|
11
|
-
console.error('usage: serve-webui <distDir> [--host host] [--port port]');
|
|
12
|
+
console.error('usage: serve-webui <distDir> [--host host] [--port port] [--gateway-port port]');
|
|
12
13
|
process.exit(1);
|
|
13
14
|
}
|
|
14
15
|
const distDir = resolve(distArg);
|
|
15
16
|
let host = '127.0.0.1';
|
|
16
|
-
let port =
|
|
17
|
+
let port = 8180;
|
|
18
|
+
let gatewayPort;
|
|
17
19
|
for (let i = 3; i < process.argv.length; i++) {
|
|
18
20
|
if (process.argv[i] === '--host' && process.argv[i + 1])
|
|
19
21
|
host = process.argv[++i];
|
|
20
22
|
if (process.argv[i] === '--port' && process.argv[i + 1])
|
|
21
23
|
port = Number(process.argv[++i]);
|
|
24
|
+
if (process.argv[i] === '--gateway-port' && process.argv[i + 1]) {
|
|
25
|
+
const gp = Number(process.argv[++i]);
|
|
26
|
+
if (Number.isInteger(gp) && gp >= 1 && gp <= 65535)
|
|
27
|
+
gatewayPort = gp;
|
|
28
|
+
}
|
|
22
29
|
}
|
|
23
30
|
const MIME = {
|
|
24
31
|
'.html': 'text/html; charset=utf-8',
|
|
@@ -47,6 +54,16 @@ function safeJoin(root, urlPath) {
|
|
|
47
54
|
}
|
|
48
55
|
const server = createServer(async (req, res) => {
|
|
49
56
|
try {
|
|
57
|
+
const reqPath = (req.url || '/').split('?')[0];
|
|
58
|
+
// 运行时配置优先于静态文件:每次启动按 octopi.json 重新应答,no-store 防缓存
|
|
59
|
+
if (req.method === 'GET' && reqPath === '/octopi-config.js') {
|
|
60
|
+
res.writeHead(200, {
|
|
61
|
+
'Content-Type': 'application/javascript; charset=utf-8',
|
|
62
|
+
'Cache-Control': 'no-store',
|
|
63
|
+
});
|
|
64
|
+
res.end(gatewayConfigScript(gatewayPort));
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
50
67
|
let file = safeJoin(distDir, req.url || '/');
|
|
51
68
|
if (!file) {
|
|
52
69
|
res.writeHead(403).end('Forbidden');
|
package/dist/cli/webui.d.ts
CHANGED
|
@@ -5,9 +5,33 @@ import type { CliArgs } from './args.js';
|
|
|
5
5
|
export interface WebUiStartOptions {
|
|
6
6
|
/** soft: 失败只警告,不 process.exit(供 serve start 使用) */
|
|
7
7
|
soft?: boolean;
|
|
8
|
+
/** CLI `--port` 覆盖(仅 webui 子命令传入;优先于配置 web.port) */
|
|
9
|
+
port?: number;
|
|
8
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* 解析 Web UI 监听端口:CLI `--port` > 配置 `web.port` > 默认 8180
|
|
13
|
+
*
|
|
14
|
+
* @param configPath 配置文件路径(缺省按 cwd / OCTOPI_HOME 查找)
|
|
15
|
+
* @param override CLI 传入的端口(非法值忽略,回落配置/默认)
|
|
16
|
+
* @returns 监听端口
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveWebUiPort(configPath?: string, override?: number): number;
|
|
19
|
+
/**
|
|
20
|
+
* 读取网关 HTTP 监听端口(`channels[type=http].port`)
|
|
21
|
+
*
|
|
22
|
+
* 供 serve-webui 下发 `/octopi-config.js`;缺省 undefined 时前端回落默认 18180。
|
|
23
|
+
*
|
|
24
|
+
* @param configPath 配置文件路径(缺省按 cwd / OCTOPI_HOME 查找)
|
|
25
|
+
* @returns 合法端口号,配置缺失/非法时为 undefined
|
|
26
|
+
*/
|
|
27
|
+
export declare function readGatewayPort(configPath?: string): number | undefined;
|
|
28
|
+
/** 探测疑似 Web UI 实例:先查期望端口(配置/默认),再查旧版与常见 vite 端口 */
|
|
29
|
+
export declare function findPidOnVitePorts(expectedPort?: number): {
|
|
30
|
+
pid: number;
|
|
31
|
+
port: number;
|
|
32
|
+
} | null;
|
|
9
33
|
export declare function webuiStartCommand(configPath?: string, options?: WebUiStartOptions): Promise<void>;
|
|
10
|
-
export declare function webuiStopCommand(): Promise<void>;
|
|
11
|
-
export declare function webuiRestartCommand(configPath?: string): Promise<void>;
|
|
12
|
-
export declare function webuiStatusCommand(): Promise<void>;
|
|
34
|
+
export declare function webuiStopCommand(configPath?: string): Promise<void>;
|
|
35
|
+
export declare function webuiRestartCommand(configPath?: string, options?: WebUiStartOptions): Promise<void>;
|
|
36
|
+
export declare function webuiStatusCommand(configPath?: string): Promise<void>;
|
|
13
37
|
export declare function webuiCommand(args: CliArgs): Promise<void>;
|
package/dist/cli/webui.js
CHANGED
|
@@ -4,14 +4,16 @@
|
|
|
4
4
|
import { resolve } from 'node:path';
|
|
5
5
|
import { existsSync, readFileSync } from 'node:fs';
|
|
6
6
|
import { networkInterfaces } from 'node:os';
|
|
7
|
-
import { isLanHost,
|
|
7
|
+
import { isLanHost, resolveListenHost, } from '@octopi-agent/engine/config.js';
|
|
8
8
|
import { ensureDaemonConfig } from './daemon.js';
|
|
9
9
|
import { getOctopiHome } from '@octopi-agent/engine/paths.js';
|
|
10
10
|
import { findWebDist, startWebUi, stopWebUi, readWebUiPidRecord, writeWebUiPidFile, removeWebUiPidFile, } from './helpers.js';
|
|
11
11
|
import { findPidOnPort, isProcessAlive } from './process-utils.js';
|
|
12
|
-
/**
|
|
13
|
-
const
|
|
14
|
-
/**
|
|
12
|
+
/** Web UI 默认监听端口 */
|
|
13
|
+
const DEFAULT_WEBUI_PORT = 8180;
|
|
14
|
+
/** 旧版默认与常见 vite dev 端口(认领未写入 pid 文件的实例) */
|
|
15
|
+
const LEGACY_VITE_PORTS = [5173, 5174, 4173];
|
|
16
|
+
/** 轻量读取配置(web 段 + 网关 http 端口),避免 loadConfig 重复打日志/强校验 */
|
|
15
17
|
function readConfigWebSettings(configPath) {
|
|
16
18
|
try {
|
|
17
19
|
let filePath;
|
|
@@ -31,16 +33,52 @@ function readConfigWebSettings(configPath) {
|
|
|
31
33
|
const host = typeof raw.web?.host === 'string' && raw.web.host.trim()
|
|
32
34
|
? raw.web.host.trim()
|
|
33
35
|
: undefined;
|
|
34
|
-
|
|
36
|
+
const port = typeof raw.web?.port === 'number' ? raw.web.port : undefined;
|
|
37
|
+
const httpChannel = Array.isArray(raw.channels)
|
|
38
|
+
? (raw.channels.find((c) => !!c && typeof c === 'object' && c.type === 'http') ?? null)
|
|
39
|
+
: null;
|
|
40
|
+
const gatewayPort = typeof httpChannel?.port === 'number' ? httpChannel.port : undefined;
|
|
41
|
+
return {
|
|
42
|
+
dir,
|
|
43
|
+
host,
|
|
44
|
+
port: isValidPort(port) ? port : undefined,
|
|
45
|
+
gatewayPort: isValidPort(gatewayPort) ? gatewayPort : undefined,
|
|
46
|
+
};
|
|
35
47
|
}
|
|
36
48
|
catch {
|
|
37
49
|
return {};
|
|
38
50
|
}
|
|
39
51
|
}
|
|
52
|
+
function isValidPort(port) {
|
|
53
|
+
return typeof port === 'number' && Number.isInteger(port) && port >= 1 && port <= 65535;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 解析 Web UI 监听端口:CLI `--port` > 配置 `web.port` > 默认 8180
|
|
57
|
+
*
|
|
58
|
+
* @param configPath 配置文件路径(缺省按 cwd / OCTOPI_HOME 查找)
|
|
59
|
+
* @param override CLI 传入的端口(非法值忽略,回落配置/默认)
|
|
60
|
+
* @returns 监听端口
|
|
61
|
+
*/
|
|
62
|
+
export function resolveWebUiPort(configPath, override) {
|
|
63
|
+
if (isValidPort(override))
|
|
64
|
+
return override;
|
|
65
|
+
return readConfigWebSettings(configPath).port ?? DEFAULT_WEBUI_PORT;
|
|
66
|
+
}
|
|
40
67
|
/** 读取配置中的 web.dir */
|
|
41
68
|
function readConfigWebDir(configPath) {
|
|
42
69
|
return readConfigWebSettings(configPath).dir;
|
|
43
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* 读取网关 HTTP 监听端口(`channels[type=http].port`)
|
|
73
|
+
*
|
|
74
|
+
* 供 serve-webui 下发 `/octopi-config.js`;缺省 undefined 时前端回落默认 18180。
|
|
75
|
+
*
|
|
76
|
+
* @param configPath 配置文件路径(缺省按 cwd / OCTOPI_HOME 查找)
|
|
77
|
+
* @returns 合法端口号,配置缺失/非法时为 undefined
|
|
78
|
+
*/
|
|
79
|
+
export function readGatewayPort(configPath) {
|
|
80
|
+
return readConfigWebSettings(configPath).gatewayPort;
|
|
81
|
+
}
|
|
44
82
|
/** 探测本机局域网 IPv4(用于启动提示) */
|
|
45
83
|
function firstLanIPv4() {
|
|
46
84
|
try {
|
|
@@ -57,9 +95,14 @@ function firstLanIPv4() {
|
|
|
57
95
|
}
|
|
58
96
|
return null;
|
|
59
97
|
}
|
|
60
|
-
/**
|
|
61
|
-
function findPidOnVitePorts() {
|
|
62
|
-
|
|
98
|
+
/** 探测疑似 Web UI 实例:先查期望端口(配置/默认),再查旧版与常见 vite 端口 */
|
|
99
|
+
export function findPidOnVitePorts(expectedPort) {
|
|
100
|
+
const ports = [expectedPort ?? DEFAULT_WEBUI_PORT, ...LEGACY_VITE_PORTS];
|
|
101
|
+
const seen = new Set();
|
|
102
|
+
for (const port of ports) {
|
|
103
|
+
if (seen.has(port))
|
|
104
|
+
continue;
|
|
105
|
+
seen.add(port);
|
|
63
106
|
const pid = findPidOnPort(port);
|
|
64
107
|
if (pid && isProcessAlive(pid))
|
|
65
108
|
return { pid, port };
|
|
@@ -77,7 +120,8 @@ export async function webuiStartCommand(configPath, options) {
|
|
|
77
120
|
return;
|
|
78
121
|
}
|
|
79
122
|
// pid 文件缺失/失效,但端口上已有实例:提示而非叠跑第二个 vite
|
|
80
|
-
const
|
|
123
|
+
const port = resolveWebUiPort(configPath, options?.port);
|
|
124
|
+
const portHit = findPidOnVitePorts(port);
|
|
81
125
|
if (portHit) {
|
|
82
126
|
console.log(`⚠️ Web UI appears already running on port ${portHit.port} (PID: ${portHit.pid})`);
|
|
83
127
|
console.log(' Not tracked in ~/.octopi/webui.pid (started outside CLI?)');
|
|
@@ -105,10 +149,14 @@ export async function webuiStartCommand(configPath, options) {
|
|
|
105
149
|
console.error(' - ~/.octopi/web/dist');
|
|
106
150
|
process.exit(1);
|
|
107
151
|
}
|
|
108
|
-
|
|
152
|
+
// Static server must bind IPv4 127.0.0.1 for local (Windows `localhost` may be IPv6-only)
|
|
153
|
+
const listenHost = resolveListenHost(webHost);
|
|
109
154
|
const lanOpen = isLanHost(webHost);
|
|
110
|
-
const
|
|
111
|
-
|
|
155
|
+
const pid = startWebUi(webDist, {
|
|
156
|
+
hostArg: listenHost,
|
|
157
|
+
port,
|
|
158
|
+
gatewayPort: webSettings.gatewayPort,
|
|
159
|
+
});
|
|
112
160
|
if (!pid) {
|
|
113
161
|
if (soft) {
|
|
114
162
|
console.warn('⚠️ Failed to start Web UI static server. Gateway continues without it.');
|
|
@@ -140,7 +188,7 @@ export async function webuiStartCommand(configPath, options) {
|
|
|
140
188
|
process.exit(0);
|
|
141
189
|
}
|
|
142
190
|
}
|
|
143
|
-
export async function webuiStopCommand() {
|
|
191
|
+
export async function webuiStopCommand(configPath) {
|
|
144
192
|
const record = readWebUiPidRecord();
|
|
145
193
|
let pid = record?.pid;
|
|
146
194
|
let source = pid ? 'pidfile' : 'none';
|
|
@@ -150,7 +198,7 @@ export async function webuiStopCommand() {
|
|
|
150
198
|
removeWebUiPidFile();
|
|
151
199
|
pid = undefined;
|
|
152
200
|
}
|
|
153
|
-
const portHit = findPidOnVitePorts();
|
|
201
|
+
const portHit = findPidOnVitePorts(resolveWebUiPort(configPath));
|
|
154
202
|
if (portHit) {
|
|
155
203
|
pid = portHit.pid;
|
|
156
204
|
source = 'port';
|
|
@@ -159,7 +207,7 @@ export async function webuiStopCommand() {
|
|
|
159
207
|
}
|
|
160
208
|
if (!pid) {
|
|
161
209
|
console.log('ℹ️ No Web UI instance found.');
|
|
162
|
-
console.log(' CLI tracks ~/.octopi/webui.pid; it also probes
|
|
210
|
+
console.log(' CLI tracks ~/.octopi/webui.pid; it also probes the configured port (default 8180) and legacy 5173/5174/4173.');
|
|
163
211
|
console.log(' Manually started vite outside those ports must be stopped in its own terminal.');
|
|
164
212
|
return;
|
|
165
213
|
}
|
|
@@ -177,22 +225,22 @@ export async function webuiStopCommand() {
|
|
|
177
225
|
console.warn(`⚠️ Web UI PID ${pid} may still be running`);
|
|
178
226
|
}
|
|
179
227
|
}
|
|
180
|
-
export async function webuiRestartCommand(configPath) {
|
|
181
|
-
await webuiStopCommand();
|
|
228
|
+
export async function webuiRestartCommand(configPath, options) {
|
|
229
|
+
await webuiStopCommand(configPath);
|
|
182
230
|
await new Promise((r) => setTimeout(r, 500));
|
|
183
|
-
await webuiStartCommand(configPath);
|
|
231
|
+
await webuiStartCommand(configPath, options);
|
|
184
232
|
}
|
|
185
|
-
export async function webuiStatusCommand() {
|
|
233
|
+
export async function webuiStatusCommand(configPath) {
|
|
186
234
|
const record = readWebUiPidRecord();
|
|
187
235
|
const pid = record?.pid;
|
|
188
|
-
const portHit = findPidOnVitePorts();
|
|
236
|
+
const portHit = findPidOnVitePorts(resolveWebUiPort(configPath));
|
|
189
237
|
if (!pid) {
|
|
190
238
|
console.log('ℹ️ No Web UI instance found in ~/.octopi/webui.pid.');
|
|
191
239
|
if (portHit && isProcessAlive(portHit.pid)) {
|
|
192
240
|
console.log(` But port ${portHit.port} is LISTENING (PID: ${portHit.pid}) — started outside CLI?`);
|
|
193
241
|
}
|
|
194
|
-
const configWebDir = readConfigWebDir();
|
|
195
|
-
const webDist = findWebDist(
|
|
242
|
+
const configWebDir = readConfigWebDir(configPath);
|
|
243
|
+
const webDist = findWebDist(configPath, configWebDir);
|
|
196
244
|
if (webDist)
|
|
197
245
|
console.log(` Detected Web UI dist (not started via CLI): ${webDist}`);
|
|
198
246
|
return;
|
|
@@ -224,20 +272,20 @@ export async function webuiCommand(args) {
|
|
|
224
272
|
const configPath = await ensureDaemonConfig(args);
|
|
225
273
|
switch (args.subcommand) {
|
|
226
274
|
case 'start':
|
|
227
|
-
await webuiStartCommand(configPath);
|
|
275
|
+
await webuiStartCommand(configPath, { port: args.port });
|
|
228
276
|
break;
|
|
229
277
|
case 'stop':
|
|
230
|
-
await webuiStopCommand();
|
|
278
|
+
await webuiStopCommand(configPath);
|
|
231
279
|
break;
|
|
232
280
|
case 'restart':
|
|
233
|
-
await webuiRestartCommand(configPath);
|
|
281
|
+
await webuiRestartCommand(configPath, { port: args.port });
|
|
234
282
|
break;
|
|
235
283
|
case 'status':
|
|
236
|
-
await webuiStatusCommand();
|
|
284
|
+
await webuiStatusCommand(configPath);
|
|
237
285
|
break;
|
|
238
286
|
case undefined:
|
|
239
287
|
console.log('💡 Tip: Use "octopi webui start" to start Web UI.\n');
|
|
240
|
-
await webuiStartCommand(configPath);
|
|
288
|
+
await webuiStartCommand(configPath, { port: args.port });
|
|
241
289
|
break;
|
|
242
290
|
default:
|
|
243
291
|
console.error(`Unknown webui subcommand: ${args.subcommand}`);
|
|
@@ -325,6 +325,43 @@ export declare const OctopiConfigSchema: z.ZodObject<{
|
|
|
325
325
|
auto: "auto";
|
|
326
326
|
}>>;
|
|
327
327
|
}, z.core.$strip>>;
|
|
328
|
+
documents: z.ZodOptional<z.ZodObject<{
|
|
329
|
+
extract: z.ZodOptional<z.ZodObject<{
|
|
330
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
331
|
+
backend: z.ZodOptional<z.ZodEnum<{
|
|
332
|
+
auto: "auto";
|
|
333
|
+
"t0-only": "t0-only";
|
|
334
|
+
}>>;
|
|
335
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
336
|
+
maxFileBytes: z.ZodOptional<z.ZodNumber>;
|
|
337
|
+
allowedRoots: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
338
|
+
}, z.core.$strip>>;
|
|
339
|
+
legacy: z.ZodOptional<z.ZodObject<{
|
|
340
|
+
converter: z.ZodOptional<z.ZodEnum<{
|
|
341
|
+
none: "none";
|
|
342
|
+
soffice: "soffice";
|
|
343
|
+
remote: "remote";
|
|
344
|
+
}>>;
|
|
345
|
+
sofficePath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
346
|
+
cacheDir: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
347
|
+
cacheMaxBytes: z.ZodOptional<z.ZodNumber>;
|
|
348
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
349
|
+
allowTextScrape: z.ZodOptional<z.ZodBoolean>;
|
|
350
|
+
}, z.core.$strip>>;
|
|
351
|
+
markitdown: z.ZodOptional<z.ZodObject<{
|
|
352
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
353
|
+
command: z.ZodOptional<z.ZodString>;
|
|
354
|
+
}, z.core.$strip>>;
|
|
355
|
+
enhanced: z.ZodOptional<z.ZodObject<{
|
|
356
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
357
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
358
|
+
endpoint: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
359
|
+
command: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
360
|
+
authRef: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
361
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
362
|
+
preferOn: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
363
|
+
}, z.core.$strip>>;
|
|
364
|
+
}, z.core.$strip>>;
|
|
328
365
|
knowledge: z.ZodOptional<z.ZodObject<{
|
|
329
366
|
recall: z.ZodOptional<z.ZodEnum<{
|
|
330
367
|
off: "off";
|
|
@@ -697,6 +734,7 @@ export declare const OctopiConfigSchema: z.ZodObject<{
|
|
|
697
734
|
local: "local";
|
|
698
735
|
lan: "lan";
|
|
699
736
|
}>, z.ZodString]>>;
|
|
737
|
+
port: z.ZodOptional<z.ZodNumber>;
|
|
700
738
|
}, z.core.$strip>>;
|
|
701
739
|
}, z.core.$strip>;
|
|
702
740
|
/** @deprecated 使用 {@link OctopiConfigSchema};历史名保留 */
|
|
@@ -998,6 +1036,43 @@ export declare const HarnessConfigSchema: z.ZodObject<{
|
|
|
998
1036
|
auto: "auto";
|
|
999
1037
|
}>>;
|
|
1000
1038
|
}, z.core.$strip>>;
|
|
1039
|
+
documents: z.ZodOptional<z.ZodObject<{
|
|
1040
|
+
extract: z.ZodOptional<z.ZodObject<{
|
|
1041
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
1042
|
+
backend: z.ZodOptional<z.ZodEnum<{
|
|
1043
|
+
auto: "auto";
|
|
1044
|
+
"t0-only": "t0-only";
|
|
1045
|
+
}>>;
|
|
1046
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
1047
|
+
maxFileBytes: z.ZodOptional<z.ZodNumber>;
|
|
1048
|
+
allowedRoots: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1049
|
+
}, z.core.$strip>>;
|
|
1050
|
+
legacy: z.ZodOptional<z.ZodObject<{
|
|
1051
|
+
converter: z.ZodOptional<z.ZodEnum<{
|
|
1052
|
+
none: "none";
|
|
1053
|
+
soffice: "soffice";
|
|
1054
|
+
remote: "remote";
|
|
1055
|
+
}>>;
|
|
1056
|
+
sofficePath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1057
|
+
cacheDir: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1058
|
+
cacheMaxBytes: z.ZodOptional<z.ZodNumber>;
|
|
1059
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
1060
|
+
allowTextScrape: z.ZodOptional<z.ZodBoolean>;
|
|
1061
|
+
}, z.core.$strip>>;
|
|
1062
|
+
markitdown: z.ZodOptional<z.ZodObject<{
|
|
1063
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
1064
|
+
command: z.ZodOptional<z.ZodString>;
|
|
1065
|
+
}, z.core.$strip>>;
|
|
1066
|
+
enhanced: z.ZodOptional<z.ZodObject<{
|
|
1067
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
1068
|
+
provider: z.ZodOptional<z.ZodString>;
|
|
1069
|
+
endpoint: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1070
|
+
command: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1071
|
+
authRef: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1072
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
1073
|
+
preferOn: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1074
|
+
}, z.core.$strip>>;
|
|
1075
|
+
}, z.core.$strip>>;
|
|
1001
1076
|
knowledge: z.ZodOptional<z.ZodObject<{
|
|
1002
1077
|
recall: z.ZodOptional<z.ZodEnum<{
|
|
1003
1078
|
off: "off";
|
|
@@ -1370,6 +1445,7 @@ export declare const HarnessConfigSchema: z.ZodObject<{
|
|
|
1370
1445
|
local: "local";
|
|
1371
1446
|
lan: "lan";
|
|
1372
1447
|
}>, z.ZodString]>>;
|
|
1448
|
+
port: z.ZodOptional<z.ZodNumber>;
|
|
1373
1449
|
}, z.core.$strip>>;
|
|
1374
1450
|
}, z.core.$strip>;
|
|
1375
1451
|
export type OctopiConfig = z.infer<typeof OctopiConfigSchema>;
|
|
@@ -12,4 +12,6 @@ export const WebConfigSchema = z.object({
|
|
|
12
12
|
dir: z.string().optional(),
|
|
13
13
|
/** 监听 host:local(默认仅本机)| lan(局域网)| 具体 IP/主机名 */
|
|
14
14
|
host: NetworkHostSchema.optional(),
|
|
15
|
+
/** 监听端口(默认 8180;`octopi webui start --port` 优先) */
|
|
16
|
+
port: z.number().int().min(1).max(65535).optional(),
|
|
15
17
|
});
|
package/dist/init.js
CHANGED
package/octopi.example.json
CHANGED
|
@@ -78,6 +78,24 @@
|
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
80
|
|
|
81
|
+
"documents": {
|
|
82
|
+
"extract": {
|
|
83
|
+
"enabled": true,
|
|
84
|
+
"timeoutMs": 30000,
|
|
85
|
+
"maxFileBytes": 52428800
|
|
86
|
+
},
|
|
87
|
+
"legacy": {
|
|
88
|
+
"converter": "none"
|
|
89
|
+
},
|
|
90
|
+
"markitdown": {
|
|
91
|
+
"enabled": false
|
|
92
|
+
},
|
|
93
|
+
"enhanced": {
|
|
94
|
+
"enabled": false,
|
|
95
|
+
"provider": "mineru"
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
|
|
81
99
|
"contextAssembler": {
|
|
82
100
|
"systemBudgetRatio": 0.22,
|
|
83
101
|
"includeLayerPreview": true,
|
|
@@ -159,7 +177,7 @@
|
|
|
159
177
|
|
|
160
178
|
"channels": [{
|
|
161
179
|
"type": "http",
|
|
162
|
-
"port":
|
|
180
|
+
"port": 18180,
|
|
163
181
|
"host": "local",
|
|
164
182
|
"path": "/messages"
|
|
165
183
|
}],
|
|
@@ -209,7 +227,8 @@
|
|
|
209
227
|
|
|
210
228
|
"web": {
|
|
211
229
|
"dir": "./web",
|
|
212
|
-
"host": "local"
|
|
230
|
+
"host": "local",
|
|
231
|
+
"port": 8180
|
|
213
232
|
},
|
|
214
233
|
|
|
215
234
|
"gateway": {
|
package/octopi.schema.json
CHANGED
|
@@ -1009,6 +1009,151 @@
|
|
|
1009
1009
|
}
|
|
1010
1010
|
}
|
|
1011
1011
|
},
|
|
1012
|
+
"documents": {
|
|
1013
|
+
"type": "object",
|
|
1014
|
+
"properties": {
|
|
1015
|
+
"extract": {
|
|
1016
|
+
"type": "object",
|
|
1017
|
+
"properties": {
|
|
1018
|
+
"enabled": {
|
|
1019
|
+
"type": "boolean"
|
|
1020
|
+
},
|
|
1021
|
+
"backend": {
|
|
1022
|
+
"type": "string",
|
|
1023
|
+
"enum": [
|
|
1024
|
+
"auto",
|
|
1025
|
+
"t0-only"
|
|
1026
|
+
]
|
|
1027
|
+
},
|
|
1028
|
+
"timeoutMs": {
|
|
1029
|
+
"type": "integer",
|
|
1030
|
+
"exclusiveMinimum": 0,
|
|
1031
|
+
"maximum": 9007199254740991
|
|
1032
|
+
},
|
|
1033
|
+
"maxFileBytes": {
|
|
1034
|
+
"type": "integer",
|
|
1035
|
+
"exclusiveMinimum": 0,
|
|
1036
|
+
"maximum": 9007199254740991
|
|
1037
|
+
},
|
|
1038
|
+
"allowedRoots": {
|
|
1039
|
+
"type": "array",
|
|
1040
|
+
"items": {
|
|
1041
|
+
"type": "string"
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
},
|
|
1046
|
+
"legacy": {
|
|
1047
|
+
"type": "object",
|
|
1048
|
+
"properties": {
|
|
1049
|
+
"converter": {
|
|
1050
|
+
"type": "string",
|
|
1051
|
+
"enum": [
|
|
1052
|
+
"none",
|
|
1053
|
+
"soffice",
|
|
1054
|
+
"remote"
|
|
1055
|
+
]
|
|
1056
|
+
},
|
|
1057
|
+
"sofficePath": {
|
|
1058
|
+
"anyOf": [
|
|
1059
|
+
{
|
|
1060
|
+
"type": "string"
|
|
1061
|
+
},
|
|
1062
|
+
{
|
|
1063
|
+
"type": "null"
|
|
1064
|
+
}
|
|
1065
|
+
]
|
|
1066
|
+
},
|
|
1067
|
+
"cacheDir": {
|
|
1068
|
+
"anyOf": [
|
|
1069
|
+
{
|
|
1070
|
+
"type": "string"
|
|
1071
|
+
},
|
|
1072
|
+
{
|
|
1073
|
+
"type": "null"
|
|
1074
|
+
}
|
|
1075
|
+
]
|
|
1076
|
+
},
|
|
1077
|
+
"cacheMaxBytes": {
|
|
1078
|
+
"type": "integer",
|
|
1079
|
+
"exclusiveMinimum": 0,
|
|
1080
|
+
"maximum": 9007199254740991
|
|
1081
|
+
},
|
|
1082
|
+
"timeoutMs": {
|
|
1083
|
+
"type": "integer",
|
|
1084
|
+
"exclusiveMinimum": 0,
|
|
1085
|
+
"maximum": 9007199254740991
|
|
1086
|
+
},
|
|
1087
|
+
"allowTextScrape": {
|
|
1088
|
+
"type": "boolean"
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
},
|
|
1092
|
+
"markitdown": {
|
|
1093
|
+
"type": "object",
|
|
1094
|
+
"properties": {
|
|
1095
|
+
"enabled": {
|
|
1096
|
+
"type": "boolean"
|
|
1097
|
+
},
|
|
1098
|
+
"command": {
|
|
1099
|
+
"type": "string"
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
},
|
|
1103
|
+
"enhanced": {
|
|
1104
|
+
"type": "object",
|
|
1105
|
+
"properties": {
|
|
1106
|
+
"enabled": {
|
|
1107
|
+
"type": "boolean"
|
|
1108
|
+
},
|
|
1109
|
+
"provider": {
|
|
1110
|
+
"type": "string"
|
|
1111
|
+
},
|
|
1112
|
+
"endpoint": {
|
|
1113
|
+
"anyOf": [
|
|
1114
|
+
{
|
|
1115
|
+
"type": "string"
|
|
1116
|
+
},
|
|
1117
|
+
{
|
|
1118
|
+
"type": "null"
|
|
1119
|
+
}
|
|
1120
|
+
]
|
|
1121
|
+
},
|
|
1122
|
+
"command": {
|
|
1123
|
+
"anyOf": [
|
|
1124
|
+
{
|
|
1125
|
+
"type": "string"
|
|
1126
|
+
},
|
|
1127
|
+
{
|
|
1128
|
+
"type": "null"
|
|
1129
|
+
}
|
|
1130
|
+
]
|
|
1131
|
+
},
|
|
1132
|
+
"authRef": {
|
|
1133
|
+
"anyOf": [
|
|
1134
|
+
{
|
|
1135
|
+
"type": "string"
|
|
1136
|
+
},
|
|
1137
|
+
{
|
|
1138
|
+
"type": "null"
|
|
1139
|
+
}
|
|
1140
|
+
]
|
|
1141
|
+
},
|
|
1142
|
+
"timeoutMs": {
|
|
1143
|
+
"type": "integer",
|
|
1144
|
+
"exclusiveMinimum": 0,
|
|
1145
|
+
"maximum": 9007199254740991
|
|
1146
|
+
},
|
|
1147
|
+
"preferOn": {
|
|
1148
|
+
"type": "array",
|
|
1149
|
+
"items": {
|
|
1150
|
+
"type": "string"
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
},
|
|
1012
1157
|
"knowledge": {
|
|
1013
1158
|
"type": "object",
|
|
1014
1159
|
"properties": {
|
|
@@ -2193,6 +2338,11 @@
|
|
|
2193
2338
|
"minLength": 1
|
|
2194
2339
|
}
|
|
2195
2340
|
]
|
|
2341
|
+
},
|
|
2342
|
+
"port": {
|
|
2343
|
+
"type": "integer",
|
|
2344
|
+
"minimum": 1,
|
|
2345
|
+
"maximum": 65535
|
|
2196
2346
|
}
|
|
2197
2347
|
}
|
|
2198
2348
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "octopi-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.56.0",
|
|
4
4
|
"description": "Octopi suite — CLI (bin: octopi), config IO, and dependency umbrella for core/engine/gateway/webui",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
"build:gateway": "npm --prefix packages/gateway run build",
|
|
27
27
|
"copy:build-assets": "node scripts/copy-build-assets.mjs",
|
|
28
28
|
"generate:schema": "node scripts/generate-octopi-schema.mjs",
|
|
29
|
+
"release:prep": "node scripts/release.mjs prep",
|
|
30
|
+
"release:print": "node scripts/release.mjs print",
|
|
29
31
|
"dev": "tsc --watch",
|
|
30
32
|
"test": "node --experimental-vm-modules node_modules/vitest/vitest.mjs run",
|
|
31
33
|
"lint": "eslint .",
|
|
@@ -62,10 +64,10 @@
|
|
|
62
64
|
"dependencies": {
|
|
63
65
|
"@earendil-works/pi-tui": "^0.78.0",
|
|
64
66
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
65
|
-
"@octopi-agent/core": "
|
|
66
|
-
"@octopi-agent/engine": "
|
|
67
|
-
"@octopi-agent/gateway": "
|
|
68
|
-
"@octopi-agent/webui": "
|
|
67
|
+
"@octopi-agent/core": "0.56.0",
|
|
68
|
+
"@octopi-agent/engine": "0.56.0",
|
|
69
|
+
"@octopi-agent/gateway": "0.56.0",
|
|
70
|
+
"@octopi-agent/webui": "0.56.0",
|
|
69
71
|
"@types/ws": "^8.18.1",
|
|
70
72
|
"chalk": "^5.6.2",
|
|
71
73
|
"js-yaml": "^4.3.2",
|