octopi-agent 0.97.15 → 0.98.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.
@@ -96,6 +96,56 @@ export declare function diagnoseStartupFailure(opts: {
96
96
  configPath?: string;
97
97
  logPath: string;
98
98
  }): string[];
99
+ /**
100
+ * 识别本次启动中 privileged 声明闸门的拒绝。
101
+ *
102
+ * gateway.log 是追加写入:只认 startMarker 之后切片里的标记,
103
+ * 否则上一次运行的同类拒绝会误触发本次启动的独立提示;
104
+ * 本次标记缺失(日志被轮转/替换)时无法界定归属,返回 null 走通用诊断。
105
+ *
106
+ * @param logPath Gateway 日志路径
107
+ * @param startMarker 本次 `serve start` 写下的 `--- octopi serve start ... ---` 行
108
+ * @returns 命中时返回 scope(elevated 启动闸门恒为 `<top>`;解析器保持 scope 无关),未命中/日志不可读返回 null
109
+ */
110
+ export declare function detectPrivilegedDeclarationFailure(logPath: string, startMarker: string): string | null;
111
+ /**
112
+ * elevated 启动声明的取值面:部署级知情声明(§8.1),只读顶层 `effectPolicy.privilegedAck`。
113
+ *
114
+ * agent 块内的 privilegedAck 是该块自己的 jail=none / escalation=full 范围级表态
115
+ * (schema refine 与 resolveEffectiveEffectPolicy 按块执法),**永不**参与 elevated
116
+ * 启动闸门——agent ack 满足不了部署声明。独立成纯函数供测试钉住这两个方向。
117
+ *
118
+ * @param config 顶层配置(只读 `effectPolicy.privilegedAck`)
119
+ * @returns 恒为 `<top>` scope 及其声明值(未声明时 `ack` 为 undefined)
120
+ */
121
+ export declare function resolveElevatedDeclarationScope(config: {
122
+ effectPolicy?: {
123
+ privilegedAck?: string;
124
+ };
125
+ }): {
126
+ name: '<top>';
127
+ ack?: string;
128
+ };
129
+ /**
130
+ * privileged 声明闸门拒绝的独立双语提示(不套「gateway 崩溃 + 日志尾巴」框架)。
131
+ *
132
+ * elevated 启动声明只认顶层(§8.1 部署级知情声明),修复指引恒指顶层 effectPolicy;
133
+ * agent 块内的 privilegedAck 只服务该块自己的 jail=none / escalation=full 范围级表态,
134
+ * 不参与 elevated 启动声明。scope 仅忠实回显断言来源供日志定位。
135
+ *
136
+ * 示例 JSON 刻意不含注释:octopi.json 是严格 JSON,用户原样粘贴必须合法。
137
+ *
138
+ * @param opts.scope 断言来源(elevated 启动闸门恒为 `<top>`)
139
+ * @param opts.configPath 实际加载的配置文件路径(指给用户修改的位置)
140
+ * @param opts.restartCommand 可复述给用户的重启动命令;缺省用中性的「重启 Octopi」
141
+ * (同一提示会被 `serve fg` 直跑路径复用,写死 `serve start` 会指错命令)
142
+ * @returns 逐行提示文本;首行含机器可读标记 `privileged_declaration_required (<scope>)`
143
+ */
144
+ export declare function renderPrivilegedDeclarationNotice(opts: {
145
+ scope: string;
146
+ configPath: string;
147
+ restartCommand?: string;
148
+ }): string[];
99
149
  /**
100
150
  * 从 `summary.tools` 配置推导 toolBindings 覆盖表(逐工具名转发,不点名硬编码)
101
151
  *
@@ -5,7 +5,7 @@ import { resolve, dirname, join } from 'node:path';
5
5
  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
- import { loadConfig, toGatewayConfig } from '../config.js';
8
+ import { loadConfig, toGatewayConfig, resolveConfigFilePath } from '../config.js';
9
9
  import { createToolSet } from '@octopi-agent/engine/harness/extension/plugin-ecosystem/tools/tool-set.js';
10
10
  import { createProviderFromConfig, createWireDumpSinkFromConfig } from '@octopi-agent/engine/config.js';
11
11
  import { startLoopWatchdog } from '@octopi-agent/engine/integration/observability/loop-watchdog.js';
@@ -17,6 +17,10 @@ export { findPidOnPort, isProcessAlive, killProcessOnPort };
17
17
  export function getPidPath() {
18
18
  return join(getOctopiHome(), 'gateway.pid');
19
19
  }
20
+ /** 缺省配置路径(模块级封装:`startGatewayBlocking` 内有同名 `await import` 遮蔽,函数内直接引用会 TDZ) */
21
+ function defaultConfigPath() {
22
+ return join(getOctopiHome(), 'octopi.json');
23
+ }
20
24
  export function readPidFile() {
21
25
  const pidPath = getPidPath();
22
26
  if (!existsSync(pidPath))
@@ -294,6 +298,102 @@ export function diagnoseStartupFailure(opts) {
294
298
  lines.push(`Foreground debug: octopi serve fg${configPath ? ` -c ${configPath}` : ''}`);
295
299
  return lines;
296
300
  }
301
+ /** privileged 声明闸门拒绝的机器可读标记(子进程写日志,serve start 父进程据此换独立提示呈现) */
302
+ const PRIVILEGED_DECLARATION_RE = /privileged_declaration_required \(([^)]+)\)/;
303
+ /**
304
+ * 识别本次启动中 privileged 声明闸门的拒绝。
305
+ *
306
+ * gateway.log 是追加写入:只认 startMarker 之后切片里的标记,
307
+ * 否则上一次运行的同类拒绝会误触发本次启动的独立提示;
308
+ * 本次标记缺失(日志被轮转/替换)时无法界定归属,返回 null 走通用诊断。
309
+ *
310
+ * @param logPath Gateway 日志路径
311
+ * @param startMarker 本次 `serve start` 写下的 `--- octopi serve start ... ---` 行
312
+ * @returns 命中时返回 scope(elevated 启动闸门恒为 `<top>`;解析器保持 scope 无关),未命中/日志不可读返回 null
313
+ */
314
+ export function detectPrivilegedDeclarationFailure(logPath, startMarker) {
315
+ try {
316
+ const text = readFileSync(logPath, 'utf-8');
317
+ const idx = text.lastIndexOf(startMarker);
318
+ if (idx < 0)
319
+ return null;
320
+ return PRIVILEGED_DECLARATION_RE.exec(text.slice(idx + startMarker.length))?.[1] ?? null;
321
+ }
322
+ catch {
323
+ // 日志缺失/不可读:无法识别,调用方走通用「崩溃 + 日志尾巴」呈现(呈现降级,不是安全绕过)
324
+ return null;
325
+ }
326
+ }
327
+ /**
328
+ * elevated 启动声明的取值面:部署级知情声明(§8.1),只读顶层 `effectPolicy.privilegedAck`。
329
+ *
330
+ * agent 块内的 privilegedAck 是该块自己的 jail=none / escalation=full 范围级表态
331
+ * (schema refine 与 resolveEffectiveEffectPolicy 按块执法),**永不**参与 elevated
332
+ * 启动闸门——agent ack 满足不了部署声明。独立成纯函数供测试钉住这两个方向。
333
+ *
334
+ * @param config 顶层配置(只读 `effectPolicy.privilegedAck`)
335
+ * @returns 恒为 `<top>` scope 及其声明值(未声明时 `ack` 为 undefined)
336
+ */
337
+ export function resolveElevatedDeclarationScope(config) {
338
+ return { name: '<top>', ack: config.effectPolicy?.privilegedAck };
339
+ }
340
+ /**
341
+ * privileged 声明闸门拒绝的独立双语提示(不套「gateway 崩溃 + 日志尾巴」框架)。
342
+ *
343
+ * elevated 启动声明只认顶层(§8.1 部署级知情声明),修复指引恒指顶层 effectPolicy;
344
+ * agent 块内的 privilegedAck 只服务该块自己的 jail=none / escalation=full 范围级表态,
345
+ * 不参与 elevated 启动声明。scope 仅忠实回显断言来源供日志定位。
346
+ *
347
+ * 示例 JSON 刻意不含注释:octopi.json 是严格 JSON,用户原样粘贴必须合法。
348
+ *
349
+ * @param opts.scope 断言来源(elevated 启动闸门恒为 `<top>`)
350
+ * @param opts.configPath 实际加载的配置文件路径(指给用户修改的位置)
351
+ * @param opts.restartCommand 可复述给用户的重启动命令;缺省用中性的「重启 Octopi」
352
+ * (同一提示会被 `serve fg` 直跑路径复用,写死 `serve start` 会指错命令)
353
+ * @returns 逐行提示文本;首行含机器可读标记 `privileged_declaration_required (<scope>)`
354
+ */
355
+ export function renderPrivilegedDeclarationNotice(opts) {
356
+ const { scope, configPath } = opts;
357
+ const zhRestart = opts.restartCommand
358
+ ? `保存后重新运行 '${opts.restartCommand}'。`
359
+ : '保存后重新启动 Octopi。';
360
+ const enRestart = opts.restartCommand
361
+ ? `Save the file, then re-run '${opts.restartCommand}'.`
362
+ : 'Save the file, then restart Octopi.';
363
+ return [
364
+ `⛔ privileged_declaration_required (${scope}) — 高权限启动已被拒绝 / elevated startup refused`,
365
+ '',
366
+ '【中文】',
367
+ '你正在以系统管理员(root/admin)权限启动 Octopi,这将使 Octopi 具备系统级权限。',
368
+ 'Octopi 拒绝在没有显式声明的情况下以高权限运行(不允许静默的特权部署)。',
369
+ '',
370
+ '如果你确定要以管理员身份启动,请在配置文件:',
371
+ ` ${configPath}`,
372
+ '在其中的顶层 effectPolicy 中加入 privilegedAck 字段(任意非空字符串,是「我明确知道这是特权部署」的申明)。',
373
+ '例如(已有的其他 effectPolicy 字段照旧保留;配置文件是严格 JSON,不要写注释):',
374
+ '',
375
+ ' "effectPolicy": {',
376
+ ' "privilegedAck": "windows-admin-by-design"',
377
+ ' }',
378
+ '',
379
+ `${zhRestart}如果不想以管理员权限运行,请改用普通用户权限的终端启动。`,
380
+ '',
381
+ '[EN]',
382
+ 'You are starting Octopi with elevated (root/admin) privileges, which grants it system-level access.',
383
+ 'Octopi refuses to run elevated without an explicit declaration — no silent privileged deployments.',
384
+ '',
385
+ 'If you intend to run as administrator, add a privilegedAck field (any non-empty string — an explicit',
386
+ 'acknowledgement that this is a privileged deployment) to your config file:',
387
+ ` ${configPath}`,
388
+ 'Apply it at the top-level effectPolicy. Example (keep your other effectPolicy fields; the config file is strict JSON — no comments):',
389
+ '',
390
+ ' "effectPolicy": {',
391
+ ' "privilegedAck": "windows-admin-by-design"',
392
+ ' }',
393
+ '',
394
+ `${enRestart} To run unprivileged, use a normal (non-admin) terminal.`,
395
+ ];
396
+ }
297
397
  /**
298
398
  * 按 `observability.llmRequestDump` 构造 wire dump sink(未启用时 undefined)
299
399
  *
@@ -438,6 +538,31 @@ export async function serveStartCommand(args) {
438
538
  exited.then(() => ({ kind: 'exited', pid: null })),
439
539
  ]);
440
540
  if (outcome.kind !== 'ready' || !outcome.pid) {
541
+ // privileged 声明闸门拒绝 = 独立安全提示;不套「gateway 崩溃 + 日志尾巴」框架
542
+ const privilegedScope = outcome.kind === 'exited' && !spawnError
543
+ ? detectPrivilegedDeclarationFailure(logPath, startMarker)
544
+ : null;
545
+ if (privilegedScope) {
546
+ let noticeConfigPath = configPath ?? defaultConfigPath();
547
+ try {
548
+ noticeConfigPath = resolveConfigFilePath(configPath);
549
+ }
550
+ catch {
551
+ // 极窄窗口内配置文件被移走/不可读:提示本体照常呈现,回退展示缺省路径;
552
+ // 真实的「配置找不到」错误在子进程 loadConfig 已上浮进日志,不会被这里吞掉
553
+ }
554
+ for (const line of renderPrivilegedDeclarationNotice({
555
+ scope: privilegedScope,
556
+ configPath: noticeConfigPath,
557
+ restartCommand: 'octopi serve start',
558
+ })) {
559
+ console.error(line);
560
+ }
561
+ console.error('');
562
+ console.error(`Full log: ${logPath}`);
563
+ console.error(`Foreground debug: octopi serve fg${configPath ? ` -c ${configPath}` : ''}`);
564
+ process.exit(1);
565
+ }
441
566
  if (outcome.kind === 'exited') {
442
567
  if (spawnError) {
443
568
  console.error(`❌ Failed to launch Gateway child process: ${spawnError}`);
@@ -672,42 +797,55 @@ async function startGatewayBlocking(configPath, args) {
672
797
  }
673
798
  // ops P4 §5 P4:root/elevated 部署语义——daemon 以高权限跑时没有 sudo,危险轴是
674
799
  // 「笼不笼 × uid=0」,必须显式 privileged 声明(同 privilegedAck),拒绝静默特权态。
675
- // 口径与 config-bridge 相同:agent.effectPolicy 整体覆盖顶层,无则回落顶层。
800
+ // ack 是部署级知情声明(进程 elevated 事实,§8.1 二级确认):只看顶层声明。
801
+ // agent 块内的 privilegedAck 服务于该块自己的 jail=none / escalation=full 范围级表态
802
+ // (schema refine 与 resolveEffectiveEffectPolicy 按块执法),与 elevated 启动声明无关。
676
803
  const { isProcessElevated, assertPrivilegedDeclaration } = await import('@octopi-agent/engine/harness/extension/execution-environment/privileged-exec.js');
677
804
  const elevated = await isProcessElevated();
678
805
  if (elevated) {
679
- const declared = [
680
- { name: '<top>', ack: config.effectPolicy?.privilegedAck },
681
- ...(config.agents ?? []).map((agent) => ({
682
- name: agent.id ?? '<agent>',
683
- ack: (agent.effectPolicy ?? config.effectPolicy)?.privilegedAck,
684
- })),
685
- ];
686
- for (const scope of declared) {
806
+ const declaration = resolveElevatedDeclarationScope(config);
807
+ try {
808
+ assertPrivilegedDeclaration({
809
+ elevated,
810
+ privilegedAck: declaration.ack,
811
+ scope: declaration.name,
812
+ });
813
+ }
814
+ catch (err) {
815
+ // 仅闸门断言渲染独立提示(首行含机器可读标记,serve start 父进程据此换呈现);
816
+ // 其他异常原样上浮,不伪装成 privilegedAck 缺失
817
+ if (!(err instanceof Error) || !err.message.startsWith('privileged_declaration_required')) {
818
+ throw err;
819
+ }
820
+ let noticeConfigPath = configPath ?? defaultConfigPath();
687
821
  try {
688
- assertPrivilegedDeclaration({ elevated, privilegedAck: scope.ack, scope: scope.name });
822
+ noticeConfigPath = resolveConfigFilePath(configPath);
823
+ }
824
+ catch {
825
+ // 极窄窗口内配置文件被移走/不可读:回退展示缺省路径;加载失败的真实错误已在 loadConfig 上浮
689
826
  }
690
- catch (err) {
691
- console.error(`✗ ${err instanceof Error ? err.message : String(err)}`);
692
- process.exit(1);
827
+ for (const line of renderPrivilegedDeclarationNotice({
828
+ scope: '<top>',
829
+ configPath: noticeConfigPath,
830
+ // 守护模式由 serve start 拉起,可复述该命令;直跑 fg 时用中性措辞避免指错命令
831
+ restartCommand: process.env.OCTOPI_DAEMON === '1' ? 'octopi serve start' : undefined,
832
+ })) {
833
+ console.error(line);
693
834
  }
835
+ process.exit(1);
694
836
  }
695
837
  console.log('⚠ PRIVILEGED: process is elevated (root/admin) — persistent PRIVILEGED marker is now in effect.');
696
838
  }
697
839
  }
698
840
  const gatewayConfig = toGatewayConfig(config);
699
841
  // ops P2 §4.3/§8.4:daemon 持安全字段启动锚,run 起点复核,漂移拒新 run
700
- // (取 raw 文件切面与复核同口径;agent 改写自身配置 = 自提权面)
842
+ // (取 raw 文件切面与复核同口径;agent 改写自身配置 = 自提权面)。
843
+ // console 受控写(config-apply)经 guard.reattest 署名重锚定,见「WebUI 署名通道」。
701
844
  {
702
- const { computeSecurityConfigFingerprint, extractSecurityConfigSlice, createFileSecurityIntegrity, } = await import('@octopi-agent/engine/harness/agent/config-integrity.js');
703
- const { readFileSync } = await import('node:fs');
845
+ const { createSecurityIntegrityGuard } = await import('@octopi-agent/engine/harness/agent/config-integrity.js');
704
846
  const { resolveConfigFilePath } = await import('../config.js');
705
847
  const filePath = resolveConfigFilePath(configPath);
706
- const anchor = computeSecurityConfigFingerprint(extractSecurityConfigSlice(readFileSync(filePath, 'utf8')));
707
- gatewayConfig.securityIntegrity = {
708
- fingerprint: anchor.fingerprint,
709
- recheck: createFileSecurityIntegrity({ configPath: filePath, anchor }),
710
- };
848
+ gatewayConfig.securityIntegrity = createSecurityIntegrityGuard({ configPath: filePath });
711
849
  }
712
850
  // AgentRuntime 构造参数在 toGatewayConfig 已带上;此处仅防御显式覆盖
713
851
  if (config.agentRuntime) {
@@ -45,6 +45,27 @@ export declare function findPidOnVitePorts(expectedPort?: number): {
45
45
  pid: number;
46
46
  port: number;
47
47
  } | null;
48
+ /**
49
+ * HTTP 指纹探针:判定端口上的监听者是否 WebUI 实例。
50
+ *
51
+ * 命中:GET /octopi-config.js 返回 2xx 且内容含 {@link WEBUI_IDENTITY_MARKER}。
52
+ * 连接失败 / 非 2xx / 无指纹 → false——**不认领**(端口上的陌生进程不是 WebUI)。
53
+ *
54
+ * @param port - 待探测端口
55
+ * @returns true = WebUI 实例
56
+ */
57
+ export declare function probeWebUiIdentity(port: number): Promise<boolean>;
58
+ /**
59
+ * 发现未被 webui.pid 跟踪的端口占用者,并用 HTTP 指纹判定其身份。
60
+ *
61
+ * @param expectedPort - 期望端口(配置/默认),缺省 8180
62
+ * @returns kind='webui' 可认领的 WebUI 实例;kind='foreign' 占用端口的陌生进程;null 无占用
63
+ */
64
+ export declare function findUntrackedWebUiInstance(expectedPort?: number): Promise<{
65
+ kind: 'webui' | 'foreign';
66
+ pid: number;
67
+ port: number;
68
+ } | null>;
48
69
  export declare function webuiStartCommand(configPath?: string, options?: WebUiStartOptions): Promise<void>;
