@openclaw/tokenjuice 2026.9.3 → 2026.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/activity.svg +3 -0
- package/assets/icon.png +0 -0
- package/node_modules/tokenjuice/README.md +6 -1
- package/node_modules/tokenjuice/dist/cli/install-output.d.ts +7 -0
- package/node_modules/tokenjuice/dist/cli/install-output.js +19 -0
- package/node_modules/tokenjuice/dist/cli/main.d.ts +4 -0
- package/node_modules/tokenjuice/dist/cli/main.js +143 -26
- package/node_modules/tokenjuice/dist/core/artifacts.d.ts +1 -0
- package/node_modules/tokenjuice/dist/core/artifacts.js +29 -0
- package/node_modules/tokenjuice/dist/core/compaction-metadata.d.ts +1 -1
- package/node_modules/tokenjuice/dist/core/integrations/compact-bash-result.d.ts +1 -0
- package/node_modules/tokenjuice/dist/core/integrations/compact-bash-result.js +1 -1
- package/node_modules/tokenjuice/dist/core/reduce.js +18 -10
- package/node_modules/tokenjuice/dist/core/text.d.ts +4 -0
- package/node_modules/tokenjuice/dist/core/text.js +32 -0
- package/node_modules/tokenjuice/dist/hosts/codex/index.d.ts +25 -1
- package/node_modules/tokenjuice/dist/hosts/codex/index.js +211 -163
- package/node_modules/tokenjuice/dist/hosts/grok-bot/index.d.ts +25 -0
- package/node_modules/tokenjuice/dist/hosts/grok-bot/index.js +644 -0
- package/node_modules/tokenjuice/dist/hosts/opencode/extension/runtime.js +79 -10
- package/node_modules/tokenjuice/dist/hosts/pi/extension/runtime.js +79 -10
- package/node_modules/tokenjuice/dist/hosts/shared/hook-command-doctor.d.ts +24 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hook-command-doctor.js +80 -1
- package/node_modules/tokenjuice/dist/hosts/shared/hook-command.d.ts +19 -0
- package/node_modules/tokenjuice/dist/hosts/shared/hook-command.js +61 -6
- package/node_modules/tokenjuice/dist/hosts/shared/hook-doctor.d.ts +3 -1
- package/node_modules/tokenjuice/dist/hosts/shared/hook-doctor.js +2 -0
- package/node_modules/tokenjuice/dist/hosts/shared/host-command.d.ts +10 -1
- package/node_modules/tokenjuice/dist/hosts/shared/host-command.js +43 -4
- package/node_modules/tokenjuice/dist/hosts/shared/pre-tool-wrap.js +9 -7
- package/node_modules/tokenjuice/dist/index.d.ts +2 -0
- package/node_modules/tokenjuice/dist/index.js +1 -0
- package/node_modules/tokenjuice/package.json +1 -1
- package/openclaw.plugin.json +1 -0
- package/package.json +8 -6
|
@@ -54,6 +54,7 @@ import { doctorGitLabDuoRule } from "../gitlab-duo/index.js";
|
|
|
54
54
|
import { doctorGooseHints } from "../goose/index.js";
|
|
55
55
|
import { doctorGreptileRule } from "../greptile/index.js";
|
|
56
56
|
import { doctorGrokBuildInstructions } from "../grok-build/index.js";
|
|
57
|
+
import { doctorGrokBotRule } from "../grok-bot/index.js";
|
|
57
58
|
import { doctorGrokCliHook } from "../grok-cli/index.js";
|
|
58
59
|
import { doctorGptmeInstructions } from "../gptme/index.js";
|
|
59
60
|
import { doctorJean2Instructions } from "../jean2/index.js";
|
|
@@ -152,6 +153,7 @@ const hookDoctorIntegrationDoctors = {
|
|
|
152
153
|
goose: (options) => doctorGooseHints(undefined, { ...getHookCommandOptions(options), scanProjectTree: false }),
|
|
153
154
|
greptile: (options) => doctorGreptileRule(undefined, getHookCommandOptions(options)),
|
|
154
155
|
"grok-build": (options) => doctorGrokBuildInstructions(undefined, getHookCommandOptions(options)),
|
|
156
|
+
"grok-bot": (options) => doctorGrokBotRule(undefined, getHookCommandOptions(options)),
|
|
155
157
|
"grok-cli": (options) => doctorGrokCliHook(undefined, getHookCommandOptions(options)),
|
|
156
158
|
gptme: (options) => doctorGptmeInstructions(undefined, getHookCommandOptions(options)),
|
|
157
159
|
jean2: (options) => doctorJean2Instructions(undefined, getHookCommandOptions(options)),
|
|
@@ -2,9 +2,18 @@ export type TokenjuiceHookCommandOptions = {
|
|
|
2
2
|
local?: boolean;
|
|
3
3
|
binaryPath?: string;
|
|
4
4
|
nodePath?: string;
|
|
5
|
+
pinNodeForJavaScriptLauncher?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export type ParsedTokenjuiceHookCommand = {
|
|
8
|
+
argv: string[];
|
|
9
|
+
checkedPaths: string[];
|
|
10
|
+
runtimePath?: string;
|
|
11
|
+
launcherPath?: string;
|
|
12
|
+
subcommand?: string;
|
|
5
13
|
};
|
|
6
14
|
export declare function isExecutableFile(path: string): Promise<boolean>;
|
|
7
15
|
export declare function pathExists(path: string): Promise<boolean>;
|
|
8
16
|
export declare function resolveInstalledTokenjuicePath(): Promise<string | undefined>;
|
|
9
17
|
export declare function buildTokenjuiceHookCommand(subcommand: string, hostLabel: string, options?: TokenjuiceHookCommandOptions): Promise<string>;
|
|
10
|
-
export declare function
|
|
18
|
+
export declare function parseTokenjuiceHookCommand(command: string, platform?: NodeJS.Platform): ParsedTokenjuiceHookCommand;
|
|
19
|
+
export declare function findMissingHookCommandPaths(command: string, platform?: NodeJS.Platform): Promise<string[]>;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { constants as fsConstants } from "node:fs";
|
|
2
|
-
import { access } from "node:fs/promises";
|
|
2
|
+
import { access, realpath, stat } from "node:fs/promises";
|
|
3
3
|
import { delimiter, isAbsolute, join, resolve } from "node:path";
|
|
4
|
-
import { extractHookCommandPaths, shellQuote } from "./hook-command.js";
|
|
4
|
+
import { extractHookCommandPaths, isNodeExecutablePath, isTokenjuiceExecutablePath, parseShellWords, shellQuote, } from "./hook-command.js";
|
|
5
5
|
export async function isExecutableFile(path) {
|
|
6
6
|
try {
|
|
7
|
+
if (!(await stat(path)).isFile()) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
7
10
|
await access(path, fsConstants.X_OK);
|
|
8
11
|
return true;
|
|
9
12
|
}
|
|
@@ -53,13 +56,49 @@ export async function buildTokenjuiceHookCommand(subcommand, hostLabel, options
|
|
|
53
56
|
const installedBinaryPath = await resolveInstalledTokenjuicePath();
|
|
54
57
|
launcher = installedBinaryPath ?? binaryPath;
|
|
55
58
|
}
|
|
59
|
+
if (!options.local && options.pinNodeForJavaScriptLauncher) {
|
|
60
|
+
try {
|
|
61
|
+
if ((await realpath(launcher)).endsWith(".js")) {
|
|
62
|
+
return `${shellQuote(nodePath)} ${shellQuote(launcher)} ${subcommand}`;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
// Preserve package-manager launchers when their final target cannot be inspected.
|
|
67
|
+
}
|
|
68
|
+
}
|
|
56
69
|
if (launcher.endsWith(".js")) {
|
|
57
70
|
return `${shellQuote(nodePath)} ${shellQuote(launcher)} ${subcommand}`;
|
|
58
71
|
}
|
|
59
72
|
return `${shellQuote(launcher)} ${subcommand}`;
|
|
60
73
|
}
|
|
61
|
-
export
|
|
62
|
-
const
|
|
74
|
+
export function parseTokenjuiceHookCommand(command, platform = process.platform) {
|
|
75
|
+
const argv = parseShellWords(command, platform);
|
|
76
|
+
const first = argv[0];
|
|
77
|
+
const second = argv[1];
|
|
78
|
+
if (first && isNodeExecutablePath(first) && second) {
|
|
79
|
+
return {
|
|
80
|
+
argv,
|
|
81
|
+
checkedPaths: extractHookCommandPaths(command, platform),
|
|
82
|
+
runtimePath: first,
|
|
83
|
+
launcherPath: second,
|
|
84
|
+
...(argv[2] ? { subcommand: argv[2] } : {}),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
if (first && isTokenjuiceExecutablePath(first)) {
|
|
88
|
+
return {
|
|
89
|
+
argv,
|
|
90
|
+
checkedPaths: extractHookCommandPaths(command, platform),
|
|
91
|
+
launcherPath: first,
|
|
92
|
+
...(second ? { subcommand: second } : {}),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
argv,
|
|
97
|
+
checkedPaths: extractHookCommandPaths(command, platform),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export async function findMissingHookCommandPaths(command, platform = process.platform) {
|
|
101
|
+
const paths = extractHookCommandPaths(command, platform);
|
|
63
102
|
const missing = [];
|
|
64
103
|
for (const path of paths) {
|
|
65
104
|
if (!(await pathExists(path))) {
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
import { constants as fsConstants } from "node:fs";
|
|
16
16
|
import { access } from "node:fs/promises";
|
|
17
17
|
import { delimiter, isAbsolute, join, resolve } from "node:path";
|
|
18
|
-
import { stripLeadingCdPrefix
|
|
19
|
-
import { isNodeExecutablePath, isTokenjuiceExecutablePath, shellQuote } from "./hook-command.js";
|
|
18
|
+
import { stripLeadingCdPrefix } from "../../core/command.js";
|
|
19
|
+
import { isNodeExecutablePath, isTokenjuiceExecutablePath, parseShellWords, posixShellQuote, shellQuote, } from "./hook-command.js";
|
|
20
20
|
export function isRecord(value) {
|
|
21
21
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22
22
|
}
|
|
@@ -148,10 +148,10 @@ export async function buildWrapLauncherHookCommand(options) {
|
|
|
148
148
|
export function buildWrappedCommand(params) {
|
|
149
149
|
const nodePath = params.nodePath ?? process.execPath;
|
|
150
150
|
const launcherCommand = params.wrapLauncher.endsWith(".js")
|
|
151
|
-
? `${
|
|
152
|
-
:
|
|
153
|
-
const sourceArgs = params.source ? ` --source ${
|
|
154
|
-
return `${launcherCommand} wrap${sourceArgs} -- ${
|
|
151
|
+
? `${posixShellQuote(nodePath)} ${posixShellQuote(params.wrapLauncher)}`
|
|
152
|
+
: posixShellQuote(params.wrapLauncher);
|
|
153
|
+
const sourceArgs = params.source ? ` --source ${posixShellQuote(params.source)}` : "";
|
|
154
|
+
return `${launcherCommand} wrap${sourceArgs} -- ${posixShellQuote(params.shellPath)} -lc ${posixShellQuote(params.command)}`;
|
|
155
155
|
}
|
|
156
156
|
/**
|
|
157
157
|
* Detect whether a command has already been wrapped by tokenjuice. Matches
|
|
@@ -166,7 +166,9 @@ export function buildWrappedCommand(params) {
|
|
|
166
166
|
* (e.g. the user invoked `tokenjuice wrap --raw -- <cmd>` explicitly).
|
|
167
167
|
*/
|
|
168
168
|
export function commandAlreadyWrapped(command) {
|
|
169
|
-
|
|
169
|
+
// PreToolUse hosts execute this command through a POSIX shell, including
|
|
170
|
+
// Bash-compatible shells on Windows.
|
|
171
|
+
const argv = parseShellWords(stripLeadingCdPrefix(command), "linux");
|
|
170
172
|
if (argv.length < 2) {
|
|
171
173
|
return false;
|
|
172
174
|
}
|
|
@@ -59,6 +59,7 @@ export { doctorGitLabDuoRule, installGitLabDuoRule, uninstallGitLabDuoRule } fro
|
|
|
59
59
|
export { doctorGooseHints, installGooseHints, uninstallGooseHints } from "./hosts/goose/index.js";
|
|
60
60
|
export { doctorGreptileRule, installGreptileRule, uninstallGreptileRule } from "./hosts/greptile/index.js";
|
|
61
61
|
export { doctorGrokBuildInstructions, installGrokBuildInstructions, uninstallGrokBuildInstructions } from "./hosts/grok-build/index.js";
|
|
62
|
+
export { doctorGrokBotRule, installGrokBotRule, uninstallGrokBotRule } from "./hosts/grok-bot/index.js";
|
|
62
63
|
export { doctorGrokCliHook, installGrokCliHook, runGrokCliPostToolUseHook, uninstallGrokCliHook } from "./hosts/grok-cli/index.js";
|
|
63
64
|
export { doctorGptmeInstructions, installGptmeInstructions, uninstallGptmeInstructions } from "./hosts/gptme/index.js";
|
|
64
65
|
export { doctorJean2Instructions, installJean2Instructions, uninstallJean2Instructions } from "./hosts/jean2/index.js";
|
|
@@ -167,6 +168,7 @@ export type { GitLabDuoDoctorReport, GitLabDuoRuleOptions, InstallGitLabDuoRuleR
|
|
|
167
168
|
export type { GreptileDoctorReport, GreptileRuleOptions, InstallGreptileRuleResult, UninstallGreptileRuleResult, } from "./hosts/greptile/index.js";
|
|
168
169
|
export type { GooseDoctorReport, GooseHintsOptions, InstallGooseHintsResult, UninstallGooseHintsResult, } from "./hosts/goose/index.js";
|
|
169
170
|
export type { GrokBuildDoctorReport, GrokBuildInstructionsOptions, InstallGrokBuildInstructionsResult, UninstallGrokBuildInstructionsResult, } from "./hosts/grok-build/index.js";
|
|
171
|
+
export type { GrokBotDoctorReport, GrokBotRuleOptions, InstallGrokBotRuleResult, UninstallGrokBotRuleResult, } from "./hosts/grok-bot/index.js";
|
|
170
172
|
export type { GrokCliDoctorReport, GrokCliHookCommandOptions, InstallGrokCliHookResult, UninstallGrokCliHookResult, } from "./hosts/grok-cli/index.js";
|
|
171
173
|
export type { GptmeDoctorReport, GptmeInstructionsOptions, InstallGptmeInstructionsResult, UninstallGptmeInstructionsResult, } from "./hosts/gptme/index.js";
|
|
172
174
|
export type { InstallJean2InstructionsResult, Jean2DoctorReport, Jean2InstructionsOptions, UninstallJean2InstructionsResult, } from "./hosts/jean2/index.js";
|
|
@@ -58,6 +58,7 @@ export { doctorGitLabDuoRule, installGitLabDuoRule, uninstallGitLabDuoRule } fro
|
|
|
58
58
|
export { doctorGooseHints, installGooseHints, uninstallGooseHints } from "./hosts/goose/index.js";
|
|
59
59
|
export { doctorGreptileRule, installGreptileRule, uninstallGreptileRule } from "./hosts/greptile/index.js";
|
|
60
60
|
export { doctorGrokBuildInstructions, installGrokBuildInstructions, uninstallGrokBuildInstructions } from "./hosts/grok-build/index.js";
|
|
61
|
+
export { doctorGrokBotRule, installGrokBotRule, uninstallGrokBotRule } from "./hosts/grok-bot/index.js";
|
|
61
62
|
export { doctorGrokCliHook, installGrokCliHook, runGrokCliPostToolUseHook, uninstallGrokCliHook } from "./hosts/grok-cli/index.js";
|
|
62
63
|
export { doctorGptmeInstructions, installGptmeInstructions, uninstallGptmeInstructions } from "./hosts/gptme/index.js";
|
|
63
64
|
export { doctorJean2Instructions, installJean2Instructions, uninstallJean2Instructions } from "./hosts/jean2/index.js";
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/tokenjuice",
|
|
3
|
-
"version": "2026.9.
|
|
3
|
+
"version": "2026.9.5",
|
|
4
4
|
"description": "OpenClaw tokenjuice exec output compaction plugin",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"tokenjuice": "0.8.
|
|
11
|
+
"tokenjuice": "0.8.3"
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"openclaw": ">=2026.9.
|
|
14
|
+
"openclaw": ">=2026.9.5"
|
|
15
15
|
},
|
|
16
16
|
"peerDependenciesMeta": {
|
|
17
17
|
"openclaw": {
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"minHostVersion": ">=2026.5.28"
|
|
30
30
|
},
|
|
31
31
|
"compat": {
|
|
32
|
-
"pluginApi": ">=2026.9.
|
|
32
|
+
"pluginApi": ">=2026.9.5"
|
|
33
33
|
},
|
|
34
34
|
"build": {
|
|
35
|
-
"openclawVersion": "2026.9.
|
|
35
|
+
"openclawVersion": "2026.9.5",
|
|
36
36
|
"bundledDist": false
|
|
37
37
|
},
|
|
38
38
|
"release": {
|
|
@@ -46,7 +46,9 @@
|
|
|
46
46
|
"files": [
|
|
47
47
|
"dist/**",
|
|
48
48
|
"openclaw.plugin.json",
|
|
49
|
-
"README.md"
|
|
49
|
+
"README.md",
|
|
50
|
+
"assets/icon.png",
|
|
51
|
+
"assets/activity.svg"
|
|
50
52
|
],
|
|
51
53
|
"bundledDependencies": [
|
|
52
54
|
"tokenjuice"
|