@hunt-labs/bytekit-sdk 0.6.1 → 0.7.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 CHANGED
@@ -8,6 +8,81 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
  This file records only the delta between versions. For how to use the package
9
9
  today, see [README.md](./README.md), which remains the authoritative usage guide.
10
10
 
11
+ ## [0.7.0] - 2026-08-11
12
+
13
+ ### Added
14
+
15
+ - **Every outbound request now carries `X-ByteKit-Client: sdk_ts/<version>`.** The SDK identifies
16
+ itself with the sanctioned `client_surface` marker (issue #2905, slice 2 of #2701), so requests
17
+ made through `@hunt-labs/bytekit-sdk` are distinguishable from raw API calls in ByteKit's own
18
+ analytics instead of all resolving to `api_direct`. `sdk_ts` is a member of the closed
19
+ `client_surface` vocabulary declared in issue #2904; the version affix is this package's own
20
+ version, baked in at build time from `package.json`.
21
+
22
+ Set at exactly ONE place — the header literal inside the private transport every request funnels
23
+ through — so it rides on the JSON path, the raw `/v1/fetch` path and every resource method
24
+ alike. **Nothing else about a request changed:** same `Authorization` and `Content-Type`, same
25
+ body bytes, same client-side abort budget, same error taxonomy, same return shapes. The marker
26
+ carries no caller data and cannot be set, overridden or read by callers — there is no
27
+ `headers` option on `ByteKitOptions` or `RequestOptions`.
28
+
29
+ Minor rather than patch because the wire format of every request changes, even though no
30
+ documented API does. A gateway that does not yet recognize the header ignores it.
31
+
32
+ - `SDK_VERSION` — an internal, build-time-generated constant (`src/version.ts`, written by
33
+ `pnpm gen:version` from `package.json` and gated by `src/__tests__/version-parity.test.ts`).
34
+ It backs the marker's version affix. **Not part of the public export surface**;
35
+ `package.json`'s `version` field remains the only version consumers should read.
36
+
37
+ ### Unchanged
38
+
39
+ - **Still ZERO runtime dependencies.** The `client_surface` vocabulary lives in an internal,
40
+ unpublished workspace package, so the emitted value is a string literal here and the binding to
41
+ that registry is a test-only import. `dependencies` stays empty, asserted by
42
+ `src/__tests__/package-manifest.test.ts`.
43
+
44
+ ## [0.6.2] - 2026-08-11 [NEVER PUBLISHED]
45
+
46
+ **This version was cut but NEVER PUBLISHED — npm `latest` went from 0.6.1 straight to 0.7.0.**
47
+ The two documentation/regeneration changes below reached consumers in the **0.7.0** artifact,
48
+ which contains all of them. Nothing under this heading is missing from 0.7.0, and nothing is
49
+ installable at 0.6.2: `npm i @hunt-labs/bytekit-sdk@0.6.2` fails.
50
+
51
+ Why it was stranded: 0.6.2 was cut for two `src/generated/api.d.ts` regenerations, and the next
52
+ change (issue #2905's new outbound request header) altered the wire format of every request —
53
+ additive behavior that belongs at a MINOR, not a patch. Folding it into the still-unpublished
54
+ 0.6.2 would have shipped a new request header to consumers pinning `^0.6.1` unannounced, so 0.7.0
55
+ was cut instead and this heading annotated per `ci/scripts/check-release-drift.sh`'s
56
+ reconciliation form (#2680).
57
+
58
+ ### Documentation
59
+
60
+ - **`AccountSessionResponse.has_activity` now documents what it actually means.** The generated
61
+ type's JSDoc previously said the flag was true once the account had "ever recorded billable
62
+ activity", which read as "ever made a request". It is true only once a request has
63
+ **successfully completed and been charged credits** — a request that failed does not flip it,
64
+ even when its bandwidth was billed (issue #2890). The doc comment also now states the
65
+ all-time (never windowed) scope and the up-to-one-rollup lag, so a caller polling it after a
66
+ first request knows `false` can mean "not visible yet" rather than "never made a request".
67
+ Regenerated from `docs/api/openapi.yaml`; the emitted TYPE is unchanged
68
+ (`has_activity: boolean`), so this release is source-compatible in both directions.
69
+
70
+ ### Changed
71
+
72
+ - Regenerated `src/generated/api.d.ts` from `docs/api/openapi.yaml` after issue #2904 declared the
73
+ optional `X-ByteKit-Client` request header as `components.parameters.ClientSurfaceMarker`. The
74
+ regeneration is ADDITIVE and touches no method signature: one entry appears under
75
+ `components["parameters"]`, because the parameter is deliberately `$ref`-ed from no operation.
76
+ **No consumer-visible change** — no exported function, type or runtime behavior differs from
77
+ 0.6.1. The entry exists because `check-release-drift` (#2680) requires a version bump for any
78
+ post-release change to a shipped file, and the publish pipeline is version-gated.
79
+
80
+ Documented under 0.6.2 alongside the #2890 regeneration above, rather than under a 0.6.3 of its
81
+ own, because 0.6.2 has been CUT BUT NOT PUBLISHED (npm `latest` is 0.6.1). Both regenerations
82
+ therefore ship in the same single artifact. Numbering this 0.6.3 would leave 0.6.2 documented and
83
+ unpublishable — the version-gated pipeline would publish 0.6.3 and skip it — which is precisely
84
+ the phantom-version class #2680 exists to kill, and `check-release-drift` rejects it by name.
85
+
11
86
  ## [0.6.1] - 2026-08-10
12
87
 
13
88
  ### Changed
package/dist/client.js CHANGED
@@ -8,6 +8,7 @@ import { SearchResource } from './resources/search.js';
8
8
  import { AccountResource } from './resources/account.js';
9
9
  import { UsageResource } from './resources/usage.js';
10
10
  import { WebhooksResource } from './resources/webhooks.js';
11
+ import { SDK_VERSION } from './version.js';
11
12
  const DEFAULT_BASE_URL = 'https://api.bytekit.com';
12
13
  /**
13
14
  * Default client-side request timeout (2 minutes).
@@ -362,6 +363,20 @@ export class ByteKit {
362
363
  headers: {
363
364
  Authorization: `Bearer ${this.apiKey}`,
364
365
  'Content-Type': 'application/json',
366
+ // The client_surface marker (issue #2905, slice 2 of #2701). Its NAME is
367
+ // `CLIENT_SURFACE_HEADER` and its `<surface>/<version>` shape and closed vocabulary
368
+ // `CLIENT_SURFACES` are declared in `@bytekit/analytics-contract` — deliberately
369
+ // spelled as literals HERE and not imported, because this package publishes with ZERO
370
+ // runtime dependencies and a `workspace:*` dependency on that private, unpublished
371
+ // package would break the published artifact. The binding to the registry is a
372
+ // TEST-ONLY import, in `client-surface-marker.test.ts`.
373
+ //
374
+ // This is the SINGLE emit site by construction: `send()` is the one transport both
375
+ // `request()` and `requestRaw()` funnel through, so a per-resource or per-method emit
376
+ // would be a duplicate rather than a completeness fix (#2905 E4). The ticket's pre-merge
377
+ // gate 1 counts occurrences of the header name in non-test `src/` and expects exactly
378
+ // one — the line below — which is why the prose above names the constant instead.
379
+ 'X-ByteKit-Client': `sdk_ts/${SDK_VERSION}`,
365
380
  },
366
381
  };
367
382
  if (body !== undefined) {
@@ -2495,7 +2495,7 @@ export interface components {
2495
2495
  terms_version: string;
2496
2496
  /** Format: date-time */
2497
2497
  created_at: string;
2498
- /** @description True once the account has ever recorded billable activity (any successful scrape/screenshot/fetch/… request, regardless of whether it was authenticated with a Clerk session or an API key). Powers the dashboard onboarding gate — the app shows the guided onboarding flow until this is true, then the dashboard. */
2498
+ /** @description True once the account has SUCCESSFULLY COMPLETED at least one billable request (a scrape/screenshot/fetch/… that settled and was charged credits), regardless of whether it was authenticated with a Clerk session or an API key. All-time — never windowed. A request that failed does not flip it, even when its bandwidth was billed: the monitor terminal-preflight-failure path records bytes without credits, and only the credited settlement counts here. Powers the dashboard onboarding gate — the app shows the guided onboarding flow until this is true, then the dashboard. Lags by up to one usage rollup: the completion service writes the row after the response is returned, so a just-completed first request may still read false for a moment. Treat that as "not visible yet", never as "this account has never made a request". */
2499
2499
  has_activity: boolean;
2500
2500
  };
2501
2501
  /** @description Partial update payload for PATCH /v1/account. All fields are optional; at least one of name, email, or notifications must be provided. */
@@ -2551,6 +2551,22 @@ export interface components {
2551
2551
  };
2552
2552
  responses: never;
2553
2553
  parameters: {
2554
+ /**
2555
+ * @description Optional. Identifies which published ByteKit client sent the request, as
2556
+ * `<surface>/<version>`. The surface comes from a closed set — `api_direct`, `sdk_ts`,
2557
+ * `sdk_python`, `cli`, `mcp` — and the version affix is the emitting client's own version.
2558
+ *
2559
+ * You do not need to send this. ByteKit's own clients set it for you, and a request that
2560
+ * omits it is authenticated, rate-limited, quota-checked, billed and answered exactly as one
2561
+ * that sends it. Requests without the header are attributed to `api_direct`.
2562
+ *
2563
+ * A header that is absent, unrecognized or malformed is attributed to `api_direct` and the
2564
+ * value you sent is discarded — never stored and never logged. The header never changes how a
2565
+ * request is routed, priced or prioritised, and `User-Agent` is never used as a substitute
2566
+ * for it.
2567
+ * @example sdk_ts/1.4.0
2568
+ */
2569
+ ClientSurfaceMarker: string;
2554
2570
  FetchUrl: string;
2555
2571
  FetchFormat: "markdown" | "html";
2556
2572
  FetchCountry: string;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The published version of `@hunt-labs/bytekit-sdk`, baked in at build time.
3
+ *
4
+ * Used for the version affix of the client-surface marker (`sdk_ts/<version>`) that every
5
+ * outbound request carries — see the emit site in `client.ts`. The header name is spelled
6
+ * only there, so issue #2905's pre-merge gate 1 counts exactly one occurrence in `src/`.
7
+ */
8
+ export declare const SDK_VERSION = "0.7.0";
@@ -0,0 +1,12 @@
1
+ // GENERATED FILE — do not edit by hand.
2
+ // Regenerate with `pnpm --filter @hunt-labs/bytekit-sdk gen:version` (also chained into `build`).
3
+ // Source of truth: this package's `package.json` "version" field.
4
+ // Guarded by `src/__tests__/version-parity.test.ts` (issue #2905, failure mode E5).
5
+ /**
6
+ * The published version of `@hunt-labs/bytekit-sdk`, baked in at build time.
7
+ *
8
+ * Used for the version affix of the client-surface marker (`sdk_ts/<version>`) that every
9
+ * outbound request carries — see the emit site in `client.ts`. The header name is spelled
10
+ * only there, so issue #2905's pre-merge gate 1 counts exactly one occurrence in `src/`.
11
+ */
12
+ export const SDK_VERSION = '0.7.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hunt-labs/bytekit-sdk",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "Official TypeScript SDK for the ByteKit API",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -48,8 +48,9 @@
48
48
  "url": "https://bytekit.com/contact"
49
49
  },
50
50
  "scripts": {
51
- "build": "rm -rf dist tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo && tsc -p tsconfig.build.json && mkdir -p dist/generated && cp src/generated/api.d.ts dist/generated/api.d.ts",
51
+ "build": "pnpm gen:version && rm -rf dist tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo && tsc -p tsconfig.build.json && mkdir -p dist/generated && cp src/generated/api.d.ts dist/generated/api.d.ts",
52
52
  "gen:types": "openapi-typescript ../../docs/api/openapi.yaml -o src/generated/api.d.ts",
53
+ "gen:version": "tsx scripts/gen-version.ts",
53
54
  "gen:types-check": "pnpm gen:types && git diff --exit-code src/generated/api.d.ts",
54
55
  "generate:docs": "tsx scripts/generate-docs.ts",
55
56
  "typecheck": "tsc --noEmit",