Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.3.1"
".": "0.3.2"
}
45 changes: 45 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,50 @@
# Changelog

## [0.3.2](https://github.com/xapi-labs/xapi-cli/compare/v0.3.1...v0.3.2) (2026-11-19)


### Features

* **call:** save complete JSON responses to private files ([a009785](https://github.com/xapi-labs/xapi-cli/commit/a009785e5944d1b63ae461e6b2e35a8eb96b190b))
* **cli:** improve service discovery and execution workflows ([#73](https://github.com/xapi-labs/xapi-cli/issues/73)) ([7b08dc0](https://github.com/xapi-labs/xapi-cli/commit/7b08dc0f6c8bbe9bfbde77cda438031c98e2100f))
* **cli:** improve service discovery, call output, and provider onboarding ([7b08dc0](https://github.com/xapi-labs/xapi-cli/commit/7b08dc0f6c8bbe9bfbde77cda438031c98e2100f))
* **cli:** promote execution envelopes to staging ([a265814](https://github.com/xapi-labs/xapi-cli/commit/a265814bf7d60145833675f3d0f8a72703abb76a))
* **cli:** show service, price and 30-day stats in action tables ([786041b](https://github.com/xapi-labs/xapi-cli/commit/786041bfc4dfaf778cc5aac18a6bc935799d1700))
* **cli:** validate discovery and provider onboarding in staging ([7bf9d2f](https://github.com/xapi-labs/xapi-cli/commit/7bf9d2faf0cc3b1850cb9145a3bfde5315adaf65))
* **provider:** import YAML with explicit default pricing ([194601d](https://github.com/xapi-labs/xapi-cli/commit/194601de767d44fdb4db926393e892da432b66d9))
* **provider:** show a service's review and lifecycle timeline ([810f89a](https://github.com/xapi-labs/xapi-cli/commit/810f89aec0eaa37e9c8df28511340c8166b523db))
* **sandbox:** server-side lifetime and spending caps, concise run output ([a00ed05](https://github.com/xapi-labs/xapi-cli/commit/a00ed054e0133a820dc09daea47cbc3b7a9f9f41))
* **sandbox:** show termination reasons and clarify budget limits ([6849d71](https://github.com/xapi-labs/xapi-cli/commit/6849d71394f2617c8752223bfbf507a64760db89))
* **skill:** explain import lifecycle and trusted discovery metadata ([960796c](https://github.com/xapi-labs/xapi-cli/commit/960796c68f65396ac72579e5144ab6b4e1e2f6e1))
* **skill:** guide service tags, official categories and token usage rules ([73696a4](https://github.com/xapi-labs/xapi-cli/commit/73696a4f7904d8fdc29535988093a43f1d20ab23))
* **skill:** guide Tripo async provider registration ([#61](https://github.com/xapi-labs/xapi-cli/issues/61)) ([550171c](https://github.com/xapi-labs/xapi-cli/commit/550171c4522d5d5a0d0ad0ce936d11e56d48dbef))
* **workers:** key-free local plan, secrets in init's next steps, shortest path in the skill ([33f20eb](https://github.com/xapi-labs/xapi-cli/commit/33f20eb0c1fc109ba3cc5282d7144050d301f6b1))


### Bug Fixes

* **agent:** report failed calls and protect generated chat routes ([a0b9d88](https://github.com/xapi-labs/xapi-cli/commit/a0b9d88897f2630ea015dd647612f258d1b3fa42))
* **call:** clarify uncertain failures and response evidence ([96ddd6a](https://github.com/xapi-labs/xapi-cli/commit/96ddd6accddc5890e938ba080ebd1ed444fe8aa6))
* **call:** preserve replaced files and complete JSON errors ([ac85a83](https://github.com/xapi-labs/xapi-cli/commit/ac85a83225321e28fc89b0f4d9915c30952380fa))
* **cli:** reuse the login session for balance and oauth ([af0a957](https://github.com/xapi-labs/xapi-cli/commit/af0a9571867c080ab747329bb3e1a3c5c075f129))
* **oauth:** inspect endpoint requirements before account binding ([fc59690](https://github.com/xapi-labs/xapi-cli/commit/fc596907dc8ab2c1e7900d177906b7d64c1fcbf2))
* **skill:** describe text search and provider tag compatibility ([4b72ccc](https://github.com/xapi-labs/xapi-cli/commit/4b72ccc446ea914ae5e76f1a7ace58eec28c2572))
* **skill:** explain referenced response schemas ([fbad100](https://github.com/xapi-labs/xapi-cli/commit/fbad100e7fe025eb86bca6f2da886d989c5dcc90))
* **skill:** handle Binance candle boundaries and USD volume ([#63](https://github.com/xapi-labs/xapi-cli/issues/63)) ([889c15e](https://github.com/xapi-labs/xapi-cli/commit/889c15ee0747757c57d6a6179ae27210c8222fca))
* **skill:** stop recommending the retired provider event feed ([#66](https://github.com/xapi-labs/xapi-cli/issues/66)) ([3a7c3d7](https://github.com/xapi-labs/xapi-cli/commit/3a7c3d7cd46348ed680c74451aa90231af2007bd))


### Documentation

* **action:** explain mixed billing states and overlapping amounts ([3d50300](https://github.com/xapi-labs/xapi-cli/commit/3d50300dddd3ce63d301093b1e4b17b8cbf3669c))
* **action:** name the separate raw cost-state headers ([bf86fa8](https://github.com/xapi-labs/xapi-cli/commit/bf86fa828ee7667268e3eed9b6a42ed0c0edca32))
* **cli:** keep the staging skill guide concise ([fe5c3c3](https://github.com/xapi-labs/xapi-cli/commit/fe5c3c32c155650f4de4516ee8fa5bdcee7b6dab))
* **provider:** explain readiness and interrupted review recovery ([24e0b71](https://github.com/xapi-labs/xapi-cli/commit/24e0b71db385da78ba4c2fead1b5f1e350b5a5be))
* **provider:** promote readiness and review guidance to staging ([1540b1b](https://github.com/xapi-labs/xapi-cli/commit/1540b1b9b063eeda0e9c3ee55866941c05791fc6))
* **skill:** describe the restored Twitter search fallback behavior ([ea4a49c](https://github.com/xapi-labs/xapi-cli/commit/ea4a49c9b5caa3b2170bf3862d1c762a7e095706))
* **skill:** how to choose between similar services and read a call's cost ([ef90979](https://github.com/xapi-labs/xapi-cli/commit/ef909791441c8bd354f04aa95063081fbbb48591))
* **skill:** tags and categories in search results ([80522c1](https://github.com/xapi-labs/xapi-cli/commit/80522c1ffc2c8faa880bb600949b2a5590207345))

## [0.3.1](https://github.com/xapi-labs/xapi-cli/compare/v0.3.0...v0.3.1) (2026-10-22)


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xapi-to",
"version": "0.3.1",
"version": "0.3.2",
"description": "Agent-friendly CLI for xapi - discover and call capabilities and APIs",
"type": "module",
"bin": {
Expand Down
35 changes: 29 additions & 6 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,20 @@ const RETRY_MAX_DELAY_MS = 8_000;
export interface ClientOptions {
actionHost: string;
apiKey?: string;
/** POST execute/batch bodies: send include_preview so the caller can reach their own PREVIEW services. */
includePreview?: boolean;
}

/** Backends that predate preview reject the body field (`property include_preview should not exist`). */
export function withPreviewHint(status: number, message: string): string {
return status === 400 && message.includes('include_preview')
? `${message} (--preview needs an xAPI backend with preview support; on older backends a key with the legacy sandbox permission reaches your own unpublished services without --preview)`
: message;
}

/** Older backends may reject unknown body fields, so send include_preview only when requested. */
function previewBody(opts: ClientOptions): { include_preview?: true } {
return opts.includePreview ? { include_preview: true } : {};
}

/** Optional Action metadata from supporting backends; source is not review evidence. */
Expand Down Expand Up @@ -448,7 +462,7 @@ export async function request<T>(
});
let responseBody: unknown;
try { responseBody = JSON.parse(text); } catch { /* Plain upstream errors stay plain. */ }
throw new HttpError(res.status, text.slice(0, 300), retryAfterMs, responseBody);
throw new HttpError(res.status, withPreviewHint(res.status, text.slice(0, 300)), retryAfterMs, responseBody);
}
if (res.status === 204) {
return undefined as T;
Expand Down Expand Up @@ -743,14 +757,17 @@ function baseUrl(opts: ClientOptions): string {

export async function actionList(
opts: ClientOptions,
params: { page?: number; page_size?: number; category?: string; source?: string; service_id?: string } = {},
params: {
page?: number; page_size?: number; category?: string; source?: string; service_id?: string; include_preview?: boolean;
} = {},
) {
const url = new URL(`${baseUrl(opts)}/v1/actions`);
if (params.page) url.searchParams.set('page', String(params.page));
if (params.page_size) url.searchParams.set('page_size', String(params.page_size));
if (params.category) url.searchParams.set('category', params.category);
if (params.source) url.searchParams.set('source', params.source);
if (params.service_id) url.searchParams.set('service_id', params.service_id);
if (params.include_preview) url.searchParams.set('include_preview', 'true');
return request<{ actions: unknown[]; pagination: unknown }>(
url.toString(),
{ method: 'GET', headers: headers(opts.apiKey) },
Expand All @@ -768,6 +785,7 @@ export async function actionSearch(
page?: number;
page_size?: number;
include_all_versions?: boolean;
include_preview?: boolean;
sort?: 'default' | 'relevance' | 'price';
} = {},
) {
Expand All @@ -778,6 +796,7 @@ export async function actionSearch(
if (params.page) url.searchParams.set('page', String(params.page));
if (params.page_size) url.searchParams.set('page_size', String(params.page_size));
if (params.include_all_versions) url.searchParams.set('include_all_versions', 'true');
if (params.include_preview) url.searchParams.set('include_preview', 'true');
if (params.sort) url.searchParams.set('sort', params.sort);
return request<{
results: unknown[];
Expand All @@ -793,9 +812,10 @@ export async function actionSearch(
);
}

export async function actionCategories(opts: ClientOptions, params: { source?: string } = {}) {
export async function actionCategories(opts: ClientOptions, params: { source?: string; include_preview?: boolean } = {}) {
const url = new URL(`${baseUrl(opts)}/v1/actions/categories`);
if (params.source) url.searchParams.set('source', params.source);
if (params.include_preview) url.searchParams.set('include_preview', 'true');
return request<{ categories: string[]; total: number }>(
url.toString(),
{ method: 'GET', headers: headers(opts.apiKey) },
Expand Down Expand Up @@ -824,7 +844,7 @@ export async function actionBatch(ids: string[], opts: ClientOptions) {
{
method: 'POST',
headers: headers(opts.apiKey),
body: JSON.stringify({ ids }),
body: JSON.stringify({ ids, ...previewBody(opts) }),
},
DEFAULT_TIMEOUT_MS,
IDEMPOTENT_RETRIES, // read-only metadata fetch — safe to retry
Expand All @@ -851,7 +871,7 @@ export async function actionCall(
{
method: 'POST',
headers: headers(opts.apiKey),
body: JSON.stringify({ action_id: actionId, ...(httpMethod ? { method: httpMethod } : {}), input }),
body: JSON.stringify({ action_id: actionId, ...(httpMethod ? { method: httpMethod } : {}), input, ...previewBody(opts) }),
},
Math.min(timeoutMs, EXECUTE_TIMEOUT_MS),
retries,
Expand Down Expand Up @@ -958,6 +978,7 @@ export async function actionStream(
...(httpMethod ? { method: httpMethod } : {}),
input,
stream: true,
...previewBody(opts),
}),
redirect: 'manual',
signal: controller.signal,
Expand Down Expand Up @@ -1055,6 +1076,7 @@ export async function actionDownload(
...(httpMethod ? { method: httpMethod } : {}),
input,
response_mode: 'raw',
...previewBody(opts),
}),
redirect: 'manual',
signal: controller.signal,
Expand Down Expand Up @@ -1113,12 +1135,13 @@ export async function actionDownload(

export async function actionServices(
opts: ClientOptions,
params: { page?: number; page_size?: number; category?: string } = {},
params: { page?: number; page_size?: number; category?: string; include_preview?: boolean } = {},
) {
const url = new URL(`${baseUrl(opts)}/v1/actions/services`);
if (params.page) url.searchParams.set('page', String(params.page));
if (params.page_size) url.searchParams.set('page_size', String(params.page_size));
if (params.category) url.searchParams.set('category', params.category);
if (params.include_preview) url.searchParams.set('include_preview', 'true');
return request<{ services: unknown[]; pagination: unknown }>(
url.toString(),
{ method: 'GET', headers: headers(opts.apiKey) },
Expand Down
27 changes: 19 additions & 8 deletions src/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export interface CodegenParams {
input: Record<string, unknown>;
actionHost: string;
method?: string;
/** --preview: the snippet must also ask for the caller's own PREVIEW services. */
includePreview?: boolean;
}

interface ResolvedTarget {
Expand Down Expand Up @@ -110,8 +112,17 @@ function baseUrl(actionHost: string): string {
return `${scheme(actionHost)}://${actionHost}/v1/actions/execute`;
}

function jsonBody(actionId: string, input: Record<string, unknown>, method?: string): string {
return JSON.stringify({ action_id: actionId, ...(method ? { method } : {}), input }, null, 2);
function payloadOf(params: CodegenParams): Record<string, unknown> {
return {
action_id: params.actionId,
...(params.method ? { method: params.method } : {}),
input: params.input,
...(params.includePreview ? { include_preview: true } : {}),
};
}

function jsonBody(params: CodegenParams): string {
return JSON.stringify(payloadOf(params), null, 2);
}

/** Re-indent a multi-line string so continuation lines are aligned */
Expand All @@ -128,7 +139,7 @@ function shellEscape(s: string): string {

function genCurl(params: CodegenParams): string {
const url = baseUrl(params.actionHost);
const body = jsonBody(params.actionId, params.input, params.method);
const body = jsonBody(params);
return [
'# Set XAPI_KEY env var or replace with your key',
`curl -X POST '${shellEscape(url)}' \\`,
Expand All @@ -140,7 +151,7 @@ function genCurl(params: CodegenParams): string {

function genPython(lib: 'requests' | 'httpx', params: CodegenParams): string {
const url = baseUrl(params.actionHost);
const payload = { action_id: params.actionId, ...(params.method ? { method: params.method } : {}), input: params.input };
const payload = payloadOf(params);
return [
`# pip install ${lib}`,
'# Set XAPI_KEY env var or replace with your key',
Expand All @@ -161,7 +172,7 @@ function genPython(lib: 'requests' | 'httpx', params: CodegenParams): string {

function genJavaScriptFetch(params: CodegenParams): string {
const url = baseUrl(params.actionHost);
const body = jsonBody(params.actionId, params.input, params.method);
const body = jsonBody(params);
return [
'// Set XAPI_KEY env var or replace with your key',
`const resp = await fetch("${url}", {`,
Expand All @@ -178,7 +189,7 @@ function genJavaScriptFetch(params: CodegenParams): string {

function genJavaScriptAxios(params: CodegenParams): string {
const url = baseUrl(params.actionHost);
const body = jsonBody(params.actionId, params.input, params.method);
const body = jsonBody(params);
return [
'// npm install axios',
'// Set XAPI_KEY env var or replace with your key',
Expand All @@ -200,7 +211,7 @@ function genJavaScriptAxios(params: CodegenParams): string {

function genTypescriptFetch(params: CodegenParams): string {
const url = baseUrl(params.actionHost);
const body = jsonBody(params.actionId, params.input, params.method);
const body = jsonBody(params);
return [
'// Set XAPI_KEY env var or replace with your key',
`const resp: Response = await fetch("${url}", {`,
Expand All @@ -218,7 +229,7 @@ function genTypescriptFetch(params: CodegenParams): string {

function genGo(params: CodegenParams): string {
const url = baseUrl(params.actionHost);
const body = jsonBody(params.actionId, params.input, params.method);
const body = jsonBody(params);
const escaped = body.replace(/`/g, '` + "`" + `');
return [
'// Set XAPI_KEY env var or replace with your key',
Expand Down
Loading
Loading