@limrun/api 0.70.2 → 0.71.1

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.
Files changed (111) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/exec-client.d.mts.map +1 -1
  3. package/exec-client.d.ts.map +1 -1
  4. package/exec-client.js +1 -5
  5. package/exec-client.js.map +1 -1
  6. package/exec-client.mjs +2 -6
  7. package/exec-client.mjs.map +1 -1
  8. package/index.d.mts +2 -2
  9. package/index.d.mts.map +1 -1
  10. package/index.d.ts +2 -2
  11. package/index.d.ts.map +1 -1
  12. package/index.js +3 -2
  13. package/index.js.map +1 -1
  14. package/index.mjs +1 -1
  15. package/index.mjs.map +1 -1
  16. package/instance-client.d.mts +4 -3
  17. package/instance-client.d.mts.map +1 -1
  18. package/instance-client.d.ts +4 -3
  19. package/instance-client.d.ts.map +1 -1
  20. package/instance-client.js.map +1 -1
  21. package/instance-client.mjs.map +1 -1
  22. package/internal/persist-option.d.mts +4 -0
  23. package/internal/persist-option.d.mts.map +1 -1
  24. package/internal/persist-option.d.ts +4 -0
  25. package/internal/persist-option.d.ts.map +1 -1
  26. package/internal/persist-option.js +10 -3
  27. package/internal/persist-option.js.map +1 -1
  28. package/internal/persist-option.mjs +9 -3
  29. package/internal/persist-option.mjs.map +1 -1
  30. package/internal/session-stream.d.mts +31 -8
  31. package/internal/session-stream.d.mts.map +1 -1
  32. package/internal/session-stream.d.ts +31 -8
  33. package/internal/session-stream.d.ts.map +1 -1
  34. package/internal/session-stream.js +45 -10
  35. package/internal/session-stream.js.map +1 -1
  36. package/internal/session-stream.mjs +44 -10
  37. package/internal/session-stream.mjs.map +1 -1
  38. package/internal/sse-fetch.d.mts +5 -0
  39. package/internal/sse-fetch.d.mts.map +1 -1
  40. package/internal/sse-fetch.d.ts +5 -0
  41. package/internal/sse-fetch.d.ts.map +1 -1
  42. package/internal/sse-fetch.js +8 -0
  43. package/internal/sse-fetch.js.map +1 -1
  44. package/internal/sse-fetch.mjs +7 -0
  45. package/internal/sse-fetch.mjs.map +1 -1
  46. package/ios-client.d.mts +52 -4
  47. package/ios-client.d.mts.map +1 -1
  48. package/ios-client.d.ts +52 -4
  49. package/ios-client.d.ts.map +1 -1
  50. package/ios-client.js +37 -12
  51. package/ios-client.js.map +1 -1
  52. package/ios-client.mjs +37 -13
  53. package/ios-client.mjs.map +1 -1
  54. package/package.json +1 -1
  55. package/resources/android-instances.d.mts +11 -4
  56. package/resources/android-instances.d.mts.map +1 -1
  57. package/resources/android-instances.d.ts +11 -4
  58. package/resources/android-instances.d.ts.map +1 -1
  59. package/resources/gradle-instances.d.mts +11 -4
  60. package/resources/gradle-instances.d.mts.map +1 -1
  61. package/resources/gradle-instances.d.ts +11 -4
  62. package/resources/gradle-instances.d.ts.map +1 -1
  63. package/resources/index.d.mts +1 -1
  64. package/resources/index.d.mts.map +1 -1
  65. package/resources/index.d.ts +1 -1
  66. package/resources/index.d.ts.map +1 -1
  67. package/resources/index.js.map +1 -1
  68. package/resources/index.mjs.map +1 -1
  69. package/resources/ios-instances-helpers.d.mts +4 -0
  70. package/resources/ios-instances-helpers.d.mts.map +1 -1
  71. package/resources/ios-instances-helpers.d.ts +4 -0
  72. package/resources/ios-instances-helpers.d.ts.map +1 -1
  73. package/resources/ios-instances-helpers.js +6 -0
  74. package/resources/ios-instances-helpers.js.map +1 -1
  75. package/resources/ios-instances-helpers.mjs +6 -0
  76. package/resources/ios-instances-helpers.mjs.map +1 -1
  77. package/resources/ios-instances.d.mts +11 -4
  78. package/resources/ios-instances.d.mts.map +1 -1
  79. package/resources/ios-instances.d.ts +11 -4
  80. package/resources/ios-instances.d.ts.map +1 -1
  81. package/resources/session-artifacts.d.mts +46 -5
  82. package/resources/session-artifacts.d.mts.map +1 -1
  83. package/resources/session-artifacts.d.ts +46 -5
  84. package/resources/session-artifacts.d.ts.map +1 -1
  85. package/resources/session-artifacts.js +3 -3
  86. package/resources/session-artifacts.js.map +1 -1
  87. package/resources/session-artifacts.mjs +3 -3
  88. package/resources/session-artifacts.mjs.map +1 -1
  89. package/resources/xcode-instances.d.mts +11 -4
  90. package/resources/xcode-instances.d.mts.map +1 -1
  91. package/resources/xcode-instances.d.ts +11 -4
  92. package/resources/xcode-instances.d.ts.map +1 -1
  93. package/src/exec-client.ts +2 -8
  94. package/src/index.ts +3 -1
  95. package/src/instance-client.ts +4 -3
  96. package/src/internal/persist-option.ts +10 -5
  97. package/src/internal/session-stream.ts +60 -12
  98. package/src/internal/sse-fetch.ts +8 -0
  99. package/src/ios-client.ts +100 -21
  100. package/src/resources/android-instances.ts +12 -4
  101. package/src/resources/gradle-instances.ts +12 -4
  102. package/src/resources/index.ts +2 -0
  103. package/src/resources/ios-instances-helpers.ts +7 -0
  104. package/src/resources/ios-instances.ts +12 -4
  105. package/src/resources/session-artifacts.ts +63 -8
  106. package/src/resources/xcode-instances.ts +12 -4
  107. package/src/version.ts +1 -1
  108. package/version.d.mts +1 -1
  109. package/version.d.ts +1 -1
  110. package/version.js +1 -1
  111. package/version.mjs +1 -1
