negotium 0.1.43 → 0.1.44
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/agent-helpers.js +117 -92
- package/dist/agent-helpers.js.map +10 -10
- package/dist/hosted-agent.js +2 -2
- package/dist/hosted-agent.js.map +2 -2
- package/dist/main.js +117 -92
- package/dist/main.js.map +10 -10
- package/dist/mcp-factories.js +541 -320
- package/dist/mcp-factories.js.map +10 -10
- package/dist/runtime/src/agents/archiver.ts +167 -160
- package/dist/runtime/src/agents/mcp-tools/spawn-subagent.ts +17 -11
- package/dist/runtime/src/mcp/wiki-server.ts +323 -103
- package/dist/runtime/src/prompts/agents/wiki-archiver.md +18 -14
- package/dist/runtime/src/runtime/turn-runner.ts +58 -40
- package/dist/runtime/src/storage/api-topic-brief.ts +11 -7
- package/dist/runtime/src/storage/wiki-summary-names.ts +22 -23
- package/dist/runtime/src/storage/wiki.ts +7 -4
- package/dist/runtime/src/version.ts +1 -1
- package/dist/storage.js +60 -52
- package/dist/storage.js.map +7 -7
- package/dist/types/packages/core/src/agents/archiver.d.ts +5 -0
- package/dist/types/packages/core/src/runtime/turn-runner.d.ts +6 -0
- package/dist/types/packages/core/src/storage/api-topic-brief.d.ts +3 -3
- package/dist/types/packages/core/src/storage/wiki-summary-names.d.ts +6 -8
- package/dist/types/packages/core/src/version.d.ts +1 -1
- package/package.json +1 -1
package/dist/agent-helpers.js
CHANGED
|
@@ -2618,7 +2618,7 @@ var init_claude_provider = __esm(async () => {
|
|
|
2618
2618
|
});
|
|
2619
2619
|
|
|
2620
2620
|
// ../../packages/core/src/version.ts
|
|
2621
|
-
var NEGOTIUM_VERSION = "0.1.
|
|
2621
|
+
var NEGOTIUM_VERSION = "0.1.44";
|
|
2622
2622
|
|
|
2623
2623
|
// ../../packages/core/src/agents/codex-native-multi-agent.ts
|
|
2624
2624
|
import { spawn as spawn3 } from "child_process";
|
|
@@ -6500,6 +6500,45 @@ var init_api_messages = __esm(async () => {
|
|
|
6500
6500
|
appendHooks = new Set;
|
|
6501
6501
|
});
|
|
6502
6502
|
|
|
6503
|
+
// ../../packages/core/src/storage/wiki-summary-names.ts
|
|
6504
|
+
function wikiSummarySlug(value) {
|
|
6505
|
+
return value.replaceAll(/[^a-zA-Z0-9\uAC00-\uD7A3_-]+/g, "-").slice(0, 120) || "_";
|
|
6506
|
+
}
|
|
6507
|
+
function wikiSummaryStorageSlug(rawTopic, _topicId) {
|
|
6508
|
+
return wikiSummarySlug(rawTopic);
|
|
6509
|
+
}
|
|
6510
|
+
function wikiBriefStorageKey(rawTopic, topicId) {
|
|
6511
|
+
return wikiSummaryStorageSlug(rawTopic, topicId);
|
|
6512
|
+
}
|
|
6513
|
+
function wikiSummaryFilename(date, rawTopic, topicId) {
|
|
6514
|
+
return `${date}-${wikiSummaryStorageSlug(rawTopic, topicId)}.md`;
|
|
6515
|
+
}
|
|
6516
|
+
function isTopicSummaryFile(filename, topicId, topicTitle) {
|
|
6517
|
+
if (!WIKI_SUMMARY_DATE_PREFIX.test(filename))
|
|
6518
|
+
return false;
|
|
6519
|
+
if (topicTitle) {
|
|
6520
|
+
const titleSlug = wikiSummarySlug(topicTitle);
|
|
6521
|
+
if (new RegExp(`^\\d{4}-\\d{2}-\\d{2}-${escapeRegExp(titleSlug)}(?:~\\d+)?\\.md$`).test(filename)) {
|
|
6522
|
+
return true;
|
|
6523
|
+
}
|
|
6524
|
+
}
|
|
6525
|
+
const idSlug = wikiSummarySlug(topicId);
|
|
6526
|
+
return filename.endsWith(`--${idSlug}.md`) || filename.endsWith(`-${idSlug}.md`);
|
|
6527
|
+
}
|
|
6528
|
+
function isTopicBriefFile(filename, topicId, topicTitle) {
|
|
6529
|
+
if (topicTitle && filename === `${wikiSummarySlug(topicTitle)}.md`)
|
|
6530
|
+
return true;
|
|
6531
|
+
const idSlug = wikiSummarySlug(topicId);
|
|
6532
|
+
return filename === `${idSlug}.md` || filename.endsWith(`--${idSlug}.md`);
|
|
6533
|
+
}
|
|
6534
|
+
function escapeRegExp(value) {
|
|
6535
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
6536
|
+
}
|
|
6537
|
+
var WIKI_SUMMARY_DATE_PREFIX;
|
|
6538
|
+
var init_wiki_summary_names = __esm(() => {
|
|
6539
|
+
WIKI_SUMMARY_DATE_PREFIX = /^\d{4}-\d{2}-\d{2}-/;
|
|
6540
|
+
});
|
|
6541
|
+
|
|
6503
6542
|
// ../../packages/core/src/storage/api-topic-brief.ts
|
|
6504
6543
|
function rowToBrief(r) {
|
|
6505
6544
|
return {
|
|
@@ -6510,17 +6549,21 @@ function rowToBrief(r) {
|
|
|
6510
6549
|
updatedAt: r.updated_at
|
|
6511
6550
|
};
|
|
6512
6551
|
}
|
|
6513
|
-
function getTopicBrief(
|
|
6514
|
-
const row = db.query("SELECT topic_id, brief_md, latest_summary_md, summary_date, updated_at FROM api_topic_brief WHERE topic_id = ?").get(
|
|
6552
|
+
function getTopicBrief(storageKey) {
|
|
6553
|
+
const row = db.query("SELECT topic_id, brief_md, latest_summary_md, summary_date, updated_at FROM api_topic_brief WHERE topic_id = ?").get(storageKey);
|
|
6515
6554
|
if (!row)
|
|
6516
6555
|
return null;
|
|
6517
6556
|
return rowToBrief(row);
|
|
6518
6557
|
}
|
|
6519
6558
|
function resolveTopicBrief(topicId, legacyTitle) {
|
|
6559
|
+
const titleKey = wikiSummarySlug(legacyTitle);
|
|
6560
|
+
const titleBrief = getTopicBrief(titleKey);
|
|
6561
|
+
if (titleBrief)
|
|
6562
|
+
return { brief: titleBrief, storageKey: titleKey };
|
|
6520
6563
|
const current2 = getTopicBrief(topicId);
|
|
6521
6564
|
if (current2)
|
|
6522
6565
|
return { brief: current2, storageKey: topicId };
|
|
6523
|
-
const legacy = getTopicBrief(legacyTitle);
|
|
6566
|
+
const legacy = titleKey === legacyTitle ? null : getTopicBrief(legacyTitle);
|
|
6524
6567
|
return legacy ? { brief: legacy, storageKey: legacyTitle } : null;
|
|
6525
6568
|
}
|
|
6526
6569
|
function setTopicBrief(topicId, fields) {
|
|
@@ -6544,6 +6587,7 @@ function deleteTopicBrief(topicId) {
|
|
|
6544
6587
|
var init_api_topic_brief = __esm(async () => {
|
|
6545
6588
|
await init_forum_db();
|
|
6546
6589
|
await init_storage_host();
|
|
6590
|
+
init_wiki_summary_names();
|
|
6547
6591
|
registerStorageSchemaInitializer((database) => {
|
|
6548
6592
|
database.exec(`
|
|
6549
6593
|
CREATE TABLE IF NOT EXISTS api_topic_brief (
|
|
@@ -6566,45 +6610,6 @@ var init_wiki = __esm(async () => {
|
|
|
6566
6610
|
await init_storage_host();
|
|
6567
6611
|
});
|
|
6568
6612
|
|
|
6569
|
-
// ../../packages/core/src/storage/wiki-summary-names.ts
|
|
6570
|
-
function wikiSummarySlug(value) {
|
|
6571
|
-
return value.replaceAll(/[^a-zA-Z0-9\uAC00-\uD7A3_-]+/g, "-").slice(0, 120) || "_";
|
|
6572
|
-
}
|
|
6573
|
-
function isEphemeralWikiTopicId(topicId) {
|
|
6574
|
-
return topicId?.startsWith("__") ?? false;
|
|
6575
|
-
}
|
|
6576
|
-
function wikiSummaryStorageSlug(rawTopic, topicId) {
|
|
6577
|
-
const titleSlug = wikiSummarySlug(rawTopic);
|
|
6578
|
-
if (!topicId || isEphemeralWikiTopicId(topicId))
|
|
6579
|
-
return titleSlug;
|
|
6580
|
-
const idSlug = wikiSummarySlug(topicId);
|
|
6581
|
-
return titleSlug === idSlug ? idSlug : `${titleSlug}--${idSlug}`;
|
|
6582
|
-
}
|
|
6583
|
-
function wikiBriefStorageKey(rawTopic, topicId) {
|
|
6584
|
-
return wikiSummaryStorageSlug(rawTopic, topicId);
|
|
6585
|
-
}
|
|
6586
|
-
function wikiSummaryFilename(date, rawTopic, topicId) {
|
|
6587
|
-
return `${date}-${wikiSummaryStorageSlug(rawTopic, topicId)}.md`;
|
|
6588
|
-
}
|
|
6589
|
-
function isTopicSummaryFile(filename, topicId, legacyTopicTitle) {
|
|
6590
|
-
if (!WIKI_SUMMARY_DATE_PREFIX.test(filename))
|
|
6591
|
-
return false;
|
|
6592
|
-
const idSlug = wikiSummarySlug(topicId);
|
|
6593
|
-
if (filename.endsWith(`--${idSlug}.md`) || filename.endsWith(`-${idSlug}.md`))
|
|
6594
|
-
return true;
|
|
6595
|
-
return legacyTopicTitle ? filename.endsWith(`-${wikiSummarySlug(legacyTopicTitle)}.md`) : false;
|
|
6596
|
-
}
|
|
6597
|
-
function isTopicBriefFile(filename, topicId, legacyTopicTitle) {
|
|
6598
|
-
const idSlug = wikiSummarySlug(topicId);
|
|
6599
|
-
if (filename === `${idSlug}.md` || filename.endsWith(`--${idSlug}.md`))
|
|
6600
|
-
return true;
|
|
6601
|
-
return legacyTopicTitle ? filename === `${wikiSummarySlug(legacyTopicTitle)}.md` : false;
|
|
6602
|
-
}
|
|
6603
|
-
var WIKI_SUMMARY_DATE_PREFIX;
|
|
6604
|
-
var init_wiki_summary_names = __esm(() => {
|
|
6605
|
-
WIKI_SUMMARY_DATE_PREFIX = /^\d{4}-\d{2}-\d{2}-/;
|
|
6606
|
-
});
|
|
6607
|
-
|
|
6608
6613
|
// ../../packages/core/src/platform/constants.ts
|
|
6609
6614
|
var FROM_AUTO_CONTINUE = "auto-continue", FROM_SELF_SCHEDULE = "self-schedule", RESERVED_TOPIC_NAMES, GENERAL_TOPIC_ID = "general";
|
|
6610
6615
|
var init_constants = __esm(() => {
|
|
@@ -7356,6 +7361,7 @@ function formatArchiverTool(name, input) {
|
|
|
7356
7361
|
}
|
|
7357
7362
|
function createArchiverRuntime(host) {
|
|
7358
7363
|
const activeSessions = new Map;
|
|
7364
|
+
const topicQueues = new Map;
|
|
7359
7365
|
let archiverDef = null;
|
|
7360
7366
|
const updateSession = (id, status, step) => {
|
|
7361
7367
|
const session = activeSessions.get(id);
|
|
@@ -7424,21 +7430,6 @@ function createArchiverRuntime(host) {
|
|
|
7424
7430
|
"#General\uC5D0 \uD45C\uC2DC\uB420 \uC9E7\uC740 \uD55C\uAD6D\uC5B4 \uC644\uB8CC \uBA54\uC2DC\uC9C0\uB85C \uCD5C\uC885 \uC751\uB2F5\uD574\uC918. " + "\uB3C4\uAD6C \uD638\uCD9C \uB85C\uADF8\uB098 \uC6D0\uBB38 \uC804\uBB38\uC740 \uC4F0\uC9C0 \uB9D0\uACE0, \uC800\uC7A5\uD55C \uC694\uC57D/\uBE0C\uB9AC\uD504/\uBB38\uC11C\uB9CC \uAC04\uB2E8\uD788 \uB9D0\uD574\uC918."
|
|
7425
7431
|
].join(`
|
|
7426
7432
|
`);
|
|
7427
|
-
const abortController = new AbortController;
|
|
7428
|
-
const events = host.agentRuntime.run({
|
|
7429
|
-
agent,
|
|
7430
|
-
prompt,
|
|
7431
|
-
cwd: host.config.workspaceDir,
|
|
7432
|
-
systemPrompt: definition.prompt,
|
|
7433
|
-
userId,
|
|
7434
|
-
session: `__archiver_${safeTopic}`,
|
|
7435
|
-
sessionType: "forum",
|
|
7436
|
-
topicId,
|
|
7437
|
-
abortController,
|
|
7438
|
-
model,
|
|
7439
|
-
mcpEnabled: ["wiki"],
|
|
7440
|
-
silent: true
|
|
7441
|
-
});
|
|
7442
7433
|
const activeSessionId = `memory:${host.config.createId()}`;
|
|
7443
7434
|
let archiveBytes = 0;
|
|
7444
7435
|
try {
|
|
@@ -7462,8 +7453,11 @@ function createArchiverRuntime(host) {
|
|
|
7462
7453
|
]
|
|
7463
7454
|
});
|
|
7464
7455
|
host.config.info({ userId, topicTitle, archivePath, agent, model }, "archiver: starting background turn");
|
|
7465
|
-
const
|
|
7466
|
-
|
|
7456
|
+
const previous = topicQueues.get(safeTopic);
|
|
7457
|
+
if (previous)
|
|
7458
|
+
updateSession(activeSessionId, "Queued", `Waiting for ${topicTitle} archive lock`);
|
|
7459
|
+
const work = (previous ?? Promise.resolve()).catch(() => {}).then(async () => {
|
|
7460
|
+
const startMs = host.config.now().getTime();
|
|
7467
7461
|
let ok = false;
|
|
7468
7462
|
let sawDelta = false;
|
|
7469
7463
|
let accumulatedText = "";
|
|
@@ -7472,6 +7466,20 @@ function createArchiverRuntime(host) {
|
|
|
7472
7466
|
let errorText = "";
|
|
7473
7467
|
let usage;
|
|
7474
7468
|
try {
|
|
7469
|
+
const events = host.agentRuntime.run({
|
|
7470
|
+
agent,
|
|
7471
|
+
prompt,
|
|
7472
|
+
cwd: host.config.workspaceDir,
|
|
7473
|
+
systemPrompt: definition.prompt,
|
|
7474
|
+
userId,
|
|
7475
|
+
session: `__archiver_${safeTopic}`,
|
|
7476
|
+
sessionType: "forum",
|
|
7477
|
+
topicId,
|
|
7478
|
+
abortController: new AbortController,
|
|
7479
|
+
model,
|
|
7480
|
+
mcpEnabled: ["wiki"],
|
|
7481
|
+
silent: true
|
|
7482
|
+
});
|
|
7475
7483
|
for await (const event of events) {
|
|
7476
7484
|
switch (event.type) {
|
|
7477
7485
|
case "session":
|
|
@@ -7551,7 +7559,12 @@ function createArchiverRuntime(host) {
|
|
|
7551
7559
|
const text = finalText.trimEnd();
|
|
7552
7560
|
finalizeGeneralMemory(host, userId, topicTitle, messageCount, startMs, ok, topicId, ok && text ? { text, agent, model, usage } : undefined);
|
|
7553
7561
|
}
|
|
7554
|
-
})
|
|
7562
|
+
});
|
|
7563
|
+
topicQueues.set(safeTopic, work);
|
|
7564
|
+
work.finally(() => {
|
|
7565
|
+
if (topicQueues.get(safeTopic) === work)
|
|
7566
|
+
topicQueues.delete(safeTopic);
|
|
7567
|
+
});
|
|
7555
7568
|
return true;
|
|
7556
7569
|
};
|
|
7557
7570
|
return Object.freeze({
|
|
@@ -7575,12 +7588,13 @@ function findSummaryFile(storage, topicTitle, date, sinceMs, topicId) {
|
|
|
7575
7588
|
if (!storage.fileExists(dir))
|
|
7576
7589
|
return null;
|
|
7577
7590
|
const predicted = join15(dir, wikiSummaryFilename(date, topicTitle, topicId));
|
|
7578
|
-
if (storage.fileExists(predicted))
|
|
7591
|
+
if (storage.fileExists(predicted) && storage.fileModifiedAt(predicted) >= sinceMs)
|
|
7579
7592
|
return predicted;
|
|
7580
7593
|
let best = null;
|
|
7581
7594
|
for (const f of storage.listDirectory(dir)) {
|
|
7582
|
-
if (!f.
|
|
7595
|
+
if (!f.startsWith(`${date}-`) || !isTopicSummaryFile(f, topicId ?? "", topicTitle)) {
|
|
7583
7596
|
continue;
|
|
7597
|
+
}
|
|
7584
7598
|
const p = join15(dir, f);
|
|
7585
7599
|
try {
|
|
7586
7600
|
const m = storage.fileModifiedAt(p);
|
|
@@ -13279,12 +13293,12 @@ function buildMentionOnlyChannelPrompt(params) {
|
|
|
13279
13293
|
].filter((line) => line !== undefined).join(`
|
|
13280
13294
|
`);
|
|
13281
13295
|
}
|
|
13282
|
-
function
|
|
13296
|
+
function escapeRegExp3(s) {
|
|
13283
13297
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
13284
13298
|
}
|
|
13285
13299
|
function mentionsAi(text2, label) {
|
|
13286
13300
|
const names = ["ai", "bot", "\uBD07", label.trim()].filter(Boolean);
|
|
13287
|
-
const alt = names.map(
|
|
13301
|
+
const alt = names.map(escapeRegExp3).join("|");
|
|
13288
13302
|
return new RegExp(`(^|\\s)@(${alt})(?![\\p{L}\\p{N}])`, "iu").test(text2);
|
|
13289
13303
|
}
|
|
13290
13304
|
var CHANNEL_CONTEXT_CURRENT_MESSAGE_MATCH_MS, CHANNEL_CONTEXT_MAX_MESSAGES = 500, CHANNEL_CONTEXT_MAX_CHARS = 120000;
|
|
@@ -14424,6 +14438,8 @@ __export(exports_turn_runner, {
|
|
|
14424
14438
|
startAiTurn: () => startAiTurn,
|
|
14425
14439
|
selectableModel: () => selectableModel,
|
|
14426
14440
|
safeAttachmentFilename: () => safeAttachmentFilename,
|
|
14441
|
+
resolveWikiMirrorPath: () => resolveWikiMirrorPath,
|
|
14442
|
+
resolveWikiMemoryMirror: () => resolveWikiMemoryMirror,
|
|
14427
14443
|
resolveVisualMediaInput: () => resolveVisualMediaInput,
|
|
14428
14444
|
resolveTopicTurnSession: () => resolveTopicTurnSession,
|
|
14429
14445
|
resolveTopicTurnExecution: () => resolveTopicTurnExecution,
|
|
@@ -14452,7 +14468,7 @@ __export(exports_turn_runner, {
|
|
|
14452
14468
|
ingestAttachment: () => ingestAttachment,
|
|
14453
14469
|
formatSelectableModel: () => formatSelectableModel,
|
|
14454
14470
|
formatChannelTranscriptLine: () => formatChannelTranscriptLine,
|
|
14455
|
-
escapeRegExp: () =>
|
|
14471
|
+
escapeRegExp: () => escapeRegExp3,
|
|
14456
14472
|
escapeHtml: () => escapeHtml2,
|
|
14457
14473
|
deliverAskCallbackToCaller: () => deliverAskCallbackToCaller,
|
|
14458
14474
|
composeAttachmentPrompt: () => composeAttachmentPrompt,
|
|
@@ -14518,29 +14534,37 @@ function appendAskReplyMessage(topicId, text2, agentType) {
|
|
|
14518
14534
|
WsHub.get().broadcastMessage(topicId, message);
|
|
14519
14535
|
return message;
|
|
14520
14536
|
}
|
|
14521
|
-
function resolveWikiMirrorPath(directory, preferredFilename,
|
|
14537
|
+
function resolveWikiMirrorPath(directory, preferredFilename, matchesLegacyId, matchesTitle, preferExact = true) {
|
|
14522
14538
|
const preferred = join27(directory, preferredFilename);
|
|
14523
|
-
if (existsSync18(preferred))
|
|
14539
|
+
if (preferExact && existsSync18(preferred))
|
|
14524
14540
|
return preferred;
|
|
14525
|
-
let
|
|
14526
|
-
let
|
|
14541
|
+
let newestLegacyId = null;
|
|
14542
|
+
let newestTitle = null;
|
|
14527
14543
|
try {
|
|
14528
14544
|
for (const filename of readdirSync5(directory)) {
|
|
14529
|
-
const
|
|
14530
|
-
|
|
14545
|
+
const titleMatch = matchesTitle(filename);
|
|
14546
|
+
const legacyIdMatch = !titleMatch && matchesLegacyId(filename);
|
|
14547
|
+
if (!titleMatch && !legacyIdMatch)
|
|
14531
14548
|
continue;
|
|
14532
14549
|
const path = join27(directory, filename);
|
|
14533
14550
|
const mtimeMs = statSync9(path).mtimeMs;
|
|
14534
|
-
if (
|
|
14535
|
-
if (!
|
|
14536
|
-
|
|
14551
|
+
if (titleMatch) {
|
|
14552
|
+
if (!newestTitle || mtimeMs > newestTitle.mtimeMs) {
|
|
14553
|
+
newestTitle = { path, mtimeMs };
|
|
14537
14554
|
}
|
|
14538
|
-
} else if (!
|
|
14539
|
-
|
|
14555
|
+
} else if (!newestLegacyId || mtimeMs > newestLegacyId.mtimeMs) {
|
|
14556
|
+
newestLegacyId = { path, mtimeMs };
|
|
14540
14557
|
}
|
|
14541
14558
|
}
|
|
14542
14559
|
} catch {}
|
|
14543
|
-
return
|
|
14560
|
+
return newestTitle?.path ?? newestLegacyId?.path ?? preferred;
|
|
14561
|
+
}
|
|
14562
|
+
function resolveWikiMemoryMirror(wikiDir, topicId, topicTitle) {
|
|
14563
|
+
const briefFile = resolveWikiMirrorPath(join27(wikiDir, "topic"), `${wikiBriefStorageKey(topicTitle, topicId)}.md`, (filename) => isTopicBriefFile(filename, topicId), (filename) => isTopicBriefFile(filename, topicId, topicTitle));
|
|
14564
|
+
const hasBriefFile = existsSync18(briefFile) && statSync9(briefFile).isFile();
|
|
14565
|
+
const latestSummaryCandidate = resolveWikiMirrorPath(join27(wikiDir, "summaries"), `__missing__-${wikiSummaryFilename("0000-00-00", topicTitle, topicId)}`, (filename) => isTopicSummaryFile(filename, topicId), (filename) => isTopicSummaryFile(filename, topicId, topicTitle), false);
|
|
14566
|
+
const latestSummaryFile = existsSync18(latestSummaryCandidate) && statSync9(latestSummaryCandidate).isFile() ? latestSummaryCandidate : null;
|
|
14567
|
+
return { briefFile, hasBriefFile, latestSummaryFile };
|
|
14544
14568
|
}
|
|
14545
14569
|
async function streamAgentEvents(topicId, topicTitle, queryId, events, control, agentType, model, effort, userId, retryableSessionExpired = true, onSessionId, execution) {
|
|
14546
14570
|
return runTurnEventStream(topicId, topicTitle, queryId, events, control, agentType, model, effort, userId, { appendSystemMessage, deliverAskCallbackToCaller, deliverAskError, redispatchInject }, retryableSessionExpired, onSessionId, execution);
|
|
@@ -15260,17 +15284,15 @@ function startAiTurn(params) {
|
|
|
15260
15284
|
if (!isMentionOnlyChannel) {
|
|
15261
15285
|
try {
|
|
15262
15286
|
const resolvedBrief = resolveTopicBrief(memoryTopic.id, memoryTopic.title);
|
|
15263
|
-
|
|
15264
|
-
|
|
15265
|
-
|
|
15266
|
-
const briefFile = resolveWikiMirrorPath(join27(wikiDir, "topic"), `${wikiBriefStorageKey(memoryTopic.title, memoryTopic.id)}.md`, (filename) => isTopicBriefFile(filename, memoryTopic.id), (filename) => isTopicBriefFile(filename, memoryTopic.id, memoryTopic.title));
|
|
15267
|
-
const latestSummaryFile = brief.summaryDate ? resolveWikiMirrorPath(join27(wikiDir, "summaries"), wikiSummaryFilename(brief.summaryDate, memoryTopic.title, memoryTopic.id), (filename) => filename.startsWith(`${brief.summaryDate}-`) && isTopicSummaryFile(filename, memoryTopic.id), (filename) => filename.startsWith(`${brief.summaryDate}-`) && isTopicSummaryFile(filename, memoryTopic.id, memoryTopic.title)) : null;
|
|
15287
|
+
const wikiDir = getSharedWikiDir();
|
|
15288
|
+
const { briefFile, hasBriefFile, latestSummaryFile } = resolveWikiMemoryMirror(wikiDir, memoryTopic.id, memoryTopic.title);
|
|
15289
|
+
if (resolvedBrief || hasBriefFile || latestSummaryFile) {
|
|
15268
15290
|
systemPrompt += buildMemoryPromptSection({
|
|
15269
15291
|
briefFile,
|
|
15270
15292
|
wikiDir,
|
|
15271
|
-
hasFiles:
|
|
15293
|
+
hasFiles: hasBriefFile,
|
|
15272
15294
|
latestSummaryFile,
|
|
15273
|
-
hasArchive: Boolean(brief.latestSummaryMd),
|
|
15295
|
+
hasArchive: Boolean(resolvedBrief?.brief.latestSummaryMd || latestSummaryFile),
|
|
15274
15296
|
isManager
|
|
15275
15297
|
});
|
|
15276
15298
|
}
|
|
@@ -15715,14 +15737,16 @@ function createSubagentLifecycle(host) {
|
|
|
15715
15737
|
return { error: "Error: memory_topic must name one topic/*.md file." };
|
|
15716
15738
|
}
|
|
15717
15739
|
const accessible = host.storage.listTopics().filter((topic) => topic.participants.some((participant) => participant.userId === userId));
|
|
15718
|
-
const
|
|
15740
|
+
const exactId = accessible.find((topic) => topic.id === key);
|
|
15741
|
+
const matches = exactId ? [exactId] : accessible.filter((topic) => {
|
|
15719
15742
|
const [canonicalFilename, legacyFilename] = host.config.memoryFilenames(topic);
|
|
15720
|
-
return key
|
|
15743
|
+
return key.toLowerCase() === topic.title.toLowerCase() || key === canonicalFilename || key === legacyFilename;
|
|
15721
15744
|
});
|
|
15722
15745
|
if (matches.length === 0) {
|
|
15723
15746
|
return { error: `Error: memory topic '${selection}' was not found or is not accessible.` };
|
|
15724
15747
|
}
|
|
15725
|
-
|
|
15748
|
+
const canonicalNamespaces = new Set(matches.map((topic) => host.config.memoryFilenames(topic)[0]));
|
|
15749
|
+
if (canonicalNamespaces.size > 1) {
|
|
15726
15750
|
return {
|
|
15727
15751
|
error: `Error: memory topic '${selection}' is ambiguous; use its topic id or canonical topic/*.md filename.`
|
|
15728
15752
|
};
|
|
@@ -16172,7 +16196,8 @@ ${card.task}${reportInstruction}`;
|
|
|
16172
16196
|
const origin = host.storage.getTopicMemoryOrigin(topic.id) ?? topic;
|
|
16173
16197
|
if (!origin.participants.some((participant) => participant.userId === ctx.userId))
|
|
16174
16198
|
continue;
|
|
16175
|
-
|
|
16199
|
+
const [canonicalFilename] = host.config.memoryFilenames(origin);
|
|
16200
|
+
sources.set(canonicalFilename, origin.title);
|
|
16176
16201
|
}
|
|
16177
16202
|
return {
|
|
16178
16203
|
names: [...sources.values()].sort((left, right) => left.localeCompare(right, undefined, { sensitivity: "base" }))
|
|
@@ -16672,7 +16697,7 @@ function err(text2) {
|
|
|
16672
16697
|
function errorMessage(error) {
|
|
16673
16698
|
return error instanceof Error ? error.message : String(error);
|
|
16674
16699
|
}
|
|
16675
|
-
function
|
|
16700
|
+
function escapeRegExp2(value) {
|
|
16676
16701
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
16677
16702
|
}
|
|
16678
16703
|
function agentAliases(agent) {
|
|
@@ -16702,7 +16727,7 @@ function hasExplicitAgentSwitchRequest(prompt, agent) {
|
|
|
16702
16727
|
if (!prompt?.trim())
|
|
16703
16728
|
return false;
|
|
16704
16729
|
const text2 = prompt.toLowerCase().replace(/\s+/g, " ").trim();
|
|
16705
|
-
const target = `(?:${agentAliases(agent).map(
|
|
16730
|
+
const target = `(?:${agentAliases(agent).map(escapeRegExp2).join("|")})`;
|
|
16706
16731
|
const switchVerb = "(?:\uBC14\uAFD4|\uBC14\uAFD4\uC918|\uBCC0\uACBD|\uBCC0\uACBD\uD574|\uC804\uD658|\uC804\uD658\uD574|\uC124\uC815|\uC124\uC815\uD574|\uC368\uC918|\uC0AC\uC6A9|\uAC00|switch|change|set|use)";
|
|
16707
16732
|
const switchSubject = "(?:agent|runtime|model|\uC5D0\uC774\uC804\uD2B8|\uB7F0\uD0C0\uC784|\uBAA8\uB378)";
|
|
16708
16733
|
return [
|
|
@@ -17348,4 +17373,4 @@ export {
|
|
|
17348
17373
|
DEFAULT_SELF_CONFIG_PRODUCT
|
|
17349
17374
|
};
|
|
17350
17375
|
|
|
17351
|
-
//# debugId=
|
|
17376
|
+
//# debugId=03CC17DBBCA47F1E64756E2164756E21
|