@microtronics/studio-cli 1.2.0-alpha.4 → 1.2.0-alpha.7

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.
@@ -2083,6 +2083,22 @@ export declare interface DevBuildState {
2083
2083
  diagnostics?: Package.MergedDiagnostics;
2084
2084
  }
2085
2085
 
2086
+ /** `GET /dev/configs` payload — every config-class container, decoded and alias-or-name keyed. */
2087
+ declare interface DevConfigs {
2088
+ configs: Record<string, unknown>;
2089
+ /** Keys of {@link DevConfigs.configs}, in DDE declaration order. */
2090
+ order: string[];
2091
+ }
2092
+
2093
+ /** One entry of the `PUT /dev/configs` response — mirrors the single-container write outcome. */
2094
+ declare type DevConfigWriteResult = {
2095
+ ok: true;
2096
+ stale?: true;
2097
+ } | {
2098
+ ok: false;
2099
+ err: string;
2100
+ };
2101
+
2086
2102
  /**
2087
2103
  * Development installation information
2088
2104
  */
@@ -2126,7 +2142,7 @@ export declare const DeviceProfiles: any;
2126
2142
  * The pair of transports (UTO data + AT debug) needed to talk to a connected device,
2127
2143
  * plus a way to release the underlying link.
2128
2144
  */
