@qduc/term2 0.17.0 → 0.19.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/dist/agent.d.ts +2 -0
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +4 -1
- package/dist/agent.js.map +1 -1
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +12 -2
- package/dist/app.js.map +1 -1
- package/dist/commands/retry-failed-turn-command.d.ts +6 -0
- package/dist/commands/retry-failed-turn-command.d.ts.map +1 -0
- package/dist/commands/retry-failed-turn-command.js +12 -0
- package/dist/commands/retry-failed-turn-command.js.map +1 -0
- package/dist/components/layout/BackgroundTaskManager.d.ts.map +1 -1
- package/dist/components/layout/BackgroundTaskManager.js +4 -0
- package/dist/components/layout/BackgroundTaskManager.js.map +1 -1
- package/dist/components/layout/BackgroundTasksPanel.d.ts.map +1 -1
- package/dist/components/layout/BackgroundTasksPanel.js +11 -1
- package/dist/components/layout/BackgroundTasksPanel.js.map +1 -1
- package/dist/components/layout/BottomArea.d.ts +6 -0
- package/dist/components/layout/BottomArea.d.ts.map +1 -1
- package/dist/components/layout/BottomArea.js +14 -5
- package/dist/components/layout/BottomArea.js.map +1 -1
- package/dist/components/layout/StatusBar.d.ts +6 -0
- package/dist/components/layout/StatusBar.d.ts.map +1 -1
- package/dist/components/layout/StatusBar.js +15 -4
- package/dist/components/layout/StatusBar.js.map +1 -1
- package/dist/components/message/ChatMessage.js +3 -1
- package/dist/components/message/ChatMessage.js.map +1 -1
- package/dist/components/message/CommandGroupSummary.js +4 -5
- package/dist/components/message/CommandGroupSummary.js.map +1 -1
- package/dist/components/message/MessageList.d.ts.map +1 -1
- package/dist/components/message/MessageList.js +15 -2
- package/dist/components/message/MessageList.js.map +1 -1
- package/dist/components/message/command-grouping.d.ts +1 -0
- package/dist/components/message/command-grouping.d.ts.map +1 -1
- package/dist/components/message/command-grouping.js +14 -7
- package/dist/components/message/command-grouping.js.map +1 -1
- package/dist/components/message/command-message-helpers.d.ts +5 -5
- package/dist/contracts/conversation.d.ts +2 -0
- package/dist/contracts/conversation.d.ts.map +1 -1
- package/dist/contracts/conversation.js.map +1 -1
- package/dist/contracts/run-termination.d.ts +7 -0
- package/dist/contracts/run-termination.d.ts.map +1 -0
- package/dist/contracts/run-termination.js +2 -0
- package/dist/contracts/run-termination.js.map +1 -0
- package/dist/contracts/session-rollover.d.ts +32 -0
- package/dist/contracts/session-rollover.d.ts.map +1 -0
- package/dist/contracts/session-rollover.js +2 -0
- package/dist/contracts/session-rollover.js.map +1 -0
- package/dist/contracts/streamed-model-turn.d.ts +4 -0
- package/dist/contracts/streamed-model-turn.d.ts.map +1 -1
- package/dist/hooks/conversation-ui-reducer.d.ts +7 -0
- package/dist/hooks/conversation-ui-reducer.d.ts.map +1 -1
- package/dist/hooks/conversation-ui-reducer.js +6 -0
- package/dist/hooks/conversation-ui-reducer.js.map +1 -1
- package/dist/hooks/settings-completion-config.d.ts.map +1 -1
- package/dist/hooks/settings-completion-config.js +6 -0
- package/dist/hooks/settings-completion-config.js.map +1 -1
- package/dist/hooks/use-app-commands.d.ts +2 -1
- package/dist/hooks/use-app-commands.d.ts.map +1 -1
- package/dist/hooks/use-app-commands.js +4 -1
- package/dist/hooks/use-app-commands.js.map +1 -1
- package/dist/hooks/use-conversation.d.ts +9 -1
- package/dist/hooks/use-conversation.d.ts.map +1 -1
- package/dist/hooks/use-conversation.js +42 -6
- package/dist/hooks/use-conversation.js.map +1 -1
- package/dist/hooks/use-model-selection.d.ts +2 -0
- package/dist/hooks/use-model-selection.d.ts.map +1 -1
- package/dist/hooks/use-model-selection.js +3 -3
- package/dist/hooks/use-model-selection.js.map +1 -1
- package/dist/lib/agent-client.d.ts +4 -0
- package/dist/lib/agent-client.d.ts.map +1 -1
- package/dist/lib/agent-client.js +120 -23
- package/dist/lib/agent-client.js.map +1 -1
- package/dist/lib/agent-configuration.d.ts +2 -0
- package/dist/lib/agent-configuration.d.ts.map +1 -1
- package/dist/lib/agent-configuration.js +3 -0
- package/dist/lib/agent-configuration.js.map +1 -1
- package/dist/lib/agent-factory.d.ts +2 -0
- package/dist/lib/agent-factory.d.ts.map +1 -1
- package/dist/lib/agent-factory.js +1 -0
- package/dist/lib/agent-factory.js.map +1 -1
- package/dist/providers/aborted-stream-recorder.d.ts +26 -1
- package/dist/providers/aborted-stream-recorder.d.ts.map +1 -1
- package/dist/providers/aborted-stream-recorder.js +133 -0
- package/dist/providers/aborted-stream-recorder.js.map +1 -1
- package/dist/providers/ai-sdk-streamed-model.d.ts +5 -0
- package/dist/providers/ai-sdk-streamed-model.d.ts.map +1 -1
- package/dist/providers/ai-sdk-streamed-model.js +90 -1
- package/dist/providers/ai-sdk-streamed-model.js.map +1 -1
- package/dist/providers/codex-compact.d.ts +5 -4
- package/dist/providers/codex-compact.d.ts.map +1 -1
- package/dist/providers/codex-compact.js +5 -4
- package/dist/providers/codex-compact.js.map +1 -1
- package/dist/providers/codex-responses-model.d.ts.map +1 -1
- package/dist/providers/codex-responses-model.js +103 -20
- package/dist/providers/codex-responses-model.js.map +1 -1
- package/dist/providers/codex.provider.d.ts +1 -0
- package/dist/providers/codex.provider.d.ts.map +1 -1
- package/dist/providers/codex.provider.js +59 -3
- package/dist/providers/codex.provider.js.map +1 -1
- package/dist/providers/fetch/logging-middleware.d.ts +1 -0
- package/dist/providers/fetch/logging-middleware.d.ts.map +1 -1
- package/dist/providers/fetch/logging-middleware.js +24 -1
- package/dist/providers/fetch/logging-middleware.js.map +1 -1
- package/dist/providers/openai-chat-completions-model.d.ts.map +1 -1
- package/dist/providers/openai-chat-completions-model.js +99 -2
- package/dist/providers/openai-chat-completions-model.js.map +1 -1
- package/dist/providers/openai-responses-model.d.ts.map +1 -1
- package/dist/providers/openai-responses-model.js +21 -13
- package/dist/providers/openai-responses-model.js.map +1 -1
- package/dist/providers/retrying-model.d.ts +5 -1
- package/dist/providers/retrying-model.d.ts.map +1 -1
- package/dist/providers/retrying-model.js +29 -6
- package/dist/providers/retrying-model.js.map +1 -1
- package/dist/providers/websocket-abort-race.d.ts +13 -0
- package/dist/providers/websocket-abort-race.d.ts.map +1 -0
- package/dist/providers/websocket-abort-race.js +34 -0
- package/dist/providers/websocket-abort-race.js.map +1 -0
- package/dist/services/agent-runtime/application-run-loop.d.ts +7 -0
- package/dist/services/agent-runtime/application-run-loop.d.ts.map +1 -1
- package/dist/services/agent-runtime/application-run-loop.js +56 -7
- package/dist/services/agent-runtime/application-run-loop.js.map +1 -1
- package/dist/services/agent-runtime/context-compaction/context-milestone-reminder.d.ts +12 -0
- package/dist/services/agent-runtime/context-compaction/context-milestone-reminder.d.ts.map +1 -0
- package/dist/services/agent-runtime/context-compaction/context-milestone-reminder.js +23 -0
- package/dist/services/agent-runtime/context-compaction/context-milestone-reminder.js.map +1 -0
- package/dist/services/agent-runtime/executor.d.ts.map +1 -1
- package/dist/services/agent-runtime/executor.js +2 -0
- package/dist/services/agent-runtime/executor.js.map +1 -1
- package/dist/services/agent-runtime/types.d.ts +2 -2
- package/dist/services/agent-runtime/types.d.ts.map +1 -1
- package/dist/services/agent-stream.d.ts +13 -0
- package/dist/services/agent-stream.d.ts.map +1 -1
- package/dist/services/agent-stream.js +56 -0
- package/dist/services/agent-stream.js.map +1 -1
- package/dist/services/background-task-activity.d.ts +7 -0
- package/dist/services/background-task-activity.d.ts.map +1 -1
- package/dist/services/background-task-activity.js +17 -0
- package/dist/services/background-task-activity.js.map +1 -1
- package/dist/services/conversation/conversation-adapter.d.ts +1 -0
- package/dist/services/conversation/conversation-adapter.d.ts.map +1 -1
- package/dist/services/conversation/conversation-adapter.js +3 -0
- package/dist/services/conversation/conversation-adapter.js.map +1 -1
- package/dist/services/conversation/conversation-decoder.d.ts.map +1 -1
- package/dist/services/conversation/conversation-decoder.js +3 -0
- package/dist/services/conversation/conversation-decoder.js.map +1 -1
- package/dist/services/conversation/conversation-events.d.ts +45 -2
- package/dist/services/conversation/conversation-events.d.ts.map +1 -1
- package/dist/services/conversation/conversation-events.js +30 -1
- package/dist/services/conversation/conversation-events.js.map +1 -1
- package/dist/services/conversation/conversation-orchestrator.d.ts +4 -0
- package/dist/services/conversation/conversation-orchestrator.d.ts.map +1 -1
- package/dist/services/conversation/conversation-orchestrator.js +74 -4
- package/dist/services/conversation/conversation-orchestrator.js.map +1 -1
- package/dist/services/conversation/conversation-orchestrator.types.d.ts +4 -0
- package/dist/services/conversation/conversation-orchestrator.types.d.ts.map +1 -1
- package/dist/services/conversation/conversation-result-builder.d.ts.map +1 -1
- package/dist/services/conversation/conversation-result-builder.js +9 -5
- package/dist/services/conversation/conversation-result-builder.js.map +1 -1
- package/dist/services/conversation/conversation-service.d.ts +5 -0
- package/dist/services/conversation/conversation-service.d.ts.map +1 -1
- package/dist/services/conversation/conversation-service.js +31 -0
- package/dist/services/conversation/conversation-service.js.map +1 -1
- package/dist/services/conversation/session-browser.d.ts +1 -0
- package/dist/services/conversation/session-browser.d.ts.map +1 -1
- package/dist/services/conversation/session-browser.js +32 -38
- package/dist/services/conversation/session-browser.js.map +1 -1
- package/dist/services/conversation-agent-client.d.ts +7 -0
- package/dist/services/conversation-agent-client.d.ts.map +1 -1
- package/dist/services/logging/conversation-log-events.d.ts +6 -1
- package/dist/services/logging/conversation-log-events.d.ts.map +1 -1
- package/dist/services/logging/conversation-log-events.js.map +1 -1
- package/dist/services/logging/conversation-log-writer.d.ts +1 -1
- package/dist/services/logging/conversation-log-writer.d.ts.map +1 -1
- package/dist/services/logging/conversation-log-writer.js +6 -1
- package/dist/services/logging/conversation-log-writer.js.map +1 -1
- package/dist/services/logging/provider-traffic.d.ts +6 -1
- package/dist/services/logging/provider-traffic.d.ts.map +1 -1
- package/dist/services/logging/provider-traffic.js +29 -4
- package/dist/services/logging/provider-traffic.js.map +1 -1
- package/dist/services/models/model-catalog-session.d.ts +1 -2
- package/dist/services/models/model-catalog-session.d.ts.map +1 -1
- package/dist/services/retry/committed-tool-continuation.d.ts +4 -0
- package/dist/services/retry/committed-tool-continuation.d.ts.map +1 -0
- package/dist/services/retry/committed-tool-continuation.js +12 -0
- package/dist/services/retry/committed-tool-continuation.js.map +1 -0
- package/dist/services/retry/in-loop-model-retry.d.ts.map +1 -1
- package/dist/services/retry/in-loop-model-retry.js +9 -0
- package/dist/services/retry/in-loop-model-retry.js.map +1 -1
- package/dist/services/retry/provider-failure-classification.d.ts +12 -0
- package/dist/services/retry/provider-failure-classification.d.ts.map +1 -0
- package/dist/services/retry/provider-failure-classification.js +55 -0
- package/dist/services/retry/provider-failure-classification.js.map +1 -0
- package/dist/services/retry/retry-classifier.d.ts.map +1 -1
- package/dist/services/retry/retry-classifier.js +68 -0
- package/dist/services/retry/retry-classifier.js.map +1 -1
- package/dist/services/retry/retry-contracts.d.ts +24 -3
- package/dist/services/retry/retry-contracts.d.ts.map +1 -1
- package/dist/services/retry/retry-event-presenter.d.ts.map +1 -1
- package/dist/services/retry/retry-event-presenter.js +14 -4
- package/dist/services/retry/retry-event-presenter.js.map +1 -1
- package/dist/services/retry/retry-recovery-budget.d.ts +51 -0
- package/dist/services/retry/retry-recovery-budget.d.ts.map +1 -0
- package/dist/services/retry/retry-recovery-budget.js +84 -0
- package/dist/services/retry/retry-recovery-budget.js.map +1 -0
- package/dist/services/service-interfaces.d.ts +67 -3
- package/dist/services/service-interfaces.d.ts.map +1 -1
- package/dist/services/session/background-check-in-scheduler.d.ts +5 -0
- package/dist/services/session/background-check-in-scheduler.d.ts.map +1 -1
- package/dist/services/session/background-check-in-scheduler.js +83 -10
- package/dist/services/session/background-check-in-scheduler.js.map +1 -1
- package/dist/services/session/continuation-recovery-handler.d.ts +1 -0
- package/dist/services/session/continuation-recovery-handler.d.ts.map +1 -1
- package/dist/services/session/continuation-recovery-handler.js +42 -0
- package/dist/services/session/continuation-recovery-handler.js.map +1 -1
- package/dist/services/session/continuation-state.d.ts +4 -1
- package/dist/services/session/continuation-state.d.ts.map +1 -1
- package/dist/services/session/continuation-state.js +5 -1
- package/dist/services/session/continuation-state.js.map +1 -1
- package/dist/services/session/initial-turn-recovery-handler.d.ts +3 -0
- package/dist/services/session/initial-turn-recovery-handler.d.ts.map +1 -1
- package/dist/services/session/initial-turn-recovery-handler.js +70 -0
- package/dist/services/session/initial-turn-recovery-handler.js.map +1 -1
- package/dist/services/session/session-composition.d.ts.map +1 -1
- package/dist/services/session/session-composition.js +6 -0
- package/dist/services/session/session-composition.js.map +1 -1
- package/dist/services/session/session-tool-tracker.d.ts +6 -0
- package/dist/services/session/session-tool-tracker.d.ts.map +1 -1
- package/dist/services/session/session-tool-tracker.js +17 -0
- package/dist/services/session/session-tool-tracker.js.map +1 -1
- package/dist/services/session/terminal-result-collector.d.ts.map +1 -1
- package/dist/services/session/terminal-result-collector.js +3 -0
- package/dist/services/session/terminal-result-collector.js.map +1 -1
- package/dist/services/session/turn-attempt-factory.d.ts +2 -0
- package/dist/services/session/turn-attempt-factory.d.ts.map +1 -1
- package/dist/services/session/turn-attempt-factory.js +1 -0
- package/dist/services/session/turn-attempt-factory.js.map +1 -1
- package/dist/services/session/turn-attempt.d.ts +6 -0
- package/dist/services/session/turn-attempt.d.ts.map +1 -1
- package/dist/services/session/turn-attempt.js +16 -0
- package/dist/services/session/turn-attempt.js.map +1 -1
- package/dist/services/session/turn-workflow.d.ts +1 -1
- package/dist/services/session/turn-workflow.d.ts.map +1 -1
- package/dist/services/session/turn-workflow.js +83 -19
- package/dist/services/session/turn-workflow.js.map +1 -1
- package/dist/services/session-rollover/session-rollover-brief.d.ts +6 -0
- package/dist/services/session-rollover/session-rollover-brief.d.ts.map +1 -0
- package/dist/services/session-rollover/session-rollover-brief.js +27 -0
- package/dist/services/session-rollover/session-rollover-brief.js.map +1 -0
- package/dist/services/settings/settings-schema.d.ts +18 -0
- package/dist/services/settings/settings-schema.d.ts.map +1 -1
- package/dist/services/settings/settings-schema.js +19 -0
- package/dist/services/settings/settings-schema.js.map +1 -1
- package/dist/services/settings/settings-sources.d.ts.map +1 -1
- package/dist/services/settings/settings-sources.js +5 -0
- package/dist/services/settings/settings-sources.js.map +1 -1
- package/dist/services/settings/test-helpers/settings-consumer-inventory.d.ts +1 -0
- package/dist/services/settings/test-helpers/settings-consumer-inventory.d.ts.map +1 -1
- package/dist/services/settings/test-helpers/settings-consumer-inventory.js +5 -0
- package/dist/services/settings/test-helpers/settings-consumer-inventory.js.map +1 -1
- package/dist/services/subagents/execution-runner.d.ts.map +1 -1
- package/dist/services/subagents/execution-runner.js +39 -4
- package/dist/services/subagents/execution-runner.js.map +1 -1
- package/dist/services/subagents/nested-runner.d.ts.map +1 -1
- package/dist/services/subagents/nested-runner.js +23 -7
- package/dist/services/subagents/nested-runner.js.map +1 -1
- package/dist/services/subagents/subagent-async-registry.d.ts.map +1 -1
- package/dist/services/subagents/subagent-async-registry.js +28 -2
- package/dist/services/subagents/subagent-async-registry.js.map +1 -1
- package/dist/services/subagents/subagent-notification-store.d.ts +4 -14
- package/dist/services/subagents/subagent-notification-store.d.ts.map +1 -1
- package/dist/services/subagents/subagent-notification-store.js +3 -2
- package/dist/services/subagents/subagent-notification-store.js.map +1 -1
- package/dist/services/subagents/types.d.ts +31 -8
- package/dist/services/subagents/types.d.ts.map +1 -1
- package/dist/services/subagents/types.js +11 -0
- package/dist/services/subagents/types.js.map +1 -1
- package/dist/services/subagents/utils.d.ts.map +1 -1
- package/dist/services/subagents/utils.js +3 -0
- package/dist/services/subagents/utils.js.map +1 -1
- package/dist/test-helpers/terminal-e2e.d.ts +2 -0
- package/dist/test-helpers/terminal-e2e.d.ts.map +1 -1
- package/dist/test-helpers/terminal-e2e.js +13 -6
- package/dist/test-helpers/terminal-e2e.js.map +1 -1
- package/dist/test-helpers/vitest-network-guard.d.ts +2 -0
- package/dist/test-helpers/vitest-network-guard.d.ts.map +1 -0
- package/dist/test-helpers/vitest-network-guard.js +24 -0
- package/dist/test-helpers/vitest-network-guard.js.map +1 -0
- package/dist/tools/agent/run-subagent-async.d.ts +1 -1
- package/dist/tools/agent/run-subagent-async.d.ts.map +1 -1
- package/dist/tools/agent/run-subagent-async.js +25 -4
- package/dist/tools/agent/run-subagent-async.js.map +1 -1
- package/dist/tools/session-rollover/session-rollover-tool.d.ts +12 -0
- package/dist/tools/session-rollover/session-rollover-tool.d.ts.map +1 -0
- package/dist/tools/session-rollover/session-rollover-tool.js +35 -0
- package/dist/tools/session-rollover/session-rollover-tool.js.map +1 -0
- package/dist/tools/types.d.ts +4 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js.map +1 -1
- package/dist/types/message.d.ts +2 -0
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/message.js.map +1 -1
- package/dist/utils/ai/token-usage.d.ts +3 -0
- package/dist/utils/ai/token-usage.d.ts.map +1 -1
- package/dist/utils/ai/token-usage.js +29 -0
- package/dist/utils/ai/token-usage.js.map +1 -1
- package/dist/utils/conversation/conversation-event-handler.d.ts.map +1 -1
- package/dist/utils/conversation/conversation-event-handler.js +23 -1
- package/dist/utils/conversation/conversation-event-handler.js.map +1 -1
- package/dist/utils/streaming/streaming-session-factory.d.ts +4 -0
- package/dist/utils/streaming/streaming-session-factory.d.ts.map +1 -1
- package/dist/utils/streaming/streaming-session-factory.js +59 -9
- package/dist/utils/streaming/streaming-session-factory.js.map +1 -1
- package/dist/utils/streaming/streaming-speed-tracker.d.ts +99 -0
- package/dist/utils/streaming/streaming-speed-tracker.d.ts.map +1 -0
- package/dist/utils/streaming/streaming-speed-tracker.js +214 -0
- package/dist/utils/streaming/streaming-speed-tracker.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry-event-presenter.d.ts","sourceRoot":"","sources":["../../../source/services/retry/retry-event-presenter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"retry-event-presenter.d.ts","sourceRoot":"","sources":["../../../source/services/retry/retry-event-presenter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAIhF,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,SAAS,GAAG,cAAc,CAAC;IACnC,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,iBAAiB,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC,CAAC;AAEF,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,KAAK,EAAE,wBAAwB,GAAG,iBAAiB,CA+I1D;CACF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { describeError } from '../../utils/error-helpers.js';
|
|
2
|
+
import { classifyProviderFailure } from './provider-failure-classification.js';
|
|
2
3
|
export class RetryEventPresenter {
|
|
3
4
|
present(input) {
|
|
4
5
|
const { failure, maxTransientRetries, maxModelRetries, source, error } = input;
|
|
@@ -26,6 +27,7 @@ export class RetryEventPresenter {
|
|
|
26
27
|
return { event, logMessage, logFields };
|
|
27
28
|
}
|
|
28
29
|
case 'transient': {
|
|
30
|
+
const providerFailure = classifyProviderFailure(error);
|
|
29
31
|
const toolName = source === 'continuation' ? 'continuation' : 'turn';
|
|
30
32
|
const event = {
|
|
31
33
|
type: 'retry',
|
|
@@ -34,6 +36,9 @@ export class RetryEventPresenter {
|
|
|
34
36
|
maxRetries: maxTransientRetries,
|
|
35
37
|
errorMessage,
|
|
36
38
|
retryType: 'upstream',
|
|
39
|
+
errorKind: providerFailure.errorKind,
|
|
40
|
+
delayMs: failure.delayMs,
|
|
41
|
+
...(providerFailure.retryAfterMs !== undefined ? { retryAfterMs: providerFailure.retryAfterMs } : {}),
|
|
37
42
|
};
|
|
38
43
|
const logMessage = source === 'continuation'
|
|
39
44
|
? 'Transient error in continuation, retrying'
|
|
@@ -44,23 +49,28 @@ export class RetryEventPresenter {
|
|
|
44
49
|
retryAttempt: failure.attempt,
|
|
45
50
|
maxRetries: maxTransientRetries,
|
|
46
51
|
errorMessage,
|
|
52
|
+
errorKind: providerFailure.errorKind,
|
|
47
53
|
delayMs: failure.delayMs,
|
|
48
54
|
};
|
|
49
55
|
return { event, logMessage, logFields };
|
|
50
56
|
}
|
|
51
57
|
case 'chain_recovery': {
|
|
58
|
+
const isConnectionInterrupted = failure.cause === 'connection_interrupted';
|
|
59
|
+
const retryType = isConnectionInterrupted ? 'connection_interrupted' : 'conversation_state';
|
|
52
60
|
const event = {
|
|
53
61
|
type: 'retry',
|
|
54
62
|
toolName: 'conversation',
|
|
55
63
|
attempt: failure.attempt,
|
|
56
64
|
maxRetries: maxTransientRetries,
|
|
57
65
|
errorMessage,
|
|
58
|
-
retryType
|
|
66
|
+
retryType,
|
|
59
67
|
};
|
|
60
|
-
const logMessage =
|
|
68
|
+
const logMessage = isConnectionInterrupted
|
|
69
|
+
? 'Connection interrupted before a terminal response event, rebuilding full history'
|
|
70
|
+
: 'Provider rejected conversation continuity, rebuilding full history';
|
|
61
71
|
const logFields = {
|
|
62
|
-
eventType: 'retry.conversation_state',
|
|
63
|
-
retryType
|
|
72
|
+
eventType: isConnectionInterrupted ? 'retry.connection_interrupted' : 'retry.conversation_state',
|
|
73
|
+
retryType,
|
|
64
74
|
retryAttempt: failure.attempt,
|
|
65
75
|
maxRetries: maxTransientRetries,
|
|
66
76
|
errorMessage,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry-event-presenter.js","sourceRoot":"","sources":["../../../source/services/retry/retry-event-presenter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"retry-event-presenter.js","sourceRoot":"","sources":["../../../source/services/retry/retry-event-presenter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAgB/E,MAAM,OAAO,mBAAmB;IAC9B,OAAO,CAAC,KAA+B;QACrC,MAAM,EAAE,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;QAC/E,4EAA4E;QAC5E,2EAA2E;QAC3E,MAAM,YAAY,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;QAE1C,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;YACrB,KAAK,uBAAuB,EAAE,CAAC;gBAC7B,MAAM,KAAK,GAAsB;oBAC/B,IAAI,EAAE,OAAO;oBACb,QAAQ,EAAE,cAAc;oBACxB,OAAO,EAAE,CAAC;oBACV,UAAU,EAAE,CAAC;oBACb,YAAY,EAAE,kFAAkF;oBAChG,SAAS,EAAE,mBAAmB;iBAC/B,CAAC;gBACF,MAAM,UAAU,GAAG,kEAAkE,CAAC;gBACtF,MAAM,SAAS,GAAG;oBAChB,SAAS,EAAE,yBAAyB;oBACpC,SAAS,EAAE,mBAAmB;oBAC9B,YAAY,EAAE,CAAC;oBACf,UAAU,EAAE,CAAC;oBACb,YAAY;iBACb,CAAC;gBACF,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;YAC1C,CAAC;YAED,KAAK,WAAW,EAAE,CAAC;gBACjB,MAAM,eAAe,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAC;gBACvD,MAAM,QAAQ,GAAG,MAAM,KAAK,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC;gBACrE,MAAM,K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EAAE,CAAC;oBACf,UAAU,EAAE,eAAe,IAAI,CAAC;oBAChC,YAAY;iBACb,CAAC;gBACF,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;YAC1C,CAAC;YAED,SAAS,CAAC;gBACR,MAAM,QAAQ,GAAG,MAAM,KAAK,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC;gBACrE,MAAM,KAAK,GAAsB;oBAC/B,IAAI,EAAE,OAAO;oBACb,QAAQ;oBACR,OAAO,EAAE,CAAC;oBACV,UAAU,EAAE,mBAAmB;oBAC/B,YAAY;oBACZ,SAAS,EAAE,UAAU;iBACtB,CAAC;gBACF,MAAM,UAAU,GAAG,wBAAwB,CAAC;gBAC5C,MAAM,SAAS,GAAG;oBAChB,SAAS,EAAE,eAAe;oBAC1B,SAAS,EAAE,UAAU;oBACrB,YAAY,EAAE,CAAC;oBACf,UAAU,EAAE,mBAAmB;oBAC/B,YAAY;iBACb,CAAC;gBACF,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;YAC1C,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One bounded capability shared by provider transport retries and session
|
|
3
|
+
* recovery. The owner is deliberately the retry/session layer: providers can
|
|
4
|
+
* consume claims, but cannot extend or reset the envelope.
|
|
5
|
+
*/
|
|
6
|
+
export declare const RETRY_RECOVERY_LIMITS: {
|
|
7
|
+
readonly maxRecoveryTimeMs: 90000;
|
|
8
|
+
readonly maxPhysicalAttempts: 3;
|
|
9
|
+
readonly maxAutomaticReplays: 1;
|
|
10
|
+
};
|
|
11
|
+
export type RetryRecoveryBudgetOptions = {
|
|
12
|
+
now?: () => number;
|
|
13
|
+
maxRecoveryTimeMs?: number;
|
|
14
|
+
maxPhysicalAttempts?: number;
|
|
15
|
+
maxAutomaticReplays?: number;
|
|
16
|
+
};
|
|
17
|
+
export declare class RetryRecoveryBudget {
|
|
18
|
+
#private;
|
|
19
|
+
readonly maxRecoveryTimeMs: number;
|
|
20
|
+
readonly maxPhysicalAttempts: number;
|
|
21
|
+
readonly maxAutomaticReplays: number;
|
|
22
|
+
constructor(options?: RetryRecoveryBudgetOptions);
|
|
23
|
+
get startedAt(): number | undefined;
|
|
24
|
+
get physicalAttempts(): number;
|
|
25
|
+
get automaticReplays(): number;
|
|
26
|
+
get elapsedMs(): number;
|
|
27
|
+
/** Starts the recovery clock only after a retryable failure is observed. */
|
|
28
|
+
noteRetryableFailure(): void;
|
|
29
|
+
get deadlineExceeded(): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Claim one physical dispatch made because recovery is in progress.
|
|
32
|
+
* Ordinary first attempts and successful tool-loop continuations are not
|
|
33
|
+
* recovery work; their callers must not spend this budget on them.
|
|
34
|
+
*/
|
|
35
|
+
claimPhysicalAttempt(): boolean;
|
|
36
|
+
/** Claim exactly once before an automatic full-history turn replay. */
|
|
37
|
+
claimAutomaticReplay(): boolean;
|
|
38
|
+
remainingMs(): number | undefined;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Raised when a provider wrapper tried to start another physical request after
|
|
42
|
+
* the shared recovery envelope was exhausted. Keeping the triggering failure
|
|
43
|
+
* as a cause lets the classifier retain its useful provider/status details
|
|
44
|
+
* without making the budget error itself look like a new provider failure.
|
|
45
|
+
*/
|
|
46
|
+
export declare class RetryRecoveryBudgetExhaustedError extends Error {
|
|
47
|
+
readonly cause: unknown;
|
|
48
|
+
constructor(cause?: unknown);
|
|
49
|
+
}
|
|
50
|
+
export declare const isRetryRecoveryBudgetExhaustedError: (error: unknown) => error is RetryRecoveryBudgetExhaustedError;
|
|
51
|
+
//# sourceMappingURL=retry-recovery-budget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry-recovery-budget.d.ts","sourceRoot":"","sources":["../../../source/services/retry/retry-recovery-budget.ts"],"names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
3
|
+
* recovery. The owner is deliberately the retry/session layer: providers can
|
|
4
|
+
* consume claims, but cannot extend or reset the envelope.
|
|
5
|
+
*/
|
|
6
|
+
export const RETRY_RECOVERY_LIMITS = {
|
|
7
|
+
maxRecoveryTimeMs: 90_000,
|
|
8
|
+
maxPhysicalAttempts: 3,
|
|
9
|
+
maxAutomaticReplays: 1,
|
|
10
|
+
};
|
|
11
|
+
export class RetryRecoveryBudget {
|
|
12
|
+
maxRecoveryTimeMs;
|
|
13
|
+
maxPhysicalAttempts;
|
|
14
|
+
maxAutomaticReplays;
|
|
15
|
+
#now;
|
|
16
|
+
#startedAt;
|
|
17
|
+
#physicalAttempts = 0;
|
|
18
|
+
#automaticReplays = 0;
|
|
19
|
+
constructor(options = {}) {
|
|
20
|
+
this.#now = options.now ?? (() => performance.now());
|
|
21
|
+
this.maxRecoveryTimeMs = options.maxRecoveryTimeMs ?? RETRY_RECOVERY_LIMITS.maxRecoveryTimeMs;
|
|
22
|
+
this.maxPhysicalAttempts = options.maxPhysicalAttempts ?? RETRY_RECOVERY_LIMITS.maxPhysicalAttempts;
|
|
23
|
+
this.maxAutomaticReplays = options.maxAutomaticReplays ?? RETRY_RECOVERY_LIMITS.maxAutomaticReplays;
|
|
24
|
+
}
|
|
25
|
+
get startedAt() {
|
|
26
|
+
return this.#startedAt;
|
|
27
|
+
}
|
|
28
|
+
get physicalAttempts() {
|
|
29
|
+
return this.#physicalAttempts;
|
|
30
|
+
}
|
|
31
|
+
get automaticReplays() {
|
|
32
|
+
return this.#automaticReplays;
|
|
33
|
+
}
|
|
34
|
+
get elapsedMs() {
|
|
35
|
+
return this.#startedAt === undefined ? 0 : Math.max(0, this.#now() - this.#startedAt);
|
|
36
|
+
}
|
|
37
|
+
/** Starts the recovery clock only after a retryable failure is observed. */
|
|
38
|
+
noteRetryableFailure() {
|
|
39
|
+
if (this.#startedAt === undefined)
|
|
40
|
+
this.#startedAt = this.#now();
|
|
41
|
+
}
|
|
42
|
+
get deadlineExceeded() {
|
|
43
|
+
return this.#startedAt !== undefined && this.elapsedMs >= this.maxRecoveryTimeMs;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Claim one physical dispatch made because recovery is in progress.
|
|
47
|
+
* Ordinary first attempts and successful tool-loop continuations are not
|
|
48
|
+
* recovery work; their callers must not spend this budget on them.
|
|
49
|
+
*/
|
|
50
|
+
claimPhysicalAttempt() {
|
|
51
|
+
if (this.#physicalAttempts >= this.maxPhysicalAttempts || this.deadlineExceeded)
|
|
52
|
+
return false;
|
|
53
|
+
this.#physicalAttempts++;
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
/** Claim exactly once before an automatic full-history turn replay. */
|
|
57
|
+
claimAutomaticReplay() {
|
|
58
|
+
if (this.#automaticReplays >= this.maxAutomaticReplays || this.deadlineExceeded)
|
|
59
|
+
return false;
|
|
60
|
+
this.#automaticReplays++;
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
remainingMs() {
|
|
64
|
+
if (this.#startedAt === undefined)
|
|
65
|
+
return undefined;
|
|
66
|
+
return Math.max(0, this.maxRecoveryTimeMs - this.elapsedMs);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Raised when a provider wrapper tried to start another physical request after
|
|
71
|
+
* the shared recovery envelope was exhausted. Keeping the triggering failure
|
|
72
|
+
* as a cause lets the classifier retain its useful provider/status details
|
|
73
|
+
* without making the budget error itself look like a new provider failure.
|
|
74
|
+
*/
|
|
75
|
+
export class RetryRecoveryBudgetExhaustedError extends Error {
|
|
76
|
+
cause;
|
|
77
|
+
constructor(cause) {
|
|
78
|
+
super('Retry recovery budget exhausted', { cause });
|
|
79
|
+
this.name = 'RetryRecoveryBudgetExhaustedError';
|
|
80
|
+
this.cause = cause;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export const isRetryRecoveryBudgetExhaustedError = (error) => error instanceof RetryRecoveryBudgetExhaustedError;
|
|
84
|
+
//# sourceMappingURL=retry-recovery-budget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry-recovery-budget.js","sourceRoot":"","sources":["../../../source/services/retry/retry-recovery-budget.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,iBAAiB,EAAE,MAAM;IACzB,mBAAmB,EAAE,CAAC;IACtB,mBAAmB,EAAE,CAAC;CACd,CAAC;AASX,MAAM,OAAO,mBAAmB;IACrB,iBAAiB,CAAS;IAC1B,mBAAmB,CAAS;IAC5B,mBAAmB,CAAS;IAC5B,IAAI,CAAe;IAC5B,UAAU,CAAqB;IAC/B,iBAAiB,GAAG,CAAC,CAAC;IACtB,iBAAiB,GAAG,CAAC,CAAC;IAEtB,YAAY,OAAO,GAA+B,EAAE;QAClD,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC;QACrD,IAAI,CAAC,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,IAAI,qBAAqB,CAAC,iBAAiB,CAAC;QAC9F,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,IAAI,qBAAqB,CAAC,mBAAmB,CAAC;QACpG,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,IAAI,qBAAqB,CAAC,mBAAmB,CAAC;IACtG,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,IAAI,gBAAgB;QAClB,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAChC,CAAC;IAED,IAAI,gBAAgB;QAClB,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAChC,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,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AAC;CACF;AAED,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,KAAc,EAA8C,EAAE,CAChH,KAAK,YAAY,iCAAiC,CAAC"}
|
|
@@ -74,26 +74,80 @@ export interface ProviderTrafficClosedResponse {
|
|
|
74
74
|
requestId: string;
|
|
75
75
|
provider: string;
|
|
76
76
|
model: string;
|
|
77
|
-
|
|
77
|
+
/**
|
|
78
|
+
* `'failed'` is a stream that ended because a raw transport `error`/`close`
|
|
79
|
+
* frame was observed before any terminal response event — distinct from
|
|
80
|
+
* `'consumer_closed'`, which is this application choosing to stop reading a
|
|
81
|
+
* still-live stream. Without the distinction, an abnormal WebSocket close
|
|
82
|
+
* (e.g. close code 1006) is indistinguishable from ordinary cleanup.
|
|
83
|
+
*/
|
|
84
|
+
outcome: 'consumer_closed' | 'aborted' | 'failed';
|
|
78
85
|
eventCount: number;
|
|
79
86
|
modelClass?: string;
|
|
80
87
|
modelWrapperClass?: string;
|
|
81
88
|
/**
|
|
82
89
|
* A stream that ends without a terminal event leaves no payload to
|
|
83
90
|
* summarize, so the retained transcript and its timings are the only record
|
|
84
|
-
* of what the model was doing when it was cut off.
|
|
91
|
+
* of what the model was doing when it was cut off. Bounded (no raw event
|
|
92
|
+
* payload) for `'failed'`, since a transport failure is not the deliberate
|
|
93
|
+
* client abort that full transcript retention is for.
|
|
85
94
|
*/
|
|
86
|
-
diagnostics?: ProviderTrafficStreamDiagnostics;
|
|
95
|
+
diagnostics?: ProviderTrafficStreamDiagnostics | ProviderTrafficBoundedStreamDiagnostics;
|
|
87
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Fixed, bounded classification of a Responses WebSocket frame's progress
|
|
99
|
+
* kind. Closed union on purpose — see `aborted-stream-recorder.ts`.
|
|
100
|
+
*/
|
|
101
|
+
export type ProviderTrafficProgressCategory = 'text' | 'reasoning' | 'tool' | 'usage' | 'heartbeat_or_unknown';
|
|
88
102
|
export interface ProviderTrafficStreamDiagnostics {
|
|
89
103
|
durationMs: number;
|
|
90
104
|
firstEventMs?: number;
|
|
91
105
|
lastEventMs?: number;
|
|
92
106
|
maxGapMs?: number;
|
|
93
107
|
responseId?: string;
|
|
108
|
+
/** Present only when a raw transport `close` frame was observed. */
|
|
109
|
+
closeCode?: number;
|
|
110
|
+
closeReason?: string;
|
|
94
111
|
eventTypeCounts: Record<string, number>;
|
|
112
|
+
progressCategoryCounts: Record<ProviderTrafficProgressCategory, number>;
|
|
113
|
+
/** Content-free count of raw tool-argument delta frames. */
|
|
114
|
+
toolArgumentDeltaFrames: number;
|
|
115
|
+
/** Sum of raw tool-argument delta string lengths. */
|
|
116
|
+
toolArgumentDeltaCharacters: number;
|
|
117
|
+
/** Raw function-call item starts observed before argument deltas. */
|
|
118
|
+
toolCallStartFrames: number;
|
|
95
119
|
events: unknown[];
|
|
96
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* A mechanically fixed-size/fixed-cardinality view of stream progress,
|
|
123
|
+
* distinct from {@link ProviderTrafficStreamDiagnostics}: every field here is
|
|
124
|
+
* either a single number (including content-free tool-argument growth counts)
|
|
125
|
+
* or a `Record` with a closed, hard-coded key set
|
|
126
|
+
* (`progressCategoryCounts`), so its serialized size cannot grow no matter
|
|
127
|
+
* how many frames, or how novel/hostile their `type` strings, a stream sends.
|
|
128
|
+
*
|
|
129
|
+
* This is why it is a distinct interface rather than
|
|
130
|
+
* `Omit<ProviderTrafficStreamDiagnostics, 'events'>`: that would still expose
|
|
131
|
+
* `eventTypeCounts` (keyed by raw, provider-supplied `type` strings with no
|
|
132
|
+
* enforced vocabulary — unbounded key cardinality) and `closeReason` (free
|
|
133
|
+
* text the server chooses). Used where the caller must retain progress
|
|
134
|
+
* evidence about a stream without retaining anything unbounded or
|
|
135
|
+
* provider-authored — in particular a genuine transport failure, which is not
|
|
136
|
+
* a deliberate client abort and can carry an unbounded number of frames.
|
|
137
|
+
*/
|
|
138
|
+
export interface ProviderTrafficBoundedStreamDiagnostics {
|
|
139
|
+
durationMs: number;
|
|
140
|
+
firstEventMs?: number;
|
|
141
|
+
lastEventMs?: number;
|
|
142
|
+
maxGapMs?: number;
|
|
143
|
+
/** Numeric WebSocket close code (RFC 6455 §7.4); never free text. */
|
|
144
|
+
closeCode?: number;
|
|
145
|
+
eventCount: number;
|
|
146
|
+
progressCategoryCounts: Record<ProviderTrafficProgressCategory, number>;
|
|
147
|
+
toolArgumentDeltaFrames: number;
|
|
148
|
+
toolArgumentDeltaCharacters: number;
|
|
149
|
+
toolCallStartFrames: number;
|
|
150
|
+
}
|
|
97
151
|
/**
|
|
98
152
|
* What a transport-liveness guard observed while receiving a response, in the
|
|
99
153
|
* same clock it judges expiry with.
|
|
@@ -124,6 +178,16 @@ export interface IProviderTraffic {
|
|
|
124
178
|
wsAttempt?: number;
|
|
125
179
|
wsMaxAttempts?: number;
|
|
126
180
|
receiveTiming?: ProviderTrafficReceiveTiming;
|
|
181
|
+
host?: string;
|
|
182
|
+
timeoutMs?: number;
|
|
183
|
+
phase?: string;
|
|
184
|
+
physicalAttempt?: number;
|
|
185
|
+
/**
|
|
186
|
+
* Bounded category/counter/timing evidence of stream progress observed
|
|
187
|
+
* before the failure, when a stream had already started delivering
|
|
188
|
+
* frames. Absent when the failure happened before any frame arrived.
|
|
189
|
+
*/
|
|
190
|
+
diagnostics?: ProviderTrafficBoundedStreamDiagnostics;
|
|
127
191
|
}): void;
|
|
128
192
|
}
|
|
129
193
|
export interface ISessionContextService {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-interfaces.d.ts","sourceRoot":"","sources":["../../source/services/service-interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAE9E;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;I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EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,WAAW,IAAI,OAAO,CAAC;IACvB;;;;;;;;;;OAUG;IACH,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACjF,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACxC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpE"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { BackgroundCheckInDueEvent } from '../conversation/conversation-events.js';
|
|
2
2
|
import type { BackgroundTask } from '../subagents/subagent-notification-store.js';
|
|
3
|
+
import type { SubagentRunStatus } from '../subagents/types.js';
|
|
4
|
+
import type { BackgroundShellJob } from '../shell/background-shell-registry.js';
|
|
3
5
|
/** Current values of `agent.backgroundCheckIn.*`, read fresh on every tick. */
|
|
4
6
|
export interface BackgroundCheckInSettings {
|
|
5
7
|
enabled: boolean;
|
|
@@ -12,6 +14,9 @@ export interface BackgroundCheckInSchedulerDeps {
|
|
|
12
14
|
/** Deliver a due check-in through the same pipeline as any other background event. */
|
|
13
15
|
emit: (event: BackgroundCheckInDueEvent) => void;
|
|
14
16
|
getSettings: () => BackgroundCheckInSettings;
|
|
17
|
+
getSubagentStatus?: (runId: string) => SubagentRunStatus | undefined;
|
|
18
|
+
getShellJob?: (jobId: string) => BackgroundShellJob<unknown> | undefined;
|
|
19
|
+
getShellOutputTail?: (jobId: string, maxBytes?: number) => string | undefined;
|
|
15
20
|
now?: () => number;
|
|
16
21
|
setInterval?: (callback: () => void, delay: number) => ReturnType<typeof setInterval>;
|
|
17
22
|
clearInterval?: (timer: ReturnType<typeof setInterval>) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"background-check-in-scheduler.d.ts","sourceRoot":"","sources":["../../../source/services/session/background-check-in-scheduler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACxF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"background-check-in-scheduler.d.ts","sourceRoot":"","sources":["../../../source/services/session/background-check-in-scheduler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AACxF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAClF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAQhF,+EAA+E;AAC/E,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,8BAA8B;IAC7C,gFAAgF;IAChF,eAAe,EAAE,MAAM,SAAS,cAAc,EAAE,CAAC;IACjD,sFAAsF;IACtF,IAAI,EAAE,CAAC,KAAK,EAAE,yBAAyB,KAAK,IAAI,CAAC;IACjD,WAAW,EAAE,MAAM,yBAAyB,CAAC;IAC7C,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,iBAAiB,GAAG,SAAS,CAAC;IACrE,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,kBAAkB,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC;IACzE,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IAC9E,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,KAAK,EAAE,MAAM,KAAK,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;IACtF,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,CAAC,OAAO,WAAW,CAAC,KAAK,IAAI,CAAC;IAChE;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAuGD;;;;;;;;;;;GAWG;AACH,qBAAa,0BAA0B;;IAYrC,YAAY,IAAI,EAAE,8BAA8B,EAY/C;IAED,wEAAwE;IACxE,IAAI,IAAI,IAAI,CAmCX;IAED,OAAO,IAAI,IAAI,CAId;CACF"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { truncatePreview } from '../subagents/utils.js';
|
|
2
|
+
import { BACKGROUND_SHELL_QUIET_AFTER_MS, BACKGROUND_SUBAGENT_QUIET_AFTER_MS, normalizeBackgroundTaskActivity, } from '../background-task-activity.js';
|
|
1
3
|
const DEFAULT_TICK_MS = 30_000;
|
|
2
4
|
function checkInKey(target) {
|
|
3
5
|
return `${target.kind}:${target.id}`;
|
|
@@ -5,16 +7,77 @@ function checkInKey(target) {
|
|
|
5
7
|
function taskTarget(task) {
|
|
6
8
|
return task.kind === 'shell' ? { kind: 'shell', id: task.jobId } : { kind: 'subagent', id: task.runId };
|
|
7
9
|
}
|
|
8
|
-
function taskDetails(task) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
function taskDetails(task, deps, now) {
|
|
11
|
+
if (task.kind === 'shell') {
|
|
12
|
+
const job = deps.getShellJob?.(task.jobId);
|
|
13
|
+
const rawTail = deps.getShellOutputTail?.(task.jobId, 400)?.trim();
|
|
14
|
+
const outputTail = rawTail && rawTail.length > 0 ? rawTail : undefined;
|
|
15
|
+
return {
|
|
16
|
+
kind: 'shell',
|
|
17
|
+
id: task.jobId,
|
|
18
|
+
command: task.command,
|
|
19
|
+
...(job?.lastObservation || job?.lastActivityAt !== undefined
|
|
20
|
+
? {
|
|
21
|
+
activity: normalizeBackgroundTaskActivity({
|
|
22
|
+
status: job?.status ?? task.status,
|
|
23
|
+
...(job?.lastObservation === undefined
|
|
24
|
+
? { lastActivityAt: job?.lastActivityAt }
|
|
25
|
+
: { lastObservation: job.lastObservation }),
|
|
26
|
+
now,
|
|
27
|
+
quietAfterMs: BACKGROUND_SHELL_QUIET_AFTER_MS,
|
|
28
|
+
}),
|
|
29
|
+
}
|
|
30
|
+
: {}),
|
|
31
|
+
...(job?.status ? { status: job.status } : {}),
|
|
32
|
+
...(job?.lastObservation ? { lastObservation: job.lastObservation } : {}),
|
|
33
|
+
...(outputTail ? { outputTail } : {}),
|
|
17
34
|
};
|
|
35
|
+
}
|
|
36
|
+
const subagentStatus = deps.getSubagentStatus?.(task.runId);
|
|
37
|
+
const narrative = subagentStatus?.currentText?.trim() ||
|
|
38
|
+
(subagentStatus?.turnHistory && subagentStatus.turnHistory.length > 0
|
|
39
|
+
? subagentStatus.turnHistory[subagentStatus.turnHistory.length - 1]?.text?.trim()
|
|
40
|
+
: undefined);
|
|
41
|
+
const latestNarrative = narrative ? truncatePreview(narrative) : undefined;
|
|
42
|
+
return {
|
|
43
|
+
kind: 'subagent',
|
|
44
|
+
id: task.runId,
|
|
45
|
+
...(task.name !== undefined ? { name: task.name } : {}),
|
|
46
|
+
role: task.role,
|
|
47
|
+
task: task.task,
|
|
48
|
+
...(subagentStatus?.lastObservation || subagentStatus?.lastActivityAt !== undefined
|
|
49
|
+
? {
|
|
50
|
+
activity: normalizeBackgroundTaskActivity({
|
|
51
|
+
status: subagentStatus.status,
|
|
52
|
+
activityState: subagentStatus.status === 'awaiting_approval' || subagentStatus.status === 'waiting_for_answer'
|
|
53
|
+
? 'waiting'
|
|
54
|
+
: subagentStatus.activityState,
|
|
55
|
+
waitingReason: subagentStatus.status === 'awaiting_approval'
|
|
56
|
+
? 'approval'
|
|
57
|
+
: subagentStatus.status === 'waiting_for_answer'
|
|
58
|
+
? 'answer'
|
|
59
|
+
: subagentStatus.waitingReason,
|
|
60
|
+
...(subagentStatus.lastObservation === undefined
|
|
61
|
+
? { lastActivityAt: subagentStatus.lastActivityAt }
|
|
62
|
+
: { lastObservation: subagentStatus.lastObservation }),
|
|
63
|
+
now,
|
|
64
|
+
quietAfterMs: BACKGROUND_SUBAGENT_QUIET_AFTER_MS,
|
|
65
|
+
}),
|
|
66
|
+
}
|
|
67
|
+
: {}),
|
|
68
|
+
...(subagentStatus?.activityState ? { activityState: subagentStatus.activityState } : {}),
|
|
69
|
+
...(subagentStatus?.waitingReason ? { waitingReason: subagentStatus.waitingReason } : {}),
|
|
70
|
+
...(subagentStatus?.toolCounts && Object.keys(subagentStatus.toolCounts).length > 0
|
|
71
|
+
? { toolCounts: subagentStatus.toolCounts }
|
|
72
|
+
: {}),
|
|
73
|
+
...(subagentStatus?.lastToolName
|
|
74
|
+
? { lastToolName: subagentStatus.lastToolName }
|
|
75
|
+
: task.lastTool?.label
|
|
76
|
+
? { lastToolName: task.lastTool.label }
|
|
77
|
+
: {}),
|
|
78
|
+
...(subagentStatus?.lastObservation ? { lastObservation: subagentStatus.lastObservation } : {}),
|
|
79
|
+
...(latestNarrative ? { latestNarrative } : {}),
|
|
80
|
+
};
|
|
18
81
|
}
|
|
19
82
|
/**
|
|
20
83
|
* Periodically checks whether any still-running background task (shell job or
|
|
@@ -32,6 +95,9 @@ export class BackgroundCheckInScheduler {
|
|
|
32
95
|
#getRunningTasks;
|
|
33
96
|
#emit;
|
|
34
97
|
#getSettings;
|
|
98
|
+
#getSubagentStatus;
|
|
99
|
+
#getShellJob;
|
|
100
|
+
#getShellOutputTail;
|
|
35
101
|
#now;
|
|
36
102
|
#clearInterval;
|
|
37
103
|
#timer;
|
|
@@ -40,6 +106,9 @@ export class BackgroundCheckInScheduler {
|
|
|
40
106
|
this.#getRunningTasks = deps.getRunningTasks;
|
|
41
107
|
this.#emit = deps.emit;
|
|
42
108
|
this.#getSettings = deps.getSettings;
|
|
109
|
+
this.#getSubagentStatus = deps.getSubagentStatus;
|
|
110
|
+
this.#getShellJob = deps.getShellJob;
|
|
111
|
+
this.#getShellOutputTail = deps.getShellOutputTail;
|
|
43
112
|
this.#now = deps.now ?? (() => Date.now());
|
|
44
113
|
const setIntervalFn = deps.setInterval ?? setInterval;
|
|
45
114
|
this.#clearInterval = deps.clearInterval ?? clearInterval;
|
|
@@ -74,7 +143,11 @@ export class BackgroundCheckInScheduler {
|
|
|
74
143
|
target,
|
|
75
144
|
checkInIndex,
|
|
76
145
|
elapsedMs: now - task.startedAt,
|
|
77
|
-
details: taskDetails(task
|
|
146
|
+
details: taskDetails(task, {
|
|
147
|
+
getSubagentStatus: this.#getSubagentStatus,
|
|
148
|
+
getShellJob: this.#getShellJob,
|
|
149
|
+
getShellOutputTail: this.#getShellOutputTail,
|
|
150
|
+
}, now),
|
|
78
151
|
});
|
|
79
152
|
}
|
|
80
153
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"background-check-in-scheduler.js","sourceRoot":"","sources":["../../../source/services/session/background-check-in-scheduler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"background-check-in-scheduler.js","sourceRoot":"","sources":["../../../source/services/session/background-check-in-scheduler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,O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/services/session/continuation-recovery-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,6BAA6B,CAAC;AACrF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,KAAK,EAAE,WAAW,EAAiB,MAAM,6BAA6B,CAAC;AAC9E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"continuation-recovery-handler.d.ts","sourceRoot":"","sources":["../../../source/services/session/continuation-recovery-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,6BAA6B,CAAC;AACrF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,KAAK,EAAE,WAAW,EAAiB,MAAM,6BAA6B,CAAC;AAC9E,OAAO,KAAK,EAAE,iBAAiB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Claim } from '../retry/committed-tool-continuation.js';
|
|
1
3
|
export class ContinuationRecoveryHandler {
|
|
2
4
|
deps;
|
|
3
5
|
constructor(deps) {
|
|
@@ -7,10 +9,12 @@ export class ContinuationRecoveryHandler {
|
|
|
7
9
|
const { error, state } = ctx;
|
|
8
10
|
const maxTransientRetries = this.deps.resolveRetryLimit();
|
|
9
11
|
const retryStream = state.lastStream;
|
|
12
|
+
const committedToolContinuation = this.deps.toolTracker.inspectCommittedToolContinuation?.();
|
|
10
13
|
const classified = this.deps.retryClassifier.classify({
|
|
11
14
|
error,
|
|
12
15
|
retryCounts: state.retryCounts,
|
|
13
16
|
stream: retryStream,
|
|
17
|
+
committedToolContinuation,
|
|
14
18
|
maxTransientRetries,
|
|
15
19
|
});
|
|
16
20
|
if (classified.kind === 'chain_recovery') {
|
|
@@ -19,6 +23,13 @@ export class ContinuationRecoveryHandler {
|
|
|
19
23
|
if (classified.kind === 'unrecoverable') {
|
|
20
24
|
return { kind: 'terminated' };
|
|
21
25
|
}
|
|
26
|
+
// model_retry (hallucination/parsing/behavior detection) has its own
|
|
27
|
+
// pre-existing maxModelRetries cap and must not draw against or be capped
|
|
28
|
+
// by the shared transport-recovery envelope; see the matching comment in
|
|
29
|
+
// initial-turn-recovery-handler.ts.
|
|
30
|
+
if (classified.kind === 'transient' || classified.kind === 'chain_recovery') {
|
|
31
|
+
state.recoveryBudget.noteRetryableFailure();
|
|
32
|
+
}
|
|
22
33
|
const presentation = this.deps.retryEventPresenter.present({
|
|
23
34
|
failure: classified,
|
|
24
35
|
maxTransientRetries,
|
|
@@ -49,6 +60,37 @@ export class ContinuationRecoveryHandler {
|
|
|
49
60
|
stream: retryStream,
|
|
50
61
|
};
|
|
51
62
|
const transientDelayMs = classified.kind === 'transient' || classified.kind === 'chain_recovery' ? classified.delayMs : undefined;
|
|
63
|
+
// Only retry_fresh draws against the automatic-replay budget; replay_turn
|
|
64
|
+
// comes exclusively from model_retry, excluded for the reason above.
|
|
65
|
+
if (plan.kind === 'retry_fresh' &&
|
|
66
|
+
((!skipsAutomaticReplayClaim(classified, committedToolContinuation) &&
|
|
67
|
+
!state.recoveryBudget.claimAutomaticReplay()) ||
|
|
68
|
+
!state.recoveryBudget.claimPhysicalAttempt())) {
|
|
69
|
+
// Refusing the plan must still settle open tool calls truthfully and
|
|
70
|
+
// clear the provider chain, exactly like an ordinary termination does --
|
|
71
|
+
// see the matching comment in initial-turn-recovery-handler.ts.
|
|
72
|
+
const terminateResult = this.deps.recoveryExecutor.apply({
|
|
73
|
+
plan: { kind: 'terminate', events: [] },
|
|
74
|
+
state: recoveryState,
|
|
75
|
+
retryCounts: state.retryCounts,
|
|
76
|
+
});
|
|
77
|
+
if (terminateResult.kind === 'terminated') {
|
|
78
|
+
for (const event of terminateResult.events) {
|
|
79
|
+
yield event;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const providerName = this.deps.provider ?? 'provider';
|
|
83
|
+
yield {
|
|
84
|
+
type: 'retry_exhausted',
|
|
85
|
+
provider: providerName,
|
|
86
|
+
errorKind: classifyProviderFailure(error).errorKind,
|
|
87
|
+
attempts: state.recoveryBudget.physicalAttempts,
|
|
88
|
+
maxAttempts: state.recoveryBudget.maxPhysicalAttempts,
|
|
89
|
+
message: `Could not reach ${providerName} after ${state.recoveryBudget.physicalAttempts} attempts. No model response was received.`,
|
|
90
|
+
canRetry: true,
|
|
91
|
+
};
|
|
92
|
+
return { kind: 'terminated' };
|
|
93
|
+
}
|
|
52
94
|
const recoveryResult = this.deps.recoveryExecutor.apply({
|
|
53
95
|
plan,
|
|
54
96
|
state: recoveryState,
|