flowing-agent 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 (89) hide show
  1. flowing_agent-0.1.0/PKG-INFO +156 -0
  2. flowing_agent-0.1.0/README.md +129 -0
  3. flowing_agent-0.1.0/flowing/__init__.py +188 -0
  4. flowing_agent-0.1.0/flowing/_unstable/__init__.py +30 -0
  5. flowing_agent-0.1.0/flowing/_unstable/logging.py +412 -0
  6. flowing_agent-0.1.0/flowing/agent.py +4945 -0
  7. flowing_agent-0.1.0/flowing/agent_registry.py +463 -0
  8. flowing_agent-0.1.0/flowing/builtins/__init__.py +101 -0
  9. flowing_agent-0.1.0/flowing/builtins/agents.py +82 -0
  10. flowing_agent-0.1.0/flowing/builtins/tools.py +833 -0
  11. flowing_agent-0.1.0/flowing/compiler.py +958 -0
  12. flowing_agent-0.1.0/flowing/composables/__init__.py +92 -0
  13. flowing_agent-0.1.0/flowing/composables/compact.py +522 -0
  14. flowing_agent-0.1.0/flowing/composables/prompt_until.py +268 -0
  15. flowing_agent-0.1.0/flowing/composables/reminder.py +269 -0
  16. flowing_agent-0.1.0/flowing/composables/retry.py +364 -0
  17. flowing_agent-0.1.0/flowing/context.py +979 -0
  18. flowing_agent-0.1.0/flowing/errors.py +2299 -0
  19. flowing_agent-0.1.0/flowing/hooks.py +1150 -0
  20. flowing_agent-0.1.0/flowing/interfaces/__init__.py +350 -0
  21. flowing_agent-0.1.0/flowing/interfaces/cli.py +328 -0
  22. flowing_agent-0.1.0/flowing/interfaces/controls.py +238 -0
  23. flowing_agent-0.1.0/flowing/interfaces/oneshot.py +360 -0
  24. flowing_agent-0.1.0/flowing/interfaces/repl.py +602 -0
  25. flowing_agent-0.1.0/flowing/interfaces/repl_debug.py +220 -0
  26. flowing_agent-0.1.0/flowing/interfaces/run.py +190 -0
  27. flowing_agent-0.1.0/flowing/interfaces/serve.py +753 -0
  28. flowing_agent-0.1.0/flowing/interfaces/web.py +319 -0
  29. flowing_agent-0.1.0/flowing/interfaces/webui-dist/index.html +189 -0
  30. flowing_agent-0.1.0/flowing/lists.py +387 -0
  31. flowing_agent-0.1.0/flowing/media.py +551 -0
  32. flowing_agent-0.1.0/flowing/message.py +2008 -0
  33. flowing_agent-0.1.0/flowing/model.py +445 -0
  34. flowing_agent-0.1.0/flowing/params.py +801 -0
  35. flowing_agent-0.1.0/flowing/parsable.py +1151 -0
  36. flowing_agent-0.1.0/flowing/parser.py +548 -0
  37. flowing_agent-0.1.0/flowing/paths.py +561 -0
  38. flowing_agent-0.1.0/flowing/persistence.py +871 -0
  39. flowing_agent-0.1.0/flowing/plugins/__init__.py +280 -0
  40. flowing_agent-0.1.0/flowing/plugins/clipboard/__init__.py +25 -0
  41. flowing_agent-0.1.0/flowing/plugins/clipboard/clipboard.py +193 -0
  42. flowing_agent-0.1.0/flowing/plugins/clipboard/tools.py +394 -0
  43. flowing_agent-0.1.0/flowing/plugins/comm/__init__.py +24 -0
  44. flowing_agent-0.1.0/flowing/plugins/comm/comm.py +1230 -0
  45. flowing_agent-0.1.0/flowing/plugins/comm/models.py +154 -0
  46. flowing_agent-0.1.0/flowing/plugins/cron/__init__.py +27 -0
  47. flowing_agent-0.1.0/flowing/plugins/cron/cron.py +151 -0
  48. flowing_agent-0.1.0/flowing/plugins/cron/jobs.py +467 -0
  49. flowing_agent-0.1.0/flowing/plugins/cron/models.py +159 -0
  50. flowing_agent-0.1.0/flowing/plugins/cron/tools.py +154 -0
  51. flowing_agent-0.1.0/flowing/plugins/skills/__init__.py +51 -0
  52. flowing_agent-0.1.0/flowing/plugins/skills/models.py +469 -0
  53. flowing_agent-0.1.0/flowing/plugins/skills/registry.py +488 -0
  54. flowing_agent-0.1.0/flowing/plugins/skills/skills.py +1006 -0
  55. flowing_agent-0.1.0/flowing/plugins/workflow/__init__.py +23 -0
  56. flowing_agent-0.1.0/flowing/plugins/workflow/loader.py +212 -0
  57. flowing_agent-0.1.0/flowing/plugins/workflow/plugin.py +246 -0
  58. flowing_agent-0.1.0/flowing/plugins/workflow/workflow.py +502 -0
  59. flowing_agent-0.1.0/flowing/provide.py +167 -0
  60. flowing_agent-0.1.0/flowing/providers/__init__.py +238 -0
  61. flowing_agent-0.1.0/flowing/providers/anthropic.py +50 -0
  62. flowing_agent-0.1.0/flowing/providers/anthropic_messages.py +650 -0
  63. flowing_agent-0.1.0/flowing/providers/bedrock.py +66 -0
  64. flowing_agent-0.1.0/flowing/providers/deepseek.py +99 -0
  65. flowing_agent-0.1.0/flowing/providers/deepseek_anthropic.py +59 -0
  66. flowing_agent-0.1.0/flowing/providers/deepseek_responses.py +68 -0
  67. flowing_agent-0.1.0/flowing/providers/groq.py +48 -0
  68. flowing_agent-0.1.0/flowing/providers/kimi_coding.py +74 -0
  69. flowing_agent-0.1.0/flowing/providers/kimi_coding_anthropic.py +68 -0
  70. flowing_agent-0.1.0/flowing/providers/moonshot.py +59 -0
  71. flowing_agent-0.1.0/flowing/providers/moonshot_anthropic.py +61 -0
  72. flowing_agent-0.1.0/flowing/providers/moonshot_responses.py +60 -0
  73. flowing_agent-0.1.0/flowing/providers/openai_completions.py +691 -0
  74. flowing_agent-0.1.0/flowing/providers/openai_responses.py +713 -0
  75. flowing_agent-0.1.0/flowing/providers/openrouter.py +107 -0
  76. flowing_agent-0.1.0/flowing/providers/provider.py +1134 -0
  77. flowing_agent-0.1.0/flowing/runtime.py +2518 -0
  78. flowing_agent-0.1.0/flowing/snapshot.py +598 -0
  79. flowing_agent-0.1.0/flowing/subagents.py +680 -0
  80. flowing_agent-0.1.0/flowing/tool/__init__.py +190 -0
  81. flowing_agent-0.1.0/flowing/tool/_env.py +44 -0
  82. flowing_agent-0.1.0/flowing/tool/cli.py +184 -0
  83. flowing_agent-0.1.0/flowing/tool/core.py +1226 -0
  84. flowing_agent-0.1.0/flowing/tool/mcp.py +326 -0
  85. flowing_agent-0.1.0/flowing/tool/registry.py +729 -0
  86. flowing_agent-0.1.0/flowing/tool/request.py +237 -0
  87. flowing_agent-0.1.0/flowing/tool/script.py +310 -0
  88. flowing_agent-0.1.0/pyproject.toml +65 -0
  89. flowing_agent-0.1.0/pyproject.toml.orig +67 -0
