@curless/hotel-storefront 0.92.0 → 0.94.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.
Files changed (59) hide show
  1. package/README.md +5 -2
  2. package/dist/card.generated.d.ts +1 -1
  3. package/dist/card.generated.js +2 -2
  4. package/dist/card.generated.js.map +1 -1
  5. package/dist/cidr.d.ts +3 -21
  6. package/dist/cidr.d.ts.map +1 -1
  7. package/dist/cidr.js +9 -56
  8. package/dist/cidr.js.map +1 -1
  9. package/dist/index.js +11 -1
  10. package/dist/index.js.map +1 -1
  11. package/dist/openai-conversation.d.ts +50 -0
  12. package/dist/openai-conversation.d.ts.map +1 -0
  13. package/dist/openai-conversation.js +83 -0
  14. package/dist/openai-conversation.js.map +1 -0
  15. package/dist/out-of-list.d.ts +74 -0
  16. package/dist/out-of-list.d.ts.map +1 -0
  17. package/dist/out-of-list.js +150 -0
  18. package/dist/out-of-list.js.map +1 -0
  19. package/dist/ranges-check-cli.js +19 -7
  20. package/dist/ranges-check-cli.js.map +1 -1
  21. package/dist/ranges-check.d.ts +19 -15
  22. package/dist/ranges-check.d.ts.map +1 -1
  23. package/dist/ranges-check.js +57 -109
  24. package/dist/ranges-check.js.map +1 -1
  25. package/dist/server.d.ts +14 -18
  26. package/dist/server.d.ts.map +1 -1
  27. package/dist/server.js +100 -148
  28. package/dist/server.js.map +1 -1
  29. package/dist/source-allowlist.d.ts +4 -10
  30. package/dist/source-allowlist.d.ts.map +1 -1
  31. package/dist/source-allowlist.js +28 -45
  32. package/dist/source-allowlist.js.map +1 -1
  33. package/dist/source-ranges.d.ts.map +1 -1
  34. package/dist/source-ranges.js +23 -418
  35. package/dist/source-ranges.js.map +1 -1
  36. package/dist/source-refusal-log.d.ts +13 -0
  37. package/dist/source-refusal-log.d.ts.map +1 -0
  38. package/dist/source-refusal-log.js +50 -0
  39. package/dist/source-refusal-log.js.map +1 -0
  40. package/dist/tools/compare.d.ts.map +1 -1
  41. package/dist/tools/compare.js +5 -0
  42. package/dist/tools/compare.js.map +1 -1
  43. package/dist/tools/hotel-bookable.d.ts +13 -0
  44. package/dist/tools/hotel-bookable.d.ts.map +1 -1
  45. package/dist/tools/hotel-bookable.js +22 -0
  46. package/dist/tools/hotel-bookable.js.map +1 -1
  47. package/dist/usage/boot.d.ts +3 -0
  48. package/dist/usage/boot.d.ts.map +1 -1
  49. package/dist/usage/boot.js +2 -1
  50. package/dist/usage/boot.js.map +1 -1
  51. package/dist/usage/platform.d.ts +7 -1
  52. package/dist/usage/platform.d.ts.map +1 -1
  53. package/dist/usage/platform.js +6 -2
  54. package/dist/usage/platform.js.map +1 -1
  55. package/dist/usage/recorder.d.ts +2 -0
  56. package/dist/usage/recorder.d.ts.map +1 -1
  57. package/dist/usage/recorder.js +1 -0
  58. package/dist/usage/recorder.js.map +1 -1
  59. package/package.json +2 -1
