@whittlelabs/sifter 0.23.0 → 0.24.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/README.md CHANGED
@@ -4,8 +4,8 @@ The Whittle Sifter is a paired AI reviewer for [Whittle Sift](https://sift.whitt
4
4
 
5
5
  ## Install
6
6
 
7
- `@whittlelabs/sifter` is published publicly to npmjs.com (released by
8
- `sifter-release.yml` on a version bump):
7
+ `@whittlelabs/sifter` is published publicly to npmjs.com (released by the
8
+ delivery pipeline on a version bump):
9
9
 
10
10
  ```bash
11
11
  npm install -g @whittlelabs/sifter
package/bin.js CHANGED
@@ -15437,6 +15437,7 @@ var require_client = __commonJS({
15437
15437
  instructions: options.instructions,
15438
15438
  maxAttempts: options.maxAttempts,
15439
15439
  deadlineDuration: options.deadlineDuration,
15440
+ claimDeadlineDuration: options.claimDeadlineDuration,
15440
15441
  priority: options.priority,
15441
15442
  tags: options.tags,
15442
15443
  clientRef: options.clientRef,
@@ -18160,7 +18161,8 @@ var require_canonicalise = __commonJS({
18160
18161
  outputLabel,
18161
18162
  rendering: promptOptions.rendering,
18162
18163
  ...promptOptions.maxAttempts !== void 0 ? { maxAttempts: promptOptions.maxAttempts } : {},
18163
- ...promptOptions.deadline !== void 0 ? { deadlineDuration: promptOptions.deadline } : {}
18164
+ ...promptOptions.deadline !== void 0 ? { deadlineDuration: promptOptions.deadline } : {},
18165
+ ...promptOptions.claimDeadline !== void 0 ? { claimDeadlineDuration: promptOptions.claimDeadline } : {}
18164
18166
  };
18165
18167
  return { ...envelope(node.name, promptOptions), entryBehavior: "loom.prompt", config: config2 };
18166
18168
  }
@@ -18192,7 +18194,8 @@ var require_canonicalise = __commonJS({
18192
18194
  jobPoolRef: jobPoolDescriptor,
18193
18195
  inputs: { ...jobsCreateOptions.inputs },
18194
18196
  ...jobsCreateOptions.maxAttempts !== void 0 ? { maxAttempts: jobsCreateOptions.maxAttempts } : {},
18195
- ...jobsCreateOptions.deadline !== void 0 ? { deadlineDuration: jobsCreateOptions.deadline } : {}
18197
+ ...jobsCreateOptions.deadline !== void 0 ? { deadlineDuration: jobsCreateOptions.deadline } : {},
18198
+ ...jobsCreateOptions.claimDeadline !== void 0 ? { claimDeadlineDuration: jobsCreateOptions.claimDeadline } : {}
18196
18199
  };
18197
18200
  return { ...envelope(node.name, jobsCreateOptions), entryBehavior: "jobs.create", config };
18198
18201
  }
@@ -18983,11 +18986,36 @@ var require_client2 = __commonJS({
18983
18986
  return this.request("POST", "/api/actor-tokens", { actor });
18984
18987
  }
18985
18988
  // ── Identity ────────────────────────────────────────────────────
18989
+ /**
18990
+ * Sign up. This NEVER returns an account or a session: Keep answers 201 with
18991
+ * an email-verification challenge, which is answered at
18992
+ * POST /api/challenges/:token/response to mint a session.
18993
+ */
18986
18994
  async createAccount(email, password, name) {
18987
- return this.request("POST", "/api/accounts", { email, password, name });
18995
+ const body = await this.envelope("POST", "/api/accounts", { email, password, name });
18996
+ if (!body.challenge) {
18997
+ throw new Error("sign-up returned no challenge; the contract expects one");
18998
+ }
18999
+ return body.challenge;
18988
19000
  }
19001
+ /**
19002
+ * Sign in. Two legitimate outcomes, neither an error: a session, or a
19003
+ * challenge (MFA, unverified email). Both arrive on HTTP 200.
19004
+ */
18989
19005
  async createSession(email, password) {
18990
- return this.request("POST", "/api/sessions", { email, password });
19006
+ const body = await this.envelope("POST", "/api/sessions", { email, password });
19007
+ if (body.challenge) {
19008
+ return { kind: "challenge", challenge: body.challenge };
19009
+ }
19010
+ const data = body.data;
19011
+ if (!data?.session) {
19012
+ throw new Error("sign-in returned neither a session nor a challenge");
19013
+ }
19014
+ return { kind: "session", user: data.user, session: data.session };
19015
+ }
19016
+ /** Answer a challenge and obtain the session it was standing in for. */
19017
+ async respondToChallenge(challengeToken, type, response) {
19018
+ return this.request("POST", `/api/challenges/${encodeURIComponent(challengeToken)}/response`, { type, response });
18991
19019
  }
18992
19020
  async destroySession(refreshToken) {
18993
19021
  await this.request("DELETE", "/api/sessions", refreshToken ? { refreshToken } : void 0);
@@ -19133,6 +19161,28 @@ var require_client2 = __commonJS({
19133
19161
  return this.request("GET", `/api/users/${encodeURIComponent(userId)}/github-token`);
19134
19162
  }
19135
19163
  // ── HTTP ────────────────────────────────────────────────────────
19164
+ /**
19165
+ * Reads the response envelope WITHOUT treating `success: false` as a
19166
+ * failure. Sign-in and sign-up use it because a challenge arrives on a 2xx
19167
+ * with success:false and no error object — `request` would raise a
19168
+ * misleading "Request failed with status 200" and give the caller no way to
19169
+ * tell MFA from a bad password (whittlelabs#530). A real error still throws.
19170
+ */
19171
+ async envelope(method, path, body) {
19172
+ const response = await fetch(`${this.baseUrl}${path}`, {
19173
+ method,
19174
+ headers: this.headers,
19175
+ body: body ? JSON.stringify(body) : void 0
19176
+ });
19177
+ const json = await response.json();
19178
+ if (!response.ok || !json.success && !json.challenge) {
19179
+ const error = new Error(json.error?.message ?? `Request failed with status ${response.status}`);
19180
+ error.code = json.error?.code;
19181
+ error.statusCode = response.status;
19182
+ throw error;
19183
+ }
19184
+ return json;
19185
+ }
19136
19186
  async request(method, path, body) {
19137
19187
  const url = `${this.baseUrl}${path}`;
19138
19188
  const response = await fetch(url, {
@@ -22321,7 +22371,7 @@ var import_path = require("path");
22321
22371
  var import_promises = require("fs/promises");
22322
22372
  var import_yaml = __toESM(require_dist());
22323
22373
  var import_shuttle = __toESM(require_dist5());
22324
- var buildVersion = true ? "0.23.0" : pkg.version;
22374
+ var buildVersion = true ? "0.24.1" : pkg.version;
22325
22375
  var sifterBrand = {
22326
22376
  product: {
22327
22377
  id: "sifter",