@khorsheed/dsh-context-lens 0.0.0-stage → 0.1.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/CHANGELOG.md +16 -0
- package/README.en.md +53 -0
- package/README.i18n.yaml +6 -0
- package/README.md +52 -2
- package/cordis.patch.yml +13 -0
- package/lib/client.js +26953 -0
- package/lib/index.js +3943 -0
- package/lib/typert.host.d.ts +3 -0
- package/lib/typert.host.js +1569 -0
- package/lib/typert.remote-client.d.ts +40 -0
- package/lib/typert.remote-client.js +1202 -0
- package/lib/types/changes.d.ts +72 -0
- package/lib/types/changes.js +328 -0
- package/lib/types/client/AgentTabs.d.ts +34 -0
- package/lib/types/client/AgentTabs.js +89 -0
- package/lib/types/client/ChangeList.d.ts +28 -0
- package/lib/types/client/ChangeList.js +109 -0
- package/lib/types/client/ConfigFacts.d.ts +21 -0
- package/lib/types/client/ConfigFacts.js +30 -0
- package/lib/types/client/HeaderUtility.d.ts +12 -0
- package/lib/types/client/HeaderUtility.js +8 -0
- package/lib/types/client/InspectorPanel.d.ts +5 -0
- package/lib/types/client/InspectorPanel.js +486 -0
- package/lib/types/client/RawView.d.ts +18 -0
- package/lib/types/client/RawView.js +8 -0
- package/lib/types/client/RequestFacts.d.ts +19 -0
- package/lib/types/client/RequestFacts.js +39 -0
- package/lib/types/client/RoomDecisionsView.d.ts +24 -0
- package/lib/types/client/RoomDecisionsView.js +52 -0
- package/lib/types/client/SchemaFields.d.ts +13 -0
- package/lib/types/client/SchemaFields.js +96 -0
- package/lib/types/client/SegCtl.d.ts +32 -0
- package/lib/types/client/SegCtl.js +12 -0
- package/lib/types/client/SegmentBlocks.d.ts +28 -0
- package/lib/types/client/SegmentBlocks.js +225 -0
- package/lib/types/client/TimingView.d.ts +17 -0
- package/lib/types/client/TimingView.js +98 -0
- package/lib/types/client/TokenView.d.ts +21 -0
- package/lib/types/client/TokenView.js +22 -0
- package/lib/types/client/ToolCatalog.d.ts +9 -0
- package/lib/types/client/ToolCatalog.js +51 -0
- package/lib/types/client/Trend.d.ts +25 -0
- package/lib/types/client/Trend.js +100 -0
- package/lib/types/client/TurnAction.d.ts +14 -0
- package/lib/types/client/TurnAction.js +31 -0
- package/lib/types/client/TurnMenu.d.ts +36 -0
- package/lib/types/client/TurnMenu.js +50 -0
- package/lib/types/client/aggregate.d.ts +141 -0
- package/lib/types/client/aggregate.js +213 -0
- package/lib/types/client/contract.d.ts +58 -0
- package/lib/types/client/contract.js +1 -0
- package/lib/types/client/definition.d.ts +47 -0
- package/lib/types/client/definition.js +25 -0
- package/lib/types/client/icons-local.d.ts +19 -0
- package/lib/types/client/icons-local.js +3 -0
- package/lib/types/client/icons.d.ts +18 -0
- package/lib/types/client/icons.js +2 -0
- package/lib/types/client/index.d.ts +42 -0
- package/lib/types/client/index.js +139 -0
- package/lib/types/client/locales.d.ts +365 -0
- package/lib/types/client/locales.js +705 -0
- package/lib/types/client/preset-visibility.d.ts +99 -0
- package/lib/types/client/preset-visibility.js +108 -0
- package/lib/types/client/scroll-sync.d.ts +54 -0
- package/lib/types/client/scroll-sync.js +118 -0
- package/lib/types/client/timing.d.ts +29 -0
- package/lib/types/client/timing.js +117 -0
- package/lib/types/client/wire.d.ts +13 -0
- package/lib/types/client/wire.js +11 -0
- package/lib/types/index.d.ts +32 -0
- package/lib/types/index.js +25 -0
- package/lib/types/log-lane.d.ts +198 -0
- package/lib/types/log-lane.js +841 -0
- package/lib/types/messages.d.ts +96 -0
- package/lib/types/messages.js +254 -0
- package/lib/types/prefix-diff.d.ts +4 -0
- package/lib/types/prefix-diff.js +20 -0
- package/lib/types/remote.d.ts +45 -0
- package/lib/types/remote.js +99 -0
- package/lib/types/room.d.ts +66 -0
- package/lib/types/room.js +101 -0
- package/lib/types/segmenter.d.ts +100 -0
- package/lib/types/segmenter.js +184 -0
- package/lib/types/service.d.ts +145 -0
- package/lib/types/service.js +493 -0
- package/lib/types/store.d.ts +424 -0
- package/lib/types/store.js +1920 -0
- package/lib/types/tool-summary.d.ts +6 -0
- package/lib/types/tool-summary.js +7 -0
- package/lib/types/types.d.ts +703 -0
- package/lib/types/types.js +18 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +133 -3
|
@@ -0,0 +1,703 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The context-lens data model — the single contract between the host
|
|
3
|
+
* capture half and the browser panel. Everything the panel renders comes from
|
|
4
|
+
* these shapes; nothing else crosses the wire.
|
|
5
|
+
*
|
|
6
|
+
* Hierarchy: session → turn → agent scope (main / one per delegation run) →
|
|
7
|
+
* request → four segments (system / tools / history / added). All text the
|
|
8
|
+
* panel shows is captured verbatim from the `llm/stream` waterfall's
|
|
9
|
+
* `GenerateOptions` (the assembly layer, BEFORE adapter projection), so the
|
|
10
|
+
* panel never reconstructs — it replays what was actually sent.
|
|
11
|
+
*
|
|
12
|
+
* Measurement honesty: per-segment sizes are exact CHARACTER counts (the host
|
|
13
|
+
* exposes no per-segment tokenizer); request-level token totals are the real
|
|
14
|
+
* provider `usage` figures. The panel footer states this split.
|
|
15
|
+
*
|
|
16
|
+
* @module @khorsheed/dsh-context-lens/types
|
|
17
|
+
*/
|
|
18
|
+
/** Category buckets behind the stacked bar / legend filter / detail rows. */
|
|
19
|
+
export type SegmentCategory =
|
|
20
|
+
/** 系统提示词(systemPrompt 组装,来源 = assemble section 名)。 */
|
|
21
|
+
'system'
|
|
22
|
+
/** 工具定义。 */
|
|
23
|
+
| 'tool-definition'
|
|
24
|
+
/** 用户消息。 */
|
|
25
|
+
| 'user'
|
|
26
|
+
/** 助手消息。 */
|
|
27
|
+
| 'assistant'
|
|
28
|
+
/** 工具结果。 */
|
|
29
|
+
| 'tool-result'
|
|
30
|
+
/** 技能注入(skill catalog / skill content)。 */
|
|
31
|
+
| 'skill-injection'
|
|
32
|
+
/** 提醒注入(system-reminder)。 */
|
|
33
|
+
| 'reminder-injection'
|
|
34
|
+
/** 插件注入(plugin prompt sections carried in messages)。 */
|
|
35
|
+
| 'plugin-injection'
|
|
36
|
+
/** 运行时快照(runtime-context durable user snapshot)。 */
|
|
37
|
+
| 'runtime-snapshot'
|
|
38
|
+
/** 工具变更通告。 */
|
|
39
|
+
| 'tool-change' | 'compaction';
|
|
40
|
+
/** A retained request address; only emitted while the target is readable. */
|
|
41
|
+
export interface RequestLink {
|
|
42
|
+
turnSeq: number;
|
|
43
|
+
scopeId: string;
|
|
44
|
+
seq: number;
|
|
45
|
+
requestNumber?: number;
|
|
46
|
+
}
|
|
47
|
+
/** Durable compression identity, separate from a model request's display ordinal. */
|
|
48
|
+
export interface CompactionInfo {
|
|
49
|
+
id: string;
|
|
50
|
+
hostTurn?: number;
|
|
51
|
+
/** True only after a checkpoint replacement actually committed. */
|
|
52
|
+
applied?: boolean;
|
|
53
|
+
replacedCount?: number;
|
|
54
|
+
replacedChars?: number;
|
|
55
|
+
/** Log recovery knows the selected region, but not the complete model input. */
|
|
56
|
+
inputPartial?: boolean;
|
|
57
|
+
before?: RequestLink;
|
|
58
|
+
}
|
|
59
|
+
/** One message row inside a request's four-segment breakdown. */
|
|
60
|
+
export interface SegmentItem {
|
|
61
|
+
/**
|
|
62
|
+
* Position in the wire message stream (0-based across the whole request).
|
|
63
|
+
* `-1` marks the one-shot system slot (`GenerateOptions.system`), which sits
|
|
64
|
+
* ahead of the message array rather than inside it.
|
|
65
|
+
*/
|
|
66
|
+
index: number;
|
|
67
|
+
messageId?: string;
|
|
68
|
+
compactionId?: string;
|
|
69
|
+
compactionRequest?: RequestLink;
|
|
70
|
+
pruning?: {
|
|
71
|
+
beforeChars: number;
|
|
72
|
+
afterChars: number;
|
|
73
|
+
before?: RequestLink;
|
|
74
|
+
};
|
|
75
|
+
category: SegmentCategory;
|
|
76
|
+
/** 角色/来源标签:model、runtime-context、skill-catalog、section 名等。 */
|
|
77
|
+
source: string;
|
|
78
|
+
/** Tool calls this assistant row issued (the chip on assistant rows). */
|
|
79
|
+
toolCalls?: string[];
|
|
80
|
+
/** Exact tool-result provenance when the issuing request is retained. */
|
|
81
|
+
toolCallId?: string;
|
|
82
|
+
sourceRequestNumber?: number;
|
|
83
|
+
/** Single-line preview (whitespace-collapsed). */
|
|
84
|
+
preview: string;
|
|
85
|
+
/**
|
|
86
|
+
* Verbatim full text — the panel's expand affordance shows exactly this.
|
|
87
|
+
* Assistant rows carry a JSON string `{reasoning?, text?, calls?}` (calls
|
|
88
|
+
* keep the raw argument JSON); every other role is its plain text.
|
|
89
|
+
*/
|
|
90
|
+
full: string;
|
|
91
|
+
/** Exact character count of `full`. */
|
|
92
|
+
chars: number;
|
|
93
|
+
/** Generation time of this assistant row, when it is one. */
|
|
94
|
+
durationMs?: number;
|
|
95
|
+
/** `new` = arrived since the previous request in this scope; `history` otherwise. */
|
|
96
|
+
/** Durable source turn, when supplied by the host. */
|
|
97
|
+
sourceTurn?: number;
|
|
98
|
+
/** Explicit tool failure; never inferred from response prose. */
|
|
99
|
+
isError?: boolean;
|
|
100
|
+
freshness: 'new' | 'history';
|
|
101
|
+
}
|
|
102
|
+
/** One tool definition as sent in the request's `tools` array. */
|
|
103
|
+
export interface ToolDefItem {
|
|
104
|
+
name: string;
|
|
105
|
+
description: string;
|
|
106
|
+
/** Serialized parameter schema (pretty JSON). */
|
|
107
|
+
parameters: string;
|
|
108
|
+
/** Exact character count of the serialized definition. */
|
|
109
|
+
chars: number;
|
|
110
|
+
/** True when this definition was not present in the previous request. */
|
|
111
|
+
added: boolean;
|
|
112
|
+
}
|
|
113
|
+
/** Real provider usage figures (never estimated). */
|
|
114
|
+
export interface RequestUsage {
|
|
115
|
+
inputTokens: number;
|
|
116
|
+
outputTokens: number;
|
|
117
|
+
totalTokens?: number;
|
|
118
|
+
/** Measured cache hits — the cache column's only source of truth. */
|
|
119
|
+
cacheReadTokens?: number;
|
|
120
|
+
/**
|
|
121
|
+
* Cache-write input (Anthropic `cache_creation_input_tokens` et al.). The
|
|
122
|
+
* host usage contract's buckets are disjoint, so a request's full input is
|
|
123
|
+
* `inputTokens + cacheReadTokens + cacheWriteTokens` — dropping this bucket
|
|
124
|
+
* shows a cache-writing (first) request as almost input-free.
|
|
125
|
+
*/
|
|
126
|
+
cacheWriteTokens?: number;
|
|
127
|
+
}
|
|
128
|
+
/** The six-way timing split of one request (same vocabulary as the host product). */
|
|
129
|
+
export interface RequestTiming {
|
|
130
|
+
/** Request dispatched → first chunk(模型等待). */
|
|
131
|
+
waitMs?: number;
|
|
132
|
+
/** reasoning blocks, summed(模型思考). */
|
|
133
|
+
reasoningMs?: number;
|
|
134
|
+
/** tool-call argument generation, summed(工具参数). */
|
|
135
|
+
toolArgsMs?: number;
|
|
136
|
+
/** text blocks, summed(模型输出). */
|
|
137
|
+
textMs?: number;
|
|
138
|
+
/** tool/call → tool/result for tools this request started(工具执行). */
|
|
139
|
+
toolExecMs?: number;
|
|
140
|
+
/** Dispatch → stream settled(总耗时). */
|
|
141
|
+
totalMs?: number;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* The request's model configuration snapshot — scopes may differ.
|
|
145
|
+
*
|
|
146
|
+
* Read from the session log's `request/header` events, the latest one
|
|
147
|
+
* applying to every later request: a round without a header means
|
|
148
|
+
* "unchanged from the previous header"; a session without any header means
|
|
149
|
+
* unrecorded (then only provider and model come from the assistant message's
|
|
150
|
+
* source). External agents' children write headers too — per wire step for
|
|
151
|
+
* kimi, per round for claude-code/codex — under that same semantics
|
|
152
|
+
* (.agents/notes/implemented/feature/2026-10-23-external-agent-request-headers.md).
|
|
153
|
+
*/
|
|
154
|
+
export interface RequestConfig {
|
|
155
|
+
provider?: string;
|
|
156
|
+
model?: string;
|
|
157
|
+
maxTokens?: number;
|
|
158
|
+
reasoningEffort?: string;
|
|
159
|
+
temperature?: number;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* 明细头锚点:本请求的响应干了什么,结构化承载(面板负责本地化与拼装)。
|
|
163
|
+
* 来自响应流的 tool-call / text blocks。
|
|
164
|
+
*/
|
|
165
|
+
export type ResponseSummary = {
|
|
166
|
+
kind: 'compaction';
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* 响应以工具调用收尾:`name` 为首个调用的工具名,`hint` 为其参数摘要
|
|
170
|
+
*(what → 文件 basename → for → description)。多调用用 `toolCounts` 按名称计数;
|
|
171
|
+
* `more` 为兼容旧客户端保留的其余调用个数。
|
|
172
|
+
*/
|
|
173
|
+
| {
|
|
174
|
+
kind: 'tool';
|
|
175
|
+
name: string;
|
|
176
|
+
hint?: string;
|
|
177
|
+
more?: number;
|
|
178
|
+
toolCounts?: {
|
|
179
|
+
name: string;
|
|
180
|
+
count: number;
|
|
181
|
+
}[];
|
|
182
|
+
}
|
|
183
|
+
/** 助手回复(有可见文本、无工具调用)。 */
|
|
184
|
+
| {
|
|
185
|
+
kind: 'text';
|
|
186
|
+
}
|
|
187
|
+
/** 纯思考响应(只有 reasoning、无可见文本也无工具调用——思考段落独占一条记录时落这里)。 */
|
|
188
|
+
| {
|
|
189
|
+
kind: 'reasoning';
|
|
190
|
+
}
|
|
191
|
+
/** 空响应(无文本也无工具调用——失败/中断的响应落这里)。 */
|
|
192
|
+
| {
|
|
193
|
+
kind: 'none';
|
|
194
|
+
};
|
|
195
|
+
/** The request's own response, verbatim content blocks. */
|
|
196
|
+
export interface CapturedResponse {
|
|
197
|
+
/** Assembled reasoning text, when the model produced any. */
|
|
198
|
+
reasoning?: string;
|
|
199
|
+
/** Assembled visible text, when any. */
|
|
200
|
+
text?: string;
|
|
201
|
+
/** Tool calls issued: name + raw arguments string. */
|
|
202
|
+
toolCalls: {
|
|
203
|
+
callId?: string;
|
|
204
|
+
name: string;
|
|
205
|
+
arguments: string;
|
|
206
|
+
/** Execution happens after the model response; never part of input composition. */
|
|
207
|
+
execution?: {
|
|
208
|
+
status: 'running' | 'ok' | 'failed';
|
|
209
|
+
result?: string;
|
|
210
|
+
};
|
|
211
|
+
}[];
|
|
212
|
+
}
|
|
213
|
+
/** Bounded view of the smallest replacement span, with unchanged context on either side. */
|
|
214
|
+
export interface PrefixTextChange {
|
|
215
|
+
/** Unicode character offset, zero based. */
|
|
216
|
+
offset: number;
|
|
217
|
+
leading: string;
|
|
218
|
+
trailing: string;
|
|
219
|
+
leadingOmitted: boolean;
|
|
220
|
+
trailingOmitted: boolean;
|
|
221
|
+
removed: string;
|
|
222
|
+
added: string;
|
|
223
|
+
removedChars: number;
|
|
224
|
+
addedChars: number;
|
|
225
|
+
}
|
|
226
|
+
/** One message as a change entry shows it. */
|
|
227
|
+
export interface ChangeRow {
|
|
228
|
+
/** Wire position in its own request (removed rows: the previous request). */
|
|
229
|
+
index: number;
|
|
230
|
+
messageId?: string;
|
|
231
|
+
category: SegmentCategory;
|
|
232
|
+
source: string;
|
|
233
|
+
/** Whitespace-collapsed, at most 120 characters. */
|
|
234
|
+
preview: string;
|
|
235
|
+
chars: number;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* One change between consecutive requests. `kind` names the host fact behind
|
|
239
|
+
* it: a surface replacement (`replace`), one metered by `compaction/summary`
|
|
240
|
+
* (`compaction`) or `compaction/prune` (`prune`), or — with no event to pair
|
|
241
|
+
* them — a bare id-level `remove` / `add`.
|
|
242
|
+
*/
|
|
243
|
+
export interface RequestChange {
|
|
244
|
+
kind: 'replace' | 'compaction' | 'prune' | 'remove' | 'add';
|
|
245
|
+
/** All rows are system messages; constituent events are listed in `parts`. */
|
|
246
|
+
system?: true;
|
|
247
|
+
removed: ChangeRow[];
|
|
248
|
+
added: ChangeRow[];
|
|
249
|
+
/** The replacing message's producer, verbatim (`kind · op`). */
|
|
250
|
+
source?: {
|
|
251
|
+
kind: string;
|
|
252
|
+
op?: string;
|
|
253
|
+
};
|
|
254
|
+
/** Host log seq of the replacement event and of what it shadowed. */
|
|
255
|
+
eventSeq?: number;
|
|
256
|
+
replacedSeqs?: number[];
|
|
257
|
+
compactionId?: string;
|
|
258
|
+
/** Retained compaction request, when this change is a compaction. */
|
|
259
|
+
compactionRequest?: RequestLink;
|
|
260
|
+
/** Retained request that still carried the un-pruned text. */
|
|
261
|
+
pruneBefore?: RequestLink;
|
|
262
|
+
/** Character diff when one text became another (system: head against head). */
|
|
263
|
+
text?: PrefixTextChange;
|
|
264
|
+
/** Assemble section holding the diff start, when the live lane attributed it. */
|
|
265
|
+
section?: string;
|
|
266
|
+
/** A removed row whose full text equals the new head — a checkable equality, not a claim. */
|
|
267
|
+
sameAs?: ChangeRow;
|
|
268
|
+
parts?: {
|
|
269
|
+
kind: RequestChange['kind'];
|
|
270
|
+
removed: ChangeRow[];
|
|
271
|
+
added: ChangeRow[];
|
|
272
|
+
eventSeq?: number;
|
|
273
|
+
replacedSeqs?: number[];
|
|
274
|
+
}[];
|
|
275
|
+
/** The cache prefix first differs inside this change. */
|
|
276
|
+
isBreak?: true;
|
|
277
|
+
}
|
|
278
|
+
/** One tool definition difference, paired by name. */
|
|
279
|
+
export interface ToolChange {
|
|
280
|
+
name: string;
|
|
281
|
+
change: 'added' | 'removed' | 'modified';
|
|
282
|
+
description?: PrefixTextChange;
|
|
283
|
+
parameters?: PrefixTextChange;
|
|
284
|
+
/** Declaring package from the tool's host-side origin tag, when tagged. */
|
|
285
|
+
owner?: string;
|
|
286
|
+
/** The message prefix is unchanged and this is the first differing tool. */
|
|
287
|
+
isBreak?: true;
|
|
288
|
+
}
|
|
289
|
+
/** One model call, fully captured. */
|
|
290
|
+
export interface CapturedRequest {
|
|
291
|
+
/** Stable 1-based request ordinal within this agent’s history; absent when the beginning is unknown. */
|
|
292
|
+
requestNumber?: number;
|
|
293
|
+
/**
|
|
294
|
+
* Collector-assigned process-wide query ID, separate from the displayed request number.
|
|
295
|
+
* Process-local and ephemeral — the counter resets on restart, so a seq
|
|
296
|
+
* only selects within the answering instance's `generation`.
|
|
297
|
+
*/
|
|
298
|
+
seq: number;
|
|
299
|
+
scopeId: string;
|
|
300
|
+
sessionId: string;
|
|
301
|
+
purpose?: string;
|
|
302
|
+
compaction?: CompactionInfo;
|
|
303
|
+
startedAt: number;
|
|
304
|
+
status: 'streaming' | 'ok' | 'failed';
|
|
305
|
+
error?: string;
|
|
306
|
+
config: RequestConfig;
|
|
307
|
+
usage?: RequestUsage;
|
|
308
|
+
timing: RequestTiming;
|
|
309
|
+
/** The answering instance's epoch — see {@link ListTurnsResult.generation}. */
|
|
310
|
+
generation?: string;
|
|
311
|
+
/**
|
|
312
|
+
* 明细头锚点:本请求的响应干了什么(结构化;面板本地化渲染为
|
|
313
|
+
* `name:hint` / 「助手回复」 / —)。
|
|
314
|
+
*/
|
|
315
|
+
responseSummary: ResponseSummary;
|
|
316
|
+
/**
|
|
317
|
+
* 本请求自己的响应原文(输出段):streaming 中缺席;在任何 block 之前
|
|
318
|
+
* 就失败的调用也缺席(error 字段承担失败展示)。一个 turn 的最后一次
|
|
319
|
+
* 请求的响应只在这里可见(下一请求的 新增上下文 看不到它)。
|
|
320
|
+
*/
|
|
321
|
+
response?: CapturedResponse;
|
|
322
|
+
/** Exact comparison with the preceding retained request in this scope. */
|
|
323
|
+
prefix?: {
|
|
324
|
+
previousSeq: number;
|
|
325
|
+
previousRequestNumber?: number;
|
|
326
|
+
gapMs: number;
|
|
327
|
+
changed?: {
|
|
328
|
+
index: number;
|
|
329
|
+
before: string;
|
|
330
|
+
after: string;
|
|
331
|
+
beforeCategory?: SegmentCategory;
|
|
332
|
+
afterCategory?: SegmentCategory;
|
|
333
|
+
text?: PrefixTextChange;
|
|
334
|
+
};
|
|
335
|
+
toolsChanged: boolean;
|
|
336
|
+
/** Every message-level change since the previous request (tail appends excluded). */
|
|
337
|
+
changes?: RequestChange[];
|
|
338
|
+
/** Tool definitions added, removed, or rewritten, by name. */
|
|
339
|
+
toolChanges?: ToolChange[];
|
|
340
|
+
/** The ordinary tail append: how many messages, from which producers. */
|
|
341
|
+
tail?: {
|
|
342
|
+
count: number;
|
|
343
|
+
sources: string[];
|
|
344
|
+
};
|
|
345
|
+
/** Provider or model differs from the previous request (caches never cross models). */
|
|
346
|
+
configChanged?: {
|
|
347
|
+
from: string;
|
|
348
|
+
to: string;
|
|
349
|
+
};
|
|
350
|
+
};
|
|
351
|
+
segments: {
|
|
352
|
+
/** systemPrompt 组装原文;source 为 assemble section 名。 */
|
|
353
|
+
system: SegmentItem[];
|
|
354
|
+
tools: ToolDefItem[];
|
|
355
|
+
/** 继承自之前请求的消息(默认折叠)。 */
|
|
356
|
+
history: SegmentItem[];
|
|
357
|
+
/** 相对上一请求新收到的内容(含上一响应及其工具返回;默认展开)。 */
|
|
358
|
+
added: SegmentItem[];
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
/** One agent scope of a turn: the main conversation, or one delegation run. */
|
|
362
|
+
export interface AgentScopeSummary {
|
|
363
|
+
/** 'main' or the subagent childId. */
|
|
364
|
+
scopeId: string;
|
|
365
|
+
/**
|
|
366
|
+
* Per-session 1-based ordinal in scope-creation order — the delegation chip's
|
|
367
|
+
* `#N` anchor. Unlike a request seq it exists even for a 0-request failed run.
|
|
368
|
+
*/
|
|
369
|
+
scopeSeq: number;
|
|
370
|
+
kind: 'main' | 'subagent';
|
|
371
|
+
/** Delegation label from `subagent/catalog` (e.g. 第一章对账 JSON 提取). */
|
|
372
|
+
label?: string;
|
|
373
|
+
status: 'running' | 'ok' | 'failed';
|
|
374
|
+
error?: string;
|
|
375
|
+
config: RequestConfig;
|
|
376
|
+
requests: CapturedRequest[];
|
|
377
|
+
startedAt: number;
|
|
378
|
+
endedAt?: number;
|
|
379
|
+
}
|
|
380
|
+
/** Where one captured unit's content came from — the fidelity marker. */
|
|
381
|
+
export type CaptureOrigin =
|
|
382
|
+
/** The in-process stream tee (full fidelity, system-section attribution). */
|
|
383
|
+
'live'
|
|
384
|
+
/**
|
|
385
|
+
* Rebuilt from the on-disk session log (a one-shot child log carries no
|
|
386
|
+
* system prompt / tool definitions; the system segment keeps no section names).
|
|
387
|
+
*/
|
|
388
|
+
| 'log-reconstructed';
|
|
389
|
+
/** `listTurns` row — deliberately light (no segments, no request payloads). */
|
|
390
|
+
export interface TurnListItem {
|
|
391
|
+
sessionId: string;
|
|
392
|
+
/** Ids of the room decisions this turn holds (a 查看判断 jump resolves its turn by them). */
|
|
393
|
+
roomDecisionIds?: string[];
|
|
394
|
+
/**
|
|
395
|
+
* The panel-facing address. Real turns key on the host's own turn number
|
|
396
|
+
* (stable across live capture and log backfill, and durable across process
|
|
397
|
+
* restarts); purpose pseudo-turns (compaction / session-title buckets) take
|
|
398
|
+
* negative addresses that are NOT durable — they re-derive from the
|
|
399
|
+
* session's bucket counter on every mount. Address semantics:
|
|
400
|
+
* `(sessionId, turnSeq)` names a TURN, never a request.
|
|
401
|
+
*/
|
|
402
|
+
turnSeq: number;
|
|
403
|
+
/** The host's turn number on real turns; absent marks a purpose pseudo-turn. */
|
|
404
|
+
hostTurn?: number;
|
|
405
|
+
/** 用户 query 预览(单行截断)。 */
|
|
406
|
+
query: string;
|
|
407
|
+
/** No human message this turn: the producer and text of the first message that started it. */
|
|
408
|
+
trigger?: {
|
|
409
|
+
source: string;
|
|
410
|
+
text: string;
|
|
411
|
+
};
|
|
412
|
+
/** The `turn/start` event's log seq — the target the chat pages history back to before a jump. */
|
|
413
|
+
startSeq?: number;
|
|
414
|
+
/** The turn's number in one session-wide sequence (main turns and room rounds, by time). */
|
|
415
|
+
ordinal?: number;
|
|
416
|
+
/** A room round: a human message to the room made outside any main turn, and who it went to. */
|
|
417
|
+
room?: {
|
|
418
|
+
targets: string[];
|
|
419
|
+
};
|
|
420
|
+
startedAt: number;
|
|
421
|
+
endedAt?: number;
|
|
422
|
+
requestCount: number;
|
|
423
|
+
scopeCount: number;
|
|
424
|
+
failedScopeCount: number;
|
|
425
|
+
totalInputTokens: number;
|
|
426
|
+
totalOutputTokens: number;
|
|
427
|
+
/**
|
|
428
|
+
* Fidelity marker: `live` once any in-process capture landed on the turn
|
|
429
|
+
* (the log lane never merges into such a turn), `log-reconstructed` when
|
|
430
|
+
* the whole turn was rebuilt from the session log.
|
|
431
|
+
*/
|
|
432
|
+
origin?: CaptureOrigin;
|
|
433
|
+
/**
|
|
434
|
+
* The turn-tail assistant message id — the `conversation.chat.assistant-actions`
|
|
435
|
+
* owner prop, so the message-row icon can map itself back to this turn.
|
|
436
|
+
*/
|
|
437
|
+
closingMessageId?: string;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* The history-backfill watermark of one session, surfaced so the panel can
|
|
441
|
+
* tell "genuinely nothing captured" from "log unreadable" from "older turns
|
|
442
|
+
* dropped by the memory budget".
|
|
443
|
+
*/
|
|
444
|
+
export interface BackfillInfo {
|
|
445
|
+
/**
|
|
446
|
+
* `none` — never read (no durable log yet, or no persistence backend);
|
|
447
|
+
* `partial` — some turns reconstructed, older ones dropped by budget (the
|
|
448
|
+
* read retries on later queries as room frees); `complete` — every turn in
|
|
449
|
+
* the log is represented; `broken` — the log refused to decode.
|
|
450
|
+
*/
|
|
451
|
+
state: 'none' | 'partial' | 'complete' | 'broken';
|
|
452
|
+
/** The decode failure summary when `state` is `broken`. */
|
|
453
|
+
reason?: string;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* The scope allow-list of one read, computed by the CALLER from its own
|
|
457
|
+
* authorization facts — the plugin treats it as an opaque filter and never
|
|
458
|
+
* derives one itself. Absent (or no `scopes` key) is the unfiltered local
|
|
459
|
+
* semantics.
|
|
460
|
+
*
|
|
461
|
+
* Scope identifiers are the ones `AgentScopeOverview.scopeId` exposes: the
|
|
462
|
+
* main conversation scope's id is the stable string `'main'`; child scopes
|
|
463
|
+
* key on the subagent childId (`call:<callId>` when the run never reached
|
|
464
|
+
* the catalog). A scope outside the list contributes nothing to the answer:
|
|
465
|
+
* no request rows, no scope counts, no lanes or tool names, no token sums —
|
|
466
|
+
* and its child log is never opened on the query's behalf.
|
|
467
|
+
*/
|
|
468
|
+
export interface ScopeFilter {
|
|
469
|
+
readonly scopes?: readonly string[];
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* The refusal half of a single-object scoped read: the address resolved to
|
|
473
|
+
* captured content, but the query's {@link ScopeFilter} excluded the scope
|
|
474
|
+
* holding it. Distinct from `undefined` (no such address) so a filtering
|
|
475
|
+
* caller never renders one as the other — the refusal confirms the address
|
|
476
|
+
* exists and carries nothing of the excluded scope.
|
|
477
|
+
*/
|
|
478
|
+
export interface ScopedRefusal {
|
|
479
|
+
readonly refused: 'no-authorized-content';
|
|
480
|
+
/** The answering instance's epoch — same restart-invalidation role as on the result envelopes. */
|
|
481
|
+
readonly generation?: string;
|
|
482
|
+
}
|
|
483
|
+
/** `listTurns` payload: the turn rows plus the session's backfill watermark. */
|
|
484
|
+
export interface ListTurnsResult {
|
|
485
|
+
turns: TurnListItem[];
|
|
486
|
+
backfill: BackfillInfo;
|
|
487
|
+
/**
|
|
488
|
+
* The answering instance's epoch (a mount-time id). Request `seq` values
|
|
489
|
+
* are process-local and reset on restart: a caller holding seqs across
|
|
490
|
+
* calls tags them with the generation of the result that yielded them and
|
|
491
|
+
* treats a changed generation as invalidating every held seq — an old seq
|
|
492
|
+
* must never silently resolve to a different request.
|
|
493
|
+
*/
|
|
494
|
+
generation?: string;
|
|
495
|
+
/**
|
|
496
|
+
* Turns this session collected and later evicted under the retention caps
|
|
497
|
+
* — the "collected then dropped" signal next to the backfill watermark,
|
|
498
|
+
* present only when non-zero. Blind spot: a session whose last turn
|
|
499
|
+
* evicts frees its whole slot, so fully-evicted reads exactly like
|
|
500
|
+
* never-seen (the store cannot tell the two apart).
|
|
501
|
+
*/
|
|
502
|
+
evictedTurnCount?: number;
|
|
503
|
+
/**
|
|
504
|
+
* This session is another session's child (its log header names a
|
|
505
|
+
* `parentSession`): the parent's title, the turn that started it, and the
|
|
506
|
+
* label it was catalogued under.
|
|
507
|
+
*/
|
|
508
|
+
parent?: {
|
|
509
|
+
sessionId: string;
|
|
510
|
+
title?: string;
|
|
511
|
+
hostTurn?: number;
|
|
512
|
+
label?: string;
|
|
513
|
+
};
|
|
514
|
+
/** First and last host turn the session's log holds; turns between them that `turns` lacks are not loaded. */
|
|
515
|
+
range?: {
|
|
516
|
+
first: number;
|
|
517
|
+
last: number;
|
|
518
|
+
};
|
|
519
|
+
/** How many turns the session has in the ordinal sequence (main turns and room rounds). */
|
|
520
|
+
total?: number;
|
|
521
|
+
/** Runs of main turns not loaded, in ordinals, with the host turns at their ends (what a window move asks for). */
|
|
522
|
+
unloaded?: {
|
|
523
|
+
from: number;
|
|
524
|
+
to: number;
|
|
525
|
+
firstHost: number;
|
|
526
|
+
lastHost: number;
|
|
527
|
+
}[];
|
|
528
|
+
/** Room coordinator handoffs, for the session map. */
|
|
529
|
+
handoffs?: {
|
|
530
|
+
at: number;
|
|
531
|
+
name: string;
|
|
532
|
+
}[];
|
|
533
|
+
/**
|
|
534
|
+
* Present exactly when the query carried a {@link ScopeFilter}: the
|
|
535
|
+
* authorized scopes that exist in the session. An empty array is the
|
|
536
|
+
* explicit zero-authorized-content signal — distinct from the field's
|
|
537
|
+
* absence (unfiltered) and from unknown-session emptiness.
|
|
538
|
+
*/
|
|
539
|
+
authorizedScopes?: readonly string[];
|
|
540
|
+
}
|
|
541
|
+
/** `getTurn` payload: scopes with request headers but without segments. */
|
|
542
|
+
/** A JSON value as recorded in a session log (the room's decision calls). */
|
|
543
|
+
export type LensJsonValue = null | boolean | number | string | LensJsonValue[] | {
|
|
544
|
+
[key: string]: LensJsonValue;
|
|
545
|
+
};
|
|
546
|
+
/**
|
|
547
|
+
* One decision-model call the room made on its own (a `room/decision` event
|
|
548
|
+
* carrying a call), shown as a request in the turn's 房间 tab. Read
|
|
549
|
+
* structurally from the room plugin's log; absent without the room plugin.
|
|
550
|
+
*/
|
|
551
|
+
export interface RoomDecisionRow {
|
|
552
|
+
id: string;
|
|
553
|
+
seq: number;
|
|
554
|
+
at: number;
|
|
555
|
+
/** `task-filing` / `report-timing` (the room's scenario table). */
|
|
556
|
+
scenario: string;
|
|
557
|
+
outcome: string;
|
|
558
|
+
rule?: string;
|
|
559
|
+
probability?: number;
|
|
560
|
+
model: string;
|
|
561
|
+
latencyMs?: number;
|
|
562
|
+
cached?: boolean;
|
|
563
|
+
inputTokens?: number;
|
|
564
|
+
outputTokens?: number;
|
|
565
|
+
request: {
|
|
566
|
+
state: LensJsonValue;
|
|
567
|
+
questions: LensJsonValue;
|
|
568
|
+
};
|
|
569
|
+
response?: LensJsonValue;
|
|
570
|
+
failure?: {
|
|
571
|
+
reason: string;
|
|
572
|
+
detail?: string;
|
|
573
|
+
};
|
|
574
|
+
about: {
|
|
575
|
+
message?: string;
|
|
576
|
+
task?: {
|
|
577
|
+
number: number;
|
|
578
|
+
title: string;
|
|
579
|
+
};
|
|
580
|
+
from?: string;
|
|
581
|
+
to?: string;
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
export interface TurnOverview {
|
|
585
|
+
turn: TurnListItem;
|
|
586
|
+
scopes: AgentScopeOverview[];
|
|
587
|
+
/** The room's decision-model calls made during this turn (the 房间 tab); absent when none. */
|
|
588
|
+
roomDecisions?: RoomDecisionRow[];
|
|
589
|
+
/** The answering instance's epoch — see {@link ListTurnsResult.generation}. */
|
|
590
|
+
generation?: string;
|
|
591
|
+
/**
|
|
592
|
+
* Present exactly when the query carried a {@link ScopeFilter}: this
|
|
593
|
+
* turn's authorized scopes. An empty array means the turn exists but the
|
|
594
|
+
* filter excluded every scope on it (the turn row's own fields are
|
|
595
|
+
* session-level metadata and still answer).
|
|
596
|
+
*/
|
|
597
|
+
authorizedScopes?: readonly string[];
|
|
598
|
+
}
|
|
599
|
+
/** Scope with light request rows (the left request list). */
|
|
600
|
+
export interface AgentScopeOverview {
|
|
601
|
+
scopeId: string;
|
|
602
|
+
/** Per-session 1-based ordinal in scope-creation order (the chip's `#N`). */
|
|
603
|
+
scopeSeq: number;
|
|
604
|
+
/** `compaction`: a compaction call shown inside the turn it happened in (scopeId `compaction:<pseudo turnSeq>`). */
|
|
605
|
+
kind: 'main' | 'subagent' | 'compaction';
|
|
606
|
+
label?: string;
|
|
607
|
+
/** The child's `subagent/descriptor` provider; anything not `dsh*` is an external agent. */
|
|
608
|
+
provider?: string;
|
|
609
|
+
/** The main request whose tool call started this child, when one did. */
|
|
610
|
+
delegatedBy?: RequestLink;
|
|
611
|
+
/** Compaction views: how many messages it replaced, and the main request it followed. */
|
|
612
|
+
compaction?: {
|
|
613
|
+
replacedCount?: number;
|
|
614
|
+
after?: RequestLink;
|
|
615
|
+
betweenTurns?: true;
|
|
616
|
+
};
|
|
617
|
+
status: 'running' | 'ok' | 'failed';
|
|
618
|
+
error?: string;
|
|
619
|
+
config: RequestConfig;
|
|
620
|
+
startedAt: number;
|
|
621
|
+
endedAt?: number;
|
|
622
|
+
/**
|
|
623
|
+
* Fidelity marker: where this scope's captured content came from (the two
|
|
624
|
+
* lanes are mutually exclusive per scope — whichever fills first owns it).
|
|
625
|
+
* Absent while the scope holds no captured content yet.
|
|
626
|
+
*/
|
|
627
|
+
origin?: CaptureOrigin;
|
|
628
|
+
requests: RequestListItem[];
|
|
629
|
+
}
|
|
630
|
+
/** `getTurn` request row — everything the left list card shows. */
|
|
631
|
+
export interface RequestListItem {
|
|
632
|
+
requestNumber?: number;
|
|
633
|
+
/** Per-request snapshot; never substitute the scope’s latest config. */
|
|
634
|
+
config?: RequestConfig;
|
|
635
|
+
seq: number;
|
|
636
|
+
scopeId: string;
|
|
637
|
+
status: 'streaming' | 'ok' | 'failed';
|
|
638
|
+
responseSummary: ResponseSummary;
|
|
639
|
+
startedAt: number;
|
|
640
|
+
usage?: RequestUsage;
|
|
641
|
+
totalMs?: number;
|
|
642
|
+
/** Logged compaction bracket, not an exact provider-call duration. */
|
|
643
|
+
timingApproximate?: boolean;
|
|
644
|
+
/** 请求体总字符数(明细头右上)。 */
|
|
645
|
+
totalChars: number;
|
|
646
|
+
toolErrors?: number;
|
|
647
|
+
}
|
|
648
|
+
/** One turn's whole-turn timing view (the 耗时分布 tab). */
|
|
649
|
+
export interface TurnTiming {
|
|
650
|
+
startedAt?: number;
|
|
651
|
+
turnSeq: number;
|
|
652
|
+
totalMs: number;
|
|
653
|
+
/** Six buckets summed across the turn's requests, in timeline order. */
|
|
654
|
+
buckets: {
|
|
655
|
+
waitMs: number;
|
|
656
|
+
reasoningMs: number;
|
|
657
|
+
toolArgsMs: number;
|
|
658
|
+
textMs: number;
|
|
659
|
+
toolExecMs: number;
|
|
660
|
+
otherMs: number;
|
|
661
|
+
};
|
|
662
|
+
/** Strictly ordered lane entries for the timeline. */
|
|
663
|
+
lanes: TimingLane[];
|
|
664
|
+
/** Per-tool aggregation for the 按工具拆分 section. */
|
|
665
|
+
tools: ToolTiming[];
|
|
666
|
+
/** The answering instance's epoch — see {@link ListTurnsResult.generation}. */
|
|
667
|
+
generation?: string;
|
|
668
|
+
/**
|
|
669
|
+
* Present exactly when the query carried a {@link ScopeFilter}: this
|
|
670
|
+
* turn's authorized scopes. An empty array means the turn exists but the
|
|
671
|
+
* filter excluded every scope on it — buckets, lanes, and tools then
|
|
672
|
+
* aggregate over nothing (the session-level `totalMs` still answers).
|
|
673
|
+
*/
|
|
674
|
+
authorizedScopes?: readonly string[];
|
|
675
|
+
}
|
|
676
|
+
/** One entry on the timing timeline. */
|
|
677
|
+
export interface TimingLane {
|
|
678
|
+
kind: 'wait' | 'reasoning' | 'tool-args' | 'text' | 'tool-exec' | 'other';
|
|
679
|
+
/** Request seq this entry belongs to (click → token tab request). */
|
|
680
|
+
requestSeq: number;
|
|
681
|
+
scopeId: string;
|
|
682
|
+
startedAt: number;
|
|
683
|
+
durationMs: number;
|
|
684
|
+
/** tool name for tool-exec lanes. */
|
|
685
|
+
tool?: string;
|
|
686
|
+
callId?: string;
|
|
687
|
+
isError?: boolean;
|
|
688
|
+
}
|
|
689
|
+
/** Per-tool timing aggregate. */
|
|
690
|
+
export interface ToolTiming {
|
|
691
|
+
tool: string;
|
|
692
|
+
calls: number;
|
|
693
|
+
totalMs: number;
|
|
694
|
+
/** Sum of the model's argument-generation time for this tool's calls. */
|
|
695
|
+
argsMs: number;
|
|
696
|
+
}
|
|
697
|
+
/** Lightweight per-request session map, retaining the same scope authorization as all reads. */
|
|
698
|
+
export interface SessionTrend extends ListTurnsResult {
|
|
699
|
+
requests: (RequestListItem & {
|
|
700
|
+
turnSeq: number;
|
|
701
|
+
})[];
|
|
702
|
+
}
|
|
703
|
+
//# sourceMappingURL=types.d.ts.map
|