release: bump version to 0.81.0
ci / backend (push) Waiting to run
ci / frontend (push) Waiting to run

This commit is contained in:
linkong committed 2026-11-30 19:39:29 +08:00
1 parent 6d310f4dbe
commit b3d2d9e9f1
156 files changed
+15910 -1385

No files matched your search

+4 -1
View File
@@ -67,8 +67,11 @@ def extract_admin_routes() -> tuple[set[str], set[str]]:
def check_route_manifest_consistency() -> None:
route_paths, manifest_paths = extract_admin_routes()
admin_routes_text = read_text("frontend/src/admin/AdminRoutes.tsx")
public_manifest_paths = {"/earth", "/docs"}
redirect_only_routes = {"/alerts"}
redirect_only_routes = set(
re.findall(r'<Route\s+path="([^"*][^"]*)"\s+element=\{<Navigate\b', admin_routes_text)
)
missing_routes = sorted(manifest_paths - route_paths - public_manifest_paths)
if missing_routes:
+149 -13
View File
@@ -90,10 +90,10 @@ const adminEnglishI18nRoutes = [
'/admin',
'/data',
'/datasources',
'/bgp',
'/alerts/system',
'/alerts/bgp',
'/alerts/situational',
'/advisor/playground',
'/advisor/workflows',
'/advisor/runs',
'/ops/monitoring',
'/ai',
'/earth-content',
'/collection-management',
@@ -268,6 +268,10 @@ function loadAdminSurface() {
['Dashboard', { text: '仪表盘' }],
['Users', { text: '用户管理' }],
['DataList', { text: '采集数据' }],
['AI', { text: 'AI 基础设施' }],
['AdvisorPlayground', { text: 'AI 参谋 Playground' }],
['AdvisorWorkflows', { text: 'AI 工作流与节点编排' }],
['AdvisorRuns', { text: 'AI 运行记录与轨迹' }],
])
const protectedRoutes = []
const authenticatedChecks = []
@@ -278,8 +282,14 @@ function loadAdminSurface() {
const component = match[4]
protectedRoutes.push(path)
if (redirectTarget === '/alerts/system') {
authenticatedChecks.push({ path, text: '系统告警' })
if (redirectTarget) {
if (redirectTarget.startsWith('/ops/monitoring')) {
authenticatedChecks.push({ path, text: '告警与观测' })
} else if (redirectTarget.startsWith('/advisor/workflows')) {
authenticatedChecks.push({ path, text: 'AI 工作流与节点编排' })
} else if (redirectTarget.startsWith('/advisor/playground')) {
authenticatedChecks.push({ path, text: 'AI 参谋 Playground' })
}
continue
}
if (!component) continue
@@ -956,6 +966,15 @@ function apiPayloadFor(requestUrl, method) {
return jsonResponse({ message: 'reset' })
}
if (method === 'POST' && path === '/auth/earth-session') {
return jsonResponse({
expires_in: 1800,
ws_token: 'smoke-ws-token',
client_type: 'web',
turnstile_required: false,
})
}
if (path === '/docs/catalog') {
return jsonResponse({
authenticated: false,
@@ -1050,6 +1069,49 @@ function apiPayloadFor(requestUrl, method) {
if (path === '/settings/ai-prompts') return jsonResponse([{ key: 'bgp_brief', name: 'BGP Brief', group: 'BGP', source: 'default', prompt: 'Summarize BGP status.' }])
if (path === '/ai/playground/session') return jsonResponse({ id: 1, session_key: 'frontend-smoke', updated_at: now })
if (path === '/ai/playground/thread') return jsonResponse({ messages: [], session: { state: {} } })
if (path === '/ai/workflows') {
const sampleGraph = {
nodes: [
{ id: 'intake', node_type: 'input', title: '问题入口', title_en: 'Intake', position: { x: 40, y: 120 }, enabled: true, system_prompt: '', prompt: '', tools: [], thinking_enabled: true, max_steps: 1, timeout_seconds: 60, native_web_search: false, guardrails: {}, params: {} },
{ id: 'default_advisor', node_type: 'llm_agent', title: '通用参谋', title_en: 'General Advisor', position: { x: 320, y: 120 }, enabled: true, prompt_key: 'situational.copilot.reply', system_prompt: 'System', prompt: 'Prompt', tools: ['query_global_situational'], thinking_enabled: true, max_steps: 2, timeout_seconds: 60, native_web_search: false, guardrails: {}, params: {} },
],
edges: [{ id: 'e1', source: 'intake', target: 'default_advisor', label: 'Always', label_en: 'Always' }],
}
return jsonResponse({
items: [
{ workflow_id: 'default.general', name: '通用AI参谋(默认)', name_en: 'General AI Advisor (Default)', category: 'default', description: '', description_en: '', is_default: true, is_builtin: true, active_revision: 1, has_draft: false, published_graph: sampleGraph, draft_graph: null },
{ workflow_id: 'location.resolve_unknown', name: '未知算力位置事实核查 Agent', name_en: 'Unknown Location Fact-Check Agent', category: 'location', description: '', description_en: '', is_default: false, is_builtin: true, active_revision: 1, has_draft: false, published_graph: sampleGraph, draft_graph: null },
],
total: 2,
})
}
if (path.startsWith('/ai/workflows/')) {
const wfId = path.replace('/ai/workflows/', '').split('/')[0] || 'default.general'
const sampleGraph = {
nodes: [
{ id: 'intake', node_type: 'input', title: '问题入口', title_en: 'Intake', position: { x: 40, y: 120 }, enabled: true, system_prompt: '', prompt: '', tools: [], thinking_enabled: true, max_steps: 1, timeout_seconds: 60, native_web_search: false, guardrails: {}, params: {} },
{ id: 'default_advisor', node_type: 'llm_agent', title: '通用参谋', title_en: 'General Advisor', position: { x: 320, y: 120 }, enabled: true, prompt_key: 'situational.copilot.reply', system_prompt: 'System', prompt: 'Prompt', tools: ['query_global_situational'], thinking_enabled: true, max_steps: 2, timeout_seconds: 60, native_web_search: false, guardrails: {}, params: {} },
],
edges: [{ id: 'e1', source: 'intake', target: 'default_advisor', label: 'Always', label_en: 'Always' }],
}
return jsonResponse({
workflow: { workflow_id: wfId, name: '通用AI参谋(默认)', name_en: 'General AI Advisor (Default)', category: 'default', description: '', description_en: '', is_default: wfId === 'default.general', active_revision: 1, has_draft: false, published_graph: sampleGraph, draft_graph: null },
revisions: [{ id: 1, revision: 1, status: 'published', change_summary: 'Initial built-in workflow', created_at: now }],
fixtures: [],
tool_catalog: [{ id: 'query_global_situational', name: '全球态势全览快照', name_en: 'Global Situational Snapshot', category: 'internal_read', description: '' }],
})
}
if (path === '/ai/runs') {
return jsonResponse({
items: [
{ id: 'run_smoke_1', workflow_id: 'default.general', status: 'completed', actor_key: 'admin', question: 'Smoke run question', tool_trace: ['intake', 'default_advisor'], started_at: now },
],
total: 1,
})
}
if (path.startsWith('/ai/runs/')) {
return jsonResponse({ id: 'run_smoke_1', workflow_id: 'default.general', status: 'completed', actor_key: 'admin', question: 'Smoke run question', tool_trace: ['intake', 'default_advisor'], started_at: now })
}
if (path === '/earth/brand') return jsonResponse({ brand: { title: '智能星球', subtitle: 'Smoke', logo_alt: 'Planet' } })
if (path === '/data-products/compute/configuration') return jsonResponse({
@@ -1320,6 +1382,80 @@ function apiPayloadFor(requestUrl, method) {
if (path.startsWith('/system/logs/observability/groups/')) return jsonResponse({ events: [] })
if (path.startsWith('/system/logs/')) return jsonResponse({ source_id: path.split('/').pop() || 'system-db', status: 'ok', line_limit: 200, line_count: 1, lines: [`${now} INFO frontend smoke log`] })
if (method === 'GET' && path === '/system/api-keys') {
return jsonResponse({
items: [],
available_scopes: [
'earth:all_read',
'visualization:read',
'layers:read',
'vessels:read',
'news:read',
'data_products:read',
'compute:read',
'situational:read',
'earth:read',
'media:read',
'tv:read',
'ws:connect',
],
})
}
if (method === 'POST' && path === '/system/api-keys') {
return jsonResponse(
{
item: {
id: 1,
name: 'smoke-key',
key_prefix: 'plt_live_smoke...',
scopes: ['earth:all_read'],
rate_limit_per_minute: null,
expires_at: null,
is_active: true,
is_expired: false,
status: 'active',
last_used_at: null,
revoked_at: null,
created_at: now,
},
api_key: 'plt_live_smoke_mock_value',
},
201,
)
}
if (method === 'POST' && /^\/system\/api-keys\/\d+\/revoke$/.test(path)) {
return jsonResponse({
item: {
id: 1,
name: 'smoke-key',
key_prefix: 'plt_live_smoke...',
scopes: ['earth:all_read'],
rate_limit_per_minute: null,
expires_at: null,
is_active: false,
is_expired: false,
status: 'revoked',
last_used_at: null,
revoked_at: now,
created_at: now,
},
})
}
if (method === 'DELETE' && /^\/system\/api-keys\/\d+$/.test(path)) {
return jsonResponse({ status: 'deleted', id: 1 })
}
if (method === 'GET' && (path === '/system/openapi.json' || path === '/system/openapi-external.json')) {
return jsonResponse({
openapi: '3.1.0',
info: { title: 'Planet API', version: 'smoke' },
paths: {
'/api/v1/visualization/geo/summary': {
get: { tags: ['visualization'], summary: 'Geo summary' },
},
},
})
}
return jsonResponse({ detail: 'mocked by frontend smoke' }, 404)
}
@@ -1524,13 +1660,13 @@ async function runAdminInteractionChecks(browser, failures, consoleErrors) {
await expectVisibleText(page, 'SMTP 邮件', 'admin language switch chinese')
await page.goto(urlFor('/ai'), { waitUntil: 'domcontentloaded' })
await clickFirstVisible(page.locator('a[aria-label="设置"][href="/settings"]'), 'ai settings shortcut')
await expectUrl(page, 'ai settings shortcut', (location) => location.pathname === '/settings')
await expectVisibleText(page, '系统设置', 'ai settings shortcut')
await clickFirstVisible(page.locator('a[aria-label="工作流与节点"][href="/advisor/workflows"]'), 'ai settings shortcut')
await expectUrl(page, 'ai settings shortcut', (location) => location.pathname === '/advisor/workflows')
await expectVisibleText(page, 'AI 工作流与节点编排', 'ai settings shortcut')
await page.goto(urlFor('/ai'), { waitUntil: 'domcontentloaded' })
await clickFirstVisible(page.getByRole('tab', { name: /Playground/ }), 'section tab ai playground')
await expectVisibleText(page, 'Playground 设置', 'section tab ai playground')
await page.goto(urlFor('/advisor/playground'), { waitUntil: 'domcontentloaded' })
await expectVisibleText(page, 'AI 参谋 Playground', 'section tab ai playground')
await expectVisibleText(page, '客户端本地上下文', 'section tab ai playground')
await page.goto(urlFor('/collection-management'), { waitUntil: 'domcontentloaded' })
await clickFirstVisible(page.getByRole('tab', { name: /采集器/ }), 'section tab collection credentials')
@@ -1750,7 +1886,7 @@ async function runDatasourceSchedulingChecks(browser, failures, consoleErrors) {
const filterMetricsDirty = await page.evaluate(() => {
const grid = document.querySelector('.an-filter-grid--datasources')?.getBoundingClientRect()
const seg = document.querySelector('.an-filter-grid--datasources > .an-segmented--counted')?.getBoundingClientRect()
const sel = document.querySelector('.an-filter-grid--datasources select')?.getBoundingClientRect()
const sel = document.querySelector('.an-filter-grid--datasources .an-select, .an-filter-grid--datasources select')?.getBoundingClientRect()
const resetBtn = document.querySelector('.an-filter-grid--datasources > button')?.getBoundingClientRect()
return {
gridH: grid ? Math.round(grid.height) : 0,
@@ -1,6 +1,7 @@
import hashlib
import io
import json
import os
import sys
import tarfile
import tempfile
@@ -609,6 +610,61 @@ class ScopedReleaseTests(unittest.TestCase):
self.assertEqual(data, b"ok")
self.assertEqual(captured["ua"], registry.DEFAULT_USER_AGENT)
def test_check_routes_public_only_without_api_key(self):
calls = []
def fake_read_url(url, **kwargs):
calls.append((url, kwargs))
if url == deploy.ADMIN + "/earth":
return b"<html><body>Earth</body></html>"
return b"{}"
env_without_key = {k: v for k, v in os.environ.items() if k != "PLANET_DEPLOY_API_KEY"}
with (
patch.dict(os.environ, env_without_key, clear=True),
patch.object(deploy, "read_url", side_effect=fake_read_url),
):
deploy.check_routes()
self.assertEqual(
[url for url, _ in calls],
[
deploy.PUBLIC + "/health/ready",
deploy.PUBLIC + "/api/v1/client/update-manifest",
deploy.ADMIN + "/earth",
],
)
def test_check_routes_with_api_key_checks_protected_summary(self):
for explicit_key, env_value, expected_key in [
("demo-key", "", "demo-key"),
(None, "env-key", "env-key"),
]:
calls = []
def fake_read_url(url, **kwargs):
calls.append((url, kwargs))
if url == deploy.ADMIN + "/earth":
return b"<html><body>Earth</body></html>"
return b"{}"
env_patch = {"PLANET_DEPLOY_API_KEY": env_value} if env_value else {}
clean_env = {k: v for k, v in os.environ.items() if k != "PLANET_DEPLOY_API_KEY"}
clean_env.update(env_patch)
with (
patch.dict(os.environ, clean_env, clear=True),
patch.object(deploy, "read_url", side_effect=fake_read_url),
):
if explicit_key is None:
deploy.check_routes()
else:
deploy.check_routes(api_key=explicit_key)
summary_url = deploy.PUBLIC + "/api/v1/visualization/geo/summary"
summary_calls = [kwargs for url, kwargs in calls if url == summary_url]
self.assertEqual(len(summary_calls), 1)
self.assertEqual(summary_calls[0].get("headers"), {"X-API-Key": expected_key})
if __name__ == "__main__":
unittest.main()
+11 -2
View File
@@ -218,10 +218,19 @@ def rollout_services(host, tag, images, services=None):
time.sleep(2)
def check_routes():
for url in (PUBLIC + "/health/ready", PUBLIC + "/api/v1/visualization/geo/summary"):
def check_routes(api_key: str | None = None):
for url in (PUBLIC + "/health/ready", PUBLIC + "/api/v1/client/update-manifest"):
if not isinstance(json.loads(read_url(url)), dict):
raise RuntimeError(f"Unexpected response from {url}")
resolved_key = (
api_key if api_key is not None else os.environ.get("PLANET_DEPLOY_API_KEY", "")
).strip()
if resolved_key:
summary_url = PUBLIC + "/api/v1/visualization/geo/summary"
if not isinstance(
json.loads(read_url(summary_url, headers={"X-API-Key": resolved_key})), dict
):
raise RuntimeError(f"Unexpected response from {summary_url}")
if b"<html" not in read_url(ADMIN + "/earth").lower():
raise RuntimeError("Admin Earth entry did not return HTML")