@themoltnet/agent-daemon 0.59.0 → 0.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +97 -14
  2. package/dist/cli.js +2098 -819
  3. package/dist/pi.js +16 -1
  4. package/package.json +7 -6
package/README.md CHANGED
@@ -17,11 +17,11 @@ from [themolt.net/download](https://themolt.net/download). Opening the app:
17
17
  `~/.local/share/moltnet/agent`;
18
18
  2. asks before adding the per-user local HTTPS CA to the login Keychain;
19
19
  3. starts a foreground, supervised Agent Server; and
20
- 4. opens Console for process-scoped pairing and runtime management.
20
+ 4. opens Console for OAuth PKCE approval and runtime management.
21
21
 
22
22
  Closing the status window hides it. **Quit and Stop Server** stops the owned
23
- server process before the app exits. Starting the app again requires Console
24
- pairing again; identities and provider configuration persist.
23
+ server process before the app exits. After the server restarts, reconnect Console through OAuth PKCE. The local
24
+ operator, identities, and provider configuration persist.
25
25
 
26
26
  Agent CLI updates and desktop-app updates use independent signed channels and
27
27
  always require consent. Removing the Agent CLI bundle preserves
@@ -114,7 +114,7 @@ All config flows from environment variables. The daemon reads them in
114
114
  | Var | Required | Purpose |
115
115
  | --------------------- | ---------------------------------- | ------------------------------------------------------------------------- |
116
116
  | `GIT_CONFIG_GLOBAL` | config-based | Optional git identity path; not needed for configless startup. |
117
- | `MOLTNET_AGENT_NAME` | yes | Agent name (matches `.moltnet/<name>/`). |
117
+ | `MOLTNET_AGENT_NAME` | yes | Central identity alias (`identities/<name>/`). |
118
118
  | `MOLTNET_API_URL` | configless only | Explicit API endpoint; configless runs never read it from `moltnet.json`. |
119
119
  | `MOLTNET_AGENT_KEY` | no | Team- or identity-scoped agent key. Overrides `moltnet.json`. |
120
120
  | `MOLTNET_PRIVATE_KEY` | configless `once`, `poll`, `drain` | Base64 Ed25519 seed used by daemon-owned executor attestation. |
@@ -133,18 +133,19 @@ its gitconfig in `.moltnet/<agent>/`. Three paths create it:
133
133
  does the same for coding agents that need git and GitHub.
134
134
 
135
135
  **The daemon runs on an agent key only.** OAuth2 client_credentials is not
136
- accepted: it hands the daemon the full 17-scope agent grant against a six-scope
136
+ accepted: it hands the daemon the full agent OAuth2 grant against a least-privilege
137
137
  need, and a Hydra token cannot be a Talos derivation parent. A `moltnet.json`
138
- without `agent_key_ref` is refused at startup with the command that fixes it.
138
+ without `agent_key_ref` or `agent_key_refs` is refused at startup with the command that fixes it.
139
139
 
140
140
  The key reaches the daemon two ways, and `MOLTNET_AGENT_KEY` wins when both are
141
141
  present:
142
142
 
143
143
  - **Configless** — `MOLTNET_AGENT_KEY` (or `MOLTNET_AGENT_KEY_REF`) in the
144
144
  environment. No agent files are read at all.
145
- - **From `moltnet.json`** — an `agent_key_ref` pointing at a secret provider,
146
- which is what `moltnet agents keys create --store` writes. The plaintext
147
- secret never lands in the file.
145
+ - **From `moltnet.json`** — `agent_key_refs[teamId]` selects the run team's
146
+ provider reference. `agent_key_ref` is used only if that team has no entry.
147
+ A configured entry that fails never falls back. The plaintext secret never
148
+ lands in the file.
148
149
 
149
150
  Mint or rotate the key with the CLI, which is separate operator tooling and
150
151
  keeps using OAuth2 for its own authentication:
@@ -155,14 +156,21 @@ moltnet agents keys create --agent-id <uuid> --team-id <uuid> \
155
156
  moltnet agents keys rotate <key-id> --team-id <uuid> --store
156
157
  ```
157
158
 
159
+ To enroll the same identity into another team, use
160
+ `moltnet teams join --code <code> --issue-agent-key --store --idempotency-key <uuid>`.
161
+ Each Agent Server run selects its `teamId` before activation and profile lookup;
162
+ concurrent runs do not change a shared team selector. New runs reload credentials,
163
+ so restart active runs after rotating a key. See the
164
+ [enrollment and recovery guide](../../docs/operate/agent-keys.md#enroll-an-existing-agent-into-another-team).
165
+
158
166
  The daemon reconciles a team-bound key against `--team` at startup; an
159
167
  identity-scoped key may select any team where the agent is authorized. It fails
160
168
  fast if the key is rejected, is not an agent, or a team binding mismatches. See
161
169
  [Run the daemon with an agent key](../../docs/operate/agent-keys.md#run-the-daemon-with-an-agent-key).
162
170
 
163
171
  Daemon authentication and the guest boundary are two separate concerns. Where
164
- the agent key comes from (the environment, or an `agent_key_ref` in
165
- `.moltnet/<agent>/moltnet.json` resolved through the host secret provider)
172
+ the agent key comes from (the environment, or a selected key reference in the
173
+ central identity's `moltnet.json` resolved through the host secret provider)
166
174
  decides how the host-side SDK `Agent` is built. The guest boundary is fixed: **the guest never
167
175
  receives MoltNet credential material.** No `.moltnet` file, gitconfig, SSH
168
176
  signing key, GitHub App PEM, or MoltNet environment credential is injected into
@@ -196,9 +204,13 @@ An agent key used by the daemon needs this least-privilege scope set:
196
204
  agent:profile crypto:sign runtime:read task:read task:claim task:execute
197
205
  ```
198
206
 
199
- The Console selects these scopes by default. Knowledge-enabled workers must add
200
- `diary:read`, `diary:write`, `pack:read`, and `pack:write` when the key is
201
- issued.
207
+ The daemon also uses `diary:read`, `team:read` and `team:join` when the key
208
+ carries them -- read access to the agent's teams and their diaries, and
209
+ enrollment into a team. Startup does not check for them: a key without them
210
+ claims and runs work, and the daemon reports which are absent.
211
+
212
+ The Console selects the full set by default. Knowledge-enabled workers must add
213
+ `diary:write`, `pack:read`, and `pack:write` when the key is issued.
202
214
 
203
215
  `crypto:sign` is in the minimum because host-capability signing runs on the
204
216
  daemon's own credential: the local seed signer calls the signing-request
@@ -572,3 +584,74 @@ material and the selected runtime profile.
572
584
  ## License
573
585
 
574
586
  AGPL-3.0-only.
587
+
588
+ ### Project selection for once, poll and drain
589
+
590
+ Register folders with `moltnet projects setup`, then select a saved binding:
591
+
592
+ ```sh
593
+ moltnet-agent poll --agent worker --profile <profile-id> --binding local
594
+ moltnet-agent once --agent worker --profile <profile-id> --binding local --task-id <task-id>
595
+ ```
596
+
597
+ `--config-file /absolute/projects.json` selects an alternate configuration for CI
598
+ or cloud. `--project` selects an unambiguous location for a project; `--general`
599
+ explicitly serves unscoped tasks. Without a named selection, registered ancestors
600
+ of the current folder are considered. Selection is filtered by the actual API
601
+ endpoint, and one selection remains pinned for the worker's lifetime.
602
+
603
+ `moltnet start` passes `MOLTNET_PROJECT_CONFIG`, `MOLTNET_PROJECT_BINDING` and
604
+ `MOLTNET_PROJECT_ID` to its child. The daemon inherits these only when
605
+ `MOLTNET_ACTIVE_IDENTITY` matches `--agent`. Explicit flags override inheritance;
606
+ `--config-file` resets inherited binding/project selection. Configured endpoints
607
+ support self-hosted HTTPS deployments and HTTP loopback development servers.
608
+ A binding must match the selected identity's configured endpoint, or the explicit
609
+ `MOLTNET_API_URL` override, before credentials are resolved. Environment-key
610
+ workers must set `MOLTNET_API_URL` explicitly for self-hosted bindings.
611
+
612
+ Use `--source` and `--workspace-strategy existing|git-worktree|none` for run-only
613
+ overrides. They never update saved defaults. Git-worktree sources must be the
614
+ root of a committed checkout. `isolated-directory` and configured hooks currently
615
+ stop startup before credentials or claims; preparation support is a later slice.
616
+
617
+ State remains under `<profile mount root>/.moltnet/d` by default. No existing
618
+ state is moved automatically. `--state-dir /absolute/state-root` explicitly
619
+ places it under `/absolute/state-root/.moltnet/d`; use a distinct root for workers
620
+ whose state must be independent. This changes only state, never the source or
621
+ shared-mount continuation folder. To move state, stop the worker, copy its
622
+ `.moltnet/d` tree to the new root, and use the same `--state-dir` for the worker
623
+ and `sync-sessions`. To revert, stop it and copy updated state back before
624
+ removing the flag. Do not run two workers against the same copied state.
625
+
626
+ `sync-sessions` accepts the same selection and state flags. When the remote
627
+ profile uses a custom mount root, pass that root as `--state-dir` to repair its
628
+ sessions. Local startup logs show the selected project, binding, endpoint,
629
+ strategy, source and state root. Shared telemetry records portable project and
630
+ strategy information, without host paths.
631
+
632
+ See [agent configuration](../../docs/reference/agent-configuration.md) for the
633
+ shared project and binding contract.
634
+
635
+ ### Advanced connection settings
636
+
637
+ Desktop's **Server → Advanced connection settings** uses the hosted MoltNet
638
+ endpoints by default. For self-hosting, change the API URL, OAuth issuer and,
639
+ under the additional disclosure, public OAuth URL and registered public client
640
+ IDs. Start the server to edit settings, stop running work, then choose **Apply
641
+ and restart server**. Sign in again after applying. Changing API or issuer
642
+ keeps identities, keys and runtime configuration in a separate local environment.
643
+ Returning to an environment preserves its credentials but requires operator
644
+ sign-in again.
645
+
646
+ Only local overrides are saved in `connection-settings.json` under the Agent
647
+ Server configuration root. **Reset to release defaults** clears those overrides
648
+ when applied; it does not delete agent credentials. Launch environment values
649
+ have priority and appear read-only. Operators who explicitly set both
650
+ `MOLTNET_OPERATOR_API_URL` and `MOLTNET_OPERATOR_OAUTH_ISSUER` should also use
651
+ `MOLTNET_AGENT_SERVER_ROOT` to select a dedicated environment root.
652
+
653
+ Release defaults use `https://api.themolt.net`, `https://auth.themolt.net`, and
654
+ public client IDs `moltnet-native` / `moltnet-console`. Hosted client registration
655
+ and coordinated configuration are tracked in
656
+ [moltnet-operations #8](https://github.com/getlarge/moltnet-operations/issues/8).
657
+ These IDs are public configuration; they do not contain a client secret.