@codetelemetry/mcp 0.3.14 → 0.4.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 CHANGED
@@ -31,19 +31,115 @@ 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.14", "codetelemetry-mcp"] }
34
+ "codetelemetry": { "command": "npx", "args": ["-y", "--package=@codetelemetry/mcp@0.4.1", "codetelemetry-mcp"] }
35
35
  }
36
36
  }
37
37
  ```
38
38
 
39
39
  Then just ask the agent: **"Connect me to CodeTelemetry."**
40
40
 
41
+ ## Persistent organization workspaces
42
+
43
+ Ask the agent: **Create a Acme workspace for this repository and configure its Grader.**
44
+ It calls `bootstrap_workspace` with a stable local context name, the repository path,
45
+ and either `organizationName` (new) or `organizationId` (existing). Select checks
46
+ with `seed_grader_config` and pass the reviewed `checks` and `features`; `publish`
47
+ explicitly publishes them, and `terraform` leaves an IaC artifact.
48
+
49
+ The first call returns one browser approval URL. The page identifies the signed-in
50
+ account and destination, supports changing account, and creates a requested new
51
+ organization. Resume with just the same `name`. The private checkpoint survives
52
+ MCP restarts, expired device codes and interrupted responses. Creation uses the
53
+ same operation ID on retries; existing organizations are selected by ID, never name.
54
+
55
+ ```sh
56
+ npx -y @codetelemetry/connect bootstrap acme \
57
+ --organization-name "Acme" --client codex --project /path/to/repository
58
+ # After approval (or funding), resume the exact saved plan:
59
+ npx -y @codetelemetry/connect bootstrap acme
60
+ npx -y @codetelemetry/connect workspace list
61
+ ```
62
+
63
+ New workspace setups capture prompts and tool content by default so session titles,
64
+ replay and command evidence work immediately. Pass `enrich: false` to
65
+ `bootstrap_workspace`, or `--no-enrich` to Connect bootstrap, to opt out. The choice
66
+ is saved in the setup plan; resuming preserves explicit opt-outs, existing saved
67
+ client choices and legacy checkpoints. A new named Codex profile also defaults to
68
+ capture when no earlier capture choice exists. This does not change personal
69
+ onboarding defaults or another workspace's configuration. Captured team-scoped
70
+ content follows the organization's visibility policy; new organizations disclose
71
+ member visibility during creation, and administrators can change it in settings.
72
+
73
+ `--plan file.json` supplies the same bootstrap fields as the MCP tool, including
74
+ selected Grader checks. CLI exit 2 means setup is waiting for the returned action;
75
+ exit 0 means the requested checks completed. Funding is checked before client
76
+ configuration. No credits or seats are purchased. Content and repository observation
77
+ remain separate explicit opt-ins.
78
+
79
+ Credentials are private version-1 JSON files under
80
+ `$CODETELEMETRY_CONTEXT_HOME/<name>.json`, defaulting to
81
+ `$XDG_CONFIG_HOME/codetelemetry/workspaces` or
82
+ `~/.config/codetelemetry/workspaces`. Files are owned, mode 0600 on POSIX, atomically
83
+ replaced, and bounded to 64 KiB. There are at most 64 contexts and 192 directory
84
+ entries including checkpoints/locks. Unsafe versions, symlinks, mismatched account,
85
+ organization, billing account or origin fail closed. Failed authorization never
86
+ falls back to personal scope. Expired credentials can be replaced with
87
+ `bootstrap_workspace` using `reauthorize: true`; the replacement must attest the
88
+ same identity. Remove an unused named context/checkpoint explicitly to free capacity.
89
+
90
+ The repository's `.codetelemetry/workspace.json` contains only the context name,
91
+ service origin and scope. It can be committed; never commit the private context,
92
+ client config, Terraform state or plan. Bindings are found from subdirectories up
93
+ to the repository root. `CODETELEMETRY_WORKSPACE` selects a context explicitly but
94
+ must agree with an existing repository binding. MCP verifies scope at restore and
95
+ before use; governance requests also carry the expected scope so a key rescope
96
+ cannot race a check and change personal configuration.
97
+
98
+ For existing auth, call `workspace_context` with `action: "save"`, a name and
99
+ `repositoryPath`. `action: "use"` selects an already-saved context. Rebinding a
100
+ repository requires explicitly removing its previous binding. Unbound clients
101
+ retain the legacy login behavior.
102
+
103
+ Bootstrap writes Claude settings inside the repository. Codex ignores project-local
104
+ `otel`, so bootstrap writes a dedicated user-level profile
105
+ `$CODEX_HOME/codetelemetry-<name>.config.toml` (or the default `~/.codex` directory).
106
+ Launch with `codetelemetry-connect run <name> -- <arguments>` or
107
+ `codex --profile codetelemetry-<name>` in the bound repository. The profile retains
108
+ your base sign-in/settings while overriding telemetry and its explicit content
109
+ opt-in. It does not rewrite the base config or copy auth tokens. The profile also registers the version-pinned workspace MCP server and disables
110
+ the standard global CodeTelemetry MCP entry for that profile. Claude receives a
111
+ project `.mcp.json` entry bound to the same context. Optional Codex observation
112
+ hooks live in the profile and run only when it is selected.
113
+ Codex combines global and profile hooks. Bootstrap upgrades recognized older
114
+ CodeTelemetry observation helpers so they abstain in named workspaces; global
115
+ hook definitions and personal reporting are preserved. Modified helpers require
116
+ review before configuration continues. When opting into new observation hooks,
117
+ review and trust them in Codex's `/hooks` interface before expecting observations.
118
+ See [OpenAI configuration reference](https://learn.chatgpt.com/docs/config-file/config-reference)
119
+ and [hooks](https://learn.chatgpt.com/docs/hooks).
120
+ Secret-bearing project paths are added to `.gitignore` before configuration.
121
+
122
+ A requested GitHub gate produces its generated workflow locally. Bootstrap then
123
+ reads GitHub through the existing `gh` authentication and checks the default-branch
124
+ workflow, required check, and a real organization-scoped PR decision for the local
125
+ HEAD and published policy after setup started. It reports pending repository
126
+ work explicitly. It does not claim a PR passed merely because a probe landed.
127
+ A verified gate decision retains its actual success/failure verdict and score.
128
+ Terraform artifact generation is reported separately from applying Terraform.
129
+
130
+ The public service must deploy `/api/device/code/bootstrap-v1` and the matching
131
+ approval route before clients use new-organization creation. Older deployments
132
+ refuse the versioned request rather than creating a personal key. Existing-org
133
+ contexts use the established scope-v1 device flow.
134
+
41
135
  ## Tools
42
136
 
43
137
  | Tool | What it does |
44
138
  | --- | --- |
45
139
  | `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
