@premai/api-sdk 1.0.31 → 1.0.33

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.cjs CHANGED
@@ -98,12 +98,27 @@ var DEFAULT_REQUEST_TIMEOUT_MS = 60000;
98
98
  var DEFAULT_MAX_BUFFER_SIZE = 10 * 1024 * 1024;
99
99
 
100
100
  // src/utils/attestation.ts
101
- var import_prem_rs = require("@premai/prem-rs");
101
+ var cachedPrem;
102
+ async function loadPrem() {
103
+ if (cachedPrem)
104
+ return cachedPrem;
105
+ const isBare = typeof globalThis.Bare !== "undefined";
106
+ if (isBare) {
107
+ cachedPrem = await import("@premai/reticle", { with: { type: "script" } });
108
+ return cachedPrem;
109
+ }
110
+ cachedPrem = await import("@premai/reticle");
111
+ return cachedPrem;
112
+ }
102
113
  function isAttestationError(err) {
103
114
  return err instanceof Error && err.name === "AttestationError";
104
115
  }
105
116
  function isGatewayError(err) {
106
- return isAttestationError(err) && err.kind instanceof import_prem_rs.GatewayError;
117
+ if (!isAttestationError(err))
118
+ return false;
119
+ if (!cachedPrem)
120
+ return false;
121
+ return err.kind instanceof cachedPrem.GatewayError;
107
122
  }
