@drawbridge/drawbridge-utils 0.0.77 → 0.0.79

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/ai.cjs CHANGED
@@ -154,6 +154,14 @@ var import_drawbridge_telemetry2 = require("@drawbridge/drawbridge-telemetry");
154
154
  var logger = (0, import_drawbridge_telemetry2.createLogger)();
155
155
  var MARKUP = 1.3;
156
156
  var cost = {
157
+ // gemini-3.5-flash — verified against Google's pricing page 2026-07-09:
158
+ // $0.15 cached / $1.50 input / $9.00 output per 1M tokens (thinking billed at
159
+ // output). ~3.6x the retired 2.5-flash output rate.
160
+ "gemini-3.5-flash": {
161
+ cached: 15,
162
+ input: 150,
163
+ output: 900
164
+ },
157
165
  "gemini-2.5-flash": {
158
166
  cached: 3,
159
167
  input: 30,
@@ -254,7 +262,7 @@ var googleCircuit = circuit({
254
262
  });
255
263
  var models = {
256
264
  image: "gemini-2.5-flash-image",
257
- text: "gemini-2.5-flash"
265
+ text: "gemini-3.5-flash"
258
266
  };
259
267
  var tokensFromMetadata = (metadata) => ({
260
268
  cached: Number(metadata == null ? void 0 : metadata.cachedContentTokenCount) || 0,
package/dist/ai.d.cts CHANGED
@@ -35,9 +35,14 @@ const googleCircuit = circuit({
35
35
  timeout : 60000
36
36
  });
37
37
 
38
+ // gemini-2.5-flash was retired by Google (generateContent → 404 "no longer
39
+ // available"), taking down every generation. gemini-3.5-flash is the current
40
+ // stable flash successor. The image model is a distinct model and still live,
41
+ // but is the same retired generation — expect it to follow, and bump it here
42
+ // (plus a billing entry) the moment it starts 404ing.
38
43
  const models = {
39
44
  image : 'gemini-2.5-flash-image',
40
- text : 'gemini-2.5-flash'
45
+ text : 'gemini-3.5-flash'
41
46
  };
42
47
 
43
48
  // Map Google's usageMetadata shape into the pricing.tokens shape.
package/dist/ai.d.ts CHANGED
@@ -35,9 +35,14 @@ const googleCircuit = circuit({
35
35
  timeout : 60000
36
36
  });
37
37
 
38
+ // gemini-2.5-flash was retired by Google (generateContent → 404 "no longer
39
+ // available"), taking down every generation. gemini-3.5-flash is the current
40
+ // stable flash successor. The image model is a distinct model and still live,
41
+ // but is the same retired generation — expect it to follow, and bump it here
42
+ // (plus a billing entry) the moment it starts 404ing.
38
43
  const models = {
39
44
  image : 'gemini-2.5-flash-image',
40
- text : 'gemini-2.5-flash'
45
+ text : 'gemini-3.5-flash'
41
46
  };
42
47
 
43
48
  // Map Google's usageMetadata shape into the pricing.tokens shape.
package/dist/ai.js CHANGED
@@ -130,6 +130,14 @@ import { createLogger } from "@drawbridge/drawbridge-telemetry";
130
130
  var logger = createLogger();
131
131
  var MARKUP = 1.3;
132
132
  var cost = {
133
+ // gemini-3.5-flash — verified against Google's pricing page 2026-07-09:
134
+ // $0.15 cached / $1.50 input / $9.00 output per 1M tokens (thinking billed at
135
+ // output). ~3.6x the retired 2.5-flash output rate.
136
+ "gemini-3.5-flash": {
137
+ cached: 15,
138
+ input: 150,
139
+ output: 900
140
+ },
133
141
  "gemini-2.5-flash": {
134
142
  cached: 3,
135
143
  input: 30,
@@ -230,7 +238,7 @@ var googleCircuit = circuit({
230
238
  });
231
239
  var models = {
232
240
  image: "gemini-2.5-flash-image",
233
- text: "gemini-2.5-flash"
241
+ text: "gemini-3.5-flash"
234
242
  };
235
243
  var tokensFromMetadata = (metadata) => ({
236
244
  cached: Number(metadata == null ? void 0 : metadata.cachedContentTokenCount) || 0,
package/dist/billing.cjs CHANGED
@@ -163,6 +163,14 @@ var import_drawbridge_telemetry2 = require("@drawbridge/drawbridge-telemetry");
163
163
  var logger = (0, import_drawbridge_telemetry2.createLogger)();
164
164
  var MARKUP = 1.3;
165
165
  var cost = {
166
+ // gemini-3.5-flash — verified against Google's pricing page 2026-07-09:
167
+ // $0.15 cached / $1.50 input / $9.00 output per 1M tokens (thinking billed at
168
+ // output). ~3.6x the retired 2.5-flash output rate.
169
+ "gemini-3.5-flash": {
170
+ cached: 15,
171
+ input: 150,
172
+ output: 900
173
+ },
166
174
  "gemini-2.5-flash": {
167
175
  cached: 3,
168
176
  input: 30,
@@ -31,6 +31,14 @@ const MARKUP = 1.3;
31
31
  // Raw per-model provider rates in cents per 1,000,000 tokens — the wholesale
32
32
  // cost. Sync from LiteLLM. Never apply markup here; `pricing` derives retail.
33
33
  const cost = {
34
+ // gemini-3.5-flash — verified against Google's pricing page 2026-07-09:
35
+ // $0.15 cached / $1.50 input / $9.00 output per 1M tokens (thinking billed at
36
+ // output). ~3.6x the retired 2.5-flash output rate.
37
+ 'gemini-3.5-flash' : {
38
+ cached : 15,
39
+ input : 150,
40
+ output : 900
41
+ },
34
42
  'gemini-2.5-flash' : {
35
43
  cached : 3,
36
44
  input : 30,
package/dist/billing.d.ts CHANGED
@@ -31,6 +31,14 @@ const MARKUP = 1.3;
31
31
  // Raw per-model provider rates in cents per 1,000,000 tokens — the wholesale
32
32
  // cost. Sync from LiteLLM. Never apply markup here; `pricing` derives retail.
33
33
  const cost = {
34
+ // gemini-3.5-flash — verified against Google's pricing page 2026-07-09:
35
+ // $0.15 cached / $1.50 input / $9.00 output per 1M tokens (thinking billed at
36
+ // output). ~3.6x the retired 2.5-flash output rate.
37
+ 'gemini-3.5-flash' : {
38
+ cached : 15,
39
+ input : 150,
40
+ output : 900
41
+ },
34
42
  'gemini-2.5-flash' : {
35
43
  cached : 3,
36
44
  input : 30,
package/dist/billing.js CHANGED
@@ -134,6 +134,14 @@ import { createLogger } from "@drawbridge/drawbridge-telemetry";
134
134
  var logger = createLogger();
135
135
  var MARKUP = 1.3;
136
136
  var cost = {
137
+ // gemini-3.5-flash — verified against Google's pricing page 2026-07-09:
138
+ // $0.15 cached / $1.50 input / $9.00 output per 1M tokens (thinking billed at
139
+ // output). ~3.6x the retired 2.5-flash output rate.
140
+ "gemini-3.5-flash": {
141
+ cached: 15,
142
+ input: 150,
143
+ output: 900
144
+ },
137
145
  "gemini-2.5-flash": {
138
146
  cached: 3,
139
147
  input: 30,
package/dist/email.cjs ADDED
@@ -0,0 +1,42 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // lib/email.js
20
+ var email_exports = {};
21
+ __export(email_exports, {
22
+ toCanonicalEmail: () => toCanonicalEmail
23
+ });
24
+ module.exports = __toCommonJS(email_exports);
25
+ var GMAIL_DOMAINS = /* @__PURE__ */ new Set(["gmail.com", "googlemail.com"]);
26
+ var toCanonicalEmail = (value) => {
27
+ if (!value || typeof value !== "string") return null;
28
+ const email = value.trim().toLowerCase();
29
+ const at = email.lastIndexOf("@");
30
+ if (at < 1 || at === email.length - 1) return null;
31
+ let local = email.slice(0, at);
32
+ const domain = email.slice(at + 1);
33
+ const plus = local.indexOf("+");
34
+ if (plus > 0) local = local.slice(0, plus);
35
+ if (GMAIL_DOMAINS.has(domain)) local = local.replaceAll(".", "");
36
+ if (!local) return null;
37
+ return local + "@" + domain;
38
+ };
39
+ // Annotate the CommonJS export names for ESM import in node:
40
+ 0 && (module.exports = {
41
+ toCanonicalEmail
42
+ });
@@ -0,0 +1,36 @@
1
+ // Gmail treats dots in the local part as insignificant; these are the only
2
+ // domains where dot-stripping is safe.
3
+ const GMAIL_DOMAINS = new Set( [ 'gmail.com', 'googlemail.com' ] );
4
+
5
+ // Canonicalize an email for identity matching (NOT for delivery — always send
6
+ // to the raw address the user typed): trim, lowercase, strip the +tag
7
+ // subaddress, and strip local-part dots on Gmail-family domains. Heuristic by
8
+ // design — a canonical collision only ever merges identities, never loses a
9
+ // deliverable address, so lenient is the right bias. Unparseable input → null.
10
+ const toCanonicalEmail = ( value ) => {
11
+
12
+ if( ! value || typeof value !== 'string' ) return null;
13
+
14
+ const email = value.trim().toLowerCase();
15
+
16
+ const at = email.lastIndexOf( '@' );
17
+
18
+ if( at < 1 || at === email.length - 1 ) return null;
19
+
20
+ let local = email.slice( 0, at );
21
+ const domain = email.slice( at + 1 );
22
+
23
+ // index 0 would empty the local part — leave a leading plus alone
24
+ const plus = local.indexOf( '+' );
25
+
26
+ if( plus > 0 ) local = local.slice( 0, plus );
27
+
28
+ if( GMAIL_DOMAINS.has( domain ) ) local = local.replaceAll( '.', '' );
29
+
30
+ if( ! local ) return null;
31
+
32
+ return local + '@' + domain;
33
+
34
+ };
35
+
36
+ export { toCanonicalEmail };
@@ -0,0 +1,36 @@
1
+ // Gmail treats dots in the local part as insignificant; these are the only
2
+ // domains where dot-stripping is safe.
3
+ const GMAIL_DOMAINS = new Set( [ 'gmail.com', 'googlemail.com' ] );
4
+
5
+ // Canonicalize an email for identity matching (NOT for delivery — always send
6
+ // to the raw address the user typed): trim, lowercase, strip the +tag
7
+ // subaddress, and strip local-part dots on Gmail-family domains. Heuristic by
8
+ // design — a canonical collision only ever merges identities, never loses a
9
+ // deliverable address, so lenient is the right bias. Unparseable input → null.
10
+ const toCanonicalEmail = ( value ) => {
11
+
12
+ if( ! value || typeof value !== 'string' ) return null;
13
+
14
+ const email = value.trim().toLowerCase();
15
+
16
+ const at = email.lastIndexOf( '@' );
17
+
18
+ if( at < 1 || at === email.length - 1 ) return null;
19
+
20
+ let local = email.slice( 0, at );
21
+ const domain = email.slice( at + 1 );
22
+
23
+ // index 0 would empty the local part — leave a leading plus alone
24
+ const plus = local.indexOf( '+' );
25
+
26
+ if( plus > 0 ) local = local.slice( 0, plus );
27
+
28
+ if( GMAIL_DOMAINS.has( domain ) ) local = local.replaceAll( '.', '' );
29
+
30
+ if( ! local ) return null;
31
+
32
+ return local + '@' + domain;
33
+
34
+ };
35
+
36
+ export { toCanonicalEmail };
package/dist/email.js ADDED
@@ -0,0 +1,18 @@
1
+ // lib/email.js
2
+ var GMAIL_DOMAINS = /* @__PURE__ */ new Set(["gmail.com", "googlemail.com"]);
3
+ var toCanonicalEmail = (value) => {
4
+ if (!value || typeof value !== "string") return null;
5
+ const email = value.trim().toLowerCase();
6
+ const at = email.lastIndexOf("@");
7
+ if (at < 1 || at === email.length - 1) return null;
8
+ let local = email.slice(0, at);
9
+ const domain = email.slice(at + 1);
10
+ const plus = local.indexOf("+");
11
+ if (plus > 0) local = local.slice(0, plus);
12
+ if (GMAIL_DOMAINS.has(domain)) local = local.replaceAll(".", "");
13
+ if (!local) return null;
14
+ return local + "@" + domain;
15
+ };
16
+ export {
17
+ toCanonicalEmail
18
+ };
package/dist/fetch.cjs CHANGED
@@ -29,6 +29,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  // lib/fetch.js
30
30
  var fetch_exports = {};
31
31
  __export(fetch_exports, {
32
+ isTransientError: () => isTransientError,
32
33
  queryString: () => queryString,
33
34
  request: () => request,
34
35
  setMemoryToken: () => setMemoryToken
@@ -109,8 +110,13 @@ var request = async ({
109
110
  }
110
111
  return res;
111
112
  };
113
+ var isTransientError = (error) => {
114
+ const status = error == null ? void 0 : error.status;
115
+ return !status || status === 429 || status >= 500;
116
+ };
112
117
  // Annotate the CommonJS export names for ESM import in node:
113
118
  0 && (module.exports = {
119
+ isTransientError,
114
120
  queryString,
115
121
  request,
116
122
  setMemoryToken
package/dist/fetch.d.cts CHANGED
@@ -112,4 +112,19 @@ const request = async ({
112
112
 
113
113
  };
114
114
 
115
- export { queryString, request, setMemoryToken };
115
+ // Classifies an error thrown by request() which carries `.status` from the
116
+ // HTTP response, or no status for a network / parse failure. Transient errors
117
+ // ( rate limits, server errors, connection blips ) may succeed on retry, so
118
+ // callers should offer a reload rather than treating them as an auth failure
119
+ // ( → sign-in / 401 ) or a missing resource ( → 404 ). Reserving those hard
120
+ // outcomes for genuine 4xx keeps a rate-limited request from bouncing between
121
+ // error screens in a redirect loop.
122
+ const isTransientError = ( error ) => {
123
+
124
+ const status = error?.status;
125
+
126
+ return ! status || status === 429 || status >= 500;
127
+
128
+ };
129
+
130
+ export { isTransientError, queryString, request, setMemoryToken };
package/dist/fetch.d.ts CHANGED
@@ -112,4 +112,19 @@ const request = async ({
112
112
 
113
113
  };
114
114
 
115
- export { queryString, request, setMemoryToken };
115
+ // Classifies an error thrown by request() which carries `.status` from the
116
+ // HTTP response, or no status for a network / parse failure. Transient errors
117
+ // ( rate limits, server errors, connection blips ) may succeed on retry, so
118
+ // callers should offer a reload rather than treating them as an auth failure
119
+ // ( → sign-in / 401 ) or a missing resource ( → 404 ). Reserving those hard
120
+ // outcomes for genuine 4xx keeps a rate-limited request from bouncing between
121
+ // error screens in a redirect loop.
122
+ const isTransientError = ( error ) => {
123
+
124
+ const status = error?.status;
125
+
126
+ return ! status || status === 429 || status >= 500;
127
+
128
+ };
129
+
130
+ export { isTransientError, queryString, request, setMemoryToken };
package/dist/fetch.js CHANGED
@@ -74,7 +74,12 @@ var request = async ({
74
74
  }
75
75
  return res;
76
76
  };
77
+ var isTransientError = (error) => {
78
+ const status = error == null ? void 0 : error.status;
79
+ return !status || status === 429 || status >= 500;
80
+ };
77
81
  export {
82
+ isTransientError,
78
83
  queryString,
79
84
  request,
80
85
  setMemoryToken
package/package.json CHANGED
@@ -47,6 +47,11 @@
47
47
  "import": "./dist/color.js",
48
48
  "require": "./dist/color.cjs"
49
49
  },
50
+ "./email": {
51
+ "types": "./dist/email.d.ts",
52
+ "import": "./dist/email.js",
53
+ "require": "./dist/email.cjs"
54
+ },
50
55
  "./encrypt": {
51
56
  "types": "./dist/encrypt.d.ts",
52
57
  "import": "./dist/encrypt.js",
@@ -159,5 +164,5 @@
159
164
  "test": "node --test test/"
160
165
  },
161
166
  "types": "dist/index.d.ts",
162
- "version": "0.0.77"
167
+ "version": "0.0.79"
163
168
  }