@@ -1,26 +1,50 @@
1
1
  /**
2
- * Long-lived tail of a runtime session SSE stream (live app logs or the
3
- * coalesced event log). The runtime replays its buffer on first connect and
4
- * tags every entry with a monotonic SSE id; eventsource-client sends
5
- * Last-Event-ID on reconnect, so the runtime resumes exactly where the
6
- * stream broke and each entry is delivered exactly once.
2
+ * Long-lived tail of a runtime session SSE stream (live app logs, the
3
+ * coalesced event log, or iOS app performance samples). The runtime replays
4
+ * its buffer on first connect and tags every entry with a monotonic SSE id;
5
+ * eventsource-client sends Last-Event-ID on reconnect, so the runtime resumes
6
+ * exactly where the stream broke and each entry is delivered exactly once,
7
+ * as long as the entries are still in the runtime's buffer.
7
8
  *
8
9
  * Stream health follows the exec client's model (and reuses its policy): the
9
10
  * EventSource reconnects forever on its own, so a dead stream (deleted
10
11
  * instance) would otherwise retry silently for good. Proof of life — a
11
12
  * delivered entry, a keepalive comment, or a clean connection that stays
12
13
  * open healthyConnectionMs — resets the give-up clock; once the stream stays
13
- * broken past giveUpAfterMs, onError fires once and the stream closes.
14
+ * broken past giveUpAfterMs, onError fires once and the stream closes. Like
15
+ * the exec client, a client error other than 408 and 429, or a 204, closes it
16
+ * at once: the router answers 404 for a missing or terminating instance and
17
+ * 403 for a token that does not match, and a runtime answers 404 for a stream
18
+ * it does not serve.
14
19
  */
15
20
 
16
21
  import { createEventSource, type EventSourceMessage } from 'eventsource-client';
17
22
  import { sseStreamPolicy } from '../exec-client';
18
23
  import { nodeProxyTransport } from './proxy-transport';
19
- import { sseFetch } from './sse-fetch';
24
+ import { refusesStream, sseFetch } from './sse-fetch';
20
25
  import type { Fetch } from './builtin-types';
21
26
 
22
- /** The session stream kept failing past the give-up window; it has been closed. */
23
- export class SessionStreamLostError extends Error {}
27
+ /** The session stream failed for good and has been closed. */
28
+ export class SessionStreamLostError extends Error {
29
+ override name = 'SessionStreamLostError';
30
+ }
31
+
32
+ /**
33
+ * The session stream was refused with `status` and has been closed. A 404 means the instance is
34
+ * gone or terminating, or its runtime predates the stream.
35
+ */
36
+ export class SessionStreamRejectedError extends SessionStreamLostError {
37
+ override name = 'SessionStreamRejectedError';
38
+ constructor(
39
+ message: string,
40
+ readonly status: number,
41
+ ) {
42
+ super(message);
43
+ }
44
+ }
45
+
46
+ /** The SSE event the iOS runtime sends after replaying its buffer. */
47
+ const REPLAYED_EVENT = 'replayed';
24
48
 
