> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentium.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Sessions and resources

> Identity-scoped session leases, snapshots, stores, and resource ownership.

Identity-scoped session leases, snapshots, stores, and resource ownership. Read the [sessions and resources guide](/harness/sessions) for examples, defaults, and behavior.

These declarations cover every public export in this category. Import from `@agentium/harness`. Types such as `ChatMessage`, `RunContext`, and `ExecutionServices` come from [`@agentium/core`](/api-reference/core). A `?` marks an optional field.

## HarnessIdentity

```typescript theme={null}
export interface HarnessIdentity {
    userId: string;
    tenantId: string;
}
```

## HarnessSessionLease

```typescript theme={null}
export interface HarnessSessionLease {
    read(): HarnessSessionSnapshot;
    commit(snapshot: Omit<HarnessSessionSnapshot, "revision">): void;
    release(): void;
}
```

## HarnessSessionSnapshot

```typescript theme={null}
export interface HarnessSessionSnapshot {
    conversations?: Record<string, ChatMessage[]>;
    history: ChatMessage[];
    state: Record<string, unknown>;
    revision: number;
    replayable: boolean;
}
```

## HarnessSessionStore

```typescript theme={null}
export interface HarnessSessionStore {
    readonly guarantees: {
        durable: boolean;
        compareAndSwap: boolean;
        singleWriter: "process" | "distributed";
    };
    acquire(identity: HarnessIdentity, sessionId: string): Promise<HarnessSessionLease>;
}
```

## ScopedResource

```typescript theme={null}
export interface ScopedResource<T = unknown> {
    value: T;
    ownership: "host" | "runtime";
    dispose?: () => Promise<void>;
}
```

## SessionResourceLease

```typescript theme={null}
export interface SessionResourceLease<T> {
    value: T;
    release: () => Promise<void>;
}
```

## HarnessResourcePool

```typescript theme={null}
/** Session resources live until explicit closeSession; run resources use their returned lease. */
export declare class HarnessResourcePool {
    acquire<T>(identity: HarnessIdentity, sessionId: string, id: string, scope: "host" | "session" | "run", initialize: () => Promise<ScopedResource<T>>): Promise<SessionResourceLease<T>>;
    closeSession(identity: HarnessIdentity, sessionId: string): Promise<readonly string[]>;
}
```

## HarnessSessionConflict

```typescript theme={null}
export declare class HarnessSessionConflict extends Error {
    readonly code = "session_conflict";
    constructor();
}
```

## InMemoryHarnessSessionStore

```typescript theme={null}
/** One writer per scoped session; deliberately rejects rather than silently interleaving. */
export declare class InMemoryHarnessSessionStore implements HarnessSessionStore {
    readonly guarantees: {
        durable: boolean;
        compareAndSwap: boolean;
        singleWriter: "process";
    };
    acquire(identity: HarnessIdentity, sessionId: string): Promise<HarnessSessionLease>;
    /** Imported display-only transcripts are readable but never represented as complete replay state. */
    importLegacy(identity: HarnessIdentity, sessionId: string, history: ChatMessage[]): void;
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.