@codetelemetry/connect 0.1.1 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +8 -24
  3. package/dist/agent.d.ts +699 -0
  4. package/dist/agent.js +435 -0
  5. package/dist/assistants.d.ts +4 -0
  6. package/dist/assistants.js +5 -0
  7. package/dist/bin.js +3 -0
  8. package/dist/cli.d.ts +1 -0
  9. package/dist/cli.js +567 -0
  10. package/dist/clients.d.ts +34 -0
  11. package/dist/clients.js +74 -0
  12. package/dist/{src/codexConfig.d.ts → codexConfig.d.ts} +1 -0
  13. package/dist/{src/codexConfig.js → codexConfig.js} +5 -0
  14. package/dist/{src/config.d.ts → config.d.ts} +17 -0
  15. package/dist/{src/config.js → config.js} +17 -0
  16. package/dist/connectivity.d.ts +51 -0
  17. package/dist/connectivity.js +118 -0
  18. package/dist/{src/deviceClient.d.ts → deviceClient.d.ts} +9 -2
  19. package/dist/{src/deviceClient.js → deviceClient.js} +45 -13
  20. package/dist/graderArtifact.d.ts +14 -0
  21. package/dist/graderArtifact.js +94 -0
  22. package/dist/graderSeed.d.ts +50 -0
  23. package/dist/graderSeed.js +289 -0
  24. package/dist/hostMetrics.d.ts +54 -0
  25. package/dist/hostMetrics.js +425 -0
  26. package/dist/import/browser.d.ts +30 -0
  27. package/dist/import/browser.js +157 -0
  28. package/dist/import/convert.d.ts +20 -0
  29. package/dist/import/convert.js +165 -0
  30. package/dist/import/core.d.ts +143 -0
  31. package/dist/import/core.js +441 -0
  32. package/dist/import/ledger.d.ts +52 -0
  33. package/dist/import/ledger.js +161 -0
  34. package/dist/import/model.d.ts +70 -0
  35. package/dist/import/model.js +42 -0
  36. package/dist/import/options.d.ts +24 -0
  37. package/dist/import/options.js +71 -0
  38. package/dist/import/otlpImport.d.ts +7 -0
  39. package/dist/import/otlpImport.js +81 -0
  40. package/dist/import/protocol.d.ts +35 -0
  41. package/dist/import/protocol.js +51 -0
  42. package/dist/import/run.d.ts +30 -0
  43. package/dist/import/run.js +127 -0
  44. package/dist/import/sources/claudeCodeText.d.ts +19 -0
  45. package/dist/import/sources/claudeCodeText.js +214 -0
  46. package/dist/import/sources/codexText.d.ts +20 -0
  47. package/dist/import/sources/codexText.js +319 -0
  48. package/dist/import/sources/files.d.ts +24 -0
  49. package/dist/import/sources/files.js +129 -0
  50. package/dist/import/transport.d.ts +76 -0
  51. package/dist/import/transport.js +141 -0
  52. package/dist/index.d.ts +19 -0
  53. package/dist/index.js +19 -0
  54. package/dist/kiro/collector.d.ts +88 -0
  55. package/dist/kiro/collector.js +577 -0
  56. package/dist/kiro/command.d.ts +3 -0
  57. package/dist/kiro/command.js +109 -0
  58. package/dist/kiro/config.d.ts +39 -0
  59. package/dist/kiro/config.js +107 -0
  60. package/dist/kiro/records.d.ts +52 -0
  61. package/dist/kiro/records.js +206 -0
  62. package/dist/kiro/service.d.ts +21 -0
  63. package/dist/kiro/service.js +183 -0
  64. package/dist/kiro/state.d.ts +45 -0
  65. package/dist/kiro/state.js +205 -0
  66. package/dist/kiro/transport.d.ts +9 -0
  67. package/dist/kiro/transport.js +90 -0
  68. package/dist/{src/onboard.d.ts → onboard.d.ts} +8 -2
  69. package/dist/onboard.js +116 -0
  70. package/dist/piConfig.d.ts +29 -0
  71. package/dist/piConfig.js +112 -0
  72. package/dist/plan.d.ts +53 -0
  73. package/dist/plan.js +113 -0
  74. package/dist/{src/repositoryHook.d.ts → repositoryHook.d.ts} +0 -1
  75. package/dist/{src/repositoryHook.js → repositoryHook.js} +5 -38
  76. package/dist/{src/settings.d.ts → settings.d.ts} +4 -0
  77. package/dist/{src/settings.js → settings.js} +17 -0
  78. package/dist/yaml.d.ts +5 -0
  79. package/dist/yaml.js +72 -0
  80. package/package.json +27 -18
  81. package/dist/bin/connect.js +0 -6
  82. package/dist/src/cli.d.ts +0 -10
  83. package/dist/src/cli.js +0 -172
  84. package/dist/src/connectivity.d.ts +0 -27
  85. package/dist/src/connectivity.js +0 -54
  86. package/dist/src/index.d.ts +0 -8
  87. package/dist/src/index.js +0 -8
  88. package/dist/src/onboard.js +0 -84
  89. /package/dist/{bin/connect.d.ts → bin.d.ts} +0 -0
  90. /package/dist/{src/keys.d.ts → keys.d.ts} +0 -0
  91. /package/dist/{src/keys.js → keys.js} +0 -0
  92. /package/dist/{src/otlp.d.ts → otlp.d.ts} +0 -0
  93. /package/dist/{src/otlp.js → otlp.js} +0 -0
