@codetelemetry/connect 0.1.1 → 0.1.3
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 +8 -24
- package/dist/agent.d.ts +699 -0
- package/dist/agent.js +435 -0
- package/dist/assistants.d.ts +4 -0
- package/dist/assistants.js +5 -0
- package/dist/bin.js +3 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +567 -0
- package/dist/clients.d.ts +34 -0
- package/dist/clients.js +74 -0
- package/dist/{src/codexConfig.d.ts → codexConfig.d.ts} +1 -0
- package/dist/{src/codexConfig.js → codexConfig.js} +5 -0
- package/dist/{src/config.d.ts → config.d.ts} +16 -0
- package/dist/{src/config.js → config.js} +16 -0
- package/dist/connectivity.d.ts +51 -0
- package/dist/connectivity.js +118 -0
- package/dist/{src/deviceClient.d.ts → deviceClient.d.ts} +9 -2
- package/dist/{src/deviceClient.js → deviceClient.js} +45 -13
- package/dist/graderSeed.d.ts +50 -0
- package/dist/graderSeed.js +289 -0
- package/dist/hostMetrics.d.ts +54 -0
- package/dist/hostMetrics.js +425 -0
- package/dist/import/browser.d.ts +30 -0
- package/dist/import/browser.js +157 -0
- package/dist/import/convert.d.ts +20 -0
- package/dist/import/convert.js +165 -0
- package/dist/import/core.d.ts +143 -0
- package/dist/import/core.js +441 -0
- package/dist/import/ledger.d.ts +52 -0
- package/dist/import/ledger.js +161 -0
- package/dist/import/model.d.ts +70 -0
- package/dist/import/model.js +42 -0
- package/dist/import/options.d.ts +24 -0
- package/dist/import/options.js +71 -0
- package/dist/import/otlpImport.d.ts +7 -0
- package/dist/import/otlpImport.js +81 -0
- package/dist/import/protocol.d.ts +35 -0
- package/dist/import/protocol.js +51 -0
- package/dist/import/run.d.ts +30 -0
- package/dist/import/run.js +127 -0
- package/dist/import/sources/claudeCodeText.d.ts +19 -0
- package/dist/import/sources/claudeCodeText.js +214 -0
- package/dist/import/sources/codexText.d.ts +20 -0
- package/dist/import/sources/codexText.js +319 -0
- package/dist/import/sources/files.d.ts +24 -0
- package/dist/import/sources/files.js +129 -0
- package/dist/import/transport.d.ts +76 -0
- package/dist/import/transport.js +141 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +19 -0
- package/dist/kiro/collector.d.ts +88 -0
- package/dist/kiro/collector.js +577 -0
- package/dist/kiro/command.d.ts +3 -0
- package/dist/kiro/command.js +109 -0
- package/dist/kiro/config.d.ts +39 -0
- package/dist/kiro/config.js +107 -0
- package/dist/kiro/records.d.ts +52 -0
- package/dist/kiro/records.js +206 -0
- package/dist/kiro/service.d.ts +21 -0
- package/dist/kiro/service.js +183 -0
- package/dist/kiro/state.d.ts +45 -0
- package/dist/kiro/state.js +205 -0
- package/dist/kiro/transport.d.ts +9 -0
- package/dist/kiro/transport.js +90 -0
- package/dist/{src/onboard.d.ts → onboard.d.ts} +8 -2
- package/dist/onboard.js +116 -0
- package/dist/piConfig.d.ts +29 -0
- package/dist/piConfig.js +112 -0
- package/dist/plan.d.ts +53 -0
- package/dist/plan.js +113 -0
- package/dist/{src/repositoryHook.d.ts → repositoryHook.d.ts} +0 -1
- package/dist/{src/repositoryHook.js → repositoryHook.js} +5 -38
- package/dist/{src/settings.d.ts → settings.d.ts} +4 -0
- package/dist/{src/settings.js → settings.js} +17 -0
- package/dist/yaml.d.ts +5 -0
- package/dist/yaml.js +72 -0
- package/package.json +27 -18
- package/dist/bin/connect.js +0 -6
- package/dist/src/cli.d.ts +0 -10
- package/dist/src/cli.js +0 -172
- package/dist/src/connectivity.d.ts +0 -27
- package/dist/src/connectivity.js +0 -54
- package/dist/src/index.d.ts +0 -8
- package/dist/src/index.js +0 -8
- package/dist/src/onboard.js +0 -84
- /package/dist/{bin/connect.d.ts → bin.d.ts} +0 -0
- /package/dist/{src/keys.d.ts → keys.d.ts} +0 -0
- /package/dist/{src/keys.js → keys.js} +0 -0
- /package/dist/{src/otlp.d.ts → otlp.d.ts} +0 -0
- /package/dist/{src/otlp.js → otlp.js} +0 -0
package/package.json
CHANGED
|
@@ -1,25 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codetelemetry/connect",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "CodeTelemetry local client and onboarding CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/CodeTelemetry/codetelemetry-mcp.git",
|
|
10
|
+
"directory": "packages/connect"
|
|
11
|
+
},
|
|
12
|
+
"bin": {
|
|
13
|
+
"codetelemetry-connect": "./dist/bin.js"
|
|
14
|
+
},
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=22.6"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
14
30
|
"scripts": {
|
|
15
|
-
"
|
|
16
|
-
"build": "npm run clean && tsc -p tsconfig.build.json",
|
|
17
|
-
"test": "node --test test/*.test.ts",
|
|
18
|
-
"typecheck": "tsc --noEmit",
|
|
19
|
-
"audit:package": "node scripts/auditPackage.ts",
|
|
20
|
-
"test:packaged": "node scripts/packagedSmoke.ts",
|
|
31
|
+
"build": "node ../../scripts/buildConnect.ts",
|
|
21
32
|
"prepack": "npm run build"
|
|
22
|
-
}
|
|
23
|
-
"engines": { "node": ">=22.6" },
|
|
24
|
-
"devDependencies": { "@types/node": "^22.10.0", "typescript": "^5.9.3" }
|
|
33
|
+
}
|
|
25
34
|
}
|
package/dist/bin/connect.js
DELETED
package/dist/src/cli.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type Endpoints } from "./config.ts";
|
|
2
|
-
import { type FetchLike } from "./otlp.ts";
|
|
3
|
-
type RunDeps = {
|
|
4
|
-
endpointsOverride?: Partial<Endpoints>;
|
|
5
|
-
fetchImpl?: FetchLike;
|
|
6
|
-
openBrowser?: (url: string) => boolean;
|
|
7
|
-
env?: NodeJS.ProcessEnv;
|
|
8
|
-
};
|
|
9
|
-
export declare function run(argv: string[], deps?: RunDeps): Promise<number>;
|
|
10
|
-
export {};
|
package/dist/src/cli.js
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import { spawn } from "node:child_process";
|
|
3
|
-
import { onboard } from "./onboard.js";
|
|
4
|
-
import { resolveEndpoints, resolveSettingsPath } from "./config.js";
|
|
5
|
-
import { buildEnvBlock } from "./settings.js";
|
|
6
|
-
import { buildOtelSection, readCodexKey, resolveCodexConfigPath } from "./codexConfig.js";
|
|
7
|
-
import { looksLikeKey, mask } from "./keys.js";
|
|
8
|
-
import { requestDeviceCode, pollForKey } from "./deviceClient.js";
|
|
9
|
-
import { sendTestEvent } from "./otlp.js";
|
|
10
|
-
import { confirmLanded } from "./connectivity.js";
|
|
11
|
-
const VALUE_FLAGS = new Set(["scope", "key-env"]);
|
|
12
|
-
const BOOL_FLAGS = new Set(["codex", "enrich", "repository-observation", "open", "test", "verify", "json", "help", "h"]);
|
|
13
|
-
function parse(argv) {
|
|
14
|
-
const positionals = [];
|
|
15
|
-
const flags = {};
|
|
16
|
-
for (let i = 0; i < argv.length; i++) {
|
|
17
|
-
const arg = argv[i];
|
|
18
|
-
if (!arg.startsWith("--") && arg !== "-h") {
|
|
19
|
-
positionals.push(arg);
|
|
20
|
-
continue;
|
|
21
|
-
}
|
|
22
|
-
const body = arg === "-h" ? "h" : arg.slice(2);
|
|
23
|
-
const negative = body.startsWith("no-");
|
|
24
|
-
const name = negative ? body.slice(3) : body.split("=", 1)[0];
|
|
25
|
-
if (!BOOL_FLAGS.has(name) && !VALUE_FLAGS.has(name))
|
|
26
|
-
return `Unknown option --${name}.`;
|
|
27
|
-
if (VALUE_FLAGS.has(name)) {
|
|
28
|
-
if (negative)
|
|
29
|
-
return `--no-${name} is not valid.`;
|
|
30
|
-
const value = body.includes("=") ? body.slice(body.indexOf("=") + 1) : argv[++i];
|
|
31
|
-
if (!value || value.startsWith("--"))
|
|
32
|
-
return `--${name} needs a value.`;
|
|
33
|
-
flags[name] = value;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
if (body.includes("="))
|
|
37
|
-
return `--${name} takes no value.`;
|
|
38
|
-
flags[name] = !negative;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return { positionals, flags };
|
|
42
|
-
}
|
|
43
|
-
const HELP = `codetelemetry-connect — connect Claude Code or Codex to CodeTelemetry
|
|
44
|
-
|
|
45
|
-
Usage:
|
|
46
|
-
codetelemetry-connect login [options]
|
|
47
|
-
codetelemetry-connect <cot_key> [options]
|
|
48
|
-
codetelemetry-connect doctor [options]
|
|
49
|
-
codetelemetry-connect print-config [options]
|
|
50
|
-
codetelemetry-connect --key-env <NAME> [options]
|
|
51
|
-
|
|
52
|
-
Options:
|
|
53
|
-
--codex Configure Codex instead of Claude Code
|
|
54
|
-
--scope user|project Claude Code config scope (default: user)
|
|
55
|
-
--enrich Opt in to prompt/body/tool-content telemetry
|
|
56
|
-
--repository-observation Opt in to repository-path observation hooks
|
|
57
|
-
--key-env <NAME> Read an ingest key from an environment variable
|
|
58
|
-
--no-open Do not open the device-approval page
|
|
59
|
-
--no-test Do not send a test event
|
|
60
|
-
--no-verify Do not wait for the test event to land
|
|
61
|
-
--json Print a machine-readable result
|
|
62
|
-
-h, --help Show this help`;
|
|
63
|
-
const out = (line) => process.stdout.write(`${line}\n`);
|
|
64
|
-
function defaultOpenBrowser(url) {
|
|
65
|
-
const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
|
|
66
|
-
const args = process.platform === "win32" ? ["/c", "start", "", url] : [url];
|
|
67
|
-
try {
|
|
68
|
-
const child = spawn(command, args, { stdio: "ignore", detached: true });
|
|
69
|
-
child.on("error", () => { });
|
|
70
|
-
child.unref();
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
catch {
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
function readClaudeKey(settingsPath) {
|
|
78
|
-
if (!fs.existsSync(settingsPath))
|
|
79
|
-
return null;
|
|
80
|
-
try {
|
|
81
|
-
const value = JSON.parse(fs.readFileSync(settingsPath, "utf8"));
|
|
82
|
-
const headers = value?.env?.OTEL_EXPORTER_OTLP_HEADERS;
|
|
83
|
-
return typeof headers === "string" ? headers.match(/Bearer\s+(cot_[A-Za-z0-9_-]+)/)?.[1] ?? null : null;
|
|
84
|
-
}
|
|
85
|
-
catch {
|
|
86
|
-
return null;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
export async function run(argv, deps = {}) {
|
|
90
|
-
const parsed = parse(argv);
|
|
91
|
-
if (typeof parsed === "string") {
|
|
92
|
-
out(parsed);
|
|
93
|
-
return 1;
|
|
94
|
-
}
|
|
95
|
-
const { positionals, flags } = parsed;
|
|
96
|
-
const command = positionals[0];
|
|
97
|
-
if (positionals.length > 1) {
|
|
98
|
-
out(`Unexpected argument: ${positionals[1]}`);
|
|
99
|
-
return 1;
|
|
100
|
-
}
|
|
101
|
-
if (flags.help || flags.h || command === "help") {
|
|
102
|
-
out(HELP);
|
|
103
|
-
return 0;
|
|
104
|
-
}
|
|
105
|
-
if (!command && !flags["key-env"]) {
|
|
106
|
-
out(HELP);
|
|
107
|
-
return 1;
|
|
108
|
-
}
|
|
109
|
-
const scope = flags.scope ?? "user";
|
|
110
|
-
if (scope !== "user" && scope !== "project") {
|
|
111
|
-
out("--scope must be user or project.");
|
|
112
|
-
return 1;
|
|
113
|
-
}
|
|
114
|
-
const client = flags.codex ? "codex" : "claude";
|
|
115
|
-
const endpoints = resolveEndpoints(deps.endpointsOverride);
|
|
116
|
-
const configPath = client === "codex" ? resolveCodexConfigPath() : resolveSettingsPath({ scope: scope });
|
|
117
|
-
const common = {
|
|
118
|
-
client,
|
|
119
|
-
endpoints,
|
|
120
|
-
settings: { scope: scope, enrich: flags.enrich === true, repositoryObservation: flags["repository-observation"] === true },
|
|
121
|
-
sendTest: flags.test !== false,
|
|
122
|
-
verify: flags.verify !== false,
|
|
123
|
-
fetchImpl: deps.fetchImpl,
|
|
124
|
-
logger: flags.json ? undefined : out,
|
|
125
|
-
};
|
|
126
|
-
if (command === "print-config") {
|
|
127
|
-
out(client === "codex"
|
|
128
|
-
? buildOtelSection("cot_<YOUR_INGEST_KEY>", endpoints.ingestEndpoint, flags.enrich === true)
|
|
129
|
-
: JSON.stringify({ env: buildEnvBlock("<YOUR_INGEST_KEY>", endpoints.ingestEndpoint, flags.enrich === true) }, null, 2));
|
|
130
|
-
return 0;
|
|
131
|
-
}
|
|
132
|
-
if (command === "doctor") {
|
|
133
|
-
const key = client === "codex" ? readCodexKey(configPath) : readClaudeKey(configPath);
|
|
134
|
-
if (!key) {
|
|
135
|
-
out(`No active CodeTelemetry key found in ${configPath}.`);
|
|
136
|
-
return 1;
|
|
137
|
-
}
|
|
138
|
-
if (!flags.json)
|
|
139
|
-
out(`Re-testing ${mask(key)} → ${endpoints.ingestEndpoint}`);
|
|
140
|
-
const test = await sendTestEvent({ key, ingestEndpoint: endpoints.ingestEndpoint, fetchImpl: deps.fetchImpl });
|
|
141
|
-
if (!test.ok)
|
|
142
|
-
return 1;
|
|
143
|
-
const verified = await confirmLanded({ key, connectivityUrl: endpoints.connectivityUrl, probeId: test.probeId, fetchImpl: deps.fetchImpl });
|
|
144
|
-
if (flags.json)
|
|
145
|
-
out(JSON.stringify({ ok: verified.landed, probeId: test.probeId, elapsedMs: verified.elapsedMs }));
|
|
146
|
-
else
|
|
147
|
-
out(verified.landed ? `✓ Telemetry landed in ${verified.elapsedMs}ms` : "Probe not confirmed within timeout.");
|
|
148
|
-
return verified.landed ? 0 : 1;
|
|
149
|
-
}
|
|
150
|
-
if (command === "login") {
|
|
151
|
-
const code = await requestDeviceCode(endpoints, deps.fetchImpl);
|
|
152
|
-
const url = `${code.verificationUri}?code=${encodeURIComponent(code.userCode)}`;
|
|
153
|
-
out(`Approve CodeTelemetry access: ${url}`);
|
|
154
|
-
out(`Code: ${code.userCode}`);
|
|
155
|
-
if (flags.open !== false && !flags.json)
|
|
156
|
-
(deps.openBrowser ?? defaultOpenBrowser)(url);
|
|
157
|
-
const result = await onboard({ ...common, getKey: () => pollForKey(endpoints, code.deviceCode, { intervalMs: code.interval * 1000, timeoutMs: code.expiresIn * 1000, fetchImpl: deps.fetchImpl }) });
|
|
158
|
-
if (flags.json)
|
|
159
|
-
out(JSON.stringify(result, null, 2));
|
|
160
|
-
return result.ok ? 0 : 1;
|
|
161
|
-
}
|
|
162
|
-
const fromEnv = typeof flags["key-env"] === "string" ? (deps.env ?? process.env)[flags["key-env"]]?.trim() : undefined;
|
|
163
|
-
const key = fromEnv ?? command;
|
|
164
|
-
if (!looksLikeKey(key)) {
|
|
165
|
-
out(fromEnv === undefined && flags["key-env"] ? `No valid CodeTelemetry key found in $${String(flags["key-env"])}.` : HELP);
|
|
166
|
-
return 1;
|
|
167
|
-
}
|
|
168
|
-
const result = await onboard({ ...common, key });
|
|
169
|
-
if (flags.json)
|
|
170
|
-
out(JSON.stringify(result, null, 2));
|
|
171
|
-
return result.ok ? 0 : 1;
|
|
172
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { FetchLike } from "./otlp.ts";
|
|
2
|
-
export type CheckResult = {
|
|
3
|
-
seen: boolean;
|
|
4
|
-
httpStatus: number;
|
|
5
|
-
};
|
|
6
|
-
export declare function checkOnce(opts: {
|
|
7
|
-
key: string;
|
|
8
|
-
connectivityUrl: string;
|
|
9
|
-
probeId: string;
|
|
10
|
-
fetchImpl?: FetchLike;
|
|
11
|
-
timeoutMs?: number;
|
|
12
|
-
}): Promise<CheckResult>;
|
|
13
|
-
export type ConfirmResult = {
|
|
14
|
-
landed: boolean;
|
|
15
|
-
elapsedMs: number;
|
|
16
|
-
polls: number;
|
|
17
|
-
};
|
|
18
|
-
export declare function confirmLanded(opts: {
|
|
19
|
-
key: string;
|
|
20
|
-
connectivityUrl: string;
|
|
21
|
-
probeId: string;
|
|
22
|
-
fetchImpl?: FetchLike;
|
|
23
|
-
intervalMs?: number;
|
|
24
|
-
timeoutMs?: number;
|
|
25
|
-
onTick?: (poll: number) => void;
|
|
26
|
-
now?: () => number;
|
|
27
|
-
}): Promise<ConfirmResult>;
|
package/dist/src/connectivity.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { assertKey } from "./keys.js";
|
|
2
|
-
export async function checkOnce(opts) {
|
|
3
|
-
const key = assertKey(opts.key);
|
|
4
|
-
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
5
|
-
const ac = new AbortController();
|
|
6
|
-
const timer = setTimeout(() => ac.abort(), opts.timeoutMs ?? 8_000);
|
|
7
|
-
try {
|
|
8
|
-
const res = await fetchImpl(opts.connectivityUrl, {
|
|
9
|
-
method: "POST",
|
|
10
|
-
headers: { "content-type": "application/json", authorization: `Bearer ${key}` },
|
|
11
|
-
body: JSON.stringify({ probeId: opts.probeId }),
|
|
12
|
-
signal: ac.signal,
|
|
13
|
-
});
|
|
14
|
-
let seen = false;
|
|
15
|
-
try {
|
|
16
|
-
const json = (await res.json());
|
|
17
|
-
seen = !!json?.seen;
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
}
|
|
21
|
-
return { seen, httpStatus: res.status };
|
|
22
|
-
}
|
|
23
|
-
finally {
|
|
24
|
-
clearTimeout(timer);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
28
|
-
export async function confirmLanded(opts) {
|
|
29
|
-
const interval = opts.intervalMs ?? 2_000;
|
|
30
|
-
const timeout = opts.timeoutMs ?? 30_000;
|
|
31
|
-
const now = opts.now ?? (() => Date.now());
|
|
32
|
-
const start = now();
|
|
33
|
-
let polls = 0;
|
|
34
|
-
while (true) {
|
|
35
|
-
const remaining = timeout - (now() - start);
|
|
36
|
-
if (remaining <= 0)
|
|
37
|
-
return { landed: false, elapsedMs: now() - start, polls };
|
|
38
|
-
polls += 1;
|
|
39
|
-
opts.onTick?.(polls);
|
|
40
|
-
const { seen } = await checkOnce({
|
|
41
|
-
key: opts.key,
|
|
42
|
-
connectivityUrl: opts.connectivityUrl,
|
|
43
|
-
probeId: opts.probeId,
|
|
44
|
-
fetchImpl: opts.fetchImpl,
|
|
45
|
-
timeoutMs: Math.min(8_000, remaining),
|
|
46
|
-
});
|
|
47
|
-
const elapsedMs = now() - start;
|
|
48
|
-
if (seen)
|
|
49
|
-
return { landed: true, elapsedMs, polls };
|
|
50
|
-
if (elapsedMs + interval >= timeout)
|
|
51
|
-
return { landed: false, elapsedMs, polls };
|
|
52
|
-
await sleep(interval);
|
|
53
|
-
}
|
|
54
|
-
}
|
package/dist/src/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { onboard, type OnboardClient, type OnboardOptions, type OnboardResult } from "./onboard.ts";
|
|
2
|
-
export { resolveEndpoints, type Endpoints, type SettingsScope } from "./config.ts";
|
|
3
|
-
export { writeSettings, buildEnvBlock } from "./settings.ts";
|
|
4
|
-
export { writeCodexConfig, buildOtelSection, readCodexKey } from "./codexConfig.ts";
|
|
5
|
-
export { sendTestEvent } from "./otlp.ts";
|
|
6
|
-
export { confirmLanded } from "./connectivity.ts";
|
|
7
|
-
export { requestDeviceCode, pollForKey, pollOnce } from "./deviceClient.ts";
|
|
8
|
-
export { looksLikeKey, mask, keyHash } from "./keys.ts";
|
package/dist/src/index.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { onboard } from "./onboard.js";
|
|
2
|
-
export { resolveEndpoints } from "./config.js";
|
|
3
|
-
export { writeSettings, buildEnvBlock } from "./settings.js";
|
|
4
|
-
export { writeCodexConfig, buildOtelSection, readCodexKey } from "./codexConfig.js";
|
|
5
|
-
export { sendTestEvent } from "./otlp.js";
|
|
6
|
-
export { confirmLanded } from "./connectivity.js";
|
|
7
|
-
export { requestDeviceCode, pollForKey, pollOnce } from "./deviceClient.js";
|
|
8
|
-
export { looksLikeKey, mask, keyHash } from "./keys.js";
|
package/dist/src/onboard.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { resolveEndpoints, resolveSettingsPath } from "./config.js";
|
|
2
|
-
import { writeSettings } from "./settings.js";
|
|
3
|
-
import { resolveCodexConfigPath, writeCodexConfig } from "./codexConfig.js";
|
|
4
|
-
import { sendTestEvent } from "./otlp.js";
|
|
5
|
-
import { confirmLanded } from "./connectivity.js";
|
|
6
|
-
import { keyHash, mask, assertKey } from "./keys.js";
|
|
7
|
-
export async function onboard(opts) {
|
|
8
|
-
const log = opts.logger ?? (() => { });
|
|
9
|
-
const steps = [];
|
|
10
|
-
let apiKey;
|
|
11
|
-
let deviceIngest;
|
|
12
|
-
if (opts.key) {
|
|
13
|
-
apiKey = assertKey(opts.key);
|
|
14
|
-
steps.push({ name: "authenticate", ok: true, detail: "used provided ingest key" });
|
|
15
|
-
}
|
|
16
|
-
else if (opts.getKey) {
|
|
17
|
-
const got = await opts.getKey();
|
|
18
|
-
apiKey = assertKey(got.apiKey);
|
|
19
|
-
deviceIngest = got.ingestEndpoint;
|
|
20
|
-
steps.push({ name: "authenticate", ok: true, detail: "obtained ingest key via device flow" });
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
throw new Error("onboard requires either `key` or `getKey`");
|
|
24
|
-
}
|
|
25
|
-
const endpoints = resolveEndpoints({
|
|
26
|
-
apiBase: opts.endpoints?.apiBase,
|
|
27
|
-
ingestEndpoint: deviceIngest ?? opts.endpoints?.ingestEndpoint,
|
|
28
|
-
});
|
|
29
|
-
log(`Using ingest key ${mask(apiKey)} → ${endpoints.ingestEndpoint}`);
|
|
30
|
-
const settings = opts.client === "codex"
|
|
31
|
-
? writeCodexConfig({
|
|
32
|
-
key: apiKey,
|
|
33
|
-
ingestEndpoint: endpoints.ingestEndpoint,
|
|
34
|
-
configPath: resolveCodexConfigPath({ path: opts.settings?.path }),
|
|
35
|
-
enrich: opts.settings?.enrich,
|
|
36
|
-
repositoryObservation: opts.settings?.repositoryObservation,
|
|
37
|
-
backup: opts.settings?.backup,
|
|
38
|
-
})
|
|
39
|
-
: writeSettings({
|
|
40
|
-
key: apiKey,
|
|
41
|
-
ingestEndpoint: endpoints.ingestEndpoint,
|
|
42
|
-
settingsPath: resolveSettingsPath({ scope: opts.settings?.scope, path: opts.settings?.path }),
|
|
43
|
-
enrich: opts.settings?.enrich,
|
|
44
|
-
repositoryObservation: opts.settings?.repositoryObservation,
|
|
45
|
-
backup: opts.settings?.backup,
|
|
46
|
-
});
|
|
47
|
-
const varsNoun = opts.client === "codex" ? "OTEL keys" : "OTEL vars";
|
|
48
|
-
steps.push({
|
|
49
|
-
name: "write_config",
|
|
50
|
-
ok: true,
|
|
51
|
-
detail: `${settings.created ? "created" : "updated"} ${settings.path} (${settings.wrote.length} ${varsNoun})`,
|
|
52
|
-
});
|
|
53
|
-
log(`Wrote ${settings.wrote.length} ${varsNoun} to ${settings.path}${settings.backupPath ? ` (backup: ${settings.backupPath})` : ""}`);
|
|
54
|
-
let test = null;
|
|
55
|
-
if (opts.sendTest !== false) {
|
|
56
|
-
test = await sendTestEvent({ key: apiKey, ingestEndpoint: endpoints.ingestEndpoint, fetchImpl: opts.fetchImpl });
|
|
57
|
-
steps.push({
|
|
58
|
-
name: "send_test_event",
|
|
59
|
-
ok: test.ok,
|
|
60
|
-
detail: test.ok ? `probe accepted (HTTP ${test.httpStatus})` : `ingest returned HTTP ${test.httpStatus}`,
|
|
61
|
-
});
|
|
62
|
-
log(test.ok ? `Test event accepted (probe ${test.probeId})` : `Test event rejected (HTTP ${test.httpStatus})`);
|
|
63
|
-
}
|
|
64
|
-
let verify = null;
|
|
65
|
-
if (opts.verify !== false && test?.ok) {
|
|
66
|
-
log("Waiting for the probe to land…");
|
|
67
|
-
verify = await confirmLanded({
|
|
68
|
-
key: apiKey,
|
|
69
|
-
connectivityUrl: endpoints.connectivityUrl,
|
|
70
|
-
probeId: test.probeId,
|
|
71
|
-
fetchImpl: opts.fetchImpl,
|
|
72
|
-
timeoutMs: opts.verifyTimeoutMs,
|
|
73
|
-
intervalMs: opts.verifyIntervalMs,
|
|
74
|
-
});
|
|
75
|
-
steps.push({
|
|
76
|
-
name: "verify_telemetry",
|
|
77
|
-
ok: verify.landed,
|
|
78
|
-
detail: verify.landed ? `landed in ${verify.elapsedMs}ms` : `not seen within timeout (${verify.elapsedMs}ms)`,
|
|
79
|
-
});
|
|
80
|
-
log(verify.landed ? `✓ Telemetry landed in ${verify.elapsedMs}ms` : "Telemetry not confirmed yet — it can take a moment to appear");
|
|
81
|
-
}
|
|
82
|
-
const ok = steps.every((s) => s.ok);
|
|
83
|
-
return { ok, key: { masked: mask(apiKey), keyHash: keyHash(apiKey) }, settings, test, verify, steps };
|
|
84
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|