xapi-to 0.1.21 → 0.1.22
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/README.md +123 -1
- package/dist/{chunk-UEQCIJ7T.js → chunk-2YRWNREY.js} +2 -2
- package/dist/index.js +475 -33
- package/dist/openai-sandbox-client.js +1 -1
- package/examples/openai-gpt-live-text.mjs +128 -0
- package/examples/provider/openapi.json +34 -0
- package/package.json +1 -1
- package/skills/xapi/SKILL.md +42 -193
- package/skills/xapi/guides/binance_web3.md +210 -0
- package/skills/xapi/guides/blockpi.md +112 -0
- package/skills/xapi/guides/domains.md +189 -0
- package/skills/xapi/guides/provider.md +30 -0
- package/skills/xapi/guides/ws_gateway.md +64 -4
- package/src/client.ts +6 -2
package/README.md
CHANGED
|
@@ -26,7 +26,8 @@ npx skills add xapi-labs/xapi-cli
|
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
This installs the bundled [`xapi` skill](skills/xapi), which teaches the agent
|
|
29
|
-
how to call social, search, crypto,
|
|
29
|
+
how to call social, search, domains/DNS, crypto, BlockPI RPC, Binance Web3, and
|
|
30
|
+
AI services through this CLI. Then just ask
|
|
30
31
|
— "what's the price of BTC" — and it takes it from there. Set up a key first;
|
|
31
32
|
see [Quick Start](#quick-start).
|
|
32
33
|
|
|
@@ -111,6 +112,13 @@ WebSocket client. Active SSE and raw downloads may run longer than 60 seconds,
|
|
|
111
112
|
but abort after 60 seconds without data by default. Set
|
|
112
113
|
`XAPI_TRANSFER_IDLE_TIMEOUT_MS` to change that idle timeout.
|
|
113
114
|
|
|
115
|
+
GPT Live is a WebSocket protocol and cannot be invoked with `xapi-to call`.
|
|
116
|
+
Read [the WebSocket Gateway guide](skills/xapi/guides/ws_gateway.md) and use a
|
|
117
|
+
real WebSocket client. The packaged
|
|
118
|
+
[`examples/openai-gpt-live-text.mjs`](examples/openai-gpt-live-text.mjs)
|
|
119
|
+
demonstrates `session.start`, managed Responses delegation, text events, and a
|
|
120
|
+
graceful `session.close` without placing an xAPI key in source or CLI arguments.
|
|
121
|
+
|
|
114
122
|
### Async Task Commands
|
|
115
123
|
|
|
116
124
|
Task helpers built on top of the `task.poll` capability.
|
|
@@ -121,6 +129,114 @@ xapi-to task wait 550e8400-e29b-41d4-a716-446655440000 # wait un
|
|
|
121
129
|
xapi-to task wait 550e8400-e29b-41d4-a716-446655440000 --interval 1s --timeout 10m
|
|
122
130
|
```
|
|
123
131
|
|
|
132
|
+
### Provider: Import → Configure → Submit → Wait
|
|
133
|
+
|
|
134
|
+
`provider` manages APIs owned by your account. It uses `XAPI_API_HOST`
|
|
135
|
+
(default `api.xapi.to`) and the same saved or environment API key as other
|
|
136
|
+
commands. In the xAPI Console API Keys settings, grant `service:create`,
|
|
137
|
+
`service:read`, `service:update`, and `service:publish`. Legacy `allowRegister`
|
|
138
|
+
only grants creation, not the remaining lifecycle permissions. Missing
|
|
139
|
+
permissions return a nonzero exit with the required scope.
|
|
140
|
+
|
|
141
|
+
Start from [examples/provider/openapi.json](examples/provider/openapi.json),
|
|
142
|
+
replace its upstream URL, service details, and endpoint contract, then run:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Inspect current rules; no API key required
|
|
146
|
+
xapi-to provider spec-rules --format pretty
|
|
147
|
+
|
|
148
|
+
# Import a raw OpenAPI 3.0.3 JSON object (not a {openApiSpec: ...} envelope)
|
|
149
|
+
xapi-to provider import --file openapi.json > imported.json
|
|
150
|
+
|
|
151
|
+
# Use the serviceId and revisionId from imported.json (jq is optional)
|
|
152
|
+
PROVIDER_SERVICE_ID=$(jq -er '.serviceId' imported.json)
|
|
153
|
+
PROVIDER_REVISION_ID=$(jq -er '.revisionId' imported.json)
|
|
154
|
+
|
|
155
|
+
# Save version configuration to move the draft revision to SANDBOX.
|
|
156
|
+
# config.json can be {"description":"Initial release"} when the imported
|
|
157
|
+
# endpoints, authentication, and pricing are already complete.
|
|
158
|
+
xapi-to provider update "$PROVIDER_SERVICE_ID" \
|
|
159
|
+
--revision "$PROVIDER_REVISION_ID" --file config.json
|
|
160
|
+
|
|
161
|
+
# Submit the specified revision, then wait for the actual publication result
|
|
162
|
+
xapi-to provider submit "$PROVIDER_SERVICE_ID" \
|
|
163
|
+
--revision "$PROVIDER_REVISION_ID" --changelog "Initial release"
|
|
164
|
+
xapi-to provider wait "$PROVIDER_SERVICE_ID" \
|
|
165
|
+
--revision "$PROVIDER_REVISION_ID" --interval 2s --timeout 10m
|
|
166
|
+
|
|
167
|
+
# Inspect owned services, configuration, version overview, or review reports
|
|
168
|
+
xapi-to provider list --format table
|
|
169
|
+
xapi-to provider get "$PROVIDER_SERVICE_ID" --format pretty
|
|
170
|
+
xapi-to provider versions "$PROVIDER_SERVICE_ID" --format pretty
|
|
171
|
+
xapi-to provider review "$PROVIDER_SERVICE_ID" --revision "$PROVIDER_REVISION_ID"
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
When scripting these steps, stop on nonzero exit (for example, use `set -e`).
|
|
175
|
+
Import returns the backend validation/preview plus `serviceId`, `revisionId`,
|
|
176
|
+
and `state`. An HTTP 201 with `success: false` is a validation failure and exits
|
|
177
|
+
nonzero; its structured validation errors are preserved. Registration creates
|
|
178
|
+
a new service each time. If a response is lost, inspect `provider list` before
|
|
179
|
+
retrying to avoid duplicate services.
|
|
180
|
+
|
|
181
|
+
For an authenticated upstream, store credentials in a local JSON object such
|
|
182
|
+
as `{"Authorization":"Bearer YOUR_UPSTREAM_KEY"}` and pass
|
|
183
|
+
`--private-headers-file private-headers.json` to `provider import`. Keep this
|
|
184
|
+
file out of version control. `--file -` and `--private-headers-file -` accept
|
|
185
|
+
stdin, but only one input can consume stdin per command. Files must be JSON;
|
|
186
|
+
YAML and URL imports are not supported in this command group.
|
|
187
|
+
|
|
188
|
+
`provider update --revision <id>` reads a version configuration object, using the backend
|
|
189
|
+
fields `description`, `baseUrl`, `baseUrls`, `authType`, `privateHeaders`,
|
|
190
|
+
`authConfig`, `openApiSpec`, `endpoints`, and `status`. Prefer structured
|
|
191
|
+
`privateHeaders` for upstream credentials. Endpoint fields include billing
|
|
192
|
+
configuration such as `billingType` and `costPerCall`. Update does not accept
|
|
193
|
+
a raw OpenAPI document; the nested backend field is `openApiSpec: {spec: ...}`.
|
|
194
|
+
Saving that field alone does not re-import endpoint definitions; configure
|
|
195
|
+
`endpoints` explicitly when changing the contract.
|
|
196
|
+
|
|
197
|
+
- `--mode merge` (default) sends PATCH and preserves omitted fields/endpoints.
|
|
198
|
+
Existing endpoint edits require `id`, e.g.
|
|
199
|
+
`{"endpoints":[{"id":"ENDPOINT_ID","costPerCall":"0.002"}]}`.
|
|
200
|
+
- `--allow-new-endpoints` explicitly permits ID-less merge entries to create
|
|
201
|
+
endpoints. Repeating such a merge can create duplicates.
|
|
202
|
+
- `--mode replace` sends PUT. If `endpoints` is provided, it replaces the
|
|
203
|
+
endpoint list; include every endpoint you intend to keep. Omitted fields
|
|
204
|
+
otherwise follow backend PUT semantics. Use full configuration for replacement.
|
|
205
|
+
|
|
206
|
+
`get` retains its existing service response; `--version v1.0` selects the
|
|
207
|
+
configuration returned by the backend. Find endpoint IDs in
|
|
208
|
+
`currentVersion.endpoints`; `provider versions` returns working revision IDs
|
|
209
|
+
in `majors[].working.id`. For an already-published API, use the existing
|
|
210
|
+
`provider revision start <service-id> <major>` command to create a working revision.
|
|
211
|
+
`provider update` without `--revision` continues to update service metadata
|
|
212
|
+
and rate limits. Existing `version update`, `publish`, and positional `review`
|
|
213
|
+
commands remain available. The `submit` and `review --revision` forms are
|
|
214
|
+
additional onboarding commands.
|
|
215
|
+
|
|
216
|
+
Updates to `IN_REVIEW`, `PUBLISHED`, or `SUSPENDED` revisions return a conflict;
|
|
217
|
+
the backend enforces this check under a transaction lock. When updating
|
|
218
|
+
`privateHeaders`, send the complete desired map: it replaces the old map and
|
|
219
|
+
rebuilds the derived authentication configuration. An empty map without an
|
|
220
|
+
explicit `authConfig` clears those credentials. Omitting both fields preserves them.
|
|
221
|
+
|
|
222
|
+
`submit` returns `{serviceId, revisionId, submission}`. A successful submission
|
|
223
|
+
does not guarantee publication. `wait` checks the requested revision, succeeds
|
|
224
|
+
only for `PUBLISHED`, and outputs the review report with `success` and `reason`.
|
|
225
|
+
`--changelog` is limited to 2,000 characters by both the CLI and backend.
|
|
226
|
+
Rejection, a draft/sandbox/suspended revision, or a legacy manual-review hold
|
|
227
|
+
exit nonzero. Pending review continues until publication, the timeout (default
|
|
228
|
+
10 minutes), or optional `--max-attempts`. Timeout and attempt-limit results
|
|
229
|
+
include the last received report; polling can be resumed with the same IDs.
|
|
230
|
+
The deadline also bounds in-flight HTTP requests and retry delays.
|
|
231
|
+
|
|
232
|
+
Reads retry transient errors; writes are never automatically retried. The CLI
|
|
233
|
+
redacts credential fields and known credential values from provider output.
|
|
234
|
+
Redacted reads are for inspection and must not be submitted unchanged as
|
|
235
|
+
configuration. After an ambiguous write failure, use `list`, `get`, or `review`
|
|
236
|
+
to inspect the result before repeating the operation. No npm release is implied
|
|
237
|
+
by a local source checkout; use `bun run src/index.ts provider ...` or build and
|
|
238
|
+
run `node dist/index.js provider ...` while testing unreleased changes.
|
|
239
|
+
|
|
124
240
|
### Sandbox Commands
|
|
125
241
|
|
|
126
242
|
Sandbox commands provide an AI-friendly cloud computer lifecycle. The fastest
|
|
@@ -350,6 +466,8 @@ management without a JWT exchange:
|
|
|
350
466
|
xapi-to provider list
|
|
351
467
|
xapi-to provider create --file ./service.json
|
|
352
468
|
xapi-to provider update <service-id> --about-file ./ABOUT.md --website https://example.com
|
|
469
|
+
xapi-to provider update <service-id> --rate-limit-requests 100 --rate-limit-period-seconds 60
|
|
470
|
+
xapi-to provider update <service-id> --clear-rate-limit
|
|
353
471
|
xapi-to provider versions <service-id>
|
|
354
472
|
xapi-to provider revision start <service-id> 1
|
|
355
473
|
xapi-to provider version update <service-id> <version-id> --file ./contract.json
|
|
@@ -359,6 +477,10 @@ xapi-to provider metrics <service-id> --days 7
|
|
|
359
477
|
xapi-to provider events --after '<opaque-next-cursor>'
|
|
360
478
|
```
|
|
361
479
|
|
|
480
|
+
Service rate limits are optional and supported only for proxied services. Both
|
|
481
|
+
numeric flags are required when setting a limit; the quota is shared by all API
|
|
482
|
+
keys belonging to the same user for that service.
|
|
483
|
+
|
|
362
484
|
Service usage tutorials are Skill packages. Scaffold one from the serving
|
|
363
485
|
contract, submit it for review, wait for publication, then link it:
|
|
364
486
|
|
|
@@ -689,10 +689,10 @@ async function initiateOAuth(apiKeyId, providerId, jwtToken, apiHost, scopes) {
|
|
|
689
689
|
}
|
|
690
690
|
);
|
|
691
691
|
}
|
|
692
|
-
async function listOAuthBindings(jwtToken, apiHost) {
|
|
692
|
+
async function listOAuthBindings(jwtToken, apiHost, signal) {
|
|
693
693
|
return request(
|
|
694
694
|
`${scheme(apiHost)}://${apiHost}/api/oauth/bindings`,
|
|
695
|
-
{ method: "GET", headers: jwtHeaders(jwtToken) },
|
|
695
|
+
{ method: "GET", headers: jwtHeaders(jwtToken), signal },
|
|
696
696
|
DEFAULT_TIMEOUT_MS,
|
|
697
697
|
IDEMPOTENT_RETRIES
|
|
698
698
|
);
|