@@ -0,0 +1,156 @@
1
+ Metadata-Version: 2.4
2
+ Name: flowing-agent
3
+ Version: 0.1.0
4
+ Summary: A lightweight, extensible, descriptive agent runtime framework
5
+ Author: Nyanifold
6
+ License-Expression: MIT
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
14
+ Requires-Dist: aiohttp>=3.14.3
15
+ Requires-Dist: croniter>=6.2.4
16
+ Requires-Dist: httpx>=0.28.1
17
+ Requires-Dist: httpx2>=2.5.0
18
+ Requires-Dist: jinja2>=3.1.6
19
+ Requires-Dist: mcp>=2.0.0
20
+ Requires-Dist: pydantic>=2.13.5
21
+ Requires-Dist: ruamel-yaml>=0.19.1
22
+ Requires-Python: >=3.13
23
+ Project-URL: Repository, https://github.com/Nyanifold/flowing
24
+ Project-URL: Documentation, https://flowing-agent.readthedocs.io/
25
+ Project-URL: Issues, https://github.com/Nyanifold/flowing/issues
26
+ Description-Content-Type: text/markdown
27
+
28
+ # Flowing
29
+
30
+ **English** | [中文](README.zh.md)
31
+
32
+ Flowing is a lightweight, extensible, descriptive agent runtime framework for complex interactions (Python ≥ 3.13). In Flowing, an agent's entire definition — its role and prompt, the LLM it uses, its tools and subagents, composable extensions, and hook code — lives in a single `.fya` file. The framework opens its execution pipeline to extensions at key points, and its runtime can be embedded into any Python host application as an ordinary object. The core does only three things: message flow, error classification, and hook dispatch; policies such as retries, compaction, and approvals are mounted on demand as composables or plugins.
33
+
34
+ ## Who it's for
35
+
36
+ - You want every layer of the framework to be readable, modifiable, and auditable, rather than a black box of policy configuration;
37
+ - You need fine-grained control over conversation history — branching off from any message, rewriting or pruning the past, instead of append-only dialogue;
38
+ - You need the same capability to present different model views on different agents, with an explicit safety boundary: being registered does not mean the model can see it.
39
+
40
+ These needs don't point to any single application shape: in Flowing, orchestration logic is plain Python code, with sequencing, branching, and concurrency expressed by the language itself. As a foundational runtime framework, it can be used to build coding, education, e-commerce, or companion agents as well as multi-agent systems, and to run multi-agent interaction experiments.
41
+
42
+ ## Highlights
43
+
44
+ - **Message-driven runtime model**: each agent instance owns a priority message queue and a persistent work loop; user input, model responses, tool results, external events, and subagent receipts are all represented as messages, each driving a turn. `query()` waits for the turn result, `message()` is fire-and-forget, `steer()` redirects an in-flight turn.
45
+ - **A message-level tree for history**: conversation history is a forest of messages, not a linear list. `fork()` moves a cursor to open a parallel branch while old branches stay intact; history itself supports five surgical operations — insert, branch, remove, update, reparent — all persisted as usual.
46
+ - **Three-layer capability description**: the executable object, the LLM-visible declaration, and the agent-level binding evolve independently — the same tool can appear under different names, descriptions, and parameter views on different agents. Built-in tools ship with the runtime, but they must be explicitly declared to become visible to the model.
47
+ - **Declarative `.fya`**: an agent's description, model intent, capability bindings, system prompt, and hook code live in one self-contained file; the compiled output is fully equivalent to a hand-written `Agent` subclass.
48
+ - **Instance-level hooks**: every instance has its own hook registry, with hook points spanning the lifecycle, turns, messages, model calls, tool execution, and subagents. A handler can rewrite data, asynchronously wait for external confirmation, or raise `Intercepted` to hard-block the operation — a natural foundation for human approval gates.
49
+ - **Automatic persistence and crash recovery**: messages and state are persisted write-behind; after a crash, replay rebuilds the state. Unpaired tool calls are sealed during recovery, so the model always sees a complete, paired history.
50
+ - **Zero-code tool access**: MCP servers (stdio / SSE / HTTP), shell command templates (arguments auto-escaped), and HTTP endpoints can all become tools from a single declaration file.
51
+ - **Complete exposure options**: eight subcommands — REPL, one-shot CLI, plain HTTP API, a built-in web frontend, CI smoke tests, and more — run the same project unchanged in any form.
52
+
53
+ ## Installation
54
+
55
+ ```bash
56
+ pip install flowing-agent
57
+ ```
58
+
59
+ ## Quick start
60
+
61
+ Create a directory with five files.
62
+
63
+ `root.fya`:
64
+
65
+ ```yaml
66
+ description: Minimal Q&A assistant
67
+ model_tag: default
68
+ ---
69
+ $system_prompt:
70
+ You are a concise assistant. Answer in at most three sentences.
71
+ ```
72
+
73
+ `main.py`:
74
+
75
+ ```python
76
+ from flowing import Runtime
77
+
78
+ async def main() -> Runtime:
79
+ runtime = Runtime(persist_dir="@/.flowing")
80
+ runtime.set_model_tags("@/model-tags.yaml")
81
+ await runtime.mount("@/root.fya", agent_id="agent-main")
82
+ return runtime
83
+ ```
84
+
85
+ Model access is split into three files, declaring the access identity, the model entries, and the tag mapping:
86
+
87
+ ```yaml
88
+ # providers.yaml
89
+ deepseek:
90
+ adapter: deepseek
91
+ base_url: https://api.deepseek.com
92
+ api_key: "{{env.DEEPSEEK_API_KEY}}"
93
+ openrouter:
94
+ adapter: openrouter
95
+ base_url: https://openrouter.ai/api/v1
96
+ api_key: "{{env.OPENROUTER_API_KEY}}"
97
+ ```
98
+
99
+ ```yaml
100
+ # models.yaml
101
+ luna:
102
+ provider: openrouter
103
+ model: openai/gpt-6-luna
104
+ "reasoning.effort": high
105
+ deepseek-flash:
106
+ provider: deepseek
107
+ model: deepseek-v4-flash
108
+ ```
109
+
110
+ ```yaml
111
+ # model-tags.yaml
112
+ tags:
113
+ default: luna
114
+ ```
115
+
116
+ Run:
117
+
118
+ ```console
119
+ $ export OPENROUTER_API_KEY='<your key>'
120
+ $ flowing repl .
121
+ (agent-main)>>> Introduce yourself in one sentence.
122
+ I'm a concise assistant, keeping answers to three sentences or fewer.
123
+ (agent-main)>>> /exit
124
+ ```
125
+
126
+ The conversation doesn't vanish on exit: the messages it produced are persisted under `.flowing/` in the project directory. A fixed `agent_id` means that running `flowing repl .` again brings back the same agent with its full history — no recovery code required.
127
+
128
+ ## Going further
129
+
130
+ - **Capability access**: declare built-in tools, MCP servers, or shell commands and HTTP endpoints as tools via `tools:`; implement custom logic with `ScriptTool`.
131
+ - **Multi-agent**: declare subagent types under `subagents:` and the orchestrator routes work using the auto-generated catalog; you can also create subagents programmatically and run them in parallel.
132
+ - **Intervention**: attach handlers at hook points — intercept a tool call pending approval, audit at turn completion, switch models and retry on provider errors. The built-in `use_retry` / `use_compact` are implemented in exactly this way and can serve as references.
133
+ - **Embedding**: the host application holds the Runtime returned by `launch()`; input goes through `query` / `message` / `steer`, output through hook subscriptions (streaming output, completion notices, call interception).
134
+
135
+ ## Documentation
136
+
137
+ - [Beginner tutorial](https://flowing-agent.readthedocs.io/en/beginner-tutorial/): for readers new to agent systems development;
138
+ - [Detailed tutorial](https://flowing-agent.readthedocs.io/en/tutorial/): from quick start to core mechanics and operations;
139
+ - [Concise reference](https://flowing-agent.readthedocs.io/en/flowing-ref/): the whole framework in four parts, for quick lookup;
140
+ - [API reference](https://flowing-agent.readthedocs.io/en/api.html): the public API organized by module.
141
+
142
+ ## Project status
143
+
144
+ Current version 0.1.0. The framework core is complete (700+ test cases passing) and the project is in the example-scenarios phase. Breaking changes are still possible during 0.x; every such release ships with a detailed changelog explaining how to migrate.
145
+
146
+ This project was developed with heavy reliance on AI assistance, using models from different providers at different capability levels. Limited by the author's available time, not every line of code has been individually reviewed; if you find any divergence between the implementation and the documentation (docstrings, tutorials), an issue is greatly appreciated.
147
+
148
+ ## License
149
+
150
+ [MIT](LICENSE) © 2026 Nyanifold
151
+
152
+ ---
153
+
154
+ <p align="center">
155
+ <img src="assets/oh-wishes.svg" alt="Oh wishes... I beg you coalesce!">
156
+ </p>
@@ -0,0 +1,129 @@
1
+ # Flowing
2
+
3
+ **English** | [中文](README.zh.md)
4
+
5
+ Flowing is a lightweight, extensible, descriptive agent runtime framework for complex interactions (Python ≥ 3.13). In Flowing, an agent's entire definition — its role and prompt, the LLM it uses, its tools and subagents, composable extensions, and hook code — lives in a single `.fya` file. The framework opens its execution pipeline to extensions at key points, and its runtime can be embedded into any Python host application as an ordinary object. The core does only three things: message flow, error classification, and hook dispatch; policies such as retries, compaction, and approvals are mounted on demand as composables or plugins.
6
+
7
+ ## Who it's for
8
+
9
+ - You want every layer of the framework to be readable, modifiable, and auditable, rather than a black box of policy configuration;
10
+ - You need fine-grained control over conversation history — branching off from any message, rewriting or pruning the past, instead of append-only dialogue;
11
+ - You need the same capability to present different model views on different agents, with an explicit safety boundary: being registered does not mean the model can see it.
12
+
13
+ These needs don't point to any single application shape: in Flowing, orchestration logic is plain Python code, with sequencing, branching, and concurrency expressed by the language itself. As a foundational runtime framework, it can be used to build coding, education, e-commerce, or companion agents as well as multi-agent systems, and to run multi-agent interaction experiments.
14
+
15
+ ## Highlights
16
+
17
+ - **Message-driven runtime model**: each agent instance owns a priority message queue and a persistent work loop; user input, model responses, tool results, external events, and subagent receipts are all represented as messages, each driving a turn. `query()` waits for the turn result, `message()` is fire-and-forget, `steer()` redirects an in-flight turn.
18
+ - **A message-level tree for history**: conversation history is a forest of messages, not a linear list. `fork()` moves a cursor to open a parallel branch while old branches stay intact; history itself supports five surgical operations — insert, branch, remove, update, reparent — all persisted as usual.
19
+ - **Three-layer capability description**: the executable object, the LLM-visible declaration, and the agent-level binding evolve independently — the same tool can appear under different names, descriptions, and parameter views on different agents. Built-in tools ship with the runtime, but they must be explicitly declared to become visible to the model.
20
+ - **Declarative `.fya`**: an agent's description, model intent, capability bindings, system prompt, and hook code live in one self-contained file; the compiled output is fully equivalent to a hand-written `Agent` subclass.
21
+ - **Instance-level hooks**: every instance has its own hook registry, with hook points spanning the lifecycle, turns, messages, model calls, tool execution, and subagents. A handler can rewrite data, asynchronously wait for external confirmation, or raise `Intercepted` to hard-block the operation — a natural foundation for human approval gates.
22
+ - **Automatic persistence and crash recovery**: messages and state are persisted write-behind; after a crash, replay rebuilds the state. Unpaired tool calls are sealed during recovery, so the model always sees a complete, paired history.
23
+ - **Zero-code tool access**: MCP servers (stdio / SSE / HTTP), shell command templates (arguments auto-escaped), and HTTP endpoints can all become tools from a single declaration file.
24
+ - **Complete exposure options**: eight subcommands — REPL, one-shot CLI, plain HTTP API, a built-in web frontend, CI smoke tests, and more — run the same project unchanged in any form.
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ pip install flowing-agent
30
+ ```
31
+
32
+ ## Quick start
33
+
34
+ Create a directory with five files.
35
+
36
+ `root.fya`:
37
+
38
+ ```yaml
39
+ description: Minimal Q&A assistant
40
+ model_tag: default
41
+ ---
42
+ $system_prompt:
43
+ You are a concise assistant. Answer in at most three sentences.
44
+ ```
45
+
46
+ `main.py`:
47
+
48
+ ```python
49
+ from flowing import Runtime
50
+
51
+ async def main() -> Runtime:
52
+ runtime = Runtime(persist_dir="@/.flowing")
53
+ runtime.set_model_tags("@/model-tags.yaml")
54
+ await runtime.mount("@/root.fya", agent_id="agent-main")
55
+ return runtime
56
+ ```
57
+
58
+ Model access is split into three files, declaring the access identity, the model entries, and the tag mapping:
59
+
60
+ ```yaml
61
+ # providers.yaml
62
+ deepseek:
63
+ adapter: deepseek
64
+ base_url: https://api.deepseek.com
65
+ api_key: "{{env.DEEPSEEK_API_KEY}}"
66
+ openrouter:
67
+ adapter: openrouter
68
+ base_url: https://openrouter.ai/api/v1
69
+ api_key: "{{env.OPENROUTER_API_KEY}}"
70
+ ```
71
+
72
+ ```yaml
73
+ # models.yaml
74
+ luna:
75
+ provider: openrouter
76
+ model: openai/gpt-6-luna
77
+ "reasoning.effort": high
78
+ deepseek-flash:
79
+ provider: deepseek
80
+ model: deepseek-v4-flash
81
+ ```
82
+
83
+ ```yaml
84
+ # model-tags.yaml
85
+ tags:
86
+ default: luna
87
+ ```
88
+
89
+ Run:
90
+
91
+ ```console
92
+ $ export OPENROUTER_API_KEY='<your key>'
93
+ $ flowing repl .
94
+ (agent-main)>>> Introduce yourself in one sentence.
95
+ I'm a concise assistant, keeping answers to three sentences or fewer.
96
+ (agent-main)>>> /exit
97
+ ```
98
+
99
+ The conversation doesn't vanish on exit: the messages it produced are persisted under `.flowing/` in the project directory. A fixed `agent_id` means that running `flowing repl .` again brings back the same agent with its full history — no recovery code required.
100
+
101
+ ## Going further
102
+
103
+ - **Capability access**: declare built-in tools, MCP servers, or shell commands and HTTP endpoints as tools via `tools:`; implement custom logic with `ScriptTool`.
104
+ - **Multi-agent**: declare subagent types under `subagents:` and the orchestrator routes work using the auto-generated catalog; you can also create subagents programmatically and run them in parallel.
105
+ - **Intervention**: attach handlers at hook points — intercept a tool call pending approval, audit at turn completion, switch models and retry on provider errors. The built-in `use_retry` / `use_compact` are implemented in exactly this way and can serve as references.
106
+ - **Embedding**: the host application holds the Runtime returned by `launch()`; input goes through `query` / `message` / `steer`, output through hook subscriptions (streaming output, completion notices, call interception).
107
+
108
+ ## Documentation
109
+
110
+ - [Beginner tutorial](https://flowing-agent.readthedocs.io/en/beginner-tutorial/): for readers new to agent systems development;
111
+ - [Detailed tutorial](https://flowing-agent.readthedocs.io/en/tutorial/): from quick start to core mechanics and operations;
112
+ - [Concise reference](https://flowing-agent.readthedocs.io/en/flowing-ref/): the whole framework in four parts, for quick lookup;
113
+ - [API reference](https://flowing-agent.readthedocs.io/en/api.html): the public API organized by module.
114
+
115
+ ## Project status
116
+
117
+ Current version 0.1.0. The framework core is complete (700+ test cases passing) and the project is in the example-scenarios phase. Breaking changes are still possible during 0.x; every such release ships with a detailed changelog explaining how to migrate.
118
+
119
+ This project was developed with heavy reliance on AI assistance, using models from different providers at different capability levels. Limited by the author's available time, not every line of code has been individually reviewed; if you find any divergence between the implementation and the documentation (docstrings, tutorials), an issue is greatly appreciated.
120
+
121
+ ## License
122
+
123
+ [MIT](LICENSE) © 2026 Nyanifold
124
+
125
+ ---
126
+
127
+ <p align="center">
128
+ <img src="assets/oh-wishes.svg" alt="Oh wishes... I beg you coalesce!">
129
+ </p>
@@ -0,0 +1,188 @@
1
+ """``flowing`` —— 轻量式 Agent 框架:最终 API 规约(顶层导出)。
2
+
3
+ .. rubric:: 功能介绍
4
+
5
+ Flowing 的核心立场是“框架只提供机制,不提供策略”。包结构三层:
6
+
7
+ - **框架核心**:``runtime`` / ``agent`` / ``agent_registry`` /
8
+ ``subagents`` / ``message`` / ``context`` /
9
+ ``parsable`` / ``params`` / ``tool``(子包)/ ``media`` / ``model`` /
10
+ ``hooks`` / ``lists`` / ``errors`` /
11
+ ``snapshot`` / ``providers`` / ``persistence`` / ``parser`` / ``paths`` /
12
+ ``provide`` / ``compiler`` —— 本模块顶层导出其中面向日常使用的符号。
13
+ - **内置扩展**:``flowing.plugins``(``skills`` / ``comm`` / ``cron`` /
14
+ ``workflow`` / ``clipboard``)——随包发布、显式 ``runtime.install(...)`` 启用。
15
+ - **应用层**:``flowing.composables``(以 ``use_xxx(agent, ...)`` 函数向
16
+ Agent 装配应用逻辑与策略)。
17
+
18
+ 运行模型锚点:消息级树(``Message.id`` + ``parent_id`` 链,
19
+ ``current_head_id`` 指向消息 id);Turn 仅为逻辑执行阶段(执行期载体
20
+ :class:`flowing.agent.TurnContext`,不落盘、不进树);三层能力描述
21
+ (可执行对象 / LLM 可见声明 / Agent 级绑定,推广到 Tool / 子 Agent /
22
+ Skill);provide-inject 沿 ``_parent_id`` 链上溯;实例级钩子系统。
23
+
24
+ .. rubric:: 设计动机
25
+
26
+ 顶层导出收敛到“写一个 Agent 项目一定会 import”的最小集合;其余符号
27
+ (异常明细、快照视图、内部容器)经子模块显式导入,保持顶层命名空间
28
+ 可读、可记忆。
29
+
30
+ .. rubric:: 使用示例
31
+
32
+ .. code-block:: python
33
+
34
+ # @/main.py —— 子项目入口约定
35
+ import flowing
36
+ from flowing import Runtime, on
37
+
38
+ async def main(**kwargs) -> Runtime:
39
+ runtime = flowing.Runtime() # @ 由 launch 上下文自动绑定
40
+ runtime.install(...) # 阶段一:安装扩展
41
+ await runtime.mount("@/root.fya") # 创建根 Agent
42
+ return runtime
43
+
44
+ .. code-block:: bash
45
+
46
+ flowing run <path> # launch(path) → await runtime → SIGINT → shutdown
47
+
48
+ .. rubric:: 行为规约
49
+
50
+ - ``flowing.launch(path, **kwargs)`` 是 Runtime 的**唯一创建入口**;
51
+ 绕过它直接 ``Runtime()`` 因无 ``@`` 上下文抛 ``RuntimeError``。
52
+ - 本模块只做 re-export,不定义任何新符号;各符号的完整契约见所属
53
+ 子模块的规约。
54
+ - 稳定性:本模块导出的全部符号属跨版本稳定契约;``_`` 前缀符号与
55
+ ``flowing.interfaces.cli`` / ``flowing.interfaces.web`` 的细节不属稳定边界。
56
+ """
57
+
58
+ from flowing.agent import (
59
+ Agent,
60
+ CancelContext,
61
+ Execution,
62
+ FieldUpdate,
63
+ ProviderErrorContext,
64
+ TurnContext,
65
+ TurnResult,
66
+ )
67
+ from flowing.agent_registry import AgentRegistry
68
+ from flowing.context import Context, PromptBlock, PromptBlockList, PromptSegment
69
+ from flowing.errors import FlowingError, Intercepted
70
+ from flowing.hooks import HookRegistry, on
71
+ from flowing.lists import ManagedList
72
+ from flowing.message import (
73
+ ContentBlock,
74
+ FileBlock,
75
+ ImageBlock,
76
+ MediaBlock,
77
+ Message,
78
+ MessageChain,
79
+ MessageKind,
80
+ MessagePriority,
81
+ MessageQueue,
82
+ StructBlock,
83
+ TextBlock,
84
+ ThinkingBlock,
85
+ ToolCallBlock,
86
+ )
87
+ from flowing.model import (
88
+ ModelConfig,
89
+ )
90
+ from flowing.params import ConfigKey, InjectionKey
91
+ from flowing.parsable import PENDING, Parsable
92
+ from flowing.plugins import Plugin
93
+ from flowing.provide import ProvideNode
94
+ from flowing.providers import (
95
+ Provider,
96
+ ProviderConfig,
97
+ ProviderDelta,
98
+ ProviderResponse,
99
+ Usage,
100
+ )
101
+ from flowing.builtins import FinishTool, SubagentInvokeTool
102
+ from flowing.runtime import Runtime, launch, resolve
103
+ from flowing.subagents import SubagentEntry, SubagentInvocation, SubagentResult
104
+ from flowing.tool import (
105
+ Audio,
106
+ File,
107
+ Image,
108
+ ScriptTool,
109
+ Tool,
110
+ ToolCall,
111
+ ToolDefinition,
112
+ ToolEntry,
113
+ ToolRegistry,
114
+ ToolResult,
115
+ Video,
116
+ flowing_tool,
117
+ normalize_output,
118
+ output_to_blocks,
119
+ register_media_converter,
120
+ )
121
+
122
+ __all__ = [
123
+ "Agent",
124
+ "AgentRegistry",
125
+ "Audio",
126
+ "CancelContext",
127
+ "ConfigKey",
128
+ "ContentBlock",
129
+ "Context",
130
+ "Execution",
131
+ "FieldUpdate",
132
+ "File",
133
+ "FileBlock",
134
+ "FinishTool",
135
+ "FlowingError",
136
+ "ScriptTool",
137
+ "HookRegistry",
138
+ "Image",
139
+ "ImageBlock",
140
+ "InjectionKey",
141
+ "Intercepted",
142
+ "ManagedList",
143
+ "MediaBlock",
144
+ "Message",
145
+ "MessageChain",
146
+ "MessageKind",
147
+ "MessagePriority",
148
+ "MessageQueue",
149
+ "ModelConfig",
150
+ "PENDING",
151
+ "Parsable",
152
+ "Plugin",
153
+ "PromptBlock",
154
+ "PromptBlockList",
155
+ "PromptSegment",
156
+ "ProvideNode",
157
+ "Provider",
158
+ "ProviderConfig",
159
+ "ProviderDelta",
160
+ "ProviderResponse",
161
+ "ProviderErrorContext",
162
+ "Runtime",
163
+ "StructBlock",
164
+ "SubagentEntry",
165
+ "SubagentInvocation",
166
+ "SubagentInvokeTool",
167
+ "SubagentResult",
168
+ "TextBlock",
169
+ "ThinkingBlock",
170
+ "Tool",
171
+ "ToolCall",
172
+ "ToolCallBlock",
173
+ "ToolDefinition",
174
+ "ToolEntry",
175
+ "ToolRegistry",
176
+ "ToolResult",
177
+ "TurnContext",
178
+ "TurnResult",
179
+ "Usage",
180
+ "Video",
181
+ "flowing_tool",
182
+ "launch",
183
+ "normalize_output",
184
+ "on",
185
+ "output_to_blocks",
186
+ "register_media_converter",
187
+ "resolve",
188
+ ]
@@ -0,0 +1,30 @@
1
+ """``flowing._unstable`` —— 实验性命名空间:可导入,但不冻结。
2
+
3
+ .. rubric:: 功能介绍
4
+
5
+ 本包收容“功能已确定、策略 / 接口形态未确定”的自用设施。与
6
+ :mod:`flowing.plugins` 的区别在稳定性承诺:
7
+
8
+ - ``flowing.plugins.*``:内置扩展,契约随框架版本冻结(签名、语义、
9
+ 持久化格式按正常版本纪律演进)。
10
+ - ``flowing._unstable.*``:允许在任何版本中改签名、改名、改语义、
11
+ 整体删除或迁出,不视为 breaking change,不发迁移通告。下划线
12
+ 前缀同时挡住自动导入与“稳定 API”的心理预期。
13
+
14
+ .. rubric:: 毕业规则
15
+
16
+ 某设施的策略确定后,整体迁往正式包(如 ``flowing.plugins``)并在本
17
+ 包留一个 re-export 过渡(仅当下一个 minor 版本);迁入正式包后按
18
+ 正常稳定性纪律管理。
19
+
20
+ .. rubric:: 使用约定
21
+
22
+ - 仅自用 / 内部 debug 场景;下游发布物(插件、workflow、技能包)
23
+ 禁止依赖本包。
24
+ - 本包模块的持久化产物(如日志文件)不构成恢复依赖——框架任何恢复
25
+ 路径不得读取 ``_unstable`` 设施写出的文件。
26
+
27
+ 当前内容::mod:`flowing._unstable.logging` (钩子链路日志插件)。
28
+ """
29
+
30
+ __all__: list[str]