@soba-so/react 0.0.27 → 0.0.28
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/ProviderMark.d.ts +13 -0
- package/dist/SobaGate.d.ts +35 -0
- package/dist/context.d.ts +36 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.mjs +290 -8
- package/dist/styles.css +282 -0
- package/dist/types.d.ts +177 -3
- package/dist/useCurrentPlan.d.ts +9 -3
- package/dist/useFeature.d.ts +27 -0
- package/dist/useModel.d.ts +117 -4
- package/dist/usePlans.d.ts +9 -1
- package/package.json +1 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { JSX } from "react";
|
|
2
|
+
export interface ProviderMarkProps {
|
|
3
|
+
/** `ModelProvider.mark` or `ModelOption.providerMark`: `openai`, `groq`, … */
|
|
4
|
+
provider: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* THE PROVIDER'S OWN MARK, for a menu drawing `useModel().providers` — inline
|
|
9
|
+
* SVG, sized by `className`, monochrome marks in `currentColor` so they follow
|
|
10
|
+
* the text in dark mode. Nothing for a provider it has no mark for: an unknown
|
|
11
|
+
* endpoint gets no invented logo.
|
|
12
|
+
*/
|
|
13
|
+
export declare function ProviderMark(props: ProviderMarkProps): JSX.Element | null;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type FeatureView } from "./useFeature.js";
|
|
3
|
+
export interface SobaGateProps {
|
|
4
|
+
/** The feature's id on the plan: `workspaces`, `export`. */
|
|
5
|
+
feature: string;
|
|
6
|
+
/** How many the gated action uses. Default 1. */
|
|
7
|
+
use?: number;
|
|
8
|
+
/** What the person may see and press. */
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* What to show instead when they may not. A node, or a function of the
|
|
12
|
+
* answer to say something of your own. Default: Soba's card with the
|
|
13
|
+
* reason and the plans to move to.
|
|
14
|
+
*/
|
|
15
|
+
fallback?: ReactNode | ((view: FeatureView) => ReactNode);
|
|
16
|
+
/** While the plan loads. Default: nothing, so no gate flashes a refusal. */
|
|
17
|
+
loading?: ReactNode;
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* SHOW IT, OR SAY WHY NOT AND OFFER THE WAY THROUGH.
|
|
22
|
+
*
|
|
23
|
+
* `<SobaGate feature="workspaces">` around a "New workspace" button draws the
|
|
24
|
+
* button while the plan allows one more, and otherwise a short card: the
|
|
25
|
+
* reason ("Your plan includes 3 workspaces, and all 3 are in use") and the
|
|
26
|
+
* plans that include more, one press away. The decision is `useFeature`'s;
|
|
27
|
+
* this only draws it, so an app with its own upgrade screen passes `fallback`
|
|
28
|
+
* or calls the hook itself.
|
|
29
|
+
*
|
|
30
|
+
* It hides a button; it does not secure an action. The server still asks
|
|
31
|
+
* `soba.users.check` before it creates anything.
|
|
32
|
+
*/
|
|
33
|
+
export declare function SobaGate({ feature, use, children, fallback, loading, className, }: SobaGateProps): import("react").JSX.Element;
|
|
34
|
+
/** The sentence for a refusal, in the plan's own words. */
|
|
35
|
+
export declare function gateMessage(view: FeatureView): string;
|
package/dist/context.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AgentEvent, ConnectApi, CurrentPlan, Machine, Message, Plan } from "./types.js";
|
|
1
|
+
import type { AgentEvent, ConnectApi, CurrentPlan, Machine, Message, ModelLayout, ModelNameWire, ModelProviderWire, Plan } from "./types.js";
|
|
2
2
|
/** What your endpoint is asked for. Everything but `signal` is forwarded to it
|
|
3
3
|
* verbatim, because the run's shape is `soba.run()`'s and yours to widen. */
|
|
4
4
|
export interface RunRequest {
|
|
@@ -118,6 +118,40 @@ export interface PlanState {
|
|
|
118
118
|
leave(): Promise<void>;
|
|
119
119
|
refresh(): Promise<void>;
|
|
120
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* THE APP'S OWN PROVIDERS, as the gateway lists them for this person — the
|
|
123
|
+
* half of a model picker that is not their machines. Fetched the first time
|
|
124
|
+
* something reads it (`useModel` does), like `plan`.
|
|
125
|
+
*/
|
|
126
|
+
export interface ModelsState {
|
|
127
|
+
/** Every provider the environment and the app allow, each with its models,
|
|
128
|
+
* locked where the person's plan does not reach it. Empty for an app with
|
|
129
|
+
* none, and wherever the gateway has not been named. */
|
|
130
|
+
providers: ModelProviderWire[];
|
|
131
|
+
/** The app's own names for its models, set on Providers. */
|
|
132
|
+
names: ModelNameWire[];
|
|
133
|
+
/** How the app designed the picker on Connect, or null before it arrives. */
|
|
134
|
+
layout: ModelLayout | null;
|
|
135
|
+
/** Whether Fast and Best are offered; false only when the app turned them off. */
|
|
136
|
+
sizes: boolean;
|
|
137
|
+
/** Which of Automatic, Fast and Best each layout offers, when the gateway
|
|
138
|
+
* says. See `ModelOptionsWire`. */
|
|
139
|
+
rowsByLayout: Partial<Record<ModelLayout, {
|
|
140
|
+
auto: boolean;
|
|
141
|
+
fast: boolean;
|
|
142
|
+
best: boolean;
|
|
143
|
+
own?: boolean;
|
|
144
|
+
search?: boolean;
|
|
145
|
+
}>>;
|
|
146
|
+
/** The person's ceiling as a run resolves it, or null before it arrives. */
|
|
147
|
+
route: {
|
|
148
|
+
allow: string[];
|
|
149
|
+
prefer: string[];
|
|
150
|
+
} | null;
|
|
151
|
+
loading: boolean;
|
|
152
|
+
error: Error | null;
|
|
153
|
+
refresh(): Promise<void>;
|
|
154
|
+
}
|
|
121
155
|
export interface SobaContextValue {
|
|
122
156
|
/** The `est_` session, once there is one. */
|
|
123
157
|
session: string | null;
|
|
@@ -127,6 +161,7 @@ export interface SobaContextValue {
|
|
|
127
161
|
compute: ComputeState;
|
|
128
162
|
connect: ConnectState;
|
|
129
163
|
plan: PlanState;
|
|
164
|
+
models: ModelsState;
|
|
130
165
|
/** Start a run through YOUR endpoint and read its events. Throws when the
|
|
131
166
|
* provider was given no `runEndpoint`, since a browser cannot start one. */
|
|
132
167
|
run(request: RunRequest): Promise<AsyncIterable<AgentEvent>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,26 +4,29 @@ export { ConnectCompute, type ConnectComputeProps } from "./ConnectCompute.js";
|
|
|
4
4
|
export { ConnectModal, type ConnectModalProps } from "./ConnectModal.js";
|
|
5
5
|
export { ConnectNudge, type ConnectNudgeProps } from "./ConnectNudge.js";
|
|
6
6
|
export { ConnectPill, type ConnectPillProps } from "./ConnectPill.js";
|
|
7
|
-
export { type ComputeState, type ConnectReason, type ConnectState, type PlanState, type RunRequest, type SobaContextValue, useSoba, } from "./context.js";
|
|
7
|
+
export { type ComputeState, type ConnectReason, type ConnectState, type ModelsState, type PlanState, type RunRequest, type SobaContextValue, useSoba, } from "./context.js";
|
|
8
8
|
export { collectText, parseEvent, readEvents } from "./events.js";
|
|
9
9
|
export { ModelPicker, type ModelPickerProps } from "./ModelPicker.js";
|
|
10
|
+
export { ProviderMark, type ProviderMarkProps } from "./ProviderMark.js";
|
|
10
11
|
export { RunError, type RunErrorProps, runErrorMessage } from "./RunError.js";
|
|
11
12
|
export { RunLimit, type RunLimitProps } from "./RunLimit.js";
|
|
12
13
|
export { SobaBilling, type SobaBillingProps } from "./SobaBilling.js";
|
|
13
14
|
export { SobaCheckout, type SobaCheckoutProps } from "./SobaCheckout.js";
|
|
14
15
|
export { SobaCurrentPlan, type SobaCurrentPlanProps } from "./SobaCurrentPlan.js";
|
|
16
|
+
export { gateMessage, SobaGate, type SobaGateProps } from "./SobaGate.js";
|
|
15
17
|
export { SobaPlans, type SobaPlansProps } from "./SobaPlans.js";
|
|
16
18
|
export { SobaProvider, type SobaProviderProps } from "./SobaProvider.js";
|
|
17
19
|
export { injectStyles } from "./styles.js";
|
|
18
20
|
export { tierLabel } from "./tier.js";
|
|
19
|
-
export type { AgentEvent, AgentEventType, ConnectApi, ConnectContext, CostClass, CurrentPlan, Launch, Machine, MachineRun, MachineState, Message, ModelGroup, ModelOption, ModelOptionKind, PendingCode, Plan, Runtime, RunUsage, } from "./types.js";
|
|
21
|
+
export type { AgentEvent, AgentEventType, ConnectApi, ConnectContext, CostClass, CurrentPlan, FeatureCheck, FeatureDenial, FeatureItem, Launch, Machine, MachineRun, MachineState, Message, ModelChoice, ModelGroup, ModelLayout, ModelNameWire, ModelOption, ModelOptionKind, ModelOptionsWire, ModelProviderWire, PendingCode, Plan, PlanFeatureWire, Runtime, RunUsage, } from "./types.js";
|
|
20
22
|
export { type CheckoutView, type UseCheckoutOptions, useCheckout } from "./useCheckout.js";
|
|
21
23
|
export { type ComputeMachine, type ComputeRuntime, type ComputeView, useCompute, } from "./useCompute.js";
|
|
22
24
|
export { type ConnectButtonView, connectSays, useConnectButton } from "./useConnectButton.js";
|
|
23
25
|
export { type NudgeReason, type NudgeStalled, type NudgeStep, type NudgeView, type UseConnectNudgeOptions, useConnectNudge, } from "./useConnectNudge.js";
|
|
24
26
|
export { type AllowanceState, type CurrentPlanReward, type CurrentPlanView, useCurrentPlan, } from "./useCurrentPlan.js";
|
|
27
|
+
export { type FeatureView, useFeature } from "./useFeature.js";
|
|
25
28
|
export { type MachineRunsOptions, type MachineRunsView, useMachineRuns } from "./useMachineRuns.js";
|
|
26
|
-
export { type ModelView, type UseModelOptions, useModel } from "./useModel.js";
|
|
29
|
+
export { type ModelAgent, type ModelProvider, type ModelView, modelLogo, type UseModelOptions, useModel, } from "./useModel.js";
|
|
27
30
|
export { useOpenSobaConnect } from "./useOpenSobaConnect.js";
|
|
28
31
|
export { type PlanCompute, type PlanConnect, type PlanCta, type PlanOffer, type PlanPrice, type PlansOptions, type PlansView, usePlans, } from "./usePlans.js";
|
|
29
32
|
export { type LimitReason, type Offer, sobaErrorCode, useRunLimit } from "./useRunLimit.js";
|