@wafflebase/cli 0.6.4 → 0.6.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.
Files changed (3) hide show
  1. package/README.md +62 -6
  2. package/dist/bin.js +24479 -22416
  3. package/package.json +6 -4
package/README.md CHANGED
@@ -24,6 +24,13 @@ Two paths, in priority order:
24
24
  `WAFFLEBASE_API_KEY`, or set `api-key:` in `~/.wafflebase/config.yaml`.
25
25
  2. **OAuth session** — `wafflebase login` opens a browser, completes
26
26
  GitHub OAuth, and writes a JWT session to `~/.wafflebase/session.json`.
27
+ The login callback is bound to a per-attempt nonce, which the backend
28
+ echoes back as the callback's `state`, so a server that predates that
29
+ echo never completes one; against such a server (a self-hosted backend
30
+ that has not upgraded yet) pass
31
+ `wafflebase login --allow-unbound-callback` to accept its `state`-less
32
+ callback anyway. It warns on stderr, and a *mismatched* `state` stays
33
+ refused under the flag.
27
34
 
28
35
  Always pair API keys with a workspace ID:
29
36
 
@@ -32,6 +39,24 @@ export WAFFLEBASE_API_KEY=wfb_…
32
39
  export WAFFLEBASE_WORKSPACE=ws-…
33
40
  ```
34
41
 
42
+ ## Image fetching
43
+
44
+ `docs export` / `slides export` fetch the images a document references. An
45
+ image `src` is content someone else may have written, so the fetcher speaks
46
+ only `http`/`https`/`data` and refuses a non-public address (loopback,
47
+ private, `169.254.169.254`, CGNAT, multicast/reserved, and the IPv6
48
+ spellings of all of those) unless it is the configured `--server`'s own host
49
+ **and port**. The hostname is resolved before it is fetched and judged per
50
+ address, so `169.254.169.254.nip.io` and friends get no further than the
51
+ literal would, and the request is then pinned to the addresses that check
52
+ approved — DNS cannot answer differently between the check and the
53
+ connection. Every redirect hop is gated the same way, up to five.
54
+
55
+ An image that is refused or unreachable is reported on stderr and skipped,
56
+ rather than failing the whole export: one `src` you cannot fix must not cost
57
+ you the export you asked for. The rest of the document still exports, minus
58
+ those images.
59
+
35
60
  ## Command Tree (v0.3.7)
36
61
 
37
62
  Plural namespaces are canonical; singular forms are accepted as
@@ -114,12 +139,43 @@ wafflebase schema cell.get # → sheets.cells.get
114
139
  - **Binary results** (pdf/docx): positional `<file>`; `-` writes to stdout.
115
140
  `--force` is required to overwrite an existing target.
116
141
  - **Errors**: a single JSON line on stderr —
117
- `{"error":{"code":"…","message":"…"}}`. Typed errors (e.g.,
142
+ `{"error":{"code":"…","message":"…","command":"docs.content"}}`. `command`
143
+ is the dotted command name (the same string `schema` indexes on), so a
144
+ caller running several commands can tell which one failed. Typed errors (e.g.,
118
145
  `INVALID_DOCX`, `TYPE_MISMATCH`, `CONFIRMATION_REQ`) carry a
119
- command-specific `code` agents can branch on; everything else
120
- reports `"ERROR"`.
146
+ command-specific `code` agents can branch on; argument-parsing
147
+ failures (missing argument, unknown option, unknown command) report
148
+ `USAGE`. A failed request whose
149
+ body the backend did *not* send in that shape (an Express/Nest
150
+ `{message, error, statusCode}` 404/500, an HTML proxy page) reports
151
+ `"HTTP_ERROR"` — or `"AUTH_ERROR"` / `"SERVER_ERROR"` when the status
152
+ says so — with `"HTTP <status>"` plus the upstream's own wording when
153
+ it had any, as `"HTTP 404: Document has no file"`. Every command
154
+ reports the same code for that condition, so the branch does not
155
+ depend on which subcommand ran. Local failures (bad input, a
156
+ filesystem error) still report `"ERROR"`.
157
+ - **Forwarded backend errors are bounded**: when the backend *did* send
158
+ the envelope, its own `code` is what you get — that is the value to
159
+ branch on, and it is never rewritten. The surrounding text is capped,
160
+ because it is upstream-controlled content going straight into an
161
+ agent's stderr: `code` is truncated at 80 characters, `message` at 500
162
+ (with a trailing `…`), a `message` that is an HTML document is replaced
163
+ by `"HTTP <status>"`, and any extra field the backend attached (a
164
+ request id) is dropped once the whole body exceeds 4,000 bytes, leaving
165
+ `{code, message}`. Treat `message` as a display string, not a parseable
166
+ payload. `command` is the one field never forwarded: attribution is the
167
+ CLI's statement about which command *it* ran, so a server cannot
168
+ relabel which call failed.
121
169
  - **Exit codes**: `0` success, `1` user error (bad input, 404, type
122
- mismatch), `2` system error (network, auth).
170
+ mismatch), `2` system error — an unreachable server
171
+ (`NETWORK_ERROR`), rejected credentials (`AUTH_ERROR`, HTTP 401/403),
172
+ or a server fault (`SERVER_ERROR`, HTTP 5xx). A 2xx the CLI cannot use
173
+ — a create that returned no id, a download that returned no bytes — is
174
+ a server fault too. The class is decided where the failure is raised,
175
+ so `--quiet` reports it too.
176
+ - **Proxies**: image downloads during `docs export` / `slides export`
177
+ honor `http_proxy` / `https_proxy` / `all_proxy` and `no_proxy` (either
178
+ letter case).
123
179
 
124
180
  ## Skills (for AI agents)
125
181
 
@@ -131,6 +187,6 @@ for the index.
131
187
 
132
188
  ## Design
133
189
 
134
- Full design in [`/docs/design/rest-api-and-cli.md`](../../docs/design/rest-api-and-cli.md)
135
- and [`/docs/design/docs-cli.md`](../../docs/design/docs-cli.md) (the
190
+ Full design in [`/docs/design/rest-api.md`](../../docs/design/rest-api.md)
191
+ and [`/docs/design/cli.md`](../../docs/design/cli.md) (the
136
192
  docs-side `content / export / import` pipeline).