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
@@ -1,4 +1,4 @@
1
- /* tokens: fuentes, paleta (dark/light), base y botones — lo que todo lo demás asume */
1
+ /* tokens: fuentes, paleta (dark/light), superficies, radios, base y botones — lo que todo lo demás asume */
2
2
  /* Misma dirección que synsema.dev: tinta sobre papel, una superfamilia (IBM Plex) en dos
3
3
  voces — la SERIF para lo que se lee (mensajes, hero), la MONO para estructura y maquinaria
4
4
  (header, sidebar, pasos, código, controles). El color se raciona: azul = link / dónde estás,
@@ -15,20 +15,29 @@
15
15
  @font-face{font-family:"Plex Mono";font-style:normal;font-weight:600;font-display:swap;src:url(/fonts/plex-mono-600-latin-ext.woff2) format("woff2");unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}
16
16
 
17
17
  :root, :root[data-theme=dark] {
18
- --paper:#131412; --paper-2:#1b1c19; --paper-3:#212320;
19
- --ink:#e9e8df; --ink-2:#9b9c90; --ink-3:#848678;
20
- --rule:#2b2c27; --rule-2:#3c3d36;
18
+ --paper:#131412; --paper-2:#1d1e1b; --paper-3:#262723;
19
+ --surface:#1a1b18; --surface-2:#21221f;
20
+ --ink:#e9e8df; --ink-2:#a8a99d; --ink-3:#8e9083;
21
+ --rule:#34352f; --rule-2:#4a4b43;
22
+ /* elevación: en oscuro la sombra casi no se ve, así que la tarjeta se separa con un filo de luz arriba */
23
+ --lift:inset 0 1px 0 rgba(255,255,255,.035), 0 1px 2px rgba(0,0,0,.45);
24
+ --lift-hover:inset 0 1px 0 rgba(255,255,255,.05), 0 6px 18px rgba(0,0,0,.5);
21
25
  --accent:#8fb4dc; --accent-bg:#1b2836;
22
26
  --rubric:#d98670; --str:#a8bd84; --amber:#d9b26f; --ok:#8fc28f;
23
27
  --sel:#33465b; --term-blue:#4f86d1;
24
28
  --serif:"Plex Serif",Georgia,"Times New Roman",serif;
25
29
  --mono:"Plex Mono",ui-monospace,SFMono-Regular,Consolas,"Liberation Mono",monospace;
26
- --r:3px; --side:280px;
30
+ /* radios por jerarquía: chico (chips, items de lista), control (botones, campos), tarjeta y panel, pastilla */
31
+ --r-sm:6px; --r:8px; --r-lg:12px; --r-pill:999px; --side:280px;
27
32
  }
