Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

fix(agent): Robot Studio RPC gaps, the ADK rename, and the Windows runtime install (#9066)

Thinh Le1cd96da93443
diff --git a/.github/workflows/agent-sdk-nightly.yml b/.github/workflows/adk-nightly.yml
similarity index 79%
rename from .github/workflows/agent-sdk-nightly.yml
rename to .github/workflows/adk-nightly.yml
index 47c10da24..80e5f3068 100644
--- a/.github/workflows/agent-sdk-nightly.yml
+++ b/.github/workflows/adk-nightly.yml
@@ -1,4 +1,4 @@
-name: Agent SDK Nightly
+name: Jan ADK Nightly
on:
workflow_run:
@@ -8,10 +8,10 @@ on:
workflow_dispatch:
pull_request:
paths:
- - '.github/workflows/agent-sdk-nightly.yml'
- - 'scripts/sdk-nightly/**'
- - 'packages/agent-sdk/**'
- - 'sdk/python/**'
+ - '.github/workflows/adk-nightly.yml'
+ - 'scripts/adk-nightly/**'
+ - 'packages/adk/**'
+ - 'adk/python/**'
- 'protocol/rpc-schema.json'
permissions:
@@ -19,7 +19,7 @@ permissions:
# Only one publisher can advance latest. PR checks do not cancel a release.
concurrency:
- group: sdk-nightly-${{ github.event_name == 'pull_request' && github.event.pull_request.number || 'publish' }}
+ group: adk-nightly-${{ github.event_name == 'pull_request' && github.event.pull_request.number || 'publish' }}
cancel-in-progress: false
jobs:
@@ -41,8 +41,8 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- - name: Validate generated SDK types
- working-directory: packages/agent-sdk
+ - name: Validate generated ADK types
+ working-directory: packages/adk
run: |
npm install --workspaces=false --ignore-scripts
npm run check-types --workspaces=false
@@ -57,16 +57,16 @@ jobs:
echo "ref=$SOURCE_REVISION" >> "$GITHUB_OUTPUT"
echo "build=$SOURCE_REVISION-$GITHUB_RUN_ID.$GITHUB_RUN_ATTEMPT" >> "$GITHUB_OUTPUT"
echo "publish=$TRUSTED" >> "$GITHUB_OUTPUT"
- - name: Package both SDKs and snapshot runtime
+ - name: Package both ADKs and snapshot runtime
env:
SOURCE_REVISION: ${{ steps.metadata.outputs.ref }}
run: >-
- python scripts/sdk-nightly/package.py --output sdk-dist
+ python scripts/adk-nightly/package.py --output adk-dist
--sha "$SOURCE_REVISION" --build "$GITHUB_RUN_ID.$GITHUB_RUN_ATTEMPT"
- uses: actions/upload-artifact@v4
with:
- name: sdk-nightly
- path: sdk-dist/
+ name: adk-nightly
+ path: adk-dist/
if-no-files-found: error
- name: Stage immutable public artifacts
if: steps.metadata.outputs.publish == 'true'
@@ -78,7 +78,7 @@ jobs:
BUCKET: ${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}
BUILD: ${{ steps.metadata.outputs.build }}
run: >-
- aws s3 cp sdk-dist/ "s3://$BUCKET/sdk-nightly/$BUILD/" --recursive
+ aws s3 cp adk-dist/ "s3://$BUCKET/adk-nightly/$BUILD/" --recursive
--cache-control 'public,max-age=31536000,immutable'
smoke:
@@ -102,17 +102,20 @@ jobs:
- uses: actions/download-artifact@v4
if: needs.package.outputs.publish != 'true'
with:
- name: sdk-nightly
- path: sdk-dist
+ name: adk-nightly
+ path: adk-dist
- name: Smoke public downloads against pinned runtime
if: needs.package.outputs.publish == 'true'
env:
BUILD: ${{ needs.package.outputs.build }}
- run: python scripts/sdk-nightly/smoke.py "https://delta.jan.ai/sdk-nightly/$BUILD/manifest.json"
+ run: python scripts/adk-nightly/smoke.py "https://delta.jan.ai/adk-nightly/$BUILD/manifest.json"
shell: bash
+ # The same shell as the publish smoke: on Windows, Git Bash puts GNU tar
+ # ahead of System32 on PATH, and a PR must see what publication will.
- name: Smoke PR artifacts without publication credentials
if: needs.package.outputs.publish != 'true'
- run: python scripts/sdk-nightly/smoke.py sdk-dist/manifest.json --artifacts sdk-dist
+ run: python scripts/adk-nightly/smoke.py adk-dist/manifest.json --artifacts adk-dist
+ shell: bash
promote:
needs: [package, smoke]
@@ -121,8 +124,8 @@ jobs:
steps:
- uses: actions/download-artifact@v4
with:
- name: sdk-nightly
- path: sdk-dist
+ name: adk-nightly
+ path: adk-dist
# All versioned assets are already public and tested. A single object PUT
# switches each discovery document from one complete build to another.
- name: Advance validated nightly discovery
@@ -133,5 +136,5 @@ jobs:
AWS_EC2_METADATA_DISABLED: 'true'
BUCKET: ${{ secrets.DELTA_AWS_S3_BUCKET_NAME }}
run: |
- aws s3 cp sdk-dist/manifest.json "s3://$BUCKET/sdk-nightly/manifest.json" --content-type application/json --cache-control no-cache
- aws s3 cp sdk-dist/index.html "s3://$BUCKET/sdk-nightly/index.html" --content-type text/html --cache-control no-cache
+ aws s3 cp adk-dist/manifest.json "s3://$BUCKET/adk-nightly/manifest.json" --content-type application/json --cache-control no-cache
+ aws s3 cp adk-dist/index.html "s3://$BUCKET/adk-nightly/index.html" --content-type text/html --cache-control no-cache
diff --git a/.github/workflows/rust-check.yml b/.github/workflows/rust-check.yml
index d67f8c77b..71519b70a 100644
--- a/.github/workflows/rust-check.yml
+++ b/.github/workflows/rust-check.yml
@@ -128,13 +128,13 @@ jobs:
cargo test --locked --manifest-path src-tauri/jan-cli/Cargo.toml \
--no-default-features --features cli --test agent_rpc
- # The Agent SDK cookbook's runnable source, run with the runner's own
+ # The ADK cookbook's runnable source, run with the runner's own
# node and python3 against the jan binary this commit builds, plus the
# check that every docs excerpt still matches the file it quotes.
- - name: cargo test (Agent SDK examples)
+ - name: cargo test (ADK examples)
run: |
cargo test --locked --manifest-path src-tauri/jan-cli/Cargo.toml \
- --no-default-features --features cli --test sdk_examples
+ --no-default-features --features cli --test adk_examples
# The deliverable of the schema work is this guard, not the file: a protocol
# shape that changes without regenerating leaves every consumer validating
@@ -234,13 +234,13 @@ jobs:
- name: cargo clippy
run: cargo clippy --manifest-path src-tauri/${{ matrix.crate }}/Cargo.toml --all-targets -- -D warnings
- # The SDKs are clients of the same channel the CLI tests drive, so they are
+ # The ADKs are clients of the same channel the CLI tests drive, so they are
# built and run here rather than in the linter workflow: the subject is a real
# runtime binary, and a client that only agreed with itself would pass. The
# committed wire types are checked against protocol/rpc-schema.json in the
# same job, since that document is what generates them.
- sdk:
- name: agent SDKs
+ adk:
+ name: ADKs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
@@ -250,21 +250,21 @@ jobs:
- uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
- key: sdk
+ key: adk
save-if: ${{ github.ref == 'refs/heads/main' }}
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: '20.x'
- # The runtime the SDKs drive, built the way a user builds it.
+ # The runtime the ADKs drive, built the way a user builds it.
- name: Build the jan runtime
run: |
cargo build --locked --manifest-path src-tauri/jan-cli/Cargo.toml \
--no-default-features --features cli --bin jan
echo "JAN_BIN=$PWD/src-tauri/jan-cli/target/debug/jan" >> "$GITHUB_ENV"
- # For the SDK's own type-check. The suite itself needs no dependency: the
+ # For the ADK's own type-check. The suite itself needs no dependency: the
# package has none, and `node --test` is in the runtime.
- name: Install the workspace
run: |
@@ -272,15 +272,15 @@ jobs:
corepack prepare [email protected] --activate
yarn install --immutable
- - name: Type-check the JavaScript SDK
- run: yarn workspace @janhq/agent-sdk check-types
+ - name: Type-check the JavaScript ADK
+ run: yarn workspace @janhq/adk check-types
- - name: JavaScript SDK suite
- run: yarn workspace @janhq/agent-sdk test
+ - name: JavaScript ADK suite
+ run: yarn workspace @janhq/adk test
# The Python client reaches the runtime without Node, so it runs with a
# PATH that has no node on it: the claim is checked, not stated.
- - name: Python SDK suite
+ - name: Python ADK suite
run: |
env -i PATH="$(dirname "$JAN_BIN"):/usr/bin:/bin" HOME="$HOME" \
- JAN_BIN="$JAN_BIN" python3 -m unittest discover -s sdk/python/tests -t sdk/python
+ JAN_BIN="$JAN_BIN" python3 -m unittest discover -s adk/python/tests -t adk/python
diff --git a/sdk/python/README.md b/adk/python/README.md
similarity index 88%
rename from sdk/python/README.md
rename to adk/python/README.md
index a08932e8a..c6b9e3e9f 100644
--- a/sdk/python/README.md
+++ b/adk/python/README.md
@@ -1,4 +1,4 @@
-# jan-agent-sdk
+# jan-adk
Python client for the Jan agent runtime: sessions, streamed turns, and the host
tools your own process runs. It speaks the JSON-RPC channel of
@@ -13,15 +13,18 @@ process serving many addressable sessions.
## Install
-For a preview without PyPI publication, use the versioned `python -m pip install`
-command on the [nightly SDK download page](https://delta.jan.ai/sdk-nightly/index.html).
-That page becomes available after the first successful **Agent SDK Nightly**
-workflow run. It links a prebuilt wheel; no repository clone or Node is required.
+It is a preview and not on PyPI yet. Install the latest nightly wheel; no
+repository clone or Node is required:
-Keep the build's linked manifest to pin its matching runtime with
+```bash
+python -m pip install "$(python -c "import json, urllib.request as r; p = json.load(r.urlopen('https://delta.jan.ai/adk-nightly/manifest.json'))['packages']['python']; print(p['url'] + '#sha256=' + p['sha256'])")"
+```
+
+The URL is versioned and digest-pinned. That build's manifest also pins its
+matching runtime:
`install_runtime(manifest_url=manifest["runtime"]["manifestUrl"], version=manifest["runtime"]["version"])`.
-See [nightly installation](https://jan.ai/docs/agent/sdk-nightly) for complete
-commands and the source-install fallback before the first nightly is published.
+See [nightly installation](https://jan.ai/docs/agent/adk-nightly) for PowerShell
+and the source-install fallback.
The runtime binary is separate, and there are three ways to have one: on `PATH`,
named by `$JAN_BIN` (the `bin` argument overrides both), or installed by this
@@ -30,7 +33,7 @@ platform, the artifact and its SHA-256, so an install is reproducible rather
than whatever the URL serves today:
```python
-from jan_agent_sdk import JanRuntime, install_runtime
+from jan_adk import JanRuntime, install_runtime
runtime_bin = install_runtime() # downloaded once, then cached
with JanRuntime.start(bin=runtime_bin.bin) as runtime:
@@ -65,7 +68,7 @@ found = find_runtime("0.8.4-50") # reads the cache, no network
```
The nightly channel also publishes a shell installer, which is what the
-[jan.ai SDK pages](https://jan.ai/docs/agent/sdk) use:
+[jan.ai ADK pages](https://jan.ai/docs/agent/adk) use:
```bash
curl -fsSL https://delta.jan.ai/jan-cli/install-jan-agent.sh | bash
@@ -76,7 +79,7 @@ To build your own instead, `make agent` in the Jan repository.
## Quickstart
```python
-from jan_agent_sdk import JanRuntime
+from jan_adk import JanRuntime
with JanRuntime.start() as runtime:
session = runtime.create_session(model="gpt-4o-mini", ephemeral=True)
@@ -102,7 +105,7 @@ A host tool is declared with the schema the model sees, what it does, and the
handler that runs it here:
```python
-from jan_agent_sdk import HostTool, JanRuntime
+from jan_adk import HostTool, JanRuntime
def observe(args, call):
return {"text": "the bench holds a red bin", "images": [frame_path]}
@@ -205,20 +208,20 @@ the cap by being rejected. `JanRpcError` is an answer (`code`, `retryable`), and
`JanRuntimeError` is the channel (spawn failure, protocol mismatch, exit), with
the runtime's own stderr attached.
-Listeners registered with `session.on(...)` run on the SDK's own dispatch
+Listeners registered with `session.on(...)` run on the ADK's own dispatch
thread, in the order the runtime emitted the events, so a listener may call back
into the runtime - answering a permission request from one is the case that
matters - but it must not block for long: the dispatch thread is shared.
## Types
-`jan_agent_sdk/_generated.py` is generated from `protocol/rpc-schema.json` -
+`jan_adk/_generated.py` is generated from `protocol/rpc-schema.json` -
request params, the event union, and the method and event-tag literals - by the
-same generator the JavaScript SDK uses:
+same generator the JavaScript ADK uses:
```bash
-node packages/agent-sdk/scripts/generate.mjs # rewrite both SDKs' types
-node packages/agent-sdk/scripts/generate.mjs --check # fail on drift
+node packages/adk/scripts/generate.mjs # rewrite both ADKs' types
+node packages/adk/scripts/generate.mjs --check # fail on drift
```
The artifact covers request params and events, not responses; the suite pins the
@@ -230,7 +233,7 @@ The suite drives a real runtime against a stub provider on loopback - no
credentials, no network, no Node:
```bash
-JAN_BIN=/path/to/jan python3 -m unittest discover -s sdk/python/tests -t sdk/python
+JAN_BIN=/path/to/jan python3 -m unittest discover -s adk/python/tests -t adk/python
```
It is skipped, not failed, when `JAN_BIN` is unset.
diff --git a/sdk/python/jan_agent_sdk/__init__.py b/adk/python/jan_adk/__init__.py
similarity index 95%
rename from sdk/python/jan_agent_sdk/__init__.py
rename to adk/python/jan_adk/__init__.py
index 45e84bd3c..5084d8aff 100644
--- a/sdk/python/jan_agent_sdk/__init__.py
+++ b/adk/python/jan_adk/__init__.py
@@ -1,9 +1,9 @@
-"""The Jan agent SDK for Python.
+"""The Jan ADK for Python.
One long-lived ``jan cli agent rpc`` runtime, many addressable sessions, and the
host tools your own process runs - with no Node and no third-party packages.
- from jan_agent_sdk import JanRuntime
+ from jan_adk import JanRuntime
with JanRuntime.start() as runtime:
session = runtime.create_session(model="gpt-4o-mini", ephemeral=True)
diff --git a/sdk/python/jan_agent_sdk/_generated.py b/adk/python/jan_adk/_generated.py
similarity index 98%
rename from sdk/python/jan_agent_sdk/_generated.py
rename to adk/python/jan_adk/_generated.py
index 6865fd9d6..e4fdf1137 100644
--- a/sdk/python/jan_agent_sdk/_generated.py
+++ b/adk/python/jan_adk/_generated.py
@@ -1,5 +1,5 @@
-# Generated from protocol/rpc-schema.json by packages/agent-sdk/scripts/generate.mjs.
-# Do not edit by hand: run `node packages/agent-sdk/scripts/generate.mjs` after
+# Generated from protocol/rpc-schema.json by packages/adk/scripts/generate.mjs.
+# Do not edit by hand: run `node packages/adk/scripts/generate.mjs` after
# changing the Rust dispatcher, and commit the regenerated output with it.
from __future__ import annotations
diff --git a/sdk/python/jan_agent_sdk/_queue.py b/adk/python/jan_adk/_queue.py
similarity index 100%
rename from sdk/python/jan_agent_sdk/_queue.py
rename to adk/python/jan_adk/_queue.py
diff --git a/sdk/python/jan_agent_sdk/errors.py b/adk/python/jan_adk/errors.py
similarity index 98%
rename from sdk/python/jan_agent_sdk/errors.py
rename to adk/python/jan_adk/errors.py
index d92692807..7732f51f9 100644
--- a/sdk/python/jan_agent_sdk/errors.py
+++ b/adk/python/jan_adk/errors.py
@@ -1,4 +1,4 @@
-"""Errors the SDK raises.
+"""Errors the ADK raises.
Two kinds, and the difference matters to a caller: an answer from the runtime,
and the channel itself.
diff --git a/sdk/python/jan_agent_sdk/install.py b/adk/python/jan_adk/install.py
similarity index 99%
rename from sdk/python/jan_agent_sdk/install.py
rename to adk/python/jan_adk/install.py
index 0dcc47f08..4ed04a051 100644
--- a/sdk/python/jan_agent_sdk/install.py
+++ b/adk/python/jan_adk/install.py
@@ -65,7 +65,7 @@ class JanInstallError(RuntimeError):
No artifact for this platform, a manifest that does not name what was asked
for, a digest that does not match, or an archive that holds no binary.
- Distinct from :class:`~jan_agent_sdk.JanRuntimeError`, which is a runtime
+ Distinct from :class:`~jan_adk.JanRuntimeError`, which is a runtime
that will not run - this is a runtime that could not be fetched.
"""
diff --git a/sdk/python/jan_agent_sdk/py.typed b/adk/python/jan_adk/py.typed
similarity index 100%
rename from sdk/python/jan_agent_sdk/py.typed
rename to adk/python/jan_adk/py.typed
diff --git a/sdk/python/jan_agent_sdk/runtime.py b/adk/python/jan_adk/runtime.py
similarity index 98%
rename from sdk/python/jan_agent_sdk/runtime.py
rename to adk/python/jan_adk/runtime.py
index 3897a4eff..d10dd9a7a 100644
--- a/sdk/python/jan_agent_sdk/runtime.py
+++ b/adk/python/jan_adk/runtime.py
@@ -24,13 +24,13 @@ try: # The version is for the handshake's clientInfo; a source checkout has no
from importlib.metadata import PackageNotFoundError, version as _package_version
try:
- CLIENT_VERSION = _package_version("jan-agent-sdk")
+ CLIENT_VERSION = _package_version("jan-adk")
except PackageNotFoundError: # pragma: no cover - source checkout
CLIENT_VERSION = "0.0.0+source"
except ImportError: # pragma: no cover - Python < 3.8 has no importlib.metadata
CLIENT_VERSION = "0.0.0+source"
-CLIENT_NAME = "jan-agent-sdk"
+CLIENT_NAME = "jan-adk"
class _Pending:
@@ -90,10 +90,10 @@ class JanRuntime:
self._on_stderr = on_stderr
self._stderr_tail: Deque[str] = deque(maxlen=256)
self._lock = threading.Lock()
- # `queue` here is the standard library's, not `._queue` - the SDK's own
+ # `queue` here is the standard library's, not `._queue` - the ADK's own
# event queue - which is why no module of this package shadows it.
self._dispatch_queue: "queue.Queue[Optional[Any]]" = queue.Queue()
- self._dispatch_thread = threading.Thread(target=self._run_dispatch, name="jan-sdk-events", daemon=True)
+ self._dispatch_thread = threading.Thread(target=self._run_dispatch, name="jan-adk-events", daemon=True)
self._pending: Dict[int, _Pending] = {}
self._next_id = 1
self._sessions: Dict[str, JanSession] = {}
@@ -107,7 +107,7 @@ class JanRuntime:
environment = {
**os.environ,
- # The SDK owns this process and its lifetime; an update check nobody
+ # The ADK owns this process and its lifetime; an update check nobody
# asked for is a network call inside a caller's turn.
"JAN_CLI_NO_UPDATE_CHECK": "1",
**(env or {}),
@@ -383,7 +383,7 @@ class JanRuntime:
try:
self._dispatch(frame)
except Exception as error: # noqa: BLE001 - one bad frame must not stop the reader
- self._fail(JanRuntimeError(f"the SDK could not route a frame: {error}", stderr=self.stderr))
+ self._fail(JanRuntimeError(f"the ADK could not route a frame: {error}", stderr=self.stderr))
return
# EOF: the process is gone or going. Anything still parked has no answer
# coming, which is exactly what the failure below says.
diff --git a/sdk/python/jan_agent_sdk/session.py b/adk/python/jan_adk/session.py
similarity index 99%
rename from sdk/python/jan_agent_sdk/session.py
rename to adk/python/jan_adk/session.py
index ba697cf50..ad5110f3e 100644
--- a/sdk/python/jan_agent_sdk/session.py
+++ b/adk/python/jan_adk/session.py
@@ -158,7 +158,7 @@ class JanSession:
``on("tool_request", fn)`` observes host tool calls, which are
answered from the declaration's handler either way.
- The listener runs on the SDK's own dispatch thread, in the order the
+ The listener runs on the ADK's own dispatch thread, in the order the
runtime emitted the events, so it may call back into the runtime -
answering a permission request from one is the case that matters -
but it shares that thread and must not block for long.
diff --git a/sdk/python/pyproject.toml b/adk/python/pyproject.toml
similarity index 87%
rename from sdk/python/pyproject.toml
rename to adk/python/pyproject.toml
index 7b58f24a2..7d5ad25ba 100644
--- a/sdk/python/pyproject.toml
+++ b/adk/python/pyproject.toml
@@ -3,14 +3,14 @@ requires = ["setuptools>=68"]
build-backend = "setuptools.build_meta"
[project]
-name = "jan-agent-sdk"
+name = "jan-adk"
version = "0.1.0"
description = "Python client for the Jan agent runtime: sessions, streamed turns, and host tools over `jan cli agent rpc`"
readme = "README.md"
requires-python = ">=3.11"
license = { text = "AGPL-3.0" }
authors = [{ name = "Jan", email = "[email protected]" }]
-keywords = ["jan", "agent", "sdk", "json-rpc"]
+keywords = ["jan", "agent", "adk", "json-rpc"]
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
@@ -26,7 +26,7 @@ Homepage = "https://jan.ai"
Repository = "https://github.com/janhq/jan"
[tool.setuptools]
-packages = ["jan_agent_sdk"]
+packages = ["jan_adk"]
[tool.setuptools.package-data]
-jan_agent_sdk = ["py.typed"]
+jan_adk = ["py.typed"]
diff --git a/adk/python/tests/__init__.py b/adk/python/tests/__init__.py
new file mode 100644
index 000000000..8e5d2257e
--- /dev/null
+++ b/adk/python/tests/__init__.py
@@ -0,0 +1 @@
+"""The ADK suite: a stub provider, a scratch home, and a real runtime."""
diff --git a/sdk/python/tests/harness.py b/adk/python/tests/harness.py
similarity index 98%
rename from sdk/python/tests/harness.py
rename to adk/python/tests/harness.py
index 2e51a0082..78be3e6f4 100644
--- a/sdk/python/tests/harness.py
+++ b/adk/python/tests/harness.py
@@ -1,4 +1,4 @@
-"""The harness the SDK suite drives: a stub provider on loopback and a scratch
+"""The harness the ADK suite drives: a stub provider on loopback and a scratch
home, so the tests need no credentials, no network and no Jan Desktop.
The provider is the same shape the Rust CLI tests use: the first request is
@@ -253,7 +253,7 @@ class Scratch:
def __init__(self, bin: str) -> None:
self.bin = bin
- self.root = Path(tempfile.mkdtemp(prefix="jan-sdk-py-"))
+ self.root = Path(tempfile.mkdtemp(prefix="jan-adk-py-"))
self.home = self.root / "home"
self.project = self.root / "project"
self.home.mkdir(parents=True, exist_ok=True)
@@ -285,7 +285,7 @@ class Scratch:
)
def start(self, **options: Any):
- from jan_agent_sdk import JanRuntime
+ from jan_adk import JanRuntime
return JanRuntime.start(bin=self.bin, env=self.env, **options)
diff --git a/sdk/python/tests/test_sdk.py b/adk/python/tests/test_adk.py
similarity index 98%
rename from sdk/python/tests/test_sdk.py
rename to adk/python/tests/test_adk.py
index b9ed2ecbb..e80d00086 100644
--- a/sdk/python/tests/test_sdk.py
+++ b/adk/python/tests/test_adk.py
@@ -1,4 +1,4 @@
-"""The Python SDK, driven end to end against a real runtime.
+"""The Python ADK, driven end to end against a real runtime.
The same conformance cases the JavaScript suite runs, because they are the same
client in a different runtime: the handshake and its caps, a session and its
@@ -23,14 +23,14 @@ from typing import Any, Dict, List
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
-from jan_agent_sdk import PROTOCOL_VERSION, HostTool, JanRpcError, JanRuntime, JanRuntimeError # noqa: E402
+from jan_adk import PROTOCOL_VERSION, HostTool, JanRpcError, JanRuntime, JanRuntimeError # noqa: E402
from tests.harness import Provider, Scratch, holding, prose, streamed, tool_call # noqa: E402
BIN = os.environ.get("JAN_BIN")
[email protected](BIN, "set JAN_BIN to the jan binary to run the SDK suite")
-class SdkTest(unittest.TestCase):
[email protected](BIN, "set JAN_BIN to the jan binary to run the ADK suite")
+class AdkTest(unittest.TestCase):
def setUp(self) -> None:
self.provider: Provider | None = None
self.scratch: Scratch | None = None
@@ -153,7 +153,7 @@ class SdkTest(unittest.TestCase):
# The steer has to be in before the tool's answer goes back: that answer
# ends the window in which the runtime still sees the turn as
# steerable. The handler runs inside that window; a listener does not,
- # because the SDK dispatches listeners asynchronously - a steer from one
+ # because the ADK dispatches listeners asynchronously - a steer from one
# races the answer, which is how this test used to fail on a slow runner.
def observe(_args, _call):
session.steer("also check the left bench")
@@ -466,7 +466,7 @@ class SdkTest(unittest.TestCase):
def _tmp(self) -> str:
import tempfile
- return tempfile.mkdtemp(prefix="jan-sdk-missing-")
+ return tempfile.mkdtemp(prefix="jan-adk-missing-")
if __name__ == "__main__":
diff --git a/sdk/python/tests/test_install.py b/adk/python/tests/test_install.py
similarity index 99%
rename from sdk/python/tests/test_install.py
rename to adk/python/tests/test_install.py
index 2bbfdc40f..74bd115ac 100644
--- a/sdk/python/tests/test_install.py
+++ b/adk/python/tests/test_install.py
@@ -26,7 +26,7 @@ from typing import Any, Dict, List, Optional
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
-from jan_agent_sdk import ( # noqa: E402
+from jan_adk import ( # noqa: E402
MANIFEST_URL,
PLATFORM_KEYS,
JanInstallError,
diff --git a/docs/_redirects b/docs/_redirects
index 3be001b29..6f3155482 100644
--- a/docs/_redirects
+++ b/docs/_redirects
@@ -1,3 +1,24 @@
+# New rules go at the top of this file: the platform stops applying it part way
+# down. Observed 2026-09-25 - in production every rule from /docs/desktop/mac
+# down to the end of the file is inert, while the same line placed above that
+# point serves its redirect. This is not a documented rule, byte or line limit:
+# adding rules here does not displace the ones that work. Repairing the rest of
+# the file is a separate change.
+#
+# Jan ADK: the SDK pages moved under /docs/agent/adk.
+/docs/agent/sdk /docs/agent/adk 302
+/docs/agent/sdk/ /docs/agent/adk/ 302
+/docs/agent/sdk-nightly /docs/agent/adk-nightly 302
+/docs/agent/sdk-nightly/ /docs/agent/adk-nightly/ 302
+/docs/agent/sdk-ts /docs/agent/adk-ts 302
+/docs/agent/sdk-ts/ /docs/agent/adk-ts/ 302
+/docs/agent/sdk-python /docs/agent/adk-python 302
+/docs/agent/sdk-python/ /docs/agent/adk-python/ 302
+/docs/agent/sdk-tools /docs/agent/adk-tools 302
+/docs/agent/sdk-tools/ /docs/agent/adk-tools/ 302
+/docs/agent/sdk-runtime /docs/agent/adk-runtime 302
+/docs/agent/sdk-runtime/ /docs/agent/adk-runtime/ 302
+
/about /handbook 302
/about/ /handbook 302
/about/community /handbook 302
diff --git a/docs/src/pages/docs/agent/_meta.json b/docs/src/pages/docs/agent/_meta.json
index 8e1e0f646..08f6b6cdf 100644
--- a/docs/src/pages/docs/agent/_meta.json
+++ b/docs/src/pages/docs/agent/_meta.json
@@ -26,12 +26,12 @@
"hooks": "Hooks",
"mcp": "MCP",
"embedding-separator": { "title": "Embedding", "type": "separator" },
- "sdk": "Agent SDK",
- "sdk-nightly": "Nightly SDK Installation",
- "sdk-ts": "JavaScript Quickstart",
- "sdk-python": "Python Quickstart",
- "sdk-tools": "Host Tools",
- "sdk-runtime": "Process & Failures",
+ "adk": "Jan ADK",
+ "adk-nightly": "Nightly ADK Installation",
+ "adk-ts": "JavaScript Quickstart",
+ "adk-python": "Python Quickstart",
+ "adk-tools": "Host Tools",
+ "adk-runtime": "Process & Failures",
"protocol": "Protocol Records",
"reference-separator": { "title": "Reference", "type": "separator" },
"cli": "CLI"
diff --git a/docs/src/pages/docs/agent/sdk-nightly.mdx b/docs/src/pages/docs/agent/adk-nightly.mdx
similarity index 52%
rename from docs/src/pages/docs/agent/sdk-nightly.mdx
rename to docs/src/pages/docs/agent/adk-nightly.mdx
index f2fd10ec2..1fc3e181c 100644
--- a/docs/src/pages/docs/agent/sdk-nightly.mdx
+++ b/docs/src/pages/docs/agent/adk-nightly.mdx
@@ -1,42 +1,78 @@
---
-title: Nightly SDK Installation
-description: Install prebuilt JavaScript and Python SDK previews without npm or PyPI publication, a repository clone, or a Rust build.
+title: Nightly ADK Installation
+description: Install prebuilt JavaScript and Python ADK previews without npm or PyPI publication, a repository clone, or a Rust build.
---
import { Callout, Tabs } from 'nextra/components'
-# Nightly SDK Installation
+# Nightly ADK Installation
-**Install a packaged SDK preview, then explicitly install its matching runtime.**
-The SDK is your language client; the `jan` runtime is the separate executable
-that runs the agent. Neither needs Jan Desktop or a Rust compiler.
+**Install a packaged ADK preview, then its runtime.**
+The ADK is your language client; the `jan` runtime is the separate executable
+that runs the agent. Neither needs Jan Desktop, a Git checkout or a Rust compiler.
<Callout type="warning">
-Nightly artifacts become available after the first successful **Agent SDK Nightly**
-workflow run. If the download page returns 404, no nightly has been published yet;
-use the source-install fallback below. These are previews, not npm/PyPI releases.
+These are previews, not npm/PyPI releases. If a download below fails (HTTP 403 or 404), that
+build is not available; use the [source-install fallback](#source-install-fallback).
</Callout>
-## Install the SDK
+## Install the ADK
-Open the [nightly download page](https://delta.jan.ai/sdk-nightly/index.html).
-Copy the **versioned installation command** for your language into a new project:
+Each command looks up the latest validated build and installs its versioned package URL, so
+your dependency file pins that exact build.
-- **JavaScript:** Node.js 20+ and npm. The command installs a `.tgz` URL directly.
-- **Python:** Python 3.11+ in a virtual environment. The command installs a wheel
- URL directly, with its SHA-256 fragment. Node is not required.
+<Tabs items={['JavaScript', 'Python']}>
+<Tabs.Tab>
+
+Node.js 20+ and npm:
+
+```bash
+npm install "$(node -e "fetch('https://delta.jan.ai/adk-nightly/manifest.json').then(r => r.json()).then(m => console.log(m.packages.javascript.url))")"
+```
+
+In PowerShell, replace `"$(...)"` with `(...)`.
+
+</Tabs.Tab>
+<Tabs.Tab>
+
+Python 3.11+, in a virtual environment. Node is not required:
+
+```bash
+python -m pip install "$(python -c "import json, urllib.request as r; p = json.load(r.urlopen('https://delta.jan.ai/adk-nightly/manifest.json'))['packages']['python']; print(p['url'] + '#sha256=' + p['sha256'])")"
+```
+
+In PowerShell, replace `"$(...)"` with `(...)`. The `#sha256=` fragment makes pip check the
+wheel against the digest the build published.
+
+</Tabs.Tab>
+</Tabs>
+
+Prefer to copy a fixed URL? The [download page](https://delta.jan.ai/adk-nightly/index.html)
+shows the same commands with the current build's URLs written out.
+
+For repeatable installs, save that build's **versioned manifest**
+(`https://delta.jan.ai/adk-nightly/<build>/manifest.json`, linked from the download page)
+alongside your lockfile. It identifies the package versions, source revision, digests, protocol
+version and compatible runtime. Use it rather than the moving latest manifest.
+
+## Install the runtime
+
+For a first run, the hosted installer puts the latest nightly `jan` on your PATH, which also gives
+you `jan login`:
+
+```bash
+curl -fsSL https://delta.jan.ai/jan-cli/install-jan-agent.sh | bash # macOS / Linux
+irm https://delta.jan.ai/jan-cli/install-jan-agent.ps1 | iex # Windows PowerShell
+```
-No GitHub login or repository clone is needed. Save the page's **versioned
-manifest** link alongside your dependency lockfile. It identifies the package
-versions, source revision, digests, protocol version and compatible runtime.
-Use the versioned link for repeatable installs, not the moving latest manifest.
+`JanRuntime.start()` finds `jan` on PATH, or the binary named by `JAN_BIN`.
-## Start the matching runtime
+### Pin the runtime your ADK build was tested with
-Download that build's versioned manifest as `sdk-nightly.json` in your project.
-These snippets use the existing SDK runtime installer; package installation itself
-does not download or launch a runtime. Configure your provider as described in the
-[Agent quickstart](/docs/agent/quickstart) before asking the agent to do work.
+Each ADK build records the runtime it was smoke-tested against. To install exactly that one,
+download the build's versioned manifest as `adk-nightly.json` and pass its runtime pin to the ADK
+installer, which downloads, verifies and caches the binary. Configure your provider as described
+in the [Agent quickstart](/docs/agent/quickstart) before asking the agent to do work.
<Tabs items={['JavaScript', 'Python']}>
<Tabs.Tab>
@@ -45,9 +81,9 @@ Save as `runtime.mjs`, then run `node runtime.mjs`:
```js
import { readFile } from 'node:fs/promises'
-import { JanRuntime, installRuntime } from '@janhq/agent-sdk'
+import { JanRuntime, installRuntime } from '@janhq/adk'
-const manifest = JSON.parse(await readFile('sdk-nightly.json', 'utf8'))
+const manifest = JSON.parse(await readFile('adk-nightly.json', 'utf8'))
const installed = await installRuntime({
manifestUrl: manifest.runtime.manifestUrl,
version: manifest.runtime.version,
@@ -68,9 +104,9 @@ Save as `runtime.py`, then run `python runtime.py`:
```python
import json
from pathlib import Path
-from jan_agent_sdk import JanRuntime, install_runtime
+from jan_adk import JanRuntime, install_runtime
-manifest = json.loads(Path('sdk-nightly.json').read_text())
+manifest = json.loads(Path('adk-nightly.json').read_text())
installed = install_runtime(
manifest_url=manifest['runtime']['manifestUrl'],
version=manifest['runtime']['version'],
@@ -84,7 +120,7 @@ with JanRuntime.start(bin=installed.bin) as runtime:
Expect the runtime's reported name and version, followed by a clean exit. A runtime's
reported version can differ from its nightly artifact version; the manifest pins the
-artifact, while the SDK checks the wire protocol before starting work.
+artifact, while the ADK checks the wire protocol before starting work.
An already provisioned compatible runtime can be passed directly as `bin`, or selected
with `JAN_BIN`. For an offline launch, skip `installRuntime` / `install_runtime` and
@@ -94,17 +130,17 @@ artifact has gone missing.
## Supported nightly platforms
The publication gate exercises Linux x64 and ARM64, macOS Intel and Apple Silicon,
-and Windows x64. Windows ARM64 is not claimed by this SDK nightly matrix, even when
+and Windows x64. Windows ARM64 is not claimed by this ADK nightly matrix, even when
the runtime channel offers an ARM64 binary.
-Each job installs the packaged SDKs into clean environments, downloads the pinned
+Each job installs the packaged ADKs into clean environments, downloads the pinned
runtime, streams a turn, executes a host callback, checks that its answer reaches a
loopback provider, and verifies runtime shutdown. Python runs without Node on `PATH`.
This is a real-runtime packaging check, not evidence of a live model-provider run.
## Versions, integrity and failures
-- The latest [manifest](https://delta.jan.ai/sdk-nightly/manifest.json) and download
+- The latest [manifest](https://delta.jan.ai/adk-nightly/manifest.json) and download
page each point to one complete, validated build. An unsuccessful build or smoke
run does not promote either pointer.
- Versioned directories include the source revision and CI run/attempt. The workflow
@@ -127,17 +163,17 @@ Until a nightly is published, clone Jan once and install only your language pack
git clone --depth 1 https://github.com/janhq/jan.git jan-source
```
-For JavaScript, run `npm install ./jan-source/packages/agent-sdk` in your project.
-For Python, run `python -m pip install ./jan-source/sdk/python` in a virtual environment.
+For JavaScript, run `npm install ./jan-source/packages/adk` in your project.
+For Python, run `python -m pip install ./jan-source/adk/python` in a virtual environment.
This fallback needs Git and a source checkout; it still needs no Jan Desktop or Rust
-build. Install the runtime explicitly with the SDK installer as described in the
+build. Install the runtime explicitly with the ADK installer as described in the
package README.
## Publishing and recovery
-Maintainers can run **Agent SDK Nightly** manually from `main`; it also runs after a
+Maintainers can run **Jan ADK Nightly** manually from `main`; it also runs after a
successful **Jan Agent CLI - Nightly Build**. It snapshots the current published
-runtime manifest, rather than assuming an SDK package version is a runtime version.
+runtime manifest, rather than assuming an ADK package version is a runtime version.
The workflow packages both clients, uploads immutable versioned assets, runs the
platform smoke matrix against the public downloads, then advances discovery. PRs
diff --git a/docs/src/pages/docs/agent/sdk-python.mdx b/docs/src/pages/docs/agent/adk-python.mdx
similarity index 62%
rename from docs/src/pages/docs/agent/sdk-python.mdx
rename to docs/src/pages/docs/agent/adk-python.mdx
index 62d309b03..b6e463e3b 100644
--- a/docs/src/pages/docs/agent/sdk-python.mdx
+++ b/docs/src/pages/docs/agent/adk-python.mdx
@@ -1,7 +1,7 @@
---
title: Python Quickstart
-description: Install the preview SDK, connect a model, and stream your first Jan Agent response from Python.
-keywords: [Jan, Jan Agent, SDK, Python, quickstart, embedding]
+description: Install the preview ADK, connect a model, and stream your first Jan Agent response from Python.
+keywords: [Jan, Jan Agent, ADK, Python, quickstart, embedding]
---
import { Callout, Steps, Tabs } from 'nextra/components'
@@ -10,53 +10,49 @@ import { Callout, Steps, Tabs } from 'nextra/components'
**Run a script that asks Jan a question and prints its answer as it arrives.**
-You need **Python 3.11+**, **Git**, and access to a model provider. No Node.js, Jan Desktop or Rust
-toolchain is needed. Python talks directly to the Jan runtime.
+You need **Python 3.11+** and access to a model provider. No Git checkout, Node.js, Jan Desktop or
+Rust toolchain is needed. Python talks directly to the Jan runtime.
<Callout type="warning">
-The SDK is a preview and is not published to PyPI yet. Install the source package below, not
-`pip install jan-agent-sdk`. The runtime is a separate, prebuilt download.
+The ADK is a preview and is not published to PyPI yet: `pip install jan-adk` does not work.
+Install the nightly wheel below instead. The runtime is a separate, prebuilt download.
</Callout>
<Steps>
-### Install the SDK and runtime
+### Install the ADK and runtime
-Create a demo directory and an isolated Python environment:
-
-```bash
-mkdir jan-python-demo
-cd jan-python-demo
-```
+Create a demo directory and an isolated Python environment, then install the latest nightly wheel:
<Tabs items={['macOS / Linux', 'Windows PowerShell']}>
<Tabs.Tab>
```bash
+mkdir jan-python-demo && cd jan-python-demo
python3 -m venv .venv
source .venv/bin/activate
+python -m pip install "$(python -c "import json, urllib.request as r; p = json.load(r.urlopen('https://delta.jan.ai/adk-nightly/manifest.json'))['packages']['python']; print(p['url'] + '#sha256=' + p['sha256'])")"
```
</Tabs.Tab>
<Tabs.Tab>
```powershell
+mkdir jan-python-demo; cd jan-python-demo
py -3 -m venv .venv
.venv\Scripts\Activate.ps1
+python -m pip install (python -c "import json, urllib.request as r; p = json.load(r.urlopen('https://delta.jan.ai/adk-nightly/manifest.json'))['packages']['python']; print(p['url'] + '#sha256=' + p['sha256'])")
```
</Tabs.Tab>
</Tabs>
-```bash
-git clone --depth 1 https://github.com/janhq/jan.git jan-source
-python -m pip install ./jan-source/sdk/python
-```
-
-Only the SDK package is installed. You do not need to install or build the rest of the repository.
+The command looks up the current build and installs its versioned wheel, checked against the
+SHA-256 the build published. The [download page](https://delta.jan.ai/adk-nightly/index.html) shows
+the same command with the URL written out.
Install the `jan` runtime:
<Tabs items={['macOS / Linux', 'Windows PowerShell']}>
<Tabs.Tab>
```bash
-bash jan-source/scripts/install-jan-agent.sh
+curl -fsSL https://delta.jan.ai/jan-cli/install-jan-agent.sh | bash
export PATH="$HOME/.local/bin:$PATH"
```
</Tabs.Tab>
@@ -82,7 +78,7 @@ Sign in to Tokamak:
jan login
```
-Or [configure your own provider](/docs/agent/quickstart#connect-a-provider). Both the CLI and SDK
+Or [configure your own provider](/docs/agent/quickstart#connect-a-provider). Both the CLI and ADK
use Jan's provider configuration. If you have already configured Jan, skip this step.
### Save and run the script
@@ -90,7 +86,7 @@ use Jan's provider configuration. If you have already configured Jan, skip this
Save this complete example as `hello.py` in `jan-python-demo`:
```python filename="hello.py"
-from jan_agent_sdk import JanRuntime
+from jan_adk import JanRuntime
with JanRuntime.start() as runtime:
session = runtime.create_session(ephemeral=True, builtins=False)
@@ -128,20 +124,21 @@ Send another prompt on the same `session` to continue the conversation. To selec
configured model, add `model="provider/model-id"` to `create_session()`.
The Python API is synchronous: iterating a turn waits for events. In an async application, run
-blocking SDK work in a worker thread rather than on your event loop.
+blocking ADK work in a worker thread rather than on your event loop.
## If it fails
| Problem | What to do |
| --- | --- |
-| `ModuleNotFoundError: jan_agent_sdk` | Activate the demo's virtual environment and run the local `pip install` above with that Python. |
+| `ModuleNotFoundError: jan_adk` | Activate the demo's virtual environment and run the `pip install` command above with that Python. |
+| The wheel download fails | No nightly is available right now. Use the [source install](/docs/agent/adk-nightly#source-install-fallback). |
| Cannot start `jan` | Add it to PATH, or pass its absolute path as `JanRuntime.start(bin="/path/to/jan")`. |
| Unknown `rpc` command or protocol mismatch | Run `jan update`, then retry startup. |
| No model, authentication error, or provider error | Run `jan login` or fix the provider configuration. A model override must name a model that provider serves. |
-See [Process & failures](/docs/agent/sdk-runtime) for error handling in an application.
+See [Process & failures](/docs/agent/adk-runtime) for error handling in an application.
## Next: give the agent a function
-The first script cannot act on your app. Add a [host tool](/docs/agent/sdk-tools) when you want it
+The first script cannot act on your app. Add a [host tool](/docs/agent/adk-tools) when you want it
to read application data or perform an action.
diff --git a/docs/src/pages/docs/agent/sdk-runtime.mdx b/docs/src/pages/docs/agent/adk-runtime.mdx
similarity index 88%
rename from docs/src/pages/docs/agent/sdk-runtime.mdx
rename to docs/src/pages/docs/agent/adk-runtime.mdx
index 707bb0edc..903c1eddd 100644
--- a/docs/src/pages/docs/agent/sdk-runtime.mdx
+++ b/docs/src/pages/docs/agent/adk-runtime.mdx
@@ -1,7 +1,7 @@
---
title: Process & Failures
description: "Keep control of an embedded Jan runtime: close it, interrupt work, answer permissions, and handle failures without repeating side effects."
-keywords: [Jan, Jan Agent, SDK, process, permissions, errors, cancellation]
+keywords: [Jan, Jan Agent, ADK, process, permissions, errors, cancellation]
---
import { Tabs } from 'nextra/components'
@@ -18,13 +18,16 @@ conversations, a Stop button, tool approval, or recovery from a failure.
- Start one runtime for your app's work, rather than one process per message.
- Reuse a session to keep conversation history. Create another session for a separate conversation.
- Wait for a turn to finish before starting another. One runtime runs one active turn at a time.
-- Use `ephemeral: true` / `ephemeral=True` when the conversation should not be saved.
+- Use `ephemeral: true` / `ephemeral=True` when the conversation should not be saved. Its answers
+ are also kept out of automatic memory recall, so one session's answers never reach a later
+ session in the same `cwd`. [Memory notes](/docs/agent/memory) written with `memory_write` in
+ other sessions are still listed in its prompt.
Always arrange cleanup, including on errors. In JavaScript, put `await runtime.close()` in a
`finally` block. In Python, use `with JanRuntime.start() as runtime:`. The
-[JavaScript](/docs/agent/sdk-ts) and [Python](/docs/agent/sdk-python) quickstarts show both patterns.
+[JavaScript](/docs/agent/adk-ts) and [Python](/docs/agent/adk-python) quickstarts show both patterns.
-The SDK closes the channel and reaps its child process, escalating when the process does not exit.
+The ADK closes the channel and reaps its child process, escalating when the process does not exit.
It does not attach to an existing process just because you know a session id.
## Stop a turn, not the whole app
@@ -38,7 +41,7 @@ from your application's Stop action. Keep consuming the turn and read its result
| `interrupted` | Work was stopped. Earlier tool side effects remain. |
| `error` | The turn failed. Read the result's `error` message. |
-These are **RPC SDK** statuses: JavaScript uses `result.stopReason`; Python uses
+These are **RPC ADK** statuses: JavaScript uses `result.stopReason`; Python uses
`result.stop_reason`. They are not the `stream-json` CLI's exit codes or `stop_reason` values.
Closing the runtime ends all work owned by that process. Use forced close only when necessary:
@@ -101,12 +104,12 @@ answer does not prove an action never ran.
## Download a runtime from code
-For deployments that do not put `jan` on PATH, the SDK can install the nightly runtime itself:
+For deployments that do not put `jan` on PATH, the ADK can install the nightly runtime itself:
<Tabs items={['JavaScript', 'Python']}>
<Tabs.Tab>
```js
-import { installRuntime, JanRuntime } from '@janhq/agent-sdk'
+import { installRuntime, JanRuntime } from '@janhq/adk'
const installed = await installRuntime()
const runtime = await JanRuntime.start({ bin: installed.bin })
@@ -119,7 +122,7 @@ try {
</Tabs.Tab>
<Tabs.Tab>
```python
-from jan_agent_sdk import install_runtime, JanRuntime
+from jan_adk import install_runtime, JanRuntime
installed = install_runtime()
with JanRuntime.start(bin=installed.bin) as runtime:
@@ -140,7 +143,7 @@ service. A matching pinned cache entry can be reused without network access.
## Working directly with the CLI?
-The SDK uses a long-lived `jan cli agent rpc` process. A direct
+The ADK uses a long-lived `jan cli agent rpc` process. A direct
`jan cli agent run --output-format stream-json` integration is different: one run ends with a
`result` record and a process exit. Do not mix its messages or status names with RPC.
diff --git a/docs/src/pages/docs/agent/sdk-tools.mdx b/docs/src/pages/docs/agent/adk-tools.mdx
similarity index 91%
rename from docs/src/pages/docs/agent/sdk-tools.mdx
rename to docs/src/pages/docs/agent/adk-tools.mdx
index 005615f99..372e4987d 100644
--- a/docs/src/pages/docs/agent/sdk-tools.mdx
+++ b/docs/src/pages/docs/agent/adk-tools.mdx
@@ -1,7 +1,7 @@
---
title: Host Tools
description: Give the agent a function in your app. Declare what it does, run the callback, and return a result.
-keywords: [Jan, Jan Agent, SDK, host tools, function calling, JavaScript, Python]
+keywords: [Jan, Jan Agent, ADK, host tools, function calling, JavaScript, Python]
---
import { Tabs } from 'nextra/components'
@@ -10,15 +10,15 @@ import { Tabs } from 'nextra/components'
**A host tool is a function in your app that the agent can ask to run.**
-The model chooses a tool and supplies arguments. The SDK calls your handler. Your handler's result
+The model chooses a tool and supplies arguments. The ADK calls your handler. Your handler's result
goes back to the model, which can use it to answer or choose another action.
```text
Model asks for get_time -> your handler reads the clock -> model receives the time
```
-First complete the [JavaScript](/docs/agent/sdk-ts) or [Python](/docs/agent/sdk-python) quickstart.
-These examples use the same installed SDK and provider configuration.
+First complete the [JavaScript](/docs/agent/adk-ts) or [Python](/docs/agent/adk-python) quickstart.
+These examples use the same installed ADK and provider configuration.
## Add one real function
@@ -28,7 +28,7 @@ Save the example in your quickstart directory and run it with `node clock.mjs` o
<Tabs items={['JavaScript', 'Python']}>
<Tabs.Tab>
```js filename="clock.mjs"
-import { JanRuntime } from '@janhq/agent-sdk'
+import { JanRuntime } from '@janhq/adk'
const runtime = await JanRuntime.start()
try {
@@ -59,7 +59,7 @@ try {
<Tabs.Tab>
```python filename="clock.py"
from datetime import datetime, timezone
-from jan_agent_sdk import HostTool, JanRuntime
+from jan_adk import HostTool, JanRuntime
def get_time(args, call):
@@ -92,7 +92,7 @@ with JanRuntime.start() as runtime:
</Tabs>
The model receives the tool description and argument schema, **not your handler's source code**.
-It asks to call the tool; the SDK runs the handler in your process. No manual JSON messages are needed.
+It asks to call the tool; the ADK runs the handler in your process. No manual JSON messages are needed.
## What a tool needs
@@ -133,7 +133,7 @@ For image tools, use a vision-capable model and check `runtime.limits`. See
A `read` tool such as the clock is not prompted. For an `actuator`:
- **Jan owns approval by default.** Your app must handle `permission_request` events and answer
- them. Otherwise the turn waits. See [permission prompts](/docs/agent/sdk-runtime#answer-permission-prompts).
+ them. Otherwise the turn waits. See [permission prompts](/docs/agent/adk-runtime#answer-permission-prompts).
- **Your app can own approval** with `permissions: 'host'` in JavaScript or `permissions="host"`
in Python. Jan will not ask for approval of host tools; your handler must enforce the policy.
@@ -151,6 +151,6 @@ that has already happened is not undone.
## Next
-[Process & failures](/docs/agent/sdk-runtime) covers stopping turns, permissions, shutdown and
+[Process & failures](/docs/agent/adk-runtime) covers stopping turns, permissions, shutdown and
retries. [Protocol records](/docs/agent/protocol#rpc-host-tools) is the lower-level reference if
you are implementing your own client.
diff --git a/docs/src/pages/docs/agent/sdk-ts.mdx b/docs/src/pages/docs/agent/adk-ts.mdx
similarity index 63%
rename from docs/src/pages/docs/agent/sdk-ts.mdx
rename to docs/src/pages/docs/agent/adk-ts.mdx
index 35f4c516f..448928072 100644
--- a/docs/src/pages/docs/agent/sdk-ts.mdx
+++ b/docs/src/pages/docs/agent/adk-ts.mdx
@@ -1,7 +1,7 @@
---
title: JavaScript Quickstart
-description: Install the preview SDK, connect a model, and stream your first Jan Agent response from Node.js.
-keywords: [Jan, Jan Agent, SDK, JavaScript, TypeScript, Node.js, quickstart]
+description: Install the preview ADK, connect a model, and stream your first Jan Agent response from Node.js.
+keywords: [Jan, Jan Agent, ADK, JavaScript, TypeScript, Node.js, quickstart]
---
import { Callout, Steps, Tabs } from 'nextra/components'
@@ -10,36 +10,47 @@ import { Callout, Steps, Tabs } from 'nextra/components'
**Run a script that asks Jan a question and prints its answer as it arrives.**
-You need **Node.js 20+**, **Git**, and access to a model provider. No Jan Desktop, Rust toolchain,
-or TypeScript build step is needed.
+You need **Node.js 20+** and access to a model provider. No Git checkout, Jan Desktop, Rust
+toolchain or TypeScript build step is needed.
<Callout type="warning">
-The SDK is a preview and is not published to npm yet. Install the source package below, not
-`npm install @janhq/agent-sdk`. The runtime is a separate, prebuilt download.
+The ADK is a preview and is not published to npm yet: `npm install @janhq/adk` does not work.
+Install the nightly package below instead. The runtime is a separate, prebuilt download.
</Callout>
<Steps>
-### Install the SDK and runtime
+### Install the ADK and runtime
-In a new directory:
+In a new directory, install the latest nightly ADK package:
+<Tabs items={['macOS / Linux', 'Windows PowerShell']}>
+ <Tabs.Tab>
```bash
-mkdir jan-js-demo
-cd jan-js-demo
+mkdir jan-js-demo && cd jan-js-demo
npm init -y
-git clone --depth 1 https://github.com/janhq/jan.git jan-source
-npm install ./jan-source/packages/agent-sdk
+npm install "$(node -e "fetch('https://delta.jan.ai/adk-nightly/manifest.json').then(r => r.json()).then(m => console.log(m.packages.javascript.url))")"
```
+ </Tabs.Tab>
+ <Tabs.Tab>
+```powershell
+mkdir jan-js-demo; cd jan-js-demo
+npm init -y
+npm install (node -e "fetch('https://delta.jan.ai/adk-nightly/manifest.json').then(r => r.json()).then(m => console.log(m.packages.javascript.url))")
+```
+ </Tabs.Tab>
+</Tabs>
-Only the SDK package is installed. You do not need to install or build the rest of the repository.
+The command looks up the current build and installs its versioned package URL, so
+`package.json` pins that exact build. The [download page](https://delta.jan.ai/adk-nightly/index.html)
+shows the same command with the URL written out.
Install the `jan` runtime:
<Tabs items={['macOS / Linux', 'Windows PowerShell']}>
<Tabs.Tab>
```bash
-bash jan-source/scripts/install-jan-agent.sh
+curl -fsSL https://delta.jan.ai/jan-cli/install-jan-agent.sh | bash
export PATH="$HOME/.local/bin:$PATH"
```
</Tabs.Tab>
@@ -65,7 +76,7 @@ Sign in to Tokamak:
jan login
```
-Or [configure your own provider](/docs/agent/quickstart#connect-a-provider). Both the CLI and SDK
+Or [configure your own provider](/docs/agent/quickstart#connect-a-provider). Both the CLI and ADK
use Jan's provider configuration. If you have already configured Jan, skip this step.
### Save and run the script
@@ -73,7 +84,7 @@ use Jan's provider configuration. If you have already configured Jan, skip this
Save this complete example as `hello.mjs` in `jan-js-demo`:
```js filename="hello.mjs"
-import { JanRuntime } from '@janhq/agent-sdk'
+import { JanRuntime } from '@janhq/adk'
const runtime = await JanRuntime.start()
try {
@@ -118,14 +129,15 @@ TypeScript uses the same API; the installed package includes type declarations.
| Problem | What to do |
| --- | --- |
-| Cannot find `@janhq/agent-sdk` | Run the local `npm install` above and keep `hello.mjs` in the demo directory. |
+| Cannot find `@janhq/adk` | Run the `npm install` command above in `jan-js-demo`, and keep `hello.mjs` there. |
+| The package download fails | No nightly is available right now. Use the [source install](/docs/agent/adk-nightly#source-install-fallback). |
| Cannot start `jan` | Add it to PATH, or pass its absolute path as `JanRuntime.start({ bin: '/path/to/jan' })`. |
| Unknown `rpc` command or protocol mismatch | Run `jan update`, then retry startup. |
| No model, authentication error, or provider error | Run `jan login` or fix the provider configuration. A model override must name a model that provider serves. |
-See [Process & failures](/docs/agent/sdk-runtime) for error handling in an application.
+See [Process & failures](/docs/agent/adk-runtime) for error handling in an application.
## Next: give the agent a function
-The first script cannot act on your app. Add a [host tool](/docs/agent/sdk-tools) when you want it
+The first script cannot act on your app. Add a [host tool](/docs/agent/adk-tools) when you want it
to read application data or perform an action.
diff --git a/docs/src/pages/docs/agent/sdk.mdx b/docs/src/pages/docs/agent/adk.mdx
similarity index 78%
rename from docs/src/pages/docs/agent/sdk.mdx
rename to docs/src/pages/docs/agent/adk.mdx
index f40e5404f..6812c7e7c 100644
--- a/docs/src/pages/docs/agent/sdk.mdx
+++ b/docs/src/pages/docs/agent/adk.mdx
@@ -1,12 +1,12 @@
---
-title: Agent SDK
+title: Jan ADK
description: Add an AI agent to your app. Start with a prompt, then give the agent functions your code can run.
-keywords: [Jan, Jan Agent, SDK, JavaScript, Python, embedding, host tools]
+keywords: [Jan, Jan Agent, ADK, JavaScript, Python, embedding, host tools]
---
import { Callout } from 'nextra/components'
-# Agent SDK
+# Jan ADK
**Send a task from your app. Get a streamed answer. Let the agent call your functions when it needs to act.**
@@ -17,29 +17,29 @@ and deciding what to do next. Your app supplies the task, controls access to its
Choose the language your app already uses:
-- **[JavaScript quickstart](/docs/agent/sdk-ts)** - Node.js 20+, also usable from TypeScript.
-- **[Python quickstart](/docs/agent/sdk-python)** - Python 3.11+, no Node.js required.
+- **[JavaScript quickstart](/docs/agent/adk-ts)** - Node.js 20+, also usable from TypeScript.
+- **[Python quickstart](/docs/agent/adk-python)** - Python 3.11+, no Node.js required.
Both guides end with a complete script that prints an answer. You do not need to understand the
wire protocol, manage subprocess pipes, or install Jan Desktop.
<Callout type="warning">
-Preview: the SDK source is available, but the packages are not yet published to npm or PyPI.
-The quickstarts install the client from the Jan repository and use a prebuilt nightly runtime.
-No Rust build is required.
+Preview: the packages are not yet published to npm or PyPI. The quickstarts install a
+[nightly ADK build](/docs/agent/adk-nightly) and a prebuilt nightly runtime with one command each.
+No Git checkout or Rust build is required.
</Callout>
## Three pieces, one app
```text
-Your app + SDK <-> Jan runtime <-> Model provider
+Your app + ADK <-> Jan runtime <-> Model provider
|
+-- Your functions: read a sensor, query a database, call an API
```
| Piece | Its job |
| --- | --- |
-| **SDK** | The JavaScript or Python library you import. It starts Jan, streams events and calls your tool handlers. |
+| **ADK** | The JavaScript or Python library you import. It starts Jan, streams events and calls your tool handlers. |
| **Runtime** | The separate `jan` executable. It manages conversations and the agent loop. |
| **Model provider** | The service Jan sends model requests to. Configure a provider or sign in with `jan login`. |
@@ -59,23 +59,23 @@ follow-up questions; create a new one for a separate conversation.
| Next goal | Guide |
| --- | --- |
-| Let the agent call a function in your app | [Host tools](/docs/agent/sdk-tools) |
-| Stop work, close the process, or handle an error | [Process & failures](/docs/agent/sdk-runtime) |
+| Let the agent call a function in your app | [Host tools](/docs/agent/adk-tools) |
+| Stop work, close the process, or handle an error | [Process & failures](/docs/agent/adk-runtime) |
| Build your own client or inspect the JSON messages | [Protocol records](/docs/agent/protocol) |
| Use Jan from a terminal instead of code | [Agent quickstart](/docs/agent/quickstart) |
## What your build supports
-The SDK uses `jan cli agent rpc`. Check that your runtime has it:
+The ADK uses `jan cli agent rpc`. Check that your runtime has it:
```bash
jan cli agent rpc --help
```
-If the command is missing, update your nightly with `jan update`. The SDK checks protocol
+If the command is missing, update your nightly with `jan update`. The ADK checks protocol
compatibility when it starts the runtime. A binary built from source must be rebuilt instead.
For download locations and checksums, use the
[nightly manifest](https://delta.jan.ai/agent-nightly/manifest.json). For negotiated capabilities
-and image limits, read `runtime.capabilities` and `runtime.limits` after SDK startup rather than
+and image limits, read `runtime.capabilities` and `runtime.limits` after ADK startup rather than
assuming every nightly has the same features.
diff --git a/docs/src/pages/docs/agent/cli.mdx b/docs/src/pages/docs/agent/cli.mdx
index f7a2f92cb..4f0aa5b4c 100644
--- a/docs/src/pages/docs/agent/cli.mdx
+++ b/docs/src/pages/docs/agent/cli.mdx
@@ -469,7 +469,7 @@ The `initialize` result carries the same `input_content_parts` object `init` doe
The `item/*` payload contains the existing `StreamEvent` object unchanged. A client can also call `session/list`, `session/resume`, `session/fork`, `session/archive`, `turn/steer`, `turn/interrupt` and `permission/respond {requestId,decision}`. Session ids address this **process**, not another RPC process. `turn/interrupt` closes the turn with one `turn/completed` carrying `stopReason: "interrupted"`, and puts that record on the wire before it answers the request. A client that closes stdin ends the process, and the turn that is still running is closed with `stopReason: "interrupted"` before it exits. An outstanding permission request is never granted - closing the channel is not an approval, and the gate's fallback for a request that is dropped without an answer is denial. Only one turn is active per process; a second `turn/start` returns `-32001` with `data.retryable: true` rather than silently queueing it, and so does a `turn/start` arriving while the output queue has no room left for the terminal record - the turn is refused instead of accepted and then lost. `turn/completed.stopReason` is the turn's outcome (`completed`, `error`, `interrupted`), not the upstream finish reason: that one is the `stop_reason` inside `item/done`. Transport errors (`-32700` malformed JSON, `-32600` invalid request, `-32601` unknown method, `-32602` bad params) differ from an agent failure reported by `turn/completed` with `stopReason: "error"`.
-Input frames are capped at 16 MiB and the writer queue holds at most 1025 records. If a client stops reading, the queue stops growing and the turn ends with a terminal overload outcome rather than the run accumulating deltas without bound; the process stays alive while the writer is blocked on the full stdout pipe, and that outcome is delivered as soon as the client reads again. The server exits when stdin closes, or when a later record finds the client gone. `--max-turns` is a one-shot flag rather than a session setting: an RPC turn runs until it finishes or a client sends `turn/interrupt`. `ephemeral: true` skips thread persistence. Host tools are declared on `session/start` (`tools`, `builtins`) and answered with `tool/respond`; see [Protocol](./protocol#rpc-host-tools). The `schema` command below documents the older `stream-json` channel, while `rpc-schema` describes this RPC envelope, accepted requests and event types. RPC clients use `turn/completed`, not the process exit code, to classify an individual turn.
+Input frames are capped at 16 MiB and the writer queue holds at most 1025 records. If a client stops reading, the queue stops growing and the turn ends with a terminal overload outcome rather than the run accumulating deltas without bound; the process stays alive while the writer is blocked on the full stdout pipe, and that outcome is delivered as soon as the client reads again. The server exits when stdin closes, or when a later record finds the client gone. `--max-turns` is a one-shot flag rather than a session setting: an RPC turn runs until it finishes or a client sends `turn/interrupt`. `ephemeral: true` skips thread persistence and automatic memory recall: the session neither indexes its answers nor has earlier answers recalled into its prompt. Memory notes written with `memory_write` still apply. Host tools are declared on `session/start` (`tools`, `builtins`) and answered with `tool/respond`; see [Protocol](./protocol#rpc-host-tools). The `schema` command below documents the older `stream-json` channel, while `rpc-schema` describes this RPC envelope, accepted requests and event types. RPC clients use `turn/completed`, not the process exit code, to classify an individual turn.
### `schema`
diff --git a/docs/src/pages/docs/agent/protocol.mdx b/docs/src/pages/docs/agent/protocol.mdx
index cf307d583..653cc1bf5 100644
--- a/docs/src/pages/docs/agent/protocol.mdx
+++ b/docs/src/pages/docs/agent/protocol.mdx
@@ -8,7 +8,7 @@ import { Callout } from 'nextra/components'
# Protocol Records
-**You do not need this page for the SDK quickstarts.** The SDK handles the messages for you.
+**You do not need this page for the ADK quickstarts.** The ADK handles the messages for you.
Use this reference when building your own client, debugging the channel, or generating types.
## Choose the transport first
@@ -20,11 +20,11 @@ Use this reference when building your own client, debugging the channel, or gene
| First exchange | `initialize` request, then `initialized` notification | The runtime emits `init` when setup succeeds |
| During work | JSON-RPC requests and notifications such as `item/token` | Records with a `type`, such as `token` |
| End of work | `turn/completed`; the process stays available | `result`, then process exit |
-| Best for | SDKs and long-lived applications | Direct CLI automation |
+| Best for | ADKs and long-lived applications | Direct CLI automation |
These are different envelopes. Do not send a stream-json `abort` record to RPC, or parse an RPC
notification as a bare stream-json event. For normal application code, use the
-[JavaScript](/docs/agent/sdk-ts) or [Python](/docs/agent/sdk-python) SDK.
+[JavaScript](/docs/agent/adk-ts) or [Python](/docs/agent/adk-python) ADK.
## Read the generated records
@@ -50,7 +50,7 @@ Use RPC's `initialize` response for its negotiated protocol and capabilities. Fo
use that run's `init` record. These are not interchangeable capability inventories.
<Callout type="info">
-The current SDKs use RPC. If your binary has no `rpc` command, update the nightly runtime.
+The current ADKs use RPC. If your binary has no `rpc` command, update the nightly runtime.
ACP is a separate, planned integration, not another name for either protocol.
</Callout>
@@ -152,23 +152,23 @@ accepts ids it does not list (a gateway, a proxy) is used as asked rather than o
model id that no provider lists is refused as above.
Every mutating method is answered. A client that gets no answer, for example because the process
-died, should treat the session as gone and close it. This fail-closed handling belongs to the SDK
+died, should treat the session as gone and close it. This fail-closed handling belongs to the ADK
or client, not the wire protocol.
## Direct stream-json examples
-Prefer the SDK unless you need to own the pipes yourself. The runnable examples in
-[`examples/agent-sdk`](https://github.com/janhq/jan/tree/main/examples/agent-sdk) show that
+Prefer the ADK unless you need to own the pipes yourself. The runnable examples in
+[`examples/adk`](https://github.com/janhq/jan/tree/main/examples/adk) show that
lower-level alternative. CI runs all four against a real runtime and checks these excerpts
-against their source. They are not the RPC SDK examples above.
+against their source. They are not the RPC ADK examples above.
<details>
-<summary>Read a streamed answer without the SDK</summary>
+<summary>Read a streamed answer without the ADK</summary>
The complete scripts handle startup and cleanup. Their reading loops distinguish answer text
from the terminal result:
-```js filename="examples/agent-sdk/js/first-turn.mjs"
+```js filename="examples/adk/js/first-turn.mjs"
for await (const line of createInterface({ input: run.stdout })) {
const record = JSON.parse(line)
if (record.type === 'init') {
@@ -181,7 +181,7 @@ for await (const line of createInterface({ input: run.stdout })) {
}
```
-```python filename="examples/agent-sdk/python/first_turn.py"
+```python filename="examples/adk/python/first_turn.py"
for line in run.stdout:
record = json.loads(line)
if record["type"] == "init":
@@ -195,13 +195,13 @@ for await (const line of createInterface({ input: run.stdout })) {
</details>
<details>
-<summary>Answer a host tool call without the SDK</summary>
+<summary>Answer a host tool call without the ADK</summary>
The complete scripts declare a weather fixture and handle permissions. These dispatch blocks
show the extra work a direct client owns: looking up a handler, reporting errors and matching
-the request id. The SDK performs that dispatch for you.
+the request id. The ADK performs that dispatch for you.
-```js filename="examples/agent-sdk/js/host-tool.mjs"
+```js filename="examples/adk/js/host-tool.mjs"
case 'tool_request': {
// `tool_name` is the name declared above, without `host__`.
let content
@@ -221,7 +221,7 @@ the request id. The SDK performs that dispatch for you.
}
```
-```python filename="examples/agent-sdk/python/host_tool.py"
+```python filename="examples/adk/python/host_tool.py"
elif kind == "tool_request":
# `tool_name` is the name declared above, without `host__`.
handler = HANDLERS.get(record["tool_name"])
diff --git a/examples/agent-sdk/js/first-turn.mjs b/examples/adk/js/first-turn.mjs
similarity index 100%
rename from examples/agent-sdk/js/first-turn.mjs
rename to examples/adk/js/first-turn.mjs
diff --git a/examples/agent-sdk/js/host-tool.mjs b/examples/adk/js/host-tool.mjs
similarity index 100%
rename from examples/agent-sdk/js/host-tool.mjs
rename to examples/adk/js/host-tool.mjs
diff --git a/examples/agent-sdk/python/first_turn.py b/examples/adk/python/first_turn.py
similarity index 100%
rename from examples/agent-sdk/python/first_turn.py
rename to examples/adk/python/first_turn.py
diff --git a/examples/agent-sdk/python/host_tool.py b/examples/adk/python/host_tool.py
similarity index 100%
rename from examples/agent-sdk/python/host_tool.py
rename to examples/adk/python/host_tool.py
diff --git a/packages/agent-sdk/README.md b/packages/adk/README.md
similarity index 90%
rename from packages/agent-sdk/README.md
rename to packages/adk/README.md
index 8ff07a3dd..56b254fa4 100644
--- a/packages/agent-sdk/README.md
+++ b/packages/adk/README.md
@@ -1,4 +1,4 @@
-# @janhq/agent-sdk
+# @janhq/adk
JavaScript and TypeScript client for the Jan agent runtime: sessions, streamed
turns, and the host tools your own process runs. It speaks the JSON-RPC channel
@@ -13,15 +13,18 @@ process serving many addressable sessions.
## Install
-For a preview without npm publication, use the versioned `npm install` command
-on the [nightly SDK download page](https://delta.jan.ai/sdk-nightly/index.html).
-That page becomes available after the first successful **Agent SDK Nightly**
-workflow run. It links a prebuilt tarball; no repository clone is required.
+It is a preview and not on npm yet. Install the latest nightly build; no
+repository clone is required:
-Keep the build's linked manifest to pin its matching runtime with
+```bash
+npm install "$(node -e "fetch('https://delta.jan.ai/adk-nightly/manifest.json').then(r => r.json()).then(m => console.log(m.packages.javascript.url))")"
+```
+
+The URL is versioned, so `package.json` pins that exact build. That build's
+manifest also pins its matching runtime:
`installRuntime({ manifestUrl: manifest.runtime.manifestUrl, version: manifest.runtime.version })`.
-See [nightly installation](https://jan.ai/docs/agent/sdk-nightly) for complete
-commands and the source-install fallback before the first nightly is published.
+See [nightly installation](https://jan.ai/docs/agent/adk-nightly) for PowerShell
+and the source-install fallback.
The runtime binary is separate, and there are three ways to have one: on `PATH`,
named by `process.env.JAN_BIN` (the `bin` option overrides both), or installed by
@@ -30,7 +33,7 @@ per platform, the artifact and its SHA-256, so an install is reproducible rather
than whatever the URL serves today:
```js
-import { JanRuntime, installRuntime } from '@janhq/agent-sdk'
+import { JanRuntime, installRuntime } from '@janhq/adk'
const runtime = await installRuntime() // downloaded once, then cached
const jan = await JanRuntime.start({ bin: runtime.bin })
@@ -61,7 +64,7 @@ const found = await findRuntime({ version: '0.8.4-50' }) // reads the cach
```
The nightly channel also publishes a shell installer, which is what the
-[jan.ai SDK pages](https://jan.ai/docs/agent/sdk) use:
+[jan.ai ADK pages](https://jan.ai/docs/agent/adk) use:
```bash
curl -fsSL https://delta.jan.ai/jan-cli/install-jan-agent.sh | bash
@@ -72,7 +75,7 @@ To build your own instead, `make agent` in the Jan repository.
## Quickstart
```js
-import { JanRuntime } from '@janhq/agent-sdk'
+import { JanRuntime } from '@janhq/adk'
const runtime = await JanRuntime.start()
const session = await runtime.createSession({ model: 'gpt-4o-mini', ephemeral: true })
@@ -208,8 +211,8 @@ generated from `protocol/rpc-schema.json` - request params, the event union, and
the method and event-tag literals:
```bash
-yarn workspace @janhq/agent-sdk generate # rewrite the generated files
-yarn workspace @janhq/agent-sdk check-types # regenerate, diff, type-check
+yarn workspace @janhq/adk generate # rewrite the generated files
+yarn workspace @janhq/adk check-types # regenerate, diff, type-check
```
The artifact covers request params and events, not responses; `RpcResponses` in
@@ -221,7 +224,7 @@ The suite drives a real runtime against a stub provider on loopback - no
credentials, no network:
```bash
-JAN_BIN=/path/to/jan yarn workspace @janhq/agent-sdk test
+JAN_BIN=/path/to/jan yarn workspace @janhq/adk test
```
It is skipped, not failed, when `JAN_BIN` is unset.
diff --git a/packages/agent-sdk/package.json b/packages/adk/package.json
similarity index 89%
rename from packages/agent-sdk/package.json
rename to packages/adk/package.json
index 3b75d50b9..74b623527 100644
--- a/packages/agent-sdk/package.json
+++ b/packages/adk/package.json
@@ -1,11 +1,11 @@
{
- "name": "@janhq/agent-sdk",
+ "name": "@janhq/adk",
"version": "0.1.0",
"description": "JavaScript and TypeScript client for the Jan agent runtime: sessions, streamed turns, and host tools over `jan cli agent rpc`",
"keywords": [
"jan",
"agent",
- "sdk",
+ "adk",
"json-rpc"
],
"homepage": "https://jan.ai",
@@ -31,7 +31,7 @@
"scripts": {
"generate": "node scripts/generate.mjs",
"check-types": "node scripts/generate.mjs --check && tsc -p tsconfig.json",
- "test": "node --test tests/sdk.test.mjs tests/install.test.mjs"
+ "test": "node --test tests/adk.test.mjs tests/install.test.mjs"
},
"devDependencies": {
"@types/node": "^22.10.0",
diff --git a/packages/agent-sdk/scripts/generate.mjs b/packages/adk/scripts/generate.mjs
similarity index 93%
rename from packages/agent-sdk/scripts/generate.mjs
rename to packages/adk/scripts/generate.mjs
index 22c838e92..2ed079156 100755
--- a/packages/agent-sdk/scripts/generate.mjs
+++ b/packages/adk/scripts/generate.mjs
@@ -1,21 +1,21 @@
#!/usr/bin/env node
-//! Generate the SDK wire types from the committed RPC schema.
+//! Generate the ADK wire types from the committed RPC schema.
//!
//! `protocol/rpc-schema.json` is the artifact CI regenerates from the Rust
//! dispatcher (`jan cli agent rpc-schema --out protocol/rpc-schema.json`), so a
//! verb cannot change without the document moving with it. This script is the
-//! other half of that guarantee: the JavaScript and Python SDKs derive their
+//! other half of that guarantee: the JavaScript and Python ADKs derive their
//! request, event and enum types from the same document, and `--check` fails
//! when the committed output no longer matches it.
//!
-//! One generator for both languages on purpose - the two SDKs are the same
+//! One generator for both languages on purpose - the two ADKs are the same
//! client in different runtimes, and two generators would be two chances to
//! drift. Nothing here is hand-maintained except the naming rules.
//!
//! Usage:
-//! node packages/agent-sdk/scripts/generate.mjs
-//! node packages/agent-sdk/scripts/generate.mjs --schema <path> --ts <path> --py <path>
-//! node packages/agent-sdk/scripts/generate.mjs --check
+//! node packages/adk/scripts/generate.mjs
+//! node packages/adk/scripts/generate.mjs --schema <path> --ts <path> --py <path>
+//! node packages/adk/scripts/generate.mjs --check
import { readFileSync, writeFileSync, mkdirSync } from 'node:fs'
import { dirname, join, resolve } from 'node:path'
@@ -31,9 +31,9 @@ const flag = (name, fallback) => {
}
const check = argv.includes('--check')
const schemaPath = resolve(flag('schema', join(repo, 'protocol/rpc-schema.json')))
-const tsPath = resolve(flag('ts', join(repo, 'packages/agent-sdk/src/generated/rpc-types.d.ts')))
-const jsPath = resolve(flag('js', join(repo, 'packages/agent-sdk/src/generated/rpc-types.js')))
-const pyPath = resolve(flag('py', join(repo, 'sdk/python/jan_agent_sdk/_generated.py')))
+const tsPath = resolve(flag('ts', join(repo, 'packages/adk/src/generated/rpc-types.d.ts')))
+const jsPath = resolve(flag('js', join(repo, 'packages/adk/src/generated/rpc-types.js')))
+const pyPath = resolve(flag('py', join(repo, 'adk/python/jan_adk/_generated.py')))
const doc = JSON.parse(readFileSync(schemaPath, 'utf8'))
@@ -47,7 +47,7 @@ const pascal = (tag) =>
/// Collect every `$defs` entry in the document, refusing two definitions that
/// share a name but disagree: the generated names are the only identity the
-/// SDKs have, so a silent redefinition would mis-type a whole field.
+/// ADKs have, so a silent redefinition would mis-type a whole field.
const defs = new Map()
const gather = (node) => {
if (Array.isArray(node)) return node.forEach(gather)
@@ -253,8 +253,8 @@ if (new Set(events.map((event) => event.name)).size !== events.length) {
/// The banner both files open with. The instruction is the same sentence in
/// both, and it names the committed schema rather than a machine-local path.
const banner = [
- 'Generated from protocol/rpc-schema.json by packages/agent-sdk/scripts/generate.mjs.',
- 'Do not edit by hand: run `node packages/agent-sdk/scripts/generate.mjs` after',
+ 'Generated from protocol/rpc-schema.json by packages/adk/scripts/generate.mjs.',
+ 'Do not edit by hand: run `node packages/adk/scripts/generate.mjs` after',
'changing the Rust dispatcher, and commit the regenerated output with it.',
]
@@ -416,12 +416,12 @@ if (check) {
if (actual !== expected) stale.push(path)
}
if (stale.length) {
- console.error('generated SDK types are out of date with protocol/rpc-schema.json:')
+ console.error('generated ADK types are out of date with protocol/rpc-schema.json:')
for (const path of stale) console.error(` ${path}`)
- console.error('run: node packages/agent-sdk/scripts/generate.mjs')
+ console.error('run: node packages/adk/scripts/generate.mjs')
process.exit(1)
}
- console.log(`generated SDK types match ${schemaPath}`)
+ console.log(`generated ADK types match ${schemaPath}`)
} else {
for (const [path, text] of outputs) {
mkdirSync(dirname(path), { recursive: true })
diff --git a/packages/agent-sdk/src/generated/rpc-types.d.ts b/packages/adk/src/generated/rpc-types.d.ts
similarity index 99%
rename from packages/agent-sdk/src/generated/rpc-types.d.ts
rename to packages/adk/src/generated/rpc-types.d.ts
index 2cddcf037..f4814821e 100644
--- a/packages/agent-sdk/src/generated/rpc-types.d.ts
+++ b/packages/adk/src/generated/rpc-types.d.ts
@@ -1,5 +1,5 @@
-// Generated from protocol/rpc-schema.json by packages/agent-sdk/scripts/generate.mjs.
-// Do not edit by hand: run `node packages/agent-sdk/scripts/generate.mjs` after
+// Generated from protocol/rpc-schema.json by packages/adk/scripts/generate.mjs.
+// Do not edit by hand: run `node packages/adk/scripts/generate.mjs` after
// changing the Rust dispatcher, and commit the regenerated output with it.
export declare const PROTOCOL_VERSION: 1
diff --git a/packages/agent-sdk/src/generated/rpc-types.js b/packages/adk/src/generated/rpc-types.js
similarity index 81%
rename from packages/agent-sdk/src/generated/rpc-types.js
rename to packages/adk/src/generated/rpc-types.js
index f3a0f2321..4f1ea1740 100644
--- a/packages/agent-sdk/src/generated/rpc-types.js
+++ b/packages/adk/src/generated/rpc-types.js
@@ -1,5 +1,5 @@
-// Generated from protocol/rpc-schema.json by packages/agent-sdk/scripts/generate.mjs.
-// Do not edit by hand: run `node packages/agent-sdk/scripts/generate.mjs` after
+// Generated from protocol/rpc-schema.json by packages/adk/scripts/generate.mjs.
+// Do not edit by hand: run `node packages/adk/scripts/generate.mjs` after
// changing the Rust dispatcher, and commit the regenerated output with it.
export const PROTOCOL_VERSION = 1
diff --git a/packages/agent-sdk/src/index.d.ts b/packages/adk/src/index.d.ts
similarity index 98%
rename from packages/agent-sdk/src/index.d.ts
rename to packages/adk/src/index.d.ts
index 9ba4a5a0e..651f9881f 100644
--- a/packages/agent-sdk/src/index.d.ts
+++ b/packages/adk/src/index.d.ts
@@ -1,4 +1,4 @@
-// The public surface of the JavaScript/TypeScript SDK, declared by hand over
+// The public surface of the JavaScript/TypeScript ADK, declared by hand over
// the generated wire types.
//
// `generated/rpc-types.d.ts` is regenerated from `protocol/rpc-schema.json`;
@@ -119,7 +119,7 @@ export interface ContentPartLimits {
export interface CreateSessionOptions {
cwd?: string
model?: string
- /** Keep nothing on disk: no thread, no media files. */
+ /** Keep nothing on disk: no thread, no media files, and no answers indexed for later recall. */
ephemeral?: boolean
/** `false` advertises only the host tools, no built-ins or MCP. */
builtins?: boolean
diff --git a/packages/agent-sdk/src/index.js b/packages/adk/src/index.js
similarity index 99%
rename from packages/agent-sdk/src/index.js
rename to packages/adk/src/index.js
index 9754c682a..3e0034596 100644
--- a/packages/agent-sdk/src/index.js
+++ b/packages/adk/src/index.js
@@ -35,13 +35,13 @@ export {
} from './install.js'
const require = createRequire(import.meta.url)
-const { version: SDK_VERSION } = require('../package.json')
+const { version: ADK_VERSION } = require('../package.json')
-const CLIENT_NAME = '@janhq/agent-sdk'
+const CLIENT_NAME = '@janhq/adk'
// The types a host may hand back as an image without naming one. The runtime
// enforces the same set (and the byte caps) on arrival; this is only what the
-// SDK can name from a file path.
+// ADK can name from a file path.
const IMAGE_MIME = {
'.png': 'image/png',
'.jpg': 'image/jpeg',
@@ -506,7 +506,7 @@ export class JanRuntime {
args = ['cli', 'agent', 'rpc'],
cwd,
env,
- clientInfo = { name: CLIENT_NAME, version: SDK_VERSION },
+ clientInfo = { name: CLIENT_NAME, version: ADK_VERSION },
handshakeTimeoutMs = 20_000,
shutdownGraceMs = 5_000,
maxBufferedEvents = 100_000,
@@ -525,7 +525,7 @@ export class JanRuntime {
stdio: ['pipe', 'pipe', 'pipe'],
env: {
...process.env,
- // The SDK owns this process and its lifetime; an update check nobody
+ // The ADK owns this process and its lifetime; an update check nobody
// asked for is a network call inside a caller's turn.
JAN_CLI_NO_UPDATE_CHECK: '1',
...env,
diff --git a/packages/agent-sdk/src/install.js b/packages/adk/src/install.js
similarity index 95%
rename from packages/agent-sdk/src/install.js
rename to packages/adk/src/install.js
index 395d3176f..28369d5d9 100644
--- a/packages/agent-sdk/src/install.js
+++ b/packages/adk/src/install.js
@@ -1,7 +1,7 @@
// Installing a pinned Jan runtime, without a Rust toolchain and without Jan
// Desktop.
//
-// The SDK spawns and owns a `jan` process, and where that process comes from is
+// The ADK spawns and owns a `jan` process, and where that process comes from is
// the caller's business: a PATH install, a build of their own, or this - the
// runtime Jan publishes, downloaded for this platform and checked against the
// digest the manifest carries.
@@ -302,6 +302,10 @@ async function download(url, target, { fetchImpl, onProgress, signal }) {
// system `tar` reads both (GNU tar on Linux, bsdtar on macOS and on the Windows
// that ships with it), which is one code path and no dependency.
//
+// On Windows that means the one in System32, named by path: under Git Bash or
+// MSYS the `tar` on PATH is GNU tar, which reads the `C:` of an absolute path as
+// a remote host and cannot open a zip at all.
+//
// Members are listed and checked before anything is extracted: an archive whose
// entries would land outside the staging directory is refused, not followed.
// Current `tar` implementations refuse those members themselves (GNU tar strips
@@ -309,9 +313,13 @@ async function download(url, target, { fetchImpl, onProgress, signal }) {
// in one place rather than left to whichever `tar` is on PATH - a digest proves
// the artifact is the one published, which is a promise about the channel and
// not about the archive's layout.
+const TAR = process.platform === 'win32'
+ ? join(process.env.SystemRoot || 'C:\\Windows', 'System32', 'tar.exe')
+ : 'tar'
+
async function extract(archive, into) {
- const listing = await run('tar', ['-tf', archive], archive, 'read')
- for (const name of listing.split('\n').filter((line) => line.length > 0)) {
+ const listing = await run(TAR, ['-tf', archive], archive, 'read')
+ for (const name of listing.split(/\r?\n/).filter((line) => line.length > 0)) {
const resolved = resolve(into, name)
if (resolved !== into && !resolved.startsWith(into + sep)) {
throw new JanInstallError(
@@ -320,7 +328,7 @@ async function extract(archive, into) {
)
}
}
- await run('tar', ['-xf', archive, '-C', into], archive, 'extract')
+ await run(TAR, ['-xf', archive, '-C', into], archive, 'extract')
}
async function run(command, args, archive, action) {
@@ -341,7 +349,7 @@ async function run(command, args, archive, action) {
child.once('error', (error) => {
reject(
new JanInstallError(
- `could not ${action} ${basename(archive)}: ${error.message} (a \`tar\` on PATH is required to install a runtime)`,
+ `could not ${action} ${basename(archive)}: ${error.message} (${TAR} is required to install a runtime)`,
{ url: archive },
),
)
diff --git a/packages/agent-sdk/tests/sdk.test.mjs b/packages/adk/tests/adk.test.mjs
similarity index 98%
rename from packages/agent-sdk/tests/sdk.test.mjs
rename to packages/adk/tests/adk.test.mjs
index 2d26bf9d4..82863ed28 100644
--- a/packages/agent-sdk/tests/sdk.test.mjs
+++ b/packages/adk/tests/adk.test.mjs
@@ -1,4 +1,4 @@
-// The JavaScript SDK, driven end to end against a real runtime.
+// The JavaScript ADK, driven end to end against a real runtime.
//
// The subject is the process boundary: every claim here is about what crosses
// it - the handshake, a turn's events, a host tool's answer becoming the tool
@@ -7,7 +7,7 @@
// agrees with itself; this asserts it agrees with `jan`.
//
// The provider is a stub on loopback, so the suite needs no credentials and no
-// network. Set `JAN_BIN` to the runtime binary to run it (the SDK's CI job
+// network. Set `JAN_BIN` to the runtime binary to run it (the ADK's CI job
// builds one; locally, `make agent` or a cargo build of `jan-cli`).
import { execFile } from 'node:child_process'
@@ -23,7 +23,7 @@ import { JanRuntime, JanRuntimeError, PROTOCOL_VERSION } from '../src/index.js'
const run = promisify(execFile)
const bin = process.env.JAN_BIN
-const missingRuntime = bin ? false : 'set JAN_BIN to the jan binary to run the SDK suite'
+const missingRuntime = bin ? false : 'set JAN_BIN to the jan binary to run the ADK suite'
// A chunk the model asks for the host tool with. `host__` is the advertised
// name; the host is told the bare one.
@@ -164,7 +164,7 @@ class Provider {
// A private home and project, removed after the test.
class Scratch {
static async create(name) {
- const root = await mkdtemp(join(tmpdir(), `jan-sdk-${name}-`))
+ const root = await mkdtemp(join(tmpdir(), `jan-adk-${name}-`))
const scratch = new Scratch(root)
await mkdir(scratch.home, { recursive: true })
await mkdir(scratch.project, { recursive: true })
@@ -457,7 +457,7 @@ test('interrupting a turn settles it once, and abandons its parked call', { skip
assert.equal(result.stopReason, 'interrupted')
// The parked call is withdrawn rather than answered: the runtime would refuse
- // a late answer as not pending, so the SDK must not write one.
+ // a late answer as not pending, so the ADK must not write one.
assert.ok(events.some((event) => event.type === 'tool_request_cancelled'))
// The handler is told on its own turn of the event loop, so the terminal
// record can arrive first; wait for the notice instead of racing it.
diff --git a/packages/agent-sdk/tests/install.test.mjs b/packages/adk/tests/install.test.mjs
similarity index 100%
rename from packages/agent-sdk/tests/install.test.mjs
rename to packages/adk/tests/install.test.mjs
diff --git a/packages/agent-sdk/tests/types.ts b/packages/adk/tests/types.ts
similarity index 97%
rename from packages/agent-sdk/tests/types.ts
rename to packages/adk/tests/types.ts
index 2b1c037b8..473f216c8 100644
--- a/packages/agent-sdk/tests/types.ts
+++ b/packages/adk/tests/types.ts
@@ -6,7 +6,7 @@
// package's own check rather than a consumer's build.
//
// The wire-shaped literals below are the same ones the runtime sends; the
-// behavioral suite in `sdk.test.mjs` is what proves they are real.
+// behavioral suite in `adk.test.mjs` is what proves they are real.
import { EVENT_TAGS, PROTOCOL_VERSION, JanRuntime, type EventTag, type RpcResponses, type StreamEvent } from '../src/index.js'
import type { RpcParams } from '../src/generated/rpc-types.js'
diff --git a/packages/agent-sdk/tsconfig.json b/packages/adk/tsconfig.json
similarity index 91%
rename from packages/agent-sdk/tsconfig.json
rename to packages/adk/tsconfig.json
index 9ea17d9a0..ddea56050 100644
--- a/packages/agent-sdk/tsconfig.json
+++ b/packages/adk/tsconfig.json
@@ -1,5 +1,5 @@
{
- // The SDK's own config: what a consumer's `tsc` has to accept is what this
+ // The ADK's own config: what a consumer's `tsc` has to accept is what this
// compiles. `src/index.js` is plain JavaScript, so it is included as a module
// - the declarations it satisfies live in `src/index.d.ts`, and both come
// from the same generated wire types.
diff --git a/scripts/sdk-nightly/package.py b/scripts/adk-nightly/package.py
similarity index 93%
rename from scripts/sdk-nightly/package.py
rename to scripts/adk-nightly/package.py
index e773eb243..2dc8d3a7d 100644
--- a/scripts/sdk-nightly/package.py
+++ b/scripts/adk-nightly/package.py
@@ -1,4 +1,4 @@
-"""Build versioned SDK artifacts and snapshot their compatible runtime manifest.
+"""Build versioned ADK artifacts and snapshot their compatible runtime manifest.
Only the workflow promotes manifest.json, after all platform smoke jobs succeed.
The output directory must be new: a release identity is never repackaged in place.
@@ -26,7 +26,7 @@ def main():
parser.add_argument("--output", type=Path, required=True)
parser.add_argument("--build", required=True, help="GitHub run ID and attempt, e.g. 123456.1")
parser.add_argument("--sha", required=True)
- parser.add_argument("--base-url", default="https://delta.jan.ai/sdk-nightly")
+ parser.add_argument("--base-url", default="https://delta.jan.ai/adk-nightly")
parser.add_argument("--runtime-manifest", default="https://delta.jan.ai/agent-nightly/manifest.json")
args = parser.parse_args()
if not re.fullmatch(r"[0-9]+\.[0-9]+", args.build) or not re.fullmatch(r"[0-9a-f]{40}", args.sha):
@@ -53,10 +53,10 @@ def main():
"packages": {},
}
(output / "runtime.json").write_bytes(snapshot)
- with tempfile.TemporaryDirectory(prefix="jan-sdk-package-") as temporary:
+ with tempfile.TemporaryDirectory(prefix="jan-adk-package-") as temporary:
stage = Path(temporary)
js = stage / "javascript"
- shutil.copytree(ROOT / "packages/agent-sdk", js, ignore=shutil.ignore_patterns("node_modules"))
+ shutil.copytree(ROOT / "packages/adk", js, ignore=shutil.ignore_patterns("node_modules"))
package = json.loads((js / "package.json").read_text())
package["version"] = f'{package["version"].split("-")[0]}-nightly.{args.build}'
(js / "package.json").write_text(json.dumps(package, indent=2) + "\n")
@@ -65,7 +65,7 @@ def main():
manifest["packages"]["javascript"] = {"name": package["name"], "version": package["version"],
"url": f"{base_url}/{archive.name}", "sha256": hashlib.sha256(archive.read_bytes()).hexdigest()}
py = stage / "python"
- shutil.copytree(ROOT / "sdk/python", py, ignore=shutil.ignore_patterns("__pycache__", "*.egg-info", "build", "dist"))
+ shutil.copytree(ROOT / "adk/python", py, ignore=shutil.ignore_patterns("__pycache__", "*.egg-info", "build", "dist"))
metadata_path = py / "pyproject.toml"
metadata = metadata_path.read_text()
project = tomllib.loads(metadata)["project"]
@@ -83,9 +83,9 @@ def main():
# Also a pip --find-links index. Every link points to one immutable build.
page = f"""<!doctype html>
<html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width">
-<title>Jan Agent SDK nightly</title>
+<title>Jan ADK nightly</title>
<style>body{{max-width:72ch;margin:3rem auto;padding:0 1rem;font:17px/1.6 system-ui;overflow-wrap:anywhere}}pre{{overflow:auto;background:#eee;padding:1rem}}code{{font-size:14px}}</style>
-<h1>Jan Agent SDK nightly</h1>
+<h1>Jan ADK nightly</h1>
<p>Preview build <code>{html.escape(identity)}</code>. No registry publication,
repository checkout, Jan Desktop or Rust compiler required.</p>
<h2>JavaScript (Node.js 20+)</h2>
@@ -102,7 +102,7 @@ repository checkout, Jan Desktop or Rust compiler required.</p>
Pass the returned <code>bin</code> to <code>JanRuntime.start</code>.
An existing compatible binary can also be passed explicitly.</p>
<p><a href="{base_url}/manifest.json">Versioned manifest and SHA-256 digests</a> |
-<a href="https://jan.ai/docs/agent/sdk">SDK guides</a></p>
+<a href="https://jan.ai/docs/agent/adk">ADK guides</a></p>
<p>Supported: Linux x64/ARM64, macOS Intel/Apple Silicon, Windows x64.
Windows ARM64 is not declared supported by this nightly smoke matrix.</p>
<p>Save this versioned page for repeatable installation. Versioned artifacts are not
diff --git a/scripts/sdk-nightly/smoke.mjs b/scripts/adk-nightly/smoke.mjs
similarity index 91%
rename from scripts/sdk-nightly/smoke.mjs
rename to scripts/adk-nightly/smoke.mjs
index 023b4c5a0..f0a14342b 100644
--- a/scripts/sdk-nightly/smoke.mjs
+++ b/scripts/adk-nightly/smoke.mjs
@@ -1,7 +1,7 @@
-// Run from a clean npm project, not from the SDK source tree.
+// Run from a clean npm project, not from the ADK source tree.
import assert from 'node:assert/strict'
import { execFileSync } from 'node:child_process'
-import { JanRuntime, installRuntime } from '@janhq/agent-sdk'
+import { JanRuntime, installRuntime } from '@janhq/adk'
const installed = await installRuntime({
manifestUrl: process.env.RUNTIME_MANIFEST,
diff --git a/scripts/sdk-nightly/smoke.py b/scripts/adk-nightly/smoke.py
similarity index 98%
rename from scripts/sdk-nightly/smoke.py
rename to scripts/adk-nightly/smoke.py
index d53f4c6fe..6e4de26b8 100644
--- a/scripts/sdk-nightly/smoke.py
+++ b/scripts/adk-nightly/smoke.py
@@ -1,4 +1,4 @@
-"""Install downloaded SDK artifacts and drive their real runtime, without source imports."""
+"""Install downloaded ADK artifacts and drive their real runtime, without source imports."""
import argparse
import hashlib
import json
@@ -61,7 +61,7 @@ def main():
node, npm = shutil.which("node"), shutil.which("npm")
assert node and npm, "Node/npm required for the JS smoke"
scripts = Path(__file__).resolve().parent
- with tempfile.TemporaryDirectory(prefix="jan-sdk-artifact-") as directory:
+ with tempfile.TemporaryDirectory(prefix="jan-adk-artifact-") as directory:
root = Path(directory)
artifacts = {}
for language in ["javascript", "python"]:
diff --git a/scripts/sdk-nightly/smoke_client.py b/scripts/adk-nightly/smoke_client.py
similarity index 96%
rename from scripts/sdk-nightly/smoke_client.py
rename to scripts/adk-nightly/smoke_client.py
index 00cfdcca5..724312127 100644
--- a/scripts/sdk-nightly/smoke_client.py
+++ b/scripts/adk-nightly/smoke_client.py
@@ -3,7 +3,7 @@ import os
import shutil
import subprocess
-from jan_agent_sdk import HostTool, JanRuntime, install_runtime
+from jan_adk import HostTool, JanRuntime, install_runtime
assert shutil.which("node") is None, "Python smoke must not have Node available"
installed = install_runtime(
diff --git a/sdk/python/tests/__init__.py b/sdk/python/tests/__init__.py
deleted file mode 100644
index cef2bec8f..000000000
--- a/sdk/python/tests/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-"""The SDK suite: a stub provider, a scratch home, and a real runtime."""
diff --git a/src-tauri/jan-cli/tests/sdk_examples.rs b/src-tauri/jan-cli/tests/adk_examples.rs
similarity index 95%
rename from src-tauri/jan-cli/tests/sdk_examples.rs
rename to src-tauri/jan-cli/tests/adk_examples.rs
index 2db3a478d..c6a9bda7c 100644
--- a/src-tauri/jan-cli/tests/sdk_examples.rs
+++ b/src-tauri/jan-cli/tests/adk_examples.rs
@@ -1,6 +1,6 @@
-//! The Agent SDK cookbook's runnable source, run.
+//! The ADK cookbook's runnable source, run.
//!
-//! Every file under `examples/agent-sdk/` is executed with its own interpreter
+//! Every file under `examples/adk/` is executed with its own interpreter
//! (`node`, `python3`) against the real `jan` binary, which talks to a scripted
//! stub provider on a loopback port. So a recipe that stops working -- a record
//! renamed, a message shape changed, a flag removed -- fails here instead of in
@@ -9,7 +9,7 @@
//! that the example printed something.
//!
//! The docs pages quote these files. A fenced block whose meta names
-//! `filename="examples/agent-sdk/..."` must be a verbatim excerpt of that file,
+//! `filename="examples/adk/..."` must be a verbatim excerpt of that file,
//! so a page cannot drift from the source this test runs.
use std::io::{Read, Write};
@@ -134,7 +134,7 @@ struct Scratch {
impl Scratch {
fn new(name: &str, stub: &Stub) -> Self {
- let root = std::env::temp_dir().join(format!("jan-sdk-{name}-{}", std::process::id()));
+ let root = std::env::temp_dir().join(format!("jan-adk-{name}-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&root);
std::fs::create_dir_all(root.join("home")).expect("scratch home");
let scratch = Self { root };
@@ -178,7 +178,7 @@ impl Scratch {
/// that stops answering the run (a renamed record it no longer matches)
/// would otherwise leave both processes waiting on each other forever.
fn example(&self, file: &str) -> Output {
- let path = repo_root().join("examples/agent-sdk").join(file);
+ let path = repo_root().join("examples/adk").join(file);
let interpreter = if file.ends_with(".py") {
"python3"
} else {
@@ -322,7 +322,7 @@ fn the_docs_quote_the_examples_verbatim() {
.split("filename=\"")
.nth(1)
.and_then(|s| s.split('"').next())
- .and_then(|f| f.strip_prefix("examples/agent-sdk/"))
+ .and_then(|f| f.strip_prefix("examples/adk/"))
else {
continue;
};
@@ -330,7 +330,7 @@ fn the_docs_quote_the_examples_verbatim() {
.by_ref()
.take_while(|l| l.trim_start() != "```")
.collect();
- let source = std::fs::read_to_string(root.join("examples/agent-sdk").join(file))
+ let source = std::fs::read_to_string(root.join("examples/adk").join(file))
.unwrap_or_else(|e| {
panic!(
"{} quotes {file}, which cannot be read: {e}",
@@ -357,12 +357,12 @@ fn the_docs_quote_the_examples_verbatim() {
for file in EXAMPLES {
assert!(
quoted.contains(file),
- "no docs page quotes examples/agent-sdk/{file}"
+ "no docs page quotes examples/adk/{file}"
);
}
}
-/// The examples the tests above run. A file added under `examples/agent-sdk/`
+/// The examples the tests above run. A file added under `examples/adk/`
/// without a test here would be published untested, so the directory must
/// hold exactly these.
const EXAMPLES: [&str; 4] = [
@@ -374,7 +374,7 @@ const EXAMPLES: [&str; 4] = [
#[test]
fn every_example_is_run() {
- let root = repo_root().join("examples/agent-sdk");
+ let root = repo_root().join("examples/adk");
let mut found = Vec::new();
let mut dirs = vec![root.clone()];
while let Some(dir) = dirs.pop() {
@@ -398,7 +398,7 @@ fn every_example_is_run() {
found.sort();
assert_eq!(
found, EXAMPLES,
- "every file under examples/agent-sdk/ needs a test that runs it"
+ "every file under examples/adk/ needs a test that runs it"
);
}
diff --git a/src-tauri/jan-cli/tests/agent_rpc.rs b/src-tauri/jan-cli/tests/agent_rpc.rs
index 5bed875b8..fada5cafd 100644
--- a/src-tauri/jan-cli/tests/agent_rpc.rs
+++ b/src-tauri/jan-cli/tests/agent_rpc.rs
@@ -974,3 +974,74 @@ fn model_set_refuses_a_model_no_provider_serves() {
rpc.close();
let _ = std::fs::remove_dir_all(scratch);
}
+
+/// Every request the provider has seen that carries recalled project memory.
+fn recalled(seen: &std::sync::Mutex<Vec<serde_json::Value>>) -> usize {
+ let requests = seen.lock().unwrap();
+ requests
+ .iter()
+ .filter(|request| request.to_string().contains("# Project Memory"))
+ .count()
+}
+
+fn start_with(rpc: &mut Rpc, id: u64, cwd: &Path, ephemeral: bool) -> String {
+ let started = rpc.ask(serde_json::json!({"jsonrpc":"2.0","id":id,"method":"session/start","params":{
+ "cwd":cwd,"model":"stub-model","ephemeral":ephemeral
+ }}));
+ started["result"]["sessionId"]
+ .as_str()
+ .unwrap_or_else(|| panic!("{started}"))
+ .to_owned()
+}
+
+fn complete_turn(rpc: &mut Rpc, id: u64, session_id: &str) {
+ let turn = rpc.ask(serde_json::json!({"jsonrpc":"2.0","id":id,"method":"turn/start","params":{"sessionId":session_id,"input":"where is the arm"}}));
+ assert!(turn["result"]["turnId"].is_string(), "{turn}");
+ let done = rpc
+ .read_until(|record| record["method"] == "turn/completed")
+ .expect("the turn completes");
+ assert_eq!(done["params"]["stopReason"], "completed", "{done}");
+}
+
+/// `ephemeral` means nothing outlives the session, and project memory is part
+/// of that: one episode's answer ("the arm reached bin") must not be recalled
+/// into a later episode's prompt, even though they share a project. The saved
+/// control proves the recall is observable in this setup at all.
+#[test]
+fn an_ephemeral_session_neither_indexes_nor_recalls_project_memory() {
+ let scratch = scratch("ephemeral-memory");
+ let home = scratch.join("home");
+ let (url, seen) = scripted_provider(&[PROSE]);
+ configure(&home, &url);
+ let mut rpc = Rpc::open(&home);
+ rpc.handshake();
+
+ let saved = scratch.join("project");
+ let first = start_with(&mut rpc, 3, &saved, false);
+ complete_turn(&mut rpc, 4, &first);
+ let second = start_with(&mut rpc, 5, &saved, false);
+ complete_turn(&mut rpc, 6, &second);
+ assert_eq!(recalled(&seen), 1, "a saved session recalls the earlier answer");
+
+ let isolated = scratch.join("isolated");
+ std::fs::create_dir_all(&isolated).unwrap();
+ let episode = start_with(&mut rpc, 7, &isolated, true);
+ complete_turn(&mut rpc, 8, &episode);
+ // A model switch and a fork rebuild the agent; both keep the setting.
+ let set = rpc.ask(serde_json::json!({"jsonrpc":"2.0","id":9,"method":"session/model/set","params":{"sessionId":episode,"model":"stub-model"}}));
+ assert_eq!(set["result"]["model"], "stub-model", "{set}");
+ complete_turn(&mut rpc, 10, &episode);
+ let fork = rpc.ask(serde_json::json!({"jsonrpc":"2.0","id":11,"method":"session/fork","params":{"sessionId":episode}}));
+ let fork = fork["result"]["sessionId"].as_str().unwrap_or_else(|| panic!("{fork}")).to_owned();
+ complete_turn(&mut rpc, 12, &fork);
+ let next = start_with(&mut rpc, 13, &isolated, true);
+ complete_turn(&mut rpc, 14, &next);
+ assert_eq!(
+ recalled(&seen),
+ 1,
+ "no ephemeral turn is sent an earlier episode's answer"
+ );
+
+ rpc.close();
+ let _ = std::fs::remove_dir_all(scratch);
+}
diff --git a/src-tauri/src/core/agent/compaction.rs b/src-tauri/src/core/agent/compaction.rs
index 698eedecf..3223d5003 100644
--- a/src-tauri/src/core/agent/compaction.rs
+++ b/src-tauri/src/core/agent/compaction.rs
@@ -101,13 +101,24 @@ pub(crate) fn estimate_request_tokens(request: &Value) -> u64 {
(json_text_len(request) as u64 / 4).max(1)
}
-/// Total length of every string in `value`, at any depth. Walks the value
-/// instead of serializing it: this runs on the first dispatch of every turn,
-/// and the request is already the largest allocation in the loop.
+/// What one image part is assumed to cost. Providers bill an image by its
+/// resolution, not by the length of its base64: Anthropic caps a resized image
+/// near 1.6K tokens, and OpenAI and Gemini typically charge less for the same
+/// frame. Counting the data URL as text scored one three-camera observation at
+/// ~560K tokens and compacted before nearly every request.
+const IMAGE_PART_TOKENS: usize = 1_600;
+
+/// Total length of every string in `value`, at any depth, with each
+/// `image_url` part counted as [`IMAGE_PART_TOKENS`] rather than its payload.
+/// Walks the value instead of serializing it: this runs on the first dispatch
+/// of every turn, and the request is already the largest allocation in the loop.
fn json_text_len(value: &Value) -> usize {
match value {
Value::String(text) => text.len(),
Value::Array(items) => items.iter().map(json_text_len).sum(),
+ Value::Object(fields) if fields.get("type").and_then(Value::as_str) == Some("image_url") => {
+ IMAGE_PART_TOKENS * 4
+ }
Value::Object(fields) => fields.values().map(json_text_len).sum(),
_ => 0,
}
@@ -968,4 +979,27 @@ mod tests {
"tool schemas must count toward the preflight estimate"
);
}
+
+ #[test]
+ fn an_image_part_costs_a_fixed_estimate_not_its_base64_length() {
+ // Three ~750 KB camera frames: as text, ~560K tokens, far past a 128K
+ // window's trigger; as images, a few thousand.
+ let frame = |_| json!({
+ "type": "image_url",
+ "image_url": { "url": format!("data:image/png;base64,{}", "A".repeat(750_000)) },
+ });
+ let observation = json!({
+ "model": "m",
+ "messages": [
+ { "role": "user", "content": "look" },
+ { "role": "tool", "tool_call_id": "c1", "content": (0..3).map(frame).collect::<Vec<_>>() },
+ ],
+ });
+ let estimate = estimate_request_tokens(&observation);
+ assert!(estimate >= 3 * IMAGE_PART_TOKENS as u64, "images still count: {estimate}");
+ assert!(
+ estimate < trigger_tokens(128_000, DEFAULT_COMPACTION_RATIO, None),
+ "one observation must not trigger compaction: {estimate}"
+ );
+ }
}
diff --git a/src-tauri/src/core/agent/loop.rs b/src-tauri/src/core/agent/loop.rs
index 75503d5d9..40f1df2a4 100644
--- a/src-tauri/src/core/agent/loop.rs
+++ b/src-tauri/src/core/agent/loop.rs
@@ -100,6 +100,11 @@ pub(crate) struct OrchestrationArgs {
/// shared project-context and tool-use prompt assembled for normal runs.
/// Child turns remain excluded from project memory recall/indexing.
pub system_prompt_override: Option<String>,
+ /// Whether the run recalls project memory into its prompt and indexes its
+ /// final answer into it. `false` for an ephemeral RPC session, whose
+ /// answers must neither outlive it nor reach a later session in the same
+ /// project. Child runs skip memory regardless (see above).
+ pub project_memory: bool,
/// Whether this run may dispatch subagents. `false` for child runs, which
/// caps recursion depth at one (a subagent cannot spawn grandchildren).
pub subagents_enabled: bool,
@@ -2338,6 +2343,7 @@ pub(crate) async fn run_server_side_openai_orchestration(
ask_requests: None,
todo_registry: None,
system_prompt_override: None,
+ project_memory: true,
subagents_enabled: false,
max_parallel_subagents: crate::core::agent::subagent::DEFAULT_MAX_PARALLEL_SUBAGENTS,
auto_approve: false,
@@ -2900,6 +2906,7 @@ async fn orchestrate_inner(
ask_requests,
todo_registry,
system_prompt_override,
+ project_memory,
subagents_enabled,
max_parallel_subagents,
auto_approve,
@@ -2989,7 +2996,8 @@ async fn orchestrate_inner(
}
// Normal parent runs recall project memory for the current query before it
// is indexed. Child runs keep their isolated history and skip memory.
- if system_prompt_override.is_none() {
+ let use_memory = *project_memory && system_prompt_override.is_none();
+ if use_memory {
if let Some(root) = project_root {
if let Some(query) = latest_user_text(&conversation_messages) {
if let Some(mem) = crate::core::agent::memory::retrieve_block(root, &query) {
@@ -3193,10 +3201,6 @@ async fn orchestrate_inner(
let cost_ceiling = body_cost_ceiling(json_body);
let mut budget = SessionBudget::new(max_session_tokens).with_cost_ceiling(cost_ceiling);
- // Top-level runs index their final assistant answer into project memory;
- // isolated child (subagent) runs skip it to keep history independent.
- let index_memory = system_prompt_override.is_none();
-
if let Some(root) = project_root {
// Background subagents are scoped to this run unless the session owns
// them: `_bg_guard` aborts any still-running child when
@@ -3401,7 +3405,9 @@ async fn orchestrate_inner(
},
)
.await;
- if index_memory {
+ // The same gate as the recall: an ephemeral session or a child run
+ // leaves no answer behind for a later session to recall.
+ if use_memory {
if let Ok(completion) = &result {
if let Some(answer) = extract_choice_message(completion).and_then(|m| {
m.get("content")
diff --git a/src-tauri/src/core/agent/subagent.rs b/src-tauri/src/core/agent/subagent.rs
index 3e4e70a89..c6cb30403 100644
--- a/src-tauri/src/core/agent/subagent.rs
+++ b/src-tauri/src/core/agent/subagent.rs
@@ -3204,6 +3204,7 @@ mod tests {
ask_requests: None,
todo_registry: None,
system_prompt_override: None,
+ project_memory: true,
subagents_enabled: true,
max_parallel_subagents: 1,
auto_approve: false,
diff --git a/src-tauri/src/core/cli/contract_conformance.rs b/src-tauri/src/core/cli/contract_conformance.rs
index d966f1a9c..4eb94de6e 100644
--- a/src-tauri/src/core/cli/contract_conformance.rs
+++ b/src-tauri/src/core/cli/contract_conformance.rs
@@ -1,11 +1,11 @@
//! Conformance suite for the host-tool / embedded-session contract
//! (jan-internal#368).
//!
-//! That issue defines the contract the Jan Agent SDKs are written against: two
+//! That issue defines the contract the Jan ADKs are written against: two
//! message tables, a requirement per row with the consumer code that proves it,
//! and an acceptance test that already runs it (Robot Studio swaps a worker and
//! keeps every test). Step 1 of its order of work is this suite, written before
-//! the SDK exists because it is the acceptance test the later steps have to
+//! the ADK exists because it is the acceptance test the later steps have to
//! satisfy.
//!
//! Two rules shape it:
@@ -535,7 +535,7 @@ fn every_implemented_session_row_declares_what_it_produces() {
}
/// The `ready` row is the one a client blocks on, so its gap is named here
-/// rather than discovered by whoever ports the first SDK.
+/// rather than discovered by whoever ports the first ADK.
///
/// The count in the name moves with the gap: `tool_specs` landed on the
/// handshake, so what `ready` still waits for is `provider` and `models`.
diff --git a/src-tauri/src/core/cli/mod.rs b/src-tauri/src/core/cli/mod.rs
index ac07d58bd..4161f0eb2 100644
--- a/src-tauri/src/core/cli/mod.rs
+++ b/src-tauri/src/core/cli/mod.rs
@@ -1175,6 +1175,7 @@ fn build_cli_orchestration_args(
ask_requests: None,
todo_registry: None,
system_prompt_override: None,
+ project_memory: true,
subagents_enabled: true,
max_parallel_subagents,
auto_approve,
diff --git a/src-tauri/src/core/cli/model_capabilities.rs b/src-tauri/src/core/cli/model_capabilities.rs
index bd9700b54..f992447f8 100644
--- a/src-tauri/src/core/cli/model_capabilities.rs
+++ b/src-tauri/src/core/cli/model_capabilities.rs
@@ -42,17 +42,20 @@ impl ContextWindowSource {
}
}
-/// Strip exactly one configured provider qualifier (`anthropic/...`) when the
-/// first segment is one of Jan's catalog providers. A user-provided model id is
-/// normally the bare id, but `--model anthropic/claude-sonnet-4-6` and the
-/// desktop selection can carry the provider prefix; both must resolve alike.
-fn strip_provider_qualifier(model_id: &str) -> &str {
- let mut parts = model_id.splitn(2, '/');
- let first = parts.next().unwrap_or("");
- match (first, parts.next()) {
- ("anthropic" | "openai" | "google" | "tokamak" | "jan", Some(rest)) => rest,
- _ => model_id,
+/// Strip the configured provider qualifiers (`anthropic/...`) in front of a
+/// bare id, as long as each leading segment is one of Jan's catalog providers.
+/// A user-provided model id is normally the bare id, but `--model
+/// anthropic/claude-sonnet-4-6` and the desktop selection can carry the
+/// provider prefix, and a gateway route nests one more
+/// (`tokamak/anthropic/claude-...`); all of them must resolve alike.
+fn strip_provider_qualifier(mut model_id: &str) -> &str {
+ while let Some((first, rest)) = model_id.split_once('/') {
+ match first {
+ "anthropic" | "openai" | "google" | "tokamak" | "jan" => model_id = rest,
+ _ => break,
+ }
}
+ model_id
}
/// Look up the catalog window for a bare model id (provider qualifier already
@@ -185,9 +188,14 @@ mod tests {
#[test]
fn provider_qualifier_does_not_change_resolution() {
+ let bare = resolve_context_window("claude-sonnet-4-6", None, None);
+ assert_eq!(resolve_context_window("anthropic/claude-sonnet-4-6", None, None), bare);
+ // A gateway route nests its upstream's qualifier inside its own.
+ assert_eq!(resolve_context_window("tokamak/anthropic/claude-sonnet-4-6", None, None), bare);
+ // Only known qualifiers are peeled: an unknown one stops the walk.
assert_eq!(
- resolve_context_window("anthropic/claude-sonnet-4-6", None, None),
- resolve_context_window("claude-sonnet-4-6", None, None),
+ resolve_context_window("tokamak/azure/claude-sonnet-4-6", None, None).source,
+ ContextWindowSource::Fallback,
);
}
diff --git a/src-tauri/src/core/cli/rpc.rs b/src-tauri/src/core/cli/rpc.rs
index a62b4ee28..daebb2060 100644
--- a/src-tauri/src/core/cli/rpc.rs
+++ b/src-tauri/src/core/cli/rpc.rs
@@ -1,5 +1,6 @@
//! Session-scoped JSON-RPC over LF-delimited stdio. Stdout contains only protocol records.
use std::collections::HashMap;
+use std::future::Future;
use std::io::{BufRead, Write};
use std::sync::Arc;
@@ -269,18 +270,49 @@ fn output_lines(mut rx: mpsc::Receiver<Value>) -> std::thread::JoinHandle<()> {
})
}
+/// Everything the engine already emitted, in order. Waits for room rather than
+/// failing on a full queue: the queue is drained by the dispatcher, whose own
+/// bounded writer queue is what ends a turn for a client that stopped reading.
async fn forward_events(
source: &mut mpsc::UnboundedReceiver<StreamEvent>,
events: &mpsc::Sender<TurnMessage>,
) -> Result<(), String> {
while let Some(event) = source.recv().await {
events
- .try_send(TurnMessage::Event(event))
- .map_err(|_| "RPC event queue overloaded or closed".to_owned())?;
+ .send(TurnMessage::Event(event))
+ .await
+ .map_err(|_| "RPC event queue closed".to_owned())?;
}
Ok(())
}
+/// Run `engine` while relaying the events it emits into `rx`, in order.
+///
+/// A burst larger than `events` is a model streaming fast, not a client that
+/// stopped reading, so a full queue waits for the dispatcher rather than ending
+/// the turn; the engine is not polled meanwhile. The dispatcher's bounded writer
+/// queue is what ends a turn nobody is reading.
+async fn pump_turn(
+ engine: impl Future<Output = Result<Value, String>>,
+ rx: &mut mpsc::UnboundedReceiver<StreamEvent>,
+ events: &mpsc::Sender<TurnMessage>,
+) -> Result<Value, String> {
+ tokio::pin!(engine);
+ loop {
+ tokio::select! {
+ run = &mut engine => return run,
+ event = rx.recv() => match event {
+ Some(event) => {
+ if events.send(TurnMessage::Event(event)).await.is_err() {
+ return Err("RPC event queue closed".to_owned());
+ }
+ }
+ None => return Err("RPC event stream closed".to_owned()),
+ },
+ }
+ }
+}
+
fn start_turn(
session: &mut Session,
input: Value,
@@ -311,28 +343,14 @@ fn start_turn(
});
let runner = tokio::spawn(async move {
let (tx, mut rx) = mpsc::unbounded_channel();
- let mut result = {
- let engine = run_orchestration_steered(&tx, &body, &args, Some(&steering_tx));
- tokio::pin!(engine);
- loop {
- tokio::select! {
- run = &mut engine => break run,
- event = rx.recv() => {
- match event {
- Some(event) => {
- if events.try_send(TurnMessage::Event(event)).is_err() {
- break Err("RPC event queue overloaded or closed".to_owned());
- }
- }
- None => break Err("RPC event stream closed".to_owned()),
- }
- }
- }
- }
- };
- // The run is complete, so stop producing events and drain only what
- // the engine already emitted. A full bounded queue is an overload,
- // not permission to buffer the remaining deltas without a bound.
+ let mut result = pump_turn(
+ run_orchestration_steered(&tx, &body, &args, Some(&steering_tx)),
+ &mut rx,
+ &events,
+ )
+ .await;
+ // The run is complete, so stop producing events and deliver what the
+ // engine already emitted.
drop(tx);
if let Err(message) = forward_events(&mut rx, &events).await {
result = Err(message);
@@ -375,6 +393,7 @@ fn rebuild_agent(source: &Session, model: Option<String>) -> Result<AgentSession
agent.args.session_id = Some(source.id.clone());
agent.args.host_tools = source.agent.args.host_tools.clone();
agent.args.host_owns_gate = source.agent.args.host_owns_gate;
+ agent.args.project_memory = source.agent.args.project_memory;
Ok(agent)
}
@@ -522,6 +541,9 @@ pub async fn serve() -> Result<(), String> {
Ok(mut agent) => {
agent.args.host_tools = host_tools;
agent.args.host_owns_gate = start.permissions == PermissionOwner::Host;
+ // "Not saved" covers project memory too: an ephemeral
+ // session's answers must not reach a later session.
+ agent.args.project_memory = !start.ephemeral;
let sid = uuid::Uuid::new_v4().to_string();
// The run reports the session by the id this client holds, not
// by the private one the agent was built with: provenance and the
@@ -831,19 +853,52 @@ mod tests {
use super::*;
use crate::core::cli::stream_input::{MAX_IMAGES, MAX_IMAGE_BYTES};
+ /// What the runner does: pump while the engine runs, then drain the rest.
+ async fn relay(
+ burst: usize,
+ events: mpsc::Sender<TurnMessage>,
+ ) -> Result<Value, String> {
+ let (tx, mut rx) = mpsc::unbounded_channel();
+ // Bursts of 50 with a yield between them: some are relayed while the
+ // engine is still running, the last is drained after it returns.
+ let engine = async {
+ for i in 0..burst {
+ tx.send(StreamEvent::Token { text: i.to_string() }).unwrap();
+ if i % 50 == 49 {
+ tokio::task::yield_now().await;
+ }
+ }
+ Ok(json!("done"))
+ };
+ let result = pump_turn(engine, &mut rx, &events).await;
+ drop(tx);
+ forward_events(&mut rx, &events).await?;
+ result
+ }
+
#[tokio::test]
- async fn event_forwarder_stops_receiving_when_its_bounded_queue_is_full() {
- let (upstream, mut source) = mpsc::unbounded_channel();
- let (downstream, _blocked) = mpsc::channel(1);
- downstream
- .send(TurnMessage::Event(StreamEvent::Parked))
- .await
- .unwrap();
- let forward = tokio::spawn(async move { forward_events(&mut source, &downstream).await });
+ async fn a_burst_larger_than_the_turn_queue_reaches_a_slow_reader_in_order() {
+ let (events, mut receiver) = mpsc::channel(4);
+ let reader = tokio::spawn(async move {
+ let mut seen = Vec::new();
+ while let Some(message) = receiver.recv().await {
+ if let TurnMessage::Event(StreamEvent::Token { text }) = message {
+ seen.push(text);
+ }
+ tokio::task::yield_now().await;
+ }
+ seen
+ });
+ assert_eq!(relay(200, events).await.unwrap(), json!("done"));
+ let expected: Vec<String> = (0..200).map(|i| i.to_string()).collect();
+ assert_eq!(reader.await.unwrap(), expected);
+ }
- upstream.send(StreamEvent::Parked).unwrap();
- assert!(forward.await.unwrap().unwrap_err().contains("overloaded"));
- assert!(upstream.send(StreamEvent::Parked).is_err(), "events should stop at the bounded boundary");
+ #[tokio::test]
+ async fn a_dispatcher_that_dropped_the_turn_ends_it() {
+ let (events, receiver) = mpsc::channel(1);
+ drop(receiver);
+ assert!(relay(3, events).await.unwrap_err().contains("closed"));
}
fn image(decoded: usize) -> Value {
diff --git a/src-tauri/src/core/cli/tui.rs b/src-tauri/src/core/cli/tui.rs
index ba28ac168..8742f2f0c 100644
--- a/src-tauri/src/core/cli/tui.rs
+++ b/src-tauri/src/core/cli/tui.rs
@@ -25273,6 +25273,7 @@ mod tests {
ask_requests: None,
todo_registry: None,
system_prompt_override: None,
+ project_memory: true,
subagents_enabled: true,
max_parallel_subagents: 4,
auto_approve: false,
diff --git a/yarn.lock b/yarn.lock
index dc38da198..41529f477 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2717,9 +2717,9 @@ __metadata:
languageName: node
linkType: hard
-"@janhq/agent-sdk@workspace:packages/agent-sdk":
+"@janhq/adk@workspace:packages/adk":
version: 0.0.0-use.local
- resolution: "@janhq/agent-sdk@workspace:packages/agent-sdk"
+ resolution: "@janhq/adk@workspace:packages/adk"
dependencies:
"@types/node": "npm:^22.10.0"
typescript: "npm:^5.6.2"