@@ -1 +1 @@
1
- {"version":3,"file":"card.generated.js","sourceRoot":"","sources":["../src/card.generated.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,wEAAwE;AACxE,gFAAgF;AAChF,4DAA4D;AAC5D,MAAM,CAAC,MAAM,eAAe,GAAW,MAAM,CAAC,IAAI,CAChD,s1g5DAAs1g5D,EACt1g5D,QAAQ,CACT,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAEnB,6GAA6G;AAC7G,MAAM,CAAC,MAAM,qBAAqB,GAChC,kEAAkE,CAAC;AAErE,0GAA0G;AAC1G,MAAM,CAAC,MAAM,qBAAqB,GAChC,iLAAiL,CAAC"}
1
+ {"version":3,"file":"card.generated.js","sourceRoot":"","sources":["../src/card.generated.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,wEAAwE;AACxE,gFAAgF;AAChF,4DAA4D;AAC5D,MAAM,CAAC,MAAM,eAAe,GAAW,MAAM,CAAC,IAAI,CAChD,8my5DAA8my5D,EAC9my5D,QAAQ,CACT,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAEnB,6GAA6G;AAC7G,MAAM,CAAC,MAAM,qBAAqB,GAChC,kEAAkE,CAAC;AAErE,0GAA0G;AAC1G,MAAM,CAAC,MAAM,qBAAqB,GAChC,iLAAiL,CAAC"}
package/dist/cidr.d.ts CHANGED
@@ -1,25 +1,7 @@
1
1
  import { type Address, parseAddress } from '@curless/connector-usage';
2
- export { type Address, parseAddress };
3
- /** A range: an address and how many of its leading bits are fixed. */
4
- export type Cidr = {
5
- v: 4 | 6;
6
- net: bigint;
7
- bits: number;
8
- };
9
- /**
10
- * A range written `address/prefix`, or one address alone (a /32 or /128) - or
11
- * undefined if it is not written exactly. See the top of this file.
12
- *
13
- * ⚠️ A RANGE INSIDE THE IPv4-MAPPED BLOCK IS THAT IPv4 RANGE (`::ffff:192.0.2.0/120`
14
- * is 192.0.2.0/24; `::ffff:0:0/96` is 0.0.0.0/0), as an address there is that
15
- * IPv4 address (`parseAddress`) - so every rule about IPv4 ranges, such as how
16
- * wide `extraCidrs` may be, sees it as what it is. Any other IPv6 range holds
17
- * IPv6 addresses only: `::/0` and `::/64` hold no IPv4 address (audit P2-3: they
18
- * did, through the mapped block, and let in every IPv4 address).
19
- */
20
- export declare const parseCidr: (raw: string) => Cidr | undefined;
21
- /** Whether `a` is inside `c` - only ever within one family (see `parseCidr`). */
22
- export declare const inCidr: (a: Address, c: Cidr) => boolean;
2
+ import { type Cidr, inCidr, parseCidr } from '@curless/platform-ranges';
3
+ export { inCidr, parseAddress, parseCidr };
4
+ export type { Address, Cidr };
23
5
  /** A private, loopback or link-local address - one only our own network can come from. */
24
6
  export declare const isPrivateAddress: (a: Address) => boolean;
25
7
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"cidr.d.ts","sourceRoot":"","sources":["../src/cidr.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEtE,OAAO,EAAE,KAAK,OAAO,EAAE,YAAY,EAAE,CAAC;AAEtC,sEAAsE;AACtE,MAAM,MAAM,IAAI,GAAG;IAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAU3D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,KAAG,IAAI,GAAG,SAkB9C,CAAC;AAEF,iFAAiF;AACjF,eAAO,MAAM,MAAM,GAAI,GAAG,OAAO,EAAE,GAAG,IAAI,KAAG,OACS,CAAC;AAavD,0FAA0F;AAC1F,eAAO,MAAM,gBAAgB,GAAI,GAAG,OAAO,KAAG,OAA4C,CAAC;AAE3F;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,GAAG,OAAO,KAAG,MAQ7C,CAAC;AAEF,8FAA8F;AAC9F,eAAO,MAAM,aAAa,GAAI,GAAG,OAAO,KAAG,MAK1B,CAAC"}
1
+ {"version":3,"file":"cidr.d.ts","sourceRoot":"","sources":["../src/cidr.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAExE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC;AAC3C,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAa9B,0FAA0F;AAC1F,eAAO,MAAM,gBAAgB,GAAI,GAAG,OAAO,KAAG,OAA4C,CAAC;AAE3F;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,GAAG,OAAO,KAAG,MAQ7C,CAAC;AAEF,8FAA8F;AAC9F,eAAO,MAAM,aAAa,GAAI,GAAG,OAAO,KAAG,MAK1B,CAAC"}
package/dist/cidr.js CHANGED
@@ -1,60 +1,13 @@
1
- // Ranges, IPv4 and IPv6, and what to do with an address once it is read. The
2
- // reading itself (`parseAddress`, `Address`) is the one in
3
- // @curless/connector-usage, shared with the country tables; a test
4
- // (__tests__/usage/address-parsing.test.ts) holds it to how every allowlist
5
- // range's edges were read when this file had its own copy.
6
- //
7
- // ⚠️ STRICT ON PURPOSE. A range that is mistyped in a config is a range that
8
- // lets the wrong people in or keeps the right ones out, found out only when
9
- // somebody complains. So a range is refused unless it is written exactly:
10
- // four decimal parts with no leading zeros, a prefix within 0-32 / 0-128, and
11
- // no bits set past the prefix (192.0.2.1/24 is a typo for one of two things,
12
- // and we cannot know which).
1
+ // Addresses and ranges, IPv4 and IPv6. ONE COPY EACH, kept elsewhere and re-exported
2
+ // here under the names this package has always had (lib.ts hands them on):
3
+ // parseAddress, Address - @curless/connector-usage (src/ip.ts)
4
+ // parseCidr, inCidr, Cidr - @curless/platform-ranges (src/cidr.ts), which holds the
5
+ // rules for what a range written exactly is
6
+ // What stays here is what only this package uses: private addresses, and how an
7
+ // address is shown on a log line.
13
8
  import { parseAddress } from '@curless/connector-usage';
14
- export { parseAddress };
15
- const MAPPED_PREFIX = 0xffffn << 32n;
16
- const width = (v) => (v === 4 ? 32 : 128);
17
- const maskOf = (v, bits) => {
18
- const w = width(v);
19
- return bits === 0 ? 0n : ((1n << BigInt(bits)) - 1n) << BigInt(w - bits);
20
- };
21
- /**
22
- * A range written `address/prefix`, or one address alone (a /32 or /128) - or
23
- * undefined if it is not written exactly. See the top of this file.
24
- *
25
- * ⚠️ A RANGE INSIDE THE IPv4-MAPPED BLOCK IS THAT IPv4 RANGE (`::ffff:192.0.2.0/120`
26
- * is 192.0.2.0/24; `::ffff:0:0/96` is 0.0.0.0/0), as an address there is that
27
- * IPv4 address (`parseAddress`) - so every rule about IPv4 ranges, such as how
28
- * wide `extraCidrs` may be, sees it as what it is. Any other IPv6 range holds
29
- * IPv6 addresses only: `::/0` and `::/64` hold no IPv4 address (audit P2-3: they
30
- * did, through the mapped block, and let in every IPv4 address).
31
- */
32
- export const parseCidr = (raw) => {
33
- const s = raw.trim();
34
- const slash = s.indexOf('/');
35
- const addressText = slash < 0 ? s : s.slice(0, slash);
36
- if (addressText.includes('%') || addressText.includes('['))
37
- return undefined;
38
- const a = parseAddress(addressText);
39
- if (!a)
40
- return undefined;
41
- const v = addressText.includes(':') ? 6 : 4;
42
- const n = v === 6 && a.v === 4 ? a.n | MAPPED_PREFIX : a.n;
43
- const prefixText = slash < 0 ? String(width(v)) : s.slice(slash + 1);
44
- if (!/^(0|[1-9]\d{0,2})$/.test(prefixText))
45
- return undefined;
46
- const bits = Number(prefixText);
47
- if (bits > width(v))
48
- return undefined;
49
- if ((n & ~maskOf(v, bits)) !== 0n)
50
- return undefined;
51
- if (v === 6 && bits >= 96 && n >> 32n === MAPPED_PREFIX >> 32n) {
52
- return { v: 4, net: n & 0xffffffffn, bits: bits - 96 };
53
- }
54
- return { v, net: n, bits };
55
- };
56
- /** Whether `a` is inside `c` - only ever within one family (see `parseCidr`). */
57
- export const inCidr = (a, c) => a.v === c.v && (a.n & maskOf(c.v, c.bits)) === c.net;
9
+ import { inCidr, parseCidr } from '@curless/platform-ranges';
10
+ export { inCidr, parseAddress, parseCidr };
58
11
  const PRIVATE = [
59
12
  '10.0.0.0/8',
60
13
  '172.16.0.0/12',
package/dist/cidr.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cidr.js","sourceRoot":"","sources":["../src/cidr.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,2DAA2D;AAC3D,mEAAmE;AACnE,4EAA4E;AAC5E,2DAA2D;AAC3D,EAAE;AACF,6EAA6E;AAC7E,4EAA4E;AAC5E,0EAA0E;AAC1E,8EAA8E;AAC9E,6EAA6E;AAC7E,6BAA6B;AAE7B,OAAO,EAAgB,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAEtE,OAAO,EAAgB,YAAY,EAAE,CAAC;AAKtC,MAAM,aAAa,GAAG,OAAO,IAAI,GAAG,CAAC;AAErC,MAAM,KAAK,GAAG,CAAC,CAAQ,EAAE,EAAE,CA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EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CACvD,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC"}
package/dist/index.js CHANGED
@@ -32,7 +32,10 @@ if (checking) {
32
32
  });
33
33
  process.exit(ok ? 0 : 1);
34
34
  }
35
- const { app, brand, deps, sources, flush, drain } = buildServer({ config, configPath });
35
+ const { app, brand, deps, sources, platformRanges, flush, drain } = buildServer({
36
+ config,
37
+ configPath,
38
+ });
36
39
  const port = Number(process.env.PORT ?? 8790);
37
40
  /** Inside the 60 seconds compose gives a stopping container (`stop_grace_period`). */
38
41
  const DRAIN_MS = 50_000;
@@ -50,11 +53,18 @@ for (const signal of ['SIGTERM', 'SIGINT']) {
50
53
  });
51
54
  });