49
70
  export declare function webuiStopCommand(configPath?: string): Promise<void>;
50
71
  export declare function webuiRestartCommand(configPath?: string, options?: WebUiStartOptions): Promise<void>;
package/dist/cli/webui.js CHANGED
@@ -134,6 +134,46 @@ export function findPidOnVitePorts(expectedPort) {
134
134
  }
135
135
  return null;
136
136
  }
137
+ /**
138
+ * WebUI 身份指纹:`/octopi-config.js`(public/ 提供,vite dev 与 dist 静态同款)
139
+ * 内容必含 `__OCTOPI_GATEWAY__`(静态回退置 null,serve-webui 动态下发改写为端口)。
140
+ */
141
+ const WEBUI_IDENTITY_MARKER = '__OCTOPI_GATEWAY__';
142
+ /**
143
+ * HTTP 指纹探针:判定端口上的监听者是否 WebUI 实例。
144
+ *
145
+ * 命中:GET /octopi-config.js 返回 2xx 且内容含 {@link WEBUI_IDENTITY_MARKER}。
146
+ * 连接失败 / 非 2xx / 无指纹 → false——**不认领**(端口上的陌生进程不是 WebUI)。
147
+ *
148
+ * @param port - 待探测端口
149
+ * @returns true = WebUI 实例
150
+ */
151
+ export async function probeWebUiIdentity(port) {
152
+ try {
153
+ const res = await fetch(`http://127.0.0.1:${port}/octopi-config.js`, {
154
+ signal: AbortSignal.timeout(1500),
155
+ });
156
+ if (!res.ok)
157
+ return false;
158
+ return (await res.text()).includes(WEBUI_IDENTITY_MARKER);
159
+ }
160
+ catch {
161
+ // 连接拒绝/超时/非 HTTP 服务:无法证明是 WebUI,一律不认领
162
+ return false;
163
+ }
164
+ }
165
+ /**
166
+ * 发现未被 webui.pid 跟踪的端口占用者,并用 HTTP 指纹判定其身份。
167
+ *
168
+ * @param expectedPort - 期望端口(配置/默认),缺省 8180
169
+ * @returns kind='webui' 可认领的 WebUI 实例;kind='foreign' 占用端口的陌生进程;null 无占用
170
+ */
171
+ export async function findUntrackedWebUiInstance(expectedPort) {
172
+ const hit = findPidOnVitePorts(expectedPort);
173
+ if (!hit)
174
+ return null;
175
+ return { ...(await probeWebUiIdentity(hit.port) ? { kind: 'webui' } : { kind: 'foreign' }), ...hit };
176
+ }
137
177
  export async function webuiStartCommand(configPath, options) {
138
178
  const soft = options?.soft === true;
139
179
  const existing = readWebUiPidRecord();
@@ -144,11 +184,18 @@ export async function webuiStartCommand(configPath, options) {
144
184
  console.log(`\nUse 'octopi webui restart' to restart.`);
145
185
  return;
146
186
  }
147
- // pid 文件缺失/失效,但端口上已有实例:提示而非叠跑第二个 vite
187
+ // pid 文件缺失/失效,但端口上已有监听:先验身份再定性(不把陌生进程误认成 WebUI)
148
188
  const port = resolveWebUiPort(configPath, options?.port);
149
- const portHit = findPidOnVitePorts(port);
150
- if (portHit) {
151
- console.log(`⚠️ Web UI appears already running on port ${portHit.port} (PID: ${portHit.pid})`);
189
+ const untracked = await findUntrackedWebUiInstance(port);
190
+ if (untracked?.kind === 'foreign') {
191
+ console.error(`❌ Port ${untracked.port} is occupied by PID ${untracked.pid} (not the Web UI) — cannot start Web UI.`);
192
+ console.error(' Free the port (stop that process) or set a different "web.port".');
193
+ if (soft)
194
+ return;
195
+ process.exit(1);
196
+ }
197
+ if (untracked) {
198
+ console.log(`⚠️ Web UI appears already running on port ${untracked.port} (PID: ${untracked.pid})`);
152
199
  console.log(' Not tracked in ~/.octopi/webui.pid (started outside CLI?)');
153
200
  if (soft)
154
201
  return;
@@ -225,11 +272,17 @@ export async function webuiStopCommand(configPath) {
225
272
  removeWebUiPidFile();
226
273
  pid = undefined;
227
274
  }
228
- const portHit = findPidOnVitePorts(resolveWebUiPort(configPath));
229
- if (portHit) {
230
- pid = portHit.pid;
275
+ const untracked = await findUntrackedWebUiInstance(resolveWebUiPort(configPath));
276
+ if (untracked?.kind === 'foreign') {
277
+ // 端口上的陌生进程不是 WebUI:拒绝误杀,fail loud
278
+ console.error(`❌ Port ${untracked.port} is held by PID ${untracked.pid} (not the Web UI) — refusing to kill it.`);
279
+ console.error(' Free the port yourself, or stop that process in its own terminal.');
280
+ process.exit(1);
281
+ }
282
+ if (untracked) {
283
+ pid = untracked.pid;
231
284
  source = 'port';
232
- console.log(`ℹ️ Adopting untracked Web UI on port ${portHit.port} (PID: ${portHit.pid})`);
285
+ console.log(`ℹ️ Adopting untracked Web UI on port ${untracked.port} (PID: ${untracked.pid})`);
233
286
  }
234
287
  }
235
288
  if (!pid) {
@@ -260,11 +313,13 @@ export async function webuiRestartCommand(configPath, options) {
260
313
  export async function webuiStatusCommand(configPath) {
261
314
  const record = readWebUiPidRecord();
262
315
  const pid = record?.pid;
263
- const portHit = findPidOnVitePorts(resolveWebUiPort(configPath));
316
+ const untracked = await findUntrackedWebUiInstance(resolveWebUiPort(configPath));
317
+ const portHit = untracked ? { pid: untracked.pid, port: untracked.port } : null;
318
+ const foreignLabel = untracked?.kind === 'foreign' ? ' (not the Web UI)' : '';
264
319
  if (!pid) {
265
320
  console.log('ℹ️ No Web UI instance found in ~/.octopi/webui.pid.');
266
- if (portHit && isProcessAlive(portHit.pid)) {
267
- console.log(` But port ${portHit.port} is LISTENING (PID: ${portHit.pid}) — started outside CLI?`);
321
+ if (untracked && isProcessAlive(untracked.pid)) {
322
+ console.log(` But port ${untracked.port} is LISTENING (PID: ${untracked.pid})${foreignLabel} — started outside CLI?`);
268
323
  }
269
324
  const configWebDir = readConfigWebDir(configPath);
270
325
  const webDist = findWebDist(configPath, configWebDir);
@@ -285,12 +340,12 @@ export async function webuiStatusCommand(configPath) {
285
340
  if (record.startedAt)
286
341
  console.log(` Started: ${record.startedAt}`);
287
342
  if (portHit)
288
- console.log(` Port: ${portHit.port} (PID ${portHit.pid})`);
343
+ console.log(` Port: ${portHit.port} (PID ${portHit.pid})${foreignLabel}`);
289
344
  console.log();
290
345
  if (!alive) {
291
346
  console.log(' ⚠️ Process is not running. PID file is stale.');
292
347
  if (portHit && portHit.pid !== pid && isProcessAlive(portHit.pid)) {
293
- console.log(` Another process holds port ${portHit.port} (PID ${portHit.pid}).`);
348
+ console.log(` Another process holds port ${portHit.port} (PID ${portHit.pid})${foreignLabel}.`);
294
349
  }
295
350
  console.log(` Run 'octopi webui start' to start a new instance.\n`);
296
351
  }
@@ -54,6 +54,8 @@ export declare const OctopiConfigSchema: z.ZodObject<{
54
54
  strict: "strict";
55
55
  soft: "soft";
56
56
  }>>;
57
+ refuseFinalSymlink: z.ZodOptional<z.ZodBoolean>;
58
+ pathDenylist: z.ZodOptional<z.ZodArray<z.ZodString>>;
57
59
  shellEscape: z.ZodOptional<z.ZodEnum<{
58
60
  deny: "deny";
59
61
  confirm: "confirm";
@@ -890,6 +892,8 @@ export declare const OctopiConfigSchema: z.ZodObject<{
890
892
  strict: "strict";
891
893
  soft: "soft";
892
894
  }>>;
895
+ refuseFinalSymlink: z.ZodOptional<z.ZodBoolean>;
896
+ pathDenylist: z.ZodOptional<z.ZodArray<z.ZodString>>;
893
897
  shellEscape: z.ZodOptional<z.ZodEnum<{
894
898
  deny: "deny";
895
899
  confirm: "confirm";
@@ -1190,6 +1194,8 @@ export declare const HarnessConfigSchema: z.ZodObject<{
1190
1194
  strict: "strict";
1191
1195
  soft: "soft";
1192
1196
  }>>;
1197
+ refuseFinalSymlink: z.ZodOptional<z.ZodBoolean>;
1198
+ pathDenylist: z.ZodOptional<z.ZodArray<z.ZodString>>;
1193
1199
  shellEscape: z.ZodOptional<z.ZodEnum<{
1194
1200
  deny: "deny";
1195
1201
  confirm: "confirm";
@@ -2026,6 +2032,8 @@ export declare const HarnessConfigSchema: z.ZodObject<{
2026
2032
  strict: "strict";
2027
2033
  soft: "soft";
2028
2034
  }>>;
2035
+ refuseFinalSymlink: z.ZodOptional<z.ZodBoolean>;
2036
+ pathDenylist: z.ZodOptional<z.ZodArray<z.ZodString>>;
2029
2037
  shellEscape: z.ZodOptional<z.ZodEnum<{
2030
2038
  deny: "deny";
2031
2039
  confirm: "confirm";
package/dist/config.js CHANGED
@@ -110,18 +110,15 @@ function finalizeNormalizedConfig(validated) {
110
110
  */
111
111
  export async function buildFromConfigFile(configPath) {
112
112
  const { buildFromConfig } = await import('@octopi-agent/engine/harness/agent/config-bridge.js');
113
- const { computeSecurityConfigFingerprint, extractSecurityConfigSlice, createFileSecurityIntegrity, } = await import('@octopi-agent/engine/harness/agent/config-integrity.js');
113
+ const { createSecurityIntegrityGuard } = await import('@octopi-agent/engine/harness/agent/config-integrity.js');
114
114
  const filePath = resolveConfigFilePath(configPath);
115
115
  const config = loadConfig(filePath);
116
116
  // ops P2 §4.3/§8.4:启动期锚定安全字段指纹(取 raw 文件切面,与复核同口径——
117
- // 展开 ${VAR} 后的值与文件字面不同,混用会永久误报漂移)。run 起点复核,漂移拒新 run。
118
- const anchor = computeSecurityConfigFingerprint(extractSecurityConfigSlice(readFileSync(filePath, 'utf8')));
117
+ // 展开 ${VAR} 后的值与文件字面不同,混用会永久误报漂移)。run 起点复核,漂移拒新 run;
118
+ // 受控写通道(console 管理面)经 guard.reattest 署名重锚定。
119
119
  return buildFromConfig(config, {
120
120
  runnerConfig: {
121
- securityIntegrity: {
122
- fingerprint: anchor.fingerprint,
123
- recheck: createFileSecurityIntegrity({ configPath: filePath, anchor }),
124
- },
121
+ securityIntegrity: createSecurityIntegrityGuard({ configPath: filePath }),
125
122
  },
126
123
  });
127
124
  }
package/dist/init.js CHANGED
@@ -158,8 +158,6 @@ function generateDefaultConfig(homeDir, agentId = 'default') {
158
158
  },
159
159
  },
160
160
  level: {
161
- // summary:summary 能力与内置子系统(wisdom.steward.formation think.model)共用
162
- summary: { primary: 'openai/gpt-5-mini' },
163
161
  mini: { primary: 'openai/gpt-5-mini' },
164
162
  standard: { primary: 'openai/gpt-5.5' },
165
163
  pro: { primary: 'openai/gpt-5.5' },
@@ -4,7 +4,6 @@
4
4
  "models": {
5
5
  "mode": "merge",
6
6
  "level": {
7
- "summary": { "primary": "openai/gpt-5-mini" },
8
7
  "mini": { "primary": "openai/gpt-5-mini" },
9
8
  "standard": { "primary": "openai/gpt-5.5" },
10
9
  "pro": { "primary": "openai/gpt-5.5" }
@@ -82,7 +81,7 @@
82
81
  },
83
82
 
84
83
  "summary": {
85
- "modelLevel": "summary",
84
+ "modelLevel": "mini",
86
85
  "defaultInputBudgetTokens": 24000,
87
86
  "safetyMarginTokens": 2000,
88
87
  "oversizedStrategy": "map_reduce",
@@ -88,6 +88,15 @@
88
88
  "none"
89
89
  ]
90
90
  },
91
+ "refuseFinalSymlink": {
92
+ "type": "boolean"
93
+ },
94
+ "pathDenylist": {
95
+ "type": "array",
96
+ "items": {
97
+ "type": "string"
98
+ }
99
+ },
91
100
  "shellEscape": {
92
101
  "type": "string",
93
102
  "enum": [
@@ -2855,6 +2864,15 @@
2855
2864
  "none"
2856
2865
  ]
2857
2866
  },
2867
+ "refuseFinalSymlink": {
2868
+ "type": "boolean"
2869
+ },
2870
+ "pathDenylist": {
2871
+ "type": "array",
2872
+ "items": {
2873
+ "type": "string"
2874
+ }
2875
+ },
2858
2876
  "shellEscape": {
2859
2877
  "type": "string",
2860
2878
  "enum": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "octopi-agent",
3
- "version": "0.97.15",
3
+ "version": "0.98.4",
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",
@@ -66,10 +66,10 @@
66
66
  "dependencies": {
67
67
  "@earendil-works/pi-tui": "^0.78.0",
68
68
  "@modelcontextprotocol/sdk": "^1.29.0",
69
- "@octopi-agent/core": "0.97.15",
70
- "@octopi-agent/engine": "0.97.15",
71
- "@octopi-agent/gateway": "0.97.15",
72
- "@octopi-agent/webui": "0.97.15",
69
+ "@octopi-agent/core": "0.98.4",
70
+ "@octopi-agent/engine": "0.98.4",
71
+ "@octopi-agent/gateway": "0.98.4",
72
+ "@octopi-agent/webui": "0.98.4",
73
73
  "@types/ws": "^8.18.1",
74
74
  "chalk": "^5.6.2",
75
75
  "js-yaml": "^4.3.2",