Return ``(source, error)``.
(tool_input: dict, cwd: Optional[Path])
| 68 | |
| 69 | |
| 70 | def _resolve_source(tool_input: dict, cwd: Optional[Path]) -> tuple[Optional[str], Optional[str]]: |
| 71 | """Return ``(source, error)``.""" |
| 72 | script = tool_input.get("script") |
| 73 | if isinstance(script, str) and script.strip(): |
| 74 | return script, None |
| 75 | script_path = tool_input.get("script_path") |
| 76 | if isinstance(script_path, str) and script_path.strip(): |
| 77 | try: |
| 78 | return Path(script_path).read_text(encoding="utf-8"), None |
| 79 | except OSError as exc: |
| 80 | return None, f"could not read script_path: {exc}" |
| 81 | name = tool_input.get("name") |
| 82 | if isinstance(name, str) and name.strip(): |
| 83 | source = resolve_named_workflow(name, cwd) |
| 84 | if source is None: |
| 85 | return None, f"no saved workflow named '{name}' under .claude/workflows" |
| 86 | return source, None |
| 87 | return None, "provide one of: script, script_path, or name" |
| 88 | |
| 89 | |
| 90 | def _default_runner_factory(registry: Any, provider: Any) -> Callable[[ToolContext, str], Any]: |