@runappsai/sdk 0.8.1 → 0.9.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runappsai/sdk",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "description": "JavaScript / TypeScript client for the RunApps AI Gateway",
5
5
  "license": "MIT",
6
6
  "author": "RunApps",
package/src/client.ts CHANGED
@@ -5,7 +5,6 @@ import { ImageService } from "./image.js";
5
5
  import { AudioService } from "./audio.js";
6
6
  import { RealtimeService } from "./realtime.js";
7
7
  import { VideoService } from "./video.js";
8
- import { ComputerService } from "./computer.js";
9
8
  import { FilesService } from "./files.js";
10
9
  import { EmbeddingsService } from "./embeddings.js";
11
10
  import { BrowserAuth, type BrowserUser } from "./browser-auth.js";
@@ -153,7 +152,6 @@ export class RunApps {
153
152
  readonly image: ImageService;
154
153
  readonly audio: AudioService;
155
154
  readonly video: VideoService;
156
- readonly computer: ComputerService;
157
155
  readonly files: FilesService;
158
156
  readonly embeddings: EmbeddingsService;
159
157
  /** Realtime voice sessions over WebSocket — see `RealtimeService.connect`. */
@@ -176,7 +174,7 @@ export class RunApps {
176
174
 
177
175
  /**
178
176
  * Runtime event bus for SDK-call telemetry. Every LLM-ish service
179
- * (chat / embeddings / image / audio / video / computer) fires
177
+ * (chat / embeddings / image / audio / video) fires
180
178
  * `request:start`, `request:streamDelta`, `request:end`, and
181
179
  * `request:error` events here so UI overlays — like the bottom-right
182
180
  * identity badge's activity ring — can render real-time state
@@ -253,7 +251,7 @@ export class RunApps {
253
251
  ...(options.fetch ? { fetchImpl: options.fetch } : {}),
254
252
  });
255
253
  // Service constructors receive the shared event bus so each call
256
- // path (chat/embeddings/image/audio/video/computer) can emit
254
+ // path (chat/embeddings/image/audio/video) can emit
257
255
  // start/end/error around its network operations. Files and Models
258
256
  // intentionally don't take it — they're infrastructure, not
259
257
  // user-facing LLM calls, and surfacing them would clutter the
@@ -263,7 +261,6 @@ export class RunApps {
263
261
  this.image = new ImageService(transport, this.events);
264
262
  this.audio = new AudioService(transport, this.events);
265
263
  this.video = new VideoService(transport, this.events);
266
- this.computer = new ComputerService(transport, this.events);
267
264
  // `project` also scopes the file URLs (/v1/p/<project>/files/...),
268
265
  // so two apps never issue byte-identical file requests. Omitted →
269
266
  // legacy unscoped /v1/files/... paths.
package/src/events.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Typed runtime event bus for SDK call telemetry.
3
3
  *
4
- * Every LLM-ish service method (chat, embeddings, image, audio, video,
5
- * computer) emits start / streamDelta / end / error events on the
4
+ * Every LLM-ish service method (chat, embeddings, image, audio, video)
5
+ * emits start / streamDelta / end / error events on the
6
6
  * shared `client.events` bus so UI overlays (e.g. the bottom-right
7
7
  * identity badge with its activity ring) can render real-time state
8
8
  * without business code having to thread anything through.
@@ -32,7 +32,6 @@ export type SDKCapability =
32
32
  | "text_to_speech"
33
33
  | "speech_to_text"
34
34
  | "video_generation"
35
- | "computer_use"
36
35
  /** A realtime voice session (`client.realtime`). */
37
36
  | "realtime"
38
37
  /** A file-space call (`client.files`). Shown on the badge while in
package/src/index.ts CHANGED
@@ -88,6 +88,7 @@ export {
88
88
  supportsVoiceClone,
89
89
  supportsInstructText,
90
90
  defaultVoice,
91
+ defaultModel,
91
92
  } from "./models.js";
92
93
 
93
94
  // Model options schema (input validation + capability introspection)
@@ -156,13 +157,6 @@ export type {
156
157
  // Media helpers (shared by image + video + chat-multimodal)
157
158
  export { encodeImageUrl, decodeMediaUrl } from "./media.js";
158
159
 
159
- // Computer
160
- export type {
161
- ComputerStepParams,
162
- ComputerContentBlock,
163
- ComputerResponse,
164
- } from "./computer.js";
165
-
166
160
  // Files (per-project file system)
167
161
  export type {
168
162
  FileObject,
package/src/models.ts CHANGED
@@ -10,6 +10,15 @@ export interface Model {
10
10
  object: string;
11
11
  capability: string;
12
12
  provider?: string;
13
+ /**
14
+ * The model the platform uses for this capability when a request names
15
+ * none: the one the admin starred in the gateway settings, else the
16
+ * first of the capability. Exactly one model per capability carries it.
17
+ * Use `defaultModel` to pick it out of a list.
18
+ */
19
+ is_default?: boolean;
20
+ /** One or two sentences about the model, set on the gateway. */
21
+ description?: string;
13
22
  /**
14
23
  * Server-derived "what this model can actually do" tags
15
24
  * (e.g. {id:"t2v", label:"Text-to-Video"}, {id:"i2v", label:"Image-to-Video"}).
@@ -100,6 +109,18 @@ export const defaultVoice = (model: Model): string | null => {
100
109
  return typeof v === "string" ? v : null;
101
110
  };
102
111
 
112
+ /**
113
+ * The platform's default model among `models` — the admin-starred one for
114
+ * the capability, else the first of the capability. With `capability`
115
+ * given, only that capability is considered; without it, the first
116
+ * default in list order (so pass a list from
117
+ * `client.models.list({ capability })`). Null when the list has none.
118
+ */
119
+ export const defaultModel = (models: Model[], capability?: string): Model | null => {
120
+ const pool = capability ? models.filter((m) => m.capability === capability) : models;
121
+ return pool.find((m) => m.is_default) ?? null;
122
+ };
123
+
103
124
  export class ModelsService {
104
125
  constructor(private readonly transport: Transport) {}
105
126
 
@@ -120,4 +141,14 @@ export class ModelsService {
120
141
  const resp = await this.transport.getPublicJSON<{ data: Model[] }>(path, init);
121
142
  return resp.data;
122
143
  }
144
+
145
+ /**
146
+ * The platform's default model for a capability (`"text"` unless given):
147
+ * the admin-starred one, else the first. What a request without `model`
148
+ * would use before the user's own preference. Null when the capability
149
+ * has no models.
150
+ */
151
+ async default(capability = "text", init?: { signal?: AbortSignal }): Promise<Model | null> {
152
+ return defaultModel(await this.list({ capability }, init), capability);
153
+ }
123
154
  }
@@ -1,57 +0,0 @@
1
- import type { Transport } from "./transport.js";
2
- import type { Usage } from "./types.js";
3
- import type { SDKEvents } from "./events.js";
4
- /** Single-step computer-use request — a screenshot + history → next action(s). */
5
- export interface ComputerStepParams {
6
- /**
7
- * Conversation history including screenshots and tool results. Each
8
- * entry has `role` + `content` (string or array of blocks). Format is
9
- * intentionally opaque to support both Anthropic and OpenAI computer-use
10
- * protocols — the gateway adapts.
11
- */
12
- messages: Record<string, unknown>[];
13
- /** Screen resolution. Defaults to 1920×1080 if omitted. */
14
- display_width?: number;
15
- display_height?: number;
16
- max_tokens?: number;
17
- enable_zoom?: boolean;
18
- /** OpenAI Responses-API state chaining. */
19
- previous_response_id?: string;
20
- /** Follow-up `computer_call_output` for OpenAI's Responses API. */
21
- openai_input?: unknown;
22
- user?: string;
23
- }
24
- /** One block of a computer-use response: text, tool_use (Anthropic), or computer_call (OpenAI). */
25
- export interface ComputerContentBlock {
26
- type: string;
27
- text?: string;
28
- id?: string;
29
- name?: string;
30
- /** Anthropic tool input (raw JSON). */
31
- input?: unknown;
32
- call_id?: string;
33
- /** OpenAI computer-call action. */
34
- action?: Record<string, unknown>;
35
- }
36
- export interface ComputerResponse {
37
- content: ComputerContentBlock[];
38
- stop_reason?: string;
39
- usage: Usage;
40
- response_id?: string;
41
- /** "anthropic" | "openai" — which protocol the upstream returned. */
42
- protocol?: string;
43
- }
44
- export declare class ComputerService {
45
- private readonly transport;
46
- private readonly events;
47
- constructor(transport: Transport, events: SDKEvents);
48
- /**
49
- * Execute one step of a computer-use agent loop. Given a screenshot
50
- * and conversation history, returns the next action(s) the model
51
- * wants the caller to execute.
52
- */
53
- step(model: string, params: ComputerStepParams, init?: {
54
- signal?: AbortSignal;
55
- }): Promise<ComputerResponse>;
56
- }
57
- //# sourceMappingURL=computer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"computer.d.ts","sourceRoot":"","sources":["../src/computer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,kFAAkF;AAClF,MAAM,WAAW,kBAAkB;IACjC;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,CAAC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C;CAgB7B"}
package/dist/computer.js DELETED
@@ -1,21 +0,0 @@
1
- import { wrapEvents } from "./event-wrap.js";
2
- export class ComputerService {
3
- transport;
4
- events;
5
- constructor(transport, events) {
6
- this.transport = transport;
7
- this.events = events;
8
- }
9
- /**
10
- * Execute one step of a computer-use agent loop. Given a screenshot
11
- * and conversation history, returns the next action(s) the model
12
- * wants the caller to execute.
13
- */
14
- async step(model, params, init) {
15
- return wrapEvents(this.events, { model, capability: "computer_use" }, () => this.transport.postJSON("/v1/computer/step", { model, ...params }, init), (r) => ({
16
- totalTokens: r.usage?.completion_tokens,
17
- costUSD: r.usage?.total_cost,
18
- }));
19
- }
20
- }
21
- //# sourceMappingURL=computer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"computer.js","sourceRoot":"","sources":["../src/computer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AA6C7C,MAAM,OAAO,eAAe;IAEP;IACA;IAFnB,YACmB,SAAoB,EACpB,MAAiB;QADjB,cAAS,GAAT,SAAS,CAAW;QACpB,WAAM,GAAN,MAAM,CAAW;IACjC,CAAC;IAEJ;;;;OAIG;IACH,KAAK,CAAC,IAAI,CACR,KAAa,EACb,MAA0B,EAC1B,IAA+B;QAE/B,OAAO,UAAU,CACf,IAAI,CAAC,MAAM,EACX,EAAE,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,EACrC,GAAG,EAAE,CACH,IAAI,CAAC,SAAS,CAAC,QAAQ,CACrB,mBAAmB,EACnB,EAAE,KAAK,EAAE,GAAG,MAAM,EAAE,EACpB,IAAI,CACL,EACH,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACN,WAAW,EAAE,CAAC,CAAC,KAAK,EAAE,iBAAiB;YACvC,OAAO,EAAE,CAAC,CAAC,KAAK,EAAE,UAAU;SAC7B,CAAC,CACH,CAAC;IACJ,CAAC;CACF"}
package/src/computer.ts DELETED
@@ -1,80 +0,0 @@
1
- import type { Transport } from "./transport.js";
2
- import type { Usage } from "./types.js";
3
- import type { SDKEvents } from "./events.js";
4
- import { wrapEvents } from "./event-wrap.js";
5
-
6
- /** Single-step computer-use request — a screenshot + history → next action(s). */
7
- export interface ComputerStepParams {
8
- /**
9
- * Conversation history including screenshots and tool results. Each
10
- * entry has `role` + `content` (string or array of blocks). Format is
11
- * intentionally opaque to support both Anthropic and OpenAI computer-use
12
- * protocols — the gateway adapts.
13
- */
14
- messages: Record<string, unknown>[];
15
- /** Screen resolution. Defaults to 1920×1080 if omitted. */
16
- display_width?: number;
17
- display_height?: number;
18
- max_tokens?: number;
19
- enable_zoom?: boolean;
20
- /** OpenAI Responses-API state chaining. */
21
- previous_response_id?: string;
22
- /** Follow-up `computer_call_output` for OpenAI's Responses API. */
23
- openai_input?: unknown;
24
- user?: string;
25
- }
26
-
27
- /** One block of a computer-use response: text, tool_use (Anthropic), or computer_call (OpenAI). */
28
- export interface ComputerContentBlock {
29
- type: string;
30
- text?: string;
31
- id?: string;
32
- name?: string;
33
- /** Anthropic tool input (raw JSON). */
34
- input?: unknown;
35
- call_id?: string;
36
- /** OpenAI computer-call action. */
37
- action?: Record<string, unknown>;
38
- }
39
-
40
- export interface ComputerResponse {
41
- content: ComputerContentBlock[];
42
- stop_reason?: string;
43
- usage: Usage;
44
- response_id?: string;
45
- /** "anthropic" | "openai" — which protocol the upstream returned. */
46
- protocol?: string;
47
- }
48
-
49
- export class ComputerService {
50
- constructor(
51
- private readonly transport: Transport,
52
- private readonly events: SDKEvents,
53
- ) {}
54
-
55
- /**
56
- * Execute one step of a computer-use agent loop. Given a screenshot
57
- * and conversation history, returns the next action(s) the model
58
- * wants the caller to execute.
59
- */
60
- async step(
61
- model: string,
62
- params: ComputerStepParams,
63
- init?: { signal?: AbortSignal },
64
- ): Promise<ComputerResponse> {
65
- return wrapEvents(
66
- this.events,
67
- { model, capability: "computer_use" },
68
- () =>
69
- this.transport.postJSON<ComputerResponse>(
70
- "/v1/computer/step",
71
- { model, ...params },
72
- init,
73
- ),
74
- (r) => ({
75
- totalTokens: r.usage?.completion_tokens,
76
- costUSD: r.usage?.total_cost,
77
- }),
78
- );
79
- }
80
- }