Whether *file_path* is a write inside the auto-memory directory. Mirrors the TS write-tool carve-out at ``filesystem.ts``: writes to paths matched by ``isAutoMemPath()`` are allowed without further permission gating, *but only when ``hasAutoMemPathOverride()`` is false*. The overrid
(file_path: str)
| 118 | # --------------------------------------------------------------------------- |
| 119 | |
| 120 | def _is_auto_memory_write(file_path: str) -> bool: |
| 121 | """Whether *file_path* is a write inside the auto-memory directory. |
| 122 | |
| 123 | Mirrors the TS write-tool carve-out at ``filesystem.ts``: writes to |
| 124 | paths matched by ``isAutoMemPath()`` are allowed without further |
| 125 | permission gating, *but only when ``hasAutoMemPathOverride()`` is |
| 126 | false*. The override case means the SDK caller has wired memory |
| 127 | themselves and has its own permission story (TS comment at |
| 128 | ``paths.ts:262-272``). |
| 129 | |
| 130 | Note: TS does **not** gate this on ``isAutoMemoryEnabled()`` — the |
| 131 | carve-out is purely path-shape, not behavior-flag. We mirror that: |
| 132 | if a process has memory writes pending and then auto-memory gets |
| 133 | disabled mid-session, the in-flight writes still resolve. |
| 134 | """ |
| 135 | try: |
| 136 | from src.memdir import ( |
| 137 | has_auto_mem_path_override, |
| 138 | is_auto_mem_path, |
| 139 | ) |
| 140 | except Exception: |
| 141 | return False |
| 142 | if has_auto_mem_path_override(): |
| 143 | return False |
| 144 | try: |
| 145 | return is_auto_mem_path(_expand_path(file_path)) |
| 146 | except Exception: |
| 147 | return False |
| 148 | |
| 149 | |
| 150 | def _check_permissions(tool_input: dict[str, Any], context: ToolContext) -> PermissionResult: |