feat(sdk): 普通 prompt 逐条上报用户时区

session/prompt 与 session/query 接受可选 timeZone,TS/Python 客户端透传;省略时逐条采样进程时区,写入 sdk-user 来源的 clientTimeZone。time-context 读取不带 rpcId 的 user 来源时区。补持久化记录、Agent Note、升级指南、README,并刷新 SDK snapshot。
This commit is contained in:
yudshj committed 2026-11-19 11:58:00 +08:00
1 parent 71ce86fae6
commit dca075e2a2
109 files changed
+1428 -421

No files matched your search

+8 -3
View File
@@ -193,9 +193,10 @@ class DeepSeekHarness:
*,
session_id: str | None = None,
on_notification: Callable[[Notification], None] | None = None,
time_zone: str | None = None,
) -> RunResult:
"""Run input to completion on a fresh or named Session and return its RunResult."""
return self.start_session(session_id).run(input, on_notification=on_notification)
return self.start_session(session_id).run(input, on_notification=on_notification, time_zone=time_zone)
class Session:
@@ -218,6 +219,7 @@ class Session:
input: str | list[JsonObject],
*,
on_notification: Callable[[Notification], None] | None = None,
time_zone: str | None = None,
) -> RunResult:
"""Run text or content blocks through native input routing.
@@ -232,11 +234,14 @@ class Session:
wire order. Every result retains this Session id, its root events and
Session-tree notifications, including overlapping work. Native refusals
return finish_reason="error". Routing, transport and observer failures
raise without rolling back work.
raise without rolling back work. ``time_zone`` is the user zone for an
ordinary prompt, UTC or an IANA Area/Location name; omitted, the runtime
samples its process zone. Native commands record no zone, and an invalid
zone raises before routing.
"""
self.harness.start()
with self.harness.client.subscribe_session_notifications(self.id) as subscription:
response = self.harness.client._query(self.id, input)
response = self.harness.client._query(self.id, input, time_zone)
if isinstance(response, CommandExecution):
activity = _RunActivity(self.id, "command", response.command_id)
while True:
+12 -4
View File
@@ -205,8 +205,15 @@ class HarnessClient:
*,
on_notification: Callable[[Notification], None] | None = None,
notification_subscription: "NotificationSubscription | None" = None,
time_zone: str | None = None,
) -> str:
"""Queue one prompt without command routing and return its message id.
``time_zone`` is UTC or an IANA Area/Location name; omitted, the runtime samples its process zone.
"""
payload: JsonObject = {"sessionId": session_id, "contentBlocks": content_blocks}
if time_zone is not None:
payload["timeZone"] = time_zone
response = self.request(
"session/prompt",
payload,
@@ -235,13 +242,14 @@ class HarnessClient:
)
def _query(
self, session_id: str, input: str | list[JsonObject],
self, session_id: str, input: str | list[JsonObject], time_zone: str | None = None,
) -> str | CommandExecution:
"""Return a validated prompt receipt or command result for high-level run callers."""
blocks = [{"type": "text", "text": input}] if isinstance(input, str) else input
result = self._request_raw("session/query", {
"sessionId": session_id, "contentBlocks": blocks,
})
params: JsonObject = {"sessionId": session_id, "contentBlocks": blocks}
if time_zone is not None:
params["timeZone"] = time_zone
result = self._request_raw("session/query", params)
if isinstance(result, dict):
if result.get("kind") == "prompt" and isinstance(result.get("messageId"), str) and result["messageId"]:
return result["messageId"]