python-tty 0.1.5__tar.gz → 0.1.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. {python_tty-0.1.5/src/python_tty.egg-info → python_tty-0.1.7}/PKG-INFO +1 -1
  2. {python_tty-0.1.5 → python_tty-0.1.7}/docs/LOG.md +93 -0
  3. {python_tty-0.1.5 → python_tty-0.1.7}/docs/context.md +734 -147
  4. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/commands/mixins.py +1 -1
  5. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/config/config.py +5 -1
  6. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/console_factory.py +11 -6
  7. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/consoles/core.py +18 -10
  8. python_tty-0.1.7/src/python_tty/executor/execution.py +105 -0
  9. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/executor/executor.py +136 -107
  10. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/executor/models.py +2 -0
  11. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/runtime/__init__.py +20 -0
  12. python_tty-0.1.7/src/python_tty/runtime/context.py +48 -0
  13. python_tty-0.1.7/src/python_tty/runtime/event_bus.py +59 -0
  14. python_tty-0.1.7/src/python_tty/runtime/jobs.py +256 -0
  15. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/runtime/router.py +16 -20
  16. python_tty-0.1.7/src/python_tty/runtime/sinks.py +31 -0
  17. {python_tty-0.1.5 → python_tty-0.1.7/src/python_tty.egg-info}/PKG-INFO +1 -1
  18. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty.egg-info/SOURCES.txt +5 -0
  19. {python_tty-0.1.5 → python_tty-0.1.7}/.github/workflows/python-publish.yml +0 -0
  20. {python_tty-0.1.5 → python_tty-0.1.7}/.gitignore +0 -0
  21. {python_tty-0.1.5 → python_tty-0.1.7}/LICENSE +0 -0
  22. {python_tty-0.1.5 → python_tty-0.1.7}/MANIFEST.in +0 -0
  23. {python_tty-0.1.5 → python_tty-0.1.7}/NOTICE +0 -0
  24. {python_tty-0.1.5 → python_tty-0.1.7}/README.md +0 -0
  25. {python_tty-0.1.5 → python_tty-0.1.7}/README_zh.md +0 -0
  26. {python_tty-0.1.5 → python_tty-0.1.7}/demos/__init__.py +0 -0
  27. {python_tty-0.1.5 → python_tty-0.1.7}/demos/chat_room/__init__.py +0 -0
  28. {python_tty-0.1.5 → python_tty-0.1.7}/demos/file_manager/__init__.py +0 -0
  29. {python_tty-0.1.5 → python_tty-0.1.7}/demos/file_manager/commands/__init__.py +0 -0
  30. {python_tty-0.1.5 → python_tty-0.1.7}/demos/file_manager/commands/root_commands.py +0 -0
  31. {python_tty-0.1.5 → python_tty-0.1.7}/demos/file_manager/consoles/__init__.py +0 -0
  32. {python_tty-0.1.5 → python_tty-0.1.7}/demos/file_manager/consoles/root.py +0 -0
  33. {python_tty-0.1.5 → python_tty-0.1.7}/demos/file_manager/core/__init__.py +0 -0
  34. {python_tty-0.1.5 → python_tty-0.1.7}/demos/file_manager/core/file_manager.py +0 -0
  35. {python_tty-0.1.5 → python_tty-0.1.7}/demos/file_manager/exceptions/__init__.py +0 -0
  36. {python_tty-0.1.5 → python_tty-0.1.7}/demos/file_manager/exceptions/console_exception.py +0 -0
  37. {python_tty-0.1.5 → python_tty-0.1.7}/demos/file_manager/main.py +0 -0
  38. {python_tty-0.1.5 → python_tty-0.1.7}/demos/file_manager/setup.py +0 -0
  39. {python_tty-0.1.5 → python_tty-0.1.7}/demos/file_manager/utils/__init__.py +0 -0
  40. {python_tty-0.1.5 → python_tty-0.1.7}/demos/file_manager/utils/table.py +0 -0
  41. {python_tty-0.1.5 → python_tty-0.1.7}/pyproject.toml +0 -0
  42. {python_tty-0.1.5 → python_tty-0.1.7}/requirements.txt +0 -0
  43. {python_tty-0.1.5 → python_tty-0.1.7}/setup.cfg +0 -0
  44. {python_tty-0.1.5 → python_tty-0.1.7}/setup.py +0 -0
  45. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/__init__.py +0 -0
  46. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/audit/__init__.py +0 -0
  47. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/audit/sink.py +0 -0
  48. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/audit/ui_logger.py +0 -0
  49. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/commands/__init__.py +0 -0
  50. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/commands/core.py +0 -0
  51. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/commands/decorators.py +0 -0
  52. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/commands/examples/__init__.py +0 -0
  53. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/commands/examples/root_commands.py +0 -0
  54. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/commands/examples/sub_commands.py +0 -0
  55. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/commands/general.py +0 -0
  56. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/commands/registry.py +0 -0
  57. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/config/__init__.py +0 -0
  58. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/consoles/__init__.py +0 -0
  59. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/consoles/decorators.py +0 -0
  60. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/consoles/examples/__init__.py +0 -0
  61. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/consoles/examples/root_console.py +0 -0
  62. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/consoles/examples/sub_console.py +0 -0
  63. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/consoles/loader.py +0 -0
  64. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/consoles/manager.py +0 -0
  65. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/consoles/registry.py +0 -0
  66. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/exceptions/__init__.py +0 -0
  67. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/exceptions/console_exception.py +0 -0
  68. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/executor/__init__.py +0 -0
  69. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/frontends/__init__.py +0 -0
  70. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/frontends/rpc/__init__.py +0 -0
  71. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/frontends/web/__init__.py +0 -0
  72. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/meta/__init__.py +0 -0
  73. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/runtime/events.py +0 -0
  74. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/runtime/provider.py +0 -0
  75. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/utils/__init__.py +0 -0
  76. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/utils/table.py +0 -0
  77. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty/utils/tokenize.py +0 -0
  78. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty.egg-info/dependency_links.txt +0 -0
  79. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty.egg-info/requires.txt +0 -0
  80. {python_tty-0.1.5 → python_tty-0.1.7}/src/python_tty.egg-info/top_level.txt +0 -0
  81. {python_tty-0.1.5 → python_tty-0.1.7}/tests/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-tty
