@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
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Vellum channel adapter
|
|
2
|
+
* Vellum channel adapter: delivers notifications to connected desktop
|
|
3
3
|
* and mobile clients via the daemon's event broadcast mechanism.
|
|
4
4
|
*
|
|
5
5
|
* The adapter broadcasts a `notification_intent` message that the client
|
|
6
6
|
* turns into an OS notification (`use-notification-intent-sync.ts` in the
|
|
7
|
-
* web client, which every first-party app runs).
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* work) without a banner.
|
|
11
|
-
* Urgent signals (`high`/`critical`) broadcast with `silent: false` and
|
|
12
|
-
* banner.
|
|
7
|
+
* web client, which every first-party app runs). Completion alerts and urgent
|
|
8
|
+
* signals may banner. Other low/medium signals reach their conversation and
|
|
9
|
+
* feed without a banner. The broadcaster owns this presentation policy.
|
|
13
10
|
*
|
|
14
11
|
* Guardian-sensitive notifications (approval requests, access requests)
|
|
15
12
|
* are delivered only to connections authenticated as the guardian: the hub
|
|
16
13
|
* matches `targetActorPrincipalId` against each connection's verified
|
|
17
14
|
* principal, so no other connection ever receives the title and body. The
|
|
18
|
-
* payload's `targetGuardianPrincipalId`
|
|
15
|
+
* payload's `targetGuardianPrincipalId` marks guardian-sensitive content for
|
|
16
|
+
* clients that enforce the legacy guardian compatibility gate.
|
|
17
|
+
* Completion previews require the same recipient scoping; an unresolved
|
|
18
|
+
* recipient fails delivery before any preview is broadcast.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
import type { AssistantEvent } from "../../api/index.js";
|
|
@@ -24,6 +24,12 @@ import { updateMessageContent } from "../../persistence/conversation-crud.js";
|
|
|
24
24
|
import type { BroadcastMessageOptions } from "../../runtime/assistant-event-hub.js";
|
|
25
25
|
import { publishConversationMessagesChanged } from "../../runtime/sync/resource-sync-events.js";
|
|
26
26
|
import { getLogger } from "../../util/logger.js";
|
|
27
|
+
import {
|
|
28
|
+
isCompletionNotification,
|
|
29
|
+
isCompletionRecipientUnavailable,
|
|
30
|
+
isLocalNotificationSilent,
|
|
31
|
+
resolveCompletionRecipient,
|
|
32
|
+
} from "../completion-policy.js";
|
|
27
33
|
import type {
|
|
28
34
|
ChannelAdapter,
|
|
29
35
|
ChannelDeliveryPayload,
|
|
@@ -86,9 +92,15 @@ export class VellumAdapter implements ChannelAdapter {
|
|
|
86
92
|
guardianPrincipalId && isGuardianSensitiveEvent(payload.sourceEventName)
|
|
87
93
|
? guardianPrincipalId
|
|
88
94
|
: undefined;
|
|
95
|
+
const targetActorPrincipalId = isCompletionNotification(payload)
|
|
96
|
+
? resolveCompletionRecipient(payload, destination)
|
|
97
|
+
: targetGuardianPrincipalId;
|
|
89
98
|
|
|
90
|
-
|
|
91
|
-
|
|
99
|
+
if (isCompletionRecipientUnavailable(payload, destination)) {
|
|
100
|
+
return { success: false, error: "completion recipient unavailable" };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const silent = payload.silent ?? isLocalNotificationSilent(payload);
|
|
92
104
|
const assistantName = getAssistantName()?.trim() || undefined;
|
|
93
105
|
|
|
94
106
|
this.broadcast(
|
|
@@ -107,14 +119,14 @@ export class VellumAdapter implements ChannelAdapter {
|
|
|
107
119
|
remotePushPlatforms: payload.remotePushPlatforms,
|
|
108
120
|
},
|
|
109
121
|
undefined,
|
|
110
|
-
{ targetActorPrincipalId
|
|
122
|
+
{ targetActorPrincipalId },
|
|
111
123
|
);
|
|
112
124
|
|
|
113
125
|
log.info(
|
|
114
126
|
{
|
|
115
127
|
sourceEventName: payload.sourceEventName,
|
|
116
128
|
title: payload.copy.title,
|
|
117
|
-
|
|
129
|
+
recipientScoped: targetActorPrincipalId != null,
|
|
118
130
|
silent,
|
|
119
131
|
},
|
|
120
132
|
"Vellum notification intent broadcast",
|
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
* notification out to registered device tokens for the bound user. Provider
|
|
7
7
|
* feature gates return 202 with `{ skipped: "flag_off" }` when no provider runs.
|
|
8
8
|
*
|
|
9
|
-
* Guardian-sensitive notifications
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* Guardian-sensitive notifications and completion previews include the
|
|
10
|
+
* resolved guardian principal so the platform can scope native fan-out.
|
|
11
|
+
* Explicitly owned background completions require that principal to match.
|
|
12
|
+
* Ordinary replies and scheduled results retain platform-owner delivery
|
|
13
|
+
* when the guardian lookup is unavailable.
|
|
12
14
|
*/
|
|
13
15
|
|
|
14
16
|
import { VellumPlatformClient } from "../../platform/client.js";
|
|
@@ -18,6 +20,11 @@ import {
|
|
|
18
20
|
isRetryableStatus,
|
|
19
21
|
sleep,
|
|
20
22
|
} from "../../util/retry.js";
|
|
23
|
+
import {
|
|
24
|
+
isCompletionNotification,
|
|
25
|
+
isCompletionRecipientUnavailable,
|
|
26
|
+
resolveCompletionRecipient,
|
|
27
|
+
} from "../completion-policy.js";
|
|
21
28
|
import {
|
|
22
29
|
describeMedia,
|
|
23
30
|
mediaEmbeds,
|
|
@@ -107,6 +114,9 @@ export class PlatformPushAdapter implements ChannelAdapter {
|
|
|
107
114
|
destination: ChannelDestination,
|
|
108
115
|
observer?: ChannelDeliveryObserver,
|
|
109
116
|
): Promise<DeliveryResult> {
|
|
117
|
+
if (isCompletionRecipientUnavailable(payload, destination)) {
|
|
118
|
+
return { success: false, error: "completion recipient unavailable" };
|
|
119
|
+
}
|
|
110
120
|
const client = await VellumPlatformClient.create();
|
|
111
121
|
if (!client) {
|
|
112
122
|
log.warn(
|
|
@@ -129,8 +139,9 @@ export class PlatformPushAdapter implements ChannelAdapter {
|
|
|
129
139
|
? destination.metadata.guardianPrincipalId
|
|
130
140
|
: undefined;
|
|
131
141
|
|
|
132
|
-
const targetGuardianPrincipalId =
|
|
133
|
-
|
|
142
|
+
const targetGuardianPrincipalId = isCompletionNotification(payload)
|
|
143
|
+
? resolveCompletionRecipient(payload, destination)
|
|
144
|
+
: guardianPrincipalId && isGuardianSensitiveEvent(payload.sourceEventName)
|
|
134
145
|
? guardianPrincipalId
|
|
135
146
|
: undefined;
|
|
136
147
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `chat.assistant_reply` producer
|
|
3
|
-
* is no longer looking at.
|
|
2
|
+
* `chat.assistant_reply` producer for a finished reply the user is not watching.
|
|
4
3
|
*
|
|
5
4
|
* Called at the end of a user-initiated turn (see
|
|
6
5
|
* `daemon/conversation-turn-finalize.ts`) and best-effort throughout: every
|
|
@@ -11,6 +10,7 @@
|
|
|
11
10
|
import type pino from "pino";
|
|
12
11
|
|
|
13
12
|
import { isAssistantFeatureFlagEnabled } from "../config/assistant-feature-flags.js";
|
|
13
|
+
import { isToolResultOnlyUserMessage } from "../conversations/message-consolidation.js";
|
|
14
14
|
import { getAttachmentMetadataForMessage } from "../persistence/attachments-store.js";
|
|
15
15
|
import {
|
|
16
16
|
getAttentionStateByConversationIds,
|
|
@@ -20,20 +20,22 @@ import {
|
|
|
20
20
|
type ConversationRow,
|
|
21
21
|
getConversation,
|
|
22
22
|
getMessageById,
|
|
23
|
+
getRecentConversationMessages,
|
|
24
|
+
type MessageRow,
|
|
23
25
|
parseMessageMetadata,
|
|
24
26
|
} from "../persistence/conversation-crud.js";
|
|
25
27
|
import { isReplaceableTitle } from "../persistence/conversation-title-placeholders.js";
|
|
26
28
|
import {
|
|
27
|
-
|
|
29
|
+
isEchoSuppressedUserMessage,
|
|
28
30
|
isReplyPushIneligibleUserMessage,
|
|
29
31
|
resolveConversationKind,
|
|
30
32
|
} from "../persistence/conversation-types.js";
|
|
31
33
|
import { stringifyMessageContent } from "../persistence/message-content.js";
|
|
32
34
|
import { projectPersistedAssistantContent } from "../persistence/user-facing-content.js";
|
|
33
|
-
import { isDesktopAttended } from "../runtime/desktop-presence.js";
|
|
34
|
-
import { isWebConversationFocused } from "../runtime/web-presence.js";
|
|
35
35
|
import { safeParseRecord } from "../util/json.js";
|
|
36
|
+
import { workStartedAfter } from "./completion-work.js";
|
|
36
37
|
import { emitNotificationSignal } from "./emit-signal.js";
|
|
38
|
+
import { hasPendingBackgroundWork } from "./has-pending-background-work.js";
|
|
37
39
|
import {
|
|
38
40
|
describeMedia,
|
|
39
41
|
mediaEmbeds,
|
|
@@ -42,12 +44,62 @@ import {
|
|
|
42
44
|
sanitizeNotificationTitle,
|
|
43
45
|
stripMarkdownForPreview,
|
|
44
46
|
} from "./notification-utils.js";
|
|
47
|
+
import { resolveCompletionVisibleInSourceNow } from "./resolve-visible-in-source.js";
|
|
48
|
+
import { collectRunRows } from "./result-output.js";
|
|
45
49
|
|
|
46
50
|
/** Kill switch for this producer, on by default. */
|
|
47
51
|
const ASSISTANT_REPLY_PUSH_FLAG = "assistant-reply-push" as const;
|
|
52
|
+
const REPLY_HISTORY_PAGE_SIZE = 200;
|
|
48
53
|
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
function isCurrentUnseenReply(
|
|
55
|
+
conversationId: string,
|
|
56
|
+
assistantRow: MessageRow,
|
|
57
|
+
turnBoundaryId: string,
|
|
58
|
+
startedAfter: number,
|
|
59
|
+
): boolean {
|
|
60
|
+
const attention = getAttentionStateByConversationIds([conversationId]).get(
|
|
61
|
+
conversationId,
|
|
62
|
+
);
|
|
63
|
+
if (
|
|
64
|
+
!hasUnseenLatestAssistantMessage(attention) ||
|
|
65
|
+
assistantRow.createdAt <=
|
|
66
|
+
(attention?.lastSeenAssistantMessageAt ?? -Infinity)
|
|
67
|
+
) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
let beforeMessageId: string | undefined;
|
|
71
|
+
let foundReply = false;
|
|
72
|
+
let foundLatestAttention = false;
|
|
73
|
+
// A same-turn private wrap-up can own attention while the public reply is earlier.
|
|
74
|
+
// Persisted turn boundaries also supersede replies whose projection is delayed.
|
|
75
|
+
while (true) {
|
|
76
|
+
const history = getRecentConversationMessages(
|
|
77
|
+
conversationId,
|
|
78
|
+
REPLY_HISTORY_PAGE_SIZE,
|
|
79
|
+
beforeMessageId,
|
|
80
|
+
);
|
|
81
|
+
for (let index = history.length - 1; index >= 0; index--) {
|
|
82
|
+
const row = history[index];
|
|
83
|
+
foundReply ||= row.id === assistantRow.id;
|
|
84
|
+
foundLatestAttention ||= row.id === attention?.latestAssistantMessageId;
|
|
85
|
+
if (row.role === "user" && !isToolResultOnlyUserMessage(row)) {
|
|
86
|
+
const metadata = readSuppressionMarkers(row.metadata);
|
|
87
|
+
if (
|
|
88
|
+
row.id !== turnBoundaryId &&
|
|
89
|
+
isEchoSuppressedUserMessage(metadata) &&
|
|
90
|
+
!workStartedAfter({ sentAt: row.createdAt, metadata }, startedAfter)
|
|
91
|
+
) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
return row.id === turnBoundaryId && foundReply && foundLatestAttention;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (history.length < REPLY_HISTORY_PAGE_SIZE) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
beforeMessageId = history[0].id;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
51
103
|
|
|
52
104
|
/**
|
|
53
105
|
* Flatten a title onto one line. Notification titles cannot wrap, and
|
|
@@ -116,44 +168,6 @@ function readSuppressionMarkers(
|
|
|
116
168
|
return metadataJson ? safeParseRecord(metadataJson) : undefined;
|
|
117
169
|
}
|
|
118
170
|
|
|
119
|
-
/**
|
|
120
|
-
* Desktop attendance, kept fail-open here: a presence read that fails has to
|
|
121
|
-
* send the push, not reach the producer's catch and silence it.
|
|
122
|
-
*
|
|
123
|
-
* No `actorPrincipalId`: the platform delivers this push to the assistant
|
|
124
|
-
* owner's device tokens, and a pod has exactly one owner, so any attended
|
|
125
|
-
* desktop client is that owner's.
|
|
126
|
-
*/
|
|
127
|
-
function readDesktopAttended(rlog: pino.Logger): boolean {
|
|
128
|
-
try {
|
|
129
|
-
return isDesktopAttended();
|
|
130
|
-
} catch (err) {
|
|
131
|
-
rlog.warn({ err }, "Desktop presence read failed; treating as unattended");
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Web presence, kept fail-open here for the same reason as
|
|
138
|
-
* {@link readDesktopAttended}: a presence read that fails has to send the
|
|
139
|
-
* push, not reach the producer's catch and silence it.
|
|
140
|
-
*
|
|
141
|
-
* No `actorPrincipalId`: the platform delivers this push to the assistant
|
|
142
|
-
* owner's device tokens, and a pod has exactly one owner, so any focused web
|
|
143
|
-
* tab is that owner's.
|
|
144
|
-
*/
|
|
145
|
-
function readWebConversationFocused(
|
|
146
|
-
conversationId: string,
|
|
147
|
-
rlog: pino.Logger,
|
|
148
|
-
): boolean {
|
|
149
|
-
try {
|
|
150
|
-
return isWebConversationFocused(conversationId);
|
|
151
|
-
} catch (err) {
|
|
152
|
-
rlog.warn({ err }, "Web presence read failed; treating as unfocused");
|
|
153
|
-
return false;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
171
|
export async function emitAssistantReplyNotification(params: {
|
|
158
172
|
conversationId: string;
|
|
159
173
|
assistantMessageId: string;
|
|
@@ -221,6 +235,26 @@ export async function emitAssistantReplyNotification(params: {
|
|
|
221
235
|
) {
|
|
222
236
|
return;
|
|
223
237
|
}
|
|
238
|
+
let turnBoundaryId = userMessageId;
|
|
239
|
+
if (initiatingMetadata?.turnOutcome === "batched") {
|
|
240
|
+
if (
|
|
241
|
+
typeof initiatingMetadata.turnBatchedInto !== "string" ||
|
|
242
|
+
!initiatingMetadata.turnBatchedInto
|
|
243
|
+
) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
turnBoundaryId = initiatingMetadata.turnBatchedInto;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const firstAssistantRow = collectRunRows(
|
|
250
|
+
assistantRow,
|
|
251
|
+
conversationId,
|
|
252
|
+
initiatingMessage.createdAt,
|
|
253
|
+
)[0];
|
|
254
|
+
const startedAfter = firstAssistantRow?.createdAt ?? assistantRow.createdAt;
|
|
255
|
+
if (hasPendingBackgroundWork(conversationId, { startedAfter })) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
224
258
|
|
|
225
259
|
// A reply whose output is entirely media has no text to preview, so name
|
|
226
260
|
// the media rather than suppressing a real reply. Markdown is flattened
|
|
@@ -256,21 +290,21 @@ export async function emitAssistantReplyNotification(params: {
|
|
|
256
290
|
? ""
|
|
257
291
|
: sanitizeNotificationTitle(flattenTitleWhitespace(storedTitle));
|
|
258
292
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
293
|
+
const visibleInSourceNow = await resolveCompletionVisibleInSourceNow({
|
|
294
|
+
conversationId,
|
|
295
|
+
logger: rlog,
|
|
296
|
+
});
|
|
297
|
+
if (
|
|
298
|
+
hasPendingBackgroundWork(conversationId, { startedAfter }) ||
|
|
299
|
+
!isCurrentUnseenReply(
|
|
300
|
+
conversationId,
|
|
301
|
+
assistantRow,
|
|
302
|
+
turnBoundaryId,
|
|
303
|
+
startedAfter,
|
|
304
|
+
)
|
|
305
|
+
) {
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
274
308
|
|
|
275
309
|
await emitNotificationSignal({
|
|
276
310
|
sourceEventName: "chat.assistant_reply",
|
|
@@ -280,24 +314,15 @@ export async function emitAssistantReplyNotification(params: {
|
|
|
280
314
|
sourceContextId: conversationId,
|
|
281
315
|
attentionHints: {
|
|
282
316
|
requiresAction: false,
|
|
283
|
-
// Load-bearing for the iOS-only scope: `emit-signal.ts` force-adds the
|
|
284
|
-
// vellum channel for high/critical signals, which would widen this into
|
|
285
|
-
// an in-app banner on every client. Raising the urgency is the same as
|
|
286
|
-
// opting into v2.
|
|
287
317
|
urgency: "medium",
|
|
288
318
|
isAsyncBackground: false,
|
|
289
|
-
|
|
290
|
-
// or focused web tab that opened the turn renders the reply in-app,
|
|
291
|
-
// so a redundant push would only duplicate what's already on screen.
|
|
292
|
-
visibleInSourceNow: desktopAttended || webFocused,
|
|
319
|
+
visibleInSourceNow,
|
|
293
320
|
},
|
|
294
321
|
contextPayload: {
|
|
295
322
|
...(requestedTitle ? { requestedTitle } : {}),
|
|
296
323
|
requestedMessage: preview,
|
|
297
324
|
},
|
|
298
|
-
//
|
|
299
|
-
// has to carry the message id or a second reply within the hour is
|
|
300
|
-
// silently dropped.
|
|
325
|
+
// Each persisted reply owns its notification claim independently.
|
|
301
326
|
dedupeKey: `chat.assistant_reply:${conversationId}:${assistantMessageId}`,
|
|
302
327
|
});
|
|
303
328
|
} catch (err) {
|