lampson 0.4.0 → 0.5.0
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 +8 -2
- package/chat.syn +1 -1
- package/hub.tpl.syn +99 -7
- package/lib/api.syn +178 -7
- package/lib/diagnose.syn +142 -0
- package/lib/loop.syn +14 -0
- package/lib/plugins.syn +6 -4
- package/lib/provider.syn +16 -13
- package/lib/runtime.syn +56 -0
- package/lib/schedule.syn +40 -2
- package/lib/teamrun.syn +78 -4
- package/lib/teams.syn +397 -24
- package/lib/workspaces.syn +84 -1
- package/lib/worktree.syn +108 -0
- package/package.json +1 -1
- package/plugins/example-hello/plugin.json +1 -0
- package/public/css/chat.css +9 -8
- package/public/css/hub.css +73 -11
- package/public/css/layout.css +12 -4
- package/public/css/login.css +1 -1
- package/public/css/mobile.css +2 -2
- package/public/css/panel.css +16 -7
- package/public/css/sidebar.css +1 -1
- package/public/css/teams.css +722 -48
- package/public/css/tokens.css +36 -12
- package/public/css/views.css +124 -0
- package/public/hub.html +17 -8
- package/public/index.html +3 -2
- package/public/js/app.js +2 -2
- package/public/js/approvals.js +1 -1
- package/public/js/core.js +5 -2
- package/public/js/flow.js +187 -0
- package/public/js/hub.js +131 -22
- package/public/js/navtabs.js +23 -0
- package/public/js/objdiag.js +90 -0
- package/public/js/objlive.js +393 -0
- package/public/js/panel.js +2 -1
- package/public/js/plugins-home.js +59 -0
- package/public/js/plugins.js +40 -18
- package/public/js/schedules.js +5 -0
- package/public/js/sidebar.js +6 -4
- package/public/js/tasks-home.js +104 -0
- package/public/js/teams-home.js +144 -0
- package/public/js/teams.js +928 -195
- package/public/js/terminal.js +8 -2
- package/public/js/workspaces.js +6 -3
- package/public/plugins-home.html +32 -0
- package/public/tasks-home.html +31 -0
- package/public/teams-home.html +45 -0
- package/public/teams.html +33 -45
- package/public/vendor/xterm-addon-webgl.js +2 -0
- package/web.syn +61 -8
package/lib/plugins.syn
CHANGED
|
@@ -14,8 +14,10 @@
|
|
|
14
14
|
-- "instructions": "INSTRUCTIONS.md" (opcional: cómo usar sus tools — texto, o un .md de su carpeta;
|
|
15
15
|
-- sin el campo, INSTRUCTIONS.md si existe. Va al prompt de cada
|
|
16
16
|
-- agente que tenga alguna de sus tools: el plugin trae su proceso)
|
|
17
|
-
-- "channel": {"agent": "tienda"}
|
|
17
|
+
-- "channel": {"agent": "tienda"}, (opcional: un CANAL — lib/channels.syn. Sus acciones `receive` y
|
|
18
18
|
-- `send` no son tools del modelo, así que un canal puede no tener tools)
|
|
19
|
+
-- "example": true} (opcional: una plantilla para copiar — plugins/example-hello. Funciona
|
|
20
|
+
-- igual, pero las UIs no la muestran entre los plugins para usar)
|
|
19
21
|
--
|
|
20
22
|
-- Cómo corre (patrón "safe runner" de la doc 22-sandbox): cada llamada es UN proceso hijo que termina.
|
|
21
23
|
-- kind=syn → `synsema run --cap-set stdout,time,env=PLUGIN_*[,caps] <entry>`: el techo lo fija el
|
|
@@ -116,7 +118,7 @@ task read_manifest(dir, name, scope, legacy)
|
|
|
116
118
|
set instr to trim(ifile)
|
|
117
119
|
when length(instr) > MAX_INSTRUCTIONS
|
|
118
120
|
set instr to slice(instr, 0, MAX_INSTRUCTIONS)
|
|
119
|
-
give {"ok": true, "name": name, "scope": scope, "legacy": is_legacy, "plugin": {"instructions": instr,"name": name, "scope": scope, "dir": dir + "/" + name, "kind": kind, "legacy": is_legacy, "description": when contains(doc, "description") then text(doc["description"]) otherwise "", "entry": when contains(doc, "entry") then text(doc["entry"]) otherwise "", "command": when contains(doc, "command") then text(doc["command"]) otherwise "", "caps": when contains(doc, "caps") then text(doc["caps"]) otherwise "", "timeout": when contains(doc, "timeout") then floor(number(doc["timeout"])) otherwise DEFAULT_TIMEOUT, "tools": tools, "channel": channel, "config": config}}
|
|
121
|
+
give {"ok": true, "name": name, "scope": scope, "legacy": is_legacy, "plugin": {"instructions": instr,"name": name, "scope": scope, "dir": dir + "/" + name, "kind": kind, "legacy": is_legacy, "description": when contains(doc, "description") then text(doc["description"]) otherwise "", "entry": when contains(doc, "entry") then text(doc["entry"]) otherwise "", "command": when contains(doc, "command") then text(doc["command"]) otherwise "", "caps": when contains(doc, "caps") then text(doc["caps"]) otherwise "", "timeout": when contains(doc, "timeout") then floor(number(doc["timeout"])) otherwise DEFAULT_TIMEOUT, "tools": tools, "channel": channel, "config": config, "example": contains(doc, "example") and doc["example"] == true}}
|
|
120
122
|
|
|
121
123
|
task scan(dir, scope, legacy)
|
|
122
124
|
let out be []
|
|
@@ -168,7 +170,7 @@ export task all()
|
|
|
168
170
|
set l["error"] to nothing
|
|
169
171
|
set out to append(out, l)
|
|
170
172
|
otherwise
|
|
171
|
-
set out to append(out, {"name": n, "scope": r["scope"], "dir": "", "kind": "?", "legacy": r["legacy"], "description": "", "entry": "", "command": "", "caps": "", "timeout": 0, "tools": [], "channel": nothing, "config": [], "instructions": "", "enabled": false, "error": r["error"]})
|
|
173
|
+
set out to append(out, {"name": n, "scope": r["scope"], "dir": "", "kind": "?", "legacy": r["legacy"], "description": "", "entry": "", "command": "", "caps": "", "timeout": 0, "tools": [], "channel": nothing, "config": [], "instructions": "", "enabled": false, "error": r["error"], "example": false})
|
|
172
174
|
give out
|
|
173
175
|
|
|
174
176
|
export task enabled()
|
|
@@ -491,5 +493,5 @@ export task summary()
|
|
|
491
493
|
require env("LAMPSON_*")
|
|
492
494
|
let out be []
|
|
493
495
|
each l in all()
|
|
494
|
-
set out to append(out, {"name": l["name"], "scope": l["scope"], "kind": l["kind"], "legacy": l["legacy"], "description": l["description"], "enabled": l["enabled"], "error": l["error"], "caps": when l["kind"] == "syn" and l["error"] == nothing then ceiling_of(l) otherwise "", "command": when l["kind"] == "exec" then l["command"] otherwise "", "tools": apply(l["tools"], (t) => t["name"]), "tool_specs": l["tools"], "dir": l["dir"], "channel": l["channel"] != nothing})
|
|
496
|
+
set out to append(out, {"name": l["name"], "scope": l["scope"], "kind": l["kind"], "legacy": l["legacy"], "description": l["description"], "enabled": l["enabled"], "error": l["error"], "caps": when l["kind"] == "syn" and l["error"] == nothing then ceiling_of(l) otherwise "", "command": when l["kind"] == "exec" then l["command"] otherwise "", "tools": apply(l["tools"], (t) => t["name"]), "tool_specs": l["tools"], "dir": l["dir"], "channel": l["channel"] != nothing, "example": l["example"]})
|
|
495
497
|
give out
|
package/lib/provider.syn
CHANGED
|
@@ -26,16 +26,18 @@ use "./settings.syn" as settings
|
|
|
26
26
|
|
|
27
27
|
let ANTHROPIC_VERSION be "2023-06-01"
|
|
28
28
|
|
|
29
|
-
-- Tabla base URL por proveedor
|
|
29
|
+
-- Tabla base URL por proveedor. Modelos por defecto revisados 2026-10-18 contra la doc de cada uno: el más
|
|
30
|
+
-- nuevo de uso general (no el más caro). deepseek-flash es el alias que DeepSeek mueve a su último Flash
|
|
31
|
+
-- (hoy V4.1-Flash-1017); kimi-k2-* se retiró el 2026-05-25; en Groq gpt-oss-120b es el que mejor usa tools.
|
|
30
32
|
export let PRESETS be {
|
|
31
|
-
"openai": {"wire": "openai", "base_url": "https://api.openai.com/v1", "model": "gpt-
|
|
32
|
-
"deepseek": {"wire": "openai", "base_url": "https://api.deepseek.com/v1", "model": "deepseek-
|
|
33
|
-
"kimi": {"wire": "openai", "base_url": "https://api.moonshot.ai/v1", "model": "kimi-
|
|
34
|
-
"groq": {"wire": "openai", "base_url": "https://api.groq.com/openai/v1", "model": "
|
|
35
|
-
"grok": {"wire": "openai", "base_url": "https://api.x.ai/v1", "model": "grok-
|
|
36
|
-
"openrouter": {"wire": "openai", "base_url": "https://openrouter.ai/api/v1", "model": "deepseek/deepseek-
|
|
37
|
-
"ollama": {"wire": "openai", "base_url": "http://127.0.0.1:11434/v1", "model": "
|
|
38
|
-
"anthropic": {"wire": "anthropic", "base_url": "https://api.anthropic.com/v1", "model": "claude-sonnet-
|
|
33
|
+
"openai": {"wire": "openai", "base_url": "https://api.openai.com/v1", "model": "gpt-6.1-sol"},
|
|
34
|
+
"deepseek": {"wire": "openai", "base_url": "https://api.deepseek.com/v1", "model": "deepseek-flash"},
|
|
35
|
+
"kimi": {"wire": "openai", "base_url": "https://api.moonshot.ai/v1", "model": "kimi-k3"},
|
|
36
|
+
"groq": {"wire": "openai", "base_url": "https://api.groq.com/openai/v1", "model": "openai/gpt-oss-120b"},
|
|
37
|
+
"grok": {"wire": "openai", "base_url": "https://api.x.ai/v1", "model": "grok-4.7"},
|
|
38
|
+
"openrouter": {"wire": "openai", "base_url": "https://openrouter.ai/api/v1", "model": "deepseek/deepseek-v4.1-flash"},
|
|
39
|
+
"ollama": {"wire": "openai", "base_url": "http://127.0.0.1:11434/v1", "model": "qwen3-coder"},
|
|
40
|
+
"anthropic": {"wire": "anthropic", "base_url": "https://api.anthropic.com/v1", "model": "claude-sonnet-5-5"},
|
|
39
41
|
"minimax": {"wire": "anthropic", "base_url": "https://api.minimax.io/anthropic/v1", "model": "MiniMax-M3"},
|
|
40
42
|
-- Z.ai (Zhipu), API compatible con OpenAI, dos presets con la MISMA key (es la misma cuenta):
|
|
41
43
|
-- `glm` = pago por uso (saldo prepago); `glm-coding` = GLM Coding Plan (suscripción), que solo vale
|
|
@@ -284,12 +286,13 @@ export task supports_vision(cfg)
|
|
|
284
286
|
give true
|
|
285
287
|
when p == "groq"
|
|
286
288
|
give contains(m, "llama-4") or contains(m, "vision")
|
|
289
|
+
-- DeepSeek V4.1-Flash (2026-09-10) es multimodal nativo; deepseek-v4-flash quedó como alias que va a él
|
|
287
290
|
when p == "deepseek"
|
|
288
|
-
give contains(m, "vision")
|
|
291
|
+
give contains(m, "vision") or contains(m, "flash")
|
|
289
292
|
when p == "openai"
|
|
290
|
-
give starts_with(m, "gpt-4o") or starts_with(m, "gpt-4.1") or starts_with(m, "gpt-5") or starts_with(m, "o1") or starts_with(m, "o3") or starts_with(m, "o4")
|
|
293
|
+
give starts_with(m, "gpt-4o") or starts_with(m, "gpt-4.1") or starts_with(m, "gpt-5") or starts_with(m, "gpt-6") or starts_with(m, "o1") or starts_with(m, "o3") or starts_with(m, "o4")
|
|
291
294
|
when p == "openrouter" or p == "ollama"
|
|
292
|
-
give contains(m, "vision") or contains(m, "vl") or contains(m, "gpt-4o") or contains(m, "gpt-5") or contains(m, "claude") or contains(m, "gemini") or contains(m, "llava") or contains(m, "pixtral") or contains(m, "qwen2.5vl") or contains(m, "qwen3-vl")
|
|
295
|
+
give contains(m, "vision") or contains(m, "vl") or contains(m, "gpt-4o") or contains(m, "gpt-5") or contains(m, "gpt-6") or contains(m, "claude") or contains(m, "gemini") or contains(m, "llava") or contains(m, "pixtral") or contains(m, "qwen2.5vl") or contains(m, "qwen3-vl")
|
|
293
296
|
when p == "grok"
|
|
294
297
|
give contains(m, "vision") or starts_with(m, "grok-4")
|
|
295
298
|
when p == "kimi"
|
|
@@ -307,7 +310,7 @@ task image_note(m)
|
|
|
307
310
|
each e in enumerate(m["images"])
|
|
308
311
|
let im be e["item"]
|
|
309
312
|
let dims be when contains(im, "w") then " " + text(floor(im["w"])) + "x" + text(floor(im["h"])) + "px" otherwise ""
|
|
310
|
-
set notes to append(notes, "[Image " + text(e["index"] + 1) + dims + " attached, but this model does not accept image input — tell the user to switch to a vision model (e.g. anthropic or gpt-
|
|
313
|
+
set notes to append(notes, "[Image " + text(e["index"] + 1) + dims + " attached, but this model does not accept image input — tell the user to switch to a vision model (e.g. anthropic or gpt-6.1-sol) if they need it read]")
|
|
311
314
|
give m["content"] + "\n" + join(notes, "\n")
|
|
312
315
|
|
|
313
316
|
-- Handle textual junto a cada imagen (patrón de hermes/deepseek): el modelo sabe cuántas hay y de qué tamaño.
|
package/lib/runtime.syn
CHANGED
|
@@ -447,6 +447,13 @@ export task thread_session(agent, thread)
|
|
|
447
447
|
give ""
|
|
448
448
|
give ""
|
|
449
449
|
|
|
450
|
+
-- la próxima entrega a (agente, thread) arranca una conversación nueva
|
|
451
|
+
export task forget_thread(agent, thread)
|
|
452
|
+
require time
|
|
453
|
+
require file(".lampson")
|
|
454
|
+
require file(".lampson/*")
|
|
455
|
+
remember_thread(agent, thread, "")
|
|
456
|
+
|
|
450
457
|
task remember_thread(agent, thread, sid)
|
|
451
458
|
require time
|
|
452
459
|
require file(".lampson")
|
|
@@ -509,6 +516,11 @@ export task open(sobre, hooks)
|
|
|
509
516
|
-- en un equipo con git, cada agente en su copia (lib/worktree.syn); "worktrees": false en el equipo lo apaga
|
|
510
517
|
when starts_with(thread, "team:")
|
|
511
518
|
let tm be teams.get(slice(thread, 5, length(thread)))
|
|
519
|
+
-- un asiento que no es el líder no le abre aprobaciones a la persona: van a su jefe (lib/loop.syn)
|
|
520
|
+
when tm != nothing
|
|
521
|
+
let mine be teams.member(tm, ctx["agent"])
|
|
522
|
+
when mine != nothing and ctx["agent"] != teams.lead_of(tm) and mine["reports_to"] != ""
|
|
523
|
+
set copts["escalate_to"] to mine["reports_to"]
|
|
512
524
|
when tm != nothing and tm["worktrees"]
|
|
513
525
|
let me be teams.member(tm, ctx["agent"])
|
|
514
526
|
let wt be worktree.ensure(tm["id"], ctx["agent"], {"name": (when me != nothing and me["role"] != ctx["agent"] then me["role"] + " · " + ctx["agent"] otherwise ctx["agent"]) + " (Lampson)", "email": ctx["agent"] + "@lampson.local"})
|
|
@@ -539,6 +551,35 @@ export task save(o, messages)
|
|
|
539
551
|
session.save(o["session"], messages, {"title": session.title_of(messages), "agent": o["ctx"]["agent"], "thread": o["thread"]})
|
|
540
552
|
remember_thread(o["ctx"]["agent"], o["thread"], o["session"])
|
|
541
553
|
|
|
554
|
+
-- la vista en vivo de un objetivo (public/js/objlive.js): cada paso de un asiento de equipo u objetivo sale al bus
|
|
555
|
+
-- ("team.step") en el momento, compacto — el detalle completo sigue en la traza
|
|
556
|
+
task live(th, agent, kind, data)
|
|
557
|
+
require time
|
|
558
|
+
when not (starts_with(th, "team:") or starts_with(th, "objective:"))
|
|
559
|
+
give false
|
|
560
|
+
let d be nothing
|
|
561
|
+
when kind == "busy"
|
|
562
|
+
set d to {"label": slice(text(field(data, "label", "")), 0, 200), "what": field(data, "kind", ""), "name": field(data, "name", "")}
|
|
563
|
+
otherwise when kind == "tool_call"
|
|
564
|
+
set d to {"name": data["name"], "args": slice(json_encode(data["args"]), 0, 1500)}
|
|
565
|
+
otherwise when kind == "tool_result"
|
|
566
|
+
let out be text(data["output"])
|
|
567
|
+
set d to {"name": data["call"]["name"], "ok": not (starts_with(out, "ERROR") or starts_with(out, "DENIED") or starts_with(out, "NOT RUN")), "out": slice(out, 0, 200)}
|
|
568
|
+
otherwise when kind == "tool_denied"
|
|
569
|
+
set d to {"name": data["call"]["name"], "reason": slice(text(data["reason"]), 0, 200)}
|
|
570
|
+
otherwise when kind == "assistant"
|
|
571
|
+
set d to {"text": slice(text(data), 0, 400)}
|
|
572
|
+
otherwise when kind == "usage"
|
|
573
|
+
let u be data["usage"]
|
|
574
|
+
let cached be field(u, "cached", 0)
|
|
575
|
+
set d to {"cost": u["input"] - cached + floor(cached / 10) + u["output"]}
|
|
576
|
+
otherwise when kind == "turn_start" or kind == "turn_end" or kind == "idle"
|
|
577
|
+
set d to {}
|
|
578
|
+
when d == nothing
|
|
579
|
+
give false
|
|
580
|
+
bus_publish("team.step", {"scope": th, "agent": agent, "kind": kind, "data": d, "at": now()})
|
|
581
|
+
give true
|
|
582
|
+
|
|
542
583
|
-- corre UN turno sobre mensajes ya armados (el del usuario ya agregado): traza, run_turn, guarda.
|
|
543
584
|
-- o: {ctx: {cfg, opts, agent}, session, thread} — lo que devuelve open(), o lo que arma la terminal.
|
|
544
585
|
-- label: lo que se anota como turno del usuario en la traza ("" = el último mensaje de usuario).
|
|
@@ -565,8 +606,11 @@ export task turn(o, messages, label, hooks)
|
|
|
565
606
|
require secret("LAMPSON_*")
|
|
566
607
|
let sid be o["session"]
|
|
567
608
|
let user_cb be field(hooks, "on_event", nothing)
|
|
609
|
+
let th0 be text(field(o, "thread", ""))
|
|
610
|
+
let me be o["ctx"]["agent"]
|
|
568
611
|
task on_event(kind, data, tag)
|
|
569
612
|
trace.event(sid, kind, data, tag)
|
|
613
|
+
live(th0, me, kind, data)
|
|
570
614
|
when user_cb != nothing
|
|
571
615
|
call(user_cb, {"kind": kind, "data": data, "tag": tag})
|
|
572
616
|
let said be label
|
|
@@ -576,14 +620,21 @@ export task turn(o, messages, label, hooks)
|
|
|
576
620
|
set said to text(m["content"])
|
|
577
621
|
let cfg be o["ctx"]["cfg"]
|
|
578
622
|
trace.user(sid, said, o["ctx"]["agent"], o["ctx"]["opts"]["permission_mode"], cfg["model"])
|
|
623
|
+
live(th0, me, "turn_start", nothing)
|
|
624
|
+
when starts_with(th0, "team:")
|
|
625
|
+
let oid be teams.objective_of_scope(th0)
|
|
626
|
+
when oid != 0
|
|
627
|
+
teams.seat_session(oid, me, sid)
|
|
579
628
|
let result be loop.run_turn(cfg, messages, o["ctx"]["opts"], on_event)
|
|
580
629
|
trace.turn_end(sid, result)
|
|
630
|
+
live(th0, me, "turn_end", nothing)
|
|
581
631
|
-- presupuesto de equipos: lo que gastó este turno (los cacheados pesan 10%, como en el loop)
|
|
582
632
|
let cost be result["usage"]["input"] - result["usage"]["cached"] + floor(result["usage"]["cached"] / 10) + result["usage"]["output"]
|
|
583
633
|
let th be text(field(o, "thread", ""))
|
|
584
634
|
when starts_with(th, "team:")
|
|
585
635
|
teams.record_spend(o["ctx"]["agent"], cost)
|
|
586
636
|
teams.team_turn_end(slice(th, 5, length(th)), o["ctx"]["agent"], cost)
|
|
637
|
+
teams.seat_turn_end(slice(th, 5, length(th)), o["ctx"]["agent"], field(result, "stopped", "done"), field(result, "text", ""))
|
|
587
638
|
when starts_with(th, "objective:")
|
|
588
639
|
teams.obj_turn_end(floor(number(slice(th, 10, length(th)))), cost)
|
|
589
640
|
save(o, result["messages"])
|
|
@@ -626,5 +677,10 @@ export task deliver(sobre, hooks)
|
|
|
626
677
|
let images be field(sobre, "images", [])
|
|
627
678
|
when length(images) > 0
|
|
628
679
|
set umsg to {"role": "user", "content": msg, "images": images}
|
|
680
|
+
let t0 be now()
|
|
629
681
|
let result be turn(o, append(o["messages"], umsg), msg, hooks)
|
|
682
|
+
-- en un equipo, la respuesta final no la lee nadie: si el asiento no mandó nada, se le reenvía a quien lo despertó
|
|
683
|
+
let th be text(o["thread"])
|
|
684
|
+
when starts_with(th, "team:")
|
|
685
|
+
teams.forward_final(slice(th, 5, length(th)), o["ctx"]["agent"], text(field(field(sobre, "meta", {}), "from", "")), field(result, "stopped", "done"), field(result, "text", ""), t0, msg)
|
|
630
686
|
give {"agent": o["ctx"]["agent"], "thread": o["thread"], "session": sid, "text": result["text"], "steps": result["steps"], "usage": result["usage"], "stopped": result["stopped"]}
|
package/lib/schedule.syn
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
-- lib/schedule.syn — tareas programadas: "cada 6 h", "todos los días a las 9", "lunes 8:30"
|
|
2
2
|
--
|
|
3
3
|
-- Qué se programa (action.type):
|
|
4
|
+
-- objective → una RUTINA de un equipo: {team, text, budget_tokens?, round_seconds?}. Cada vez que le toca crea un
|
|
5
|
+
-- objetivo normal para el líder del equipo (created_by = "rutina:<id de la tarea>": así se ven sus
|
|
6
|
+
-- ejecuciones). Si la ejecución anterior sigue abierta, esta se saltea — no se amontonan objetivos.
|
|
4
7
|
-- plugin → una tool de un plugin ENCENDIDO: {plugin, tool, args}. Encenderlo ya fue la autorización.
|
|
5
8
|
-- bash → un comando fijo desde el workspace: {command, timeout}. Aprobado UNA vez, al crear la tarea.
|
|
6
9
|
-- prompt → una corrida completa del agente con un texto: {prompt, agent}. Sin humano al lado: corre con el
|
|
@@ -28,6 +31,7 @@ use "./permission.syn" as permission
|
|
|
28
31
|
use "./tools/common.syn" as c
|
|
29
32
|
use "./tools/memo.syn" as memo
|
|
30
33
|
use "./settings.syn" as settings
|
|
34
|
+
use "./teams.syn" as teams
|
|
31
35
|
|
|
32
36
|
export let FILE be ".lampson/schedules.json"
|
|
33
37
|
export let LOG_DIR be ".lampson/schedules"
|
|
@@ -380,11 +384,18 @@ task slug(name)
|
|
|
380
384
|
-- valida y normaliza la acción → {ok, action, error}
|
|
381
385
|
task check_action(action)
|
|
382
386
|
when action == nothing or not contains(action, "type")
|
|
383
|
-
give {"ok": false, "error": "action needs a type: plugin | bash | prompt"}
|
|
387
|
+
give {"ok": false, "error": "action needs a type: objective | plugin | bash | prompt"}
|
|
384
388
|
let kind be lower(text(action["type"]))
|
|
385
389
|
when kind == "lamp"
|
|
386
390
|
-- compat: "lamp" era el nombre de "plugin" hasta 2026-09 (tareas guardadas, JSON escrito a mano)
|
|
387
391
|
set kind to "plugin"
|
|
392
|
+
when kind == "objective"
|
|
393
|
+
let tid be lower(text(when contains(action, "team") then action["team"] otherwise ""))
|
|
394
|
+
when tid == "" or teams.get(tid) == nothing
|
|
395
|
+
give {"ok": false, "error": "action objective needs the id of a team of this project (got '" + tid + "')"}
|
|
396
|
+
when not contains(action, "text") or trim(text(action["text"])) == ""
|
|
397
|
+
give {"ok": false, "error": "action objective needs the text of the objective"}
|
|
398
|
+
give {"ok": true, "action": {"type": "objective", "team": tid, "text": trim(text(action["text"])), "budget_tokens": floor(number(when contains(action, "budget_tokens") and action["budget_tokens"] != nothing then action["budget_tokens"] otherwise 600000)), "round_seconds": floor(number(when contains(action, "round_seconds") and action["round_seconds"] != nothing then action["round_seconds"] otherwise 60)), "pass_ask": when contains(action, "pass_ask") then action["pass_ask"] == true otherwise false}}
|
|
388
399
|
when kind == "plugin"
|
|
389
400
|
let pname be plugin_of(action)
|
|
390
401
|
when pname == "" or not contains(action, "tool")
|
|
@@ -409,7 +420,7 @@ task check_action(action)
|
|
|
409
420
|
when not contains(["build", "plan", "review", "explore"], agent)
|
|
410
421
|
give {"ok": false, "error": "agent must be build | plan | review | explore"}
|
|
411
422
|
give {"ok": true, "action": {"type": "prompt", "prompt": text(action["prompt"]), "agent": agent}}
|
|
412
|
-
give {"ok": false, "error": "unknown action type '" + kind + "' (plugin | bash | prompt)"}
|
|
423
|
+
give {"ok": false, "error": "unknown action type '" + kind + "' (objective | plugin | bash | prompt)"}
|
|
413
424
|
|
|
414
425
|
-- crear: spec = {name, when, action, permission?, approval_timeout?, notify?} → la tarea (raise si es inválida)
|
|
415
426
|
export task add(spec)
|
|
@@ -466,6 +477,9 @@ task is_plugin_action(a)
|
|
|
466
477
|
give a["type"] == "plugin" or a["type"] == "lamp"
|
|
467
478
|
|
|
468
479
|
task default_name(action)
|
|
480
|
+
when action["type"] == "objective"
|
|
481
|
+
let o be replace(action["text"], "\n", " ")
|
|
482
|
+
give when length(o) > 40 then slice(o, 0, 40) + "…" otherwise o
|
|
469
483
|
when is_plugin_action(action)
|
|
470
484
|
give plugin_of(action) + " " + action["tool"]
|
|
471
485
|
when action["type"] == "bash"
|
|
@@ -561,6 +575,8 @@ export task run_simple(t)
|
|
|
561
575
|
require file("workspace")
|
|
562
576
|
require file("workspace/*")
|
|
563
577
|
let a be t["action"]
|
|
578
|
+
when a["type"] == "objective"
|
|
579
|
+
give run_routine(t)
|
|
564
580
|
when is_plugin_action(a)
|
|
565
581
|
give plugins.call(plugins.tool_name(plugin_of(a), a["tool"]), a["args"])
|
|
566
582
|
when a["type"] == "bash"
|
|
@@ -653,8 +669,30 @@ export task log_tail(id, n)
|
|
|
653
669
|
recover err
|
|
654
670
|
give ""
|
|
655
671
|
|
|
672
|
+
-- una ejecución de una rutina: un objetivo para el líder del equipo, salvo que la anterior siga abierta
|
|
673
|
+
export let ROUTINE_PREFIX be "rutina:"
|
|
674
|
+
export task run_routine(t)
|
|
675
|
+
require db(".lampson/teams.db")
|
|
676
|
+
require time
|
|
677
|
+
require file(".lampson")
|
|
678
|
+
require file(".lampson/*")
|
|
679
|
+
require file.read("workspace")
|
|
680
|
+
require file.read("workspace/*")
|
|
681
|
+
let a be t["action"]
|
|
682
|
+
let tm be teams.get(a["team"])
|
|
683
|
+
when tm == nothing
|
|
684
|
+
give "ERROR: team '" + a["team"] + "' no longer exists in this project"
|
|
685
|
+
let mine be ROUTINE_PREFIX + t["id"]
|
|
686
|
+
let still be where(teams.obj_list(), (o) => o["created_by"] == mine and contains(["active", "waiting", "paused"], o["status"]))
|
|
687
|
+
when length(still) > 0
|
|
688
|
+
give "SKIPPED: the previous run (O-" + text(still[0]["id"]) + ") is still open"
|
|
689
|
+
let id be teams.obj_create(teams.lead_of(tm), a["text"], {"team": tm["id"], "budget_tokens": a["budget_tokens"], "round_seconds": a["round_seconds"], "created_by": mine, "pass_ask": when contains(a, "pass_ask") then a["pass_ask"] == true otherwise false})
|
|
690
|
+
give "O-" + text(id) + " → team " + tm["id"]
|
|
691
|
+
|
|
656
692
|
-- descripción de la acción (una línea) para previews y listados
|
|
657
693
|
export task describe_action(a)
|
|
694
|
+
when a["type"] == "objective"
|
|
695
|
+
give "objective for team " + a["team"] + ": " + one_line(a["text"], 140)
|
|
658
696
|
when is_plugin_action(a)
|
|
659
697
|
give "plugin " + plugin_of(a) + "." + a["tool"] + (when length(keys(a["args"])) > 0 then " " + one_line(json_encode(a["args"]), 80) otherwise "")
|
|
660
698
|
when a["type"] == "bash"
|
package/lib/teamrun.syn
CHANGED
|
@@ -11,8 +11,11 @@
|
|
|
11
11
|
use "./teams.syn" as teams
|
|
12
12
|
use "./mailbox.syn" as mailbox
|
|
13
13
|
use "./runtime.syn" as runtime
|
|
14
|
+
use "./approvals.syn" as approvals
|
|
14
15
|
|
|
15
16
|
export let TICK_SECONDS be 3
|
|
17
|
+
-- lo que el hub muestra de este workspace (inicio, /equipos) sin abrir su base: equipos, objetivos y lo que espera
|
|
18
|
+
export let SUMMARY_FILE be ".lampson/teams-summary.json"
|
|
16
19
|
export let ROUND_TEXT be "[round] Your periodic round: look at your open tasks and the team's news above, and move your work forward. If there is nothing for you to do, reply with one short line and stop — don't invent work."
|
|
17
20
|
|
|
18
21
|
task flag_budget(team, agent)
|
|
@@ -23,7 +26,7 @@ task flag_budget(team, agent)
|
|
|
23
26
|
let k be "teams:budget:" + team["id"] + ":" + agent + ":" + format_time(now(), "%Y-%m-%d")
|
|
24
27
|
when state_get(k) == nothing
|
|
25
28
|
state_set(k, true)
|
|
26
|
-
teams.log("team:" + team["id"], agent, "budget", "", "daily budget reached (" + text(team
|
|
29
|
+
teams.log("team:" + team["id"], agent, "budget", "", "daily budget reached (" + text(teams.cap_of(team, agent)) + " tokens): no more turns today")
|
|
27
30
|
|
|
28
31
|
-- un turno para `agent` en su conversación del equipo
|
|
29
32
|
export task deliver_to(team, agent, sender, head)
|
|
@@ -40,7 +43,18 @@ export task deliver_to(team, agent, sender, head)
|
|
|
40
43
|
when spec == nothing
|
|
41
44
|
teams.log("team:" + team["id"], "lampson", "error", "", "no agent file for '" + agent + "' — create .lampson/agents/" + agent + ".agent.json")
|
|
42
45
|
give false
|
|
43
|
-
|
|
46
|
+
-- su primer turno en un objetivo: conversación nueva (el tablero, el registro y git ya cuentan lo anterior)
|
|
47
|
+
let oid be teams.objective_of_scope("team:" + team["id"])
|
|
48
|
+
when oid != 0 and teams.seat_session_of(oid, agent) == ""
|
|
49
|
+
runtime.forget_thread(agent, "team:" + team["id"])
|
|
50
|
+
-- quién está en medio de un turno: sus mensajes le llegan cuando termina. (Visto 2026-10-17: el CEO le preguntó
|
|
51
|
+
-- tres veces al CMO, que estaba documentando, no le contestó, y le pasó su tarea al CTO: los dos hicieron lo mismo.)
|
|
52
|
+
let busy be []
|
|
53
|
+
each m in team["members"]
|
|
54
|
+
when m["agent"] != agent and mailbox.working(m["agent"], "team:" + team["id"])
|
|
55
|
+
set busy to append(busy, m["agent"])
|
|
56
|
+
let now_line be when length(busy) == 0 then "" otherwise "\nWorking right now (your messages reach them when their turn ends — wait for them, don't reassign their tasks): " + join(busy, ", ")
|
|
57
|
+
let sobre be {"to": agent, "thread": "team:" + team["id"], "session": "", "from": sender, "text": teams.turn_text(team, agent, head) + now_line, "images": [], "channel": "team", "meta": {"team": team["id"], "from": sender}}
|
|
44
58
|
mailbox.submit(sobre, {"mode": when spec["permission"] != "" then "" otherwise "strict", "buffer": mailbox.buffer_of(spec, false)})
|
|
45
59
|
give true
|
|
46
60
|
|
|
@@ -94,10 +108,66 @@ export task objective_due(o)
|
|
|
94
108
|
give false
|
|
95
109
|
-- en un equipo, el líder solo hace ronda si algo cambió o tiene tareas propias (si no, está esperando a los demás)
|
|
96
110
|
when o["team"] != ""
|
|
97
|
-
|
|
111
|
+
when teams.has_work("team:" + o["team"], o["agent"])
|
|
112
|
+
give true
|
|
113
|
+
-- nadie se mueve hace rato: el líder recibe UNA ronda para destrabar (y otra si sigue igual, STALL_SECONDS después)
|
|
114
|
+
when stalled(o)
|
|
115
|
+
teams.obj_set(o["id"], {"reply": STALL_TEXT})
|
|
116
|
+
give true
|
|
117
|
+
give false
|
|
98
118
|
give true
|
|
99
119
|
|
|
120
|
+
export let STALL_SECONDS be 600
|
|
121
|
+
export let STALL_TEXT be "[stalled] Nothing has moved in the team for 10 minutes and nobody is working. Look at the board: is someone waiting for something, or did someone stop without saying? Unblock it (`send` them what they need; reassign only if they said they are blocked) or, if the team can't go on, ask the person with `objective` ask."
|
|
122
|
+
|
|
123
|
+
-- ¿el equipo de un objetivo está quieto? nadie trabajando, ningún mensaje por entregar y nada en el registro hace rato
|
|
124
|
+
task stalled(o)
|
|
125
|
+
require db(".lampson/teams.db")
|
|
126
|
+
require file(".lampson")
|
|
127
|
+
require file(".lampson/*")
|
|
128
|
+
require file.read("workspace")
|
|
129
|
+
require file.read("workspace/*")
|
|
130
|
+
require time
|
|
131
|
+
let tm be teams.get(o["team"])
|
|
132
|
+
when tm == nothing or now() - o["last_end"] < STALL_SECONDS
|
|
133
|
+
give false
|
|
134
|
+
each m in tm["members"]
|
|
135
|
+
when mailbox.working(m["agent"], "team:" + tm["id"])
|
|
136
|
+
give false
|
|
137
|
+
give teams.quiet_for("team:" + tm["id"]) >= STALL_SECONDS
|
|
138
|
+
|
|
139
|
+
-- escribe el resumen si cambió: equipos, objetivos abiertos (y los últimos cerrados) y aprobaciones pendientes
|
|
140
|
+
export task write_summary()
|
|
141
|
+
require db(".lampson/teams.db")
|
|
142
|
+
require time
|
|
143
|
+
require net
|
|
144
|
+
require env("LAMPSON_*")
|
|
145
|
+
require file(".lampson")
|
|
146
|
+
require file(".lampson/*")
|
|
147
|
+
require file.read("workspace")
|
|
148
|
+
require file.read("workspace/*")
|
|
149
|
+
-- roles: lo que /equipos del hub muestra de cada equipo (el rol, o el id del agente si no tiene)
|
|
150
|
+
let ts be apply(teams.all(), (t) => {"id": t["id"], "name": t["name"], "description": t["description"], "members": length(t["members"]), "lead": teams.lead_of(t), "roles": apply(t["members"], (m) => when contains(m, "role") and m["role"] != nothing and text(m["role"]) != "" then text(m["role"]) otherwise text(m["agent"]))})
|
|
151
|
+
let objs be teams.obj_list()
|
|
152
|
+
let open_o be where(objs, (o) => contains(["active", "waiting", "paused"], o["status"]))
|
|
153
|
+
let closed be slice(where(objs, (o) => not contains(["active", "waiting", "paused"], o["status"])), 0, 5)
|
|
154
|
+
let brief be apply(open_o + closed, (o) => {"id": o["id"], "ref": "O-" + text(o["id"]), "agent": o["agent"], "team": o["team"], "text": slice(o["text"], 0, 240), "status": o["status"], "question": o["question"], "question_kind": o["question_kind"], "progress": slice(o["progress"], 0, 240), "spent": o["spent"], "updated_at": o["updated_at"]})
|
|
155
|
+
let aps be []
|
|
156
|
+
try
|
|
157
|
+
set aps to apply(approvals.pending(), (a) => {"id": a["id"], "message": a["message"], "why": a["why"], "created": a["created"]})
|
|
158
|
+
recover err
|
|
159
|
+
set aps to []
|
|
160
|
+
let body be {"teams": ts, "objectives": brief, "approvals": aps, "active": length(where(open_o, (o) => o["status"] == "active")), "waiting": length(where(open_o, (o) => o["status"] == "waiting")) + length(aps)}
|
|
161
|
+
let enc be json_encode(body)
|
|
162
|
+
when state_get("teams:summary:last", "") != enc
|
|
163
|
+
state_set("teams:summary:last", enc)
|
|
164
|
+
set body["updated"] to now()
|
|
165
|
+
write_file(SUMMARY_FILE, json_encode(body))
|
|
166
|
+
give body
|
|
167
|
+
|
|
100
168
|
export task tick()
|
|
169
|
+
require net
|
|
170
|
+
require env("LAMPSON_*")
|
|
101
171
|
require db(".lampson/teams.db")
|
|
102
172
|
require time
|
|
103
173
|
require random
|
|
@@ -108,6 +178,10 @@ export task tick()
|
|
|
108
178
|
require file.read("agents")
|
|
109
179
|
require file.read("agents/*")
|
|
110
180
|
let n be 0
|
|
181
|
+
try
|
|
182
|
+
write_summary()
|
|
183
|
+
recover err
|
|
184
|
+
set n to 0
|
|
111
185
|
each o in teams.obj_list()
|
|
112
186
|
when objective_due(o)
|
|
113
187
|
when deliver_objective(o)
|
|
@@ -126,7 +200,7 @@ export task tick()
|
|
|
126
200
|
flag_budget(team, m["recipient"])
|
|
127
201
|
otherwise
|
|
128
202
|
let who be teams.member(team, m["sender"])
|
|
129
|
-
let head be "[message from " + m["sender"] + (when who != nothing then " (" + who["role"] + ")" otherwise "") + "]\n" + m["text"]
|
|
203
|
+
let head be when m["sender"] == "person" then "[message from the person who owns this team — act on it]\n" + m["text"] otherwise "[message from " + m["sender"] + (when who != nothing then " (" + who["role"] + ")" otherwise "") + "]\n" + m["text"]
|
|
130
204
|
when deliver_to(team, m["recipient"], m["sender"], head)
|
|
131
205
|
teams.mark(m["id"], "delivered")
|
|
132
206
|
set n to n + 1
|