@flovialabs/sdk 0.1.23 → 0.1.25

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 (49) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +27 -14
  3. package/dist/account.d.ts +12 -0
  4. package/dist/account.js +110 -0
  5. package/dist/accountcommands.d.ts +17 -0
  6. package/dist/accountcommands.js +124 -0
  7. package/dist/args.d.ts +19 -0
  8. package/dist/args.js +91 -0
  9. package/dist/cli.d.ts +11 -36
  10. package/dist/cli.js +31 -993
  11. package/dist/client.d.ts +4 -5
  12. package/dist/client.js +29 -294
  13. package/dist/commandhelp.d.ts +7 -0
  14. package/dist/commandhelp.js +52 -0
  15. package/dist/doctor.d.ts +11 -7
  16. package/dist/doctor.js +50 -23
  17. package/dist/doctorcommand.d.ts +9 -0
  18. package/dist/doctorcommand.js +125 -0
  19. package/dist/examples.d.ts +2 -0
  20. package/dist/examples.js +29 -0
  21. package/dist/generatecommand.d.ts +15 -0
  22. package/dist/generatecommand.js +64 -0
  23. package/dist/generation.d.ts +6 -0
  24. package/dist/generation.js +30 -0
  25. package/dist/install.d.ts +15 -2
  26. package/dist/install.js +77 -12
  27. package/dist/installcommand.d.ts +4 -0
  28. package/dist/installcommand.js +251 -0
  29. package/dist/keyfile.d.ts +6 -0
  30. package/dist/keyfile.js +33 -0
  31. package/dist/nodeio.d.ts +7 -0
  32. package/dist/nodeio.js +62 -0
  33. package/dist/output.d.ts +26 -0
  34. package/dist/output.js +196 -0
  35. package/dist/reply.d.ts +9 -0
  36. package/dist/reply.js +36 -0
  37. package/dist/runwayoutput.d.ts +5 -0
  38. package/dist/runwayoutput.js +44 -0
  39. package/dist/sandbox.d.ts +13 -0
  40. package/dist/sandbox.js +80 -0
  41. package/dist/sandboxcommands.d.ts +14 -0
  42. package/dist/sandboxcommands.js +90 -0
  43. package/dist/toolcommands.d.ts +14 -0
  44. package/dist/toolcommands.js +65 -0
  45. package/dist/transport.d.ts +11 -0
  46. package/dist/transport.js +2 -0
  47. package/dist/types.d.ts +20 -7
  48. package/dist/types.js +3 -2
  49. package/package.json +5 -2