25
49
  export interface SessionStreamOptions<T extends { ts: number }> {
26
50
  /** Full URL of the runtime SSE endpoint, without credentials. */
@@ -29,7 +53,15 @@ export interface SessionStreamOptions<T extends { ts: number }> {
29
53
  token: string;
30
54
  /** Called once per delivered entry, in stream order. */
31
55
  onEntry: (entry: T) => void;
32
- /** Called at most once, when the stream is given up on and closed. */
56
+ /**
57
+ * Called after each connection's replay, the first and every reconnect, so later entries are
58
+ * live. Android and older iOS runtimes never call it.
59
+ */
60
+ onReplayed?: (() => void) | undefined;
61
+ /**
62
+ * Called at most once, when the stream closes for good: at once on a refusal, or after the
63
+ * give-up window when it stays unreachable.
64
+ */
33
65
  onError?: ((error: Error) => void) | undefined;
34
66
  }
35
67
 
@@ -64,8 +96,18 @@ export function streamSessionEntries<T extends { ts: number }>(options: SessionS
64
96
  // transient refusal does not kill a live stream.
65
97
  const fetchWithStreamPolicy: Fetch = async (input, init) => {
66
98
  const response = await nodeProxyTransport.fetch(input, init);
67
- if (!response.ok) {
68
- lastStreamError = new Error(`server answered HTTP ${response.status}`);
99
+ const status = response.status;
100
+ if (refusesStream(status)) {
101
+ const reason =
102
+ status === 404 ? ': the instance no longer exists, or its runtime does not serve this stream' : '';
103
+ fail(
104
+ new SessionStreamRejectedError(
105
+ `session stream to ${options.url} answered HTTP ${status}${reason}`,
106
+ status,
107
+ ),
108
+ );
109
+ } else if (!response.ok) {
110
+ lastStreamError = new Error(`server answered HTTP ${status}`);
69
111
  }
70
112
  cleanResponseThisCycle = response.ok;
71
113
  return response;
@@ -132,9 +174,15 @@ export function streamSessionEntries<T extends { ts: number }>(options: SessionS
132
174
  }
133
175
  },
134
176
  onMessage: (message: EventSourceMessage) => {
177
+ // A closed stream can still hand over the rest of the chunk it was parsing.
178
+ if (closed) return;
135
179
  deadSince = 0;
136
180
  proofOfLifeThisCycle = true;
137
181
  lastStreamError = undefined;
182
+ if (message.event === REPLAYED_EVENT) {
183
+ options.onReplayed?.();
184
+ return;
185
+ }
138
186
  const data = typeof message.data === 'string' ? message.data : String(message.data ?? '');
139
187
  let parsed: unknown;
140
188
  try {
@@ -18,3 +18,11 @@ export function sseFetch(fetchImpl: Fetch, onRejected: (err: unknown) => void):
18
18
  }
19
19
  };
20
20
  }
21
+
22
+ /**
23
+ * Whether an SSE response refuses the stream for good: a 204, which makes the EventSource close
24
+ * without reporting it, or a client error other than 408 and 429, which retrying cannot fix.
25
+ */
26
+ export function refusesStream(status: number): boolean {
27
+ return status === 204 || (status >= 400 && status < 500 && status !== 408 && status !== 429);
28
+ }
package/src/ios-client.ts CHANGED
@@ -31,9 +31,9 @@ import {
31
31
  type StartForwardHttpProxyOptions,
32
32
  } from './http-proxy';
33
33
  import { startXcrunShim as startClientXcrunShim } from './ios-shim';
34
- import { persistFields, type PersistOption } from './internal/persist-option';
34
+ import { persistFields, ttlFields, type PersistOption } from './internal/persist-option';
35
35
  import { streamSessionEntries } from './internal/session-stream';
36
- import type { SessionLogLine, SessionEvent } from './resources/session-artifacts';
36
+ import type { SessionLogLine, SessionEvent, PerformanceSample } from './resources/session-artifacts';
37
37
  import { LogStream } from './log-stream';
38
38
 
39
39
  export { type PersistOption } from './internal/persist-option';
@@ -1069,9 +1069,10 @@ export type InstanceClient = {
1069
1069
  * delivers lines as they are captured; a dropped connection reconnects
1070
1070
  * and resumes exactly where it left off, so every line is delivered once.
1071
1071
  * The stream is independent of this client's websocket and survives
1072
- * {@link disconnect}; `onError` fires at most once, after the stream has
1073
- * kept failing for several minutes (e.g. the instance was deleted), and
1074
- * the stream is closed. Returns a function that closes the stream.
1072
+ * {@link disconnect}; `onError` fires at most once and the stream is
1073
+ * closed: at once with a `SessionStreamRejectedError` when the
1074
+ * instance refuses it (404 once the instance is gone), or after it has
1075
+ * kept failing for several minutes. Returns a function that closes it.
1075
1076
  */
1076
1077
  streamAppLogCapture: (handlers: {
1077
1078
  onLine: (line: SessionLogLine) => void;
@@ -1087,6 +1088,28 @@ export type InstanceClient = {
1087
1088
  onError?: (error: Error) => void;
1088
1089
  }) => () => void;
1089
1090
 
1091
+ /**
1092
+ * Start saving the running apps' {@link PerformanceSample}s. The instance
1093
+ * samples whether or not anything listens, so this capture always persists:
1094
+ * it is uploaded to Limrun's bucket when it stops or the instance
1095
+ * terminates, kept for `ttlSeconds` (server default 72h); list it with
1096
+ * `iosInstances.listPerformanceCaptures`. One performance capture runs at a
1097
+ * time; the server rejects a second start.
1098
+ */
1099
+ startPerformanceCapture: (options?: { ttlSeconds?: number }) => Promise<void>;
1100
+
1101
+ /** Stop the active performance capture and upload it. */
1102
+ stopPerformanceCapture: () => Promise<void>;
1103
+
1104
+ /**
1105
+ * Tail the running apps' {@link PerformanceSample}s; no capture is needed.
1106
+ * On connect the instance replays its recent samples, so a late subscriber
1107
+ * still sees history. Same reconnect and lifecycle semantics as
1108
+ * {@link streamAppLogCapture}, except that a gap longer than the replay
1109
+ * window loses the samples in between.
1110
+ */
1111
+ streamPerformance: (handlers: PerformanceStreamHandlers) => () => void;
1112
+
1090
1113
  /**
1091
1114
  * Play an audio file as the simulator's microphone input. Stage the file on
1092
1115
  * the instance first with `pushFile` (no bundle ID); `path` is the same
@@ -1770,6 +1793,43 @@ export class SimctlExecution extends EventEmitter {
1770
1793
  }
1771
1794
  }
1772
1795
 
1796
+ export type PerformanceStreamOptions = {
1797
+ /** The instance's status.apiUrl. */
1798
+ apiUrl: string;
1799
+ /** The instance token. */
1800
+ token: string;
1801
+ onSample: (sample: PerformanceSample) => void;
1802
+ /**
1803
+ * Called after each connection's replay of recent samples, the first and every reconnect, so
1804
+ * later samples are live. Runtimes that predate the signal never call it.
1805
+ */
1806
+ onReplayed?: (() => void) | undefined;
1807
+ /**
1808
+ * Called at most once, when the stream closes for good: at once with a
1809
+ * SessionStreamRejectedError (status 404 when the instance is gone or its runtime
1810
+ * predates performance), or after the give-up window when it stays unreachable.
1811
+ */
1812
+ onError?: ((error: Error) => void) | undefined;
1813
+ };
1814
+
1815
+ /** What a performance stream reports to, without the instance's address. */
1816
+ export type PerformanceStreamHandlers = Omit<PerformanceStreamOptions, 'apiUrl' | 'token'>;
1817
+
1818
+ /**
1819
+ * Tails the running apps' {@link PerformanceSample}s with only the instance's apiUrl and token,
1820
+ * without the WebSocket an {@link InstanceClient} opens. On connect the instance replays its
1821
+ * recent samples, then sends new ones; call the returned function to stop.
1822
+ */
1823
+ export function streamPerformance(options: PerformanceStreamOptions): () => void {
1824
+ return streamSessionEntries<PerformanceSample>({
1825
+ url: `${options.apiUrl}/session/performance/events`,
1826
+ token: options.token,
1827
+ onEntry: options.onSample,
1828
+ onReplayed: options.onReplayed,
1829
+ onError: options.onError,
1830
+ });
1831
+ }
1832
+
1773
1833
  /**
1774
1834
  * Creates a client for interacting with a Limrun iOS instance
1775
1835
  * @param options Configuration options including webrtcUrl, token and log level
@@ -2139,6 +2199,8 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
2139
2199
  stopAppLogCaptureResult: () => undefined,
2140
2200
  startEventCaptureResult: () => undefined,
2141
2201
  stopEventCaptureResult: () => undefined,
2202
+ startPerformanceCaptureResult: () => undefined,
2203
+ stopPerformanceCaptureResult: () => undefined,
2142
2204
  cameraControlResult: () => undefined,
2143
2205
  playOnMicrophoneResult: (msg): IosPlayOnMicrophoneResult => ({
2144
2206
  duration: msg.duration ?? 0,
@@ -2349,6 +2411,9 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
2349
2411
  stopEventCapture,
2350
2412
  streamAppLogCapture,
2351
2413
  streamEventCapture,
2414
+ startPerformanceCapture,
2415
+ stopPerformanceCapture,
2416
+ streamPerformance: streamClientPerformance,
2352
2417
  playOnMicrophone,
2353
2418
  stopMicrophonePlayback,
2354
2419
  microphoneStatus,
@@ -2872,8 +2937,11 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
2872
2937
  });
2873
2938
  };
2874
2939
 
2940
+ // A stop answers once its persisted capture is uploaded, which grows with the capture's length.
2941
+ const captureStopTimeoutMs = 300_000;
2942
+
2875
2943
  const stopAppLogCapture = async (): Promise<void> => {
2876
- await sendRequest<void>('stopAppLogCapture');
2944
+ await sendRequest<void>('stopAppLogCapture', {}, undefined, captureStopTimeoutMs);
2877
2945
  };
2878
2946
 
2879
2947
  const startEventCapture = async (opts?: { persist?: PersistOption }): Promise<void> => {
@@ -2881,30 +2949,41 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
2881
2949
  };
2882
2950
 
2883
2951
  const stopEventCapture = async (): Promise<void> => {
2884
- await sendRequest<void>('stopEventCapture');
2952
+ await sendRequest<void>('stopEventCapture', {}, undefined, captureStopTimeoutMs);
2953
+ };
2954
+
2955
+ const startPerformanceCapture = async (opts?: { ttlSeconds?: number }): Promise<void> => {
2956
+ await sendRequest<void>('startPerformanceCapture', ttlFields(opts?.ttlSeconds));
2957
+ };
2958
+
2959
+ const stopPerformanceCapture = async (): Promise<void> => {
2960
+ await sendRequest<void>('stopPerformanceCapture', {}, undefined, captureStopTimeoutMs);
2885
2961
  };
2886
2962
 
2963
+ const tailSession = <T extends { ts: number }>(
2964
+ stream: 'applogs' | 'events',
2965
+ onEntry: (entry: T) => void,
2966
+ onError?: (error: Error) => void,
2967
+ ): (() => void) =>
2968
+ streamSessionEntries<T>({
2969
+ url: `${options.apiUrl}/session/${stream}/events`,
2970
+ token: options.token,
2971
+ onEntry,
2972
+ onError,
2973
+ });
2974
+
2887
2975
  const streamAppLogCapture = (handlers: {
2888
2976
  onLine: (line: SessionLogLine) => void;
2889
2977
  onError?: (error: Error) => void;
2890
- }): (() => void) =>
2891
- streamSessionEntries<SessionLogLine>({
2892
- url: `${options.apiUrl}/session/applogs/events`,
2893
- token: options.token,
2894
- onEntry: handlers.onLine,
2895
- onError: handlers.onError,
2896
- });
2978
+ }): (() => void) => tailSession('applogs', handlers.onLine, handlers.onError);
2897
2979
 
2898
2980
  const streamEventCapture = (handlers: {
2899
2981
  onEvent: (event: SessionEvent) => void;
2900
2982
  onError?: (error: Error) => void;
2901
- }): (() => void) =>
2902
- streamSessionEntries<SessionEvent>({
2903
- url: `${options.apiUrl}/session/events/events`,
2904
- token: options.token,
2905
- onEntry: handlers.onEvent,
2906
- onError: handlers.onError,
2907
- });
2983
+ }): (() => void) => tailSession('events', handlers.onEvent, handlers.onError);
2984
+
2985
+ const streamClientPerformance = (handlers: PerformanceStreamHandlers): (() => void) =>
2986
+ streamPerformance({ ...handlers, apiUrl: options.apiUrl, token: options.token });
2908
2987
 
2909
2988
  const stopRecording = async (saveTo: { presignedUrl?: string; localPath?: string }): Promise<string> => {
2910
2989
  await sendRequest<void>('stopVideoRecording', {
@@ -77,6 +77,12 @@ export namespace AndroidInstance {
77
77
  labels?: { [key: string]: string };
78
78
 
79
79
  terminatedAt?: string;
80
+
81
+ /**
82
+ * Billing cutoff for a deletion requested while the region is unavailable.
83
+ * Absent for normal regional deletions.
84
+ */
85
+ terminatingAt?: string;
80
86
  }
81
87
 
82
88
  export interface Spec {
@@ -120,7 +126,7 @@ export namespace AndroidInstance {
120
126
  */
121
127
  token?: string;
122
128
 
123
- state: 'unknown' | 'creating' | 'assigned' | 'ready' | 'terminated';
129
+ state: 'unknown' | 'creating' | 'assigned' | 'ready' | 'terminating' | 'terminated';
124
130
 
125
131
  adbWebSocketUrl?: string;
126
132
 
@@ -147,13 +153,15 @@ export namespace AndroidInstance {
147
153
  targetHttpPortUrlPrefix?: string;
148
154
 
149
155
  /**
150
- * Machine-readable reason the instance was terminated. Always present once state
151
- * is "terminated", never present before that. New values may be added over time,
152
- * so treat any unrecognized value as "Unknown". Known values:
156
+ * Machine-readable reason for instance termination. Present when state is
157
+ * "terminating" or "terminated". New values may be added over time, so treat any
158
+ * unrecognized value as "Unknown". Known values:
153
159
  *
154
160
  * - "UserRequested": terminated by a delete request to the API.
155
161
  * - "InactivityTimeout": the timeout given in spec.inactivityTimeout elapsed.
156
162
  * - "HardTimeout": the timeout given in spec.hardTimeout elapsed.
163
+ * - "CapacityTimeout": no instance was free when it was created, and none freed
164
+ * up before its wait for capacity ended.
157
165
  * - "Unknown": terminated for a cause the platform did not attribute, including
158
166
  * instances that failed to get ready during creation. See errorMessage for
159
167
  * details when available.
@@ -78,6 +78,12 @@ export namespace GradleInstance {
78
78
  labels?: { [key: string]: string };
79
79
 
80
80
  terminatedAt?: string;
81
+
82
+ /**
83
+ * Billing cutoff for a deletion requested while the region is unavailable.
84
+ * Absent for normal regional deletions.
85
+ */
86
+ terminatingAt?: string;
81
87
  }
82
88
 
83
89
  export interface Spec {
@@ -102,20 +108,22 @@ export namespace GradleInstance {
102
108
  */
103
109
  token?: string;
104
110
 
105
- state: 'unknown' | 'creating' | 'assigned' | 'ready' | 'terminated';
111
+ state: 'unknown' | 'creating' | 'assigned' | 'ready' | 'terminating' | 'terminated';
106
112
 
107
113
  apiUrl?: string;
108
114
 
109
115
  errorMessage?: string;
110
116
 
111
117
  /**
112
- * Machine-readable reason the instance was terminated. Always present once state
113
- * is "terminated", never present before that. New values may be added over time,
114
- * so treat any unrecognized value as "Unknown". Known values:
118
+ * Machine-readable reason for instance termination. Present when state is
119
+ * "terminating" or "terminated". New values may be added over time, so treat any
120
+ * unrecognized value as "Unknown". Known values:
115
121
  *
116
122
  * - "UserRequested": terminated by a delete request to the API.
117
123
  * - "InactivityTimeout": the timeout given in spec.inactivityTimeout elapsed.
118
124
  * - "HardTimeout": the timeout given in spec.hardTimeout elapsed.
125
+ * - "CapacityTimeout": no instance was free when it was created, and none freed
126
+ * up before its wait for capacity ended.
119
127
  * - "Unknown": terminated for a cause the platform did not attribute, including
120
128
  * instances that failed to get ready during creation. See errorMessage for
121
129
  * details when available.
@@ -66,6 +66,8 @@ export {
66
66
  type SessionLogLine,
67
67
  type SessionEvent,
68
68
  type SessionEventType,
69
+ type PerformanceSample,
70
+ type PerformanceThread,
69
71
  } from './session-artifacts';
70
72
  export {
71
73
  XcodeInstances,
@@ -42,4 +42,11 @@ export class IosInstances extends GeneratedIosInstances {
42
42
  listEvents(id: string, options?: RequestOptions): APIPromise<SessionArtifact[]> {
43
43
  return this.listSessionArtifacts(id, 'eventLog', options);
44
44
  }
45
+
46
+ /**
47
+ * List the instance's persisted performance captures.
48
+ */
49
+ listPerformanceCaptures(id: string, options?: RequestOptions): APIPromise<SessionArtifact[]> {
50
+ return this.listSessionArtifacts(id, 'performance', options);
51
+ }
45
52
  }
@@ -77,6 +77,12 @@ export namespace IosInstance {
77
77
  labels?: { [key: string]: string };
78
78
 
79
79
  terminatedAt?: string;
80
+
81
+ /**
82
+ * Billing cutoff for a deletion requested while the region is unavailable.
83
+ * Absent for normal regional deletions.
84
+ */
85
+ terminatingAt?: string;
80
86
  }
81
87
 
82
88
  export interface Spec {
@@ -120,7 +126,7 @@ export namespace IosInstance {
120
126
  */
121
127
  token?: string;
122
128
 
123
- state: 'unknown' | 'creating' | 'assigned' | 'ready' | 'terminated';
129
+ state: 'unknown' | 'creating' | 'assigned' | 'ready' | 'terminating' | 'terminated';
124
130
 
125
131
  apiUrl?: string;
126
132
 
@@ -143,13 +149,15 @@ export namespace IosInstance {
143
149
  targetHttpPortUrlPrefix?: string;
144
150
 
145
151
  /**
146
- * Machine-readable reason the instance was terminated. Always present once state
147
- * is "terminated", never present before that. New values may be added over time,
148
- * so treat any unrecognized value as "Unknown". Known values:
152
+ * Machine-readable reason for instance termination. Present when state is
153
+ * "terminating" or "terminated". New values may be added over time, so treat any
154
+ * unrecognized value as "Unknown". Known values:
149
155
  *
150
156
  * - "UserRequested": terminated by a delete request to the API.
151
157
  * - "InactivityTimeout": the timeout given in spec.inactivityTimeout elapsed.
152
158
  * - "HardTimeout": the timeout given in spec.hardTimeout elapsed.
159
+ * - "CapacityTimeout": no instance was free when it was created, and none freed
160
+ * up before its wait for capacity ended.
153
161
  * - "Unknown": terminated for a cause the platform did not attribute, including
154
162
  * instances that failed to get ready during creation. See errorMessage for
155
163
  * details when available.
@@ -1,17 +1,18 @@
1
1
  // Hand-written: the session-artifact list endpoint is not in the generated
2
2
  // OpenAPI surface yet. Shared by the iOS and Android instance helpers.
3
- // SessionLogLine and SessionEvent mirror pkg/artifacts/contract.go in the
4
- // limrun repo; the runtimes emit the same JSON over live SSE and into the
5
- // persisted JSONL artifacts.
3
+ // SessionLogLine, SessionEvent and PerformanceSample mirror
4
+ // pkg/artifacts/contract.go in the limrun repo; the runtimes emit the same JSON
5
+ // over live SSE and into the persisted JSONL artifacts.
6
6
 
7
7
  /** The kind of a persisted session capture. */
8
- export type SessionArtifactKind = 'recording' | 'appLog' | 'eventLog' | 'networkLog';
8
+ export type SessionArtifactKind = 'recording' | 'appLog' | 'eventLog' | 'networkLog' | 'performance';
9
9
 
10
10
  /**
11
11
  * One persisted session capture of an instance: a video recording, an app log
12
- * capture, a coalesced event log, or a HAR network log. Returned by the
13
- * director's GET /v1/{ios,android}_instances/{id}/session_artifacts endpoint,
14
- * optionally narrowed with its kind query parameter.
12
+ * capture, a coalesced event log, a HAR network log, or iOS app performance
13
+ * samples. Returned by the director's
14
+ * GET /v1/{ios,android}_instances/{id}/session_artifacts endpoint, optionally
15
+ * narrowed with its kind query parameter.
15
16
  */
16
17
  export interface SessionArtifact {
17
18
  id: string;
@@ -38,7 +39,8 @@ export interface SessionArtifact {
38
39
 
39
40
  /**
40
41
  * Short-lived presigned GET URL for the raw artifact: MP4 for recordings,
41
- * JSONL for app logs and event logs, HAR for network logs.
42
+ * JSONL for app logs, event logs and performance samples, HAR for network
43
+ * logs.
42
44
  */
43
45
  downloadUrl: string;
44
46
  }
@@ -93,3 +95,56 @@ export interface SessionEvent {
93
95
  */
94
96
  summary?: string;
95
97
  }
98
+
99
+ /** One thread's share of an app's CPU in a {@link PerformanceSample}. */
100
+ export interface PerformanceThread {
101
+ /** The thread's name, `main` for the main thread, or empty. */
102
+ name: string;
103
+
104
+ /** Share of one core; 100 is one fully busy core. */
105
+ cpuPercent: number;
106
+ }
107
+
108
+ /**
109
+ * One running app's resource use at one moment, the figures Xcode's debug
110
+ * gauges show. iOS instances sample every running app they installed once a
111
+ * second, delivered live by `streamPerformance` and stored one-per-line in
112
+ * `performance` artifacts. Rates cover the second since the previous sample of
113
+ * the same process, so a process's first sample has none.
114
+ */
115
+ export interface PerformanceSample {
116
+ /** Epoch milliseconds, same clock as SessionLogLine. */
117
+ ts: number;
118
+
119
+ bundleId: string;
120
+
121
+ /** Changes when the app relaunches. */
122
+ pid: number;
123
+
124
+ /** The process start in epoch milliseconds. */
125
+ startedAt: number;
126
+
127
+ /** Set for XCTest runners such as WebDriverAgent. */
128
+ testRunner?: boolean;
129
+
130
+ /** One fully busy core is 100, so a multithreaded app can exceed it. */
131
+ cpuPercent?: number;
132
+
133
+ /** Physical footprint, the figure Xcode's memory gauge and iOS's memory limit use. */
134
+ footprintBytes: number;
135
+
136
+ /** The highest footprint over the process lifetime. */
137
+ peakFootprintBytes: number;
138
+
139
+ threadCount: number;
140
+
141
+ diskReadBytesPerSecond?: number;
142
+
143
+ diskWriteBytesPerSecond?: number;
144
+
145
+ /**
146
+ * Up to five threads using at least 0.1% of a core, busiest first. They add
147
+ * up to roughly, not exactly, the app's `cpuPercent`.
148
+ */
149
+ topThreads?: PerformanceThread[];
150
+ }
@@ -77,6 +77,12 @@ export namespace XcodeInstance {
77
77
  labels?: { [key: string]: string };
78
78
 
79
79
  terminatedAt?: string;
80
+
81
+ /**
82
+ * Billing cutoff for a deletion requested while the region is unavailable.
83
+ * Absent for normal regional deletions.
84
+ */
85
+ terminatingAt?: string;
80
86
  }
81
87
 
82
88
  export interface Spec {
@@ -101,20 +107,22 @@ export namespace XcodeInstance {
101
107
  */
102
108
  token?: string;
103
109
 
104
- state: 'unknown' | 'creating' | 'assigned' | 'ready' | 'terminated';
110
+ state: 'unknown' | 'creating' | 'assigned' | 'ready' | 'terminating' | 'terminated';
105
111
 
106
112
  apiUrl?: string;
107
113
 
108
114
  errorMessage?: string;
109
115
 
110
116
  /**
111
- * Machine-readable reason the instance was terminated. Always present once state
112
- * is "terminated", never present before that. New values may be added over time,
113
- * so treat any unrecognized value as "Unknown". Known values:
117
+ * Machine-readable reason for instance termination. Present when state is
118
+ * "terminating" or "terminated". New values may be added over time, so treat any
119
+ * unrecognized value as "Unknown". Known values:
114
120
  *
115
121
  * - "UserRequested": terminated by a delete request to the API.
116
122
  * - "InactivityTimeout": the timeout given in spec.inactivityTimeout elapsed.
117
123
  * - "HardTimeout": the timeout given in spec.hardTimeout elapsed.
124
+ * - "CapacityTimeout": no instance was free when it was created, and none freed
125
+ * up before its wait for capacity ended.
118
126
  * - "Unknown": terminated for a cause the platform did not attribute, including
119
127
  * instances that failed to get ready during creation. See errorMessage for
120
128
  * details when available.
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.70.2'; // x-release-please-version
1
+ export const VERSION = '0.71.1'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.70.2";
1
+ export declare const VERSION = "0.71.1";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.70.2";
1
+ export declare const VERSION = "0.71.1";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.70.2'; // x-release-please-version
4
+ exports.VERSION = '0.71.1'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.70.2'; // x-release-please-version
1
+ export const VERSION = '0.71.1'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map