@lamalibre/create-lamaste 4.0.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.
- package/LICENSE.md +118 -0
- package/README.md +114 -0
- package/bin/create-lamaste.js +15 -0
- package/package.json +54 -0
- package/scripts/bundle-vendor.js +110 -0
- package/scripts/lamaste-cert-info +62 -0
- package/scripts/lamaste-certbot +96 -0
- package/scripts/lamaste-priv +693 -0
- package/src/index.js +646 -0
- package/src/lib/accounts.js +86 -0
- package/src/lib/binaries.js +137 -0
- package/src/lib/cert-help-page.js +160 -0
- package/src/lib/env.js +132 -0
- package/src/lib/http-redirect.js +38 -0
- package/src/lib/ownership.js +231 -0
- package/src/lib/relay-services.js +103 -0
- package/src/lib/secrets.js +19 -0
- package/src/lib/service-config.js +311 -0
- package/src/lib/summary.js +131 -0
- package/src/lib/wrappers.js +63 -0
- package/src/tasks/gatekeeper.js +233 -0
- package/src/tasks/harden.js +293 -0
- package/src/tasks/mtls.js +193 -0
- package/src/tasks/nginx.js +265 -0
- package/src/tasks/node.js +110 -0
- package/src/tasks/panel.js +408 -0
- package/src/tasks/redeploy.js +438 -0
- package/vendor/docs/00-introduction/how-it-works.md +447 -0
- package/vendor/docs/00-introduction/quickstart.md +472 -0
- package/vendor/docs/00-introduction/what-is-lamaste.md +112 -0
- package/vendor/docs/01-concepts/authentication.md +464 -0
- package/vendor/docs/01-concepts/authorization.md +242 -0
- package/vendor/docs/01-concepts/certificates.md +452 -0
- package/vendor/docs/01-concepts/dns-and-domains.md +343 -0
- package/vendor/docs/01-concepts/mtls.md +490 -0
- package/vendor/docs/01-concepts/nginx-reverse-proxy.md +540 -0
- package/vendor/docs/01-concepts/security-model.md +600 -0
- package/vendor/docs/01-concepts/tickets.md +414 -0
- package/vendor/docs/01-concepts/tunneling.md +367 -0
- package/vendor/docs/02-guides/agent-setup.md +194 -0
- package/vendor/docs/02-guides/certificate-management.md +341 -0
- package/vendor/docs/02-guides/cloud-provisioning.md +406 -0
- package/vendor/docs/02-guides/desktop-app-setup.md +226 -0
- package/vendor/docs/02-guides/disaster-recovery.md +464 -0
- package/vendor/docs/02-guides/first-tunnel.md +230 -0
- package/vendor/docs/02-guides/installation.md +393 -0
- package/vendor/docs/02-guides/managing-users.md +255 -0
- package/vendor/docs/02-guides/onboarding.md +244 -0
- package/vendor/docs/02-guides/standalone-plugin-with-tickets.md +375 -0
- package/vendor/docs/02-guides/static-sites.md +364 -0
- package/vendor/docs/03-architecture/e2e-three-vm-sequences.md +457 -0
- package/vendor/docs/03-architecture/installer-flow.md +151 -0
- package/vendor/docs/03-architecture/installer.md +445 -0
- package/vendor/docs/03-architecture/management-flow.md +288 -0
- package/vendor/docs/03-architecture/nginx-configuration.md +830 -0
- package/vendor/docs/03-architecture/onboarding-flow.md +164 -0
- package/vendor/docs/03-architecture/overview.md +541 -0
- package/vendor/docs/03-architecture/panel-client.md +416 -0
- package/vendor/docs/03-architecture/panel-server.md +695 -0
- package/vendor/docs/03-architecture/state-management.md +529 -0
- package/vendor/docs/03-architecture/system-overview.md +167 -0
- package/vendor/docs/04-api-reference/certificates.md +1141 -0
- package/vendor/docs/04-api-reference/gatekeeper.md +592 -0
- package/vendor/docs/04-api-reference/onboarding.md +473 -0
- package/vendor/docs/04-api-reference/overview.md +404 -0
- package/vendor/docs/04-api-reference/services.md +267 -0
- package/vendor/docs/04-api-reference/settings.md +343 -0
- package/vendor/docs/04-api-reference/sites.md +716 -0
- package/vendor/docs/04-api-reference/system.md +268 -0
- package/vendor/docs/04-api-reference/tickets.md +618 -0
- package/vendor/docs/04-api-reference/tunnels.md +417 -0
- package/vendor/docs/04-api-reference/users.md +333 -0
- package/vendor/docs/05-operations/backup-and-restore.md +342 -0
- package/vendor/docs/05-operations/monitoring.md +285 -0
- package/vendor/docs/05-operations/uninstalling.md +344 -0
- package/vendor/docs/05-operations/upgrades.md +270 -0
- package/vendor/docs/06-reference/config-files.md +1080 -0
- package/vendor/docs/06-reference/glossary.md +528 -0
- package/vendor/docs/06-reference/installer-flags.md +260 -0
- package/vendor/docs/06-reference/ports-and-services.md +244 -0
- package/vendor/docs/06-reference/troubleshooting.md +665 -0
- package/vendor/docs/_index.json +233 -0
- package/vendor/docs/gatekeeper-design.md +953 -0
- package/vendor/docs/package.json +15 -0
- package/vendor/docs/todo/lib-cli-desktop-refactor.md +641 -0
- package/vendor/gatekeeper/dist/boot.d.ts +1 -0
- package/vendor/gatekeeper/dist/boot.d.ts.map +1 -0
- package/vendor/gatekeeper/dist/boot.js +17 -0
- package/vendor/gatekeeper/dist/boot.js.map +1 -0
- package/vendor/gatekeeper/dist/cli/commands/access.d.ts +2 -0
- package/vendor/gatekeeper/dist/cli/commands/access.d.ts.map +1 -0
- package/vendor/gatekeeper/dist/cli/commands/access.js +33 -0
- package/vendor/gatekeeper/dist/cli/commands/access.js.map +1 -0
- package/vendor/gatekeeper/dist/cli/commands/grants.d.ts +2 -0
- package/vendor/gatekeeper/dist/cli/commands/grants.d.ts.map +1 -0
- package/vendor/gatekeeper/dist/cli/commands/grants.js +110 -0
- package/vendor/gatekeeper/dist/cli/commands/grants.js.map +1 -0
- package/vendor/gatekeeper/dist/cli/commands/groups.d.ts +2 -0
- package/vendor/gatekeeper/dist/cli/commands/groups.d.ts.map +1 -0
- package/vendor/gatekeeper/dist/cli/commands/groups.js +98 -0
- package/vendor/gatekeeper/dist/cli/commands/groups.js.map +1 -0
- package/vendor/gatekeeper/dist/cli/index.d.ts +3 -0
- package/vendor/gatekeeper/dist/cli/index.d.ts.map +1 -0
- package/vendor/gatekeeper/dist/cli/index.js +45 -0
- package/vendor/gatekeeper/dist/cli/index.js.map +1 -0
- package/vendor/gatekeeper/dist/index.d.ts +9 -0
- package/vendor/gatekeeper/dist/index.d.ts.map +1 -0
- package/vendor/gatekeeper/dist/index.js +13 -0
- package/vendor/gatekeeper/dist/index.js.map +1 -0
- package/vendor/gatekeeper/dist/lib/authz.d.ts +16 -0
- package/vendor/gatekeeper/dist/lib/authz.d.ts.map +1 -0
- package/vendor/gatekeeper/dist/lib/authz.js +42 -0
- package/vendor/gatekeeper/dist/lib/authz.js.map +1 -0
- package/vendor/gatekeeper/dist/lib/cache-bust.d.ts +15 -0
- package/vendor/gatekeeper/dist/lib/cache-bust.d.ts.map +1 -0
- package/vendor/gatekeeper/dist/lib/cache-bust.js +19 -0
- package/vendor/gatekeeper/dist/lib/cache-bust.js.map +1 -0
- package/vendor/gatekeeper/dist/lib/constants.d.ts +82 -0
- package/vendor/gatekeeper/dist/lib/constants.d.ts.map +1 -0
- package/vendor/gatekeeper/dist/lib/constants.js +79 -0
- package/vendor/gatekeeper/dist/lib/constants.js.map +1 -0
- package/vendor/gatekeeper/dist/lib/grants.d.ts +32 -0
- package/vendor/gatekeeper/dist/lib/grants.d.ts.map +1 -0
- package/vendor/gatekeeper/dist/lib/grants.js +314 -0
- package/vendor/gatekeeper/dist/lib/grants.js.map +1 -0
- package/vendor/gatekeeper/dist/lib/groups.d.ts +10 -0
- package/vendor/gatekeeper/dist/lib/groups.d.ts.map +1 -0
- package/vendor/gatekeeper/dist/lib/groups.js +247 -0
- package/vendor/gatekeeper/dist/lib/groups.js.map +1 -0
- package/vendor/gatekeeper/dist/lib/migration.d.ts +17 -0
- package/vendor/gatekeeper/dist/lib/migration.d.ts.map +1 -0
- package/vendor/gatekeeper/dist/lib/migration.js +79 -0
- package/vendor/gatekeeper/dist/lib/migration.js.map +1 -0
- package/vendor/gatekeeper/dist/lib/migrations/gatekeeper/0001_groups.sql +7 -0
- package/vendor/gatekeeper/dist/lib/migrations/gatekeeper/0002_access_grants.sql +14 -0
- package/vendor/gatekeeper/dist/lib/migrations/gatekeeper/0003_access_request_log.sql +9 -0
- package/vendor/gatekeeper/dist/lib/migrations/migrations/gatekeeper/0001_groups.sql +7 -0
- package/vendor/gatekeeper/dist/lib/migrations/migrations/gatekeeper/0002_access_grants.sql +14 -0
- package/vendor/gatekeeper/dist/lib/migrations/migrations/gatekeeper/0003_access_request_log.sql +9 -0
- package/vendor/gatekeeper/dist/lib/state-db.d.ts +16 -0
- package/vendor/gatekeeper/dist/lib/state-db.d.ts.map +1 -0
- package/vendor/gatekeeper/dist/lib/state-db.js +154 -0
- package/vendor/gatekeeper/dist/lib/state-db.js.map +1 -0
- package/vendor/gatekeeper/dist/lib/templates.d.ts +21 -0
- package/vendor/gatekeeper/dist/lib/templates.d.ts.map +1 -0
- package/vendor/gatekeeper/dist/lib/templates.js +151 -0
- package/vendor/gatekeeper/dist/lib/templates.js.map +1 -0
- package/vendor/gatekeeper/dist/lib/types.d.ts +178 -0
- package/vendor/gatekeeper/dist/lib/types.d.ts.map +1 -0
- package/vendor/gatekeeper/dist/lib/types.js +2 -0
- package/vendor/gatekeeper/dist/lib/types.js.map +1 -0
- package/vendor/gatekeeper/dist/server/index.d.ts +15 -0
- package/vendor/gatekeeper/dist/server/index.d.ts.map +1 -0
- package/vendor/gatekeeper/dist/server/index.js +251 -0
- package/vendor/gatekeeper/dist/server/index.js.map +1 -0
- package/vendor/gatekeeper/dist/server/routes/access-request.d.ts +7 -0
- package/vendor/gatekeeper/dist/server/routes/access-request.d.ts.map +1 -0
- package/vendor/gatekeeper/dist/server/routes/access-request.js +17 -0
- package/vendor/gatekeeper/dist/server/routes/access-request.js.map +1 -0
- package/vendor/gatekeeper/dist/server/routes/authz.d.ts +3 -0
- package/vendor/gatekeeper/dist/server/routes/authz.d.ts.map +1 -0
- package/vendor/gatekeeper/dist/server/routes/authz.js +279 -0
- package/vendor/gatekeeper/dist/server/routes/authz.js.map +1 -0
- package/vendor/gatekeeper/dist/server/routes/diagnostic.d.ts +13 -0
- package/vendor/gatekeeper/dist/server/routes/diagnostic.d.ts.map +1 -0
- package/vendor/gatekeeper/dist/server/routes/diagnostic.js +249 -0
- package/vendor/gatekeeper/dist/server/routes/diagnostic.js.map +1 -0
- package/vendor/gatekeeper/dist/server/routes/grants.d.ts +3 -0
- package/vendor/gatekeeper/dist/server/routes/grants.d.ts.map +1 -0
- package/vendor/gatekeeper/dist/server/routes/grants.js +112 -0
- package/vendor/gatekeeper/dist/server/routes/grants.js.map +1 -0
- package/vendor/gatekeeper/dist/server/routes/groups.d.ts +3 -0
- package/vendor/gatekeeper/dist/server/routes/groups.d.ts.map +1 -0
- package/vendor/gatekeeper/dist/server/routes/groups.js +139 -0
- package/vendor/gatekeeper/dist/server/routes/groups.js.map +1 -0
- package/vendor/gatekeeper/package.json +49 -0
- package/vendor/server/bin/lamaste-server.js +204 -0
- package/vendor/server/package.json +31 -0
- package/vendor/server/src/commands/certs.js +224 -0
- package/vendor/server/src/commands/chisel.js +132 -0
- package/vendor/server/src/commands/logs.js +49 -0
- package/vendor/server/src/commands/plugins.js +321 -0
- package/vendor/server/src/commands/reset-admin.js +478 -0
- package/vendor/server/src/commands/restart.js +94 -0
- package/vendor/server/src/commands/sites.js +257 -0
- package/vendor/server/src/commands/status.js +158 -0
- package/vendor/server/src/commands/tunnels.js +365 -0
- package/vendor/server/src/commands/uninstall.js +326 -0
- package/vendor/server/src/config.js +38 -0
- package/vendor/server/src/exec.js +26 -0
- package/vendor/server/src/logger.js +39 -0
- package/vendor/server/src/ndjson.js +56 -0
- package/vendor/server/src/panel-api.js +85 -0
- package/vendor/server/src/state.js +45 -0
- package/vendor/server-ui/dist/assets/index-B0nWuUyL.js +257 -0
- package/vendor/server-ui/dist/assets/index-BqWWFlTU.css +1 -0
- package/vendor/server-ui/dist/index.html +13 -0
- package/vendor/serverd/package.json +44 -0
- package/vendor/serverd/src/boot.js +13 -0
- package/vendor/serverd/src/index.js +191 -0
- package/vendor/serverd/src/lib/app-error.js +14 -0
- package/vendor/serverd/src/lib/authelia.js +85 -0
- package/vendor/serverd/src/lib/certbot.js +74 -0
- package/vendor/serverd/src/lib/chisel-args.js +6 -0
- package/vendor/serverd/src/lib/chisel-reconcile.js +232 -0
- package/vendor/serverd/src/lib/chisel-runtime.js +46 -0
- package/vendor/serverd/src/lib/chisel-users.js +109 -0
- package/vendor/serverd/src/lib/chisel.js +81 -0
- package/vendor/serverd/src/lib/config.js +190 -0
- package/vendor/serverd/src/lib/constants.js +8 -0
- package/vendor/serverd/src/lib/csr-signing.js +331 -0
- package/vendor/serverd/src/lib/enrollment.js +302 -0
- package/vendor/serverd/src/lib/files.js +19 -0
- package/vendor/serverd/src/lib/gatekeeper-client.js +135 -0
- package/vendor/serverd/src/lib/invite-page.js +281 -0
- package/vendor/serverd/src/lib/ip-utils.js +79 -0
- package/vendor/serverd/src/lib/migrations/state/0001_enrollment_tokens.sql +17 -0
- package/vendor/serverd/src/lib/migrations/state/0002_tickets.sql +70 -0
- package/vendor/serverd/src/lib/migrations/state/0003_plugins.sql +15 -0
- package/vendor/serverd/src/lib/migrations/state/0004_agents.sql +19 -0
- package/vendor/serverd/src/lib/mtls.js +795 -0
- package/vendor/serverd/src/lib/nginx.js +1090 -0
- package/vendor/serverd/src/lib/pki-paths.js +41 -0
- package/vendor/serverd/src/lib/pki-sign.js +103 -0
- package/vendor/serverd/src/lib/plugins.js +538 -0
- package/vendor/serverd/src/lib/push-install.js +390 -0
- package/vendor/serverd/src/lib/revocation.js +112 -0
- package/vendor/serverd/src/lib/services.js +131 -0
- package/vendor/serverd/src/lib/session.js +151 -0
- package/vendor/serverd/src/lib/state-db.js +130 -0
- package/vendor/serverd/src/lib/state.js +140 -0
- package/vendor/serverd/src/lib/storage.js +63 -0
- package/vendor/serverd/src/lib/system-stats.js +58 -0
- package/vendor/serverd/src/lib/tickets.js +1556 -0
- package/vendor/serverd/src/lib/totp.js +76 -0
- package/vendor/serverd/src/lib/tunnel-deps.js +41 -0
- package/vendor/serverd/src/lib/user-access-session.js +142 -0
- package/vendor/serverd/src/lib/user-access.js +52 -0
- package/vendor/serverd/src/middleware/errors.js +63 -0
- package/vendor/serverd/src/middleware/mtls.js +120 -0
- package/vendor/serverd/src/middleware/onboarding-guard.js +30 -0
- package/vendor/serverd/src/middleware/role-guard.js +58 -0
- package/vendor/serverd/src/middleware/twofa-session.js +65 -0
- package/vendor/serverd/src/middleware/user-access-session.js +52 -0
- package/vendor/serverd/src/routes/enrollment.js +120 -0
- package/vendor/serverd/src/routes/health.js +22 -0
- package/vendor/serverd/src/routes/invite.js +163 -0
- package/vendor/serverd/src/routes/management/agents.js +182 -0
- package/vendor/serverd/src/routes/management/certs.js +911 -0
- package/vendor/serverd/src/routes/management/gatekeeper-proxy.js +160 -0
- package/vendor/serverd/src/routes/management/identity.js +107 -0
- package/vendor/serverd/src/routes/management/invitations.js +166 -0
- package/vendor/serverd/src/routes/management/logs.js +218 -0
- package/vendor/serverd/src/routes/management/plugins.js +560 -0
- package/vendor/serverd/src/routes/management/services.js +63 -0
- package/vendor/serverd/src/routes/management/settings.js +325 -0
- package/vendor/serverd/src/routes/management/sites.js +522 -0
- package/vendor/serverd/src/routes/management/storage.js +192 -0
- package/vendor/serverd/src/routes/management/system.js +201 -0
- package/vendor/serverd/src/routes/management/tickets.js +457 -0
- package/vendor/serverd/src/routes/management/tunnels.js +709 -0
- package/vendor/serverd/src/routes/management/users.js +377 -0
- package/vendor/serverd/src/routes/management.js +36 -0
- package/vendor/serverd/src/routes/onboarding/dns.js +101 -0
- package/vendor/serverd/src/routes/onboarding/domain.js +42 -0
- package/vendor/serverd/src/routes/onboarding/index.js +18 -0
- package/vendor/serverd/src/routes/onboarding/provision.js +327 -0
- package/vendor/serverd/src/routes/onboarding/status.js +12 -0
- package/vendor/serverd/src/routes/plugin-router.js +79 -0
- package/vendor/serverd/src/routes/user-access.js +389 -0
|
@@ -0,0 +1,641 @@
|
|
|
1
|
+
# Refactor: lib → cli → desktop Dependency Chain (v2.0.0)
|
|
2
|
+
|
|
3
|
+
> Consolidate business logic into a shared lib layer, expose it through thin CLIs, and have the desktop app consume the CLIs — eliminating ~60 Rust reimplementations of JavaScript logic. All packages bump to 2.0.0. All breaking changes accepted. Feria used as local registry throughout to validate before npm publish. **Feria itself is out of scope for this refactor** — it will be addressed separately.
|
|
4
|
+
|
|
5
|
+
## Motivation
|
|
6
|
+
|
|
7
|
+
The desktop app (Tauri/Rust) reimplements business logic that already exists in the CLI's JavaScript lib/ modules. When a JSON schema changes (e.g., `agents.json`, `plugins.json`), two implementations must be updated — JavaScript and Rust — with no shared contract between them. This is the primary source of maintenance cost and subtle bugs.
|
|
8
|
+
|
|
9
|
+
Additionally, the server side has no operational CLI at all. `create-lamaste` is a provisioner (OS hardening, nginx, Authelia, certificates), not a day-to-day management tool. Server operations like uninstall, reset-admin, status, and plugin management have no terminal interface — they're either standalone scripts (`lamaste-reset-admin`) or only accessible through the browser panel.
|
|
10
|
+
|
|
11
|
+
On the agent side, `lamaste-agent` is a monolith that bundles CLI commands, a REST API daemon on :9393, and business logic all in one package. This means a CLI bug fix requires restarting the daemon, the CLI loads Fastify even when it doesn't need it, and root-capable CLI code paths live in the same binary as the daemon.
|
|
12
|
+
|
|
13
|
+
`lamaste-cloud` already follows the correct pattern: TypeScript lib → CLI with `--json` NDJSON → desktop spawns subprocess. This refactor extends that pattern to the rest of the codebase.
|
|
14
|
+
|
|
15
|
+
## Naming Convention
|
|
16
|
+
|
|
17
|
+
All packages use the `@lamalibre/` scope. The naming pattern is:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
lamaste the project itself — core library (like express, fastify, react)
|
|
21
|
+
lamaste-{domain} operational CLI for a domain (agent, server, cloud)
|
|
22
|
+
lamaste-{domain}d long-running daemon for a domain (agentd, serverd)
|
|
23
|
+
lamaste-{domain}-ui React UI components for a domain (agent-ui, server-ui)
|
|
24
|
+
lamaste-{sdk} standalone SDK (tickets, identity)
|
|
25
|
+
lamaste-desktop Tauri desktop app (multi-target: full, agent-only, server-only)
|
|
26
|
+
create-lamaste-{target} npx one-shot provisioner/installer (npx create-lamaste, npx create-lamaste-agent, etc.)
|
|
27
|
+
feria dev registry — OUT OF SCOPE, do not touch
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Naming Rules
|
|
31
|
+
|
|
32
|
+
- **`lamaste`** is the core lib. You `import { ... } from '@lamalibre/lamaste@4.0.0'`. No `-lib` suffix.
|
|
33
|
+
- **`-d` suffix** for daemons — Unix convention (`httpd`, `sshd`, `mongod`). Instantly signals "long-running process".
|
|
34
|
+
- **`-ui`** for React component libraries — universal term, avoids "serverd serves the panel" tautology.
|
|
35
|
+
- **`create-*`** for all npx one-shot tools — the one npm convention everyone knows.
|
|
36
|
+
- **Subject-first** word order: `lamaste-agent-ui` (agent's UI), not `lamaste-ui-agent`.
|
|
37
|
+
- **Domain grouping**: packages sort alphabetically by domain (`agent`, `server`, `cloud`).
|
|
38
|
+
|
|
39
|
+
## Target Architecture
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
lamaste core library (types, constants, schemas, plugin host, file helpers)
|
|
43
|
+
│
|
|
44
|
+
├── lamaste/agent agent domain logic (~/.lamalibre/lamaste/)
|
|
45
|
+
│ │
|
|
46
|
+
│ ├── lamaste-agent agent operational CLI (thin, no Fastify)
|
|
47
|
+
│ │
|
|
48
|
+
│ ├── lamalibre-lamaste-agentd agent REST daemon :9393
|
|
49
|
+
│ │ │
|
|
50
|
+
│ │ ├── lamaste-desktop calls REST API / spawns CLI subprocess
|
|
51
|
+
│ │ └── lamaste-agent-ui browser SPA build
|
|
52
|
+
│ │
|
|
53
|
+
│ ├── create-lamaste-agent agent provisioner (npx create-lamaste-agent)
|
|
54
|
+
│ ├── create-lamaste-admin admin cert upgrade (npx create-lamaste-admin)
|
|
55
|
+
│ └── create-lamaste-e2e E2E test MCP (npx create-lamaste-e2e)
|
|
56
|
+
│
|
|
57
|
+
├── lamaste/server server domain logic (/etc/lamalibre/lamaste/)
|
|
58
|
+
│ │
|
|
59
|
+
│ ├── lamaste-server server operational CLI (thin, no Fastify)
|
|
60
|
+
│ │
|
|
61
|
+
│ ├── lamalibre-lamaste-serverd server REST daemon :3100
|
|
62
|
+
│ │ │
|
|
63
|
+
│ │ ├── lamaste-desktop calls REST API via curl_panel
|
|
64
|
+
│ │ └── lamaste-server-ui browser SPA build
|
|
65
|
+
│ │
|
|
66
|
+
│ └── create-lamaste server provisioner (npx create-lamaste)
|
|
67
|
+
│
|
|
68
|
+
├── lamaste-cloud cloud lib + CLI (already follows correct pattern)
|
|
69
|
+
├── lamaste-tickets agent-to-agent auth SDK
|
|
70
|
+
└── lamaste-identity Authelia identity SDK
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Complete Package Inventory
|
|
74
|
+
|
|
75
|
+
| # | Package (npm name) | Type | Depends on | Purpose |
|
|
76
|
+
| --- | ----------------------------------- | ----------- | ---------- | ------------------------------------------------------------------------------------------------------------------- |
|
|
77
|
+
| 1 | `@lamalibre/lamaste@4.0.0` | core lib | nothing | Types, constants, Zod schemas, plugin host Fastify plugin, atomic file helpers, client interfaces |
|
|
78
|
+
| | | | | Subpath: `@lamalibre/lamaste@4.0.0/agent` — agent domain logic |
|
|
79
|
+
| | | | | Subpath: `@lamalibre/lamaste@4.0.0/server` — server domain logic |
|
|
80
|
+
| 2 | `@lamalibre/lamaste-agent@4.0.0` | CLI | `lamaste` | Thin agent CLI. No Fastify, no HTTP |
|
|
81
|
+
| 3 | `@lamalibre/lamaste-agentd@4.0.0` | daemon | `lamaste` | Agent REST API on :9393. No CLI argument parsing |
|
|
82
|
+
| 4 | `@lamalibre/lamaste-agent-ui@4.0.0` | UI lib | `lamaste` | Agent React components + browser SPA build. Used by desktop and agentd |
|
|
83
|
+
| 5 | `@lamalibre/lamaste-server@4.0.0` | CLI | `lamaste` | **NEW.** Thin server CLI. No Fastify, no HTTP |
|
|
84
|
+
| 6 | `@lamalibre/lamaste-serverd@4.0.0` | daemon | `lamaste` | Server REST API on :3100. No CLI argument parsing. Renamed from `serverd` |
|
|
85
|
+
| 7 | `@lamalibre/lamaste-server-ui@4.0.0` | UI lib | `lamaste` | Server/admin React components + browser SPA build. Replaces both `panel-client` and `lamaste-admin-panel` |
|
|
86
|
+
| 8 | `@lamalibre/lamaste@4.0.0-desktop` | desktop | `lamaste` | Unified Tauri app. Multi-target: full, agent-only, server-only. Credentials, tray, deep links |
|
|
87
|
+
| 9 | `@lamalibre/lamaste-cloud@4.0.0` | lib + CLI | — | Cloud provider abstraction (already correct pattern) |
|
|
88
|
+
| 10 | `@lamalibre/lamaste-tickets@4.0.0` | SDK | — | Agent-to-agent authorization |
|
|
89
|
+
| 11 | `@lamalibre/lamaste-identity@4.0.0` | SDK | — | Authelia identity parsing and query |
|
|
90
|
+
| 12 | `@lamalibre/create-lamaste@4.0.0` | provisioner | `lamaste` | Server provisioner: OS hardening, nginx, Authelia, certs. `npx create-lamaste` |
|
|
91
|
+
| 13 | `@lamalibre/create-lamaste-agent@4.0.0` | provisioner | `lamaste` | Agent provisioner: cert enrollment, service setup. `npx create-lamaste-agent`. Renamed from `install-lamaste-agent` |
|
|
92
|
+
| 14 | `@lamalibre/create-lamaste-desktop@4.0.0` | installer | — | Desktop app installer. `npx create-lamaste-desktop`. Renamed from `install-lamaste-desktop` |
|
|
93
|
+
| 15 | `@lamalibre/create-lamaste-admin@4.0.0` | provisioner | `lamaste` | Admin cert upgrade to hardware-bound. `npx create-lamaste-admin`. Renamed from `install-lamaste-admin` |
|
|
94
|
+
| 16 | `@lamalibre/create-lamaste-e2e@4.0.0` | test infra | — | E2E test MCP server. `npx create-lamaste-e2e`. Renamed from `install-lamaste-e2e-mcp` |
|
|
95
|
+
| 17 | `@lamalibre/feria` | dev tool | — | Dev registry + release runner. **Out of scope — do not touch in this refactor** |
|
|
96
|
+
|
|
97
|
+
### Rename Map (1.x → 2.0.0)
|
|
98
|
+
|
|
99
|
+
| 1.x name | 2.0.0 name | Change type |
|
|
100
|
+
| -------------------------- | ----------------------------------------------------------- | --------------------------------- |
|
|
101
|
+
| `serverd` | `lamalibre-lamaste-serverd` | Renamed |
|
|
102
|
+
| `panel-client` | `lamaste-server-ui` | Merged with `lamaste-admin-panel` |
|
|
103
|
+
| `lamaste-admin-panel` | `lamaste-server-ui` | Merged with `panel-client` |
|
|
104
|
+
| `lamaste-agent-panel` | `lamaste-agent-ui` | Renamed |
|
|
105
|
+
| `lamaste-agent` (monolith) | `lamaste-agent` (CLI) + `lamalibre-lamaste-agentd` (daemon) | Split |
|
|
106
|
+
| `install-lamaste-agent` | `create-lamaste-agent` | Renamed |
|
|
107
|
+
| `install-lamaste-desktop` | `create-lamaste-desktop` | Renamed |
|
|
108
|
+
| `install-lamaste-admin` | `create-lamaste-admin` | Renamed |
|
|
109
|
+
| `install-lamaste-e2e-mcp` | `create-lamaste-e2e` | Renamed |
|
|
110
|
+
| — | `lamaste-server` | New |
|
|
111
|
+
| — | `lamaste` (core lib) | New |
|
|
112
|
+
|
|
113
|
+
### Core Library: Subpath Exports vs Separate Packages
|
|
114
|
+
|
|
115
|
+
The core library uses **subpath exports** to provide domain-specific entry points from a single package:
|
|
116
|
+
|
|
117
|
+
```json
|
|
118
|
+
{
|
|
119
|
+
"name": "@lamalibre/lamaste@4.0.0",
|
|
120
|
+
"exports": {
|
|
121
|
+
".": "./dist/index.js",
|
|
122
|
+
"./agent": "./dist/agent/index.js",
|
|
123
|
+
"./server": "./dist/server/index.js"
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
import { RESERVED_API_PREFIXES, pluginManifestSchema } from '@lamalibre/lamaste@4.0.0';
|
|
130
|
+
import { loadRegistry, loadAgent, isAgentLoaded } from '@lamalibre/lamaste@4.0.0/agent';
|
|
131
|
+
import { createTunnel, rotateCert } from '@lamalibre/lamaste@4.0.0/server';
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Why subpath exports instead of three packages (`lamaste-lib`, `lamaste-lib-agent`, `lamaste-lib-server`):**
|
|
135
|
+
|
|
136
|
+
- One package to version and publish instead of three
|
|
137
|
+
- No circular dependency risk between lib packages
|
|
138
|
+
- Import paths are cleaner and self-documenting
|
|
139
|
+
- TypeScript project references within a single package enforce the same isolation boundaries
|
|
140
|
+
- The `agent` and `server` subpaths can still have separate dependency trees via optional `peerDependencies`
|
|
141
|
+
|
|
142
|
+
**Isolation enforced via TypeScript project references:**
|
|
143
|
+
|
|
144
|
+
- `src/agent/` cannot import from `src/server/` and vice versa
|
|
145
|
+
- `src/index.ts` (shared core) cannot import from either domain
|
|
146
|
+
- Build fails on cross-domain imports — same guarantee as separate packages
|
|
147
|
+
|
|
148
|
+
### Symmetry: Agent Side vs Server Side
|
|
149
|
+
|
|
150
|
+
| Layer | Agent side | Server side |
|
|
151
|
+
| ------------------------ | ----------------------------------------------- | ---------------------------------------------- |
|
|
152
|
+
| **Domain logic** | `@lamalibre/lamaste@4.0.0/agent` | `@lamalibre/lamaste@4.0.0/server` |
|
|
153
|
+
| **Operational CLI** | `lamaste-agent` | `lamaste-server` (new) |
|
|
154
|
+
| **Long-running daemon** | `lamalibre-lamaste-agentd` on :9393 (extracted) | `lamalibre-lamaste-serverd` on :3100 (renamed) |
|
|
155
|
+
| **UI components** | `lamaste-agent-ui` (renamed) | `lamaste-server-ui` (merged) |
|
|
156
|
+
| **Provisioner** | `create-lamaste-agent` (renamed) | `create-lamaste` |
|
|
157
|
+
| **Desktop consumes via** | REST to :9393 / CLI subprocess | REST to :3100 / `curl_panel` |
|
|
158
|
+
|
|
159
|
+
### Desktop: Multi-Target Build
|
|
160
|
+
|
|
161
|
+
`lamaste-desktop` is a single Tauri project that produces multiple build targets:
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
lamaste-desktop/
|
|
165
|
+
├── src/ shared shell (tray, credentials, deep links, process mgmt)
|
|
166
|
+
├── src/agent/ imports lamaste-agent-ui components
|
|
167
|
+
├── src/server/ imports lamaste-server-ui components
|
|
168
|
+
│
|
|
169
|
+
├── target: lamaste-desktop full app (agent + server)
|
|
170
|
+
├── target: lamaste-agent-desktop agent only (tray, local services)
|
|
171
|
+
└── target: lamaste-server-desktop server only (mTLS, cloud provisioning)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
One package, multiple binaries. Tauri feature flags in Cargo + conditional frontend imports. The full app includes both. Focused apps tree-shake to only what they need. Splitting into separate apps is a product decision that doesn't require architecture changes.
|
|
175
|
+
|
|
176
|
+
### Why Separate CLI from Daemon
|
|
177
|
+
|
|
178
|
+
The split applies to both sides — `lamaste-agent` (1.x monolith) splits into `lamaste-agent` (CLI) + `lamalibre-lamaste-agentd` (daemon), matching `lamaste-server` + `lamalibre-lamaste-serverd`:
|
|
179
|
+
|
|
180
|
+
- **Deployment scope.** CLI installs globally (`/usr/local/bin/`). Daemon runs as a system service from `node_modules`. Different install paths, different permissions, different update lifecycles. A CLI bug fix shouldn't require restarting the daemon.
|
|
181
|
+
- **Dependency weight.** The daemon pulls in Fastify, WebSocket, all route handlers. The CLI needs none of that — it imports lib functions directly. On a 512MB VPS or a laptop, not loading Fastify for `lamaste-agent status` matters.
|
|
182
|
+
- **Security surface.** The CLI may run as root (e.g., agent uninstall, service management). The daemon runs as a service user. Separating them means the daemon binary has no root-capable code paths.
|
|
183
|
+
- **Testing.** CLI commands testable without spinning up Fastify. Daemon testable without CLI argument parsing.
|
|
184
|
+
|
|
185
|
+
### `lamaste-agent` CLI (extracted from current lamaste-agent)
|
|
186
|
+
|
|
187
|
+
The current `lamaste-agent` CLI subcommands remain, but the REST API daemon moves to `lamalibre-lamaste-agentd`:
|
|
188
|
+
|
|
189
|
+
```
|
|
190
|
+
lamaste-agent setup # enrollment, cert generation, service config
|
|
191
|
+
lamaste-agent status # agent running state, config summary
|
|
192
|
+
lamaste-agent start / stop / restart # service lifecycle
|
|
193
|
+
lamaste-agent logs [--follow] # agent log tail
|
|
194
|
+
lamaste-agent update # fetch latest plist/unit, restart
|
|
195
|
+
|
|
196
|
+
lamaste-agent plugin install <pkg> # install agent plugin
|
|
197
|
+
lamaste-agent plugin uninstall <name> # remove plugin
|
|
198
|
+
lamaste-agent plugin status # list installed plugins
|
|
199
|
+
|
|
200
|
+
lamaste-agent panel --enable / --disable / --status # agent panel expose
|
|
201
|
+
|
|
202
|
+
lamaste-agent --json <any-command> # NDJSON output for subprocess consumers
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### `lamaste-server` CLI (new package)
|
|
206
|
+
|
|
207
|
+
Absorbs operations currently scattered across standalone scripts, inline route logic, and missing entirely:
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
lamaste-server status # service health, uptime, resource usage
|
|
211
|
+
lamaste-server logs [--follow] # journalctl lamalibre-lamaste-serverd logs
|
|
212
|
+
lamaste-server restart # restart lamalibre-lamaste-serverd service
|
|
213
|
+
|
|
214
|
+
lamaste-server plugins list # installed plugins with status
|
|
215
|
+
lamaste-server plugins install <pkg> # npm install + manifest + registry
|
|
216
|
+
lamaste-server plugins enable <name> # enable plugin
|
|
217
|
+
lamaste-server plugins disable <name> # disable plugin
|
|
218
|
+
lamaste-server plugins uninstall <name>
|
|
219
|
+
|
|
220
|
+
lamaste-server tunnels list # active tunnels
|
|
221
|
+
lamaste-server tunnels create ... # create tunnel (cert → nginx → chisel → state)
|
|
222
|
+
lamaste-server tunnels delete <id>
|
|
223
|
+
|
|
224
|
+
lamaste-server sites list # managed sites
|
|
225
|
+
lamaste-server sites create ... # create site (managed/custom domain)
|
|
226
|
+
lamaste-server sites delete <id>
|
|
227
|
+
|
|
228
|
+
lamaste-server reset-admin # replaces standalone lamaste-reset-admin script
|
|
229
|
+
lamaste-server uninstall # full server teardown (new)
|
|
230
|
+
|
|
231
|
+
lamaste-server certs status # certificate expiry, renewal status
|
|
232
|
+
lamaste-server certs renew # force certificate renewal
|
|
233
|
+
|
|
234
|
+
lamaste-server --json <any-command> # NDJSON output for subprocess consumers
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Rules
|
|
238
|
+
|
|
239
|
+
1. **`lamaste`** (core lib) owns shared contracts: types, constants, schemas, plugin host Fastify plugin, atomic file write helpers. Domain logic in subpath exports (`/agent`, `/server`).
|
|
240
|
+
2. **`lamaste/agent`** owns agent-side business logic: registry CRUD, config I/O, platform paths, service lifecycle, local plugin management, service discovery. Touches `~/.lamalibre/lamaste/` only.
|
|
241
|
+
3. **`lamaste/server`** owns server-side business logic: server plugin lifecycle, mTLS, tunnel/site workflows, access control. Touches `/etc/lamalibre/lamaste/` only.
|
|
242
|
+
4. **Operational CLIs** are thin layers: import their domain subpath, add CLI UX (prompts, progress bars), expose lib operations as subcommands with `--json`. `lamaste-agent` for agent ops, `lamaste-server` for server ops. No Fastify, no HTTP serving.
|
|
243
|
+
5. **Daemons** are thin HTTP layers: `lamalibre-lamaste-serverd` imports `lamaste/server`, handles HTTP/WebSocket only. `lamalibre-lamaste-agentd` imports `lamaste/agent`, serves REST API on :9393 + web SPA. No CLI argument parsing.
|
|
244
|
+
6. **UI packages** are host-agnostic React component libraries: `lamaste-agent-ui` and `lamaste-server-ui`. Each consumer provides its own client implementation (desktop via Tauri invoke, browser via fetch). Each package includes a browser SPA build target.
|
|
245
|
+
7. **Desktop** is a container, not an implementation. It has Rust for credentials, tray, deep links, and process management. All UI comes from `-ui` packages. All logic comes from daemons via REST or CLIs via subprocess. Never reimplements lib logic in Rust.
|
|
246
|
+
8. **Credentials stay in Rust.** macOS Keychain (`security-framework`) and Linux libsecret (`secret-tool`) are legitimately desktop-only. lib/cli accept credentials as env vars or stdin.
|
|
247
|
+
9. **Service lifecycle** (`launchctl`/`systemctl`) lives in `lamaste/agent`. Desktop calls it through the CLI.
|
|
248
|
+
10. **`create-*` packages** are npx one-shot tools. They import from `lamaste` for business logic but add interactive UX (Listr2, prompts, NDJSON progress). Thin wrappers, not logic owners.
|
|
249
|
+
|
|
250
|
+
## Current State: Violation Map
|
|
251
|
+
|
|
252
|
+
### Desktop Reimplements lib in Rust (~60 commands)
|
|
253
|
+
|
|
254
|
+
These operations exist as JavaScript functions in `lamaste-agent/src/lib/` but were rewritten in Rust in `lamaste-desktop/src-tauri/src/`:
|
|
255
|
+
|
|
256
|
+
#### Agent Registry (agents.rs vs registry.js)
|
|
257
|
+
|
|
258
|
+
| Desktop Rust | CLI lib/ equivalent | What it does |
|
|
259
|
+
| ------------------- | --------------------------------------------------- | -------------------------------------- |
|
|
260
|
+
| `get_agents` | `registry.listAgents()` + `service.isAgentLoaded()` | Read agents.json, check service status |
|
|
261
|
+
| `get_agent_status` | `registry.getAgent()` + `service.isAgentLoaded()` | Single agent status |
|
|
262
|
+
| `list_agents` | `registry.listAgents()` | Filter/list agents |
|
|
263
|
+
| `set_current_agent` | `registry.setCurrentAgent()` | Update current_label in agents.json |
|
|
264
|
+
| `remove_agent` | `registry.removeAgent()` | Delete from registry + data dir |
|
|
265
|
+
| `get_agent_logs` | `platform.agentLogFile()` + fs read | Read log files |
|
|
266
|
+
| `get_agent_config` | `config.loadAgentConfig()` | Read per-agent config |
|
|
267
|
+
| `start_agent` | `service.loadAgent()` | launchctl load / systemctl start |
|
|
268
|
+
| `stop_agent` | `service.unloadAgent()` | launchctl unload / systemctl stop |
|
|
269
|
+
| `restart_agent` | `service.unloadAgent()` + `service.loadAgent()` | Restart service |
|
|
270
|
+
|
|
271
|
+
#### Local Plugins (local_plugins.rs vs local-plugins.js)
|
|
272
|
+
|
|
273
|
+
| Desktop Rust | CLI lib/ equivalent | What it does |
|
|
274
|
+
| ------------------------------ | ---------------------------------------- | -------------------------------------------- |
|
|
275
|
+
| `get_curated_plugins` | Hardcoded list (both sides) | Return available plugins |
|
|
276
|
+
| `get_local_plugins` | `localPlugins.readLocalPluginRegistry()` | Read plugins.json |
|
|
277
|
+
| `local_install_plugin` | `localPlugins.installLocalPlugin()` | npm install + manifest read + registry write |
|
|
278
|
+
| `enable_local_plugin` | `localPlugins.enableLocalPlugin()` | Update status in registry |
|
|
279
|
+
| `disable_local_plugin` | `localPlugins.disableLocalPlugin()` | Update status in registry |
|
|
280
|
+
| `get_local_plugin_host_status` | `localHostService.isHostLoaded()` | Check launchd/systemd status |
|
|
281
|
+
| `start_local_plugin_host` | `localHostService.loadHostService()` | Start service |
|
|
282
|
+
| `stop_local_plugin_host` | `localHostService.unloadHostService()` | Stop service |
|
|
283
|
+
|
|
284
|
+
#### Legacy Agent Operations (commands.rs vs config.js + service.js)
|
|
285
|
+
|
|
286
|
+
| Desktop Rust | CLI lib/ equivalent | What it does |
|
|
287
|
+
| --------------- | ------------------------------------------------------ | ----------------------------- |
|
|
288
|
+
| `get_status` | `config.loadAgentConfig()` + `service.isAgentLoaded()` | Agent running state |
|
|
289
|
+
| `get_config` | `config.loadAgentConfig()` | Read config |
|
|
290
|
+
| `get_panel_url` | `config.loadAgentConfig().panelUrl` | Extract URL |
|
|
291
|
+
| `get_logs` | `platform.agentLogFile()` + fs read | Read logs |
|
|
292
|
+
| `update_agent` | `update` command logic | Fetch plist, rewrite, restart |
|
|
293
|
+
|
|
294
|
+
### Business Logic Only in Rust (no lib at all)
|
|
295
|
+
|
|
296
|
+
These operations were written directly in Rust with no JavaScript equivalent. They need to be written in `lamaste/agent` first, then exposed through `lamaste-agent` CLI.
|
|
297
|
+
|
|
298
|
+
#### Service Discovery (services.rs) → lamaste/agent
|
|
299
|
+
|
|
300
|
+
| Desktop Rust | What it does |
|
|
301
|
+
| ----------------------- | --------------------------------------- |
|
|
302
|
+
| `scan_services` | `which`/`pgrep`/`lsof`/Docker detection |
|
|
303
|
+
| `get_service_registry` | Read/generate services.json |
|
|
304
|
+
| `add_custom_service` | Write to services.json |
|
|
305
|
+
| `remove_custom_service` | Remove from services.json |
|
|
306
|
+
|
|
307
|
+
#### Server Registry (cloud.rs) → lamaste/agent
|
|
308
|
+
|
|
309
|
+
| Desktop Rust | What it does |
|
|
310
|
+
| --------------------- | ------------------------------------------------ |
|
|
311
|
+
| `get_servers` | Read servers.json |
|
|
312
|
+
| `set_active_server` | Update active flag in servers.json |
|
|
313
|
+
| `delete_server` | Remove entry from servers.json |
|
|
314
|
+
| `get_storage_servers` | Read storage-servers.json |
|
|
315
|
+
| `get_spaces_regions` | Hardcoded region list (already in lamaste-cloud) |
|
|
316
|
+
|
|
317
|
+
#### Admin Cert & Mode Management (mode.rs) → lamaste/agent
|
|
318
|
+
|
|
319
|
+
| Desktop Rust | What it does |
|
|
320
|
+
| ------------------- | --------------------------------------------------------------------------------- |
|
|
321
|
+
| `set_server_mode` | Update activeMode in servers.json |
|
|
322
|
+
| `get_server_mode` | Read activeMode from servers.json |
|
|
323
|
+
| `has_admin_cert` | Check adminAuth in servers.json |
|
|
324
|
+
| `import_admin_cert` | Copy P12, store creds, update registry (file ops → lamaste/agent, creds → Rust) |
|
|
325
|
+
| `remove_admin_cert` | Delete P12, clear creds, update registry (file ops → lamaste/agent, creds → Rust) |
|
|
326
|
+
|
|
327
|
+
### Agent CLI + Daemon Are One Monolith
|
|
328
|
+
|
|
329
|
+
`lamaste-agent` (1.x) bundles CLI commands, REST API daemon (:9393), and business logic in one package. After refactor:
|
|
330
|
+
|
|
331
|
+
| Current location | 2.0.0 target |
|
|
332
|
+
| ---------------------------------------------------------------- | ------------------------------------------------------------ |
|
|
333
|
+
| `lamaste-agent/src/lib/` (business logic) | `lamaste` (`/agent` subpath) |
|
|
334
|
+
| `lamaste-agent/src/commands/` (CLI) | `lamaste-agent` (CLI-only package) |
|
|
335
|
+
| `lamaste-agent/src/lib/serverd.js` (Fastify daemon) | `lamalibre-lamaste-agentd` |
|
|
336
|
+
| `lamaste-agent/src/lib/panel-api-routes.js` (REST routes) | `lamalibre-lamaste-agentd` |
|
|
337
|
+
| `lamaste-agent/src/lib/agent-plugin-router.js` (plugin mounting) | `lamalibre-lamaste-agentd` (uses plugin host from `lamaste`) |
|
|
338
|
+
| `lamaste-agent/panel-dist/` (SPA assets) | `lamalibre-lamaste-agentd` (built from `lamaste-agent-ui`) |
|
|
339
|
+
|
|
340
|
+
### Server Has No Operational CLI
|
|
341
|
+
|
|
342
|
+
These operations currently have no terminal interface or exist only as standalone scripts:
|
|
343
|
+
|
|
344
|
+
| Operation | Current state | 2.0.0 target |
|
|
345
|
+
| ------------------- | --------------------------------------- | ----------------------------- |
|
|
346
|
+
| Server status | Browser panel only | `lamaste-server status` |
|
|
347
|
+
| Server logs | `journalctl` manually | `lamaste-server logs` |
|
|
348
|
+
| Plugin management | Browser panel or REST API only | `lamaste-server plugins ...` |
|
|
349
|
+
| Tunnel management | Browser panel or REST API only | `lamaste-server tunnels ...` |
|
|
350
|
+
| Site management | Browser panel or REST API only | `lamaste-server sites ...` |
|
|
351
|
+
| Reset admin | Standalone `lamaste-reset-admin` script | `lamaste-server reset-admin` |
|
|
352
|
+
| Uninstall | Doesn't exist | `lamaste-server uninstall` |
|
|
353
|
+
| Certificate status | Browser panel only | `lamaste-server certs status` |
|
|
354
|
+
| Certificate renewal | Certbot cron only | `lamaste-server certs renew` |
|
|
355
|
+
|
|
356
|
+
### Desktop Correctly Delegates (~120 commands)
|
|
357
|
+
|
|
358
|
+
`admin_commands.rs` correctly delegates all server-panel operations through the REST API. These are fine:
|
|
359
|
+
|
|
360
|
+
- All user management → `curl_panel` → lamalibre-lamaste-serverd `/api/users`
|
|
361
|
+
- All site management → `curl_panel` → lamalibre-lamaste-serverd `/api/sites`
|
|
362
|
+
- All certificate ops → `curl_panel` → lamalibre-lamaste-serverd `/api/certs`
|
|
363
|
+
- All plugin management → `curl_panel` → lamalibre-lamaste-serverd `/api/plugins`
|
|
364
|
+
- All ticket operations → `curl_panel` → lamalibre-lamaste-serverd `/api/tickets`
|
|
365
|
+
- All storage operations → `curl_panel` → lamalibre-lamaste-serverd `/api/storage`
|
|
366
|
+
- All 2FA operations → `curl_panel` → lamalibre-lamaste-serverd `/api/settings/2fa`
|
|
367
|
+
|
|
368
|
+
### Desktop Correctly Desktop-Only (~25 commands)
|
|
369
|
+
|
|
370
|
+
These legitimately belong in Rust:
|
|
371
|
+
|
|
372
|
+
- **Credentials**: macOS Keychain / Linux libsecret access
|
|
373
|
+
- **Tray**: System tray icon state management
|
|
374
|
+
- **Deep links**: `lamalibre://` URL scheme handling
|
|
375
|
+
- **Browser launch**: Open external URLs
|
|
376
|
+
- **P12 password storage**: OS credential store operations
|
|
377
|
+
- **2FA session**: In-process session token (desktop-specific, not persisted)
|
|
378
|
+
|
|
379
|
+
### Business Logic Locked in Route Handlers (serverd → lamalibre-lamaste-serverd)
|
|
380
|
+
|
|
381
|
+
These operations are in route handlers instead of lib. Should move to `lamaste/server` so both `lamalibre-lamaste-serverd` and `lamaste-server` CLI can use them.
|
|
382
|
+
|
|
383
|
+
| Route File | What's inline | Lines |
|
|
384
|
+
| ------------------------- | ----------------------------------------------------------------------------- | ----- |
|
|
385
|
+
| `tunnels.js` | 4-step tunnel creation workflow (cert → nginx → chisel → state) with rollback | ~170 |
|
|
386
|
+
| `sites.js` | Site creation branching (managed vs custom domain), DNS validation | ~170 |
|
|
387
|
+
| `onboarding/provision.js` | Full provisioning orchestrator with progress streaming | ~250 |
|
|
388
|
+
| `settings.js` | Rate limiting (in-memory IP throttle for 2FA) | ~70 |
|
|
389
|
+
| `onboarding/dns.js` | DNS A-record resolution and diagnostics | ~60 |
|
|
390
|
+
| `logs.js` | WebSocket journalctl stream with backpressure | ~100 |
|
|
391
|
+
|
|
392
|
+
## Shared Infrastructure Duplication
|
|
393
|
+
|
|
394
|
+
### Plugin Hosting (three independent implementations) → lamaste
|
|
395
|
+
|
|
396
|
+
| Server | File | What it does |
|
|
397
|
+
| --------------------------------- | ---------------------------------------------- | ------------------------------------------------------- |
|
|
398
|
+
| lamalibre-lamaste-serverd (:3100) | `serverd/src/routes/plugin-router.js` | CJS/ESM plugin load, bundle serve, 503 disabled handler |
|
|
399
|
+
| lamalibre-lamaste-agentd (:9393) | `lamaste-agent/src/lib/agent-plugin-router.js` | Same logic, different auth |
|
|
400
|
+
| Local host (:9293) | `lamaste-agent/src/lib/local-plugin-host.js` | Same logic, no auth |
|
|
401
|
+
|
|
402
|
+
Becomes a single Fastify plugin in `lamaste`, configured per server with auth strategy and data directory.
|
|
403
|
+
|
|
404
|
+
### Plugin Manifest Validation (three copies) → lamaste
|
|
405
|
+
|
|
406
|
+
| Package | File | What it validates |
|
|
407
|
+
| ------------- | -------------------------- | ----------------------------------- |
|
|
408
|
+
| serverd | `src/lib/plugins.js` | `lamaste-plugin.json` schema |
|
|
409
|
+
| lamaste-agent | `src/lib/agent-plugins.js` | Same schema, same Zod rules |
|
|
410
|
+
| lamaste-agent | `src/lib/local-plugins.js` | Same schema, `modes` filter differs |
|
|
411
|
+
|
|
412
|
+
Becomes a single Zod schema exported from `lamaste`.
|
|
413
|
+
|
|
414
|
+
### Plugin Lifecycle (three copies) → lamaste
|
|
415
|
+
|
|
416
|
+
| Package | File | Context |
|
|
417
|
+
| ------------- | -------------------------- | --------------------------------------------------------------- |
|
|
418
|
+
| serverd | `src/lib/plugins.js` | Server plugins in `/etc/lamalibre/lamaste/plugins/` |
|
|
419
|
+
| lamaste-agent | `src/lib/agent-plugins.js` | Agent plugins in `~/.lamalibre/lamaste/agents/<label>/plugins/` |
|
|
420
|
+
| lamaste-agent | `src/lib/local-plugins.js` | Local plugins in `~/.lamalibre/local/plugins/` |
|
|
421
|
+
|
|
422
|
+
All three implement: install (npm + manifest + registry), uninstall, enable, disable, update, bundle read. Differs only in data directory, mode filter, and max plugin cap. Becomes a single parameterized lifecycle module in `lamaste`.
|
|
423
|
+
|
|
424
|
+
### PluginLoader React Component (two copies) → shared component in lamaste-server-ui
|
|
425
|
+
|
|
426
|
+
| Package | File | Mechanism |
|
|
427
|
+
| ------------------- | ------------------------------------------ | ----------------------------- |
|
|
428
|
+
| lamaste-admin-panel | `src/components/PluginLoader.jsx` | `<script>` tag, admin theme |
|
|
429
|
+
| lamaste-agent-panel | `src/pages/Plugins.jsx` (AgentPluginPanel) | `new Function()`, agent theme |
|
|
430
|
+
|
|
431
|
+
Both implement `window.__lamalibrePlugins[name]` mount/unmount protocol. Becomes one component with theme/fetch as props, shared between `lamaste-server-ui` and `lamaste-agent-ui`.
|
|
432
|
+
|
|
433
|
+
### Client Interfaces (JSDoc-only, no shared contract) → lamaste
|
|
434
|
+
|
|
435
|
+
| Interface | Methods | Implementations | Typed? |
|
|
436
|
+
| ----------- | ------- | ------------------------------------------------ | ---------- |
|
|
437
|
+
| AdminClient | ~130 | `web-admin-client.js`, `desktop-admin-client.js` | No (JSDoc) |
|
|
438
|
+
| AgentClient | ~29 | `web-agent-client.js`, `desktop-agent-client.js` | No (JSDoc) |
|
|
439
|
+
|
|
440
|
+
A method signature mismatch between web and desktop surfaces only at runtime. Becomes TypeScript interfaces in `lamaste`.
|
|
441
|
+
|
|
442
|
+
### Constants & Reserved Names (duplicated) → lamaste
|
|
443
|
+
|
|
444
|
+
| Constant | Current Locations |
|
|
445
|
+
| --------------------- | ------------------------------------------------------------------------------------------------------------------ |
|
|
446
|
+
| Reserved API prefixes | `serverd/src/lib/constants.js`, `lamaste-agent/src/lib/agent-plugins.js`, `lamaste-agent/src/lib/local-plugins.js` |
|
|
447
|
+
| Curated plugin list | `lamaste-desktop/src-tauri/src/local_plugins.rs`, `lamaste-agent/src/lib/local-plugins.js` |
|
|
448
|
+
| Capability names | `serverd/src/lib/mtls.js`, inline in route handlers |
|
|
449
|
+
|
|
450
|
+
All move to `lamaste` (core lib).
|
|
451
|
+
|
|
452
|
+
## Legacy Code Paths
|
|
453
|
+
|
|
454
|
+
### Single-Agent vs Multi-Agent (desktop)
|
|
455
|
+
|
|
456
|
+
`desktop-agent-client.js` branches on whether `label` exists:
|
|
457
|
+
|
|
458
|
+
```javascript
|
|
459
|
+
getStatus: () => (label ? invoke('get_agent_status', { label }) : invoke('get_status')); // legacy single-agent
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
The Rust backend has both `commands.rs` (legacy) and `agents.rs` (multi-agent). After refactor, `commands.rs` removed entirely. Multi-agent is the only path.
|
|
463
|
+
|
|
464
|
+
### Committed Build Artifact (panel-dist/)
|
|
465
|
+
|
|
466
|
+
`lamaste-agent-panel` builds to `dist-web/`, which is manually copied into `lamaste-agent/panel-dist/` and committed to git. After refactor, `lamaste-agent-ui` builds the SPA, `lamalibre-lamaste-agentd` consumes it via build script. No committed artifacts.
|
|
467
|
+
|
|
468
|
+
## Execution Plan
|
|
469
|
+
|
|
470
|
+
### Phase 1: Create `lamaste` core library
|
|
471
|
+
|
|
472
|
+
Create `packages/lamaste/` (TypeScript) with subpath exports:
|
|
473
|
+
|
|
474
|
+
**Root (`@lamalibre/lamaste@4.0.0`):**
|
|
475
|
+
|
|
476
|
+
- Types: `AdminClient`, `AgentClient` TypeScript interfaces, plugin manifest types, capability types
|
|
477
|
+
- Constants: Reserved API prefixes, curated plugin list, capability names
|
|
478
|
+
- Schemas: Plugin manifest Zod schema (single source of truth)
|
|
479
|
+
- Plugin Host: Fastify plugin for plugin route mounting, bundle serving, disabled handler (unified from three routers)
|
|
480
|
+
- File Helpers: Atomic write (temp → fsync → rename), promise-chain mutex
|
|
481
|
+
|
|
482
|
+
**Agent subpath (`@lamalibre/lamaste@4.0.0/agent`):**
|
|
483
|
+
|
|
484
|
+
- Platform: Path helpers, platform detection (from `platform.js`)
|
|
485
|
+
- Registry: Agent registry CRUD, label validation, legacy migration (from `registry.js`)
|
|
486
|
+
- Config: Agent config I/O (from `config.js`)
|
|
487
|
+
- Service: Start/stop/status for launchctl and systemd (from `service.js`, `launchctl.js`)
|
|
488
|
+
- Plugins: Agent and local plugin lifecycle (unified — uses shared schema/lifecycle from root)
|
|
489
|
+
- Local Host Service: Service config generation and lifecycle (from `local-host-service.js`)
|
|
490
|
+
- Service Discovery: Port scanning, process detection, Docker discovery (new — from Rust `services.rs`)
|
|
491
|
+
- Server Registry: servers.json and storage-servers.json CRUD (new — from Rust `cloud.rs`)
|
|
492
|
+
- Mode: Server mode and admin cert file operations (new — from Rust `mode.rs`)
|
|
493
|
+
|
|
494
|
+
**Server subpath (`@lamalibre/lamaste@4.0.0/server`):**
|
|
495
|
+
|
|
496
|
+
- Plugins: Server-side plugin lifecycle (uses shared schema from root)
|
|
497
|
+
- Tunnels: Tunnel creation workflow with rollback (from `routes/tunnels.js`)
|
|
498
|
+
- Sites: Site creation with managed/custom domain branching (from `routes/sites.js`)
|
|
499
|
+
- mTLS: Certificate management and rotation (from `lib/mtls.js`)
|
|
500
|
+
- Access Control: Authelia access control sync (from `lib/access-control-sync.js`)
|
|
501
|
+
- Provisioning: Provisioning orchestrator (from `routes/onboarding/provision.js`)
|
|
502
|
+
|
|
503
|
+
### Phase 2: CLIs and daemons consume core library
|
|
504
|
+
|
|
505
|
+
#### 2a: Extract `lamalibre-lamaste-agentd` from `lamaste-agent`
|
|
506
|
+
|
|
507
|
+
Split the current monolithic `lamaste-agent` into two packages:
|
|
508
|
+
|
|
509
|
+
- **`lamaste-agent`** (CLI only): keeps command handlers, CLI entry point, `--json` NDJSON support. Imports from `lamaste/agent`. No Fastify.
|
|
510
|
+
- **`lamalibre-lamaste-agentd`** (daemon only): gets Fastify REST API, plugin router, SPA serving. Imports from `lamaste/agent`. No CLI argument parsing.
|
|
511
|
+
|
|
512
|
+
Both import business logic from `lamaste/agent` — neither contains it.
|
|
513
|
+
|
|
514
|
+
#### 2b: `lamaste-agent` CLI consumes `lamaste/agent`
|
|
515
|
+
|
|
516
|
+
Refactor the extracted CLI:
|
|
517
|
+
|
|
518
|
+
- Command handlers become thin orchestrators calling `lamaste/agent` functions
|
|
519
|
+
- `src/lib/` modules removed (logic now in core library)
|
|
520
|
+
- `--json` NDJSON output on all commands
|
|
521
|
+
|
|
522
|
+
#### 2c: `lamalibre-lamaste-agentd` consumes `lamaste/agent`
|
|
523
|
+
|
|
524
|
+
Refactor the extracted agent daemon:
|
|
525
|
+
|
|
526
|
+
- REST API routes become thin HTTP handlers calling `lamaste/agent` functions
|
|
527
|
+
- Uses plugin host Fastify plugin from `lamaste`
|
|
528
|
+
- Serves web SPA built from `lamaste-agent-ui`
|
|
529
|
+
|
|
530
|
+
Add missing REST API endpoints for operations desktop currently does in Rust:
|
|
531
|
+
|
|
532
|
+
- `GET /api/agents` — list agents with status
|
|
533
|
+
- `POST /api/agents/:label/start` / `stop` / `restart`
|
|
534
|
+
- `PATCH /api/agents/current` — set current agent
|
|
535
|
+
- `DELETE /api/agents/:label` — remove agent
|
|
536
|
+
- `GET /api/local-plugins` / `POST /install` / `POST /:name/enable` / etc.
|
|
537
|
+
- `GET /api/local-host/status` / `POST /start` / `POST /stop`
|
|
538
|
+
- `GET /api/services/scan` — service discovery
|
|
539
|
+
- `POST /api/services/custom` — add custom service
|
|
540
|
+
|
|
541
|
+
#### 2d: Create `lamaste-server` CLI (new package)
|
|
542
|
+
|
|
543
|
+
Create `packages/lamaste-server/` — thin CLI that imports from `lamaste/server`:
|
|
544
|
+
|
|
545
|
+
- Subcommands: `status`, `logs`, `restart`, `plugins`, `tunnels`, `sites`, `certs`, `reset-admin`, `uninstall`
|
|
546
|
+
- `--json` flag for NDJSON output on all commands
|
|
547
|
+
- Absorbs `lamaste-reset-admin` standalone script
|
|
548
|
+
- Installed globally on the server during provisioning (`create-lamaste` adds it)
|
|
549
|
+
|
|
550
|
+
#### 2e: Rename `serverd` to `lamalibre-lamaste-serverd`, consume `lamaste/server`
|
|
551
|
+
|
|
552
|
+
Rename and refactor:
|
|
553
|
+
|
|
554
|
+
- Plugin manifest schema from `lamaste`
|
|
555
|
+
- Plugin host Fastify plugin from `lamaste`
|
|
556
|
+
- Constants and types from `lamaste`
|
|
557
|
+
- Server plugin lifecycle from `lamaste/server`
|
|
558
|
+
- Extract inline route logic to `lamaste/server` functions
|
|
559
|
+
- Routes become thin HTTP handlers
|
|
560
|
+
|
|
561
|
+
#### 2f: Merge `panel-client` + `lamaste-admin-panel` into `lamaste-server-ui`
|
|
562
|
+
|
|
563
|
+
- Server/admin React components + browser SPA build in one package
|
|
564
|
+
- Rename `lamaste-agent-panel` to `lamaste-agent-ui`
|
|
565
|
+
- Unify PluginLoader into a single shared component
|
|
566
|
+
|
|
567
|
+
#### 2g: Rename `create-*` and `install-*` packages
|
|
568
|
+
|
|
569
|
+
- `install-lamaste-agent` → `create-lamaste-agent`
|
|
570
|
+
- `install-lamaste-desktop` → `create-lamaste-desktop`
|
|
571
|
+
- `install-lamaste-admin` → `create-lamaste-admin`
|
|
572
|
+
- `install-lamaste-e2e-mcp` → `create-lamaste-e2e`
|
|
573
|
+
- Business logic (CSR generation, cert file ops) moves from these packages into `lamaste/agent`
|
|
574
|
+
- Packages become thin CLI wrappers with interactive UX
|
|
575
|
+
|
|
576
|
+
### Phase 3: Desktop drops Rust reimplementations
|
|
577
|
+
|
|
578
|
+
Replace Rust business logic with REST API calls to `lamalibre-lamaste-agentd` (:9393) or CLI subprocess spawns of `lamaste-agent`:
|
|
579
|
+
|
|
580
|
+
| Current Rust | Replacement | Via |
|
|
581
|
+
| ---------------------------------- | ----------------------------------- | ---------------------- |
|
|
582
|
+
| `agents.rs` registry CRUD | `lamalibre-lamaste-agentd` REST API | REST to :9393 |
|
|
583
|
+
| `agents.rs` service start/stop | `lamalibre-lamaste-agentd` REST API | REST to :9393 |
|
|
584
|
+
| `local_plugins.rs` all operations | `lamalibre-lamaste-agentd` REST API | REST to :9393 or :9293 |
|
|
585
|
+
| `commands.rs` legacy operations | Remove entirely | Multi-agent only |
|
|
586
|
+
| `services.rs` scan/registry | `lamalibre-lamaste-agentd` REST API | REST to :9393 |
|
|
587
|
+
| `mode.rs` server mode | `lamaste-agent` CLI subprocess | subprocess `--json` |
|
|
588
|
+
| `cloud.rs` server/storage registry | `lamaste-agent` CLI subprocess | subprocess `--json` |
|
|
589
|
+
|
|
590
|
+
Rust files that remain:
|
|
591
|
+
|
|
592
|
+
- `api.rs` — curl helpers (still needed for lamalibre-lamaste-serverd mTLS calls)
|
|
593
|
+
- `admin_commands.rs` — REST API delegation to lamalibre-lamaste-serverd (already correct)
|
|
594
|
+
- `credentials.rs` — OS credential store (desktop-only)
|
|
595
|
+
- `tray.rs` — system tray (desktop-only)
|
|
596
|
+
- `user_access.rs` — deep link handling (desktop-only)
|
|
597
|
+
- `local_install.rs` — pkexec subprocess (desktop-only)
|
|
598
|
+
- `upgrade_admin.rs` — CLI subprocess (already correct pattern)
|
|
599
|
+
|
|
600
|
+
### Phase 4: Cleanup
|
|
601
|
+
|
|
602
|
+
- Remove `commands.rs` (legacy single-agent)
|
|
603
|
+
- Remove legacy branching in `desktop-agent-client.js`
|
|
604
|
+
- No more committed `panel-dist/` — built from `lamaste-agent-ui` as part of `lamalibre-lamaste-agentd` build
|
|
605
|
+
- Remove standalone `lamaste-reset-admin` script (absorbed into `lamaste-server reset-admin`)
|
|
606
|
+
- Add TypeScript interface checks to CI (web and desktop clients must implement the full interface)
|
|
607
|
+
- Verify isolation: `lamaste/agent` cannot import `lamaste/server` and vice versa
|
|
608
|
+
- Verify CLI packages have no Fastify dependency
|
|
609
|
+
- Verify daemon packages have no CLI argument parsing dependency
|
|
610
|
+
- All packages at 2.0.0, published to Feria for validation before npm
|
|
611
|
+
- Feria itself is out of scope — do not modify, will be addressed separately
|
|
612
|
+
|
|
613
|
+
## Reference: What Already Works
|
|
614
|
+
|
|
615
|
+
`lamaste-cloud` follows the ideal pattern and should serve as the template:
|
|
616
|
+
|
|
617
|
+
```
|
|
618
|
+
lamaste-cloud/src/lib/ → Business logic (provisioner, discoverer, updater)
|
|
619
|
+
lamaste-cloud/src/cli.js → Thin CLI with --json NDJSON output
|
|
620
|
+
lamaste-desktop/cloud.rs → Spawns CLI subprocess, parses NDJSON events
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
This is what every domain in the codebase should look like. After refactor:
|
|
624
|
+
|
|
625
|
+
```
|
|
626
|
+
lamaste/src/ → Shared types, constants, schemas, plugin host
|
|
627
|
+
lamaste/src/agent/ → Agent business logic (registry, service, plugins)
|
|
628
|
+
lamaste/src/server/ → Server business logic (mTLS, tunnels, sites, plugins)
|
|
629
|
+
|
|
630
|
+
lamaste-agent/src/ → Thin agent CLI (no Fastify)
|
|
631
|
+
lamaste-agentd/src/ → Agent REST API daemon on :9393 (no CLI)
|
|
632
|
+
lamaste-agent-ui/src/ → Agent React components + browser SPA
|
|
633
|
+
|
|
634
|
+
lamaste-server/src/ → Thin server CLI (no Fastify)
|
|
635
|
+
lamaste-serverd/src/ → Server REST API daemon on :3100 (no CLI)
|
|
636
|
+
lamaste-server-ui/src/ → Server/admin React components + browser SPA
|
|
637
|
+
|
|
638
|
+
lamaste-desktop/src-tauri/ → Tauri shell (credentials, tray, deep links — no business logic)
|
|
639
|
+
lamaste-desktop/src/agent/ → Imports lamaste-agent-ui
|
|
640
|
+
lamaste-desktop/src/server/ → Imports lamaste-server-ui
|
|
641
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=boot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boot.d.ts","sourceRoot":"","sources":["../src/boot.ts"],"names":[],"mappings":""}
|