agents-city 0.5.9 → 0.5.11
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/.claude-plugin/marketplace.json +1 -1
- package/README.es.md +44 -13
- package/README.md +43 -13
- package/bin/agents-city.js +181 -56
- package/bin/hall +83 -3
- package/bin/hall.html +223 -159
- package/bin/serve.py +138 -30
- package/bin/setup.py +9 -7
- package/bin/test +6 -3
- package/bin/test-actualiza.py +16 -6
- package/bin/test-alcance.py +9 -7
- package/bin/test-arnes.py +7 -5
- package/bin/test-atajos.py +141 -9
- package/bin/test-broker.py +4 -4
- package/bin/test-cage.py +36 -8
- package/bin/test-card.py +11 -10
- package/bin/test-cities.py +38 -21
- package/bin/test-contracts.py +445 -150
- package/bin/test-doctor.py +5 -5
- package/bin/test-domains.py +4 -4
- package/bin/test-e2e.py +2 -2
- package/bin/test-exit.py +1 -1
- package/bin/test-hooks.py +227 -0
- package/bin/test-launch.py +110 -6
- package/bin/test-live-feed.py +3 -2
- package/bin/test-multiplexor.py +262 -0
- package/bin/test-seat.py +322 -276
- package/bin/test-security.py +18 -10
- package/bin/test-serve.py +87 -5
- package/bin/testlib.py +11 -0
- package/bus/scripts/test-hub.ts +34 -16
- package/city/scripts/history.py +1 -1
- package/city/scripts/seed.py +2 -2
- package/city/web/dist/index.html +76 -60
- package/city/web/dist-hall/hall.js +311 -291
- package/city/web/index.html +76 -60
- package/city/web/src/bienvenida.ts +18 -1
- package/city/web/src/desconectado.ts +103 -0
- package/city/web/src/es.ts +23 -0
- package/city/web/src/hall.ts +67 -16
- package/docs/security.md +1 -1
- package/package.json +3 -2
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/channel/adapter.js +64 -34
- package/plugin/channel/multiplexor.ts +93 -0
- package/plugin/channel/runtime/multiplexores.json +206 -0
- package/plugin/channel/terminal-delivery.ts +14 -33
- package/plugin/hooks/hook.py +557 -0
- package/plugin/hooks/hooks.json +12 -12
- package/plugin/scripts/apaga.py +30 -10
- package/plugin/scripts/atajos.py +104 -8
- package/plugin/scripts/cage.py +1 -1
- package/plugin/scripts/city-env.sh +12 -86
- package/plugin/scripts/city-runtime.sh +4 -86
- package/plugin/scripts/city-session.sh +8 -805
- package/plugin/scripts/city_env.py +168 -6
- package/plugin/scripts/conciencia.py +158 -0
- package/plugin/scripts/doctor.py +11 -3
- package/plugin/scripts/launch.py +238 -34
- package/plugin/scripts/multiplexor.py +354 -0
- package/plugin/scripts/mux_herdr.py +275 -0
- package/plugin/scripts/report.py +1 -1
- package/plugin/scripts/roles.py +1 -1
- package/plugin/scripts/runtime_processes.py +25 -0
- package/plugin/scripts/runtimes.py +120 -0
- package/plugin/scripts/seat.py +40 -93
- package/plugin/scripts/sesion.py +870 -0
- package/plugin/scripts/tokens.py +3 -3
- package/plugin/scripts/ui.py +14 -3
- package/plugin/scripts/workspace.py +122 -16
- package/plugin/hooks/activity.sh +0 -6
- package/plugin/hooks/ask-the-house.sh +0 -30
- package/plugin/hooks/digging.sh +0 -68
- package/plugin/hooks/growth.sh +0 -42
- package/plugin/hooks/notice-on-pr.sh +0 -35
- package/plugin/hooks/notice-on-stop.sh +0 -86
- package/plugin/hooks/notice-pending.sh +0 -58
- package/plugin/hooks/solo-en-ciudad.sh +0 -23
- package/plugin/hooks/tokens.sh +0 -47
- package/plugin/hooks/who-does-this-concern.sh +0 -22
package/README.es.md
CHANGED
|
@@ -165,10 +165,9 @@ agents-city --version
|
|
|
165
165
|
| Node.js 22.13 o posterior | paquete npm, bus WebSocket, recepción local y frontends |
|
|
166
166
|
| npm | instalación y empaquetado |
|
|
167
167
|
| Python 3 | Hall, onboarding, ciudades, mapas y utilidades |
|
|
168
|
-
|
|
|
169
|
-
|
|
|
170
|
-
|
|
|
171
|
-
| WSL | necesario en Windows porque Windows no incluye bash/tmux nativos |
|
|
168
|
+
| un servidor de ventanas | una ventana por asiento/agente: **tmux** en macOS y Linux, **herdr** en Windows; `seat` intenta instalarlo si falta |
|
|
169
|
+
| macOS, Linux o Windows | los tres de forma nativa. Cuatro comandos siguen necesitando shell — `city`, `demo`, `benchmark`, `test` — y lo dicen por su nombre en Windows |
|
|
170
|
+
| bash | sólo para esos cuatro |
|
|
172
171
|
|
|
173
172
|
Cada motor necesita además su propio CLI instalado y autenticado. Agents City no
|
|
174
173
|
incluye ni suplanta las cuentas de Claude, Codex, OpenCode o Kimi.
|
|
@@ -340,15 +339,18 @@ agents-city shortcut --remove # quitarlo otra vez
|
|
|
340
339
|
agents-city shortcut --to ~/bin # en otro sitio que no sea el escritorio
|
|
341
340
|
```
|
|
342
341
|
|
|
343
|
-
**En Windows**
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
adivinarlo a partir del nombre de usuario
|
|
347
|
-
a un perfil de dominio no está bajo `C:\Users\<nombre>\Desktop
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
342
|
+
**En Windows** es un `.lnk` de verdad, construido con la propia PowerShell de
|
|
343
|
+
Windows para que pueda llevar un `.ico`, y ejecuta el mismo comando de la puerta
|
|
344
|
+
principal que cualquier otro escritorio. El escritorio se le pregunta a Windows
|
|
345
|
+
en vez de adivinarlo a partir del nombre de usuario: uno redirigido a OneDrive o
|
|
346
|
+
a un perfil de dominio no está bajo `C:\Users\<nombre>\Desktop`. Si no hay
|
|
347
|
+
PowerShell se escribe un `.cmd` que también se abre con doble clic: la misma
|
|
348
|
+
puerta, con icono genérico.
|
|
349
|
+
|
|
350
|
+
**Dentro de WSL** el acceso directo sigue cruzando de vuelta: un `~/Desktop` de
|
|
351
|
+
ahí es el escritorio del home de Linux, que nadie mira, así que el escritorio de
|
|
352
|
+
Windows recibe un `.lnk` que arranca `wsl.exe` con el mismo comando en una shell
|
|
353
|
+
de login.
|
|
352
354
|
|
|
353
355
|
### Qué se crea
|
|
354
356
|
|
|
@@ -619,6 +621,35 @@ agents-city setup --no-browser
|
|
|
619
621
|
| `--tui` | usa onboarding de terminal y abre la sesión |
|
|
620
622
|
| `--no-browser` | mantiene el Hall en terminal e imprime su URL |
|
|
621
623
|
|
|
624
|
+
### `agents-city hall`
|
|
625
|
+
|
|
626
|
+
El ayuntamiento corre **desacoplado**, como el bus de la ciudad y todo lo demás
|
|
627
|
+
que vive mucho en este producto. Cerrar la ventana desde la que lo lanzaste deja
|
|
628
|
+
de ser una forma de romper la página que alguien está mirando, y `agents-city
|
|
629
|
+
hall` dos veces te devuelve la dirección que ya está sirviendo en vez de abrir
|
|
630
|
+
un segundo. Se para con `agents-city exit`; `--foreground` sirve en la ventana y
|
|
631
|
+
muere con ella.
|
|
632
|
+
|
|
633
|
+
Su dirección sobrevive a un reinicio. El token se acuñaba por proceso, y eso
|
|
634
|
+
hacía desechable cada pestaña — cierras el ayuntamiento, lo vuelves a abrir, y la
|
|
635
|
+
página que alguien tenía queda rechazada para siempre, sin más vuelta que leer
|
|
636
|
+
una URL nueva en una terminal. Se guarda en `~/.agents-city/.runtime/hall.pase`,
|
|
637
|
+
modo 0600, en la misma clase que el token del bus que este producto ya guarda.
|
|
638
|
+
|
|
639
|
+
Si la ciudad está corriendo se dice en **todas** las pantallas, no en una
|
|
640
|
+
portada a la que quizá no vuelvas: abierta o no, cuántos agentes están conectados
|
|
641
|
+
de verdad y — sólo cuando falta — que esta ciudad corre sin ninguna de sus reglas.
|
|
642
|
+
Esa última luz hubo que ganársela: antes adivinaba si existía un directorio, y ese
|
|
643
|
+
directorio es la caché del *marketplace*, que aparece en cuanto alguien lo añade.
|
|
644
|
+
Así que una máquina sin el plugin enseñaba un «installed» en verde, y por eso su
|
|
645
|
+
dueño podía pasarse una tarde sin ver que no se estaba aplicando nada. Ahora se lo
|
|
646
|
+
pregunta a Claude.
|
|
647
|
+
|
|
648
|
+
Y cuando el ayuntamiento no contesta, la página lo dice con sus palabras: qué ha
|
|
649
|
+
pasado, que no se ha perdido nada, el comando que lo vuelve a abrir y un botón
|
|
650
|
+
que reintenta — más un reintento silencioso cada pocos segundos, para que una
|
|
651
|
+
pestaña abierta se recupere sola cuando el ayuntamiento vuelve.
|
|
652
|
+
|
|
622
653
|
### `agents-city seat`
|
|
623
654
|
|
|
624
655
|
Configura lo solicitado, garantiza tmux/plugin y abre o reanuda la sesión de la
|
package/README.md
CHANGED
|
@@ -163,10 +163,9 @@ agents-city --version
|
|
|
163
163
|
| Node.js 22.13 or later | npm package, WebSocket bus, local reception, and frontends |
|
|
164
164
|
| npm | installation and packaging |
|
|
165
165
|
| Python 3 | Hall, onboarding, cities, maps, and utilities |
|
|
166
|
-
|
|
|
167
|
-
|
|
|
168
|
-
|
|
|
169
|
-
| WSL | required on Windows because native Windows has no bash/tmux |
|
|
166
|
+
| a window server | one window per seat/agent: **tmux** on macOS and Linux, **herdr** on Windows; `seat` tries to install it when missing |
|
|
167
|
+
| macOS, Linux or Windows | all three natively. Four commands still need a shell — `city`, `demo`, `benchmark`, `test` — and say so by name on Windows |
|
|
168
|
+
| bash | only for those four |
|
|
170
169
|
| bubblewrap | optional, Linux only: it IS the cage there. Without it agents run uncaged — see [the cage](#the-cage-the-broker-and-the-audit-chain) |
|
|
171
170
|
|
|
172
171
|
Each runtime also needs its own installed and authenticated CLI. Agents City
|
|
@@ -336,14 +335,16 @@ agents-city shortcut --remove # take it off again
|
|
|
336
335
|
agents-city shortcut --to ~/bin # somewhere other than the desktop
|
|
337
336
|
```
|
|
338
337
|
|
|
339
|
-
**On Windows**
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
338
|
+
**On Windows** it is a real `.lnk`, built through Windows' own PowerShell so it
|
|
339
|
+
can carry an `.ico`, running the same front-door command as every other desktop.
|
|
340
|
+
The desktop is asked of Windows itself rather than guessed from a username — one
|
|
341
|
+
redirected to OneDrive or a domain profile is not under `C:\Users\<name>\Desktop`.
|
|
342
|
+
Where PowerShell is unavailable a double-clickable `.cmd` is written instead:
|
|
343
|
+
same door, plain icon.
|
|
344
|
+
|
|
345
|
+
**Inside WSL** the shortcut still crosses back: a `~/Desktop` there is the Linux
|
|
346
|
+
home's desktop, which nobody looks at, so the Windows desktop gets a `.lnk` that
|
|
347
|
+
launches `wsl.exe` running the same command in a login shell.
|
|
347
348
|
|
|
348
349
|
### What gets created
|
|
349
350
|
|
|
@@ -610,6 +611,34 @@ agents-city setup --no-browser
|
|
|
610
611
|
| `--tui` | use terminal onboarding and open the session |
|
|
611
612
|
| `--no-browser` | keep the Hall in the terminal and print its URL |
|
|
612
613
|
|
|
614
|
+
### `agents-city hall`
|
|
615
|
+
|
|
616
|
+
The town hall runs **detached**, like the city bus and every other long-lived
|
|
617
|
+
piece of this product. Closing the window that started it is not a way to break
|
|
618
|
+
the page somebody is looking at, and `agents-city hall` run twice hands back the
|
|
619
|
+
address that is already serving rather than starting a second one. Stop it with
|
|
620
|
+
`agents-city exit`; `--foreground` serves in the window and stops with it.
|
|
621
|
+
|
|
622
|
+
Its address survives a restart. The token used to be minted per process, which
|
|
623
|
+
made every tab disposable — close the hall, open it again, and the page somebody
|
|
624
|
+
had is permanently refused, with no way back except reading a new URL out of a
|
|
625
|
+
terminal. It is stored at `~/.agents-city/.runtime/hall.pase`, mode 0600, in the
|
|
626
|
+
same class as the bus token this product already keeps.
|
|
627
|
+
|
|
628
|
+
Whether the city is running is said on **every** screen, not on the front page
|
|
629
|
+
somebody may never return to: open or not, how many agents are actually
|
|
630
|
+
connected, and — only when it is missing — that this city is running with none of
|
|
631
|
+
its rules. That last light is the one that had to be earned: it used to be a
|
|
632
|
+
guess at whether a directory existed, and that directory is the *marketplace's*
|
|
633
|
+
cache, which appears the moment somebody adds the marketplace. So a machine with
|
|
634
|
+
no city plugin showed a green "installed", which is why its owner could spend an
|
|
635
|
+
afternoon unable to see that nothing was being enforced. It asks Claude now.
|
|
636
|
+
|
|
637
|
+
And when the hall is not answering, the page says so in its own words: what
|
|
638
|
+
happened, that nothing was lost, the command that opens it again, and a button
|
|
639
|
+
that retries — plus a quiet retry every few seconds, so a page left open
|
|
640
|
+
recovers by itself when the hall comes back.
|
|
641
|
+
|
|
613
642
|
### `agents-city seat`
|
|
614
643
|
|
|
615
644
|
Configures requested settings, ensures tmux/plugin, and opens or resumes the city
|
|
@@ -961,7 +990,8 @@ script pretending:
|
|
|
961
990
|
|---|---|---|
|
|
962
991
|
| macOS | `.app` bundle running the city in Terminal | `.icns`, built with the system's `iconutil` |
|
|
963
992
|
| Linux | `.desktop` entry, marked trusted where `gio` exists | `.png` under `XDG_DATA_HOME` |
|
|
964
|
-
| Windows
|
|
993
|
+
| Windows | `.lnk` on the desktop, running the front-door command | `.ico`, built by hand; a `.cmd` without PowerShell |
|
|
994
|
+
| Windows (inside WSL) | `.lnk` on the **Windows** desktop, launching `wsl.exe` | `.ico`, when PowerShell interop is reachable |
|
|
965
995
|
|
|
966
996
|
All of them run the same line you would type, so the shortcut is a labelled
|
|
967
997
|
button on the front door rather than a second way in. The icon is generated
|
package/bin/agents-city.js
CHANGED
|
@@ -3,9 +3,15 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The same trick Claude Code uses — npm as the installer, the payload being
|
|
5
5
|
* whatever the product actually is. Here the payload is the repo itself: the
|
|
6
|
-
* Python that writes your files
|
|
7
|
-
* prebuilt map. Node is only the dispatcher, and it is guaranteed
|
|
8
|
-
* npm just ran.
|
|
6
|
+
* Python that writes your files and builds your city, the Node that carries the
|
|
7
|
+
* bus, and the prebuilt map. Node is only the dispatcher, and it is guaranteed
|
|
8
|
+
* present because npm just ran.
|
|
9
|
+
*
|
|
10
|
+
* Every command used to go through a bash door, and fifteen of them were one
|
|
11
|
+
* `exec python3 x.py "$@"` line — a spelling of the interpreter, in the one
|
|
12
|
+
* language Windows does not have. They are named by their implementation now,
|
|
13
|
+
* and this file picks the interpreter, so what is left needing a shell is five
|
|
14
|
+
* commands rather than all of them.
|
|
9
15
|
*
|
|
10
16
|
* Deliberately not a port to JS: the shared modules (card, parcels, units, roles)
|
|
11
17
|
* are the product's single source of truth and every door reads them — the
|
|
@@ -19,35 +25,114 @@ const fs = require('fs');
|
|
|
19
25
|
|
|
20
26
|
const RAIZ = path.dirname(__dirname);
|
|
21
27
|
|
|
28
|
+
/* Every command, named by what it IS rather than by the door it used to have.
|
|
29
|
+
*
|
|
30
|
+
* A door that was one `exec python3 x.py "$@"` line is not a door: it is a
|
|
31
|
+
* spelling of the interpreter, and spelling it in bash is what kept this
|
|
32
|
+
* product off Windows for the fifteen commands that never needed a shell at
|
|
33
|
+
* all. So each entry says its kind, and this file picks the interpreter:
|
|
34
|
+
*
|
|
35
|
+
* py a Python module — everywhere
|
|
36
|
+
* node a Node entry point — everywhere; `env` first resolves the city's
|
|
37
|
+
* settings, which the bash door used to do by sourcing city-env.sh
|
|
38
|
+
* sh a door with shell logic of its own, and therefore POSIX for now
|
|
39
|
+
*/
|
|
22
40
|
const ORDENES = {
|
|
23
|
-
hall: {
|
|
24
|
-
seat: {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
41
|
+
hall: { py: 'bin/hall', di: 'the town hall: manage your city from the browser' },
|
|
42
|
+
seat: {
|
|
43
|
+
py: 'plugin/scripts/seat.py',
|
|
44
|
+
di: 'your chair: domain, seat role, repo-agent roles, goal, tmux',
|
|
45
|
+
},
|
|
46
|
+
cities: { py: 'plugin/scripts/cities.py', di: 'list, create or select your cities' },
|
|
47
|
+
agents: {
|
|
48
|
+
py: 'plugin/scripts/workspace.py',
|
|
49
|
+
di: 'list agents and manage their workspace mounts',
|
|
50
|
+
},
|
|
51
|
+
road: { py: 'plugin/scripts/roads.py', di: 'connect two cities explicitly' },
|
|
52
|
+
connect: {
|
|
53
|
+
node: 'plugin/channel/managed-connect-cli.js',
|
|
54
|
+
di: 'pair this computer and open encrypted managed Roads',
|
|
55
|
+
},
|
|
56
|
+
bus: {
|
|
57
|
+
node: 'plugin/channel/client.js',
|
|
58
|
+
antes: ['bus'],
|
|
59
|
+
entorno: true,
|
|
60
|
+
di: 'send information over those roads (seat only)',
|
|
61
|
+
},
|
|
62
|
+
committee: {
|
|
63
|
+
node: 'plugin/channel/client.js',
|
|
64
|
+
antes: ['committee'],
|
|
65
|
+
entorno: true,
|
|
66
|
+
di: 'chair-mediated work with repo agents',
|
|
67
|
+
},
|
|
68
|
+
benchmark: {
|
|
69
|
+
sh: 'bin/benchmark',
|
|
70
|
+
di: 'offline stress/governance or opt-in live runtime latency',
|
|
71
|
+
},
|
|
72
|
+
logs: {
|
|
73
|
+
py: 'plugin/scripts/logs.py',
|
|
74
|
+
di: 'read or follow visible activity and operational diagnostics',
|
|
75
|
+
},
|
|
76
|
+
reset: { py: 'plugin/scripts/reset.py', di: 'reset one city to onboarding, recoverably' },
|
|
34
77
|
uninstall: {
|
|
35
|
-
|
|
78
|
+
py: 'plugin/scripts/desinstala.py',
|
|
36
79
|
di: 'remove everything this wrote on this machine (previews first)',
|
|
37
80
|
},
|
|
38
|
-
skills: {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
81
|
+
skills: {
|
|
82
|
+
py: 'plugin/scripts/capabilities.py',
|
|
83
|
+
di: 'recognise the skills installed in each repo',
|
|
84
|
+
},
|
|
85
|
+
city: { sh: 'bin/city', di: 'draw your city' },
|
|
86
|
+
shortcut: {
|
|
87
|
+
py: 'plugin/scripts/atajos.py',
|
|
88
|
+
di: 'put a city on your desktop: icon, name, double-click',
|
|
89
|
+
},
|
|
90
|
+
demo: { sh: 'bin/demo', di: 'Aurora Games — see it working, no account' },
|
|
91
|
+
setup: { py: 'bin/setup.py', di: 'create or open a personal city' },
|
|
92
|
+
report: { py: 'bin/report.py', di: 'report growth from your folders' },
|
|
93
|
+
tokens: { py: 'bin/tokens.py', di: 'report token spend' },
|
|
94
|
+
exit: {
|
|
95
|
+
py: 'plugin/scripts/apaga.py',
|
|
96
|
+
di: 'close the day — every session and agent, or one city',
|
|
97
|
+
},
|
|
98
|
+
doctor: {
|
|
99
|
+
py: 'plugin/scripts/doctor.py',
|
|
100
|
+
di: 'check this machine: tools, runtimes, cage, city, version',
|
|
101
|
+
},
|
|
102
|
+
update: {
|
|
103
|
+
py: 'plugin/scripts/actualiza.py',
|
|
104
|
+
di: 'install the newest published version (--check just asks)',
|
|
105
|
+
},
|
|
106
|
+
test: { sh: 'bin/test', di: 'every check in the repo' },
|
|
49
107
|
};
|
|
50
108
|
|
|
109
|
+
/* Which Python. `python3` is the POSIX spelling and it is NOT what a Windows
|
|
110
|
+
* install from python.org gives you — that is `python` and the `py` launcher,
|
|
111
|
+
* and the Microsoft Store's `python3.exe` is a stub that opens the Store when
|
|
112
|
+
* nothing is installed. So: ask, in order, and take the first that answers with
|
|
113
|
+
* a version. Resolved once per run.
|
|
114
|
+
*/
|
|
115
|
+
let elInterprete;
|
|
116
|
+
function interprete() {
|
|
117
|
+
if (elInterprete !== undefined) return elInterprete;
|
|
118
|
+
const candidatos =
|
|
119
|
+
process.platform === 'win32'
|
|
120
|
+
? [['python'], ['py', '-3'], ['python3']]
|
|
121
|
+
: [['python3'], ['python']];
|
|
122
|
+
for (const c of candidatos) {
|
|
123
|
+
const r = spawnSync(c[0], [...c.slice(1), '-c', 'import sys; print(sys.version_info[0])'], {
|
|
124
|
+
encoding: 'utf8',
|
|
125
|
+
});
|
|
126
|
+
if (r.status === 0 && String(r.stdout).trim() === '3') {
|
|
127
|
+
elInterprete = c;
|
|
128
|
+
return elInterprete;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
elInterprete = null;
|
|
132
|
+
return elInterprete;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
|
|
51
136
|
function ayuda() {
|
|
52
137
|
const v = require(path.join(RAIZ, 'package.json')).version;
|
|
53
138
|
console.log(`
|
|
@@ -60,17 +145,16 @@ function ayuda() {
|
|
|
60
145
|
for (const [n, o] of Object.entries(ORDENES)) {
|
|
61
146
|
console.log(` ${n.padEnd(11)}${o.di}`);
|
|
62
147
|
}
|
|
148
|
+
const conShell = Object.entries(ORDENES).filter(([, o]) => o.sh).map(([n]) => n);
|
|
63
149
|
console.log(`
|
|
64
|
-
Needs
|
|
65
|
-
|
|
150
|
+
Needs Python 3, and a window server for the ones that open a city (the seat
|
|
151
|
+
installs it itself).
|
|
66
152
|
`);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
{ shell: process.platform !== 'win32', stdio: 'ignore' });
|
|
73
|
-
return r.status === 0;
|
|
153
|
+
if (process.platform === 'win32') {
|
|
154
|
+
console.log(` On Windows these still need WSL, because they are shell programs:
|
|
155
|
+
${conShell.join(', ')}
|
|
156
|
+
`);
|
|
157
|
+
}
|
|
74
158
|
}
|
|
75
159
|
|
|
76
160
|
function main() {
|
|
@@ -83,42 +167,83 @@ function main() {
|
|
|
83
167
|
return 0;
|
|
84
168
|
}
|
|
85
169
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
console.error(' wsl -- npm install -g agents-city\n');
|
|
90
|
-
return 1;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const orden = ORDENES[primera];
|
|
94
|
-
const resto = orden ? args.slice(1) : args;
|
|
95
|
-
const entrada = orden ? orden.que[0] : ORDENES.hall.que[0];
|
|
96
|
-
if (!orden && args.length && primera.startsWith('-') === false) {
|
|
170
|
+
const orden = ORDENES[primera] || ORDENES.hall;
|
|
171
|
+
const resto = ORDENES[primera] ? args.slice(1) : args;
|
|
172
|
+
if (!ORDENES[primera] && args.length && primera.startsWith('-') === false) {
|
|
97
173
|
console.error(`\n No such command: ${primera}\n`);
|
|
98
174
|
ayuda();
|
|
99
175
|
return 1;
|
|
100
176
|
}
|
|
101
177
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
console.error(
|
|
178
|
+
// A door with shell logic of its own. Named, with what it is, rather than a
|
|
179
|
+
// blanket "this product does not run here" — fifteen of these commands do.
|
|
180
|
+
if (orden.sh && process.platform === 'win32') {
|
|
181
|
+
console.error(`\n \`agents-city ${primera}\` is still a shell program, and Windows has`);
|
|
182
|
+
console.error(' no shell to run it in. Everything else on this install works;');
|
|
183
|
+
console.error(' for this one, run it inside WSL:\n');
|
|
184
|
+
console.error(` wsl -- agents-city ${primera}\n`);
|
|
106
185
|
return 1;
|
|
107
186
|
}
|
|
108
187
|
|
|
109
|
-
const
|
|
188
|
+
const objetivo = orden.sh || orden.py || orden.node;
|
|
189
|
+
const guion = path.join(RAIZ, objetivo);
|
|
110
190
|
if (!fs.existsSync(guion)) {
|
|
111
|
-
console.error(`\n ${
|
|
191
|
+
console.error(`\n ${objetivo} is missing from this install — reinstall:`);
|
|
112
192
|
console.error(' npm install -g agents-city\n');
|
|
113
193
|
return 1;
|
|
114
194
|
}
|
|
195
|
+
|
|
196
|
+
let programa = guion;
|
|
197
|
+
let antes = [];
|
|
198
|
+
if (orden.py) {
|
|
199
|
+
const py = interprete();
|
|
200
|
+
if (!py) {
|
|
201
|
+
console.error('\n agents-city needs Python 3 on PATH — the files it manages are');
|
|
202
|
+
console.error(' written by Python, the same modules every door shares.');
|
|
203
|
+
console.error(' macOS: xcode-select --install · Debian: apt install python3');
|
|
204
|
+
console.error(' Windows: winget install Python.Python.3.12\n');
|
|
205
|
+
return 1;
|
|
206
|
+
}
|
|
207
|
+
programa = py[0];
|
|
208
|
+
antes = [...py.slice(1), guion];
|
|
209
|
+
} else if (orden.node) {
|
|
210
|
+
programa = process.execPath;
|
|
211
|
+
antes = [guion, ...(orden.antes || [])];
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// The settings the bash doors used to establish by sourcing city-env.sh.
|
|
215
|
+
// Asked of the one resolver, in the one shape a non-shell can read.
|
|
216
|
+
// PYTHONUTF8 makes `open()` and stdout default to UTF-8 whatever code page
|
|
217
|
+
// the console is on. Without it, on Windows, a card with an em dash is
|
|
218
|
+
// written in cp1252 and read back as UTF-8 by the next door along.
|
|
219
|
+
let entorno = {
|
|
220
|
+
...process.env, PYTHONUNBUFFERED: '1', PYTHONUTF8: '1', PYTHONIOENCODING: 'utf-8',
|
|
221
|
+
};
|
|
222
|
+
if (orden.entorno) {
|
|
223
|
+
const py = interprete();
|
|
224
|
+
if (py) {
|
|
225
|
+
const r = spawnSync(py[0], [...py.slice(1), path.join(RAIZ, 'plugin/scripts/city_env.py'),
|
|
226
|
+
'--json'], { encoding: 'utf8' });
|
|
227
|
+
if (r.status === 0) {
|
|
228
|
+
try {
|
|
229
|
+
entorno = { ...entorno, ...JSON.parse(r.stdout) };
|
|
230
|
+
} catch {
|
|
231
|
+
/* a resolver that cannot answer leaves the environment as it found it */
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
115
237
|
// Unbuffered, so the URL a server prints reaches a pipe as well as a terminal
|
|
116
238
|
// — a CI log or a `| head` otherwise swallows it and the run looks silent.
|
|
117
|
-
const r = spawnSync(
|
|
118
|
-
stdio: 'inherit', cwd: RAIZ,
|
|
119
|
-
env: { ...process.env, PYTHONUNBUFFERED: '1' },
|
|
239
|
+
const r = spawnSync(programa, [...antes, ...resto], {
|
|
240
|
+
stdio: 'inherit', cwd: RAIZ, env: entorno,
|
|
120
241
|
});
|
|
121
242
|
return r.status === null ? 1 : r.status;
|
|
122
243
|
}
|
|
123
244
|
|
|
124
|
-
|
|
245
|
+
// Only when this IS the command. Exported so the checks can read the real map
|
|
246
|
+
// rather than a regex over this file — what each command runs, and which ones
|
|
247
|
+
// still need a shell, is exactly the thing that must not drift unnoticed.
|
|
248
|
+
if (require.main === module) process.exit(main());
|
|
249
|
+
module.exports = { ORDENES };
|
package/bin/hall
CHANGED
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
./bin/hall open it
|
|
5
5
|
./bin/hall --city lab open one known city
|
|
6
6
|
./bin/hall --no-browser print the address instead
|
|
7
|
+
./bin/hall --foreground serve here, and stop when this window closes
|
|
8
|
+
|
|
9
|
+
It runs detached, like the city bus and every other long-lived piece of this
|
|
10
|
+
product. Closing the window that started it is not a way to break the page
|
|
11
|
+
somebody is looking at, and its address survives a restart, so a tab left open
|
|
12
|
+
overnight still works in the morning.
|
|
7
13
|
|
|
8
14
|
One page on localhost: the selected city's identity, owner seat (role, folders,
|
|
9
15
|
goal), repo support agents, recognised skills, roads, districts and houses. It
|
|
@@ -51,10 +57,72 @@ def asegura_build():
|
|
|
51
57
|
return True
|
|
52
58
|
|
|
53
59
|
|
|
60
|
+
def vivo():
|
|
61
|
+
"""The URL of a Hall already serving on this machine, or ''.
|
|
62
|
+
|
|
63
|
+
Asked, not assumed: a marker file outlives a process that was killed, and
|
|
64
|
+
handing somebody a URL that answers nothing is exactly the broken tab this
|
|
65
|
+
change exists to remove.
|
|
66
|
+
"""
|
|
67
|
+
import json
|
|
68
|
+
import urllib.error
|
|
69
|
+
import urllib.request
|
|
70
|
+
|
|
71
|
+
try:
|
|
72
|
+
with open(serve.marcador(), encoding='utf-8') as f:
|
|
73
|
+
url = str(json.load(f).get('url') or '')
|
|
74
|
+
if not url:
|
|
75
|
+
return ''
|
|
76
|
+
with urllib.request.urlopen(url, timeout=2) as r:
|
|
77
|
+
return url if r.status == 200 else ''
|
|
78
|
+
except (OSError, ValueError, urllib.error.URLError):
|
|
79
|
+
return ''
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def despega(datos, abrir):
|
|
83
|
+
"""Start the Hall detached, and wait until it can actually answer.
|
|
84
|
+
|
|
85
|
+
Detached because every other long-lived piece of this product already is —
|
|
86
|
+
the bus hub, the gateways, the adapters — and the Hall was the one that died
|
|
87
|
+
with whichever terminal happened to start it. Closing a window is not
|
|
88
|
+
supposed to be a way to break the page somebody is looking at.
|
|
89
|
+
|
|
90
|
+
It waits for the address to serve rather than printing one optimistically: a
|
|
91
|
+
URL that is not up yet is the same broken tab, one second earlier.
|
|
92
|
+
"""
|
|
93
|
+
import subprocess
|
|
94
|
+
import time
|
|
95
|
+
import webbrowser
|
|
96
|
+
|
|
97
|
+
subprocess.Popen(
|
|
98
|
+
[sys.executable, os.path.join(AQUI, 'serve.py'), datos],
|
|
99
|
+
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, **runtime_processes.DESPEGADO,
|
|
100
|
+
)
|
|
101
|
+
limite = time.monotonic() + 25
|
|
102
|
+
while time.monotonic() < limite:
|
|
103
|
+
url = vivo()
|
|
104
|
+
if url:
|
|
105
|
+
print(f'\n The town hall\n\n {url}\n')
|
|
106
|
+
print(' It keeps running when you close this window.')
|
|
107
|
+
print(' Stop it with: agents-city exit\n')
|
|
108
|
+
if abrir:
|
|
109
|
+
try:
|
|
110
|
+
webbrowser.open(url)
|
|
111
|
+
except Exception:
|
|
112
|
+
pass
|
|
113
|
+
return 0
|
|
114
|
+
time.sleep(0.2)
|
|
115
|
+
print(' The hall did not come up. Run it here to see why:', file=sys.stderr)
|
|
116
|
+
print(f' {os.path.basename(sys.argv[0])} --foreground', file=sys.stderr)
|
|
117
|
+
return 1
|
|
118
|
+
|
|
119
|
+
|
|
54
120
|
if __name__ == '__main__':
|
|
55
121
|
ap = argparse.ArgumentParser(description='Open one personal city in the local Hall')
|
|
56
122
|
ap.add_argument('--city', default='', help='known city name, id or path')
|
|
57
123
|
ap.add_argument('--no-browser', action='store_true', help='print the URL only')
|
|
124
|
+
ap.add_argument('--foreground', action='store_true',
|
|
125
|
+
help='serve in this window and stop when it closes')
|
|
58
126
|
a = ap.parse_args()
|
|
59
127
|
if not asegura_build():
|
|
60
128
|
sys.exit(1)
|
|
@@ -68,6 +136,18 @@ if __name__ == '__main__':
|
|
|
68
136
|
print(f" This city belongs to {owner!r}, not {usuario!r}.", file=sys.stderr)
|
|
69
137
|
sys.exit(1)
|
|
70
138
|
cities.selecciona(usuario, datos)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
139
|
+
if a.foreground:
|
|
140
|
+
sys.exit(0 if serve.sirve(datos, abrir=not a.no_browser, pagina='hall') else 0)
|
|
141
|
+
# Already open: hand back the same address rather than starting a second
|
|
142
|
+
# hall and leaving somebody with two of them and no way to tell which.
|
|
143
|
+
ya = vivo()
|
|
144
|
+
if ya:
|
|
145
|
+
print(f'\n The town hall is already open\n\n {ya}\n')
|
|
146
|
+
if not a.no_browser:
|
|
147
|
+
import webbrowser
|
|
148
|
+
try:
|
|
149
|
+
webbrowser.open(ya)
|
|
150
|
+
except Exception:
|
|
151
|
+
pass
|
|
152
|
+
sys.exit(0)
|
|
153
|
+
sys.exit(despega(datos, abrir=not a.no_browser))
|