mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-20 09:31:54 -06:00
d7627d6f4c
* refactor(prompt): plain inbound context labels with a provenance marker
Replaces trust-worded inbound context labels ("(untrusted metadata)",
"(untrusted, for context)") with plain labels plus a fixed provenance
marker suffix appended to every OpenClaw-injected context header.
Detection keys on the marker, not label text, so strippers stay correct
across UI, TUI, replay, /trace segmentation, memory recall, and the Swift
chat preprocessor. Drops sanitizeInboundSystemTags in favor of the marker
boundary plus trusted system-prompt narration.
Renames the untrusted-named plugin SDK context identifiers to
channel-provenance names, keeping deprecated aliases registered for
removal after 2026-09-08.
Adds `openclaw doctor --fix` migrations that rewrite legacy inbound
labels in stored SQLite transcripts and purge legacy envelope-
contaminated LanceDB recall rows.
* fix(ci): resolve gate failures for plain inbound context labels
- doctor sqlite readers: open read-only connections via openNodeSqliteDatabase
so the Kysely connection-boundary guardrail holds; unexport the now-internal
transcript snapshot type (Knip unused-export gate).
- compat registry: split the record table into registry-records.ts and
plugin-sdk-subpath-records.ts. The new compat record pushed registry.ts past
the 700-line oxlint cap; suppressions are disallowed, so follow the existing
sibling record-module pattern. Public exports and PluginCompatCode literals
unchanged.
- acp-runtime test: assert current finalization behavior (newline normalization
only). The bracket de-fang and System: rewrite it expected were removed with
sanitizeInboundSystemTags; forged system lines are neutralized at the
system-event queue, the single chokepoint feeding the System:-per-line render.
- regenerate docs_map and the plugin SDK API baseline manifest.
* fix(prompt): harden inbound context label migration and drop in-band sanitizer
Review follow-ups on the plain-label + provenance-marker change:
- Remove src/security/system-tags.ts. Rewriting inbound text to neutralize
look-alike `System:`/`[System]` markers corrupted legitimate user text and is
not a real injection boundary; role separation plus external-content wrapping
is. Explicit product decision, recorded at the system-event queue.
- Narrow the LanceDB legacy-row purge so it cannot delete benign memories. It
now requires a complete known legacy sentinel line, a legacy label followed by
a fenced JSON body, or the complete legacy external-content header. The prior
predicates matched ordinary prose such as `Notes (untrusted metadata):`, and
deletion is irreversible.
- Make explicit-empty canonical ChannelStructuredContext win over the deprecated
alias via a present/absent result instead of collapsing `[]` to undefined.
- Keep `\r?` in the active-memory doctor rule. It is the only rule spanning the
header's line break, migrated assistant rows skip newline normalization, and
without it the marked-header replace wins and the body strips to empty. Added
a CRLF regression test.
- Fix stale comments that described removed behavior, and cover the Swift
prose-block strip path.
Claude-Session: https://claude.ai/code/session_01WNzsPddQmxy9Y7jKD4wAxH
86 lines
2.9 KiB
TypeScript
86 lines
2.9 KiB
TypeScript
/**
|
|
* @deprecated Broad public SDK barrel. Prefer focused security/SSRF/secret
|
|
* subpaths and avoid adding new imports here.
|
|
*/
|
|
|
|
import { statRegularFileSync as inspectRegularFileSync } from "../infra/fs-safe.js";
|
|
|
|
/** Return whether a path resolves to a regular file, treating filesystem errors as missing. */
|
|
export function fileExists(filePath: string): boolean {
|
|
try {
|
|
return !inspectRegularFileSync(filePath).missing;
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
export {
|
|
buildChannelMetadata,
|
|
buildUntrustedChannelMetadata,
|
|
} from "../security/channel-metadata.js";
|
|
export {
|
|
evaluateSupplementalContextVisibility,
|
|
filterSupplementalContextItems,
|
|
shouldIncludeSupplementalContext,
|
|
} from "../security/context-visibility.js";
|
|
export type { ContextVisibilityDecision } from "../security/context-visibility.js";
|
|
|
|
export {
|
|
expandAllowFromWithAccessGroups,
|
|
parseAccessGroupAllowFromEntry,
|
|
} from "./access-groups.js";
|
|
export { wrapExternalContent, wrapWebContent } from "../security/external-content.js";
|
|
export { compileSafeRegexDetailed } from "../security/safe-regex.js";
|
|
export type { SafeRegexRejectReason } from "../security/safe-regex.js";
|
|
export {
|
|
appendRegularFile,
|
|
FsSafeError,
|
|
openLocalFileSafely,
|
|
pathExists,
|
|
pathExistsSync,
|
|
readRegularFile,
|
|
resolveLocalPathFromRootsSync,
|
|
readRegularFileSync,
|
|
root,
|
|
statRegularFile,
|
|
statRegularFileSync,
|
|
writeExternalFileWithinRoot,
|
|
withTimeout,
|
|
} from "../infra/fs-safe.js";
|
|
|
|
export { extractErrorCode, formatErrorMessage } from "../infra/errors.js";
|
|
export { hasProxyEnvConfigured } from "../infra/net/proxy-env.js";
|
|
export { normalizeHostname } from "../infra/net/hostname.js";
|
|
export {
|
|
SsrFBlockedError,
|
|
isPrivateNetworkAllowedByPolicy,
|
|
matchesHostnameAllowlist,
|
|
resolvePinnedHostnameWithPolicy,
|
|
} from "../infra/net/ssrf.js";
|
|
export type { LookupFn, SsrFPolicy } from "../infra/net/ssrf.js";
|
|
export { isPathInside } from "../infra/path-guards.js";
|
|
export {
|
|
canonicalPathFromExistingAncestor,
|
|
findExistingAncestor,
|
|
resolveAbsolutePathForRead,
|
|
resolveAbsolutePathForWrite,
|
|
} from "../infra/fs-safe.js";
|
|
export { sanitizeUntrustedFileName } from "../infra/fs-safe-advanced.js";
|
|
export { privateFileStoreSync } from "../infra/private-file-store.js";
|
|
export { movePathWithCopyFallback, replaceFileAtomic } from "../infra/replace-file.js";
|
|
|
|
export { assertNoSymlinkParents, assertNoSymlinkParentsSync } from "../infra/fs-safe-advanced.js";
|
|
export { ensurePortAvailable } from "../infra/ports.js";
|
|
|
|
export {
|
|
resolveExistingPathsWithinRoot,
|
|
pathScope,
|
|
resolveStrictExistingPathsWithinRoot,
|
|
} from "../infra/root-paths.js";
|
|
|
|
export { resolvePreferredOpenClawTmpDir } from "../infra/tmp-openclaw-dir.js";
|
|
export { redactSensitiveText } from "../logging/redact.js";
|
|
export { safeEqualSecret } from "../security/secret-equal.js";
|
|
|
|
export { resolvePinnedMainDmOwnerFromAllowlist } from "../security/dm-policy-shared.js";
|