@alfe.ai/gateway 0.9.5 → 0.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # @alfe.ai/gateway
2
2
 
3
- Local gateway daemon for Alfe — the always-on control plane for agent integrations.
3
+ Local gateway daemon for Alfe — the always-on control plane between an agent VM,
4
+ its runtime, and Alfe cloud.
4
5
 
5
6
  ## Overview
6
7
 
@@ -8,23 +9,24 @@ The gateway daemon is a standalone Node.js process that:
8
9
 
9
10
  - Maintains a persistent WebSocket connection to Alfe cloud (`@alfe/gateway-service` on Fly.io)
10
11
  - Exposes a Unix socket at `~/.alfe/gateway.sock` for local plugin IPC
11
- - Translates between the cloud protocol and local IPC protocol
12
- - Survives OpenClaw restarts — it's the always-on bridge between cloud and agent
13
- - Queues commands when plugins are offline (5min TTL)
12
+ - Reconciles integrations and state-shaped runtime config from full cloud snapshots
13
+ - Supervises the selected runtime (`openclaw`, `hermes`, or `claude-code`)
14
+ - Hosts the local AI proxy and MCP bundler
15
+ - Survives runtime restarts and reports lifecycle/health back to cloud
14
16
 
15
17
  ## Architecture
16
18
 
17
19
  ```
18
- Alfe Cloud ←—— control WS ——→ @alfe.ai/gateway (daemon, always running)
19
- ↕ IPC (~/.alfe/gateway.sock)
20
- @alfe.ai/openclaw (OpenClaw plugin, Phase 2)
21
-
22
- OpenClaw process
20
+ Alfe Cloud ←—— control WS ——→ @alfe.ai/gateway (daemon)
21
+ ├── runtime supervisor → OpenClaw/Hermes/Claude host
22
+ ├── integration reconciliation
23
+ ├── local AI proxy + MCP bundler
24
+ └── IPC (~/.alfe/gateway.sock) ← runtime plugins/CLI
23
25
  ```
24
26
 
25
27
  ## Prerequisites
26
28
 
27
- 1. Run `alfe login` to configure your API key in `~/.alfe/config.toml`
29
+ 1. Run `alfe setup` (or managed provisioning) to configure agent identity
28
30
  2. Node.js 22+
29
31
  3. pnpm
30
32
 
@@ -58,8 +60,8 @@ alfe doctor
58
60
  ### Via standalone binary
59
61
 
60
62
  ```bash
61
- # Start daemon
62
- alfe-gateway daemon
63
+ # Start daemon in foreground
64
+ alfe-gateway start
63
65
 
64
66
  # Status
65
67
  alfe-gateway status
@@ -79,7 +81,7 @@ Plugins connect to `~/.alfe/gateway.sock` and speak newline-delimited JSON:
79
81
 
80
82
  ### Response (daemon → plugin)
81
83
  ```json
82
- { "id": "uuid", "ok": true, "payload": { "status": "registered", "daemonVersion": "0.1.0", "protocolVersion": 1 } }
84
+ { "id": "uuid", "ok": true, "payload": { "status": "registered", "daemonVersion": "<current CLI version>", "protocolVersion": 1 } }
83
85
  ```
84
86
 
85
87
  ### Event (daemon → plugin)
@@ -87,21 +89,21 @@ Plugins connect to `~/.alfe/gateway.sock` and speak newline-delimited JSON:
87
89
  { "type": "event", "event": "cloud.status", "payload": { "connected": true } }
88
90
  ```
89
91
 
90
- ### Phase 1 Methods
92
+ ### Current methods
91
93
 
92
94
  | Direction | Method | Description |
93
95
  |-----------|--------|-------------|
94
- | Daemon→Plugin | `integration.install` | Install an integration |
95
- | Daemon→Plugin | `integration.remove` | Remove an integration |
96
- | Daemon→Plugin | `integration.configure` | Update integration config |
97
- | Daemon→Plugin | `integration.health` | Check integration health |
98
- | Daemon→Plugin | `integration.activate` | Activate an installed integration |
99
- | Daemon→Plugin | `integration.deactivate` | Deactivate a running integration |
100
- | Daemon→Plugin | `integration.list` | List installed integrations |
96
+ | Daemon→Plugin | `runtime.activity` | Probe whether a chat turn is in flight before a planned restart |
101
97
  | Plugin→Daemon | `register` | Register plugin with daemon |
