netizen-cli 0.10.0__py3-none-any.whl
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.
- netizen_cli/__init__.py +3 -0
- netizen_cli/__main__.py +4 -0
- netizen_cli/admin/__init__.py +1 -0
- netizen_cli/admin/auth.py +928 -0
- netizen_cli/admin/errors.py +9 -0
- netizen_cli/admin/port_config.py +115 -0
- netizen_cli/admin/presentation.py +257 -0
- netizen_cli/admin/queries.py +337 -0
- netizen_cli/admin/static/admin.css +260 -0
- netizen_cli/admin/static/admin.js +2898 -0
- netizen_cli/admin/static/index.html +327 -0
- netizen_cli/admin/transport.py +935 -0
- netizen_cli/admin/web.py +2717 -0
- netizen_cli/bindings.py +3215 -0
- netizen_cli/builtin_skills.py +93 -0
- netizen_cli/cards/__init__.py +105 -0
- netizen_cli/cards/callbacks.py +565 -0
- netizen_cli/cards/controls.py +2273 -0
- netizen_cli/cards/defaults.py +213 -0
- netizen_cli/cards/model_info.py +80 -0
- netizen_cli/cards/questions.py +220 -0
- netizen_cli/cards/reply.py +2247 -0
- netizen_cli/cards/scheduled.py +836 -0
- netizen_cli/channel/__init__.py +1 -0
- netizen_cli/channel/completion_mentions.py +60 -0
- netizen_cli/channel/input_preparation.py +644 -0
- netizen_cli/channel/messages.py +57 -0
- netizen_cli/channel/ports.py +52 -0
- netizen_cli/channel/question_inputs.py +51 -0
- netizen_cli/channel/reactions.py +293 -0
- netizen_cli/channel/reply_presenter.py +1505 -0
- netizen_cli/channel/topics.py +70 -0
- netizen_cli/channel_app.py +6593 -0
- netizen_cli/cli.py +287 -0
- netizen_cli/cli_data.py +536 -0
- netizen_cli/cli_packages.py +526 -0
- netizen_cli/cli_services.py +651 -0
- netizen_cli/cli_setup.py +242 -0
- netizen_cli/cli_update.py +303 -0
- netizen_cli/cli_update_restore.py +53 -0
- netizen_cli/cli_update_worker.py +333 -0
- netizen_cli/codex_runtime.py +7125 -0
- netizen_cli/completion_mention.py +16 -0
- netizen_cli/database_migrations.py +218 -0
- netizen_cli/defaults/__init__.py +5 -0
- netizen_cli/defaults/models.py +39 -0
- netizen_cli/defaults/service.py +232 -0
- netizen_cli/defaults/store.py +260 -0
- netizen_cli/deployment/__init__.py +1 -0
- netizen_cli/deployment/restart_worker.py +134 -0
- netizen_cli/deployment/update_executor.py +258 -0
- netizen_cli/deployment/update_protocol.py +281 -0
- netizen_cli/domain.py +416 -0
- netizen_cli/error_messages.py +124 -0
- netizen_cli/experience.py +531 -0
- netizen_cli/feishu_app_onboarding.py +187 -0
- netizen_cli/feishu_app_permissions.py +123 -0
- netizen_cli/git_status.py +63 -0
- netizen_cli/image_inputs.py +579 -0
- netizen_cli/instance.py +84 -0
- netizen_cli/lark_app.py +125 -0
- netizen_cli/main.py +903 -0
- netizen_cli/management/__init__.py +83 -0
- netizen_cli/management/blocking_io.py +352 -0
- netizen_cli/management/chat_labels.py +266 -0
- netizen_cli/management/coordination.py +32 -0
- netizen_cli/management/service.py +2187 -0
- netizen_cli/management/updates.py +214 -0
- netizen_cli/markdown_images.py +78 -0
- netizen_cli/message_content.py +786 -0
- netizen_cli/message_history.py +643 -0
- netizen_cli/message_preparation.py +60 -0
- netizen_cli/message_projection.py +923 -0
- netizen_cli/migrations/__init__.py +1 -0
- netizen_cli/migrations/schema.py +103 -0
- netizen_cli/migrations/v14.py +438 -0
- netizen_cli/model_settings.py +269 -0
- netizen_cli/package_resources.py +22 -0
- netizen_cli/projects.py +327 -0
- netizen_cli/prompt_projection.py +327 -0
- netizen_cli/quoted_context.py +312 -0
- netizen_cli/resources/config.example.yaml +35 -0
- netizen_cli/resources/skills/netizen-lark/SKILL.md +64 -0
- netizen_cli/resources/skills/netizen-user-guide/SKILL.md +37 -0
- netizen_cli/resources/skills/netizen-user-guide/references/user-guide.md +842 -0
- netizen_cli/result_images.py +123 -0
- netizen_cli/runtime/__init__.py +1 -0
- netizen_cli/runtime/contracts.py +792 -0
- netizen_cli/runtime/name_writes.py +67 -0
- netizen_cli/runtime/thread_naming.py +451 -0
- netizen_cli/schedules/__init__.py +1 -0
- netizen_cli/schedules/mcp.py +535 -0
- netizen_cli/schedules/models.py +394 -0
- netizen_cli/schedules/scheduler.py +374 -0
- netizen_cli/schedules/service.py +766 -0
- netizen_cli/schedules/store.py +771 -0
- netizen_cli/sdk_gap_adapter.py +1151 -0
- netizen_cli/service_launcher.py +583 -0
- netizen_cli/session_settings.py +126 -0
- netizen_cli/settings.py +216 -0
- netizen_cli/skill_references.py +40 -0
- netizen_cli/terminal_cleanup.py +155 -0
- netizen_cli/turn_activity.py +688 -0
- netizen_cli/turn_files.py +812 -0
- netizen_cli/turn_patch_children.py +254 -0
- netizen_cli/turn_plan_observer.py +315 -0
- netizen_cli/user_questions.py +106 -0
- netizen_cli-0.10.0.dist-info/METADATA +18 -0
- netizen_cli-0.10.0.dist-info/RECORD +112 -0
- netizen_cli-0.10.0.dist-info/WHEEL +5 -0
- netizen_cli-0.10.0.dist-info/entry_points.txt +2 -0
- netizen_cli-0.10.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""Public Channel sends for fresh topics, with bounded same-UUID reconciliation."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from lark_channel import SendOpts
|
|
9
|
+
|
|
10
|
+
from .messages import _nonempty_field, _object_field
|
|
11
|
+
from .ports import ReplyChannel
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class TopicPublishError(RuntimeError):
|
|
15
|
+
def __init__(self, message: str, *, unknown: bool = False) -> None:
|
|
16
|
+
super().__init__(message)
|
|
17
|
+
self.unknown = unknown
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@dataclass(frozen=True, slots=True)
|
|
21
|
+
class TopicMessage:
|
|
22
|
+
message_id: str
|
|
23
|
+
chat_id: str
|
|
24
|
+
thread_id: str | None
|
|
25
|
+
root_id: str | None
|
|
26
|
+
parent_id: str | None
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
async def send_topic_message(channel: ReplyChannel, chat_id: str, content: Any, opts: SendOpts) -> TopicMessage:
|
|
30
|
+
if not opts.uuid:
|
|
31
|
+
raise TopicPublishError("话题消息缺少确定性发送 UUID。")
|
|
32
|
+
uncertain = False
|
|
33
|
+
for attempt in range(2):
|
|
34
|
+
try:
|
|
35
|
+
result = await channel.send(chat_id, content, opts)
|
|
36
|
+
except Exception as error:
|
|
37
|
+
uncertain = True
|
|
38
|
+
if attempt == 0:
|
|
39
|
+
continue
|
|
40
|
+
raise TopicPublishError("话题发布结果未确认;同 UUID 有界对账也未成功。", unknown=True) from error
|
|
41
|
+
if getattr(result, "success", None) is not True and getattr(getattr(result, "error", None), "retryable", None) is True:
|
|
42
|
+
uncertain = True
|
|
43
|
+
if attempt == 0:
|
|
44
|
+
continue
|
|
45
|
+
raise TopicPublishError("话题发布结果未确认;同 UUID 对账仍返回可重试失败。", unknown=True)
|
|
46
|
+
try:
|
|
47
|
+
return validate_topic_message(result, chat_id)
|
|
48
|
+
except TopicPublishError as error:
|
|
49
|
+
if uncertain and not error.unknown:
|
|
50
|
+
raise TopicPublishError(str(error), unknown=True) from error
|
|
51
|
+
raise
|
|
52
|
+
raise AssertionError("unreachable send budget")
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def validate_topic_message(result: object, chat_id: str) -> TopicMessage:
|
|
56
|
+
raw = getattr(result, "raw", None)
|
|
57
|
+
code = _object_field(raw, "code")
|
|
58
|
+
if code == 230071:
|
|
59
|
+
raise TopicPublishError("当前飞书会话不支持创建话题(230071)。")
|
|
60
|
+
if getattr(result, "success", None) is not True:
|
|
61
|
+
raise TopicPublishError(f"飞书未确认消息发送成功(code={code!r})。")
|
|
62
|
+
data = _object_field(raw, "data")
|
|
63
|
+
message_id = _nonempty_field(result, "message_id")
|
|
64
|
+
if (
|
|
65
|
+
code != 0 or getattr(result, "chunk_ids", None) or data is None
|
|
66
|
+
or message_id is None or _nonempty_field(data, "message_id") != message_id
|
|
67
|
+
or _nonempty_field(data, "chat_id") != chat_id
|
|
68
|
+
):
|
|
69
|
+
raise TopicPublishError("飞书消息响应缺少一致的 exact 消息和聊天标识。", unknown=True)
|
|
70
|
+
return TopicMessage(message_id, chat_id, _nonempty_field(data, "thread_id"), _nonempty_field(data, "root_id"), _nonempty_field(data, "parent_id"))
|