lingtai-kernel 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. lingtai_kernel-0.1.0/PKG-INFO +6 -0
  2. lingtai_kernel-0.1.0/README.md +86 -0
  3. lingtai_kernel-0.1.0/pyproject.toml +20 -0
  4. lingtai_kernel-0.1.0/setup.cfg +4 -0
  5. lingtai_kernel-0.1.0/src/lingtai_kernel/__init__.py +16 -0
  6. lingtai_kernel-0.1.0/src/lingtai_kernel/base_agent.py +1332 -0
  7. lingtai_kernel-0.1.0/src/lingtai_kernel/config.py +32 -0
  8. lingtai_kernel-0.1.0/src/lingtai_kernel/handshake.py +55 -0
  9. lingtai_kernel-0.1.0/src/lingtai_kernel/i18n/__init__.py +60 -0
  10. lingtai_kernel-0.1.0/src/lingtai_kernel/i18n/en.json +46 -0
  11. lingtai_kernel-0.1.0/src/lingtai_kernel/i18n/wen.json +46 -0
  12. lingtai_kernel-0.1.0/src/lingtai_kernel/i18n/zh.json +46 -0
  13. lingtai_kernel-0.1.0/src/lingtai_kernel/intrinsics/__init__.py +15 -0
  14. lingtai_kernel-0.1.0/src/lingtai_kernel/intrinsics/eigen.py +215 -0
  15. lingtai_kernel-0.1.0/src/lingtai_kernel/intrinsics/mail.py +474 -0
  16. lingtai_kernel-0.1.0/src/lingtai_kernel/intrinsics/soul.py +351 -0
  17. lingtai_kernel-0.1.0/src/lingtai_kernel/intrinsics/system.py +321 -0
  18. lingtai_kernel-0.1.0/src/lingtai_kernel/llm/__init__.py +11 -0
  19. lingtai_kernel-0.1.0/src/lingtai_kernel/llm/base.py +230 -0
  20. lingtai_kernel-0.1.0/src/lingtai_kernel/llm/interface.py +591 -0
  21. lingtai_kernel-0.1.0/src/lingtai_kernel/llm/service.py +70 -0
  22. lingtai_kernel-0.1.0/src/lingtai_kernel/llm/streaming.py +180 -0
  23. lingtai_kernel-0.1.0/src/lingtai_kernel/llm_utils.py +186 -0
  24. lingtai_kernel-0.1.0/src/lingtai_kernel/logging.py +51 -0
  25. lingtai_kernel-0.1.0/src/lingtai_kernel/loop_guard.py +207 -0
  26. lingtai_kernel-0.1.0/src/lingtai_kernel/message.py +48 -0
  27. lingtai_kernel-0.1.0/src/lingtai_kernel/prompt.py +125 -0
  28. lingtai_kernel-0.1.0/src/lingtai_kernel/services/__init__.py +0 -0
  29. lingtai_kernel-0.1.0/src/lingtai_kernel/services/logging.py +75 -0
  30. lingtai_kernel-0.1.0/src/lingtai_kernel/services/mail.py +234 -0
  31. lingtai_kernel-0.1.0/src/lingtai_kernel/session.py +355 -0
  32. lingtai_kernel-0.1.0/src/lingtai_kernel/state.py +26 -0
  33. lingtai_kernel-0.1.0/src/lingtai_kernel/token_counter.py +66 -0
  34. lingtai_kernel-0.1.0/src/lingtai_kernel/tool_executor.py +396 -0
  35. lingtai_kernel-0.1.0/src/lingtai_kernel/tool_timing.py +24 -0
  36. lingtai_kernel-0.1.0/src/lingtai_kernel/types.py +10 -0
  37. lingtai_kernel-0.1.0/src/lingtai_kernel/workdir.py +279 -0
  38. lingtai_kernel-0.1.0/src/lingtai_kernel.egg-info/PKG-INFO +6 -0
  39. lingtai_kernel-0.1.0/src/lingtai_kernel.egg-info/SOURCES.txt +58 -0
  40. lingtai_kernel-0.1.0/src/lingtai_kernel.egg-info/dependency_links.txt +1 -0
  41. lingtai_kernel-0.1.0/src/lingtai_kernel.egg-info/top_level.txt +1 -0
  42. lingtai_kernel-0.1.0/tests/test_base_agent.py +162 -0
  43. lingtai_kernel-0.1.0/tests/test_filesystem_mail.py +299 -0
  44. lingtai_kernel-0.1.0/tests/test_heartbeat.py +256 -0
  45. lingtai_kernel-0.1.0/tests/test_i18n.py +37 -0
  46. lingtai_kernel-0.1.0/tests/test_interface.py +67 -0
  47. lingtai_kernel-0.1.0/tests/test_llm_utils.py +73 -0
  48. lingtai_kernel-0.1.0/tests/test_loop_guard.py +48 -0
  49. lingtai_kernel-0.1.0/tests/test_mail_identity.py +287 -0
  50. lingtai_kernel-0.1.0/tests/test_message.py +14 -0
  51. lingtai_kernel-0.1.0/tests/test_prompt.py +17 -0
  52. lingtai_kernel-0.1.0/tests/test_services_logging.py +201 -0
  53. lingtai_kernel-0.1.0/tests/test_session.py +359 -0
  54. lingtai_kernel-0.1.0/tests/test_soul.py +398 -0
  55. lingtai_kernel-0.1.0/tests/test_state.py +12 -0
  56. lingtai_kernel-0.1.0/tests/test_streaming.py +230 -0
  57. lingtai_kernel-0.1.0/tests/test_token_counter.py +16 -0
  58. lingtai_kernel-0.1.0/tests/test_tool_executor.py +128 -0
  59. lingtai_kernel-0.1.0/tests/test_types.py +6 -0
  60. lingtai_kernel-0.1.0/tests/test_workdir.py +171 -0
