@vellumai/assistant 0.10.7-dev.202607092332.9deedf4 → 0.10.7-dev.202607100313.fffdfea
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/ARCHITECTURE.md +1 -2
- package/docs/architecture/memory.md +1 -3
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/package.json +0 -2
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/__tests__/contracts.test.ts +0 -2
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/credential-rpc.ts +3 -5
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/index.ts +2 -4
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/rpc.ts +4 -447
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/package.json +0 -2
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/__tests__/contracts.test.ts +0 -2
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/credential-rpc.ts +3 -5
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/index.ts +2 -4
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/rpc.ts +4 -447
- package/node_modules/@vellumai/service-contracts/package.json +0 -2
- package/node_modules/@vellumai/service-contracts/src/__tests__/contracts.test.ts +0 -2
- package/node_modules/@vellumai/service-contracts/src/credential-rpc.ts +3 -5
- package/node_modules/@vellumai/service-contracts/src/index.ts +2 -4
- package/node_modules/@vellumai/service-contracts/src/rpc.ts +4 -447
- package/openapi.yaml +1 -222
- package/package.json +1 -1
- package/scripts/memory-inspect.ts +2 -8
- package/src/__tests__/approval-routes-http.test.ts +0 -8
- package/src/__tests__/background-workers-disk-pressure.test.ts +4 -2
- package/src/__tests__/compaction-events.test.ts +0 -4
- package/src/__tests__/context-search-memory-source.test.ts +0 -1
- package/src/__tests__/conversation-agent-loop-disk-pressure.test.ts +0 -1
- package/src/__tests__/conversation-agent-loop-inference-profile.test.ts +0 -2
- package/src/__tests__/conversation-agent-loop-overflow.test.ts +0 -2
- package/src/__tests__/conversation-agent-loop.test.ts +0 -4
- package/src/__tests__/conversation-app-control-lifecycle.test.ts +0 -4
- package/src/__tests__/conversation-fork-crud.test.ts +18 -5
- package/src/__tests__/conversation-fork-retrospective.test.ts +483 -0
- package/src/__tests__/conversation-routes-disk-view.test.ts +0 -4
- package/src/__tests__/conversation-store.test.ts +0 -10
- package/src/__tests__/conversation-summarize-up-to.test.ts +0 -4
- package/src/__tests__/credential-execution-api-key-propagation.test.ts +0 -40
- package/src/__tests__/credential-execution-client.test.ts +3 -3
- package/src/__tests__/credential-execution-managed-contract.test.ts +8 -104
- package/src/__tests__/file-write-tool.test.ts +9 -13
- package/src/__tests__/graph-extraction-event-date.test.ts +0 -9
- package/src/__tests__/injection-block.test.ts +0 -1
- package/src/__tests__/job-handler-registration-guard.test.ts +0 -1
- package/src/__tests__/lexical-index-dual-write.test.ts +2 -2
- package/src/__tests__/llm-resolver.test.ts +0 -1
- package/src/__tests__/messages-after-tiebreaker.test.ts +0 -1
- package/src/__tests__/playbook-execution.test.ts +2 -26
- package/src/__tests__/plugin-import-boundary-guard.test.ts +0 -4
- package/src/__tests__/plugin-import-boundary-reverse-guard.test.ts +318 -0
- package/src/__tests__/proxy-approval-callback.test.ts +0 -1
- package/src/__tests__/rebuild-index-graph-nodes.test.ts +0 -4
- package/src/__tests__/send-endpoint-busy.test.ts +0 -12
- package/src/__tests__/service-contracts-import-guard.test.ts +4 -9
- package/src/__tests__/subagent-fork-spawn.test.ts +0 -37
- package/src/__tests__/task-memory-cleanup.test.ts +0 -11
- package/src/__tests__/voice-scoped-grant-consumer.test.ts +0 -1
- package/src/__tests__/voice-session-bridge.test.ts +0 -56
- package/src/__tests__/workspace-migration-009-backfill-conversation-disk-view.test.ts +0 -1
- package/src/__tests__/workspace-migration-013-repair-conversation-disk-view.test.ts +0 -1
- package/src/__tests__/workspace-migration-028-recover-conversations-from-disk-view.test.ts +0 -1
- package/src/__tests__/workspace-migration-129-remove-analyze-conversation-config.test.ts +190 -0
- package/src/cli/commands/db/repair-step-conversation-backfill.ts +0 -1
- package/src/config/bundled-skills/messaging/tools/messaging-analyze-style.ts +0 -6
- package/src/config/bundled-skills/playbooks/tools/playbook-create.ts +0 -3
- package/src/config/bundled-skills/playbooks/tools/playbook-delete.ts +0 -3
- package/src/config/bundled-skills/playbooks/tools/playbook-list.ts +1 -3
- package/src/config/bundled-skills/playbooks/tools/playbook-update.ts +0 -4
- package/src/config/call-site-defaults.ts +0 -1
- package/src/config/feature-flag-registry.json +0 -16
- package/src/config/schema.ts +0 -3
- package/src/config/schemas/call-site-catalog.ts +0 -6
- package/src/config/schemas/llm.ts +0 -1
- package/src/conversations/job-handlers/summarization.ts +0 -2
- package/src/daemon/conversation-agent-loop-handlers.ts +0 -1
- package/src/daemon/conversation-agent-loop.ts +1 -6
- package/src/daemon/conversation-lifecycle.ts +0 -14
- package/src/daemon/conversation-turn-finalize.ts +0 -1
- package/src/daemon/handlers/shared.ts +1 -2
- package/src/export/transcript-formatter.ts +9 -39
- package/src/home/conversation-starter-checkpoints.ts +9 -5
- package/src/home/job-handlers/conversation-starters.ts +24 -54
- package/src/hooks/types.ts +2 -2
- package/src/ipc/routes/__tests__/memory-v2-backfill.test.ts +5 -7
- package/src/persistence/__tests__/bulk-write-gate.test.ts +165 -0
- package/src/persistence/__tests__/immediate-transaction-guard.test.ts +70 -0
- package/src/persistence/auto-analysis-constants.ts +4 -13
- package/src/persistence/bulk-write-gate.ts +82 -0
- package/src/persistence/conversation-bootstrap.ts +3 -3
- package/src/persistence/conversation-crud.ts +158 -80
- package/src/persistence/conversation-key-store.ts +0 -2
- package/src/persistence/conversation-row-batch-delete.ts +16 -1
- package/src/persistence/conversation-types.ts +12 -1
- package/src/persistence/db-async-query.ts +18 -9
- package/src/persistence/db-connection.ts +20 -4
- package/src/persistence/db-maintenance.ts +78 -6
- package/src/persistence/embeddings/qdrant-client.ts +2 -18
- package/src/persistence/fork-message-copy.ts +18 -4
- package/src/persistence/jobs-store.ts +3 -86
- package/src/persistence/migrations/323-delete-non-default-memory-scopes.test.ts +148 -0
- package/src/persistence/migrations/323-delete-non-default-memory-scopes.ts +35 -0
- package/src/persistence/schema/conversations.ts +0 -1
- package/src/persistence/schema/memory-core.ts +17 -28
- package/src/persistence/schema/memory-graph.ts +0 -4
- package/src/persistence/schema/tasks.ts +0 -1
- package/src/persistence/steps.ts +2 -0
- package/src/playbooks/playbook-compiler.ts +2 -10
- package/src/plugins/defaults/memory/__tests__/db-maintenance.test.ts +105 -11
- package/src/plugins/defaults/memory/__tests__/jobs-store-enqueue-gate.test.ts +7 -62
- package/src/plugins/defaults/memory/__tests__/memory-retrospective-job.test.ts +47 -5
- package/src/plugins/defaults/memory/__tests__/memory-retrospective-skill-card.test.ts +29 -1
- package/src/plugins/defaults/memory/__tests__/memory-retrospective-startup-cleanup.test.ts +133 -70
- package/src/plugins/defaults/memory/activation-session-store.ts +1 -1
- package/src/plugins/defaults/memory/config.ts +1 -1
- package/src/plugins/defaults/memory/context-search/sources/conversations.ts +1 -1
- package/src/plugins/defaults/memory/context-search/sources/memory-v2.ts +1 -1
- package/src/plugins/defaults/memory/context-search/sources/memory.ts +1 -1
- package/src/plugins/defaults/memory/filing-jobs.ts +1 -1
- package/src/plugins/defaults/memory/fork-conversation-memory.ts +8 -4
- package/src/plugins/defaults/memory/frontmatter.ts +1 -1
- package/src/plugins/defaults/memory/graph/__tests__/handle-remember-v2.test.ts +4 -25
- package/src/plugins/defaults/memory/graph/bootstrap.ts +12 -18
- package/src/plugins/defaults/memory/graph/capability-seed.ts +4 -18
- package/src/plugins/defaults/memory/graph/consolidation.ts +7 -14
- package/src/plugins/defaults/memory/graph/conversation-graph-memory.ts +1 -3
- package/src/plugins/defaults/memory/graph/decay.ts +5 -10
- package/src/plugins/defaults/memory/graph/extraction-job.ts +2 -3
- package/src/plugins/defaults/memory/graph/extraction.test.ts +1 -9
- package/src/plugins/defaults/memory/graph/extraction.ts +1 -8
- package/src/plugins/defaults/memory/graph/graph-search.ts +1 -2
- package/src/plugins/defaults/memory/graph/injection.test.ts +0 -1
- package/src/plugins/defaults/memory/graph/injection.ts +1 -1
- package/src/plugins/defaults/memory/graph/narrative.ts +1 -3
- package/src/plugins/defaults/memory/graph/pattern-scan.ts +1 -4
- package/src/plugins/defaults/memory/graph/retriever.test.ts +0 -19
- package/src/plugins/defaults/memory/graph/retriever.ts +6 -14
- package/src/plugins/defaults/memory/graph/scoring.test.ts +0 -1
- package/src/plugins/defaults/memory/graph/store.test.ts +6 -58
- package/src/plugins/defaults/memory/graph/store.ts +5 -43
- package/src/plugins/defaults/memory/graph/tool-handlers.test.ts +0 -4
- package/src/plugins/defaults/memory/graph/tool-handlers.ts +1 -11
- package/src/plugins/defaults/memory/graph/types.ts +0 -3
- package/src/plugins/defaults/memory/hooks/init.ts +1 -1
- package/src/plugins/defaults/memory/indexer.ts +2 -45
- package/src/plugins/defaults/memory/injectors.ts +2 -3
- package/src/plugins/defaults/memory/job-handler-registration.ts +0 -4
- package/src/plugins/defaults/memory/job-handlers/backfill.ts +0 -1
- package/src/plugins/defaults/memory/job-handlers/embedding.test.ts +0 -1
- package/src/plugins/defaults/memory/job-handlers/embedding.ts +0 -4
- package/src/plugins/defaults/memory/job-handlers/index-maintenance.ts +1 -1
- package/src/plugins/defaults/memory/job-handlers.ts +5 -9
- package/src/plugins/defaults/memory/jobs/embed-concept-page.ts +1 -1
- package/src/plugins/defaults/memory/jobs/embed-pkb-file.test.ts +41 -21
- package/src/plugins/defaults/memory/jobs/embed-pkb-file.ts +10 -5
- package/src/plugins/defaults/memory/jobs-worker.ts +21 -9
- package/src/plugins/defaults/memory/logging.ts +17 -0
- package/src/plugins/defaults/memory/memory-retrospective-constants.ts +10 -7
- package/src/plugins/defaults/memory/memory-retrospective-enqueue.ts +5 -6
- package/src/plugins/defaults/memory/memory-retrospective-fork-boundary.ts +57 -20
- package/src/plugins/defaults/memory/memory-retrospective-job.ts +13 -15
- package/src/plugins/defaults/memory/memory-retrospective-skill-card.ts +2 -2
- package/src/plugins/defaults/memory/memory-retrospective-startup-cleanup.ts +52 -39
- package/src/plugins/defaults/memory/memory-retrospective-trigger-check.ts +1 -1
- package/src/plugins/defaults/memory/pkb/pkb-index.test.ts +25 -38
- package/src/plugins/defaults/memory/pkb/pkb-index.ts +7 -19
- package/src/plugins/defaults/memory/pkb/pkb-reconcile.test.ts +46 -28
- package/src/plugins/defaults/memory/pkb/pkb-reconcile.ts +4 -9
- package/src/plugins/defaults/memory/pkb/pkb-search.test.ts +3 -9
- package/src/plugins/defaults/memory/pkb/pkb-search.ts +2 -9
- package/src/plugins/defaults/memory/pkb/types.ts +0 -11
- package/src/plugins/defaults/memory/rerank-local.ts +1 -1
- package/src/plugins/defaults/memory/routes/memory-eval-routes.ts +1 -1
- package/src/plugins/defaults/memory/routes/memory-item-routes.test.ts +0 -1
- package/src/plugins/defaults/memory/routes/memory-item-routes.ts +3 -11
- package/src/plugins/defaults/memory/routes/memory-v2-routes.ts +1 -1
- package/src/plugins/defaults/memory/routes/memory-v3-routes.ts +1 -1
- package/src/plugins/defaults/memory/startup.ts +2 -3
- package/src/plugins/defaults/memory/task-memory-cleanup.ts +1 -1
- package/src/plugins/defaults/memory/tools.test.ts +1 -9
- package/src/plugins/defaults/memory/tools.ts +0 -1
- package/src/plugins/defaults/memory/v2/backfill-jobs.ts +1 -1
- package/src/plugins/defaults/memory/v2/cli-command-store.ts +1 -1
- package/src/plugins/defaults/memory/v2/consolidation-job.ts +1 -1
- package/src/plugins/defaults/memory/v2/frontmatter-sweep.ts +1 -1
- package/src/plugins/defaults/memory/v2/injection-events.ts +1 -1
- package/src/plugins/defaults/memory/v2/injection.ts +1 -1
- package/src/plugins/defaults/memory/v2/memory-v2-startup.ts +1 -1
- package/src/plugins/defaults/memory/v2/migration.ts +1 -1
- package/src/plugins/defaults/memory/v2/page-index.ts +1 -1
- package/src/plugins/defaults/memory/v2/prompts/consolidation.ts +1 -1
- package/src/plugins/defaults/memory/v2/prompts/router.ts +1 -1
- package/src/plugins/defaults/memory/v2/qdrant.ts +1 -1
- package/src/plugins/defaults/memory/v2/reranker.ts +1 -1
- package/src/plugins/defaults/memory/v2/router.ts +1 -1
- package/src/plugins/defaults/memory/v2/skill-store.ts +1 -1
- package/src/plugins/defaults/memory/v2/sweep-job.ts +1 -1
- package/src/plugins/defaults/memory/v3/candidate-match.ts +1 -1
- package/src/plugins/defaults/memory/v3/dense.ts +1 -1
- package/src/plugins/defaults/memory/v3/injector.ts +1 -1
- package/src/plugins/defaults/memory/v3/maintain-job.ts +1 -1
- package/src/plugins/defaults/memory/v3/orchestrate.ts +1 -1
- package/src/plugins/defaults/memory/v3/pool-select.ts +1 -1
- package/src/plugins/defaults/memory/v3/prune.ts +1 -1
- package/src/plugins/defaults/memory/v3/section-dense-store.ts +1 -1
- package/src/plugins/defaults/memory/v3/shadow-plugin.ts +1 -1
- package/src/plugins/defaults/memory/worker.ts +1 -1
- package/src/runtime/capabilities.ts +1 -1
- package/src/runtime/routes/__tests__/bookmark-routes.test.ts +0 -1
- package/src/runtime/routes/__tests__/conversation-management-routes.test.ts +0 -1
- package/src/runtime/routes/__tests__/conversation-query-routes.test.ts +0 -1
- package/src/runtime/routes/conversation-starter-routes.ts +12 -23
- package/src/runtime/routes/index.ts +0 -2
- package/src/runtime/services/__tests__/auto-analysis-guard.test.ts +1 -8
- package/src/runtime/services/__tests__/conversation-serializer.test.ts +0 -1
- package/src/runtime/services/auto-analysis-guard.ts +5 -5
- package/src/runtime/services/conversation-serializer.ts +2 -3
- package/src/tasks/SPEC.md +10 -17
- package/src/tools/executor.ts +1 -102
- package/src/tools/filesystem/write.ts +0 -2
- package/src/tools/tool-types.ts +0 -15
- package/src/tools/types.ts +0 -10
- package/src/workspace/migrations/028-recover-conversations-from-disk-view.ts +0 -1
- package/src/workspace/migrations/129-remove-analyze-conversation-config.ts +59 -0
- package/src/workspace/migrations/registry.ts +2 -0
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/__tests__/grants.test.ts +0 -686
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/grants.ts +0 -184
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/rendering.ts +0 -135
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/__tests__/grants.test.ts +0 -686
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/grants.ts +0 -184
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/rendering.ts +0 -135
- package/node_modules/@vellumai/service-contracts/src/__tests__/grants.test.ts +0 -686
- package/node_modules/@vellumai/service-contracts/src/grants.ts +0 -184
- package/node_modules/@vellumai/service-contracts/src/rendering.ts +0 -135
- package/src/__tests__/auto-analysis-end-to-end.test.ts +0 -621
- package/src/__tests__/auto-analysis-prompt.test.ts +0 -50
- package/src/__tests__/config-analysis.test.ts +0 -83
- package/src/__tests__/conversation-analysis-routes.test.ts +0 -156
- package/src/__tests__/credential-execution-approval-bridge.test.ts +0 -297
- package/src/config/schemas/analysis.ts +0 -32
- package/src/credential-execution/approval-bridge.ts +0 -320
- package/src/daemon/__tests__/conversation-lifecycle-auto-analyze.test.ts +0 -449
- package/src/plugins/defaults/memory/__tests__/find-analysis-conversation.test.ts +0 -197
- package/src/runtime/routes/conversation-analysis-routes.ts +0 -75
- package/src/runtime/services/__tests__/analyze-conversation.test.ts +0 -477
- package/src/runtime/services/__tests__/auto-analysis-enqueue.test.ts +0 -386
- package/src/runtime/services/__tests__/auto-analysis-prompt.test.ts +0 -53
- package/src/runtime/services/__tests__/conversation-analyze-job.test.ts +0 -213
- package/src/runtime/services/__tests__/manual-analysis-prompt.test.ts +0 -41
- package/src/runtime/services/analyze-conversation.ts +0 -334
- package/src/runtime/services/auto-analysis-enqueue.ts +0 -130
- package/src/runtime/services/auto-analysis-prompt.ts +0 -55
- package/src/runtime/services/conversation-analyze-job.ts +0 -53
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Route handler for conversation analysis.
|
|
3
|
-
*
|
|
4
|
-
* POST /v1/conversations/:id/analyze — analyze a conversation via a new
|
|
5
|
-
* agent loop that produces a structured self-assessment.
|
|
6
|
-
*
|
|
7
|
-
* The heavy lifting lives in `services/analyze-conversation.ts`. This module
|
|
8
|
-
* is thin glue: map the route params to the service, translate service
|
|
9
|
-
* errors, and build the success response.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { z } from "zod";
|
|
13
|
-
|
|
14
|
-
import { ACTOR_PRINCIPALS } from "../auth/route-policy.js";
|
|
15
|
-
import { analyzeConversation } from "../services/analyze-conversation.js";
|
|
16
|
-
import { buildConversationDetailResponse } from "../services/conversation-serializer.js";
|
|
17
|
-
import { conversationSummarySchema } from "./conversation-list-routes.js";
|
|
18
|
-
import { BadRequestError, InternalError, NotFoundError } from "./errors.js";
|
|
19
|
-
import type { RouteDefinition, RouteHandlerArgs } from "./types.js";
|
|
20
|
-
|
|
21
|
-
// ---------------------------------------------------------------------------
|
|
22
|
-
// Handler
|
|
23
|
-
// ---------------------------------------------------------------------------
|
|
24
|
-
|
|
25
|
-
async function handleAnalyzeConversation({
|
|
26
|
-
pathParams = {},
|
|
27
|
-
}: RouteHandlerArgs) {
|
|
28
|
-
const conversationId = pathParams.id;
|
|
29
|
-
if (!conversationId) {
|
|
30
|
-
throw new BadRequestError("Conversation ID is required");
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const result = await analyzeConversation(conversationId, {
|
|
34
|
-
trigger: "manual",
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
if ("error" in result) {
|
|
38
|
-
const { kind, message } = result.error;
|
|
39
|
-
if (kind === "NOT_FOUND") throw new NotFoundError(message);
|
|
40
|
-
if (kind === "BAD_REQUEST") throw new BadRequestError(message);
|
|
41
|
-
throw new InternalError(message);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const detail = buildConversationDetailResponse(result.analysisConversationId);
|
|
45
|
-
if (!detail) {
|
|
46
|
-
throw new InternalError(
|
|
47
|
-
`Analysis conversation ${result.analysisConversationId} could not be loaded`,
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
return detail;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// ---------------------------------------------------------------------------
|
|
54
|
-
// Transport-agnostic route definitions
|
|
55
|
-
// ---------------------------------------------------------------------------
|
|
56
|
-
|
|
57
|
-
export const ROUTES: RouteDefinition[] = [
|
|
58
|
-
{
|
|
59
|
-
operationId: "analyzeConversation",
|
|
60
|
-
endpoint: "conversations/:id/analyze",
|
|
61
|
-
method: "POST",
|
|
62
|
-
policy: {
|
|
63
|
-
requiredScopes: ["chat.write"],
|
|
64
|
-
allowedPrincipalTypes: ACTOR_PRINCIPALS,
|
|
65
|
-
},
|
|
66
|
-
summary: "Analyze a conversation",
|
|
67
|
-
description:
|
|
68
|
-
"Create a new conversation with a structured self-assessment of an existing conversation.",
|
|
69
|
-
tags: ["conversations"],
|
|
70
|
-
responseBody: z.object({
|
|
71
|
-
conversation: conversationSummarySchema,
|
|
72
|
-
}),
|
|
73
|
-
handler: handleAnalyzeConversation,
|
|
74
|
-
},
|
|
75
|
-
];
|
|
@@ -1,477 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Unit tests for the analyzeConversation service.
|
|
3
|
-
*
|
|
4
|
-
* The service is driven directly (no HTTP routing) so tests exercise the
|
|
5
|
-
* validation + setup logic against mocked memory/CRUD + transcript helpers.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { beforeEach, describe, expect, mock, test } from "bun:test";
|
|
9
|
-
|
|
10
|
-
mock.module("../../../util/logger.js", () => ({
|
|
11
|
-
getLogger: () =>
|
|
12
|
-
new Proxy({} as Record<string, unknown>, {
|
|
13
|
-
get: () => () => {},
|
|
14
|
-
}),
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
|
-
const mockResolveConversationId = mock((id: string) => id as string | null);
|
|
18
|
-
const mockGetConversation = mock(
|
|
19
|
-
() =>
|
|
20
|
-
({
|
|
21
|
-
id: "conv-1",
|
|
22
|
-
title: "Source",
|
|
23
|
-
conversationType: "standard",
|
|
24
|
-
}) as Record<string, unknown> | null,
|
|
25
|
-
);
|
|
26
|
-
const mockGetMessages = mock(
|
|
27
|
-
() => [{ id: "m-source" }] as Array<{ id: string }>,
|
|
28
|
-
);
|
|
29
|
-
const mockCreateConversation = mock((_opts?: Record<string, unknown>) => ({
|
|
30
|
-
id: "analysis-new",
|
|
31
|
-
}));
|
|
32
|
-
// Echo back the caller-supplied row id (the request id, under the
|
|
33
|
-
// requestId-as-row-id invariant) so tests can assert the persisted message
|
|
34
|
-
// row id matches the turn's request id. Falls back to "msg-1" when no id is
|
|
35
|
-
// passed.
|
|
36
|
-
const mockAddMessage = mock(
|
|
37
|
-
async (
|
|
38
|
-
_conversationId: string,
|
|
39
|
-
_role: string,
|
|
40
|
-
_content: string,
|
|
41
|
-
opts?: { id?: string },
|
|
42
|
-
) => ({ id: opts?.id ?? "msg-1" }),
|
|
43
|
-
);
|
|
44
|
-
const mockFindAnalysisConversationFor = mock(
|
|
45
|
-
(_parent: string) => null as { id: string } | null,
|
|
46
|
-
);
|
|
47
|
-
const mockGetConversationSource = mock((_id: string) => null as string | null);
|
|
48
|
-
|
|
49
|
-
mock.module("../../../persistence/conversation-key-store.js", () => ({
|
|
50
|
-
resolveConversationId: mockResolveConversationId,
|
|
51
|
-
}));
|
|
52
|
-
|
|
53
|
-
mock.module("../../../persistence/conversation-crud.js", () => ({
|
|
54
|
-
getConversation: mockGetConversation,
|
|
55
|
-
getMessages: mockGetMessages,
|
|
56
|
-
createConversation: mockCreateConversation,
|
|
57
|
-
addMessage: mockAddMessage,
|
|
58
|
-
findAnalysisConversationFor: mockFindAnalysisConversationFor,
|
|
59
|
-
getConversationSource: mockGetConversationSource,
|
|
60
|
-
reserveMessage: mock(async () => ({ id: "msg-reserve" })),
|
|
61
|
-
}));
|
|
62
|
-
|
|
63
|
-
mock.module("../../../export/transcript-formatter.js", () => ({
|
|
64
|
-
buildAnalysisTranscript: () => "user: hi",
|
|
65
|
-
}));
|
|
66
|
-
|
|
67
|
-
// Mock the direct imports the service now uses instead of DI deps.
|
|
68
|
-
function makeConversation() {
|
|
69
|
-
return {
|
|
70
|
-
setTrustContext: mock(() => {}),
|
|
71
|
-
ensureActorScopedHistory: mock(() => Promise.resolve()),
|
|
72
|
-
setSubagentAllowedTools: mock(() => {}),
|
|
73
|
-
updateClient: mock(() => {}),
|
|
74
|
-
processing: false,
|
|
75
|
-
isProcessing(this: { processing: boolean }) {
|
|
76
|
-
return this.processing;
|
|
77
|
-
},
|
|
78
|
-
setProcessing(this: { processing: boolean }, value: boolean) {
|
|
79
|
-
this.processing = value;
|
|
80
|
-
},
|
|
81
|
-
abortController: null as AbortController | null,
|
|
82
|
-
currentRequestId: null as string | null,
|
|
83
|
-
loadedHistoryTrustClass: undefined as string | undefined,
|
|
84
|
-
runAgentLoop: mock(() => Promise.resolve()),
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
let currentConversation = makeConversation();
|
|
89
|
-
const mockGetOrCreateConversation = mock(async () => currentConversation);
|
|
90
|
-
|
|
91
|
-
mock.module("../../../daemon/conversation-store.js", () => ({
|
|
92
|
-
getOrCreateConversation: mockGetOrCreateConversation,
|
|
93
|
-
}));
|
|
94
|
-
|
|
95
|
-
import { AssistantEventHub } from "../../assistant-event-hub.js";
|
|
96
|
-
|
|
97
|
-
const testHub = new AssistantEventHub();
|
|
98
|
-
mock.module("../../assistant-event-hub.js", () => ({
|
|
99
|
-
AssistantEventHub,
|
|
100
|
-
assistantEventHub: testHub,
|
|
101
|
-
broadcastMessage: async () => {},
|
|
102
|
-
}));
|
|
103
|
-
|
|
104
|
-
import { analyzeConversation } from "../analyze-conversation.js";
|
|
105
|
-
|
|
106
|
-
beforeEach(() => {
|
|
107
|
-
mockResolveConversationId.mockReset();
|
|
108
|
-
mockResolveConversationId.mockImplementation((id: string) => id);
|
|
109
|
-
mockGetConversation.mockReset();
|
|
110
|
-
mockGetConversation.mockImplementation(() => ({
|
|
111
|
-
id: "conv-1",
|
|
112
|
-
title: "Source",
|
|
113
|
-
conversationType: "standard",
|
|
114
|
-
}));
|
|
115
|
-
mockGetMessages.mockReset();
|
|
116
|
-
mockGetMessages.mockImplementation(() => [{ id: "m-source" }]);
|
|
117
|
-
mockCreateConversation.mockReset();
|
|
118
|
-
mockCreateConversation.mockImplementation(() => ({ id: "analysis-new" }));
|
|
119
|
-
mockAddMessage.mockReset();
|
|
120
|
-
mockAddMessage.mockImplementation(
|
|
121
|
-
async (
|
|
122
|
-
_conversationId: string,
|
|
123
|
-
_role: string,
|
|
124
|
-
_content: string,
|
|
125
|
-
opts?: { id?: string },
|
|
126
|
-
) => ({ id: opts?.id ?? "msg-1" }),
|
|
127
|
-
);
|
|
128
|
-
mockFindAnalysisConversationFor.mockReset();
|
|
129
|
-
mockFindAnalysisConversationFor.mockImplementation(() => null);
|
|
130
|
-
mockGetConversationSource.mockReset();
|
|
131
|
-
mockGetConversationSource.mockImplementation(() => null);
|
|
132
|
-
mockGetOrCreateConversation.mockReset();
|
|
133
|
-
currentConversation = makeConversation();
|
|
134
|
-
mockGetOrCreateConversation.mockImplementation(
|
|
135
|
-
async () => currentConversation,
|
|
136
|
-
);
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
describe("analyzeConversation", () => {
|
|
140
|
-
test("returns NOT_FOUND when the source ID does not resolve", async () => {
|
|
141
|
-
mockResolveConversationId.mockImplementation(() => null);
|
|
142
|
-
|
|
143
|
-
const result = await analyzeConversation("missing", {
|
|
144
|
-
trigger: "manual",
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
expect("error" in result).toBe(true);
|
|
148
|
-
if (!("error" in result)) throw new Error("expected error");
|
|
149
|
-
expect(result.error.kind).toBe("NOT_FOUND");
|
|
150
|
-
expect(result.error.status).toBe(404);
|
|
151
|
-
expect(mockGetConversation).not.toHaveBeenCalled();
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
test("returns NOT_FOUND when the conversation record is missing", async () => {
|
|
155
|
-
mockGetConversation.mockImplementation(() => null);
|
|
156
|
-
|
|
157
|
-
const result = await analyzeConversation("conv-1", {
|
|
158
|
-
trigger: "manual",
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
expect("error" in result).toBe(true);
|
|
162
|
-
if (!("error" in result)) throw new Error("expected error");
|
|
163
|
-
expect(result.error.kind).toBe("NOT_FOUND");
|
|
164
|
-
expect(result.error.status).toBe(404);
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
test("returns BAD_REQUEST when the source conversation has no messages", async () => {
|
|
168
|
-
mockGetMessages.mockImplementation(() => []);
|
|
169
|
-
|
|
170
|
-
const result = await analyzeConversation("conv-1", {
|
|
171
|
-
trigger: "manual",
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
expect("error" in result).toBe(true);
|
|
175
|
-
if (!("error" in result)) throw new Error("expected error");
|
|
176
|
-
expect(result.error.kind).toBe("BAD_REQUEST");
|
|
177
|
-
expect(result.error.status).toBe(400);
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
test("creates an analysis conversation with unknown trust, no tools, and returns the new ID", async () => {
|
|
181
|
-
const result = await analyzeConversation("conv-1", {
|
|
182
|
-
trigger: "manual",
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
expect("error" in result).toBe(false);
|
|
186
|
-
if ("error" in result) throw new Error("expected success");
|
|
187
|
-
expect(result.analysisConversationId).toBe("analysis-new");
|
|
188
|
-
|
|
189
|
-
// Persists the prompt as a user message with unknown trust, under a
|
|
190
|
-
// caller-minted row id (the turn's request id).
|
|
191
|
-
expect(mockAddMessage).toHaveBeenCalledWith(
|
|
192
|
-
"analysis-new",
|
|
193
|
-
"user",
|
|
194
|
-
expect.any(String),
|
|
195
|
-
{ id: expect.any(String), metadata: { provenanceTrustClass: "unknown" } },
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
// Sets trust context to unknown.
|
|
199
|
-
expect(currentConversation.setTrustContext).toHaveBeenCalledWith({
|
|
200
|
-
trustClass: "unknown",
|
|
201
|
-
sourceChannel: "vellum",
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
// Strips all tools.
|
|
205
|
-
expect(currentConversation.setSubagentAllowedTools).toHaveBeenCalledTimes(
|
|
206
|
-
1,
|
|
207
|
-
);
|
|
208
|
-
const allowedTools = (
|
|
209
|
-
currentConversation.setSubagentAllowedTools.mock
|
|
210
|
-
.calls as unknown as Array<[Set<string> | undefined]>
|
|
211
|
-
)[0]?.[0];
|
|
212
|
-
expect(allowedTools).toBeInstanceOf(Set);
|
|
213
|
-
expect(allowedTools?.size).toBe(0);
|
|
214
|
-
|
|
215
|
-
// requestId === userMessageId invariant: the id the prompt row was
|
|
216
|
-
// persisted under, the turn's currentRequestId, and the userMessageId
|
|
217
|
-
// handed to the agent loop are all the same value.
|
|
218
|
-
const persistedId = (
|
|
219
|
-
mockAddMessage.mock.calls as unknown as Array<
|
|
220
|
-
[string, string, string, { id?: string } | undefined]
|
|
221
|
-
>
|
|
222
|
-
)[0]?.[3]?.id;
|
|
223
|
-
expect(typeof persistedId).toBe("string");
|
|
224
|
-
expect(currentConversation.currentRequestId).toBe(persistedId ?? null);
|
|
225
|
-
|
|
226
|
-
// Fires the agent loop with the analyzeConversation call-site so the
|
|
227
|
-
// per-call provider config flows through `resolveCallSiteConfig`, keying
|
|
228
|
-
// the loop off the same id as userMessageId.
|
|
229
|
-
expect(currentConversation.runAgentLoop).toHaveBeenCalledWith(
|
|
230
|
-
expect.any(String),
|
|
231
|
-
persistedId,
|
|
232
|
-
expect.objectContaining({
|
|
233
|
-
isInteractive: false,
|
|
234
|
-
isUserMessage: true,
|
|
235
|
-
callSite: "analyzeConversation",
|
|
236
|
-
}),
|
|
237
|
-
);
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
// ── Auto trigger ──────────────────────────────────────────────────
|
|
241
|
-
|
|
242
|
-
test("auto: creates a new analysis conversation when none exists, with source=auto-analysis, dedicated groupId, and forkParentConversationId", async () => {
|
|
243
|
-
mockFindAnalysisConversationFor.mockImplementation(() => null);
|
|
244
|
-
|
|
245
|
-
const result = await analyzeConversation("conv-1", {
|
|
246
|
-
trigger: "auto",
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
expect("error" in result).toBe(false);
|
|
250
|
-
if ("error" in result) throw new Error("expected success");
|
|
251
|
-
expect(result.analysisConversationId).toBe("analysis-new");
|
|
252
|
-
|
|
253
|
-
// Verifies the rolling-analysis lookup was consulted against the source ID.
|
|
254
|
-
expect(mockFindAnalysisConversationFor).toHaveBeenCalledWith("conv-1");
|
|
255
|
-
|
|
256
|
-
expect(mockCreateConversation).toHaveBeenCalledTimes(1);
|
|
257
|
-
expect(mockCreateConversation).toHaveBeenCalledWith(
|
|
258
|
-
expect.objectContaining({
|
|
259
|
-
title: "Analysis: Source",
|
|
260
|
-
source: "auto-analysis",
|
|
261
|
-
groupId: "system:background",
|
|
262
|
-
forkParentConversationId: "conv-1",
|
|
263
|
-
}),
|
|
264
|
-
);
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
test("auto: skips the run (no agent loop, no message persisted) when the rolling analysis conversation is already processing", async () => {
|
|
268
|
-
currentConversation.processing = true;
|
|
269
|
-
|
|
270
|
-
const result = await analyzeConversation("conv-1", {
|
|
271
|
-
trigger: "auto",
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
// Returns a successful no-op result tagged with `skipped: true`.
|
|
275
|
-
expect("error" in result).toBe(false);
|
|
276
|
-
if ("error" in result) throw new Error("expected success");
|
|
277
|
-
expect(result.analysisConversationId).toBe("analysis-new");
|
|
278
|
-
expect(result.skipped).toBe(true);
|
|
279
|
-
|
|
280
|
-
// Critically, none of the mutating side effects should have run: no
|
|
281
|
-
// message persisted, no trust context overwritten, no agent loop fired.
|
|
282
|
-
expect(mockAddMessage).not.toHaveBeenCalled();
|
|
283
|
-
expect(currentConversation.setTrustContext).not.toHaveBeenCalled();
|
|
284
|
-
expect(currentConversation.runAgentLoop).not.toHaveBeenCalled();
|
|
285
|
-
expect(currentConversation.abortController).toBeNull();
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
test("manual: does NOT skip when the conversation reports processing (guard is auto-only)", async () => {
|
|
289
|
-
currentConversation.processing = true;
|
|
290
|
-
|
|
291
|
-
const result = await analyzeConversation("conv-1", {
|
|
292
|
-
trigger: "manual",
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
expect("error" in result).toBe(false);
|
|
296
|
-
if ("error" in result) throw new Error("expected success");
|
|
297
|
-
expect(result.skipped).toBeUndefined();
|
|
298
|
-
|
|
299
|
-
// Manual trigger always proceeds — it creates a fresh conversation per
|
|
300
|
-
// invocation, so there is no shared-state concurrency hazard.
|
|
301
|
-
expect(mockAddMessage).toHaveBeenCalled();
|
|
302
|
-
expect(currentConversation.runAgentLoop).toHaveBeenCalled();
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
test("auto: reuses an existing rolling analysis conversation (no new row)", async () => {
|
|
306
|
-
mockFindAnalysisConversationFor.mockImplementation(() => ({
|
|
307
|
-
id: "analysis-existing",
|
|
308
|
-
}));
|
|
309
|
-
|
|
310
|
-
const result = await analyzeConversation("conv-1", {
|
|
311
|
-
trigger: "auto",
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
expect("error" in result).toBe(false);
|
|
315
|
-
if ("error" in result) throw new Error("expected success");
|
|
316
|
-
expect(result.analysisConversationId).toBe("analysis-existing");
|
|
317
|
-
|
|
318
|
-
// No new conversation row is created on reuse.
|
|
319
|
-
expect(mockCreateConversation).not.toHaveBeenCalled();
|
|
320
|
-
|
|
321
|
-
// The new user message is appended to the existing analysis conversation,
|
|
322
|
-
// persisted under the turn's request id.
|
|
323
|
-
expect(mockAddMessage).toHaveBeenCalledWith(
|
|
324
|
-
"analysis-existing",
|
|
325
|
-
"user",
|
|
326
|
-
expect.any(String),
|
|
327
|
-
{
|
|
328
|
-
id: expect.any(String),
|
|
329
|
-
metadata: { provenanceTrustClass: "guardian" },
|
|
330
|
-
},
|
|
331
|
-
);
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
test("auto: invalidates loadedHistoryTrustClass before ensureActorScopedHistory on reuse so stale ctx.messages is reloaded", async () => {
|
|
335
|
-
// Simulate a reused rolling conversation whose prior run already cached
|
|
336
|
-
// a guardian-class history load. Without explicit invalidation,
|
|
337
|
-
// ensureActorScopedHistory would short-circuit and runAgentLoopImpl
|
|
338
|
-
// would execute against ctx.messages missing the newly-enqueued prompt.
|
|
339
|
-
mockFindAnalysisConversationFor.mockImplementation(() => ({
|
|
340
|
-
id: "analysis-existing",
|
|
341
|
-
}));
|
|
342
|
-
currentConversation.loadedHistoryTrustClass = "guardian";
|
|
343
|
-
let trustClassWhenEnsured: string | undefined = "sentinel";
|
|
344
|
-
currentConversation.ensureActorScopedHistory.mockImplementation(() => {
|
|
345
|
-
trustClassWhenEnsured = currentConversation.loadedHistoryTrustClass;
|
|
346
|
-
return Promise.resolve();
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
const result = await analyzeConversation("conv-1", {
|
|
350
|
-
trigger: "auto",
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
expect("error" in result).toBe(false);
|
|
354
|
-
// The invalidation must land before ensureActorScopedHistory runs so
|
|
355
|
-
// the reload inside it pulls the freshly-persisted user prompt.
|
|
356
|
-
expect(trustClassWhenEnsured).toBeUndefined();
|
|
357
|
-
expect(currentConversation.ensureActorScopedHistory).toHaveBeenCalledTimes(
|
|
358
|
-
1,
|
|
359
|
-
);
|
|
360
|
-
});
|
|
361
|
-
|
|
362
|
-
test("auto: sets trustClass to guardian", async () => {
|
|
363
|
-
const result = await analyzeConversation("conv-1", {
|
|
364
|
-
trigger: "auto",
|
|
365
|
-
});
|
|
366
|
-
expect("error" in result).toBe(false);
|
|
367
|
-
|
|
368
|
-
expect(currentConversation.setTrustContext).toHaveBeenCalledWith({
|
|
369
|
-
trustClass: "guardian",
|
|
370
|
-
sourceChannel: "vellum",
|
|
371
|
-
});
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
test("auto: does NOT strip the tool surface", async () => {
|
|
375
|
-
const result = await analyzeConversation("conv-1", {
|
|
376
|
-
trigger: "auto",
|
|
377
|
-
});
|
|
378
|
-
expect("error" in result).toBe(false);
|
|
379
|
-
|
|
380
|
-
// Manual mode calls this with an empty Set; auto mode must leave the
|
|
381
|
-
// conversation's default tool surface intact.
|
|
382
|
-
expect(currentConversation.setSubagentAllowedTools).not.toHaveBeenCalled();
|
|
383
|
-
});
|
|
384
|
-
|
|
385
|
-
test("auto: rejects when the source conversation is itself an auto-analysis conversation", async () => {
|
|
386
|
-
mockGetConversationSource.mockImplementation(() => "auto-analysis");
|
|
387
|
-
|
|
388
|
-
const result = await analyzeConversation("conv-1", {
|
|
389
|
-
trigger: "auto",
|
|
390
|
-
});
|
|
391
|
-
|
|
392
|
-
expect("error" in result).toBe(true);
|
|
393
|
-
if (!("error" in result)) throw new Error("expected error");
|
|
394
|
-
expect(result.error.kind).toBe("BAD_REQUEST");
|
|
395
|
-
expect(result.error.status).toBe(400);
|
|
396
|
-
|
|
397
|
-
// Nothing downstream of the guard should have fired.
|
|
398
|
-
expect(mockFindAnalysisConversationFor).not.toHaveBeenCalled();
|
|
399
|
-
expect(mockCreateConversation).not.toHaveBeenCalled();
|
|
400
|
-
expect(mockAddMessage).not.toHaveBeenCalled();
|
|
401
|
-
});
|
|
402
|
-
|
|
403
|
-
test.each(["memory-retrospective", "memory-retrospective-fork"])(
|
|
404
|
-
"auto: rejects when the source conversation is a %s conversation",
|
|
405
|
-
async (source) => {
|
|
406
|
-
// Fork-kind retrospective conversations carry a full copy of the
|
|
407
|
-
// source conversation's history; auto-analyzing one would re-process
|
|
408
|
-
// the entire source conversation and double-write memory.
|
|
409
|
-
mockGetConversationSource.mockImplementation(() => source);
|
|
410
|
-
|
|
411
|
-
const result = await analyzeConversation("conv-1", {
|
|
412
|
-
trigger: "auto",
|
|
413
|
-
});
|
|
414
|
-
|
|
415
|
-
expect("error" in result).toBe(true);
|
|
416
|
-
if (!("error" in result)) throw new Error("expected error");
|
|
417
|
-
expect(result.error.kind).toBe("BAD_REQUEST");
|
|
418
|
-
expect(result.error.status).toBe(400);
|
|
419
|
-
|
|
420
|
-
// Nothing downstream of the guard should have fired.
|
|
421
|
-
expect(mockFindAnalysisConversationFor).not.toHaveBeenCalled();
|
|
422
|
-
expect(mockCreateConversation).not.toHaveBeenCalled();
|
|
423
|
-
expect(mockAddMessage).not.toHaveBeenCalled();
|
|
424
|
-
},
|
|
425
|
-
);
|
|
426
|
-
|
|
427
|
-
test("manual: does NOT reject a memory-retrospective conversation (guard is auto-only)", async () => {
|
|
428
|
-
mockGetConversationSource.mockImplementation(
|
|
429
|
-
() => "memory-retrospective-fork",
|
|
430
|
-
);
|
|
431
|
-
|
|
432
|
-
const result = await analyzeConversation("conv-1", {
|
|
433
|
-
trigger: "manual",
|
|
434
|
-
});
|
|
435
|
-
|
|
436
|
-
expect("error" in result).toBe(false);
|
|
437
|
-
if ("error" in result) throw new Error("expected success");
|
|
438
|
-
expect(result.analysisConversationId).toBe("analysis-new");
|
|
439
|
-
});
|
|
440
|
-
|
|
441
|
-
test("auto: routes the agent loop through callSite: 'analyzeConversation'", async () => {
|
|
442
|
-
await analyzeConversation("conv-1", { trigger: "auto" });
|
|
443
|
-
|
|
444
|
-
// Same requestId === userMessageId invariant on the auto path: the row
|
|
445
|
-
// id the prompt was persisted under, currentRequestId, and the loop's
|
|
446
|
-
// userMessageId are the same value.
|
|
447
|
-
const persistedId = (
|
|
448
|
-
mockAddMessage.mock.calls as unknown as Array<
|
|
449
|
-
[string, string, string, { id?: string } | undefined]
|
|
450
|
-
>
|
|
451
|
-
)[0]?.[3]?.id;
|
|
452
|
-
expect(typeof persistedId).toBe("string");
|
|
453
|
-
expect(currentConversation.currentRequestId).toBe(persistedId ?? null);
|
|
454
|
-
expect(currentConversation.runAgentLoop).toHaveBeenCalledWith(
|
|
455
|
-
expect.any(String),
|
|
456
|
-
persistedId,
|
|
457
|
-
expect.objectContaining({ callSite: "analyzeConversation" }),
|
|
458
|
-
);
|
|
459
|
-
});
|
|
460
|
-
|
|
461
|
-
test("does not thread modelIntent/modelOverride into getOrCreateConversation", async () => {
|
|
462
|
-
// Per-call model selection now happens via the call-site resolver against
|
|
463
|
-
// `llm.callSites.analyzeConversation`, not via legacy modelIntent/
|
|
464
|
-
// modelOverride keys on the conversation create options.
|
|
465
|
-
await analyzeConversation("conv-1", { trigger: "auto" });
|
|
466
|
-
|
|
467
|
-
const calls = mockGetOrCreateConversation.mock.calls as unknown as Array<
|
|
468
|
-
[string, Record<string, unknown> | undefined]
|
|
469
|
-
>;
|
|
470
|
-
expect(calls.length).toBe(1);
|
|
471
|
-
const passedOpts = calls[0]?.[1];
|
|
472
|
-
if (passedOpts !== undefined) {
|
|
473
|
-
expect("modelIntent" in passedOpts).toBe(false);
|
|
474
|
-
expect("modelOverride" in passedOpts).toBe(false);
|
|
475
|
-
}
|
|
476
|
-
});
|
|
477
|
-
});
|