lampson 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +8 -2
  2. package/chat.syn +1 -1
  3. package/hub.tpl.syn +99 -7
  4. package/lib/api.syn +178 -7
  5. package/lib/diagnose.syn +142 -0
  6. package/lib/loop.syn +14 -0
  7. package/lib/plugins.syn +6 -4
  8. package/lib/provider.syn +16 -13
  9. package/lib/runtime.syn +56 -0
  10. package/lib/schedule.syn +40 -2
  11. package/lib/teamrun.syn +78 -4
  12. package/lib/teams.syn +397 -24
  13. package/lib/workspaces.syn +84 -1
  14. package/lib/worktree.syn +108 -0
  15. package/package.json +1 -1
  16. package/plugins/example-hello/plugin.json +1 -0
  17. package/public/css/chat.css +9 -8
  18. package/public/css/hub.css +73 -11
  19. package/public/css/layout.css +12 -4
  20. package/public/css/login.css +1 -1
  21. package/public/css/mobile.css +2 -2
  22. package/public/css/panel.css +16 -7
  23. package/public/css/sidebar.css +1 -1
  24. package/public/css/teams.css +722 -48
  25. package/public/css/tokens.css +36 -12
  26. package/public/css/views.css +124 -0
  27. package/public/hub.html +17 -8
  28. package/public/index.html +3 -2
  29. package/public/js/app.js +2 -2
  30. package/public/js/approvals.js +1 -1
  31. package/public/js/core.js +5 -2
  32. package/public/js/flow.js +187 -0
  33. package/public/js/hub.js +131 -22
  34. package/public/js/navtabs.js +23 -0
  35. package/public/js/objdiag.js +90 -0
  36. package/public/js/objlive.js +393 -0
  37. package/public/js/panel.js +2 -1
  38. package/public/js/plugins-home.js +59 -0
  39. package/public/js/plugins.js +40 -18
  40. package/public/js/schedules.js +5 -0
  41. package/public/js/sidebar.js +6 -4
  42. package/public/js/tasks-home.js +104 -0
  43. package/public/js/teams-home.js +144 -0
  44. package/public/js/teams.js +928 -195
  45. package/public/js/terminal.js +8 -2
  46. package/public/js/workspaces.js +6 -3
  47. package/public/plugins-home.html +32 -0
  48. package/public/tasks-home.html +31 -0
  49. package/public/teams-home.html +45 -0
  50. package/public/teams.html +33 -45
  51. package/public/vendor/xterm-addon-webgl.js +2 -0
  52. package/web.syn +61 -8
package/web.syn CHANGED
@@ -152,6 +152,13 @@ mcp.start_all(8)
152
152
  share {"id": text(now())} as "lampson:run"
153
153
  share {"kind": "web"} as "lampson:ui"
154
154
 
155
+ -- la pantalla de equipos (public/teams.html) en cualquiera de sus rutas; abierta por el puerto de este proceso, al hub
156
+ task teams_page(request, slug, rest)
157
+ let h be headers of request
158
+ when env("LAMPSON_WS", "") != "" and not contains(h, "x-forwarded-host")
159
+ give redirect("http://127.0.0.1:8080/w/" + slug + rest)
160
+ give html(read_file("public/teams.html"))
161
+
155
162
  serve on 8080
156
163
  -- el proxy del hub (y nada más) conecta por loopback: sus X-Forwarded-* traen la origin real (check_client).
157
164
  -- Acá y no como flag de start_ws: el web.syn se copia al arrancar, y un hub viejo en memoria lo lanzaba sin el
@@ -458,7 +465,7 @@ serve on 8080
458
465
  private
459
466
  stream
460
467
  state_set("lampson:last_used", now())
461
- let sub be bus_subscribe(["proc.*", "subagent.*", "mcp.*", "approval.*", "schedule.*"], {"max_queue": 512})
468
+ let sub be bus_subscribe(["proc.*", "subagent.*", "mcp.*", "approval.*", "schedule.*", "team.*"], {"max_queue": 512})
462
469
  let open be true
463
470
  while open
464
471
  let ev be bus_recv(sub, 25)
@@ -615,7 +622,7 @@ serve on 8080
615
622
 
616
623
  route "GET /w/:slug/api/approvals" requires auth
617
624
  private
618
- give {"approvals": approvals.list(), "public_url": approvals.public_url(), "webhook": approvals.webhook_url() != ""}
625
+ give {"approvals": api.approvals_view(approvals.list()), "public_url": approvals.public_url(), "webhook": approvals.webhook_url() != ""}
619
626
 
620
627
  -- link de decisión (PÚBLICO a propósito: lo abre el humano desde el teléfono; el token de un solo uso es la
621
628
  -- autorización, como en el `approve` nativo de Synsema bajo serve). GET porque un link en un chat es un GET.
@@ -893,15 +900,18 @@ serve on 8080
893
900
  -- ---------- EQUIPOS Y OBJETIVOS: su pantalla propia (public/teams.html) y la API privada que la alimenta ----------