140
  | `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. |
141
+ | `workspace_context` | Save, list or select persistent verified workspace contexts. Repository bindings contain no credentials; cold MCP processes restore the bound context. |
142
+ | `bootstrap_workspace` | Create or select an organization, authorize once, and resume funding, repository-local telemetry, Grader publication, Terraform artifacts and GitHub gate verification. |
47
143
  | `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). |
48
144
  | `auth_status` | Poll the approval; on success captures the key into the session (masked-only to the model). |
49
145
  | `get_ingest_key` | Record a pasted key (fast path) or report the authenticated one — masked + hash only. |
@@ -1,3 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import { run } from "./cli.js";
3
- process.exitCode = await run(process.argv.slice(2));
3
+ import { scrub } from "./keys.js";
4
+ try {
5
+ process.exitCode = await run(process.argv.slice(2));
6
+ }
7
+ catch (error) {
8
+ process.stderr.write(scrub(`CodeTelemetry: ${String(error.message)}\n`));
9
+ process.exitCode = 1;
10
+ }
@@ -0,0 +1,28 @@
1
+ import { type FetchLike } from "./otlp.ts";
2
+ export type BootstrapOptions = {
3
+ name: string;
4
+ repositoryPath?: string;
5
+ organizationName?: string;
6
+ organizationId?: string;
7
+ client?: "claude" | "codex";
8
+ configPath?: string;
9
+ features?: string;
10
+ checks?: Record<string, unknown>[];
11
+ publish?: boolean;
12
+ githubRepository?: string;
13
+ terraform?: boolean;
14
+ enrich?: boolean;
15
+ repositoryObservation?: boolean;
16
+ reauthorize?: boolean;
17
+ };
18
+ export declare function bootstrapWorkspace(options: BootstrapOptions, environment?: {
19
+ apiBase?: string;
20
+ fetchImpl?: FetchLike;
21
+ timeoutMs?: number;
22
+ }): Promise<{
23
+ nextAction?: string | undefined;
24
+ ok: boolean;
25
+ status: string;
26
+ workspace: string;
27
+ steps: Record<string, string>;
28
+ }>;