Repository navigation
feat(tokenjuice): bundle the native adapter - #69946
Conversation
🔒 Aisle Security AnalysisWe found 1 potential security issue(s) in this PR:
1. 🟠 Arbitrary code execution via untrusted npm_execpath in runtime deps installer
Description
Key points:
Vulnerable code: const rawNpmExecPath = ... ? env.npm_execpath : undefined;
const npmExecPath = rawNpmExecPath && isNpmCliPath(rawNpmExecPath) ? rawNpmExecPath : undefined;
...
const npmCliPath = npmCliCandidates.find((candidate) => pathImpl.isAbsolute(candidate) && existsSync(candidate));
if (npmCliPath) {
return { command: execPath, args: [npmCliPath, ...params.npmArgs] };
}RecommendationDo not trust Recommended fixes (pick one):
const npmCliCandidates = [
pathImpl.resolve(nodeDir, "../lib/node_modules/npm/bin/npm-cli.js"),
pathImpl.resolve(nodeDir, "node_modules/npm/bin/npm-cli.js"),
];
import fs from "node:fs";
const real = fs.realpathSync(rawNpmExecPath);
const realNodeDir = fs.realpathSync(nodeDir);
if (!real.startsWith(realNodeDir + pathImpl.sep)) throw new Error("Untrusted npm_execpath");Additionally, consider sanitizing the installer env:
Analyzed PR: #69946 at commit Last updated on: 2026-04-22T07:06:17Z |
Greptile SummaryThis PR adds a public Confidence Score: 5/5Safe to merge; implementation is consistent with existing plugin registry patterns and all cache paths are covered. All findings are P2: one style suggestion about awaiting the factory call in the test (harmless since the current factory is synchronous), and a minor temp-directory cleanup omission. No logic errors, no data integrity issues, and no security concerns beyond what the existing plugin trust model already handles. src/agents/pi-embedded-runner.extensions.test.ts — minor test hygiene (void factory call and missing tmpdir cleanup). Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/agents/pi-embedded-runner.extensions.test.ts
Line: 98-103
Comment:
**Unawaited async factory call may cause flaky assertions**
The factory result is discarded with `void`, so if any future `ExtensionFactory` is async (returns a `Promise<void>` instead of `void`), `handlers.set` won't be called before the `expect` on line 103. The test would silently pass with an empty `handlers` map since the factory type allows async. Awaiting the call makes the test robust now and safe for async factories later.
```suggestion
await cachedFactories[0]?.({
on(event: string, handler: Function) {
handlers.set(event, handler);
},
} as never);
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/agents/pi-embedded-runner.extensions.test.ts
Line: 48
Comment:
**Temp directory not cleaned up after test**
`fs.mkdtempSync` creates a directory in the OS temp folder that is never removed. Other plugin seam tests in this codebase typically call `fs.rmSync(tmp, { recursive: true, force: true })` inside `afterEach`. This isn't a correctness issue, but it accumulates test artifacts on developer machines.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "feat(plugins): register embedded extensi..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c11473c734
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0d477d7385
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2a6c8b4350
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 601e8ef865
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
601e8ef to
8d181fe
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f0e903dd9c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d5a72de4d6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| .toSorted((left, right) => left.localeCompare(right)); | ||
| const missingSpecs = deps | ||
| .filter((dep) => !hasDependencySentinel(dependencySearchRoots, dep)) | ||
| .filter((dep) => !hasDependencySentinel([installRoot], dep)) |
There was a problem hiding this comment.
Avoid npm installs inside source-checkout plugin roots
Restricting the missing-dependency check to installRoot here means source-checkout plugins now fall through to npm install in the plugin directory whenever <plugin>/node_modules is absent. For extensions/tokenjuice (and other workspace packages), that nested npm install fails with EUNSUPPORTEDPROTOCOL because the manifest contains workspace:* dev dependencies, so enabling the plugin can fail before it registers. This needs a source-checkout-safe install target (or a source-checkout bypass) instead of invoking npm in the workspace package root.
Useful? React with 👍 / 👎.
* feat(plugins): register embedded extension factories * feat(tokenjuice): bundle the native adapter * fix(tokenjuice): gate the bundled embedded extension seam * fix(tokenjuice): refresh runtime sidecar baseline * fix(plugins): harden bundled embedded extensions * fix(plugins): install source bundled runtime deps * fix(tokenjuice): sync lockfile importer * fix(plugins): validate reused runtime dep versions * fix(plugins): restore tokenjuice CI contract * fix(plugins): remove tokenjuice dts bridge * fix(tokenjuice): repair openclaw type shim * fix(plugins): harden bundled runtime deps * fix(plugins): keep source checkout runtime deps local * fix(plugins): isolate bundled runtime dep installs * fix(cli): keep plugin startup registration non-activating * fix(cli): keep loader overrides out of plugin cli options
* feat(plugins): register embedded extension factories * feat(tokenjuice): bundle the native adapter * fix(tokenjuice): gate the bundled embedded extension seam * fix(tokenjuice): refresh runtime sidecar baseline * fix(plugins): harden bundled embedded extensions * fix(plugins): install source bundled runtime deps * fix(tokenjuice): sync lockfile importer * fix(plugins): validate reused runtime dep versions * fix(plugins): restore tokenjuice CI contract * fix(plugins): remove tokenjuice dts bridge * fix(tokenjuice): repair openclaw type shim * fix(plugins): harden bundled runtime deps * fix(plugins): keep source checkout runtime deps local * fix(plugins): isolate bundled runtime dep installs * fix(cli): keep plugin startup registration non-activating * fix(cli): keep loader overrides out of plugin cli options
* feat(plugins): register embedded extension factories * feat(tokenjuice): bundle the native adapter * fix(tokenjuice): gate the bundled embedded extension seam * fix(tokenjuice): refresh runtime sidecar baseline * fix(plugins): harden bundled embedded extensions * fix(plugins): install source bundled runtime deps * fix(tokenjuice): sync lockfile importer * fix(plugins): validate reused runtime dep versions * fix(plugins): restore tokenjuice CI contract * fix(plugins): remove tokenjuice dts bridge * fix(tokenjuice): repair openclaw type shim * fix(plugins): harden bundled runtime deps * fix(plugins): keep source checkout runtime deps local * fix(plugins): isolate bundled runtime dep installs * fix(cli): keep plugin startup registration non-activating * fix(cli): keep loader overrides out of plugin cli options
* feat(plugins): register embedded extension factories * feat(tokenjuice): bundle the native adapter * fix(tokenjuice): gate the bundled embedded extension seam * fix(tokenjuice): refresh runtime sidecar baseline * fix(plugins): harden bundled embedded extensions * fix(plugins): install source bundled runtime deps * fix(tokenjuice): sync lockfile importer * fix(plugins): validate reused runtime dep versions * fix(plugins): restore tokenjuice CI contract * fix(plugins): remove tokenjuice dts bridge * fix(tokenjuice): repair openclaw type shim * fix(plugins): harden bundled runtime deps * fix(plugins): keep source checkout runtime deps local * fix(plugins): isolate bundled runtime dep installs * fix(cli): keep plugin startup registration non-activating * fix(cli): keep loader overrides out of plugin cli options
* feat(plugins): register embedded extension factories * feat(tokenjuice): bundle the native adapter * fix(tokenjuice): gate the bundled embedded extension seam * fix(tokenjuice): refresh runtime sidecar baseline * fix(plugins): harden bundled embedded extensions * fix(plugins): install source bundled runtime deps * fix(tokenjuice): sync lockfile importer * fix(plugins): validate reused runtime dep versions * fix(plugins): restore tokenjuice CI contract * fix(plugins): remove tokenjuice dts bridge * fix(tokenjuice): repair openclaw type shim * fix(plugins): harden bundled runtime deps * fix(plugins): keep source checkout runtime deps local * fix(plugins): isolate bundled runtime dep installs * fix(cli): keep plugin startup registration non-activating * fix(cli): keep loader overrides out of plugin cli options
* feat(plugins): register embedded extension factories * feat(tokenjuice): bundle the native adapter * fix(tokenjuice): gate the bundled embedded extension seam * fix(tokenjuice): refresh runtime sidecar baseline * fix(plugins): harden bundled embedded extensions * fix(plugins): install source bundled runtime deps * fix(tokenjuice): sync lockfile importer * fix(plugins): validate reused runtime dep versions * fix(plugins): restore tokenjuice CI contract * fix(plugins): remove tokenjuice dts bridge * fix(tokenjuice): repair openclaw type shim * fix(plugins): harden bundled runtime deps * fix(plugins): keep source checkout runtime deps local * fix(plugins): isolate bundled runtime dep installs * fix(cli): keep plugin startup registration non-activating * fix(cli): keep loader overrides out of plugin cli options
* feat(plugins): register embedded extension factories * feat(tokenjuice): bundle the native adapter * fix(tokenjuice): gate the bundled embedded extension seam * fix(tokenjuice): refresh runtime sidecar baseline * fix(plugins): harden bundled embedded extensions * fix(plugins): install source bundled runtime deps * fix(tokenjuice): sync lockfile importer * fix(plugins): validate reused runtime dep versions * fix(plugins): restore tokenjuice CI contract * fix(plugins): remove tokenjuice dts bridge * fix(tokenjuice): repair openclaw type shim * fix(plugins): harden bundled runtime deps * fix(plugins): keep source checkout runtime deps local * fix(plugins): isolate bundled runtime dep installs * fix(cli): keep plugin startup registration non-activating * fix(cli): keep loader overrides out of plugin cli options
* feat(plugins): register embedded extension factories * feat(tokenjuice): bundle the native adapter * fix(tokenjuice): gate the bundled embedded extension seam * fix(tokenjuice): refresh runtime sidecar baseline * fix(plugins): harden bundled embedded extensions * fix(plugins): install source bundled runtime deps * fix(tokenjuice): sync lockfile importer * fix(plugins): validate reused runtime dep versions * fix(plugins): restore tokenjuice CI contract * fix(plugins): remove tokenjuice dts bridge * fix(tokenjuice): repair openclaw type shim * fix(plugins): harden bundled runtime deps * fix(plugins): keep source checkout runtime deps local * fix(plugins): isolate bundled runtime dep installs * fix(cli): keep plugin startup registration non-activating * fix(cli): keep loader overrides out of plugin cli options
* feat(plugins): register embedded extension factories * feat(tokenjuice): bundle the native adapter * fix(tokenjuice): gate the bundled embedded extension seam * fix(tokenjuice): refresh runtime sidecar baseline * fix(plugins): harden bundled embedded extensions * fix(plugins): install source bundled runtime deps * fix(tokenjuice): sync lockfile importer * fix(plugins): validate reused runtime dep versions * fix(plugins): restore tokenjuice CI contract * fix(plugins): remove tokenjuice dts bridge * fix(tokenjuice): repair openclaw type shim * fix(plugins): harden bundled runtime deps * fix(plugins): keep source checkout runtime deps local * fix(plugins): isolate bundled runtime dep installs * fix(cli): keep plugin startup registration non-activating * fix(cli): keep loader overrides out of plugin cli options
Summary
Describe the problem and fix in 2–5 bullets:
registerEmbeddedExtensionFactory(...)seam, added a bundledextensions/tokenjuiceplugin that importstokenjuice/openclawthrough a local runtime boundary, and added labeler/lockfile/test coverage for that bundled plugin.tool_result_persistfallback.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
For bug fixes or regressions, explain why this happened, not just what changed. Otherwise write
N/A. If the cause is unclear, writeUnknown.Regression Test Plan (if applicable)
For bug fixes or regressions, name the smallest reliable test coverage that should catch this. Otherwise write
N/A.src/agents/pi-embedded-runner.extensions.test.ts,extensions/tokenjuice/index.test.ts,extensions/tokenjuice/manifest.test.tsUser-visible / Behavior Changes
List user-visible changes (including defaults/config).
If none, write
None.tokenjuiceplugin that can be enabled instead of installed as a separate plugin package.Diagram (if applicable)
For UI changes or non-trivial logic flows, include a small ASCII diagram reviewers can scan quickly. Otherwise write
N/A.Security Impact (required)
Yes/No): YesYes/No): NoYes/No): NoYes/No): YesYes/No): NoYes, explain risk + mitigation:Repro + Verification
Environment
openai/gpt-5.4plugins.entries.tokenjuice.enabled=trueSteps
tokenjuice/openclawexport exists indist.extensions/tokenjuice/node_modules/tokenjuiceso the bundled plugin resolves the new export through a normal package import path.tokenjuiceplugin, build embedded extension factories, and invoke thetool_resulthandler with agit statusexec result.Expected
Actual
git statusoutput plus tokenjuice metadata.Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
pnpm test:serial extensions/tokenjuice/index.test.ts extensions/tokenjuice/manifest.test.ts src/agents/pi-embedded-runner.extensions.test.ts; real bundled-plugin smoke throughloadOpenClawPlugins(...)+buildEmbeddedExtensionFactories(...)using the tokenjuice worktree through a normal package import path.tool_resultoutput.pnpm check:changedstill fails on unrelated existing typecheck issues insrc/docs/clawhub-plugin-docs.test.ts,src/gateway/reconnect-gating.test.ts,src/i18n/registry.test.ts,src/ui-app-settings.agents-files-refresh.test.ts,extensions/qa-lab/web/src/main.ts, andextensions/qqbot/src/bridge/setup/finalize.ts.Review Conversations
If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.
Compatibility / Migration
Yes/No): YesYes/No): NoYes/No): NoRisks and Mitigations
List only real risks for this PR. Add/remove entries as needed. If none, write
None.[email protected]does not exposetokenjuice/openclawyet.tokenjuice@^0.6.0, so once the tokenjuice release from feat(openclaw): export the embedded adapter vincentkoc/tokenjuice#25 lands, bundled runtime dependency staging can resolve the new export without another architecture change.AI Assistance