@schuttdev/gigai 0.1.0-beta.6 → 0.1.0-beta.8

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.
@@ -11,6 +11,7 @@ import {
11
11
  GigaiConfigSchema,
12
12
  GigaiError,
13
13
  decrypt,
14
+ encrypt,
14
15
  generateEncryptionKey
15
16
  } from "./chunk-4XUWD3DZ.js";
16
17
 
@@ -43,6 +44,9 @@ import { resolve as resolve3 } from "path";
43
44
  import { input, select, checkbox, confirm } from "@inquirer/prompts";
44
45
  import { writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
45
46
  import { resolve as resolve4, join as join3 } from "path";
47
+ import { execFile } from "child_process";
48
+ import { promisify } from "util";
49
+ import { randomBytes as randomBytes2 } from "crypto";
46
50
  import { input as input2 } from "@inquirer/prompts";
47
51
  import { readFile as readFile4, writeFile as writeFile3 } from "fs/promises";
48
52
  import { resolve as resolve5 } from "path";
@@ -59,7 +63,7 @@ function connectWithToken(store, encryptedToken, orgUuid, encryptionKey, session
59
63
  } catch {
60
64
  throw new GigaiError(ErrorCode.TOKEN_DECRYPT_FAILED, "Failed to decrypt token");
61
65
  }
62
- if (decrypted.orgUuid !== orgUuid) {
66
+ if (decrypted.orgUuid !== "*" && decrypted.orgUuid !== orgUuid) {
63
67
  throw new GigaiError(ErrorCode.ORG_MISMATCH, "Organization UUID mismatch");
64
68
  }
65
69
  return store.createSession(orgUuid, sessionTtlSeconds);
@@ -826,6 +830,18 @@ async function loadConfig(path) {
826
830
  const json = JSON.parse(raw);
827
831
  return GigaiConfigSchema.parse(json);
828
832
  }
833
+ var execFileAsync = promisify(execFile);
834
+ async function getTailscaleDnsName() {
835
+ try {
836
+ const { stdout } = await execFileAsync("tailscale", ["status", "--json"]);
837
+ const data = JSON.parse(stdout);
838
+ const dnsName = data?.Self?.DNSName;
839
+ if (dnsName) return dnsName.replace(/\.$/, "");
840
+ return null;
841
+ } catch {
842
+ return null;
843
+ }
844
+ }
829
845
  async function runInit() {
830
846
  console.log("\n gigai server setup\n");
831
847
  const httpsProvider = await select({
@@ -965,45 +981,84 @@ async function runInit() {
965
981
  Config written to: ${configPath}`);
966
982
  const skillDir = resolve4("gigai-skill");
967
983
  await mkdir2(skillDir, { recursive: true });
968
- const skillMd = `# gigai Skill
984
+ let serverUrl = "<YOUR_SERVER_URL>";
985
+ if (httpsProvider === "tailscale") {
986
+ const dnsName = await getTailscaleDnsName();
987
+ if (dnsName) {
988
+ serverUrl = `https://${dnsName}:${port}`;
989
+ console.log(` Detected Tailscale URL: ${serverUrl}`);
990
+ }
991
+ }
992
+ const skillMd = `---
993
+ name: gigai
994
+ description: Access tools on the user's machine via the gigai CLI
995
+ ---
996
+
997
+ # gigai Skill
969
998
 
970
999
  This skill gives you access to tools running on the user's machine via the gigai CLI.
971
1000
 
972
- ## Setup
1001
+ ## Quick Start
1002
+
1003
+ 1. Connect to the server:
1004
+ \`\`\`
1005
+ gigai connect
1006
+ \`\`\`
973
1007
 
974
- The gigai CLI is pre-installed. To use it:
1008
+ 2. List available tools:
1009
+ \`\`\`
1010
+ gigai list
1011
+ \`\`\`
975
1012
 
976
- 1. Connect to the server: \`gigai connect\`
977
- 2. List available tools: \`gigai list\`
978
- 3. Get help on a tool: \`gigai help <tool-name>\`
979
- 4. Use a tool: \`gigai <tool-name> [args...]\`
1013
+ 3. Get help on a specific tool:
1014
+ \`\`\`
1015
+ gigai help <tool-name>
1016
+ \`\`\`
980
1017
 
981
- ## File Transfer
1018
+ 4. Use a tool directly:
1019
+ \`\`\`
1020
+ gigai <tool-name> [args...]
1021
+ \`\`\`
982
1022
 
983
- - Upload: \`gigai upload <file>\`
984
- - Download: \`gigai download <id> <dest>\`
1023
+ ## Commands
1024
+
1025
+ ### Connection
1026
+ - \`gigai connect\` \u2014 Establish/renew a session with the server
1027
+ - \`gigai status\` \u2014 Check connection status
1028
+ - \`gigai pair <code> <server-url>\` \u2014 Pair with a new server
1029
+
1030
+ ### Tool Usage
1031
+ - \`gigai list\` \u2014 List all available tools
1032
+ - \`gigai help <name>\` \u2014 Show detailed help for a tool
1033
+ - \`gigai <name> [args...]\` \u2014 Execute a tool by name
1034
+
1035
+ ### File Transfer
1036
+ - \`gigai upload <file>\` \u2014 Upload a file to the server
1037
+ - \`gigai download <id> <dest>\` \u2014 Download a file from the server
985
1038
 
986
1039
  ## Notes
987
1040
 
988
- - The connection is authenticated and encrypted
989
- - Tools are scoped to what the user has configured
990
- - If a command fails, check \`gigai status\` for connection info
1041
+ - The connection is authenticated and encrypted end-to-end
1042
+ - Tools are scoped to what the user has explicitly configured
1043
+ - Sessions auto-renew; if you get auth errors, run \`gigai connect\`
1044
+ - All tool execution happens on the user's machine, not in this container
991
1045
  `;
992
1046
  await writeFile2(join3(skillDir, "SKILL.md"), skillMd);
1047
+ const tokenPayload = {
1048
+ orgUuid: "*",
1049
+ serverFingerprint: randomBytes2(16).toString("hex"),
1050
+ createdAt: Date.now()
1051
+ };
1052
+ const encryptedToken = encrypt(tokenPayload, encryptionKey);
993
1053
  const skillConfig = {
994
- server: "<YOUR_SERVER_URL>",
995
- token: "<PASTE_ENCRYPTED_TOKEN_HERE>"
1054
+ server: serverUrl,
1055
+ token: JSON.stringify(encryptedToken)
996
1056
  };
997
- await writeFile2(join3(skillDir, "config.json"), JSON.stringify(skillConfig, null, 2) + "\n");
1057
+ await writeFile2(join3(skillDir, "config.json"), JSON.stringify(skillConfig, null, 2) + "\n", { mode: 384 });
998
1058
  console.log(` Skill template written to: ${skillDir}/`);
999
- const store = new AuthStore();
1000
- const code = generatePairingCode(store, config.auth.pairingTtlSeconds);
1001
- console.log(`
1002
- Pairing code: ${code}`);
1003
- console.log(` Expires in ${config.auth.pairingTtlSeconds / 60} minutes.`);
1004
1059
  console.log(`
1005
1060
  Start the server with: gigai server start${httpsConfig ? "" : " --dev"}`);
1006
- store.destroy();
1061
+ console.log(` Then upload gigai-skill/ contents to your Claude Project.`);
1007
1062
  }
1008
1063
  async function loadConfigFile(path) {
1009
1064
  const configPath = resolve5(path ?? "gigai.config.json");
package/dist/index.js CHANGED
@@ -438,7 +438,7 @@ function runCitty() {
438
438
  dev: { type: "boolean", description: "Development mode (no HTTPS)" }
439
439
  },
440
440
  async run({ args }) {
441
- const { startServer } = await import("./dist-DX6G464T.js");
441
+ const { startServer } = await import("./dist-YHKBLFWY.js");
442
442
  const extraArgs = [];
443
443
  if (args.config) extraArgs.push("--config", args.config);
444
444
  if (args.dev) extraArgs.push("--dev");
@@ -449,7 +449,7 @@ function runCitty() {
449
449
  init: defineCommand({
450
450
  meta: { name: "init", description: "Interactive setup wizard" },
451
451
  async run() {
452
- const { runInit } = await import("./dist-DX6G464T.js");
452
+ const { runInit } = await import("./dist-YHKBLFWY.js");
453
453
  await runInit();
454
454
  }
455
455
  }),
@@ -459,7 +459,7 @@ function runCitty() {
459
459
  config: { type: "string", alias: "c", description: "Config file path" }
460
460
  },
461
461
  async run({ args }) {
462
- const { generateServerPairingCode } = await import("./dist-DX6G464T.js");
462
+ const { generateServerPairingCode } = await import("./dist-YHKBLFWY.js");
463
463
  await generateServerPairingCode(args.config);
464
464
  }
465
465
  }),
@@ -486,21 +486,21 @@ function runCitty() {
486
486
  cli: defineCommand({
487
487
  meta: { name: "cli", description: "Wrap a CLI command" },
488
488
  async run() {
489
- const { wrapCli } = await import("./dist-DX6G464T.js");
489
+ const { wrapCli } = await import("./dist-YHKBLFWY.js");
490
490
  await wrapCli();
491
491
  }
492
492
  }),
493
493
  mcp: defineCommand({
494
494
  meta: { name: "mcp", description: "Wrap an MCP server" },
495
495
  async run() {
496
- const { wrapMcp } = await import("./dist-DX6G464T.js");
496
+ const { wrapMcp } = await import("./dist-YHKBLFWY.js");
497
497
  await wrapMcp();
498
498
  }
499
499
  }),
500
500
  script: defineCommand({
501
501
  meta: { name: "script", description: "Wrap a script" },
502
502
  async run() {
503
- const { wrapScript } = await import("./dist-DX6G464T.js");
503
+ const { wrapScript } = await import("./dist-YHKBLFWY.js");
504
504
  await wrapScript();
505
505
  }
506
506
  }),
@@ -510,7 +510,7 @@ function runCitty() {
510
510
  path: { type: "positional", description: "Path to config file", required: true }
511
511
  },
512
512
  async run({ args }) {
513
- const { wrapImport } = await import("./dist-DX6G464T.js");
513
+ const { wrapImport } = await import("./dist-YHKBLFWY.js");
514
514
  await wrapImport(args.path);
515
515
  }
516
516
  })
@@ -522,7 +522,7 @@ function runCitty() {
522
522
  name: { type: "positional", description: "Tool name", required: true }
523
523
  },
524
524
  async run({ args }) {
525
- const { unwrapTool } = await import("./dist-DX6G464T.js");
525
+ const { unwrapTool } = await import("./dist-YHKBLFWY.js");
526
526
  await unwrapTool(args.name);
527
527
  }
528
528
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schuttdev/gigai",
3
- "version": "0.1.0-beta.6",
3
+ "version": "0.1.0-beta.8",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "gigai": "dist/index.js"