mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-11 08:10:48 +08:00
Add one-shot UME alarm Excel delivery for WhatsApp ops.
Collapse query+xlsx+deliverable into ume_alarm_xlsx_report, allow write_xlsx(deliverable=true), and accept run_command aliases to cut multi-tool loops. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
aff11c1eae
commit
e03c90fb35
10 changed files with 564 additions and 27 deletions
|
|
@ -8,24 +8,36 @@ from runtime.tools.public.local_sdk import get_local_adapter
|
|||
|
||||
def run_command_tool() -> ToolSpec:
|
||||
def _handler(args: dict[str, Any]) -> dict[str, Any]:
|
||||
command = str(args.get("command") or "").strip()
|
||||
command = str(
|
||||
args.get("command") or args.get("cmd") or args.get("shell") or args.get("script") or ""
|
||||
).strip()
|
||||
if not command:
|
||||
return {"ok": False, "error_code": "command_required", "error": "command_required"}
|
||||
cwd = str(args.get("cwd") or "").strip() or None
|
||||
return {
|
||||
"ok": False,
|
||||
"error_code": "command_required",
|
||||
"error": "command_required",
|
||||
"hint": "Pass command (aliases: cmd, shell).",
|
||||
"example": {"command": "echo hello", "timeout": 60},
|
||||
}
|
||||
cwd = str(args.get("cwd") or args.get("workdir") or "").strip() or None
|
||||
timeout = int(args.get("timeout") or 300)
|
||||
return get_local_adapter().run_command(command=command, cwd=cwd, timeout=timeout)
|
||||
|
||||
return ToolSpec(
|
||||
name="run_command",
|
||||
description="Run a shell command via local backend.",
|
||||
description="Run a shell command via local backend. Prefer cmd aliases: command/cmd/shell.",
|
||||
parameters={
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"command": {"type": "string", "description": "Shell command to execute."},
|
||||
"cmd": {"type": "string", "description": "Alias for command."},
|
||||
"shell": {"type": "string", "description": "Alias for command."},
|
||||
"script": {"type": "string", "description": "Alias for command."},
|
||||
"cwd": {"type": "string", "description": "Optional working directory."},
|
||||
"workdir": {"type": "string", "description": "Alias for cwd."},
|
||||
"timeout": {"type": "integer", "description": "Timeout in seconds.", "default": 300},
|
||||
},
|
||||
"required": ["command"],
|
||||
"required": [],
|
||||
"additionalProperties": False,
|
||||
},
|
||||
handler=_handler,
|
||||
|
|
|
|||
|
|
@ -216,6 +216,12 @@ def write_xlsx_tool() -> ToolSpec:
|
|||
return {"ok": False, "error": "path_write_failed", "detail": str(exc)}
|
||||
|
||||
meta = AttachmentAssetStore().save_bytes(blob, filename=filename, mime=XLSX_MIME)
|
||||
deliverable = args.get("deliverable") is True or str(args.get("deliverable") or "").strip().lower() in {
|
||||
"1",
|
||||
"true",
|
||||
"yes",
|
||||
"on",
|
||||
}
|
||||
out: dict[str, Any] = {
|
||||
"ok": True,
|
||||
"attachment_id": meta.attachment_id,
|
||||
|
|
@ -224,12 +230,16 @@ def write_xlsx_tool() -> ToolSpec:
|
|||
"bytes": meta.bytes,
|
||||
"sheet_count": len(summary),
|
||||
"sheets": summary,
|
||||
"hint": (
|
||||
"Excel saved to attachment store. Not sent to channel yet. "
|
||||
"If the user asked to receive the file, call save_deliverable_attachment "
|
||||
"with this attachment_id."
|
||||
),
|
||||
}
|
||||
if deliverable:
|
||||
out["deliverable"] = True
|
||||
out["hint"] = "Excel marked deliverable — channel outbound will attach this file."
|
||||
else:
|
||||
out["hint"] = (
|
||||
"Excel saved to attachment store. Not sent to channel yet. "
|
||||
"If the user asked to receive the file, either re-call with deliverable=true "
|
||||
"or call save_deliverable_attachment with this attachment_id."
|
||||
)
|
||||
if path_written:
|
||||
out["path"] = path_written
|
||||
return out
|
||||
|
|
@ -238,8 +248,8 @@ def write_xlsx_tool() -> ToolSpec:
|
|||
name="write_xlsx",
|
||||
description=(
|
||||
"Build a real .xlsx workbook from structured sheet data (headers + rows) and save it "
|
||||
"to the attachment store. Returns attachment_id/name/mime/bytes — does NOT mark "
|
||||
"deliverable and does NOT send to WhatsApp/WeChat. To deliver, call "
|
||||
"to the attachment store. Returns attachment_id/name/mime/bytes. "
|
||||
"Set deliverable=true to send on WhatsApp/WeChat in one step; otherwise call "
|
||||
"save_deliverable_attachment(attachment_id=...). Prefer this over run_command/openpyxl."
|
||||
),
|
||||
parameters={
|
||||
|
|
@ -343,6 +353,14 @@ def write_xlsx_tool() -> ToolSpec:
|
|||
"default": True,
|
||||
"description": "Best-effort column width from sample cells (default true).",
|
||||
},
|
||||
"deliverable": {
|
||||
"type": "boolean",
|
||||
"default": False,
|
||||
"description": (
|
||||
"If true, mark the workbook for channel delivery (WhatsApp/WeChat) "
|
||||
"without a separate save_deliverable_attachment call."
|
||||
),
|
||||
},
|
||||
},
|
||||
"required": [],
|
||||
"additionalProperties": False,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue