spawnllm 0.17.5__tar.gz → 0.17.7__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 (35) hide show
  1. {spawnllm-0.17.5 → spawnllm-0.17.7}/PKG-INFO +3 -3
  2. {spawnllm-0.17.5 → spawnllm-0.17.7}/README.md +2 -2
  3. {spawnllm-0.17.5 → spawnllm-0.17.7}/pyproject.toml +1 -1
  4. {spawnllm-0.17.5 → spawnllm-0.17.7}/pyproject.toml.orig +1 -1
  5. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/_core/spawnllm_core.wasm +0 -0
  6. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/cli.py +74 -1
  7. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/decide.py +2 -0
  8. {spawnllm-0.17.5 → spawnllm-0.17.7}/LICENSE +0 -0
  9. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/__init__.py +0 -0
  10. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/__main__.py +0 -0
  11. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/_core/__init__.py +0 -0
  12. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/backends/__init__.py +0 -0
  13. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/backends/apple.py +0 -0
  14. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/backends/base.py +0 -0
  15. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/backends/claude.py +0 -0
  16. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/backends/claude_sdk.py +0 -0
  17. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/backends/codex.py +0 -0
  18. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/backends/gemini.py +0 -0
  19. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/backends/mlx.py +0 -0
  20. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/backends/openai_endpoint.py +0 -0
  21. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/backends/registry.py +0 -0
  22. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/call.py +0 -0
  23. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/extract.py +0 -0
  24. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/mlx/__init__.py +0 -0
  25. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/mlx/codec.py +0 -0
  26. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/mlx/engine.py +0 -0
  27. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/mlx/fuse.py +0 -0
  28. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/mlx/patches.py +0 -0
  29. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/proc.py +0 -0
  30. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/py.typed +0 -0
  31. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/response.py +0 -0
  32. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/run.py +0 -0
  33. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/spec.py +0 -0
  34. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/structured.py +0 -0
  35. {spawnllm-0.17.5 → spawnllm-0.17.7}/spawnllm/types.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spawnllm
3
- Version: 0.17.5
3
+ Version: 0.17.7
4
4
  Summary: Delete your subprocess wrappers around claude, codex, and gemini.
5
5
  Keywords:
6
6
  Author: Yasyf Mohamedali
@@ -175,7 +175,7 @@ print(decision.answers["rollback"].p_yes) # 0.99
175
175
  print(decision.answers["action"].choice) # rollback
176
176
  ```
177
177
 
178
- On a warm keep-alive connection from a Mac, a three-question Jev call took 120 to 130 ms end to end. Pass `provider=OPENAI` to ask `gpt-6-luna` instead. Retries cover 408, 429, 5xx, and 529 and stop at `timeout`. Keys come from `TYPESAFE_API_KEY` or `OPENAI_API_KEY`, or on macOS from a Keychain item that `spawnllm key set jev` (or `openai`) writes from stdin.
178
+ On a warm keep-alive connection from a Mac, a three-question Jev call took 120 to 130 ms end to end. Pass `provider=OPENAI` to ask `gpt-6-luna` instead. Retries cover 408, 429, 5xx, and 529 and stop at `timeout`. Keys come from `TYPESAFE_API_KEY` or `OPENAI_API_KEY`, or on macOS from a Keychain item that `spawnllm key set jev` (or `openai`) writes from stdin. Set `TYPESAFE_BASE_URL` to send Jev calls through a gateway such as a Sprites Connector, which supplies the real key in place of a placeholder `TYPESAFE_API_KEY`.
179
179
 
180
180
  ### Call the same backends from Go or Rust
181
181
 
@@ -194,7 +194,7 @@ Both expose `Call`/`call` and typed `Extract`/`extract` against your existing CL
194
194
  - **Decisions** — every question and answer type, the provider pins, and the retry and key-lookup rules — [Deciding reference](https://yasyf.github.io/spawnllm/reference/#deciding)
195
195
  - **Backend selection** — the priority chain, plus `specialty=` routing (`debugging` and `review` go to Codex, `general` to the Claude Agent SDK backend) — [Backends reference](https://yasyf.github.io/spawnllm/reference/#backends)
196
196
  - **Transport helpers** — `run_cli`, `collect_process`, and `map_concurrent`, the subprocess plumbing shared by every CLI backend — [Transport reference](https://yasyf.github.io/spawnllm/reference/#transport)
197
- - **The CLI** — `spawnllm call`, `status`, `backends`, and `key set` from any shell — [CLI reference](https://yasyf.github.io/spawnllm/reference/cli/)
197
+ - **The CLI** — `spawnllm call`, `decide`, `status`, `backends`, and `key set` from any shell — [CLI reference](https://yasyf.github.io/spawnllm/reference/cli/)
198
198
  - **MLX internals** — the adapter codec, fuser, and runtime patches behind the local engine — [MLX reference](https://yasyf.github.io/spawnllm/reference/#mlx)
199
199
 
200
200
  Read the [docs](https://yasyf.github.io/spawnllm/) for the full guide and API reference. Licensed under [MIT](https://github.com/yasyf/spawnllm/blob/main/LICENSE).
@@ -123,7 +123,7 @@ print(decision.answers["rollback"].p_yes) # 0.99
123
123
  print(decision.answers["action"].choice) # rollback
124
124
  ```
