@jskit-ai/assistant-runtime 0.2.26 → 0.2.27

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.
@@ -5,6 +5,7 @@ import { tmpdir } from "node:os";
5
5
  import path from "node:path";
6
6
  import knex from "knex";
7
7
  import { AppError } from "@jskit-ai/kernel/server/runtime";
8
+ import { silentLogger } from "@jskit-ai/kernel/server/runtime/logger";
8
9
  import { createConversationTranscript } from "@jskit-ai/assistant-core/server/conversation";
9
10
  import { verifyConversationStorageContract } from "@jskit-ai/assistant-core/testing/conversation-storage";
10
11
  import transcriptsMigration from "../migrations/assistant_transcripts_initial.cjs";
@@ -17,8 +18,12 @@ import { createSqlConversationStorage } from "../src/server/sqlConversationStora
17
18
  import { createAssistantConversationRuntime } from "../src/server/createAssistantRuntime.js";
18
19
  import { createTranscriptService } from "../src/server/services/transcriptService.js";
19
20
  import { createChatService } from "../src/server/services/chatService.js";
21
+ import { NO_PERSON_CONTEXT, createPersonContextPrompt } from "../src/server/support/personContext.js";
20
22
  import { createScriptedModel } from "./support/scriptedModel.js";
21
23
 
24
+ // The chat service of an application that supplies no facts about the person.
25
+ const NO_FACTS = createPersonContextPrompt({ personContext: NO_PERSON_CONTEXT, logger: silentLogger });
26
+
22
27
  async function fixture(t) {
23
28
  const directory = await mkdtemp(path.join(tmpdir(), "assistant-sql-runtime-"));
24
29
  const clients = [];
@@ -178,6 +183,7 @@ test("the SQL facade uses common inference and durable tool rows, and the model'
178
183
  const dependencies = { conversationRuntime: runtime, aiClientFactory, serviceToolCatalog: catalog,
179
184
  transcriptService: createTranscriptService(f), turnRequests: createTurnRequestsRepository(f.db),
180
185
  assistantConfigService: { resolveSystemPrompt: async () => "Retained SQL instructions" },
186
+ personContextPrompt: NO_FACTS,
181
187
  appConfig: { surfaceDefinitions: { assistant: { enabled: true, requiresWorkspace: false } },
182
188
  assistantSurfaces: { assistant: { settingsSurfaceId: "assistant", configScope: "global" } } } };
183
189
  const service = createChatService(dependencies);
@@ -234,6 +240,7 @@ test("the SQL facade replays historical inspection failures with their exact pub
234
240
  const dependencies = { conversationRuntime: runtime, aiClientFactory, serviceToolCatalog: catalog,
235
241
  transcriptService: createTranscriptService(f), turnRequests,
236
242
  assistantConfigService: { resolveSystemPrompt: async () => "Read the supplied context" },
243
+ personContextPrompt: NO_FACTS,
237
244
  appConfig: { surfaceDefinitions: { assistant: { enabled: true, requiresWorkspace: false } },
238
245
  assistantSurfaces: { assistant: { settingsSurfaceId: "assistant", configScope: "global" } } } };
239
246
  const input = { targetSurfaceId: "assistant", conversationId: conversation.id,
@@ -344,6 +351,7 @@ for (const shape of ["orphan-output", "orphan-tool-result", "unconfirmed-tool"])
344
351
  const dependencies = { conversationRuntime: runtime, aiClientFactory, serviceToolCatalog: catalog,
345
352
  transcriptService: createTranscriptService(f), turnRequests,
346
353
  assistantConfigService: { resolveSystemPrompt: async () => "Read only the admitted request" },
354
+ personContextPrompt: NO_FACTS,
347
355
  workspaceScopeSupport: { resolveWorkspace: context => context.requestMeta.resolvedWorkspaceContext.workspace },
348
356
  appConfig: { surfaceDefinitions: {
349
357
  assistant: { enabled: true, requiresWorkspace: true }, other: { enabled: true, requiresWorkspace: true }
@@ -1,8 +1,8 @@
1
1
  /** Repository fixture for the original chat-service unit cases. The production
2
2
  * SQL adapter and common runtime run unchanged over these transactional rows.
3
3
  */
4
- export function createMemoryAssistantRows({ id = "conversation_1", surfaceId = "assistant", messages = [] } = {}) {
5
- let state = { conversation: { id, workspaceId: null, createdByUserId: "1", surfaceId,
4
+ export function createMemoryAssistantRows({ id = "conversation_1", surfaceId = "assistant", workspaceId = null, messages = [] } = {}) {
5
+ let state = { conversation: { id, workspaceId, createdByUserId: "1", surfaceId,
6
6
  title: "New conversation", status: "active", messageCount: 0, metadata: {} }, transcript: { revision: "", summary: null }, messages: [] };
7
7
  let pending = Promise.resolve();
8
8
  const read = options => options?.trx || state;
@@ -6,7 +6,9 @@ import path from "node:path";
6
6
  import knex from "knex";
7
7
  import migration from "../migrations/assistant_turn_requests.cjs";
8
8
  import { createRepository } from "../src/server/repositories/turnRequestsRepository.js";
9
+ import { silentLogger } from "@jskit-ai/kernel/server/runtime/logger";
9
10
  import { createChatService } from "../src/server/services/chatService.js";
11
+ import { NO_PERSON_CONTEXT, createPersonContextPrompt } from "../src/server/support/personContext.js";
10
12
  import { createAssistantConversationRuntime } from "../src/server/createAssistantRuntime.js";
11
13
  import { createMemoryAssistantRows } from "./support/memoryAssistantRows.js";
12
14
  import { createScriptedModel } from "./support/scriptedModel.js";
@@ -59,6 +61,7 @@ function service(repository, { provider, transcript = [] } = {}) {
59
61
  serviceToolCatalog: { limits: { maxToolArgumentBytes: 64 * 1024 }, resolveToolSet: () => ({ tools: [] }),
60
62
  toOpenAiToolSchema: tool => ({ type: "function", function: tool }) },
61
63
  assistantConfigService: { resolveSystemPrompt: async () => "Answer." },
64
+ personContextPrompt: createPersonContextPrompt({ personContext: NO_PERSON_CONTEXT, logger: silentLogger }),
62
65
  appConfig: {
63
66
  surfaceDefinitions: { assistant: { id: "assistant", enabled: true, requiresWorkspace: false, accessPolicyId: "public" } },
64
67
  assistantSurfaces: { assistant: { settingsSurfaceId: "assistant", configScope: "global" } }