pynydus.common.connector_utils

Shared utilities for source spawners and target hatchers.

Helpers for paragraph splitting, MCP config discovery, skill filenames, and lightweight parsing used by OpenClaw, ZeroClaw, and Letta connectors.

Module Contents

Functions

split_paragraphs

Split text into non-empty paragraphs.

parse_mcp_configs_from_files

Parse MCP server configurations from a virtual file tree.

skill_to_filename

Turn a skill display name into a safe .py module filename.

parse_timestamp

Parse a timestamp from common string or numeric forms.

extract_date_from_filename

Extract a YYYY-MM-DD date from a filename like memory/2026-03-15.md.

date_key_from_record

Extract a YYYY-MM-DD date key from a state record.

join_records

Join memory records into a single file’s content.

Data

API

pynydus.common.connector_utils.split_paragraphs(text: str) list[str]

Split text into non-empty paragraphs.

Paragraphs are separated by one or more blank lines.

Args: text: Full document text.

Returns: Non-empty paragraph strings in order.

pynydus.common.connector_utils.parse_mcp_configs_from_files(files: dict[str, str]) dict[str, dict]

Parse MCP server configurations from a virtual file tree.

Loads mcp.json (mapping of server name to config), then applies each mcp/<name>.json file. A per-file entry replaces an existing same-named server from mcp.json.

Args: files: Map of relative path to file body (e.g. from a spawn snapshot).

Returns: Mapping of server name to configuration dict.

pynydus.common.connector_utils.skill_to_filename(name: str) str

Turn a skill display name into a safe .py module filename.

Args: name: Human-readable skill name.

Returns: Filename such as my_skill.py, prefixed with tool_ if the stem would otherwise start with a digit. Falls back to tool.py if empty after normalization.

pynydus.common.connector_utils.parse_timestamp(val: object) datetime.datetime | None

Parse a timestamp from common string or numeric forms.

Args: val: ISO-like string, Unix epoch seconds, or None.

Returns: Aware or naive :class:~datetime.datetime on success. None if val is None or cannot be parsed.

pynydus.common.connector_utils._DATE_RE

‘compile(…)’

pynydus.common.connector_utils.extract_date_from_filename(name: str) datetime.datetime | None

Extract a YYYY-MM-DD date from a filename like memory/2026-03-15.md.

pynydus.common.connector_utils.date_key_from_record(rec: pynydus.api.schemas.MemoryRecord) str | None

Extract a YYYY-MM-DD date key from a state record.

Prefers the record’s timestamp field. Falls back to extracting a date from source_store (e.g. memory/2026-04-01.md).

Args: rec: Memory record with optional timestamp and source store path.

Returns: Date string YYYY-MM-DD, or None if no date could be determined.

pynydus.common.connector_utils.join_records(records: list[pynydus.api.schemas.MemoryRecord]) str

Join memory records into a single file’s content.