102
98
  | Plugin→Daemon | `status` | Get daemon health status |
103
99
  | Plugin→Daemon | `integration.list` | List known integrations |
104
100
  | Plugin→Daemon | `integration.report` | Report integration status |
101
+ | Plugin→Daemon | `mcp.list_tools` / `mcp.call_tool` | Inspect or invoke bundled MCP tools |
102
+ | Plugin→Daemon | `mcp.list_servers` / `mcp.add_server` / `mcp.remove_server` | Manage local MCP servers |
103
+
104
+ IPC is owner-only, newline-delimited JSON. Requests must contain non-empty
105
+ `id`/`method` fields and an object `params`; individual messages are capped at
106
+ 1 MiB.
105
107
 
106
108
  ## File Locations
107
109
 
@@ -113,13 +115,15 @@ Plugins connect to `~/.alfe/gateway.sock` and speak newline-delimited JSON:
113
115
  | Logs | `~/.alfe/logs/gateway.log` |
114
116
  | launchd plist | `~/Library/LaunchAgents/ai.alfe.gateway.plist` |
115
117
  | systemd unit | `~/.config/systemd/user/alfe-gateway.service` |
118
+ | managed systemd environment | `~/.alfe/gateway.env` (or `/etc/alfe/gateway.env` for root) |
116
119
 
117
120
  ## Security
118
121
 
119
122
  - Socket file is `chmod 0600` (owner-only access)
120
- - PID file prevents multiple daemon instances
121
- - Secrets pass through in-memory only never persisted to disk
122
- - Auth via user's `api_key` from `~/.alfe/config.toml`
123
+ - PID ownership is verified against the live process command before signals are sent
124
+ - Managed systemd credentials are stored in an owner-only (`0600`) environment file, not the unit text
125
+ - Credential fragments are never logged
126
+ - Auth uses the agent API key from managed environment or `~/.alfe/config.toml`
123
127
 
124
128
  ## Development
125
129
 
@@ -128,6 +132,8 @@ Plugins connect to `~/.alfe/gateway.sock` and speak newline-delimited JSON:
128
132
  pnpm install
129
133
  pnpm --filter @alfe.ai/gateway build
130
134
  pnpm --filter @alfe.ai/gateway test
135
+ pnpm --filter @alfe.ai/gateway lint
136
+ pnpm --filter @alfe.ai/gateway typecheck
131
137
 
132
138
  # Dev mode (auto-restart on changes)
133
139
  pnpm --filter @alfe.ai/gateway dev
@@ -145,22 +151,15 @@ The daemon speaks the following message types with the cloud gateway service:
145
151
  | Outbound | `COMMAND_ACK` | Daemon reports command result |
146
152
  | Inbound | `DESIRED_STATE` | Cloud pushes desired integration state |
147
153
  | Outbound | `RECONCILIATION_REPORT` | Daemon reports reconciliation results |
154
+ | Outbound | `COMMANDS_AVAILABLE` | Daemon advertises integration commands |
148
155
  | Inbound | `PING` | Cloud heartbeat |
149
156
  | Outbound | `PONG` | Daemon heartbeat response |
150
157
 
151
- See `src/protocol.ts` for full type definitions.
152
-
153
- ## Completed
154
-
155
- - `@alfe.ai/openclaw` plugin connecting via IPC (`packages/openclaw/`)
156
- - Integration manifest spec (`packages/integration-manifest/`)
157
- - Integration registry — now DynamoDB-backed via `services/integrations/`
158
- - Reconciliation engine (`src/reconciliation.ts`) — converges local state to cloud desired state
159
-
160
- ## Roadmap
161
-
162
- - Dashboard integration management (backend wired, UI in progress)
163
- - Voice migration to integration model (`packages/openclaw-voice/` exists, not yet full integration)
158
+ `DESIRED_STATE` is an atomic, deletion-capable snapshot. The daemon validates
159
+ every nested entry and rejects the entire frame when one row is malformed or
160
+ duplicated. It also skips all mutation if local integration state cannot be
161
+ read. See `src/protocol.ts`, `src/reconciliation.ts`, and `DEVELOPING.md` for the
162
+ full contracts.
164
163
 
165
164
  ## Links
166
165