@cloop/runner 0.3.30 → 0.3.31

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.
Files changed (25) hide show
  1. package/dist/{box-NK3P3ESD.js → box-RFAHCXZS.js} +158 -37
  2. package/dist/{chunk-OTZDNYX4.js → chunk-7AHYPGSU.js} +2 -2
  3. package/dist/{chunk-HGKTPD5Z.js → chunk-FKYVJUIR.js} +1 -1
  4. package/dist/{chunk-JQGHB2EJ.js → chunk-GL77IQQE.js} +1 -1
  5. package/dist/{chunk-J4YN6KXM.js → chunk-MEAVT5SJ.js} +951 -73
  6. package/dist/{chunk-EOWS3JIY.js → chunk-R73PVAM2.js} +8 -3
  7. package/dist/{chunk-NTXQLEMQ.js → chunk-SBYSVZ7J.js} +94 -2
  8. package/dist/{chunk-DYA2BUDB.js → chunk-UERK5AHI.js} +6 -6
  9. package/dist/{chunk-IYZLO64O.js → chunk-WYU74GLG.js} +5 -5
  10. package/dist/{chunk-3YJD6J2N.js → chunk-YLVOEZWH.js} +1 -1
  11. package/dist/{connect-RYIPSXZK.js → connect-WRTLQW5H.js} +7 -8
  12. package/dist/{disconnect-FLRZVPXW.js → disconnect-I44BWWFB.js} +7 -8
  13. package/dist/{existing-runner-ATMNX2FX.js → existing-runner-SP6SNFH4.js} +7 -8
  14. package/dist/{hook-activity-GAJ5NABA.js → hook-activity-3T6IMEM6.js} +2 -3
  15. package/dist/{hook-session-start-5JYNMGX4.js → hook-session-start-DLP77G4H.js} +5 -7
  16. package/dist/index.js +20 -17
  17. package/dist/{login-CNTB5SXY.js → login-LH2KF7N2.js} +3 -3
  18. package/dist/{mcp-server-35YMJHA6.js → mcp-server-SGIWNLLL.js} +8 -10
  19. package/dist/{runner-JDJUWIGC.js → runner-SXUQH5IU.js} +4 -4
  20. package/dist/{runs-CKN4DINY.js → runs-3YZO57MX.js} +2 -2
  21. package/dist/{statusline-UD4OFVWL.js → statusline-UHZTCNCB.js} +1 -1
  22. package/dist/{takeover-M4KKYDHN.js → takeover-M4QHMXTZ.js} +5 -6
  23. package/dist/{use-AFCJUIGA.js → use-YB75NHTE.js} +7 -8
  24. package/package.json +1 -1
  25. package/dist/chunk-ES5BRAKJ.js +0 -88
@@ -1,88 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- getOrigin,
4
- getToken
5
- } from "./chunk-D5UZW42X.js";
6
-
7
- // src/api.ts
8
- var REAUTH_MESSAGE = "Cloop session expired or unauthenticated. Run `cloop login`.";
9
- var ReauthError = class extends Error {
10
- constructor(message = REAUTH_MESSAGE) {
11
- super(message);
12
- this.name = "ReauthError";
13
- }
14
- };
15
- var ApiError = class extends Error {
16
- constructor(status, message, body = "") {
17
- super(message);
18
- this.status = status;
19
- this.body = body;
20
- this.name = "ApiError";
21
- }
22
- status;
23
- body;
24
- };
25
- function buildUrl(origin, path, query) {
26
- const url = new URL(path, `${origin}/`);
27
- if (query) {
28
- for (const [key, value] of Object.entries(query)) {
29
- if (value !== void 0) url.searchParams.set(key, value);
30
- }
31
- }
32
- return url.toString();
33
- }
34
- async function api(path, opts = {}) {
35
- const {
36
- method = "GET",
37
- body,
38
- query,
39
- auth = true,
40
- fetchFn = fetch,
41
- origin = getOrigin(),
42
- timeoutMs
43
- } = opts;
44
- const headers = { accept: "application/json" };
45
- if (auth) {
46
- const token = getToken();
47
- if (!token) throw new ReauthError();
48
- headers.authorization = `Bearer ${token}`;
49
- }
50
- if (body !== void 0) headers["content-type"] = "application/json";
51
- const url = buildUrl(origin, path, query);
52
- const init = {
53
- method,
54
- headers,
55
- ...body !== void 0 ? { body: JSON.stringify(body) } : {}
56
- };
57
- const attempt = () => fetchFn(url, timeoutMs ? { ...init, signal: AbortSignal.timeout(timeoutMs) } : init);
58
- let res;
59
- try {
60
- res = await attempt();
61
- } catch (err) {
62
- try {
63
- res = await attempt();
64
- } catch {
65
- const detail = err instanceof Error ? err.message : String(err);
66
- throw new ApiError(0, `Network error reaching ${url}: ${detail}`);
67
- }
68
- }
69
- if (res.status === 401) throw new ReauthError();
70
- if (!res.ok) {
71
- const text2 = await res.text().catch(() => "");
72
- throw new ApiError(
73
- res.status,
74
- `Cloop API ${res.status} for ${path}: ${text2.slice(0, 300)}`,
75
- text2
76
- );
77
- }
78
- if (res.status === 204) return void 0;
79
- const text = await res.text();
80
- if (!text) return void 0;
81
- return JSON.parse(text);
82
- }
83
-
84
- export {
85
- ReauthError,
86
- ApiError,
87
- api
88
- };