894
901
  route "GET /w/:slug/equipos"
895
902
  private
896
- let h be headers of request
897
- when env("LAMPSON_WS", "") != "" and not contains(h, "x-forwarded-host")
898
- give redirect("http://127.0.0.1:8080/w/" + params.slug + "/equipos")
899
- give html(read_file("public/teams.html"))
903
+ give teams_page(request, params.slug, "/equipos")
904
+ route "GET /w/:slug/equipos/*rest"
905
+ private
906
+ give teams_page(request, params.slug, "/equipos/" + params.rest)
907
+ route "GET /w/:slug/objetivos/*rest"
908
+ private
909
+ give teams_page(request, params.slug, "/objetivos/" + params.rest)
900
910
 
901
911
  route "GET /w/:slug/api/objectives" requires auth
902
912
  private
903
- let rows be apply(teams.obj_list(), (o) => {"id": o["id"], "ref": "O-" + text(o["id"]), "agent": o["agent"], "team": o["team"], "text": o["text"], "status": o["status"], "progress": o["progress"], "question": o["question"], "question_kind": o["question_kind"], "turns": o["turns"], "spent": o["spent"], "budget_tokens": o["budget_tokens"], "updated_at": o["updated_at"], "working": mailbox.working(o["agent"], teams.obj_scope(o))})
904
- give {"objectives": rows, "teams": apply(teams.all(), (t) => {"id": t["id"], "lead": teams.lead_of(t), "description": t["description"]}), "agents": apply(where(runtime.names(), (n) => not runtime.get(n)["builtin"]), (n) => {"id": n, "description": runtime.get(n)["description"]})}
913
+ let rows be apply(teams.obj_list(), (o) => {"id": o["id"], "ref": "O-" + text(o["id"]), "agent": o["agent"], "team": o["team"], "text": o["text"], "status": o["status"], "progress": o["progress"], "question": o["question"], "question_kind": o["question_kind"], "turns": o["turns"], "spent": o["spent"], "budget_tokens": o["budget_tokens"], "updated_at": o["updated_at"], "created_at": o["created_at"], "created_by": o["created_by"], "from_obj": o["from_obj"], "pass_pending": o["pass_pending"] != "", "working": mailbox.working(o["agent"], teams.obj_scope(o))})
914
+ give {"objectives": rows, "teams": apply(teams.all(), (t) => {"id": t["id"], "name": t["name"], "lead": teams.lead_of(t), "description": t["description"]}), "agents": apply(where(runtime.names(), (n) => not runtime.get(n)["builtin"]), (n) => {"id": n, "description": runtime.get(n)["description"]})}
905
915
 
906
916
  route "GET /w/:slug/api/objectives/:id" requires auth
907
917
  private
@@ -928,6 +938,33 @@ serve on 8080
928
938
  recover err
929
939
  give fail(409, regex_replace(text(err), "^.*?:\\d+:\\d+: ", ""))
930
940
 
941
+ route "GET /w/:slug/api/objectives/:id/facts" requires auth
942
+ private
943
+ let o be teams.obj_get(floor(number(params.id)))
944
+ when o == nothing
945
+ give fail(404, "no such objective")
946
+ give {"facts": api.obj_facts(o)}
947
+
948
+ route "POST /w/:slug/api/objectives/:id/diagnose" requires auth
949
+ private
950
+ let o be teams.obj_get(floor(number(params.id)))
951
+ when o == nothing
952
+ give fail(404, "no such objective")
953
+ let r be api.obj_analyze(o)
954
+ when not r["ok"]
955
+ give fail(502, r["error"])
956
+ give r
957
+
958
+ route "POST /w/:slug/api/objectives/:id/act" requires auth
959
+ private
960
+ let o be teams.obj_get(floor(number(params.id)))
961
+ when o == nothing
962
+ give fail(404, "no such objective")
963
+ let r be api.obj_act(o, json of request)
964
+ when not r["ok"]
965
+ give fail(400, r["error"])
966
+ give r
967
+
931
968
  route "POST /w/:slug/api/objectives/:id/cancel" requires auth
932
969
  private
933
970
  give api.objective_view(teams.obj_cancel(floor(number(params.id)), "person"))
@@ -943,6 +980,22 @@ serve on 8080
943
980
  give fail(400, r["error"])
944
981
  give api.teams_view()
945
982
 
983
+ route "POST /w/:slug/api/teams/seat-tokens" requires auth
984
+ private
985
+ expect body {agent: text}
986
+ let r be api.seat_tokens(json of request)
987
+ when not r["ok"]
988
+ give fail(400, r["error"])
989
+ give r
990
+
991
+ route "POST /w/:slug/api/teams/delete" requires auth
992
+ private
993
+ expect body {id: text}
994
+ let r be api.delete_team(json of request)
995
+ when not r["ok"]
996
+ give fail(400, r["error"])
997
+ give r
998
+
946
999
  route "GET /w/:slug/api/keys" requires auth
947
1000
  private
948
1001
  let pub be approvals.public_url()