@opengeni/react 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +86 -4
- package/dist/index.js +330 -153
- package/dist/index.js.map +1 -1
- package/package.json +9 -2
- package/src/client.ts +2 -0
- package/src/components/chat-composer.tsx +28 -2
- package/src/components/markdown.tsx +170 -0
- package/src/components/message-timeline.tsx +21 -5
- package/src/components/model-picker.tsx +87 -0
- package/src/hooks/use-available-models.ts +39 -0
- package/src/index.ts +6 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { OpenGeniClient, Session, ResourceRef, ToolRef, SessionStatus as SessionStatus$1, SessionEvent, StreamConnectionState, SendMessageInput, FileAsset, FileResourceRef, SessionTurn, UpdateSessionTurnRequest, SessionGoal, ScheduledTask, WorkspaceEnvironment, CreateWorkspaceEnvironmentRequest, UpdateWorkspaceEnvironmentRequest, WorkspaceEnvironmentVariableMetadata, CapabilityPack, PackInstallation, RegisterCapabilityPackRequest, WorkspaceRegisteredPack, EnablePackRequest, Workspace, CreateWorkspaceRequest, UpdateWorkspaceRequest, BillingBalance, UsageEvent, Permission } from '@opengeni/sdk';
|
|
1
|
+
import { OpenGeniClient, Session, ResourceRef, ToolRef, SessionStatus as SessionStatus$1, SessionEvent, StreamConnectionState, SendMessageInput, FileAsset, FileResourceRef, SessionTurn, UpdateSessionTurnRequest, SessionGoal, ScheduledTask, WorkspaceEnvironment, CreateWorkspaceEnvironmentRequest, UpdateWorkspaceEnvironmentRequest, WorkspaceEnvironmentVariableMetadata, CapabilityPack, PackInstallation, RegisterCapabilityPackRequest, WorkspaceRegisteredPack, EnablePackRequest, Workspace, CreateWorkspaceRequest, UpdateWorkspaceRequest, BillingBalance, UsageEvent, ClientModel, Permission } from '@opengeni/sdk';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import * as react from 'react';
|
|
3
4
|
import { ReactNode, KeyboardEvent, ClipboardEvent } from 'react';
|
|
4
5
|
import { ClassValue } from 'clsx';
|
|
5
6
|
|
|
@@ -8,7 +9,7 @@ import { ClassValue } from 'clsx';
|
|
|
8
9
|
* pass the real SDK client, a proxy-backed client that routes through their
|
|
9
10
|
* own API, or a scripted client in tests/demos.
|
|
10
11
|
*/
|
|
11
|
-
type SessionClientLike = Pick<OpenGeniClient, "getSession" | "listSessions" | "sendMessage" | "steerMessage" | "interrupt" | "sendApprovalDecision" | "streamEvents" | "listTurns" | "updateQueuedTurn" | "reorderQueuedTurns" | "deleteQueuedTurn" | "getGoal" | "updateGoal" | "clearSessionContext" | "compactSessionContext" | "listScheduledTasks" | "uploadFile" | "getFile" | "createFileDownloadUrl" | "listEnvironments" | "createEnvironment" | "updateEnvironment" | "deleteEnvironment" | "setEnvironmentVariable" | "deleteEnvironmentVariable" | "listPacks" | "registerPack" | "enablePack" | "deletePack" | "listWorkspaces" | "createWorkspace" | "updateWorkspace" | "getBillingUsage">;
|
|
12
|
+
type SessionClientLike = Pick<OpenGeniClient, "getClientConfig" | "getSession" | "listSessions" | "sendMessage" | "steerMessage" | "interrupt" | "sendApprovalDecision" | "streamEvents" | "listTurns" | "updateQueuedTurn" | "reorderQueuedTurns" | "deleteQueuedTurn" | "getGoal" | "updateGoal" | "clearSessionContext" | "compactSessionContext" | "listScheduledTasks" | "uploadFile" | "getFile" | "createFileDownloadUrl" | "listEnvironments" | "createEnvironment" | "updateEnvironment" | "deleteEnvironment" | "setEnvironmentVariable" | "deleteEnvironmentVariable" | "listPacks" | "registerPack" | "enablePack" | "deletePack" | "listWorkspaces" | "createWorkspace" | "updateWorkspace" | "getBillingUsage">;
|
|
12
13
|
|
|
13
14
|
type OpenGeniContextValue = {
|
|
14
15
|
client: SessionClientLike;
|
|
@@ -538,6 +539,28 @@ type UseBillingUsageResult = {
|
|
|
538
539
|
*/
|
|
539
540
|
declare function useBillingUsage(options?: UseBillingUsageOptions): UseBillingUsageResult;
|
|
540
541
|
|
|
542
|
+
type UseAvailableModelsOptions = Pick<ClientOverride, "client"> & {
|
|
543
|
+
/** Refresh interval (ms). Off by default — the host model list rarely moves. */
|
|
544
|
+
pollIntervalMs?: number | undefined;
|
|
545
|
+
enabled?: boolean | undefined;
|
|
546
|
+
};
|
|
547
|
+
type UseAvailableModelsResult = {
|
|
548
|
+
/** The provider-grouped models the host exposes (empty until loaded). */
|
|
549
|
+
models: ClientModel[];
|
|
550
|
+
/** The deployment's default model id, null until loaded. */
|
|
551
|
+
defaultModel: string | null;
|
|
552
|
+
loading: boolean;
|
|
553
|
+
error: Error | null;
|
|
554
|
+
refresh: () => Promise<void>;
|
|
555
|
+
};
|
|
556
|
+
/**
|
|
557
|
+
* The host-exposed model list for a <ModelPicker>: fetches the deployment's
|
|
558
|
+
* public client config (`GET /v1/config/client`) and surfaces the richer
|
|
559
|
+
* provider-grouped `models` plus the `defaultModel` the picker should preselect.
|
|
560
|
+
* Deployment-scoped, so it only needs the client (no workspace).
|
|
561
|
+
*/
|
|
562
|
+
declare function useAvailableModels(options?: UseAvailableModelsOptions): UseAvailableModelsResult;
|
|
563
|
+
|
|
541
564
|
type PendingApproval = {
|
|
542
565
|
/** The id to send back via `user.approvalDecision` (`approvalId`). */
|
|
543
566
|
id: string;
|
|
@@ -785,6 +808,20 @@ type ChatComposerProps = {
|
|
|
785
808
|
* Absent → no attachment UI renders and the composer behaves exactly as before.
|
|
786
809
|
*/
|
|
787
810
|
attachments?: UseFileAttachmentsResult | undefined;
|
|
811
|
+
/**
|
|
812
|
+
* Opt-in model picker. When supplied (e.g. from {@link useAvailableModels}),
|
|
813
|
+
* the composer renders a {@link ModelPicker} at the start of `controlsStart`
|
|
814
|
+
* so the operator can choose which host-exposed model serves the next message.
|
|
815
|
+
* The host owns the selection (`selectedModel`/`onSelectModel`) and is
|
|
816
|
+
* responsible for threading it into the composer's `sendExtras` (typically
|
|
817
|
+
* `useComposer({ sendExtras: () => ({ model }) })`) so `composeSendInput`
|
|
818
|
+
* carries it. Absent → no picker renders and the composer behaves as before.
|
|
819
|
+
*/
|
|
820
|
+
models?: ClientModel[] | undefined;
|
|
821
|
+
/** The currently selected model id (the picker's controlled value). */
|
|
822
|
+
selectedModel?: string | undefined;
|
|
823
|
+
/** Called with the chosen model id when the operator picks one. */
|
|
824
|
+
onSelectModel?: ((modelId: string) => void) | undefined;
|
|
788
825
|
className?: string | undefined;
|
|
789
826
|
/**
|
|
790
827
|
* Slash-command palette. Defaults to the built-in {@link defaultCommands};
|
|
@@ -811,7 +848,30 @@ type ChatComposerProps = {
|
|
|
811
848
|
* the agent. The palette is purely additive: with no `commandContext` it is
|
|
812
849
|
* inert and the composer behaves exactly as before.
|
|
813
850
|
*/
|
|
814
|
-
declare function ChatComposer({ composer, status, placeholder, disabled, autoFocus, hint, controlsStart, header, onPaste, attachments, className, commands, commandContext, onClearView, }: ChatComposerProps): react_jsx_runtime.JSX.Element;
|
|
851
|
+
declare function ChatComposer({ composer, status, placeholder, disabled, autoFocus, hint, controlsStart, header, onPaste, attachments, models, selectedModel, onSelectModel, className, commands, commandContext, onClearView, }: ChatComposerProps): react_jsx_runtime.JSX.Element;
|
|
852
|
+
|
|
853
|
+
type ModelPickerProps = {
|
|
854
|
+
/** The host-exposed models to choose from (typically {@link useAvailableModels}). */
|
|
855
|
+
models: ClientModel[];
|
|
856
|
+
/** Controlled selection — the model id, or undefined for "nothing chosen yet". */
|
|
857
|
+
value?: string | undefined;
|
|
858
|
+
/** Called with the chosen model id when the operator picks a row. */
|
|
859
|
+
onChange: (modelId: string) => void;
|
|
860
|
+
disabled?: boolean | undefined;
|
|
861
|
+
className?: string | undefined;
|
|
862
|
+
};
|
|
863
|
+
/**
|
|
864
|
+
* The model picker — a compact dropdown for the composer footer, grouping the
|
|
865
|
+
* host-exposed models by `providerLabel` (so "OpenAI" and "Fireworks AI" head
|
|
866
|
+
* their own sections) and showing each model's display `label`. A native
|
|
867
|
+
* `<select>` keeps it keyboard- and screen-reader-accessible for free and
|
|
868
|
+
* themes via the package's og-* tokens; the chevron is a decorative overlay.
|
|
869
|
+
*
|
|
870
|
+
* Controlled: the host owns `value`/`onChange` and threads the selection into
|
|
871
|
+
* the send path. Renders nothing when no models are exposed, so a single-model
|
|
872
|
+
* deployment shows no chrome.
|
|
873
|
+
*/
|
|
874
|
+
declare function ModelPicker({ models, value, onChange, disabled, className }: ModelPickerProps): react_jsx_runtime.JSX.Element | null;
|
|
815
875
|
|
|
816
876
|
type MessageTimelineProps = {
|
|
817
877
|
/** Raw session events (projected internally) … */
|
|
@@ -837,6 +897,28 @@ type MessageTimelineProps = {
|
|
|
837
897
|
*/
|
|
838
898
|
declare function MessageTimeline({ events, items, status, renderMessageText, onOpenSession, autoFollow, emptyState, className, }: MessageTimelineProps): react_jsx_runtime.JSX.Element;
|
|
839
899
|
|
|
900
|
+
/**
|
|
901
|
+
* The default renderer for chat message bodies in {@link MessageTimeline}.
|
|
902
|
+
*
|
|
903
|
+
* Agent (and user) messages arrive as GitHub-flavored markdown. This turns the
|
|
904
|
+
* raw text into styled HTML using `react-markdown` + `remark-gfm`, themed to the
|
|
905
|
+
* package's `og-*` design tokens so it reads as one cohesive dark surface — no
|
|
906
|
+
* stock Tailwind colors leak in.
|
|
907
|
+
*
|
|
908
|
+
* It re-parses on every render, which is exactly right for streaming: a body
|
|
909
|
+
* that is still arriving (an unterminated `**`, a half-open code fence, a table
|
|
910
|
+
* mid-row) renders as best-effort markdown and resolves cleanly as the rest of
|
|
911
|
+
* the tokens land. Consumers who want a different renderer can still pass
|
|
912
|
+
* `renderMessageText` to `MessageTimeline` to override this entirely.
|
|
913
|
+
*/
|
|
914
|
+
type MarkdownProps = {
|
|
915
|
+
children: string;
|
|
916
|
+
className?: string | undefined;
|
|
917
|
+
};
|
|
918
|
+
declare function MarkdownImpl({ children, className }: MarkdownProps): react_jsx_runtime.JSX.Element;
|
|
919
|
+
/** Memoized so streaming re-renders of the parent don't re-parse settled bodies. */
|
|
920
|
+
declare const Markdown: react.MemoExoticComponent<typeof MarkdownImpl>;
|
|
921
|
+
|
|
840
922
|
type SessionStatusMeta = {
|
|
841
923
|
label: string;
|
|
842
924
|
/** Token-backed color classes for the dot and tinted badge. */
|
|
@@ -894,4 +976,4 @@ declare function stringifyPayload(value: unknown): string;
|
|
|
894
976
|
/** JSON.parse that returns `undefined` instead of throwing. */
|
|
895
977
|
declare function tryParseJson(text: string): unknown;
|
|
896
978
|
|
|
897
|
-
export { type AgentMessageItem, ChatComposer, type ChatComposerProps, type ClientOverride, type CommandContext, CommandPalette, type CommandPaletteProps, type CommandResult, type ComposerMode, type ComposerSendExtras, type ComposerState, type ConfirmState, type FileAttachment, FleetTile, type FleetTileProps, type GoalItem, MessageTimeline, type MessageTimelineProps, type Notice, type NoticeItem, type OpenGeniContextValue, OpenGeniProvider, type OpenGeniProviderProps, type ParsedCommandLine, type PendingApproval, type ReasoningItem, SESSION_STATUS_META, type SandboxItem, type SessionClientLike, type SessionEventsConnectionState, SessionStatus, type SessionStatusItem, type SessionStatusMeta, type SessionStatusProps, type SlashArg, type SlashCommand, type SlashCommandContext, type SlashCommandHandlers, StatusDot, type StatusDotProps, type TimelineGroup, type TimelineItem, type ToolCallItem, type UseBillingUsageOptions, type UseBillingUsageResult, type UseComposerOptions, type UseEnvironmentsOptions, type UseEnvironmentsResult, type UseFileAttachmentsOptions, type UseFileAttachmentsResult, type UseGoalOptions, type UseGoalResult, type UsePacksOptions, type UsePacksResult, type UseScheduledTasksOptions, type UseScheduledTasksResult, type UseSessionControlOptions, type UseSessionControlResult, type UseSessionEventsOptions, type UseSessionEventsResult, type UseSessionOptions, type UseSessionResult, type UseSlashCommandsOptions, type UseSlashCommandsResult, type UseTurnQueueOptions, type UseTurnQueueResult, type UseWorkspaceSessionsOptions, type UseWorkspaceSessionsResult, type UseWorkspacesOptions, type UseWorkspacesResult, type UserMessageItem, type WorkerItem, activeTurnFromTurns, applyTurnEdit, applyTurnRemoval, applyTurnReorder, approvalsFromRequiresAction, argHint, buildTimeline, cn, compactPayloadPreview, composeSendInput, defaultCommands, extractSessionRef, filterCommands, firstMissingRequiredArg, formatBytes, formatRelativeTime, groupTimeline, hasPermission, isGoalEvent, isTurnQueueEvent, matchCommand, parseCommandLine, projectPendingApprovals, queueFromTurns, sessionDisplayTitle, sessionStatusFromEvents, shouldSubmitOnKey, stringifyPayload, toolDisplayName, truncate, tryParseJson, useBillingUsage, useComposer, useEnvironments, useFileAttachments, useGoal, useOpenGeni, useOpenGeniClient, usePacks, useScheduledTasks, useSession, useSessionControl, useSessionEvents, useSlashCommands, useTurnQueue, useWorkspaceSessions, useWorkspaces };
|
|
979
|
+
export { type AgentMessageItem, ChatComposer, type ChatComposerProps, type ClientOverride, type CommandContext, CommandPalette, type CommandPaletteProps, type CommandResult, type ComposerMode, type ComposerSendExtras, type ComposerState, type ConfirmState, type FileAttachment, FleetTile, type FleetTileProps, type GoalItem, Markdown, type MarkdownProps, MessageTimeline, type MessageTimelineProps, ModelPicker, type ModelPickerProps, type Notice, type NoticeItem, type OpenGeniContextValue, OpenGeniProvider, type OpenGeniProviderProps, type ParsedCommandLine, type PendingApproval, type ReasoningItem, SESSION_STATUS_META, type SandboxItem, type SessionClientLike, type SessionEventsConnectionState, SessionStatus, type SessionStatusItem, type SessionStatusMeta, type SessionStatusProps, type SlashArg, type SlashCommand, type SlashCommandContext, type SlashCommandHandlers, StatusDot, type StatusDotProps, type TimelineGroup, type TimelineItem, type ToolCallItem, type UseAvailableModelsOptions, type UseAvailableModelsResult, type UseBillingUsageOptions, type UseBillingUsageResult, type UseComposerOptions, type UseEnvironmentsOptions, type UseEnvironmentsResult, type UseFileAttachmentsOptions, type UseFileAttachmentsResult, type UseGoalOptions, type UseGoalResult, type UsePacksOptions, type UsePacksResult, type UseScheduledTasksOptions, type UseScheduledTasksResult, type UseSessionControlOptions, type UseSessionControlResult, type UseSessionEventsOptions, type UseSessionEventsResult, type UseSessionOptions, type UseSessionResult, type UseSlashCommandsOptions, type UseSlashCommandsResult, type UseTurnQueueOptions, type UseTurnQueueResult, type UseWorkspaceSessionsOptions, type UseWorkspaceSessionsResult, type UseWorkspacesOptions, type UseWorkspacesResult, type UserMessageItem, type WorkerItem, activeTurnFromTurns, applyTurnEdit, applyTurnRemoval, applyTurnReorder, approvalsFromRequiresAction, argHint, buildTimeline, cn, compactPayloadPreview, composeSendInput, defaultCommands, extractSessionRef, filterCommands, firstMissingRequiredArg, formatBytes, formatRelativeTime, groupTimeline, hasPermission, isGoalEvent, isTurnQueueEvent, matchCommand, parseCommandLine, projectPendingApprovals, queueFromTurns, sessionDisplayTitle, sessionStatusFromEvents, shouldSubmitOnKey, stringifyPayload, toolDisplayName, truncate, tryParseJson, useAvailableModels, useBillingUsage, useComposer, useEnvironments, useFileAttachments, useGoal, useOpenGeni, useOpenGeniClient, usePacks, useScheduledTasks, useSession, useSessionControl, useSessionEvents, useSlashCommands, useTurnQueue, useWorkspaceSessions, useWorkspaces };
|