@cultured_computer/sight 0.8.2 → 0.8.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/CHANGELOG.md +17 -0
- package/README.md +10 -1
- package/dist/cli.js +15 -8
- package/dist/index.cjs +52 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +52 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/schema/sight-record-v1.schema.json +8 -0
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,23 @@ reconstructed from the repository: the `sdk-v*` release tags (dates are tag
|
|
|
5
5
|
dates) and the commits between them. Where the history does not say what a
|
|
6
6
|
version changed for SDK users, the entry says "see git history".
|
|
7
7
|
|
|
8
|
+
## 0.8.4 (2026-10-13)
|
|
9
|
+
|
|
10
|
+
- Capture slots and drain now include consuming or cancelling the HTTP
|
|
11
|
+
response body, not just receiving its headers. Unused response bodies
|
|
12
|
+
are cancelled, and debug acknowledgements are capped at 64 KiB under
|
|
13
|
+
the existing request timeout.
|
|
14
|
+
- Drain uses elapsed time rather than the system clock. An incomplete
|
|
15
|
+
accepted acknowledgement never retries capture; only the existing
|
|
16
|
+
single rate-limit retry remains. Public exports and capture payloads
|
|
17
|
+
are unchanged.
|
|
18
|
+
|
|
19
|
+
## 0.8.3 (2026-10-06)
|
|
20
|
+
|
|
21
|
+
- `sight openrouter connect --house-trial`: marks the connection as the
|
|
22
|
+
operator's key connected for a demo. The server accepts it only for the
|
|
23
|
+
house key it has pinned; any other key is refused with `not_house_key`.
|
|
24
|
+
|
|
8
25
|
## 0.8.2 (2026-10-06)
|
|
9
26
|
|
|
10
27
|
- `sight auth login` works again. 0.8.1 sent `client_id: undefined` (the
|
package/README.md
CHANGED
|
@@ -182,7 +182,7 @@ environment variables. Secrets are read from the environment, never from a flag.
|
|
|
182
182
|
| `sight export --project <slug> --deployment <slug>` | Writes a deployment's record as JSONL (`--out <file>`, default stdout) | `auth login`; owner role on the project |
|
|
183
183
|
| `sight conditions --session <id>` | Prints one session's detector checks as NDJSON | A key with `studio:run`: `SIGHT_API_KEY`, or the key saved by `account create` |
|
|
184
184
|
| `sight account create` | Redeems a one-time token and saves the key to `~/.config/sight/machine.json` (mode `0600`) | `SIGHT_PROVISION_TOKEN` |
|
|
185
|
-
| `sight openrouter connect --budget <usd
|
|
185
|
+
| `sight openrouter connect --budget <usd> [--house-trial]` | Connects your OpenRouter key (`OPENROUTER_API_KEY`) to the project; `--house-trial` marks it as the operator's key for a demo | A key with `providers:write` |
|
|
186
186
|
| `sight openrouter status` | Prints the stored connection: status, last four characters, budget | A key with `studio:run` or `providers:write` |
|
|
187
187
|
| `sight connect <relay-url> --invite <code>` | See [Connect your room](https://sight.cultured.computer/docs/connect-your-room) | An invite code |
|
|
188
188
|
|
|
@@ -196,6 +196,15 @@ Every flag: [CLI](https://sight.cultured.computer/docs/cli).
|
|
|
196
196
|
|
|
197
197
|
## Troubleshooting
|
|
198
198
|
|
|
199
|
+
Capture sends have a 15-second deadline and at most 64 requests in flight.
|
|
200
|
+
That slot covers the response body as well as headers: unused bodies are
|
|
201
|
+
cancelled, and debug turn acknowledgements are read up to 64 KiB. Await
|
|
202
|
+
`Sight.shutdown()` before a short-lived process exits; its bounded drain also
|
|
203
|
+
waits for pending rate-limit retries. A successful HTTP status means ingest
|
|
204
|
+
accepted the turn, not that worker redaction has finished. An acknowledgement
|
|
205
|
+
body failure never retries an accepted capture; only a `429` permits the
|
|
206
|
+
existing single retry after `Retry-After`.
|
|
207
|
+
|
|
199
208
|
Failed sends never throw. The first send the API rejects prints one
|
|
200
209
|
warning on stderr without `debug`: once per process for `401`, once for
|
|
201
210
|
`403`, once for any other `4xx` except `429`. Set `debug: true` on `init`
|
package/dist/cli.js
CHANGED
|
@@ -18,17 +18,17 @@ function usage() {
|
|
|
18
18
|
"Usage:",
|
|
19
19
|
" sight auth login [--base <dashboard-url>] [--no-browser]",
|
|
20
20
|
" sight auth logout",
|
|
21
|
-
" sight export --project <slug> --deployment <slug> [--readings|--conditions] [--out file.jsonl]",
|
|
21
|
+
" sight export --project <slug> --deployment <slug> [--readings|--conditions|--labels] [--out file.jsonl]",
|
|
22
22
|
" sight conditions --session <id-or-external-id> [--deployment <slug>] [--run <id>] [--since <iso>] [--until <iso>] [--base <dashboard-url>]",
|
|
23
23
|
" sight account create [--openrouter --budget <usd>] [--api <base>]",
|
|
24
|
-
" sight openrouter connect --budget <usd> [--api <base>]",
|
|
24
|
+
" sight openrouter connect --budget <usd> [--house-trial] [--api <base>]",
|
|
25
25
|
" sight openrouter status [--api <base>]",
|
|
26
26
|
" sight connect <relay-url> --invite <code> [--pulse] [--api <base>]",
|
|
27
27
|
"",
|
|
28
28
|
"Commands:",
|
|
29
29
|
" auth login Sign this terminal in: approve the printed link in your browser.",
|
|
30
30
|
" auth logout Delete the stored login token.",
|
|
31
|
-
" export Write a deployment's record (or --readings, --conditions) as JSONL. Needs auth login, owner role.",
|
|
31
|
+
" export Write a deployment's record (or --readings, --conditions, --labels) as JSONL. Needs auth login, owner role.",
|
|
32
32
|
" conditions Print a session's or a run's detector checks as NDJSON. Needs a key with studio:run.",
|
|
33
33
|
" account create Redeem SIGHT_PROVISION_TOKEN; save the key to ~/.config/sight/machine.json (0600).",
|
|
34
34
|
" openrouter connect Connect your OpenRouter key with a monthly USD budget. Needs a key with providers:write.",
|
|
@@ -168,7 +168,13 @@ async function connectOpenRouter(api, sightKey, args) {
|
|
|
168
168
|
authorization: `Bearer ${sightKey}`,
|
|
169
169
|
"content-type": "application/json"
|
|
170
170
|
},
|
|
171
|
-
body: JSON.stringify({
|
|
171
|
+
body: JSON.stringify({
|
|
172
|
+
apiKey: openRouterKey,
|
|
173
|
+
monthlyBudgetUsd: budget,
|
|
174
|
+
// --house-trial: the key is the operator's, connected for a demo
|
|
175
|
+
// (the connection says so; the dashboard card and the audit read it).
|
|
176
|
+
...args.includes("--house-trial") ? { houseTrial: true } : {}
|
|
177
|
+
})
|
|
172
178
|
}).catch((_error) => ({ __error: _error }));
|
|
173
179
|
if (!response.ok) {
|
|
174
180
|
const body2 = response instanceof Response ? await response.json().catch(() => ({})) : {};
|
|
@@ -231,7 +237,7 @@ async function account(args) {
|
|
|
231
237
|
async function openrouter(args) {
|
|
232
238
|
const sub = args[0];
|
|
233
239
|
if (sub !== "connect" && sub !== "status") {
|
|
234
|
-
console.error("usage: sight openrouter connect --budget <usd> [--api <base>] | sight openrouter status [--api <base>]");
|
|
240
|
+
console.error("usage: sight openrouter connect --budget <usd> [--house-trial] [--api <base>] | sight openrouter status [--api <base>]");
|
|
235
241
|
return 1;
|
|
236
242
|
}
|
|
237
243
|
const stored = readMachineCredentials();
|
|
@@ -345,8 +351,9 @@ async function exportRecord(args) {
|
|
|
345
351
|
const out = flag(args, "--out") ?? null;
|
|
346
352
|
const readings = args.includes("--readings");
|
|
347
353
|
const conditions2 = args.includes("--conditions");
|
|
348
|
-
|
|
349
|
-
|
|
354
|
+
const labels = args.includes("--labels");
|
|
355
|
+
if (!project || !deployment || [readings, conditions2, labels].filter(Boolean).length > 1) {
|
|
356
|
+
console.error("usage: sight export --project <slug> --deployment <slug> [--readings|--conditions|--labels] [--out file.jsonl]");
|
|
350
357
|
return 1;
|
|
351
358
|
}
|
|
352
359
|
const creds = readCredentials();
|
|
@@ -354,7 +361,7 @@ async function exportRecord(args) {
|
|
|
354
361
|
console.error("no stored login. Run sight auth login first.");
|
|
355
362
|
return 1;
|
|
356
363
|
}
|
|
357
|
-
const kind = conditions2 ? "conditions" : readings ? "readings" : null;
|
|
364
|
+
const kind = conditions2 ? "conditions" : readings ? "readings" : labels ? "labels" : null;
|
|
358
365
|
const url = `${creds.base}/api/export?project=${encodeURIComponent(project)}&deployment=${encodeURIComponent(deployment)}` + (kind ? `&kind=${kind}` : "");
|
|
359
366
|
const res = await fetch(url, {
|
|
360
367
|
headers: { authorization: `Bearer ${creds.token}` }
|
package/dist/index.cjs
CHANGED
|
@@ -13,6 +13,34 @@ var MAX_PENDING_RETRIES = 50;
|
|
|
13
13
|
var SEND_TIMEOUT_MS = 15e3;
|
|
14
14
|
var MAX_INFLIGHT = 64;
|
|
15
15
|
var MAX_TURN_BODY_BYTES = 9e5;
|
|
16
|
+
var MAX_ACK_BODY_BYTES = 65536;
|
|
17
|
+
async function readAcknowledgement(response) {
|
|
18
|
+
if (!response.body) return {};
|
|
19
|
+
const reader = response.body.getReader();
|
|
20
|
+
const chunks = [];
|
|
21
|
+
let size = 0;
|
|
22
|
+
try {
|
|
23
|
+
while (true) {
|
|
24
|
+
const { done, value } = await reader.read();
|
|
25
|
+
if (done) break;
|
|
26
|
+
size += value.byteLength;
|
|
27
|
+
if (size > MAX_ACK_BODY_BYTES) throw new Error("acknowledgement exceeds 65536 bytes");
|
|
28
|
+
chunks.push(value);
|
|
29
|
+
}
|
|
30
|
+
const bytes = new Uint8Array(size);
|
|
31
|
+
let offset = 0;
|
|
32
|
+
for (const chunk of chunks) {
|
|
33
|
+
bytes.set(chunk, offset);
|
|
34
|
+
offset += chunk.byteLength;
|
|
35
|
+
}
|
|
36
|
+
const body = JSON.parse(new TextDecoder().decode(bytes));
|
|
37
|
+
return body !== null && typeof body === "object" && "pendingId" in body && typeof body.pendingId === "string" ? { pendingId: body.pendingId } : {};
|
|
38
|
+
} finally {
|
|
39
|
+
await reader.cancel().catch(() => {
|
|
40
|
+
});
|
|
41
|
+
reader.releaseLock();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
16
44
|
var IngestClient = class {
|
|
17
45
|
apiKey;
|
|
18
46
|
endpoint;
|
|
@@ -48,7 +76,7 @@ var IngestClient = class {
|
|
|
48
76
|
* first drop prints one stderr warning, later ones log only with
|
|
49
77
|
* `debug: true`.
|
|
50
78
|
*/
|
|
51
|
-
async guardedFetch(url, init) {
|
|
79
|
+
async guardedFetch(url, init, consume) {
|
|
52
80
|
if (this.inFlight >= MAX_INFLIGHT) {
|
|
53
81
|
if (!this.shedAnnounced) {
|
|
54
82
|
this.shedAnnounced = true;
|
|
@@ -59,9 +87,14 @@ var IngestClient = class {
|
|
|
59
87
|
throw new Error(`${MAX_INFLIGHT} sends already in flight; this send was dropped`);
|
|
60
88
|
}
|
|
61
89
|
this.inFlight++;
|
|
90
|
+
let response;
|
|
62
91
|
try {
|
|
63
|
-
|
|
92
|
+
response = await fetch(url, { ...init, signal: AbortSignal.timeout(SEND_TIMEOUT_MS) });
|
|
93
|
+
await consume?.(response);
|
|
94
|
+
return response;
|
|
64
95
|
} finally {
|
|
96
|
+
if (response?.body && !response.body.locked) await response.body.cancel().catch(() => {
|
|
97
|
+
});
|
|
65
98
|
this.inFlight--;
|
|
66
99
|
}
|
|
67
100
|
}
|
|
@@ -72,8 +105,8 @@ var IngestClient = class {
|
|
|
72
105
|
* the time is up is not guaranteed to be sent.
|
|
73
106
|
*/
|
|
74
107
|
async drainInFlight(timeoutMs = SEND_TIMEOUT_MS) {
|
|
75
|
-
const deadline =
|
|
76
|
-
while ((this.inFlight > 0 || this.pendingRetries > 0) &&
|
|
108
|
+
const deadline = performance.now() + timeoutMs;
|
|
109
|
+
while ((this.inFlight > 0 || this.pendingRetries > 0) && performance.now() < deadline) {
|
|
77
110
|
await new Promise((r) => setTimeout(r, 50));
|
|
78
111
|
}
|
|
79
112
|
}
|
|
@@ -103,6 +136,18 @@ var IngestClient = class {
|
|
|
103
136
|
"content-type": "application/json"
|
|
104
137
|
},
|
|
105
138
|
body
|
|
139
|
+
}, async (response2) => {
|
|
140
|
+
if (!response2.ok) return;
|
|
141
|
+
if (!this.firstCaptureAnnounced) {
|
|
142
|
+
this.firstCaptureAnnounced = true;
|
|
143
|
+
console.error(
|
|
144
|
+
`Sight: first session captured -> ${this.dashboardUrl}/sessions/${encodeURIComponent(turn.sessionExternalId)}`
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
if (this.debug) {
|
|
148
|
+
const ack = await readAcknowledgement(response2);
|
|
149
|
+
this.log(`[sight] ingest ok id=${ack.pendingId ?? "?"}`);
|
|
150
|
+
}
|
|
106
151
|
});
|
|
107
152
|
const response = await this.retryIfRateLimited(await send(), send);
|
|
108
153
|
if (response === null) return;
|
|
@@ -111,16 +156,6 @@ var IngestClient = class {
|
|
|
111
156
|
this.log(`[sight] ingest failed status=${response.status}`);
|
|
112
157
|
return;
|
|
113
158
|
}
|
|
114
|
-
if (!this.firstCaptureAnnounced) {
|
|
115
|
-
this.firstCaptureAnnounced = true;
|
|
116
|
-
console.error(
|
|
117
|
-
`Sight: first session captured -> ${this.dashboardUrl}/sessions/${encodeURIComponent(turn.sessionExternalId)}`
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
if (this.debug) {
|
|
121
|
-
const body2 = await response.json();
|
|
122
|
-
this.log(`[sight] ingest ok id=${body2.pendingId ?? "?"}`);
|
|
123
|
-
}
|
|
124
159
|
} catch (err) {
|
|
125
160
|
const msg = err instanceof Error ? err.message : String(err);
|
|
126
161
|
this.log(`[sight] ingest error: ${msg}`);
|
|
@@ -1901,7 +1936,7 @@ function createIntegration(options) {
|
|
|
1901
1936
|
call.contextSession = sessionFromContext(e["runtimeContext"]) ?? call.contextSession;
|
|
1902
1937
|
const model = rec(e["model"]);
|
|
1903
1938
|
const response = rec(e["response"]);
|
|
1904
|
-
const
|
|
1939
|
+
const performance2 = rec(e["performance"]);
|
|
1905
1940
|
const content = Array.isArray(e["content"]) ? e["content"] : [];
|
|
1906
1941
|
const toolNames = [];
|
|
1907
1942
|
for (const part of content) {
|
|
@@ -1927,8 +1962,8 @@ function createIntegration(options) {
|
|
|
1927
1962
|
finishReason,
|
|
1928
1963
|
rawFinishReason: str(e["rawFinishReason"]),
|
|
1929
1964
|
toolNames,
|
|
1930
|
-
latencyMs: ms(
|
|
1931
|
-
firstTokenMs: ms(
|
|
1965
|
+
latencyMs: ms(performance2?.["responseTimeMs"]) ?? (open ? Math.max(0, Date.now() - open.startedAt) : void 0),
|
|
1966
|
+
firstTokenMs: ms(performance2?.["timeToFirstOutputMs"]),
|
|
1932
1967
|
// A stream that failed part way ends its step with this finish
|
|
1933
1968
|
// reason; the events carry no error message for it.
|
|
1934
1969
|
error: finishReason === "error" ? 'model call ended with finish reason "error"' : void 0,
|