yepanywhere 0.6.2 → 0.7.0
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/bundled/@yep-anywhere/shared/dist/app-types.d.ts +49 -1
- package/bundled/@yep-anywhere/shared/dist/app-types.d.ts.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/app-types.js +13 -2
- package/bundled/@yep-anywhere/shared/dist/app-types.js.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/browser-settings-backup.d.ts +12 -0
- package/bundled/@yep-anywhere/shared/dist/browser-settings-backup.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/browser-settings-backup.js +2 -0
- package/bundled/@yep-anywhere/shared/dist/browser-settings-backup.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-additional-models.d.ts +15 -0
- package/bundled/@yep-anywhere/shared/dist/claude-additional-models.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-additional-models.js +49 -0
- package/bundled/@yep-anywhere/shared/dist/claude-additional-models.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/AssistantEntrySchema.d.ts +8 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/AssistantEntrySchema.d.ts.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/AttachmentEntrySchema.d.ts +30 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/AttachmentEntrySchema.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/AttachmentEntrySchema.js +12 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/AttachmentEntrySchema.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/MetadataEntrySchema.d.ts +9 -1
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/MetadataEntrySchema.d.ts.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/MetadataEntrySchema.js +16 -3
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/MetadataEntrySchema.js.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/QueueOperationEntrySchema.d.ts +57 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/QueueOperationEntrySchema.d.ts.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/QueueOperationEntrySchema.js +12 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/QueueOperationEntrySchema.js.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/SystemEntrySchema.d.ts +160 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/SystemEntrySchema.d.ts.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/SystemEntrySchema.js +52 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/entry/SystemEntrySchema.js.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/index.d.ts +511 -2
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/index.d.ts.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/index.js +3 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/index.js.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/message/AssistantMessageSchema.d.ts +16 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/message/AssistantMessageSchema.d.ts.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/message/AssistantMessageSchema.js +6 -0
- package/bundled/@yep-anywhere/shared/dist/claude-sdk-schema/message/AssistantMessageSchema.js.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/codex-schema/session.d.ts +9 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/session.d.ts.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/codex-schema/session.js +4 -0
- package/bundled/@yep-anywhere/shared/dist/codex-schema/session.js.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/host-awake.d.ts +27 -0
- package/bundled/@yep-anywhere/shared/dist/host-awake.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/host-awake.js +19 -0
- package/bundled/@yep-anywhere/shared/dist/host-awake.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/host-identity.d.ts +12 -0
- package/bundled/@yep-anywhere/shared/dist/host-identity.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/host-identity.js +27 -0
- package/bundled/@yep-anywhere/shared/dist/host-identity.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/index.d.ts +10 -3
- package/bundled/@yep-anywhere/shared/dist/index.d.ts.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/index.js +8 -2
- package/bundled/@yep-anywhere/shared/dist/index.js.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/jsonlTable.d.ts +17 -0
- package/bundled/@yep-anywhere/shared/dist/jsonlTable.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/jsonlTable.js +87 -0
- package/bundled/@yep-anywhere/shared/dist/jsonlTable.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/project-queue.d.ts +2 -0
- package/bundled/@yep-anywhere/shared/dist/project-queue.d.ts.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/server-capabilities.d.ts +106 -1
- package/bundled/@yep-anywhere/shared/dist/server-capabilities.d.ts.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/server-capabilities.js +135 -0
- package/bundled/@yep-anywhere/shared/dist/server-capabilities.js.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/toon.d.ts +22 -0
- package/bundled/@yep-anywhere/shared/dist/toon.d.ts.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/toon.js +128 -0
- package/bundled/@yep-anywhere/shared/dist/toon.js.map +1 -0
- package/bundled/@yep-anywhere/shared/dist/types.d.ts +11 -0
- package/bundled/@yep-anywhere/shared/dist/types.d.ts.map +1 -1
- package/bundled/@yep-anywhere/shared/dist/types.js.map +1 -1
- package/bundled/@yep-anywhere/shared/package.json +1 -1
- package/client-dist/assets/KaTeX_Size3-Regular-gV2CO0n9.woff2 +0 -0
- package/client-dist/assets/index-7OpGawa_.css +1 -0
- package/client-dist/assets/index-CSJgXvUR.js +593 -0
- package/client-dist/index.html +2 -2
- package/dist/app.d.ts +7 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +106 -20
- package/dist/app.js.map +1 -1
- package/dist/augments/augment-generator.d.ts.map +1 -1
- package/dist/augments/augment-generator.js +10 -1
- package/dist/augments/augment-generator.js.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/codex/webRun.js +1 -1
- package/dist/codex/webRun.js.map +1 -1
- package/dist/index.js +26 -1
- package/dist/index.js.map +1 -1
- package/dist/indexes/SessionIndexService.d.ts.map +1 -1
- package/dist/indexes/SessionIndexService.js +17 -0
- package/dist/indexes/SessionIndexService.js.map +1 -1
- package/dist/metadata/SessionMetadataService.d.ts +9 -0
- package/dist/metadata/SessionMetadataService.d.ts.map +1 -1
- package/dist/metadata/SessionMetadataService.js +37 -6
- package/dist/metadata/SessionMetadataService.js.map +1 -1
- package/dist/projects/paths.js +4 -4
- package/dist/projects/paths.js.map +1 -1
- package/dist/routes/bang-commands.d.ts +32 -0
- package/dist/routes/bang-commands.d.ts.map +1 -0
- package/dist/routes/bang-commands.js +273 -0
- package/dist/routes/bang-commands.js.map +1 -0
- package/dist/routes/browser-settings-backup.d.ts +7 -0
- package/dist/routes/browser-settings-backup.d.ts.map +1 -0
- package/dist/routes/browser-settings-backup.js +35 -0
- package/dist/routes/browser-settings-backup.js.map +1 -0
- package/dist/routes/inbox.d.ts.map +1 -1
- package/dist/routes/inbox.js +2 -2
- package/dist/routes/inbox.js.map +1 -1
- package/dist/routes/processes.d.ts +9 -0
- package/dist/routes/processes.d.ts.map +1 -1
- package/dist/routes/processes.js +45 -4
- package/dist/routes/processes.js.map +1 -1
- package/dist/routes/project-queue-response.d.ts.map +1 -1
- package/dist/routes/project-queue-response.js +2 -2
- package/dist/routes/project-queue-response.js.map +1 -1
- package/dist/routes/project-queue.d.ts.map +1 -1
- package/dist/routes/project-queue.js +3 -0
- package/dist/routes/project-queue.js.map +1 -1
- package/dist/routes/providers.d.ts.map +1 -1
- package/dist/routes/providers.js +11 -2
- package/dist/routes/providers.js.map +1 -1
- package/dist/routes/recents.d.ts.map +1 -1
- package/dist/routes/recents.js +3 -3
- package/dist/routes/recents.js.map +1 -1
- package/dist/routes/sessions.d.ts.map +1 -1
- package/dist/routes/sessions.js +48 -56
- package/dist/routes/sessions.js.map +1 -1
- package/dist/routes/settings-parsers.d.ts +2 -1
- package/dist/routes/settings-parsers.d.ts.map +1 -1
- package/dist/routes/settings-parsers.js +39 -1
- package/dist/routes/settings-parsers.js.map +1 -1
- package/dist/routes/settings.d.ts +3 -0
- package/dist/routes/settings.d.ts.map +1 -1
- package/dist/routes/settings.js +70 -4
- package/dist/routes/settings.js.map +1 -1
- package/dist/routes/version.d.ts +2 -0
- package/dist/routes/version.d.ts.map +1 -1
- package/dist/routes/version.js +13 -7
- package/dist/routes/version.js.map +1 -1
- package/dist/routes/ws-relay-handlers.d.ts.map +1 -1
- package/dist/routes/ws-relay-handlers.js +2 -1
- package/dist/routes/ws-relay-handlers.js.map +1 -1
- package/dist/sdk/providers/acp/client.d.ts +14 -0
- package/dist/sdk/providers/acp/client.d.ts.map +1 -1
- package/dist/sdk/providers/acp/client.js +23 -2
- package/dist/sdk/providers/acp/client.js.map +1 -1
- package/dist/sdk/providers/claude-additional-models.d.ts +5 -0
- package/dist/sdk/providers/claude-additional-models.d.ts.map +1 -0
- package/dist/sdk/providers/claude-additional-models.js +55 -0
- package/dist/sdk/providers/claude-additional-models.js.map +1 -0
- package/dist/sdk/providers/claude.d.ts +6 -1
- package/dist/sdk/providers/claude.d.ts.map +1 -1
- package/dist/sdk/providers/claude.js +57 -17
- package/dist/sdk/providers/claude.js.map +1 -1
- package/dist/sdk/providers/codex-model-catalog.d.ts +4 -1
- package/dist/sdk/providers/codex-model-catalog.d.ts.map +1 -1
- package/dist/sdk/providers/codex-model-catalog.js +144 -98
- package/dist/sdk/providers/codex-model-catalog.js.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/ContentItem.d.ts +3 -0
- package/dist/sdk/providers/codex-protocol/generated/ContentItem.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/FunctionCallOutputContentItem.d.ts +3 -0
- package/dist/sdk/providers/codex-protocol/generated/FunctionCallOutputContentItem.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/LegacyAppPathString.d.ts +7 -6
- package/dist/sdk/providers/codex-protocol/generated/LegacyAppPathString.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/ResponseItem.d.ts +15 -14
- package/dist/sdk/providers/codex-protocol/generated/ResponseItem.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/ResponseItemId.d.ts +6 -0
- package/dist/sdk/providers/codex-protocol/generated/ResponseItemId.d.ts.map +1 -0
- package/dist/sdk/providers/codex-protocol/generated/ResponseItemId.js +3 -0
- package/dist/sdk/providers/codex-protocol/generated/ResponseItemId.js.map +1 -0
- package/dist/sdk/providers/codex-protocol/generated/SleepItem.d.ts +8 -0
- package/dist/sdk/providers/codex-protocol/generated/SleepItem.d.ts.map +1 -0
- package/dist/sdk/providers/codex-protocol/generated/SleepItem.js +3 -0
- package/dist/sdk/providers/codex-protocol/generated/SleepItem.js.map +1 -0
- package/dist/sdk/providers/codex-protocol/generated/WebSearchItem.d.ts +8 -0
- package/dist/sdk/providers/codex-protocol/generated/WebSearchItem.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/DynamicToolCallOutputContentItem.d.ts +3 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/DynamicToolCallOutputContentItem.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/FileSystemSpecialPath.d.ts +3 -2
- package/dist/sdk/providers/codex-protocol/generated/v2/FileSystemSpecialPath.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/McpToolCallAppContext.d.ts +0 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/McpToolCallAppContext.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/Thread.d.ts +5 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/Thread.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadForkParams.d.ts +11 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadForkParams.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadItem.d.ts +2 -3
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadItem.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadResumeResponse.d.ts +14 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/ThreadResumeResponse.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/TokenUsageBreakdown.d.ts +1 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/TokenUsageBreakdown.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/TurnEnvironmentParams.d.ts +4 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/TurnEnvironmentParams.d.ts.map +1 -1
- package/dist/sdk/providers/codex-protocol/generated/v2/UserInput.d.ts +6 -0
- package/dist/sdk/providers/codex-protocol/generated/v2/UserInput.d.ts.map +1 -1
- package/dist/sdk/providers/codex.d.ts.map +1 -1
- package/dist/sdk/providers/codex.js +63 -29
- package/dist/sdk/providers/codex.js.map +1 -1
- package/dist/sdk/providers/grok-acp.d.ts +33 -12
- package/dist/sdk/providers/grok-acp.d.ts.map +1 -1
- package/dist/sdk/providers/grok-acp.js +327 -20
- package/dist/sdk/providers/grok-acp.js.map +1 -1
- package/dist/sdk/providers/index.d.ts +3 -0
- package/dist/sdk/providers/index.d.ts.map +1 -1
- package/dist/sdk/providers/index.js +1 -0
- package/dist/sdk/providers/index.js.map +1 -1
- package/dist/sdk/providers/pi.d.ts +10 -4
- package/dist/sdk/providers/pi.d.ts.map +1 -1
- package/dist/sdk/providers/pi.js +57 -9
- package/dist/sdk/providers/pi.js.map +1 -1
- package/dist/sdk/providers/types.d.ts +16 -1
- package/dist/sdk/providers/types.d.ts.map +1 -1
- package/dist/sdk/types.d.ts +6 -1
- package/dist/sdk/types.d.ts.map +1 -1
- package/dist/services/BangCommandService.d.ts +86 -0
- package/dist/services/BangCommandService.d.ts.map +1 -0
- package/dist/services/BangCommandService.js +463 -0
- package/dist/services/BangCommandService.js.map +1 -0
- package/dist/services/BrowserSettingsBackupService.d.ts +30 -0
- package/dist/services/BrowserSettingsBackupService.d.ts.map +1 -0
- package/dist/services/BrowserSettingsBackupService.js +136 -0
- package/dist/services/BrowserSettingsBackupService.js.map +1 -0
- package/dist/services/ProjectQueueScheduler.d.ts +1 -0
- package/dist/services/ProjectQueueScheduler.d.ts.map +1 -1
- package/dist/services/ProjectQueueScheduler.js +16 -7
- package/dist/services/ProjectQueueScheduler.js.map +1 -1
- package/dist/services/PublicShareService.d.ts.map +1 -1
- package/dist/services/PublicShareService.js +1 -1
- package/dist/services/PublicShareService.js.map +1 -1
- package/dist/services/ServerSettingsService.d.ts +9 -1
- package/dist/services/ServerSettingsService.d.ts.map +1 -1
- package/dist/services/ServerSettingsService.js +13 -1
- package/dist/services/ServerSettingsService.js.map +1 -1
- package/dist/services/bangCompletions.d.ts +42 -0
- package/dist/services/bangCompletions.d.ts.map +1 -0
- package/dist/services/bangCompletions.js +186 -0
- package/dist/services/bangCompletions.js.map +1 -0
- package/dist/services/host-awake/HostAwakeBackend.d.ts +30 -0
- package/dist/services/host-awake/HostAwakeBackend.d.ts.map +1 -0
- package/dist/services/host-awake/HostAwakeBackend.js +12 -0
- package/dist/services/host-awake/HostAwakeBackend.js.map +1 -0
- package/dist/services/host-awake/HostAwakeService.d.ts +44 -0
- package/dist/services/host-awake/HostAwakeService.d.ts.map +1 -0
- package/dist/services/host-awake/HostAwakeService.js +282 -0
- package/dist/services/host-awake/HostAwakeService.js.map +1 -0
- package/dist/services/host-awake/MacHostAwakeBackend.d.ts +36 -0
- package/dist/services/host-awake/MacHostAwakeBackend.d.ts.map +1 -0
- package/dist/services/host-awake/MacHostAwakeBackend.js +279 -0
- package/dist/services/host-awake/MacHostAwakeBackend.js.map +1 -0
- package/dist/services/host-awake/WindowsHostAwakeBackend.d.ts +21 -0
- package/dist/services/host-awake/WindowsHostAwakeBackend.d.ts.map +1 -0
- package/dist/services/host-awake/WindowsHostAwakeBackend.js +487 -0
- package/dist/services/host-awake/WindowsHostAwakeBackend.js.map +1 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +2 -0
- package/dist/services/index.js.map +1 -1
- package/dist/sessions/claude-summary.js +1 -1
- package/dist/sessions/claude-summary.js.map +1 -1
- package/dist/sessions/codex-reader.d.ts +5 -3
- package/dist/sessions/codex-reader.d.ts.map +1 -1
- package/dist/sessions/codex-reader.js +66 -8
- package/dist/sessions/codex-reader.js.map +1 -1
- package/dist/sessions/provider-resolution.d.ts +7 -1
- package/dist/sessions/provider-resolution.d.ts.map +1 -1
- package/dist/sessions/provider-resolution.js +82 -0
- package/dist/sessions/provider-resolution.js.map +1 -1
- package/dist/sessions/reader.d.ts +23 -7
- package/dist/sessions/reader.d.ts.map +1 -1
- package/dist/sessions/reader.js +136 -73
- package/dist/sessions/reader.js.map +1 -1
- package/dist/sessions/resume-exemption.d.ts +28 -0
- package/dist/sessions/resume-exemption.d.ts.map +1 -0
- package/dist/sessions/resume-exemption.js +22 -0
- package/dist/sessions/resume-exemption.js.map +1 -0
- package/dist/sessions/types.d.ts +31 -3
- package/dist/sessions/types.d.ts.map +1 -1
- package/dist/sessions/types.js +19 -1
- package/dist/sessions/types.js.map +1 -1
- package/dist/subscriptions.d.ts.map +1 -1
- package/dist/subscriptions.js +7 -0
- package/dist/subscriptions.js.map +1 -1
- package/dist/supervisor/ExternalSessionTracker.d.ts +7 -2
- package/dist/supervisor/ExternalSessionTracker.d.ts.map +1 -1
- package/dist/supervisor/ExternalSessionTracker.js +99 -91
- package/dist/supervisor/ExternalSessionTracker.js.map +1 -1
- package/dist/supervisor/Process.d.ts +45 -6
- package/dist/supervisor/Process.d.ts.map +1 -1
- package/dist/supervisor/Process.js +353 -54
- package/dist/supervisor/Process.js.map +1 -1
- package/dist/supervisor/Supervisor.d.ts +4 -6
- package/dist/supervisor/Supervisor.d.ts.map +1 -1
- package/dist/supervisor/Supervisor.js +80 -19
- package/dist/supervisor/Supervisor.js.map +1 -1
- package/dist/supervisor/types.d.ts +16 -1
- package/dist/supervisor/types.d.ts.map +1 -1
- package/dist/supervisor/types.js.map +1 -1
- package/dist/watcher/EventBus.d.ts +13 -2
- package/dist/watcher/EventBus.d.ts.map +1 -1
- package/dist/watcher/EventBus.js.map +1 -1
- package/dist/watcher/FileWatcher.d.ts.map +1 -1
- package/dist/watcher/FileWatcher.js +5 -3
- package/dist/watcher/FileWatcher.js.map +1 -1
- package/dist/watcher/index.d.ts +1 -1
- package/dist/watcher/index.d.ts.map +1 -1
- package/dist/watcher/index.js.map +1 -1
- package/package.json +3 -3
- package/client-dist/assets/index-1y2h7U7U.js +0 -582
- package/client-dist/assets/index-Cn_ZDP6u.css +0 -1
|
@@ -11,18 +11,68 @@ import { getSystemMessageText, isAwaySummaryMessage, messageTimestampMs, toDurab
|
|
|
11
11
|
import { buildSessionLivenessSnapshot, } from "./liveness.js";
|
|
12
12
|
export const NATIVE_RECAP_FALLBACK_GRACE_MS = 2_000;
|
|
13
13
|
const CLAUDE_UNBOUNDED_MAX_RETRIES = 2_147_483_647;
|
|
14
|
+
const PROCESS_ABORT_TIMEOUT_MS = 5_000;
|
|
15
|
+
const PID_EXIT_POLL_INTERVAL_MS = 25;
|
|
16
|
+
const MODEL_SWITCH_RETRY_INTERRUPT_PREAMBLE = "The previous provider request was interrupted because the model changed while the provider was retrying. Continue under the newly selected model.";
|
|
17
|
+
function isLocalPidRunning(pid) {
|
|
18
|
+
try {
|
|
19
|
+
process.kill(pid, 0);
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
if (error.code === "ESRCH") {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
if (error.code === "EPERM") {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async function waitForLocalPidExit(pid, timeoutMs) {
|
|
33
|
+
const deadline = Date.now() + timeoutMs;
|
|
34
|
+
while (isLocalPidRunning(pid)) {
|
|
35
|
+
const remainingMs = deadline - Date.now();
|
|
36
|
+
if (remainingMs <= 0) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(PID_EXIT_POLL_INTERVAL_MS, remainingMs)));
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
async function waitUntilAbortDeadline(promise, deadline, timeoutMessage) {
|
|
44
|
+
const remainingMs = deadline - Date.now();
|
|
45
|
+
if (remainingMs <= 0) {
|
|
46
|
+
throw new Error(timeoutMessage);
|
|
47
|
+
}
|
|
48
|
+
let timeoutHandle;
|
|
49
|
+
try {
|
|
50
|
+
return await Promise.race([
|
|
51
|
+
promise,
|
|
52
|
+
new Promise((_resolve, reject) => {
|
|
53
|
+
timeoutHandle = setTimeout(() => reject(new Error(timeoutMessage)), remainingMs);
|
|
54
|
+
}),
|
|
55
|
+
]);
|
|
56
|
+
}
|
|
57
|
+
finally {
|
|
58
|
+
if (timeoutHandle)
|
|
59
|
+
clearTimeout(timeoutHandle);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/** Whether the user chose durable patient queue intent for this entry. */
|
|
63
|
+
function hasPatientQueueIntent(entry) {
|
|
64
|
+
return entry.message.metadata?.deliveryIntent === "patient";
|
|
65
|
+
}
|
|
14
66
|
/**
|
|
15
|
-
* Whether a queued entry should ride the verified-idle
|
|
16
|
-
* of the plain turn-end deferred path. Patient
|
|
17
|
-
* deferred on Claude — the only provider that reports background-work
|
|
18
|
-
* (session crons, background/live tasks), which is what lets YA wait
|
|
19
|
-
* genuine completion.
|
|
20
|
-
*
|
|
21
|
-
* promotes at turn end and never engages the patient machinery.
|
|
67
|
+
* Whether a queued entry should ride the verified-idle patient delivery path
|
|
68
|
+
* instead of the plain turn-end deferred path. Patient timing only differs
|
|
69
|
+
* from deferred on Claude — the only provider that reports background-work
|
|
70
|
+
* retention (session crons, background/live tasks), which is what lets YA wait
|
|
71
|
+
* for genuine completion. Other providers still preserve patient intent across
|
|
72
|
+
* restart, but promote it at the ordinary turn-end boundary.
|
|
22
73
|
*/
|
|
23
|
-
function
|
|
24
|
-
return (entry
|
|
25
|
-
isClaudeSdkProvider(provider));
|
|
74
|
+
function usesPatientDeliveryPath(entry, provider) {
|
|
75
|
+
return hasPatientQueueIntent(entry) && isClaudeSdkProvider(provider);
|
|
26
76
|
}
|
|
27
77
|
/** Quiet milliseconds this patient entry waits for after verified idle. */
|
|
28
78
|
function patientPatienceMsForEntry(entry) {
|
|
@@ -133,9 +183,7 @@ function readPositiveInteger(value) {
|
|
|
133
183
|
return Math.trunc(number);
|
|
134
184
|
}
|
|
135
185
|
function readNonEmptyString(value) {
|
|
136
|
-
return typeof value === "string" && value.trim()
|
|
137
|
-
? value.trim()
|
|
138
|
-
: undefined;
|
|
186
|
+
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
139
187
|
}
|
|
140
188
|
function readCodexHttpStatus(codexErrorInfo) {
|
|
141
189
|
if (!codexErrorInfo || typeof codexErrorInfo !== "object") {
|
|
@@ -407,6 +455,12 @@ export class Process {
|
|
|
407
455
|
previousBucket = [];
|
|
408
456
|
bucketSwapTimer = null;
|
|
409
457
|
static BUCKET_SWAP_INTERVAL_MS = 15_000;
|
|
458
|
+
/**
|
|
459
|
+
* User echoes accepted for in-turn steering remain replayable through the
|
|
460
|
+
* provider turn. A steer can wait behind a long-running tool for longer than
|
|
461
|
+
* the ordinary replay buckets, while its durable row does not exist yet.
|
|
462
|
+
*/
|
|
463
|
+
activeSteerEchoes = new Map();
|
|
410
464
|
/** Accumulated streaming text for catch-up when clients connect mid-stream */
|
|
411
465
|
_streamingText = "";
|
|
412
466
|
/** Message ID for current streaming response */
|
|
@@ -447,8 +501,17 @@ export class Process {
|
|
|
447
501
|
_thinking;
|
|
448
502
|
/** Effort level for response quality */
|
|
449
503
|
_effort;
|
|
504
|
+
/** Latest effort selected while the current provider turn is still active. */
|
|
505
|
+
pendingEffortUpdate = null;
|
|
506
|
+
/** Serializes provider effort controls so slower writes cannot win late. */
|
|
507
|
+
effortApplyTail = Promise.resolve();
|
|
508
|
+
/** A failed turn-boundary effort write keeps the process non-idle. */
|
|
509
|
+
effortBoundaryBlocked = false;
|
|
510
|
+
effortBoundaryTransition = null;
|
|
450
511
|
/** Function to change max thinking tokens at runtime (SDK 0.2.7+) */
|
|
451
512
|
setMaxThinkingTokensFn;
|
|
513
|
+
/** Function to change effort without restarting the provider process. */
|
|
514
|
+
setEffortFn;
|
|
452
515
|
/** Function to interrupt current turn gracefully (SDK 0.2.7+) */
|
|
453
516
|
interruptFn;
|
|
454
517
|
/** Function to steer an active turn (provider-specific, currently Codex app-server) */
|
|
@@ -490,6 +553,7 @@ export class Process {
|
|
|
490
553
|
_livenessProbeInFlight = null;
|
|
491
554
|
/** OS PID of the spawned agent child process (supports deferred resolution) */
|
|
492
555
|
_pidResolver;
|
|
556
|
+
_lastKnownPid;
|
|
493
557
|
/** Resolved model name from the first assistant message (e.g., "claude-sonnet-4-5-20250929") */
|
|
494
558
|
_resolvedModel;
|
|
495
559
|
/**
|
|
@@ -531,6 +595,7 @@ export class Process {
|
|
|
531
595
|
this._thinking = options.thinking;
|
|
532
596
|
this._effort = options.effort;
|
|
533
597
|
this.setMaxThinkingTokensFn = options.setMaxThinkingTokensFn ?? null;
|
|
598
|
+
this.setEffortFn = options.setEffortFn ?? null;
|
|
534
599
|
this.interruptFn = options.interruptFn ?? null;
|
|
535
600
|
this.steerFn = options.steerFn ?? null;
|
|
536
601
|
this.supportedModelsFn = options.supportedModelsFn ?? null;
|
|
@@ -660,10 +725,13 @@ export class Process {
|
|
|
660
725
|
}
|
|
661
726
|
/** OS PID of the spawned agent child process */
|
|
662
727
|
get pid() {
|
|
663
|
-
|
|
664
|
-
|
|
728
|
+
const resolved = typeof this._pidResolver === "function"
|
|
729
|
+
? this._pidResolver()
|
|
730
|
+
: this._pidResolver;
|
|
731
|
+
if (resolved !== undefined) {
|
|
732
|
+
this._lastKnownPid = resolved;
|
|
665
733
|
}
|
|
666
|
-
return this.
|
|
734
|
+
return resolved ?? this._lastKnownPid;
|
|
667
735
|
}
|
|
668
736
|
get queueDepth() {
|
|
669
737
|
if (this.messageQueue) {
|
|
@@ -675,10 +743,10 @@ export class Process {
|
|
|
675
743
|
return this.deferredQueue.length;
|
|
676
744
|
}
|
|
677
745
|
hasPatientDeferredMessages() {
|
|
678
|
-
return this.deferredQueue.some((entry) =>
|
|
746
|
+
return this.deferredQueue.some((entry) => usesPatientDeliveryPath(entry, this.provider));
|
|
679
747
|
}
|
|
680
748
|
hasVolatileDeferredMessages() {
|
|
681
|
-
return this.deferredQueue.some((entry) => !
|
|
749
|
+
return this.deferredQueue.some((entry) => !hasPatientQueueIntent(entry));
|
|
682
750
|
}
|
|
683
751
|
async waitForPatientQueuePersistenceIdle() {
|
|
684
752
|
await this.patientQueuePersistenceTail;
|
|
@@ -1004,10 +1072,12 @@ export class Process {
|
|
|
1004
1072
|
return this._thinking;
|
|
1005
1073
|
}
|
|
1006
1074
|
/**
|
|
1007
|
-
*
|
|
1075
|
+
* Selected effort for subsequent responses. While a provider turn is active,
|
|
1076
|
+
* this reflects the queued next-turn selection before the provider control
|
|
1077
|
+
* request is applied at the turn boundary.
|
|
1008
1078
|
*/
|
|
1009
1079
|
get effort() {
|
|
1010
|
-
return this._effort;
|
|
1080
|
+
return this.pendingEffortUpdate?.effort ?? this._effort;
|
|
1011
1081
|
}
|
|
1012
1082
|
/**
|
|
1013
1083
|
* Update thinking config and effort after a dynamic change.
|
|
@@ -1023,6 +1093,10 @@ export class Process {
|
|
|
1023
1093
|
get supportsThinkingModeChange() {
|
|
1024
1094
|
return this.setMaxThinkingTokensFn !== null;
|
|
1025
1095
|
}
|
|
1096
|
+
/** Whether this process can change effort without being restarted. */
|
|
1097
|
+
get supportsEffortChange() {
|
|
1098
|
+
return this.setEffortFn !== null;
|
|
1099
|
+
}
|
|
1026
1100
|
/**
|
|
1027
1101
|
* Whether this process supports graceful interrupt.
|
|
1028
1102
|
* Only Claude SDK 0.2.7+ supports this.
|
|
@@ -1108,6 +1182,94 @@ export class Process {
|
|
|
1108
1182
|
await this.setMaxThinkingTokensFn(tokens ?? null);
|
|
1109
1183
|
return true;
|
|
1110
1184
|
}
|
|
1185
|
+
/**
|
|
1186
|
+
* Select a new effort without interrupting provider work. An idle process can
|
|
1187
|
+
* apply it immediately; an active or waiting process holds the latest choice
|
|
1188
|
+
* until the provider reports the turn boundary.
|
|
1189
|
+
*/
|
|
1190
|
+
async setEffort(effort) {
|
|
1191
|
+
if (!this.setEffortFn) {
|
|
1192
|
+
return false;
|
|
1193
|
+
}
|
|
1194
|
+
this.pendingEffortUpdate = { effort };
|
|
1195
|
+
if ((this._state.type === "in-turn" ||
|
|
1196
|
+
this._state.type === "waiting-input") &&
|
|
1197
|
+
!this.effortBoundaryBlocked) {
|
|
1198
|
+
getLogger().info({
|
|
1199
|
+
event: "effort_change_queued",
|
|
1200
|
+
sessionId: this._sessionId,
|
|
1201
|
+
processId: this.id,
|
|
1202
|
+
oldEffort: this._effort,
|
|
1203
|
+
newEffort: effort,
|
|
1204
|
+
}, `Queued effort change: ${this._effort ?? "default"} → ${effort ?? "default"}`);
|
|
1205
|
+
return true;
|
|
1206
|
+
}
|
|
1207
|
+
if (this.effortBoundaryBlocked) {
|
|
1208
|
+
await this.completeEffortBoundaryTransition();
|
|
1209
|
+
}
|
|
1210
|
+
else {
|
|
1211
|
+
await this.enqueuePendingEffortApplication();
|
|
1212
|
+
}
|
|
1213
|
+
return true;
|
|
1214
|
+
}
|
|
1215
|
+
async applyEffort(effort) {
|
|
1216
|
+
if (!this.setEffortFn) {
|
|
1217
|
+
throw new Error("Provider does not support dynamic effort changes");
|
|
1218
|
+
}
|
|
1219
|
+
getLogger().info({
|
|
1220
|
+
event: "effort_change",
|
|
1221
|
+
sessionId: this._sessionId,
|
|
1222
|
+
processId: this.id,
|
|
1223
|
+
oldEffort: this._effort,
|
|
1224
|
+
newEffort: effort,
|
|
1225
|
+
}, `Changing effort: ${this._effort ?? "default"} → ${effort ?? "default"}`);
|
|
1226
|
+
await this.setEffortFn(effort);
|
|
1227
|
+
this._effort = effort;
|
|
1228
|
+
}
|
|
1229
|
+
async applyPendingEffort() {
|
|
1230
|
+
while (this.pendingEffortUpdate) {
|
|
1231
|
+
const pending = this.pendingEffortUpdate;
|
|
1232
|
+
try {
|
|
1233
|
+
await this.applyEffort(pending.effort);
|
|
1234
|
+
}
|
|
1235
|
+
catch (error) {
|
|
1236
|
+
if (this.pendingEffortUpdate !== pending) {
|
|
1237
|
+
continue;
|
|
1238
|
+
}
|
|
1239
|
+
throw new Error("Failed to apply queued effort change", {
|
|
1240
|
+
cause: error,
|
|
1241
|
+
});
|
|
1242
|
+
}
|
|
1243
|
+
if (this.pendingEffortUpdate === pending) {
|
|
1244
|
+
this.pendingEffortUpdate = null;
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
enqueuePendingEffortApplication() {
|
|
1249
|
+
const application = this.effortApplyTail.then(() => this.applyPendingEffort());
|
|
1250
|
+
this.effortApplyTail = application.catch(() => { });
|
|
1251
|
+
return application;
|
|
1252
|
+
}
|
|
1253
|
+
completeEffortBoundaryTransition() {
|
|
1254
|
+
if (this.effortBoundaryTransition) {
|
|
1255
|
+
return this.effortBoundaryTransition;
|
|
1256
|
+
}
|
|
1257
|
+
const transition = this.enqueuePendingEffortApplication().then(() => {
|
|
1258
|
+
this.effortBoundaryBlocked = false;
|
|
1259
|
+
this.finishTransitionToIdle();
|
|
1260
|
+
});
|
|
1261
|
+
this.effortBoundaryTransition = transition;
|
|
1262
|
+
void transition.then(() => {
|
|
1263
|
+
if (this.effortBoundaryTransition === transition) {
|
|
1264
|
+
this.effortBoundaryTransition = null;
|
|
1265
|
+
}
|
|
1266
|
+
}, () => {
|
|
1267
|
+
if (this.effortBoundaryTransition === transition) {
|
|
1268
|
+
this.effortBoundaryTransition = null;
|
|
1269
|
+
}
|
|
1270
|
+
});
|
|
1271
|
+
return transition;
|
|
1272
|
+
}
|
|
1111
1273
|
/**
|
|
1112
1274
|
* Whether this process supports dynamic model listing.
|
|
1113
1275
|
* Only Claude SDK 0.2.7+ supports this.
|
|
@@ -1203,6 +1365,11 @@ export class Process {
|
|
|
1203
1365
|
if (!this.setModelFn) {
|
|
1204
1366
|
return false;
|
|
1205
1367
|
}
|
|
1368
|
+
const interruptsRetryingTurn = this._state.type === "in-turn" &&
|
|
1369
|
+
this.providerRuntimeStatus?.kind === "retrying";
|
|
1370
|
+
if (interruptsRetryingTurn && !this.interruptFn) {
|
|
1371
|
+
return false;
|
|
1372
|
+
}
|
|
1206
1373
|
const log = getLogger();
|
|
1207
1374
|
log.info({
|
|
1208
1375
|
event: "model_change",
|
|
@@ -1212,6 +1379,19 @@ export class Process {
|
|
|
1212
1379
|
newModel: model,
|
|
1213
1380
|
}, `Changing model: ${this.model} → ${model}`);
|
|
1214
1381
|
await this.setModelFn(model);
|
|
1382
|
+
if (interruptsRetryingTurn &&
|
|
1383
|
+
this._state.type === "in-turn" &&
|
|
1384
|
+
this.providerRuntimeStatus?.kind === "retrying") {
|
|
1385
|
+
const interrupted = await this.interrupt({
|
|
1386
|
+
preamble: MODEL_SWITCH_RETRY_INTERRUPT_PREAMBLE,
|
|
1387
|
+
});
|
|
1388
|
+
if (!interrupted &&
|
|
1389
|
+
this._state.type === "in-turn" &&
|
|
1390
|
+
this.providerRuntimeStatus?.kind === "retrying") {
|
|
1391
|
+
throw new Error("Provider retry could not be interrupted after changing models");
|
|
1392
|
+
}
|
|
1393
|
+
this.clearRetryingProviderRuntimeStatus();
|
|
1394
|
+
}
|
|
1215
1395
|
// Update resolved model so subsequent API responses reflect the switch
|
|
1216
1396
|
if (model) {
|
|
1217
1397
|
this._resolvedModel = model;
|
|
@@ -1360,11 +1540,24 @@ export class Process {
|
|
|
1360
1540
|
return info;
|
|
1361
1541
|
}
|
|
1362
1542
|
/**
|
|
1363
|
-
* Get recent message history
|
|
1364
|
-
*
|
|
1543
|
+
* Get recent message history for SSE replay.
|
|
1544
|
+
*
|
|
1545
|
+
* Ordinary messages remain available for 15-30 seconds. In-turn steer
|
|
1546
|
+
* echoes remain available through the provider turn so a reconnect cannot
|
|
1547
|
+
* lose an accepted user message before its durable row exists.
|
|
1365
1548
|
*/
|
|
1366
1549
|
getMessageHistory() {
|
|
1367
|
-
|
|
1550
|
+
const buffered = [...this.previousBucket, ...this.currentBucket];
|
|
1551
|
+
if (this.activeSteerEchoes.size === 0) {
|
|
1552
|
+
return buffered;
|
|
1553
|
+
}
|
|
1554
|
+
const bufferedUuids = new Set(buffered
|
|
1555
|
+
.map((message) => message.uuid)
|
|
1556
|
+
.filter((uuid) => typeof uuid === "string"));
|
|
1557
|
+
const expiredSteerEchoes = [...this.activeSteerEchoes.entries()]
|
|
1558
|
+
.filter(([uuid]) => !bufferedUuids.has(uuid))
|
|
1559
|
+
.map(([, message]) => message);
|
|
1560
|
+
return [...expiredSteerEchoes, ...buffered];
|
|
1368
1561
|
}
|
|
1369
1562
|
/**
|
|
1370
1563
|
* Get accumulated streaming text for catch-up when clients connect mid-stream.
|
|
@@ -1860,6 +2053,9 @@ export class Process {
|
|
|
1860
2053
|
if (this._state.type === "in-turn" &&
|
|
1861
2054
|
this.steerFn &&
|
|
1862
2055
|
options?.allowSteer !== false) {
|
|
2056
|
+
if (!hidden && shouldEmitMessage(sdkMessage)) {
|
|
2057
|
+
this.activeSteerEchoes.set(uuid, sdkMessage);
|
|
2058
|
+
}
|
|
1863
2059
|
const steerMessage = {
|
|
1864
2060
|
...messageWithUuid,
|
|
1865
2061
|
// Mirror MessageQueue's attachment expansion for steer payloads.
|
|
@@ -1925,8 +2121,7 @@ export class Process {
|
|
|
1925
2121
|
});
|
|
1926
2122
|
}
|
|
1927
2123
|
persistPatientDeferredEntry(entry) {
|
|
1928
|
-
if (!this.sessionQueuePersistenceService ||
|
|
1929
|
-
!isPatientDeferredEntry(entry, this.provider)) {
|
|
2124
|
+
if (!this.sessionQueuePersistenceService || !hasPatientQueueIntent(entry)) {
|
|
1930
2125
|
return;
|
|
1931
2126
|
}
|
|
1932
2127
|
const item = this.toPersistedPatientDeferredItem(entry, "queued");
|
|
@@ -1937,8 +2132,7 @@ export class Process {
|
|
|
1937
2132
|
}, { action: "upsert", persistedQueueId: item.id });
|
|
1938
2133
|
}
|
|
1939
2134
|
toPersistedPatientDeferredItem(entry, status, updatedAt = entry.timestamp) {
|
|
1940
|
-
if (!this.sessionQueuePersistenceService ||
|
|
1941
|
-
!isPatientDeferredEntry(entry, this.provider)) {
|
|
2135
|
+
if (!this.sessionQueuePersistenceService || !hasPatientQueueIntent(entry)) {
|
|
1942
2136
|
return null;
|
|
1943
2137
|
}
|
|
1944
2138
|
const id = entry.persistedQueueId ?? randomUUID();
|
|
@@ -1972,7 +2166,7 @@ export class Process {
|
|
|
1972
2166
|
return;
|
|
1973
2167
|
}
|
|
1974
2168
|
const ids = entries
|
|
1975
|
-
.filter(
|
|
2169
|
+
.filter(hasPatientQueueIntent)
|
|
1976
2170
|
.map((entry) => entry.persistedQueueId)
|
|
1977
2171
|
.filter((id) => Boolean(id));
|
|
1978
2172
|
if (ids.length === 0) {
|
|
@@ -1988,7 +2182,7 @@ export class Process {
|
|
|
1988
2182
|
if (!this.sessionQueuePersistenceService) {
|
|
1989
2183
|
return 0;
|
|
1990
2184
|
}
|
|
1991
|
-
const entries = this.deferredQueue.filter(
|
|
2185
|
+
const entries = this.deferredQueue.filter(hasPatientQueueIntent);
|
|
1992
2186
|
if (entries.length === 0) {
|
|
1993
2187
|
return 0;
|
|
1994
2188
|
}
|
|
@@ -2037,10 +2231,10 @@ export class Process {
|
|
|
2037
2231
|
deferMessage(message, options) {
|
|
2038
2232
|
const canPromoteIfReady = !!(options?.promoteIfReady &&
|
|
2039
2233
|
this.messageQueue &&
|
|
2040
|
-
// Only
|
|
2041
|
-
// elsewhere
|
|
2234
|
+
// Only Claude waits for the verified-idle patient delivery path;
|
|
2235
|
+
// elsewhere durable patient intent uses ordinary deferred timing and
|
|
2042
2236
|
// promotes immediately like any other deferred turn.
|
|
2043
|
-
!
|
|
2237
|
+
!usesPatientDeliveryPath({ message, timestamp: new Date().toISOString() }, this.provider) &&
|
|
2044
2238
|
this._state.type === "idle");
|
|
2045
2239
|
if (canPromoteIfReady) {
|
|
2046
2240
|
const result = this.queueMessage(message);
|
|
@@ -2127,6 +2321,22 @@ export class Process {
|
|
|
2127
2321
|
removeBufferedEchoByTempId(tempId) {
|
|
2128
2322
|
this.currentBucket = this.currentBucket.filter((message) => !this.sdkMessageMatchesTempId(message, tempId));
|
|
2129
2323
|
this.previousBucket = this.previousBucket.filter((message) => !this.sdkMessageMatchesTempId(message, tempId));
|
|
2324
|
+
for (const [uuid, message] of this.activeSteerEchoes) {
|
|
2325
|
+
if (this.sdkMessageMatchesTempId(message, tempId)) {
|
|
2326
|
+
this.activeSteerEchoes.delete(uuid);
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
releaseActiveSteerEchoes() {
|
|
2331
|
+
const bufferedUuids = new Set([...this.previousBucket, ...this.currentBucket]
|
|
2332
|
+
.map((message) => message.uuid)
|
|
2333
|
+
.filter((uuid) => typeof uuid === "string"));
|
|
2334
|
+
for (const [uuid, message] of this.activeSteerEchoes) {
|
|
2335
|
+
if (!bufferedUuids.has(uuid)) {
|
|
2336
|
+
this.currentBucket.push(message);
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
this.activeSteerEchoes.clear();
|
|
2130
2340
|
}
|
|
2131
2341
|
/**
|
|
2132
2342
|
* Get a summary of the deferred queue for SSE events and client sync.
|
|
@@ -2547,29 +2757,81 @@ export class Process {
|
|
|
2547
2757
|
terminate(reason) {
|
|
2548
2758
|
// Kill the underlying CLI process first (if available), so it doesn't
|
|
2549
2759
|
// continue running as an orphan after we unregister from the Supervisor.
|
|
2550
|
-
|
|
2551
|
-
this.abortFn();
|
|
2552
|
-
}
|
|
2760
|
+
this.requestProviderAbortWithoutWaiting(reason);
|
|
2553
2761
|
this.markTerminated(reason);
|
|
2554
2762
|
}
|
|
2763
|
+
async requestProviderAbort() {
|
|
2764
|
+
await this.abortFn?.();
|
|
2765
|
+
}
|
|
2766
|
+
requestProviderAbortWithoutWaiting(reason) {
|
|
2767
|
+
void this.requestProviderAbort().catch((error) => {
|
|
2768
|
+
getLogger().error({
|
|
2769
|
+
event: "provider_abort_failed",
|
|
2770
|
+
sessionId: this._sessionId,
|
|
2771
|
+
processId: this.id,
|
|
2772
|
+
projectId: this.projectId,
|
|
2773
|
+
reason,
|
|
2774
|
+
errorMessage: error instanceof Error ? error.message : String(error),
|
|
2775
|
+
}, `Provider abort failed: ${this._sessionId}`);
|
|
2776
|
+
});
|
|
2777
|
+
}
|
|
2555
2778
|
async abort() {
|
|
2556
2779
|
this.clearIdleTimer();
|
|
2557
2780
|
this.clearPromptCacheKeepaliveTimer();
|
|
2558
2781
|
this.stopBucketSwapTimer();
|
|
2559
2782
|
this.clearRetryingProviderRuntimeStatus();
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2783
|
+
const pid = this.pid;
|
|
2784
|
+
const deadline = Date.now() + PROCESS_ABORT_TIMEOUT_MS;
|
|
2785
|
+
const providerAbortOutcome = this.requestProviderAbort().then(() => ({ ok: true }), (error) => ({ ok: false, error }));
|
|
2786
|
+
let verification;
|
|
2787
|
+
if (pid !== undefined && this.executor === undefined) {
|
|
2788
|
+
const remainingMs = Math.max(0, deadline - Date.now());
|
|
2789
|
+
if (!(await waitForLocalPidExit(pid, remainingMs))) {
|
|
2790
|
+
throw new Error(`Provider PID ${pid} is still running after abort`);
|
|
2791
|
+
}
|
|
2792
|
+
// A provider may own descendants in the same process group after its
|
|
2793
|
+
// leader exits. When it exposes stronger liveness, let its shutdown
|
|
2794
|
+
// promise finish and require that group-level check to agree.
|
|
2795
|
+
const providerAliveAfterPidExit = this._isProcessAlive?.();
|
|
2796
|
+
if (providerAliveAfterPidExit !== undefined &&
|
|
2797
|
+
providerAliveAfterPidExit) {
|
|
2798
|
+
const abortOutcome = await waitUntilAbortDeadline(providerAbortOutcome, deadline, `Timed out waiting for provider process group ${pid} to stop`);
|
|
2799
|
+
if (!abortOutcome.ok)
|
|
2800
|
+
throw abortOutcome.error;
|
|
2801
|
+
if (this._isProcessAlive?.() !== false) {
|
|
2802
|
+
throw new Error(`Provider process group for PID ${pid} is still running after abort`);
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2805
|
+
verification = "pid";
|
|
2806
|
+
}
|
|
2807
|
+
else {
|
|
2808
|
+
const abortOutcome = await waitUntilAbortDeadline(providerAbortOutcome, deadline, "Timed out waiting for provider shutdown");
|
|
2809
|
+
if (!abortOutcome.ok)
|
|
2810
|
+
throw abortOutcome.error;
|
|
2811
|
+
}
|
|
2812
|
+
if (verification === undefined && this._isProcessAlive) {
|
|
2813
|
+
if (this.isProcessAlive !== false) {
|
|
2814
|
+
throw new Error("Provider still reports its process as running after abort");
|
|
2815
|
+
}
|
|
2816
|
+
verification = "provider";
|
|
2817
|
+
}
|
|
2818
|
+
else if (verification === undefined) {
|
|
2819
|
+
await waitUntilAbortDeadline(this._exitPromise, deadline, "Timed out waiting for provider iterator to stop");
|
|
2820
|
+
verification = "iterator";
|
|
2563
2821
|
}
|
|
2564
|
-
// Wait for CLI process to fully exit (with timeout to avoid hanging)
|
|
2565
|
-
const timeout = new Promise((resolve) => setTimeout(resolve, 5000));
|
|
2566
|
-
await Promise.race([this._exitPromise, timeout]);
|
|
2567
2822
|
// Signal completion to subscribers (skip if already terminated —
|
|
2568
2823
|
// markTerminated() already emitted "complete")
|
|
2569
2824
|
if (this._state.type !== "terminated") {
|
|
2570
2825
|
this.emit({ type: "complete" });
|
|
2571
2826
|
}
|
|
2572
2827
|
this.listeners.clear();
|
|
2828
|
+
return {
|
|
2829
|
+
processId: this.id,
|
|
2830
|
+
sessionId: this._sessionId,
|
|
2831
|
+
...(pid !== undefined ? { pid } : {}),
|
|
2832
|
+
verifiedStopped: true,
|
|
2833
|
+
verification,
|
|
2834
|
+
};
|
|
2573
2835
|
}
|
|
2574
2836
|
async processMessages() {
|
|
2575
2837
|
try {
|
|
@@ -2579,7 +2841,7 @@ export class Process {
|
|
|
2579
2841
|
this.iteratorDone = true;
|
|
2580
2842
|
// Don't transition to idle if we're waiting for input
|
|
2581
2843
|
if (this._state.type !== "waiting-input") {
|
|
2582
|
-
this.transitionToIdle();
|
|
2844
|
+
this.transitionToIdle({ applyPendingEffort: false });
|
|
2583
2845
|
}
|
|
2584
2846
|
break;
|
|
2585
2847
|
}
|
|
@@ -2659,14 +2921,17 @@ export class Process {
|
|
|
2659
2921
|
this.emit({ type: "message", message });
|
|
2660
2922
|
}
|
|
2661
2923
|
if (isClaudeSdkApiErrorMessage(this.provider, message)) {
|
|
2662
|
-
this.
|
|
2924
|
+
this.requestProviderAbortWithoutWaiting("Claude SDK API error; restart required");
|
|
2663
2925
|
this.markTerminated("Claude SDK API error; restart required", new Error(describeClaudeSdkApiError(message)));
|
|
2664
2926
|
return;
|
|
2665
2927
|
}
|
|
2666
2928
|
// Handle special message types
|
|
2667
2929
|
const claudeSessionState = getClaudeSessionStateChange(message);
|
|
2668
2930
|
if (claudeSessionState) {
|
|
2669
|
-
this.handleClaudeSessionStateChanged(claudeSessionState);
|
|
2931
|
+
const effortUpdate = this.handleClaudeSessionStateChanged(claudeSessionState);
|
|
2932
|
+
if (effortUpdate) {
|
|
2933
|
+
await effortUpdate;
|
|
2934
|
+
}
|
|
2670
2935
|
}
|
|
2671
2936
|
else if (message.type === "system" &&
|
|
2672
2937
|
message.subtype === "input_request") {
|
|
@@ -2696,7 +2961,10 @@ export class Process {
|
|
|
2696
2961
|
}
|
|
2697
2962
|
}
|
|
2698
2963
|
}
|
|
2699
|
-
this.transitionToIdle();
|
|
2964
|
+
const effortUpdate = this.transitionToIdle();
|
|
2965
|
+
if (effortUpdate) {
|
|
2966
|
+
await effortUpdate;
|
|
2967
|
+
}
|
|
2700
2968
|
}
|
|
2701
2969
|
// Note: deferred messages are intentionally NOT promoted at completed
|
|
2702
2970
|
// tool-result boundaries. A queued (`deferred`) item delivers at the
|
|
@@ -2731,8 +2999,11 @@ export class Process {
|
|
|
2731
2999
|
return;
|
|
2732
3000
|
}
|
|
2733
3001
|
// Don't transition to idle if we're waiting for input
|
|
2734
|
-
if (this._state.type !== "waiting-input") {
|
|
2735
|
-
this.transitionToIdle();
|
|
3002
|
+
if (this._state.type !== "waiting-input" && !this.effortBoundaryBlocked) {
|
|
3003
|
+
const effortUpdate = this.transitionToIdle();
|
|
3004
|
+
if (effortUpdate) {
|
|
3005
|
+
await effortUpdate;
|
|
3006
|
+
}
|
|
2736
3007
|
}
|
|
2737
3008
|
}
|
|
2738
3009
|
finally {
|
|
@@ -2780,7 +3051,7 @@ export class Process {
|
|
|
2780
3051
|
switch (state) {
|
|
2781
3052
|
case "idle":
|
|
2782
3053
|
if (this._state.type !== "waiting-input") {
|
|
2783
|
-
this.transitionToIdle();
|
|
3054
|
+
return this.transitionToIdle();
|
|
2784
3055
|
}
|
|
2785
3056
|
break;
|
|
2786
3057
|
case "running":
|
|
@@ -2806,9 +3077,38 @@ export class Process {
|
|
|
2806
3077
|
break;
|
|
2807
3078
|
}
|
|
2808
3079
|
}
|
|
2809
|
-
transitionToIdle() {
|
|
3080
|
+
transitionToIdle(options) {
|
|
2810
3081
|
this.clearIdleTimer();
|
|
2811
3082
|
this.clearRetryingProviderRuntimeStatus();
|
|
3083
|
+
// A provider turn boundary ends the special steering-retention window.
|
|
3084
|
+
// Move any aged-out echoes back into the ordinary replay window to cover
|
|
3085
|
+
// the short gap before the provider's durable transcript becomes visible.
|
|
3086
|
+
this.releaseActiveSteerEchoes();
|
|
3087
|
+
if (options?.applyPendingEffort !== false && this.pendingEffortUpdate) {
|
|
3088
|
+
this.effortBoundaryBlocked = true;
|
|
3089
|
+
return this.completeEffortBoundaryTransition().catch((error) => {
|
|
3090
|
+
const requestedEffort = this.pendingEffortUpdate?.effort;
|
|
3091
|
+
const configurationError = new Error("Failed to apply effort; queued work remains blocked until retry", { cause: error });
|
|
3092
|
+
getLogger().error({
|
|
3093
|
+
event: "effort_change_boundary_failed",
|
|
3094
|
+
sessionId: this._sessionId,
|
|
3095
|
+
processId: this.id,
|
|
3096
|
+
projectId: this.projectId,
|
|
3097
|
+
requestedEffort,
|
|
3098
|
+
errorMessage: error instanceof Error ? error.message : String(error),
|
|
3099
|
+
}, "Failed to apply effort before queued work");
|
|
3100
|
+
this.emit({
|
|
3101
|
+
type: "configuration-error",
|
|
3102
|
+
setting: "effort",
|
|
3103
|
+
requestedValue: requestedEffort,
|
|
3104
|
+
error: configurationError,
|
|
3105
|
+
});
|
|
3106
|
+
});
|
|
3107
|
+
}
|
|
3108
|
+
this.effortBoundaryBlocked = false;
|
|
3109
|
+
this.finishTransitionToIdle();
|
|
3110
|
+
}
|
|
3111
|
+
finishTransitionToIdle() {
|
|
2812
3112
|
// Promote deferred messages as the same stitched user turn the provider
|
|
2813
3113
|
// receives, so the live echo and later transcript catch-up agree.
|
|
2814
3114
|
if (this.promoteEligibleDeferredAfterTurn()) {
|
|
@@ -2914,7 +3214,7 @@ export class Process {
|
|
|
2914
3214
|
if (this.deferredQueue.length === 0 || !this.messageQueue) {
|
|
2915
3215
|
return false;
|
|
2916
3216
|
}
|
|
2917
|
-
const eligible = this.deferredQueue.filter((entry) => !
|
|
3217
|
+
const eligible = this.deferredQueue.filter((entry) => !usesPatientDeliveryPath(entry, this.provider));
|
|
2918
3218
|
if (eligible.length === 0) {
|
|
2919
3219
|
return false;
|
|
2920
3220
|
}
|
|
@@ -2934,6 +3234,7 @@ export class Process {
|
|
|
2934
3234
|
}
|
|
2935
3235
|
const promotedEntries = new Set(group);
|
|
2936
3236
|
this.deferredQueue = this.deferredQueue.filter((entry) => !promotedEntries.has(entry));
|
|
3237
|
+
this.deletePersistedPatientDeferredEntries(group, "promoted");
|
|
2937
3238
|
this.emitDeferredQueueChange("promoted", group.length === 1 ? group[0].message.tempId : undefined);
|
|
2938
3239
|
return true;
|
|
2939
3240
|
}
|
|
@@ -2955,7 +3256,7 @@ export class Process {
|
|
|
2955
3256
|
this._state.type !== "idle") {
|
|
2956
3257
|
return { promoted: false, nextPatienceMsRemaining: null };
|
|
2957
3258
|
}
|
|
2958
|
-
const patientEntries = this.deferredQueue.filter((entry) =>
|
|
3259
|
+
const patientEntries = this.deferredQueue.filter((entry) => usesPatientDeliveryPath(entry, this.provider));
|
|
2959
3260
|
if (patientEntries.length === 0) {
|
|
2960
3261
|
return { promoted: false, nextPatienceMsRemaining: null };
|
|
2961
3262
|
}
|
|
@@ -3150,9 +3451,7 @@ export class Process {
|
|
|
3150
3451
|
this.iteratorDone = true;
|
|
3151
3452
|
this.clearRetryingProviderRuntimeStatus();
|
|
3152
3453
|
this.emit({ type: "idle-reap" });
|
|
3153
|
-
|
|
3154
|
-
this.abortFn();
|
|
3155
|
-
}
|
|
3454
|
+
this.requestProviderAbortWithoutWaiting("idle reap");
|
|
3156
3455
|
this.emit({ type: "complete" });
|
|
3157
3456
|
this.listeners.clear();
|
|
3158
3457
|
if (this._exitResolve) {
|