@cultured_computer/sight 0.2.0 → 0.3.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 +20 -0
- package/dist/index.cjs +159 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +191 -4
- package/dist/index.d.ts +191 -4
- package/dist/index.js +159 -4
- package/dist/index.js.map +1 -1
- package/package.json +13 -5
package/dist/index.d.cts
CHANGED
|
@@ -58,6 +58,144 @@ declare const PropensitySchema: z.ZodObject<{
|
|
|
58
58
|
selectionMeta?: Record<string, unknown> | undefined;
|
|
59
59
|
}>;
|
|
60
60
|
type PropensityInput = z.infer<typeof PropensitySchema>;
|
|
61
|
+
declare const EnvironmentEventInputSchema: z.ZodObject<{
|
|
62
|
+
/** Free-form channel label (e.g. a stimulus feed, a game state stream). Open vocabulary — NOT an enum. */
|
|
63
|
+
source_type: z.ZodString;
|
|
64
|
+
/** Free-form event name. Open vocabulary — NOT an enum. */
|
|
65
|
+
event: z.ZodString;
|
|
66
|
+
/** ISO timestamp of the event on the deployer's clock (see alignment). */
|
|
67
|
+
at: z.ZodString;
|
|
68
|
+
/** Optional detail payload (deployer-defined). */
|
|
69
|
+
meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
70
|
+
sessionExternalId: z.ZodString;
|
|
71
|
+
deploymentSlug: z.ZodString;
|
|
72
|
+
/**
|
|
73
|
+
* Optional reference to the causing turn. v1 resolves a turn index within
|
|
74
|
+
* the same session (string-encoded integer); any other value is stored
|
|
75
|
+
* verbatim on the event record without an outcome-corner link. The
|
|
76
|
+
* instrument records the reference only — no causal inference.
|
|
77
|
+
*/
|
|
78
|
+
causeProvenance: z.ZodOptional<z.ZodString>;
|
|
79
|
+
}, "strip", z.ZodTypeAny, {
|
|
80
|
+
at: string;
|
|
81
|
+
deploymentSlug: string;
|
|
82
|
+
sessionExternalId: string;
|
|
83
|
+
source_type: string;
|
|
84
|
+
event: string;
|
|
85
|
+
meta?: Record<string, unknown> | undefined;
|
|
86
|
+
causeProvenance?: string | undefined;
|
|
87
|
+
}, {
|
|
88
|
+
at: string;
|
|
89
|
+
deploymentSlug: string;
|
|
90
|
+
sessionExternalId: string;
|
|
91
|
+
source_type: string;
|
|
92
|
+
event: string;
|
|
93
|
+
meta?: Record<string, unknown> | undefined;
|
|
94
|
+
causeProvenance?: string | undefined;
|
|
95
|
+
}>;
|
|
96
|
+
type EnvironmentEventInput = z.infer<typeof EnvironmentEventInputSchema>;
|
|
97
|
+
/**
|
|
98
|
+
* Clock contract for a batch: whose clock produced the events' `at`, the
|
|
99
|
+
* deployer's bound on skew against the instrument's clock, and the version
|
|
100
|
+
* of the attach rule the deployer aligned to. Free-form strings — the
|
|
101
|
+
* instrument stores the claim, it does not verify clocks.
|
|
102
|
+
*/
|
|
103
|
+
declare const AlignmentProvenanceSchema: z.ZodObject<{
|
|
104
|
+
clock_source: z.ZodString;
|
|
105
|
+
skew_bound_ms: z.ZodOptional<z.ZodNumber>;
|
|
106
|
+
rule_version: z.ZodString;
|
|
107
|
+
}, "strip", z.ZodTypeAny, {
|
|
108
|
+
clock_source: string;
|
|
109
|
+
rule_version: string;
|
|
110
|
+
skew_bound_ms?: number | undefined;
|
|
111
|
+
}, {
|
|
112
|
+
clock_source: string;
|
|
113
|
+
rule_version: string;
|
|
114
|
+
skew_bound_ms?: number | undefined;
|
|
115
|
+
}>;
|
|
116
|
+
type AlignmentProvenance = z.infer<typeof AlignmentProvenanceSchema>;
|
|
117
|
+
declare const EnvironmentEventsBatchSchema: z.ZodObject<{
|
|
118
|
+
/** Events are self-addressed: a batch may span sessions/deployments. */
|
|
119
|
+
events: z.ZodArray<z.ZodObject<{
|
|
120
|
+
/** Free-form channel label (e.g. a stimulus feed, a game state stream). Open vocabulary — NOT an enum. */
|
|
121
|
+
source_type: z.ZodString;
|
|
122
|
+
/** Free-form event name. Open vocabulary — NOT an enum. */
|
|
123
|
+
event: z.ZodString;
|
|
124
|
+
/** ISO timestamp of the event on the deployer's clock (see alignment). */
|
|
125
|
+
at: z.ZodString;
|
|
126
|
+
/** Optional detail payload (deployer-defined). */
|
|
127
|
+
meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
128
|
+
sessionExternalId: z.ZodString;
|
|
129
|
+
deploymentSlug: z.ZodString;
|
|
130
|
+
/**
|
|
131
|
+
* Optional reference to the causing turn. v1 resolves a turn index within
|
|
132
|
+
* the same session (string-encoded integer); any other value is stored
|
|
133
|
+
* verbatim on the event record without an outcome-corner link. The
|
|
134
|
+
* instrument records the reference only — no causal inference.
|
|
135
|
+
*/
|
|
136
|
+
causeProvenance: z.ZodOptional<z.ZodString>;
|
|
137
|
+
}, "strip", z.ZodTypeAny, {
|
|
138
|
+
at: string;
|
|
139
|
+
deploymentSlug: string;
|
|
140
|
+
sessionExternalId: string;
|
|
141
|
+
source_type: string;
|
|
142
|
+
event: string;
|
|
143
|
+
meta?: Record<string, unknown> | undefined;
|
|
144
|
+
causeProvenance?: string | undefined;
|
|
145
|
+
}, {
|
|
146
|
+
at: string;
|
|
147
|
+
deploymentSlug: string;
|
|
148
|
+
sessionExternalId: string;
|
|
149
|
+
source_type: string;
|
|
150
|
+
event: string;
|
|
151
|
+
meta?: Record<string, unknown> | undefined;
|
|
152
|
+
causeProvenance?: string | undefined;
|
|
153
|
+
}>, "many">;
|
|
154
|
+
alignment: z.ZodObject<{
|
|
155
|
+
clock_source: z.ZodString;
|
|
156
|
+
skew_bound_ms: z.ZodOptional<z.ZodNumber>;
|
|
157
|
+
rule_version: z.ZodString;
|
|
158
|
+
}, "strip", z.ZodTypeAny, {
|
|
159
|
+
clock_source: string;
|
|
160
|
+
rule_version: string;
|
|
161
|
+
skew_bound_ms?: number | undefined;
|
|
162
|
+
}, {
|
|
163
|
+
clock_source: string;
|
|
164
|
+
rule_version: string;
|
|
165
|
+
skew_bound_ms?: number | undefined;
|
|
166
|
+
}>;
|
|
167
|
+
}, "strip", z.ZodTypeAny, {
|
|
168
|
+
events: {
|
|
169
|
+
at: string;
|
|
170
|
+
deploymentSlug: string;
|
|
171
|
+
sessionExternalId: string;
|
|
172
|
+
source_type: string;
|
|
173
|
+
event: string;
|
|
174
|
+
meta?: Record<string, unknown> | undefined;
|
|
175
|
+
causeProvenance?: string | undefined;
|
|
176
|
+
}[];
|
|
177
|
+
alignment: {
|
|
178
|
+
clock_source: string;
|
|
179
|
+
rule_version: string;
|
|
180
|
+
skew_bound_ms?: number | undefined;
|
|
181
|
+
};
|
|
182
|
+
}, {
|
|
183
|
+
events: {
|
|
184
|
+
at: string;
|
|
185
|
+
deploymentSlug: string;
|
|
186
|
+
sessionExternalId: string;
|
|
187
|
+
source_type: string;
|
|
188
|
+
event: string;
|
|
189
|
+
meta?: Record<string, unknown> | undefined;
|
|
190
|
+
causeProvenance?: string | undefined;
|
|
191
|
+
}[];
|
|
192
|
+
alignment: {
|
|
193
|
+
clock_source: string;
|
|
194
|
+
rule_version: string;
|
|
195
|
+
skew_bound_ms?: number | undefined;
|
|
196
|
+
};
|
|
197
|
+
}>;
|
|
198
|
+
type EnvironmentEventsBatch = z.infer<typeof EnvironmentEventsBatchSchema>;
|
|
61
199
|
|
|
62
200
|
/**
|
|
63
201
|
* Sight SDK (@cultured-computer/sight) shared types.
|
|
@@ -563,7 +701,8 @@ type OutcomeEventEmit = z.infer<typeof OutcomeEventEmitSchema>;
|
|
|
563
701
|
* HTTP client for the Probe ingest API.
|
|
564
702
|
*
|
|
565
703
|
* Sends captured turns to POST /v1/turns with a Bearer token. Async, fire-and-log:
|
|
566
|
-
* SDK never blocks the customer's LLM path on ingest.
|
|
704
|
+
* SDK never blocks the customer's LLM path on ingest. Rate-limited sends (429)
|
|
705
|
+
* are retried exactly once after Retry-After; sustained limiting drops captures.
|
|
567
706
|
*/
|
|
568
707
|
|
|
569
708
|
type IngestClientOptions = {
|
|
@@ -588,6 +727,15 @@ declare class IngestClient {
|
|
|
588
727
|
* arriving before any turn is not a captured session).
|
|
589
728
|
*/
|
|
590
729
|
private firstCaptureAnnounced;
|
|
730
|
+
/**
|
|
731
|
+
* Rate-limit (429) handling: the first 429 per process prints one stderr
|
|
732
|
+
* warning (not debug-gated, same channel and lifetime as the first-capture
|
|
733
|
+
* announce); subsequent 429s only debug-log. Each rate-limited request is
|
|
734
|
+
* retried exactly once after Retry-After; pendingRetries counts retries
|
|
735
|
+
* waiting on their timers so the cap can shed load.
|
|
736
|
+
*/
|
|
737
|
+
private rateLimitAnnounced;
|
|
738
|
+
private pendingRetries;
|
|
591
739
|
constructor(opts: IngestClientOptions);
|
|
592
740
|
/**
|
|
593
741
|
* Send a turn to the ingest API. Fire-and-log: errors are logged but never
|
|
@@ -609,6 +757,23 @@ declare class IngestClient {
|
|
|
609
757
|
* probe_outcome_events per Amendment I Method D.
|
|
610
758
|
*/
|
|
611
759
|
sendOutcomeEvent(deploymentSlug: string, event: OutcomeEventEmit): Promise<void>;
|
|
760
|
+
/**
|
|
761
|
+
* Send an environment-event batch to the ingest API. Fire-and-log, same as
|
|
762
|
+
* sendTurn. The envelope is generalized: the worker attaches each event to
|
|
763
|
+
* its session's record by time; meaning is per-deployment.
|
|
764
|
+
*/
|
|
765
|
+
sendEnvironmentEvents(batch: EnvironmentEventsBatch): Promise<void>;
|
|
766
|
+
/**
|
|
767
|
+
* Route a send response through the 429 retry policy. Non-429 responses
|
|
768
|
+
* pass through untouched. A 429 is re-sent exactly once after Retry-After
|
|
769
|
+
* seconds (default 1s when the header is missing or unparseable; clamped
|
|
770
|
+
* to [1, 60]s); the retry's response is returned as-is, so a second 429 is
|
|
771
|
+
* never retried again — callers log and drop it like any other failed
|
|
772
|
+
* send. Returns null when the retry was dropped at the pending-retry cap.
|
|
773
|
+
* The timer is unref'd (where supported) so a pending retry never holds
|
|
774
|
+
* the process open.
|
|
775
|
+
*/
|
|
776
|
+
private retryIfRateLimited;
|
|
612
777
|
private log;
|
|
613
778
|
}
|
|
614
779
|
|
|
@@ -691,8 +856,8 @@ declare function compileSignaturePhrases(phrases: SignaturePhrase[]): CompiledPh
|
|
|
691
856
|
*
|
|
692
857
|
* Probe.init({
|
|
693
858
|
* apiKey: process.env.PROBE_API_KEY!,
|
|
694
|
-
* deployment: '
|
|
695
|
-
* persona: { slug: '
|
|
859
|
+
* deployment: 'support-agent',
|
|
860
|
+
* persona: { slug: 'casey' },
|
|
696
861
|
* });
|
|
697
862
|
*
|
|
698
863
|
* // Autocapture is now on for any subsequent OpenAI / Anthropic / etc. call.
|
|
@@ -913,6 +1078,28 @@ declare class Probe {
|
|
|
913
1078
|
* signal the worker cannot infer.
|
|
914
1079
|
*/
|
|
915
1080
|
static emitOutcomeEvent(input: OutcomeEventEmit): Promise<void>;
|
|
1081
|
+
/**
|
|
1082
|
+
* Capture one environment event against a session (Arc D-rail). The
|
|
1083
|
+
* envelope is generalized: `source_type` and `event` are free strings whose
|
|
1084
|
+
* meaning is defined per deployment — the instrument stores the event and
|
|
1085
|
+
* attaches it to the session's record by time (the next turn's state
|
|
1086
|
+
* corner, plus the causing turn's outcome corner when `causeProvenance`
|
|
1087
|
+
* names a turn index), and never interprets it. Fire-and-log, like
|
|
1088
|
+
* captureTurn: errors are debug-logged, never thrown.
|
|
1089
|
+
*
|
|
1090
|
+
* Alignment defaults to the SDK's own clock claim; deployments with a
|
|
1091
|
+
* stricter clock contract (or batches) should call
|
|
1092
|
+
* captureEnvironmentEvents with explicit alignment provenance.
|
|
1093
|
+
*/
|
|
1094
|
+
static captureEnvironmentEvent(event: EnvironmentEventInput, alignment?: AlignmentProvenance): Promise<void>;
|
|
1095
|
+
/**
|
|
1096
|
+
* Capture a batch of environment events with explicit alignment provenance
|
|
1097
|
+
* (clock_source, skew_bound_ms, rule_version). Batches are capped at 100
|
|
1098
|
+
* events and may span sessions — every event is self-addressed. Same
|
|
1099
|
+
* generalized envelope and fire-and-log discipline as the single-event
|
|
1100
|
+
* capture above.
|
|
1101
|
+
*/
|
|
1102
|
+
static captureEnvironmentEvents(events: EnvironmentEventInput[], alignment: AlignmentProvenance): Promise<void>;
|
|
916
1103
|
/**
|
|
917
1104
|
* Flag a persona break for a session. Wire this to the customer's in-product
|
|
918
1105
|
* "that didn't sound like you" UX. Populates the `user_flagged_break`
|
|
@@ -941,4 +1128,4 @@ declare class Probe {
|
|
|
941
1128
|
private static shouldSample;
|
|
942
1129
|
}
|
|
943
1130
|
|
|
944
|
-
export { type CapturedTurn, type OutcomeEventEmit, type OutcomeHook, type OutcomeResult, type PersonaConfig, Probe, type ProbeConfig, type ProbeConfigInput, Probe as Sight, type CapturedTurn as SightCapturedTurn, type ProbeConfig as SightConfig, type ProbeConfigInput as SightConfigInput, type OutcomeEventEmit as SightOutcomeEventEmit, type OutcomeHook as SightOutcomeHook, type OutcomeResult as SightOutcomeResult, type PersonaConfig as SightPersonaConfig };
|
|
1131
|
+
export { type AlignmentProvenance, type CapturedTurn, type EnvironmentEventInput, type OutcomeEventEmit, type OutcomeHook, type OutcomeResult, type PersonaConfig, Probe, type ProbeConfig, type ProbeConfigInput, Probe as Sight, type AlignmentProvenance as SightAlignmentProvenance, type CapturedTurn as SightCapturedTurn, type ProbeConfig as SightConfig, type ProbeConfigInput as SightConfigInput, type EnvironmentEventInput as SightEnvironmentEventInput, type OutcomeEventEmit as SightOutcomeEventEmit, type OutcomeHook as SightOutcomeHook, type OutcomeResult as SightOutcomeResult, type PersonaConfig as SightPersonaConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -58,6 +58,144 @@ declare const PropensitySchema: z.ZodObject<{
|
|
|
58
58
|
selectionMeta?: Record<string, unknown> | undefined;
|
|
59
59
|
}>;
|
|
60
60
|
type PropensityInput = z.infer<typeof PropensitySchema>;
|
|
61
|
+
declare const EnvironmentEventInputSchema: z.ZodObject<{
|
|
62
|
+
/** Free-form channel label (e.g. a stimulus feed, a game state stream). Open vocabulary — NOT an enum. */
|
|
63
|
+
source_type: z.ZodString;
|
|
64
|
+
/** Free-form event name. Open vocabulary — NOT an enum. */
|
|
65
|
+
event: z.ZodString;
|
|
66
|
+
/** ISO timestamp of the event on the deployer's clock (see alignment). */
|
|
67
|
+
at: z.ZodString;
|
|
68
|
+
/** Optional detail payload (deployer-defined). */
|
|
69
|
+
meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
70
|
+
sessionExternalId: z.ZodString;
|
|
71
|
+
deploymentSlug: z.ZodString;
|
|
72
|
+
/**
|
|
73
|
+
* Optional reference to the causing turn. v1 resolves a turn index within
|
|
74
|
+
* the same session (string-encoded integer); any other value is stored
|
|
75
|
+
* verbatim on the event record without an outcome-corner link. The
|
|
76
|
+
* instrument records the reference only — no causal inference.
|
|
77
|
+
*/
|
|
78
|
+
causeProvenance: z.ZodOptional<z.ZodString>;
|
|
79
|
+
}, "strip", z.ZodTypeAny, {
|
|
80
|
+
at: string;
|
|
81
|
+
deploymentSlug: string;
|
|
82
|
+
sessionExternalId: string;
|
|
83
|
+
source_type: string;
|
|
84
|
+
event: string;
|
|
85
|
+
meta?: Record<string, unknown> | undefined;
|
|
86
|
+
causeProvenance?: string | undefined;
|
|
87
|
+
}, {
|
|
88
|
+
at: string;
|
|
89
|
+
deploymentSlug: string;
|
|
90
|
+
sessionExternalId: string;
|
|
91
|
+
source_type: string;
|
|
92
|
+
event: string;
|
|
93
|
+
meta?: Record<string, unknown> | undefined;
|
|
94
|
+
causeProvenance?: string | undefined;
|
|
95
|
+
}>;
|
|
96
|
+
type EnvironmentEventInput = z.infer<typeof EnvironmentEventInputSchema>;
|
|
97
|
+
/**
|
|
98
|
+
* Clock contract for a batch: whose clock produced the events' `at`, the
|
|
99
|
+
* deployer's bound on skew against the instrument's clock, and the version
|
|
100
|
+
* of the attach rule the deployer aligned to. Free-form strings — the
|
|
101
|
+
* instrument stores the claim, it does not verify clocks.
|
|
102
|
+
*/
|
|
103
|
+
declare const AlignmentProvenanceSchema: z.ZodObject<{
|
|
104
|
+
clock_source: z.ZodString;
|
|
105
|
+
skew_bound_ms: z.ZodOptional<z.ZodNumber>;
|
|
106
|
+
rule_version: z.ZodString;
|
|
107
|
+
}, "strip", z.ZodTypeAny, {
|
|
108
|
+
clock_source: string;
|
|
109
|
+
rule_version: string;
|
|
110
|
+
skew_bound_ms?: number | undefined;
|
|
111
|
+
}, {
|
|
112
|
+
clock_source: string;
|
|
113
|
+
rule_version: string;
|
|
114
|
+
skew_bound_ms?: number | undefined;
|
|
115
|
+
}>;
|
|
116
|
+
type AlignmentProvenance = z.infer<typeof AlignmentProvenanceSchema>;
|
|
117
|
+
declare const EnvironmentEventsBatchSchema: z.ZodObject<{
|
|
118
|
+
/** Events are self-addressed: a batch may span sessions/deployments. */
|
|
119
|
+
events: z.ZodArray<z.ZodObject<{
|
|
120
|
+
/** Free-form channel label (e.g. a stimulus feed, a game state stream). Open vocabulary — NOT an enum. */
|
|
121
|
+
source_type: z.ZodString;
|
|
122
|
+
/** Free-form event name. Open vocabulary — NOT an enum. */
|
|
123
|
+
event: z.ZodString;
|
|
124
|
+
/** ISO timestamp of the event on the deployer's clock (see alignment). */
|
|
125
|
+
at: z.ZodString;
|
|
126
|
+
/** Optional detail payload (deployer-defined). */
|
|
127
|
+
meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
128
|
+
sessionExternalId: z.ZodString;
|
|
129
|
+
deploymentSlug: z.ZodString;
|
|
130
|
+
/**
|
|
131
|
+
* Optional reference to the causing turn. v1 resolves a turn index within
|
|
132
|
+
* the same session (string-encoded integer); any other value is stored
|
|
133
|
+
* verbatim on the event record without an outcome-corner link. The
|
|
134
|
+
* instrument records the reference only — no causal inference.
|
|
135
|
+
*/
|
|
136
|
+
causeProvenance: z.ZodOptional<z.ZodString>;
|
|
137
|
+
}, "strip", z.ZodTypeAny, {
|
|
138
|
+
at: string;
|
|
139
|
+
deploymentSlug: string;
|
|
140
|
+
sessionExternalId: string;
|
|
141
|
+
source_type: string;
|
|
142
|
+
event: string;
|
|
143
|
+
meta?: Record<string, unknown> | undefined;
|
|
144
|
+
causeProvenance?: string | undefined;
|
|
145
|
+
}, {
|
|
146
|
+
at: string;
|
|
147
|
+
deploymentSlug: string;
|
|
148
|
+
sessionExternalId: string;
|
|
149
|
+
source_type: string;
|
|
150
|
+
event: string;
|
|
151
|
+
meta?: Record<string, unknown> | undefined;
|
|
152
|
+
causeProvenance?: string | undefined;
|
|
153
|
+
}>, "many">;
|
|
154
|
+
alignment: z.ZodObject<{
|
|
155
|
+
clock_source: z.ZodString;
|
|
156
|
+
skew_bound_ms: z.ZodOptional<z.ZodNumber>;
|
|
157
|
+
rule_version: z.ZodString;
|
|
158
|
+
}, "strip", z.ZodTypeAny, {
|
|
159
|
+
clock_source: string;
|
|
160
|
+
rule_version: string;
|
|
161
|
+
skew_bound_ms?: number | undefined;
|
|
162
|
+
}, {
|
|
163
|
+
clock_source: string;
|
|
164
|
+
rule_version: string;
|
|
165
|
+
skew_bound_ms?: number | undefined;
|
|
166
|
+
}>;
|
|
167
|
+
}, "strip", z.ZodTypeAny, {
|
|
168
|
+
events: {
|
|
169
|
+
at: string;
|
|
170
|
+
deploymentSlug: string;
|
|
171
|
+
sessionExternalId: string;
|
|
172
|
+
source_type: string;
|
|
173
|
+
event: string;
|
|
174
|
+
meta?: Record<string, unknown> | undefined;
|
|
175
|
+
causeProvenance?: string | undefined;
|
|
176
|
+
}[];
|
|
177
|
+
alignment: {
|
|
178
|
+
clock_source: string;
|
|
179
|
+
rule_version: string;
|
|
180
|
+
skew_bound_ms?: number | undefined;
|
|
181
|
+
};
|
|
182
|
+
}, {
|
|
183
|
+
events: {
|
|
184
|
+
at: string;
|
|
185
|
+
deploymentSlug: string;
|
|
186
|
+
sessionExternalId: string;
|
|
187
|
+
source_type: string;
|
|
188
|
+
event: string;
|
|
189
|
+
meta?: Record<string, unknown> | undefined;
|
|
190
|
+
causeProvenance?: string | undefined;
|
|
191
|
+
}[];
|
|
192
|
+
alignment: {
|
|
193
|
+
clock_source: string;
|
|
194
|
+
rule_version: string;
|
|
195
|
+
skew_bound_ms?: number | undefined;
|
|
196
|
+
};
|
|
197
|
+
}>;
|
|
198
|
+
type EnvironmentEventsBatch = z.infer<typeof EnvironmentEventsBatchSchema>;
|
|
61
199
|
|
|
62
200
|
/**
|
|
63
201
|
* Sight SDK (@cultured-computer/sight) shared types.
|
|
@@ -563,7 +701,8 @@ type OutcomeEventEmit = z.infer<typeof OutcomeEventEmitSchema>;
|
|
|
563
701
|
* HTTP client for the Probe ingest API.
|
|
564
702
|
*
|
|
565
703
|
* Sends captured turns to POST /v1/turns with a Bearer token. Async, fire-and-log:
|
|
566
|
-
* SDK never blocks the customer's LLM path on ingest.
|
|
704
|
+
* SDK never blocks the customer's LLM path on ingest. Rate-limited sends (429)
|
|
705
|
+
* are retried exactly once after Retry-After; sustained limiting drops captures.
|
|
567
706
|
*/
|
|
568
707
|
|
|
569
708
|
type IngestClientOptions = {
|
|
@@ -588,6 +727,15 @@ declare class IngestClient {
|
|
|
588
727
|
* arriving before any turn is not a captured session).
|
|
589
728
|
*/
|
|
590
729
|
private firstCaptureAnnounced;
|
|
730
|
+
/**
|
|
731
|
+
* Rate-limit (429) handling: the first 429 per process prints one stderr
|
|
732
|
+
* warning (not debug-gated, same channel and lifetime as the first-capture
|
|
733
|
+
* announce); subsequent 429s only debug-log. Each rate-limited request is
|
|
734
|
+
* retried exactly once after Retry-After; pendingRetries counts retries
|
|
735
|
+
* waiting on their timers so the cap can shed load.
|
|
736
|
+
*/
|
|
737
|
+
private rateLimitAnnounced;
|
|
738
|
+
private pendingRetries;
|
|
591
739
|
constructor(opts: IngestClientOptions);
|
|
592
740
|
/**
|
|
593
741
|
* Send a turn to the ingest API. Fire-and-log: errors are logged but never
|
|
@@ -609,6 +757,23 @@ declare class IngestClient {
|
|
|
609
757
|
* probe_outcome_events per Amendment I Method D.
|
|
610
758
|
*/
|
|
611
759
|
sendOutcomeEvent(deploymentSlug: string, event: OutcomeEventEmit): Promise<void>;
|
|
760
|
+
/**
|
|
761
|
+
* Send an environment-event batch to the ingest API. Fire-and-log, same as
|
|
762
|
+
* sendTurn. The envelope is generalized: the worker attaches each event to
|
|
763
|
+
* its session's record by time; meaning is per-deployment.
|
|
764
|
+
*/
|
|
765
|
+
sendEnvironmentEvents(batch: EnvironmentEventsBatch): Promise<void>;
|
|
766
|
+
/**
|
|
767
|
+
* Route a send response through the 429 retry policy. Non-429 responses
|
|
768
|
+
* pass through untouched. A 429 is re-sent exactly once after Retry-After
|
|
769
|
+
* seconds (default 1s when the header is missing or unparseable; clamped
|
|
770
|
+
* to [1, 60]s); the retry's response is returned as-is, so a second 429 is
|
|
771
|
+
* never retried again — callers log and drop it like any other failed
|
|
772
|
+
* send. Returns null when the retry was dropped at the pending-retry cap.
|
|
773
|
+
* The timer is unref'd (where supported) so a pending retry never holds
|
|
774
|
+
* the process open.
|
|
775
|
+
*/
|
|
776
|
+
private retryIfRateLimited;
|
|
612
777
|
private log;
|
|
613
778
|
}
|
|
614
779
|
|
|
@@ -691,8 +856,8 @@ declare function compileSignaturePhrases(phrases: SignaturePhrase[]): CompiledPh
|
|
|
691
856
|
*
|
|
692
857
|
* Probe.init({
|
|
693
858
|
* apiKey: process.env.PROBE_API_KEY!,
|
|
694
|
-
* deployment: '
|
|
695
|
-
* persona: { slug: '
|
|
859
|
+
* deployment: 'support-agent',
|
|
860
|
+
* persona: { slug: 'casey' },
|
|
696
861
|
* });
|
|
697
862
|
*
|
|
698
863
|
* // Autocapture is now on for any subsequent OpenAI / Anthropic / etc. call.
|
|
@@ -913,6 +1078,28 @@ declare class Probe {
|
|
|
913
1078
|
* signal the worker cannot infer.
|
|
914
1079
|
*/
|
|
915
1080
|
static emitOutcomeEvent(input: OutcomeEventEmit): Promise<void>;
|
|
1081
|
+
/**
|
|
1082
|
+
* Capture one environment event against a session (Arc D-rail). The
|
|
1083
|
+
* envelope is generalized: `source_type` and `event` are free strings whose
|
|
1084
|
+
* meaning is defined per deployment — the instrument stores the event and
|
|
1085
|
+
* attaches it to the session's record by time (the next turn's state
|
|
1086
|
+
* corner, plus the causing turn's outcome corner when `causeProvenance`
|
|
1087
|
+
* names a turn index), and never interprets it. Fire-and-log, like
|
|
1088
|
+
* captureTurn: errors are debug-logged, never thrown.
|
|
1089
|
+
*
|
|
1090
|
+
* Alignment defaults to the SDK's own clock claim; deployments with a
|
|
1091
|
+
* stricter clock contract (or batches) should call
|
|
1092
|
+
* captureEnvironmentEvents with explicit alignment provenance.
|
|
1093
|
+
*/
|
|
1094
|
+
static captureEnvironmentEvent(event: EnvironmentEventInput, alignment?: AlignmentProvenance): Promise<void>;
|
|
1095
|
+
/**
|
|
1096
|
+
* Capture a batch of environment events with explicit alignment provenance
|
|
1097
|
+
* (clock_source, skew_bound_ms, rule_version). Batches are capped at 100
|
|
1098
|
+
* events and may span sessions — every event is self-addressed. Same
|
|
1099
|
+
* generalized envelope and fire-and-log discipline as the single-event
|
|
1100
|
+
* capture above.
|
|
1101
|
+
*/
|
|
1102
|
+
static captureEnvironmentEvents(events: EnvironmentEventInput[], alignment: AlignmentProvenance): Promise<void>;
|
|
916
1103
|
/**
|
|
917
1104
|
* Flag a persona break for a session. Wire this to the customer's in-product
|
|
918
1105
|
* "that didn't sound like you" UX. Populates the `user_flagged_break`
|
|
@@ -941,4 +1128,4 @@ declare class Probe {
|
|
|
941
1128
|
private static shouldSample;
|
|
942
1129
|
}
|
|
943
1130
|
|
|
944
|
-
export { type CapturedTurn, type OutcomeEventEmit, type OutcomeHook, type OutcomeResult, type PersonaConfig, Probe, type ProbeConfig, type ProbeConfigInput, Probe as Sight, type CapturedTurn as SightCapturedTurn, type ProbeConfig as SightConfig, type ProbeConfigInput as SightConfigInput, type OutcomeEventEmit as SightOutcomeEventEmit, type OutcomeHook as SightOutcomeHook, type OutcomeResult as SightOutcomeResult, type PersonaConfig as SightPersonaConfig };
|
|
1131
|
+
export { type AlignmentProvenance, type CapturedTurn, type EnvironmentEventInput, type OutcomeEventEmit, type OutcomeHook, type OutcomeResult, type PersonaConfig, Probe, type ProbeConfig, type ProbeConfigInput, Probe as Sight, type AlignmentProvenance as SightAlignmentProvenance, type CapturedTurn as SightCapturedTurn, type ProbeConfig as SightConfig, type ProbeConfigInput as SightConfigInput, type EnvironmentEventInput as SightEnvironmentEventInput, type OutcomeEventEmit as SightOutcomeEventEmit, type OutcomeHook as SightOutcomeHook, type OutcomeResult as SightOutcomeResult, type PersonaConfig as SightPersonaConfig };
|