opencode-prompt-logger 0.1.0 → 0.2.0
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/README.md +105 -525
- package/dist/core.d.ts +7 -46
- package/dist/detail-lines.d.ts +17 -0
- package/dist/gui-experimental.cjs +29 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2282 -71
- package/dist/index.js.map +15 -5
- package/dist/log/body.d.ts +41 -0
- package/dist/log/errors.d.ts +5 -0
- package/dist/log/limits.d.ts +30 -0
- package/dist/log/paths.d.ts +42 -0
- package/dist/log/sanitize.d.ts +16 -0
- package/dist/log/summary.d.ts +3 -0
- package/dist/log/types.d.ts +58 -0
- package/dist/log/v2.d.ts +155 -0
- package/dist/logging-indicator.d.ts +31 -0
- package/dist/rpc-client.d.ts +27 -0
- package/dist/rpc-client.js +585 -0
- package/dist/rpc-client.js.map +14 -0
- package/dist/rpc.d.ts +1437 -0
- package/dist/rpc.js +446 -0
- package/dist/rpc.js.map +12 -0
- package/dist/runtime-state.d.ts +35 -0
- package/dist/session-scope-client.d.ts +8 -0
- package/dist/session-scope.d.ts +65 -0
- package/dist/settings.d.ts +46 -0
- package/dist/tui-panel/detail.d.ts +28 -0
- package/dist/tui-panel/panel.d.ts +21 -0
- package/dist/tui-status.d.ts +25 -0
- package/dist/tui.d.ts +15 -0
- package/dist/tui.js +2571 -0
- package/dist/tui.js.map +25 -0
- package/dist/ui-support.d.ts +3 -0
- package/dist/view-model.d.ts +76 -0
- package/package.json +53 -10
package/dist/tui.js
ADDED
|
@@ -0,0 +1,2571 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/tui.tsx
|
|
3
|
+
import { createComponent as _$createComponent4 } from "@opentui/solid";
|
|
4
|
+
import { Plugin } from "@opencode/plugin/tui";
|
|
5
|
+
|
|
6
|
+
// src/tui-panel/panel.tsx
|
|
7
|
+
import { createTextNode as _$createTextNode2 } from "@opentui/solid";
|
|
8
|
+
import { insertNode as _$insertNode2 } from "@opentui/solid";
|
|
9
|
+
import { effect as _$effect2 } from "@opentui/solid";
|
|
10
|
+
import { use as _$use } from "@opentui/solid";
|
|
11
|
+
import { insert as _$insert2 } from "@opentui/solid";
|
|
12
|
+
import { createComponent as _$createComponent2 } from "@opentui/solid";
|
|
13
|
+
import { setProp as _$setProp2 } from "@opentui/solid";
|
|
14
|
+
import { createElement as _$createElement2 } from "@opentui/solid";
|
|
15
|
+
import { TextAttributes as TextAttributes2 } from "@opentui/core";
|
|
16
|
+
import { For as For2, Show as Show2, createEffect, createMemo, createSignal, on, onCleanup } from "solid-js";
|
|
17
|
+
|
|
18
|
+
// src/log/limits.ts
|
|
19
|
+
var DEFAULT_PAGE = 50;
|
|
20
|
+
var MAX_PAGE = 200;
|
|
21
|
+
var MAX_RECORD_BYTES = 2 * 1024 * 1024;
|
|
22
|
+
var MAX_FULL_RECORD_BYTES = 16 * 1024 * 1024;
|
|
23
|
+
var MAX_SEARCH_BYTES = 128 * 1024 * 1024;
|
|
24
|
+
var MAX_SEARCH_MS = 2000;
|
|
25
|
+
var MAX_SEARCH_QUERY = 500;
|
|
26
|
+
var MAX_SEARCH_RESULTS = 100;
|
|
27
|
+
var EVENT_COALESCE_MS = 1000;
|
|
28
|
+
function clampInteger(value, min, max, fallback) {
|
|
29
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
30
|
+
return fallback;
|
|
31
|
+
return Math.min(max, Math.max(min, Math.round(value)));
|
|
32
|
+
}
|
|
33
|
+
function clampPage(value) {
|
|
34
|
+
return clampInteger(value, 1, MAX_PAGE, DEFAULT_PAGE);
|
|
35
|
+
}
|
|
36
|
+
function clampReadBytes(value) {
|
|
37
|
+
return clampInteger(value, 1024, MAX_FULL_RECORD_BYTES, MAX_RECORD_BYTES);
|
|
38
|
+
}
|
|
39
|
+
function clampSearchBytes(value) {
|
|
40
|
+
return clampInteger(value, 1024 * 1024, MAX_SEARCH_BYTES, MAX_SEARCH_BYTES);
|
|
41
|
+
}
|
|
42
|
+
function clampSearchMs(value) {
|
|
43
|
+
return clampInteger(value, 100, MAX_SEARCH_MS, MAX_SEARCH_MS);
|
|
44
|
+
}
|
|
45
|
+
function boundedString(value, maxLength) {
|
|
46
|
+
if (typeof value !== "string")
|
|
47
|
+
return;
|
|
48
|
+
const trimmed = value.trim();
|
|
49
|
+
if (trimmed === "")
|
|
50
|
+
return;
|
|
51
|
+
return trimmed.length > maxLength ? trimmed.slice(0, maxLength) : trimmed;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/rpc.ts
|
|
55
|
+
import { Rpc } from "@opencode/plugin/rpc";
|
|
56
|
+
|
|
57
|
+
// src/core.ts
|
|
58
|
+
var DEFAULT_DISK_BUDGET = 256 * 1024 * 1024;
|
|
59
|
+
var CONTEXT_KINDS = ["context", "compaction", "generate", "title"];
|
|
60
|
+
|
|
61
|
+
// src/settings.ts
|
|
62
|
+
var SETTINGS_KEY = "settings";
|
|
63
|
+
var MAX_SETTINGS_DISK_BUDGET = 8 * 1024 * 1024 * 1024;
|
|
64
|
+
var MAX_SETTINGS_RETENTION_DAYS = 3650;
|
|
65
|
+
var MAX_SETTINGS_RETENTION_SESSIONS = 1e4;
|
|
66
|
+
var MAX_SETTINGS_DIRECTORY = 4096;
|
|
67
|
+
var DEFAULT_SETTINGS = {
|
|
68
|
+
enabled: true,
|
|
69
|
+
http: false,
|
|
70
|
+
diskBudget: DEFAULT_DISK_BUDGET,
|
|
71
|
+
retentionMaxAgeDays: 30,
|
|
72
|
+
retentionMaxSessions: 200,
|
|
73
|
+
directory: "",
|
|
74
|
+
maintenance: true
|
|
75
|
+
};
|
|
76
|
+
function defaultSettings() {
|
|
77
|
+
return { ...DEFAULT_SETTINGS };
|
|
78
|
+
}
|
|
79
|
+
function isRecord(value) {
|
|
80
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
81
|
+
}
|
|
82
|
+
function isBoundedInteger(value, max) {
|
|
83
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 && Math.floor(value) === value && value <= max;
|
|
84
|
+
}
|
|
85
|
+
function boundedInteger(value, max, fallback) {
|
|
86
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < 0)
|
|
87
|
+
return fallback;
|
|
88
|
+
return Math.min(max, Math.floor(value));
|
|
89
|
+
}
|
|
90
|
+
function directoryValue(value) {
|
|
91
|
+
if (typeof value !== "string")
|
|
92
|
+
return;
|
|
93
|
+
return value.trim().slice(0, MAX_SETTINGS_DIRECTORY);
|
|
94
|
+
}
|
|
95
|
+
function overlay(target, value) {
|
|
96
|
+
if (!isRecord(value))
|
|
97
|
+
return target;
|
|
98
|
+
const next = { ...target };
|
|
99
|
+
if (typeof value.enabled === "boolean")
|
|
100
|
+
next.enabled = value.enabled;
|
|
101
|
+
if (typeof value.http === "boolean")
|
|
102
|
+
next.http = value.http;
|
|
103
|
+
next.diskBudget = boundedInteger(value.diskBudget, MAX_SETTINGS_DISK_BUDGET, next.diskBudget);
|
|
104
|
+
next.retentionMaxAgeDays = boundedInteger(value.retentionMaxAgeDays, MAX_SETTINGS_RETENTION_DAYS, next.retentionMaxAgeDays);
|
|
105
|
+
next.retentionMaxSessions = boundedInteger(value.retentionMaxSessions, MAX_SETTINGS_RETENTION_SESSIONS, next.retentionMaxSessions);
|
|
106
|
+
const directory = directoryValue(value.directory);
|
|
107
|
+
if (directory !== undefined)
|
|
108
|
+
next.directory = directory;
|
|
109
|
+
if (typeof value.maintenance === "boolean")
|
|
110
|
+
next.maintenance = value.maintenance;
|
|
111
|
+
return next;
|
|
112
|
+
}
|
|
113
|
+
function sanitizeSettings(value) {
|
|
114
|
+
return overlay(defaultSettings(), value);
|
|
115
|
+
}
|
|
116
|
+
function isValidSettings(value) {
|
|
117
|
+
if (!isRecord(value))
|
|
118
|
+
return false;
|
|
119
|
+
if (typeof value.enabled !== "boolean" || typeof value.http !== "boolean")
|
|
120
|
+
return false;
|
|
121
|
+
if (typeof value.maintenance !== "boolean")
|
|
122
|
+
return false;
|
|
123
|
+
if (typeof value.directory !== "string" || value.directory.length > MAX_SETTINGS_DIRECTORY)
|
|
124
|
+
return false;
|
|
125
|
+
return isBoundedInteger(value.diskBudget, MAX_SETTINGS_DISK_BUDGET) && isBoundedInteger(value.retentionMaxAgeDays, MAX_SETTINGS_RETENTION_DAYS) && isBoundedInteger(value.retentionMaxSessions, MAX_SETTINGS_RETENTION_SESSIONS);
|
|
126
|
+
}
|
|
127
|
+
function settingsFromEnvelope(value) {
|
|
128
|
+
return sanitizeSettings(isRecord(value) ? value.settings : undefined);
|
|
129
|
+
}
|
|
130
|
+
function pickSettings(value) {
|
|
131
|
+
return {
|
|
132
|
+
enabled: value.enabled,
|
|
133
|
+
http: value.http,
|
|
134
|
+
diskBudget: value.diskBudget,
|
|
135
|
+
retentionMaxAgeDays: value.retentionMaxAgeDays,
|
|
136
|
+
retentionMaxSessions: value.retentionMaxSessions,
|
|
137
|
+
directory: value.directory,
|
|
138
|
+
maintenance: value.maintenance
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// src/rpc.ts
|
|
143
|
+
var CONTRACT_VERSION = 6;
|
|
144
|
+
var nullableString = { type: ["string", "null"] };
|
|
145
|
+
var modelSchema = {
|
|
146
|
+
anyOf: [
|
|
147
|
+
{ type: "null" },
|
|
148
|
+
{
|
|
149
|
+
type: "object",
|
|
150
|
+
properties: {
|
|
151
|
+
providerID: { type: "string" },
|
|
152
|
+
id: { type: "string" },
|
|
153
|
+
variant: { type: "string" }
|
|
154
|
+
},
|
|
155
|
+
additionalProperties: false
|
|
156
|
+
}
|
|
157
|
+
]
|
|
158
|
+
};
|
|
159
|
+
var summarySchema = {
|
|
160
|
+
type: "object",
|
|
161
|
+
properties: {
|
|
162
|
+
key: { type: "string" },
|
|
163
|
+
cursor: { type: "string" },
|
|
164
|
+
bytes: { type: "number" },
|
|
165
|
+
at: nullableString,
|
|
166
|
+
type: nullableString,
|
|
167
|
+
kind: nullableString,
|
|
168
|
+
sessionID: nullableString,
|
|
169
|
+
agent: nullableString,
|
|
170
|
+
model: modelSchema,
|
|
171
|
+
url: nullableString,
|
|
172
|
+
messages: { type: "number" },
|
|
173
|
+
bodyBytes: { type: "number" },
|
|
174
|
+
hasBody: { type: "boolean" }
|
|
175
|
+
},
|
|
176
|
+
required: ["key", "cursor", "bytes", "at", "type", "kind", "sessionID", "agent", "model", "url"],
|
|
177
|
+
additionalProperties: false
|
|
178
|
+
};
|
|
179
|
+
var storeStatusSchema = {
|
|
180
|
+
type: "object",
|
|
181
|
+
properties: {
|
|
182
|
+
path: { type: "string" },
|
|
183
|
+
exists: { type: "boolean" },
|
|
184
|
+
bytes: { type: "number" },
|
|
185
|
+
mtimeMs: { anyOf: [{ type: "number" }, { type: "null" }] },
|
|
186
|
+
directory: { type: "boolean" },
|
|
187
|
+
symlink: { type: "boolean" },
|
|
188
|
+
mode: { anyOf: [{ type: "number" }, { type: "null" }] },
|
|
189
|
+
directoryMode: { anyOf: [{ type: "number" }, { type: "null" }] },
|
|
190
|
+
warnings: { type: "array", items: { type: "string" } }
|
|
191
|
+
},
|
|
192
|
+
required: ["path", "exists", "bytes", "mtimeMs", "directory", "symlink", "mode", "directoryMode", "warnings"],
|
|
193
|
+
additionalProperties: false
|
|
194
|
+
};
|
|
195
|
+
var cacheSchema = {
|
|
196
|
+
type: "object",
|
|
197
|
+
properties: {
|
|
198
|
+
requests: { type: "number" },
|
|
199
|
+
requestBytes: { type: "number" },
|
|
200
|
+
lastScanMs: { type: "number" },
|
|
201
|
+
error: nullableString
|
|
202
|
+
},
|
|
203
|
+
required: ["requests", "requestBytes", "lastScanMs", "error"],
|
|
204
|
+
additionalProperties: false
|
|
205
|
+
};
|
|
206
|
+
var settingsSchema = {
|
|
207
|
+
type: "object",
|
|
208
|
+
properties: {
|
|
209
|
+
enabled: { type: "boolean" },
|
|
210
|
+
http: { type: "boolean" },
|
|
211
|
+
diskBudget: { type: "number", minimum: 0, maximum: MAX_SETTINGS_DISK_BUDGET },
|
|
212
|
+
retentionMaxAgeDays: { type: "number", minimum: 0, maximum: MAX_SETTINGS_RETENTION_DAYS },
|
|
213
|
+
retentionMaxSessions: { type: "number", minimum: 0, maximum: MAX_SETTINGS_RETENTION_SESSIONS },
|
|
214
|
+
directory: { type: "string", maxLength: MAX_SETTINGS_DIRECTORY },
|
|
215
|
+
maintenance: { type: "boolean" }
|
|
216
|
+
},
|
|
217
|
+
required: [
|
|
218
|
+
"enabled",
|
|
219
|
+
"http",
|
|
220
|
+
"diskBudget",
|
|
221
|
+
"retentionMaxAgeDays",
|
|
222
|
+
"retentionMaxSessions",
|
|
223
|
+
"directory",
|
|
224
|
+
"maintenance"
|
|
225
|
+
],
|
|
226
|
+
additionalProperties: false
|
|
227
|
+
};
|
|
228
|
+
var statusSettingsSchema = {
|
|
229
|
+
type: "object",
|
|
230
|
+
properties: {
|
|
231
|
+
...settingsSchema.properties,
|
|
232
|
+
retention: {
|
|
233
|
+
type: "object",
|
|
234
|
+
properties: {
|
|
235
|
+
maxTotalBytes: { anyOf: [{ type: "number" }, { type: "null" }] },
|
|
236
|
+
maxAgeDays: { type: "number" },
|
|
237
|
+
maxSessions: { anyOf: [{ type: "number" }, { type: "null" }] }
|
|
238
|
+
},
|
|
239
|
+
required: ["maxTotalBytes", "maxAgeDays", "maxSessions"],
|
|
240
|
+
additionalProperties: false
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
required: [...settingsSchema.required, "retention"],
|
|
244
|
+
additionalProperties: false
|
|
245
|
+
};
|
|
246
|
+
var sessionScopeSchema = {
|
|
247
|
+
type: "object",
|
|
248
|
+
properties: {
|
|
249
|
+
mode: { type: "string", enum: ["all", "only"] },
|
|
250
|
+
sessions: { type: "array", items: { type: "string", maxLength: 200 } },
|
|
251
|
+
max: { type: "number" }
|
|
252
|
+
},
|
|
253
|
+
required: ["mode", "sessions", "max"],
|
|
254
|
+
additionalProperties: false
|
|
255
|
+
};
|
|
256
|
+
var settingsResponseSchema = {
|
|
257
|
+
type: "object",
|
|
258
|
+
properties: {
|
|
259
|
+
settings: settingsSchema,
|
|
260
|
+
sessionScope: sessionScopeSchema
|
|
261
|
+
},
|
|
262
|
+
required: ["settings", "sessionScope"],
|
|
263
|
+
additionalProperties: false
|
|
264
|
+
};
|
|
265
|
+
var errorSchema = {
|
|
266
|
+
type: "object",
|
|
267
|
+
properties: { message: { type: "string" } },
|
|
268
|
+
additionalProperties: false
|
|
269
|
+
};
|
|
270
|
+
var errors = {
|
|
271
|
+
io: errorSchema,
|
|
272
|
+
not_found: errorSchema,
|
|
273
|
+
bad_request: errorSchema,
|
|
274
|
+
forbidden: errorSchema
|
|
275
|
+
};
|
|
276
|
+
var filtersSchema = {
|
|
277
|
+
sessionID: { type: "string", maxLength: 200 },
|
|
278
|
+
type: { type: "string", maxLength: 80 },
|
|
279
|
+
kind: { type: "string", maxLength: 80 },
|
|
280
|
+
agent: { type: "string", maxLength: 200 },
|
|
281
|
+
model: { type: "string", maxLength: 200 },
|
|
282
|
+
query: { type: "string", maxLength: 200 }
|
|
283
|
+
};
|
|
284
|
+
var PromptLogger = Rpc.define({
|
|
285
|
+
id: "prompt-logger",
|
|
286
|
+
methods: {
|
|
287
|
+
status: {
|
|
288
|
+
input: { type: "object", properties: {}, additionalProperties: false },
|
|
289
|
+
output: {
|
|
290
|
+
type: "object",
|
|
291
|
+
properties: {
|
|
292
|
+
version: { type: "number" },
|
|
293
|
+
store: storeStatusSchema,
|
|
294
|
+
settings: statusSettingsSchema,
|
|
295
|
+
sessionScope: sessionScopeSchema,
|
|
296
|
+
cache: cacheSchema,
|
|
297
|
+
lastWriteAt: { anyOf: [{ type: "string" }, { type: "null" }] },
|
|
298
|
+
lastWriteError: {
|
|
299
|
+
anyOf: [
|
|
300
|
+
{ type: "null" },
|
|
301
|
+
{
|
|
302
|
+
type: "object",
|
|
303
|
+
properties: {
|
|
304
|
+
at: { type: "string" },
|
|
305
|
+
code: { type: "string" },
|
|
306
|
+
message: { type: "string" }
|
|
307
|
+
},
|
|
308
|
+
required: ["at", "message"],
|
|
309
|
+
additionalProperties: false
|
|
310
|
+
}
|
|
311
|
+
]
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
required: ["version", "store", "settings", "sessionScope", "cache", "lastWriteAt", "lastWriteError"],
|
|
315
|
+
additionalProperties: false
|
|
316
|
+
},
|
|
317
|
+
errors
|
|
318
|
+
},
|
|
319
|
+
list: {
|
|
320
|
+
input: {
|
|
321
|
+
type: "object",
|
|
322
|
+
properties: {
|
|
323
|
+
...filtersSchema,
|
|
324
|
+
limit: { type: "number" },
|
|
325
|
+
cursor: { type: "string" }
|
|
326
|
+
},
|
|
327
|
+
additionalProperties: false
|
|
328
|
+
},
|
|
329
|
+
output: {
|
|
330
|
+
type: "object",
|
|
331
|
+
properties: {
|
|
332
|
+
entries: { type: "array", items: summarySchema },
|
|
333
|
+
hasMore: { type: "boolean" },
|
|
334
|
+
records: { type: "number" },
|
|
335
|
+
error: nullableString
|
|
336
|
+
},
|
|
337
|
+
required: ["entries", "hasMore", "records", "error"],
|
|
338
|
+
additionalProperties: false
|
|
339
|
+
},
|
|
340
|
+
errors
|
|
341
|
+
},
|
|
342
|
+
read: {
|
|
343
|
+
input: {
|
|
344
|
+
type: "object",
|
|
345
|
+
properties: {
|
|
346
|
+
key: { type: "string", maxLength: 300 },
|
|
347
|
+
maxBytes: { type: "number" }
|
|
348
|
+
},
|
|
349
|
+
required: ["key"],
|
|
350
|
+
additionalProperties: false
|
|
351
|
+
},
|
|
352
|
+
output: {
|
|
353
|
+
type: "object",
|
|
354
|
+
properties: {
|
|
355
|
+
record: {},
|
|
356
|
+
bytes: { type: "number" },
|
|
357
|
+
truncated: { type: "boolean" },
|
|
358
|
+
moreAvailable: { type: "boolean" },
|
|
359
|
+
fullBytes: { type: "number" },
|
|
360
|
+
paths: {
|
|
361
|
+
type: "object",
|
|
362
|
+
properties: {
|
|
363
|
+
session: { type: "string" },
|
|
364
|
+
requests: { type: "string" },
|
|
365
|
+
body: { type: "string" }
|
|
366
|
+
},
|
|
367
|
+
additionalProperties: false
|
|
368
|
+
}
|
|
369
|
+
},
|
|
370
|
+
required: ["record", "bytes", "truncated"],
|
|
371
|
+
additionalProperties: false
|
|
372
|
+
},
|
|
373
|
+
errors
|
|
374
|
+
},
|
|
375
|
+
search: {
|
|
376
|
+
input: {
|
|
377
|
+
type: "object",
|
|
378
|
+
properties: {
|
|
379
|
+
...filtersSchema,
|
|
380
|
+
query: { type: "string", minLength: 1, maxLength: 500 },
|
|
381
|
+
limit: { type: "number" },
|
|
382
|
+
ignoreCase: { type: "boolean" },
|
|
383
|
+
budgetBytes: { type: "number" },
|
|
384
|
+
budgetMs: { type: "number" }
|
|
385
|
+
},
|
|
386
|
+
required: ["query"],
|
|
387
|
+
additionalProperties: false
|
|
388
|
+
},
|
|
389
|
+
output: {
|
|
390
|
+
type: "object",
|
|
391
|
+
properties: {
|
|
392
|
+
matches: {
|
|
393
|
+
type: "array",
|
|
394
|
+
items: {
|
|
395
|
+
type: "object",
|
|
396
|
+
properties: { entry: summarySchema, snippet: { type: "string" } },
|
|
397
|
+
required: ["entry", "snippet"],
|
|
398
|
+
additionalProperties: false
|
|
399
|
+
}
|
|
400
|
+
},
|
|
401
|
+
partial: { type: "boolean" },
|
|
402
|
+
scannedBytes: { type: "number" },
|
|
403
|
+
skipped: { type: "number" },
|
|
404
|
+
error: nullableString
|
|
405
|
+
},
|
|
406
|
+
required: ["matches", "partial", "scannedBytes", "skipped", "error"],
|
|
407
|
+
additionalProperties: false
|
|
408
|
+
},
|
|
409
|
+
errors
|
|
410
|
+
},
|
|
411
|
+
truncate: {
|
|
412
|
+
input: {
|
|
413
|
+
type: "object",
|
|
414
|
+
properties: {
|
|
415
|
+
target: { type: "string", enum: ["current", "all"] },
|
|
416
|
+
sessionID: { type: "string", maxLength: 200 },
|
|
417
|
+
confirm: { type: "boolean", enum: [true] }
|
|
418
|
+
},
|
|
419
|
+
required: ["target", "confirm"],
|
|
420
|
+
additionalProperties: false
|
|
421
|
+
},
|
|
422
|
+
output: {
|
|
423
|
+
type: "object",
|
|
424
|
+
properties: {
|
|
425
|
+
target: { type: "string", enum: ["current", "all"] },
|
|
426
|
+
bytesFreed: { type: "number" }
|
|
427
|
+
},
|
|
428
|
+
required: ["target", "bytesFreed"],
|
|
429
|
+
additionalProperties: false
|
|
430
|
+
},
|
|
431
|
+
errors
|
|
432
|
+
},
|
|
433
|
+
getSettings: {
|
|
434
|
+
input: { type: "object", properties: {}, additionalProperties: false },
|
|
435
|
+
output: settingsResponseSchema,
|
|
436
|
+
errors
|
|
437
|
+
},
|
|
438
|
+
setSettings: {
|
|
439
|
+
input: {
|
|
440
|
+
type: "object",
|
|
441
|
+
properties: { settings: settingsSchema },
|
|
442
|
+
required: ["settings"],
|
|
443
|
+
additionalProperties: false
|
|
444
|
+
},
|
|
445
|
+
output: settingsResponseSchema,
|
|
446
|
+
errors
|
|
447
|
+
},
|
|
448
|
+
resetSettings: {
|
|
449
|
+
input: { type: "object", properties: {}, additionalProperties: false },
|
|
450
|
+
output: settingsResponseSchema,
|
|
451
|
+
errors
|
|
452
|
+
},
|
|
453
|
+
updateSessionScope: {
|
|
454
|
+
input: {
|
|
455
|
+
type: "object",
|
|
456
|
+
properties: {
|
|
457
|
+
mode: { type: "string", enum: ["all", "only"] },
|
|
458
|
+
action: { type: "string", enum: ["only", "disarm", "clear"] },
|
|
459
|
+
sessionID: { type: "string", maxLength: 200 }
|
|
460
|
+
},
|
|
461
|
+
additionalProperties: false
|
|
462
|
+
},
|
|
463
|
+
output: {
|
|
464
|
+
type: "object",
|
|
465
|
+
properties: {
|
|
466
|
+
sessionScope: sessionScopeSchema,
|
|
467
|
+
settings: settingsSchema
|
|
468
|
+
},
|
|
469
|
+
required: ["sessionScope", "settings"],
|
|
470
|
+
additionalProperties: false
|
|
471
|
+
},
|
|
472
|
+
errors
|
|
473
|
+
}
|
|
474
|
+
},
|
|
475
|
+
events: {
|
|
476
|
+
changed: {
|
|
477
|
+
schema: {
|
|
478
|
+
type: "object",
|
|
479
|
+
properties: {
|
|
480
|
+
store: { type: "string" },
|
|
481
|
+
reason: { type: "string", enum: ["append", "truncate", "error"] },
|
|
482
|
+
at: { type: "string" }
|
|
483
|
+
},
|
|
484
|
+
required: ["store", "reason", "at"],
|
|
485
|
+
additionalProperties: false
|
|
486
|
+
}
|
|
487
|
+
},
|
|
488
|
+
settingsChanged: {
|
|
489
|
+
schema: settingsResponseSchema
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
// src/rpc-client.ts
|
|
495
|
+
function asSettingsResponse(value) {
|
|
496
|
+
const response = value;
|
|
497
|
+
return {
|
|
498
|
+
settings: settingsFromEnvelope(value),
|
|
499
|
+
sessionScope: response.sessionScope
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
function promptLogApi(client, location) {
|
|
503
|
+
const rpc = client.rpc(PromptLogger);
|
|
504
|
+
const options = (signal) => ({
|
|
505
|
+
...location?.directory === undefined ? {} : { location: { directory: location.directory } },
|
|
506
|
+
...signal === undefined ? {} : { signal }
|
|
507
|
+
});
|
|
508
|
+
return {
|
|
509
|
+
status(signal) {
|
|
510
|
+
return rpc.status({}, options(signal));
|
|
511
|
+
},
|
|
512
|
+
list(input = {}, signal) {
|
|
513
|
+
return rpc.list(clampList(input), options(signal));
|
|
514
|
+
},
|
|
515
|
+
read(input, signal) {
|
|
516
|
+
return rpc.read(clampRead(input), options(signal));
|
|
517
|
+
},
|
|
518
|
+
search(input, signal) {
|
|
519
|
+
return rpc.search(clampSearch(input), options(signal));
|
|
520
|
+
},
|
|
521
|
+
truncate(target, sessionID) {
|
|
522
|
+
return rpc.truncate({
|
|
523
|
+
target,
|
|
524
|
+
confirm: true,
|
|
525
|
+
...sessionID === undefined ? {} : { sessionID: boundedString(sessionID, 200) }
|
|
526
|
+
}, options());
|
|
527
|
+
},
|
|
528
|
+
getSettings() {
|
|
529
|
+
return rpc.getSettings({}, options()).then(asSettingsResponse);
|
|
530
|
+
},
|
|
531
|
+
setSettings(settings) {
|
|
532
|
+
const input = { settings: pickSettings(settings) };
|
|
533
|
+
return rpc.setSettings(input, options()).then(asSettingsResponse);
|
|
534
|
+
},
|
|
535
|
+
resetSettings() {
|
|
536
|
+
return rpc.resetSettings({}, options()).then(asSettingsResponse);
|
|
537
|
+
},
|
|
538
|
+
updateSessionScope(input) {
|
|
539
|
+
const sessionID = boundedString(input.sessionID, 200);
|
|
540
|
+
return rpc.updateSessionScope({
|
|
541
|
+
...input.mode === undefined ? {} : { mode: input.mode },
|
|
542
|
+
...input.action === undefined ? {} : { action: input.action },
|
|
543
|
+
...sessionID === undefined ? {} : { sessionID }
|
|
544
|
+
}, options());
|
|
545
|
+
},
|
|
546
|
+
onChanged(handler, signal) {
|
|
547
|
+
if (typeof rpc.events?.on !== "function")
|
|
548
|
+
return () => {};
|
|
549
|
+
return rpc.events.on("changed", (event) => handler(event.data), signal === undefined ? undefined : { signal });
|
|
550
|
+
},
|
|
551
|
+
onSettingsChanged(handler, signal) {
|
|
552
|
+
if (typeof rpc.events?.on !== "function")
|
|
553
|
+
return () => {};
|
|
554
|
+
return rpc.events.on("settingsChanged", (event) => handler(asSettingsResponse(event.data)), signal === undefined ? undefined : { signal });
|
|
555
|
+
},
|
|
556
|
+
contractVersion: CONTRACT_VERSION
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
function filtersOf(input) {
|
|
560
|
+
const sessionID = boundedString(input.sessionID, 200);
|
|
561
|
+
const type = boundedString(input.type, 80);
|
|
562
|
+
const kind = boundedString(input.kind, 80);
|
|
563
|
+
const agent = boundedString(input.agent, 200);
|
|
564
|
+
const model = boundedString(input.model, 200);
|
|
565
|
+
return {
|
|
566
|
+
...sessionID === undefined ? {} : { sessionID },
|
|
567
|
+
...type === undefined ? {} : { type },
|
|
568
|
+
...kind === undefined ? {} : { kind },
|
|
569
|
+
...agent === undefined ? {} : { agent },
|
|
570
|
+
...model === undefined ? {} : { model }
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
function clampList(input) {
|
|
574
|
+
return {
|
|
575
|
+
...filtersOf(input),
|
|
576
|
+
...boundedString(input.query, 200) === undefined ? {} : { query: boundedString(input.query, 200) },
|
|
577
|
+
limit: clampPage(input.limit),
|
|
578
|
+
...boundedString(input.cursor, 400) === undefined ? {} : { cursor: boundedString(input.cursor, 400) }
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
function clampRead(input) {
|
|
582
|
+
return {
|
|
583
|
+
key: boundedString(input.key, 300) ?? "",
|
|
584
|
+
maxBytes: clampReadBytes(input.maxBytes)
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
function clampSearch(input) {
|
|
588
|
+
return {
|
|
589
|
+
...filtersOf(input),
|
|
590
|
+
query: (input.query ?? "").trim().slice(0, 500),
|
|
591
|
+
limit: clampInteger(input.limit, 1, MAX_SEARCH_RESULTS, 50),
|
|
592
|
+
ignoreCase: input.ignoreCase === true,
|
|
593
|
+
budgetBytes: clampSearchBytes(input.budgetBytes),
|
|
594
|
+
budgetMs: clampSearchMs(input.budgetMs)
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
// src/ui-support.ts
|
|
599
|
+
function errorMessage(cause) {
|
|
600
|
+
if (cause instanceof Error)
|
|
601
|
+
return cause.message;
|
|
602
|
+
if (cause !== null && typeof cause === "object" && "message" in cause) {
|
|
603
|
+
return String(cause.message);
|
|
604
|
+
}
|
|
605
|
+
return "the prompt logger rpc is unavailable";
|
|
606
|
+
}
|
|
607
|
+
function warningLabel(warning) {
|
|
608
|
+
switch (warning) {
|
|
609
|
+
case "directory-permissions":
|
|
610
|
+
return "the store directory is writable by others";
|
|
611
|
+
case "symlink":
|
|
612
|
+
return "the store path is a symlink";
|
|
613
|
+
case "not-regular":
|
|
614
|
+
return "the store path is not a directory";
|
|
615
|
+
default:
|
|
616
|
+
return warning;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
// src/session-scope.ts
|
|
621
|
+
var SESSION_SCOPE_KEY = "sessionScope";
|
|
622
|
+
var MAX_SESSION_SCOPE = 50;
|
|
623
|
+
function emptySessionScope() {
|
|
624
|
+
return { mode: "all", sessions: [], max: MAX_SESSION_SCOPE };
|
|
625
|
+
}
|
|
626
|
+
function parseSessionScope(value) {
|
|
627
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
628
|
+
return emptySessionScope();
|
|
629
|
+
}
|
|
630
|
+
const record = value;
|
|
631
|
+
const sessions = [];
|
|
632
|
+
const seen = new Set;
|
|
633
|
+
if (Array.isArray(record.sessions)) {
|
|
634
|
+
for (const entry of record.sessions) {
|
|
635
|
+
if (typeof entry !== "string")
|
|
636
|
+
continue;
|
|
637
|
+
const sessionID = entry.trim();
|
|
638
|
+
if (sessionID === "" || sessionID.length > 200 || seen.has(sessionID))
|
|
639
|
+
continue;
|
|
640
|
+
seen.add(sessionID);
|
|
641
|
+
sessions.push(sessionID);
|
|
642
|
+
if (sessions.length >= MAX_SESSION_SCOPE)
|
|
643
|
+
break;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
return {
|
|
647
|
+
mode: record.mode === "only" ? "only" : "all",
|
|
648
|
+
sessions,
|
|
649
|
+
max: MAX_SESSION_SCOPE
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
function sessionAllowed(scope, sessionID) {
|
|
653
|
+
if (sessionID === undefined || sessionID === "")
|
|
654
|
+
return false;
|
|
655
|
+
return scope.mode === "all" || scope.sessions.includes(sessionID);
|
|
656
|
+
}
|
|
657
|
+
function isSelected(scope, sessionID) {
|
|
658
|
+
if (scope === undefined || scope.mode !== "only" || sessionID === undefined)
|
|
659
|
+
return false;
|
|
660
|
+
return scope.sessions.includes(sessionID);
|
|
661
|
+
}
|
|
662
|
+
function scopeLabel(scope, enabled, sessionID) {
|
|
663
|
+
if (!enabled)
|
|
664
|
+
return "off";
|
|
665
|
+
if (scope === undefined)
|
|
666
|
+
return "unavailable";
|
|
667
|
+
if (scope.mode === "all")
|
|
668
|
+
return "all sessions";
|
|
669
|
+
if (scope.sessions.length === 0)
|
|
670
|
+
return "paused";
|
|
671
|
+
if (sessionID !== undefined && isSelected(scope, sessionID))
|
|
672
|
+
return "this session";
|
|
673
|
+
return scope.sessions.length === 1 ? "1 session" : `${scope.sessions.length} sessions`;
|
|
674
|
+
}
|
|
675
|
+
function onlySession(scope, sessionID) {
|
|
676
|
+
return { mode: "only", sessions: [sessionID], max: scope.max };
|
|
677
|
+
}
|
|
678
|
+
function removeSession(scope, sessionID) {
|
|
679
|
+
return {
|
|
680
|
+
mode: scope.mode,
|
|
681
|
+
sessions: scope.sessions.filter((entry) => entry !== sessionID),
|
|
682
|
+
max: scope.max
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
function clearSessions(scope) {
|
|
686
|
+
return { mode: "only", sessions: [], max: scope.max };
|
|
687
|
+
}
|
|
688
|
+
function allSessions(scope) {
|
|
689
|
+
return { mode: "all", sessions: [], max: scope.max };
|
|
690
|
+
}
|
|
691
|
+
function changeSessionScope(scope, change) {
|
|
692
|
+
const sessionID = change.sessionID?.trim() ?? "";
|
|
693
|
+
if (change.action === "only")
|
|
694
|
+
return sessionID === "" ? scope : onlySession(scope, sessionID);
|
|
695
|
+
if (change.action === "disarm")
|
|
696
|
+
return sessionID === "" ? scope : removeSession(scope, sessionID);
|
|
697
|
+
if (change.action === "clear")
|
|
698
|
+
return clearSessions(scope);
|
|
699
|
+
if (change.mode === "all")
|
|
700
|
+
return allSessions(scope);
|
|
701
|
+
return { ...scope, mode: "only" };
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
// src/session-scope-client.ts
|
|
705
|
+
async function toggleSessionArmed(api, sessionID) {
|
|
706
|
+
const status = await api.status();
|
|
707
|
+
return api.updateSessionScope(isSelected(status.sessionScope, sessionID) ? { action: "disarm", sessionID } : { action: "only", sessionID });
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
// src/log/sanitize.ts
|
|
711
|
+
function sanitizeTerminalInfo(input, limit = 64000) {
|
|
712
|
+
const parts = [];
|
|
713
|
+
let length = 0;
|
|
714
|
+
let truncated = false;
|
|
715
|
+
let i = 0;
|
|
716
|
+
const append = (value) => {
|
|
717
|
+
if (length >= limit) {
|
|
718
|
+
truncated = true;
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
parts.push(value);
|
|
722
|
+
length += value.length;
|
|
723
|
+
};
|
|
724
|
+
while (i < input.length) {
|
|
725
|
+
if (length >= limit) {
|
|
726
|
+
truncated = true;
|
|
727
|
+
break;
|
|
728
|
+
}
|
|
729
|
+
const code = input.charCodeAt(i);
|
|
730
|
+
if (code === 27) {
|
|
731
|
+
i = skipEscape(input, i);
|
|
732
|
+
continue;
|
|
733
|
+
}
|
|
734
|
+
if (code === 13) {
|
|
735
|
+
append(`
|
|
736
|
+
`);
|
|
737
|
+
i += input.charCodeAt(i + 1) === 10 ? 2 : 1;
|
|
738
|
+
continue;
|
|
739
|
+
}
|
|
740
|
+
if (code === 10 || code === 9) {
|
|
741
|
+
append(input[i]);
|
|
742
|
+
i += 1;
|
|
743
|
+
continue;
|
|
744
|
+
}
|
|
745
|
+
if (code < 32 || code === 127) {
|
|
746
|
+
i += 1;
|
|
747
|
+
continue;
|
|
748
|
+
}
|
|
749
|
+
if (code >= 128 && code <= 159) {
|
|
750
|
+
i += 1;
|
|
751
|
+
continue;
|
|
752
|
+
}
|
|
753
|
+
if (isBidiControl(code)) {
|
|
754
|
+
i += 1;
|
|
755
|
+
continue;
|
|
756
|
+
}
|
|
757
|
+
if (code >= 55296 && code <= 56319 && i + 1 < input.length) {
|
|
758
|
+
if (length + 2 > limit) {
|
|
759
|
+
truncated = true;
|
|
760
|
+
break;
|
|
761
|
+
}
|
|
762
|
+
append(input.slice(i, i + 2));
|
|
763
|
+
i += 2;
|
|
764
|
+
continue;
|
|
765
|
+
}
|
|
766
|
+
append(input[i]);
|
|
767
|
+
i += 1;
|
|
768
|
+
}
|
|
769
|
+
const text = parts.join("");
|
|
770
|
+
if (truncated)
|
|
771
|
+
return { text: `${text.slice(0, limit)}
|
|
772
|
+
\u2026 [truncated]`, truncated: true };
|
|
773
|
+
return { text, truncated: false };
|
|
774
|
+
}
|
|
775
|
+
function sanitizeTerminal(input, limit = 64000) {
|
|
776
|
+
return sanitizeTerminalInfo(input, limit).text;
|
|
777
|
+
}
|
|
778
|
+
function skipEscape(input, start) {
|
|
779
|
+
const next = input[start + 1];
|
|
780
|
+
if (next === undefined)
|
|
781
|
+
return start + 1;
|
|
782
|
+
if (next === "[") {
|
|
783
|
+
let i = start + 2;
|
|
784
|
+
while (i < input.length) {
|
|
785
|
+
const code = input.charCodeAt(i);
|
|
786
|
+
i += 1;
|
|
787
|
+
if (code >= 64 && code <= 126)
|
|
788
|
+
break;
|
|
789
|
+
}
|
|
790
|
+
return i;
|
|
791
|
+
}
|
|
792
|
+
if (next === "]" || next === "P" || next === "X" || next === "^" || next === "_") {
|
|
793
|
+
let i = start + 2;
|
|
794
|
+
while (i < input.length) {
|
|
795
|
+
const code = input.charCodeAt(i);
|
|
796
|
+
if (code === 7)
|
|
797
|
+
return i + 1;
|
|
798
|
+
if (code === 27 && input[i + 1] === "\\")
|
|
799
|
+
return i + 2;
|
|
800
|
+
i += 1;
|
|
801
|
+
}
|
|
802
|
+
return i;
|
|
803
|
+
}
|
|
804
|
+
return start + 2;
|
|
805
|
+
}
|
|
806
|
+
function isBidiControl(code) {
|
|
807
|
+
if (code === 1564 || code === 8206 || code === 8207)
|
|
808
|
+
return true;
|
|
809
|
+
if (code >= 8234 && code <= 8238)
|
|
810
|
+
return true;
|
|
811
|
+
if (code >= 8294 && code <= 8297)
|
|
812
|
+
return true;
|
|
813
|
+
return false;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
// src/view-model.ts
|
|
817
|
+
var PANEL_NAME = "prompt-logger.log";
|
|
818
|
+
var DETAIL_PAGE = 30;
|
|
819
|
+
var PREVIEW_LIMIT = 16 * 1024;
|
|
820
|
+
var FULL_SECTION_LIMIT = MAX_FULL_RECORD_BYTES;
|
|
821
|
+
var SECTION_PRETTY_SOURCE_CHARS = 4 * 1024 * 1024;
|
|
822
|
+
var SECTION_PRETTY_OUTPUT_CHARS = 8 * 1024 * 1024;
|
|
823
|
+
var BODY_PRETTY_SOURCE_CHARS = 256 * 1024;
|
|
824
|
+
var BODY_PRETTY_OUTPUT_CHARS = 1024 * 1024;
|
|
825
|
+
function splitKeyValueLine(line) {
|
|
826
|
+
const at = line.indexOf(":");
|
|
827
|
+
if (at <= 0)
|
|
828
|
+
return null;
|
|
829
|
+
return { key: line.slice(0, at), value: line.slice(at + 1) };
|
|
830
|
+
}
|
|
831
|
+
function tokenizeJson(text) {
|
|
832
|
+
const tokens = [];
|
|
833
|
+
const push = (value, kind) => {
|
|
834
|
+
if (value === "")
|
|
835
|
+
return;
|
|
836
|
+
const previous = tokens.at(-1);
|
|
837
|
+
if (previous !== undefined && previous.kind === kind) {
|
|
838
|
+
tokens[tokens.length - 1] = { text: previous.text + value, kind };
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
tokens.push({ text: value, kind });
|
|
842
|
+
};
|
|
843
|
+
let index = 0;
|
|
844
|
+
while (index < text.length) {
|
|
845
|
+
const char = text[index];
|
|
846
|
+
if (char === " " || char === "\t" || char === `
|
|
847
|
+
` || char === "\r") {
|
|
848
|
+
let end = index + 1;
|
|
849
|
+
while (end < text.length && /[ \t\n\r]/.test(text[end]))
|
|
850
|
+
end += 1;
|
|
851
|
+
push(text.slice(index, end), "plain");
|
|
852
|
+
index = end;
|
|
853
|
+
continue;
|
|
854
|
+
}
|
|
855
|
+
if (char === '"') {
|
|
856
|
+
let end = index + 1;
|
|
857
|
+
while (end < text.length) {
|
|
858
|
+
if (text[end] === "\\") {
|
|
859
|
+
end += 2;
|
|
860
|
+
continue;
|
|
861
|
+
}
|
|
862
|
+
end += 1;
|
|
863
|
+
if (text[end - 1] === '"')
|
|
864
|
+
break;
|
|
865
|
+
}
|
|
866
|
+
let lookahead = end;
|
|
867
|
+
while (lookahead < text.length && /[ \t\n\r]/.test(text[lookahead]))
|
|
868
|
+
lookahead += 1;
|
|
869
|
+
push(text.slice(index, end), text[lookahead] === ":" ? "key" : "string");
|
|
870
|
+
index = end;
|
|
871
|
+
continue;
|
|
872
|
+
}
|
|
873
|
+
if (char === "-" || char >= "0" && char <= "9") {
|
|
874
|
+
let end = index + 1;
|
|
875
|
+
while (end < text.length && /[0-9.eE+-]/.test(text[end]))
|
|
876
|
+
end += 1;
|
|
877
|
+
push(text.slice(index, end), "number");
|
|
878
|
+
index = end;
|
|
879
|
+
continue;
|
|
880
|
+
}
|
|
881
|
+
if (text.startsWith("true", index) || text.startsWith("false", index)) {
|
|
882
|
+
const value = text.startsWith("true", index) ? "true" : "false";
|
|
883
|
+
push(value, "boolean");
|
|
884
|
+
index += value.length;
|
|
885
|
+
continue;
|
|
886
|
+
}
|
|
887
|
+
if (text.startsWith("null", index)) {
|
|
888
|
+
push("null", "null");
|
|
889
|
+
index += 4;
|
|
890
|
+
continue;
|
|
891
|
+
}
|
|
892
|
+
if ("{}[],:".includes(char)) {
|
|
893
|
+
push(char, "punctuation");
|
|
894
|
+
index += 1;
|
|
895
|
+
continue;
|
|
896
|
+
}
|
|
897
|
+
let end = index + 1;
|
|
898
|
+
while (end < text.length) {
|
|
899
|
+
const next = text[end];
|
|
900
|
+
if (next === '"' || next === "-" || next >= "0" && next <= "9")
|
|
901
|
+
break;
|
|
902
|
+
if ("{}[],:".includes(next) || next === " " || next === "\t" || next === `
|
|
903
|
+
` || next === "\r")
|
|
904
|
+
break;
|
|
905
|
+
end += 1;
|
|
906
|
+
}
|
|
907
|
+
push(text.slice(index, end), "plain");
|
|
908
|
+
index = end;
|
|
909
|
+
}
|
|
910
|
+
return tokens;
|
|
911
|
+
}
|
|
912
|
+
var encoder = new TextEncoder;
|
|
913
|
+
function byteLength(text) {
|
|
914
|
+
return encoder.encode(text).length;
|
|
915
|
+
}
|
|
916
|
+
function formatBytes(bytes) {
|
|
917
|
+
if (!Number.isFinite(bytes) || bytes < 0)
|
|
918
|
+
return "?";
|
|
919
|
+
if (bytes < 1024)
|
|
920
|
+
return `${bytes} B`;
|
|
921
|
+
if (bytes < 1024 * 1024)
|
|
922
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
923
|
+
if (bytes < 1024 * 1024 * 1024)
|
|
924
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
925
|
+
return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
|
|
926
|
+
}
|
|
927
|
+
function formatTime(at) {
|
|
928
|
+
if (at === null)
|
|
929
|
+
return "\u2014";
|
|
930
|
+
const date = new Date(at);
|
|
931
|
+
if (Number.isNaN(date.getTime()))
|
|
932
|
+
return at.length > 19 ? at.slice(11, 19) : at;
|
|
933
|
+
return date.toISOString().slice(11, 19);
|
|
934
|
+
}
|
|
935
|
+
function modelLabel(model) {
|
|
936
|
+
if (model === null)
|
|
937
|
+
return "\u2014";
|
|
938
|
+
const base = [model.providerID, model.id].filter((part) => part !== undefined && part !== "").join("/");
|
|
939
|
+
if (base === "")
|
|
940
|
+
return "\u2014";
|
|
941
|
+
return model.variant === undefined ? base : `${base}/${model.variant}`;
|
|
942
|
+
}
|
|
943
|
+
function displayText(value, limit = 500) {
|
|
944
|
+
return sanitizeTerminal(value ?? "", limit);
|
|
945
|
+
}
|
|
946
|
+
function fitText(text, width) {
|
|
947
|
+
if (width <= 0)
|
|
948
|
+
return "";
|
|
949
|
+
if (text.length <= width)
|
|
950
|
+
return text;
|
|
951
|
+
return `${text.slice(0, Math.max(0, width - 1))}\u2026`;
|
|
952
|
+
}
|
|
953
|
+
function shortSession(sessionID) {
|
|
954
|
+
if (sessionID === null)
|
|
955
|
+
return "\u2014";
|
|
956
|
+
return sessionID.length <= 12 ? sessionID : sessionID.slice(0, 12);
|
|
957
|
+
}
|
|
958
|
+
function entryLine(entry) {
|
|
959
|
+
const base = entry.type === null ? "?" : entry.kind === null ? entry.type : `${entry.type}/${entry.kind}`;
|
|
960
|
+
const type = entry.hasBody === true && entry.type === "assembled" ? `${entry.kind ?? "assembled"}+http` : entry.hasBody === true && entry.type !== "http" ? `${base}+http` : base;
|
|
961
|
+
const extra = [
|
|
962
|
+
entry.messages === undefined ? null : `${entry.messages} msg`,
|
|
963
|
+
entry.hasBody === true ? "body" : null
|
|
964
|
+
].filter((value) => value !== null);
|
|
965
|
+
return sanitizeTerminal([
|
|
966
|
+
formatTime(entry.at),
|
|
967
|
+
type.padEnd(18),
|
|
968
|
+
shortSession(entry.sessionID).padEnd(12),
|
|
969
|
+
(entry.agent ?? "\u2014").padEnd(9),
|
|
970
|
+
modelLabel(entry.model).padEnd(26),
|
|
971
|
+
formatBytes(entry.bytes),
|
|
972
|
+
...extra
|
|
973
|
+
].join(" "), 400);
|
|
974
|
+
}
|
|
975
|
+
function entryTitle(entry) {
|
|
976
|
+
return sanitizeTerminal(`${formatTime(entry.at)} \xB7 ${entry.type ?? "unknown"}${entry.kind === null ? "" : `/${entry.kind}`} \xB7 ${entry.sessionID ?? "no session"} \xB7 ${formatBytes(entry.bytes)}${entry.messages === undefined ? "" : ` \xB7 ${entry.messages} messages`}${entry.hasBody === true ? " \xB7 HTTP body" : ""}`, 500);
|
|
977
|
+
}
|
|
978
|
+
function summaryKey(entry) {
|
|
979
|
+
return entry.key;
|
|
980
|
+
}
|
|
981
|
+
function mergeSummaries(current, incoming, limit = 200) {
|
|
982
|
+
if (incoming.length === 0)
|
|
983
|
+
return current;
|
|
984
|
+
const known = new Set(current.map(summaryKey));
|
|
985
|
+
const fresh = incoming.filter((entry) => !known.has(summaryKey(entry)));
|
|
986
|
+
const merged = [...fresh, ...current];
|
|
987
|
+
merged.sort((left, right) => right.cursor.localeCompare(left.cursor));
|
|
988
|
+
return merged.slice(0, limit);
|
|
989
|
+
}
|
|
990
|
+
function asObject(value) {
|
|
991
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
992
|
+
}
|
|
993
|
+
function textOf(value) {
|
|
994
|
+
if (typeof value === "string")
|
|
995
|
+
return value;
|
|
996
|
+
if (Array.isArray(value)) {
|
|
997
|
+
const parts = [];
|
|
998
|
+
for (const part of value) {
|
|
999
|
+
const record = asObject(part);
|
|
1000
|
+
if (record !== null && typeof record.text === "string")
|
|
1001
|
+
parts.push(record.text);
|
|
1002
|
+
}
|
|
1003
|
+
return parts.length === 0 ? null : parts.join(`
|
|
1004
|
+
|
|
1005
|
+
`);
|
|
1006
|
+
}
|
|
1007
|
+
return null;
|
|
1008
|
+
}
|
|
1009
|
+
function withText(title, text, limit, tone, language, full) {
|
|
1010
|
+
const preview = sanitizeTerminalInfo(text, limit);
|
|
1011
|
+
const expand = full && preview.truncated ? () => sanitizeTerminalInfo(text, FULL_SECTION_LIMIT).text : undefined;
|
|
1012
|
+
return {
|
|
1013
|
+
title,
|
|
1014
|
+
text: preview.text,
|
|
1015
|
+
tone,
|
|
1016
|
+
language,
|
|
1017
|
+
...preview.truncated ? { truncated: true } : {},
|
|
1018
|
+
...expand === undefined ? {} : { expand }
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
function prettyJson(value, sourceLimit, outputLimit) {
|
|
1022
|
+
const compact = JSON.stringify(value) ?? "null";
|
|
1023
|
+
if (compact.length > sourceLimit)
|
|
1024
|
+
return { text: compact, pretty: false };
|
|
1025
|
+
const pretty = JSON.stringify(value, null, 2) ?? compact;
|
|
1026
|
+
return pretty.length <= outputLimit ? { text: pretty, pretty: true } : { text: compact, pretty: false };
|
|
1027
|
+
}
|
|
1028
|
+
function jsonText(value) {
|
|
1029
|
+
return prettyJson(value, SECTION_PRETTY_SOURCE_CHARS, SECTION_PRETTY_OUTPUT_CHARS).text;
|
|
1030
|
+
}
|
|
1031
|
+
function section(title, value, limit, tone, language, full = false) {
|
|
1032
|
+
if (value === undefined || value === null)
|
|
1033
|
+
return null;
|
|
1034
|
+
const isText = typeof value === "string";
|
|
1035
|
+
const text = isText ? value : jsonText(value);
|
|
1036
|
+
if (text === undefined)
|
|
1037
|
+
return null;
|
|
1038
|
+
return withText(`${title} (${formatBytes(byteLength(text))})`, text, limit, tone, language ?? (isText ? "text" : "json"), full);
|
|
1039
|
+
}
|
|
1040
|
+
function httpSections(value, limit, title = "HTTP body", full = false) {
|
|
1041
|
+
const http = asObject(value);
|
|
1042
|
+
if (http === null)
|
|
1043
|
+
return [];
|
|
1044
|
+
const meta = [];
|
|
1045
|
+
if (typeof http.url === "string")
|
|
1046
|
+
meta.push(`url: ${http.url}`);
|
|
1047
|
+
if (typeof http.bodyEncoding === "string")
|
|
1048
|
+
meta.push(`encoding: ${http.bodyEncoding}`);
|
|
1049
|
+
if (typeof http.contentType === "string")
|
|
1050
|
+
meta.push(`content-type: ${http.contentType}`);
|
|
1051
|
+
if (typeof http.bodyBytes === "number")
|
|
1052
|
+
meta.push(`wire bytes: ${formatBytes(http.bodyBytes)}`);
|
|
1053
|
+
if (typeof http.decodedBytes === "number")
|
|
1054
|
+
meta.push(`decoded bytes: ${formatBytes(http.decodedBytes)}`);
|
|
1055
|
+
if (http.bodyTruncated === true || http.truncated === true) {
|
|
1056
|
+
meta.push(http.bodyCapped === true || http.truncated === true ? "the body was capped while capturing" : "the body was truncated for display");
|
|
1057
|
+
}
|
|
1058
|
+
const sections = [];
|
|
1059
|
+
if (meta.length > 0) {
|
|
1060
|
+
sections.push(withText(`${title} metadata`, meta.join(`
|
|
1061
|
+
`), limit, "http-meta", "key-value", full));
|
|
1062
|
+
}
|
|
1063
|
+
if (typeof http.body === "string") {
|
|
1064
|
+
let pretty = http.body;
|
|
1065
|
+
let language = "text";
|
|
1066
|
+
if (http.body.length <= BODY_PRETTY_SOURCE_CHARS) {
|
|
1067
|
+
try {
|
|
1068
|
+
const formatted = prettyJson(JSON.parse(http.body), BODY_PRETTY_SOURCE_CHARS, BODY_PRETTY_OUTPUT_CHARS);
|
|
1069
|
+
pretty = formatted.text;
|
|
1070
|
+
language = "json";
|
|
1071
|
+
} catch {}
|
|
1072
|
+
}
|
|
1073
|
+
sections.push(withText(`${title} (${formatBytes(byteLength(pretty))})`, pretty, limit, "http-body", language, full));
|
|
1074
|
+
} else if (typeof http.bodyBase64 === "string") {
|
|
1075
|
+
const preview = http.bodyBase64.slice(0, Math.min(2048, limit));
|
|
1076
|
+
const suffix = http.bodyBase64.length > preview.length ? `
|
|
1077
|
+
\u2026 [base64 preview truncated]` : "";
|
|
1078
|
+
sections.push(withText(`${title} (binary)`, `binary body
|
|
1079
|
+
${preview}${suffix}`, limit, "http-body", "text", false));
|
|
1080
|
+
} else if (http.bodyUnavailable === true) {
|
|
1081
|
+
sections.push({
|
|
1082
|
+
title: `${title} (unavailable)`,
|
|
1083
|
+
text: "the body blob is missing from the log",
|
|
1084
|
+
tone: "warning",
|
|
1085
|
+
language: "text"
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1088
|
+
return sections;
|
|
1089
|
+
}
|
|
1090
|
+
function sectionsFor(record, limit = PREVIEW_LIMIT, options = {}) {
|
|
1091
|
+
const full = options.full === true;
|
|
1092
|
+
const object = asObject(record);
|
|
1093
|
+
if (object === null) {
|
|
1094
|
+
return [withText("Record", String(record), limit, "warning", "text", full)];
|
|
1095
|
+
}
|
|
1096
|
+
const meta = [];
|
|
1097
|
+
for (const key of ["at", "type", "kind", "sessionID", "agent"]) {
|
|
1098
|
+
if (typeof object[key] === "string")
|
|
1099
|
+
meta.push(`${key}: ${object[key]}`);
|
|
1100
|
+
}
|
|
1101
|
+
const model = asObject(object.model);
|
|
1102
|
+
if (model !== null) {
|
|
1103
|
+
meta.push(`model: ${modelLabel({
|
|
1104
|
+
providerID: typeof model.providerID === "string" ? model.providerID : undefined,
|
|
1105
|
+
id: typeof model.id === "string" ? model.id : undefined,
|
|
1106
|
+
variant: typeof model.variant === "string" ? model.variant : undefined
|
|
1107
|
+
})}`);
|
|
1108
|
+
}
|
|
1109
|
+
if (typeof object.url === "string")
|
|
1110
|
+
meta.push(`url: ${object.url}`);
|
|
1111
|
+
const http = asObject(object.http);
|
|
1112
|
+
if (http !== null) {
|
|
1113
|
+
const encoding = typeof http.bodyEncoding === "string" ? http.bodyEncoding : "unknown";
|
|
1114
|
+
const size = typeof http.bodyBytes === "number" ? `, ${formatBytes(http.bodyBytes)} on the wire` : "";
|
|
1115
|
+
meta.push(http.bodyUnavailable === true ? "http body: missing blob" : `http body: captured (${encoding}${size})`);
|
|
1116
|
+
}
|
|
1117
|
+
const sections = [
|
|
1118
|
+
withText("Metadata", meta.join(`
|
|
1119
|
+
`) || "\u2014", limit, "metadata", "key-value", full)
|
|
1120
|
+
];
|
|
1121
|
+
if (object.type === "assembled") {
|
|
1122
|
+
const system = textOf(object.system);
|
|
1123
|
+
const systemSection = section("System prompt", system, limit, "system", "text", full);
|
|
1124
|
+
if (systemSection !== null)
|
|
1125
|
+
sections.push(systemSection);
|
|
1126
|
+
if (Array.isArray(object.messages)) {
|
|
1127
|
+
const total = typeof object.messageCount === "number" ? object.messageCount : object.messages.length;
|
|
1128
|
+
const roles = object.messages.map((message) => asObject(message)?.role).filter((role) => typeof role === "string");
|
|
1129
|
+
const summary = [
|
|
1130
|
+
`messages: ${total}`,
|
|
1131
|
+
...object.messages.length < total ? [`previewed: ${object.messages.length}`] : [],
|
|
1132
|
+
...roles.slice(0, 40).map((role, index) => `${index + 1}. ${role}`)
|
|
1133
|
+
];
|
|
1134
|
+
if (object.messages.length > 40)
|
|
1135
|
+
summary.push(`\u2026 ${object.messages.length - 40} more`);
|
|
1136
|
+
sections.push(withText("Messages", summary.join(`
|
|
1137
|
+
`), limit, "messages", "text", full));
|
|
1138
|
+
const raw = section("Messages (raw preview)", object.messages, limit, "messages", "json", full);
|
|
1139
|
+
if (raw !== null)
|
|
1140
|
+
sections.push(raw);
|
|
1141
|
+
}
|
|
1142
|
+
if (Array.isArray(object.tools)) {
|
|
1143
|
+
const tools = object.tools.filter((tool) => typeof tool === "string");
|
|
1144
|
+
sections.push(withText(`Tools (${tools.length})`, tools.join(", ") || "none", limit, "tools", "text", full));
|
|
1145
|
+
}
|
|
1146
|
+
if (object.http !== undefined) {
|
|
1147
|
+
sections.push(...httpSections(object.http, limit, "HTTP request", full));
|
|
1148
|
+
} else if (options.httpEnabled === false) {
|
|
1149
|
+
sections.push({
|
|
1150
|
+
title: "HTTP body (not captured)",
|
|
1151
|
+
text: "HTTP body logging is disabled, so the provider bytes for this request are not in the store. " + 'Enable "Log HTTP bodies" in the Prompt logger settings and repeat the request to capture them.',
|
|
1152
|
+
tone: "warning",
|
|
1153
|
+
language: "text"
|
|
1154
|
+
});
|
|
1155
|
+
}
|
|
1156
|
+
} else if (object.type === "http") {
|
|
1157
|
+
sections.push(...httpSections(object, limit, "HTTP body", full));
|
|
1158
|
+
} else {
|
|
1159
|
+
const raw = section("Record", record, limit, "metadata", "json", full);
|
|
1160
|
+
if (raw !== null)
|
|
1161
|
+
sections.push(raw);
|
|
1162
|
+
}
|
|
1163
|
+
return sections;
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
// src/detail-lines.ts
|
|
1167
|
+
function textLine(text, token) {
|
|
1168
|
+
return { segments: [{ text, ...token === undefined ? {} : { token } }] };
|
|
1169
|
+
}
|
|
1170
|
+
function jsonLines(text) {
|
|
1171
|
+
const lines = [];
|
|
1172
|
+
let segments = [];
|
|
1173
|
+
const flush = () => {
|
|
1174
|
+
lines.push({ segments: segments.length === 0 ? [{ text: "" }] : segments });
|
|
1175
|
+
segments = [];
|
|
1176
|
+
};
|
|
1177
|
+
for (const token of tokenizeJson(text)) {
|
|
1178
|
+
const parts = token.text.split(`
|
|
1179
|
+
`);
|
|
1180
|
+
for (let index = 0;index < parts.length; index += 1) {
|
|
1181
|
+
if (index > 0)
|
|
1182
|
+
flush();
|
|
1183
|
+
const part = parts[index] ?? "";
|
|
1184
|
+
if (part !== "") {
|
|
1185
|
+
segments.push({ text: part, ...token.kind === "plain" ? {} : { token: token.kind } });
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
flush();
|
|
1190
|
+
return lines;
|
|
1191
|
+
}
|
|
1192
|
+
function keyValueLines(text) {
|
|
1193
|
+
return text.split(`
|
|
1194
|
+
`).map((line) => {
|
|
1195
|
+
const parts = splitKeyValueLine(line);
|
|
1196
|
+
if (parts === null)
|
|
1197
|
+
return textLine(line);
|
|
1198
|
+
return {
|
|
1199
|
+
segments: [
|
|
1200
|
+
{ text: parts.key, token: "key" },
|
|
1201
|
+
{ text: ":", token: "punctuation" },
|
|
1202
|
+
{ text: parts.value, token: "value" }
|
|
1203
|
+
]
|
|
1204
|
+
};
|
|
1205
|
+
});
|
|
1206
|
+
}
|
|
1207
|
+
function bodyLines(section) {
|
|
1208
|
+
if (section.language === "json")
|
|
1209
|
+
return jsonLines(section.text);
|
|
1210
|
+
if (section.language === "key-value")
|
|
1211
|
+
return keyValueLines(section.text);
|
|
1212
|
+
return section.text.split(`
|
|
1213
|
+
`).map((line) => ({
|
|
1214
|
+
...textLine(line),
|
|
1215
|
+
...section.tone === "warning" ? { tone: section.tone } : {}
|
|
1216
|
+
}));
|
|
1217
|
+
}
|
|
1218
|
+
function detailLinesForSections(sections) {
|
|
1219
|
+
const lines = [];
|
|
1220
|
+
for (const section of sections) {
|
|
1221
|
+
lines.push({
|
|
1222
|
+
segments: [{ text: `== ${section.title} ==` }],
|
|
1223
|
+
...section.tone === undefined ? {} : { tone: section.tone },
|
|
1224
|
+
bold: true
|
|
1225
|
+
});
|
|
1226
|
+
lines.push(...bodyLines(section));
|
|
1227
|
+
lines.push(textLine(""));
|
|
1228
|
+
}
|
|
1229
|
+
return lines;
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
// src/tui-panel/detail.tsx
|
|
1233
|
+
import { spread as _$spread } from "@opentui/solid";
|
|
1234
|
+
import { mergeProps as _$mergeProps } from "@opentui/solid";
|
|
1235
|
+
import { createComponent as _$createComponent } from "@opentui/solid";
|
|
1236
|
+
import { effect as _$effect } from "@opentui/solid";
|
|
1237
|
+
import { createTextNode as _$createTextNode } from "@opentui/solid";
|
|
1238
|
+
import { insertNode as _$insertNode } from "@opentui/solid";
|
|
1239
|
+
import { memo as _$memo } from "@opentui/solid";
|
|
1240
|
+
import { insert as _$insert } from "@opentui/solid";
|
|
1241
|
+
import { setProp as _$setProp } from "@opentui/solid";
|
|
1242
|
+
import { createElement as _$createElement } from "@opentui/solid";
|
|
1243
|
+
import { TextAttributes } from "@opentui/core";
|
|
1244
|
+
import { For, Show } from "solid-js";
|
|
1245
|
+
function sectionColor(ctx, tone) {
|
|
1246
|
+
switch (tone) {
|
|
1247
|
+
case "metadata":
|
|
1248
|
+
return ctx.theme.text.muted;
|
|
1249
|
+
case "system":
|
|
1250
|
+
return ctx.theme.text.feedback.info.base;
|
|
1251
|
+
case "messages":
|
|
1252
|
+
return ctx.theme.text.feedback.success.base;
|
|
1253
|
+
case "tools":
|
|
1254
|
+
return ctx.theme.text.feedback.warning.base;
|
|
1255
|
+
case "http-meta":
|
|
1256
|
+
case "http-body":
|
|
1257
|
+
return ctx.theme.text.action.primary.base;
|
|
1258
|
+
case "warning":
|
|
1259
|
+
return ctx.theme.text.feedback.warning.base;
|
|
1260
|
+
default:
|
|
1261
|
+
return ctx.theme.text.base;
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
function tokenColor(ctx, token, fallback) {
|
|
1265
|
+
switch (token) {
|
|
1266
|
+
case "key":
|
|
1267
|
+
return ctx.theme.syntax.variable;
|
|
1268
|
+
case "string":
|
|
1269
|
+
return ctx.theme.syntax.string;
|
|
1270
|
+
case "number":
|
|
1271
|
+
return ctx.theme.syntax.number;
|
|
1272
|
+
case "boolean":
|
|
1273
|
+
return ctx.theme.syntax.keyword;
|
|
1274
|
+
case "null":
|
|
1275
|
+
return ctx.theme.syntax.comment;
|
|
1276
|
+
case "punctuation":
|
|
1277
|
+
return ctx.theme.syntax.punctuation;
|
|
1278
|
+
default:
|
|
1279
|
+
return fallback;
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
function DetailPane(props) {
|
|
1283
|
+
return (() => {
|
|
1284
|
+
var _el$ = _$createElement("box"), _el$2 = _$createElement("text"), _el$3 = _$createElement("text"), _el$4 = _$createTextNode(`section page `), _el$5 = _$createTextNode(` of `), _el$7 = _$createTextNode(` \xB7 j/k scroll \xB7 `), _el$9 = _$createTextNode(` \xB7 `), _el$1 = _$createTextNode(`esc back \xB7 q close`), _el$10 = _$createElement("text"), _el$14 = _$createElement("text"), _el$15 = _$createElement("text"), _el$16 = _$createTextNode(`\u2013`), _el$17 = _$createTextNode(` of `), _el$18 = _$createTextNode(` lines \xB7 the request is displayed as sanitized plain text`);
|
|
1285
|
+
_$insertNode(_el$, _el$2);
|
|
1286
|
+
_$insertNode(_el$, _el$3);
|
|
1287
|
+
_$insertNode(_el$, _el$10);
|
|
1288
|
+
_$insertNode(_el$, _el$14);
|
|
1289
|
+
_$insertNode(_el$, _el$15);
|
|
1290
|
+
_$setProp(_el$, "flexDirection", "column");
|
|
1291
|
+
_$setProp(_el$, "flexGrow", 1);
|
|
1292
|
+
_$insert(_el$2, () => entryTitle(props.detail.entry));
|
|
1293
|
+
_$insertNode(_el$3, _el$4);
|
|
1294
|
+
_$insertNode(_el$3, _el$5);
|
|
1295
|
+
_$insertNode(_el$3, _el$7);
|
|
1296
|
+
_$insertNode(_el$3, _el$9);
|
|
1297
|
+
_$insertNode(_el$3, _el$1);
|
|
1298
|
+
_$insert(_el$3, () => Math.floor(props.offset / DETAIL_PAGE) + 1, _el$5);
|
|
1299
|
+
_$insert(_el$3, () => Math.max(1, Math.ceil(props.lines.length / DETAIL_PAGE)), _el$7);
|
|
1300
|
+
_$insert(_el$3, (() => {
|
|
1301
|
+
var _c$ = _$memo(() => !!props.expanded);
|
|
1302
|
+
return () => _c$() ? "e collapse" : props.hasTruncated ? "e expand" : "no truncated sections";
|
|
1303
|
+
})(), _el$9);
|
|
1304
|
+
_$insert(_el$3, () => props.data?.moreAvailable === true ? "shift+e full \xB7 " : "", _el$1);
|
|
1305
|
+
_$insert(_el$, _$createComponent(Show, {
|
|
1306
|
+
get when() {
|
|
1307
|
+
return props.data?.truncated === true;
|
|
1308
|
+
},
|
|
1309
|
+
get children() {
|
|
1310
|
+
var _el$11 = _$createElement("text");
|
|
1311
|
+
_$insert(_el$11, (() => {
|
|
1312
|
+
var _c$2 = _$memo(() => props.data?.moreAvailable === true);
|
|
1313
|
+
return () => _c$2() ? `the request is ${formatBytes(props.data?.fullBytes ?? 0)} and is truncated at the ${formatBytes(MAX_RECORD_BYTES)} read budget; press shift+e to load the complete request` : `the request is ${formatBytes(props.data?.fullBytes ?? 0)}${(props.data?.fullBytes ?? 0) > MAX_FULL_RECORD_BYTES ? `, larger than the ${formatBytes(MAX_FULL_RECORD_BYTES)} viewer limit` : "; it is still truncated for display"}; the stored files may contain more`;
|
|
1314
|
+
})());
|
|
1315
|
+
_$effect((_$p) => _$setProp(_el$11, "fg", props.ctx.theme.text.feedback.warning.base, _$p));
|
|
1316
|
+
return _el$11;
|
|
1317
|
+
}
|
|
1318
|
+
}), _el$14);
|
|
1319
|
+
_$insert(_el$, _$createComponent(Show, {
|
|
1320
|
+
get when() {
|
|
1321
|
+
return props.loading;
|
|
1322
|
+
},
|
|
1323
|
+
get children() {
|
|
1324
|
+
var _el$12 = _$createElement("text");
|
|
1325
|
+
_$insertNode(_el$12, _$createTextNode(`loading the request\u2026`));
|
|
1326
|
+
_$effect((_$p) => _$setProp(_el$12, "fg", props.ctx.theme.text.muted, _$p));
|
|
1327
|
+
return _el$12;
|
|
1328
|
+
}
|
|
1329
|
+
}), _el$14);
|
|
1330
|
+
_$insert(_el$, _$createComponent(For, {
|
|
1331
|
+
get each() {
|
|
1332
|
+
return props.page;
|
|
1333
|
+
},
|
|
1334
|
+
children: (line) => {
|
|
1335
|
+
const lineColor = line.tone === undefined ? props.ctx.theme.text.base : sectionColor(props.ctx, line.tone);
|
|
1336
|
+
return (() => {
|
|
1337
|
+
var _el$19 = _$createElement("text");
|
|
1338
|
+
_$setProp(_el$19, "fg", lineColor);
|
|
1339
|
+
_$insert(_el$19, _$createComponent(For, {
|
|
1340
|
+
get each() {
|
|
1341
|
+
return line.segments;
|
|
1342
|
+
},
|
|
1343
|
+
children: (segment) => (() => {
|
|
1344
|
+
var _el$20 = _$createElement("span");
|
|
1345
|
+
_$spread(_el$20, _$mergeProps(() => ({
|
|
1346
|
+
fg: tokenColor(props.ctx, segment.token, lineColor)
|
|
1347
|
+
})), true);
|
|
1348
|
+
_$insert(_el$20, () => segment.text);
|
|
1349
|
+
return _el$20;
|
|
1350
|
+
})()
|
|
1351
|
+
}));
|
|
1352
|
+
_$effect((_$p) => _$setProp(_el$19, "attributes", line.bold === true ? TextAttributes.BOLD : undefined, _$p));
|
|
1353
|
+
return _el$19;
|
|
1354
|
+
})();
|
|
1355
|
+
}
|
|
1356
|
+
}), _el$14);
|
|
1357
|
+
_$insertNode(_el$15, _el$16);
|
|
1358
|
+
_$insertNode(_el$15, _el$17);
|
|
1359
|
+
_$insertNode(_el$15, _el$18);
|
|
1360
|
+
_$insert(_el$15, () => props.offset + 1, _el$16);
|
|
1361
|
+
_$insert(_el$15, () => Math.min(props.offset + DETAIL_PAGE, props.lines.length), _el$17);
|
|
1362
|
+
_$insert(_el$15, () => props.lines.length, _el$18);
|
|
1363
|
+
_$effect((_p$) => {
|
|
1364
|
+
var _v$ = props.ctx.theme.text.base, _v$2 = TextAttributes.BOLD, _v$3 = props.ctx.theme.text.muted, _v$4 = props.ctx.theme.text.muted, _v$5 = props.ctx.theme.text.muted, _v$6 = props.ctx.theme.text.muted;
|
|
1365
|
+
_v$ !== _p$.e && (_p$.e = _$setProp(_el$2, "fg", _v$, _p$.e));
|
|
1366
|
+
_v$2 !== _p$.t && (_p$.t = _$setProp(_el$2, "attributes", _v$2, _p$.t));
|
|
1367
|
+
_v$3 !== _p$.a && (_p$.a = _$setProp(_el$3, "fg", _v$3, _p$.a));
|
|
1368
|
+
_v$4 !== _p$.o && (_p$.o = _$setProp(_el$10, "fg", _v$4, _p$.o));
|
|
1369
|
+
_v$5 !== _p$.i && (_p$.i = _$setProp(_el$14, "fg", _v$5, _p$.i));
|
|
1370
|
+
_v$6 !== _p$.n && (_p$.n = _$setProp(_el$15, "fg", _v$6, _p$.n));
|
|
1371
|
+
return _p$;
|
|
1372
|
+
}, {
|
|
1373
|
+
e: undefined,
|
|
1374
|
+
t: undefined,
|
|
1375
|
+
a: undefined,
|
|
1376
|
+
o: undefined,
|
|
1377
|
+
i: undefined,
|
|
1378
|
+
n: undefined
|
|
1379
|
+
});
|
|
1380
|
+
return _el$;
|
|
1381
|
+
})();
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
// src/tui-panel/panel.tsx
|
|
1385
|
+
var TUI_SECTION_LIMIT = 256 * 1024;
|
|
1386
|
+
var BUDGET_PRESETS = [{
|
|
1387
|
+
title: "64 MB",
|
|
1388
|
+
value: 64 * 1024 * 1024
|
|
1389
|
+
}, {
|
|
1390
|
+
title: "256 MB",
|
|
1391
|
+
value: 256 * 1024 * 1024
|
|
1392
|
+
}, {
|
|
1393
|
+
title: "1 GB",
|
|
1394
|
+
value: 1024 * 1024 * 1024
|
|
1395
|
+
}, {
|
|
1396
|
+
title: "No budget",
|
|
1397
|
+
value: false
|
|
1398
|
+
}];
|
|
1399
|
+
function budgetLabel(value) {
|
|
1400
|
+
return value === 0 ? "no budget" : formatBytes(value);
|
|
1401
|
+
}
|
|
1402
|
+
function LogView(props) {
|
|
1403
|
+
const [status, setStatus] = createSignal();
|
|
1404
|
+
const [entries, setEntries] = createSignal([]);
|
|
1405
|
+
const [cursor, setCursor] = createSignal(0);
|
|
1406
|
+
const [scope, setScope] = createSignal(props.initialScope ?? (props.sessionID === undefined ? "all" : "session"));
|
|
1407
|
+
const [type, setType] = createSignal("all");
|
|
1408
|
+
const [filter, setFilter] = createSignal("");
|
|
1409
|
+
const [live, setLive] = createSignal(true);
|
|
1410
|
+
const [loading, setLoading] = createSignal(false);
|
|
1411
|
+
const [hasMore, setHasMore] = createSignal(false);
|
|
1412
|
+
const [error, setError] = createSignal();
|
|
1413
|
+
const [help, setHelp] = createSignal(false);
|
|
1414
|
+
const [detailData, setDetailData] = createSignal();
|
|
1415
|
+
const [expanded, setExpanded] = createSignal(false);
|
|
1416
|
+
const [detailLoading, setDetailLoading] = createSignal(false);
|
|
1417
|
+
const [detailOffset, setDetailOffset] = createSignal(0);
|
|
1418
|
+
const api = () => promptLogApi(props.ctx.client, props.ctx.location);
|
|
1419
|
+
let scroller;
|
|
1420
|
+
let listAbort;
|
|
1421
|
+
let detailAbort;
|
|
1422
|
+
let listGeneration = 0;
|
|
1423
|
+
let statusGeneration = 0;
|
|
1424
|
+
let pollTimer;
|
|
1425
|
+
let debounceTimer;
|
|
1426
|
+
let unsubscribe;
|
|
1427
|
+
let unsubscribeSettings;
|
|
1428
|
+
let disposed = false;
|
|
1429
|
+
let lastSearchKey = "";
|
|
1430
|
+
let lastSearchAt = 0;
|
|
1431
|
+
function isAbort(cause) {
|
|
1432
|
+
return cause !== null && typeof cause === "object" && "name" in cause && cause.name === "AbortError";
|
|
1433
|
+
}
|
|
1434
|
+
function toast(message, variant = "info") {
|
|
1435
|
+
props.ctx.ui.toast.show({
|
|
1436
|
+
message: displayText(message, 600),
|
|
1437
|
+
variant
|
|
1438
|
+
});
|
|
1439
|
+
}
|
|
1440
|
+
function listInput(cursorValue) {
|
|
1441
|
+
return {
|
|
1442
|
+
...scope() === "session" && props.sessionID !== undefined ? {
|
|
1443
|
+
sessionID: props.sessionID
|
|
1444
|
+
} : {},
|
|
1445
|
+
...type() === "all" ? {} : {
|
|
1446
|
+
type: type()
|
|
1447
|
+
},
|
|
1448
|
+
...filter().trim() === "" ? {} : {
|
|
1449
|
+
query: filter().trim()
|
|
1450
|
+
},
|
|
1451
|
+
limit: 50,
|
|
1452
|
+
...cursorValue === undefined ? {} : {
|
|
1453
|
+
cursor: cursorValue
|
|
1454
|
+
}
|
|
1455
|
+
};
|
|
1456
|
+
}
|
|
1457
|
+
async function refreshStatus() {
|
|
1458
|
+
const generation = ++statusGeneration;
|
|
1459
|
+
try {
|
|
1460
|
+
const next = await api().status();
|
|
1461
|
+
if (generation === statusGeneration) {
|
|
1462
|
+
setStatus(next);
|
|
1463
|
+
setError(undefined);
|
|
1464
|
+
}
|
|
1465
|
+
} catch (cause) {
|
|
1466
|
+
if (generation === statusGeneration && !isAbort(cause))
|
|
1467
|
+
setError(errorMessage(cause));
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
async function refreshList(mode = "refresh") {
|
|
1471
|
+
const generation = ++listGeneration;
|
|
1472
|
+
listAbort?.abort();
|
|
1473
|
+
const controller = new AbortController;
|
|
1474
|
+
listAbort = controller;
|
|
1475
|
+
setLoading(true);
|
|
1476
|
+
try {
|
|
1477
|
+
const query = filter().trim();
|
|
1478
|
+
if (query !== "") {
|
|
1479
|
+
if (mode === "more") {
|
|
1480
|
+
setHasMore(false);
|
|
1481
|
+
return;
|
|
1482
|
+
}
|
|
1483
|
+
const searchKey = `${query}\x00${scope()}\x00${props.sessionID ?? ""}\x00${type()}`;
|
|
1484
|
+
if (mode === "refresh" && searchKey === lastSearchKey && Date.now() - lastSearchAt < 5000)
|
|
1485
|
+
return;
|
|
1486
|
+
const result = await api().search({
|
|
1487
|
+
...scope() === "session" && props.sessionID !== undefined ? {
|
|
1488
|
+
sessionID: props.sessionID
|
|
1489
|
+
} : {},
|
|
1490
|
+
...type() === "all" ? {} : {
|
|
1491
|
+
type: type()
|
|
1492
|
+
},
|
|
1493
|
+
query,
|
|
1494
|
+
limit: 50,
|
|
1495
|
+
ignoreCase: true
|
|
1496
|
+
}, controller.signal);
|
|
1497
|
+
if (generation !== listGeneration)
|
|
1498
|
+
return;
|
|
1499
|
+
lastSearchKey = searchKey;
|
|
1500
|
+
lastSearchAt = Date.now();
|
|
1501
|
+
setEntries(result.matches.map((match) => match.entry));
|
|
1502
|
+
setHasMore(false);
|
|
1503
|
+
setError(result.error ?? undefined);
|
|
1504
|
+
setCursor(0);
|
|
1505
|
+
return;
|
|
1506
|
+
}
|
|
1507
|
+
const last = mode === "more" ? entries().at(-1) : undefined;
|
|
1508
|
+
const result = await api().list(listInput(last?.cursor), controller.signal);
|
|
1509
|
+
if (generation !== listGeneration)
|
|
1510
|
+
return;
|
|
1511
|
+
setError(result.error ?? undefined);
|
|
1512
|
+
if (mode === "reset") {
|
|
1513
|
+
setEntries(result.entries);
|
|
1514
|
+
setHasMore(result.hasMore);
|
|
1515
|
+
setCursor(0);
|
|
1516
|
+
} else if (mode === "more") {
|
|
1517
|
+
const known = new Set(entries().map(summaryKey));
|
|
1518
|
+
const next = [...entries(), ...result.entries.filter((entry) => !known.has(summaryKey(entry)))];
|
|
1519
|
+
setEntries(next.slice(0, 200));
|
|
1520
|
+
setHasMore(result.hasMore && next.length < 200);
|
|
1521
|
+
} else if (result.records === 0 && result.entries.length === 0) {
|
|
1522
|
+
setEntries([]);
|
|
1523
|
+
setHasMore(false);
|
|
1524
|
+
setCursor(0);
|
|
1525
|
+
} else {
|
|
1526
|
+
const merged = mergeSummaries(entries(), result.entries);
|
|
1527
|
+
setEntries(merged);
|
|
1528
|
+
if (result.hasMore)
|
|
1529
|
+
setHasMore(true);
|
|
1530
|
+
setCursor((value) => Math.min(value, Math.max(0, merged.length - 1)));
|
|
1531
|
+
}
|
|
1532
|
+
} catch (cause) {
|
|
1533
|
+
if (generation === listGeneration && !isAbort(cause))
|
|
1534
|
+
setError(errorMessage(cause));
|
|
1535
|
+
} finally {
|
|
1536
|
+
if (generation === listGeneration)
|
|
1537
|
+
setLoading(false);
|
|
1538
|
+
}
|
|
1539
|
+
}
|
|
1540
|
+
function schedulePoll(delay = 2000) {
|
|
1541
|
+
if (disposed || pollTimer !== undefined)
|
|
1542
|
+
return;
|
|
1543
|
+
pollTimer = setTimeout(() => {
|
|
1544
|
+
pollTimer = undefined;
|
|
1545
|
+
if (disposed)
|
|
1546
|
+
return;
|
|
1547
|
+
(async () => {
|
|
1548
|
+
await refreshStatus();
|
|
1549
|
+
await refreshList("refresh");
|
|
1550
|
+
if (!disposed && live())
|
|
1551
|
+
schedulePoll(2000);
|
|
1552
|
+
})();
|
|
1553
|
+
}, delay);
|
|
1554
|
+
pollTimer.unref?.();
|
|
1555
|
+
}
|
|
1556
|
+
function subscribe() {
|
|
1557
|
+
try {
|
|
1558
|
+
unsubscribe = api().onChanged((event) => {
|
|
1559
|
+
const current = status();
|
|
1560
|
+
if (current !== undefined && event.store !== current.store.path)
|
|
1561
|
+
return;
|
|
1562
|
+
if (event.reason === "truncate") {
|
|
1563
|
+
setEntries([]);
|
|
1564
|
+
setCursor(0);
|
|
1565
|
+
setDetailData(undefined);
|
|
1566
|
+
setDetailOffset(0);
|
|
1567
|
+
refreshStatus();
|
|
1568
|
+
refreshList("reset");
|
|
1569
|
+
return;
|
|
1570
|
+
}
|
|
1571
|
+
if (!live())
|
|
1572
|
+
return;
|
|
1573
|
+
if (debounceTimer !== undefined)
|
|
1574
|
+
return;
|
|
1575
|
+
debounceTimer = setTimeout(() => {
|
|
1576
|
+
debounceTimer = undefined;
|
|
1577
|
+
refreshStatus();
|
|
1578
|
+
refreshList("refresh");
|
|
1579
|
+
}, 250);
|
|
1580
|
+
debounceTimer.unref?.();
|
|
1581
|
+
});
|
|
1582
|
+
unsubscribeSettings = api().onSettingsChanged(() => {
|
|
1583
|
+
refreshStatus();
|
|
1584
|
+
});
|
|
1585
|
+
} catch {}
|
|
1586
|
+
}
|
|
1587
|
+
function move(delta) {
|
|
1588
|
+
const length = entries().length;
|
|
1589
|
+
if (length === 0)
|
|
1590
|
+
return;
|
|
1591
|
+
const next = Math.max(0, Math.min(length - 1, cursor() + delta));
|
|
1592
|
+
setCursor(next);
|
|
1593
|
+
queueMicrotask(() => scroller?.scrollChildIntoView?.(`row-${next}`));
|
|
1594
|
+
}
|
|
1595
|
+
function moveEdge(toEnd) {
|
|
1596
|
+
const length = entries().length;
|
|
1597
|
+
if (length === 0)
|
|
1598
|
+
return;
|
|
1599
|
+
const next = toEnd ? length - 1 : 0;
|
|
1600
|
+
setCursor(next);
|
|
1601
|
+
queueMicrotask(() => scroller?.scrollChildIntoView?.(`row-${next}`));
|
|
1602
|
+
}
|
|
1603
|
+
async function loadMore() {
|
|
1604
|
+
if (!hasMore() || loading())
|
|
1605
|
+
return;
|
|
1606
|
+
await refreshList("more");
|
|
1607
|
+
}
|
|
1608
|
+
async function readDetail(entry, full) {
|
|
1609
|
+
detailAbort?.abort();
|
|
1610
|
+
const controller = new AbortController;
|
|
1611
|
+
detailAbort = controller;
|
|
1612
|
+
setDetailLoading(true);
|
|
1613
|
+
try {
|
|
1614
|
+
const result = await api().read({
|
|
1615
|
+
key: entry.key,
|
|
1616
|
+
...full ? {
|
|
1617
|
+
maxBytes: MAX_FULL_RECORD_BYTES
|
|
1618
|
+
} : {}
|
|
1619
|
+
}, controller.signal);
|
|
1620
|
+
setDetailData({
|
|
1621
|
+
entry,
|
|
1622
|
+
record: result.record,
|
|
1623
|
+
truncated: result.truncated,
|
|
1624
|
+
moreAvailable: result.moreAvailable,
|
|
1625
|
+
fullBytes: result.fullBytes,
|
|
1626
|
+
httpEnabled: status()?.settings.http
|
|
1627
|
+
});
|
|
1628
|
+
setExpanded(full);
|
|
1629
|
+
setDetailOffset(0);
|
|
1630
|
+
} catch (cause) {
|
|
1631
|
+
if (!isAbort(cause))
|
|
1632
|
+
setError(errorMessage(cause));
|
|
1633
|
+
} finally {
|
|
1634
|
+
setDetailLoading(false);
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
async function openDetail() {
|
|
1638
|
+
const entry = entries()[cursor()];
|
|
1639
|
+
if (entry === undefined)
|
|
1640
|
+
return;
|
|
1641
|
+
await readDetail(entry, false);
|
|
1642
|
+
}
|
|
1643
|
+
async function loadFullDetail() {
|
|
1644
|
+
const data = detailData();
|
|
1645
|
+
if (data === undefined || data.moreAvailable !== true)
|
|
1646
|
+
return;
|
|
1647
|
+
await readDetail(data.entry, true);
|
|
1648
|
+
}
|
|
1649
|
+
function buildDetailSections(data, full) {
|
|
1650
|
+
const limit = full ? TUI_SECTION_LIMIT : PREVIEW_LIMIT;
|
|
1651
|
+
if (data.record === null) {
|
|
1652
|
+
return [{
|
|
1653
|
+
title: data.truncated ? "Record (truncated)" : "Record",
|
|
1654
|
+
text: "the record could not be read",
|
|
1655
|
+
tone: "warning",
|
|
1656
|
+
language: "text"
|
|
1657
|
+
}];
|
|
1658
|
+
}
|
|
1659
|
+
return sectionsFor(data.record, limit, {
|
|
1660
|
+
httpEnabled: data.httpEnabled
|
|
1661
|
+
});
|
|
1662
|
+
}
|
|
1663
|
+
const detail = createMemo(() => {
|
|
1664
|
+
const data = detailData();
|
|
1665
|
+
if (data === undefined)
|
|
1666
|
+
return;
|
|
1667
|
+
return {
|
|
1668
|
+
entry: data.entry,
|
|
1669
|
+
sections: buildDetailSections(data, expanded())
|
|
1670
|
+
};
|
|
1671
|
+
});
|
|
1672
|
+
const hasTruncated = createMemo(() => detail()?.sections.some((section) => section.truncated === true) ?? false);
|
|
1673
|
+
function closeDetail() {
|
|
1674
|
+
setDetailData(undefined);
|
|
1675
|
+
setExpanded(false);
|
|
1676
|
+
setDetailOffset(0);
|
|
1677
|
+
}
|
|
1678
|
+
function toggleExpand() {
|
|
1679
|
+
if (!expanded() && !hasTruncated())
|
|
1680
|
+
return;
|
|
1681
|
+
setExpanded((value) => !value);
|
|
1682
|
+
setDetailOffset(0);
|
|
1683
|
+
}
|
|
1684
|
+
const detailLines = createMemo(() => {
|
|
1685
|
+
const current = detail();
|
|
1686
|
+
if (current === undefined)
|
|
1687
|
+
return [];
|
|
1688
|
+
return detailLinesForSections(current.sections);
|
|
1689
|
+
});
|
|
1690
|
+
const detailPage = createMemo(() => detailLines().slice(detailOffset(), detailOffset() + DETAIL_PAGE));
|
|
1691
|
+
const rowWidth = () => Math.max(40, (props.width ?? 100) - 4);
|
|
1692
|
+
function scrollDetail(delta) {
|
|
1693
|
+
const total = detailLines().length;
|
|
1694
|
+
setDetailOffset((value) => Math.max(0, Math.min(Math.max(0, total - 1), value + delta)));
|
|
1695
|
+
}
|
|
1696
|
+
async function truncate(target) {
|
|
1697
|
+
if (status()?.settings.maintenance === false) {
|
|
1698
|
+
toast("delete actions are disabled in the settings", "warning");
|
|
1699
|
+
return;
|
|
1700
|
+
}
|
|
1701
|
+
if (target === "current" && props.sessionID === undefined) {
|
|
1702
|
+
toast("open a session to delete its log", "warning");
|
|
1703
|
+
return;
|
|
1704
|
+
}
|
|
1705
|
+
const what = target === "current" ? "this session's log" : "all session logs";
|
|
1706
|
+
const confirmed = await props.ctx.ui.dialog.confirm({
|
|
1707
|
+
title: "Delete the prompt log?",
|
|
1708
|
+
message: `This removes ${what}. The action cannot be undone.`,
|
|
1709
|
+
label: {
|
|
1710
|
+
confirm: "Delete",
|
|
1711
|
+
cancel: "Cancel"
|
|
1712
|
+
}
|
|
1713
|
+
});
|
|
1714
|
+
if (confirmed !== true)
|
|
1715
|
+
return;
|
|
1716
|
+
try {
|
|
1717
|
+
const result = await api().truncate(target, target === "current" ? props.sessionID : undefined);
|
|
1718
|
+
toast(`removed ${formatBytes(result.bytesFreed)}`, "success");
|
|
1719
|
+
setDetailData(undefined);
|
|
1720
|
+
setDetailOffset(0);
|
|
1721
|
+
await refreshStatus();
|
|
1722
|
+
await refreshList("reset");
|
|
1723
|
+
} catch (cause) {
|
|
1724
|
+
toast(errorMessage(cause), "warning");
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
async function applySettings(next) {
|
|
1728
|
+
try {
|
|
1729
|
+
await api().setSettings(next);
|
|
1730
|
+
toast("settings saved", "success");
|
|
1731
|
+
await refreshStatus();
|
|
1732
|
+
} catch (cause) {
|
|
1733
|
+
toast(errorMessage(cause), "warning");
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
async function applySessionScope(run) {
|
|
1737
|
+
try {
|
|
1738
|
+
const result = await run();
|
|
1739
|
+
toast(`logging: ${scopeLabel(result.sessionScope, result.settings.enabled, props.sessionID)}`, "success");
|
|
1740
|
+
await refreshStatus();
|
|
1741
|
+
} catch (cause) {
|
|
1742
|
+
toast(errorMessage(cause), "warning");
|
|
1743
|
+
}
|
|
1744
|
+
}
|
|
1745
|
+
async function toggleSessionScope() {
|
|
1746
|
+
const sessionID = props.sessionID;
|
|
1747
|
+
if (sessionID === undefined) {
|
|
1748
|
+
toast("open a session to log only that session", "info");
|
|
1749
|
+
return;
|
|
1750
|
+
}
|
|
1751
|
+
await applySessionScope(() => toggleSessionArmed(api(), sessionID));
|
|
1752
|
+
}
|
|
1753
|
+
async function settingsDialog() {
|
|
1754
|
+
const current = status();
|
|
1755
|
+
if (current === undefined) {
|
|
1756
|
+
toast("the prompt logger status is not available yet", "warning");
|
|
1757
|
+
return;
|
|
1758
|
+
}
|
|
1759
|
+
const settings = current.settings;
|
|
1760
|
+
const choice = await props.ctx.ui.dialog.select({
|
|
1761
|
+
title: "Prompt logger settings",
|
|
1762
|
+
options: [{
|
|
1763
|
+
title: `Logging: ${settings.enabled ? "on" : "off"}`,
|
|
1764
|
+
description: "Record one assembled request per model call: system prompt, messages, agent, model and tools. Off writes nothing and keeps the viewer available.",
|
|
1765
|
+
value: "enabled"
|
|
1766
|
+
}, {
|
|
1767
|
+
title: props.sessionID === undefined ? `Session scope: ${scopeLabel(current.sessionScope, settings.enabled)}` : `Log only this session: ${isSelected(current.sessionScope, props.sessionID) ? "on" : "off"}`,
|
|
1768
|
+
description: props.sessionID === undefined ? "All sessions are recorded by default. Select a session from its prompt log panel to record only that session. Clearing the selection pauses logging instead of recording everything." : "Record only this session from now on and pause the others. Turning it off pauses this session; it does not fall back to logging every session.",
|
|
1769
|
+
value: "sessionScope"
|
|
1770
|
+
}, {
|
|
1771
|
+
title: `HTTP bodies: ${settings.http ? "on" : "off"}`,
|
|
1772
|
+
description: "Capture the exact provider request body as bytes and link it to the assembled request. Gzip and binary bodies stay lossless. Usually the largest part of the store.",
|
|
1773
|
+
value: "http"
|
|
1774
|
+
}, {
|
|
1775
|
+
title: `Disk budget: ${budgetLabel(settings.diskBudget)}`,
|
|
1776
|
+
description: `Total size of all sessions. Oldest sessions are deleted first. Also keeps sessions for at most ${settings.retention.maxAgeDays === 0 ? "unlimited time" : `${settings.retention.maxAgeDays} days`} and ${settings.retention.maxSessions === null ? "unlimited sessions" : `${settings.retention.maxSessions} sessions`}.`,
|
|
1777
|
+
value: "budget"
|
|
1778
|
+
}, {
|
|
1779
|
+
title: `Retention age: ${settings.retentionMaxAgeDays === 0 ? "unlimited" : `${settings.retentionMaxAgeDays} days`}`,
|
|
1780
|
+
description: "Delete sessions whose last write is older than this when retention runs. Zero means unlimited.",
|
|
1781
|
+
value: "age"
|
|
1782
|
+
}, {
|
|
1783
|
+
title: `Retention sessions: ${settings.retentionMaxSessions === 0 ? "unlimited" : `${settings.retentionMaxSessions} sessions`}`,
|
|
1784
|
+
description: "Keep at most this many sessions after the age and byte limits are applied. Zero means unlimited.",
|
|
1785
|
+
value: "sessions"
|
|
1786
|
+
}, {
|
|
1787
|
+
title: `Storage directory: ${settings.directory === "" ? "default" : settings.directory}`,
|
|
1788
|
+
description: "Where the per-session store lives. The value is saved now and applies on the next server start; the current store keeps being used until then.",
|
|
1789
|
+
value: "directory"
|
|
1790
|
+
}, {
|
|
1791
|
+
title: `Delete actions: ${settings.maintenance ? "allowed" : "read-only"}`,
|
|
1792
|
+
description: "Allow destructive actions from the viewer. This is a UI guardrail, not a security boundary.",
|
|
1793
|
+
value: "maintenance"
|
|
1794
|
+
}, {
|
|
1795
|
+
title: "Reset to defaults",
|
|
1796
|
+
description: "Restore logging, HTTP capture, the disk budget, retention, the storage directory and delete actions to their built-in defaults. Does not delete data.",
|
|
1797
|
+
value: "reset"
|
|
1798
|
+
}]
|
|
1799
|
+
});
|
|
1800
|
+
if (choice === undefined)
|
|
1801
|
+
return;
|
|
1802
|
+
if (choice === "enabled") {
|
|
1803
|
+
await applySettings({
|
|
1804
|
+
...settings,
|
|
1805
|
+
enabled: !settings.enabled
|
|
1806
|
+
});
|
|
1807
|
+
return;
|
|
1808
|
+
}
|
|
1809
|
+
if (choice === "sessionScope") {
|
|
1810
|
+
if (props.sessionID !== undefined) {
|
|
1811
|
+
await toggleSessionScope();
|
|
1812
|
+
return;
|
|
1813
|
+
}
|
|
1814
|
+
const next = await props.ctx.ui.dialog.select({
|
|
1815
|
+
title: "Session scope",
|
|
1816
|
+
current: current.sessionScope?.mode,
|
|
1817
|
+
options: [{
|
|
1818
|
+
title: "Log all sessions",
|
|
1819
|
+
description: "Record every session again, subject to the master switch. The selected list is cleared; use a session panel to select one again.",
|
|
1820
|
+
value: "all"
|
|
1821
|
+
}, {
|
|
1822
|
+
title: "Clear selected sessions (pause)",
|
|
1823
|
+
description: "Keep the scope limited but select nothing: no session is recorded until one is selected again. It does not delete data.",
|
|
1824
|
+
value: "clear"
|
|
1825
|
+
}]
|
|
1826
|
+
});
|
|
1827
|
+
if (next === "all")
|
|
1828
|
+
await applySessionScope(() => api().updateSessionScope({
|
|
1829
|
+
mode: "all"
|
|
1830
|
+
}));
|
|
1831
|
+
if (next === "clear")
|
|
1832
|
+
await applySessionScope(() => api().updateSessionScope({
|
|
1833
|
+
action: "clear"
|
|
1834
|
+
}));
|
|
1835
|
+
return;
|
|
1836
|
+
}
|
|
1837
|
+
if (choice === "http") {
|
|
1838
|
+
await applySettings({
|
|
1839
|
+
...settings,
|
|
1840
|
+
http: !settings.http
|
|
1841
|
+
});
|
|
1842
|
+
return;
|
|
1843
|
+
}
|
|
1844
|
+
if (choice === "maintenance") {
|
|
1845
|
+
await applySettings({
|
|
1846
|
+
...settings,
|
|
1847
|
+
maintenance: !settings.maintenance
|
|
1848
|
+
});
|
|
1849
|
+
return;
|
|
1850
|
+
}
|
|
1851
|
+
if (choice === "reset") {
|
|
1852
|
+
try {
|
|
1853
|
+
await api().resetSettings();
|
|
1854
|
+
toast("settings reset to defaults", "success");
|
|
1855
|
+
await refreshStatus();
|
|
1856
|
+
} catch (cause) {
|
|
1857
|
+
toast(errorMessage(cause), "warning");
|
|
1858
|
+
}
|
|
1859
|
+
return;
|
|
1860
|
+
}
|
|
1861
|
+
if (choice === "directory") {
|
|
1862
|
+
const value = await props.ctx.ui.dialog.prompt({
|
|
1863
|
+
title: "Storage directory",
|
|
1864
|
+
description: "Absolute path, ~ path, or a path relative to the project. Leave empty for the platform default. Applies on the next server start.",
|
|
1865
|
+
value: settings.directory
|
|
1866
|
+
});
|
|
1867
|
+
if (value !== undefined) {
|
|
1868
|
+
await applySettings({
|
|
1869
|
+
...settings,
|
|
1870
|
+
directory: value.trim()
|
|
1871
|
+
});
|
|
1872
|
+
toast("storage directory saved; restart the server to apply", "info");
|
|
1873
|
+
}
|
|
1874
|
+
return;
|
|
1875
|
+
}
|
|
1876
|
+
if (choice === "age") {
|
|
1877
|
+
const value = await props.ctx.ui.dialog.select({
|
|
1878
|
+
title: "Retention age",
|
|
1879
|
+
current: settings.retentionMaxAgeDays,
|
|
1880
|
+
options: [{
|
|
1881
|
+
title: "Unlimited",
|
|
1882
|
+
description: "Never delete a session by age.",
|
|
1883
|
+
value: 0
|
|
1884
|
+
}, {
|
|
1885
|
+
title: "7 days",
|
|
1886
|
+
description: "Remove sessions inactive for more than a week.",
|
|
1887
|
+
value: 7
|
|
1888
|
+
}, {
|
|
1889
|
+
title: "30 days",
|
|
1890
|
+
description: "Default; remove sessions inactive for more than a month.",
|
|
1891
|
+
value: 30
|
|
1892
|
+
}, {
|
|
1893
|
+
title: "90 days",
|
|
1894
|
+
description: "Keep a quarter of history.",
|
|
1895
|
+
value: 90
|
|
1896
|
+
}, {
|
|
1897
|
+
title: "1 year",
|
|
1898
|
+
description: "Keep a year of history.",
|
|
1899
|
+
value: 365
|
|
1900
|
+
}]
|
|
1901
|
+
});
|
|
1902
|
+
if (value !== undefined)
|
|
1903
|
+
await applySettings({
|
|
1904
|
+
...settings,
|
|
1905
|
+
retentionMaxAgeDays: value
|
|
1906
|
+
});
|
|
1907
|
+
return;
|
|
1908
|
+
}
|
|
1909
|
+
if (choice === "sessions") {
|
|
1910
|
+
const value = await props.ctx.ui.dialog.select({
|
|
1911
|
+
title: "Retention session count",
|
|
1912
|
+
current: settings.retentionMaxSessions,
|
|
1913
|
+
options: [{
|
|
1914
|
+
title: "Unlimited",
|
|
1915
|
+
description: "Never delete by session count.",
|
|
1916
|
+
value: 0
|
|
1917
|
+
}, {
|
|
1918
|
+
title: "50 sessions",
|
|
1919
|
+
description: "Keep the 50 newest sessions.",
|
|
1920
|
+
value: 50
|
|
1921
|
+
}, {
|
|
1922
|
+
title: "200 sessions",
|
|
1923
|
+
description: "Default; keep the 200 newest sessions.",
|
|
1924
|
+
value: 200
|
|
1925
|
+
}, {
|
|
1926
|
+
title: "500 sessions",
|
|
1927
|
+
description: "Keep the 500 newest sessions.",
|
|
1928
|
+
value: 500
|
|
1929
|
+
}, {
|
|
1930
|
+
title: "1000 sessions",
|
|
1931
|
+
description: "Keep the 1000 newest sessions.",
|
|
1932
|
+
value: 1000
|
|
1933
|
+
}]
|
|
1934
|
+
});
|
|
1935
|
+
if (value !== undefined)
|
|
1936
|
+
await applySettings({
|
|
1937
|
+
...settings,
|
|
1938
|
+
retentionMaxSessions: value
|
|
1939
|
+
});
|
|
1940
|
+
return;
|
|
1941
|
+
}
|
|
1942
|
+
const value = await props.ctx.ui.dialog.select({
|
|
1943
|
+
title: "Retention disk budget",
|
|
1944
|
+
current: settings.diskBudget === 0 ? false : settings.diskBudget,
|
|
1945
|
+
options: BUDGET_PRESETS.map((preset) => ({
|
|
1946
|
+
title: preset.value === false ? "No budget" : preset.title,
|
|
1947
|
+
description: preset.value === false ? "No total byte budget. The age and session limits still apply." : `${preset.title} total budget across all sessions; the oldest sessions are removed first.`,
|
|
1948
|
+
value: preset.value
|
|
1949
|
+
}))
|
|
1950
|
+
});
|
|
1951
|
+
if (value !== undefined)
|
|
1952
|
+
await applySettings({
|
|
1953
|
+
...settings,
|
|
1954
|
+
diskBudget: value === false ? 0 : value
|
|
1955
|
+
});
|
|
1956
|
+
}
|
|
1957
|
+
async function filterDialog() {
|
|
1958
|
+
const value = await props.ctx.ui.dialog.prompt({
|
|
1959
|
+
title: "Search entries",
|
|
1960
|
+
description: "Searches the system prompt, messages, HTTP bodies and metadata. Leave empty to clear the search.",
|
|
1961
|
+
placeholder: "AGENTS.md, tool output, a model name\u2026",
|
|
1962
|
+
value: filter()
|
|
1963
|
+
});
|
|
1964
|
+
if (value !== undefined)
|
|
1965
|
+
setFilter(value.trim());
|
|
1966
|
+
}
|
|
1967
|
+
function toggleLive() {
|
|
1968
|
+
const next = !live();
|
|
1969
|
+
setLive(next);
|
|
1970
|
+
if (next)
|
|
1971
|
+
schedulePoll(0);
|
|
1972
|
+
}
|
|
1973
|
+
function toggleScope() {
|
|
1974
|
+
if (props.sessionID === undefined) {
|
|
1975
|
+
toast("No session is routed; the viewer shows all sessions", "info");
|
|
1976
|
+
return;
|
|
1977
|
+
}
|
|
1978
|
+
setScope(scope() === "session" ? "all" : "session");
|
|
1979
|
+
}
|
|
1980
|
+
function cycleType() {
|
|
1981
|
+
setType(type() === "all" ? "assembled" : type() === "assembled" ? "http" : "all");
|
|
1982
|
+
}
|
|
1983
|
+
function refreshAll() {
|
|
1984
|
+
refreshStatus();
|
|
1985
|
+
refreshList("reset");
|
|
1986
|
+
}
|
|
1987
|
+
const headerLines = createMemo(() => {
|
|
1988
|
+
const current = status();
|
|
1989
|
+
const path = current === undefined ? "\u2026" : props.ctx.ui.format.path(current.store.path);
|
|
1990
|
+
const settings = current?.settings;
|
|
1991
|
+
const lines = [`Prompt log${props.sessionID === undefined ? " \xB7 all sessions" : ""} \xB7 ${path}`, current === undefined ? "waiting for the prompt logger rpc\u2026" : `size ${formatBytes(current.store.bytes)} \xB7 ${current.cache.requests} requests`, settings === undefined ? `show ${scope()} \xB7 type ${type()} \xB7 live ${live() ? "on" : "off"}` : `show ${scope()} \xB7 type ${type()} \xB7 live ${live() ? "on" : "off"}${filter() === "" ? "" : ` \xB7 search \u201C${filter()}\u201D`} \xB7 logging ${scopeLabel(current?.sessionScope, settings.enabled, props.sessionID)} \xB7 http ${settings.http ? "on" : "off"} \xB7 budget ${budgetLabel(settings.diskBudget)}`];
|
|
1992
|
+
return lines.map((line) => displayText(line, 800));
|
|
1993
|
+
});
|
|
1994
|
+
const warningLines = createMemo(() => {
|
|
1995
|
+
const current = status();
|
|
1996
|
+
if (current === undefined)
|
|
1997
|
+
return [];
|
|
1998
|
+
const warnings = [];
|
|
1999
|
+
if (current.version !== CONTRACT_VERSION) {
|
|
2000
|
+
warnings.push(`the server plugin speaks contract ${current.version}; this viewer expects ${CONTRACT_VERSION}`);
|
|
2001
|
+
}
|
|
2002
|
+
for (const warning of current.store.warnings)
|
|
2003
|
+
warnings.push(warningLabel(warning));
|
|
2004
|
+
if (current.store.exists === false)
|
|
2005
|
+
warnings.push("the store does not exist yet");
|
|
2006
|
+
if (current.cache.error !== null)
|
|
2007
|
+
warnings.push(`cache: ${current.cache.error}`);
|
|
2008
|
+
if (current.settings.maintenance === false)
|
|
2009
|
+
warnings.push("delete actions are disabled in the settings");
|
|
2010
|
+
if (current.lastWriteError !== null) {
|
|
2011
|
+
warnings.push(`last write failed at ${current.lastWriteError.at}: ${current.lastWriteError.message}`);
|
|
2012
|
+
}
|
|
2013
|
+
return [...new Set(warnings)].map((warning) => displayText(warning, 800));
|
|
2014
|
+
});
|
|
2015
|
+
const emptyLines = createMemo(() => {
|
|
2016
|
+
const current = status();
|
|
2017
|
+
if (current?.settings.enabled === false) {
|
|
2018
|
+
return "logging is off; enable it from the settings (c)";
|
|
2019
|
+
}
|
|
2020
|
+
const sessionScope = current?.sessionScope;
|
|
2021
|
+
if (sessionScope?.mode === "only" && sessionScope.sessions.length === 0) {
|
|
2022
|
+
return "logging is paused; press c to log all sessions again";
|
|
2023
|
+
}
|
|
2024
|
+
if (sessionScope?.mode === "only") {
|
|
2025
|
+
if (props.sessionID !== undefined && !isSelected(sessionScope, props.sessionID)) {
|
|
2026
|
+
return `logging is limited to ${sessionScope.sessions.length} selected session${sessionScope.sessions.length === 1 ? "" : "s"}; press shift+l to record this session`;
|
|
2027
|
+
}
|
|
2028
|
+
if (props.sessionID === undefined) {
|
|
2029
|
+
return `logging is limited to ${sessionScope.sessions.length} selected session${sessionScope.sessions.length === 1 ? "" : "s"}`;
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
return "no entries yet; the store fills as requests are logged";
|
|
2033
|
+
});
|
|
2034
|
+
const listFooter = createMemo(() => {
|
|
2035
|
+
if (!help())
|
|
2036
|
+
return "j/k move \xB7 enter open \xB7 n more \xB7 ? help \xB7 esc close";
|
|
2037
|
+
return "j/k move \xB7 g/G first/last \xB7 enter open \xB7 n more \xB7 a show \xB7 t type \xB7 f search \xB7 l live \xB7 shift+l only this session \xB7 x delete session \xB7 R refresh \xB7 c settings \xB7 esc close";
|
|
2038
|
+
});
|
|
2039
|
+
const helpLines = createMemo(() => ["j/k or arrows move the cursor; g/G jump to the ends.", "Enter opens the assembled prompt, the messages and the raw HTTP body.", "n loads older entries; the viewer keeps at most 200 in memory.", "a changes what the viewer shows: this session or all sessions; t cycles the request type.", "shift+l records only this session and pauses the others. Turning it off pauses this session instead of logging every session.", "f searches prompt content: system prompt, messages, HTTP bodies and metadata.", "In a request, e expands or collapses the truncated sections and j/k scrolls.", "shift+e loads the complete request when the preview read budget was hit.", "x deletes this session's log, shift+x deletes every session log, and c opens settings. Retention prunes the store instead of rotating a file.", "The log contains unredacted prompts. Treat a screenshot or a copy as sensitive data."]);
|
|
2040
|
+
props.ctx.keymap.layer(() => {
|
|
2041
|
+
const command = (id, title, bind, run) => ({
|
|
2042
|
+
id,
|
|
2043
|
+
title,
|
|
2044
|
+
bind,
|
|
2045
|
+
run
|
|
2046
|
+
});
|
|
2047
|
+
if (detail() !== undefined) {
|
|
2048
|
+
return {
|
|
2049
|
+
commands: [command("prompt-logger.detail.up", "Scroll up", "up", () => scrollDetail(-1)), command("prompt-logger.detail.up.k", "Scroll up", "k", () => scrollDetail(-1)), command("prompt-logger.detail.down", "Scroll down", "down", () => scrollDetail(1)), command("prompt-logger.detail.down.j", "Scroll down", "j", () => scrollDetail(1)), command("prompt-logger.detail.page.up", "Page up", "pageup", () => scrollDetail(-DETAIL_PAGE)), command("prompt-logger.detail.page.down", "Page down", "pagedown", () => scrollDetail(DETAIL_PAGE)), command("prompt-logger.detail.home", "First line", "home", () => {
|
|
2050
|
+
setDetailOffset(0);
|
|
2051
|
+
}), command("prompt-logger.detail.end", "Last line", "end", () => {
|
|
2052
|
+
setDetailOffset(Math.max(0, detailLines().length - DETAIL_PAGE));
|
|
2053
|
+
}), command("prompt-logger.detail.expand", "Expand or collapse sections", "e", toggleExpand), command("prompt-logger.detail.full", "Load the complete request", "shift+e", () => void loadFullDetail()), command("prompt-logger.detail.back", "Back to the list", "escape", closeDetail), command("prompt-logger.detail.backspace", "Back to the list", "backspace", closeDetail), command("prompt-logger.detail.close", "Close the viewer", "q", () => props.close())]
|
|
2054
|
+
};
|
|
2055
|
+
}
|
|
2056
|
+
return {
|
|
2057
|
+
commands: [command("prompt-logger.up", "Move up", "up", () => move(-1)), command("prompt-logger.up.k", "Move up", "k", () => move(-1)), command("prompt-logger.down", "Move down", "down", () => move(1)), command("prompt-logger.down.j", "Move down", "j", () => move(1)), command("prompt-logger.page.up", "Page up", "pageup", () => move(-10)), command("prompt-logger.page.down", "Page down", "pagedown", () => move(10)), command("prompt-logger.first", "First entry", "g", () => moveEdge(false)), command("prompt-logger.last", "Last entry", "shift+g", () => moveEdge(true)), command("prompt-logger.open", "Open the record", "return", () => void openDetail()), command("prompt-logger.more", "Load older entries", "n", () => void loadMore()), command("prompt-logger.scope", "Toggle session/all sessions", "a", toggleScope), command("prompt-logger.type", "Cycle record type", "t", cycleType), command("prompt-logger.filter", "Filter entries", "f", () => void filterDialog()), command("prompt-logger.live", "Toggle live updates", "l", toggleLive), command("prompt-logger.only", "Log only this session", "shift+l", () => void toggleSessionScope()), command("prompt-logger.refresh", "Refresh", "shift+r", refreshAll), command("prompt-logger.truncate", "Delete this session's log", "x", () => void truncate("current")), command("prompt-logger.truncate.all", "Delete every session log", "shift+x", () => void truncate("all")), command("prompt-logger.settings", "Settings", "c", () => void settingsDialog()), command("prompt-logger.help", "Help", "?", () => {
|
|
2058
|
+
setHelp((value) => !value);
|
|
2059
|
+
}), command("prompt-logger.close", "Close the viewer", "escape", () => props.close()), command("prompt-logger.close.q", "Close the viewer", "q", () => props.close())]
|
|
2060
|
+
};
|
|
2061
|
+
});
|
|
2062
|
+
createEffect(on([scope, type, filter], () => {
|
|
2063
|
+
setCursor(0);
|
|
2064
|
+
setDetailData(undefined);
|
|
2065
|
+
setDetailOffset(0);
|
|
2066
|
+
refreshList("reset");
|
|
2067
|
+
}, {
|
|
2068
|
+
defer: true
|
|
2069
|
+
}));
|
|
2070
|
+
let settingsOpened = false;
|
|
2071
|
+
createEffect(() => {
|
|
2072
|
+
if (props.openSettings !== true || settingsOpened || status() === undefined)
|
|
2073
|
+
return;
|
|
2074
|
+
settingsOpened = true;
|
|
2075
|
+
settingsDialog();
|
|
2076
|
+
});
|
|
2077
|
+
refreshStatus();
|
|
2078
|
+
refreshList("reset");
|
|
2079
|
+
subscribe();
|
|
2080
|
+
schedulePoll(2000);
|
|
2081
|
+
onCleanup(() => {
|
|
2082
|
+
disposed = true;
|
|
2083
|
+
listAbort?.abort();
|
|
2084
|
+
detailAbort?.abort();
|
|
2085
|
+
if (pollTimer !== undefined)
|
|
2086
|
+
clearTimeout(pollTimer);
|
|
2087
|
+
if (debounceTimer !== undefined)
|
|
2088
|
+
clearTimeout(debounceTimer);
|
|
2089
|
+
unsubscribe?.();
|
|
2090
|
+
unsubscribeSettings?.();
|
|
2091
|
+
});
|
|
2092
|
+
const color = (tone) => {
|
|
2093
|
+
switch (tone) {
|
|
2094
|
+
case "muted":
|
|
2095
|
+
return props.ctx.theme.text.muted;
|
|
2096
|
+
case "warning":
|
|
2097
|
+
return props.ctx.theme.text.feedback.warning.base;
|
|
2098
|
+
case "accent":
|
|
2099
|
+
return props.ctx.theme.text.feedback.info.base;
|
|
2100
|
+
default:
|
|
2101
|
+
return props.ctx.theme.text.base;
|
|
2102
|
+
}
|
|
2103
|
+
};
|
|
2104
|
+
return (() => {
|
|
2105
|
+
var _el$ = _$createElement2("box");
|
|
2106
|
+
_$setProp2(_el$, "flexDirection", "column");
|
|
2107
|
+
_$setProp2(_el$, "paddingLeft", 1);
|
|
2108
|
+
_$setProp2(_el$, "paddingRight", 1);
|
|
2109
|
+
_$insert2(_el$, _$createComponent2(Show2, {
|
|
2110
|
+
get when() {
|
|
2111
|
+
return detail() !== undefined;
|
|
2112
|
+
},
|
|
2113
|
+
get fallback() {
|
|
2114
|
+
return (() => {
|
|
2115
|
+
var _el$2 = _$createElement2("scrollbox"), _el$3 = _$createElement2("text"), _el$0 = _$createElement2("text"), _el$1 = _$createElement2("text");
|
|
2116
|
+
_$insertNode2(_el$2, _el$3);
|
|
2117
|
+
_$insertNode2(_el$2, _el$0);
|
|
2118
|
+
_$insertNode2(_el$2, _el$1);
|
|
2119
|
+
_$use((target) => {
|
|
2120
|
+
scroller = target;
|
|
2121
|
+
const focusable = target;
|
|
2122
|
+
if (focusable !== null && typeof focusable === "object")
|
|
2123
|
+
focusable.focusable = false;
|
|
2124
|
+
}, _el$2);
|
|
2125
|
+
_$setProp2(_el$2, "flexGrow", 1);
|
|
2126
|
+
_$setProp2(_el$2, "scrollY", true);
|
|
2127
|
+
_$setProp2(_el$2, "verticalScrollbarOptions", {
|
|
2128
|
+
visible: true
|
|
2129
|
+
});
|
|
2130
|
+
_$insert2(_el$2, _$createComponent2(For2, {
|
|
2131
|
+
get each() {
|
|
2132
|
+
return headerLines();
|
|
2133
|
+
},
|
|
2134
|
+
children: (line) => (() => {
|
|
2135
|
+
var _el$10 = _$createElement2("text");
|
|
2136
|
+
_$insert2(_el$10, line);
|
|
2137
|
+
_$effect2((_$p) => _$setProp2(_el$10, "fg", color("base"), _$p));
|
|
2138
|
+
return _el$10;
|
|
2139
|
+
})()
|
|
2140
|
+
}), _el$3);
|
|
2141
|
+
_$insert2(_el$2, _$createComponent2(For2, {
|
|
2142
|
+
get each() {
|
|
2143
|
+
return warningLines();
|
|
2144
|
+
},
|
|
2145
|
+
children: (line) => (() => {
|
|
2146
|
+
var _el$11 = _$createElement2("text"), _el$12 = _$createTextNode2(`warning: `);
|
|
2147
|
+
_$insertNode2(_el$11, _el$12);
|
|
2148
|
+
_$insert2(_el$11, line, null);
|
|
2149
|
+
_$effect2((_$p) => _$setProp2(_el$11, "fg", color("warning"), _$p));
|
|
2150
|
+
return _el$11;
|
|
2151
|
+
})()
|
|
2152
|
+
}), _el$3);
|
|
2153
|
+
_$insert2(_el$2, _$createComponent2(Show2, {
|
|
2154
|
+
get when() {
|
|
2155
|
+
return help();
|
|
2156
|
+
},
|
|
2157
|
+
get children() {
|
|
2158
|
+
return [_$createComponent2(For2, {
|
|
2159
|
+
get each() {
|
|
2160
|
+
return helpLines();
|
|
2161
|
+
},
|
|
2162
|
+
children: (line) => (() => {
|
|
2163
|
+
var _el$13 = _$createElement2("text");
|
|
2164
|
+
_$insert2(_el$13, line);
|
|
2165
|
+
_$effect2((_$p) => _$setProp2(_el$13, "fg", color("muted"), _$p));
|
|
2166
|
+
return _el$13;
|
|
2167
|
+
})()
|
|
2168
|
+
}), (() => {
|
|
2169
|
+
var _el$4 = _$createElement2("text");
|
|
2170
|
+
_$effect2((_$p) => _$setProp2(_el$4, "fg", color("muted"), _$p));
|
|
2171
|
+
return _el$4;
|
|
2172
|
+
})()];
|
|
2173
|
+
}
|
|
2174
|
+
}), _el$0);
|
|
2175
|
+
_$insert2(_el$2, _$createComponent2(For2, {
|
|
2176
|
+
get each() {
|
|
2177
|
+
return entries();
|
|
2178
|
+
},
|
|
2179
|
+
children: (entry, index) => {
|
|
2180
|
+
const selected = () => index() === cursor();
|
|
2181
|
+
return (() => {
|
|
2182
|
+
var _el$14 = _$createElement2("text");
|
|
2183
|
+
_$insert2(_el$14, () => fitText(entryLine(entry), rowWidth()));
|
|
2184
|
+
_$effect2((_p$) => {
|
|
2185
|
+
var _v$4 = `row-${index()}`, _v$5 = entry.type === "http" ? color("accent") : color("base"), _v$6 = selected() ? props.ctx.theme.background.raised.high : undefined, _v$7 = selected() ? TextAttributes2.BOLD : undefined;
|
|
2186
|
+
_v$4 !== _p$.e && (_p$.e = _$setProp2(_el$14, "id", _v$4, _p$.e));
|
|
2187
|
+
_v$5 !== _p$.t && (_p$.t = _$setProp2(_el$14, "fg", _v$5, _p$.t));
|
|
2188
|
+
_v$6 !== _p$.a && (_p$.a = _$setProp2(_el$14, "bg", _v$6, _p$.a));
|
|
2189
|
+
_v$7 !== _p$.o && (_p$.o = _$setProp2(_el$14, "attributes", _v$7, _p$.o));
|
|
2190
|
+
return _p$;
|
|
2191
|
+
}, {
|
|
2192
|
+
e: undefined,
|
|
2193
|
+
t: undefined,
|
|
2194
|
+
a: undefined,
|
|
2195
|
+
o: undefined
|
|
2196
|
+
});
|
|
2197
|
+
return _el$14;
|
|
2198
|
+
})();
|
|
2199
|
+
}
|
|
2200
|
+
}), _el$0);
|
|
2201
|
+
_$insert2(_el$2, _$createComponent2(Show2, {
|
|
2202
|
+
get when() {
|
|
2203
|
+
return entries().length === 0;
|
|
2204
|
+
},
|
|
2205
|
+
get children() {
|
|
2206
|
+
var _el$5 = _$createElement2("text");
|
|
2207
|
+
_$insert2(_el$5, emptyLines);
|
|
2208
|
+
_$effect2((_$p) => _$setProp2(_el$5, "fg", color("muted"), _$p));
|
|
2209
|
+
return _el$5;
|
|
2210
|
+
}
|
|
2211
|
+
}), _el$0);
|
|
2212
|
+
_$insert2(_el$2, _$createComponent2(Show2, {
|
|
2213
|
+
get when() {
|
|
2214
|
+
return loading();
|
|
2215
|
+
},
|
|
2216
|
+
get children() {
|
|
2217
|
+
var _el$6 = _$createElement2("text");
|
|
2218
|
+
_$insertNode2(_el$6, _$createTextNode2(`loading\u2026`));
|
|
2219
|
+
_$effect2((_$p) => _$setProp2(_el$6, "fg", color("muted"), _$p));
|
|
2220
|
+
return _el$6;
|
|
2221
|
+
}
|
|
2222
|
+
}), _el$0);
|
|
2223
|
+
_$insert2(_el$2, _$createComponent2(Show2, {
|
|
2224
|
+
get when() {
|
|
2225
|
+
return error() !== undefined;
|
|
2226
|
+
},
|
|
2227
|
+
get children() {
|
|
2228
|
+
var _el$8 = _$createElement2("text"), _el$9 = _$createTextNode2(`error: `);
|
|
2229
|
+
_$insertNode2(_el$8, _el$9);
|
|
2230
|
+
_$insert2(_el$8, () => displayText(error(), 800), null);
|
|
2231
|
+
_$effect2((_$p) => _$setProp2(_el$8, "fg", color("warning"), _$p));
|
|
2232
|
+
return _el$8;
|
|
2233
|
+
}
|
|
2234
|
+
}), _el$0);
|
|
2235
|
+
_$insert2(_el$1, listFooter);
|
|
2236
|
+
_$effect2((_p$) => {
|
|
2237
|
+
var _v$ = color("muted"), _v$2 = color("muted"), _v$3 = color("muted");
|
|
2238
|
+
_v$ !== _p$.e && (_p$.e = _$setProp2(_el$3, "fg", _v$, _p$.e));
|
|
2239
|
+
_v$2 !== _p$.t && (_p$.t = _$setProp2(_el$0, "fg", _v$2, _p$.t));
|
|
2240
|
+
_v$3 !== _p$.a && (_p$.a = _$setProp2(_el$1, "fg", _v$3, _p$.a));
|
|
2241
|
+
return _p$;
|
|
2242
|
+
}, {
|
|
2243
|
+
e: undefined,
|
|
2244
|
+
t: undefined,
|
|
2245
|
+
a: undefined
|
|
2246
|
+
});
|
|
2247
|
+
return _el$2;
|
|
2248
|
+
})();
|
|
2249
|
+
},
|
|
2250
|
+
get children() {
|
|
2251
|
+
return _$createComponent2(Show2, {
|
|
2252
|
+
get when() {
|
|
2253
|
+
return detail();
|
|
2254
|
+
},
|
|
2255
|
+
children: (current) => _$createComponent2(DetailPane, {
|
|
2256
|
+
get ctx() {
|
|
2257
|
+
return props.ctx;
|
|
2258
|
+
},
|
|
2259
|
+
get detail() {
|
|
2260
|
+
return current();
|
|
2261
|
+
},
|
|
2262
|
+
get lines() {
|
|
2263
|
+
return detailLines();
|
|
2264
|
+
},
|
|
2265
|
+
get page() {
|
|
2266
|
+
return detailPage();
|
|
2267
|
+
},
|
|
2268
|
+
get offset() {
|
|
2269
|
+
return detailOffset();
|
|
2270
|
+
},
|
|
2271
|
+
get data() {
|
|
2272
|
+
return detailData();
|
|
2273
|
+
},
|
|
2274
|
+
get loading() {
|
|
2275
|
+
return detailLoading();
|
|
2276
|
+
},
|
|
2277
|
+
get expanded() {
|
|
2278
|
+
return expanded();
|
|
2279
|
+
},
|
|
2280
|
+
get hasTruncated() {
|
|
2281
|
+
return hasTruncated();
|
|
2282
|
+
}
|
|
2283
|
+
})
|
|
2284
|
+
});
|
|
2285
|
+
}
|
|
2286
|
+
}));
|
|
2287
|
+
return _el$;
|
|
2288
|
+
})();
|
|
2289
|
+
}
|
|
2290
|
+
|
|
2291
|
+
// src/tui-status.tsx
|
|
2292
|
+
import { createComponent as _$createComponent3 } from "@opentui/solid";
|
|
2293
|
+
import { setProp as _$setProp3 } from "@opentui/solid";
|
|
2294
|
+
import { effect as _$effect3 } from "@opentui/solid";
|
|
2295
|
+
import { insert as _$insert3 } from "@opentui/solid";
|
|
2296
|
+
import { createElement as _$createElement3 } from "@opentui/solid";
|
|
2297
|
+
import { Show as Show3, createSignal as createSignal2 } from "solid-js";
|
|
2298
|
+
|
|
2299
|
+
// src/logging-indicator.ts
|
|
2300
|
+
function loggingIndicator(state) {
|
|
2301
|
+
if (!state.enabled) {
|
|
2302
|
+
return { tone: "off", label: "log: off", detail: "Logging is off" };
|
|
2303
|
+
}
|
|
2304
|
+
const scope = state.scope;
|
|
2305
|
+
if (scope === undefined) {
|
|
2306
|
+
return { tone: "off", label: "log: unavailable", detail: "Prompt logger status is unavailable" };
|
|
2307
|
+
}
|
|
2308
|
+
if (scope.mode === "all") {
|
|
2309
|
+
return { tone: "recording", label: "log: all", detail: "Recording all sessions" };
|
|
2310
|
+
}
|
|
2311
|
+
const sessionID = state.sessionID;
|
|
2312
|
+
if (sessionID !== undefined) {
|
|
2313
|
+
if (isSelected(scope, sessionID)) {
|
|
2314
|
+
return { tone: "recording", label: "log: this", detail: "Recording this session only" };
|
|
2315
|
+
}
|
|
2316
|
+
return {
|
|
2317
|
+
tone: "paused",
|
|
2318
|
+
label: "log: paused",
|
|
2319
|
+
detail: "Logging is on, but paused for this session"
|
|
2320
|
+
};
|
|
2321
|
+
}
|
|
2322
|
+
const count = scope.sessions.length;
|
|
2323
|
+
if (count === 0) {
|
|
2324
|
+
return { tone: "paused", label: "log: paused", detail: "Logging is paused: no session is selected" };
|
|
2325
|
+
}
|
|
2326
|
+
return {
|
|
2327
|
+
tone: "recording",
|
|
2328
|
+
label: `log: ${count}`,
|
|
2329
|
+
detail: count === 1 ? "Recording 1 session" : `Recording ${count} sessions`
|
|
2330
|
+
};
|
|
2331
|
+
}
|
|
2332
|
+
|
|
2333
|
+
// src/tui-status.tsx
|
|
2334
|
+
function createLoggingSnapshot(ctx) {
|
|
2335
|
+
const [snapshot, setSnapshot] = createSignal2();
|
|
2336
|
+
const api = promptLogApi(ctx.client, ctx.location);
|
|
2337
|
+
let disposed = false;
|
|
2338
|
+
const apply = (enabled, scope) => {
|
|
2339
|
+
if (disposed)
|
|
2340
|
+
return;
|
|
2341
|
+
setSnapshot({
|
|
2342
|
+
enabled,
|
|
2343
|
+
scope
|
|
2344
|
+
});
|
|
2345
|
+
};
|
|
2346
|
+
const refresh = async () => {
|
|
2347
|
+
try {
|
|
2348
|
+
const status = await api.status();
|
|
2349
|
+
apply(status.settings.enabled, status.sessionScope);
|
|
2350
|
+
} catch {}
|
|
2351
|
+
};
|
|
2352
|
+
refresh();
|
|
2353
|
+
let unsubscribeSettings = () => {};
|
|
2354
|
+
try {
|
|
2355
|
+
unsubscribeSettings = api.onSettingsChanged((event) => {
|
|
2356
|
+
apply(event.settings.enabled, event.sessionScope);
|
|
2357
|
+
});
|
|
2358
|
+
} catch {}
|
|
2359
|
+
let unsubscribeConnected = () => {};
|
|
2360
|
+
try {
|
|
2361
|
+
if (typeof ctx.data?.on === "function") {
|
|
2362
|
+
unsubscribeConnected = ctx.data.on("server.connected", () => {
|
|
2363
|
+
refresh();
|
|
2364
|
+
});
|
|
2365
|
+
}
|
|
2366
|
+
} catch {}
|
|
2367
|
+
return {
|
|
2368
|
+
current: snapshot,
|
|
2369
|
+
dispose() {
|
|
2370
|
+
disposed = true;
|
|
2371
|
+
unsubscribeSettings();
|
|
2372
|
+
unsubscribeConnected();
|
|
2373
|
+
}
|
|
2374
|
+
};
|
|
2375
|
+
}
|
|
2376
|
+
function LoggingBadge(props) {
|
|
2377
|
+
const indicator = () => {
|
|
2378
|
+
const current = props.snapshot();
|
|
2379
|
+
if (current === undefined)
|
|
2380
|
+
return;
|
|
2381
|
+
return loggingIndicator({
|
|
2382
|
+
enabled: current.enabled,
|
|
2383
|
+
scope: current.scope,
|
|
2384
|
+
...props.sessionID === undefined ? {} : {
|
|
2385
|
+
sessionID: props.sessionID
|
|
2386
|
+
}
|
|
2387
|
+
});
|
|
2388
|
+
};
|
|
2389
|
+
const visible = () => {
|
|
2390
|
+
const current = indicator();
|
|
2391
|
+
return current !== undefined && current.tone !== "off";
|
|
2392
|
+
};
|
|
2393
|
+
const color = () => {
|
|
2394
|
+
const tone = indicator()?.tone;
|
|
2395
|
+
if (tone === "recording")
|
|
2396
|
+
return props.theme.text.feedback.success.base;
|
|
2397
|
+
if (tone === "paused")
|
|
2398
|
+
return props.theme.text.feedback.warning.base;
|
|
2399
|
+
return props.theme.text.muted;
|
|
2400
|
+
};
|
|
2401
|
+
const label = () => {
|
|
2402
|
+
const current = indicator();
|
|
2403
|
+
if (current === undefined)
|
|
2404
|
+
return "";
|
|
2405
|
+
return `${current.tone === "paused" ? "\u25D0" : "\u25CF"} ${current.label}`;
|
|
2406
|
+
};
|
|
2407
|
+
return _$createComponent3(Show3, {
|
|
2408
|
+
get when() {
|
|
2409
|
+
return visible();
|
|
2410
|
+
},
|
|
2411
|
+
get children() {
|
|
2412
|
+
var _el$ = _$createElement3("text");
|
|
2413
|
+
_$insert3(_el$, label);
|
|
2414
|
+
_$effect3((_$p) => _$setProp3(_el$, "fg", color(), _$p));
|
|
2415
|
+
return _el$;
|
|
2416
|
+
}
|
|
2417
|
+
});
|
|
2418
|
+
}
|
|
2419
|
+
|
|
2420
|
+
// src/tui.tsx
|
|
2421
|
+
var PAGE_NAME = "prompt-logger";
|
|
2422
|
+
var tui_default = Plugin.define({
|
|
2423
|
+
id: "prompt-logger.tui",
|
|
2424
|
+
setup(ctx) {
|
|
2425
|
+
const logging = createLoggingSnapshot(ctx);
|
|
2426
|
+
const disposePage = ctx.ui.router.register({
|
|
2427
|
+
name: PAGE_NAME,
|
|
2428
|
+
render: (input) => _$createComponent4(LogView, {
|
|
2429
|
+
ctx,
|
|
2430
|
+
initialScope: "all",
|
|
2431
|
+
get openSettings() {
|
|
2432
|
+
return input.data?.settings === true;
|
|
2433
|
+
},
|
|
2434
|
+
get width() {
|
|
2435
|
+
return ctx.renderer.width;
|
|
2436
|
+
},
|
|
2437
|
+
close: () => ctx.ui.router.navigate({
|
|
2438
|
+
type: "home"
|
|
2439
|
+
})
|
|
2440
|
+
})
|
|
2441
|
+
});
|
|
2442
|
+
const disposePanel = ctx.ui.slot({
|
|
2443
|
+
append: "session.panel",
|
|
2444
|
+
render: (input) => input.name === PANEL_NAME ? _$createComponent4(LogView, {
|
|
2445
|
+
ctx,
|
|
2446
|
+
get sessionID() {
|
|
2447
|
+
return input.sessionID;
|
|
2448
|
+
},
|
|
2449
|
+
get width() {
|
|
2450
|
+
return input.width;
|
|
2451
|
+
},
|
|
2452
|
+
close: () => input.close()
|
|
2453
|
+
}) : null
|
|
2454
|
+
});
|
|
2455
|
+
const disposeSessionStatus = ctx.ui.slot({
|
|
2456
|
+
append: "prompt.footer.status",
|
|
2457
|
+
render: (input) => _$createComponent4(LoggingBadge, {
|
|
2458
|
+
get snapshot() {
|
|
2459
|
+
return logging.current;
|
|
2460
|
+
},
|
|
2461
|
+
get theme() {
|
|
2462
|
+
return ctx.theme;
|
|
2463
|
+
},
|
|
2464
|
+
get sessionID() {
|
|
2465
|
+
return input.sessionID;
|
|
2466
|
+
}
|
|
2467
|
+
})
|
|
2468
|
+
});
|
|
2469
|
+
const disposeHomeStatus = ctx.ui.slot({
|
|
2470
|
+
append: "home.footer.status",
|
|
2471
|
+
render: () => _$createComponent4(LoggingBadge, {
|
|
2472
|
+
get snapshot() {
|
|
2473
|
+
return logging.current;
|
|
2474
|
+
},
|
|
2475
|
+
get theme() {
|
|
2476
|
+
return ctx.theme;
|
|
2477
|
+
}
|
|
2478
|
+
})
|
|
2479
|
+
});
|
|
2480
|
+
ctx.keymap.layer(() => {
|
|
2481
|
+
return {
|
|
2482
|
+
mode: "global",
|
|
2483
|
+
commands: [{
|
|
2484
|
+
id: "prompt-logger.open",
|
|
2485
|
+
title: "Prompt log",
|
|
2486
|
+
description: "Inspect the assembled prompt and, when enabled, the raw request body",
|
|
2487
|
+
group: "Prompt logger",
|
|
2488
|
+
bind: false,
|
|
2489
|
+
palette: true,
|
|
2490
|
+
slash: {
|
|
2491
|
+
name: "prompt-log"
|
|
2492
|
+
},
|
|
2493
|
+
run: () => {
|
|
2494
|
+
if (ctx.ui.panel.current()?.name === PANEL_NAME) {
|
|
2495
|
+
ctx.ui.panel.close();
|
|
2496
|
+
return;
|
|
2497
|
+
}
|
|
2498
|
+
if (!ctx.ui.panel.open(PANEL_NAME, {
|
|
2499
|
+
presentation: "fullscreen"
|
|
2500
|
+
})) {
|
|
2501
|
+
ctx.ui.router.navigate({
|
|
2502
|
+
type: "plugin",
|
|
2503
|
+
name: PAGE_NAME
|
|
2504
|
+
});
|
|
2505
|
+
}
|
|
2506
|
+
}
|
|
2507
|
+
}, {
|
|
2508
|
+
id: "prompt-logger.settings",
|
|
2509
|
+
title: "Prompt logger settings",
|
|
2510
|
+
description: "Configure logging and maintain the prompt log without a session",
|
|
2511
|
+
group: "Prompt logger",
|
|
2512
|
+
bind: false,
|
|
2513
|
+
palette: true,
|
|
2514
|
+
run: () => {
|
|
2515
|
+
ctx.ui.router.navigate({
|
|
2516
|
+
type: "plugin",
|
|
2517
|
+
name: PAGE_NAME,
|
|
2518
|
+
data: {
|
|
2519
|
+
settings: true
|
|
2520
|
+
}
|
|
2521
|
+
});
|
|
2522
|
+
}
|
|
2523
|
+
}, {
|
|
2524
|
+
id: "prompt-logger.only",
|
|
2525
|
+
title: "Log only this session",
|
|
2526
|
+
description: "Record model requests for the current session and pause the others",
|
|
2527
|
+
group: "Prompt logger",
|
|
2528
|
+
bind: false,
|
|
2529
|
+
palette: true,
|
|
2530
|
+
slash: {
|
|
2531
|
+
name: "prompt-log-only"
|
|
2532
|
+
},
|
|
2533
|
+
run: async () => {
|
|
2534
|
+
const route = ctx.ui.router.current();
|
|
2535
|
+
if (route.type !== "session") {
|
|
2536
|
+
ctx.ui.toast.show({
|
|
2537
|
+
message: "open a session to log only that session",
|
|
2538
|
+
variant: "info"
|
|
2539
|
+
});
|
|
2540
|
+
return;
|
|
2541
|
+
}
|
|
2542
|
+
try {
|
|
2543
|
+
const result = await toggleSessionArmed(promptLogApi(ctx.client, ctx.location), route.sessionID);
|
|
2544
|
+
ctx.ui.toast.show({
|
|
2545
|
+
message: `logging: ${scopeLabel(result.sessionScope, result.settings.enabled, route.sessionID)}`,
|
|
2546
|
+
variant: "success"
|
|
2547
|
+
});
|
|
2548
|
+
} catch (cause) {
|
|
2549
|
+
ctx.ui.toast.show({
|
|
2550
|
+
message: errorMessage(cause),
|
|
2551
|
+
variant: "warning"
|
|
2552
|
+
});
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
}]
|
|
2556
|
+
};
|
|
2557
|
+
});
|
|
2558
|
+
return () => {
|
|
2559
|
+
disposePage();
|
|
2560
|
+
disposePanel();
|
|
2561
|
+
disposeSessionStatus();
|
|
2562
|
+
disposeHomeStatus();
|
|
2563
|
+
logging.dispose();
|
|
2564
|
+
};
|
|
2565
|
+
}
|
|
2566
|
+
});
|
|
2567
|
+
export {
|
|
2568
|
+
tui_default as default
|
|
2569
|
+
};
|
|
2570
|
+
|
|
2571
|
+
//# debugId=10760FA9AAE231EC64756E2164756E21
|