-
-
Notifications
You must be signed in to change notification settings - Fork 256
Expand file tree
/
Copy pathsession-status.ts
More file actions
39 lines (34 loc) · 1.06 KB
/
session-status.ts
File metadata and controls
39 lines (34 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* Session Status Resource Plugin
*
* Provides read-only runtime session state for log capture and debugging.
*/
import { log } from '../../utils/logging/index.ts';
import { toErrorMessage } from '../../utils/errors.ts';
import { getSessionRuntimeStatusSnapshot } from '../../utils/session-status.ts';
export async function sessionStatusResourceLogic(): Promise<{ contents: Array<{ text: string }> }> {
try {
log('info', 'Processing session status resource request');
const status = await getSessionRuntimeStatusSnapshot();
return {
contents: [
{
text: JSON.stringify(status, null, 2),
},
],
};
} catch (error) {
const errorMessage = toErrorMessage(error);
log('error', `Error in session status resource handler: ${errorMessage}`);
return {
contents: [
{
text: `Error retrieving session status: ${errorMessage}`,
},
],
};
}
}
export async function handler(_uri: URL): Promise<{ contents: Array<{ text: string }> }> {
return sessionStatusResourceLogic();
}