octopi-agent 0.98.4 → 0.121.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 +29 -9
- package/README.zh.md +24 -8
- package/dist/agent-admin.d.ts +5 -2
- package/dist/agent-admin.js +7 -5
- package/dist/cli/args.d.ts +8 -1
- package/dist/cli/args.js +21 -1
- package/dist/cli/browser.d.ts +22 -0
- package/dist/cli/browser.js +41 -0
- package/dist/cli/commands.d.ts +1 -1
- package/dist/cli/commands.js +266 -40
- package/dist/cli/crash-forensics.d.ts +34 -0
- package/dist/cli/crash-forensics.js +90 -0
- package/dist/cli/daemon.d.ts +15 -2
- package/dist/cli/daemon.js +210 -131
- package/dist/cli/doctor/data.d.ts +23 -0
- package/dist/cli/doctor/data.js +129 -0
- package/dist/cli/doctor/index.d.ts +2 -2
- package/dist/cli/doctor/index.js +43 -7
- package/dist/cli/helpers.d.ts +45 -6
- package/dist/cli/helpers.js +66 -10
- package/dist/cli/index.js +35 -1
- package/dist/cli/listen-config.d.ts +52 -0
- package/dist/cli/listen-config.js +28 -0
- package/dist/cli/plugin-tools.d.ts +172 -0
- package/dist/cli/plugin-tools.js +682 -0
- package/dist/cli/serve-webui.js +28 -2
- package/dist/cli/webui.js +21 -1
- package/dist/cli/wizard/agent-new.d.ts +32 -0
- package/dist/cli/wizard/agent-new.js +157 -0
- package/dist/cli/wizard/onboarding.d.ts +58 -0
- package/dist/cli/wizard/onboarding.js +561 -0
- package/dist/cli/wizard/prompt.d.ts +98 -0
- package/dist/cli/wizard/prompt.js +248 -0
- package/dist/config-migrations.d.ts +28 -0
- package/dist/config-migrations.js +202 -6
- package/dist/config-schema/index.d.ts +303 -332
- package/dist/config-schema/index.js +21 -2
- package/dist/config-schema/unknown-keys.js +8 -1
- package/dist/config-schema/unwired-keys.d.ts +35 -0
- package/dist/config-schema/unwired-keys.js +107 -0
- package/dist/config-schema/webui.d.ts +1 -0
- package/dist/config-schema/webui.js +2 -0
- package/dist/config.d.ts +12 -0
- package/dist/config.js +58 -4
- package/dist/init.d.ts +17 -3
- package/dist/init.js +48 -23
- package/dist/integration/tui/app.d.ts +1 -1
- package/dist/integration/tui/app.js +13 -13
- package/dist/registry-bridge.d.ts +44 -0
- package/dist/registry-bridge.js +93 -0
- package/dist/testing/scenario-runner.js +1 -1
- package/dist/ws-identity-hooks.d.ts +37 -0
- package/dist/ws-identity-hooks.js +32 -0
- package/octopi.example.json +74 -39
- package/octopi.schema.json +397 -536
- 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.
|
|
@@ -282,16 +283,35 @@ dependencies — so the entire runtime above it is contracts you can swap:
|
|
|
282
283
|
**Prerequisites**: Node.js ≥ 24.
|
|
283
284
|
|
|
284
285
|
```bash
|
|
285
|
-
npm install octopi-agent
|
|
286
|
+
npm install -g octopi-agent
|
|
286
287
|
```
|
|
287
288
|
|
|
288
|
-
###
|
|
289
|
+
### Three minutes to your first conversation
|
|
289
290
|
|
|
290
291
|
```bash
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
292
|
+
octopi serve start
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
On a fresh machine this scaffolds `OCTOPI_HOME` and prints a personal setup
|
|
296
|
+
link in the terminal:
|
|
297
|
+
|
|
298
|
+
```text
|
|
299
|
+
🧙 First-run setup wizard (Web): http://localhost:8180/?setup=<token>
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
(Port `8180` is the default; if you set `web.port`, use that value — the terminal prints the exact link.)
|
|
303
|
+
|
|
304
|
+
Open it and walk the nine-step wizard (language → model provider → API key →
|
|
305
|
+
pick a model → …). When you finish, the config takes effect immediately —
|
|
306
|
+
open the web console at `http://localhost:8180`, open a session and just
|
|
307
|
+
start chatting.
|
|
308
|
+
|
|
309
|
+
Prefer the terminal?
|
|
310
|
+
|
|
311
|
+
```bash
|
|
312
|
+
octopi init # the same nine-step wizard, in your terminal
|
|
313
|
+
octopi chat # talk to your agent right away
|
|
314
|
+
octopi doctor # verify the environment
|
|
295
315
|
```
|
|
296
316
|
|
|
297
317
|
### Embed in code
|
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
|
|
|
@@ -181,16 +181,32 @@ Loop 层是**纯 async generator**——零状态、零外部依赖——所以
|
|
|
181
181
|
**前置**:Node.js ≥ 24。
|
|
182
182
|
|
|
183
183
|
```bash
|
|
184
|
-
npm install octopi-agent
|
|
184
|
+
npm install -g octopi-agent
|
|
185
185
|
```
|
|
186
186
|
|
|
187
|
-
###
|
|
187
|
+
### 三分钟跑通第一次对话
|
|
188
188
|
|
|
189
189
|
```bash
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
190
|
+
octopi serve start
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
全新机器上它会脚手架 `OCTOPI_HOME`,并在终端打印你的专属配置向导链接:
|
|
194
|
+
|
|
195
|
+
```text
|
|
196
|
+
🧙 首启配置向导(Web):http://localhost:8180/?setup=<token>
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
(`8180` 是默认端口;配置了 `web.port` 时以终端打印的链接为准。)
|
|
200
|
+
|
|
201
|
+
打开链接走完九步向导(语言 → 模型服务 → API Key → 选模型 → …)。完成后配置**即时生效**——
|
|
202
|
+
浏览器打开 `http://localhost:8180` 进入 Web 控制台,直接开会话开聊。
|
|
203
|
+
|
|
204
|
+
喜欢终端?
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
octopi init # 同款九步向导,在终端里走
|
|
208
|
+
octopi chat # 立刻和你的 agent 对话
|
|
209
|
+
octopi doctor # 检查环境
|
|
194
210
|
```
|
|
195
211
|
|
|
196
212
|
### 嵌入代码
|
package/dist/agent-admin.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export interface ScaffoldAgentOptions {
|
|
|
4
4
|
agentsMd?: string;
|
|
5
5
|
/** workspace 目录路径(`~` 由调用方展开为绝对路径);缺省用脚手架默认 */
|
|
6
6
|
workspace?: string;
|
|
7
|
+
/** 归属租户(脚手架布局用);缺省 DEFAULT_TENANT_ID */
|
|
8
|
+
tenantId?: string;
|
|
7
9
|
}
|
|
8
10
|
export declare class AgentFileAdmin {
|
|
9
11
|
private readonly homeDir;
|
|
@@ -12,12 +14,13 @@ export declare class AgentFileAdmin {
|
|
|
12
14
|
*/
|
|
13
15
|
constructor(homeDir?: string);
|
|
14
16
|
/**
|
|
15
|
-
* agent 文件态标准路径(与 octopi init
|
|
17
|
+
* agent 文件态标准路径(与 octopi init 布局同源;派生单一来源 = engine/paths)
|
|
16
18
|
*
|
|
17
19
|
* @param agentId - agent id
|
|
20
|
+
* @param tenantId - 归属租户;缺省 DEFAULT_TENANT_ID
|
|
18
21
|
* @returns home / workspace / skillDirectory 绝对路径
|
|
19
22
|
*/
|
|
20
|
-
pathsOf(agentId: string): {
|
|
23
|
+
pathsOf(agentId: string, tenantId?: string): {
|
|
21
24
|
home: string;
|
|
22
25
|
workspace: string;
|
|
23
26
|
skillDirectory: string;
|
package/dist/agent-admin.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
11
11
|
import { isAbsolute, join, resolve } from 'node:path';
|
|
12
|
+
import { agentHomeDir, agentWorkspaceDir } from '@octopi-agent/engine/paths.js';
|
|
12
13
|
import { ensureAgentDirs, getOctopiHome } from './init.js';
|
|
13
14
|
export class AgentFileAdmin {
|
|
14
15
|
homeDir;
|
|
@@ -19,16 +20,17 @@ export class AgentFileAdmin {
|
|
|
19
20
|
this.homeDir = homeDir;
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
22
|
-
* agent 文件态标准路径(与 octopi init
|
|
23
|
+
* agent 文件态标准路径(与 octopi init 布局同源;派生单一来源 = engine/paths)
|
|
23
24
|
*
|
|
24
25
|
* @param agentId - agent id
|
|
26
|
+
* @param tenantId - 归属租户;缺省 DEFAULT_TENANT_ID
|
|
25
27
|
* @returns home / workspace / skillDirectory 绝对路径
|
|
26
28
|
*/
|
|
27
|
-
pathsOf(agentId) {
|
|
28
|
-
const home =
|
|
29
|
+
pathsOf(agentId, tenantId) {
|
|
30
|
+
const home = agentHomeDir(this.homeDir, agentId);
|
|
29
31
|
return {
|
|
30
32
|
home,
|
|
31
|
-
workspace:
|
|
33
|
+
workspace: agentWorkspaceDir(this.homeDir, tenantId, agentId),
|
|
32
34
|
skillDirectory: join(home, 'skills'),
|
|
33
35
|
};
|
|
34
36
|
}
|
|
@@ -52,7 +54,7 @@ export class AgentFileAdmin {
|
|
|
52
54
|
if (agentId === '.' || agentId === '..' || agentId.includes('/') || agentId.includes('\\')) {
|
|
53
55
|
throw new Error(`invalid agent id: ${agentId}`);
|
|
54
56
|
}
|
|
55
|
-
await ensureAgentDirs(agentId, this.homeDir);
|
|
57
|
+
await ensureAgentDirs(agentId, this.homeDir, opts.tenantId);
|
|
56
58
|
if (opts.agentsMd !== undefined) {
|
|
57
59
|
// 仅在 AGENTS.md 缺失时写:重建同 id agent 不覆盖既有 persona(用户数据)
|
|
58
60
|
const agentsMdPath = join(this.homeOf(agentId), 'AGENTS.md');
|
package/dist/cli/args.d.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* CLI 参数解析
|
|
3
3
|
*/
|
|
4
4
|
export interface CliArgs {
|
|
5
|
-
|
|
5
|
+
/** 显式子命令;裸 octopi 时为 undefined(分派语义在 index.ts:未初始化→init、已初始化→tui chat) */
|
|
6
|
+
command?: string;
|
|
6
7
|
subcommand?: string;
|
|
7
8
|
/** 第三个位置参数(如 `octopi ops kill <agentId>` 的 agentId) */
|
|
8
9
|
target?: string;
|
|
@@ -24,6 +25,12 @@ export interface CliArgs {
|
|
|
24
25
|
agent?: string;
|
|
25
26
|
/** chat:启动即续接的会话 id(含历史加载) */
|
|
26
27
|
resume?: string;
|
|
28
|
+
/** init:向导形态(--web 请求 Web 向导 / --cli 强制命令行) */
|
|
29
|
+
web?: boolean;
|
|
30
|
+
cliMode?: boolean;
|
|
31
|
+
/** init --yes:provider / 模型预选(缺省 provider=ollama、模型=预设默认) */
|
|
32
|
+
provider?: string;
|
|
33
|
+
model?: string;
|
|
27
34
|
/** llm-diff:wire dump 根目录 */
|
|
28
35
|
dir?: string;
|
|
29
36
|
/** llm-diff:展示的调用条数(0 = 全部) */
|
package/dist/cli/args.js
CHANGED
|
@@ -36,6 +36,10 @@ export function parseArgs(argv = process.argv.slice(2)) {
|
|
|
36
36
|
let dir;
|
|
37
37
|
let limit;
|
|
38
38
|
let cacheDiscount;
|
|
39
|
+
let web = false;
|
|
40
|
+
let cliMode = false;
|
|
41
|
+
let provider;
|
|
42
|
+
let model;
|
|
39
43
|
const positional = [];
|
|
40
44
|
for (let i = 0; i < argv.length; i++) {
|
|
41
45
|
switch (argv[i]) {
|
|
@@ -121,13 +125,25 @@ export function parseArgs(argv = process.argv.slice(2)) {
|
|
|
121
125
|
cacheDiscount = parsed;
|
|
122
126
|
break;
|
|
123
127
|
}
|
|
128
|
+
case '--web':
|
|
129
|
+
web = true;
|
|
130
|
+
break;
|
|
131
|
+
case '--cli':
|
|
132
|
+
cliMode = true;
|
|
133
|
+
break;
|
|
134
|
+
case '--provider':
|
|
135
|
+
provider = requireFlagValue(argv, ++i, '--provider');
|
|
136
|
+
break;
|
|
137
|
+
case '--model':
|
|
138
|
+
model = requireFlagValue(argv, ++i, '--model');
|
|
139
|
+
break;
|
|
124
140
|
default:
|
|
125
141
|
positional.push(argv[i]);
|
|
126
142
|
break;
|
|
127
143
|
}
|
|
128
144
|
}
|
|
129
145
|
return {
|
|
130
|
-
command: positional[0]
|
|
146
|
+
command: positional[0], // 不归一成 help——裸命令的分派语义见 index.ts(m11)
|
|
131
147
|
subcommand: positional[1],
|
|
132
148
|
target: positional[2],
|
|
133
149
|
config,
|
|
@@ -147,5 +163,9 @@ export function parseArgs(argv = process.argv.slice(2)) {
|
|
|
147
163
|
dir,
|
|
148
164
|
limit,
|
|
149
165
|
cacheDiscount,
|
|
166
|
+
web,
|
|
167
|
+
cliMode,
|
|
168
|
+
provider,
|
|
169
|
+
model,
|
|
150
170
|
};
|
|
151
171
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* octopi browser — 浏览器引擎管理(arch/browser-capability.md §3.9)
|
|
3
|
+
*
|
|
4
|
+
* `octopi browser install [engine]`:显式安装浏览器二进制/提供方(二进制不随 npm
|
|
5
|
+
* 包下载)。安装逻辑单一实现在 engine 的 `integration/browser/install.ts`(与
|
|
6
|
+
* gateway / WebUI 设置页共用)——本 CLI 只做参数分派 + 终端透传。
|
|
7
|
+
*
|
|
8
|
+
* engine 与 `browser.engine` 同名:
|
|
9
|
+
* - `playwright`(缺省):管理版 Chromium
|
|
10
|
+
* - `rebrowser`:rebrowser 的 Chromium 构建
|
|
11
|
+
* - `camoufox`:隔离 provider + Camoufox 定制 Firefox(不依赖系统 Firefox)
|
|
12
|
+
* - `stealth` = rebrowser + camoufox(engine="stealth" 链所需全部)
|
|
13
|
+
*
|
|
14
|
+
* 备选零下载路径:`browser.channel: "chrome"` 用系统 Chrome,无需本命令。
|
|
15
|
+
*/
|
|
16
|
+
import type { CliArgs } from './args.js';
|
|
17
|
+
/**
|
|
18
|
+
* browser 命令入口(`octopi browser install [engine]`)。
|
|
19
|
+
*
|
|
20
|
+
* @param args - CLI 参数(`target` = 引擎名,缺省 playwright)
|
|
21
|
+
*/
|
|
22
|
+
export declare function browserCommand(args: CliArgs): Promise<void>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* octopi browser — 浏览器引擎管理(arch/browser-capability.md §3.9)
|
|
3
|
+
*
|
|
4
|
+
* `octopi browser install [engine]`:显式安装浏览器二进制/提供方(二进制不随 npm
|
|
5
|
+
* 包下载)。安装逻辑单一实现在 engine 的 `integration/browser/install.ts`(与
|
|
6
|
+
* gateway / WebUI 设置页共用)——本 CLI 只做参数分派 + 终端透传。
|
|
7
|
+
*
|
|
8
|
+
* engine 与 `browser.engine` 同名:
|
|
9
|
+
* - `playwright`(缺省):管理版 Chromium
|
|
10
|
+
* - `rebrowser`:rebrowser 的 Chromium 构建
|
|
11
|
+
* - `camoufox`:隔离 provider + Camoufox 定制 Firefox(不依赖系统 Firefox)
|
|
12
|
+
* - `stealth` = rebrowser + camoufox(engine="stealth" 链所需全部)
|
|
13
|
+
*
|
|
14
|
+
* 备选零下载路径:`browser.channel: "chrome"` 用系统 Chrome,无需本命令。
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* browser 命令入口(`octopi browser install [engine]`)。
|
|
18
|
+
*
|
|
19
|
+
* @param args - CLI 参数(`target` = 引擎名,缺省 playwright)
|
|
20
|
+
*/
|
|
21
|
+
export async function browserCommand(args) {
|
|
22
|
+
if (args.subcommand !== 'install') {
|
|
23
|
+
console.error(`Unknown browser subcommand: ${args.subcommand ?? '(none)'} — supported: install [playwright|rebrowser|camoufox|stealth]`);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
const { installEngine } = await import('@octopi-agent/engine/integration/browser/install.js');
|
|
27
|
+
const engine = args.target ?? 'playwright';
|
|
28
|
+
const result = await installEngine(engine, {
|
|
29
|
+
onProgress: (line) => console.log(line),
|
|
30
|
+
});
|
|
31
|
+
if (result.ok) {
|
|
32
|
+
console.log(`[browser] done. ${result.detail}`);
|
|
33
|
+
if (engine === 'playwright') {
|
|
34
|
+
console.log('[browser] tip: set browser.channel="chrome" in octopi.json to use system Chrome instead.');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
console.error(`[browser] ${result.detail}`);
|
|
39
|
+
}
|
|
40
|
+
process.exit(result.ok ? 0 : 1);
|
|
41
|
+
}
|
package/dist/cli/commands.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { CliArgs } from './args.js';
|
|
5
5
|
export declare function showHelp(): void;
|
|
6
|
-
export declare function initCommand(args: CliArgs): Promise<
|
|
6
|
+
export declare function initCommand(args: CliArgs): Promise<string | undefined>;
|
|
7
7
|
export declare function ensureInitialized(args: CliArgs): Promise<string | undefined>;
|
|
8
8
|
export declare function chatCommand(args: CliArgs): Promise<void>;
|
|
9
9
|
export declare function healthCommand(args: CliArgs): Promise<void>;
|