@qiaolei81/copilot-session-viewer 0.3.3 → 0.3.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.
- package/package.json +25 -2
- package/.nycrc +0 -29
- package/AGENTS.md +0 -109
- package/CHANGELOG.md +0 -313
- package/CONTRIBUTING.md +0 -104
- package/RELEASE.md +0 -146
- package/docs/API.md +0 -471
- package/docs/DEVELOPMENT.md +0 -556
- package/docs/INSTALLATION.md +0 -329
- package/docs/README.md +0 -102
- package/docs/TROUBLESHOOTING.md +0 -630
- package/docs/images/homepage.png +0 -0
- package/docs/images/session-detail.png +0 -0
- package/docs/images/time-analysis.png +0 -0
- package/docs/unified-event-format-design.md +0 -844
- package/docs/unified-event-format-implementation.md +0 -350
- package/eslint.config.mjs +0 -133
- package/examples/parser-usage.js +0 -114
- package/scripts/release.sh +0 -43
package/RELEASE.md
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
# Release Process
|
|
2
|
-
|
|
3
|
-
## Automatic Version Bumping
|
|
4
|
-
|
|
5
|
-
### Using npm scripts (recommended)
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
# Patch release (0.1.0 → 0.1.1) - bug fixes
|
|
9
|
-
npm run release:patch
|
|
10
|
-
|
|
11
|
-
# Minor release (0.1.0 → 0.2.0) - new features
|
|
12
|
-
npm run release:minor
|
|
13
|
-
|
|
14
|
-
# Major release (0.1.0 → 1.0.0) - breaking changes
|
|
15
|
-
npm run release:major
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
**What happens:**
|
|
19
|
-
1. ✅ Updates `package.json` version
|
|
20
|
-
2. ✅ Creates git commit (`chore: release vX.Y.Z`)
|
|
21
|
-
3. ✅ Creates git tag (`vX.Y.Z`)
|
|
22
|
-
4. ✅ Pushes to GitHub
|
|
23
|
-
5. ✅ Creates GitHub release with auto-generated notes
|
|
24
|
-
6. ✅ Triggers npm publish workflow
|
|
25
|
-
|
|
26
|
-
---
|
|
27
|
-
|
|
28
|
-
### Manual npm version command
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
# Bump version
|
|
32
|
-
npm version patch -m "chore: release v%s"
|
|
33
|
-
|
|
34
|
-
# Push tag and code
|
|
35
|
-
git push --follow-tags
|
|
36
|
-
|
|
37
|
-
# Create GitHub release
|
|
38
|
-
gh release create v0.1.1 --title "v0.1.1" --generate-notes
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
## Semantic Versioning
|
|
44
|
-
|
|
45
|
-
Follow [SemVer](https://semver.org/):
|
|
46
|
-
|
|
47
|
-
- **Patch** (0.1.x) - Bug fixes, documentation, minor improvements
|
|
48
|
-
- **Minor** (0.x.0) - New features, backward-compatible changes
|
|
49
|
-
- **Major** (x.0.0) - Breaking changes, API changes
|
|
50
|
-
|
|
51
|
-
---
|
|
52
|
-
|
|
53
|
-
## Pre-Release Checklist
|
|
54
|
-
|
|
55
|
-
Before running `npm run release:*`, ensure:
|
|
56
|
-
|
|
57
|
-
- [ ] All tests pass (`npm run test:all`)
|
|
58
|
-
- [ ] Lint passes (`npm run lint:check`)
|
|
59
|
-
- [ ] `CHANGELOG.md` is updated
|
|
60
|
-
- [ ] Working directory is clean (`git status`)
|
|
61
|
-
- [ ] You're on `main` branch
|
|
62
|
-
- [ ] Branch is up to date with remote
|
|
63
|
-
|
|
64
|
-
---
|
|
65
|
-
|
|
66
|
-
## Release Workflow
|
|
67
|
-
|
|
68
|
-
```mermaid
|
|
69
|
-
graph LR
|
|
70
|
-
A[npm run release:patch] --> B[Update package.json]
|
|
71
|
-
B --> C[Git commit + tag]
|
|
72
|
-
C --> D[Push to GitHub]
|
|
73
|
-
D --> E[Create GitHub Release]
|
|
74
|
-
E --> F[Trigger npm-publish.yml]
|
|
75
|
-
F --> G[Publish to npm]
|
|
76
|
-
F --> H[Upload .tgz to release]
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
---
|
|
80
|
-
|
|
81
|
-
## Troubleshooting
|
|
82
|
-
|
|
83
|
-
### "Working directory is not clean"
|
|
84
|
-
```bash
|
|
85
|
-
# Check what's uncommitted
|
|
86
|
-
git status
|
|
87
|
-
|
|
88
|
-
# Commit or stash changes
|
|
89
|
-
git add .
|
|
90
|
-
git commit -m "chore: prepare for release"
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
### "Tag already exists"
|
|
94
|
-
```bash
|
|
95
|
-
# Delete local tag
|
|
96
|
-
git tag -d v0.1.0
|
|
97
|
-
|
|
98
|
-
# Delete remote tag
|
|
99
|
-
git push origin :refs/tags/v0.1.0
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### "gh command not found"
|
|
103
|
-
```bash
|
|
104
|
-
# Install GitHub CLI
|
|
105
|
-
brew install gh
|
|
106
|
-
|
|
107
|
-
# Authenticate
|
|
108
|
-
gh auth login
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
---
|
|
112
|
-
|
|
113
|
-
## Examples
|
|
114
|
-
|
|
115
|
-
### Patch release (bug fix)
|
|
116
|
-
|
|
117
|
-
```bash
|
|
118
|
-
# Fix bug
|
|
119
|
-
git commit -m "fix: resolve session parsing error"
|
|
120
|
-
|
|
121
|
-
# Release
|
|
122
|
-
npm run release:patch
|
|
123
|
-
# → v0.1.0 → v0.1.1
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
### Minor release (new feature)
|
|
127
|
-
|
|
128
|
-
```bash
|
|
129
|
-
# Add feature
|
|
130
|
-
git commit -m "feat: add dark mode toggle"
|
|
131
|
-
|
|
132
|
-
# Release
|
|
133
|
-
npm run release:minor
|
|
134
|
-
# → v0.1.0 → v0.2.0
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
### Major release (breaking change)
|
|
138
|
-
|
|
139
|
-
```bash
|
|
140
|
-
# Breaking change
|
|
141
|
-
git commit -m "feat!: redesign API endpoints"
|
|
142
|
-
|
|
143
|
-
# Release
|
|
144
|
-
npm run release:major
|
|
145
|
-
# → v0.1.0 → v1.0.0
|
|
146
|
-
```
|
package/docs/API.md
DELETED
|
@@ -1,471 +0,0 @@
|
|
|
1
|
-
# 🔌 API Documentation
|
|
2
|
-
|
|
3
|
-
REST API endpoints for Copilot Session Viewer.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Base URL
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
http://localhost:3838
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
## Authentication
|
|
16
|
-
|
|
17
|
-
**None required** - This is a local development tool with no authentication.
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## Endpoints
|
|
22
|
-
|
|
23
|
-
### Sessions
|
|
24
|
-
|
|
25
|
-
#### List Sessions
|
|
26
|
-
|
|
27
|
-
Get all sessions with optional pagination.
|
|
28
|
-
|
|
29
|
-
```http
|
|
30
|
-
GET /api/sessions
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
**Query Parameters:**
|
|
34
|
-
- `page` (number, optional) - Page number for pagination
|
|
35
|
-
- `limit` (number, optional) - Items per page
|
|
36
|
-
|
|
37
|
-
**Response:**
|
|
38
|
-
```json
|
|
39
|
-
[
|
|
40
|
-
{
|
|
41
|
-
"id": "f9db650c-1f87-491f-8e4f-52d45538d677",
|
|
42
|
-
"summary": "Analyze this codebase structure",
|
|
43
|
-
"createdAt": "2026-02-15T02:30:00.000Z",
|
|
44
|
-
"duration": 17936000,
|
|
45
|
-
"eventCount": 1044,
|
|
46
|
-
"type": "directory",
|
|
47
|
-
"workspace": {
|
|
48
|
-
"cwd": "/Users/dev/my-project"
|
|
49
|
-
},
|
|
50
|
-
"selectedModel": "claude-sonnet-4.5",
|
|
51
|
-
"copilotVersion": "0.0.410",
|
|
52
|
-
"isImported": false,
|
|
53
|
-
"hasInsight": true
|
|
54
|
-
}
|
|
55
|
-
]
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
**Example:**
|
|
59
|
-
```bash
|
|
60
|
-
curl http://localhost:3838/api/sessions
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
---
|
|
64
|
-
|
|
65
|
-
#### Load More Sessions
|
|
66
|
-
|
|
67
|
-
Get additional sessions with offset-based pagination (for infinite scroll).
|
|
68
|
-
|
|
69
|
-
```http
|
|
70
|
-
GET /api/sessions/load-more
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
**Query Parameters:**
|
|
74
|
-
- `offset` (number, required) - Number of sessions to skip
|
|
75
|
-
- `limit` (number, optional, default: 20) - Number of sessions to return
|
|
76
|
-
|
|
77
|
-
**Response:**
|
|
78
|
-
```json
|
|
79
|
-
{
|
|
80
|
-
"sessions": [
|
|
81
|
-
{
|
|
82
|
-
"id": "session-id",
|
|
83
|
-
"summary": "Session summary",
|
|
84
|
-
// ... same structure as /api/sessions
|
|
85
|
-
}
|
|
86
|
-
],
|
|
87
|
-
"hasMore": true,
|
|
88
|
-
"totalSessions": 237
|
|
89
|
-
}
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
**Example:**
|
|
93
|
-
```bash
|
|
94
|
-
curl "http://localhost:3838/api/sessions/load-more?offset=20&limit=20"
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
---
|
|
98
|
-
|
|
99
|
-
#### Get Session Events
|
|
100
|
-
|
|
101
|
-
Retrieve all events for a specific session.
|
|
102
|
-
|
|
103
|
-
```http
|
|
104
|
-
GET /api/sessions/:sessionId/events
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
**Path Parameters:**
|
|
108
|
-
- `sessionId` (string, required) - UUID of the session
|
|
109
|
-
|
|
110
|
-
**Response:** JSONL stream (one JSON object per line)
|
|
111
|
-
```
|
|
112
|
-
{"type":"session.start","timestamp":"2026-02-15T02:30:00.000Z","sessionId":"f9db650c..."}
|
|
113
|
-
{"type":"user.message","timestamp":"2026-02-15T02:30:01.000Z","message":"Analyze this code","turnId":0}
|
|
114
|
-
{"type":"assistant.message","timestamp":"2026-02-15T02:30:05.000Z","message":"I'll help you analyze...","turnId":0}
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
**Example:**
|
|
118
|
-
```bash
|
|
119
|
-
curl http://localhost:3838/api/sessions/f9db650c-1f87-491f-8e4f-52d45538d677/events
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
---
|
|
123
|
-
|
|
124
|
-
### Session Management
|
|
125
|
-
|
|
126
|
-
#### Get Session Details
|
|
127
|
-
|
|
128
|
-
Get detailed information about a specific session.
|
|
129
|
-
|
|
130
|
-
```http
|
|
131
|
-
GET /session/:sessionId
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
**Response:** HTML page with session viewer interface
|
|
135
|
-
|
|
136
|
-
---
|
|
137
|
-
|
|
138
|
-
#### Export Session
|
|
139
|
-
|
|
140
|
-
Download a session as a ZIP archive.
|
|
141
|
-
|
|
142
|
-
```http
|
|
143
|
-
GET /session/:sessionId/download
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
**Response:**
|
|
147
|
-
- **Content-Type:** `application/zip`
|
|
148
|
-
- **Content-Disposition:** `attachment; filename="session-{sessionId}.zip"`
|
|
149
|
-
|
|
150
|
-
**ZIP Contents:**
|
|
151
|
-
- `events.jsonl` - Event stream data
|
|
152
|
-
- `workspace.yaml` - Session metadata
|
|
153
|
-
- `copilot-insight.md` - AI analysis (if available)
|
|
154
|
-
|
|
155
|
-
**Example:**
|
|
156
|
-
```bash
|
|
157
|
-
curl -O http://localhost:3838/session/f9db650c-1f87-491f-8e4f-52d45538d677/download
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
---
|
|
161
|
-
|
|
162
|
-
#### Import Session
|
|
163
|
-
|
|
164
|
-
Upload and import a session ZIP file.
|
|
165
|
-
|
|
166
|
-
```http
|
|
167
|
-
POST /session/import
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
**Content-Type:** `multipart/form-data`
|
|
171
|
-
|
|
172
|
-
**Form Fields:**
|
|
173
|
-
- `sessionZip` (file, required) - ZIP file containing session data
|
|
174
|
-
|
|
175
|
-
**Response:**
|
|
176
|
-
```json
|
|
177
|
-
{
|
|
178
|
-
"success": true,
|
|
179
|
-
"sessionId": "imported-session-uuid",
|
|
180
|
-
"message": "Session imported successfully"
|
|
181
|
-
}
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
**Error Response:**
|
|
185
|
-
```json
|
|
186
|
-
{
|
|
187
|
-
"success": false,
|
|
188
|
-
"error": "Invalid ZIP file format"
|
|
189
|
-
}
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
**Example:**
|
|
193
|
-
```bash
|
|
194
|
-
curl -X POST \
|
|
195
|
-
-F "sessionZip=@session-export.zip" \
|
|
196
|
-
http://localhost:3838/session/import
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
---
|
|
200
|
-
|
|
201
|
-
### AI Insights
|
|
202
|
-
|
|
203
|
-
#### Generate Insight
|
|
204
|
-
|
|
205
|
-
Generate an AI-powered analysis of a session.
|
|
206
|
-
|
|
207
|
-
```http
|
|
208
|
-
POST /session/:sessionId/insight
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
**Request Body:**
|
|
212
|
-
```json
|
|
213
|
-
{}
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
**Response:** Server-Sent Events (SSE) stream
|
|
217
|
-
|
|
218
|
-
**SSE Event Types:**
|
|
219
|
-
```
|
|
220
|
-
data: {"type":"start","message":"Starting analysis..."}
|
|
221
|
-
data: {"type":"progress","message":"Analyzing events...","percent":25}
|
|
222
|
-
data: {"type":"content","content":"## Session Analysis\n\nThis session shows..."}
|
|
223
|
-
data: {"type":"complete","message":"Analysis complete"}
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
**Example:**
|
|
227
|
-
```bash
|
|
228
|
-
curl -X POST \
|
|
229
|
-
-H "Accept: text/event-stream" \
|
|
230
|
-
http://localhost:3838/session/f9db650c-1f87-491f-8e4f-52d45538d677/insight
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
---
|
|
234
|
-
|
|
235
|
-
#### Get Insight Status
|
|
236
|
-
|
|
237
|
-
Check if an insight exists for a session.
|
|
238
|
-
|
|
239
|
-
```http
|
|
240
|
-
GET /session/:sessionId/insight
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
**Response:**
|
|
244
|
-
```json
|
|
245
|
-
{
|
|
246
|
-
"exists": true,
|
|
247
|
-
"path": "/path/to/copilot-insight.md",
|
|
248
|
-
"size": 15420,
|
|
249
|
-
"lastModified": "2026-02-15T02:35:00.000Z"
|
|
250
|
-
}
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
---
|
|
254
|
-
|
|
255
|
-
#### Delete Insight
|
|
256
|
-
|
|
257
|
-
Remove the generated insight for a session.
|
|
258
|
-
|
|
259
|
-
```http
|
|
260
|
-
DELETE /session/:sessionId/insight
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
**Response:**
|
|
264
|
-
```json
|
|
265
|
-
{
|
|
266
|
-
"success": true,
|
|
267
|
-
"message": "Insight deleted successfully"
|
|
268
|
-
}
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
---
|
|
272
|
-
|
|
273
|
-
## Data Types
|
|
274
|
-
|
|
275
|
-
### Session Object
|
|
276
|
-
|
|
277
|
-
```typescript
|
|
278
|
-
interface Session {
|
|
279
|
-
id: string; // UUID
|
|
280
|
-
summary: string; // Human-readable description
|
|
281
|
-
createdAt: string; // ISO timestamp
|
|
282
|
-
duration?: number; // Duration in milliseconds
|
|
283
|
-
eventCount: number; // Number of events in session
|
|
284
|
-
type: "directory" | "file"; // Session format type
|
|
285
|
-
workspace?: {
|
|
286
|
-
cwd: string; // Working directory
|
|
287
|
-
};
|
|
288
|
-
selectedModel?: string; // AI model used
|
|
289
|
-
copilotVersion?: string; // Copilot CLI version
|
|
290
|
-
isImported: boolean; // Whether session was imported
|
|
291
|
-
hasInsight: boolean; // Whether AI insight exists
|
|
292
|
-
}
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
### Event Object
|
|
296
|
-
|
|
297
|
-
```typescript
|
|
298
|
-
interface Event {
|
|
299
|
-
type: string; // Event type (e.g., "user.message")
|
|
300
|
-
timestamp: string; // ISO timestamp
|
|
301
|
-
[key: string]: any; // Additional event-specific fields
|
|
302
|
-
}
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
### Common Event Types
|
|
306
|
-
|
|
307
|
-
| Category | Event Types | Description |
|
|
308
|
-
|----------|-------------|-------------|
|
|
309
|
-
| **Session** | `session.start`, `session.model_change` | Session lifecycle |
|
|
310
|
-
| **User** | `user.message`, `user.confirmation` | User interactions |
|
|
311
|
-
| **Assistant** | `assistant.message`, `assistant.turn_start`, `assistant.turn_end` | AI responses |
|
|
312
|
-
| **Tool** | `tool.execution_start`, `tool.execution_complete` | Tool invocations |
|
|
313
|
-
| **Sub-Agent** | `subagent.started`, `subagent.completed` | Sub-agent lifecycle |
|
|
314
|
-
| **System** | `client.log`, `error` | System diagnostics |
|
|
315
|
-
|
|
316
|
-
---
|
|
317
|
-
|
|
318
|
-
## Error Responses
|
|
319
|
-
|
|
320
|
-
### Standard Error Format
|
|
321
|
-
|
|
322
|
-
```json
|
|
323
|
-
{
|
|
324
|
-
"error": "Error message",
|
|
325
|
-
"code": "ERROR_CODE",
|
|
326
|
-
"details": "Additional details"
|
|
327
|
-
}
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
### HTTP Status Codes
|
|
331
|
-
|
|
332
|
-
| Code | Description | Common Causes |
|
|
333
|
-
|------|-------------|---------------|
|
|
334
|
-
| `200` | OK | Request successful |
|
|
335
|
-
| `400` | Bad Request | Invalid session ID, malformed request |
|
|
336
|
-
| `404` | Not Found | Session not found, endpoint not found |
|
|
337
|
-
| `500` | Internal Server Error | File system errors, processing errors |
|
|
338
|
-
|
|
339
|
-
### Example Error Responses
|
|
340
|
-
|
|
341
|
-
**Invalid Session ID:**
|
|
342
|
-
```json
|
|
343
|
-
{
|
|
344
|
-
"error": "Invalid session ID format",
|
|
345
|
-
"code": "INVALID_SESSION_ID"
|
|
346
|
-
}
|
|
347
|
-
```
|
|
348
|
-
|
|
349
|
-
**Session Not Found:**
|
|
350
|
-
```json
|
|
351
|
-
{
|
|
352
|
-
"error": "Session not found",
|
|
353
|
-
"code": "SESSION_NOT_FOUND"
|
|
354
|
-
}
|
|
355
|
-
```
|
|
356
|
-
|
|
357
|
-
**File System Error:**
|
|
358
|
-
```json
|
|
359
|
-
{
|
|
360
|
-
"error": "Unable to read session directory",
|
|
361
|
-
"code": "FILE_SYSTEM_ERROR",
|
|
362
|
-
"details": "ENOENT: no such file or directory"
|
|
363
|
-
}
|
|
364
|
-
```
|
|
365
|
-
|
|
366
|
-
---
|
|
367
|
-
|
|
368
|
-
## Rate Limiting
|
|
369
|
-
|
|
370
|
-
### Current Limits
|
|
371
|
-
|
|
372
|
-
- **General requests**: 100 requests per minute
|
|
373
|
-
- **Insight generation**: 5 requests per minute
|
|
374
|
-
- **File uploads**: 10 requests per minute
|
|
375
|
-
|
|
376
|
-
### Rate Limit Headers
|
|
377
|
-
|
|
378
|
-
```http
|
|
379
|
-
X-RateLimit-Limit: 100
|
|
380
|
-
X-RateLimit-Remaining: 95
|
|
381
|
-
X-RateLimit-Reset: 1640995200
|
|
382
|
-
```
|
|
383
|
-
|
|
384
|
-
---
|
|
385
|
-
|
|
386
|
-
## WebSocket Support
|
|
387
|
-
|
|
388
|
-
**Not currently implemented** - All communication is via REST API and SSE.
|
|
389
|
-
|
|
390
|
-
Future versions may include WebSocket support for:
|
|
391
|
-
- Real-time session updates
|
|
392
|
-
- Live event streaming
|
|
393
|
-
- Multi-user collaboration
|
|
394
|
-
|
|
395
|
-
---
|
|
396
|
-
|
|
397
|
-
## SDK / Client Libraries
|
|
398
|
-
|
|
399
|
-
### JavaScript/Node.js
|
|
400
|
-
|
|
401
|
-
```javascript
|
|
402
|
-
// Basic API client example
|
|
403
|
-
class CopilotSessionViewer {
|
|
404
|
-
constructor(baseURL = 'http://localhost:3838') {
|
|
405
|
-
this.baseURL = baseURL;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
async getSessions() {
|
|
409
|
-
const response = await fetch(`${this.baseURL}/api/sessions`);
|
|
410
|
-
return response.json();
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
async getSessionEvents(sessionId) {
|
|
414
|
-
const response = await fetch(`${this.baseURL}/api/sessions/${sessionId}/events`);
|
|
415
|
-
const text = await response.text();
|
|
416
|
-
return text.split('\n').filter(Boolean).map(line => JSON.parse(line));
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
async exportSession(sessionId) {
|
|
420
|
-
const response = await fetch(`${this.baseURL}/session/${sessionId}/download`);
|
|
421
|
-
return response.blob();
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
// Usage
|
|
426
|
-
const viewer = new CopilotSessionViewer();
|
|
427
|
-
const sessions = await viewer.getSessions();
|
|
428
|
-
```
|
|
429
|
-
|
|
430
|
-
### Python
|
|
431
|
-
|
|
432
|
-
```python
|
|
433
|
-
import requests
|
|
434
|
-
import json
|
|
435
|
-
|
|
436
|
-
class CopilotSessionViewer:
|
|
437
|
-
def __init__(self, base_url="http://localhost:3838"):
|
|
438
|
-
self.base_url = base_url
|
|
439
|
-
|
|
440
|
-
def get_sessions(self):
|
|
441
|
-
response = requests.get(f"{self.base_url}/api/sessions")
|
|
442
|
-
return response.json()
|
|
443
|
-
|
|
444
|
-
def get_session_events(self, session_id):
|
|
445
|
-
response = requests.get(f"{self.base_url}/api/sessions/{session_id}/events")
|
|
446
|
-
return [json.loads(line) for line in response.text.strip().split('\n')]
|
|
447
|
-
|
|
448
|
-
def export_session(self, session_id, filename):
|
|
449
|
-
response = requests.get(f"{self.base_url}/session/{session_id}/download")
|
|
450
|
-
with open(filename, 'wb') as f:
|
|
451
|
-
f.write(response.content)
|
|
452
|
-
|
|
453
|
-
# Usage
|
|
454
|
-
viewer = CopilotSessionViewer()
|
|
455
|
-
sessions = viewer.get_sessions()
|
|
456
|
-
```
|
|
457
|
-
|
|
458
|
-
---
|
|
459
|
-
|
|
460
|
-
## OpenAPI Specification
|
|
461
|
-
|
|
462
|
-
A complete OpenAPI 3.0 specification is available at:
|
|
463
|
-
```
|
|
464
|
-
http://localhost:3838/api/openapi.json
|
|
465
|
-
```
|
|
466
|
-
|
|
467
|
-
You can use this with tools like Swagger UI, Postman, or code generators.
|
|
468
|
-
|
|
469
|
-
---
|
|
470
|
-
|
|
471
|
-
**Need help?** Check the [Troubleshooting Guide](TROUBLESHOOTING.md) or [open an issue](https://github.com/qiaolei81/copilot-session-viewer/issues).
|