@@ -0,0 +1,129 @@
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+ import readline from "node:readline";
5
+ import { ClaudeSessionAccumulator } from "./claudeCodeText.js";
6
+ import { CodexSessionAccumulator, codexSessionIdFromName } from "./codexText.js";
7
+ export const MAX_SESSION_FILE_BYTES = 512 * 1024 * 1024;
8
+ export const MAX_SUBAGENT_FILES = 2_000;
9
+ export function defaultClaudeProjectsDir(home) {
10
+ return path.join(home ?? os.homedir(), ".claude", "projects");
11
+ }
12
+ export function defaultCodexSessionsDir(home, env = process.env) {
13
+ if (!home && env.CODEX_HOME)
14
+ return path.join(env.CODEX_HOME, "sessions");
15
+ return path.join(home ?? os.homedir(), ".codex", "sessions");
16
+ }
17
+ const statOrNull = (p) => {
18
+ try {
19
+ return fs.statSync(p);
20
+ }
21
+ catch {
22
+ return null;
23
+ }
24
+ };
25
+ const readDir = (dir) => {
26
+ try {
27
+ return fs.readdirSync(dir, { withFileTypes: true });
28
+ }
29
+ catch {
30
+ return [];
31
+ }
32
+ };
33
+ function describe(source, file, extraFiles) {
34
+ const main = statOrNull(file);
35
+ if (!main)
36
+ return null;
37
+ let bytes = main.size;
38
+ let mtimeMs = Math.floor(main.mtimeMs);
39
+ const kept = [];
40
+ for (const f of extraFiles) {
41
+ const s = statOrNull(f);
42
+ if (!s)
43
+ continue;
44
+ kept.push(f);
45
+ bytes += s.size;
46
+ mtimeMs = Math.max(mtimeMs, Math.floor(s.mtimeMs));
47
+ }
48
+ return { source, file, extraFiles: kept, mtimeMs, bytes, fileSig: `${bytes}:${mtimeMs}:${kept.length}` };
49
+ }
50
+ export function scanClaudeSessions(projectsDir) {
51
+ const out = [];
52
+ for (const project of readDir(projectsDir)) {
53
+ if (!project.isDirectory())
54
+ continue;
55
+ const dir = path.join(projectsDir, project.name);
56
+ for (const entry of readDir(dir)) {
57
+ if (!entry.isFile() || !entry.name.endsWith(".jsonl"))
58
+ continue;
59
+ const sessionDir = path.join(dir, entry.name.slice(0, -".jsonl".length), "subagents");
60
+ const extras = readDir(sessionDir)
61
+ .filter((e) => e.isFile() && e.name.endsWith(".jsonl"))
62
+ .map((e) => path.join(sessionDir, e.name))
63
+ .sort()
64
+ .slice(0, MAX_SUBAGENT_FILES);
65
+ const c = describe("claude-code", path.join(dir, entry.name), extras);
66
+ if (c)
67
+ out.push(c);
68
+ }
69
+ }
70
+ return out.sort((a, b) => a.file.localeCompare(b.file));
71
+ }
72
+ export function scanCodexSessions(sessionsDir) {
73
+ const out = [];
74
+ const walk = (dir, depth) => {
75
+ if (depth > 4)
76
+ return;
77
+ for (const e of readDir(dir)) {
78
+ const full = path.join(dir, e.name);
79
+ if (e.isDirectory())
80
+ walk(full, depth + 1);
81
+ else if (e.isFile() && e.name.startsWith("rollout-") && e.name.endsWith(".jsonl")) {
82
+ const c = describe("codex", full, []);
83
+ if (c)
84
+ out.push(c);
85
+ }
86
+ }
87
+ };
88
+ walk(sessionsDir, 0);
89
+ return out.sort((a, b) => a.file.localeCompare(b.file));
90
+ }
91
+ async function feedLines(file, onLine) {
92
+ const stream = fs.createReadStream(file, { encoding: "utf8" });
93
+ const rl = readline.createInterface({ input: stream, crlfDelay: Infinity });
94
+ try {
95
+ for await (const line of rl)
96
+ onLine(line);
97
+ }
98
+ finally {
99
+ rl.close();
100
+ stream.destroy();
101
+ }
102
+ }
103
+ export async function parseCandidate(c, keep) {
104
+ if (c.bytes > MAX_SESSION_FILE_BYTES) {
105
+ return { ok: false, reason: "too_large", detail: `${c.bytes} bytes exceeds the ${MAX_SESSION_FILE_BYTES}-byte session bound` };
106
+ }
107
+ const acc = c.source === "claude-code" ? new ClaudeSessionAccumulator({ keep }) : new CodexSessionAccumulator({ keep });
108
+ try {
109
+ for (const f of [c.file, ...c.extraFiles]) {
110
+ await feedLines(f, (line) => acc.line(line));
111
+ if (acc.overflowed)
112
+ break;
113
+ }
114
+ }
115
+ catch (err) {
116
+ return { ok: false, reason: "unreadable", detail: err instanceof Error ? err.message : String(err) };
117
+ }
118
+ if (acc.overflowed)
119
+ return { ok: false, reason: "too_many_events", detail: "session exceeds the per-session event bound" };
120
+ const base = path.basename(c.file, ".jsonl");
121
+ return {
122
+ ok: true,
123
+ session: acc.finish({
124
+ files: [c.file, ...c.extraFiles],
125
+ fileSig: c.fileSig,
126
+ fallbackSessionId: c.source === "codex" ? codexSessionIdFromName(c.file) : base,
127
+ }),
128
+ };
129
+ }
@@ -0,0 +1,76 @@
1
+ import type { FetchLike } from "../otlp.ts";
2
+ export type PostOutcome = {
3
+ kind: "ok";
4
+ } | {
5
+ kind: "auth";
6
+ status: number;
7
+ } | {
8
+ kind: "budget";
9
+ topup: string | null;
10
+ } | {
11
+ kind: "rejected";
12
+ status: number;
13
+ message: string;
14
+ } | {
15
+ kind: "busy";
16
+ detail: string;
17
+ } | {
18
+ kind: "uncertain";
19
+ detail: string;
20
+ };
21
+ export type Pacer = {
22
+ wait(): Promise<void>;
23
+ };
24
+ export declare function makePacer(perMinute: number, sleep: (ms: number) => Promise<void>, now?: () => number): Pacer;
25
+ export declare const sleepMs: (ms: number) => Promise<void>;
26
+ export type PostOptions = {
27
+ url: string;
28
+ key: string;
29
+ body: unknown;
30
+ fetchImpl: FetchLike;
31
+ pacer: Pacer;
32
+ sleep: (ms: number) => Promise<void>;
33
+ retryAmbiguous: boolean;
34
+ timeoutMs?: number;
35
+ maxAttempts?: number;
36
+ };
37
+ export declare function postOtlp(opts: PostOptions): Promise<PostOutcome>;
38
+ export type StatusRequestSession = {
39
+ sessionId: string;
40
+ startMs: number;
41
+ endMs: number;
42
+ probePlan?: string;
43
+ };
44
+ export type StatusResponse = {
45
+ sessions: Array<{
46
+ sessionId: string;
47
+ live: boolean;
48
+ plans: Array<{
49
+ plan: string;
50
+ complete: boolean;
51
+ logParts: string[];
52
+ metricParts?: string[];
53
+ lastArrivalMs: number;
54
+ }>;
55
+ }>;
56
+ settleMs: number;
57
+ nowMs: number;
58
+ };
59
+ export type StatusOutcome = {
60
+ kind: "ok";
61
+ value: StatusResponse;
62
+ } | {
63
+ kind: "auth";
64
+ status: number;
65
+ } | {
66
+ kind: "unavailable";
67
+ detail: string;
68
+ };
69
+ export declare function fetchStatus(opts: {
70
+ url: string;
71
+ key: string;
72
+ sessions: StatusRequestSession[];
73
+ fetchImpl: FetchLike;
74
+ sleep: (ms: number) => Promise<void>;
75
+ timeoutMs?: number;
76
+ }): Promise<StatusOutcome>;
@@ -0,0 +1,141 @@
1
+ export function makePacer(perMinute, sleep, now = Date.now) {
2
+ const gap = Math.ceil(60_000 / Math.max(1, perMinute));
3
+ let next = 0;
4
+ return {
5
+ async wait() {
6
+ const t = now();
7
+ if (t < next)
8
+ await sleep(next - t);
9
+ next = Math.max(t, next) + gap;
10
+ },
11
+ };
12
+ }
13
+ export const sleepMs = (ms) => new Promise((r) => setTimeout(r, ms));
14
+ const PRE_FORWARD_503 = /capacity busy|receipt unavailable/i;
15
+ const BACKOFF_BASE_MS = 2_000;
16
+ const BACKOFF_MAX_MS = 60_000;
17
+ export async function postOtlp(opts) {
18
+ const payload = JSON.stringify(opts.body);
19
+ const maxAttempts = opts.maxAttempts ?? 6;
20
+ let lastDetail = "";
21
+ let lastWasDefinitive = false;
22
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
23
+ if (attempt > 1) {
24
+ await opts.sleep(Math.min(BACKOFF_BASE_MS * 2 ** (attempt - 2), BACKOFF_MAX_MS));
25
+ }
26
+ await opts.pacer.wait();
27
+ const ac = new AbortController();
28
+ const timer = setTimeout(() => ac.abort(), opts.timeoutMs ?? 45_000);
29
+ let res;
30
+ try {
31
+ res = await opts.fetchImpl(opts.url, {
32
+ method: "POST",
33
+ headers: { "content-type": "application/json", authorization: `Bearer ${opts.key}` },
34
+ body: payload,
35
+ signal: ac.signal,
36
+ });
37
+ }
38
+ catch (err) {
39
+ clearTimeout(timer);
40
+ lastDetail = `network error (${err instanceof Error ? err.name : "unknown"})`;
41
+ lastWasDefinitive = false;
42
+ if (!opts.retryAmbiguous)
43
+ return { kind: "uncertain", detail: lastDetail };
44
+ continue;
45
+ }
46
+ clearTimeout(timer);
47
+ const status = res.status;
48
+ let text = "";
49
+ try {
50
+ text = await res.text();
51
+ }
52
+ catch {
53
+ text = "";
54
+ }
55
+ if (status >= 200 && status < 300)
56
+ return { kind: "ok" };
57
+ if (status === 401 || status === 403)
58
+ return { kind: "auth", status };
59
+ if (status === 402) {
60
+ let topup = null;
61
+ try {
62
+ const parsed = JSON.parse(text);
63
+ topup = typeof parsed?.topup === "string" ? parsed.topup : null;
64
+ }
65
+ catch {
66
+ topup = null;
67
+ }
68
+ return { kind: "budget", topup };
69
+ }
70
+ const definitiveRetry = status === 429 || status === 408 || (status === 503 && PRE_FORWARD_503.test(text));
71
+ if (definitiveRetry) {
72
+ lastWasDefinitive = true;
73
+ lastDetail = `HTTP ${status}`;
74
+ continue;
75
+ }
76
+ if (status >= 500) {
77
+ lastDetail = `HTTP ${status}`;
78
+ lastWasDefinitive = false;
79
+ if (!opts.retryAmbiguous)
80
+ return { kind: "uncertain", detail: lastDetail };
81
+ continue;
82
+ }
83
+ return { kind: "rejected", status, message: text.slice(0, 200) };
84
+ }
85
+ if (lastWasDefinitive)
86
+ return { kind: "busy", detail: lastDetail };
87
+ return opts.retryAmbiguous ? { kind: "rejected", status: 0, message: lastDetail } : { kind: "uncertain", detail: lastDetail };
88
+ }
89
+ export async function fetchStatus(opts) {
90
+ let detail = "";
91
+ for (let attempt = 1; attempt <= 5; attempt++) {
92
+ if (attempt > 1)
93
+ await opts.sleep(Math.min(BACKOFF_BASE_MS * 2 ** (attempt - 2), BACKOFF_MAX_MS));
94
+ const ac = new AbortController();
95
+ const timer = setTimeout(() => ac.abort(), opts.timeoutMs ?? 30_000);
96
+ let res;
97
+ try {
98
+ res = await opts.fetchImpl(opts.url, {
99
+ method: "POST",
100
+ headers: { "content-type": "application/json", authorization: `Bearer ${opts.key}` },
101
+ body: JSON.stringify({ sessions: opts.sessions }),
102
+ signal: ac.signal,
103
+ });
104
+ }
105
+ catch (err) {
106
+ clearTimeout(timer);
107
+ detail = `network error (${err instanceof Error ? err.name : "unknown"})`;
108
+ continue;
109
+ }
110
+ finally {
111
+ clearTimeout(timer);
112
+ }
113
+ if (res.status === 401 || res.status === 403)
114
+ return { kind: "auth", status: res.status };
115
+ if (res.status === 429 || res.status >= 500) {
116
+ detail = `HTTP ${res.status}`;
117
+ if (res.status === 429 || res.status === 503 || res.status === 502)
118
+ continue;
119
+ return { kind: "unavailable", detail };
120
+ }
121
+ if (res.status !== 200)
122
+ return { kind: "unavailable", detail: `HTTP ${res.status}` };
123
+ try {
124
+ const json = (await res.json());
125
+ if (!Array.isArray(json.sessions))
126
+ return { kind: "unavailable", detail: "malformed status response" };
127
+ return {
128
+ kind: "ok",
129
+ value: {
130
+ sessions: json.sessions,
131
+ settleMs: typeof json.settleMs === "number" ? json.settleMs : 300_000,
132
+ nowMs: typeof json.nowMs === "number" ? json.nowMs : Date.now(),
133
+ },
134
+ };
135
+ }
136
+ catch {
137
+ return { kind: "unavailable", detail: "malformed status response" };
138
+ }
139
+ }
140
+ return { kind: "unavailable", detail };
141
+ }
@@ -0,0 +1,19 @@
1
+ export { looksLikeKey, assertKey, mask, keyHash, scrub } from "./keys.ts";
2
+ export { resolveEndpoints, resolveSettingsPath, type Endpoints, type SettingsScope, } from "./config.ts";
3
+ export { baseEnv, enrichEnv, buildEnvBlock, mergeSettings, writeSettings, readSettingsSummary, type EnvBlock, type WriteResult, type WriteOptions, } from "./settings.ts";
4
+ export { buildProbeLog, sendTestEvent, PROBE_ATTR, PROBE_EVENT, PROBE_SERVICE, type SendTestResult, type SendTestOptions, type FetchLike, } from "./otlp.ts";
5
+ export { checkOnce, confirmLanded, verifyScope, type CheckResult, type ConfirmResult, type ConnectivityState, type KeyScope, type ExpectedKeyScope, } from "./connectivity.ts";
6
+ export { getCostSignal, getSessionPerformance, normalizeSessionPerformanceService, findSimilarSessionErrors, searchCodingSessions, SESSION_SEARCH_REQUEST_TIMEOUT_MS, countReplyPhrases, type ReplyPhraseTrendsResult, estimateTaskSize, estimateLinearIssue, interpretSession, readSessionEvents, compareSessions, planNextSession, getHostHealth, readGitHubGate, configureGitHubGate, type GitHubGateResult, type HostState, type HostThresholds, type HostSignals, type HostHeadroom, type HostAdmission, type HostAgentdProcess, type HostHealth, type HostHealthReport, type HostHealthResult, type LinearIssueSource, type LinearConnectionChoice, type LinearIssueEstimateResult, type TaskSize, type TaskEffortEstimate, type LinearEstimateProjection, type LinearEstimateScale, type TaskEffortResult, type CostSignal, type CostSignalResult, type AgentReadPerformance, type SessionPerformanceReport, type SessionPerformanceResult, type SimilarSessionErrorsReport, type SimilarSessionErrorsResult, type SessionSearchHit, type SessionSearchLegacyReport, type SessionPrecedentReport, type SessionSearchReport, type SessionSearchResult, } from "./agent.ts";
7
+ export { normalizePlan, PLAN_PROVIDERS, MAX_PLAN_TEXT, MAX_PLAN_STEPS, type PlanInput, type PlanStepInput, type PlanProvider, type PlanSource, type PlanSourceStep, type NormalizedPlan, type NormalizePlanResult, } from "./plan.ts";
8
+ export { requestDeviceCode, pollForKey, pollOnce, type DeviceCodeResponse, type DeviceKey, type PollOnce, } from "./deviceClient.ts";
9
+ export { onboard, type OnboardOptions, type OnboardResult, type OnboardStep, type OnboardClient } from "./onboard.ts";
10
+ export { CLIENTS, PI_EXTENSION_HINT, readClaudeKey, resolveClient, type ClientDescriptor, type ClientSummary, } from "./clients.ts";
11
+ export { buildPiOtelBlock, mergePiSettings, piTracesEndpoint, readPiKey, readPiSummary, resolvePiConfigPath, writePiConfig, type PiWriteOptions, type PiWriteResult, } from "./piConfig.ts";
12
+ export { ONBOARD_CLIENTS, SESSION_FILTER_ASSISTANTS, isOnboardClient, } from "./assistants.ts";
13
+ export { buildHostMetricsConfig, renderHostMetricsConfig, writeHostMetricsConfig, hostMetricsOptionsFromFlags, defaultHostMetricsPaths, defaultInstanceId, HOST_METRIC_CONTRACT, REDACTED_RESOURCE_ATTRIBUTES, DEFAULT_PROCESS_NAMES, DEFAULT_KEY_ENV, DEFAULT_SERVICE_NAME, SERVICE_NAMESPACE, type HostMetricsOptions, type HostMetricsMode, type HostMetricsPaths, type HostMetricsWriteOptions, type HostMetricsWriteResult, } from "./hostMetrics.ts";
14
+ export { resolveCodexConfigPath, buildOtelSection, writeCodexConfig, readCodexKey, readCodexSummary, readCodexLogUserPrompt, type CodexWriteOptions, } from "./codexConfig.ts";
15
+ export { readClaudeContentFlags } from "./settings.ts";
16
+ export { runImport, RETENTION_DAYS, DEFAULT_SINCE_DAYS, type ImportRunOptions, type ImportRunResult, type ImportSourceSummary, type ContentBySource, } from "./import/run.ts";
17
+ export { resolveImportKey, resolveImportContent, parseContentFlag, parseWhen } from "./import/options.ts";
18
+ export { NO_CONTENT, ALL_CONTENT, type ContentPolicy, type ImportSource } from "./import/model.ts";
19
+ export { graderConfigRequest } from "./agent.ts";
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ export { looksLikeKey, assertKey, mask, keyHash, scrub } from "./keys.js";
2
+ export { resolveEndpoints, resolveSettingsPath, } from "./config.js";
3
+ export { baseEnv, enrichEnv, buildEnvBlock, mergeSettings, writeSettings, readSettingsSummary, } from "./settings.js";
4
+ export { buildProbeLog, sendTestEvent, PROBE_ATTR, PROBE_EVENT, PROBE_SERVICE, } from "./otlp.js";
5
+ export { checkOnce, confirmLanded, verifyScope, } from "./connectivity.js";
6
+ export { getCostSignal, getSessionPerformance, normalizeSessionPerformanceService, findSimilarSessionErrors, searchCodingSessions, SESSION_SEARCH_REQUEST_TIMEOUT_MS, countReplyPhrases, estimateTaskSize, estimateLinearIssue, interpretSession, readSessionEvents, compareSessions, planNextSession, getHostHealth, readGitHubGate, configureGitHubGate, } from "./agent.js";
7
+ export { normalizePlan, PLAN_PROVIDERS, MAX_PLAN_TEXT, MAX_PLAN_STEPS, } from "./plan.js";
8
+ export { requestDeviceCode, pollForKey, pollOnce, } from "./deviceClient.js";
9
+ export { onboard } from "./onboard.js";
10
+ export { CLIENTS, PI_EXTENSION_HINT, readClaudeKey, resolveClient, } from "./clients.js";
11
+ export { buildPiOtelBlock, mergePiSettings, piTracesEndpoint, readPiKey, readPiSummary, resolvePiConfigPath, writePiConfig, } from "./piConfig.js";
12
+ export { ONBOARD_CLIENTS, SESSION_FILTER_ASSISTANTS, isOnboardClient, } from "./assistants.js";
13
+ export { buildHostMetricsConfig, renderHostMetricsConfig, writeHostMetricsConfig, hostMetricsOptionsFromFlags, defaultHostMetricsPaths, defaultInstanceId, HOST_METRIC_CONTRACT, REDACTED_RESOURCE_ATTRIBUTES, DEFAULT_PROCESS_NAMES, DEFAULT_KEY_ENV, DEFAULT_SERVICE_NAME, SERVICE_NAMESPACE, } from "./hostMetrics.js";
14
+ export { resolveCodexConfigPath, buildOtelSection, writeCodexConfig, readCodexKey, readCodexSummary, readCodexLogUserPrompt, } from "./codexConfig.js";
15
+ export { readClaudeContentFlags } from "./settings.js";
16
+ export { runImport, RETENTION_DAYS, DEFAULT_SINCE_DAYS, } from "./import/run.js";
17
+ export { resolveImportKey, resolveImportContent, parseContentFlag, parseWhen } from "./import/options.js";
18
+ export { NO_CONTENT, ALL_CONTENT } from "./import/model.js";
19
+ export { graderConfigRequest } from "./agent.js";
@@ -0,0 +1,88 @@
1
+ import { type Dir } from "node:fs";
2
+ import { type ContentPolicy } from "../import/model.ts";
3
+ import type { KiroPost } from "./transport.ts";
4
+ export type KiroHealth = {
5
+ version: 2;
6
+ status: string;
7
+ trackedSessions: number;
8
+ parkedSessions: number;
9
+ skippingOversizeSessions: number;
10
+ cachedTailBytes: number;
11
+ cachedTailSessions: number;
12
+ carryEvictions: number;
13
+ discoveryBacklog: number;
14
+ backloggedSessions: number;
15
+ unsupportedSessions: number;
16
+ sourceConflicts: number;
17
+ sourceErrors: number;
18
+ ignoredRecords: number;
19
+ malformedRecords: number;
20
+ duplicateRecords: number;
21
+ evictedCalls: number;
22
+ missingCalls?: number;
23
+ unsupportedToolDetails: number;
24
+ discoveryOverflow: number;
25
+ oversizeRecords: number;
26
+ readBytes: number;
27
+ logsAcknowledged: number;
28
+ requests: number;
29
+ pending: boolean;
30
+ lastTickAt: number;
31
+ };
32
+ export type KiroCollectorOptions = {
33
+ sourceRoot: string;
34
+ stateDir: string;
35
+ destinationHash: string;
36
+ post: KiroPost;
37
+ policy?: ContentPolicy;
38
+ now?: () => number;
39
+ tickBudgetMs?: number;
40
+ bootstrap?: "start" | "end";
41
+ };
42
+ export declare class KiroDiscovery {
43
+ overflow: number;
44
+ root: Dir | null;
45
+ workspaces: Map<string, Dir>;
46
+ nextPassAt: number;
47
+ cursor: number;
48
+ scan(root: string, now: number, deadline: number, clock: () => number): Promise<{
49
+ relative: string;
50
+ id: string;
51
+ }[]>;
52
+ close(): Promise<void>;
53
+ }
54
+ export declare class KiroCollector {
55
+ private options;
56
+ private checkpoint;
57
+ private pending;
58
+ private release;
59
+ private discovery;
60
+ private carries;
61
+ private candidates;
62
+ private candidateCursor;
63
+ private capacityBlocked;
64
+ private stateBytesBlocked;
65
+ private running;
66
+ private lastPostAt;
67
+ private startedAt;
68
+ private health;
69
+ readonly recordCounters: import("./records.ts").KiroRecordCounters;
70
+ constructor(options: KiroCollectorOptions);
71
+ private policyHash;
72
+ private now;
73
+ private file;
74
+ private policy;
75
+ private fits;
76
+ private save;
77
+ open(): Promise<void>;
78
+ close(): Promise<void>;
79
+ snapshot(): KiroHealth;
80
+ private metadata;
81
+ private keepCarry;
82
+ private observe;
83
+ private rotateSessions;
84
+ private admitCandidates;
85
+ private flush;
86
+ tick(): Promise<KiroHealth>;
87
+ private finish;
88
+ }