Class: IngestionSession
@kortexya/reasoninglayer / IngestionSession
Class: IngestionSession
Defined in: src/resources/ingestion-session.ts:64
Handle for an async ingestion session, returned when sync: false.
Provides methods to poll for completion, check progress, and retrieve final stats. Wraps the session tracking endpoints.
Example
const session = await client.ingestion.ingestMarkdown(request, { sync: false });console.log(session.sessionId); // UUID
// Poll until done (with optional progress callback)const stats = await session.waitForCompletion({ onProgress: (p) => console.log(p.documents[0]?.currentStepLabel), pollIntervalMs: 3000,});
// Or check manuallyconst progress = await session.getProgress();const sessionInfo = await session.getSession();Remarks
The session handle does not hold an open connection. All methods are independent HTTP requests using the session endpoints.
Properties
documentId
readonlydocumentId:string
Defined in: src/resources/ingestion-session.ts:69
The document ID (UUID).
sessionId
readonlysessionId:string
Defined in: src/resources/ingestion-session.ts:66
The session ID (UUID).
status
readonlystatus:string
Defined in: src/resources/ingestion-session.ts:72
The initial status (always "pending" on creation).
statusUrl
readonlystatusUrl:string
Defined in: src/resources/ingestion-session.ts:75
URL path to check session status.
Methods
getProgress()
getProgress():
Promise<SessionProgressResponse>
Defined in: src/resources/ingestion-session.ts:111
Get live pipeline progress for all documents in the session.
Returns
Promise<SessionProgressResponse>
Progress snapshots for each document being processed.
Remarks
Maps to GET /api/v1/ingest/sessions/{session_id}/progress.
Returns real-time counters, current pipeline step, and step log.
getSession()
getSession():
Promise<IngestionSessionResponse>
Defined in: src/resources/ingestion-session.ts:97
Get the current session details (status, document counts).
Returns
Promise<IngestionSessionResponse>
The session information.
Remarks
Maps to GET /api/v1/ingest/sessions/{session_id}.
getStats()
getStats():
Promise<SessionStatsResponse>
Defined in: src/resources/ingestion-session.ts:125
Get stats for all completed documents in the session.
Returns
Promise<SessionStatsResponse>
Per-document stats (term IDs, sort names, token usage, etc.).
Remarks
Maps to GET /api/v1/ingest/sessions/{session_id}/stats.
May be empty if no documents have completed yet.
waitForCompletion()
waitForCompletion(
options?):Promise<SessionStatsResponse>
Defined in: src/resources/ingestion-session.ts:156
Poll the session until it completes or fails, then return final stats.
Parameters
options?
Polling configuration (interval, timeout, progress callback, abort signal).
Returns
Promise<SessionStatsResponse>
Final session stats once all documents are complete.
Throws
IngestionFailedError If the session status becomes "failed".
Throws
TimeoutError If timeoutMs is exceeded.
Throws
ReasoningLayerError If the abort signal is triggered.
Example
const stats = await session.waitForCompletion({ pollIntervalMs: 2000, timeoutMs: 300_000, onProgress: (p) => { const doc = p.documents[0]; if (doc) console.log(`${doc.currentStepLabel} — chunk ${doc.chunksProcessed}/${doc.totalChunks}`); },});console.log(`Created ${stats.documents[0]?.termIds.length} terms`);Remarks
Polls getSession() to check status, and calls onProgress with live
progress data between checks. Terminal states are "complete" and "failed".