@flovialabs/sdk 0.1.16 → 0.1.17
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 +7 -1
- package/README.md +14 -5
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +43 -1
- package/dist/client.d.ts +11 -3
- package/dist/client.js +39 -2
- package/dist/types.d.ts +15 -2
- package/dist/types.js +3 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 0.1.17
|
|
4
|
+
|
|
5
|
+
- Introduce the consent API and CLI described below; these are not in the published 0.1.16 package. Expect contract `2026-10-07.172`. When the current notice is `relay-consent-19`, `flovia consent` describes notice 19's December 3/new-record retrieval rules. Earlier yes answers keep working; a new answer is not required to keep looking up.
|
|
6
|
+
- `flovia consent` reads the current notice version, your last yes, whether it is to an earlier version (`updated`), and the full notice text. `flovia consent accept <version> --yes` records the account owner's own yes to exactly that version, as in Console; without `--yes` nothing is sent. In code: `client.consent()` and `client.acceptConsent(version)`. An agent must never answer for the person.
|
|
7
|
+
- Notice 18-eligible Nansen answers and generated text/audio can be reopened only by their owner for up to 30 days from creation. Eligibility starts with accepted use from 2026-12-01, or records after an earlier explicit yes to notice 18 or matching registration Terms. Retrieval availability follows the Relay rollout and the notice on each original record. Earlier records keep their original periods; reopening does not renew the deadline or restore a missing or expired copy. Runway's eligible media retrieval period remains up to 30 days.
|
|
8
|
+
- Other lookup replies and fal.ai URL copies get up to 30 days only for new notice 19 records, from 2026-12-03 or after a fresh explicit yes to notice 19. Old notice 18 and earlier lookup copies keep about 15 minutes; later agreement never extends them. These copies are owner-only retrieval data, not fresh results or a shared cache.
|
|
9
|
+
- A saved fal.ai URL still expires at the provider after about an hour. Saving its URL for longer does not extend or restore the image.
|
|
4
10
|
|
|
5
11
|
## 0.1.16
|
|
6
12
|
|
package/README.md
CHANGED
|
@@ -10,9 +10,15 @@ TypeScript client and command-line tool for [Flovia](https://api.flovia.dev). It
|
|
|
10
10
|
## Install
|
|
11
11
|
|
|
12
12
|
```sh
|
|
13
|
-
npm install --save-exact @flovialabs/sdk@0.1.
|
|
13
|
+
npm install --save-exact @flovialabs/sdk@0.1.17
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
## 0.1.17 release notes
|
|
17
|
+
|
|
18
|
+
This release introduces `client.consent()`, `client.acceptConsent(version)` and the `flovia consent` commands, which are not in the published 0.1.16 package. It expects contract `2026-10-07.172`. When the current notice is `relay-consent-19`, the CLI shows its December 3/new-record rule. Your earlier yes keeps working, and the CLI never answers for you.
|
|
19
|
+
|
|
20
|
+
Eligible Nansen answers and generated text/audio can be reopened only by their owner for up to 30 days under notice 18, from the original record's creation. Retrieval availability follows the Relay rollout and the notice on each original record. Earlier records keep their original periods. Other lookup replies and fal.ai URL copies get this period only for new notice 19 records, from 2026-12-03 or after your fresh explicit yes to notice 19. Old notice 18 and earlier lookup copies keep about 15 minutes; later agreement never extends them. Reopening does not renew the deadline, fetch fresh data or restore a missing copy. A fal.ai image URL still expires after about an hour; a saved URL does not extend the image's lifetime.
|
|
21
|
+
|
|
16
22
|
## Your key
|
|
17
23
|
|
|
18
24
|
1. Register at https://console.flovia.dev/auth/register with email verification and a Passkey.
|
|
@@ -104,7 +110,7 @@ const output = await flovia.downloadRunwayOutput(String(result["generation_id"])
|
|
|
104
110
|
|
|
105
111
|
Images are one 720p `gen4_image` result. Videos use `action: "video"` with `duration: 2` through `5`, and return MP4. Runway jobs never resend automatically, even with `retryRateLimited: true`. Keep the original operation ID after a disconnect or unknown result; never generate a replacement to recover it. A failed/moderated generation may still be charged. Status distinguishes the billing state from output delivery.
|
|
106
112
|
|
|
107
|
-
Flovia keeps output privately for 24 hours, with authenticated downloads; Runway's own retention is separate. The SDK download is a bounded (32 MiB), one-request GET to Flovia, never a provider URL. A download does not generate or charge again. OAuth-only MCP users can use the returned `console_download_url` while signed in to their own Console.
|
|
113
|
+
Flovia keeps output privately for up to 30 days from generation creation under notice 18 (earlier records keep 24 hours), with authenticated downloads; Runway's own retention is separate. The SDK download is a bounded (32 MiB), one-request GET to Flovia, never a provider URL. A download does not generate or charge again. OAuth-only MCP users can use the returned `console_download_url` while signed in to their own Console.
|
|
108
114
|
|
|
109
115
|
```bash
|
|
110
116
|
flovia call flovia_runway '{"action":"list"}'
|
|
@@ -205,7 +211,7 @@ For Luna, set `reasoning.effort` to `none`, `low`, `medium`, `high`, `xhigh` or
|
|
|
205
211
|
|
|
206
212
|
`generate()` requires an operation id (8-128 characters of `A-Z a-z 0-9 _ . : -`). Create one with `newOperationId()` and store it with the request **before** sending.
|
|
207
213
|
|
|
208
|
-
If the reply is lost (timeout, network error, `executed: "unknown"`), keep the request and **same** id. A completed or incomplete answer can
|
|
214
|
+
If the reply is lost (timeout, network error, `executed: "unknown"`), keep the request and **same** id. A completed or incomplete saved answer can be reopened with the unchanged request, `replayed: true` and no additional charge. For generations made under data-use notice 18 (including matching registration Terms), the period is up to 30 days from creation. This covers accepted use from 2026-12-01T00:00Z, or work after your earlier explicit agreement to notice 18. Earlier generations keep about 15 minutes; later agreement does not extend them. A failed save or missing copy can prevent reopening even before expiry. Follow `nextStep` for `generation_pending` or `generation_unknown`; the answer may not be available yet. After `answer_expired` or `operation_retired`, Flovia cannot return the saved text. Expired or deleted copies are not restored. Never start a new id to recover a lost answer: that may run and charge twice. A new generation requires the person's decision to spend again. [Data use](https://docs.flovia.dev/data-use/) explains the retrieval periods and their limits.
|
|
209
215
|
|
|
210
216
|
## Errors
|
|
211
217
|
|
|
@@ -263,15 +269,17 @@ npx flovia tools --json # includes each tool's inputSchema
|
|
|
263
269
|
npx flovia tools flovia_coingecko --json # only this tool's description and inputSchema
|
|
264
270
|
npx flovia call flovia_usage_today '{}'
|
|
265
271
|
npx flovia generate --op sdk-example-0001 --max-output 1000 --reasoning-effort low "Explain a DEX aggregator."
|
|
266
|
-
# Only to reopen that exact request
|
|
272
|
+
# Only to reopen that exact request while its saved answer is available:
|
|
267
273
|
npx flovia generate --op sdk-example-0001 --max-output 1000 --reasoning-effort low --yes "Explain a DEX aggregator."
|
|
268
274
|
npx flovia resets # saved resets and both free windows (read-only)
|
|
269
275
|
npx flovia resets use 42 --yes # use saved reset 42 (cannot be undone)
|
|
276
|
+
npx flovia consent # current notice version, your yes and the notice text (read-only)
|
|
277
|
+
npx flovia consent accept relay-consent-19 --yes # your own yes to the version just shown (same as Console)
|
|
270
278
|
npx flovia agents-md # a short note for CLAUDE.md or AGENTS.md
|
|
271
279
|
npx flovia help
|
|
272
280
|
npx flovia --version
|
|
273
281
|
```
|
|
274
|
-
These commands run after installing `@flovialabs/sdk` in the current project. Without a local installation, specify the package: `npx --package=@flovialabs/sdk@0.1.
|
|
282
|
+
These commands run after installing `@flovialabs/sdk` in the current project. Without a local installation, specify the package: `npx --package=@flovialabs/sdk@0.1.17 flovia --help`. Use a unique operation id for each new request; `sdk-example-0001` is only an example. Save the id, prompt and options before sending, and keep them unchanged for replay.
|
|
275
283
|
|
|
276
284
|
Get or manage your key in [Console](https://console.flovia.dev/groupbuy/), save it privately, then run `flovia status --key-file <saved-key-file>`. A connected key can still have sharing declined, withdrawn or stopped; `status` shows those separately from provider availability. It never answers consent for you.
|
|
277
285
|
|
|
@@ -303,6 +311,7 @@ Keep the same `--key-file` and `--base-url` too. For a prompt starting with a hy
|
|
|
303
311
|
- `generate` uses your free allowance first, then your purchased balance. It needs `--op ID` or `--new-op`, and asks for confirmation on a terminal; add `--yes` in scripts.
|
|
304
312
|
- `generate` prints the response status and incomplete reason. `incomplete` / `max_output_tokens` means the delivered text stopped at the output limit, not that a continuation ran. Exit 0 means the response was delivered, not that the text is complete or correct. `--json` retains the full public response.
|
|
305
313
|
- `resets` only reads: the number of saved resets, the next to expire, and the 5-hour and weekly windows. `resets use <id> --yes` uses one; both free windows (5-hour and week) start again from 0%. Without `--yes` nothing is sent, even on a terminal. It is never resent automatically: after a lost reply, run `flovia resets` before trying again. `Not used; nothing changed.` exits 1. In code: `client.bankedResets()` and `client.useBankedReset(id)`.
|
|
314
|
+
- `consent` only reads: the current notice version, the version you last said yes to, whether that yes is to an earlier version (it keeps working; continued use accepts the current one), and the full notice. `consent accept <version> --yes` records your own yes to exactly that version, the same as answering in Console; an older version is refused and nothing is recorded, and a repeat changes nothing. Without `--yes` it shows the text and sends nothing (exit 2). Only the account owner should run it, never an agent on their behalf. In code: `client.consent()` and `client.acceptConsent(version)`.
|
|
306
315
|
- Exit codes: 0 ok, 1 an error from Flovia, 2 a usage error.
|
|
307
316
|
|
|
308
317
|
### Safety
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { FloviaError, type BankedResets, type StatusReply, type UsageTodayReply } from "./index.js";
|
|
2
|
+
import { FloviaError, type BankedResets, type ConsentState, type StatusReply, type UsageTodayReply } from "./index.js";
|
|
3
3
|
/** Exclusive creation: a failed write may leave a private partial file, never overwrite or delete an existing path. */
|
|
4
4
|
export declare function writePrivateOutput(path: string, data: Uint8Array): Promise<void>;
|
|
5
5
|
export interface Io {
|
|
@@ -33,6 +33,7 @@ export declare function when(v: unknown, now?: number): string;
|
|
|
33
33
|
export declare function renderStatus(s: StatusReply, expected: string | null, now?: number): string;
|
|
34
34
|
export declare function renderUsage(u: UsageTodayReply, today?: boolean, now?: number): string;
|
|
35
35
|
export declare function renderResets(r: BankedResets, s: StatusReply, now?: number): string;
|
|
36
|
+
export declare function renderConsent(c: ConsentState): string;
|
|
36
37
|
/** A refusal or failure: code, next_step, executed; a handshake's notice or question is shown for the person, never answered here. */
|
|
37
38
|
export declare function renderError(e: FloviaError): string;
|
|
38
39
|
export declare function run(argv: string[], io: Io): Promise<number>;
|
package/dist/cli.js
CHANGED
|
@@ -30,6 +30,7 @@ const COMMANDS = {
|
|
|
30
30
|
"runway-output": { usage: "runway-output <generation_id> --out PATH", about: "download an existing private output; never regenerates or overwrites", flags: { "--out": true } },
|
|
31
31
|
generate: { usage: "generate (--op ID | --new-op) [--max-output N]\n [--reasoning-effort LEVEL] [--yes] <prompt | ->", about: "a text generation (uses your free allowance, then your purchased balance)", flags: { "--op": true, "--new-op": false, "--max-output": true, "--reasoning-effort": true, "--yes": false } },
|
|
32
32
|
resets: { usage: "resets [use <id> --yes]", about: "check saved resets (read-only), or use one to restart both free windows", flags: { "--yes": false } },
|
|
33
|
+
consent: { usage: "consent [accept <version> --yes]", about: "read Flovia's current notice and your answer, or record your own yes to it", flags: { "--yes": false } },
|
|
33
34
|
"agents-md": { usage: "agents-md", about: "a short Flovia note to paste into CLAUDE.md or AGENTS.md (no network)", flags: {} },
|
|
34
35
|
help: { usage: "help [command]", about: "this help", flags: {} },
|
|
35
36
|
version: { usage: "version", about: "the installed CLI version", flags: {} },
|
|
@@ -106,6 +107,8 @@ export function help(command) {
|
|
|
106
107
|
lines.push("", "Inspect one tool: flovia tools <tool> --json", "Inspect all tool arguments: flovia tools --json", "Read-only example: flovia call flovia_status '{}'");
|
|
107
108
|
if (command === "resets")
|
|
108
109
|
lines.push("", "flovia resets only reads; it never uses one.", "Using one starts both free windows (5-hour and week) again; it cannot be undone.", " flovia resets use <id> --yes", "It is never resent automatically; after a lost reply, run flovia resets first.");
|
|
110
|
+
if (command === "consent")
|
|
111
|
+
lines.push("", "flovia consent only reads; it never answers.", "Only the account owner may answer, for themselves, after reading the notice:", " flovia consent accept <version> --yes", "Without --yes nothing is sent. The same answer can be given in Console.");
|
|
109
112
|
if (command === "call")
|
|
110
113
|
lines.push("", "Read a saved request: flovia call <tool> - < request.json", ...SAVE_OP);
|
|
111
114
|
lines.push("", "Default base URL: https://api.flovia.dev.", "Exit codes: 0 ok, 1 error from Flovia, 2 usage error.", "");
|
|
@@ -283,6 +286,16 @@ export function renderResets(r, s, now = Date.now()) {
|
|
|
283
286
|
lines.push("Using one starts both free windows (5-hour and week) again from 0%. It cannot be undone.", `To use it: flovia resets use ${r.next.id} --yes`);
|
|
284
287
|
return lines.join("\n") + "\n";
|
|
285
288
|
}
|
|
289
|
+
export function renderConsent(c) {
|
|
290
|
+
const lines = [`${label("current notice")}${c.version}`, `${label("your yes")}${c.answered_version ?? "none"}`];
|
|
291
|
+
if (!c.needed && !c.updated)
|
|
292
|
+
return lines.join("\n") + "\n";
|
|
293
|
+
if (c.updated)
|
|
294
|
+
lines.push("", c.version === "relay-consent-19" ? "Your earlier yes keeps working. Notice 19 adds owner-only lookup reply copies for up to 30 days for new records from 2026-12-03 or after your fresh explicit yes. Earlier records keep their original periods; no answer is needed to keep looking up." : "Your earlier yes keeps working. If you keep using Flovia from 2026-12-01 (30 days after the notice), you agree to the current notice; recording a yes below now is optional and applies from when you give it.");
|
|
295
|
+
lines.push("", "Notice:", c.notice);
|
|
296
|
+
lines.push("", `To answer yes yourself: flovia consent accept ${c.version} --yes (or in Console: ${CONSOLE})`);
|
|
297
|
+
return lines.join("\n") + "\n";
|
|
298
|
+
}
|
|
286
299
|
/** A refusal or failure: code, next_step, executed; a handshake's notice or question is shown for the person, never answered here. */
|
|
287
300
|
export function renderError(e) {
|
|
288
301
|
const lines = [`error: ${e.code}: ${e.message}`];
|
|
@@ -424,6 +437,35 @@ export async function run(argv, io) {
|
|
|
424
437
|
: `Not used; nothing changed.\n${label("saved resets")}${u.available}\nCheck: flovia resets\n`);
|
|
425
438
|
return u.outcome === "used" ? 0 : 1;
|
|
426
439
|
}
|
|
440
|
+
case "consent": {
|
|
441
|
+
const [action, version, extra] = p.positional;
|
|
442
|
+
if (action === undefined) {
|
|
443
|
+
if (p.flags.has("--yes"))
|
|
444
|
+
throw new Usage("Usage: flovia consent accept <version> --yes");
|
|
445
|
+
const client = await connect(), c = await waitFor(() => client.consent());
|
|
446
|
+
if (json)
|
|
447
|
+
print(c);
|
|
448
|
+
else
|
|
449
|
+
out(renderConsent(c));
|
|
450
|
+
return 0;
|
|
451
|
+
}
|
|
452
|
+
if (action !== "accept" || version === undefined || extra !== undefined)
|
|
453
|
+
throw new Usage("Usage: flovia consent accept <version> --yes (the version from flovia consent)");
|
|
454
|
+
const client = await connect();
|
|
455
|
+
if (!p.flags.has("--yes")) {
|
|
456
|
+
// Show what would be agreed to, then stop: nothing is sent without --yes.
|
|
457
|
+
const c = await waitFor(() => client.consent());
|
|
458
|
+
if (!json)
|
|
459
|
+
out(renderConsent(c));
|
|
460
|
+
throw new Usage(`consent accept: nothing was sent. Read the notice, then add --yes to answer yes to ${version} yourself.`);
|
|
461
|
+
}
|
|
462
|
+
const a = await waitFor(() => client.acceptConsent(version));
|
|
463
|
+
if (json)
|
|
464
|
+
print(a);
|
|
465
|
+
else
|
|
466
|
+
out(a.outcome === "recorded" ? `Recorded: yes to ${a.version}.\n` : `Already answered yes to ${a.version}; nothing changed.\n`);
|
|
467
|
+
return 0;
|
|
468
|
+
}
|
|
427
469
|
case "usage": {
|
|
428
470
|
const since = str(p.flags.get("--since")), days = positiveInt("--days", str(p.flags.get("--days")), 7), cursor = str(p.flags.get("--cursor"));
|
|
429
471
|
if (since !== undefined && days !== undefined)
|
|
@@ -523,7 +565,7 @@ export async function run(argv, io) {
|
|
|
523
565
|
// The id is shown before anything is sent, so a lost reply can be reopened with it (never resent under a new one).
|
|
524
566
|
if (fresh)
|
|
525
567
|
err(`operation_id: ${id}\nSave it. To resend or reopen this request, use: --op ${id}\n`);
|
|
526
|
-
err("This generation uses your free allowance first, then your purchased balance.\nIf the reply is lost, rerun with the same --op, prompt, output limit and effort.\nA saved answer
|
|
568
|
+
err("This generation uses your free allowance first, then your purchased balance.\nIf the reply is lost, rerun with the same --op, prompt, output limit and effort.\nA saved answer may reopen free: up to 30 days from creation for notice 18 generations; earlier ones about 15 minutes. Missing or deleted copies are not restored. Never use a new id to recover an answer.\n");
|
|
527
569
|
if (!p.flags.has("--yes")) {
|
|
528
570
|
if (io.confirm === null || text === "-")
|
|
529
571
|
throw new Usage("generate: add --yes to send (no terminal to confirm on)");
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Generation, type GenerationRequest, type StatusReply, type ToolReply, type UsageTodayArgs, type UsageTodayReply, type BankedResets, type BankedResetUse } from "./types.js";
|
|
1
|
+
import { type Generation, type GenerationRequest, type StatusReply, type ToolReply, type UsageTodayArgs, type UsageTodayReply, type BankedResets, type BankedResetUse, type ConsentState, type ConsentAccept } from "./types.js";
|
|
2
2
|
export interface FloviaClientOptions {
|
|
3
3
|
/** A Flovia key (flv_...). Defaults to the FLOVIA_KEY environment variable. Never logged. */
|
|
4
4
|
apiKey?: string;
|
|
@@ -27,7 +27,7 @@ export declare const newOperationId: () => string;
|
|
|
27
27
|
export declare class FloviaClient {
|
|
28
28
|
#private;
|
|
29
29
|
constructor(options?: FloviaClientOptions);
|
|
30
|
-
/** Download an existing Runway output before
|
|
30
|
+
/** Download an existing Runway output before output.expires_at (up to 30 days under notice 18; earlier outputs keep 24h). This GET never creates, regenerates or retries a task. */
|
|
31
31
|
downloadRunwayOutput(generationId: string): Promise<{
|
|
32
32
|
data: Uint8Array;
|
|
33
33
|
contentType: string;
|
|
@@ -39,6 +39,13 @@ export declare class FloviaClient {
|
|
|
39
39
|
* "not_used" means nothing changed. After a lost, refused (401) or unreadable reply, check bankedResets() before deciding to try again.
|
|
40
40
|
*/
|
|
41
41
|
useBankedReset(grantId: number): Promise<BankedResetUse>;
|
|
42
|
+
/** The account's answer to Flovia's current notice and the notice text. Read-only; nothing is answered. */
|
|
43
|
+
consent(): Promise<ConsentState>;
|
|
44
|
+
/**
|
|
45
|
+
* Record the account owner's own yes to exactly this notice version (from consent()). Only call it on the owner's explicit instruction; an agent must
|
|
46
|
+
* never answer for them. An older version is refused and nothing is recorded; a repeat changes nothing.
|
|
47
|
+
*/
|
|
48
|
+
acceptConsent(version: string): Promise<ConsentAccept>;
|
|
42
49
|
/** tools/list: the tools this key is offered, with their input schemas. */
|
|
43
50
|
listTools(): Promise<ToolInfo[]>;
|
|
44
51
|
/** tools/call for any tool. A reply with ok: false throws FloviaError (handshakes such as notice_first too; see error.reply). */
|
|
@@ -49,7 +56,8 @@ export declare class FloviaClient {
|
|
|
49
56
|
usageToday(args?: UsageTodayArgs): Promise<UsageTodayReply>;
|
|
50
57
|
/**
|
|
51
58
|
* POST /openai/v1/responses. operationId is required: save it with the request before calling. Sending the same request with the same id
|
|
52
|
-
* again can return the saved answer (replayed: true)
|
|
59
|
+
* again can return the saved answer (replayed: true) at no charge: notice 18 generations up to 30 days from creation, earlier ones about 15 minutes.
|
|
60
|
+
* Missing or deleted copies are not restored. Pending, unknown and expired answers
|
|
53
61
|
* are not proof that nothing ran. Never resent automatically, and never under a new id to recover an answer.
|
|
54
62
|
*/
|
|
55
63
|
generate(request: GenerationRequest, options: {
|
package/dist/client.js
CHANGED
|
@@ -119,7 +119,7 @@ export class FloviaClient {
|
|
|
119
119
|
message: String(message.error?.message ?? "No result."), nextStep: operationId ? SAME_OPERATION : null });
|
|
120
120
|
return message.result;
|
|
121
121
|
}
|
|
122
|
-
/** Download an existing Runway output before
|
|
122
|
+
/** Download an existing Runway output before output.expires_at (up to 30 days under notice 18; earlier outputs keep 24h). This GET never creates, regenerates or retries a task. */
|
|
123
123
|
async downloadRunwayOutput(generationId) {
|
|
124
124
|
const unavailable = () => this.#error({ code: "output_unavailable", executed: "no", message: "The private output could not be downloaded.", nextStep: "Check the original generation's status and expiry; never regenerate it automatically." });
|
|
125
125
|
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(generationId))
|
|
@@ -194,6 +194,37 @@ export class FloviaClient {
|
|
|
194
194
|
throw this.#error({ code: "invalid_reply", status: r.status, executed: "unknown", message: "The saved-reset reply was not in the expected form.", nextStep: check });
|
|
195
195
|
return { outcome: body["outcome"], available: body.available, next: body.next };
|
|
196
196
|
}
|
|
197
|
+
/** The account's answer to Flovia's current notice and the notice text. Read-only; nothing is answered. */
|
|
198
|
+
async consent() {
|
|
199
|
+
const r = await this.#send("/account/consent", null, {}, null, "GET");
|
|
200
|
+
const body = await this.#account(r, null);
|
|
201
|
+
if (!isConsent(body))
|
|
202
|
+
throw this.#error({ code: "invalid_reply", status: r.status, executed: "no", message: "The consent reply was not in the expected form.", nextStep: null });
|
|
203
|
+
return { version: body.version, answered_version: body.answered_version, needed: body.needed, updated: body.updated, notice: body.notice };
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Record the account owner's own yes to exactly this notice version (from consent()). Only call it on the owner's explicit instruction; an agent must
|
|
207
|
+
* never answer for them. An older version is refused and nothing is recorded; a repeat changes nothing.
|
|
208
|
+
*/
|
|
209
|
+
async acceptConsent(version) {
|
|
210
|
+
if (typeof version !== "string" || !/^[a-z0-9-]{1,80}$/.test(version))
|
|
211
|
+
throw new FloviaError({ code: "invalid_request", executed: "no", message: "version must be the version from consent()." });
|
|
212
|
+
const check = "It may have been recorded. Run consent() (flovia consent) to see whether it was recorded before trying again.";
|
|
213
|
+
const unknown = (e) => this.#error({ code: e.code, status: e.status, executed: "unknown", message: e.message,
|
|
214
|
+
nextStep: e.nextStep && e.executed !== "unknown" ? `${check} ${e.nextStep}` : check });
|
|
215
|
+
let r;
|
|
216
|
+
try {
|
|
217
|
+
r = await this.#send("/account/consent/accept", { version });
|
|
218
|
+
}
|
|
219
|
+
// The relay rechecks the key after the write, so a 401 does not prove that nothing was recorded.
|
|
220
|
+
catch (e) {
|
|
221
|
+
throw e instanceof FloviaError && (e.executed === "unknown" || e.status === 401) ? unknown(e) : e;
|
|
222
|
+
}
|
|
223
|
+
const body = await this.#account(r, check);
|
|
224
|
+
if (!isConsent(body) || (body["outcome"] !== "recorded" && body["outcome"] !== "unchanged"))
|
|
225
|
+
throw this.#error({ code: "invalid_reply", status: r.status, executed: "unknown", message: "The consent reply was not in the expected form.", nextStep: check });
|
|
226
|
+
return { outcome: body["outcome"], version: body.version, answered_version: body.answered_version, needed: body.needed, updated: body.updated, notice: body.notice };
|
|
227
|
+
}
|
|
197
228
|
async #account(r, unknownStep) {
|
|
198
229
|
let body;
|
|
199
230
|
try {
|
|
@@ -262,7 +293,8 @@ export class FloviaClient {
|
|
|
262
293
|
}
|
|
263
294
|
/**
|
|
264
295
|
* POST /openai/v1/responses. operationId is required: save it with the request before calling. Sending the same request with the same id
|
|
265
|
-
* again can return the saved answer (replayed: true)
|
|
296
|
+
* again can return the saved answer (replayed: true) at no charge: notice 18 generations up to 30 days from creation, earlier ones about 15 minutes.
|
|
297
|
+
* Missing or deleted copies are not restored. Pending, unknown and expired answers
|
|
266
298
|
* are not proof that nothing ran. Never resent automatically, and never under a new id to recover an answer.
|
|
267
299
|
*/
|
|
268
300
|
async generate(request, options) {
|
|
@@ -292,6 +324,11 @@ function isResets(b) {
|
|
|
292
324
|
return count(b["available"], 0) && (next === null || (typeof next === "object" && !Array.isArray(next) && count(next["id"], 1)
|
|
293
325
|
&& typeof next["expires_at"] === "string" && !Number.isNaN(Date.parse(next["expires_at"])))) && (next === null) === (b["available"] === 0);
|
|
294
326
|
}
|
|
327
|
+
function isConsent(b) {
|
|
328
|
+
const text = (v) => typeof v === "string" && v.length > 0;
|
|
329
|
+
return text(b["version"]) && (b["answered_version"] === null || text(b["answered_version"])) && typeof b["needed"] === "boolean"
|
|
330
|
+
&& typeof b["updated"] === "boolean" && text(b["notice"]);
|
|
331
|
+
}
|
|
295
332
|
/** Whether a refused generation ran, from its public code (the same reading flovia_openai gives over MCP). */
|
|
296
333
|
function generationExecuted(code) {
|
|
297
334
|
if (["answer_unavailable", "answer_expired", "answer_delivery_denied"].includes(code))
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** The relay's tool contract this SDK was written against (flovia_status.contract_version). */
|
|
2
|
-
export declare const EXPECTED_CONTRACT_VERSION = "2026-10-07.
|
|
2
|
+
export declare const EXPECTED_CONTRACT_VERSION = "2026-10-07.172";
|
|
3
3
|
/** Every public explanation.code (the relay's contract). A provider's own HTTP error is `http_<status>`. */
|
|
4
|
-
export declare const PUBLIC_CODES: readonly ["approval_pending", "key_disabled", "key_stopped", "consent_missing", "data_consent_mismatch", "data_consent_needed", "notice_first", "provider_not_allowed", "endpoint_unknown", "endpoint_disabled", "read_only", "not_relayed", "key_in_query", "secret_in_input", "invalid_body", "body_too_large", "answer_too_large", "answer_precision_unsafe", "answer_not_relayed", "request_text_too_long", "over_max_credits", "window_5h", "window_month", "window_week", "over_week", "free_limited", "free_needs_email", "free_not_granted", "global_cap", "flovia_paused", "rate_limited", "too_many_in_parallel", "reservation_changed", "operation_conflict", "operation_pending", "relay_internal_error", "upstream_unknown", "cannot_summarize", "upstream_unavailable", "page_tls_invalid", "page_unreachable", "replay_response_unavailable", "rpc_error", "unknown_lookup", "invalid_cursor", "since_too_old", "since_in_future", "feedback_too_long", "feedback_limit", "not_configured", "service_off"];
|
|
4
|
+
export declare const PUBLIC_CODES: readonly ["approval_pending", "key_disabled", "key_stopped", "consent_missing", "data_consent_mismatch", "data_consent_needed", "notice_first", "provider_not_allowed", "account_key_required", "endpoint_unknown", "endpoint_disabled", "read_only", "not_relayed", "key_in_query", "secret_in_input", "invalid_body", "body_too_large", "answer_too_large", "answer_precision_unsafe", "answer_not_relayed", "request_text_too_long", "over_max_credits", "window_5h", "window_month", "window_week", "over_week", "free_limited", "free_needs_email", "free_not_granted", "global_cap", "flovia_paused", "rate_limited", "too_many_in_parallel", "reservation_changed", "operation_conflict", "operation_pending", "relay_internal_error", "relay_internal_unknown", "upstream_unknown", "cannot_summarize", "upstream_unavailable", "page_tls_invalid", "page_unreachable", "replay_response_unavailable", "rpc_error", "unknown_lookup", "invalid_cursor", "since_too_old", "since_in_future", "feedback_too_long", "feedback_limit", "not_configured", "service_off"];
|
|
5
5
|
export type FloviaCode = (typeof PUBLIC_CODES)[number] | `http_${number}`;
|
|
6
6
|
/** Whether the request ran upstream: "unknown" means keep the same operation_id and never send a replacement. */
|
|
7
7
|
export type Executed = "yes" | "no" | "unknown";
|
|
@@ -92,3 +92,16 @@ export interface BankedResets {
|
|
|
92
92
|
export interface BankedResetUse extends BankedResets {
|
|
93
93
|
outcome: "used" | "not_used";
|
|
94
94
|
}
|
|
95
|
+
/** GET /account/consent: the current notice version, the version this account last said yes to (null: none), and the notice text.
|
|
96
|
+
* updated: the yes is to an earlier version; it keeps working and continued use accepts the current one, so an explicit yes is optional. */
|
|
97
|
+
export interface ConsentState {
|
|
98
|
+
version: string;
|
|
99
|
+
answered_version: string | null;
|
|
100
|
+
needed: boolean;
|
|
101
|
+
updated: boolean;
|
|
102
|
+
notice: string;
|
|
103
|
+
}
|
|
104
|
+
/** "recorded": the yes to the current notice was saved now. "unchanged": it was already saved; nothing changed. */
|
|
105
|
+
export interface ConsentAccept extends ConsentState {
|
|
106
|
+
outcome: "recorded" | "unchanged";
|
|
107
|
+
}
|
package/dist/types.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/** The relay's tool contract this SDK was written against (flovia_status.contract_version). */
|
|
2
|
-
export const EXPECTED_CONTRACT_VERSION = "2026-10-07.
|
|
2
|
+
export const EXPECTED_CONTRACT_VERSION = "2026-10-07.172";
|
|
3
3
|
/** Every public explanation.code (the relay's contract). A provider's own HTTP error is `http_<status>`. */
|
|
4
4
|
export const PUBLIC_CODES = [
|
|
5
5
|
"approval_pending", "key_disabled", "key_stopped", "consent_missing", "data_consent_mismatch", "data_consent_needed", "notice_first",
|
|
6
|
-
"provider_not_allowed", "endpoint_unknown", "endpoint_disabled", "read_only", "not_relayed", "key_in_query", "secret_in_input", "invalid_body", "body_too_large",
|
|
6
|
+
"provider_not_allowed", "account_key_required", "endpoint_unknown", "endpoint_disabled", "read_only", "not_relayed", "key_in_query", "secret_in_input", "invalid_body", "body_too_large",
|
|
7
7
|
"answer_too_large", "answer_precision_unsafe", "answer_not_relayed", "request_text_too_long",
|
|
8
8
|
"over_max_credits", "window_5h", "window_month", "window_week", "over_week", "free_limited", "free_needs_email", "free_not_granted", "global_cap",
|
|
9
9
|
"flovia_paused", "rate_limited", "too_many_in_parallel", "reservation_changed",
|
|
10
|
-
"operation_conflict", "operation_pending", "relay_internal_error", "upstream_unknown", "cannot_summarize", "upstream_unavailable", "page_tls_invalid", "page_unreachable", "replay_response_unavailable", "rpc_error",
|
|
10
|
+
"operation_conflict", "operation_pending", "relay_internal_error", "relay_internal_unknown", "upstream_unknown", "cannot_summarize", "upstream_unavailable", "page_tls_invalid", "page_unreachable", "replay_response_unavailable", "rpc_error",
|
|
11
11
|
"unknown_lookup", "invalid_cursor", "since_too_old", "since_in_future", "feedback_too_long", "feedback_limit", "not_configured", "service_off",
|
|
12
12
|
];
|
package/package.json
CHANGED