3
- Version: 0.1.5
3
+ Version: 0.1.7
4
4
  Summary: A multi-console TTY framework for complex CLI/TTY apps
5
5
  Home-page: https://github.com/ROOKIEMIE/python-tty
6
6
  Author: ROOKIEMIE
@@ -1,5 +1,98 @@
1
1
  # 阶段记录
2
2
 
3
+ ## 2026/02/02
4
+
5
+ 目标:
6
+ 1. Milestone A:Kernel 固化 + Job API(不做 RPC)
7
+ - 交付物
8
+ - 完整 RuntimeEvent 流(含 stdout/log,支持 run_id 关联)
9
+ - JobStore + 基础操作(list/get/cancel/events/result)
10
+ - TTY 侧:新增 jobs 命令族(只是前端展示,不改变内核)
11
+ 2. Milestone B:proto + grpc aio server(RPC 独立 submit)
12
+ - 交付物
13
+ - runtime.proto(Invoke + StreamEvents)
14
+ - RPC 侧:构建 ExecutionContext → Invocation → executor.submit(source=rpc)
15
+ - StreamEvents 从 JobStore/EventBus 订阅事件
16
+
17
+ 落地细节:
18
+ 1. 固化中心链路:Executor + RuntimeEvent + Audit 不依赖 TTY/RPC
19
+
20
+ 事件“采集”与事件“消费”必须分层
21
+
22
+ 1.1.
23
+ 目前的问题:
24
+ stdout/log 目前很多还是走 router(proxy_print)→ UIEvent,这会导致 RPC/Job 无法看到过程输出
25
+
26
+ 引入机制:Run 上下文传播(contextvar 或显式参数)
27
+ - 执行某个 invocation 时,executor 在运行 handler 前设置 current_run_id(contextvar)
28
+ - proxy_print() 如果发现存在 current_run_id,则发布 RuntimeEvent(kind=STDOUT/LOG, run_id=...) 给 executor/eventhub,同时仍可选渲染到 TTY
29
+
30
+ 1.2. 构建事件消费层(Frontends / Sinks)
31
+ - TTY:订阅 RuntimeEvent → to_ui_event → 渲染
32
+ - RPC:订阅 RuntimeEvent → proto → streaming
33
+ - Audit:订阅 RuntimeEvent + run_state → 落盘
34
+ - Web:订阅 RuntimeEvent + meta snapshot → WS push
35
+
36
+ 2. Job 管理:给一个基本组件 + 为 Session 留空间
37
+ 对外的 JobStore / JobAPI(可被 TTY/RPC 同时使用)。
38
+ 2.1. 最小 JobStore 接口(建议就这些):
39
+ - list(filters):按 status/source/principal/command_id 查询
40
+ - get(run_id):返回 RunState + 元信息(Invocation 摘要)
41
+ - cancel(run_id)
42
+ - events(run_id, since_seq=0):订阅事件(最好支持 fanout)
43
+ - result(run_id):等结果(可选 timeout)
44
+
45
+ 2.2. 为 Session 留哪些空间
46
+ Session 本质是“跨多次 invocation 的上下文容器”,先不实现它,但要预留 2 个钩子就够:
47
+ - Invocation.session_id: Optional[str](或放到 invocation.tags/kwargs)
48
+ - lock_key 未来可从 global → session:{session_id}(你说 global 会用很久完全 OK,但先把字段语义预留)
49
+
50
+ 3. ExecutionContext:从 TTY 抽象最小执行上下文,让 RPC 复用
51
+
52
+ 3.1. ExecutionContext 应该是什么
53
+ 它不是 Console,也不是 Commands。它应该是一个纯运行时载体:
54
+ - source(tty/rpc)
55
+ - principal(用户/客户端)
56
+ - console_path(console_name,可选)
57
+ - command_path(command_name / command_id)
58
+ - argv/raw_cmd
59
+ - run_id(提交后填)
60
+ - meta_revision(可选:客户端携带)
61
+ - session_id(预留)
62
+ - deadline/timeout_ms
63
+ - lock_key(默认 global)
64
+
65
+ 它的职责:
66
+ - 承载调用意图
67
+ - 参与校验(argspec / meta revision / allowlist)
68
+ - 构建 Invocation
69
+
70
+ 3.2. “命令执行”需要谁来做
71
+ 执行永远是 executor handler 做。ExecutionContext 只负责把“调用意图”变成 invocation。
72
+
73
+ 3.3. 增加一个ExecutionBinding(适配器)用以解决“必须通过console才能拿到service”的问题
74
+ - ExecutionBinding(service, manager, ctx)
75
+ - 让 Commands 在执行时能访问 binding.service
76
+ - TTY binding 的 service 来自 main console 注入
77
+ - RPC binding 的 service 来自 factory 注入(同一实例)
78
+ 这比“RPC 必须构造 console”更干净:你把“获取业务核心”的依赖从 console 语义里抽出来了。
79
+
80
+ 4. 先定义 proto,再完善 RPC:proto 要按“运行时协议”来,而不是按“TTY 命令对象”来
81
+
82
+ 4.1. proto 的核心应该只围绕三件事
83
+ - InvokeRequest/InvokeReply(返回 run_id)
84
+ - StreamEventsRequest(run_id + since_seq)
85
+ - RuntimeEvent(state/log/stdout + seq + ts + level + payload)
86
+ 不要把 UIEvent/Prompt 这类东西放进去。
87
+
88
+ 4.2. 一个必须提前考虑的问题:事件 fanout
89
+ 一个 run_id 同时被 TTY 显示、RPC client 订阅、Audit 记录,那么 per-run events 不能是单消费者 queue。
90
+
91
+ 现在就把事件模型做成:
92
+ - RunEventBus:每个订阅者拿一个独立 queue
93
+ - publish 时广播
94
+ 否则你很快会遇到“RPC 订阅把事件读走了,TTY 就看不到了”的问题。
95
+
3
96
  ## 2026/01/27/02
4
97
 
5
98
  1. rpc侧应该模仿console/core模块中execute和run方法的实现,重新构建invocation并投递至executor,source为rpc。不要复用现有console的submit过程,应该形成一条独立的submit过程。