clikernel 0.2.19__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.
Files changed (24) hide show
  1. {clikernel-0.2.19 → clikernel-0.2.20}/CHANGELOG.md +7 -0
  2. {clikernel-0.2.19/clikernel.egg-info → clikernel-0.2.20}/PKG-INFO +5 -4
  3. {clikernel-0.2.19 → clikernel-0.2.20}/README.md +4 -3
  4. {clikernel-0.2.19 → clikernel-0.2.20}/clikernel/__init__.py +1 -1
  5. {clikernel-0.2.19 → clikernel-0.2.20}/clikernel/_modidx.py +1 -0
  6. {clikernel-0.2.19 → clikernel-0.2.20}/clikernel/core.py +6 -3
  7. clikernel-0.2.20/clikernel/login.py +40 -0
  8. {clikernel-0.2.19 → clikernel-0.2.20/clikernel.egg-info}/PKG-INFO +5 -4
  9. {clikernel-0.2.19 → clikernel-0.2.20}/clikernel.egg-info/SOURCES.txt +1 -0
  10. {clikernel-0.2.19 → clikernel-0.2.20}/clikernel.egg-info/entry_points.txt +1 -0
  11. {clikernel-0.2.19 → clikernel-0.2.20}/pyproject.toml +1 -0
  12. {clikernel-0.2.19 → clikernel-0.2.20}/LICENSE +0 -0
  13. {clikernel-0.2.19 → clikernel-0.2.20}/MANIFEST.in +0 -0
  14. {clikernel-0.2.19 → clikernel-0.2.20}/clikernel/cli.py +0 -0
  15. {clikernel-0.2.19 → clikernel-0.2.20}/clikernel/mcp.py +0 -0
  16. {clikernel-0.2.19 → clikernel-0.2.20}/clikernel/rules.py +0 -0
  17. {clikernel-0.2.19 → clikernel-0.2.20}/clikernel/skill.py +0 -0
  18. {clikernel-0.2.19 → clikernel-0.2.20}/clikernel/stream.py +0 -0
  19. {clikernel-0.2.19 → clikernel-0.2.20}/clikernel.egg-info/dependency_links.txt +0 -0
  20. {clikernel-0.2.19 → clikernel-0.2.20}/clikernel.egg-info/requires.txt +0 -0
  21. {clikernel-0.2.19 → clikernel-0.2.20}/clikernel.egg-info/top_level.txt +0 -0
  22. {clikernel-0.2.19 → clikernel-0.2.20}/setup.cfg +0 -0
  23. {clikernel-0.2.19 → clikernel-0.2.20}/tests/test_rules.py +0 -0
  24. {clikernel-0.2.19 → clikernel-0.2.20}/tests/test_stream.py +0 -0
@@ -2,6 +2,13 @@
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
+
5
12
  ## 0.2.19
6
13
 
7
14
  ### New Features
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clikernel
3
- Version: 0.2.19
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
@@ -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://solveit.example.com/gate"
80
- token_env = "SOLVEIT_TOKEN"
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://solveit.example.com/gate"
55
- token_env = "SOLVEIT_TOKEN"
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.19"
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
- return g['url'], g.get('token') or os.environ.get(g.get('token_env','')) or None, g.get('verify', True)
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):
@@ -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}')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clikernel
3
- Version: 0.2.19
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
@@ -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://solveit.example.com/gate"
80
- token_env = "SOLVEIT_TOKEN"
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:
@@ -7,6 +7,7 @@ clikernel/__init__.py
7
7
  clikernel/_modidx.py
8
8
  clikernel/cli.py
9
9
  clikernel/core.py
10
+ clikernel/login.py
10
11
  clikernel/mcp.py
11
12
  clikernel/rules.py
12
13
  clikernel/skill.py
@@ -2,6 +2,7 @@
2
2
  clikernel = clikernel.cli:main
3
3
  clikernel-hook = clikernel.mcp:hook
4
4
  clikernel-mcp = clikernel.mcp:main
5
+ solveit-login = clikernel.login:main
5
6
 
6
7
  [nbdev]
7
8
  clikernel = clikernel._modidx:d
@@ -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