lampson 0.2.10 → 0.4.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 +52 -1
- package/bin/lampson.js +2 -2
- package/chat.syn +40 -24
- package/cli.syn +6 -3
- package/hub.tpl.syn +15 -0
- package/lampson.ps1 +85 -11
- package/lampson.sh +82 -24
- package/lib/api.syn +292 -0
- package/lib/apikeys.syn +115 -0
- package/lib/approvals.syn +7 -0
- package/lib/channels.syn +340 -0
- package/lib/loop.syn +77 -3
- package/lib/mailbox.syn +440 -0
- package/lib/mcp.syn +128 -9
- package/lib/mcp_server.syn +235 -0
- package/lib/plugins.syn +94 -7
- package/lib/runtime.syn +630 -0
- package/lib/scope.syn +62 -0
- package/lib/session.syn +11 -1
- package/lib/teamrun.syn +142 -0
- package/lib/teams.syn +802 -0
- package/lib/tools.syn +1 -1
- package/lib/workspaces.syn +78 -3
- package/lib/worktree.syn +105 -0
- package/package.json +16 -2
- package/plugins/chatwoot/plugin.json +11 -0
- package/plugins/chatwoot/plugin.syn +143 -0
- package/plugins/orders/INSTRUCTIONS.md +16 -0
- package/plugins/orders/plugin.json +81 -0
- package/plugins/orders/plugin.syn +342 -0
- package/plugins/telegram/plugin.json +11 -0
- package/plugins/telegram/plugin.syn +272 -0
- package/public/css/panel.css +2 -0
- package/public/css/teams.css +159 -0
- package/public/index.html +10 -0
- package/public/js/app.js +1 -1
- package/public/js/engine.js +149 -0
- package/public/js/sessions.js +5 -1
- package/public/js/teams.js +301 -0
- package/public/teams.html +75 -0
- package/run.syn +493 -0
- package/sdk/index.d.ts +94 -0
- package/sdk/index.js +250 -0
- package/sdk/index.mjs +4 -0
- package/web.syn +428 -47
package/README.md
CHANGED
|
@@ -87,13 +87,64 @@ Turn it on with `/plugins on postgres` or the **plugins** pill in the web UI. Ke
|
|
|
87
87
|
or inside a project (`.lampson/plugins/` — commit it and your team has it). The agent can *write* a plugin for you;
|
|
88
88
|
turning it on is always yours.
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
A plugin can also bring **instructions** (`INSTRUCTIONS.md` in its folder): how to use its tools — a backend
|
|
91
|
+
process, "read the `release` skill first", a long precise prompt. Lampson adds them to the prompt of every agent
|
|
92
|
+
that has the plugin's tools.
|
|
93
|
+
|
|
94
|
+
→ [How plugins work](https://lampson.org/docs/plugins) · the example ships in `plugins/example-hello/` · a complete
|
|
95
|
+
one, `plugins/orders/`, takes orders by chat end to end → [recipe](https://lampson.org/docs/orders).
|
|
91
96
|
|
|
92
97
|
Plugins are yours and local: any language, no sandbox unless you write them in Synsema. For tools with an
|
|
93
98
|
**enforced capability ceiling**, versioned and shared with any agent (Claude Code, Cursor, Lampson…), use
|
|
94
99
|
[lamps.sh](https://lamps.sh): `lamp add <ref>`, then `lamp mcp` as an MCP server in Lampson. (Until 0.2.6
|
|
95
100
|
plugins were called *lamps*; old `.lampson/lamps/` folders and `LAMP_*` variables still work for now.)
|
|
96
101
|
|
|
102
|
+
## Use it from your app
|
|
103
|
+
|
|
104
|
+
Lampson's agents also work **inside other software**, as an engine: a bot that answers your shop's customers, your
|
|
105
|
+
backend asking an agent something, another AI using your agents as a tool.
|
|
106
|
+
|
|
107
|
+
```sh
|
|
108
|
+
lampson key add --agent shop # an API key for your app (rate limit, allowed callbacks)
|
|
109
|
+
curl -X POST http://127.0.0.1:8080/w/<workspace>/v1/messages -H "Authorization: Bearer lk_…" -d '{"to": "shop", "thread": "customer-42", "text": "do you have whole-wheat bread?"}'
|
|
110
|
+
lampson channel on telegram && lampson channel setup telegram # a Telegram bot — even without a public URL
|
|
111
|
+
lampson mcp serve --agent shop # your agent as a tool for Claude, Cursor or another Lampson
|
|
112
|
+
lampson run --agent shop "hi" # one message from a script; --json streams every step
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
import { Lampson } from "lampson"; // also: pip install lampson
|
|
117
|
+
const lampson = new Lampson({ local: { workspace: "./my-project" } }); // or { url, key } for a running Lampson
|
|
118
|
+
const r = await lampson.ask({ agent: "shop", thread: "customer-42", text: "do you have whole-wheat bread?" });
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
- **An agent is a file**: `.lampson/agents/shop.agent.json` (or `~/lampson/agents/` for every project) — its prompt,
|
|
122
|
+
the exact tools it may use (optionally limited to some paths, with per-tool approval) and its model.
|
|
123
|
+
- **One conversation per customer** (`thread`), and a mailbox per conversation: a burst of messages gets one
|
|
124
|
+
answer, and what arrives while the agent works joins the turn in progress.
|
|
125
|
+
- **Channels are plugins**: Telegram and Chatwoot (WhatsApp, Instagram, email…) ship with Lampson; anyone can write
|
|
126
|
+
another with two actions, `receive` and `send`.
|
|
127
|
+
- **Agent ↔ agent**: put another Lampson's `/v1/mcp` URL in your `mcp.json` and your agent can ask theirs.
|
|
128
|
+
|
|
129
|
+
Docs: **[lampson.org/docs/engine](https://lampson.org/docs/engine)**. Design and status: [spec/engine.md](spec/engine.md).
|
|
130
|
+
|
|
131
|
+
## Objectives and teams
|
|
132
|
+
|
|
133
|
+
Give an agent an **objective** and it works on it by itself until it's done: it plans on its board, works in
|
|
134
|
+
rounds, reports, and asks you before anything irreversible (merge, push, buy, send). Or give it to a **team**: agents
|
|
135
|
+
with roles (CEO, CTO, Dev…), each in its own git worktree with its own branch and author, coordinating through
|
|
136
|
+
messages and a shared board — and nothing reaches `main` without your approval.
|
|
137
|
+
|
|
138
|
+
```sh
|
|
139
|
+
lampson objective add "Add task priorities with tests; ask me before merging" --team company
|
|
140
|
+
lampson objective list · objective show 2 · objective reply 2 --approve · objective cancel 2
|
|
141
|
+
lampson team list
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
A full-screen view at `http://127.0.0.1:8080/w/<workspace>/equipos` (button **equipos** in the web UI) shows the
|
|
145
|
+
objectives, what waits for you, the team as a live graph, its board and its record — and lets you build the team.
|
|
146
|
+
→ **[lampson.org/docs/teams](https://lampson.org/docs/teams)**
|
|
147
|
+
|
|
97
148
|
## Also in the box
|
|
98
149
|
|
|
99
150
|
Sub-agents that work in parallel · skills (`SKILL.md` procedures, anything on [skills.sh](https://skills.sh)
|
package/bin/lampson.js
CHANGED
|
@@ -22,7 +22,7 @@ const home = process.env.LAMPSON_HOME || path.join(os.homedir(), 'lampson');
|
|
|
22
22
|
const marker = path.join(home, '.npm-installed');
|
|
23
23
|
|
|
24
24
|
// what gets copied into the home: the runtime, never state. Keep in sync with "files" in package.json.
|
|
25
|
-
const CODE = ['lib', 'public', 'skills', 'chat.syn', 'web.syn', 'hub.tpl.syn', 'edge.syn', 'cli.syn', 'lampson.ps1', 'lampson.sh', 'lampson.cmd', '.env.example', 'README.md', 'LICENSE'];
|
|
25
|
+
const CODE = ['lib', 'public', 'skills', 'chat.syn', 'run.syn', 'web.syn', 'hub.tpl.syn', 'edge.syn', 'cli.syn', 'lampson.ps1', 'lampson.sh', 'lampson.cmd', '.env.example', 'README.md', 'LICENSE'];
|
|
26
26
|
|
|
27
27
|
// copia un archivo; en unix, los scripts de shell y los .syn salen con LF aunque el paquete se haya armado
|
|
28
28
|
// en Windows (un CRLF en lampson.sh rompe bash: "set: pipefail\r: invalid option")
|
|
@@ -47,7 +47,7 @@ function sync() {
|
|
|
47
47
|
fs.mkdirSync(home, { recursive: true });
|
|
48
48
|
// the folders every workspace links to (lib/workspaces.syn LINKS): if `memory/` does not exist when the
|
|
49
49
|
// link is made, the link is born dangling and memory(write) fails with "No such file or directory"
|
|
50
|
-
for (const d of ['memory', 'plugins']) fs.mkdirSync(path.join(home, d), { recursive: true });
|
|
50
|
+
for (const d of ['memory', 'plugins', 'agents']) fs.mkdirSync(path.join(home, d), { recursive: true });
|
|
51
51
|
for (const item of CODE) {
|
|
52
52
|
const src = path.join(pkgDir, item);
|
|
53
53
|
if (!fs.existsSync(src)) continue;
|
package/chat.syn
CHANGED
|
@@ -18,6 +18,7 @@ require random
|
|
|
18
18
|
require env("LAMPSON_*")
|
|
19
19
|
require env("OS")
|
|
20
20
|
require secret("LAMPSON_*")
|
|
21
|
+
require db(".lampson/teams.db")
|
|
21
22
|
require judge
|
|
22
23
|
require file("workspace")
|
|
23
24
|
require file("workspace/*")
|
|
@@ -25,6 +26,8 @@ require file.read("skills")
|
|
|
25
26
|
require file.read("skills/*")
|
|
26
27
|
require file.read("plugins")
|
|
27
28
|
require file.read("plugins/*")
|
|
29
|
+
require file.read("agents")
|
|
30
|
+
require file.read("agents/*")
|
|
28
31
|
require file("memory")
|
|
29
32
|
require file("memory/*")
|
|
30
33
|
require file(".lampson")
|
|
@@ -58,6 +61,7 @@ use "./lib/sched_run.syn" as sched_run
|
|
|
58
61
|
use "./lib/approvals.syn" as approvals
|
|
59
62
|
use "./lib/computer.syn" as computer
|
|
60
63
|
use "./lib/judge.syn" as jdg
|
|
64
|
+
use "./lib/runtime.syn" as runtime
|
|
61
65
|
|
|
62
66
|
-- ---------- UI de terminal ----------
|
|
63
67
|
-- Colores ANSI (Windows Terminal, PowerShell 7, cualquier terminal moderna). LAMPSON_NO_COLOR=1 los apaga.
|
|
@@ -255,8 +259,8 @@ task busy_off()
|
|
|
255
259
|
set waited to waited + 1
|
|
256
260
|
|
|
257
261
|
-- tag = "" para el agente principal; los subagentes en background NO pasan por acá (escriben su log)
|
|
262
|
+
-- el runtime (runtime.turn) ya trazó cada evento en .lampson/trace/<sid>.log: acá solo se dibuja
|
|
258
263
|
task on_event(kind, data, tag)
|
|
259
|
-
trace.event(sid, kind, data, tag)
|
|
260
264
|
when kind == "busy"
|
|
261
265
|
busy_on(data["label"], data["kind"])
|
|
262
266
|
otherwise when kind == "idle"
|
|
@@ -435,8 +439,8 @@ task complete_args(cmd, head, last)
|
|
|
435
439
|
give []
|
|
436
440
|
give apply((s) => s["id"], schedule.summary())
|
|
437
441
|
when cmd == "/agent"
|
|
438
|
-
--
|
|
439
|
-
give
|
|
442
|
+
-- los elegibles por el usuario (integrados + workspace/.lampson/agents): `worker` es interno de delegate
|
|
443
|
+
give runtime.names()
|
|
440
444
|
give []
|
|
441
445
|
|
|
442
446
|
-- rutas del workspace que empiezan con el prefijo escrito (directorios con "/" final para seguir completando)
|
|
@@ -549,7 +553,7 @@ task show_config(cfg, ws, profile, mode, opts)
|
|
|
549
553
|
print("")
|
|
550
554
|
print(" proveedor " + cfg["provider"] + " (" + cfg["wire"] + " → " + cfg["base_url"] + ")")
|
|
551
555
|
print(" modelo " + cfg["model"] + " max_tokens " + text(cfg["max_tokens"]) + " timeout " + text(floor(cfg["timeout"])) + "s")
|
|
552
|
-
print(" agente " + profile + " tools: " + join(agents.tool_names(
|
|
556
|
+
print(" agente " + profile + " tools: " + join(agents.tool_names(runtime.get(profile)), ", "))
|
|
553
557
|
print(" permisos " + mode)
|
|
554
558
|
print(" límites " + text(opts["max_steps"]) + " pasos/turno · " + text(floor(opts["budget_tokens"])) + " tokens/turno · compacta a " + text(floor(opts["compact_at_tokens"])))
|
|
555
559
|
print(" workspace " + ws)
|
|
@@ -864,16 +868,27 @@ when not provider.configured() and cfg["provider"] != "ollama"
|
|
|
864
868
|
let env_info be agents.env_info(cfg)
|
|
865
869
|
let profile be lower(env("LAMPSON_AGENT", "build"))
|
|
866
870
|
-- `--agent worker` (o cualquier nombre desconocido): worker es interno de delegate, no un perfil de sesión
|
|
867
|
-
when not contains(
|
|
868
|
-
print("agente '" + profile + "' no disponible · disponibles: " + join(
|
|
871
|
+
when not contains(runtime.names(), profile)
|
|
872
|
+
print("agente '" + profile + "' no disponible · disponibles: " + join(runtime.names(), ", ") + " · uso build")
|
|
869
873
|
set profile to "build"
|
|
874
|
+
-- un agente del proyecto con "model" propio corre con ese modelo (los integrados y los que no dicen, con el configurado).
|
|
875
|
+
-- /model lo cambia para la sesión, como siempre.
|
|
876
|
+
task cfg_for_agent(p)
|
|
877
|
+
let spec be runtime.get(p)
|
|
878
|
+
when spec != nothing and (spec["model"]["provider"] != "" or spec["model"]["model"] != "")
|
|
879
|
+
give provider.config_for(spec["model"]["provider"], spec["model"]["model"])
|
|
880
|
+
give provider.config()
|
|
881
|
+
set cfg to cfg_for_agent(profile)
|
|
882
|
+
set env_info to agents.env_info(cfg)
|
|
883
|
+
-- agentes por lib/runtime.syn (integrados y los del proyecto): el system prompt se arma una vez por sesión/cambio
|
|
884
|
+
-- de agente (prompt cache); las opts en cada turno (catálogo fresco)
|
|
870
885
|
task system_for(p)
|
|
871
|
-
give
|
|
886
|
+
give runtime.system_for(p, cfg)
|
|
872
887
|
task opts_for(p, mode)
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
give
|
|
888
|
+
give runtime.opts_for(p, mode, ask_user)
|
|
889
|
+
-- lo que runtime.turn / runtime.save necesitan de esta terminal: agente, cfg, opts y la sesión actual
|
|
890
|
+
task turn_ctx()
|
|
891
|
+
give {"ctx": {"cfg": cfg, "opts": opts, "agent": profile}, "session": sid, "thread": ""}
|
|
877
892
|
|
|
878
893
|
-- Subagente en background: `agent Child` (lib/agents.syn) corre en un hilo con intérprete propio y solo
|
|
879
894
|
-- puede llamar tasks TOP-LEVEL de este programa — esta es su única puerta de entrada al harness.
|
|
@@ -901,6 +916,8 @@ agent Sched
|
|
|
901
916
|
require file.read("skills/*")
|
|
902
917
|
require file.read("plugins")
|
|
903
918
|
require file.read("plugins/*")
|
|
919
|
+
require file.read("agents")
|
|
920
|
+
require file.read("agents/*")
|
|
904
921
|
require file("memory")
|
|
905
922
|
require file("memory/*")
|
|
906
923
|
require file(".lampson")
|
|
@@ -1042,14 +1059,11 @@ while running
|
|
|
1042
1059
|
print("")
|
|
1043
1060
|
print(" " + cyan("✉ " + first_line(m, 140)))
|
|
1044
1061
|
set messages to append(messages, {"role": "user", "content": m})
|
|
1045
|
-
trace.user(sid, "(turno automático por aviso de subagente)", profile, mode, cfg["model"])
|
|
1046
1062
|
set opts to opts_for(profile, mode)
|
|
1047
|
-
let result be
|
|
1048
|
-
trace.turn_end(sid, result)
|
|
1063
|
+
let result be runtime.turn(turn_ctx(), messages, "(turno automático por aviso de subagente)", {"on_event": on_event})
|
|
1049
1064
|
set messages to result["messages"]
|
|
1050
1065
|
set total_usage to {"input": total_usage["input"] + result["usage"]["input"], "output": total_usage["output"] + result["usage"]["output"]}
|
|
1051
1066
|
print(dim(" ─── " + text(result["steps"]) + " pasos · " + fmt_tokens(result["usage"]["input"] + result["usage"]["output"]) + " tokens · turno automático por subagente"))
|
|
1052
|
-
session.save(sid, messages, {"title": session.title_of(messages)})
|
|
1053
1067
|
flush()
|
|
1054
1068
|
otherwise
|
|
1055
1069
|
let saved be settings.load()
|
|
@@ -1449,16 +1463,21 @@ while running
|
|
|
1449
1463
|
otherwise when starts_with(input, "/agent")
|
|
1450
1464
|
let want be trim(slice(input, 6, length(input)))
|
|
1451
1465
|
when want == ""
|
|
1452
|
-
print("agente=" + profile + " · disponibles: " + join(
|
|
1453
|
-
otherwise when contains(
|
|
1466
|
+
print("agente=" + profile + " · disponibles: " + join(runtime.names(), ", "))
|
|
1467
|
+
otherwise when contains(runtime.names(), want)
|
|
1454
1468
|
set profile to want
|
|
1469
|
+
let prev_model be cfg["provider"] + "/" + cfg["model"]
|
|
1470
|
+
set cfg to cfg_for_agent(profile)
|
|
1471
|
+
set env_info to agents.env_info(cfg)
|
|
1472
|
+
when cfg["provider"] + "/" + cfg["model"] != prev_model
|
|
1473
|
+
print("modelo=" + cfg["provider"] + "/" + cfg["model"] + " (el del agente " + profile + ")")
|
|
1455
1474
|
set system_msg to system_for(profile)
|
|
1456
1475
|
set opts to opts_for(profile, mode)
|
|
1457
1476
|
-- el system prompt cambia con el perfil; el historial se conserva (cambiar de agente no borra la conversación)
|
|
1458
1477
|
set messages to [system_msg] + slice(messages, 1, length(messages))
|
|
1459
|
-
print("agente=" + profile + " · tools: " + join(
|
|
1478
|
+
print("agente=" + profile + " · tools: " + join(runtime.get(profile)["tools"], ", "))
|
|
1460
1479
|
otherwise
|
|
1461
|
-
print("no existe el agente " + want + " · disponibles: " + join(
|
|
1480
|
+
print("no existe el agente " + want + " · disponibles: " + join(runtime.names(), ", "))
|
|
1462
1481
|
otherwise when starts_with(input, "/")
|
|
1463
1482
|
print(" " + suggest(input))
|
|
1464
1483
|
otherwise when starts_with(input, "!")
|
|
@@ -1471,20 +1490,18 @@ while running
|
|
|
1471
1490
|
flush()
|
|
1472
1491
|
let out be run_interactive(cmd)
|
|
1473
1492
|
set messages to append(messages, {"role": "user", "content": "[The user ran this command in the shell themselves]\n$ " + cmd + "\n" + tools.truncate(out, 6000)})
|
|
1474
|
-
|
|
1493
|
+
runtime.save(turn_ctx(), messages)
|
|
1475
1494
|
otherwise
|
|
1476
1495
|
when length(pending_images) > 0
|
|
1477
1496
|
set messages to append(messages, {"role": "user", "content": input, "images": pending_images})
|
|
1478
1497
|
set pending_images to []
|
|
1479
1498
|
otherwise
|
|
1480
1499
|
set messages to append(messages, {"role": "user", "content": input})
|
|
1481
|
-
trace.user(sid, input, profile, mode, cfg["model"])
|
|
1482
1500
|
-- catálogo fresco por turno: si el turno anterior conectó/quitó un server MCP, sus tools
|
|
1483
1501
|
-- entran/salen acá (con los mismos servers el catálogo es idéntico → el prompt cache no se corta)
|
|
1484
1502
|
set opts to opts_for(profile, mode)
|
|
1485
1503
|
let t0 be now()
|
|
1486
|
-
let result be
|
|
1487
|
-
trace.turn_end(sid, result)
|
|
1504
|
+
let result be runtime.turn(turn_ctx(), messages, input, {"on_event": on_event})
|
|
1488
1505
|
set messages to result["messages"]
|
|
1489
1506
|
set total_usage to {"input": total_usage["input"] + result["usage"]["input"], "output": total_usage["output"] + result["usage"]["output"]}
|
|
1490
1507
|
let summary be text(result["steps"]) + (when result["steps"] == 1 then " paso" otherwise " pasos") + " · " + fmt_tokens(result["usage"]["input"] + result["usage"]["output"]) + " tokens · " + ui.fmt_duration(now() - t0)
|
|
@@ -1503,7 +1520,6 @@ while running
|
|
|
1503
1520
|
print(dim(" ─── " + summary))
|
|
1504
1521
|
otherwise
|
|
1505
1522
|
print(dim(" ─── " + summary))
|
|
1506
|
-
session.save(sid, messages, {"title": session.title_of(messages)})
|
|
1507
1523
|
flush()
|
|
1508
1524
|
-- los procesos gestionados (servidores) y los subagentes en background mueren con lampson
|
|
1509
1525
|
share true as "lampson:spinner:stop"
|
package/cli.syn
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
--
|
|
3
3
|
-- LAMPSON_CMD=ensure LAMPSON_WORKSPACE=<ruta> synsema run cli.syn
|
|
4
4
|
-- registra/prepara el workspace, asegura el hub y su proceso → imprime UNA línea JSON {slug, port, dir, url, alive}
|
|
5
|
+
-- LAMPSON_CMD=prepare LAMPSON_WORKSPACE=<ruta> lo mismo que ensure SIN hub ni proceso web: solo la carpeta del
|
|
6
|
+
-- workspace (lo que usan `lampson run`, `run --stdio`, `key`, `channel` y `mcp serve`, que no necesitan servidor)
|
|
5
7
|
-- LAMPSON_CMD=hub-status → {alive}
|
|
6
8
|
-- LAMPSON_CMD=hub-start | hub-stop | hub-reboot (stop + start: hub y workspaces; lo lanza ⚙ → Apagar o reiniciar)
|
|
7
9
|
-- LAMPSON_CMD=list
|
|
@@ -23,6 +25,7 @@ require file(".lampson/*")
|
|
|
23
25
|
require file.read("web.syn")
|
|
24
26
|
require file.read(".env")
|
|
25
27
|
require file.read("chat.syn")
|
|
28
|
+
require file.read("run.syn")
|
|
26
29
|
require file.read("hub.tpl.syn")
|
|
27
30
|
require file("hub.syn")
|
|
28
31
|
|
|
@@ -31,15 +34,15 @@ use "./lib/settings.syn" as settings
|
|
|
31
34
|
|
|
32
35
|
let cmd be env("LAMPSON_CMD", "ensure")
|
|
33
36
|
|
|
34
|
-
when cmd == "ensure"
|
|
37
|
+
when cmd == "ensure" or cmd == "prepare"
|
|
35
38
|
let path be env("LAMPSON_WORKSPACE", "")
|
|
36
39
|
when path == ""
|
|
37
40
|
raise("LAMPSON_WORKSPACE required")
|
|
38
41
|
let w be ws.ensure(path)
|
|
39
|
-
when not ws.hub_alive()
|
|
42
|
+
when cmd == "ensure" and not ws.hub_alive()
|
|
40
43
|
ws.start_hub()
|
|
41
44
|
let hc be ws.health(w)
|
|
42
|
-
when hc == nothing
|
|
45
|
+
when cmd == "ensure" and hc == nothing
|
|
43
46
|
ws.start_ws(w)
|
|
44
47
|
ws.wait_ready(w, 10)
|
|
45
48
|
set hc to ws.health(w)
|
package/hub.tpl.syn
CHANGED
|
@@ -27,6 +27,7 @@ require file(".lampson/*")
|
|
|
27
27
|
require file.read("web.syn")
|
|
28
28
|
require file.read(".env")
|
|
29
29
|
require file.read("chat.syn")
|
|
30
|
+
require file.read("run.syn")
|
|
30
31
|
require file.read("hub.tpl.syn")
|
|
31
32
|
require file("hub.syn")
|
|
32
33
|
require file.read("public")
|
|
@@ -73,6 +74,9 @@ serve on 8080
|
|
|
73
74
|
max_streams 200
|
|
74
75
|
auth with check_client
|
|
75
76
|
static "./public"
|
|
77
|
+
-- el hub es la UI y el manejo de workspaces: nada que publicar (/openapi.json, /llms.txt, /docs → 404). La API
|
|
78
|
+
-- para apps vive en cada workspace: /w/<slug>/v1/openapi.json
|
|
79
|
+
private
|
|
76
80
|
|
|
77
81
|
route "GET /"
|
|
78
82
|
when not page_allowed(request)
|
|
@@ -174,6 +178,17 @@ serve on 8080
|
|
|
174
178
|
ws.summary()
|
|
175
179
|
give html(read_file("public/index.html"))
|
|
176
180
|
|
|
181
|
+
-- la pantalla de equipos y objetivos de un workspace (public/teams.html): página propia, a pantalla completa
|
|
182
|
+
route "GET /w/:slug/equipos"
|
|
183
|
+
when not page_allowed(request)
|
|
184
|
+
give redirect("/login", 302)
|
|
185
|
+
let w be ws.get(params.slug)
|
|
186
|
+
when w != nothing and ws.health(w) == nothing
|
|
187
|
+
ws.start_ws(w)
|
|
188
|
+
ws.wait_ready(w, 8)
|
|
189
|
+
ws.summary()
|
|
190
|
+
give html(read_file("public/teams.html"))
|
|
191
|
+
|
|
177
192
|
route "GET /api/hub" requires auth
|
|
178
193
|
give {"ok": true, "port": ws.HUB_PORT, "idle_hours": ws.idle_hours(), "home": ws.home(), "local": request.user["local"]}
|
|
179
194
|
|
package/lampson.ps1
CHANGED
|
@@ -8,6 +8,13 @@
|
|
|
8
8
|
# lampson --domain lampson.midominio.com --email vos@midominio.com # HTTPS con tu dominio (opcional) · --domain off
|
|
9
9
|
# lampson --pair [https://tu-dominio] # QR en la terminal para emparejar el celular
|
|
10
10
|
# lampson --agent plan · --yolo|--strict|--ask · --update · --help
|
|
11
|
+
# lampson run [--agent ID] [--thread T | --session ID] [--json] [--yolo|--strict|--ask] "mensaje" # sin interfaz
|
|
12
|
+
# lampson run --stdio # modo local: un proceso abierto, un pedido JSON por línea (lo usa el SDK)
|
|
13
|
+
# lampson key add [--agent ID[,ID]] [--name NOMBRE] [--rate N] [--callback URL] · key list · key remove <id> # API keys /v1
|
|
14
|
+
# lampson mcp serve [--agent ID[,ID]] [--workspace RUTA] # Lampson como servidor MCP (stdio) para otros agentes
|
|
15
|
+
# lampson channel list · channel on|off <canal> · channel setup <canal> # canales (Telegram, Chatwoot…)
|
|
16
|
+
# lampson objective add "…" --agent ID | --team ID [--budget N] [--round S] · objective list · show <id> · reply <id> "…" [--approve|--deny] · cancel <id> # objetivos
|
|
17
|
+
# lampson team list # equipos de agentes y quién reporta a quién
|
|
11
18
|
#
|
|
12
19
|
# Cómo funciona (ver SPEC-WORKSPACES.md): .lampson\ws\<slug>\ es el cwd del proceso del workspace, con una junction
|
|
13
20
|
# `workspace` al proyecto y junctions a lib/public/skills/plugins/memory de esta instalación. El registro y los procesos
|
|
@@ -18,7 +25,19 @@ $caller = (Get-Location).Path
|
|
|
18
25
|
|
|
19
26
|
# --- args: acepta --flag y -Flag, sin distinguir mayúsculas ---
|
|
20
27
|
$Workspace = ""; $Web = $false; $Agent = ""; $Perm = ""; $Hub = ""; $Install = ""; $Domain = $null; $Email = ""; $Pair = $null
|
|
28
|
+
$Run = $false; $Message = @(); $Thread = ""; $Session = ""; $Json = $false; $Key = ""; $KeyName = ""; $KeyId = ""; $McpServe = $false; $ChannelCmd = ""; $ChannelName = ""; $Stdio = $false; $KeyRate = ""; $KeyCallbacks = @(); $ObjCmd = ""; $ObjId = ""; $ObjTeam = ""; $ObjBudget = ""; $ObjRound = ""; $ObjDecision = ""; $TeamCmd = ""
|
|
21
29
|
$i = 0
|
|
30
|
+
# `lampson run …`: subcomando sin interfaz (run.syn, spec/engine.md); las palabras sueltas son el mensaje
|
|
31
|
+
if ($args.Count -gt 0 -and ([string]$args[0]).ToLower() -eq "run") { $Run = $true; $i = 1 }
|
|
32
|
+
# `lampson key add|list|remove …`: API keys (también corre run.syn, con LAMPSON_KEY_CMD)
|
|
33
|
+
# `lampson mcp serve …`: servidor MCP por stdio (run.syn con LAMPSON_MCP_SERVE)
|
|
34
|
+
if ($args.Count -gt 1 -and ([string]$args[0]).ToLower() -eq "mcp" -and ([string]$args[1]).ToLower() -eq "serve") { $Run = $true; $McpServe = $true; $i = 2 }
|
|
35
|
+
# `lampson channel list|on|off|setup <canal>` (run.syn con LAMPSON_CHANNEL_CMD)
|
|
36
|
+
if ($args.Count -gt 0 -and ([string]$args[0]).ToLower() -eq "channel") { $Run = $true; $ChannelCmd = $(if ($args.Count -gt 1) { ([string]$args[1]).ToLower() } else { "list" }); $i = 2 }
|
|
37
|
+
# `lampson objective add|list|show|reply|cancel` y `lampson team list` (run.syn con LAMPSON_OBJ_CMD / LAMPSON_TEAM_CMD)
|
|
38
|
+
if ($args.Count -gt 0 -and ([string]$args[0]).ToLower() -eq "objective") { $Run = $true; $ObjCmd = $(if ($args.Count -gt 1) { ([string]$args[1]).ToLower() } else { "list" }); $i = 2 }
|
|
39
|
+
if ($args.Count -gt 0 -and ([string]$args[0]).ToLower() -eq "team") { $Run = $true; $TeamCmd = "list"; $i = $(if ($args.Count -gt 1) { 2 } else { 1 }) }
|
|
40
|
+
if ($args.Count -gt 0 -and ([string]$args[0]).ToLower() -eq "key") { $Run = $true; $Key = $(if ($args.Count -gt 1) { ([string]$args[1]).ToLower() } else { "help" }); $i = 2 }
|
|
22
41
|
while ($i -lt $args.Count) {
|
|
23
42
|
$a = [string]$args[$i]
|
|
24
43
|
switch -Regex ($a.ToLower()) {
|
|
@@ -35,9 +54,21 @@ while ($i -lt $args.Count) {
|
|
|
35
54
|
'^--?(strict|s)$' { $Perm = "strict" }
|
|
36
55
|
'^--?(ask)$' { $Perm = "ask" }
|
|
37
56
|
'^--?(permission|p)$' { $i++; $Perm = ([string]$args[$i]).ToLower() }
|
|
57
|
+
'^--?thread$' { $i++; $Thread = [string]$args[$i] }
|
|
58
|
+
'^--?session$' { $i++; $Session = [string]$args[$i] }
|
|
59
|
+
'^--?json$' { $Json = $true }
|
|
60
|
+
'^--?stdio$' { $Stdio = $true }
|
|
61
|
+
'^--?name$' { $i++; $KeyName = [string]$args[$i] }
|
|
62
|
+
'^--?rate$' { $i++; $KeyRate = [string]$args[$i] }
|
|
63
|
+
'^--?callback$' { $i++; $KeyCallbacks += [string]$args[$i] }
|
|
64
|
+
'^--?team$' { $i++; $ObjTeam = [string]$args[$i] }
|
|
65
|
+
'^--?budget$' { $i++; $ObjBudget = [string]$args[$i] }
|
|
66
|
+
'^--?round$' { $i++; $ObjRound = [string]$args[$i] }
|
|
67
|
+
'^--?approve$' { $ObjDecision = "approve" }
|
|
68
|
+
'^--?deny$' { $ObjDecision = "deny" }
|
|
38
69
|
'^--?(update|u)$' { Write-Host "actualizando Lampson en $here"; git -C $here pull --ff-only origin main; Write-Host ("lampson " + (git -C $here rev-parse --short HEAD)); exit $LASTEXITCODE }
|
|
39
|
-
'^--?(help|h|\?)$' { Get-Content $PSCommandPath | Select-Object -Skip 1 -First
|
|
40
|
-
default { if ($Workspace -eq "" -and -not $a.StartsWith("-")) { $Workspace = $a } else { Write-Error "argumento desconocido: $a (probá lampson --help)"; exit 1 } }
|
|
70
|
+
'^--?(help|h|\?)$' { Get-Content $PSCommandPath | Select-Object -Skip 1 -First 9 | ForEach-Object { $_.TrimStart('#',' ') }; exit 0 }
|
|
71
|
+
default { if ($ObjCmd -ne "" -and $ObjId -eq "" -and @("show", "reply", "cancel") -contains $ObjCmd -and -not $a.StartsWith("-")) { $ObjId = $a } elseif ($ObjCmd -ne "" -and -not $a.StartsWith("-")) { $Message += $a } elseif ($ChannelCmd -ne "" -and -not $a.StartsWith("-")) { $ChannelName = $a } elseif ($Key -ne "" -and -not $a.StartsWith("-")) { $KeyId = $a } elseif ($Run -and -not $a.StartsWith("-")) { $Message += $a } elseif ($Workspace -eq "" -and -not $a.StartsWith("-")) { $Workspace = $a } else { Write-Error "argumento desconocido: $a (probá lampson --help)"; exit 1 } }
|
|
41
72
|
}
|
|
42
73
|
$i++
|
|
43
74
|
}
|
|
@@ -73,7 +104,8 @@ function Invoke-Cli([string]$cmd, [string]$ws) {
|
|
|
73
104
|
$out = & synsema run cli.syn 2>&1
|
|
74
105
|
if ($LASTEXITCODE -ne 0) { $out | ForEach-Object { Write-Host $_ }; throw "cli.syn falló ($cmd)" }
|
|
75
106
|
$lines = @($out | ForEach-Object { [string]$_ })
|
|
76
|
-
|
|
107
|
+
# en `lampson run` la salida es del programa que llama (JSONL): lo informativo va a stderr
|
|
108
|
+
$lines | Select-Object -SkipLast 1 | ForEach-Object { if ($Run) { [Console]::Error.WriteLine($_) } else { Write-Host $_ } }
|
|
77
109
|
return ($lines[-1] | ConvertFrom-Json)
|
|
78
110
|
}
|
|
79
111
|
|
|
@@ -117,15 +149,35 @@ try {
|
|
|
117
149
|
}
|
|
118
150
|
exit 0
|
|
119
151
|
}
|
|
120
|
-
# --- arranque al iniciar sesión: Tarea Programada
|
|
152
|
+
# --- arranque al iniciar sesión: Tarea Programada; sin permiso para crearla, un .vbs en la carpeta Inicio ---
|
|
153
|
+
$startupVbs = Join-Path ([Environment]::GetFolderPath("Startup")) "lampson-hub.vbs"
|
|
121
154
|
if ($Install -eq "install") {
|
|
122
|
-
$cmd = "cmd /c cd /d `"$here`" && set LAMPSON_HOME=$here
|
|
123
|
-
|
|
124
|
-
|
|
155
|
+
$cmd = "cmd /c cd /d `"$here`" && set LAMPSON_HOME=$here&& synsema serve hub.syn > .lampson\hub.log 2>&1"
|
|
156
|
+
$prev = $ErrorActionPreference; $ErrorActionPreference = "Continue"
|
|
157
|
+
$out = schtasks /Create /F /TN "Lampson hub" /SC ONLOGON /TR $cmd 2>&1
|
|
158
|
+
$ErrorActionPreference = $prev
|
|
159
|
+
if ($LASTEXITCODE -eq 0) {
|
|
160
|
+
Write-Host "instalado: el hub de Lampson arranca al iniciar sesión (Tarea Programada «Lampson hub»). Arrancándolo ahora…"
|
|
161
|
+
} else {
|
|
162
|
+
$q = $cmd.Replace('"', '""')
|
|
163
|
+
$vbs = "' Lampson hub: lo arranca Windows al iniciar sesion. Quitar con: lampson --uninstall`r`nCreateObject(""WScript.Shell"").Run ""$q"", 0, False`r`n"
|
|
164
|
+
try {
|
|
165
|
+
[IO.File]::WriteAllText($startupVbs, $vbs, [Text.Encoding]::ASCII)
|
|
166
|
+
Write-Host "instalado: el hub de Lampson arranca al iniciar sesión (carpeta Inicio: $startupVbs — la Tarea Programada pidió permisos de administrador). Arrancándolo ahora…"
|
|
167
|
+
} catch {
|
|
168
|
+
Write-Error ("no pude instalar el arranque: schtasks dijo «" + ($out -join " ") + "» y la carpeta Inicio falló: " + $_.Exception.Message); exit 1
|
|
169
|
+
}
|
|
170
|
+
}
|
|
125
171
|
$null = Invoke-Cli "hub-start" ""
|
|
126
172
|
exit 0
|
|
127
173
|
}
|
|
128
|
-
if ($Install -eq "uninstall") {
|
|
174
|
+
if ($Install -eq "uninstall") {
|
|
175
|
+
$prev = $ErrorActionPreference; $ErrorActionPreference = "Continue"
|
|
176
|
+
schtasks /Delete /F /TN "Lampson hub" 2>&1 | Out-Null
|
|
177
|
+
$ErrorActionPreference = $prev
|
|
178
|
+
if (Test-Path $startupVbs) { Remove-Item $startupVbs -Force }
|
|
179
|
+
Write-Host "quitado el arranque al iniciar sesión (el hub sigue corriendo hasta lampson --hub stop)"; exit 0
|
|
180
|
+
}
|
|
129
181
|
|
|
130
182
|
# --- resolver el proyecto: explícito > directorio actual (si no es el propio lampson) ---
|
|
131
183
|
if ($Workspace -eq "" -and $caller -ne $here) { $Workspace = $caller }
|
|
@@ -139,7 +191,8 @@ try {
|
|
|
139
191
|
if ($target -eq $here) { Write-Error "no montes el propio directorio de lampson como workspace"; exit 1 }
|
|
140
192
|
|
|
141
193
|
# registrar/preparar el workspace y asegurar hub + proceso
|
|
142
|
-
|
|
194
|
+
# `run`, `key`, `channel` y `mcp serve` no necesitan servidor: solo la carpeta del workspace (sin hub)
|
|
195
|
+
$r = Invoke-Cli $(if ($Run) { "prepare" } else { "ensure" }) $target
|
|
143
196
|
$wsDir = Join-Path $here ($r.dir -replace '/', '\')
|
|
144
197
|
if ($Web) {
|
|
145
198
|
Write-Host ("Lampson web · " + $r.url + " (workspace " + $r.slug + $(if ($r.alive) { " ● vivo" } else { " ○ arrancando" }) + ")")
|
|
@@ -157,9 +210,30 @@ try {
|
|
|
157
210
|
if ($r.judge_model) { $env:SYNSEMA_JUDGE_MODEL = $r.judge_model }
|
|
158
211
|
if ($r.judge_key) { $env:TYPESAFE_API_KEY = $r.judge_key }
|
|
159
212
|
$envFile = Join-Path $here ".env"
|
|
160
|
-
|
|
161
|
-
|
|
213
|
+
$entry = "chat.syn"
|
|
214
|
+
if ($Run) {
|
|
215
|
+
# sin interfaz: los permisos los fija el flag, o el agente (run.syn: strict si el agente no dice nada)
|
|
216
|
+
$entry = "run.syn"
|
|
217
|
+
$env:LAMPSON_MESSAGE = ($Message -join " "); $env:LAMPSON_RUN_PERMISSION = $Perm
|
|
218
|
+
$env:LAMPSON_THREAD = $Thread; $env:LAMPSON_SESSION = $Session; $env:LAMPSON_RUN_JSON = $(if ($Json) { "1" } else { "" })
|
|
219
|
+
$env:LAMPSON_KEY_CMD = $Key; $env:LAMPSON_KEY_NAME = $KeyName; $env:LAMPSON_KEY_ID = $KeyId; $env:LAMPSON_KEY_AGENTS = $Agent
|
|
220
|
+
$env:LAMPSON_KEY_RATE = $KeyRate; $env:LAMPSON_KEY_CALLBACKS = ($KeyCallbacks -join ",")
|
|
221
|
+
$env:LAMPSON_MCP_SERVE = $(if ($McpServe) { "1" } else { "" }); $env:LAMPSON_MCP_AGENTS = $(if ($McpServe) { $Agent } else { "" })
|
|
222
|
+
$env:LAMPSON_CHANNEL_CMD = $ChannelCmd; $env:LAMPSON_CHANNEL_NAME = $ChannelName
|
|
223
|
+
$env:LAMPSON_RUN_STDIO = $(if ($Stdio) { "1" } else { "" })
|
|
224
|
+
$env:LAMPSON_OBJ_CMD = $ObjCmd; $env:LAMPSON_OBJ_ID = $ObjId; $env:LAMPSON_OBJ_AGENT = $(if ($ObjCmd -ne "") { $Agent } else { "" }); $env:LAMPSON_OBJ_TEAM = $ObjTeam
|
|
225
|
+
$env:LAMPSON_OBJ_BUDGET = $ObjBudget; $env:LAMPSON_OBJ_ROUND = $ObjRound; $env:LAMPSON_OBJ_DECISION = $ObjDecision; $env:LAMPSON_TEAM_CMD = $TeamCmd
|
|
226
|
+
}
|
|
227
|
+
if (Test-Path -LiteralPath $envFile) { synsema run --env-file $envFile $entry } else { synsema run $entry }
|
|
228
|
+
$exitCode = $LASTEXITCODE
|
|
229
|
+
} finally {
|
|
230
|
+
Pop-Location
|
|
231
|
+
# `lampson` corre este script dentro de TU sesión de PowerShell: lo de `run`/`key` no debe quedar en el entorno
|
|
232
|
+
# (un LAMPSON_SESSION que queda haría que el próximo `lampson` retome esa sesión sin pedirlo)
|
|
233
|
+
if ($Run) { foreach ($v in "LAMPSON_MESSAGE","LAMPSON_RUN_PERMISSION","LAMPSON_THREAD","LAMPSON_SESSION","LAMPSON_RUN_JSON","LAMPSON_KEY_CMD","LAMPSON_KEY_NAME","LAMPSON_KEY_ID","LAMPSON_KEY_AGENTS","LAMPSON_MCP_SERVE","LAMPSON_MCP_AGENTS","LAMPSON_CHANNEL_CMD","LAMPSON_CHANNEL_NAME","LAMPSON_RUN_STDIO","LAMPSON_KEY_RATE","LAMPSON_KEY_CALLBACKS","LAMPSON_OBJ_CMD","LAMPSON_OBJ_ID","LAMPSON_OBJ_AGENT","LAMPSON_OBJ_TEAM","LAMPSON_OBJ_BUDGET","LAMPSON_OBJ_ROUND","LAMPSON_OBJ_DECISION","LAMPSON_TEAM_CMD") { Remove-Item "Env:$v" -ErrorAction SilentlyContinue } }
|
|
234
|
+
}
|
|
162
235
|
} finally {
|
|
163
236
|
Pop-Location
|
|
164
237
|
try { [Console]::OutputEncoding = $prevOutEnc } catch {}
|
|
165
238
|
}
|
|
239
|
+
if ($Run) { exit $exitCode }
|