Skip to main content

Module import_for_agent

Module import_for_agent 

Source
Expand description

bundle.import_for_agent: apply an ABF to an existing agent definition, serialised per agent by bundle_import_for_agent_lock.

StructsΒ§

BundleImportForAgentResponse πŸ”’
Response for bundle.import_for_agent.
ImportForAgentReq πŸ”’

FunctionsΒ§

bundle_import_for_agent_impl πŸ”’
bundle.import_for_agent β€” ABF v0.2 Β§2.3. The only import path that processes a components.memory key; the generic bundle.import explicitly skips it (see parse_bundle_import_with_budget’s own components.memory guard). Unlike bundle.import/bundle.import.commit, this is a single-step import β€” no preview phase β€” since a memory-bearing import has its own unconditional safety net instead: the target agent must have ZERO existing db_agent_native_memory rows, or the whole import is rejected before any write happens. Simpler than skip/rename/replace conflict resolution, and sufficient for v0.2 (see the spec’s revision note for why merge semantics are an explicit follow-up, not designed here). Extracted from the RPC closure into a directly-callable, directly-testable function, matching bundle_import_preview_impl’s pattern.
create_bundle_row πŸ”’
Insert the reusable bundle row for an import; on failure the skills it created are rolled back.
import_global_skills πŸ”’
Create the bundle’s skills as global skills, exactly as bundle.import does (global, not bound to any agent; skill_upsert_unique_global is the real API β€” a genuine name conflict is a per-skill warning, any other error aborts the whole RPC). Returns the ids of the skills created.
memory_dir_for_import πŸ”’
The directory the import writes memory into: the one resolved before, unless the manifest has memory files, in which case it must be a verified one.
refresh_memory_mirror_before_check πŸ”’
The agent’s memory directory (None when it has no resolvable working directory), after refreshing the mirror from it when it is a verified one.
register_bundle_import_for_agent πŸ”’
resolved_memory_paths πŸ”’
Every memory/* path listed under components.memory in a parsed import’s manifest (bundle.json, or armory.json before ABF v0.3) β€” mirrors how components.instructions/ components.skills are read elsewhere in this file, kept local to bundle.import_for_agent since no other handler needs it.
rollback_skills πŸ”’
Delete the global skills an import created, after a later step failed; the errors of any that could not be deleted.
with_rollback_note πŸ”’
msg, plus a note naming the skills a rollback could not delete.
write_memory_file πŸ”’
Write one memory file to the live directory and the mirror; false when either write failed (the failure is a warning).
write_memory_files πŸ”’
Bundle files: write through the SAME dual-write path agent:memory:write_file uses (live FS via memory_dir_for_cwd, then the mirror) β€” writing only to db_agent_native_memory would leave this content visible in Stash while invisible to the actual running agent (see the spec’s revision note). Returns how many files were written.