mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-16 06:40:45 +08:00
初始化:独立 oclaw 仓库首提交
- 在 oclaw/ 下重新初始化 Git 仓库 - 补齐子仓库 .gitignore,避免提交本地运行态数据(_local、node_modules、logs 等) - 提交当前工程代码与配置 Made-with: Cursor
This commit is contained in:
commit
ba3836f00f
579 changed files with 83112 additions and 0 deletions
5
ops/__init__.py
Normal file
5
ops/__init__.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from .main import main
|
||||
|
||||
__all__ = ["main"]
|
||||
7
ops/__main__.py
Normal file
7
ops/__main__.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from .main import main
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
63
ops/main.py
Normal file
63
ops/main.py
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
|
||||
from oclaw.ops.memory import register_memory_parser
|
||||
from oclaw.ops.providers.registry import build_channel_registry
|
||||
from oclaw.ops.stack import register_stack_parser
|
||||
|
||||
|
||||
def _cmd_gateway_start(args: argparse.Namespace) -> int:
|
||||
if args.host:
|
||||
os.environ["AIA_ASSISTANT_GATEWAY_HOST"] = args.host
|
||||
if args.port is not None:
|
||||
os.environ["AIA_ASSISTANT_GATEWAY_PORT"] = str(args.port)
|
||||
from oclaw.ops.mcp_env import apply_gateway_mcp_env_to_os
|
||||
|
||||
apply_gateway_mcp_env_to_os()
|
||||
from oclaw.interfaces.http.fastapi_app import main as fastapi_main
|
||||
|
||||
return fastapi_main()
|
||||
|
||||
|
||||
def _build_parser() -> argparse.ArgumentParser:
|
||||
p = argparse.ArgumentParser(prog="python -m oclaw.ops", description="Unified operational CLI")
|
||||
root_sub = p.add_subparsers(dest="root_cmd", required=True)
|
||||
|
||||
registry = build_channel_registry()
|
||||
channel = root_sub.add_parser("channel", help="Channel operations")
|
||||
channel_sub = channel.add_subparsers(dest="channel_name", required=True)
|
||||
channel_list = channel_sub.add_parser("list", help="List available channel providers")
|
||||
channel_list.set_defaults(func=lambda _a: (print("channels=" + ",".join(sorted(registry.keys()))) or 0))
|
||||
for provider in registry.values():
|
||||
provider.register(channel_sub)
|
||||
|
||||
gateway = root_sub.add_parser("gateway", help="Gateway operations")
|
||||
gateway_sub = gateway.add_subparsers(dest="gateway_cmd", required=True)
|
||||
gateway_start = gateway_sub.add_parser("start", help="Start inbound HTTP gateway")
|
||||
gateway_start.add_argument("--host", default=None, help="Bind host")
|
||||
gateway_start.add_argument("--port", type=int, default=None, help="Bind port")
|
||||
gateway_start.set_defaults(func=_cmd_gateway_start)
|
||||
|
||||
register_memory_parser(root_sub)
|
||||
register_stack_parser(root_sub)
|
||||
return p
|
||||
|
||||
|
||||
def main(argv: list[str] | None = None) -> int:
|
||||
if argv is None:
|
||||
argv = list(sys.argv[1:])
|
||||
if argv and len(argv) >= 1 and argv[0] == "wecom":
|
||||
argv = ["channel", "wecom", *argv[1:]]
|
||||
parser = _build_parser()
|
||||
args = parser.parse_args(argv)
|
||||
func = getattr(args, "func", None)
|
||||
if not callable(func):
|
||||
parser.print_help()
|
||||
return 2
|
||||
return int(func(args) or 0)
|
||||
|
||||
|
||||
__all__ = ["main"]
|
||||
97
ops/mcp_env.py
Normal file
97
ops/mcp_env.py
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
from __future__ import annotations
|
||||
|
||||
"""MCP 相关进程环境:默认 allowlist + 可选本地 env 文件(首选 `oclaw/_local/mcp_local.env`)。"""
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from oclaw.platform.config.paths import PROJECT_ROOT, db_path
|
||||
|
||||
_DEFAULT_ALLOWLIST = (
|
||||
"BRAVE_API_KEY,GOOGLE_OAUTH_CREDENTIALS,GOOGLE_CALENDAR_MCP_TOKEN_PATH,"
|
||||
"GITHUB_PERSONAL_ACCESS_TOKEN,CONTEXT7_API_KEY"
|
||||
)
|
||||
|
||||
|
||||
def mcp_env_allowlist_keys() -> list[str]:
|
||||
raw = str(os.getenv("AIA_MCP_ENV_ALLOWLIST") or "").strip()
|
||||
if not raw:
|
||||
return [x.strip() for x in _DEFAULT_ALLOWLIST.split(",") if x.strip()]
|
||||
return [x.strip() for x in raw.split(",") if x.strip()]
|
||||
|
||||
|
||||
def _parse_env_file(path: Path) -> dict[str, str]:
|
||||
out: dict[str, str] = {}
|
||||
if not path.is_file():
|
||||
return out
|
||||
try:
|
||||
raw = path.read_text(encoding="utf-8", errors="replace")
|
||||
except OSError:
|
||||
return out
|
||||
for line in raw.splitlines():
|
||||
line = line.strip()
|
||||
if not line or line.startswith("#"):
|
||||
continue
|
||||
if "=" not in line:
|
||||
continue
|
||||
k, _, v = line.partition("=")
|
||||
k = k.strip()
|
||||
v = v.strip().strip('"').strip("'")
|
||||
if k:
|
||||
out[k] = _expand_env_value(v)
|
||||
return out
|
||||
|
||||
|
||||
def _expand_env_value(v: str) -> str:
|
||||
s = v.strip()
|
||||
if "${PROJECT_ROOT}" in s:
|
||||
rel = s.split("${PROJECT_ROOT}", 1)[1].lstrip("/\\")
|
||||
s = str((PROJECT_ROOT / rel).resolve())
|
||||
return os.path.expandvars(s)
|
||||
|
||||
|
||||
def _mcp_local_env_paths_in_load_order() -> list[Path]:
|
||||
return [
|
||||
Path(db_path()).resolve().parent / "mcp_local.env",
|
||||
(PROJECT_ROOT / "oclaw" / "_local" / "mcp_local.env").resolve(),
|
||||
]
|
||||
|
||||
|
||||
def mcp_local_env_merged() -> dict[str, str]:
|
||||
out: dict[str, str] = {}
|
||||
for p in _mcp_local_env_paths_in_load_order():
|
||||
if p.is_file():
|
||||
out.update(_parse_env_file(p))
|
||||
return out
|
||||
|
||||
|
||||
def mcp_local_env_file_path() -> Path:
|
||||
return (PROJECT_ROOT / "oclaw" / "_local" / "mcp_local.env").resolve()
|
||||
|
||||
|
||||
def gateway_mcp_env_extras() -> dict[str, str]:
|
||||
extra: dict[str, str] = {}
|
||||
has_aia = str(os.getenv("AIA_MCP_ENV_ALLOWLIST") or "").strip()
|
||||
if not has_aia:
|
||||
extra["AIA_MCP_ENV_ALLOWLIST"] = _DEFAULT_ALLOWLIST
|
||||
file_vals = mcp_local_env_merged()
|
||||
for k, v in file_vals.items():
|
||||
if not v.strip():
|
||||
continue
|
||||
if not str(os.getenv(k) or "").strip():
|
||||
extra[k] = v
|
||||
return extra
|
||||
|
||||
|
||||
def apply_gateway_mcp_env_to_os() -> None:
|
||||
for k, v in gateway_mcp_env_extras().items():
|
||||
os.environ[k] = v
|
||||
|
||||
|
||||
__all__ = [
|
||||
"apply_gateway_mcp_env_to_os",
|
||||
"gateway_mcp_env_extras",
|
||||
"mcp_env_allowlist_keys",
|
||||
"mcp_local_env_file_path",
|
||||
"mcp_local_env_merged",
|
||||
]
|
||||
109
ops/mcp_registry_export.py
Normal file
109
ops/mcp_registry_export.py
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
"""Build a reinstallable MCP JSON from SQLite and persist under ``oclaw/_local/`` for migration."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import warnings
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from oclaw.platform.config.paths import PROJECT_ROOT
|
||||
from oclaw.platform.persistence.sqlite_store import SqliteStore
|
||||
from oclaw.tools.mcp.registry import McpRegistry
|
||||
|
||||
_EXPORT_FILENAME = "mcp_registry_migrated.json"
|
||||
_LOCAL_DIR = (PROJECT_ROOT / "oclaw" / "_local").resolve()
|
||||
_EXPORT_PATH = (_LOCAL_DIR / _EXPORT_FILENAME).resolve()
|
||||
|
||||
|
||||
def mcp_migrated_json_path() -> Path:
|
||||
return _EXPORT_PATH
|
||||
|
||||
|
||||
def _collapse_entry_arg(arg: str, root: Path) -> str:
|
||||
"""Rewrite absolute / repo-relative paths to ``__REPO_ROOT__/...`` when they exist on disk under root.
|
||||
|
||||
Skips npx flags (``-y``) and tokens that are not an existing file or directory, so package names
|
||||
(e.g. ``mcp-sqlite``, ``@upstash/foo``) are not mistaken for paths.
|
||||
"""
|
||||
t = (arg or "").strip()
|
||||
if not t or t.startswith("__REPO_ROOT__") or t.startswith("-"):
|
||||
return str(arg)
|
||||
r = root.resolve()
|
||||
a = Path(os.path.expanduser(t))
|
||||
if not a.is_absolute():
|
||||
a = (r / t).resolve()
|
||||
else:
|
||||
a = a.resolve()
|
||||
if not a.exists():
|
||||
return str(arg)
|
||||
try:
|
||||
rel = a.relative_to(r)
|
||||
except ValueError:
|
||||
return str(arg)
|
||||
return "__REPO_ROOT__/" + rel.as_posix()
|
||||
|
||||
|
||||
def _collapse_entry_args(args: list[str], root: Path) -> list[str]:
|
||||
return [_collapse_entry_arg(x, root) for x in args]
|
||||
|
||||
|
||||
def build_mcp_install_export_document(store: SqliteStore) -> dict[str, Any]:
|
||||
rows = McpRegistry(store).list_servers(enabled_only=False)
|
||||
root = PROJECT_ROOT.resolve()
|
||||
servers: list[dict[str, Any]] = []
|
||||
for r in rows:
|
||||
if not isinstance(r, dict):
|
||||
continue
|
||||
raw_args = r.get("entry_args")
|
||||
if isinstance(raw_args, list):
|
||||
entry_args = _collapse_entry_args([str(x) for x in raw_args if str(x).strip()], root)
|
||||
else:
|
||||
entry_args = []
|
||||
es = r.get("env_schema")
|
||||
env_schema = es if isinstance(es, dict) else {}
|
||||
perms = r.get("required_permissions")
|
||||
if not isinstance(perms, list):
|
||||
perms = []
|
||||
servers.append(
|
||||
{
|
||||
"server_id": str(r.get("server_id") or ""),
|
||||
"source_type": str(r.get("source_type") or ""),
|
||||
"source_ref": str(r.get("source_ref") or ""),
|
||||
"version": str(r.get("version") or ""),
|
||||
"entry_command": str(r.get("entry_command") or ""),
|
||||
"entry_args": entry_args,
|
||||
"env_schema": env_schema,
|
||||
"required_permissions": [str(x) for x in perms if str(x).strip()],
|
||||
"risk_level": str(r.get("risk_level") or "high"),
|
||||
"enabled": bool(r.get("enabled")),
|
||||
"timeout_s": float(r.get("timeout_s") or 30.0),
|
||||
"dry_run": False,
|
||||
}
|
||||
)
|
||||
return {
|
||||
"_comment": "管理台导出 / 新安装后自动落盘。可粘到「Install from JSON」;`__REPO_ROOT__/` 在管理台与 seed 中展开为仓库根。已存在路径会写成占位符,其余参数保持原样。",
|
||||
"exported_at": datetime.now(timezone.utc).isoformat(),
|
||||
"servers": servers,
|
||||
}
|
||||
|
||||
|
||||
def persist_mcp_migrated_file(store: SqliteStore) -> str | None:
|
||||
"""Write ``oclaw/_local/mcp_registry_migrated.json``. Fails open (warn only). Returns path or None."""
|
||||
try:
|
||||
mcp_migrated_json_path().parent.mkdir(parents=True, exist_ok=True)
|
||||
doc = build_mcp_install_export_document(store)
|
||||
path = mcp_migrated_json_path()
|
||||
path.write_text(json.dumps(doc, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
|
||||
return str(path)
|
||||
except OSError as exc:
|
||||
warnings.warn(f"mcp_registry_migrated write failed: {exc}", RuntimeWarning, stacklevel=1)
|
||||
return None
|
||||
|
||||
|
||||
__all__ = [
|
||||
"build_mcp_install_export_document",
|
||||
"mcp_migrated_json_path",
|
||||
"persist_mcp_migrated_file",
|
||||
]
|
||||
162
ops/memory.py
Normal file
162
ops/memory.py
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import datetime as dt
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def _now_date() -> dt.date:
|
||||
return dt.date.today()
|
||||
|
||||
|
||||
def _iso_week_label(day: dt.date) -> str:
|
||||
year, week, _weekday = day.isocalendar()
|
||||
return f"{year}-W{week:02d}"
|
||||
|
||||
|
||||
def _ensure_dirs(base_dir: Path) -> None:
|
||||
for name in ("Projects", "Areas", "Resources", "Archives", "Inbox", "runs"):
|
||||
(base_dir / name).mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
||||
def _count_notes(path: Path) -> int:
|
||||
if not path.exists():
|
||||
return 0
|
||||
count = 0
|
||||
for item in path.rglob("*.md"):
|
||||
if item.name.lower() == "readme.md":
|
||||
continue
|
||||
if "templates" in item.parts or "runs" in item.parts:
|
||||
continue
|
||||
count += 1
|
||||
return count
|
||||
|
||||
|
||||
def _recommend_new_cards(inbox_count: int, backlog_count: int, fresh_resources: int) -> int:
|
||||
target = 10
|
||||
if backlog_count > 0:
|
||||
target -= min(6, backlog_count // 20)
|
||||
if inbox_count > 20:
|
||||
target -= 2
|
||||
if fresh_resources >= 5 and backlog_count < 20:
|
||||
target += 1
|
||||
return max(3, min(10, target))
|
||||
|
||||
|
||||
def _build_focus_order(projects: int, areas: int, resources: int) -> list[str]:
|
||||
ranked = [("Projects", projects * 3), ("Areas", areas * 2), ("Resources", resources)]
|
||||
ranked.sort(key=lambda x: x[1], reverse=True)
|
||||
return [name for name, score in ranked if score > 0][:3]
|
||||
|
||||
|
||||
def _parse_date(text: str | None) -> dt.date:
|
||||
if not text:
|
||||
return _now_date()
|
||||
return dt.date.fromisoformat(text)
|
||||
|
||||
|
||||
def _cmd_memory_status(args: argparse.Namespace) -> int:
|
||||
base = Path(args.base_dir).resolve()
|
||||
_ensure_dirs(base)
|
||||
projects = _count_notes(base / "Projects")
|
||||
areas = _count_notes(base / "Areas")
|
||||
resources = _count_notes(base / "Resources")
|
||||
archives = _count_notes(base / "Archives")
|
||||
inbox = _count_notes(base / "Inbox")
|
||||
suggested = _recommend_new_cards(inbox, int(args.review_backlog), resources)
|
||||
focus = _build_focus_order(projects, areas, resources)
|
||||
print(f"base_dir={base}")
|
||||
print(f"projects={projects} areas={areas} resources={resources} archives={archives} inbox={inbox}")
|
||||
print(f"suggested_new_cards_per_day={suggested}")
|
||||
print("focus_topics=" + (",".join(focus) if focus else "Resources"))
|
||||
return 0
|
||||
|
||||
|
||||
def _cmd_memory_daily(args: argparse.Namespace) -> int:
|
||||
base = Path(args.base_dir).resolve()
|
||||
_ensure_dirs(base)
|
||||
day = _parse_date(args.date)
|
||||
projects = _count_notes(base / "Projects")
|
||||
areas = _count_notes(base / "Areas")
|
||||
resources = _count_notes(base / "Resources")
|
||||
inbox = _count_notes(base / "Inbox")
|
||||
suggested = _recommend_new_cards(inbox, int(args.review_backlog), resources)
|
||||
focus = _build_focus_order(projects, areas, resources)
|
||||
focus_topic = args.focus or (focus[0] if focus else "Resources")
|
||||
out = base / "runs" / f"daily-{day.isoformat()}.md"
|
||||
text = (
|
||||
f"# Daily Memory Run ({day.isoformat()})\n\n"
|
||||
f"- Focus topic: `{focus_topic}`\n"
|
||||
f"- Suggested new cards today: `{suggested}`\n"
|
||||
f"- Current inbox notes: `{inbox}`\n"
|
||||
f"- Review backlog input: `{int(args.review_backlog)}`\n\n"
|
||||
"## Auto Steps\n\n"
|
||||
"1. Capture 3-5 high-value items into `Inbox`.\n"
|
||||
"2. Distill 1-3 items into atomic notes under `Resources`.\n"
|
||||
"3. Convert notes into Q/A or cloze cards (respect suggested limit).\n"
|
||||
"4. Produce one output (summary/answer/code note).\n\n"
|
||||
"## Smart Suggestions\n\n"
|
||||
f"- Priority order now: `{', '.join(focus) if focus else 'Resources'}`\n"
|
||||
"- If reviews feel overloaded, reduce new cards before skipping due reviews.\n"
|
||||
"- If inbox keeps growing for 2+ days, process inbox first before new captures.\n"
|
||||
)
|
||||
out.write_text(text, encoding="utf-8")
|
||||
print(f"created={out}")
|
||||
return 0
|
||||
|
||||
|
||||
def _cmd_memory_weekly(args: argparse.Namespace) -> int:
|
||||
base = Path(args.base_dir).resolve()
|
||||
_ensure_dirs(base)
|
||||
day = _parse_date(args.date)
|
||||
week_label = _iso_week_label(day)
|
||||
projects = _count_notes(base / "Projects")
|
||||
areas = _count_notes(base / "Areas")
|
||||
resources = _count_notes(base / "Resources")
|
||||
archives = _count_notes(base / "Archives")
|
||||
inbox = _count_notes(base / "Inbox")
|
||||
suggested = _recommend_new_cards(inbox, int(args.review_backlog), resources)
|
||||
focus = _build_focus_order(projects, areas, resources)
|
||||
out = base / "runs" / f"weekly-{week_label}.md"
|
||||
text = (
|
||||
f"# Weekly Memory Review ({week_label})\n\n"
|
||||
f"- Run date: `{day.isoformat()}`\n"
|
||||
f"- Suggested next-week new cards/day: `{suggested}`\n\n"
|
||||
"## Snapshot\n\n"
|
||||
f"- Projects notes: `{projects}`\n"
|
||||
f"- Areas notes: `{areas}`\n"
|
||||
f"- Resources notes: `{resources}`\n"
|
||||
f"- Archives notes: `{archives}`\n"
|
||||
f"- Inbox notes: `{inbox}`\n\n"
|
||||
"## Fixed Review Checklist\n\n"
|
||||
"- [ ] Inbox zero\n- [ ] Linking/backlinks completion\n- [ ] Move inactive notes to Archives\n- [ ] Tune next-week card load\n\n"
|
||||
"## Auto Focus for Next Week\n\n"
|
||||
f"- Top topics: `{', '.join(focus) if focus else 'Resources'}`\n"
|
||||
"- Keep new cards within 3-10/day and adjust by real review pressure.\n"
|
||||
)
|
||||
out.write_text(text, encoding="utf-8")
|
||||
print(f"created={out}")
|
||||
return 0
|
||||
|
||||
|
||||
def register_memory_parser(root_sub: argparse._SubParsersAction[argparse.ArgumentParser]) -> None:
|
||||
memory = root_sub.add_parser("memory", help="Memory system automation")
|
||||
memory_sub = memory.add_subparsers(dest="memory_cmd", required=True)
|
||||
|
||||
status = memory_sub.add_parser("status", help="Show memory workload status")
|
||||
status.add_argument("--base-dir", default="oclaw/docs/memory-system", help="Memory system base directory")
|
||||
status.add_argument("--review-backlog", type=int, default=0, help="Current due review backlog")
|
||||
status.set_defaults(func=_cmd_memory_status)
|
||||
|
||||
daily = memory_sub.add_parser("daily", help="Generate today's automated memory run")
|
||||
daily.add_argument("--base-dir", default="oclaw/docs/memory-system", help="Memory system base directory")
|
||||
daily.add_argument("--date", default=None, help="Run date in YYYY-MM-DD")
|
||||
daily.add_argument("--focus", default=None, help="Override focus topic")
|
||||
daily.add_argument("--review-backlog", type=int, default=0, help="Current due review backlog")
|
||||
daily.set_defaults(func=_cmd_memory_daily)
|
||||
|
||||
weekly = memory_sub.add_parser("weekly", help="Generate weekly review run sheet")
|
||||
weekly.add_argument("--base-dir", default="oclaw/docs/memory-system", help="Memory system base directory")
|
||||
weekly.add_argument("--date", default=None, help="Run date in YYYY-MM-DD")
|
||||
weekly.add_argument("--review-backlog", type=int, default=0, help="Current due review backlog")
|
||||
weekly.set_defaults(func=_cmd_memory_weekly)
|
||||
4
ops/providers/__init__.py
Normal file
4
ops/providers/__init__.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
from __future__ import annotations
|
||||
|
||||
__all__ = []
|
||||
|
||||
14
ops/providers/base.py
Normal file
14
ops/providers/base.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from argparse import _SubParsersAction
|
||||
|
||||
|
||||
class ChannelProvider(ABC):
|
||||
@property
|
||||
@abstractmethod
|
||||
def name(self) -> str: ...
|
||||
|
||||
@abstractmethod
|
||||
def register(self, channel_subparsers: _SubParsersAction) -> None: ...
|
||||
|
||||
9
ops/providers/registry.py
Normal file
9
ops/providers/registry.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from .base import ChannelProvider
|
||||
from .wecom import WecomProvider
|
||||
|
||||
|
||||
def build_channel_registry() -> dict[str, ChannelProvider]:
|
||||
providers: list[ChannelProvider] = [WecomProvider()]
|
||||
return {p.name: p for p in providers}
|
||||
211
ops/providers/wecom.py
Normal file
211
ops/providers/wecom.py
Normal file
|
|
@ -0,0 +1,211 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import secrets
|
||||
import sys
|
||||
from argparse import _SubParsersAction
|
||||
|
||||
from oclaw.channels.wecom.longconn_runner import run_forever as run_wecom_longconn
|
||||
from oclaw.platform.config.paths import db_path
|
||||
from oclaw.platform.persistence.sqlite_store import SqliteStore
|
||||
|
||||
from .base import ChannelProvider
|
||||
|
||||
_CLEAR_KEYS = [
|
||||
"wecom_mode",
|
||||
"wecom_bot_id",
|
||||
"wecom_bot_secret",
|
||||
"wecom_corp_id",
|
||||
"wecom_agent_id",
|
||||
"wecom_agent_secret",
|
||||
"wecom_access_token_cache",
|
||||
"wecom_last_msg_ts",
|
||||
"wecom_last_from_user",
|
||||
"wecom_recent_from_users",
|
||||
"wecom_last_cmd",
|
||||
"wecom_last_unknown_cmd_payload",
|
||||
"wecom_last_raw_body",
|
||||
"wecom_last_raw_from_user",
|
||||
"wecom_last_parse_error",
|
||||
]
|
||||
|
||||
|
||||
def _store() -> SqliteStore:
|
||||
return SqliteStore(db_path())
|
||||
|
||||
|
||||
class WecomProvider(ChannelProvider):
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return "wecom"
|
||||
|
||||
def register(self, channel_subparsers: _SubParsersAction) -> None:
|
||||
p = channel_subparsers.add_parser(self.name, help="WeCom channel operations")
|
||||
sub = p.add_subparsers(dest="channel_action", required=True)
|
||||
|
||||
start = sub.add_parser("start", help="Start WeCom long connection runner")
|
||||
start.add_argument("--mode", choices=["ws", "pull", "mock"], help="Runner mode")
|
||||
start.add_argument("--interval", type=float, help="Polling interval for non-ws modes")
|
||||
start.add_argument("--deliver-outbound", action=argparse.BooleanOptionalAction, default=None)
|
||||
start.add_argument("--ws-url", help="Override websocket URL")
|
||||
start.add_argument("--pull-url", help="Pull mode URL")
|
||||
start.set_defaults(func=self._cmd_start)
|
||||
|
||||
status = sub.add_parser("status", help="Show WeCom status snapshot")
|
||||
status.set_defaults(func=self._cmd_status)
|
||||
|
||||
doctor = sub.add_parser("doctor", help="Run lightweight environment checks")
|
||||
doctor.set_defaults(func=self._cmd_doctor)
|
||||
|
||||
config = sub.add_parser("config", help="Configure WeCom credentials")
|
||||
config_sub = config.add_subparsers(dest="config_cmd", required=True)
|
||||
conf_set = config_sub.add_parser("set", help="Set bot credentials (bot_api)")
|
||||
conf_set.add_argument("--bot-id", required=True)
|
||||
conf_set.add_argument("--bot-secret", required=True)
|
||||
conf_set.set_defaults(func=self._cmd_config_set)
|
||||
|
||||
auto_bind = sub.add_parser("auto-bind", help="Manage auto bind behavior")
|
||||
auto_bind.add_argument("action", choices=["on", "off", "show"])
|
||||
auto_bind.add_argument("tenant_name", nargs="?")
|
||||
auto_bind.add_argument("role", nargs="?")
|
||||
auto_bind.set_defaults(func=self._cmd_auto_bind)
|
||||
|
||||
smoke = sub.add_parser("smoke", help="Run smoke test")
|
||||
smoke.add_argument("--ws", action="store_true", help="Run bot websocket subscribe smoke")
|
||||
smoke.set_defaults(func=self._cmd_smoke)
|
||||
|
||||
create_bind = sub.add_parser("create-bind", help="Create a bind code")
|
||||
create_bind.add_argument("--role", default="member")
|
||||
create_bind.set_defaults(func=self._cmd_create_bind)
|
||||
|
||||
unbind = sub.add_parser("unbind", help="Clear local wecom config and wecom bindings")
|
||||
unbind.set_defaults(func=self._cmd_unbind)
|
||||
|
||||
switch = sub.add_parser("switch-bot", help="Switch to a new bot quickly")
|
||||
switch.add_argument("bot_id")
|
||||
switch.add_argument("bot_secret")
|
||||
switch.set_defaults(func=self._cmd_switch)
|
||||
|
||||
def _cmd_start(self, args: argparse.Namespace) -> int:
|
||||
if args.mode:
|
||||
os.environ["WECOM_LONGCONN_MODE"] = args.mode
|
||||
if args.interval is not None:
|
||||
os.environ["WECOM_LONGCONN_INTERVAL_SEC"] = str(args.interval)
|
||||
if args.deliver_outbound is not None:
|
||||
os.environ["WECOM_LONGCONN_DELIVER_OUTBOUND"] = "1" if args.deliver_outbound else "0"
|
||||
if args.ws_url:
|
||||
os.environ["WECOM_LONGCONN_WS_URL"] = args.ws_url
|
||||
if args.pull_url:
|
||||
os.environ["WECOM_LONGCONN_PULL_URL"] = args.pull_url
|
||||
return run_wecom_longconn()
|
||||
|
||||
def _cmd_status(self, _args: argparse.Namespace) -> int:
|
||||
from scripts.wecom_status import main as status_main
|
||||
|
||||
return status_main()
|
||||
|
||||
def _cmd_doctor(self, _args: argparse.Namespace) -> int:
|
||||
s = _store()
|
||||
print("ok=1")
|
||||
print(f"db_path={db_path()}")
|
||||
mode = str(s.get_setting("wecom_mode") or "").strip() or "auto"
|
||||
print(f"mode_setting={mode}")
|
||||
print(f"bot_id_set={1 if s.get_setting('wecom_bot_id') else 0}")
|
||||
print(f"bot_secret_set={1 if s.get_secret('wecom_bot_secret') else 0}")
|
||||
try:
|
||||
import websocket # type: ignore # noqa: F401
|
||||
|
||||
print("websocket_client=ok")
|
||||
except Exception as exc:
|
||||
print(f"websocket_client=missing ({type(exc).__name__})")
|
||||
return 0
|
||||
|
||||
def _cmd_config_set(self, args: argparse.Namespace) -> int:
|
||||
s = _store()
|
||||
s.set_setting("wecom_mode", "bot_api")
|
||||
s.set_setting("wecom_bot_id", args.bot_id)
|
||||
s.set_secret("wecom_bot_secret", args.bot_secret)
|
||||
s.delete_setting("wecom_access_token_cache")
|
||||
print("ok=1")
|
||||
print("mode=bot_api")
|
||||
return 0
|
||||
|
||||
def _cmd_auto_bind(self, args: argparse.Namespace) -> int:
|
||||
s = _store()
|
||||
if args.action == "show":
|
||||
print("ok=1")
|
||||
print(f"enabled={str(s.get_setting('wecom_auto_bind_enabled') or '1').strip()}")
|
||||
print(f"tenant_name={str(s.get_setting('wecom_auto_bind_tenant_name') or 'Team').strip() or 'Team'}")
|
||||
print(f"role={str(s.get_setting('wecom_auto_bind_role') or 'member').strip() or 'member'}")
|
||||
return 0
|
||||
enabled = "1" if args.action == "on" else "0"
|
||||
s.set_setting("wecom_auto_bind_enabled", enabled)
|
||||
if args.tenant_name:
|
||||
s.set_setting("wecom_auto_bind_tenant_name", args.tenant_name.strip())
|
||||
if args.role:
|
||||
s.set_setting("wecom_auto_bind_role", args.role.strip())
|
||||
print("ok=1")
|
||||
print(f"enabled={enabled}")
|
||||
return 0
|
||||
|
||||
def _cmd_smoke(self, args: argparse.Namespace) -> int:
|
||||
from scripts.wecom_smoke_test import main as smoke_main
|
||||
|
||||
old = sys.argv
|
||||
try:
|
||||
argv = ["wecom_smoke_test.py"]
|
||||
if args.ws:
|
||||
argv.append("--ws")
|
||||
sys.argv = argv
|
||||
return smoke_main()
|
||||
finally:
|
||||
sys.argv = old
|
||||
|
||||
def _cmd_create_bind(self, args: argparse.Namespace) -> int:
|
||||
s = _store()
|
||||
tenants = s.list_tenants(limit=1)
|
||||
if tenants:
|
||||
tenant_id = tenants[0]["id"]
|
||||
tenant_name = tenants[0]["name"]
|
||||
else:
|
||||
t = s.create_tenant("Team")
|
||||
tenant_id = t["id"]
|
||||
tenant_name = t["name"]
|
||||
role = args.role or "member"
|
||||
code = secrets.token_urlsafe(6)
|
||||
s.create_bind_code(tenant_id=tenant_id, role=role, code=code)
|
||||
print(f"tenant={tenant_name} ({tenant_id})")
|
||||
print(f"role={role}")
|
||||
print(f"bind_code={code}")
|
||||
print(f"wecom_cmd=bind {code}")
|
||||
return 0
|
||||
|
||||
def _cmd_unbind(self, _args: argparse.Namespace) -> int:
|
||||
s = _store()
|
||||
with s._connect() as conn:
|
||||
cur_ident = conn.execute("DELETE FROM channel_identity WHERE channel = ?", ("wecom",))
|
||||
ident_deleted = int(cur_ident.rowcount or 0)
|
||||
cur_sess = conn.execute("DELETE FROM channel_session WHERE channel = ?", ("wecom",))
|
||||
sess_deleted = int(cur_sess.rowcount or 0)
|
||||
for k in _CLEAR_KEYS:
|
||||
s.delete_setting(k)
|
||||
print("ok=1")
|
||||
print(f"deleted_channel_identity={ident_deleted}")
|
||||
print(f"deleted_channel_session={sess_deleted}")
|
||||
return 0
|
||||
|
||||
def _cmd_switch(self, args: argparse.Namespace) -> int:
|
||||
s = _store()
|
||||
s.set_setting("wecom_mode", "bot_api")
|
||||
s.set_setting("wecom_bot_id", args.bot_id)
|
||||
s.set_secret("wecom_bot_secret", args.bot_secret)
|
||||
for k in _CLEAR_KEYS:
|
||||
if k not in ("wecom_bot_id", "wecom_bot_secret", "wecom_mode"):
|
||||
s.delete_setting(k)
|
||||
print("ok=1")
|
||||
print("mode=bot_api")
|
||||
print(f"bot_id={args.bot_id}")
|
||||
print("next=python -m oclaw.ops channel wecom start")
|
||||
return 0
|
||||
|
||||
293
ops/runtime.py
Normal file
293
ops/runtime.py
Normal file
|
|
@ -0,0 +1,293 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from oclaw.platform.config.paths import db_path
|
||||
|
||||
|
||||
def _runtime_file() -> Path:
|
||||
return Path(db_path()).resolve().parent / "ops_runtime_state.json"
|
||||
|
||||
|
||||
def _runtime_log_dir() -> Path:
|
||||
p = str(os.getenv("AIA_RUNTIME_LOG_DIR") or "").strip()
|
||||
if p:
|
||||
return Path(p).expanduser().resolve()
|
||||
return Path(db_path()).resolve().parent / "logs"
|
||||
|
||||
|
||||
def _read_state() -> dict[str, Any]:
|
||||
p = _runtime_file()
|
||||
if not p.exists():
|
||||
return {"services": {}}
|
||||
try:
|
||||
obj = json.loads(p.read_text(encoding="utf-8"))
|
||||
except Exception:
|
||||
return {"services": {}}
|
||||
if not isinstance(obj, dict):
|
||||
return {"services": {}}
|
||||
if not isinstance(obj.get("services"), dict):
|
||||
obj["services"] = {}
|
||||
return obj
|
||||
|
||||
|
||||
def _write_state(state: dict[str, Any]) -> None:
|
||||
p = _runtime_file()
|
||||
p.parent.mkdir(parents=True, exist_ok=True)
|
||||
p.write_text(json.dumps(state, ensure_ascii=False, indent=2), encoding="utf-8")
|
||||
|
||||
|
||||
def _is_running(pid: int) -> bool:
|
||||
if pid <= 0:
|
||||
return False
|
||||
if os.name == "nt":
|
||||
try:
|
||||
out = subprocess.check_output(
|
||||
["tasklist", "/FI", f"PID eq {int(pid)}", "/FO", "CSV", "/NH"],
|
||||
stderr=subprocess.DEVNULL,
|
||||
text=True,
|
||||
)
|
||||
text = (out or "").strip().lower()
|
||||
return bool(text and "no tasks are running" not in text and "info:" not in text)
|
||||
except Exception:
|
||||
return False
|
||||
try:
|
||||
os.kill(pid, 0)
|
||||
return True
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
def _python_bin() -> str:
|
||||
return sys.executable or "python"
|
||||
|
||||
|
||||
def _service_signature(name: str) -> str | None:
|
||||
n = str(name or "").strip().lower()
|
||||
if n == "gateway":
|
||||
return "-m oclaw.ops gateway start"
|
||||
if n == "ui":
|
||||
return "-m oclaw.ops ui start"
|
||||
if n.startswith("channel:"):
|
||||
ch = n.split(":", 1)[1].strip()
|
||||
if ch:
|
||||
return f"-m oclaw.ops channel {ch} start"
|
||||
return None
|
||||
|
||||
|
||||
def _find_pids_by_signature(signature: str) -> list[int]:
|
||||
sig = str(signature or "").strip().lower()
|
||||
if not sig:
|
||||
return []
|
||||
out: list[int] = []
|
||||
if os.name == "nt":
|
||||
try:
|
||||
raw = subprocess.check_output(
|
||||
["wmic", "process", "where", "name='python.exe'", "get", "ProcessId,CommandLine"],
|
||||
stderr=subprocess.DEVNULL,
|
||||
text=True,
|
||||
encoding="utf-8",
|
||||
errors="replace",
|
||||
)
|
||||
except Exception:
|
||||
return []
|
||||
for line in (raw or "").splitlines():
|
||||
txt = line.strip()
|
||||
if not txt or txt.lower().startswith("commandline"):
|
||||
continue
|
||||
parts = txt.rsplit(None, 1)
|
||||
if len(parts) != 2:
|
||||
continue
|
||||
cmd, pid_s = parts[0].strip(), parts[1].strip()
|
||||
if not pid_s.isdigit():
|
||||
continue
|
||||
if sig in cmd.lower():
|
||||
out.append(int(pid_s))
|
||||
return out
|
||||
try:
|
||||
raw = subprocess.check_output(
|
||||
["ps", "-eo", "pid=,args="],
|
||||
stderr=subprocess.DEVNULL,
|
||||
text=True,
|
||||
encoding="utf-8",
|
||||
errors="replace",
|
||||
)
|
||||
except Exception:
|
||||
return []
|
||||
for line in (raw or "").splitlines():
|
||||
txt = line.strip()
|
||||
if not txt:
|
||||
continue
|
||||
parts = txt.split(None, 1)
|
||||
if len(parts) != 2:
|
||||
continue
|
||||
pid_s, cmd = parts
|
||||
if not pid_s.isdigit():
|
||||
continue
|
||||
if sig in cmd.lower():
|
||||
out.append(int(pid_s))
|
||||
return out
|
||||
|
||||
|
||||
def _kill_pid_force(pid: int) -> bool:
|
||||
if pid <= 0:
|
||||
return False
|
||||
try:
|
||||
if os.name == "nt":
|
||||
subprocess.call(["taskkill", "/PID", str(pid), "/T", "/F"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
else:
|
||||
os.kill(pid, signal.SIGTERM)
|
||||
return True
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
def _cleanup_orphan_service_processes(name: str, *, keep_pids: set[int] | None = None) -> list[int]:
|
||||
sig = _service_signature(name)
|
||||
if not sig:
|
||||
return []
|
||||
keep = keep_pids or set()
|
||||
killed: list[int] = []
|
||||
for pid in _find_pids_by_signature(sig):
|
||||
if pid in keep:
|
||||
continue
|
||||
if _kill_pid_force(pid):
|
||||
killed.append(pid)
|
||||
return killed
|
||||
|
||||
|
||||
def detect_orphan_service_processes(name: str, *, keep_pids: set[int] | None = None) -> list[int]:
|
||||
sig = _service_signature(name)
|
||||
if not sig:
|
||||
return []
|
||||
keep = keep_pids or set()
|
||||
out: list[int] = []
|
||||
for pid in _find_pids_by_signature(sig):
|
||||
if pid in keep:
|
||||
continue
|
||||
out.append(pid)
|
||||
return out
|
||||
|
||||
|
||||
def cleanup_orphan_service_processes(name: str, *, keep_pids: set[int] | None = None) -> list[int]:
|
||||
return _cleanup_orphan_service_processes(name, keep_pids=keep_pids)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class ServiceState:
|
||||
name: str
|
||||
pid: int
|
||||
command: list[str]
|
||||
running: bool
|
||||
|
||||
|
||||
def start_service(*, name: str, command: list[str], env: dict[str, str] | None = None, cwd: str | None = None) -> int:
|
||||
state = _read_state()
|
||||
services = state.setdefault("services", {})
|
||||
_cleanup_orphan_service_processes(name)
|
||||
existing = services.get(name)
|
||||
if isinstance(existing, dict):
|
||||
pid = int(existing.get("pid") or 0)
|
||||
if _is_running(pid):
|
||||
return pid
|
||||
merged_env = os.environ.copy()
|
||||
if env:
|
||||
merged_env.update({str(k): str(v) for k, v in env.items()})
|
||||
merged_env.setdefault("PYTHONUNBUFFERED", "1")
|
||||
log_dir = _runtime_log_dir()
|
||||
log_dir.mkdir(parents=True, exist_ok=True)
|
||||
safe_name = str(name).replace(":", "_").replace("/", "_").replace("\\", "_")
|
||||
stdout_path = log_dir / f"{safe_name}.out.log"
|
||||
stderr_path = log_dir / f"{safe_name}.err.log"
|
||||
stdout_fh = open(stdout_path, "ab")
|
||||
stderr_fh = open(stderr_path, "ab")
|
||||
kwargs: dict[str, Any] = {
|
||||
"env": merged_env,
|
||||
"cwd": cwd or str(Path.cwd()),
|
||||
"stdin": subprocess.DEVNULL,
|
||||
"stdout": stdout_fh,
|
||||
"stderr": stderr_fh,
|
||||
}
|
||||
if os.name == "nt":
|
||||
create_no_window = getattr(subprocess, "CREATE_NO_WINDOW", 0)
|
||||
create_detached = getattr(subprocess, "DETACHED_PROCESS", 0)
|
||||
create_group = getattr(subprocess, "CREATE_NEW_PROCESS_GROUP", 0)
|
||||
kwargs["creationflags"] = create_group | create_detached | create_no_window
|
||||
startupinfo = subprocess.STARTUPINFO()
|
||||
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||
startupinfo.wShowWindow = 0
|
||||
kwargs["startupinfo"] = startupinfo
|
||||
else:
|
||||
kwargs["start_new_session"] = True
|
||||
try:
|
||||
proc = subprocess.Popen(command, **kwargs)
|
||||
finally:
|
||||
try:
|
||||
stdout_fh.close()
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
stderr_fh.close()
|
||||
except Exception:
|
||||
pass
|
||||
services[name] = {
|
||||
"pid": int(proc.pid),
|
||||
"command": command,
|
||||
"stdout_log": str(stdout_path),
|
||||
"stderr_log": str(stderr_path),
|
||||
}
|
||||
_write_state(state)
|
||||
return int(proc.pid)
|
||||
|
||||
|
||||
def status_services() -> list[ServiceState]:
|
||||
state = _read_state()
|
||||
services = state.get("services")
|
||||
if not isinstance(services, dict):
|
||||
return []
|
||||
out: list[ServiceState] = []
|
||||
for name, meta in services.items():
|
||||
if not isinstance(meta, dict):
|
||||
continue
|
||||
pid = int(meta.get("pid") or 0)
|
||||
cmd = meta.get("command") if isinstance(meta.get("command"), list) else []
|
||||
out.append(ServiceState(name=str(name), pid=pid, command=[str(x) for x in cmd], running=_is_running(pid)))
|
||||
return out
|
||||
|
||||
|
||||
def stop_service(name: str) -> bool:
|
||||
state = _read_state()
|
||||
services = state.get("services")
|
||||
if not isinstance(services, dict):
|
||||
return False
|
||||
meta = services.get(name)
|
||||
if not isinstance(meta, dict):
|
||||
return False
|
||||
pid = int(meta.get("pid") or 0)
|
||||
ok = False
|
||||
if _is_running(pid):
|
||||
ok = _kill_pid_force(pid)
|
||||
services.pop(name, None)
|
||||
_write_state(state)
|
||||
orphan_killed = _cleanup_orphan_service_processes(name, keep_pids={pid})
|
||||
return bool(ok or orphan_killed)
|
||||
|
||||
|
||||
def stop_all() -> list[str]:
|
||||
stopped: list[str] = []
|
||||
for s in status_services():
|
||||
if stop_service(s.name):
|
||||
stopped.append(s.name)
|
||||
return stopped
|
||||
|
||||
|
||||
def default_python_command(args: list[str]) -> list[str]:
|
||||
return [_python_bin(), *args]
|
||||
|
||||
91
ops/stack.py
Normal file
91
ops/stack.py
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
from typing import Any
|
||||
|
||||
from .mcp_env import gateway_mcp_env_extras
|
||||
from .runtime import default_python_command, start_service, status_services, stop_all
|
||||
|
||||
|
||||
def cmd_stack_up(args: argparse.Namespace) -> int:
|
||||
started: list[tuple[str, int]] = []
|
||||
gateway_cmd = default_python_command(
|
||||
[
|
||||
"-m",
|
||||
"oclaw.ops",
|
||||
"gateway",
|
||||
"start",
|
||||
"--host",
|
||||
args.gateway_host,
|
||||
"--port",
|
||||
str(args.gateway_port),
|
||||
]
|
||||
)
|
||||
started.append(("gateway", start_service(name="gateway", command=gateway_cmd, env=gateway_mcp_env_extras())))
|
||||
|
||||
channel_cmd = default_python_command(
|
||||
[
|
||||
"-m",
|
||||
"oclaw.ops",
|
||||
"channel",
|
||||
args.channel,
|
||||
"start",
|
||||
"--mode",
|
||||
args.channel_mode,
|
||||
"--interval",
|
||||
str(args.channel_interval),
|
||||
"--deliver-outbound" if args.deliver_outbound else "--no-deliver-outbound",
|
||||
]
|
||||
)
|
||||
if args.channel_mode == "pull" and args.pull_url:
|
||||
channel_cmd.extend(["--pull-url", args.pull_url])
|
||||
started.append((f"channel:{args.channel}", start_service(name=f"channel:{args.channel}", command=channel_cmd)))
|
||||
|
||||
if args.with_ui:
|
||||
print(
|
||||
"hint=--with-ui ignored: Streamlit is disabled; use Ops Chat at "
|
||||
f"http://127.0.0.1:{int(args.gateway_port)}/chat",
|
||||
file=sys.stderr,
|
||||
)
|
||||
print("ok=1")
|
||||
for name, pid in started:
|
||||
print(f"{name}_pid={pid}")
|
||||
print("hint=use `python -m oclaw.ops stack status` to check running services")
|
||||
return 0
|
||||
|
||||
|
||||
def cmd_stack_status(_args: argparse.Namespace) -> int:
|
||||
rows = status_services()
|
||||
print("ok=1")
|
||||
print(f"services={len(rows)}")
|
||||
for r in rows:
|
||||
print(f"service={r.name} pid={r.pid} running={1 if r.running else 0}")
|
||||
return 0
|
||||
|
||||
|
||||
def cmd_stack_down(_args: argparse.Namespace) -> int:
|
||||
stopped = stop_all()
|
||||
print("ok=1")
|
||||
print(f"stopped={','.join(stopped)}")
|
||||
return 0
|
||||
|
||||
|
||||
def register_stack_parser(root_subparsers: Any) -> None:
|
||||
stack = root_subparsers.add_parser("stack", help="Manage local multi-service stack")
|
||||
sub = stack.add_subparsers(dest="stack_cmd", required=True)
|
||||
up = sub.add_parser("up", help="Start gateway + channel worker")
|
||||
up.add_argument("--channel", default="wecom")
|
||||
up.add_argument("--channel-mode", choices=["ws", "pull", "mock"], default="ws")
|
||||
up.add_argument("--channel-interval", type=float, default=3.0)
|
||||
up.add_argument("--deliver-outbound", action=argparse.BooleanOptionalAction, default=True)
|
||||
up.add_argument("--pull-url", default=None)
|
||||
up.add_argument("--gateway-host", default="0.0.0.0")
|
||||
up.add_argument("--gateway-port", type=int, default=8787)
|
||||
up.add_argument("--with-ui", action="store_true", help="Ignored (deprecated): legacy Streamlit; use http://127.0.0.1:<gateway-port>/chat")
|
||||
up.add_argument("--ui-port", type=int, default=8501, help="Unused (reserved for compatibility)")
|
||||
up.set_defaults(func=cmd_stack_up)
|
||||
status = sub.add_parser("status", help="Show stack service status")
|
||||
status.set_defaults(func=cmd_stack_status)
|
||||
down = sub.add_parser("down", help="Stop all stack services started by ops runtime")
|
||||
down.set_defaults(func=cmd_stack_down)
|
||||
Loading…
Add table
Add a link
Reference in a new issue