llm-latchkey 1.0.0__tar.gz
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.
- llm_latchkey-1.0.0/PKG-INFO +39 -0
- llm_latchkey-1.0.0/README.md +26 -0
- llm_latchkey-1.0.0/llm_latchkey.egg-info/PKG-INFO +39 -0
- llm_latchkey-1.0.0/llm_latchkey.egg-info/SOURCES.txt +9 -0
- llm_latchkey-1.0.0/llm_latchkey.egg-info/dependency_links.txt +1 -0
- llm_latchkey-1.0.0/llm_latchkey.egg-info/entry_points.txt +2 -0
- llm_latchkey-1.0.0/llm_latchkey.egg-info/requires.txt +1 -0
- llm_latchkey-1.0.0/llm_latchkey.egg-info/top_level.txt +1 -0
- llm_latchkey-1.0.0/llm_latchkey.py +72 -0
- llm_latchkey-1.0.0/pyproject.toml +25 -0
- llm_latchkey-1.0.0/setup.cfg +4 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: llm-latchkey
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: An LLM tool plugin for using Latchkey to make authenticated HTTP API requests.
|
|
5
|
+
Author-email: Hynek Urban <hynek@imbue.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/imbue-ai/latchkey/integrations/llm-latchkey
|
|
8
|
+
Project-URL: Issues, https://github.com/imbue-ai/latchkey/issues
|
|
9
|
+
Project-URL: Repository, https://github.com/imbue-ai/latchkey
|
|
10
|
+
Requires-Python: >=3.9
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: llm
|
|
13
|
+
|
|
14
|
+
# llm-latchkey
|
|
15
|
+
|
|
16
|
+
A plugin for Simon Willison's [LLM](https://llm.datasette.io/) tool that lets models make authenticated HTTP API requests via [Latchkey](https://github.com/imbue-ai/latchkey).
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
First, install Latchkey and configure credentials for at least one service:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install -g latchkey
|
|
24
|
+
latchkey auth set github -H "Authorization: Bearer ghp_..."
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Then install this plugin:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
llm install llm-latchkey
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
llm -T latchkey "What are my most recent GitHub notifications?" --td
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The model gets a single `latchkey` tool that accepts any latchkey command string. The tool description includes usage instructions, examples, and the list of supported services, so the model knows how to use it.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# llm-latchkey
|
|
2
|
+
|
|
3
|
+
A plugin for Simon Willison's [LLM](https://llm.datasette.io/) tool that lets models make authenticated HTTP API requests via [Latchkey](https://github.com/imbue-ai/latchkey).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
First, install Latchkey and configure credentials for at least one service:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g latchkey
|
|
11
|
+
latchkey auth set github -H "Authorization: Bearer ghp_..."
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Then install this plugin:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
llm install llm-latchkey
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
llm -T latchkey "What are my most recent GitHub notifications?" --td
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The model gets a single `latchkey` tool that accepts any latchkey command string. The tool description includes usage instructions, examples, and the list of supported services, so the model knows how to use it.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: llm-latchkey
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: An LLM tool plugin for using Latchkey to make authenticated HTTP API requests.
|
|
5
|
+
Author-email: Hynek Urban <hynek@imbue.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/imbue-ai/latchkey/integrations/llm-latchkey
|
|
8
|
+
Project-URL: Issues, https://github.com/imbue-ai/latchkey/issues
|
|
9
|
+
Project-URL: Repository, https://github.com/imbue-ai/latchkey
|
|
10
|
+
Requires-Python: >=3.9
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: llm
|
|
13
|
+
|
|
14
|
+
# llm-latchkey
|
|
15
|
+
|
|
16
|
+
A plugin for Simon Willison's [LLM](https://llm.datasette.io/) tool that lets models make authenticated HTTP API requests via [Latchkey](https://github.com/imbue-ai/latchkey).
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
First, install Latchkey and configure credentials for at least one service:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install -g latchkey
|
|
24
|
+
latchkey auth set github -H "Authorization: Bearer ghp_..."
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Then install this plugin:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
llm install llm-latchkey
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
llm -T latchkey "What are my most recent GitHub notifications?" --td
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The model gets a single `latchkey` tool that accepts any latchkey command string. The tool description includes usage instructions, examples, and the list of supported services, so the model knows how to use it.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
llm_latchkey.py
|
|
3
|
+
pyproject.toml
|
|
4
|
+
llm_latchkey.egg-info/PKG-INFO
|
|
5
|
+
llm_latchkey.egg-info/SOURCES.txt
|
|
6
|
+
llm_latchkey.egg-info/dependency_links.txt
|
|
7
|
+
llm_latchkey.egg-info/entry_points.txt
|
|
8
|
+
llm_latchkey.egg-info/requires.txt
|
|
9
|
+
llm_latchkey.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
llm
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
llm_latchkey
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import shlex
|
|
2
|
+
import shutil
|
|
3
|
+
import subprocess
|
|
4
|
+
|
|
5
|
+
import llm
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class LatchkeyError(Exception):
|
|
9
|
+
pass
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _find_latchkey() -> str:
|
|
13
|
+
path = shutil.which("latchkey")
|
|
14
|
+
if path is None:
|
|
15
|
+
raise LatchkeyError(
|
|
16
|
+
"Latchkey is not installed. Install it with: npm install -g latchkey"
|
|
17
|
+
)
|
|
18
|
+
return path
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def latchkey(command: str) -> str:
|
|
22
|
+
"""Run a latchkey command. Latchkey injects stored API credentials into curl commands for third-party services.
|
|
23
|
+
|
|
24
|
+
Available commands:
|
|
25
|
+
- `services list --viable` — List services with configured credentials.
|
|
26
|
+
- `services info <service_name>` — Get auth options, credential status, and API docs links for a service.
|
|
27
|
+
- `curl <curl_arguments>` — Make an authenticated HTTP request. Pass standard curl arguments; credentials are injected automatically.
|
|
28
|
+
- `auth browser <service_name>` — Open a browser login popup to authenticate (only if credentials are missing/invalid).
|
|
29
|
+
|
|
30
|
+
Usage:
|
|
31
|
+
1. Start with `services list --viable` to discover configured services.
|
|
32
|
+
2. Use `services info <service_name>` to learn about the API and check credential status.
|
|
33
|
+
3. Use `curl <args>` to make requests — do NOT include Authorization headers, latchkey adds them.
|
|
34
|
+
4. If you get HTTP 401/403, check `services info` — if credentials are invalid, use `auth browser`.
|
|
35
|
+
5. Do NOT initiate a login if credential status is `valid` or `unknown`.
|
|
36
|
+
|
|
37
|
+
Important: Do NOT use shell features like $(...), backticks, or variable expansion in commands — they will not be interpreted. Compute any dynamic values (like dates) yourself and inline them directly.
|
|
38
|
+
|
|
39
|
+
Examples:
|
|
40
|
+
- `services list --viable`
|
|
41
|
+
- `services info slack`
|
|
42
|
+
- `curl https://api.github.com/user`
|
|
43
|
+
- `curl -X POST 'https://slack.com/api/conversations.create' -H 'Content-Type: application/json' -d '{"name":"my-channel"}'`
|
|
44
|
+
- `curl 'https://api.linear.app/graphql' -X POST -H 'Content-Type: application/json' -d '{"query": "{ viewer { assignedIssues(first: 10) { nodes { title state { name } } } } }"}'`
|
|
45
|
+
- `curl 'https://discord.com/api/v10/users/@me'`
|
|
46
|
+
|
|
47
|
+
Supported services include: AWS, Discord, Dropbox, GitHub, GitLab, Gmail, Google Calendar, Google Docs, Google Drive, Google Sheets, Linear, Notion, Sentry, Slack, Stripe, Telegram, Zoom, and more."""
|
|
48
|
+
latchkey_path = _find_latchkey()
|
|
49
|
+
try:
|
|
50
|
+
arguments = shlex.split(command)
|
|
51
|
+
except ValueError as error:
|
|
52
|
+
return f"Error parsing command: {error}"
|
|
53
|
+
|
|
54
|
+
timeout = 60 if arguments and arguments[0] == "curl" else 30
|
|
55
|
+
result = subprocess.run(
|
|
56
|
+
[latchkey_path, *arguments],
|
|
57
|
+
capture_output=True,
|
|
58
|
+
text=True,
|
|
59
|
+
timeout=timeout,
|
|
60
|
+
)
|
|
61
|
+
output = result.stdout.strip()
|
|
62
|
+
error = result.stderr.strip()
|
|
63
|
+
if result.returncode != 0:
|
|
64
|
+
return f"Error (exit code {result.returncode}): {error or output}"
|
|
65
|
+
if error and output:
|
|
66
|
+
return f"{output}\n\n(stderr: {error})"
|
|
67
|
+
return output or error or "(empty response)"
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@llm.hookimpl
|
|
71
|
+
def register_tools(register):
|
|
72
|
+
register(latchkey)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "llm-latchkey"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
description = "An LLM tool plugin for using Latchkey to make authenticated HTTP API requests."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.9"
|
|
7
|
+
license = { text = "MIT" }
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "Hynek Urban", email = "hynek@imbue.com" },
|
|
10
|
+
]
|
|
11
|
+
dependencies = [
|
|
12
|
+
"llm",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
[build-system]
|
|
16
|
+
requires = ["setuptools"]
|
|
17
|
+
build-backend = "setuptools.build_meta"
|
|
18
|
+
|
|
19
|
+
[project.urls]
|
|
20
|
+
Homepage = "https://github.com/imbue-ai/latchkey/integrations/llm-latchkey"
|
|
21
|
+
Issues = "https://github.com/imbue-ai/latchkey/issues"
|
|
22
|
+
Repository = "https://github.com/imbue-ai/latchkey"
|
|
23
|
+
|
|
24
|
+
[project.entry-points.llm]
|
|
25
|
+
latchkey = "llm_latchkey"
|