engine7 7.1.148 → 7.1.150

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.
@@ -1367,7 +1367,9 @@ var tokenizer_exports = {};
1367
1367
  __export(tokenizer_exports, {
1368
1368
  DEFAULT_STOPWORDS: () => DEFAULT_STOPWORDS,
1369
1369
  MIN_TOKEN_LENGTH: () => MIN_TOKEN_LENGTH,
1370
+ cjkBigrams: () => cjkBigrams,
1370
1371
  tokenize: () => tokenize,
1372
+ tokenizeCjk: () => tokenizeCjk,
1371
1373
  tokenizeToField: () => tokenizeToField
1372
1374
  });
1373
1375
  import { Jieba } from "@node-rs/jieba";
@@ -1390,6 +1392,16 @@ function tokenize(text2) {
1390
1392
  function tokenizeToField(text2) {
1391
1393
  return tokenize(text2).join(" ");
1392
1394
  }
1395
+ function cjkBigrams(text2) {
1396
+ const out = [];
1397
+ for (const seg of String(text2 ?? "").match(/[\u4e00-\u9fff]{2,}/g) ?? []) {
1398
+ for (let i = 0; i + 1 < seg.length; i++) out.push(seg.slice(i, i + 2));
1399
+ }
1400
+ return out;
1401
+ }
1402
+ function tokenizeCjk(text2) {
1403
+ return [...tokenize(text2), ...cjkBigrams(text2)];
1404
+ }
1393
1405
  var DEFAULT_STOPWORDS, MIN_TOKEN_LENGTH, jieba;
1394
1406
  var init_tokenizer = __esm({
1395
1407
  "src/mem7/core/tokenizer.ts"() {
@@ -5714,16 +5726,15 @@ function stripInjectedContext(text2) {
5714
5726
  function escapeRegExp(s) {
5715
5727
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
5716
5728
  }
5717
- var SKILL_GATE_HINT_PREFIX, SYSTEM_REMINDER_BLOCK, INJECT_SECTION_HEADS, KNOWN_INJECTED_TEXT, INJECTED_LINE_PREFIXES, XML_BLOCK;
5729
+ var SYSTEM_REMINDER_BLOCK, INJECT_SECTION_HEADS, KNOWN_INJECTED_TEXT, INJECTED_LINE_PREFIXES, XML_BLOCK;
5718
5730
  var init_strip_injected = __esm({
5719
5731
  "src/messages/strip-injected.ts"() {
5720
5732
  "use strict";
5721
- SKILL_GATE_HINT_PREFIX = "\u8FD9\u6761\u6D88\u606F\u662F\u5F00\u53D1\u4EFB\u52A1";
5722
5733
  SYSTEM_REMINDER_BLOCK = /<system-reminder>[\s\S]*?<\/system-reminder>/g;
5723
5734
  INJECT_SECTION_HEADS = /^(本轮对话|当前情绪状态|当前模式)/;
5724
5735
  KNOWN_INJECTED_TEXT = [
5725
- SKILL_GATE_HINT_PREFIX,
5726
- // skill-gate hint 默认/自定义前缀(1007 现行)
5736
+ "\u8FD9\u6761\u6D88\u606F\u662F\u5F00\u53D1\u4EFB\u52A1",
5737
+ // 旧版 skill-gate 提示前缀,兼容未打标签的历史
5727
5738
  "\u5F00\u53D1\u4EFB\u52A1\u8DEF\u6807\uFF0C\u6309\u573A\u666F\u5BF9\u53F7\u5165\u5EA7",
5728
5739
  // skill-gate hint(0912 老文案,历史 JSONL 兼容)
5729
5740
  "\u3010\u5B9A\u65F6\u5FC3\u8DF3\u3011\u8BF7 read HEARTBEAT.md"
@@ -8383,10 +8394,10 @@ function installSQLiteWriteCapture(db, source) {
8383
8394
  if (db.isTransaction) throw new Error("REPLICATION_TRANSACTION_ALREADY_OPEN");
8384
8395
  const exec = db.exec, prepare = db.prepare;
8385
8396
  let active, failed = false, closed = false, reading = false;
8386
- let direct;
8397
+ let direct2;
8387
8398
  const check = () => {
8388
8399
  if (closed) throw new Error("REPLICATION_TRANSACTION_CLOSED");
8389
- direct?.assertOpen();
8400
+ direct2?.assertOpen();
8390
8401
  };
8391
8402
  const wrappedExec = function(sql) {
8392
8403
  check();
@@ -8457,10 +8468,10 @@ function installSQLiteWriteCapture(db, source) {
8457
8468
  db.prepare = checkedPrepare;
8458
8469
  const transaction = (operation) => {
8459
8470
  check();
8460
- if (db.isTransaction) return direct.scope(operation);
8471
+ if (db.isTransaction) return direct2.scope(operation);
8461
8472
  db.exec("BEGIN IMMEDIATE");
8462
8473
  try {
8463
- const result = direct.scope(operation);
8474
+ const result = direct2.scope(operation);
8464
8475
  if (result && typeof result.then === "function") throw new Error("REPLICATION_ASYNC_TRANSACTION");
8465
8476
  db.exec("COMMIT");
8466
8477
  return result;
@@ -8469,10 +8480,10 @@ function installSQLiteWriteCapture(db, source) {
8469
8480
  throw error;
8470
8481
  }
8471
8482
  };
8472
- direct = installAutocommitCapture(db, transaction);
8483
+ direct2 = installAutocommitCapture(db, transaction);
8473
8484
  return {
8474
8485
  assertOpen: check,
8475
- scope: (operation) => direct.scope(operation),
8486
+ scope: (operation) => direct2.scope(operation),
8476
8487
  transaction,
8477
8488
  close() {
8478
8489
  if (closed) return;
@@ -8481,7 +8492,7 @@ function installSQLiteWriteCapture(db, source) {
8481
8492
  source.endCapture(active);
8482
8493
  active = void 0;
8483
8494
  }
8484
- direct.close();
8495
+ direct2.close();
8485
8496
  db.prepare = prepare;
8486
8497
  db.exec = exec;
8487
8498
  closed = true;
@@ -8801,18 +8812,31 @@ function forgotten(b, path8) {
8801
8812
  }
8802
8813
  function openIndex(b, version) {
8803
8814
  if (!b.stateDir || !b.topicsDir) return null;
8804
- const root = topicsHistoryRoot(b);
8815
+ const root = topicsHistoryRoot(b), expectedRoot = resolve7(b.topicsDir);
8816
+ let selected = "", actualRoot;
8805
8817
  try {
8806
- const selected = version ?? readJson(join13(root, "current.json")).version;
8818
+ selected = version ?? readJson(join13(root, "current.json")).version;
8807
8819
  if (!/^[a-f0-9-]{36}$/.test(selected)) throw new Error("INVALID_HISTORY_VERSION");
8808
8820
  const db = new DatabaseSync7(unlinked(join13(root, selected, "history.db")), { readOnly: true });
8809
8821
  const meta = db.prepare("SELECT value FROM metadata WHERE key=?").get("binding");
8810
- if (meta?.value !== canonical({ scope: topicsScope(b), root: resolve7(b.topicsDir) })) {
8822
+ if (meta?.value !== canonical({ scope: topicsScope(b), root: expectedRoot })) {
8823
+ try {
8824
+ actualRoot = String(JSON.parse(meta?.value ?? "{}").root ?? "") || void 0;
8825
+ } catch {
8826
+ actualRoot = meta?.value;
8827
+ }
8811
8828
  db.close();
8812
8829
  throw new Error("HISTORY_SCOPE_MISMATCH");
8813
8830
  }
8814
8831
  return db;
8815
- } catch {
8832
+ } catch (error) {
8833
+ if (error instanceof Error && error.message === "HISTORY_SCOPE_MISMATCH") {
8834
+ const signature2 = `${expectedRoot}|${actualRoot ?? ""}`;
8835
+ if (!scopeMismatchWarned.has(signature2)) {
8836
+ scopeMismatchWarned.add(signature2);
8837
+ console.warn(`[topics-history] HISTORY_SCOPE_MISMATCH\uFF1A\u7D22\u5F15\u7ED1\u5B9A\u7684 topics \u6839\u76EE\u5F55\u4E0E\u5F53\u524D\u4E0D\u7B26\uFF0C\u5386\u53F2\u68C0\u7D22\u672C\u6B21\u4E3A\u7A7A\u4E14\u4E0D\u4F1A\u81EA\u6108\uFF08\u9700\u91CD\u5EFA\uFF09\u3002expected root=${expectedRoot} actual root=${actualRoot ?? "(unreadable)"} version=${selected} index=${join13(root, selected, "history.db")}`);
8838
+ }
8839
+ }
8816
8840
  return null;
8817
8841
  }
8818
8842
  }
@@ -9006,15 +9030,15 @@ async function publishTopicsIndex(bundle, cleaned, b) {
9006
9030
  const md = /(?:^|-)\d{2}-\d{2}$/.test(d.value) ? d.value.slice(-5) : void 0;
9007
9031
  return [d.value, d.year?.toString() ?? "", ...md ? [md, `${Number(md.slice(0, 2))}\u6708${Number(md.slice(-2))}\u65E5`] : []];
9008
9032
  });
9009
- const terms = tokenize(`${paragraph}
9033
+ const terms = tokenizeCjk(`${paragraph}
9010
9034
  ${aliases.join(" ")}`);
9011
9035
  documentTerms.push(...terms);
9012
- search.run(id, [...tokenize(item.originalMetadata.title), ...terms].join(" "));
9036
+ search.run(id, [...tokenizeCjk(item.originalMetadata.title), ...terms].join(" "));
9013
9037
  }
9014
9038
  start = end;
9015
9039
  }
9016
9040
  }
9017
- if (documentTerms.length) documentInsert.run(item.path, item.originalHash, [...tokenize(item.originalMetadata.title), ...documentTerms].join(" "));
9041
+ if (documentTerms.length) documentInsert.run(item.path, item.originalHash, [...tokenizeCjk(item.originalMetadata.title), ...documentTerms].join(" "));
9018
9042
  }
9019
9043
  db.exec("COMMIT");
9020
9044
  if (db.prepare("PRAGMA integrity_check").get().integrity_check !== "ok") throw new Error("HISTORY_INDEX_INVALID");
@@ -9035,7 +9059,7 @@ async function searchTopicsHistory(b, query, options = {}) {
9035
9059
  const before = mem7StartDate(b);
9036
9060
  const year = topicQueryYear(query, options);
9037
9061
  const normalized = query.replace(/(?<!\d)(?:19|20)\d{2}\s*年?(?!\d)/g, "").replace(/去年|今年/g, "");
9038
- const terms = [...new Set(tokenize(normalized))].slice(0, 24);
9062
+ const terms = [...new Set(tokenizeCjk(normalized))].slice(0, 24);
9039
9063
  if (!terms.length && year !== void 0) terms.push(String(year));
9040
9064
  if (!terms.length) return [];
9041
9065
  const match = terms.map((term) => `"${term.replace(/"/g, '""')}"`).join(" OR ");
@@ -9046,7 +9070,7 @@ async function searchTopicsHistory(b, query, options = {}) {
9046
9070
  for (const row of rows) {
9047
9071
  const ref = JSON.parse(row.ref);
9048
9072
  const words = terms.filter((term) => !/^\d+[年月日]?$/.test(term));
9049
- if (words.length && !words.some((term) => tokenize(row.body + " " + row.title).includes(term))) continue;
9073
+ if (words.length && !words.some((term) => tokenizeCjk(row.body + " " + row.title).includes(term))) continue;
9050
9074
  try {
9051
9075
  const hit = getTopicHistory(b, ref, before);
9052
9076
  if (!topicMatchesYear(hit.dates, year)) continue;
@@ -9089,7 +9113,7 @@ async function searchTopicsHistory(b, query, options = {}) {
9089
9113
  db.close();
9090
9114
  }
9091
9115
  }
9092
- var topicsScope, key3, rootKey, refPath, refId, fallbackChecks, credential2;
9116
+ var topicsScope, key3, rootKey, refPath, refId, scopeMismatchWarned, fallbackChecks, credential2;
9093
9117
  var init_topics_history = __esm({
9094
9118
  "src/memory/topics-history/index.ts"() {
9095
9119
  "use strict";
@@ -9104,6 +9128,7 @@ var init_topics_history = __esm({
9104
9128
  rootKey = (b) => digest3(resolve7(b.topicsDir));
9105
9129
  refPath = (ref) => `topics-history://${Buffer.from(canonical(ref)).toString("base64url")}`;
9106
9130
  refId = (ref) => digest3(canonical(ref));
9131
+ scopeMismatchWarned = /* @__PURE__ */ new Set();
9107
9132
  fallbackChecks = /* @__PURE__ */ new Map();
9108
9133
  credential2 = /(?:api[_-]?key|password|secret|access[_-]?token)["']?\s*[:=]\s*["']?(?!YOUR_|PLACEHOLDER|\*|\[REDACTED\]|env:|\{\{)[\w/+.-]{10,}|-----BEGIN (?:RSA |OPENSSH |EC )?PRIVATE KEY-----|\bsk-[A-Za-z0-9_-]{20,}/i;
9109
9134
  }
@@ -9138,6 +9163,8 @@ function attachmentToMessage(attachment) {
9138
9163
  ${attachment.notifications.join("\n\n")}`
9139
9164
  )
9140
9165
  };
9166
+ case "coldstart_hint":
9167
+ return { role: "user", content: wrapInSystemReminder(attachment.text) };
9141
9168
  case "teammate_messages": {
9142
9169
  const lines = attachment.messages.map(
9143
9170
  (m) => m.summary ? `[From: ${m.from}] ${m.summary}
@@ -11963,32 +11990,32 @@ CREATE TABLE IF NOT EXISTS cluster_members (
11963
11990
  return { built: !hasStats, ms: Date.now() - started };
11964
11991
  }
11965
11992
  async close() {
11966
- const errors = [];
11993
+ const errors2 = [];
11967
11994
  try {
11968
11995
  this.capture?.close();
11969
11996
  } catch (error) {
11970
- errors.push(error);
11997
+ errors2.push(error);
11971
11998
  }
11972
11999
  try {
11973
12000
  this.db.close();
11974
12001
  } catch (error) {
11975
- errors.push(error);
12002
+ errors2.push(error);
11976
12003
  }
11977
12004
  try {
11978
12005
  await this.vectors?.close();
11979
12006
  } catch (error) {
11980
- errors.push(error);
12007
+ errors2.push(error);
11981
12008
  } finally {
11982
12009
  this.vectors = null;
11983
12010
  }
11984
12011
  try {
11985
12012
  this.releaseRuntimeWriter?.();
11986
12013
  } catch (error) {
11987
- errors.push(error);
12014
+ errors2.push(error);
11988
12015
  } finally {
11989
12016
  this.releaseRuntimeWriter = void 0;
11990
12017
  }
11991
- if (errors.length) throw new AggregateError(errors, "MEM7_CLOSE_FAILED");
12018
+ if (errors2.length) throw new AggregateError(errors2, "MEM7_CLOSE_FAILED");
11992
12019
  }
11993
12020
  // ── memcell 账本 ──────────────────────────────────────────
11994
12021
  insertMemcell(cell) {
@@ -15363,8 +15390,8 @@ async function warmReadStore(stateDir2) {
15363
15390
  const t0 = Date.now();
15364
15391
  try {
15365
15392
  const store = getReadStore(stateDir2);
15366
- const { tokenize: tokenize2 } = await Promise.resolve().then(() => (init_tokenizer(), tokenizer_exports));
15367
- tokenize2("");
15393
+ const { tokenize: tokenize3 } = await Promise.resolve().then(() => (init_tokenizer(), tokenizer_exports));
15394
+ tokenize3("");
15368
15395
  const vs = store.vectorStore();
15369
15396
  for (const kind of ["episode", "atomic_fact", "foresight", "agent_case", "agent_skill"]) {
15370
15397
  try {
@@ -15945,11 +15972,15 @@ var init_cpu_router_scene = __esm({
15945
15972
  });
15946
15973
 
15947
15974
  // src/skills/skill-gate.ts
15975
+ var USER_CHANNELS, SKILL_CHANNELS;
15948
15976
  var init_skill_gate = __esm({
15949
15977
  "src/skills/skill-gate.ts"() {
15950
15978
  "use strict";
15951
15979
  init_strip_injected();
15980
+ init_writer();
15952
15981
  init_cpu_router_scene();
15982
+ USER_CHANNELS = /* @__PURE__ */ new Set(["discord", "feishu", "wechat", "telegram", "cli", "console", "voice-chat", "deskBuddy", "ccBridge"]);
15983
+ SKILL_CHANNELS = /* @__PURE__ */ new Set([...USER_CHANNELS, "chan7", "webhook"]);
15953
15984
  }
15954
15985
  });
15955
15986
 
@@ -16095,8 +16126,125 @@ var init_provider = __esm({
16095
16126
  }
16096
16127
  });
16097
16128
 
16129
+ // src/services/adaptive-proxy.ts
16130
+ import { HttpsProxyAgent } from "https-proxy-agent";
16131
+ import { Agent, Client, ProxyAgent, errors } from "undici";
16132
+ function proxyAddress(value) {
16133
+ const bareLoopback = /^(?:localhost\.?|127(?:\.\d{1,3}){3}|\[::1\]):\d+$/i;
16134
+ return new URL(bareLoopback.test(value) ? `http://${value}` : value);
16135
+ }
16136
+ function localProxyKey(url) {
16137
+ if (url.protocol !== "http:" && url.protocol !== "https:") return;
16138
+ const host = url.hostname.replace(/\.$/, "");
16139
+ if (host !== "localhost" && host !== "[::1]" && !/^127\./.test(host)) return;
16140
+ return `${host}:${url.port || (url.protocol === "https:" ? 443 : 80)}`;
16141
+ }
16142
+ function proxyUnavailable(key4) {
16143
+ return (unreachableUntil.get(key4) ?? -Infinity) > Date.now();
16144
+ }
16145
+ function markUnavailable(key4) {
16146
+ unreachableUntil.set(key4, Date.now() + RETRY_PROXY_AFTER_MS);
16147
+ }
16148
+ function isTcpDialFailure(error) {
16149
+ if (error instanceof AggregateError) {
16150
+ return error.errors.length > 0 && error.errors.every(isTcpDialFailure);
16151
+ }
16152
+ const err = error;
16153
+ return err?.syscall === "connect" && dialFailureCodes.has(err.code ?? "");
16154
+ }
16155
+ function getProxyDispatcher(value) {
16156
+ const raw = value?.trim();
16157
+ if (!raw) return;
16158
+ const cached = dispatchers.get(raw);
16159
+ if (cached) return cached;
16160
+ const url = proxyAddress(raw);
16161
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
16162
+ throw new Error(
16163
+ `\u4E0D\u652F\u6301\u7684\u4EE3\u7406\u534F\u8BAE ${url.protocol}\uFF08\u4EC5 http/https \u53EF\u76F4\u63A5\u4F7F\u7528\uFF1Bsocks5 \u7B49\u8BF7\u5148\u8F6C\u6210 http \u4EE3\u7406\uFF0C\u5982 gost/privoxy\uFF09\uFF1A${raw}`
16164
+ );
16165
+ }
16166
+ const key4 = localProxyKey(url);
16167
+ const dispatcher = key4 ? new AdaptiveProxyDispatcher(url.href, key4) : new ProxyAgent({ uri: url.href });
16168
+ dispatchers.set(raw, dispatcher);
16169
+ return dispatcher;
16170
+ }
16171
+ var RETRY_PROXY_AFTER_MS, LOCAL_CONNECT_TIMEOUT_MS, unreachableUntil, failedProxyDials, dispatchers, direct, dialFailureCodes, AdaptiveProxyDispatcher;
16172
+ var init_adaptive_proxy = __esm({
16173
+ "src/services/adaptive-proxy.ts"() {
16174
+ "use strict";
16175
+ RETRY_PROXY_AFTER_MS = 5e3;
16176
+ LOCAL_CONNECT_TIMEOUT_MS = 1e3;
16177
+ unreachableUntil = /* @__PURE__ */ new Map();
16178
+ failedProxyDials = /* @__PURE__ */ new WeakSet();
16179
+ dispatchers = /* @__PURE__ */ new Map();
16180
+ direct = new Agent();
16181
+ dialFailureCodes = /* @__PURE__ */ new Set(["ECONNREFUSED", "ETIMEDOUT", "ENETUNREACH", "EHOSTUNREACH", "EADDRNOTAVAIL"]);
16182
+ AdaptiveProxyDispatcher = class extends ProxyAgent {
16183
+ constructor(uri, key4) {
16184
+ super({
16185
+ uri,
16186
+ proxyTls: { timeout: LOCAL_CONNECT_TIMEOUT_MS },
16187
+ clientFactory(origin, opts) {
16188
+ const { connect } = opts;
16189
+ return new Client(origin, {
16190
+ connect(options, callback) {
16191
+ let tcpConnected = false;
16192
+ const socket = connect(options, (...result) => {
16193
+ const [error] = result;
16194
+ if (error && !tcpConnected && (isTcpDialFailure(error) || error.code === "UND_ERR_CONNECT_TIMEOUT")) {
16195
+ markUnavailable(key4);
16196
+ failedProxyDials.add(error);
16197
+ }
16198
+ callback(...result);
16199
+ });
16200
+ socket.once("connect", () => {
16201
+ tcpConnected = true;
16202
+ });
16203
+ return socket;
16204
+ }
16205
+ });
16206
+ }
16207
+ });
16208
+ this.key = key4;
16209
+ }
16210
+ dispatch(options, handler) {
16211
+ if (!this.closed && !this.destroyed && proxyUnavailable(this.key)) {
16212
+ const headers = options.headers;
16213
+ const keys = !headers ? [] : Array.isArray(headers) ? headers.filter((_, index) => index % 2 === 0) : Symbol.iterator in headers ? Array.from(headers, ([name]) => name) : Object.keys(headers);
16214
+ if (keys.some((name) => name.toLowerCase() === "proxy-authorization")) {
16215
+ throw new errors.InvalidArgumentError("Proxy-Authorization should be sent in ProxyAgent constructor");
16216
+ }
16217
+ return direct.dispatch(options, handler);
16218
+ }
16219
+ let connected = false;
16220
+ const extended = handler;
16221
+ const guarded = {
16222
+ onConnect: (abort) => {
16223
+ connected = true;
16224
+ handler.onConnect?.(abort);
16225
+ },
16226
+ onError: (error) => {
16227
+ if (!connected && failedProxyDials.has(error)) {
16228
+ direct.dispatch(options, handler);
16229
+ } else {
16230
+ handler.onError?.(error);
16231
+ }
16232
+ },
16233
+ onHeaders: handler.onHeaders?.bind(handler),
16234
+ onData: handler.onData?.bind(handler),
16235
+ onComplete: handler.onComplete?.bind(handler),
16236
+ onUpgrade: handler.onUpgrade?.bind(handler),
16237
+ onResponseStarted: handler.onResponseStarted?.bind(handler),
16238
+ onBodySent: handler.onBodySent?.bind(handler),
16239
+ onRequestSent: extended.onRequestSent?.bind(handler)
16240
+ };
16241
+ return super.dispatch(options, guarded);
16242
+ }
16243
+ };
16244
+ }
16245
+ });
16246
+
16098
16247
  // src/services/withRetry.ts
16099
- import { ProxyAgent } from "undici";
16100
16248
  function sleep(ms, signal) {
16101
16249
  return new Promise((resolve13, reject) => {
16102
16250
  if (signal?.aborted) {
@@ -16164,15 +16312,6 @@ function shouldRetry(status, errorBody) {
16164
16312
  if (errorBody?.includes('"type":"overloaded_error"')) return true;
16165
16313
  return false;
16166
16314
  }
16167
- function getProxyDispatcher(proxyUrl) {
16168
- if (!proxyUrl) return void 0;
16169
- let agent = proxyAgentCache.get(proxyUrl);
16170
- if (!agent) {
16171
- agent = new ProxyAgent({ uri: proxyUrl });
16172
- proxyAgentCache.set(proxyUrl, agent);
16173
- }
16174
- return agent;
16175
- }
16176
16315
  async function* fetchWithRetry(url, init, providerLabel, proxy, beforeRequest, retryPolicy) {
16177
16316
  const configuredRetries = getMaxRetries();
16178
16317
  const maxRetries = retryPolicy?.maxRetries === void 0 ? configuredRetries : Math.min(configuredRetries, Math.max(0, Math.floor(retryPolicy.maxRetries)));
@@ -16310,10 +16449,11 @@ function readWithTimeout(reader, timeoutMs, signal) {
16310
16449
  if (onAbort) signal?.removeEventListener("abort", onAbort);
16311
16450
  });
16312
16451
  }
16313
- var DEFAULT_MAX_RETRIES, BASE_DELAY_MS, MAX_DELAY_MS, DEFAULT_TIMEOUT_MS, READ_TIMEOUT_MS, FIRST_READ_TIMEOUT_MS, NO_PROGRESS_TIMEOUT_MS, proxyAgentCache;
16452
+ var DEFAULT_MAX_RETRIES, BASE_DELAY_MS, MAX_DELAY_MS, DEFAULT_TIMEOUT_MS, READ_TIMEOUT_MS, FIRST_READ_TIMEOUT_MS, NO_PROGRESS_TIMEOUT_MS;
16314
16453
  var init_withRetry = __esm({
16315
16454
  "src/services/withRetry.ts"() {
16316
16455
  "use strict";
16456
+ init_adaptive_proxy();
16317
16457
  DEFAULT_MAX_RETRIES = 10;
16318
16458
  BASE_DELAY_MS = 500;
16319
16459
  MAX_DELAY_MS = 32e3;
@@ -16321,7 +16461,6 @@ var init_withRetry = __esm({
16321
16461
  READ_TIMEOUT_MS = 6e4;
16322
16462
  FIRST_READ_TIMEOUT_MS = parseInt(process.env.API_TIMEOUT_MS || "", 10) || 6e5;
16323
16463
  NO_PROGRESS_TIMEOUT_MS = parseInt(process.env.STREAM_NO_PROGRESS_TIMEOUT_MS || "", 10) || 3e5;
16324
- proxyAgentCache = /* @__PURE__ */ new Map();
16325
16464
  }
16326
16465
  });
16327
16466
 
@@ -19801,7 +19940,7 @@ var init_sweep = __esm({
19801
19940
 
19802
19941
  // src/memory/proactive/opportunity.ts
19803
19942
  import { DatabaseSync as DatabaseSync12 } from "node:sqlite";
19804
- var OPPORTUNITY_SCAN_INTERVAL_MS, FORESIGHT_CACHE_TTL_MS;
19943
+ var OPPORTUNITY_SCAN_INTERVAL_MS, FORESIGHT_CACHE_TTL_MS, OPPORTUNITY_DELAY_MS, OPPORTUNITY_WINDOW_MARGIN_MS;
19805
19944
  var init_opportunity = __esm({
19806
19945
  "src/memory/proactive/opportunity.ts"() {
19807
19946
  "use strict";
@@ -19827,6 +19966,8 @@ var init_opportunity = __esm({
19827
19966
  init_sweep();
19828
19967
  OPPORTUNITY_SCAN_INTERVAL_MS = 6 * 60 * 6e4;
19829
19968
  FORESIGHT_CACHE_TTL_MS = 30 * 6e4;
19969
+ OPPORTUNITY_DELAY_MS = 30 * 6e4;
19970
+ OPPORTUNITY_WINDOW_MARGIN_MS = 10 * 6e4;
19830
19971
  }
19831
19972
  });
19832
19973