Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(relay): skip a UTF-8 byte-order mark in an enqueue input file
AkitaOnRails4e7f3404c0be
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ded8a44c..abf56411 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -223,12 +223,6 @@ version in [`docs/changelog/`](docs/changelog/):relay and wiki sync companions take the same `rustls-webpki` bump.### Fixed-- The `/hook` ingress now strips a leading UTF-8 byte-order mark, as the native- client already did. Some PowerShell pipelines add that marker when writing to- a native process, and both hook bundles forward it, so the event was answered- with 400 and lost — the hooks are fire-and-forget, so nothing surfaced.- ([#1523](https://github.com/akitaonrails/ai-memory/pull/1523))-- Reserved local-embedding capacity for interactive search queries instead ofallowing concurrent page writes and backfill work to occupy every inferenceslot. Excess queries fall back immediately to non-vector retrieval, and a@@ -243,6 +237,13 @@ version in [`docs/changelog/`](docs/changelog/):with no profile digest, brief or inbox notice at all. The refusal now costsonly the claim, and the handoff stays open.+- The `/hook` ingress now skips a leading UTF-8 byte-order mark, as the native+ hook client already did. Some PowerShell pipelines add that marker when+ writing to a native process, and the POSIX shell hook bundle forwards the+ payload byte for byte, so such an event was answered with 400 and lost+ without notice. `ai-memory-relay enqueue --file` skips the marker too.+ ([#1523](https://github.com/akitaonrails/ai-memory/pull/1523))+- `mcp-bridge` and the `setup` self-check no longer send requests to theserver through `HTTP_PROXY`, `HTTPS_PROXY` or `ALL_PROXY`, as the hooksalready did. A sandbox such as ai-jail exports a proxy with an emptydiff --git a/companions/ai-memory-relay/README.md b/companions/ai-memory-relay/README.mdindex cb0a6280..7dcad0f5 100644--- a/companions/ai-memory-relay/README.md+++ b/companions/ai-memory-relay/README.md@@ -79,7 +79,8 @@ ai-memory-relay flush --queue-dir "$HOME/.ai-memory-relay"ai-memory-relay status --queue-dir "$HOME/.ai-memory-relay"```-`enqueue` validates the whole array and commits it in one transaction. Each body+`enqueue` validates the whole array and commits it in one transaction. A leading+UTF-8 byte-order mark in the file is skipped. Each bodymust be an object with explicit `session_id` and `cwd` strings. Use the harness'snative identity and canonical hook event names. Sensitive identities are refusedwithout renaming them. Shared private capture helpers scrub new body text anddiff --git a/companions/ai-memory-relay/src/relay.rs b/companions/ai-memory-relay/src/relay.rsindex ea02fed9..5e22db4a 100644--- a/companions/ai-memory-relay/src/relay.rs+++ b/companions/ai-memory-relay/src/relay.rs@@ -167,7 +167,11 @@ fn read_input(file: &Path, binding: &Binding) -> Result<Vec<ValidEvent>> {file.display());}- let input: Vec<InputEvent> = serde_json::from_slice(&raw).map_err(|e| {+ // A Windows producer can write the file as UTF-8 with a byte-order mark+ // (Windows PowerShell's `-Encoding UTF8`); the server's `/hook` ingress and+ // the native hook client skip it too.+ let json = raw.strip_prefix(b"\xEF\xBB\xBF").unwrap_or(&raw);+ let input: Vec<InputEvent> = serde_json::from_slice(json).map_err(|e| {// Category plus position only. `Display` on a serde error can quote the// offending value ("invalid type: string \"...\""), and an event body is// exactly the thing that must not reach a terminal or a log.diff --git a/companions/ai-memory-relay/tests/relay.rs b/companions/ai-memory-relay/tests/relay.rsindex ddff93e9..30058013 100644--- a/companions/ai-memory-relay/tests/relay.rs+++ b/companions/ai-memory-relay/tests/relay.rs@@ -406,6 +406,26 @@ fn a_reopened_queue_recognizes_an_acknowledged_event() {assert_eq!(server.bodies().len(), 1, "and must not be re-sent");}+#[test]+fn an_input_file_with_a_utf8_byte_order_mark_is_enqueued() {+ let root = fixture("bom-input");+ let dir = bind(&root, "http://127.0.0.1:9");+ let path = root.join("in.json");+ let mut bytes = b"\xEF\xBB\xBF".to_vec();+ bytes.extend(+ serde_json::to_vec(&serde_json::json!([event(+ "e-bom",+ "claude-code",+ "session-start",+ "s-1"+ )]))+ .unwrap(),+ );+ std::fs::write(&path, bytes).unwrap();+ relay::enqueue(&dir, &path).unwrap();+ assert_eq!(pending_count(&dir), 1);+}+#[test]fn an_unauthenticated_rejection_keeps_everything_pending() {let root = fixture("auth-rejected");