lampson 0.5.1 → 0.5.3
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 +2 -0
- package/chat.syn +17 -12
- package/cli.syn +8 -1
- package/hub.tpl.syn +4 -4
- package/lampson.ps1 +2 -2
- package/lampson.sh +7 -4
- package/lib/agents.syn +35 -27
- package/lib/api.syn +37 -35
- package/lib/apikeys.syn +8 -8
- package/lib/approvals.syn +11 -7
- package/lib/apptools.syn +27 -24
- package/lib/channels.syn +38 -36
- package/lib/computer.syn +20 -20
- package/lib/diagnose.syn +9 -7
- package/lib/fs.syn +11 -11
- package/lib/judge.syn +4 -4
- package/lib/loop.syn +46 -21
- package/lib/lsp.syn +13 -13
- package/lib/mailbox.syn +34 -24
- package/lib/mcp.syn +25 -17
- package/lib/mcp_server.syn +34 -26
- package/lib/permission.syn +3 -1
- package/lib/plugins.syn +48 -40
- package/lib/prompt.syn +5 -5
- package/lib/provider.syn +25 -11
- package/lib/remotetools.syn +3 -1
- package/lib/runtime.syn +112 -85
- package/lib/sched_run.syn +19 -13
- package/lib/schedule.syn +25 -23
- package/lib/session.syn +6 -6
- package/lib/settings.syn +10 -10
- package/lib/skills.syn +9 -9
- package/lib/teamrun.syn +75 -28
- package/lib/teams.syn +190 -115
- package/lib/term.syn +2 -2
- package/lib/tools/bash.syn +2 -2
- package/lib/tools/common.syn +3 -3
- package/lib/tools/edit.syn +1 -1
- package/lib/tools/fetch.syn +7 -3
- package/lib/tools/find.syn +1 -1
- package/lib/tools/grep.syn +2 -2
- package/lib/tools/ls.syn +1 -1
- package/lib/tools/memo.syn +7 -7
- package/lib/tools/proc.syn +10 -10
- package/lib/tools/process.syn +1 -1
- package/lib/tools/read.syn +2 -2
- package/lib/tools/todo.syn +3 -3
- package/lib/tools/write.syn +1 -1
- package/lib/tools.syn +17 -15
- package/lib/trace.syn +5 -5
- package/lib/tree.syn +3 -3
- package/lib/update.syn +6 -0
- package/lib/workspaces.syn +25 -25
- package/lib/worktree.syn +323 -24
- package/package.json +2 -2
- package/plugins/chatwoot/plugin.syn +2 -0
- package/plugins/orders/plugin.json +1 -1
- package/plugins/orders/plugin.syn +1 -1
- package/plugins/telegram/plugin.syn +2 -0
- package/public/css/inbox.css +100 -0
- package/public/css/mobile.css +0 -13
- package/public/css/panel.css +21 -0
- package/public/css/teams.css +20 -52
- package/public/hub.html +3 -0
- package/public/index.html +3 -0
- package/public/js/config.js +3 -3
- package/public/js/devices.js +1 -1
- package/public/js/hub.js +3 -2
- package/public/js/inbox.js +234 -0
- package/public/js/navtabs.js +1 -6
- package/public/js/objlive.js +11 -3
- package/public/js/panel.js +12 -6
- package/public/js/teams-home.js +3 -33
- package/public/js/teams.js +35 -114
- package/public/js/workspaces.js +1 -1
- package/public/plugins-home.html +3 -0
- package/public/tasks-home.html +3 -0
- package/public/teams-home.html +3 -1
- package/public/teams.html +3 -2
- package/run.syn +17 -12
- package/sdk/index.d.ts +1 -1
- package/sdk/index.js +51 -8
- package/skills/synsema/SKILL.md +3 -3
- package/web.syn +10 -7
package/lib/teams.syn
CHANGED
|
@@ -40,7 +40,7 @@ let DIGEST_MAX be 30
|
|
|
40
40
|
task open()
|
|
41
41
|
require db(".lampson/teams.db")
|
|
42
42
|
require file(".lampson")
|
|
43
|
-
require file(".lampson
|
|
43
|
+
require file(".lampson/**")
|
|
44
44
|
db_open(DB)
|
|
45
45
|
sql_exec("CREATE TABLE IF NOT EXISTS tasks (id INTEGER PRIMARY KEY AUTOINCREMENT, scope TEXT NOT NULL, title TEXT NOT NULL, notes TEXT DEFAULT '', owner TEXT DEFAULT '', status TEXT DEFAULT 'todo', depends TEXT DEFAULT '[]', created_by TEXT DEFAULT '', created_at REAL, updated_at REAL)")
|
|
46
46
|
sql_exec("CREATE TABLE IF NOT EXISTS ledger (id INTEGER PRIMARY KEY AUTOINCREMENT, scope TEXT NOT NULL, at REAL, actor TEXT, kind TEXT, ref TEXT DEFAULT '', text TEXT DEFAULT '')")
|
|
@@ -50,6 +50,7 @@ task open()
|
|
|
50
50
|
sql_exec("CREATE TABLE IF NOT EXISTS spend (day TEXT, agent TEXT, tokens INTEGER DEFAULT 0, PRIMARY KEY (day, agent))")
|
|
51
51
|
sql_exec("CREATE TABLE IF NOT EXISTS seat_cont (objective INTEGER, agent TEXT, n INTEGER DEFAULT 0, PRIMARY KEY (objective, agent))")
|
|
52
52
|
sql_exec("CREATE TABLE IF NOT EXISTS obj_sessions (objective INTEGER, agent TEXT, session TEXT, PRIMARY KEY (objective, agent))")
|
|
53
|
+
sql_exec("CREATE TABLE IF NOT EXISTS seat_notes (objective INTEGER, agent TEXT, note TEXT, at REAL, PRIMARY KEY (objective, agent))")
|
|
53
54
|
sql_exec("CREATE TABLE IF NOT EXISTS objectives (id INTEGER PRIMARY KEY AUTOINCREMENT, agent TEXT NOT NULL, text TEXT NOT NULL, status TEXT DEFAULT 'active', progress TEXT DEFAULT '', question TEXT DEFAULT '', question_kind TEXT DEFAULT '', reply TEXT DEFAULT '', result TEXT DEFAULT '', round_seconds INTEGER DEFAULT 20, budget_tokens INTEGER DEFAULT 500000, spent INTEGER DEFAULT 0, turns INTEGER DEFAULT 0, last_start REAL DEFAULT 0, last_end REAL DEFAULT 0, created_by TEXT DEFAULT '', created_at REAL, updated_at REAL, team TEXT DEFAULT '')")
|
|
54
55
|
-- bases creadas antes de los objetivos de equipo
|
|
55
56
|
try
|
|
@@ -62,6 +63,12 @@ task open()
|
|
|
62
63
|
sql_exec("ALTER TABLE objectives ADD COLUMN " + col)
|
|
63
64
|
recover err
|
|
64
65
|
set err to err
|
|
66
|
+
-- bases creadas antes de los mensajes numerados: seen = el último mensaje del destinatario que el remitente ya
|
|
67
|
+
-- tenía cuando escribió (lib/teamrun.syn avisa si se cruzaron)
|
|
68
|
+
try
|
|
69
|
+
sql_exec("ALTER TABLE messages ADD COLUMN seen INTEGER DEFAULT 0")
|
|
70
|
+
recover err
|
|
71
|
+
set err to err
|
|
65
72
|
-- bases creadas antes de las tareas por objetivo: la columna, y las tareas que ya había (una sola vez, cuando se
|
|
66
73
|
-- agrega): las de un objetivo solo, por su scope; las de un equipo, al último objetivo del equipo creado antes
|
|
67
74
|
try
|
|
@@ -112,7 +119,7 @@ export task validate(raw, source)
|
|
|
112
119
|
-- todos los equipos del proyecto: {teams, errors}
|
|
113
120
|
export task scan()
|
|
114
121
|
require file.read("workspace")
|
|
115
|
-
require file.read("workspace
|
|
122
|
+
require file.read("workspace/**")
|
|
116
123
|
let teams be []
|
|
117
124
|
let errors be []
|
|
118
125
|
try
|
|
@@ -133,24 +140,38 @@ export task scan()
|
|
|
133
140
|
|
|
134
141
|
export task all()
|
|
135
142
|
require file.read("workspace")
|
|
136
|
-
require file.read("workspace
|
|
143
|
+
require file.read("workspace/**")
|
|
137
144
|
give scan()["teams"]
|
|
138
145
|
|
|
139
146
|
export task get(id)
|
|
140
147
|
require file.read("workspace")
|
|
141
|
-
require file.read("workspace
|
|
148
|
+
require file.read("workspace/**")
|
|
142
149
|
let f be where(all(), (t) => t["id"] == id)
|
|
143
150
|
give when length(f) == 0 then nothing otherwise f[0]
|
|
144
151
|
|
|
145
152
|
export task teams_of(agent)
|
|
146
153
|
require file.read("workspace")
|
|
147
|
-
require file.read("workspace
|
|
154
|
+
require file.read("workspace/**")
|
|
148
155
|
give where(all(), (t) => length(where(t["members"], (m) => m["agent"] == agent)) > 0)
|
|
149
156
|
|
|
150
157
|
export task member(team, agent)
|
|
151
158
|
let f be where(team["members"], (m) => m["agent"] == agent)
|
|
152
159
|
give when length(f) == 0 then nothing otherwise f[0]
|
|
153
160
|
|
|
161
|
+
-- los que dependen de `agent`, directa o indirectamente (el Dev del CTO; para el líder, todos): en sus copias puede
|
|
162
|
+
-- trabajar (lib/worktree.syn, la regla del asiento)
|
|
163
|
+
export task below(team, agent)
|
|
164
|
+
let out be []
|
|
165
|
+
let frontier be [agent]
|
|
166
|
+
while length(frontier) > 0
|
|
167
|
+
let nxt be []
|
|
168
|
+
each m in team["members"]
|
|
169
|
+
when contains(frontier, m["reports_to"]) and m["agent"] != agent and not contains(out, m["agent"])
|
|
170
|
+
set out to append(out, m["agent"])
|
|
171
|
+
set nxt to append(nxt, m["agent"])
|
|
172
|
+
set frontier to nxt
|
|
173
|
+
give out
|
|
174
|
+
|
|
154
175
|
-- a quién le puede escribir `agent` en el equipo: su jefe, los que le reportan y los pares de "talks" (la pantalla los
|
|
155
176
|
-- propone al unir dos asientos bajo el mismo jefe, pero se hablan solo si el par está: lo decide quien arma el equipo)
|
|
156
177
|
export task peers(team, agent)
|
|
@@ -180,7 +201,7 @@ task managers(team, agent)
|
|
|
180
201
|
-- el equipo de una llamada: el pedido (`team`) o el único del agente. {ok, team} / {ok: false, error}
|
|
181
202
|
export task resolve(agent, wanted)
|
|
182
203
|
require file.read("workspace")
|
|
183
|
-
require file.read("workspace
|
|
204
|
+
require file.read("workspace/**")
|
|
184
205
|
let mine be teams_of(agent)
|
|
185
206
|
when wanted != nothing and text(wanted) != ""
|
|
186
207
|
let f be where(mine, (t) => t["id"] == lower(text(wanted)))
|
|
@@ -196,61 +217,32 @@ export task resolve(agent, wanted)
|
|
|
196
217
|
-- qué puede hacer un asiento, según las tools de su archivo: así nadie se asigna (ni le asignan) algo que no puede
|
|
197
218
|
-- hacer. (Visto 2026-10-17: un CEO con «leer y correr comandos» se quedó con la implementación y, sin edit ni write,
|
|
198
219
|
-- «editaba» con `echo edit-1`.)
|
|
199
|
-
task can_do(agent)
|
|
200
|
-
require file.read("workspace")
|
|
201
|
-
require file.read("workspace/*")
|
|
202
|
-
let tools be nothing
|
|
203
|
-
each f in ["workspace/.lampson/agents/" + agent + ".agent.json", "agents/" + agent + ".agent.json"]
|
|
204
|
-
when tools == nothing and file_exists(f)
|
|
205
|
-
try
|
|
206
|
-
let spec be json_decode(read_file(f))
|
|
207
|
-
set tools to when contains(spec, "tools") then spec["tools"] otherwise nothing
|
|
208
|
-
recover err
|
|
209
|
-
set tools to nothing
|
|
210
|
-
when tools == nothing
|
|
211
|
-
give ""
|
|
212
|
-
when contains(tools, "edit") or contains(tools, "write")
|
|
213
|
-
give " — can edit files and run commands"
|
|
214
|
-
when contains(tools, "bash")
|
|
215
|
-
give " — can read and run commands, cannot edit files"
|
|
216
|
-
when length(tools) == 0
|
|
217
|
-
give " — coordinates only (no file tools)"
|
|
218
|
-
give " — can read, cannot edit files"
|
|
219
|
-
|
|
220
220
|
-- lo que el agente tiene que saber de su equipo, para su prompt (lib/runtime.syn → system_for)
|
|
221
221
|
export task instructions(agent)
|
|
222
222
|
require file.read("workspace")
|
|
223
|
-
require file.read("workspace
|
|
223
|
+
require file.read("workspace/**")
|
|
224
224
|
let out be ""
|
|
225
225
|
each t in teams_of(agent)
|
|
226
226
|
let me be member(t, agent)
|
|
227
227
|
let lines be []
|
|
228
228
|
each m in t["members"]
|
|
229
|
-
set lines to append(lines, "- " + m["agent"] + ": " + m["role"] + (when m["reports_to"] != "" then " (reports to " + m["reports_to"] + ")" otherwise "")
|
|
229
|
+
set lines to append(lines, "- " + m["agent"] + ": " + m["role"] + (when m["reports_to"] != "" then " (reports to " + m["reports_to"] + ")" otherwise ""))
|
|
230
230
|
let ps be peers(t, agent)
|
|
231
231
|
let lead be lead_of(t)
|
|
232
|
-
-- los que dependen de él (directos o no):
|
|
233
|
-
let subs be
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
set subs to append(subs, m["agent"])
|
|
240
|
-
set nxt to append(nxt, m["agent"])
|
|
241
|
-
set frontier to nxt
|
|
242
|
-
-- la cadena de mando: cada uno le pregunta a su jefe; solo el líder le pregunta a la persona (y solo lo que el
|
|
243
|
-
-- equipo no puede resolver). Lo mismo con lo que necesita aprobación: lib/loop.syn no deja que un asiento que
|
|
244
|
-
-- no es el líder abra una aprobación a la persona (opts.escalate_to, lib/runtime.syn)
|
|
245
|
-
let chain be when agent == lead then "\nYou lead the team. The others bring their questions and anything that needs approval to their boss, and it comes up to you only if their boss can't solve it. Solve what you can: decide, unblock, re-plan. Ask the person (`objective` ask or request_approval) only what truly only they can decide or approve — they shouldn't hear about anything the team can handle." otherwise "\nChain of command: when you are stuck, unsure what to do, or need a decision, ask " + me["reports_to"] + " with `send` — never the person. Anything that needs approval (a merge, a push, a risky command) also goes to " + me["reports_to"] + ": you can't ask the person, only the lead does, and only if it is really needed. When someone who reports to you asks you something, answer it if you can; if you can't, ask your own boss."
|
|
246
|
-
set out to out + "\n\n# Team " + t["id"] + (when t["description"] != "" then " — " + t["description"] otherwise "") + "\nYou are " + agent + ", role: " + me["role"] + "." + (when me["reports_to"] != "" then " You report to " + me["reports_to"] + "." otherwise "") + "\nMembers:\n" + join(lines, "\n") + "\nYou can message: " + (when length(ps) == 0 then "nobody" otherwise join(ps, ", ")) + " (with `send`). Messages to anyone else are rejected.\nThe shared work lives on the board (`board`): list it, take a task before working on it (`claim`), move it as you go (doing → review → done, or blocked with a note; when you review a task in review, move it to done if it passes or back to doing with what to fix — if it is not yours to move, tell its owner), add the tasks you break work into. Never work on a task someone else owns. Give each task to someone who can do it (see what each member can do above); if a task needs a tool you don't have, hand it over instead of trying. Each turn starts with what changed in the team since your last turn. A teammate who hasn't answered is usually still in the middle of a turn: wait for their reply instead of asking again or giving their task to someone else — reassign only if they say they are blocked. If a teammate runs out of steps mid-turn, Lampson gives them another turn in the same conversation to finish; if they get stuck anyway, a message from you gives them a fresh turn to continue. Your final reply in a turn is not seen by anyone: to tell someone something, `send` it; to record progress, update the board." + chain + (when t["worktrees"] then "\nGit: if the project uses git, you work in your OWN working copy (it is your root for files and bash), on branch team/" + t["id"] + "/" + agent + ", and your commits carry your name. Use relative paths: absolute paths into the project point to the main checkout, not to your copy. Commit your work there and say which branch when you hand it over. The main checkout is ../../.. — merging into it (e.g. `git -C ../../.. merge team/" + t["id"] + "/<agent>`) or pushing touches the shared history: " + (when agent == lead then "Lampson asks the person to approve it first." otherwise "only the lead does it (Lampson asks the person to approve it) — hand your branch over to " + me["reports_to"] + ".") + (when length(subs) > 0 then " You can see the work of those who report to you (" + join(subs, ", ") + "): their commits with `git log/diff/show team/" + t["id"] + "/<agent>`, their uncommitted changes with `git -C ../<agent> status` and `git -C ../<agent> diff`. If one of them is stuck or slow, or two of them overlap, step in like a manager would: bring their branch into your copy (`git merge team/" + t["id"] + "/<agent>`), finish or fix it there, and tell them (and your boss) what you took over. Don't edit files inside their copies." otherwise " Don't edit files of other agents' copies.") otherwise "")
|
|
232
|
+
-- los que dependen de él (directos o no): trabaja también en sus copias, como un jefe que se sienta a arreglarlo
|
|
233
|
+
let subs be below(t, agent)
|
|
234
|
+
-- una organización: la persona es el directorio (da el objetivo, aprueba solo el borde); las dudas y decisiones
|
|
235
|
+
-- suben por la cadena de mando, y solo el líder le pregunta a la persona. Los permisos no suben por la cadena: la
|
|
236
|
+
-- regla del asiento (lib/worktree.syn) da autonomía total en su copia y lo de borde va directo a la persona
|
|
237
|
+
let chain be when agent == lead then "\nYou lead the team, and the person is your board of directors: they set the objective and only see what crosses the company's border. The others bring their questions and decisions to their boss, and it comes up to you only if their boss can't solve it. Solve what you can: decide, unblock, re-plan. Ask the person (`objective` ask) only what truly only they can decide — they shouldn't hear about anything the team can handle." otherwise "\nChain of command: when you are stuck, unsure what to do, or need a decision, ask " + me["reports_to"] + " with `send` — never the person. When someone who reports to you asks you something, answer it if you can; if you can't, ask your own boss."
|
|
238
|
+
set out to out + "\n\n# Team " + t["id"] + (when t["description"] != "" then " — " + t["description"] otherwise "") + "\nYou are " + agent + ", role: " + me["role"] + "." + (when me["reports_to"] != "" then " You report to " + me["reports_to"] + "." otherwise "") + "\nMembers:\n" + join(lines, "\n") + "\nYou can message: " + (when length(ps) == 0 then "nobody" otherwise join(ps, ", ")) + " (with `send`). Messages to anyone else are rejected.\nThe shared work lives on the board (`board`): list it, take a task before working on it (`claim`), move it as you go (doing → review → done, or blocked with a note; when you review a task in review, move it to done if it passes or back to doing with what to fix — if it is not yours to move, tell its owner), add the tasks you break work into. Never work on a task someone else owns. Check ONCE: tokens are the team's budget, and redoing a fix now and then costs less than everyone checking everything every time. Each change is checked by ONE person: whoever the team gives that job (a reviewer or QA role), or else whoever did the task, in their copy, saying so (commit + result). That IS the check. Nobody re-runs what a teammate already ran on the same commit, re-checks someone else's check, or builds a parallel smoke test; nobody tests before there is something to test. Docs are checked against the code by whoever writes them, and by no one else. Whoever integrates trusts the commits they get: merge, run the tests ONCE after merging, done. If something breaks later, fix it then. Every member has ALL of Lampson's tools (read, write, edit, bash, process, lsp, fetch, memory, todo, skill, the plugins and MCP servers of the project): your role says what you are responsible for, not what you are able to do. Give each task to whoever owns that part; if something blocks the objective and fixing it yourself is faster than explaining it, fix it and tell its owner what you changed. Each turn starts with what changed in the team since your last turn. A teammate who hasn't answered is usually still in the middle of a turn: wait for their reply instead of asking again or giving their task to someone else — reassign only if they say they are blocked. If a teammate runs out of steps mid-turn, Lampson gives them another turn in the same conversation to finish; if they get stuck anyway, a message from you gives them a fresh turn to continue. Each turn starts a FRESH conversation: you get the team news, the board, the messages that woke you and the note you left yourself — not your earlier turns (re-read a file if you need it). Your final reply in a turn is that note to yourself, and nobody else reads it: end every turn with a few lines — what you did, what you tried that didn't work, what's next. To tell someone something, `send` it; to record progress, update the board. Don't send acknowledgements or thanks (\"received\", \"ok\", \"thanks\", \"standing by\"): every message wakes its recipient for a turn. Send only what someone needs to act on. Messages are numbered (#n); one marked as written BEFORE its sender got yours crossed with it: answer only what is still open and don't redo work you already sent." + chain + (when t["worktrees"] then "\nGit: if the project uses git, your OWN working copy is your workplace: bash and the file tools start there (it is your root), on branch team/" + t["id"] + "/" + agent + ", and your commits carry your name. There you have full autonomy — install, build, test, delete, reset, branch, commit: nobody approves anything there, so never ask anyone for permission to do your work. Use relative paths: the other agents' copies are ../<agent> and the person's own copy of the project (the main checkout, on the main branch) is ../../..; you can READ anything in the project, nothing outside it." + (when agent == lead then " As the lead you can also work directly in every teammate's copy (../<agent>): fix, finish, run their tests — then tell its owner what you changed." otherwise (when length(subs) > 0 then " You can also work directly in the copies of those under you (" + join(subs, ", ") + "): fix, finish, run their tests — then tell them what you changed. The other copies are read-only for you: to build on someone else's work, merge their branch into your copy (`git merge team/" + t["id"] + "/<agent>`)." otherwise " The other copies are read-only for you: to build on or test someone's work, merge their branch into your copy (`git merge team/" + t["id"] + "/<agent>`) and work there.")) + (when agent == lead or length(subs) > 0 then " The person's copy (../../..) is where the work lands: integrating into the main branch and whatever that needs there (a conflict, the tests, a tag) is yours to do — the person approves working there ONCE per objective, and after that nothing there asks again. Do it cleanly: merge every branch into YOUR copy first, resolve conflicts and run the tests there, then bring it over with `git -C ../../.. merge --ff-only team/" + t["id"] + "/" + agent + "` so the person's copy never sees a conflict, and leave no stray files in it." otherwise " Integrating into the main branch is your boss's: commit your work and hand your branch over to " + me["reports_to"] + ".") + " Pushing " + (when agent == lead then "is yours only, and every push asks the person." otherwise "is only for the lead.") + " If a command comes back NOT RUN because of a team rule, the command itself was fine: do what the message says instead of retrying variants." otherwise "")
|
|
247
239
|
give out
|
|
248
240
|
|
|
249
241
|
-- ---------- registro ----------
|
|
250
242
|
export task log(scope, actor, kind, ref, txt)
|
|
251
243
|
require db(".lampson/teams.db")
|
|
252
244
|
require file(".lampson")
|
|
253
|
-
require file(".lampson
|
|
245
|
+
require file(".lampson/**")
|
|
254
246
|
require time
|
|
255
247
|
open()
|
|
256
248
|
let id be sql_exec("INSERT INTO ledger (scope, at, actor, kind, ref, text) VALUES (?, ?, ?, ?, ?, ?)", [scope, now(), actor, kind, ref, slice(text(txt), 0, 400)])["last_id"]
|
|
@@ -261,7 +253,7 @@ export task log(scope, actor, kind, ref, txt)
|
|
|
261
253
|
export task ledger(scope, after, limit)
|
|
262
254
|
require db(".lampson/teams.db")
|
|
263
255
|
require file(".lampson")
|
|
264
|
-
require file(".lampson
|
|
256
|
+
require file(".lampson/**")
|
|
265
257
|
open()
|
|
266
258
|
give sql("SELECT * FROM ledger WHERE scope = ? AND id > ? ORDER BY id DESC LIMIT ?", [scope, after, limit])
|
|
267
259
|
|
|
@@ -269,7 +261,7 @@ export task ledger(scope, after, limit)
|
|
|
269
261
|
export task digest(scope, agent)
|
|
270
262
|
require db(".lampson/teams.db")
|
|
271
263
|
require file(".lampson")
|
|
272
|
-
require file(".lampson
|
|
264
|
+
require file(".lampson/**")
|
|
273
265
|
open()
|
|
274
266
|
let cur be sql("SELECT last FROM cursors WHERE agent = ? AND scope = ?", [agent, scope])
|
|
275
267
|
let after be when length(cur) == 0 then 0 otherwise cur[0]["last"]
|
|
@@ -289,14 +281,14 @@ task row_text(t)
|
|
|
289
281
|
export task tasks(scope)
|
|
290
282
|
require db(".lampson/teams.db")
|
|
291
283
|
require file(".lampson")
|
|
292
|
-
require file(".lampson
|
|
284
|
+
require file(".lampson/**")
|
|
293
285
|
open()
|
|
294
286
|
give sql("SELECT * FROM tasks WHERE scope = ? ORDER BY id", [scope])
|
|
295
287
|
|
|
296
288
|
export task task_get(scope, id)
|
|
297
289
|
require db(".lampson/teams.db")
|
|
298
290
|
require file(".lampson")
|
|
299
|
-
require file(".lampson
|
|
291
|
+
require file(".lampson/**")
|
|
300
292
|
open()
|
|
301
293
|
let r be sql("SELECT * FROM tasks WHERE scope = ? AND id = ?", [scope, id])
|
|
302
294
|
give when length(r) == 0 then nothing otherwise r[0]
|
|
@@ -304,7 +296,7 @@ export task task_get(scope, id)
|
|
|
304
296
|
export task add_task(scope, actor, title, notes, owner, depends)
|
|
305
297
|
require db(".lampson/teams.db")
|
|
306
298
|
require file(".lampson")
|
|
307
|
-
require file(".lampson
|
|
299
|
+
require file(".lampson/**")
|
|
308
300
|
require time
|
|
309
301
|
open()
|
|
310
302
|
when trim(text(title)) == ""
|
|
@@ -329,7 +321,7 @@ export task objective_of_scope(scope)
|
|
|
329
321
|
export task claim(scope, actor, id)
|
|
330
322
|
require db(".lampson/teams.db")
|
|
331
323
|
require file(".lampson")
|
|
332
|
-
require file(".lampson
|
|
324
|
+
require file(".lampson/**")
|
|
333
325
|
require time
|
|
334
326
|
open()
|
|
335
327
|
let t be task_get(scope, id)
|
|
@@ -355,7 +347,7 @@ export task claim(scope, actor, id)
|
|
|
355
347
|
export task update_task(scope, team, actor, id, changes)
|
|
356
348
|
require db(".lampson/teams.db")
|
|
357
349
|
require file(".lampson")
|
|
358
|
-
require file(".lampson
|
|
350
|
+
require file(".lampson/**")
|
|
359
351
|
require time
|
|
360
352
|
open()
|
|
361
353
|
let t be task_get(scope, id)
|
|
@@ -389,12 +381,12 @@ export task update_task(scope, team, actor, id, changes)
|
|
|
389
381
|
export task send(team, sender, dest, txt)
|
|
390
382
|
require db(".lampson/teams.db")
|
|
391
383
|
require file(".lampson")
|
|
392
|
-
require file(".lampson
|
|
384
|
+
require file(".lampson/**")
|
|
393
385
|
require time
|
|
394
386
|
require file.read("workspace")
|
|
395
|
-
require file.read("workspace
|
|
387
|
+
require file.read("workspace/**")
|
|
396
388
|
require file.read("agents")
|
|
397
|
-
require file.read("agents
|
|
389
|
+
require file.read("agents/**")
|
|
398
390
|
open()
|
|
399
391
|
let d be lower(trim(text(dest)))
|
|
400
392
|
when member(team, d) == nothing
|
|
@@ -407,16 +399,54 @@ export task send(team, sender, dest, txt)
|
|
|
407
399
|
when not file_exists("workspace/.lampson/agents/" + d + ".agent.json") and not file_exists("agents/" + d + ".agent.json")
|
|
408
400
|
raise(d + " is in the team but has no agent file, so nobody would read it — tell the person (the team needs .lampson/agents/" + d + ".agent.json)")
|
|
409
401
|
let scope be "team:" + team["id"]
|
|
410
|
-
let
|
|
402
|
+
let sn be sql("SELECT MAX(id) AS m FROM messages WHERE scope = ? AND sender = ? AND recipient = ? AND state = 'delivered'", [scope, d, sender])
|
|
403
|
+
let seen be when length(sn) == 0 or sn[0]["m"] == nothing then 0 otherwise sn[0]["m"]
|
|
404
|
+
let id be sql_exec("INSERT INTO messages (scope, sender, recipient, text, at, seen) VALUES (?, ?, ?, ?, ?, ?)", [scope, sender, d, text(txt), now(), seen])["last_id"]
|
|
411
405
|
log(scope, sender, "message", "→ " + d, text(txt))
|
|
412
406
|
give id
|
|
413
407
|
|
|
408
|
+
-- la cabeza de un mensaje al entregarlo: su número, quién lo manda y si se cruzó con uno del destinatario. Un mensaje
|
|
409
|
+
-- escrito antes de que el remitente recibiera el último del destinatario se cruzó con él: el que lo lee no tiene que
|
|
410
|
+
-- rehacer lo que ya mandó. (Visto en O-16: el CEO pidió «rehacé los candidatos» justo cuando el CTO mandaba los nuevos.)
|
|
411
|
+
export task msg_head(team, m)
|
|
412
|
+
require db(".lampson/teams.db")
|
|
413
|
+
require file(".lampson")
|
|
414
|
+
require file(".lampson/**")
|
|
415
|
+
open()
|
|
416
|
+
when m["sender"] == "person"
|
|
417
|
+
give "[message from the person who owns this team — act on it]\n" + m["text"]
|
|
418
|
+
let who be member(team, m["sender"])
|
|
419
|
+
let seen be field(m, "seen", 0)
|
|
420
|
+
let tag be "#" + text(m["id"]) + " from " + m["sender"] + (when who != nothing then " (" + who["role"] + ")" otherwise "")
|
|
421
|
+
let cross be sql("SELECT id FROM messages WHERE scope = ? AND sender = ? AND recipient = ? AND id > ? AND id < ? ORDER BY id", [m["scope"], m["recipient"], m["sender"], when seen == nothing then 0 otherwise seen, m["id"]])
|
|
422
|
+
when length(cross) > 0
|
|
423
|
+
let ids be join(apply(cross, (x) => "#" + text(x["id"])), ", ")
|
|
424
|
+
give "[message " + tag + " — written BEFORE " + m["sender"] + " got your " + ids + ": it crossed with yours. Answer only what is still open; don't redo what you already sent]\n" + m["text"]
|
|
425
|
+
give "[message " + tag + (when seen != nothing and seen > 0 then ", after reading your #" + text(seen) otherwise "") + "]\n" + m["text"]
|
|
426
|
+
|
|
427
|
+
-- ¿el mensaje es de un objetivo que ya terminó? los que se mandan al cerrar (o hasta 2 min después, mientras terminan
|
|
428
|
+
-- sus turnos) no despiertan a nadie: el objetivo está entregado. (Visto en O-16: el CEO cerró sin esperar la
|
|
429
|
+
-- confirmación que había pedido y el CPO se despertó para contestarle a nadie.) La persona siempre llega.
|
|
430
|
+
export let CLOSED_GRACE be 120
|
|
431
|
+
|
|
432
|
+
export task after_close(team_id, m)
|
|
433
|
+
require db(".lampson/teams.db")
|
|
434
|
+
require file(".lampson")
|
|
435
|
+
require file(".lampson/**")
|
|
436
|
+
open()
|
|
437
|
+
when m["sender"] == "person"
|
|
438
|
+
give false
|
|
439
|
+
let r be sql("SELECT status, created_at, updated_at FROM objectives WHERE team = ? ORDER BY id DESC LIMIT 1", [team_id])
|
|
440
|
+
when length(r) == 0 or not contains(["done", "cancelled", "failed"], r[0]["status"])
|
|
441
|
+
give false
|
|
442
|
+
give m["at"] >= r[0]["created_at"] and m["at"] <= r[0]["updated_at"] + CLOSED_GRACE
|
|
443
|
+
|
|
414
444
|
-- los mensajes por entregar (los entrega lib/teamrun.syn por el buzón)
|
|
415
445
|
-- cuánto hace que no pasa nada en un scope (segundos desde lo último del registro; con mensajes por entregar, 0)
|
|
416
446
|
export task quiet_for(scope)
|
|
417
447
|
require db(".lampson/teams.db")
|
|
418
448
|
require file(".lampson")
|
|
419
|
-
require file(".lampson
|
|
449
|
+
require file(".lampson/**")
|
|
420
450
|
require time
|
|
421
451
|
open()
|
|
422
452
|
when sql("SELECT COUNT(*) AS n FROM messages WHERE scope = ? AND state = 'pending'", [scope])[0]["n"] > 0
|
|
@@ -427,14 +457,14 @@ export task quiet_for(scope)
|
|
|
427
457
|
export task pending()
|
|
428
458
|
require db(".lampson/teams.db")
|
|
429
459
|
require file(".lampson")
|
|
430
|
-
require file(".lampson
|
|
460
|
+
require file(".lampson/**")
|
|
431
461
|
open()
|
|
432
462
|
give sql("SELECT * FROM messages WHERE state = 'pending' ORDER BY id", [])
|
|
433
463
|
|
|
434
464
|
export task mark(id, state)
|
|
435
465
|
require db(".lampson/teams.db")
|
|
436
466
|
require file(".lampson")
|
|
437
|
-
require file(".lampson
|
|
467
|
+
require file(".lampson/**")
|
|
438
468
|
open()
|
|
439
469
|
sql_exec("UPDATE messages SET state = ? WHERE id = ?", [state, id])
|
|
440
470
|
give true
|
|
@@ -447,7 +477,7 @@ task today()
|
|
|
447
477
|
export task record_spend(agent, tokens)
|
|
448
478
|
require db(".lampson/teams.db")
|
|
449
479
|
require file(".lampson")
|
|
450
|
-
require file(".lampson
|
|
480
|
+
require file(".lampson/**")
|
|
451
481
|
require time
|
|
452
482
|
open()
|
|
453
483
|
sql_exec("INSERT INTO spend (day, agent, tokens) VALUES (?, ?, ?) ON CONFLICT(day, agent) DO UPDATE SET tokens = tokens + excluded.tokens", [today(), agent, floor(tokens)])
|
|
@@ -458,7 +488,7 @@ export task record_spend(agent, tokens)
|
|
|
458
488
|
export task archive(id)
|
|
459
489
|
require db(".lampson/teams.db")
|
|
460
490
|
require file(".lampson")
|
|
461
|
-
require file(".lampson
|
|
491
|
+
require file(".lampson/**")
|
|
462
492
|
require time
|
|
463
493
|
open()
|
|
464
494
|
let a be id + "~" + format_time(now(), "%Y%m%d-%H%M%S")
|
|
@@ -472,7 +502,7 @@ export task archive(id)
|
|
|
472
502
|
export task forget_spend(agent)
|
|
473
503
|
require db(".lampson/teams.db")
|
|
474
504
|
require file(".lampson")
|
|
475
|
-
require file(".lampson
|
|
505
|
+
require file(".lampson/**")
|
|
476
506
|
open()
|
|
477
507
|
sql_exec("DELETE FROM spend WHERE agent = ?", [agent])
|
|
478
508
|
give true
|
|
@@ -480,7 +510,7 @@ export task forget_spend(agent)
|
|
|
480
510
|
export task spent_today(agent)
|
|
481
511
|
require db(".lampson/teams.db")
|
|
482
512
|
require file(".lampson")
|
|
483
|
-
require file(".lampson
|
|
513
|
+
require file(".lampson/**")
|
|
484
514
|
require time
|
|
485
515
|
open()
|
|
486
516
|
let r be sql("SELECT tokens FROM spend WHERE day = ? AND agent = ?", [today(), agent])
|
|
@@ -496,7 +526,7 @@ export task cap_of(team, agent)
|
|
|
496
526
|
export task seat_tokens(agent, action, tokens)
|
|
497
527
|
require db(".lampson/teams.db")
|
|
498
528
|
require file(".lampson")
|
|
499
|
-
require file(".lampson
|
|
529
|
+
require file(".lampson/**")
|
|
500
530
|
require time
|
|
501
531
|
open()
|
|
502
532
|
let before be spent_today(agent)
|
|
@@ -507,7 +537,7 @@ export task seat_tokens(agent, action, tokens)
|
|
|
507
537
|
export task over_budget(team, agent)
|
|
508
538
|
require db(".lampson/teams.db")
|
|
509
539
|
require file(".lampson")
|
|
510
|
-
require file(".lampson
|
|
540
|
+
require file(".lampson/**")
|
|
511
541
|
require time
|
|
512
542
|
let cap be cap_of(team, agent)
|
|
513
543
|
when cap <= 0 or spent_today(agent) < cap
|
|
@@ -515,7 +545,8 @@ export task over_budget(team, agent)
|
|
|
515
545
|
-- con un objetivo abierto que todavía tiene presupuesto, manda ese presupuesto (lo aprobó la persona): el tope
|
|
516
546
|
-- diario es para las rondas sueltas. (Visto 2026-10-17: el CTO llegó al tope a mitad de O-5 y el equipo quedó
|
|
517
547
|
-- esperando su revisión con el objetivo «en curso» y nadie trabajando.)
|
|
518
|
-
|
|
548
|
+
-- esperando a la persona también cuenta: si no, el líder que preguntó quedaba «sin turnos por hoy» (O-18)
|
|
549
|
+
let r be sql("SELECT id FROM objectives WHERE team = ? AND status IN ('active', 'waiting') AND (budget_tokens <= 0 OR spent < budget_tokens) LIMIT 1", [team["id"]])
|
|
519
550
|
give length(r) == 0
|
|
520
551
|
|
|
521
552
|
-- la conversación que usó cada asiento en cada objetivo: el primer turno de un asiento en un objetivo arranca una
|
|
@@ -524,7 +555,7 @@ export task over_budget(team, agent)
|
|
|
524
555
|
export task seat_session(oid, agent, sid)
|
|
525
556
|
require db(".lampson/teams.db")
|
|
526
557
|
require file(".lampson")
|
|
527
|
-
require file(".lampson
|
|
558
|
+
require file(".lampson/**")
|
|
528
559
|
open()
|
|
529
560
|
sql_exec("INSERT OR IGNORE INTO obj_sessions (objective, agent, session) VALUES (?, ?, ?)", [oid, agent, sid])
|
|
530
561
|
give true
|
|
@@ -532,7 +563,7 @@ export task seat_session(oid, agent, sid)
|
|
|
532
563
|
export task seat_session_of(oid, agent)
|
|
533
564
|
require db(".lampson/teams.db")
|
|
534
565
|
require file(".lampson")
|
|
535
|
-
require file(".lampson
|
|
566
|
+
require file(".lampson/**")
|
|
536
567
|
open()
|
|
537
568
|
let r be sql("SELECT session FROM obj_sessions WHERE objective = ? AND agent = ?", [oid, agent])
|
|
538
569
|
give when length(r) == 0 then "" otherwise r[0]["session"]
|
|
@@ -545,7 +576,7 @@ export task seat_session_of(oid, agent)
|
|
|
545
576
|
export task has_work(scope, agent)
|
|
546
577
|
require db(".lampson/teams.db")
|
|
547
578
|
require file(".lampson")
|
|
548
|
-
require file(".lampson
|
|
579
|
+
require file(".lampson/**")
|
|
549
580
|
open()
|
|
550
581
|
-- sus tareas abiertas; una «por hacer» que depende de otras sin terminar todavía no es trabajo (visto 2026-10-18:
|
|
551
582
|
-- el CEO tenía «merge cuando estén #49 y #50» y recibía una ronda por minuto, ~38k tokens cada una, para esperar)
|
|
@@ -569,6 +600,21 @@ export task has_work(scope, agent)
|
|
|
569
600
|
give true
|
|
570
601
|
give false
|
|
571
602
|
|
|
603
|
+
-- ¿le asignaron una tarea desde su último turno? (otro la creó con él de dueño, o le pasó una existente)
|
|
604
|
+
export task assigned_since(scope, agent)
|
|
605
|
+
require db(".lampson/teams.db")
|
|
606
|
+
require file(".lampson")
|
|
607
|
+
require file(".lampson/**")
|
|
608
|
+
open()
|
|
609
|
+
let cur be sql("SELECT last FROM cursors WHERE agent = ? AND scope = ?", [agent, scope])
|
|
610
|
+
let after be when length(cur) == 0 then 0 otherwise cur[0]["last"]
|
|
611
|
+
each r in sql("SELECT * FROM ledger WHERE scope = ? AND id > ? AND actor != ? AND kind IN ('added', 'updated')", [scope, after, agent])
|
|
612
|
+
when r["kind"] == "added" and ends_with(r["text"], "→ " + agent)
|
|
613
|
+
give true
|
|
614
|
+
when r["kind"] == "updated" and contains(r["text"], "owner " + agent)
|
|
615
|
+
give true
|
|
616
|
+
give false
|
|
617
|
+
|
|
572
618
|
task deps_done(scope, t)
|
|
573
619
|
each d in json_decode(field(t, "depends", "[]"))
|
|
574
620
|
let x be task_get(scope, floor(number(d)))
|
|
@@ -587,12 +633,17 @@ task owner_of(scope, ref)
|
|
|
587
633
|
export task round_due(team, agent)
|
|
588
634
|
require db(".lampson/teams.db")
|
|
589
635
|
require file(".lampson")
|
|
590
|
-
require file(".lampson
|
|
636
|
+
require file(".lampson/**")
|
|
591
637
|
require time
|
|
592
|
-
when team["round_minutes"] <= 0
|
|
593
|
-
give false
|
|
594
638
|
open()
|
|
595
639
|
let scope be "team:" + team["id"]
|
|
640
|
+
-- sin rondas: lo despierta solo una tarea que le asignaron desde su último turno (los mensajes ya llegan solos).
|
|
641
|
+
-- Visto 2026-10-19: el CEO repartió #60 al CPO y #61 al CTO sin escribirles, y el equipo quedó quieto 10 minutos
|
|
642
|
+
when team["round_minutes"] <= 0
|
|
643
|
+
when not assigned_since(scope, agent)
|
|
644
|
+
give false
|
|
645
|
+
let up0 be sql_exec("INSERT INTO rounds (agent, scope, last_at) VALUES (?, ?, ?) ON CONFLICT(agent, scope) DO UPDATE SET last_at = excluded.last_at", [agent, scope, now()])
|
|
646
|
+
give true
|
|
596
647
|
let r be sql("SELECT last_at FROM rounds WHERE agent = ? AND scope = ?", [agent, scope])
|
|
597
648
|
let last be when length(r) == 0 then 0 otherwise r[0]["last_at"]
|
|
598
649
|
when now() - last < team["round_minutes"] * 60
|
|
@@ -606,19 +657,38 @@ export task round_due(team, agent)
|
|
|
606
657
|
export task turn_text(team, agent, head)
|
|
607
658
|
require db(".lampson/teams.db")
|
|
608
659
|
require file(".lampson")
|
|
609
|
-
require file(".lampson
|
|
660
|
+
require file(".lampson/**")
|
|
610
661
|
require time
|
|
611
662
|
let scope be "team:" + team["id"]
|
|
612
663
|
let news be digest(scope, agent)
|
|
613
664
|
let mine be where(tasks(scope), (t) => t["owner"] == agent and t["status"] != "done")
|
|
614
665
|
let free be where(tasks(scope), (t) => t["owner"] == "" and t["status"] == "todo")
|
|
615
666
|
let out be head
|
|
667
|
+
let oid be objective_of_scope(scope)
|
|
668
|
+
when oid != 0 and lead_of(team) != agent
|
|
669
|
+
let ob be obj_get(oid)
|
|
670
|
+
when ob != nothing
|
|
671
|
+
set out to out + "\n\n[objective O-" + text(oid) + ", led by " + ob["agent"] + "] " + slice(ob["text"], 0, 500)
|
|
672
|
+
let nt be sql("SELECT note, at FROM seat_notes WHERE objective = ? AND agent = ?", [oid, agent])
|
|
673
|
+
when length(nt) > 0 and fresh_turn(scope, agent)
|
|
674
|
+
set out to out + "\n\n[your note from your previous turn, " + format_time(nt[0]["at"], "%H:%M") + "]\n" + nt[0]["note"]
|
|
616
675
|
set out to out + "\n\n[team " + team["id"] + "] Since your last turn:" + (when length(news) == 0 then " nothing new." otherwise "\n" + join(apply(news, (n) => "- " + n), "\n"))
|
|
617
676
|
set out to out + "\nYour open tasks:" + (when length(mine) == 0 then " none." otherwise "\n" + join(apply(mine, (t) => row_text(t)), "\n"))
|
|
618
677
|
when length(free) > 0
|
|
619
678
|
set out to out + "\nTasks nobody owns:\n" + join(apply(free, (t) => row_text(t)), "\n")
|
|
620
679
|
give out
|
|
621
680
|
|
|
681
|
+
-- ¿el próximo turno de `agent` arranca con la conversación limpia? Sí, salvo que el anterior se haya cortado a la mitad
|
|
682
|
+
-- (límite de pasos): ese sigue en la misma conversación. Lo de antes está en el tablero, el registro, git y su nota.
|
|
683
|
+
-- Una conversación que arrastra todos sus turnos reenvía todo en cada paso (visto en O-15: el CEO, ~80k por paso).
|
|
684
|
+
export task fresh_turn(scope, agent)
|
|
685
|
+
require db(".lampson/teams.db")
|
|
686
|
+
require file(".lampson")
|
|
687
|
+
require file(".lampson/**")
|
|
688
|
+
open()
|
|
689
|
+
let r be sql("SELECT n FROM seat_cont WHERE objective = ? AND agent = ?", [objective_of_scope(scope), agent])
|
|
690
|
+
give length(r) == 0 or r[0]["n"] == 0
|
|
691
|
+
|
|
622
692
|
-- ---------- un asiento al que se le cortó el turno ----------
|
|
623
693
|
-- Si un turno se corta (límite de pasos o de tokens del turno) en medio de un objetivo, el asiento recibe un mensaje
|
|
624
694
|
-- para seguir donde quedó: si no, se queda dormido con su tarea a medias y su resumen en una respuesta final que nadie
|
|
@@ -629,13 +699,16 @@ export let MAX_CONT be 3
|
|
|
629
699
|
export task seat_turn_end(team_id, agent, stopped, last)
|
|
630
700
|
require db(".lampson/teams.db")
|
|
631
701
|
require file(".lampson")
|
|
632
|
-
require file(".lampson
|
|
702
|
+
require file(".lampson/**")
|
|
633
703
|
require file.read("workspace")
|
|
634
|
-
require file.read("workspace
|
|
704
|
+
require file.read("workspace/**")
|
|
635
705
|
require time
|
|
636
706
|
open()
|
|
637
707
|
let scope be "team:" + team_id
|
|
638
708
|
let oid be objective_of_scope(scope)
|
|
709
|
+
-- su nota para el próximo turno (que arranca con la conversación limpia): lo último que dijo
|
|
710
|
+
when trim(text(last)) != ""
|
|
711
|
+
sql_exec("INSERT INTO seat_notes (objective, agent, note, at) VALUES (?, ?, ?, ?) ON CONFLICT(objective, agent) DO UPDATE SET note = excluded.note, at = excluded.at", [oid, agent, slice(trim(text(last)), 0, 2000), now()])
|
|
639
712
|
when stopped != "max_steps" and stopped != "budget"
|
|
640
713
|
sql_exec("DELETE FROM seat_cont WHERE objective = ? AND agent = ?", [oid, agent])
|
|
641
714
|
give false
|
|
@@ -661,7 +734,7 @@ export task seat_turn_end(team_id, agent, stopped, last)
|
|
|
661
734
|
|
|
662
735
|
-- ---------- la respuesta final que nadie lee ----------
|
|
663
736
|
-- Un asiento que contesta en su respuesta final en vez de `send` (pasa con modelos flojos): esa respuesta se le
|
|
664
|
-
-- reenvía
|
|
737
|
+
-- reenvía al compañero que lo despertó, para que no se pierda (despertado por una ronda, es solo su nota). (Visto 2026-10-18: el Dev contestó «voy
|
|
665
738
|
-- avanzando» a un pedido de estado, nadie lo leyó, y el CEO lo dio por perdido.) No se reenvía si en el turno ya
|
|
666
739
|
-- mandó algo, si es corta (una línea de «nada que hacer»), ni si lo que lo despertó ya era un reenvío (ping-pong).
|
|
667
740
|
export let FORWARD_MARK be "(Lampson forwarded this: it was my final reply and I didn't `send` it)"
|
|
@@ -669,9 +742,9 @@ export let FORWARD_MARK be "(Lampson forwarded this: it was my final reply and I
|
|
|
669
742
|
export task forward_final(team_id, agent, from, stopped, said, t0, trigger)
|
|
670
743
|
require db(".lampson/teams.db")
|
|
671
744
|
require file(".lampson")
|
|
672
|
-
require file(".lampson
|
|
745
|
+
require file(".lampson/**")
|
|
673
746
|
require file.read("workspace")
|
|
674
|
-
require file.read("workspace
|
|
747
|
+
require file.read("workspace/**")
|
|
675
748
|
require time
|
|
676
749
|
when stopped != "done" or length(trim(text(said))) < 80 or contains(text(trigger), FORWARD_MARK)
|
|
677
750
|
give ""
|
|
@@ -685,8 +758,10 @@ export task forward_final(team_id, agent, from, stopped, said, t0, trigger)
|
|
|
685
758
|
let scope be "team:" + team_id
|
|
686
759
|
when sql("SELECT COUNT(*) AS n FROM ledger WHERE scope = ? AND actor = ? AND kind = 'message' AND at >= ?", [scope, agent, t0])[0]["n"] > 0
|
|
687
760
|
give ""
|
|
688
|
-
|
|
689
|
-
|
|
761
|
+
when from == agent or member(tm, from) == nothing
|
|
762
|
+
give ""
|
|
763
|
+
let dest be from
|
|
764
|
+
when not contains(peers(tm, agent), dest)
|
|
690
765
|
give ""
|
|
691
766
|
sql_exec("INSERT INTO messages (scope, sender, recipient, text, at, state) VALUES (?, ?, ?, ?, ?, 'pending')", [scope, agent, dest, FORWARD_MARK + "\n" + slice(trim(text(said)), 0, 1500), now()])
|
|
692
767
|
log(scope, agent, "message", "→ " + dest, "[forwarded final reply] " + trim(text(said)))
|
|
@@ -696,9 +771,9 @@ export task forward_final(team_id, agent, from, stopped, said, t0, trigger)
|
|
|
696
771
|
export task person_message(team_id, agent, txt)
|
|
697
772
|
require db(".lampson/teams.db")
|
|
698
773
|
require file(".lampson")
|
|
699
|
-
require file(".lampson
|
|
774
|
+
require file(".lampson/**")
|
|
700
775
|
require file.read("workspace")
|
|
701
|
-
require file.read("workspace
|
|
776
|
+
require file.read("workspace/**")
|
|
702
777
|
require time
|
|
703
778
|
let tm be get(team_id)
|
|
704
779
|
when tm == nothing or member(tm, agent) == nothing
|
|
@@ -713,7 +788,7 @@ export task person_message(team_id, agent, txt)
|
|
|
713
788
|
export task person_move(scope, id, status)
|
|
714
789
|
require db(".lampson/teams.db")
|
|
715
790
|
require file(".lampson")
|
|
716
|
-
require file(".lampson
|
|
791
|
+
require file(".lampson/**")
|
|
717
792
|
require time
|
|
718
793
|
when not contains(STATUSES, status)
|
|
719
794
|
give false
|
|
@@ -756,21 +831,21 @@ export let BOARD_SPEC be {
|
|
|
756
831
|
-- reservada y builtin). Las versiones *_with reciben el mapa (los tests las usan directo).
|
|
757
832
|
export task send_tool(recipient, message, team, _agent, _scope)
|
|
758
833
|
require file.read("agents")
|
|
759
|
-
require file.read("agents
|
|
834
|
+
require file.read("agents/**")
|
|
760
835
|
require db(".lampson/teams.db")
|
|
761
836
|
require file(".lampson")
|
|
762
|
-
require file(".lampson
|
|
837
|
+
require file(".lampson/**")
|
|
763
838
|
require file.read("workspace")
|
|
764
|
-
require file.read("workspace
|
|
839
|
+
require file.read("workspace/**")
|
|
765
840
|
require time
|
|
766
841
|
give send_with({"recipient": recipient, "message": message, "team": team, "_agent": _agent, "_scope": _scope})
|
|
767
842
|
|
|
768
843
|
export task board_tool(action, id, title, notes, owner, status, depends, mine, team, _agent, _scope)
|
|
769
844
|
require db(".lampson/teams.db")
|
|
770
845
|
require file(".lampson")
|
|
771
|
-
require file(".lampson
|
|
846
|
+
require file(".lampson/**")
|
|
772
847
|
require file.read("workspace")
|
|
773
|
-
require file.read("workspace
|
|
848
|
+
require file.read("workspace/**")
|
|
774
849
|
require time
|
|
775
850
|
let a be {"_agent": _agent, "_scope": _scope}
|
|
776
851
|
each pair in [["action", action], ["id", id], ["title", title], ["notes", notes], ["owner", owner], ["status", status], ["depends", depends], ["mine", mine], ["team", team]]
|
|
@@ -780,12 +855,12 @@ export task board_tool(action, id, title, notes, owner, status, depends, mine, t
|
|
|
780
855
|
|
|
781
856
|
export task send_with(args)
|
|
782
857
|
require file.read("agents")
|
|
783
|
-
require file.read("agents
|
|
858
|
+
require file.read("agents/**")
|
|
784
859
|
require db(".lampson/teams.db")
|
|
785
860
|
require file(".lampson")
|
|
786
|
-
require file(".lampson
|
|
861
|
+
require file(".lampson/**")
|
|
787
862
|
require file.read("workspace")
|
|
788
|
-
require file.read("workspace
|
|
863
|
+
require file.read("workspace/**")
|
|
789
864
|
require time
|
|
790
865
|
let me be text(field(args, "_agent", ""))
|
|
791
866
|
when me == ""
|
|
@@ -795,17 +870,17 @@ export task send_with(args)
|
|
|
795
870
|
when not rt["ok"]
|
|
796
871
|
give "ERROR: " + rt["error"]
|
|
797
872
|
try
|
|
798
|
-
send(rt["team"], me, field(args, "recipient", ""), field(args, "message", ""))
|
|
799
|
-
give "sent to " + lower(text(field(args, "recipient", ""))) + " — it reaches them as a new message"
|
|
873
|
+
let mid be send(rt["team"], me, field(args, "recipient", ""), field(args, "message", ""))
|
|
874
|
+
give "sent #" + text(mid) + " to " + lower(text(field(args, "recipient", ""))) + " — it reaches them as a new message"
|
|
800
875
|
recover err
|
|
801
876
|
give "ERROR: " + regex_replace(text(err), "^.*?:\\d+:\\d+: ", "")
|
|
802
877
|
|
|
803
878
|
export task board_with(args)
|
|
804
879
|
require db(".lampson/teams.db")
|
|
805
880
|
require file(".lampson")
|
|
806
|
-
require file(".lampson
|
|
881
|
+
require file(".lampson/**")
|
|
807
882
|
require file.read("workspace")
|
|
808
|
-
require file.read("workspace
|
|
883
|
+
require file.read("workspace/**")
|
|
809
884
|
require time
|
|
810
885
|
let me be text(field(args, "_agent", ""))
|
|
811
886
|
when me == ""
|
|
@@ -871,7 +946,7 @@ export let MAX_HOPS be 2
|
|
|
871
946
|
-- los equipos que nombra un texto con @id (los que existen)
|
|
872
947
|
export task mentions(txt)
|
|
873
948
|
require file.read("workspace")
|
|
874
|
-
require file.read("workspace
|
|
949
|
+
require file.read("workspace/**")
|
|
875
950
|
let ids be apply(all(), (t) => t["id"])
|
|
876
951
|
let out be []
|
|
877
952
|
each m in regex_find_all(lower(text(txt)), "@[a-z0-9][a-z0-9-]*")
|
|
@@ -883,16 +958,16 @@ export task mentions(txt)
|
|
|
883
958
|
export task obj_create(agent, txt, opts)
|
|
884
959
|
require db(".lampson/teams.db")
|
|
885
960
|
require file(".lampson")
|
|
886
|
-
require file(".lampson
|
|
961
|
+
require file(".lampson/**")
|
|
887
962
|
require file.read("workspace")
|
|
888
|
-
require file.read("workspace
|
|
963
|
+
require file.read("workspace/**")
|
|
889
964
|
require time
|
|
890
965
|
open()
|
|
891
966
|
when trim(text(txt)) == ""
|
|
892
967
|
raise("an objective needs a text")
|
|
893
968
|
let tid be lower(text(field(opts, "team", "")))
|
|
894
969
|
let rs be floor(number(field(opts, "round_seconds", when tid != "" then 60 otherwise 20)))
|
|
895
|
-
let bt be floor(number(field(opts, "budget_tokens",
|
|
970
|
+
let bt be floor(number(field(opts, "budget_tokens", 700000)))
|
|
896
971
|
let chain be field(opts, "chain", [])
|
|
897
972
|
-- a quién lo puede pasar: lo que heredó del objetivo del que viene, o los equipos que nombra el pedido
|
|
898
973
|
let wanted be when field(opts, "pass_to", nothing) != nothing then opts["pass_to"] otherwise (when tid != "" then mentions(txt) otherwise [])
|
|
@@ -906,7 +981,7 @@ export task obj_create(agent, txt, opts)
|
|
|
906
981
|
export task obj_children(id)
|
|
907
982
|
require db(".lampson/teams.db")
|
|
908
983
|
require file(".lampson")
|
|
909
|
-
require file(".lampson
|
|
984
|
+
require file(".lampson/**")
|
|
910
985
|
open()
|
|
911
986
|
give sql("SELECT id, team, status FROM objectives WHERE from_obj = ? ORDER BY id", [id])
|
|
912
987
|
|
|
@@ -914,9 +989,9 @@ export task obj_children(id)
|
|
|
914
989
|
task pass_now(o, tid, msg)
|
|
915
990
|
require db(".lampson/teams.db")
|
|
916
991
|
require file(".lampson")
|
|
917
|
-
require file(".lampson
|
|
992
|
+
require file(".lampson/**")
|
|
918
993
|
require file.read("workspace")
|
|
919
|
-
require file.read("workspace
|
|
994
|
+
require file.read("workspace/**")
|
|
920
995
|
require time
|
|
921
996
|
let tm be get(tid)
|
|
922
997
|
let chain be append(json_decode(field(o, "chain", "[]")), o["team"])
|
|
@@ -937,7 +1012,7 @@ export task lead_of(team)
|
|
|
937
1012
|
export task team_objective(team_id, agent)
|
|
938
1013
|
require db(".lampson/teams.db")
|
|
939
1014
|
require file(".lampson")
|
|
940
|
-
require file(".lampson
|
|
1015
|
+
require file(".lampson/**")
|
|
941
1016
|
open()
|
|
942
1017
|
let r be sql("SELECT * FROM objectives WHERE team = ? AND agent = ? AND status IN ('active', 'waiting', 'paused') ORDER BY id DESC LIMIT 1", [team_id, agent])
|
|
943
1018
|
give when length(r) == 0 then nothing otherwise r[0]
|
|
@@ -947,7 +1022,7 @@ export task team_objective(team_id, agent)
|
|
|
947
1022
|
export task team_turn_end(team_id, agent, tokens)
|
|
948
1023
|
require db(".lampson/teams.db")
|
|
949
1024
|
require file(".lampson")
|
|
950
|
-
require file(".lampson
|
|
1025
|
+
require file(".lampson/**")
|
|
951
1026
|
require time
|
|
952
1027
|
open()
|
|
953
1028
|
-- el turno que cruza el tope diario del asiento queda en el registro (una vez): la persona ve quién gasta de más
|
|
@@ -970,7 +1045,7 @@ export task team_turn_end(team_id, agent, tokens)
|
|
|
970
1045
|
export task obj_get(id)
|
|
971
1046
|
require db(".lampson/teams.db")
|
|
972
1047
|
require file(".lampson")
|
|
973
|
-
require file(".lampson
|
|
1048
|
+
require file(".lampson/**")
|
|
974
1049
|
open()
|
|
975
1050
|
let r be sql("SELECT * FROM objectives WHERE id = ?", [id])
|
|
976
1051
|
give when length(r) == 0 then nothing otherwise r[0]
|
|
@@ -978,7 +1053,7 @@ export task obj_get(id)
|
|
|
978
1053
|
export task obj_list()
|
|
979
1054
|
require db(".lampson/teams.db")
|
|
980
1055
|
require file(".lampson")
|
|
981
|
-
require file(".lampson
|
|
1056
|
+
require file(".lampson/**")
|
|
982
1057
|
open()
|
|
983
1058
|
give sql("SELECT * FROM objectives ORDER BY id DESC", [])
|
|
984
1059
|
|
|
@@ -986,7 +1061,7 @@ export task obj_list()
|
|
|
986
1061
|
export task obj_set(id, changes)
|
|
987
1062
|
require db(".lampson/teams.db")
|
|
988
1063
|
require file(".lampson")
|
|
989
|
-
require file(".lampson
|
|
1064
|
+
require file(".lampson/**")
|
|
990
1065
|
require time
|
|
991
1066
|
open()
|
|
992
1067
|
let allowed_keys be ["status", "progress", "question", "question_kind", "reply", "result", "last_start", "turns", "pass_pending"]
|
|
@@ -999,7 +1074,7 @@ export task obj_set(id, changes)
|
|
|
999
1074
|
export task obj_turn_end(id, tokens)
|
|
1000
1075
|
require db(".lampson/teams.db")
|
|
1001
1076
|
require file(".lampson")
|
|
1002
|
-
require file(".lampson
|
|
1077
|
+
require file(".lampson/**")
|
|
1003
1078
|
require time
|
|
1004
1079
|
open()
|
|
1005
1080
|
sql_exec("UPDATE objectives SET spent = spent + ?, last_end = ?, updated_at = ? WHERE id = ?", [floor(tokens), now(), now(), id])
|
|
@@ -1013,7 +1088,7 @@ export task obj_turn_end(id, tokens)
|
|
|
1013
1088
|
export task obj_reply(id, txt, approved, who)
|
|
1014
1089
|
require db(".lampson/teams.db")
|
|
1015
1090
|
require file(".lampson")
|
|
1016
|
-
require file(".lampson
|
|
1091
|
+
require file(".lampson/**")
|
|
1017
1092
|
require time
|
|
1018
1093
|
let o be obj_get(id)
|
|
1019
1094
|
when o == nothing
|
|
@@ -1047,7 +1122,7 @@ export task obj_reply(id, txt, approved, who)
|
|
|
1047
1122
|
export task obj_cancel(id, who)
|
|
1048
1123
|
require db(".lampson/teams.db")
|
|
1049
1124
|
require file(".lampson")
|
|
1050
|
-
require file(".lampson
|
|
1125
|
+
require file(".lampson/**")
|
|
1051
1126
|
require time
|
|
1052
1127
|
let o be obj_get(id)
|
|
1053
1128
|
when o == nothing
|
|
@@ -1061,7 +1136,7 @@ export task obj_cancel(id, who)
|
|
|
1061
1136
|
-- lo que el líder tiene que saber para pasar el trabajo (vacío si el pedido no nombró a otro equipo)
|
|
1062
1137
|
export task pass_text(o)
|
|
1063
1138
|
require file.read("workspace")
|
|
1064
|
-
require file.read("workspace
|
|
1139
|
+
require file.read("workspace/**")
|
|
1065
1140
|
let pt be json_decode(field(o, "pass_to", "[]"))
|
|
1066
1141
|
when length(pt) == 0
|
|
1067
1142
|
give ""
|
|
@@ -1075,7 +1150,7 @@ export task pass_text(o)
|
|
|
1075
1150
|
export task obj_head(o)
|
|
1076
1151
|
when o["turns"] == 0 and field(o, "team", "") != ""
|
|
1077
1152
|
let fromt be when field(o, "from_obj", 0) > 0 then " — handed over by team " + json_decode(field(o, "chain", "[]"))[length(json_decode(field(o, "chain", "[]"))) - 1] + " from O-" + text(o["from_obj"]) + "; ask the person, not that team, if something is unclear" otherwise ""
|
|
1078
|
-
give "[objective O-" + text(o["id"]) + " for team " + o["team"] + fromt + "] " + o["text"] + pass_text(o) + "\n\nYou lead this objective with your team. How:\n- Break it into tasks on the team board (`board` add, with owner = who should do it, and depends when one needs another) and `send` each teammate what you need from them. They work in parallel in their own copies; follow up every turn with what changed.\n- Keep the person informed with `objective` (action report) at milestones. Before anything that leaves the
|
|
1153
|
+
give "[objective O-" + text(o["id"]) + " for team " + o["team"] + fromt + "] " + o["text"] + pass_text(o) + "\n\nYou lead this objective with your team. How:\n- Break it into tasks on the team board (`board` add, with owner = who should do it, and depends when one needs another) and `send` each teammate what you need from them. They work in parallel in their own copies; follow up every turn with what changed.\n- Keep the person informed with `objective` (action report) at milestones. Before anything that leaves the company or can't be undone (release, publish, deploy, buy, send), `objective` action request_approval and wait. Integrating into main and pushing need no request_approval: just run the merge or the push, and Lampson itself asks the person — once per objective for working in their copy (showing what goes in), and on every push. Never request_approval for a merge on top of that: the person would approve the same thing twice.\n- One check per change: if a teammate's role is to review or test (QA, a technical lead), that is the one review; otherwise the one who does a task tests it. Don't add extra review tasks on top, except for what is risky (security, money, data migrations, deleting things) or when the person asks; docs never need one. When you integrate, don't re-review what was approved: merge, run the tests once.\n- When everything is delivered, `objective` action done with a closing report for the person, who didn't follow the work. Write it in their language, in three short labeled parts: what was achieved (and by whom), what is in the project now (files, branches, commits — exact paths), and what is left or worth doing next. If it can't be done, action fail with why."
|
|
1079
1154
|
when o["turns"] == 0
|
|
1080
1155
|
give "[objective O-" + text(o["id"]) + "] " + o["text"] + "\n\nWork on this on your own until it is done. How:\n- First plan it: break it into tasks on your board (`board` add), then work through them (claim → doing → done).\n- Each turn, move the work forward and end the turn; you'll get the next turn automatically. Nobody reads your final reply: report with `objective` (action report) when you reach something worth telling.\n- Need a decision or information only the person has? `objective` action ask. Before anything that leaves this workspace or can't be undone (merge into main, push, deploy, buy, book, send an email), `objective` action request_approval and wait for the answer — never do it without an approval.\n- When it is done, `objective` action done with a closing report for the person, in their language, in three short labeled parts: what was achieved, what is in the project now (files, branches — exact paths) and what is left or worth doing next. If it can't be done, action fail with why."
|
|
1081
1156
|
when o["reply"] != ""
|
|
@@ -1085,7 +1160,7 @@ export task obj_head(o)
|
|
|
1085
1160
|
export task obj_turn_text(o)
|
|
1086
1161
|
require db(".lampson/teams.db")
|
|
1087
1162
|
require file(".lampson")
|
|
1088
|
-
require file(".lampson
|
|
1163
|
+
require file(".lampson/**")
|
|
1089
1164
|
require time
|
|
1090
1165
|
let scope be "objective:" + text(o["id"])
|
|
1091
1166
|
let head be obj_head(o)
|
|
@@ -1110,9 +1185,9 @@ export let OBJECTIVE_SPEC be {
|
|
|
1110
1185
|
export task objective_tool(action, message, _agent, _scope, team = nothing)
|
|
1111
1186
|
require db(".lampson/teams.db")
|
|
1112
1187
|
require file(".lampson")
|
|
1113
|
-
require file(".lampson
|
|
1188
|
+
require file(".lampson/**")
|
|
1114
1189
|
require file.read("workspace")
|
|
1115
|
-
require file.read("workspace
|
|
1190
|
+
require file.read("workspace/**")
|
|
1116
1191
|
require time
|
|
1117
1192
|
let sc be text(_scope)
|
|
1118
1193
|
let o be nothing
|