lampson 0.5.5 → 0.5.7
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/bin/lampson.js +1 -1
- package/chat.syn +7 -2
- package/cli.syn +3 -0
- package/hub.tpl.syn +3 -0
- package/lib/agents.syn +30 -13
- package/lib/approvals.syn +4 -1
- package/lib/loop.syn +103 -56
- package/lib/mailbox.syn +29 -2
- package/lib/prompt.syn +3 -3
- package/lib/runtime.syn +19 -0
- package/lib/settings.syn +23 -0
- package/lib/webchat.syn +373 -0
- package/package.json +3 -2
- package/public/css/chat.css +28 -0
- package/public/css/layout.css +3 -1
- package/public/index.html +3 -0
- package/public/js/app.js +2 -1
- package/public/js/chat.js +148 -25
- package/public/js/core.js +32 -13
- package/public/js/editor.js +11 -1
- package/public/js/markdown.js +72 -0
- package/public/js/sessions.js +31 -10
- package/public/js/tree.js +2 -1
- package/public/vendor/README.md +8 -0
- package/public/vendor/dompurify.LICENSE +202 -0
- package/public/vendor/marked.LICENSE +44 -0
- package/public/vendor/marked.umd.js +92 -0
- package/public/vendor/purify.min.js +7 -0
- package/run.syn +5 -0
- package/synsema.json +3 -0
- package/web.syn +104 -63
package/lib/settings.syn
CHANGED
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
|
|
10
10
|
-- bajo el hub cada workspace corre con su propio .lampson/ y una junction .lampson/global → <home>/.lampson:
|
|
11
11
|
-- la config (keys, ⚙) es una sola para todos. Sin junction (instalación directa, tests) es .lampson/config.json
|
|
12
|
+
-- El enlace sale del .lampson local: desde Synsema 0.6.45 necesita un grant propio.
|
|
13
|
+
-- Sin él, cfg_path() recuperaba el rechazo y usaba una configuración local distinta por workspace.
|
|
14
|
+
|
|
12
15
|
task cfg_path()
|
|
13
16
|
try
|
|
14
17
|
when file_exists(".lampson/global/config.json") or file_exists(".lampson/global")
|
|
@@ -20,6 +23,8 @@ task cfg_path()
|
|
|
20
23
|
export task load()
|
|
21
24
|
require file.read(".lampson")
|
|
22
25
|
require file.read(".lampson/**")
|
|
26
|
+
require file.read(".lampson/global")
|
|
27
|
+
require file.read(".lampson/global/**")
|
|
23
28
|
require env("LAMPSON_*")
|
|
24
29
|
-- LAMPSON_NO_CONFIG=1: ignorar config.json (proveedor/key reales) — lo fija tests/run.ps1|sh para que la
|
|
25
30
|
-- suite hable SOLO con el mock (2026-08-27: agents_test gastó tokens reales de DeepSeek por no tenerlo)
|
|
@@ -41,6 +46,8 @@ export task load()
|
|
|
41
46
|
export task save(doc)
|
|
42
47
|
require file(".lampson")
|
|
43
48
|
require file(".lampson/**")
|
|
49
|
+
require file(".lampson/global")
|
|
50
|
+
require file(".lampson/global/**")
|
|
44
51
|
require env("LAMPSON_*")
|
|
45
52
|
-- LAMPSON_NO_CONFIG=1 (tests): NUNCA escribir el archivo real. Como load() devuelve un doc en blanco,
|
|
46
53
|
-- cualquier save() (remember_command al tipear /exit en tty_test, /verbose, set_key, set_default…)
|
|
@@ -54,6 +61,8 @@ export task save(doc)
|
|
|
54
61
|
export task raw_key(name)
|
|
55
62
|
require file.read(".lampson")
|
|
56
63
|
require file.read(".lampson/**")
|
|
64
|
+
require file.read(".lampson/global")
|
|
65
|
+
require file.read(".lampson/global/**")
|
|
57
66
|
let doc be load()
|
|
58
67
|
when contains(doc["keys"], lower(name))
|
|
59
68
|
give text(doc["keys"][lower(name)])
|
|
@@ -62,6 +71,8 @@ export task raw_key(name)
|
|
|
62
71
|
export task set_key(name, key)
|
|
63
72
|
require file(".lampson")
|
|
64
73
|
require file(".lampson/**")
|
|
74
|
+
require file(".lampson/global")
|
|
75
|
+
require file(".lampson/global/**")
|
|
65
76
|
let doc be load()
|
|
66
77
|
when trim(key) == ""
|
|
67
78
|
let keys be {}
|
|
@@ -77,6 +88,8 @@ export task set_key(name, key)
|
|
|
77
88
|
export task set_default(name, model)
|
|
78
89
|
require file(".lampson")
|
|
79
90
|
require file(".lampson/**")
|
|
91
|
+
require file(".lampson/global")
|
|
92
|
+
require file(".lampson/global/**")
|
|
80
93
|
let doc be load()
|
|
81
94
|
set doc["provider"] to lower(name)
|
|
82
95
|
set doc["model"] to model
|
|
@@ -109,6 +122,8 @@ task load_raw()
|
|
|
109
122
|
export task set_value(key, value)
|
|
110
123
|
require file(".lampson")
|
|
111
124
|
require file(".lampson/**")
|
|
125
|
+
require file(".lampson/global")
|
|
126
|
+
require file(".lampson/global/**")
|
|
112
127
|
require env("LAMPSON_*")
|
|
113
128
|
when not contains(KEYS, key)
|
|
114
129
|
raise("unknown setting '" + text(key) + "'")
|
|
@@ -127,6 +142,8 @@ export task set_value(key, value)
|
|
|
127
142
|
export task values()
|
|
128
143
|
require file.read(".lampson")
|
|
129
144
|
require file.read(".lampson/**")
|
|
145
|
+
require file.read(".lampson/global")
|
|
146
|
+
require file.read(".lampson/global/**")
|
|
130
147
|
require env("LAMPSON_*")
|
|
131
148
|
let doc be load_raw()
|
|
132
149
|
let out be {}
|
|
@@ -149,6 +166,8 @@ export task values()
|
|
|
149
166
|
export task judge_env()
|
|
150
167
|
require file.read(".lampson")
|
|
151
168
|
require file.read(".lampson/**")
|
|
169
|
+
require file.read(".lampson/global")
|
|
170
|
+
require file.read(".lampson/global/**")
|
|
152
171
|
require env("LAMPSON_*")
|
|
153
172
|
let js be judge_setting()
|
|
154
173
|
let mode be lower(trim(text(js["mode"])))
|
|
@@ -173,6 +192,8 @@ export task judge_env()
|
|
|
173
192
|
export task judge_setting()
|
|
174
193
|
require file.read(".lampson")
|
|
175
194
|
require file.read(".lampson/**")
|
|
195
|
+
require file.read(".lampson/global")
|
|
196
|
+
require file.read(".lampson/global/**")
|
|
176
197
|
require env("LAMPSON_*")
|
|
177
198
|
let v be values()
|
|
178
199
|
let m be trim(text(v["judge"]))
|
|
@@ -187,6 +208,8 @@ export task judge_setting()
|
|
|
187
208
|
export task set_judge(mode, model)
|
|
188
209
|
require file(".lampson")
|
|
189
210
|
require file(".lampson/**")
|
|
211
|
+
require file(".lampson/global")
|
|
212
|
+
require file(".lampson/global/**")
|
|
190
213
|
require env("LAMPSON_*")
|
|
191
214
|
set_value("judge", when mode == "off" then "" otherwise mode)
|
|
192
215
|
when model != nothing
|
package/lib/webchat.syn
ADDED
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
-- Chat web: sesión persistida antes del inicio y worker independiente de las conexiones del navegador.
|
|
2
|
+
-- Input entre herramientas, aprobaciones y diario de eventos reanudable; una ejecución por sesión.
|
|
3
|
+
use "./runtime.syn" as runtime
|
|
4
|
+
use "./mailbox.syn" as mailbox
|
|
5
|
+
use "./loop.syn" as loop
|
|
6
|
+
use "./agents.syn" as agents
|
|
7
|
+
use "./session.syn" as session
|
|
8
|
+
use "./approvals.syn" as approvals
|
|
9
|
+
use "./permission.syn" as permission
|
|
10
|
+
|
|
11
|
+
export task enqueue(sid, item)
|
|
12
|
+
when not session.valid_id(sid)
|
|
13
|
+
give false
|
|
14
|
+
give mailbox.enqueue_active("web:" + sid, item)
|
|
15
|
+
|
|
16
|
+
export task stop_pending(sid)
|
|
17
|
+
give length(where(mailbox.peek("web:" + sid), (it) => it["kind"] == "stop")) > 0
|
|
18
|
+
|
|
19
|
+
task deliver(sobre, hooks)
|
|
20
|
+
require db(".lampson/teams.db")
|
|
21
|
+
require net
|
|
22
|
+
require net("0.0.0.0/0")
|
|
23
|
+
require net("::/0")
|
|
24
|
+
require exec
|
|
25
|
+
require judge
|
|
26
|
+
require time
|
|
27
|
+
require random
|
|
28
|
+
require file(".lampson")
|
|
29
|
+
require file(".lampson/**")
|
|
30
|
+
require file("workspace")
|
|
31
|
+
require file("workspace/**")
|
|
32
|
+
require file.read("skills")
|
|
33
|
+
require file.read("skills/**")
|
|
34
|
+
require file.read("plugins")
|
|
35
|
+
require file.read("plugins/**")
|
|
36
|
+
require file.read("agents")
|
|
37
|
+
require file.read("agents/**")
|
|
38
|
+
require file.read("memory")
|
|
39
|
+
require file.read("memory/**")
|
|
40
|
+
require env("LAMPSON_*")
|
|
41
|
+
require env("OS")
|
|
42
|
+
require secret("LAMPSON_*")
|
|
43
|
+
let o be runtime.open(sobre, hooks)
|
|
44
|
+
let sid be o["session"]
|
|
45
|
+
let k be "web:" + sid
|
|
46
|
+
let cb be hooks["on_event"]
|
|
47
|
+
let ctx be o["ctx"]
|
|
48
|
+
let opts be ctx["opts"]
|
|
49
|
+
let prev be opts["inbox_fn"]
|
|
50
|
+
task inputs(step, tag)
|
|
51
|
+
let msgs be []
|
|
52
|
+
let halt be false
|
|
53
|
+
each it in mailbox.take(k)
|
|
54
|
+
when it["kind"] == "stop"
|
|
55
|
+
set halt to true
|
|
56
|
+
otherwise
|
|
57
|
+
set msgs to append(msgs, {"role": "user", "content": it["text"], "images": it["images"]})
|
|
58
|
+
call(cb, {"kind": "user_input", "data": it, "tag": ""})
|
|
59
|
+
call(cb, {"kind": "input_applied", "data": {"id": it["id"]}, "tag": ""})
|
|
60
|
+
when length(msgs) == 0 and not halt
|
|
61
|
+
give nothing
|
|
62
|
+
give {"messages": msgs, "stop": halt}
|
|
63
|
+
task inbox(step, tag)
|
|
64
|
+
let incoming be inputs(step, tag)
|
|
65
|
+
let msgs be when incoming == nothing then [] otherwise incoming["messages"]
|
|
66
|
+
let halt be when incoming == nothing then false otherwise incoming["stop"]
|
|
67
|
+
when prev != nothing
|
|
68
|
+
let reports be call(prev, {"step": step, "tag": tag})
|
|
69
|
+
when reports != nothing
|
|
70
|
+
set msgs to msgs + reports["messages"]
|
|
71
|
+
when length(msgs) == 0 and not halt
|
|
72
|
+
give nothing
|
|
73
|
+
give {"messages": msgs, "stop": halt}
|
|
74
|
+
task final_inbox(step, tag)
|
|
75
|
+
let deadline be now() + 900
|
|
76
|
+
while true
|
|
77
|
+
let incoming be inbox(step, tag)
|
|
78
|
+
when incoming != nothing
|
|
79
|
+
give incoming
|
|
80
|
+
let children be where(agents.list_children(), (c) => get(c, "parent", "") == sid and c["status"] == "running" and not c["delivered"])
|
|
81
|
+
when length(children) == 0 or now() >= deadline
|
|
82
|
+
give inbox(step, tag)
|
|
83
|
+
sleep(0.25)
|
|
84
|
+
set opts to loop.with_final_inbox(loop.with_inbox(opts, inbox, ""))
|
|
85
|
+
-- Como Hermes/DeepSeek/OpenCode: el texto entra en el próximo paso del modelo, tras el lote.
|
|
86
|
+
-- Entre herramientas solo se consulta Detener; no se acusa una indicación como incorporada antes de tiempo.
|
|
87
|
+
task control(step, tag)
|
|
88
|
+
when stop_pending(sid)
|
|
89
|
+
give inputs(step, tag)
|
|
90
|
+
give nothing
|
|
91
|
+
set opts["control_fn"] to control
|
|
92
|
+
task stop_requested()
|
|
93
|
+
give stop_pending(sid)
|
|
94
|
+
set opts["stop_pending_fn"] to stop_requested
|
|
95
|
+
set opts["final_inbox_fn"] to final_inbox
|
|
96
|
+
set ctx["opts"] to opts
|
|
97
|
+
set o["ctx"] to ctx
|
|
98
|
+
-- start() ya guardó el primer mensaje antes de anunciar la sesión.
|
|
99
|
+
let msgs be o["messages"]
|
|
100
|
+
let system be msgs[0]
|
|
101
|
+
set system["content"] to system["content"] + "\n\n# Live web conversation\nMessages received while you work are updates to the active conversation. A status question, acknowledgement, or supplementary instruction does not cancel or replace the original task. Briefly answer side questions and continue outstanding authorized work in the same turn, without asking whether to continue. Redirect or stop only when the user actually requests that. Pending tool batches can finish before you see an update; review their results and apply new constraints to subsequent actions. Do not claim that a tool was cancelled merely because a new message arrived."
|
|
102
|
+
set msgs to [system] + slice(msgs, 1, length(msgs))
|
|
103
|
+
let result be nothing
|
|
104
|
+
let steps be 0
|
|
105
|
+
let usage be {"input": 0, "output": 0, "cached": 0}
|
|
106
|
+
let running be true
|
|
107
|
+
try
|
|
108
|
+
let cfg be ctx["cfg"]
|
|
109
|
+
call(hooks["on_start"], {"info": {"session": sid, "agent": ctx["agent"], "thread": o["thread"], "mode": o["mode"], "provider": cfg["provider"], "model": cfg["model"], "has_key": cfg["has_key"]}})
|
|
110
|
+
when o["note"] != ""
|
|
111
|
+
call(cb, {"kind": "inbox", "data": o["note"], "tag": ""})
|
|
112
|
+
when starts_with(trim(sobre["text"]), "!")
|
|
113
|
+
-- El comando lo escribió el usuario: misma autorización explícita que la puerta web original.
|
|
114
|
+
let cmd be trim(slice(trim(sobre["text"]), 1, length(trim(sobre["text"]))))
|
|
115
|
+
let tc be {"id": "user", "name": "bash", "args": {"command": cmd}}
|
|
116
|
+
set msgs to append(msgs, {"role": "assistant", "content": "", "tool_calls": [tc]})
|
|
117
|
+
call(cb, {"kind": "tool_call", "data": tc, "tag": ""})
|
|
118
|
+
let bash_tool be agents.registry_for("build")["bash"]
|
|
119
|
+
let output be call_tool(bash_tool, {"command": cmd, "timeout": 600})
|
|
120
|
+
set msgs to append(msgs, {"role": "tool", "tool_call_id": "user", "name": "bash", "content": output})
|
|
121
|
+
call(cb, {"kind": "tool_result", "data": {"call": tc, "output": output}, "tag": ""})
|
|
122
|
+
runtime.save(o, msgs)
|
|
123
|
+
set result to {"text": "", "stopped": "user_command"}
|
|
124
|
+
when mailbox.release(k)
|
|
125
|
+
set running to false
|
|
126
|
+
while running
|
|
127
|
+
set result to runtime.turn(o, msgs, "", hooks)
|
|
128
|
+
set msgs to result["messages"]
|
|
129
|
+
set steps to steps + result["steps"]
|
|
130
|
+
each field in ["input", "output", "cached"]
|
|
131
|
+
set usage[field] to usage[field] + get(result["usage"], field, 0)
|
|
132
|
+
-- Si el input llegó entre el checkpoint final y el guardado, se atiende antes de soltar la sesión.
|
|
133
|
+
-- Encolar y soltar usan el mismo lock: el mensaje se acepta aquí o el cliente recibe 409 y reenvía.
|
|
134
|
+
when mailbox.release(k)
|
|
135
|
+
set running to false
|
|
136
|
+
recover err
|
|
137
|
+
-- Un fallo libera la sesión y conserva el input que todavía esté en la cola.
|
|
138
|
+
while running
|
|
139
|
+
each it in mailbox.take(k)
|
|
140
|
+
when it["kind"] == "input"
|
|
141
|
+
set msgs to append(msgs, {"role": "user", "content": it["text"], "images": it["images"]})
|
|
142
|
+
runtime.save(o, msgs)
|
|
143
|
+
when mailbox.release(k)
|
|
144
|
+
set running to false
|
|
145
|
+
call(cb, {"kind": "error", "data": text(err), "tag": ""})
|
|
146
|
+
set result to {"text": "", "stopped": "error: " + text(err)}
|
|
147
|
+
give {"agent": ctx["agent"], "thread": o["thread"], "session": sid, "text": result["text"], "steps": steps, "usage": usage, "stopped": result["stopped"]}
|
|
148
|
+
|
|
149
|
+
-- Diario de eventos independiente de las conexiones del navegador. Un solo worker escribe por corrida.
|
|
150
|
+
-- El lector nunca avanza sobre un hueco: una recarga puede repetir eventos sin duplicarlos.
|
|
151
|
+
task publish(run_id, kind, data, tag)
|
|
152
|
+
let seq be state_incr("wc:seq:" + run_id, 1)
|
|
153
|
+
state_set("wc:event:" + run_id + ":" + text(seq), {"kind": kind, "data": data, "tag": tag, "run": run_id, "seq": seq})
|
|
154
|
+
|
|
155
|
+
export task event_at(run_id, seq)
|
|
156
|
+
give state_get("wc:event:" + run_id + ":" + text(seq), nothing)
|
|
157
|
+
|
|
158
|
+
export task run_info(run_id)
|
|
159
|
+
give state_get("wc:run:" + run_id, nothing)
|
|
160
|
+
|
|
161
|
+
task purge_run(run_id)
|
|
162
|
+
let seq be state_get("wc:seq:" + run_id, 0)
|
|
163
|
+
let i be 1
|
|
164
|
+
while i <= seq
|
|
165
|
+
state_delete("wc:event:" + run_id + ":" + text(i))
|
|
166
|
+
set i to i + 1
|
|
167
|
+
state_delete("wc:seq:" + run_id)
|
|
168
|
+
state_delete("wc:run:" + run_id)
|
|
169
|
+
|
|
170
|
+
export task forget(sid)
|
|
171
|
+
let run_id be state_get("wc:current:" + sid, "")
|
|
172
|
+
when run_id != ""
|
|
173
|
+
let info be run_info(run_id)
|
|
174
|
+
when info != nothing
|
|
175
|
+
when info["active"]
|
|
176
|
+
give false
|
|
177
|
+
purge_run(run_id)
|
|
178
|
+
state_delete("wc:current:" + sid)
|
|
179
|
+
give true
|
|
180
|
+
|
|
181
|
+
export task status(sid)
|
|
182
|
+
let run_id be state_get("wc:current:" + sid, "")
|
|
183
|
+
when run_id == ""
|
|
184
|
+
give nothing
|
|
185
|
+
let info be run_info(run_id)
|
|
186
|
+
when info == nothing
|
|
187
|
+
give nothing
|
|
188
|
+
give {"id": run_id, "active": info["active"], "base": when info["active"] then info["base"] otherwise [], "pending": where(mailbox.peek("web:" + sid), (it) => it["kind"] == "input")}
|
|
189
|
+
|
|
190
|
+
export task begin(body)
|
|
191
|
+
require db(".lampson/teams.db")
|
|
192
|
+
require net
|
|
193
|
+
require net("0.0.0.0/0")
|
|
194
|
+
require net("::/0")
|
|
195
|
+
require exec
|
|
196
|
+
require judge
|
|
197
|
+
require time
|
|
198
|
+
require random
|
|
199
|
+
require file(".lampson")
|
|
200
|
+
require file(".lampson/**")
|
|
201
|
+
require file("workspace")
|
|
202
|
+
require file("workspace/**")
|
|
203
|
+
require file.read("skills")
|
|
204
|
+
require file.read("skills/**")
|
|
205
|
+
require file.read("plugins")
|
|
206
|
+
require file.read("plugins/**")
|
|
207
|
+
require file.read("agents")
|
|
208
|
+
require file.read("agents/**")
|
|
209
|
+
require file.read("memory")
|
|
210
|
+
require file.read("memory/**")
|
|
211
|
+
require env("LAMPSON_*")
|
|
212
|
+
require env("OS")
|
|
213
|
+
require secret("LAMPSON_*")
|
|
214
|
+
let mode be lower(text(get(body, "permission", env("LAMPSON_PERMISSION", "ask"))))
|
|
215
|
+
when not contains(["ask", "yolo", "strict"], mode)
|
|
216
|
+
set mode to "ask"
|
|
217
|
+
let want be lower(text(get(body, "agent", "build")))
|
|
218
|
+
when not contains(runtime.names(), want)
|
|
219
|
+
set want to "build"
|
|
220
|
+
let images be []
|
|
221
|
+
let total be 0
|
|
222
|
+
each im in get(body, "images", [])
|
|
223
|
+
when contains(im, "data") and contains(im, "media_type")
|
|
224
|
+
set total to total + length(im["data"])
|
|
225
|
+
when total <= 5000000
|
|
226
|
+
let entry be {"media_type": text(im["media_type"]), "data": text(im["data"])}
|
|
227
|
+
when contains(im, "w") and contains(im, "h")
|
|
228
|
+
set entry to {"media_type": entry["media_type"], "data": entry["data"], "w": floor(number(im["w"])), "h": floor(number(im["h"]))}
|
|
229
|
+
set images to append(images, entry)
|
|
230
|
+
let envelope be {"to": want, "session": text(get(body, "session", "")), "from": {"id": "", "name": "", "kind": "human"}, "text": body["message"], "images": images, "channel": "web", "meta": {}}
|
|
231
|
+
give start(envelope, {"mode": mode, "provider": lower(text(get(body, "provider", ""))), "model": text(get(body, "model", "")), "await_subagents": true})
|
|
232
|
+
|
|
233
|
+
export task start(sobre, options)
|
|
234
|
+
require db(".lampson/teams.db")
|
|
235
|
+
require net
|
|
236
|
+
require net("0.0.0.0/0")
|
|
237
|
+
require net("::/0")
|
|
238
|
+
require exec
|
|
239
|
+
require judge
|
|
240
|
+
require time
|
|
241
|
+
require random
|
|
242
|
+
require file(".lampson")
|
|
243
|
+
require file(".lampson/**")
|
|
244
|
+
require file("workspace")
|
|
245
|
+
require file("workspace/**")
|
|
246
|
+
require file.read("skills")
|
|
247
|
+
require file.read("skills/**")
|
|
248
|
+
require file.read("plugins")
|
|
249
|
+
require file.read("plugins/**")
|
|
250
|
+
require file.read("agents")
|
|
251
|
+
require file.read("agents/**")
|
|
252
|
+
require file.read("memory")
|
|
253
|
+
require file.read("memory/**")
|
|
254
|
+
require env("LAMPSON_*")
|
|
255
|
+
require env("OS")
|
|
256
|
+
require secret("LAMPSON_*")
|
|
257
|
+
-- Rechazar una segunda pestaña antes de reconstruir el contexto; el lock de abajo cierra la carrera.
|
|
258
|
+
let requested be get(sobre, "session", "")
|
|
259
|
+
when requested != "" and mailbox.is_active("web:" + requested)
|
|
260
|
+
give {"ok": false, "session": requested, "error": "conversation is already running"}
|
|
261
|
+
let o be runtime.open(sobre, options)
|
|
262
|
+
let sid be o["session"]
|
|
263
|
+
let k be "web:" + sid
|
|
264
|
+
when not mailbox.begin_inline(k)
|
|
265
|
+
give {"ok": false, "session": sid, "error": "conversation is already running"}
|
|
266
|
+
-- La conversación completa vive en disco; solo la corrida reciente necesita diario de reconexión.
|
|
267
|
+
let previous be state_get("wc:current:" + sid, "")
|
|
268
|
+
when previous != ""
|
|
269
|
+
let old be run_info(previous)
|
|
270
|
+
when old != nothing
|
|
271
|
+
when not old["active"]
|
|
272
|
+
purge_run(previous)
|
|
273
|
+
let run_id be mailbox.new_id()
|
|
274
|
+
let msgs be append(o["messages"], {"role": "user", "content": sobre["text"], "images": sobre["images"]})
|
|
275
|
+
try
|
|
276
|
+
-- La sesión existe en disco ANTES de arrancar el worker o devolver su identificador.
|
|
277
|
+
runtime.save(o, msgs)
|
|
278
|
+
state_set("wc:run:" + run_id, {"session": sid, "active": true, "base": where(msgs, (m) => m["role"] != "system")})
|
|
279
|
+
state_set("wc:current:" + sid, run_id)
|
|
280
|
+
let envelope be sobre
|
|
281
|
+
set envelope["session"] to sid
|
|
282
|
+
spawn WebChatWorker with spec_json = json_encode({"run": run_id, "sobre": envelope, "options": options})
|
|
283
|
+
recover err
|
|
284
|
+
mailbox.release(k)
|
|
285
|
+
state_set("wc:run:" + run_id, {"session": sid, "active": false, "base": []})
|
|
286
|
+
raise(text(err))
|
|
287
|
+
give {"ok": true, "session": sid, "run": run_id}
|
|
288
|
+
|
|
289
|
+
export task work(spec_json)
|
|
290
|
+
require db(".lampson/teams.db")
|
|
291
|
+
require net
|
|
292
|
+
require net("0.0.0.0/0")
|
|
293
|
+
require net("::/0")
|
|
294
|
+
require exec
|
|
295
|
+
require judge
|
|
296
|
+
require time
|
|
297
|
+
require random
|
|
298
|
+
require file(".lampson")
|
|
299
|
+
require file(".lampson/**")
|
|
300
|
+
require file("workspace")
|
|
301
|
+
require file("workspace/**")
|
|
302
|
+
require file.read("skills")
|
|
303
|
+
require file.read("skills/**")
|
|
304
|
+
require file.read("plugins")
|
|
305
|
+
require file.read("plugins/**")
|
|
306
|
+
require file.read("agents")
|
|
307
|
+
require file.read("agents/**")
|
|
308
|
+
require file.read("memory")
|
|
309
|
+
require file.read("memory/**")
|
|
310
|
+
require env("LAMPSON_*")
|
|
311
|
+
require env("OS")
|
|
312
|
+
require secret("LAMPSON_*")
|
|
313
|
+
let spec be json_decode(spec_json)
|
|
314
|
+
let run_id be spec["run"]
|
|
315
|
+
let sid be spec["sobre"]["session"]
|
|
316
|
+
task emit(kind, data, tag)
|
|
317
|
+
publish(run_id, kind, data, tag)
|
|
318
|
+
task on_start(info)
|
|
319
|
+
emit("session", sid, "")
|
|
320
|
+
emit("mode", {"agent": info["agent"], "permission": info["mode"], "provider": info["provider"], "model": info["model"], "has_key": info["has_key"]}, "")
|
|
321
|
+
task ask_web(name, args, why)
|
|
322
|
+
let id be approvals.open("chat", permission.describe_call(name, args), why, 180)
|
|
323
|
+
emit("approval_request", {"id": id, "name": name, "args": args, "why": why, "timeout": 180}, "")
|
|
324
|
+
let t0 be now()
|
|
325
|
+
task stopped()
|
|
326
|
+
give stop_pending(sid)
|
|
327
|
+
let ok be approvals.wait(id, 180, stopped)
|
|
328
|
+
emit("approval_result", {"id": id, "approved": ok, "timeout": (not ok) and now() - t0 >= 179}, "")
|
|
329
|
+
give ok
|
|
330
|
+
let hooks be spec["options"]
|
|
331
|
+
set hooks["on_event"] to emit
|
|
332
|
+
set hooks["on_start"] to on_start
|
|
333
|
+
set hooks["ask_fn"] to ask_web
|
|
334
|
+
let result be nothing
|
|
335
|
+
try
|
|
336
|
+
set result to deliver(spec["sobre"], hooks)
|
|
337
|
+
recover err
|
|
338
|
+
mailbox.release("web:" + sid)
|
|
339
|
+
emit("error", text(err), "")
|
|
340
|
+
set result to {"session": sid, "text": "", "steps": 0, "usage": {"input": 0, "output": 0}, "stopped": "error: " + text(err)}
|
|
341
|
+
emit("done", result, "")
|
|
342
|
+
let info be run_info(run_id)
|
|
343
|
+
set info["active"] to false
|
|
344
|
+
set info["base"] to []
|
|
345
|
+
state_set("wc:run:" + run_id, info)
|
|
346
|
+
give true
|
|
347
|
+
|
|
348
|
+
agent WebChatWorker
|
|
349
|
+
require db(".lampson/teams.db")
|
|
350
|
+
require net
|
|
351
|
+
require net("0.0.0.0/0")
|
|
352
|
+
require net("::/0")
|
|
353
|
+
require exec
|
|
354
|
+
require judge
|
|
355
|
+
require time
|
|
356
|
+
require random
|
|
357
|
+
require file(".lampson")
|
|
358
|
+
require file(".lampson/**")
|
|
359
|
+
require file("workspace")
|
|
360
|
+
require file("workspace/**")
|
|
361
|
+
require file.read("skills")
|
|
362
|
+
require file.read("skills/**")
|
|
363
|
+
require file.read("plugins")
|
|
364
|
+
require file.read("plugins/**")
|
|
365
|
+
require file.read("agents")
|
|
366
|
+
require file.read("agents/**")
|
|
367
|
+
require file("memory")
|
|
368
|
+
require file("memory/**")
|
|
369
|
+
require env("LAMPSON_*")
|
|
370
|
+
require env("OS")
|
|
371
|
+
require secret("LAMPSON_*")
|
|
372
|
+
require sign("LAMPSON_TOOLS")
|
|
373
|
+
lampson_webchat_worker(spec_json)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lampson",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.7",
|
|
4
4
|
"description": "A coding agent written in Synsema: terminal + web, tools confined to the mounted project, plugins (your own tools, any language), LSP, MCP, sub-agents. Also an SDK: import { Lampson } from \"lampson\" (server or local mode).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"hub.tpl.syn",
|
|
37
37
|
"edge.syn",
|
|
38
38
|
"cli.syn",
|
|
39
|
+
"synsema.json",
|
|
39
40
|
"lampson.ps1",
|
|
40
41
|
"lampson.sh",
|
|
41
42
|
"lampson.cmd",
|
|
@@ -47,7 +48,7 @@
|
|
|
47
48
|
"node": ">=18"
|
|
48
49
|
},
|
|
49
50
|
"dependencies": {
|
|
50
|
-
"synsema": "0.6.
|
|
51
|
+
"synsema": "0.6.67"
|
|
51
52
|
},
|
|
52
53
|
"scripts": {
|
|
53
54
|
"test": "pwsh -NoProfile -File tests/run.ps1"
|
package/public/css/chat.css
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/* chat: mensajes, pasos del agente, tarjeta de permiso, portada (hero) */
|
|
2
2
|
/* mensajes: el del usuario es una nota al margen (como el blockquote de la doc), el del agente es prosa */
|
|
3
3
|
.msg { margin:0 0 16px; }
|
|
4
|
+
.msg a { color:var(--accent); text-decoration:underline; text-underline-offset:3px; overflow-wrap:anywhere; }
|
|
5
|
+
.msg a:hover { text-decoration-thickness:2px; }
|
|
4
6
|
.user { margin:26px 0 16px; padding:.85em 1.1em; background:var(--paper-2); border-left:2px solid var(--accent); white-space:pre-wrap; font-size:15px; }
|
|
5
7
|
.user::before { content:"vos"; display:block; font:400 12px/1 var(--mono); color:var(--accent); margin-bottom:6px; }
|
|
6
8
|
.assistant { font-size:15px; line-height:1.62; }
|
|
@@ -13,6 +15,32 @@
|
|
|
13
15
|
.assistant li::marker { color:var(--ink-3); }
|
|
14
16
|
.assistant h1, .assistant h2, .assistant h3 { font:600 1.06rem/1.4 var(--serif); margin:1.4em 0 .5em; }
|
|
15
17
|
.assistant b, .assistant strong { font-weight:600; }
|
|
18
|
+
.assistant { min-width:0; overflow-wrap:anywhere; }
|
|
19
|
+
.assistant h1 { font-size:1.4rem; }
|
|
20
|
+
.assistant h2 { font-size:1.2rem; }
|
|
21
|
+
.assistant h4, .assistant h5, .assistant h6 { margin:1.2em 0 .5em; font-weight:600; }
|
|
22
|
+
.assistant blockquote { margin:1em 0; padding:.15em 1em; border-left:3px solid var(--accent); color:var(--ink-2); }
|
|
23
|
+
.assistant blockquote p:last-child { margin-bottom:0; }
|
|
24
|
+
.assistant hr { border:0; border-top:1px solid var(--rule); margin:1.4em 0; }
|
|
25
|
+
.assistant li > ul, .assistant li > ol { margin:.35em 0; }
|
|
26
|
+
.assistant input[type="checkbox"] { margin-right:.45em; accent-color:var(--accent); }
|
|
27
|
+
.chat-table { max-width:100%; overflow-x:auto; margin:1em 0; border:1px solid var(--rule); border-radius:var(--r); }
|
|
28
|
+
.chat-table table { width:100%; border-collapse:collapse; font-size:.93em; }
|
|
29
|
+
.chat-table th, .chat-table td { padding:.6em .8em; border-bottom:1px solid var(--rule); vertical-align:top; min-width:7em; }
|
|
30
|
+
.chat-table th { font-weight:600; background:var(--paper-2); text-align:left; }
|
|
31
|
+
.chat-table [align="right"] { text-align:right; }
|
|
32
|
+
.chat-table [align="center"] { text-align:center; }
|
|
33
|
+
.chat-table tr:last-child td { border-bottom:0; }
|
|
34
|
+
.chat-code { max-width:100%; margin:1em 0; border:1px solid var(--rule); border-radius:var(--r); overflow:hidden; }
|
|
35
|
+
.chat-code-bar { display:flex; align-items:center; justify-content:space-between; gap:1em; padding:6px 12px; background:var(--paper-2); border-bottom:1px solid var(--rule); color:var(--ink-2); font:12px/1.5 var(--mono); }
|
|
36
|
+
.chat-code-bar button { padding:3px 8px; color:var(--ink); font:inherit; background:transparent; border:1px solid var(--rule); border-radius:var(--r-sm); cursor:pointer; }
|
|
37
|
+
.chat-code-bar button:hover { border-color:var(--accent); }
|
|
38
|
+
.chat-code-bar button:focus-visible, .chat-table:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
|
|
39
|
+
.assistant .chat-code pre { margin:0; border:0; border-radius:0; }
|
|
40
|
+
@media (max-width:600px) {
|
|
41
|
+
.chat-table th, .chat-table td { padding:.5em .6em; }
|
|
42
|
+
.assistant .chat-code pre { padding:12px; }
|
|
43
|
+
}
|
|
16
44
|
|
|
17
45
|
/* pasos del agente: maquinaria, en mono */
|
|
18
46
|
.step { display:grid; grid-template-columns:16px 1fr; column-gap:8px; margin:0 0 7px 2px; font:400 12.5px/1.5 var(--mono); color:var(--ink-2); }
|
package/public/css/layout.css
CHANGED
|
@@ -128,7 +128,9 @@ textarea:focus { outline:none; }
|
|
|
128
128
|
.crow .keys { color:var(--ink-3); font:400 10.5px/1 var(--mono); letter-spacing:.03em; }
|
|
129
129
|
#send { width:34px; height:30px; padding:0; font-size:15px; display:inline-flex; align-items:center; justify-content:center; }
|
|
130
130
|
#stop { color:var(--rubric); border-color:var(--rubric); display:none; height:30px; }
|
|
131
|
-
form.busy #
|
|
131
|
+
form.busy #stop { display:inline-flex; align-items:center; gap:6px; }
|
|
132
|
+
.input-state { display:block; margin-top:6px; color:var(--ink-3); font-size:12px; }
|
|
133
|
+
.input-state.failed { color:var(--rubric); }
|
|
132
134
|
.hint { display:none; }
|
|
133
135
|
|
|
134
136
|
@media (max-width:900px) { body { grid-template-columns:1fr; grid-template-areas:"top" "main"; } aside { display:none; } #log, form { padding-left:20px; padding-right:20px; } }
|
package/public/index.html
CHANGED
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
<script src="/vendor/xterm-addon-fit.js"></script>
|
|
26
26
|
<script src="/vendor/xterm-addon-webgl.js"></script>
|
|
27
27
|
<script src="/vendor/highlight.min.js"></script>
|
|
28
|
+
<script src="/vendor/marked.umd.js"></script>
|
|
29
|
+
<script src="/vendor/purify.min.js"></script>
|
|
28
30
|
<script>(function(){try{var t=localStorage.getItem('lampson.theme');if(t!=='light'&&t!=='dark'){t='dark';}document.documentElement.setAttribute('data-theme',t);}catch(e){}})();</script>
|
|
29
31
|
</head>
|
|
30
32
|
<body>
|
|
@@ -131,6 +133,7 @@
|
|
|
131
133
|
</main>
|
|
132
134
|
<!-- módulos (scripts clásicos, en orden): core y el componente Panel primero, las vistas después, app.js arranca -->
|
|
133
135
|
<script src="/js/core.js"></script>
|
|
136
|
+
<script src="/js/markdown.js"></script>
|
|
134
137
|
<script src="/js/panel.js"></script>
|
|
135
138
|
<script src="/js/theme.js"></script>
|
|
136
139
|
<script src="/js/sidebar.js"></script>
|
package/public/js/app.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// app.js — arranque: config de la cabecera y primera carga de cada sección (se carga último)
|
|
2
2
|
async function loadCfg() {
|
|
3
3
|
try { cfg = await (await fetch(BASE + '/api/config')).json(); } catch (e) { cfg = {}; }
|
|
4
|
+
scopeSessionStorage(cfg.project);
|
|
4
5
|
const ws = cfg.workspace || '';
|
|
5
6
|
$('#proj').textContent = ws.split(/[\\/]/).filter(Boolean).pop() || 'workspace'; $('#proj').title = shortPath(ws);
|
|
6
7
|
$('#hpath').textContent = shortPath(ws); $('#hpath').title = shortPath(ws);
|
|
@@ -14,7 +15,7 @@ async function loadCfg() {
|
|
|
14
15
|
sel.onchange = () => { localStorage.setItem('lampson.agent', sel.value); hint(); }; hint();
|
|
15
16
|
if (!log.children.length) empty();
|
|
16
17
|
}
|
|
17
|
-
loadCfg().then(() => { loadTree(); loadSessions(); loadProcs(); loadMemory(); loadAgents(); loadMcp(); loadLsp(); loadPlugins(); loadKeys(); loadChannels(); loadTodo(); loadSched(); loadApprovals(); checkUpdate(); const pq = new URLSearchParams(location.search).get('proc'); if (pq) openProc(pq); else if (session) openSession(session); });
|
|
18
|
+
loadCfg().then(() => { loadTree(); loadSessions(); loadProcs(); loadMemory(); loadAgents(); loadMcp(); loadLsp(); loadPlugins(); loadKeys(); loadChannels(); loadTodo(); loadSched(); loadApprovals(); checkUpdate(); const pq = new URLSearchParams(location.search).get('proc'); if (pq) openProc(pq); else if (session) openSession(session, 'replace'); });
|
|
18
19
|
// respaldos lentos por si el stream de eventos se cae
|
|
19
20
|
setInterval(loadProcs, events ? 60000 : 10000);
|
|
20
21
|
setInterval(() => { loadSched(); if (!events) loadApprovals(); }, events ? 60000 : 15000);
|