@soba-so/sdk 0.0.22 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/dist/client.d.ts +243 -3
- package/dist/e2e.d.ts +5 -0
- package/dist/errors.d.ts +6 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.mjs +10 -10
- package/dist/local.d.ts +134 -0
- package/dist/local.mjs +2 -0
- package/dist/managed.d.ts +203 -0
- package/dist/management.d.ts +381 -1
- package/dist/protocol.d.ts +11 -0
- package/dist/run.d.ts +6 -0
- package/dist/version.d.ts +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import type { CostClass } from "./protocol.js";
|
|
2
|
+
/** What `SobaManagement` reads and writes of an app, as the API spells it. Money is in dollars. */
|
|
3
|
+
export type Environment = "development" | "production";
|
|
4
|
+
export interface ConnectPopup {
|
|
5
|
+
theme: "light" | "dark" | "system";
|
|
6
|
+
/** Six-digit hex, like #4F46E5. Null is the default. */
|
|
7
|
+
accent: string | null;
|
|
8
|
+
background: string | null;
|
|
9
|
+
logo: "favicon" | "soba" | "custom" | "none";
|
|
10
|
+
/** https. Setting it makes `logo` custom. */
|
|
11
|
+
logo_url: string | null;
|
|
12
|
+
hosted: boolean;
|
|
13
|
+
show_code: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface ModelPickerSettings {
|
|
16
|
+
/** False is no picker: every message uses Automatic. */
|
|
17
|
+
users_choose: boolean;
|
|
18
|
+
menu: "submenus" | "two_panes" | "tabs" | null;
|
|
19
|
+
presets: {
|
|
20
|
+
automatic: boolean;
|
|
21
|
+
fast: boolean;
|
|
22
|
+
best: boolean;
|
|
23
|
+
};
|
|
24
|
+
search: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** One environment's settings, and the app's own, which hold in both. */
|
|
27
|
+
export interface AppSettings {
|
|
28
|
+
environment: Environment;
|
|
29
|
+
connect_popup: ConnectPopup;
|
|
30
|
+
model_picker: ModelPickerSettings;
|
|
31
|
+
/** The AIs users may connect: claude, chatgpt, local… Null is all of them. */
|
|
32
|
+
own_ai: string[] | null;
|
|
33
|
+
ask_to_connect: boolean;
|
|
34
|
+
connect_return_url: string | null;
|
|
35
|
+
app: {
|
|
36
|
+
name: string;
|
|
37
|
+
icon: string | null;
|
|
38
|
+
run_limit_minutes: number | null;
|
|
39
|
+
max_cost_per_run: number | null;
|
|
40
|
+
/** What the app will ever run on, over every plan. Null is no ceiling. */
|
|
41
|
+
route_allow: CostClass[] | null;
|
|
42
|
+
provider_failover: boolean;
|
|
43
|
+
outage_fallback: boolean;
|
|
44
|
+
use_soba: boolean;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** Only what you send changes. `name` down to `use_soba` hold in both environments. */
|
|
48
|
+
export interface AppSettingsPatch {
|
|
49
|
+
environment: Environment;
|
|
50
|
+
connect_popup?: Partial<ConnectPopup>;
|
|
51
|
+
model_picker?: {
|
|
52
|
+
users_choose?: boolean;
|
|
53
|
+
menu?: "submenus" | "two_panes" | "tabs";
|
|
54
|
+
presets?: {
|
|
55
|
+
automatic?: boolean;
|
|
56
|
+
fast?: boolean;
|
|
57
|
+
best?: boolean;
|
|
58
|
+
};
|
|
59
|
+
search?: boolean;
|
|
60
|
+
};
|
|
61
|
+
own_ai?: string[] | null;
|
|
62
|
+
ask_to_connect?: boolean;
|
|
63
|
+
connect_return_url?: string | null;
|
|
64
|
+
name?: string;
|
|
65
|
+
/** An https image address or one emoji. */
|
|
66
|
+
icon?: string | null;
|
|
67
|
+
run_limit_minutes?: number | null;
|
|
68
|
+
max_cost_per_run?: number | null;
|
|
69
|
+
route_allow?: CostClass[] | null;
|
|
70
|
+
provider_failover?: boolean;
|
|
71
|
+
outage_fallback?: boolean;
|
|
72
|
+
use_soba?: boolean;
|
|
73
|
+
}
|
|
74
|
+
export interface ManagedProvider {
|
|
75
|
+
id: string;
|
|
76
|
+
name: string;
|
|
77
|
+
base_url: string;
|
|
78
|
+
cost_class: "frontier" | "open-weights";
|
|
79
|
+
/** Whether a key is stored. The key is never read back. */
|
|
80
|
+
has_key: boolean;
|
|
81
|
+
enabled: boolean;
|
|
82
|
+
max_cost_per_run: number | null;
|
|
83
|
+
models: {
|
|
84
|
+
model: string;
|
|
85
|
+
alias: string | null;
|
|
86
|
+
label: string | null;
|
|
87
|
+
note: string | null;
|
|
88
|
+
shown: boolean;
|
|
89
|
+
is_default: boolean;
|
|
90
|
+
input_per_mtok: number;
|
|
91
|
+
output_per_mtok: number;
|
|
92
|
+
}[];
|
|
93
|
+
/** Saved, but something about the key could not be checked. */
|
|
94
|
+
warning?: string;
|
|
95
|
+
}
|
|
96
|
+
export interface ProviderParams {
|
|
97
|
+
name?: string;
|
|
98
|
+
base_url?: string;
|
|
99
|
+
cost_class?: "frontier" | "open-weights";
|
|
100
|
+
/** Checked with the provider, stored sealed, never returned. */
|
|
101
|
+
api_key?: string;
|
|
102
|
+
max_cost_per_run?: number | null;
|
|
103
|
+
}
|
|
104
|
+
export interface ProviderModelParams {
|
|
105
|
+
model: string;
|
|
106
|
+
/** Both, or neither to look them up. */
|
|
107
|
+
input_per_mtok?: number;
|
|
108
|
+
output_per_mtok?: number;
|
|
109
|
+
alias?: string | null;
|
|
110
|
+
label?: string | null;
|
|
111
|
+
note?: string | null;
|
|
112
|
+
/** Whether it is in the model picker. */
|
|
113
|
+
shown?: boolean;
|
|
114
|
+
is_default?: boolean;
|
|
115
|
+
/** What Fast or Best picks. One model each per app. */
|
|
116
|
+
tier?: "fast" | "best" | null;
|
|
117
|
+
}
|
|
118
|
+
export interface CustomModel {
|
|
119
|
+
/** What a user's pick is saved as. Fixed once made. */
|
|
120
|
+
alias: string;
|
|
121
|
+
label: string;
|
|
122
|
+
note: string | null;
|
|
123
|
+
icon: string | null;
|
|
124
|
+
is_default: boolean;
|
|
125
|
+
/** With `percent` on every model, runs are split; without, tried in order. */
|
|
126
|
+
models: {
|
|
127
|
+
provider: string;
|
|
128
|
+
model: string;
|
|
129
|
+
percent: number | null;
|
|
130
|
+
}[];
|
|
131
|
+
}
|
|
132
|
+
export interface RewardParams {
|
|
133
|
+
name?: string;
|
|
134
|
+
kind?: "discount" | "grant" | "plan";
|
|
135
|
+
discount_type?: "percent" | "fixed";
|
|
136
|
+
amount?: number | null;
|
|
137
|
+
duration_months?: number | null;
|
|
138
|
+
/** Plan ids a discount is for. Null is any. */
|
|
139
|
+
plans?: string[] | null;
|
|
140
|
+
first_time_only?: boolean;
|
|
141
|
+
grants?: {
|
|
142
|
+
feature: string;
|
|
143
|
+
name?: string;
|
|
144
|
+
type?: "boolean" | "number" | "text";
|
|
145
|
+
amount?: number | null;
|
|
146
|
+
expiry_days?: number | null;
|
|
147
|
+
}[];
|
|
148
|
+
plan?: string;
|
|
149
|
+
duration_days?: number;
|
|
150
|
+
trigger?: "none" | "signup" | "first_connect";
|
|
151
|
+
/** The whole list: one left out is removed. */
|
|
152
|
+
codes?: {
|
|
153
|
+
code: string;
|
|
154
|
+
cap?: number | null;
|
|
155
|
+
}[];
|
|
156
|
+
}
|
|
157
|
+
export interface ManagedReward {
|
|
158
|
+
id: string;
|
|
159
|
+
environment: Environment;
|
|
160
|
+
slug: string;
|
|
161
|
+
name: string;
|
|
162
|
+
kind: "discount" | "grant" | "plan";
|
|
163
|
+
holders: number;
|
|
164
|
+
codes: {
|
|
165
|
+
code: string;
|
|
166
|
+
cap: number | null;
|
|
167
|
+
redemptions: number;
|
|
168
|
+
}[];
|
|
169
|
+
[field: string]: unknown;
|
|
170
|
+
}
|
|
171
|
+
export interface ListParams {
|
|
172
|
+
environment?: Environment;
|
|
173
|
+
/** Up to 200. Default 50. */
|
|
174
|
+
limit?: number;
|
|
175
|
+
offset?: number;
|
|
176
|
+
}
|
|
177
|
+
/** A row as the dashboard shows it. */
|
|
178
|
+
export type Row = {
|
|
179
|
+
id: string;
|
|
180
|
+
[field: string]: unknown;
|
|
181
|
+
};
|
|
182
|
+
export interface Member {
|
|
183
|
+
id: string;
|
|
184
|
+
email: string | null;
|
|
185
|
+
name: string | null;
|
|
186
|
+
role: "owner" | "admin" | "member" | "billing" | null;
|
|
187
|
+
}
|
|
188
|
+
/** A step a person takes in a browser. Open it, then read until it is done. */
|
|
189
|
+
export interface BrowserStep {
|
|
190
|
+
url: string;
|
|
191
|
+
next?: string;
|
|
192
|
+
}
|
|
193
|
+
export interface Repricing {
|
|
194
|
+
old_price: string;
|
|
195
|
+
plan: string;
|
|
196
|
+
plan_name: string;
|
|
197
|
+
old_amount: number;
|
|
198
|
+
new_amount: number;
|
|
199
|
+
currency: string;
|
|
200
|
+
interval: string;
|
|
201
|
+
subscribers: number;
|
|
202
|
+
}
|
|
203
|
+
export type MemberRole = "admin" | "member" | "billing";
|
package/dist/management.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { AppSettings, AppSettingsPatch, BrowserStep, CustomModel, Environment, ListParams, ManagedProvider, ManagedReward, Member, MemberRole, ProviderModelParams, ProviderParams, Repricing, RewardParams, Row } from "./managed.js";
|
|
2
|
+
import type { CostClass } from "./protocol.js";
|
|
1
3
|
/**
|
|
2
|
-
* SOBA ITSELF, MANAGED FROM CODE: workspaces, apps
|
|
4
|
+
* SOBA ITSELF, MANAGED FROM CODE: workspaces, apps, their keys and plans — the way
|
|
3
5
|
* the Supabase and Railway management APIs work.
|
|
4
6
|
*
|
|
5
7
|
* ```js
|
|
@@ -8,6 +10,7 @@
|
|
|
8
10
|
* const [workspace] = await soba.workspaces.list()
|
|
9
11
|
* const app = await soba.apps.create({ workspace: workspace.id, name: "Study planner" })
|
|
10
12
|
* const { key } = await soba.apps.keys.create(app.id, { environment: "production" })
|
|
13
|
+
* await soba.apps.plans.create(app.id, { environment: "production", template: "byo" })
|
|
11
14
|
* ```
|
|
12
15
|
*
|
|
13
16
|
* TWO CREDENTIALS, ONE CLIENT:
|
|
@@ -58,6 +61,8 @@ export interface ManagedKey {
|
|
|
58
61
|
preview: string;
|
|
59
62
|
created_at: string;
|
|
60
63
|
last_used_at: string | null;
|
|
64
|
+
/** Dollars a month it may spend. Null is no cap. */
|
|
65
|
+
monthly_cap: number | null;
|
|
61
66
|
}
|
|
62
67
|
export interface MintedKey {
|
|
63
68
|
id: string;
|
|
@@ -66,6 +71,90 @@ export interface MintedKey {
|
|
|
66
71
|
preview: string;
|
|
67
72
|
environment: "development" | "production";
|
|
68
73
|
}
|
|
74
|
+
export type PlanUnit = "run" | "task" | "token" | "cost" | "credit";
|
|
75
|
+
/** What a plan is made of, as the API spells it. Money is in dollars. */
|
|
76
|
+
export interface PlanFields {
|
|
77
|
+
name: string;
|
|
78
|
+
description?: string;
|
|
79
|
+
/** Dollars a month. 0 is a free plan. */
|
|
80
|
+
price: number;
|
|
81
|
+
/** What the allowances count. Default `run`. */
|
|
82
|
+
unit?: PlanUnit;
|
|
83
|
+
/** A month, on AI the app pays for. Null is unlimited. */
|
|
84
|
+
included_units?: number | null;
|
|
85
|
+
/** A month, on the user's own AI. Null is unlimited. */
|
|
86
|
+
own_included_units?: number | null;
|
|
87
|
+
/** What `own_included_units` counts, when not `unit`. */
|
|
88
|
+
own_unit?: PlanUnit | null;
|
|
89
|
+
/** Past the allowance on a `cost` or `credit` plan. */
|
|
90
|
+
overage_per_unit?: number | null;
|
|
91
|
+
/** On a run, task or token plan: keep going past the allowance, at cost plus `markup_percent`. */
|
|
92
|
+
meter?: boolean;
|
|
93
|
+
/** When the own-AI allowance is spent: stop, or continue on AI the app pays for. */
|
|
94
|
+
byo_overage?: "stop" | "meter";
|
|
95
|
+
trial_days?: number;
|
|
96
|
+
markup_percent?: number;
|
|
97
|
+
/** Percent per model vendor, over `markup_percent`. */
|
|
98
|
+
markup_overrides?: Record<string, number>;
|
|
99
|
+
credits_per_dollar?: number;
|
|
100
|
+
/** Dollars per 1,000 credits. */
|
|
101
|
+
credit_price?: number | null;
|
|
102
|
+
credit_packs?: {
|
|
103
|
+
credits: number;
|
|
104
|
+
price: number;
|
|
105
|
+
}[] | null;
|
|
106
|
+
credit_expiry?: "never" | "month_end";
|
|
107
|
+
/** What the app calls a run, plural. */
|
|
108
|
+
task_noun?: string | null;
|
|
109
|
+
/** A plan sold by conversation: its "Talk to us" link. Its price becomes 0. */
|
|
110
|
+
contact_url?: string | null;
|
|
111
|
+
/** What a run may use, best first. Also the ceiling: a class left out is never billed. */
|
|
112
|
+
route_prefer: CostClass[];
|
|
113
|
+
/** Classes allowed but not ranked, on top of `route_prefer`. */
|
|
114
|
+
route_allow?: CostClass[];
|
|
115
|
+
/** Dollars one run may cost. Null is no cap. */
|
|
116
|
+
max_cost_per_run?: number | null;
|
|
117
|
+
connected_reward?: "none" | "included" | "credit";
|
|
118
|
+
connected_included_units?: number | null;
|
|
119
|
+
connected_credit?: number | null;
|
|
120
|
+
features?: PlanFeature[];
|
|
121
|
+
}
|
|
122
|
+
/** A line your app enforces and your pricing card shows. */
|
|
123
|
+
export interface PlanFeature {
|
|
124
|
+
id: string;
|
|
125
|
+
name: string;
|
|
126
|
+
type: "boolean" | "number" | "text";
|
|
127
|
+
/** Null is unlimited, on a number. */
|
|
128
|
+
value: boolean | number | string | null;
|
|
129
|
+
unit?: string;
|
|
130
|
+
resets?: "month";
|
|
131
|
+
/** Per-unit pricing (seats): millionths of a dollar a unit, past `included`. */
|
|
132
|
+
price?: {
|
|
133
|
+
amountMicros: number;
|
|
134
|
+
included: number;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/** The free "Bring your own" plan, for an environment with no plans yet. */
|
|
138
|
+
export type CreatePlanParams = {
|
|
139
|
+
environment: "development" | "production";
|
|
140
|
+
} & (PlanFields | {
|
|
141
|
+
template: "byo";
|
|
142
|
+
});
|
|
143
|
+
export interface ManagedPlan extends Required<Omit<PlanFields, "route_allow">> {
|
|
144
|
+
id: string;
|
|
145
|
+
environment: "development" | "production";
|
|
146
|
+
/** Null is no ceiling. */
|
|
147
|
+
route_allow: CostClass[] | null;
|
|
148
|
+
/** Where new users start. */
|
|
149
|
+
is_default: boolean;
|
|
150
|
+
/** Shown as "Most popular". One per environment. */
|
|
151
|
+
is_popular: boolean;
|
|
152
|
+
created_at: string;
|
|
153
|
+
}
|
|
154
|
+
export interface PlanPatch extends Partial<PlanFields> {
|
|
155
|
+
is_default?: boolean;
|
|
156
|
+
is_popular?: boolean;
|
|
157
|
+
}
|
|
69
158
|
export type Me = {
|
|
70
159
|
kind: "person";
|
|
71
160
|
user_id: string;
|
|
@@ -92,6 +181,111 @@ export declare class SobaManagement {
|
|
|
92
181
|
key: string;
|
|
93
182
|
workspace_id: string;
|
|
94
183
|
}>;
|
|
184
|
+
/** Changes below take a person's token, never a workspace key. */
|
|
185
|
+
update(workspaceId: string, params: {
|
|
186
|
+
name?: string;
|
|
187
|
+
icon?: string | null;
|
|
188
|
+
}): Promise<unknown>;
|
|
189
|
+
members: {
|
|
190
|
+
list(workspaceId: string): Promise<{
|
|
191
|
+
data: Member[];
|
|
192
|
+
invites: {
|
|
193
|
+
id: string;
|
|
194
|
+
email: string;
|
|
195
|
+
role: string | null;
|
|
196
|
+
}[];
|
|
197
|
+
}>;
|
|
198
|
+
/** Sends the invitation, and answers with its link. */
|
|
199
|
+
invite(workspaceId: string, params: {
|
|
200
|
+
email: string;
|
|
201
|
+
role?: MemberRole;
|
|
202
|
+
}): Promise<{
|
|
203
|
+
email: string;
|
|
204
|
+
url: string;
|
|
205
|
+
sent: boolean;
|
|
206
|
+
}>;
|
|
207
|
+
revokeInvite(workspaceId: string, inviteId: string): Promise<{
|
|
208
|
+
id: string;
|
|
209
|
+
revoked: true;
|
|
210
|
+
}>;
|
|
211
|
+
update(workspaceId: string, memberId: string, params: {
|
|
212
|
+
role: MemberRole;
|
|
213
|
+
}): Promise<unknown>;
|
|
214
|
+
remove(workspaceId: string, memberId: string): Promise<{
|
|
215
|
+
id: string;
|
|
216
|
+
removed: true;
|
|
217
|
+
}>;
|
|
218
|
+
};
|
|
219
|
+
/** Base64. */
|
|
220
|
+
setLogo(workspaceId: string, data: string): Promise<{
|
|
221
|
+
icon: string;
|
|
222
|
+
}>;
|
|
223
|
+
keys: {
|
|
224
|
+
list(workspaceId: string): Promise<Row[]>;
|
|
225
|
+
revoke(workspaceId: string, keyId: string): Promise<{
|
|
226
|
+
id: string;
|
|
227
|
+
revoked: true;
|
|
228
|
+
}>;
|
|
229
|
+
};
|
|
230
|
+
/** Soba's bill. A card is only ever typed on Stripe's page. */
|
|
231
|
+
billing: {
|
|
232
|
+
get(workspaceId: string): Promise<{
|
|
233
|
+
live: boolean;
|
|
234
|
+
tier: string | null;
|
|
235
|
+
} & Record<string, unknown>>;
|
|
236
|
+
/** Where a person puts a card in. Live once `get` says so. */
|
|
237
|
+
goLive(workspaceId: string, params: {
|
|
238
|
+
tier: string;
|
|
239
|
+
}): Promise<BrowserStep>;
|
|
240
|
+
changeCard(workspaceId: string): Promise<BrowserStep>;
|
|
241
|
+
/** `confirm_fee` is the tier's monthly fee, in dollars: it is charged. */
|
|
242
|
+
changeTier(workspaceId: string, params: {
|
|
243
|
+
tier: string;
|
|
244
|
+
confirm_fee: number;
|
|
245
|
+
}): Promise<{
|
|
246
|
+
tier: string;
|
|
247
|
+
effective_at: string | null;
|
|
248
|
+
}>;
|
|
249
|
+
/** `confirm` is the workspace's name. Ends with the period. */
|
|
250
|
+
cancel(workspaceId: string, params: {
|
|
251
|
+
confirm: string;
|
|
252
|
+
}): Promise<{
|
|
253
|
+
ends_at: string | null;
|
|
254
|
+
}>;
|
|
255
|
+
};
|
|
256
|
+
/** The workspace's own Stripe, which its users pay into. */
|
|
257
|
+
stripe: {
|
|
258
|
+
get(workspaceId: string, params: {
|
|
259
|
+
environment: Environment;
|
|
260
|
+
}): Promise<{
|
|
261
|
+
connected: boolean;
|
|
262
|
+
account: string | null;
|
|
263
|
+
}>;
|
|
264
|
+
/** You accept it on Stripe, signed in as yourself. Connected once `get` says so. */
|
|
265
|
+
connect(workspaceId: string, params: {
|
|
266
|
+
environment: Environment;
|
|
267
|
+
}): Promise<BrowserStep>;
|
|
268
|
+
disconnect(workspaceId: string, params: {
|
|
269
|
+
environment: Environment;
|
|
270
|
+
confirm: string;
|
|
271
|
+
}): Promise<{
|
|
272
|
+
connected: boolean;
|
|
273
|
+
}>;
|
|
274
|
+
};
|
|
275
|
+
/** `confirm` is the workspace's name. You become an admin. */
|
|
276
|
+
transfer(workspaceId: string, params: {
|
|
277
|
+
member: string;
|
|
278
|
+
confirm: string;
|
|
279
|
+
}): Promise<{
|
|
280
|
+
owner: string;
|
|
281
|
+
}>;
|
|
282
|
+
/** `confirm` is the workspace's name. Everything in it goes, and cannot come back. */
|
|
283
|
+
delete(workspaceId: string, params: {
|
|
284
|
+
confirm: string;
|
|
285
|
+
}): Promise<{
|
|
286
|
+
id: string;
|
|
287
|
+
deleted: true;
|
|
288
|
+
}>;
|
|
95
289
|
};
|
|
96
290
|
readonly apps: {
|
|
97
291
|
/** A workspace's apps, oldest first. */
|
|
@@ -126,11 +320,197 @@ export declare class SobaManagement {
|
|
|
126
320
|
name?: string;
|
|
127
321
|
replaceIdle?: boolean;
|
|
128
322
|
}): Promise<MintedKey>;
|
|
323
|
+
/** The most it may spend a month, in dollars. Null is no cap. */
|
|
324
|
+
setCap(appId: string, keyId: string, monthlyCap: number | null): Promise<{
|
|
325
|
+
id: string;
|
|
326
|
+
monthly_cap: number | null;
|
|
327
|
+
}>;
|
|
129
328
|
revoke(appId: string, keyId: string): Promise<{
|
|
130
329
|
id: string;
|
|
131
330
|
revoked: true;
|
|
132
331
|
}>;
|
|
133
332
|
};
|
|
333
|
+
plans: {
|
|
334
|
+
/** Live plans, oldest first, in both environments unless you name one. */
|
|
335
|
+
list(appId: string, params?: {
|
|
336
|
+
environment?: "development" | "production";
|
|
337
|
+
}): Promise<ManagedPlan[]>;
|
|
338
|
+
get(appId: string, planId: string): Promise<ManagedPlan>;
|
|
339
|
+
/**
|
|
340
|
+
* A production plan is on sale to your users at once. The environment's
|
|
341
|
+
* first free plan becomes the one new users start on.
|
|
342
|
+
*/
|
|
343
|
+
create(appId: string, params: CreatePlanParams): Promise<ManagedPlan>;
|
|
344
|
+
/** Changes the fields sent and leaves the rest. A plan never moves environment. */
|
|
345
|
+
update(appId: string, planId: string, params: PlanPatch): Promise<ManagedPlan>;
|
|
346
|
+
/** Off sale. Users already on it, and its history, are kept. */
|
|
347
|
+
archive(appId: string, planId: string): Promise<{
|
|
348
|
+
id: string;
|
|
349
|
+
archived: true;
|
|
350
|
+
}>;
|
|
351
|
+
/** Stripe's checkout for it, as a preview buyer. Live mode takes real money. */
|
|
352
|
+
tryCheckout(appId: string, planId: string): Promise<BrowserStep>;
|
|
353
|
+
setSeats(appId: string, planId: string, params: {
|
|
354
|
+
user: string;
|
|
355
|
+
quantity: number;
|
|
356
|
+
}): Promise<unknown>;
|
|
357
|
+
/** Put it back in Stripe where it was changed there, or leave the change. */
|
|
358
|
+
restoreInStripe(appId: string, planId: string): Promise<unknown>;
|
|
359
|
+
acceptStripeChange(appId: string, planId: string, kind: string): Promise<unknown>;
|
|
360
|
+
};
|
|
361
|
+
/** Models, Connect popup, Model picker and Settings. */
|
|
362
|
+
settings: {
|
|
363
|
+
get(appId: string, params: {
|
|
364
|
+
environment: Environment;
|
|
365
|
+
}): Promise<AppSettings>;
|
|
366
|
+
/** Changes what you send, and answers with everything. */
|
|
367
|
+
update(appId: string, params: AppSettingsPatch): Promise<AppSettings>;
|
|
368
|
+
};
|
|
369
|
+
/** The accounts the app pays for, used when a user's own AI can't serve. */
|
|
370
|
+
providers: {
|
|
371
|
+
list(appId: string): Promise<ManagedProvider[]>;
|
|
372
|
+
/** OpenAI, Anthropic, Groq… `service` below takes one of these. */
|
|
373
|
+
services(appId: string): Promise<{
|
|
374
|
+
service: string;
|
|
375
|
+
name: string;
|
|
376
|
+
base_url: string;
|
|
377
|
+
}[]>;
|
|
378
|
+
get(appId: string, providerId: string): Promise<ManagedProvider>;
|
|
379
|
+
create(appId: string, params: ProviderParams & {
|
|
380
|
+
service?: string;
|
|
381
|
+
}): Promise<ManagedProvider>;
|
|
382
|
+
/** A new host in `base_url` needs `api_key` with it. */
|
|
383
|
+
update(appId: string, providerId: string, params: ProviderParams & {
|
|
384
|
+
enabled?: boolean;
|
|
385
|
+
}): Promise<ManagedProvider>;
|
|
386
|
+
delete(appId: string, providerId: string): Promise<{
|
|
387
|
+
id: string;
|
|
388
|
+
deleted: true;
|
|
389
|
+
}>;
|
|
390
|
+
/** Forget the stored key, and keep the provider. */
|
|
391
|
+
clearKey(appId: string, providerId: string): Promise<ManagedProvider>;
|
|
392
|
+
/** Every id, first tried first. */
|
|
393
|
+
reorder(appId: string, providerIds: string[]): Promise<ManagedProvider[]>;
|
|
394
|
+
/** What the provider says it serves. */
|
|
395
|
+
available(appId: string, providerId: string): Promise<{
|
|
396
|
+
model: string;
|
|
397
|
+
input_per_mtok: number | null;
|
|
398
|
+
output_per_mtok: number | null;
|
|
399
|
+
}[]>;
|
|
400
|
+
/** Add a model, or change how it is shown. */
|
|
401
|
+
setModel(appId: string, providerId: string, params: ProviderModelParams): Promise<ManagedProvider>;
|
|
402
|
+
removeModel(appId: string, providerId: string, model: string): Promise<ManagedProvider>;
|
|
403
|
+
};
|
|
404
|
+
/** Names of your own over models from any provider. */
|
|
405
|
+
customModels: {
|
|
406
|
+
list(appId: string): Promise<CustomModel[]>;
|
|
407
|
+
set(appId: string, alias: string, params: Partial<Omit<CustomModel, "alias" | "models">> & {
|
|
408
|
+
models?: {
|
|
409
|
+
provider: string;
|
|
410
|
+
model: string;
|
|
411
|
+
percent?: number | null;
|
|
412
|
+
}[];
|
|
413
|
+
}): Promise<CustomModel>;
|
|
414
|
+
delete(appId: string, alias: string): Promise<{
|
|
415
|
+
alias: string;
|
|
416
|
+
deleted: true;
|
|
417
|
+
}>;
|
|
418
|
+
};
|
|
419
|
+
rewards: {
|
|
420
|
+
list(appId: string, params?: {
|
|
421
|
+
environment?: Environment;
|
|
422
|
+
}): Promise<ManagedReward[]>;
|
|
423
|
+
create(appId: string, params: RewardParams & {
|
|
424
|
+
environment: Environment;
|
|
425
|
+
name: string;
|
|
426
|
+
kind: string;
|
|
427
|
+
}): Promise<ManagedReward>;
|
|
428
|
+
/** By id or slug. Name the environment when a slug is in both. */
|
|
429
|
+
update(appId: string, reward: string, params: RewardParams & {
|
|
430
|
+
environment?: Environment;
|
|
431
|
+
}): Promise<ManagedReward>;
|
|
432
|
+
archive(appId: string, reward: string, params?: {
|
|
433
|
+
environment?: Environment;
|
|
434
|
+
}): Promise<{
|
|
435
|
+
id: string;
|
|
436
|
+
archived: true;
|
|
437
|
+
}>;
|
|
438
|
+
give(appId: string, reward: string, params: {
|
|
439
|
+
user: string;
|
|
440
|
+
environment?: Environment;
|
|
441
|
+
}): Promise<unknown>;
|
|
442
|
+
};
|
|
443
|
+
users: {
|
|
444
|
+
list(appId: string, params?: ListParams): Promise<Row[]>;
|
|
445
|
+
/** By Soba's id or yours. */
|
|
446
|
+
get(appId: string, user: string, params?: {
|
|
447
|
+
environment?: Environment;
|
|
448
|
+
}): Promise<Row>;
|
|
449
|
+
/** Put them on a plan, or off with null. A paid plan is a gift: nothing is billed. */
|
|
450
|
+
setPlan(appId: string, user: string, plan: string | null, params?: {
|
|
451
|
+
environment?: Environment;
|
|
452
|
+
}): Promise<Row>;
|
|
453
|
+
};
|
|
454
|
+
machines: {
|
|
455
|
+
list(appId: string, params?: ListParams): Promise<Row[]>;
|
|
456
|
+
get(appId: string, machineId: string): Promise<Row>;
|
|
457
|
+
};
|
|
458
|
+
runs: {
|
|
459
|
+
list(appId: string, params?: ListParams & {
|
|
460
|
+
range?: string;
|
|
461
|
+
status?: string;
|
|
462
|
+
class?: string;
|
|
463
|
+
model?: string;
|
|
464
|
+
}): Promise<{
|
|
465
|
+
range: string;
|
|
466
|
+
summary: Record<string, number | null>;
|
|
467
|
+
data: Row[];
|
|
468
|
+
}>;
|
|
469
|
+
get(appId: string, runId: string): Promise<Row>;
|
|
470
|
+
};
|
|
471
|
+
activations(appId: string): Promise<{
|
|
472
|
+
period: {
|
|
473
|
+
start: string;
|
|
474
|
+
end: string;
|
|
475
|
+
};
|
|
476
|
+
activations: number;
|
|
477
|
+
pending: number;
|
|
478
|
+
}>;
|
|
479
|
+
overview(appId: string, params?: {
|
|
480
|
+
environment?: Environment;
|
|
481
|
+
}): Promise<Record<string, unknown>>;
|
|
482
|
+
/** Put the app's plans into the workspace's connected Stripe now. */
|
|
483
|
+
syncStripe(appId: string): Promise<{
|
|
484
|
+
synced: true;
|
|
485
|
+
}>;
|
|
486
|
+
/** Compare the app's plans with what is in Stripe. */
|
|
487
|
+
checkStripe(appId: string): Promise<{
|
|
488
|
+
checked: true;
|
|
489
|
+
}>;
|
|
490
|
+
/** People still paying a plan's old price. */
|
|
491
|
+
repricing: {
|
|
492
|
+
list(appId: string): Promise<Repricing[]>;
|
|
493
|
+
/** Moving changes what people pay, so it names how many. */
|
|
494
|
+
decide(appId: string, params: {
|
|
495
|
+
old_price: string;
|
|
496
|
+
decision: "keep" | "move";
|
|
497
|
+
confirm_subscribers?: number;
|
|
498
|
+
}): Promise<{
|
|
499
|
+
decision: string;
|
|
500
|
+
moved: number;
|
|
501
|
+
}>;
|
|
502
|
+
};
|
|
503
|
+
/** An image in base64: the app's icon, or one environment's connect popup. */
|
|
504
|
+
setLogo(appId: string, params: {
|
|
505
|
+
data: string;
|
|
506
|
+
use?: "icon";
|
|
507
|
+
} | {
|
|
508
|
+
data: string;
|
|
509
|
+
use: "connect_popup";
|
|
510
|
+
environment: Environment;
|
|
511
|
+
}): Promise<unknown>;
|
|
512
|
+
/** Pair your own machine, as your app's first user. You approve it in the browser. */
|
|
513
|
+
pair(appId: string): Promise<BrowserStep>;
|
|
134
514
|
};
|
|
135
515
|
constructor(options?: SobaManagementOptions);
|
|
136
516
|
}
|
package/dist/protocol.d.ts
CHANGED
|
@@ -61,6 +61,17 @@ export interface AgentEvent {
|
|
|
61
61
|
/** On `done` / `error`: the runtime's conversation id. Send it back as `resume`
|
|
62
62
|
* to make the next run a follow-up of this one. */
|
|
63
63
|
session?: string;
|
|
64
|
+
/** On `done` / `error`: the thread the run was kept in. Send it back as
|
|
65
|
+
* `thread` to add the next run to it. */
|
|
66
|
+
thread?: string;
|
|
67
|
+
/** On a `status` opening a run that asked to `resume`, or is in a `thread`: the
|
|
68
|
+
* AI's own conversation goes on (`resumed`), it was handed what was said so far
|
|
69
|
+
* (`rebuilt`, as when a thread changes AI), or it knows none of it (`new`). */
|
|
70
|
+
continued?: "resumed" | "rebuilt" | "new";
|
|
71
|
+
/** On a tool `status`: the call's id, the same from its start to its end. */
|
|
72
|
+
callId?: string;
|
|
73
|
+
/** On the `status` that ends a tool call: whether it worked. */
|
|
74
|
+
callEnded?: "ok" | "failed";
|
|
64
75
|
/** On a tool `status`: what the tool was pointed at — a path, a command. */
|
|
65
76
|
toolInput?: string;
|
|
66
77
|
/** On a `status` when a command finished: what it printed, its last 8 KB. */
|
package/dist/run.d.ts
CHANGED
|
@@ -49,6 +49,12 @@ export interface RunInit {
|
|
|
49
49
|
runKey?: RunKey;
|
|
50
50
|
/** `runKey` wrapped for keeping. See `Run.key`. */
|
|
51
51
|
key?: string;
|
|
52
|
+
/** A run in a thread: how it is put there when the user's machine did not
|
|
53
|
+
* answer it, and so did not keep it. */
|
|
54
|
+
keep?: {
|
|
55
|
+
thread: string;
|
|
56
|
+
put: (thread: string, turn: string, answer: string, runtime: string) => Promise<void>;
|
|
57
|
+
};
|
|
52
58
|
}
|
|
53
59
|
/**
|
|
54
60
|
* A run in flight.
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.0.
|
|
1
|
+
export declare const VERSION = "0.0.24";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soba-so/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
4
4
|
"description": "One request that comes back finished, executed on compute the end user owns.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"homepage": "https://soba.so/docs/runs",
|
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
"./identity": {
|
|
16
16
|
"types": "./dist/identity.d.ts",
|
|
17
17
|
"default": "./dist/identity.mjs"
|
|
18
|
+
},
|
|
19
|
+
"./local": {
|
|
20
|
+
"types": "./dist/local.d.ts",
|
|
21
|
+
"default": "./dist/local.mjs"
|
|
18
22
|
}
|
|
19
23
|
},
|
|
20
24
|
"files": [
|