@agentvalet/register 0.3.3 → 0.3.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.
- package/dist/index.js +14 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -534,7 +534,7 @@ import prompts3 from "prompts";
|
|
|
534
534
|
import { createOAuthDeviceAuth } from "@octokit/auth-oauth-device";
|
|
535
535
|
import open from "open";
|
|
536
536
|
import chalk3 from "chalk";
|
|
537
|
-
var GITHUB_CLIENT_ID = process.env.AGENTVALET_GITHUB_CLIENT_ID ?? "
|
|
537
|
+
var GITHUB_CLIENT_ID = process.env.AGENTVALET_GITHUB_CLIENT_ID ?? "Ov23liQcaW0HcqJxmLfF";
|
|
538
538
|
async function authenticateWithGitHub() {
|
|
539
539
|
const auth = createOAuthDeviceAuth({
|
|
540
540
|
clientType: "oauth-app",
|
|
@@ -586,20 +586,26 @@ async function getGitHubUser(token) {
|
|
|
586
586
|
}
|
|
587
587
|
|
|
588
588
|
// src/api/agentvalet.ts
|
|
589
|
-
var
|
|
589
|
+
var SUPABASE_URL = "https://jmodblrolfoavrxqgbps.supabase.co";
|
|
590
|
+
var SUPABASE_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imptb2RibHJvbGZvYXZyeHFnYnBzIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzQwODIzNzYsImV4cCI6MjA4OTY1ODM3Nn0.xQQiYHXbDsHyiTd5TsAfXtNWBUGkT4eO7Ew9UH8n6UE";
|
|
591
|
+
var FUNCTIONS_URL = `${SUPABASE_URL}/functions/v1`;
|
|
592
|
+
var baseHeaders = {
|
|
593
|
+
"Content-Type": "application/json",
|
|
594
|
+
"apikey": SUPABASE_ANON_KEY
|
|
595
|
+
};
|
|
590
596
|
async function createOrFindAccount(params) {
|
|
591
597
|
const controller = new AbortController();
|
|
592
598
|
const timeout = setTimeout(() => controller.abort(), 1e4);
|
|
593
599
|
try {
|
|
594
|
-
const response = await fetch(`${
|
|
600
|
+
const response = await fetch(`${FUNCTIONS_URL}/cli-account`, {
|
|
595
601
|
method: "POST",
|
|
596
|
-
headers:
|
|
602
|
+
headers: baseHeaders,
|
|
597
603
|
body: JSON.stringify(params),
|
|
598
604
|
signal: controller.signal
|
|
599
605
|
});
|
|
600
606
|
if (!response.ok) {
|
|
601
607
|
const error = await response.json().catch(() => ({}));
|
|
602
|
-
throw new Error(`Account
|
|
608
|
+
throw new Error(`Account setup failed: ${response.status} ${error.error ?? ""}`);
|
|
603
609
|
}
|
|
604
610
|
return response.json();
|
|
605
611
|
} catch (err) {
|
|
@@ -614,10 +620,10 @@ async function registerAgent2(params, apiKey) {
|
|
|
614
620
|
const controller = new AbortController();
|
|
615
621
|
const timeout = setTimeout(() => controller.abort(), 1e4);
|
|
616
622
|
try {
|
|
617
|
-
const response = await fetch(`${
|
|
623
|
+
const response = await fetch(`${FUNCTIONS_URL}/cli-register-agent`, {
|
|
618
624
|
method: "POST",
|
|
619
625
|
headers: {
|
|
620
|
-
|
|
626
|
+
...baseHeaders,
|
|
621
627
|
"Authorization": `Bearer ${apiKey}`
|
|
622
628
|
},
|
|
623
629
|
body: JSON.stringify(params),
|
|
@@ -625,7 +631,7 @@ async function registerAgent2(params, apiKey) {
|
|
|
625
631
|
});
|
|
626
632
|
if (!response.ok) {
|
|
627
633
|
const error = await response.json().catch(() => ({}));
|
|
628
|
-
throw new Error(`Agent registration failed: ${response.status} ${error.
|
|
634
|
+
throw new Error(`Agent registration failed: ${response.status} ${error.error ?? ""}`);
|
|
629
635
|
}
|
|
630
636
|
return response.json();
|
|
631
637
|
} catch (err) {
|