@cultured_computer/sight 0.7.1 → 0.8.1

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