@quantis-ai/gary 0.0.0-stage → 0.1.0
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 +68 -2
- package/bin/gary.js +40 -0
- package/package.json +22 -4
package/README.md
CHANGED
|
@@ -1,3 +1,69 @@
|
|
|
1
|
-
#
|
|
1
|
+
# gary CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Connects a person's Linux or macOS computer to their Gary, so their Garys can work in the directories they share
|
|
4
|
+
there: list, search, read and write files, and run commands and git. Like `cloudflared`, it dials out and holds one
|
|
5
|
+
connection; nothing ever connects in to the computer.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @quantis-ai/gary # or: curl -fsSL https://chat.getquantis.com/cli/install.sh | bash
|
|
9
|
+
gary install # signs in, starts the service
|
|
10
|
+
gary dir add ~/projects # share a directory (--read-only to only read)
|
|
11
|
+
gary status
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
| Command | What it does |
|
|
15
|
+
|---|---|
|
|
16
|
+
| `gary install` | Copies gary to `~/.local/bin`, signs in if needed, and runs it in the background: a systemd user unit on Linux (lingering on, so it keeps running after logout), a launchd agent on macOS |
|
|
17
|
+
| `gary login` | Signs this computer in: prints a link to open where you're signed in to Gary, and waits for you to approve it |
|
|
18
|
+
| `gary status` | Signed in or not, connected or not (and why not), and the directories shared |
|
|
19
|
+
| `gary dir add [path]` | Shares a directory, this one by default. `--read-only`: Gary can read it, not change it or run commands in it. `--name`: what Gary calls it |
|
|
20
|
+
| `gary dir list` / `gary dir remove <path\|name>` | The directories shared; stop sharing one |
|
|
21
|
+
| `gary tasks` | What your Garys did on this computer (newest last), and the commands running now; `gary tasks stop <id>` stops one |
|
|
22
|
+
| `gary logout` / `gary uninstall` | Sign this computer out; stop the service and remove it |
|
|
23
|
+
|
|
24
|
+
## How it works
|
|
25
|
+
|
|
26
|
+
It's a second kind of device on the folder bridge the Mac app uses (gary-platform `docs/MAC-BRIDGE.md`): the daemon
|
|
27
|
+
holds a session over a WebSocket to `/chat/v1/mac/connect`, and a Gary's `mac_` tool call reaches it as a request it
|
|
28
|
+
answers inside the shared directories. Approvals, audit and limits are the bridge's. The contract is
|
|
29
|
+
[docs/PROTOCOL.md](docs/PROTOCOL.md).
|
|
30
|
+
|
|
31
|
+
- Only the shared directories: every path is resolved through its links and refused if it lands outside. Nothing is
|
|
32
|
+
written in a `.git` folder.
|
|
33
|
+
- A write names the version it replaces, so a file changed since Gary read it isn't overwritten; the replaced bytes
|
|
34
|
+
are kept 30 days in `~/.local/state/gary/undo/`.
|
|
35
|
+
- Commands run `bash -lc` as you, in a shared directory, in their own process group, killed whole at their time limit
|
|
36
|
+
(120 s by default, 600 s at most). Gary asks you before each one.
|
|
37
|
+
- git runs without a shell, hooks off, at the shared directory's top, under the same rule the platform checks
|
|
38
|
+
(`gitrule_test.go` holds the daemon to the platform's own answers).
|
|
39
|
+
- What Gary did is logged on this computer only, in `~/.local/state/gary/activity.jsonl`, commands' text included.
|
|
40
|
+
|
|
41
|
+
## Files
|
|
42
|
+
|
|
43
|
+
| Path | What |
|
|
44
|
+
|---|---|
|
|
45
|
+
| `~/.config/gary/config.json` | This computer's name and id, and the directories shared |
|
|
46
|
+
| `~/.config/gary/credentials.json` | This computer's token (mode 0600). It reaches only the bridge; forget the computer on Gary's Computer sheet to revoke it |
|
|
47
|
+
| `~/.local/state/gary/` | The control socket, the activity log, undo copies, and on macOS the daemon's log |
|
|
48
|
+
|
|
49
|
+
## npm
|
|
50
|
+
|
|
51
|
+
`@quantis-ai/gary` is the `gary` command (a few lines of Node that run the binary); `@quantis-ai/gary-<os>-<arch>`
|
|
52
|
+
holds each platform's binary, and npm installs only the one whose `os` and `cpu` match, as esbuild's packages do.
|
|
53
|
+
`gary install` copies the binary the service runs to `~/.local/share/gary/` (not on PATH, so it doesn't shadow npm's
|
|
54
|
+
`gary`); after `npm update -g @quantis-ai/gary`, run `gary install` again, and `gary status` says when the service
|
|
55
|
+
still runs an older version.
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
make dist VERSION=0.1.0 && node npm/build.js 0.1.0 # npm/out/0.1.0/*.tgz, nothing published
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Building
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
make test # go vet, and the tests with the race detector
|
|
65
|
+
make dist VERSION=0.1.0 # dist/0.1.0/gary-{linux,darwin}-{amd64,arm64}, checksums.txt and install.sh
|
|
66
|
+
GARY_SERVER=http://127.0.0.1:18300 ./gary login # against a local dev portal
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Prior art: exeora (github.com/leynier/exeora), for the shape of the connection. None of its code is used.
|
package/bin/gary.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Runs the gary binary for this computer. npm installed exactly one of the platform packages
|
|
3
|
+
// (@quantis-ai/gary-<os>-<arch>, picked by their "os" and "cpu"); this finds it and hands over.
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
const { spawnSync } = require("child_process");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
|
|
9
|
+
const platforms = {
|
|
10
|
+
"darwin-arm64": "@quantis-ai/gary-darwin-arm64",
|
|
11
|
+
"darwin-x64": "@quantis-ai/gary-darwin-x64",
|
|
12
|
+
"linux-arm64": "@quantis-ai/gary-linux-arm64",
|
|
13
|
+
"linux-x64": "@quantis-ai/gary-linux-x64",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const key = `${process.platform}-${process.arch}`;
|
|
17
|
+
const pkg = platforms[key];
|
|
18
|
+
if (!pkg) {
|
|
19
|
+
console.error(`gary runs on Linux and macOS (x64 and arm64), not ${key}.`);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let bin;
|
|
24
|
+
try {
|
|
25
|
+
bin = path.join(path.dirname(require.resolve(`${pkg}/package.json`)), "bin", "gary");
|
|
26
|
+
} catch {
|
|
27
|
+
console.error(
|
|
28
|
+
`gary: ${pkg} isn't installed. npm skips it when optional dependencies are turned off ` +
|
|
29
|
+
`(--omit=optional or --no-optional); install again without that: npm install -g @quantis-ai/gary`
|
|
30
|
+
);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// GARY_NPM tells `gary install` it came from npm, so it says how to update.
|
|
35
|
+
const r = spawnSync(bin, process.argv.slice(2), { stdio: "inherit", env: { ...process.env, GARY_NPM: "1" } });
|
|
36
|
+
if (r.error) {
|
|
37
|
+
console.error(`gary: ${r.error.message}`);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
process.exit(r.status === null ? 1 : r.status);
|
package/package.json
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quantis-ai/gary",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"description": "Connects this computer to your Gary, so your Garys can work in the directories you share here.",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"homepage": "https://docs.getquantis.com",
|
|
7
|
+
"author": "QUANTIS",
|
|
8
|
+
"bin": {
|
|
9
|
+
"gary": "bin/gary.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"bin/gary.js",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=18"
|
|
17
|
+
},
|
|
18
|
+
"optionalDependencies": {
|
|
19
|
+
"@quantis-ai/gary-darwin-arm64": "0.1.0",
|
|
20
|
+
"@quantis-ai/gary-darwin-x64": "0.1.0",
|
|
21
|
+
"@quantis-ai/gary-linux-arm64": "0.1.0",
|
|
22
|
+
"@quantis-ai/gary-linux-x64": "0.1.0"
|
|
23
|
+
}
|
|
24
|
+
}
|