@valerypopoff/rivet2-core 2.1.3 → 2.1.4
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/cjs/bundle.cjs +2707 -1012
- package/dist/cjs/bundle.cjs.map +4 -4
- package/dist/cjs/webAppRuntime.cjs +625 -0
- package/dist/cjs/webAppRuntime.cjs.map +7 -0
- package/dist/esm/api/createProcessor.js +3 -0
- package/dist/esm/api/streaming.js +6 -0
- package/dist/esm/exports.js +5 -0
- package/dist/esm/integrations/mcp/MCPBase.js +92 -34
- package/dist/esm/model/GraphProcessor.js +11 -4
- package/dist/esm/model/GraphProgress.js +15 -0
- package/dist/esm/model/Nodes.js +3 -0
- package/dist/esm/model/ProcessContextBuilder.js +2 -1
- package/dist/esm/model/RecordingPlayer.js +10 -0
- package/dist/esm/model/SubprocessorBridge.js +1 -0
- package/dist/esm/model/UiGraph.js +127 -4
- package/dist/esm/model/UiGraphActionProtocol.js +122 -0
- package/dist/esm/model/UiGraphBindings.js +530 -0
- package/dist/esm/model/UiGraphBrowserRuntime.js +40 -0
- package/dist/esm/model/UiGraphNormalization.js +298 -0
- package/dist/esm/model/UiGraphRendererStyles.js +374 -6
- package/dist/esm/model/UiGraphRuntimeModel.js +300 -0
- package/dist/esm/model/UiGraphWebAppStatus.js +19 -0
- package/dist/esm/model/nodes/ArrayNode.js +2 -13
- package/dist/esm/model/nodes/AssembleMessageNode.js +2 -13
- package/dist/esm/model/nodes/AssemblePromptNode.js +2 -13
- package/dist/esm/model/nodes/CoalesceNode.js +2 -15
- package/dist/esm/model/nodes/DelayNode.js +3 -14
- package/dist/esm/model/nodes/DidRunNode.js +2 -13
- package/dist/esm/model/nodes/JoinNode.js +2 -13
- package/dist/esm/model/nodes/LoopControllerNode.js +3 -14
- package/dist/esm/model/nodes/MCPDiscoveryNode.js +19 -90
- package/dist/esm/model/nodes/MCPGetPromptNode.js +11 -97
- package/dist/esm/model/nodes/MCPToolCallNode.js +11 -97
- package/dist/esm/model/nodes/PassthroughNode.js +3 -14
- package/dist/esm/model/nodes/RaceInputsNode.js +2 -13
- package/dist/esm/model/nodes/ReportProgressNode.js +57 -0
- package/dist/esm/model/nodes/variadicPortIndex.js +32 -0
- package/dist/esm/plugins/anthropic/anthropic.js +1 -1
- package/dist/esm/recording/ExecutionRecorder.js +5 -0
- package/dist/esm/utils/fetchEventSource.js +16 -17
- package/dist/esm/utils/serialization/serialization.js +4 -0
- package/dist/esm/utils/serialization/serializationUtils.js +8 -27
- package/dist/esm/utils/serialization/serialization_v4.js +3 -3
- package/dist/esm/webAppRuntime.js +4 -2
- package/dist/types/api/streaming.d.ts +6 -0
- package/dist/types/exports.d.ts +5 -0
- package/dist/types/integrations/mcp/MCPBase.d.ts +26 -3
- package/dist/types/model/ExecutorProtocol.d.ts +7 -0
- package/dist/types/model/GraphProcessor.d.ts +7 -0
- package/dist/types/model/GraphProgress.d.ts +6 -0
- package/dist/types/model/Nodes.d.ts +3 -2
- package/dist/types/model/ProcessContext.d.ts +3 -0
- package/dist/types/model/ProcessContextBuilder.d.ts +2 -1
- package/dist/types/model/UiGraph.d.ts +42 -9
- package/dist/types/model/UiGraphActionProtocol.d.ts +69 -0
- package/dist/types/model/UiGraphBindings.d.ts +45 -0
- package/dist/types/model/UiGraphBrowserRuntime.d.ts +4 -0
- package/dist/types/model/UiGraphNormalization.d.ts +24 -0
- package/dist/types/model/UiGraphRendererStyles.d.ts +1 -1
- package/dist/types/model/UiGraphRuntimeModel.d.ts +77 -5
- package/dist/types/model/UiGraphWebAppStatus.d.ts +5 -0
- package/dist/types/model/nodes/ArrayNode.d.ts +0 -1
- package/dist/types/model/nodes/AssembleMessageNode.d.ts +0 -1
- package/dist/types/model/nodes/AssemblePromptNode.d.ts +0 -1
- package/dist/types/model/nodes/DelayNode.d.ts +0 -1
- package/dist/types/model/nodes/DidRunNode.d.ts +0 -1
- package/dist/types/model/nodes/JoinNode.d.ts +0 -1
- package/dist/types/model/nodes/LoopControllerNode.d.ts +0 -1
- package/dist/types/model/nodes/PassthroughNode.d.ts +0 -1
- package/dist/types/model/nodes/RaceInputsNode.d.ts +0 -1
- package/dist/types/model/nodes/ReportProgressNode.d.ts +23 -0
- package/dist/types/model/nodes/variadicPortIndex.d.ts +4 -0
- package/dist/types/recording/RecordedEvents.d.ts +5 -0
- package/dist/types/webAppRuntime.d.ts +8 -3
- package/package.json +2 -2
- package/dist/esm/plugins/anthropic/fetchEventSource.js +0 -107
- package/dist/types/plugins/anthropic/fetchEventSource.d.ts +0 -11
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type GraphBoundary } from './GraphBoundaryCache.js';
|
|
2
|
+
import type { GraphId } from './NodeGraph.js';
|
|
3
|
+
import type { Project } from './Project.js';
|
|
4
|
+
import { type UiComponentId, type UiGraph, type UiGraphChatRunGraphAction, type UiGraphId, type UiGraphInputBinding, type UiGraphOutputBinding, type UiGraphRunGraphAction } from './UiGraph.js';
|
|
5
|
+
export type UiGraphButtonBindingRenames = {
|
|
6
|
+
inputIds?: Readonly<Record<string, string>>;
|
|
7
|
+
outputIds?: Readonly<Record<string, string>>;
|
|
8
|
+
};
|
|
9
|
+
export type UiGraphActionBindingIssue = {
|
|
10
|
+
code: 'duplicate-chat-input' | 'duplicate-input-binding' | 'duplicate-output-state-key' | 'empty-input-id' | 'empty-input-state-key' | 'empty-output-state-key' | 'missing-chat-history-input' | 'missing-chat-response-output' | 'missing-chat-user-input' | 'missing-target-graph' | 'stale-input-binding' | 'stale-output-binding' | 'target-graph-not-found';
|
|
11
|
+
componentId: UiComponentId;
|
|
12
|
+
graphId?: GraphId;
|
|
13
|
+
message: string;
|
|
14
|
+
portId?: string;
|
|
15
|
+
severity: 'error';
|
|
16
|
+
uiGraphId: UiGraphId;
|
|
17
|
+
};
|
|
18
|
+
/** @deprecated Use UiGraphActionBindingIssue for Button and Chat components. */
|
|
19
|
+
export type UiGraphButtonBindingIssue = UiGraphActionBindingIssue;
|
|
20
|
+
/**
|
|
21
|
+
* Aligns a button with a graph boundary without guessing by row position.
|
|
22
|
+
* Exact IDs win; state keys cross an ID change only for a proven node rename.
|
|
23
|
+
*/
|
|
24
|
+
export declare function reconcileUiGraphRunGraphActionBindings(action: UiGraphRunGraphAction, boundary: GraphBoundary, renames?: UiGraphButtonBindingRenames): UiGraphRunGraphAction;
|
|
25
|
+
/** Seeds a new button from ordered factory placeholder data keys. */
|
|
26
|
+
export declare function initializeUiGraphRunGraphActionBindings(action: UiGraphRunGraphAction, boundary: GraphBoundary): UiGraphRunGraphAction;
|
|
27
|
+
/** Seeds the three graph-boundary roles required by a new Chat component. */
|
|
28
|
+
export declare function initializeUiGraphChatActionBindings(action: UiGraphChatRunGraphAction, boundary: GraphBoundary | undefined): UiGraphChatRunGraphAction;
|
|
29
|
+
export declare function reconcileUiGraphChatActionBindings(action: UiGraphChatRunGraphAction, boundary: GraphBoundary, renames?: UiGraphButtonBindingRenames, changed?: {
|
|
30
|
+
inputs: boolean;
|
|
31
|
+
outputs: boolean;
|
|
32
|
+
}): UiGraphChatRunGraphAction;
|
|
33
|
+
export declare function getReconciledUiGraphActionInputBindings(action: UiGraphRunGraphAction, boundary: GraphBoundary): UiGraphInputBinding[];
|
|
34
|
+
export declare function getReconciledUiGraphActionOutputBindings(action: UiGraphRunGraphAction, boundary: GraphBoundary): UiGraphOutputBinding[];
|
|
35
|
+
/** Reconciles workflow-bound UI components for changed graph boundaries. */
|
|
36
|
+
export declare function reconcileProjectUiGraphBindings<TProject extends Project>(previousProject: TProject, nextProject: TProject): TProject;
|
|
37
|
+
/** @deprecated Use reconcileProjectUiGraphBindings for all workflow-bound components. */
|
|
38
|
+
export declare const reconcileProjectUiGraphButtonBindings: typeof reconcileProjectUiGraphBindings;
|
|
39
|
+
/** Non-mutating preflight for desktop and hosted web-app runners. */
|
|
40
|
+
export declare function validateUiGraphActionBindings(project: Project, uiGraph: UiGraph, componentId?: UiComponentId): UiGraphActionBindingIssue[];
|
|
41
|
+
export declare function validateUiGraphButtonBindings(project: Project, uiGraph: UiGraph, componentId?: UiComponentId): UiGraphButtonBindingIssue[];
|
|
42
|
+
export declare function validateProjectUiGraphButtonBindings(project: Project): UiGraphButtonBindingIssue[];
|
|
43
|
+
export declare function validateProjectUiGraphActionBindings(project: Project): UiGraphActionBindingIssue[];
|
|
44
|
+
export declare function formatUiGraphActionBindingIssues(issues: readonly UiGraphActionBindingIssue[]): string;
|
|
45
|
+
export declare function formatUiGraphButtonBindingIssues(issues: readonly UiGraphButtonBindingIssue[]): string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Copies rendered web-app output without requiring the modern Clipboard API. */
|
|
2
|
+
export declare function copyUiGraphText(value: string): Promise<boolean>;
|
|
3
|
+
/** Downloads the exact JSON string rendered by a web-app output component. */
|
|
4
|
+
export declare function downloadUiGraphJsonOutput(value: string, appName: string): void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Project } from './Project.js';
|
|
2
|
+
import { type UiGraph, type UiGraphId } from './UiGraph.js';
|
|
3
|
+
export type UiGraphNormalizationIssue = {
|
|
4
|
+
message: string;
|
|
5
|
+
path: string;
|
|
6
|
+
};
|
|
7
|
+
export type UiGraphNormalizationOptions = {
|
|
8
|
+
/** Disable only when validating raw data before known legacy ID repair. */
|
|
9
|
+
repairComponentIds?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare class UiGraphNormalizationError extends Error {
|
|
12
|
+
readonly issues: readonly UiGraphNormalizationIssue[];
|
|
13
|
+
constructor(issues: readonly UiGraphNormalizationIssue[]);
|
|
14
|
+
}
|
|
15
|
+
export declare function formatUiGraphNormalizationIssue(issue: UiGraphNormalizationIssue): string;
|
|
16
|
+
/**
|
|
17
|
+
* Validates every UI graph and component discriminator while applying only the
|
|
18
|
+
* deterministic component-ID repair supported for legacy project snapshots.
|
|
19
|
+
*/
|
|
20
|
+
export declare function normalizeUiGraph(value: unknown, options?: UiGraphNormalizationOptions): UiGraph;
|
|
21
|
+
export declare function normalizeUiGraphRecord(value: unknown, options?: UiGraphNormalizationOptions): Record<UiGraphId, UiGraph>;
|
|
22
|
+
export declare function normalizeProjectUiGraphs<T extends {
|
|
23
|
+
uiGraphs?: Project['uiGraphs'];
|
|
24
|
+
}>(project: T): T;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const RIVET_WEB_APP_RENDERER_CSS = "\n.rivet-web-app-root {\n --rivet-web-app-background: var(--grey-dark-colorish, #1c222b);\n --rivet-web-app-foreground: var(--foreground, #ffffff);\n --rivet-web-app-card-background: color-mix(in srgb, var(--modal-surface-bg, #252b34) 88%, var(--foreground, #ffffff) 4%);\n --rivet-web-app-card-border: var(--foldable-section-border, rgba(255, 255, 255, 0.04));\n --rivet-web-app-control-background: var(--form-control-bg, #20252d);\n --rivet-web-app-control-border: var(--form-control-border, rgba(255, 255, 255, 0.14));\n --rivet-web-app-button-radius: var(--rivet-web-app-host-button-radius, 6px);\n --rivet-web-app-button-background: var(--success, #3ba85b);\n --rivet-web-app-button-foreground: var(--grey-lightest, #ffffff);\n --rivet-web-app-output-title: var(--rivet-web-app-foreground, #ffffff);\n --rivet-web-app-error-color: var(--error, #ff6b5f);\n --rivet-web-app-font-size: var(--rivet-web-app-host-font-size, 15px);\n box-sizing: border-box;\n height: 100%;\n background: var(--rivet-web-app-background);\n color: var(--rivet-web-app-foreground);\n overflow: auto;\n font-family: Inter, system-ui, sans-serif;\n font-size: var(--rivet-web-app-font-size);\n line-height: 1.4;\n}\n\n.rivet-web-app-root *,\n.rivet-web-app-root *::before,\n.rivet-web-app-root *::after {\n box-sizing: border-box;\n}\n\n.rivet-web-app-surface {\n display: grid;\n gap: 16px;\n margin: 0 auto;\n max-width: 760px;\n padding: 48px 20px;\n}\n\n.rivet-web-app-card,\n.rivet-web-app-field {\n border: 1px solid var(--rivet-web-app-card-border);\n border-radius: 10px;\n background: var(--rivet-web-app-card-background);\n padding: 16px;\n}\n\n.rivet-web-app-component-frame {\n border-radius: 12px;\n margin: -5px;\n padding: 4px;\n}\n\n.rivet-web-app-component-frame.active {\n background: color-mix(in srgb, var(--modal-surface-bg, #252b34) 75%, var(--primary, #ff9e2c) 16%);\n}\n\n.rivet-web-app-field {\n display: grid;\n gap: 8px;\n color: var(--rivet-web-app-foreground);\n font-size: inherit;\n font-weight: 600;\n}\n\n.rivet-web-app-field input,\n.rivet-web-app-field textarea {\n appearance: none;\n width: 100%;\n box-sizing: border-box;\n border: 1px solid var(--rivet-web-app-control-border);\n border-radius: 8px;\n background: var(--rivet-web-app-control-background);\n color: var(--rivet-web-app-foreground);\n font: inherit;\n font-weight: 400;\n padding: 10px 12px;\n}\n\n.rivet-web-app-field textarea {\n min-height: 110px;\n resize: vertical;\n}\n\n.rivet-web-app-button {\n width: fit-content;\n border: 0;\n border-radius: var(--rivet-web-app-button-radius);\n background: var(--rivet-web-app-button-background);\n color: var(--rivet-web-app-button-foreground);\n cursor: pointer;\n font: inherit;\n font-weight: 700;\n padding: 10px 16px;\n}\n\n.rivet-web-app-button:disabled {\n cursor: wait;\n opacity: 0.72;\n}\n\n.rivet-web-app-output {\n display: grid;\n gap: 8px;\n position: relative;\n}\n\n.rivet-web-app-output-title {\n color: var(--rivet-web-app-output-title);\n font-weight: 700;\n padding-right: 32px;\n}\n\n.rivet-web-app-output-has-download .rivet-web-app-output-title {\n padding-right: 64px;\n}\n\n.rivet-web-app-output-action-button {\n position: absolute;\n top: 11px;\n width: 24px;\n height: 24px;\n border: 0;\n border-radius: 5px;\n background: transparent;\n color: color-mix(in srgb, var(--rivet-web-app-foreground) 68%, transparent);\n cursor: pointer;\n padding: 0;\n}\n\n.rivet-web-app-output-copy-button {\n right: 11px;\n}\n\n.rivet-web-app-output-download-button {\n right: 39px;\n}\n\n.rivet-web-app-output-copy-button::before,\n.rivet-web-app-output-copy-button::after {\n content: \"\";\n position: absolute;\n width: 10px;\n height: 12px;\n border: 1.5px solid currentColor;\n border-radius: 2px;\n}\n\n.rivet-web-app-output-copy-button::before {\n top: 5px;\n left: 8px;\n}\n\n.rivet-web-app-output-copy-button::after {\n top: 8px;\n left: 5px;\n background: var(--rivet-web-app-card-background);\n}\n\n.rivet-web-app-output-download-button::before,\n.rivet-web-app-output-download-button::after {\n content: \"\";\n position: absolute;\n}\n\n.rivet-web-app-output-download-button::before {\n top: 5px;\n left: 8px;\n width: 8px;\n height: 8px;\n border-right: 1.5px solid currentColor;\n border-bottom: 1.5px solid currentColor;\n transform: rotate(45deg);\n}\n\n.rivet-web-app-output-download-button::after {\n top: 16px;\n left: 6px;\n width: 12px;\n height: 4px;\n border-right: 1.5px solid currentColor;\n border-bottom: 1.5px solid currentColor;\n border-left: 1.5px solid currentColor;\n border-radius: 0 0 2px 2px;\n}\n\n.rivet-web-app-output-action-button:hover,\n.rivet-web-app-output-action-button:focus-visible {\n color: var(--primary, #ff9e2c);\n outline: none;\n background: color-mix(in srgb, var(--rivet-web-app-foreground) 8%, transparent);\n}\n\n.rivet-web-app-output pre {\n margin: 0;\n background: transparent;\n border-radius: 0;\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace;\n font-size: inherit;\n padding: 0;\n white-space: pre-wrap;\n word-break: break-word;\n}\n\n.rivet-web-app-markdown,\n.rivet-web-app-output-markdown {\n word-break: break-word;\n}\n\n.rivet-web-app-markdown.markdown-body {\n background: var(--rivet-web-app-card-background);\n font-family: inherit;\n min-width: 0;\n}\n\n.rivet-web-app-output-markdown.markdown-body {\n background: transparent;\n font-family: inherit;\n min-width: 0;\n}\n\n.rivet-web-app-markdown h1,\n.rivet-web-app-output-markdown h1 {\n margin: 0 0 12px;\n padding-bottom: 8px;\n border-bottom: 1px solid var(--rivet-web-app-card-border);\n font-size: 24px;\n line-height: 1.22;\n}\n\n.rivet-web-app-markdown h2,\n.rivet-web-app-output-markdown h2 {\n margin: 0 0 10px;\n font-size: 20px;\n line-height: 1.25;\n}\n\n.rivet-web-app-markdown p,\n.rivet-web-app-output-markdown p,\n.rivet-web-app-markdown ul,\n.rivet-web-app-output-markdown ul {\n margin: 0 0 12px;\n}\n\n.rivet-web-app-markdown.markdown-body code,\n.rivet-web-app-output-markdown.markdown-body code {\n border-radius: 4px;\n background: color-mix(in srgb, var(--rivet-web-app-control-background) 70%, var(--rivet-web-app-foreground) 6%);\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace;\n padding: 1px 4px;\n}\n\n.rivet-web-app-markdown.markdown-body pre,\n.rivet-web-app-output-markdown.markdown-body pre {\n background: transparent;\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace;\n padding: 0;\n white-space: pre-wrap;\n}\n\n.rivet-web-app-markdown > :first-child,\n.rivet-web-app-output-markdown > :first-child {\n margin-top: 0;\n}\n\n.rivet-web-app-markdown > :last-child,\n.rivet-web-app-output-markdown > :last-child {\n margin-bottom: 0;\n}\n\n.rivet-web-app-error {\n color: var(--rivet-web-app-error-color);\n font-weight: 700;\n}\n\n.rivet-web-app-modal-backdrop {\n position: fixed;\n inset: 0;\n z-index: 1000;\n display: grid;\n place-items: center;\n background: rgba(0, 0, 0, 0.46);\n background: color-mix(in srgb, var(--rivet-web-app-background) 78%, transparent);\n padding: 20px;\n}\n\n.rivet-web-app-modal {\n display: grid;\n gap: 18px;\n width: min(420px, 100%);\n border: 1px solid var(--rivet-web-app-card-border);\n border-radius: 12px;\n background: var(--rivet-web-app-card-background);\n box-shadow: 0 18px 60px rgba(0, 0, 0, 0.32);\n color: var(--rivet-web-app-foreground);\n padding: 22px;\n}\n\n.rivet-web-app-modal-message {\n font-size: 18px;\n font-weight: 700;\n line-height: 1.3;\n}\n\n.rivet-web-app-modal-button {\n justify-self: start;\n}\n";
|
|
1
|
+
export declare const RIVET_WEB_APP_RENDERER_CSS = "\n.rivet-web-app-root {\n --rivet-web-app-background: var(--grey-dark-colorish, #1c222b);\n --rivet-web-app-foreground: var(--foreground, #ffffff);\n --rivet-web-app-card-background: color-mix(in srgb, var(--modal-surface-bg, #252b34) 88%, var(--foreground, #ffffff) 4%);\n --rivet-web-app-card-border: var(--foldable-section-border, rgba(255, 255, 255, 0.04));\n --rivet-web-app-control-background: var(--form-control-bg, #20252d);\n --rivet-web-app-control-border: var(--form-control-border, rgba(255, 255, 255, 0.14));\n --rivet-web-app-button-radius: var(--rivet-web-app-host-button-radius, var(--ui-button-radius, 6px));\n --rivet-web-app-button-height: calc(32px * var(--ui-font-scale, 1));\n --rivet-web-app-button-background: var(--success, #3ba85b);\n --rivet-web-app-button-foreground: var(--grey-lightest, #ffffff);\n --rivet-web-app-output-title: var(--rivet-web-app-foreground, #ffffff);\n --rivet-web-app-error-color: var(--error, #ff6b5f);\n --rivet-web-app-font-size: var(--rivet-web-app-host-font-size, 15px);\n --rivet-web-app-chat-min-height: clamp(360px, calc(100vh - 136px), 540px);\n box-sizing: border-box;\n height: 100%;\n background: var(--rivet-web-app-background);\n color: var(--rivet-web-app-foreground);\n overflow: auto;\n font-family: Inter, system-ui, sans-serif;\n font-size: var(--rivet-web-app-font-size);\n line-height: 1.4;\n}\n\n.rivet-web-app-root *,\n.rivet-web-app-root *::before,\n.rivet-web-app-root *::after {\n box-sizing: border-box;\n}\n\n.rivet-web-app-surface {\n display: flex;\n flex-direction: column;\n gap: 16px;\n height: 100%;\n margin: 0 auto;\n max-width: 760px;\n padding: 48px 20px;\n}\n\n.rivet-web-app-card,\n.rivet-web-app-field {\n border: 1px solid var(--rivet-web-app-card-border);\n border-radius: 10px;\n background: var(--rivet-web-app-card-background);\n padding: 16px;\n}\n\n.rivet-web-app-text {\n background: transparent;\n}\n\n.rivet-web-app-gap {\n width: 100%;\n border: 0;\n background: transparent;\n}\n\n.rivet-web-app-gap-small {\n height: 8px;\n}\n\n.rivet-web-app-gap-medium {\n height: 24px;\n}\n\n.rivet-web-app-gap-large {\n height: 48px;\n}\n\n.rivet-web-app-component-frame {\n flex: 0 0 auto;\n border-radius: 12px;\n margin: -5px;\n padding: 4px;\n}\n\n.rivet-web-app-component-frame[data-rivet-web-app-component-type='chat'] {\n display: flex;\n flex: 1 0 var(--rivet-web-app-chat-min-height);\n min-height: var(--rivet-web-app-chat-min-height);\n}\n\n.rivet-web-app-component-frame.active {\n background: color-mix(in srgb, var(--modal-surface-bg, #252b34) 75%, var(--primary, #ff9e2c) 16%);\n}\n\n.rivet-web-app-field {\n display: grid;\n gap: 8px;\n color: var(--rivet-web-app-foreground);\n font-size: inherit;\n font-weight: 600;\n}\n\n.rivet-web-app-field input,\n.rivet-web-app-field textarea {\n appearance: none;\n width: 100%;\n box-sizing: border-box;\n border: 1px solid var(--rivet-web-app-control-border);\n border-radius: 8px;\n background: var(--rivet-web-app-control-background);\n color: var(--rivet-web-app-foreground);\n font: inherit;\n font-weight: 400;\n padding: 10px 12px;\n}\n\n.rivet-web-app-field textarea {\n min-height: 110px;\n resize: vertical;\n}\n\n.rivet-web-app-button {\n width: fit-content;\n border: 0;\n border-radius: var(--rivet-web-app-button-radius);\n background: var(--rivet-web-app-button-background);\n color: var(--rivet-web-app-button-foreground);\n cursor: pointer;\n display: flex;\n align-items: center;\n gap: 0.5rem;\n font: inherit;\n font-family: var(--font-family, Inter, system-ui, sans-serif);\n font-size: var(--ui-font-size-base, var(--rivet-web-app-font-size));\n height: var(--rivet-web-app-button-height);\n margin: 0;\n padding: 0.5rem 1rem;\n corner-shape: squircle;\n}\n\n.rivet-web-app-button:disabled {\n background: var(--grey-darkish, #30343b);\n color: var(--grey-light, #b6b8bf);\n cursor: wait;\n opacity: 0.8;\n}\n\n.rivet-web-app-button:hover:not(:disabled) {\n background: var(--success-dark, #009624);\n}\n\n.rivet-web-app-running-indicator {\n box-sizing: border-box;\n color: currentColor;\n display: inline-block;\n width: calc(16px * var(--ui-font-scale, 1));\n height: calc(16px * var(--ui-font-scale, 1));\n border: calc(2px * var(--ui-font-scale, 1)) solid currentColor;\n border-right-color: transparent;\n border-bottom-color: transparent;\n border-radius: 50%;\n flex: 0 0 auto;\n pointer-events: none;\n animation: rivet-web-app-running-indicator-spin 0.8s linear infinite;\n}\n\n@keyframes rivet-web-app-running-indicator-spin {\n to {\n transform: rotate(360deg);\n }\n}\n\n.rivet-web-app-action-stack {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: 10px;\n min-width: 0;\n}\n\n.rivet-web-app-action-stack-running > .rivet-web-app-button,\n.rivet-web-app-action-stack-running > .rivet-web-app-abort-button {\n box-sizing: border-box;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n height: var(--rivet-web-app-button-height);\n min-height: var(--rivet-web-app-button-height);\n padding: 0.5rem 1rem;\n}\n\n.rivet-web-app-action-stack-running > .rivet-web-app-button {\n gap: 8px;\n white-space: nowrap;\n}\n\n.rivet-web-app-action-stack .rivet-web-app-progress {\n flex: 0 0 100%;\n}\n\n.rivet-web-app-abort-button {\n flex: 0 0 auto;\n border: 1px solid var(--rivet-web-app-control-border);\n border-radius: var(--rivet-web-app-button-radius);\n background: transparent;\n color: var(--rivet-web-app-foreground);\n cursor: pointer;\n font: inherit;\n font-size: var(--ui-font-size-base, var(--rivet-web-app-font-size));\n padding: 6px 10px;\n}\n\n.rivet-web-app-abort-button:hover,\n.rivet-web-app-abort-button:focus-visible {\n border-color: color-mix(in srgb, var(--rivet-web-app-foreground) 40%, transparent);\n outline: none;\n}\n\n.rivet-web-app-progress {\n display: grid;\n gap: 5px;\n color: color-mix(in srgb, var(--rivet-web-app-foreground) 68%, transparent);\n font-size: 13px;\n min-width: 0;\n}\n\n.rivet-web-app-progress progress {\n width: min(320px, 100%);\n height: 6px;\n accent-color: var(--rivet-web-app-button-background);\n}\n\n.rivet-web-app-chat {\n display: grid;\n flex: 1;\n grid-template-rows: auto minmax(0, 1fr) auto auto;\n min-height: 0;\n width: 100%;\n overflow: hidden;\n border: 1px solid var(--rivet-web-app-card-border);\n border-radius: 14px;\n background: var(--rivet-web-app-card-background);\n}\n\n.rivet-web-app-chat-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n min-height: 52px;\n border-bottom: 1px solid var(--rivet-web-app-card-border);\n padding: 0 18px;\n font-weight: 700;\n}\n\n.rivet-web-app-chat-status {\n color: color-mix(in srgb, var(--rivet-web-app-foreground) 56%, transparent);\n font-size: 12px;\n font-weight: 500;\n}\n\n.rivet-web-app-chat-header-actions {\n display: flex;\n align-items: center;\n gap: 10px;\n}\n\n.rivet-web-app-chat > .rivet-web-app-progress {\n border-top: 1px solid var(--rivet-web-app-card-border);\n padding: 10px 14px 0;\n}\n\n.rivet-web-app-chat-messages {\n display: flex;\n flex-direction: column;\n gap: 12px;\n min-height: 0;\n overflow-y: auto;\n padding: 22px 18px;\n scrollbar-gutter: stable;\n}\n\n.rivet-web-app-chat-messages > :first-child {\n margin-top: auto;\n}\n\n.rivet-web-app-chat-empty {\n display: grid;\n place-content: center;\n gap: 6px;\n flex: 1;\n min-height: 220px;\n color: color-mix(in srgb, var(--rivet-web-app-foreground) 56%, transparent);\n text-align: center;\n}\n\n.rivet-web-app-chat-empty strong {\n color: var(--rivet-web-app-foreground);\n font-size: 17px;\n}\n\n.rivet-web-app-chat-message {\n width: fit-content;\n max-width: min(82%, 620px);\n border: 1px solid var(--rivet-web-app-card-border);\n border-radius: 14px;\n padding: 10px 13px;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n}\n\n.rivet-web-app-chat-message-user {\n align-self: flex-end;\n border-bottom-right-radius: 5px;\n background: color-mix(in srgb, var(--rivet-web-app-button-background) 72%, var(--rivet-web-app-card-background));\n color: var(--rivet-web-app-button-foreground);\n}\n\n.rivet-web-app-chat-message-assistant {\n align-self: flex-start;\n border-bottom-left-radius: 5px;\n background: var(--rivet-web-app-control-background);\n}\n\n.rivet-web-app-chat-thinking {\n display: flex;\n gap: 5px;\n align-items: center;\n min-width: 52px;\n min-height: 38px;\n}\n\n.rivet-web-app-chat-thinking span {\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: currentColor;\n opacity: 0.35;\n animation: rivet-web-app-chat-thinking 1.1s ease-in-out infinite;\n}\n\n.rivet-web-app-chat-thinking span:nth-child(2) {\n animation-delay: 0.14s;\n}\n\n.rivet-web-app-chat-thinking span:nth-child(3) {\n animation-delay: 0.28s;\n}\n\n.rivet-web-app-chat-error {\n border-top: 1px solid var(--rivet-web-app-card-border);\n color: var(--rivet-web-app-error-color);\n padding: 10px 18px 0;\n font-size: 13px;\n font-weight: 600;\n}\n\n.rivet-web-app-chat-composer {\n display: flex;\n align-items: flex-end;\n gap: 10px;\n border-top: 1px solid var(--rivet-web-app-card-border);\n padding: 14px;\n}\n\n.rivet-web-app-chat-error + .rivet-web-app-chat-composer {\n border-top: 0;\n}\n\n.rivet-web-app-chat-composer textarea {\n field-sizing: content;\n flex: 1;\n min-width: 0;\n min-height: 42px;\n max-height: 160px;\n border: 1px solid var(--rivet-web-app-control-border);\n border-radius: 12px;\n outline: none;\n background: var(--rivet-web-app-control-background);\n color: var(--rivet-web-app-foreground);\n font: inherit;\n line-height: 1.35;\n padding: 10px 12px;\n resize: none;\n}\n\n.rivet-web-app-chat-composer textarea:focus {\n border-color: color-mix(in srgb, var(--rivet-web-app-foreground) 34%, transparent);\n}\n\n.rivet-web-app-chat-send {\n flex: 0 0 auto;\n width: 40px;\n height: 40px;\n border: 0;\n border-radius: 50%;\n background: var(--rivet-web-app-button-background);\n color: var(--rivet-web-app-button-foreground);\n cursor: pointer;\n font: inherit;\n font-size: 21px;\n font-weight: 700;\n line-height: 1;\n padding: 0 0 2px;\n}\n\n.rivet-web-app-chat-send:disabled {\n cursor: default;\n opacity: 0.42;\n}\n\n@keyframes rivet-web-app-chat-thinking {\n 0%,\n 60%,\n 100% {\n transform: translateY(0);\n opacity: 0.35;\n }\n 30% {\n transform: translateY(-3px);\n opacity: 0.9;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .rivet-web-app-chat-thinking span {\n animation: none;\n }\n}\n\n@media (max-width: 600px) {\n .rivet-web-app-root {\n --rivet-web-app-chat-min-height: clamp(320px, calc(100vh - 64px), 540px);\n }\n\n .rivet-web-app-chat {\n border-radius: 10px;\n }\n\n .rivet-web-app-chat-message {\n max-width: 90%;\n }\n}\n\n.rivet-web-app-output {\n display: grid;\n gap: 8px;\n position: relative;\n}\n\n.rivet-web-app-output-title {\n color: var(--rivet-web-app-output-title);\n font-weight: 700;\n padding-right: 32px;\n}\n\n.rivet-web-app-output-has-download .rivet-web-app-output-title {\n padding-right: 64px;\n}\n\n.rivet-web-app-output-action-button {\n position: absolute;\n top: 11px;\n width: 24px;\n height: 24px;\n border: 0;\n border-radius: 5px;\n background: transparent;\n color: color-mix(in srgb, var(--rivet-web-app-foreground) 68%, transparent);\n cursor: pointer;\n padding: 0;\n}\n\n.rivet-web-app-output-copy-button {\n right: 11px;\n}\n\n.rivet-web-app-output-download-button {\n right: 39px;\n}\n\n.rivet-web-app-output-copy-button::before,\n.rivet-web-app-output-copy-button::after {\n content: \"\";\n position: absolute;\n width: 10px;\n height: 12px;\n border: 1.5px solid currentColor;\n border-radius: 2px;\n}\n\n.rivet-web-app-output-copy-button::before {\n top: 5px;\n left: 8px;\n}\n\n.rivet-web-app-output-copy-button::after {\n top: 8px;\n left: 5px;\n background: var(--rivet-web-app-card-background);\n}\n\n.rivet-web-app-output-download-button::before,\n.rivet-web-app-output-download-button::after {\n content: \"\";\n position: absolute;\n}\n\n.rivet-web-app-output-download-button::before {\n top: 5px;\n left: 8px;\n width: 8px;\n height: 8px;\n border-right: 1.5px solid currentColor;\n border-bottom: 1.5px solid currentColor;\n transform: rotate(45deg);\n}\n\n.rivet-web-app-output-download-button::after {\n top: 16px;\n left: 6px;\n width: 12px;\n height: 4px;\n border-right: 1.5px solid currentColor;\n border-bottom: 1.5px solid currentColor;\n border-left: 1.5px solid currentColor;\n border-radius: 0 0 2px 2px;\n}\n\n.rivet-web-app-output-action-button:hover,\n.rivet-web-app-output-action-button:focus-visible {\n color: var(--primary, #ff9e2c);\n outline: none;\n background: color-mix(in srgb, var(--rivet-web-app-foreground) 8%, transparent);\n}\n\n.rivet-web-app-output pre {\n margin: 0;\n background: transparent;\n border-radius: 0;\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace;\n font-size: inherit;\n padding: 0;\n white-space: pre-wrap;\n word-break: break-word;\n}\n\n.rivet-web-app-output-image {\n display: block;\n width: auto;\n max-width: 100%;\n height: auto;\n max-height: min(70vh, 720px);\n margin: 0 auto;\n border-radius: 6px;\n object-fit: contain;\n}\n\n.rivet-web-app-output-image-placeholder {\n color: color-mix(in srgb, var(--rivet-web-app-foreground) 56%, transparent);\n font-size: 13px;\n}\n\n.rivet-web-app-output-image-placeholder:empty {\n display: none;\n}\n\n.rivet-web-app-markdown,\n.rivet-web-app-output-markdown {\n word-break: break-word;\n}\n\n.rivet-web-app-markdown.markdown-body {\n background: transparent;\n font-family: inherit;\n min-width: 0;\n}\n\n.rivet-web-app-output-markdown.markdown-body {\n background: transparent;\n font-family: inherit;\n min-width: 0;\n}\n\n.rivet-web-app-markdown h1,\n.rivet-web-app-output-markdown h1 {\n margin: 0 0 12px;\n padding-bottom: 8px;\n border-bottom: 1px solid var(--rivet-web-app-card-border);\n font-size: 24px;\n line-height: 1.22;\n}\n\n.rivet-web-app-markdown h2,\n.rivet-web-app-output-markdown h2 {\n margin: 0 0 10px;\n font-size: 20px;\n line-height: 1.25;\n}\n\n.rivet-web-app-markdown p,\n.rivet-web-app-output-markdown p,\n.rivet-web-app-markdown ul,\n.rivet-web-app-output-markdown ul {\n margin: 0 0 12px;\n}\n\n.rivet-web-app-markdown.markdown-body code,\n.rivet-web-app-output-markdown.markdown-body code {\n border-radius: 4px;\n background: color-mix(in srgb, var(--rivet-web-app-control-background) 70%, var(--rivet-web-app-foreground) 6%);\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace;\n padding: 1px 4px;\n}\n\n.rivet-web-app-markdown.markdown-body pre,\n.rivet-web-app-output-markdown.markdown-body pre {\n background: transparent;\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace;\n padding: 0;\n white-space: pre-wrap;\n}\n\n.rivet-web-app-markdown > :first-child,\n.rivet-web-app-output-markdown > :first-child {\n margin-top: 0;\n}\n\n.rivet-web-app-markdown > :last-child,\n.rivet-web-app-output-markdown > :last-child {\n margin-bottom: 0;\n}\n\n.rivet-web-app-error {\n color: var(--rivet-web-app-error-color);\n font-weight: 700;\n}\n\n.rivet-web-app-modal-backdrop {\n position: fixed;\n inset: 0;\n z-index: 1000;\n display: grid;\n place-items: center;\n background: rgba(0, 0, 0, 0.46);\n background: color-mix(in srgb, var(--rivet-web-app-background) 78%, transparent);\n padding: 20px;\n}\n\n.rivet-web-app-modal {\n display: grid;\n gap: 18px;\n width: min(420px, 100%);\n border: 1px solid var(--rivet-web-app-card-border);\n border-radius: 12px;\n background: var(--rivet-web-app-card-background);\n box-shadow: 0 18px 60px rgba(0, 0, 0, 0.32);\n color: var(--rivet-web-app-foreground);\n padding: 22px;\n}\n\n.rivet-web-app-modal-message {\n font-size: 18px;\n font-weight: 700;\n line-height: 1.3;\n}\n\n.rivet-web-app-modal-button {\n justify-self: start;\n}\n\n.rivet-web-app-clipboard-fallback {\n position: fixed;\n top: 0;\n left: 0;\n width: 1px;\n height: 1px;\n opacity: 0;\n pointer-events: none;\n}\n";
|
|
2
2
|
export declare const RIVET_WEB_APP_DOCUMENT_CSS = "\nhtml,\nbody {\n height: 100%;\n margin: 0;\n}\n\nbody {\n min-height: 100vh;\n background: #1c222b;\n}\n\n#app {\n min-height: 100vh;\n}\n";
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
1
|
+
import { type UiComponentId, type UiGraph, type UiGraphActionComponent, type UiGraphChatMessage, type UiGraphComponent, type UiGraphGapSize, type UiGraphOutputRenderMode } from './UiGraph.js';
|
|
2
|
+
import { type GraphProgress } from './GraphProgress.js';
|
|
3
3
|
export type UiGraphOutputRenderModel = {
|
|
4
4
|
hasValue: boolean;
|
|
5
|
+
imageErrorMessage?: string;
|
|
6
|
+
imageSource?: string;
|
|
5
7
|
jsonDownloadValue?: string;
|
|
6
8
|
renderedValue: string;
|
|
7
9
|
renderAs: UiGraphOutputRenderMode;
|
|
@@ -18,6 +20,12 @@ export type UiGraphComponentRenderModel = {
|
|
|
18
20
|
}>;
|
|
19
21
|
markdown: string;
|
|
20
22
|
type: 'markdown';
|
|
23
|
+
} | {
|
|
24
|
+
component: Extract<UiGraphComponent, {
|
|
25
|
+
type: 'gap';
|
|
26
|
+
}>;
|
|
27
|
+
size: UiGraphGapSize;
|
|
28
|
+
type: 'gap';
|
|
21
29
|
} | {
|
|
22
30
|
component: Extract<UiGraphComponent, {
|
|
23
31
|
type: 'input' | 'textarea';
|
|
@@ -31,6 +39,13 @@ export type UiGraphComponentRenderModel = {
|
|
|
31
39
|
}>;
|
|
32
40
|
label: string;
|
|
33
41
|
type: 'button';
|
|
42
|
+
} | {
|
|
43
|
+
component: Extract<UiGraphComponent, {
|
|
44
|
+
type: 'chat';
|
|
45
|
+
}>;
|
|
46
|
+
draft: string;
|
|
47
|
+
messages: UiGraphChatMessage[];
|
|
48
|
+
type: 'chat';
|
|
34
49
|
} | {
|
|
35
50
|
component: Extract<UiGraphComponent, {
|
|
36
51
|
type: 'output';
|
|
@@ -39,13 +54,70 @@ export type UiGraphComponentRenderModel = {
|
|
|
39
54
|
output: UiGraphOutputRenderModel;
|
|
40
55
|
type: 'output';
|
|
41
56
|
};
|
|
42
|
-
export
|
|
57
|
+
export type UiGraphActionExecution = Readonly<{
|
|
58
|
+
componentId: UiComponentId;
|
|
59
|
+
id: number;
|
|
60
|
+
}>;
|
|
61
|
+
export type UiGraphActionExecutionController = {
|
|
62
|
+
begin(component: UiGraphActionComponent): UiGraphActionExecution | undefined;
|
|
63
|
+
finish(execution: UiGraphActionExecution): boolean;
|
|
64
|
+
isCurrent(execution: UiGraphActionExecution): boolean;
|
|
65
|
+
isRunning(componentId: UiComponentId): boolean;
|
|
66
|
+
noteStateWrite(stateKey: string): void;
|
|
67
|
+
resolveStatePatch(execution: UiGraphActionExecution, statePatch: Record<string, unknown> | undefined): Record<string, unknown> | undefined;
|
|
68
|
+
reset(): void;
|
|
69
|
+
};
|
|
70
|
+
export type UiGraphInteractionChange = 'action' | 'graph' | 'state';
|
|
71
|
+
export type UiGraphInteractionSnapshot = Readonly<{
|
|
72
|
+
actionErrors: Readonly<Record<string, string>>;
|
|
73
|
+
actionProgress: Readonly<Record<string, GraphProgress>>;
|
|
74
|
+
runningComponentIds: ReadonlySet<UiComponentId>;
|
|
75
|
+
state: Readonly<Record<string, unknown>>;
|
|
76
|
+
}>;
|
|
77
|
+
export type UiGraphActionRunContext = Readonly<{
|
|
78
|
+
abortOtherActions(): void;
|
|
79
|
+
componentId: UiComponentId;
|
|
80
|
+
reportProgress(progress: GraphProgress): void;
|
|
81
|
+
signal: AbortSignal;
|
|
82
|
+
state: Record<string, unknown>;
|
|
83
|
+
}>;
|
|
84
|
+
export type UiGraphActionRunResult = {
|
|
85
|
+
statePatch?: Record<string, unknown>;
|
|
86
|
+
};
|
|
87
|
+
export type UiGraphActionRunner = (context: UiGraphActionRunContext) => Promise<UiGraphActionRunResult>;
|
|
88
|
+
export type UiGraphInteractionController = {
|
|
89
|
+
abortActions(): void;
|
|
90
|
+
cancelAction(componentId: UiComponentId): void;
|
|
91
|
+
detachActions(): void;
|
|
92
|
+
getSnapshot(): UiGraphInteractionSnapshot;
|
|
93
|
+
runAction(component: UiGraphActionComponent, runner: UiGraphActionRunner): Promise<void>;
|
|
94
|
+
setUiGraph(uiGraph: UiGraph): void;
|
|
95
|
+
subscribe(listener: (change: UiGraphInteractionChange) => void): () => void;
|
|
96
|
+
updateState(stateKey: string, value: unknown): void;
|
|
97
|
+
updateStatePatch(statePatch: Record<string, unknown>): void;
|
|
98
|
+
};
|
|
99
|
+
export type UiGraphInteractionControllerOptions = {
|
|
100
|
+
initialState?: Record<string, unknown>;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Coordinates independent web-app actions without allowing older completions to
|
|
104
|
+
* clear newer loading states or overwrite newer writes to the same UI state key.
|
|
105
|
+
*/
|
|
106
|
+
export declare function createUiGraphActionExecutionController(): UiGraphActionExecutionController;
|
|
107
|
+
/**
|
|
108
|
+
* Owns mutable web-app interaction state for every renderer. React and direct
|
|
109
|
+
* DOM hosts subscribe to this controller instead of reimplementing action
|
|
110
|
+
* cancellation, loading/error state, and stale state-patch protection.
|
|
111
|
+
*/
|
|
112
|
+
export declare function createUiGraphInteractionController(initialUiGraph: UiGraph, options?: UiGraphInteractionControllerOptions): UiGraphInteractionController;
|
|
113
|
+
export declare function getUiGraphComponentRenderModel(component: UiGraphComponent, state: Readonly<Record<string, unknown>>): UiGraphComponentRenderModel;
|
|
43
114
|
export declare function getUiGraphComponentLabel(component: Extract<UiGraphComponent, {
|
|
44
115
|
type: 'input' | 'textarea' | 'output';
|
|
45
116
|
}>): string;
|
|
46
|
-
export declare function getUiGraphOutputRenderModel(state: Record<string, unknown
|
|
47
|
-
export declare function hasUiGraphStateValue(state: Record<string, unknown
|
|
117
|
+
export declare function getUiGraphOutputRenderModel(state: Readonly<Record<string, unknown>>, stateKey: string, renderAs: UiGraphOutputRenderMode): UiGraphOutputRenderModel;
|
|
118
|
+
export declare function hasUiGraphStateValue(state: Readonly<Record<string, unknown>>, key: string): boolean;
|
|
48
119
|
export declare function renderUiGraphOutputValue(value: unknown, renderAs: UiGraphOutputRenderMode): string;
|
|
120
|
+
export declare function getUiGraphImageSource(value: unknown): string | undefined;
|
|
49
121
|
export declare function stringifyUiGraphValue(value: unknown): string | undefined;
|
|
50
122
|
export declare function getUiGraphJsonOutputFilename(appName: string, date?: Date): string;
|
|
51
123
|
export declare function formatUiGraphDownloadDateTime(date: Date): string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ExternalFunction } from './GraphProcessor.js';
|
|
2
|
+
export declare const RIVET_WEB_APP_STATUS_FUNCTION_NAME = "setWebAppStatus";
|
|
3
|
+
/** Built-in External Call function used to report web-app status. */
|
|
4
|
+
export declare const rivetWebAppStatusExternalFunction: ExternalFunction;
|
|
5
|
+
export declare function formatRivetWebAppStatusMessage(value: unknown): string;
|
|
@@ -8,7 +8,6 @@ export type ArrayNodeData = {
|
|
|
8
8
|
flattenDeep?: boolean;
|
|
9
9
|
};
|
|
10
10
|
export declare class ArrayNodeImpl extends NodeImpl<ArrayNode> {
|
|
11
|
-
#private;
|
|
12
11
|
static create(): ArrayNode;
|
|
13
12
|
getInputDefinitions(connections: NodeConnection[]): NodeInputDefinition[];
|
|
14
13
|
getOutputDefinitions(): NodeOutputDefinition[];
|
|
@@ -11,7 +11,6 @@ export type AssembleMessageNodeData = {
|
|
|
11
11
|
useToolCallIdInput?: boolean;
|
|
12
12
|
};
|
|
13
13
|
export declare class AssembleMessageNodeImpl extends NodeImpl<AssembleMessageNode> {
|
|
14
|
-
#private;
|
|
15
14
|
static create(): AssembleMessageNode;
|
|
16
15
|
getInputDefinitions(connections: NodeConnection[]): NodeInputDefinition[];
|
|
17
16
|
getOutputDefinitions(): NodeOutputDefinition[];
|
|
@@ -11,7 +11,6 @@ export type AssemblePromptNodeData = {
|
|
|
11
11
|
useIsLastMessageCacheBreakpointInput?: boolean;
|
|
12
12
|
};
|
|
13
13
|
export declare class AssemblePromptNodeImpl extends NodeImpl<AssemblePromptNode> {
|
|
14
|
-
#private;
|
|
15
14
|
static create(): AssemblePromptNode;
|
|
16
15
|
getInputDefinitions(connections: NodeConnection[]): NodeInputDefinition[];
|
|
17
16
|
getOutputDefinitions(): NodeOutputDefinition[];
|
|
@@ -8,7 +8,6 @@ export type DelayNodeData = {
|
|
|
8
8
|
useDelayInput?: boolean;
|
|
9
9
|
};
|
|
10
10
|
export declare class DelayNodeImpl extends NodeImpl<DelayNode> {
|
|
11
|
-
#private;
|
|
12
11
|
static create(): DelayNode;
|
|
13
12
|
getInputDefinitions(connections: NodeConnection[]): NodeInputDefinition[];
|
|
14
13
|
getOutputDefinitions(connections: NodeConnection[]): NodeOutputDefinition[];
|
|
@@ -5,7 +5,6 @@ import { type EditorDefinition } from '../EditorDefinition.js';
|
|
|
5
5
|
export type DidRunNode = ChartNode<'didRun', DidRunNodeData>;
|
|
6
6
|
export type DidRunNodeData = {};
|
|
7
7
|
export declare class DidRunNodeImpl extends NodeImpl<DidRunNode> {
|
|
8
|
-
#private;
|
|
9
8
|
static create(): DidRunNode;
|
|
10
9
|
getInputDefinitions(connections: NodeConnection[]): NodeInputDefinition[];
|
|
11
10
|
getOutputDefinitions(): NodeOutputDefinition[];
|
|
@@ -9,7 +9,6 @@ export type JoinNodeData = {
|
|
|
9
9
|
useJoinStringInput?: boolean;
|
|
10
10
|
};
|
|
11
11
|
export declare class JoinNodeImpl extends NodeImpl<JoinNode> {
|
|
12
|
-
#private;
|
|
13
12
|
static create: () => JoinNode;
|
|
14
13
|
getInputDefinitions(connections: NodeConnection[]): NodeInputDefinition[];
|
|
15
14
|
getOutputDefinitions(): NodeOutputDefinition[];
|
|
@@ -9,7 +9,6 @@ export type LoopControllerNodeData = {
|
|
|
9
9
|
atMaxIterationsAction?: 'break' | 'error';
|
|
10
10
|
};
|
|
11
11
|
export declare class LoopControllerNodeImpl extends NodeImpl<LoopControllerNode> {
|
|
12
|
-
#private;
|
|
13
12
|
static create(): LoopControllerNode;
|
|
14
13
|
getInputDefinitions(connections: NodeConnection[], nodes: Record<NodeId, ChartNode>): NodeInputDefinition[];
|
|
15
14
|
getOutputDefinitions(connections: NodeConnection[], nodes: Record<NodeId, ChartNode>): NodeOutputDefinition[];
|
|
@@ -4,7 +4,6 @@ import { type Inputs, type Outputs } from '../GraphProcessor.js';
|
|
|
4
4
|
export type PassthroughNode = ChartNode<'passthrough', PassthroughNodeData>;
|
|
5
5
|
export type PassthroughNodeData = {};
|
|
6
6
|
export declare class PassthroughNodeImpl extends NodeImpl<PassthroughNode> {
|
|
7
|
-
#private;
|
|
8
7
|
static create: () => PassthroughNode;
|
|
9
8
|
getInputDefinitions(connections: NodeConnection[]): NodeInputDefinition[];
|
|
10
9
|
getOutputDefinitions(connections: NodeConnection[]): NodeOutputDefinition[];
|
|
@@ -5,7 +5,6 @@ import { type EditorDefinition } from '../../index.js';
|
|
|
5
5
|
export type RaceInputsNode = ChartNode<'raceInputs', RaceInputsNodeData>;
|
|
6
6
|
export type RaceInputsNodeData = {};
|
|
7
7
|
export declare class RaceInputsNodeImpl extends NodeImpl<RaceInputsNode> {
|
|
8
|
-
#private;
|
|
9
8
|
static create(): RaceInputsNode;
|
|
10
9
|
getInputDefinitions(connections: NodeConnection[]): NodeInputDefinition[];
|
|
11
10
|
getOutputDefinitions(): NodeOutputDefinition[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { DataValue } from '../DataValue.js';
|
|
2
|
+
import type { EditorDefinition } from '../EditorDefinition.js';
|
|
3
|
+
import type { Inputs } from '../GraphProcessor.js';
|
|
4
|
+
import type { ChartNode, NodeInputDefinition, NodeOutputDefinition } from '../NodeBase.js';
|
|
5
|
+
import { NodeImpl, type NodeUIData } from '../NodeImpl.js';
|
|
6
|
+
import type { InternalProcessContext } from '../ProcessContext.js';
|
|
7
|
+
export type ReportProgressNode = ChartNode<'reportProgress', ReportProgressNodeData>;
|
|
8
|
+
export type ReportProgressNodeData = {
|
|
9
|
+
message: string;
|
|
10
|
+
percent?: number;
|
|
11
|
+
useMessageInput: boolean;
|
|
12
|
+
usePercentInput: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare class ReportProgressNodeImpl extends NodeImpl<ReportProgressNode> {
|
|
15
|
+
static create(): ReportProgressNode;
|
|
16
|
+
getInputDefinitions(): NodeInputDefinition[];
|
|
17
|
+
getOutputDefinitions(): NodeOutputDefinition[];
|
|
18
|
+
getEditors(): EditorDefinition<ReportProgressNode>[];
|
|
19
|
+
getBody(): string;
|
|
20
|
+
static getUIData(): NodeUIData;
|
|
21
|
+
process(inputs: Inputs, context: InternalProcessContext): Promise<Record<string, DataValue>>;
|
|
22
|
+
}
|
|
23
|
+
export declare const reportProgressNode: import("../NodeDefinition.js").NodeDefinition<ReportProgressNode>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { NodeConnection, NodeId } from '../NodeBase.js';
|
|
2
|
+
export type VariadicPortIndexPolicy = 'legacy' | 'decimal' | 'strict-positive';
|
|
3
|
+
export declare function getHighestVariadicPortIndex(connections: readonly NodeConnection[], inputNodeId: NodeId, prefix: string, policy: VariadicPortIndexPolicy): number;
|
|
4
|
+
export declare function getNextVariadicPortIndex(connections: readonly NodeConnection[], inputNodeId: NodeId, prefix: string, policy: VariadicPortIndexPolicy): number;
|
|
@@ -79,6 +79,11 @@ export type RecordedEventsMap = OverrideProperties<ProcessEvents, {
|
|
|
79
79
|
index: number;
|
|
80
80
|
processId: ProcessId;
|
|
81
81
|
}>;
|
|
82
|
+
progress: WithOptionalExecution<{
|
|
83
|
+
nodeId: NodeId;
|
|
84
|
+
processId: ProcessId;
|
|
85
|
+
progress: ProcessEvents['progress']['progress'];
|
|
86
|
+
}>;
|
|
82
87
|
/** Called when the outputs of a node have been cleared entirely. If processId is present, only the one process() should be cleared. */
|
|
83
88
|
nodeOutputsCleared: WithOptionalExecution<{
|
|
84
89
|
nodeId: NodeId;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
export type { UiComponentId, UiGraph, UiGraphComponent } from './model/UiGraph.js';
|
|
1
|
+
export type { UiComponentId, UiGraph, UiGraphActionComponent, UiGraphChatMessage, UiGraphComponent, } from './model/UiGraph.js';
|
|
2
|
+
export type { UiGraphInteractionSnapshot } from './model/UiGraphRuntimeModel.js';
|
|
3
|
+
export type { RivetWebAppClientMessage, RivetWebAppRunEvent, RivetWebAppServerMessage, } from './model/UiGraphActionProtocol.js';
|
|
4
|
+
export type { GraphProgress } from './model/GraphProgress.js';
|
|
2
5
|
export type { RivetMarkdownSanitizerPolicy } from './model/MarkdownSanitizationPolicy.js';
|
|
3
|
-
export { getUiGraphActionState } from './model/UiGraph.js';
|
|
4
|
-
export { applyUiGraphStatePatch, getUiGraphComponentRenderModel, getUiGraphJsonOutputFilename, } from './model/UiGraphRuntimeModel.js';
|
|
6
|
+
export { createUiGraphChatSubmissionStatePatch, getUiGraphActionState, getUiGraphChatDraftStateKey, } from './model/UiGraph.js';
|
|
7
|
+
export { applyUiGraphStatePatch, createUiGraphActionExecutionController, createUiGraphInteractionController, getUiGraphComponentRenderModel, getUiGraphJsonOutputFilename, } from './model/UiGraphRuntimeModel.js';
|
|
8
|
+
export { parseRivetWebAppClientMessage, parseRivetWebAppServerMessage, RIVET_WEB_APP_ACTION_PROTOCOL_VERSION, } from './model/UiGraphActionProtocol.js';
|
|
9
|
+
export { copyUiGraphText, downloadUiGraphJsonOutput } from './model/UiGraphBrowserRuntime.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@valerypopoff/rivet2-core",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/cjs/bundle.cjs",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"./web-app-runtime": {
|
|
28
28
|
"types": "./dist/types/webAppRuntime.d.ts",
|
|
29
29
|
"import": "./dist/esm/webAppRuntime.js",
|
|
30
|
-
"require": "./dist/cjs/
|
|
30
|
+
"require": "./dist/cjs/webAppRuntime.cjs"
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"files": [
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_CHAT_NODE_TIMEOUT } from '../../utils/defaults.js';
|
|
2
|
-
// https://github.com/openai/openai-node/issues/18#issuecomment-1518715285
|
|
3
|
-
export class EventSourceResponse extends Response {
|
|
4
|
-
name;
|
|
5
|
-
streams;
|
|
6
|
-
constructor(body, init) {
|
|
7
|
-
if (body == null) {
|
|
8
|
-
super(null, init);
|
|
9
|
-
this.name = 'EventSourceResponse';
|
|
10
|
-
this.streams = null;
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
const [bodyForString, bodyForEvents] = body.tee();
|
|
14
|
-
const streams = createEventStream(bodyForEvents);
|
|
15
|
-
// By passing our transformed stream into the Response constructor, we prevent anyone
|
|
16
|
-
// from accidentally accessing the raw response.body stream.
|
|
17
|
-
super(bodyForString, init);
|
|
18
|
-
this.name = 'EventSourceResponse';
|
|
19
|
-
this.streams = streams;
|
|
20
|
-
}
|
|
21
|
-
async *events() {
|
|
22
|
-
if (this.streams == null) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const reader = this.streams.eventStream.getReader();
|
|
26
|
-
try {
|
|
27
|
-
while (true) {
|
|
28
|
-
const { done, value } = await this.raceWithTimeout(reader.read(), DEFAULT_CHAT_NODE_TIMEOUT);
|
|
29
|
-
if (done) {
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
yield value;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
finally {
|
|
36
|
-
reader.releaseLock();
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
async raceWithTimeout(promise, timeout = 5000) {
|
|
40
|
-
// eslint-disable-next-line no-async-promise-executor,@typescript-eslint/no-misused-promises -- Error handled correctly
|
|
41
|
-
return new Promise(async (resolve, reject) => {
|
|
42
|
-
const timer = setTimeout(() => {
|
|
43
|
-
reject(new Error('Timeout: API response took too long.'));
|
|
44
|
-
}, timeout);
|
|
45
|
-
try {
|
|
46
|
-
const result = await promise;
|
|
47
|
-
clearTimeout(timer);
|
|
48
|
-
resolve(result);
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
clearTimeout(timer);
|
|
52
|
-
reject(error);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
export default async function fetchEventSource(url, init) {
|
|
58
|
-
const headers = {
|
|
59
|
-
...init?.headers,
|
|
60
|
-
accept: 'text/event-stream',
|
|
61
|
-
};
|
|
62
|
-
const response = await fetch(url, {
|
|
63
|
-
...init,
|
|
64
|
-
headers,
|
|
65
|
-
});
|
|
66
|
-
return new EventSourceResponse(response.body, response);
|
|
67
|
-
}
|
|
68
|
-
class LineSplitter {
|
|
69
|
-
separator;
|
|
70
|
-
buffer = '';
|
|
71
|
-
constructor(separator = /\n+/) {
|
|
72
|
-
this.separator = separator;
|
|
73
|
-
}
|
|
74
|
-
transform(chunk, controller) {
|
|
75
|
-
this.buffer += chunk;
|
|
76
|
-
const lines = this.buffer.split(this.separator);
|
|
77
|
-
this.buffer = lines.pop() ?? '';
|
|
78
|
-
for (const line of lines) {
|
|
79
|
-
controller.enqueue(line);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
flush(controller) {
|
|
83
|
-
if (this.buffer.length > 0) {
|
|
84
|
-
controller.enqueue(this.buffer);
|
|
85
|
-
this.buffer = '';
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
function createEventStream(body) {
|
|
90
|
-
if (body == null) {
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
const textStream = body.pipeThrough(new TextDecoderStream());
|
|
94
|
-
const eventStream = textStream.pipeThrough(new TransformStream(new LineSplitter())).pipeThrough(new TransformStream({
|
|
95
|
-
transform(line, controller) {
|
|
96
|
-
if (line.startsWith('data: ')) {
|
|
97
|
-
const data = line.slice(6).trim();
|
|
98
|
-
controller.enqueue(data);
|
|
99
|
-
}
|
|
100
|
-
else if (line.startsWith('event: ')) {
|
|
101
|
-
const event = line.slice(7).trim();
|
|
102
|
-
controller.enqueue(`[${event}]`);
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
}));
|
|
106
|
-
return { eventStream, textStream };
|
|
107
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare class EventSourceResponse extends Response {
|
|
2
|
-
name: string;
|
|
3
|
-
readonly streams: {
|
|
4
|
-
eventStream: ReadableStream<string>;
|
|
5
|
-
textStream: ReadableStream<string>;
|
|
6
|
-
} | null;
|
|
7
|
-
constructor(body: ReadableStream<Uint8Array> | null, init?: ResponseInit);
|
|
8
|
-
events(): AsyncGenerator<string>;
|
|
9
|
-
private raceWithTimeout;
|
|
10
|
-
}
|
|
11
|
-
export default function fetchEventSource(url: string, init?: RequestInit): Promise<EventSourceResponse>;
|