@wrongstack/wrongtrace 0.313.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/LICENSE +21 -0
- package/dist/adapters/ipc.d.ts +49 -0
- package/dist/adapters/ipc.js +127 -0
- package/dist/adapters/mcp.d.ts +28 -0
- package/dist/adapters/mcp.js +42 -0
- package/dist/agent-helpers.d.ts +109 -0
- package/dist/agent-helpers.js +226 -0
- package/dist/client.d.ts +45 -0
- package/dist/client.js +304 -0
- package/dist/discovery.d.ts +37 -0
- package/dist/discovery.js +65 -0
- package/dist/gate-counters.d.ts +53 -0
- package/dist/gate-counters.js +161 -0
- package/dist/gate.d.ts +64 -0
- package/dist/gate.js +94 -0
- package/dist/hooks.d.ts +120 -0
- package/dist/hooks.js +228 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +28 -0
- package/dist/types.d.ts +237 -0
- package/dist/types.js +12 -0
- package/package.json +49 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type contracts for the WrongTrace AI Observability adapter.
|
|
3
|
+
*
|
|
4
|
+
* The adapter speaks to an EXTERNAL daemon that may or may not be running
|
|
5
|
+
* on the developer's machine. WrongStack does not own, ship, or bootstrap
|
|
6
|
+
* that daemon — it just probes + talks to it when present, and silently
|
|
7
|
+
* no-ops when it is absent. All types are deliberately narrow: we
|
|
8
|
+
* declare exactly the surfaces the integration protocol promises, and
|
|
9
|
+
* we let unknown fields stay `unknown` so we can forward them through.
|
|
10
|
+
*/
|
|
11
|
+
/** Result of `GET /api/health`. */
|
|
12
|
+
export interface WrongTraceHealth {
|
|
13
|
+
ok: boolean;
|
|
14
|
+
/** SemVer string of the running daemon, when the daemon reports it. */
|
|
15
|
+
version?: string;
|
|
16
|
+
/** Filesystem path of the IPC socket the daemon is listening on. */
|
|
17
|
+
socket_path?: string;
|
|
18
|
+
/** Anything else the daemon returned is preserved as-is for forward-compat. */
|
|
19
|
+
[extra: string]: unknown;
|
|
20
|
+
}
|
|
21
|
+
/** `GET /api/file/health?path=...` response. Daemon 2026-08-24+: lock fields included. */
|
|
22
|
+
export interface WrongTraceFileHealth {
|
|
23
|
+
file_path: string;
|
|
24
|
+
/** 0..100. Lower = more fragile. */
|
|
25
|
+
health_score: number;
|
|
26
|
+
is_fragile: boolean;
|
|
27
|
+
/** Number of write/delete cycles observed in the last 24h. */
|
|
28
|
+
recent_thrashing_count: number;
|
|
29
|
+
is_locked: boolean;
|
|
30
|
+
lock_owner?: string;
|
|
31
|
+
lock_reason?: string;
|
|
32
|
+
lock_owner_run_id?: string;
|
|
33
|
+
lock_expires_at?: string;
|
|
34
|
+
warning?: string;
|
|
35
|
+
[extra: string]: unknown;
|
|
36
|
+
}
|
|
37
|
+
/** `GET /api/symbol/history` row — one revision event per row (daemon returns an array). */
|
|
38
|
+
export interface WrongTraceSymbolEvent {
|
|
39
|
+
event_id: string;
|
|
40
|
+
run_id?: string;
|
|
41
|
+
repo_name?: string;
|
|
42
|
+
file_path: string;
|
|
43
|
+
/** Daemon format: `function:file.go::Name` / `struct:file.go::Name` / `method:...`. */
|
|
44
|
+
node_signature: string;
|
|
45
|
+
node_type?: string;
|
|
46
|
+
action?: string;
|
|
47
|
+
ast_content_hash?: string;
|
|
48
|
+
added_lines?: number;
|
|
49
|
+
deleted_lines?: number;
|
|
50
|
+
diff_snippet?: string;
|
|
51
|
+
author_model?: string;
|
|
52
|
+
event_time?: string;
|
|
53
|
+
timestamp?: string;
|
|
54
|
+
[extra: string]: unknown;
|
|
55
|
+
}
|
|
56
|
+
/** `GET /api/metrics/friction` — model-vs-model overwriter heatmap. */
|
|
57
|
+
export interface WrongTraceFrictionRow {
|
|
58
|
+
author_model: string;
|
|
59
|
+
overwriter_model: string;
|
|
60
|
+
file_count: number;
|
|
61
|
+
deleted_lines: number;
|
|
62
|
+
[extra: string]: unknown;
|
|
63
|
+
}
|
|
64
|
+
/** One file entry inside a full (non-summary) atlas. */
|
|
65
|
+
export interface WrongTraceAtlasFile {
|
|
66
|
+
path: string;
|
|
67
|
+
name?: string;
|
|
68
|
+
language?: string;
|
|
69
|
+
health_score?: number;
|
|
70
|
+
is_fragile?: boolean;
|
|
71
|
+
recent_thrashing_count?: number;
|
|
72
|
+
total_loc?: number;
|
|
73
|
+
symbols?: unknown[];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* `GET /api/atlas` — repo-wide map. Two modes (daemon 2026-08-24+):
|
|
77
|
+
* full: packages[].files[] with per-file health + AST symbols
|
|
78
|
+
* summary: packages[] carry file_count / fragile_files_count / avg_health_score
|
|
79
|
+
* Both modes carry top-level totals since the round-2 daemon update.
|
|
80
|
+
*/
|
|
81
|
+
export interface WrongTraceAtlasSummary {
|
|
82
|
+
repo?: string;
|
|
83
|
+
generated_at?: string;
|
|
84
|
+
is_monorepo?: boolean;
|
|
85
|
+
workspaces?: string[];
|
|
86
|
+
total_packages?: number;
|
|
87
|
+
total_files?: number;
|
|
88
|
+
total_loc?: number;
|
|
89
|
+
total_nodes?: number;
|
|
90
|
+
index_status?: string;
|
|
91
|
+
packages: Array<{
|
|
92
|
+
path: string;
|
|
93
|
+
name: string;
|
|
94
|
+
workspace?: string;
|
|
95
|
+
/** Summary mode only. */
|
|
96
|
+
file_count?: number;
|
|
97
|
+
/** Summary mode only. */
|
|
98
|
+
fragile_files_count?: number;
|
|
99
|
+
/** Summary mode only. */
|
|
100
|
+
avg_health_score?: number;
|
|
101
|
+
total_loc?: number;
|
|
102
|
+
is_fragile?: boolean;
|
|
103
|
+
/** Full mode only. */
|
|
104
|
+
files?: WrongTraceAtlasFile[];
|
|
105
|
+
}>;
|
|
106
|
+
[extra: string]: unknown;
|
|
107
|
+
}
|
|
108
|
+
export interface WrongTraceAtlasQuery {
|
|
109
|
+
/** Restrict the atlas to one workspace (e.g. "internal"). */
|
|
110
|
+
workspace?: string;
|
|
111
|
+
/** Summary mode: no per-file payloads, aggregate counters per package. */
|
|
112
|
+
summary?: boolean;
|
|
113
|
+
/** Strip AST symbol trees from files[] (~90% size cut) while keeping health scores. */
|
|
114
|
+
includeSymbols?: boolean;
|
|
115
|
+
/** Package-level pagination (daemon slices packages[], returns limit/offset meta). */
|
|
116
|
+
limit?: number;
|
|
117
|
+
offset?: number;
|
|
118
|
+
}
|
|
119
|
+
/** `POST /api/telemetry` payload. */
|
|
120
|
+
export interface WrongTraceTelemetryReport {
|
|
121
|
+
run_id: string;
|
|
122
|
+
task_id?: string;
|
|
123
|
+
agent_name: string;
|
|
124
|
+
model_name: string;
|
|
125
|
+
provider: string;
|
|
126
|
+
prompt_tokens: number;
|
|
127
|
+
completion_tokens: number;
|
|
128
|
+
cost_usd: number;
|
|
129
|
+
intent: string;
|
|
130
|
+
/** Free-form pass-through. */
|
|
131
|
+
[extra: string]: unknown;
|
|
132
|
+
}
|
|
133
|
+
/** `POST /api/guardrail/{lock,unlock}` payloads. Daemon 2026-08-24+: ownership + TTL. */
|
|
134
|
+
export interface WrongTraceLockRequest {
|
|
135
|
+
path: string;
|
|
136
|
+
reason: string;
|
|
137
|
+
owner?: string;
|
|
138
|
+
owner_run_id?: string;
|
|
139
|
+
/** Seconds until the lock self-expires (daemon-enforced TTL). */
|
|
140
|
+
ttl_seconds?: number;
|
|
141
|
+
/** Take over an existing lock (override a 409 conflict). */
|
|
142
|
+
force?: boolean;
|
|
143
|
+
}
|
|
144
|
+
export interface WrongTraceUnlockRequest {
|
|
145
|
+
path: string;
|
|
146
|
+
}
|
|
147
|
+
export interface WrongTraceLockResult {
|
|
148
|
+
ok: boolean;
|
|
149
|
+
path: string;
|
|
150
|
+
status?: string;
|
|
151
|
+
/** Set when the lock was rejected because someone else already owns it. */
|
|
152
|
+
owner?: string;
|
|
153
|
+
owner_run_id?: string;
|
|
154
|
+
reason?: string;
|
|
155
|
+
locked_at?: string;
|
|
156
|
+
expires_at?: string;
|
|
157
|
+
[extra: string]: unknown;
|
|
158
|
+
}
|
|
159
|
+
/** Caller-supplied lock ownership, mapped to the daemon's snake_case body. */
|
|
160
|
+
export interface WrongTraceLockOwnership {
|
|
161
|
+
owner?: string;
|
|
162
|
+
ownerRunId?: string;
|
|
163
|
+
ttlSeconds?: number;
|
|
164
|
+
/** Take over an existing lock (daemon 409-conflict override). */
|
|
165
|
+
force?: boolean;
|
|
166
|
+
}
|
|
167
|
+
/** `GET /api/events/recent` row — daemon 2026-08-24+. */
|
|
168
|
+
export interface WrongTraceRecentEvent {
|
|
169
|
+
event_id: string;
|
|
170
|
+
run_id?: string;
|
|
171
|
+
repo_name?: string;
|
|
172
|
+
file_path: string;
|
|
173
|
+
node_signature?: string;
|
|
174
|
+
node_type?: string;
|
|
175
|
+
action?: string;
|
|
176
|
+
added_lines?: number;
|
|
177
|
+
deleted_lines?: number;
|
|
178
|
+
diff_snippet?: string;
|
|
179
|
+
author_model?: string;
|
|
180
|
+
event_time?: string;
|
|
181
|
+
timestamp?: string;
|
|
182
|
+
[extra: string]: unknown;
|
|
183
|
+
}
|
|
184
|
+
export interface WrongTraceRecentEventsQuery {
|
|
185
|
+
limit?: number;
|
|
186
|
+
/** ISO timestamp / SQLite datetime / Unix epoch (s or ms); only events after this. */
|
|
187
|
+
since?: string;
|
|
188
|
+
/** Repo name filter (e.g. "WrongTrace"). Omit for all repos. */
|
|
189
|
+
repo?: string;
|
|
190
|
+
/** Filter events to a single file path. */
|
|
191
|
+
filePath?: string;
|
|
192
|
+
}
|
|
193
|
+
/** `GET /api/guardrail/locks` row — active locks listing, daemon 2026-08-24+. */
|
|
194
|
+
export interface WrongTraceLockInfo {
|
|
195
|
+
path: string;
|
|
196
|
+
status?: string;
|
|
197
|
+
owner?: string;
|
|
198
|
+
owner_run_id?: string;
|
|
199
|
+
reason?: string;
|
|
200
|
+
locked_at?: string;
|
|
201
|
+
expires_at?: string;
|
|
202
|
+
[extra: string]: unknown;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* The resolved, ready-to-use client. When `isAvailable` is false every
|
|
206
|
+
* method degrades to a typed no-op (returns sensible defaults, never throws),
|
|
207
|
+
* so callers can wire it unconditionally and forget the daemon is optional.
|
|
208
|
+
*/
|
|
209
|
+
export interface WrongTraceClient {
|
|
210
|
+
readonly isAvailable: boolean;
|
|
211
|
+
readonly baseUrl?: string | undefined;
|
|
212
|
+
readonly socketPath?: string | undefined;
|
|
213
|
+
/** `GET /api/health`. Returns `null` if the daemon is unreachable. */
|
|
214
|
+
getHealth(): Promise<WrongTraceHealth | null>;
|
|
215
|
+
/** `GET /api/file/health?path=...`. */
|
|
216
|
+
getFileHealth(path: string): Promise<WrongTraceFileHealth | null>;
|
|
217
|
+
/** `GET /api/symbol/history?path=...` — all symbol events for a file; add a
|
|
218
|
+
* daemon-format signature (`function:file.go::Name`) to narrow to one symbol. */
|
|
219
|
+
getSymbolLineage(path: string, signature?: string): Promise<WrongTraceSymbolEvent[]>;
|
|
220
|
+
/** `GET /api/metrics/friction?limit=50`. */
|
|
221
|
+
getFrictionMatrix(limit?: number): Promise<WrongTraceFrictionRow[]>;
|
|
222
|
+
/** `GET /api/atlas` — full or summary mode, optional workspace filter. */
|
|
223
|
+
getAtlas(query?: WrongTraceAtlasQuery): Promise<WrongTraceAtlasSummary | null>;
|
|
224
|
+
/** `POST /api/guardrail/lock`. Ownership/TTL options available since daemon 2026-08-24. */
|
|
225
|
+
lockFile(path: string, reason: string, opts?: WrongTraceLockOwnership): Promise<WrongTraceLockResult | null>;
|
|
226
|
+
/** `POST /api/guardrail/unlock`. */
|
|
227
|
+
unlockFile(path: string): Promise<WrongTraceLockResult | null>;
|
|
228
|
+
/** `POST /api/telemetry`. */
|
|
229
|
+
reportTelemetry(report: WrongTraceTelemetryReport): Promise<{
|
|
230
|
+
ok: boolean;
|
|
231
|
+
} | null>;
|
|
232
|
+
/** `GET /api/events/recent` — chronological event feed (daemon 2026-08-24+). */
|
|
233
|
+
getRecentEvents(query?: WrongTraceRecentEventsQuery): Promise<WrongTraceRecentEvent[]>;
|
|
234
|
+
/** `GET /api/guardrail/locks` — active locks (daemon 2026-08-24+). */
|
|
235
|
+
listLocks(): Promise<WrongTraceLockInfo[]>;
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type contracts for the WrongTrace AI Observability adapter.
|
|
3
|
+
*
|
|
4
|
+
* The adapter speaks to an EXTERNAL daemon that may or may not be running
|
|
5
|
+
* on the developer's machine. WrongStack does not own, ship, or bootstrap
|
|
6
|
+
* that daemon — it just probes + talks to it when present, and silently
|
|
7
|
+
* no-ops when it is absent. All types are deliberately narrow: we
|
|
8
|
+
* declare exactly the surfaces the integration protocol promises, and
|
|
9
|
+
* we let unknown fields stay `unknown` so we can forward them through.
|
|
10
|
+
*/
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=types.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wrongstack/wrongtrace",
|
|
3
|
+
"version": "0.313.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Optional client adapter for the external WrongTrace AI Observability daemon. Discovers the daemon over HTTP/IPC/MCP at runtime; returns isAvailable:false when it is not reachable, so callers degrade gracefully. Not coupled to any runtime inside WrongStack — this is the 'sibling' integration protocol.",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/WrongStack/WrongStack.git",
|
|
9
|
+
"directory": "packages/wrongtrace"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/WrongStack/WrongStack#readme",
|
|
12
|
+
"bugs": "https://github.com/WrongStack/WrongStack/issues",
|
|
13
|
+
"author": "ECOSTACK TECHNOLOGY OÜ",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"!dist/**/*.map",
|
|
27
|
+
"README.md"
|
|
28
|
+
],
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=22.19.0"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"undici-types": "^8.10.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/node": "^22.19.0",
|
|
40
|
+
"typescript": "^7.0.0",
|
|
41
|
+
"vitest": "^4.1.11"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsc -p tsconfig.json",
|
|
45
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
46
|
+
"test": "vitest run --config vitest.config.ts",
|
|
47
|
+
"test:watch": "vitest --config vitest.config.ts"
|
|
48
|
+
}
|
|
49
|
+
}
|