@roj-ai/client 0.0.2

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.
@@ -0,0 +1,18 @@
1
+ import { RpcClient, RpcError } from '@roj-ai/shared/rpc';
2
+ import type { Result, RpcErrorInfo, RpcInput, RpcMethodName, RpcOutput } from '@roj-ai/shared/rpc';
3
+ export { RpcClient, RpcError };
4
+ export type { RpcErrorInfo };
5
+ export interface ApiClient {
6
+ call<M extends RpcMethodName>(method: M, input: RpcInput<M>): Promise<Result<RpcOutput<M>, RpcErrorInfo>>;
7
+ uploadFile(sessionId: string, file: File): Promise<{
8
+ uploadId: string;
9
+ status: 'ready' | 'failed';
10
+ extractedContent?: string;
11
+ }>;
12
+ }
13
+ export declare function configureApiBaseUrl(url: string): void;
14
+ export declare function getApiBaseUrl(): string;
15
+ export declare function configureProjectId(projectId: string | null): void;
16
+ export declare function createApiClient(baseUrl?: string): ApiClient;
17
+ export declare const api: ApiClient;
18
+ export declare function useApiError(error: unknown): string | null;
@@ -0,0 +1,2 @@
1
+ import type { Result, RpcErrorInfo } from '@roj-ai/shared/rpc';
2
+ export declare function unwrap<T>(result: Result<T, RpcErrorInfo>): T;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @roj-ai/client
3
+ *
4
+ * Vanilla TypeScript client for the roj agent server. No React — React hooks
5
+ * and chat components live in `@roj-ai/client-react`.
6
+ */
7
+ export { api, configureApiBaseUrl, createApiClient, getApiBaseUrl, configureProjectId, RpcClient, RpcError, useApiError, } from './api/client';
8
+ export type { ApiClient } from './api/client';
9
+ export { unwrap } from './api/unwrap';
@@ -0,0 +1,6 @@
1
+ import type { RpcError } from './rpc-definition';
2
+ export declare class RojApiError extends Error {
3
+ readonly error: RpcError;
4
+ readonly type: string;
5
+ constructor(error: RpcError);
6
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @roj-ai/client/platform
3
+ *
4
+ * Client SDK for the roj platform REST API. Works against both the full
5
+ * platform (Cloudflare worker) and the standalone server.
6
+ */
7
+ export { defineMethods, method } from './rpc-definition';
8
+ export type { MethodDef, MethodInput, MethodOutput, RpcRequest, RpcResponse, RpcError } from './rpc-definition';
9
+ export { createRpcClient } from './rpc-client';
10
+ export type { RpcClient, RpcClientOptions, RpcResult } from './rpc-client';
11
+ export { createRpcRouter } from './rpc-server';
12
+ export type { RpcRouter, MethodHandler, MethodHandlers } from './rpc-server';
13
+ export { platformMethods } from './methods';
14
+ export type { PlatformMethods, PlatformMethodName } from './methods';
15
+ export type * from './methods';
16
+ export { instanceMethods } from './instance-methods';
17
+ export type { InstanceMethods, InstanceMethodName } from './instance-methods';
18
+ export type * from './instance-methods';
19
+ export type { SandboxState } from './sandbox-state';
20
+ export { buildPreviewUrl, buildWsUrl, buildApiBaseUrl, instanceIdToHex } from './urls';
21
+ export type { BuildPreviewUrlOptions, BuildWsUrlOptions } from './urls';
22
+ export { createRojClient } from './rest-client';
23
+ export type { RojClient, RojClientOptions } from './rest-client';
24
+ export { RojApiError } from './errors';
@@ -0,0 +1,94 @@
1
+ import type { PublishSessionOutput, GetAgentLogsOutput } from './methods';
2
+ export type InstanceCreateSandboxInput = {};
3
+ export interface InstanceCreateSandboxOutput {
4
+ sandboxId: string;
5
+ }
6
+ export interface InstancePauseSandboxInput {
7
+ sandboxId: string;
8
+ }
9
+ export type InstanceResumeSandboxInput = {};
10
+ export interface InstanceTerminateSandboxInput {
11
+ sandboxId: string;
12
+ }
13
+ export interface InstanceRestartAgentInput {
14
+ sandboxId: string;
15
+ }
16
+ export interface InstanceGetAgentLogsInput {
17
+ sandboxId: string;
18
+ lines?: number;
19
+ }
20
+ export interface InstanceExecInSandboxInput {
21
+ command: string;
22
+ }
23
+ export interface InstanceExecInSandboxOutput {
24
+ stdout: string;
25
+ stderr: string;
26
+ success: boolean;
27
+ }
28
+ export interface InstanceValidateSandboxTokenInput {
29
+ sandboxId: string;
30
+ token: string;
31
+ }
32
+ export interface InstanceValidateSandboxTokenOutput {
33
+ value: boolean;
34
+ }
35
+ export interface InstanceCreateSessionInput {
36
+ presetId: string;
37
+ }
38
+ export interface InstanceCreateSessionOutput {
39
+ sessionId: string;
40
+ }
41
+ export type InstanceListSessionsInput = {};
42
+ export interface InstanceListSessionsOutput {
43
+ sessions: Array<{
44
+ id: string;
45
+ presetId: string | null;
46
+ status: string;
47
+ createdAt: number;
48
+ }>;
49
+ }
50
+ export interface InstancePublishSessionInput {
51
+ sessionId: string;
52
+ }
53
+ export interface InstanceGetServiceUrlInput {
54
+ sessionId: string;
55
+ serviceType: string;
56
+ }
57
+ export interface InstanceGetServiceUrlOutput {
58
+ url: string | null;
59
+ }
60
+ export interface InstanceGetServiceUrlsInput {
61
+ sessionId: string;
62
+ }
63
+ export interface InstanceGetServiceUrlsOutput {
64
+ services: Array<{
65
+ serviceType: string;
66
+ code: string;
67
+ port: number;
68
+ }>;
69
+ }
70
+ export interface InstanceEnsureSandboxOutput {
71
+ sandboxId: string;
72
+ state: string;
73
+ }
74
+ export interface InstanceOkOutput {
75
+ ok: boolean;
76
+ }
77
+ export declare const instanceMethods: {
78
+ createSandbox: import("./rpc-definition").MethodDef<InstanceCreateSandboxInput, InstanceCreateSandboxOutput>;
79
+ pauseSandbox: import("./rpc-definition").MethodDef<InstancePauseSandboxInput, InstanceOkOutput>;
80
+ resumeSandbox: import("./rpc-definition").MethodDef<InstanceResumeSandboxInput, InstanceOkOutput>;
81
+ terminateSandbox: import("./rpc-definition").MethodDef<InstanceTerminateSandboxInput, InstanceOkOutput>;
82
+ restartAgent: import("./rpc-definition").MethodDef<InstanceRestartAgentInput, InstanceOkOutput>;
83
+ getAgentLogs: import("./rpc-definition").MethodDef<InstanceGetAgentLogsInput, GetAgentLogsOutput>;
84
+ execInSandbox: import("./rpc-definition").MethodDef<InstanceExecInSandboxInput, InstanceExecInSandboxOutput>;
85
+ validateSandboxToken: import("./rpc-definition").MethodDef<InstanceValidateSandboxTokenInput, InstanceValidateSandboxTokenOutput>;
86
+ createSession: import("./rpc-definition").MethodDef<InstanceCreateSessionInput, InstanceCreateSessionOutput>;
87
+ listSessions: import("./rpc-definition").MethodDef<InstanceListSessionsInput, InstanceListSessionsOutput>;
88
+ publishSession: import("./rpc-definition").MethodDef<InstancePublishSessionInput, PublishSessionOutput>;
89
+ getServiceUrl: import("./rpc-definition").MethodDef<InstanceGetServiceUrlInput, InstanceGetServiceUrlOutput>;
90
+ getServiceUrls: import("./rpc-definition").MethodDef<InstanceGetServiceUrlsInput, InstanceGetServiceUrlsOutput>;
91
+ ensureSandbox: import("./rpc-definition").MethodDef<{}, InstanceEnsureSandboxOutput>;
92
+ };
93
+ export type InstanceMethods = typeof instanceMethods;
94
+ export type InstanceMethodName = keyof InstanceMethods;
@@ -0,0 +1,260 @@
1
+ import type { SandboxState } from './sandbox-state';
2
+ export interface CreateInstanceInput {
3
+ templateSlug: string;
4
+ bundleSlug?: string;
5
+ bundleRevisionId?: string;
6
+ name: string;
7
+ vcsType?: 'github' | 'gitLocal' | 'none';
8
+ metadata?: Record<string, unknown>;
9
+ autoCreateSession?: {
10
+ presetId: string;
11
+ blocking?: boolean;
12
+ initialPrompt?: string;
13
+ resourceIds?: string[];
14
+ fileIds?: string[];
15
+ };
16
+ }
17
+ export interface CreateInstanceOutput {
18
+ instanceId: string;
19
+ status: 'created' | 'initializing' | 'ready';
20
+ sessionId?: string;
21
+ wsToken?: string;
22
+ }
23
+ export interface GetInstanceInput {
24
+ instanceId: string;
25
+ }
26
+ export interface GetInstanceOutput {
27
+ instanceId: string;
28
+ name: string;
29
+ status: string;
30
+ templateSlug: string;
31
+ bundleSlug: string;
32
+ bundleRevisionId: string;
33
+ vcsType: string;
34
+ metadata: Record<string, unknown> | null;
35
+ createdAt: string;
36
+ }
37
+ export interface GetInstanceStatusInput {
38
+ instanceId: string;
39
+ }
40
+ export interface GetInstanceStatusOutput {
41
+ instanceId: string;
42
+ status: string;
43
+ sandbox: {
44
+ state: SandboxState;
45
+ e2bId?: string;
46
+ lastActivityAt?: string;
47
+ } | null;
48
+ sessions: Array<{
49
+ id: string;
50
+ presetId: string | null;
51
+ status: string;
52
+ createdAt: string;
53
+ }>;
54
+ lifecycleEvents: Array<{
55
+ event: string;
56
+ detail?: string;
57
+ createdAt: string;
58
+ }>;
59
+ serviceUrls: Array<{
60
+ code: string;
61
+ sessionId: string | null;
62
+ serviceType: string | null;
63
+ port: number;
64
+ }>;
65
+ }
66
+ export interface ArchiveInstanceInput {
67
+ instanceId: string;
68
+ }
69
+ export interface ArchiveInstanceOutput {
70
+ ok: boolean;
71
+ }
72
+ export interface ListInstancesInput {
73
+ limit?: number;
74
+ offset?: number;
75
+ }
76
+ export interface ListInstancesOutput {
77
+ instances: GetInstanceOutput[];
78
+ total: number;
79
+ }
80
+ export interface CreateSessionInput {
81
+ instanceId: string;
82
+ presetId: string;
83
+ blocking?: boolean;
84
+ origin?: string;
85
+ expiresIn?: number;
86
+ }
87
+ export interface CreateSessionOutput {
88
+ sessionId: string;
89
+ status: 'creating' | 'active';
90
+ wsToken?: string;
91
+ }
92
+ export interface ListSessionsInput {
93
+ instanceId: string;
94
+ }
95
+ export interface ListSessionsOutput {
96
+ sessions: Array<{
97
+ id: string;
98
+ presetId: string | null;
99
+ status: string;
100
+ createdAt: string;
101
+ }>;
102
+ }
103
+ export interface PublishSessionInput {
104
+ instanceId: string;
105
+ sessionId: string;
106
+ }
107
+ export interface PublishSessionOutput {
108
+ ok: boolean;
109
+ pushed: boolean;
110
+ commitSha?: string;
111
+ error?: string;
112
+ }
113
+ export interface CreateInstanceTokenInput {
114
+ instanceId: string;
115
+ origin?: string;
116
+ expiresIn?: number;
117
+ meta?: Record<string, unknown>;
118
+ }
119
+ export interface CreateInstanceTokenOutput {
120
+ token: string;
121
+ expiresAt: string;
122
+ }
123
+ export interface ListBundlesInput {
124
+ limit?: number;
125
+ offset?: number;
126
+ }
127
+ export interface ListBundlesOutput {
128
+ bundles: Array<{
129
+ id: string;
130
+ slug: string;
131
+ name: string | null;
132
+ description: string | null;
133
+ latestRevision: {
134
+ id: string;
135
+ version: string | null;
136
+ r2Key: string;
137
+ createdAt: string;
138
+ } | null;
139
+ createdAt: string;
140
+ }>;
141
+ }
142
+ export interface DeleteBundleInput {
143
+ bundleId?: string;
144
+ bundleSlug?: string;
145
+ }
146
+ export interface DeleteBundleOutput {
147
+ ok: boolean;
148
+ }
149
+ export interface CreateResourceInput {
150
+ slug: string;
151
+ name?: string;
152
+ description?: string;
153
+ fileId: string;
154
+ label?: string;
155
+ }
156
+ export interface CreateResourceOutput {
157
+ resourceId: string;
158
+ revisionId: string;
159
+ }
160
+ export interface AddResourceRevisionInput {
161
+ resourceId?: string;
162
+ resourceSlug?: string;
163
+ fileId: string;
164
+ label?: string;
165
+ }
166
+ export interface AddResourceRevisionOutput {
167
+ revisionId: string;
168
+ }
169
+ export interface GetResourceInput {
170
+ resourceId?: string;
171
+ resourceSlug?: string;
172
+ }
173
+ export interface GetResourceOutput {
174
+ id: string;
175
+ slug: string;
176
+ name: string | null;
177
+ description: string | null;
178
+ latestRevision: {
179
+ id: string;
180
+ label: string | null;
181
+ file: {
182
+ id: string;
183
+ filename: string;
184
+ mimeType: string;
185
+ size: number;
186
+ };
187
+ createdAt: string;
188
+ } | null;
189
+ createdAt: string;
190
+ }
191
+ export interface ListResourcesInput {
192
+ limit?: number;
193
+ offset?: number;
194
+ }
195
+ export interface ListResourcesOutput {
196
+ resources: GetResourceOutput[];
197
+ }
198
+ export interface DeleteResourceInput {
199
+ resourceId: string;
200
+ }
201
+ export interface DeleteResourceOutput {
202
+ ok: boolean;
203
+ }
204
+ export interface PauseSandboxInput {
205
+ instanceId: string;
206
+ sandboxId: string;
207
+ }
208
+ export interface ResumeSandboxInput {
209
+ instanceId: string;
210
+ sandboxId: string;
211
+ }
212
+ export interface TerminateSandboxInput {
213
+ instanceId: string;
214
+ sandboxId: string;
215
+ }
216
+ export interface RestartAgentInput {
217
+ instanceId: string;
218
+ sandboxId: string;
219
+ }
220
+ export interface GetAgentLogsInput {
221
+ instanceId: string;
222
+ sandboxId: string;
223
+ lines?: number;
224
+ }
225
+ export interface GetAgentLogsOutput {
226
+ logs: string;
227
+ truncated: boolean;
228
+ }
229
+ export interface SandboxActionOutput {
230
+ ok: boolean;
231
+ }
232
+ export interface GetServiceUrlInput {
233
+ instanceId: string;
234
+ sessionId: string;
235
+ serviceType: string;
236
+ }
237
+ export interface GetServiceUrlOutput {
238
+ url: string | null;
239
+ }
240
+ export declare const platformMethods: {
241
+ 'instances.create': import("./rpc-definition").MethodDef<CreateInstanceInput, CreateInstanceOutput>;
242
+ 'instances.get': import("./rpc-definition").MethodDef<GetInstanceInput, GetInstanceOutput>;
243
+ 'instances.list': import("./rpc-definition").MethodDef<ListInstancesInput, ListInstancesOutput>;
244
+ 'instances.status': import("./rpc-definition").MethodDef<GetInstanceStatusInput, GetInstanceStatusOutput>;
245
+ 'instances.archive': import("./rpc-definition").MethodDef<ArchiveInstanceInput, ArchiveInstanceOutput>;
246
+ 'sessions.create': import("./rpc-definition").MethodDef<CreateSessionInput, CreateSessionOutput>;
247
+ 'sessions.list': import("./rpc-definition").MethodDef<ListSessionsInput, ListSessionsOutput>;
248
+ 'sessions.publish': import("./rpc-definition").MethodDef<PublishSessionInput, PublishSessionOutput>;
249
+ 'tokens.create': import("./rpc-definition").MethodDef<CreateInstanceTokenInput, CreateInstanceTokenOutput>;
250
+ 'services.getUrl': import("./rpc-definition").MethodDef<GetServiceUrlInput, GetServiceUrlOutput>;
251
+ 'bundles.list': import("./rpc-definition").MethodDef<ListBundlesInput, ListBundlesOutput>;
252
+ 'bundles.delete': import("./rpc-definition").MethodDef<DeleteBundleInput, DeleteBundleOutput>;
253
+ 'resources.create': import("./rpc-definition").MethodDef<CreateResourceInput, CreateResourceOutput>;
254
+ 'resources.addRevision': import("./rpc-definition").MethodDef<AddResourceRevisionInput, AddResourceRevisionOutput>;
255
+ 'resources.get': import("./rpc-definition").MethodDef<GetResourceInput, GetResourceOutput>;
256
+ 'resources.list': import("./rpc-definition").MethodDef<ListResourcesInput, ListResourcesOutput>;
257
+ 'resources.delete': import("./rpc-definition").MethodDef<DeleteResourceInput, DeleteResourceOutput>;
258
+ };
259
+ export type PlatformMethods = typeof platformMethods;
260
+ export type PlatformMethodName = keyof PlatformMethods;
@@ -0,0 +1,49 @@
1
+ import type { CreateInstanceInput, CreateInstanceOutput, GetInstanceOutput, GetInstanceStatusOutput, ListInstancesInput, ListInstancesOutput, ArchiveInstanceOutput, CreateSessionInput, CreateSessionOutput, ListSessionsOutput, PublishSessionInput, PublishSessionOutput, CreateInstanceTokenInput, CreateInstanceTokenOutput, ListBundlesInput, ListBundlesOutput, DeleteBundleOutput, CreateResourceInput, CreateResourceOutput, AddResourceRevisionInput, AddResourceRevisionOutput, GetResourceInput, GetResourceOutput, ListResourcesInput, ListResourcesOutput, DeleteResourceOutput } from './methods';
2
+ export interface RojClientOptions {
3
+ /** Platform URL (e.g. https://roj.example.com) */
4
+ url: string;
5
+ /** Platform API key */
6
+ apiKey: string;
7
+ }
8
+ export interface RojClient {
9
+ instances: {
10
+ create(input: CreateInstanceInput): Promise<CreateInstanceOutput>;
11
+ get(instanceId: string): Promise<GetInstanceOutput>;
12
+ getStatus(instanceId: string): Promise<GetInstanceStatusOutput>;
13
+ list(input?: ListInstancesInput): Promise<ListInstancesOutput>;
14
+ archive(instanceId: string): Promise<ArchiveInstanceOutput>;
15
+ };
16
+ sessions: {
17
+ create(input: CreateSessionInput): Promise<CreateSessionOutput>;
18
+ list(instanceId: string): Promise<ListSessionsOutput>;
19
+ publish(input: PublishSessionInput): Promise<PublishSessionOutput>;
20
+ };
21
+ tokens: {
22
+ create(input: CreateInstanceTokenInput): Promise<CreateInstanceTokenOutput>;
23
+ };
24
+ bundles: {
25
+ list(input?: ListBundlesInput): Promise<ListBundlesOutput>;
26
+ delete(input: {
27
+ bundleId?: string;
28
+ bundleSlug?: string;
29
+ }): Promise<DeleteBundleOutput>;
30
+ };
31
+ files: {
32
+ upload(file: File | Blob, filename?: string): Promise<{
33
+ ok: true;
34
+ fileId: string;
35
+ filename: string;
36
+ mimeType: string;
37
+ size: number;
38
+ r2Key: string;
39
+ }>;
40
+ };
41
+ resources: {
42
+ create(input: CreateResourceInput): Promise<CreateResourceOutput>;
43
+ addRevision(input: AddResourceRevisionInput): Promise<AddResourceRevisionOutput>;
44
+ get(input: GetResourceInput): Promise<GetResourceOutput>;
45
+ list(input?: ListResourcesInput): Promise<ListResourcesOutput>;
46
+ delete(resourceId: string): Promise<DeleteResourceOutput>;
47
+ };
48
+ }
49
+ export declare function createRojClient(options: RojClientOptions): RojClient;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Type-safe RPC client.
3
+ * Mirrors the method definitions for compile-time safety.
4
+ *
5
+ * Usage:
6
+ * const client = createRpcClient<PlatformMethods>('https://api.roj.cloud/rpc', {
7
+ * headers: { Authorization: `Bearer ${apiKey}` },
8
+ * })
9
+ * const result = await client.call('instances.create', { ... })
10
+ */
11
+ import type { MethodDef, MethodInput, MethodOutput, RpcError } from './rpc-definition';
12
+ export interface RpcClientOptions {
13
+ headers?: Record<string, string>;
14
+ credentials?: RequestCredentials;
15
+ }
16
+ export interface RpcClient<Methods extends Record<string, MethodDef>> {
17
+ call<M extends string & keyof Methods>(method: M, input: MethodInput<Methods, M>): Promise<RpcResult<MethodOutput<Methods, M>>>;
18
+ }
19
+ export type RpcResult<T> = {
20
+ ok: true;
21
+ value: T;
22
+ } | {
23
+ ok: false;
24
+ error: RpcError;
25
+ };
26
+ export declare function createRpcClient<Methods extends Record<string, MethodDef>>(baseUrl: string, options?: RpcClientOptions): RpcClient<Methods>;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Type-safe RPC definition system.
3
+ * No external dependencies — just TypeScript types + minimal runtime.
4
+ *
5
+ * Usage:
6
+ * const methods = defineMethods({
7
+ * 'instances.create': method<CreateInput, CreateOutput>(),
8
+ * 'sessions.list': method<ListInput, ListOutput>(),
9
+ * })
10
+ */
11
+ /** Marker type for a method definition (input → output). */
12
+ export interface MethodDef<I = unknown, O = unknown> {
13
+ readonly _input: I;
14
+ readonly _output: O;
15
+ }
16
+ /** Define a method type. Zero runtime cost — just a type marker. */
17
+ export declare function method<I, O>(): MethodDef<I, O>;
18
+ /** Define a set of methods. Returns the definition object as-is (typed). */
19
+ export declare function defineMethods<T extends Record<string, MethodDef>>(methods: T): T;
20
+ /** Extract input type from a method name. */
21
+ export type MethodInput<Methods extends Record<string, MethodDef>, M extends keyof Methods> = Methods[M]['_input'];
22
+ /** Extract output type from a method name. */
23
+ export type MethodOutput<Methods extends Record<string, MethodDef>, M extends keyof Methods> = Methods[M]['_output'];
24
+ /** RPC request envelope. */
25
+ export interface RpcRequest<M extends string = string> {
26
+ method: M;
27
+ input: unknown;
28
+ }
29
+ /** RPC response envelope. */
30
+ export interface RpcResponse<T = unknown> {
31
+ ok: boolean;
32
+ value?: T;
33
+ error?: RpcError;
34
+ }
35
+ export interface RpcError {
36
+ type: string;
37
+ message: string;
38
+ details?: unknown;
39
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Type-safe RPC server handler.
3
+ * Maps method names to handler functions, dispatches incoming requests.
4
+ *
5
+ * Usage:
6
+ * const router = createRpcRouter(platformMethods, {
7
+ * 'instances.create': async (input, ctx) => { ... },
8
+ * 'instances.get': async (input, ctx) => { ... },
9
+ * })
10
+ * // In Hono route:
11
+ * app.post('/rpc', (c) => router.handle(c.req.json(), ctx))
12
+ */
13
+ import type { MethodDef, MethodInput, MethodOutput, RpcRequest, RpcResponse } from './rpc-definition';
14
+ export type MethodHandler<Methods extends Record<string, MethodDef>, M extends keyof Methods, Ctx> = (input: MethodInput<Methods, M>, ctx: Ctx) => Promise<MethodOutput<Methods, M>>;
15
+ export type MethodHandlers<Methods extends Record<string, MethodDef>, Ctx> = {
16
+ [M in keyof Methods]: MethodHandler<Methods, M, Ctx>;
17
+ };
18
+ export interface RpcRouter<Ctx> {
19
+ handle(request: RpcRequest, ctx: Ctx): Promise<RpcResponse>;
20
+ }
21
+ export declare function createRpcRouter<Methods extends Record<string, MethodDef>, Ctx>(_methods: Methods, handlers: MethodHandlers<Methods, Ctx>): RpcRouter<Ctx>;
@@ -0,0 +1 @@
1
+ export type SandboxState = 'stopped' | 'starting' | 'running' | 'pausing' | 'paused' | 'failed';
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Convert an instance UUID to its full 32-char hex representation (no hyphens, lowercase).
3
+ */
4
+ export declare function instanceIdToHex(instanceId: string): string;
5
+ export interface BuildPreviewUrlOptions {
6
+ instanceId: string;
7
+ code: string;
8
+ baseDomain: string;
9
+ /** Optional instance token appended as ?token= for auth */
10
+ token?: string;
11
+ /** Platform URL for path-based preview (used when subdomains aren't available) */
12
+ platformUrl?: string;
13
+ }
14
+ /**
15
+ * Build a dev preview URL for a service running in a roj sandbox.
16
+ *
17
+ * Production: https://dev-{slug}-{code}.{baseDomain}/
18
+ * Local dev: {platformUrl}/api/v1/instances/{id}/preview/{code}/
19
+ */
20
+ export declare function buildPreviewUrl({ instanceId, code, baseDomain, token, platformUrl }: BuildPreviewUrlOptions): string;
21
+ export interface BuildWsUrlOptions {
22
+ platformUrl: string;
23
+ instanceId: string;
24
+ sessionId: string;
25
+ token: string;
26
+ }
27
+ /**
28
+ * Build a WebSocket URL for connecting to a roj instance.
29
+ */
30
+ export declare function buildWsUrl({ platformUrl, instanceId, sessionId, token }: BuildWsUrlOptions): string;
31
+ /**
32
+ * Build the RPC base URL for a roj instance.
33
+ */
34
+ export declare function buildApiBaseUrl(platformUrl: string, instanceId: string): string;