Overview
| Comment: | Auth actions as RPC and shell commands with JSON out (#71) |
|---|---|
| Timelines: | family | ancestors | descendants | both | auth-2 |
| Files: | files | file ages | folders |
| SHA3-256: |
9f36c13fcc6075ae5e409e843ca094a9 |
| User & Date: | dmestas on 2026-11-24 13:25:40.347 |
| Other Links: | branch diff | manifest | tags |
/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_sameopens the row and compares in constant time, so storing the same key again writes nothing. - main.c:
add_key,credentials_json,run_checksare shared by the RPC answers and the shell's--json, so the two surfaces cannot drift.pic auth status --jsonprints exactlyget_credentials's data. - rpc.c:
set_modelcredential,logoutlabel. check_credentialsopens the store as a request would; RPC never asks on a terminal, so a passphrase store's keys go unchecked (checked:0) untilunlock.- 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.
Context
|
2026-11-24
| ||
| 13:50 | Merge auth-1 into auth-2 check-in: cf9380caa3 user: dmestas tags: auth-2 | |
| 13:25 | Auth actions as RPC and shell commands with JSON out (#71) check-in: 9f36c13fcc user: dmestas tags: auth-2 | |
| 13:14 | Create new branch named "auth-2" check-in: 2b462a91e2 user: dmestas tags: auth-2 | |
Changes
Modified CHANGELOG.md
from [0e9d88ddab]
to [783cf538be].
[diff]
Modified Makefile
from [8f356754a2]
to [7413c006dc].
[diff]
Modified docs/manual/named-keys.md
from [189a301e92]
to [e401efd185].
[diff]
Modified docs/reference/cli.md
from [1e178273bf]
to [ef3ebe1fe2].
[diff]
Modified docs/reference/rpc-commands.md
from [07688cca1e]
to [de5f17044d].
[diff]
Modified src/cred.c
from [ffdfb1c5f5]
to [fa0ecdb090].
[diff]
Modified src/cred.h
from [a7824e7116]
to [2ccef087b6].
[diff]
Modified src/main.c
from [6848b4fe51]
to [885542ad14].
[diff]
Modified src/rpc.c
from [f16861326a]
to [e0ef7b27b5].
[diff]
Added test/pic/authcmd.sh version [4be2632926].