52
55
  }
56
+ // OpenAI's and Anthropic's ranges: read now from their two official URLs and every 24 hours
57
+ // (@curless/platform-ranges). Started here, not in buildServer: a test builds servers and
58
+ // must not reach the network. A failed read leaves the list in use, and is said.
59
+ void platformRanges.start();
53
60
  serve({ fetch: app.fetch, port }, (info) => {
54
61
  console.log(`${config.server.title} — ${brand.vocab.demo ? 'DEMONSTRATION DATA' : 'live'} — hotel-storefront ${VERSION} on :${info.port}`);
55
62
  console.log(` mcp POST ${config.urls.publicUrl ?? config.urls.appUrl}/mcp`);
56
63
  console.log(` tools ${[...(deps.offered ?? Object.values(brand.tools))].join(', ')}`);
57
64
  // Who may reach /mcp (source-allowlist.ts) - said at every start, so a log shows which mode ran.
58
65
  console.log(` source ${sources ? sources.summary : 'off (anyone may reach /mcp)'}`);
66
+ for (const l of Object.values(platformRanges.status())) {
67
+ console.log(` ranges ${l.platform}: ${l.count} from ${l.from}, ${l.fetchedAt}${l.version ? `, version ${l.version}` : ''}`);
68
+ }
59
69
  });