125
125
 
126
- On a warm keep-alive connection from a Mac, a three-question Jev call took 120 to 130 ms end to end. Pass `provider=OPENAI` to ask `gpt-6-luna` instead. Retries cover 408, 429, 5xx, and 529 and stop at `timeout`. Keys come from `TYPESAFE_API_KEY` or `OPENAI_API_KEY`, or on macOS from a Keychain item that `spawnllm key set jev` (or `openai`) writes from stdin.
126
+ On a warm keep-alive connection from a Mac, a three-question Jev call took 120 to 130 ms end to end. Pass `provider=OPENAI` to ask `gpt-6-luna` instead. Retries cover 408, 429, 5xx, and 529 and stop at `timeout`. Keys come from `TYPESAFE_API_KEY` or `OPENAI_API_KEY`, or on macOS from a Keychain item that `spawnllm key set jev` (or `openai`) writes from stdin. Set `TYPESAFE_BASE_URL` to send Jev calls through a gateway such as a Sprites Connector, which supplies the real key in place of a placeholder `TYPESAFE_API_KEY`.
127
127
 
128
128
  ### Call the same backends from Go or Rust
129
129
 
@@ -142,7 +142,7 @@ Both expose `Call`/`call` and typed `Extract`/`extract` against your existing CL
142
142
  - **Decisions** — every question and answer type, the provider pins, and the retry and key-lookup rules — [Deciding reference](https://yasyf.github.io/spawnllm/reference/#deciding)
143
143
  - **Backend selection** — the priority chain, plus `specialty=` routing (`debugging` and `review` go to Codex, `general` to the Claude Agent SDK backend) — [Backends reference](https://yasyf.github.io/spawnllm/reference/#backends)
144
144
  - **Transport helpers** — `run_cli`, `collect_process`, and `map_concurrent`, the subprocess plumbing shared by every CLI backend — [Transport reference](https://yasyf.github.io/spawnllm/reference/#transport)
145
- - **The CLI** — `spawnllm call`, `status`, `backends`, and `key set` from any shell — [CLI reference](https://yasyf.github.io/spawnllm/reference/cli/)
145
+ - **The CLI** — `spawnllm call`, `decide`, `status`, `backends`, and `key set` from any shell — [CLI reference](https://yasyf.github.io/spawnllm/reference/cli/)
146
146
  - **MLX internals** — the adapter codec, fuser, and runtime patches behind the local engine — [MLX reference](https://yasyf.github.io/spawnllm/reference/#mlx)
147
147
 
148
148
  Read the [docs](https://yasyf.github.io/spawnllm/) for the full guide and API reference. Licensed under [MIT](https://github.com/yasyf/spawnllm/blob/main/LICENSE).
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "spawnllm"
3
- version = "0.17.5"
3
+ version = "0.17.7"
4
4
  description = "Delete your subprocess wrappers around claude, codex, and gemini."
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "spawnllm"
3
3
  # Inert sentinel: the real version is set from the release tag (uv version --frozen).
4
- version = "0.17.5"
4
+ version = "0.17.7"
5
5
  description = "Delete your subprocess wrappers around claude, codex, and gemini."
6
6
  readme = "README.md"
7
7
  license = "MIT"
@@ -1,7 +1,10 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import dataclasses
4
+ import json
3
5
  import subprocess
4
6
  import sys
7
+ from typing import Any
5
8
 
6
9
  import click
7
10
  from loguru import logger
@@ -15,10 +18,35 @@ from spawnllm.backends import (
15
18
  )
16
19
  from spawnllm.backends.registry import BACKENDS_BY_NAME, PRIORITY, select_backend
17
20
  from spawnllm.call import DEFAULT_MODEL, call_sync
18
- from spawnllm.decide import JEV, OPENAI, Provider, store_key
21
+ from spawnllm.decide import (
22
+ DEFAULT_TIMEOUT,
23
+ JEV,
24
+ OPENAI,
25
+ Answer,
26
+ Binary,
27
+ BinaryAnswer,
28
+ DecideError,
29
+ DecideKeyMissing,
30
+ Label,
31
+ LabelAnswer,
32
+ Provider,
33
+ Question,
34
+ Refused,
35
+ Score,
36
+ ScoreAnswer,
37
+ decide_sync,
38
+ store_key,
39
+ )
19
40
 
20
41
  BACKEND_NAMES = tuple(BACKENDS_BY_NAME)
21
42
  DECIDE_PROVIDERS: dict[str, Provider] = {provider.name: provider for provider in (JEV, OPENAI)}
43
+ QUESTION_TYPES: dict[str, type[Binary | Label | Score]] = {"binary": Binary, "label": Label, "score": Score}
44
+ ANSWER_TYPES: dict[type[Answer], str] = {
45
+ BinaryAnswer: "binary",
46
+ LabelAnswer: "label",
47
+ ScoreAnswer: "score",
48
+ Refused: "refused",
49
+ }
22
50
 
23
51
 
24
52
  @click.group()
@@ -73,6 +101,51 @@ def status() -> None:
73
101
  click.echo(f"core: {(v := _core.version())['core_version']}@{v['source_hash'][:12]}")
74
102
 
75
103
 
104
+ @main.command("decide")
105
+ @click.option("--provider", type=click.Choice(list(DECIDE_PROVIDERS)), default=JEV.name, show_default=True)
106
+ @click.option(
107
+ "--timeout",
108
+ type=float,
109
+ default=DEFAULT_TIMEOUT,
110
+ show_default=True,
111
+ help="Seconds for the whole call, retries included.",
112
+ )
113
+ def decide_questions(provider: str, timeout: float) -> None:
114
+ """Ask the questions a JSON object on stdin holds about its state, and print the answers as JSON.
115
+
116
+ The object holds `state`, the text or JSON to judge, and `questions`, each id mapped to
117
+ `{"binary": {...}}`, `{"label": {...}}` or `{"score": {...}}` holding that question's fields,
118
+ such as `{"label": {"instructions": "...", "options": {"none": "...", "a1": null}}}`. It prints
119
+ `{"model": ..., "answers": {<id>: {"type": "label", "choice": ..., "probabilities": {...}, "confidence": ...}}}`.
120
+ """
121
+ try:
122
+ request = json.loads(sys.stdin.read())
123
+ questions = {id: question(spec) for id, spec in request["questions"].items()}
124
+ decision = decide_sync(request["state"], questions, provider=DECIDE_PROVIDERS[provider], timeout=timeout)
125
+ except (
126
+ json.JSONDecodeError,
127
+ KeyError,
128
+ TypeError,
129
+ ValueError,
130
+ TimeoutError,
131
+ DecideError,
132
+ DecideKeyMissing,
133
+ ) as error:
134
+ raise click.ClickException(str(error)) from error
135
+ answers = {
136
+ id: {"type": ANSWER_TYPES[type(answer)], **dataclasses.asdict(answer)}
137
+ for id, answer in decision.answers.items()
138
+ }
139
+ click.echo(json.dumps({"model": decision.model, "answers": answers}))
140
+
141
+
142
+ def question(spec: dict[str, Any]) -> Question:
143
+ [(kind, fields)] = spec.items()
144
+ if kind not in QUESTION_TYPES:
145
+ raise ValueError(f"unknown question type {kind!r}: use {', '.join(QUESTION_TYPES)}")
146
+ return QUESTION_TYPES[kind](**fields)
147
+
148
+
76
149
  @main.group()
77
150
  def key() -> None:
78
151
  """Manage the decision providers' API keys in the macOS Keychain."""
@@ -47,6 +47,7 @@ TDecideProvider = Literal["jev", "openai"]
47
47
  """A decision provider: TypeSafe's Jev (`jev`) or OpenAI Decisions (`openai`)."""
48
48
 
49
49
  KEY_ENV: dict[TDecideProvider, str] = {"jev": "TYPESAFE_API_KEY", "openai": "OPENAI_API_KEY"}
50
+ JEV_BASE_URL_ENV = "TYPESAFE_BASE_URL"
50
51
  KEY_PATTERN = re.compile(r"[A-Za-z0-9._-]+")
51
52
  DEFAULT_TIMEOUT = 10.0
52
53
 
@@ -356,6 +357,7 @@ class Call:
356
357
  planned = {
357
358
  "provider": {"name": provider.name, "model": provider.model},
358
359
  "api_key": key or api_key(provider, timeout=timeout),
360
+ "base_url": (provider.name == "jev" and os.environ.get(JEV_BASE_URL_ENV)) or None,
359
361
  "state": state,
360
362
  "questions": wired,
361
363
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes