@codetelemetry/mcp 0.3.8 → 0.3.12
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 +1 -1
- package/README.md +90 -9
- package/dist/src/client/agent.d.ts +221 -3
- package/dist/src/client/agent.js +174 -0
- package/dist/src/client/assistants.d.ts +4 -0
- package/dist/src/client/assistants.js +5 -0
- package/dist/src/client/bin.d.ts +2 -0
- package/dist/src/client/bin.js +3 -0
- package/dist/src/client/cli.d.ts +1 -0
- package/dist/src/client/cli.js +567 -0
- package/dist/src/client/clients.d.ts +34 -0
- package/dist/src/client/clients.js +74 -0
- package/dist/src/client/codexConfig.d.ts +1 -0
- package/dist/src/client/codexConfig.js +5 -0
- package/dist/src/client/config.d.ts +7 -0
- package/dist/src/client/config.js +7 -0
- package/dist/src/client/graderSeed.d.ts +50 -0
- package/dist/src/client/graderSeed.js +289 -0
- package/dist/src/client/hostMetrics.d.ts +54 -0
- package/dist/src/client/hostMetrics.js +425 -0
- package/dist/src/client/import/browser.d.ts +30 -0
- package/dist/src/client/import/browser.js +157 -0
- package/dist/src/client/import/convert.d.ts +20 -0
- package/dist/src/client/import/convert.js +165 -0
- package/dist/src/client/import/core.d.ts +143 -0
- package/dist/src/client/import/core.js +441 -0
- package/dist/src/client/import/ledger.d.ts +52 -0
- package/dist/src/client/import/ledger.js +161 -0
- package/dist/src/client/import/model.d.ts +70 -0
- package/dist/src/client/import/model.js +42 -0
- package/dist/src/client/import/options.d.ts +24 -0
- package/dist/src/client/import/options.js +71 -0
- package/dist/src/client/import/otlpImport.d.ts +7 -0
- package/dist/src/client/import/otlpImport.js +81 -0
- package/dist/src/client/import/protocol.d.ts +35 -0
- package/dist/src/client/import/protocol.js +51 -0
- package/dist/src/client/import/run.d.ts +30 -0
- package/dist/src/client/import/run.js +127 -0
- package/dist/src/client/import/sources/claudeCodeText.d.ts +19 -0
- package/dist/src/client/import/sources/claudeCodeText.js +214 -0
- package/dist/src/client/import/sources/codexText.d.ts +20 -0
- package/dist/src/client/import/sources/codexText.js +319 -0
- package/dist/src/client/import/sources/files.d.ts +24 -0
- package/dist/src/client/import/sources/files.js +129 -0
- package/dist/src/client/import/transport.d.ts +76 -0
- package/dist/src/client/import/transport.js +141 -0
- package/dist/src/client/index.d.ts +19 -0
- package/dist/src/client/index.js +19 -0
- package/dist/src/client/kiro/collector.d.ts +88 -0
- package/dist/src/client/kiro/collector.js +577 -0
- package/dist/src/client/kiro/command.d.ts +3 -0
- package/dist/src/client/kiro/command.js +109 -0
- package/dist/src/client/kiro/config.d.ts +39 -0
- package/dist/src/client/kiro/config.js +107 -0
- package/dist/src/client/kiro/records.d.ts +52 -0
- package/dist/src/client/kiro/records.js +206 -0
- package/dist/src/client/kiro/service.d.ts +21 -0
- package/dist/src/client/kiro/service.js +183 -0
- package/dist/src/client/kiro/state.d.ts +45 -0
- package/dist/src/client/kiro/state.js +205 -0
- package/dist/src/client/kiro/transport.d.ts +9 -0
- package/dist/src/client/kiro/transport.js +90 -0
- package/dist/src/client/onboard.d.ts +5 -1
- package/dist/src/client/onboard.js +28 -23
- package/dist/src/client/piConfig.d.ts +29 -0
- package/dist/src/client/piConfig.js +112 -0
- package/dist/src/client/plan.d.ts +1 -1
- package/dist/src/client/plan.js +2 -1
- package/dist/src/client/settings.d.ts +4 -0
- package/dist/src/client/settings.js +17 -0
- package/dist/src/client/yaml.d.ts +5 -0
- package/dist/src/client/yaml.js +72 -0
- package/dist/src/mcpServer.js +1 -1
- package/dist/src/tools.d.ts +9 -6
- package/dist/src/tools.js +478 -60
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +178 -9
- package/tool-manifest.json +497 -21
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ deterministic (see [Releases & discovery](#releases--discovery)):
|
|
|
31
31
|
```json
|
|
32
32
|
{
|
|
33
33
|
"mcpServers": {
|
|
34
|
-
"codetelemetry": { "command": "npx", "args": ["-y", "--package=@codetelemetry/mcp@0.3.
|
|
34
|
+
"codetelemetry": { "command": "npx", "args": ["-y", "--package=@codetelemetry/mcp@0.3.12", "codetelemetry-mcp"] }
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
```
|
|
@@ -42,6 +42,8 @@ Then just ask the agent: **"Connect me to CodeTelemetry."**
|
|
|
42
42
|
|
|
43
43
|
| Tool | What it does |
|
|
44
44
|
| --- | --- |
|
|
45
|
+
| `count_reply_phrases` | Count how often your own phrases appear in your Claude model replies, per day or week and per model (turns, turns with a match, per-phrase counts). Plain-text phrases with `{a|b}` / `[a|b]` groups, whole-word and case-insensitive; main-thread replies only; counts and session references, never reply text. |
|
|
46
|
+
| `import_history` | Import this machine's past Claude Code / Codex sessions (`~/.claude/projects`, `~/.codex/sessions`) through the normal ingest, tagged as imported. Dry run by default; skips sessions captured live or already imported; resumes interrupted imports; pages with `remaining`. Content defaults to `live` (what your live exporters send); `none` opts out. |
|
|
45
47
|
| `authenticate` | Start device-code auth; returns a URL + short code for the human to approve. Optional `organizationId` connects one of the user's organizations; optional `workspaceUrl` picks a CodeTelemetry server (codetelemetry.com hosts only). |
|
|
46
48
|
| `auth_status` | Poll the approval; on success captures the key into the session (masked-only to the model). |
|
|
47
49
|
| `get_ingest_key` | Record a pasted key (fast path) or report the authenticated one — masked + hash only. |
|
|
@@ -61,10 +63,63 @@ Then just ask the agent: **"Connect me to CodeTelemetry."**
|
|
|
61
63
|
| `estimate_task_size` | T-shirt size a proposed task (free-form text or a Linear-shaped issue) from the caller's own history. |
|
|
62
64
|
| `estimate_plan` | T-shirt size a Claude Code / Codex **plan** (plain text or ordered steps) from the caller's own history. |
|
|
63
65
|
| `estimate_linear_issue` | T-shirt size an **existing Linear issue** by URL or identifier, resolved through the workspace the user already connected. |
|
|
66
|
+
| `seed_grader_config` | Inspect local agent instructions, selected skills, and project task files; return source text and command-check candidates for the user's requested grading focus. Reads files without running commands or uploading them. |
|
|
67
|
+
| `get_grader_config` | Read a page of the workspace's Grader draft, its revision, and published version. |
|
|
68
|
+
| `update_grader_config` | Add, update, or remove selected draft checks while preserving others. Records the user's requested instruction features and rejects stale revisions. Publish the draft on the Grader page to change scoring. |
|
|
69
|
+
| `get_github_pr_gate` | Read the workspace's GitHub PR gate as its settings page shows it: the policy, trusted repositories, the GitHub Actions workflow file to commit, the check to require, outstanding steps, and recent decisions. |
|
|
70
|
+
| `configure_github_pr_gate` | Set up or change the GitHub PR gate: trust repositories (`owner/repo` or `owner/*`), set the policy, enable it. Once the gate is on, a change that loosens it is refused (`requires_dashboard`) and the user makes it on the settings page. No GitHub token is involved: the workflow authenticates with GitHub's own OIDC token. |
|
|
64
71
|
|
|
65
72
|
Typical agent flow: `authenticate` → (human approves) → `auth_status` →
|
|
66
73
|
`onboard`. Or, if the user pastes a key: `onboard { key }`.
|
|
67
74
|
|
|
75
|
+
GitHub PR gate flow, run from inside the repository to gate:
|
|
76
|
+
`configure_github_pr_gate { addRepositories: ["owner/repo"], enabled: true }` →
|
|
77
|
+
commit `gate.actions.workflow.content` at `gate.actions.workflow.path` (a PR
|
|
78
|
+
the user merges) → once it has run, the user requires
|
|
79
|
+
`codetelemetry/validation` from GitHub Actions on the default branch (`howTo`
|
|
80
|
+
gives the `gh api` ruleset command to run with their permission).
|
|
81
|
+
|
|
82
|
+
## Seed and update the Grader
|
|
83
|
+
|
|
84
|
+
Ask, for example: **"Use AGENTS.md and our security-review skill to grade unit
|
|
85
|
+
tests, lint, and security-review skill invocation. Ignore the writing style rules."**
|
|
86
|
+
|
|
87
|
+
The agent calls `seed_grader_config` with the repository directory and your
|
|
88
|
+
`features` description. Discovery includes nested packages and repository skills
|
|
89
|
+
under `.agents/skills`, `.claude/skills`, and `.codex/skills`. Additional user
|
|
90
|
+
skills can be selected explicitly through `skillPaths`; your home directory is
|
|
91
|
+
never scanned automatically.
|
|
92
|
+
|
|
93
|
+
Command candidates come from npm/pnpm/yarn/bun scripts, Composer scripts,
|
|
94
|
+
Make/Just/Rake targets, pytest/Ruff/mypy configuration, tox/nox, Go, Cargo,
|
|
95
|
+
Maven/Gradle, .NET project files, Swift, Mix, and CMake test configuration.
|
|
96
|
+
Declared tasks and inferred conventions are labelled separately. Discovery is
|
|
97
|
+
bounded, skips dependency/generated/hidden directories, does not follow links,
|
|
98
|
+
and reports truncation or unreadable sources. Narrow the repository directory
|
|
99
|
+
when a large monorepo hits the limits. No task is executed.
|
|
100
|
+
|
|
101
|
+
The calling agent uses your description to select relevant checks and translate
|
|
102
|
+
instruction features into observable command or tool-use matchers. It should
|
|
103
|
+
explain prose requirements the deterministic Grader cannot establish. Invoking a
|
|
104
|
+
skill can be checked; compliance with all its written guidance cannot be inferred
|
|
105
|
+
from invocation alone. Review inferred commands and adapt local working-directory
|
|
106
|
+
matchers if your sessions run at another path. Pass `repositoryId` from session
|
|
107
|
+
metadata to scope checks to the recorded repository.
|
|
108
|
+
|
|
109
|
+
The agent then reads `get_grader_config` (follow `nextOffset` for remaining checks)
|
|
110
|
+
and sends selected `upsertChecks` and/or `removeCheckIds` to
|
|
111
|
+
`update_grader_config`, with `features` and the read's `revision` as
|
|
112
|
+
`expectedRevision`. Existing checks are preserved unless named. A concurrent
|
|
113
|
+
edit returns `conflict`; read again before retrying. An uncertain save must also
|
|
114
|
+
be read back before retrying. Only selected check definitions and your feature
|
|
115
|
+
description go to the server; source file text stays local to the MCP response.
|
|
116
|
+
|
|
117
|
+
Changes appear as a draft at the [Grader page](https://codetelemetry.com/app/validation).
|
|
118
|
+
Publish there to apply them to scoring. MCP tools do not publish a policy or
|
|
119
|
+
rewrite historical scores. Remote configuration requires a backend implementing
|
|
120
|
+
`POST /api/agent/grader` and `POST /api/agent/grader/configure`; older deployments
|
|
121
|
+
return `not_supported` or `not_configured`. Local seeding works without a key.
|
|
122
|
+
|
|
68
123
|
## Organizations
|
|
69
124
|
|
|
70
125
|
Without an `organizationId`, the key goes wherever the user picks while approving:
|
|
@@ -144,7 +199,7 @@ passes its own plan text/steps explicitly:
|
|
|
144
199
|
{ "title": "Config", "detail": "expose the limit + window as env vars" },
|
|
145
200
|
"Add unit and integration tests for the limiter"
|
|
146
201
|
],
|
|
147
|
-
"repo": "
|
|
202
|
+
"repo": "acme-api",
|
|
148
203
|
"provider": "claude",
|
|
149
204
|
"model": "claude-opus-4-8"
|
|
150
205
|
}
|
|
@@ -158,7 +213,7 @@ steps) and set `provider: "codex"`:
|
|
|
158
213
|
{
|
|
159
214
|
"title": "Backfill Linear estimates",
|
|
160
215
|
"planText": "1. Read settled sessions for the window\n2. Size each by actual token usage\n3. Write the estimate + provenance back to Linear behind a confirm gate",
|
|
161
|
-
"repo": "
|
|
216
|
+
"repo": "acme-api",
|
|
162
217
|
"provider": "codex"
|
|
163
218
|
}
|
|
164
219
|
```
|
|
@@ -185,7 +240,7 @@ names its own workspace, so nothing else is needed:
|
|
|
185
240
|
// tool: estimate_linear_issue
|
|
186
241
|
{
|
|
187
242
|
"reference": "https://linear.app/acme/issue/ELL-44/add-an-mcp-tool-to-estimate-linear-issues",
|
|
188
|
-
"repo": "
|
|
243
|
+
"repo": "acme-api"
|
|
189
244
|
}
|
|
190
245
|
```
|
|
191
246
|
|
|
@@ -198,7 +253,7 @@ workspace is connected, name the one to use:
|
|
|
198
253
|
{
|
|
199
254
|
"reference": "ELL-44",
|
|
200
255
|
"workspace": "acme",
|
|
201
|
-
"repo": "
|
|
256
|
+
"repo": "acme-api"
|
|
202
257
|
}
|
|
203
258
|
```
|
|
204
259
|
|
|
@@ -255,8 +310,8 @@ not help), and `sizing_failed` for anything unmapped.
|
|
|
255
310
|
The plaintext `cot_…` key lives only inside the server process's session
|
|
256
311
|
(`#private` field). Every tool result carries a **masked** preview (`cot_…b3F9`)
|
|
257
312
|
and the key hash — never the plaintext. `callTool` additionally scrubs the
|
|
258
|
-
serialized result as a backstop. This invariant is asserted
|
|
259
|
-
[`test/tools.test.ts`](test/tools.test.ts)
|
|
313
|
+
serialized result as a backstop. This invariant is asserted throughout
|
|
314
|
+
[`test/tools.test.ts`](test/tools.test.ts).
|
|
260
315
|
|
|
261
316
|
The public MCP schemas deliberately expose neither endpoint overrides nor
|
|
262
317
|
arbitrary config paths. Test harnesses and trusted embedders can inject those
|
|
@@ -288,7 +343,7 @@ npm run smoke -- --tarball out.tgz --require-auth # exactly these by
|
|
|
288
343
|
and read `server`:
|
|
289
344
|
|
|
290
345
|
```jsonc
|
|
291
|
-
"server": { "name": "codetelemetry", "version": "0.3.
|
|
346
|
+
"server": { "name": "codetelemetry", "version": "0.3.11", "registryHash": "cb420922…", "toolCount": 23 }
|
|
292
347
|
```
|
|
293
348
|
|
|
294
349
|
**When a long-running client sees a new tool.** `tools/list` is requested once, at
|
|
@@ -329,6 +384,32 @@ npm run test:packaged # packs, launches the artifact, runs the release smoke
|
|
|
329
384
|
npm run typecheck
|
|
330
385
|
```
|
|
331
386
|
|
|
332
|
-
`npm test
|
|
387
|
+
`npm test` and `test:protocol` load `test/support/isolateHome.ts`, which
|
|
333
388
|
points `HOME`, `USERPROFILE` and `CODEX_HOME` at a throwaway directory, so a test can
|
|
334
389
|
never rewrite your own `~/.claude/settings.json` or Codex config.
|
|
390
|
+
|
|
391
|
+
## Client implementation ownership
|
|
392
|
+
|
|
393
|
+
This public repository owns the local client implementation. `src/client` contains
|
|
394
|
+
configuration, privacy controls, HTTP adapters, history upload, and the bounded
|
|
395
|
+
Kiro collector. The MCP server and Connect CLI share that implementation. Server
|
|
396
|
+
authorization, analytics, dispatch policy and production operations are maintained
|
|
397
|
+
separately and are not included in either package.
|
|
398
|
+
|
|
399
|
+
Run the Connect CLI with `npx -p @codetelemetry/mcp codetelemetry-connect --help`.
|
|
400
|
+
Kiro uses `codetelemetry-connect login --client kiro` and requires Node 24.
|
|
401
|
+
`kiro status`, `kiro disable`, and `kiro uninstall` inspect or stop its owned service.
|
|
402
|
+
Kiro reads local V3 transcripts with prompt/tool content disabled by default;
|
|
403
|
+
`--enrich` explicitly opts into those fields. Linux/macOS support an owned user
|
|
404
|
+
service; Windows uses foreground `kiro collect`. Configuration lives separately
|
|
405
|
+
from Kiro itself. Checkpoints and owned runtime files survive service removal.
|
|
406
|
+
|
|
407
|
+
The Kiro collector sends bounded, sanitized source records. Event interpretation,
|
|
408
|
+
call/result association, usage aggregation and analytics run in the service.
|
|
409
|
+
The service must support `kiro-v3-source-v1` before this collector is released;
|
|
410
|
+
unsupported responses leave the pending upload and source offsets intact.
|
|
411
|
+
Checkpoint versions 1 and 2 upgrade to version 3; older collector binaries refuse
|
|
412
|
+
version 3. Existing canonical pending uploads retain their exact retry bytes.
|
|
413
|
+
|
|
414
|
+
Collector health version 2 reports local capture and delivery counters. It omits
|
|
415
|
+
call-association counts that are now computed by the service.
|
|
@@ -39,6 +39,7 @@ export type AgentReadPerformance = {
|
|
|
39
39
|
};
|
|
40
40
|
export type SessionPerformanceReport = {
|
|
41
41
|
sessionId: string;
|
|
42
|
+
service?: string;
|
|
42
43
|
present: boolean;
|
|
43
44
|
sessionCount: number;
|
|
44
45
|
eventCount: number;
|
|
@@ -90,6 +91,14 @@ export type SessionSearchHit = {
|
|
|
90
91
|
title: string;
|
|
91
92
|
titleIsId: boolean;
|
|
92
93
|
sessionName?: string;
|
|
94
|
+
delegation?: {
|
|
95
|
+
parentSessionId: string;
|
|
96
|
+
parentSessionUrl?: string;
|
|
97
|
+
at: string;
|
|
98
|
+
source: "codex.agent_communication";
|
|
99
|
+
taskName?: string;
|
|
100
|
+
taskNameSource?: "parent_spawn_agent";
|
|
101
|
+
};
|
|
93
102
|
repo: string;
|
|
94
103
|
repoInferred?: boolean;
|
|
95
104
|
user?: string;
|
|
@@ -97,17 +106,66 @@ export type SessionSearchHit = {
|
|
|
97
106
|
models: string[];
|
|
98
107
|
lastSeen: string | null;
|
|
99
108
|
durationMs: number;
|
|
100
|
-
totalTokens
|
|
101
|
-
costUsd
|
|
109
|
+
totalTokens?: number;
|
|
110
|
+
costUsd?: number;
|
|
102
111
|
prompts: number;
|
|
103
|
-
invocations
|
|
112
|
+
invocations?: number;
|
|
104
113
|
tools: number;
|
|
114
|
+
linesAdded?: number;
|
|
115
|
+
linesRemoved?: number;
|
|
116
|
+
commits?: number;
|
|
117
|
+
pullRequests?: number;
|
|
118
|
+
costPerCommit?: number;
|
|
119
|
+
zeroOutput?: true;
|
|
120
|
+
outcomeSource?: "claude_code_metrics" | "tool_event_parse";
|
|
105
121
|
activity?: "substantive" | "instrumentation_only" | "insufficient_evidence";
|
|
106
122
|
match?: {
|
|
107
123
|
fields: string[];
|
|
108
124
|
};
|
|
125
|
+
measurements?: {
|
|
126
|
+
version: 1;
|
|
127
|
+
tokens: "measured" | "unmeasured" | "unavailable" | "conflict";
|
|
128
|
+
usd: "measured" | "unmeasured" | "unavailable" | "conflict";
|
|
129
|
+
modelCalls: "measured" | "unmeasured" | "unavailable" | "conflict";
|
|
130
|
+
apiLatency: "measured" | "unmeasured" | "unavailable" | "conflict";
|
|
131
|
+
toolDuration: "measured" | "unmeasured" | "unavailable" | "conflict";
|
|
132
|
+
providerCredits: "measured" | "unmeasured" | "unavailable" | "conflict";
|
|
133
|
+
reportedTurnElapsed: "measured" | "unmeasured" | "unavailable" | "conflict";
|
|
134
|
+
turnCompletion?: "measured" | "unmeasured" | "unavailable" | "conflict";
|
|
135
|
+
};
|
|
136
|
+
providerUsageWindow?: {
|
|
137
|
+
from: string;
|
|
138
|
+
through: string;
|
|
139
|
+
basis: "retained_provider_turns";
|
|
140
|
+
};
|
|
141
|
+
turnCompletion?: {
|
|
142
|
+
turns: number;
|
|
143
|
+
completed: number;
|
|
144
|
+
cancelled: number;
|
|
145
|
+
errors: number;
|
|
146
|
+
unknown: number;
|
|
147
|
+
successfulCompleted: number;
|
|
148
|
+
reportedStatusTurns: number;
|
|
149
|
+
};
|
|
150
|
+
providerTurnCoverage?: {
|
|
151
|
+
turnsWithoutUsage: number;
|
|
152
|
+
turnsWithoutCompletion: number;
|
|
153
|
+
};
|
|
154
|
+
providerUsage?: {
|
|
155
|
+
provider: "kiro";
|
|
156
|
+
unit: "credit";
|
|
157
|
+
amount: number;
|
|
158
|
+
turns: number;
|
|
159
|
+
reportedTurnElapsedMs?: number;
|
|
160
|
+
reportedTurnCount: number;
|
|
161
|
+
};
|
|
109
162
|
};
|
|
110
163
|
export type SessionSearchLegacyReport = {
|
|
164
|
+
telemetrySnapshot?: {
|
|
165
|
+
materializedAt: string;
|
|
166
|
+
dataThrough: string | null;
|
|
167
|
+
eventContent: "separate_snapshot";
|
|
168
|
+
};
|
|
111
169
|
results: SessionSearchHit[];
|
|
112
170
|
total: number;
|
|
113
171
|
limit: number;
|
|
@@ -345,16 +403,121 @@ export type SimilarSessionErrorsResult = {
|
|
|
345
403
|
error: string | null;
|
|
346
404
|
message: string | null;
|
|
347
405
|
};
|
|
406
|
+
export type HostState = "healthy" | "degraded" | "stale" | "offline";
|
|
407
|
+
export type HostThresholds = {
|
|
408
|
+
cpuSoft: number;
|
|
409
|
+
cpuHard: number;
|
|
410
|
+
memSoft: number;
|
|
411
|
+
memHard: number;
|
|
412
|
+
swapHard: number;
|
|
413
|
+
fsSoft: number;
|
|
414
|
+
fsHard: number;
|
|
415
|
+
staleAfterSec: number;
|
|
416
|
+
offlineAfterSec: number;
|
|
417
|
+
};
|
|
418
|
+
export type HostAgentdProcess = {
|
|
419
|
+
detected: boolean;
|
|
420
|
+
cpuUtil: number | null;
|
|
421
|
+
memUtil: number | null;
|
|
422
|
+
threads: number | null;
|
|
423
|
+
};
|
|
424
|
+
export type HostSignals = {
|
|
425
|
+
cpuUtil: number | null;
|
|
426
|
+
memUtil: number | null;
|
|
427
|
+
swapUtil: number | null;
|
|
428
|
+
fsUtil: number | null;
|
|
429
|
+
load1: number | null;
|
|
430
|
+
load5: number | null;
|
|
431
|
+
load15: number | null;
|
|
432
|
+
uptimeSec: number | null;
|
|
433
|
+
networkErrors: number | null;
|
|
434
|
+
agentd: HostAgentdProcess;
|
|
435
|
+
codingAgentsPresent: string[];
|
|
436
|
+
};
|
|
437
|
+
export type HostHeadroom = {
|
|
438
|
+
cpu: number | null;
|
|
439
|
+
memory: number | null;
|
|
440
|
+
swap: number | null;
|
|
441
|
+
filesystem: number | null;
|
|
442
|
+
limitingFactor: string | null;
|
|
443
|
+
};
|
|
444
|
+
export type HostAdmission = {
|
|
445
|
+
admit: boolean;
|
|
446
|
+
reason: string;
|
|
447
|
+
limitingFactor: string | null;
|
|
448
|
+
};
|
|
449
|
+
export type HostHealth = {
|
|
450
|
+
instance: string;
|
|
451
|
+
host: string | null;
|
|
452
|
+
os: string | null;
|
|
453
|
+
arch: string | null;
|
|
454
|
+
environment: string | null;
|
|
455
|
+
state: HostState;
|
|
456
|
+
synthetic?: boolean;
|
|
457
|
+
reasons: string[];
|
|
458
|
+
warnings: string[];
|
|
459
|
+
lastSeen: string | null;
|
|
460
|
+
ageSeconds: number | null;
|
|
461
|
+
signals: HostSignals;
|
|
462
|
+
signalObservedAt?: Record<string, {
|
|
463
|
+
at: string;
|
|
464
|
+
ageSeconds: number;
|
|
465
|
+
}>;
|
|
466
|
+
headroom: HostHeadroom;
|
|
467
|
+
admission: HostAdmission;
|
|
468
|
+
};
|
|
469
|
+
export type HostHealthReport = {
|
|
470
|
+
generatedAt: string;
|
|
471
|
+
asOf: string | null;
|
|
472
|
+
policyVersion: string;
|
|
473
|
+
lookbackMinutes: number;
|
|
474
|
+
windowMinutes: number;
|
|
475
|
+
signalMaxAgeSec: number;
|
|
476
|
+
thresholds: HostThresholds;
|
|
477
|
+
signalUnits?: Record<string, string>;
|
|
478
|
+
hosts: HostHealth[];
|
|
479
|
+
summary: {
|
|
480
|
+
total: number;
|
|
481
|
+
healthy: number;
|
|
482
|
+
degraded: number;
|
|
483
|
+
stale: number;
|
|
484
|
+
offline: number;
|
|
485
|
+
admittable: number;
|
|
486
|
+
synthetic?: number;
|
|
487
|
+
};
|
|
488
|
+
};
|
|
489
|
+
export type HostPipelineDiagnosis = {
|
|
490
|
+
stage: string;
|
|
491
|
+
detail: string;
|
|
492
|
+
hostFeedLastSeen: string | null;
|
|
493
|
+
hostFeedLastSeenAgeSec: number | null;
|
|
494
|
+
otherFeedsLastSeen: string | null;
|
|
495
|
+
otherFeedsLastSeenAgeSec: number | null;
|
|
496
|
+
horizonDays: number | null;
|
|
497
|
+
};
|
|
498
|
+
export type HostHealthResult = {
|
|
499
|
+
ok: boolean;
|
|
500
|
+
report: HostHealthReport | null;
|
|
501
|
+
status: string | null;
|
|
502
|
+
diagnosis: HostPipelineDiagnosis | null;
|
|
503
|
+
serverVersion: string | null;
|
|
504
|
+
reportUnusable: string | null;
|
|
505
|
+
httpStatus: number;
|
|
506
|
+
error: string | null;
|
|
507
|
+
message: string | null;
|
|
508
|
+
};
|
|
348
509
|
export declare function getCostSignal(opts: {
|
|
349
510
|
key: string;
|
|
350
511
|
url: string;
|
|
351
512
|
fetchImpl?: FetchLike;
|
|
352
513
|
timeoutMs?: number;
|
|
353
514
|
}): Promise<CostSignalResult>;
|
|
515
|
+
export declare function normalizeSessionPerformanceService(value: unknown): string | undefined | null;
|
|
354
516
|
export declare function getSessionPerformance(opts: {
|
|
355
517
|
key: string;
|
|
356
518
|
url: string;
|
|
357
519
|
sessionId: string;
|
|
520
|
+
service?: string;
|
|
358
521
|
includeFresh?: boolean;
|
|
359
522
|
cacheSamples?: number;
|
|
360
523
|
fetchImpl?: FetchLike;
|
|
@@ -383,6 +546,20 @@ export declare function searchCodingSessions(opts: SessionSearchOptions<Record<s
|
|
|
383
546
|
export declare function searchCodingSessions(opts: SessionSearchOptions<Record<string, unknown> & {
|
|
384
547
|
precedent?: false;
|
|
385
548
|
}>): Promise<SessionSearchResult>;
|
|
549
|
+
export type ReplyPhraseTrendsResult = {
|
|
550
|
+
ok: boolean;
|
|
551
|
+
trends: Record<string, unknown> | null;
|
|
552
|
+
httpStatus: number;
|
|
553
|
+
error: string | null;
|
|
554
|
+
message: string | null;
|
|
555
|
+
};
|
|
556
|
+
export declare function countReplyPhrases(opts: {
|
|
557
|
+
key: string;
|
|
558
|
+
url: string;
|
|
559
|
+
query: Record<string, unknown>;
|
|
560
|
+
fetchImpl?: FetchLike;
|
|
561
|
+
timeoutMs?: number;
|
|
562
|
+
}): Promise<ReplyPhraseTrendsResult>;
|
|
386
563
|
export declare function estimateTaskSize(opts: {
|
|
387
564
|
key: string;
|
|
388
565
|
url: string;
|
|
@@ -402,6 +579,15 @@ export declare function estimateTaskSize(opts: {
|
|
|
402
579
|
fetchImpl?: FetchLike;
|
|
403
580
|
timeoutMs?: number;
|
|
404
581
|
}): Promise<TaskEffortResult>;
|
|
582
|
+
export declare function getHostHealth(opts: {
|
|
583
|
+
key: string;
|
|
584
|
+
url: string;
|
|
585
|
+
lookbackMinutes?: number;
|
|
586
|
+
thresholds?: Partial<HostThresholds>;
|
|
587
|
+
diagnose?: boolean;
|
|
588
|
+
fetchImpl?: FetchLike;
|
|
589
|
+
timeoutMs?: number;
|
|
590
|
+
}): Promise<HostHealthResult>;
|
|
405
591
|
export declare function estimateLinearIssue(opts: {
|
|
406
592
|
key: string;
|
|
407
593
|
url: string;
|
|
@@ -445,6 +631,26 @@ export declare function readSessionEvents(opts: {
|
|
|
445
631
|
error: string | null;
|
|
446
632
|
message: string | null;
|
|
447
633
|
}>;
|
|
634
|
+
export type GitHubGateResult = {
|
|
635
|
+
ok: boolean;
|
|
636
|
+
gate: Record<string, unknown> | null;
|
|
637
|
+
httpStatus: number;
|
|
638
|
+
error: string | null;
|
|
639
|
+
message: string | null;
|
|
640
|
+
};
|
|
641
|
+
export declare function readGitHubGate(opts: {
|
|
642
|
+
key: string;
|
|
643
|
+
url: string;
|
|
644
|
+
fetchImpl?: FetchLike;
|
|
645
|
+
timeoutMs?: number;
|
|
646
|
+
}): Promise<GitHubGateResult>;
|
|
647
|
+
export declare function configureGitHubGate(opts: {
|
|
648
|
+
key: string;
|
|
649
|
+
url: string;
|
|
650
|
+
change: Record<string, unknown>;
|
|
651
|
+
fetchImpl?: FetchLike;
|
|
652
|
+
timeoutMs?: number;
|
|
653
|
+
}): Promise<GitHubGateResult>;
|
|
448
654
|
export declare function compareSessions(opts: {
|
|
449
655
|
key: string;
|
|
450
656
|
url: string;
|
|
@@ -478,4 +684,16 @@ export declare function planNextSession(opts: {
|
|
|
478
684
|
error: string | null;
|
|
479
685
|
message: string | null;
|
|
480
686
|
}>;
|
|
687
|
+
export declare function graderConfigRequest(opts: {
|
|
688
|
+
key: string;
|
|
689
|
+
url: string;
|
|
690
|
+
body: Record<string, unknown>;
|
|
691
|
+
fetchImpl?: FetchLike;
|
|
692
|
+
}): Promise<{
|
|
693
|
+
ok: boolean;
|
|
694
|
+
config: any;
|
|
695
|
+
httpStatus: number;
|
|
696
|
+
error: any;
|
|
697
|
+
message: any;
|
|
698
|
+
}>;
|
|
481
699
|
export {};
|
package/dist/src/client/agent.js
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import { assertKey } from "./keys.js";
|
|
2
|
+
function parseDiagnosis(raw) {
|
|
3
|
+
if (raw === null || typeof raw !== "object" || Array.isArray(raw))
|
|
4
|
+
return null;
|
|
5
|
+
const d = raw;
|
|
6
|
+
if (typeof d.stage !== "string" || !d.stage)
|
|
7
|
+
return null;
|
|
8
|
+
const str = (v) => (typeof v === "string" && v ? v : null);
|
|
9
|
+
const num = (v) => typeof v === "number" && Number.isFinite(v) ? v : null;
|
|
10
|
+
return {
|
|
11
|
+
stage: d.stage,
|
|
12
|
+
detail: str(d.detail) ?? "",
|
|
13
|
+
hostFeedLastSeen: str(d.hostFeedLastSeen),
|
|
14
|
+
hostFeedLastSeenAgeSec: num(d.hostFeedLastSeenAgeSec),
|
|
15
|
+
otherFeedsLastSeen: str(d.otherFeedsLastSeen),
|
|
16
|
+
otherFeedsLastSeenAgeSec: num(d.otherFeedsLastSeenAgeSec),
|
|
17
|
+
horizonDays: num(d.horizonDays),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
2
20
|
async function postAgent(opts) {
|
|
3
21
|
const key = assertKey(opts.key);
|
|
4
22
|
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
@@ -79,12 +97,24 @@ export async function getCostSignal(opts) {
|
|
|
79
97
|
clearTimeout(timer);
|
|
80
98
|
}
|
|
81
99
|
}
|
|
100
|
+
export function normalizeSessionPerformanceService(value) {
|
|
101
|
+
if (value === undefined)
|
|
102
|
+
return undefined;
|
|
103
|
+
if (typeof value !== "string" || /[\u0000-\u001f]/.test(value))
|
|
104
|
+
return null;
|
|
105
|
+
const service = value.trim();
|
|
106
|
+
return service && Buffer.byteLength(service, "utf8") <= 128 ? service : null;
|
|
107
|
+
}
|
|
82
108
|
export async function getSessionPerformance(opts) {
|
|
109
|
+
const service = normalizeSessionPerformanceService(opts.service);
|
|
110
|
+
if (service === null)
|
|
111
|
+
return { ok: false, report: null, httpStatus: 0, error: "bad_input", message: "service must contain 1-128 UTF-8 bytes without C0 controls" };
|
|
83
112
|
const result = await postAgent({
|
|
84
113
|
...opts,
|
|
85
114
|
timeoutMs: opts.timeoutMs ?? 120_000,
|
|
86
115
|
body: {
|
|
87
116
|
sessionId: opts.sessionId,
|
|
117
|
+
...(service === undefined ? {} : { service }),
|
|
88
118
|
...(opts.includeFresh === undefined ? {} : { includeFresh: opts.includeFresh }),
|
|
89
119
|
...(opts.cacheSamples === undefined ? {} : { cacheSamples: opts.cacheSamples }),
|
|
90
120
|
},
|
|
@@ -152,6 +182,19 @@ export async function searchCodingSessions(opts) {
|
|
|
152
182
|
message: result.message,
|
|
153
183
|
};
|
|
154
184
|
}
|
|
185
|
+
export async function countReplyPhrases(opts) {
|
|
186
|
+
const result = await postAgent({
|
|
187
|
+
key: opts.key, url: opts.url, fetchImpl: opts.fetchImpl, timeoutMs: opts.timeoutMs ?? 20_000, body: opts.query,
|
|
188
|
+
});
|
|
189
|
+
if (result.bodyError) {
|
|
190
|
+
return { ok: false, trends: null, httpStatus: result.httpStatus, error: result.bodyError, message: `Reply-phrase response headers arrived but its body did not (${result.bodyError}).` };
|
|
191
|
+
}
|
|
192
|
+
const trends = result.value?.trends;
|
|
193
|
+
if (result.ok && (!trends || typeof trends !== "object" || Array.isArray(trends))) {
|
|
194
|
+
return { ok: false, trends: null, httpStatus: result.httpStatus, error: "read_unusable", message: "Reply-phrase response did not contain usable counts." };
|
|
195
|
+
}
|
|
196
|
+
return { ok: result.ok, trends: result.ok ? trends ?? null : null, httpStatus: result.httpStatus, error: result.error, message: result.message };
|
|
197
|
+
}
|
|
155
198
|
export async function estimateTaskSize(opts) {
|
|
156
199
|
const result = await postAgent({
|
|
157
200
|
...opts,
|
|
@@ -176,6 +219,76 @@ export async function estimateTaskSize(opts) {
|
|
|
176
219
|
message: result.message,
|
|
177
220
|
};
|
|
178
221
|
}
|
|
222
|
+
export async function getHostHealth(opts) {
|
|
223
|
+
assertKey(opts.key);
|
|
224
|
+
let result;
|
|
225
|
+
try {
|
|
226
|
+
result = await postAgent({
|
|
227
|
+
...opts,
|
|
228
|
+
timeoutMs: opts.timeoutMs ?? 25_000,
|
|
229
|
+
body: {
|
|
230
|
+
...(opts.lookbackMinutes === undefined ? {} : { lookbackMinutes: opts.lookbackMinutes }),
|
|
231
|
+
...(opts.thresholds === undefined ? {} : { thresholds: opts.thresholds }),
|
|
232
|
+
...(opts.diagnose === undefined ? {} : { diagnose: opts.diagnose }),
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
catch (err) {
|
|
237
|
+
return {
|
|
238
|
+
ok: false,
|
|
239
|
+
report: null,
|
|
240
|
+
status: null,
|
|
241
|
+
diagnosis: null,
|
|
242
|
+
serverVersion: null,
|
|
243
|
+
reportUnusable: null,
|
|
244
|
+
httpStatus: 0,
|
|
245
|
+
error: "read_unavailable",
|
|
246
|
+
message: `Host-health read could not reach the control plane: ${err.message}`,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
if (result.bodyError) {
|
|
250
|
+
return {
|
|
251
|
+
ok: false,
|
|
252
|
+
report: null,
|
|
253
|
+
status: null,
|
|
254
|
+
diagnosis: null,
|
|
255
|
+
serverVersion: null,
|
|
256
|
+
reportUnusable: null,
|
|
257
|
+
httpStatus: result.httpStatus,
|
|
258
|
+
error: result.bodyError,
|
|
259
|
+
message: `Host-health response headers arrived but its body did not (${result.bodyError}).`,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
const decoded = result.ok ? result.value : null;
|
|
263
|
+
const reportUnusable = (() => {
|
|
264
|
+
if (!result.ok)
|
|
265
|
+
return null;
|
|
266
|
+
if (decoded === null || typeof decoded !== "object") {
|
|
267
|
+
return "the response body could not be read as JSON";
|
|
268
|
+
}
|
|
269
|
+
if (!("report" in decoded))
|
|
270
|
+
return "the response carried no report member";
|
|
271
|
+
if (decoded.report === null)
|
|
272
|
+
return null;
|
|
273
|
+
if (typeof decoded.report !== "object" || Array.isArray(decoded.report)) {
|
|
274
|
+
return "the response report is not an object";
|
|
275
|
+
}
|
|
276
|
+
return null;
|
|
277
|
+
})();
|
|
278
|
+
return {
|
|
279
|
+
ok: result.ok,
|
|
280
|
+
report: result.ok && reportUnusable === null ? result.value?.report ?? null : null,
|
|
281
|
+
status: result.ok && typeof result.value?.status === "string" ? result.value.status : null,
|
|
282
|
+
diagnosis: parseDiagnosis(result.value?.diagnosis),
|
|
283
|
+
serverVersion: typeof result.value?.serverVersion === "string" && result.value.serverVersion.trim()
|
|
284
|
+
? result.value.serverVersion.trim()
|
|
285
|
+
: null,
|
|
286
|
+
reportUnusable,
|
|
287
|
+
httpStatus: result.httpStatus,
|
|
288
|
+
error: result.error,
|
|
289
|
+
message: result.message,
|
|
290
|
+
};
|
|
291
|
+
}
|
|
179
292
|
export async function estimateLinearIssue(opts) {
|
|
180
293
|
const result = await postAgent({
|
|
181
294
|
...opts,
|
|
@@ -231,6 +344,26 @@ export async function readSessionEvents(opts) {
|
|
|
231
344
|
message: result.message,
|
|
232
345
|
};
|
|
233
346
|
}
|
|
347
|
+
export async function readGitHubGate(opts) {
|
|
348
|
+
const result = await postAgent({ ...opts, body: {} });
|
|
349
|
+
return {
|
|
350
|
+
ok: result.ok,
|
|
351
|
+
gate: result.ok ? result.value?.gate ?? null : null,
|
|
352
|
+
httpStatus: result.httpStatus,
|
|
353
|
+
error: result.error,
|
|
354
|
+
message: result.message,
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
export async function configureGitHubGate(opts) {
|
|
358
|
+
const result = await postAgent({ ...opts, body: opts.change });
|
|
359
|
+
return {
|
|
360
|
+
ok: result.ok,
|
|
361
|
+
gate: result.ok ? result.value?.gate ?? null : null,
|
|
362
|
+
httpStatus: result.httpStatus,
|
|
363
|
+
error: result.error,
|
|
364
|
+
message: result.message,
|
|
365
|
+
};
|
|
366
|
+
}
|
|
234
367
|
export async function compareSessions(opts) {
|
|
235
368
|
const result = await postAgent({
|
|
236
369
|
...opts,
|
|
@@ -259,3 +392,44 @@ export async function planNextSession(opts) {
|
|
|
259
392
|
});
|
|
260
393
|
return { ok: result.ok, value: result.value ?? null, httpStatus: result.httpStatus, error: result.error, message: result.message };
|
|
261
394
|
}
|
|
395
|
+
export async function graderConfigRequest(opts) {
|
|
396
|
+
const key = assertKey(opts.key);
|
|
397
|
+
const response = await (opts.fetchImpl ?? fetch)(opts.url, {
|
|
398
|
+
method: "POST", headers: { "content-type": "application/json", authorization: `Bearer ${key}` },
|
|
399
|
+
body: JSON.stringify(opts.body), signal: AbortSignal.timeout(10_000),
|
|
400
|
+
});
|
|
401
|
+
const reader = response.body?.getReader();
|
|
402
|
+
const chunks = [];
|
|
403
|
+
let bytes = 0;
|
|
404
|
+
if (reader)
|
|
405
|
+
try {
|
|
406
|
+
while (true) {
|
|
407
|
+
const chunk = await reader.read();
|
|
408
|
+
if (chunk.done)
|
|
409
|
+
break;
|
|
410
|
+
bytes += chunk.value.byteLength;
|
|
411
|
+
if (bytes > 64 * 1024)
|
|
412
|
+
throw new Error("Grader response exceeds 64 KiB");
|
|
413
|
+
chunks.push(chunk.value);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
finally {
|
|
417
|
+
await reader.cancel().catch(() => { });
|
|
418
|
+
reader.releaseLock();
|
|
419
|
+
}
|
|
420
|
+
let decoded;
|
|
421
|
+
try {
|
|
422
|
+
decoded = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
423
|
+
}
|
|
424
|
+
catch {
|
|
425
|
+
decoded = null;
|
|
426
|
+
}
|
|
427
|
+
const config = decoded?.config;
|
|
428
|
+
return {
|
|
429
|
+
ok: response.ok && decoded?.ok === true && !!config && typeof config === "object" && !Array.isArray(config),
|
|
430
|
+
config,
|
|
431
|
+
httpStatus: response.status,
|
|
432
|
+
error: typeof decoded?.error === "string" ? decoded.error : null,
|
|
433
|
+
message: typeof decoded?.message === "string" ? decoded.message : null,
|
|
434
|
+
};
|
|
435
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const ONBOARD_CLIENTS: readonly ["claude", "codex", "pi", "kiro"];
|
|
2
|
+
export type OnboardClient = (typeof ONBOARD_CLIENTS)[number];
|
|
3
|
+
export declare function isOnboardClient(value: unknown): value is OnboardClient;
|
|
4
|
+
export declare const SESSION_FILTER_ASSISTANTS: readonly ["claude", "codex", "kiro"];
|