@opengeni/react 1.2.1-canary.37222965366001 → 1.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.
@@ -1,15 +1,15 @@
1
1
  import { type ReactNode } from "react";
2
+ import { type ToolActionReview } from "@opengeni/sdk";
2
3
  import type { PendingApproval } from "../approvals.js";
4
+ import { type ToolReviewDetailsLoader } from "./tool-action-review.js";
3
5
  export type ApprovalSurfaceMessages = {
4
6
  title: string;
5
- /** Screen-reader context for the decision; not shown visually. */
6
7
  description: string;
7
8
  approve: string;
8
9
  reject: string;
9
10
  approving: string;
10
11
  rejecting: string;
11
12
  formatToolName: (name: string) => string;
12
- /** Toggle for the exact arguments when they are shown as readable fields. */
13
13
  showDetails?: string | undefined;
14
14
  hideDetails?: string | undefined;
15
15
  };
@@ -22,6 +22,12 @@ export type ApprovalSurfaceProps = {
22
22
  error?: string | Error | null | undefined;
23
23
  messages?: Partial<ApprovalSurfaceMessages> | undefined;
24
24
  renderApproval?: ((approval: PendingApproval) => ReactNode) | undefined;
25
+ /** Authenticated server facts; hosts need not import any web-app code. */
26
+ loadReview?: ((approval: PendingApproval) => Promise<ToolActionReview>) | undefined;
27
+ loadDetails?: ToolReviewDetailsLoader | undefined;
28
+ onViewDetails?: ((review: ToolActionReview, path: string) => void) | undefined;
29
+ selectedApprovalId?: string | null | undefined;
30
+ onSelectedApprovalChange?: ((id: string) => void) | undefined;
25
31
  className?: string | undefined;
26
32
  };
