@schuttdev/kon 0.3.1 → 0.3.3
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 +39 -0
- package/dist/index.js +43 -19
- package/package.json +4 -2
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @schuttdev/kon
|
|
2
|
+
|
|
3
|
+
Lightweight client CLI for [Kon](https://github.com/Kaden-Schutt/kon) — gives Claude access to tools on your machine from any platform.
|
|
4
|
+
|
|
5
|
+
Runs inside Claude's code execution sandbox and proxies commands over HTTPS to a [gigai](https://www.npmjs.com/package/@schuttdev/gigai) server on your machine.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @schuttdev/kon
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
kon connect # establish session with gigai server
|
|
17
|
+
kon list # list available tools
|
|
18
|
+
kon help <tool-name> # show tool usage
|
|
19
|
+
kon <tool-name> [args...] # execute a tool
|
|
20
|
+
kon status # connection info
|
|
21
|
+
kon connect <server-name> # switch between servers
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Any unrecognized subcommand is treated as a tool name:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
kon read ~/notes.txt
|
|
28
|
+
kon bash git status
|
|
29
|
+
kon grep "TODO" ~/project
|
|
30
|
+
kon obsidian search-notes "meeting"
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Setup
|
|
34
|
+
|
|
35
|
+
This package is installed automatically when you pair with a gigai server. See the [full documentation](https://github.com/Kaden-Schutt/kon) for setup instructions.
|
|
36
|
+
|
|
37
|
+
## License
|
|
38
|
+
|
|
39
|
+
MIT
|
package/dist/index.js
CHANGED
|
@@ -341,7 +341,7 @@ function createHttpClient(serverUrl, sessionToken) {
|
|
|
341
341
|
}
|
|
342
342
|
|
|
343
343
|
// ../cli/src/version.ts
|
|
344
|
-
var VERSION = "0.3.
|
|
344
|
+
var VERSION = "0.3.3";
|
|
345
345
|
|
|
346
346
|
// ../cli/src/connect.ts
|
|
347
347
|
async function connect(serverName) {
|
|
@@ -367,15 +367,18 @@ async function connect(serverName) {
|
|
|
367
367
|
return { serverUrl: entry.server, sessionToken: entry.sessionToken };
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
|
+
return refreshSession(name, entry.server, entry.token);
|
|
371
|
+
}
|
|
372
|
+
async function refreshSession(serverName, serverUrl, encryptedToken) {
|
|
370
373
|
const orgUuid = getOrgUUID();
|
|
371
|
-
const http = createHttpClient(
|
|
374
|
+
const http = createHttpClient(serverUrl);
|
|
372
375
|
const res = await http.post("/auth/connect", {
|
|
373
|
-
encryptedToken
|
|
376
|
+
encryptedToken,
|
|
374
377
|
orgUuid
|
|
375
378
|
});
|
|
376
|
-
await updateServerSession(
|
|
377
|
-
await checkAndUpdateServer(
|
|
378
|
-
return { serverUrl
|
|
379
|
+
await updateServerSession(serverName, res.sessionToken, res.expiresAt);
|
|
380
|
+
await checkAndUpdateServer(serverUrl, res.sessionToken);
|
|
381
|
+
return { serverUrl, sessionToken: res.sessionToken };
|
|
379
382
|
}
|
|
380
383
|
async function checkAndUpdateServer(serverUrl, sessionToken) {
|
|
381
384
|
try {
|
|
@@ -1015,22 +1018,43 @@ if (firstArg && !firstArg.startsWith("-") && !KNOWN_COMMANDS.has(firstArg)) {
|
|
|
1015
1018
|
const toolName = firstArg;
|
|
1016
1019
|
const toolArgs = process.argv.slice(3);
|
|
1017
1020
|
try {
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
const
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1021
|
+
let { serverUrl, sessionToken } = await connect();
|
|
1022
|
+
let http = createHttpClient(serverUrl, sessionToken);
|
|
1023
|
+
const runTool = async () => {
|
|
1024
|
+
const { tool: detail } = await fetchToolDetail(http, toolName);
|
|
1025
|
+
if (detail.type === "mcp") {
|
|
1026
|
+
const mcpToolName = toolArgs[0];
|
|
1027
|
+
if (!mcpToolName) {
|
|
1028
|
+
const toolNames = (detail.mcpTools ?? []).map((t) => ` ${t.name} \u2014 ${t.description}`);
|
|
1029
|
+
console.log(`MCP tools for ${toolName}:
|
|
1026
1030
|
${toolNames.join("\n")}`);
|
|
1031
|
+
} else {
|
|
1032
|
+
const jsonArg = toolArgs.slice(1).join(" ");
|
|
1033
|
+
const args = jsonArg ? JSON.parse(jsonArg) : {};
|
|
1034
|
+
await execMcpTool(http, toolName, mcpToolName, args);
|
|
1035
|
+
}
|
|
1036
|
+
} else {
|
|
1037
|
+
await execTool(http, toolName, toolArgs);
|
|
1038
|
+
}
|
|
1039
|
+
};
|
|
1040
|
+
try {
|
|
1041
|
+
await runTool();
|
|
1042
|
+
} catch (e) {
|
|
1043
|
+
const msg = e.message;
|
|
1044
|
+
if (msg.includes("Invalid session") || msg.includes("Session expired") || msg.includes("Authorization")) {
|
|
1045
|
+
const config = await readConfig();
|
|
1046
|
+
const active = getActiveEntry(config);
|
|
1047
|
+
if (active) {
|
|
1048
|
+
const refreshed = await refreshSession(active.name, active.entry.server, active.entry.token);
|
|
1049
|
+
sessionToken = refreshed.sessionToken;
|
|
1050
|
+
http = createHttpClient(serverUrl, sessionToken);
|
|
1051
|
+
await runTool();
|
|
1052
|
+
} else {
|
|
1053
|
+
throw e;
|
|
1054
|
+
}
|
|
1027
1055
|
} else {
|
|
1028
|
-
|
|
1029
|
-
const args = jsonArg ? JSON.parse(jsonArg) : {};
|
|
1030
|
-
await execMcpTool(http, toolName, mcpToolName, args);
|
|
1056
|
+
throw e;
|
|
1031
1057
|
}
|
|
1032
|
-
} else {
|
|
1033
|
-
await execTool(http, toolName, toolArgs);
|
|
1034
1058
|
}
|
|
1035
1059
|
} catch (e) {
|
|
1036
1060
|
console.error(`Error: ${e.message}`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schuttdev/kon",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
5
6
|
"description": "Lightweight gigai client for Claude code execution",
|
|
6
7
|
"bin": {
|
|
7
8
|
"kon": "dist/index.js"
|
|
@@ -10,7 +11,8 @@
|
|
|
10
11
|
".": "./dist/index.js"
|
|
11
12
|
},
|
|
12
13
|
"files": [
|
|
13
|
-
"dist"
|
|
14
|
+
"dist",
|
|
15
|
+
"README.md"
|
|
14
16
|
],
|
|
15
17
|
"scripts": {
|
|
16
18
|
"build": "tsup",
|