@@ -0,0 +1,5 @@
1
+ import type { Transport } from "./transport.js";
2
+ export declare function downloadRunwayOutput(t: Transport, generationId: string): Promise<{
3
+ data: Uint8Array;
4
+ contentType: string;
5
+ }>;
@@ -0,0 +1,44 @@
1
+ import { FloviaError } from "./errors.js";
2
+ export async function downloadRunwayOutput(t, generationId) {
3
+ const unavailable = () => t.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." });
4
+ 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))
5
+ throw t.error({ code: "invalid_request", executed: "no", message: "Use the generation_id returned by Flovia, never a URL or upstream task ID." });
6
+ let reader;
7
+ try {
8
+ const response = await t.send("/mcp?runway_output=" + generationId, null, { Accept: "image/png, image/jpeg, image/webp, video/mp4" }, null, "GET");
9
+ const contentType = response.headers.get("Content-Type"), declared = response.headers.get("Content-Length"), length = declared === null ? null : Number(declared), limit = 32 * 1024 * 1024;
10
+ if (response.status !== 200 || !response.body || contentType === null || !["image/png", "image/jpeg", "image/webp", "video/mp4"].includes(contentType ?? "") ||
11
+ length !== null && (!Number.isSafeInteger(length) || length < 1 || length > limit))
12
+ throw unavailable();
13
+ reader = response.body.getReader();
14
+ const chunks = [];
15
+ let size = 0;
16
+ while (true) {
17
+ const { value, done } = await reader.read();
18
+ if (done)
19
+ break;
20
+ size += value.byteLength;
21
+ if (size > limit)
22
+ throw unavailable();
23
+ chunks.push(value);
24
+ }
25
+ if (size === 0 || length !== null && size !== length)
26
+ throw unavailable();
27
+ const data = new Uint8Array(size);
28
+ let offset = 0;
29
+ for (const chunk of chunks) {
30
+ data.set(chunk, offset);
31
+ offset += chunk.byteLength;
32
+ }
33
+ return { data, contentType };
34
+ }
35
+ catch (error) {
36
+ await reader?.cancel().catch(() => { });
37
+ if (error instanceof FloviaError && ["unauthorized", "formal_registration_required"].includes(error.code))
38
+ throw error;
39
+ throw unavailable();
40
+ }
41
+ finally {
42
+ reader?.releaseLock();
43
+ }
44
+ }
@@ -0,0 +1,13 @@
1
+ import { type Transport } from "./transport.js";
2
+ import type { SandboxRunArgs, SandboxRunReply, SandboxResultOptions, SandboxResultReply, SandboxRunsReply, SandboxScheduleSet, SandboxSchedulesReply, WorkspaceListReply, WorkspaceReadPart, WorkspaceReadReply } from "./types.js";
3
+ export declare function sandboxRun(t: Transport, args: SandboxRunArgs): Promise<SandboxRunReply>;
4
+ export declare function sandboxRuns(t: Transport): Promise<SandboxRunsReply>;
5
+ export declare function sandboxResult(t: Transport, runId: string, options?: SandboxResultOptions): Promise<SandboxResultReply>;
6
+ export declare function sandboxSchedules(t: Transport): Promise<SandboxSchedulesReply>;
7
+ export declare function setSandboxSchedule(t: Transport, schedule: SandboxScheduleSet): Promise<SandboxSchedulesReply>;
8
+ export declare function changeSandboxSchedule(t: Transport, action: "delete" | "pause" | "resume", scheduleId: string): Promise<SandboxSchedulesReply>;
9
+ export declare function takeOverTeamTask(t: Transport, scheduleId: string, schedule: Omit<SandboxScheduleSet, "schedule_id" | "team">): Promise<SandboxSchedulesReply>;
10
+ export declare function workspaceTasks(t: Transport): Promise<WorkspaceListReply>;
11
+ export declare function workspaceRead(t: Transport, scheduleId: string, options?: {
12
+ include?: WorkspaceReadPart[];
13
+ }): Promise<WorkspaceReadReply>;
@@ -0,0 +1,80 @@
1
+ import { FloviaError } from "./errors.js";
2
+ import { OPERATION_ID } from "./transport.js";
3
+ /** The relay's run_id and schedule_id shape (a UUID v4). */
4
+ const SANDBOX_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
5
+ /** The MCP server's own answer for a tool this key is not offered: it refuses the name before running anything. */
6
+ const NOT_OFFERED = /\bTool \S+ (not found|disabled)/;
7
+ /** The relay's own limits for a script (MAX_CODE_BYTES, MAX_INPUTS): checked here so an oversize script is refused before anything is sent. */
8
+ const SANDBOX_CODE_BYTES = 64 * 1024, SANDBOX_INPUTS = 8;
9
+ /**
10
+ * A sandbox or Team workspace tool. The relay lists these tools only while code runs are on for this account (and the workspace tools only on a
11
+ * Team key of a Team whose owner turned the workspace on), so an unlisted tool is tool_not_offered with executed "no": nothing ran.
12
+ */
13
+ async function offered(t, tool, args) {
14
+ try {
15
+ return await t.call(tool, args);
16
+ }
17
+ catch (e) {
18
+ if (!(e instanceof FloviaError && e.code === "mcp_error" && NOT_OFFERED.test(e.message)))
19
+ throw e;
20
+ throw t.error({ code: "tool_not_offered", executed: "no", message: `${tool} is not offered to this key.`,
21
+ nextStep: tool.startsWith("flovia_workspace") ? "Use a Team key of a Team whose owner turned the Team workspace on, on an account where code runs are on; listTools() shows what this key is offered."
22
+ : "Code runs are not available to this account now; listTools() shows what this key is offered. Do not retry in a loop." });
23
+ }
24
+ }
25
+ /** A script the relay would refuse for its size is refused here, with executed "no": nothing is sent. */
26
+ function sandboxScript(script) {
27
+ if (script === undefined)
28
+ return;
29
+ if (typeof script.code !== "string" || script.code === "" || new TextEncoder().encode(script.code).length > SANDBOX_CODE_BYTES)
30
+ throw new FloviaError({ code: "invalid_request", executed: "no", message: `code must be 1 to ${SANDBOX_CODE_BYTES} bytes of UTF-8 text (64 KiB); nothing was sent.` });
31
+ if (script.inputs !== undefined && (!Array.isArray(script.inputs) || script.inputs.length > SANDBOX_INPUTS))
32
+ throw new FloviaError({ code: "invalid_request", executed: "no", message: `inputs must be a list of at most ${SANDBOX_INPUTS}; nothing was sent.` });
33
+ }
34
+ function sandboxId(name, v) {
35
+ if (typeof v !== "string" || !SANDBOX_ID.test(v))
36
+ throw new FloviaError({ code: "invalid_request", executed: "no", message: `${name} must be the id Flovia returned.` });
37
+ return v;
38
+ }
39
+ export async function sandboxRun(t, args) {
40
+ if (args.operation_id !== undefined && !OPERATION_ID.test(args.operation_id))
41
+ throw new FloviaError({ code: "invalid_operation_id", executed: "no", message: "operation_id must be 8-128 of A-Z a-z 0-9 _ . : -" });
42
+ sandboxScript(args);
43
+ return offered(t, "flovia_sandbox_run", { ...args });
44
+ }
45
+ export function sandboxRuns(t) {
46
+ return offered(t, "flovia_sandbox_result", {});
47
+ }
48
+ export async function sandboxResult(t, runId, options = {}) {
49
+ const wait = options.waitSeconds;
50
+ if (wait !== undefined && (!Number.isInteger(wait) || wait < 0 || wait > 50))
51
+ throw new FloviaError({ code: "invalid_request", executed: "no", message: "waitSeconds must be a whole number from 0 to 50." });
52
+ return offered(t, "flovia_sandbox_result", { run_id: sandboxId("runId", runId), ...(options.include ? { include: options.include } : {}), ...(wait === undefined ? {} : { wait_seconds: wait }) });
53
+ }
54
+ export function sandboxSchedules(t) {
55
+ return offered(t, "flovia_sandbox_schedule", { action: "list" });
56
+ }
57
+ export async function setSandboxSchedule(t, schedule) {
58
+ if (schedule.schedule_id !== undefined)
59
+ sandboxId("schedule_id", schedule.schedule_id);
60
+ sandboxScript(schedule.script);
61
+ // The caller's fields go first, so nothing in them can replace the action.
62
+ return offered(t, "flovia_sandbox_schedule", { ...schedule, action: "set" });
63
+ }
64
+ export async function changeSandboxSchedule(t, action, scheduleId) {
65
+ if (action !== "delete" && action !== "pause" && action !== "resume")
66
+ throw new FloviaError({ code: "invalid_request", executed: "no", message: "action must be delete, pause or resume." });
67
+ return offered(t, "flovia_sandbox_schedule", { action, schedule_id: sandboxId("scheduleId", scheduleId) });
68
+ }
69
+ export async function takeOverTeamTask(t, scheduleId, schedule) {
70
+ const id = sandboxId("scheduleId", scheduleId);
71
+ sandboxScript(schedule.script);
72
+ // The caller's fields go first, so nothing in them can replace the action or the checked id.
73
+ return offered(t, "flovia_sandbox_schedule", { ...schedule, action: "take_over", schedule_id: id });
74
+ }
75
+ export function workspaceTasks(t) {
76
+ return offered(t, "flovia_workspace_list", {});
77
+ }
78
+ export async function workspaceRead(t, scheduleId, options = {}) {
79
+ return offered(t, "flovia_workspace_read", { schedule_id: sandboxId("scheduleId", scheduleId), ...(options.include ? { include: options.include } : {}) });
80
+ }
@@ -0,0 +1,14 @@
1
+ import { type Parsed } from "./args.js";
2
+ import { type FloviaClient } from "./index.js";
3
+ import type { Io } from "./cli.js";
4
+ type CommandContext = {
5
+ connect: () => Promise<FloviaClient>;
6
+ waitFor: <T>(request: () => Promise<T>) => Promise<T>;
7
+ json: boolean;
8
+ print: (value: unknown) => void;
9
+ out: (text: string) => void;
10
+ err: (text: string) => void;
11
+ };
12
+ export declare function sandboxCommand(p: Parsed, io: Pick<Io, "now" | "readCode" | "readFile" | "readStdin">, { connect, waitFor, json, print, out, err }: CommandContext): Promise<number>;
13
+ export declare function workspaceCommand(p: Parsed, io: Pick<Io, "now">, { connect, waitFor, json, print, out }: CommandContext): Promise<number>;
14
+ export {};
@@ -0,0 +1,90 @@
1
+ import { COMMANDS, Usage, positiveInt, str } from "./args.js";
2
+ import { OPERATION_ID } from "./transport.js";
3
+ import { newOperationId } from "./index.js";
4
+ import { plain, renderSandboxResult, renderSandboxRuns, renderSandboxSchedules, renderWorkspace, renderWorkspaceRead } from "./output.js";
5
+ const SANDBOX_LANGUAGES = ["python", "node", "bash"];
6
+ const SANDBOX_UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
7
+ const SANDBOX_CODE_BYTES = 64 * 1024;
8
+ export async function sandboxCommand(p, io, { connect, waitFor, json, print, out, err }) {
9
+ const [action, a, b, extra] = p.positional, usage = () => new Usage(`Usage: flovia ${COMMANDS["sandbox"]?.usage}`), now = (io.now ?? Date.now)();
10
+ const runFlags = p.flags.has("--op") || p.flags.has("--label") || p.flags.has("--timeout-seconds");
11
+ if (action === "schedules") {
12
+ if (a !== undefined || runFlags || p.flags.has("--wait"))
13
+ throw usage();
14
+ const client = await connect(), r = await waitFor(() => client.sandboxSchedules());
15
+ if (json)
16
+ print(r);
17
+ else
18
+ out(renderSandboxSchedules(r, now));
19
+ return 0;
20
+ }
21
+ if (action === "result") {
22
+ if (b !== undefined || runFlags || (a === undefined && p.flags.has("--wait")) || (a !== undefined && !SANDBOX_UUID.test(a)))
23
+ throw usage();
24
+ const client = await connect();
25
+ if (a === undefined) {
26
+ const r = await waitFor(() => client.sandboxRuns());
27
+ if (json)
28
+ print(r);
29
+ else
30
+ out(renderSandboxRuns(r, now));
31
+ return 0;
32
+ }
33
+ const r = await waitFor(() => client.sandboxResult(a, p.flags.has("--wait") ? { waitSeconds: 50 } : {}));
34
+ if (json)
35
+ print(r);
36
+ else
37
+ out(renderSandboxResult(r, now));
38
+ return 0;
39
+ }
40
+ if (action !== "run" || a === undefined || !SANDBOX_LANGUAGES.includes(a) || b === undefined || extra !== undefined || p.flags.has("--wait"))
41
+ throw usage();
42
+ const op = str(p.flags.get("--op")), runLabel = str(p.flags.get("--label")), seconds = positiveInt("--timeout-seconds", str(p.flags.get("--timeout-seconds")), 60);
43
+ if (op !== undefined && !OPERATION_ID.test(op))
44
+ throw new Usage("sandbox run: --op must be 8-128 of A-Z a-z 0-9 _ . : -");
45
+ if (runLabel !== undefined && (runLabel === "" || runLabel.length > 256))
46
+ throw new Usage("sandbox run: --label must be 1 to 256 characters");
47
+ let code;
48
+ // Never echo a user-given path: a key pasted in its place would land in the output.
49
+ try {
50
+ code = b === "-" ? await io.readStdin() : await (io.readCode ?? io.readFile)(b);
51
+ }
52
+ catch {
53
+ throw new Usage(b === "-" ? "sandbox run: cannot read the code from stdin (it must be UTF-8 text)" : "sandbox run: cannot read the code file (it must be UTF-8 text)");
54
+ }
55
+ if (code.trim() === "")
56
+ throw new Usage("sandbox run: the code is empty");
57
+ // Refused here, before a connection: the relay takes at most 64 KiB of code.
58
+ if (new TextEncoder().encode(code).length > SANDBOX_CODE_BYTES)
59
+ throw new Usage("sandbox run: the code is over 64 KiB (65536 bytes); nothing was sent");
60
+ const client = await connect();
61
+ const id = op ?? newOperationId();
62
+ // The id is shown before anything is sent, so a lost reply can be asked again with it instead of queueing a second run.
63
+ if (op === undefined)
64
+ err(`operation_id: ${id}\nIf the reply is lost, rerun with the same code and: --op ${id}\n`);
65
+ const r = await waitFor(() => client.sandboxRun({ code, language: a, ...(seconds ? { timeout_seconds: seconds } : {}), ...(runLabel ? { label: runLabel } : {}), operation_id: id }));
66
+ if (json)
67
+ print(r);
68
+ else
69
+ out(plain(`run_id: ${r.run_id}\nstatus: ${r.status}${typeof r.note === "string" ? `\n${r.note}` : ""}`) + `\nResult: flovia sandbox result ${r.run_id} --wait\n`);
70
+ return 0;
71
+ }
72
+ export async function workspaceCommand(p, io, { connect, waitFor, json, print, out }) {
73
+ const [action, id, extra] = p.positional, now = (io.now ?? Date.now)();
74
+ if (action === undefined) {
75
+ const client = await connect(), r = await waitFor(() => client.workspaceTasks());
76
+ if (json)
77
+ print(r);
78
+ else
79
+ out(renderWorkspace(r, now));
80
+ return 0;
81
+ }
82
+ if (action !== "read" || id === undefined || !SANDBOX_UUID.test(id) || extra !== undefined)
83
+ throw new Usage(`Usage: flovia ${COMMANDS["workspace"]?.usage} (the schedule_id from flovia workspace)`);
84
+ const client = await connect(), r = await waitFor(() => client.workspaceRead(id));
85
+ if (json)
86
+ print(r);
87
+ else
88
+ out(renderWorkspaceRead(r, now));
89
+ return 0;
90
+ }
@@ -0,0 +1,14 @@
1
+ import { type Parsed } from "./args.js";
2
+ import type { FloviaClient } from "./client.js";
3
+ type ToolCommandContext = {
4
+ connect: () => Promise<FloviaClient>;
5
+ waitFor: <T>(request: () => Promise<T>) => Promise<T>;
6
+ json: boolean;
7
+ print: (value: unknown) => void;
8
+ out: (text: string) => void;
9
+ };
10
+ export declare function listToolsCommand(p: Parsed, { connect, waitFor, json, print, out }: ToolCommandContext): Promise<number>;
11
+ export declare function callToolCommand(p: Parsed, io: {
12
+ readStdin: () => Promise<string>;
13
+ }, { connect, waitFor, print }: Pick<ToolCommandContext, "connect" | "waitFor" | "print">): Promise<number>;
14
+ export {};
@@ -0,0 +1,65 @@
1
+ import { COMMANDS, Usage, notOffered } from "./args.js";
2
+ import { FloviaError } from "./errors.js";
3
+ import { exampleCall } from "./examples.js";
4
+ import { prose } from "./output.js";
5
+ /** The first sentence, plus the next when both fit in about 200 characters, so what the tool is for survives. */
6
+ const brief = (description) => {
7
+ const [first = "", second] = description.split(/(?<=\.)\s/);
8
+ return second !== undefined && first.length + second.length < 200 ? `${first} ${second}` : first;
9
+ };
10
+ export async function listToolsCommand(p, { connect, waitFor, json, print, out }) {
11
+ const [name, extra] = p.positional;
12
+ if (extra !== undefined)
13
+ throw new Usage(`Usage: flovia ${COMMANDS["tools"]?.usage}`);
14
+ const client = await connect(), tools = await waitFor(() => client.listTools());
15
+ if (name !== undefined) {
16
+ const tool = tools.find((t) => t.name === name);
17
+ if (tool === undefined)
18
+ throw new Usage(notOffered(name, tools.map((t) => t.name)));
19
+ if (json)
20
+ print(tool);
21
+ else
22
+ out(`${tool.name}\n${tool.description ?? ""}\n\nArguments (JSON Schema):\n${JSON.stringify(tool.inputSchema, null, 2)}\n${exampleCall(tool.name, tool.inputSchema)}`);
23
+ }
24
+ else if (json)
25
+ print(tools);
26
+ else
27
+ out(tools.map((t) => `${t.name}\n ${prose(brief(t.description ?? ""))}\n`).join("\n") + "\nArguments: flovia tools <tool> --json\nRead-only example: flovia call flovia_status '{}'\n");
28
+ return 0;
29
+ }
30
+ export async function callToolCommand(p, io, { connect, waitFor, print }) {
31
+ const [tool, input, extra] = p.positional;
32
+ if (tool === undefined || extra !== undefined)
33
+ throw new Usage(`Usage: flovia ${COMMANDS["call"]?.usage}`);
34
+ let raw = input;
35
+ if (input === "-") {
36
+ try {
37
+ raw = await io.readStdin();
38
+ }
39
+ catch {
40
+ throw new Usage("call: cannot read JSON from stdin");
41
+ }
42
+ }
43
+ let args = {};
44
+ if (raw !== undefined)
45
+ try {
46
+ args = JSON.parse(raw);
47
+ }
48
+ catch {
49
+ throw new Usage("call: the arguments must be one JSON object, e.g. '{\"since\":\"2026-10-10T00:00:00Z\"}'");
50
+ }
51
+ if (args === null || typeof args !== "object" || Array.isArray(args))
52
+ throw new Usage("call: the arguments must be a JSON object");
53
+ const client = await connect();
54
+ try {
55
+ print(await waitFor(() => client.call(tool, args)));
56
+ }
57
+ catch (e) {
58
+ // The relay's MCP server refuses an unknown name with "Tool <name> not found" before running anything; only then read the catalog to suggest one.
59
+ if (!(e instanceof FloviaError && e.code === "mcp_error" && /\bTool \S+ (not found|disabled)/.test(e.message)))
60
+ throw e;
61
+ const names = await client.listTools().then((t) => t.map((x) => x.name), () => []);
62
+ throw new FloviaError({ code: "tool_not_offered", executed: "no", message: notOffered(tool, names), nextStep: "Run: flovia tools" });
63
+ }
64
+ return 0;
65
+ }
@@ -0,0 +1,11 @@
1
+ import type { FloviaError } from "./errors.js";
2
+ import type { ToolReply } from "./types.js";
3
+ /** The relay's operation_id shape: 8-128 of A-Z a-z 0-9 _ . : - */
4
+ export declare const OPERATION_ID: RegExp;
5
+ export type ErrorInit = ConstructorParameters<typeof FloviaError>[0];
6
+ /** The FloviaClient's own request and error helpers, handed to the account, sandbox and Runway output modules. */
7
+ export interface Transport {
8
+ send(path: string, body: unknown, headers?: Record<string, string>, operationId?: string | null, method?: "POST" | "GET"): Promise<Response>;
9
+ error(init: ErrorInit): FloviaError;
10
+ call<R extends ToolReply>(tool: string, args: Record<string, unknown>): Promise<R>;
11
+ }
@@ -0,0 +1,2 @@
1
+ /** The relay's operation_id shape: 8-128 of A-Z a-z 0-9 _ . : - */
2
+ export const OPERATION_ID = /^[A-Za-z0-9_.:-]{8,128}$/;
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.208";
2
+ export declare const EXPECTED_CONTRACT_VERSION = "2026-10-07.255";
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", "team_stopped", "consent_missing", "data_consent_mismatch", "data_consent_needed", "notice_first", "elevenlabs_terms_required", "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_only_exhausted", "key_cap_reached", "member_cap_reached", "team_balance_empty", "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", "queue_full", "input_unavailable", "sandbox_disabled", "team_feature_off"];
4
+ export declare const PUBLIC_CODES: readonly ["approval_pending", "key_disabled", "key_stopped", "team_stopped", "consent_missing", "data_consent_mismatch", "data_consent_needed", "notice_first", "elevenlabs_terms_required", "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", "output_withheld", "request_text_too_long", "over_max_credits", "window_5h", "window_month", "window_week", "over_week", "free_only_exhausted", "key_cap_reached", "member_cap_reached", "team_balance_empty", "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", "queue_full", "input_unavailable", "sandbox_disabled", "team_feature_off", "purchase_refused", "team_purchase_not_supported"];
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";
@@ -48,7 +48,7 @@ export interface Window {
48
48
  resets_at: string | null;
49
49
  }
