openmates 0.10.0-alpha.3 → 0.10.0-alpha.4

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.
@@ -4847,6 +4847,8 @@ function formatEmbedsForMessage(embeds) {
4847
4847
  // src/uploadService.ts
4848
4848
  import { readFileSync as readFileSync4 } from "fs";
4849
4849
  import { basename as basename2 } from "path";
4850
+ var UPLOAD_MAX_ATTEMPTS = 3;
4851
+ var UPLOAD_RETRY_DELAY_MS = 2e3;
4850
4852
  function getUploadUrl(apiUrl) {
4851
4853
  try {
4852
4854
  const url = new URL(apiUrl);
@@ -4861,22 +4863,37 @@ async function uploadFile(filePath, session) {
4861
4863
  const filename = basename2(filePath);
4862
4864
  const fileBytes = readFileSync4(filePath);
4863
4865
  const uploadUrl = `${getUploadUrl(session.apiUrl)}/v1/upload/file`;
4864
- const blob = new Blob([fileBytes]);
4865
- const formData = new FormData();
4866
- formData.append("file", blob, filename);
4867
4866
  const cookies = [];
4868
4867
  if (session.cookies?.auth_refresh_token) {
4869
4868
  cookies.push(`auth_refresh_token=${session.cookies.auth_refresh_token}`);
4870
4869
  }
4871
- const response = await fetch(uploadUrl, {
4872
- method: "POST",
4873
- body: formData,
4874
- headers: {
4875
- ...cookies.length > 0 ? { Cookie: cookies.join("; ") } : {}
4876
- },
4877
- signal: AbortSignal.timeout(10 * 60 * 1e3)
4878
- // 10-minute timeout
4879
- });
4870
+ let response;
4871
+ let lastError;
4872
+ for (let attempt = 1; attempt <= UPLOAD_MAX_ATTEMPTS; attempt++) {
4873
+ try {
4874
+ const blob = new Blob([fileBytes]);
4875
+ const formData = new FormData();
4876
+ formData.append("file", blob, filename);
4877
+ response = await fetch(uploadUrl, {
4878
+ method: "POST",
4879
+ body: formData,
4880
+ headers: {
4881
+ ...cookies.length > 0 ? { Cookie: cookies.join("; ") } : {}
4882
+ },
4883
+ signal: AbortSignal.timeout(10 * 60 * 1e3)
4884
+ // 10-minute timeout
4885
+ });
4886
+ break;
4887
+ } catch (error) {
4888
+ lastError = error;
4889
+ if (attempt === UPLOAD_MAX_ATTEMPTS) break;
4890
+ await new Promise((resolve4) => setTimeout(resolve4, UPLOAD_RETRY_DELAY_MS));
4891
+ }
4892
+ }
4893
+ if (!response) {
4894
+ const message = lastError instanceof Error ? lastError.message : String(lastError);
4895
+ throw new Error(message || "Upload request failed.");
4896
+ }
4880
4897
  if (!response.ok) {
4881
4898
  const status = response.status;
4882
4899
  let errorMessage;
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  getExtForLang,
4
4
  serializeToYaml
5
- } from "./chunk-R4HKMYBT.js";
5
+ } from "./chunk-H76DR4ER.js";
6
6
  export {
7
7
  getExtForLang,
8
8
  serializeToYaml
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  getExtForLang,
7
7
  parseNewChatSuggestionText,
8
8
  serializeToYaml
9
- } from "./chunk-R4HKMYBT.js";
9
+ } from "./chunk-H76DR4ER.js";
10
10
  export {
11
11
  MATE_NAMES,
12
12
  MEMORY_TYPE_REGISTRY,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openmates",
3
- "version": "0.10.0-alpha.3",
3
+ "version": "0.10.0-alpha.4",
4
4
  "description": "OpenMates CLI and SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",