@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
package/README.md
CHANGED
|
@@ -165,6 +165,23 @@ const app = await soba.apps.create({ workspace: workspace.id, name: "Study plann
|
|
|
165
165
|
await soba.apps.update(app.id, { name: "Study coach" })
|
|
166
166
|
const { key } = await soba.apps.keys.create(app.id, { environment: "production" })
|
|
167
167
|
await soba.apps.keys.list(app.id)
|
|
168
|
+
const pro = await soba.apps.plans.create(app.id, {
|
|
169
|
+
environment: "production",
|
|
170
|
+
name: "Pro",
|
|
171
|
+
price: 20,
|
|
172
|
+
route_prefer: ["user-subscription", "frontier"],
|
|
173
|
+
})
|
|
174
|
+
await soba.apps.plans.update(app.id, pro.id, { price: 25 })
|
|
175
|
+
await soba.apps.plans.archive(app.id, pro.id)
|
|
176
|
+
await soba.apps.settings.update(app.id, {
|
|
177
|
+
environment: "production",
|
|
178
|
+
connect_popup: { theme: "dark" },
|
|
179
|
+
model_picker: { menu: "tabs" },
|
|
180
|
+
})
|
|
181
|
+
await soba.apps.providers.create(app.id, { service: "openai", api_key: process.env.OPENAI_API_KEY })
|
|
182
|
+
await soba.workspaces.billing.goLive(workspace.id, { tier: "hobby" }) // { url }: a person adds the card
|
|
183
|
+
await soba.workspaces.stripe.connect(workspace.id, { environment: "production" })
|
|
184
|
+
// also: customModels, rewards, users, machines, runs, activations, overview, workspaces.members
|
|
168
185
|
await soba.apps.delete(app.id) // a person's token only
|
|
169
186
|
|
|
170
187
|
const runs = new Soba({ apiKey: key }) // that app's own key, which runs things
|
package/dist/client.d.ts
CHANGED
|
@@ -215,6 +215,22 @@ export interface RunParams {
|
|
|
215
215
|
resumable?: boolean;
|
|
216
216
|
/** How hard the agent thinks on this run: `low` to `max`. The machine's own default otherwise. */
|
|
217
217
|
effort?: "low" | "medium" | "high" | "xhigh" | "max";
|
|
218
|
+
/**
|
|
219
|
+
* Continue the conversation a previous run reported as its `session`, or a
|
|
220
|
+
* thread `soba.threads.continue` answered with. Name the same `runtime` and
|
|
221
|
+
* `policy.cwd`: another runtime ignores the id, and starts a new conversation.
|
|
222
|
+
*/
|
|
223
|
+
resume?: string;
|
|
224
|
+
/**
|
|
225
|
+
* Keep this run in a thread on the user's own machine: `"new"`, an id from
|
|
226
|
+
* `soba.threads.create`, or the `thread` an earlier run's `done` reported.
|
|
227
|
+
* Without it nothing is kept. In a thread that has begun, send only the new
|
|
228
|
+
* message: the AI goes on where it left off, and another `runtime` is handed
|
|
229
|
+
* what was said. The opening `status` says which, as `continued`. Served by
|
|
230
|
+
* the user's own machine only; a turn other compute answers is put in the
|
|
231
|
+
* thread afterwards, in words.
|
|
232
|
+
*/
|
|
233
|
+
thread?: string;
|
|
218
234
|
}
|
|
219
235
|
/** A detached run, started. */
|
|
220
236
|
export interface StartedRun {
|
|
@@ -268,7 +284,7 @@ export interface AttachParams {
|
|
|
268
284
|
* anywhere and the app reads it with `soba.runs.attach(id, …)` — no public URL,
|
|
269
285
|
* no tunnel on a laptop.
|
|
270
286
|
*/
|
|
271
|
-
export type OpKind = "git.snapshot" | "git.diff" | "git.push" | "git.update" | "git.worktree.add" | "git.worktree.remove" | "fs.list" | "fs.read" | "fs.write" | "fs.attach" | "git.mark" | "fs.copy" | "term.mode.get" | "term.mode.set" | "sessions.list" | "sessions.read" | "sessions.adopt" | "agent.open" | "editor.open" | "project.state" | "chat.latest" | "preview.send" | "project.check";
|
|
287
|
+
export type OpKind = "git.snapshot" | "git.diff" | "git.push" | "git.update" | "git.worktree.add" | "git.worktree.remove" | "fs.list" | "fs.read" | "fs.write" | "fs.attach" | "git.mark" | "fs.copy" | "term.mode.get" | "term.mode.set" | "sessions.list" | "sessions.read" | "sessions.adopt" | "threads.list" | "threads.read" | "threads.continue" | "threads.create" | "threads.kept" | "threads.get" | "threads.update" | "threads.delete" | "threads.search" | "threads.attachment" | "threads.fork" | "threads.append" | "agent.open" | "editor.open" | "project.state" | "chat.latest" | "preview.send" | "project.check";
|
|
272
288
|
export interface OpParams {
|
|
273
289
|
/** Whose machine. Resolve it on your server, never from the browser. */
|
|
274
290
|
user: string;
|
|
@@ -321,6 +337,125 @@ export interface OpResult<T = unknown> {
|
|
|
321
337
|
/** `not_allowed` · `outside_roots` · `no_worktree` · `conflict` · `dirty` · `failed` */
|
|
322
338
|
code?: string;
|
|
323
339
|
}
|
|
340
|
+
/** A thread the app keeps on a user's machine, or that its owner shared with it. */
|
|
341
|
+
export interface ThreadInfo {
|
|
342
|
+
id: string;
|
|
343
|
+
title: string;
|
|
344
|
+
created: number;
|
|
345
|
+
/** When it was last spoken in, in ms. */
|
|
346
|
+
at: number;
|
|
347
|
+
/** How many messages it has. */
|
|
348
|
+
messages: number;
|
|
349
|
+
access: "read" | "continue";
|
|
350
|
+
/** Made by this app, rather than shared with it. */
|
|
351
|
+
own: boolean;
|
|
352
|
+
/** Kept for every app of your workspace that this user has connected. */
|
|
353
|
+
scope?: "workspace";
|
|
354
|
+
/** The thread this one branched from, and the last message they share. */
|
|
355
|
+
from?: {
|
|
356
|
+
thread: string;
|
|
357
|
+
message: string;
|
|
358
|
+
};
|
|
359
|
+
meta?: Record<string, unknown>;
|
|
360
|
+
}
|
|
361
|
+
export interface ThreadPage {
|
|
362
|
+
threads: ThreadInfo[];
|
|
363
|
+
/** Pass back as `before` for the page after this one. Absent at the end. */
|
|
364
|
+
before?: string;
|
|
365
|
+
}
|
|
366
|
+
export type ThreadPart = {
|
|
367
|
+
type: "text";
|
|
368
|
+
text: string;
|
|
369
|
+
} | {
|
|
370
|
+
type: "thinking";
|
|
371
|
+
text: string;
|
|
372
|
+
} | {
|
|
373
|
+
type: "tool";
|
|
374
|
+
id?: string;
|
|
375
|
+
name: string;
|
|
376
|
+
input?: string;
|
|
377
|
+
cut?: true;
|
|
378
|
+
} | {
|
|
379
|
+
type: "result";
|
|
380
|
+
id?: string;
|
|
381
|
+
name?: string;
|
|
382
|
+
output: string;
|
|
383
|
+
error?: true;
|
|
384
|
+
cut?: true;
|
|
385
|
+
} | {
|
|
386
|
+
type: "image";
|
|
387
|
+
mediaType?: string;
|
|
388
|
+
attachment?: string;
|
|
389
|
+
} | {
|
|
390
|
+
type: "error";
|
|
391
|
+
text: string;
|
|
392
|
+
};
|
|
393
|
+
export interface ThreadMessage {
|
|
394
|
+
id: string;
|
|
395
|
+
role: "person" | "agent";
|
|
396
|
+
at: number;
|
|
397
|
+
/** The AI it was said to or by. */
|
|
398
|
+
runtime: string;
|
|
399
|
+
/** That AI's own id for the conversation, and the run it was part of. */
|
|
400
|
+
chat: string | null;
|
|
401
|
+
run: string | null;
|
|
402
|
+
parts: ThreadPart[];
|
|
403
|
+
}
|
|
404
|
+
export interface ThreadDetail extends Omit<ThreadInfo, "messages"> {
|
|
405
|
+
/** How many messages it has in all. */
|
|
406
|
+
total: number;
|
|
407
|
+
messages: ThreadMessage[];
|
|
408
|
+
/** Pass back as `before` for earlier messages. Absent at the start. */
|
|
409
|
+
before?: string;
|
|
410
|
+
}
|
|
411
|
+
export interface ThreadMatch {
|
|
412
|
+
thread: string;
|
|
413
|
+
message: string;
|
|
414
|
+
role: "person" | "agent";
|
|
415
|
+
at: number;
|
|
416
|
+
/** The words, with a little round them. */
|
|
417
|
+
text: string;
|
|
418
|
+
}
|
|
419
|
+
/** A Claude Code or Codex chat on a user's machine, in one folder. */
|
|
420
|
+
export interface Thread {
|
|
421
|
+
runtime: "claude-code" | "codex";
|
|
422
|
+
id: string;
|
|
423
|
+
title: string;
|
|
424
|
+
/** When it last changed, in ms. */
|
|
425
|
+
at: number;
|
|
426
|
+
/** The folder it ran in, relative to the repository: "" for the checkout itself. */
|
|
427
|
+
where: string;
|
|
428
|
+
/** Open in a terminal there, or mid-turn. Claude Code only; a Codex chat reads "closed". */
|
|
429
|
+
state: "closed" | "open" | "busy";
|
|
430
|
+
}
|
|
431
|
+
export interface ThreadTranscript extends Thread {
|
|
432
|
+
/** The person's messages and the agent's last word to each. */
|
|
433
|
+
turns: {
|
|
434
|
+
who: "person" | "agent";
|
|
435
|
+
text: string;
|
|
436
|
+
}[];
|
|
437
|
+
files: string[];
|
|
438
|
+
/** Earlier turns were left out. */
|
|
439
|
+
skipped: boolean;
|
|
440
|
+
version: string;
|
|
441
|
+
}
|
|
442
|
+
export interface ThreadParams {
|
|
443
|
+
/** Whose machine. Resolve it on your server, never from the browser. */
|
|
444
|
+
user: string;
|
|
445
|
+
/** The folder on that machine. Must be inside a granted root. */
|
|
446
|
+
repo: string;
|
|
447
|
+
runtime: "claude-code" | "codex";
|
|
448
|
+
id: string;
|
|
449
|
+
}
|
|
450
|
+
export interface ContinuedThread {
|
|
451
|
+
runtime: "codex";
|
|
452
|
+
/** Pass as a run's `resume`. */
|
|
453
|
+
id: string;
|
|
454
|
+
/** Pass as that run's `policy.cwd`. */
|
|
455
|
+
cwd: string;
|
|
456
|
+
/** "open": a terminal still has the original. What is said there stays there. */
|
|
457
|
+
state: "closed" | "open" | "busy";
|
|
458
|
+
}
|
|
324
459
|
export interface TerminalParams {
|
|
325
460
|
/** Whose machine. Resolve it on your server, never from the browser. */
|
|
326
461
|
user: string;
|
|
@@ -372,8 +507,6 @@ export interface DetachedRunParams extends Omit<RunParams, "approve" | "signal"
|
|
|
372
507
|
branch: string;
|
|
373
508
|
base?: string;
|
|
374
509
|
};
|
|
375
|
-
/** Continue the conversation a previous run reported as its `session`. */
|
|
376
|
-
resume?: string;
|
|
377
510
|
}
|
|
378
511
|
export declare class Soba {
|
|
379
512
|
#private;
|
|
@@ -488,6 +621,113 @@ export declare class Soba {
|
|
|
488
621
|
readonly ops: {
|
|
489
622
|
run<T = unknown>(params: OpParams): Promise<OpResult<T>>;
|
|
490
623
|
};
|
|
624
|
+
/**
|
|
625
|
+
* THREADS, on the user's own machine. The app's own (`create`, `list`, `get`),
|
|
626
|
+
* and the chats they already have with Claude Code and Codex in a folder,
|
|
627
|
+
* followed live and carried on (`list` with a `repo`, `read`, `watch`,
|
|
628
|
+
* `continue`): those only for an app their machine's owner named in `chats`.
|
|
629
|
+
* Sealed end to end like a run, unless the client says `encrypt: false`. A refusal throws a `SobaError` with its code:
|
|
630
|
+
* `not_allowed`, `outside_roots`, `not_found`, `busy`.
|
|
631
|
+
*/
|
|
632
|
+
readonly threads: {
|
|
633
|
+
/**
|
|
634
|
+
* The app's own threads, kept on the user's machine: no folder, no grant,
|
|
635
|
+
* and no database of yours. `soba.run({ thread })` adds to one.
|
|
636
|
+
*/
|
|
637
|
+
create(params: {
|
|
638
|
+
user: string;
|
|
639
|
+
title?: string;
|
|
640
|
+
meta?: Record<string, unknown>;
|
|
641
|
+
/** `workspace`: your workspace's other apps may read and continue it too. */
|
|
642
|
+
scope?: "workspace";
|
|
643
|
+
}): Promise<ThreadInfo>;
|
|
644
|
+
/** The app's threads and any the owner shared with it, last spoken in first. */
|
|
645
|
+
list(params: {
|
|
646
|
+
user: string;
|
|
647
|
+
limit?: number;
|
|
648
|
+
before?: string;
|
|
649
|
+
}): Promise<ThreadPage>;
|
|
650
|
+
/** The chats in a folder, with Claude Code and Codex. */
|
|
651
|
+
list(params: {
|
|
652
|
+
user: string;
|
|
653
|
+
repo: string;
|
|
654
|
+
}): Promise<Thread[]>;
|
|
655
|
+
/** The newest messages, oldest of them first. `before` asks for the page before. */
|
|
656
|
+
get(params: {
|
|
657
|
+
user: string;
|
|
658
|
+
thread: string;
|
|
659
|
+
before?: string;
|
|
660
|
+
}): Promise<ThreadDetail>;
|
|
661
|
+
/** Its title, or its `meta`: yours to keep up to 4 KB in, replaced whole. */
|
|
662
|
+
update(params: {
|
|
663
|
+
user: string;
|
|
664
|
+
thread: string;
|
|
665
|
+
title?: string;
|
|
666
|
+
meta?: Record<string, unknown>;
|
|
667
|
+
scope?: "workspace" | "app";
|
|
668
|
+
}): Promise<ThreadInfo>;
|
|
669
|
+
/**
|
|
670
|
+
* A branch: a new thread that begins as this one was, down to and including
|
|
671
|
+
* the message `at` (its newest, left out), and goes its own way. To ask
|
|
672
|
+
* something again, branch at the message before it.
|
|
673
|
+
*/
|
|
674
|
+
fork(params: {
|
|
675
|
+
user: string;
|
|
676
|
+
thread: string;
|
|
677
|
+
at?: string;
|
|
678
|
+
title?: string;
|
|
679
|
+
}): Promise<ThreadInfo>;
|
|
680
|
+
/**
|
|
681
|
+
* Put a turn that ran somewhere else in a thread. `soba.run({ thread })`
|
|
682
|
+
* does this itself when other compute answered. Kept now when the user's
|
|
683
|
+
* computer is awake; otherwise sealed to it and left for it (`"later"`).
|
|
684
|
+
* `turn`: your id for it, so a retry is kept once.
|
|
685
|
+
*/
|
|
686
|
+
append(params: {
|
|
687
|
+
user: string;
|
|
688
|
+
thread: string;
|
|
689
|
+
messages: {
|
|
690
|
+
role: "user" | "assistant";
|
|
691
|
+
content: string;
|
|
692
|
+
}[];
|
|
693
|
+
turn?: string;
|
|
694
|
+
/** What answered. */
|
|
695
|
+
runtime?: string;
|
|
696
|
+
signal?: AbortSignal;
|
|
697
|
+
}): Promise<{
|
|
698
|
+
thread: string;
|
|
699
|
+
kept: "now" | "later";
|
|
700
|
+
}>;
|
|
701
|
+
delete(params: {
|
|
702
|
+
user: string;
|
|
703
|
+
thread: string;
|
|
704
|
+
}): Promise<void>;
|
|
705
|
+
search(params: {
|
|
706
|
+
user: string;
|
|
707
|
+
query: string;
|
|
708
|
+
limit?: number;
|
|
709
|
+
}): Promise<ThreadMatch[]>;
|
|
710
|
+
/** A picture in a message, by its part's `attachment`. `data` is base64. */
|
|
711
|
+
attachment(params: {
|
|
712
|
+
user: string;
|
|
713
|
+
thread: string;
|
|
714
|
+
attachment: string;
|
|
715
|
+
}): Promise<{
|
|
716
|
+
mediaType: string;
|
|
717
|
+
data: string;
|
|
718
|
+
}>;
|
|
719
|
+
read(params: ThreadParams): Promise<ThreadTranscript>;
|
|
720
|
+
/** The chat now, then again each time it changes, until `signal` aborts. */
|
|
721
|
+
watch(params: ThreadParams & {
|
|
722
|
+
signal?: AbortSignal;
|
|
723
|
+
}): AsyncGenerator<ThreadTranscript>;
|
|
724
|
+
/** Fork a Claude Code chat into Codex. Then run with `runtime: "codex"`,
|
|
725
|
+
* `resume: id` and `policy: { cwd }`. */
|
|
726
|
+
continue(params: ThreadParams & {
|
|
727
|
+
runtime: "claude-code";
|
|
728
|
+
to: "codex";
|
|
729
|
+
}): Promise<ContinuedThread>;
|
|
730
|
+
};
|
|
491
731
|
/**
|
|
492
732
|
* Web terminals: a shell on one of a user's machines, typed into from a
|
|
493
733
|
* browser. Only on a machine whose owner set `webTerminal` in its policy.
|
package/dist/e2e.d.ts
CHANGED
|
@@ -53,6 +53,11 @@ export declare function newRunKey(): Promise<RunKey>;
|
|
|
53
53
|
export declare function wrapRunKey(runKey: RunKey, apiKey: string): Promise<string>;
|
|
54
54
|
/** Throws if it was wrapped with another API key, or altered. */
|
|
55
55
|
export declare function unwrapRunKey(text: string, apiKey: string): Promise<RunKey>;
|
|
56
|
+
/** A thread's id, made here because its machine is asleep. */
|
|
57
|
+
export declare function newThreadId(): string;
|
|
58
|
+
/** Text only the machine with `recipient`'s other half can open:
|
|
59
|
+
* packages/worker/src/passport-seal.ts. */
|
|
60
|
+
export declare function sealTo(recipient: string, text: string): Promise<string>;
|
|
56
61
|
/** Seal `payload` so that only the machines in `recipients` can open it. */
|
|
57
62
|
export declare function sealRequest(runKey: RunKey, payload: Record<string, unknown>, recipients: MachineKey[]): Promise<SealedRequest>;
|
|
58
63
|
/** One frame from the app to the machine: a tool result. */
|
package/dist/errors.d.ts
CHANGED
|
@@ -32,6 +32,12 @@ export type SobaErrorCode =
|
|
|
32
32
|
| "stream_truncated"
|
|
33
33
|
/** a delivered terminal `error` event, surfaced by `run.text()` */
|
|
34
34
|
| "run_failed"
|
|
35
|
+
/** `soba.threads`: the machine's owner has not let this app do that */
|
|
36
|
+
| "not_allowed"
|
|
37
|
+
/** `soba.threads`: the folder is not one the machine allows */
|
|
38
|
+
| "outside_roots"
|
|
39
|
+
/** `soba.threads.continue`: the chat is mid-turn; try again when it finishes */
|
|
40
|
+
| "busy"
|
|
35
41
|
/** the caller aborted */
|
|
36
42
|
| "canceled" | "unknown";
|
|
37
43
|
export interface SobaErrorInit {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export { type AttachParams, DEFAULT_BASE_URL, DEFAULT_WEB_BASE_URL, type DetachedRunParams, type EncryptOptions, type FallbackControl, type OfferedKey, type OpKind, type OpParams, type OpResult, type PinStore, type PrivateParams, type RunParams, Soba, type SobaOptions, type StartedRun, type TerminalBooking, type TerminalParams, } from "./client.js";
|
|
1
|
+
export { type AttachParams, DEFAULT_BASE_URL, DEFAULT_WEB_BASE_URL, type DetachedRunParams, type EncryptOptions, type FallbackControl, type OfferedKey, type OpKind, type OpParams, type OpResult, type ContinuedThread, type Thread, type ThreadDetail, type ThreadInfo, type ThreadMatch, type ThreadMessage, type ThreadPage, type ThreadParams, type ThreadPart, type ThreadTranscript, type PinStore, type PrivateParams, type RunParams, Soba, type SobaOptions, type StartedRun, type TerminalBooking, type TerminalParams, } from "./client.js";
|
|
2
2
|
export { fingerprint, type MachineKey } from "./e2e.js";
|
|
3
3
|
export { SobaError, type SobaErrorCode } from "./errors.js";
|
|
4
4
|
export { runResponse } from "./respond.js";
|
|
5
|
-
export { type ManagedApp, type ManagedKey, type Me, type MintedKey, SobaManagement, type SobaManagementOptions, type Workspace, } from "./management.js";
|
|
5
|
+
export { type ManagedApp, type ManagedKey, type Me, type MintedKey, SobaManagement, type SobaManagementOptions, type Workspace, type CreatePlanParams, type ManagedPlan, type PlanFeature, type PlanFields, type PlanPatch, type PlanUnit, } from "./management.js";
|
|
6
|
+
export type { AppSettings, AppSettingsPatch, BrowserStep, ConnectPopup, CustomModel, ManagedProvider, ManagedReward, Member, MemberRole, ModelPickerSettings, ProviderModelParams, ProviderParams, Repricing, RewardParams, } from "./managed.js";
|
|
6
7
|
export { type AgentEvent, type AgentEventType, type CostClass, type GitSnapshot, type ImageInput, isCostClass, isMetered, isTerminal, METERED_CLASSES, type Message, type PermissionMode, type RouteRequest, type RunPolicy, type RunUsage, TOOL_SLUGS, type ToolSchema, type ToolSlug, } from "./protocol.js";
|
|
7
8
|
export type { Allowance, ConnectContextResponse, ConnectedMachine, CurrentPlanItem, CustomerMembers, CustomerMembersResult, FeatureCheckResult, FeatureDenial, MachineListItem, MachineListState, MachineRuntime, PlanFeatureWire, PlanLimitsWire, PlanListItem, PlanListResponse, PlanSummary, QuantityResult, RuntimeListItem, SobaUser, TrackResult, UsagePage, UsageQuery, UsageRow, } from "./resources.js";
|
|
8
9
|
export { type ApprovalDecision, type ApprovalRequest, type Approver, Run, } from "./run.js";
|