@whittlelabs/sifter 0.4.0 → 0.4.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/bin.js +32 -22
- package/bin.js.map +2 -2
- package/package.json +1 -1
package/bin.js
CHANGED
|
@@ -15342,18 +15342,36 @@ var require_client = __commonJS({
|
|
|
15342
15342
|
var prompt_execution_1 = require_prompt_execution();
|
|
15343
15343
|
var JobsClient = class {
|
|
15344
15344
|
baseUrl;
|
|
15345
|
-
|
|
15345
|
+
apiKey;
|
|
15346
|
+
accessToken;
|
|
15347
|
+
getAccessToken;
|
|
15346
15348
|
onResponse;
|
|
15347
15349
|
constructor(config) {
|
|
15348
15350
|
this.baseUrl = config.baseUrl.replace(/\/$/, "");
|
|
15349
|
-
this.
|
|
15350
|
-
|
|
15351
|
-
|
|
15352
|
-
} else if (config.accessToken) {
|
|
15353
|
-
this.headers["Authorization"] = `Bearer ${config.accessToken}`;
|
|
15354
|
-
}
|
|
15351
|
+
this.apiKey = config.apiKey;
|
|
15352
|
+
this.accessToken = config.accessToken;
|
|
15353
|
+
this.getAccessToken = config.getAccessToken;
|
|
15355
15354
|
this.onResponse = config.onResponse;
|
|
15356
15355
|
}
|
|
15356
|
+
/**
|
|
15357
|
+
* Headers for one request. The auth header is resolved per call so a
|
|
15358
|
+
* long-lived client picks up a refreshed token from `getAccessToken`
|
|
15359
|
+
* (the manager behind it re-mints before expiry) instead of pinning the
|
|
15360
|
+
* token it happened to hold at construction.
|
|
15361
|
+
*/
|
|
15362
|
+
async buildHeaders() {
|
|
15363
|
+
const headers = { "Content-Type": "application/json" };
|
|
15364
|
+
if (this.apiKey) {
|
|
15365
|
+
headers["X-API-Key"] = this.apiKey;
|
|
15366
|
+
} else if (this.getAccessToken) {
|
|
15367
|
+
const token = await this.getAccessToken();
|
|
15368
|
+
if (token)
|
|
15369
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
15370
|
+
} else if (this.accessToken) {
|
|
15371
|
+
headers["Authorization"] = `Bearer ${this.accessToken}`;
|
|
15372
|
+
}
|
|
15373
|
+
return headers;
|
|
15374
|
+
}
|
|
15357
15375
|
// ── Attention Pools ──────────────────────────────────────────────
|
|
15358
15376
|
async createAttentionPool(options) {
|
|
15359
15377
|
return this.request("POST", "/api/attention-pools", options);
|
|
@@ -15543,19 +15561,11 @@ var require_client = __commonJS({
|
|
|
15543
15561
|
}
|
|
15544
15562
|
}
|
|
15545
15563
|
// ── HTTP plumbing ────────────────────────────────────────────────
|
|
15546
|
-
/** @internal exposed for the subscribe loop */
|
|
15547
|
-
buildUrl(path) {
|
|
15548
|
-
return `${this.baseUrl}${path}`;
|
|
15549
|
-
}
|
|
15550
|
-
/** @internal exposed for the subscribe loop */
|
|
15551
|
-
authHeaders() {
|
|
15552
|
-
return { ...this.headers };
|
|
15553
|
-
}
|
|
15554
15564
|
async request(method, path, body) {
|
|
15555
|
-
const url = this.
|
|
15565
|
+
const url = `${this.baseUrl}${path}`;
|
|
15556
15566
|
const response = await fetch(url, {
|
|
15557
15567
|
method,
|
|
15558
|
-
headers: this.
|
|
15568
|
+
headers: await this.buildHeaders(),
|
|
15559
15569
|
body: body ? JSON.stringify(body) : void 0
|
|
15560
15570
|
});
|
|
15561
15571
|
this.onResponse?.(response);
|
|
@@ -15570,8 +15580,8 @@ var require_client = __commonJS({
|
|
|
15570
15580
|
return json.data;
|
|
15571
15581
|
}
|
|
15572
15582
|
async requestPaginated(method, path) {
|
|
15573
|
-
const url = this.
|
|
15574
|
-
const response = await fetch(url, { method, headers: this.
|
|
15583
|
+
const url = `${this.baseUrl}${path}`;
|
|
15584
|
+
const response = await fetch(url, { method, headers: await this.buildHeaders() });
|
|
15575
15585
|
this.onResponse?.(response);
|
|
15576
15586
|
const json = await response.json();
|
|
15577
15587
|
if (!response.ok || !json.success) {
|
|
@@ -17862,7 +17872,7 @@ var require_shuttle = __commonJS({
|
|
|
17862
17872
|
const jobsClient = new jobs_1.JobsClient({
|
|
17863
17873
|
baseUrl: this.config.auth.jobsApiUrl,
|
|
17864
17874
|
apiKey: auth.kind === "apiKey" ? auth.apiKey : void 0,
|
|
17865
|
-
|
|
17875
|
+
getAccessToken: auth.kind === "tokenProvider" ? auth.getToken : void 0,
|
|
17866
17876
|
onResponse: enforceMinVersion
|
|
17867
17877
|
});
|
|
17868
17878
|
const registry = new registry_1.ExecutorRegistry(this.brand.executorAllowlist);
|
|
@@ -17945,7 +17955,7 @@ var require_shuttle = __commonJS({
|
|
|
17945
17955
|
});
|
|
17946
17956
|
const token = await tokens.getToken();
|
|
17947
17957
|
if (token)
|
|
17948
|
-
return { kind: "
|
|
17958
|
+
return { kind: "tokenProvider", getToken: () => tokens.getToken() };
|
|
17949
17959
|
}
|
|
17950
17960
|
if (config.auth.apiKey) {
|
|
17951
17961
|
return { kind: "apiKey", apiKey: config.auth.apiKey };
|
|
@@ -18484,7 +18494,7 @@ var import_shuttle = __toESM(require_dist4());
|
|
|
18484
18494
|
// package.json
|
|
18485
18495
|
var package_default = {
|
|
18486
18496
|
name: "@whittlelabs/sifter",
|
|
18487
|
-
version: "0.4.
|
|
18497
|
+
version: "0.4.1",
|
|
18488
18498
|
description: "Whittle Sifter: paired AI reviewer for Whittle Sift attention pools.",
|
|
18489
18499
|
bin: {
|
|
18490
18500
|
"whittle-sifter": "./dist/bin.js"
|