@cultured_computer/sight 0.4.2 → 0.4.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 +6 -4
- package/dist/cli.js +5 -5
- package/dist/index.cjs +18 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +18 -3
- package/dist/index.js.map +1 -1
- package/package.json +6 -9
- package/schema/sight-record-v1.schema.json +520 -101
package/dist/index.d.cts
CHANGED
|
@@ -989,6 +989,14 @@ declare class IngestClient {
|
|
|
989
989
|
* the first shed per process warns on stderr, the rest debug-log.
|
|
990
990
|
*/
|
|
991
991
|
private guardedFetch;
|
|
992
|
+
/**
|
|
993
|
+
* Await all in-flight sends (bounded). Called by Probe.shutdown() so
|
|
994
|
+
* short-lived processes (serverless, CLI scripts) can actually exit after
|
|
995
|
+
* it — the documented "in-flight sends finish within 15s" only holds while
|
|
996
|
+
* the process lives. Polling is coarse on purpose: sends report through
|
|
997
|
+
* guardedFetch's counter, never awaited individually.
|
|
998
|
+
*/
|
|
999
|
+
drainInFlight(timeoutMs?: number): Promise<void>;
|
|
992
1000
|
constructor(opts: IngestClientOptions);
|
|
993
1001
|
/**
|
|
994
1002
|
* Send a turn to the ingest API. Fire-and-log: errors are logged but never
|
package/dist/index.d.ts
CHANGED
|
@@ -989,6 +989,14 @@ declare class IngestClient {
|
|
|
989
989
|
* the first shed per process warns on stderr, the rest debug-log.
|
|
990
990
|
*/
|
|
991
991
|
private guardedFetch;
|
|
992
|
+
/**
|
|
993
|
+
* Await all in-flight sends (bounded). Called by Probe.shutdown() so
|
|
994
|
+
* short-lived processes (serverless, CLI scripts) can actually exit after
|
|
995
|
+
* it — the documented "in-flight sends finish within 15s" only holds while
|
|
996
|
+
* the process lives. Polling is coarse on purpose: sends report through
|
|
997
|
+
* guardedFetch's counter, never awaited individually.
|
|
998
|
+
*/
|
|
999
|
+
drainInFlight(timeoutMs?: number): Promise<void>;
|
|
992
1000
|
constructor(opts: IngestClientOptions);
|
|
993
1001
|
/**
|
|
994
1002
|
* Send a turn to the ingest API. Fire-and-log: errors are logged but never
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { propagation, context, trace } from '@opentelemetry/api';
|
|
3
3
|
|
|
4
4
|
// src/client.ts
|
|
5
|
-
var DEFAULT_DASHBOARD_URL = "https://
|
|
5
|
+
var DEFAULT_DASHBOARD_URL = "https://sight.cultured.computer/dashboard";
|
|
6
6
|
var MAX_PENDING_RETRIES = 50;
|
|
7
7
|
var SEND_TIMEOUT_MS = 15e3;
|
|
8
8
|
var MAX_INFLIGHT = 64;
|
|
@@ -56,6 +56,19 @@ var IngestClient = class {
|
|
|
56
56
|
this.inFlight--;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Await all in-flight sends (bounded). Called by Probe.shutdown() so
|
|
61
|
+
* short-lived processes (serverless, CLI scripts) can actually exit after
|
|
62
|
+
* it — the documented "in-flight sends finish within 15s" only holds while
|
|
63
|
+
* the process lives. Polling is coarse on purpose: sends report through
|
|
64
|
+
* guardedFetch's counter, never awaited individually.
|
|
65
|
+
*/
|
|
66
|
+
async drainInFlight(timeoutMs = SEND_TIMEOUT_MS) {
|
|
67
|
+
const deadline = Date.now() + timeoutMs;
|
|
68
|
+
while (this.inFlight > 0 && Date.now() < deadline) {
|
|
69
|
+
await new Promise((r) => setTimeout(r, 50));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
59
72
|
constructor(opts) {
|
|
60
73
|
this.apiKey = opts.apiKey;
|
|
61
74
|
this.endpoint = opts.endpoint.replace(/\/$/, "");
|
|
@@ -281,7 +294,7 @@ var IngestClient = class {
|
|
|
281
294
|
if (!this.rateLimitAnnounced) {
|
|
282
295
|
this.rateLimitAnnounced = true;
|
|
283
296
|
console.error(
|
|
284
|
-
"Sight: ingest rate limit (429) \u2014 retrying once per Retry-After; sustained limiting drops captures. See https://
|
|
297
|
+
"Sight: ingest rate limit (429) \u2014 retrying once per Retry-After; sustained limiting drops captures. See https://sight.cultured.computer/docs/sdk-reference#rate-limits"
|
|
285
298
|
);
|
|
286
299
|
} else {
|
|
287
300
|
this.log("[sight] ingest rate limited (429), retrying once");
|
|
@@ -363,7 +376,7 @@ var ProbeConfigSchema = z.object({
|
|
|
363
376
|
* Self-hosted or staging dashboards override it the same way `endpoint`
|
|
364
377
|
* is overridden.
|
|
365
378
|
*/
|
|
366
|
-
dashboardUrl: z.string().url().default("https://
|
|
379
|
+
dashboardUrl: z.string().url().default("https://sight.cultured.computer/dashboard"),
|
|
367
380
|
/** Persona identification. Optional at init; can be set later via identifyPersona(). */
|
|
368
381
|
persona: PersonaConfigSchema.optional(),
|
|
369
382
|
/** Outcome hook. Optional at init; can be set later via wireOutcomeHook(). */
|
|
@@ -2060,8 +2073,10 @@ var Probe = class {
|
|
|
2060
2073
|
if (state === null) {
|
|
2061
2074
|
return;
|
|
2062
2075
|
}
|
|
2076
|
+
const client = state.client;
|
|
2063
2077
|
detachOtelState();
|
|
2064
2078
|
state = null;
|
|
2079
|
+
await client.drainInFlight();
|
|
2065
2080
|
}
|
|
2066
2081
|
// ── Internal helpers ─────────────────────────────────────────────────────
|
|
2067
2082
|
/** Package-internal: instrumentation adapters read this to build turns. */
|