@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
|
@@ -56,11 +56,16 @@ import {
|
|
|
56
56
|
} from "../runtime/sync/resource-sync-events.js";
|
|
57
57
|
import { getLogger } from "../util/logger.js";
|
|
58
58
|
import { withSqliteRetry } from "../util/sqlite-retry.js";
|
|
59
|
+
import {
|
|
60
|
+
hasPersistedCompletionResult,
|
|
61
|
+
notificationConversationId,
|
|
62
|
+
} from "./completion-policy.js";
|
|
59
63
|
import {
|
|
60
64
|
composeConversationSeed,
|
|
61
65
|
isConversationSeedSane,
|
|
62
66
|
} from "./conversation-seed-composer.js";
|
|
63
67
|
import { isGuardianRequestSignalEvent } from "./guardian-feed-projection.js";
|
|
68
|
+
import { signalMirrorsToHomeFeed } from "./home-feed-mirror.js";
|
|
64
69
|
import type { NotificationSignal } from "./signal.js";
|
|
65
70
|
import type {
|
|
66
71
|
ConversationAction,
|
|
@@ -130,7 +135,6 @@ export interface PairingOptions {
|
|
|
130
135
|
* transactional request or a system alert.
|
|
131
136
|
*/
|
|
132
137
|
const ASSISTANT_SHARE_EVENT = "assistant.share";
|
|
133
|
-
const ASSISTANT_REPLY_EVENT = "chat.assistant_reply";
|
|
134
138
|
|
|
135
139
|
/**
|
|
136
140
|
* Promote a background share into an assistant-initiated thread, under the
|
|
@@ -264,17 +268,17 @@ export async function pairDeliveryWithConversation(
|
|
|
264
268
|
// notification can appear. The home feed aims its "Go to Conversation"
|
|
265
269
|
// button at the same row whenever it mirrors the signal.
|
|
266
270
|
//
|
|
267
|
-
//
|
|
268
|
-
//
|
|
271
|
+
// Reply and explicit background completions have their result persisted.
|
|
272
|
+
// Their notification body is a lock-screen preview, so appending it would
|
|
269
273
|
// create a second, truncated assistant row. Keep the conversation target
|
|
270
274
|
// for deep links without writing the preview into the transcript.
|
|
271
275
|
if (
|
|
272
276
|
strategy === "start_new_conversation" &&
|
|
273
277
|
!signal.requiresConversation &&
|
|
274
|
-
signal
|
|
278
|
+
hasPersistedCompletionResult(signal)
|
|
275
279
|
) {
|
|
276
280
|
return {
|
|
277
|
-
conversationId:
|
|
281
|
+
conversationId: resolveSourceConversation(signal)?.id ?? null,
|
|
278
282
|
messageId: null,
|
|
279
283
|
strategy,
|
|
280
284
|
createdNewConversation: false,
|
|
@@ -767,12 +771,16 @@ async function resolveChannelDeliveryHome(params: {
|
|
|
767
771
|
* Indexing is skipped for parity with the other notification write paths:
|
|
768
772
|
* notification copy is delivery audit, not conversational memory.
|
|
769
773
|
*/
|
|
770
|
-
function
|
|
771
|
-
|
|
774
|
+
function resolveSourceConversation(
|
|
775
|
+
signal: NotificationSignal,
|
|
776
|
+
): { id: string; conversationType?: string } | null {
|
|
777
|
+
const conversationId = notificationConversationId(signal);
|
|
778
|
+
if (!conversationId) {
|
|
772
779
|
return null;
|
|
773
780
|
}
|
|
774
781
|
try {
|
|
775
|
-
|
|
782
|
+
const row = getConversation(conversationId);
|
|
783
|
+
return row ? { id: row.id, conversationType: row.conversationType } : null;
|
|
776
784
|
} catch {
|
|
777
785
|
return null;
|
|
778
786
|
}
|
|
@@ -783,14 +791,25 @@ async function appendBodyToSourceConversation(
|
|
|
783
791
|
channel: NotificationChannel,
|
|
784
792
|
messageContent: string,
|
|
785
793
|
): Promise<{ conversationId: string; messageId: string } | null> {
|
|
786
|
-
const
|
|
787
|
-
if (!
|
|
794
|
+
const source = resolveSourceConversation(signal);
|
|
795
|
+
if (!source) {
|
|
788
796
|
return null;
|
|
789
797
|
}
|
|
798
|
+
const conversationId = source.id;
|
|
790
799
|
|
|
791
|
-
const message = await addMessage(
|
|
792
|
-
|
|
793
|
-
|
|
800
|
+
const message = await addMessage(
|
|
801
|
+
conversationId,
|
|
802
|
+
"assistant",
|
|
803
|
+
messageContent,
|
|
804
|
+
{
|
|
805
|
+
skipIndexing: true,
|
|
806
|
+
// A notification the bell carries is bookkeeping about the
|
|
807
|
+
// conversation, not activity in it, so it must not bounce a chat the
|
|
808
|
+
// user just marked Done back into the sidebar. One the bell does not
|
|
809
|
+
// carry has this transcript as its only home, and the chat resurfaces.
|
|
810
|
+
skipResurface: signalMirrorsToHomeFeed(signal, source.conversationType),
|
|
811
|
+
},
|
|
812
|
+
);
|
|
794
813
|
// `addMessage` projects attention metadata alone, so a client with this
|
|
795
814
|
// conversation open needs the messages tag to refetch the transcript. A
|
|
796
815
|
// notification the user taps through to has every chance of landing on an
|
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
intersectChannelAllowlist,
|
|
40
40
|
readChannelAllowlist,
|
|
41
41
|
} from "./channel-allowlist.js";
|
|
42
|
+
import { readCompletionContext } from "./completion-policy.js";
|
|
42
43
|
import {
|
|
43
44
|
buildConversationCandidates,
|
|
44
45
|
type ConversationCandidateSet,
|
|
@@ -81,26 +82,8 @@ const PROMPT_VERSION = "v4";
|
|
|
81
82
|
*/
|
|
82
83
|
const MAX_IDENTITY_CONTEXT_CHARS = 2000;
|
|
83
84
|
|
|
84
|
-
/**
|
|
85
|
-
|
|
86
|
-
* push_only relay that never materializes a conversation, so these signals
|
|
87
|
-
* reach the user exclusively as a push. Adding a channel here widens delivery
|
|
88
|
-
* to it.
|
|
89
|
-
*/
|
|
90
|
-
const ASSISTANT_REPLY_CHANNELS = [
|
|
91
|
-
"platform",
|
|
92
|
-
] as const satisfies readonly NotificationChannel[];
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Delivery scope for `schedule.result` signals. Wider than
|
|
96
|
-
* {@link ASSISTANT_REPLY_CHANNELS} by one channel, and the difference is the
|
|
97
|
-
* point: an unseen chat reply is already sitting in a conversation the user
|
|
98
|
-
* opened, so a push is the only thing it can add. A scheduled run's output has
|
|
99
|
-
* no such home — nobody is looking at the run's conversation — so `vellum`
|
|
100
|
-
* carries it into the notification center where it persists, and `platform`
|
|
101
|
-
* pushes it.
|
|
102
|
-
*/
|
|
103
|
-
const SCHEDULE_RESULT_CHANNELS = [
|
|
85
|
+
/** Completion alerts reach connected clients and registered mobile devices. */
|
|
86
|
+
const COMPLETION_CHANNELS = [
|
|
104
87
|
"vellum",
|
|
105
88
|
"platform",
|
|
106
89
|
] as const satisfies readonly NotificationChannel[];
|
|
@@ -886,6 +869,17 @@ export async function evaluateSignal(
|
|
|
886
869
|
const requestedBody = nonEmpty(
|
|
887
870
|
readPayloadString(signal.contextPayload, "requestedMessage"),
|
|
888
871
|
);
|
|
872
|
+
if (readCompletionContext(signal) && requestedBody) {
|
|
873
|
+
return buildPassThroughDecision({
|
|
874
|
+
signal,
|
|
875
|
+
availableChannels,
|
|
876
|
+
selectedChannels: COMPLETION_CHANNELS.filter((channel) =>
|
|
877
|
+
availableChannels.includes(channel),
|
|
878
|
+
),
|
|
879
|
+
body: requestedBody,
|
|
880
|
+
reasoningSummary: "background_result pass-through",
|
|
881
|
+
});
|
|
882
|
+
}
|
|
889
883
|
if (signal.sourceChannel === "assistant_tool" && requestedBody) {
|
|
890
884
|
const payload = signal.contextPayload as Record<string, unknown>;
|
|
891
885
|
const defaultChannels = selectDefaultChannelsByUrgency(
|
|
@@ -932,12 +926,12 @@ export async function evaluateSignal(
|
|
|
932
926
|
}
|
|
933
927
|
|
|
934
928
|
// Assistant-reply pass-through: the delivery scope is fixed
|
|
935
|
-
// (
|
|
929
|
+
// (COMPLETION_CHANNELS), so the LLM classifier has nothing to decide.
|
|
936
930
|
if (signal.sourceEventName === "chat.assistant_reply" && requestedBody) {
|
|
937
931
|
return buildPassThroughDecision({
|
|
938
932
|
signal,
|
|
939
933
|
availableChannels,
|
|
940
|
-
selectedChannels:
|
|
934
|
+
selectedChannels: COMPLETION_CHANNELS.filter((ch) =>
|
|
941
935
|
availableChannels.includes(ch),
|
|
942
936
|
),
|
|
943
937
|
body: requestedBody,
|
|
@@ -972,7 +966,7 @@ export async function evaluateSignal(
|
|
|
972
966
|
}
|
|
973
967
|
|
|
974
968
|
// Schedule-result pass-through: the body is the run's own reply, which is
|
|
975
|
-
// the whole point of the notification
|
|
969
|
+
// the whole point of the notification: a briefing, a digest, a report. The
|
|
976
970
|
// classifier rewrites bodies into short alerts, which would throw away the
|
|
977
971
|
// content the user set the schedule up to receive. Routing has nothing to
|
|
978
972
|
// decide either: the user asked for this cadence, so it goes to the inbox
|
|
@@ -981,7 +975,7 @@ export async function evaluateSignal(
|
|
|
981
975
|
return buildPassThroughDecision({
|
|
982
976
|
signal,
|
|
983
977
|
availableChannels,
|
|
984
|
-
selectedChannels:
|
|
978
|
+
selectedChannels: COMPLETION_CHANNELS.filter((ch) =>
|
|
985
979
|
availableChannels.includes(ch),
|
|
986
980
|
),
|
|
987
981
|
body: requestedBody,
|
|
@@ -512,7 +512,22 @@ export async function emitNotificationSignal<TEventName extends string>(
|
|
|
512
512
|
}
|
|
513
513
|
|
|
514
514
|
// Step 2.5b: Enforce routing intent policy (fire-time guard).
|
|
515
|
-
// An exclusive allowlist already closed the channel set.
|
|
515
|
+
// An exclusive allowlist already closed the channel set. An access request
|
|
516
|
+
// routed to every channel is delivered even when the decision engine
|
|
517
|
+
// suppressed it (step 2.5c never lets one go undelivered), so it is made
|
|
518
|
+
// deliverable first: routing enforcement leaves a suppressed decision
|
|
519
|
+
// alone, which would leave the request on the in-app card alone.
|
|
520
|
+
if (
|
|
521
|
+
signal.sourceEventName === "ingress.access_request" &&
|
|
522
|
+
signal.routingIntent === "all_channels" &&
|
|
523
|
+
!decision.shouldNotify
|
|
524
|
+
) {
|
|
525
|
+
decision = {
|
|
526
|
+
...decision,
|
|
527
|
+
shouldNotify: true,
|
|
528
|
+
reasoningSummary: `${decision.reasoningSummary} (notify forced: access request routed to all channels)`,
|
|
529
|
+
};
|
|
530
|
+
}
|
|
516
531
|
if (!exclusiveAllowlist) {
|
|
517
532
|
decision = enforceRoutingIntent(
|
|
518
533
|
decision,
|
|
@@ -174,6 +174,7 @@ export function listEvents(
|
|
|
174
174
|
export function hasNotifiedSourceContextSince(
|
|
175
175
|
sourceContextId: string,
|
|
176
176
|
sinceMs: number,
|
|
177
|
+
sourceEventNames?: readonly string[],
|
|
177
178
|
): boolean {
|
|
178
179
|
const db = getDb();
|
|
179
180
|
const row = db
|
|
@@ -194,6 +195,9 @@ export function hasNotifiedSourceContextSince(
|
|
|
194
195
|
and(
|
|
195
196
|
eq(notificationEvents.sourceContextId, sourceContextId),
|
|
196
197
|
gte(notificationEvents.createdAt, sinceMs),
|
|
198
|
+
sourceEventNames
|
|
199
|
+
? inArray(notificationEvents.sourceEventName, [...sourceEventNames])
|
|
200
|
+
: undefined,
|
|
197
201
|
or(
|
|
198
202
|
eq(notificationDecisions.shouldNotify, 0),
|
|
199
203
|
inArray(notificationDeliveries.status, ["pending", "sent"]),
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { Conversation } from "../daemon/conversation.js";
|
|
2
|
+
import {
|
|
3
|
+
allSubagentConversations,
|
|
4
|
+
findConversation,
|
|
5
|
+
} from "../daemon/conversation-registry.js";
|
|
6
|
+
import {
|
|
7
|
+
getSubagentRecordByConversationId,
|
|
8
|
+
getSubagentRecordsByParent,
|
|
9
|
+
} from "../persistence/subagent-store.js";
|
|
10
|
+
import { hasPendingAgentWake } from "../runtime/agent-wake-queue.js";
|
|
11
|
+
import { TERMINAL_STATUSES } from "../subagent/types.js";
|
|
12
|
+
import { hasBackgroundToolWork } from "../tools/background-tool-registry.js";
|
|
13
|
+
import { isUserFacingSubagent, workStartedAfter } from "./completion-work.js";
|
|
14
|
+
|
|
15
|
+
function hasPendingTurn(
|
|
16
|
+
conversation: Conversation | undefined,
|
|
17
|
+
startedAfter?: number,
|
|
18
|
+
): boolean {
|
|
19
|
+
if (!conversation) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
if (
|
|
23
|
+
conversation.isProcessing() &&
|
|
24
|
+
(startedAfter === undefined ||
|
|
25
|
+
conversation.currentTurnWorkOrigins === undefined ||
|
|
26
|
+
conversation.currentTurnWorkOrigins.some((origin) =>
|
|
27
|
+
workStartedAfter(origin, startedAfter),
|
|
28
|
+
))
|
|
29
|
+
) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
if (startedAfter === undefined) {
|
|
33
|
+
return (
|
|
34
|
+
conversation.hasQueuedMessages() ||
|
|
35
|
+
(conversation.pendingQueuedDispatches?.size ?? 0) > 0
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
return (
|
|
39
|
+
conversation
|
|
40
|
+
.snapshotQueuedMessages()
|
|
41
|
+
.some((message) => workStartedAfter(message, startedAfter)) ||
|
|
42
|
+
[...(conversation.pendingQueuedDispatches?.values() ?? [])].some(
|
|
43
|
+
(dispatches) =>
|
|
44
|
+
[...dispatches].some((dispatch) =>
|
|
45
|
+
dispatch.messages.some((message) =>
|
|
46
|
+
workStartedAfter(message, startedAfter),
|
|
47
|
+
),
|
|
48
|
+
),
|
|
49
|
+
)
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** A finished turn can still own delegated work whose result is not ready. */
|
|
54
|
+
export function hasPendingBackgroundWork(
|
|
55
|
+
conversationId: string,
|
|
56
|
+
options?: { startedAfter?: number },
|
|
57
|
+
): boolean {
|
|
58
|
+
const conversation = findConversation(conversationId);
|
|
59
|
+
// Terminal records can retain a live child while its queued follow-ups drain.
|
|
60
|
+
for (const child of allSubagentConversations()) {
|
|
61
|
+
if (
|
|
62
|
+
child.parentConversationId !== conversationId ||
|
|
63
|
+
!hasPendingTurn(child)
|
|
64
|
+
) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const task = getSubagentRecordByConversationId(child.conversationId);
|
|
68
|
+
if (
|
|
69
|
+
task &&
|
|
70
|
+
isUserFacingSubagent(task) &&
|
|
71
|
+
(options?.startedAfter === undefined ||
|
|
72
|
+
task.createdAt >= options.startedAfter)
|
|
73
|
+
) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return (
|
|
78
|
+
hasPendingTurn(conversation, options?.startedAfter) ||
|
|
79
|
+
hasPendingAgentWake(conversationId, undefined, options) ||
|
|
80
|
+
getSubagentRecordsByParent(conversationId, {
|
|
81
|
+
terminalStatuses: [...TERMINAL_STATUSES],
|
|
82
|
+
maxTerminal: 0,
|
|
83
|
+
}).some(
|
|
84
|
+
(task) =>
|
|
85
|
+
isUserFacingSubagent(task) &&
|
|
86
|
+
(options?.startedAfter === undefined ||
|
|
87
|
+
task.createdAt >= options.startedAfter),
|
|
88
|
+
) ||
|
|
89
|
+
hasBackgroundToolWork(conversationId, options)
|
|
90
|
+
);
|
|
91
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { isBackgroundConversationType } from "../persistence/conversation-types.js";
|
|
2
|
+
import { readChannelAllowlist } from "./channel-allowlist.js";
|
|
3
|
+
import { hasCompletionOwnership } from "./completion-policy.js";
|
|
4
|
+
import type { NotificationSignal } from "./signal.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Whether the home feed carries a card for `signal`, judged from the signal
|
|
8
|
+
* and the conversation it names. The feed side effect's mirror decision is
|
|
9
|
+
* this plus two checks only it can make (a guardian request always mirrors;
|
|
10
|
+
* a delivery that materialized an assistant-initiated thread never does).
|
|
11
|
+
*
|
|
12
|
+
* The one other reader is the passive vellum append: a notification the
|
|
13
|
+
* bell carries is bookkeeping about the conversation it is appended to, so
|
|
14
|
+
* that append must not resurface a Done chat, while a notification the bell
|
|
15
|
+
* does not carry has the transcript as its only home and must.
|
|
16
|
+
*
|
|
17
|
+
* Recipient-owned completions never mirror: the feed has no recipient ACL.
|
|
18
|
+
* Other `assistant_tool` signals mirror because the documented
|
|
19
|
+
* `notifications send` skill (and background-job failure emits) deliberately
|
|
20
|
+
* target the home feed, unless an exclusive channel allowlist leaves vellum
|
|
21
|
+
* out; `chat.assistant_reply` follows the same rule. An async-background
|
|
22
|
+
* hint or a background-typed source conversation mirrors as well.
|
|
23
|
+
*/
|
|
24
|
+
export function signalMirrorsToHomeFeed(
|
|
25
|
+
signal: NotificationSignal,
|
|
26
|
+
sourceConversationType: string | undefined,
|
|
27
|
+
): boolean {
|
|
28
|
+
if (hasCompletionOwnership(signal)) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
if (
|
|
32
|
+
signal.sourceChannel === "assistant_tool" ||
|
|
33
|
+
signal.sourceEventName === "chat.assistant_reply"
|
|
34
|
+
) {
|
|
35
|
+
const allowlist = readChannelAllowlist(signal.contextPayload);
|
|
36
|
+
if (!allowlist || allowlist.includes("vellum")) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (signal.attentionHints.isAsyncBackground) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
return isBackgroundConversationType(sourceConversationType);
|
|
44
|
+
}
|
|
@@ -15,6 +15,8 @@ import {
|
|
|
15
15
|
type FeedItemCategory,
|
|
16
16
|
type FeedItemDetailPanelKind,
|
|
17
17
|
feedItemSchema,
|
|
18
|
+
type FeedItemUpdate,
|
|
19
|
+
feedItemUpdateSchema,
|
|
18
20
|
} from "../home/feed-types.js";
|
|
19
21
|
import { appendFeedItem } from "../home/feed-writer.js";
|
|
20
22
|
import {
|
|
@@ -23,14 +25,11 @@ import {
|
|
|
23
25
|
getMessageById,
|
|
24
26
|
updateMessageContent,
|
|
25
27
|
} from "../persistence/conversation-crud.js";
|
|
26
|
-
import {
|
|
27
|
-
ASSISTANT_INITIATED_SOURCE,
|
|
28
|
-
isBackgroundConversationType,
|
|
29
|
-
} from "../persistence/conversation-types.js";
|
|
28
|
+
import { ASSISTANT_INITIATED_SOURCE } from "../persistence/conversation-types.js";
|
|
30
29
|
import { publishConversationMessagesChanged } from "../runtime/sync/resource-sync-events.js";
|
|
31
30
|
import { getLogger } from "../util/logger.js";
|
|
31
|
+
import { isPlainObject } from "../util/object.js";
|
|
32
32
|
import { normalizeTitle, stripMarkdown } from "../util/short-title.js";
|
|
33
|
-
import { readChannelAllowlist } from "./channel-allowlist.js";
|
|
34
33
|
import { isConversationSeedSane } from "./conversation-seed-composer.js";
|
|
35
34
|
import { deriveTitle } from "./copy-composer.js";
|
|
36
35
|
import {
|
|
@@ -39,6 +38,7 @@ import {
|
|
|
39
38
|
isGuardianRequestSignalEvent,
|
|
40
39
|
receiptGuardianFeedItemIfRequestTerminal,
|
|
41
40
|
} from "./guardian-feed-projection.js";
|
|
41
|
+
import { signalMirrorsToHomeFeed } from "./home-feed-mirror.js";
|
|
42
42
|
import { readPayloadString } from "./notification-utils.js";
|
|
43
43
|
import type { NotificationSignal } from "./signal.js";
|
|
44
44
|
import type {
|
|
@@ -65,6 +65,30 @@ const log = getLogger("home-feed-side-effect");
|
|
|
65
65
|
*/
|
|
66
66
|
const CONVERSATION_MESSAGE_ID_KEY = "notificationConversationMessageId";
|
|
67
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Payload key a skill-update receipt carries its entries under. Read here
|
|
70
|
+
* through the wire schema and mapped onto the item's typed `updates`, so the
|
|
71
|
+
* panel the client opens is decided by the shape, never by copy.
|
|
72
|
+
*/
|
|
73
|
+
const UPDATES_KEY = "updates";
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The receipt entries in `contextPayload`, when it carries a non-empty list
|
|
77
|
+
* that parses as the wire shape; otherwise undefined, and the item renders
|
|
78
|
+
* as an ordinary notification. A malformed list is dropped rather than
|
|
79
|
+
* mirrored, since a client would render whatever survived.
|
|
80
|
+
*/
|
|
81
|
+
function readUpdates(contextPayload: unknown): FeedItemUpdate[] | undefined {
|
|
82
|
+
if (!isPlainObject(contextPayload)) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
const parsed = feedItemUpdateSchema
|
|
86
|
+
.array()
|
|
87
|
+
.min(1)
|
|
88
|
+
.safeParse(contextPayload[UPDATES_KEY]);
|
|
89
|
+
return parsed.success ? parsed.data : undefined;
|
|
90
|
+
}
|
|
91
|
+
|
|
68
92
|
/**
|
|
69
93
|
* Append a `FeedItem` for the given notification signal when the
|
|
70
94
|
* filter criteria pass.
|
|
@@ -106,12 +130,19 @@ export async function writeHomeFeedItemForSignal(
|
|
|
106
130
|
readPayloadString(signal.contextPayload, "body") ??
|
|
107
131
|
readPayloadString(signal.contextPayload, "requestedMessage");
|
|
108
132
|
|
|
133
|
+
// A receipt's summary is the producer's own list of what changed, which
|
|
134
|
+
// the panel renders from the typed entries and a client without the panel
|
|
135
|
+
// reads as-is. Model copy is not allowed to rewrite it: a paraphrase can
|
|
136
|
+
// drop an entry, and the list is the receipt's whole point.
|
|
137
|
+
const updates = readUpdates(signal.contextPayload);
|
|
138
|
+
|
|
109
139
|
// Prefer conversationSeedMessage over body for the home feed: the seed
|
|
110
140
|
// message is richer and may contain structured markdown (lists, headers,
|
|
111
141
|
// bold) that the detail panel renders. The popup-oriented `body` is
|
|
112
142
|
// intentionally short (≤ 2 sentences) and loses formatting.
|
|
113
143
|
const seedCandidate = renderedCopy?.conversationSeedMessage;
|
|
114
144
|
const resolvedSummary =
|
|
145
|
+
(updates ? payloadBody?.trim() : undefined) ||
|
|
115
146
|
(isConversationSeedSane(seedCandidate)
|
|
116
147
|
? seedCandidate.trim()
|
|
117
148
|
: undefined) ||
|
|
@@ -146,7 +177,7 @@ export async function writeHomeFeedItemForSignal(
|
|
|
146
177
|
const now = new Date().toISOString();
|
|
147
178
|
|
|
148
179
|
const category = deriveCategory(signal);
|
|
149
|
-
const panelKind = deriveDetailPanelKind(signal);
|
|
180
|
+
const panelKind = updates ? "updatesList" : deriveDetailPanelKind(signal);
|
|
150
181
|
|
|
151
182
|
const baseMetadata =
|
|
152
183
|
signal.contextPayload &&
|
|
@@ -157,6 +188,9 @@ export async function writeHomeFeedItemForSignal(
|
|
|
157
188
|
// Producer payloads reach the card verbatim, and this key addresses a
|
|
158
189
|
// message row for rewriting, so only this module may set it.
|
|
159
190
|
delete baseMetadata?.[CONVERSATION_MESSAGE_ID_KEY];
|
|
191
|
+
// The entries ride on the item as its typed `updates`, not in the
|
|
192
|
+
// free-form bag, so a client reads them from one place.
|
|
193
|
+
delete baseMetadata?.[UPDATES_KEY];
|
|
160
194
|
|
|
161
195
|
// Link scheduled-run notifications back to their schedule. `notify`-mode
|
|
162
196
|
// jobs put `scheduleId` directly in the context payload; `execute`-mode (and
|
|
@@ -205,6 +239,7 @@ export async function writeHomeFeedItemForSignal(
|
|
|
205
239
|
...(urgency ? { urgency } : {}),
|
|
206
240
|
...(sourceConversationId ? { conversationId: sourceConversationId } : {}),
|
|
207
241
|
...(panelKind ? { detailPanel: { kind: panelKind } } : {}),
|
|
242
|
+
...(updates ? { updates } : {}),
|
|
208
243
|
...(metadata ? { metadata } : {}),
|
|
209
244
|
};
|
|
210
245
|
|
|
@@ -322,6 +357,10 @@ async function appendSummaryToFeedTarget(
|
|
|
322
357
|
try {
|
|
323
358
|
const message = await addMessage(conversationId, "assistant", summary, {
|
|
324
359
|
skipIndexing: true,
|
|
360
|
+
// The body is bookkeeping about the conversation, not activity in it:
|
|
361
|
+
// a receipt for work the conversation already saw must not bounce a
|
|
362
|
+
// chat the user just marked Done back into the sidebar.
|
|
363
|
+
skipResurface: true,
|
|
325
364
|
});
|
|
326
365
|
publishConversationMessagesChanged(conversationId);
|
|
327
366
|
log.info(
|
|
@@ -496,7 +535,8 @@ function deriveDetailPanelKind(
|
|
|
496
535
|
* (scheduler job ids, watcher event ids, CLI tool-call ids) leave
|
|
497
536
|
* `sourceConversationId` undefined so the client hides the affordance.
|
|
498
537
|
*
|
|
499
|
-
*
|
|
538
|
+
* Recipient-owned completions are excluded by `signalMirrorsToHomeFeed`.
|
|
539
|
+
* Other `assistant_tool` signals mirror because the documented
|
|
500
540
|
* `notifications send` skill (and background-job failure emits) deliberately
|
|
501
541
|
* does not require a background-typed conversation or the
|
|
502
542
|
* `isAsyncBackground` hint. `chat.assistant_reply` also mirrors: it is the
|
|
@@ -527,20 +567,18 @@ function resolveHomeFeedMirror(
|
|
|
527
567
|
conversationType?: string;
|
|
528
568
|
scheduleJobId?: string | null;
|
|
529
569
|
} | null = null;
|
|
530
|
-
|
|
570
|
+
const conversationId = signal.sourceContextId;
|
|
571
|
+
if (conversationId) {
|
|
531
572
|
try {
|
|
532
|
-
sourceRow = getConversation(
|
|
573
|
+
sourceRow = getConversation(conversationId) ?? null;
|
|
533
574
|
} catch {
|
|
534
575
|
sourceRow = null;
|
|
535
576
|
}
|
|
536
577
|
}
|
|
537
|
-
//
|
|
538
|
-
//
|
|
539
|
-
// since that's where the work actually happened. Fall back to the paired
|
|
540
|
-
// delivery conversation only when the source context didn't resolve —
|
|
541
|
-
// covers producers whose `sourceContextId` is a sentinel string.
|
|
578
|
+
// Link to the producing conversation when it exists.
|
|
579
|
+
// Signals with non-conversation source IDs use the paired delivery.
|
|
542
580
|
const sourceConversationId = sourceRow
|
|
543
|
-
?
|
|
581
|
+
? conversationId
|
|
544
582
|
: fallbackConversationId;
|
|
545
583
|
const sourceScheduleJobId = sourceRow?.scheduleJobId ?? undefined;
|
|
546
584
|
|
|
@@ -553,19 +591,7 @@ function resolveHomeFeedMirror(
|
|
|
553
591
|
if (isAssistantInitiatedThreadDelivery(fallbackConversationId)) {
|
|
554
592
|
return { mirror: false };
|
|
555
593
|
}
|
|
556
|
-
if (
|
|
557
|
-
signal.sourceChannel === "assistant_tool" ||
|
|
558
|
-
signal.sourceEventName === "chat.assistant_reply"
|
|
559
|
-
) {
|
|
560
|
-
const allowlist = readChannelAllowlist(signal.contextPayload);
|
|
561
|
-
if (!allowlist || allowlist.includes("vellum")) {
|
|
562
|
-
return { mirror: true, sourceConversationId, sourceScheduleJobId };
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
if (signal.attentionHints.isAsyncBackground) {
|
|
566
|
-
return { mirror: true, sourceConversationId, sourceScheduleJobId };
|
|
567
|
-
}
|
|
568
|
-
if (isBackgroundConversationType(sourceRow?.conversationType)) {
|
|
594
|
+
if (signalMirrorsToHomeFeed(signal, sourceRow?.conversationType)) {
|
|
569
595
|
return { mirror: true, sourceConversationId, sourceScheduleJobId };
|
|
570
596
|
}
|
|
571
597
|
return { mirror: false };
|
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
import type pino from "pino";
|
|
18
18
|
|
|
19
19
|
import { isAssistantFeatureFlagEnabled } from "../config/assistant-feature-flags.js";
|
|
20
|
+
import {
|
|
21
|
+
getGuardianDelivery,
|
|
22
|
+
guardianForChannel,
|
|
23
|
+
} from "../contacts/guardian-delivery-reader.js";
|
|
20
24
|
import { isWebConversationFocused } from "../runtime/web-presence.js";
|
|
21
25
|
import { getLogger } from "../util/logger.js";
|
|
22
26
|
|
|
@@ -27,6 +31,7 @@ const log = getLogger("notification-source-active");
|
|
|
27
31
|
export interface ResolveVisibleInSourceOptions {
|
|
28
32
|
conversationId: string | undefined;
|
|
29
33
|
logger?: pino.Logger;
|
|
34
|
+
actorPrincipalId?: string;
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
/**
|
|
@@ -37,15 +42,64 @@ export interface ResolveVisibleInSourceOptions {
|
|
|
37
42
|
export function resolveVisibleInSourceNow(
|
|
38
43
|
options: ResolveVisibleInSourceOptions,
|
|
39
44
|
): boolean {
|
|
40
|
-
const { conversationId
|
|
45
|
+
const { conversationId } = options;
|
|
41
46
|
if (!conversationId) {
|
|
42
47
|
return false;
|
|
43
48
|
}
|
|
44
49
|
if (!isAssistantFeatureFlagEnabled(ACTIVITY_PRESENCE_FLAG)) {
|
|
45
50
|
return false;
|
|
46
51
|
}
|
|
52
|
+
return readConversationPresence(options);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Completion alerts suppress only for the recipient watching their result. */
|
|
56
|
+
export async function resolveCompletionVisibleInSourceNow(
|
|
57
|
+
options: ResolveVisibleInSourceOptions,
|
|
58
|
+
): Promise<boolean> {
|
|
59
|
+
if (
|
|
60
|
+
!options.conversationId ||
|
|
61
|
+
!isAssistantFeatureFlagEnabled("web-presence-suppression")
|
|
62
|
+
) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
const actorPrincipalId =
|
|
66
|
+
options.actorPrincipalId ??
|
|
67
|
+
(await resolveCompletionRecipientPrincipalId(options.logger));
|
|
68
|
+
return actorPrincipalId
|
|
69
|
+
? readConversationPresence({ ...options, actorPrincipalId })
|
|
70
|
+
: false;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The same active guardian identity the local completion delivery targets. */
|
|
74
|
+
export async function resolveCompletionRecipientPrincipalId(
|
|
75
|
+
logger?: pino.Logger,
|
|
76
|
+
): Promise<string | undefined> {
|
|
77
|
+
try {
|
|
78
|
+
const guardians = await getGuardianDelivery();
|
|
79
|
+
return guardians
|
|
80
|
+
? (guardianForChannel(guardians, "vellum")?.principalId ?? undefined)
|
|
81
|
+
: undefined;
|
|
82
|
+
} catch (err) {
|
|
83
|
+
(logger ?? log).warn(
|
|
84
|
+
{ err },
|
|
85
|
+
"Completion recipient read failed; treating as unfocused",
|
|
86
|
+
);
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function readConversationPresence({
|
|
92
|
+
conversationId,
|
|
93
|
+
logger,
|
|
94
|
+
actorPrincipalId,
|
|
95
|
+
}: ResolveVisibleInSourceOptions): boolean {
|
|
96
|
+
if (!conversationId) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
47
99
|
try {
|
|
48
|
-
return
|
|
100
|
+
return actorPrincipalId
|
|
101
|
+
? isWebConversationFocused(conversationId, { actorPrincipalId })
|
|
102
|
+
: isWebConversationFocused(conversationId);
|
|
49
103
|
} catch (err) {
|
|
50
104
|
(logger ?? log).warn(
|
|
51
105
|
{ err },
|