clikernel 0.2.9__tar.gz → 0.2.10__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.
- {clikernel-0.2.9 → clikernel-0.2.10}/CHANGELOG.md +7 -0
- clikernel-0.2.10/PKG-INFO +94 -0
- clikernel-0.2.10/README.md +71 -0
- {clikernel-0.2.9 → clikernel-0.2.10}/clikernel/__init__.py +1 -1
- {clikernel-0.2.9 → clikernel-0.2.10}/clikernel/core.py +2 -1
- {clikernel-0.2.9 → clikernel-0.2.10}/clikernel/skill.py +6 -0
- clikernel-0.2.10/clikernel.egg-info/PKG-INFO +94 -0
- {clikernel-0.2.9 → clikernel-0.2.10}/clikernel.egg-info/requires.txt +1 -1
- {clikernel-0.2.9 → clikernel-0.2.10}/pyproject.toml +1 -1
- clikernel-0.2.9/PKG-INFO +0 -76
- clikernel-0.2.9/README.md +0 -53
- clikernel-0.2.9/clikernel.egg-info/PKG-INFO +0 -76
- {clikernel-0.2.9 → clikernel-0.2.10}/LICENSE +0 -0
- {clikernel-0.2.9 → clikernel-0.2.10}/MANIFEST.in +0 -0
- {clikernel-0.2.9 → clikernel-0.2.10}/clikernel/_modidx.py +0 -0
- {clikernel-0.2.9 → clikernel-0.2.10}/clikernel/cli.py +0 -0
- {clikernel-0.2.9 → clikernel-0.2.10}/clikernel/mcp.py +0 -0
- {clikernel-0.2.9 → clikernel-0.2.10}/clikernel/stream.py +0 -0
- {clikernel-0.2.9 → clikernel-0.2.10}/clikernel.egg-info/SOURCES.txt +0 -0
- {clikernel-0.2.9 → clikernel-0.2.10}/clikernel.egg-info/dependency_links.txt +0 -0
- {clikernel-0.2.9 → clikernel-0.2.10}/clikernel.egg-info/entry_points.txt +0 -0
- {clikernel-0.2.9 → clikernel-0.2.10}/clikernel.egg-info/top_level.txt +0 -0
- {clikernel-0.2.9 → clikernel-0.2.10}/setup.cfg +0 -0
- {clikernel-0.2.9 → clikernel-0.2.10}/tests/test_stream.py +0 -0
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- do not remove -->
|
|
4
4
|
|
|
5
|
+
## 0.2.10
|
|
6
|
+
|
|
7
|
+
### New Features
|
|
8
|
+
|
|
9
|
+
- Add Luau kernel support: lua tool and create(language=...), Python-only startup/inspectors ([#48](https://github.com/AnswerDotAI/clikernel/issues/48))
|
|
10
|
+
|
|
11
|
+
|
|
5
12
|
## 0.2.9
|
|
6
13
|
|
|
7
14
|
### Breaking Changes
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: clikernel
|
|
3
|
+
Version: 0.2.10
|
|
4
|
+
Summary: Serve persistent Jupyter kernels to LLMs as concise text, over MCP or a plain stream protocol
|
|
5
|
+
Author: clikernel contributors
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Repository, https://github.com/AnswerDotAI/clikernel
|
|
8
|
+
Project-URL: Documentation, https://AnswerDotAI.github.io/clikernel/
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
11
|
+
Requires-Python: >=3.11
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: fastcore>=2.2.2
|
|
15
|
+
Requires-Dist: jupyasyncclient>=0.2.10
|
|
16
|
+
Requires-Dist: jupywire>=0.1.9
|
|
17
|
+
Requires-Dist: mcpmini>=0.0.4
|
|
18
|
+
Requires-Dist: rustygate>=0.1.11
|
|
19
|
+
Requires-Dist: httpx
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: fastship; extra == "dev"
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# clikernel
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
|
|
28
|
+
|
|
29
|
+
`clikernel` gives an LLM agent a persistent Python or Luau session. Imports, variables, and results remain available between tool calls. An agent can create a kernel or attach to an existing one, including a user’s live solveit kernel, on a local or named remote gateway.
|
|
30
|
+
|
|
31
|
+
[rustygate](https://github.com/AnswerDotAI/rustygate) hosts the Jupyter kernels and provides their MCP tools. `clikernel` is the conversation-side router: the MCP host launches it over stdio, and it forwards requests to gateways over HTTP. It selects gateways from `gateways.toml`, supplies `startup.py` and `inspectors.py` to Python kernels it creates, and starts a private local gateway when needed. The default kernel is [ipymini](https://github.com/AnswerDotAI/ipymini).
|
|
32
|
+
|
|
33
|
+
Kernel ownership determines what happens when the conversation ends:
|
|
34
|
+
|
|
35
|
+
- A session closes kernels it created with `autoclose`, including the automatic kernel used by bare `py` or `lua` and kernels created with `create`’s default settings.
|
|
36
|
+
- Attaching with `use_kernel` does not make that session responsible for closing the kernel.
|
|
37
|
+
- A kernel created with `autoclose=false` on a resident gateway can outlive the conversation. A later conversation can attach and continue using its state.
|
|
38
|
+
- A private child gateway ends with its conversation. Use a resident gateway for kernels that need to survive across conversations.
|
|
39
|
+
|
|
40
|
+
## Install
|
|
41
|
+
|
|
42
|
+
``` sh
|
|
43
|
+
pip install clikernel
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
This installs rustygate and ipymini. No service setup is required for a conversation-local kernel: clikernel starts a private gateway if it cannot find one. To retain kernels across conversations, run a resident gateway, for example through launchd or systemd:
|
|
47
|
+
|
|
48
|
+
``` sh
|
|
49
|
+
rustygate --port 8787
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Use with an MCP host
|
|
53
|
+
|
|
54
|
+
Register the stdio server with your MCP host. For Claude Code:
|
|
55
|
+
|
|
56
|
+
``` sh
|
|
57
|
+
claude mcp add clikernel -- clikernel-mcp
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Use `py(code=...)` for Python/IPython or `lua(code=...)` for bundled Luau. Either starts its language’s kernel when none is current. There is one current kernel: a language mismatch errors without switching or running the code. IPython magics, including `%%bash`, are Python-only.
|
|
61
|
+
|
|
62
|
+
For a named kernel, use `create(dlgname="work", language="luau")`. Omit `language` to reuse an existing binding unchanged, or default a new kernel to Python. An explicit language must match an existing binding. The other tools are `list_kernels`, `use_kernel`, `delete_kernel`, `restart`, and `interrupt`; creation, selection, and listing report the language.
|
|
63
|
+
|
|
64
|
+
These tools forward to rustygate. `list_kernels`, `use_kernel`, and `create` also accept a `host` naming a gateway from `gateways.toml`. One MCP registration can therefore reach multiple machines. Replies retain the gateway’s text and image blocks. Python startup and inspectors run only in Python, never Luau, including after restart.
|
|
65
|
+
|
|
66
|
+
`$CLIKERNEL_HOST` overrides the default gateway URL, `http://127.0.0.1:8787`. If no gateway answers, clikernel uses a private child gateway for the conversation. The ownership rules above determine which kernels close at session end.
|
|
67
|
+
|
|
68
|
+
Pass `--quiet`, as in `clikernel-mcp --quiet`, to omit startup output from replies. Python startup code still runs.
|
|
69
|
+
|
|
70
|
+
## Configuration
|
|
71
|
+
|
|
72
|
+
Three optional files in `$XDG_CONFIG_HOME/clikernel/` configure the router, usually under `~/.config/clikernel/`:
|
|
73
|
+
|
|
74
|
+
- `startup.py` runs in each Python kernel clikernel creates, with `__file__` set to its path. Its output appears in the reply announcing the kernel unless `--quiet` is set.
|
|
75
|
+
- `inspectors.py` installs Python cell inspectors after startup. Define `inspect`, a list named `inspectors`, or both. Each inspector runs once before a cell: a one-argument inspector takes the cell’s AST, and a two-argument inspector takes the AST and raw source. Return a string to print a note before the output. Raise the provided `RuleBlock` to block execution. Other exceptions produce a warning and allow the cell to run. See [examples/inspectors.py](examples/inspectors.py).
|
|
76
|
+
- `gateways.toml` names remote gateways and configures authentication without putting tokens in tool arguments:
|
|
77
|
+
|
|
78
|
+
``` toml
|
|
79
|
+
[gateways.solveit]
|
|
80
|
+
url = "https://solveit.example.com/gate"
|
|
81
|
+
token_env = "SOLVEIT_TOKEN"
|
|
82
|
+
verify = false # optional: accept a self-signed certificate
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## The stream protocol
|
|
86
|
+
|
|
87
|
+
Run `clikernel` as a plain CLI process for clients that read a text stream rather than MCP messages. It uses a delimiter-framed stdin/stdout protocol:
|
|
88
|
+
|
|
89
|
+
- Input is not echoed.
|
|
90
|
+
- Each request gets a `.` acknowledgement.
|
|
91
|
+
- A per-process random delimiter marks the end of each response.
|
|
92
|
+
- Multiline cells are framed by `--` and the delimiter.
|
|
93
|
+
|
|
94
|
+
The startup banner supplies the protocol instructions and delimiter. Running `clikernel` without arguments creates a kernel and stops it on exit. `--kernel <id>` attaches to an existing kernel and leaves it running on exit.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# clikernel
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
|
|
5
|
+
|
|
6
|
+
`clikernel` gives an LLM agent a persistent Python or Luau session. Imports, variables, and results remain available between tool calls. An agent can create a kernel or attach to an existing one, including a user’s live solveit kernel, on a local or named remote gateway.
|
|
7
|
+
|
|
8
|
+
[rustygate](https://github.com/AnswerDotAI/rustygate) hosts the Jupyter kernels and provides their MCP tools. `clikernel` is the conversation-side router: the MCP host launches it over stdio, and it forwards requests to gateways over HTTP. It selects gateways from `gateways.toml`, supplies `startup.py` and `inspectors.py` to Python kernels it creates, and starts a private local gateway when needed. The default kernel is [ipymini](https://github.com/AnswerDotAI/ipymini).
|
|
9
|
+
|
|
10
|
+
Kernel ownership determines what happens when the conversation ends:
|
|
11
|
+
|
|
12
|
+
- A session closes kernels it created with `autoclose`, including the automatic kernel used by bare `py` or `lua` and kernels created with `create`’s default settings.
|
|
13
|
+
- Attaching with `use_kernel` does not make that session responsible for closing the kernel.
|
|
14
|
+
- A kernel created with `autoclose=false` on a resident gateway can outlive the conversation. A later conversation can attach and continue using its state.
|
|
15
|
+
- A private child gateway ends with its conversation. Use a resident gateway for kernels that need to survive across conversations.
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
``` sh
|
|
20
|
+
pip install clikernel
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
This installs rustygate and ipymini. No service setup is required for a conversation-local kernel: clikernel starts a private gateway if it cannot find one. To retain kernels across conversations, run a resident gateway, for example through launchd or systemd:
|
|
24
|
+
|
|
25
|
+
``` sh
|
|
26
|
+
rustygate --port 8787
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Use with an MCP host
|
|
30
|
+
|
|
31
|
+
Register the stdio server with your MCP host. For Claude Code:
|
|
32
|
+
|
|
33
|
+
``` sh
|
|
34
|
+
claude mcp add clikernel -- clikernel-mcp
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Use `py(code=...)` for Python/IPython or `lua(code=...)` for bundled Luau. Either starts its language’s kernel when none is current. There is one current kernel: a language mismatch errors without switching or running the code. IPython magics, including `%%bash`, are Python-only.
|
|
38
|
+
|
|
39
|
+
For a named kernel, use `create(dlgname="work", language="luau")`. Omit `language` to reuse an existing binding unchanged, or default a new kernel to Python. An explicit language must match an existing binding. The other tools are `list_kernels`, `use_kernel`, `delete_kernel`, `restart`, and `interrupt`; creation, selection, and listing report the language.
|
|
40
|
+
|
|
41
|
+
These tools forward to rustygate. `list_kernels`, `use_kernel`, and `create` also accept a `host` naming a gateway from `gateways.toml`. One MCP registration can therefore reach multiple machines. Replies retain the gateway’s text and image blocks. Python startup and inspectors run only in Python, never Luau, including after restart.
|
|
42
|
+
|
|
43
|
+
`$CLIKERNEL_HOST` overrides the default gateway URL, `http://127.0.0.1:8787`. If no gateway answers, clikernel uses a private child gateway for the conversation. The ownership rules above determine which kernels close at session end.
|
|
44
|
+
|
|
45
|
+
Pass `--quiet`, as in `clikernel-mcp --quiet`, to omit startup output from replies. Python startup code still runs.
|
|
46
|
+
|
|
47
|
+
## Configuration
|
|
48
|
+
|
|
49
|
+
Three optional files in `$XDG_CONFIG_HOME/clikernel/` configure the router, usually under `~/.config/clikernel/`:
|
|
50
|
+
|
|
51
|
+
- `startup.py` runs in each Python kernel clikernel creates, with `__file__` set to its path. Its output appears in the reply announcing the kernel unless `--quiet` is set.
|
|
52
|
+
- `inspectors.py` installs Python cell inspectors after startup. Define `inspect`, a list named `inspectors`, or both. Each inspector runs once before a cell: a one-argument inspector takes the cell’s AST, and a two-argument inspector takes the AST and raw source. Return a string to print a note before the output. Raise the provided `RuleBlock` to block execution. Other exceptions produce a warning and allow the cell to run. See [examples/inspectors.py](examples/inspectors.py).
|
|
53
|
+
- `gateways.toml` names remote gateways and configures authentication without putting tokens in tool arguments:
|
|
54
|
+
|
|
55
|
+
``` toml
|
|
56
|
+
[gateways.solveit]
|
|
57
|
+
url = "https://solveit.example.com/gate"
|
|
58
|
+
token_env = "SOLVEIT_TOKEN"
|
|
59
|
+
verify = false # optional: accept a self-signed certificate
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## The stream protocol
|
|
63
|
+
|
|
64
|
+
Run `clikernel` as a plain CLI process for clients that read a text stream rather than MCP messages. It uses a delimiter-framed stdin/stdout protocol:
|
|
65
|
+
|
|
66
|
+
- Input is not echoed.
|
|
67
|
+
- Each request gets a `.` acknowledgement.
|
|
68
|
+
- A per-process random delimiter marks the end of each response.
|
|
69
|
+
- Multiline cells are framed by `--` and the delimiter.
|
|
70
|
+
|
|
71
|
+
The startup banner supplies the protocol instructions and delimiter. Running `clikernel` without arguments creates a kernel and stops it on exit. `--kernel <id>` attaches to an existing kernel and leaves it running on exit.
|
|
@@ -8,4 +8,4 @@ Modules:
|
|
|
8
8
|
- `clikernel.skill`: Use the `clikernel` MCP session as the default workspace for Python work: reading and changing files, notebook work, trying things out, checking how a library behaves, and reshaping data. One session stays open, so imports and variables carry between calls. Read this before writing, running, or debugging Python code in a session with `clikernel` connected.
|
|
9
9
|
- `clikernel.stream`: Streaming JSON-lines worker protocol: nbformat-shaped output events, and a supervisor for select-based UIs."""
|
|
10
10
|
|
|
11
|
-
__version__ = "0.2.
|
|
11
|
+
__version__ = "0.2.10"
|
|
@@ -33,8 +33,9 @@ def resolve(host='', cfgdir=None):
|
|
|
33
33
|
"`(url, token, verify)` for `host`: empty = the default local gateway, a URL = itself, else a `gateways.toml` name"
|
|
34
34
|
if not host: return os.environ.get('CLIKERNEL_HOST', DEFAULT_URL), os.environ.get('CLIKERNEL_TOKEN'), True
|
|
35
35
|
if '://' in host: return host, os.environ.get('CLIKERNEL_TOKEN'), True
|
|
36
|
+
cfgdir = Path(cfgdir) if cfgdir else cfg_dir()
|
|
36
37
|
g = gateways(cfgdir).get(host)
|
|
37
|
-
if g is None: raise ValueError(f"unknown gateway {host!r}: not a URL, and not in {
|
|
38
|
+
if g is None: raise ValueError(f"unknown gateway {host!r}: not a URL, and not in {cfgdir/'gateways.toml'}")
|
|
38
39
|
return g['url'], g.get('token') or os.environ.get(g.get('token_env','')) or None, g.get('verify', True)
|
|
39
40
|
|
|
40
41
|
|
|
@@ -14,6 +14,12 @@ Remote gateways are the same tools with a `host` argument on `list_kernels`, `us
|
|
|
14
14
|
|
|
15
15
|
# Working in it
|
|
16
16
|
|
|
17
|
+
For native Luau work use `lua(code=...)`, or `create(dlgname, language="luau")` for a named kernel. The first `lua` auto-starts Luau when no kernel is selected, with the same autoclose rules as Python. There is one current kernel: `py` requires Python and `lua` requires Luau, so a mismatch errors rather than switching. Use `use_kernel` or `create` to select deliberately. Omit `language` to reuse an existing binding unchanged or default a new one to Python; an explicit language must match an existing binding. A `dlgname` execution override changes only that call. These rules also apply on named remote gateways.
|
|
18
|
+
|
|
19
|
+
Start native work with `lua(code="help()")` for the bundled guide and examples, or `lua(code='help("ex.edit_file")')` for function details.
|
|
20
|
+
|
|
21
|
+
Luau has persistent globals, cell-local `local` variables, and native `rg.search`, `rg.find`, `fs.read_text`, `ex.edit_text`, `ex.view_file`/`ex.edit_file`, `ex.view_cell`/`ex.edit_cell`, `os.execute`, and `io.popen` APIs. File edits use arrays of command fields (like Python exhash tuples); `{inplace=false}` previews. Shell commands use `/bin/sh -c`; pipes support read/lines/write/flush/close and persist until closed. Interrupts terminate subprocess groups and close outstanding pipes. Python startup/inspectors and IPython magics do not apply to Luau. The following guidance is for Python:
|
|
22
|
+
|
|
17
23
|
- Magics work as written, including `%%bash` for shell work. `%cd` expands `~` and is the way to change directory: prefer it over `os.chdir`.
|
|
18
24
|
- Only the last expression in a cell displays. `print(...)` any earlier value you need to see.
|
|
19
25
|
- Everything a cell outputs lands in the conversation. Be selective: `len(v)` first, then decide what to show.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: clikernel
|
|
3
|
+
Version: 0.2.10
|
|
4
|
+
Summary: Serve persistent Jupyter kernels to LLMs as concise text, over MCP or a plain stream protocol
|
|
5
|
+
Author: clikernel contributors
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Repository, https://github.com/AnswerDotAI/clikernel
|
|
8
|
+
Project-URL: Documentation, https://AnswerDotAI.github.io/clikernel/
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
11
|
+
Requires-Python: >=3.11
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: fastcore>=2.2.2
|
|
15
|
+
Requires-Dist: jupyasyncclient>=0.2.10
|
|
16
|
+
Requires-Dist: jupywire>=0.1.9
|
|
17
|
+
Requires-Dist: mcpmini>=0.0.4
|
|
18
|
+
Requires-Dist: rustygate>=0.1.11
|
|
19
|
+
Requires-Dist: httpx
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: fastship; extra == "dev"
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
|
|
24
|
+
# clikernel
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
|
|
28
|
+
|
|
29
|
+
`clikernel` gives an LLM agent a persistent Python or Luau session. Imports, variables, and results remain available between tool calls. An agent can create a kernel or attach to an existing one, including a user’s live solveit kernel, on a local or named remote gateway.
|
|
30
|
+
|
|
31
|
+
[rustygate](https://github.com/AnswerDotAI/rustygate) hosts the Jupyter kernels and provides their MCP tools. `clikernel` is the conversation-side router: the MCP host launches it over stdio, and it forwards requests to gateways over HTTP. It selects gateways from `gateways.toml`, supplies `startup.py` and `inspectors.py` to Python kernels it creates, and starts a private local gateway when needed. The default kernel is [ipymini](https://github.com/AnswerDotAI/ipymini).
|
|
32
|
+
|
|
33
|
+
Kernel ownership determines what happens when the conversation ends:
|
|
34
|
+
|
|
35
|
+
- A session closes kernels it created with `autoclose`, including the automatic kernel used by bare `py` or `lua` and kernels created with `create`’s default settings.
|
|
36
|
+
- Attaching with `use_kernel` does not make that session responsible for closing the kernel.
|
|
37
|
+
- A kernel created with `autoclose=false` on a resident gateway can outlive the conversation. A later conversation can attach and continue using its state.
|
|
38
|
+
- A private child gateway ends with its conversation. Use a resident gateway for kernels that need to survive across conversations.
|
|
39
|
+
|
|
40
|
+
## Install
|
|
41
|
+
|
|
42
|
+
``` sh
|
|
43
|
+
pip install clikernel
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
This installs rustygate and ipymini. No service setup is required for a conversation-local kernel: clikernel starts a private gateway if it cannot find one. To retain kernels across conversations, run a resident gateway, for example through launchd or systemd:
|
|
47
|
+
|
|
48
|
+
``` sh
|
|
49
|
+
rustygate --port 8787
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Use with an MCP host
|
|
53
|
+
|
|
54
|
+
Register the stdio server with your MCP host. For Claude Code:
|
|
55
|
+
|
|
56
|
+
``` sh
|
|
57
|
+
claude mcp add clikernel -- clikernel-mcp
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Use `py(code=...)` for Python/IPython or `lua(code=...)` for bundled Luau. Either starts its language’s kernel when none is current. There is one current kernel: a language mismatch errors without switching or running the code. IPython magics, including `%%bash`, are Python-only.
|
|
61
|
+
|
|
62
|
+
For a named kernel, use `create(dlgname="work", language="luau")`. Omit `language` to reuse an existing binding unchanged, or default a new kernel to Python. An explicit language must match an existing binding. The other tools are `list_kernels`, `use_kernel`, `delete_kernel`, `restart`, and `interrupt`; creation, selection, and listing report the language.
|
|
63
|
+
|
|
64
|
+
These tools forward to rustygate. `list_kernels`, `use_kernel`, and `create` also accept a `host` naming a gateway from `gateways.toml`. One MCP registration can therefore reach multiple machines. Replies retain the gateway’s text and image blocks. Python startup and inspectors run only in Python, never Luau, including after restart.
|
|
65
|
+
|
|
66
|
+
`$CLIKERNEL_HOST` overrides the default gateway URL, `http://127.0.0.1:8787`. If no gateway answers, clikernel uses a private child gateway for the conversation. The ownership rules above determine which kernels close at session end.
|
|
67
|
+
|
|
68
|
+
Pass `--quiet`, as in `clikernel-mcp --quiet`, to omit startup output from replies. Python startup code still runs.
|
|
69
|
+
|
|
70
|
+
## Configuration
|
|
71
|
+
|
|
72
|
+
Three optional files in `$XDG_CONFIG_HOME/clikernel/` configure the router, usually under `~/.config/clikernel/`:
|
|
73
|
+
|
|
74
|
+
- `startup.py` runs in each Python kernel clikernel creates, with `__file__` set to its path. Its output appears in the reply announcing the kernel unless `--quiet` is set.
|
|
75
|
+
- `inspectors.py` installs Python cell inspectors after startup. Define `inspect`, a list named `inspectors`, or both. Each inspector runs once before a cell: a one-argument inspector takes the cell’s AST, and a two-argument inspector takes the AST and raw source. Return a string to print a note before the output. Raise the provided `RuleBlock` to block execution. Other exceptions produce a warning and allow the cell to run. See [examples/inspectors.py](examples/inspectors.py).
|
|
76
|
+
- `gateways.toml` names remote gateways and configures authentication without putting tokens in tool arguments:
|
|
77
|
+
|
|
78
|
+
``` toml
|
|
79
|
+
[gateways.solveit]
|
|
80
|
+
url = "https://solveit.example.com/gate"
|
|
81
|
+
token_env = "SOLVEIT_TOKEN"
|
|
82
|
+
verify = false # optional: accept a self-signed certificate
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## The stream protocol
|
|
86
|
+
|
|
87
|
+
Run `clikernel` as a plain CLI process for clients that read a text stream rather than MCP messages. It uses a delimiter-framed stdin/stdout protocol:
|
|
88
|
+
|
|
89
|
+
- Input is not echoed.
|
|
90
|
+
- Each request gets a `.` acknowledgement.
|
|
91
|
+
- A per-process random delimiter marks the end of each response.
|
|
92
|
+
- Multiline cells are framed by `--` and the delimiter.
|
|
93
|
+
|
|
94
|
+
The startup banner supplies the protocol instructions and delimiter. Running `clikernel` without arguments creates a kernel and stops it on exit. `--kernel <id>` attaches to an existing kernel and leaves it running on exit.
|
clikernel-0.2.9/PKG-INFO
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: clikernel
|
|
3
|
-
Version: 0.2.9
|
|
4
|
-
Summary: Serve persistent Jupyter kernels to LLMs as concise text, over MCP or a plain stream protocol
|
|
5
|
-
Author: clikernel contributors
|
|
6
|
-
License: Apache-2.0
|
|
7
|
-
Project-URL: Repository, https://github.com/AnswerDotAI/clikernel
|
|
8
|
-
Project-URL: Documentation, https://AnswerDotAI.github.io/clikernel/
|
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
11
|
-
Requires-Python: >=3.11
|
|
12
|
-
Description-Content-Type: text/markdown
|
|
13
|
-
License-File: LICENSE
|
|
14
|
-
Requires-Dist: fastcore>=2.2.2
|
|
15
|
-
Requires-Dist: jupyasyncclient>=0.2.10
|
|
16
|
-
Requires-Dist: jupywire>=0.1.9
|
|
17
|
-
Requires-Dist: mcpmini>=0.0.4
|
|
18
|
-
Requires-Dist: rustygate>=0.1.7
|
|
19
|
-
Requires-Dist: httpx
|
|
20
|
-
Provides-Extra: dev
|
|
21
|
-
Requires-Dist: fastship; extra == "dev"
|
|
22
|
-
Dynamic: license-file
|
|
23
|
-
|
|
24
|
-
# clikernel
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
|
|
28
|
-
|
|
29
|
-
`clikernel` gives an LLM agent a persistent Python workbench built from two processes. A gateway ([rustygate](https://github.com/AnswerDotAI/rustygate)) hosts real Jupyter kernels ([ipymini](https://github.com/AnswerDotAI/ipymini) by default) and serves the MCP tool surface itself; kernels live there and persist until explicitly stopped. `clikernel` starts and stops with each conversation: a router the MCP host launches, speaking stdio MCP to the model and forwarding to gateways over HTTP. It adds what a single fixed endpoint cannot: gateway naming from `gateways.toml` (a `host` argument on the kernel-selection tools reaches any machine you’ve named), delivery of your `startup.py` and `inspectors.py` into every kernel a conversation creates, and a local gateway that always exists — found running, or started as a child that lives exactly as long as the conversation.
|
|
30
|
-
|
|
31
|
-
Kernel scope is the gateway’s rule, one rule everywhere: a session’s end stops the kernels it created with autoclose (the bare-`py` auto kernel, and `create`’s default) and nothing else. A kernel created with `autoclose=false` on a persistent gateway outlives the conversation, and a later conversation reattaches with `use_kernel` and finds its state intact — including the user’s live solveit kernel.
|
|
32
|
-
|
|
33
|
-
## Install
|
|
34
|
-
|
|
35
|
-
``` sh
|
|
36
|
-
pip install clikernel
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
This brings [rustygate](https://github.com/AnswerDotAI/rustygate) and a kernel ([ipymini](https://github.com/AnswerDotAI/ipymini)) with it, and no service setup is needed: a conversation that finds no gateway starts its own. Run a resident gateway when kernels should outlive conversations (e.g. via launchd/systemd):
|
|
40
|
-
|
|
41
|
-
``` sh
|
|
42
|
-
rustygate --port 8787
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## Use with an MCP host
|
|
46
|
-
|
|
47
|
-
Register the stdio server with your MCP host, e.g. for Claude Code:
|
|
48
|
-
|
|
49
|
-
``` sh
|
|
50
|
-
claude mcp add clikernel -- clikernel-mcp
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
The tools are rustygate’s, forwarded: `py` (the normal tool — it auto-starts a kernel when none is current, and magics like a `%%bash` first line run as written), `list_kernels`, `create`, `use_kernel`, `delete_kernel`, `restart`, and `interrupt`. The router adds one thing to them: `list_kernels`, `use_kernel`, and `create` take a `host` naming a gateway from `gateways.toml`, so one MCP entry reaches every machine you’ve named. Replies carry text and image blocks exactly as the gateway rendered them.
|
|
54
|
-
|
|
55
|
-
A conversation cleans up after itself: its end stops the auto kernel and every `create` it made, unless `autoclose=false` asked for a keeper. Kernels reached with `use_kernel` are never touched. `$CLIKERNEL_HOST` overrides the default gateway (`http://127.0.0.1:8787`), and when nothing answers there, the conversation runs on a private child gateway that ends with it.
|
|
56
|
-
|
|
57
|
-
Pass `--quiet` (`clikernel-mcp --quiet`) for a host whose sessions should not see banner noise: startup still runs, but its output stays out of every reply.
|
|
58
|
-
|
|
59
|
-
## Configuration
|
|
60
|
-
|
|
61
|
-
Three optional files in `$XDG_CONFIG_HOME/clikernel/` (usually `~/.config/clikernel/`):
|
|
62
|
-
|
|
63
|
-
- `startup.py` — run in every kernel clikernel creates, with `__file__` bound to its path; its output returns in the reply that announces the kernel.
|
|
64
|
-
- `inspectors.py` — cell inspectors installed after startup. The file may define `inspect` and/or a list `inspectors`; each is called once per cell before it runs (1-arg: the cell’s AST; 2-arg: AST and raw source). Return a string to print a note before the cell’s output, raise `RuleBlock` (provided in the namespace) to block the cell; any other exception warns and the cell runs. See `examples/inspectors.py`.
|
|
65
|
-
- `gateways.toml` — named remote gateways, so tokens never appear in tool arguments:
|
|
66
|
-
|
|
67
|
-
``` toml
|
|
68
|
-
[gateways.solveit]
|
|
69
|
-
url = "https://solveit.example.com/gate"
|
|
70
|
-
token_env = "SOLVEIT_TOKEN"
|
|
71
|
-
verify = false # optional: accept a self-signed certificate
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## The stream protocol
|
|
75
|
-
|
|
76
|
-
Run `clikernel` as a plain CLI process and the same client speaks a delimiter-framed stdin/stdout protocol for token-reading clients: no echo, a cheap `.` acknowledgement per request, responses ended by a per-process random delimiter, multiline cells framed by `--` and the delimiter. The full recipe is announced in the process’s own startup banner. Run bare it creates a kernel and stops it on exit; `--kernel <id>` attaches to an existing kernel and leaves it as found.
|
clikernel-0.2.9/README.md
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# clikernel
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
|
|
5
|
-
|
|
6
|
-
`clikernel` gives an LLM agent a persistent Python workbench built from two processes. A gateway ([rustygate](https://github.com/AnswerDotAI/rustygate)) hosts real Jupyter kernels ([ipymini](https://github.com/AnswerDotAI/ipymini) by default) and serves the MCP tool surface itself; kernels live there and persist until explicitly stopped. `clikernel` starts and stops with each conversation: a router the MCP host launches, speaking stdio MCP to the model and forwarding to gateways over HTTP. It adds what a single fixed endpoint cannot: gateway naming from `gateways.toml` (a `host` argument on the kernel-selection tools reaches any machine you’ve named), delivery of your `startup.py` and `inspectors.py` into every kernel a conversation creates, and a local gateway that always exists — found running, or started as a child that lives exactly as long as the conversation.
|
|
7
|
-
|
|
8
|
-
Kernel scope is the gateway’s rule, one rule everywhere: a session’s end stops the kernels it created with autoclose (the bare-`py` auto kernel, and `create`’s default) and nothing else. A kernel created with `autoclose=false` on a persistent gateway outlives the conversation, and a later conversation reattaches with `use_kernel` and finds its state intact — including the user’s live solveit kernel.
|
|
9
|
-
|
|
10
|
-
## Install
|
|
11
|
-
|
|
12
|
-
``` sh
|
|
13
|
-
pip install clikernel
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
This brings [rustygate](https://github.com/AnswerDotAI/rustygate) and a kernel ([ipymini](https://github.com/AnswerDotAI/ipymini)) with it, and no service setup is needed: a conversation that finds no gateway starts its own. Run a resident gateway when kernels should outlive conversations (e.g. via launchd/systemd):
|
|
17
|
-
|
|
18
|
-
``` sh
|
|
19
|
-
rustygate --port 8787
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
## Use with an MCP host
|
|
23
|
-
|
|
24
|
-
Register the stdio server with your MCP host, e.g. for Claude Code:
|
|
25
|
-
|
|
26
|
-
``` sh
|
|
27
|
-
claude mcp add clikernel -- clikernel-mcp
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
The tools are rustygate’s, forwarded: `py` (the normal tool — it auto-starts a kernel when none is current, and magics like a `%%bash` first line run as written), `list_kernels`, `create`, `use_kernel`, `delete_kernel`, `restart`, and `interrupt`. The router adds one thing to them: `list_kernels`, `use_kernel`, and `create` take a `host` naming a gateway from `gateways.toml`, so one MCP entry reaches every machine you’ve named. Replies carry text and image blocks exactly as the gateway rendered them.
|
|
31
|
-
|
|
32
|
-
A conversation cleans up after itself: its end stops the auto kernel and every `create` it made, unless `autoclose=false` asked for a keeper. Kernels reached with `use_kernel` are never touched. `$CLIKERNEL_HOST` overrides the default gateway (`http://127.0.0.1:8787`), and when nothing answers there, the conversation runs on a private child gateway that ends with it.
|
|
33
|
-
|
|
34
|
-
Pass `--quiet` (`clikernel-mcp --quiet`) for a host whose sessions should not see banner noise: startup still runs, but its output stays out of every reply.
|
|
35
|
-
|
|
36
|
-
## Configuration
|
|
37
|
-
|
|
38
|
-
Three optional files in `$XDG_CONFIG_HOME/clikernel/` (usually `~/.config/clikernel/`):
|
|
39
|
-
|
|
40
|
-
- `startup.py` — run in every kernel clikernel creates, with `__file__` bound to its path; its output returns in the reply that announces the kernel.
|
|
41
|
-
- `inspectors.py` — cell inspectors installed after startup. The file may define `inspect` and/or a list `inspectors`; each is called once per cell before it runs (1-arg: the cell’s AST; 2-arg: AST and raw source). Return a string to print a note before the cell’s output, raise `RuleBlock` (provided in the namespace) to block the cell; any other exception warns and the cell runs. See `examples/inspectors.py`.
|
|
42
|
-
- `gateways.toml` — named remote gateways, so tokens never appear in tool arguments:
|
|
43
|
-
|
|
44
|
-
``` toml
|
|
45
|
-
[gateways.solveit]
|
|
46
|
-
url = "https://solveit.example.com/gate"
|
|
47
|
-
token_env = "SOLVEIT_TOKEN"
|
|
48
|
-
verify = false # optional: accept a self-signed certificate
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## The stream protocol
|
|
52
|
-
|
|
53
|
-
Run `clikernel` as a plain CLI process and the same client speaks a delimiter-framed stdin/stdout protocol for token-reading clients: no echo, a cheap `.` acknowledgement per request, responses ended by a per-process random delimiter, multiline cells framed by `--` and the delimiter. The full recipe is announced in the process’s own startup banner. Run bare it creates a kernel and stops it on exit; `--kernel <id>` attaches to an existing kernel and leaves it as found.
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: clikernel
|
|
3
|
-
Version: 0.2.9
|
|
4
|
-
Summary: Serve persistent Jupyter kernels to LLMs as concise text, over MCP or a plain stream protocol
|
|
5
|
-
Author: clikernel contributors
|
|
6
|
-
License: Apache-2.0
|
|
7
|
-
Project-URL: Repository, https://github.com/AnswerDotAI/clikernel
|
|
8
|
-
Project-URL: Documentation, https://AnswerDotAI.github.io/clikernel/
|
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
11
|
-
Requires-Python: >=3.11
|
|
12
|
-
Description-Content-Type: text/markdown
|
|
13
|
-
License-File: LICENSE
|
|
14
|
-
Requires-Dist: fastcore>=2.2.2
|
|
15
|
-
Requires-Dist: jupyasyncclient>=0.2.10
|
|
16
|
-
Requires-Dist: jupywire>=0.1.9
|
|
17
|
-
Requires-Dist: mcpmini>=0.0.4
|
|
18
|
-
Requires-Dist: rustygate>=0.1.7
|
|
19
|
-
Requires-Dist: httpx
|
|
20
|
-
Provides-Extra: dev
|
|
21
|
-
Requires-Dist: fastship; extra == "dev"
|
|
22
|
-
Dynamic: license-file
|
|
23
|
-
|
|
24
|
-
# clikernel
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
|
|
28
|
-
|
|
29
|
-
`clikernel` gives an LLM agent a persistent Python workbench built from two processes. A gateway ([rustygate](https://github.com/AnswerDotAI/rustygate)) hosts real Jupyter kernels ([ipymini](https://github.com/AnswerDotAI/ipymini) by default) and serves the MCP tool surface itself; kernels live there and persist until explicitly stopped. `clikernel` starts and stops with each conversation: a router the MCP host launches, speaking stdio MCP to the model and forwarding to gateways over HTTP. It adds what a single fixed endpoint cannot: gateway naming from `gateways.toml` (a `host` argument on the kernel-selection tools reaches any machine you’ve named), delivery of your `startup.py` and `inspectors.py` into every kernel a conversation creates, and a local gateway that always exists — found running, or started as a child that lives exactly as long as the conversation.
|
|
30
|
-
|
|
31
|
-
Kernel scope is the gateway’s rule, one rule everywhere: a session’s end stops the kernels it created with autoclose (the bare-`py` auto kernel, and `create`’s default) and nothing else. A kernel created with `autoclose=false` on a persistent gateway outlives the conversation, and a later conversation reattaches with `use_kernel` and finds its state intact — including the user’s live solveit kernel.
|
|
32
|
-
|
|
33
|
-
## Install
|
|
34
|
-
|
|
35
|
-
``` sh
|
|
36
|
-
pip install clikernel
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
This brings [rustygate](https://github.com/AnswerDotAI/rustygate) and a kernel ([ipymini](https://github.com/AnswerDotAI/ipymini)) with it, and no service setup is needed: a conversation that finds no gateway starts its own. Run a resident gateway when kernels should outlive conversations (e.g. via launchd/systemd):
|
|
40
|
-
|
|
41
|
-
``` sh
|
|
42
|
-
rustygate --port 8787
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## Use with an MCP host
|
|
46
|
-
|
|
47
|
-
Register the stdio server with your MCP host, e.g. for Claude Code:
|
|
48
|
-
|
|
49
|
-
``` sh
|
|
50
|
-
claude mcp add clikernel -- clikernel-mcp
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
The tools are rustygate’s, forwarded: `py` (the normal tool — it auto-starts a kernel when none is current, and magics like a `%%bash` first line run as written), `list_kernels`, `create`, `use_kernel`, `delete_kernel`, `restart`, and `interrupt`. The router adds one thing to them: `list_kernels`, `use_kernel`, and `create` take a `host` naming a gateway from `gateways.toml`, so one MCP entry reaches every machine you’ve named. Replies carry text and image blocks exactly as the gateway rendered them.
|
|
54
|
-
|
|
55
|
-
A conversation cleans up after itself: its end stops the auto kernel and every `create` it made, unless `autoclose=false` asked for a keeper. Kernels reached with `use_kernel` are never touched. `$CLIKERNEL_HOST` overrides the default gateway (`http://127.0.0.1:8787`), and when nothing answers there, the conversation runs on a private child gateway that ends with it.
|
|
56
|
-
|
|
57
|
-
Pass `--quiet` (`clikernel-mcp --quiet`) for a host whose sessions should not see banner noise: startup still runs, but its output stays out of every reply.
|
|
58
|
-
|
|
59
|
-
## Configuration
|
|
60
|
-
|
|
61
|
-
Three optional files in `$XDG_CONFIG_HOME/clikernel/` (usually `~/.config/clikernel/`):
|
|
62
|
-
|
|
63
|
-
- `startup.py` — run in every kernel clikernel creates, with `__file__` bound to its path; its output returns in the reply that announces the kernel.
|
|
64
|
-
- `inspectors.py` — cell inspectors installed after startup. The file may define `inspect` and/or a list `inspectors`; each is called once per cell before it runs (1-arg: the cell’s AST; 2-arg: AST and raw source). Return a string to print a note before the cell’s output, raise `RuleBlock` (provided in the namespace) to block the cell; any other exception warns and the cell runs. See `examples/inspectors.py`.
|
|
65
|
-
- `gateways.toml` — named remote gateways, so tokens never appear in tool arguments:
|
|
66
|
-
|
|
67
|
-
``` toml
|
|
68
|
-
[gateways.solveit]
|
|
69
|
-
url = "https://solveit.example.com/gate"
|
|
70
|
-
token_env = "SOLVEIT_TOKEN"
|
|
71
|
-
verify = false # optional: accept a self-signed certificate
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## The stream protocol
|
|
75
|
-
|
|
76
|
-
Run `clikernel` as a plain CLI process and the same client speaks a delimiter-framed stdin/stdout protocol for token-reading clients: no echo, a cheap `.` acknowledgement per request, responses ended by a per-process random delimiter, multiline cells framed by `--` and the delimiter. The full recipe is announced in the process’s own startup banner. Run bare it creates a kernel and stops it on exit; `--kernel <id>` attaches to an existing kernel and leaves it as found.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|