@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,281 @@
|
|
|
1
|
+
import { beforeEach, expect, mock, test } from "bun:test";
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
QueuedDispatch,
|
|
5
|
+
QueuedMessage,
|
|
6
|
+
} from "../../daemon/conversation-queue-manager.js";
|
|
7
|
+
import type { SubagentRecord } from "../../persistence/subagent-store.js";
|
|
8
|
+
|
|
9
|
+
let tasks: Array<
|
|
10
|
+
Pick<SubagentRecord, "role" | "isFork" | "sendResultToUser"> & {
|
|
11
|
+
createdAt?: number;
|
|
12
|
+
}
|
|
13
|
+
> = [];
|
|
14
|
+
let tools: unknown[] = [];
|
|
15
|
+
let queued = false;
|
|
16
|
+
let processing = false;
|
|
17
|
+
let activeOrigins: QueuedMessage[] | undefined;
|
|
18
|
+
let wakeStartedAt: number | undefined;
|
|
19
|
+
let liveChild = false;
|
|
20
|
+
let childProcessing = true;
|
|
21
|
+
let queuedMessages: QueuedMessage[] = [];
|
|
22
|
+
let taskCreatedAt = 100;
|
|
23
|
+
const parentDispatches = new Map<string | null, Set<QueuedDispatch>>();
|
|
24
|
+
const childDispatches = new Map<string | null, Set<QueuedDispatch>>();
|
|
25
|
+
let wakeQueued = false;
|
|
26
|
+
mock.module("../../runtime/agent-wake-queue.js", () => ({
|
|
27
|
+
hasPendingAgentWake: (
|
|
28
|
+
_id: string,
|
|
29
|
+
_run: string | undefined,
|
|
30
|
+
options?: { startedAfter?: number },
|
|
31
|
+
) =>
|
|
32
|
+
wakeQueued &&
|
|
33
|
+
(options?.startedAfter === undefined ||
|
|
34
|
+
(wakeStartedAt !== undefined && wakeStartedAt >= options.startedAfter)),
|
|
35
|
+
}));
|
|
36
|
+
mock.module("../../persistence/subagent-store.js", () => ({
|
|
37
|
+
getSubagentRecordsByParent: () => tasks,
|
|
38
|
+
getSubagentRecordById: () => ({
|
|
39
|
+
role: "worker",
|
|
40
|
+
isFork: false,
|
|
41
|
+
sendResultToUser: true,
|
|
42
|
+
createdAt: taskCreatedAt,
|
|
43
|
+
}),
|
|
44
|
+
getSubagentRecordByConversationId: () => ({
|
|
45
|
+
role: "worker",
|
|
46
|
+
isFork: false,
|
|
47
|
+
sendResultToUser: true,
|
|
48
|
+
createdAt: 100,
|
|
49
|
+
}),
|
|
50
|
+
}));
|
|
51
|
+
mock.module("../../tools/background-tool-registry.js", () => ({
|
|
52
|
+
hasBackgroundToolWork: (
|
|
53
|
+
_conversationId: string,
|
|
54
|
+
options?: { startedAfter?: number },
|
|
55
|
+
) =>
|
|
56
|
+
tools.some(
|
|
57
|
+
(tool) =>
|
|
58
|
+
options?.startedAfter === undefined ||
|
|
59
|
+
(tool as { startedAt: number }).startedAt >= options.startedAfter,
|
|
60
|
+
),
|
|
61
|
+
}));
|
|
62
|
+
mock.module("../../daemon/conversation-registry.js", () => ({
|
|
63
|
+
allSubagentConversations: () =>
|
|
64
|
+
liveChild
|
|
65
|
+
? [
|
|
66
|
+
{
|
|
67
|
+
conversationId: "conv-child",
|
|
68
|
+
parentConversationId: "conv-123",
|
|
69
|
+
isProcessing: () => childProcessing,
|
|
70
|
+
pendingQueuedDispatches: childDispatches,
|
|
71
|
+
hasQueuedMessages: () => false,
|
|
72
|
+
},
|
|
73
|
+
]
|
|
74
|
+
: [],
|
|
75
|
+
findConversation: () => ({
|
|
76
|
+
isProcessing: () => processing,
|
|
77
|
+
currentTurnWorkOrigins: activeOrigins,
|
|
78
|
+
pendingQueuedDispatches: parentDispatches,
|
|
79
|
+
hasQueuedMessages: () => queued || queuedMessages.length > 0,
|
|
80
|
+
snapshotQueuedMessages: () => queuedMessages,
|
|
81
|
+
}),
|
|
82
|
+
}));
|
|
83
|
+
const { hasPendingBackgroundWork } =
|
|
84
|
+
await import("../has-pending-background-work.js");
|
|
85
|
+
|
|
86
|
+
beforeEach(() => {
|
|
87
|
+
tasks = [];
|
|
88
|
+
tools = [];
|
|
89
|
+
queued = false;
|
|
90
|
+
queuedMessages = [];
|
|
91
|
+
taskCreatedAt = 100;
|
|
92
|
+
processing = false;
|
|
93
|
+
activeOrigins = undefined;
|
|
94
|
+
wakeStartedAt = undefined;
|
|
95
|
+
liveChild = false;
|
|
96
|
+
childProcessing = true;
|
|
97
|
+
parentDispatches.clear();
|
|
98
|
+
childDispatches.clear();
|
|
99
|
+
wakeQueued = false;
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test("internal advisor and silent-fork work cannot suppress the user's reply", () => {
|
|
103
|
+
tasks = [
|
|
104
|
+
{ role: "advisor", isFork: false, sendResultToUser: null },
|
|
105
|
+
{ role: "worker", isFork: true, sendResultToUser: null },
|
|
106
|
+
{ role: "worker", isFork: false, sendResultToUser: false },
|
|
107
|
+
];
|
|
108
|
+
expect(hasPendingBackgroundWork("conv-123")).toBe(false);
|
|
109
|
+
});
|
|
110
|
+
test("a pending user-facing child, command, or parent continuation delays completion", () => {
|
|
111
|
+
tasks = [{ role: "worker", isFork: false, sendResultToUser: null }];
|
|
112
|
+
expect(hasPendingBackgroundWork("conv-123")).toBe(true);
|
|
113
|
+
tasks = [{ role: "worker", isFork: true, sendResultToUser: true }];
|
|
114
|
+
expect(hasPendingBackgroundWork("conv-123")).toBe(true);
|
|
115
|
+
tasks = [];
|
|
116
|
+
tools = [{}];
|
|
117
|
+
expect(hasPendingBackgroundWork("conv-123")).toBe(true);
|
|
118
|
+
tools = [];
|
|
119
|
+
queued = true;
|
|
120
|
+
expect(hasPendingBackgroundWork("conv-123")).toBe(true);
|
|
121
|
+
queued = false;
|
|
122
|
+
processing = true;
|
|
123
|
+
expect(hasPendingBackgroundWork("conv-123")).toBe(true);
|
|
124
|
+
processing = false;
|
|
125
|
+
expect(hasPendingBackgroundWork("conv-123")).toBe(false);
|
|
126
|
+
wakeQueued = true;
|
|
127
|
+
expect(hasPendingBackgroundWork("conv-123")).toBe(true);
|
|
128
|
+
expect(hasPendingBackgroundWork("conv-123", { startedAfter: 200 })).toBe(
|
|
129
|
+
false,
|
|
130
|
+
);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test("a later ordinary reply ignores pending work from an earlier turn", () => {
|
|
134
|
+
tasks = [
|
|
135
|
+
{ role: "worker", isFork: false, sendResultToUser: true, createdAt: 100 },
|
|
136
|
+
];
|
|
137
|
+
tools = [{ startedAt: 100 }];
|
|
138
|
+
expect(hasPendingBackgroundWork("conv-123", { startedAfter: 200 })).toBe(
|
|
139
|
+
false,
|
|
140
|
+
);
|
|
141
|
+
tasks[0].createdAt = 200;
|
|
142
|
+
expect(hasPendingBackgroundWork("conv-123", { startedAfter: 200 })).toBe(
|
|
143
|
+
true,
|
|
144
|
+
);
|
|
145
|
+
tasks = [];
|
|
146
|
+
tools = [{ startedAt: 200 }];
|
|
147
|
+
expect(hasPendingBackgroundWork("conv-123", { startedAfter: 200 })).toBe(
|
|
148
|
+
true,
|
|
149
|
+
);
|
|
150
|
+
expect(hasPendingBackgroundWork("conv-123")).toBe(true);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test("a terminal child's queued follow-up must settle before completion", () => {
|
|
154
|
+
liveChild = true;
|
|
155
|
+
expect(hasPendingBackgroundWork("conv-123")).toBe(true);
|
|
156
|
+
expect(hasPendingBackgroundWork("conv-other")).toBe(false);
|
|
157
|
+
expect(hasPendingBackgroundWork("conv-123", { startedAfter: 200 })).toBe(
|
|
158
|
+
false,
|
|
159
|
+
);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
test("a dequeued unscheduled continuation suppresses kickoff alerts before its processing claim", () => {
|
|
163
|
+
parentDispatches.set(
|
|
164
|
+
null,
|
|
165
|
+
new Set([
|
|
166
|
+
{ controller: new AbortController(), messages: [queuedMessage(100)] },
|
|
167
|
+
]),
|
|
168
|
+
);
|
|
169
|
+
expect(hasPendingBackgroundWork("conv-123", { startedAfter: 100 })).toBe(
|
|
170
|
+
true,
|
|
171
|
+
);
|
|
172
|
+
expect(hasPendingBackgroundWork("conv-123")).toBe(true);
|
|
173
|
+
parentDispatches.clear();
|
|
174
|
+
expect(hasPendingBackgroundWork("conv-123", { startedAfter: 100 })).toBe(
|
|
175
|
+
false,
|
|
176
|
+
);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
test("a terminal child's dequeued continuation remains pending before its claim", () => {
|
|
180
|
+
liveChild = true;
|
|
181
|
+
childProcessing = false;
|
|
182
|
+
childDispatches.set(
|
|
183
|
+
null,
|
|
184
|
+
new Set([
|
|
185
|
+
{ controller: new AbortController(), messages: [queuedMessage(100)] },
|
|
186
|
+
]),
|
|
187
|
+
);
|
|
188
|
+
expect(hasPendingBackgroundWork("conv-123", { startedAfter: 100 })).toBe(
|
|
189
|
+
true,
|
|
190
|
+
);
|
|
191
|
+
expect(hasPendingBackgroundWork("conv-123", { startedAfter: 200 })).toBe(
|
|
192
|
+
false,
|
|
193
|
+
);
|
|
194
|
+
childDispatches.clear();
|
|
195
|
+
expect(hasPendingBackgroundWork("conv-123")).toBe(false);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
function queuedMessage(
|
|
199
|
+
sentAt: number,
|
|
200
|
+
metadata?: Record<string, unknown>,
|
|
201
|
+
): QueuedMessage {
|
|
202
|
+
return {
|
|
203
|
+
content: "Continuation",
|
|
204
|
+
attachments: [],
|
|
205
|
+
requestId: "req-123",
|
|
206
|
+
sentAt,
|
|
207
|
+
metadata,
|
|
208
|
+
onEvent: () => {},
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
for (const state of ["queued", "dispatch", "active"] as const) {
|
|
213
|
+
for (const source of ["user", "subagent", "command"] as const) {
|
|
214
|
+
test(`a newer reply ignores older ${source} work while ${state}`, () => {
|
|
215
|
+
const metadata =
|
|
216
|
+
source === "subagent"
|
|
217
|
+
? { subagentNotification: { subagentId: "task-123" } }
|
|
218
|
+
: source === "command"
|
|
219
|
+
? {
|
|
220
|
+
backgroundEventSource: "background-tool",
|
|
221
|
+
backgroundToolCompletion: { startedAt: 100 },
|
|
222
|
+
}
|
|
223
|
+
: undefined;
|
|
224
|
+
const message = queuedMessage(source === "user" ? 100 : 300, metadata);
|
|
225
|
+
if (state === "queued") {
|
|
226
|
+
queuedMessages = [message];
|
|
227
|
+
} else if (state === "active") {
|
|
228
|
+
processing = true;
|
|
229
|
+
activeOrigins = [message];
|
|
230
|
+
} else {
|
|
231
|
+
parentDispatches.set(
|
|
232
|
+
null,
|
|
233
|
+
new Set([{ controller: new AbortController(), messages: [message] }]),
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
expect(hasPendingBackgroundWork("conv-123")).toBe(true);
|
|
237
|
+
expect(hasPendingBackgroundWork("conv-123", { startedAfter: 200 })).toBe(
|
|
238
|
+
false,
|
|
239
|
+
);
|
|
240
|
+
expect(hasPendingBackgroundWork("conv-123", { startedAfter: 100 })).toBe(
|
|
241
|
+
true,
|
|
242
|
+
);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
test("a mixed dispatch still suppresses the kickoff alert for newer work", () => {
|
|
248
|
+
parentDispatches.set(
|
|
249
|
+
null,
|
|
250
|
+
new Set([
|
|
251
|
+
{
|
|
252
|
+
controller: new AbortController(),
|
|
253
|
+
messages: [queuedMessage(100), queuedMessage(200)],
|
|
254
|
+
},
|
|
255
|
+
]),
|
|
256
|
+
);
|
|
257
|
+
expect(hasPendingBackgroundWork("conv-123", { startedAfter: 200 })).toBe(
|
|
258
|
+
true,
|
|
259
|
+
);
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
test("pending command wakes use their originating work time", () => {
|
|
263
|
+
wakeQueued = true;
|
|
264
|
+
wakeStartedAt = 100;
|
|
265
|
+
expect(hasPendingBackgroundWork("conv-123", { startedAfter: 200 })).toBe(
|
|
266
|
+
false,
|
|
267
|
+
);
|
|
268
|
+
wakeStartedAt = 200;
|
|
269
|
+
expect(hasPendingBackgroundWork("conv-123", { startedAfter: 200 })).toBe(
|
|
270
|
+
true,
|
|
271
|
+
);
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
test("an older active turn does not hide newer queued work", () => {
|
|
275
|
+
processing = true;
|
|
276
|
+
activeOrigins = [queuedMessage(100)];
|
|
277
|
+
queuedMessages = [queuedMessage(200)];
|
|
278
|
+
expect(hasPendingBackgroundWork("conv-123", { startedAfter: 200 })).toBe(
|
|
279
|
+
true,
|
|
280
|
+
);
|
|
281
|
+
});
|
|
@@ -20,7 +20,7 @@ const messageAppends: Array<{
|
|
|
20
20
|
conversationId: string;
|
|
21
21
|
role: string;
|
|
22
22
|
content: string;
|
|
23
|
-
options?: { skipIndexing?: boolean };
|
|
23
|
+
options?: { skipIndexing?: boolean; skipResurface?: boolean };
|
|
24
24
|
}> = [];
|
|
25
25
|
const messageRewrites: Array<{ messageId: string; content: string }> = [];
|
|
26
26
|
/** messageId -> the conversation it belongs to, for the scoped lookup. */
|
|
@@ -86,7 +86,7 @@ mock.module("../../persistence/conversation-crud.js", () => ({
|
|
|
86
86
|
conversationId: string,
|
|
87
87
|
role: string,
|
|
88
88
|
content: string,
|
|
89
|
-
options?: { skipIndexing?: boolean },
|
|
89
|
+
options?: { skipIndexing?: boolean; skipResurface?: boolean },
|
|
90
90
|
) => {
|
|
91
91
|
if (messageAppendShouldThrow) {
|
|
92
92
|
throw new Error("simulated message write failure");
|
|
@@ -183,6 +183,80 @@ beforeEach(() => {
|
|
|
183
183
|
});
|
|
184
184
|
|
|
185
185
|
describe("writeHomeFeedItemForSignal", () => {
|
|
186
|
+
test.each([undefined, "sent", "failed", "skipped"] as const)(
|
|
187
|
+
"recipient-owned completion stays out of the shared feed with delivery %s",
|
|
188
|
+
async (status) => {
|
|
189
|
+
conversationRowsById.set("conv-source", { conversationType: "standard" });
|
|
190
|
+
conversationRowsById.set("conv-result", {
|
|
191
|
+
conversationType: "background",
|
|
192
|
+
});
|
|
193
|
+
const item = await writeHomeFeedItemForSignal(
|
|
194
|
+
makeSignal({
|
|
195
|
+
sourceChannel: "assistant_tool",
|
|
196
|
+
sourceContextId: "conv-source",
|
|
197
|
+
sourceEventName: "activity.complete",
|
|
198
|
+
contextPayload: {
|
|
199
|
+
title: "Result ready",
|
|
200
|
+
body: "Private result preview.",
|
|
201
|
+
completion: {
|
|
202
|
+
workId: "task-1",
|
|
203
|
+
conversationId: "conv-result",
|
|
204
|
+
recipientPrincipalId: "principal-1",
|
|
205
|
+
owner: "parent_continuation",
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
attentionHints: {
|
|
209
|
+
requiresAction: false,
|
|
210
|
+
urgency: "medium",
|
|
211
|
+
isAsyncBackground: true,
|
|
212
|
+
visibleInSourceNow: false,
|
|
213
|
+
},
|
|
214
|
+
}),
|
|
215
|
+
makeDecision({
|
|
216
|
+
selectedChannels: ["platform"],
|
|
217
|
+
renderedCopy: {
|
|
218
|
+
platform: { title: "Result ready", body: "The report is ready." },
|
|
219
|
+
},
|
|
220
|
+
}),
|
|
221
|
+
status === undefined
|
|
222
|
+
? undefined
|
|
223
|
+
: makeVellumDelivery({
|
|
224
|
+
status,
|
|
225
|
+
...(status === "failed"
|
|
226
|
+
? { errorMessage: "completion recipient unavailable" }
|
|
227
|
+
: {}),
|
|
228
|
+
}),
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
expect(item).toBeNull();
|
|
232
|
+
expect(appendCalls).toEqual([]);
|
|
233
|
+
expect(messageAppends).toEqual([]);
|
|
234
|
+
expect(messagesInvalidated).toEqual([]);
|
|
235
|
+
},
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
test.each([null, {}, { recipientPrincipalId: "principal-1" }])(
|
|
239
|
+
"malformed completion ownership cannot fall back to the assistant-wide feed (%j)",
|
|
240
|
+
async (completion) => {
|
|
241
|
+
conversationRow = { conversationType: "background" };
|
|
242
|
+
const item = await writeHomeFeedItemForSignal(
|
|
243
|
+
makeSignal({
|
|
244
|
+
sourceChannel: "assistant_tool",
|
|
245
|
+
sourceEventName: "activity.complete",
|
|
246
|
+
contextPayload: {
|
|
247
|
+
title: "Result ready",
|
|
248
|
+
body: "Private result preview.",
|
|
249
|
+
completion,
|
|
250
|
+
},
|
|
251
|
+
}),
|
|
252
|
+
makeDecision(),
|
|
253
|
+
);
|
|
254
|
+
expect(item).toBeNull();
|
|
255
|
+
expect(appendCalls).toEqual([]);
|
|
256
|
+
expect(messageAppends).toEqual([]);
|
|
257
|
+
},
|
|
258
|
+
);
|
|
259
|
+
|
|
186
260
|
test("background conversation signal writes a feed item with payload title + rendered body", async () => {
|
|
187
261
|
conversationRow = { conversationType: "background" };
|
|
188
262
|
const signal = makeSignal({
|
|
@@ -1039,6 +1113,88 @@ describe("writeHomeFeedItemForSignal", () => {
|
|
|
1039
1113
|
expect(appendCalls).toHaveLength(1);
|
|
1040
1114
|
});
|
|
1041
1115
|
|
|
1116
|
+
// ── skill-update receipts ───────────────────────────────────────────
|
|
1117
|
+
|
|
1118
|
+
const RECEIPT_UPDATES = [
|
|
1119
|
+
{
|
|
1120
|
+
skillId: "skill-a",
|
|
1121
|
+
name: "Skill A",
|
|
1122
|
+
summary: "Changed a step.",
|
|
1123
|
+
conversationId: "conv-source-1",
|
|
1124
|
+
},
|
|
1125
|
+
{ skillId: "skill-b", name: "Skill B", summary: "Changed another." },
|
|
1126
|
+
];
|
|
1127
|
+
|
|
1128
|
+
test("a receipt's entries land as the typed updates, out of metadata, under the list panel", async () => {
|
|
1129
|
+
conversationRow = { conversationType: "background" };
|
|
1130
|
+
const signal = makeSignal({
|
|
1131
|
+
sourceChannel: "assistant_tool",
|
|
1132
|
+
sourceEventName: "activity.complete",
|
|
1133
|
+
contextPayload: {
|
|
1134
|
+
title: "2 skills updated",
|
|
1135
|
+
body: "- Skill A: Changed a step.\n- Skill B: Changed another.",
|
|
1136
|
+
updates: RECEIPT_UPDATES,
|
|
1137
|
+
skillId: "skill-a",
|
|
1138
|
+
},
|
|
1139
|
+
});
|
|
1140
|
+
|
|
1141
|
+
const item = await writeHomeFeedItemForSignal(signal, makeDecision());
|
|
1142
|
+
|
|
1143
|
+
expect(item?.updates).toEqual(RECEIPT_UPDATES);
|
|
1144
|
+
expect(item?.detailPanel).toEqual({ kind: "updatesList" });
|
|
1145
|
+
expect(item?.metadata).not.toHaveProperty("updates");
|
|
1146
|
+
expect(item?.metadata?.skillId).toBe("skill-a");
|
|
1147
|
+
});
|
|
1148
|
+
|
|
1149
|
+
test("a receipt's summary is the payload body, never model copy", async () => {
|
|
1150
|
+
// The pipeline's seed message and body win for every other item; a
|
|
1151
|
+
// paraphrase of a receipt can drop an entry, so the list is kept.
|
|
1152
|
+
conversationRow = { conversationType: "background" };
|
|
1153
|
+
const signal = makeSignal({
|
|
1154
|
+
sourceChannel: "assistant_tool",
|
|
1155
|
+
sourceEventName: "activity.complete",
|
|
1156
|
+
contextPayload: {
|
|
1157
|
+
title: "2 skills updated",
|
|
1158
|
+
body: "- Skill A: Changed a step.\n- Skill B: Changed another.",
|
|
1159
|
+
updates: RECEIPT_UPDATES,
|
|
1160
|
+
},
|
|
1161
|
+
});
|
|
1162
|
+
const decision = makeDecision({
|
|
1163
|
+
selectedChannels: ["vellum"],
|
|
1164
|
+
renderedCopy: {
|
|
1165
|
+
vellum: {
|
|
1166
|
+
title: "Skills refreshed",
|
|
1167
|
+
body: "Two skills were refreshed.",
|
|
1168
|
+
conversationSeedMessage:
|
|
1169
|
+
"The assistant refreshed two of your skills after reviewing recent work.",
|
|
1170
|
+
},
|
|
1171
|
+
},
|
|
1172
|
+
});
|
|
1173
|
+
|
|
1174
|
+
const item = await writeHomeFeedItemForSignal(signal, decision);
|
|
1175
|
+
|
|
1176
|
+
expect(item?.summary).toBe(
|
|
1177
|
+
"- Skill A: Changed a step.\n- Skill B: Changed another.",
|
|
1178
|
+
);
|
|
1179
|
+
});
|
|
1180
|
+
|
|
1181
|
+
test("a malformed or empty updates list leaves the item an ordinary notification", async () => {
|
|
1182
|
+
conversationRow = { conversationType: "background" };
|
|
1183
|
+
for (const updates of [[], [{ name: "no id" }], "not a list"]) {
|
|
1184
|
+
appendCalls.length = 0;
|
|
1185
|
+
const signal = makeSignal({
|
|
1186
|
+
sourceChannel: "assistant_tool",
|
|
1187
|
+
sourceEventName: "activity.complete",
|
|
1188
|
+
contextPayload: { title: "Skill updated", body: "Body", updates },
|
|
1189
|
+
});
|
|
1190
|
+
|
|
1191
|
+
const item = await writeHomeFeedItemForSignal(signal, makeDecision());
|
|
1192
|
+
|
|
1193
|
+
expect(item?.updates).toBeUndefined();
|
|
1194
|
+
expect(item?.detailPanel).toBeUndefined();
|
|
1195
|
+
}
|
|
1196
|
+
});
|
|
1197
|
+
|
|
1042
1198
|
// ── noteworthy derivation ────────────────────────────────────────────
|
|
1043
1199
|
|
|
1044
1200
|
test("assistant_tool source marks the feed item noteworthy", async () => {
|
|
@@ -1264,7 +1420,9 @@ describe("writeHomeFeedItemForSignal", () => {
|
|
|
1264
1420
|
conversationId: "conv-source-1",
|
|
1265
1421
|
role: "assistant",
|
|
1266
1422
|
content: "Three things today.",
|
|
1267
|
-
|
|
1423
|
+
// Bookkeeping about the conversation, so it never resurfaces a
|
|
1424
|
+
// chat the user marked Done.
|
|
1425
|
+
options: { skipIndexing: true, skipResurface: true },
|
|
1268
1426
|
});
|
|
1269
1427
|
expect(item?.metadata?.notificationConversationMessageId).toBe("msg-1");
|
|
1270
1428
|
// A client with the conversation open refetches only on the messages
|
|
@@ -26,7 +26,29 @@ mock.module("../../runtime/web-presence.js", () => ({
|
|
|
26
26
|
},
|
|
27
27
|
}));
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
let guardianPrincipalId: string | undefined = "guardian-1";
|
|
30
|
+
let guardianReadShouldThrow = false;
|
|
31
|
+
const realGuardianDelivery =
|
|
32
|
+
await import("../../contacts/guardian-delivery-reader.js");
|
|
33
|
+
mock.module("../../contacts/guardian-delivery-reader.js", () => ({
|
|
34
|
+
...realGuardianDelivery,
|
|
35
|
+
getGuardianDelivery: async () => {
|
|
36
|
+
if (guardianReadShouldThrow) {
|
|
37
|
+
throw new Error("recipient unavailable");
|
|
38
|
+
}
|
|
39
|
+
return guardianPrincipalId
|
|
40
|
+
? [
|
|
41
|
+
{
|
|
42
|
+
channelType: "vellum",
|
|
43
|
+
status: "active",
|
|
44
|
+
principalId: guardianPrincipalId,
|
|
45
|
+
},
|
|
46
|
+
]
|
|
47
|
+
: null;
|
|
48
|
+
},
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
const { resolveVisibleInSourceNow, resolveCompletionVisibleInSourceNow } =
|
|
30
52
|
await import("../resolve-visible-in-source.js");
|
|
31
53
|
|
|
32
54
|
describe("resolveVisibleInSourceNow", () => {
|
|
@@ -94,3 +116,90 @@ describe("resolveVisibleInSourceNow", () => {
|
|
|
94
116
|
expect(webPresenceArgs).toEqual([]);
|
|
95
117
|
});
|
|
96
118
|
});
|
|
119
|
+
|
|
120
|
+
describe("resolveCompletionVisibleInSourceNow", () => {
|
|
121
|
+
beforeEach(() => {
|
|
122
|
+
guardianPrincipalId = "guardian-1";
|
|
123
|
+
guardianReadShouldThrow = false;
|
|
124
|
+
webFocused = true;
|
|
125
|
+
webPresenceShouldThrow = false;
|
|
126
|
+
webPresenceArgs.length = 0;
|
|
127
|
+
setOverridesForTesting({ "web-presence-suppression": true });
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test("reads attendance only for the completion recipient", async () => {
|
|
131
|
+
expect(
|
|
132
|
+
await resolveCompletionVisibleInSourceNow({
|
|
133
|
+
conversationId: CONVERSATION_ID,
|
|
134
|
+
}),
|
|
135
|
+
).toBe(true);
|
|
136
|
+
expect(webPresenceArgs).toEqual([
|
|
137
|
+
[CONVERSATION_ID, { actorPrincipalId: "guardian-1" }],
|
|
138
|
+
]);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test("does not read unscoped presence when the recipient is unknown", async () => {
|
|
142
|
+
guardianPrincipalId = undefined;
|
|
143
|
+
expect(
|
|
144
|
+
await resolveCompletionVisibleInSourceNow({
|
|
145
|
+
conversationId: CONVERSATION_ID,
|
|
146
|
+
}),
|
|
147
|
+
).toBe(false);
|
|
148
|
+
expect(webPresenceArgs).toEqual([]);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
test("uses an already resolved recipient without a second identity lookup", async () => {
|
|
152
|
+
guardianReadShouldThrow = true;
|
|
153
|
+
expect(
|
|
154
|
+
await resolveCompletionVisibleInSourceNow({
|
|
155
|
+
conversationId: CONVERSATION_ID,
|
|
156
|
+
actorPrincipalId: "guardian-resolved",
|
|
157
|
+
}),
|
|
158
|
+
).toBe(true);
|
|
159
|
+
expect(webPresenceArgs).toEqual([
|
|
160
|
+
[CONVERSATION_ID, { actorPrincipalId: "guardian-resolved" }],
|
|
161
|
+
]);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
test("uses the completion presence flag independently of activity suppression", async () => {
|
|
165
|
+
setOverridesForTesting({ "web-presence-suppression": true, [FLAG]: false });
|
|
166
|
+
expect(
|
|
167
|
+
await resolveCompletionVisibleInSourceNow({
|
|
168
|
+
conversationId: CONVERSATION_ID,
|
|
169
|
+
}),
|
|
170
|
+
).toBe(true);
|
|
171
|
+
setOverridesForTesting({ "web-presence-suppression": false, [FLAG]: true });
|
|
172
|
+
webPresenceArgs.length = 0;
|
|
173
|
+
expect(
|
|
174
|
+
await resolveCompletionVisibleInSourceNow({
|
|
175
|
+
conversationId: CONVERSATION_ID,
|
|
176
|
+
}),
|
|
177
|
+
).toBe(false);
|
|
178
|
+
expect(webPresenceArgs).toEqual([]);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
test("allows delivery when recipient lookup fails", async () => {
|
|
182
|
+
guardianReadShouldThrow = true;
|
|
183
|
+
const warn = mock(() => {});
|
|
184
|
+
expect(
|
|
185
|
+
await resolveCompletionVisibleInSourceNow({
|
|
186
|
+
conversationId: CONVERSATION_ID,
|
|
187
|
+
logger: { warn } as unknown as pino.Logger,
|
|
188
|
+
}),
|
|
189
|
+
).toBe(false);
|
|
190
|
+
expect(webPresenceArgs).toEqual([]);
|
|
191
|
+
expect(warn).toHaveBeenCalledTimes(1);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
test("allows delivery when presence lookup fails", async () => {
|
|
195
|
+
webPresenceShouldThrow = true;
|
|
196
|
+
const warn = mock(() => {});
|
|
197
|
+
expect(
|
|
198
|
+
await resolveCompletionVisibleInSourceNow({
|
|
199
|
+
conversationId: CONVERSATION_ID,
|
|
200
|
+
logger: { warn } as unknown as pino.Logger,
|
|
201
|
+
}),
|
|
202
|
+
).toBe(false);
|
|
203
|
+
expect(warn).toHaveBeenCalledTimes(1);
|
|
204
|
+
});
|
|
205
|
+
});
|
|
@@ -69,10 +69,17 @@ mock.module("../../persistence/conversation-crud.js", () => ({
|
|
|
69
69
|
messageId === ASSISTANT_MESSAGE_ID
|
|
70
70
|
? assistantRow
|
|
71
71
|
: (turnRows.find((row) => row.id === messageId) ?? null),
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
getRecentConversationMessages: (
|
|
73
|
+
_conversationId: string,
|
|
74
|
+
limit: number,
|
|
75
|
+
beforeMessageId?: string,
|
|
76
|
+
) => {
|
|
77
|
+
const history = [...turnRows, ...(assistantRow ? [assistantRow] : [])];
|
|
78
|
+
const end = beforeMessageId
|
|
79
|
+
? history.findIndex((row) => row.id === beforeMessageId)
|
|
80
|
+
: history.length;
|
|
81
|
+
return history.slice(Math.max(0, end - limit), end);
|
|
82
|
+
},
|
|
76
83
|
getMessagesAfter: () => toolResultRows,
|
|
77
84
|
}));
|
|
78
85
|
|