lakonai 1.2.4 → 1.2.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/README.md +5 -4
- package/package.json +1 -1
- package/src/proxy/state.js +32 -15
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
<img src="https://img.shields.io/badge/node-%E2%89%A518-0F0F0F" alt="node ≥18" />
|
|
21
21
|
<img src="https://img.shields.io/badge/deps-0-0F0F0F" alt="zero dependencies" />
|
|
22
22
|
<img src="https://img.shields.io/badge/agents-6-0F0F0F" alt="6 AI agents" />
|
|
23
|
-
<img src="https://img.shields.io/badge/tests-
|
|
23
|
+
<img src="https://img.shields.io/badge/tests-832-0F0F0F" alt="832 tests" />
|
|
24
24
|
</p>
|
|
25
25
|
|
|
26
26
|
<p align="center">
|
|
@@ -175,8 +175,9 @@ accumulate in `~/.lakon/proxy-stats.json`.
|
|
|
175
175
|
`ANTHROPIC_BASE_URL` directly — it sources `~/.lakon/proxy-env.sh`, which checks
|
|
176
176
|
that the proxy is actually listening before pointing anything at it. Proxy down
|
|
177
177
|
(reboot, crash, `lakonai proxy stop`) means no compression, and Claude talks to
|
|
178
|
-
the API directly as if lakonai were not installed.
|
|
179
|
-
|
|
178
|
+
the API directly as if lakonai were not installed. It also clears a dead lakonai
|
|
179
|
+
URL it finds already in the environment, so a shell that inherited one from an
|
|
180
|
+
older install heals itself. A base URL you set yourself is never touched.
|
|
180
181
|
|
|
181
182
|
Manage it with `lakonai proxy`:
|
|
182
183
|
|
|
@@ -341,7 +342,7 @@ Input is measured and deterministic. Output is estimated by your local AI CLI (n
|
|
|
341
342
|
|
|
342
343
|
## Test suite
|
|
343
344
|
|
|
344
|
-
|
|
345
|
+
832 tests across 54 suites — all passing, no mocks on I/O boundaries.
|
|
345
346
|
|
|
346
347
|
| Type | Suites | Tests |
|
|
347
348
|
|------|--------|-------|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lakonai",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"description": "lakonai — save AI context tokens. Filters & compresses CLI output (git, ls, grep, find, test runners, lint/build, docker/kubectl/aws) before it reaches Claude Code, Codex, Cursor, Windsurf, Cline or Gemini — and learns to filter new commands automatically the more you use it.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude",
|
package/src/proxy/state.js
CHANGED
|
@@ -124,30 +124,47 @@ function envScript(port) {
|
|
|
124
124
|
return `# lakonai proxy — generated by lakonai, safe to delete.
|
|
125
125
|
# Points ANTHROPIC_BASE_URL at the local compression proxy, but only while it is
|
|
126
126
|
# actually listening. Proxy down = plain direct API access, never a broken CLI.
|
|
127
|
+
|
|
128
|
+
# Is something listening on 127.0.0.1:$1? Shell-native where possible.
|
|
129
|
+
__lakon_probe() {
|
|
130
|
+
if [ -n "$ZSH_VERSION" ] && zmodload zsh/net/tcp 2>/dev/null; then
|
|
131
|
+
if ztcp 127.0.0.1 "$1" 2>/dev/null; then ztcp -c "$REPLY" 2>/dev/null; return 0; fi
|
|
132
|
+
return 1
|
|
133
|
+
elif [ -n "$BASH_VERSION" ]; then
|
|
134
|
+
(exec 3<>/dev/tcp/127.0.0.1/"$1") 2>/dev/null && return 0
|
|
135
|
+
return 1
|
|
136
|
+
elif command -v nc >/dev/null 2>&1; then
|
|
137
|
+
nc -z -w 1 127.0.0.1 "$1" >/dev/null 2>&1 && return 0
|
|
138
|
+
return 1
|
|
139
|
+
fi
|
|
140
|
+
return 1
|
|
141
|
+
}
|
|
142
|
+
|
|
127
143
|
__lakon_port=${port}
|
|
128
|
-
__lakon_up=0
|
|
129
144
|
|
|
130
145
|
# Never clobber a base URL the user set for another endpoint — only take over
|
|
131
|
-
# when nothing is set, or when what is set is
|
|
146
|
+
# when nothing is set, or when what is set is a local proxy.
|
|
132
147
|
case "$ANTHROPIC_BASE_URL" in
|
|
133
148
|
""|http://127.0.0.1:*)
|
|
134
|
-
if
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
149
|
+
if __lakon_probe "$__lakon_port"; then
|
|
150
|
+
export ANTHROPIC_BASE_URL=http://127.0.0.1:$__lakon_port
|
|
151
|
+
else
|
|
152
|
+
# A dead lakonai URL inherited from the environment (ours, or the
|
|
153
|
+
# pre-1.2.3 port 7474) is what broke the CLI in the first place. If
|
|
154
|
+
# nothing answers there, drop it and let Claude talk to the API directly.
|
|
155
|
+
case "$ANTHROPIC_BASE_URL" in
|
|
156
|
+
http://127.0.0.1:$__lakon_port|http://127.0.0.1:7474)
|
|
157
|
+
__lakon_stale=\${ANTHROPIC_BASE_URL##*:}
|
|
158
|
+
__lakon_probe "$__lakon_stale" || unset ANTHROPIC_BASE_URL
|
|
159
|
+
unset __lakon_stale
|
|
160
|
+
;;
|
|
161
|
+
esac
|
|
143
162
|
fi
|
|
144
163
|
;;
|
|
145
164
|
esac
|
|
146
165
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
fi
|
|
150
|
-
unset __lakon_port __lakon_up
|
|
166
|
+
unset __lakon_port
|
|
167
|
+
unset -f __lakon_probe 2>/dev/null
|
|
151
168
|
`;
|
|
152
169
|
}
|
|
153
170
|
|