octopi-agent 0.55.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/LICENSE +201 -0
- package/NOTICE +7 -0
- package/README.md +244 -0
- package/README_CN.md +241 -0
- package/dist/cli/args.d.ts +20 -0
- package/dist/cli/args.js +90 -0
- package/dist/cli/commands.d.ts +10 -0
- package/dist/cli/commands.js +253 -0
- package/dist/cli/daemon.d.ts +40 -0
- package/dist/cli/daemon.js +549 -0
- package/dist/cli/doctor/data.d.ts +64 -0
- package/dist/cli/doctor/data.js +209 -0
- package/dist/cli/doctor/index.d.ts +131 -0
- package/dist/cli/doctor/index.js +711 -0
- package/dist/cli/doctor/redact.d.ts +21 -0
- package/dist/cli/doctor/redact.js +48 -0
- package/dist/cli/doctor/restore.d.ts +36 -0
- package/dist/cli/doctor/restore.js +93 -0
- package/dist/cli/helpers.d.ts +38 -0
- package/dist/cli/helpers.js +158 -0
- package/dist/cli/index.d.ts +5 -0
- package/dist/cli/index.js +62 -0
- package/dist/cli/process-utils.d.ts +55 -0
- package/dist/cli/process-utils.js +306 -0
- package/dist/cli/serve-webui.d.ts +1 -0
- package/dist/cli/serve-webui.js +82 -0
- package/dist/cli/webui.d.ts +13 -0
- package/dist/cli/webui.js +249 -0
- package/dist/config-migrations.d.ts +198 -0
- package/dist/config-migrations.js +692 -0
- package/dist/config-schema/index.d.ts +1400 -0
- package/dist/config-schema/index.js +100 -0
- package/dist/config-schema/webui.d.ts +15 -0
- package/dist/config-schema/webui.js +15 -0
- package/dist/config-schema.d.ts +9 -0
- package/dist/config-schema.js +9 -0
- package/dist/config.d.ts +18 -0
- package/dist/config.js +136 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +35 -0
- package/dist/init.d.ts +86 -0
- package/dist/init.js +386 -0
- package/dist/integration/index.d.ts +8 -0
- package/dist/integration/index.js +8 -0
- package/dist/integration/tui/app.d.ts +50 -0
- package/dist/integration/tui/app.js +584 -0
- package/dist/integration/tui/components.d.ts +82 -0
- package/dist/integration/tui/components.js +291 -0
- package/dist/integration/tui/index.d.ts +8 -0
- package/dist/integration/tui/index.js +8 -0
- package/dist/integration/tui/theme.d.ts +77 -0
- package/dist/integration/tui/theme.js +90 -0
- package/dist/testing/chaos-provider.d.ts +109 -0
- package/dist/testing/chaos-provider.js +211 -0
- package/dist/testing/index.d.ts +15 -0
- package/dist/testing/index.js +10 -0
- package/dist/testing/recording-provider.d.ts +75 -0
- package/dist/testing/recording-provider.js +172 -0
- package/dist/testing/replay-provider.d.ts +52 -0
- package/dist/testing/replay-provider.js +138 -0
- package/dist/testing/scenario-composer.d.ts +86 -0
- package/dist/testing/scenario-composer.js +200 -0
- package/dist/testing/scenario-runner.d.ts +134 -0
- package/dist/testing/scenario-runner.js +240 -0
- package/octopi.example.json +220 -0
- package/octopi.schema.json +2206 -0
- package/package.json +97 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 配置旧字段 / 手改损坏形态的检测与迁移
|
|
3
|
+
*
|
|
4
|
+
* 单一真相:loadConfig 告警 + doctor --fix 写回共用本模块。
|
|
5
|
+
* 变换基于「未展开 env」的磁盘原义,禁止把 ${VAR} 写成明文。
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
export type MigrationSeverity = 'error' | 'warn' | 'info';
|
|
10
|
+
export interface MigrationFinding {
|
|
11
|
+
id: string;
|
|
12
|
+
severity: MigrationSeverity;
|
|
13
|
+
message: string;
|
|
14
|
+
hint?: string;
|
|
15
|
+
autoFixable: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface MigrationApplyResult {
|
|
18
|
+
/** 是否改动了对象 */
|
|
19
|
+
changed: boolean;
|
|
20
|
+
notes: string[];
|
|
21
|
+
findings: MigrationFinding[];
|
|
22
|
+
}
|
|
23
|
+
type RawObject = Record<string, unknown>;
|
|
24
|
+
/**
|
|
25
|
+
* 去掉 JSON 字符串外的 // 与 /* *\/ 注释
|
|
26
|
+
*
|
|
27
|
+
* @param text - 原始配置文本
|
|
28
|
+
* @returns 去掉注释后的文本
|
|
29
|
+
*/
|
|
30
|
+
export declare function stripJsonComments(text: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* 去掉对象/数组字面量前的尾逗号(字符串感知,避免改到值里的 `,}` / `,]`)
|
|
33
|
+
*
|
|
34
|
+
* @param text - JSON 文本
|
|
35
|
+
* @returns 规范化后的文本
|
|
36
|
+
*/
|
|
37
|
+
export declare function stripTrailingCommas(text: string): string;
|
|
38
|
+
export interface JsonParseAttempt {
|
|
39
|
+
ok: boolean;
|
|
40
|
+
raw?: unknown;
|
|
41
|
+
recovered: boolean;
|
|
42
|
+
error?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 解析配置 JSON;标准 parse 失败时尝试去注释与尾逗号
|
|
46
|
+
*
|
|
47
|
+
* @param text - 磁盘原文
|
|
48
|
+
* @returns 解析结果
|
|
49
|
+
*/
|
|
50
|
+
export declare function parseConfigJson(text: string): JsonParseAttempt;
|
|
51
|
+
/**
|
|
52
|
+
* 将手改配置里可唯一确定的标量类型纠正为 schema 期望类型
|
|
53
|
+
*
|
|
54
|
+
* @param raw - 未展开的配置对象(就地修改)
|
|
55
|
+
* @returns 是否发生变更
|
|
56
|
+
*/
|
|
57
|
+
export declare function coerceKnownScalarTypes(raw: RawObject): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* 将旧顶层 providers[] 归一到 models.providers(值随节点搬迁,含 apiKey 原样)
|
|
60
|
+
*
|
|
61
|
+
* @param raw - 未展开配置
|
|
62
|
+
* @returns notes 与是否变更
|
|
63
|
+
*/
|
|
64
|
+
export declare function migrateTopLevelProviders(raw: RawObject): {
|
|
65
|
+
changed: boolean;
|
|
66
|
+
notes: string[];
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* 检测 supervisor / runGuard 冲突与旧字段
|
|
70
|
+
*
|
|
71
|
+
* @param raw - 配置对象
|
|
72
|
+
* @returns finding 或 null
|
|
73
|
+
*/
|
|
74
|
+
export declare function detectSupervisor(raw: RawObject): MigrationFinding | null;
|
|
75
|
+
/**
|
|
76
|
+
* 就地迁移 supervisor → runGuard(新字段已存在时保留新字段)
|
|
77
|
+
*
|
|
78
|
+
* @param raw - 配置对象
|
|
79
|
+
* @returns 是否变更
|
|
80
|
+
*/
|
|
81
|
+
export declare function applySupervisor(raw: RawObject): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* 检测 distributedIntelligence 旧顶层节点
|
|
84
|
+
*
|
|
85
|
+
* @param raw - 配置对象
|
|
86
|
+
* @returns finding 或 null
|
|
87
|
+
*/
|
|
88
|
+
export declare function detectDistributedIntelligence(raw: RawObject): MigrationFinding | null;
|
|
89
|
+
/**
|
|
90
|
+
* 移除 distributedIntelligence(值无新落点可机械回填,迁入 _legacy 备份键)
|
|
91
|
+
*
|
|
92
|
+
* @param raw - 配置对象
|
|
93
|
+
* @returns 是否变更
|
|
94
|
+
*/
|
|
95
|
+
export declare function applyDistributedIntelligence(raw: RawObject): boolean;
|
|
96
|
+
/**
|
|
97
|
+
* 检测旧顶层 budget / spend hard 字段(arch/budget-redesign.md P0)
|
|
98
|
+
*
|
|
99
|
+
* @param raw - 配置对象
|
|
100
|
+
* @returns finding 或 null
|
|
101
|
+
*/
|
|
102
|
+
export declare function detectLegacyBudget(raw: RawObject): MigrationFinding | null;
|
|
103
|
+
/**
|
|
104
|
+
* 迁移旧 budget → budgetPolicy(丢弃 nominal token hard 与 soft 字段)
|
|
105
|
+
*
|
|
106
|
+
* @param raw - 配置对象
|
|
107
|
+
* @returns 是否变更
|
|
108
|
+
*/
|
|
109
|
+
export declare function applyLegacyBudget(raw: RawObject): boolean;
|
|
110
|
+
/** @deprecated use detectLegacyBudget */
|
|
111
|
+
export declare const detectBudgetMaxTimeMs: typeof detectLegacyBudget;
|
|
112
|
+
/** @deprecated use applyLegacyBudget */
|
|
113
|
+
export declare const applyBudgetMaxTimeMs: typeof applyLegacyBudget;
|
|
114
|
+
/**
|
|
115
|
+
* 检测 agents[].persona 字符串(旧 home)
|
|
116
|
+
*
|
|
117
|
+
* @param raw - 配置对象
|
|
118
|
+
* @returns findings
|
|
119
|
+
*/
|
|
120
|
+
export declare function detectPersonaAsHome(raw: RawObject): MigrationFinding[];
|
|
121
|
+
/**
|
|
122
|
+
* persona 字符串 → home(仅当 home 缺省或相同)
|
|
123
|
+
*
|
|
124
|
+
* @param raw - 配置对象
|
|
125
|
+
* @returns 是否变更
|
|
126
|
+
*/
|
|
127
|
+
export declare function applyPersonaAsHome(raw: RawObject): boolean;
|
|
128
|
+
/**
|
|
129
|
+
* 检测 $schema 是否指向明显无效位置
|
|
130
|
+
*
|
|
131
|
+
* @param raw - 配置对象
|
|
132
|
+
* @returns finding 或 null
|
|
133
|
+
*/
|
|
134
|
+
export declare function detectSchemaRef(raw: RawObject): MigrationFinding | null;
|
|
135
|
+
/**
|
|
136
|
+
* 将 $schema 规范到包内 schema 相对提示路径
|
|
137
|
+
*
|
|
138
|
+
* @param raw - 配置对象
|
|
139
|
+
* @returns 是否变更
|
|
140
|
+
*/
|
|
141
|
+
export declare function applySchemaRef(raw: RawObject): boolean;
|
|
142
|
+
/**
|
|
143
|
+
* 检测废弃的 session.store(Gateway 忽略 store/dataDir,会话落在 agent.home/sessions)
|
|
144
|
+
*
|
|
145
|
+
* @param raw - 配置对象
|
|
146
|
+
* @returns finding 或 null
|
|
147
|
+
*/
|
|
148
|
+
export declare function detectSessionStore(raw: RawObject): MigrationFinding | null;
|
|
149
|
+
/**
|
|
150
|
+
* 将 session.store 移入 _legacy.session.store(保留 dmScope;不搬数据)
|
|
151
|
+
*
|
|
152
|
+
* @param raw - 配置对象
|
|
153
|
+
* @returns 是否变更
|
|
154
|
+
*/
|
|
155
|
+
export declare function applySessionStore(raw: RawObject): boolean;
|
|
156
|
+
/**
|
|
157
|
+
* 检测顶层 providers 旧数组
|
|
158
|
+
*
|
|
159
|
+
* @param raw - 配置对象
|
|
160
|
+
* @returns finding 或 null
|
|
161
|
+
*/
|
|
162
|
+
export declare function detectTopLevelProviders(raw: RawObject): MigrationFinding | null;
|
|
163
|
+
/**
|
|
164
|
+
* 检测手改后可安全纠正的标量类型
|
|
165
|
+
*
|
|
166
|
+
* @param raw - 配置对象
|
|
167
|
+
* @returns finding 或 null
|
|
168
|
+
*/
|
|
169
|
+
export declare function detectScalarCoercion(raw: RawObject): MigrationFinding | null;
|
|
170
|
+
/** 全量迁移规则(detect + apply) */
|
|
171
|
+
export interface ConfigMigrationRule {
|
|
172
|
+
id: string;
|
|
173
|
+
detect(raw: RawObject): MigrationFinding | null | MigrationFinding[];
|
|
174
|
+
apply(raw: RawObject): boolean;
|
|
175
|
+
}
|
|
176
|
+
export declare const CONFIG_MIGRATION_RULES: ConfigMigrationRule[];
|
|
177
|
+
/**
|
|
178
|
+
* 检测配置中的旧字段与手改问题(不修改输入)
|
|
179
|
+
*
|
|
180
|
+
* @param raw - 未展开或已展开的配置对象
|
|
181
|
+
* @returns findings 列表
|
|
182
|
+
*/
|
|
183
|
+
export declare function detectConfigMigrations(raw: unknown): MigrationFinding[];
|
|
184
|
+
/**
|
|
185
|
+
* 应用全部可自动迁移规则(就地修改 raw)
|
|
186
|
+
*
|
|
187
|
+
* @param raw - 配置对象
|
|
188
|
+
* @returns 应用结果
|
|
189
|
+
*/
|
|
190
|
+
export declare function applyConfigMigrations(raw: unknown): MigrationApplyResult;
|
|
191
|
+
/**
|
|
192
|
+
* 与 loadConfig 相同的 ${ENV} / ${ENV:-default} 展开(仅用于复检,不写回磁盘)
|
|
193
|
+
*
|
|
194
|
+
* @param text - 配置原文
|
|
195
|
+
* @returns 展开后的文本
|
|
196
|
+
*/
|
|
197
|
+
export declare function expandEnvPlaceholders(text: string): string;
|
|
198
|
+
export {};
|