lampson 0.3.0 → 0.4.1

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 CHANGED
@@ -87,7 +87,12 @@ 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
- → [How plugins work](https://lampson.org/docs/plugins) · the example ships in `plugins/example-hello/`.
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
@@ -96,19 +101,51 @@ plugins were called *lamps*; old `.lampson/lamps/` folders and `LAMP_*` variable
96
101
 
97
102
  ## Use it from your app
98
103
 
99
- Lampson also runs **headless**, as the engine behind something else — a bot that answers your shop's
100
- messages, a script that asks it about a database, another agent that delegates to it:
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.
101
137
 
102
138
  ```sh
103
- lampson run "summarize what changed today" # prints the answer
104
- echo "do you have whole-wheat bread?" | lampson run --agent shop --thread whatsapp:+5491122334455 --json
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
105
142
  ```
106
143
 
107
- An agent is a file: `.lampson/agents/shop.agent.json` in your project, with its own prompt, the exact tools it
108
- may use and its permissions (`strict` by default when nobody is there to approve). Same `--thread` → same
109
- conversation, so each customer keeps their own history. `--json` streams every step as JSON lines.
110
- Details in [guide.md](guide.md#headless-lampson-run); where this is going (HTTP API, MCP server, channels,
111
- agent teams) in [spec/engine.md](spec/engine.md).
144
+ Start at `http://127.0.0.1:8080/equipos`: every project's teams and objectives, everything waiting for you, and
145
+ **+ equipo** (in a project you have, or a new folder for a team that doesn't code). Each project has a full-screen
146
+ view at `/w/<project>/equipos` with the objectives, the team as a live graph, its board and its record — and the
147
+ editor to build the team.
148
+ → **[lampson.org/docs/teams](https://lampson.org/docs/teams)**
112
149
 
113
150
  ## Also in the box
114
151
 
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/*")
package/hub.tpl.syn CHANGED
@@ -32,6 +32,9 @@ require file.read("hub.tpl.syn")
32
32
  require file("hub.syn")
33
33
  require file.read("public")
34
34
  require file.read("public/*")
35
+ -- equipos que no programan: su carpeta vive en la instalación (equipos/<nombre>/), creada desde /equipos
36
+ require file("equipos")
37
+ require file("equipos/*")
35
38
  require random
36
39
 
37
40
  use "./lib/workspaces.syn" as ws
@@ -170,6 +173,10 @@ serve on 8080
170
173
  route "GET /w/:slug"
171
174
  when not page_allowed(request)
172
175
  give redirect("/login", 302)
176
+ -- /w/empresa-demo → /w/empresa-demo-f0bfe45d si un solo workspace se llama así (el hash solo desempata)
177
+ let full be ws.resolve_slug(params.slug)
178
+ when full != nothing and full != params.slug
179
+ give redirect("/w/" + full, 302)
173
180
  -- entrar a un workspace apagado lo enciende (y levanta la pausa manual): si alguien abre la URL es para usarlo
174
181
  let w be ws.get(params.slug)
175
182
  when w != nothing and ws.health(w) == nothing
@@ -178,6 +185,59 @@ serve on 8080
178
185
  ws.summary()
179
186
  give html(read_file("public/index.html"))
180
187
 
188
+ -- la pantalla de equipos y objetivos de un workspace (public/teams.html): página propia, a pantalla completa
189
+ route "GET /w/:slug/equipos"
190
+ when not page_allowed(request)
191
+ give redirect("/login", 302)
192
+ let full be ws.resolve_slug(params.slug)
193
+ when full != nothing and full != params.slug
194
+ give redirect("/w/" + full + "/equipos" + (when contains(query, "new") then "?new=1" otherwise ""), 302)
195
+ let w be ws.get(params.slug)
196
+ when w != nothing and ws.health(w) == nothing
197
+ ws.start_ws(w)
198
+ ws.wait_ready(w, 8)
199
+ ws.summary()
200
+ give html(read_file("public/teams.html"))
201
+
202
+ -- EQUIPOS Y OBJETIVOS de todos los workspaces (public/teams-home.html): lo que espera a la persona, cada proyecto
203
+ -- con sus equipos y objetivos, y «+ equipo». Lee el resumen que escribe cada workspace (lib/teamrun.syn).
204
+ route "GET /equipos"
205
+ when not page_allowed(request)
206
+ give redirect("/login", 302)
207
+ give html(read_file("public/teams-home.html"))
208
+
209
+ route "GET /api/teams-home" requires auth
210
+ let out be []
211
+ each w in ws.summary_cached(20)
212
+ let s be ws.teams_summary(w)
213
+ set out to append(out, {"slug": w["slug"], "name": w["name"], "path": w["path"], "alive": w["alive"], "teams": s["teams"], "objectives": s["objectives"], "approvals": s["approvals"], "active": s["active"], "waiting": s["waiting"]})
214
+ give {"workspaces": out}
215
+
216
+ -- un equipo nuevo: en un workspace que ya existe, o en una carpeta nueva equipos/<nombre> (para un equipo que no
217
+ -- programa: ventas, soporte, investigación). Devuelve la pantalla del workspace con el editor abierto.
218
+ route "POST /api/teams-home/new" requires auth
219
+ let b be json of request
220
+ let slug be when contains(b, "slug") and b["slug"] != nothing then text(b["slug"]) otherwise ""
221
+ let w be nothing
222
+ when slug != ""
223
+ set w to ws.get(slug)
224
+ when w == nothing
225
+ give fail(404, "no such workspace")
226
+ otherwise
227
+ let nm be lower(trim(when contains(b, "name") and b["name"] != nothing then text(b["name"]) otherwise ""))
228
+ when not matches(nm, "[a-z0-9][a-z0-9-]{0,39}")
229
+ give fail(400, "el nombre va en minúsculas, números y guiones (por ejemplo «ventas»)")
230
+ when not file_exists("equipos/" + nm + "/README.md")
231
+ write_file("equipos/" + nm + "/README.md", "# " + nm + "\n\nCarpeta del equipo «" + nm + "» de Lampson: sus agentes, su tablero y sus objetivos viven en .lampson/.\nLo que el equipo produzca (notas, informes, archivos) puede quedar acá.\n")
232
+ try
233
+ set w to ws.ensure(ws.home() + "/equipos/" + nm)
234
+ recover err
235
+ give fail(400, text(err))
236
+ ws.start_ws(w)
237
+ ws.wait_ready(w, 8)
238
+ ws.summary()
239
+ give {"ok": true, "slug": w["slug"], "url": "/w/" + w["slug"] + "/equipos?new=1"}
240
+
181
241
  route "GET /api/hub" requires auth
182
242
  give {"ok": true, "port": ws.HUB_PORT, "idle_hours": ws.idle_hours(), "home": ws.home(), "local": request.user["local"]}
183
243
 
package/lampson.ps1 CHANGED
@@ -13,6 +13,8 @@
13
13
  # lampson key add [--agent ID[,ID]] [--name NOMBRE] [--rate N] [--callback URL] · key list · key remove <id> # API keys /v1
14
14
  # lampson mcp serve [--agent ID[,ID]] [--workspace RUTA] # Lampson como servidor MCP (stdio) para otros agentes
15
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
16
18
  #
17
19
  # Cómo funciona (ver SPEC-WORKSPACES.md): .lampson\ws\<slug>\ es el cwd del proceso del workspace, con una junction
18
20
  # `workspace` al proyecto y junctions a lib/public/skills/plugins/memory de esta instalación. El registro y los procesos
@@ -23,7 +25,7 @@ $caller = (Get-Location).Path
23
25
 
24
26
  # --- args: acepta --flag y -Flag, sin distinguir mayúsculas ---
25
27
  $Workspace = ""; $Web = $false; $Agent = ""; $Perm = ""; $Hub = ""; $Install = ""; $Domain = $null; $Email = ""; $Pair = $null
26
- $Run = $false; $Message = @(); $Thread = ""; $Session = ""; $Json = $false; $Key = ""; $KeyName = ""; $KeyId = ""; $McpServe = $false; $ChannelCmd = ""; $ChannelName = ""; $Stdio = $false; $KeyRate = ""; $KeyCallbacks = @()
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 = ""
27
29
  $i = 0
28
30
  # `lampson run …`: subcomando sin interfaz (run.syn, spec/engine.md); las palabras sueltas son el mensaje
29
31
  if ($args.Count -gt 0 -and ([string]$args[0]).ToLower() -eq "run") { $Run = $true; $i = 1 }
@@ -32,6 +34,9 @@ if ($args.Count -gt 0 -and ([string]$args[0]).ToLower() -eq "run") { $Run = $tru
32
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 }
33
35
  # `lampson channel list|on|off|setup <canal>` (run.syn con LAMPSON_CHANNEL_CMD)
34
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 }) }
35
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 }
36
41
  while ($i -lt $args.Count) {
37
42
  $a = [string]$args[$i]
@@ -56,9 +61,14 @@ while ($i -lt $args.Count) {
56
61
  '^--?name$' { $i++; $KeyName = [string]$args[$i] }
57
62
  '^--?rate$' { $i++; $KeyRate = [string]$args[$i] }
58
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" }
59
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 }
60
70
  '^--?(help|h|\?)$' { Get-Content $PSCommandPath | Select-Object -Skip 1 -First 9 | ForEach-Object { $_.TrimStart('#',' ') }; exit 0 }
61
- default { if ($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 } }
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 } }
62
72
  }
63
73
  $i++
64
74
  }
@@ -139,15 +149,35 @@ try {
139
149
  }
140
150
  exit 0
141
151
  }
142
- # --- arranque al iniciar sesión: Tarea Programada que corre el hub (synsema daemon, --watch) ---
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"
143
154
  if ($Install -eq "install") {
144
- $cmd = "cmd /c cd /d `"$here`" && set LAMPSON_HOME=$here && synsema serve hub.syn > .lampson\hub.log 2>&1"
145
- schtasks /Create /F /TN "Lampson hub" /SC ONLOGON /TR $cmd | Out-Null
146
- Write-Host "instalado: el hub de Lampson arranca al iniciar sesión (Tarea Programada «Lampson hub»). Arrancándolo ahora…"
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
+ }
147
171
  $null = Invoke-Cli "hub-start" ""
148
172
  exit 0
149
173
  }
150
- if ($Install -eq "uninstall") { schtasks /Delete /F /TN "Lampson hub" | Out-Null; Write-Host "quitado el arranque al iniciar sesión (el hub sigue corriendo hasta lampson --hub stop)"; exit 0 }
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
+ }
151
181
 
152
182
  # --- resolver el proyecto: explícito > directorio actual (si no es el propio lampson) ---
153
183
  if ($Workspace -eq "" -and $caller -ne $here) { $Workspace = $caller }
@@ -191,6 +221,8 @@ try {
191
221
  $env:LAMPSON_MCP_SERVE = $(if ($McpServe) { "1" } else { "" }); $env:LAMPSON_MCP_AGENTS = $(if ($McpServe) { $Agent } else { "" })
192
222
  $env:LAMPSON_CHANNEL_CMD = $ChannelCmd; $env:LAMPSON_CHANNEL_NAME = $ChannelName
193
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
194
226
  }
195
227
  if (Test-Path -LiteralPath $envFile) { synsema run --env-file $envFile $entry } else { synsema run $entry }
196
228
  $exitCode = $LASTEXITCODE
@@ -198,7 +230,7 @@ try {
198
230
  Pop-Location
199
231
  # `lampson` corre este script dentro de TU sesión de PowerShell: lo de `run`/`key` no debe quedar en el entorno
200
232
  # (un LAMPSON_SESSION que queda haría que el próximo `lampson` retome esa sesión sin pedirlo)
201
- 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") { Remove-Item "Env:$v" -ErrorAction SilentlyContinue } }
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 } }
202
234
  }
203
235
  } finally {
204
236
  Pop-Location
package/lampson.sh CHANGED
@@ -12,12 +12,15 @@
12
12
  # lampson key add [--agent ID[,ID]] [--name NOMBRE] [--rate N] [--callback URL] · key list · key remove <id> # API keys /v1
13
13
  # lampson mcp serve [--agent ID[,ID]] [--workspace RUTA] # Lampson como servidor MCP (stdio) para otros agentes
14
14
  # lampson channel list · channel on|off <canal> · channel setup <canal> # canales (Telegram, Chatwoot…)
15
+ # lampson objective add "…" --agent ID | --team ID [--budget N] [--round S] · objective list · show <id> · reply <id> "…" [--approve|--deny] · cancel <id> # objetivos
16
+ # lampson team list # equipos de agentes y quién reporta a quién
15
17
  set -euo pipefail
16
18
  # se lo llama por el symlink `lampson` (~/.local/bin): la carpeta es donde vive el script de verdad
17
19
  here="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" && pwd)"
18
20
  caller="$(pwd)"
19
21
  ws=""; web=0; hub=""; install=""; domain="-"; email=""; pair_url="-"
20
22
  run=0; msg=""; perm_flag=""; key=""; key_name=""; key_id=""; mcp_serve=""; ch_cmd=""; ch_name=""
23
+ obj_cmd=""; obj_id=""; obj_team=""; obj_budget=""; obj_round=""; obj_decision=""; team_cmd=""
21
24
  # `lampson run …`: subcomando sin interfaz (run.syn); las palabras sueltas son el mensaje, no el workspace
22
25
  if [ "${1:-}" = run ]; then run=1; shift; fi
23
26
  # `lampson key add|list|remove …`: API keys (también corre run.syn, con LAMPSON_KEY_CMD)
@@ -26,6 +29,9 @@ if [ "${1:-}" = mcp ] && [ "${2:-}" = serve ]; then run=1; mcp_serve=1; shift 2;
26
29
  # `lampson channel list|on|off|setup <canal>` (run.syn con LAMPSON_CHANNEL_CMD)
27
30
  if [ "${1:-}" = channel ]; then run=1; ch_cmd="${2:-list}"; shift; [ $# -gt 0 ] && shift; fi
28
31
  if [ "${1:-}" = key ]; then run=1; key="${2:-help}"; shift; [ $# -gt 0 ] && shift; fi
32
+ # `lampson objective add|list|show|reply|cancel` y `lampson team list` (run.syn con LAMPSON_OBJ_CMD / LAMPSON_TEAM_CMD)
33
+ if [ "${1:-}" = objective ]; then run=1; obj_cmd="${2:-list}"; shift; [ $# -gt 0 ] && shift; fi
34
+ if [ "${1:-}" = team ]; then run=1; team_cmd=list; shift; [ $# -gt 0 ] && shift; fi
29
35
  while [ $# -gt 0 ]; do
30
36
  case "$1" in
31
37
  --web) web=1 ;;
@@ -47,9 +53,14 @@ while [ $# -gt 0 ]; do
47
53
  --name) shift; key_name="$1" ;;
48
54
  --rate) shift; export LAMPSON_KEY_RATE="$1" ;;
49
55
  --callback) shift; export LAMPSON_KEY_CALLBACKS="${LAMPSON_KEY_CALLBACKS:+$LAMPSON_KEY_CALLBACKS,}$1" ;;
56
+ --team) shift; obj_team="$1" ;;
57
+ --budget) shift; obj_budget="$1" ;;
58
+ --round) shift; obj_round="$1" ;;
59
+ --approve) obj_decision=approve ;;
60
+ --deny) obj_decision=deny ;;
50
61
  --update) echo "actualizando Lampson en $here"; git -C "$here" pull --ff-only origin main; echo "lampson $(git -C "$here" rev-parse --short HEAD)"; exit $? ;;
51
62
  -*) echo "uso: lampson run [--agent ID] [--thread T|--session ID] [--json] [--yolo|--strict|--ask] [mensaje]" >&2; echo "uso: lampson [--web] [--hub start|stop|status|logs|restart] [--domain DOMINIO|off [--email EMAIL]] [--pair [URL]] [--install|--uninstall] [--workspace RUTA] [--agent PERFIL] [--yolo|--strict|--ask] [--update]" >&2; exit 1 ;;
52
- *) if [ -n "$ch_cmd" ]; then ch_name="$1"; elif [ -n "$key" ]; then key_id="$1"; elif [ "$run" = 1 ]; then msg="${msg:+$msg }$1"; else ws="$1"; fi ;;
63
+ *) if [ -n "$obj_cmd" ] && [ -z "$obj_id" ] && { [ "$obj_cmd" = show ] || [ "$obj_cmd" = reply ] || [ "$obj_cmd" = cancel ]; }; then obj_id="$1"; elif [ -n "$obj_cmd" ]; then msg="${msg:+$msg }$1"; elif [ -n "$ch_cmd" ]; then ch_name="$1"; elif [ -n "$key" ]; then key_id="$1"; elif [ "$run" = 1 ]; then msg="${msg:+$msg }$1"; else ws="$1"; fi ;;
53
64
  esac
54
65
  shift
55
66
  done
@@ -173,6 +184,8 @@ if [ "$run" = 1 ]; then
173
184
  entry=run.syn; export LAMPSON_MESSAGE="$msg" LAMPSON_RUN_PERMISSION="$perm_flag"
174
185
  export LAMPSON_KEY_CMD="$key" LAMPSON_KEY_NAME="$key_name" LAMPSON_KEY_ID="$key_id" LAMPSON_KEY_AGENTS="${LAMPSON_AGENT:-}"
175
186
  export LAMPSON_CHANNEL_CMD="$ch_cmd" LAMPSON_CHANNEL_NAME="$ch_name"
187
+ export LAMPSON_OBJ_CMD="$obj_cmd" LAMPSON_OBJ_ID="$obj_id" LAMPSON_OBJ_AGENT="$([ -n "$obj_cmd" ] && echo "${LAMPSON_AGENT:-}")" LAMPSON_OBJ_TEAM="$obj_team"
188
+ export LAMPSON_OBJ_BUDGET="$obj_budget" LAMPSON_OBJ_ROUND="$obj_round" LAMPSON_OBJ_DECISION="$obj_decision" LAMPSON_TEAM_CMD="$team_cmd"
176
189
  export LAMPSON_MCP_SERVE="$mcp_serve" LAMPSON_MCP_AGENTS="$([ -n "$mcp_serve" ] && echo "${LAMPSON_AGENT:-}")"
177
190
  fi
178
191
  if [ -f "$here/.env" ]; then exec synsema run --env-file "$here/.env" "$entry"; else exec synsema run "$entry"; fi
package/lib/api.syn CHANGED
@@ -22,6 +22,7 @@
22
22
  use "./runtime.syn" as runtime
23
23
  use "./apikeys.syn" as apikeys
24
24
  use "./mailbox.syn" as mailbox
25
+ use "./teams.syn" as teams
25
26
 
26
27
 
27
28
  -- la key del header Authorization (o nothing)
@@ -151,3 +152,141 @@ export task mcp_deliver(sobre, mode)
151
152
  let spec be runtime.get(sobre["to"])
152
153
  let s be mailbox.submit(sobre, {"mode": mode, "buffer": mailbox.buffer_of(spec, false)})
153
154
  give mailbox.wait(s["id"])
155
+
156
+
157
+ -- ---------- objetivos (lib/teams.syn) ----------
158
+ -- un objetivo con su tablero y su registro, como lo devuelve la API
159
+ export task objective_view(o)
160
+ require db(".lampson/teams.db")
161
+ require file(".lampson")
162
+ require file(".lampson/*")
163
+ let scope be teams.obj_scope(o)
164
+ let ts be apply(teams.tasks(scope), (t) => {"id": t["id"], "title": t["title"], "status": t["status"], "owner": t["owner"], "notes": t["notes"], "depends": json_decode(t["depends"])})
165
+ let lg be apply(teams.ledger(scope, 0, 100), (r) => {"id": r["id"], "at": r["at"], "actor": r["actor"], "kind": r["kind"], "ref": r["ref"], "text": r["text"]})
166
+ give {"id": o["id"], "ref": "O-" + text(o["id"]), "agent": o["agent"], "team": o["team"], "text": o["text"], "status": o["status"], "progress": o["progress"], "question": o["question"], "question_kind": o["question_kind"], "result": o["result"], "turns": o["turns"], "spent": o["spent"], "budget_tokens": o["budget_tokens"], "round_seconds": o["round_seconds"], "created_at": o["created_at"], "updated_at": o["updated_at"], "tasks": ts, "ledger": lg}
167
+
168
+ -- POST /v1/objectives: {agent, text, round_seconds?, budget_tokens?} → {ok, id} / {ok: false, status, error}
169
+ export task create_objective(body, rec)
170
+ require db(".lampson/teams.db")
171
+ require time
172
+ require file(".lampson")
173
+ require file(".lampson/*")
174
+ require file.read("workspace")
175
+ require file.read("workspace/*")
176
+ require file.read("agents")
177
+ require file.read("agents/*")
178
+ let agent be lower(text(field(body, "agent", "")))
179
+ let tid be lower(text(field(body, "team", "")))
180
+ when tid != ""
181
+ let tm be teams.get(tid)
182
+ when tm == nothing
183
+ give {"ok": false, "status": 404, "error": "no team named '" + tid + "'"}
184
+ when agent == ""
185
+ set agent to teams.lead_of(tm)
186
+ when teams.member(tm, agent) == nothing
187
+ give {"ok": false, "status": 400, "error": agent + " is not in team " + tid}
188
+ when agent == ""
189
+ give {"ok": false, "status": 400, "error": "agent (or team) is required"}
190
+ when runtime.get(agent) == nothing
191
+ give {"ok": false, "status": 404, "error": "no agent named '" + agent + "'"}
192
+ when not apikeys.allows(rec, agent)
193
+ give {"ok": false, "status": 403, "error": "this API key can't use agent '" + agent + "'"}
194
+ when trim(text(field(body, "text", ""))) == ""
195
+ give {"ok": false, "status": 400, "error": "text is required"}
196
+ let opts be {"budget_tokens": field(body, "budget_tokens", 500000), "created_by": "api:" + rec["name"], "team": tid}
197
+ when field(body, "round_seconds", nothing) != nothing
198
+ set opts["round_seconds"] to body["round_seconds"]
199
+ let id be teams.obj_create(agent, field(body, "text", ""), opts)
200
+ give {"ok": true, "id": id}
201
+
202
+ -- el objetivo si la key puede verlo (su agente), si no nothing
203
+ export task objective_for(id, rec)
204
+ require db(".lampson/teams.db")
205
+ require file(".lampson")
206
+ require file(".lampson/*")
207
+ let o be teams.obj_get(floor(number(id)))
208
+ when o == nothing or not apikeys.allows(rec, o["agent"])
209
+ give nothing
210
+ give o
211
+
212
+
213
+ -- los equipos con su gente (rol, a quién reporta, si está trabajando ahora, lo gastado hoy), su tablero y su registro
214
+ export task teams_view()
215
+ require db(".lampson/teams.db")
216
+ require time
217
+ require file(".lampson")
218
+ require file(".lampson/*")
219
+ require file.read("workspace")
220
+ require file.read("workspace/*")
221
+ require file.read("agents")
222
+ require file.read("agents/*")
223
+ let sc be teams.scan()
224
+ let out be []
225
+ each t in sc["teams"]
226
+ let scope be "team:" + t["id"]
227
+ let members be []
228
+ each m in t["members"]
229
+ let spec be runtime.get(m["agent"])
230
+ set members to append(members, {"agent": m["agent"], "role": m["role"], "reports_to": m["reports_to"], "description": when spec == nothing then "" otherwise spec["description"], "system": when spec == nothing then "" otherwise spec["system"], "tools": when spec == nothing then [] otherwise spec["tools"], "permission": when spec == nothing then "" otherwise spec["permission"], "missing": spec == nothing, "working": mailbox.working(m["agent"], scope), "spent_today": teams.spent_today(m["agent"]), "peers": teams.peers(t, m["agent"])})
231
+ let ts be apply(teams.tasks(scope), (x) => {"id": x["id"], "title": x["title"], "status": x["status"], "owner": x["owner"], "notes": x["notes"], "depends": json_decode(x["depends"])})
232
+ let lg be apply(teams.ledger(scope, 0, 150), (r) => {"id": r["id"], "at": r["at"], "actor": r["actor"], "kind": r["kind"], "ref": r["ref"], "text": r["text"]})
233
+ set out to append(out, {"id": t["id"], "description": t["description"], "members": members, "talks": t["talks"], "round_minutes": t["round_minutes"], "budget_daily_tokens": t["budget_daily_tokens"], "worktrees": t["worktrees"], "lead": teams.lead_of(t), "tasks": ts, "ledger": lg})
234
+ give {"teams": out, "errors": sc["errors"]}
235
+
236
+
237
+ -- guardar un equipo desde la pantalla: el archivo del equipo y los de sus agentes (los que vienen). Cada agente
238
+ -- conserva lo que su archivo ya tenía y pisa solo lo que se editó. → {ok, error}
239
+ export let TOOL_PRESETS be {"code": ["read", "write", "edit", "ls", "find", "grep", "bash", "todo"], "read": ["read", "ls", "find", "grep", "bash"], "none": []}
240
+
241
+ export task save_team(body)
242
+ require db(".lampson/teams.db")
243
+ require time
244
+ require file(".lampson")
245
+ require file(".lampson/*")
246
+ require file("workspace")
247
+ require file("workspace/*")
248
+ require file.read("agents")
249
+ require file.read("agents/*")
250
+ let t be field(body, "team", nothing)
251
+ when t == nothing
252
+ give {"ok": false, "error": "team is required"}
253
+ let v be teams.validate(t, "team")
254
+ when not v["ok"]
255
+ give {"ok": false, "error": v["error"]}
256
+ let team be v["team"]
257
+ let files be []
258
+ each a in field(body, "agents", [])
259
+ let id be lower(text(field(a, "id", "")))
260
+ let path be runtime.PROJECT_DIR + "/" + id + runtime.SUFFIX
261
+ let cur be {}
262
+ when file_exists(path)
263
+ try
264
+ set cur to json_decode(read_file(path))
265
+ recover err
266
+ set cur to {}
267
+ set cur["id"] to id
268
+ each key in ["description", "system", "permission", "base"]
269
+ when contains(a, key) and a[key] != nothing
270
+ set cur[key] to text(a[key])
271
+ when not contains(cur, "base")
272
+ set cur["base"] to "lampson"
273
+ when contains(a, "preset") and a["preset"] != nothing and contains(TOOL_PRESETS, text(a["preset"]))
274
+ set cur["tools"] to TOOL_PRESETS[text(a["preset"])]
275
+ when not contains(cur, "tools")
276
+ set cur["tools"] to TOOL_PRESETS["code"]
277
+ when not contains(cur, "steps")
278
+ set cur["steps"] to 25
279
+ let av be runtime.validate(cur, id + runtime.SUFFIX)
280
+ when not av["ok"]
281
+ give {"ok": false, "error": av["error"]}
282
+ set files to append(files, {"path": path, "doc": cur})
283
+ -- los miembros sin archivo de agente (ni del proyecto ni global) no pueden trabajar
284
+ each m in team["members"]
285
+ when runtime.get(m["agent"]) == nothing and length(where(files, (f) => f["doc"]["id"] == m["agent"])) == 0
286
+ give {"ok": false, "error": "agent '" + m["agent"] + "' has no file yet — give it a personality to create it"}
287
+ each f in files
288
+ write_file(f["path"], json_encode(f["doc"]))
289
+ let raw be {"id": team["id"], "description": team["description"], "members": apply(team["members"], (m) => {"agent": m["agent"], "role": m["role"], "reports_to": m["reports_to"]}), "talks": team["talks"], "round_minutes": team["round_minutes"], "budget_daily_tokens": team["budget_daily_tokens"], "worktrees": team["worktrees"]}
290
+ write_file(teams.DIR + "/" + team["id"] + ".team.json", json_encode(raw))
291
+ teams.log("team:" + team["id"], "person", "team saved", "", join(apply(team["members"], (m) => m["agent"] + " (" + m["role"] + ")"), ", "))
292
+ give {"ok": true, "error": ""}
package/lib/approvals.syn CHANGED
@@ -131,6 +131,13 @@ export task wait(id, timeout_s)
131
131
  share nothing as "approval:token:" + id
132
132
  give ok
133
133
 
134
+ -- lo mismo, diciendo si nadie respondió (para que el agente sepa que no fue un «no»)
135
+ export task wait_detail(id, timeout_s)
136
+ require time
137
+ let ok be wait(id, timeout_s)
138
+ let meta be meta_of(id)
139
+ give {"approved": ok, "expired": meta != nothing and meta["status"] == "expired", "minutes": floor(timeout_s / 60)}
140
+
134
141
  -- responder desde la UI (loopback, ya autenticado) o desde la terminal: sin token
135
142
  export task answer(id, decision)
136
143
  let meta be meta_of(id)
package/lib/loop.syn CHANGED
@@ -26,6 +26,7 @@ use "./mcp.syn" as mcp
26
26
  use "./plugins.syn" as plugins
27
27
  use "./tools/todo.syn" as todo
28
28
  use "./scope.syn" as scope
29
+ use "./worktree.syn" as worktree
29
30
 
30
31
  let MAX_ERRORS_PER_TURN be 8
31
32
  -- capturas de computer_use (lib/computer.syn): el driver las deja en el blackboard "computer:screenshot" y acá van al
@@ -313,17 +314,39 @@ task execute(tc, opts, on_event)
313
314
  let verdict be permission.evaluate(name, args, when forced == "auto" then "yolo" otherwise opts["permission_mode"])
314
315
  when forced == "ask" and verdict["decision"] == "allow"
315
316
  set verdict to {"decision": "ask", "reason": "this agent asks before every " + name + " call"}
317
+ -- equipos (lib/worktree.syn): el agente trabaja en SU copia; tocar la historia compartida (merge a main, push…)
318
+ -- lo aprueba siempre la persona, en cualquier modo (salvo lo prohibido, que sigue prohibido)
319
+ let wroot be when contains(opts, "root") and opts["root"] != nothing then text(opts["root"]) otherwise ""
320
+ when wroot != "" and name == "bash" and verdict["decision"] != "deny"
321
+ let shared be worktree.touches_shared(when contains(args, "command") then args["command"] otherwise "")
322
+ when shared != ""
323
+ set verdict to {"decision": "ask", "reason": "touches the shared history (" + shared + ") — the person approves · agent " + (when contains(opts, "agent_id") then text(opts["agent_id"]) otherwise "?")}
316
324
  when verdict["decision"] == "deny"
317
325
  emit(on_event, "tool_denied", {"call": tc, "reason": verdict["reason"]}, tag)
318
326
  give "DENIED by policy (" + verdict["reason"] + "). Do not retry this exact action; explain or propose an alternative."
319
327
  when verdict["decision"] == "ask"
320
328
  let approved be false
329
+ let expired be false
330
+ let waited_min be 0
321
331
  when opts["ask_fn"] != nothing
322
- set approved to call(opts["ask_fn"], {"name": name, "args": args, "why": verdict["reason"]})
332
+ let ans be call(opts["ask_fn"], {"name": name, "args": args, "why": verdict["reason"]})
333
+ -- la cola de aprobaciones (lib/mailbox.syn) dice además si nadie respondió; la terminal y el chat dan un bool
334
+ when type_of(ans) == "map"
335
+ set approved to ans["approved"] == true
336
+ set expired to ans["expired"] == true
337
+ set waited_min to ans["minutes"]
338
+ otherwise
339
+ set approved to ans == true
340
+ when not approved and expired
341
+ emit(on_event, "tool_denied", {"call": tc, "reason": "no answer to the approval request (" + verdict["reason"] + ")"}, tag)
342
+ give "NOT RUN: nobody answered the approval request in " + text(waited_min) + " min (" + verdict["reason"] + "). The action did not happen. Don't retry it right away: tell whoever is waiting on it (your lead with `send`, or the person with `objective` ask), keep working on what doesn't depend on it, and try again later."
323
343
  when not approved
324
344
  emit(on_event, "tool_denied", {"call": tc, "reason": "user declined (" + verdict["reason"] + ")"}, tag)
325
345
  give "DENIED by the user (" + verdict["reason"] + "). Do not retry this exact action; ask the user or propose an alternative."
326
346
  emit(on_event, "busy", {"label": permission.describe_call(name, args), "kind": "tool", "name": name}, tag)
347
+ -- su copia: las tools de archivos y bash operan ahí; los paths que ve el modelo son relativos a ella
348
+ when wroot != "" and (name == "bash" or contains(worktree.FILE_TOOLS, name))
349
+ set args to worktree.rooted(name, args, wroot)
327
350
  let out be ""
328
351
  try
329
352
  -- tools MCP: no son tasks Synsema (args libres); el registry las marca con "mcp"
@@ -332,11 +355,19 @@ task execute(tc, opts, on_event)
332
355
  -- tools de plugins: un proceso hijo por llamada (lib/plugins.syn)
333
356
  otherwise when registry[name] == "plugin"
334
357
  set out to text(plugins.call(name, args))
358
+ -- equipos: send/board saben quién llama por opts.agent_id (el modelo no lo elige: se pisa lo que mande)
359
+ otherwise when name == "send" or name == "board" or name == "objective"
360
+ let targs be args
361
+ set targs["_agent"] to when contains(opts, "agent_id") then opts["agent_id"] otherwise ""
362
+ set targs["_scope"] to when contains(opts, "scope") then opts["scope"] otherwise ""
363
+ set out to text(call_tool(registry[name], targs))
335
364
  otherwise
336
365
  set out to text(call_tool(registry[name], args))
337
366
  recover err
338
367
  set out to "ERROR: " + err
339
368
  emit(on_event, "idle", nothing, tag)
369
+ when wroot != ""
370
+ set out to replace(out, wroot + "/", "")
340
371
  give out
341
372
 
342
373
  export task run_turn(cfg, messages, opts, on_event)
@@ -429,7 +460,19 @@ export task run_turn(cfg, messages, opts, on_event)
429
460
  set msgs to append(msgs, assistant)
430
461
  when clean_text != ""
431
462
  emit(on_event, "assistant", clean_text, tag)
432
- when length(r["tool_calls"]) == 0
463
+ -- buzón de conversación (opts.inbox_final): si mientras el modelo escribía la respuesta llegaron mensajes
464
+ -- nuevos, esa respuesta ya está vieja (visto 2026-10-16: «soy Lucía» llegó a mitad de turno y salió «decime
465
+ -- tu nombre»). Se descarta el borrador, entran los mensajes y el modelo responde de nuevo — un paso más.
466
+ let late be nothing
467
+ when length(r["tool_calls"]) == 0 and not last_step and contains(opts, "inbox_final") and opts["inbox_final"] == true and opts["inbox_fn"] != nothing
468
+ set late to call(opts["inbox_fn"], {"step": steps, "tag": tag})
469
+ when late != nothing and length(late["messages"]) > 0
470
+ set msgs to slice(msgs, 0, length(msgs) - 1)
471
+ emit(on_event, "inbox", "llegaron mensajes mientras respondía: rehago la respuesta", tag)
472
+ each m in late["messages"]
473
+ emit(on_event, "inbox", m, tag)
474
+ set msgs to append(msgs, {"role": "user", "content": m})
475
+ otherwise when length(r["tool_calls"]) == 0
433
476
  set final_text to clean_text
434
477
  give {"messages": msgs, "text": final_text, "steps": steps, "usage": usage, "stopped": when over_budget then "budget" otherwise (when last_step then "max_steps" otherwise "done")}
435
478
  each tc in r["tool_calls"]
@@ -524,5 +567,10 @@ export task with_steps(opts, n)
524
567
  export task with_inbox(opts, inbox_fn, tag)
525
568
  give with_key(with_key(opts, "inbox_fn", inbox_fn), "tag", tag)
526
569
 
570
+ -- buzón de una conversación (lib/mailbox.syn): además de antes de cada llamada, se consulta al terminar; lo que
571
+ -- llegó mientras el modelo respondía rehace la respuesta en lugar de mandar una vieja
572
+ export task with_final_inbox(opts)
573
+ give with_key(opts, "inbox_final", true)
574
+
527
575
  export task with_ask(opts, ask_fn)
528
576
  give with_key(opts, "ask_fn", ask_fn)