@columenlabs/lumen-ai 0.1.231 → 0.1.232

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.
@@ -144,6 +144,8 @@ export interface AskInput {
144
144
  screen?: AssistantScreenMap;
145
145
  /** How earlier screen calls ended in the browser. */
146
146
  outcomes?: AssistantScreenOutcome[];
147
+ /** The person kept this message in this chat after a fresh chat was offered (`offerFresh`). */
148
+ stay?: boolean;
147
149
  }
148
150
  /** A quote as sent, checked: its text cut to `ASSISTANT_QUOTE_MAX`, and whose message it came from. */
149
151
  export declare function quoteOf(q: unknown): AssistantQuote | undefined;
@@ -182,6 +184,13 @@ export declare abstract class LumenAgent<Env = unknown> extends Think<Env> {
182
184
  includeMcpTools: boolean;
183
185
  /** What the person sent with the message this turn answers (page, refs, tier, zone). */
184
186
  protected get input(): AskInput | null;
187
+ /**
188
+ * Whether to ask the person to take `input` to a fresh chat before answering it: `true` when it
189
+ * starts new work and this chat is long (the app decides both, e.g. from `usage().context`).
190
+ * The panel then shows a card: + sends the message in a new chat, × sends it here again with
191
+ * `stay`. Off (`false`) unless the app overrides it; a throw counts as `false`.
192
+ */
193
+ protected offerFresh(_input: AskInput): Promise<boolean>;
185
194
  /** The chat's running use: every answer's parts added up, and the last context size. */
186
195
  usage(): ChatUsage;
187
196
  /** The chat as the panel reads it: title, last message, items and use. */
@@ -184,6 +184,15 @@ export class LumenAgent extends Think {
184
184
  this.#meta();
185
185
  this.sql `INSERT OR REPLACE INTO lumen_chat (k, v) VALUES (${k}, ${JSON.stringify(v)})`;
186
186
  }
187
+ /**
188
+ * Whether to ask the person to take `input` to a fresh chat before answering it: `true` when it
189
+ * starts new work and this chat is long (the app decides both, e.g. from `usage().context`).
190
+ * The panel then shows a card: + sends the message in a new chat, × sends it here again with
191
+ * `stay`. Off (`false`) unless the app overrides it; a throw counts as `false`.
192
+ */
193
+ async offerFresh(_input) {
194
+ return false;
195
+ }
187
196
  /** The chat's running use: every answer's parts added up, and the last context size. */
188
197
  usage() {
189
198
  return this.#get('usage') ?? chatUsage([]);
@@ -229,6 +238,12 @@ export class LumenAgent extends Think {
229
238
  }
230
239
  this.#put('at', at);
231
240
  await sink.event({ event: 'chat', data: { id: this.name, title } });
241
+ // New work in a long chat: the panel asks first, and the message is not kept or answered here.
242
+ if (!input.stay && (await this.offerFresh(input).catch(() => false))) {
243
+ await sink.event({ event: 'fresh', data: {} });
244
+ await sink.event({ event: 'done', data: { id: this.name, usage: this.usage() } });
245
+ return;
246
+ }
232
247
  this.#outcomes(screenOutcomesOf(input.outcomes));
233
248
  const quote = quoteOf(input.quote);
234
249
  const meta = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@columenlabs/lumen-ai",
3
- "version": "0.1.231",
3
+ "version": "0.1.232",
4
4
  "description": "Lumen's assistant and agent parts: a chat assistant's server (Claude tiers, tools over MCP, the web, hand off, spend caps), serving an MCP server from a Worker, read-only tool sets and metered tool calls.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -52,8 +52,8 @@
52
52
  "@ai-sdk/openai": "4.0.108",
53
53
  "@anthropic-ai/sdk": "0.133.0",
54
54
  "@cloudflare/think": "0.23.0",
55
- "@columenlabs/lumen-ops": "0.1.231",
56
- "@columenlabs/lumen-ui-types": "0.1.231",
55
+ "@columenlabs/lumen-ops": "0.1.232",
56
+ "@columenlabs/lumen-ui-types": "0.1.232",
57
57
  "agents": "0.32.0",
58
58
  "ai": "7.0.162",
59
59
  "just-bash": "3.6.0",