octopi-agent 0.98.4 → 0.102.10
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 +4 -3
- package/README.zh.md +2 -2
- package/dist/cli/commands.js +34 -21
- package/dist/cli/daemon.d.ts +1 -1
- package/dist/cli/daemon.js +22 -9
- package/dist/cli/doctor/index.js +36 -2
- package/dist/cli/listen-config.d.ts +52 -0
- package/dist/cli/listen-config.js +28 -0
- package/dist/cli/webui.js +5 -1
- package/dist/config-migrations.d.ts +28 -0
- package/dist/config-migrations.js +202 -6
- package/dist/config-schema/index.d.ts +115 -323
- package/dist/config-schema/index.js +1 -1
- package/dist/config-schema/unknown-keys.js +8 -1
- package/dist/config-schema/unwired-keys.d.ts +26 -0
- package/dist/config-schema/unwired-keys.js +60 -0
- package/dist/config.js +20 -3
- package/dist/init.d.ts +1 -0
- package/dist/init.js +1 -2
- package/dist/integration/tui/app.d.ts +1 -1
- package/dist/integration/tui/app.js +13 -13
- package/dist/testing/scenario-runner.js +1 -1
- package/octopi.example.json +26 -28
- package/octopi.schema.json +117 -532
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ Between "works in the demo" and "runs in production" stand five walls:
|
|
|
21
21
|
- **Garbage memory** — a bolted-on vector store happily remembers things it should never have believed.
|
|
22
22
|
- **Context rot** — the window fills until the model can no longer see what matters, and nobody can say why.
|
|
23
23
|
- **Unenforced authority** — permissions are a promise in a prompt, not a constraint in the engine.
|
|
24
|
-
- **Unattended runs** — the first time a run goes sideways at 3 a.m., nothing is watching, and the only policy is `
|
|
24
|
+
- **Unattended runs** — the first time a run goes sideways at 3 a.m., nothing is watching, and the only policy is `maxSteps`.
|
|
25
25
|
|
|
26
26
|
Frameworks hand you the loop and wish you luck with the walls.
|
|
27
27
|
|
|
@@ -160,8 +160,9 @@ owned, budgeted pipeline**:
|
|
|
160
160
|
assembly order (what the model sees) are orthogonal axes — a distinction the
|
|
161
161
|
rest of the industry has yet to put into words.
|
|
162
162
|
- **Token accounting with calibration** — three estimation tiers (LLM-reported →
|
|
163
|
-
tokenizer → heuristic
|
|
164
|
-
`
|
|
163
|
+
tokenizer → heuristic; segmented classification: 1 token/char for CJK), with a
|
|
164
|
+
per-model calibration ledger (`ContextSizeLedger`) feeding measured actuals
|
|
165
|
+
into every decision reading.
|
|
165
166
|
- **Per-layer budget competition and a manifest** — every layer's inclusion or
|
|
166
167
|
drop is reasoned and inspectable. *Why this turn's prompt looks the way it
|
|
167
168
|
does* is a question with an answer.
|
package/README.zh.md
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
- **垃圾记忆**——外挂的向量库会兴高采烈地记住它本不该相信的东西。
|
|
24
24
|
- **上下文腐烂**——窗口被填满,直到模型看不见真正重要的东西,而没人说得清为什么。
|
|
25
25
|
- **权限只是承诺**——权限写在 prompt 里,而不是刻在引擎里。
|
|
26
|
-
- **无人值守的运行**——凌晨三点第一次跑飞的时候,什么都没在看着,唯一的策略是 `
|
|
26
|
+
- **无人值守的运行**——凌晨三点第一次跑飞的时候,什么都没在看着,唯一的策略是 `maxSteps`。
|
|
27
27
|
|
|
28
28
|
框架把 loop 给你,把五堵墙留给你。
|
|
29
29
|
|
|
@@ -112,7 +112,7 @@ Information ──蒸馏──► Memory ──织网──► Cognition ──
|
|
|
112
112
|
*收益:provider 前缀缓存轮轮命中——延迟热、输入按缓存价计费。*
|
|
113
113
|
- **三条所有权带**——Agent 基质(跨会话持久)/ Run(易失,绝不回写模板)/ Session(一等连续性)。它*解释了*为什么多个 agent 可以共用一条对话线,却永不共享人格与记忆。
|
|
114
114
|
- **形成 ≠ 装配。** 分馏链(知识怎么形成)与装配序(模型看到什么)是正交的两根轴——这一点,业界还没人把它说出口。
|
|
115
|
-
- **带校准的 Token 计量**——三层估算(LLM 实测 → tokenizer →
|
|
115
|
+
- **带校准的 Token 计量**——三层估算(LLM 实测 → tokenizer → 启发式;分类查表:中文 1 token/字),实测经按 model 分键的校准台账(`ContextSizeLedger`)作用到所有决策读数。
|
|
116
116
|
- **逐层预算竞争 + manifest**——每层的入选或裁撤都有理由、可检视。*"这一轮的 prompt 为什么长这样"是一个有答案的问题。*
|
|
117
117
|
- **Compact 键 = `(sessionId, agentId)`**——摘要跟着"会话 × 智能体"走,永不污染模板。
|
|
118
118
|
|
package/dist/cli/commands.js
CHANGED
|
@@ -6,7 +6,9 @@ import { fork } from 'node:child_process';
|
|
|
6
6
|
import { loadConfig } from '../config.js';
|
|
7
7
|
import { initOctopi, getOctopiHome, isInitialized, formatInitReport } from '../init.js';
|
|
8
8
|
import { readPidFile, writePidFile, removePidFile, isProcessAlive } from './daemon.js';
|
|
9
|
+
import { resolveListenConfig } from './listen-config.js';
|
|
9
10
|
import { createProviderFromConfig } from '@octopi-agent/engine/config.js';
|
|
11
|
+
import enginePackage from '@octopi-agent/engine/package.json' with { type: 'json' };
|
|
10
12
|
import { resolveGatewayUrl, resolveGatewayApiKey, selectChatAgent } from './helpers.js';
|
|
11
13
|
export function showHelp() {
|
|
12
14
|
console.log(`
|
|
@@ -125,7 +127,11 @@ export async function chatCommand(args) {
|
|
|
125
127
|
}
|
|
126
128
|
const channels = config.channels ?? [];
|
|
127
129
|
const httpChannel = channels.find((c) => c.type === "http");
|
|
128
|
-
|
|
130
|
+
// 与 daemon 监听同序(listen-config.ts):fork 的 serve fg 子进程按配置自解析,此处必须同值
|
|
131
|
+
const port = resolveListenConfig({
|
|
132
|
+
gateway: config.gateway,
|
|
133
|
+
http: httpChannel,
|
|
134
|
+
}).port;
|
|
129
135
|
writePidFile({
|
|
130
136
|
pid: child.pid,
|
|
131
137
|
config: configPath ?? join(getOctopiHome(), 'octopi.json'),
|
|
@@ -207,38 +213,44 @@ export async function pluginCommand(args) {
|
|
|
207
213
|
fs.mkdirSync(targetDir, { recursive: true });
|
|
208
214
|
const manifest = {
|
|
209
215
|
id: pluginName,
|
|
216
|
+
apiVersion: '1',
|
|
210
217
|
name: `${pluginName} plugin`,
|
|
211
218
|
version: '0.1.0',
|
|
212
219
|
description: 'A plugin for Octopi',
|
|
213
|
-
|
|
220
|
+
entry: './dist/index.js',
|
|
214
221
|
enabledByDefault: true,
|
|
222
|
+
engine: { octopi: `>=${enginePackage.version} <1` },
|
|
223
|
+
configSchema: { type: 'object', additionalProperties: false },
|
|
224
|
+
contributes: { tools: ['hello'] },
|
|
215
225
|
};
|
|
216
226
|
fs.writeFileSync(path.join(targetDir, 'octopi.plugin.json'), JSON.stringify(manifest, null, 2) + '\n');
|
|
217
|
-
const entryCode =
|
|
218
|
-
* ${pluginName} plugin
|
|
219
|
-
*/
|
|
227
|
+
const entryCode = `import { definePlugin } from '@octopi-agent/engine/plugin-sdk/plugin-entry';
|
|
220
228
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
export default definePluginEntry({
|
|
229
|
+
export default definePlugin({
|
|
224
230
|
id: '${pluginName}',
|
|
225
|
-
name: '${pluginName}',
|
|
226
|
-
description: 'A plugin for Octopi',
|
|
227
|
-
|
|
228
231
|
register(api) {
|
|
229
|
-
|
|
232
|
+
api.registerTool(
|
|
233
|
+
{ name: 'hello', description: 'Return a greeting', parameters: {}, capabilities: ['egress'] },
|
|
234
|
+
async () => 'Hello from ${pluginName}',
|
|
235
|
+
);
|
|
230
236
|
},
|
|
231
237
|
});
|
|
232
238
|
`;
|
|
233
|
-
fs.
|
|
239
|
+
fs.mkdirSync(path.join(targetDir, 'src'));
|
|
240
|
+
fs.writeFileSync(path.join(targetDir, 'src', 'index.ts'), entryCode);
|
|
234
241
|
const pkg = {
|
|
235
242
|
name: `@octopi-agent/plugin-${pluginName}`,
|
|
236
243
|
version: '0.1.0',
|
|
237
244
|
type: 'module',
|
|
238
|
-
main: 'index.js',
|
|
239
|
-
types: 'index.d.ts',
|
|
245
|
+
main: 'dist/index.js',
|
|
246
|
+
types: 'dist/index.d.ts',
|
|
247
|
+
scripts: { build: 'tsc -p tsconfig.json' },
|
|
240
248
|
peerDependencies: {
|
|
241
|
-
octopi:
|
|
249
|
+
'@octopi-agent/engine': `>=${enginePackage.version} <1`,
|
|
250
|
+
},
|
|
251
|
+
devDependencies: {
|
|
252
|
+
'@types/node': '^24',
|
|
253
|
+
typescript: '^6',
|
|
242
254
|
},
|
|
243
255
|
};
|
|
244
256
|
fs.writeFileSync(path.join(targetDir, 'package.json'), JSON.stringify(pkg, null, 2) + '\n');
|
|
@@ -248,23 +260,24 @@ export default definePluginEntry({
|
|
|
248
260
|
module: 'ESNext',
|
|
249
261
|
moduleResolution: 'bundler',
|
|
250
262
|
declaration: true,
|
|
251
|
-
outDir: '
|
|
252
|
-
rootDir: '
|
|
263
|
+
outDir: 'dist',
|
|
264
|
+
rootDir: 'src',
|
|
253
265
|
strict: true,
|
|
254
266
|
esModuleInterop: true,
|
|
255
267
|
skipLibCheck: true,
|
|
256
268
|
},
|
|
257
|
-
include: ['
|
|
269
|
+
include: ['src/**/*.ts'],
|
|
258
270
|
};
|
|
259
271
|
fs.writeFileSync(path.join(targetDir, 'tsconfig.json'), JSON.stringify(tsconfig, null, 2) + '\n');
|
|
260
272
|
console.log(`\n🐙 Plugin "${pluginName}" created at ${targetDir}\n`);
|
|
261
273
|
console.log('Files:');
|
|
262
274
|
console.log(` ${targetDir}/octopi.plugin.json ← Plugin manifest`);
|
|
263
|
-
console.log(` ${targetDir}/index.ts
|
|
275
|
+
console.log(` ${targetDir}/src/index.ts ← Entry point`);
|
|
264
276
|
console.log(` ${targetDir}/package.json ← Package config`);
|
|
265
277
|
console.log(` ${targetDir}/tsconfig.json ← TypeScript config`);
|
|
266
278
|
console.log('\nNext steps:');
|
|
267
279
|
console.log(` cd ${targetDir}`);
|
|
268
280
|
console.log(' # Edit index.ts to add your plugin logic');
|
|
269
|
-
console.log('
|
|
281
|
+
console.log(' npm install && npm run build');
|
|
282
|
+
console.log(' # Set plugins.loadPaths and plugins.entries.<id>.enabled, then restart Octopi');
|
|
270
283
|
}
|
package/dist/cli/daemon.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare function getPidPath(): string;
|
|
|
14
14
|
export declare function readPidFile(): DaemonPidFile | null;
|
|
15
15
|
export declare function writePidFile(data: DaemonPidFile): void;
|
|
16
16
|
export declare function removePidFile(): void;
|
|
17
|
-
/** 从配置解析 Gateway
|
|
17
|
+
/** 从配置解析 Gateway 监听端口(与 listen-config.ts 同一优先级:CLI > gateway > channels > 18180) */
|
|
18
18
|
export declare function resolveListenPort(args: Pick<CliArgs, 'port' | 'config'>, configPath?: string): number;
|
|
19
19
|
/**
|
|
20
20
|
* 解析当前 Gateway 的真实 PID
|
package/dist/cli/daemon.js
CHANGED
|
@@ -6,6 +6,7 @@ import { spawn } from 'node:child_process';
|
|
|
6
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, resolveConfigFilePath } from '../config.js';
|
|
9
|
+
import { resolveListenConfig } from './listen-config.js';
|
|
9
10
|
import { createToolSet } from '@octopi-agent/engine/harness/extension/plugin-ecosystem/tools/tool-set.js';
|
|
10
11
|
import { createProviderFromConfig, createWireDumpSinkFromConfig } from '@octopi-agent/engine/config.js';
|
|
11
12
|
import { startLoopWatchdog } from '@octopi-agent/engine/integration/observability/loop-watchdog.js';
|
|
@@ -46,7 +47,7 @@ export function removePidFile() {
|
|
|
46
47
|
catch { /* ignore */ }
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
|
-
/** 从配置解析 Gateway
|
|
50
|
+
/** 从配置解析 Gateway 监听端口(与 listen-config.ts 同一优先级:CLI > gateway > channels > 18180) */
|
|
50
51
|
export function resolveListenPort(args, configPath) {
|
|
51
52
|
if (args.port)
|
|
52
53
|
return args.port;
|
|
@@ -54,8 +55,8 @@ export function resolveListenPort(args, configPath) {
|
|
|
54
55
|
try {
|
|
55
56
|
const config = loadConfig(path);
|
|
56
57
|
const httpChannel = config.channels?.find((c) => c.type === 'http');
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
const gatewayOverride = config.gateway;
|
|
59
|
+
return resolveListenConfig({ gateway: gatewayOverride, http: httpChannel }).port;
|
|
59
60
|
}
|
|
60
61
|
catch { /* fall through */ }
|
|
61
62
|
return 18180;
|
|
@@ -479,7 +480,7 @@ export async function serveStartCommand(args) {
|
|
|
479
480
|
console.error('\n How to resolve:');
|
|
480
481
|
console.error(" 1. Stop the occupying process, then run 'octopi serve start' again");
|
|
481
482
|
console.error(` 2. Start on another port: octopi serve start --port ${port + 1}`);
|
|
482
|
-
console.error(` 3. Change the port permanently: set channels[type=http].port in ${configPath ?? 'your config'}`);
|
|
483
|
+
console.error(` 3. Change the port permanently: set gateway.port or channels[type=http].port in ${configPath ?? 'your config'}`);
|
|
483
484
|
process.exit(1);
|
|
484
485
|
}
|
|
485
486
|
if (occupant.state === 'unknown') {
|
|
@@ -949,7 +950,6 @@ async function startGatewayBlocking(configPath, args) {
|
|
|
949
950
|
providers: providerMap,
|
|
950
951
|
levelMap: config.models?.level,
|
|
951
952
|
fallbackProvider: fallback,
|
|
952
|
-
legacySummaryModel: config.contextEngine?.summaryModel,
|
|
953
953
|
model: summaryCfg?.model,
|
|
954
954
|
modelLevel: summaryCfg?.modelLevel,
|
|
955
955
|
gate: summaryCfg?.gate,
|
|
@@ -1053,10 +1053,18 @@ async function startGatewayBlocking(configPath, args) {
|
|
|
1053
1053
|
agentSignal: arCfg?.agentSignal,
|
|
1054
1054
|
});
|
|
1055
1055
|
const httpConfig = config.channels?.find((c) => c.type === 'http');
|
|
1056
|
-
|
|
1056
|
+
// gateway 进程面覆盖段接线(listen-config.ts):CLI --port > gateway.* > channels[type=http] > 缺省
|
|
1057
|
+
const gatewayOverride = config.gateway;
|
|
1058
|
+
const listenCfg = resolveListenConfig({
|
|
1059
|
+
cliPort: args.port,
|
|
1060
|
+
gateway: gatewayOverride,
|
|
1061
|
+
http: httpConfig,
|
|
1062
|
+
webHost: config.web?.host,
|
|
1063
|
+
});
|
|
1064
|
+
const listenPort = listenCfg.port;
|
|
1057
1065
|
// web.host 可作 Gateway HTTP 的缺省(局域网访问两者都要放开);channels[].host 优先
|
|
1058
|
-
const listenHostConfig =
|
|
1059
|
-
if (
|
|
1066
|
+
const listenHostConfig = listenCfg.host;
|
|
1067
|
+
if (listenCfg.enabled) {
|
|
1060
1068
|
const { HttpChannelAdapter } = await import('@octopi-agent/gateway/protocols/http.js');
|
|
1061
1069
|
const { WebApiRouter } = await import('@octopi-agent/gateway/web/api/router.js');
|
|
1062
1070
|
const { resolveListenHost } = await import('@octopi-agent/engine/config.js');
|
|
@@ -1100,6 +1108,11 @@ async function startGatewayBlocking(configPath, args) {
|
|
|
1100
1108
|
approverIdentity: httpConfig?.apiKey ? 'owner' : undefined,
|
|
1101
1109
|
});
|
|
1102
1110
|
const listenHost = resolveListenHost(listenHostConfig);
|
|
1111
|
+
// SEC-7 边界显式化:无 apiKey 时 console/config API 不设防(checkAuth 放行),
|
|
1112
|
+
// 与 `--port` 单独启动同语义;gateway.port 覆盖段使该组合更易撞上,必须出声。
|
|
1113
|
+
if (!httpConfig?.apiKey) {
|
|
1114
|
+
console.warn('⚠️ Gateway HTTP listener has NO apiKey (channels[type=http].apiKey): console/config API is unauthenticated — local use only, configure an apiKey otherwise.');
|
|
1115
|
+
}
|
|
1103
1116
|
gateway.registerChannel(new HttpChannelAdapter({
|
|
1104
1117
|
port: listenPort,
|
|
1105
1118
|
host: listenHost,
|
|
@@ -1128,7 +1141,7 @@ async function startGatewayBlocking(configPath, args) {
|
|
|
1128
1141
|
writePidFile({
|
|
1129
1142
|
pid: process.pid,
|
|
1130
1143
|
config: configPath ?? join(getOctopiHome(), 'octopi.json'),
|
|
1131
|
-
port:
|
|
1144
|
+
port: listenCfg.enabled ? listenPort : undefined,
|
|
1132
1145
|
startedAt: new Date().toISOString(),
|
|
1133
1146
|
});
|
|
1134
1147
|
await gateway.start();
|
package/dist/cli/doctor/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { createInterface } from 'node:readline/promises';
|
|
|
8
8
|
import { dirname, join, resolve } from 'node:path';
|
|
9
9
|
import { expandHomePath, getOctopiHome } from '@octopi-agent/engine/paths.js';
|
|
10
10
|
import { validateConfig } from '../../config-schema.js';
|
|
11
|
-
import { applyConfigMigrations, detectConfigMigrations, expandEnvPlaceholders, parseConfigJson, } from '../../config-migrations.js';
|
|
11
|
+
import { applyConfigMigrations, CONFIG_MIGRATION_RULES, detectConfigMigrations, expandEnvPlaceholders, parseConfigJson, } from '../../config-migrations.js';
|
|
12
12
|
import { applyDataLayerFixes, checkDeprecatedSessionStore, detectDataLayer, resolveAgentDataTargets, detectKnowledgeDb, detectKnowledgeSourcesAsync, migrateKnowledgeDatabase, knowledgeDbPath, listKnowledgeSources, removeKnowledgeSource, } from './data.js';
|
|
13
13
|
import { latestConfigBackup, listConfigBackups, restoreConfigFromBackup, } from './restore.js';
|
|
14
14
|
import { redactConfig, looksLikeSecret, redactSecretString } from './redact.js';
|
|
@@ -179,8 +179,42 @@ function checkLayout(home, configPath, raw, allowDeleteLegacyDirs, explicitConfi
|
|
|
179
179
|
return findings;
|
|
180
180
|
}
|
|
181
181
|
// ── Zod / 语义 ──
|
|
182
|
+
/**
|
|
183
|
+
* 静默跑一遍全部迁移规则(只用于预演校验,不改磁盘、不打日志)
|
|
184
|
+
*
|
|
185
|
+
* doctor 已通过 `detectConfigMigrations` 单独报告迁移项,这里只需要一个「迁移后形状」
|
|
186
|
+
* 喂给 Zod,避免同一个旧键被报两次。
|
|
187
|
+
*
|
|
188
|
+
* @param raw - 就地迁移的配置副本
|
|
189
|
+
*/
|
|
190
|
+
function applyMigrationsQuietly(raw) {
|
|
191
|
+
for (const rule of CONFIG_MIGRATION_RULES) {
|
|
192
|
+
try {
|
|
193
|
+
rule.apply(raw);
|
|
194
|
+
}
|
|
195
|
+
catch {
|
|
196
|
+
// 单条规则失败不应阻断结构校验:残留的旧键会由 Zod/迁移项各自报告,这里不吞诊断
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Zod 结构校验
|
|
202
|
+
*
|
|
203
|
+
* 在**迁移后**的副本上校验:CFG011 等删除键会先被搬进 `_legacy`,否则 `.strict()` 段
|
|
204
|
+
* (如 `gateway`)会额外报一条 `Unrecognized key`,让用户误以为配置有结构性错误——
|
|
205
|
+
* 而实际只需「删掉这个已废弃的键」(迁移项已单独报告)。
|
|
206
|
+
*
|
|
207
|
+
* @param raw - 未展开、未迁移的 raw 配置
|
|
208
|
+
* @returns Zod 相关 findings
|
|
209
|
+
*/
|
|
182
210
|
function checkZod(raw) {
|
|
183
|
-
const
|
|
211
|
+
const probe = raw !== null && typeof raw === 'object'
|
|
212
|
+
? JSON.parse(JSON.stringify(raw))
|
|
213
|
+
: raw;
|
|
214
|
+
if (probe !== null && typeof probe === 'object') {
|
|
215
|
+
applyMigrationsQuietly(probe);
|
|
216
|
+
}
|
|
217
|
+
const result = validateConfig(probe);
|
|
184
218
|
if (result.success) {
|
|
185
219
|
return [
|
|
186
220
|
{
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gateway HTTP 监听配置解析(纯函数;daemon / webui / TUI 接线与测试共用)
|
|
3
|
+
*
|
|
4
|
+
* 优先级(docs/KNOWN-ISSUES.md `gateway` 覆盖段条目,语义自 v0.98.8):
|
|
5
|
+
* CLI `--port` > `gateway.port`(进程面覆盖)> `channels[type=http].port` > 默认 18180;
|
|
6
|
+
* host 同序:`gateway.host` > `channels[].host` > `web.host`(web.host 仅作缺省,
|
|
7
|
+
* 局域网访问两者都要放开)。
|
|
8
|
+
*
|
|
9
|
+
* 语义要点:端口来源即监听开关(CLI --port / gateway.port / channels 任一存在才启动
|
|
10
|
+
* 监听);认证(apiKey)与 path 仍取 `channels[type=http]`,`gateway` 段只覆盖
|
|
11
|
+
* port/host。单独 `gateway.host` 不启动监听,但渠道存在时仍改变绑定地址。
|
|
12
|
+
*
|
|
13
|
+
* 注意:本模块只解析对象段(channels 数组内取 type=http 一项)。
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
import type { NetworkHostConfig } from '@octopi-agent/engine/config.js';
|
|
18
|
+
/** 监听 host 配置值(NetworkHostSchema:'local' | 'lan' | 具体 IP/主机名) */
|
|
19
|
+
export type ListenHostValue = NetworkHostConfig;
|
|
20
|
+
/** 监听解析输入 */
|
|
21
|
+
export interface ListenConfigInput {
|
|
22
|
+
/** CLI `--port` */
|
|
23
|
+
cliPort?: number;
|
|
24
|
+
/** `gateway` 进程面覆盖段 */
|
|
25
|
+
gateway?: {
|
|
26
|
+
port?: number;
|
|
27
|
+
host?: ListenHostValue;
|
|
28
|
+
};
|
|
29
|
+
/** `channels[type=http]` 段 */
|
|
30
|
+
http?: {
|
|
31
|
+
port?: number;
|
|
32
|
+
host?: ListenHostValue;
|
|
33
|
+
};
|
|
34
|
+
/** `web.host`(仅作 host 缺省) */
|
|
35
|
+
webHost?: ListenHostValue;
|
|
36
|
+
}
|
|
37
|
+
/** 监听解析结果 */
|
|
38
|
+
export interface ListenConfig {
|
|
39
|
+
/** 生效监听端口(enabled=false 时为缺省值,不作数) */
|
|
40
|
+
port: number;
|
|
41
|
+
/** 生效 host 配置值(undefined = 由 resolveListenHost 决定缺省) */
|
|
42
|
+
host?: ListenHostValue;
|
|
43
|
+
/** 是否启动 HTTP 监听(存在显式端口来源:CLI / gateway / channels) */
|
|
44
|
+
enabled: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 解析 Gateway HTTP 监听配置
|
|
48
|
+
*
|
|
49
|
+
* @param input - 各来源配置
|
|
50
|
+
* @returns 监听配置(端口/host/是否启动)
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolveListenConfig(input: ListenConfigInput): ListenConfig;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gateway HTTP 监听配置解析(纯函数;daemon / webui / TUI 接线与测试共用)
|
|
3
|
+
*
|
|
4
|
+
* 优先级(docs/KNOWN-ISSUES.md `gateway` 覆盖段条目,语义自 v0.98.8):
|
|
5
|
+
* CLI `--port` > `gateway.port`(进程面覆盖)> `channels[type=http].port` > 默认 18180;
|
|
6
|
+
* host 同序:`gateway.host` > `channels[].host` > `web.host`(web.host 仅作缺省,
|
|
7
|
+
* 局域网访问两者都要放开)。
|
|
8
|
+
*
|
|
9
|
+
* 语义要点:端口来源即监听开关(CLI --port / gateway.port / channels 任一存在才启动
|
|
10
|
+
* 监听);认证(apiKey)与 path 仍取 `channels[type=http]`,`gateway` 段只覆盖
|
|
11
|
+
* port/host。单独 `gateway.host` 不启动监听,但渠道存在时仍改变绑定地址。
|
|
12
|
+
*
|
|
13
|
+
* 注意:本模块只解析对象段(channels 数组内取 type=http 一项)。
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* 解析 Gateway HTTP 监听配置
|
|
19
|
+
*
|
|
20
|
+
* @param input - 各来源配置
|
|
21
|
+
* @returns 监听配置(端口/host/是否启动)
|
|
22
|
+
*/
|
|
23
|
+
export function resolveListenConfig(input) {
|
|
24
|
+
const port = input.cliPort ?? input.gateway?.port ?? input.http?.port ?? 18180;
|
|
25
|
+
const host = input.gateway?.host ?? input.http?.host ?? input.webHost;
|
|
26
|
+
const enabled = input.cliPort != null || input.gateway?.port != null || input.http != null;
|
|
27
|
+
return { port, host, enabled };
|
|
28
|
+
}
|
package/dist/cli/webui.js
CHANGED
|
@@ -44,7 +44,11 @@ function readConfigWebSettings(configPath) {
|
|
|
44
44
|
const httpChannel = Array.isArray(raw.channels)
|
|
45
45
|
? (raw.channels.find((c) => !!c && typeof c === 'object' && c.type === 'http') ?? null)
|
|
46
46
|
: null;
|
|
47
|
-
|
|
47
|
+
// 与 daemon 监听同序:gateway.port(进程面覆盖)> channels[type=http].port(listen-config.ts)
|
|
48
|
+
const gatewayOverridePort = raw.gateway && typeof raw.gateway === 'object' && typeof raw.gateway.port === 'number'
|
|
49
|
+
? raw.gateway.port
|
|
50
|
+
: undefined;
|
|
51
|
+
const gatewayPort = gatewayOverridePort ?? (typeof httpChannel?.port === 'number' ? httpChannel.port : undefined);
|
|
48
52
|
return {
|
|
49
53
|
dir,
|
|
50
54
|
host,
|
|
@@ -153,6 +153,24 @@ export declare function detectSessionStore(raw: RawObject): MigrationFinding | n
|
|
|
153
153
|
* @returns 是否变更
|
|
154
154
|
*/
|
|
155
155
|
export declare function applySessionStore(raw: RawObject): boolean;
|
|
156
|
+
/**
|
|
157
|
+
* 检测已删除配置键(键与整段)
|
|
158
|
+
*
|
|
159
|
+
* @param raw - 配置对象
|
|
160
|
+
* @returns finding 或 null
|
|
161
|
+
*/
|
|
162
|
+
export declare function detectRemovedKeys(raw: RawObject): MigrationFinding | null;
|
|
163
|
+
/**
|
|
164
|
+
* 将 v0.98.16 删除键移入 `_legacy`(原值保留,不做语义转换)
|
|
165
|
+
*
|
|
166
|
+
* @param raw - 配置对象
|
|
167
|
+
* @returns 是否变更
|
|
168
|
+
*/
|
|
169
|
+
export declare function applyRemovedKeys(raw: RawObject): boolean;
|
|
170
|
+
/** 检测已删除的附件冗余配置。 */
|
|
171
|
+
export declare function detectRemovedAttachmentKeys(raw: RawObject): MigrationFinding | null;
|
|
172
|
+
/** 将废弃附件配置原值收进 _legacy;不改变 recallTopK 等有效配置。 */
|
|
173
|
+
export declare function applyRemovedAttachmentKeys(raw: RawObject): boolean;
|
|
156
174
|
/**
|
|
157
175
|
* 检测顶层 providers 旧数组
|
|
158
176
|
*
|
|
@@ -167,6 +185,16 @@ export declare function detectTopLevelProviders(raw: RawObject): MigrationFindin
|
|
|
167
185
|
* @returns finding 或 null
|
|
168
186
|
*/
|
|
169
187
|
export declare function detectScalarCoercion(raw: RawObject): MigrationFinding | null;
|
|
188
|
+
/**
|
|
189
|
+
* Move legacy plugins.configs to entries. Legacy entries were not wired to the
|
|
190
|
+
* default Gateway, so merely having business config must not become enablement.
|
|
191
|
+
*
|
|
192
|
+
* @param raw - Mutable raw config
|
|
193
|
+
* @returns Whether a legacy section was migrated
|
|
194
|
+
*/
|
|
195
|
+
export declare function applyLegacyPluginConfigs(raw: RawObject): boolean;
|
|
196
|
+
/** Detect legacy plugin configs and fail-loud id conflicts. */
|
|
197
|
+
export declare function detectLegacyPluginConfigs(raw: RawObject): MigrationFinding | null;
|
|
170
198
|
/** 全量迁移规则(detect + apply) */
|
|
171
199
|
export interface ConfigMigrationRule {
|
|
172
200
|
id: string;
|