108
123
  function getGatewayErrorMessage(err) {
109
124
  if (isGatewayError(err))
@@ -113,8 +128,9 @@ function getGatewayErrorMessage(err) {
113
128
  async function attest(apiKey, options = { enabled: true }) {
114
129
  if (!options.enabled)
115
130
  return null;
116
- const client = await new import_prem_rs.ClientBuilder(endpoints.proxy ?? "").with_authorization(apiKey).build();
117
- let query = new import_prem_rs.QueryParams;
131
+ const prem = await loadPrem();
132
+ const client = await new prem.ClientBuilder(endpoints.proxy ?? "").with_authorization(apiKey).build();
133
+ let query = new prem.QueryParams;
118
134
  if (options.model)
119
135
  query = query.with("model", options.model);
120
136
  try {
package/dist/index.mjs CHANGED
@@ -1,3 +1,6 @@
1
+ import { createRequire } from "node:module";
2
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
3
+
1
4
  // src/index.ts
2
5
  import dotenv2 from "dotenv";
3
6
 
@@ -18,12 +21,27 @@ var DEFAULT_REQUEST_TIMEOUT_MS = 60000;
18
21
  var DEFAULT_MAX_BUFFER_SIZE = 10 * 1024 * 1024;
19
22
 
20
23
  // src/utils/attestation.ts
21
- import { ClientBuilder, GatewayError, QueryParams } from "@premai/prem-rs";
24
+ var cachedPrem;
25
+ async function loadPrem() {
26
+ if (cachedPrem)
27
+ return cachedPrem;
28
+ const isBare = typeof globalThis.Bare !== "undefined";
29
+ if (isBare) {
30
+ cachedPrem = await import("@premai/reticle", { with: { type: "script" } });
31
+ return cachedPrem;
32
+ }
33
+ cachedPrem = await import("@premai/reticle");
34
+ return cachedPrem;
35
+ }
22
36
  function isAttestationError(err) {
23
37
  return err instanceof Error && err.name === "AttestationError";
24
38
  }
25
39
  function isGatewayError(err) {
26
- return isAttestationError(err) && err.kind instanceof GatewayError;
40
+ if (!isAttestationError(err))
41
+ return false;
42
+ if (!cachedPrem)
43
+ return false;
44
+ return err.kind instanceof cachedPrem.GatewayError;
27
45
  }
28
46
  function getGatewayErrorMessage(err) {
29
47
  if (isGatewayError(err))
@@ -33,8 +51,9 @@ function getGatewayErrorMessage(err) {
33
51
  async function attest(apiKey, options = { enabled: true }) {
34
52
  if (!options.enabled)
35
53
  return null;
36
- const client = await new ClientBuilder(endpoints.proxy ?? "").with_authorization(apiKey).build();
37
- let query = new QueryParams;
54
+ const prem = await loadPrem();
55
+ const client = await new prem.ClientBuilder(endpoints.proxy ?? "").with_authorization(apiKey).build();
56
+ let query = new prem.QueryParams;
38
57
  if (options.model)
39
58
  query = query.with("model", options.model);
40
59
  try {
@@ -1,11 +1,11 @@
1
- import { GatewayError } from "@premai/prem-rs";
1
+ import type * as PremRs from "@premai/reticle";
2
2
  type AttestationError = Error & {
3
3
  cause: string[];
4
- kind?: GatewayError;
4
+ kind?: PremRs.GatewayError;
5
5
  };
6
6
  export declare function isAttestationError(err: unknown): err is AttestationError;
7
7
  export declare function isGatewayError(err: unknown): err is AttestationError & {
8
- kind: GatewayError;
8
+ kind: PremRs.GatewayError;
9
9
  };
10
10
  export declare function getGatewayErrorMessage(err: unknown): string | null;
11
11
  export declare function attest(apiKey: string, options?: {
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  },
5
5
  "homepage": "https://github.com/premai-io/api-sdk-ts",
6
6
  "name": "@premai/api-sdk",
7
- "version": "1.0.31",
7
+ "version": "1.0.33",
8
8
  "main": "./dist/index.cjs",
9
9
  "bin": {
10
10
  "pcci-proxy": "./dist/cli.cjs"
@@ -15,6 +15,7 @@
15
15
  "description": "",
16
16
  "exports": {
17
17
  ".": {
18
+ "bare": "./dist/core.browser.mjs",
18
19
  "node": "./dist/index.cjs",
19
20
  "require": "./dist/index.cjs",
20
21
  "import": "./dist/index.mjs",
@@ -24,6 +25,28 @@
24
25
  "require": "./dist/core.browser.cjs",
25
26
  "import": "./dist/core.browser.mjs",
26
27
  "types": "./dist/index.d.ts"
28
+ },
29
+ "./bare-global": {
30
+ "import": "./dist/bare-global.mjs",
31
+ "types": "./dist/bare-global.d.ts"
32
+ }
33
+ },
34
+ "imports": {
35
+ "crypto": {
36
+ "bare": "bare-crypto",
37
+ "default": "crypto"
38
+ },
39
+ "crypto/*": {
40
+ "bare": "bare-crypto/*",
41
+ "default": "crypto/*"
42
+ },
43
+ "fs": {
44
+ "bare": "bare-fs",
45
+ "default": "fs"
46
+ },
47
+ "fs/*": {
48
+ "bare": "bare-fs/*",
49
+ "default": "fs/*"
27
50
  }
28
51
  },
29
52
  "files": [
@@ -42,7 +65,13 @@
42
65
  "@noble/curves": "^1.8.1",
43
66
  "@noble/hashes": "^1.7.1",
44
67
  "@noble/post-quantum": "^0.5.2",
45
- "@premai/prem-rs": "0.3.0",
68
+ "@premai/reticle": "0.3.1",
69
+ "bare-abort-controller": "^1.1.1",
70
+ "bare-crypto": "^1.13.5",
71
+ "bare-encoding": "^1.0.3",
72
+ "bare-fetch": "^3.0.0",
73
+ "bare-fs": "^4.7.1",
74
+ "bare-process": "^4.4.1",
46
75
  "date-fns": "^4.1.0",
47
76
  "dotenv": "^17.2.3",
48
77
  "express": "^4.18.2",
@@ -53,9 +82,9 @@
53
82
  },
54
83
  "devDependencies": {
55
84
  "@biomejs/biome": "2.3.10",
85
+ "@types/bun": "^1.3.6",
56
86
  "@types/express": "^4.17.21",
57
87
  "@types/multer": "^2.0.0",
58
- "@types/bun": "^1.3.6",
59
88
  "@types/node": "^22.15.21",
60
89
  "ts-node": "^10.9.2"
61
90
  }