Session
Defined in: src/session.ts:186
Properties
config
readonlyconfig:PublicSessionConfig
Defined in: src/session.ts:192
The session’s immutable configuration
id
readonlyid:string
Defined in: src/session.ts:188
Unique identifier for this session
repo
readonlyrepo:Repo
Defined in: src/session.ts:190
The repository this session is connected to
Methods
ask()
ask(
prompt,options?):AskStream
Defined in: src/session.ts:277
Ask a question about the repository.
Returns an AskStream synchronously. The stream starts producing events when consumed (iterated or .result() awaited). Concurrent calls are serialized — the second stream won’t produce events until the first completes.
Parameters
prompt
string
options?
Returns
Throws
Error (synchronous) if the session is closed
Throws
Error (synchronous) if afterTurn references an unknown turn ID
close()
close():
Promise<void>
Defined in: src/session.ts:330
Close the session and clean up resources.
This MUST be called when the caller is done with the session. The root
OTel “ask” span is started in Client.connect() and only ended here; if
close() is never called (early return, thrown ask(), caller forgets,
session is GC’d), the root span never terminates and the OTel SDK silently
drops the entire trace tree on shutdown — every turn, generation, and
tool span for this session is lost from your observability backend.
Always pair connect() with close() via try/finally:
const session = await client.connect(config);try { for await (const ev of session.ask("...")) { ... }} finally { await session.close();}Also releases the forge-managed resources associated with the session. The session cannot be used after closing. Safe to call multiple times.
Returns
Promise<void>
getCompactionSummary()
getCompactionSummary():
string|undefined
Defined in: src/session.ts:347
Get the current compaction summary. Persist this alongside getTurns() for session restoration.
Returns
string | undefined
getTurn()
getTurn(
id):TurnResult|null
Defined in: src/session.ts:352
Get a specific turn by ID. Returns null if not found.
Parameters
id
string
Returns
TurnResult | null
getTurns()
getTurns(): readonly
TurnResult[]
Defined in: src/session.ts:342
Get all completed turns in chronological order.
Returns
readonly TurnResult[]