pi-lean-host 0.7.1 → 0.8.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/CHANGELOG.md +146 -0
- package/README.md +229 -235
- package/core/api-guide-types.ts +71 -3
- package/core/api-toggle.ts +6 -3
- package/core/auth.ts +16 -1
- package/core/guide-catalog.ts +9 -3
- package/core/helpers-command.ts +3 -1
- package/core/helpers.ts +458 -17
- package/core/oauth-command.ts +77 -6
- package/core/oauth-flow.ts +31 -18
- package/core/parse-api-guide.ts +198 -18
- package/core/resolve-op.ts +50 -6
- package/core/response-spill.ts +4 -1
- package/core/secrets-store.ts +3 -1
- package/core/staging.ts +3 -3
- package/core/status-hint.ts +2 -3
- package/core/transport.ts +803 -171
- package/core/verify-command.ts +117 -62
- package/docs/migration-v1.md +19 -20
- package/package.json +4 -3
- package/tools/api-fetch.ts +96 -22
- package/tools/api-guide.ts +10 -1
- package/tools/api-learn.ts +6 -2
- package/tools/api-probe.ts +26 -10
- package/tools/api-scaffold.ts +21 -5
- package/tools/api-store.ts +3 -3
- package/tools/oauth-mint.ts +22 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [Unreleased]
|
|
4
|
+
|
|
5
|
+
## [0.8.0] - 2026-12-06
|
|
6
|
+
|
|
7
|
+
### New Features
|
|
8
|
+
|
|
9
|
+
- **Byte downloads** — a guide flags a `restGet` op `download: true` and the
|
|
10
|
+
caller passes `saveTo` to stream the response body straight to disk, bounded
|
|
11
|
+
by free disk space rather than RAM; auth resolves through the normal machinery
|
|
12
|
+
so secrets never enter agent context, and the result is metadata only
|
|
13
|
+
(`file: {path, bytes, contentType}`).
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- **First-class byte downloads (`download: true` + `saveTo`)** — a guide flags a
|
|
18
|
+
`restGet` op `download: true` (exclusive with the JSON-shaped surfaces), the
|
|
19
|
+
caller passes `saveTo` (honored on any op; caller intent wins), and the body
|
|
20
|
+
streams straight to disk, bounded by free disk space rather than RAM. Auth
|
|
21
|
+
resolves through the normal machinery, so secrets never enter agent context. A
|
|
22
|
+
failed or cancelled transfer never touches a pre-existing destination, only
|
|
23
|
+
2xx bodies are written, and oversized compressed error bodies render their
|
|
24
|
+
reason. Results are metadata only (`file: {path, bytes, contentType}`);
|
|
25
|
+
`/api verify` proves download ops with a bounded byte-budget probe.
|
|
26
|
+
- **OAuth2 `authorizeParams`** — new optional `OAuth2Auth.authorizeParams` map
|
|
27
|
+
(authorization_code-only) spread into the authorize URL after the built-ins,
|
|
28
|
+
for providers that gate refresh tokens behind consent flags (Google's
|
|
29
|
+
`access_type=offline` + `prompt=consent`); without it such slots mint but
|
|
30
|
+
never refresh. Supplied on the guide or at mint time (`oauth-mint` param,
|
|
31
|
+
`/api oauth init --authorize-params` flag + wizard prompt).
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
|
|
35
|
+
- **The OAuth authorize URL is now printed in full** — the paste prompt
|
|
36
|
+
previously showed only `origin + path` with the full URL in the OSC 8
|
|
37
|
+
hyperlink target, which terminals like kitty (ctrl-click opens the target)
|
|
38
|
+
can't surface. Both the notify banner and paste-dialog title now show the
|
|
39
|
+
complete URL as text; the OSC 8 hyperlink remains as a self-targeting bonus,
|
|
40
|
+
and the wrap warning now applies everywhere.
|
|
41
|
+
|
|
42
|
+
### Fixed
|
|
43
|
+
|
|
44
|
+
- **429 backoff honors the call's timeout contract** — a server-supplied
|
|
45
|
+
`Retry-After` is now clamped at 60s (previously a broken or hostile server
|
|
46
|
+
could demand an hours-long wait that silently blew the call's own timeout),
|
|
47
|
+
and tool-call cancellation preempts the backoff sleep instead of waiting it
|
|
48
|
+
out.
|
|
49
|
+
|
|
50
|
+
## [0.7.2] - 2026-10-07
|
|
51
|
+
|
|
52
|
+
### Changed
|
|
53
|
+
|
|
54
|
+
- Raised the `pi-tool-masking` floor from `^2.0.1` to `^2.1.0`. No code changes;
|
|
55
|
+
no behavior change.
|
|
56
|
+
|
|
57
|
+
## [0.7.0] - 2026-10-05
|
|
58
|
+
|
|
59
|
+
### Changed
|
|
60
|
+
|
|
61
|
+
- **`pi-tool-masking` 2.0.1 migration** — migrated to pi-tool-masking 2.0.1's
|
|
62
|
+
intent-delta toggle gate; same-value toggle repeats become silent no-ops in
|
|
63
|
+
the library. Focus-mode refusals now surface as the friendly "Focus mode
|
|
64
|
+
(allowlist) is active" notify; `/api` command behavior is otherwise unchanged.
|
|
65
|
+
**Ships in the same release window as `pi-tool-masking` 2.0.1**.
|
|
66
|
+
|
|
67
|
+
## [0.6.0] - 2026-09-16
|
|
68
|
+
|
|
69
|
+
### Added
|
|
70
|
+
|
|
71
|
+
- **OAuth paste-prompt recovery** — Esc at the auth-code paste prompt no longer
|
|
72
|
+
discards the flow. It now opens a recovery input: Enter repastes into the
|
|
73
|
+
untouched pending flow, typing a corrected redirect URI restarts the
|
|
74
|
+
authorization (fresh PKCE/state/authorize URL) with every wizard answer
|
|
75
|
+
preserved, and Esc still aborts to the `--code` nudge. Fixes the dead end
|
|
76
|
+
where a wrong redirect URI (never registered at the provider, so no code was
|
|
77
|
+
ever issued) cost the whole wizard redo.
|
|
78
|
+
|
|
79
|
+
### Changed
|
|
80
|
+
|
|
81
|
+
- **Organization header on all tool-channel disambiguation menus** — when a
|
|
82
|
+
domain is claimed by multiple guides sharing one `organization:`, the
|
|
83
|
+
`api-learn` and `api-scaffold` menus now show the `(organization: X)` header
|
|
84
|
+
like `api-guide`'s menu already did, giving the agent the same ownership
|
|
85
|
+
signal when picking between sibling recipes. Shared menu/error rendering
|
|
86
|
+
extracted to one helper (no other behavior change).
|
|
87
|
+
|
|
88
|
+
## [0.5.0] - 2026-09-11
|
|
89
|
+
|
|
90
|
+
### Added
|
|
91
|
+
|
|
92
|
+
- **First public release** — the declarative REST API client package.
|
|
93
|
+
- **Declarative REST API client** — recipe-based access to REST APIs. A guide is
|
|
94
|
+
one markdown file with YAML frontmatter (`guide.md`) declaring an API's host,
|
|
95
|
+
endpoints, auth, pagination, and response shape; a fixed executor runs the
|
|
96
|
+
declared operation so an API encoded once is reusable forever, not re-derived
|
|
97
|
+
each session. Guides live at
|
|
98
|
+
`~/.pi/agent/pi-lean-host/api-guides/<slug(shortName)>/`: only files placed
|
|
99
|
+
there execute. Ships 7 tools (`api-guide`, `api-fetch`, `api-learn`,
|
|
100
|
+
`api-probe`, `api-scaffold`, `api-store`, `oauth-mint`) and the `/api`
|
|
101
|
+
command. GET-read only: no mutation helper. Declares `pi-lean-portal` as an
|
|
102
|
+
**optional peer dependency** (host-only installs are valid).
|
|
103
|
+
- **`/api` toggle, an independent peer of `/web`** — three states (`on`,
|
|
104
|
+
`learn`, `off`); the authoring tools are gated behind `learn`; starts **on**.
|
|
105
|
+
The two toggles compose freely (e.g. `/api on` + `/web off` = pure api-only
|
|
106
|
+
context for batch structured-data pulls), each with its own status-bar glyph.
|
|
107
|
+
Subcommands: `verify` (live-runs a guide's ops and stamps `verified` on
|
|
108
|
+
success, strict threshold, `--force` for human-attested), `delete`, `oauth`,
|
|
109
|
+
`bootstrap`, `secrets`, `helpers`, `status`. State persists via
|
|
110
|
+
`pi-tool-masking`; actuating subcommands are refused while a focus mode is
|
|
111
|
+
active. Persist keys: `toolset-state:pi-lean-dimension.api` / `.api-learn`
|
|
112
|
+
(overridable via the `toolsetDefaults` settings block).
|
|
113
|
+
- **Authoring loop** — `api-learn` stages a working copy to `/tmp/pi-lean-host/`
|
|
114
|
+
for template creation and fetched-recipe editing, then mirror-saves a staged
|
|
115
|
+
directory back (deletion-safety gate refuses unconfirmed sibling wipes).
|
|
116
|
+
`api-probe` fetches an exploratory path, summarizes the JSON shape, and emits
|
|
117
|
+
a draft operation block (it suggests, never writes). `api-scaffold` bootstraps
|
|
118
|
+
a starter `verify.json` (sentinel-filled) and/or `helper.ts` stub into the
|
|
119
|
+
same staging dir. `/api verify` runs the ops against the live API.
|
|
120
|
+
- **Auth and secrets** — `auth.kind` is a
|
|
121
|
+
`NoneAuth | StaticKeyAuth | OAuth2Auth` union with nested `SecretRef`s
|
|
122
|
+
(`{ secret, prefix?, optional? }`). Secrets persist per-domain at
|
|
123
|
+
`~/.pi/agent/pi-lean-host/secrets/<domain>.json` (mode `0600`), provisioned
|
|
124
|
+
transcript-safely via `/api secrets` (names only, never values). Values are
|
|
125
|
+
resolved and injected in code: they never enter agent context, and are
|
|
126
|
+
scrubbed from error bodies and surfaced headers, with query-param secrets
|
|
127
|
+
redacted on every surfaced URL. OAuth2 covers `client_credentials`
|
|
128
|
+
(auto-mint/refresh) and a headless paste-based auth-code flow; `oauth-mint` is
|
|
129
|
+
the human-in-the-loop mint tool and `api-store` a read-only view of both
|
|
130
|
+
credential stores (metadata only).
|
|
131
|
+
- **Execution** — six pagination styles (`offset-limit`, `page`, `nextLink`,
|
|
132
|
+
`cursor`, `resumptionToken`, `tokenBag`) with a `gatherAll` exhaustion walk
|
|
133
|
+
under a per-op ceiling; op-level `errorPath` envelopes fail
|
|
134
|
+
present-only-on-error 200 bodies; `helper.ts` files reshape params pre-call
|
|
135
|
+
(`helper: true`) and a per-op built-in transform runs post-parse
|
|
136
|
+
(`transform: true`; distinct mechanisms, each under a load/call guard). The
|
|
137
|
+
shared transport caches only on an explicit server freshness grant
|
|
138
|
+
(`Cache-Control: max-age` or ETag/304; never a fabricated TTL), and the SSRF
|
|
139
|
+
guard blocks loopback/private/metadata targets on server-supplied pagination
|
|
140
|
+
URLs. The guide schema is closed (unknown keys are parse errors) and
|
|
141
|
+
`schemaVersion`-stamped; a truncated `api-fetch` result spills the full JSON
|
|
142
|
+
to disk for the session.
|
|
143
|
+
- **Multi-recipe domains** — a domain may claim multiple guides; `api-guide`
|
|
144
|
+
disambiguates and `api-fetch` resolves ops by name across all matches. Bundled
|
|
145
|
+
`api-guides/` are repo-only test fixtures, not recipes to copy: the
|
|
146
|
+
comprehensive recipe library lives in the separate `Caritas` repo.
|