mycode-sdk 0.8.7__tar.gz → 0.8.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mycode_sdk-0.8.7 → mycode_sdk-0.8.9}/.gitignore +1 -0
- {mycode_sdk-0.8.7 → mycode_sdk-0.8.9}/PKG-INFO +4 -4
- {mycode_sdk-0.8.7 → mycode_sdk-0.8.9}/pyproject.toml +4 -4
- {mycode_sdk-0.8.7 → mycode_sdk-0.8.9}/src/mycode/__init__.py +0 -3
- {mycode_sdk-0.8.7 → mycode_sdk-0.8.9}/src/mycode/agent.py +8 -20
- {mycode_sdk-0.8.7 → mycode_sdk-0.8.9}/src/mycode/messages.py +13 -18
- {mycode_sdk-0.8.7 → mycode_sdk-0.8.9}/src/mycode/models.py +1 -6
- {mycode_sdk-0.8.7 → mycode_sdk-0.8.9}/src/mycode/models_catalog.json +1597 -421
- {mycode_sdk-0.8.7 → mycode_sdk-0.8.9}/src/mycode/providers/anthropic_like.py +10 -17
- {mycode_sdk-0.8.7 → mycode_sdk-0.8.9}/src/mycode/providers/base.py +7 -9
- {mycode_sdk-0.8.7 → mycode_sdk-0.8.9}/src/mycode/providers/gemini.py +6 -6
- {mycode_sdk-0.8.7 → mycode_sdk-0.8.9}/src/mycode/providers/openai_chat.py +7 -6
- {mycode_sdk-0.8.7 → mycode_sdk-0.8.9}/src/mycode/providers/openai_responses.py +2 -1
- {mycode_sdk-0.8.7 → mycode_sdk-0.8.9}/src/mycode/session.py +6 -10
- {mycode_sdk-0.8.7 → mycode_sdk-0.8.9}/src/mycode/tools.py +27 -67
- {mycode_sdk-0.8.7 → mycode_sdk-0.8.9}/LICENSE +0 -0
- {mycode_sdk-0.8.7 → mycode_sdk-0.8.9}/README.md +0 -0
- {mycode_sdk-0.8.7 → mycode_sdk-0.8.9}/src/mycode/compact.py +0 -0
- {mycode_sdk-0.8.7 → mycode_sdk-0.8.9}/src/mycode/hooks.py +0 -0
- {mycode_sdk-0.8.7 → mycode_sdk-0.8.9}/src/mycode/providers/__init__.py +0 -0
- {mycode_sdk-0.8.7 → mycode_sdk-0.8.9}/src/mycode/py.typed +0 -0
- {mycode_sdk-0.8.7 → mycode_sdk-0.8.9}/src/mycode/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mycode-sdk
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.9
|
|
4
4
|
Summary: Lightweight Python SDK for building AI agents.
|
|
5
5
|
Project-URL: Homepage, https://github.com/legibet/mycode
|
|
6
6
|
Project-URL: Repository, https://github.com/legibet/mycode
|
|
@@ -18,9 +18,9 @@ Classifier: Programming Language :: Python :: 3.12
|
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.13
|
|
19
19
|
Classifier: Topic :: Software Development
|
|
20
20
|
Requires-Python: >=3.12
|
|
21
|
-
Requires-Dist: anthropic>=0.
|
|
22
|
-
Requires-Dist: google-genai>=
|
|
23
|
-
Requires-Dist: openai>=2.
|
|
21
|
+
Requires-Dist: anthropic>=0.102.0
|
|
22
|
+
Requires-Dist: google-genai>=2.3.0
|
|
23
|
+
Requires-Dist: openai>=2.36.0
|
|
24
24
|
Description-Content-Type: text/markdown
|
|
25
25
|
|
|
26
26
|
# mycode-sdk
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "mycode-sdk"
|
|
7
|
-
version = "0.8.
|
|
7
|
+
version = "0.8.9"
|
|
8
8
|
description = "Lightweight Python SDK for building AI agents."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.12"
|
|
@@ -23,9 +23,9 @@ classifiers = [
|
|
|
23
23
|
]
|
|
24
24
|
keywords = ["agent", "llm", "anthropic", "openai", "gemini", "sdk"]
|
|
25
25
|
dependencies = [
|
|
26
|
-
"anthropic>=0.
|
|
27
|
-
"google-genai>=
|
|
28
|
-
"openai>=2.
|
|
26
|
+
"anthropic>=0.102.0",
|
|
27
|
+
"google-genai>=2.3.0",
|
|
28
|
+
"openai>=2.36.0",
|
|
29
29
|
]
|
|
30
30
|
|
|
31
31
|
[project.urls]
|
|
@@ -39,9 +39,6 @@ from mycode.tools import (
|
|
|
39
39
|
# The package metadata in mycode/pyproject.toml is the single version source.
|
|
40
40
|
__version__ = metadata.version("mycode-sdk")
|
|
41
41
|
|
|
42
|
-
# Built-in tool specs exposed as module-level constants so callers can pick
|
|
43
|
-
# which ones to register (``tools=[read_tool, bash_tool]``) rather than
|
|
44
|
-
# getting all four by default.
|
|
45
42
|
read_tool, write_tool, edit_tool, bash_tool = DEFAULT_TOOL_SPECS
|
|
46
43
|
|
|
47
44
|
__all__ = [
|
|
@@ -136,10 +136,9 @@ class Agent:
|
|
|
136
136
|
raise ValueError(msg)
|
|
137
137
|
self.messages: list[ConversationMessage] = list(messages)
|
|
138
138
|
|
|
139
|
-
#
|
|
140
|
-
#
|
|
141
|
-
#
|
|
142
|
-
# When no session is configured, use a tempdir scoped to session_id.
|
|
139
|
+
# ``tool_output_dir`` defaults to a session-adjacent directory so logs
|
|
140
|
+
# (e.g. bash spill files) live next to the session JSONL; without a
|
|
141
|
+
# session, fall back to a tempdir scoped to ``session_id``.
|
|
143
142
|
if session_dir is not None:
|
|
144
143
|
tool_output_dir = session_dir / self.session_id / "tool-output"
|
|
145
144
|
else:
|
|
@@ -434,21 +433,12 @@ class Agent:
|
|
|
434
433
|
*,
|
|
435
434
|
on_persist: PersistCallback | None = None,
|
|
436
435
|
) -> AsyncIterator[Event]:
|
|
437
|
-
"""Run the full agent loop for one user message.
|
|
438
|
-
|
|
439
|
-
Each turn asks the provider for one assistant message. If the assistant
|
|
440
|
-
requests tools, the agent runs them locally, appends one user-side
|
|
441
|
-
tool_result message, and continues until the assistant stops using tools.
|
|
442
|
-
|
|
443
|
-
When a ``session_dir`` is configured, every emitted message is appended
|
|
444
|
-
to the on-disk session log. ``on_persist`` fires *before* that append
|
|
445
|
-
regardless of whether a store is configured, so callers can plug in a
|
|
446
|
-
custom backend or stage related records (the web server uses it to
|
|
447
|
-
land a rewind marker first).
|
|
448
|
-
"""
|
|
436
|
+
"""Run the full agent loop for one user message."""
|
|
449
437
|
|
|
450
438
|
async def persist(message: ConversationMessage) -> None:
|
|
451
439
|
if on_persist is not None:
|
|
440
|
+
# Callers may need to write related records before the SDK
|
|
441
|
+
# appends this message to its own session log.
|
|
452
442
|
await on_persist(message)
|
|
453
443
|
if self._store is None:
|
|
454
444
|
return
|
|
@@ -517,7 +507,6 @@ class Agent:
|
|
|
517
507
|
)
|
|
518
508
|
|
|
519
509
|
try:
|
|
520
|
-
# Phase 1: ask the provider for exactly one assistant turn.
|
|
521
510
|
async for provider_event in self._stream_provider_turn(adapter, request):
|
|
522
511
|
if self._cancel_event.is_set():
|
|
523
512
|
provider_cancelled = True
|
|
@@ -675,8 +664,8 @@ class Agent:
|
|
|
675
664
|
yield Event("error", {"message": "cancelled"})
|
|
676
665
|
return
|
|
677
666
|
except Exception:
|
|
678
|
-
#
|
|
679
|
-
#
|
|
667
|
+
# Compaction must not block the current answer; the full
|
|
668
|
+
# transcript is still available for the next turn.
|
|
680
669
|
logger.warning(
|
|
681
670
|
"Context compaction failed, continuing without compaction",
|
|
682
671
|
exc_info=True,
|
|
@@ -686,7 +675,6 @@ class Agent:
|
|
|
686
675
|
break
|
|
687
676
|
|
|
688
677
|
else:
|
|
689
|
-
# while loop exhausted max_turns without breaking
|
|
690
678
|
yield Event("error", {"message": "max_turns reached"})
|
|
691
679
|
return
|
|
692
680
|
|
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
"""Internal conversation model shared by the runtime, session store, CLI, and UI.
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
`context_window` (see docs/sessions.md for `total_tokens` semantics)
|
|
17
|
-
- provider-specific assistant message extras live under `meta.native`
|
|
18
|
-
- provider-specific block replay hints live under `block.meta.native`
|
|
19
|
-
- local display metadata, such as `block.meta.duration_ms`, is never sent
|
|
20
|
-
upstream; provider adapters must explicitly project only supported fields
|
|
3
|
+
Provider adapters translate this shape to and from provider-specific wire
|
|
4
|
+
formats so the agent loop and session store stay provider-agnostic.
|
|
5
|
+
|
|
6
|
+
Metadata layout:
|
|
7
|
+
|
|
8
|
+
- assistant message ``meta`` keeps only normalized top-level fields:
|
|
9
|
+
``provider``, ``model``, ``provider_message_id``, ``stop_reason``,
|
|
10
|
+
``total_tokens``, ``context_window`` (see docs/sessions.md for
|
|
11
|
+
``total_tokens`` semantics)
|
|
12
|
+
- provider-specific extras live under ``meta.native`` on messages and
|
|
13
|
+
``block.meta.native`` on blocks
|
|
14
|
+
- local display metadata such as ``block.meta.duration_ms`` is never sent
|
|
15
|
+
upstream
|
|
21
16
|
"""
|
|
22
17
|
|
|
23
18
|
from __future__ import annotations
|
|
@@ -42,12 +42,7 @@ def load_models_catalog() -> dict[str, Any] | None:
|
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
def infer_provider_from_model(model: str | None) -> str | None:
|
|
45
|
-
"""Return the canonical built-in provider id for a known model id, else None.
|
|
46
|
-
|
|
47
|
-
Recognizes well-known prefixes on bare model ids and ``provider/model``
|
|
48
|
-
ids alike. Returns ``None`` for unknown ids — callers should require an
|
|
49
|
-
explicit provider in that case rather than guess.
|
|
50
|
-
"""
|
|
45
|
+
"""Return the canonical built-in provider id for a known model id, else None."""
|
|
51
46
|
|
|
52
47
|
bare = (model or "").strip().split("/", 1)[-1].strip().lower()
|
|
53
48
|
if bare.startswith("claude-"):
|