Skip to content

refactor(hooks): move the hooks.json command-hook engine into tinyagents-runtime - #6795

Merged
senamakel merged 12 commits into
tinyhumansai:mainfrom
senamakel:vendor-extract-w2-hooks
Sep 30, 2026
Merged

senamakel merged 12 commits into
tinyhumansai:mainfrom
senamakel:vendor-extract-w2-hooks

Conversation

@senamakel

Copy link
Copy Markdown
Member

Summary

Wave 2: move the Cursor-compatible hooks.json command-hook engine into tinyagents-runtime. The net change is −2.5k lines (78 added, 2,584 deleted).

Stacked on #6789 (→ #6786 → #6785 → #6781). The base is main because upstream branch creation is restricted.

Hooks engine → tinyagents_runtime::command_hooks (tinyagents#237, against main)

  • What moved: hooks/{types,config,matcher,engine,exec,context,followup}.rs and their tests. The new code sits beside the existing SessionHooks trait, which is untouched.
  • The seam is a HookEnvironment passed to HookEngine::new. It carries four things:
    • product: "OpenHuman", which derives the system dir (ProgramData\OpenHuman, /Library/Application Support/OpenHuman, /etc/openhuman), the .openhuman user and project dirs, and the OPENHUMAN_* hook env vars;
    • home_dir;
    • the shell builder platform_shell::build_tokio_command, which stays in OpenHuman because the sandbox, host runtime and cron shell jobs also use it;
    • an optional prompt evaluator, which wraps OpenHuman's prompt_eval.
  • Fixture tests pin the behaviour:
    • a literal hooks.json parse;
    • the resolved discovery paths for the injected product, including a check that a different product never reads OpenHuman's paths;
    • the hook env var names.
  • Stays in OpenHuman:
    • bridge.rs, which adapts to the agent's ToolHook/PostTurnHook;
    • ops.rs, schemas.rs and prompt_eval.rs;
    • a new host.rs, which builds the process-wide engine through the seam.
  • Visible changes:
    • The moved code logs through tracing instead of log.
    • Before ops::init sets the version at boot, the openhuman_version fallback is now empty instead of the core crate version. After boot it is the same as before.

Not moved: running_subagents

  • The mechanics already live upstream: DetachedTaskRegistry, TaskStoreRegistry and the JSONL store.
  • What remains is host glue tied to OpenHuman types:
    • RunQueue<QueuedTurn> metadata;
    • background_completions;
    • subagent_sessions writes;
    • subagent_events;
    • the .openhuman/orchestration_tasks.jsonl layout;
    • the host SubagentStatus enum.
  • Moving it would redesign the orchestration subagent lifecycle, which is more than a seam.

Verification

  • cargo check --tests -p openhuman -p openhuman-cli --features "$(bash scripts/ci/product-features.sh)" passes. The app manifest, openhuman-embed and openhuman-tinyhumans --tests also compile.
  • Full lib suite with the product features: 10330 passed, 1 failed. The failure is memory::sync_activity::a_run_with_no_terminal_stage_goes_stale_after_the_ceiling. It is the same global-map timing race as its sibling described in refactor(core): move time/goals tools, conversation store and composio execute into vendor crates #6785, and it passes when run alone (11/11).
  • tinyagents-runtime: 106 tests, including the moved hooks tests and 3 new fixtures. fmt and clippy -D warnings are clean.
  • These pass: rust:layout, check-agent-runtime-boundary (no re-exports; call sites import tinyagents_runtime::command_hooks directly), check-feature-forwarding, check-gated-test-allowlist, and check-submodule-monotonic upstream/main HEAD (9 pins forward).
  • check-module-pins fails only for tinywallet and tinychannels, both from test: drop 45 quarantined raw-coverage files, dedupe vendor-covered tests, repoint vendor pins #6781.

Merge order

tinyagents#237 is based on main and doesn't depend on the other open tinyagents PRs. Merge it, then re-pin the gitlink to the merge commit, then merge this PR after #6789.

senamakel and others added 9 commits September 30, 2026 09:52
Updated the pinned commit for the tinyagents vendored dependency to incorporate upstream changes.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Update the pinned commit of the tinyagents vendored dependency to incorporate upstream changes.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Update the pinned commit of the tinyagents submodule to include the latest changes from its upstream repository.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
The tinyagents submodule pointer has been advanced to include the latest upstream changes. The new commit hash reflects a dirty state, indicating local modifications were present at the time of the update.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Update the pinned commit of the tinyagents vendored dependency to incorporate upstream changes.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Split the monolithic hooks module into dedicated files for configuration, context, engine, execution, follow-up, matcher, and types, each with their own tests. This improves maintainability by giving each concern a clear home and makes the codebase easier to navigate.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
The hook engine, types, config, matcher, exec, context, and follow-up modules have been extracted into the `tinyagents_runtime::command_hooks` crate. OpenHuman now re-exports only the bridge, host, ops, prompt_eval, and schemas modules, delegating all engine internals to the shared library. This reduces duplication between projects and makes the hook contract a single source of truth.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
The doc comment in the hooks schema module referenced an internal path that no longer exists after a refactor. The path is updated to point to the correct public module in the runtime crate, ensuring the documentation remains accurate and navigable for readers.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
Added regex and serde dependencies to the Cargo.lock file to reflect changes in the project's dependency tree, ensuring the lock file remains consistent with the current crate requirements.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: f8d35063-f31f-4df5-a78f-f5a12633097c

📥 Commits

Reviewing files that changed from the base of the PR and between ee49cef and 6b850c2.

⛔ Files ignored due to path filters (1)
  • crates/openhuman-app/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (19)
  • crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
  • crates/openhuman-core/src/config/schema/hooks.rs
  • crates/openhuman-core/src/hooks/bridge.rs
  • crates/openhuman-core/src/hooks/config.rs
  • crates/openhuman-core/src/hooks/context.rs
  • crates/openhuman-core/src/hooks/engine.rs
  • crates/openhuman-core/src/hooks/exec.rs
  • crates/openhuman-core/src/hooks/exec_tests.rs
  • crates/openhuman-core/src/hooks/followup.rs
  • crates/openhuman-core/src/hooks/followup_tests.rs
  • crates/openhuman-core/src/hooks/hooks_tests.rs
  • crates/openhuman-core/src/hooks/host.rs
  • crates/openhuman-core/src/hooks/matcher.rs
  • crates/openhuman-core/src/hooks/matcher_tests.rs
  • crates/openhuman-core/src/hooks/mod.rs
  • crates/openhuman-core/src/hooks/ops.rs
  • crates/openhuman-core/src/hooks/schemas.rs
  • crates/openhuman-core/src/hooks/types.rs
  • crates/openhuman-core/src/web_chat/ops/start_chat.rs
 ______________________________________________
< Your code is my code, your bugs are my bugs. >
 ----------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).

Comment @coderabbitai help to get the list of available commands.

@tinysweeper

tinysweeper Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Tiny Sweeper review

⚠️ Review failed for 9689569b0e1d. pull request exceeds review limits: 319 changed files (limit 500), 66412 changed lines (limit 50000)

senamakel and others added 2 commits September 30, 2026 11:12
The lockfile is updated to reflect the addition of three new workspace crates: tinycomputer-accessibility, tinyflows-schedule, and tinyruntime-pyserver. Several previously direct dependencies (chrono-tz, cpal, cron) are now pulled in transitively through these new crates rather than listed as direct dependencies of the root package.

Auto-committed-on: dragonfly
Co-authored-by: Medulla <medulla@tinyhumans.ai>
@senamakel
senamakel merged commit 21a8664 into tinyhumansai:main Sep 30, 2026
25 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant