/** * Collect — the easy data collection pipeline. * * One call chains: scrape → extract → store → think. * * const result = await at.collect.url("https://example.com/article"); * // → { scrape, memory, strand, thought } * // The agent now has the article content in memory + a strand thinking about it. * * This is the "welcome, don't block" principle applied to data collection: * one door, many paths, the agent picks what it needs. The human gets the * same simplicity — one CLI command, one SDK call. * * Doctrine: the five principles, applied to collection: * - Welcome: one call, no setup * - Remember: collected data goes to memory (it persists) * - Guide: every step has a clear result, errors point forward * - Trust: the agent decides what to collect and how to process it * - Rest: partial results are returned, not thrown away * * @module collect */ import type { HttpConfig } from "./_http.js"; import { type MemoryClient } from "./memory.js"; import { type StrandsClient } from "./strands.js"; import { type ToolsClient } from "./tools.js"; export interface CollectUrlOpts { /** CSS selector to extract specific content. */ selector?: string; /** Extract links from the page. */ extractLinks?: boolean; /** Use Readability for cleaner extraction (default: true). */ readable?: boolean; /** Store the collected content as a memory. */ storeMemory?: boolean; /** Memory type (default: "episodic"). */ memoryType?: "episodic" | "semantic" | "procedural" | "working"; /** Memory importance (default: 0.5). */ memoryImportance?: number; /** Create a strand to think about what was collected. */ think?: boolean; /** Strand topic (default: derived from page title). */ strandTopic?: string; /** Initial thought kind (default: "observation"). */ thoughtKind?: string; /** K_master for thought encryption (required if think=true). */ k_master?: Uint8Array; /** ed25519 signing key for thought signature (required if think=true). */ signing_key?: Uint8Array; /** signing_key_id for thought (required if think=true). */ signing_key_id?: string; /** Agent identity ID for memory/strand ownership. */ identity_id?: string; } export interface CollectTextOpts { /** Optional title/source label. */ title?: string; /** Store as memory. */ storeMemory?: boolean; /** Memory type. */ memoryType?: "episodic" | "semantic" | "procedural" | "working"; /** Memory importance. */ memoryImportance?: number; /** Create a strand. */ think?: boolean; /** Strand topic. */ strandTopic?: string; /** Thought kind. */ thoughtKind?: string; /** K_master for thought encryption. */ k_master?: Uint8Array; /** Signing key. */ signing_key?: Uint8Array; /** Signing key ID. */ signing_key_id?: string; /** Identity ID. */ identity_id?: string; } export interface CollectBatchOpts { /** Multiple URLs to collect. */ urls: string[]; /** Shared options (same as CollectUrlOpts minus url). */ selector?: string; extractLinks?: boolean; readable?: boolean; storeMemory?: boolean; memoryType?: "episodic" | "semantic" | "procedural" | "working"; memoryImportance?: number; think?: boolean; identity_id?: string; k_master?: Uint8Array; signing_key?: Uint8Array; signing_key_id?: string; } export interface CollectUrlResult { url: string; title: string; content: string; links: string[]; memory_id?: string; strand_id?: string; thought_id?: string; duration_ms: number; errors: string[]; } export interface CollectBatchResult { results: CollectUrlResult[]; total: number; succeeded: number; failed: number; duration_ms: number; } /** * Collect client — the easy data collection pipeline. * * One call chains scrape → extract → store → think. * Works for agents (SDK method) and humans (CLI command). * * @example * ```ts * const at = new AgentTool(); * * // Simplest: collect a URL, store as memory, create a strand * const result = await at.collect.url("https://example.com/article", { * think: true, * k_master: myKMaster, * signing_key: mySigningKey, * signing_key_id: "key-uuid", * }); * * // Batch: collect multiple URLs * const batch = await at.collect.batch({ * urls: ["https://a.com", "https://b.com"], * storeMemory: true, * }); * ``` */ export declare class CollectClient { private readonly http; private readonly tools; private readonly memory; private readonly strands; private _at; /** @internal */ constructor(http: HttpConfig, at: { tools: ToolsClient; memory: MemoryClient; strands: StrandsClient; }); /** * Collect a single URL: scrape → extract → store → think. * * Each step is optional. By default it scrapes + stores as memory. * With `think: true`, it also creates a strand + first encrypted thought. * * @param url - The URL to collect. * @param opts - Collection options. * @returns Collection result with IDs for created memory/strand/thought. */ url(url: string, opts?: CollectUrlOpts): Promise; /** * Collect raw text: store → think. * * For when the agent already has the content (from a tool, a paste, * a previous scrape) and just needs to persist it + start thinking. * * @param text - The text to collect. * @param opts - Collection options. */ text(text: string, opts?: CollectTextOpts): Promise; /** * Collect multiple URLs in parallel. * * Each URL gets the same options. Results are returned in order. * Failures don't abort the batch — rest, don't crash. * * @param opts - Batch options including URLs. * @returns Batch result with per-URL results + summary. */ batch(opts: CollectBatchOpts): Promise; /** * Enrich an existing memory with additional data. * * Given a memory_id, fetch the source URL (if stored in metadata), * re-scrape, and update the memory with fresh content. This is the * "keep it alive" path — collected data doesn't go stale. * * @param memoryId - The memory to enrich. * @param url - Optional URL override (uses metadata.source if omitted). */ enrich(memoryId: string, url?: string): Promise<{ memory_id: string; enriched: boolean; new_content_length: number; errors: string[]; }>; }