prompsit-cli 26.225.1206 → 26.227.2006
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/README.md +10 -4
- package/dist/api/auth-session.d.ts +11 -11
- package/dist/api/auth-session.d.ts.map +1 -1
- package/dist/api/auth-session.js +21 -17
- package/dist/api/auth-session.js.map +1 -1
- package/dist/api/client.d.ts +4 -4
- package/dist/api/client.d.ts.map +1 -1
- package/dist/api/client.js +8 -8
- package/dist/api/client.js.map +1 -1
- package/dist/api/curl.d.ts +30 -0
- package/dist/api/curl.d.ts.map +1 -0
- package/dist/api/curl.js +115 -0
- package/dist/api/curl.js.map +1 -0
- package/dist/api/errors.d.ts +2 -3
- package/dist/api/errors.d.ts.map +1 -1
- package/dist/api/errors.js +4 -2
- package/dist/api/errors.js.map +1 -1
- package/dist/api/http-utils.d.ts +5 -0
- package/dist/api/http-utils.d.ts.map +1 -0
- package/dist/api/http-utils.js +19 -0
- package/dist/api/http-utils.js.map +1 -0
- package/dist/api/models.d.ts +135 -89
- package/dist/api/models.d.ts.map +1 -1
- package/dist/api/models.js +62 -72
- package/dist/api/models.js.map +1 -1
- package/dist/api/resources/data.d.ts +3 -5
- package/dist/api/resources/data.d.ts.map +1 -1
- package/dist/api/resources/data.js +11 -12
- package/dist/api/resources/data.js.map +1 -1
- package/dist/api/resources/discovery.d.ts +26 -0
- package/dist/api/resources/discovery.d.ts.map +1 -0
- package/dist/api/resources/discovery.js +46 -0
- package/dist/api/resources/discovery.js.map +1 -0
- package/dist/api/resources/evaluation.d.ts +9 -12
- package/dist/api/resources/evaluation.d.ts.map +1 -1
- package/dist/api/resources/evaluation.js +45 -20
- package/dist/api/resources/evaluation.js.map +1 -1
- package/dist/api/resources/formats.d.ts +1 -1
- package/dist/api/resources/formats.js +2 -2
- package/dist/api/resources/formats.js.map +1 -1
- package/dist/api/resources/jobs.d.ts +7 -8
- package/dist/api/resources/jobs.d.ts.map +1 -1
- package/dist/api/resources/jobs.js +10 -49
- package/dist/api/resources/jobs.js.map +1 -1
- package/dist/api/resources/languages.d.ts +25 -0
- package/dist/api/resources/languages.d.ts.map +1 -0
- package/dist/api/resources/languages.js +44 -0
- package/dist/api/resources/languages.js.map +1 -0
- package/dist/api/resources/translation.d.ts +8 -16
- package/dist/api/resources/translation.d.ts.map +1 -1
- package/dist/api/resources/translation.js +11 -15
- package/dist/api/resources/translation.js.map +1 -1
- package/dist/api/sse-client.d.ts +10 -16
- package/dist/api/sse-client.d.ts.map +1 -1
- package/dist/api/sse-client.js +158 -197
- package/dist/api/sse-client.js.map +1 -1
- package/dist/api/sse-models.js +1 -1
- package/dist/api/sse-models.js.map +1 -1
- package/dist/api/trace.js +1 -1
- package/dist/api/trace.js.map +1 -1
- package/dist/api/transport.d.ts +28 -1
- package/dist/api/transport.d.ts.map +1 -1
- package/dist/api/transport.js +89 -17
- package/dist/api/transport.js.map +1 -1
- package/dist/cli/arg-order.d.ts +2 -0
- package/dist/cli/arg-order.d.ts.map +1 -1
- package/dist/cli/arg-order.js +2 -0
- package/dist/cli/arg-order.js.map +1 -1
- package/dist/cli/exit-codes.d.ts +0 -2
- package/dist/cli/exit-codes.d.ts.map +1 -1
- package/dist/cli/exit-codes.js +0 -2
- package/dist/cli/exit-codes.js.map +1 -1
- package/dist/cli/exit.d.ts +4 -4
- package/dist/cli/exit.d.ts.map +1 -1
- package/dist/cli/exit.js +4 -4
- package/dist/cli/exit.js.map +1 -1
- package/dist/cli/prompts.d.ts +0 -2
- package/dist/cli/prompts.d.ts.map +1 -1
- package/dist/cli/prompts.js +1 -1
- package/dist/cli/prompts.js.map +1 -1
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +0 -1
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/batch-processor.d.ts +38 -0
- package/dist/commands/batch-processor.d.ts.map +1 -0
- package/dist/commands/batch-processor.js +73 -0
- package/dist/commands/batch-processor.js.map +1 -0
- package/dist/commands/config/api-url.d.ts.map +1 -1
- package/dist/commands/config/api-url.js +4 -1
- package/dist/commands/config/api-url.js.map +1 -1
- package/dist/commands/config/command.d.ts.map +1 -1
- package/dist/commands/config/command.js +3 -2
- package/dist/commands/config/command.js.map +1 -1
- package/dist/commands/config/language.d.ts.map +1 -1
- package/dist/commands/config/language.js.map +1 -1
- package/dist/commands/config/reset.d.ts.map +1 -1
- package/dist/commands/config/reset.js.map +1 -1
- package/dist/commands/config/shared.js +3 -3
- package/dist/commands/config/shared.js.map +1 -1
- package/dist/commands/config/show.d.ts.map +1 -1
- package/dist/commands/config/show.js +0 -13
- package/dist/commands/config/show.js.map +1 -1
- package/dist/commands/data.d.ts.map +1 -1
- package/dist/commands/data.js +241 -68
- package/dist/commands/data.js.map +1 -1
- package/dist/commands/evaluate.d.ts.map +1 -1
- package/dist/commands/evaluate.js +111 -29
- package/dist/commands/evaluate.js.map +1 -1
- package/dist/commands/formats.d.ts +1 -1
- package/dist/commands/formats.d.ts.map +1 -1
- package/dist/commands/formats.js +5 -12
- package/dist/commands/formats.js.map +1 -1
- package/dist/commands/health.d.ts +1 -1
- package/dist/commands/health.d.ts.map +1 -1
- package/dist/commands/health.js +3 -10
- package/dist/commands/health.js.map +1 -1
- package/dist/commands/job-tracking.d.ts +13 -5
- package/dist/commands/job-tracking.d.ts.map +1 -1
- package/dist/commands/job-tracking.js +25 -18
- package/dist/commands/job-tracking.js.map +1 -1
- package/dist/commands/languages.d.ts +12 -0
- package/dist/commands/languages.d.ts.map +1 -0
- package/dist/commands/languages.js +48 -0
- package/dist/commands/languages.js.map +1 -0
- package/dist/commands/mappers.d.ts +15 -3
- package/dist/commands/mappers.d.ts.map +1 -1
- package/dist/commands/mappers.js +38 -18
- package/dist/commands/mappers.js.map +1 -1
- package/dist/commands/progress-animator.d.ts +2 -1
- package/dist/commands/progress-animator.d.ts.map +1 -1
- package/dist/commands/progress-animator.js +4 -2
- package/dist/commands/progress-animator.js.map +1 -1
- package/dist/commands/translate.d.ts.map +1 -1
- package/dist/commands/translate.js +149 -87
- package/dist/commands/translate.js.map +1 -1
- package/dist/config/credentials.d.ts +11 -87
- package/dist/config/credentials.d.ts.map +1 -1
- package/dist/config/credentials.js +28 -87
- package/dist/config/credentials.js.map +1 -1
- package/dist/config/env-parser.d.ts.map +1 -1
- package/dist/config/env-parser.js +3 -2
- package/dist/config/env-parser.js.map +1 -1
- package/dist/config/file-utils.js +1 -1
- package/dist/config/file-utils.js.map +1 -1
- package/dist/config/index.d.ts +4 -7
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +6 -12
- package/dist/config/index.js.map +1 -1
- package/dist/config/schemas.d.ts +4 -33
- package/dist/config/schemas.d.ts.map +1 -1
- package/dist/config/schemas.js +14 -19
- package/dist/config/schemas.js.map +1 -1
- package/dist/config/settings.d.ts +4 -4
- package/dist/config/settings.d.ts.map +1 -1
- package/dist/config/settings.js +16 -21
- package/dist/config/settings.js.map +1 -1
- package/dist/config/toml-io.js +1 -1
- package/dist/config/toml-io.js.map +1 -1
- package/dist/constants.d.ts +10 -9
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +10 -9
- package/dist/constants.js.map +1 -1
- package/dist/errors/catalog.d.ts.map +1 -1
- package/dist/errors/catalog.js +6 -8
- package/dist/errors/catalog.js.map +1 -1
- package/dist/errors/contracts.d.ts.map +1 -1
- package/dist/errors/contracts.js +2 -3
- package/dist/errors/contracts.js.map +1 -1
- package/dist/i18n/cache.d.ts +0 -2
- package/dist/i18n/cache.d.ts.map +1 -1
- package/dist/i18n/cache.js +4 -4
- package/dist/i18n/cache.js.map +1 -1
- package/dist/i18n/catalog.d.ts +34 -37
- package/dist/i18n/catalog.d.ts.map +1 -1
- package/dist/i18n/catalog.js +38 -40
- package/dist/i18n/catalog.js.map +1 -1
- package/dist/i18n/index.d.ts +0 -1
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/index.js +0 -3
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/translator-adapter.js +1 -1
- package/dist/i18n/translator-adapter.js.map +1 -1
- package/dist/i18n/translator.d.ts.map +1 -1
- package/dist/i18n/translator.js +1 -0
- package/dist/i18n/translator.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/logging/console-handler.js +1 -1
- package/dist/logging/console-handler.js.map +1 -1
- package/dist/logging/file-handler.d.ts.map +1 -1
- package/dist/logging/file-handler.js +4 -5
- package/dist/logging/file-handler.js.map +1 -1
- package/dist/logging/index.d.ts +2 -2
- package/dist/logging/index.d.ts.map +1 -1
- package/dist/logging/index.js +1 -1
- package/dist/logging/index.js.map +1 -1
- package/dist/logging/logger.d.ts +18 -22
- package/dist/logging/logger.d.ts.map +1 -1
- package/dist/logging/logger.js +38 -64
- package/dist/logging/logger.js.map +1 -1
- package/dist/logging/loki-handler.js +1 -1
- package/dist/logging/loki-handler.js.map +1 -1
- package/dist/logging/setup.d.ts +4 -3
- package/dist/logging/setup.d.ts.map +1 -1
- package/dist/logging/setup.js +136 -33
- package/dist/logging/setup.js.map +1 -1
- package/dist/output/ansi-utils.d.ts +13 -0
- package/dist/output/ansi-utils.d.ts.map +1 -0
- package/dist/output/ansi-utils.js +37 -0
- package/dist/output/ansi-utils.js.map +1 -0
- package/dist/output/index.d.ts +2 -5
- package/dist/output/index.d.ts.map +1 -1
- package/dist/output/index.js +3 -2
- package/dist/output/index.js.map +1 -1
- package/dist/output/output-events.d.ts +0 -1
- package/dist/output/output-events.d.ts.map +1 -1
- package/dist/output/tables/catalog.d.ts +5 -2
- package/dist/output/tables/catalog.d.ts.map +1 -1
- package/dist/output/tables/catalog.js +65 -9
- package/dist/output/tables/catalog.js.map +1 -1
- package/dist/output/tables/evaluation.d.ts.map +1 -1
- package/dist/output/tables/evaluation.js +3 -0
- package/dist/output/tables/evaluation.js.map +1 -1
- package/dist/output/tables/health-status.d.ts.map +1 -1
- package/dist/output/tables/health-status.js +11 -7
- package/dist/output/tables/health-status.js.map +1 -1
- package/dist/output/tables/index.d.ts +3 -3
- package/dist/output/tables/index.d.ts.map +1 -1
- package/dist/output/tables/index.js +2 -2
- package/dist/output/tables/index.js.map +1 -1
- package/dist/output/tables/render.d.ts.map +1 -1
- package/dist/output/tables/render.js +2 -10
- package/dist/output/tables/render.js.map +1 -1
- package/dist/output/terminal.d.ts +1 -5
- package/dist/output/terminal.d.ts.map +1 -1
- package/dist/output/terminal.js +25 -24
- package/dist/output/terminal.js.map +1 -1
- package/dist/output/view-models.d.ts +28 -2
- package/dist/output/view-models.d.ts.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +21 -29
- package/dist/program.js.map +1 -1
- package/dist/repl/controller.d.ts.map +1 -1
- package/dist/repl/controller.js +82 -47
- package/dist/repl/controller.js.map +1 -1
- package/dist/repl/core/output-bridge.d.ts.map +1 -1
- package/dist/repl/core/output-bridge.js +6 -4
- package/dist/repl/core/output-bridge.js.map +1 -1
- package/dist/repl/core/progress-types.d.ts +1 -1
- package/dist/repl/core/progress-types.d.ts.map +1 -1
- package/dist/repl/core/progress-types.js +1 -1
- package/dist/repl/core/progress-types.js.map +1 -1
- package/dist/repl/examples.d.ts +5 -7
- package/dist/repl/examples.d.ts.map +1 -1
- package/dist/repl/examples.js +27 -14
- package/dist/repl/examples.js.map +1 -1
- package/dist/repl/executor.d.ts +2 -4
- package/dist/repl/executor.d.ts.map +1 -1
- package/dist/repl/executor.js +69 -58
- package/dist/repl/executor.js.map +1 -1
- package/dist/repl/help.d.ts +10 -3
- package/dist/repl/help.d.ts.map +1 -1
- package/dist/repl/help.js +31 -4
- package/dist/repl/help.js.map +1 -1
- package/dist/repl/history/command-history.js +5 -5
- package/dist/repl/history/command-history.js.map +1 -1
- package/dist/repl/history/output-render.d.ts +1 -3
- package/dist/repl/history/output-render.d.ts.map +1 -1
- package/dist/repl/history/output-render.js +4 -6
- package/dist/repl/history/output-render.js.map +1 -1
- package/dist/repl/history/output-store.d.ts.map +1 -1
- package/dist/repl/history/output-store.js +6 -3
- package/dist/repl/history/output-store.js.map +1 -1
- package/dist/repl/input/autocomplete-provider.d.ts.map +1 -1
- package/dist/repl/input/autocomplete-provider.js +1 -2
- package/dist/repl/input/autocomplete-provider.js.map +1 -1
- package/dist/repl/input/completer.d.ts +0 -2
- package/dist/repl/input/completer.d.ts.map +1 -1
- package/dist/repl/input/completer.js +9 -7
- package/dist/repl/input/completer.js.map +1 -1
- package/dist/repl/input/ghost-text.d.ts +1 -1
- package/dist/repl/input/ghost-text.d.ts.map +1 -1
- package/dist/repl/input/ghost-text.js +1 -1
- package/dist/repl/input/ghost-text.js.map +1 -1
- package/dist/repl/input/input-handler.d.ts.map +1 -1
- package/dist/repl/input/input-handler.js +21 -15
- package/dist/repl/input/input-handler.js.map +1 -1
- package/dist/repl/input/keybindings.d.ts +0 -5
- package/dist/repl/input/keybindings.d.ts.map +1 -1
- package/dist/repl/input/keybindings.js +0 -65
- package/dist/repl/input/keybindings.js.map +1 -1
- package/dist/repl/loop.d.ts +1 -2
- package/dist/repl/loop.d.ts.map +1 -1
- package/dist/repl/loop.js +14 -14
- package/dist/repl/loop.js.map +1 -1
- package/dist/repl/registry.d.ts +28 -20
- package/dist/repl/registry.d.ts.map +1 -1
- package/dist/repl/registry.js +229 -171
- package/dist/repl/registry.js.map +1 -1
- package/dist/repl/service.d.ts +1 -10
- package/dist/repl/service.d.ts.map +1 -1
- package/dist/repl/service.js +15 -26
- package/dist/repl/service.js.map +1 -1
- package/dist/repl/ui/components/curl-panel.js +4 -4
- package/dist/repl/ui/components/curl-panel.js.map +1 -1
- package/dist/repl/ui/components/ghost-text-editor.d.ts +4 -0
- package/dist/repl/ui/components/ghost-text-editor.d.ts.map +1 -1
- package/dist/repl/ui/components/ghost-text-editor.js +17 -6
- package/dist/repl/ui/components/ghost-text-editor.js.map +1 -1
- package/dist/repl/ui/components/history-component.d.ts.map +1 -1
- package/dist/repl/ui/components/history-component.js +7 -69
- package/dist/repl/ui/components/history-component.js.map +1 -1
- package/dist/repl/ui/components/progress-bar.js.map +1 -1
- package/dist/repl/ui/components/status-bar-line.js +1 -1
- package/dist/repl/ui/components/status-bar-line.js.map +1 -1
- package/dist/repl/ui/data.js +3 -3
- package/dist/repl/ui/data.js.map +1 -1
- package/dist/repl/ui/hint-state.d.ts +0 -1
- package/dist/repl/ui/hint-state.d.ts.map +1 -1
- package/dist/repl/ui/hint-state.js +1 -1
- package/dist/repl/ui/hint-state.js.map +1 -1
- package/dist/repl/ui/selection-utils.d.ts +28 -0
- package/dist/repl/ui/selection-utils.d.ts.map +1 -0
- package/dist/repl/ui/selection-utils.js +70 -0
- package/dist/repl/ui/selection-utils.js.map +1 -0
- package/dist/repl/ui/status-bar.d.ts +1 -4
- package/dist/repl/ui/status-bar.d.ts.map +1 -1
- package/dist/repl/ui/status-bar.js +6 -33
- package/dist/repl/ui/status-bar.js.map +1 -1
- package/dist/runtime/async-utils.d.ts +16 -0
- package/dist/runtime/async-utils.d.ts.map +1 -0
- package/dist/runtime/async-utils.js +40 -0
- package/dist/runtime/async-utils.js.map +1 -0
- package/dist/runtime/clipboard-win32.d.ts.map +1 -1
- package/dist/runtime/clipboard-win32.js +2 -1
- package/dist/runtime/clipboard-win32.js.map +1 -1
- package/dist/runtime/clipboard.d.ts.map +1 -1
- package/dist/runtime/clipboard.js +6 -2
- package/dist/runtime/clipboard.js.map +1 -1
- package/dist/runtime/external-transport.d.ts.map +1 -1
- package/dist/runtime/external-transport.js +1 -1
- package/dist/runtime/external-transport.js.map +1 -1
- package/dist/runtime/file-args.d.ts +38 -0
- package/dist/runtime/file-args.d.ts.map +1 -0
- package/dist/runtime/file-args.js +133 -0
- package/dist/runtime/file-args.js.map +1 -0
- package/dist/runtime/platform.d.ts +0 -2
- package/dist/runtime/platform.d.ts.map +1 -1
- package/dist/runtime/platform.js +0 -6
- package/dist/runtime/platform.js.map +1 -1
- package/dist/tui/settings-screen.d.ts +1 -13
- package/dist/tui/settings-screen.d.ts.map +1 -1
- package/dist/tui/settings-screen.js +46 -34
- package/dist/tui/settings-screen.js.map +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +3 -2
- package/dist/version.js.map +1 -1
- package/examples/sample.tmx +6 -0
- package/package.json +18 -7
package/dist/api/sse-client.d.ts
CHANGED
|
@@ -3,14 +3,11 @@ import { type SSEEvent } from "./sse-models.ts";
|
|
|
3
3
|
* SSE client with automatic reconnection and token refresh.
|
|
4
4
|
*
|
|
5
5
|
* Features:
|
|
6
|
-
* - Bearer auth via
|
|
6
|
+
* - Bearer auth via custom fetch wrapper
|
|
7
7
|
* - Exponential backoff reconnection (1s, 2s, 4s)
|
|
8
|
-
* - Heartbeat timeout detection (30s)
|
|
8
|
+
* - Heartbeat timeout detection (30s via AbortController)
|
|
9
9
|
* - Last-Event-ID reconnection protocol
|
|
10
10
|
* - Proactive token refresh before connect + reactive refresh on 401
|
|
11
|
-
*
|
|
12
|
-
* Note: Got afterResponse hooks are ignored for Stream API,
|
|
13
|
-
* so token refresh is handled manually at this level.
|
|
14
11
|
*/
|
|
15
12
|
export declare class SSEClient {
|
|
16
13
|
private readonly baseUrl;
|
|
@@ -23,29 +20,26 @@ export declare class SSEClient {
|
|
|
23
20
|
*
|
|
24
21
|
* @param jobId - Job ID to track
|
|
25
22
|
* @param onEvent - Callback for connected/progress events
|
|
23
|
+
* @param signal - External abort signal (e.g. Ctrl+C) for immediate cancellation
|
|
26
24
|
* @returns Terminal event (complete/error/cancelled) or null for polling fallback
|
|
27
25
|
*/
|
|
28
|
-
streamJobEvents(jobId: string, onEvent: (event: SSEEvent) => void): Promise<SSEEvent | null>;
|
|
26
|
+
streamJobEvents(jobId: string, onEvent: (event: SSEEvent) => void, signal?: AbortSignal): Promise<SSEEvent | null>;
|
|
29
27
|
/**
|
|
30
|
-
* Connect to SSE stream and process events.
|
|
28
|
+
* Connect to SSE stream once and process events.
|
|
31
29
|
*
|
|
32
|
-
* Uses
|
|
33
|
-
*
|
|
30
|
+
* Uses AbortController for heartbeat timeout: if no message arrives within
|
|
31
|
+
* SSE_HEARTBEAT_TIMEOUT seconds, the connection is aborted and the method
|
|
32
|
+
* resolves with undefined (triggering retry in the outer loop).
|
|
34
33
|
*
|
|
34
|
+
* @param signal - External abort signal for immediate cancellation
|
|
35
35
|
* @returns SSEEvent for terminal events, null for fallback, undefined for retry
|
|
36
36
|
*/
|
|
37
|
-
private
|
|
37
|
+
private connectOnce;
|
|
38
38
|
/**
|
|
39
39
|
* Dispatch a parsed SSE event to callback or return terminal event.
|
|
40
40
|
*
|
|
41
41
|
* @returns SSEEvent for terminal, null for fallback, undefined to continue
|
|
42
42
|
*/
|
|
43
43
|
private dispatchEvent;
|
|
44
|
-
/**
|
|
45
|
-
* Classify error to determine retry strategy.
|
|
46
|
-
*
|
|
47
|
-
* @returns "retry" to retry with backoff, "fallback" to return null
|
|
48
|
-
*/
|
|
49
|
-
private classifyError;
|
|
50
44
|
}
|
|
51
45
|
//# sourceMappingURL=sse-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse-client.d.ts","sourceRoot":"","sources":["../../src/api/sse-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sse-client.d.ts","sourceRoot":"","sources":["../../src/api/sse-client.ts"],"names":[],"mappings":"AAgCA,OAAO,EAAE,KAAK,QAAQ,EAAiB,MAAM,iBAAiB,CAAC;AAkB/D;;;;;;;;;GASG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAyB;IACpD,OAAO,CAAC,WAAW,CAAM;IACzB,OAAO,CAAC,iBAAiB,CAAK;gBAElB,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC;IAK/D;;;;;;;OAOG;IACG,eAAe,CACnB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,EAClC,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAmC3B;;;;;;;;;OASG;IACH,OAAO,CAAC,WAAW;IAyJnB;;;;OAIG;IACH,OAAO,CAAC,aAAa;CA8CtB"}
|
package/dist/api/sse-client.js
CHANGED
|
@@ -1,74 +1,18 @@
|
|
|
1
1
|
// See API-481: SSE Client with Reconnection
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// Manual text/event-stream parser per WHATWG SSE spec.
|
|
2
|
+
// Uses eventsource-client (MIT, async iterators, custom fetch) for SSE parsing.
|
|
3
|
+
// Custom fetch wrapper handles Bearer auth, 401 refresh, 404/503 fallback.
|
|
5
4
|
//
|
|
6
5
|
// Reconnection: exponential backoff (1s, 2s, 4s) + jitter, max 3 retries.
|
|
7
|
-
// Heartbeat timeout: 30s
|
|
6
|
+
// Heartbeat timeout: 30s AbortController detects silent disconnections.
|
|
8
7
|
// Last-Event-ID: sent on reconnect for server-side event replay.
|
|
9
|
-
import
|
|
8
|
+
import { createEventSource, } from "eventsource-client";
|
|
10
9
|
import { getAccessToken, isTokenExpired } from "../config/credentials.js";
|
|
11
10
|
import { getLogger } from "../logging/index.js";
|
|
12
11
|
import { getSettings } from "../config/settings.js";
|
|
13
|
-
import {
|
|
12
|
+
import { sleep } from "../runtime/async-utils.js";
|
|
13
|
+
import { BEARER_PREFIX, CONTENT_TYPE_SSE, Endpoint, HEADER_ACCEPT, HEADER_AUTHORIZATION, HttpStatus, SSE_BACKOFF_JITTER_MS, SSE_BACKOFF_MAX_MS, SSE_HEARTBEAT_TIMEOUT, SSE_RETRY_ATTEMPTS, SSEEventType, } from "../constants.js";
|
|
14
14
|
import { parseSSEEvent } from "./sse-models.js";
|
|
15
15
|
const log = getLogger(import.meta.url);
|
|
16
|
-
/**
|
|
17
|
-
* Parse a single SSE field line per WHATWG spec.
|
|
18
|
-
* Lines are "field: value" or "field:value" (space after colon is optional).
|
|
19
|
-
*
|
|
20
|
-
* @returns true if the line was a blank line (event dispatch trigger)
|
|
21
|
-
*/
|
|
22
|
-
function parseSSELine(line, fields) {
|
|
23
|
-
// Blank line = dispatch event
|
|
24
|
-
if (line === "")
|
|
25
|
-
return true;
|
|
26
|
-
// Comment lines (start with colon)
|
|
27
|
-
if (line.startsWith(":"))
|
|
28
|
-
return false;
|
|
29
|
-
const colonIdx = line.indexOf(":");
|
|
30
|
-
let field;
|
|
31
|
-
let value;
|
|
32
|
-
if (colonIdx === -1) {
|
|
33
|
-
// No colon: field name is entire line, value is empty
|
|
34
|
-
field = line;
|
|
35
|
-
value = "";
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
field = line.slice(0, colonIdx);
|
|
39
|
-
// Skip single leading space after colon (per spec)
|
|
40
|
-
value = line[colonIdx + 1] === " " ? line.slice(colonIdx + 2) : line.slice(colonIdx + 1);
|
|
41
|
-
}
|
|
42
|
-
switch (field) {
|
|
43
|
-
case "event":
|
|
44
|
-
fields.event = value;
|
|
45
|
-
break;
|
|
46
|
-
case "data":
|
|
47
|
-
fields.data.push(value);
|
|
48
|
-
break;
|
|
49
|
-
case "id":
|
|
50
|
-
// Spec: id field must not contain null character
|
|
51
|
-
if (!value.includes("\0")) {
|
|
52
|
-
fields.id = value;
|
|
53
|
-
}
|
|
54
|
-
break;
|
|
55
|
-
case "retry": {
|
|
56
|
-
const parsed = parseInt(value, 10);
|
|
57
|
-
if (!isNaN(parsed) && parsed >= 0) {
|
|
58
|
-
fields.retry = parsed;
|
|
59
|
-
}
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
// Unknown fields: ignore (per spec)
|
|
63
|
-
}
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Create fresh SSE fields accumulator.
|
|
68
|
-
*/
|
|
69
|
-
function createEmptyFields() {
|
|
70
|
-
return { event: "", data: [], id: "", retry: undefined };
|
|
71
|
-
}
|
|
72
16
|
// --- Backoff ---
|
|
73
17
|
/**
|
|
74
18
|
* Calculate backoff delay with jitter.
|
|
@@ -84,14 +28,11 @@ function backoffDelay(attempt) {
|
|
|
84
28
|
* SSE client with automatic reconnection and token refresh.
|
|
85
29
|
*
|
|
86
30
|
* Features:
|
|
87
|
-
* - Bearer auth via
|
|
31
|
+
* - Bearer auth via custom fetch wrapper
|
|
88
32
|
* - Exponential backoff reconnection (1s, 2s, 4s)
|
|
89
|
-
* - Heartbeat timeout detection (30s)
|
|
33
|
+
* - Heartbeat timeout detection (30s via AbortController)
|
|
90
34
|
* - Last-Event-ID reconnection protocol
|
|
91
35
|
* - Proactive token refresh before connect + reactive refresh on 401
|
|
92
|
-
*
|
|
93
|
-
* Note: Got afterResponse hooks are ignored for Stream API,
|
|
94
|
-
* so token refresh is handled manually at this level.
|
|
95
36
|
*/
|
|
96
37
|
export class SSEClient {
|
|
97
38
|
baseUrl;
|
|
@@ -107,33 +48,34 @@ export class SSEClient {
|
|
|
107
48
|
*
|
|
108
49
|
* @param jobId - Job ID to track
|
|
109
50
|
* @param onEvent - Callback for connected/progress events
|
|
51
|
+
* @param signal - External abort signal (e.g. Ctrl+C) for immediate cancellation
|
|
110
52
|
* @returns Terminal event (complete/error/cancelled) or null for polling fallback
|
|
111
53
|
*/
|
|
112
|
-
async streamJobEvents(jobId, onEvent) {
|
|
54
|
+
async streamJobEvents(jobId, onEvent, signal) {
|
|
113
55
|
const url = `${this.baseUrl}${Endpoint.JOB_SSE_EVENTS.replace("{job_id}", jobId)}`;
|
|
114
56
|
for (let attempt = 0; attempt < SSE_RETRY_ATTEMPTS; attempt++) {
|
|
57
|
+
// Fast-path: bail immediately if already aborted
|
|
58
|
+
if (signal?.aborted)
|
|
59
|
+
return null;
|
|
115
60
|
log.debug("SSE connecting", { jobId, attempt: String(attempt) });
|
|
116
61
|
// Apply server reconnection delay if set
|
|
117
62
|
if (this.reconnectionDelay > 0) {
|
|
118
|
-
await sleep(this.reconnectionDelay);
|
|
63
|
+
await sleep(this.reconnectionDelay, signal).catch(() => { });
|
|
119
64
|
this.reconnectionDelay = 0;
|
|
65
|
+
if (signal?.aborted)
|
|
66
|
+
return null;
|
|
120
67
|
}
|
|
121
68
|
try {
|
|
122
|
-
const result = await this.
|
|
69
|
+
const result = await this.connectOnce(url, onEvent, signal);
|
|
123
70
|
if (result !== undefined) {
|
|
124
71
|
return result;
|
|
125
72
|
}
|
|
126
73
|
// undefined = stream ended without terminal event, retry
|
|
127
74
|
}
|
|
128
|
-
catch
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return null;
|
|
133
|
-
}
|
|
134
|
-
// action === "retry": apply backoff before next attempt
|
|
135
|
-
log.debug("SSE error, retrying", { jobId, attempt: String(attempt), error: String(error) });
|
|
136
|
-
await sleep(backoffDelay(attempt));
|
|
75
|
+
catch {
|
|
76
|
+
// All errors are retryable (404/503 fallback handled inside connectOnce via shouldFallback)
|
|
77
|
+
log.debug("SSE error, retrying", { jobId, attempt: String(attempt) });
|
|
78
|
+
await sleep(backoffDelay(attempt), signal).catch(() => { });
|
|
137
79
|
continue;
|
|
138
80
|
}
|
|
139
81
|
}
|
|
@@ -142,95 +84,145 @@ export class SSEClient {
|
|
|
142
84
|
return null;
|
|
143
85
|
}
|
|
144
86
|
/**
|
|
145
|
-
* Connect to SSE stream and process events.
|
|
87
|
+
* Connect to SSE stream once and process events.
|
|
146
88
|
*
|
|
147
|
-
* Uses
|
|
148
|
-
*
|
|
89
|
+
* Uses AbortController for heartbeat timeout: if no message arrives within
|
|
90
|
+
* SSE_HEARTBEAT_TIMEOUT seconds, the connection is aborted and the method
|
|
91
|
+
* resolves with undefined (triggering retry in the outer loop).
|
|
149
92
|
*
|
|
93
|
+
* @param signal - External abort signal for immediate cancellation
|
|
150
94
|
* @returns SSEEvent for terminal events, null for fallback, undefined for retry
|
|
151
95
|
*/
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (isTokenExpired()) {
|
|
155
|
-
await this.tryRefresh();
|
|
156
|
-
}
|
|
157
|
-
const headers = {
|
|
158
|
-
[HEADER_ACCEPT]: CONTENT_TYPE_SSE,
|
|
159
|
-
[HEADER_AUTHORIZATION]: `${BEARER_PREFIX} ${getAccessToken()}`,
|
|
160
|
-
};
|
|
161
|
-
if (this.lastEventId) {
|
|
162
|
-
headers[HEADER_LAST_EVENT_ID] = this.lastEventId;
|
|
163
|
-
}
|
|
164
|
-
const settings = getSettings();
|
|
165
|
-
const stream = got.stream(url, {
|
|
166
|
-
headers,
|
|
167
|
-
timeout: {
|
|
168
|
-
connect: settings.api.connect_timeout * 1000,
|
|
169
|
-
read: SSE_HEARTBEAT_TIMEOUT * 1000,
|
|
170
|
-
send: settings.api.write_timeout * 1000,
|
|
171
|
-
},
|
|
172
|
-
retry: { limit: 0 }, // We handle retries ourselves
|
|
173
|
-
throwHttpErrors: false, // We check status manually
|
|
174
|
-
});
|
|
175
|
-
return new Promise((resolve, reject) => {
|
|
96
|
+
connectOnce(url, onEvent, signal) {
|
|
97
|
+
return new Promise((resolve) => {
|
|
176
98
|
let settled = false;
|
|
177
|
-
let
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
99
|
+
let client = null;
|
|
100
|
+
// Heartbeat: abort if no message within timeout
|
|
101
|
+
const heartbeatMs = SSE_HEARTBEAT_TIMEOUT * 1000;
|
|
102
|
+
let heartbeatTimer = null;
|
|
103
|
+
const resetHeartbeat = () => {
|
|
104
|
+
if (heartbeatTimer)
|
|
105
|
+
clearTimeout(heartbeatTimer);
|
|
106
|
+
heartbeatTimer = setTimeout(() => {
|
|
107
|
+
log.debug("SSE heartbeat timeout");
|
|
108
|
+
settle();
|
|
109
|
+
}, heartbeatMs);
|
|
110
|
+
};
|
|
111
|
+
const settle = (value) => {
|
|
181
112
|
if (settled)
|
|
182
113
|
return;
|
|
183
114
|
settled = true;
|
|
184
|
-
|
|
185
|
-
|
|
115
|
+
if (heartbeatTimer)
|
|
116
|
+
clearTimeout(heartbeatTimer);
|
|
117
|
+
client?.close();
|
|
118
|
+
resolve(value);
|
|
186
119
|
};
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (
|
|
190
|
-
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
if (sc === HttpStatus.UNAUTHORIZED) {
|
|
194
|
-
// Reactive: refresh token and signal retry via undefined
|
|
195
|
-
this.tryRefresh()
|
|
196
|
-
.then((refreshed) => {
|
|
197
|
-
settle(resolve, refreshed ? undefined : null);
|
|
198
|
-
})
|
|
199
|
-
.catch(() => {
|
|
200
|
-
settle(resolve, null);
|
|
201
|
-
});
|
|
120
|
+
// External abort: settle immediately on Ctrl+C
|
|
121
|
+
if (signal) {
|
|
122
|
+
if (signal.aborted) {
|
|
123
|
+
resolve(null);
|
|
202
124
|
return;
|
|
203
125
|
}
|
|
204
|
-
|
|
205
|
-
settle(
|
|
206
|
-
|
|
126
|
+
signal.addEventListener("abort", () => {
|
|
127
|
+
settle(null);
|
|
128
|
+
}, { once: true });
|
|
129
|
+
}
|
|
130
|
+
// Track whether we should fallback (set by custom fetch on 404/503)
|
|
131
|
+
let shouldFallback = false;
|
|
132
|
+
// Custom fetch: Bearer auth, 401 refresh, 404/503 detection
|
|
133
|
+
const sseAuthFetch = async (fetchUrl, init) => {
|
|
134
|
+
// Proactive: refresh expired token before connecting
|
|
135
|
+
if (isTokenExpired()) {
|
|
136
|
+
await this.tryRefresh();
|
|
207
137
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
138
|
+
const settings = getSettings();
|
|
139
|
+
const headers = {
|
|
140
|
+
[HEADER_ACCEPT]: CONTENT_TYPE_SSE,
|
|
141
|
+
[HEADER_AUTHORIZATION]: `${BEARER_PREFIX} ${getAccessToken()}`,
|
|
142
|
+
...init?.headers,
|
|
143
|
+
};
|
|
144
|
+
const controller = new AbortController();
|
|
145
|
+
const connectTimeout = globalThis.setTimeout(() => {
|
|
146
|
+
controller.abort();
|
|
147
|
+
}, settings.api.connect_timeout * 1000);
|
|
148
|
+
// Compose: external signal + connect timeout + library's init.signal
|
|
149
|
+
const signals = [controller.signal];
|
|
150
|
+
if (signal)
|
|
151
|
+
signals.push(signal);
|
|
152
|
+
if (init?.signal)
|
|
153
|
+
signals.push(init.signal);
|
|
154
|
+
const composedSignal = AbortSignal.any(signals);
|
|
155
|
+
try {
|
|
156
|
+
const response = await fetch(fetchUrl, {
|
|
157
|
+
...init,
|
|
158
|
+
headers,
|
|
159
|
+
signal: composedSignal,
|
|
160
|
+
});
|
|
161
|
+
clearTimeout(connectTimeout);
|
|
162
|
+
const sc = response.status;
|
|
163
|
+
// 404/503: SSE not available, signal polling fallback
|
|
164
|
+
if (sc === HttpStatus.NOT_FOUND || sc === HttpStatus.SERVICE_UNAVAILABLE) {
|
|
165
|
+
shouldFallback = true;
|
|
166
|
+
return response;
|
|
167
|
+
}
|
|
168
|
+
// 401: reactive token refresh
|
|
169
|
+
if (sc === HttpStatus.UNAUTHORIZED) {
|
|
170
|
+
const refreshed = await this.tryRefresh();
|
|
171
|
+
if (!refreshed) {
|
|
172
|
+
shouldFallback = true;
|
|
173
|
+
return response;
|
|
224
174
|
}
|
|
175
|
+
// Retry with fresh token
|
|
176
|
+
return await fetch(fetchUrl, {
|
|
177
|
+
...init,
|
|
178
|
+
headers: {
|
|
179
|
+
...headers,
|
|
180
|
+
[HEADER_AUTHORIZATION]: `${BEARER_PREFIX} ${getAccessToken()}`,
|
|
181
|
+
},
|
|
182
|
+
signal: composedSignal,
|
|
183
|
+
});
|
|
225
184
|
}
|
|
185
|
+
return response;
|
|
226
186
|
}
|
|
187
|
+
catch (error) {
|
|
188
|
+
clearTimeout(connectTimeout);
|
|
189
|
+
throw error;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
client = createEventSource({
|
|
193
|
+
url,
|
|
194
|
+
fetch: sseAuthFetch,
|
|
195
|
+
initialLastEventId: this.lastEventId || undefined,
|
|
196
|
+
headers: {}, // Headers managed by custom fetch
|
|
197
|
+
onMessage: (msg) => {
|
|
198
|
+
if (settled)
|
|
199
|
+
return;
|
|
200
|
+
resetHeartbeat();
|
|
201
|
+
const result = this.dispatchEvent(msg, onEvent);
|
|
202
|
+
if (result !== undefined) {
|
|
203
|
+
settle(result);
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
onScheduleReconnect: ({ delay }) => {
|
|
207
|
+
// Honor server retry: directive in our external retry loop
|
|
208
|
+
this.reconnectionDelay = delay;
|
|
209
|
+
// Prevent library's internal reconnect — we manage retries ourselves
|
|
210
|
+
client?.close();
|
|
211
|
+
},
|
|
212
|
+
onDisconnect: () => {
|
|
213
|
+
if (settled)
|
|
214
|
+
return;
|
|
215
|
+
if (shouldFallback) {
|
|
216
|
+
settle(null);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
// Stream ended without terminal event — retry
|
|
220
|
+
settle();
|
|
221
|
+
}
|
|
222
|
+
},
|
|
227
223
|
});
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
});
|
|
231
|
-
stream.on("end", () => {
|
|
232
|
-
settle(resolve, undefined);
|
|
233
|
-
});
|
|
224
|
+
// Start heartbeat timer
|
|
225
|
+
resetHeartbeat();
|
|
234
226
|
});
|
|
235
227
|
}
|
|
236
228
|
/**
|
|
@@ -238,72 +230,41 @@ export class SSEClient {
|
|
|
238
230
|
*
|
|
239
231
|
* @returns SSEEvent for terminal, null for fallback, undefined to continue
|
|
240
232
|
*/
|
|
241
|
-
dispatchEvent(
|
|
233
|
+
dispatchEvent(msg, onEvent) {
|
|
242
234
|
// Track Last-Event-ID for reconnection
|
|
243
|
-
if (
|
|
244
|
-
this.lastEventId =
|
|
245
|
-
}
|
|
246
|
-
// Track server retry field (milliseconds -> milliseconds)
|
|
247
|
-
if (fields.retry !== undefined) {
|
|
248
|
-
this.reconnectionDelay = fields.retry;
|
|
235
|
+
if (msg.id) {
|
|
236
|
+
this.lastEventId = msg.id;
|
|
249
237
|
}
|
|
238
|
+
const eventType = msg.event ?? "";
|
|
250
239
|
// Skip ping/heartbeat and empty data
|
|
251
|
-
if (
|
|
240
|
+
if (eventType === SSEEventType.PING || !msg.data) {
|
|
252
241
|
log.debug("SSE ping/heartbeat");
|
|
253
242
|
return undefined;
|
|
254
243
|
}
|
|
255
|
-
// Multi-line data: concatenate with newline per spec
|
|
256
|
-
const dataStr = fields.data.join("\n");
|
|
257
244
|
let data;
|
|
258
245
|
try {
|
|
259
|
-
data = JSON.parse(
|
|
246
|
+
data = JSON.parse(msg.data);
|
|
260
247
|
}
|
|
261
248
|
catch {
|
|
262
|
-
log.debug("SSE malformed JSON", { event:
|
|
249
|
+
log.debug("SSE malformed JSON", { event: eventType, data: msg.data });
|
|
263
250
|
return undefined;
|
|
264
251
|
}
|
|
265
|
-
const event = parseSSEEvent(
|
|
252
|
+
const event = parseSSEEvent(eventType, data);
|
|
266
253
|
if (event === null) {
|
|
267
|
-
log.debug("SSE parse failed", { event:
|
|
254
|
+
log.debug("SSE parse failed", { event: eventType, data: msg.data });
|
|
268
255
|
return undefined;
|
|
269
256
|
}
|
|
270
257
|
// Terminal events: complete, error, cancelled
|
|
271
|
-
if (
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
log.debug("SSE terminal", { event:
|
|
258
|
+
if (eventType === SSEEventType.COMPLETE ||
|
|
259
|
+
eventType === SSEEventType.ERROR ||
|
|
260
|
+
eventType === SSEEventType.CANCELLED) {
|
|
261
|
+
log.debug("SSE terminal", { event: eventType });
|
|
275
262
|
return event;
|
|
276
263
|
}
|
|
277
264
|
// Connected/Progress events: dispatch to callback
|
|
278
|
-
log.debug("SSE event", { event:
|
|
265
|
+
log.debug("SSE event", { event: eventType, data: msg.data });
|
|
279
266
|
onEvent(event);
|
|
280
267
|
return undefined;
|
|
281
268
|
}
|
|
282
|
-
/**
|
|
283
|
-
* Classify error to determine retry strategy.
|
|
284
|
-
*
|
|
285
|
-
* @returns "retry" to retry with backoff, "fallback" to return null
|
|
286
|
-
*/
|
|
287
|
-
classifyError(error) {
|
|
288
|
-
if (error instanceof HTTPError) {
|
|
289
|
-
const status = error.response.statusCode;
|
|
290
|
-
// 404/503: SSE not available
|
|
291
|
-
if (status === HttpStatus.NOT_FOUND || status === HttpStatus.SERVICE_UNAVAILABLE)
|
|
292
|
-
return "fallback";
|
|
293
|
-
}
|
|
294
|
-
// Timeout errors: retry (heartbeat timeout)
|
|
295
|
-
if (error instanceof RequestError) {
|
|
296
|
-
const code = error.code;
|
|
297
|
-
if (code === "ERR_SOCKET_TIMEOUT" || code === "ETIMEDOUT") {
|
|
298
|
-
return "retry";
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
// Network errors: retry
|
|
302
|
-
return "retry";
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
/** Promise-based sleep utility. */
|
|
306
|
-
function sleep(ms) {
|
|
307
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
308
269
|
}
|
|
309
270
|
//# sourceMappingURL=sse-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse-client.js","sourceRoot":"","sources":["../../src/api/sse-client.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,
|
|
1
|
+
{"version":3,"file":"sse-client.js","sourceRoot":"","sources":["../../src/api/sse-client.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,gFAAgF;AAChF,2EAA2E;AAC3E,EAAE;AACF,0EAA0E;AAC1E,wEAAwE;AACxE,iEAAiE;AAEjE,OAAO,EACL,iBAAiB,GAIlB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,qBA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AC,SAAS,EAAE,IAAI,CAAC,CAAC;QAC7C,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,GAAG,CAAC,KAAK,CAAC,kBAAkB,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;YACpE,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,8CAA8C;QAC9C,IACE,SAAS,KAAK,YAAY,CAAC,QAAQ;YACnC,SAAS,KAAK,YAAY,CAAC,KAAK;YAChC,SAAS,KAAK,YAAY,CAAC,SAAS,EACpC,CAAC;YACD,GAAG,CAAC,KAAK,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;YAChD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,kDAAkD;QAClD,GAAG,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;QAC7D,OAAO,CAAC,KAAK,CAAC,CAAC;QACf,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
|
package/dist/api/sse-models.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// See API-478: SSE Event Models (Zod Schemas)
|
|
2
2
|
// Schema-first design: Zod schemas define runtime validation + TypeScript types.
|
|
3
3
|
//
|
|
4
|
-
// Pattern: z.object() (lenient) because server may add fields
|
|
4
|
+
// Pattern: z.object() (lenient) because server may add fields.
|
|
5
5
|
// Discriminated parse: SSEEventType string selects correct schema at runtime.
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
import { JobStatus, SSEEventType } from "../constants.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse-models.js","sourceRoot":"","sources":["../../src/api/sse-models.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,iFAAiF;AACjF,EAAE;AACF,+
|
|
1
|
+
{"version":3,"file":"sse-models.js","s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2"
|
|
12
12
|
*/
|
|
13
13
|
export function generateTraceId() {
|
|
14
|
-
return randomUUID().
|
|
14
|
+
return randomUUID().replaceAll("-", "").slice(0, 8);
|
|
15
15
|
}
|
|
16
16
|
//# sourceMappingURL=trace.js.map
|
package/dist/api/trace.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace.js","sourceRoot":"","sources":["../../src/api/trace.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,iDAAiD;AACjD,4EAA4E;AAE5E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,UAAU,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"trace.js","sourceRoot":"","sources":["../../src/api/trace.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,iDAAiD;AACjD,4EAA4E;AAE5E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,UAAU,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACtD,CAAC"}
|