28
33
  :root[data-theme=light] {
29
- --paper:#fcfcfa; --paper-2:#f4f3ee; --paper-3:#ecebe3;
30
- --ink:#1a1b18; --ink-2:#56584f; --ink-3:#6a6c61;
31
- --rule:#e4e3da; --rule-2:#cfcec2;
34
+ --paper:#f6f5f0; --paper-2:#ecebe4; --paper-3:#e3e2da;
35
+ --surface:#ffffff; --surface-2:#faf9f5;
36
+ --ink:#1a1b18; --ink-2:#4e5049; --ink-3:#63655b;
37
+ --rule:#d8d5c9; --rule-2:#c4c2b5;
38
+ /* sombras cortas y teñidas del papel (no gris puro): apoyan la tarjeta, no la hacen flotar */
39
+ --lift:0 1px 1px rgba(60,54,36,.05), 0 1px 3px rgba(60,54,36,.06);
40
+ --lift-hover:0 1px 2px rgba(60,54,36,.06), 0 6px 16px rgba(60,54,36,.09);
32
41
  --accent:#21578c; --accent-bg:#e9eef4;
33
42
  --rubric:#99372a; --str:#4a6b3f; --amber:#8a6a1f; --ok:#3d7a3d;
34
43
  --sel:#cfe0f0; --term-blue:#21578c;
@@ -38,13 +47,13 @@
38
47
  html, body { height:100%; }
39
48
  body { margin:0; background:var(--paper); color:var(--ink); font:400 14.5px/1.6 var(--serif); -webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility; }
40
49
  ::selection { background:var(--sel); }
41
- :focus-visible { outline:2px solid var(--accent); outline-offset:2px; border-radius:1px; }
50
+ :focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
42
51
  button, select, textarea { font-family:inherit; }
43
52
  .spacer { flex:1; }
44
53
 
45
- /* botones: el primario es tinta sobre papel, el secundario solo borde */
46
- button { font:600 10.5px/1 var(--mono); text-transform:uppercase; letter-spacing:.09em; color:var(--ink-2); background:none; border:1px solid var(--rule-2); border-radius:2px; padding:7px 12px; cursor:pointer; }
47
- button:hover { color:var(--ink); border-color:var(--ink-3); }
54
+ /* botones: el primario es tinta sobre papel, el secundario solo borde. En minúscula: se leen como lo que hacen */
55
+ button { font:600 12.5px/1 var(--mono); color:var(--ink-2); background:none; border:1px solid var(--rule-2); border-radius:var(--r); padding:8px 14px; cursor:pointer; transition:border-color .12s, background-color .12s, color .12s; }
56
+ button:hover { color:var(--ink); border-color:var(--ink-3); background:var(--paper-2); }
48
57
  button.primary { color:var(--paper); background:var(--ink); border-color:var(--ink); }
49
58
  button.primary:hover { opacity:.85; color:var(--paper); }
50
59
  button:disabled { opacity:.45; cursor:default; }
@@ -55,3 +64,18 @@ button:disabled { opacity:.45; cursor:default; }
55
64
  *::-webkit-scrollbar-track { background:transparent; }
56
65
  *::-webkit-scrollbar-thumb { background:var(--rule-2); border-radius:4px; }
57
66
  *::-webkit-scrollbar-thumb:hover { background:var(--ink-3); }
67
+
68
+ /* pestañas del hub: Proyectos · Equipos son las dos mitades del producto (public/hub.html y public/teams-home.html) */
69
+ .navtabs { display:flex; align-items:center; gap:2px; margin-left:6px; min-width:0; overflow-x:auto; scrollbar-width:none; }
70
+ .navtabs::-webkit-scrollbar { display:none; }
71
+ .navtabs a { font:400 13px/1 var(--mono); color:var(--ink-2); text-decoration:none; padding:8px 12px; border-radius:var(--r-pill); display:flex; align-items:center; gap:6px; white-space:nowrap; }
72
+ .navtabs a:hover { color:var(--ink); background:var(--paper-2); }
73
+ .navtabs a.on { color:var(--ink); background:var(--paper-3); }
74
+ .navtabs .badge { font:600 10.5px/1 var(--mono); color:var(--paper); background:var(--rubric); border-radius:var(--r-pill); padding:3px 7px; }
75
+ /* en un celular las pestañas son la navegación: la marca y las etiquetas secundarias ceden el lugar */
76
+ @media (max-width: 520px) {
77
+ .navtabs { margin-left:0; }
78
+ .navtabs a { padding:7px 9px; }
79
+ header .brand, .tbar .brand { display:none; }
80
+ .tbar .live { display:none; }
81
+ }
@@ -0,0 +1,124 @@
1
+ /* views.css — /tareas y /plugins del hub (public/tasks-home.html, public/plugins-home.html). La base es teams.css
2
+ (barra, .homegrid, .pblock, .projhead, .st): esto suma la cabecera de la vista, las filas de tareas y las tarjetas
3
+ del escaparate de plugins. */
4
+ body.home .homegrid { max-width:1180px; width:100%; margin:0 auto; }
5
+ .vhead { margin:4px 0 22px; }
6
+ .vhead h1 { font:600 1.7rem/1.15 var(--serif); letter-spacing:-.02em; margin:0 0 6px; }
7
+ .vlead { margin:0; max-width:760px; color:var(--ink-2); }
8
+ .vfoot { margin:26px 0 0; color:var(--ink-3); font-size:13.5px; max-width:760px; }
9
+ .vfoot a { color:var(--accent); text-underline-offset:.2em; }
10
+ .vempty { border:1px dashed var(--rule-2); border-radius:var(--r-lg); padding:20px 22px; color:var(--ink-2); max-width:760px; }
11
+ .vempty p { margin:0 0 8px; }
12
+ .vpick { display:flex; flex-wrap:wrap; gap:8px; margin-top:10px; }
13
+ .vpick a { font:400 12px/1 var(--mono); color:var(--accent); text-decoration:none; border:1px solid var(--rule-2); border-radius:var(--r-pill); padding:7px 12px; }
14
+ .vpick a:hover { border-color:var(--accent); }
15
+ .projhead .open + .open { margin-left:4px; }
16
+
17
+ /* tareas: interruptor · qué y cuándo · estado · correr */
18
+ .taskrow { display:grid; grid-template-columns:auto minmax(0, 1fr) minmax(150px, 230px) auto; align-items:center; gap:14px; padding:10px 16px; border-top:1px solid var(--rule); }
19
+ .taskrow:first-of-type { border-top:none; }
20
+ .taskrow.off .tmain { opacity:.6; }
21
+ /* interruptor encendida/apagada: el checkbox real queda (teclado y lector de pantalla), se ve la pista */
22
+ .taskrow .sw { position:relative; display:flex; flex-direction:column; align-items:center; gap:5px; cursor:pointer; width:72px; }
23
+ .taskrow .sw input { position:absolute; opacity:0; width:38px; height:22px; margin:0; cursor:pointer; }
24
+ .taskrow .swt { width:38px; height:22px; border-radius:var(--r-pill); background:var(--rule-2); position:relative; transition:background-color .15s; }
25
+ .taskrow .swt::after { content:''; position:absolute; left:3px; top:3px; width:16px; height:16px; border-radius:50%; background:var(--surface); box-shadow:0 1px 2px rgba(0,0,0,.25); transition:transform .15s; }
26
+ .taskrow .sw input:checked + .swt { background:var(--ok); }
27
+ .taskrow .sw input:checked + .swt::after { transform:translateX(16px); }
28
+ .taskrow .sw input:focus-visible + .swt { outline:2px solid var(--accent); outline-offset:2px; }
29
+ .taskrow .swl { font:400 11px/1 var(--mono); color:var(--ink-3); }
30
+ .tmain { display:flex; flex-direction:column; min-width:0; color:var(--ink); text-decoration:none; }
31
+ .tmain b { font-weight:600; }
32
+ .tmain:hover b { text-decoration:underline; text-underline-offset:.18em; }
33
+ .tplan { font:400 11.5px/1.5 var(--mono); color:var(--ink-2); }
34
+ .tact { font-size:12.5px; color:var(--ink-3); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
35
+ .tstate { display:flex; flex-direction:column; align-items:flex-start; gap:4px; min-width:0; }
36
+ .twhen { font:400 11px/1.5 var(--mono); color:var(--ink-3); }
37
+ .terr { font-size:12px; color:var(--rubric); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:100%; }
38
+
39
+ /* plugins: escaparate */
40
+ .pgrid { display:grid; grid-template-columns:repeat(auto-fill, minmax(300px, 1fr)); gap:14px; }
41
+ .pcard { display:flex; flex-direction:column; background:var(--surface); border:1px solid var(--rule); border-radius:var(--r-lg); box-shadow:var(--lift); padding:16px 18px 14px; min-width:0; }
42
+ .pcard.used { border-color:var(--rule-2); }
43
+ .pcard .pn { font:600 17px/1.2 var(--serif); margin:0 0 8px; }
44
+ .ptags { display:flex; flex-wrap:wrap; gap:6px; margin:0 0 10px; }
45
+ .ptags span { font:400 11.5px/1 var(--mono); color:var(--ink-2); background:var(--paper-2); border-radius:var(--r-pill); padding:4px 9px; }
46
+ .pdesc { margin:0 0 10px; font-size:14px; line-height:1.5; color:var(--ink); flex:1; }
47
+ .pcfg { margin:0 0 10px; font:400 11px/1.6 var(--mono); color:var(--ink-3); }
48
+ .pcfg code { color:var(--ink-2); }
49
+ .pwhere { margin:0 0 12px; font:400 11.5px/1.5 var(--mono); color:var(--ink-3); }
50
+ .pwhere a { color:var(--ok); text-decoration:none; }
51
+ .pwhere a:hover { text-decoration:underline; }
52
+ .pcard > button { align-self:flex-start; }
53
+ .ppick { display:flex; flex-wrap:wrap; align-items:center; gap:6px; font:400 11.5px/1 var(--mono); color:var(--ink-3); }
54
+ .ppick a { color:var(--accent); text-decoration:none; border:1px solid var(--rule-2); border-radius:var(--r-pill); padding:6px 11px; }
55
+ .ppick a:hover { border-color:var(--accent); }
56
+ .ppick .pcancel { cursor:pointer; padding:6px 4px; }
57
+ .ppick .pcancel:hover { color:var(--ink); }
58
+
59
+ @media (max-width: 720px) {
60
+ .taskrow { grid-template-columns:auto minmax(0, 1fr); }
61
+ .taskrow .tstate, .taskrow > button { grid-column:2; }
62
+ .projhead .ppath { display:none; }
63
+ }
64
+ .vfoot code { font:400 .9em/1.5 var(--mono); background:var(--paper-2); padding:.1em .4em; border-radius:var(--r-sm); color:var(--ink); }
65
+
66
+ /* /equipos: una tarjeta por equipo (public/teams-home.html) */
67
+ .tgrid { display:grid; grid-template-columns:repeat(auto-fill, minmax(360px, 1fr)); gap:16px; }
68
+ .tcard { display:flex; flex-direction:column; gap:12px; background:var(--surface); border:1px solid var(--rule); border-radius:var(--r-lg); box-shadow:var(--lift); padding:18px 20px 16px; min-width:0; }
69
+ .thead { display:flex; align-items:baseline; gap:12px; }
70
+ .thead h2 { font:600 20px/1.2 var(--serif); margin:0; }
71
+ .tproj { margin-left:auto; display:flex; align-items:center; gap:7px; font:400 12.5px/1 var(--mono); color:var(--ink-2); text-decoration:none; white-space:nowrap; }
72
+ .tproj:hover { color:var(--ink); }
73
+ .tdesc { margin:-6px 0 0; color:var(--ink-2); font-size:14px; }
74
+ .roles { display:flex; flex-wrap:wrap; gap:6px; }
75
+ .role { font:400 12px/1 var(--mono); color:var(--ink-2); background:var(--paper-2); border-radius:var(--r-pill); padding:6px 11px; }
76
+ .role.lead { color:var(--ink); background:var(--accent-bg); }
77
+ .tnow { display:flex; flex-direction:column; gap:6px; padding:12px 14px; background:var(--paper-2); border-radius:var(--r); }
78
+ .tidle { margin:0; color:var(--ink-2); font-size:14px; }
79
+ .oline { display:flex; align-items:baseline; gap:10px; color:var(--ink); text-decoration:none; font-size:14px; line-height:1.45; min-width:0; }
80
+ .oline .st { flex:none; }
81
+ .oline .otext { min-width:0; }
82
+ .oline:hover .otext { text-decoration:underline; text-underline-offset:.18em; }
83
+ .oprog { margin:0 0 0 2px; color:var(--ink-3); font-size:13px; }
84
+ .tacts { display:flex; align-items:center; gap:14px; }
85
+ .tacts .lnk { font:400 12.5px/1 var(--mono); color:var(--accent); text-decoration:none; }
86
+ .tacts .lnk:hover { text-decoration:underline; }
87
+ .tdone > summary { cursor:pointer; list-style:none; font:400 12.5px/1 var(--mono); color:var(--ink-3); padding:4px 0; }
88
+ .tdone > summary::-webkit-details-marker { display:none; }
89
+ .tdone > summary::before { content:'▸ '; }
90
+ .tdone[open] > summary::before { content:'▾ '; }
91
+ .tdone > summary:hover { color:var(--ink); }
92
+ .tdone[open] { display:flex; flex-direction:column; gap:8px; }
93
+ .tdone .oline { color:var(--ink-2); }
94
+ /* las tarjetas de una misma fila comparten sus filas (subgrid): título, para qué, roles, en curso, acciones y terminados
95
+ quedan a la misma altura aunque una tenga más roles o más texto. Las seis filas existen siempre (vacías si no hay) */
96
+ @supports (grid-template-rows:subgrid) {
97
+ .tcard { display:grid; grid-row:span 6; grid-template-rows:subgrid; row-gap:12px; }
98
+ .tcard > .roles, .tcard > .tacts, .tcard > .tdone { align-self:start; }
99
+ }
100
+ .tcard > .tdesc:empty, .tcard > div.tdone { margin:0; }
101
+ /* .clip: texto cortado a dos líneas (public/js/teams-home.js → clip). Si no entra, «ver más» sobre el final y, al pasar
102
+ el mouse o con el foco, el texto completo se despliega en el mismo lugar, encima de lo que sigue */
103
+ .clip { position:relative; display:block; --clip-bg:var(--surface); }
104
+ .tnow .clip { --clip-bg:var(--paper-2); }
105
+ .clip .ct { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
106
+ .clip .cmore, .clip .cfull { display:none; }
107
+ .clip.cut .cmore { display:block; position:absolute; right:0; bottom:0; padding-left:32px; font:400 12px/1.6 var(--mono); color:var(--accent); background:linear-gradient(to right, transparent, var(--clip-bg) 28px); }
108
+ .clip.cut:hover .cfull, .clip.cut:focus-visible .cfull, .oline:focus-visible .clip.cut .cfull { display:block; position:absolute; z-index:20; left:-11px; right:-11px; top:-9px; max-height:260px; overflow:auto; padding:8px 10px; color:var(--ink); background:var(--surface); border:1px solid var(--rule-2); border-radius:var(--r); box-shadow:var(--lift-hover); }
109
+ .clip.cut:focus-visible { outline:none; }
110
+ .tinvite { max-width:620px; background:var(--surface); border:1px dashed var(--rule-2); border-radius:var(--r-lg); padding:22px 24px; }
111
+ .tinvite h2 { font:600 20px/1.2 var(--serif); margin:0 0 8px; }
112
+ .tinvite p { margin:0 0 16px; color:var(--ink-2); }
113
+ .solohead { font:600 16px/1.2 var(--serif); margin:30px 0 12px; }
114
+ .solo { display:flex; flex-direction:column; gap:8px; max-width:900px; }
115
+ .srow { display:flex; gap:14px; align-items:baseline; background:var(--surface); border:1px solid var(--rule); border-radius:var(--r); box-shadow:var(--lift); padding:10px 14px; }
116
+ .swho { font:600 13px/1.3 var(--mono); white-space:nowrap; }
117
+ .swho span { font-weight:400; color:var(--ink-3); }
118
+
119
+ /* un link con forma de botón (acciones que navegan) */
120
+ a.btn { display:inline-flex; align-items:center; font:600 12.5px/1 var(--mono); color:var(--ink-2); text-decoration:none; border:1px solid var(--rule-2); border-radius:var(--r); padding:9px 14px; transition:border-color .12s, background-color .12s, color .12s; }
121
+ a.btn:hover { color:var(--ink); border-color:var(--ink-3); background:var(--paper-2); }
122
+ a.btn.primary { color:var(--paper); background:var(--ink); border-color:var(--ink); }
123
+ a.btn.primary:hover { opacity:.85; }
124
+ @media (max-width: 720px) { .tgrid { grid-template-columns:minmax(0, 1fr); } .thead { flex-wrap:wrap; } .tproj { margin-left:0; } }
package/public/hub.html CHANGED
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="utf-8">
5
5
  <link rel="icon" href="/favicon.svg" type="image/svg+xml">
6
- <title>Lampson · workspaces</title>
6
+ <title>Lampson · proyectos</title>
7
7
  <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
8
8
  <meta name="theme-color" content="#131412">
9
9
  <meta name="mobile-web-app-capable" content="yes">
@@ -21,7 +21,8 @@
21
21
  <body class="hub">
22
22
  <header>
23
23
  <div class="hrow">
24
- <span class="brand">lampson<span class="proj">workspaces</span></span>
24
+ <span class="brand">lampson</span>
25
+ <nav class="navtabs" data-on="proyectos"></nav>
25
26
  <span class="spacer"></span>
26
27
  <span class="pill" id="devicesBtn" role="button" tabindex="0">dispositivos</span>
27
28
  <button class="theme-toggle" id="theme" type="button" title="cambiar tema"></button>
@@ -29,16 +30,24 @@
29
30
  </header>
30
31
  <main>
31
32
  <div id="stage">
32
- <div class="empty">
33
- <p class="eyebrow">workspaces</p>
34
- <h1>¿En qué proyecto trabajamos?</h1>
35
- <p class="lead">Cada workspace es una carpeta de tu disco con su propio agente: sesiones, tareas programadas, plugins, MCP. Corren en procesos separados, así podés tener varios abiertos a la vez. Los que tienen tareas encendidas siguen vivos aunque cierres todo.</p>
36
- <div class="wsgrid" id="wsGrid"></div>
37
- <p class="lead" style="margin-top:22px">Desde una terminal: <code>cd mi-proyecto &amp;&amp; lampson</code> (terminal) o <code>lampson --web</code> (esta web, en ese workspace).</p>
33
+ <div class="empty hubhome">
34
+ <div class="hhead">
35
+ <h1>Proyectos</h1>
36
+ <span class="spacer"></span>
37
+ <input id="wsSearch" type="search" placeholder="buscar proyecto…" autocomplete="off" spellcheck="false" aria-label="buscar proyecto">
38
+ <button id="wsManage" type="button" title="encender, apagar, política de vida, quitar">gestionar</button>
39
+ <button id="wsNew" class="primary" type="button">+ nuevo proyecto</button>
40
+ </div>
41
+ <div class="lead">Cada proyecto es una carpeta de tu disco con su propio agente. <details class="how"><summary>¿cómo funciona?</summary><p>Cada uno tiene sus sesiones, tareas programadas, plugins y MCP, y corre en su propio proceso: podés tener varios abiertos a la vez. Los que tienen tareas encendidas siguen activos aunque cierres todo; al abrir uno apagado se enciende solo.</p></details></div>
42
+ <div id="wsAttn"></div>
43
+ <div class="tiles" id="wsTiles"></div>
44
+ <div id="wsGroups"></div>
45
+ <p class="cli">desde una terminal: <code>cd mi-proyecto &amp;&amp; lampson</code> <span class="copy" data-copy="cd mi-proyecto &amp;&amp; lampson" role="button" tabindex="0">copiar</span> · <code>lampson --web</code> abre esta web en ese proyecto <span class="copy" data-copy="lampson --web" role="button" tabindex="0">copiar</span></p>
38
46
  </div>
39
47
  </div>
40
48
  </main>
41
49
  <script src="/js/panel.js"></script>
50
+ <script src="/js/navtabs.js"></script>
42
51
  <script src="/js/hub.js"></script>
43
52
  <script src="/js/workspaces.js"></script>
44
53
  <script src="/vendor/qrcode.js"></script>
package/public/index.html CHANGED
@@ -22,13 +22,14 @@
22
22
  <link rel="stylesheet" href="/vendor/xterm.css">
23
23
  <script src="/vendor/xterm.js"></script>
24
24
  <script src="/vendor/xterm-addon-fit.js"></script>
25
+ <script src="/vendor/xterm-addon-webgl.js"></script>
25
26
  <script src="/vendor/highlight.min.js"></script>
26
27
  <script>(function(){try{var t=localStorage.getItem('lampson.theme');if(t!=='light'&&t!=='dark'){t='dark';}document.documentElement.setAttribute('data-theme',t);}catch(e){}})();</script>
27
28
  </head>
28
29
  <body>
29
30
  <header>
30
31
  <div class="hrow">
31
- <span class="brand">lampson<span class="proj" id="proj">…</span></span>
32
+ <span class="brand"><a class="home" id="home">lampson</a><span class="proj" id="proj">…</span></span>
32
33
  <span class="spacer"></span>
33
34
  <button class="hbtn upd" id="update" style="display:none"></button>
34
35
  <button class="hbtn" id="term" title="terminal real (shell en el workspace): lo abre, lo trae de vuelta si está minimizado y lo esconde si está a la vista — verde = shell abierta">&gt;_ terminal</button>
@@ -49,7 +50,7 @@
49
50
  </header>
50
51
  <aside>
51
52
  <button class="fold" title="plegar este panel"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M9 4v16"/></svg></button>
52
- <div class="rail"><button title="desplegar el panel"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M9 4v16"/></svg></button></div>
53
+ <div class="rail"><button title="sesiones, procesos, agentes, memoria, MCP, tareas y más"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M9 4v16"/></svg></button></div>
53
54
  <section class="sec open" data-sec="sessions">
54
55
  <h2 title="las últimas conversaciones de este workspace; «ver todas» abre el buscador"><span class="caret">▾</span>Sesiones<span class="cnt" id="sessCount"></span><button class="h2act" id="sessAll" title="ver todas y buscar">⌕</button></h2>
55
56
  <div class="body" id="sessions"></div>
package/public/js/app.js CHANGED
@@ -2,8 +2,8 @@
2
2
  async function loadCfg() {
3
3
  try { cfg = await (await fetch(BASE + '/api/config')).json(); } catch (e) { cfg = {}; }
4
4
  const ws = cfg.workspace || '';
5
- $('#proj').textContent = ws.split(/[\\/]/).filter(Boolean).pop() || 'workspace'; $('#proj').title = ws;
6
- $('#hpath').textContent = ws; $('#hpath').title = ws;
5
+ $('#proj').textContent = ws.split(/[\\/]/).filter(Boolean).pop() || 'workspace'; $('#proj').title = shortPath(ws);
6
+ $('#hpath').textContent = shortPath(ws); $('#hpath').title = shortPath(ws);
7
7
  $('#perm').value = localStorage.getItem('lampson.perm') || cfg.permission || 'ask'; $('#perm').onchange = () => localStorage.setItem('lampson.perm', $('#perm').value);
8
8
  paintModel();
9
9
  if (cfg.configured === false) openSetup(true);
@@ -10,7 +10,7 @@ async function loadApprovals() {
10
10
  if (!list.length) { box.innerHTML = '<div class="p none" style="cursor:default">ninguna pendiente</div>'; }
11
11
  for (const a of list) {
12
12
  const d = document.createElement('div'); d.className = 'p appr'; const src = a.source === 'chat' ? 'chat' : ('⏰ ' + a.source.replace(/^schedule:?/, ''));
13
- d.innerHTML = `<span class="st ${a.status === 'pending' ? 'busy' : ''}"></span><span class="nm">${esc(src)}</span><span class="cm">${a.status === 'pending' ? 'vence ' + esc(fmtWhen(a.expires_at)) : esc(a.status)}</span><span class="msg">${esc(a.message)}</span><span class="why">${esc(a.why)}</span>`
13
+ d.innerHTML = `<span class="st ${a.status === 'pending' ? 'busy' : ''}"></span><span class="nm">${esc(src)}</span><span class="cm">${a.status === 'pending' ? 'vence ' + esc(fmtWhen(a.expires_at)) : esc(a.status)}</span><span class="msg">${a.preview && a.preview.count ? esc(`${a.preview.branch} → ${a.preview.into} · ${a.preview.count} commit${a.preview.count === 1 ? '' : 's'} · ${a.preview.files.length} archivo${a.preview.files.length === 1 ? '' : 's'}${a.preview.conflicts ? ' · choca' : ''}\n`) : ''}${esc(a.message)}</span><span class="why">${esc(a.why)}</span>`
14
14
  + (a.status === 'pending' ? `<span class="btns"><button class="primary" data-ok="1">Permitir</button><button data-ok="0">Denegar</button></span>` : '');
15
15
  d.querySelectorAll('button').forEach(b => b.onclick = async () => { d.querySelectorAll('button').forEach(x => x.disabled = true); await api(BASE + '/api/approve', { id: a.id, decision: b.dataset.ok === '1' }); setTimeout(loadApprovals, 600); });
16
16
  box.appendChild(d);
package/public/js/core.js CHANGED
@@ -7,6 +7,9 @@ const log = $('#log');
7
7
  let session = new URLSearchParams(location.search).get('session') || localStorage.getItem('lampson.session') || '';
8
8
  let busy = false; let cfg = {};
9
9
 
10
+ // la carpeta del usuario se muestra como ~ (igual que en el inicio): el nombre de usuario no aparece al compartir
11
+ // pantalla o grabar un video, y la ruta sigue siendo inequívoca
12
+ function shortPath(p) { return String(p || '').replace(/^[a-z]:[\\/]users[\\/][^\\/]+/i, '~').replace(/^\/(home|Users)\/[^/]+/, '~'); }
10
13
  function esc(s) { return String(s ?? '').replace(/[&<>]/g, c => ({'&':'&amp;','<':'&lt;','>':'&gt;'}[c])); }
11
14
  function md(src) { // Markdown mínimo: code fences, inline code, bold, headers, listas, párrafos
12
15
  const blocks = []; src = String(src ?? '').replace(/```(\w*)\n([\s\S]*?)```/g, (m, l, c) => { blocks.push('<pre><code class="hljs">' + (typeof hlCode === 'function' ? hlCode(c, l) : esc(c)) + '</code></pre>'); return '\uE000' + (blocks.length - 1) + '\uE001'; }); // marcador = índice entre U+E000/U+E001, NUNCA dígitos a secas (se perdieron dos veces al reescribir el archivo y todo número salía undefined)
@@ -67,7 +70,6 @@ function empty() {
67
70
  const name = (cfg.workspace || '').split(/[\\/]/).filter(Boolean).pop() || 'workspace';
68
71
  log.classList.add('hero');
69
72
  log.innerHTML = `<div class="empty">
70
- <p class="eyebrow">workspace</p>
71
73
  <h1>${esc(name)}</h1>
72
74
  <p class="lead">Un agente con herramientas acotadas a este proyecto. Vos pedís; él lee, busca, edita y corre comandos — y cada paso queda a la vista.</p>
73
75
  <div class="grid">
@@ -88,6 +90,7 @@ function empty() {
88
90
  <div class="card"><h3>Cómo lo ve el modelo</h3>
89
91
  <p>Cada tool y su resultado — errores y rechazos incluidos — queda en el historial y se le reenvía en cada turno.</p>
90
92
  <p>Hacé clic en un archivo del panel de archivos para verlo. Un mensaje que empieza con <code>!</code> lo corrés vos, sin el modelo.</p></div>
91
- </div></div>`;
93
+ </div><p class="plughint" id="plugHint" hidden></p></div>`;
92
94
  log.querySelectorAll('.try').forEach(el => el.onclick = () => { $('#in').value = el.textContent; $('#in').focus(); });
95
+ if (typeof paintPlugHint === 'function') paintPlugHint();
93
96
  }
@@ -0,0 +1,187 @@
1
+ // flow.js — un lienzo de nodos al estilo React Flow, sin dependencias (lo usa la pantalla de equipos, js/teams.js).
2
+ // Fondo de puntos; arrastrar el fondo lo desplaza, la rueda hace zoom; los nodos se arrastran y su posición se guarda
3
+ // en el navegador (opts.storeKey). Editando, cada nodo tiene un punto abajo: arrastrado hasta otro nodo, ese nodo pasa
4
+ // a reportarle (la jerarquía); soltado en el vacío, crea uno nuevo ahí que le reporta. Una conexión se elige con un
5
+ // clic y se quita con su ✕ o con Supr.
6
+ //
7
+ // const f = Flow.create(elemento)
8
+ // f.render({ nodes: [{id, title, desc, meta, lead, loose, avatar, working, missing, at}], edges: [{kind:'reports'|'talk', from, to, hot}],
9
+ // editable, selected, storeKey, onSelect(id|null), onConnect(from, to), onConnectEmpty(from, pos), onDeleteEdge(edge) })
10
+ // f.fit() · f.center(id) · f.freeSpot() → una posición libre para un nodo nuevo
11
+ const Flow = (() => {
12
+ const NW = 232, NH = 118, GAPX = 44, ROWH = 170;
13
+ const load = (k) => { try { return JSON.parse(localStorage.getItem(k) || '{}'); } catch (e) { return {}; } };
14
+ const save = (k, v) => { try { localStorage.setItem(k, JSON.stringify(v)); } catch (e) {} };
15
+ const escH = (s) => String(s ?? '').replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
16
+
17
+ // orden automático: niveles por jefe (raíces arriba), cada nivel centrado
18
+ function autoLayout(nodes, edges) {
19
+ const boss = {}; edges.filter((e) => e.kind === 'reports').forEach((e) => (boss[e.to] = e.from));
20
+ const level = {};
21
+ const lv = (id, seen = new Set()) => { if (level[id] !== undefined) return level[id]; const b = boss[id]; if (!b || seen.has(id) || !nodes.some((n) => n.id === b)) return (level[id] = 0); seen.add(id); return (level[id] = lv(b, seen) + 1); };
22
+ nodes.forEach((n) => lv(n.id));
23
+ const rows = {}; nodes.forEach((n) => (rows[level[n.id]] = rows[level[n.id]] || []).push(n.id));
24
+ const pos = {};
25
+ Object.entries(rows).forEach(([l, ids]) => ids.forEach((id, i) => (pos[id] = { x: (i - (ids.length - 1) / 2) * (NW + GAPX) - NW / 2, y: Number(l) * ROWH })));
26
+ return pos;
27
+ }
28
+
29
+ function create(root) {
30
+ root.classList.add('flow');
31
+ root.innerHTML = `<div class="fl-pane"><svg class="fl-edges"><g class="fl-e"></g><g class="fl-fx"></g><path class="fl-ghost" d=""/></svg><div class="fl-nodes"></div><svg class="fl-edges fl-top"><g class="fl-fx2"></g></svg><div class="fl-tools"></div></div>
32
+ <div class="fl-ctrl"><button type="button" data-z="in" title="acercar">+</button><button type="button" data-z="out" title="alejar">−</button><button type="button" data-z="fit" title="encuadrar todo">⤢</button><button type="button" data-z="tidy" title="ordenar automáticamente">ordenar</button></div>`;
33
+ const pane = root.querySelector('.fl-pane'), eg = root.querySelector('.fl-e'), fx = root.querySelector('.fl-fx'), fxTop = root.querySelector('.fl-fx2'), ghost = root.querySelector('.fl-ghost'), nodesEl = root.querySelector('.fl-nodes'), tools = root.querySelector('.fl-tools');
34
+ const st = { x: 0, y: 0, k: 1, pos: {}, opts: null, fitted: false, selEdge: null, key: '' };
35
+ const apply = () => { pane.style.transform = `translate(${st.x}px,${st.y}px) scale(${st.k})`; root.style.backgroundPosition = `${st.x}px ${st.y}px`; root.style.backgroundSize = `${20 * st.k}px ${20 * st.k}px`; };
36
+ const toPane = (cx, cy) => { const r = root.getBoundingClientRect(); return { x: (cx - r.left - st.x) / st.k, y: (cy - r.top - st.y) / st.k }; };
37
+ function zoomAt(f, cx, cy) {
38
+ const r = root.getBoundingClientRect(); const px = cx ?? r.left + r.width / 2, py = cy ?? r.top + r.height / 2;
39
+ const k = Math.min(1.6, Math.max(0.35, st.k * f)), p = toPane(px, py);
40
+ st.x = px - r.left - p.x * k; st.y = py - r.top - p.y * k; st.k = k; apply();
41
+ }
42
+ // encuadrar: todo a la vista, sin agrandar de más un equipo chico (un asiento solo no ocupa media pantalla)
43
+ function fit() {
44
+ const ids = (st.opts?.nodes || []).map((n) => n.id).filter((i) => st.pos[i]); if (!ids.length) return;
45
+ const xs = ids.map((i) => st.pos[i].x), ys = ids.map((i) => st.pos[i].y);
46
+ const minX = Math.min(...xs), maxX = Math.max(...xs) + NW, minY = Math.min(...ys), maxY = Math.max(...ys) + NH;
47
+ const r = root.getBoundingClientRect(), pad = 80;
48
+ const k = Math.min(1, Math.max(0.35, Math.min((r.width - pad * 2) / (maxX - minX), (r.height - pad * 2) / (maxY - minY))));
49
+ st.k = k; st.x = r.width / 2 - ((minX + maxX) / 2) * k; st.y = r.height / 2 - ((minY + maxY) / 2) * k; apply();
50
+ }
51
+ const anchor = (id, side) => { const p = st.pos[id]; return side === 'top' ? { x: p.x + NW / 2, y: p.y } : side === 'bottom' ? { x: p.x + NW / 2, y: p.y + NH } : side === 'left' ? { x: p.x, y: p.y + NH / 2 } : { x: p.x + NW, y: p.y + NH / 2 }; };
52
+ function edgePath(e) {
53
+ if (e.kind === 'reports') {
54
+ const a = anchor(e.from, 'bottom'), b = anchor(e.to, 'top'), dy = Math.max(40, Math.abs(b.y - a.y) / 2);
55
+ return { d: `M${a.x},${a.y} C${a.x},${a.y + dy} ${b.x},${b.y - dy} ${b.x},${b.y}`, mx: (a.x + b.x) / 2, my: (a.y + b.y) / 2 };
56
+ }
57
+ const A = st.pos[e.from], B = st.pos[e.to];
58
+ if (Math.abs(A.x - B.x) >= NW * 0.75) {
59
+ const left = A.x < B.x, a = anchor(e.from, left ? 'right' : 'left'), b = anchor(e.to, left ? 'left' : 'right'), dx = Math.max(30, Math.abs(b.x - a.x) / 2) * (left ? 1 : -1);
60
+ return { d: `M${a.x},${a.y} C${a.x + dx},${a.y} ${b.x - dx},${b.y} ${b.x},${b.y}`, mx: (a.x + b.x) / 2, my: (a.y + b.y) / 2 };
61
+ }
62
+ const a = anchor(e.from, 'right'), b = anchor(e.to, 'right'), out = Math.max(a.x, b.x) + 50 + Math.abs(a.y - b.y) * 0.1;
63
+ return { d: `M${a.x},${a.y} C${out},${a.y} ${out},${b.y} ${b.x},${b.y}`, mx: out - 12, my: (a.y + b.y) / 2 };
64
+ }
65
+ const ekey = (e) => e.kind + ':' + e.from + '>' + e.to;
66
+ // una curva cúbica «M a C c1 c2 b» al revés (para que la partícula salga del que manda)
67
+ const reversePath = (d) => { const n = d.match(/-?[\d.]+/g).map(Number); return `M${n[6]},${n[7]} C${n[4]},${n[5]} ${n[2]},${n[3]} ${n[0]},${n[1]}`; };
68
+ function drawEdges() {
69
+ const o = st.opts; if (!o) return;
70
+ eg.innerHTML = o.edges.filter((e) => st.pos[e.from] && st.pos[e.to]).map((e) => { const p = edgePath(e), k = ekey(e);
71
+ return `<g class="fl-edge ${e.kind}${e.hot ? ' hot' : ''}${st.selEdge === k ? ' sel' : ''}" data-k="${escH(k)}"><path class="hit" d="${p.d}"/><path class="line" d="${p.d}"/></g>`; }).join('');
72
+ const sel = o.editable && o.edges.find((e) => ekey(e) === st.selEdge);
73
+ tools.innerHTML = sel ? (() => { const p = edgePath(sel); return `<button type="button" class="fl-del" style="left:${p.mx}px;top:${p.my}px" title="quitar la conexión (Supr)">✕</button>`; })() : '';
74
+ const del = tools.querySelector('.fl-del'); if (del) del.onclick = (ev) => { ev.stopPropagation(); removeSel(); };
75
+ if (o.editable) eg.querySelectorAll('.fl-edge').forEach((g) => (g.onpointerdown = (ev) => { ev.stopPropagation(); st.selEdge = g.dataset.k; drawEdges(); }));
76
+ }
77
+ function removeSel() { const o = st.opts; const e = o && o.edges.find((x) => ekey(x) === st.selEdge); st.selEdge = null; if (e && o.onDeleteEdge) o.onDeleteEdge(e); else drawEdges(); }
78
+ function placeNodes() { nodesEl.querySelectorAll('.fl-node').forEach((el) => { const p = st.pos[el.dataset.id]; el.style.transform = `translate(${p.x}px,${p.y}px)`; }); }
79
+
80
+ // fondo: desplazar; un clic suelto deselecciona
81
+ root.addEventListener('pointerdown', (ev) => {
82
+ if (ev.target !== root && !ev.target.closest('.fl-pane')) return;
83
+ if (ev.target.closest('.fl-node, .fl-del, .fl-edge')) return;
84
+ const sx = ev.clientX - st.x, sy = ev.clientY - st.y, x0 = ev.clientX, y0 = ev.clientY; root.setPointerCapture(ev.pointerId); root.classList.add('panning');
85
+ if (st.selEdge) { st.selEdge = null; drawEdges(); }
86
+ const mv = (e) => { st.x = e.clientX - sx; st.y = e.clientY - sy; apply(); };
87
+ const up = (e) => { root.classList.remove('panning'); root.removeEventListener('pointermove', mv); root.removeEventListener('pointerup', up);
88
+ if (Math.hypot(e.clientX - x0, e.clientY - y0) < 4 && st.opts.onSelect) st.opts.onSelect(null); };
89
+ root.addEventListener('pointermove', mv); root.addEventListener('pointerup', up);
90
+ });
91
+ root.addEventListener('wheel', (ev) => { if (!ev.target.closest('.fl-pane') && ev.target !== root) return; ev.preventDefault(); zoomAt(ev.deltaY < 0 ? 1.1 : 1 / 1.1, ev.clientX, ev.clientY); }, { passive: false });
92
+ root.querySelector('.fl-ctrl').onclick = (ev) => { const z = ev.target.dataset.z; if (z === 'in') zoomAt(1.2); if (z === 'out') zoomAt(1 / 1.2); if (z === 'fit') fit();
93
+ if (z === 'tidy') { st.pos = autoLayout(st.opts.nodes, st.opts.edges); if (st.key) save(st.key, st.pos); placeNodes(); drawEdges(); fit(); } };
94
+ root.tabIndex = 0;
95
+ root.addEventListener('keydown', (ev) => { if ((ev.key === 'Delete' || ev.key === 'Backspace') && st.selEdge && st.opts?.editable && !ev.target.closest('input, textarea, select')) { ev.preventDefault(); removeSel(); } });
96
+
97
+ function bindNode(el) {
98
+ const id = el.dataset.id;
99
+ el.addEventListener('pointerdown', (ev) => {
100
+ const h = ev.target.closest('.fl-h');
101
+ ev.stopPropagation();
102
+ if (h) { connect(ev, id); return; }
103
+ // arrastrar el nodo (un clic sin moverse = elegirlo)
104
+ const start = toPane(ev.clientX, ev.clientY), p0 = { ...st.pos[id] }; let moved = false;
105
+ el.setPointerCapture(ev.pointerId);
106
+ const mv = (e) => { const p = toPane(e.clientX, e.clientY); if (!moved && Math.hypot(p.x - start.x, p.y - start.y) < 4) return; moved = true; el.classList.add('dragging');
107
+ st.pos[id] = { x: p0.x + p.x - start.x, y: p0.y + p.y - start.y }; el.style.transform = `translate(${st.pos[id].x}px,${st.pos[id].y}px)`; drawEdges(); };
108
+ const up = () => { el.removeEventListener('pointermove', mv); el.removeEventListener('pointerup', up); el.classList.remove('dragging');
109
+ if (moved) { if (st.key) save(st.key, st.pos); } else if (st.opts.onSelect) st.opts.onSelect(id); };
110
+ el.addEventListener('pointermove', mv); el.addEventListener('pointerup', up);
111
+ });
112
+ }
113
+ // arrastrar desde el punto de abajo: hasta otro nodo (le reporta) o al vacío (uno nuevo ahí)
114
+ function connect(ev, from) {
115
+ const a = anchor(from, 'bottom'); root.classList.add('connecting');
116
+ const mv = (e) => { const p = toPane(e.clientX, e.clientY); const dy = Math.max(30, Math.abs(p.y - a.y) / 2);
117
+ ghost.setAttribute('d', `M${a.x},${a.y} C${a.x},${a.y + dy} ${p.x},${p.y - dy} ${p.x},${p.y}`);
118
+ const over = document.elementFromPoint(e.clientX, e.clientY)?.closest('.fl-node');
119
+ nodesEl.querySelectorAll('.fl-node').forEach((n) => n.classList.toggle('target', n.dataset.id !== from && n === over)); };
120
+ const up = (e) => { window.removeEventListener('pointermove', mv); window.removeEventListener('pointerup', up); ghost.setAttribute('d', ''); root.classList.remove('connecting');
121
+ nodesEl.querySelectorAll('.target').forEach((n) => n.classList.remove('target'));
122
+ const t = document.elementFromPoint(e.clientX, e.clientY)?.closest('.fl-node');
123
+ if (t && t.dataset.id !== from) { st.opts.onConnect && st.opts.onConnect(from, t.dataset.id); return; }
124
+ const p = toPane(e.clientX, e.clientY);
125
+ if (!t && Math.hypot(p.x - a.x, p.y - a.y) > 40 && e.target.closest && root.contains(e.target) && st.opts.onConnectEmpty) st.opts.onConnectEmpty(from, { x: p.x - NW / 2, y: p.y }); };
126
+ window.addEventListener('pointermove', mv); window.addEventListener('pointerup', up);
127
+ }
128
+ // un lugar libre para un nodo nuevo: debajo de todo, centrado en lo visible
129
+ function freeSpot(under) {
130
+ if (under && st.pos[under]) { const kids = Object.values(st.pos).filter((p) => p.y > st.pos[under].y + NH && Math.abs(p.y - (st.pos[under].y + ROWH)) < NH);
131
+ const x = kids.length ? Math.max(...kids.map((p) => p.x)) + NW + GAPX : st.pos[under].x; return { x, y: st.pos[under].y + ROWH }; }
132
+ // suelto: desde el centro de lo visible, el primer lugar que no pise otra tarjeta (en espiral)
133
+ const r = root.getBoundingClientRect(), c = toPane(r.left + r.width / 2 - NW / 2 * st.k, r.top + r.height / 2 - NH / 2 * st.k);
134
+ const busy = (p) => Object.values(st.pos).some((q) => Math.abs(q.x - p.x) < NW + 16 && Math.abs(q.y - p.y) < NH + 16);
135
+ for (let ring = 0; ring < 8; ring++) for (let i = -ring; i <= ring; i++) for (const p of [{ x: c.x + i * (NW + GAPX), y: c.y + ring * (NH + 30) }, { x: c.x + ring * (NW + GAPX), y: c.y + i * (NH + 30) }, { x: c.x - ring * (NW + GAPX), y: c.y + i * (NH + 30) }]) if (!busy(p)) return p;
136
+ return c;
137
+ }
138
+
139
+ return {
140
+ render(o) {
141
+ const keyChanged = o.storeKey !== st.key; st.opts = o;
142
+ if (keyChanged) { st.key = o.storeKey || ''; st.pos = st.key ? load(st.key) : {}; st.fitted = false; st.selEdge = null; }
143
+ const auto = autoLayout(o.nodes, o.edges), ids = new Set(o.nodes.map((n) => n.id));
144
+ Object.keys(st.pos).forEach((i) => { if (!ids.has(i)) delete st.pos[i]; });
145
+ o.nodes.forEach((n) => { if (!st.pos[n.id]) st.pos[n.id] = n.at || auto[n.id]; });
146
+ if (st.key) save(st.key, st.pos);
147
+ root.classList.toggle('editable', !!o.editable);
148
+ nodesEl.innerHTML = o.nodes.map((n) => `<div class="fl-node${n.working ? ' working' : ''}${n.missing ? ' missing' : ''}${n.lead ? ' lead' : ''}${n.loose ? ' loose' : ''}${n.cls ? ' ' + escH(n.cls) : ''}${o.selected === n.id ? ' sel' : ''}" data-id="${escH(n.id)}">
149
+ <div class="fl-top"><span class="fl-av">${escH(n.avatar || n.title.slice(0, 1))}</span><b>${escH(n.title)}</b>${n.lead ? '<span class="fl-lead">líder</span>' : ''}<span class="fl-pip"></span></div>
150
+ ${n.html !== undefined ? n.html : `<p class="fl-desc">${escH(n.desc || '')}</p><span class="fl-meta">${escH(n.meta || '')}</span>`}
151
+ ${o.editable ? '<span class="fl-h top" aria-hidden="true"></span><span class="fl-h bottom" title="arrastrá hasta otro asiento: te reporta · soltalo en el vacío: un asiento nuevo"></span>' : ''}</div>`).join('');
152
+ nodesEl.querySelectorAll('.fl-node').forEach(bindNode);
153
+ placeNodes(); drawEdges();
154
+ if (!st.fitted) { st.fitted = true; requestAnimationFrame(fit); }
155
+ apply();
156
+ },
157
+ fit,
158
+ freeSpot,
159
+ // algo que viaja de un nodo a otro (la vista en vivo de un objetivo): por la línea que los une, si la hay; si no,
160
+ // por una curva directa. La línea se enciende del color de quien manda y corre como un flujo mientras el sobre
161
+ // (glyph: SVG centrado en 0,0) la recorre; al llegar, una onda en el destino. Vive en su propia capa (fl-fx),
162
+ // que el repintado no borra. opts: {color, glyph, dur (s)}
163
+ particle(from, to, opts = {}) {
164
+ if (!st.pos[from] || !st.pos[to] || matchMedia('(prefers-reduced-motion: reduce)').matches) return;
165
+ const e = (st.opts.edges || []).find((x) => (x.from === from && x.to === to) || (x.from === to && x.to === from));
166
+ let d;
167
+ if (e) { d = edgePath(e).d; if (e.from !== from) d = reversePath(d); }
168
+ else { const a = anchor(from, 'bottom'), b = anchor(to, 'top'); d = `M${a.x},${a.y} C${a.x},${(a.y + b.y) / 2} ${b.x},${(a.y + b.y) / 2} ${b.x},${b.y}`; }
169
+ const dur = opts.dur || 1.6, end = d.match(/-?[\d.]+/g).map(Number).slice(-2);
170
+ // la línea encendida va debajo de las tarjetas; el sobre y la onda, encima (si no, la tarjeta lo tapa a la mitad)
171
+ const ns = 'http://www.w3.org/2000/svg', g = document.createElementNS(ns, 'g'), top = document.createElementNS(ns, 'g');
172
+ [g, top].forEach((x) => { x.setAttribute('class', 'fl-particle'); if (opts.color) x.style.setProperty('--flow', opts.color); x.style.setProperty('--dur', dur + 's'); });
173
+ g.innerHTML = `<path class="glow" d="${d}"/><path class="trail" d="${d}"/>`;
174
+ top.innerHTML = `<circle class="ripple" cx="${end[0]}" cy="${end[1]}" r="4"/>
175
+ <g class="glyph">${opts.glyph || '<circle r="6"/>'}<animateMotion dur="${dur}s" fill="freeze" path="${d}" calcMode="spline" keyTimes="0;1" keySplines="0.45 0 0.25 1"/></g>`;
176
+ fx.appendChild(g); fxTop.appendChild(top); setTimeout(() => { g.remove(); top.remove(); }, dur * 1000 + 1200);
177
+ },
178
+ // al unir: si el que pasa a reportar quedó arriba (o a la par) de su jefe, va debajo de él — la línea no da vueltas
179
+ placeUnder(child, boss) {
180
+ const c = st.pos[child], b = st.pos[boss]; if (!c || !b || c.y >= b.y + NH + 20) return false;
181
+ delete st.pos[child]; st.pos[child] = freeSpot(boss); if (st.key) save(st.key, st.pos); return true;
182
+ },
183
+ center(id) { const p = st.pos[id]; if (!p) return; const r = root.getBoundingClientRect(); st.x = r.width / 2 - (p.x + NW / 2) * st.k; st.y = r.height / 2 - (p.y + NH / 2) * st.k; apply(); },
184
+ };
185
+ }
186
+ return { create };
187
+ })();