Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

Merge branch 'fix-bug-1' of [email protected]:chen-hui-zhe-xi/jiuwenclaw.git into 'dev-stable' # Conflicts: # conflict tests/unit_tests/agentserver/test_skill_index_warmup.py

chen-hui-zhe-xi14a9c05b340f
diff --cc deploy/enterprise/templates/gateway.template.env
index 2437ddd632,17454bc89c..262dd3135a
--- a/deploy/enterprise/templates/gateway.template.env
+++ b/deploy/enterprise/templates/gateway.template.env
@@@ -121,11 -124,8 +123,10 @@@ RUNTIME_DB_POOL_TIMEOUT=<<GATEWAY_DB_PO
GATEWAY_CONFIG_RECEIVER_ENABLED=true
GATEWAY_CONFIG_HTTP_HOST=0.0.0.0
GATEWAY_CONFIG_HTTP_PORT=<<GATEWAY_CONFIG_HTTP_PORT>>
- GATEWAY_WEB_HTTP_PORT=<<GATEWAY_WEB_HTTP_PORT>>
GATEWAY_CONFIG_PUBLIC_HOST=<<GATEWAY_NAME>>
+GATEWAY_WEB_HTTP_TRUST_CLIENT_HEADERS=true
GATEWAY_MANAGER_HTTP_URL=http://<<MANAGER_SERVER_NAME>>:<<MANAGER_REST_PORT>>
+GATEWAY_RUNTIME_MANAGER_URL=http://<<AGENT_RUNTIME_NAME>>:<<AGENT_RUNTIME_PORT>>
GATEWAY_CONFIG_HEARTBEAT_SECONDS=60
GATEWAY_MANAGER_MAX_RECONNECT_ATTEMPTS=3
GATEWAY_MANAGER_RECONNECT_INTERVAL_SECONDS=3
diff --cc deploy/enterprise/templates/web.template.yaml
index deec8dbfd0,31bf7087b7..cc99d43fa3
--- a/deploy/enterprise/templates/web.template.yaml
+++ b/deploy/enterprise/templates/web.template.yaml
@@@ -34,10 -34,18 +34,20 @@@ spec
value: "0.0.0.0"
- name: FRONTEND_HOST
value: "0.0.0.0"
+ - name: USER_WEB_MODE
+ value: "<<USER_WEB_MODE>>"
+ - name: VITE_USER_WEB_MODE
+ value: "<<USER_WEB_MODE>>"
+ - name: VITE_ENABLE_USER_WEB_EMBEDDING
+ value: "<<ENABLE_USER_WEB_EMBEDDING>>"
+ - name: USER_WEB_IDP_TARGET
+ value: "http://<<IDENTITY_NAME>>:<<IDENTITY_REST_PORT>>"
+ - name: USER_WEB_MANAGER_TARGET
+ value: "http://<<MANAGER_SERVER_NAME>>:<<MANAGER_REST_PORT>>"
- name: FRONTEND_PORT
value: "<<WEB_HTTP_PORT>>"
+ - name: VITE_WEB_TRANSPORT
+ value: "http"
- name: ENTERPRISE_WEB_WS_HOST
value: "0.0.0.0"
- name: ENTERPRISE_WEB_WS_PORT
diff --cc tests/unit_tests/agentserver/test_skill_index_warmup.py
index 5ee7e4ce15,3b6f15cf90..28f4632336
--- a/tests/unit_tests/agentserver/test_skill_index_warmup.py
+++ b/tests/unit_tests/agentserver/test_skill_index_warmup.py
@@@ -1,268 -1,337 +1,337 @@@
-"""Skill process-index warmup after listen / sync_agents_configs."""
-
-from __future__ import annotations
-
-import asyncio
-
-import pytest
-
-from jiuwenswarm.common.local_env_config import ENV_CONFIG_DICT
-from jiuwenswarm.common.utils import JIUWENSWARM_SHARED_SKILLS_DIRS_ENV
-
-
[email protected](autouse=True)
-def _reset_skill_warmup_task():
- mod = pytest.importorskip("jiuwenswarm.server.agent_ws_server")
- mod._skill_index_warmup_task = None
- mod._skill_index_warmup_roots_cache = []
- mod._skill_index_warmup_enabled_cache = None
- mod._startup_warmup_task = None
- yield
- task = mod._skill_index_warmup_task
- mod._skill_index_warmup_task = None
- mod._skill_index_warmup_roots_cache = []
- mod._skill_index_warmup_enabled_cache = None
- mod._startup_warmup_task = None
- if task is not None and not task.done():
- task.cancel()
-
-
-def test_shared_skills_dirs_from_sync_params_reads_office_env(tmp_path) -> None:
- mod = pytest.importorskip("jiuwenswarm.server.agent_ws_server")
- shared = tmp_path / "office-claw-skills"
- shared.mkdir()
- params = {
- "agents": [
- {
- "agent_id": "office",
- "env": {"JIUWENSWARM_SHARED_SKILLS_DIRS": str(shared)},
- }
- ]
- }
- assert mod._shared_skills_dirs_from_sync_params(params) == [str(shared.resolve())]
-
-
-def test_enabled_skills_from_sync_params_uses_office_only() -> None:
- mod = pytest.importorskip("jiuwenswarm.server.agent_ws_server")
- shared = "D:/skills"
- params = {
- "agents": [
- {
- "agent_id": "agentteam",
- "env": {
- "JIUWENSWARM_SHARED_SKILLS_DIRS": shared,
- "ENABLED_SKILLS": "",
- },
- },
- {
- "agent_id": "expert-academic-evidence-researcher",
- "env": {
- "JIUWENSWARM_SHARED_SKILLS_DIRS": shared,
- "ENABLED_SKILLS": "alpha,beta",
- },
- },
- {
- "agent_id": "office",
- "env": {
- "JIUWENSWARM_SHARED_SKILLS_DIRS": shared,
- "ENABLED_SKILLS": "pptx-craft,docx-craft,email-craft",
- },
- },
- ]
- }
- assert (
- mod._enabled_skills_from_sync_params(params)
- == "pptx-craft,docx-craft,email-craft"
- )
-
-
-def test_enabled_skills_from_sync_params_none_without_office() -> None:
- mod = pytest.importorskip("jiuwenswarm.server.agent_ws_server")
- params = {
- "agents": [
- {"agent_id": "agentteam", "env": {"ENABLED_SKILLS": "alpha,beta"}},
- {"agent_id": "other", "env": {"ENABLED_SKILLS": "beta,gamma"}},
- ]
- }
- assert mod._enabled_skills_from_sync_params(params) is None
-
-
-async def test_schedule_skill_index_warmup_after_sync_caches_shared_dirs_enabled_skills(
- monkeypatch: pytest.MonkeyPatch,
- tmp_path,
-) -> None:
- mod = pytest.importorskip("jiuwenswarm.server.agent_ws_server")
- shared = tmp_path / "shared"
- shared.mkdir()
- started: list[bool] = []
-
- def _record(*, force: bool = False) -> None:
- started.append(force)
-
- monkeypatch.setattr(mod, "_start_skill_index_warmup", _record)
- mod.schedule_skill_index_warmup_after_sync(
- sync_params={
- "agents": [
- {
- "agent_id": "agentteam",
- "env": {"ENABLED_SKILLS": "alpha,beta"},
- },
- {
- "agent_id": "office",
- "env": {
- "JIUWENSWARM_SHARED_SKILLS_DIRS": str(shared),
- "ENABLED_SKILLS": "pptx-craft,docx-craft",
- },
- },
- ]
- },
- force=True,
- )
- assert started == [True]
- assert mod._skill_index_warmup_enabled_cache == "pptx-craft,docx-craft"
-
-
-def test_skill_index_warmup_roots_uses_resolve_agent_registered_skill_dirs(
- monkeypatch: pytest.MonkeyPatch,
- tmp_path,
-) -> None:
- mod = pytest.importorskip("jiuwenswarm.server.agent_ws_server")
- shared = tmp_path / "office-claw-skills"
- shared.mkdir()
- monkeypatch.setattr(
- "jiuwenswarm.common.utils.resolve_agent_registered_skill_dirs",
- lambda: [shared],
- )
- assert mod._skill_index_warmup_roots() == [str(shared.resolve())]
-
-
-async def test_warm_skill_md_index_fills_process_index(
- monkeypatch: pytest.MonkeyPatch,
-) -> None:
- """Wire-check: roots/enabled are passed to warmup_process_skill_index.
-
- Mock agent-core API so CI does not require a refreshed uv.lock pin.
- """
- mod = pytest.importorskip("jiuwenswarm.server.agent_ws_server")
- import openjiuwen.harness.rails.skills as skills_pkg
-
- calls: list[tuple[list[str], str | None]] = []
-
- def _fake_warmup(roots, *, enabled_skills=None, disabled_skills=None):
- calls.append((list(roots), enabled_skills))
- return {
- "scanned": 1,
- "kept": 1,
- "filled": 1,
- "hits": 0,
- "entries": 1,
- "cost_ms": 1.0,
- }
-
- monkeypatch.setattr(
- skills_pkg,
- "warmup_process_skill_index",
- _fake_warmup,
- raising=False,
- )
- monkeypatch.setattr(mod, "_skill_index_warmup_roots", lambda: ["/tmp/skills"])
- monkeypatch.setattr(
- mod, "_skill_index_warmup_enabled_skills", lambda: "pptx-craft"
- )
-
- await mod._warm_skill_md_index()
-
- assert calls == [(["/tmp/skills"], "pptx-craft")]
-
-
-async def test_schedule_skill_index_warmup_after_sync_uses_sync_params(
- monkeypatch: pytest.MonkeyPatch,
- tmp_path,
-) -> None:
- mod = pytest.importorskip("jiuwenswarm.server.agent_ws_server")
- shared = tmp_path / "shared"
- shared.mkdir()
- started: list[list[str]] = []
-
- def _record(*, force: bool = False) -> None:
- started.append(list(mod._skill_index_warmup_roots_cache))
-
- monkeypatch.setattr(mod, "_start_skill_index_warmup", _record)
- mod.schedule_skill_index_warmup_after_sync(
- sync_params={
- "agents": [
- {
- "agent_id": "office",
- "env": {"JIUWENSWARM_SHARED_SKILLS_DIRS": str(shared)},
- }
- ]
- },
- force=True,
- )
- assert started == [[str(shared.resolve())]]
-
-
-async def test_schedule_skill_index_warmup_after_sync_skips_without_shared_dirs(
- monkeypatch: pytest.MonkeyPatch,
-) -> None:
- mod = pytest.importorskip("jiuwenswarm.server.agent_ws_server")
- monkeypatch.setattr(
- "jiuwenswarm.common.utils.get_shared_agent_skills_dirs",
- lambda: [],
- )
- called = False
-
- def _boom(*_args, **_kwargs):
- nonlocal called
- called = True
-
- monkeypatch.setattr(mod, "_start_skill_index_warmup", _boom)
- mod.schedule_skill_index_warmup_after_sync(sync_params={"agents": []}, force=True)
- assert called is False
-
-
-async def test_schedule_skill_index_warmup_after_sync_starts_when_shared_dirs_ready(
- monkeypatch: pytest.MonkeyPatch,
- tmp_path,
-) -> None:
- mod = pytest.importorskip("jiuwenswarm.server.agent_ws_server")
- shared = tmp_path / "shared"
- shared.mkdir()
- ENV_CONFIG_DICT[JIUWENSWARM_SHARED_SKILLS_DIRS_ENV] = str(shared)
- started: list[bool] = []
-
- def _record(*, force: bool = False) -> None:
- started.append(force)
-
- monkeypatch.setattr(mod, "_start_skill_index_warmup", _record)
- mod.schedule_skill_index_warmup_after_sync(force=True)
- assert started == [True]
-
-
-async def test_start_skill_index_warmup_force_cancels_inflight(
- monkeypatch: pytest.MonkeyPatch,
-) -> None:
- mod = pytest.importorskip("jiuwenswarm.server.agent_ws_server")
-
- gate = asyncio.Event()
- cancelled = False
-
- async def _slow_warm() -> None:
- nonlocal cancelled
- try:
- await gate.wait()
- except asyncio.CancelledError:
- cancelled = True
- raise
-
- monkeypatch.setattr(mod, "_warm_skill_md_index", _slow_warm)
- mod._start_skill_index_warmup()
- await asyncio.sleep(0)
- mod._start_skill_index_warmup(force=True)
- await asyncio.sleep(0)
- gate.set()
- assert cancelled is True
-
-
-async def test_schedule_skill_index_warmup_after_sync_skips_same_roots(
- monkeypatch: pytest.MonkeyPatch,
- tmp_path,
-) -> None:
- mod = pytest.importorskip("jiuwenswarm.server.agent_ws_server")
- shared = tmp_path / "shared"
- shared.mkdir()
- started: list[bool] = []
-
- def _record(*, force: bool = False) -> None:
- started.append(force)
-
- async def _done() -> None:
- return None
-
- mod._skill_index_warmup_task = asyncio.get_running_loop().create_task(_done())
-
- monkeypatch.setattr(mod, "_start_skill_index_warmup", _record)
- params = {
- "agents": [
- {
- "agent_id": "office",
- "env": {"JIUWENSWARM_SHARED_SKILLS_DIRS": str(shared)},
- }
- ]
- }
- mod.schedule_skill_index_warmup_after_sync(sync_params=params)
- await asyncio.sleep(0)
- mod.schedule_skill_index_warmup_after_sync(sync_params=params)
- assert started == [False]
-
-
-async def test_schedule_skill_index_warmup_after_sync_skips_when_inflight(
- monkeypatch: pytest.MonkeyPatch,
- tmp_path,
-) -> None:
- mod = pytest.importorskip("jiuwenswarm.server.agent_ws_server")
- shared = tmp_path / "shared"
- shared.mkdir()
- started: list[bool] = []
- gate = asyncio.Event()
-
- async def _slow() -> None:
- await gate.wait()
-
- def _record(*, force: bool = False) -> None:
- started.append(force)
- mod._skill_index_warmup_task = asyncio.get_running_loop().create_task(_slow())
-
- monkeypatch.setattr(mod, "_start_skill_index_warmup", _record)
- params = {
- "agents": [
- {
- "agent_id": "office",
- "env": {"JIUWENSWARM_SHARED_SKILLS_DIRS": str(shared)},
- }
- ]
- }
- mod.schedule_skill_index_warmup_after_sync(sync_params=params)
- mod.schedule_skill_index_warmup_after_sync(sync_params=params, force=True)
- gate.set()
- await asyncio.sleep(0)
- assert started == [False]
+"""Skill process-index warmup after listen / sync_agents_configs."""
+
+from __future__ import annotations
+
+import asyncio
+
+import pytest
+
+from jiuwenswarm.common.local_env_config import ENV_CONFIG_DICT
+from jiuwenswarm.common.utils import JIUWENSWARM_SHARED_SKILLS_DIRS_ENV
+
+
[email protected](autouse=True)
+def _reset_skill_warmup_task():
+ mod = pytest.importorskip("jiuwenswarm.server.agent_ws_server")
+ mod._skill_index_warmup_task = None
+ mod._skill_index_warmup_roots_cache = []
+ mod._skill_index_warmup_enabled_cache = None
++ mod._startup_warmup_task = None
+ yield
+ task = mod._skill_index_warmup_task
+ mod._skill_index_warmup_task = None
+ mod._skill_index_warmup_roots_cache = []
+ mod._skill_index_warmup_enabled_cache = None
++ mod._startup_warmup_task = None
+ if task is not None and not task.done():
+ task.cancel()
+
+
+def test_shared_skills_dirs_from_sync_params_reads_office_env(tmp_path) -> None:
+ mod = pytest.importorskip("jiuwenswarm.server.agent_ws_server")
+ shared = tmp_path / "office-claw-skills"
+ shared.mkdir()
+ params = {
+ "agents": [
+ {
+ "agent_id": "office",
+ "env": {"JIUWENSWARM_SHARED_SKILLS_DIRS": str(shared)},
+ }
+ ]
+ }
+ assert mod._shared_skills_dirs_from_sync_params(params) == [str(shared.resolve())]
+
+
+def test_enabled_skills_from_sync_params_uses_office_only() -> None:
+ mod = pytest.importorskip("jiuwenswarm.server.agent_ws_server")
+ shared = "D:/skills"
+ params = {
+ "agents": [
+ {
+ "agent_id": "agentteam",
+ "env": {
+ "JIUWENSWARM_SHARED_SKILLS_DIRS": shared,
+ "ENABLED_SKILLS": "",
+ },
+ },
+ {
+ "agent_id": "expert-academic-evidence-researcher",
+ "env": {
+ "JIUWENSWARM_SHARED_SKILLS_DIRS": shared,
+ "ENABLED_SKILLS": "alpha,beta",
+ },
+ },
+ {
+ "agent_id": "office",
+ "env": {
+ "JIUWENSWARM_SHARED_SKILLS_DIRS": shared,
+ "ENABLED_SKILLS": "pptx-craft,docx-craft,email-craft",
+ },
+ },
+ ]
+ }
+ assert (
+ mod._enabled_skills_from_sync_params(params)
+ == "pptx-craft,docx-craft,email-craft"
+ )
+
+
+def test_enabled_skills_from_sync_params_none_without_office() -> None:
+ mod = pytest.importorskip("jiuwenswarm.server.agent_ws_server")
+ params = {
+ "agents": [
+ {"agent_id": "agentteam", "env": {"ENABLED_SKILLS": "alpha,beta"}},
+ {"agent_id": "other", "env": {"ENABLED_SKILLS": "beta,gamma"}},
+ ]
+ }
+ assert mod._enabled_skills_from_sync_params(params) is None
+
+
+async def test_schedule_skill_index_warmup_after_sync_caches_shared_dirs_enabled_skills(
+ monkeypatch: pytest.MonkeyPatch,
+ tmp_path,
+) -> None:
+ mod = pytest.importorskip("jiuwenswarm.server.agent_ws_server")
+ shared = tmp_path / "shared"
+ shared.mkdir()
+ started: list[bool] = []
+
+ def _record(*, force: bool = False) -> None:
+ started.append(force)
+
+ monkeypatch.setattr(mod, "_start_skill_index_warmup", _record)
+ mod.schedule_skill_index_warmup_after_sync(
+ sync_params={
+ "agents": [
+ {
+ "agent_id": "agentteam",
+ "env": {"ENABLED_SKILLS": "alpha,beta"},
+ },
+ {
+ "agent_id": "office",
+ "env": {
+ "JIUWENSWARM_SHARED_SKILLS_DIRS": str(shared),
+ "ENABLED_SKILLS": "pptx-craft,docx-craft",
+ },
+ },
+ ]
+ },
+ force=True,
+ )
+ assert started == [True]
+ assert mod._skill_index_warmup_enabled_cache == "pptx-craft,docx-craft"
+
+
+def test_skill_index_warmup_roots_uses_resolve_agent_registered_skill_dirs(
+ monkeypatch: pytest.MonkeyPatch,
+ tmp_path,
+) -> None:
+ mod = pytest.importorskip("jiuwenswarm.server.agent_ws_server")
+ shared = tmp_path / "office-claw-skills"
+ shared.mkdir()
+ monkeypatch.setattr(
+ "jiuwenswarm.common.utils.resolve_agent_registered_skill_dirs",
+ lambda: [shared],
+ )
+ assert mod._skill_index_warmup_roots() == [str(shared.resolve())]
+
+
+async def test_warm_skill_md_index_fills_process_index(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """Wire-check: roots/enabled are passed to warmup_process_skill_index.
+
+ Mock agent-core API so CI does not require a refreshed uv.lock pin.
+ """
+ mod = pytest.importorskip("jiuwenswarm.server.agent_ws_server")
+ import openjiuwen.harness.rails.skills as skills_pkg
+
+ calls: list[tuple[list[str], str | None]] = []
+
+ def _fake_warmup(roots, *, enabled_skills=None, disabled_skills=None):
+ calls.append((list(roots), enabled_skills))
+ return {
+ "scanned": 1,
+ "kept": 1,
+ "filled": 1,
+ "hits": 0,
+ "entries": 1,
+ "cost_ms": 1.0,
+ }
+
+ monkeypatch.setattr(
+ skills_pkg,
+ "warmup_process_skill_index",
+ _fake_warmup,
+ raising=False,
+ )
+ monkeypatch.setattr(mod, "_skill_index_warmup_roots", lambda: ["/tmp/skills"])
+ monkeypatch.setattr(
+ mod, "_skill_index_warmup_enabled_skills", lambda: "pptx-craft"
+ )
+
+ await mod._warm_skill_md_index()
+
+ assert calls == [(["/tmp/skills"], "pptx-craft")]
+
+
+async def test_schedule_skill_index_warmup_after_sync_uses_sync_params(
+ monkeypatch: pytest.MonkeyPatch,
+ tmp_path,
+) -> None:
+ mod = pytest.importorskip("jiuwenswarm.server.agent_ws_server")
+ shared = tmp_path / "shared"
+ shared.mkdir()
+ started: list[list[str]] = []
+
+ def _record(*, force: bool = False) -> None:
+ started.append(list(mod._skill_index_warmup_roots_cache))
+
+ monkeypatch.setattr(mod, "_start_skill_index_warmup", _record)
+ mod.schedule_skill_index_warmup_after_sync(
+ sync_params={
+ "agents": [
+ {
+ "agent_id": "office",
+ "env": {"JIUWENSWARM_SHARED_SKILLS_DIRS": str(shared)},
+ }
+ ]
+ },
+ force=True,
+ )
+ assert started == [[str(shared.resolve())]]
+
+
+async def test_schedule_skill_index_warmup_after_sync_skips_without_shared_dirs(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ mod = pytest.importorskip("jiuwenswarm.server.agent_ws_server")
+ monkeypatch.setattr(
+ "jiuwenswarm.common.utils.get_shared_agent_skills_dirs",
+ lambda: [],
+ )
+ called = False
+
+ def _boom(*_args, **_kwargs):
+ nonlocal called
+ called = True
+
+ monkeypatch.setattr(mod, "_start_skill_index_warmup", _boom)
+ mod.schedule_skill_index_warmup_after_sync(sync_params={"agents": []}, force=True)
+ assert called is False
+
+
+async def test_schedule_skill_index_warmup_after_sync_starts_when_shared_dirs_ready(
+ monkeypatch: pytest.MonkeyPatch,
+ tmp_path,
+) -> None:
+ mod = pytest.importorskip("jiuwenswarm.server.agent_ws_server")
+ shared = tmp_path / "shared"
+ shared.mkdir()
+ ENV_CONFIG_DICT[JIUWENSWARM_SHARED_SKILLS_DIRS_ENV] = str(shared)
+ started: list[bool] = []
+
+ def _record(*, force: bool = False) -> None:
+ started.append(force)
+
+ monkeypatch.setattr(mod, "_start_skill_index_warmup", _record)
+ mod.schedule_skill_index_warmup_after_sync(force=True)
+ assert started == [True]
+
+
+async def test_start_skill_index_warmup_force_cancels_inflight(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ mod = pytest.importorskip("jiuwenswarm.server.agent_ws_server")
+
+ gate = asyncio.Event()
+ cancelled = False
+
+ async def _slow_warm() -> None:
+ nonlocal cancelled
+ try:
+ await gate.wait()
+ except asyncio.CancelledError:
+ cancelled = True
+ raise
+
+ monkeypatch.setattr(mod, "_warm_skill_md_index", _slow_warm)
+ mod._start_skill_index_warmup()
+ await asyncio.sleep(0)
+ mod._start_skill_index_warmup(force=True)
+ await asyncio.sleep(0)
+ gate.set()
+ assert cancelled is True
++
++
++async def test_schedule_skill_index_warmup_after_sync_skips_same_roots(
++ monkeypatch: pytest.MonkeyPatch,
++ tmp_path,
++) -> None:
++ mod = pytest.importorskip("jiuwenswarm.server.agent_ws_server")
++ shared = tmp_path / "shared"
++ shared.mkdir()
++ started: list[bool] = []
++
++ def _record(*, force: bool = False) -> None:
++ started.append(force)
++
++ async def _done() -> None:
++ return None
++
++ mod._skill_index_warmup_task = asyncio.get_running_loop().create_task(_done())
++
++ monkeypatch.setattr(mod, "_start_skill_index_warmup", _record)
++ params = {
++ "agents": [
++ {
++ "agent_id": "office",
++ "env": {"JIUWENSWARM_SHARED_SKILLS_DIRS": str(shared)},
++ }
++ ]
++ }
++ mod.schedule_skill_index_warmup_after_sync(sync_params=params)
++ await asyncio.sleep(0)
++ mod.schedule_skill_index_warmup_after_sync(sync_params=params)
++ assert started == [False]
++
++
++async def test_schedule_skill_index_warmup_after_sync_skips_when_inflight(
++ monkeypatch: pytest.MonkeyPatch,
++ tmp_path,
++) -> None:
++ mod = pytest.importorskip("jiuwenswarm.server.agent_ws_server")
++ shared = tmp_path / "shared"
++ shared.mkdir()
++ started: list[bool] = []
++ gate = asyncio.Event()
++
++ async def _slow() -> None:
++ await gate.wait()
++
++ def _record(*, force: bool = False) -> None:
++ started.append(force)
++ mod._skill_index_warmup_task = asyncio.get_running_loop().create_task(_slow())
++
++ monkeypatch.setattr(mod, "_start_skill_index_warmup", _record)
++ params = {
++ "agents": [
++ {
++ "agent_id": "office",
++ "env": {"JIUWENSWARM_SHARED_SKILLS_DIRS": str(shared)},
++ }
++ ]
++ }
++ mod.schedule_skill_index_warmup_after_sync(sync_params=params)
++ mod.schedule_skill_index_warmup_after_sync(sync_params=params, force=True)
++ gate.set()
++ await asyncio.sleep(0)
++ assert started == [False]