Skip to main content

Module import

Module import 

Source
Expand description

bundle.import, bundle.import.preview, bundle.import.commit: the ABF file/bytes intake path, its size and warning budgets, and the two-phase preview/commit flow.

Structs§

BundleImportReq 🔒
BundleImportResponse 🔒
Response for bundle.import.
ResolvedImportInput 🔒
The outcome of resolving one of file_path/zip_base64/files into intake-ready files plus the Phase 3 content digest (§3.0.5) — shared by bundle.import.preview and .commit so both compute the digest identically. The mode tag baked into content_digest (round 7) means a plain digest-equality check at commit is sufficient to enforce “same input mode as preview” (round 6) — no separate mode field is needed.

Constants§

MAX_ABF_FILE_SIZE_BYTES 🔒
On-disk size ceiling for file_path input (Phase 3 spec §3.0.5, rounds 4/5) — generous headroom above MAX_TOTAL_UNCOMPRESSED_BYTES’s 50 MiB for compression/container overhead and imperfectly-compressed content.
MAX_PROJECT_INSTRUCTION_PREVIEW_CHARS 🔒
Final combined-list bound applied to a preview/commit response’s warnings (Phase 3 spec §3.1 round 8 / round 9’s commit-response generalization) — cheap defense-in-depth over an already per-source-bounded list (each of resolve_import_input’s intake warnings and parse_bundle_import_with_budget’s own warnings is already individually bounded; concatenating two independently-bounded lists can still exceed either bound alone, so one more pass caps the combined total before it’s ever serialized). Per-entry content cap for project_instructions in an import preview.

Functions§

bound_warnings_for_response 🔒
bundle_import_commit_impl 🔒
bundle.import.commit — Phase 3 §3.2. Re-resolves and re-parses the same input fresh (never trusts client-supplied preview data for anything written), rejects on a content-digest mismatch, then writes only the selected items. Shares bundle.import’s existing skill-write/ rollback logic; the differences are selection filtering, the bundle_name/import_as overrides, and the digest gate. Extracted from the RPC closure into a directly-callable, directly-testable function (the closure itself only deserializes the request and forwards).
bundle_import_preview_impl 🔒
bundle.import.preview — Phase 3 of docs/specs/SPEC_ABF_IMPORT_UI_PHASE3_2026_08_02.md §3.1. Pure parse plus read-only collision/name-collision lookups — zero Store writes. Window- scoped like the rest of bundle.*. Extracted from the RPC closure into a directly-callable, directly-testable function (the closure itself only deserializes the request and forwards).
install_bundle_widgets 🔒
After a commit: copy in the chosen widgets and ask the user to approve each, the way an agent’s WidgetInstall does. The archive is read again and held to the digest the user previewed, so what installs is what they saw (SPEC_WIDGET_SHARING_2026_10_10.md §3.3). A bundle never approves a widget.
preview_commit_warning_budget 🔒
Bounded warning budget shared by bundle.import.preview/.commit (Phase 3 spec §3.1, round 11) — unlike the existing bundle.import route’s effectively-unbounded budget, preserved unchanged above.
preview_widgets 🔒
The import preview’s line for each widget the bundle carries.
read_abf_file_path 🔒
Reads a file_path input server-side (Phase 3 spec §3.0.5). Opens the path with a no-follow mechanism so a symlink fails to open at all rather than being silently resolved to its target (round 6) — one handle, one continuous read, no second path resolution for anything to race against (round 5’s TOCTOU fix): metadata comes from that SAME open handle and is checked against MAX_ABF_FILE_SIZE_BYTES BEFORE any read (round 4); the actual read is still hard-bounded via .take(...) regardless of what the metadata claimed.
register_bundle_import 🔒
bundle.import — ABF importer, Phase 2 of docs/specs/SPEC_ABF_V0_1_SINGLE_FILE_AND_IMPORTER_2026_08_01.md. Window- scoped like bundle.export (bundles aren’t agent-specific). Accepts EITHER zip_base64 (a .abf archive, mirroring bundle.export’s own zip_base64 response field) OR files (a raw [{path, content}] list) — exactly one must be present. Hands the bytes to the pure bundle_import module for parsing/validation, then owns every Store side-effect: creates the bundle row, creates one global Skill row per parsed skill, and performs READ-ONLY account-requirement lookups (never creates an account, never writes a secret anywhere — see the spec’s §4.5 correction for why this stopped short of “resolving” placeholders in place).
register_bundle_import_commit 🔒
register_bundle_import_preview 🔒
resolve_import_input 🔒
split_widgets 🔒
Takes a zip’s widget entries out of the text files and their warnings, and reads them as bytes instead.