@standardagents/builder 0.18.2 → 0.19.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/dist/index.js CHANGED
@@ -19824,15 +19824,22 @@ function addCorsHeaders(response) {
19824
19824
  return response;
19825
19825
  }
19826
19826
 
19827
- // Preserve Set-Cookie exactly. Rebuilding a Response from response.headers can
19828
- // drop cookie headers in Worker runtimes because Set-Cookie is special.
19829
- if (response.headers.has("Set-Cookie")) {
19827
+ // Skip if already has CORS headers
19828
+ if (response.headers.has("Access-Control-Allow-Origin")) {
19830
19829
  return response;
19831
19830
  }
19832
19831
 
19833
- // Skip if already has CORS headers
19834
- if (response.headers.has("Access-Control-Allow-Origin")) {
19832
+ // Prefer mutating the original Response headers. Rebuilding a Response from
19833
+ // response.headers can drop special headers such as Set-Cookie in Worker
19834
+ // runtimes, even when the header is not visible through Headers.has().
19835
+ try {
19836
+ for (const [key, value] of Object.entries(CORS_HEADERS)) {
19837
+ response.headers.set(key, value);
19838
+ }
19835
19839
  return response;
19840
+ } catch {
19841
+ // Some Responses, especially fetched upstream responses, have immutable
19842
+ // headers. Fall back to wrapping those responses.
19836
19843
  }
19837
19844
 
19838
19845
  // Create new headers with CORS added
@@ -29044,6 +29051,13 @@ ${result ?? error ?? "No result content."}${attachmentSummary}`;
29044
29051
  for (const replicaUser of snapshot.users) {
29045
29052
  const user = await this.upsertPlatformReplicaUser(replicaUser);
29046
29053
  activeUserIds.add(user.id);
29054
+ if (typeof replicaUser.session_revoked_at === "number" && Number.isFinite(replicaUser.session_revoked_at)) {
29055
+ await this.ctx.storage.sql.exec(
29056
+ `DELETE FROM sessions WHERE user_id = ? AND created_at <= ?`,
29057
+ user.id,
29058
+ Math.floor(replicaUser.session_revoked_at)
29059
+ );
29060
+ }
29047
29061
  }
29048
29062
  const activeList = Array.from(activeUserIds);
29049
29063
  if (activeList.length > 0) {