lonny-agent 0.2.3 → 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/index.js +1 -1
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/llm.d.ts +4 -0
- package/dist/agent/llm.d.ts.map +1 -1
- package/dist/agent/project.d.ts +26 -0
- package/dist/agent/project.d.ts.map +1 -0
- package/dist/agent/project.js +303 -0
- package/dist/agent/project.js.map +1 -0
- package/dist/agent/prompt-builder.d.ts +1 -1
- package/dist/agent/prompt-builder.d.ts.map +1 -1
- package/dist/agent/prompt-builder.js +22 -13
- package/dist/agent/prompt-builder.js.map +1 -1
- package/dist/agent/providers/anthropic.d.ts.map +1 -1
- package/dist/agent/providers/anthropic.js +20 -2
- package/dist/agent/providers/anthropic.js.map +1 -1
- package/dist/agent/providers/google.d.ts.map +1 -1
- package/dist/agent/providers/google.js +1 -1
- package/dist/agent/providers/google.js.map +1 -1
- package/dist/agent/providers/ollama.d.ts.map +1 -1
- package/dist/agent/providers/ollama.js +2 -1
- package/dist/agent/providers/ollama.js.map +1 -1
- package/dist/agent/providers/openai.d.ts.map +1 -1
- package/dist/agent/providers/openai.js +63 -3
- package/dist/agent/providers/openai.js.map +1 -1
- package/dist/agent/session.d.ts +8 -2
- package/dist/agent/session.d.ts.map +1 -1
- package/dist/agent/session.js +250 -153
- 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 +58 -0
- package/dist/tools/edit.d.ts.map +1 -1
- package/dist/tools/edit.js +366 -149
- 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/read.d.ts +6 -0
- package/dist/tools/read.d.ts.map +1 -1
- package/dist/tools/read.js +42 -15
- package/dist/tools/read.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 -33
- 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/tools/write_plan.d.ts +1 -1
- package/dist/tools/write_plan.d.ts.map +1 -1
- package/dist/tools/write_plan.js +14 -4
- package/dist/tools/write_plan.js.map +1 -1
- package/dist/tui/index.d.ts.map +1 -1
- package/dist/tui/index.js +5 -4
- package/dist/tui/index.js.map +1 -1
- package/dist/web/index.d.ts.map +1 -1
- package/dist/web/index.js +30 -7
- 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/project.ts +366 -0
- package/src/agent/prompt-builder.ts +23 -13
- package/src/agent/providers/anthropic.ts +179 -172
- package/src/agent/providers/google.ts +210 -211
- package/src/agent/providers/ollama.ts +186 -182
- package/src/agent/providers/openai.ts +73 -5
- package/src/agent/session.ts +275 -153
- 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 +414 -154
- package/src/tools/git.ts +76 -76
- package/src/tools/grep.ts +57 -30
- package/src/tools/read.ts +61 -25
- package/src/tools/registry.ts +231 -265
- package/src/tools/write_plan.ts +21 -5
- package/src/tui/index.ts +786 -785
- package/src/web/index.ts +29 -7
- 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/.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'
|
|
@@ -88,13 +89,13 @@ export async function startWebUi(config: Config, port: number): Promise<void> {
|
|
|
88
89
|
// Create WebSocket server
|
|
89
90
|
const wss = new WebSocketServer({ server })
|
|
90
91
|
|
|
91
|
-
wss.on('connection', (ws: WebSocket) => {
|
|
92
|
+
wss.on('connection', async (ws: WebSocket) => {
|
|
92
93
|
console.log('[Web UI] Client connected')
|
|
93
94
|
|
|
94
95
|
// Reset event bus for new session
|
|
95
96
|
resetGlobalEventBus()
|
|
96
97
|
|
|
97
|
-
const session = Session.load(config) || new Session(config)
|
|
98
|
+
const session = (await Session.load(config)) || new Session(config)
|
|
98
99
|
let bridge: ReturnType<typeof startSessionBridge> | null = null
|
|
99
100
|
|
|
100
101
|
// Track output to forward to WebSocket
|
|
@@ -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
|
|
@@ -238,20 +239,41 @@ export async function startWebUi(config: Config, port: number): Promise<void> {
|
|
|
238
239
|
const arg = parts.slice(1).join(' ')
|
|
239
240
|
|
|
240
241
|
if (cmd === 'mode' && (arg === 'code' || arg === 'plan' || arg === 'ask')) {
|
|
241
|
-
sessionWithOutput.setMode(arg as 'code' | 'plan' | 'ask')
|
|
242
|
+
await sessionWithOutput.setMode(arg as 'code' | 'plan' | 'ask')
|
|
242
243
|
ws.send(JSON.stringify({ type: 'mode_changed', mode: arg }))
|
|
243
244
|
return
|
|
244
245
|
}
|
|
245
246
|
|
|
246
247
|
if (cmd === 'model' && arg) {
|
|
247
248
|
sessionWithOutput.config.model = arg
|
|
248
|
-
sessionWithOutput.setMode(sessionWithOutput.config.mode)
|
|
249
|
+
await sessionWithOutput.setMode(sessionWithOutput.config.mode)
|
|
249
250
|
ws.send(JSON.stringify({ type: 'model_changed', model: arg }))
|
|
250
251
|
return
|
|
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
|