dsh-thinking-guard 0.1.19 → 0.1.21
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 +80 -80
- package/cordis.patch.yml +5 -0
- package/lib/client.d.ts +20 -2
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +6724 -7923
- package/lib/guard-core.js +72 -1
- package/lib/guard-core.js.map +1 -1
- package/lib/guard-loop-core.js +36 -5
- package/lib/guard-loop-core.js.map +1 -1
- package/lib/guard.js +20 -4
- package/lib/guard.js.map +1 -1
- package/lib/host-face.js +1 -0
- package/lib/host-face.js.map +1 -1
- package/lib/index.js +11 -1
- package/lib/index.js.map +1 -1
- package/lib/policy-state.js +29 -1
- package/lib/policy-state.js.map +1 -1
- package/lib/policy.js +24 -2
- package/lib/policy.js.map +1 -1
- package/lib/server/call-index-remote.js +110 -0
- package/lib/server/call-index-remote.js.map +1 -0
- package/lib/server/remote.js +13 -0
- package/lib/server/remote.js.map +1 -1
- package/lib/types/guard-core.d.ts +69 -1
- package/lib/types/guard-core.d.ts.map +1 -1
- package/lib/types/guard-loop-core.d.ts +15 -0
- package/lib/types/guard-loop-core.d.ts.map +1 -1
- package/lib/types/guard.d.ts +7 -1
- package/lib/types/guard.d.ts.map +1 -1
- package/lib/types/host-face.d.ts.map +1 -1
- package/lib/types/index.d.ts +5 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/policy-state.d.ts +6 -0
- package/lib/types/policy-state.d.ts.map +1 -1
- package/lib/types/policy.d.ts +22 -3
- package/lib/types/policy.d.ts.map +1 -1
- package/lib/types/server/call-index-remote.d.ts +17 -0
- package/lib/types/server/call-index-remote.d.ts.map +1 -0
- package/lib/types/server/remote.d.ts +9 -0
- package/lib/types/server/remote.d.ts.map +1 -1
- package/lib/types/usage/call-index-core.d.ts +152 -0
- package/lib/types/usage/call-index-core.d.ts.map +1 -0
- package/lib/types/usage/call-index-host-face.d.ts +44 -0
- package/lib/types/usage/call-index-host-face.d.ts.map +1 -0
- package/lib/types/usage/call-index-host.d.ts +7 -0
- package/lib/types/usage/call-index-host.d.ts.map +1 -0
- package/lib/types/usage/call-index-query.d.ts +97 -0
- package/lib/types/usage/call-index-query.d.ts.map +1 -0
- package/lib/types/usage/call-index-runtime.d.ts +46 -0
- package/lib/types/usage/call-index-runtime.d.ts.map +1 -0
- package/lib/types/usage/call-index-scope.d.ts +59 -0
- package/lib/types/usage/call-index-scope.d.ts.map +1 -0
- package/lib/types/usage/call-index-wire.d.ts +286 -0
- package/lib/types/usage/call-index-wire.d.ts.map +1 -0
- package/lib/types/usage/session-index.d.ts +149 -0
- package/lib/types/usage/session-index.d.ts.map +1 -0
- package/lib/usage/call-index-core.js +761 -0
- package/lib/usage/call-index-core.js.map +1 -0
- package/lib/usage/call-index-host-face.js +77 -0
- package/lib/usage/call-index-host-face.js.map +1 -0
- package/lib/usage/call-index-host.js +13 -0
- package/lib/usage/call-index-host.js.map +1 -0
- package/lib/usage/call-index-query.js +669 -0
- package/lib/usage/call-index-query.js.map +1 -0
- package/lib/usage/call-index-runtime.js +376 -0
- package/lib/usage/call-index-runtime.js.map +1 -0
- package/lib/usage/call-index-scope.js +79 -0
- package/lib/usage/call-index-scope.js.map +1 -0
- package/lib/usage/call-index-wire.js +490 -0
- package/lib/usage/call-index-wire.js.map +1 -0
- package/lib/usage/session-index.js +600 -0
- package/lib/usage/session-index.js.map +1 -0
- package/package.json +144 -144
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-safe wire contract for the `callIndex` Remote namespace (D-026).
|
|
3
|
+
*
|
|
4
|
+
* This module is the single place both faces agree on. It is imported at
|
|
5
|
+
* RUNTIME by the browser contribution (`src/client/call-index-remote.ts`) and by
|
|
6
|
+
* the Host face (`src/usage/call-index-host-face.ts`), so it may only depend on
|
|
7
|
+
* `zod`; it must never runtime-import a Node module or `session-index.ts` (a
|
|
8
|
+
* type-only import is fine because it is erased before the browser bundle).
|
|
9
|
+
*
|
|
10
|
+
* @module dsh-thinking-guard/usage/call-index-wire
|
|
11
|
+
*/
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
/** Every reply kind on the `callIndex` wire. */
|
|
14
|
+
export declare const CALL_INDEX_REPLY_KINDS: readonly ["status", "task", "summary", "sessions", "calls", "detail", "error"];
|
|
15
|
+
export type CallIndexReplyKind = (typeof CALL_INDEX_REPLY_KINDS)[number];
|
|
16
|
+
/** Stable failure codes; anything else normalizes to `internal-error`. */
|
|
17
|
+
export declare const CALL_INDEX_ERROR_REASONS: readonly ["invalid-request", "scope-disabled", "persistence-unavailable", "cursor-stale", "query-capacity", "reply-too-large", "not-visible", "runtime-unavailable", "task-not-found", "internal-error"];
|
|
18
|
+
export type CallIndexErrorReason = (typeof CALL_INDEX_ERROR_REASONS)[number];
|
|
19
|
+
/** Call statuses mirrored from `CallIndexRow.outcome`. */
|
|
20
|
+
export declare const CALL_INDEX_OUTCOMES: readonly ["success", "error", "cancelled", "unresolved", "unknown", "running"];
|
|
21
|
+
export type CallIndexOutcome = (typeof CALL_INDEX_OUTCOMES)[number];
|
|
22
|
+
/** Known call source categories (the core currently emits only `unknown`). */
|
|
23
|
+
export declare const CALL_INDEX_SOURCE_KINDS: readonly ["mcp", "plugin-tool", "native", "skill", "unknown"];
|
|
24
|
+
export type CallIndexSourceKind = (typeof CALL_INDEX_SOURCE_KINDS)[number];
|
|
25
|
+
/** Shared literal bounds; Host and browser must agree. */
|
|
26
|
+
export declare const CALL_INDEX_MAX_ID_LENGTH = 512;
|
|
27
|
+
export declare const CALL_INDEX_MAX_CWD_LENGTH = 4096;
|
|
28
|
+
export declare const CALL_INDEX_MAX_CURSOR_LENGTH = 256;
|
|
29
|
+
export declare const CALL_INDEX_DEFAULT_LIMIT = 50;
|
|
30
|
+
export declare const CALL_INDEX_MAX_LIMIT = 200;
|
|
31
|
+
export declare const CALL_INDEX_DEFAULT_TTL_MS = 60000;
|
|
32
|
+
export declare const CALL_INDEX_DEFAULT_MAX_VIEWS = 4;
|
|
33
|
+
export declare const CALL_INDEX_DEFAULT_MAX_BYTES: number;
|
|
34
|
+
export declare const CALL_INDEX_MAX_REPLY_BYTES: number;
|
|
35
|
+
/**
|
|
36
|
+
* Reply envelope. Intentionally loose at the type level (`kind` + `data`) so
|
|
37
|
+
* the runtime owner can build `{ schemaVersion, ok, kind, data }` without
|
|
38
|
+
* importing every inner interface; the runtime guarantee comes from
|
|
39
|
+
* {@link callIndexReply}, which re-projects the value through closed schemas.
|
|
40
|
+
*/
|
|
41
|
+
export interface CallIndexReply {
|
|
42
|
+
readonly schemaVersion: 1;
|
|
43
|
+
readonly ok: boolean;
|
|
44
|
+
readonly kind: CallIndexReplyKind;
|
|
45
|
+
readonly data?: Record<string, unknown>;
|
|
46
|
+
readonly reason?: string;
|
|
47
|
+
readonly [key: string]: unknown;
|
|
48
|
+
}
|
|
49
|
+
/** Build a stable error reply; an unknown reason becomes `internal-error`. */
|
|
50
|
+
export declare function callIndexError(reason: string): CallIndexReply;
|
|
51
|
+
/** One filter shared by summary / list requests. Half-open `[fromMs, toMs)`. */
|
|
52
|
+
export declare const callIndexQuerySchema: z.ZodObject<{
|
|
53
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
54
|
+
toolName: z.ZodOptional<z.ZodString>;
|
|
55
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
56
|
+
outcome: z.ZodOptional<z.ZodEnum<{
|
|
57
|
+
success: "success";
|
|
58
|
+
error: "error";
|
|
59
|
+
cancelled: "cancelled";
|
|
60
|
+
unknown: "unknown";
|
|
61
|
+
unresolved: "unresolved";
|
|
62
|
+
running: "running";
|
|
63
|
+
}>>;
|
|
64
|
+
sourceKind: z.ZodOptional<z.ZodEnum<{
|
|
65
|
+
skill: "skill";
|
|
66
|
+
unknown: "unknown";
|
|
67
|
+
mcp: "mcp";
|
|
68
|
+
"plugin-tool": "plugin-tool";
|
|
69
|
+
native: "native";
|
|
70
|
+
}>>;
|
|
71
|
+
fromMs: z.ZodOptional<z.ZodNumber>;
|
|
72
|
+
toMs: z.ZodOptional<z.ZodNumber>;
|
|
73
|
+
includeInherited: z.ZodOptional<z.ZodBoolean>;
|
|
74
|
+
}, z.core.$strict>;
|
|
75
|
+
/** Bounds for the client-supplied local-day offset (UTC-12:00 … UTC+14:00). */
|
|
76
|
+
export declare const CALL_INDEX_MIN_DAY_OFFSET_MINUTES = -720;
|
|
77
|
+
export declare const CALL_INDEX_MAX_DAY_OFFSET_MINUTES = 840;
|
|
78
|
+
/** Hard cap on returned day buckets: one calendar year of daily rows. */
|
|
79
|
+
export declare const CALL_INDEX_MAX_DAY_BUCKETS = 366;
|
|
80
|
+
export declare const callIndexSummaryRequestSchema: z.ZodObject<{
|
|
81
|
+
query: z.ZodOptional<z.ZodObject<{
|
|
82
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
83
|
+
toolName: z.ZodOptional<z.ZodString>;
|
|
84
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
85
|
+
outcome: z.ZodOptional<z.ZodEnum<{
|
|
86
|
+
success: "success";
|
|
87
|
+
error: "error";
|
|
88
|
+
cancelled: "cancelled";
|
|
89
|
+
unknown: "unknown";
|
|
90
|
+
unresolved: "unresolved";
|
|
91
|
+
running: "running";
|
|
92
|
+
}>>;
|
|
93
|
+
sourceKind: z.ZodOptional<z.ZodEnum<{
|
|
94
|
+
skill: "skill";
|
|
95
|
+
unknown: "unknown";
|
|
96
|
+
mcp: "mcp";
|
|
97
|
+
"plugin-tool": "plugin-tool";
|
|
98
|
+
native: "native";
|
|
99
|
+
}>>;
|
|
100
|
+
fromMs: z.ZodOptional<z.ZodNumber>;
|
|
101
|
+
toMs: z.ZodOptional<z.ZodNumber>;
|
|
102
|
+
includeInherited: z.ZodOptional<z.ZodBoolean>;
|
|
103
|
+
}, z.core.$strict>>;
|
|
104
|
+
snapshotId: z.ZodOptional<z.ZodString>;
|
|
105
|
+
dayOffsetMinutes: z.ZodOptional<z.ZodNumber>;
|
|
106
|
+
}, z.core.$strict>;
|
|
107
|
+
export declare const callIndexListRequestSchema: z.ZodObject<{
|
|
108
|
+
query: z.ZodOptional<z.ZodObject<{
|
|
109
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
110
|
+
toolName: z.ZodOptional<z.ZodString>;
|
|
111
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
112
|
+
outcome: z.ZodOptional<z.ZodEnum<{
|
|
113
|
+
success: "success";
|
|
114
|
+
error: "error";
|
|
115
|
+
cancelled: "cancelled";
|
|
116
|
+
unknown: "unknown";
|
|
117
|
+
unresolved: "unresolved";
|
|
118
|
+
running: "running";
|
|
119
|
+
}>>;
|
|
120
|
+
sourceKind: z.ZodOptional<z.ZodEnum<{
|
|
121
|
+
skill: "skill";
|
|
122
|
+
unknown: "unknown";
|
|
123
|
+
mcp: "mcp";
|
|
124
|
+
"plugin-tool": "plugin-tool";
|
|
125
|
+
native: "native";
|
|
126
|
+
}>>;
|
|
127
|
+
fromMs: z.ZodOptional<z.ZodNumber>;
|
|
128
|
+
toMs: z.ZodOptional<z.ZodNumber>;
|
|
129
|
+
includeInherited: z.ZodOptional<z.ZodBoolean>;
|
|
130
|
+
}, z.core.$strict>>;
|
|
131
|
+
snapshotId: z.ZodOptional<z.ZodString>;
|
|
132
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
133
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
134
|
+
}, z.core.$strict>;
|
|
135
|
+
export declare const callIndexDetailRequestSchema: z.ZodObject<{
|
|
136
|
+
sessionId: z.ZodString;
|
|
137
|
+
callSeq: z.ZodNumber;
|
|
138
|
+
snapshotId: z.ZodOptional<z.ZodString>;
|
|
139
|
+
}, z.core.$strict>;
|
|
140
|
+
/** `startIndex(request?)`; the runtime owns the actual scan mode. */
|
|
141
|
+
export declare const callIndexStartRequestSchema: z.ZodObject<{
|
|
142
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
143
|
+
full: "full";
|
|
144
|
+
incremental: "incremental";
|
|
145
|
+
}>>;
|
|
146
|
+
}, z.core.$strict>;
|
|
147
|
+
/** `cancelIndex(request)`; `request` is required even when it carries nothing. */
|
|
148
|
+
export declare const callIndexCancelRequestSchema: z.ZodObject<{
|
|
149
|
+
taskId: z.ZodOptional<z.ZodString>;
|
|
150
|
+
}, z.core.$strict>;
|
|
151
|
+
/** Fixed metadata fields of one call row (mirrors `CallIndexRow`, never args). */
|
|
152
|
+
export declare const callIndexWireRowSchema: z.ZodObject<{
|
|
153
|
+
sessionId: z.ZodString;
|
|
154
|
+
callSeq: z.ZodNumber;
|
|
155
|
+
callId: z.ZodString;
|
|
156
|
+
toolName: z.ZodString;
|
|
157
|
+
turn: z.ZodOptional<z.ZodNumber>;
|
|
158
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
159
|
+
startedAt: z.ZodNumber;
|
|
160
|
+
endedAt: z.ZodOptional<z.ZodNumber>;
|
|
161
|
+
resultSeq: z.ZodOptional<z.ZodNumber>;
|
|
162
|
+
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
163
|
+
outcome: z.ZodEnum<{
|
|
164
|
+
success: "success";
|
|
165
|
+
error: "error";
|
|
166
|
+
cancelled: "cancelled";
|
|
167
|
+
unknown: "unknown";
|
|
168
|
+
unresolved: "unresolved";
|
|
169
|
+
running: "running";
|
|
170
|
+
}>;
|
|
171
|
+
inherited: z.ZodBoolean;
|
|
172
|
+
sourceKind: z.ZodEnum<{
|
|
173
|
+
skill: "skill";
|
|
174
|
+
unknown: "unknown";
|
|
175
|
+
mcp: "mcp";
|
|
176
|
+
"plugin-tool": "plugin-tool";
|
|
177
|
+
native: "native";
|
|
178
|
+
}>;
|
|
179
|
+
layer: z.ZodString;
|
|
180
|
+
}, z.core.$strip>;
|
|
181
|
+
export declare const callIndexWireSessionSchema: z.ZodObject<{
|
|
182
|
+
sessionId: z.ZodString;
|
|
183
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
184
|
+
revision: z.ZodString;
|
|
185
|
+
cut: z.ZodNumber;
|
|
186
|
+
coverage: z.ZodEnum<{
|
|
187
|
+
complete: "complete";
|
|
188
|
+
partial: "partial";
|
|
189
|
+
}>;
|
|
190
|
+
stale: z.ZodBoolean;
|
|
191
|
+
reasons: z.ZodPipe<z.ZodArray<z.ZodString>, z.ZodTransform<string[], string[]>>;
|
|
192
|
+
}, z.core.$strip>;
|
|
193
|
+
/**
|
|
194
|
+
* Overview aggregates over the whole filtered set (never the current page).
|
|
195
|
+
*
|
|
196
|
+
* `bySource` always carries every source kind, including zeros, so a caller can
|
|
197
|
+
* distinguish "known to be zero" from "not reported". `byDay` is bounded and
|
|
198
|
+
* ordered oldest-first; a request whose span exceeds
|
|
199
|
+
* {@link CALL_INDEX_MAX_DAY_BUCKETS} fails with `reply-too-large` instead of
|
|
200
|
+
* silently truncating a trend line.
|
|
201
|
+
*/
|
|
202
|
+
/**
|
|
203
|
+
* Per-source counts. All five keys are always emitted by this Host, but a reply
|
|
204
|
+
* that omits one is still readable: the missing kind is 0 and the caller renders
|
|
205
|
+
* it as "not resolved" anyway (R-009 forbids reading 0 as "unused"). Rejecting
|
|
206
|
+
* the whole overview over one absent key was never worth it.
|
|
207
|
+
*/
|
|
208
|
+
export declare const callIndexSourceCountsSchema: z.ZodPipe<z.ZodObject<{
|
|
209
|
+
mcp: z.ZodOptional<z.ZodNumber>;
|
|
210
|
+
'plugin-tool': z.ZodOptional<z.ZodNumber>;
|
|
211
|
+
native: z.ZodOptional<z.ZodNumber>;
|
|
212
|
+
skill: z.ZodOptional<z.ZodNumber>;
|
|
213
|
+
unknown: z.ZodOptional<z.ZodNumber>;
|
|
214
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
215
|
+
mcp: number;
|
|
216
|
+
'plugin-tool': number;
|
|
217
|
+
native: number;
|
|
218
|
+
skill: number;
|
|
219
|
+
unknown: number;
|
|
220
|
+
}, {
|
|
221
|
+
mcp?: number | undefined;
|
|
222
|
+
'plugin-tool'?: number | undefined;
|
|
223
|
+
native?: number | undefined;
|
|
224
|
+
skill?: number | undefined;
|
|
225
|
+
unknown?: number | undefined;
|
|
226
|
+
}>>;
|
|
227
|
+
export declare const callIndexAggregatesSchema: z.ZodObject<{
|
|
228
|
+
distinctTools: z.ZodNumber;
|
|
229
|
+
bySource: z.ZodPipe<z.ZodObject<{
|
|
230
|
+
mcp: z.ZodOptional<z.ZodNumber>;
|
|
231
|
+
'plugin-tool': z.ZodOptional<z.ZodNumber>;
|
|
232
|
+
native: z.ZodOptional<z.ZodNumber>;
|
|
233
|
+
skill: z.ZodOptional<z.ZodNumber>;
|
|
234
|
+
unknown: z.ZodOptional<z.ZodNumber>;
|
|
235
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
236
|
+
mcp: number;
|
|
237
|
+
'plugin-tool': number;
|
|
238
|
+
native: number;
|
|
239
|
+
skill: number;
|
|
240
|
+
unknown: number;
|
|
241
|
+
}, {
|
|
242
|
+
mcp?: number | undefined;
|
|
243
|
+
'plugin-tool'?: number | undefined;
|
|
244
|
+
native?: number | undefined;
|
|
245
|
+
skill?: number | undefined;
|
|
246
|
+
unknown?: number | undefined;
|
|
247
|
+
}>>;
|
|
248
|
+
byDay: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodObject<{
|
|
249
|
+
day: z.ZodString;
|
|
250
|
+
calls: z.ZodOptional<z.ZodNumber>;
|
|
251
|
+
success: z.ZodOptional<z.ZodNumber>;
|
|
252
|
+
error: z.ZodOptional<z.ZodNumber>;
|
|
253
|
+
cancelled: z.ZodOptional<z.ZodNumber>;
|
|
254
|
+
unresolved: z.ZodOptional<z.ZodNumber>;
|
|
255
|
+
unknown: z.ZodOptional<z.ZodNumber>;
|
|
256
|
+
running: z.ZodOptional<z.ZodNumber>;
|
|
257
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
258
|
+
day: string;
|
|
259
|
+
calls: number;
|
|
260
|
+
success: number;
|
|
261
|
+
error: number;
|
|
262
|
+
cancelled: number;
|
|
263
|
+
unresolved: number;
|
|
264
|
+
unknown: number;
|
|
265
|
+
running: number;
|
|
266
|
+
}, {
|
|
267
|
+
day: string;
|
|
268
|
+
calls?: number | undefined;
|
|
269
|
+
success?: number | undefined;
|
|
270
|
+
error?: number | undefined;
|
|
271
|
+
cancelled?: number | undefined;
|
|
272
|
+
unresolved?: number | undefined;
|
|
273
|
+
unknown?: number | undefined;
|
|
274
|
+
running?: number | undefined;
|
|
275
|
+
}>>>>;
|
|
276
|
+
dayOffsetMinutes: z.ZodNumber;
|
|
277
|
+
}, z.core.$strip>;
|
|
278
|
+
/** Public, non-throwing projector used by the Host gateway and the client codec. */
|
|
279
|
+
export declare function callIndexReply(value: unknown): CallIndexReply;
|
|
280
|
+
/**
|
|
281
|
+
* Zod codec for replies. `.parse` always succeeds and returns the projected
|
|
282
|
+
* reply, so a malformed Host payload degrades to `internal-error` instead of a
|
|
283
|
+
* transport failure.
|
|
284
|
+
*/
|
|
285
|
+
export declare const callIndexReplySchema: z.ZodPipe<z.ZodAny, z.ZodTransform<CallIndexReply, any>>;
|
|
286
|
+
//# sourceMappingURL=call-index-wire.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-index-wire.d.ts","sourceRoot":"","sources":["../../../src/usage/call-index-wire.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,gDAAgD;AAChD,eAAO,MAAM,sBAAsB,gFAQzB,CAAA;AACV,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAA;AAExE,0EAA0E;AAC1E,eAAO,MAAM,wBAAwB,0MAW3B,CAAA;AACV,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAA;AAE5E,0DAA0D;AAC1D,eAAO,MAAM,mBAAmB,gFAOtB,CAAA;AACV,MAAM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AM,0BAA0B,MAAM,CAAA;AAE7C,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;kBAkB/B,CAAA;AAEX,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAO5B,CAAA;AAEX,eAAO,MAAM,4BAA4B;;;;kBAM9B,CAAA;AAEX,qEAAqE;AACrE,eAAO,MAAM,2BAA2B;;;;;kBAE7B,CAAA;AAEX,kFAAkF;AAClF,eAAO,MAAM,4BAA4B;;kBAE9B,CAAA;AA+BX,kFAAkF;AAClF,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAejC,CAAA;AAWF,eAAO,MAAM,0BAA0B;;;;;;;;;;;iBAAmB,CAAA;AA2C1D;;;;;;;;GAQG;AACH;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;GAYrC,CAAA;AAmCH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAQpC,CAAA;AAkMF,oFAAoF;AACpF,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAE7D;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,0DAA+D,CAAA"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { type CallIndexSourceResolver } from './call-index-core.ts';
|
|
2
|
+
export interface SessionCallIndexOptions {
|
|
3
|
+
getMode: () => unknown;
|
|
4
|
+
getBackend: () => unknown;
|
|
5
|
+
/** Optional public SessionStore membership; it never supplies historical content. */
|
|
6
|
+
isLiveSession?: (id: string) => boolean;
|
|
7
|
+
pageSize?: number;
|
|
8
|
+
maxBytes?: number;
|
|
9
|
+
maxCalls?: number;
|
|
10
|
+
maxSessions?: number;
|
|
11
|
+
maxEventsPerSession?: number;
|
|
12
|
+
maxOrphans?: number;
|
|
13
|
+
maxLiveQueue?: number;
|
|
14
|
+
now?: () => number;
|
|
15
|
+
yield?: () => Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Provenance resolver built from trusted catalog evidence by the runtime.
|
|
18
|
+
*
|
|
19
|
+
* Absent means the Host has no capability service, so every row reports
|
|
20
|
+
* `unknown` provenance and `semanticCoverage.source` stays `unknown`.
|
|
21
|
+
*/
|
|
22
|
+
resolveSource?: CallIndexSourceResolver;
|
|
23
|
+
}
|
|
24
|
+
export interface IndexScanOptions {
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
maxEvents?: number;
|
|
27
|
+
full?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* In-memory engine for N22. It is deliberately not mounted in the old Usage runtime.
|
|
31
|
+
* Scope is freshly resolved before AND after asynchronous service operations.
|
|
32
|
+
* Memory limits bound estimated retained index metadata, not backend decoding/RSS.
|
|
33
|
+
*/
|
|
34
|
+
export declare class SessionCallIndex {
|
|
35
|
+
private readonly options;
|
|
36
|
+
private readonly scopes;
|
|
37
|
+
private lastScope;
|
|
38
|
+
private token;
|
|
39
|
+
private ledger;
|
|
40
|
+
private readonly published;
|
|
41
|
+
private readonly stages;
|
|
42
|
+
private readonly live;
|
|
43
|
+
private readonly observedThrough;
|
|
44
|
+
private readonly visible;
|
|
45
|
+
private readonly pending;
|
|
46
|
+
private readonly failures;
|
|
47
|
+
private readonly reasons;
|
|
48
|
+
private task;
|
|
49
|
+
private aborter;
|
|
50
|
+
private fairCursor;
|
|
51
|
+
private generation;
|
|
52
|
+
private censusGeneration;
|
|
53
|
+
private asOf;
|
|
54
|
+
private enumerated;
|
|
55
|
+
private enumerationCurrent;
|
|
56
|
+
private listedCount;
|
|
57
|
+
private phase;
|
|
58
|
+
private liveCount;
|
|
59
|
+
private disposed;
|
|
60
|
+
private readonly limits;
|
|
61
|
+
constructor(options: SessionCallIndexOptions);
|
|
62
|
+
private gap;
|
|
63
|
+
private syncScope;
|
|
64
|
+
private guard;
|
|
65
|
+
private reserve;
|
|
66
|
+
private discard;
|
|
67
|
+
/** Immediate projection keeps raw events out of the bounded live queue. */
|
|
68
|
+
observeLive(sessionId: string, raw: unknown, inheritedEventCount: number): boolean;
|
|
69
|
+
/** One active task, including concurrent callers. Cancellation is not a second task. */
|
|
70
|
+
start(options?: IndexScanOptions): Promise<ReturnType<SessionCallIndex['snapshot']>>;
|
|
71
|
+
/** Host observation failures are fixed codes, never exception messages or raw payloads. */
|
|
72
|
+
markGap(reason: 'live-projection-failed' | 'live-timer-failed'): void;
|
|
73
|
+
/** Publish observed metadata only; never enumerate/open historical storage here. */
|
|
74
|
+
flushLive(): ReturnType<SessionCallIndex['snapshot']>;
|
|
75
|
+
/** Cheap authorization/data stamp; resolving it also notices live backend replacement. */
|
|
76
|
+
stamp(): {
|
|
77
|
+
epoch?: number;
|
|
78
|
+
generation: number;
|
|
79
|
+
};
|
|
80
|
+
cancel(): void;
|
|
81
|
+
dispose(): void;
|
|
82
|
+
private stage;
|
|
83
|
+
private mergeLive;
|
|
84
|
+
private publish;
|
|
85
|
+
private run;
|
|
86
|
+
snapshot(includeRows?: boolean): {
|
|
87
|
+
corpus: "persisted-plus-observed-live";
|
|
88
|
+
scope: import("./call-index-scope.ts").CallIndexScopeDescription;
|
|
89
|
+
generation: number;
|
|
90
|
+
censusGeneration: number;
|
|
91
|
+
asOf: number | undefined;
|
|
92
|
+
phase: "cancelled" | "complete" | "failed" | "running" | "idle";
|
|
93
|
+
coverage: "complete" | "partial" | "unknown";
|
|
94
|
+
eventCoverage: "complete" | "partial" | "unknown";
|
|
95
|
+
enumerationCoverage: "complete" | "partial" | "unknown";
|
|
96
|
+
semanticCoverage: {
|
|
97
|
+
source: "unknown" | "verified";
|
|
98
|
+
ptc: "unknown";
|
|
99
|
+
skillExecution: "unavailable";
|
|
100
|
+
denied: "unavailable";
|
|
101
|
+
};
|
|
102
|
+
listedSessions: number;
|
|
103
|
+
visibleSessions: number;
|
|
104
|
+
completedSessions: number;
|
|
105
|
+
pendingSessions: number;
|
|
106
|
+
failedSessions: number;
|
|
107
|
+
pendingLive: number;
|
|
108
|
+
declaredEvents: number;
|
|
109
|
+
readEvents: number;
|
|
110
|
+
estimatedBytes: number;
|
|
111
|
+
reasons: string[];
|
|
112
|
+
sessions: {
|
|
113
|
+
revision: string;
|
|
114
|
+
cut: number;
|
|
115
|
+
coverage: "complete" | "partial";
|
|
116
|
+
stale: boolean;
|
|
117
|
+
reasons: string[];
|
|
118
|
+
cwd?: string | undefined;
|
|
119
|
+
sessionId: string;
|
|
120
|
+
}[];
|
|
121
|
+
rows: {
|
|
122
|
+
sessionId: string;
|
|
123
|
+
callSeq: number;
|
|
124
|
+
callId: string;
|
|
125
|
+
toolName: string;
|
|
126
|
+
turn?: number;
|
|
127
|
+
step?: number;
|
|
128
|
+
startedAt: number;
|
|
129
|
+
endedAt?: number;
|
|
130
|
+
resultSeq?: number;
|
|
131
|
+
durationMs?: number;
|
|
132
|
+
outcome: "success" | "error" | "cancelled" | "unresolved" | "unknown" | "running";
|
|
133
|
+
inherited: boolean;
|
|
134
|
+
sourceKind: import("./call-index-wire.ts").CallIndexSourceKind;
|
|
135
|
+
layer: "unknown";
|
|
136
|
+
}[];
|
|
137
|
+
totals: {
|
|
138
|
+
calls: number;
|
|
139
|
+
succeeded: number;
|
|
140
|
+
failed: number;
|
|
141
|
+
unresolved: number;
|
|
142
|
+
unknown: number;
|
|
143
|
+
cancelled: number;
|
|
144
|
+
running: number;
|
|
145
|
+
inherited: number;
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=session-index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-index.d.ts","sourceRoot":"","sources":["../../../src/usage/session-index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmG,KAAK,uBAAuB,EAAE,MAAM,sBAAsB,CAAA;AASpK,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,OAAO,CAAA;IACtB,UAAU,E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