kairos-cli 0.0.4 → 0.0.5

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 CHANGED
@@ -1,53 +1,79 @@
1
1
  # kairos-cli
2
2
 
3
- The local command-line bridge for KairOS AI tools.
3
+ Local command-line bridge for KairOS AI tools.
4
4
 
5
- `kairos-cli` lets an AI agent (or you) authenticate once and then call KairOS tools from your machine.
6
-
7
- ## Install
5
+ **AI agents** need this CLI **and** the **kairos-skill** skill on [skills.sh](https://skills.sh):
8
6
 
9
7
  ```bash
10
8
  npm install -g kairos-cli
11
9
  ```
12
10
 
11
+ Add **kairos-skill** using the `npx skills add …` command from the user's KairOS **Dashboard → Connect your AI agent** (each host includes the correct GitHub source).
12
+
13
13
  ## Authenticate
14
14
 
15
15
  ```bash
16
16
  kairos login --api-url https://your-kairos-url.com
17
- kairos whoami
17
+ kairos whoami # expect: Token valid: yes
18
18
  ```
19
19
 
20
- `kairos login` opens a browser consent flow and stores local credentials for future calls.
20
+ `kairos login` opens a browser consent flow (or prints a URL with `--no-open`) and stores credentials at `~/.config/kairos/credentials.json`.
21
+
22
+ | Flag | Purpose |
23
+ | ----------------- | --------------------------------------------------- |
24
+ | `--api-url <url>` | KairOS app URL; stored in credentials |
25
+ | `--no-open` | Print URL only — for agents / headless environments |
26
+ | `--timeout <sec>` | Max wait for authorize (default 300, minimum 30) |
21
27
 
22
- ## Common commands
28
+ Default API URL: `KAIROS_API_URL` env, else `https://kairos.querobines.com`. Stored `api_url` in credentials wins for later commands.
29
+
30
+ ## Commands
23
31
 
24
32
  ```bash
33
+ kairos logout
25
34
  kairos tools
26
35
  kairos call query_today '{}'
27
36
  kairos call query_tasks '{"activeOnly":true}'
28
37
  kairos call create_task '{"title":"Follow up","status":"todo"}'
29
38
  ```
30
39
 
31
- ## Command summary
40
+ - `kairos call <toolName> '<json>'` — invoke a tool (requires valid token)
41
+ - Tool names and payloads: in **kairos-skill** (`references/tools.md` after install)
42
+
43
+ ## Credentials
32
44
 
33
- - `kairos login [--api-url <url>] [--no-open] [--timeout <seconds>]`
34
- - `kairos logout`
35
- - `kairos whoami`
36
- - `kairos tools`
37
- - `kairos call <toolName> '<json>'`
45
+ `~/.config/kairos/credentials.json` (file mode `600`):
46
+
47
+ ```json
48
+ {
49
+ "api_url": "https://your-kairos-url.com",
50
+ "access_token": "<jwt>",
51
+ "expires_at": "2026-05-18T12:00:00.000Z"
52
+ }
53
+ ```
54
+
55
+ v1 has **no refresh token** (~1 hour JWT). Re-run `kairos login` when `Token valid: no` or tools return **401**.
38
56
 
39
57
  ## Troubleshooting
40
58
 
41
- - `Not authenticated. Run: kairos login`
42
- - Run `kairos login` again to refresh credentials.
43
- - Login opened the wrong environment
44
- - Re-run with explicit URL: `kairos login --api-url https://your-kairos-url.com`
45
- - Agent/non-browser environment
46
- - Use `kairos login --no-open`, copy the printed URL, open it manually, then approve.
59
+ | Symptom | Fix |
60
+ | -------------------------------------- | --------------------------------------------------- |
61
+ | `Not authenticated. Run: kairos login` | Missing or expired credentials — login again |
62
+ | `Token valid: no` | JWT past `expires_at` — `kairos login` |
63
+ | Login silent after URL | Waiting for **Authorize** in browser — check stderr |
64
+ | `Login timed out after Ns` | Re-run login; authorize within timeout |
65
+ | `fetch failed` / wrong data | Wrong host — `kairos login --api-url <correct>` |
66
+ | Redirect to `/login` on consent page | Sign in on the web app first, then authorize |
67
+ | `CODE_EXPIRED` / `PKCE_INVALID` | Fresh login; use the **latest** printed URL only |
68
+ | Tool **401** | `kairos login` |
69
+
70
+ Agent-driven login (`--no-open`, do not background): see `references/auth.md` in **kairos-skill**.
47
71
 
48
72
  ## Local development (monorepo)
49
73
 
50
- From the monorepo root:
74
+ > **Maintainers:** Keep customer-facing sections free of repo-internal links (`docs/`, monorepo paths). Monorepo notes below only.
75
+
76
+ Skill source (before skills.sh publish): `packages/kairos-skill/` · sync with `pnpm skill:sync` from repo root.
51
77
 
52
78
  ```bash
53
79
  pnpm cli:build
@@ -1,6 +1,6 @@
1
1
  /** Default wait for browser consent (matches server auth code TTL). */
2
2
  export declare const DEFAULT_LOGIN_TIMEOUT_MS: number;
3
- /** stderr heartbeat while waiting for loopback callback (documented in docs/cli-auth.md §7). */
3
+ /** stderr heartbeat while waiting for loopback callback (`kairos login --no-open`). */
4
4
  export declare const LOGIN_HEARTBEAT_MS = 15000;
5
5
  /** Minimum `kairos login --timeout` value (seconds). */
6
6
  export declare const MIN_LOGIN_TIMEOUT_SEC = 30;
@@ -4,7 +4,7 @@ import { createPkcePair } from "./pkce.js";
4
4
  import { exchangeDeviceTokenAtApi } from "./device-token-client.js";
5
5
  /** Default wait for browser consent (matches server auth code TTL). */
6
6
  export const DEFAULT_LOGIN_TIMEOUT_MS = 5 * 60 * 1000;
7
- /** stderr heartbeat while waiting for loopback callback (documented in docs/cli-auth.md §7). */
7
+ /** stderr heartbeat while waiting for loopback callback (`kairos login --no-open`). */
8
8
  export const LOGIN_HEARTBEAT_MS = 15_000;
9
9
  /** Minimum `kairos login --timeout` value (seconds). */
10
10
  export const MIN_LOGIN_TIMEOUT_SEC = 30;
@@ -85,6 +85,17 @@ function waitForAuthorizationCode(server, timeoutMs) {
85
85
  res.end();
86
86
  return;
87
87
  }
88
+ const error = urlObj.searchParams.get("error");
89
+ const errorDescription = urlObj.searchParams.get("error_description");
90
+ if (error) {
91
+ res.writeHead(400, {
92
+ "Content-Type": "text/html",
93
+ Connection: "close",
94
+ });
95
+ res.end(`<h1>Auth failed: ${error}</h1><p>${errorDescription || ""}</p>`);
96
+ finish(() => reject(new Error(`Authorization failed: ${error}${errorDescription ? ` - ${errorDescription}` : ""}`)));
97
+ return;
98
+ }
88
99
  const code = urlObj.searchParams.get("code");
89
100
  if (!code) {
90
101
  res.writeHead(400, {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kairos-cli",
3
- "version": "0.0.4",
4
- "description": "KairOS Agent CLI — login and tool calls",
3
+ "version": "0.0.5",
4
+ "description": "KairOS Agent CLI — pair with kairos-skill on skills.sh (install via KairOS dashboard)",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "kairos": "./dist/bin.js"