lonny-agent 0.2.4 → 0.2.6
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 +326 -326
- package/dist/agent/llm.d.ts +4 -0
- package/dist/agent/llm.d.ts.map +1 -1
- package/dist/agent/prompt-builder.d.ts.map +1 -1
- package/dist/agent/prompt-builder.js +13 -9
- package/dist/agent/prompt-builder.js.map +1 -1
- package/dist/agent/providers/google.d.ts.map +1 -1
- package/dist/agent/providers/google.js.map +1 -1
- package/dist/agent/providers/openai.d.ts.map +1 -1
- package/dist/agent/providers/openai.js +43 -3
- package/dist/agent/providers/openai.js.map +1 -1
- package/dist/agent/session.d.ts +4 -0
- package/dist/agent/session.d.ts.map +1 -1
- package/dist/agent/session.js +45 -7
- package/dist/agent/session.js.map +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +7 -1
- package/dist/config/index.js.map +1 -1
- package/dist/tools/__tests__/bash.test.js +1 -1
- package/dist/tools/__tests__/bash.test.js.map +1 -1
- package/dist/tools/__tests__/edit.test.js +875 -371
- package/dist/tools/__tests__/edit.test.js.map +1 -1
- package/dist/tools/__tests__/grep.test.js +32 -0
- package/dist/tools/__tests__/grep.test.js.map +1 -1
- package/dist/tools/__tests__/sed.test.d.ts +2 -0
- package/dist/tools/__tests__/sed.test.d.ts.map +1 -0
- package/dist/tools/__tests__/sed.test.js +228 -0
- package/dist/tools/__tests__/sed.test.js.map +1 -0
- package/dist/tools/bash.d.ts.map +1 -1
- package/dist/tools/bash.js +83 -10
- package/dist/tools/bash.js.map +1 -1
- package/dist/tools/edit.d.ts +50 -9
- package/dist/tools/edit.d.ts.map +1 -1
- package/dist/tools/edit.js +328 -158
- package/dist/tools/edit.js.map +1 -1
- package/dist/tools/grep.d.ts.map +1 -1
- package/dist/tools/grep.js +54 -30
- package/dist/tools/grep.js.map +1 -1
- package/dist/tools/registry.d.ts +0 -6
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/registry.js +2 -29
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/sed.d.ts +4 -0
- package/dist/tools/sed.d.ts.map +1 -0
- package/dist/tools/sed.js +121 -0
- package/dist/tools/sed.js.map +1 -0
- package/dist/web/index.d.ts.map +1 -1
- package/dist/web/index.js +26 -3
- package/dist/web/index.js.map +1 -1
- package/dist/web/public/app.js +5 -855
- package/dist/web/public/confirm.js +70 -0
- package/dist/web/public/index.html +121 -120
- package/dist/web/public/input.js +107 -0
- package/dist/web/public/messages.js +395 -0
- package/dist/web/public/sidebar.js +82 -0
- package/dist/web/public/state.js +72 -0
- package/dist/web/public/style.css +996 -949
- package/dist/web/public/utils.js +37 -0
- package/dist/web/public/websocket.js +267 -0
- package/dist/web/public/ws.js +19 -0
- package/dist/web/session-bridge.d.ts.map +1 -1
- package/dist/web/session-bridge.js +3 -7
- package/dist/web/session-bridge.js.map +1 -1
- package/package.json +55 -54
- package/scripts/copy-native.mjs +24 -0
- package/scripts/copy-web.mjs +15 -0
- package/src/agent/index.ts +25 -25
- package/src/agent/llm.ts +4 -0
- package/src/agent/prompt-builder.ts +13 -9
- package/src/agent/providers/anthropic.ts +179 -179
- package/src/agent/providers/google.ts +210 -211
- package/src/agent/providers/ollama.ts +186 -186
- package/src/agent/providers/openai.ts +61 -5
- package/src/agent/session.ts +59 -3
- package/src/config/index.ts +342 -335
- package/src/tools/__tests__/bash.test.ts +1 -1
- package/src/tools/__tests__/edit.test.ts +981 -385
- package/src/tools/__tests__/grep.test.ts +35 -0
- package/src/tools/bash.ts +97 -11
- package/src/tools/edit.ts +362 -169
- package/src/tools/git.ts +76 -76
- package/src/tools/grep.ts +57 -30
- package/src/tools/registry.ts +2 -31
- package/src/tui/index.ts +786 -786
- package/src/web/index.ts +25 -3
- package/src/web/public/app.js +5 -855
- package/src/web/public/confirm.js +70 -0
- package/src/web/public/index.html +121 -120
- package/src/web/public/input.js +107 -0
- package/src/web/public/messages.js +395 -0
- package/src/web/public/sidebar.js +82 -0
- package/src/web/public/state.js +72 -0
- package/src/web/public/style.css +996 -949
- package/src/web/public/utils.js +37 -0
- package/src/web/public/websocket.js +267 -0
- package/src/web/public/ws.js +19 -0
- package/src/web/session-bridge.ts +193 -194
- package/.claude/settings.local.json +0 -14
- package/.kilo/plans/1780064105789-mighty-pixel.md +0 -171
- package/.kilo/plans/1780293725888-quick-wizard.md +0 -62
- package/.lonny/plan-web-cwd-status.md +0 -38
- package/src/tools/exec.ts +0 -348
package/src/web/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { ensurePromptsDir, loadPromptTemplates } from '../agent/prompt-templates
|
|
|
8
8
|
import { Session, type SessionOutput } from '../agent/session.js'
|
|
9
9
|
import { ensureSkillsDir, loadSkills } from '../agent/skills.js'
|
|
10
10
|
import type { Config } from '../config/index.js'
|
|
11
|
+
import { resetTokenUsage } from '../config/tokens.js'
|
|
11
12
|
import { fmtErr } from '../tools/errors.js'
|
|
12
13
|
import { fetchDeepSeekBalance, isDeepSeekOfficial } from '../tui/balance.js'
|
|
13
14
|
import { listPlans, type PlanEntry } from '../tui/components.js'
|
|
@@ -149,7 +150,7 @@ export async function startWebUi(config: Config, port: number): Promise<void> {
|
|
|
149
150
|
}
|
|
150
151
|
|
|
151
152
|
// Re-create session with output
|
|
152
|
-
|
|
153
|
+
let sessionWithOutput = (await Session.load(config, output)) || new Session(config, output)
|
|
153
154
|
sessionWithOutput.messages = session.messages
|
|
154
155
|
sessionWithOutput.totalInputTokens = session.totalInputTokens
|
|
155
156
|
sessionWithOutput.totalOutputTokens = session.totalOutputTokens
|
|
@@ -251,7 +252,28 @@ export async function startWebUi(config: Config, port: number): Promise<void> {
|
|
|
251
252
|
}
|
|
252
253
|
|
|
253
254
|
if (cmd === 'new') {
|
|
255
|
+
// Stop any running agent first
|
|
256
|
+
sessionWithOutput.stop()
|
|
257
|
+
// Close old bridge
|
|
258
|
+
if (bridge) bridge.close()
|
|
259
|
+
// Clear persisted state
|
|
254
260
|
Session.clearSavedSession(config.cwd)
|
|
261
|
+
resetTokenUsage(config.cwd)
|
|
262
|
+
resetGlobalEventBus()
|
|
263
|
+
// Create fresh session with empty context
|
|
264
|
+
sessionWithOutput = new Session(config, output)
|
|
265
|
+
sessionWithOutput.onPlanWritten = (display: string) => {
|
|
266
|
+
ws.send(JSON.stringify({ type: 'plan_written', display }))
|
|
267
|
+
sendPlanData()
|
|
268
|
+
}
|
|
269
|
+
// Create new bridge for the fresh session
|
|
270
|
+
bridge = startSessionBridge(sessionWithOutput, config, (msg: WsMessage) => {
|
|
271
|
+
if (ws.readyState === ws.OPEN) {
|
|
272
|
+
ws.send(JSON.stringify(msg))
|
|
273
|
+
}
|
|
274
|
+
})
|
|
275
|
+
// Reset pending confirmation state
|
|
276
|
+
pendingConfirm = null
|
|
255
277
|
ws.send(JSON.stringify({ type: 'session_cleared' }))
|
|
256
278
|
ws.send(JSON.stringify({ type: 'done', reason: 'stop' }))
|
|
257
279
|
return
|
|
@@ -428,11 +450,11 @@ export async function startWebUi(config: Config, port: number): Promise<void> {
|
|
|
428
450
|
sendPlanData()
|
|
429
451
|
})()
|
|
430
452
|
|
|
431
|
-
// Send full session history (exclude system prompt, strip ANSI from tool results)
|
|
453
|
+
// Send full session history (exclude system prompt, strip ANSI from non-edit tool results)
|
|
432
454
|
const historyMessages = sessionWithOutput.messages
|
|
433
455
|
.filter(m => m.role !== 'system')
|
|
434
456
|
.map(m => {
|
|
435
|
-
if (m.role === 'tool' && typeof m.content === 'string') {
|
|
457
|
+
if (m.role === 'tool' && typeof m.content === 'string' && m.name !== 'edit') {
|
|
436
458
|
return { ...m, content: stripAnsi(m.content) }
|
|
437
459
|
}
|
|
438
460
|
return m
|