Merge master and integrate image offload with both DeepSeek protocols

This commit is contained in:
creatixchu committed 2026-09-14 10:19:11 +08:00
commit a7070008e7
2052 files changed
+727131 -33615

No files matched your search

+1 -1
View File
@@ -2,5 +2,5 @@
# side as of the last confirmed-consistent state. Both languages carry equal authority;
# after editing either side, bring the other along and re-record with:
# pnpm run verify-translation-pairing --write python/sdk-runtime/README.md
README.md: ce733b8f293e974ec051e600c187e0741117ab46
README.md: 8ab226427f89d2746d6da13bcd8bd254731f2460
README.zh.md: 23a042006c38425a83347322fa63f0fafb319d0d
+1 -1
View File
@@ -35,4 +35,4 @@ Production deployment permits unused workspace patches for packages outside the
From the repository root, `pnpm exec tsx scripts/build-exe-for-python-sdk.ts` verifies the closure, builds packages, deploys a symlink-free tree, packages the selected target, and syncs the executable and sidecars into this module. `scripts/build-python-release.py` stages release-shaped wheels at the root repository version and pins `deepseek-harness-sdk` to the exact runtime version.
The installed-wheel smoke creates a clean virtual environment outside the checkout, proves distribution and executable provenance, then exercises default and customized SDK profiles, external plugins, MCP, native tools, direct JSON-RPC, committed snapshots, and the real provider on trusted runs. See the [Python contributor workflow](../development.md) and [installed-wheel testing decision](../../.agents/notes/implemented/testing/2026-08-23-installed-python-wheel-black-box-ci.md).
The installed-wheel smoke creates a clean virtual environment outside the checkout, proves the installed distribution and executable identities, then exercises default and customized SDK profiles, external plugins, MCP, native tools, direct JSON-RPC, committed snapshots, and the real provider on trusted runs. See the [Python contributor workflow](../development.md) and [installed-wheel testing decision](../../.agents/notes/implemented/testing/2026-08-23-installed-python-wheel-black-box-ci.md).
+3 -3
View File
@@ -24,8 +24,8 @@
"@deepseek-ai/dsh-authorization": "workspace:^",
"@deepseek-ai/dsh-bash-local": "workspace:^",
"@deepseek-ai/dsh-brand": "workspace:^",
"@deepseek-ai/dsh-code-runtime": "workspace:^",
"@deepseek-ai/dsh-code-runtime-worker-thread": "workspace:^",
"@deepseek-ai/dsh-ptc-runtime": "workspace:^",
"@deepseek-ai/dsh-ptc-runtime-node": "workspace:^",
"@deepseek-ai/dsh-command-compact": "workspace:^",
"@deepseek-ai/dsh-command-goal": "workspace:^",
"@deepseek-ai/dsh-commands": "workspace:^",
@@ -130,7 +130,7 @@
"@deepseek-ai/dsh-web-search-exa": "workspace:^",
"@deepseek-ai/dsh-web-search-perplexity": "workspace:^",
"@deepseek-ai/dsh-workflow": "workspace:^",
"@deepseek-ai/dsh-workflow-worker-thread": "workspace:^",
"@deepseek-ai/dsh-workflow-ptc": "workspace:^",
"@deepseek-ai/schemastery": "workspace:^"
}
}
+11 -1
View File
@@ -1,10 +1,20 @@
#!/usr/bin/env node
/** Private entry owned by the Python single-file runtime packaging. */
import { fileURLToPath } from 'node:url'
const selectorName = 'DSH_SUBPROCESS_RUNNER'
const selection = process.env[selectorName]
const aclRunner = process.platform === 'win32'
? fileURLToPath(import.meta.resolve('@deepseek-ai/dsh-sandbox-windows-acl/runner'))
: undefined
if (selection === undefined) {
if (aclRunner !== undefined && process.argv[2] === aclRunner) {
process.argv.splice(1, 1)
await import('@deepseek-ai/dsh-sandbox-windows-acl/runner')
} else if (process.env.DSH_PTC_RUNTIME_NODE === '1') {
Reflect.deleteProperty(process.env, 'DSH_PTC_RUNTIME_NODE')
await import('@deepseek-ai/dsh-ptc-runtime-node/process')
} else if (selection === undefined) {
const { runCli } = await import('@deepseek-ai/dsh/lib/bin.js')
await runCli()
} else {
+93 -1
View File
@@ -13,7 +13,7 @@ from deepseek_harness import DeepSeekHarness, HarnessClient, HarnessConfig, Noti
from deepseek_harness.errors import JsonRpcError
def test_high_level_sdk_runs_turn_and_collects_final_response(tmp_path: Path) -> None:
def test_high_level_sdk_runs_turn_and_preserves_auto_review_errors(tmp_path: Path) -> None:
script = tmp_path / "fake_runtime.py"
env_dump = tmp_path / "env.json"
init_dump = tmp_path / "init.json"
@@ -43,6 +43,77 @@ for line in sys.stdin:
print(json.dumps({"jsonrpc": "2.0", "method": "session.event", "params": {"sessionId": params["sessionId"], "event": {"type": "agent/inbox/spliced", "data": {"target": "next-turn", "start": 0, "inserted": [{"id": "message-1"}]}}}}), flush=True)
print(json.dumps({"jsonrpc": "2.0", "method": "session.status", "params": {"sessionId": params["sessionId"], "status": "running"}}), flush=True)
print(json.dumps({"jsonrpc": "2.0", "id": msg["id"], "result": {"messageId": "message-1"}}), flush=True)
print(json.dumps({
"jsonrpc": "2.0",
"method": "session.event",
"params": {
"sessionId": params["sessionId"],
"event": {
"type": "tool/result",
"data": {
"turn": 1,
"step": 1,
"message": {
"source": {"kind": "tool", "callId": "native-call"},
"content": [{
"type": "tool-result",
"toolCallId": "native-call",
"content": [{"type": "text", "text": "Error: blocked by policy"}],
"isError": True,
}],
"role": "user",
"id": "native-result",
},
"error": {
"name": "AutoReviewDeniedError",
"code": "AUTO_REVIEW_DENIED",
"reason": " native raw\\nreason ",
},
},
},
},
}), flush=True)
print(json.dumps({
"jsonrpc": "2.0",
"method": "session.event",
"params": {
"sessionId": params["sessionId"],
"event": {
"type": "tool/ptc-dispatch-start",
"data": {
"rootCallId": "run-code-call",
"parentCallId": "run-code-call",
"subCallId": "run-code-call:ptc:1",
"name": "bash",
"arguments": {"command": "git push --force"},
},
},
},
}), flush=True)
print(json.dumps({
"jsonrpc": "2.0",
"method": "session.event",
"params": {
"sessionId": params["sessionId"],
"event": {
"type": "tool/ptc-dispatch",
"data": {
"rootCallId": "run-code-call",
"parentCallId": "run-code-call",
"subCallId": "run-code-call:ptc:1",
"name": "bash",
"arguments": {"command": "git push --force"},
"isError": True,
"content": [{"type": "text", "text": "Error: blocked by policy"}],
"error": {
"name": "AutoReviewDeniedError",
"code": "AUTO_REVIEW_DENIED",
"reason": " ptc raw\\nreason ",
},
},
},
},
}), flush=True)
print(json.dumps({
"jsonrpc": "2.0",
"method": "session.event",
@@ -110,6 +181,27 @@ for line in sys.stdin:
assert result.final_response == "hello from runtime"
assert result.finish_reason == "max-tokens"
assert result.events[-1]["type"] == "turn/end"
projected_errors = [
event["data"]["error"]
for event in result.events
if event["type"] in {"tool/result", "tool/ptc-dispatch"}
]
assert projected_errors == [
{
"name": "AutoReviewDeniedError",
"code": "AUTO_REVIEW_DENIED",
"reason": " native raw\nreason ",
},
{
"name": "AutoReviewDeniedError",
"code": "AUTO_REVIEW_DENIED",
"reason": " ptc raw\nreason ",
},
]
ptc_events = [event for event in result.events if event["type"].startswith("tool/ptc-dispatch")]
assert [event["type"] for event in ptc_events] == ["tool/ptc-dispatch-start", "tool/ptc-dispatch"]
for event in ptc_events:
assert not {"description", "parameters", "schema"}.intersection(event["data"])
dumped_env = json.loads(env_dump.read_text())
assert dumped_env["DEEPSEEK_API_KEY"] == "env-key"
assert dumped_env["DEEPSEEK_BASE_URL"] == "http://127.0.0.1:4321"
+40 -22
View File
@@ -3,6 +3,7 @@ from __future__ import annotations
import json
import runpy
import subprocess
import urllib.request
from pathlib import Path
from types import SimpleNamespace
@@ -170,59 +171,76 @@ def test_live_smoke_rejects_unrelated_tool_without_exact_receipt(
def test_child_prompt_precedes_runtime_context(prompt_name: str, expected: str) -> None:
chunks = SMOKE["completion_chunks"]({
"messages": [
{"role": "user", "content": SMOKE[prompt_name]},
{"role": "user", "content": "Current runtime context"},
{"role": "user", "content": [
{"type": "text", "text": SMOKE[prompt_name]},
{"type": "text", "text": "Current runtime context"},
]},
],
})
assert any(
choice.get("delta", {}).get("content") == expected
chunk.get("delta", {}).get("text") == expected
for chunk in chunks
for choice in chunk.get("choices", [])
)
def test_mcp_smoke_requests_the_discovered_tool() -> None:
chunks = SMOKE["completion_chunks"]({
"messages": [{"role": "user", "content": SMOKE["MCP_PROMPT"]}],
"tools": [{"type": "function", "function": {"name": "mcp__fixture__add"}}],
"messages": [{"role": "user", "content": [{"type": "text", "text": SMOKE["MCP_PROMPT"]}]}],
"tools": [{"name": "mcp__fixture__add", "input_schema": {"type": "object"}}],
})
calls = [
call
chunk["content_block"]
for chunk in chunks
for choice in chunk.get("choices", [])
for call in choice.get("delta", {}).get("tool_calls", [])
if chunk.get("type") == "content_block_start"
]
assert calls[0]["function"] == {
"name": "mcp__fixture__add",
"arguments": '{"a": 19, "b": 23}',
}
assert calls == [{"type": "tool_use", "id": "mcp-add", "name": "mcp__fixture__add", "input": {}}]
arguments = next(chunk["delta"]["partial_json"] for chunk in chunks if chunk.get("type") == "content_block_delta")
assert json.loads(arguments) == {"a": 19, "b": 23}
def test_mcp_smoke_accepts_the_external_server_result() -> None:
chunks = SMOKE["completion_chunks"]({
"messages": [
{"role": "user", "content": SMOKE["MCP_PROMPT"]},
{"role": "user", "content": [{"type": "text", "text": SMOKE["MCP_PROMPT"]}]},
{
"role": "assistant",
"tool_calls": [{
"id": "mcp-add",
"type": "function",
"function": {"name": "mcp__fixture__add", "arguments": '{}'},
"content": [{
"type": "tool_use", "id": "mcp-add", "name": "mcp__fixture__add", "input": {},
}],
},
{"role": "tool", "tool_call_id": "mcp-add", "content": "42"},
{"role": "user", "content": [
{"type": "tool_result", "tool_use_id": "mcp-add", "content": [{"type": "text", "text": "42"}]},
]},
],
})
assert any(
choice.get("delta", {}).get("content") == SMOKE["MCP_TEXT"]
chunk.get("delta", {}).get("text") == SMOKE["MCP_TEXT"]
for chunk in chunks
for choice in chunk.get("choices", [])
)
def test_mock_model_serves_native_messages_events() -> None:
with SMOKE["MockModel"]() as model:
body = {"model": "smoke-model", "stream": True, "messages": [{
"role": "user", "content": [{"type": "text", "text": "hello"}],
}]}
request = urllib.request.Request(
model.url + "/v1/messages", data=json.dumps(body).encode(),
headers={"content-type": "application/json"},
)
with urllib.request.urlopen(request) as response:
stream = response.read().decode()
frames = [frame.splitlines() for frame in stream.strip().split("\n\n")]
events = [json.loads(frame[1].removeprefix("data: ")) for frame in frames]
assert all(frame[0] == f"event: {event['type']}" for frame, event in zip(frames, events))
assert events[0]["type"] == "message_start"
assert events[-1] == {"type": "message_stop"}
assert next(event["delta"]["text"] for event in events if event["type"] == "content_block_delta") == SMOKE["EXPECTED_TEXT"]
def test_advanced_snapshot_normalizes_catalog_child_creation_time() -> None:
value = {
"type": "subagent/catalog",
@@ -244,7 +262,7 @@ def test_advanced_snapshot_normalizes_catalog_child_creation_time() -> None:
) == {"type": "fixture/event", "data": {"childCreatedAt": 1788246207176}}
def test_snapshot_comparison_preserves_opaque_generation_provenance() -> None:
def test_snapshot_comparison_preserves_opaque_generation_qualifiers() -> None:
normalize = SMOKE["normalize_session_format_comparison"]
expected = {
"header": {"type": "session", "version": 0, "otherVersion": 7},