@flovialabs/sdk 0.1.11 → 0.1.12

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 CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.1.12
6
+
7
+ - Expect contract `2026-10-07.146`: Flovia can look up public X posts (recent search and counts, one post and its quote posts, an account's recent posts); the tool is closed unless Flovia offers it.
8
+
9
+ - Expect contract `2026-10-07.145`: reopened Nansen trade quotes replace transaction data with SHA-256 fingerprints. Fresh replies are unchanged; preparation uses only an owned, encrypted short-lived quote copy when enabled.
10
+
11
+ - Expect contract `2026-10-07.144`: the Base unsigned-preparation tool takes an owned quote reference and index, with separately billed chain checks; it is available only when Flovia offers it. `cannot_summarize` returns nothing to sign; Flovia does not charge for the preparation. Flovia never signs or sends.
12
+
13
+ - Contract `2026-10-07.143` adds nine read-only Nansen GET endpoints for swap quotes, bridge status, perp account data and token sectors.
14
+
15
+ - `FloviaCode` and `PUBLIC_CODES` include the relay's Firecrawl codes `page_tls_invalid` and `page_unreachable`.
16
+
17
+ - Expect contract `2026-10-07.138`: Exa accepts optional `text_max_characters` (1–12,000) for page text in the existing search. Missing text and possible truncation are marked; all results share the existing reply budget. Default excerpts, search count and charges are unchanged.
18
+
19
+ - Expect contract `2026-10-07.137`: Exa supports optional publication-date bounds and category filters; default search and charges are unchanged.
20
+
21
+ - The CLI reads the key from `~/.config/flovia/key` when neither `--key-file` nor `FLOVIA_KEY` is given.
22
+
23
+ - Expect relay contract `2026-10-07.136`: `flovia_feedback` accepts optional `type` and `area` fields for user feedback and agent-observed reports. Existing calls without these fields still work.
24
+
5
25
  ## 0.1.11
6
26
 
7
27
  - SDK request-construction failures use `invalid_request` with `executed: no` before any request is sent; raw exception causes are not exposed.
package/README.md CHANGED
@@ -10,13 +10,13 @@ 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.11
13
+ npm install --save-exact @flovialabs/sdk@0.1.12
14
14
  ```
15
15
 
16
16
  ## Your key
17
17
 
18
- 1. Open the link in your invitation email and register.
19
- 2. In [Flovia Console](https://console.flovia.dev/groupbuy/), create an API key. Console shows it once; save it somewhere private.
18
+ 1. Register at https://console.flovia.dev/auth/register with email verification and a Passkey.
19
+ 2. In [Flovia Console](https://console.flovia.dev/groupbuy/), press Create API key. Console shows it once; save it somewhere private.
20
20
  3. Set the key (`flv_...`) in the environment, then check it:
21
21
 
22
22
  ```sh
@@ -24,9 +24,13 @@ export FLOVIA_KEY=flv_...
24
24
  npx flovia status
25
25
  ```
26
26
 
27
+ Without `FLOVIA_KEY` or `--key-file`, the CLI reads `~/.config/flovia/key`, the file Console's Claude Code setup saves.
28
+
29
+ Claude Code pluginの既定の保存先は別ファイル `~/.config/flovia/relay-key` です。Consoleでキーを更新したら、CLIのキーファイル(または `FLOVIA_KEY`)とpluginの両方を更新し、pluginはClaude Codeで `/flovia:setup` を再実行してください(基点 `28e5cbeee1d7bca5c68c18d765e576445e452997`、2026-10-25確認)。
30
+
27
31
  `status` shows how much of your free allowance you have used, and your purchased balance. A $0 purchased balance is fine while free allowance remains.
28
32
 
29
- Keys from the test period no longer work. The [Quickstart](https://flovia.dev/docs/quickstart) has the full steps, and [Free and paid use](https://flovia.dev/docs/usage) explains the limits. If the invitation is missing or you lose your key, [contact Flovia](https://flovia.dev/contact). Installing this package does not create an account or start a free allowance.
33
+ Keys from the test period no longer work. The [Quickstart](https://docs.flovia.dev/get-started/quickstart/) has the full steps, and [Free and paid use](https://docs.flovia.dev/usage/) explains the limits. If you lose your key or think it leaked, regenerate it on the API Key tab in [Flovia Console](https://console.flovia.dev/groupbuy/); the old key stops working at once. Installing this package does not create an account or start a free allowance.
30
34
 
31
35
  In code, the client reads `FLOVIA_KEY`, or you can pass it as `new FloviaClient({ apiKey })`. The client keeps the key private: it does not appear in logs, error messages or `console.log(client)`. The SDK sends no telemetry.
32
36
 
@@ -183,7 +187,7 @@ A refusal (`ok: false`) or a failed request throws `FloviaError`:
183
187
  | `operationId` | the operation id of the request |
184
188
  | `reply` | the full reply body |
185
189
 
186
- HTTP 401 with `code: "formal_registration_required"` means test access ended: complete formal registration from the invitation email, then reconnect through Console. A generic `unauthorized` means the key was not accepted; check your account and current key in Console. Both are unsent (`executed: "no"`) and are never retried automatically. The SDK does not expose arbitrary authentication response bodies.
190
+ HTTP 401 with `code: "formal_registration_required"` means test access ended: register at https://console.flovia.dev/auth/register with email verification and a Passkey (or use the link in your invitation email if you have one); if you have already registered, sign in to Console, press Create API key, then reconnect with the new key. A generic `unauthorized` means the key was not accepted; check your account and current key in Console. Both are unsent (`executed: "no"`) and are never retried automatically. The SDK does not expose arbitrary authentication response bodies.
187
191
 
188
192
  ### `notice_first` and `data_consent_needed`: a human must answer
189
193
 
@@ -230,7 +234,7 @@ npx flovia agents-md # a short note for CLAUDE.md or AGENTS.md
230
234
  npx flovia help
231
235
  npx flovia --version
232
236
  ```
233
- These commands run after installing `@flovialabs/sdk` in the current project. Without a local installation, specify the package: `npx --package=@flovialabs/sdk@0.1.11 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.
237
+ These commands run after installing `@flovialabs/sdk` in the current project. Without a local installation, specify the package: `npx --package=@flovialabs/sdk@0.1.12 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.
234
238
 
235
239
  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.
236
240
 
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * flovia: a small CLI over the SDK's public client, for people to check their status and usage and try calls with their own key.
4
- * The key comes from FLOVIA_KEY or --key-file only (never argv, which ps shows), and is never printed. Exit 2: usage error; 1: a relay error.
4
+ * The key comes from FLOVIA_KEY, --key-file or ~/.config/flovia/key only (never argv, which ps shows), and is never printed. Exit 2: usage error; 1: a relay error.
5
5
  */
6
6
  import { readFile, stat } from "node:fs/promises";
7
7
  import { readFileSync, realpathSync } from "node:fs";
@@ -84,7 +84,7 @@ export function help(command) {
84
84
  const c = command === undefined || !Object.hasOwn(COMMANDS, command) ? undefined : COMMANDS[command];
85
85
  const lines = c === undefined ? ["Usage: flovia <command> [options]", "",
86
86
  ...Object.values(COMMANDS).flatMap((x) => [` ${x.usage}`, ` ${x.about}`])] : [`Usage: flovia ${c.usage}`, ` ${c.about}`];
87
- lines.push("", "Options: " + GLOBAL, "", `Get or manage your key: ${CONSOLE}`, "Save the key privately, then: flovia status --key-file <saved-key-file>", "Or set FLOVIA_KEY. Never paste the key into a command argument.");
87
+ lines.push("", "Options: " + GLOBAL, "", `Get or manage your key: ${CONSOLE}`, "Save the key privately, then: flovia status --key-file <saved-key-file>", "Or set FLOVIA_KEY, or save it to ~/.config/flovia/key.", "Never paste the key into a command argument.");
88
88
  if (command === "generate")
89
89
  lines.push("", "Default output limit: 1000 tokens; maximum: 4000.", "--reasoning-effort: none (default), low, medium, high, xhigh, max.", "Reasoning shares the output token limit; higher effort can leave less visible text.", "Long answers can take minutes. Save the id, same input, output limit and effort.", " flovia generate --new-op --reasoning-effort high --yes - < prompt.txt", "Replay only: replace --new-op with --op <saved-id>; keep everything else.", "Use -- before a prompt that starts with a hyphen.");
90
90
  if (command === "tools" || c === undefined)
@@ -148,29 +148,35 @@ function reasoningEffort(v) {
148
148
  return v;
149
149
  throw new Usage("--reasoning-effort must be one of: none, low, medium, high, xhigh, max");
150
150
  }
151
- /** The key from --key-file (trimmed) or FLOVIA_KEY. Its text never goes into a message. */
151
+ /** The key from --key-file, FLOVIA_KEY, or the file Console's setup saves (~/.config/flovia/key), in that order, trimmed. Its text never goes into a message. */
152
152
  async function readKey(p, io) {
153
153
  const file = str(p.flags.get("--key-file"));
154
- if (file !== undefined) {
155
- let text;
156
- // Never echo the path: a key pasted in its place would land in the output.
157
- try {
158
- text = await io.readFile(file);
159
- }
160
- catch {
161
- throw new Usage("--key-file: cannot read the key file");
162
- }
163
- const key = text.trim();
164
- if (key === "")
165
- throw new Usage("--key-file: the key file is empty");
166
- const mode = await io.fileMode?.(file).catch(() => null);
167
- if (typeof mode === "number" && (mode & 0o077) !== 0)
168
- io.err(`warning: the key file is readable by other users (mode ${(mode & 0o777).toString(8)}); run chmod 600 on it\n`);
154
+ if (file !== undefined)
155
+ return fromFile(file, io, "--key-file");
156
+ const key = io.env["FLOVIA_KEY"]?.trim();
157
+ if (key)
169
158
  return key;
159
+ const home = io.env["HOME"];
160
+ if (home && await io.readFile(`${home}/${DEFAULT_KEY_FILE}`).then(() => true, () => false))
161
+ return fromFile(`${home}/${DEFAULT_KEY_FILE}`, io, `~/${DEFAULT_KEY_FILE}`);
162
+ throw new Usage(`No key: set FLOVIA_KEY, pass --key-file PATH, or save it to ~/${DEFAULT_KEY_FILE}. Never paste a key as an argument.\nGet or manage your key: ${CONSOLE}\nThen: flovia status --key-file <saved-key-file>`);
163
+ }
164
+ const DEFAULT_KEY_FILE = ".config/flovia/key";
165
+ async function fromFile(file, io, label) {
166
+ let text;
167
+ // Never echo a user-given path: a key pasted in its place would land in the output.
168
+ try {
169
+ text = await io.readFile(file);
170
170
  }
171
- const key = io.env["FLOVIA_KEY"]?.trim();
172
- if (!key)
173
- throw new Usage(`No key: set FLOVIA_KEY or pass --key-file PATH. Never paste a key as an argument.\nGet or manage your key: ${CONSOLE}\nThen: flovia status --key-file <saved-key-file>`);
171
+ catch {
172
+ throw new Usage(`${label}: cannot read the key file`);
173
+ }
174
+ const key = text.trim();
175
+ if (key === "")
176
+ throw new Usage(`${label}: the key file is empty`);
177
+ const mode = await io.fileMode?.(file).catch(() => null);
178
+ if (typeof mode === "number" && (mode & 0o077) !== 0)
179
+ io.err(`warning: the key file is readable by other users (mode ${(mode & 0o777).toString(8)}); run chmod 600 on it\n`);
174
180
  return key;
175
181
  }
176
182
  const pct = (v) => typeof v === "number" ? `${v}%` : "-";
package/dist/client.js CHANGED
@@ -106,7 +106,7 @@ export class FloviaClient {
106
106
  const formal = auth !== null && typeof auth === "object" && "error" in auth && auth.error === "formal_registration_required";
107
107
  throw this.#error({ code: formal ? "formal_registration_required" : "unauthorized", status: 401, executed: "no", operationId,
108
108
  message: formal ? "Test access has ended. API keys issued during the test no longer work." : "The Flovia key was not accepted.",
109
- nextStep: formal ? "Complete formal registration from your invitation email, then open https://console.flovia.dev/auth/ to connect your app again."
109
+ nextStep: formal ? "Register at https://console.flovia.dev/auth/register with email verification and a Passkey (or use the link in your invitation email if you have one); if you have already registered, sign in at https://console.flovia.dev/auth/, open Console, press Create API key, then reconnect with the new key."
110
110
  : "Open https://console.flovia.dev/groupbuy/ to check your account and get a current key. Do not resend with the same key." });
111
111
  }
112
112
  return r;
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.135";
2
+ export declare const EXPECTED_CONTRACT_VERSION = "2026-10-07.146";
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", "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_week", "over_week", "free_limited", "free_needs_email", "global_cap", "flovia_paused", "rate_limited", "too_many_in_parallel", "reservation_changed", "operation_conflict", "operation_pending", "upstream_unknown", "upstream_unavailable", "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", "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_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", "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";
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.135";
2
+ export const EXPECTED_CONTRACT_VERSION = "2026-10-07.146";
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
6
  "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
- "over_max_credits", "window_5h", "window_week", "over_week", "free_limited", "free_needs_email", "global_cap",
8
+ "over_max_credits", "window_5h", "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", "upstream_unknown", "upstream_unavailable", "replay_response_unavailable", "rpc_error",
10
+ "operation_conflict", "operation_pending", "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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flovialabs/sdk",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "type": "module",
5
5
  "description": "TypeScript client and CLI for Flovia: MCP tools over HTTP and OpenAI-compatible generation. Zero dependencies.",
6
6
  "license": "MIT",