@akilium/telemetry-collector 0.1.3 → 0.1.4
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 +2 -2
- package/bin/akilium-telemetry.mjs +4 -2
- package/lib/session-capture.mjs +6 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -43,10 +43,10 @@ The Collector retains local rotated archive files for seven days with up to 20 b
|
|
|
43
43
|
The SDK's action export queue is in memory: 128 reports, one-hour expiry, exponential retries capped at a 60-second delay by default. `lineage.status()` exposes queued, dropped, accepted, duplicate, rejected, and unavailable counts; `lineage.flush()` retries due reports. Process exit or queue overflow can lose SDK reports. The Codex OTel action pipeline uses the Collector's persistent file-backed queue and retries for up to one hour. `akilium-telemetry status` shows local service/archive state, while hosted receipt, normalization, and artifact linkage remain explicitly unknown until checked through their respective Akila health/read surfaces. `doctor` checks only local OTLP receipt and archive capture.
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
## Session capture (0.1.
|
|
46
|
+
## Session capture (0.1.4)
|
|
47
47
|
|
|
48
48
|
Session capture requires an active approved Codex completion source with protected conversation references. In **Connections → Codex telemetry → Session capture**, issue a separate session capture token. Existing usage/action tokens do not enable this capability. The source administrator's controls show enrollment validity, captured sessions/revisions and pending/failed processing.
|
|
49
49
|
|
|
50
|
-
Use the displayed hidden-prompt commands with `npx --yes @akilium/telemetry-collector@0.1.
|
|
50
|
+
Use the displayed hidden-prompt commands with `npx --yes @akilium/telemetry-collector@0.1.4 preview-sessions --endpoint https://YOUR_PROJECT.supabase.co/functions/v1/ai-session-evidence/enroll` and then `enroll-sessions` at that same endpoint. Both read the token from stdin; never put it in a command argument or URL. Preview reports exact retained sessions/completion revisions, missing-identity records and already captured revisions without changing any data. Add `--include-history` to enrollment only after reviewing that preview if you want retained exact history; default enrollment captures new completions.
|
|
51
51
|
|
|
52
52
|
Enrollment reuses the existing completion exporter and protected source-qualified canonical metadata. It adds no exporter, does not collect prompts/responses, and does not restart or overwrite the Collector. It stores only public enrollment metadata locally, not the session credential. Token rotation, revocation, expiry or lost source approval stops session capture; issue and enroll a replacement token to resume. `status` distinguishes local configuration from hosted validity; inspect Connections health, then refresh Sessions after processing. Missing protected identity remains unresolved, and a captured session may be unscored or have unavailable monetary cost.
|
|
@@ -326,11 +326,13 @@ async function enrollSessions(previewOnly = false) {
|
|
|
326
326
|
const completionEndpoint = lines.find(line => line.startsWith("AKILA_INGESTION_ENDPOINT="))?.slice("AKILA_INGESTION_ENDPOINT=".length);
|
|
327
327
|
if (!completionEndpoint || new URL(completionEndpoint).origin !== new URL(endpoint).origin) throw new Error("Session and completion endpoints must use the same project");
|
|
328
328
|
const token = readFileSync(0, "utf8").trim();
|
|
329
|
-
const
|
|
329
|
+
const completionToken = lines.find(line => line.startsWith("AKILA_CODEX_TOKEN="))?.slice("AKILA_CODEX_TOKEN=".length);
|
|
330
|
+
const preview = await configureSessionCapture({ endpoint, token, completionToken, action: "preview" });
|
|
330
331
|
console.log(`Retained history: ${preview.eligibleSessions} exact sessions / ${preview.eligibleRecords} completion revisions; ${preview.unresolvedRecords} unresolved; ${preview.capturedRecords} already captured.`);
|
|
332
|
+
if (preview.usageCredentialState !== "active") console.log(`Usage credential: ${preview.usageCredentialState}. Renew usage enrollment and restart/recreate the collector to resume new completions.`);
|
|
331
333
|
if (previewOnly) { console.log("Preview only; no capture settings or session data changed."); return; }
|
|
332
334
|
const includeHistory = args.includes("--include-history");
|
|
333
|
-
const result = await configureSessionCapture({ endpoint, token, action: "enroll", includeHistory });
|
|
335
|
+
const result = await configureSessionCapture({ endpoint, token, completionToken, action: "enroll", includeHistory });
|
|
334
336
|
manifest.akilaSessionCapture = { endpoint, sourceId: result.sourceId, expiresAt: result.expiresAt, includeHistory };
|
|
335
337
|
saveManifest(manifest);
|
|
336
338
|
console.log(`Session capture enrolled until ${result.expiresAt}. ${includeHistory ? "Exact retained history included." : "New completions only."}`);
|
package/lib/session-capture.mjs
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
/** No raw identifiers or tokens are persisted or returned by this client. */
|
|
2
|
-
export async function configureSessionCapture({ endpoint, token, action, includeHistory = false, request = fetch }) {
|
|
2
|
+
export async function configureSessionCapture({ endpoint, token, completionToken, action, includeHistory = false, request = fetch }) {
|
|
3
3
|
const url = new URL(endpoint);
|
|
4
4
|
if (url.protocol !== 'https:' || url.username || url.password || url.search || url.hash ||
|
|
5
5
|
!url.pathname.endsWith('/functions/v1/ai-session-evidence/enroll')) {
|
|
6
6
|
throw new Error('Session enrollment requires a verified HTTPS session receiver URL');
|
|
7
7
|
}
|
|
8
8
|
if (!/^[A-Za-z0-9_-]{32,128}$/.test(token)) throw new Error('Invalid session enrollment token on stdin');
|
|
9
|
+
if (!/^[A-Za-z0-9_-]{32,128}$/.test(completionToken ?? '')) throw new Error('Protected usage enrollment is required to match this laptop to its source');
|
|
9
10
|
if (!['preview', 'enroll'].includes(action) || typeof includeHistory !== 'boolean') throw new Error('Invalid capture options');
|
|
10
11
|
let response;
|
|
11
12
|
try {
|
|
12
13
|
response = await request(url, { method: 'POST', redirect: 'error',
|
|
13
14
|
headers: { authorization: `Bearer ${token}`, 'content-type': 'application/json' },
|
|
14
|
-
body: JSON.stringify({ action, includeHistory }), signal: AbortSignal.timeout(15_000) });
|
|
15
|
+
body: JSON.stringify({ action, includeHistory, completionToken }), signal: AbortSignal.timeout(15_000) });
|
|
15
16
|
} catch { throw new Error('Session receiver unavailable; existing usage capture is unchanged'); }
|
|
17
|
+
if (response.status === 403) throw new Error('Session token belongs to a different source than this laptop. Issue the session token from the same Codex source as its usage token');
|
|
16
18
|
if (!response.ok) throw new Error(`Session enrollment rejected (HTTP ${response.status}); check token expiry, capability and source approval`);
|
|
17
19
|
let value;
|
|
18
20
|
try { value = await response.json(); } catch { throw new Error('Invalid session enrollment response'); }
|
|
@@ -24,5 +26,6 @@ export async function configureSessionCapture({ endpoint, token, action, include
|
|
|
24
26
|
}
|
|
25
27
|
return { state: value.state, sourceId: value.sourceId, expiresAt: value.expiresAt,
|
|
26
28
|
eligibleRecords: value.eligibleRecords, eligibleSessions: value.eligibleSessions,
|
|
27
|
-
unresolvedRecords: value.unresolvedRecords, capturedRecords: value.capturedRecords
|
|
29
|
+
unresolvedRecords: value.unresolvedRecords, capturedRecords: value.capturedRecords,
|
|
30
|
+
usageCredentialState: ['active', 'expired', 'revoked'].includes(value.usageCredentialState) ? value.usageCredentialState : 'unknown' };
|
|
28
31
|
}
|