@firstlovecenter/ai-chat 0.8.1 → 0.9.0

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.
@@ -1,5 +1,5 @@
1
- import { S as SystemBlock, T as ToolSchema, a as ToolContext, b as ToolDefinition, P as PresentPayload, c as PersistencePort, A as AuthPort, d as ScopePort, e as ToolsPort, V as VertexPort, L as LoggerPort } from '../types-BnwUkqKb.cjs';
2
- export { f as AiSettings, g as AiSettingsPatch, h as AppendMessageInput, i as AuthFail, j as AuthOk, k as AuthResult, B as Block, C as ChartSpec, l as ChatMessage, m as ChatMessageRole, n as ChatSession, o as CreateSessionInput, p as ListSessionsOpts, q as TERMINAL_TOOL_NAME, r as ToolResult, s as err, t as ok } from '../types-BnwUkqKb.cjs';
1
+ import { S as SystemBlock, T as ToolSchema, a as ToolContext, b as ToolDefinition, P as PresentPayload, c as PersistencePort, A as AuthPort, d as ScopePort, e as ToolsPort, V as VertexPort, L as LoggerPort } from '../types-BOgBJ7CD.cjs';
2
+ export { f as AiSettings, g as AiSettingsPatch, h as AppendMessageInput, i as AuthFail, j as AuthOk, k as AuthResult, B as Block, C as ChartSpec, l as ChatMessage, m as ChatMessageRole, n as ChatSession, o as CreateSessionInput, p as ListSessionsOpts, q as TERMINAL_TOOL_NAME, r as ToolResult, s as err, t as ok } from '../types-BOgBJ7CD.cjs';
3
3
  import { GoogleAuth } from 'google-auth-library';
4
4
  export { GoogleAuth } from 'google-auth-library';
5
5
  import 'zod';
@@ -272,7 +272,7 @@ type AgentCustomHooks$1<S> = RouteHooks$1<S> & {
272
272
  generateSessionId?(args: {
273
273
  scope: S;
274
274
  userId: number;
275
- chatSessionId: number | null;
275
+ chatSessionId: string | null;
276
276
  }): string | Promise<string>;
277
277
  /**
278
278
  * Runs once after the session id is resolved, before the agent loop.
@@ -1,5 +1,5 @@
1
- import { S as SystemBlock, T as ToolSchema, a as ToolContext, b as ToolDefinition, P as PresentPayload, c as PersistencePort, A as AuthPort, d as ScopePort, e as ToolsPort, V as VertexPort, L as LoggerPort } from '../types-BnwUkqKb.js';
2
- export { f as AiSettings, g as AiSettingsPatch, h as AppendMessageInput, i as AuthFail, j as AuthOk, k as AuthResult, B as Block, C as ChartSpec, l as ChatMessage, m as ChatMessageRole, n as ChatSession, o as CreateSessionInput, p as ListSessionsOpts, q as TERMINAL_TOOL_NAME, r as ToolResult, s as err, t as ok } from '../types-BnwUkqKb.js';
1
+ import { S as SystemBlock, T as ToolSchema, a as ToolContext, b as ToolDefinition, P as PresentPayload, c as PersistencePort, A as AuthPort, d as ScopePort, e as ToolsPort, V as VertexPort, L as LoggerPort } from '../types-BOgBJ7CD.js';
2
+ export { f as AiSettings, g as AiSettingsPatch, h as AppendMessageInput, i as AuthFail, j as AuthOk, k as AuthResult, B as Block, C as ChartSpec, l as ChatMessage, m as ChatMessageRole, n as ChatSession, o as CreateSessionInput, p as ListSessionsOpts, q as TERMINAL_TOOL_NAME, r as ToolResult, s as err, t as ok } from '../types-BOgBJ7CD.js';
3
3
  import { GoogleAuth } from 'google-auth-library';
4
4
  export { GoogleAuth } from 'google-auth-library';
5
5
  import 'zod';
@@ -272,7 +272,7 @@ type AgentCustomHooks$1<S> = RouteHooks$1<S> & {
272
272
  generateSessionId?(args: {
273
273
  scope: S;
274
274
  userId: number;
275
- chatSessionId: number | null;
275
+ chatSessionId: string | null;
276
276
  }): string | Promise<string>;
277
277
  /**
278
278
  * Runs once after the session id is resolved, before the agent loop.
@@ -1011,7 +1011,7 @@ function createAgentCustomRoutes(ctx) {
1011
1011
  );
1012
1012
  }
1013
1013
  const rawChatSessionId = body?.chatSessionId;
1014
- const incomingChatSessionId = typeof rawChatSessionId === "number" && Number.isInteger(rawChatSessionId) ? rawChatSessionId : null;
1014
+ const incomingChatSessionId = typeof rawChatSessionId === "string" && rawChatSessionId.length > 0 ? rawChatSessionId : null;
1015
1015
  const aiSettings = await persistence.getAiSettings();
1016
1016
  const effectiveProjectId = aiSettings.gcpProjectId ?? vertex.projectId;
1017
1017
  let chatSessionId;
@@ -1357,7 +1357,7 @@ function createAgentVercelRoutes(ctx) {
1357
1357
  );
1358
1358
  }
1359
1359
  const rawChatSessionId = body?.chatSessionId;
1360
- const incomingChatSessionId = typeof rawChatSessionId === "number" && Number.isInteger(rawChatSessionId) ? rawChatSessionId : null;
1360
+ const incomingChatSessionId = typeof rawChatSessionId === "string" && rawChatSessionId.length > 0 ? rawChatSessionId : null;
1361
1361
  const rawModel = body?.model;
1362
1362
  const requestedModel = typeof rawModel === "string" && VALID_MODELS.has(rawModel) ? rawModel : null;
1363
1363
  const aiSettings = await persistence.getAiSettings();
@@ -1595,10 +1595,10 @@ function serializeSession(s) {
1595
1595
  updatedAt: s.updatedAt ? s.updatedAt.toISOString() : null
1596
1596
  };
1597
1597
  }
1598
+ var SESSION_ID_RE = /^[A-Za-z0-9_-]{1,32}$/;
1598
1599
  function parseSessionId(raw) {
1599
- const id = Number(raw);
1600
- if (!Number.isInteger(id) || id <= 0) return null;
1601
- return id;
1600
+ if (!raw || !SESSION_ID_RE.test(raw)) return null;
1601
+ return raw;
1602
1602
  }
1603
1603
  function createChatSessionsRoutes(ctx) {
1604
1604
  const { persistence, auth, logger, hooks } = ctx;