agentmail 0.3.3 → 0.3.5

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.
@@ -43,8 +43,8 @@ function normalizeClientOptions(options) {
43
43
  const headers = (0, headers_js_1.mergeHeaders)({
44
44
  "X-Fern-Language": "JavaScript",
45
45
  "X-Fern-SDK-Name": "agentmail",
46
- "X-Fern-SDK-Version": "0.3.3",
47
- "User-Agent": "agentmail/0.3.3",
46
+ "X-Fern-SDK-Version": "0.3.5",
47
+ "User-Agent": "agentmail/0.3.5",
48
48
  "X-Fern-Runtime": core.RUNTIME.type,
49
49
  "X-Fern-Runtime-Version": core.RUNTIME.version,
50
50
  }, options === null || options === void 0 ? void 0 : options.headers);
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.3.3";
1
+ export declare const SDK_VERSION = "0.3.5";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "0.3.3";
4
+ exports.SDK_VERSION = "0.3.5";
@@ -1,22 +1,22 @@
1
1
  import type { x402Client } from "@x402/fetch";
2
- import type { Mppx } from "mppx/client";
3
2
  import { Supplier } from "../core/index.js";
4
3
  import { AgentMailClient as FernAgentMailClient } from "../Client.js";
5
4
  import { WebsocketsClient } from "./WebsocketsClient.js";
5
+ import { type MppxClient } from "./mppx.js";
6
6
  type SharedOptions = Omit<FernAgentMailClient.Options, "apiKey">;
7
7
  export declare namespace AgentMailClient {
8
8
  type Options = SharedOptions & ({
9
9
  x402: x402Client;
10
- mpp?: never;
10
+ mppx?: never;
11
11
  apiKey?: never;
12
12
  } | {
13
- mpp: Mppx.Mppx;
13
+ mppx: MppxClient;
14
14
  x402?: never;
15
15
  apiKey?: never;
16
16
  } | {
17
17
  apiKey?: Supplier<string>;
18
18
  x402?: never;
19
- mpp?: never;
19
+ mppx?: never;
20
20
  });
21
21
  type RequestOptions = FernAgentMailClient.RequestOptions;
22
22
  }
@@ -60,7 +60,7 @@ const environments_js_1 = require("../environments.js");
60
60
  const Client_js_1 = require("../Client.js");
61
61
  const WebsocketsClient_js_1 = require("./WebsocketsClient.js");
62
62
  const x402_js_1 = require("./x402.js");
63
- const mpp_js_1 = require("./mpp.js");
63
+ const mppx_js_1 = require("./mppx.js");
64
64
  class AgentMailClient extends Client_js_1.AgentMailClient {
65
65
  get websockets() {
66
66
  var _a;
@@ -72,8 +72,8 @@ class AgentMailClient extends Client_js_1.AgentMailClient {
72
72
  let wrappedFetch;
73
73
  const fernOptions = Object.assign(Object.assign({}, rest), { authProvider: new NoOpAuthProvider_js_1.NoOpAuthProvider(), fetch: (input, init) => __awaiter(this, void 0, void 0, function* () {
74
74
  if (!wrappedFetch) {
75
- const mod = yield Promise.resolve().then(() => __importStar(require("@x402/fetch")));
76
- wrappedFetch = mod.wrapFetchWithPayment(fetch, x402);
75
+ const { wrapFetchWithPayment } = yield Promise.resolve().then(() => __importStar(require("@x402/fetch")));
76
+ wrappedFetch = wrapFetchWithPayment(fetch, x402);
77
77
  }
78
78
  return wrappedFetch(input, init);
79
79
  }) });
@@ -83,14 +83,14 @@ class AgentMailClient extends Client_js_1.AgentMailClient {
83
83
  super(fernOptions);
84
84
  this._getPaymentCredentials = (wsUrl) => (0, x402_js_1.getPaymentCredentials)(wsUrl, x402);
85
85
  }
86
- else if (options.mpp) {
87
- const { mpp } = options, rest = __rest(options, ["mpp"]);
88
- const fernOptions = Object.assign(Object.assign({}, rest), { authProvider: new NoOpAuthProvider_js_1.NoOpAuthProvider(), fetch: mpp.fetch });
86
+ else if (options.mppx) {
87
+ const { mppx } = options, rest = __rest(options, ["mppx"]);
88
+ const fernOptions = Object.assign(Object.assign({}, rest), { authProvider: new NoOpAuthProvider_js_1.NoOpAuthProvider(), fetch: mppx.fetch });
89
89
  if (!fernOptions.environment && !fernOptions.baseUrl) {
90
90
  fernOptions.environment = environments_js_1.AgentMailEnvironment.ProdMpp;
91
91
  }
92
92
  super(fernOptions);
93
- this._getPaymentCredentials = (wsUrl) => (0, mpp_js_1.getPaymentCredentials)(wsUrl, mpp);
93
+ this._getPaymentCredentials = (wsUrl) => (0, mppx_js_1.getPaymentCredentials)(wsUrl, mppx);
94
94
  }
95
95
  else {
96
96
  let fernOptions = options;
@@ -0,0 +1,8 @@
1
+ export interface MppxClient {
2
+ fetch: typeof globalThis.fetch;
3
+ transport: {
4
+ setCredential(request: Request, credential: string): RequestInit;
5
+ };
6
+ createCredential(response: Response): Promise<string>;
7
+ }
8
+ export declare function getPaymentCredentials(wsUrl: string, mppx: MppxClient): Promise<Record<string, string>>;
@@ -10,14 +10,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getPaymentCredentials = getPaymentCredentials;
13
- const probe402_js_1 = require("./probe402.js");
14
- function getPaymentCredentials(wsUrl, mpp) {
13
+ const util_js_1 = require("./util.js");
14
+ function getPaymentCredentials(wsUrl, mppx) {
15
15
  return __awaiter(this, void 0, void 0, function* () {
16
- const response = yield (0, probe402_js_1.probe402)(wsUrl);
17
- const credential = yield mpp.createCredential(response);
18
- const signed = mpp.transport.setCredential(new Request(wsUrl), credential);
16
+ const response = yield (0, util_js_1.probe402)(wsUrl);
17
+ const credential = yield mppx.createCredential(response);
18
+ const signed = mppx.transport.setCredential(new Request((0, util_js_1.wsToHttp)(wsUrl)), credential);
19
19
  const headers = {};
20
- signed.headers.forEach((value, key) => {
20
+ new Headers(signed.headers).forEach((value, key) => {
21
21
  headers[key] = value;
22
22
  });
23
23
  return headers;
@@ -1 +1,2 @@
1
+ export declare function wsToHttp(wsUrl: string): string;
1
2
  export declare function probe402(wsUrl: string): Promise<Response>;
@@ -9,10 +9,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.wsToHttp = wsToHttp;
12
13
  exports.probe402 = probe402;
14
+ function wsToHttp(wsUrl) {
15
+ return wsUrl.replace(/^wss:\/\//, "https://").replace(/^ws:\/\//, "http://");
16
+ }
13
17
  function probe402(wsUrl) {
14
18
  return __awaiter(this, void 0, void 0, function* () {
15
- const httpUrl = wsUrl.replace(/^wss:\/\//, "https://").replace(/^ws:\/\//, "http://");
19
+ const httpUrl = wsToHttp(wsUrl);
16
20
  const response = yield fetch(httpUrl);
17
21
  if (response.status !== 402) {
18
22
  throw new Error(`Expected 402 from ${httpUrl} but got ${response.status}`);
@@ -43,12 +43,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
43
43
  };
44
44
  Object.defineProperty(exports, "__esModule", { value: true });
45
45
  exports.getPaymentCredentials = getPaymentCredentials;
46
- const probe402_js_1 = require("./probe402.js");
46
+ const util_js_1 = require("./util.js");
47
47
  function getPaymentCredentials(wsUrl, client) {
48
48
  return __awaiter(this, void 0, void 0, function* () {
49
49
  const { x402HTTPClient } = yield Promise.resolve().then(() => __importStar(require("@x402/fetch")));
50
50
  const httpClient = new x402HTTPClient(client);
51
- const response = yield (0, probe402_js_1.probe402)(wsUrl);
51
+ const response = yield (0, util_js_1.probe402)(wsUrl);
52
52
  let body;
53
53
  try {
54
54
  body = JSON.parse(yield response.text());
@@ -6,8 +6,8 @@ export function normalizeClientOptions(options) {
6
6
  const headers = mergeHeaders({
7
7
  "X-Fern-Language": "JavaScript",
8
8
  "X-Fern-SDK-Name": "agentmail",
9
- "X-Fern-SDK-Version": "0.3.3",
10
- "User-Agent": "agentmail/0.3.3",
9
+ "X-Fern-SDK-Version": "0.3.5",
10
+ "User-Agent": "agentmail/0.3.5",
11
11
  "X-Fern-Runtime": core.RUNTIME.type,
12
12
  "X-Fern-Runtime-Version": core.RUNTIME.version,
13
13
  }, options === null || options === void 0 ? void 0 : options.headers);
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.3.3";
1
+ export declare const SDK_VERSION = "0.3.5";
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.3.3";
1
+ export const SDK_VERSION = "0.3.5";
@@ -1,22 +1,22 @@
1
1
  import type { x402Client } from "@x402/fetch";
2
- import type { Mppx } from "mppx/client";
3
2
  import { Supplier } from "../core/index.mjs";
4
3
  import { AgentMailClient as FernAgentMailClient } from "../Client.mjs";
5
4
  import { WebsocketsClient } from "./WebsocketsClient.mjs";
5
+ import { type MppxClient } from "./mppx.mjs";
6
6
  type SharedOptions = Omit<FernAgentMailClient.Options, "apiKey">;
7
7
  export declare namespace AgentMailClient {
8
8
  type Options = SharedOptions & ({
9
9
  x402: x402Client;
10
- mpp?: never;
10
+ mppx?: never;
11
11
  apiKey?: never;
12
12
  } | {
13
- mpp: Mppx.Mppx;
13
+ mppx: MppxClient;
14
14
  x402?: never;
15
15
  apiKey?: never;
16
16
  } | {
17
17
  apiKey?: Supplier<string>;
18
18
  x402?: never;
19
- mpp?: never;
19
+ mppx?: never;
20
20
  });
21
21
  type RequestOptions = FernAgentMailClient.RequestOptions;
22
22
  }
@@ -24,7 +24,7 @@ import { AgentMailEnvironment } from "../environments.mjs";
24
24
  import { AgentMailClient as FernAgentMailClient } from "../Client.mjs";
25
25
  import { WebsocketsClient } from "./WebsocketsClient.mjs";
26
26
  import { getPaymentCredentials as getX402Credentials } from "./x402.mjs";
27
- import { getPaymentCredentials as getMppCredentials } from "./mpp.mjs";
27
+ import { getPaymentCredentials as getMppCredentials } from "./mppx.mjs";
28
28
  export class AgentMailClient extends FernAgentMailClient {
29
29
  get websockets() {
30
30
  var _a;
@@ -36,8 +36,8 @@ export class AgentMailClient extends FernAgentMailClient {
36
36
  let wrappedFetch;
37
37
  const fernOptions = Object.assign(Object.assign({}, rest), { authProvider: new NoOpAuthProvider(), fetch: (input, init) => __awaiter(this, void 0, void 0, function* () {
38
38
  if (!wrappedFetch) {
39
- const mod = yield import("@x402/fetch");
40
- wrappedFetch = mod.wrapFetchWithPayment(fetch, x402);
39
+ const { wrapFetchWithPayment } = yield import("@x402/fetch");
40
+ wrappedFetch = wrapFetchWithPayment(fetch, x402);
41
41
  }
42
42
  return wrappedFetch(input, init);
43
43
  }) });
@@ -47,14 +47,14 @@ export class AgentMailClient extends FernAgentMailClient {
47
47
  super(fernOptions);
48
48
  this._getPaymentCredentials = (wsUrl) => getX402Credentials(wsUrl, x402);
49
49
  }
50
- else if (options.mpp) {
51
- const { mpp } = options, rest = __rest(options, ["mpp"]);
52
- const fernOptions = Object.assign(Object.assign({}, rest), { authProvider: new NoOpAuthProvider(), fetch: mpp.fetch });
50
+ else if (options.mppx) {
51
+ const { mppx } = options, rest = __rest(options, ["mppx"]);
52
+ const fernOptions = Object.assign(Object.assign({}, rest), { authProvider: new NoOpAuthProvider(), fetch: mppx.fetch });
53
53
  if (!fernOptions.environment && !fernOptions.baseUrl) {
54
54
  fernOptions.environment = AgentMailEnvironment.ProdMpp;
55
55
  }
56
56
  super(fernOptions);
57
- this._getPaymentCredentials = (wsUrl) => getMppCredentials(wsUrl, mpp);
57
+ this._getPaymentCredentials = (wsUrl) => getMppCredentials(wsUrl, mppx);
58
58
  }
59
59
  else {
60
60
  let fernOptions = options;
@@ -0,0 +1,8 @@
1
+ export interface MppxClient {
2
+ fetch: typeof globalThis.fetch;
3
+ transport: {
4
+ setCredential(request: Request, credential: string): RequestInit;
5
+ };
6
+ createCredential(response: Response): Promise<string>;
7
+ }
8
+ export declare function getPaymentCredentials(wsUrl: string, mppx: MppxClient): Promise<Record<string, string>>;
@@ -7,14 +7,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { probe402 } from "./probe402.mjs";
11
- export function getPaymentCredentials(wsUrl, mpp) {
10
+ import { probe402, wsToHttp } from "./util.mjs";
11
+ export function getPaymentCredentials(wsUrl, mppx) {
12
12
  return __awaiter(this, void 0, void 0, function* () {
13
13
  const response = yield probe402(wsUrl);
14
- const credential = yield mpp.createCredential(response);
15
- const signed = mpp.transport.setCredential(new Request(wsUrl), credential);
14
+ const credential = yield mppx.createCredential(response);
15
+ const signed = mppx.transport.setCredential(new Request(wsToHttp(wsUrl)), credential);
16
16
  const headers = {};
17
- signed.headers.forEach((value, key) => {
17
+ new Headers(signed.headers).forEach((value, key) => {
18
18
  headers[key] = value;
19
19
  });
20
20
  return headers;
@@ -1 +1,2 @@
1
+ export declare function wsToHttp(wsUrl: string): string;
1
2
  export declare function probe402(wsUrl: string): Promise<Response>;
@@ -7,9 +7,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
+ export function wsToHttp(wsUrl) {
11
+ return wsUrl.replace(/^wss:\/\//, "https://").replace(/^ws:\/\//, "http://");
12
+ }
10
13
  export function probe402(wsUrl) {
11
14
  return __awaiter(this, void 0, void 0, function* () {
12
- const httpUrl = wsUrl.replace(/^wss:\/\//, "https://").replace(/^ws:\/\//, "http://");
15
+ const httpUrl = wsToHttp(wsUrl);
13
16
  const response = yield fetch(httpUrl);
14
17
  if (response.status !== 402) {
15
18
  throw new Error(`Expected 402 from ${httpUrl} but got ${response.status}`);
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { probe402 } from "./probe402.mjs";
10
+ import { probe402 } from "./util.mjs";
11
11
  export function getPaymentCredentials(wsUrl, client) {
12
12
  return __awaiter(this, void 0, void 0, function* () {
13
13
  const { x402HTTPClient } = yield import("@x402/fetch");