@tryarcanist/cli 0.1.68 → 0.1.70
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 +40 -29
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -383,6 +383,17 @@ async function whoamiCommand(options, command) {
|
|
|
383
383
|
if (payload.tokenScope) console.log(`Token scope: ${String(payload.tokenScope)}`);
|
|
384
384
|
}
|
|
385
385
|
|
|
386
|
+
// ../../shared/utils/timing.ts
|
|
387
|
+
function sleep(ms) {
|
|
388
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// src/constants/watch.ts
|
|
392
|
+
var MIN_WATCH_POLL_INTERVAL_MS = 1;
|
|
393
|
+
var DEFAULT_WATCH_POLL_INTERVAL_MS = 1e3;
|
|
394
|
+
var WATCH_REPLAY_PAGE_SIZE = 200;
|
|
395
|
+
var WATCH_TERMINAL_STATUSES = /* @__PURE__ */ new Set(["idle", "stopped", "archived"]);
|
|
396
|
+
|
|
386
397
|
// src/uploads.ts
|
|
387
398
|
import { readFile } from "fs/promises";
|
|
388
399
|
import { basename, extname } from "path";
|
|
@@ -505,17 +516,6 @@ function normalizeUploadedFileOptions(files) {
|
|
|
505
516
|
return Array.isArray(files) ? files : [files];
|
|
506
517
|
}
|
|
507
518
|
|
|
508
|
-
// ../../shared/utils/timing.ts
|
|
509
|
-
function sleep(ms) {
|
|
510
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
// src/constants/watch.ts
|
|
514
|
-
var MIN_WATCH_POLL_INTERVAL_MS = 1;
|
|
515
|
-
var DEFAULT_WATCH_POLL_INTERVAL_MS = 1e3;
|
|
516
|
-
var WATCH_REPLAY_PAGE_SIZE = 200;
|
|
517
|
-
var WATCH_TERMINAL_STATUSES = /* @__PURE__ */ new Set(["idle", "stopped", "archived"]);
|
|
518
|
-
|
|
519
519
|
// ../../shared/utils/type-guards.ts
|
|
520
520
|
function isRecord(value) {
|
|
521
521
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
@@ -1646,21 +1646,6 @@ async function fetchPromptLabels(config, sessionId) {
|
|
|
1646
1646
|
const data = await apiFetch(config, `/api/sessions/${sessionId}/prompts`);
|
|
1647
1647
|
return buildPromptLabelMap(data.prompts);
|
|
1648
1648
|
}
|
|
1649
|
-
function extractSessionStatus(payload) {
|
|
1650
|
-
const session = payload.session;
|
|
1651
|
-
if (session && typeof session === "object" && typeof session.status === "string") {
|
|
1652
|
-
return String(session.status);
|
|
1653
|
-
}
|
|
1654
|
-
return typeof payload.status === "string" ? payload.status : "unknown";
|
|
1655
|
-
}
|
|
1656
|
-
async function waitForSessionToBecomeIdle(config, sessionId, pollIntervalMs) {
|
|
1657
|
-
const effectivePollIntervalMs = Math.max(pollIntervalMs, MIN_WATCH_POLL_INTERVAL_MS);
|
|
1658
|
-
while (true) {
|
|
1659
|
-
const payload = await apiFetch(config, `/api/sessions/${sessionId}`);
|
|
1660
|
-
if (WATCH_TERMINAL_STATUSES.has(extractSessionStatus(payload))) return;
|
|
1661
|
-
await sleep(effectivePollIntervalMs);
|
|
1662
|
-
}
|
|
1663
|
-
}
|
|
1664
1649
|
async function watchCommand(sessionId, options, command) {
|
|
1665
1650
|
const runtime = getRuntimeOptions(command, options);
|
|
1666
1651
|
const config = requireConfig(runtime);
|
|
@@ -1753,6 +1738,7 @@ function validateRepoUrl(url) {
|
|
|
1753
1738
|
if (REPO_URL_PATTERNS.some((pattern) => pattern.test(url))) return null;
|
|
1754
1739
|
return `Invalid repo URL: "${url}". Expected a GitHub URL (https://github.com/owner/repo) or owner/repo shorthand.`;
|
|
1755
1740
|
}
|
|
1741
|
+
var PROMPT_TERMINAL_STATUSES = /* @__PURE__ */ new Set(["completed", "failed"]);
|
|
1756
1742
|
function selectCreatedPrompt(prompts, promptId) {
|
|
1757
1743
|
if (prompts.length === 0) return null;
|
|
1758
1744
|
if (promptId) {
|
|
@@ -1767,16 +1753,41 @@ function buildPromptFailureError(sessionId, prompt, sessionUrl) {
|
|
|
1767
1753
|
hint: `Inspect with: arcanist sessions transcript ${sessionId}`
|
|
1768
1754
|
});
|
|
1769
1755
|
}
|
|
1756
|
+
function extractSessionStatus(payload) {
|
|
1757
|
+
const session = payload.session;
|
|
1758
|
+
if (session && typeof session === "object" && typeof session.status === "string") {
|
|
1759
|
+
return String(session.status);
|
|
1760
|
+
}
|
|
1761
|
+
return typeof payload.status === "string" ? payload.status : "unknown";
|
|
1762
|
+
}
|
|
1763
|
+
async function fetchCreatedPromptStatus(config, sessionId, promptId) {
|
|
1764
|
+
const promptList = await apiFetch(config, `/api/sessions/${sessionId}/prompts`);
|
|
1765
|
+
return selectCreatedPrompt(promptList.prompts, promptId);
|
|
1766
|
+
}
|
|
1767
|
+
async function waitForCreatedPromptToSettle(config, sessionId, promptId, pollIntervalMs) {
|
|
1768
|
+
const effectivePollIntervalMs = Math.max(pollIntervalMs, MIN_WATCH_POLL_INTERVAL_MS);
|
|
1769
|
+
while (true) {
|
|
1770
|
+
const createdPrompt = await fetchCreatedPromptStatus(config, sessionId, promptId);
|
|
1771
|
+
if (createdPrompt && PROMPT_TERMINAL_STATUSES.has(createdPrompt.status)) {
|
|
1772
|
+
return createdPrompt;
|
|
1773
|
+
}
|
|
1774
|
+
const sessionPayload = await apiFetch(config, `/api/sessions/${sessionId}`);
|
|
1775
|
+
if (WATCH_TERMINAL_STATUSES.has(extractSessionStatus(sessionPayload))) {
|
|
1776
|
+
return fetchCreatedPromptStatus(config, sessionId, promptId);
|
|
1777
|
+
}
|
|
1778
|
+
await sleep(effectivePollIntervalMs);
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1770
1781
|
async function waitForCreatedPrompt(sessionId, promptId, sessionUrl, pollIntervalMs, runtime, command) {
|
|
1771
1782
|
const config = requireConfig(runtime);
|
|
1772
1783
|
const jsonMode = isJson(command, runtime);
|
|
1784
|
+
let createdPrompt;
|
|
1773
1785
|
if (jsonMode) {
|
|
1774
|
-
await
|
|
1786
|
+
createdPrompt = await waitForCreatedPromptToSettle(config, sessionId, promptId, pollIntervalMs);
|
|
1775
1787
|
} else {
|
|
1776
1788
|
await watchCommand(sessionId, { ...runtime, pollInterval: String(pollIntervalMs) }, command);
|
|
1789
|
+
createdPrompt = await fetchCreatedPromptStatus(config, sessionId, promptId);
|
|
1777
1790
|
}
|
|
1778
|
-
const promptList = await apiFetch(config, `/api/sessions/${sessionId}/prompts`);
|
|
1779
|
-
const createdPrompt = selectCreatedPrompt(promptList.prompts, promptId);
|
|
1780
1791
|
if (!createdPrompt) {
|
|
1781
1792
|
throw new CliError("server", `Prompt status was unavailable after session ${sessionId} became idle.`, {
|
|
1782
1793
|
hint: `Inspect with: arcanist sessions transcript ${sessionId}`
|