@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.
- package/CHANGELOG.md +48 -0
- package/exec-client.d.mts.map +1 -1
- package/exec-client.d.ts.map +1 -1
- package/exec-client.js +1 -5
- package/exec-client.js.map +1 -1
- package/exec-client.mjs +2 -6
- package/exec-client.mjs.map +1 -1
- package/index.d.mts +2 -2
- package/index.d.mts.map +1 -1
- package/index.d.ts +2 -2
- package/index.d.ts.map +1 -1
- package/index.js +3 -2
- package/index.js.map +1 -1
- package/index.mjs +1 -1
- package/index.mjs.map +1 -1
- package/instance-client.d.mts +4 -3
- package/instance-client.d.mts.map +1 -1
- package/instance-client.d.ts +4 -3
- package/instance-client.d.ts.map +1 -1
- package/instance-client.js.map +1 -1
- package/instance-client.mjs.map +1 -1
- package/internal/persist-option.d.mts +4 -0
- package/internal/persist-option.d.mts.map +1 -1
- package/internal/persist-option.d.ts +4 -0
- package/internal/persist-option.d.ts.map +1 -1
- package/internal/persist-option.js +10 -3
- package/internal/persist-option.js.map +1 -1
- package/internal/persist-option.mjs +9 -3
- package/internal/persist-option.mjs.map +1 -1
- package/internal/session-stream.d.mts +31 -8
- package/internal/session-stream.d.mts.map +1 -1
- package/internal/session-stream.d.ts +31 -8
- package/internal/session-stream.d.ts.map +1 -1
- package/internal/session-stream.js +45 -10
- package/internal/session-stream.js.map +1 -1
- package/internal/session-stream.mjs +44 -10
- package/internal/session-stream.mjs.map +1 -1
- package/internal/sse-fetch.d.mts +5 -0
- package/internal/sse-fetch.d.mts.map +1 -1
- package/internal/sse-fetch.d.ts +5 -0
- package/internal/sse-fetch.d.ts.map +1 -1
- package/internal/sse-fetch.js +8 -0
- package/internal/sse-fetch.js.map +1 -1
- package/internal/sse-fetch.mjs +7 -0
- package/internal/sse-fetch.mjs.map +1 -1
- package/ios-client.d.mts +52 -4
- package/ios-client.d.mts.map +1 -1
- package/ios-client.d.ts +52 -4
- package/ios-client.d.ts.map +1 -1
- package/ios-client.js +37 -12
- package/ios-client.js.map +1 -1
- package/ios-client.mjs +37 -13
- package/ios-client.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/android-instances.d.mts +11 -4
- package/resources/android-instances.d.mts.map +1 -1
- package/resources/android-instances.d.ts +11 -4
- package/resources/android-instances.d.ts.map +1 -1
- package/resources/gradle-instances.d.mts +11 -4
- package/resources/gradle-instances.d.mts.map +1 -1
- package/resources/gradle-instances.d.ts +11 -4
- package/resources/gradle-instances.d.ts.map +1 -1
- package/resources/index.d.mts +1 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/ios-instances-helpers.d.mts +4 -0
- package/resources/ios-instances-helpers.d.mts.map +1 -1
- package/resources/ios-instances-helpers.d.ts +4 -0
- package/resources/ios-instances-helpers.d.ts.map +1 -1
- package/resources/ios-instances-helpers.js +6 -0
- package/resources/ios-instances-helpers.js.map +1 -1
- package/resources/ios-instances-helpers.mjs +6 -0
- package/resources/ios-instances-helpers.mjs.map +1 -1
- package/resources/ios-instances.d.mts +11 -4
- package/resources/ios-instances.d.mts.map +1 -1
- package/resources/ios-instances.d.ts +11 -4
- package/resources/ios-instances.d.ts.map +1 -1
- package/resources/session-artifacts.d.mts +46 -5
- package/resources/session-artifacts.d.mts.map +1 -1
- package/resources/session-artifacts.d.ts +46 -5
- package/resources/session-artifacts.d.ts.map +1 -1
- package/resources/session-artifacts.js +3 -3
- package/resources/session-artifacts.js.map +1 -1
- package/resources/session-artifacts.mjs +3 -3
- package/resources/session-artifacts.mjs.map +1 -1
- package/resources/xcode-instances.d.mts +11 -4
- package/resources/xcode-instances.d.mts.map +1 -1
- package/resources/xcode-instances.d.ts +11 -4
- package/resources/xcode-instances.d.ts.map +1 -1
- package/src/exec-client.ts +2 -8
- package/src/index.ts +3 -1
- package/src/instance-client.ts +4 -3
- package/src/internal/persist-option.ts +10 -5
- package/src/internal/session-stream.ts +60 -12
- package/src/internal/sse-fetch.ts +8 -0
- package/src/ios-client.ts +100 -21
- package/src/resources/android-instances.ts +12 -4
- package/src/resources/gradle-instances.ts +12 -4
- package/src/resources/index.ts +2 -0
- package/src/resources/ios-instances-helpers.ts +7 -0
- package/src/resources/ios-instances.ts +12 -4
- package/src/resources/session-artifacts.ts +63 -8
- package/src/resources/xcode-instances.ts +12 -4
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -1,19 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Long-lived tail of a runtime session SSE stream (live app logs
|
|
3
|
-
* coalesced event log). The runtime replays
|
|
4
|
-
* tags every entry with a monotonic SSE id;
|
|
5
|
-
* Last-Event-ID on reconnect, so the runtime resumes
|
|
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
|
-
/** The session stream
|
|
20
|
+
/** The session stream failed for good and has been closed. */
|
|
16
21
|
export declare class SessionStreamLostError extends Error {
|
|
22
|
+
name: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The session stream was refused with `status` and has been closed. A 404 means the instance is
|
|
26
|
+
* gone or terminating, or its runtime predates the stream.
|
|
27
|
+
*/
|
|
28
|
+
export declare class SessionStreamRejectedError extends SessionStreamLostError {
|
|
29
|
+
readonly status: number;
|
|
30
|
+
name: string;
|
|
31
|
+
constructor(message: string, status: number);
|
|
17
32
|
}
|
|
18
33
|
export interface SessionStreamOptions<T extends {
|
|
19
34
|
ts: number;
|
|
@@ -24,7 +39,15 @@ export interface SessionStreamOptions<T extends {
|
|
|
24
39
|
token: string;
|
|
25
40
|
/** Called once per delivered entry, in stream order. */
|
|
26
41
|
onEntry: (entry: T) => void;
|
|
27
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* Called after each connection's replay, the first and every reconnect, so later entries are
|
|
44
|
+
* live. Android and older iOS runtimes never call it.
|
|
45
|
+
*/
|
|
46
|
+
onReplayed?: (() => void) | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Called at most once, when the stream closes for good: at once on a refusal, or after the
|
|
49
|
+
* give-up window when it stays unreachable.
|
|
50
|
+
*/
|
|
28
51
|
onError?: ((error: Error) => void) | undefined;
|
|
29
52
|
}
|
|
30
53
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-stream.d.mts","sourceRoot":"","sources":["../src/internal/session-stream.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"session-stream.d.mts","sourceRoot":"","sources":["../src/internal/session-stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAQH,8DAA8D;AAC9D,qBAAa,sBAAuB,SAAQ,KAAK;IACtC,IAAI,SAA4B;CAC1C;AAED;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,sBAAsB;IAIlE,QAAQ,CAAC,MAAM,EAAE,MAAM;IAHhB,IAAI,SAAgC;gBAE3C,OAAO,EAAE,MAAM,EACN,MAAM,EAAE,MAAM;CAI1B;AAKD,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE;IAC5D,iEAAiE;IACjE,GAAG,EAAE,MAAM,CAAC;IACZ,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,wDAAwD;IACxD,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC5B;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;IACtC;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CAChD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAAE,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,CAmI3G"}
|
|
@@ -1,19 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Long-lived tail of a runtime session SSE stream (live app logs
|
|
3
|
-
* coalesced event log). The runtime replays
|
|
4
|
-
* tags every entry with a monotonic SSE id;
|
|
5
|
-
* Last-Event-ID on reconnect, so the runtime resumes
|
|
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
|
-
/** The session stream
|
|
20
|
+
/** The session stream failed for good and has been closed. */
|
|
16
21
|
export declare class SessionStreamLostError extends Error {
|
|
22
|
+
name: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The session stream was refused with `status` and has been closed. A 404 means the instance is
|
|
26
|
+
* gone or terminating, or its runtime predates the stream.
|
|
27
|
+
*/
|
|
28
|
+
export declare class SessionStreamRejectedError extends SessionStreamLostError {
|
|
29
|
+
readonly status: number;
|
|
30
|
+
name: string;
|
|
31
|
+
constructor(message: string, status: number);
|
|
17
32
|
}
|
|
18
33
|
export interface SessionStreamOptions<T extends {
|
|
19
34
|
ts: number;
|
|
@@ -24,7 +39,15 @@ export interface SessionStreamOptions<T extends {
|
|
|
24
39
|
token: string;
|
|
25
40
|
/** Called once per delivered entry, in stream order. */
|
|
26
41
|
onEntry: (entry: T) => void;
|
|
27
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* Called after each connection's replay, the first and every reconnect, so later entries are
|
|
44
|
+
* live. Android and older iOS runtimes never call it.
|
|
45
|
+
*/
|
|
46
|
+
onReplayed?: (() => void) | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* Called at most once, when the stream closes for good: at once on a refusal, or after the
|
|
49
|
+
* give-up window when it stays unreachable.
|
|
50
|
+
*/
|
|
28
51
|
onError?: ((error: Error) => void) | undefined;
|
|
29
52
|
}
|
|
30
53
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-stream.d.ts","sourceRoot":"","sources":["../src/internal/session-stream.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"session-stream.d.ts","sourceRoot":"","sources":["../src/internal/session-stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAQH,8DAA8D;AAC9D,qBAAa,sBAAuB,SAAQ,KAAK;IACtC,IAAI,SAA4B;CAC1C;AAED;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,sBAAsB;IAIlE,QAAQ,CAAC,MAAM,EAAE,MAAM;IAHhB,IAAI,SAAgC;gBAE3C,OAAO,EAAE,MAAM,EACN,MAAM,EAAE,MAAM;CAI1B;AAKD,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE;IAC5D,iEAAiE;IACjE,GAAG,EAAE,MAAM,CAAC;IACZ,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAC;IACd,wDAAwD;IACxD,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC5B;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;IACtC;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;CAChD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,SAAS;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAAE,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,CAmI3G"}
|
|
@@ -1,29 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Long-lived tail of a runtime session SSE stream (live app logs
|
|
4
|
-
* coalesced event log). The runtime replays
|
|
5
|
-
* tags every entry with a monotonic SSE id;
|
|
6
|
-
* Last-Event-ID on reconnect, so the runtime resumes
|
|
7
|
-
* stream broke and each entry is delivered exactly once
|
|
3
|
+
* Long-lived tail of a runtime session SSE stream (live app logs, the
|
|
4
|
+
* coalesced event log, or iOS app performance samples). The runtime replays
|
|
5
|
+
* its buffer on first connect and tags every entry with a monotonic SSE id;
|
|
6
|
+
* eventsource-client sends Last-Event-ID on reconnect, so the runtime resumes
|
|
7
|
+
* exactly where the stream broke and each entry is delivered exactly once,
|
|
8
|
+
* as long as the entries are still in the runtime's buffer.
|
|
8
9
|
*
|
|
9
10
|
* Stream health follows the exec client's model (and reuses its policy): the
|
|
10
11
|
* EventSource reconnects forever on its own, so a dead stream (deleted
|
|
11
12
|
* instance) would otherwise retry silently for good. Proof of life — a
|
|
12
13
|
* delivered entry, a keepalive comment, or a clean connection that stays
|
|
13
14
|
* open healthyConnectionMs — resets the give-up clock; once the stream stays
|
|
14
|
-
* broken past giveUpAfterMs, onError fires once and the stream closes.
|
|
15
|
+
* broken past giveUpAfterMs, onError fires once and the stream closes. Like
|
|
16
|
+
* the exec client, a client error other than 408 and 429, or a 204, closes it
|
|
17
|
+
* at once: the router answers 404 for a missing or terminating instance and
|
|
18
|
+
* 403 for a token that does not match, and a runtime answers 404 for a stream
|
|
19
|
+
* it does not serve.
|
|
15
20
|
*/
|
|
16
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.SessionStreamLostError = void 0;
|
|
22
|
+
exports.SessionStreamRejectedError = exports.SessionStreamLostError = void 0;
|
|
18
23
|
exports.streamSessionEntries = streamSessionEntries;
|
|
19
24
|
const eventsource_client_1 = require("eventsource-client");
|
|
20
25
|
const exec_client_1 = require("../exec-client.js");
|
|
21
26
|
const proxy_transport_1 = require("./proxy-transport.js");
|
|
22
27
|
const sse_fetch_1 = require("./sse-fetch.js");
|
|
23
|
-
/** The session stream
|
|
28
|
+
/** The session stream failed for good and has been closed. */
|
|
24
29
|
class SessionStreamLostError extends Error {
|
|
30
|
+
constructor() {
|
|
31
|
+
super(...arguments);
|
|
32
|
+
this.name = 'SessionStreamLostError';
|
|
33
|
+
}
|
|
25
34
|
}
|
|
26
35
|
exports.SessionStreamLostError = SessionStreamLostError;
|
|
36
|
+
/**
|
|
37
|
+
* The session stream was refused with `status` and has been closed. A 404 means the instance is
|
|
38
|
+
* gone or terminating, or its runtime predates the stream.
|
|
39
|
+
*/
|
|
40
|
+
class SessionStreamRejectedError extends SessionStreamLostError {
|
|
41
|
+
constructor(message, status) {
|
|
42
|
+
super(message);
|
|
43
|
+
this.status = status;
|
|
44
|
+
this.name = 'SessionStreamRejectedError';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.SessionStreamRejectedError = SessionStreamRejectedError;
|
|
48
|
+
/** The SSE event the iOS runtime sends after replaying its buffer. */
|
|
49
|
+
const REPLAYED_EVENT = 'replayed';
|
|
27
50
|
/**
|
|
28
51
|
* Connects to a session SSE endpoint and delivers parsed entries until the
|
|
29
52
|
* returned function is called (or the stream is given up on). Entries are
|
|
@@ -54,8 +77,13 @@ function streamSessionEntries(options) {
|
|
|
54
77
|
// transient refusal does not kill a live stream.
|
|
55
78
|
const fetchWithStreamPolicy = async (input, init) => {
|
|
56
79
|
const response = await proxy_transport_1.nodeProxyTransport.fetch(input, init);
|
|
57
|
-
|
|
58
|
-
|
|
80
|
+
const status = response.status;
|
|
81
|
+
if ((0, sse_fetch_1.refusesStream)(status)) {
|
|
82
|
+
const reason = status === 404 ? ': the instance no longer exists, or its runtime does not serve this stream' : '';
|
|
83
|
+
fail(new SessionStreamRejectedError(`session stream to ${options.url} answered HTTP ${status}${reason}`, status));
|
|
84
|
+
}
|
|
85
|
+
else if (!response.ok) {
|
|
86
|
+
lastStreamError = new Error(`server answered HTTP ${status}`);
|
|
59
87
|
}
|
|
60
88
|
cleanResponseThisCycle = response.ok;
|
|
61
89
|
return response;
|
|
@@ -117,9 +145,16 @@ function streamSessionEntries(options) {
|
|
|
117
145
|
}
|
|
118
146
|
},
|
|
119
147
|
onMessage: (message) => {
|
|
148
|
+
// A closed stream can still hand over the rest of the chunk it was parsing.
|
|
149
|
+
if (closed)
|
|
150
|
+
return;
|
|
120
151
|
deadSince = 0;
|
|
121
152
|
proofOfLifeThisCycle = true;
|
|
122
153
|
lastStreamError = undefined;
|
|
154
|
+
if (message.event === REPLAYED_EVENT) {
|
|
155
|
+
options.onReplayed?.();
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
123
158
|
const data = typeof message.data === 'string' ? message.data : String(message.data ?? '');
|
|
124
159
|
let parsed;
|
|
125
160
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-stream.js","sourceRoot":"","sources":["../src/internal/session-stream.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"session-stream.js","sourceRoot":"","sources":["../src/internal/session-stream.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;AAuDH,oDAmIC;AAxLD,2DAAgF;AAChF,mDAAiD;AACjD,0DAAuD;AACvD,8CAAsD;AAGtD,8DAA8D;AAC9D,MAAa,sBAAuB,SAAQ,KAAK;IAAjD;;QACW,SAAI,GAAG,wBAAwB,CAAC;IAC3C,CAAC;CAAA;AAFD,wDAEC;AAED;;;GAGG;AACH,MAAa,0BAA2B,SAAQ,sBAAsB;IAEpE,YACE,OAAe,EACN,MAAc;QAEvB,KAAK,CAAC,OAAO,CAAC,CAAC;QAFN,WAAM,GAAN,MAAM,CAAQ;QAHhB,SAAI,GAAG,4BAA4B,CAAC;IAM7C,CAAC;CACF;AARD,gEAQC;AAED,sEAAsE;AACtE,MAAM,c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CAAC;YAC5B,IAAI,OAAO,CAAC,KAAK,KAAK,cAAc,EAAE,CAAC;gBACrC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;gBACvB,OAAO;YACT,CAAC;YACD,MAAM,IAAI,GAAG,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;YAC1F,IAAI,MAAe,CAAC;YACpB,IAAI,CAAC;gBACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO;YACT,CAAC;YACD,IAAI,OAAQ,MAA2B,EAAE,EAAE,KAAK,QAAQ,EAAE,CAAC;gBACzD,OAAO;YACT,CAAC;YACD,OAAO,CAAC,OAAO,CAAC,MAAW,CAAC,CAAC;QAC/B,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,GAAG,EAAE;QACV,IAAI,MAAM;YAAE,OAAO;QACnB,MAAM,GAAG,IAAI,CAAC;QACd,WAAW,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,24 +1,46 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Long-lived tail of a runtime session SSE stream (live app logs
|
|
3
|
-
* coalesced event log). The runtime replays
|
|
4
|
-
* tags every entry with a monotonic SSE id;
|
|
5
|
-
* Last-Event-ID on reconnect, so the runtime resumes
|
|
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
|
import { createEventSource } from 'eventsource-client';
|
|
16
21
|
import { sseStreamPolicy } from "../exec-client.mjs";
|
|
17
22
|
import { nodeProxyTransport } from "./proxy-transport.mjs";
|
|
18
|
-
import { sseFetch } from "./sse-fetch.mjs";
|
|
19
|
-
/** The session stream
|
|
23
|
+
import { refusesStream, sseFetch } from "./sse-fetch.mjs";
|
|
24
|
+
/** The session stream failed for good and has been closed. */
|
|
20
25
|
export class SessionStreamLostError extends Error {
|
|
26
|
+
constructor() {
|
|
27
|
+
super(...arguments);
|
|
28
|
+
this.name = 'SessionStreamLostError';
|
|
29
|
+
}
|
|
21
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* The session stream was refused with `status` and has been closed. A 404 means the instance is
|
|
33
|
+
* gone or terminating, or its runtime predates the stream.
|
|
34
|
+
*/
|
|
35
|
+
export class SessionStreamRejectedError extends SessionStreamLostError {
|
|
36
|
+
constructor(message, status) {
|
|
37
|
+
super(message);
|
|
38
|
+
this.status = status;
|
|
39
|
+
this.name = 'SessionStreamRejectedError';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** The SSE event the iOS runtime sends after replaying its buffer. */
|
|
43
|
+
const REPLAYED_EVENT = 'replayed';
|
|
22
44
|
/**
|
|
23
45
|
* Connects to a session SSE endpoint and delivers parsed entries until the
|
|
24
46
|
* returned function is called (or the stream is given up on). Entries are
|
|
@@ -49,8 +71,13 @@ export function streamSessionEntries(options) {
|
|
|
49
71
|
// transient refusal does not kill a live stream.
|
|
50
72
|
const fetchWithStreamPolicy = async (input, init) => {
|
|
51
73
|
const response = await nodeProxyTransport.fetch(input, init);
|
|
52
|
-
|
|
53
|
-
|
|
74
|
+
const status = response.status;
|
|
75
|
+
if (refusesStream(status)) {
|
|
76
|
+
const reason = status === 404 ? ': the instance no longer exists, or its runtime does not serve this stream' : '';
|
|
77
|
+
fail(new SessionStreamRejectedError(`session stream to ${options.url} answered HTTP ${status}${reason}`, status));
|
|
78
|
+
}
|
|
79
|
+
else if (!response.ok) {
|
|
80
|
+
lastStreamError = new Error(`server answered HTTP ${status}`);
|
|
54
81
|
}
|
|
55
82
|
cleanResponseThisCycle = response.ok;
|
|
56
83
|
return response;
|
|
@@ -112,9 +139,16 @@ export function streamSessionEntries(options) {
|
|
|
112
139
|
}
|
|
113
140
|
},
|
|
114
141
|
onMessage: (message) => {
|
|
142
|
+
// A closed stream can still hand over the rest of the chunk it was parsing.
|
|
143
|
+
if (closed)
|
|
144
|
+
return;
|
|
115
145
|
deadSince = 0;
|
|
116
146
|
proofOfLifeThisCycle = true;
|
|
117
147
|
lastStreamError = undefined;
|
|
148
|
+
if (message.event === REPLAYED_EVENT) {
|
|
149
|
+
options.onReplayed?.();
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
118
152
|
const data = typeof message.data === 'string' ? message.data : String(message.data ?? '');
|
|
119
153
|
let parsed;
|
|
120
154
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-stream.mjs","sourceRoot":"","sources":["../src/internal/session-stream.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"session-stream.mjs","sourceRoot":"","sources":["../src/internal/session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E,OAAO;QACnB,MAAM,GAAG,IAAI,CAAC;QACd,WAAW,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC"}
|
package/internal/sse-fetch.d.mts
CHANGED
|
@@ -8,4 +8,9 @@ import type { Fetch } from "./builtin-types.mjs";
|
|
|
8
8
|
* this when touched next.
|
|
9
9
|
*/
|
|
10
10
|
export declare function sseFetch(fetchImpl: Fetch, onRejected: (err: unknown) => void): Fetch;
|
|
11
|
+
/**
|
|
12
|
+
* Whether an SSE response refuses the stream for good: a 204, which makes the EventSource close
|
|
13
|
+
* without reporting it, or a client error other than 408 and 429, which retrying cannot fix.
|
|
14
|
+
*/
|
|
15
|
+
export declare function refusesStream(status: number): boolean;
|
|
11
16
|
//# sourceMappingURL=sse-fetch.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse-fetch.d.mts","sourceRoot":"","sources":["../src/internal/sse-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,4BAAwB;AAE7C;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,GAAG,KAAK,CASpF"}
|
|
1
|
+
{"version":3,"file":"sse-fetch.d.mts","sourceRoot":"","sources":["../src/internal/sse-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,4BAAwB;AAE7C;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,GAAG,KAAK,CASpF;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAErD"}
|
package/internal/sse-fetch.d.ts
CHANGED
|
@@ -8,4 +8,9 @@ import type { Fetch } from "./builtin-types.js";
|
|
|
8
8
|
* this when touched next.
|
|
9
9
|
*/
|
|
10
10
|
export declare function sseFetch(fetchImpl: Fetch, onRejected: (err: unknown) => void): Fetch;
|
|
11
|
+
/**
|
|
12
|
+
* Whether an SSE response refuses the stream for good: a 204, which makes the EventSource close
|
|
13
|
+
* without reporting it, or a client error other than 408 and 429, which retrying cannot fix.
|
|
14
|
+
*/
|
|
15
|
+
export declare function refusesStream(status: number): boolean;
|
|
11
16
|
//# sourceMappingURL=sse-fetch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse-fetch.d.ts","sourceRoot":"","sources":["../src/internal/sse-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,2BAAwB;AAE7C;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,GAAG,KAAK,CASpF"}
|
|
1
|
+
{"version":3,"file":"sse-fetch.d.ts","sourceRoot":"","sources":["../src/internal/sse-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,2BAAwB;AAE7C;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,GAAG,KAAK,CASpF;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAErD"}
|
package/internal/sse-fetch.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sseFetch = sseFetch;
|
|
4
|
+
exports.refusesStream = refusesStream;
|
|
4
5
|
/**
|
|
5
6
|
* Wraps a fetch for use with eventsource-client, which swallows a REJECTED
|
|
6
7
|
* fetch (connection refused, instance gone) into a silent reconnect loop
|
|
@@ -20,4 +21,11 @@ function sseFetch(fetchImpl, onRejected) {
|
|
|
20
21
|
}
|
|
21
22
|
};
|
|
22
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Whether an SSE response refuses the stream for good: a 204, which makes the EventSource close
|
|
26
|
+
* without reporting it, or a client error other than 408 and 429, which retrying cannot fix.
|
|
27
|
+
*/
|
|
28
|
+
function refusesStream(status) {
|
|
29
|
+
return status === 204 || (status >= 400 && status < 500 && status !== 408 && status !== 429);
|
|
30
|
+
}
|
|
23
31
|
//# sourceMappingURL=sse-fetch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse-fetch.js","sourceRoot":"","sources":["../src/internal/sse-fetch.ts"],"names":[],"mappings":";;AAUA,4BASC;
|
|
1
|
+
{"version":3,"file":"sse-fetch.js","sourceRoot":"","sources":["../src/internal/sse-fetch.ts"],"names":[],"mappings":";;AAUA,4BASC;AAMD,sCAEC;AAzBD;;;;;;;GAOG;AACH,SAAgB,QAAQ,CAAC,SAAgB,EAAE,UAAkC;IAC3E,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAC3B,IAAI,CAAC;YACH,OAAO,MAAM,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACtC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,UAAU,CAAC,GAAG,CAAC,CAAC;YAChB,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,aAAa,CAAC,MAAc;IAC1C,OAAO,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,IAAI,GAAG,IAAI,MAAM,GAAG,GAAG,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,CAAC,CAAC;AAC/F,CAAC"}
|
package/internal/sse-fetch.mjs
CHANGED
|
@@ -17,4 +17,11 @@ export function sseFetch(fetchImpl, onRejected) {
|
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Whether an SSE response refuses the stream for good: a 204, which makes the EventSource close
|
|
22
|
+
* without reporting it, or a client error other than 408 and 429, which retrying cannot fix.
|
|
23
|
+
*/
|
|
24
|
+
export function refusesStream(status) {
|
|
25
|
+
return status === 204 || (status >= 400 && status < 500 && status !== 408 && status !== 429);
|
|
26
|
+
}
|
|
20
27
|
//# sourceMappingURL=sse-fetch.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse-fetch.mjs","sourceRoot":"","sources":["../src/internal/sse-fetch.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,SAAgB,EAAE,UAAkC;IAC3E,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAC3B,IAAI,CAAC;YACH,OAAO,MAAM,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACtC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,UAAU,CAAC,GAAG,CAAC,CAAC;YAChB,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"sse-fetch.mjs","sourceRoot":"","sources":["../src/internal/sse-fetch.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,SAAgB,EAAE,UAAkC;IAC3E,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAC3B,IAAI,CAAC;YACH,OAAO,MAAM,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACtC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,UAAU,CAAC,GAAG,CAAC,CAAC;YAChB,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,MAAc;IAC1C,OAAO,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,IAAI,GAAG,IAAI,MAAM,GAAG,GAAG,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,CAAC,CAAC;AAC/F,CAAC"}
|
package/ios-client.d.mts
CHANGED
|
@@ -5,7 +5,7 @@ import { type SyncFolderResult, type FolderSyncOptions } from "./folder-sync.mjs
|
|
|
5
5
|
import { type DestinationTunnelStatus } from "./internal/destination-tunnel-management.mjs";
|
|
6
6
|
import { type StartForwardHttpProxyOptions } from "./http-proxy.mjs";
|
|
7
7
|
import { type PersistOption } from "./internal/persist-option.mjs";
|
|
8
|
-
import type { SessionLogLine, SessionEvent } from "./resources/session-artifacts.mjs";
|
|
8
|
+
import type { SessionLogLine, SessionEvent, PerformanceSample } from "./resources/session-artifacts.mjs";
|
|
9
9
|
import { LogStream } from "./log-stream.mjs";
|
|
10
10
|
export { type PersistOption } from "./internal/persist-option.mjs";
|
|
11
11
|
export { LogStream, type LogStreamEvents } from "./log-stream.mjs";
|
|
@@ -919,9 +919,10 @@ export type InstanceClient = {
|
|
|
919
919
|
* delivers lines as they are captured; a dropped connection reconnects
|
|
920
920
|
* and resumes exactly where it left off, so every line is delivered once.
|
|
921
921
|
* The stream is independent of this client's websocket and survives
|
|
922
|
-
* {@link disconnect}; `onError` fires at most once
|
|
923
|
-
*
|
|
924
|
-
*
|
|
922
|
+
* {@link disconnect}; `onError` fires at most once and the stream is
|
|
923
|
+
* closed: at once with a `SessionStreamRejectedError` when the
|
|
924
|
+
* instance refuses it (404 once the instance is gone), or after it has
|
|
925
|
+
* kept failing for several minutes. Returns a function that closes it.
|
|
925
926
|
*/
|
|
926
927
|
streamAppLogCapture: (handlers: {
|
|
927
928
|
onLine: (line: SessionLogLine) => void;
|
|
@@ -935,6 +936,27 @@ export type InstanceClient = {
|
|
|
935
936
|
onEvent: (event: SessionEvent) => void;
|
|
936
937
|
onError?: (error: Error) => void;
|
|
937
938
|
}) => () => void;
|
|
939
|
+
/**
|
|
940
|
+
* Start saving the running apps' {@link PerformanceSample}s. The instance
|
|
941
|
+
* samples whether or not anything listens, so this capture always persists:
|
|
942
|
+
* it is uploaded to Limrun's bucket when it stops or the instance
|
|
943
|
+
* terminates, kept for `ttlSeconds` (server default 72h); list it with
|
|
944
|
+
* `iosInstances.listPerformanceCaptures`. One performance capture runs at a
|
|
945
|
+
* time; the server rejects a second start.
|
|
946
|
+
*/
|
|
947
|
+
startPerformanceCapture: (options?: {
|
|
948
|
+
ttlSeconds?: number;
|
|
949
|
+
}) => Promise<void>;
|
|
950
|
+
/** Stop the active performance capture and upload it. */
|
|
951
|
+
stopPerformanceCapture: () => Promise<void>;
|
|
952
|
+
/**
|
|
953
|
+
* Tail the running apps' {@link PerformanceSample}s; no capture is needed.
|
|
954
|
+
* On connect the instance replays its recent samples, so a late subscriber
|
|
955
|
+
* still sees history. Same reconnect and lifecycle semantics as
|
|
956
|
+
* {@link streamAppLogCapture}, except that a gap longer than the replay
|
|
957
|
+
* window loses the samples in between.
|
|
958
|
+
*/
|
|
959
|
+
streamPerformance: (handlers: PerformanceStreamHandlers) => () => void;
|
|
938
960
|
/**
|
|
939
961
|
* Play an audio file as the simulator's microphone input. Stage the file on
|
|
940
962
|
* the instance first with `pushFile` (no bundle ID); `path` is the same
|
|
@@ -1388,6 +1410,32 @@ export declare class SimctlExecution extends EventEmitter {
|
|
|
1388
1410
|
/** @internal - Handle errors from server or connection */
|
|
1389
1411
|
_handleError(error: Error): void;
|
|
1390
1412
|
}
|
|
1413
|
+
export type PerformanceStreamOptions = {
|
|
1414
|
+
/** The instance's status.apiUrl. */
|
|
1415
|
+
apiUrl: string;
|
|
1416
|
+
/** The instance token. */
|
|
1417
|
+
token: string;
|
|
1418
|
+
onSample: (sample: PerformanceSample) => void;
|
|
1419
|
+
/**
|
|
1420
|
+
* Called after each connection's replay of recent samples, the first and every reconnect, so
|
|
1421
|
+
* later samples are live. Runtimes that predate the signal never call it.
|
|
1422
|
+
*/
|
|
1423
|
+
onReplayed?: (() => void) | undefined;
|
|
1424
|
+
/**
|
|
1425
|
+
* Called at most once, when the stream closes for good: at once with a
|
|
1426
|
+
* SessionStreamRejectedError (status 404 when the instance is gone or its runtime
|
|
1427
|
+
* predates performance), or after the give-up window when it stays unreachable.
|
|
1428
|
+
*/
|
|
1429
|
+
onError?: ((error: Error) => void) | undefined;
|
|
1430
|
+
};
|
|
1431
|
+
/** What a performance stream reports to, without the instance's address. */
|
|
1432
|
+
export type PerformanceStreamHandlers = Omit<PerformanceStreamOptions, 'apiUrl' | 'token'>;
|
|
1433
|
+
/**
|
|
1434
|
+
* Tails the running apps' {@link PerformanceSample}s with only the instance's apiUrl and token,
|
|
1435
|
+
* without the WebSocket an {@link InstanceClient} opens. On connect the instance replays its
|
|
1436
|
+
* recent samples, then sends new ones; call the returned function to stop.
|
|
1437
|
+
*/
|
|
1438
|
+
export declare function streamPerformance(options: PerformanceStreamOptions): () => void;
|
|
1391
1439
|
/**
|
|
1392
1440
|
* Creates a client for interacting with a Limrun iOS instance
|
|
1393
1441
|
* @param options Configuration options including webrtcUrl, token and log level
|