2129
- declare interface DeviceTransports {
2145
+ export declare interface DeviceTransports {
2130
2146
  uto: ITransport;
2131
2147
  /** Absent when the caller asked for the UTO interface only (`needDebug: false`). */
2132
2148
  debug?: ITransport;
@@ -2145,11 +2161,12 @@ export declare interface DevLogRecord {
2145
2161
  raw?: string;
2146
2162
  }
2147
2163
 
2148
- /** Where a log record came from. */
2149
- export declare type DevLogSource = 'rm2mlog' | 'at' | 'uto' | 'pov';
2164
+ /** Where a log record came from. `state`/`console` are only used by `--replay` (`dev/replay/replaySession.ts`). */
2165
+ export declare type DevLogSource = 'rm2mlog' | 'at' | 'uto' | 'pov' | 'state' | 'console';
2150
2166
 
2151
2167
  export declare interface DevOptions {
2152
- serial: string;
2168
+ /** Required unless {@link DevOptions.replay} is given. */
2169
+ serial?: string;
2153
2170
  host?: string;
2154
2171
  port?: number;
2155
2172
  /** Allow a non-loopback `host` without a bearer token. */
@@ -2175,15 +2192,41 @@ export declare interface DevOptions {
2175
2192
  pov?: string | boolean;
2176
2193
  /** Persist the mirror to `.studio/dev/mirror.json` (default `true`). */
2177
2194
  persistMirror?: boolean;
2178
- /** Test/replay seams, forwarded to {@link DevSession}. */
2195
+ /** Test seam, forwarded to {@link DevSession}. */
2179
2196
  transportFactory?: TransportFactory;
2180
2197
  createDevice?: DevSessionOptions['createDevice'];
2198
+ /**
2199
+ * Support/forensics mode: replay a companion-app flight-recorder export instead of
2200
+ * opening USB (`cli/src/dev/replay/*`). Mutually exclusive with a live device — no
2201
+ * `build`/`flash`/poller/watch run, and `/api/**` answers empty/`E_EOD`.
2202
+ */
2203
+ replay?: string;
2204
+ /** Explicit recording session id; default = the session with the most records. */
2205
+ session?: string;
2206
+ /** Replay speed; `0`/`'max'` disables recorded delays. Default `1` (real-time). */
2207
+ speed?: number | 'max';
2208
+ }
2209
+
2210
+ /** Recording metadata reported by a `--replay` session (`dev/replay/replaySession.ts`). */
2211
+ declare interface DevReplayStatus {
2212
+ mode: 'replay';
2213
+ /** The cassette file this session was started from. */
2214
+ file: string;
2215
+ session: string;
2216
+ serial: string | null;
2217
+ deviceId: string | null;
2218
+ appVersion: string | null;
2219
+ platform: string | null;
2220
+ recordCount: number;
2221
+ startedTs: number;
2222
+ endedTs: number | null;
2223
+ speed: number | 'max';
2181
2224
  }
2182
2225
 
2183
2226
  export declare interface DevResult {
2184
2227
  url: string;
2185
2228
  port: number;
2186
- session: DevSession;
2229
+ session: DevServerSession;
2187
2230
  apmId: string;
2188
2231
  close(): Promise<void>;
2189
2232
  }
@@ -2194,6 +2237,38 @@ export declare interface DevServer {
2194
2237
  close(): Promise<void>;
2195
2238
  }
2196
2239
 
2240
+ /** The `/dev/logs` ring-buffer surface — shared by {@link DevServerSession} implementations. */
2241
+ declare interface DevServerLogStream {
2242
+ readonly lastSeq: number;
2243
+ since(since?: number, limit?: number): DevLogRecord[];
2244
+ }
2245
+
2246
+ /**
2247
+ * The subset of `DevSession` this server actually calls. A `--replay` session
2248
+ * (`dev/replay/replaySession.ts`'s `ReplayDevSession`) implements this directly instead of
2249
+ * a real `DevSession` — everything below is what `startDevServer` needs and nothing more.
2250
+ */
2251
+ export declare interface DevServerSession {
2252
+ readonly serial: string;
2253
+ readonly logStream: DevServerLogStream;
2254
+ on(event: string, listener: (...args: any[]) => void): this;
2255
+ off(event: string, listener: (...args: any[]) => void): this;
2256
+ handleApi(req: LocalApiRequest): Promise<LocalApiResponse>;
2257
+ status(): DevStatus;
2258
+ build(): Promise<DevBuildState>;
2259
+ flash(file?: string): Promise<UploadResult>;
2260
+ sync(tags?: number[]): Promise<{
2261
+ tags: number[];
2262
+ at: number;
2263
+ }>;
2264
+ at(cmd: string): Promise<string>;
2265
+ state(): Promise<unknown>;
2266
+ localDataSnapshot(): unknown;
2267
+ measure(): Promise<unknown>;
2268
+ configs(): Promise<DevConfigs>;
2269
+ applyConfigs(body: Record<string, unknown>): Promise<Record<string, DevConfigWriteResult>>;
2270
+ }
2271
+
2197
2272
  /**
2198
2273
  * One `studio dev` session: owns the USB link, the project's DDE model, the `IStorage`
2199
2274
  * mirror and the myDatanet-compatible API handler, and fans device activity out as events.
@@ -2294,6 +2369,22 @@ export declare class DevSession extends EventEmitter {
2294
2369
  /** Trigger a measurement and return its outcome plus the fresh values. */
2295
2370
  measure(): Promise<unknown>;
2296
2371
  status(): DevStatus;
2372
+ /** Config-class containers (`settings`/`config0..9`/`configA..C`) in DDE declaration order. */
2373
+ private configContainers;
2374
+ /**
2375
+ * `GET /dev/configs` — one entry per config-class container, decoded through
2376
+ * {@link handleApi} (the same path `GET /api/1/sites/<uid>/containers/<name>` uses). Keyed
2377
+ * by the container's alias when the DDE declares one, else its raw name.
2378
+ */
2379
+ configs(): Promise<DevConfigs>;
2380
+ /**
2381
+ * `PUT /dev/configs` — applies each entry as a partial write via {@link handleApi}, exactly
2382
+ * like `PUT /api/1/sites/<uid>/containers/<name>`. Accepts an alias or a raw container name
2383
+ * as key; a key that resolves to no container, or to a non-config-class one, fails that
2384
+ * entry alone with the same `{err}` wording the single-container route produces — the rest
2385
+ * of the entries still apply.
2386
+ */
2387
+ applyConfigs(body: Record<string, unknown>): Promise<Record<string, DevConfigWriteResult>>;
2297
2388
  /** Force one poll pass (used by the watcher and by `POST /dev/sync`). */
2298
2389
  tick(): Promise<ContainerChange[]>;
2299
2390
  /** The mirror's current stamp40 for a tag, or 0. */
@@ -2341,7 +2432,7 @@ export declare interface DevSessionOptions {
2341
2432
  lockWaitMs?: number;
2342
2433
  }
2343
2434
 
2344
- /** `GET /dev/status` payload. */
2435
+ /** `GET /dev/status` payload — `replay` is only present for a `--replay` session. */
2345
2436
  export declare interface DevStatus {
2346
2437
  serial: string;
2347
2438
  connected: boolean;
@@ -2358,6 +2449,7 @@ export declare interface DevStatus {
2358
2449
  lastSync: number | null;
2359
2450
  buildState: DevBuildState;
2360
2451
  poll: StampPollerStatus;
2452
+ replay?: DevReplayStatus;
2361
2453
  }
2362
2454
 
2363
2455
  export declare namespace DFILES {
@@ -5727,7 +5819,7 @@ export declare interface StampPollerStatus {
5727
5819
  * Opens the transports for a device given its serial number. The default (WebUSB) factory
5728
5820
  * is used by {@link openDevice} unless a test/consumer supplies its own.
5729
5821
  */
5730
- declare type TransportFactory = (serial: string, needDebug?: boolean) => Promise<DeviceTransports>;
5822
+ export declare type TransportFactory = (serial: string, needDebug?: boolean) => Promise<DeviceTransports>;
5731
5823
 
5732
5824
  /**
5733
5825
  * Upload result interface
@@ -5746,9 +5838,11 @@ declare interface UploadResult {
5746
5838
  * @param debugLog - Enable debug logging
5747
5839
  * @param retryMs - Total ms budget to retry a transient device-open failure (see
5748
5840
  * {@link isTransientUsbOpenError}); `0` (the default) attempts once.
5841
+ * @param transportFactory - Overrides how the transports are obtained (used by tests and by
5842
+ * consumers, e.g. the VS Code extension, running on their own injected transport).
5749
5843
  * @returns Promise resolving to an UploadResult
5750
5844
  */
5751
- declare function uploadToDevice(serialNumber: string, fileUri: URI, fs: LocalFS, logger: Log.Logger, debugLog?: boolean, retryMs?: number): Promise<UploadResult>;
5845
+ declare function uploadToDevice(serialNumber: string, fileUri: URI, fs: LocalFS, logger: Log.Logger, debugLog?: boolean, retryMs?: number, transportFactory?: TransportFactory): Promise<UploadResult>;
5752
5846
 
5753
5847
  declare function uriToMemFsPath(path: URI): string;
5754
5848
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microtronics/studio-cli",
3
- "version": "1.2.0-alpha.4",
3
+ "version": "1.2.0-alpha.7",
4
4
  "description": "Microtronics Studio CLI Tool",
5
5
  "main": "./out/api.js",
6
6
  "typings": "./out/studio-cli.d.ts",
@@ -44,6 +44,7 @@
44
44
  "openapi-fetch": "^0.13.0",
45
45
  "pako": "^2.1.0",
46
46
  "semver": "^7.7.2",
47
+ "sql.js": "^1.14.2",
47
48
  "tinytar-fix": "^0.1.1",
48
49
  "update-notifier": "^7.3.1",
49
50
  "usb": "^2.14.0",
@@ -63,6 +64,7 @@
63
64
  "@types/mocha": "^10.0.9",
64
65
  "@types/node": "^22.9.1",
65
66
  "@types/semver": "^7.5.6",
67
+ "@types/sql.js": "^1.4.11",
66
68
  "@types/update-notifier": "^6.0.8",
67
69
  "@types/vscode": "^1.86.2",
68
70
  "@yao-pkg/pkg": "^6.22.0",