Skip to content

Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors

Rust

Merge PR #1416: support Antigravity native session capture

AkitaOnRailsbd9ef79887b0
diff --cc CHANGELOG.md
index f46476d2,e32a7765..4a673e9d
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -103,80 -103,36 +103,108 @@@ version in [`docs/changelog/`](docs/cha
recently updated; the store applies that cap before loading nodes or their
selected edges into the process. Expired pages stay hidden. An edge still
requires both ends to be readable.
+ - Added Antigravity hook parity with Claude Code and Codex for the `agy` CLI,
+ the desktop App and the IDE. `install-hooks --agent antigravity-cli` now
+ wires the native `SessionStart`, which injects the handoff as an
+ `injectSteps` system message that stays in the conversation, where the
+ ephemeral message it replaces was dropped after the first turn.
+ `PreInvocation` gets its own `pre-invocation` handler: on builds without
+ `SessionStart`, the first turn's call stands in for it, once per
+ conversation. The native hook now reads each turn's prompts from the
+ conversation's own transcript (`transcriptPath`, only under
+ `~/.gemini/<app>/brain/<conversationId>/`, no symlinks out of it, 8 MiB per
+ hook) and records them as user prompts, so summaries and handoffs carry
+ them. A `Stop` that finished the turn (`NO_TOOL_CALL` or `model_stop`) with
+ `fullyIdle: true` writes a turn checkpoint, the path OpenCode 2 uses: the
+ summary page and one handoff are refreshed and the conversation stays open,
+ so `finalize-session` is no longer needed for normal use. It remains the
+ explicit close, hands the baton over without the 10-minute quiet period,
+ queues opt-in consolidation, and skips its `history.jsonl` prompt replay
+ for a conversation whose prompts were already captured. Rerun
+ `install-hooks --agent antigravity-cli --apply` to add `SessionStart`;
+ existing native-hook installs get the prompts and checkpoints without it.
+ A turn checkpoint never ends a conversation, even a turn with no captured
+ prompt or tool call, so a handoff it claimed at start is never offered
+ again; the conversation start is claimed atomically, so a concurrent
+ `SessionStart` and first `PreInvocation` cannot both claim a handoff;
+ prompt ingest keys include the prompt's time and text, so a rewind that
+ reuses step numbers keeps its new prompts; and the transcript is opened
+ with `O_NOFOLLOW | O_NONBLOCK` and, on Linux, checked against the opened
+ descriptor's real path. (#1416)
### Fixed
+- Added exact hover timestamps to `/web` page metadata, made the OKF upgrade
+ dialog keyboard accessible, and added a labelled main-navigation landmark
+ with current-page state and narrow-screen wrapping.
+ ([#1391](https://github.com/akitaonrails/ai-memory/pull/1391),
+ [#1392](https://github.com/akitaonrails/ai-memory/pull/1392),
+ [#1393](https://github.com/akitaonrails/ai-memory/pull/1393))
+- Made guarded admin routes treat an omitted `confirm` as `false`, returning
+ the documented 400 response without performing the operation.
+ ([#1394](https://github.com/akitaonrails/ai-memory/pull/1394))
+- Retried OpenAI-style embedding requests on HTTP 503 as well as 429, honored
+ bounded whole-second `Retry-After` values, and made `ai-memory embed` fail
+ after printing a report that contains failed pages.
+ ([#1397](https://github.com/akitaonrails/ai-memory/pull/1397))
+- Made pending-write diffs return an internal error when the existing page
+ cannot be read instead of presenting an update as a new page.
+ ([#1399](https://github.com/akitaonrails/ai-memory/pull/1399))
+- Refused page-path components over 255 UTF-8 bytes and additional Windows DOS
+ device spellings, while keeping existing non-portable pages readable.
+ ([#1400](https://github.com/akitaonrails/ai-memory/pull/1400),
+ [#1407](https://github.com/akitaonrails/ai-memory/pull/1407))
+- Recognized frontmatter whose closing fence is at end of file, ignored H1-like
+ comments inside fenced code when deriving titles, and gave empty exported
+ wikilink labels their target as visible text.
+ ([#1402](https://github.com/akitaonrails/ai-memory/pull/1402),
+ [#1403](https://github.com/akitaonrails/ai-memory/pull/1403),
+ [#1419](https://github.com/akitaonrails/ai-memory/pull/1419))
+- Preserved FTS5 prefix operators and `title:` / `body:` filters on punctuated
+ terms, and stripped managed-workstream column prefixes only at word starts.
+ ([#1404](https://github.com/akitaonrails/ai-memory/pull/1404),
+ [#1405](https://github.com/akitaonrails/ai-memory/pull/1405),
+ [#1406](https://github.com/akitaonrails/ai-memory/pull/1406))
+- Stripped reasoning that ends in a bare closing tag from OpenAI-compatible
+ structured responses and found Cursor Agent JSON inside bracketed prose.
+ ([#1408](https://github.com/akitaonrails/ai-memory/pull/1408),
+ [#1409](https://github.com/akitaonrails/ai-memory/pull/1409))
+- Matched automatic-handoff acknowledgments as whole phrases, treated Windows
+ drive roots as broad session anchors, preserved Antigravity output around
+ invalid UTF-8 bytes, and stopped repeating the last prompt in automatic
+ handoffs.
+ ([#1410](https://github.com/akitaonrails/ai-memory/pull/1410),
+ [#1411](https://github.com/akitaonrails/ai-memory/pull/1411),
+ [#1412](https://github.com/akitaonrails/ai-memory/pull/1412),
+ [#1418](https://github.com/akitaonrails/ai-memory/pull/1418))
+- Returned `invalid params` for malformed handoff and message ids and accepted
+ surrounding whitespace consistently on handoff cancellation.
+ ([#1413](https://github.com/akitaonrails/ai-memory/pull/1413))
+- Fixed A2 compaction summaries when a heading directly precedes the first
+ paragraph or the page uses CRLF line endings.
+ ([#1414](https://github.com/akitaonrails/ai-memory/pull/1414))
+- Excluded TTL-expired pages from cross-project degree metrics, memory-health
+ counts and details, and project/workspace page-count and timestamp summaries.
+ ([#1422](https://github.com/akitaonrails/ai-memory/pull/1422),
+ [#1423](https://github.com/akitaonrails/ai-memory/pull/1423),
+ [#1426](https://github.com/akitaonrails/ai-memory/pull/1426))
+- Stopped LLM provider and embedder requests from following a redirect to
+ another origin. reqwest drops `Authorization` on a cross-host hop but keeps
+ every other header, so `x-api-key`, `x-goog-api-key` and operator headers
+ from `llm_headers` reached whatever host a configured endpoint redirected
+ to. Redirects inside the same origin still work; one that changes scheme,
+ host or port now fails the request and names the origin it pointed at.
+ ([#1396](https://github.com/akitaonrails/ai-memory/pull/1396))
+- Required Write access before a session start records a project's `[profile]`
+ `profile_contribute` / `profile_consume` flags. A Read-only viewer's explicit
+ values now only narrow its own session instead of changing the flags for every
+ operator in the project.
+ ([#1421](https://github.com/akitaonrails/ai-memory/pull/1421))
+- Stopped the server from opening files named in a hook payload. Antigravity
+ step-log enrichment now runs only in the client-side `ai-memory hook`; the
+ `/hook` and `/hook/batch` ingest paths store the `tool_response` the client
+ sent and never read `artifactDirectoryPath` or `transcriptPath` locations
+ on the server's own disk.
+ ([#1420](https://github.com/akitaonrails/ai-memory/pull/1420))
- Fixed `memory_lint` reporting findings for TTL-expired pages. The lint pass
now omits expired pages before evaluating episodic staleness, rule suggestions,
duplicate titles, and vector or LLM contradiction candidates, preventing
diff --cc docs/security-boundaries.md
index e9dcb67b,a661148b..e2887956
--- a/docs/security-boundaries.md
+++ b/docs/security-boundaries.md
@@@ -137,7 -136,7 +137,8 @@@ means the boundary is not built yet
| 26 | Cross-harness native-history continuation stays checkout-scoped and client-local | `ai-memory-store/src/workstream.rs` `prepare_run` selects the newest current native session only when its harness differs from the destination and pins that typed identity on the run before destination linking can change recency; `ai-memory-cli/src/commands/run.rs` validates the returned `NativeSessionIdentity`, resolves only known adapter flavors, requires `native_session_in_checkout`, exports through the bounded read-only adapter, and writes an untrusted-history dossier to a private temporary directory exposed only to the child as `AI_MEMORY_PREVIOUS_SESSION_HISTORY`; the server wire type deliberately has no path/content field and same-harness launches select no source; `ai-memory-hooks/src/router.rs` keeps the server-authored resume directive outside the untrusted-history fence while fencing the transcript evidence itself, and `ai-memory-core/src/routing_snippet.rs` gives installed project instructions the same wrapper-variable-gated fallback | Core `prepare_response_carries_only_previous_native_identity`, `older_prepare_response_defaults_to_no_adoption`, and `snippets_route_managed_continue_to_the_previous_native_history`; store `managed_adoption_stops_after_any_harness_links_the_workstream` (switch control, destination-link recency cannot replace the pinned source, same-harness refusal); hooks `managed_context_points_at_local_history_on_a_harness_switch` (no session id rendered, directive precedes the untrusted fence); CLI `previous_session_history_is_private_local_and_checkout_scoped` (legitimate control, foreign checkout refused, private local file removed with its owner) | STRONG for checkout isolation, prompt-boundary placement, and server path/content privacy. The dossier is a bounded visible-history projection, not raw hidden reasoning; if the source store is absent, remote, unreadable, or over bounds, the child receives only the portable ledger and handoff |
| 27 | Plain-HTTP human authentication stays fail-closed beyond loopback unless the operator supplies the dedicated dangerous override (#1383) | `ai-memory-cli/src/cli.rs` exposes `serve --allow-insecure-human-auth` separately from `--allow-insecure-no-auth`; `serve.rs` `validate_http_exposure` accepts it only when authentication and human mode are both active and the listener is non-loopback with a Non-Secure cookie, while the ordinary unauthenticated guard still runs otherwise. `HttpExposure::InsecureHumanAuthByOverride` gives that path its own unconditional stderr banner and structured warning, naming passwords, API credentials, session cookies, and memory data as plaintext. The default remains refusal, and `secure_cookie=true` or loopback remains the safe path | `serve.rs` `human_auth_non_loopback_requires_secure_cookie_posture` (default refusal, the no-auth override cannot substitute, the dedicated override succeeds, and that override cannot expose a server with no authentication even under inconsistent human-mode input; secure-cookie and loopback controls), `every_unsafe_exposure_produces_an_operator_banner` (the dedicated banner names the flag and session-cookie risk), and `cli.rs` `serve_parses_insecure_transport_overrides` (both dangerous flags remain distinct) | STRONG for the startup boundary. This is an explicit operator acceptance of transport risk, not encryption; authorization, CSRF, rate limits, Host validation, and the unauthenticated exposure refusal are unchanged |
+| 27a | Provider credentials stay on the configured origin | `ai-memory-llm/src/redirect.rs` `same_origin_redirects`, set on every provider and embedder client (`anthropic.rs`, `codex.rs`, `copilot.rs`, `embedding.rs`, `gemini.rs`, `google.rs`, `openai.rs`, `openai_oauth.rs`, `opencode.rs`): a redirect is followed only when scheme, host and port match the previous request, with reqwest's ten-hop limit; any other redirect fails the request. reqwest's own guard strips only `Authorization`, cookies and the proxy headers, so `x-api-key`, `x-goog-api-key` and `llm_headers` values depend on this one. The local model download (`local.rs`) carries no credential and keeps the default policy for its CDN redirects; OIDC and CLI login requests refuse every redirect on clients of their own (`oidc.rs`, `auth.rs` `auth_http_client`) | `ai-memory-llm` `tests/suite/redirect_credentials.rs` `gemini_api_key_does_not_follow_a_cross_origin_redirect`, `anthropic_api_key_does_not_follow_a_cross_origin_redirect`, `operator_headers_do_not_follow_a_cross_origin_redirect` (with `Authorization` stripped as the control), `google_embedder_key_does_not_follow_a_cross_origin_redirect`, `a_refused_redirect_says_where_it_pointed`; legitimate control `a_same_origin_redirect_still_reaches_the_provider` (the key follows a path redirect on one origin); each cross-origin test fails with the policy removed | STRONG for the provider and embedder clients in `ai-memory-llm` |
+ | 28 | An Antigravity hook reads, and uploads as prompts, only the named conversation's own transcript, within bounds | `ai-memory-hooks/src/antigravity.rs` `antigravity_transcript_path` accepts the payload's `transcriptPath` only when it is absolute, has no `..`, names `transcript.jsonl` or `transcript_full.jsonl`, and its canonical directory equals `canonical(<home>/.gemini/<app>/brain)/<conversationId>/.system_generated/logs` for `<app>` `antigravity`, `antigravity-cli` or `antigravity-ide`, with `conversationId` a plain id (`antigravity_conversation_id`); `read_transcript_prompts` opens only a regular, non-symlink file that is still the same file once open (`open_regular_file`, opened with `O_NOFOLLOW | O_NONBLOCK` so a symlink or FIFO swapped in after the check is refused without blocking, and on Linux only when the opened descriptor's `/proc/self/fd` path is the checked one, so a directory swapped for a symlink after the containment check is refused too), reads at most `MAX_TRANSCRIPT_SCAN_BYTES` per hook and parses lines up to `MAX_TRANSCRIPT_LINE_BYTES`, and returns only `USER_INPUT` steps whose `source` is absent or `USER_EXPLICIT`; `ai-memory-cli/src/commands/hook.rs` `antigravity_transcript_prompt_events` runs inside the spool block, so after the capture allowlist, routing, server-profile and external-capture gates, with the home `run_with_payload` resolved once; each prompt is capped and scrubbed client-side, keyed by conversation and step, and sanitized again by the server (row 7) | `antigravity.rs` `transcript_path_refuses_anything_outside_the_conversations_own_logs` (another conversation's transcript, the same layout outside the home, another file in the logs directory, an unknown app directory, `..`, a traversal or empty id, a relative path, a missing or non-string path; the conversation's own transcript is the control), `transcript_path_refuses_symlinked_directories_that_leave_the_conversation` (a symlinked `.system_generated` and `brain/<id>` refused; a symlinked `~/.gemini` accepted as the control), `transcript_reader_refuses_symlinks_and_special_files` (a symlinked transcript and a directory refused; the same bytes as a regular file are read), `skips_injected_malformed_empty_and_non_prompt_steps`, `a_line_longer_than_the_scan_budget_is_skipped_across_reads`, `one_read_returns_a_bounded_number_of_prompts`; `hook.rs` `antigravity_transcript_reads_are_confined_to_the_conversations_own_logs` (end to end through the native hook: a forged path outside the home, another conversation's transcript and an arbitrary JSONL file under the home spool no prompt; the conversation's own transcript spools one), `antigravity_transcript_prompts_follow_the_capture_allowlist` (a repository the allowlist leaves out is not read) | STRONG on Unix; the symlink cases are `cfg(unix)`, and elsewhere the canonical-directory check still runs; `antigravity.rs` `transcript_reader_refuses_fifos_and_swapped_directories` |
### IBM Bob evidence