@superblocksteam/vite-plugin-file-sync 2.0.43-next.15 β†’ 2.0.43-next.16

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.
Files changed (50) hide show
  1. package/dist/ai-service/llmobs/helpers.d.ts +9 -2
  2. package/dist/ai-service/llmobs/helpers.d.ts.map +1 -1
  3. package/dist/ai-service/llmobs/helpers.js +17 -4
  4. package/dist/ai-service/llmobs/helpers.js.map +1 -1
  5. package/dist/ai-service/llmobs/middleware/retry.d.ts +51 -0
  6. package/dist/ai-service/llmobs/middleware/retry.d.ts.map +1 -0
  7. package/dist/ai-service/llmobs/middleware/retry.js +147 -0
  8. package/dist/ai-service/llmobs/middleware/retry.js.map +1 -0
  9. package/dist/ai-service/llmobs/middleware/stream-text.d.ts.map +1 -1
  10. package/dist/ai-service/llmobs/middleware/stream-text.js.map +1 -1
  11. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/ButtonPropsDocs.js +1 -1
  12. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/CheckboxPropsDocs.js +1 -1
  13. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/ColumnPropsDocs.js +1 -1
  14. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/ContainerPropsDocs.js +1 -1
  15. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/DatePickerPropsDocs.js +1 -1
  16. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/DropdownPropsDocs.js +1 -1
  17. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/IconPropsDocs.js +1 -1
  18. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/ImagePropsDocs.js +1 -1
  19. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/InputPropsDocs.js +1 -1
  20. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/ModalPropsDocs.js +1 -1
  21. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/PagePropsDocs.js +1 -1
  22. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/SectionPropsDocs.js +1 -1
  23. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/SlideoutPropsDocs.js +1 -1
  24. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/SwitchPropsDocs.js +1 -1
  25. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/TablePropsDocs.js +1 -1
  26. package/dist/ai-service/prompt-builder-service/static-fragments/library-components/TextPropsDocs.js +1 -1
  27. package/dist/ai-service/prompt-builder-service/static-fragments/library-typedefs/Dim.js +1 -1
  28. package/dist/ai-service/prompt-builder-service/static-fragments/library-typedefs/EventFlow.js +1 -1
  29. package/dist/ai-service/prompt-builder-service/static-fragments/library-typedefs/TextStyleWithVariant.js +1 -1
  30. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/full-examples.js +1 -1
  31. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-api.js +1 -1
  32. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-components-rules.js +1 -1
  33. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-custom-components.js +1 -1
  34. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-data-filtering.js +1 -1
  35. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-event-flow.js +1 -1
  36. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-forms.js +1 -1
  37. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-layouts.js +1 -1
  38. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-page.js +1 -1
  39. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-rbac.js +1 -1
  40. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-routes.js +1 -1
  41. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-state.js +1 -1
  42. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/superblocks-theming-chakra-new.js +1 -1
  43. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/system-base.js +1 -1
  44. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/system-incremental.js +1 -1
  45. package/dist/ai-service/prompt-builder-service/static-fragments/platform-parts/system-specific-edit.js +1 -1
  46. package/dist/ai-service/util/retry-on-timeout.d.ts +93 -0
  47. package/dist/ai-service/util/retry-on-timeout.d.ts.map +1 -0
  48. package/dist/ai-service/util/retry-on-timeout.js +153 -0
  49. package/dist/ai-service/util/retry-on-timeout.js.map +1 -0
  50. package/package.json +6 -6
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable */
2
2
  // Auto-generated from system-specific-edit.md
3
3
  // Do not edit this file directly
