@agentbridge1/cli 0.0.3 → 0.0.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.
@@ -1,6 +1,6 @@
1
1
  {
2
- "builtAt": "2026-06-02T01:31:45.533Z",
3
- "gitHead": "184f85c",
4
- "sourceLatestMtime": "2026-06-02T01:19:37.980Z",
5
- "sourceLatestFile": "src/commands/recover.ts"
2
+ "builtAt": "2026-06-02T04:55:04.008Z",
3
+ "gitHead": "86fed7f",
4
+ "sourceLatestMtime": "2026-06-02T04:51:46.614Z",
5
+ "sourceLatestFile": "src/commands/connect.ts"
6
6
  }
@@ -10,35 +10,68 @@ function resolveBaseUrl(override) {
10
10
  config_1.DEFAULT_API_BASE_URL);
11
11
  }
12
12
  async function verifyCredentials(projectId, apiKey, apiBaseUrl) {
13
- const url = `${apiBaseUrl}/v1/dev/projects/${projectId}/health`;
14
- let res;
15
- try {
16
- res = await fetch(url, {
17
- method: "GET",
18
- headers: {
19
- Authorization: `Bearer ${apiKey}`,
20
- "Content-Type": "application/json",
21
- },
22
- });
13
+ const summaryUrl = `${apiBaseUrl}/v1/dev/projects/${projectId}/summary`;
14
+ const packetUrl = `${apiBaseUrl}/v1/dev/projects/${projectId}/packet`;
15
+ const headers = {
16
+ Authorization: `Bearer ${apiKey}`,
17
+ "Content-Type": "application/json",
18
+ };
19
+ async function get(url) {
20
+ try {
21
+ return await fetch(url, { method: "GET", headers });
22
+ }
23
+ catch (e) {
24
+ const msg = e instanceof Error ? e.message : String(e);
25
+ throw new errors_1.SafeCliError(`Could not reach AgentBridge server at ${apiBaseUrl}.\nNetwork error: ${msg}\n\nCheck your AGENTBRIDGE_BASE_URL or internet connection.`);
26
+ }
23
27
  }
24
- catch (e) {
25
- const msg = e instanceof Error ? e.message : String(e);
26
- throw new errors_1.SafeCliError(`Could not reach AgentBridge server at ${apiBaseUrl}.\nNetwork error: ${msg}\n\nCheck your AGENTBRIDGE_BASE_URL or internet connection.`);
28
+ async function readBody(res) {
29
+ try {
30
+ return await res.text();
31
+ }
32
+ catch {
33
+ return "";
34
+ }
27
35
  }
28
- if (res.status === 401 || res.status === 403) {
29
- throw new errors_1.SafeCliError(`API key rejected (HTTP ${res.status}).\n\nGet a valid key at https://agentbridge.dev/dashboard and set AGENTBRIDGE_API_KEY.`);
36
+ function isRouteMissing(body) {
37
+ return body.toLowerCase().includes("route not found");
30
38
  }
31
- if (res.status === 404) {
32
- throw new errors_1.SafeCliError(`Project not found on ${apiBaseUrl}. Check project ID or backend URL.`);
39
+ async function throwAuthOrNotFound(res) {
40
+ if (res.status === 401 || res.status === 403) {
41
+ throw new errors_1.SafeCliError(`API key rejected (HTTP ${res.status}).\n\nGet a valid key at https://agentbridge.dev/dashboard and set AGENTBRIDGE_API_KEY.`);
42
+ }
43
+ if (res.status === 404) {
44
+ throw new errors_1.SafeCliError(`Project not found or key has no access on ${apiBaseUrl}.\nCheck project ID, API key, and backend URL.`);
45
+ }
46
+ const text = await readBody(res);
47
+ throw new http_1.CliHttpError(`GET ${summaryUrl} failed (${res.status}): ${text || "<empty>"}`, res.status, text);
48
+ }
49
+ let res;
50
+ res = await get(summaryUrl);
51
+ if (res.ok) {
52
+ const body = (await res.json());
53
+ return {
54
+ projectName: body.project_name ?? body.projectName ?? projectId,
55
+ agentCount: typeof body.agent_count === "number"
56
+ ? body.agent_count
57
+ : Array.isArray(body.agents)
58
+ ? body.agents.length
59
+ : 0,
60
+ };
33
61
  }
34
- if (!res.ok) {
35
- const text = await res.text();
36
- throw new http_1.CliHttpError(`GET ${url} failed (${res.status}): ${text || "<empty>"}`, res.status, text);
62
+ const summaryBody = await readBody(res);
63
+ if (!(res.status === 404 && isRouteMissing(summaryBody))) {
64
+ await throwAuthOrNotFound(res);
37
65
  }
38
- const body = (await res.json());
66
+ // Backward compatibility for servers that haven't shipped /summary yet.
67
+ const packetRes = await get(packetUrl);
68
+ if (!packetRes.ok) {
69
+ await throwAuthOrNotFound(packetRes);
70
+ }
71
+ const packetBody = (await packetRes.json());
39
72
  return {
40
- projectName: body.projectName ?? projectId,
41
- agentCount: Array.isArray(body.agents) ? body.agents.length : 0,
73
+ projectName: packetBody.project_name ?? projectId,
74
+ agentCount: 0,
42
75
  };
43
76
  }
44
77
  async function listAgents(projectId, apiKey, apiBaseUrl) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentbridge1/cli",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "CLI for AgentBridge — structured AI agent work sessions with domain authority and approval gates",
5
5
  "type": "commonjs",
6
6
  "bin": {