fix: resolve LINE formatDocsLink circular dep and Cortex review items
This commit is contained in:
parent
94c9004022
commit
346909a2c7
@ -4,7 +4,6 @@
|
||||
export * from "../../src/plugin-sdk/line.js";
|
||||
export { resolveExactLineGroupConfigKey } from "../../src/plugin-sdk/line-core.js";
|
||||
export {
|
||||
formatDocsLink,
|
||||
setSetupChannelEnabled,
|
||||
splitSetupEntries,
|
||||
type ChannelSetupDmPolicy,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { createAllowFromSection, createTopLevelChannelDmPolicy } from "openclaw/plugin-sdk/setup";
|
||||
import { formatDocsLink } from "openclaw/plugin-sdk/setup-tools";
|
||||
import {
|
||||
DEFAULT_ACCOUNT_ID,
|
||||
formatDocsLink,
|
||||
resolveLineAccount,
|
||||
setSetupChannelEnabled,
|
||||
splitSetupEntries,
|
||||
|
||||
@ -324,7 +324,9 @@ function buildAgentCortexConversationKey(params: {
|
||||
sessionId?: string;
|
||||
channelId?: string;
|
||||
}): string {
|
||||
return [params.agentId, params.sessionId ?? "", params.channelId ?? ""].join(":");
|
||||
// Use NUL as separator to avoid collisions when IDs contain colons
|
||||
// (e.g. "session:test" vs separate "session" + "test" tokens).
|
||||
return [params.agentId, params.sessionId ?? "", params.channelId ?? ""].join("\0");
|
||||
}
|
||||
|
||||
export function getAgentCortexMemoryCaptureStatus(params: {
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
import { resolveDefaultAgentId } from "../../agents/agent-scope.js";
|
||||
import { getLatestCortexCaptureHistoryEntry } from "../../agents/cortex-history.js";
|
||||
import {
|
||||
getCachedLatestCortexCaptureHistoryEntry,
|
||||
getLatestCortexCaptureHistoryEntry,
|
||||
} from "../../agents/cortex-history.js";
|
||||
import { resolveAgentCortexModeStatus, resolveCortexChannelTarget } from "../../agents/cortex.js";
|
||||
import { getHealthSnapshot, type HealthSummary } from "../../commands/health.js";
|
||||
import { STATE_DIR, createConfigIO, loadConfig } from "../../config/config.js";
|
||||
@ -41,12 +44,17 @@ export async function buildGatewaySnapshot(): Promise<Snapshot> {
|
||||
sessionId: mainSessionEntry?.sessionId,
|
||||
channelId,
|
||||
});
|
||||
// Prefer the in-memory cache to avoid reading the full JSONL during
|
||||
// WebSocket connect handshakes. Fall back to async read only when
|
||||
// the cache is cold (first snapshot after restart).
|
||||
const cortexHistoryParams = {
|
||||
agentId: defaultAgentId,
|
||||
sessionId: mainSessionEntry?.sessionId,
|
||||
channelId,
|
||||
};
|
||||
const latestCortexCapture = cortex
|
||||
? await getLatestCortexCaptureHistoryEntry({
|
||||
agentId: defaultAgentId,
|
||||
sessionId: mainSessionEntry?.sessionId,
|
||||
channelId,
|
||||
}).catch(() => null)
|
||||
? (getCachedLatestCortexCaptureHistoryEntry(cortexHistoryParams) ??
|
||||
(await getLatestCortexCaptureHistoryEntry(cortexHistoryParams).catch(() => null)))
|
||||
: null;
|
||||
const scope = cfg.session?.scope ?? "per-sender";
|
||||
const presence = listSystemPresence();
|
||||
|
||||
@ -19,7 +19,8 @@ type CortexModeOverrideStore = {
|
||||
};
|
||||
|
||||
function buildKey(agentId: string, targetId: string): string {
|
||||
return `${agentId}:${targetId}`;
|
||||
// Use NUL separator to avoid collisions when IDs contain colons.
|
||||
return `${agentId}\0${targetId}`;
|
||||
}
|
||||
|
||||
export function resolveCortexModeOverridesPath(env: NodeJS.ProcessEnv = process.env): string {
|
||||
|
||||
@ -405,13 +405,23 @@ export async function ingestCortexMemoryFromText(params: {
|
||||
if (!text) {
|
||||
throw new Error("Cortex memory ingest requires non-empty text");
|
||||
}
|
||||
const status = requireCortexStatus(
|
||||
await resolveCortexStatus({
|
||||
const status = await resolveCortexStatus({
|
||||
workspaceDir: params.workspaceDir,
|
||||
graphPath: params.graphPath,
|
||||
status: params.status,
|
||||
});
|
||||
if (!status.available) {
|
||||
throw new Error("Cortex CLI unavailable: " + (status.error ?? "unknown error"));
|
||||
}
|
||||
// Allow ingesting even if the graph does not exist yet - cortex extract
|
||||
// creates the output file when -o is provided, and ensureCortexGraphInitialized
|
||||
// seeds the directory below. This fixes first-time ingest failures.
|
||||
if (!status.graphExists) {
|
||||
await ensureCortexGraphInitialized({
|
||||
workspaceDir: params.workspaceDir,
|
||||
graphPath: params.graphPath,
|
||||
status: params.status,
|
||||
}),
|
||||
);
|
||||
});
|
||||
}
|
||||
await fs.mkdir(path.dirname(status.graphPath), { recursive: true });
|
||||
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-cortex-ingest-"));
|
||||
const inputPath = path.join(tmpDir, "memory.txt");
|
||||
|
||||
@ -121,6 +121,10 @@ const SETUP_BARREL_GUARDS: GuardedSource[] = [
|
||||
path: "extensions/whatsapp/src/setup-surface.ts",
|
||||
forbiddenPatterns: [/\bformatCliCommand\b/, /\bformatDocsLink\b/],
|
||||
},
|
||||
{
|
||||
path: "extensions/line/src/setup-surface.ts",
|
||||
forbiddenPatterns: [/\bformatDocsLink\b/],
|
||||
},
|
||||
];
|
||||
|
||||
const LOCAL_EXTENSION_API_BARREL_GUARDS = [
|
||||
|
||||
@ -3,7 +3,6 @@ export type { LineConfig } from "../line/types.js";
|
||||
export {
|
||||
createTopLevelChannelDmPolicy,
|
||||
DEFAULT_ACCOUNT_ID,
|
||||
formatDocsLink,
|
||||
setSetupChannelEnabled,
|
||||
setTopLevelChannelDmPolicyWithAllowFrom,
|
||||
splitSetupEntries,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user