Skip to content

fix(openclaw): launch hooks through the installed Node entry - #1307

Merged
SaulMoro merged 1 commit into
Tencent:mainfrom
nateEc:fix/1221-openclaw-hook-launch
Oct 23, 2026
Merged

SaulMoro merged 1 commit into
Tencent:mainfrom
nateEc:fix/1221-openclaw-hook-launch

Conversation

@nateEc

@nateEc nateEc commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

OpenClaw gateways with a restricted service PATH never start TeamAI's generated hook; native Node spawn also cannot execute a Windows npm .cmd shim. Generate the handler with the installing Node executable and CLI entry, then pass the dispatch arguments directly to Node. Workspace/session mapping and nonblocking error handling are preserved.

Type of Change

  • Bug fix

Test Plan

  • Focused regression evidence failed before the fix and passed afterward.
  • 77 tests across openclaw-hooks.test.ts and hooks-cmd.test.ts.
  • npm run build, npx tsc --noEmit, npm run lint, and git diff --check passed.
  • Real CLI after build, commit 1eedff6:
npx vitest run --config vitest.e2e.config.ts src/__tests__/e2e/openclaw-hook-launch.test.ts
1 passed: the built CLI injects the hook into a fixture OpenClaw workspace; its generated TypeScript handler is loaded and dispatches session-start with PATH empty. The isolated HOME debug log proves the real CLI received session-start/openclaw.

Related Issues

Related to #1221, one specific item in "Other findings". This PR does not close the umbrella issue or include its descriptor/resolver redesign.

Notes for Reviewers

Uses existing resolveCliEntry(); adds no shell or dependency. Generated absolute paths are refreshed by the existing injection/reconcile path. macOS execution verified; a native Windows gateway and a live OpenClaw runtime were not available locally. Windows behavior is covered structurally by spawning Node directly with windowsHide.

Integration verification: all five independent fixes cherry-picked cleanly onto origin/main in a local-only checkout; combined build, typecheck and lint passed, with 174 unit tests and 7 real-CLI cases across 6 E2E files. The Windows test-list guard and moved POSIX command regression also pass together (25 tests).

- Record the installing Node executable and TeamAI CLI entry in generated handlers so gateway services do not depend on a shell PATH.
- Spawn Node with separate script and dispatch arguments, avoiding Windows npm .cmd execution while preserving workspace and session payloads.
- Keep dispatch nonblocking, hide Windows child consoles, and report a missing CLI entry before writing a partial installation.
- Verify 77 focused tests, build, typecheck and lint, plus a real-CLI injection and dispatch with an empty service PATH. Related to Tencent#1221.
@github-actions

Copy link
Copy Markdown

No findings confidently supported by the current PR diff.

  • The description documents sufficient testing: a post-build real-CLI run at 1eedff6 verifies injection and dispatch with an empty PATH. Unavailable native Windows/live OpenClaw coverage is explicitly disclosed and is not blocking.
  • The checkout is shallow, so triple-dot comparison failed. Commit metadata confirms both endpoints share parent 97f1e7b; I reviewed that parent-to-head diff, excluding unrelated base changes.
  • No PR code was run, built, or installed.

@SaulMoro SaulMoro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was generated by AI during triage.

@nateEc Thanks, approving. This closes the #1221 item "OpenClaw: the hook runs spawn('teamai') without a shell".

We ran teamai hooks inject with the built CLI on this head and on its base 97f1e7b4. Then we called the rendered OpenClaw handler with an empty PATH:

  • Base: the handler renders spawn('teamai', …), never reaches the CLI, and debug.log has no hook-dispatch line.
  • This PR: the handler spawns the pinned Node binary with the CLI entry, and debug.log shows [hook-dispatch] session-start/openclaw.

The new e2e and the new unit case fail on the base and pass here. tsc, lint and the unit tests pass.

Not blocking:

  • [P2 non-blocking] With the Node path rewritten to one that no longer exists, the handler exits 0 and logs nothing. After a Node upgrade, hooks would stop until the handler is rendered again. ~/.teamai/bin/teamai pins paths the same way, but init and pull rewrite it. Worth checking that the OpenClaw handler is refreshed on the same path.
  • [P3 nit] The e2e checks windowsHide by reading the rendered source. It does not run anything on Windows.

Outside this PR: src/opencode-hooks.ts:119 also spawns a bare teamai.

@SaulMoro
SaulMoro merged commit 562a438 into Tencent:main Oct 23, 2026
18 checks passed
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
…#1307)

- Record the installing Node executable and TeamAI CLI entry in generated handlers so gateway services do not depend on a shell PATH.
- Spawn Node with separate script and dispatch arguments, avoiding Windows npm .cmd execution while preserving workspace and session payloads.
- Keep dispatch nonblocking, hide Windows child consoles, and report a missing CLI entry before writing a partial installation.
- Verify 77 focused tests, build, typecheck and lint, plus a real-CLI injection and dispatch with an empty service PATH. Related to Tencent#1221.
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.

3 participants