|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
# /auth step 2 (#71): every auth action as a command, JSON out
One idempotent command per action, for agents with no terminal. A second run changes nothing and
says `"changed":false`. No answer carries a key.
| Action | Shell | RPC |
|---|---|---|
| store an API key | `pic auth login P --api-key [--as L] --json` (key on stdin) | `add_credential {provider, label?, key, use?}` (new) |
| list keys, what is left | `pic auth status --json` | `get_credentials` (+ `currency`, `probed`) |
| free checks | `pic auth status --check --json` | `check_credentials {provider?, active?}` (new) |
| make a key the provider's | `pic auth use P L --json` | `set_credential` + `persist`, now with data |
| switch model and key | `pic models use M [--key L] --json` (new) | `set_model` + `credential` |
| remove a key | `pic auth logout P[:L] --json` | `logout` + `label` |
## How
- cred.c: `pic_cred_same` opens the row and compares in constant time, so storing the same key
again writes nothing.
- main.c: `add_key`, `credentials_json`, `run_checks` are shared by the RPC answers and the shell's
`--json`, so the two surfaces cannot drift. `pic auth status --json` prints exactly
`get_credentials`'s data.
- rpc.c: `set_model` `credential`, `logout` `label`.
- `check_credentials` opens the store as a request would; RPC never asks on a terminal, so a
passphrase store's keys go unchecked (`checked:0`) until `unlock`.
- keyhealth.c untouched.
Binding a model family to a key (pattern rules, `--for`) is step 4 of the plan; here binding is
per provider (`persist`) and per process or conversation (`set_model credential`).
## Tests
New `test/pic/authcmd.sh` (dev; release skips it since it needs PIC_TEST_PASSPHRASE).
Tier: root (main.c), core (cred.c, rpc.c); no new file. Clock: pi. Record: settings and the
credential store, as before. Default: on.
|