@cabane/cli 0.1.5 → 0.1.6
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/cli.js +20 -9
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1029,14 +1029,23 @@ async function setupAgent(opts) {
|
|
|
1029
1029
|
const client = makeClient(base, token);
|
|
1030
1030
|
const me = await client.get("/api/auth/me");
|
|
1031
1031
|
ok(`owner resolved (${me.user.id})`);
|
|
1032
|
-
const
|
|
1033
|
-
ok("setup complete");
|
|
1032
|
+
const assignment = await defaultAgentAssignment(client);
|
|
1034
1033
|
info("");
|
|
1035
|
-
|
|
1036
|
-
|
|
1034
|
+
if (assignment.kind === "unavailable") {
|
|
1035
|
+
info("Agent assignment could not be checked. Open Cabane to verify it.");
|
|
1036
|
+
return;
|
|
1037
|
+
}
|
|
1038
|
+
const { username, executor } = assignment.agent;
|
|
1039
|
+
if (executor.deviceId) {
|
|
1040
|
+
info(`Agent @${username} is assigned to ${executor.deviceLabel}.`);
|
|
1041
|
+
return;
|
|
1042
|
+
}
|
|
1043
|
+
info(`Agent @${username} has no device assigned.`);
|
|
1037
1044
|
info(" 1. Install the Companion \u2014 the desktop app, or the headless `@cabane/companion`.");
|
|
1038
1045
|
info(` 2. Sign in against this instance (${instanceUrl}) and pair the device.`);
|
|
1039
|
-
info(
|
|
1046
|
+
info(
|
|
1047
|
+
` 3. Assign @${username} to the device, then choose a connector on it and message the agent in the app.`
|
|
1048
|
+
);
|
|
1040
1049
|
}
|
|
1041
1050
|
async function healthy(port) {
|
|
1042
1051
|
try {
|
|
@@ -1054,18 +1063,20 @@ async function resolvePat(opts, base) {
|
|
|
1054
1063
|
}
|
|
1055
1064
|
throw new Error("no access token. Pass --token <cab_\u2026> (mint it in Settings \u2192 Developer).");
|
|
1056
1065
|
}
|
|
1057
|
-
async function
|
|
1066
|
+
async function defaultAgentAssignment(client) {
|
|
1058
1067
|
try {
|
|
1059
1068
|
const { workspaces } = await client.get("/api/workspaces");
|
|
1060
1069
|
const workspace = workspaces.find((w) => w.role === "owner") ?? workspaces[0];
|
|
1061
|
-
if (!workspace) return "
|
|
1070
|
+
if (!workspace) return { kind: "unavailable" };
|
|
1062
1071
|
const { agents } = await client.get(
|
|
1063
1072
|
`/api/workspaces/${workspace.id}/agents`
|
|
1064
1073
|
);
|
|
1065
1074
|
const agent = workspace.defaultAgentId && agents.find((a) => a.id === workspace.defaultAgentId) || agents.find((a) => a.username === "cabane") || agents[0];
|
|
1066
|
-
|
|
1075
|
+
if (!agent?.username || !agent.executor) return { kind: "unavailable" };
|
|
1076
|
+
if (agent.executor.deviceId && !agent.executor.deviceLabel) return { kind: "unavailable" };
|
|
1077
|
+
return { kind: "resolved", agent };
|
|
1067
1078
|
} catch {
|
|
1068
|
-
return "
|
|
1079
|
+
return { kind: "unavailable" };
|
|
1069
1080
|
}
|
|
1070
1081
|
}
|
|
1071
1082
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cabane/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The cabane CLI — install, run, and update a self-hosted Cabane on your own machine (server + embedded Postgres; agents run on a companion you pair).",
|
|
6
6
|
"license": "UNLICENSED",
|