@vellumai/assistant 0.12.4 → 0.12.5-dev.202609251017.e467a6c
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/docs/architecture/memory.md +9 -1
- package/docs/architecture/scheduling.md +13 -5
- package/docs/desktop-browser-cli.md +3 -2
- package/docs/guardian-request-flow.md +1 -1
- package/node_modules/@vellumai/avatar-manifest/src/__tests__/notification-avatar.test.ts +48 -4
- package/node_modules/@vellumai/avatar-manifest/src/notification-avatar.ts +12 -8
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/__tests__/guardian-requests.test.ts +26 -0
- package/node_modules/@vellumai/ces-client/node_modules/@vellumai/service-contracts/src/guardian-requests.ts +77 -3
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/__tests__/guardian-requests.test.ts +26 -0
- package/node_modules/@vellumai/gateway-client/node_modules/@vellumai/service-contracts/src/guardian-requests.ts +77 -3
- package/node_modules/@vellumai/gateway-client/src/outbound-contract.ts +2 -4
- package/node_modules/@vellumai/service-contracts/src/__tests__/guardian-requests.test.ts +26 -0
- package/node_modules/@vellumai/service-contracts/src/guardian-requests.ts +77 -3
- package/openapi.yaml +152 -3
- package/package.json +1 -1
- package/src/__tests__/agent-loop.test.ts +76 -0
- package/src/__tests__/anthropic-error-formatting.test.ts +9 -0
- package/src/__tests__/background-shell-bash.test.ts +34 -0
- package/src/__tests__/background-shell-host-bash.test.ts +98 -1
- package/src/__tests__/background-tool-registry.test.ts +39 -0
- package/src/__tests__/channel-readiness-discord.test.ts +8 -0
- package/src/__tests__/channel-readiness-slack-remote.test.ts +8 -0
- package/src/__tests__/client-os-metadata-persistence.test.ts +4 -20
- package/src/__tests__/conversation-agent-loop.test.ts +529 -1
- package/src/__tests__/conversation-error.test.ts +18 -0
- package/src/__tests__/conversation-pairing.test.ts +69 -0
- package/src/__tests__/conversation-queue.test.ts +257 -4
- package/src/__tests__/conversation-runtime-assembly.test.ts +27 -0
- package/src/__tests__/emit-signal-routing-intent.test.ts +62 -0
- package/src/__tests__/evict-conversations-for-reload.test.ts +21 -0
- package/src/__tests__/gemini-provider.test.ts +9 -0
- package/src/__tests__/host-cu-proxy.test.ts +79 -0
- package/src/__tests__/host-cu-routes-targeted.test.ts +14 -5
- package/src/__tests__/introduction-card-resolver.test.ts +53 -8
- package/src/__tests__/job-handler-registration-guard.test.ts +1 -0
- package/src/__tests__/non-member-access-request.test.ts +48 -0
- package/src/__tests__/notification-events-source-context-probe.test.ts +48 -1
- package/src/__tests__/notification-platform-adapter.test.ts +97 -0
- package/src/__tests__/notification-vellum-adapter.test.ts +103 -3
- package/src/__tests__/platform-callback-registration.test.ts +46 -1
- package/src/__tests__/plugin-import-boundary-guard.test.ts +3 -0
- package/src/__tests__/scaffold-managed-skill-tool.test.ts +116 -66
- package/src/__tests__/scheduler-disk-pressure.test.ts +1 -0
- package/src/__tests__/scheduler-result-notification.test.ts +521 -7
- package/src/__tests__/scheduler-wake.test.ts +1 -0
- package/src/__tests__/skill-load-inline-command.test.ts +35 -0
- package/src/__tests__/subagent-cron-run-attribution.test.ts +41 -2
- package/src/__tests__/subagent-manager-notify.test.ts +48 -0
- package/src/__tests__/trusted-contact-inline-approval-integration.test.ts +6 -6
- package/src/__tests__/usage-attribution.test.ts +31 -0
- package/src/__tests__/wake-schedule-escalation.test.ts +1 -0
- package/src/agent/loop.ts +23 -0
- package/src/api/ask-question-tool.ts +50 -0
- package/src/api/events/generation-handoff.ts +4 -0
- package/src/api/events/message-complete.ts +4 -0
- package/src/api/events/tool-result.ts +11 -0
- package/src/api/index.ts +11 -0
- package/src/api/requests/guardian-actions.test.ts +45 -0
- package/src/api/requests/guardian-actions.ts +20 -0
- package/src/api/responses/conversation-message.ts +4 -0
- package/src/api/responses/home.ts +27 -0
- package/src/approvals/guardian-decision-primitive.ts +6 -4
- package/src/approvals/guardian-request-resolvers.ts +35 -30
- package/src/avatar/notification-avatar.test.ts +42 -34
- package/src/avatar/notification-avatar.ts +1 -0
- package/src/calls/__tests__/call-controller.test.ts +18 -0
- package/src/calls/__tests__/voice-control-protocol.test.ts +6 -1
- package/src/calls/__tests__/voice-leg-coordinator.test.ts +70 -0
- package/src/calls/__tests__/voice-session-bridge.test.ts +116 -4
- package/src/calls/__tests__/voice-triage-escalate.test.ts +77 -11
- package/src/calls/call-controller.ts +3 -1
- package/src/calls/voice-control-protocol.ts +12 -4
- package/src/calls/voice-escalation-judge.ts +2 -2
- package/src/calls/voice-leg-coordinator.ts +23 -5
- package/src/calls/voice-screen-annotation.ts +44 -0
- package/src/calls/voice-session-bridge.ts +63 -20
- package/src/calls/voice-triage-escalate.ts +82 -27
- package/src/cli/commands/__tests__/conversations-clear.test.ts +156 -0
- package/src/cli/commands/conversations.help.ts +7 -2
- package/src/cli/commands/conversations.ts +36 -30
- package/src/cli/commands/oauth/index.help.ts +8 -2
- package/src/cli/commands/oauth/request.test.ts +32 -0
- package/src/cli/commands/platform/index.help.ts +2 -1
- package/src/cli/commands/platform/index.ts +8 -2
- package/src/cli/lib/__tests__/plugin-catalog-cache.test.ts +60 -0
- package/src/cli/lib/__tests__/plugin-catalog-platform.test.ts +66 -2
- package/src/cli/lib/bundled-marketplace.json +35 -0
- package/src/cli/lib/bundled-plugin-packages.json +21 -0
- package/src/cli/lib/plugin-catalog-cache.ts +17 -2
- package/src/cli/lib/plugin-catalog-platform.ts +48 -9
- package/src/config/__tests__/default-profile-catalog.test.ts +28 -0
- package/src/config/__tests__/platform-identity.test.ts +59 -0
- package/src/config/__tests__/profile-order.test.ts +19 -0
- package/src/config/__tests__/sync-gated-profiles.test.ts +71 -0
- package/src/config/bundled-skills/computer-use/SKILL.md +20 -0
- package/src/config/bundled-skills/computer-use/TOOLS.json +11 -11
- package/src/config/bundled-skills/screen-annotation/SKILL.md +41 -29
- package/src/config/bundled-skills/screen-annotation/TOOLS.json +5 -5
- package/src/config/call-site-defaults.ts +6 -0
- package/src/config/default-profile-catalog.ts +30 -1
- package/src/config/default-profile-names.ts +36 -2
- package/src/config/feature-flag-registry.json +9 -1
- package/src/config/platform-identity.ts +22 -5
- package/src/config/profile-order.ts +7 -1
- package/src/config/schemas/call-site-catalog.ts +7 -0
- package/src/config/schemas/llm.ts +21 -5
- package/src/config/sync-gated-profiles.ts +96 -44
- package/src/daemon/__tests__/abort-null-controller.test.ts +135 -1
- package/src/daemon/__tests__/auto-profile-router.test.ts +380 -0
- package/src/daemon/__tests__/turn-tail-assistant-reply-notify.test.ts +16 -0
- package/src/daemon/activity-trail.test.ts +206 -0
- package/src/daemon/activity-trail.ts +190 -0
- package/src/daemon/auto-profile-router.ts +431 -0
- package/src/daemon/computer-use-observation.test.ts +81 -0
- package/src/daemon/computer-use-observation.ts +23 -0
- package/src/daemon/conversation-agent-loop-handlers.ts +11 -0
- package/src/daemon/conversation-agent-loop.ts +157 -32
- package/src/daemon/conversation-error.ts +19 -0
- package/src/daemon/conversation-lifecycle.ts +70 -7
- package/src/daemon/conversation-media-retry.ts +1 -2
- package/src/daemon/conversation-messaging.ts +31 -2
- package/src/daemon/conversation-process.ts +107 -16
- package/src/daemon/conversation-queue-manager.ts +7 -0
- package/src/daemon/conversation-runtime-assembly.ts +1 -0
- package/src/daemon/conversation-turn-finalize.ts +14 -0
- package/src/daemon/conversation.ts +25 -6
- package/src/daemon/event-loop-watchdog.test.ts +201 -2
- package/src/daemon/event-loop-watchdog.ts +182 -6
- package/src/daemon/host-cu-proxy.ts +34 -3
- package/src/daemon/pkb-reminder-builder.test.ts +10 -3
- package/src/daemon/pkb-reminder-builder.ts +1 -1
- package/src/daemon/wake-conversation-ops.ts +4 -2
- package/src/desktop/desktop-computer-use.test.ts +14 -4
- package/src/home/feed-types.ts +2 -0
- package/src/inbound/platform-callback-registration.ts +19 -6
- package/src/live-voice/__tests__/live-voice-agent-turn.test.ts +27 -0
- package/src/live-voice/__tests__/live-voice-flux-turn-end.test.ts +83 -0
- package/src/live-voice/__tests__/live-voice-triage-escalate.test.ts +48 -1
- package/src/live-voice/__tests__/live-voice-vad.test.ts +34 -2
- package/src/live-voice/__tests__/protocol.test.ts +22 -0
- package/src/live-voice/continuation-judge.ts +1 -1
- package/src/live-voice/live-voice-session.ts +25 -19
- package/src/live-voice/protocol.ts +16 -5
- package/src/messaging/providers/discord/withdraw.ts +4 -5
- package/src/messaging/providers/gmail/client.ts +4 -0
- package/src/messaging/providers/slack/withdraw.ts +5 -5
- package/src/messaging/providers/telegram-bot/withdraw.ts +4 -5
- package/src/monitoring/__tests__/proc-fixtures.ts +28 -0
- package/src/monitoring/__tests__/proc-wait-state.test.ts +232 -0
- package/src/monitoring/__tests__/process-usage.test.ts +243 -0
- package/src/monitoring/proc-wait-state.ts +366 -0
- package/src/monitoring/process-memory.ts +4 -3
- package/src/monitoring/process-usage.ts +215 -0
- package/src/monitoring/resource-sample-types.ts +8 -0
- package/src/monitoring/resource-sampler.ts +17 -2
- package/src/monitoring/stall-capture.ts +12 -0
- package/src/notifications/README.md +88 -9
- package/src/notifications/__tests__/assistant-reply-producer.test.ts +390 -119
- package/src/notifications/__tests__/background-result-producer.test.ts +1272 -0
- package/src/notifications/__tests__/broadcaster.test.ts +292 -1
- package/src/notifications/__tests__/completion-policy.test.ts +243 -0
- package/src/notifications/__tests__/decision-engine.test.ts +51 -4
- package/src/notifications/__tests__/has-pending-background-work.test.ts +281 -0
- package/src/notifications/__tests__/home-feed-side-effect.test.ts +161 -3
- package/src/notifications/__tests__/resolve-visible-in-source.test.ts +110 -1
- package/src/notifications/__tests__/schedule-result-producer.test.ts +11 -4
- package/src/notifications/adapters/macos.ts +24 -12
- package/src/notifications/adapters/platform.ts +16 -5
- package/src/notifications/assistant-reply-producer.ts +96 -71
- package/src/notifications/background-result-producer.ts +369 -0
- package/src/notifications/broadcaster.ts +28 -8
- package/src/notifications/completion-policy.ts +115 -0
- package/src/notifications/completion-work.ts +46 -0
- package/src/notifications/conversation-pairing.ts +32 -13
- package/src/notifications/decision-engine.ts +18 -24
- package/src/notifications/emit-signal.ts +16 -1
- package/src/notifications/events-store.ts +4 -0
- package/src/notifications/has-pending-background-work.ts +91 -0
- package/src/notifications/home-feed-mirror.ts +44 -0
- package/src/notifications/home-feed-side-effect.ts +54 -28
- package/src/notifications/resolve-visible-in-source.ts +56 -2
- package/src/notifications/result-output.ts +154 -0
- package/src/notifications/schedule-result-producer.ts +6 -187
- package/src/notifications/types.ts +2 -0
- package/src/oauth/AGENTS.md +9 -1
- package/src/oauth/byo-connection.test.ts +28 -0
- package/src/persistence/__tests__/recent-conversation-messages.test.ts +41 -0
- package/src/persistence/conversation-crud.ts +26 -0
- package/src/persistence/conversation-types.ts +15 -37
- package/src/persistence/embeddings/__tests__/embedding-local-lifecycle.test.ts +85 -14
- package/src/persistence/jobs-store.ts +229 -0
- package/src/persistence/migrations/383-normalize-opencode-host-connections.ts +44 -0
- package/src/persistence/migrations/__tests__/383-normalize-opencode-host-connections.test.ts +102 -0
- package/src/persistence/steps.ts +12 -0
- package/src/platform/sync-avatar.test.ts +29 -0
- package/src/plugins/defaults/memory/AGENTS.md +5 -3
- package/src/plugins/defaults/memory/__tests__/skill-update-receipt-boundary-guard.test.ts +45 -0
- package/src/plugins/defaults/memory/__tests__/skill-update-receipt-job.test.ts +580 -0
- package/src/plugins/defaults/memory/__tests__/turn-retrieval.test.ts +21 -0
- package/src/plugins/defaults/memory/graph/tools.ts +9 -5
- package/src/plugins/defaults/memory/hooks/conversation-deleted.ts +4 -0
- package/src/plugins/defaults/memory/hooks/user-prompt-submit.ts +7 -3
- package/src/plugins/defaults/memory/job-handlers.ts +8 -2
- package/src/plugins/defaults/memory/skill-update-receipt-job.ts +334 -0
- package/src/plugins/defaults/memory/tools.test.ts +17 -0
- package/src/plugins/defaults/memory/turn-retrieval.ts +8 -0
- package/src/plugins/defaults/memory/v3/__tests__/injection.test.ts +24 -0
- package/src/plugins/defaults/memory/v3/injector.ts +4 -4
- package/src/plugins/types.ts +2 -0
- package/src/providers/__tests__/search-provider-catalog.test.ts +8 -0
- package/src/providers/anthropic/client.ts +4 -0
- package/src/providers/gemini/client.ts +7 -1
- package/src/providers/inference/auth.ts +25 -0
- package/src/providers/inference/profile-probe.ts +1 -0
- package/src/{calls/__tests__/typesafe-noul.test.ts → providers/jev/ask.test.ts} +4 -4
- package/src/{calls/typesafe-noul.ts → providers/jev/ask.ts} +67 -34
- package/src/providers/openai/__tests__/api-error-normalization.test.ts +12 -0
- package/src/providers/openai/api-error-normalization.ts +4 -0
- package/src/providers/retry.ts +2 -0
- package/src/providers/search-provider-catalog.ts +10 -0
- package/src/providers/types.ts +7 -0
- package/src/providers/usage-tracking.ts +5 -3
- package/src/runtime/__tests__/agent-wake.test.ts +308 -0
- package/src/runtime/access-request-helper.ts +16 -9
- package/src/runtime/agent-wake-queue.ts +52 -0
- package/src/runtime/agent-wake.ts +111 -18
- package/src/runtime/channel-approval-types.ts +6 -38
- package/src/runtime/channel-approvals.ts +4 -5
- package/src/runtime/http-server.ts +4 -1
- package/src/runtime/introduction-policy.test.ts +17 -1
- package/src/runtime/introduction-policy.ts +25 -7
- package/src/runtime/migrations/vbundle-builder.ts +9 -0
- package/src/runtime/routes/__tests__/inference-profiles-routes.test.ts +21 -1
- package/src/runtime/routes/__tests__/inference-provider-connection-routes.test.ts +60 -0
- package/src/runtime/routes/__tests__/oauth-proxy-routes.test.ts +61 -3
- package/src/runtime/routes/auto-profile-routes.ts +83 -0
- package/src/runtime/routes/conversation-management-routes.ts +1 -3
- package/src/runtime/routes/conversation-routes.ts +9 -0
- package/src/runtime/routes/guardian-action-routes.ts +8 -23
- package/src/runtime/routes/host-cu-routes.ts +3 -1
- package/src/runtime/routes/index.ts +2 -0
- package/src/runtime/routes/inference-profiles-routes.ts +5 -2
- package/src/runtime/routes/inference-provider-connection-routes.ts +25 -8
- package/src/runtime/routes/migration-routes.ts +8 -2
- package/src/runtime/routes/oauth-proxy-passthrough.test.ts +32 -0
- package/src/runtime/routes/platform-routes.ts +6 -1
- package/src/runtime/routes/user-route-dispatcher.ts +1 -2
- package/src/runtime/web-presence.ts +3 -4
- package/src/schedule/schedule-store.ts +10 -0
- package/src/schedule/scheduler.ts +92 -24
- package/src/subagent/manager.ts +32 -12
- package/src/telegram/__tests__/webhook-health.test.ts +8 -0
- package/src/telemetry/telemetry-wire-source.json +1 -1
- package/src/telemetry/telemetry-wire.generated.ts +1 -0
- package/src/tools/background-tool-registry.ts +30 -3
- package/src/tools/browser/cdp-client/local-cdp-client.ts +1 -2
- package/src/tools/host-terminal/host-shell.ts +7 -0
- package/src/tools/network/__tests__/web-fetch-firecrawl.test.ts +28 -1
- package/src/tools/network/__tests__/web-fetch-metadata.test.ts +34 -0
- package/src/tools/network/__tests__/web-fetch-tinyfish.test.ts +35 -1
- package/src/tools/network/__tests__/web-search.test.ts +96 -0
- package/src/tools/network/web-fetch.ts +30 -9
- package/src/tools/network/web-search.ts +235 -4
- package/src/tools/skills/load.ts +13 -17
- package/src/tools/skills/scaffold-managed.ts +86 -71
- package/src/tools/terminal/shell-launch.test.ts +27 -1
- package/src/tools/terminal/shell.ts +4 -0
- package/src/tools/workspace-tools/loader.ts +1 -2
- package/src/usage/attribution.ts +18 -1
- package/src/util/abort-reasons.ts +2 -0
- package/src/util/errors.ts +1 -0
- package/src/util/oauth-request-body.test.ts +5 -1
- package/src/util/provider-error-patterns.ts +11 -0
- package/src/util/single-flight.test.ts +6 -0
- package/src/util/single-flight.ts +2 -0
- package/src/util/worker-pipe.test.ts +56 -10
- package/src/util/worker-pipe.ts +9 -4
- package/src/workspace/git-service.ts +6 -1
- package/src/workspace/migrations/158-repoint-opencode-host-provider-fragments.ts +163 -0
- package/src/workspace/migrations/__tests__/158-repoint-opencode-host-provider-fragments.test.ts +188 -0
- package/src/workspace/migrations/registry.ts +2 -0
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
|
|
3
|
+
import type { ProfileEntry } from "../../config/schemas/llm.js";
|
|
4
|
+
import type {
|
|
5
|
+
Message,
|
|
6
|
+
Provider,
|
|
7
|
+
ProviderResponse,
|
|
8
|
+
SendMessageOptions,
|
|
9
|
+
} from "../../providers/types.js";
|
|
10
|
+
import {
|
|
11
|
+
AUTO_PROFILE_FALLBACK,
|
|
12
|
+
AUTO_PROFILE_PREVIEW_REUSE_MS,
|
|
13
|
+
autoProfileCandidates,
|
|
14
|
+
autoProfileFallback,
|
|
15
|
+
autoProfilePreviewContext,
|
|
16
|
+
type AutoProfileRoute,
|
|
17
|
+
clearAutoProfilePreviewsForTesting,
|
|
18
|
+
recentConversationForRouter,
|
|
19
|
+
rememberAutoProfilePreview,
|
|
20
|
+
routeAutoProfile,
|
|
21
|
+
takeAutoProfilePreview,
|
|
22
|
+
} from "../auto-profile-router.js";
|
|
23
|
+
|
|
24
|
+
function text(role: "user" | "assistant", body: string): Message {
|
|
25
|
+
return { role, content: [{ type: "text", text: body }] };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function jevResponse(answers: Record<string, unknown>): ProviderResponse {
|
|
29
|
+
return {
|
|
30
|
+
content: [{ type: "text", text: JSON.stringify(answers) }],
|
|
31
|
+
model: "jev-latest",
|
|
32
|
+
usage: { inputTokens: 1, outputTokens: 1 },
|
|
33
|
+
stopReason: "end_turn",
|
|
34
|
+
rawResponse: { model: "jev-latest", answers },
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function fakeProvider(
|
|
39
|
+
respond: (
|
|
40
|
+
messages: Message[],
|
|
41
|
+
options?: SendMessageOptions,
|
|
42
|
+
) => Promise<ProviderResponse>,
|
|
43
|
+
): Provider {
|
|
44
|
+
return { name: "typesafe", sendMessage: respond } as Provider;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const managed = (label: string, status?: "disabled"): ProfileEntry => ({
|
|
48
|
+
source: "managed",
|
|
49
|
+
provider: "vellum",
|
|
50
|
+
model: "m",
|
|
51
|
+
label,
|
|
52
|
+
...(status ? { status } : {}),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const profiles: Record<string, ProfileEntry> = {
|
|
56
|
+
auto: managed("Auto"),
|
|
57
|
+
balanced: managed("Balanced"),
|
|
58
|
+
"quality-optimized": managed("Quality"),
|
|
59
|
+
"cost-optimized": managed("Budget"),
|
|
60
|
+
"latency-optimized": managed("Fast"),
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const contextFor = (
|
|
64
|
+
history: readonly Message[],
|
|
65
|
+
userMessage: string,
|
|
66
|
+
candidatesFrom: Record<string, ProfileEntry>,
|
|
67
|
+
) =>
|
|
68
|
+
autoProfilePreviewContext(
|
|
69
|
+
history,
|
|
70
|
+
userMessage,
|
|
71
|
+
autoProfileCandidates(candidatesFrom),
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const base = {
|
|
75
|
+
conversationId: "conv-1",
|
|
76
|
+
history: [text("user", "hi"), text("assistant", "hello")],
|
|
77
|
+
userMessage: "Refactor the auth module and fix the race in token refresh",
|
|
78
|
+
profiles,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
describe("autoProfileCandidates", () => {
|
|
82
|
+
test("offers the default profiles that exist and are not disabled", () => {
|
|
83
|
+
expect(
|
|
84
|
+
autoProfileCandidates({
|
|
85
|
+
...profiles,
|
|
86
|
+
"cost-optimized": managed("Budget", "disabled"),
|
|
87
|
+
}),
|
|
88
|
+
).toEqual(["balanced", "quality-optimized", "latency-optimized"]);
|
|
89
|
+
expect(autoProfileCandidates({ balanced: managed("Balanced") })).toEqual([
|
|
90
|
+
"balanced",
|
|
91
|
+
]);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
describe("recentConversationForRouter", () => {
|
|
96
|
+
test("drops injected blocks and the current message, keeps roles", () => {
|
|
97
|
+
const history: Message[] = [
|
|
98
|
+
text("user", "hey"),
|
|
99
|
+
{ role: "user", content: [{ type: "text", text: "<memory>x</memory>" }] },
|
|
100
|
+
text("assistant", "Hi there"),
|
|
101
|
+
text("user", "do it"),
|
|
102
|
+
];
|
|
103
|
+
expect(recentConversationForRouter(history, "do it")).toBe(
|
|
104
|
+
"user: hey\nassistant: Hi there",
|
|
105
|
+
);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
describe("routeAutoProfile", () => {
|
|
110
|
+
test("pins the turn to Jev's choice and sends the candidates as criteria", async () => {
|
|
111
|
+
let sent: unknown;
|
|
112
|
+
const route = await routeAutoProfile({
|
|
113
|
+
...base,
|
|
114
|
+
resolveProvider: async () =>
|
|
115
|
+
fakeProvider(async (messages) => {
|
|
116
|
+
const block = messages[0]?.content[0];
|
|
117
|
+
sent = JSON.parse(block?.type === "text" ? block.text : "{}");
|
|
118
|
+
return jevResponse({
|
|
119
|
+
profile: {
|
|
120
|
+
type: "choice",
|
|
121
|
+
choice: "quality-optimized",
|
|
122
|
+
confidence: 0.8,
|
|
123
|
+
probabilities: { "quality-optimized": 0.85, balanced: 0.15 },
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
}),
|
|
127
|
+
});
|
|
128
|
+
expect(route).toMatchObject({
|
|
129
|
+
profile: "quality-optimized",
|
|
130
|
+
outcome: "routed",
|
|
131
|
+
confidence: 0.8,
|
|
132
|
+
});
|
|
133
|
+
const request = sent as {
|
|
134
|
+
state: Record<string, string>;
|
|
135
|
+
questions: {
|
|
136
|
+
profile: { type: string; criteria: Record<string, string> };
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
expect(request.state.latest_user_message).toBe(base.userMessage);
|
|
140
|
+
expect(request.state.recent_conversation).toBe(
|
|
141
|
+
"user: hi\nassistant: hello",
|
|
142
|
+
);
|
|
143
|
+
expect(request.questions.profile.type).toBe("choice");
|
|
144
|
+
expect(Object.keys(request.questions.profile.criteria)).toEqual([
|
|
145
|
+
"balanced",
|
|
146
|
+
"quality-optimized",
|
|
147
|
+
"cost-optimized",
|
|
148
|
+
"latency-optimized",
|
|
149
|
+
]);
|
|
150
|
+
expect(
|
|
151
|
+
request.questions.profile.criteria.balanced.startsWith("Balanced: "),
|
|
152
|
+
).toBe(true);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
test("falls back to Balanced when the choice names no candidate", async () => {
|
|
156
|
+
const route = await routeAutoProfile({
|
|
157
|
+
...base,
|
|
158
|
+
resolveProvider: async () =>
|
|
159
|
+
fakeProvider(async () =>
|
|
160
|
+
jevResponse({ profile: { type: "choice", choice: "auto" } }),
|
|
161
|
+
),
|
|
162
|
+
});
|
|
163
|
+
expect(route).toMatchObject({
|
|
164
|
+
profile: AUTO_PROFILE_FALLBACK,
|
|
165
|
+
outcome: "error",
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test("falls back to Balanced when no TypeSafe route resolves", async () => {
|
|
170
|
+
const route = await routeAutoProfile({
|
|
171
|
+
...base,
|
|
172
|
+
resolveProvider: async () => null,
|
|
173
|
+
});
|
|
174
|
+
expect(route).toEqual({
|
|
175
|
+
profile: AUTO_PROFILE_FALLBACK,
|
|
176
|
+
outcome: "unavailable",
|
|
177
|
+
latencyMs: expect.any(Number),
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
test("falls back to Balanced on timeout", async () => {
|
|
182
|
+
const route = await routeAutoProfile({
|
|
183
|
+
...base,
|
|
184
|
+
timeoutMs: 5,
|
|
185
|
+
resolveProvider: async () =>
|
|
186
|
+
fakeProvider(
|
|
187
|
+
(_messages, options) =>
|
|
188
|
+
new Promise((_resolve, reject) => {
|
|
189
|
+
options?.signal?.addEventListener("abort", () =>
|
|
190
|
+
reject(new Error("aborted")),
|
|
191
|
+
);
|
|
192
|
+
}),
|
|
193
|
+
),
|
|
194
|
+
});
|
|
195
|
+
expect(route.profile).toBe(AUTO_PROFILE_FALLBACK);
|
|
196
|
+
expect(route.outcome).toBe("timeout");
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
test("does not ask when fewer than two candidates remain", async () => {
|
|
200
|
+
let asked = false;
|
|
201
|
+
const route = await routeAutoProfile({
|
|
202
|
+
...base,
|
|
203
|
+
profiles: { auto: managed("Auto"), balanced: managed("Balanced") },
|
|
204
|
+
resolveProvider: async () => {
|
|
205
|
+
asked = true;
|
|
206
|
+
return null;
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
expect(asked).toBe(false);
|
|
210
|
+
expect(route).toEqual({
|
|
211
|
+
profile: AUTO_PROFILE_FALLBACK,
|
|
212
|
+
outcome: "fallback",
|
|
213
|
+
latencyMs: 0,
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
test("falls back to an enabled candidate when Balanced is disabled", async () => {
|
|
218
|
+
const withoutBalanced = {
|
|
219
|
+
...profiles,
|
|
220
|
+
balanced: managed("Balanced", "disabled"),
|
|
221
|
+
};
|
|
222
|
+
expect(autoProfileFallback(autoProfileCandidates(withoutBalanced))).toBe(
|
|
223
|
+
"quality-optimized",
|
|
224
|
+
);
|
|
225
|
+
const unavailable = await routeAutoProfile({
|
|
226
|
+
...base,
|
|
227
|
+
profiles: withoutBalanced,
|
|
228
|
+
resolveProvider: async () => null,
|
|
229
|
+
});
|
|
230
|
+
expect(unavailable.profile).toBe("quality-optimized");
|
|
231
|
+
const single = await routeAutoProfile({
|
|
232
|
+
...base,
|
|
233
|
+
profiles: {
|
|
234
|
+
auto: managed("Auto"),
|
|
235
|
+
balanced: managed("Balanced", "disabled"),
|
|
236
|
+
"cost-optimized": managed("Budget"),
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
expect(single).toMatchObject({
|
|
240
|
+
profile: "cost-optimized",
|
|
241
|
+
outcome: "fallback",
|
|
242
|
+
});
|
|
243
|
+
expect(autoProfileFallback([])).toBe(AUTO_PROFILE_FALLBACK);
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
describe("draft preview reuse", () => {
|
|
248
|
+
const routed: AutoProfileRoute = {
|
|
249
|
+
profile: "quality-optimized",
|
|
250
|
+
outcome: "routed",
|
|
251
|
+
confidence: 0.9,
|
|
252
|
+
latencyMs: 120,
|
|
253
|
+
};
|
|
254
|
+
const history = [text("user", "hi"), text("assistant", "hello")];
|
|
255
|
+
const context = (h: Message[] = history) =>
|
|
256
|
+
contextFor(h, "Refactor the auth module", profiles);
|
|
257
|
+
const take = (
|
|
258
|
+
overrides: Partial<Parameters<typeof takeAutoProfilePreview>[0]> = {},
|
|
259
|
+
) =>
|
|
260
|
+
takeAutoProfilePreview({
|
|
261
|
+
conversationId: "conv-1",
|
|
262
|
+
text: "Refactor the auth module",
|
|
263
|
+
history,
|
|
264
|
+
profiles,
|
|
265
|
+
...overrides,
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
test("a routed preview is reused once by the turn that sends the same text", () => {
|
|
269
|
+
clearAutoProfilePreviewsForTesting();
|
|
270
|
+
rememberAutoProfilePreview(
|
|
271
|
+
"conv-1",
|
|
272
|
+
"Refactor the auth\nmodule",
|
|
273
|
+
routed,
|
|
274
|
+
context(),
|
|
275
|
+
);
|
|
276
|
+
expect(take()).toEqual(routed);
|
|
277
|
+
expect(take()).toBeUndefined();
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
test("a different draft, another conversation, or an expired preview is not reused", () => {
|
|
281
|
+
clearAutoProfilePreviewsForTesting();
|
|
282
|
+
const at = Date.now();
|
|
283
|
+
rememberAutoProfilePreview("conv-1", "hello", routed, context(), at);
|
|
284
|
+
expect(take({ text: "hello there" })).toBeUndefined();
|
|
285
|
+
expect(take({ text: "hello", conversationId: "conv-2" })).toBeUndefined();
|
|
286
|
+
expect(
|
|
287
|
+
take({ text: "hello", now: at + AUTO_PROFILE_PREVIEW_REUSE_MS + 1 }),
|
|
288
|
+
).toBeUndefined();
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
test("a preview is not reused once the conversation or the candidates moved on", () => {
|
|
292
|
+
clearAutoProfilePreviewsForTesting();
|
|
293
|
+
rememberAutoProfilePreview("conv-1", "do that too", routed, context());
|
|
294
|
+
expect(
|
|
295
|
+
take({
|
|
296
|
+
text: "do that too",
|
|
297
|
+
history: [...history, text("assistant", "Anything else?")],
|
|
298
|
+
}),
|
|
299
|
+
).toBeUndefined();
|
|
300
|
+
rememberAutoProfilePreview("conv-1", "do that too", routed, context());
|
|
301
|
+
expect(
|
|
302
|
+
take({
|
|
303
|
+
text: "do that too",
|
|
304
|
+
profiles: {
|
|
305
|
+
...profiles,
|
|
306
|
+
"cost-optimized": managed("Budget", "disabled"),
|
|
307
|
+
},
|
|
308
|
+
}),
|
|
309
|
+
).toBeUndefined();
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
test("a preview made before the conversation existed fits only a turn with no history", () => {
|
|
313
|
+
clearAutoProfilePreviewsForTesting();
|
|
314
|
+
rememberAutoProfilePreview(
|
|
315
|
+
undefined,
|
|
316
|
+
"first message",
|
|
317
|
+
routed,
|
|
318
|
+
contextFor([], "first message", profiles),
|
|
319
|
+
);
|
|
320
|
+
expect(
|
|
321
|
+
take({ conversationId: "conv-old", text: "first message" }),
|
|
322
|
+
).toBeUndefined();
|
|
323
|
+
expect(
|
|
324
|
+
take({ conversationId: "conv-new", text: "first message", history: [] }),
|
|
325
|
+
).toEqual(routed);
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
test("a fallback is not remembered, so the turn asks Jev again", () => {
|
|
329
|
+
clearAutoProfilePreviewsForTesting();
|
|
330
|
+
rememberAutoProfilePreview(
|
|
331
|
+
"conv-1",
|
|
332
|
+
"hi",
|
|
333
|
+
{ profile: AUTO_PROFILE_FALLBACK, outcome: "timeout", latencyMs: 1000 },
|
|
334
|
+
contextFor(history, "hi", profiles),
|
|
335
|
+
);
|
|
336
|
+
expect(take({ text: "hi" })).toBeUndefined();
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
test("abandoned previews expire and the map stays bounded", () => {
|
|
340
|
+
clearAutoProfilePreviewsForTesting();
|
|
341
|
+
const at = Date.now();
|
|
342
|
+
rememberAutoProfilePreview(
|
|
343
|
+
"conv-stale",
|
|
344
|
+
"old draft",
|
|
345
|
+
routed,
|
|
346
|
+
context(),
|
|
347
|
+
at,
|
|
348
|
+
);
|
|
349
|
+
for (let i = 0; i < 250; i += 1) {
|
|
350
|
+
rememberAutoProfilePreview(
|
|
351
|
+
`conv-${i}`,
|
|
352
|
+
"draft",
|
|
353
|
+
routed,
|
|
354
|
+
context(),
|
|
355
|
+
at + AUTO_PROFILE_PREVIEW_REUSE_MS + 1,
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
expect(
|
|
359
|
+
take({
|
|
360
|
+
conversationId: "conv-stale",
|
|
361
|
+
text: "old draft",
|
|
362
|
+
now: at + AUTO_PROFILE_PREVIEW_REUSE_MS + 2,
|
|
363
|
+
}),
|
|
364
|
+
).toBeUndefined();
|
|
365
|
+
expect(
|
|
366
|
+
take({
|
|
367
|
+
conversationId: "conv-0",
|
|
368
|
+
text: "draft",
|
|
369
|
+
now: at + AUTO_PROFILE_PREVIEW_REUSE_MS + 2,
|
|
370
|
+
}),
|
|
371
|
+
).toBeUndefined();
|
|
372
|
+
expect(
|
|
373
|
+
take({
|
|
374
|
+
conversationId: "conv-249",
|
|
375
|
+
text: "draft",
|
|
376
|
+
now: at + AUTO_PROFILE_PREVIEW_REUSE_MS + 2,
|
|
377
|
+
}),
|
|
378
|
+
).toEqual(routed);
|
|
379
|
+
});
|
|
380
|
+
});
|
|
@@ -24,6 +24,18 @@ interface EmitCall {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const emitCalls: EmitCall[] = [];
|
|
27
|
+
const backgroundCalls: Array<{
|
|
28
|
+
recoverOnly?: boolean;
|
|
29
|
+
assistantMessageId?: string;
|
|
30
|
+
}> = [];
|
|
31
|
+
mock.module("../../notifications/background-result-producer.js", () => ({
|
|
32
|
+
emitBackgroundResultNotification: async (params: {
|
|
33
|
+
recoverOnly?: boolean;
|
|
34
|
+
assistantMessageId?: string;
|
|
35
|
+
}) => {
|
|
36
|
+
backgroundCalls.push(params);
|
|
37
|
+
},
|
|
38
|
+
}));
|
|
27
39
|
/** Ordered trace of the tail's deferred work, for the ordering assertion. */
|
|
28
40
|
const trace: string[] = [];
|
|
29
41
|
let producerBehavior: "resolve" | "reject" | "hang" = "resolve";
|
|
@@ -98,6 +110,7 @@ async function runTail(overrides: {
|
|
|
98
110
|
|
|
99
111
|
beforeEach(() => {
|
|
100
112
|
emitCalls.length = 0;
|
|
113
|
+
backgroundCalls.length = 0;
|
|
101
114
|
trace.length = 0;
|
|
102
115
|
producerBehavior = "resolve";
|
|
103
116
|
});
|
|
@@ -138,6 +151,9 @@ describe("runDeferredTurnTail assistant-reply notification", () => {
|
|
|
138
151
|
await runTail({ turnCompleted: false });
|
|
139
152
|
|
|
140
153
|
expect(emitCalls).toEqual([]);
|
|
154
|
+
expect(backgroundCalls).toMatchObject([
|
|
155
|
+
{ recoverOnly: true, assistantMessageId: undefined },
|
|
156
|
+
]);
|
|
141
157
|
});
|
|
142
158
|
|
|
143
159
|
test("stays silent when the turn produced no assistant row", async () => {
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for the daemon activity trail. A block report asks "what overlapped
|
|
3
|
+
* the last N ms", so the trail must include work still running, include work
|
|
4
|
+
* that ended inside the window, exclude work that ended before it, and group
|
|
5
|
+
* identical labels so the report stays small.
|
|
6
|
+
*/
|
|
7
|
+
import { beforeEach, describe, expect, test } from "bun:test";
|
|
8
|
+
|
|
9
|
+
import type { InterfaceId } from "../channels/types.js";
|
|
10
|
+
import {
|
|
11
|
+
getActivityOverlapping,
|
|
12
|
+
resetActivityTrailForTests,
|
|
13
|
+
trackDaemonActivity,
|
|
14
|
+
turnActivityLabel,
|
|
15
|
+
turnConversationType,
|
|
16
|
+
} from "./activity-trail.js";
|
|
17
|
+
|
|
18
|
+
/** Resolves after `ms` of wall time. */
|
|
19
|
+
function sleep(ms: number): Promise<void> {
|
|
20
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
resetActivityTrailForTests();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe("getActivityOverlapping", () => {
|
|
28
|
+
test("reports running work and work that ended inside the window", async () => {
|
|
29
|
+
// GIVEN a background turn that has ended and a user turn still running
|
|
30
|
+
await trackDaemonActivity({ kind: "schedule_tick" }, async () => {});
|
|
31
|
+
let release!: () => void;
|
|
32
|
+
const userTurn = trackDaemonActivity(
|
|
33
|
+
{
|
|
34
|
+
kind: "turn",
|
|
35
|
+
conversationType: "standard",
|
|
36
|
+
callSite: "mainAgent",
|
|
37
|
+
turnInterface: "web",
|
|
38
|
+
interactive: true,
|
|
39
|
+
},
|
|
40
|
+
() => new Promise<void>((resolve) => (release = resolve)),
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
// WHEN the last minute is queried
|
|
44
|
+
const groups = getActivityOverlapping(60_000);
|
|
45
|
+
|
|
46
|
+
// THEN both appear, the user turn marked as running
|
|
47
|
+
expect(groups).toHaveLength(2);
|
|
48
|
+
expect(groups).toContainEqual(
|
|
49
|
+
expect.objectContaining({ kind: "schedule_tick", count: 1, running: 0 }),
|
|
50
|
+
);
|
|
51
|
+
expect(groups).toContainEqual(
|
|
52
|
+
expect.objectContaining({
|
|
53
|
+
kind: "turn",
|
|
54
|
+
turnInterface: "web",
|
|
55
|
+
interactive: true,
|
|
56
|
+
running: 1,
|
|
57
|
+
}),
|
|
58
|
+
);
|
|
59
|
+
release();
|
|
60
|
+
await userTurn;
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test("excludes work that ended before the window began", async () => {
|
|
64
|
+
// GIVEN work that ended ~50ms ago
|
|
65
|
+
await trackDaemonActivity({ kind: "git_compaction" }, async () => {});
|
|
66
|
+
await sleep(50);
|
|
67
|
+
|
|
68
|
+
// WHEN only the last 10ms are queried
|
|
69
|
+
const groups = getActivityOverlapping(10);
|
|
70
|
+
|
|
71
|
+
// THEN it is not attributed to the window
|
|
72
|
+
expect(groups).toEqual([]);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("groups identical labels and keeps the longest duration", async () => {
|
|
76
|
+
// GIVEN three heartbeat turns, one noticeably longer
|
|
77
|
+
const heartbeat = {
|
|
78
|
+
kind: "turn" as const,
|
|
79
|
+
conversationType: "background" as const,
|
|
80
|
+
callSite: "heartbeatAgent" as const,
|
|
81
|
+
interactive: false,
|
|
82
|
+
};
|
|
83
|
+
await trackDaemonActivity(heartbeat, async () => {});
|
|
84
|
+
await trackDaemonActivity(heartbeat, () => sleep(30));
|
|
85
|
+
await trackDaemonActivity(heartbeat, async () => {});
|
|
86
|
+
|
|
87
|
+
// WHEN the window covers all three
|
|
88
|
+
const groups = getActivityOverlapping(60_000);
|
|
89
|
+
|
|
90
|
+
// THEN they collapse into one group
|
|
91
|
+
expect(groups).toHaveLength(1);
|
|
92
|
+
expect(groups[0]).toMatchObject({ ...heartbeat, count: 3, running: 0 });
|
|
93
|
+
expect(groups[0]!.longestMs).toBeGreaterThanOrEqual(25);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test("a failing job still closes its mark", async () => {
|
|
97
|
+
// GIVEN tracked work that throws
|
|
98
|
+
await expect(
|
|
99
|
+
trackDaemonActivity({ kind: "vbundle_export" }, async () => {
|
|
100
|
+
throw new Error("boom");
|
|
101
|
+
}),
|
|
102
|
+
).rejects.toThrow("boom");
|
|
103
|
+
|
|
104
|
+
// WHEN the trail is queried
|
|
105
|
+
const groups = getActivityOverlapping(60_000);
|
|
106
|
+
|
|
107
|
+
// THEN the work is recorded as ended, not left running forever
|
|
108
|
+
expect(groups).toEqual([
|
|
109
|
+
expect.objectContaining({ kind: "vbundle_export", running: 0 }),
|
|
110
|
+
]);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
describe("burst retention", () => {
|
|
115
|
+
test("a burst of finished work does not evict what overlapped a block", async () => {
|
|
116
|
+
// GIVEN a user turn that ends, then a burst of 500 short jobs
|
|
117
|
+
await trackDaemonActivity(
|
|
118
|
+
{ kind: "turn", conversationType: "standard", callSite: "mainAgent" },
|
|
119
|
+
async () => {},
|
|
120
|
+
);
|
|
121
|
+
for (let i = 0; i < 500; i++) {
|
|
122
|
+
await trackDaemonActivity({ kind: "schedule_tick" }, async () => {});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// WHEN the last minute is queried
|
|
126
|
+
const groups = getActivityOverlapping(60_000);
|
|
127
|
+
|
|
128
|
+
// THEN the earlier turn is still attributed
|
|
129
|
+
expect(groups).toContainEqual(
|
|
130
|
+
expect.objectContaining({ kind: "turn", count: 1 }),
|
|
131
|
+
);
|
|
132
|
+
expect(groups).toContainEqual(
|
|
133
|
+
expect.objectContaining({ kind: "schedule_tick", count: 500 }),
|
|
134
|
+
);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
describe("turnActivityLabel", () => {
|
|
139
|
+
function conversation(opts: {
|
|
140
|
+
isSubagent?: boolean;
|
|
141
|
+
originInterface?: InterfaceId;
|
|
142
|
+
liveInterface?: InterfaceId;
|
|
143
|
+
}) {
|
|
144
|
+
return {
|
|
145
|
+
conversationType: "standard",
|
|
146
|
+
isSubagent: opts.isSubagent ?? false,
|
|
147
|
+
originInterface: opts.originInterface,
|
|
148
|
+
getTurnInterfaceContext: () =>
|
|
149
|
+
opts.liveInterface
|
|
150
|
+
? { userMessageInterface: opts.liveInterface }
|
|
151
|
+
: null,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
test("a subagent turn without an explicit call site is a subagent turn", () => {
|
|
156
|
+
// GIVEN a subagent conversation and a queue-drained turn with no call site
|
|
157
|
+
// WHEN its label is built
|
|
158
|
+
const label = turnActivityLabel(
|
|
159
|
+
conversation({ isSubagent: true }),
|
|
160
|
+
undefined,
|
|
161
|
+
false,
|
|
162
|
+
);
|
|
163
|
+
// THEN it matches the call site the loop resolves, not mainAgent
|
|
164
|
+
expect(label.callSite).toBe("subagentSpawn");
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test("an explicit call site wins", () => {
|
|
168
|
+
const label = turnActivityLabel(conversation({}), "heartbeatAgent", false);
|
|
169
|
+
expect(label.callSite).toBe("heartbeatAgent");
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
test("the turn's own interface wins over the conversation's origin", () => {
|
|
173
|
+
// GIVEN a conversation started on web, now continued from Slack
|
|
174
|
+
// WHEN the Slack turn's label is built
|
|
175
|
+
const label = turnActivityLabel(
|
|
176
|
+
conversation({ originInterface: "web", liveInterface: "slack" }),
|
|
177
|
+
undefined,
|
|
178
|
+
true,
|
|
179
|
+
);
|
|
180
|
+
// THEN it is attributed to Slack
|
|
181
|
+
expect(label.turnInterface).toBe("slack");
|
|
182
|
+
expect(label.interactive).toBe(true);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
test("falls back to the origin interface, and omits it when unknown", () => {
|
|
186
|
+
expect(
|
|
187
|
+
turnActivityLabel(
|
|
188
|
+
conversation({ originInterface: "macos" }),
|
|
189
|
+
undefined,
|
|
190
|
+
false,
|
|
191
|
+
).turnInterface,
|
|
192
|
+
).toBe("macos");
|
|
193
|
+
expect(
|
|
194
|
+
turnActivityLabel(conversation({}), undefined, false),
|
|
195
|
+
).not.toHaveProperty("turnInterface");
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
describe("turnConversationType", () => {
|
|
200
|
+
test("keeps known types, defaults a missing one, and buckets the rest", () => {
|
|
201
|
+
expect(turnConversationType("background")).toBe("background");
|
|
202
|
+
expect(turnConversationType("scheduled")).toBe("scheduled");
|
|
203
|
+
expect(turnConversationType(undefined)).toBe("standard");
|
|
204
|
+
expect(turnConversationType("something-new")).toBe("other");
|
|
205
|
+
});
|
|
206
|
+
});
|