chore: merge origin/main into mintlify/af82bda4 and resolve conflicts

This commit is contained in:
mintlify[bot]
2026-09-16 11:46:52 +00:00
committed by GitHub
parent b5ae772eae
commit 08d9636491
693 changed files with 55668 additions and 22676 deletions
@@ -0,0 +1,64 @@
#!/usr/bin/env python3
"""Run Codex hooks through the shared Mem0 runtime."""
from __future__ import annotations
import sys
from pathlib import Path
HERE = Path(__file__).resolve()
BUNDLED_CORE = HERE.parent.parent / "core"
CORE = BUNDLED_CORE if BUNDLED_CORE.is_dir() else HERE.parents[2] / "core" / "python"
sys.path.insert(0, str(CORE))
import hook_runner # noqa: E402
import telemetry # noqa: E402
from memory_core import ( # noqa: E402
configure_harness,
record_subagent_start,
record_subagent_stop,
record_tool,
)
configure_harness("codex", data_dir_name="codex-plugin", source_tag="codex_plugin")
telemetry.init(harness="codex", source_tag="CODEX_PLUGIN")
def _subagent_start(store, hook_input):
context = record_subagent_start(store, hook_input)
if context:
return {
"hookSpecificOutput": {
"hookEventName": "SubagentStart",
"additionalContext": context,
}
}
def _subagent_stop(store, hook_input):
record_subagent_stop(store, hook_input)
def _post_tool(store, payload):
response = payload.get("tool_response")
failed = None
if isinstance(response, dict):
exit_code = response.get("exit_code")
if isinstance(exit_code, int) and not isinstance(exit_code, bool):
failed = exit_code != 0
elif isinstance(response.get("isError"), bool):
failed = response["isError"]
elif isinstance(response.get("success"), bool):
failed = not response["success"]
if failed:
payload = {**payload, "error": response}
record_tool(store, payload, failed=failed)
if __name__ == "__main__":
if len(sys.argv) > 1 and sys.argv[1] == "post-tool":
sys.argv[1] = "codex-post-tool"
hook_runner.entry_point(
extra_actions={"subagent-start": _subagent_start, "subagent-stop": _subagent_stop, "codex-post-tool": _post_tool},
automatic_flush_reasons={"session-end", "pre-compact"},
)
@@ -0,0 +1,63 @@
{
"description": "Create memories from coding sessions and recall them in later work.",
"hooks": {
"SessionStart": [
{
"matcher": "startup|resume|clear|compact",
"hooks": [
{ "type": "command", "command": "python3 \"${PLUGIN_ROOT}/hooks/adapter.py\" session-start --plugin-data-dir \"${PLUGIN_DATA}\"", "timeout": 3 }
]
}
],
"UserPromptSubmit": [
{
"hooks": [
{ "type": "command", "command": "python3 \"${PLUGIN_ROOT}/hooks/adapter.py\" user-prompt --plugin-data-dir \"${PLUGIN_DATA}\"", "timeout": 3 }
]
}
],
"PostToolUse": [
{
"matcher": ".*",
"hooks": [
{ "type": "command", "command": "python3 \"${PLUGIN_ROOT}/hooks/adapter.py\" post-tool --plugin-data-dir \"${PLUGIN_DATA}\"", "timeout": 3 }
]
}
],
"SubagentStart": [
{
"hooks": [
{ "type": "command", "command": "python3 \"${PLUGIN_ROOT}/hooks/adapter.py\" subagent-start --plugin-data-dir \"${PLUGIN_DATA}\"", "timeout": 3 }
]
}
],
"SubagentStop": [
{
"hooks": [
{ "type": "command", "command": "python3 \"${PLUGIN_ROOT}/hooks/adapter.py\" subagent-stop --plugin-data-dir \"${PLUGIN_DATA}\"", "timeout": 3 }
]
}
],
"Stop": [
{
"hooks": [
{ "type": "command", "command": "python3 \"${PLUGIN_ROOT}/hooks/adapter.py\" stop --plugin-data-dir \"${PLUGIN_DATA}\"", "timeout": 3 }
]
}
],
"PreCompact": [
{
"hooks": [
{ "type": "command", "command": "python3 \"${PLUGIN_ROOT}/hooks/adapter.py\" flush --reason pre-compact --plugin-data-dir \"${PLUGIN_DATA}\"", "timeout": 3 }
]
}
],
"SessionEnd": [
{
"hooks": [
{ "type": "command", "command": "python3 \"${PLUGIN_ROOT}/hooks/adapter.py\" flush --reason session-end --plugin-data-dir \"${PLUGIN_DATA}\"", "timeout": 3 }
]
}
]
}
}