oh-my-opencode-cohub 1.18.1 → 1.18.3
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/index.js +1 -1
- package/dist/config/loader.test.d.ts +2 -0
- package/dist/config/loader.test.d.ts.map +1 -0
- package/dist/context/diag-log.d.ts +50 -0
- package/dist/context/diag-log.d.ts.map +1 -1
- package/dist/context/diag-log.test.d.ts +2 -0
- package/dist/context/diag-log.test.d.ts.map +1 -0
- package/dist/context/engine.d.ts +18 -0
- package/dist/context/engine.d.ts.map +1 -1
- package/dist/context/prompt-budget.d.ts +45 -0
- package/dist/context/prompt-budget.d.ts.map +1 -0
- package/dist/context/prompt-budget.test.d.ts +2 -0
- package/dist/context/prompt-budget.test.d.ts.map +1 -0
- package/dist/context/types.d.ts +6 -0
- package/dist/context/types.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +942 -197
- package/dist/orchestration/engine.d.ts +19 -2
- package/dist/orchestration/engine.d.ts.map +1 -1
- package/dist/orchestration/rate-limit.d.ts +19 -0
- package/dist/orchestration/rate-limit.d.ts.map +1 -0
- package/dist/orchestration/rate-limit.test.d.ts +21 -0
- package/dist/orchestration/rate-limit.test.d.ts.map +1 -0
- package/dist/orchestration/types.d.ts +12 -0
- package/dist/orchestration/types.d.ts.map +1 -1
- package/dist/prompts/oracle.d.ts +1 -1
- package/dist/prompts/oracle.d.ts.map +1 -1
- package/dist/prompts/orchestrator.d.ts +1 -1
- package/dist/prompts/orchestrator.d.ts.map +1 -1
- package/dist/prompts/planner.d.ts +1 -1
- package/dist/prompts/planner.d.ts.map +1 -1
- package/dist/task-manager/tracker.d.ts +149 -13
- package/dist/task-manager/tracker.d.ts.map +1 -1
- package/dist/task-manager/types.d.ts +15 -0
- package/dist/task-manager/types.d.ts.map +1 -1
- package/dist/tools/job-control.d.ts +11 -4
- package/dist/tools/job-control.d.ts.map +1 -1
- package/dist/tools/job-control.test.d.ts +2 -0
- package/dist/tools/job-control.test.d.ts.map +1 -0
- package/dist/tui.js +121 -0
- package/dist/utils/log.d.ts +12 -0
- package/dist/utils/log.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/task-manager/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,WAAW,CAAC;AAE3E,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,UAAU,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB;IACjB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,kBAAkB;IAClB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,8CAA8C;IAC9C,OAAO,CAAC,EAAE;QACR,oEAAoE;QACpE,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,eAAe,CAAC,EAAE,eAAe,CAAC;QAClC,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC;KAC5C,CAAC;CACH;AAED,MAAM,WAAW,QAAQ;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,U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AM,MAAM,YAAY,GAAG,IAAI,GAAG,UAAU,GAAG,WAAW,GAAG,YAAY,GAAG,UAAU,CAAC;AAEvF,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,YAAY,CAAC;IACrB,qCAAqC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -6,9 +6,16 @@ import type { TaskTracker } from '../task-manager/tracker.js';
|
|
|
6
6
|
*
|
|
7
7
|
* 仅 co-orchestrator(主代理)允许调用(纵深防御,与权限配置层配合)。
|
|
8
8
|
*
|
|
9
|
-
* @param ctx
|
|
10
|
-
* @param tracker
|
|
11
|
-
* @param onClosed
|
|
9
|
+
* @param ctx 插件 input(提供 client 以调用 session.abort)
|
|
10
|
+
* @param tracker TaskTracker 实例(resolveCancelTarget / markCancelledByAlias)
|
|
11
|
+
* @param onClosed 可选回调:工具执行完成后刷新状态(如 syncTrackerState;兼容旧语义,
|
|
12
|
+
* 每次执行返回前调用,与取消成败无关——保持既有行为)
|
|
13
|
+
* @param onCancelled 可选回调:**仅当本次确实完成 running → cancelled**(markCancelledByAlias
|
|
14
|
+
* reason==='ok')时以捕获的 alias 回调一次;入口用于同步 engine.cancelled
|
|
15
|
+
* 与该 parent board。
|
|
16
|
+
* 重复取消(幂等)——含 await SDK abort 期间任务被其他路径终结/取消
|
|
17
|
+
* (idle 完成、失败、另一 close)——不触发;未知/失败不触发;
|
|
18
|
+
* 回调抛错不影响返回(try/catch 保护)。
|
|
12
19
|
*/
|
|
13
|
-
export declare function createCloseJobTool(ctx: PluginInput, tracker: TaskTracker, onClosed?: () => void): Record<string, ReturnType<typeof tool>>;
|
|
20
|
+
export declare function createCloseJobTool(ctx: PluginInput, tracker: TaskTracker, onClosed?: () => void, onCancelled?: (alias: string) => void): Record<string, ReturnType<typeof tool>>;
|
|
14
21
|
//# sourceMappingURL=job-control.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"job-control.d.ts","sourceRoot":"","sources":["../../src/tools/job-control.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"job-control.d.ts","sourceRoot":"","sources":["../../src/tools/job-control.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAM9D;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,WAAW,EACpB,QAAQ,CAAC,EAAE,MAAM,IAAI,EACrB,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GACpC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC,CA6IzC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"job-control.test.d.ts","sourceRoot":"","sources":["../../src/tools/job-control.test.ts"],"names":[],"mappings":""}
|
package/dist/tui.js
CHANGED
|
@@ -100,6 +100,119 @@ function createLogger(cfg) {
|
|
|
100
100
|
return appendLogSync;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
// src/orchestration/rate-limit.ts
|
|
104
|
+
var RATE_LIMIT_TEXT = ["tokens per minute", "rate limit", "quota"];
|
|
105
|
+
var NETWORK_TEXT = ["econnreset", "socket hang up", "timeout", "etimedout"];
|
|
106
|
+
function isPlainObject(v) {
|
|
107
|
+
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
108
|
+
}
|
|
109
|
+
function normalizeError(error) {
|
|
110
|
+
if (!isPlainObject(error))
|
|
111
|
+
return null;
|
|
112
|
+
const obj = error;
|
|
113
|
+
const data = isPlainObject(obj["data"]) ? obj["data"] : undefined;
|
|
114
|
+
const pick = (key) => {
|
|
115
|
+
if (obj[key] !== undefined)
|
|
116
|
+
return obj[key];
|
|
117
|
+
if (data && data[key] !== undefined)
|
|
118
|
+
return data[key];
|
|
119
|
+
return;
|
|
120
|
+
};
|
|
121
|
+
const statusCode = pick("statusCode");
|
|
122
|
+
const isRetryable = pick("isRetryable");
|
|
123
|
+
const headers = pick("responseHeaders");
|
|
124
|
+
const body = pick("responseBody");
|
|
125
|
+
const message = pick("message");
|
|
126
|
+
const cause = pick("cause");
|
|
127
|
+
const headersOut = {};
|
|
128
|
+
if (isPlainObject(headers)) {
|
|
129
|
+
for (const [k, v] of Object.entries(headers)) {
|
|
130
|
+
if (typeof v === "string")
|
|
131
|
+
headersOut[k] = v;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const causeCode = isPlainObject(cause) && typeof cause["code"] === "string" ? cause["code"] : undefined;
|
|
135
|
+
return {
|
|
136
|
+
statusCode: typeof statusCode === "number" && Number.isFinite(statusCode) ? statusCode : undefined,
|
|
137
|
+
isRetryable: typeof isRetryable === "boolean" ? isRetryable : false,
|
|
138
|
+
responseHeaders: headersOut,
|
|
139
|
+
responseBody: typeof body === "string" ? body : undefined,
|
|
140
|
+
message: typeof message === "string" ? message : undefined,
|
|
141
|
+
causeCode
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function findRetryAfter(headers) {
|
|
145
|
+
for (const [k, v] of Object.entries(headers)) {
|
|
146
|
+
if (k.toLowerCase() === "retry-after" && v.trim() !== "")
|
|
147
|
+
return v.trim();
|
|
148
|
+
}
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
function parseRetryAfter(headers, nowMs) {
|
|
152
|
+
const raw = findRetryAfter(headers);
|
|
153
|
+
if (raw === undefined)
|
|
154
|
+
return { retryAfterSource: "none" };
|
|
155
|
+
if (/^\d+$/.test(raw)) {
|
|
156
|
+
const secs = Number(raw);
|
|
157
|
+
if (secs > 0)
|
|
158
|
+
return { retryAfterMs: secs * 1000, retryAfterSource: "header-seconds" };
|
|
159
|
+
return { retryAfterSource: "none" };
|
|
160
|
+
}
|
|
161
|
+
const dateMs = Date.parse(raw);
|
|
162
|
+
if (Number.isNaN(dateMs))
|
|
163
|
+
return { retryAfterSource: "none" };
|
|
164
|
+
const waitMs = dateMs - nowMs;
|
|
165
|
+
if (waitMs > 0)
|
|
166
|
+
return { retryAfterMs: waitMs, retryAfterSource: "header-date" };
|
|
167
|
+
return { retryAfterSource: "none" };
|
|
168
|
+
}
|
|
169
|
+
function classifyRateLimit(error, now) {
|
|
170
|
+
const norm = normalizeError(error);
|
|
171
|
+
if (!norm) {
|
|
172
|
+
return {
|
|
173
|
+
kind: "other",
|
|
174
|
+
retryAfterSource: "none",
|
|
175
|
+
isRetryable: false,
|
|
176
|
+
maskedMessage: "non-object-input"
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
const nowMs = typeof now === "number" && Number.isFinite(now) ? now : Date.now();
|
|
180
|
+
if (norm.statusCode === 429) {
|
|
181
|
+
const ra = parseRetryAfter(norm.responseHeaders, nowMs);
|
|
182
|
+
return {
|
|
183
|
+
kind: "rate_limit",
|
|
184
|
+
...ra,
|
|
185
|
+
isRetryable: norm.isRetryable,
|
|
186
|
+
maskedMessage: "rate-limit-classified (http-429)"
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
const text = [norm.message, norm.responseBody].filter((s) => typeof s === "string" && s !== "").join(`
|
|
190
|
+
`).toLowerCase();
|
|
191
|
+
if (RATE_LIMIT_TEXT.some((t) => text.includes(t))) {
|
|
192
|
+
return {
|
|
193
|
+
kind: "rate_limit",
|
|
194
|
+
retryAfterSource: "none",
|
|
195
|
+
isRetryable: norm.isRetryable,
|
|
196
|
+
maskedMessage: "rate-limit-classified (text-signal)"
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
const causeText = norm.causeCode?.toLowerCase() ?? "";
|
|
200
|
+
if (NETWORK_TEXT.some((t) => text.includes(t)) || NETWORK_TEXT.some((t) => causeText.includes(t))) {
|
|
201
|
+
return {
|
|
202
|
+
kind: "retryable_network",
|
|
203
|
+
retryAfterSource: "none",
|
|
204
|
+
isRetryable: norm.isRetryable,
|
|
205
|
+
maskedMessage: "retryable-network-error (socket/timeout)"
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
return {
|
|
209
|
+
kind: "other",
|
|
210
|
+
retryAfterSource: "none",
|
|
211
|
+
isRetryable: norm.isRetryable,
|
|
212
|
+
maskedMessage: "unclassified-error"
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
103
216
|
// src/utils/log.ts
|
|
104
217
|
var LOG_DIR = path2.join(os.homedir(), ".local", "share", "opencode", "log");
|
|
105
218
|
var appendLog = createLogger({
|
|
@@ -110,6 +223,14 @@ var appendLog = createLogger({
|
|
|
110
223
|
keepDays: 7,
|
|
111
224
|
async: true
|
|
112
225
|
});
|
|
226
|
+
function appendSafeLog(tag, message, err) {
|
|
227
|
+
if (err === undefined) {
|
|
228
|
+
appendLog(tag, message);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
const { maskedMessage } = classifyRateLimit(err);
|
|
232
|
+
appendLog(tag, `${message} — ${maskedMessage}`);
|
|
233
|
+
}
|
|
113
234
|
|
|
114
235
|
// src/tui.ts
|
|
115
236
|
var AGENT_CONFIG_FILE = path3.join(os2.homedir(), ".config", "opencode", "oh-my-opencode-cohub.json");
|
package/dist/utils/log.d.ts
CHANGED
|
@@ -11,4 +11,16 @@
|
|
|
11
11
|
import { type LogFn } from '../shared/log';
|
|
12
12
|
/** 追加一条诊断日志(异步,失败静默)。 */
|
|
13
13
|
export declare const appendLog: LogFn;
|
|
14
|
+
/**
|
|
15
|
+
* 安全观测辅助:记录错误摘要而非原始错误对象。
|
|
16
|
+
*
|
|
17
|
+
* 原始 err 可能携带 SDK ApiError 的 responseBody / responseHeaders(含密钥),
|
|
18
|
+
* 若直接 `appendLog(tag, msg, err)` 会把敏感内容写入 ~/.local 日志。
|
|
19
|
+
* 本函数先用 classifyRateLimit 生成脱敏固定摘要(maskedMessage),
|
|
20
|
+
* 仅记录摘要文本,不把原始 err 传给底层 logger(避免 String(err)/err.stack 泄漏)。
|
|
21
|
+
*
|
|
22
|
+
* 用法(Wave4 接线):
|
|
23
|
+
* try { ... } catch (e) { appendSafeLog('orchestration', 'session.idle 处理失败', e); }
|
|
24
|
+
*/
|
|
25
|
+
export declare function appendSafeLog(tag: string, message: string, err?: unknown): void;
|
|
14
26
|
//# sourceMappingURL=log.d.ts.map
|
package/dist/utils/log.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/utils/log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAgB,KAAK,KAAK,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/utils/log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH,OAAO,EAAgB,KAAK,KAAK,EAAE,MAAM,eAAe,CAAC;AAKzD,yBAAyB;AACzB,eAAO,MAAM,SAAS,EAAE,KAOtB,CAAC;AAEH;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,IAAI,CAO/E"}
|