@codetelemetry/mcp 0.6.0 → 0.8.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/README.md +78 -7
- package/dist/src/client/cli.js +177 -4
- package/dist/src/client/import/browser.d.ts +8 -0
- package/dist/src/client/import/browser.js +83 -47
- package/dist/src/client/import/convert.d.ts +3 -3
- package/dist/src/client/import/convert.js +15 -4
- package/dist/src/client/import/core.d.ts +23 -3
- package/dist/src/client/import/core.js +78 -9
- package/dist/src/client/import/estimate.d.ts +87 -0
- package/dist/src/client/import/estimate.js +187 -0
- package/dist/src/client/import/identity.d.ts +25 -0
- package/dist/src/client/import/identity.js +118 -0
- package/dist/src/client/import/model.d.ts +18 -0
- package/dist/src/client/import/model.js +127 -0
- package/dist/src/client/import/run.d.ts +15 -2
- package/dist/src/client/import/run.js +80 -2
- package/dist/src/client/import/sources/claudeCodeText.js +2 -2
- package/dist/src/client/import/sources/codexText.js +28 -2
- package/dist/src/client/import/sources/files.d.ts +5 -1
- package/dist/src/client/import/sources/files.js +23 -2
- package/dist/src/client/import/transport.d.ts +10 -0
- package/dist/src/client/import/transport.js +26 -0
- package/dist/src/client/index.d.ts +3 -1
- package/dist/src/client/index.js +3 -1
- package/dist/src/client/repositoryHook.js +6 -1
- package/dist/src/client/repositoryOrigin.d.ts +1 -0
- package/dist/src/client/repositoryOrigin.js +13 -0
- package/dist/src/client/rolloutRepository.d.ts +29 -0
- package/dist/src/client/rolloutRepository.js +84 -0
- package/dist/src/client/workspaceImport.js +4 -2
- package/dist/src/client/workspaces.d.ts +1 -1
- package/dist/src/client/workspaces.js +3 -1
- package/dist/src/tools.d.ts +5 -0
- package/dist/src/tools.js +90 -9
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +9 -1
- package/tool-manifest.json +75 -7
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.
|
|
34
|
+
"codetelemetry": { "command": "npx", "args": ["-y", "--package=@codetelemetry/mcp@0.8.0", "codetelemetry-mcp"] }
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
```
|
|
@@ -45,7 +45,7 @@ sessions without local setup, or **Connect my coding tool** to record your own w
|
|
|
45
45
|
Run the project connection command from the repository you choose:
|
|
46
46
|
|
|
47
47
|
```sh
|
|
48
|
-
npx -y @codetelemetry/connect@0.
|
|
48
|
+
npx -y @codetelemetry/connect@0.4.0 join --organization-id tm_example --client codex --project .
|
|
49
49
|
# For Claude Code, use --client claude.
|
|
50
50
|
```
|
|
51
51
|
|
|
@@ -67,9 +67,9 @@ verification. **My sessions** is scoped to your authenticated ingest ownership;
|
|
|
67
67
|
Optional history import uses the saved project and credentials, without a key argument:
|
|
68
68
|
|
|
69
69
|
```sh
|
|
70
|
-
npx -y @codetelemetry/connect@0.
|
|
70
|
+
npx -y @codetelemetry/connect@0.4.0 import --workspace <name> --preview
|
|
71
71
|
# Choose numbers from that preview; no session content uploads until confirmation:
|
|
72
|
-
npx -y @codetelemetry/connect@0.
|
|
72
|
+
npx -y @codetelemetry/connect@0.4.0 import --workspace <name> --select 1,2 --confirm
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
Preview is local-only and defaults to the last 30 days. It keeps at most 100 session
|
|
@@ -118,6 +118,19 @@ exit 0 means the requested checks completed. Funding is checked before client
|
|
|
118
118
|
configuration. No credits or seats are purchased. Capture follows the saved choice;
|
|
119
119
|
repository observation remains a separate setup option (enabled by project join).
|
|
120
120
|
|
|
121
|
+
With repository observation enabled, Connect reports the canonical URL of a
|
|
122
|
+
GitHub checkout when its origin is an unambiguous HTTPS or SSH clone URL.
|
|
123
|
+
Codex history imports can use the origin and parent ID from the rollout
|
|
124
|
+
header. To preview just the repository metadata for previously recorded
|
|
125
|
+
sessions, run `codetelemetry-connect repository-metadata <rollout files>`.
|
|
126
|
+
To deliver the displayed observations to your account, supply its
|
|
127
|
+
`CODETELEMETRY_INGEST_KEY` and append `--send`. This command reads only the
|
|
128
|
+
first record of each selected file and sends no prompts, calls or usage.
|
|
129
|
+
If Codex has retained the Git origin in its SQLite thread database, preview
|
|
130
|
+
selected thread IDs with `repository-metadata --state <database> <thread IDs>`.
|
|
131
|
+
This mode needs Node's built-in SQLite module and performs read-only lookups.
|
|
132
|
+
|
|
133
|
+
|
|
121
134
|
Credentials are private version-1 JSON files under
|
|
122
135
|
`$CODETELEMETRY_CONTEXT_HOME/<name>.json`, defaulting to
|
|
123
136
|
`$XDG_CONFIG_HOME/codetelemetry/workspaces` or
|
|
@@ -179,7 +192,8 @@ contexts use the established scope-v1 device flow.
|
|
|
179
192
|
| Tool | What it does |
|
|
180
193
|
| --- | --- |
|
|
181
194
|
| `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. |
|
|
182
|
-
| `
|
|
195
|
+
| `estimate_history` | Price this machine's past Claude Code / Codex sessions before importing them: sessions and tokens per source, UTC month and day, oldest and newest session, last-30-day pace, priced with the public price list. Needs no key and sends nothing else; says from when a Claude Code session survives only if it was captured live or is still on disk (`cleanupPeriodDays`). |
|
|
196
|
+
| `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. Imported tokens are billed like live usage: the result's `billing` prices the run, and a real import starts no session the prepaid credit cannot cover. Rows carry the signed-in account's identity as live rows do (`identity: false` omits it). |
|
|
183
197
|
| `workspace_context` | Save, list or select persistent verified workspace contexts. Repository bindings contain no credentials; cold MCP processes restore the bound context. |
|
|
184
198
|
| `bootstrap_workspace` | Create or select an organization, authorize once, and resume funding, repository-local telemetry, Grader publication, Terraform artifacts and GitHub gate verification. |
|
|
185
199
|
| `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). |
|
|
@@ -191,7 +205,7 @@ contexts use the established scope-v1 device flow.
|
|
|
191
205
|
| `onboard` | One-shot: key → config → test → verify, returns a checklist. |
|
|
192
206
|
| `status` | Read-only diagnostics (no secrets). |
|
|
193
207
|
| `get_cost_signal` | Read recent tokens and observed model cost for the caller's own telemetry, with what CodeTelemetry meters for those tokens shown separately. |
|
|
194
|
-
| `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. Results are ordered by `lastSeen` (most recently active, not started or finished); `activity: "substantive"` keeps only sessions with observed agent work and counts what it left out. |
|
|
208
|
+
| `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. Results are ordered by `lastSeen` (most recently active, not started or finished); `activity: "substantive"` keeps only sessions with observed agent work and counts what it left out. Optional `start` / `end` (Unix seconds) keep sessions last active in that window. |
|
|
195
209
|
| `read_session_events` | Read one of your sessions' recorded events in order (prompts, assistant text, commands, tool inputs and outputs, exit codes), after privacy filtering and independent of any interpretation. Pages with a cursor, jumps by position or time, filters by kind, recorded outcome, tool or text, shows the context around an event, and expands one event's full retained text. |
|
|
196
210
|
| `interpret_session` | Read CodeTelemetry's own bounded, materialized interpretation of a session: optional hints to verify against the recorded events. Evidence cards are opt-in, privacy-filtered and pointer-resolved; the tool never replays raw telemetry. |
|
|
197
211
|
| `compare_sessions` | Compare 2–10 distinct materialized personal sessions. Returns descriptive repeated patterns, evidence pointers, denominators, observed outcome counterexamples, one-offs and confidence limits; it never replays raw telemetry or claims causation. |
|
|
@@ -269,7 +283,12 @@ explain prose requirements the deterministic Grader cannot establish. Invoking a
|
|
|
269
283
|
skill can be checked; compliance with all its written guidance cannot be inferred
|
|
270
284
|
from invocation alone. Review inferred commands and adapt local working-directory
|
|
271
285
|
matchers if your sessions run at another path. Pass `repositoryId` from session
|
|
272
|
-
metadata to scope checks to the recorded repository.
|
|
286
|
+
metadata to scope checks to the recorded repository. Give a check `issues`
|
|
287
|
+
(`["owner/repo#N"]`, lowercase) to make it a task check: it is required only for a
|
|
288
|
+
pull request that GitHub reports closes one of those issues, and it adds to the
|
|
289
|
+
organization and repository checks. The PR gate reads GitHub's closing-issue
|
|
290
|
+
references; when a repository has task checks, unknown or unmapped linkage fails
|
|
291
|
+
closed.
|
|
273
292
|
|
|
274
293
|
The agent then reads `get_grader_config` (follow `nextOffset` for remaining checks)
|
|
275
294
|
and sends selected `upsertChecks` and/or `removeCheckIds` to
|
|
@@ -393,6 +412,58 @@ on prompt/body telemetry, and `enrich` does not install repository hooks. A late
|
|
|
393
412
|
run with `repositoryObservation` omitted or false removes only CodeTelemetry's
|
|
394
413
|
managed hook entries and helper/state files; unrelated user hooks are preserved.
|
|
395
414
|
|
|
415
|
+
## Price and import past sessions
|
|
416
|
+
|
|
417
|
+
Both assistants keep local history that CodeTelemetry can import, but it does
|
|
418
|
+
not keep forever. Price it first; nothing is sent and no key is needed:
|
|
419
|
+
|
|
420
|
+
```bash
|
|
421
|
+
npx -y @codetelemetry/connect estimate # the whole retained year (364 days)
|
|
422
|
+
npx -y @codetelemetry/connect estimate --since 90d --source claude-code
|
|
423
|
+
npx -y @codetelemetry/connect estimate --json
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
The estimate reads `~/.claude/projects` (or `$CLAUDE_CONFIG_DIR/projects`) and
|
|
427
|
+
`~/.codex/sessions` (or `$CODEX_HOME/sessions`) with the importer's own parsers
|
|
428
|
+
and reports sessions and tokens per source and per UTC month, the oldest and
|
|
429
|
+
newest session, what uploading them would cost, and the monthly cost of one seat
|
|
430
|
+
at the last 30 days' pace. Tokens are input + output + cache read + cache
|
|
431
|
+
creation, each counted once. Its only request is the public price list
|
|
432
|
+
(`GET /api/pricing`); without it, the estimate prints the token totals and a
|
|
433
|
+
link to the pricing page. In a browser, `estimateFiles` from
|
|
434
|
+
`@codetelemetry/mcp/client/import/browser` estimates dropped files the same way;
|
|
435
|
+
`runEstimate` (`@codetelemetry/mcp/client/import/run`) is the Node entry point and
|
|
436
|
+
`@codetelemetry/mcp/client/import/estimate` holds the shared core
|
|
437
|
+
(`HistoryEstimate`, `EstimateBuilder`, `fetchPricing`, `priceEstimate`).
|
|
438
|
+
|
|
439
|
+
Some data is gone for good. Claude Code deletes a transcript at startup once it
|
|
440
|
+
is `cleanupPeriodDays` (settings.json, default 30) past its last activity, so a
|
|
441
|
+
session from before then can be imported only if its transcript is still on disk
|
|
442
|
+
(the sweep leaves subagent transcripts and can miss a file); the estimate names
|
|
443
|
+
the cutoff date. Codex keeps rollouts until they are removed. No
|
|
444
|
+
import recovers what only live telemetry carries: per-request latency and
|
|
445
|
+
retries, permission decisions, active time, lines-of-code / commit /
|
|
446
|
+
pull-request counters, model responses and tool output content.
|
|
447
|
+
|
|
448
|
+
Imported tokens are billed like live usage: they count toward the current
|
|
449
|
+
month, seat-included tokens first, then the per-million token price from
|
|
450
|
+
prepaid credit. When the import-status read reports the workspace's billing
|
|
451
|
+
state, `import --dry-run` shows the run's estimated cost and whether the credit
|
|
452
|
+
covers it, and a real import never starts a session whose cumulative cost
|
|
453
|
+
would exceed the included allowance plus credit: the rest are skipped as
|
|
454
|
+
`budget` (`stoppedBy: "budget"`) and the same command continues once credit is
|
|
455
|
+
added. Without billing state the import behaves as before.
|
|
456
|
+
|
|
457
|
+
Imported rows carry the identity attributes the live exporters send, on every
|
|
458
|
+
record: Claude Code's `organization.id`, `user.account_id`,
|
|
459
|
+
`user.account_uuid`, `user.email` and `user.id` from `~/.claude.json` (or
|
|
460
|
+
`$CLAUDE_CONFIG_DIR`), and Codex's `user.account_id` and `user.email` from the
|
|
461
|
+
ChatGPT sign-in in `~/.codex/auth.json` (or `$CODEX_HOME`; the id token is
|
|
462
|
+
decoded locally and never sent or logged). Output shows the identity masked.
|
|
463
|
+
`--email` overrides `user.email`; `--no-identity` (MCP: `identity: false`)
|
|
464
|
+
omits the rest. A browser upload stamps only the email it is given
|
|
465
|
+
(`importFiles(files, { identity: { email } })`).
|
|
466
|
+
|
|
396
467
|
## Estimating a plan
|
|
397
468
|
|
|
398
469
|
`estimate_plan` predicts the **coding-assistant token effort** of a plan from the
|
package/dist/src/client/cli.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { reportRolloutRepositories } from "./rolloutRepository.js";
|
|
1
2
|
import fs from "node:fs";
|
|
2
3
|
import { joinOrganization, workspaceProject } from "./join.js";
|
|
3
4
|
import { importWorkspaceHistory } from "./workspaceImport.js";
|
|
@@ -10,8 +11,10 @@ import { resolveEndpoints } from "./config.js";
|
|
|
10
11
|
import { CLIENTS, PI_EXTENSION_HINT } from "./clients.js";
|
|
11
12
|
import { ONBOARD_CLIENTS, isOnboardClient } from "./assistants.js";
|
|
12
13
|
import { looksLikeKey, mask } from "./keys.js";
|
|
13
|
-
import { runImport } from "./import/run.js";
|
|
14
|
+
import { runImport, runEstimate } from "./import/run.js";
|
|
14
15
|
import { parseContentFlag, parseWhen, resolveImportContent, resolveImportKey } from "./import/options.js";
|
|
16
|
+
import { resolveImportIdentity } from "./import/identity.js";
|
|
17
|
+
import { ESTIMATE_DEFAULT_DAYS, IMPORT_NEVER_RECOVERS, claudeRetentionCutoffMs, fetchPricing, priceEstimate, } from "./import/estimate.js";
|
|
15
18
|
import { requestDeviceCode, pollForKey } from "./deviceClient.js";
|
|
16
19
|
import { sendTestEvent } from "./otlp.js";
|
|
17
20
|
import { confirmLanded, verifyScope } from "./connectivity.js";
|
|
@@ -46,6 +49,9 @@ function parse(argv) {
|
|
|
46
49
|
const HELP = `codetelemetry-connect — wire Claude Code, OpenAI Codex or pi into CodeTelemetry
|
|
47
50
|
|
|
48
51
|
Usage:
|
|
52
|
+
codetelemetry-connect repository-metadata <rollout files> [--send]
|
|
53
|
+
Preview GitHub origins and parent IDs. --send uses CODETELEMETRY_INGEST_KEY.
|
|
54
|
+
codetelemetry-connect repository-metadata --state <Codex state database> <thread IDs> [--send]
|
|
49
55
|
codetelemetry-connect join --organization-id ID --client claude|codex [--project PATH]
|
|
50
56
|
Connect this project; resume the same command after interruption.
|
|
51
57
|
codetelemetry-connect import --workspace NAME --preview
|
|
@@ -68,6 +74,9 @@ Usage:
|
|
|
68
74
|
process health (see below)
|
|
69
75
|
codetelemetry-connect kiro status|collect|enable|disable|uninstall
|
|
70
76
|
Manage the background V3 transcript collector
|
|
77
|
+
codetelemetry-connect estimate [opts] Price past Claude Code / Codex
|
|
78
|
+
sessions before importing them:
|
|
79
|
+
no key, nothing sent (see below)
|
|
71
80
|
codetelemetry-connect import [opts] Backfill past Claude Code / Codex
|
|
72
81
|
sessions from local history files
|
|
73
82
|
(see below)
|
|
@@ -123,6 +132,18 @@ host-metrics options:
|
|
|
123
132
|
--interfaces Keep per-interface network breakdown (off by default)
|
|
124
133
|
--mounts Keep per-mount filesystem breakdown (off by default)
|
|
125
134
|
|
|
135
|
+
estimate options:
|
|
136
|
+
Reads the same local history as import, counts sessions and tokens per
|
|
137
|
+
source, month and day, and prices them with the public price list
|
|
138
|
+
(GET /api/pricing, the only request it makes). Claude Code deletes local
|
|
139
|
+
transcripts cleanupPeriodDays (default 30) after their last activity; the
|
|
140
|
+
estimate prints the cutoff before which a session survives only if it was
|
|
141
|
+
captured live or its transcript is still on disk.
|
|
142
|
+
--source claude-code|codex|all Which history to read (default: all)
|
|
143
|
+
--since <Nd|date> Window start (default: 364d, the whole retained year)
|
|
144
|
+
--api-base <url> Where the price list is read (default: https://codetelemetry.com)
|
|
145
|
+
--json Emit the estimate (and pricing) as JSON
|
|
146
|
+
|
|
126
147
|
import options:
|
|
127
148
|
Reads ~/.claude/projects/**/*.jsonl (Claude Code) and ~/.codex/sessions/**
|
|
128
149
|
(Codex) locally and sends them as telemetry through the normal ingest, tagged
|
|
@@ -130,6 +151,10 @@ import options:
|
|
|
130
151
|
imported, are skipped; an interrupted import resumes on the next run.
|
|
131
152
|
Imported history has tokens, prompts and tool results, but no per-request
|
|
132
153
|
latency, retries, permission decisions or active time.
|
|
154
|
+
Imported tokens are billed like live usage: they count toward this month's
|
|
155
|
+
included seat tokens first, then 5¢ per million from prepaid credit. When the
|
|
156
|
+
server reports billing state, an import starts no session the credit cannot
|
|
157
|
+
cover (--dry-run reports whether the whole window is affordable).
|
|
133
158
|
--dry-run Parse, check and summarize; send nothing
|
|
134
159
|
--source claude-code|codex|all Which history to read (default: all; --client
|
|
135
160
|
claude|codex narrows it too). pi is refused: it keeps
|
|
@@ -138,7 +163,13 @@ import options:
|
|
|
138
163
|
telemetry is kept 365 days by event time)
|
|
139
164
|
--until <Nd|date> Window end (default: now)
|
|
140
165
|
--project <path> Only sessions whose working directory is under <path>
|
|
141
|
-
--email <addr> Stamp user.email on imported rows
|
|
166
|
+
--email <addr> Stamp user.email on imported rows (overrides the
|
|
167
|
+
signed-in account's email)
|
|
168
|
+
--no-identity Do not stamp the signed-in account's identity (by
|
|
169
|
+
default rows carry what live exporters send: Claude
|
|
170
|
+
organization.id, user.account_id, user.account_uuid,
|
|
171
|
+
user.email, user.id from ~/.claude.json; Codex
|
|
172
|
+
user.account_id, user.email from ~/.codex/auth.json)
|
|
142
173
|
--content none|live|all|prompts,tools
|
|
143
174
|
Text to include (default: live — exactly what your
|
|
144
175
|
live exporters send: Claude OTEL_LOG_USER_PROMPTS /
|
|
@@ -238,8 +269,9 @@ const ONBOARDING_FLAGS = new Set([
|
|
|
238
269
|
const IMPORT_FLAGS = new Set([
|
|
239
270
|
"json", "help", "h", "api-base", "endpoint", "codex", "settings",
|
|
240
271
|
"dry-run", "source", "since", "until", "project", "email", "content", "max-sessions", "rate",
|
|
241
|
-
"time-limit", "key-env", "codex-config", "client",
|
|
272
|
+
"time-limit", "key-env", "codex-config", "client", "identity",
|
|
242
273
|
]);
|
|
274
|
+
const ESTIMATE_FLAGS = new Set(["json", "help", "h", "source", "since", "api-base"]);
|
|
243
275
|
function unknownFlag(flags, allowed) {
|
|
244
276
|
for (const key of Object.keys(flags))
|
|
245
277
|
if (!allowed.has(key))
|
|
@@ -264,7 +296,121 @@ const SKIP_LABELS = {
|
|
|
264
296
|
unreadable: "unreadable",
|
|
265
297
|
changed_during_run: "changed while importing",
|
|
266
298
|
deferred: "deferred (session cap / time limit)",
|
|
299
|
+
budget: "would exceed the prepaid credit (add credit, then re-run)",
|
|
300
|
+
time_limit: "not read before the time limit",
|
|
267
301
|
};
|
|
302
|
+
const fmtInt = (n) => Math.round(n).toLocaleString("en-US");
|
|
303
|
+
const fmtUsd = (n) => (n > 0 && n < 0.01 ? "less than $0.01" : `$${n.toFixed(2)}`);
|
|
304
|
+
const perMillionLabel = (usd) => usd < 1 ? `${Math.round(usd * 100 * 1000) / 1000}¢` : `$${usd.toFixed(2)}`;
|
|
305
|
+
const dateOf = (ms) => new Date(ms).toISOString().slice(0, 10);
|
|
306
|
+
const sourceLabel = (s) => (s === "claude-code" ? "Claude Code" : "Codex");
|
|
307
|
+
function identityLine(identity) {
|
|
308
|
+
if (!identity)
|
|
309
|
+
return null;
|
|
310
|
+
const parts = Object.entries(identity).map(([source, attrs]) => `${sourceLabel(source)} ${attrs["user.email"] ?? "(no email)"}` +
|
|
311
|
+
(Object.keys(attrs).filter((k) => k !== "user.email").length ? ` + ${Object.keys(attrs).filter((k) => k !== "user.email").join(", ")}` : ""));
|
|
312
|
+
return parts.length ? `Identity on imported rows: ${parts.join("; ")} (--no-identity to omit)` : null;
|
|
313
|
+
}
|
|
314
|
+
function billingLines(result) {
|
|
315
|
+
const b = result.billing;
|
|
316
|
+
if (!b)
|
|
317
|
+
return [];
|
|
318
|
+
if (!b.importsBilled)
|
|
319
|
+
return [`Billing: imported tokens are not billed for this workspace (${fmtInt(b.estimatedTokens)} tokens).`];
|
|
320
|
+
if (b.unlimited)
|
|
321
|
+
return [`Billing: ${fmtInt(b.estimatedTokens)} tokens; this workspace's token allowance is unlimited, so the import costs nothing.`];
|
|
322
|
+
return [
|
|
323
|
+
`Billing: ${fmtInt(b.estimatedTokens)} tokens ${result.dryRun ? "would cost" : "cost"} about ${fmtUsd(b.estimatedCostUsd)} at ` +
|
|
324
|
+
`${perMillionLabel(b.tokenPriceUsdPerMillion)} per million, after ${fmtInt(b.includedTokensRemaining)} included seat tokens left this month.`,
|
|
325
|
+
` prepaid credit ${fmtUsd(Math.max(0, b.creditUsd))}: ` +
|
|
326
|
+
(b.affordable ? "affordable" : result.dryRun
|
|
327
|
+
? "NOT affordable; a real import stops before the first session the credit cannot cover"
|
|
328
|
+
: "not enough for every session; the rest were skipped (add credit, then re-run)"),
|
|
329
|
+
];
|
|
330
|
+
}
|
|
331
|
+
async function runEstimateCommand(flags, fetchImpl) {
|
|
332
|
+
const rogue = unknownFlag(flags, ESTIMATE_FLAGS);
|
|
333
|
+
if (rogue) {
|
|
334
|
+
out(`Unknown option --${rogue} for estimate.`);
|
|
335
|
+
return 1;
|
|
336
|
+
}
|
|
337
|
+
const source = str(flags, "source") ?? "all";
|
|
338
|
+
if (source !== "all" && source !== "claude-code" && source !== "codex") {
|
|
339
|
+
out("--source must be claude-code, codex or all.");
|
|
340
|
+
return 1;
|
|
341
|
+
}
|
|
342
|
+
const now = Date.now();
|
|
343
|
+
let sinceMs;
|
|
344
|
+
if (hasFlag(flags, "since")) {
|
|
345
|
+
const raw = str(flags, "since");
|
|
346
|
+
const parsed = raw === undefined ? null : parseWhen(raw, now);
|
|
347
|
+
if (parsed === null) {
|
|
348
|
+
out("--since takes a number of days or hours (30d, 90d, 364d) or an ISO date (2026-09-01).");
|
|
349
|
+
return 1;
|
|
350
|
+
}
|
|
351
|
+
sinceMs = parsed;
|
|
352
|
+
}
|
|
353
|
+
const json = flags.json !== undefined && flags.json !== false;
|
|
354
|
+
const estimate = await runEstimate({ source, sinceMs, nowMs: now });
|
|
355
|
+
const apiBase = resolveEndpoints({ apiBase: str(flags, "api-base") }).apiBase;
|
|
356
|
+
const pricing = await fetchPricing(apiBase, fetchImpl);
|
|
357
|
+
const cost = pricing ? priceEstimate(estimate, pricing) : null;
|
|
358
|
+
if (json) {
|
|
359
|
+
out(JSON.stringify({ ...estimate, pricing, cost }, null, 2));
|
|
360
|
+
return 0;
|
|
361
|
+
}
|
|
362
|
+
for (const line of estimateLines(estimate, { pricing, cost, apiBase, now, since: str(flags, "since") }))
|
|
363
|
+
out(line);
|
|
364
|
+
return 0;
|
|
365
|
+
}
|
|
366
|
+
function estimateLines(e, o) {
|
|
367
|
+
const lines = [];
|
|
368
|
+
lines.push("Estimate from local history: nothing was sent and no key was used.");
|
|
369
|
+
lines.push(`Window ${e.window.sinceIso.slice(0, 10)} → ${e.window.untilIso.slice(0, 16).replace("T", " ")} UTC`);
|
|
370
|
+
lines.push("");
|
|
371
|
+
for (const s of e.sources) {
|
|
372
|
+
const tokens = s.tokens.input + s.tokens.output + s.tokens.cacheRead + s.tokens.cacheCreation;
|
|
373
|
+
lines.push(`${sourceLabel(s.source)}: ${fmtInt(s.sessions)} session(s), ${fmtInt(tokens)} tokens (${fmtInt(s.filesFound)} session file(s) found)`);
|
|
374
|
+
for (const [reason, n] of Object.entries(s.skipped))
|
|
375
|
+
if (n)
|
|
376
|
+
lines.push(` skipped ${n}: ${SKIP_LABELS[reason] ?? reason}`);
|
|
377
|
+
}
|
|
378
|
+
if (e.months.length) {
|
|
379
|
+
lines.push("");
|
|
380
|
+
lines.push("Tokens by month (UTC):");
|
|
381
|
+
for (const m of e.months)
|
|
382
|
+
lines.push(` ${m.month} ${fmtInt(m.sessions).padStart(6)} session(s) ${fmtInt(m.tokens).padStart(16)} tokens`);
|
|
383
|
+
}
|
|
384
|
+
if (e.oldestEventMs !== null && e.newestEventMs !== null) {
|
|
385
|
+
lines.push(`Oldest session: ${dateOf(e.oldestEventMs)} · newest session: ${dateOf(e.newestEventMs)}`);
|
|
386
|
+
}
|
|
387
|
+
lines.push("");
|
|
388
|
+
if (o.pricing && o.cost) {
|
|
389
|
+
const rate = `${perMillionLabel(o.pricing.tokenPriceUsdPerMillion)} per million tokens`;
|
|
390
|
+
lines.push(o.cost.importsBilled
|
|
391
|
+
? `Uploading these sessions: about ${fmtUsd(o.cost.uploadCostUsd)} at ${rate} (included seat tokens apply first).`
|
|
392
|
+
: "Uploading these sessions: imported tokens are not billed.");
|
|
393
|
+
lines.push(`At this pace: about ${fmtUsd(o.cost.monthlyUsdOneSeat)}/month for one seat ` +
|
|
394
|
+
`(${fmtInt(e.trailing30dTokens)} tokens in the last 30 days; ${fmtInt(o.pricing.includedTokensPerSeat)} included per seat at ` +
|
|
395
|
+
`${fmtUsd(o.pricing.seatPriceUsdPerMonth)}/month, then ${rate}).`);
|
|
396
|
+
}
|
|
397
|
+
else {
|
|
398
|
+
lines.push(`${fmtInt(e.totals.tokens)} tokens in total (${fmtInt(e.trailing30dTokens)} in the last 30 days). ` +
|
|
399
|
+
`Prices could not be read; see ${o.apiBase}/estimate`);
|
|
400
|
+
}
|
|
401
|
+
if (e.claudeCleanupPeriodDays !== null) {
|
|
402
|
+
const n = e.claudeCleanupPeriodDays;
|
|
403
|
+
lines.push(`Gone for good: Claude Code deletes transcripts ${n} day(s) after their last activity (cleanupPeriodDays, default 30), ` +
|
|
404
|
+
`so a Claude Code session from before ${dateOf(claudeRetentionCutoffMs(o.now, n))} survives only if CodeTelemetry captured it live or its transcript is still on disk (those are counted above). ` +
|
|
405
|
+
"Codex keeps its rollouts until you remove them.");
|
|
406
|
+
}
|
|
407
|
+
lines.push(`An import never recovers ${IMPORT_NEVER_RECOVERS}; those exist only in live telemetry.`);
|
|
408
|
+
for (const w of e.warnings.slice(0, 10))
|
|
409
|
+
lines.push(`warning: ${w}`);
|
|
410
|
+
lines.push("");
|
|
411
|
+
lines.push(`Next: codetelemetry-connect import --dry-run --since ${o.since ?? `${ESTIMATE_DEFAULT_DAYS}d`}`);
|
|
412
|
+
return lines;
|
|
413
|
+
}
|
|
268
414
|
async function runImportCommand(positional, flags, endpoints, settingsOpts, client) {
|
|
269
415
|
const rogue = unknownFlag(flags, IMPORT_FLAGS);
|
|
270
416
|
if (rogue) {
|
|
@@ -345,6 +491,11 @@ async function runImportCommand(positional, flags, endpoints, settingsOpts, clie
|
|
|
345
491
|
out("--project and --email need a value.");
|
|
346
492
|
return 1;
|
|
347
493
|
}
|
|
494
|
+
if (hasFlag(flags, "identity") && flags.identity !== false) {
|
|
495
|
+
out("--no-identity takes no value.");
|
|
496
|
+
return 1;
|
|
497
|
+
}
|
|
498
|
+
const identity = resolveImportIdentity({ source, disabled: flags.identity === false });
|
|
348
499
|
const log = json.on ? undefined : out;
|
|
349
500
|
log?.(`${dry.on ? "Dry run: reading" : "Importing"} local history with ${mask(resolved.key)} (from ${resolved.from})…`);
|
|
350
501
|
const result = await runImport({
|
|
@@ -355,6 +506,7 @@ async function runImportCommand(positional, flags, endpoints, settingsOpts, clie
|
|
|
355
506
|
untilMs,
|
|
356
507
|
project,
|
|
357
508
|
email,
|
|
509
|
+
identity,
|
|
358
510
|
content: resolveImportContent(content, paths),
|
|
359
511
|
dryRun: dry.on,
|
|
360
512
|
maxSessions,
|
|
@@ -381,11 +533,24 @@ async function runImportCommand(positional, flags, endpoints, settingsOpts, clie
|
|
|
381
533
|
if (tok.input + tok.output + tok.cacheRead + tok.cacheCreation > 0) {
|
|
382
534
|
out(` tokens: ${tok.input} input, ${tok.output} output, ${tok.cacheRead} cache read, ${tok.cacheCreation} cache write`);
|
|
383
535
|
}
|
|
536
|
+
if (s.months.length) {
|
|
537
|
+
out(` by month: ${s.months.map((m) => `${m.month} ${m.sessions} session(s) ${fmtInt(m.tokens)} tokens`).join("; ")}`);
|
|
538
|
+
}
|
|
539
|
+
if (s.firstEventMs !== null && s.lastEventMs !== null)
|
|
540
|
+
out(` sessions from ${dateOf(s.firstEventMs)} to ${dateOf(s.lastEventMs)}`);
|
|
384
541
|
for (const [reason, n] of Object.entries(s.skipped)) {
|
|
385
542
|
if (n)
|
|
386
543
|
out(` skipped ${n}: ${SKIP_LABELS[reason] ?? reason}`);
|
|
387
544
|
}
|
|
388
545
|
}
|
|
546
|
+
const who = identityLine(result.identity);
|
|
547
|
+
if (who)
|
|
548
|
+
out(`\n${who}`);
|
|
549
|
+
const billing = billingLines(result);
|
|
550
|
+
if (billing.length)
|
|
551
|
+
out("");
|
|
552
|
+
for (const line of billing)
|
|
553
|
+
out(line);
|
|
389
554
|
if (result.remaining)
|
|
390
555
|
out(`\n${result.remaining} session(s) remain — re-run the same command to continue.`);
|
|
391
556
|
for (const c of result.cleanup)
|
|
@@ -424,6 +589,14 @@ export async function run(argv) {
|
|
|
424
589
|
out(HELP);
|
|
425
590
|
return 0;
|
|
426
591
|
}
|
|
592
|
+
if (cmd === "estimate")
|
|
593
|
+
return runEstimateCommand(flags);
|
|
594
|
+
if (cmd === "repository-metadata") {
|
|
595
|
+
if (unknownFlag(flags, new Set(["send", "state"])) || (flags.state !== undefined && typeof flags.state !== "string") || (flags.send !== undefined && typeof flags.send !== "boolean"))
|
|
596
|
+
throw new Error("Put --send after the selected files.");
|
|
597
|
+
out(JSON.stringify(await reportRolloutRepositories(_.slice(1), flags.send === true, str(flags, "state"))));
|
|
598
|
+
return 0;
|
|
599
|
+
}
|
|
427
600
|
if (cmd === "join") {
|
|
428
601
|
const rogue = unknownFlag(flags, new Set(["organization-id", "client", "project", "enrich", "reauthorize", "open", "json", "api-base"]));
|
|
429
602
|
if (rogue)
|
|
@@ -463,7 +636,7 @@ export async function run(argv) {
|
|
|
463
636
|
result.previewSessions.forEach((session, i) => out(`${i + 1}. ${session.source} ${session.sessionId} · ${new Date(session.endMs).toISOString()} · ${session.events} events`));
|
|
464
637
|
if (result.remaining)
|
|
465
638
|
out(`${result.remaining} additional sessions remain; narrow --since for another preview.`);
|
|
466
|
-
out(`Import selected numbers: npx -y @codetelemetry/connect@0.
|
|
639
|
+
out(`Import selected numbers: npx -y @codetelemetry/connect@0.4.0 import --workspace ${flags.workspace} --select 1,2 --confirm`);
|
|
467
640
|
}
|
|
468
641
|
else
|
|
469
642
|
out(`Imported ${result.totals.sessions} sessions; ${result.remaining} remain. ${result.errors.slice(0, 3).join(" ")}`);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ContentBySource, type ImportRunResult } from "./core.ts";
|
|
2
|
+
import { type HistoryEstimate } from "./estimate.ts";
|
|
2
3
|
import type { FetchLike } from "../otlp.ts";
|
|
3
4
|
export type UploadFile = {
|
|
4
5
|
name: string;
|
|
@@ -22,9 +23,16 @@ export type BrowserImportOptions = {
|
|
|
22
23
|
sinceMs?: number;
|
|
23
24
|
content?: Partial<ContentBySource>;
|
|
24
25
|
maxSessions?: number;
|
|
26
|
+
identity?: {
|
|
27
|
+
email?: string;
|
|
28
|
+
};
|
|
25
29
|
fetchImpl?: FetchLike;
|
|
26
30
|
nowMs?: number;
|
|
27
31
|
sleep?: (ms: number) => Promise<void>;
|
|
28
32
|
logger?: (msg: string) => void;
|
|
29
33
|
};
|
|
30
34
|
export declare function importFiles(files: UploadFile[], opts: BrowserImportOptions): Promise<ImportRunResult>;
|
|
35
|
+
export declare function estimateFiles(files: UploadFile[], opts?: {
|
|
36
|
+
nowMs?: number;
|
|
37
|
+
sinceMs?: number;
|
|
38
|
+
}): Promise<HistoryEstimate>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { NO_CONTENT } from "./model.js";
|
|
1
2
|
import { ClaudeSessionAccumulator } from "./sources/claudeCodeText.js";
|
|
2
3
|
import { CodexSessionAccumulator, codexSessionIdFromName } from "./sources/codexText.js";
|
|
3
4
|
import { ACTIVE_GRACE_MS, bump, contentOrDefault, emptySummary, importPrepared, memoryLedger, prepareSession, resolveWindow, } from "./core.js";
|
|
5
|
+
import { EstimateBuilder, estimateWindow } from "./estimate.js";
|
|
4
6
|
export const MAX_UPLOAD_FILE_BYTES = 128 * 1024 * 1024;
|
|
5
7
|
export const MAX_UPLOAD_TOTAL_BYTES = 512 * 1024 * 1024;
|
|
6
8
|
export const MAX_UPLOAD_FILES = 2_000;
|
|
@@ -51,87 +53,101 @@ async function parseGroup(g, keep) {
|
|
|
51
53
|
const mtime = Math.max(...g.files.map((f) => f.lastModified));
|
|
52
54
|
return acc.finish({ files: g.files.map((f) => f.name), fileSig: `${bytes}:${mtime}:${g.files.length}`, fallbackSessionId: g.sessionId });
|
|
53
55
|
}
|
|
54
|
-
|
|
55
|
-
const key = opts.key.trim();
|
|
56
|
-
if (!looksLikeBrowserKey(key))
|
|
57
|
-
throw new Error("not a CodeTelemetry ingest key (expected cot_…)");
|
|
58
|
-
const now = opts.nowMs ?? Date.now();
|
|
59
|
-
const content = contentOrDefault(opts.content);
|
|
60
|
-
const warnings = [];
|
|
61
|
-
const window = resolveWindow(now, opts.sinceMs);
|
|
62
|
-
if (window.warning)
|
|
63
|
-
warnings.push(window.warning);
|
|
64
|
-
const summaries = new Map([
|
|
65
|
-
["claude-code", emptySummary("claude-code")],
|
|
66
|
-
["codex", emptySummary("codex")],
|
|
67
|
-
]);
|
|
56
|
+
async function visitUploads(files, o, visit) {
|
|
68
57
|
const groups = new Map();
|
|
69
58
|
let total = 0;
|
|
70
59
|
for (const f of files.slice(0, MAX_UPLOAD_FILES)) {
|
|
71
60
|
if (!f.name.endsWith(".jsonl")) {
|
|
72
|
-
warnings.push(`${f.name}: not a .jsonl session file; skipped`);
|
|
61
|
+
o.warnings.push(`${f.name}: not a .jsonl session file; skipped`);
|
|
73
62
|
continue;
|
|
74
63
|
}
|
|
75
64
|
if (f.size > MAX_UPLOAD_FILE_BYTES || total + f.size > MAX_UPLOAD_TOTAL_BYTES) {
|
|
76
|
-
warnings.push(`${f.name}: too large to
|
|
65
|
+
o.warnings.push(`${f.name}: too large to read in the browser; use \`npx @codetelemetry/connect import\``);
|
|
77
66
|
continue;
|
|
78
67
|
}
|
|
79
68
|
total += f.size;
|
|
80
69
|
const head = await (f.slice ? f.slice(0, 256 * 1024).text() : f.text().then((t) => t.slice(0, 256 * 1024)));
|
|
81
70
|
const kind = classify(f.name, head);
|
|
82
71
|
if (!kind) {
|
|
83
|
-
warnings.push(`${f.name}: not a Claude Code transcript or Codex rollout; skipped`);
|
|
72
|
+
o.warnings.push(`${f.name}: not a Claude Code transcript or Codex rollout; skipped`);
|
|
84
73
|
continue;
|
|
85
74
|
}
|
|
86
75
|
const id = `${kind.source}:${kind.sessionId}`;
|
|
87
76
|
const g = groups.get(id) ?? { ...kind, files: [] };
|
|
88
77
|
g.files.push(f);
|
|
89
78
|
groups.set(id, g);
|
|
90
|
-
|
|
79
|
+
visit.found(kind.source);
|
|
91
80
|
}
|
|
92
81
|
if (files.length > MAX_UPLOAD_FILES)
|
|
93
|
-
warnings.push(`only the first ${MAX_UPLOAD_FILES} files were read`);
|
|
94
|
-
const prepareOpts = {
|
|
95
|
-
sinceMs: window.sinceMs,
|
|
96
|
-
untilMs: window.untilMs,
|
|
97
|
-
caseInsensitivePaths: false,
|
|
98
|
-
content,
|
|
99
|
-
sha256Hex: sha256HexWeb,
|
|
100
|
-
};
|
|
101
|
-
const prepared = [];
|
|
82
|
+
o.warnings.push(`only the first ${MAX_UPLOAD_FILES} files were read`);
|
|
102
83
|
for (const g of groups.values()) {
|
|
103
|
-
const s = summaries.get(g.source);
|
|
104
84
|
const mtime = Math.max(...g.files.map((f) => f.lastModified));
|
|
105
|
-
if (mtime <
|
|
106
|
-
|
|
85
|
+
if (mtime < o.sinceMs) {
|
|
86
|
+
visit.skip(g.source, "older");
|
|
107
87
|
continue;
|
|
108
88
|
}
|
|
109
|
-
if (mtime > now - ACTIVE_GRACE_MS) {
|
|
110
|
-
|
|
89
|
+
if (mtime > o.now - ACTIVE_GRACE_MS) {
|
|
90
|
+
visit.skip(g.source, "active");
|
|
111
91
|
continue;
|
|
112
92
|
}
|
|
113
|
-
const session = await parseGroup(g,
|
|
93
|
+
const session = await parseGroup(g, o.keep(g.source));
|
|
114
94
|
if (session === "too_many_events") {
|
|
115
|
-
|
|
95
|
+
visit.skip(g.source, "too_many_events");
|
|
116
96
|
continue;
|
|
117
97
|
}
|
|
118
98
|
if (!session) {
|
|
119
|
-
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
s.sessionsParsed++;
|
|
123
|
-
const reload = async () => {
|
|
124
|
-
const again = await parseGroup(g, content[g.source]);
|
|
125
|
-
return again === "too_many_events" ? null : again;
|
|
126
|
-
};
|
|
127
|
-
const p = await prepareSession(session, session.fileSig, reload, prepareOpts);
|
|
128
|
-
if (typeof p === "string") {
|
|
129
|
-
bump(s, p);
|
|
99
|
+
visit.skip(g.source, "empty");
|
|
130
100
|
continue;
|
|
131
101
|
}
|
|
132
|
-
|
|
133
|
-
prepared.push(p);
|
|
102
|
+
await visit.session(session, g);
|
|
134
103
|
}
|
|
104
|
+
}
|
|
105
|
+
export async function importFiles(files, opts) {
|
|
106
|
+
const key = opts.key.trim();
|
|
107
|
+
if (!looksLikeBrowserKey(key))
|
|
108
|
+
throw new Error("not a CodeTelemetry ingest key (expected cot_…)");
|
|
109
|
+
const now = opts.nowMs ?? Date.now();
|
|
110
|
+
const content = contentOrDefault(opts.content);
|
|
111
|
+
const warnings = [];
|
|
112
|
+
const window = resolveWindow(now, opts.sinceMs);
|
|
113
|
+
if (window.warning)
|
|
114
|
+
warnings.push(window.warning);
|
|
115
|
+
const summaries = new Map([
|
|
116
|
+
["claude-code", emptySummary("claude-code")],
|
|
117
|
+
["codex", emptySummary("codex")],
|
|
118
|
+
]);
|
|
119
|
+
const email = opts.identity?.email?.trim();
|
|
120
|
+
const identity = email ? { "claude-code": { "user.email": email }, codex: { "user.email": email } } : undefined;
|
|
121
|
+
const prepareOpts = {
|
|
122
|
+
sinceMs: window.sinceMs,
|
|
123
|
+
untilMs: window.untilMs,
|
|
124
|
+
caseInsensitivePaths: false,
|
|
125
|
+
content,
|
|
126
|
+
identity,
|
|
127
|
+
sha256Hex: sha256HexWeb,
|
|
128
|
+
};
|
|
129
|
+
const prepared = [];
|
|
130
|
+
await visitUploads(files, { now, sinceMs: window.sinceMs, keep: (source) => content[source], warnings }, {
|
|
131
|
+
found: (source) => {
|
|
132
|
+
summaries.get(source).filesFound++;
|
|
133
|
+
},
|
|
134
|
+
skip: (source, reason) => bump(summaries.get(source), reason),
|
|
135
|
+
session: async (session, g) => {
|
|
136
|
+
const s = summaries.get(g.source);
|
|
137
|
+
s.sessionsParsed++;
|
|
138
|
+
const reload = async () => {
|
|
139
|
+
const again = await parseGroup(g, content[g.source]);
|
|
140
|
+
return again === "too_many_events" ? null : again;
|
|
141
|
+
};
|
|
142
|
+
const p = await prepareSession(session, session.fileSig, reload, prepareOpts);
|
|
143
|
+
if (typeof p === "string") {
|
|
144
|
+
bump(s, p);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
s.candidates++;
|
|
148
|
+
prepared.push(p);
|
|
149
|
+
},
|
|
150
|
+
});
|
|
135
151
|
const keyHash = await sha256HexWeb(key);
|
|
136
152
|
return importPrepared(prepared, {
|
|
137
153
|
...prepareOpts,
|
|
@@ -155,3 +171,23 @@ export async function importFiles(files, opts) {
|
|
|
155
171
|
logger: opts.logger,
|
|
156
172
|
});
|
|
157
173
|
}
|
|
174
|
+
export async function estimateFiles(files, opts = {}) {
|
|
175
|
+
const now = opts.nowMs ?? Date.now();
|
|
176
|
+
const window = estimateWindow(now, opts.sinceMs);
|
|
177
|
+
const builder = new EstimateBuilder({ sinceMs: window.sinceMs, untilMs: window.untilMs, nowMs: now, sources: ["claude-code", "codex"] });
|
|
178
|
+
const warnings = [];
|
|
179
|
+
if (window.warning)
|
|
180
|
+
warnings.push(window.warning);
|
|
181
|
+
await visitUploads(files, { now, sinceMs: window.sinceMs, keep: () => NO_CONTENT, warnings }, {
|
|
182
|
+
found: (source) => builder.found(source),
|
|
183
|
+
skip: (source, reason) => builder.skip(source, reason),
|
|
184
|
+
session: async (session) => {
|
|
185
|
+
const outcome = builder.add(session);
|
|
186
|
+
if (outcome !== "added")
|
|
187
|
+
builder.skip(session.source, outcome);
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
for (const w of warnings)
|
|
191
|
+
builder.warn(w);
|
|
192
|
+
return builder.finish({ claudeCleanupPeriodDays: null });
|
|
193
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ContentPolicy, ImportLog, ImportMetric, ImportedSession } from "./model.ts";
|
|
1
|
+
import type { ContentPolicy, ImportIdentity, ImportLog, ImportMetric, ImportedSession } from "./model.ts";
|
|
2
2
|
export declare const CLAUDE_SERVICE = "claude-code";
|
|
3
3
|
export declare const CODEX_SERVICE = "codex-cli";
|
|
4
4
|
export declare const TOKEN_USAGE_METRIC = "claude_code.token.usage";
|
|
@@ -11,10 +11,10 @@ export type ConvertedSession = {
|
|
|
11
11
|
logs: ImportLog[];
|
|
12
12
|
metrics: ImportMetric[];
|
|
13
13
|
};
|
|
14
|
-
export declare function convertSession(session: ImportedSession, content: ContentPolicy): ConvertedSession;
|
|
14
|
+
export declare function convertSession(session: ImportedSession, content: ContentPolicy, identity?: ImportIdentity): ConvertedSession;
|
|
15
15
|
export declare function completionMarker(session: ImportedSession, plan: {
|
|
16
16
|
id: string;
|
|
17
17
|
logParts: number;
|
|
18
18
|
metricParts: number;
|
|
19
19
|
events: number;
|
|
20
|
-
}): ImportLog;
|
|
20
|
+
}, identity?: ImportIdentity): ImportLog;
|