27
33
  export type ApprovalField = {
@@ -29,15 +35,7 @@ export type ApprovalField = {
29
35
  label: string;
30
36
  value: string;
31
37
  };
32
- /**
33
- * Readable fields for a flat argument object (scalars and short scalar lists).
34
- * Returns null when the arguments are nested, large, or not an object, so the
35
- * caller shows the exact JSON instead of a lossy summary.
36
- */
38
+ /** @deprecated Prefer the versioned server review; retained for small custom renderers. */
37
39
  export declare function approvalArgumentFields(value: unknown): ApprovalField[] | null;
38
- /**
39
- * Host-neutral approval presentation backed by the native pending-approval
40
- * projection and control callbacks. It owns only presentation and duplicate
41
- * click fencing; OpenGeni remains the authority for approval state.
42
- */
43
- export declare function ApprovalSurface({ approvals, onApprove, onReject, responding, error, messages: overrides, renderApproval, className, }: ApprovalSurfaceProps): import("react").JSX.Element | null;
40
+ /** Hosts provide decisions; this surface never mutates the approved payload. */
41
+ export declare function ApprovalSurface({ approvals, onApprove, onReject, responding, error, messages: overrides, renderApproval, loadReview, loadDetails, onViewDetails, selectedApprovalId, onSelectedApprovalChange, className, }: ApprovalSurfaceProps): import("react").JSX.Element | null;
@@ -1,3 +1,4 @@
1
+ import type { FileResourceRef, LatencyMode, ReasoningEffort } from "@opengeni/sdk";
1
2
  import { type CSSProperties } from "react";
2
3
  import { type HostSurfacePreference, type HostThemePreference } from "../lib/host-theme.js";
3
4
  import { type ClientOverride } from "../session-context.js";
@@ -13,6 +14,15 @@ export type OpenGeniChatLabels = SessionListLabels & {
13
14
  send: string;
14
15
  newChatUnavailable: string;
15
16
  };
17
+ /** What the first message carries besides its text. */
18
+ export type OpenGeniChatCreateOptions = {
19
+ /** Files attached in the new-chat composer. */
20
+ resources?: FileResourceRef[] | undefined;
21
+ /** Present only when the user changed it in the model picker. */
22
+ model?: string | undefined;
23
+ reasoningEffort?: ReasoningEffort | undefined;
24
+ latencyMode?: LatencyMode | undefined;
25
+ };
16
26
  export type OpenGeniChatProps = ClientOverride & SessionProxyBaseUrl & {
17
27
  /** Controlled selection. `null` shows the new-chat composer. */
18
28
  sessionId?: string | null | undefined;
@@ -21,14 +31,19 @@ export type OpenGeniChatProps = ClientOverride & SessionProxyBaseUrl & {
21
31
  onSessionChange?: ((sessionId: string | null) => void) | undefined;
22
32
  /**
23
33
  * Create a chat from its first message. Defaults to `client.createSession`
24
- * with `{ initialMessage, idempotencyKey }`, which `createSessionProxyHandler`
25
- * accepts when the server supplies a `createSession` hook. Return the new id.
34
+ * with `{ initialMessage, idempotencyKey }` plus the attached files and any
35
+ * model choice, which `createSessionProxyHandler` accepts when the server
36
+ * supplies a `createSession` hook. Return the new id.
26
37
  */
27
- createSession?: ((initialMessage: string, idempotencyKey: string) => Promise<string>) | undefined;
38
+ createSession?: ((initialMessage: string, idempotencyKey: string, options: OpenGeniChatCreateOptions) => Promise<string>) | undefined;
28
39
  /** Hide the "New chat" entry point. */
29
40
  newChat?: boolean | undefined;
30
- /** Forwarded to the conversation (message rendering, tool renderers, composer...). */
31
- conversationProps?: Omit<SessionConversationProps, "sessionId" | "client" | "workspaceId" | "baseUrl">;
41
+ /**
42
+ * Forwarded to the conversation (message rendering, tool renderers,
43
+ * composer...). `attachments`, `modelPicker`, `modelPickerProps`, and
44
+ * `composerProps` also apply to the new-chat composer.
45
+ */
46
+ conversationProps?: Omit<SessionConversationProps, "sessionId" | "client" | "workspaceId" | "baseUrl" | "headers" | "fetch">;
32
47
  /** Forwarded to the list (rename/archive toggles, page size). */
33
48
  listProps?: Pick<SessionListProps, "rename" | "archive" | "pageSize"> | undefined;
34
49
  labels?: Partial<OpenGeniChatLabels> | undefined;
@@ -55,4 +70,4 @@ export type OpenGeniChatProps = ClientOverride & SessionProxyBaseUrl & {
55
70
  * `<OpenGeniChat baseUrl="/api/opengeni" />` needs no provider: it talks to
56
71
  * your session proxy and uses the workspace the proxy resolves.
57
72
  */
58
- export declare function OpenGeniChat({ baseUrl, ...props }: OpenGeniChatProps): import("react").JSX.Element;
73
+ export declare function OpenGeniChat({ baseUrl, headers, fetch, ...props }: OpenGeniChatProps): import("react").JSX.Element;
@@ -1,3 +1,4 @@
1
+ import { type ReasoningEffort } from "@opengeni/sdk";
1
2
  import { type CSSProperties } from "react";
2
3
  import { type ClientOverride } from "../session-context.js";
3
4
  import { type ModelPolicyPickerProps } from "./model-policy-picker.js";
@@ -86,4 +87,20 @@ export type SessionConversationProps = ClientOverride & SessionProxyBaseUrl & {
86
87
  * (including Site clients), one shared event feed, and authoritative queue state.
87
88
  * `<SessionConversation baseUrl="/api/opengeni" sessionId={id} />` needs no
88
89
  * provider: it talks to your session proxy and its resolved workspace. */
89
- export declare function SessionConversation({ baseUrl, ...props }: SessionConversationProps): import("react").JSX.Element;
90
+ export declare function SessionConversation({ baseUrl, headers, fetch, ...props }: SessionConversationProps): import("react").JSX.Element;
91
+ /** Deployment/proxy flags from the client config: uploads, and whether model choice is open. */
92
+ export declare function useClientConfigFlags(client: {
93
+ getClientConfig: () => Promise<{
94
+ fileUploads?: {
95
+ enabled?: boolean;
96
+ };
97
+ modelSelection?: boolean | undefined;
98
+ sandboxFiles?: boolean | undefined;
99
+ defaultReasoningEffort?: ReasoningEffort | undefined;
100
+ }>;
101
+ }): {
102
+ uploads: boolean;
103
+ modelSelection: boolean;
104
+ sandboxFiles: boolean;
105
+ defaultReasoningEffort: ReasoningEffort | null;
106
+ };
@@ -1,21 +1,35 @@
1
+ import { type FetchLike } from "@opengeni/sdk/browser";
1
2
  import { type ReactNode } from "react";
3
+ import type { SessionClientLike } from "../client.js";
4
+ /** Request headers for every proxy call: static, or computed per request. */
5
+ export type SessionProxyHeaders = Record<string, string> | (() => Record<string, string>);
2
6
  export type SessionProxyBaseUrl = {
3
7
  /**
4
8
  * Mount path of your `createSessionProxyHandler` (for example
5
9
  * `"/api/opengeni"`). The component then needs no `OpenGeniProvider`,
6
10
  * client, or workspace id: it creates the browser client for that path and
7
11
  * uses the workspace the proxy resolved for the signed-in user. An explicit
8
- * `workspaceId` skips that lookup.
12
+ * `workspaceId` skips that lookup. A `client` you pass is used instead of
13
+ * the created one (point it at the same proxy).
9
14
  */
10
15
  baseUrl?: string | undefined;
16
+ /**
17
+ * `baseUrl` mode: headers added to every proxy request, for hosts that
18
+ * authenticate with a bearer token instead of cookies. A function is called
19
+ * per request, so it can return the current token.
20
+ */
21
+ headers?: SessionProxyHeaders | undefined;
22
+ /** `baseUrl` mode: custom fetch for every proxy request (async auth, retries). */
23
+ fetch?: FetchLike | undefined;
11
24
  };
12
25
  /**
13
26
  * `OpenGeniProvider` for a same-origin session proxy, from its base URL alone.
14
27
  * The proxy's client config names the resolved workspace, so the browser
15
28
  * never handles an Opengeni id. Provider-based usage is unchanged.
16
29
  */
17
- export declare function SessionProxyScope({ baseUrl, workspaceId, children, }: {
30
+ export declare function SessionProxyScope({ baseUrl, workspaceId, client: suppliedClient, headers, fetch, children, }: Omit<SessionProxyBaseUrl, "baseUrl"> & {
18
31
  baseUrl: string;
19
32
  workspaceId?: string | undefined;
33
+ client?: SessionClientLike | undefined;
20
34
  children: ReactNode;
21
35
  }): import("react").JSX.Element;
@@ -0,0 +1,20 @@
1
+ import type { ToolActionReview, ToolReviewDetailsPage } from "@opengeni/sdk";
2
+ export type ToolReviewDetailsLoader = (review: ToolActionReview, path: string, offset: number) => Promise<ToolReviewDetailsPage>;
3
+ /** One host-neutral review. All callbacks refer to the immutable action; none can edit it. */
4
+ export declare function ToolActionReviewCard({ review, onApprove, onReject, submitting, disabled, onViewDetails, pendingLabel, rejectLabel, }: {
5
+ review: ToolActionReview;
6
+ onApprove?: (() => void) | undefined;
7
+ onReject?: (() => void) | undefined;
8
+ submitting?: "approve" | "reject" | null | undefined;
9
+ disabled?: boolean | undefined;
10
+ onViewDetails?: ((path: string) => void) | undefined;
11
+ pendingLabel?: string | undefined;
12
+ rejectLabel?: string | undefined;
13
+ }): import("react").JSX.Element;
14
+ /** Full-page detail content: hosts choose navigation, never a nested scrolling panel. */
15
+ export declare function ToolActionReviewDetails({ review, path: initialPath, load, onBack, }: {
16
+ review: ToolActionReview;
17
+ path?: string;
18
+ load: ToolReviewDetailsLoader;
19
+ onBack: () => void;
20
+ }): import("react").JSX.Element;
@@ -0,0 +1,21 @@
1
+ import { type ReactNode } from "react";
2
+ import type { SessionEvent, ToolActionReview } from "@opengeni/sdk";
3
+ type HistoryContext = {
4
+ approvalIds: ReadonlySet<string>;
5
+ revision: number;
6
+ load: (approvalId: string) => Promise<ToolActionReview>;
7
+ onViewDetails: (review: ToolActionReview, path: string) => void;
8
+ };
9
+ /** Opt-in, authenticated history for the exact reviewed calls in the visible event window. */
10
+ export declare function ToolReviewHistoryProvider({ events, load, onViewDetails, children, }: {
11
+ events: readonly SessionEvent[];
12
+ load: HistoryContext["load"];
13
+ onViewDetails: HistoryContext["onViewDetails"];
14
+ children: ReactNode;
15
+ }): import("react").JSX.Element;
16
+ export declare function useHasToolReview(approvalId: string | null): boolean;
17
+ /** Recorded calls have details, never another decision button. */
18
+ export declare function ToolReviewHistoryReceipt({ approvalId }: {
19
+ approvalId: string;
20
+ }): import("react").JSX.Element | null;
21
+ export {};
package/dist/index.d.ts CHANGED
@@ -91,6 +91,8 @@ export type { DeriveMachineChipInput, MachineChip, MachineChipState, UseMachineC
91
91
  export { approvalsFromRequiresAction, projectPendingApprovals } from "./approvals.js";
92
92
  export type { PendingApproval } from "./approvals.js";
93
93
  export { ApprovalSurface, defaultApprovalSurfaceMessages } from "./components/approval-surface.js";
94
+ export { ToolActionReviewCard, ToolActionReviewDetails } from "./components/tool-action-review.js";
95
+ export type { ToolReviewDetailsLoader } from "./components/tool-action-review.js";
94
96
  export type { ApprovalSurfaceMessages, ApprovalSurfaceProps } from "./components/approval-surface.js";
95
97
  export { humanInputRequestFromEvent, projectPendingHumanInputRequests } from "./human-input.js";
96
98
  export type { PendingHumanInputRequest } from "./human-input.js";
@@ -121,7 +123,7 @@ export { SessionConversation } from "./components/session-conversation.js";
121
123
  export { SessionList } from "./components/session-list.js";
122
124
  export type { SessionListLabels, SessionListProps } from "./components/session-list.js";
123
125
  export { OpenGeniChat } from "./components/open-geni-chat.js";
124
- export type { OpenGeniChatLabels, OpenGeniChatProps } from "./components/open-geni-chat.js";
126
+ export type { OpenGeniChatCreateOptions, OpenGeniChatLabels, OpenGeniChatProps, } from "./components/open-geni-chat.js";
125
127
  export type { SessionConversationLabels, SessionConversationProps, } from "./components/session-conversation.js";
126
128
  export type { ChatComposerProps } from "./components/chat-composer.js";
127
129
  export { ComposerTranscriptionControl } from "./components/composer-transcription-control.js";
@@ -203,3 +205,4 @@ export { ClaudeMark } from "./components/claude-mark.js";
203
205
  export { AnthropicMark } from "./components/anthropic-mark.js";
204
206
  export { OpenRouterMark } from "./components/openrouter-mark.js";
205
207
  export { GrokMark } from "./components/grok-mark.js";
208
+ export { ToolReviewHistoryProvider } from "./components/tool-review-history.js";
package/dist/index.js CHANGED
@@ -72,6 +72,9 @@ import {
72
72
  StartupTimings,
73
73
  StatusDot,
74
74
  TimelineRow,
75
+ ToolActionReviewCard,
76
+ ToolActionReviewDetails,
77
+ ToolReviewHistoryProvider,
75
78
  TurnSummary,
76
79
  UserMessageBody,
77
80
  answersFromDrafts,
@@ -107,7 +110,7 @@ import {
107
110
  useWorkspaceSessions,
108
111
  userMessageLikelyNeedsDisclosure,
109
112
  v4aToGitFileDiff
110
- } from "./chunk-4OTO7KBK.js";
113
+ } from "./chunk-PGSX7UCP.js";
111
114
  import {
112
115
  useThemeType
113
116
  } from "./chunk-UK4TINKT.js";
@@ -140,7 +143,7 @@ import {
140
143
  useSessionControl,
141
144
  useSessionEvents,
142
145
  useTurnQueue
143
- } from "./chunk-X34BSY2R.js";
146
+ } from "./chunk-WWEUO2PL.js";
144
147
  import {
145
148
  buildTimeline,
146
149
  creditExhaustedFromEvents,
@@ -5019,6 +5022,9 @@ export {
5019
5022
  TermBlock,
5020
5023
  Thumbnail,
5021
5024
  TimelineRow,
5025
+ ToolActionReviewCard,
5026
+ ToolActionReviewDetails,
5027
+ ToolReviewHistoryProvider,
5022
5028
  Tooltip,
5023
5029
  TooltipContent,
5024
5030
  TooltipProvider,