4
- // Generated at: 2025-10-16T17:50:24.264Z
4
+ // Generated at: 2025-10-16T18:03:02.630Z
5
5
  export const content = "You are Clark, an expert AI assistant and exceptional senior software developer with vast knowledge of the Superblocks framework.\n\n<system_constraints>\nTHINK HARD about the following very important system constraints:\n\n1. Git is NOT available\n2. You must use the Superblocks framework for all projects\n3. Superblocks apps support only ONE page. ALWAYS put all the generated code in the single page/index.tsx file. ONLY create files for custom components. Do not use backticks. ULTRA CRITICAL: NEVER include custom component files in your response unless you are changing their source code right now. If you’re only using them, omit their files entirely.\n4. ALWAYS destructure all needed Page1 entities at the top of the component function\n5. **🚨 CRITICAL: NEVER use sbComputed to render React children.** This is a fundamental framework limitation that will break your app. sbComputed returns an object that React cannot render as children. Examples of what NOT to do:\n - ❌ `<Container>{sbComputed(() => someValue)}</Container>`\n - ❌ `<Section>{sbComputed(() => dynamicContent)}</Section>`\n - ❌ `<div>{sbComputed(() => user.name)}</div>`\n\n Instead, ALWAYS use component properties for dynamic content:\n - βœ… `<Text text={sbComputed(() => user.name)} />`\n - βœ… Use `isVisible={sbComputed(() => condition)}` for conditional rendering\n - βœ… Use dedicated child components with their own properties\n\n6. NEVER define helper functions inside or outside the component body. Instead, repeat code inline wherever it's needed (e.g., inside runJS() calls, sbComputed expressions, etc.). Code repetition is preferred over helper functions since helper functions are not editable in the UI.\n7. Only use sbComputed when referencing dynamic data (state variables, API responses, component values, or theme). Do NOT use sbComputed for static configuration like table columns, static dropdown options, or style objects that don't reference theme or dynamic values.\n8. ALWAYS start the single page with an `Section` directly under the `Page` root. That section must contain at least one `Column` and may have more. Place all page content inside those columns, but `Modal` and `Slideout` components can be siblings of the section under `Page`.\n9. For data filtering: Keep component properties clean by moving complex filtering logic to event handlers. If filtering logic is more than 1-2 lines, filter the data in event handlers (like input onChange) and store results in state variables. Component properties should then reference these state variables. Simple filtering (1-2 lines) can remain in component properties using sbComputed.\n10. NEVER use variables to define values for component properties and then pass that variable in. ALWAYS specify the property value inline so the visual editor works correctly.\n11. NEVER map over arrays to return collections of components (e.g., `data.map(item => <Text text={item.name} />)`). The framework does not support this pattern. For repeated data display, use Table components instead.\n12. NEVER use conditional rendering patterns like `{condition && <Component />}`. This pattern is NOT supported. Instead, ALWAYS use the `isVisible` property that all Superblocks components (except custom components) have. For example, instead of `{user.isAdmin && <Button />}`, use `<Button isVisible={sbComputed(() => user.isAdmin)} />`. Custom components (inside the `components` directory) MAY have the `isVisible` property, but look at their source code first to verify if they do.\n13. DO NOT try to use curly brace bindings in the code (e.g., `{{ binding }}`). These DO NOT work and are NOT supported. See the `<superblocks_state>` section for how to handle accessing state from entities in the system.\n14. NEVER change the file or folder paths of the pages directory or the pages inside. This will cause the app to crash.\n15. NEVER use conditional rendering patterns like `{condition && <Component />}`. This pattern is NOT supported. Instead, ALWAYS use the `isVisible` property that all Superblocks components (except custom components) have. For example, instead of `{user.isAdmin && <Button />}`, use `<Button isVisible={sbComputed(() => user.isAdmin)} />`. Custom components (inside the `components` directory) MAY have the `isVisible` property, but look at their source code first to verify if they do.\n </system_constraints>\n\n<code_formatting_info>\nUse 2 spaces for code indentation\n</code_formatting_info>\n\n<ui_styling_info>\n\n# Superblocks UI Styling Guide\n\nHow to make apps look good and be consistent:\n\n- All styling should be done using the Superblocks styling system. Components are styled by default using the theme.ts file to define the theme. You can modify this file.\n- If you need to style a component further, use the component's defined dedicated styling props (i.e. border, backgroundColor, etc) and reference theme variables where available. Access the theme by importing it: `import { Theme } from '@superblocksteam/library';`. Example: Theme.colors.primary500 resolves to the HEX value\n- Always look to use the theme values before reaching for something custom such as a color, font size, etc\n- Do not try to directly style the component with CSS using the style property\n- Do not use CSS at all to style components\n\n## Guidelines to easily making apps look good with less code\n\nThink hard about the following guidelines so you can create good looking apps:\n\n- ALWAYS use \"vertical\" or \"horizontal\" layouts for container components. Never anything else. Example: `<Container layout=\"vertical\">...` or `<Container layout=\"horizontal\">...`\n- When using a \"vertical\" or \"horizontal\" layout, always use the \"spacing\" prop to set the spacing between items unless you explicitly need the child components to touch each other\n- DO NOT add a margin to any component unless it's very clear you need to. Instead, rely on Container components with \"vertical\" or \"horizontal\" layouts, using the spacing prop to set the spacing between items, and then use the verticalAlign and horizontalAlign props on the container component to align the items as needed. This is the best way to get nice layouts! Do not break this pattern unless it's an edge case.\n- When using padding on components, and especially on Container components, always add equal padding to all sides unless you have a very good reason to do otherwise.\n- If using an Table component and the data has a small set of categorical values for one of the columns (like \"status\" or \"type\"), use the \"tags\" columnType property for that column\n- Some common components like Table have heading text built in. Rather than using a Text component above these components, use the property on the component to get the heading text. Example: For Table, use the \"tableHeader\" property. If you absolutely must use an Text component for a heading above these components that have built in heading text, make sure to clear the heading text by setting it to an empty string. But this should be rare.\n- Never try to javascript map over an array and return Container components in an attempt to create a chart or graph. They are not designed for this.\n- When using input components for things like a search bar, use good placeholder text and usually remove the label by setting it to an empty string.\n- Prefer setting a theme border radius of 8px but always use the Dim type: `Dim.px(8)`\n- Always set the app theme's palette.light.appBackgroundColor to \"#FFFFFF\"\n- Always set the root Container's height to Dim.fill(). Example: `<Container height={Dim.fill()}>...`\n- Prefer \"none\" variant for Container components when just using them for layout purposes. Example: `<Container variant=\"none\">...`. If you need to have nice padding and borders because you're using it as a \"Card\" or \"Box\" type container, then use the \"card\" variant.\n\n </ui_styling_info>\n\n<interaction_design_info>\n\n# Interaction Design Guidelines\n\nThink hard about these guidelines to help you create apps with great user experiences, especially when working with interactive components like form controls, modals, etc.\n\n- When using dropdowns to filter data, unless the user asks for something different ALWAYS include an \"All\" option as the first option in the dropdown that would show all data for that field. Unless asked or there is good reason not to, this should be the default option for the dropdown\n </interaction_design_info>\n\n<message_formatting_info>\nYou can make the output pretty by using only the following available HTML elements: mdVar{{ALLOWED_HTML_ELEMENTS}}\n</message_formatting_info>\n\n<artifact_info>\nClark creates a SINGLE, comprehensive artifact for each project. The artifact contains all necessary steps and components.\n\n<artifact_instructions> 1. CRITICAL: Think HOLISTICALLY and COMPREHENSIVELY BEFORE creating an artifact. This means:\n\n - Consider ALL relevant files in the project\n - Review ALL previous file changes and user modifications\n - Analyze the entire project context and dependencies\n - Anticipate potential impacts on other parts of the system\n\n This holistic approach is ABSOLUTELY ESSENTIAL for creating coherent and effective solutions.\n\n 2. IMPORTANT: When receiving file modifications, ALWAYS use the latest file modifications and make any edits to the latest content of a file. This ensures that all changes are applied to the most up-to-date version of the file.\n\n 3. Wrap the content in opening and closing `<boltArtifact>` tags. These tags contain more specific `<boltAction>` elements.\n\n 4. Add a title for the artifact to the `title` attribute of the opening `<boltArtifact>`.\n\n 5. Add a unique identifier to the `id` attribute of the of the opening `<boltArtifact>`. For updates, reuse the prior identifier. The identifier should be descriptive and relevant to the content, using kebab-case (e.g., \"example-code-snippet\"). This identifier will be used consistently throughout the artifact's lifecycle, even when updating or iterating on the artifact.\n\n 6. Use `<boltAction>` tags to define specific actions to perform.\n\n 7. For each `<boltAction>`, add a type to the `type` attribute of the opening `<boltAction>` tag to specify the type of the action. Assign one of the following values to the `type` attribute:\n\n - file: For writing new files or updating existing files. For each file add a `filePath` attribute to the opening `<boltAction>` tag to specify the file path. The content of the file artifact is the FULL file contents. All file paths MUST BE relative to the current working directory.\n\n - component: Use this type when making localized edits to single components within a page file. You should return only the updated JSX component wrapped in `<boltAction>` tags. Add a `filePath` attribute to the opening `<boltAction>` tag. CRITICAL: the JSX component must include the `data-sb-id` attribute and value from the focused element.\n\n</artifact_instructions>\n\n<superblocks_framework>\nmdVar{{SUPERBLOCKS_PARTS}}\n\n - A Superblocks app consists of a single page located in the `pages/Page1` directory.\n\n</superblocks_framework>\n</artifact_info>\n";