@@ -0,0 +1,6 @@
1
+ Metadata-Version: 2.4
2
+ Name: lingtai-kernel
3
+ Version: 0.1.0
4
+ Summary: Minimal agent kernel — think, communicate, remember, host tools
5
+ License-Expression: MIT
6
+ Requires-Python: >=3.11
@@ -0,0 +1,86 @@
1
+ # lingtai-kernel
2
+
3
+ > [English](README.md) | [中文](README.zh.md) | [文言](README.wen.md)
4
+
5
+ > *灵台者有持,而不知其所持,而不可持者也。*
6
+ > *The spirit platform holds something, yet knows not what it holds — and what it holds cannot be held by force.*
7
+ > — 庄子·庚桑楚
8
+
9
+ Minimal agent kernel — think, communicate, remember, host tools.
10
+
11
+ ## Philosophy
12
+
13
+ **灵台**,心也 — the spirit platform is the mind. In Zhuangzi, it is where consciousness dwells: a place that naturally holds everything the soul needs, without knowing what it holds, and without forcing it.
14
+
15
+ In this framework, the agent's 灵台 is its **working directory** — a folder on disk where memory, covenant, identity, and mailbox live. The directory IS the agent. Give the kernel a folder and an LLM service, it brings the agent to life. Take the folder away, the agent ceases to exist. The kernel holds the agent's world, but does not interpret it — like the 灵台 of Zhuangzi, it holds without knowing what it holds.
16
+
17
+ This kernel follows Unix design:
18
+
19
+ - **Everything is a file.** The agent's identity is its directory path. No abstract IDs — the path is the address, the lock, the truth.
20
+ - **The kernel defines protocols, not implementations.** `LLMService` and `ChatSession` are abstract interfaces. How they're fulfilled — adapters, API keys, rate limiting — is the caller's concern.
21
+ - **Each agent is a self-contained process.** Own directory, own LLM service, own mail, own logs. Agents communicate through filesystem mail, not shared memory.
22
+ - **The kernel is minimal.** Think (LLM), communicate (mail), remember (memory), host tools. Capabilities, file I/O, orchestration — those live in [lingtai](https://github.com/user/lingtai).
23
+
24
+ ## Install
25
+
26
+ ```bash
27
+ pip install lingtai-kernel
28
+ ```
29
+
30
+ ## What the kernel provides
31
+
32
+ | Component | Purpose |
33
+ |-----------|---------|
34
+ | **BaseAgent** | Kernel coordinator — lifecycle, message loop, tool dispatch |
35
+ | **4 intrinsics** | mail (IPC), system (lifecycle), eigen (memory/identity), soul (inner voice) |
36
+ | **LLM protocol** | `LLMService` ABC, `ChatSession` ABC, provider-agnostic types |
37
+ | **Services** | Filesystem mail transport, structured JSONL logging |
38
+ | **WorkingDir** | Directory management — locking, git, manifest |
39
+
40
+ ## What the kernel does NOT provide
41
+
42
+ Capabilities, file I/O, MCP, vision, web search, bash, avatars, LLM adapters, rate limiting — these live in `lingtai`.
43
+
44
+ ## Quick start
45
+
46
+ ```python
47
+ from lingtai_kernel import BaseAgent
48
+
49
+ # The caller provides the LLM service (any implementation of the ABC)
50
+ agent = BaseAgent(
51
+ service=my_llm_service,
52
+ working_dir="/agents/alice", # the 灵台 — where the soul lives
53
+ agent_name="alice", # optional display name
54
+ )
55
+
56
+ agent.add_tool("hello", schema={...}, handler=lambda args: {"msg": "hi"})
57
+ agent.start()
58
+ agent.send("Say hello")
59
+ agent.stop()
60
+ ```
61
+
62
+ The kernel takes a directory path and a service. It doesn't know or care how either was created.
63
+
64
+ ## Agent identity
65
+
66
+ ```
67
+ /agents/alice/ ← this path IS the agent
68
+ .agent.lock ← exclusive lock (one process per directory)
69
+ .agent.heartbeat ← liveness proof (updated periodically)
70
+ .agent.json ← manifest (name, address, config)
71
+ system/
72
+ covenant.md ← protected instructions
73
+ memory.md ← agent's working notes
74
+ mailbox/
75
+ inbox/ ← received messages
76
+ outbox/ ← pending sends
77
+ sent/ ← delivery audit trail
78
+ logs/
79
+ events.jsonl ← structured event log
80
+ ```
81
+
82
+ No `agent_id`. The path is the identity. The heartbeat proves liveness. The lock proves exclusivity.
83
+
84
+ ## License
85
+
86
+ MIT
@@ -0,0 +1,20 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "lingtai-kernel"
7
+ version = "0.1.0"
8
+ requires-python = ">=3.11"
9
+ dependencies = []
10
+ description = "Minimal agent kernel — think, communicate, remember, host tools"
11
+ license = "MIT"
12
+
13
+ [tool.setuptools.packages.find]
14
+ where = ["src"]
15
+
16
+ [tool.setuptools.package-data]
17
+ lingtai_kernel = ["i18n/*.json"]
18
+
19
+ [tool.pytest.ini_options]
20
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,16 @@
1
+ """lingtai-kernel — minimal agent kernel: think, communicate, remember, host tools."""
2
+ from .types import UnknownToolError
3
+ from .config import AgentConfig
4
+ from .base_agent import BaseAgent
5
+ from .state import AgentState
6
+ from .message import Message, MSG_REQUEST, MSG_USER_INPUT
7
+
8
+ __all__ = [
9
+ "BaseAgent",
10
+ "AgentConfig",
11
+ "AgentState",
12
+ "Message",
13
+ "MSG_REQUEST",
14
+ "MSG_USER_INPUT",
15
+ "UnknownToolError",
16
+ ]