@alook/cli 0.0.14 → 0.0.15
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.js +48 -14
- package/dist/session-runner.js +48 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15826,16 +15826,33 @@ class DaemonClient {
|
|
|
15826
15826
|
"Content-Type": "application/json",
|
|
15827
15827
|
Authorization: `Bearer ${token}`
|
|
15828
15828
|
};
|
|
15829
|
-
const
|
|
15830
|
-
|
|
15831
|
-
|
|
15832
|
-
|
|
15833
|
-
|
|
15834
|
-
|
|
15835
|
-
|
|
15836
|
-
|
|
15837
|
-
|
|
15838
|
-
|
|
15829
|
+
const MAX_RETRIES = 3;
|
|
15830
|
+
const BASE_DELAY_MS = 500;
|
|
15831
|
+
let lastError;
|
|
15832
|
+
for (let attempt = 0;attempt <= MAX_RETRIES; attempt++) {
|
|
15833
|
+
try {
|
|
15834
|
+
const res = await fetch(this.baseURL + path, {
|
|
15835
|
+
method,
|
|
15836
|
+
headers,
|
|
15837
|
+
body: body ? JSON.stringify(body) : undefined
|
|
15838
|
+
});
|
|
15839
|
+
if (!res.ok)
|
|
15840
|
+
throw new Error(`HTTP ${res.status}: ${await res.text()}`);
|
|
15841
|
+
if (res.status === 204)
|
|
15842
|
+
return;
|
|
15843
|
+
return res.json();
|
|
15844
|
+
} catch (e) {
|
|
15845
|
+
if (e instanceof TypeError) {
|
|
15846
|
+
lastError = e;
|
|
15847
|
+
if (attempt < MAX_RETRIES) {
|
|
15848
|
+
await new Promise((r) => setTimeout(r, BASE_DELAY_MS * 2 ** attempt));
|
|
15849
|
+
continue;
|
|
15850
|
+
}
|
|
15851
|
+
}
|
|
15852
|
+
throw e;
|
|
15853
|
+
}
|
|
15854
|
+
}
|
|
15855
|
+
throw lastError;
|
|
15839
15856
|
}
|
|
15840
15857
|
async register(token, body) {
|
|
15841
15858
|
const raw = await this.request("POST", "/api/daemon/register", token, body);
|
|
@@ -15870,11 +15887,28 @@ class DaemonClient {
|
|
|
15870
15887
|
return this.request("GET", `/api/artifacts/${artifactId}?workspace_id=${encodeURIComponent(workspaceId)}`, token);
|
|
15871
15888
|
}
|
|
15872
15889
|
async downloadArtifact(token, artifactId, workspaceId) {
|
|
15873
|
-
const
|
|
15874
|
-
|
|
15875
|
-
|
|
15890
|
+
const MAX_RETRIES = 3;
|
|
15891
|
+
const BASE_DELAY_MS = 500;
|
|
15892
|
+
let lastError;
|
|
15893
|
+
for (let attempt = 0;attempt <= MAX_RETRIES; attempt++) {
|
|
15894
|
+
try {
|
|
15895
|
+
const res = await fetch(`${this.baseURL}/api/artifacts/${artifactId}/content?workspace_id=${encodeURIComponent(workspaceId)}`, { headers: { Authorization: `Bearer ${token}` } });
|
|
15896
|
+
if (!res.ok) {
|
|
15897
|
+
throw new Error(`artifact download failed: HTTP ${res.status}`);
|
|
15898
|
+
}
|
|
15899
|
+
return res.arrayBuffer();
|
|
15900
|
+
} catch (e) {
|
|
15901
|
+
if (e instanceof TypeError) {
|
|
15902
|
+
lastError = e;
|
|
15903
|
+
if (attempt < MAX_RETRIES) {
|
|
15904
|
+
await new Promise((r) => setTimeout(r, BASE_DELAY_MS * 2 ** attempt));
|
|
15905
|
+
continue;
|
|
15906
|
+
}
|
|
15907
|
+
}
|
|
15908
|
+
throw e;
|
|
15909
|
+
}
|
|
15876
15910
|
}
|
|
15877
|
-
|
|
15911
|
+
throw lastError;
|
|
15878
15912
|
}
|
|
15879
15913
|
reportMessages(token, taskId, messages) {
|
|
15880
15914
|
return this.request("POST", `/api/daemon/tasks/${taskId}/messages`, token, { messages });
|
package/dist/session-runner.js
CHANGED
|
@@ -15532,16 +15532,33 @@ class DaemonClient {
|
|
|
15532
15532
|
"Content-Type": "application/json",
|
|
15533
15533
|
Authorization: `Bearer ${token}`
|
|
15534
15534
|
};
|
|
15535
|
-
const
|
|
15536
|
-
|
|
15537
|
-
|
|
15538
|
-
|
|
15539
|
-
|
|
15540
|
-
|
|
15541
|
-
|
|
15542
|
-
|
|
15543
|
-
|
|
15544
|
-
|
|
15535
|
+
const MAX_RETRIES = 3;
|
|
15536
|
+
const BASE_DELAY_MS = 500;
|
|
15537
|
+
let lastError;
|
|
15538
|
+
for (let attempt = 0;attempt <= MAX_RETRIES; attempt++) {
|
|
15539
|
+
try {
|
|
15540
|
+
const res = await fetch(this.baseURL + path, {
|
|
15541
|
+
method,
|
|
15542
|
+
headers,
|
|
15543
|
+
body: body ? JSON.stringify(body) : undefined
|
|
15544
|
+
});
|
|
15545
|
+
if (!res.ok)
|
|
15546
|
+
throw new Error(`HTTP ${res.status}: ${await res.text()}`);
|
|
15547
|
+
if (res.status === 204)
|
|
15548
|
+
return;
|
|
15549
|
+
return res.json();
|
|
15550
|
+
} catch (e) {
|
|
15551
|
+
if (e instanceof TypeError) {
|
|
15552
|
+
lastError = e;
|
|
15553
|
+
if (attempt < MAX_RETRIES) {
|
|
15554
|
+
await new Promise((r) => setTimeout(r, BASE_DELAY_MS * 2 ** attempt));
|
|
15555
|
+
continue;
|
|
15556
|
+
}
|
|
15557
|
+
}
|
|
15558
|
+
throw e;
|
|
15559
|
+
}
|
|
15560
|
+
}
|
|
15561
|
+
throw lastError;
|
|
15545
15562
|
}
|
|
15546
15563
|
async register(token, body) {
|
|
15547
15564
|
const raw = await this.request("POST", "/api/daemon/register", token, body);
|
|
@@ -15576,11 +15593,28 @@ class DaemonClient {
|
|
|
15576
15593
|
return this.request("GET", `/api/artifacts/${artifactId}?workspace_id=${encodeURIComponent(workspaceId)}`, token);
|
|
15577
15594
|
}
|
|
15578
15595
|
async downloadArtifact(token, artifactId, workspaceId) {
|
|
15579
|
-
const
|
|
15580
|
-
|
|
15581
|
-
|
|
15596
|
+
const MAX_RETRIES = 3;
|
|
15597
|
+
const BASE_DELAY_MS = 500;
|
|
15598
|
+
let lastError;
|
|
15599
|
+
for (let attempt = 0;attempt <= MAX_RETRIES; attempt++) {
|
|
15600
|
+
try {
|
|
15601
|
+
const res = await fetch(`${this.baseURL}/api/artifacts/${artifactId}/content?workspace_id=${encodeURIComponent(workspaceId)}`, { headers: { Authorization: `Bearer ${token}` } });
|
|
15602
|
+
if (!res.ok) {
|
|
15603
|
+
throw new Error(`artifact download failed: HTTP ${res.status}`);
|
|
15604
|
+
}
|
|
15605
|
+
return res.arrayBuffer();
|
|
15606
|
+
} catch (e) {
|
|
15607
|
+
if (e instanceof TypeError) {
|
|
15608
|
+
lastError = e;
|
|
15609
|
+
if (attempt < MAX_RETRIES) {
|
|
15610
|
+
await new Promise((r) => setTimeout(r, BASE_DELAY_MS * 2 ** attempt));
|
|
15611
|
+
continue;
|
|
15612
|
+
}
|
|
15613
|
+
}
|
|
15614
|
+
throw e;
|
|
15615
|
+
}
|
|
15582
15616
|
}
|
|
15583
|
-
|
|
15617
|
+
throw lastError;
|
|
15584
15618
|
}
|
|
15585
15619
|
reportMessages(token, taskId, messages) {
|
|
15586
15620
|
return this.request("POST", `/api/daemon/tasks/${taskId}/messages`, token, { messages });
|