clikernel 0.2.18__tar.gz → 0.2.20__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.18 → clikernel-0.2.20}/CHANGELOG.md +15 -0
- {clikernel-0.2.18/clikernel.egg-info → clikernel-0.2.20}/PKG-INFO +6 -5
- {clikernel-0.2.18 → clikernel-0.2.20}/README.md +4 -3
- {clikernel-0.2.18 → clikernel-0.2.20}/clikernel/__init__.py +1 -1
- {clikernel-0.2.18 → clikernel-0.2.20}/clikernel/_modidx.py +1 -0
- {clikernel-0.2.18 → clikernel-0.2.20}/clikernel/core.py +8 -6
- clikernel-0.2.20/clikernel/login.py +40 -0
- {clikernel-0.2.18 → clikernel-0.2.20}/clikernel/mcp.py +4 -2
- {clikernel-0.2.18 → clikernel-0.2.20/clikernel.egg-info}/PKG-INFO +6 -5
- {clikernel-0.2.18 → clikernel-0.2.20}/clikernel.egg-info/SOURCES.txt +1 -0
- {clikernel-0.2.18 → clikernel-0.2.20}/clikernel.egg-info/entry_points.txt +1 -0
- {clikernel-0.2.18 → clikernel-0.2.20}/clikernel.egg-info/requires.txt +1 -1
- {clikernel-0.2.18 → clikernel-0.2.20}/pyproject.toml +2 -1
- {clikernel-0.2.18 → clikernel-0.2.20}/LICENSE +0 -0
- {clikernel-0.2.18 → clikernel-0.2.20}/MANIFEST.in +0 -0
- {clikernel-0.2.18 → clikernel-0.2.20}/clikernel/cli.py +0 -0
- {clikernel-0.2.18 → clikernel-0.2.20}/clikernel/rules.py +0 -0
- {clikernel-0.2.18 → clikernel-0.2.20}/clikernel/skill.py +0 -0
- {clikernel-0.2.18 → clikernel-0.2.20}/clikernel/stream.py +0 -0
- {clikernel-0.2.18 → clikernel-0.2.20}/clikernel.egg-info/dependency_links.txt +0 -0
- {clikernel-0.2.18 → clikernel-0.2.20}/clikernel.egg-info/top_level.txt +0 -0
- {clikernel-0.2.18 → clikernel-0.2.20}/setup.cfg +0 -0
- {clikernel-0.2.18 → clikernel-0.2.20}/tests/test_rules.py +0 -0
- {clikernel-0.2.18 → clikernel-0.2.20}/tests/test_stream.py +0 -0
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
<!-- do not remove -->
|
|
4
4
|
|
|
5
|
+
## 0.2.20
|
|
6
|
+
|
|
7
|
+
### New Features
|
|
8
|
+
|
|
9
|
+
- Add solveit-login command for browser sign-in and `token_file` gateway credential source, rejecting configs with multiple token sources ([#63](https://github.com/AnswerDotAI/clikernel/issues/63))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## 0.2.19
|
|
13
|
+
|
|
14
|
+
### New Features
|
|
15
|
+
|
|
16
|
+
- Use ipymini generic display defaults via module import in Python kernels instead of `enable_full_metadata` ([#62](https://github.com/AnswerDotAI/clikernel/issues/62))
|
|
17
|
+
- Handle SIGTERM in clikernel-mcp by cancelling the serve task so gateway sessions close and autoclose kernels are stopped ([#61](https://github.com/AnswerDotAI/clikernel/issues/61))
|
|
18
|
+
|
|
19
|
+
|
|
5
20
|
## 0.2.18
|
|
6
21
|
|
|
7
22
|
### New Features
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: clikernel
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.20
|
|
4
4
|
Summary: Serve persistent Jupyter kernels to LLMs as concise text, over MCP or a plain stream protocol
|
|
5
5
|
Author: clikernel contributors
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -16,7 +16,7 @@ Requires-Dist: jupyasyncclient>=0.2.10
|
|
|
16
16
|
Requires-Dist: jupywire>=0.1.9
|
|
17
17
|
Requires-Dist: mcpmini>=0.0.5
|
|
18
18
|
Requires-Dist: rustygate>=0.1.27
|
|
19
|
-
Requires-Dist: ipymini>=0.1.
|
|
19
|
+
Requires-Dist: ipymini>=0.1.28
|
|
20
20
|
Requires-Dist: httpx
|
|
21
21
|
Requires-Dist: ipython
|
|
22
22
|
Provides-Extra: dev
|
|
@@ -76,11 +76,12 @@ Two optional files in `$XDG_CONFIG_HOME/clikernel/` configure the router, usuall
|
|
|
76
76
|
|
|
77
77
|
``` toml
|
|
78
78
|
[gateways.solveit]
|
|
79
|
-
url = "https
|
|
80
|
-
|
|
81
|
-
verify = false # optional: accept a self-signed certificate
|
|
79
|
+
url = "https://<instance-host>/rusty"
|
|
80
|
+
token_file = "~/.config/solveit/session"
|
|
82
81
|
```
|
|
83
82
|
|
|
83
|
+
Run `solveit-login` to sign in through your browser and save that session file with mode `0600`. Restart the client after signing in again. Use the instance URL from your browser with `/rusty` appended. For other gateways, choose one of `token`, `token_env` or `token_file`; `verify = false` accepts a self-signed certificate. See [Solveit login](https://AnswerDotAI.github.io/clikernel/login.html) for login options.
|
|
84
|
+
|
|
84
85
|
## The stream protocol
|
|
85
86
|
|
|
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:
|
|
@@ -51,11 +51,12 @@ Two optional files in `$XDG_CONFIG_HOME/clikernel/` configure the router, usuall
|
|
|
51
51
|
|
|
52
52
|
``` toml
|
|
53
53
|
[gateways.solveit]
|
|
54
|
-
url = "https
|
|
55
|
-
|
|
56
|
-
verify = false # optional: accept a self-signed certificate
|
|
54
|
+
url = "https://<instance-host>/rusty"
|
|
55
|
+
token_file = "~/.config/solveit/session"
|
|
57
56
|
```
|
|
58
57
|
|
|
58
|
+
Run `solveit-login` to sign in through your browser and save that session file with mode `0600`. Restart the client after signing in again. Use the instance URL from your browser with `/rusty` appended. For other gateways, choose one of `token`, `token_env` or `token_file`; `verify = false` accepts a self-signed certificate. See [Solveit login](https://AnswerDotAI.github.io/clikernel/login.html) for login options.
|
|
59
|
+
|
|
59
60
|
## The stream protocol
|
|
60
61
|
|
|
61
62
|
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:
|
|
@@ -8,4 +8,4 @@ Modules:
|
|
|
8
8
|
- `clikernel.skill`: Use `clikernel` MCP as the default persistent Python workspace for file/notebook reads and edits, exploration, library checks, data reshaping and debugging. Imports and variables carry across calls. Read before writing, running or debugging Python 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.20"
|
|
@@ -31,6 +31,7 @@ d = { 'settings': { 'branch': 'main',
|
|
|
31
31
|
'clikernel.core.resolve': ('core.html#resolve', 'clikernel/core.py'),
|
|
32
32
|
'clikernel.core.session_defaults': ('core.html#session_defaults', 'clikernel/core.py'),
|
|
33
33
|
'clikernel.core.startup_src': ('core.html#startup_src', 'clikernel/core.py')},
|
|
34
|
+
'clikernel.login': {'clikernel.login.main': ('login.html#main', 'clikernel/login.py')},
|
|
34
35
|
'clikernel.mcp': { 'clikernel.mcp.Router': ('mcp.html#router', 'clikernel/mcp.py'),
|
|
35
36
|
'clikernel.mcp.Router.__init__': ('mcp.html#router.__init__', 'clikernel/mcp.py'),
|
|
36
37
|
'clikernel.mcp.Router.aclose': ('mcp.html#router.aclose', 'clikernel/mcp.py'),
|
|
@@ -31,7 +31,7 @@ def cfg_dir():
|
|
|
31
31
|
return xdg_config_home()/'clikernel'
|
|
32
32
|
|
|
33
33
|
def gateways(cfgdir=None):
|
|
34
|
-
"Read named gateways as `{name: {url, token | token_env, verify}}` from `gateways.toml`."
|
|
34
|
+
"Read named gateways as `{name: {url, token | token_env | token_file, verify}}` from `gateways.toml`."
|
|
35
35
|
p = (Path(cfgdir) if cfgdir else cfg_dir())/'gateways.toml'
|
|
36
36
|
return tomllib.loads(p.read_text()).get('gateways', {}) if p.exists() else {}
|
|
37
37
|
|
|
@@ -42,8 +42,11 @@ def resolve(host='', cfgdir=None):
|
|
|
42
42
|
cfgdir = Path(cfgdir) if cfgdir else cfg_dir()
|
|
43
43
|
g = gateways(cfgdir).get(host)
|
|
44
44
|
if g is None: raise ValueError(f"unknown gateway {host!r}: not a URL, and not in {cfgdir/'gateways.toml'}")
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
if sum(k in g for k in ('token', 'token_env', 'token_file')) > 1:
|
|
46
|
+
raise ValueError(f"gateway {host!r}: choose one of token, token_env or token_file")
|
|
47
|
+
token = g.get('token') or os.environ.get(g.get('token_env', ''))
|
|
48
|
+
if 'token_file' in g: token = Path(g['token_file']).expanduser().read_text().strip()
|
|
49
|
+
return g['url'], token or None, g.get('verify', True)
|
|
47
50
|
|
|
48
51
|
# %% ../nbs/00_core.ipynb #0d846754
|
|
49
52
|
def _with_file(src, path):
|
|
@@ -54,10 +57,9 @@ finally: del __file__'''
|
|
|
54
57
|
|
|
55
58
|
# %% ../nbs/00_core.ipynb #b0dd40c1
|
|
56
59
|
def _python_display(shell):
|
|
57
|
-
"
|
|
60
|
+
"Set display defaults for Python kernels."
|
|
58
61
|
import ast
|
|
59
|
-
|
|
60
|
-
enable_full_metadata(shell.display_formatter)
|
|
62
|
+
import ipymini.term.display # chkstyle: ignore
|
|
61
63
|
run = shell.run_ast_nodes
|
|
62
64
|
async def run_ast_nodes(nodelist, cell_name, interactivity='last_expr', **kwargs):
|
|
63
65
|
if interactivity != 'all': return await run(nodelist, cell_name, interactivity, **kwargs)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""Sign in through a browser and save a Solveit session for gateway clients
|
|
2
|
+
|
|
3
|
+
Docs: https://AnswerDotAI.github.io/clikernel/login.html.md"""
|
|
4
|
+
|
|
5
|
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/03_login.ipynb.
|
|
6
|
+
|
|
7
|
+
# %% auto #0
|
|
8
|
+
__all__ = ['main']
|
|
9
|
+
|
|
10
|
+
# %% ../nbs/03_login.ipynb #357e8981
|
|
11
|
+
import httpx, secrets, time, webbrowser
|
|
12
|
+
from fastcore.utils import *
|
|
13
|
+
from fastcore.xdg import xdg_config_home
|
|
14
|
+
from fastcore.script import call_parse
|
|
15
|
+
|
|
16
|
+
# %% ../nbs/03_login.ipynb #984f0dfe
|
|
17
|
+
@call_parse
|
|
18
|
+
def main(
|
|
19
|
+
server:str='https://solve.it.com', # Solveit login server
|
|
20
|
+
output:Path=None, # Session file; defaults to $XDG_CONFIG_HOME/solveit/session
|
|
21
|
+
):
|
|
22
|
+
"Sign in to Solveit and save a session credential for gateway clients."
|
|
23
|
+
output = output.expanduser() if output else xdg_config_home()/'solveit'/'session'
|
|
24
|
+
paircode = secrets.token_urlsafe(32)
|
|
25
|
+
with httpx.Client(base_url=server.rstrip('/'), headers={'Accept': 'application/json'}) as client:
|
|
26
|
+
r = client.post('/cli_login', data={'paircode': paircode})
|
|
27
|
+
r.raise_for_status()
|
|
28
|
+
print(f'Finish signing in at {r.text}')
|
|
29
|
+
webbrowser.open(r.text)
|
|
30
|
+
deadline = time.monotonic() + 600
|
|
31
|
+
while time.monotonic() < deadline:
|
|
32
|
+
r = client.post('/cli_token', data={'paircode': paircode})
|
|
33
|
+
r.raise_for_status()
|
|
34
|
+
if r.text: break
|
|
35
|
+
time.sleep(1)
|
|
36
|
+
else: raise TimeoutError('Solveit login expired; run solveit-login again')
|
|
37
|
+
token = client.cookies.get('_solveit')
|
|
38
|
+
if not token: raise RuntimeError('Solveit did not return a session cookie')
|
|
39
|
+
with atomic_save(output, mode='w') as f: f.write(token)
|
|
40
|
+
print(f'Saved Solveit session to {output}')
|
|
@@ -6,7 +6,7 @@ Each host has a separate gateway session. Calls without an explicit `host` go to
|
|
|
6
6
|
|
|
7
7
|
Before forwarding `exec`, the router checks the cell against `clikernel.rules`. Most rules add a note to the reply. Two rules block the cell, which then never reaches a gateway.
|
|
8
8
|
|
|
9
|
-
`main`
|
|
9
|
+
`main` closes its gateway sessions on EOF, SIGTERM, or an exception. Closing a session sends an HTTP DELETE. The gateway then stops the kernels that session created with autoclose. If the router started a child gateway, it stops that process too.
|
|
10
10
|
|
|
11
11
|
Docs: https://AnswerDotAI.github.io/clikernel/mcp.html.md"""
|
|
12
12
|
|
|
@@ -16,7 +16,7 @@ Docs: https://AnswerDotAI.github.io/clikernel/mcp.html.md"""
|
|
|
16
16
|
__all__ = ['HOST_PARAM', 'HOSTED', 'Router', 'main', 'agent_input', 'hook']
|
|
17
17
|
|
|
18
18
|
# %% ../nbs/01_mcp.ipynb #28c42902
|
|
19
|
-
import asyncio, httpx, json
|
|
19
|
+
import asyncio, httpx, json, signal
|
|
20
20
|
from fastcore.utils import *
|
|
21
21
|
from fastcore.script import call_parse, store_true
|
|
22
22
|
from mcpmini.core import serve_stdio, jresp, jerr
|
|
@@ -125,6 +125,8 @@ def main(
|
|
|
125
125
|
"Run `clikernel-mcp` as a stdio server."
|
|
126
126
|
async def _main():
|
|
127
127
|
router = Router(cfgdir, quiet=quiet)
|
|
128
|
+
loop,task = asyncio.get_running_loop(),asyncio.current_task()
|
|
129
|
+
signal.signal(signal.SIGTERM, lambda *_: loop.call_soon_threadsafe(task.cancel))
|
|
128
130
|
try: await serve_stdio(router)
|
|
129
131
|
finally: await router.aclose()
|
|
130
132
|
asyncio.run(_main())
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: clikernel
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.20
|
|
4
4
|
Summary: Serve persistent Jupyter kernels to LLMs as concise text, over MCP or a plain stream protocol
|
|
5
5
|
Author: clikernel contributors
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -16,7 +16,7 @@ Requires-Dist: jupyasyncclient>=0.2.10
|
|
|
16
16
|
Requires-Dist: jupywire>=0.1.9
|
|
17
17
|
Requires-Dist: mcpmini>=0.0.5
|
|
18
18
|
Requires-Dist: rustygate>=0.1.27
|
|
19
|
-
Requires-Dist: ipymini>=0.1.
|
|
19
|
+
Requires-Dist: ipymini>=0.1.28
|
|
20
20
|
Requires-Dist: httpx
|
|
21
21
|
Requires-Dist: ipython
|
|
22
22
|
Provides-Extra: dev
|
|
@@ -76,11 +76,12 @@ Two optional files in `$XDG_CONFIG_HOME/clikernel/` configure the router, usuall
|
|
|
76
76
|
|
|
77
77
|
``` toml
|
|
78
78
|
[gateways.solveit]
|
|
79
|
-
url = "https
|
|
80
|
-
|
|
81
|
-
verify = false # optional: accept a self-signed certificate
|
|
79
|
+
url = "https://<instance-host>/rusty"
|
|
80
|
+
token_file = "~/.config/solveit/session"
|
|
82
81
|
```
|
|
83
82
|
|
|
83
|
+
Run `solveit-login` to sign in through your browser and save that session file with mode `0600`. Restart the client after signing in again. Use the instance URL from your browser with `/rusty` appended. For other gateways, choose one of `token`, `token_env` or `token_file`; `verify = false` accepts a self-signed certificate. See [Solveit login](https://AnswerDotAI.github.io/clikernel/login.html) for login options.
|
|
84
|
+
|
|
84
85
|
## The stream protocol
|
|
85
86
|
|
|
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:
|
|
@@ -21,7 +21,7 @@ dependencies = [
|
|
|
21
21
|
"jupywire>=0.1.9",
|
|
22
22
|
"mcpmini>=0.0.5",
|
|
23
23
|
"rustygate>=0.1.27",
|
|
24
|
-
"ipymini>=0.1.
|
|
24
|
+
"ipymini>=0.1.28",
|
|
25
25
|
"httpx",
|
|
26
26
|
"ipython",
|
|
27
27
|
]
|
|
@@ -43,6 +43,7 @@ Documentation = "https://AnswerDotAI.github.io/clikernel/"
|
|
|
43
43
|
clikernel = "clikernel.cli:main"
|
|
44
44
|
clikernel-mcp = "clikernel.mcp:main"
|
|
45
45
|
clikernel-hook = "clikernel.mcp:hook"
|
|
46
|
+
solveit-login = "clikernel.login:main"
|
|
46
47
|
|
|
47
48
|
[project.entry-points.nbdev]
|
|
48
49
|
clikernel = "clikernel._modidx:d"
|
|
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
|