@cloop/runner 0.3.29 → 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.
- package/README.md +7 -0
- package/dist/{box-6TJMXQXM.js → box-RFAHCXZS.js} +239 -69
- package/dist/chunk-52CUSFDQ.js +401 -0
- package/dist/{chunk-P56EL4D4.js → chunk-7AHYPGSU.js} +2 -2
- package/dist/{chunk-65KJPIZC.js → chunk-FKYVJUIR.js} +1 -1
- package/dist/{chunk-4FXRG3Q3.js → chunk-GL77IQQE.js} +1 -1
- package/dist/{chunk-SVHQXVCH.js → chunk-MEAVT5SJ.js} +986 -205
- package/dist/{chunk-AIOOLVM7.js → chunk-R73PVAM2.js} +182 -88
- package/dist/{chunk-NTXQLEMQ.js → chunk-SBYSVZ7J.js} +94 -2
- package/dist/{chunk-PSA5EC65.js → chunk-UERK5AHI.js} +6 -6
- package/dist/{chunk-TWDKR7XV.js → chunk-WYU74GLG.js} +5 -5
- package/dist/{chunk-GURADB5L.js → chunk-YLVOEZWH.js} +1 -1
- package/dist/{connect-HVUNZ6A2.js → connect-WRTLQW5H.js} +10 -9
- package/dist/{disconnect-NXVDABS5.js → disconnect-I44BWWFB.js} +8 -9
- package/dist/existing-runner-SP6SNFH4.js +20 -0
- package/dist/{hook-activity-GAJ5NABA.js → hook-activity-3T6IMEM6.js} +2 -3
- package/dist/{hook-session-start-5JYNMGX4.js → hook-session-start-DLP77G4H.js} +5 -7
- package/dist/index.js +20 -17
- package/dist/{login-PH2RZNOE.js → login-LH2KF7N2.js} +3 -3
- package/dist/{mcp-server-U2H4U4BZ.js → mcp-server-SGIWNLLL.js} +9 -11
- package/dist/{runner-YTGTJPPR.js → runner-SXUQH5IU.js} +4 -4
- package/dist/{runs-D7XT2PYS.js → runs-3YZO57MX.js} +2 -2
- package/dist/{statusline-U4K2IQIT.js → statusline-UHZTCNCB.js} +1 -1
- package/dist/{takeover-M2SDWTVK.js → takeover-M4QHMXTZ.js} +5 -6
- package/dist/{use-7OUFEREN.js → use-YB75NHTE.js} +8 -9
- package/package.json +1 -1
- package/dist/chunk-ES5BRAKJ.js +0 -88
- package/dist/chunk-KYGYU5G2.js +0 -220
- package/dist/existing-runner-7E6RUUJH.js +0 -21
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
ApiError,
|
|
4
|
-
api
|
|
5
|
-
|
|
4
|
+
api,
|
|
5
|
+
defaultDeviceName
|
|
6
|
+
} from "./chunk-SBYSVZ7J.js";
|
|
6
7
|
import {
|
|
7
8
|
VERSION
|
|
8
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-GL77IQQE.js";
|
|
9
10
|
import {
|
|
10
11
|
getOrigin,
|
|
11
12
|
readCredentials,
|
|
@@ -14,7 +15,6 @@ import {
|
|
|
14
15
|
|
|
15
16
|
// src/commands/login.ts
|
|
16
17
|
import { execFile } from "child_process";
|
|
17
|
-
import { hostname } from "os";
|
|
18
18
|
|
|
19
19
|
// src/connect-report.ts
|
|
20
20
|
import { randomUUID } from "crypto";
|
|
@@ -142,7 +142,7 @@ function openUrl(url) {
|
|
|
142
142
|
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
143
143
|
async function loginCommand(argv = process.argv.slice(2)) {
|
|
144
144
|
const origin = getOrigin();
|
|
145
|
-
const deviceName = parseDeviceName(argv) ??
|
|
145
|
+
const deviceName = parseDeviceName(argv) ?? defaultDeviceName();
|
|
146
146
|
const existing = readCredentials();
|
|
147
147
|
let token;
|
|
148
148
|
try {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
DEFAULT_T3_URL,
|
|
4
4
|
DRIVER_NAME,
|
|
5
|
+
FIRST_CONNECT_MS,
|
|
5
6
|
T3PairError,
|
|
6
7
|
WINGET_UPDATE,
|
|
7
8
|
askHidden,
|
|
@@ -52,22 +53,22 @@ import {
|
|
|
52
53
|
which,
|
|
53
54
|
workFolder,
|
|
54
55
|
workFolderLine
|
|
55
|
-
} from "./chunk-
|
|
56
|
-
import "./chunk-
|
|
57
|
-
import "./chunk-
|
|
58
|
-
import "./chunk-
|
|
59
|
-
import "./chunk-NTXQLEMQ.js";
|
|
56
|
+
} from "./chunk-MEAVT5SJ.js";
|
|
57
|
+
import "./chunk-52CUSFDQ.js";
|
|
58
|
+
import "./chunk-YLVOEZWH.js";
|
|
59
|
+
import "./chunk-R73PVAM2.js";
|
|
60
60
|
import "./chunk-VK6GV757.js";
|
|
61
61
|
import "./chunk-365HFCQQ.js";
|
|
62
62
|
import "./chunk-PKIEWBR7.js";
|
|
63
|
-
import "./chunk-
|
|
64
|
-
import "./chunk-
|
|
65
|
-
import "./chunk-
|
|
66
|
-
import "./chunk-
|
|
63
|
+
import "./chunk-7AHYPGSU.js";
|
|
64
|
+
import "./chunk-WYU74GLG.js";
|
|
65
|
+
import "./chunk-SBYSVZ7J.js";
|
|
66
|
+
import "./chunk-GL77IQQE.js";
|
|
67
67
|
import "./chunk-D5UZW42X.js";
|
|
68
68
|
export {
|
|
69
69
|
DEFAULT_T3_URL,
|
|
70
70
|
DRIVER_NAME,
|
|
71
|
+
FIRST_CONNECT_MS,
|
|
71
72
|
T3PairError,
|
|
72
73
|
WINGET_UPDATE,
|
|
73
74
|
askHidden,
|
|
@@ -7,18 +7,17 @@ import {
|
|
|
7
7
|
runnerOrigin,
|
|
8
8
|
stopService,
|
|
9
9
|
unitOrigin
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-NTXQLEMQ.js";
|
|
10
|
+
} from "./chunk-MEAVT5SJ.js";
|
|
11
|
+
import "./chunk-52CUSFDQ.js";
|
|
12
|
+
import "./chunk-YLVOEZWH.js";
|
|
13
|
+
import "./chunk-R73PVAM2.js";
|
|
15
14
|
import "./chunk-VK6GV757.js";
|
|
16
15
|
import "./chunk-365HFCQQ.js";
|
|
17
16
|
import "./chunk-PKIEWBR7.js";
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-7AHYPGSU.js";
|
|
18
|
+
import "./chunk-WYU74GLG.js";
|
|
19
|
+
import "./chunk-SBYSVZ7J.js";
|
|
20
|
+
import "./chunk-GL77IQQE.js";
|
|
22
21
|
import "./chunk-D5UZW42X.js";
|
|
23
22
|
export {
|
|
24
23
|
disconnect,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
existingRunnerEnvironment,
|
|
4
|
+
pinExistingRunner
|
|
5
|
+
} from "./chunk-MEAVT5SJ.js";
|
|
6
|
+
import "./chunk-52CUSFDQ.js";
|
|
7
|
+
import "./chunk-YLVOEZWH.js";
|
|
8
|
+
import "./chunk-R73PVAM2.js";
|
|
9
|
+
import "./chunk-VK6GV757.js";
|
|
10
|
+
import "./chunk-365HFCQQ.js";
|
|
11
|
+
import "./chunk-PKIEWBR7.js";
|
|
12
|
+
import "./chunk-7AHYPGSU.js";
|
|
13
|
+
import "./chunk-WYU74GLG.js";
|
|
14
|
+
import "./chunk-SBYSVZ7J.js";
|
|
15
|
+
import "./chunk-GL77IQQE.js";
|
|
16
|
+
import "./chunk-D5UZW42X.js";
|
|
17
|
+
export {
|
|
18
|
+
existingRunnerEnvironment,
|
|
19
|
+
pinExistingRunner
|
|
20
|
+
};
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
toolPhrase,
|
|
6
6
|
writeSessionState
|
|
7
7
|
} from "./chunk-EVIVOEJY.js";
|
|
8
|
+
import "./chunk-VK6GV757.js";
|
|
8
9
|
import {
|
|
9
10
|
HeartbeatClient,
|
|
10
11
|
detectPlatform,
|
|
@@ -12,9 +13,7 @@ import {
|
|
|
12
13
|
getName,
|
|
13
14
|
getSurface,
|
|
14
15
|
sanitizeSessionKey
|
|
15
|
-
} from "./chunk-
|
|
16
|
-
import "./chunk-VK6GV757.js";
|
|
17
|
-
import "./chunk-ES5BRAKJ.js";
|
|
16
|
+
} from "./chunk-SBYSVZ7J.js";
|
|
18
17
|
import {
|
|
19
18
|
getToken
|
|
20
19
|
} from "./chunk-D5UZW42X.js";
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
sanitizeLabel
|
|
4
|
+
} from "./chunk-VK6GV757.js";
|
|
2
5
|
import {
|
|
3
6
|
HeartbeatClient,
|
|
7
|
+
api,
|
|
4
8
|
detectPlatform,
|
|
5
9
|
getMachine,
|
|
6
10
|
getName,
|
|
7
11
|
getSurface,
|
|
8
12
|
newSessionKey
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import {
|
|
11
|
-
sanitizeLabel
|
|
12
|
-
} from "./chunk-VK6GV757.js";
|
|
13
|
-
import {
|
|
14
|
-
api
|
|
15
|
-
} from "./chunk-ES5BRAKJ.js";
|
|
13
|
+
} from "./chunk-SBYSVZ7J.js";
|
|
16
14
|
import {
|
|
17
15
|
getToken
|
|
18
16
|
} from "./chunk-D5UZW42X.js";
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-365HFCQQ.js";
|
|
5
5
|
import {
|
|
6
6
|
VERSION
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-GL77IQQE.js";
|
|
8
8
|
import {
|
|
9
9
|
applyEnvironmentFlag
|
|
10
10
|
} from "./chunk-D5UZW42X.js";
|
|
@@ -40,7 +40,10 @@ Usage:
|
|
|
40
40
|
link from T3 Code (Settings, Connections,
|
|
41
41
|
Create pairing link) at the question, or pass
|
|
42
42
|
it with --t3-pair. Cloop shows the threads you
|
|
43
|
-
started yourself; --hide-other-threads hides them
|
|
43
|
+
started yourself; --hide-other-threads hides them.
|
|
44
|
+
Cloop also reads what you and your agents say
|
|
45
|
+
and do in those threads, redacted here, never
|
|
46
|
+
tool output or files
|
|
44
47
|
cloop use t3|claude-code|codex Run Cloop work here with that harness. It reconnects
|
|
45
48
|
this machine, swaps its service, and keeps the choice
|
|
46
49
|
cloop disconnect [--yes] Stop being a Cloop machine in one environment: revoke
|
|
@@ -65,7 +68,7 @@ Add --staging to any command to use Cloop staging instead of production.
|
|
|
65
68
|
A production machine and a staging machine can run side by side on one computer.
|
|
66
69
|
`;
|
|
67
70
|
async function pinExistingRunner() {
|
|
68
|
-
const { pinExistingRunner: pin } = await import("./existing-runner-
|
|
71
|
+
const { pinExistingRunner: pin } = await import("./existing-runner-SP6SNFH4.js");
|
|
69
72
|
const { note } = pin();
|
|
70
73
|
if (note) console.error(note);
|
|
71
74
|
}
|
|
@@ -73,7 +76,7 @@ async function main() {
|
|
|
73
76
|
switch (command) {
|
|
74
77
|
case "login":
|
|
75
78
|
case "auth": {
|
|
76
|
-
const { loginCommand } = await import("./login-
|
|
79
|
+
const { loginCommand } = await import("./login-LH2KF7N2.js");
|
|
77
80
|
await loginCommand(argv);
|
|
78
81
|
break;
|
|
79
82
|
}
|
|
@@ -83,61 +86,61 @@ async function main() {
|
|
|
83
86
|
break;
|
|
84
87
|
}
|
|
85
88
|
case "serve": {
|
|
86
|
-
const { startMcpServer } = await import("./mcp-server-
|
|
89
|
+
const { startMcpServer } = await import("./mcp-server-SGIWNLLL.js");
|
|
87
90
|
await startMcpServer();
|
|
88
91
|
break;
|
|
89
92
|
}
|
|
90
93
|
case "statusline": {
|
|
91
|
-
const { statuslineCommand } = await import("./statusline-
|
|
94
|
+
const { statuslineCommand } = await import("./statusline-UHZTCNCB.js");
|
|
92
95
|
statuslineCommand();
|
|
93
96
|
break;
|
|
94
97
|
}
|
|
95
98
|
case "connect": {
|
|
96
|
-
const { connectCommand } = await import("./connect-
|
|
99
|
+
const { connectCommand } = await import("./connect-WRTLQW5H.js");
|
|
97
100
|
await connectCommand(argv.slice(1));
|
|
98
101
|
break;
|
|
99
102
|
}
|
|
100
103
|
case "use": {
|
|
101
|
-
const { useCommand } = await import("./use-
|
|
104
|
+
const { useCommand } = await import("./use-YB75NHTE.js");
|
|
102
105
|
process.exitCode = await useCommand(argv.slice(1));
|
|
103
106
|
break;
|
|
104
107
|
}
|
|
105
108
|
case "disconnect": {
|
|
106
|
-
const { disconnectCommand } = await import("./disconnect-
|
|
109
|
+
const { disconnectCommand } = await import("./disconnect-I44BWWFB.js");
|
|
107
110
|
await disconnectCommand(argv.slice(1));
|
|
108
111
|
break;
|
|
109
112
|
}
|
|
110
113
|
case "box": {
|
|
111
|
-
const { boxCommand } = await import("./box-
|
|
114
|
+
const { boxCommand } = await import("./box-RFAHCXZS.js");
|
|
112
115
|
await boxCommand(argv.slice(1));
|
|
113
116
|
break;
|
|
114
117
|
}
|
|
115
118
|
case "runs": {
|
|
116
119
|
await pinExistingRunner();
|
|
117
|
-
const { runsCommand } = await import("./runs-
|
|
120
|
+
const { runsCommand } = await import("./runs-3YZO57MX.js");
|
|
118
121
|
process.exitCode = runsCommand();
|
|
119
122
|
break;
|
|
120
123
|
}
|
|
121
124
|
case "watch": {
|
|
122
125
|
await pinExistingRunner();
|
|
123
|
-
const { watchCommand } = await import("./runs-
|
|
126
|
+
const { watchCommand } = await import("./runs-3YZO57MX.js");
|
|
124
127
|
process.exitCode = await watchCommand(argv.slice(1));
|
|
125
128
|
break;
|
|
126
129
|
}
|
|
127
130
|
case "takeover": {
|
|
128
131
|
await pinExistingRunner();
|
|
129
|
-
const { takeoverCommand } = await import("./takeover-
|
|
132
|
+
const { takeoverCommand } = await import("./takeover-M4QHMXTZ.js");
|
|
130
133
|
process.exitCode = await takeoverCommand(argv.slice(1));
|
|
131
134
|
break;
|
|
132
135
|
}
|
|
133
136
|
case "resume": {
|
|
134
137
|
await pinExistingRunner();
|
|
135
|
-
const { resumeCommand } = await import("./runs-
|
|
138
|
+
const { resumeCommand } = await import("./runs-3YZO57MX.js");
|
|
136
139
|
process.exitCode = await resumeCommand(argv.slice(1));
|
|
137
140
|
break;
|
|
138
141
|
}
|
|
139
142
|
case "runner": {
|
|
140
|
-
const { runnerCommand } = await import("./runner-
|
|
143
|
+
const { runnerCommand } = await import("./runner-SXUQH5IU.js");
|
|
141
144
|
await runnerCommand(argv.slice(1));
|
|
142
145
|
break;
|
|
143
146
|
}
|
|
@@ -146,10 +149,10 @@ async function main() {
|
|
|
146
149
|
const { runnerPermissionHook } = await import("./read-permissions-EGSGI4HL.js");
|
|
147
150
|
await runnerPermissionHook();
|
|
148
151
|
} else if (argv[1] === "session-start") {
|
|
149
|
-
const { hookSessionStart } = await import("./hook-session-start-
|
|
152
|
+
const { hookSessionStart } = await import("./hook-session-start-DLP77G4H.js");
|
|
150
153
|
await hookSessionStart();
|
|
151
154
|
} else if (argv[1] === "activity") {
|
|
152
|
-
const { hookActivity } = await import("./hook-activity-
|
|
155
|
+
const { hookActivity } = await import("./hook-activity-3T6IMEM6.js");
|
|
153
156
|
await hookActivity();
|
|
154
157
|
} else {
|
|
155
158
|
console.error(`Unknown hook: ${argv[1] ?? "(none)"}`);
|
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
deviceLogin,
|
|
4
4
|
loginCommand,
|
|
5
5
|
refusalSentence
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-WYU74GLG.js";
|
|
7
|
+
import "./chunk-SBYSVZ7J.js";
|
|
8
|
+
import "./chunk-GL77IQQE.js";
|
|
9
9
|
import "./chunk-D5UZW42X.js";
|
|
10
10
|
export {
|
|
11
11
|
deviceLogin,
|
|
@@ -14,26 +14,24 @@ import {
|
|
|
14
14
|
import {
|
|
15
15
|
MeshSocket,
|
|
16
16
|
defaultSocketFactory
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-52CUSFDQ.js";
|
|
18
|
+
import {
|
|
19
|
+
sanitizeLabel,
|
|
20
|
+
sanitizeUntrusted
|
|
21
|
+
} from "./chunk-VK6GV757.js";
|
|
18
22
|
import {
|
|
19
23
|
HeartbeatClient,
|
|
24
|
+
ReauthError,
|
|
25
|
+
api,
|
|
20
26
|
detectPlatform,
|
|
21
27
|
getMachine,
|
|
22
28
|
getName,
|
|
23
29
|
getSurface,
|
|
24
30
|
newSessionKey
|
|
25
|
-
} from "./chunk-
|
|
26
|
-
import {
|
|
27
|
-
sanitizeLabel,
|
|
28
|
-
sanitizeUntrusted
|
|
29
|
-
} from "./chunk-VK6GV757.js";
|
|
30
|
-
import {
|
|
31
|
-
ReauthError,
|
|
32
|
-
api
|
|
33
|
-
} from "./chunk-ES5BRAKJ.js";
|
|
31
|
+
} from "./chunk-SBYSVZ7J.js";
|
|
34
32
|
import {
|
|
35
33
|
VERSION
|
|
36
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-GL77IQQE.js";
|
|
37
35
|
import {
|
|
38
36
|
getMeshUrl,
|
|
39
37
|
getToken
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import {
|
|
3
3
|
connectWebhook,
|
|
4
4
|
runnerCommand
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-7AHYPGSU.js";
|
|
6
|
+
import "./chunk-WYU74GLG.js";
|
|
7
|
+
import "./chunk-SBYSVZ7J.js";
|
|
8
|
+
import "./chunk-GL77IQQE.js";
|
|
9
9
|
import "./chunk-D5UZW42X.js";
|
|
10
10
|
export {
|
|
11
11
|
connectWebhook,
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
runsCommand,
|
|
10
10
|
sessionFolder,
|
|
11
11
|
watchCommand
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-FKYVJUIR.js";
|
|
13
|
+
import "./chunk-R73PVAM2.js";
|
|
14
14
|
import "./chunk-VK6GV757.js";
|
|
15
15
|
import "./chunk-D5UZW42X.js";
|
|
16
16
|
export {
|
|
@@ -9,13 +9,12 @@ import {
|
|
|
9
9
|
takeoverDir,
|
|
10
10
|
writeTakeoverReply,
|
|
11
11
|
writeTakeoverRequest
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
16
|
-
import "./chunk-NTXQLEMQ.js";
|
|
12
|
+
} from "./chunk-UERK5AHI.js";
|
|
13
|
+
import "./chunk-FKYVJUIR.js";
|
|
14
|
+
import "./chunk-YLVOEZWH.js";
|
|
15
|
+
import "./chunk-R73PVAM2.js";
|
|
17
16
|
import "./chunk-VK6GV757.js";
|
|
18
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-SBYSVZ7J.js";
|
|
19
18
|
import "./chunk-D5UZW42X.js";
|
|
20
19
|
export {
|
|
21
20
|
endInFile,
|
|
@@ -3,21 +3,20 @@ import {
|
|
|
3
3
|
DRIVER_NAME,
|
|
4
4
|
pinExistingRunner,
|
|
5
5
|
runConnect
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-MEAVT5SJ.js";
|
|
7
|
+
import "./chunk-52CUSFDQ.js";
|
|
8
|
+
import "./chunk-YLVOEZWH.js";
|
|
9
9
|
import {
|
|
10
10
|
isLocal,
|
|
11
11
|
readRunnerConfig
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-NTXQLEMQ.js";
|
|
12
|
+
} from "./chunk-R73PVAM2.js";
|
|
14
13
|
import "./chunk-VK6GV757.js";
|
|
15
14
|
import "./chunk-365HFCQQ.js";
|
|
16
15
|
import "./chunk-PKIEWBR7.js";
|
|
17
|
-
import "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-7AHYPGSU.js";
|
|
17
|
+
import "./chunk-WYU74GLG.js";
|
|
18
|
+
import "./chunk-SBYSVZ7J.js";
|
|
19
|
+
import "./chunk-GL77IQQE.js";
|
|
21
20
|
import "./chunk-D5UZW42X.js";
|
|
22
21
|
|
|
23
22
|
// src/commands/use.ts
|
package/package.json
CHANGED
package/dist/chunk-ES5BRAKJ.js
DELETED
|
@@ -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
|
-
};
|