@aixnn/aixautots 0.6.17 → 0.6.20
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/dist/{automation-queue-DO8fOG6l.d.ts → automation-queue-GhfQtZLm.d.ts} +2 -2
- package/dist/{chunk-TJ2QIP5M.js → chunk-4NRIEM5Z.js} +249 -33
- package/dist/{chunk-WOPEKCVC.js → chunk-DAU3FVCV.js} +2 -2
- package/dist/chunk-DTXXQPOU.js +693 -0
- package/dist/{chunk-7BJPVSEZ.js → chunk-ED6CB3B4.js} +222 -12
- package/dist/{chunk-NIEGPH3E.js → chunk-FJKMRWYC.js} +55 -23
- package/dist/{chunk-ZDCTHR7D.js → chunk-H7KZUU67.js} +2 -2
- package/dist/{chunk-FJPIY4YI.js → chunk-HQ2L4NQ2.js} +262 -10
- package/dist/{chunk-LOKPZ677.js → chunk-JQBSGFAR.js} +2 -2
- package/dist/{chunk-2KPZSPV6.js → chunk-OJK35AQD.js} +105 -17
- package/dist/chunk-QISBQ532.js +1665 -0
- package/dist/{chunk-KASSYUGM.js → chunk-RFOJSDYI.js} +2 -2
- package/dist/{chunk-QEK25NUA.js → chunk-UEZVXYGP.js} +12 -5
- package/dist/{config-CBUhr4Gl.d.ts → config-C79rcedl.d.ts} +52 -10
- package/dist/core/index.d.ts +13 -9
- package/dist/core/index.js +2 -2
- package/dist/core/network-adb-node.d.ts +23 -0
- package/dist/core/network-adb-node.js +171 -0
- package/dist/{script-debugger-DoT02din.d.ts → device-channel-OiZwAqNQ.d.ts} +41 -55
- package/dist/{device-normalize-Vl5JYbAI.d.ts → device-normalize-ODrxJb-a.d.ts} +1 -1
- package/dist/device-session-PVHD6PNR.js +1 -0
- package/dist/i18n/index.js +1 -1
- package/dist/{mirror-session-Y1InpkUY.d.ts → mirror-session-DifANocH.d.ts} +2 -2
- package/dist/react/index.d.ts +19 -12
- package/dist/react/index.js +3 -3
- package/dist/script-debugger-DjxpvdaN.d.ts +56 -0
- package/dist/{task-agent-runner-Cl2ickJ1.d.ts → task-agent-runner-CAt-z8gr.d.ts} +3 -3
- package/dist/{types-Cp1ohbTb.d.ts → types-CBI5SIH5.d.ts} +102 -4
- package/dist/ui/billing.d.ts +43 -6
- package/dist/ui/billing.js +190 -309
- package/dist/ui/device-create.d.ts +1 -1
- package/dist/ui/device-create.js +7 -7
- package/dist/ui/device-mirror.js +5 -5
- package/dist/ui/devices.d.ts +5 -5
- package/dist/ui/devices.js +9 -9
- package/dist/ui/editor.d.ts +2 -2
- package/dist/ui/editor.js +5 -5
- package/dist/ui/index.d.ts +6 -4
- package/dist/ui/index.js +13 -492
- package/dist/ui/inspector.js +4 -4
- package/dist/ui/ip-commerce.d.ts +2 -2
- package/dist/ui/ip-commerce.js +5 -5
- package/dist/ui/market.js +4 -4
- package/dist/ui/mirror.d.ts +3 -3
- package/dist/ui/script-studio.js +4 -4
- package/dist/ui/scripts.d.ts +1 -1
- package/dist/ui/scripts.js +4 -4
- package/dist/ui/settings.d.ts +164 -0
- package/dist/ui/settings.js +10 -0
- package/dist/ui/tasks.js +9 -9
- package/package.json +9 -1
- package/dist/device-session-3XK2SZDF.js +0 -1
|
@@ -209,7 +209,8 @@ function resolveConfig(cfg) {
|
|
|
209
209
|
if (t2 == null) throw new AixAuthError("no user bearer token configured (set auth.user or getAuthToken)");
|
|
210
210
|
return t2;
|
|
211
211
|
});
|
|
212
|
-
|
|
212
|
+
const channel = cfg.channel?.trim() || void 0;
|
|
213
|
+
return { baseUrl: cfg.baseUrl, channel, getAuthToken, auth, fetchFn, wsFactory, rtcFactory, localNode: cfg.localNode };
|
|
213
214
|
}
|
|
214
215
|
|
|
215
216
|
// src/core/transport.ts
|
|
@@ -217,6 +218,7 @@ var ReconnectingSocket = class {
|
|
|
217
218
|
constructor(o) {
|
|
218
219
|
this.o = o;
|
|
219
220
|
this.ws = null;
|
|
221
|
+
this.opened = false;
|
|
220
222
|
this.closed = false;
|
|
221
223
|
this.attempt = 0;
|
|
222
224
|
this.reconnectTimer = null;
|
|
@@ -235,6 +237,7 @@ var ReconnectingSocket = class {
|
|
|
235
237
|
ws.onopen = () => {
|
|
236
238
|
if (!this.closed && this.ws === ws) {
|
|
237
239
|
this.attempt = 0;
|
|
240
|
+
this.opened = true;
|
|
238
241
|
this.o.onOpen?.();
|
|
239
242
|
}
|
|
240
243
|
};
|
|
@@ -247,6 +250,7 @@ var ReconnectingSocket = class {
|
|
|
247
250
|
ws.onclose = () => {
|
|
248
251
|
if (this.ws !== ws) return;
|
|
249
252
|
this.ws = null;
|
|
253
|
+
this.opened = false;
|
|
250
254
|
this.o.onClose?.();
|
|
251
255
|
if (!this.closed) this.scheduleReconnect();
|
|
252
256
|
};
|
|
@@ -272,6 +276,7 @@ var ReconnectingSocket = class {
|
|
|
272
276
|
}
|
|
273
277
|
const previous = this.ws;
|
|
274
278
|
this.ws = null;
|
|
279
|
+
this.opened = false;
|
|
275
280
|
try {
|
|
276
281
|
previous?.close();
|
|
277
282
|
} catch {
|
|
@@ -280,11 +285,19 @@ var ReconnectingSocket = class {
|
|
|
280
285
|
this.scheduleReconnect();
|
|
281
286
|
}
|
|
282
287
|
send(text) {
|
|
283
|
-
if (!this.ws) throw new Error("socket not connected");
|
|
288
|
+
if (!this.ws || !this.opened) throw new Error("socket not connected");
|
|
289
|
+
this.ws.send(text);
|
|
290
|
+
}
|
|
291
|
+
/** Refuse ADB writes when transport backpressure is unavailable or over budget. */
|
|
292
|
+
sendBounded(text, maxBufferedBytes) {
|
|
293
|
+
if (!this.ws || !this.opened) throw new Error("socket not connected");
|
|
294
|
+
if (typeof this.ws.bufferedAmount !== "number" || !Number.isFinite(this.ws.bufferedAmount) || this.ws.bufferedAmount + text.length > maxBufferedBytes) {
|
|
295
|
+
throw new Error("ADB socket buffer capacity unavailable or exhausted");
|
|
296
|
+
}
|
|
284
297
|
this.ws.send(text);
|
|
285
298
|
}
|
|
286
299
|
isConnected() {
|
|
287
|
-
return this.
|
|
300
|
+
return this.opened;
|
|
288
301
|
}
|
|
289
302
|
close() {
|
|
290
303
|
if (this.reconnectTimer !== null) {
|
|
@@ -292,6 +305,7 @@ var ReconnectingSocket = class {
|
|
|
292
305
|
this.reconnectTimer = null;
|
|
293
306
|
}
|
|
294
307
|
this.closed = true;
|
|
308
|
+
this.opened = false;
|
|
295
309
|
this.ws?.close();
|
|
296
310
|
this.ws = null;
|
|
297
311
|
}
|
|
@@ -383,7 +397,7 @@ var RestClient = class {
|
|
|
383
397
|
}
|
|
384
398
|
let resp;
|
|
385
399
|
try {
|
|
386
|
-
resp = await this.cfg.fetchFn(url, { method, headers, body, ...opts.signal ? { signal: opts.signal } : {} });
|
|
400
|
+
resp = await this.cfg.fetchFn(url, { method, headers, body, ...opts.redirect ? { redirect: opts.redirect } : {}, ...opts.signal ? { signal: opts.signal } : {} });
|
|
387
401
|
} catch (e) {
|
|
388
402
|
if (e instanceof AixError) throw e;
|
|
389
403
|
throw new AixError(`${method} ${path} request failed: ${String(e)}`, "network");
|
|
@@ -398,7 +412,7 @@ var RestClient = class {
|
|
|
398
412
|
const error = j.error && typeof j.error === "object" ? j.error : j;
|
|
399
413
|
const m = typeof error.message === "string" ? error.message : typeof j.error === "string" ? j.error : void 0;
|
|
400
414
|
detail = m || void 0;
|
|
401
|
-
apiCode = typeof error.code === "string" ? error.code : void 0;
|
|
415
|
+
apiCode = typeof error.code === "string" ? error.code : typeof j.error === "string" ? j.error : void 0;
|
|
402
416
|
const state = error.request_state ?? j.request_state;
|
|
403
417
|
requestState = state === "rejected" || state === "unknown" ? state : void 0;
|
|
404
418
|
} catch {
|
|
@@ -492,6 +506,9 @@ var UsersApi = class {
|
|
|
492
506
|
};
|
|
493
507
|
|
|
494
508
|
// src/core/resources/devices.ts
|
|
509
|
+
function isQueuedPowerReceipt(receipt) {
|
|
510
|
+
return receipt !== null && typeof receipt === "object" && "status" in receipt && receipt.status === "queued";
|
|
511
|
+
}
|
|
495
512
|
var DevicesApi = class {
|
|
496
513
|
constructor(c) {
|
|
497
514
|
this.c = c;
|
|
@@ -508,6 +525,10 @@ var DevicesApi = class {
|
|
|
508
525
|
provision(spec) {
|
|
509
526
|
return this.c.post("/api/devices/provision", spec);
|
|
510
527
|
}
|
|
528
|
+
/** Inspect a persisted provisioning operation without retrying creation or contacting the node. */
|
|
529
|
+
provisionOperation(operationId, options) {
|
|
530
|
+
return this.c.get(`/api/devices/provision/operations/${encodeURIComponent(operationId)}`, options);
|
|
531
|
+
}
|
|
511
532
|
/** Brand→model identity catalog for the create-wizard's 品牌 → 机型 picker
|
|
512
533
|
* (`GET /api/devices/profile-catalog`). Static read-only data; the chosen
|
|
513
534
|
* `model` is passed back via `ProvisionSpec.model` to lock the fingerprint base. */
|
|
@@ -526,14 +547,22 @@ var DevicesApi = class {
|
|
|
526
547
|
captureUiTree(deviceId) {
|
|
527
548
|
return this.op(deviceId, { op: "capture_ui_tree" });
|
|
528
549
|
}
|
|
529
|
-
/** Power / lifecycle op (`POST /api/devices/:id/power`).
|
|
530
|
-
*
|
|
531
|
-
* `{
|
|
532
|
-
*
|
|
533
|
-
*
|
|
550
|
+
/** Power / lifecycle op (`POST /api/devices/:id/power`). A confirmed Stop
|
|
551
|
+
* returns `{ stopped: true }`, but during an image cutover Stop may return
|
|
552
|
+
* `{ status: 'queued', desired_running: false }`. Reboot starts asynchronously
|
|
553
|
+
* and returns `{ status: 'rebooting', async: true }`. Non-2xx responses
|
|
554
|
+
* reject with the node/backend error. */
|
|
534
555
|
power(deviceId, action, extra) {
|
|
535
556
|
return this.c.post(`/api/devices/${encodeURIComponent(deviceId)}/power`, { action, ...extra });
|
|
536
557
|
}
|
|
558
|
+
/** Read the virtual Android settings back from the device (not USB host authorization). */
|
|
559
|
+
getDeveloperSettings(deviceId) {
|
|
560
|
+
return this.c.get(`/api/devices/${encodeURIComponent(deviceId)}/developer-settings`);
|
|
561
|
+
}
|
|
562
|
+
/** Enable developer mode and USB debugging; backend verifies both by reading Android settings. */
|
|
563
|
+
enableDeveloperSettings(deviceId) {
|
|
564
|
+
return this.c.post(`/api/devices/${encodeURIComponent(deviceId)}/developer-settings`, { developerMode: true, usbDebugging: true });
|
|
565
|
+
}
|
|
537
566
|
/** List all user data snapshots, including while the device is offline. */
|
|
538
567
|
listSnapshots(deviceId) {
|
|
539
568
|
return this.c.get(`/api/devices/${encodeURIComponent(deviceId)}/snapshots`);
|
|
@@ -577,6 +606,8 @@ var DevicesApi = class {
|
|
|
577
606
|
lease(deviceId) {
|
|
578
607
|
return this.c.post(`/api/devices/${encodeURIComponent(deviceId)}/lease`);
|
|
579
608
|
}
|
|
609
|
+
/** Release the caller's open real-device lease sessions and settle their billing.
|
|
610
|
+
* This does not stop, power off, or delete the device. */
|
|
580
611
|
release(deviceId) {
|
|
581
612
|
return this.c.post(`/api/devices/${encodeURIComponent(deviceId)}/release`);
|
|
582
613
|
}
|
|
@@ -617,6 +648,10 @@ var DevicesApi = class {
|
|
|
617
648
|
updateProxy(deviceId, proxy) {
|
|
618
649
|
return this.c.patch(`/api/devices/${encodeURIComponent(deviceId)}`, { proxy });
|
|
619
650
|
}
|
|
651
|
+
/** Retrieve only the configured custom proxy address for an authorized device. */
|
|
652
|
+
customProxyAddress(deviceId) {
|
|
653
|
+
return this.c.get(`/api/devices/${encodeURIComponent(deviceId)}/proxy`);
|
|
654
|
+
}
|
|
620
655
|
/** Probe the device's configured proxy and report its egress IP/connectivity. */
|
|
621
656
|
probeProxy(deviceId) {
|
|
622
657
|
return this.c.post(`/api/devices/${encodeURIComponent(deviceId)}/proxy/probe`, {});
|
|
@@ -1441,14 +1476,31 @@ var ImagesApi = class {
|
|
|
1441
1476
|
};
|
|
1442
1477
|
|
|
1443
1478
|
// src/core/resources/billing.ts
|
|
1479
|
+
function normalizeTopupAmount(value) {
|
|
1480
|
+
if (typeof value !== "string") return null;
|
|
1481
|
+
const text = value.trim();
|
|
1482
|
+
if (!/^\d+(?:\.\d{1,4})?$/.test(text)) return null;
|
|
1483
|
+
const [whole = "", fraction = ""] = text.split(".");
|
|
1484
|
+
const integer = whole.replace(/^0+/, "") || "0";
|
|
1485
|
+
const decimals = fraction.replace(/0+$/, "");
|
|
1486
|
+
if (integer.length > 10 || decimals.length > 4 || integer === "0" && !decimals) return null;
|
|
1487
|
+
return decimals ? `${integer}.${decimals}` : integer;
|
|
1488
|
+
}
|
|
1489
|
+
var TOPUP_UUID = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i;
|
|
1444
1490
|
var BillingApi = class {
|
|
1445
|
-
constructor(c) {
|
|
1491
|
+
constructor(c, defaultChannel) {
|
|
1446
1492
|
this.c = c;
|
|
1493
|
+
this.defaultChannel = defaultChannel;
|
|
1447
1494
|
}
|
|
1448
1495
|
/** 当前钱包余额 + 最近流水(`GET /api/billing/balance`)。 */
|
|
1449
1496
|
balance() {
|
|
1450
1497
|
return this.c.get("/api/billing/balance");
|
|
1451
1498
|
}
|
|
1499
|
+
/** Caller project runtime payer mode for display/diagnosis only; server admission is authoritative.
|
|
1500
|
+
* Account balance currency is reported by the server; this does not convert credits or points. */
|
|
1501
|
+
runtimePayer() {
|
|
1502
|
+
return this.c.get("/api/billing/runtime-payer");
|
|
1503
|
+
}
|
|
1452
1504
|
/** 名下项目订阅列表(`GET /api/billing/subscriptions`)。 */
|
|
1453
1505
|
subscriptions() {
|
|
1454
1506
|
return this.c.get("/api/billing/subscriptions");
|
|
@@ -1461,9 +1513,45 @@ var BillingApi = class {
|
|
|
1461
1513
|
ownNodeCharges() {
|
|
1462
1514
|
return this.c.get("/api/billing/own-node-charges");
|
|
1463
1515
|
}
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1516
|
+
topupMethods() {
|
|
1517
|
+
return this.c.get("/api/billing/topup/methods");
|
|
1518
|
+
}
|
|
1519
|
+
wiseOrders() {
|
|
1520
|
+
return this.c.get("/api/billing/wise/orders");
|
|
1521
|
+
}
|
|
1522
|
+
createWiseOrder(amount_cents, opts) {
|
|
1523
|
+
const channel = opts?.channel?.trim() || this.defaultChannel;
|
|
1524
|
+
const body = channel ? { amount_cents, channel } : { amount_cents };
|
|
1525
|
+
return this.c.post("/api/billing/wise/orders", body, { redirect: "error" });
|
|
1526
|
+
}
|
|
1527
|
+
stripeOrders() {
|
|
1528
|
+
return this.c.get("/api/billing/stripe/orders");
|
|
1529
|
+
}
|
|
1530
|
+
createStripeCheckout(input) {
|
|
1531
|
+
const channel = input.channel?.trim() || this.defaultChannel;
|
|
1532
|
+
const body = channel ? { ...input, channel } : input;
|
|
1533
|
+
return this.c.post("/api/billing/stripe/checkout", body, { redirect: "error" });
|
|
1534
|
+
}
|
|
1535
|
+
reconcileStripeCheckout(session_id) {
|
|
1536
|
+
return this.c.post("/api/billing/stripe/reconcile", { session_id }, { redirect: "error" });
|
|
1537
|
+
}
|
|
1538
|
+
/** 查询当前管理员身份,或按 UUID 核对未决充值;不执行写入。 */
|
|
1539
|
+
async lookupTopup(requestId) {
|
|
1540
|
+
if (requestId !== void 0 && (typeof requestId !== "string" || !TOPUP_UUID.test(requestId))) {
|
|
1541
|
+
throw new TypeError("request_id must be a UUID");
|
|
1542
|
+
}
|
|
1543
|
+
return this.c.get("/api/admin/billing/balance/topup", { scope: "admin", query: requestId ? { request_id: requestId } : void 0 });
|
|
1544
|
+
}
|
|
1545
|
+
/** PUT 避免旧版仅 POST 的服务端将未携回执的请求重复入账。 */
|
|
1546
|
+
async topup(input) {
|
|
1547
|
+
if (typeof input.request_id !== "string" || !TOPUP_UUID.test(input.request_id)) {
|
|
1548
|
+
throw new TypeError("request_id must be a UUID");
|
|
1549
|
+
}
|
|
1550
|
+
const amount = normalizeTopupAmount(input.amount);
|
|
1551
|
+
if (amount === null) throw new RangeError("amount must be a positive NUMERIC(14,4) decimal text");
|
|
1552
|
+
const note = input.note?.trim();
|
|
1553
|
+
if (note && ([...note].length > 500 || note.includes("\0"))) throw new RangeError("note must be at most 500 characters and contain no NUL");
|
|
1554
|
+
return this.c.put("/api/admin/billing/balance/topup", { ...input, amount, note: note || void 0 }, { scope: "admin" });
|
|
1467
1555
|
}
|
|
1468
1556
|
};
|
|
1469
1557
|
|
|
@@ -1794,7 +1882,7 @@ var AixClient = class {
|
|
|
1794
1882
|
this.llm = new LlmApi(this.http);
|
|
1795
1883
|
this.admin = new AdminApi(this.http);
|
|
1796
1884
|
this.images = new ImagesApi(this.http);
|
|
1797
|
-
this.billing = new BillingApi(this.http);
|
|
1885
|
+
this.billing = new BillingApi(this.http, this.cfg.channel);
|
|
1798
1886
|
this.proxies = new ManagedProxiesApi(this.http);
|
|
1799
1887
|
this.ipCommerce = new IpCommerceApi(this.http);
|
|
1800
1888
|
this.tokens = new ApiTokensApi(this.http);
|
|
@@ -1815,7 +1903,7 @@ var AixClient = class {
|
|
|
1815
1903
|
* 即可,不必回依赖 client 实例)。
|
|
1816
1904
|
*/
|
|
1817
1905
|
async deviceSession(deviceId, opts = {}) {
|
|
1818
|
-
const { DeviceSession: DeviceSession2 } = await import('./device-session-
|
|
1906
|
+
const { DeviceSession: DeviceSession2 } = await import('./device-session-PVHD6PNR.js');
|
|
1819
1907
|
return DeviceSession2.open(this.cfg, deviceId, opts);
|
|
1820
1908
|
}
|
|
1821
1909
|
};
|
|
@@ -2466,4 +2554,4 @@ async function pullFile(source, deviceId, src, opts = {}) {
|
|
|
2466
2554
|
}
|
|
2467
2555
|
}
|
|
2468
2556
|
|
|
2469
|
-
export { AdminApi, AixAuthError, AixClient, AixDeviceOffline, AixError, AixLocked, AixProtocolError, AixTimeout, ApiTokensApi, AuthApi, BillingApi, ClustersApi, DeviceSession, DevicesApi, EnvRun, FleetApi, ImagesApi, IpCommerceApi, LlmApi, LocalNodeController, LocatorsApi, ManagedProxiesApi, NodesApi, ProjectsApi, ReconnectingSocket, RestClient, ScriptsApi, ShortcutsApi, SnapshotsApi, TasksApi, UsersApi, WebhooksApi, authHeader, buildAuthProvider, createCachedUserCredential, createClient, detectEnvOs, envBlocker, errorFromRet, executionStreamEventsAfter, executionWsTicketUrl, executionWsUrl, getIceServers, getLocale, isEnvEventFrame, isExecutionFrame, isFleetRunTerminal, isFridaEventFrame, isRetFrame, isScriptletEventFrame, isStatusFrame, joinUrl, mintViewerGrant, mintViewerToken, parseIncoming, pullFile, pushFile, resolveConfig, restClient, runEnvToFinish, setLocale, summarizeEnv, t, validUuid, validateViewerGrant };
|
|
2557
|
+
export { AdminApi, AixAuthError, AixClient, AixDeviceOffline, AixError, AixLocked, AixProtocolError, AixTimeout, ApiTokensApi, AuthApi, BillingApi, ClustersApi, DeviceSession, DevicesApi, EnvRun, FleetApi, ImagesApi, IpCommerceApi, LlmApi, LocalNodeController, LocatorsApi, ManagedProxiesApi, NodesApi, ProjectsApi, ReconnectingSocket, RestClient, ScriptsApi, ShortcutsApi, SnapshotsApi, TasksApi, UsersApi, WebhooksApi, authHeader, buildAuthProvider, createCachedUserCredential, createClient, detectEnvOs, envBlocker, errorFromRet, executionStreamEventsAfter, executionWsTicketUrl, executionWsUrl, getIceServers, getLocale, isEnvEventFrame, isExecutionFrame, isFleetRunTerminal, isFridaEventFrame, isQueuedPowerReceipt, isRetFrame, isScriptletEventFrame, isStatusFrame, joinUrl, mintViewerGrant, mintViewerToken, normalizeTopupAmount, parseIncoming, pullFile, pushFile, resolveConfig, restClient, runEnvToFinish, setLocale, summarizeEnv, t, validUuid, validateViewerGrant };
|