@codetelemetry/mcp 0.3.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.
Files changed (38) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +242 -0
  3. package/dist/src/client/agent.d.ts +379 -0
  4. package/dist/src/client/agent.js +204 -0
  5. package/dist/src/client/codexConfig.d.ts +23 -0
  6. package/dist/src/client/codexConfig.js +265 -0
  7. package/dist/src/client/config.d.ts +26 -0
  8. package/dist/src/client/config.js +32 -0
  9. package/dist/src/client/connectivity.d.ts +27 -0
  10. package/dist/src/client/connectivity.js +54 -0
  11. package/dist/src/client/deviceClient.d.ts +32 -0
  12. package/dist/src/client/deviceClient.js +112 -0
  13. package/dist/src/client/keys.d.ts +5 -0
  14. package/dist/src/client/keys.js +24 -0
  15. package/dist/src/client/onboard.d.ts +47 -0
  16. package/dist/src/client/onboard.js +84 -0
  17. package/dist/src/client/otlp.d.ts +18 -0
  18. package/dist/src/client/otlp.js +60 -0
  19. package/dist/src/client/repositoryHook.d.ts +17 -0
  20. package/dist/src/client/repositoryHook.js +631 -0
  21. package/dist/src/client/settings.d.ts +28 -0
  22. package/dist/src/client/settings.js +97 -0
  23. package/dist/src/index.d.ts +2 -0
  24. package/dist/src/index.js +2 -0
  25. package/dist/src/manifest.d.ts +29 -0
  26. package/dist/src/manifest.js +93 -0
  27. package/dist/src/mcpServer.d.ts +3 -0
  28. package/dist/src/mcpServer.js +18 -0
  29. package/dist/src/server.d.ts +2 -0
  30. package/dist/src/server.js +16 -0
  31. package/dist/src/session.d.ts +21 -0
  32. package/dist/src/session.js +44 -0
  33. package/dist/src/tools.d.ts +28 -0
  34. package/dist/src/tools.js +697 -0
  35. package/dist/src/version.d.ts +2 -0
  36. package/dist/src/version.js +2 -0
  37. package/package.json +55 -0
  38. package/tool-manifest.json +474 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Elliot Gardiner
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,242 @@
1
+ # @codetelemetry/mcp
2
+
3
+ The CodeTelemetry MCP server. It lets a coding agent onboard a user to
4
+ [CodeTelemetry](https://codetelemetry.com) in **one instruction** — authenticate,
5
+ obtain an ingest key, write the Claude Code OTEL config, send a test event, and
6
+ confirm telemetry landed — **without the plaintext key ever entering the model's
7
+ context.**
8
+
9
+ This repository contains the complete source that executes in the published npm
10
+ artifact. The CodeTelemetry web application, storage, and infrastructure are not
11
+ part of this package. See [PUBLICATION.md](PUBLICATION.md) for the enforced
12
+ publication boundary.
13
+
14
+ ## Install (Claude Code)
15
+
16
+ ```bash
17
+ claude mcp add codetelemetry -- npx -y @codetelemetry/mcp
18
+ ```
19
+
20
+ or in `.mcp.json` — pinning the version you expect, so what a client launches is
21
+ deterministic (see [Releases & discovery](#releases--discovery)):
22
+
23
+ ```json
24
+ {
25
+ "mcpServers": {
26
+ "codetelemetry": { "command": "npx", "args": ["-y", "@codetelemetry/mcp@0.3.0"] }
27
+ }
28
+ }
29
+ ```
30
+
31
+ Then just ask the agent: **"Connect me to CodeTelemetry."**
32
+
33
+ ## Tools
34
+
35
+ | Tool | What it does |
36
+ | --- | --- |
37
+ | `authenticate` | Start device-code auth; returns a URL + short code for the human to approve. |
38
+ | `auth_status` | Poll the approval; on success captures the key into the session (masked-only to the model). |
39
+ | `get_ingest_key` | Record a pasted key (fast path) or report the authenticated one — masked + hash only. |
40
+ | `write_local_config` | Merge the OTEL config + key into a recognized Claude Code or Codex config path (preserves + backs up). |
41
+ | `send_test_event` | Fire one OTLP probe log with a unique id. |
42
+ | `verify_telemetry` | Poll the connectivity check until the probe lands. |
43
+ | `onboard` | One-shot: key → config → test → verify, returns a checklist. |
44
+ | `status` | Read-only diagnostics (no secrets). |
45
+ | `get_cost_signal` | Read recent observed model cost and CodeTelemetry fee for the caller's own telemetry. |
46
+ | `search_sessions` | Search the same bounded session index as the UI by prompt/title text, assistant, repo, model, duration, and sort order; returns metadata and match fields, never prompt text. |
47
+ | `get_session_performance` | Measure a session timeline's fresh/cache latency, rows, bytes, and query phases without returning content. |
48
+ | `find_similar_session_errors` | Find other personal-scope sessions with matching normalized failure signatures and report query performance. |
49
+ | `estimate_task_size` | T-shirt size a proposed task (free-form text or a Linear-shaped issue) from the caller's own history. |
50
+ | `estimate_linear_issue` | T-shirt size an **existing Linear issue** by URL or identifier, resolved through the workspace the user already connected. |
51
+
52
+ Typical agent flow: `authenticate` → (human approves) → `auth_status` →
53
+ `onboard`. Or, if the user pastes a key: `onboard { key }`.
54
+
55
+ ## Data and local changes
56
+
57
+ The default setup writes only the OpenTelemetry exporter endpoint and ingest
58
+ credential to the selected client's recognized config file. The MCP tool cannot
59
+ choose an arbitrary URL or filesystem path: authentication uses
60
+ `https://codetelemetry.com` and telemetry uses CodeTelemetry's production ingest
61
+ endpoint, while configuration is limited to Claude Code's user/current-project
62
+ `settings.json` or Codex's active `config.toml`. Existing config is preserved,
63
+ backed up before a change, and the resulting file is made owner-readable only
64
+ where the platform supports it.
65
+
66
+ Two higher-sensitivity features are off by default and require separate boolean
67
+ opt-ins:
68
+
69
+ - `enrich: true` enables content telemetry. For Claude Code this uploads prompt
70
+ text, tool details and content, and raw API request/response bodies. For Codex
71
+ it uploads prompt text. Those fields can contain source code, shell commands,
72
+ file contents, secrets, or other sensitive data.
73
+ - `repositoryObservation: true` installs local lifecycle/tool hooks. When a
74
+ session starts or resumes, or its repository/workspace changes, the hook sends
75
+ the absolute repository root and working-directory paths, repository name, a
76
+ hashed repository id, session id, and hook event to CodeTelemetry. The hook
77
+ keeps a bounded local hash-only cache to avoid duplicate observations.
78
+
79
+ These options are independent: opting into repository observation does not turn
80
+ on prompt/body telemetry, and `enrich` does not install repository hooks. A later
81
+ run with `repositoryObservation` omitted or false removes only CodeTelemetry's
82
+ managed hook entries and helper/state files; unrelated user hooks are preserved.
83
+
84
+ ## Estimating a Linear issue
85
+
86
+ `estimate_linear_issue` sizes an issue that **already exists** in Linear, so you
87
+ never paste its contents into a prompt. You pass a reference; CodeTelemetry
88
+ resolves it through the Linear workspace the user connected in Settings. **No
89
+ Linear token is ever sent** — the request carries only the reference and optional
90
+ hints, and it is read-only: the issue's estimate, description, labels, state and
91
+ comments are left untouched.
92
+
93
+ **Claude Code** — ask it to size the ticket you're about to pick up. An issue URL
94
+ names its own workspace, so nothing else is needed:
95
+
96
+ ```jsonc
97
+ // tool: estimate_linear_issue
98
+ {
99
+ "reference": "https://linear.app/acme/issue/ELL-44/add-an-mcp-tool-to-estimate-linear-issues",
100
+ "repo": "elo"
101
+ }
102
+ ```
103
+
104
+ **Codex** — the same tool from a Codex session, using the bare identifier. A
105
+ Linear identifier is only unique *within* a workspace, so if more than one
106
+ workspace is connected, name the one to use:
107
+
108
+ ```jsonc
109
+ // tool: estimate_linear_issue
110
+ {
111
+ "reference": "ELL-44",
112
+ "workspace": "acme",
113
+ "repo": "elo"
114
+ }
115
+ ```
116
+
117
+ Omit `workspace` when only one workspace is connected. With several, the call
118
+ fails with `ambiguous_connection` and returns the candidates, so you can retry
119
+ naming one — the tool never guesses which workspace's `ELL-44` you meant.
120
+ Pass **either** `workspace` **or** `connectionId`, not both: hints don't outrank
121
+ each other, so any two that name different workspaces (including the workspace in
122
+ an issue URL) fail with `conflicting_selection` rather than one silently winning.
123
+
124
+ ```jsonc
125
+ {
126
+ "ok": false,
127
+ "error": "ambiguous_connection",
128
+ "message": "... name one with connectionId or workspace: \"acme\", \"globex\"",
129
+ "connections": [
130
+ { "connectionId": "conn-…", "workspace": { "urlKey": "acme", "name": "Acme Inc" }, "isDefault": true, "status": "connected" },
131
+ { "connectionId": "conn-…", "workspace": { "urlKey": "globex", "name": "Globex" }, "isDefault": false, "status": "connected" }
132
+ ]
133
+ }
134
+ ```
135
+
136
+ A success carries the shared sizing schema (`estimate`: size, sizing-model
137
+ version, predicted token range, confidence with reasons, comparable-work
138
+ evidence, optional calibration task, and the size projected onto the issue's own
139
+ team scale), plus `source` — the reference as submitted, the issue's identifier,
140
+ URL, title, labels, project, team, the workspace it came from, and the
141
+ `normalizedText` actually matched. `source` deliberately omits the issue's
142
+ **description**: every tool result is serialized twice (text *and*
143
+ `structuredContent`), so repeating it would double an already-doubled body.
144
+
145
+ Read the body from `estimate.issueSource.description` — **capped at 4,000
146
+ characters**, with `descriptionChars` (its true length) and
147
+ `descriptionTruncated` alongside it. Linear puts no ceiling on a description and
148
+ a tool result lands in your context twice, so the server bounds it rather than
149
+ letting one long issue exhaust your tool-result budget. When
150
+ `descriptionTruncated` is true you have a prefix, not the issue — open the `url`
151
+ if you need the rest.
152
+
153
+ Other failures each keep their own code, so the next action is unambiguous:
154
+ `no_connected_workspace`,
155
+ `connection_not_found`, `workspace_not_connected`, `conflicting_selection`,
156
+ `connection_needs_reconnect`, `issue_inaccessible` (the *connection* can't read —
157
+ reconnect it rather than trying other identifiers), `issue_not_found` (Linear
158
+ reports "no such issue" and "invisible to this credential" identically, so this
159
+ one means either — check the identifier *or* connect a workspace that can see it),
160
+ `empty_issue`, `invalid_reference`, `invalid_workspace`, `read_limit_exceeded`,
161
+ `unauthenticated`, `rate_limited`, `read_timeout`, `linear_unavailable`
162
+ (transient — retry), `linear_not_configured` (a deployment fault; retrying will
163
+ not help), and `sizing_failed` for anything unmapped.
164
+
165
+ ## Security
166
+
167
+ The plaintext `cot_…` key lives only inside the server process's session
168
+ (`#private` field). Every tool result carries a **masked** preview (`cot_…b3F9`)
169
+ and the key hash — never the plaintext. `callTool` additionally scrubs the
170
+ serialized result as a backstop. This invariant is asserted in
171
+ [`test/tools.test.ts`](test/tools.test.ts) across a full onboarding transcript.
172
+
173
+ The public MCP schemas deliberately expose neither endpoint overrides nor
174
+ arbitrary config paths. Test harnesses and trusted embedders can inject those
175
+ values through the programmatic `ToolContext`; they are not model-controlled.
176
+
177
+ ## Releases & discovery
178
+
179
+ A tool only exists for a customer once it reaches the **published** package. Three
180
+ inventories have to agree, and `npm run verify:registry` fails when they don't:
181
+
182
+ | Inventory | What it is |
183
+ | --- | --- |
184
+ | source | `TOOLS` in `src/tools.ts`, pinned by the committed `tool-manifest.json` |
185
+ | packaged | what `npm pack` produces and actually serves when launched |
186
+ | published | the version on npm that `npx -y @codetelemetry/mcp` downloads |
187
+
188
+ ```bash
189
+ npm run manifest:write # after intentionally changing a tool; commit the diff
190
+ npm run verify:registry # source ↔ committed manifest ↔ the two tool tables
191
+ npm run verify:registry -- --packaged # + pack, launch, diff tools/list
192
+ npm run verify:registry -- --published # + compare against npm (inventory, artifact, `latest` tag)
193
+ npm run smoke -- --npx --endpoint https://codetelemetry.com # the customer path
194
+ npm run smoke -- --install # deps via a real `npm install`
195
+ npm run smoke -- --tarball out.tgz --require-auth # exactly these bytes (the release gate)
196
+ ```
197
+
198
+ `registryHash` identifies an **inventory** (sha256 over the wire-visible fields);
199
+ `version` identifies a **build**. Both are readable from any client — call `status`
200
+ and read `server`:
201
+
202
+ ```jsonc
203
+ "server": { "name": "codetelemetry", "version": "0.3.0", "registryHash": "f2b6568d…", "toolCount": 15 }
204
+ ```
205
+
206
+ **When a long-running client sees a new tool.** `tools/list` is requested once, at
207
+ connect time, and the server declares `capabilities.tools` *without* `listChanged`
208
+ — accurately: its registry is fixed for the life of the process, so nothing will
209
+ push an update to a connected client. A new tool therefore arrives only when a new
210
+ server process starts with the new package:
211
+
212
+ - **new client session** — nothing to do; it discovers the current inventory.
213
+ - **already-connected session** — restart the client (Claude Code: quit and
214
+ relaunch, or reconnect the server from `/mcp` if your version offers it; Codex:
215
+ restart the session).
216
+ - **restarted and still missing** — the launcher is reusing an older download. Pin
217
+ the version in `.mcp.json` (or append `@latest`) and confirm with `status`:
218
+ `server.version` / `server.registryHash` name the build that answered.
219
+
220
+ Publishing is the deploy: there is no server-side runtime that serves this
221
+ registry. The release runs that smoke against production **before** it publishes,
222
+ with `--require-auth` — which fails unless every sizing route actually answered, so
223
+ an immutable version cannot ship ahead of the backend its tools call. For
224
+ `estimate_linear_issue`, a workspace-shaped refusal (no workspace connected, issue
225
+ not found) counts as an answer; a deployment fault, an unavailable upstream, or a
226
+ 404 does not.
227
+ `CODETELEMETRY_INGEST_KEY` comes from the environment — never a flag. Publication
228
+ is manual; see [PUBLICATION.md](PUBLICATION.md) for the review and release gates.
229
+
230
+ ## Develop
231
+
232
+ Requires **Node ≥ 22.6** to run the sources; the published artifact is compiled JS
233
+ (`npm run build` → `dist/`), because Node will not strip types inside
234
+ `node_modules`.
235
+
236
+ ```bash
237
+ npm test # dep-free: tool registry, the no-leak invariant, manifest pins
238
+ npm install # pulls @modelcontextprotocol/sdk
239
+ npm run test:protocol # drives the tools through a real MCP client/server pair
240
+ npm run test:packaged # packs, launches the artifact, runs the release smoke
241
+ npm run typecheck
242
+ ```
@@ -0,0 +1,379 @@
1
+ import type { FetchLike } from "./otlp.ts";
2
+ export type CostSignal = {
3
+ windowDays: number;
4
+ observedCostUsd: number;
5
+ feeUsd: number;
6
+ byModel: {
7
+ model: string;
8
+ observedCostUsd: number;
9
+ }[];
10
+ topRepo: string | null;
11
+ asOf: string | null;
12
+ note: string;
13
+ };
14
+ export type CostSignalResult = {
15
+ ok: boolean;
16
+ cost: CostSignal | null;
17
+ httpStatus: number;
18
+ };
19
+ export type AgentReadPerformance = {
20
+ totalMs: number;
21
+ queryMs: number;
22
+ queryCount: number;
23
+ readRows: number;
24
+ readBytes: number;
25
+ resultBytes: number;
26
+ targetMs: number;
27
+ meetsTarget: boolean;
28
+ phases: {
29
+ phase: string;
30
+ queryId: string;
31
+ durationMs: number;
32
+ readRows?: number;
33
+ readBytes?: number;
34
+ resultBytes: number;
35
+ }[];
36
+ cache?: string;
37
+ coldTargetMs?: number;
38
+ meetsColdTarget?: boolean;
39
+ };
40
+ export type SessionPerformanceReport = {
41
+ sessionId: string;
42
+ present: boolean;
43
+ sessionCount: number;
44
+ eventCount: number;
45
+ returnedEvents: number;
46
+ turnCount: number;
47
+ targetsMs: {
48
+ fresh: number;
49
+ cacheHit: number;
50
+ };
51
+ samples: {
52
+ mode: "fresh" | "dashboard-cache";
53
+ cache: "hit" | "miss" | "disabled" | "bypass";
54
+ performance: AgentReadPerformance;
55
+ }[];
56
+ };
57
+ export type SimilarSessionErrorsReport = {
58
+ sessionId: string;
59
+ lookbackDays: number;
60
+ targetFailures: number;
61
+ targetSignatures: {
62
+ signature: string;
63
+ tool: string;
64
+ category: string;
65
+ occurrences: number;
66
+ lastSeen: string;
67
+ }[];
68
+ targetSignaturesTruncated: boolean;
69
+ matches: {
70
+ sessionId: string;
71
+ lastSeen: string;
72
+ matchingFailures: number;
73
+ exactSignatureMatches: number;
74
+ familySignatureMatches: number;
75
+ similarityPct: number;
76
+ tools: string[];
77
+ categories: string[];
78
+ }[];
79
+ };
80
+ export type SessionPerformanceResult = {
81
+ ok: boolean;
82
+ report: SessionPerformanceReport | null;
83
+ httpStatus: number;
84
+ error: string | null;
85
+ message: string | null;
86
+ };
87
+ export type SessionSearchHit = {
88
+ sessionId: string;
89
+ title: string;
90
+ titleIsId: boolean;
91
+ sessionName?: string;
92
+ repo: string;
93
+ repoInferred?: boolean;
94
+ user?: string;
95
+ sourceService: string;
96
+ models: string[];
97
+ lastSeen: string | null;
98
+ durationMs: number;
99
+ totalTokens: number;
100
+ costUsd: number;
101
+ prompts: number;
102
+ invocations: number;
103
+ tools: number;
104
+ match?: {
105
+ fields: string[];
106
+ };
107
+ };
108
+ export type SessionSearchReport = {
109
+ results: SessionSearchHit[];
110
+ total: number;
111
+ limit: number;
112
+ offset: number;
113
+ hasMore: boolean;
114
+ nextOffset: number | null;
115
+ query: Record<string, unknown>;
116
+ repos: string[];
117
+ promptSearchAvailable: boolean;
118
+ promptSearchTruncated?: boolean;
119
+ promptSearchThrough?: string | null;
120
+ contentRedacted: true;
121
+ truncated?: boolean;
122
+ };
123
+ export type SessionSearchResult = {
124
+ ok: boolean;
125
+ report: SessionSearchReport | null;
126
+ httpStatus: number;
127
+ error: string | null;
128
+ message: string | null;
129
+ };
130
+ export type TaskSize = "XS" | "S" | "M" | "L" | "XL";
131
+ export type LinearEstimateScale = "exponential" | "fibonacci" | "linear" | "tShirt";
132
+ export type LinearEstimateProjection = {
133
+ scale: LinearEstimateScale;
134
+ extended: boolean;
135
+ value: number;
136
+ label: string;
137
+ size: TaskSize;
138
+ };
139
+ export type TaskEffortEstimate = {
140
+ task: {
141
+ text: string;
142
+ source: "text" | "issue";
143
+ issueKey: string | null;
144
+ terms: string[];
145
+ };
146
+ sizingRequestId: string;
147
+ size: TaskSize | null;
148
+ range: {
149
+ minTokens: number;
150
+ maxTokens: number | null;
151
+ } | null;
152
+ sizeRange?: {
153
+ min: TaskSize;
154
+ max: TaskSize;
155
+ };
156
+ tokens: {
157
+ point: number;
158
+ low: number;
159
+ high: number;
160
+ };
161
+ basis: "matched" | "corpus-median" | "none";
162
+ sampleCount: number;
163
+ confidence: {
164
+ band: "high" | "medium" | "low";
165
+ ladder: "high" | "medium" | "low";
166
+ similarity: number;
167
+ evidence: number;
168
+ corpus: number;
169
+ agreement: number;
170
+ scoring: {
171
+ inputs: {
172
+ key: string;
173
+ label: string;
174
+ value: number;
175
+ weight: number;
176
+ detail: string;
177
+ }[];
178
+ weightedScore: number;
179
+ cap: number;
180
+ capBand: "high" | "medium" | "low";
181
+ capped: boolean;
182
+ capReason: "samples" | "disagreement" | null;
183
+ score: number;
184
+ };
185
+ reasons: string[];
186
+ };
187
+ matches: {
188
+ sessionId: string;
189
+ kind: "session" | "segment";
190
+ sourceSessionId?: string;
191
+ title: string;
192
+ useCase: string;
193
+ similarityPct: number;
194
+ totalTokens: number;
195
+ lastSeen: string;
196
+ }[];
197
+ model: {
198
+ rulesVersion: string;
199
+ cohortKey: string;
200
+ cohortSampleSize: number;
201
+ observationCount: number;
202
+ } | null;
203
+ evidence: {
204
+ lookbackDays: number;
205
+ sessions: number;
206
+ describedSessions: number;
207
+ truncated?: boolean;
208
+ descriptionsUnavailable?: boolean;
209
+ segmentedSessions?: number;
210
+ };
211
+ linearEstimate: LinearEstimateProjection | null;
212
+ issueSource: {
213
+ connectionId: string;
214
+ workspace: {
215
+ id: string;
216
+ name: string;
217
+ urlKey: string;
218
+ };
219
+ identifier: string;
220
+ url: string;
221
+ title: string;
222
+ description: string;
223
+ descriptionChars: number;
224
+ descriptionTruncated: boolean;
225
+ labels: string[];
226
+ project: {
227
+ id: string;
228
+ name: string;
229
+ } | null;
230
+ team: {
231
+ id: string;
232
+ key: string;
233
+ name: string;
234
+ } | null;
235
+ estimate: number | null;
236
+ } | null;
237
+ calibrationTask: {
238
+ kind: "spike" | "slice" | "instrument";
239
+ size: "XS" | "S";
240
+ title: string;
241
+ question: string;
242
+ targetSignal: "similarity" | "evidence" | "corpus" | "agreement" | "ladder";
243
+ why: string;
244
+ steps: string[];
245
+ expectedEvidence: string;
246
+ exitCriteria: string[];
247
+ expectedImprovement: string;
248
+ expectedTokens: number;
249
+ sizingRequestId: string;
250
+ markdown: string;
251
+ signature: string;
252
+ } | null;
253
+ confidenceTask: TaskEffortEstimate["calibrationTask"];
254
+ };
255
+ export type TaskEffortResult = {
256
+ ok: boolean;
257
+ estimate: TaskEffortEstimate | null;
258
+ performance: AgentReadPerformance | null;
259
+ httpStatus: number;
260
+ error: string | null;
261
+ message: string | null;
262
+ };
263
+ export type LinearIssueSource = {
264
+ reference: string;
265
+ connectionId: string;
266
+ workspace: {
267
+ id: string;
268
+ name: string;
269
+ urlKey: string;
270
+ };
271
+ identifier: string;
272
+ url: string;
273
+ title: string;
274
+ labels: string[];
275
+ project: {
276
+ id: string;
277
+ name: string;
278
+ } | null;
279
+ team: {
280
+ id: string;
281
+ key: string;
282
+ name: string;
283
+ } | null;
284
+ estimate: number | null;
285
+ normalizedText: string;
286
+ };
287
+ export type LinearConnectionChoice = {
288
+ connectionId: string;
289
+ workspace: {
290
+ id: string;
291
+ name: string;
292
+ urlKey: string;
293
+ };
294
+ isDefault: boolean;
295
+ status: string;
296
+ };
297
+ export type LinearIssueEstimateResult = {
298
+ ok: boolean;
299
+ estimate: TaskEffortEstimate | null;
300
+ source: LinearIssueSource | null;
301
+ connections: LinearConnectionChoice[] | null;
302
+ performance: AgentReadPerformance | null;
303
+ httpStatus: number;
304
+ error: string | null;
305
+ message: string | null;
306
+ };
307
+ export type SimilarSessionErrorsResult = {
308
+ ok: boolean;
309
+ report: SimilarSessionErrorsReport | null;
310
+ performance: AgentReadPerformance | null;
311
+ httpStatus: number;
312
+ error: string | null;
313
+ message: string | null;
314
+ };
315
+ export declare function getCostSignal(opts: {
316
+ key: string;
317
+ url: string;
318
+ fetchImpl?: FetchLike;
319
+ timeoutMs?: number;
320
+ }): Promise<CostSignalResult>;
321
+ export declare function getSessionPerformance(opts: {
322
+ key: string;
323
+ url: string;
324
+ sessionId: string;
325
+ includeFresh?: boolean;
326
+ cacheSamples?: number;
327
+ fetchImpl?: FetchLike;
328
+ timeoutMs?: number;
329
+ }): Promise<SessionPerformanceResult>;
330
+ export declare function findSimilarSessionErrors(opts: {
331
+ key: string;
332
+ url: string;
333
+ sessionId: string;
334
+ lookbackDays?: number;
335
+ limit?: number;
336
+ fetchImpl?: FetchLike;
337
+ timeoutMs?: number;
338
+ }): Promise<SimilarSessionErrorsResult>;
339
+ export declare const SESSION_SEARCH_REQUEST_TIMEOUT_MS = 65000;
340
+ export declare function searchCodingSessions(opts: {
341
+ key: string;
342
+ url: string;
343
+ query: Record<string, unknown>;
344
+ fetchImpl?: FetchLike;
345
+ timeoutMs?: number;
346
+ }): Promise<SessionSearchResult>;
347
+ export declare function estimateTaskSize(opts: {
348
+ key: string;
349
+ url: string;
350
+ taskText?: string;
351
+ issue?: {
352
+ identifier?: string;
353
+ title?: string;
354
+ description?: string;
355
+ labels?: string[];
356
+ };
357
+ issueKey?: string;
358
+ repo?: string;
359
+ linearScale?: LinearEstimateScale;
360
+ linearScaleExtended?: boolean;
361
+ lookbackDays?: number;
362
+ limit?: number;
363
+ fetchImpl?: FetchLike;
364
+ timeoutMs?: number;
365
+ }): Promise<TaskEffortResult>;
366
+ export declare function estimateLinearIssue(opts: {
367
+ key: string;
368
+ url: string;
369
+ reference: string;
370
+ connectionId?: string;
371
+ workspace?: string;
372
+ repo?: string;
373
+ linearScale?: LinearEstimateScale;
374
+ linearScaleExtended?: boolean;
375
+ lookbackDays?: number;
376
+ limit?: number;
377
+ fetchImpl?: FetchLike;
378
+ timeoutMs?: number;
379
+ }): Promise<LinearIssueEstimateResult>;