agent-rulebook 0.2.1 → 0.3.1
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 +69 -5
- package/dist/commands/dashboard.d.ts +7 -0
- package/dist/commands/dashboard.js +42 -0
- package/dist/commands/dashboard.js.map +1 -0
- package/dist/commands/diagnostics.d.ts +2 -0
- package/dist/commands/diagnostics.js +38 -0
- package/dist/commands/diagnostics.js.map +1 -0
- package/dist/commands/import.d.ts +2 -0
- package/dist/commands/import.js +34 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/pending.d.ts +2 -0
- package/dist/commands/pending.js +27 -0
- package/dist/commands/pending.js.map +1 -0
- package/dist/commands/resolution.js +25 -11
- package/dist/commands/resolution.js.map +1 -1
- package/dist/commands/stats-renderer.d.ts +3 -0
- package/dist/commands/stats-renderer.js +76 -0
- package/dist/commands/stats-renderer.js.map +1 -0
- package/dist/commands/stats.d.ts +4 -0
- package/dist/commands/stats.js +107 -0
- package/dist/commands/stats.js.map +1 -0
- package/dist/commands/status.d.ts +2 -0
- package/dist/commands/status.js +17 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/sync.js +1 -1
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/usage.d.ts +2 -0
- package/dist/commands/usage.js +25 -0
- package/dist/commands/usage.js.map +1 -0
- package/dist/core/codex-call-parser.d.ts +10 -0
- package/dist/core/codex-call-parser.js +97 -0
- package/dist/core/codex-call-parser.js.map +1 -0
- package/dist/core/codex-usage-import.d.ts +24 -0
- package/dist/core/codex-usage-import.js +259 -0
- package/dist/core/codex-usage-import.js.map +1 -0
- package/dist/core/diagnostic-cluster.d.ts +37 -0
- package/dist/core/diagnostic-cluster.js +20 -0
- package/dist/core/diagnostic-cluster.js.map +1 -0
- package/dist/core/environment-normalization.d.ts +21 -0
- package/dist/core/environment-normalization.js +42 -0
- package/dist/core/environment-normalization.js.map +1 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/invocation-diagnostics.d.ts +40 -0
- package/dist/core/invocation-diagnostics.js +91 -0
- package/dist/core/invocation-diagnostics.js.map +1 -0
- package/dist/core/legacy-candidate.d.ts +159 -0
- package/dist/core/legacy-candidate.js +73 -0
- package/dist/core/legacy-candidate.js.map +1 -0
- package/dist/core/legacy-import-apply.d.ts +215 -0
- package/dist/core/legacy-import-apply.js +172 -0
- package/dist/core/legacy-import-apply.js.map +1 -0
- package/dist/core/legacy-import-manifest.d.ts +197 -0
- package/dist/core/legacy-import-manifest.js +63 -0
- package/dist/core/legacy-import-manifest.js.map +1 -0
- package/dist/core/legacy-scan.d.ts +71 -0
- package/dist/core/legacy-scan.js +99 -0
- package/dist/core/legacy-scan.js.map +1 -0
- package/dist/core/pending-replay.d.ts +4 -0
- package/dist/core/pending-replay.js +96 -0
- package/dist/core/pending-replay.js.map +1 -0
- package/dist/core/resolution-applicability.d.ts +1 -0
- package/dist/core/resolution-applicability.js +28 -11
- package/dist/core/resolution-applicability.js.map +1 -1
- package/dist/core/resolution-ranker.js +9 -2
- package/dist/core/resolution-ranker.js.map +1 -1
- package/dist/core/resolution-search-types.d.ts +9 -0
- package/dist/core/statistics-data.d.ts +98 -0
- package/dist/core/statistics-data.js +53 -0
- package/dist/core/statistics-data.js.map +1 -0
- package/dist/core/statistics-pages.d.ts +3 -0
- package/dist/core/statistics-pages.js +107 -0
- package/dist/core/statistics-pages.js.map +1 -0
- package/dist/core/statistics-query.d.ts +86 -0
- package/dist/core/statistics-query.js +51 -0
- package/dist/core/statistics-query.js.map +1 -0
- package/dist/core/statistics-types.d.ts +286 -0
- package/dist/core/statistics-types.js +2 -0
- package/dist/core/statistics-types.js.map +1 -0
- package/dist/core/statistics.d.ts +5 -0
- package/dist/core/statistics.js +101 -0
- package/dist/core/statistics.js.map +1 -0
- package/dist/core/sync-status.d.ts +53 -0
- package/dist/core/sync-status.js +85 -0
- package/dist/core/sync-status.js.map +1 -0
- package/dist/core/usage-context.d.ts +15 -0
- package/dist/core/usage-context.js +22 -0
- package/dist/core/usage-context.js.map +1 -0
- package/dist/core/usage-observer.d.ts +36 -0
- package/dist/core/usage-observer.js +112 -0
- package/dist/core/usage-observer.js.map +1 -0
- package/dist/core/usage-schema.d.ts +113 -0
- package/dist/core/usage-schema.js +33 -0
- package/dist/core/usage-schema.js.map +1 -0
- package/dist/dashboard/public/api.js +41 -0
- package/dist/dashboard/public/app.js +111 -0
- package/dist/dashboard/public/components/detail-panel.js +21 -0
- package/dist/dashboard/public/components/index.js +216 -0
- package/dist/dashboard/public/components/input-diff.js +15 -0
- package/dist/dashboard/public/diagnostic-detail.js +25 -0
- package/dist/dashboard/public/diagnostics.js +46 -0
- package/dist/dashboard/public/index.html +28 -0
- package/dist/dashboard/public/knowledge.js +57 -0
- package/dist/dashboard/public/overview.js +101 -0
- package/dist/dashboard/public/solution-detail.js +42 -0
- package/dist/dashboard/public/styles.css +205 -0
- package/dist/dashboard/server.d.ts +10 -0
- package/dist/dashboard/server.js +133 -0
- package/dist/dashboard/server.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/observed-transport.d.ts +20 -0
- package/dist/mcp/observed-transport.js +99 -0
- package/dist/mcp/observed-transport.js.map +1 -0
- package/dist/mcp/resolution-change.d.ts +1 -1
- package/dist/mcp/resolution-change.js +24 -9
- package/dist/mcp/resolution-change.js.map +1 -1
- package/dist/mcp/resolutions-commit-change-tool.d.ts +5 -0
- package/dist/mcp/resolutions-commit-change-tool.js +22 -4
- package/dist/mcp/resolutions-commit-change-tool.js.map +1 -1
- package/dist/mcp/resolutions-find-tool.d.ts +1 -2
- package/dist/mcp/resolutions-find-tool.js +43 -8
- package/dist/mcp/resolutions-find-tool.js.map +1 -1
- package/dist/mcp/resolutions-list-facets-tool.d.ts +1 -1
- package/dist/mcp/resolutions-list-facets-tool.js +16 -2
- package/dist/mcp/resolutions-list-facets-tool.js.map +1 -1
- package/dist/mcp/resolutions-report-attempt-tool.d.ts +1 -0
- package/dist/mcp/resolutions-report-attempt-tool.js +44 -55
- package/dist/mcp/resolutions-report-attempt-tool.js.map +1 -1
- package/dist/mcp/schemas.d.ts +299 -14
- package/dist/mcp/schemas.js +31 -10
- package/dist/mcp/schemas.js.map +1 -1
- package/dist/mcp/server.js +20 -5
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/stats-get-tool.d.ts +99 -0
- package/dist/mcp/stats-get-tool.js +17 -0
- package/dist/mcp/stats-get-tool.js.map +1 -0
- package/dist/mcp/tool-call.d.ts +99 -0
- package/dist/mcp/tool-call.js +20 -0
- package/dist/mcp/tool-call.js.map +1 -0
- package/dist/mcp/tool-output.d.ts +9 -0
- package/dist/mcp/tool-output.js +22 -0
- package/dist/mcp/tool-output.js.map +1 -1
- package/dist/mcp/tools.d.ts +182 -27
- package/dist/mcp/tools.js +10 -3
- package/dist/mcp/tools.js.map +1 -1
- package/dist/program.js +14 -0
- package/dist/program.js.map +1 -1
- package/dist/storage/canonical-write-lock.d.ts +2 -0
- package/dist/storage/canonical-write-lock.js +32 -0
- package/dist/storage/canonical-write-lock.js.map +1 -0
- package/dist/storage/diagnostic-store.d.ts +21 -0
- package/dist/storage/diagnostic-store.js +50 -0
- package/dist/storage/diagnostic-store.js.map +1 -0
- package/dist/storage/import-manifest.d.ts +6 -0
- package/dist/storage/import-manifest.js +41 -0
- package/dist/storage/import-manifest.js.map +1 -0
- package/dist/storage/pending-store.d.ts +329 -0
- package/dist/storage/pending-store.js +164 -0
- package/dist/storage/pending-store.js.map +1 -0
- package/dist/storage/resolution-candidate-service.js +2 -1
- package/dist/storage/resolution-candidate-service.js.map +1 -1
- package/dist/storage/resolution-change-transaction.d.ts +41 -3
- package/dist/storage/resolution-change-transaction.js +101 -12
- package/dist/storage/resolution-change-transaction.js.map +1 -1
- package/dist/storage/resolution-home.js +1 -1
- package/dist/storage/resolution-home.js.map +1 -1
- package/dist/storage/resolution-index-check.js +3 -2
- package/dist/storage/resolution-index-check.js.map +1 -1
- package/dist/storage/resolution-indexer.js +3 -1
- package/dist/storage/resolution-indexer.js.map +1 -1
- package/dist/storage/usage-store.d.ts +80 -0
- package/dist/storage/usage-store.js +239 -0
- package/dist/storage/usage-store.js.map +1 -0
- package/package.json +11 -4
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/** Browser-safe DTOs: no Node, database or validation runtime imports. */
|
|
2
|
+
export type StatisticsSource = 'live' | 'codex_history';
|
|
3
|
+
export type AppliedStatisticsQuery = {
|
|
4
|
+
days: number | null;
|
|
5
|
+
all: boolean;
|
|
6
|
+
source: StatisticsSource;
|
|
7
|
+
usage_kind: 'production' | 'test';
|
|
8
|
+
timezone: string;
|
|
9
|
+
project_key?: string;
|
|
10
|
+
language?: string;
|
|
11
|
+
page: number;
|
|
12
|
+
page_size: number;
|
|
13
|
+
applied_from: string | null;
|
|
14
|
+
applied_to: string;
|
|
15
|
+
};
|
|
16
|
+
export type Ratio = {
|
|
17
|
+
value: number | null;
|
|
18
|
+
numerator: number | null;
|
|
19
|
+
denominator: number | null;
|
|
20
|
+
sample_size: number | null;
|
|
21
|
+
definition: string;
|
|
22
|
+
};
|
|
23
|
+
export type CanonicalCounts = {
|
|
24
|
+
problems: number | null;
|
|
25
|
+
solutions: number | null;
|
|
26
|
+
revisions: number | null;
|
|
27
|
+
outcomes: number | null;
|
|
28
|
+
};
|
|
29
|
+
export type OutcomeCounts = {
|
|
30
|
+
solved: number;
|
|
31
|
+
failed: number;
|
|
32
|
+
regressed: number;
|
|
33
|
+
inapplicable: number;
|
|
34
|
+
inconclusive: number;
|
|
35
|
+
};
|
|
36
|
+
export type Breakdown = {
|
|
37
|
+
key: string;
|
|
38
|
+
count: number;
|
|
39
|
+
};
|
|
40
|
+
export type DiagnosticClusterDto = {
|
|
41
|
+
cluster_key: string;
|
|
42
|
+
tool: string;
|
|
43
|
+
schema_digest: string;
|
|
44
|
+
count: number;
|
|
45
|
+
first_at: string;
|
|
46
|
+
last_at: string;
|
|
47
|
+
representative_id: string;
|
|
48
|
+
issues: Array<{
|
|
49
|
+
code: string;
|
|
50
|
+
path: string;
|
|
51
|
+
expected: string;
|
|
52
|
+
received: string;
|
|
53
|
+
}>;
|
|
54
|
+
clients: string[];
|
|
55
|
+
package_versions: string[];
|
|
56
|
+
confidences?: string[];
|
|
57
|
+
categories?: string[];
|
|
58
|
+
explicit_retry_count: number;
|
|
59
|
+
successful_retry_count: number;
|
|
60
|
+
trace_available_count: number;
|
|
61
|
+
retry_linkage: 'explicit_only';
|
|
62
|
+
request_id_scope: 'connection_local';
|
|
63
|
+
};
|
|
64
|
+
export type RecordingCoverage = {
|
|
65
|
+
status: 'not_recorded' | 'partial' | 'complete' | 'disabled' | 'degraded';
|
|
66
|
+
recorded_from: string | null;
|
|
67
|
+
unknown_before: string | null;
|
|
68
|
+
pruned_intervals: Array<{
|
|
69
|
+
source: string;
|
|
70
|
+
from_at: string;
|
|
71
|
+
to_at: string;
|
|
72
|
+
removed_count: number;
|
|
73
|
+
}>;
|
|
74
|
+
has_recorded_interval: boolean;
|
|
75
|
+
source: StatisticsSource;
|
|
76
|
+
usage_kind: 'production' | 'test';
|
|
77
|
+
confidence: Breakdown[];
|
|
78
|
+
scope: string;
|
|
79
|
+
};
|
|
80
|
+
export type KnowledgeRow = {
|
|
81
|
+
id: string;
|
|
82
|
+
kind: 'problem' | 'solution' | 'pending' | 'legacy';
|
|
83
|
+
title: string;
|
|
84
|
+
status: string;
|
|
85
|
+
created_at: string | null;
|
|
86
|
+
problem_id?: string;
|
|
87
|
+
solution_handle?: string;
|
|
88
|
+
revision?: number;
|
|
89
|
+
languages: string[];
|
|
90
|
+
platforms: string[];
|
|
91
|
+
tools: string[];
|
|
92
|
+
runtimes: string[];
|
|
93
|
+
source_projects: string[];
|
|
94
|
+
used_in_projects: string[];
|
|
95
|
+
summary: string;
|
|
96
|
+
cause?: string;
|
|
97
|
+
applicable_if?: string[];
|
|
98
|
+
reject_if?: string[];
|
|
99
|
+
inspections?: string[];
|
|
100
|
+
actions?: string[];
|
|
101
|
+
verification?: string[];
|
|
102
|
+
safety?: string[];
|
|
103
|
+
observations?: {
|
|
104
|
+
symptoms: string[];
|
|
105
|
+
error_signatures: string[];
|
|
106
|
+
expected: string;
|
|
107
|
+
observed: string;
|
|
108
|
+
};
|
|
109
|
+
source_evidence?: Array<{
|
|
110
|
+
id: string;
|
|
111
|
+
project_key: string;
|
|
112
|
+
relative_path: string;
|
|
113
|
+
tests: string[];
|
|
114
|
+
revision: string;
|
|
115
|
+
}>;
|
|
116
|
+
outcome_counts?: OutcomeCounts;
|
|
117
|
+
missing_fields?: string[];
|
|
118
|
+
relation?: string;
|
|
119
|
+
related_solution_handles?: string[];
|
|
120
|
+
outcome_reasons?: Array<{
|
|
121
|
+
result: string;
|
|
122
|
+
reason: string;
|
|
123
|
+
count: number;
|
|
124
|
+
}>;
|
|
125
|
+
};
|
|
126
|
+
export type PageResult<T> = {
|
|
127
|
+
status: string;
|
|
128
|
+
query: AppliedStatisticsQuery;
|
|
129
|
+
items: T[];
|
|
130
|
+
total: number | null;
|
|
131
|
+
page: number;
|
|
132
|
+
page_size: number;
|
|
133
|
+
has_more: boolean;
|
|
134
|
+
};
|
|
135
|
+
export type DiagnosticPreviewDto = {
|
|
136
|
+
representation_version: number;
|
|
137
|
+
raw_payload_retained: false;
|
|
138
|
+
redacted: true;
|
|
139
|
+
truncated: boolean;
|
|
140
|
+
input_shape: unknown;
|
|
141
|
+
redacted_preview: unknown;
|
|
142
|
+
issues: Array<{
|
|
143
|
+
code: string;
|
|
144
|
+
path: string;
|
|
145
|
+
expected: string;
|
|
146
|
+
received: string;
|
|
147
|
+
}>;
|
|
148
|
+
};
|
|
149
|
+
export type DiagnosticRecordDto = {
|
|
150
|
+
diagnostic_id: string;
|
|
151
|
+
invocation_id: string;
|
|
152
|
+
created_at: string;
|
|
153
|
+
tool: string;
|
|
154
|
+
schema_digest: string;
|
|
155
|
+
cluster_key: string;
|
|
156
|
+
diagnostic: DiagnosticPreviewDto;
|
|
157
|
+
};
|
|
158
|
+
export type DiagnosticMetadataDto = {
|
|
159
|
+
client_name: string | null;
|
|
160
|
+
client_version: string | null;
|
|
161
|
+
supplied_agent: string | null;
|
|
162
|
+
supplied_model: string | null;
|
|
163
|
+
package_version: string;
|
|
164
|
+
source: string;
|
|
165
|
+
confidence: string;
|
|
166
|
+
category: string | null;
|
|
167
|
+
investigation_id: string | null;
|
|
168
|
+
project_key: string | null;
|
|
169
|
+
};
|
|
170
|
+
export type DiagnosticDetailDto = {
|
|
171
|
+
record: DiagnosticRecordDto;
|
|
172
|
+
metadata: DiagnosticMetadataDto | null;
|
|
173
|
+
fixture: unknown;
|
|
174
|
+
retries: Array<{
|
|
175
|
+
invocation_id: string;
|
|
176
|
+
category: string | null;
|
|
177
|
+
status: string;
|
|
178
|
+
diagnostic: DiagnosticPreviewDto | null;
|
|
179
|
+
}>;
|
|
180
|
+
retry_total: number;
|
|
181
|
+
};
|
|
182
|
+
export type DiagnosticPageDto = PageResult<DiagnosticClusterDto> & {
|
|
183
|
+
coverage: RecordingCoverage;
|
|
184
|
+
records: DiagnosticRecordDto[];
|
|
185
|
+
details: DiagnosticDetailDto[];
|
|
186
|
+
};
|
|
187
|
+
export type Statistics = {
|
|
188
|
+
query: AppliedStatisticsQuery;
|
|
189
|
+
inventory: CanonicalCounts & {
|
|
190
|
+
status: string;
|
|
191
|
+
global: CanonicalCounts;
|
|
192
|
+
scope: string;
|
|
193
|
+
};
|
|
194
|
+
growth: {
|
|
195
|
+
observed_new_solutions: number | null;
|
|
196
|
+
observed_new_revisions: number | null;
|
|
197
|
+
source: string;
|
|
198
|
+
record_created_at: CanonicalCounts;
|
|
199
|
+
record_time_caveat: string;
|
|
200
|
+
};
|
|
201
|
+
activity: {
|
|
202
|
+
invocations: number | null;
|
|
203
|
+
find_calls: number | null;
|
|
204
|
+
valid_completed_find: number | null;
|
|
205
|
+
validation_errors: number | null;
|
|
206
|
+
no_results: number | null;
|
|
207
|
+
exhausted: number | null;
|
|
208
|
+
interrupted: number | null;
|
|
209
|
+
pending: number | null;
|
|
210
|
+
blocked: number | null;
|
|
211
|
+
hit_rate: Ratio;
|
|
212
|
+
validation_error_rate: Ratio;
|
|
213
|
+
no_results_rate: Ratio;
|
|
214
|
+
storage_success_rate: Ratio;
|
|
215
|
+
trace_missing_rate: Ratio;
|
|
216
|
+
source: string;
|
|
217
|
+
};
|
|
218
|
+
outcomes: {
|
|
219
|
+
source: string;
|
|
220
|
+
time_basis: string;
|
|
221
|
+
total: number | null;
|
|
222
|
+
counts: OutcomeCounts | null;
|
|
223
|
+
solve_rate: Ratio;
|
|
224
|
+
project_unknown: number | null;
|
|
225
|
+
interpretation: string;
|
|
226
|
+
};
|
|
227
|
+
funnel: {
|
|
228
|
+
linked_investigations: number;
|
|
229
|
+
linked_calls: number;
|
|
230
|
+
unlinked_calls: number;
|
|
231
|
+
searched: number;
|
|
232
|
+
candidates_found: number;
|
|
233
|
+
attempted: number;
|
|
234
|
+
solved: number;
|
|
235
|
+
captured: number;
|
|
236
|
+
scope: string;
|
|
237
|
+
};
|
|
238
|
+
reuse: {
|
|
239
|
+
known_cross_project: number;
|
|
240
|
+
known_same_project: number;
|
|
241
|
+
unknown: number;
|
|
242
|
+
coverage: Ratio;
|
|
243
|
+
};
|
|
244
|
+
breakdowns: {
|
|
245
|
+
languages: Breakdown[];
|
|
246
|
+
projects: Breakdown[];
|
|
247
|
+
tools: Breakdown[];
|
|
248
|
+
clients: Breakdown[];
|
|
249
|
+
};
|
|
250
|
+
timeline: Array<{
|
|
251
|
+
date: string;
|
|
252
|
+
find_calls: number | null;
|
|
253
|
+
validation_errors: number | null;
|
|
254
|
+
candidate_hits: number | null;
|
|
255
|
+
partial: boolean;
|
|
256
|
+
}>;
|
|
257
|
+
diagnostics: {
|
|
258
|
+
count: number | null;
|
|
259
|
+
clusters: DiagnosticClusterDto[];
|
|
260
|
+
};
|
|
261
|
+
coverage: RecordingCoverage;
|
|
262
|
+
health: {
|
|
263
|
+
status: string;
|
|
264
|
+
recording: {
|
|
265
|
+
status: string;
|
|
266
|
+
failure_count: number;
|
|
267
|
+
code: string | null;
|
|
268
|
+
};
|
|
269
|
+
canonical: string;
|
|
270
|
+
index: string;
|
|
271
|
+
pending_count: number | null;
|
|
272
|
+
import_backlog: number | null;
|
|
273
|
+
sync: {
|
|
274
|
+
remote_state: string;
|
|
275
|
+
remote_check: string;
|
|
276
|
+
divergence: string;
|
|
277
|
+
local_ahead: number | null;
|
|
278
|
+
local_behind: number | null;
|
|
279
|
+
conflicts: string[];
|
|
280
|
+
};
|
|
281
|
+
};
|
|
282
|
+
instruction_compliance: {
|
|
283
|
+
value: null;
|
|
284
|
+
reason: string;
|
|
285
|
+
};
|
|
286
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statistics-types.js","sourceRoot":"","sources":["../../src/core/statistics-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { readUsageStore } from '../storage/usage-store.js';
|
|
2
|
+
import type { AppliedStatisticsQuery, RecordingCoverage, Statistics } from './statistics-types.js';
|
|
3
|
+
export declare function recordingCoverage(snapshot: ReturnType<typeof readUsageStore>, query: AppliedStatisticsQuery): RecordingCoverage;
|
|
4
|
+
/** Shared read-only projection for CLI, MCP and HTTP. Never initializes, rebuilds or fetches. */
|
|
5
|
+
export declare function getStatistics(home: string, input?: unknown, now?: Date): Promise<Statistics>;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { readUsageStore } from '../storage/usage-store.js';
|
|
2
|
+
import { readDiagnostics } from '../storage/diagnostic-store.js';
|
|
3
|
+
import { getSyncStatus } from './sync-status.js';
|
|
4
|
+
import { clusterDiagnostics } from './diagnostic-cluster.js';
|
|
5
|
+
import { calendarDate, resolveStatisticsQuery, shiftCalendarDate, startOfCalendarDay } from './statistics-query.js';
|
|
6
|
+
import { breakdown, canonicalProjects, confirmed, countDocuments, emptyOutcomes, families, filterDocuments, matchesUsage, ratio, statisticsDocuments } from './statistics-data.js';
|
|
7
|
+
export function recordingCoverage(snapshot, query) {
|
|
8
|
+
const scoped = (snapshot.events ?? []).filter((e) => e.source === query.source && e.usage_kind === query.usage_kind);
|
|
9
|
+
const recorded = snapshot.coverage.sources[`${query.source}:${query.usage_kind}`] ?? scoped[0]?.started_at ?? null;
|
|
10
|
+
const gaps = snapshot.coverage.pruned.filter((gap) => gap.source === query.source && (!gap.usage_kind || gap.usage_kind === query.usage_kind) && gap.from_at < query.applied_to && (!query.applied_from || gap.to_at > query.applied_from));
|
|
11
|
+
const lower = [query.applied_from, recorded].filter((v) => v !== null).sort().at(-1) ?? query.applied_to;
|
|
12
|
+
let cursor = lower;
|
|
13
|
+
for (const gap of [...gaps].sort((a, b) => a.from_at.localeCompare(b.from_at))) {
|
|
14
|
+
if (gap.from_at <= cursor && gap.to_at > cursor)
|
|
15
|
+
cursor = gap.to_at;
|
|
16
|
+
}
|
|
17
|
+
const hasRecorded = snapshot.events !== null && recorded !== null && cursor < query.applied_to;
|
|
18
|
+
const partial = !query.applied_from || Boolean(recorded && query.applied_from < recorded) || gaps.length > 0 || query.source === 'codex_history';
|
|
19
|
+
const status = snapshot.status === 'disabled' ? 'disabled' : snapshot.status === 'degraded' ? 'degraded' : !recorded ? 'not_recorded' : partial ? 'partial' : 'complete';
|
|
20
|
+
return { status, recorded_from: recorded, unknown_before: recorded, pruned_intervals: gaps, has_recorded_interval: hasRecorded, source: query.source, usage_kind: query.usage_kind, confidence: breakdown(scoped.filter((e) => matchesUsage(e, query)).map((e) => e.confidence)), scope: query.source === 'live' ? 'Observed calls only; before recording and pruned intervals are unknown. Availability between calls is not proven.' : 'Explicitly imported session files only; missing sessions and inferred calls are not complete usage.' };
|
|
21
|
+
}
|
|
22
|
+
/** Shared read-only projection for CLI, MCP and HTTP. Never initializes, rebuilds or fetches. */
|
|
23
|
+
export async function getStatistics(home, input = {}, now = new Date()) {
|
|
24
|
+
const query = resolveStatisticsQuery(input, now);
|
|
25
|
+
const [documents, sync] = await Promise.all([statisticsDocuments(home), getSyncStatus(home)]);
|
|
26
|
+
const snapshot = readUsageStore(home);
|
|
27
|
+
const coverage = recordingCoverage(snapshot, query);
|
|
28
|
+
const events = (snapshot.events ?? []).filter((e) => matchesUsage(e, query));
|
|
29
|
+
const known = events.filter(confirmed);
|
|
30
|
+
const readable = snapshot.events !== null && (coverage.has_recorded_interval || events.length > 0);
|
|
31
|
+
const count = (n) => readable ? n : null;
|
|
32
|
+
const find = events.filter((e) => e.tool === 'resolutions.find');
|
|
33
|
+
const validFind = find.filter((e) => confirmed(e) && normal(e));
|
|
34
|
+
const hits = validFind.filter((e) => (e.result_summary.candidate_count ?? 0) > 0);
|
|
35
|
+
const hitKnown = validFind.every((e) => e.category !== 'success' || e.result_summary.candidate_count !== undefined);
|
|
36
|
+
const errors = find.filter((e) => e.category === 'validation_error');
|
|
37
|
+
const noResults = validFind.filter((e) => e.category === 'no_results');
|
|
38
|
+
const filtered = documents && filterDocuments(documents, snapshot.events ?? [], query);
|
|
39
|
+
const windowed = documents && filterDocuments(documents, snapshot.events ?? [], query, true);
|
|
40
|
+
const outcomes = windowed?.filter((d) => d.kind === 'outcome') ?? null;
|
|
41
|
+
const outcomeCounts = outcomes ? emptyOutcomes() : null;
|
|
42
|
+
for (const outcome of outcomes ?? [])
|
|
43
|
+
outcomeCounts[outcome.result]++;
|
|
44
|
+
const committed = known.filter((e) => normal(e) && e.tool === 'resolutions.commit_change' && e.result_summary.canonical_write === true);
|
|
45
|
+
const writes = known.filter((e) => ['resolutions.commit_change', 'resolutions.report_attempt'].includes(e.tool));
|
|
46
|
+
const outcomeById = new Map((documents ?? []).filter((d) => d.kind === 'outcome').map((d) => [d.id, d]));
|
|
47
|
+
const linked = new Map();
|
|
48
|
+
for (const event of known)
|
|
49
|
+
if (event.investigation_id) {
|
|
50
|
+
const key = `${event.project_key ?? '__unknown__'}:${event.investigation_id}`;
|
|
51
|
+
const group = linked.get(key) ?? [];
|
|
52
|
+
group.push(event);
|
|
53
|
+
linked.set(key, group);
|
|
54
|
+
}
|
|
55
|
+
const groups = [...linked.values()];
|
|
56
|
+
const groupCount = (fn) => groups.filter((g) => g.some(fn)).length;
|
|
57
|
+
const solutions = new Map((documents ?? []).filter((d) => d.kind === 'solution').map((d) => [`${d.id}@${d.revision}`, d]));
|
|
58
|
+
const reuse = { known_cross_project: 0, known_same_project: 0, unknown: 0 };
|
|
59
|
+
for (const event of known.filter((e) => ['resolutions.get', 'resolutions.report_attempt'].includes(e.tool) && normal(e))) {
|
|
60
|
+
const sources = solutions.get(event.result_summary.solution_handle ?? '')?.source_evidence.map((e) => e.project_key) ?? [];
|
|
61
|
+
if (!event.project_key || !sources.length)
|
|
62
|
+
reuse.unknown++;
|
|
63
|
+
else if (sources.includes(event.project_key))
|
|
64
|
+
reuse.known_same_project++;
|
|
65
|
+
else
|
|
66
|
+
reuse.known_cross_project++;
|
|
67
|
+
}
|
|
68
|
+
const diagnosticSnapshot = readDiagnostics(home);
|
|
69
|
+
const ids = new Set(events.map((e) => e.invocation_id));
|
|
70
|
+
const diagnosticRows = diagnosticSnapshot.diagnostics.filter((d) => ids.has(d.invocation_id));
|
|
71
|
+
const today = calendarDate(now, query.timezone);
|
|
72
|
+
const first = query.applied_from ? calendarDate(new Date(query.applied_from), query.timezone) : events[0] ? calendarDate(new Date(events[0].started_at), query.timezone) : today;
|
|
73
|
+
// For all-history queries keep a sparse timeline; bounded day queries include empty days.
|
|
74
|
+
const dates = query.all ? [...new Set(events.map((e) => calendarDate(new Date(e.started_at), query.timezone)))].sort() : Array.from({ length: query.days }, (_, i) => shiftCalendarDate(first, i));
|
|
75
|
+
const timeline = dates.map((date) => {
|
|
76
|
+
const from = startOfCalendarDay(date, query.timezone).toISOString();
|
|
77
|
+
const to = startOfCalendarDay(shiftCalendarDate(date, 1), query.timezone).toISOString();
|
|
78
|
+
const dayCoverage = recordingCoverage(snapshot, { ...query, applied_from: from, applied_to: to < query.applied_to ? to : query.applied_to });
|
|
79
|
+
const rows = find.filter((e) => e.started_at >= from && e.started_at < to);
|
|
80
|
+
const observed = dayCoverage.has_recorded_interval || rows.length > 0;
|
|
81
|
+
return { date, find_calls: observed ? rows.length : null, validation_errors: observed ? rows.filter((e) => e.category === 'validation_error').length : null, candidate_hits: observed ? rows.filter((e) => confirmed(e) && normal(e) && (e.result_summary.candidate_count ?? 0) > 0).length : null, partial: dayCoverage.status !== 'complete' };
|
|
82
|
+
});
|
|
83
|
+
const canonical = documents === null ? 'invalid' : 'ok';
|
|
84
|
+
return {
|
|
85
|
+
query,
|
|
86
|
+
inventory: { ...countDocuments(filtered), status: canonical, global: countDocuments(documents), scope: 'Current canonical inventory; language and source/confirmed-use project filters apply, time/source/kind do not.' },
|
|
87
|
+
growth: { observed_new_solutions: query.source === 'live' ? count(new Set(committed.flatMap((e) => e.result_summary.created_solution_ids ?? [])).size) : null, observed_new_revisions: query.source === 'live' ? count(new Set(committed.flatMap((e) => e.result_summary.created_revisions ?? [])).size) : null, source: 'live committed receipts with canonical_write=true', record_created_at: countDocuments(windowed), record_time_caveat: 'Canonical created_at is author supplied, not the observed storage time.' },
|
|
88
|
+
activity: { invocations: count(events.length), find_calls: count(find.length), valid_completed_find: count(validFind.length), validation_errors: count(errors.length), no_results: count(noResults.length), exhausted: count(validFind.filter((e) => e.category === 'candidates_exhausted').length), interrupted: count(events.filter((e) => e.status !== 'completed').length), pending: count(events.filter((e) => e.result_summary.status === 'pending').length), blocked: count(events.filter((e) => e.result_summary.status === 'blocked').length), hit_rate: ratio(hitKnown ? count(hits.length) : null, count(validFind.length), 'confirmed completed find with candidates / confirmed normally completed find'), validation_error_rate: ratio(count(errors.length), count(find.length), 'find validation errors / all observed find invocations including interrupted'), no_results_rate: ratio(count(noResults.length), count(validFind.length), 'no_results / confirmed normally completed find; exhausted is separate'), storage_success_rate: ratio(count(writes.filter((e) => normal(e) && (e.result_summary.canonical_write === true || ['already_committed', 'already_recorded'].includes(e.result_summary.status ?? ''))).length), count(writes.length), 'successful confirmed commit/report calls including verified replay / all confirmed commit/report calls'), trace_missing_rate: ratio(count(events.filter((e) => !e.investigation_id).length), count(events.length), 'calls without explicit investigation_id / all observed calls'), source: query.source },
|
|
89
|
+
outcomes: { source: 'canonical_evidence', time_basis: 'record_created_at', total: outcomes?.length ?? null, counts: outcomeCounts, solve_rate: ratio(outcomeCounts?.solved ?? null, outcomeCounts ? outcomeCounts.solved + outcomeCounts.failed + outcomeCounts.regressed : null, 'solved / (solved + failed + regressed); unique canonical outcome IDs'), project_unknown: documents && outcomes ? outcomes.filter((d) => canonicalProjects(d, documents, snapshot.events ?? []).length === 0).length : null, interpretation: 'Stored verified evidence only; not total agent success. Inapplicable and inconclusive are separate. Project attribution requires an explicit confirmed outcome link.' },
|
|
90
|
+
funnel: { linked_investigations: groups.length, linked_calls: known.filter((e) => e.investigation_id).length, unlinked_calls: events.filter((e) => !confirmed(e) || !e.investigation_id).length, searched: groupCount((e) => e.tool === 'resolutions.find'), candidates_found: groupCount((e) => e.tool === 'resolutions.find' && normal(e) && (e.result_summary.candidate_count ?? 0) > 0), attempted: groupCount((e) => e.tool === 'resolutions.report_attempt' && normal(e)), solved: groupCount((e) => normal(e) && e.result_summary.canonical_write === true && outcomeById.get(e.result_summary.outcome_id ?? '')?.result === 'solved'), captured: groupCount((e) => committed.includes(e)), scope: 'Explicit investigation_id within project only; stages are independent observed events, not inferred sequential conversions.' },
|
|
91
|
+
reuse: { ...reuse, coverage: ratio(reuse.known_cross_project + reuse.known_same_project, reuse.known_cross_project + reuse.known_same_project + reuse.unknown, 'successful get/attempt calls with known source and use projects / successful get/attempt calls') },
|
|
92
|
+
breakdowns: { languages: breakdown(events.flatMap((e) => e.languages.length ? families(e.languages) : ['unknown'])), projects: breakdown(events.map((e) => e.project_key ?? 'unknown')), tools: breakdown(events.map((e) => e.tool)), clients: breakdown(events.map((e) => e.client_name ?? 'unknown')) },
|
|
93
|
+
timeline,
|
|
94
|
+
diagnostics: { count: readable && diagnosticSnapshot.status !== 'degraded' ? diagnosticRows.length : null, clusters: clusterDiagnostics(diagnosticRows, events).slice(0, query.page_size) },
|
|
95
|
+
coverage,
|
|
96
|
+
health: { status: canonical !== 'ok' || sync.index.status !== 'ok' || snapshot.status === 'degraded' ? 'degraded' : 'ok', recording: snapshot.health, canonical, index: sync.index.status, pending_count: sync.pending_count, import_backlog: sync.imports.pending, sync: sync.git },
|
|
97
|
+
instruction_compliance: { value: null, reason: 'The total number of agent problems and missed lookups is unobserved; no compliance percentage can be computed.' },
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function normal(event) { return event.status === 'completed' && ['success', 'no_results', 'candidates_exhausted'].includes(event.category ?? ''); }
|
|
101
|
+
//# sourceMappingURL=statistics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statistics.js","sourceRoot":"","sources":["../../src/core/statistics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACpH,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,QAAQ,EAAE,eAAe,EAAE,YAAY,EAAE,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAInL,MAAM,UAAU,iBAAiB,CAAC,QAA2C,EAAE,KAA6B;IAC1G,MAAM,MAAM,GAAG,CAAC,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC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AI,EAAE,MAAM,EAAE,gHAAgH,EAAE;KAClK,CAAC;AACJ,CAAC;AACD,SAAS,MAAM,CAAC,KAAiB,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,WAAW,IAAI,CAAC,SAAS,EAAE,YAAY,EAAE,sBAAsB,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** Local diagnostic only: it never fetches, pushes, commits or initializes a home. */
|
|
2
|
+
export declare function getSyncStatus(home: string): Promise<{
|
|
3
|
+
home_status: string;
|
|
4
|
+
canonical: {
|
|
5
|
+
status: string;
|
|
6
|
+
counts: null;
|
|
7
|
+
} | {
|
|
8
|
+
status: string;
|
|
9
|
+
counts: {
|
|
10
|
+
problems: number;
|
|
11
|
+
solutions: number;
|
|
12
|
+
revisions: number;
|
|
13
|
+
outcomes: number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
canonical_dirty: string[];
|
|
17
|
+
untracked_canonical: string[];
|
|
18
|
+
git: {
|
|
19
|
+
status: string;
|
|
20
|
+
remote_check: string;
|
|
21
|
+
remote_checked_at: null;
|
|
22
|
+
remote_state: string;
|
|
23
|
+
local_head: string | null;
|
|
24
|
+
upstream: string | null;
|
|
25
|
+
upstream_head: string | null;
|
|
26
|
+
local_ahead: number | null;
|
|
27
|
+
local_behind: number | null;
|
|
28
|
+
divergence: string;
|
|
29
|
+
conflicts: string[];
|
|
30
|
+
canonical_dirty: string[];
|
|
31
|
+
untracked_canonical: string[];
|
|
32
|
+
};
|
|
33
|
+
index: {
|
|
34
|
+
status: string;
|
|
35
|
+
} | {
|
|
36
|
+
status: "ok" | "stale" | "missing" | "clean_rebuild_required";
|
|
37
|
+
};
|
|
38
|
+
pending_count: number | null;
|
|
39
|
+
pending_status: string;
|
|
40
|
+
imports: {
|
|
41
|
+
status: string;
|
|
42
|
+
manifests: number;
|
|
43
|
+
pending: number;
|
|
44
|
+
} | {
|
|
45
|
+
status: string;
|
|
46
|
+
manifests: null;
|
|
47
|
+
pending: null;
|
|
48
|
+
} | {
|
|
49
|
+
status: string;
|
|
50
|
+
manifests: number;
|
|
51
|
+
pending: null;
|
|
52
|
+
};
|
|
53
|
+
}>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { access, readFile, readdir } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { runGit } from './git.js';
|
|
4
|
+
import { loadCanonicalResolutions } from '../storage/resolution-indexer.js';
|
|
5
|
+
import { checkResolutionIndex } from '../storage/resolution-index-check.js';
|
|
6
|
+
import { listPending } from '../storage/pending-store.js';
|
|
7
|
+
/** Local diagnostic only: it never fetches, pushes, commits or initializes a home. */
|
|
8
|
+
export async function getSyncStatus(home) {
|
|
9
|
+
const exists = await access(home).then(() => true, () => false);
|
|
10
|
+
const canonical = await loadCanonicalResolutions(home).then((rows) => ({ status: 'ok', counts: {
|
|
11
|
+
problems: rows.filter(({ document }) => document.kind === 'problem').length,
|
|
12
|
+
solutions: new Set(rows.filter(({ document }) => document.kind === 'solution').map(({ document }) => document.id)).size,
|
|
13
|
+
revisions: rows.filter(({ document }) => document.kind === 'solution').length,
|
|
14
|
+
outcomes: rows.filter(({ document }) => document.kind === 'outcome').length,
|
|
15
|
+
} }), () => ({ status: 'invalid', counts: null }));
|
|
16
|
+
const pending = await listPending(home).then((items) => ({ count: items.filter(({ status }) => !['completed', 'discarded'].includes(status)).length, status: 'ok' }), () => ({ count: null, status: 'unavailable' }));
|
|
17
|
+
const index = await checkResolutionIndex(home).then(({ status }) => ({ status }), () => ({ status: 'unavailable' }));
|
|
18
|
+
const git = await localGitStatus(home);
|
|
19
|
+
return { home_status: exists ? 'present' : 'missing', canonical, canonical_dirty: git.canonical_dirty, untracked_canonical: git.untracked_canonical, git, index, pending_count: pending.count, pending_status: pending.status, imports: await importsBacklog(home) };
|
|
20
|
+
}
|
|
21
|
+
async function localGitStatus(home) {
|
|
22
|
+
const base = { remote_check: 'not_fetched', remote_checked_at: null, remote_state: 'unknown', local_head: null, upstream: null, upstream_head: null, local_ahead: null, local_behind: null, divergence: 'unknown', conflicts: [], canonical_dirty: [], untracked_canonical: [] };
|
|
23
|
+
const repo = await runGit(home, ['rev-parse', '--is-inside-work-tree']);
|
|
24
|
+
if (repo.exitCode !== 0)
|
|
25
|
+
return { ...base, status: 'not_a_repository' };
|
|
26
|
+
const [head, upstream, tracking, changes] = await Promise.all([
|
|
27
|
+
runGit(home, ['rev-parse', '--verify', 'HEAD']), runGit(home, ['rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{upstream}']),
|
|
28
|
+
runGit(home, ['rev-parse', '--verify', '@{upstream}']), runGit(home, ['--no-optional-locks', 'status', '--porcelain=v1', '-z', '--untracked-files=all']),
|
|
29
|
+
]);
|
|
30
|
+
base.local_head = head.exitCode === 0 ? head.stdout.trim() : null;
|
|
31
|
+
base.upstream = upstream.exitCode === 0 ? upstream.stdout.trim() : null;
|
|
32
|
+
base.upstream_head = tracking.exitCode === 0 ? tracking.stdout.trim() : null;
|
|
33
|
+
if (base.local_head && base.upstream_head) {
|
|
34
|
+
const counts = await runGit(home, ['rev-list', '--left-right', '--count', 'HEAD...@{upstream}']);
|
|
35
|
+
if (counts.exitCode === 0) {
|
|
36
|
+
[base.local_ahead, base.local_behind] = counts.stdout.trim().split(/\s+/).map(Number);
|
|
37
|
+
base.divergence = base.local_ahead && base.local_behind ? 'diverged' : base.local_ahead ? 'ahead' : base.local_behind ? 'behind' : 'tracking_equal';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const entries = changes.stdout.split('\0');
|
|
41
|
+
for (let i = 0; i < entries.length; i++) {
|
|
42
|
+
const entry = entries[i];
|
|
43
|
+
if (!entry)
|
|
44
|
+
continue;
|
|
45
|
+
const code = entry.slice(0, 2);
|
|
46
|
+
const path = entry.slice(3);
|
|
47
|
+
if (/U|AA|DD/.test(code))
|
|
48
|
+
base.conflicts.push(path);
|
|
49
|
+
if (portable(path)) {
|
|
50
|
+
base.canonical_dirty.push(path);
|
|
51
|
+
if (code === '??')
|
|
52
|
+
base.untracked_canonical.push(path);
|
|
53
|
+
}
|
|
54
|
+
if (/[RC]/.test(code)) {
|
|
55
|
+
const original = entries[++i];
|
|
56
|
+
if (original && portable(original))
|
|
57
|
+
base.canonical_dirty.push(original);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return { ...base, status: changes.exitCode === 0 ? 'ok' : 'unavailable' };
|
|
61
|
+
}
|
|
62
|
+
async function importsBacklog(home) {
|
|
63
|
+
let names;
|
|
64
|
+
try {
|
|
65
|
+
names = await readdir(join(home, 'imports'));
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
return error.code === 'ENOENT' ? { status: 'ok', manifests: 0, pending: 0 } : { status: 'unavailable', manifests: null, pending: null };
|
|
69
|
+
}
|
|
70
|
+
let manifests = 0;
|
|
71
|
+
let pending = 0;
|
|
72
|
+
for (const name of names.filter((name) => name.endsWith('.manifest.json'))) {
|
|
73
|
+
try {
|
|
74
|
+
const value = JSON.parse(await readFile(join(home, 'imports', name), 'utf8'));
|
|
75
|
+
manifests++;
|
|
76
|
+
pending += (value.entries ?? []).filter(({ status, import_receipt }) => !import_receipt && !['committed', 'imported', 'discarded'].includes(status)).length;
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return { status: 'unavailable', manifests, pending: null };
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return { status: 'ok', manifests, pending };
|
|
83
|
+
}
|
|
84
|
+
function portable(path) { return path === '.gitignore' || path === 'config.yaml' || /^(problems|solutions|outcomes)\/.+\.ya?ml$/i.test(path); }
|
|
85
|
+
//# sourceMappingURL=sync-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-status.js","sourceRoot":"","sources":["../../src/core/sync-status.ts"],"names":[],"mappings":"AAAA,OAA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od';
|
|
2
|
+
export declare const UsageContextSchema: z.ZodObject<{
|
|
3
|
+
investigation_id: z.ZodOptional<z.ZodString>;
|
|
4
|
+
invocation_id: z.ZodOptional<z.ZodString>;
|
|
5
|
+
retry_of: z.ZodOptional<z.ZodUUID>;
|
|
6
|
+
project_key: z.ZodOptional<z.ZodString>;
|
|
7
|
+
supplied_agent: z.ZodOptional<z.ZodString>;
|
|
8
|
+
supplied_model: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, z.core.$strict>;
|
|
10
|
+
export type UsageContext = z.infer<typeof UsageContextSchema>;
|
|
11
|
+
export declare function safeUsageLabel(value: unknown): string | null;
|
|
12
|
+
export declare function readUsageContext(input: unknown): UsageContext;
|
|
13
|
+
export declare function stripUsageContext<T extends {
|
|
14
|
+
usage_context?: unknown;
|
|
15
|
+
}>(input: T): Omit<T, 'usage_context'>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { redactSensitiveText } from './redaction.js';
|
|
3
|
+
const identifier = z.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/).refine((value) => redactSensitiveText(value) === value, 'Expected a safe trace identifier');
|
|
4
|
+
const supplied = z.string().min(1).max(128).refine((value) => safeUsageLabel(value) !== null, 'Expected safe supplied metadata');
|
|
5
|
+
export const UsageContextSchema = z.object({
|
|
6
|
+
investigation_id: identifier.optional(), invocation_id: identifier.optional(), retry_of: z.uuid().optional(),
|
|
7
|
+
project_key: z.string().regex(/^[a-z0-9][a-z0-9._-]{0,127}$/).refine((value) => redactSensitiveText(value) === value).optional(),
|
|
8
|
+
supplied_agent: supplied.optional(), supplied_model: supplied.optional(),
|
|
9
|
+
}).strict().describe('Optional observation metadata, excluded from canonical payloads and hashes. retry_of references the server invocation UUID returned in response _meta. Supplied agent/model labels are caller claims.');
|
|
10
|
+
export function safeUsageLabel(value) {
|
|
11
|
+
return typeof value === 'string' && /^[a-zA-Z0-9][a-zA-Z0-9 ._+/-]{0,127}$/.test(value) && redactSensitiveText(value) === value ? value : null;
|
|
12
|
+
}
|
|
13
|
+
export function readUsageContext(input) {
|
|
14
|
+
const context = input && typeof input === 'object' ? input.usage_context : undefined;
|
|
15
|
+
const parsed = UsageContextSchema.safeParse(context ?? {});
|
|
16
|
+
return parsed.success ? parsed.data : {};
|
|
17
|
+
}
|
|
18
|
+
export function stripUsageContext(input) {
|
|
19
|
+
const { usage_context: _context, ...payload } = input;
|
|
20
|
+
return payload;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=usage-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage-context.js","sourceRoot":"","sources":["../../src/core/usage-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,mBAAmB,CAAC,KAAK,CAAC,KAAK,KAAK,EAAE,kCAAkC,CAAC,CAAC;AACvK,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,iCAAiC,CAAC,CAAC;AACjI,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,gBAAgB,EAAE,UAAU,CAAC,QAAQ,EAAE,EAAE,aAAa,EAAE,UAAU,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IAC5G,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,C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