mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-28 13:32:23 +00:00
* refactor(transcript): update session transcript paths and enhance directory structure
- Changed the source of truth path for session transcripts from `sessions/{DDMMYYYY}/{agent}_{index}.jsonl` to `session_raw/{DDMMYYYY}/{agent}_{index}.jsonl` to better reflect the organization of files.
- Updated the logic for creating and resolving transcript paths to accommodate the new directory structure, ensuring compatibility with legacy `.md` files.
- Improved documentation to clarify the changes in file organization and their implications for transcript management.
This refactor enhances the clarity and maintainability of session transcript handling by establishing a more logical file structure.
* refactor(prompts): update tool handling in prompt builders
- Replaced `Vec<String>` with `Vec<ToolSummary<'_>>` for available tools in multiple agent prompt builders, enhancing type safety and clarity.
- Introduced `render_tool_catalog` and `render_connected_integrations` functions to dynamically generate sections in prompts based on available tools and connected integrations.
- Updated the `build` function in various agent prompts to utilize the new rendering functions, ensuring that prompts accurately reflect the current context and available resources.
These changes improve the maintainability and functionality of the prompt generation process across different agents.
* refactor(prompts): streamline prompt builders for agent templates
- Updated the prompt builders for various agents to utilize the sibling `prompt.md` template directly, enhancing clarity and maintainability.
- Replaced `Vec<ToolSummary<'_>>` with `Vec<ToolSummary>` and `Vec<ConnectedIntegration>` for improved type safety in test cases.
- Adjusted the `build` function to ensure consistent formatting and handling of tool catalogs across different agents.
These changes simplify the prompt generation process and prepare the codebase for future enhancements.
* refactor(harness): unify tool filtering and prompt loading for debug consistency
- Exposed `filter_tool_indices` and `load_prompt_source` as `pub(crate)` to ensure that both the live runner and debug dump share the same filtering and loading logic, eliminating discrepancies.
- Enhanced documentation for both functions to clarify their purpose and usage, improving maintainability and understanding of the codebase.
These changes streamline the tool management process and enhance the reliability of debug outputs, ensuring consistency across different contexts.
* refactor(prompts): enhance prompt builders for agent templates
- Updated the prompt builders for various agents to return fully-assembled system prompts, incorporating section helpers from `crate::openhuman::context::prompt`.
- Replaced `Vec<ToolSummary<'_>>` with `Vec<ToolSummary>` and `Vec<ConnectedIntegration>` for improved type safety in test cases.
- Adjusted the `build` function to ensure consistent formatting and handling of user files, tools, and workspace sections across different agents.
These changes streamline the prompt generation process, improve maintainability, and prepare the codebase for future enhancements.
* refactor(prompts): enhance prompt context handling for dynamic sources
- Updated the prompt builders to support fully-assembled prompts from dynamic sources, allowing for more flexible prompt generation.
- Introduced `PromptTool` and `PromptContext` structures to replace `ToolSummary`, improving type safety and clarity in prompt construction.
- Refactored the handling of prompt sources in both the subagent runner and session builder to streamline the integration of dynamic prompts and legacy sources.
These changes improve the maintainability and functionality of the prompt generation process, ensuring accurate representation of available tools and context in agent interactions.
* refactor(prompts): improve prompt context and tool handling
- Enhanced the `PromptContext` structure to include additional fields for better context management, such as `skills`, `dispatcher_instructions`, and `tool_call_format`.
- Replaced `ToolSummary` with `PromptTool` for improved type safety and clarity in prompt generation.
- Updated the handling of dynamic prompt sources in both the subagent runner and debug dump, ensuring consistent integration and rendering of prompts.
- Introduced a mechanism to handle empty visible tool names, enhancing the robustness of prompt generation.
These changes streamline the prompt construction process and improve the overall maintainability of the codebase.
* refactor(prompts): reorganize prompt handling and introduce SystemPromptBuilder
- Moved prompt-related types and builders from `openhuman::context::prompt` to `openhuman::agent::prompts` for better modularity.
- Introduced `SystemPromptBuilder` to streamline the construction of system prompts, allowing for flexible section management.
- Updated module exports to maintain compatibility while enhancing the organization of prompt-related code.
These changes improve the clarity and maintainability of the prompt generation process, aligning it more closely with the agents that utilize these prompts.
* refactor(prompts): unify agent prompt handling and update CLI references
- Removed the "main" alias for the orchestrator in the prompt dumping process, treating it as just another registered agent.
- Updated the `debug-agent-prompts.sh` script to reflect this change, ensuring all agents are included uniformly.
- Revised documentation and error messages in `agent_cli.rs` to replace references to "main" with "orchestrator" for clarity.
- Enhanced the debug dump functionality to maintain consistency across agent prompts, improving overall maintainability and usability.
These changes streamline the prompt handling process and clarify the usage of agent identifiers in the CLI, aligning with the new architecture.
* refactor(prompts): remove CACHE_BOUNDARY references from agent prompts
- Eliminated the CACHE_BOUNDARY marker from various agent prompt files, streamlining the prompt generation process.
- Updated the build functions in multiple agents to ensure consistent handling of workspace rendering without the cache boundary.
- Refactored related prompt handling logic to enhance clarity and maintainability, aligning with the new architecture.
These changes simplify the prompt structure and improve the overall efficiency of prompt generation across agents.
* refactor(prompts): remove cache boundary references from tests and prompts
- Eliminated all instances of cache boundary references from the subagent runner and related tests, simplifying the prompt handling logic.
- Updated test assertions to reflect the removal of cache boundary checks, ensuring consistency across the testing framework.
- Refactored the session manager to streamline the system prompt assembly process without relying on cache boundaries.
These changes enhance the clarity and maintainability of the prompt generation process, aligning with the recent architectural updates.
* refactor(harness): clean up unused imports and streamline code
- Removed unnecessary imports from multiple files, including `RandomState`, `Hasher`, and `SerializeMap`, to enhance code clarity and maintainability.
- Simplified the structure of several modules by eliminating redundant use statements, ensuring a cleaner and more efficient codebase.
These changes contribute to a more organized and readable code structure, aligning with ongoing refactoring efforts.
* refactor(prompts): enhance agent prompt structures and integration handling
- Updated the `orchestrator`, `skills_agent`, and `welcome` prompts to streamline the rendering of connected integrations and delegation guides.
- Introduced dedicated functions for rendering integration information, ensuring clarity in the agent's voice and responsibilities.
- Removed redundant sections from the shared prompt builder, allowing each agent to manage its own prompt content more effectively.
- Improved test coverage for prompt generation, ensuring accurate representation of connected integrations and skills.
These changes enhance the maintainability and clarity of the prompt generation process, aligning with the recent architectural updates.
* refactor(session): update integration handling and clean up prompt parameters
- Revised documentation for `connected_integrations` in the `Agent` struct to clarify its role in the agent's prompt rendering.
- Updated the parameter name in `render_subagent_system_prompt_with_format` to `_connected_integrations` to indicate it is unused, enhancing code clarity.
- Cleaned up import statements in the context module for better organization and maintainability.
These changes improve the clarity of integration handling and streamline the code structure, aligning with ongoing refactoring efforts.
* refactor(agent_cli): simplify command options and improve documentation
- Removed the `--skill` option from the `dump-prompt` command, streamlining the command usage and focusing on essential parameters.
- Updated documentation to clarify the usage of the `dump-prompt` command and its parameters, enhancing user understanding.
- Cleaned up the `DumpFlags` structure by removing unused fields, contributing to a more maintainable codebase.
These changes improve the clarity and usability of the agent CLI, aligning with ongoing refactoring efforts.
* refactor(cli): streamline dotenv loading and clean up prompt rendering
- Introduced `load_dotenv_for_cli` to load environment variables for all CLI entrypoints, ensuring consistent configuration across commands.
- Updated documentation to clarify the purpose of the dotenv loading mechanism.
- Removed unnecessary blank lines in prompt rendering functions across multiple agents, enhancing code readability.
These changes improve the maintainability and clarity of the CLI and prompt handling, aligning with ongoing refactoring efforts.
* refactor(debug-agent-prompts): enhance environment loading and streamline workspace resolution
- Updated the script to load environment variables from a `.env` file, ensuring consistent configuration for prompt generation.
- Simplified workspace resolution by delegating to the binary's internal logic, improving reliability and reducing code duplication.
- Revised documentation to clarify the usage of command options and the impact of environment variables on prompt rendering.
These changes improve the maintainability and clarity of the debug agent prompts script, aligning with ongoing refactoring efforts.
* refactor(agent): remove category filter and simplify agent definitions
- Eliminated the `category_filter` from various agent definitions and related tests, streamlining the agent configuration.
- Updated the `run_list` function in `agent_cli.rs` to reflect the removal of category filtering, enhancing output clarity.
- Revised documentation and comments to remove references to the now-removed category filter, improving overall code maintainability.
These changes contribute to a cleaner and more efficient agent architecture, aligning with ongoing refactoring efforts.
* feat(agents): introduce integrations_agent and tools_agent for enhanced service handling
- Added the `integrations_agent` to manage service integrations via Composio, including a new TOML configuration and prompt structure.
- Introduced the `tools_agent` for general ad-hoc tasks using built-in OpenHuman tools, with its own configuration and prompt.
- Updated the loader to include both agents in the built-in agent list, increasing the total number of agents from 13 to 14.
- Revised orchestrator and welcome prompts to delegate integration tasks to the new `integrations_agent`, ensuring clarity in agent responsibilities.
- Enhanced tests to verify the registration and functionality of the new agents, improving overall test coverage.
These changes expand the capabilities of the agent architecture, allowing for more specialized handling of integrations and tool usage.
* refactor(agents): update references from skills_agent to integrations_agent
- Changed all instances of `skills_agent` to `integrations_agent` across various files, including prompts, CLI commands, and tool registrations.
- Updated documentation and comments to reflect the new agent name, ensuring clarity in agent responsibilities and usage.
- Revised debug scripts to align with the new prompt structure for the integrations agent.
These changes enhance consistency in the codebase and improve the clarity of agent interactions.
* refactor(agents): rename skills_agent to integrations_agent throughout the codebase
- Updated all instances of `skills_agent` to `integrations_agent` in various files, including tests, documentation, and comments.
- Ensured consistency in agent references to improve clarity in agent responsibilities and interactions.
- Revised related code structures to align with the new naming convention, enhancing overall maintainability.
These changes support the transition to the new agent architecture and improve code readability.
* refactor(prompts): implement dynamic prompt rendering for enhanced context handling
- Introduced `DynamicPromptSection` to allow prompts to be built dynamically using a function pointer, enabling real-time access to the `PromptContext`.
- Updated `SystemPromptBuilder` to support dynamic prompts, ensuring that late-arriving state like `connected_integrations` is accurately reflected in the rendered output.
- Revised the prompt handling logic in the agent builder to streamline the integration of dynamic prompts, improving overall flexibility and responsiveness.
These changes enhance the prompt generation process, aligning with the ongoing improvements in agent architecture and context management.
* refactor(prompts): refine delegation guide to display only connected integrations
- Updated the `render_delegation_guide` function to list only the toolkits that are actively connected, omitting unauthorized toolkits to prevent hallucinations during delegation.
- Revised related tests to ensure the prompt correctly reflects the current state of integrations, including scenarios where no integrations are connected.
- Introduced a new utility function to filter out welcome-only tools from non-welcome agents, enhancing the clarity and safety of tool visibility.
These changes improve the accuracy and focus of the delegation guide, aligning with the ongoing enhancements in agent prompt handling.
* refactor(planner): update tool usage and prompt guidelines for read-only operations
- Modified the `agent.toml` configuration to clarify that the planner operates in a read-only mode, specifying that it does not mutate the workspace or memory.
- Revised the prompt guidelines to reflect the read-only nature of the planner, emphasizing the need for explicit nodes for any required writes to be handled by downstream agents.
These changes enhance the clarity of the planner's operational constraints and improve the overall structure of the planning process.
* refactor(config): remove web search enable flag and update related configurations
- Eliminated the `OPENHUMAN_WEB_SEARCH_ENABLED` environment variable and associated logic, as web search is now always enabled by default.
- Updated the configuration schema to reflect the removal of the enable flag from `WebSearchConfig`.
- Adjusted tool registration to ensure web search is always available, simplifying the configuration process.
These changes streamline the web search functionality, ensuring it is consistently available across all sessions.
* refactor(config): update http_request flag to always enabled
- Changed the `http_request` configuration to always be enabled, removing the dependency on the `config.http_request.enabled` flag.
- This adjustment simplifies the configuration process and ensures consistent behavior across the application.
These changes contribute to a more streamlined configuration and enhance the overall reliability of the onboarding process.
* refactor(debug-agent-prompts): transition to dump-all command for agent prompts
- Replaced the previous method of listing agent IDs and dumping prompts with a new `dump-all` command that consolidates the functionality into a single call.
- Updated the script to handle output directory and workspace options more efficiently, leveraging Rust's `dump_all_agent_prompts` for processing.
- Enhanced the handling of the `integrations_agent` to generate separate dumps for each connected toolkit, improving the clarity and organization of output files.
- Revised related logging and summary generation to reflect the new structure, ensuring a more streamlined user experience.
These changes modernize the prompt dumping process, aligning it with the latest architectural improvements and enhancing usability.
* feat(composio): implement dynamic fetching of toolkit actions for integrations
- Added a new `fetch_toolkit_actions` function to retrieve the current action catalogue for a specified Composio toolkit, enhancing the responsiveness of the integrations agent.
- Updated the `subagent_runner` to utilize the fresh action list at spawn time, ensuring that the toolkit's actions reflect the latest backend state.
- Modified the `render_integrations_agent` function to refresh the action catalogue during prompt generation, improving the accuracy of the displayed tools.
These changes enhance the integration experience by providing up-to-date action information, aligning with the ongoing improvements in agent functionality.
* refactor(integrations-agent): update tool visibility and configuration handling
- Modified the `agent.toml` to replace `wildcard` with `named` tools, enhancing control over tool visibility for the integrations agent.
- Updated the `subagent_runner` to ensure that tool visibility aligns with the new TOML configuration, preventing unnecessary stripping of tools.
- Revised the `render_integrations_agent` function to respect the updated tool scope, improving the accuracy of the tool list generated for subagents.
These changes streamline the tool management process, ensuring that only explicitly defined tools are available during agent execution.
* feat(composio): add composio_list_connections tool for dynamic integration detection
- Introduced the `composio_list_connections` tool in the orchestrator's configuration, allowing the agent to detect newly-authorized Composio integrations mid-session.
- Enhanced the `ComposioListConnectionsTool` to filter and return only currently-connected integrations with ACTIVE or CONNECTED status, improving the accuracy of integration management.
- Updated the tool's description to clarify its functionality and usage context.
These changes enhance the agent's ability to manage integrations dynamically, aligning with ongoing improvements in the integration experience.
* fix(prompt): update delegation guide to reference Skills page
- Modified the `render_delegation_guide` function to change the reference from **Settings → Integrations** to the **Skills** page for connecting integrations. This update clarifies the user instructions for integration management.
* feat(session): introduce session key management for sub-agents
- Added `session_key` and `session_parent_prefix` fields to `ParentExecutionContext` to facilitate hierarchical transcript naming for sub-agents.
- Updated `persist_subagent_transcript` to generate transcript filenames based on the parent's session key, ensuring a flat file structure that reflects the parent-child relationship.
- Enhanced `AgentBuilder` and `Agent` to support the new session key management, allowing for better organization of session transcripts.
- Adjusted related functions to ensure proper handling of session keys during agent execution and transcript persistence.
These changes improve the clarity and organization of session transcripts, aligning with the ongoing enhancements in agent functionality.
* refactor(tests): update integrations agent tests for tool scope and transcript handling
- Renamed the `integrations_agent_is_wildcard` test to `integrations_agent_tool_scope_honours_toml` to better reflect its purpose of validating tool scope based on TOML configuration.
- Enhanced the test to assert that the `integrations_agent` correctly recognizes named tools instead of a wildcard.
- Removed the `integrations_agent_has_extra_tools_for_export` test as it is no longer relevant to the current tool management strategy.
- Improved the `latest_in_dir` function to clarify the handling of transcript naming schemes, ensuring proper differentiation between legacy and keyed formats.
These changes streamline the testing process and improve the accuracy of tool scope validation, aligning with recent updates in agent functionality.
* refactor(subagent_runner): improve transcript persistence and streamline inner loop
- Removed the `persist_subagent_transcript` function, transitioning transcript persistence to occur per-iteration within the `run_inner_loop`, enhancing reliability by ensuring transcripts are written immediately after each provider response.
- Updated the handling of session keys to maintain consistent naming for transcripts, reflecting the parent-child relationship in the file structure.
- Simplified the code by eliminating redundant post-loop transcript writes, aligning with recent changes in agent functionality and improving overall clarity in transcript management.
* refactor(agent_cli, subagent_runner, session): improve code readability and formatting
- Enhanced formatting in `agent_cli.rs` for better readability by adjusting the structure of string formatting.
- Streamlined conditional checks in `subagent_runner.rs` to improve clarity and maintainability.
- Simplified the handling of agent IDs in `builder.rs` to reduce line length and improve code flow.
- Updated test cases in `tests.rs` for better alignment and readability of expected values.
- Improved formatting in `debug_dump.rs` to enhance the clarity of toolkit action fetching and logging.
These changes collectively enhance the overall readability and maintainability of the codebase, aligning with ongoing refactoring efforts.
* fix(tests): add missing session_key fields to ParentExecutionContext stub
* fix: address PR review feedback
* fix(prompts-v2): round 2 PR review — dispatcher instructions, workspace-file preservation, cached-tool fallback, transcript persistence
- subagent_runner: populate PromptContext.dispatcher_instructions for Dynamic prompts (was empty string, dropping the ## Tool Use Protocol block in render_tools for PFormat/Json/Native sub-agents)
- subagent_runner: add post-tool persist_transcript after tool results are appended so a mid-round crash doesn't lose tool outputs
- prompts::sync_workspace_file: preserve user-edited workspace files — only overwrite when the file doesn't exist OR its current hash matches the stored builtin hash
- context::debug_dump: mirror runner's cached-tool fallback — keep cached action catalogue on empty/error from fetch_toolkit_actions instead of blanking it
- core::agent_cli: add entry/exit debug logs around dump_all / dump_prompt calls and a trace log around each prompt file write; update module banner to note --toolkit is required when --agent is integrations_agent
227 lines
9.0 KiB
Bash
Executable File
227 lines
9.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# debug-agent-prompts.sh — Dump the exact system prompt the context engine
|
|
# would produce for every built-in agent (plus the main / orchestrator
|
|
# agent), so prompt-engineering changes can be reviewed in one place.
|
|
#
|
|
# Each prompt is written to a numbered file under the output directory
|
|
# along with a side-car `.meta.txt` containing the metadata banner
|
|
# (agent id, model, tool count, cache boundary, …) that the CLI prints
|
|
# to stderr. Useful workflow:
|
|
#
|
|
# bash scripts/debug-agent-prompts.sh
|
|
# diff -u prompts.before/integrations_agent.md prompts.after/integrations_agent.md
|
|
#
|
|
# The dumper runs against the real session construction path
|
|
# (`Agent::from_config_for_agent` → `Agent::build_system_prompt`), so the
|
|
# Composio surface reflects the signed-in user's actual integrations.
|
|
# If you need the toolkit list populated, sign in via the desktop app or
|
|
# point `OPENHUMAN_WORKSPACE` at a workspace that already holds the
|
|
# connection state.
|
|
#
|
|
# The dumper runs against the currently-logged-in user's workspace
|
|
# (`$OPENHUMAN_WORKSPACE`, falling back to `~/.openhuman/workspace`) so
|
|
# onboarding-generated files like `PROFILE.md` appear in the dump. Export
|
|
# `OPENHUMAN_WORKSPACE=<path>` before running if you want to target a
|
|
# different workspace.
|
|
#
|
|
# Usage:
|
|
# bash scripts/debug-agent-prompts.sh [--out <dir>] [--with-tools] [-v]
|
|
#
|
|
# The output directory is wiped and recreated at the start of each run
|
|
# so the snapshot only reflects the current agent set — stale files from
|
|
# an earlier run cannot hide a regression.
|
|
#
|
|
# Defaults:
|
|
# --out ./prompt-dumps (deleted + recreated each run)
|
|
# --with-tools DEPRECATED / no-op — tool names are always recorded in
|
|
# the per-agent `.meta.txt` files emitted by dump-all.
|
|
#
|
|
|
|
set -euo pipefail
|
|
|
|
# ── Locate repo root + binary ─────────────────────────────────────────────
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
|
BIN="${REPO_ROOT}/target/debug/openhuman-core"
|
|
|
|
# Load the repo .env so staging/prod backend URLs, API keys, and the
|
|
# Composio toggle reach the dumped prompts. `Config::load_or_init`
|
|
# calls `apply_env_overrides` after reading from disk, so any variable
|
|
# exported here wins over whatever is baked into the workspace config.
|
|
# Mirrors `yarn tauri dev`, which sources the same file via
|
|
# `scripts/load-dotenv.sh` before launching the sidecar.
|
|
if [[ -f "${REPO_ROOT}/.env" ]]; then
|
|
echo "[debug-agent-prompts] loading env from ${REPO_ROOT}/.env" >&2
|
|
# shellcheck disable=SC1091
|
|
source "${SCRIPT_DIR}/load-dotenv.sh" "${REPO_ROOT}/.env"
|
|
fi
|
|
|
|
# The project's CLI logger writes to stdout (not stderr), so any
|
|
# `RUST_LOG` value inherited from `.env` (typically `info`) would
|
|
# interleave log lines into the JSON/prompt payloads this script
|
|
# expects on stdout. Force quiet unless the caller passed `-v` — in
|
|
# which case the later `--verbose` flag restores debug logging.
|
|
export RUST_LOG=error
|
|
|
|
# Always run `cargo build` — it no-ops when the binary is already
|
|
# up-to-date, and re-links quickly when it isn't. The old `-x` existence
|
|
# check let a stale debug binary survive across agent-registry changes
|
|
# (e.g. new entries in `agents::BUILTINS`), which made this script
|
|
# silently skip newly added agents like `welcome`.
|
|
echo "[debug-agent-prompts] building openhuman-core (no-op if up-to-date) …" >&2
|
|
( cd "${REPO_ROOT}" && cargo build --manifest-path Cargo.toml --bin openhuman-core >&2 )
|
|
|
|
# ── Parse flags ───────────────────────────────────────────────────────────
|
|
OUT_DIR=""
|
|
WITH_TOOLS=0
|
|
VERBOSE_FLAG=()
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--out)
|
|
if [[ -z "${2-}" ]] || [[ "${2-}" == -* ]]; then
|
|
echo "[debug-agent-prompts] missing value for --out" >&2
|
|
exit 64
|
|
fi
|
|
OUT_DIR="$2"
|
|
shift 2
|
|
;;
|
|
--with-tools)
|
|
WITH_TOOLS=1
|
|
shift
|
|
;;
|
|
-v|--verbose)
|
|
VERBOSE_FLAG=(-v)
|
|
shift
|
|
;;
|
|
-h|--help)
|
|
sed -n '2,38p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "[debug-agent-prompts] unknown flag: $1" >&2
|
|
exit 64
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [[ -z "${OUT_DIR}" ]]; then
|
|
OUT_DIR="${REPO_ROOT}/prompt-dumps"
|
|
fi
|
|
|
|
# ── Validate & canonicalize OUT_DIR before `rm -rf` ─────────────────────
|
|
# The output directory is wiped at the start of each run. Literal string
|
|
# matching against "/" / $HOME / $REPO_ROOT is not enough on its own:
|
|
# trailing slashes, ".", "..", or symlinked paths can slip past and
|
|
# trigger `rm -rf` on a sensitive target. So:
|
|
#
|
|
# 1. Reject obviously bad inputs up-front ("", ".", "..", relative).
|
|
# 2. Canonicalize OUT_DIR and REPO_ROOT via `realpath` (falling back
|
|
# to python when realpath is unavailable on barebones macOS).
|
|
# 3. Match the canonicalized form against the disallow list.
|
|
# 4. Only then `rm -rf` the canonicalized path.
|
|
case "${OUT_DIR}" in
|
|
"" | "." | "..")
|
|
echo "[debug-agent-prompts] refusing to wipe --out='${OUT_DIR}' (relative/empty)" >&2
|
|
exit 64
|
|
;;
|
|
esac
|
|
if [[ "${OUT_DIR}" != /* ]]; then
|
|
echo "[debug-agent-prompts] --out must be an absolute path (starts with '/'), got '${OUT_DIR}'" >&2
|
|
exit 64
|
|
fi
|
|
|
|
canonicalize() {
|
|
local p="$1"
|
|
# `realpath` is GNU + modern macOS (coreutils), and `readlink -f` on
|
|
# Linux. Try both; if neither resolves the path (target missing) we
|
|
# fall back to python3, which handles symlinks even for non-existent
|
|
# leaves via `os.path.realpath`.
|
|
if command -v realpath >/dev/null 2>&1; then
|
|
realpath -m -- "${p}" 2>/dev/null && return 0
|
|
fi
|
|
if command -v readlink >/dev/null 2>&1 && readlink -f / >/dev/null 2>&1; then
|
|
readlink -f -- "${p}" 2>/dev/null && return 0
|
|
fi
|
|
python3 -c 'import os,sys; print(os.path.realpath(sys.argv[1]))' "${p}"
|
|
}
|
|
|
|
resolved_out="$(canonicalize "${OUT_DIR}")"
|
|
resolved_repo="$(canonicalize "${REPO_ROOT}")"
|
|
resolved_home="$(canonicalize "${HOME}")"
|
|
|
|
if [[ -z "${resolved_out}" ]]; then
|
|
echo "[debug-agent-prompts] failed to canonicalize --out='${OUT_DIR}'" >&2
|
|
exit 64
|
|
fi
|
|
case "${resolved_out}" in
|
|
"/" | "${resolved_home}" | "${resolved_repo}")
|
|
echo "[debug-agent-prompts] refusing to wipe --out (resolves to ${resolved_out})" >&2
|
|
exit 64
|
|
;;
|
|
esac
|
|
|
|
# Use the canonicalized path from here on so every subsequent command
|
|
# (rm, mkdir, per-agent dump writes) operates on the same resolved
|
|
# target — no symlink window between validation and deletion.
|
|
OUT_DIR="${resolved_out}"
|
|
rm -rf "${OUT_DIR}"
|
|
mkdir -p "${OUT_DIR}"
|
|
|
|
# Workspace resolution is owned by `Config::load_or_init` inside the
|
|
# binary: it reads `~/.openhuman/active_user.toml`, falls back to the
|
|
# persisted workspace marker, then to the pre-login user directory. We
|
|
# only pass `--workspace` when the caller has explicitly exported one
|
|
# (an empty `OPENHUMAN_WORKSPACE=` in `.env` counts as unset — the
|
|
# binary's resolver is what we want in that case).
|
|
#
|
|
# Previously this script duplicated the resolution in shell and guessed
|
|
# wrong when the user's active install used a multi-user layout under
|
|
# `~/.openhuman/users/<user_id>/workspace` without a top-level
|
|
# `active_user.toml`, causing the dumper to bail with "workspace not
|
|
# found". Delegating to the binary removes that divergence and makes
|
|
# `.env` (including `OPENHUMAN_APP_ENV=staging`) take effect
|
|
# automatically.
|
|
WORKSPACE_OVERRIDE=""
|
|
if [[ -n "${OPENHUMAN_WORKSPACE:-}" ]]; then
|
|
WORKSPACE_OVERRIDE="${OPENHUMAN_WORKSPACE}"
|
|
fi
|
|
|
|
echo "[debug-agent-prompts] output dir : ${OUT_DIR}" >&2
|
|
if [[ -n "${WORKSPACE_OVERRIDE}" ]]; then
|
|
echo "[debug-agent-prompts] workspace : ${WORKSPACE_OVERRIDE} (OPENHUMAN_WORKSPACE override)" >&2
|
|
else
|
|
echo "[debug-agent-prompts] workspace : <resolved by Config::load_or_init>" >&2
|
|
fi
|
|
if [[ -n "${OPENHUMAN_APP_ENV:-}" ]]; then
|
|
echo "[debug-agent-prompts] app env : ${OPENHUMAN_APP_ENV}" >&2
|
|
fi
|
|
if [[ -n "${OPENHUMAN_BASE_URL:-}" ]]; then
|
|
echo "[debug-agent-prompts] base url : ${OPENHUMAN_BASE_URL}" >&2
|
|
fi
|
|
echo >&2
|
|
|
|
# ── Delegate to `openhuman-core agent dump-all` ──────────────────────────
|
|
# All the per-agent iteration + `integrations_agent`-per-toolkit
|
|
# expansion now lives in Rust (`debug_dump::dump_all_agent_prompts`).
|
|
# The shell script just supplies the output directory and passes
|
|
# through workspace / verbose toggles.
|
|
DUMP_ARGS=(agent dump-all --out "${OUT_DIR}")
|
|
if [[ -n "${WORKSPACE_OVERRIDE}" ]]; then
|
|
DUMP_ARGS+=(--workspace "${WORKSPACE_OVERRIDE}")
|
|
fi
|
|
if [[ ${#VERBOSE_FLAG[@]} -gt 0 ]]; then
|
|
DUMP_ARGS+=("${VERBOSE_FLAG[@]}")
|
|
fi
|
|
|
|
"${BIN}" "${DUMP_ARGS[@]}"
|
|
|
|
if [[ ${WITH_TOOLS} -eq 1 ]]; then
|
|
echo "[debug-agent-prompts] NOTE: --with-tools is no longer honoured by dump-all" >&2
|
|
echo "[debug-agent-prompts] (tool names are always recorded in the .meta.txt files)" >&2
|
|
fi
|
|
|
|
echo >&2
|
|
echo "[debug-agent-prompts] done — see ${OUT_DIR}/SUMMARY.txt" >&2
|