@theoremjs/web 0.3.4-next.781.g97bafb5 → 0.3.4-next.785.g899b273

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -282,13 +282,11 @@ const transport = withPageToolDispatch(
282
282
 
283
283
  ### Defaults
284
284
 
285
- A limit that stops a turn or refuses a request is unset unless you set it: `gateTtlMs`, `maxRequestBytes`, `pageToolTimeoutMs`, and a session store's `capacity`. Only what keeps stored data from growing without end has a default:
285
+ A limit that stops a turn or refuses a request is unset unless you set it: `gateTtlMs`, `maxRequestBytes`, `pageToolTimeoutMs`, and a session store's `capacity`. The memory stores expire and evict nothing unless you set `ttlMs` and `maxSessions`, so they grow until the process ends. Set both on a public server. These have a default:
286
286
 
287
287
  | What | Default | Set it with |
288
288
  | --- | --- | --- |
289
289
  | A settled tool result | Kept 24 hours | `operationRetentionMs` |
290
- | A session in `createMemorySessionStore` | Dropped after 24 idle hours; at most 10,000 kept | `ttlMs`, `maxSessions` |
291
- | A conversation in `createMemoryConversationStore` | Dropped after 24 hours unsaved; at most 10,000 kept | `ttlMs`, `maxSessions` |
292
290
  | The session cookie | Lasts 30 days | `session` |
293
291
 
294
292
  A model profile that leaves out `maxSteps` makes at most 20 model calls a turn.
@@ -326,7 +324,7 @@ The session store keeps gates, permissions, and operations. The two stores are s
326
324
 
327
325
  | Store | Where the conversation is kept |
328
326
  | --- | --- |
329
- | `createMemoryConversationStore()` | Process memory, for one server instance. A conversation that is not saved for 24 hours expires. At most 10,000 conversations are kept; the one saved longest ago goes first. Set `ttlMs` and `maxSessions` to change these limits. |
327
+ | `createMemoryConversationStore()` | Process memory, for one server instance. It keeps every conversation until the process ends. Set `ttlMs` to expire a conversation that is not saved for that long, and `maxSessions` to cap the count; the one saved longest ago goes first. |
330
328
  | `createSealedConversationStore({ keys, keyVersion })` | Nowhere on the server. The ref is the conversation itself, encrypted and signed with your key, and bound to the session. The browser cannot read it or change it. |
331
329
  | Your own `TheoremConversationStore` | Your database. |
332
330
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theoremjs/web",
3
- "version": "0.3.4-next.781.g97bafb5",
3
+ "version": "0.3.4-next.785.g899b273",
4
4
  "description": "Theorem on the web platform, with no UI framework: Web-standard server handlers that serve a profile, and the browser client that talks to them.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -25,6 +25,6 @@
25
25
  },
26
26
  "peerDependencies": {
27
27
  "zod": "^4.6.5",
28
- "@theoremjs/agents": "^0.3.4-next.781.g97bafb5"
28
+ "@theoremjs/agents": "^0.3.4-next.785.g899b273"
29
29
  }
30
30
  }
@@ -80,7 +80,7 @@ export interface TheoremConversationStore {
80
80
  }
81
81
  /** Refuses a ref the store does not know or cannot open: the browser reads `session.conversation_unknown`. */
82
82
  export declare function unknownConversation(cause?: unknown): TheoremError;
83
- /** Conversations in process memory: forgotten when idle, oldest evicted first. For one instance. */
83
+ /** Conversations in process memory, until the limits it is given. For one instance. */
84
84
  export declare function createMemoryConversationStore(options?: Omit<MemorySessionStoreOptions, 'sessionLimits'>): TheoremConversationStore;
85
85
  export type SealedConversationStoreOptions = {
86
86
  /** Every sealing key still in use, by version: each at least 32 bytes, kept off the browser. */
@@ -49,7 +49,7 @@ export function unknownConversation(cause) {
49
49
  ...(cause === undefined ? {} : { cause }),
50
50
  });
51
51
  }
52
- /** Conversations in process memory: forgotten when idle, oldest evicted first. For one instance. */
52
+ /** Conversations in process memory, until the limits it is given. For one instance. */
53
53
  export function createMemoryConversationStore(options = {}) {
54
54
  const { ttlMs, maxSessions } = memoryStoreLimits(options);
55
55
  const conversations = new Map();
@@ -117,9 +117,9 @@ export declare function pruneGates<Gate extends {
117
117
  export type MemorySessionStoreOptions = {
118
118
  /** What it holds for one session. Unset, it holds any size. */
119
119
  capacity?: TheoremSessionCapacity;
120
- /** invariant: Idle retention is in milliseconds. Protected authority remains. Default 24h. */
120
+ /** invariant: Idle retention is in milliseconds. Protected authority remains. Unset, nothing expires. */
121
121
  ttlMs?: number;
122
- /** Oldest sessions are evicted past this count. Default 10 000. */
122
+ /** Oldest sessions are evicted past this count. Unset, nothing is evicted. */
123
123
  maxSessions?: number;
124
124
  };
125
125
  export declare function memoryStoreLimits(options: MemorySessionStoreOptions): {
@@ -131,7 +131,7 @@ export type PerSessionStore<T> = {
131
131
  load(sessionId: string): T | undefined | Promise<T | undefined>;
132
132
  save(sessionId: string, value: T): void | Promise<void>;
133
133
  };
134
- /** A per-session value kept in process memory: forgotten when idle, oldest evicted first. */
134
+ /** A per-session value kept in process memory, until the limits it is given. */
135
135
  export declare function createMemorySessionMap<T>(options?: MemorySessionStoreOptions): {
136
136
  load(sessionId: string): T | undefined;
137
137
  save(sessionId: string, value: T): void;
@@ -198,19 +198,19 @@ export function pruneGates(gates, now, ttlMs) {
198
198
  : !gateExpired(gate.createdAt, now, ttlMs)));
199
199
  }
200
200
  export function memoryStoreLimits(options) {
201
- const ttlMs = options.ttlMs ?? 24 * 60 * 60 * 1000;
202
- const maxSessions = options.maxSessions ?? 10_000;
203
- if (!Number.isFinite(ttlMs) ||
204
- ttlMs <= 0 ||
205
- !Number.isSafeInteger(maxSessions) ||
206
- maxSessions <= 0) {
201
+ const { ttlMs, maxSessions } = options;
202
+ if ((ttlMs !== undefined && (!Number.isFinite(ttlMs) || ttlMs <= 0)) ||
203
+ (maxSessions !== undefined && (!Number.isSafeInteger(maxSessions) || maxSessions <= 0))) {
207
204
  throw new TheoremError('config', labelText('error.config'), {
208
205
  cause: { code: 'session_store_options', ttlMs, maxSessions },
209
206
  });
210
207
  }
211
- return { ttlMs, maxSessions };
208
+ return {
209
+ ttlMs: ttlMs ?? Number.POSITIVE_INFINITY,
210
+ maxSessions: maxSessions ?? Number.POSITIVE_INFINITY,
211
+ };
212
212
  }
213
- /** A per-session value kept in process memory: forgotten when idle, oldest evicted first. */
213
+ /** A per-session value kept in process memory, until the limits it is given. */
214
214
  export function createMemorySessionMap(options = {}) {
215
215
  const { ttlMs, maxSessions } = memoryStoreLimits(options);
216
216
  const sessions = new Map();