@cultured_computer/sight 0.6.0 → 0.8.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/CHANGELOG.md ADDED
@@ -0,0 +1,257 @@
1
+ # Changelog
2
+
3
+ `@cultured_computer/sight`. Newest first. Released versions are
4
+ reconstructed from the repository: the `sdk-v*` release tags (dates are tag
5
+ dates) and the commits between them. Where the history does not say what a
6
+ version changed for SDK users, the entry says "see git history".
7
+
8
+ ## 0.8.0 (2026-10-03)
9
+
10
+ Vercel AI SDK (`ai`)
11
+
12
+ - `ai` 7 is captured automatically. `init` registers a telemetry
13
+ integration with `ai` (`registerTelemetry`); `ai` 7 sends every call to a
14
+ registered integration, so no per-call flag is needed. Covers
15
+ `generateText`, `streamText`, `generateObject`, `streamObject`. Verified
16
+ with `ai` 7.0.17.
17
+ - One turn per model call: a tool loop of N model calls is N turns, each
18
+ with the text of that reply and the names of the tools it requested.
19
+ `streamText` captures once, when the model call's stream ends, with the
20
+ full text.
21
+ - A turn carries the reply text (text parts only), the model id the
22
+ provider returned, the provider id, input, output, cache read and cache
23
+ write tokens, tool names and count, finish reason, response time, time to
24
+ first output for streams (`probe_first_token_ms`), and the person's
25
+ message when the request's last message is the person's (text recorded
26
+ with `userInputSubmit` wins). A model call that throws or is aborted is
27
+ one turn with an error and no reply.
28
+ - Session: the `Sight.withSession` scope. Outside a scope, the session id
29
+ is read from `sightTelemetry({ sessionId })` passed in the call's
30
+ `telemetry.integrations`, then from `runtimeContext.sightSessionId` or
31
+ `runtimeContext.sessionId` (when `telemetry.includeRuntimeContext` names
32
+ the key). With none, the call is skipped and the one no-session warning
33
+ prints.
34
+ - New exports: `sightTelemetry(options?)` and the types `SightAiTelemetry`
35
+ and `SightAiTelemetryOptions`. For hosts where the SDK cannot resolve
36
+ `ai`: `registerTelemetry(sightTelemetry())`.
37
+ - `ai` 6 is captured from the OpenTelemetry spans it emits for calls made
38
+ with `experimental_telemetry: { isEnabled: true }`: the spans
39
+ `ai.generateText.doGenerate`, `ai.streamText.doStream`,
40
+ `ai.generateObject.doGenerate` and `ai.streamObject.doStream` become
41
+ turns (reply from `ai.response.text` or `ai.response.object`, model from
42
+ `ai.response.model`, tokens from `gen_ai.usage.*` then `ai.usage.*`, tool
43
+ names from `ai.response.toolCalls`, session fallback from
44
+ `ai.telemetry.metadata.sightSessionId` then `.sessionId`). The outer
45
+ `ai.generateText` span is not a turn. Verified with `ai` 6.0.300; `ai` 3
46
+ to 5 are not verified.
47
+ - One model call is one turn across paths: a span or a wrapped OpenAI call
48
+ made inside an `ai` 7 model call is not captured a second time, and a
49
+ span carrying the response id of a call the integration captured (the
50
+ span `@ai-sdk/otel` emits) is skipped.
51
+
52
+ Capture behavior
53
+
54
+ - A call seen by autocapture (a wrapped OpenAI client or an instrumented
55
+ library) outside any `Sight.withSession(id, fn)` scope is still skipped,
56
+ but the first such skip in a process now prints one warning without
57
+ `debug`. Later skips log only with `debug: true`.
58
+ - The startup warning about OpenAI module patching no longer prints when a
59
+ client has been wrapped with `wrapOpenAI()`. When it does print, it says
60
+ that calls through a wrapped client are captured and calls through an
61
+ unwrapped client are not.
62
+ - `captureTurn` validates the turn before sending. An invalid turn logs one
63
+ warning line naming the first invalid field and is dropped; nothing is
64
+ sent. Before, it was sent, refused by the server and swallowed.
65
+ - `userRating`, `userThumbs`, `userInputStart`, `userInputEdit`,
66
+ `userInputSubmit` and `endSession` log one warning line on invalid input
67
+ and drop it. Before, `userRating` dropped an out-of-range value silently
68
+ and the others did not validate.
69
+ - `captureTurn`: `deploymentSlug` is optional and defaults to the
70
+ `deployment` given to `init`. An explicit value wins. New exported type
71
+ `CaptureTurnInput` (alias `SightCaptureTurnInput`).
72
+ - Every captured turn carries `turnId`, a fresh UUID per logical turn. The
73
+ SDK's retry of a rate-limited send re-sends the same `turnId`. A `turnId`
74
+ supplied to `captureTurn` is sent as given (it must be a UUID).
75
+ `turnIndex` is unchanged: still a per-process counter per session.
76
+
77
+ First-token time and cost
78
+
79
+ - `wrapOpenAI`: a streamed call sends its first-token time, the
80
+ milliseconds from the start of the request to the first chunk that
81
+ carries reply text, a refusal or a tool call (Chat Completions and
82
+ Responses API). The role-only opening chunk does not count. A call that
83
+ is not streamed sends no first-token time.
84
+ - `wrapOpenAI`: a streamed call sends the names and count of its tool
85
+ calls. Before, a streamed tool call sent none.
86
+ - `wrapOpenAI`: when the response usage reports a cost (`usage.cost`, as
87
+ OpenRouter sends), the turn carries it. A reported 0 is sent as 0. With
88
+ no reported cost nothing is sent. On an OpenRouter bring-your-own-key
89
+ call the cost is sent only when the upstream charge is reported too.
90
+ - `wrapOpenAI`: provider is read from the client's `baseURL`:
91
+ `api.openai.com` or none is `openai`, `openrouter.ai` is `openrouter`,
92
+ `*.openai.azure.com` is `azure`, `*.inceptionlabs.ai` is `inception`.
93
+ For any other host no provider is sent. Before, every host was sent as
94
+ `openai`.
95
+ - OpenTelemetry spans: `gen_ai.usage.cost` is sent as the turn's cost when
96
+ the span carries it. No first-token time is sent on this path: the
97
+ bundled OpenAI, Anthropic and LangChain instrumentations do not report
98
+ one on the span.
99
+ - Every autocaptured turn also sends the requested model, and, where the
100
+ convention is known (a wrapped OpenAI client, the bundled OpenAI and
101
+ Anthropic instrumentations), whether the input token count includes
102
+ cached tokens.
103
+ - Server side: a turn with no reported cost gets an estimated cost from the
104
+ price catalogue when its provider and model name exactly one price in
105
+ effect at the turn's time (exact match, no name normalization); otherwise
106
+ the cost is unavailable, never 0. Each turn records whether its cost was
107
+ reported by the provider, estimated (with the price used), or
108
+ unavailable.
109
+
110
+ OpenTelemetry span mapping
111
+
112
+ - Provider is read from `gen_ai.provider.name`, then `gen_ai.system`, then
113
+ `gen_ai.provider`.
114
+ - The reply text is parsed out of structured `gen_ai.output.messages`
115
+ (text parts of the first assistant message). A JSON message array is no
116
+ longer stored as the reply. A plain-text value is kept as before.
117
+ - Tool names and the tool-call count come from the reply's `tool_call`
118
+ parts, then from `execute_tool` spans that are children of the model-call
119
+ span, then from `gen_ai.response.tool_names` /
120
+ `gen_ai.response.tool_calls_count`.
121
+ - Cache tokens are read from `gen_ai.usage.cache_read.input_tokens` and
122
+ `gen_ai.usage.cache_creation.input_tokens`, then from the underscore
123
+ names (`cache_read_input_tokens`, `cache_creation_input_tokens`).
124
+ - Input and output tokens fall back to `gen_ai.usage.prompt_tokens` and
125
+ `gen_ai.usage.completion_tokens`.
126
+ - The person's message is read from `gen_ai.input.messages` (the last
127
+ message of the request, when it is the person's and carries text) and
128
+ sent as `userInput.text`, unless text recorded with `userInputSubmit` is
129
+ pending for that turn or the turn already carries `userInput.text`.
130
+ - With no `withSession` scope, a span's `gen_ai.conversation.id` is used as
131
+ the session id. An explicit scope wins.
132
+ - Operations that become turns: `chat`, `generate_content`,
133
+ `text_completion`. `embeddings` spans no longer become turns.
134
+ `invoke_agent`, `create_agent`, workflow and `execute_tool` spans are not
135
+ turns.
136
+
137
+ Packaging
138
+
139
+ - Typings and doc comments name the package `@cultured_computer/sight` and
140
+ describe behavior in plain terms. The build checks the shipped typings
141
+ for internal references and fails on any.
142
+ - `CHANGELOG.md` added and shipped in the package.
143
+ - `package.json` description and the CLI's first help line rewritten.
144
+ - `sight --help` lists every verb with one line each, documents
145
+ `SIGHT_API`, `SIGHT_BASE`, `SIGHT_API_KEY`, `SIGHT_PROVISION_TOKEN` and
146
+ `OPENROUTER_API_KEY`, and states that the Field API has no CLI verbs.
147
+ - README: the quickstart captures inside `withSession`; requirements state
148
+ Node 20.6 or later, server side only; the claim of cost capture removed.
149
+ The Vercel AI SDK section states what is captured for `ai` 7 and `ai` 6.
150
+
151
+ Already on the main branch since 0.7.1, not part of the change set above
152
+
153
+ - `sight conditions` accepts `--deployment <slug>`.
154
+ - `endSession` always sends the session end to the server; the reason
155
+ defaults to `natural` when none is given.
156
+
157
+ ## 0.7.1 (2026-09-22)
158
+
159
+ - CLI: `sight conditions` (one session's or one run's detector checks,
160
+ read with the machine key) and `sight export --conditions`.
161
+
162
+ ## 0.7.0 (2026-09-22)
163
+
164
+ - CLI: `sight account create` (redeem a provisioning token without a
165
+ browser) and `sight openrouter connect|status`.
166
+ - Span capture contract v2: `SpanInputV2` and the span schemas and
167
+ constants are exported; the v1 shape stays accepted.
168
+ - Every captured turn is stamped with `envelopeVersion`.
169
+ - Other changes: see git history.
170
+
171
+ ## 0.6.0 (2026-08-10)
172
+
173
+ - `wrapOpenAI(client)`: instance wrapping for `chat.completions.create` and
174
+ `responses.create`, streaming included.
175
+ - A startup warning when OpenAI module patching did not attach.
176
+ - CLI: `sight export --readings`.
177
+
178
+ ## 0.5.1 (2026-08-04)
179
+
180
+ - npm description shortened to fit the registry limit.
181
+
182
+ ## 0.5.0 (2026-08-04)
183
+
184
+ - CLI: `sight auth login`, `sight auth logout`, `sight export`.
185
+
186
+ ## 0.4.4 (2026-07-30)
187
+
188
+ - `shutdown()` waits for in-flight sends.
189
+
190
+ ## 0.4.3 (2026-07-29)
191
+
192
+ - npm texts: homepage, keywords, README link to the connect walkthrough.
193
+
194
+ ## 0.4.2 (2026-07-28)
195
+
196
+ - README, description and CLI output text edits.
197
+
198
+ ## 0.4.1 (2026-07-28)
199
+
200
+ - README documents the CLI and `sight connect`.
201
+
202
+ ## 0.4.0 (2026-07-28)
203
+
204
+ - The `sight` CLI ships in the package, with `sight connect`.
205
+ - The record schema is published in the package
206
+ (`schema/sight-record-v1.schema.json`).
207
+
208
+ ## 0.3.6 (2026-07-27)
209
+
210
+ - npm description change. No release tag for this version: see git history.
211
+
212
+ ## 0.3.5 (2026-07-22)
213
+
214
+ - README rewrite.
215
+
216
+ ## 0.3.4 (2026-07-22)
217
+
218
+ - README fix.
219
+
220
+ ## 0.3.3 (2026-07-21)
221
+
222
+ - Host-safety hardening: a per-send timeout, a cap on in-flight sends, a
223
+ cap on tracked sessions, and per-request methods that warn and drop on
224
+ invalid input instead of throwing.
225
+ - `captureEnvironmentEvent` may omit `alignment`; the SDK stamps its own
226
+ clock.
227
+
228
+ ## 0.3.2 (2026-07-21)
229
+
230
+ - `captureSpan` / `captureSpans`.
231
+ - `endSession` accepts a declared `outcome`; a declared outcome wins over
232
+ the outcome hook.
233
+ - Typings build fix.
234
+
235
+ ## 0.3.1 (2026-07-20)
236
+
237
+ - The default `endpoint` points at the production ingest service.
238
+
239
+ ## 0.3.0 (2026-07-19)
240
+
241
+ - `captureEnvironmentEvent` / `captureEnvironmentEvents`.
242
+
243
+ ## 0.2.1 (2026-07-15)
244
+
245
+ - A rate-limited send (429) is retried once after `Retry-After`; the first
246
+ 429 in a process prints one warning.
247
+
248
+ ## 0.2.0 (2026-07-14)
249
+
250
+ - The outcome hook resolves when `endSession` is called.
251
+ - Sessions are stamped with a hash of the system prompt when no
252
+ `environmentConfigHash` is set.
253
+ - No release tag for this version: see git history.
254
+
255
+ ## 0.1.0 (2026-07-14)
256
+
257
+ - First published version. See git history.