60
70
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OA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AC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzF,iGAAiG;IACjG,OAAO,CAAC,GAAG,CAAC,aAAa,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,6BAA6B,EAAE,CAAC,CAAC;IACtF,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC;QACvD,OAAO,CAAC,GAAG,CACT,aAAa,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CACjH,CAAC;IACJ,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * ChatGPT's conversation id, as it is taken (0.75.1): 16 to 256 characters, every one
3
+ * printable ASCII other than the space (0x21-0x7E). ChatGPT sends 79 opaque ones, one
4
+ * per conversation (moody's access log, docs/shopify-connectors.md). Anything else -
5
+ * shorter, longer, a space, a control character or a non-ASCII one, or two headers
6
+ * joined with ", " - is not taken, and the call is keyed by its connection as before.
7
+ */
8
+ export declare const OPENAI_SESSION_SHAPE: RegExp;
9
+ /** What a ChatGPT conversation's key starts with - a session id we issue (a UUID) never does. */
10
+ export declare const OPENAI_KEY_PREFIX = "oai:";
11
+ /**
12
+ ⚠️ ONE CHATGPT CONVERSATION, ONE KEY (0.75.1, 总线程 11-18). ChatGPT opens a new MCP
13
+ connection - a new `initialize`, a new `Mcp-Session-Id` - for every tool call, so a
14
+ conversation keyed by its connection was a new one on every card: the sign-in, the
15
+ membership links and the trip of the card before were not on the next (k=3OUE2Bfr,
16
+ then k=BHb9E1dS, in one conversation). Every call ChatGPT makes - the model's and the
17
+ card's - carries `X-OpenAI-Session`, its pseudonymous id of the conversation, so that
18
+ is the conversation's key - on three conditions, or the call is keyed as before:
19
+ - the request reached Caddy from one of OpenAI's published ranges (`OPENAI`), by
20
+ `sourceOf` ALONE: the last `X-Forwarded-For` entry, which Caddy writes (it has no
21
+ trusted_proxies, so whatever the caller sent there is replaced), or the connection's
22
+ own address where that is public. NEVER `X-Caller-Forwarded-For` - Caddy's verbatim
23
+ copy of the caller's own header - or any other header the caller writes: the
24
+ header's value is not a secret (OpenAI sends it to the connectors a conversation
25
+ uses; whether it differs per connector is not documented), the address it is
26
+ called from is what nobody else has;
27
+ - the value has the shape of ChatGPT's (`OPENAI_SESSION_SHAPE`);
28
+ - the client did not say it draws no card: a client in words carries its
29
+ conversation by its id, in words (`Sessions.bind`), and that is left as it is.
30
+ The key is `oai:` and 32 hex characters of an HMAC of the value - never the value
31
+ itself, in a key, a log line or the state directory - under a key of its own, made
32
+ from `againKey` with a label: kept in the state directory, so a restart still finds
33
+ the conversation; unknown to anyone who reads the header elsewhere. Then `tripKey`,
34
+ as any conversation's.
35
+ `HOTEL_OPENAI_CONVERSATION=off` turns it off: every call keyed by its connection again.
36
+
37
+ *
38
+ * ⚠️ "FROM OPENAI'S RANGES" IS THE RUNNING LIST of @curless/platform-ranges (read daily), and
39
+ * a header from anywhere else is STILL NOT TAKEN (2026-11-27, out-of-list.ts): it is counted
40
+ * and logged, never accepted - a header anyone can copy must not make them the conversation.
41
+ */
42
+ export declare const makeOpenAiConversation: (o: {
43
+ /** `HOTEL_OPENAI_CONVERSATION` is not `off`. */
44
+ enabled: boolean;
45
+ againKey: string;
46
+ keyBrand: string;
47
+ now: () => number;
48
+ fromOpenAi: (address: string | undefined) => boolean;
49
+ }) => (header: string | undefined, address: string | undefined, onOutside: () => void) => string | undefined;
50
+ //# sourceMappingURL=openai-conversation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-conversation.d.ts","sourceRoot":"","sources":["../src/openai-conversation.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,QAA0B,CAAC;AAC5D,iGAAiG;AACjG,eAAO,MAAM,iBAAiB,SAAS,CAAC;AAIxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,sBAAsB,GAAI,GAAG;IACxC,gDAAgD;IAChD,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,MAAM,CAAC;IAClB,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC;CACtD,MAUG,QAAQ,MAAM,GAAG,SAAS,EAC1B,SAAS,MAAM,GAAG,SAAS,EAC3B,WAAW,MAAM,IAAI,KACpB,MAAM,GAAG,SAyBb,CAAC"}
@@ -0,0 +1,83 @@
1
+ // ChatGPT's conversation, from its `X-OpenAI-Session` header - taken only from OpenAI's own
2
+ // addresses (server.ts calls `takeOpenAiConversation` for each tool call).
3
+ import { createHmac } from 'node:crypto';
4
+ import { tripKey } from './trip.js';
5
+ /**
6
+ * ChatGPT's conversation id, as it is taken (0.75.1): 16 to 256 characters, every one
7
+ * printable ASCII other than the space (0x21-0x7E). ChatGPT sends 79 opaque ones, one
8
+ * per conversation (moody's access log, docs/shopify-connectors.md). Anything else -
9
+ * shorter, longer, a space, a control character or a non-ASCII one, or two headers
10
+ * joined with ", " - is not taken, and the call is keyed by its connection as before.
11
+ */
12
+ export const OPENAI_SESSION_SHAPE = /^[\x21-\x7e]{16,256}$/;
13
+ /** What a ChatGPT conversation's key starts with - a session id we issue (a UUID) never does. */
14
+ export const OPENAI_KEY_PREFIX = 'oai:';
15
+ /** How often, at most, the count of `X-OpenAI-Session` headers not taken is logged. */
16
+ const OPENAI_SKIPPED_LOG_MS = 10 * 60_000;
17
+ /**
18
+ ⚠️ ONE CHATGPT CONVERSATION, ONE KEY (0.75.1, 总线程 11-18). ChatGPT opens a new MCP
19
+ connection - a new `initialize`, a new `Mcp-Session-Id` - for every tool call, so a
20
+ conversation keyed by its connection was a new one on every card: the sign-in, the
21
+ membership links and the trip of the card before were not on the next (k=3OUE2Bfr,
22
+ then k=BHb9E1dS, in one conversation). Every call ChatGPT makes - the model's and the
23
+ card's - carries `X-OpenAI-Session`, its pseudonymous id of the conversation, so that
24
+ is the conversation's key - on three conditions, or the call is keyed as before:
25
+ - the request reached Caddy from one of OpenAI's published ranges (`OPENAI`), by
26
+ `sourceOf` ALONE: the last `X-Forwarded-For` entry, which Caddy writes (it has no
27
+ trusted_proxies, so whatever the caller sent there is replaced), or the connection's
28
+ own address where that is public. NEVER `X-Caller-Forwarded-For` - Caddy's verbatim
29
+ copy of the caller's own header - or any other header the caller writes: the
30
+ header's value is not a secret (OpenAI sends it to the connectors a conversation
31
+ uses; whether it differs per connector is not documented), the address it is
32
+ called from is what nobody else has;
33
+ - the value has the shape of ChatGPT's (`OPENAI_SESSION_SHAPE`);
34
+ - the client did not say it draws no card: a client in words carries its
35
+ conversation by its id, in words (`Sessions.bind`), and that is left as it is.
36
+ The key is `oai:` and 32 hex characters of an HMAC of the value - never the value
37
+ itself, in a key, a log line or the state directory - under a key of its own, made
38
+ from `againKey` with a label: kept in the state directory, so a restart still finds
39
+ the conversation; unknown to anyone who reads the header elsewhere. Then `tripKey`,
40
+ as any conversation's.
41
+ `HOTEL_OPENAI_CONVERSATION=off` turns it off: every call keyed by its connection again.
42
+
43
+ *
44
+ * ⚠️ "FROM OPENAI'S RANGES" IS THE RUNNING LIST of @curless/platform-ranges (read daily), and
45
+ * a header from anywhere else is STILL NOT TAKEN (2026-11-27, out-of-list.ts): it is counted
46
+ * and logged, never accepted - a header anyone can copy must not make them the conversation.
47
+ */
48
+ export const makeOpenAiConversation = (o) => {
49
+ const mac = createHmac('sha256', o.againKey).update('hotel-openai-conversation-v1').digest();
50
+ /** Headers not taken since the line that last said so - counts only, never a value or an address. */
51
+ const skipped = { outside: 0, shape: 0, loggedAt: Number.NEGATIVE_INFINITY };
52
+ /**
53
+ * The conversation's key for a call that carried `header` from `address` - or undefined
54
+ * (keyed by its connection as before). `onOutside` is told when the header was not taken
55
+ * for the address alone.
56
+ */
57
+ return (header, address, onOutside) => {
58
+ if (!o.enabled || header === undefined)
59
+ return undefined;
60
+ const why = !o.fromOpenAi(address)
61
+ ? 'outside'
62
+ : !OPENAI_SESSION_SHAPE.test(header)
63
+ ? 'shape'
64
+ : undefined;
65
+ if (why) {
66
+ // So a list of OpenAI's ranges that has fallen behind shows up as lines and as a count.
67
+ if (why === 'outside')
68
+ onOutside();
69
+ skipped[why] += 1;
70
+ const t = o.now();
71
+ if (t - skipped.loggedAt >= OPENAI_SKIPPED_LOG_MS) {
72
+ console.log(`[mcp] x-openai-session not taken: outside OpenAI's ranges=${skipped.outside} not its shape=${skipped.shape}`);
73
+ skipped.outside = 0;
74
+ skipped.shape = 0;
75
+ skipped.loggedAt = t;
76
+ }
77
+ return undefined;
78
+ }
79
+ const h = createHmac('sha256', mac).update(header).digest('hex').slice(0, 32);
80
+ return tripKey(`${OPENAI_KEY_PREFIX}${h}`, o.keyBrand);
81
+ };
82
+ };
83
+ //# sourceMappingURL=openai-conversation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai-conversation.js","sourceRoot":"","sources":["../src/openai-conversation.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2EAA2E;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,uBAAuB,CAAC;AAC5D,iGAAiG;AACjG,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACxC,uFAAuF;AACvF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KAAK,GAAG,CAAC,CAAC;gBAClB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;YACvB,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,MAAM,CAAC,GAAG,UAAU,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC9E,OAAO,OAAO,CAAC,GAAG,iBAAiB,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;IACzD,CAAC,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,74 @@
1
+ import { type PlatformRanges } from '@curless/platform-ranges';
2
+ import { type Platform } from './usage/platform.js';
3
+ export type OutOfListCheck = 'card-source' | 'openai-session' | 'openai-trip';
4
+ export type OutOfListOutcome = 'handled' | 'refused';
5
+ /** Lines logged per minute, all checks together; every call is still counted. */
6
+ export declare const OUT_OF_LIST_LOGS_PER_MINUTE = 30;
7
+ /** A call from outside the lists reads the lists again - at most this often. */
8
+ export declare const OUT_OF_LIST_REFRESH_GAP_MS: number;
9
+ export type OutOfListCall = {
10
+ check: OutOfListCheck;
11
+ outcome: OutOfListOutcome;
12
+ tool: string | undefined;
13
+ /** The address our proxy saw - never written down; only its network is. */
14
+ address: string | undefined;
15
+ client: string | undefined;
16
+ userAgent: string | undefined;
17
+ /** The request carried `X-OpenAI-Session`. */
18
+ openaiSession: boolean;
19
+ };
20
+ export type OutOfListHealth = {
21
+ since: string;
22
+ total: number;
23
+ byPlatformCheck: Record<string, {
24
+ handled: number;
25
+ refused: number;
26
+ }>;
27
+ };
28
+ export declare class OutOfList {
29
+ private readonly now;
30
+ private readonly log;
31
+ /** Reads the platforms' lists again (never awaited by a request); absent: never. */
32
+ private readonly refresh?;
33
+ private readonly counts;
34
+ private minuteAt;
35
+ private minuteLines;
36
+ private held;
37
+ private readonly since;
38
+ private refreshedAt;
39
+ constructor(now?: () => number, log?: (line: string) => void,
40
+ /** Reads the platforms' lists again (never awaited by a request); absent: never. */
41
+ refresh?: (() => Promise<unknown> | undefined) | undefined);
42
+ /** The platform a call says it is from - by the client's name and user-agent only (a guess). */
43
+ static guess(c: Pick<OutOfListCall, 'client' | 'userAgent' | 'openaiSession'>): Platform;
44
+ /** Counts the call, and logs one line for it (at most `OUT_OF_LIST_LOGS_PER_MINUTE` a minute). */
45
+ note(c: OutOfListCall): void;
46
+ /**
47
+ * ⚠️ A CALL FROM OUTSIDE THE LISTS MAY MEAN A NEW RANGE: the lists are read again, at most
48
+ * once in `OUT_OF_LIST_REFRESH_GAP_MS`, in the background - never awaited by the request,
49
+ * errors only logged. So a range a platform adds is picked up within minutes, and the counts
50
+ * tell "new range" (they stop) from "really not on the list" (they go on).
51
+ */
52
+ private refreshSoon;
53
+ private failed;
54
+ /** `note`, for a request's headers; a fault in noting is `onFault`'s, never the request's. */
55
+ noteRequest(r: Pick<OutOfListCall, 'address' | 'userAgent' | 'openaiSession' | 'tool' | 'client'>, check: OutOfListCheck, outcome: OutOfListOutcome, onFault: (e: unknown) => void): void;
56
+ /** For /healthz/detail: since this process started, by platform guessed and check. */
57
+ health(): OutOfListHealth;
58
+ }
59
+ /**
60
+ * `HOTEL_CARD_SOURCES`: what a card's call from outside the platforms' ranges meets.
61
+ * Unset: handled, counted and logged (2026-11-27). `enforce`: refused as not_this_conversation,
62
+ * counted and logged (what 0.75.1 did). `off`: nothing is looked at - no count, no line.
63
+ */
64
+ export declare const cardSourcesMode: (value: string | undefined) => "off" | "count" | "enforce";
65
+ /**
66
+ * Where a card's call came from (0.75.1, risk A), by `sourceOf` alone: 'platform' - OpenAI's or
67
+ * Anthropic's published ranges (the running lists of @curless/platform-ranges); 'local' - our
68
+ * own side of the proxy: no address, a private or a loopback one (a test, a local preview - a
69
+ * request from outside comes through Caddy, which writes its public address); undefined -
70
+ * anywhere else. Since 2026-11-27 undefined no longer refuses a call (server.ts, out-of-list.ts):
71
+ * it is counted and logged.
72
+ */
73
+ export declare const cardSourceOf: (address: string | undefined, ranges?: Pick<PlatformRanges, "has">) => "platform" | "local" | undefined;
74
+ //# sourceMappingURL=out-of-list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"out-of-list.d.ts","sourceRoot":"","sources":["../src/out-of-list.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,0BAA0B,CAAC;AAErF,OAAO,EAAE,KAAK,QAAQ,EAAc,MAAM,qBAAqB,CAAC;AAEhE,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG,gBAAgB,GAAG,aAAa,CAAC;AAC9E,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,SAAS,CAAC;AAErD,iFAAiF;AACjF,eAAO,MAAM,2BAA2B,KAAK,CAAC;AAC9C,gFAAgF;AAChF,eAAO,MAAM,0BAA0B,QAAc,CAAC;AAItD,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,cAAc,CAAC;IACtB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,2EAA2E;IAC3E,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,8CAA8C;IAC9C,aAAa,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACvE,CAAC;AAEF,qBAAa,SAAS;IASlB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,C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AAE,KAAK,CAAmB,KACpD,UAAU,GAAG,OAAO,GAAG,SAIzB,CAAC"}
@@ -0,0 +1,150 @@
1
+ // A call from outside the platform's published ranges - counted and logged, and no
2
+ // longer turned away by that alone where that is safe.
3
+ //
4
+ // Two checks used to refuse a card's call that did not come from OpenAI's or
5
+ // Anthropic's published ranges (server.ts). On 2026-11-27 OpenAI had published new
6
+ // ranges two days before and ours was the list of the 6th: real ChatGPT cards were
7
+ // refused as `not_this_conversation` for hours. The lists now renew themselves
8
+ // (@curless/platform-ranges), and a call from outside them is handled as usual where
9
+ // that is safe - and ALWAYS SAID, here:
10
+ //
11
+ // check what it protects outside the list
12
+ // card-source a card's call naming a conversation not its handled, counted, logged
13
+ // own (a trip id, a sign-in's claim)
14
+ // openai-session `X-OpenAI-Session` as the conversation's key refused: the header is not taken
15
+ // openai-trip a trip under a ChatGPT conversation's `oai:` key refused
16
+ //
17
+ // ⚠️ THE TWO `openai-*` CHECKS STAY, AND WHY: the header is not a secret - OpenAI sends it
18
+ // to every connector the conversation uses, and it is in their logs - so the address it
19
+ // comes from is the only thing that says the caller is OpenAI's. Taken from anyone, a
20
+ // script that copied it joins that conversation: its cart, its signed-in account, its
21
+ // bookings. A list that is behind is the lesser harm - and it is no longer a matter of
22
+ // days: the counts here are what the daily health check reads.
23
+ //
24
+ // ⚠️ NEVER AN ADDRESS, NEVER GUEST DATA: a line names the platform as guessed from the
25
+ // client's name and user-agent, the caller's network (/24, /48), the check and the tool.
26
+ import { createPlatformRanges } from '@curless/platform-ranges';
27
+ import { isPrivateAddress, networkOfAddress, parseAddress } from './cidr.js';
28
+ import { platformOf } from './usage/platform.js';
29
+ /** Lines logged per minute, all checks together; every call is still counted. */
30
+ export const OUT_OF_LIST_LOGS_PER_MINUTE = 30;
31
+ /** A call from outside the lists reads the lists again - at most this often. */
32
+ export const OUT_OF_LIST_REFRESH_GAP_MS = 10 * 60_000;
33
+ const printable = (s, max) => s.replace(/[^\x20-\x7e]/g, '?').slice(0, max);
34
+ export class OutOfList {
35
+ now;
36
+ log;
37
+ refresh;
38
+ counts = new Map();
39
+ minuteAt = Number.NEGATIVE_INFINITY;
40
+ minuteLines = 0;
41
+ held = 0;
42
+ since;
43
+ refreshedAt = Number.NEGATIVE_INFINITY;
44
+ constructor(now = () => Date.now(), log = (l) => console.log(l),
45
+ /** Reads the platforms' lists again (never awaited by a request); absent: never. */
46
+ refresh) {
47
+ this.now = now;
48
+ this.log = log;
49
+ this.refresh = refresh;
50
+ this.since = this.now();
51
+ }
52
+ /** The platform a call says it is from - by the client's name and user-agent only (a guess). */
53
+ static guess(c) {
54
+ return platformOf({
55
+ client: c.client,
56
+ userAgent: c.userAgent,
57
+ openaiSession: c.openaiSession,
58
+ });
59
+ }
60
+ /** Counts the call, and logs one line for it (at most `OUT_OF_LIST_LOGS_PER_MINUTE` a minute). */
61
+ note(c) {
62
+ const platform = OutOfList.guess(c);
63
+ this.refreshSoon();
64
+ const key = `${platform}/${c.check}`;
65
+ const row = this.counts.get(key) ?? { handled: 0, refused: 0 };
66
+ row[c.outcome] += 1;
67
+ this.counts.set(key, row);
68
+ const t = this.now();
69
+ if (t - this.minuteAt >= 60_000) {
70
+ if (this.held) {
71
+ this.log(`[ranges] outside the lists: ${this.held} more not logged in the minute before (over ${OUT_OF_LIST_LOGS_PER_MINUTE} a minute) - every one is counted on /healthz/detail`);
72
+ }
73
+ this.minuteAt = t;
74
+ this.minuteLines = 0;
75
+ this.held = 0;
76
+ }
77
+ if (this.minuteLines >= OUT_OF_LIST_LOGS_PER_MINUTE) {
78
+ this.held += 1;
79
+ return;
80
+ }
81
+ this.minuteLines += 1;
82
+ const a = parseAddress(c.address);
83
+ this.log(`[ranges] outside the lists platform=${platform} net=${a ? networkOfAddress(a) : '-'} check=${c.check} tool=${printable(c.tool ?? '-', 60)} outcome=${c.outcome}`);
84
+ }
85
+ /**
86
+ * ⚠️ A CALL FROM OUTSIDE THE LISTS MAY MEAN A NEW RANGE: the lists are read again, at most
87
+ * once in `OUT_OF_LIST_REFRESH_GAP_MS`, in the background - never awaited by the request,
88
+ * errors only logged. So a range a platform adds is picked up within minutes, and the counts
89
+ * tell "new range" (they stop) from "really not on the list" (they go on).
90
+ */
91
+ refreshSoon() {
92
+ const t = this.now();
93
+ if (!this.refresh || t - this.refreshedAt < OUT_OF_LIST_REFRESH_GAP_MS)
94
+ return;
95
+ try {
96
+ const reading = this.refresh();
97
+ if (!reading)
98
+ return; // nothing is keeping the lists current here: not a read, so no wait
99
+ this.refreshedAt = t;
100
+ void Promise.resolve(reading).catch((e) => this.failed(e));
101
+ }
102
+ catch (e) {
103
+ this.failed(e);
104
+ }
105
+ }
106
+ failed(e) {
107
+ this.log(`[ranges] refresh after an outside call failed (${e instanceof Error ? e.name : typeof e})`);
108
+ }
109
+ /** `note`, for a request's headers; a fault in noting is `onFault`'s, never the request's. */
110
+ noteRequest(r, check, outcome, onFault) {
111
+ try {
112
+ this.note({ ...r, check, outcome });
113
+ }
114
+ catch (e) {
115
+ onFault(e);
116
+ }
117
+ }
118
+ /** For /healthz/detail: since this process started, by platform guessed and check. */
119
+ health() {
120
+ const byPlatformCheck = Object.fromEntries([...this.counts].sort(([x], [y]) => x.localeCompare(y)).map(([k, v]) => [k, { ...v }]));
121
+ const total = [...this.counts.values()].reduce((n, v) => n + v.handled + v.refused, 0);
122
+ return { since: new Date(this.since).toISOString(), total, byPlatformCheck };
123
+ }
124
+ }
125
+ /**
126
+ * `HOTEL_CARD_SOURCES`: what a card's call from outside the platforms' ranges meets.
127
+ * Unset: handled, counted and logged (2026-11-27). `enforce`: refused as not_this_conversation,
128
+ * counted and logged (what 0.75.1 did). `off`: nothing is looked at - no count, no line.
129
+ */
130
+ export const cardSourcesMode = (value) => {
131
+ const v = value?.trim().toLowerCase();
132
+ return v === 'off' ? 'off' : v === 'enforce' ? 'enforce' : 'count';
133
+ };
134
+ /** The package's built-in snapshot, for a caller with no running list (a test). */
135
+ const BUILT_IN_RANGES = createPlatformRanges({ log: () => { } });
136
+ /**
137
+ * Where a card's call came from (0.75.1, risk A), by `sourceOf` alone: 'platform' - OpenAI's or
138
+ * Anthropic's published ranges (the running lists of @curless/platform-ranges); 'local' - our
139
+ * own side of the proxy: no address, a private or a loopback one (a test, a local preview - a
140
+ * request from outside comes through Caddy, which writes its public address); undefined -
141
+ * anywhere else. Since 2026-11-27 undefined no longer refuses a call (server.ts, out-of-list.ts):
142
+ * it is counted and logged.
143
+ */
144
+ export const cardSourceOf = (address, ranges = BUILT_IN_RANGES) => {
145
+ const a = parseAddress(address);
146
+ if (!a || isPrivateAddress(a))
147
+ return 'local';
148
+ return ranges.has('openai', a) || ranges.has('anthropic', a) ? 'platform' : undefined;
149
+ };
150
+ //# sourceMappingURL=out-of-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"out-of-list.js","sourceRoot":"","sources":["../src/out-of-list.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,uDAAuD;AACvD,EAAE;AACF,6EAA6E;AAC7E,mFAAmF;AACnF,mFAAmF;AACnF,+EAA+E;AAC/E,qFAAqF;AACrF,wCAAwC;AACxC,EAAE;AACF,sFAAsF;AACtF,8FAA8F;AAC9F,uDAAuD;AACvD,sGAAsG;AACtG,6EAA6E;AAC7E,EAAE;AACF,2FAA2F;AAC3F,wFAAwF;AACxF,sFAAsF;AACtF,sFAAsF;AACtF,uFAAuF;AACvF,+DAA+D;AAC/D,EAAE;AACF,uFAAuF;AACvF,yFAAyF;AACzF,OAAO,EAAuB,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC7E,OAAO,EAAiB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAKhE,iFAAiF;AACjF,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,CAAC;AAC9C,gFAAgF;AAChF,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,GAAG,MAAM,CAAC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AE,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;AACxF,CAAC,CAAC"}
@@ -1,10 +1,22 @@
1
1
  #!/usr/bin/env node
2
- import { checkRanges, exitCodeOf, reportOf } from './ranges-check.js';
3
- // `npm run check-ranges` - what each platform publishes today, beside
4
- // source-ranges.ts. Exit 0: the same. 1: something differs. 2: a source could
5
- // not be read. See ranges-check.ts; it is a file of its own so that the
6
- // library (lib.ts) holds no top-level await.
7
- const diffs = await checkRanges();
8
- console.log(process.argv.includes('--json') ? JSON.stringify(diffs, null, 2) : reportOf(diffs));
2
+ import { createPlatformRanges } from '@curless/platform-ranges';
3
+ import { checkRanges, exitCodeOf, inUse, reportOf } from './ranges-check.js';
4
+ // `npm run check-ranges` - what each platform publishes today, beside the list the
5
+ // server has in use, and how old that list is. The list in use is the one the running
6
+ // server keeps in `<HOTEL_STATE_DIR>/platform-ranges` (nothing is read or written there
7
+ // by this command), or the package's built-in snapshot with no state directory.
8
+ //
9
+ // Exit 0: the same, and fresh. 1: something differs. 2: a source could not be read.
10
+ // 3: a list in use is stale (nothing newer than 3 days has been read). See
11
+ // ranges-check.ts; it is a file of its own so that the library (lib.ts) holds no
12
+ // top-level await.
13
+ const stateDir = process.env.HOTEL_STATE_DIR;
14
+ const registry = createPlatformRanges({
15
+ ...(stateDir ? { stateDir: `${stateDir.replace(/\/$/, '')}/platform-ranges` } : {}),
16
+ log: (line) => console.error(line),
17
+ });
18
+ const { platforms, lists } = inUse(registry);
19
+ const diffs = await checkRanges(fetch, platforms, lists);
20
+ console.log(process.argv.includes('--json') ? JSON.stringify(diffs, null, 2) : reportOf(diffs, platforms));
9
21
  process.exit(exitCodeOf(diffs));
10
22
  //# sourceMappingURL=ranges-check-cli.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ranges-check-cli.js","sourceRoot":"","sources":["../src/ranges-check-cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,UAAU,EA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