@aixnn/aixautots 0.5.3 → 0.5.4

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.
@@ -0,0 +1,22 @@
1
+ interface Box {
2
+ left: number;
3
+ top: number;
4
+ width: number;
5
+ height: number;
6
+ }
7
+ interface DeviceSize {
8
+ width: number;
9
+ height: number;
10
+ }
11
+ interface DevicePoint {
12
+ x: number;
13
+ y: number;
14
+ }
15
+ /** Map a pointer's client coords inside a `<video>` (rendered with object-fit:
16
+ * contain) to device pixels. Returns null if the point is in a letterbox bar. */
17
+ declare function toDevicePoint(pointer: {
18
+ clientX: number;
19
+ clientY: number;
20
+ }, box: Box, device: DeviceSize): DevicePoint | null;
21
+
22
+ export { type Box as B, type DeviceSize as D, type DevicePoint as a, toDevicePoint as t };
@@ -0,0 +1,135 @@
1
+ import { R as ResolvedConfig, W as WebSocketFactory } from '../config-fsx4jlLK.js';
2
+ export { f as AdminApi, c as AixClient, A as AixConfig, g as ApiTokensApi, h as AuthApi, i as AuthProvider, B as BillingApi, C as CachedUserCredentialOpts, j as ClustersApi, k as Credential, D as DcStream, l as DeviceReq, m as DeviceResp, n as DeviceSession, o as DevicesApi, p as EnvAction, e as EnvEventKind, q as EnvFinished, E as EnvOs, r as EnvResultDto, d as EnvRoute, s as EnvRun, t as EnvSetupInput, u as EnvStepMeta, v as EnvStepView, w as EnvSummary, x as EnvTeardownInput, y as ExecutionFrame, z as ExecutionStreamEvent, G as ExecutionStreamEventsResult, H as FileEntry, I as FleetApi, F as FridaEventFrame, J as IRTCDataChannel, K as IRTCPeerConnection, L as IWebSocket, M as ImagesApi, N as IncomingFrame, P as LlmApi, Q as LocalNodeController, T as LocalNodeOptions, U as LocatorsApi, V as NodeHost, X as NodeHostStatus, Y as NodesApi, O as OutgoingFrame, Z as ProgressFn, _ as ProjectsApi, $ as PullResult, a0 as PushInput, a1 as RTCFactory, a2 as RequestOpts, a3 as RestClient, a4 as RetFrame, a as RunEventKind, a5 as Scope, S as ScriptletEventFrame, a6 as ScriptsApi, a7 as ShortcutsApi, b as StatusFrame, a8 as StreamTarget, a9 as TasksApi, aa as TransferOpts, ab as TransferProgress, ac as TransferResult, ad as UsersApi, ae as WebhooksApi, af as authHeader, ag as buildAuthProvider, ah as createCachedUserCredential, ai as createClient, aj as detectEnvOs, ak as envBlocker, al as executionStreamEventsAfter, am as executionWsTicketUrl, an as executionWsUrl, ao as isEnvEventFrame, ap as isExecutionFrame, aq as isFleetRunTerminal, ar as isFridaEventFrame, as as isRetFrame, at as isScriptletEventFrame, au as isStatusFrame, av as joinUrl, aw as parseIncoming, ax as pullFile, ay as pushFile, az as resolveConfig, aA as restClient, aB as runEnvToFinish, aC as summarizeEnv } from '../config-fsx4jlLK.js';
3
+ export { A as AdbResult, D as DeviceChannel, b as DeviceTunnel, c as ScriptDebugger, d as ScriptDebuggerOptions, a as ScriptEngine, S as ScriptEvent, e as ScriptRunInput, W as WdaResult } from '../script-debugger-Cu_coj-h.js';
4
+ export { A as AutomationQueue, B as BatchConfig, F as FlowEvent, a as FlowRun, b as FlowSubmit, Q as QueueMode, s as submitBatch } from '../automation-queue-CKsueO9z.js';
5
+ import { h as ScriptParam } from '../types-C2WXVcam.js';
6
+ export { i as AdbScanResult, d as AgentTaskBlocker, j as AgentTaskCurrentAttempt, k as AgentTaskEvent, l as AgentTaskEventsResult, e as AgentTaskEvidence, m as AgentTaskReadResult, n as AgentTaskReadTarget, o as AgentTaskSubmitInput, p as AgentTaskSubmitResult, c as AgentTaskTarget, A as AgentTaskTargetStatus, q as ApiTokenRow, r as AppCandidate, s as AppEntry, t as AppTemplate, u as AppTemplateItemAndroid, v as AppTemplateItemIos, w as AuthResult, B as BalanceLedgerRow, x as BalanceResp, y as BillingPlan, C as CatalogBrand, z as CatalogModel, E as Cluster, F as ClusterMode, G as CreateClusterInput, H as CreateLocatorInput, I as CreateProjectInput, J as CreateProjectResult, K as CreateTokenInput, L as CreateWebhookInput, M as CreatedToken, g as Decimal, O as DeveloperRef, Q as DeviceLocation, R as DeviceOp, T as DeviceProfileView, U as DeviceRate, D as DeviceRow, V as DeviceUsageSession, b as DiscoveredDevice, W as DiscoveredStatus, X as ElementNode, Y as FleetMode, Z as FleetRunDetail, _ as FleetRunDeviceRow, $ as FleetRunSubmit, a0 as ImageArtifact, a1 as ImageInput, a2 as ImageOption, a3 as InstallAntiDetectResult, a4 as IosAccountState, a5 as IosDeviceRow, a6 as IosLibraryApp, a7 as IosLoginResult, a8 as IosScanResult, a9 as KnownDeviceOpName, aa as LlmTestResult, ab as Locator, ac as MdnsEntry, ad as NewAppTemplate, ae as NewShortcut, af as NodeEffectiveCaps, ag as NodeOwnerPolicy, N as NodeRow, ah as NodeScope, ai as OwnNodeDailyCharge, aj as PlanInput, ak as PlatformOem, al as PlatformOemInput, am as PowerAction, an as PowerRunResult, ao as ProfileOverrides, ap as Project, aq as ProjectSubscription, ar as ProjectUserResult, a as ProvisionResult, P as ProvisionSpec, as as ProvisionUserInput, at as ProvisionUserResult, au as ProxyApplyReceipt, av as ProxyApplyStatus, aw as ProxyPatchResult, ax as ProxyProbe, ay as ProxyProbeErrorCode, az as ProxySummary, aA as ProxyUrl, aB as RateInput, aC as RebateLedgerRow, aD as RecycledDeviceRow, aE as RegisterNodeInput, aF as RegisterNodeResult, aG as ScreenshotResult, S as Script, f as ScriptSummary, aH as SendCodeResult, aI as SetDataRootResult, aJ as SetDisguiseResult, aK as SetProfileResult, aL as Shortcut, aM as ShortcutParam, aN as ShortcutRunResult, aO as SubscribeInput, aP as TaskEvent, aQ as TaskEventsResult, aR as TaskListFilter, aS as TaskListResult, aT as TaskStatus, aU as TaskSubmitResult, aV as TaskSummary, aW as TaskTarget, aX as TopupInput, aY as TopupResult, aZ as UpdateNodeInput, a_ as User, a$ as VerifyCodeResult, b0 as WebhookConfig } from '../types-C2WXVcam.js';
7
+ import { C as ControlMessage } from '../mirror-session-DM-trg1F.js';
8
+ export { I as InputMessage, M as MirrorSession, S as SCRCPY_PROFILES, a as ScrcpyProfile, b as ScrcpyProfileName, q as qualityMessage } from '../mirror-session-DM-trg1F.js';
9
+ import { B as Box, D as DeviceSize } from '../coords-LPR_MPyp.js';
10
+ export { a as DevicePoint, t as toDevicePoint } from '../coords-LPR_MPyp.js';
11
+ export { D as DeviceTransport, N as NormalizedDevice, n as normalizeDevices } from '../device-normalize-BaThgnH7.js';
12
+
13
+ type AixErrorCode = 'auth' | 'timeout' | 'offline' | 'locked' | 'protocol' | 'unknown';
14
+ declare class AixError extends Error {
15
+ readonly code: AixErrorCode;
16
+ /** HTTP status when the error came from a REST response (else undefined). */
17
+ readonly status?: number;
18
+ /** Backend's human-facing message parsed from the response body (`message`/
19
+ * `error` field), if any — prefer this over `message` when showing a prompt
20
+ * (e.g. 402 → "账号余额不足,请充值"). */
21
+ readonly detail?: string;
22
+ constructor(message: string, code?: AixErrorCode, opts?: {
23
+ status?: number;
24
+ detail?: string;
25
+ });
26
+ }
27
+ declare class AixAuthError extends AixError {
28
+ constructor(m: string);
29
+ }
30
+ declare class AixTimeout extends AixError {
31
+ constructor(m: string);
32
+ }
33
+ declare class AixDeviceOffline extends AixError {
34
+ constructor(m: string);
35
+ }
36
+ declare class AixLocked extends AixError {
37
+ constructor(m: string);
38
+ }
39
+ declare class AixProtocolError extends AixError {
40
+ constructor(m: string);
41
+ }
42
+ /** Map a backend `ret.error` string to the most specific typed error. */
43
+ declare function errorFromRet(error: string): AixError;
44
+
45
+ interface WsAccess {
46
+ token: string;
47
+ expires_in: number;
48
+ direct_ws: string | null;
49
+ relay_ws: string;
50
+ }
51
+ /** POST /api/devices/:id/ws-access → short-lived device token + dual WS links. */
52
+ declare function mintDeviceAccess(cfg: ResolvedConfig, deviceId: string): Promise<WsAccess>;
53
+ /** Choose the WS url to use, appending the token query param. */
54
+ declare function wsUrlFromAccess(a: WsAccess, prefer?: 'direct' | 'relay'): string;
55
+
56
+ interface ReconnectingSocketOpts {
57
+ urlProvider: () => Promise<string>;
58
+ wsFactory: WebSocketFactory;
59
+ onMessage: (text: string) => void;
60
+ onOpen?: () => void;
61
+ onClose?: () => void;
62
+ baseDelayMs?: number;
63
+ maxDelayMs?: number;
64
+ }
65
+ /** A WebSocket that reconnects with exponential backoff + jitter. Each
66
+ * (re)connect calls `urlProvider()` so a fresh token can be embedded. */
67
+ declare class ReconnectingSocket {
68
+ private readonly o;
69
+ private ws;
70
+ private closed;
71
+ private attempt;
72
+ private reconnectTimer;
73
+ private readonly base;
74
+ private readonly max;
75
+ constructor(o: ReconnectingSocketOpts);
76
+ start(): Promise<void>;
77
+ private connect;
78
+ private scheduleReconnect;
79
+ send(text: string): void;
80
+ isConnected(): boolean;
81
+ close(): void;
82
+ }
83
+
84
+ /** schema 存放在 variables 里的保留键。以 `__` 前缀避免与真实参数键冲突。 */
85
+ declare const SCHEMA_KEY = "__schema__";
86
+ /**
87
+ * 从 `Script.variables` 解出结构化 schema。
88
+ * - 有合法 `__schema__` 数组 → 采用之(去重保唯一 isTarget:仅第一个生效)。
89
+ * - 否则降级:把所有非 `__` 前缀键当 `type:'text'` 字段,default=String(值)。
90
+ */
91
+ declare function variablesToSchema(variables: Record<string, unknown> | undefined): ScriptParam[];
92
+ /**
93
+ * 把结构化 schema 写回 `variables`:产出 `{ __schema__, <key>: <default> }`。
94
+ * 保留传入 variables 里的其它 `__` 保留键(除 `__schema__` 本身)。
95
+ */
96
+ declare function schemaToVariables(schema: ScriptParam[], base?: Record<string, unknown>): Record<string, unknown>;
97
+ /** schema 中被标记为目标字段(isTarget)的参数;无则 undefined。 */
98
+ declare function targetParam(schema: ScriptParam[]): ScriptParam | undefined;
99
+ /** schema 默认值映射(key → 字符串),供表单初始化。 */
100
+ declare function schemaDefaults(schema: ScriptParam[]): Record<string, string>;
101
+
102
+ declare function getIceServers(cfg: ResolvedConfig): Promise<unknown[]>;
103
+ declare function mintViewerToken(cfg: ResolvedConfig, session: string): Promise<string>;
104
+
105
+ interface PointerSample {
106
+ clientX: number;
107
+ clientY: number;
108
+ /** Timestamp in ms (e.g. `performance.now()` / `event.timeStamp`). */
109
+ t: number;
110
+ }
111
+ interface ClassifyDragOpts {
112
+ /** Max pixel movement still treated as a tap (not a swipe). */
113
+ tapMovePx?: number;
114
+ }
115
+ /** Classify a pointer gesture (down → up) into a `tap` or `swipe`.
116
+ * Coords are normalized to [0,1] via the video `box` + device size (the node
117
+ * scales back to px). Returns null if the relevant point is in the letterbox. */
118
+ declare function classifyDrag(start: PointerSample, end: PointerSample, box: Box, device: DeviceSize, opts?: ClassifyDragOpts): ControlMessage | null;
119
+ interface KeyEventLike {
120
+ key: string;
121
+ ctrlKey?: boolean;
122
+ metaKey?: boolean;
123
+ altKey?: boolean;
124
+ }
125
+ /** Map a keydown into a `key` (special keys) or `text` (printable char) control
126
+ * message. Returns null for unmapped / modifier-combo keys (let the browser
127
+ * keep them). */
128
+ declare function mapKey(e: KeyEventLike): ControlMessage | null;
129
+
130
+ type Locale = "en" | "zh";
131
+ declare function setLocale(l: Locale): void;
132
+ declare function getLocale(): Locale;
133
+ declare function t(code: AixErrorCode): string;
134
+
135
+ export { AixAuthError, AixDeviceOffline, AixError, type AixErrorCode, AixLocked, AixProtocolError, AixTimeout, Box, type ClassifyDragOpts, ControlMessage, DeviceSize, type KeyEventLike, type Locale, type PointerSample, ReconnectingSocket, ResolvedConfig, SCHEMA_KEY, ScriptParam, WebSocketFactory, type WsAccess, classifyDrag, errorFromRet, getIceServers, getLocale, mapKey, mintDeviceAccess, mintViewerToken, schemaDefaults, schemaToVariables, setLocale, t, targetParam, variablesToSchema, wsUrlFromAccess };
@@ -0,0 +1,43 @@
1
+ import { D as DeviceRow } from './types-C2WXVcam.js';
2
+
3
+ /** One backend device row as a transport of a (possibly de-duplicated) physical
4
+ * device. The same phone reachable over both USB and WiFi yields two rows with
5
+ * different `external_id`s — they share a `transport` label and a stable
6
+ * `serialno` (set by the node from `ro.serialno`). */
7
+ interface DeviceTransport {
8
+ /** The adb-serial-derived id this transport is addressed by (`POST /api/devices/:id/*`). */
9
+ external_id: string;
10
+ /** `'usb' | 'wifi' | 'virtual' | null` — from `meta.transport`. */
11
+ transport: string | null;
12
+ online: boolean;
13
+ node_id: string | null;
14
+ node_name: string | null;
15
+ last_seen_at: string | null;
16
+ }
17
+ /** A physical device after merging its transport rows. Extends the chosen
18
+ * primary `DeviceRow`, but:
19
+ * - `device_id` is the id to address device ops at (the active transport's
20
+ * `external_id`) — NOT the DB primary key `id`. The whole `/api/devices/:id/*`
21
+ * family resolves by `external_id`, so addressing by `id` 403s "not in scope".
22
+ * - `online` is true if ANY transport is online.
23
+ * - `transports` lists every underlying row (so the UI can show "USB + WiFi"). */
24
+ interface NormalizedDevice extends DeviceRow {
25
+ /** The `external_id` to pass to every `/api/devices/:id/*` call. */
26
+ device_id: string;
27
+ transports: DeviceTransport[];
28
+ }
29
+ /** Merge the caller's device rows so the same physical device appears once.
30
+ *
31
+ * Dedup key: `meta.serialno` when present; otherwise the row's own `external_id`.
32
+ *
33
+ * Cross-reference: a provisioned virtual device row (e.g. `external_id = rd-XXXX`)
34
+ * typically has no `meta.serialno`, but the ADB-TCP row the node auto-discovers
35
+ * for the same container (e.g. `external_id = 127.0.0.1:PORT`) carries
36
+ * `meta.serialno = rd-XXXX`. We collect all serialno values first, then treat any
37
+ * row whose `external_id` appears in that set as belonging to the same group —
38
+ * so both rows end up under `sn:rd-XXXX` and are merged into one display entry.
39
+ *
40
+ * Output order follows first appearance of each device in `rows`. */
41
+ declare function normalizeDevices(rows: DeviceRow[]): NormalizedDevice[];
42
+
43
+ export { type DeviceTransport as D, type NormalizedDevice as N, normalizeDevices as n };
@@ -0,0 +1,30 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+
4
+ /**
5
+ * aixautots UI 内置词典(扁平 key→文案)。默认提供 en / zh 两份。各页面下沉时把自己
6
+ * 的文案 key 加到这里(命名建议:`<area>.<thing>`,如 `devices.title`、`common.refresh`)。
7
+ * 接入方可通过 `AixI18nProvider` 的 `overrides` 增改任意 key。
8
+ */
9
+ type AixLang = 'en' | 'zh';
10
+ type AixDict = Record<string, string>;
11
+
12
+ type AixT = (key: string, vars?: Record<string, string | number>) => string;
13
+ interface I18nValue {
14
+ lang: AixLang;
15
+ t: AixT;
16
+ }
17
+ interface AixI18nProviderProps {
18
+ /** 语言,默认 en。 */
19
+ lang?: AixLang;
20
+ /** 增改词条:按语言合并进内置词典(同 key 覆盖)。 */
21
+ overrides?: Partial<Record<AixLang, AixDict>>;
22
+ children: ReactNode;
23
+ }
24
+ declare function AixI18nProvider({ lang, overrides, children }: AixI18nProviderProps): react.FunctionComponentElement<react.ProviderProps<I18nValue | null>>;
25
+ /** 取翻译函数。未包 Provider 时回退到 en 内置词典(找不到 key 则原样返回 key)。 */
26
+ declare function useAixT(): AixT;
27
+ /** 取当前语言(未包 Provider 时为 en)。 */
28
+ declare function useAixLang(): AixLang;
29
+
30
+ export { type AixDict, AixI18nProvider, type AixI18nProviderProps, type AixLang, type AixT, useAixLang, useAixT };
@@ -0,0 +1,108 @@
1
+ import { A as AixConfig, R as ResolvedConfig } from './config-fsx4jlLK.js';
2
+
3
+ /** Mirrors the node's `ControlMsg` (webrtc/control.rs): `t`-tagged, coords
4
+ * normalized [0,1] (node scales to px). Sent over the `control` DataChannel. */
5
+ type ControlMessage = {
6
+ t: 'tap';
7
+ x: number;
8
+ y: number;
9
+ } | {
10
+ t: 'swipe';
11
+ from_x: number;
12
+ from_y: number;
13
+ to_x: number;
14
+ to_y: number;
15
+ duration_ms?: number;
16
+ } | {
17
+ t: 'touch_down';
18
+ x: number;
19
+ y: number;
20
+ } | {
21
+ t: 'touch_move';
22
+ x: number;
23
+ y: number;
24
+ } | {
25
+ t: 'touch_up';
26
+ x: number;
27
+ y: number;
28
+ } | {
29
+ t: 'key';
30
+ code: string;
31
+ } | {
32
+ t: 'text';
33
+ value: string;
34
+ } | {
35
+ t: 'home';
36
+ } | {
37
+ t: 'back';
38
+ } | {
39
+ t: 'rotate';
40
+ orientation: 'portrait' | 'landscape';
41
+ } | {
42
+ t: 'quality';
43
+ max_size: number;
44
+ bitrate: number;
45
+ fps: number;
46
+ };
47
+ type InputMessage = ControlMessage;
48
+ /** Named encode profiles (latency/quality tradeoff). The client owns the
49
+ * names; the node only sees the explicit knobs (`qualityMessage`). */
50
+ type ScrcpyProfileName = 'balanced' | 'low_latency' | 'high_quality';
51
+ interface ScrcpyProfile {
52
+ /** Long-edge cap in px; 0 = native resolution. */
53
+ max_size: number;
54
+ /** Target video bitrate in bits/s. */
55
+ bitrate: number;
56
+ /** Frame-rate cap. */
57
+ fps: number;
58
+ }
59
+ declare const SCRCPY_PROFILES: Record<ScrcpyProfileName, ScrcpyProfile>;
60
+ /** Build the `quality` control message for a named profile. */
61
+ declare function qualityMessage(profile: ScrcpyProfileName): ControlMessage;
62
+ /** WebRTC viewer for one signaling `session`. Viewer is the **answerer**: it
63
+ * waits for an `offer` from the node (which is the offerer and owns the video
64
+ * track + `control` DataChannel), creates an answer, and receives the
65
+ * `control` DataChannel via `ondatachannel`. */
66
+ declare class MirrorSession {
67
+ private readonly cfg;
68
+ readonly session: string;
69
+ private readonly socket;
70
+ private readonly iceServers;
71
+ private readonly token;
72
+ private pc;
73
+ private input;
74
+ private _stream;
75
+ private peerId;
76
+ private remotePeer;
77
+ private remoteDescriptionReady;
78
+ private pendingIce;
79
+ private readonly stateListeners;
80
+ private readonly streamListeners;
81
+ private constructor();
82
+ /** Start a viewer session. On WebSocket reconnect the socket re-joins
83
+ * automatically; the node then sends a fresh offer, which is paired with a
84
+ * fresh RTCPeerConnection (see the `offer` handler) — no consumer action
85
+ * needed to restore the video track. */
86
+ static join(cfg: AixConfig | ResolvedConfig, session: string): Promise<MirrorSession>;
87
+ get stream(): MediaStream | null;
88
+ onConnectionStateChange(cb: (s: string) => void): () => void;
89
+ onStream(cb: (s: MediaStream) => void): () => void;
90
+ sendInput(msg: InputMessage): void;
91
+ /** Ask the node to switch this device's encode profile (restarts its capture
92
+ * pipeline; the video blanks briefly while it re-syncs on a keyframe). */
93
+ setQuality(profile: ScrcpyProfileName): void;
94
+ /** Current round-trip time (seconds) from the active ICE candidate pair, or
95
+ * null when stats are unavailable (no pc yet / mock without getStats). Used
96
+ * by the auto quality heuristic. */
97
+ currentRtt(): Promise<number | null>;
98
+ private sendSignal;
99
+ private ensurePc;
100
+ private attachInput;
101
+ /** Drop the current peer connection (keeps the last frame on screen until
102
+ * the replacement track arrives). */
103
+ private resetPeer;
104
+ private onSignal;
105
+ leave(): void;
106
+ }
107
+
108
+ export { type ControlMessage as C, type InputMessage as I, MirrorSession as M, SCRCPY_PROFILES as S, type ScrcpyProfile as a, type ScrcpyProfileName as b, qualityMessage as q };
@@ -0,0 +1,19 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+
4
+ interface AixNav {
5
+ /** 跳转到目标路径(应用内路由)。replace=true 时替换历史记录。 */
6
+ navigate: (to: string, opts?: {
7
+ replace?: boolean;
8
+ }) => void;
9
+ }
10
+ interface AixNavProviderProps {
11
+ nav: AixNav;
12
+ children: ReactNode;
13
+ }
14
+ declare function AixNavProvider({ nav, children }: AixNavProviderProps): react.FunctionComponentElement<react.ProviderProps<AixNav | null>>;
15
+ /** 取注入的导航器。未包 `AixNavProvider` 时返回一个 no-op(仅 console.warn),
16
+ * 让组件在缺 Provider 时不崩溃。 */
17
+ declare function useAixNav(): AixNav;
18
+
19
+ export { type AixNav, AixNavProvider, type AixNavProviderProps, useAixNav };