lampson 0.4.1 → 0.5.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 +19 -0
- package/chat.syn +1 -1
- package/hub.tpl.syn +55 -12
- package/lampson.ps1 +13 -6
- package/lampson.sh +11 -5
- package/lib/api.syn +224 -9
- package/lib/apikeys.syn +42 -9
- package/lib/apptools.syn +549 -0
- package/lib/diagnose.syn +142 -0
- package/lib/loop.syn +27 -0
- package/lib/mailbox.syn +24 -10
- package/lib/mcp_server.syn +6 -5
- package/lib/permission.syn +22 -1
- package/lib/plugins.syn +6 -4
- package/lib/provider.syn +16 -13
- package/lib/remotetools.syn +76 -0
- package/lib/runtime.syn +213 -9
- package/lib/schedule.syn +40 -2
- package/lib/sdktools.syn +73 -0
- package/lib/session.syn +8 -0
- package/lib/teamrun.syn +42 -5
- package/lib/teams.syn +397 -24
- package/lib/tools/common.syn +5 -0
- package/lib/tools/url.syn +82 -9
- package/lib/workspaces.syn +87 -3
- package/lib/worktree.syn +108 -0
- package/package.json +2 -2
- package/plugins/example-hello/plugin.json +1 -0
- package/public/css/chat.css +9 -8
- package/public/css/hub.css +69 -16
- package/public/css/layout.css +12 -4
- package/public/css/login.css +1 -1
- package/public/css/mobile.css +2 -2
- package/public/css/panel.css +18 -7
- package/public/css/sidebar.css +1 -1
- package/public/css/teams.css +701 -55
- package/public/css/tokens.css +36 -12
- package/public/css/views.css +124 -0
- package/public/hub.html +17 -9
- package/public/index.html +5 -2
- package/public/js/app.js +2 -2
- package/public/js/approvals.js +1 -1
- package/public/js/apptools.js +63 -0
- package/public/js/core.js +5 -2
- package/public/js/flow.js +187 -0
- package/public/js/hub.js +131 -31
- package/public/js/navtabs.js +23 -0
- package/public/js/objdiag.js +90 -0
- package/public/js/objlive.js +393 -0
- package/public/js/panel.js +3 -2
- package/public/js/plugins-home.js +59 -0
- package/public/js/plugins.js +40 -18
- package/public/js/schedules.js +5 -0
- package/public/js/sidebar.js +6 -4
- package/public/js/tasks-home.js +104 -0
- package/public/js/teams-home.js +64 -15
- package/public/js/teams.js +927 -202
- package/public/js/terminal.js +8 -2
- package/public/js/workspaces.js +6 -3
- package/public/plugins-home.html +32 -0
- package/public/tasks-home.html +31 -0
- package/public/teams-home.html +5 -2
- package/public/teams.html +33 -46
- package/public/vendor/xterm-addon-webgl.js +2 -0
- package/run.syn +87 -6
- package/sdk/index.d.ts +64 -3
- package/sdk/index.js +253 -11
- package/skills/lampson/SKILL.md +15 -0
- package/web.syn +91 -12
package/lib/runtime.syn
CHANGED
|
@@ -40,6 +40,9 @@ use "./session.syn" as session
|
|
|
40
40
|
use "./trace.syn" as trace
|
|
41
41
|
use "./mcp.syn" as mcp
|
|
42
42
|
use "./plugins.syn" as plugins
|
|
43
|
+
use "./apptools.syn" as apptools
|
|
44
|
+
use "./sdktools.syn" as sdktools
|
|
45
|
+
use "./remotetools.syn" as remotetools
|
|
43
46
|
use "./tools/proc.syn" as proc
|
|
44
47
|
use "./scope.syn" as scope
|
|
45
48
|
use "./teams.syn" as teams
|
|
@@ -249,7 +252,7 @@ task team_tools(spec)
|
|
|
249
252
|
give false
|
|
250
253
|
give contains(spec["tools"], "send") or contains(spec["tools"], "board") or length(teams.teams_of(spec["id"])) > 0
|
|
251
254
|
|
|
252
|
-
|
|
255
|
+
task registry_full(spec)
|
|
253
256
|
require exec
|
|
254
257
|
require time
|
|
255
258
|
require file(".lampson")
|
|
@@ -274,13 +277,21 @@ export task registry_of(spec)
|
|
|
274
277
|
each m in plugins.names(false)
|
|
275
278
|
when allowed(spec["tools"], m)
|
|
276
279
|
set reg[m] to "plugin"
|
|
280
|
+
-- herramientas de la app (lib/apptools.syn): un archivo .syn por herramienta en .lampson/tools/ del proyecto
|
|
281
|
+
each m in apptools.names()
|
|
282
|
+
when allowed(spec["tools"], m)
|
|
283
|
+
set reg[m] to apptools.MARK
|
|
284
|
+
-- funciones de la app registradas con lampson.tool() (lib/sdktools.syn; solo con el SDK en modo local)
|
|
285
|
+
each m in sdktools.names()
|
|
286
|
+
when allowed(spec["tools"], m) and not contains(reg, m)
|
|
287
|
+
set reg[m] to sdktools.MARK
|
|
277
288
|
-- equipos (lib/teams.syn): un miembro coordina con send y board; fuera de un equipo, solo si los lista
|
|
278
289
|
when team_tools(spec)
|
|
279
290
|
set reg["send"] to teams.send_tool
|
|
280
291
|
set reg["board"] to teams.board_tool
|
|
281
292
|
give reg
|
|
282
293
|
|
|
283
|
-
|
|
294
|
+
task catalog_full(spec)
|
|
284
295
|
require exec
|
|
285
296
|
require time
|
|
286
297
|
require file(".lampson")
|
|
@@ -300,10 +311,104 @@ export task catalog_of(spec)
|
|
|
300
311
|
when contains(names, "delegate")
|
|
301
312
|
set cat to append(cat, agents.DELEGATE_SPEC)
|
|
302
313
|
let extra be where(mcp.catalog(false) + plugins.catalog(false), (s) => allowed(spec["tools"], s["name"]))
|
|
314
|
+
set extra to extra + apptools.catalog(where(apptools.names(), (n) => allowed(spec["tools"], n)))
|
|
315
|
+
let app_tools be apptools.names()
|
|
316
|
+
set extra to extra + sdktools.catalog(where(sdktools.names(), (n) => allowed(spec["tools"], n) and not contains(app_tools, n)))
|
|
303
317
|
when team_tools(spec)
|
|
304
318
|
set extra to extra + [teams.SEND_SPEC, teams.BOARD_SPEC]
|
|
305
319
|
give cat + extra
|
|
306
320
|
|
|
321
|
+
-- LAMPSON_BUILTIN_TOOLS=off (SDK: lampsonTools: false): el proceso no ofrece NINGUNA tool propia de Lampson (bash,
|
|
322
|
+
-- read, write, fetch, delegate…), ni a los agentes integrados: solo las que trae quien lo usa (plugins, MCP) y la
|
|
323
|
+
-- coordinación de un equipo (send, board). Para una app que embebe un agente: nada que inyectar hacia el shell.
|
|
324
|
+
export task builtin_off()
|
|
325
|
+
require env("LAMPSON_*")
|
|
326
|
+
give lower(env("LAMPSON_BUILTIN_TOOLS", "")) == "off"
|
|
327
|
+
|
|
328
|
+
task external(name)
|
|
329
|
+
give starts_with(name, plugins.PREFIX) or starts_with(name, "mcp_") or name == "send" or name == "board"
|
|
330
|
+
|
|
331
|
+
export task registry_of(spec)
|
|
332
|
+
require exec
|
|
333
|
+
require time
|
|
334
|
+
require file(".lampson")
|
|
335
|
+
require file(".lampson/*")
|
|
336
|
+
require file("workspace")
|
|
337
|
+
require file("workspace/*")
|
|
338
|
+
require file.read("plugins")
|
|
339
|
+
require file.read("plugins/*")
|
|
340
|
+
require file.read("agents")
|
|
341
|
+
require file.read("agents/*")
|
|
342
|
+
require env("LAMPSON_*")
|
|
343
|
+
require env("OS")
|
|
344
|
+
let reg be registry_full(spec)
|
|
345
|
+
when not builtin_off()
|
|
346
|
+
give reg
|
|
347
|
+
let out be {}
|
|
348
|
+
each k in keys(reg)
|
|
349
|
+
when external(k) or reg[k] == apptools.MARK or reg[k] == sdktools.MARK
|
|
350
|
+
set out[k] to reg[k]
|
|
351
|
+
give out
|
|
352
|
+
|
|
353
|
+
export task catalog_of(spec)
|
|
354
|
+
require exec
|
|
355
|
+
require time
|
|
356
|
+
require file(".lampson")
|
|
357
|
+
require file(".lampson/*")
|
|
358
|
+
require file("workspace")
|
|
359
|
+
require file("workspace/*")
|
|
360
|
+
require file.read("plugins")
|
|
361
|
+
require file.read("plugins/*")
|
|
362
|
+
require file.read("agents")
|
|
363
|
+
require file.read("agents/*")
|
|
364
|
+
require env("LAMPSON_*")
|
|
365
|
+
require env("OS")
|
|
366
|
+
let cat be catalog_full(spec)
|
|
367
|
+
when not builtin_off()
|
|
368
|
+
give cat
|
|
369
|
+
let keep be keys(registry_of(spec))
|
|
370
|
+
give where(cat, (s) => contains(keep, s["name"]))
|
|
371
|
+
|
|
372
|
+
-- las tools que el agente lista y no va a tener (plugin apagado o inexistente, MCP caído, nombre mal escrito) →
|
|
373
|
+
-- un aviso por tool. Sin esto el agente arranca sin su herramienta y nadie se entera (2026-10-18, prueba del SDK)
|
|
374
|
+
export task missing(spec)
|
|
375
|
+
require exec
|
|
376
|
+
require time
|
|
377
|
+
require file(".lampson")
|
|
378
|
+
require file(".lampson/*")
|
|
379
|
+
require file("workspace")
|
|
380
|
+
require file("workspace/*")
|
|
381
|
+
require file.read("plugins")
|
|
382
|
+
require file.read("plugins/*")
|
|
383
|
+
require file.read("agents")
|
|
384
|
+
require file.read("agents/*")
|
|
385
|
+
require env("LAMPSON_*")
|
|
386
|
+
require env("OS")
|
|
387
|
+
when spec == nothing or spec["builtin"]
|
|
388
|
+
give []
|
|
389
|
+
let have be keys(registry_of(spec))
|
|
390
|
+
let out be []
|
|
391
|
+
each t in spec["tools"]
|
|
392
|
+
when length(where(have, (h) => allowed([t], h))) == 0
|
|
393
|
+
let why be "not a known tool"
|
|
394
|
+
when starts_with(t, plugins.PREFIX)
|
|
395
|
+
let rest be slice(t, length(plugins.PREFIX), length(t))
|
|
396
|
+
let pn be split(rest, "_")[0]
|
|
397
|
+
let found be where(plugins.all(), (l) => l["name"] == pn)
|
|
398
|
+
set why to when length(found) == 0 then "there is no plugin '" + pn + "'" otherwise (when found[0]["error"] != nothing then "plugin '" + pn + "' is broken: " + text(found[0]["error"]) otherwise (when not found[0]["enabled"] then "plugin '" + pn + "' is off (turn it on: lampson plugin on " + pn + ")" otherwise "plugin '" + pn + "' has no such tool"))
|
|
399
|
+
otherwise when apptools.get(t) != nothing
|
|
400
|
+
set why to "tool file " + apptools.dir() + "/" + t + ".syn: " + text(apptools.get(t)["error"])
|
|
401
|
+
otherwise when apptools.load_error() != ""
|
|
402
|
+
set why to "the app tools folder " + apptools.dir() + " could not be read: " + apptools.load_error()
|
|
403
|
+
otherwise when builtin_off() and (t == "delegate" or contains(apply((s) => s["name"], tools.CATALOG), t))
|
|
404
|
+
set why to "Lampson's own tools are off in this process (lampsonTools: false)"
|
|
405
|
+
otherwise when starts_with(t, "mcp_")
|
|
406
|
+
set why to "no MCP server provides it (is the server configured and running?)"
|
|
407
|
+
when why == "not a known tool"
|
|
408
|
+
set why to "no Lampson tool, plugin, MCP server or app tool (" + apptools.dir() + "/" + t + ".syn, or lampson.tool() in the SDK) has that name"
|
|
409
|
+
set out to append(out, "agent '" + spec["id"] + "': tool '" + t + "' is not available: " + why)
|
|
410
|
+
give out
|
|
411
|
+
|
|
307
412
|
-- ---------- boot: cfg + system + opts de un agente ----------
|
|
308
413
|
|
|
309
414
|
task pick(a, b)
|
|
@@ -350,8 +455,15 @@ export task opts_for(id, mode, ask_fn)
|
|
|
350
455
|
set opts["budget_tokens"] to spec["budget_tokens"]
|
|
351
456
|
when length(keys(spec["scopes"])) > 0
|
|
352
457
|
set opts["scopes"] to spec["scopes"]
|
|
353
|
-
|
|
354
|
-
|
|
458
|
+
-- una herramienta de la app que declara `require spend(…)` pide aprobación siempre, salvo que el agente diga otra cosa
|
|
459
|
+
let appr be spec["approve"]
|
|
460
|
+
each k in keys(opts["registry"])
|
|
461
|
+
when opts["registry"][k] == apptools.MARK and not contains(appr, k)
|
|
462
|
+
let at be apptools.get(k)
|
|
463
|
+
when at != nothing and at["spend"]
|
|
464
|
+
set appr[k] to "ask"
|
|
465
|
+
when length(keys(appr)) > 0
|
|
466
|
+
set opts["approve"] to appr
|
|
355
467
|
-- buzón de subagentes: los integrados siempre (igual que antes); uno del proyecto solo si puede delegar
|
|
356
468
|
when spec["builtin"] or contains(spec["tools"], "delegate")
|
|
357
469
|
set opts to loop.with_inbox(opts, agents.parent_inbox, "")
|
|
@@ -382,7 +494,8 @@ export task system_for(id, cfg)
|
|
|
382
494
|
require secret("LAMPSON_*")
|
|
383
495
|
let spec be spec_or_raise(id)
|
|
384
496
|
-- los plugins traen su proceso: las instrucciones de los que tienen tools en el catálogo de este agente
|
|
385
|
-
let
|
|
497
|
+
let tnames be apply(catalog_of(spec), (s) => s["name"])
|
|
498
|
+
let extra be plugins.instructions(tnames) + apptools.instructions(tnames)
|
|
386
499
|
-- su equipo: rol, a quién reporta, a quién le puede escribir, cómo se usa el tablero (lib/teams.syn)
|
|
387
500
|
when not spec["builtin"]
|
|
388
501
|
set extra to extra + teams.instructions(spec["id"])
|
|
@@ -428,11 +541,24 @@ export task fresh_session()
|
|
|
428
541
|
let i be 0
|
|
429
542
|
while i < 20
|
|
430
543
|
set i to i + 1
|
|
431
|
-
|
|
544
|
+
-- antes 4 dígitos: con la hora, se adivinaba (2026-10-19). La API además exige que sea de su key
|
|
545
|
+
let id be base + "-" + token(16)
|
|
432
546
|
when not session.exists(id)
|
|
433
547
|
give id
|
|
434
548
|
raise("could not allocate a session id")
|
|
435
549
|
|
|
550
|
+
-- de qué key es una sesión ("key:<id>:", lib/api.syn space_of); "" si no es de la API o no existe
|
|
551
|
+
export task session_space(sid)
|
|
552
|
+
require file.read(".lampson")
|
|
553
|
+
require file.read(".lampson/*")
|
|
554
|
+
when not session.exists(sid)
|
|
555
|
+
give ""
|
|
556
|
+
try
|
|
557
|
+
let doc be session.load(sid)
|
|
558
|
+
give when contains(doc, "meta") and type_of(doc["meta"]) == "map" and contains(doc["meta"], "space") then text(doc["meta"]["space"]) otherwise ""
|
|
559
|
+
recover err
|
|
560
|
+
give ""
|
|
561
|
+
|
|
436
562
|
-- la sesión de (agente, thread) si ya existe; "" si no
|
|
437
563
|
export task thread_session(agent, thread)
|
|
438
564
|
require file.read(".lampson")
|
|
@@ -447,6 +573,13 @@ export task thread_session(agent, thread)
|
|
|
447
573
|
give ""
|
|
448
574
|
give ""
|
|
449
575
|
|
|
576
|
+
-- la próxima entrega a (agente, thread) arranca una conversación nueva
|
|
577
|
+
export task forget_thread(agent, thread)
|
|
578
|
+
require time
|
|
579
|
+
require file(".lampson")
|
|
580
|
+
require file(".lampson/*")
|
|
581
|
+
remember_thread(agent, thread, "")
|
|
582
|
+
|
|
450
583
|
task remember_thread(agent, thread, sid)
|
|
451
584
|
require time
|
|
452
585
|
require file(".lampson")
|
|
@@ -482,6 +615,11 @@ export task open(sobre, hooks)
|
|
|
482
615
|
let ctx be boot(id, hooks, field(hooks, "ask_fn", nothing))
|
|
483
616
|
let thread be text(field(sobre, "thread", ""))
|
|
484
617
|
let sid be text(field(sobre, "session", ""))
|
|
618
|
+
-- por la API (space = "key:<id>:"): solo una sesión de esa key, y su thread nunca se adopta (lib/api.syn ya
|
|
619
|
+
-- contestó 404 a una ajena; esto es la segunda capa)
|
|
620
|
+
let space be text(field(sobre, "space", ""))
|
|
621
|
+
when sid != "" and space != "" and session_space(sid) != space
|
|
622
|
+
raise("no such session: " + sid)
|
|
485
623
|
when sid != "" and not session.exists(sid)
|
|
486
624
|
set sid to ""
|
|
487
625
|
when sid == ""
|
|
@@ -492,7 +630,7 @@ export task open(sobre, hooks)
|
|
|
492
630
|
let doc be session.load(sid)
|
|
493
631
|
let prev be doc["messages"]
|
|
494
632
|
set messages to [ctx["system"]] + slice(prev, 1, length(prev))
|
|
495
|
-
when thread == "" and contains(doc["meta"], "thread")
|
|
633
|
+
when thread == "" and space == "" and contains(doc["meta"], "thread")
|
|
496
634
|
set thread to text(doc["meta"]["thread"])
|
|
497
635
|
-- sesión guardada por otra corrida de lampson: sus procesos ya no viven — decírselo al modelo (una vez)
|
|
498
636
|
when session.from_other_run(doc)
|
|
@@ -509,6 +647,11 @@ export task open(sobre, hooks)
|
|
|
509
647
|
-- en un equipo con git, cada agente en su copia (lib/worktree.syn); "worktrees": false en el equipo lo apaga
|
|
510
648
|
when starts_with(thread, "team:")
|
|
511
649
|
let tm be teams.get(slice(thread, 5, length(thread)))
|
|
650
|
+
-- un asiento que no es el líder no le abre aprobaciones a la persona: van a su jefe (lib/loop.syn)
|
|
651
|
+
when tm != nothing
|
|
652
|
+
let mine be teams.member(tm, ctx["agent"])
|
|
653
|
+
when mine != nothing and ctx["agent"] != teams.lead_of(tm) and mine["reports_to"] != ""
|
|
654
|
+
set copts["escalate_to"] to mine["reports_to"]
|
|
512
655
|
when tm != nothing and tm["worktrees"]
|
|
513
656
|
let me be teams.member(tm, ctx["agent"])
|
|
514
657
|
let wt be worktree.ensure(tm["id"], ctx["agent"], {"name": (when me != nothing and me["role"] != ctx["agent"] then me["role"] + " · " + ctx["agent"] otherwise ctx["agent"]) + " (Lampson)", "email": ctx["agent"] + "@lampson.local"})
|
|
@@ -526,9 +669,26 @@ export task open(sobre, hooks)
|
|
|
526
669
|
set copts["registry"] to reg
|
|
527
670
|
set copts["catalog"] to where(copts["catalog"], (s) => s["name"] != "board" and s["name"] != "objective") + [teams.BOARD_SPEC, teams.OBJECTIVE_SPEC]
|
|
528
671
|
set ctx["opts"] to copts
|
|
672
|
+
-- contexto de confianza para las herramientas de la app (lib/apptools.syn): lo pone quien manda el sobre, el
|
|
673
|
+
-- modelo no lo ve ni lo escribe
|
|
674
|
+
let aopts be ctx["opts"]
|
|
675
|
+
set aopts["tool_ctx"] to {"from": field(sobre, "from", {}), "thread": thread, "agent": ctx["agent"], "session": sid, "meta": field(sobre, "meta", {}), "channel": text(field(sobre, "channel", ""))}
|
|
676
|
+
-- funciones de la app que viajan en el mensaje (modo servidor, lib/remotetools.syn): solo las que el agente lista
|
|
677
|
+
-- y sin pisar ninguna que ya tenga
|
|
678
|
+
let remote be remotetools.of_sobre(sobre)
|
|
679
|
+
when remote != nothing
|
|
680
|
+
let rspec be ctx["spec"]
|
|
681
|
+
let rreg be aopts["registry"]
|
|
682
|
+
let rnames be where(apply((t) => t["name"], remote["tools"]), (n) => allowed(rspec["tools"], n) and not contains(rreg, n))
|
|
683
|
+
each n in rnames
|
|
684
|
+
set rreg[n] to remotetools.MARK
|
|
685
|
+
set aopts["registry"] to rreg
|
|
686
|
+
set aopts["catalog"] to aopts["catalog"] + remotetools.catalog(remote, rnames)
|
|
687
|
+
set aopts["remote_tools"] to remote
|
|
688
|
+
set ctx["opts"] to aopts
|
|
529
689
|
-- sesión actual (blackboard): la tool todo guarda su lista por sesión (lib/tools/todo.syn)
|
|
530
690
|
share {"id": sid} as "lampson:session"
|
|
531
|
-
give {"ctx": ctx, "session": sid, "thread": thread, "messages": messages, "mode": ctx["opts"]["permission_mode"], "note": note}
|
|
691
|
+
give {"ctx": ctx, "session": sid, "thread": thread, "messages": messages, "mode": ctx["opts"]["permission_mode"], "note": note, "space": space}
|
|
532
692
|
|
|
533
693
|
-- guarda la sesión con su agente y thread (y el índice del thread)
|
|
534
694
|
export task save(o, messages)
|
|
@@ -536,9 +696,38 @@ export task save(o, messages)
|
|
|
536
696
|
require file(".lampson")
|
|
537
697
|
require file(".lampson/*")
|
|
538
698
|
require env("LAMPSON_*")
|
|
539
|
-
session.save(o["session"], messages, {"title": session.title_of(messages), "agent": o["ctx"]["agent"], "thread": o["thread"]})
|
|
699
|
+
session.save(o["session"], messages, {"title": session.title_of(messages), "agent": o["ctx"]["agent"], "thread": o["thread"], "space": text(field(o, "space", ""))})
|
|
540
700
|
remember_thread(o["ctx"]["agent"], o["thread"], o["session"])
|
|
541
701
|
|
|
702
|
+
-- la vista en vivo de un objetivo (public/js/objlive.js): cada paso de un asiento de equipo u objetivo sale al bus
|
|
703
|
+
-- ("team.step") en el momento, compacto — el detalle completo sigue en la traza
|
|
704
|
+
task live(th, agent, kind, data)
|
|
705
|
+
require time
|
|
706
|
+
when not (starts_with(th, "team:") or starts_with(th, "objective:"))
|
|
707
|
+
give false
|
|
708
|
+
let d be nothing
|
|
709
|
+
when kind == "busy"
|
|
710
|
+
set d to {"label": slice(text(field(data, "label", "")), 0, 200), "what": field(data, "kind", ""), "name": field(data, "name", "")}
|
|
711
|
+
otherwise when kind == "tool_call"
|
|
712
|
+
set d to {"name": data["name"], "args": slice(json_encode(data["args"]), 0, 1500)}
|
|
713
|
+
otherwise when kind == "tool_result"
|
|
714
|
+
let out be text(data["output"])
|
|
715
|
+
set d to {"name": data["call"]["name"], "ok": not (starts_with(out, "ERROR") or starts_with(out, "DENIED") or starts_with(out, "NOT RUN")), "out": slice(out, 0, 200)}
|
|
716
|
+
otherwise when kind == "tool_denied"
|
|
717
|
+
set d to {"name": data["call"]["name"], "reason": slice(text(data["reason"]), 0, 200)}
|
|
718
|
+
otherwise when kind == "assistant"
|
|
719
|
+
set d to {"text": slice(text(data), 0, 400)}
|
|
720
|
+
otherwise when kind == "usage"
|
|
721
|
+
let u be data["usage"]
|
|
722
|
+
let cached be field(u, "cached", 0)
|
|
723
|
+
set d to {"cost": u["input"] - cached + floor(cached / 10) + u["output"]}
|
|
724
|
+
otherwise when kind == "turn_start" or kind == "turn_end" or kind == "idle"
|
|
725
|
+
set d to {}
|
|
726
|
+
when d == nothing
|
|
727
|
+
give false
|
|
728
|
+
bus_publish("team.step", {"scope": th, "agent": agent, "kind": kind, "data": d, "at": now()})
|
|
729
|
+
give true
|
|
730
|
+
|
|
542
731
|
-- corre UN turno sobre mensajes ya armados (el del usuario ya agregado): traza, run_turn, guarda.
|
|
543
732
|
-- o: {ctx: {cfg, opts, agent}, session, thread} — lo que devuelve open(), o lo que arma la terminal.
|
|
544
733
|
-- label: lo que se anota como turno del usuario en la traza ("" = el último mensaje de usuario).
|
|
@@ -565,8 +754,11 @@ export task turn(o, messages, label, hooks)
|
|
|
565
754
|
require secret("LAMPSON_*")
|
|
566
755
|
let sid be o["session"]
|
|
567
756
|
let user_cb be field(hooks, "on_event", nothing)
|
|
757
|
+
let th0 be text(field(o, "thread", ""))
|
|
758
|
+
let me be o["ctx"]["agent"]
|
|
568
759
|
task on_event(kind, data, tag)
|
|
569
760
|
trace.event(sid, kind, data, tag)
|
|
761
|
+
live(th0, me, kind, data)
|
|
570
762
|
when user_cb != nothing
|
|
571
763
|
call(user_cb, {"kind": kind, "data": data, "tag": tag})
|
|
572
764
|
let said be label
|
|
@@ -576,14 +768,21 @@ export task turn(o, messages, label, hooks)
|
|
|
576
768
|
set said to text(m["content"])
|
|
577
769
|
let cfg be o["ctx"]["cfg"]
|
|
578
770
|
trace.user(sid, said, o["ctx"]["agent"], o["ctx"]["opts"]["permission_mode"], cfg["model"])
|
|
771
|
+
live(th0, me, "turn_start", nothing)
|
|
772
|
+
when starts_with(th0, "team:")
|
|
773
|
+
let oid be teams.objective_of_scope(th0)
|
|
774
|
+
when oid != 0
|
|
775
|
+
teams.seat_session(oid, me, sid)
|
|
579
776
|
let result be loop.run_turn(cfg, messages, o["ctx"]["opts"], on_event)
|
|
580
777
|
trace.turn_end(sid, result)
|
|
778
|
+
live(th0, me, "turn_end", nothing)
|
|
581
779
|
-- presupuesto de equipos: lo que gastó este turno (los cacheados pesan 10%, como en el loop)
|
|
582
780
|
let cost be result["usage"]["input"] - result["usage"]["cached"] + floor(result["usage"]["cached"] / 10) + result["usage"]["output"]
|
|
583
781
|
let th be text(field(o, "thread", ""))
|
|
584
782
|
when starts_with(th, "team:")
|
|
585
783
|
teams.record_spend(o["ctx"]["agent"], cost)
|
|
586
784
|
teams.team_turn_end(slice(th, 5, length(th)), o["ctx"]["agent"], cost)
|
|
785
|
+
teams.seat_turn_end(slice(th, 5, length(th)), o["ctx"]["agent"], field(result, "stopped", "done"), field(result, "text", ""))
|
|
587
786
|
when starts_with(th, "objective:")
|
|
588
787
|
teams.obj_turn_end(floor(number(slice(th, 10, length(th)))), cost)
|
|
589
788
|
save(o, result["messages"])
|
|
@@ -626,5 +825,10 @@ export task deliver(sobre, hooks)
|
|
|
626
825
|
let images be field(sobre, "images", [])
|
|
627
826
|
when length(images) > 0
|
|
628
827
|
set umsg to {"role": "user", "content": msg, "images": images}
|
|
828
|
+
let t0 be now()
|
|
629
829
|
let result be turn(o, append(o["messages"], umsg), msg, hooks)
|
|
830
|
+
-- en un equipo, la respuesta final no la lee nadie: si el asiento no mandó nada, se le reenvía a quien lo despertó
|
|
831
|
+
let th be text(o["thread"])
|
|
832
|
+
when starts_with(th, "team:")
|
|
833
|
+
teams.forward_final(slice(th, 5, length(th)), o["ctx"]["agent"], text(field(field(sobre, "meta", {}), "from", "")), field(result, "stopped", "done"), field(result, "text", ""), t0, msg)
|
|
630
834
|
give {"agent": o["ctx"]["agent"], "thread": o["thread"], "session": sid, "text": result["text"], "steps": result["steps"], "usage": result["usage"], "stopped": result["stopped"]}
|
package/lib/schedule.syn
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
-- lib/schedule.syn — tareas programadas: "cada 6 h", "todos los días a las 9", "lunes 8:30"
|
|
2
2
|
--
|
|
3
3
|
-- Qué se programa (action.type):
|
|
4
|
+
-- objective → una RUTINA de un equipo: {team, text, budget_tokens?, round_seconds?}. Cada vez que le toca crea un
|
|
5
|
+
-- objetivo normal para el líder del equipo (created_by = "rutina:<id de la tarea>": así se ven sus
|
|
6
|
+
-- ejecuciones). Si la ejecución anterior sigue abierta, esta se saltea — no se amontonan objetivos.
|
|
4
7
|
-- plugin → una tool de un plugin ENCENDIDO: {plugin, tool, args}. Encenderlo ya fue la autorización.
|
|
5
8
|
-- bash → un comando fijo desde el workspace: {command, timeout}. Aprobado UNA vez, al crear la tarea.
|
|
6
9
|
-- prompt → una corrida completa del agente con un texto: {prompt, agent}. Sin humano al lado: corre con el
|
|
@@ -28,6 +31,7 @@ use "./permission.syn" as permission
|
|
|
28
31
|
use "./tools/common.syn" as c
|
|
29
32
|
use "./tools/memo.syn" as memo
|
|
30
33
|
use "./settings.syn" as settings
|
|
34
|
+
use "./teams.syn" as teams
|
|
31
35
|
|
|
32
36
|
export let FILE be ".lampson/schedules.json"
|
|
33
37
|
export let LOG_DIR be ".lampson/schedules"
|
|
@@ -380,11 +384,18 @@ task slug(name)
|
|
|
380
384
|
-- valida y normaliza la acción → {ok, action, error}
|
|
381
385
|
task check_action(action)
|
|
382
386
|
when action == nothing or not contains(action, "type")
|
|
383
|
-
give {"ok": false, "error": "action needs a type: plugin | bash | prompt"}
|
|
387
|
+
give {"ok": false, "error": "action needs a type: objective | plugin | bash | prompt"}
|
|
384
388
|
let kind be lower(text(action["type"]))
|
|
385
389
|
when kind == "lamp"
|
|
386
390
|
-- compat: "lamp" era el nombre de "plugin" hasta 2026-09 (tareas guardadas, JSON escrito a mano)
|
|
387
391
|
set kind to "plugin"
|
|
392
|
+
when kind == "objective"
|
|
393
|
+
let tid be lower(text(when contains(action, "team") then action["team"] otherwise ""))
|
|
394
|
+
when tid == "" or teams.get(tid) == nothing
|
|
395
|
+
give {"ok": false, "error": "action objective needs the id of a team of this project (got '" + tid + "')"}
|
|
396
|
+
when not contains(action, "text") or trim(text(action["text"])) == ""
|
|
397
|
+
give {"ok": false, "error": "action objective needs the text of the objective"}
|
|
398
|
+
give {"ok": true, "action": {"type": "objective", "team": tid, "text": trim(text(action["text"])), "budget_tokens": floor(number(when contains(action, "budget_tokens") and action["budget_tokens"] != nothing then action["budget_tokens"] otherwise 600000)), "round_seconds": floor(number(when contains(action, "round_seconds") and action["round_seconds"] != nothing then action["round_seconds"] otherwise 60)), "pass_ask": when contains(action, "pass_ask") then action["pass_ask"] == true otherwise false}}
|
|
388
399
|
when kind == "plugin"
|
|
389
400
|
let pname be plugin_of(action)
|
|
390
401
|
when pname == "" or not contains(action, "tool")
|
|
@@ -409,7 +420,7 @@ task check_action(action)
|
|
|
409
420
|
when not contains(["build", "plan", "review", "explore"], agent)
|
|
410
421
|
give {"ok": false, "error": "agent must be build | plan | review | explore"}
|
|
411
422
|
give {"ok": true, "action": {"type": "prompt", "prompt": text(action["prompt"]), "agent": agent}}
|
|
412
|
-
give {"ok": false, "error": "unknown action type '" + kind + "' (plugin | bash | prompt)"}
|
|
423
|
+
give {"ok": false, "error": "unknown action type '" + kind + "' (objective | plugin | bash | prompt)"}
|
|
413
424
|
|
|
414
425
|
-- crear: spec = {name, when, action, permission?, approval_timeout?, notify?} → la tarea (raise si es inválida)
|
|
415
426
|
export task add(spec)
|
|
@@ -466,6 +477,9 @@ task is_plugin_action(a)
|
|
|
466
477
|
give a["type"] == "plugin" or a["type"] == "lamp"
|
|
467
478
|
|
|
468
479
|
task default_name(action)
|
|
480
|
+
when action["type"] == "objective"
|
|
481
|
+
let o be replace(action["text"], "\n", " ")
|
|
482
|
+
give when length(o) > 40 then slice(o, 0, 40) + "…" otherwise o
|
|
469
483
|
when is_plugin_action(action)
|
|
470
484
|
give plugin_of(action) + " " + action["tool"]
|
|
471
485
|
when action["type"] == "bash"
|
|
@@ -561,6 +575,8 @@ export task run_simple(t)
|
|
|
561
575
|
require file("workspace")
|
|
562
576
|
require file("workspace/*")
|
|
563
577
|
let a be t["action"]
|
|
578
|
+
when a["type"] == "objective"
|
|
579
|
+
give run_routine(t)
|
|
564
580
|
when is_plugin_action(a)
|
|
565
581
|
give plugins.call(plugins.tool_name(plugin_of(a), a["tool"]), a["args"])
|
|
566
582
|
when a["type"] == "bash"
|
|
@@ -653,8 +669,30 @@ export task log_tail(id, n)
|
|
|
653
669
|
recover err
|
|
654
670
|
give ""
|
|
655
671
|
|
|
672
|
+
-- una ejecución de una rutina: un objetivo para el líder del equipo, salvo que la anterior siga abierta
|
|
673
|
+
export let ROUTINE_PREFIX be "rutina:"
|
|
674
|
+
export task run_routine(t)
|
|
675
|
+
require db(".lampson/teams.db")
|
|
676
|
+
require time
|
|
677
|
+
require file(".lampson")
|
|
678
|
+
require file(".lampson/*")
|
|
679
|
+
require file.read("workspace")
|
|
680
|
+
require file.read("workspace/*")
|
|
681
|
+
let a be t["action"]
|
|
682
|
+
let tm be teams.get(a["team"])
|
|
683
|
+
when tm == nothing
|
|
684
|
+
give "ERROR: team '" + a["team"] + "' no longer exists in this project"
|
|
685
|
+
let mine be ROUTINE_PREFIX + t["id"]
|
|
686
|
+
let still be where(teams.obj_list(), (o) => o["created_by"] == mine and contains(["active", "waiting", "paused"], o["status"]))
|
|
687
|
+
when length(still) > 0
|
|
688
|
+
give "SKIPPED: the previous run (O-" + text(still[0]["id"]) + ") is still open"
|
|
689
|
+
let id be teams.obj_create(teams.lead_of(tm), a["text"], {"team": tm["id"], "budget_tokens": a["budget_tokens"], "round_seconds": a["round_seconds"], "created_by": mine, "pass_ask": when contains(a, "pass_ask") then a["pass_ask"] == true otherwise false})
|
|
690
|
+
give "O-" + text(id) + " → team " + tm["id"]
|
|
691
|
+
|
|
656
692
|
-- descripción de la acción (una línea) para previews y listados
|
|
657
693
|
export task describe_action(a)
|
|
694
|
+
when a["type"] == "objective"
|
|
695
|
+
give "objective for team " + a["team"] + ": " + one_line(a["text"], 140)
|
|
658
696
|
when is_plugin_action(a)
|
|
659
697
|
give "plugin " + plugin_of(a) + "." + a["tool"] + (when length(keys(a["args"])) > 0 then " " + one_line(json_encode(a["args"]), 80) otherwise "")
|
|
660
698
|
when a["type"] == "bash"
|
package/lib/sdktools.syn
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
-- lib/sdktools.syn — herramientas que son funciones de la app (JS / Python), registradas con lampson.tool() del SDK
|
|
2
|
+
--
|
|
3
|
+
-- Solo en `lampson run --stdio` (el modo local del SDK): la función corre DENTRO del proceso de la app, con su base
|
|
4
|
+
-- de datos, su auth y sus tipos. Lampson pone lo suyo: qué agente la tiene (la lista de tools del agente), aprobación
|
|
5
|
+
-- ("approve" del agente), plazo y el registro de la llamada. Lo que hace la función adentro es de la app: no hay techo
|
|
6
|
+
-- de Synsema (para eso, una herramienta .syn — lib/apptools.syn).
|
|
7
|
+
--
|
|
8
|
+
-- Protocolo (run.syn):
|
|
9
|
+
-- SDK → Lampson {"op": "tools", "tools": [{name, description, parameters, timeout?}]} reemplaza la lista entera
|
|
10
|
+
-- Lampson → SDK {"id": "", "kind": "tool_request", "data": {call_id, name, args, ctx}}
|
|
11
|
+
-- SDK → Lampson {"op": "tool_result", "call_id", "output"} | {…, "error"}
|
|
12
|
+
-- La lista vive en el blackboard ("sdk:tools"): la escribe el hilo principal y la leen los StdioJob. La respuesta
|
|
13
|
+
-- vuelve por el bus ("sdktool.result"); cada llamada espera la suya por call_id.
|
|
14
|
+
|
|
15
|
+
use "./apptools.syn" as apptools
|
|
16
|
+
|
|
17
|
+
export let MARK be "sdktool"
|
|
18
|
+
let DEFAULT_TIMEOUT be 60
|
|
19
|
+
let MAX_TIMEOUT be 600
|
|
20
|
+
|
|
21
|
+
-- valida y normaliza lo que mandó el SDK → {tools, errors}
|
|
22
|
+
export task normalize(raw)
|
|
23
|
+
let out be []
|
|
24
|
+
let errors be []
|
|
25
|
+
when type_of(raw) != "list"
|
|
26
|
+
give {"tools": [], "errors": ["tools must be a list"]}
|
|
27
|
+
each t in raw
|
|
28
|
+
let n be when type_of(t) == "map" then text(get(t, "name", "")) otherwise ""
|
|
29
|
+
when not matches(n, "[a-z][a-z0-9_]{0,39}")
|
|
30
|
+
set errors to append(errors, "tool name '" + n + "': lowercase letters, digits and _ (max 40), starting with a letter")
|
|
31
|
+
otherwise when contains(apptools.TAKEN, n) or starts_with(n, "plugin_") or starts_with(n, "mcp_")
|
|
32
|
+
set errors to append(errors, "tool name '" + n + "' is a name Lampson already uses")
|
|
33
|
+
otherwise
|
|
34
|
+
let ps be get(t, "parameters", {})
|
|
35
|
+
let tmo be number(get(t, "timeout", DEFAULT_TIMEOUT), DEFAULT_TIMEOUT)
|
|
36
|
+
set out to append(out, {"name": n, "description": text(get(t, "description", "")), "parameters": when type_of(ps) == "map" then ps otherwise {"type": "object", "properties": {}}, "timeout": when tmo <= 0 then DEFAULT_TIMEOUT otherwise (when tmo > MAX_TIMEOUT then MAX_TIMEOUT otherwise tmo)})
|
|
37
|
+
give {"tools": out, "errors": errors}
|
|
38
|
+
|
|
39
|
+
export task all()
|
|
40
|
+
observe "sdk:tools" as st
|
|
41
|
+
when st == nothing or type_of(st) != "map"
|
|
42
|
+
give []
|
|
43
|
+
give st["tools"]
|
|
44
|
+
|
|
45
|
+
export task names()
|
|
46
|
+
give apply((t) => t["name"], all())
|
|
47
|
+
|
|
48
|
+
export task catalog(allowed_names)
|
|
49
|
+
give apply((t) => {"name": t["name"], "description": t["description"], "parameters": t["parameters"]}, where(all(), (t) => contains(allowed_names, t["name"])))
|
|
50
|
+
|
|
51
|
+
-- pedirle la llamada a la app y esperar su respuesta (o el plazo)
|
|
52
|
+
export task call(name, args, ctx)
|
|
53
|
+
require time
|
|
54
|
+
require random
|
|
55
|
+
let f be where(all(), (t) => t["name"] == name)
|
|
56
|
+
when length(f) == 0
|
|
57
|
+
give "ERROR: the app has no tool '" + name + "' registered (lampson.tool)"
|
|
58
|
+
let cid be token()
|
|
59
|
+
let sub be bus_subscribe(["sdktool.result"], {"max_queue": 1000, "on_full": "drop_oldest"})
|
|
60
|
+
bus_publish("stdio.out", {"id": "", "kind": "tool_request", "data": {"call_id": cid, "name": name, "args": when args == nothing then {} otherwise args, "ctx": when ctx == nothing then {} otherwise ctx}})
|
|
61
|
+
let deadline be now() + f[0]["timeout"]
|
|
62
|
+
let res be nothing
|
|
63
|
+
while res == nothing and now() < deadline
|
|
64
|
+
let ev be bus_recv(sub, deadline - now())
|
|
65
|
+
when ev != nothing and type_of(ev["data"]) == "map" and get(ev["data"], "call_id", "") == cid
|
|
66
|
+
set res to ev["data"]
|
|
67
|
+
bus_unsubscribe(sub)
|
|
68
|
+
when res == nothing
|
|
69
|
+
give "ERROR: the app did not answer tool '" + name + "' within " + text(f[0]["timeout"]) + "s"
|
|
70
|
+
when get(res, "error", nothing) != nothing
|
|
71
|
+
give "ERROR: " + text(res["error"])
|
|
72
|
+
let o be get(res, "output", nothing)
|
|
73
|
+
give when o == nothing then "(no output)" otherwise (when type_of(o) == "text" then o otherwise json_encode(o))
|
package/lib/session.syn
CHANGED
|
@@ -13,7 +13,13 @@ export task new_id()
|
|
|
13
13
|
require time
|
|
14
14
|
give format_time(now(), "%Y%m%d-%H%M%S")
|
|
15
15
|
|
|
16
|
+
-- un id es un nombre de archivo: sin / ni .. (un id con ../ abría otro JSON de .lampson)
|
|
17
|
+
export task valid_id(id)
|
|
18
|
+
give matches(text(id), "[A-Za-z0-9_-]{1,96}")
|
|
19
|
+
|
|
16
20
|
task path_of(id)
|
|
21
|
+
when not valid_id(id)
|
|
22
|
+
raise("invalid session id")
|
|
17
23
|
give DIR + "/" + id + ".json"
|
|
18
24
|
|
|
19
25
|
export task save(id, messages, meta)
|
|
@@ -50,6 +56,8 @@ export task from_other_run(doc)
|
|
|
50
56
|
export task exists(id)
|
|
51
57
|
require file.read(".lampson")
|
|
52
58
|
require file.read(".lampson/*")
|
|
59
|
+
when not valid_id(id)
|
|
60
|
+
give false
|
|
53
61
|
try
|
|
54
62
|
read_file(path_of(id), 1, 1)
|
|
55
63
|
give true
|
package/lib/teamrun.syn
CHANGED
|
@@ -26,7 +26,7 @@ task flag_budget(team, agent)
|
|
|
26
26
|
let k be "teams:budget:" + team["id"] + ":" + agent + ":" + format_time(now(), "%Y-%m-%d")
|
|
27
27
|
when state_get(k) == nothing
|
|
28
28
|
state_set(k, true)
|
|
29
|
-
teams.log("team:" + team["id"], agent, "budget", "", "daily budget reached (" + text(team
|
|
29
|
+
teams.log("team:" + team["id"], agent, "budget", "", "daily budget reached (" + text(teams.cap_of(team, agent)) + " tokens): no more turns today")
|
|
30
30
|
|
|
31
31
|
-- un turno para `agent` en su conversación del equipo
|
|
32
32
|
export task deliver_to(team, agent, sender, head)
|
|
@@ -43,7 +43,18 @@ export task deliver_to(team, agent, sender, head)
|
|
|
43
43
|
when spec == nothing
|
|
44
44
|
teams.log("team:" + team["id"], "lampson", "error", "", "no agent file for '" + agent + "' — create .lampson/agents/" + agent + ".agent.json")
|
|
45
45
|
give false
|
|
46
|
-
|
|
46
|
+
-- su primer turno en un objetivo: conversación nueva (el tablero, el registro y git ya cuentan lo anterior)
|
|
47
|
+
let oid be teams.objective_of_scope("team:" + team["id"])
|
|
48
|
+
when oid != 0 and teams.seat_session_of(oid, agent) == ""
|
|
49
|
+
runtime.forget_thread(agent, "team:" + team["id"])
|
|
50
|
+
-- quién está en medio de un turno: sus mensajes le llegan cuando termina. (Visto 2026-10-17: el CEO le preguntó
|
|
51
|
+
-- tres veces al CMO, que estaba documentando, no le contestó, y le pasó su tarea al CTO: los dos hicieron lo mismo.)
|
|
52
|
+
let busy be []
|
|
53
|
+
each m in team["members"]
|
|
54
|
+
when m["agent"] != agent and mailbox.working(m["agent"], "team:" + team["id"])
|
|
55
|
+
set busy to append(busy, m["agent"])
|
|
56
|
+
let now_line be when length(busy) == 0 then "" otherwise "\nWorking right now (your messages reach them when their turn ends — wait for them, don't reassign their tasks): " + join(busy, ", ")
|
|
57
|
+
let sobre be {"to": agent, "thread": "team:" + team["id"], "session": "", "from": sender, "text": teams.turn_text(team, agent, head) + now_line, "images": [], "channel": "team", "meta": {"team": team["id"], "from": sender}}
|
|
47
58
|
mailbox.submit(sobre, {"mode": when spec["permission"] != "" then "" otherwise "strict", "buffer": mailbox.buffer_of(spec, false)})
|
|
48
59
|
give true
|
|
49
60
|
|
|
@@ -97,9 +108,34 @@ export task objective_due(o)
|
|
|
97
108
|
give false
|
|
98
109
|
-- en un equipo, el líder solo hace ronda si algo cambió o tiene tareas propias (si no, está esperando a los demás)
|
|
99
110
|
when o["team"] != ""
|
|
100
|
-
|
|
111
|
+
when teams.has_work("team:" + o["team"], o["agent"])
|
|
112
|
+
give true
|
|
113
|
+
-- nadie se mueve hace rato: el líder recibe UNA ronda para destrabar (y otra si sigue igual, STALL_SECONDS después)
|
|
114
|
+
when stalled(o)
|
|
115
|
+
teams.obj_set(o["id"], {"reply": STALL_TEXT})
|
|
116
|
+
give true
|
|
117
|
+
give false
|
|
101
118
|
give true
|
|
102
119
|
|
|
120
|
+
export let STALL_SECONDS be 600
|
|
121
|
+
export let STALL_TEXT be "[stalled] Nothing has moved in the team for 10 minutes and nobody is working. Look at the board: is someone waiting for something, or did someone stop without saying? Unblock it (`send` them what they need; reassign only if they said they are blocked) or, if the team can't go on, ask the person with `objective` ask."
|
|
122
|
+
|
|
123
|
+
-- ¿el equipo de un objetivo está quieto? nadie trabajando, ningún mensaje por entregar y nada en el registro hace rato
|
|
124
|
+
task stalled(o)
|
|
125
|
+
require db(".lampson/teams.db")
|
|
126
|
+
require file(".lampson")
|
|
127
|
+
require file(".lampson/*")
|
|
128
|
+
require file.read("workspace")
|
|
129
|
+
require file.read("workspace/*")
|
|
130
|
+
require time
|
|
131
|
+
let tm be teams.get(o["team"])
|
|
132
|
+
when tm == nothing or now() - o["last_end"] < STALL_SECONDS
|
|
133
|
+
give false
|
|
134
|
+
each m in tm["members"]
|
|
135
|
+
when mailbox.working(m["agent"], "team:" + tm["id"])
|
|
136
|
+
give false
|
|
137
|
+
give teams.quiet_for("team:" + tm["id"]) >= STALL_SECONDS
|
|
138
|
+
|
|
103
139
|
-- escribe el resumen si cambió: equipos, objetivos abiertos (y los últimos cerrados) y aprobaciones pendientes
|
|
104
140
|
export task write_summary()
|
|
105
141
|
require db(".lampson/teams.db")
|
|
@@ -110,7 +146,8 @@ export task write_summary()
|
|
|
110
146
|
require file(".lampson/*")
|
|
111
147
|
require file.read("workspace")
|
|
112
148
|
require file.read("workspace/*")
|
|
113
|
-
|
|
149
|
+
-- roles: lo que /equipos del hub muestra de cada equipo (el rol, o el id del agente si no tiene)
|
|
150
|
+
let ts be apply(teams.all(), (t) => {"id": t["id"], "name": t["name"], "description": t["description"], "members": length(t["members"]), "lead": teams.lead_of(t), "roles": apply(t["members"], (m) => when contains(m, "role") and m["role"] != nothing and text(m["role"]) != "" then text(m["role"]) otherwise text(m["agent"]))})
|
|
114
151
|
let objs be teams.obj_list()
|
|
115
152
|
let open_o be where(objs, (o) => contains(["active", "waiting", "paused"], o["status"]))
|
|
116
153
|
let closed be slice(where(objs, (o) => not contains(["active", "waiting", "paused"], o["status"])), 0, 5)
|
|
@@ -163,7 +200,7 @@ export task tick()
|
|
|
163
200
|
flag_budget(team, m["recipient"])
|
|
164
201
|
otherwise
|
|
165
202
|
let who be teams.member(team, m["sender"])
|
|
166
|
-
let head be "[message from " + m["sender"] + (when who != nothing then " (" + who["role"] + ")" otherwise "") + "]\n" + m["text"]
|
|
203
|
+
let head be when m["sender"] == "person" then "[message from the person who owns this team — act on it]\n" + m["text"] otherwise "[message from " + m["sender"] + (when who != nothing then " (" + who["role"] + ")" otherwise "") + "]\n" + m["text"]
|
|
167
204
|
when deliver_to(team, m["recipient"], m["sender"], head)
|
|
168
205
|
teams.mark(m["id"], "delivered")
|
|
169
206
|
set n to n + 1
|