@octopi-agent/engine 0.58.0 → 0.65.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/dist/config-schema/context.d.ts +1 -1
- package/dist/config-schema/context.js +1 -1
- package/dist/config-schema/engine.d.ts +38 -1
- package/dist/config-schema/substrate.d.ts +37 -0
- package/dist/config-schema/substrate.js +47 -0
- package/dist/config.d.ts +30 -1
- package/dist/harness/agent/builder.d.ts +14 -0
- package/dist/harness/agent/builder.js +14 -2
- package/dist/harness/{context/capabilities → capabilities}/document/backends/docx.d.ts +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/backends/docx.js +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/backends/office-parser.d.ts +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/backends/office-parser.js +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/backends/pdf.d.ts +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/backends/pdf.js +13 -3
- package/dist/harness/{context/capabilities → capabilities}/document/backends/plain.d.ts +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/backends/plain.js +13 -4
- package/dist/harness/{context/capabilities → capabilities}/document/backends/sheet.d.ts +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/backends/sheet.js +25 -5
- package/dist/harness/{context/capabilities → capabilities}/document/backends/xmind.d.ts +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/backends/xmind.js +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/errors.d.ts +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/errors.js +1 -1
- package/dist/harness/capabilities/document/factory.d.ts +33 -0
- package/dist/harness/capabilities/document/factory.js +37 -0
- package/dist/harness/{context/capabilities → capabilities}/document/format.d.ts +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/format.js +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/html-to-md.d.ts +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/html-to-md.js +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/index.d.ts +3 -1
- package/dist/harness/{context/capabilities → capabilities}/document/index.js +2 -1
- package/dist/harness/{context/capabilities → capabilities}/document/legacy/factory.d.ts +3 -1
- package/dist/harness/{context/capabilities → capabilities}/document/legacy/factory.js +3 -1
- package/dist/harness/{context/capabilities → capabilities}/document/legacy/soffice.d.ts +3 -1
- package/dist/harness/{context/capabilities → capabilities}/document/legacy/soffice.js +44 -1
- package/dist/harness/{context/capabilities → capabilities}/document/port.d.ts +1 -1
- package/dist/harness/{context/capabilities → capabilities}/document/port.js +4 -4
- package/dist/harness/{context/capabilities → capabilities}/document/types.d.ts +11 -1
- package/dist/harness/{context/capabilities → capabilities}/document/types.js +1 -1
- package/dist/harness/capabilities/document/worker-port.d.ts +13 -0
- package/dist/harness/capabilities/document/worker-port.js +78 -0
- package/dist/harness/context/capabilities/index.d.ts +2 -2
- package/dist/harness/context/capabilities/index.js +2 -2
- package/dist/harness/extension/plugin-ecosystem/tools/knowledge.d.ts +10 -0
- package/dist/harness/extension/plugin-ecosystem/tools/knowledge.js +102 -5
- package/dist/harness/index.d.ts +4 -2
- package/dist/harness/index.js +2 -1
- package/dist/harness/knowledge/adapters.d.ts +8 -5
- package/dist/harness/knowledge/adapters.js +53 -13
- package/dist/harness/knowledge/client.d.ts +197 -0
- package/dist/harness/knowledge/client.js +237 -0
- package/dist/harness/knowledge/connector-fetcher.d.ts +2 -2
- package/dist/harness/knowledge/connectors.d.ts +3 -3
- package/dist/harness/knowledge/connectors.js +14 -8
- package/dist/harness/knowledge/db.d.ts +40 -5
- package/dist/harness/knowledge/db.js +441 -113
- package/dist/harness/knowledge/document-extract-worker.js +55 -12
- package/dist/harness/knowledge/embed-runner.d.ts +53 -0
- package/dist/harness/knowledge/embed-runner.js +171 -0
- package/dist/harness/knowledge/engine-thread.d.ts +1 -0
- package/dist/harness/knowledge/engine-thread.js +302 -0
- package/dist/harness/knowledge/extract-document.d.ts +21 -5
- package/dist/harness/knowledge/extract-document.js +32 -8
- package/dist/harness/knowledge/fetchers.d.ts +14 -3
- package/dist/harness/knowledge/fetchers.js +52 -16
- package/dist/harness/knowledge/file-identity.d.ts +53 -0
- package/dist/harness/knowledge/file-identity.js +172 -0
- package/dist/harness/knowledge/file-index-store.d.ts +50 -0
- package/dist/harness/knowledge/file-index-store.js +132 -0
- package/dist/harness/knowledge/file-limits.d.ts +86 -0
- package/dist/harness/knowledge/file-limits.js +175 -0
- package/dist/harness/knowledge/fts.d.ts +60 -0
- package/dist/harness/knowledge/fts.js +218 -0
- package/dist/harness/knowledge/grounding.d.ts +3 -2
- package/dist/harness/knowledge/http-app.d.ts +50 -0
- package/dist/harness/knowledge/http-app.js +652 -0
- package/dist/harness/knowledge/http-bridge.d.ts +49 -0
- package/dist/harness/knowledge/http-bridge.js +17 -0
- package/dist/harness/knowledge/index-store.d.ts +158 -93
- package/dist/harness/knowledge/index-store.js +982 -441
- package/dist/harness/knowledge/index.d.ts +45 -5
- package/dist/harness/knowledge/index.js +23 -2
- package/dist/harness/knowledge/ingest.d.ts +262 -87
- package/dist/harness/knowledge/ingest.js +1072 -480
- package/dist/harness/knowledge/job-control-state.d.ts +29 -0
- package/dist/harness/knowledge/job-control-state.js +44 -0
- package/dist/harness/knowledge/job-control.d.ts +35 -0
- package/dist/harness/knowledge/job-control.js +86 -0
- package/dist/harness/knowledge/job-queue.d.ts +62 -0
- package/dist/harness/knowledge/job-queue.js +173 -0
- package/dist/harness/knowledge/knowledge-serve-child.d.ts +1 -0
- package/dist/harness/knowledge/knowledge-serve-child.js +100 -0
- package/dist/harness/knowledge/local-stack.d.ts +27 -0
- package/dist/harness/knowledge/local-stack.js +63 -0
- package/dist/harness/knowledge/membership-store.d.ts +65 -0
- package/dist/harness/knowledge/membership-store.js +198 -0
- package/dist/harness/knowledge/network-guard.d.ts +11 -2
- package/dist/harness/knowledge/network-guard.js +130 -85
- package/dist/harness/knowledge/parse-text-in-worker.d.ts +32 -0
- package/dist/harness/knowledge/parse-text-in-worker.js +158 -0
- package/dist/harness/knowledge/query-service.d.ts +272 -0
- package/dist/harness/knowledge/query-service.js +326 -0
- package/dist/harness/knowledge/query-worker-client.d.ts +96 -0
- package/dist/harness/knowledge/query-worker-client.js +207 -0
- package/dist/harness/knowledge/query-worker.d.ts +1 -0
- package/dist/harness/knowledge/query-worker.js +186 -0
- package/dist/harness/knowledge/read-http.d.ts +35 -0
- package/dist/harness/knowledge/read-http.js +373 -0
- package/dist/harness/knowledge/retriever.d.ts +22 -5
- package/dist/harness/knowledge/retriever.js +66 -35
- package/dist/harness/knowledge/secret-scan.d.ts +13 -2
- package/dist/harness/knowledge/secret-scan.js +25 -2
- package/dist/harness/knowledge/serve.d.ts +48 -0
- package/dist/harness/knowledge/serve.js +336 -0
- package/dist/harness/knowledge/source-store.d.ts +80 -17
- package/dist/harness/knowledge/source-store.js +160 -89
- package/dist/harness/knowledge/start-service-process.d.ts +49 -0
- package/dist/harness/knowledge/start-service-process.js +158 -0
- package/dist/harness/knowledge/text-parse-worker.d.ts +1 -0
- package/dist/harness/knowledge/text-parse-worker.js +54 -0
- package/dist/harness/knowledge/types.d.ts +1 -1
- package/dist/harness/knowledge/types.js +1 -1
- package/dist/harness/knowledge/vector-ann.d.ts +42 -0
- package/dist/harness/knowledge/vector-ann.js +68 -0
- package/dist/harness/knowledge/writer-lock.d.ts +13 -0
- package/dist/harness/knowledge/writer-lock.js +71 -0
- package/dist/harness/knowledge/writer-service.d.ts +194 -0
- package/dist/harness/knowledge/writer-service.js +355 -0
- package/dist/harness/knowledge/writer-worker-client.d.ts +102 -0
- package/dist/harness/knowledge/writer-worker-client.js +381 -0
- package/dist/harness/knowledge/writer-worker.d.ts +1 -0
- package/dist/harness/knowledge/writer-worker.js +189 -0
- package/dist/harness/memory/sqlite/embedding.d.ts +5 -2
- package/dist/harness/memory/sqlite/embedding.js +109 -16
- package/dist/harness/memory/sqlite/keyword-search.d.ts +21 -0
- package/dist/harness/memory/sqlite/keyword-search.js +64 -0
- package/dist/harness/session/attachments/service.d.ts +1 -1
- package/dist/harness/session/attachments/service.js +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +2 -1
- package/dist/worker-path.d.ts +8 -0
- package/dist/worker-path.js +15 -0
- package/package.json +2 -2
|
@@ -37,6 +37,25 @@ function asEmbedding(value) {
|
|
|
37
37
|
// float32 buffer 等情况暂不支持
|
|
38
38
|
return null;
|
|
39
39
|
}
|
|
40
|
+
/** 服务端提示输入超过模型上下文(Ollama/TEI/OpenAI 措辞不一) */
|
|
41
|
+
function isContextLengthError(err) {
|
|
42
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
43
|
+
return /context length|input length|prompt is too long|maximum context|too many tokens|exceeds the (max|context)|max_?tokens|token limit/i.test(msg);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 为 embedding 缩短输入:保头 72% + 尾 28%(表头/结论都在),中间用省略号衔接。
|
|
47
|
+
* 全文仍留在检索侧;这里只影响向量语义覆盖面。
|
|
48
|
+
*/
|
|
49
|
+
function shrinkEmbedText(text, maxChars) {
|
|
50
|
+
const t = text.trim();
|
|
51
|
+
if (t.length <= maxChars)
|
|
52
|
+
return t;
|
|
53
|
+
const marker = '\n…\n';
|
|
54
|
+
const budget = Math.max(48, maxChars - marker.length);
|
|
55
|
+
const head = Math.ceil(budget * 0.72);
|
|
56
|
+
const tail = Math.floor(budget * 0.28);
|
|
57
|
+
return `${t.slice(0, head)}${marker}${t.slice(t.length - tail)}`;
|
|
58
|
+
}
|
|
40
59
|
function defaultPath(type, custom) {
|
|
41
60
|
if (custom)
|
|
42
61
|
return custom;
|
|
@@ -181,8 +200,8 @@ class HttpEmbeddingProvider {
|
|
|
181
200
|
continue;
|
|
182
201
|
}
|
|
183
202
|
const vec = asEmbedding(getByPath(item, mapping.itemEmbeddingPath));
|
|
184
|
-
|
|
185
|
-
|
|
203
|
+
// 保留空槽对齐下标;调用方按条重试,禁止静默丢条
|
|
204
|
+
out.push(vec ?? []);
|
|
186
205
|
}
|
|
187
206
|
}
|
|
188
207
|
if (out.length === 0) {
|
|
@@ -193,33 +212,87 @@ class HttpEmbeddingProvider {
|
|
|
193
212
|
// 协议异常时以实际返回条数为准,由调用方决定是否串行重试
|
|
194
213
|
return out;
|
|
195
214
|
}
|
|
196
|
-
|
|
215
|
+
/** 单次请求;不做截断回退 */
|
|
216
|
+
async embedRaw(text) {
|
|
197
217
|
const res = await fetch(this.opts.url, {
|
|
198
218
|
method: 'POST',
|
|
199
219
|
headers: this.buildHeaders(),
|
|
200
220
|
body: JSON.stringify(this.buildBody(text)),
|
|
201
221
|
signal: AbortSignal.timeout(this.opts.timeoutMs),
|
|
202
222
|
});
|
|
223
|
+
const rawText = await res.text().catch(() => '');
|
|
224
|
+
let data = {};
|
|
225
|
+
if (rawText) {
|
|
226
|
+
try {
|
|
227
|
+
data = JSON.parse(rawText);
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
data = {};
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
else if (typeof res.json === 'function') {
|
|
234
|
+
// 测试桩可能只实现 json();真响应 body 空则维持 {}
|
|
235
|
+
data = await res.json().catch(() => ({}));
|
|
236
|
+
}
|
|
203
237
|
if (!res.ok) {
|
|
204
|
-
const
|
|
205
|
-
|
|
238
|
+
const errText = typeof data?.error === 'string'
|
|
239
|
+
? data.error
|
|
240
|
+
: rawText.slice(0, 200);
|
|
241
|
+
throw new Error(`Embedding request failed: ${res.status} ${res.statusText} ${errText}`.slice(0, 400));
|
|
242
|
+
}
|
|
243
|
+
const apiErr = data?.error;
|
|
244
|
+
if (typeof apiErr === 'string' && apiErr) {
|
|
245
|
+
throw new Error(`Embedding request failed: ${apiErr}`);
|
|
206
246
|
}
|
|
207
|
-
const data = (await res.json());
|
|
208
247
|
const vec = this.extractOne(data);
|
|
209
248
|
if (!vec || vec.length === 0) {
|
|
210
249
|
throw new Error(`Embedding response missing vector at path "${this.opts.mapping.embeddingsPath}"`);
|
|
211
250
|
}
|
|
212
251
|
return vec;
|
|
213
252
|
}
|
|
253
|
+
async embed(text) {
|
|
254
|
+
try {
|
|
255
|
+
return await this.embedRaw(text);
|
|
256
|
+
}
|
|
257
|
+
catch (err) {
|
|
258
|
+
// 模型上下文按 token 计:同字数中文密度不同,有的 2400 字能进有的不能
|
|
259
|
+
if (!isContextLengthError(err))
|
|
260
|
+
throw err;
|
|
261
|
+
let size = Math.min(text.trim().length, 1600);
|
|
262
|
+
while (size >= 200) {
|
|
263
|
+
try {
|
|
264
|
+
return await this.embedRaw(shrinkEmbedText(text, size));
|
|
265
|
+
}
|
|
266
|
+
catch (e2) {
|
|
267
|
+
if (!isContextLengthError(e2))
|
|
268
|
+
throw e2;
|
|
269
|
+
size = Math.floor(size * 0.7);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
throw err;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
214
275
|
async embedBatch(texts) {
|
|
215
276
|
if (texts.length === 0)
|
|
216
277
|
return [];
|
|
217
278
|
if (!this.opts.supportsBatch) {
|
|
218
|
-
// 串行调用 embed
|
|
279
|
+
// 串行调用 embed(含截断回退);单条失败不拖垮同批其它条
|
|
219
280
|
const out = [];
|
|
281
|
+
let lastErr;
|
|
282
|
+
let ok = 0;
|
|
220
283
|
for (const t of texts) {
|
|
221
|
-
|
|
284
|
+
try {
|
|
285
|
+
const vec = await this.embed(t);
|
|
286
|
+
out.push(vec);
|
|
287
|
+
ok += 1;
|
|
288
|
+
}
|
|
289
|
+
catch (e) {
|
|
290
|
+
lastErr = e;
|
|
291
|
+
out.push([]);
|
|
292
|
+
}
|
|
222
293
|
}
|
|
294
|
+
if (ok === 0 && lastErr)
|
|
295
|
+
throw lastErr;
|
|
223
296
|
return out;
|
|
224
297
|
}
|
|
225
298
|
// 服务端批次上限(如百炼 qwen3.7-text-embedding = 20);超出切片
|
|
@@ -248,21 +321,41 @@ class HttpEmbeddingProvider {
|
|
|
248
321
|
}
|
|
249
322
|
const data = (await res.json());
|
|
250
323
|
const many = this.extractMany(data);
|
|
251
|
-
if (many.length
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
324
|
+
if (many.length === texts.length) {
|
|
325
|
+
// 对齐后仍有空槽:按条补齐(embed 内含上下文截断回退);单条失败留空槽给上层续试
|
|
326
|
+
for (let i = 0; i < many.length; i++) {
|
|
327
|
+
if (many[i]?.length)
|
|
328
|
+
continue;
|
|
329
|
+
try {
|
|
330
|
+
many[i] = await this.embed(texts[i]);
|
|
331
|
+
}
|
|
332
|
+
catch {
|
|
333
|
+
many[i] = [];
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return many;
|
|
257
337
|
}
|
|
258
|
-
|
|
338
|
+
if (texts.length > 1)
|
|
339
|
+
return this.embedSerial(texts);
|
|
340
|
+
return many.slice(0, 1);
|
|
259
341
|
}
|
|
260
342
|
/** 串行单条(批量失败回退;避免并发风暴触发限流) */
|
|
261
343
|
async embedSerial(texts) {
|
|
262
344
|
const out = [];
|
|
345
|
+
let lastErr;
|
|
346
|
+
let ok = 0;
|
|
263
347
|
for (const t of texts) {
|
|
264
|
-
|
|
348
|
+
try {
|
|
349
|
+
out.push(await this.embed(t));
|
|
350
|
+
ok += 1;
|
|
351
|
+
}
|
|
352
|
+
catch (e) {
|
|
353
|
+
lastErr = e;
|
|
354
|
+
out.push([]);
|
|
355
|
+
}
|
|
265
356
|
}
|
|
357
|
+
if (ok === 0 && lastErr)
|
|
358
|
+
throw lastErr;
|
|
266
359
|
return out;
|
|
267
360
|
}
|
|
268
361
|
}
|
|
@@ -34,6 +34,27 @@ export interface KeywordTokens {
|
|
|
34
34
|
* @param text - 原始查询
|
|
35
35
|
*/
|
|
36
36
|
export declare function tokenizeKeywordDetail(text: string): KeywordTokens;
|
|
37
|
+
/**
|
|
38
|
+
* 查询是否有足够语义信号做自动召回(grounding)。
|
|
39
|
+
*
|
|
40
|
+
* - ≥2 个 strong 词 → 有
|
|
41
|
+
* - 单个 CJK 整段长度 ≥3(如「技术栈选择」)→ 视为多概念
|
|
42
|
+
* - 否则(「继续」「好的」「ok」)→ 无
|
|
43
|
+
*
|
|
44
|
+
* @param tokens - {@link tokenizeKeywordDetail} 结果
|
|
45
|
+
*/
|
|
46
|
+
export declare function hasEnoughQuerySignal(tokens: KeywordTokens | string[]): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* 绝对关键词相关度(0–1):查询 token 被正文/路径覆盖的加权比例。
|
|
49
|
+
*
|
|
50
|
+
* 与结果集无关,供 inject/hint 地板使用;**不要**再做组内 min-max。
|
|
51
|
+
* strong 权重 1,weak(CJK 滑窗二元组)0.5;命中字段:content 1.0 / tags 0.6 / 其它 0.3。
|
|
52
|
+
*
|
|
53
|
+
* @param fields - 可检索字段
|
|
54
|
+
* @param tokens - 查询分词
|
|
55
|
+
* @returns 0–1;无 token 时 0
|
|
56
|
+
*/
|
|
57
|
+
export declare function scoreKeywordCoverage(fields: KeywordFields, tokens: string[] | KeywordTokens): number;
|
|
37
58
|
/**
|
|
38
59
|
* 单条记忆的关键词命中得分。
|
|
39
60
|
*
|
|
@@ -64,6 +64,70 @@ export function tokenizeKeywordDetail(text) {
|
|
|
64
64
|
const all = [...new Set([...strong, ...weak])].filter((t) => t.length >= 2);
|
|
65
65
|
return { all, strong: [...strong].filter((t) => t.length >= 2), weak: [...weak] };
|
|
66
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* 查询是否有足够语义信号做自动召回(grounding)。
|
|
69
|
+
*
|
|
70
|
+
* - ≥2 个 strong 词 → 有
|
|
71
|
+
* - 单个 CJK 整段长度 ≥3(如「技术栈选择」)→ 视为多概念
|
|
72
|
+
* - 否则(「继续」「好的」「ok」)→ 无
|
|
73
|
+
*
|
|
74
|
+
* @param tokens - {@link tokenizeKeywordDetail} 结果
|
|
75
|
+
*/
|
|
76
|
+
export function hasEnoughQuerySignal(tokens) {
|
|
77
|
+
const strong = Array.isArray(tokens) ? tokens : tokens.strong;
|
|
78
|
+
const usable = strong.filter((t) => t.length >= 2);
|
|
79
|
+
if (usable.length >= 2)
|
|
80
|
+
return true;
|
|
81
|
+
return usable.some((t) => t.length >= 3 && isCjk(t[0] ?? ''));
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* 绝对关键词相关度(0–1):查询 token 被正文/路径覆盖的加权比例。
|
|
85
|
+
*
|
|
86
|
+
* 与结果集无关,供 inject/hint 地板使用;**不要**再做组内 min-max。
|
|
87
|
+
* strong 权重 1,weak(CJK 滑窗二元组)0.5;命中字段:content 1.0 / tags 0.6 / 其它 0.3。
|
|
88
|
+
*
|
|
89
|
+
* @param fields - 可检索字段
|
|
90
|
+
* @param tokens - 查询分词
|
|
91
|
+
* @returns 0–1;无 token 时 0
|
|
92
|
+
*/
|
|
93
|
+
export function scoreKeywordCoverage(fields, tokens) {
|
|
94
|
+
const detail = Array.isArray(tokens)
|
|
95
|
+
? {
|
|
96
|
+
all: tokens,
|
|
97
|
+
strong: tokens,
|
|
98
|
+
weak: [],
|
|
99
|
+
}
|
|
100
|
+
: tokens;
|
|
101
|
+
const list = detail.all;
|
|
102
|
+
if (list.length === 0)
|
|
103
|
+
return 0;
|
|
104
|
+
const weakSet = new Set(detail.weak);
|
|
105
|
+
const content = (fields.content ?? '').toLowerCase();
|
|
106
|
+
const futureUse = (fields.futureUse ?? '').toLowerCase();
|
|
107
|
+
const tags = asText(fields.tags).toLowerCase();
|
|
108
|
+
const anchors = asText(fields.anchors).toLowerCase();
|
|
109
|
+
const evidence = (fields.evidence ?? '').toLowerCase();
|
|
110
|
+
let totalW = 0;
|
|
111
|
+
let hitW = 0;
|
|
112
|
+
for (const token of list) {
|
|
113
|
+
if (!token)
|
|
114
|
+
continue;
|
|
115
|
+
const tw = weakSet.has(token) ? 0.5 : 1;
|
|
116
|
+
totalW += tw;
|
|
117
|
+
if (content.includes(token)) {
|
|
118
|
+
hitW += tw * 1.0;
|
|
119
|
+
}
|
|
120
|
+
else if (tags.includes(token)) {
|
|
121
|
+
hitW += tw * 0.6;
|
|
122
|
+
}
|
|
123
|
+
else if (futureUse.includes(token) || anchors.includes(token) || evidence.includes(token)) {
|
|
124
|
+
hitW += tw * 0.3;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (totalW === 0)
|
|
128
|
+
return 0;
|
|
129
|
+
return Math.min(1, hitW / totalW);
|
|
130
|
+
}
|
|
67
131
|
function asText(v) {
|
|
68
132
|
if (v == null)
|
|
69
133
|
return '';
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* 原则:原件 + .manifest.json 为权威;抽取/索引可重建。
|
|
7
7
|
*/
|
|
8
8
|
import { type AttachmentLimits, type AttachmentUploadInput, type SessionAttachment } from './types.js';
|
|
9
|
-
import type { DocumentPort } from '../../
|
|
9
|
+
import type { DocumentPort } from '../../capabilities/document/types.js';
|
|
10
10
|
export interface SessionAttachmentServiceOptions {
|
|
11
11
|
/** 通常 `OCTOPI_HOME/sessions` */
|
|
12
12
|
sessionsDir: string;
|
|
@@ -13,7 +13,7 @@ import { resolveSessionAttachmentsPaths } from './paths.js';
|
|
|
13
13
|
import { attachmentExtension, isPathInside, sanitizeAttachmentName } from './sanitize.js';
|
|
14
14
|
import { classifyAttachmentKind, extractCompanionName, extractText, isPlainReadable, } from './extract.js';
|
|
15
15
|
import { DEFAULT_ATTACHMENT_LIMITS, } from './types.js';
|
|
16
|
-
import { isDocumentExtractError } from '../../
|
|
16
|
+
import { isDocumentExtractError } from '../../capabilities/document/errors.js';
|
|
17
17
|
export class SessionAttachmentService {
|
|
18
18
|
sessionsDir;
|
|
19
19
|
limits;
|
package/dist/index.d.ts
CHANGED
|
@@ -71,8 +71,10 @@ export type { AgentPersona, ModelConfig, AgentDefinition } from './harness/share
|
|
|
71
71
|
export { DefaultToolBus } from './harness/extension/plugin-ecosystem/tools/tool-bus.js';
|
|
72
72
|
export { getBuiltinTools, createShellTool, createFileReadTool, createFileWriteTool, createFileListTool } from './harness/extension/plugin-ecosystem/tools/builtin.js';
|
|
73
73
|
export { createToolSet } from './harness/extension/plugin-ecosystem/tools/tool-set.js';
|
|
74
|
-
export { createSummaryPort, applyToolOutputGate, createCompactEngine
|
|
75
|
-
export
|
|
74
|
+
export { createSummaryPort, applyToolOutputGate, createCompactEngine } from './harness/context/capabilities/index.js';
|
|
75
|
+
export { createDefaultDocumentPort, createDocumentPortFromConfig, DocumentExtractError } from './harness/capabilities/document/index.js';
|
|
76
|
+
export type { SummaryPort, SummaryPolicy, ContentUnit, ToolSummarySupport, CompactEngine } from './harness/context/capabilities/index.js';
|
|
77
|
+
export type { DocumentPort, ExtractResult, ExtractSource } from './harness/capabilities/document/index.js';
|
|
76
78
|
export type { ToolSet, ToolSetConfig } from './harness/extension/plugin-ecosystem/tools/tool-set.js';
|
|
77
79
|
export { createWebSearchTool } from './harness/extension/plugin-ecosystem/tools/web-search.js';
|
|
78
80
|
export type { WebSearchToolOptions } from './harness/extension/plugin-ecosystem/tools/web-search.js';
|
package/dist/index.js
CHANGED
|
@@ -47,7 +47,8 @@ export { DefaultSkillManager, FileSystemSkillSource } from './harness/extension/
|
|
|
47
47
|
export { DefaultToolBus } from './harness/extension/plugin-ecosystem/tools/tool-bus.js';
|
|
48
48
|
export { getBuiltinTools, createShellTool, createFileReadTool, createFileWriteTool, createFileListTool } from './harness/extension/plugin-ecosystem/tools/builtin.js';
|
|
49
49
|
export { createToolSet } from './harness/extension/plugin-ecosystem/tools/tool-set.js';
|
|
50
|
-
export { createSummaryPort, applyToolOutputGate, createCompactEngine
|
|
50
|
+
export { createSummaryPort, applyToolOutputGate, createCompactEngine } from './harness/context/capabilities/index.js';
|
|
51
|
+
export { createDefaultDocumentPort, createDocumentPortFromConfig, DocumentExtractError } from './harness/capabilities/document/index.js';
|
|
51
52
|
export { createWebSearchTool } from './harness/extension/plugin-ecosystem/tools/web-search.js';
|
|
52
53
|
export { createSessionHistoryPort, resolveHistoryAccess, } from './harness/session/history/index.js';
|
|
53
54
|
export { createSessionHistoryTools, createSessionSearchTool, createSessionReadTool, } from './harness/extension/plugin-ecosystem/tools/session-history.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module path resolver for workers and child processes.
|
|
3
|
+
*
|
|
4
|
+
* Neither Worker nor child_process can execute TypeScript. Production loads
|
|
5
|
+
* compiled files under packages/pkg/dist. Vitest imports src TypeScript, so we
|
|
6
|
+
* map src -> dist. Callers MUST pass their own `import.meta.url`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveWorkerUrl(moduleFile: string, fromUrl: string): URL;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module path resolver for workers and child processes.
|
|
3
|
+
*
|
|
4
|
+
* Neither Worker nor child_process can execute TypeScript. Production loads
|
|
5
|
+
* compiled files under packages/pkg/dist. Vitest imports src TypeScript, so we
|
|
6
|
+
* map src -> dist. Callers MUST pass their own `import.meta.url`.
|
|
7
|
+
*/
|
|
8
|
+
export function resolveWorkerUrl(moduleFile, fromUrl) {
|
|
9
|
+
const normalized = fromUrl.replace(/\\/g, '/');
|
|
10
|
+
if (normalized.includes('/src/') && normalized.endsWith('.ts')) {
|
|
11
|
+
const distBase = normalized.replace('/src/', '/dist/').replace(/\.ts$/, '.js');
|
|
12
|
+
return new URL(moduleFile, distBase);
|
|
13
|
+
}
|
|
14
|
+
return new URL(moduleFile, fromUrl);
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octopi-agent/engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.65.0",
|
|
4
4
|
"description": "Octopi Engine — Harness product domains, library integrations, and embeddable Agent.run()",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
82
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
83
|
-
"@octopi-agent/core": "0.
|
|
83
|
+
"@octopi-agent/core": "0.65.0",
|
|
84
84
|
"js-yaml": "^4.3.2",
|
|
85
85
|
"zod": "^4.4.3"
|
|
86
86
|
},
|