@schuttdev/gigai 0.1.0-beta.10 → 0.1.0-beta.11
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,12 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
// ../server/dist/chunk-
|
|
3
|
+
// ../server/dist/chunk-RZTCSUFS.mjs
|
|
4
4
|
import { nanoid } from "nanoid";
|
|
5
5
|
var AuthStore = class {
|
|
6
6
|
pairingCodes = /* @__PURE__ */ new Map();
|
|
7
7
|
sessions = /* @__PURE__ */ new Map();
|
|
8
|
-
boundOrgs = /* @__PURE__ */ new Map();
|
|
9
|
-
// serverFingerprint -> orgUuid
|
|
10
8
|
cleanupInterval;
|
|
11
9
|
constructor() {
|
|
12
10
|
this.cleanupInterval = setInterval(() => this.cleanup(), 6e4);
|
|
@@ -49,13 +47,6 @@ var AuthStore = class {
|
|
|
49
47
|
}
|
|
50
48
|
return session;
|
|
51
49
|
}
|
|
52
|
-
// Org binding (bind-on-first-use for wildcard tokens)
|
|
53
|
-
bindOrg(fingerprint, orgUuid) {
|
|
54
|
-
this.boundOrgs.set(fingerprint, orgUuid);
|
|
55
|
-
}
|
|
56
|
-
getBoundOrg(fingerprint) {
|
|
57
|
-
return this.boundOrgs.get(fingerprint);
|
|
58
|
-
}
|
|
59
50
|
// Cleanup
|
|
60
51
|
cleanup() {
|
|
61
52
|
const now = Date.now();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
AuthStore
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-OWDYY3IG.js";
|
|
5
5
|
import {
|
|
6
6
|
generatePairingCode,
|
|
7
7
|
validateAndPair
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
GigaiConfigSchema,
|
|
12
12
|
GigaiError,
|
|
13
13
|
decrypt,
|
|
14
|
-
encrypt,
|
|
15
14
|
generateEncryptionKey
|
|
16
15
|
} from "./chunk-4XUWD3DZ.js";
|
|
17
16
|
|
|
@@ -42,11 +41,10 @@ import { nanoid } from "nanoid";
|
|
|
42
41
|
import { readFile as readFile3 } from "fs/promises";
|
|
43
42
|
import { resolve as resolve3 } from "path";
|
|
44
43
|
import { input, select, checkbox, confirm } from "@inquirer/prompts";
|
|
45
|
-
import { writeFile as writeFile2
|
|
46
|
-
import { resolve as resolve4
|
|
44
|
+
import { writeFile as writeFile2 } from "fs/promises";
|
|
45
|
+
import { resolve as resolve4 } from "path";
|
|
47
46
|
import { execFile } from "child_process";
|
|
48
47
|
import { promisify } from "util";
|
|
49
|
-
import { randomBytes as randomBytes2 } from "crypto";
|
|
50
48
|
import { input as input2 } from "@inquirer/prompts";
|
|
51
49
|
import { readFile as readFile4, writeFile as writeFile3 } from "fs/promises";
|
|
52
50
|
import { resolve as resolve5 } from "path";
|
|
@@ -63,16 +61,7 @@ function connectWithToken(store, encryptedToken, orgUuid, encryptionKey, session
|
|
|
63
61
|
} catch {
|
|
64
62
|
throw new GigaiError(ErrorCode.TOKEN_DECRYPT_FAILED, "Failed to decrypt token");
|
|
65
63
|
}
|
|
66
|
-
if (decrypted.orgUuid
|
|
67
|
-
const bound = store.getBoundOrg(decrypted.serverFingerprint);
|
|
68
|
-
if (bound) {
|
|
69
|
-
if (bound !== orgUuid) {
|
|
70
|
-
throw new GigaiError(ErrorCode.ORG_MISMATCH, "Organization UUID mismatch");
|
|
71
|
-
}
|
|
72
|
-
} else {
|
|
73
|
-
store.bindOrg(decrypted.serverFingerprint, orgUuid);
|
|
74
|
-
}
|
|
75
|
-
} else if (decrypted.orgUuid !== orgUuid) {
|
|
64
|
+
if (decrypted.orgUuid !== orgUuid) {
|
|
76
65
|
throw new GigaiError(ErrorCode.ORG_MISMATCH, "Organization UUID mismatch");
|
|
77
66
|
}
|
|
78
67
|
return store.createSession(orgUuid, sessionTtlSeconds);
|
|
@@ -988,8 +977,6 @@ async function runInit() {
|
|
|
988
977
|
await writeFile2(configPath, JSON.stringify(config, null, 2) + "\n", { mode: 384 });
|
|
989
978
|
console.log(`
|
|
990
979
|
Config written to: ${configPath}`);
|
|
991
|
-
const skillDir = resolve4("gigai-skill");
|
|
992
|
-
await mkdir2(skillDir, { recursive: true });
|
|
993
980
|
let serverUrl = "<YOUR_SERVER_URL>";
|
|
994
981
|
if (httpsProvider === "tailscale") {
|
|
995
982
|
const dnsName = await getTailscaleDnsName();
|
|
@@ -998,83 +985,27 @@ async function runInit() {
|
|
|
998
985
|
console.log(` Detected Tailscale URL: ${serverUrl}`);
|
|
999
986
|
}
|
|
1000
987
|
}
|
|
1001
|
-
const tokenPayload = {
|
|
1002
|
-
orgUuid: "*",
|
|
1003
|
-
serverFingerprint: randomBytes2(16).toString("hex"),
|
|
1004
|
-
createdAt: Date.now()
|
|
1005
|
-
};
|
|
1006
|
-
const encryptedToken = encrypt(tokenPayload, encryptionKey);
|
|
1007
|
-
const tokenStr = JSON.stringify(JSON.stringify(encryptedToken));
|
|
1008
|
-
const skillMd = `---
|
|
1009
|
-
name: gigai
|
|
1010
|
-
description: Access tools on the user's machine via the gigai CLI
|
|
1011
|
-
---
|
|
1012
|
-
|
|
1013
|
-
# gigai
|
|
1014
|
-
|
|
1015
|
-
You have access to tools running on the user's local machine through the gigai CLI. This CLI proxies commands over HTTPS to a server on the user's machine.
|
|
1016
|
-
|
|
1017
|
-
## Setup (run once per session)
|
|
1018
|
-
|
|
1019
|
-
Before using any gigai commands, you must install and configure the CLI in your code execution environment. Run this setup block first:
|
|
1020
|
-
|
|
1021
|
-
\`\`\`bash
|
|
1022
|
-
npm install -g @schuttdev/gigai 2>/dev/null
|
|
1023
|
-
|
|
1024
|
-
mkdir -p ~/.gigai
|
|
1025
|
-
cat > ~/.gigai/config.json << 'GIGAI_EOF'
|
|
1026
|
-
{
|
|
1027
|
-
"server": "${serverUrl}",
|
|
1028
|
-
"token": ${tokenStr}
|
|
1029
|
-
}
|
|
1030
|
-
GIGAI_EOF
|
|
1031
|
-
|
|
1032
|
-
gigai connect
|
|
1033
|
-
\`\`\`
|
|
1034
|
-
|
|
1035
|
-
If \`gigai connect\` succeeds, you are ready to use tools. If it fails, tell the user.
|
|
1036
|
-
|
|
1037
|
-
## Usage
|
|
1038
|
-
|
|
1039
|
-
### List available tools
|
|
1040
|
-
\`\`\`bash
|
|
1041
|
-
gigai list
|
|
1042
|
-
\`\`\`
|
|
1043
|
-
|
|
1044
|
-
### Get help for a tool
|
|
1045
|
-
\`\`\`bash
|
|
1046
|
-
gigai help <tool-name>
|
|
1047
|
-
\`\`\`
|
|
1048
|
-
|
|
1049
|
-
### Run a tool
|
|
1050
|
-
\`\`\`bash
|
|
1051
|
-
gigai <tool-name> [args...]
|
|
1052
|
-
\`\`\`
|
|
1053
|
-
|
|
1054
|
-
### File transfer
|
|
1055
|
-
\`\`\`bash
|
|
1056
|
-
gigai upload <file>
|
|
1057
|
-
gigai download <id> <dest>
|
|
1058
|
-
\`\`\`
|
|
1059
|
-
|
|
1060
|
-
## Important
|
|
1061
|
-
|
|
1062
|
-
- Always run the setup block before first use in a new session
|
|
1063
|
-
- All commands execute on the **user's machine**, not in this sandbox
|
|
1064
|
-
- If you get auth errors, run \`gigai connect\` to refresh the session
|
|
1065
|
-
- Tools are scoped to what the user has configured \u2014 if a tool is missing, tell the user
|
|
1066
|
-
`;
|
|
1067
|
-
await writeFile2(join3(skillDir, "SKILL.md"), skillMd, { mode: 384 });
|
|
1068
|
-
console.log(` Skill written to: ${skillDir}/SKILL.md`);
|
|
1069
988
|
const store = new AuthStore();
|
|
1070
989
|
const code = generatePairingCode(store, config.auth.pairingTtlSeconds);
|
|
1071
|
-
console.log(`
|
|
1072
|
-
Pairing code: ${code} (expires in ${config.auth.pairingTtlSeconds / 60} min)`);
|
|
1073
990
|
store.destroy();
|
|
1074
991
|
console.log(`
|
|
1075
|
-
|
|
1076
|
-
console.log(`
|
|
1077
|
-
|
|
992
|
+
Pairing code: ${code}`);
|
|
993
|
+
console.log(` Expires in ${config.auth.pairingTtlSeconds / 60} minutes.
|
|
994
|
+
`);
|
|
995
|
+
console.log(` Start the server with: gigai server start${httpsConfig ? "" : " --dev"}
|
|
996
|
+
`);
|
|
997
|
+
console.log(` Then paste this into Claude to pair:
|
|
998
|
+
`);
|
|
999
|
+
console.log(` \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
|
|
1000
|
+
console.log(` Install the gigai CLI and pair with my server:
|
|
1001
|
+
`);
|
|
1002
|
+
console.log(` \`\`\`bash`);
|
|
1003
|
+
console.log(` npm install -g @schuttdev/gigai`);
|
|
1004
|
+
console.log(` gigai pair ${code} ${serverUrl}`);
|
|
1005
|
+
console.log(` \`\`\`
|
|
1006
|
+
`);
|
|
1007
|
+
console.log(` Then show me the skill file output so I can save it.`);
|
|
1008
|
+
console.log(` \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
|
|
1078
1009
|
}
|
|
1079
1010
|
async function loadConfigFile(path) {
|
|
1080
1011
|
const configPath = resolve5(path ?? "gigai.config.json");
|
|
@@ -1187,7 +1118,7 @@ async function unwrapTool(name) {
|
|
|
1187
1118
|
}
|
|
1188
1119
|
async function generateServerPairingCode(configPath) {
|
|
1189
1120
|
const { config } = await loadConfigFile(configPath);
|
|
1190
|
-
const { AuthStore: AuthStore2 } = await import("./store-
|
|
1121
|
+
const { AuthStore: AuthStore2 } = await import("./store-Y4V3TOYJ-GKOB6ANA.js");
|
|
1191
1122
|
const { generatePairingCode: generatePairingCode2 } = await import("./pairing-IGMDVOIZ-RA7GNFU7.js");
|
|
1192
1123
|
const store = new AuthStore2();
|
|
1193
1124
|
const code = generatePairingCode2(store, config.auth.pairingTtlSeconds);
|
package/dist/index.js
CHANGED
|
@@ -194,7 +194,74 @@ async function pair(code, serverUrl) {
|
|
|
194
194
|
sessionToken: void 0,
|
|
195
195
|
sessionExpiresAt: void 0
|
|
196
196
|
});
|
|
197
|
-
console.log("Paired successfully
|
|
197
|
+
console.log("Paired successfully!\n");
|
|
198
|
+
const tokenStr = JSON.stringify(res.encryptedToken);
|
|
199
|
+
const skillMd = generateSkill(serverUrl, tokenStr);
|
|
200
|
+
console.log("Save the following as a Claude Desktop skill:\n");
|
|
201
|
+
console.log("\u2500".repeat(50));
|
|
202
|
+
console.log(skillMd);
|
|
203
|
+
console.log("\u2500".repeat(50));
|
|
204
|
+
}
|
|
205
|
+
function generateSkill(serverUrl, token) {
|
|
206
|
+
return `---
|
|
207
|
+
name: gigai
|
|
208
|
+
description: Access tools on the user's machine via the gigai CLI
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
# gigai
|
|
212
|
+
|
|
213
|
+
You have access to tools running on the user's local machine through the gigai CLI. This CLI proxies commands over HTTPS to a server on the user's machine.
|
|
214
|
+
|
|
215
|
+
## Setup (run once per session)
|
|
216
|
+
|
|
217
|
+
Before using any gigai commands, you must install and configure the CLI in your code execution environment. Run this setup block:
|
|
218
|
+
|
|
219
|
+
\`\`\`bash
|
|
220
|
+
npm install -g @schuttdev/gigai 2>/dev/null
|
|
221
|
+
|
|
222
|
+
mkdir -p ~/.gigai
|
|
223
|
+
cat > ~/.gigai/config.json << 'GIGAI_EOF'
|
|
224
|
+
{
|
|
225
|
+
"server": "${serverUrl}",
|
|
226
|
+
"token": ${token}
|
|
227
|
+
}
|
|
228
|
+
GIGAI_EOF
|
|
229
|
+
|
|
230
|
+
gigai connect
|
|
231
|
+
\`\`\`
|
|
232
|
+
|
|
233
|
+
If \`gigai connect\` succeeds, you are ready to use tools. If it fails, tell the user.
|
|
234
|
+
|
|
235
|
+
## Usage
|
|
236
|
+
|
|
237
|
+
### List available tools
|
|
238
|
+
\`\`\`bash
|
|
239
|
+
gigai list
|
|
240
|
+
\`\`\`
|
|
241
|
+
|
|
242
|
+
### Get help for a tool
|
|
243
|
+
\`\`\`bash
|
|
244
|
+
gigai help <tool-name>
|
|
245
|
+
\`\`\`
|
|
246
|
+
|
|
247
|
+
### Run a tool
|
|
248
|
+
\`\`\`bash
|
|
249
|
+
gigai <tool-name> [args...]
|
|
250
|
+
\`\`\`
|
|
251
|
+
|
|
252
|
+
### File transfer
|
|
253
|
+
\`\`\`bash
|
|
254
|
+
gigai upload <file>
|
|
255
|
+
gigai download <id> <dest>
|
|
256
|
+
\`\`\`
|
|
257
|
+
|
|
258
|
+
## Important
|
|
259
|
+
|
|
260
|
+
- Always run the setup block before first use in a new session
|
|
261
|
+
- All commands execute on the **user's machine**, not in this sandbox
|
|
262
|
+
- If you get auth errors, run \`gigai connect\` to refresh the session
|
|
263
|
+
- Tools are scoped to what the user has configured \u2014 if a tool is missing, tell the user
|
|
264
|
+
`;
|
|
198
265
|
}
|
|
199
266
|
|
|
200
267
|
// src/discover.ts
|
|
@@ -438,7 +505,7 @@ function runCitty() {
|
|
|
438
505
|
dev: { type: "boolean", description: "Development mode (no HTTPS)" }
|
|
439
506
|
},
|
|
440
507
|
async run({ args }) {
|
|
441
|
-
const { startServer } = await import("./dist-
|
|
508
|
+
const { startServer } = await import("./dist-66IDK7VT.js");
|
|
442
509
|
const extraArgs = [];
|
|
443
510
|
if (args.config) extraArgs.push("--config", args.config);
|
|
444
511
|
if (args.dev) extraArgs.push("--dev");
|
|
@@ -449,7 +516,7 @@ function runCitty() {
|
|
|
449
516
|
init: defineCommand({
|
|
450
517
|
meta: { name: "init", description: "Interactive setup wizard" },
|
|
451
518
|
async run() {
|
|
452
|
-
const { runInit } = await import("./dist-
|
|
519
|
+
const { runInit } = await import("./dist-66IDK7VT.js");
|
|
453
520
|
await runInit();
|
|
454
521
|
}
|
|
455
522
|
}),
|
|
@@ -459,7 +526,7 @@ function runCitty() {
|
|
|
459
526
|
config: { type: "string", alias: "c", description: "Config file path" }
|
|
460
527
|
},
|
|
461
528
|
async run({ args }) {
|
|
462
|
-
const { generateServerPairingCode } = await import("./dist-
|
|
529
|
+
const { generateServerPairingCode } = await import("./dist-66IDK7VT.js");
|
|
463
530
|
await generateServerPairingCode(args.config);
|
|
464
531
|
}
|
|
465
532
|
}),
|
|
@@ -486,21 +553,21 @@ function runCitty() {
|
|
|
486
553
|
cli: defineCommand({
|
|
487
554
|
meta: { name: "cli", description: "Wrap a CLI command" },
|
|
488
555
|
async run() {
|
|
489
|
-
const { wrapCli } = await import("./dist-
|
|
556
|
+
const { wrapCli } = await import("./dist-66IDK7VT.js");
|
|
490
557
|
await wrapCli();
|
|
491
558
|
}
|
|
492
559
|
}),
|
|
493
560
|
mcp: defineCommand({
|
|
494
561
|
meta: { name: "mcp", description: "Wrap an MCP server" },
|
|
495
562
|
async run() {
|
|
496
|
-
const { wrapMcp } = await import("./dist-
|
|
563
|
+
const { wrapMcp } = await import("./dist-66IDK7VT.js");
|
|
497
564
|
await wrapMcp();
|
|
498
565
|
}
|
|
499
566
|
}),
|
|
500
567
|
script: defineCommand({
|
|
501
568
|
meta: { name: "script", description: "Wrap a script" },
|
|
502
569
|
async run() {
|
|
503
|
-
const { wrapScript } = await import("./dist-
|
|
570
|
+
const { wrapScript } = await import("./dist-66IDK7VT.js");
|
|
504
571
|
await wrapScript();
|
|
505
572
|
}
|
|
506
573
|
}),
|
|
@@ -510,7 +577,7 @@ function runCitty() {
|
|
|
510
577
|
path: { type: "positional", description: "Path to config file", required: true }
|
|
511
578
|
},
|
|
512
579
|
async run({ args }) {
|
|
513
|
-
const { wrapImport } = await import("./dist-
|
|
580
|
+
const { wrapImport } = await import("./dist-66IDK7VT.js");
|
|
514
581
|
await wrapImport(args.path);
|
|
515
582
|
}
|
|
516
583
|
})
|
|
@@ -522,7 +589,7 @@ function runCitty() {
|
|
|
522
589
|
name: { type: "positional", description: "Tool name", required: true }
|
|
523
590
|
},
|
|
524
591
|
async run({ args }) {
|
|
525
|
-
const { unwrapTool } = await import("./dist-
|
|
592
|
+
const { unwrapTool } = await import("./dist-66IDK7VT.js");
|
|
526
593
|
await unwrapTool(args.name);
|
|
527
594
|
}
|
|
528
595
|
});
|