The resources module manages files, directories, and semantic relations within viking://resources/.
All path parameters are relative to the resources root — e.g. "docs/guide.md" maps to viking://resources/docs/guide.md.
Ingest a file, directory, or URL into OpenViking.
await huscarl.resources.add("./data/report.pdf", {
target: "reports/", // destination path within resources
reason: "Q4 financial report", // improves search relevance
wait: true, // block until L0/L1 generation completes
watchInterval: 60, // re-ingest every 60 minutes (requires target)
});| Option | Type | Description |
|---|---|---|
target |
string |
Destination path within viking://resources/. If omitted, the server chooses. |
reason |
string |
Why this resource is being added — improves search relevance and memory extraction. |
wait |
boolean |
Block until semantic processing (L0/L1 generation) completes. Default: false. |
watchInterval |
number |
Re-ingest interval in minutes. > 0 enables, <= 0 disables. Requires target. |
Returns metadata for a resource or directory: size, type, and timestamps.
Returns: ResourceStat with size, type, created, modified, accessed.
const info = await huscarl.resources.stat("docs/guide.md");
console.log(info.size, info.type);Returns the full content (L2) of a file. For directories, returns the concatenated content of all children.
Returns: string containing the full file content or concatenated children.
const content = await huscarl.resources.read("docs/guide.md");Returns the L0 abstract — a short, AI-generated summary. Fast to retrieve and useful for ranking, previews, or building compact search result snippets.
Returns: string containing the L0 abstract (typically 1–2 sentences).
const summary = await huscarl.resources.abstract("docs/guide.md");Returns the L1 overview — a medium-length AI-generated summary with key details, structure, and main takeaways.
Returns: string containing the L1 overview (typically a few paragraphs).
const overview = await huscarl.resources.overview("docs/");Lists the immediate children of a directory. Pass recursive: true to list all descendants.
Returns: ListEntry[] with name, type, and metadata for each child.
const entries = await huscarl.resources.list("docs/");
const allEntries = await huscarl.resources.list("docs/", { recursive: true });
for (const entry of entries) {
console.log(entry.name, entry.isDirectory ? "dir" : "file");
}Returns the full recursive directory tree as a nested structure, including L0 abstracts for directories.
Returns: Nested tree object with name, isDirectory, abstract, and children.
const tree = await huscarl.resources.tree("docs/");Moves or renames a resource or directory.
await huscarl.resources.move("old-project/", "archive/old-project/");Deletes a resource or directory. Pass recursive: true when deleting a non-empty directory.
await huscarl.resources.remove("docs/guide.md");
await huscarl.resources.remove("old-project/", { recursive: true });Creates an empty directory.
await huscarl.resources.createDirectory("new-project/");Creates a semantic relation between two resources. Linked resources surface together in search results and inform memory extraction.
The toUris parameter can be a single path (string) or an array of paths.
// Single link
await huscarl.resources.link("docs/guide.md", "docs/api-reference.md", {
reason: "The guide references the API docs",
});
// Link to multiple targets at once
await huscarl.resources.link("docs/guide.md", ["docs/faq.md", "docs/examples.md"]);Removes a semantic relation between two resources.
await huscarl.resources.unlink("docs/guide.md", "docs/api-reference.md");Returns all resources linked to the given resource.
Returns: RelatedResource[] with URI, abstract, and relation reason.
const related = await huscarl.resources.relations("docs/guide.md");
for (const rel of related) {
console.log(rel.uri, rel.reason);
}