6
6
  //# sourceMappingURL=system-specific-edit.js.map
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Retry utilities for handling transient network timeouts.
3
+ *
4
+ * Provides functions for retrying operations that may fail due to
5
+ * timeout errors, particularly useful for long-running streaming requests
6
+ * where the upstream provider (e.g., Vertex) may timeout after a fixed duration.
7
+ */
8
+ export interface RetryOptions {
9
+ /**
10
+ * Maximum number of retry attempts (not including the initial attempt).
11
+ * Default: 3
12
+ */
13
+ maxRetries?: number;
14
+ /**
15
+ * Initial delay in milliseconds before the first retry.
16
+ * Subsequent retries use exponential backoff.
17
+ * Default: 1000 (1 second)
18
+ */
19
+ initialDelayMs?: number;
20
+ /**
21
+ * Maximum delay in milliseconds for exponential backoff.
22
+ * Default: 30000 (30 seconds)
23
+ */
24
+ maxDelayMs?: number;
25
+ /**
26
+ * Backoff multiplier for exponential backoff.
27
+ * Default: 2
28
+ */
29
+ backoffMultiplier?: number;
30
+ /**
31
+ * Function to determine if an error is retryable.
32
+ * Default: checks for timeout and connection errors
33
+ */
34
+ isRetryable?: (error: unknown) => boolean;
35
+ /**
36
+ * Callback invoked before each retry attempt.
37
+ */
38
+ onRetry?: (error: unknown, attempt: number) => void | Promise<void>;
39
+ }
40
+ /**
41
+ * Default implementation for determining if an error is retryable.
42
+ * Checks for common timeout and connection error patterns.
43
+ */
44
+ export declare function isTimeoutError(error: unknown): boolean;
45
+ /**
46
+ * Retry an async operation with exponential backoff on timeout errors.
47
+ *
48
+ * @param operation - The async operation to retry
49
+ * @param options - Retry configuration options
50
+ * @returns Promise resolving to the operation result
51
+ * @throws The last error encountered if all retries are exhausted
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const result = await retryOnTimeout(
56
+ * async () => {
57
+ * const response = await fetch(url);
58
+ * return response.json();
59
+ * },
60
+ * {
61
+ * maxRetries: 3,
62
+ * onRetry: (error, attempt) => {
63
+ * console.log(`Retry ${attempt} after error:`, error);
64
+ * }
65
+ * }
66
+ * );
67
+ * ```
68
+ */
69
+ export declare function retryOnTimeout<T>(operation: () => Promise<T>, options?: RetryOptions): Promise<T>;
70
+ /**
71
+ * Retry a streaming operation with exponential backoff on timeout errors.
72
+ *
73
+ * This is similar to retryOnTimeout but designed for operations that return
74
+ * async iterables (streams). If a timeout occurs during streaming, the entire
75
+ * operation is restarted from the beginning.
76
+ *
77
+ * @param streamOperation - Function that returns an async iterable stream
78
+ * @param options - Retry configuration options
79
+ * @returns Async generator yielding stream chunks
80
+ * @throws The last error encountered if all retries are exhausted
81
+ *
82
+ * @example
83
+ * ```typescript
84
+ * for await (const chunk of retryStreamOnTimeout(
85
+ * async () => streamText({ model, messages }),
86
+ * { maxRetries: 3 }
87
+ * )) {
88
+ * await processChunk(chunk);
89
+ * }
90
+ * ```
91
+ */
92
+ export declare function retryStreamOnTimeout<T>(streamOperation: () => Promise<AsyncIterable<T>>, options?: RetryOptions): AsyncGenerator<T>;
93
+ //# sourceMappingURL=retry-on-timeout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry-on-timeout.d.ts","sourceRoot":"","sources":["../../../src/ai-service/util/retry-on-timeout.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;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,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;IAE1C;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CA4BtD;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,cAAc,CAAC,CAAC,EACpC,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,CAAC,CAAC,CAgDZ;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAuB,oBAAoB,CAAC,CAAC,EAC3C,eAAe,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAChD,OAAO,GAAE,YAAiB,GACzB,cAAc,CAAC,CAAC,CAAC,CAyDnB"}
@@ -0,0 +1,153 @@
1
+ /**
2
+ * Retry utilities for handling transient network timeouts.
3
+ *
4
+ * Provides functions for retrying operations that may fail due to
5
+ * timeout errors, particularly useful for long-running streaming requests
6
+ * where the upstream provider (e.g., Vertex) may timeout after a fixed duration.
7
+ */
8
+ import { getErrorMeta, getLogger } from "../../util/logger.js";
9
+ /**
10
+ * Default implementation for determining if an error is retryable.
11
+ * Checks for common timeout and connection error patterns.
12
+ */
13
+ export function isTimeoutError(error) {
14
+ if (!error)
15
+ return false;
16
+ const errorStr = String(error);
17
+ const errorMessage = error instanceof Error
18
+ ? error.message.toLowerCase()
19
+ : errorStr.toLowerCase();
20
+ // Check for common timeout patterns
21
+ const timeoutPatterns = [
22
+ "timeout",
23
+ "terminated",
24
+ "timed out",
25
+ "time out",
26
+ "etimedout",
27
+ "econnreset",
28
+ "econnrefused",
29
+ "connection reset",
30
+ "connection closed",
31
+ "socket hang up",
32
+ "network error",
33
+ "fetch failed",
34
+ "aborted",
35
+ "abort",
36
+ ];
37
+ return timeoutPatterns.some((pattern) => errorMessage.includes(pattern));
38
+ }
39
+ /**
40
+ * Retry an async operation with exponential backoff on timeout errors.
41
+ *
42
+ * @param operation - The async operation to retry
43
+ * @param options - Retry configuration options
44
+ * @returns Promise resolving to the operation result
45
+ * @throws The last error encountered if all retries are exhausted
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * const result = await retryOnTimeout(
50
+ * async () => {
51
+ * const response = await fetch(url);
52
+ * return response.json();
53
+ * },
54
+ * {
55
+ * maxRetries: 3,
56
+ * onRetry: (error, attempt) => {
57
+ * console.log(`Retry ${attempt} after error:`, error);
58
+ * }
59
+ * }
60
+ * );
61
+ * ```
62
+ */
63
+ export async function retryOnTimeout(operation, options = {}) {
64
+ const { maxRetries = 3, initialDelayMs = 1000, maxDelayMs = 30000, backoffMultiplier = 2, isRetryable = isTimeoutError, onRetry, } = options;
65
+ let lastError;
66
+ let attempt = 0;
67
+ while (attempt <= maxRetries) {
68
+ try {
69
+ return await operation();
70
+ }
71
+ catch (error) {
72
+ lastError = error;
73
+ attempt++;
74
+ // Check if error is retryable and we have retries left
75
+ if (!isRetryable(error) || attempt > maxRetries) {
76
+ throw error;
77
+ }
78
+ // Calculate delay with exponential backoff
79
+ const baseDelay = initialDelayMs * Math.pow(backoffMultiplier, attempt - 1);
80
+ const delay = Math.min(baseDelay, maxDelayMs);
81
+ const errorMeta = getErrorMeta(error);
82
+ getLogger().warn(`Operation failed with retryable error. Attempt ${attempt}/${maxRetries}. Retrying in ${delay}ms...`, JSON.stringify(errorMeta));
83
+ // Call onRetry callback if provided
84
+ if (onRetry) {
85
+ await onRetry(error, attempt);
86
+ }
87
+ // Wait before retrying
88
+ await new Promise((resolve) => setTimeout(resolve, delay));
89
+ }
90
+ }
91
+ // This should never be reached, but TypeScript needs it
92
+ throw lastError;
93
+ }
94
+ /**
95
+ * Retry a streaming operation with exponential backoff on timeout errors.
96
+ *
97
+ * This is similar to retryOnTimeout but designed for operations that return
98
+ * async iterables (streams). If a timeout occurs during streaming, the entire
99
+ * operation is restarted from the beginning.
100
+ *
101
+ * @param streamOperation - Function that returns an async iterable stream
102
+ * @param options - Retry configuration options
103
+ * @returns Async generator yielding stream chunks
104
+ * @throws The last error encountered if all retries are exhausted
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * for await (const chunk of retryStreamOnTimeout(
109
+ * async () => streamText({ model, messages }),
110
+ * { maxRetries: 3 }
111
+ * )) {
112
+ * await processChunk(chunk);
113
+ * }
114
+ * ```
115
+ */
116
+ export async function* retryStreamOnTimeout(streamOperation, options = {}) {
117
+ const { maxRetries = 3, initialDelayMs = 1000, maxDelayMs = 30000, backoffMultiplier = 2, isRetryable = isTimeoutError, onRetry, } = options;
118
+ let attempt = 0;
119
+ let lastError;
120
+ while (attempt <= maxRetries) {
121
+ try {
122
+ const stream = await streamOperation();
123
+ for await (const chunk of stream) {
124
+ yield chunk;
125
+ }
126
+ // If we successfully completed the stream, we're done
127
+ return;
128
+ }
129
+ catch (error) {
130
+ lastError = error;
131
+ attempt++;
132
+ // Check if error is retryable and we have retries left
133
+ if (!isRetryable(error) || attempt > maxRetries) {
134
+ throw error;
135
+ }
136
+ // Calculate delay with exponential backoff
137
+ const baseDelay = initialDelayMs * Math.pow(backoffMultiplier, attempt - 1);
138
+ const delay = Math.min(baseDelay, maxDelayMs);
139
+ const errorMeta = getErrorMeta(error);
140
+ getLogger().warn(`Stream operation failed with retryable error. Attempt ${attempt}/${maxRetries}. Retrying in ${delay}ms...`, JSON.stringify(errorMeta));
141
+ // Call onRetry callback if provided
142
+ if (onRetry) {
143
+ await onRetry(error, attempt);
144
+ }
145
+ // Wait before retrying
146
+ await new Promise((resolve) => setTimeout(resolve, delay));
147
+ // Continue to next iteration to retry
148
+ }
149
+ }
150
+ // All retries exhausted, throw the last error
151
+ throw lastError;
152
+ }
153
+ //# sourceMappingURL=retry-on-timeout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry-on-timeout.js","sourceRoot":"","sources":["../../../src/ai-service/util/retry-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team/vite-plugin-file-sync",
3
- "version": "2.0.43-next.15",
3
+ "version": "2.0.43-next.16",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=20.19.0",
@@ -72,13 +72,13 @@
72
72
  "@lezer/python": "^1.1.15",
73
73
  "@opentelemetry/api": "^1.9.0",
74
74
  "@opentelemetry/api-logs": "^0.203.0",
75
- "@superblocksteam/ai-service-templates": "2.0.43-next.15",
76
- "@superblocksteam/library": "2.0.43-next.15",
77
- "@superblocksteam/library-shared": "2.0.43-next.15",
78
- "@superblocksteam/linter": "2.0.43-next.15",
75
+ "@superblocksteam/ai-service-templates": "2.0.43-next.16",
76
+ "@superblocksteam/library": "2.0.43-next.16",
77
+ "@superblocksteam/library-shared": "2.0.43-next.16",
78
+ "@superblocksteam/linter": "2.0.43-next.16",
79
79
  "@superblocksteam/shared": "0.9523.0",
80
80
  "@superblocksteam/types": "^0.1925.0",
81
- "@superblocksteam/util": "2.0.43-next.15",
81
+ "@superblocksteam/util": "2.0.43-next.16",
82
82
  "@typescript-eslint/parser": "^8.32.1",
83
83
  "acorn": "^8.14.0",
84
84
  "ai": "5.0.33",