@superblocksteam/vite-plugin-file-sync 2.0.59-next.0 → 2.0.59-next.10
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/ai-service/agent/prompts/build-base-system-prompt.d.ts.map +1 -1
- package/dist/ai-service/agent/prompts/build-base-system-prompt.js +25 -9
- package/dist/ai-service/agent/prompts/build-base-system-prompt.js.map +1 -1
- package/dist/ai-service/agent/subagents/apis/examples.d.ts.map +1 -1
- package/dist/ai-service/agent/subagents/apis/examples.js +137 -10
- package/dist/ai-service/agent/subagents/apis/examples.js.map +1 -1
- package/dist/ai-service/agent/subagents/apis/static-analysis.d.ts.map +1 -1
- package/dist/ai-service/agent/subagents/apis/static-analysis.js +14 -7
- package/dist/ai-service/agent/subagents/apis/static-analysis.js.map +1 -1
- package/dist/ai-service/agent/tool-message-utils.d.ts.map +1 -1
- package/dist/ai-service/agent/tool-message-utils.js +6 -2
- package/dist/ai-service/agent/tool-message-utils.js.map +1 -1
- package/dist/ai-service/agent/tools/apis/analysis.d.ts +9 -0
- package/dist/ai-service/agent/tools/apis/analysis.d.ts.map +1 -0
- package/dist/ai-service/agent/tools/apis/analysis.js +358 -0
- package/dist/ai-service/agent/tools/apis/analysis.js.map +1 -0
- package/dist/ai-service/agent/{subagents → tools}/apis/api-executor.d.ts +35 -10
- package/dist/ai-service/agent/tools/apis/api-executor.d.ts.map +1 -0
- package/dist/ai-service/agent/{subagents → tools}/apis/api-executor.js +179 -94
- package/dist/ai-service/agent/tools/apis/api-executor.js.map +1 -0
- package/dist/ai-service/agent/tools/apis/api-source.d.ts +19 -0
- package/dist/ai-service/agent/tools/apis/api-source.d.ts.map +1 -0
- package/dist/ai-service/agent/tools/apis/api-source.js +73 -0
- package/dist/ai-service/agent/tools/apis/api-source.js.map +1 -0
- package/dist/ai-service/agent/tools/apis/api-validation-orchestrator.d.ts +51 -0
- package/dist/ai-service/agent/tools/apis/api-validation-orchestrator.d.ts.map +1 -0
- package/dist/ai-service/agent/tools/apis/api-validation-orchestrator.js +510 -0
- package/dist/ai-service/agent/tools/apis/api-validation-orchestrator.js.map +1 -0
- package/dist/ai-service/agent/tools/apis/build-api-artifact.d.ts +32 -0
- package/dist/ai-service/agent/tools/apis/build-api-artifact.d.ts.map +1 -0
- package/dist/ai-service/agent/tools/apis/build-api-artifact.js +313 -0
- package/dist/ai-service/agent/tools/apis/build-api-artifact.js.map +1 -0
- package/dist/ai-service/agent/tools/apis/build-api.d.ts +1 -10
- package/dist/ai-service/agent/tools/apis/build-api.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/apis/build-api.js +26 -238
- package/dist/ai-service/agent/tools/apis/build-api.js.map +1 -1
- package/dist/ai-service/agent/tools/apis/get-api-docs.d.ts +11 -0
- package/dist/ai-service/agent/tools/apis/get-api-docs.d.ts.map +1 -0
- package/dist/ai-service/agent/tools/apis/get-api-docs.js +1841 -0
- package/dist/ai-service/agent/tools/apis/get-api-docs.js.map +1 -0
- package/dist/ai-service/agent/tools/apis/integration-types.d.ts +37 -0
- package/dist/ai-service/agent/tools/apis/integration-types.d.ts.map +1 -0
- package/dist/ai-service/agent/tools/apis/integration-types.js +689 -0
- package/dist/ai-service/agent/tools/apis/integration-types.js.map +1 -0
- package/dist/ai-service/agent/tools/apis/test-api.d.ts +25 -0
- package/dist/ai-service/agent/tools/apis/test-api.d.ts.map +1 -0
- package/dist/ai-service/agent/tools/apis/test-api.js +194 -0
- package/dist/ai-service/agent/tools/apis/test-api.js.map +1 -0
- package/dist/ai-service/agent/tools/apis/write-api.d.ts +11 -0
- package/dist/ai-service/agent/tools/apis/write-api.d.ts.map +1 -0
- package/dist/ai-service/agent/tools/apis/write-api.js +41 -0
- package/dist/ai-service/agent/tools/apis/write-api.js.map +1 -0
- package/dist/ai-service/agent/tools/build-read-files.js +2 -2
- package/dist/ai-service/agent/tools/build-read-files.js.map +1 -1
- package/dist/ai-service/agent/tools.d.ts +2 -5
- package/dist/ai-service/agent/tools.d.ts.map +1 -1
- package/dist/ai-service/agent/tools.js +51 -22
- package/dist/ai-service/agent/tools.js.map +1 -1
- package/dist/ai-service/agent/tools2/access-control.d.ts +1 -0
- package/dist/ai-service/agent/tools2/access-control.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/access-control.js +15 -13
- package/dist/ai-service/agent/tools2/access-control.js.map +1 -1
- package/dist/ai-service/agent/tools2/registry.d.ts +2 -1
- package/dist/ai-service/agent/tools2/registry.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/registry.js +4 -3
- package/dist/ai-service/agent/tools2/registry.js.map +1 -1
- package/dist/ai-service/agent/tools2/tools/exit-plan-mode.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js +73 -127
- package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js.map +1 -1
- package/dist/ai-service/agent/tools2/tools/grep-metadata.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/tools/grep-metadata.js +25 -4
- package/dist/ai-service/agent/tools2/tools/grep-metadata.js.map +1 -1
- package/dist/ai-service/agent/tools2/types.d.ts +1 -1
- package/dist/ai-service/agent/tools2/types.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/types.js.map +1 -1
- package/dist/ai-service/agent/tools2/utils.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/utils.js +4 -1
- package/dist/ai-service/agent/tools2/utils.js.map +1 -1
- package/dist/ai-service/agent/utils.d.ts +1 -3
- package/dist/ai-service/agent/utils.d.ts.map +1 -1
- package/dist/ai-service/agent/utils.js +55 -13
- package/dist/ai-service/agent/utils.js.map +1 -1
- package/dist/ai-service/app-interface/shell.d.ts +5 -0
- package/dist/ai-service/app-interface/shell.d.ts.map +1 -1
- package/dist/ai-service/app-interface/shell.js +17 -2
- package/dist/ai-service/app-interface/shell.js.map +1 -1
- package/dist/ai-service/chat/chat-session-store.d.ts +7 -0
- package/dist/ai-service/chat/chat-session-store.d.ts.map +1 -1
- package/dist/ai-service/chat/chat-session-store.js +26 -0
- package/dist/ai-service/chat/chat-session-store.js.map +1 -1
- package/dist/ai-service/const.d.ts +3 -1
- package/dist/ai-service/const.d.ts.map +1 -1
- package/dist/ai-service/const.js +3 -0
- package/dist/ai-service/const.js.map +1 -1
- package/dist/ai-service/index.d.ts +5 -1
- package/dist/ai-service/index.d.ts.map +1 -1
- package/dist/ai-service/index.js +55 -7
- package/dist/ai-service/index.js.map +1 -1
- package/dist/ai-service/integrations/metadata-storage/index.d.ts +10 -0
- package/dist/ai-service/integrations/metadata-storage/index.d.ts.map +1 -1
- package/dist/ai-service/integrations/metadata-storage/local.d.ts +4 -2
- package/dist/ai-service/integrations/metadata-storage/local.d.ts.map +1 -1
- package/dist/ai-service/integrations/metadata-storage/local.js +35 -9
- package/dist/ai-service/integrations/metadata-storage/local.js.map +1 -1
- package/dist/ai-service/integrations/store.d.ts +27 -2
- package/dist/ai-service/integrations/store.d.ts.map +1 -1
- package/dist/ai-service/integrations/store.js +129 -62
- package/dist/ai-service/integrations/store.js.map +1 -1
- package/dist/ai-service/llm/client.d.ts +123 -0
- package/dist/ai-service/llm/client.d.ts.map +1 -0
- package/dist/ai-service/llm/client.js +168 -0
- package/dist/ai-service/llm/client.js.map +1 -0
- package/dist/ai-service/llm/context/context-handle.d.ts +4 -4
- package/dist/ai-service/llm/context/context-handle.d.ts.map +1 -1
- package/dist/ai-service/llm/context/context-handle.js +7 -3
- package/dist/ai-service/llm/context/context-handle.js.map +1 -1
- package/dist/ai-service/llm/context/context.d.ts +28 -0
- package/dist/ai-service/llm/context/context.d.ts.map +1 -1
- package/dist/ai-service/llm/context/context.js +119 -0
- package/dist/ai-service/llm/context/context.js.map +1 -1
- package/dist/ai-service/llm/context/manager.d.ts +22 -2
- package/dist/ai-service/llm/context/manager.d.ts.map +1 -1
- package/dist/ai-service/llm/context/manager.js +86 -13
- package/dist/ai-service/llm/context/manager.js.map +1 -1
- package/dist/ai-service/llm/context/storage/index.d.ts +1 -0
- package/dist/ai-service/llm/context/storage/index.d.ts.map +1 -1
- package/dist/ai-service/llm/context/storage/local.d.ts +1 -0
- package/dist/ai-service/llm/context/storage/local.d.ts.map +1 -1
- package/dist/ai-service/llm/context/storage/local.js +13 -1
- package/dist/ai-service/llm/context/storage/local.js.map +1 -1
- package/dist/ai-service/llm/context/utils/message-utils.d.ts.map +1 -1
- package/dist/ai-service/llm/context/utils/message-utils.js +6 -2
- package/dist/ai-service/llm/context/utils/message-utils.js.map +1 -1
- package/dist/ai-service/llm/error.d.ts +14 -4
- package/dist/ai-service/llm/error.d.ts.map +1 -1
- package/dist/ai-service/llm/error.js +49 -4
- package/dist/ai-service/llm/error.js.map +1 -1
- package/dist/ai-service/llm/interaction/adapters/vercel.d.ts +67 -0
- package/dist/ai-service/llm/interaction/adapters/vercel.d.ts.map +1 -0
- package/dist/ai-service/llm/interaction/adapters/vercel.js +111 -0
- package/dist/ai-service/llm/interaction/adapters/vercel.js.map +1 -0
- package/dist/ai-service/llm/interaction/compose.d.ts +71 -0
- package/dist/ai-service/llm/interaction/compose.d.ts.map +1 -0
- package/dist/ai-service/llm/interaction/compose.js +88 -0
- package/dist/ai-service/llm/interaction/compose.js.map +1 -0
- package/dist/ai-service/llm/interaction/index.d.ts +68 -0
- package/dist/ai-service/llm/interaction/index.d.ts.map +1 -0
- package/dist/ai-service/llm/interaction/index.js +70 -0
- package/dist/ai-service/llm/interaction/index.js.map +1 -0
- package/dist/ai-service/llm/interaction/middleware.d.ts +52 -0
- package/dist/ai-service/llm/interaction/middleware.d.ts.map +1 -0
- package/dist/ai-service/llm/interaction/middleware.js +17 -0
- package/dist/ai-service/llm/interaction/middleware.js.map +1 -0
- package/dist/ai-service/llm/interaction/middlewares/llmobs.d.ts +45 -0
- package/dist/ai-service/llm/interaction/middlewares/llmobs.d.ts.map +1 -0
- package/dist/ai-service/llm/interaction/middlewares/llmobs.js +85 -0
- package/dist/ai-service/llm/interaction/middlewares/llmobs.js.map +1 -0
- package/dist/ai-service/llm/interaction/middlewares/logging.d.ts +88 -0
- package/dist/ai-service/llm/interaction/middlewares/logging.d.ts.map +1 -0
- package/dist/ai-service/llm/interaction/middlewares/logging.js +238 -0
- package/dist/ai-service/llm/interaction/middlewares/logging.js.map +1 -0
- package/dist/ai-service/llm/interaction/middlewares/profiler.d.ts +47 -0
- package/dist/ai-service/llm/interaction/middlewares/profiler.d.ts.map +1 -0
- package/dist/ai-service/llm/interaction/middlewares/profiler.js +183 -0
- package/dist/ai-service/llm/interaction/middlewares/profiler.js.map +1 -0
- package/dist/ai-service/llm/interaction/middlewares/stream-retry.d.ts +121 -0
- package/dist/ai-service/llm/interaction/middlewares/stream-retry.d.ts.map +1 -0
- package/dist/ai-service/llm/interaction/middlewares/stream-retry.js +291 -0
- package/dist/ai-service/llm/interaction/middlewares/stream-retry.js.map +1 -0
- package/dist/ai-service/llm/interaction/provider.d.ts +173 -0
- package/dist/ai-service/llm/interaction/provider.d.ts.map +1 -0
- package/dist/ai-service/llm/interaction/provider.js +15 -0
- package/dist/ai-service/llm/interaction/provider.js.map +1 -0
- package/dist/ai-service/llm/interaction/result-utils.d.ts +43 -0
- package/dist/ai-service/llm/interaction/result-utils.d.ts.map +1 -0
- package/dist/ai-service/llm/interaction/result-utils.js +49 -0
- package/dist/ai-service/llm/interaction/result-utils.js.map +1 -0
- package/dist/ai-service/llm/interaction/stream-lifecycle.d.ts +48 -0
- package/dist/ai-service/llm/interaction/stream-lifecycle.d.ts.map +1 -0
- package/dist/ai-service/llm/interaction/stream-lifecycle.js +129 -0
- package/dist/ai-service/llm/interaction/stream-lifecycle.js.map +1 -0
- package/dist/ai-service/llm/provider.d.ts +1 -2
- package/dist/ai-service/llm/provider.d.ts.map +1 -1
- package/dist/ai-service/llm/provider.js +3 -6
- package/dist/ai-service/llm/provider.js.map +1 -1
- package/dist/ai-service/llmobs/helpers.d.ts +7 -8
- package/dist/ai-service/llmobs/helpers.d.ts.map +1 -1
- package/dist/ai-service/llmobs/helpers.js +8 -48
- package/dist/ai-service/llmobs/helpers.js.map +1 -1
- package/dist/ai-service/llmobs/middleware/stream-text.d.ts +19 -21
- package/dist/ai-service/llmobs/middleware/stream-text.d.ts.map +1 -1
- package/dist/ai-service/llmobs/middleware/stream-text.js +98 -106
- package/dist/ai-service/llmobs/middleware/stream-text.js.map +1 -1
- package/dist/ai-service/llmobs/types.d.ts +14 -1
- package/dist/ai-service/llmobs/types.d.ts.map +1 -1
- package/dist/ai-service/state-machine/clark-fsm.d.ts +75 -5
- package/dist/ai-service/state-machine/clark-fsm.d.ts.map +1 -1
- package/dist/ai-service/state-machine/clark-fsm.js +100 -0
- package/dist/ai-service/state-machine/clark-fsm.js.map +1 -1
- package/dist/ai-service/state-machine/handlers/agent-planning.d.ts.map +1 -1
- package/dist/ai-service/state-machine/handlers/agent-planning.js +4 -0
- package/dist/ai-service/state-machine/handlers/agent-planning.js.map +1 -1
- package/dist/ai-service/state-machine/handlers/llm-generating.d.ts.map +1 -1
- package/dist/ai-service/state-machine/handlers/llm-generating.js +91 -456
- package/dist/ai-service/state-machine/handlers/llm-generating.js.map +1 -1
- package/dist/ai-service/state-machine/handlers/runtime-reviewing.js +1 -1
- package/dist/ai-service/state-machine/handlers/runtime-reviewing.js.map +1 -1
- package/dist/ai-service/state-machine/helpers/peer.d.ts.map +1 -1
- package/dist/ai-service/state-machine/helpers/peer.js +15 -0
- package/dist/ai-service/state-machine/helpers/peer.js.map +1 -1
- package/dist/ai-service/state-machine/mocks.d.ts.map +1 -1
- package/dist/ai-service/state-machine/mocks.js +1 -0
- package/dist/ai-service/state-machine/mocks.js.map +1 -1
- package/dist/ai-service/template-renderer.js +1 -1
- package/dist/ai-service/template-renderer.js.map +1 -1
- package/dist/ai-service/types.d.ts +30 -0
- package/dist/ai-service/types.d.ts.map +1 -1
- package/dist/binding-extraction/extract-identifiers.d.ts +14 -0
- package/dist/binding-extraction/extract-identifiers.d.ts.map +1 -1
- package/dist/binding-extraction/extract-identifiers.js +46 -1
- package/dist/binding-extraction/extract-identifiers.js.map +1 -1
- package/dist/binding-extraction/js-identifiers.d.ts +14 -0
- package/dist/binding-extraction/js-identifiers.d.ts.map +1 -1
- package/dist/binding-extraction/js-identifiers.js +168 -0
- package/dist/binding-extraction/js-identifiers.js.map +1 -1
- package/dist/binding-extraction/python-identifiers.d.ts +5 -0
- package/dist/binding-extraction/python-identifiers.d.ts.map +1 -1
- package/dist/binding-extraction/python-identifiers.js +76 -7
- package/dist/binding-extraction/python-identifiers.js.map +1 -1
- package/dist/file-sync-vite-plugin.d.ts.map +1 -1
- package/dist/file-sync-vite-plugin.js +73 -3
- package/dist/file-sync-vite-plugin.js.map +1 -1
- package/dist/file-system-manager.d.ts.map +1 -1
- package/dist/file-system-manager.js +6 -4
- package/dist/file-system-manager.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lock-service/activity-tracker.d.ts +14 -2
- package/dist/lock-service/activity-tracker.d.ts.map +1 -1
- package/dist/lock-service/activity-tracker.js +43 -6
- package/dist/lock-service/activity-tracker.js.map +1 -1
- package/dist/lock-service/index.d.ts +13 -2
- package/dist/lock-service/index.d.ts.map +1 -1
- package/dist/lock-service/index.js +130 -44
- package/dist/lock-service/index.js.map +1 -1
- package/dist/parsing/jsx.d.ts.map +1 -1
- package/dist/parsing/jsx.js +78 -66
- package/dist/parsing/jsx.js.map +1 -1
- package/dist/socket-manager.js +1 -1
- package/dist/socket-manager.js.map +1 -1
- package/dist/sync-service/list-dir.d.ts.map +1 -1
- package/dist/sync-service/list-dir.js +41 -18
- package/dist/sync-service/list-dir.js.map +1 -1
- package/dist/vite-plugin-yaml-types.d.ts.map +1 -1
- package/dist/vite-plugin-yaml-types.js +2 -4
- package/dist/vite-plugin-yaml-types.js.map +1 -1
- package/package.json +7 -7
- package/dist/ai-service/agent/subagents/apis/api-executor.d.ts.map +0 -1
- package/dist/ai-service/agent/subagents/apis/api-executor.js.map +0 -1
- package/dist/ai-service/agent/subagents/apis/context.d.ts +0 -12
- package/dist/ai-service/agent/subagents/apis/context.d.ts.map +0 -1
- package/dist/ai-service/agent/subagents/apis/context.js +0 -18
- package/dist/ai-service/agent/subagents/apis/context.js.map +0 -1
- package/dist/ai-service/agent/subagents/apis/generate-api-source.d.ts +0 -40
- package/dist/ai-service/agent/subagents/apis/generate-api-source.d.ts.map +0 -1
- package/dist/ai-service/agent/subagents/apis/generate-api-source.js +0 -516
- package/dist/ai-service/agent/subagents/apis/generate-api-source.js.map +0 -1
- package/dist/ai-service/agent/subagents/apis/state.d.ts +0 -49
- package/dist/ai-service/agent/subagents/apis/state.d.ts.map +0 -1
- package/dist/ai-service/agent/subagents/apis/state.js +0 -25
- package/dist/ai-service/agent/subagents/apis/state.js.map +0 -1
- package/dist/ai-service/agent/subagents/apis/system-prompt.d.ts +0 -3
- package/dist/ai-service/agent/subagents/apis/system-prompt.d.ts.map +0 -1
- package/dist/ai-service/agent/subagents/apis/system-prompt.js +0 -1704
- package/dist/ai-service/agent/subagents/apis/system-prompt.js.map +0 -1
- package/dist/ai-service/agent/tools/apis/finalize-api.d.ts +0 -11
- package/dist/ai-service/agent/tools/apis/finalize-api.d.ts.map +0 -1
- package/dist/ai-service/agent/tools/apis/finalize-api.js +0 -133
- package/dist/ai-service/agent/tools/apis/finalize-api.js.map +0 -1
- package/dist/ai-service/llm/middleware/retry.d.ts +0 -112
- package/dist/ai-service/llm/middleware/retry.d.ts.map +0 -1
- package/dist/ai-service/llm/middleware/retry.js +0 -239
- package/dist/ai-service/llm/middleware/retry.js.map +0 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profiler middleware for LLM interactions.
|
|
3
|
+
*
|
|
4
|
+
* This middleware creates performance traces for LLM operations including:
|
|
5
|
+
* - Waiting for first token (waiting_on_llm span)
|
|
6
|
+
* - Streaming response (stream_text span)
|
|
7
|
+
* - Individual reasoning and text generation segments
|
|
8
|
+
*
|
|
9
|
+
* The traces are recorded in Perfetto format for visualization.
|
|
10
|
+
*/
|
|
11
|
+
import type { ClarkProfiler } from "../../../profiler/clark-profiler.js";
|
|
12
|
+
import type { StreamTextMiddleware } from "../middleware.js";
|
|
13
|
+
/**
|
|
14
|
+
* Options for configuring the profiler middleware.
|
|
15
|
+
*/
|
|
16
|
+
export interface ProfilerMiddlewareOptions {
|
|
17
|
+
/** The Clark profiler instance */
|
|
18
|
+
profiler: ClarkProfiler;
|
|
19
|
+
/** Model identifier for logging */
|
|
20
|
+
modelId?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Creates a middleware that profiles LLM interactions.
|
|
24
|
+
*
|
|
25
|
+
* The middleware wraps the streamText call to create timing spans:
|
|
26
|
+
* 1. waiting_on_llm: From call start to first token received
|
|
27
|
+
* 2. stream_text: From first token to stream completion
|
|
28
|
+
* 3. thinking/text_generation: Individual reasoning and text segments
|
|
29
|
+
*
|
|
30
|
+
* All timing data is recorded to the profiler for later export.
|
|
31
|
+
*
|
|
32
|
+
* @param options - Configuration for the middleware
|
|
33
|
+
* @returns A StreamTextMiddleware
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const middleware = createProfilerMiddleware({
|
|
38
|
+
* profiler: services.clarkProfiler,
|
|
39
|
+
* modelId: model.modelId
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* const streamText = applyMiddleware(baseStreamText, middleware);
|
|
43
|
+
* const result = await streamText({ model, messages, tools });
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function createProfilerMiddleware(options: ProfilerMiddlewareOptions): StreamTextMiddleware;
|
|
47
|
+
//# sourceMappingURL=profiler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiler.d.ts","sourceRoot":"","sources":["../../../../../src/ai-service/llm/interaction/middlewares/profiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACzE,OAAO,KAAK,EACV,oBAAoB,EAGrB,MAAM,kBAAkB,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,kCAAkC;IAClC,QAAQ,EAAE,aAAa,CAAC;IAExB,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,yBAAyB,GACjC,oBAAoB,CAwKtB"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profiler middleware for LLM interactions.
|
|
3
|
+
*
|
|
4
|
+
* This middleware creates performance traces for LLM operations including:
|
|
5
|
+
* - Waiting for first token (waiting_on_llm span)
|
|
6
|
+
* - Streaming response (stream_text span)
|
|
7
|
+
* - Individual reasoning and text generation segments
|
|
8
|
+
*
|
|
9
|
+
* The traces are recorded in Perfetto format for visualization.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Creates a middleware that profiles LLM interactions.
|
|
13
|
+
*
|
|
14
|
+
* The middleware wraps the streamText call to create timing spans:
|
|
15
|
+
* 1. waiting_on_llm: From call start to first token received
|
|
16
|
+
* 2. stream_text: From first token to stream completion
|
|
17
|
+
* 3. thinking/text_generation: Individual reasoning and text segments
|
|
18
|
+
*
|
|
19
|
+
* All timing data is recorded to the profiler for later export.
|
|
20
|
+
*
|
|
21
|
+
* @param options - Configuration for the middleware
|
|
22
|
+
* @returns A StreamTextMiddleware
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const middleware = createProfilerMiddleware({
|
|
27
|
+
* profiler: services.clarkProfiler,
|
|
28
|
+
* modelId: model.modelId
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* const streamText = applyMiddleware(baseStreamText, middleware);
|
|
32
|
+
* const result = await streamText({ model, messages, tools });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export function createProfilerMiddleware(options) {
|
|
36
|
+
const { profiler, modelId } = options;
|
|
37
|
+
return {
|
|
38
|
+
wrap(provider) {
|
|
39
|
+
return {
|
|
40
|
+
async streamText(streamOptions) {
|
|
41
|
+
let firstTokenReceived = false;
|
|
42
|
+
let thinkingSpanActive = false;
|
|
43
|
+
let textSpanActive = false;
|
|
44
|
+
const thinkingTrack = "thinking";
|
|
45
|
+
const textTrack = "text_generation";
|
|
46
|
+
let stepCount = 0;
|
|
47
|
+
// Start waiting span before the call
|
|
48
|
+
profiler.startLLMWaiting({
|
|
49
|
+
messages: streamOptions.messages,
|
|
50
|
+
model: modelId || streamOptions.model.modelId || "unknown",
|
|
51
|
+
});
|
|
52
|
+
// Wrap onChunk to track first token and segment transitions
|
|
53
|
+
const originalOnChunk = streamOptions.onChunk;
|
|
54
|
+
const wrappedOnChunk = async (chunk) => {
|
|
55
|
+
// Start streaming span on first token
|
|
56
|
+
if (!firstTokenReceived) {
|
|
57
|
+
firstTokenReceived = true;
|
|
58
|
+
const firstChunk = chunk.chunk.type === "text-delta"
|
|
59
|
+
? chunk.chunk.text
|
|
60
|
+
: chunk.chunk.type === "reasoning-delta"
|
|
61
|
+
? chunk.chunk.reasoning
|
|
62
|
+
: undefined;
|
|
63
|
+
profiler.startLLMStreaming({
|
|
64
|
+
firstChunk,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
// Track reasoning segments
|
|
68
|
+
if (chunk.chunk.type === "reasoning-delta") {
|
|
69
|
+
if (!thinkingSpanActive) {
|
|
70
|
+
profiler
|
|
71
|
+
.getProfiler()
|
|
72
|
+
.createTrack(thinkingTrack, "AI Thinking/Reasoning", "llm");
|
|
73
|
+
profiler
|
|
74
|
+
.getProfiler()
|
|
75
|
+
.startFrame(`Thinking Step ${stepCount + 1}`, thinkingTrack);
|
|
76
|
+
thinkingSpanActive = true;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else if (thinkingSpanActive) {
|
|
80
|
+
// End thinking span when switching to different chunk type
|
|
81
|
+
profiler.getProfiler().endFrame(thinkingTrack);
|
|
82
|
+
thinkingSpanActive = false;
|
|
83
|
+
}
|
|
84
|
+
// Track text generation segments
|
|
85
|
+
if (chunk.chunk.type === "text-delta") {
|
|
86
|
+
if (!textSpanActive) {
|
|
87
|
+
profiler
|
|
88
|
+
.getProfiler()
|
|
89
|
+
.createTrack(textTrack, "Text Generation", "llm");
|
|
90
|
+
profiler
|
|
91
|
+
.getProfiler()
|
|
92
|
+
.startFrame(`Text Generation Step ${stepCount + 1}`, textTrack);
|
|
93
|
+
textSpanActive = true;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else if (textSpanActive) {
|
|
97
|
+
// End text span when switching to different chunk type
|
|
98
|
+
profiler.getProfiler().endFrame(textTrack);
|
|
99
|
+
textSpanActive = false;
|
|
100
|
+
}
|
|
101
|
+
// Call original onChunk if present
|
|
102
|
+
if (originalOnChunk) {
|
|
103
|
+
await originalOnChunk(chunk);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
// Wrap onStepFinish to track step count
|
|
107
|
+
const originalOnStepFinish = streamOptions.onStepFinish;
|
|
108
|
+
const wrappedOnStepFinish = async (step) => {
|
|
109
|
+
stepCount++;
|
|
110
|
+
// Call original onStepFinish if present
|
|
111
|
+
if (originalOnStepFinish) {
|
|
112
|
+
await originalOnStepFinish(step);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
// Wrap onFinish to end all active spans
|
|
116
|
+
const originalOnFinish = streamOptions.onFinish;
|
|
117
|
+
const wrappedOnFinish = async (result) => {
|
|
118
|
+
// End streaming span if it was started
|
|
119
|
+
if (firstTokenReceived) {
|
|
120
|
+
profiler.endFrame(); // End stream_text
|
|
121
|
+
}
|
|
122
|
+
profiler.endFrame(); // End waiting_on_llm
|
|
123
|
+
// End any active segment spans
|
|
124
|
+
if (thinkingSpanActive) {
|
|
125
|
+
profiler.getProfiler().endFrame(thinkingTrack);
|
|
126
|
+
}
|
|
127
|
+
if (textSpanActive) {
|
|
128
|
+
profiler.getProfiler().endFrame(textTrack);
|
|
129
|
+
}
|
|
130
|
+
// Call original onFinish if present
|
|
131
|
+
if (originalOnFinish) {
|
|
132
|
+
await originalOnFinish(result);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
// Wrap onError to clean up spans on error
|
|
136
|
+
const originalOnError = streamOptions.onError;
|
|
137
|
+
const wrappedOnError = async (error) => {
|
|
138
|
+
// End all active spans on error
|
|
139
|
+
if (firstTokenReceived) {
|
|
140
|
+
profiler.endFrame(); // End stream_text
|
|
141
|
+
}
|
|
142
|
+
profiler.endFrame(); // End waiting_on_llm
|
|
143
|
+
if (thinkingSpanActive) {
|
|
144
|
+
profiler.getProfiler().endFrame(thinkingTrack);
|
|
145
|
+
}
|
|
146
|
+
if (textSpanActive) {
|
|
147
|
+
profiler.getProfiler().endFrame(textTrack);
|
|
148
|
+
}
|
|
149
|
+
// Call original onError if present
|
|
150
|
+
if (originalOnError) {
|
|
151
|
+
await originalOnError(error);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
// Call provider with wrapped callbacks
|
|
155
|
+
try {
|
|
156
|
+
return await provider.streamText({
|
|
157
|
+
...streamOptions,
|
|
158
|
+
onChunk: wrappedOnChunk,
|
|
159
|
+
onStepFinish: wrappedOnStepFinish,
|
|
160
|
+
onFinish: wrappedOnFinish,
|
|
161
|
+
onError: wrappedOnError,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
// Clean up spans if an error is thrown before onError is called
|
|
166
|
+
if (firstTokenReceived) {
|
|
167
|
+
profiler.endFrame();
|
|
168
|
+
}
|
|
169
|
+
profiler.endFrame();
|
|
170
|
+
if (thinkingSpanActive) {
|
|
171
|
+
profiler.getProfiler().endFrame(thinkingTrack);
|
|
172
|
+
}
|
|
173
|
+
if (textSpanActive) {
|
|
174
|
+
profiler.getProfiler().endFrame(textTrack);
|
|
175
|
+
}
|
|
176
|
+
throw error;
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=profiler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiler.js","sourceRoot":"","sources":["../../../../../src/ai-service/llm/interaction/middlewares/profiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAqBH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,wBAAwB,CACtC,OAAkC;IAElC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAEtC,OAAO;QACL,IAAI,CAAC,QAA4B;YAC/B,OAAO;gBACL,KAAK,CAAC,UAAU,CACd,aAAuC;oBAEvC,IAAI,kBAAkB,GAAG,KAAK,CAAC;oBAC/B,IAAI,kBAAkB,GAAG,KAAK,CAAC;oBAC/B,IAAI,cAAc,GAAG,KAAK,CAAC;oBAC3B,MAAM,aAAa,GAAG,UAAU,CAAC;oBACjC,MAAM,SAAS,GAAG,iBAAiB,CAAC;oBACpC,IAAI,SAAS,GAAG,CAAC,CAAC;oBAElB,qCAAqC;oBACrC,QAAQ,CAAC,eAAe,CAAC;wBACvB,QAAQ,EAAE,aAAa,CAAC,QAAQ;wBAChC,KAAK,EAAE,OAAO,IAAK,aAAa,CAAC,KAAa,CAAC,OAAO,IAAI,SAAS;qBACpE,CAAC,CAAC;oBAEH,4DAA4D;oBAC5D,MAAM,eAAe,GAAG,aAAa,CAAC,OAAO,CAAC;oBAC9C,MAAM,cAAc,GAAG,KAAK,EAAE,KAAU,EAAE,EAAE;wBAC1C,sCAAsC;wBACtC,IAAI,CAAC,kBAAkB,EAAE,CAAC;4BACxB,kBAAkB,GAAG,IAAI,CAAC;4BAC1B,MAAM,UAAU,GACd,KAAK,CAAC,KA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W,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;wBAC7C,CAAC;wBAED,MAAM,KAAK,CAAC;oBACd,CAAC;gBACH,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retry middleware for StreamText operations.
|
|
3
|
+
*
|
|
4
|
+
* This middleware wraps entire streamText() calls to handle failures during
|
|
5
|
+
* stream consumption. When a stream fails mid-consumption (e.g., network timeout),
|
|
6
|
+
* this middleware retries the entire streamText call with accumulated messages
|
|
7
|
+
* from successful steps preserved via Context.
|
|
8
|
+
*
|
|
9
|
+
* **Two-phase retry architecture:**
|
|
10
|
+
* 1. **Initial call retry**: Retries errors when calling streamText() to get metadata
|
|
11
|
+
* 2. **Stream consumption retry**: Retries mid-stream errors during stream consumption
|
|
12
|
+
*
|
|
13
|
+
* **Separate retry budgets:**
|
|
14
|
+
* Each phase has its own independent retry budget. For example, with maxRetries: 3:
|
|
15
|
+
* - Phase 1 can retry up to 3 times (4 total attempts to get initial metadata)
|
|
16
|
+
* - Phase 2 can retry up to 3 times (4 total attempts to consume stream)
|
|
17
|
+
* - Maximum total attempts: 4 (phase 1) + 4 (phase 2) = 8
|
|
18
|
+
*
|
|
19
|
+
* This design ensures that failures in one phase don't prevent retries in the other phase.
|
|
20
|
+
*
|
|
21
|
+
* ## Why at StreamText Level?
|
|
22
|
+
*
|
|
23
|
+
* Retrying at the streamText level (vs model.doStream level) ensures:
|
|
24
|
+
* 1. **Fresh Vercel SDK state**: Each retry gets a new eventProcessor with no
|
|
25
|
+
* partial chunk pollution from failed attempts
|
|
26
|
+
* 2. **Correct message sequences**: No orphaned content IDs or invalid message structures
|
|
27
|
+
* 3. **Natural continuation**: Vercel SDK's built-in logic handles multi-step resumption
|
|
28
|
+
*
|
|
29
|
+
* ## How It Works with Context
|
|
30
|
+
*
|
|
31
|
+
* The Context system provides the accumulated messages for retry:
|
|
32
|
+
* - Step 1 succeeds → Context.endStep() records messages
|
|
33
|
+
* - Step 2 fails → No endStep() call, empty step array remains
|
|
34
|
+
* - Retry → Context.getMessages() provides Step 1's messages
|
|
35
|
+
* - Fresh streamText() call receives those messages and continues from Step 2 Context.startStep() is idempotent → reuses empty step array
|
|
36
|
+
*
|
|
37
|
+
* ## Multi-Step Scenarios
|
|
38
|
+
*
|
|
39
|
+
* For multi-step flows (e.g., tool calling):
|
|
40
|
+
* - Step 1 (tool call) succeeds
|
|
41
|
+
* - Step 2 (continuation) fails
|
|
42
|
+
* - Retry receives Step 1's messages (including tool-results)
|
|
43
|
+
* - Vercel SDK sees tool-results and continues to Step 2
|
|
44
|
+
* - Does NOT re-execute Step 1's tools (already have results)
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const middleware = createStreamRetryMiddleware({
|
|
49
|
+
* maxRetries: 3,
|
|
50
|
+
* maxTotalRetryTimeMs: 120000,
|
|
51
|
+
* isRetryable: (error) => isNetworkError(error)
|
|
52
|
+
* });
|
|
53
|
+
*
|
|
54
|
+
* const provider = applyMiddleware(baseProvider, middleware);
|
|
55
|
+
* const result = await provider.streamText({ model, messages, tools });
|
|
56
|
+
* // Automatically retries on stream consumption failures
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
import { type Logger } from "../../../../util/logger.js";
|
|
60
|
+
import { type BackoffStrategy } from "../../../util/backoff-strategy.js";
|
|
61
|
+
import type { StreamTextMiddleware } from "../middleware.js";
|
|
62
|
+
export interface StreamRetryOptions {
|
|
63
|
+
/**
|
|
64
|
+
* Maximum number of retry attempts per phase (not including the initial attempt).
|
|
65
|
+
* Each phase (initial call, stream consumption) gets its own retry budget.
|
|
66
|
+
* Default: Infinity (unlimited)
|
|
67
|
+
*/
|
|
68
|
+
maxRetries?: number;
|
|
69
|
+
/**
|
|
70
|
+
* Custom backoff strategy for calculating retry delays.
|
|
71
|
+
* If not provided, uses ExponentialBackoff.
|
|
72
|
+
*/
|
|
73
|
+
backoffStrategy?: BackoffStrategy;
|
|
74
|
+
/**
|
|
75
|
+
* Initial delay in milliseconds before the first retry.
|
|
76
|
+
* Default: 500 (0.5 seconds)
|
|
77
|
+
*/
|
|
78
|
+
initialDelayMs?: number;
|
|
79
|
+
/**
|
|
80
|
+
* Maximum delay in milliseconds for exponential backoff.
|
|
81
|
+
* Default: 5000 (5 seconds)
|
|
82
|
+
*/
|
|
83
|
+
maxDelayMs?: number;
|
|
84
|
+
/**
|
|
85
|
+
* Backoff multiplier for exponential backoff.
|
|
86
|
+
* Default: 2
|
|
87
|
+
*/
|
|
88
|
+
backoffMultiplier?: number;
|
|
89
|
+
/**
|
|
90
|
+
* Maximum total time in milliseconds for all retry attempts.
|
|
91
|
+
* Default: undefined (no time limit)
|
|
92
|
+
*/
|
|
93
|
+
maxTotalRetryTimeMs?: number;
|
|
94
|
+
/**
|
|
95
|
+
* Function to determine if an error is retryable.
|
|
96
|
+
* Default: checks for timeout and connection errors
|
|
97
|
+
*/
|
|
98
|
+
isRetryable?: (error: unknown) => boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Callback invoked before each retry attempt.
|
|
101
|
+
*/
|
|
102
|
+
onRetry?: (error: unknown, attempt: number, delayMs: number, totalRetryTimeMs: number) => void | Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Optional abort signal to cancel retry attempts.
|
|
105
|
+
* When the signal is aborted, no further retries will be attempted.
|
|
106
|
+
*/
|
|
107
|
+
abortSignal?: AbortSignal;
|
|
108
|
+
/** Logger instance for retry operations */
|
|
109
|
+
logger?: Logger;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Creates a middleware that retries streamText calls on failure.
|
|
113
|
+
*
|
|
114
|
+
* This middleware wraps the entire streamText operation, catching errors during
|
|
115
|
+
* both the initial call and stream consumption. Retries with accumulated messages from Context.
|
|
116
|
+
*
|
|
117
|
+
* @param options - Configuration for retry behavior
|
|
118
|
+
* @returns A StreamTextMiddleware
|
|
119
|
+
*/
|
|
120
|
+
export declare function createStreamRetryMiddleware(options?: StreamRetryOptions): StreamTextMiddleware;
|
|
121
|
+
//# sourceMappingURL=stream-retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-retry.d.ts","sourceRoot":"","sources":["../../../../../src/ai-service/llm/interaction/middlewares/stream-retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAEH,OAAO,EACL,KAAK,MAAM,EAGZ,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,mCAAmC,CAAC;AAI3C,OAAO,KAAK,EACV,oBAAoB,EAIrB,MAAM,kBAAkB,CAAC;AAG1B,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;IAElC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;IAE1C;;OAEG;IACH,OAAO,CAAC,EAAE,CACR,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,gBAAgB,EAAE,MAAM,KACrB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1B;;;OAGG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAE1B,2CAA2C;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,GAAE,kBAAuB,GAC/B,oBAAoB,CAgHtB"}
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retry middleware for StreamText operations.
|
|
3
|
+
*
|
|
4
|
+
* This middleware wraps entire streamText() calls to handle failures during
|
|
5
|
+
* stream consumption. When a stream fails mid-consumption (e.g., network timeout),
|
|
6
|
+
* this middleware retries the entire streamText call with accumulated messages
|
|
7
|
+
* from successful steps preserved via Context.
|
|
8
|
+
*
|
|
9
|
+
* **Two-phase retry architecture:**
|
|
10
|
+
* 1. **Initial call retry**: Retries errors when calling streamText() to get metadata
|
|
11
|
+
* 2. **Stream consumption retry**: Retries mid-stream errors during stream consumption
|
|
12
|
+
*
|
|
13
|
+
* **Separate retry budgets:**
|
|
14
|
+
* Each phase has its own independent retry budget. For example, with maxRetries: 3:
|
|
15
|
+
* - Phase 1 can retry up to 3 times (4 total attempts to get initial metadata)
|
|
16
|
+
* - Phase 2 can retry up to 3 times (4 total attempts to consume stream)
|
|
17
|
+
* - Maximum total attempts: 4 (phase 1) + 4 (phase 2) = 8
|
|
18
|
+
*
|
|
19
|
+
* This design ensures that failures in one phase don't prevent retries in the other phase.
|
|
20
|
+
*
|
|
21
|
+
* ## Why at StreamText Level?
|
|
22
|
+
*
|
|
23
|
+
* Retrying at the streamText level (vs model.doStream level) ensures:
|
|
24
|
+
* 1. **Fresh Vercel SDK state**: Each retry gets a new eventProcessor with no
|
|
25
|
+
* partial chunk pollution from failed attempts
|
|
26
|
+
* 2. **Correct message sequences**: No orphaned content IDs or invalid message structures
|
|
27
|
+
* 3. **Natural continuation**: Vercel SDK's built-in logic handles multi-step resumption
|
|
28
|
+
*
|
|
29
|
+
* ## How It Works with Context
|
|
30
|
+
*
|
|
31
|
+
* The Context system provides the accumulated messages for retry:
|
|
32
|
+
* - Step 1 succeeds → Context.endStep() records messages
|
|
33
|
+
* - Step 2 fails → No endStep() call, empty step array remains
|
|
34
|
+
* - Retry → Context.getMessages() provides Step 1's messages
|
|
35
|
+
* - Fresh streamText() call receives those messages and continues from Step 2 Context.startStep() is idempotent → reuses empty step array
|
|
36
|
+
*
|
|
37
|
+
* ## Multi-Step Scenarios
|
|
38
|
+
*
|
|
39
|
+
* For multi-step flows (e.g., tool calling):
|
|
40
|
+
* - Step 1 (tool call) succeeds
|
|
41
|
+
* - Step 2 (continuation) fails
|
|
42
|
+
* - Retry receives Step 1's messages (including tool-results)
|
|
43
|
+
* - Vercel SDK sees tool-results and continues to Step 2
|
|
44
|
+
* - Does NOT re-execute Step 1's tools (already have results)
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const middleware = createStreamRetryMiddleware({
|
|
49
|
+
* maxRetries: 3,
|
|
50
|
+
* maxTotalRetryTimeMs: 120000,
|
|
51
|
+
* isRetryable: (error) => isNetworkError(error)
|
|
52
|
+
* });
|
|
53
|
+
*
|
|
54
|
+
* const provider = applyMiddleware(baseProvider, middleware);
|
|
55
|
+
* const result = await provider.streamText({ model, messages, tools });
|
|
56
|
+
* // Automatically retries on stream consumption failures
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
import { getErrorMeta, getPrefixedLogger, } from "../../../../util/logger.js";
|
|
60
|
+
import { ExponentialBackoff, } from "../../../util/backoff-strategy.js";
|
|
61
|
+
import { LLMProviderError } from "../../error.js";
|
|
62
|
+
import { isProviderErrorRetryable } from "../../util/provider-errors.js";
|
|
63
|
+
/**
|
|
64
|
+
* Creates a middleware that retries streamText calls on failure.
|
|
65
|
+
*
|
|
66
|
+
* This middleware wraps the entire streamText operation, catching errors during
|
|
67
|
+
* both the initial call and stream consumption. Retries with accumulated messages from Context.
|
|
68
|
+
*
|
|
69
|
+
* @param options - Configuration for retry behavior
|
|
70
|
+
* @returns A StreamTextMiddleware
|
|
71
|
+
*/
|
|
72
|
+
export function createStreamRetryMiddleware(options = {}) {
|
|
73
|
+
const { maxRetries = Infinity, initialDelayMs = 500, maxDelayMs = 5000, backoffMultiplier = 2, maxTotalRetryTimeMs, isRetryable = isProviderErrorRetryable, onRetry, abortSignal, logger = getPrefixedLogger("[StreamRetry]"), } = options;
|
|
74
|
+
const backoffStrategy = options.backoffStrategy ??
|
|
75
|
+
new ExponentialBackoff({
|
|
76
|
+
initialDelayMs,
|
|
77
|
+
maxDelayMs,
|
|
78
|
+
backoffMultiplier,
|
|
79
|
+
});
|
|
80
|
+
const maxRetriesDisplay = maxRetries === Infinity ? "unlimited" : String(maxRetries);
|
|
81
|
+
return {
|
|
82
|
+
wrap(provider) {
|
|
83
|
+
return {
|
|
84
|
+
async streamText(streamOptions) {
|
|
85
|
+
// Phase 1: Retry initial streamText call
|
|
86
|
+
let httpAttempt = 0;
|
|
87
|
+
let totalRetryTime = 0;
|
|
88
|
+
const overallStartTime = Date.now();
|
|
89
|
+
let initialResult;
|
|
90
|
+
while (true) {
|
|
91
|
+
try {
|
|
92
|
+
initialResult = await provider.streamText(streamOptions);
|
|
93
|
+
break; // Success!
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
httpAttempt++;
|
|
97
|
+
const error = wrapError(err);
|
|
98
|
+
const delay = await handleRetryAttempt(error, httpAttempt, totalRetryTime, {
|
|
99
|
+
maxRetries,
|
|
100
|
+
maxRetriesDisplay,
|
|
101
|
+
maxTotalRetryTimeMs,
|
|
102
|
+
overallStartTime,
|
|
103
|
+
backoffStrategy,
|
|
104
|
+
isRetryable,
|
|
105
|
+
onRetry,
|
|
106
|
+
abortSignal,
|
|
107
|
+
logger,
|
|
108
|
+
errorContext: "HTTP error",
|
|
109
|
+
});
|
|
110
|
+
totalRetryTime += delay;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// Phase 2: Wrap streams to handle consumption errors
|
|
114
|
+
const retryingFullStream = createRetryingAsyncIterable(provider, streamOptions, () => initialResult.fullStream, {
|
|
115
|
+
maxRetries,
|
|
116
|
+
maxRetriesDisplay,
|
|
117
|
+
maxTotalRetryTimeMs,
|
|
118
|
+
overallStartTime,
|
|
119
|
+
backoffStrategy,
|
|
120
|
+
isRetryable,
|
|
121
|
+
onRetry,
|
|
122
|
+
abortSignal,
|
|
123
|
+
logger,
|
|
124
|
+
});
|
|
125
|
+
const retryingTextStream = createRetryingAsyncIterable(provider, streamOptions, () => initialResult.textStream, {
|
|
126
|
+
maxRetries,
|
|
127
|
+
maxRetriesDisplay,
|
|
128
|
+
maxTotalRetryTimeMs,
|
|
129
|
+
overallStartTime,
|
|
130
|
+
backoffStrategy,
|
|
131
|
+
isRetryable,
|
|
132
|
+
onRetry,
|
|
133
|
+
abortSignal,
|
|
134
|
+
logger,
|
|
135
|
+
});
|
|
136
|
+
// Return result with retrying streams
|
|
137
|
+
return {
|
|
138
|
+
...initialResult,
|
|
139
|
+
fullStream: retryingFullStream,
|
|
140
|
+
textStream: retryingTextStream,
|
|
141
|
+
};
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Creates an AsyncIterableStream that retries on consumption errors.
|
|
149
|
+
*/
|
|
150
|
+
function createRetryingAsyncIterable(provider, streamOptions, getInitialStream, config) {
|
|
151
|
+
// Create an AsyncIterable that implements the retry logic
|
|
152
|
+
const retryingIterable = {
|
|
153
|
+
async *[Symbol.asyncIterator]() {
|
|
154
|
+
let consumptionAttempt = 0;
|
|
155
|
+
let isFirstAttempt = true;
|
|
156
|
+
while (true) {
|
|
157
|
+
try {
|
|
158
|
+
// Get stream for current attempt
|
|
159
|
+
const iterator = isFirstAttempt
|
|
160
|
+
? getInitialStream()[Symbol.asyncIterator]()
|
|
161
|
+
: await (async () => {
|
|
162
|
+
const streamResult = await provider.streamText(streamOptions);
|
|
163
|
+
// Use fullStream for retries (contains all chunk types)
|
|
164
|
+
return streamResult.fullStream[Symbol.asyncIterator]();
|
|
165
|
+
})();
|
|
166
|
+
isFirstAttempt = false;
|
|
167
|
+
// Iterate through chunks
|
|
168
|
+
while (true) {
|
|
169
|
+
const { value: chunk, done } = await iterator.next();
|
|
170
|
+
if (done) {
|
|
171
|
+
return; // Success!
|
|
172
|
+
}
|
|
173
|
+
// Check for error chunks
|
|
174
|
+
if (typeof chunk === "object" &&
|
|
175
|
+
chunk !== null &&
|
|
176
|
+
"type" in chunk &&
|
|
177
|
+
chunk.type === "error") {
|
|
178
|
+
throw wrapError(chunk.error);
|
|
179
|
+
}
|
|
180
|
+
// Normal chunk - yield it
|
|
181
|
+
yield chunk;
|
|
182
|
+
// Reset consumption attempt on successful chunk
|
|
183
|
+
consumptionAttempt = 0;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
catch (err) {
|
|
187
|
+
const error = wrapError(err);
|
|
188
|
+
// Handle error - check if we should retry
|
|
189
|
+
consumptionAttempt++;
|
|
190
|
+
const totalElapsed = Date.now() - config.overallStartTime;
|
|
191
|
+
try {
|
|
192
|
+
await handleRetryAttempt(error, consumptionAttempt, totalElapsed, {
|
|
193
|
+
...config,
|
|
194
|
+
errorContext: "Stream error",
|
|
195
|
+
});
|
|
196
|
+
// Loop continues - will try again with fresh stream
|
|
197
|
+
}
|
|
198
|
+
catch (finalError) {
|
|
199
|
+
// Exhausted or non-retryable - yield error and exit
|
|
200
|
+
yield {
|
|
201
|
+
type: "error",
|
|
202
|
+
error: finalError,
|
|
203
|
+
};
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
// Convert AsyncIterable to ReadableStream
|
|
211
|
+
const readableStream = new ReadableStream({
|
|
212
|
+
async start(controller) {
|
|
213
|
+
try {
|
|
214
|
+
for await (const chunk of retryingIterable) {
|
|
215
|
+
controller.enqueue(chunk);
|
|
216
|
+
}
|
|
217
|
+
controller.close();
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
controller.error(error);
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
// Return as AsyncIterableStream (ReadableStream with async iteration support)
|
|
225
|
+
return readableStream;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Wraps an error in LLMProviderError if it isn't already.
|
|
229
|
+
*/
|
|
230
|
+
function wrapError(err, provider) {
|
|
231
|
+
if (err instanceof LLMProviderError) {
|
|
232
|
+
return err;
|
|
233
|
+
}
|
|
234
|
+
// Provider is optional here since we may not know it at this level
|
|
235
|
+
return new LLMProviderError({
|
|
236
|
+
provider: provider,
|
|
237
|
+
cause: err,
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Checks if retry is allowed and executes retry logic.
|
|
242
|
+
* Returns the delay in milliseconds if a retry should be attempted.
|
|
243
|
+
* Throws if no retry is possible.
|
|
244
|
+
*/
|
|
245
|
+
async function handleRetryAttempt(error, attempt, totalRetryTime, config) {
|
|
246
|
+
// Check abort signal
|
|
247
|
+
if (config.abortSignal?.aborted) {
|
|
248
|
+
const abortError = new LLMProviderError({
|
|
249
|
+
provider: error.provider,
|
|
250
|
+
message: "Request aborted",
|
|
251
|
+
type: "aborted",
|
|
252
|
+
isRetryable: false,
|
|
253
|
+
});
|
|
254
|
+
config.logger.info("Request aborted, stopping retry attempts");
|
|
255
|
+
throw abortError;
|
|
256
|
+
}
|
|
257
|
+
// Check retry conditions
|
|
258
|
+
const withinMaxRetries = attempt <= config.maxRetries;
|
|
259
|
+
const withinTimeLimit = !config.maxTotalRetryTimeMs ||
|
|
260
|
+
Date.now() - config.overallStartTime < config.maxTotalRetryTimeMs;
|
|
261
|
+
const errorIsRetryable = config.isRetryable(error);
|
|
262
|
+
const canRetry = errorIsRetryable && withinMaxRetries && withinTimeLimit;
|
|
263
|
+
if (!canRetry) {
|
|
264
|
+
if (errorIsRetryable) {
|
|
265
|
+
const reason = !withinMaxRetries
|
|
266
|
+
? `after ${config.maxRetriesDisplay} retries`
|
|
267
|
+
: `total retry time exceeded ${config.maxTotalRetryTimeMs}ms`;
|
|
268
|
+
config.logger.error(`Exceeded retry limits: ${reason}`, getErrorMeta(error.cause));
|
|
269
|
+
throw new LLMProviderError({
|
|
270
|
+
provider: error.provider,
|
|
271
|
+
message: `${config.errorContext} ${reason}`,
|
|
272
|
+
type: "retries_exhausted",
|
|
273
|
+
isRetryable: false,
|
|
274
|
+
cause: error,
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
config.logger.error("Non-retryable error encountered", getErrorMeta(error.cause));
|
|
278
|
+
throw error;
|
|
279
|
+
}
|
|
280
|
+
// Calculate backoff delay
|
|
281
|
+
const delay = config.backoffStrategy.getNextDelay(attempt);
|
|
282
|
+
config.logger.warn(`${config.errorContext} (type: ${error.type}). Attempt ${attempt}/${config.maxRetriesDisplay}. Retrying in ${delay}ms...`);
|
|
283
|
+
// Call onRetry callback
|
|
284
|
+
if (config.onRetry) {
|
|
285
|
+
await config.onRetry(error, attempt, delay, totalRetryTime);
|
|
286
|
+
}
|
|
287
|
+
// Wait before retry
|
|
288
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
289
|
+
return delay;
|
|
290
|
+
}
|
|
291
|
+
//# sourceMappingURL=stream-retry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-retry.js","sourceRoot":"","sources":["../../../../../src/ai-service/llm/interaction/middlewares/stream-retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAEH,OAAO,EAEL,YAAY,EACZ,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,kBAAkB,GAEnB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AA0EzE;;;;;;;;GAQG;A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