50
50
  export type StatusArgs = {
51
- about_sharing?: true;
51
+ about_sharing?: boolean;
52
52
  };
53
53
  export interface StatusReply extends ToolReply {
54
54
  contract_version: string;
@@ -58,7 +58,7 @@ export interface StatusReply extends ToolReply {
58
58
  services_off: string[];
59
59
  }
60
60
  export interface UsageTodayArgs {
61
- /** ISO 8601 time, at most 30 days ago (relays before #2641: 7 days). */
61
+ /** ISO 8601 time or YYYY-MM-DD (00:00 UTC), at most 30 days ago (relays before #2641: 7 days). */
62
62
  since?: string;
63
63
  /** The last N days (1-30) instead of since; not with since or a cursor. Relays before #2641 refuse it. */
64
64
  days?: number;
@@ -75,8 +75,11 @@ export interface UsageTodayReply extends ToolReply {
75
75
  }
76
76
  /** POST /openai/v1/responses: an OpenAI Responses request, text only. Unknown fields are refused. */
77
77
  export interface GenerationRequest {
78
- model: "gpt-6-luna";
78
+ /** gpt-6-luna is the default; gpt-6.1-terra, gpt-6.2-astra and gpt-6.2-sol answer only where the relay offers them; gpt-6.2-* refuse effort none. */
79
+ model: "gpt-6-luna" | "gpt-6.1-terra" | "gpt-6.2-astra" | "gpt-6.2-sol";
79
80
  input: string;
81
+ /** A system prompt; it counts toward the same input limits as input. */
82
+ instructions?: string;
80
83
  max_output_tokens?: number;
81
84
  reasoning?: {
82
85
  effort: "none" | "low" | "medium" | "high" | "xhigh" | "max";
@@ -87,6 +90,11 @@ export interface GenerationRequest {
87
90
  text?: {
88
91
  format: {
89
92
  type: "json_object";
93
+ } | {
94
+ type: "json_schema";
95
+ name: string;
96
+ schema: Record<string, unknown>;
97
+ strict?: boolean;
90
98
  };
91
99
  };
92
100
  }
@@ -103,15 +111,20 @@ export interface Generation {
103
111
  receivedAt: string | null;
104
112
  conversationId: string | null;
105
113
  }
106
- /** GET /account/banked-resets: saved resets that can still be used, and the first to expire. */
114
+ /** GET /account/banked-resets: saved resets that can still be used, the first to expire, and (new relays) one choice per kind. */
107
115
  export interface BankedResets {
108
116
  available: number;
109
117
  next: {
110
118
  id: number;
111
119
  expires_at: string;
112
120
  } | null;
121
+ resets?: {
122
+ id: number;
123
+ kind: "five_hour" | "week";
124
+ expires_at: string;
125
+ }[];
113
126
  }
114
- /** "used": both free windows (5-hour and week) start again. "not_used": nothing changed (already used, expired, a lookup still settling, or nothing to reset). */
127
+ /** "used": the selected coupon resets its free window (weekly also resets 5-hour usage). "not_used": nothing changed (already used, expired, a lookup still settling, or nothing to reset). */
115
128
  export interface BankedResetUse extends BankedResets {
116
129
  outcome: "used" | "not_used";
117
130
  }
package/dist/types.js CHANGED
@@ -1,13 +1,14 @@
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.208";
2
+ export const EXPECTED_CONTRACT_VERSION = "2026-10-07.255";
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", "team_stopped", "consent_missing", "data_consent_mismatch", "data_consent_needed", "notice_first",
6
6
  "elevenlabs_terms_required", "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
- "answer_too_large", "answer_precision_unsafe", "answer_not_relayed", "request_text_too_long",
7
+ "answer_too_large", "answer_precision_unsafe", "answer_not_relayed", "output_withheld", "request_text_too_long",
8
8
  "over_max_credits", "window_5h", "window_month", "window_week", "over_week", "free_only_exhausted", "key_cap_reached", "member_cap_reached", "team_balance_empty", "free_limited", "free_needs_email", "free_not_granted", "global_cap",
9
9
  "flovia_paused", "rate_limited", "too_many_in_parallel", "reservation_changed",
10
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
  "queue_full", "input_unavailable", "sandbox_disabled", "team_feature_off",
13
+ "purchase_refused", "team_purchase_not_supported",
13
14
  ];
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "@flovialabs/sdk",
3
- "version": "0.1.23",
3
+ "version": "0.1.25",
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",
7
- "homepage": "https://api.flovia.dev",
7
+ "homepage": "https://docs.flovia.dev",
8
+ "bugs": {
9
+ "url": "https://flovia.dev/contact"
10
+ },
8
11
  "repository": {
9
12
  "type": "git",
10
13
  "url": "git+https://github.com/flovia/groupbuy.git",