Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

Merge remote-tracking branch 'origin/dev' into feat/678-desktop-upload-documents

Alfredo Lopezcf6bc2aca701
diff --cc desktop-app/src/ipc.ts
index 6169c1b8d,436abdaa3..0f1c2623b
--- a/desktop-app/src/ipc.ts
+++ b/desktop-app/src/ipc.ts
@@@ -23,9 -27,10 +27,11 @@@ import
PLUGIN_SDK_REQUEST_CHANNEL,
} from './pluginSdkProtocol.js'
import {
+ type ChatAuthorityScope,
+ type ChatDeleteFence,
DesktopRuntimeConfig,
HostActivityStreamEvent,
+ HostMessageAttachment,
HostMessageRequest,
HostStatusStreamEvent,
TaskProgressStreamEvent,
diff --cc desktop-app/ui/src/contexts/AgentChatActionsContext/types.ts
index 070d0e30b,be847729f..3b9102f19
--- a/desktop-app/ui/src/contexts/AgentChatActionsContext/types.ts
+++ b/desktop-app/ui/src/contexts/AgentChatActionsContext/types.ts
@@@ -1,10 -1,13 +1,17 @@@
import type { ReactNode, RefObject } from 'react'
+ import type { ChatDeleteFence } from '../../../../src/types'
-import type { ComposerImageAttachment, ComposerReferenceAttachment } from '../../uiTypes'
+import type {
+ ComposerFileAttachment,
+ ComposerImageAttachment,
+ ComposerReferenceAttachment,
+} from '../../uiTypes'
+ export interface QueuedChatDelete {
+ agentRef: string
+ fence: ChatDeleteFence
+ hostAuthorityEpoch: number
+ }
+
/**
* Stable, cross-cutting chat actions. These are `useCallback` handlers plus the
* scroll ref — split out from chat state so action-only consumers (e.g. FleetBoard)
diff --cc desktop-app/ui/src/hooks/domain/useAgentChatController.ts
index 728047aa5,dca0f7034..6a5ce66ce
--- a/desktop-app/ui/src/hooks/domain/useAgentChatController.ts
+++ b/desktop-app/ui/src/hooks/domain/useAgentChatController.ts
@@@ -1311,36 -1391,19 +1423,36 @@@ export function useAgentChatController(
return () => {
cancelled = true
}
- }, [cancelOlderMessagesLoad, currentTeamId, navItem, selectedAgent])
+ }, [cancelOlderMessagesLoad, currentTeamId, navItem, selectedAgent, isHostAccessBlocked])
const mapComposerAttachmentsToHostRequest = (
- attachments: ComposerImageAttachment[]
- ): HostMessageAttachment[] =>
- attachments.map(att => ({
- id: att.id,
- kind: 'image',
- mimeType: att.mimeType,
- encoding: 'base64',
- dataBase64: att.dataBase64,
- filename: att.name,
- }))
+ attachments: ComposerImageAttachment[],
+ files: ReadyComposerFileAttachment[]
+ ): HostMessageAttachment[] => [
+ ...attachments.map(
+ (att): HostMessageAttachment => ({
+ id: att.id,
+ kind: 'image',
+ mimeType: att.mimeType,
+ encoding: 'base64',
+ dataBase64: att.dataBase64,
+ filename: att.name,
+ })
+ ),
+ ...files.map(
+ (file): HostMessageAttachment => ({
+ id: file.id,
+ kind: 'file',
+ filename: file.filename,
+ mimeType: file.declaredMediaType,
+ detectedMediaType: file.classification.detectedMediaType,
+ encoding: 'base64',
+ dataBase64: file.dataBase64,
+ sizeBytes: file.sizeBytes,
+ digest: { algorithm: 'sha256', hex: file.digestHex },
+ })
+ ),
+ ]
// ─── Activity / progress state updaters (hoisted from sendAgentMessage so the
// tracker subscription effect and tracker callbacks can share them) ───
@@@ -2558,10 -2760,8 +2812,11 @@@
const effectiveReferences = [...references]
if (
!selectedAgent ||
+ isHostAccessBlocked(selectedAgent) ||
- (!trimmedContent && !effectiveAttachments.length && !effectiveReferences.length)
+ (!trimmedContent &&
+ !effectiveAttachments.length &&
+ !effectiveFiles.length &&
+ !effectiveReferences.length)
)
return
// Per-(agent, chat) re-entry guard: a chat with a running task can't start
@@@ -2611,61 -2820,18 +2875,69 @@@
const blocker = error instanceof Error ? error.message : String(error)
setAgentError(blocker)
pushToast(blocker, 'error')
- agentSendInFlightRef.current = false
+ releaseSendSetup()
return
}
+ // #678 — the content the Host receives is fixed before anything is created
+ // or cleared, so the shared per-message limits are checked against the
+ // exact request and a refusal leaves the composer as the user typed it.
+ const baseContentForRequest =
+ trimmedContent ||
+ (effectiveAttachments.length && effectiveFiles.length
+ ? 'Please analyze the attached image(s) and file(s).'
+ : effectiveFiles.length
+ ? 'Please analyze the attached file(s).'
+ : effectiveAttachments.length
+ ? 'Please analyze the attached image(s).'
+ : 'Please use the attached context.')
+ const effectiveContentForRequest = buildComposerRequestContent(
+ baseContentForRequest,
+ effectiveReferences
+ )
+ if (effectiveFiles.length > 0) {
+ // The limits rpc-proxy and mcp-host enforce, most specific first: the
+ // count, the file quota, the share left for text and file details, then
+ // the whole body (images included), so the reason names what to remove.
+ const textBytes = new TextEncoder().encode(effectiveContentForRequest).length
+ let blocker: string | null = null
+ if (effectiveAttachments.length + effectiveFiles.length > COMPOSER_MAX_ATTACHMENTS) {
+ blocker = `A message can carry at most ${COMPOSER_MAX_ATTACHMENTS} attachments.`
+ } else if (composerFileBase64Bytes(effectiveFiles) > COMPOSER_MAX_TOTAL_FILE_BASE64_BYTES) {
+ blocker = `The attached files take more than ${formatFileSize(COMPOSER_MAX_TOTAL_FILE_BASE64_BYTES)} once encoded. Remove a file.`
+ } else if (
+ composerNonImageBodyBytes({ files: effectiveFiles, textBytes }) >
+ COMPOSER_MAX_NON_IMAGE_BODY_BYTES
+ ) {
+ blocker = `The message text and file details take more than ${formatFileSize(COMPOSER_MAX_NON_IMAGE_BODY_BYTES)} once encoded. Shorten the message or remove a file.`
+ } else if (
+ composerRequestBodyBytes({
+ files: effectiveFiles,
+ textBytes,
+ imageBase64Bytes: effectiveAttachments.reduce(
+ (total, image) => total + image.dataBase64.length,
+ 0
+ ),
+ imageCount: effectiveAttachments.length,
+ }) > COMPOSER_MAX_REQUEST_BODY_BYTES
+ ) {
+ blocker = `The attachments and text take more than ${formatFileSize(COMPOSER_MAX_REQUEST_BODY_BYTES)} once encoded. Remove an attachment or shorten the message.`
+ }
+ if (blocker) {
+ setAgentError(blocker)
+ pushToast(blocker, 'error')
- agentSendInFlightRef.current = false
++ releaseSendSetup()
+ return
+ }
+ }
- let sendChatId = activeChatId
+ let sendChatId = currentChatId ?? activeChatId
+ const sendStillAuthorized = () =>
+ sendScope === sendScopeGeneration.current &&
+ sendScopeIdentity === currentAuthScopeRef.current &&
+ !isHostAccessBlocked(sendAgent) &&
+ (!sendChatId || !isChatDeleted(sendAgent, sendChatId))
+ const sendChatIsVisible = () =>
+ activeChatVisibilityRef.current.selectedAgent === sendAgent &&
+ activeChatVisibilityRef.current.activeChatId === sendChatId
// Captured for the retention snapshot: the model this attempt actually
// asked for (issue #654), readable from the catch below.
let requestModelForRetention: string | undefined
@@@ -2712,11 -2889,23 +2995,15 @@@
return
}
}
+ if (!sendStillAuthorized()) {
+ releaseSendSetup()
+ return
+ }
const userMessageId = crypto.randomUUID()
- const baseContentForRequest =
- trimmedContent ||
- (effectiveAttachments.length
- ? 'Please analyze the attached image(s).'
- : 'Please use the attached context.')
- const effectiveContentForRequest = buildComposerRequestContent(
- baseContentForRequest,
- effectiveReferences
- )
const displayAttachments = buildChatMessageAttachments(
effectiveAttachments,
- effectiveReferences
+ effectiveReferences,
+ effectiveFiles
)
const userMessage: AgentChatMessage = {
id: userMessageId,
@@@ -3052,21 -3216,15 +3360,25 @@@
// Async task accepted. Persist the user message once, now carrying its
// task_id (schema v2), then hand the SSE lifecycle to the tracker.
const persistedUserMessage: AgentChatMessage = { ...userMessage, task_id: taskId }
- setChatMessages(prev => prev.map(m => (m.id === userMessageId ? persistedUserMessage : m)))
+ if (sendChatIsVisible()) {
+ setChatMessages(prev =>
+ prev.map(m => (m.id === userMessageId ? persistedUserMessage : m))
+ )
+ }
if (sendChatId) {
- await chatStore.appendMessages(sendAgent, sendChatId, [persistedUserMessage])
+ await chatStore.upsertMessages(sendAgent, sendChatId, [persistedUserMessage])
}
attachTaskIdToRetainedSend(sendAgent, sendChatId ?? null, userMessageId, taskId)
+ if (filesNotDeliveredMessage) {
+ // The task runs without the documents; the snapshot survives its
+ // success (see releaseSucceededRetainedSendsForTask).
+ markRetainedSendReason(
+ taskId,
+ 'host_files_unsupported',
+ filesNotDeliveredMessage,
+ 'upstream'
+ )
+ }
activityTaskToMessageByAgentRef.current[sendAgent] = {
...(activityTaskToMessageByAgentRef.current[sendAgent] || {}),
[taskId]: userMessageId,
@@@ -3183,9 -3367,12 +3523,13 @@@
},
[
selectedAgent,
+ isHostAccessBlocked,
+ isChatDeleted,
+ revokeHostAccess,
+ holdHostAccess,
activeChatId,
composerImageAttachments,
+ readyComposerFiles,
composerReferenceAttachments,
chatList,
chatStore,
@@@ -3302,9 -3467,8 +3646,9 @@@
)
return
if (
- getComposerDraft(activeChatId) ||
+ getComposerDraft(activeChatId, selectedAgent ?? undefined) ||
composerImageAttachments.length ||
+ composerFileAttachments.length ||
composerReferenceAttachments.length
) {
pushToast('Keep or clear the current draft before recovering the earlier input.', 'error')
diff --cc external-rest-api/src/releaseManifest.ts
index 4baa3420e,f159b47b7..18182251e
--- a/external-rest-api/src/releaseManifest.ts
+++ b/external-rest-api/src/releaseManifest.ts
@@@ -9,7 -9,7 +9,7 @@@ export type ReleaseManifest =
export const releaseManifest: ReleaseManifest = {
releaseId: 'v0.10.0',
externalRestApiVersion: '0.1.85',
- rpcProxyVersion: '0.1.95',
- rpcProxyVersion: '0.1.111',
++ rpcProxyVersion: '0.1.112',
desktopVersion: '0.10.0',
minimumDesktopVersion: '0.1.252',
}
diff --cc mcp-host/package-lock.json
index 9feb4321f,5778fe896..7f183a0de
--- a/mcp-host/package-lock.json
+++ b/mcp-host/package-lock.json
@@@ -1,12 -1,12 +1,12 @@@
{
"name": "clerum-mcp-host",
- "version": "0.1.472",
- "version": "0.1.476",
++ "version": "0.1.477",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-mcp-host",
- "version": "0.1.472",
- "version": "0.1.476",
++ "version": "0.1.477",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@anthropic-ai/sdk": "^0.32.0",
diff --cc mcp-host/package.json
index 07681f4d1,ece16c828..fc186a3e8
--- a/mcp-host/package.json
+++ b/mcp-host/package.json
@@@ -1,6 -1,6 +1,6 @@@
{
"name": "clerum-mcp-host",
- "version": "0.1.472",
- "version": "0.1.476",
++ "version": "0.1.477",
"description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude",
"main": "dist/main.js",
"engines": {
diff --cc rpc-proxy/package-lock.json
index 0796f6589,5bb586f38..6e2967f85
--- a/rpc-proxy/package-lock.json
+++ b/rpc-proxy/package-lock.json
@@@ -1,12 -1,12 +1,12 @@@
{
"name": "clerum-rpc-proxy",
- "version": "0.1.95",
- "version": "0.1.111",
++ "version": "0.1.112",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-rpc-proxy",
- "version": "0.1.95",
- "version": "0.1.111",
++ "version": "0.1.112",
"dependencies": {
"cors": "^2.8.5",
"express": "^4.21.2",
diff --cc rpc-proxy/package.json
index ef129fee1,7544d37ea..ed2a02696
--- a/rpc-proxy/package.json
+++ b/rpc-proxy/package.json
@@@ -1,6 -1,6 +1,6 @@@
{
"name": "clerum-rpc-proxy",
- "version": "0.1.95",
- "version": "0.1.111",
++ "version": "0.1.112",
"description": "External-facing RPC proxy for tenant-scoped MCP access",
"main": "dist/main.js",
"engines": {
diff --cc scripts/minikube/pre-gate-incremental.sh
index 0f6b294b4,6d00f4196..ac7779ee9
--- a/scripts/minikube/pre-gate-incremental.sh
+++ b/scripts/minikube/pre-gate-incremental.sh
@@@ -452,10 -452,8 +452,10 @@@ incremental_build_images()
log "Building all images because the change cannot be safely targeted"
(
cd "${PROJECT_DIR}"
+ # pre-gate-sync already holds the profile lock; the target's lock wrapper
+ # must validate that lease instead of acquiring it again (PROFILE_BUSY).
T2_SKIP_LOCK=true T2_LOCK_TOKEN="${T2_LOCK_TOKEN}" make minikube-build-images
- make minikube-verify-images
+ T2_SKIP_LOCK=true T2_LOCK_TOKEN="${T2_LOCK_TOKEN}" make minikube-verify-images
)
return 0
fi
@@@ -488,9 -486,8 +488,9 @@@ incremental_build_images_ghcr()
log "Re-pulling the release image set (${IMAGE_TAG}) before shadowing the changed images"
(
cd "${PROJECT_DIR}"
+ # Same inherited lease as the full local build above.
T2_SKIP_LOCK=true T2_LOCK_TOKEN="${T2_LOCK_TOKEN}" make minikube-pull-images
- make minikube-verify-images
+ T2_SKIP_LOCK=true T2_LOCK_TOKEN="${T2_LOCK_TOKEN}" make minikube-verify-images
)
fi