Skip to content

The agent that grows with you

Merge origin/main into the gateway cutover repair branch

Teknium7e2c7e15814d
diff --cc apps/desktop/electron/main.ts
index 478f37418c8,e68c47879a6..1ec8e4e21d5
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@@ -274,9 -269,10 +273,10 @@@ import
} from './native-oauth'
import { runNativeLogin } from './native-oauth-login'
import { loadNativeTokenSet, type NativeTokenStoreIo, persistNativeTokenSet } from './native-token-store'
+ import { registerNativeNotifications } from './notification-ipc'
import { serializeJsonBody, setJsonRequestHeaders } from './oauth-net-request'
import { LEGACY_OAUTH_PARTITION, resolveOauthPartition } from './oauth-partition'
-import { createParentStartMarkerResolver, parentWatchdogEnv } from './parent-process-identity'
+import { createParentStartMarkerResolver } from './parent-process-identity'
import { registerPetOverlayIpc } from './pet-overlay-ipc'
import {
pendingNotice as pendingPluginCompatNotice,
diff --cc apps/desktop/src/app/chat/composer/hooks/use-composer-queue.test.tsx
index 1530a0d7c83,8a2894e650d..1b4396fc166
--- a/apps/desktop/src/app/chat/composer/hooks/use-composer-queue.test.tsx
+++ b/apps/desktop/src/app/chat/composer/hooks/use-composer-queue.test.tsx
@@@ -11,7 -10,7 +11,7 @@@ import
MAX_AUTO_DRAIN_ATTEMPTS,
parkQueuedPrompts
} from '@/store/composer-queue'
- import { $connection } from '@/store/session'
-import { setSessionsLoading } from '@/store/session'
++import { $connection, setSessionsLoading } from '@/store/session'
import type { QueueEditState } from '../composer-utils'
import type { ChatBarProps } from '../types'
@@@ -67,55 -67,9 +68,56 @@@ describe('useComposerQueue park integra
vi.restoreAllMocks()
$queuedPromptsBySession.set({})
$parkedQueueSessions.set({})
+ setSessionsLoading(true)
})
+ it('admits native Queue through submit and retains an uncertain draft without a local replay', async () => {
+ $connection.set({ mode: 'local', wsUrl: 'ws://localhost/api/ws?native_dial=unminted' } as HermesConnection)
+ const draftRef = { current: 'durable queue' }
+ const clearDraft = vi.fn(() => { draftRef.current = '' })
+ const onSubmit = vi.fn<ChatBarProps['onSubmit']>().mockResolvedValue(false)
+
+ const hook = renderHook(({ busy }) => useComposerQueue({
+ activeQueueSessionKey: SESSION_KEY, attachments: [], busy, clearDraft, draftRef,
+ focusInput: () => undefined, loadIntoComposer: () => undefined, onCancel: vi.fn(), onSteer: undefined,
+ onSubmit, queueEditRef: { current: null }, queueSessionKey: SESSION_KEY, sessionId: 'rt-session-queue-hook'
+ }), { initialProps: { busy: true } })
+
+ try {
+ await act(async () => { await hook.result.current.queueCurrentDraft() })
+ expect(onSubmit).toHaveBeenCalledWith('durable queue', expect.objectContaining({ fromQueue: true, storedSessionId: SESSION_KEY }))
+ expect(draftRef.current).toBe('durable queue')
+ expect(getQueuedPrompts(SESSION_KEY)).toEqual([])
+ onSubmit.mockResolvedValue(true)
+ await act(async () => { await hook.result.current.queueCurrentDraft() })
+ expect(clearDraft).toHaveBeenCalledTimes(1)
+ hook.rerender({ busy: false })
+ await act(async () => { await Promise.resolve() })
+ expect(onSubmit).toHaveBeenCalledTimes(2)
+ } finally { $connection.set(null) }
+ })
+
+ it('does not clear the next session draft when a queue ACK arrives after navigation', async () => {
+ $connection.set({ mode: 'local', wsUrl: 'ws://localhost/api/ws?native_dial=unminted' } as HermesConnection)
+ let accept!: (value: boolean) => void
+ const clearDraft = vi.fn()
+ const draftRef = { current: 'same text' }
+
+ const hook = renderHook(({ key }) => useComposerQueue({
+ activeQueueSessionKey: key, attachments: [], busy: true, clearDraft, draftRef,
+ focusInput: () => undefined, loadIntoComposer: () => undefined, onCancel: vi.fn(), onSteer: undefined,
+ onSubmit: () => new Promise<boolean>(resolve => { accept = resolve }), queueEditRef: { current: null }, queueSessionKey: key, sessionId: key
+ }), { initialProps: { key: 'outgoing' } })
+
+ try {
+ let pending: boolean | Promise<boolean> = false
+ act(() => { pending = hook.result.current.queueCurrentDraft() })
+ hook.rerender({ key: 'incoming' })
+ await act(async () => { accept(true); await pending })
+ expect(clearDraft).not.toHaveBeenCalled()
+ } finally { $connection.set(null) }
+ })
+
it('reschedules rejected foreground drains to a bounded stop and keeps manual recovery', async () => {
vi.useFakeTimers()
diff --cc apps/desktop/src/global.d.ts
index 596b09cf060,08f516fd6e1..af79edf15d1
--- a/apps/desktop/src/global.d.ts
+++ b/apps/desktop/src/global.d.ts
@@@ -1,6 -1,9 +1,8 @@@
import type { GatewayWsUrlResult } from '@hermes/shared'
import type { TranslucencyState } from '@hermes/shared/translucency'
+ import type { HermesNotification } from '../electron/notification-types'
-import type { PoolLimits } from '../electron/pool-limits'
+
import type { WakeIndicatorState } from './lib/wake-indicator'
import type {
PetOverlayBounds,
diff --cc cron/scheduler_delivery.py
index 2ddbeddd578,92f99b4c9e8..c8b74be647b
--- a/cron/scheduler_delivery.py
+++ b/cron/scheduler_delivery.py
@@@ -623,16 -639,26 +635,16 @@@ def _resolve_single_delivery_target
if not _is_known_delivery_platform(platform_name):
return None
chat_id = _get_home_target_chat_id(platform_name)
- return _home_target(platform_name, chat_id) if chat_id else None
+ return _home_target(platform_name, chat_id, home_provenance) if chat_id else None
-def _get_bot_chat_delivery_timeout() -> int:
- """Timeout for one bot-chat delivery turn (a full agent turn — minutes, not seconds).
- ``cron.bot_chat_delivery_timeout_seconds``; default 600."""
- try:
- cfg = _sched.load_config()
- value = int(cfg.get("cron", {}).get("bot_chat_delivery_timeout_seconds", 600))
- return value if value > 0 else 600
- except Exception:
- return 600
-
-
def _deliver_to_bot_chat(job: dict, content: str, profile: str) -> Optional[str]:
- """Hand output to the live Bot Chat owner, or use the legacy unowned CLI lane.
+ """Admit job output to the target profile's authority as a real inbound Bot Chat turn.
- None means completed; a queued/claimed receipt returns an explicit unverified status
- string so existing Optional[str] callers cannot misreport admission as delivery.
- ``profile`` is ``""`` for the job's own profile.
+ None means the target's durable receipt is settled; anything else is an explicit
+ unverified status string so Optional[str] callers cannot misreport admission as
+ delivery. ``profile`` is ``""`` for the job's own profile. There is no second-writer
+ fallback: without a running authority the payload stays unverified for retry.
"""
import hashlib
import json
diff --cc gateway/AGENTS.md
index 855ed306c19,ef22c4cf311..a22afd2163d
--- a/gateway/AGENTS.md
+++ b/gateway/AGENTS.md
@@@ -75,14 -75,10 +75,16 @@@ acceptance. Refused admission refunds e
actual delivery errors keep their bounded retry policy. Recognized raw API routes resolve after
persisted messaging origins and defer quietly when unavailable; malformed routes still warn.
+Canonical local CLI/TUI/Desktop sessions admit completion and watch events into the same durable
+FIFO as human input, retaining the private local launch policy and `internal_notification` display
+kind. Observers neither own nor consume those turns. Accepted local automation survives owner
+restart; an interrupted started turn remains unknown and pauses its followers. Watch hits carry
+separate event IDs even for identical text, but their pre-admission process queue is not durable.
+
- Cron deliveries are NOT mirrored into the target gateway session — they land in their own cron
- session with a header/footer frame so the main conversation's role alternation stays intact
+ Cron execution has its own session. Eligible continuable deliveries may mirror or seed the
+ reply-facing conversation: origin, origin-less home fallback, user-written bare-platform home,
+ or opted-in explicit targets. `all` expansions do not gain home mirror eligibility. Mirrored
+ briefs are labelled user turns appended at a turn boundary, preserving role alternation
(`cron/AGENTS.md`).
## Gateway lifecycle vs. the Desktop app