@boboddy/sdk 0.0.7-alpha

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,9 @@
1
+ import type { ApiErrorResponse } from "./contracts";
2
+ type ElysiaErrorCode = "UNKNOWN" | "VALIDATION" | "NOT_FOUND" | "PARSE" | "INTERNAL_SERVER_ERROR" | "INVALID_COOKIE_SIGNATURE" | "INVALID_FILE_TYPE" | (string & {}) | number;
3
+ type ProblemDetailsOptions = {
4
+ code: ElysiaErrorCode;
5
+ error: unknown;
6
+ request: Request;
7
+ };
8
+ export declare function createProblemDetails({ code, error, request, }: ProblemDetailsOptions): ApiErrorResponse;
9
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,62 @@
1
+ // src/treaty.ts
2
+ import { treaty } from "@elysiajs/eden";
3
+ var TRAILING_SLASHES_PATTERN = /\/+$/u;
4
+ var API_SUFFIX_PATTERN = /\/api$/u;
5
+ var normalizeBoboddyBaseUrl = (baseUrl) => {
6
+ const trimmedBaseUrl = baseUrl.trim();
7
+ if (trimmedBaseUrl.length === 0) {
8
+ return "";
9
+ }
10
+ return trimmedBaseUrl.replace(TRAILING_SLASHES_PATTERN, "").replace(API_SUFFIX_PATTERN, "");
11
+ };
12
+ function createBoboddyTreaty(baseUrlOrApp) {
13
+ if (typeof baseUrlOrApp === "string") {
14
+ return treaty(normalizeBoboddyBaseUrl(baseUrlOrApp), {
15
+ parseDate: false
16
+ });
17
+ }
18
+ return treaty(baseUrlOrApp, {
19
+ parseDate: false
20
+ });
21
+ }
22
+ var unwrapTreatyResponse = async (promise) => {
23
+ const { data, error } = await promise;
24
+ if (error) {
25
+ throw error.value;
26
+ }
27
+ return data;
28
+ };
29
+ var createBoboddyApiClient = createBoboddyTreaty;
30
+ // src/step-execution-plane-client.ts
31
+ function createStepExecutionPlaneClient(baseUrlOrApp) {
32
+ return buildStepExecutionPlaneClient(createBoboddyTreaty(baseUrlOrApp));
33
+ }
34
+ var buildStepExecutionPlaneClient = (apiClient) => {
35
+ return {
36
+ claimStepExecutions: async (body, options) => await unwrapTreatyResponse(apiClient.api["step-executions"].claims.post(body, options)),
37
+ heartbeatStepExecution: async (stepExecutionId, body, options) => await unwrapTreatyResponse(apiClient.api["step-executions"]({
38
+ stepExecutionId
39
+ }).heartbeat.put(body, options)),
40
+ getStepExecution: async (stepExecutionId, options) => await unwrapTreatyResponse(apiClient.api["step-executions"]({
41
+ stepExecutionId
42
+ }).get(options)),
43
+ getStepExecutionWorkerContext: async (stepExecutionId, body, options) => await unwrapTreatyResponse(apiClient.api["step-executions"]({
44
+ stepExecutionId
45
+ })["worker-context"].post(body, options)),
46
+ completeStepExecution: async (stepExecutionId, body, options) => await unwrapTreatyResponse(apiClient.api["step-executions"]({
47
+ stepExecutionId
48
+ }).completions.post(body, options)),
49
+ failStepExecution: async (stepExecutionId, body, options) => await unwrapTreatyResponse(apiClient.api["step-executions"]({
50
+ stepExecutionId
51
+ }).completions.post({
52
+ ...body,
53
+ status: "failed"
54
+ }, options))
55
+ };
56
+ };
57
+ export {
58
+ unwrapTreatyResponse,
59
+ createStepExecutionPlaneClient,
60
+ createBoboddyTreaty,
61
+ createBoboddyApiClient
62
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from "./treaty";
2
+ export * from "./step-execution-plane-client";
@@ -0,0 +1 @@
1
+ export * from "./client";
@@ -0,0 +1,369 @@
1
+ import type { App } from "@boboddy/api/app";
2
+ import { createBoboddyTreaty } from "./treaty";
3
+ type JsonValue = string | number | boolean | null | {
4
+ [key: string]: JsonValue;
5
+ } | JsonValue[];
6
+ type RequestOptions = {
7
+ headers?: Record<string, unknown> | undefined;
8
+ };
9
+ export declare function createStepExecutionPlaneClient(baseUrlOrApp: string | App): ReturnType<typeof buildStepExecutionPlaneClient>;
10
+ declare const buildStepExecutionPlaneClient: (apiClient: ReturnType<typeof createBoboddyTreaty>) => {
11
+ claimStepExecutions: (body: {
12
+ projectId: string;
13
+ workerId: string;
14
+ batchSize: number;
15
+ leaseDurationSeconds: number;
16
+ }, options?: RequestOptions) => Promise<{
17
+ stepExecution: {
18
+ id: string & {
19
+ readonly __brand: "uuidv7";
20
+ };
21
+ projectId: string & {
22
+ readonly __brand: "uuidv7";
23
+ };
24
+ stepDefinitionId: string & {
25
+ readonly __brand: "uuidv7";
26
+ };
27
+ stepDefinitionVersion: number;
28
+ status: "queued" | "running" | "succeeded" | "failed" | "cancelled" | "skipped" | "timeout" | "abandoned";
29
+ inputJson: import("@boboddy/core/common/contracts/json").AnyJsonValue;
30
+ claimedBy: string | null;
31
+ claimedAt: string | null;
32
+ lastHeartbeatAt: string | null;
33
+ leaseExpiresAt: string | null;
34
+ executionTimeoutSeconds: number | null;
35
+ executionDeadlineAt: string | null;
36
+ startedAt: string | null;
37
+ completedAt: string | null;
38
+ results: {
39
+ id: string & {
40
+ readonly __brand: "uuidv7";
41
+ };
42
+ stepExecutionId: string & {
43
+ readonly __brand: "uuidv7";
44
+ };
45
+ attempt: number;
46
+ status: "succeeded" | "failed";
47
+ resultJson: import("@boboddy/core/common/contracts/json").AnyJsonValue;
48
+ errorJson: import("@boboddy/core/common/contracts/json").AnyJsonValue;
49
+ signals: {
50
+ id: string & {
51
+ readonly __brand: "uuidv7";
52
+ };
53
+ stepExecutionResultId: string & {
54
+ readonly __brand: "uuidv7";
55
+ };
56
+ key: string;
57
+ type: "string" | "number" | "boolean" | "object" | "array";
58
+ source: "extracted" | "computed";
59
+ valueJson: import("@boboddy/core/common/contracts/json").AnyJsonValue;
60
+ sourcePath: string | null;
61
+ computedFromSignalKeys: string[] | null;
62
+ createdAt: string;
63
+ }[];
64
+ createdAt: string;
65
+ }[];
66
+ createdAt: string;
67
+ updatedAt: string;
68
+ };
69
+ claimToken: string;
70
+ }[]>;
71
+ heartbeatStepExecution: (stepExecutionId: string, body: {
72
+ claimToken: string;
73
+ leaseDurationSeconds: number;
74
+ }, options?: RequestOptions) => Promise<{
75
+ id: string & {
76
+ readonly __brand: "uuidv7";
77
+ };
78
+ projectId: string & {
79
+ readonly __brand: "uuidv7";
80
+ };
81
+ stepDefinitionId: string & {
82
+ readonly __brand: "uuidv7";
83
+ };
84
+ stepDefinitionVersion: number;
85
+ status: "queued" | "running" | "succeeded" | "failed" | "cancelled" | "skipped" | "timeout" | "abandoned";
86
+ inputJson: import("@boboddy/core/common/contracts/json").AnyJsonValue;
87
+ claimedBy: string | null;
88
+ claimedAt: string | null;
89
+ lastHeartbeatAt: string | null;
90
+ leaseExpiresAt: string | null;
91
+ executionTimeoutSeconds: number | null;
92
+ executionDeadlineAt: string | null;
93
+ startedAt: string | null;
94
+ completedAt: string | null;
95
+ results: {
96
+ id: string & {
97
+ readonly __brand: "uuidv7";
98
+ };
99
+ stepExecutionId: string & {
100
+ readonly __brand: "uuidv7";
101
+ };
102
+ attempt: number;
103
+ status: "succeeded" | "failed";
104
+ resultJson: import("@boboddy/core/common/contracts/json").AnyJsonValue;
105
+ errorJson: import("@boboddy/core/common/contracts/json").AnyJsonValue;
106
+ signals: {
107
+ id: string & {
108
+ readonly __brand: "uuidv7";
109
+ };
110
+ stepExecutionResultId: string & {
111
+ readonly __brand: "uuidv7";
112
+ };
113
+ key: string;
114
+ type: "string" | "number" | "boolean" | "object" | "array";
115
+ source: "extracted" | "computed";
116
+ valueJson: import("@boboddy/core/common/contracts/json").AnyJsonValue;
117
+ sourcePath: string | null;
118
+ computedFromSignalKeys: string[] | null;
119
+ createdAt: string;
120
+ }[];
121
+ createdAt: string;
122
+ }[];
123
+ createdAt: string;
124
+ updatedAt: string;
125
+ }>;
126
+ getStepExecution: (stepExecutionId: string, options?: RequestOptions) => Promise<{
127
+ id: string & {
128
+ readonly __brand: "uuidv7";
129
+ };
130
+ projectId: string & {
131
+ readonly __brand: "uuidv7";
132
+ };
133
+ stepDefinitionId: string & {
134
+ readonly __brand: "uuidv7";
135
+ };
136
+ stepDefinitionVersion: number;
137
+ status: "queued" | "running" | "succeeded" | "failed" | "cancelled" | "skipped" | "timeout" | "abandoned";
138
+ inputJson: import("@boboddy/core/common/contracts/json").AnyJsonValue;
139
+ claimedBy: string | null;
140
+ claimedAt: string | null;
141
+ lastHeartbeatAt: string | null;
142
+ leaseExpiresAt: string | null;
143
+ executionTimeoutSeconds: number | null;
144
+ executionDeadlineAt: string | null;
145
+ startedAt: string | null;
146
+ completedAt: string | null;
147
+ results: {
148
+ id: string & {
149
+ readonly __brand: "uuidv7";
150
+ };
151
+ stepExecutionId: string & {
152
+ readonly __brand: "uuidv7";
153
+ };
154
+ attempt: number;
155
+ status: "succeeded" | "failed";
156
+ resultJson: import("@boboddy/core/common/contracts/json").AnyJsonValue;
157
+ errorJson: import("@boboddy/core/common/contracts/json").AnyJsonValue;
158
+ signals: {
159
+ id: string & {
160
+ readonly __brand: "uuidv7";
161
+ };
162
+ stepExecutionResultId: string & {
163
+ readonly __brand: "uuidv7";
164
+ };
165
+ key: string;
166
+ type: "string" | "number" | "boolean" | "object" | "array";
167
+ source: "extracted" | "computed";
168
+ valueJson: import("@boboddy/core/common/contracts/json").AnyJsonValue;
169
+ sourcePath: string | null;
170
+ computedFromSignalKeys: string[] | null;
171
+ createdAt: string;
172
+ }[];
173
+ createdAt: string;
174
+ }[];
175
+ createdAt: string;
176
+ updatedAt: string;
177
+ }>;
178
+ getStepExecutionWorkerContext: (stepExecutionId: string, body: {
179
+ claimToken: string;
180
+ }, options?: RequestOptions) => Promise<{
181
+ projectId: string & {
182
+ readonly __brand: "uuidv7";
183
+ };
184
+ gitUrl: string;
185
+ requestedBranch: string | null;
186
+ projectOpencodeConfig: {
187
+ relativePath: string;
188
+ present: boolean;
189
+ commands: {
190
+ name: string;
191
+ description: string;
192
+ run: string;
193
+ cwd: string | null;
194
+ }[];
195
+ services: {
196
+ name: string;
197
+ description: string;
198
+ run: string;
199
+ cwd: string | null;
200
+ dependsOn: string[];
201
+ expose: {
202
+ targetPort: number;
203
+ protocol: "tcp" | "http";
204
+ };
205
+ healthcheck: {
206
+ protocol: "tcp" | "http";
207
+ path: string | null;
208
+ expectedStatus: number | null;
209
+ };
210
+ }[];
211
+ };
212
+ stepExecution: {
213
+ id: string & {
214
+ readonly __brand: "uuidv7";
215
+ };
216
+ status: "queued" | "running" | "succeeded" | "failed" | "cancelled" | "skipped" | "timeout" | "abandoned";
217
+ inputJson: import("@boboddy/core/common/contracts/json").AnyJsonValue;
218
+ executionTimeoutSeconds: number | null;
219
+ };
220
+ stepDefinition: {
221
+ id: string & {
222
+ readonly __brand: "uuidv7";
223
+ };
224
+ key: string;
225
+ name: string;
226
+ prompt: string;
227
+ resultSchemaJson: import("@boboddy/core/common/contracts/json").AnyJsonObject | null;
228
+ opencodeMcpJson: Record<string, {
229
+ type: "local";
230
+ command: string[];
231
+ environment?: Record<string, string> | undefined;
232
+ enabled?: boolean | undefined;
233
+ timeout?: number | undefined;
234
+ } | {
235
+ type: "remote";
236
+ url: string;
237
+ enabled?: boolean | undefined;
238
+ headers?: Record<string, string> | undefined;
239
+ oauth?: false | {
240
+ clientId?: string | undefined;
241
+ clientSecret?: string | undefined;
242
+ scope?: string | undefined;
243
+ redirectUri?: string | undefined;
244
+ } | undefined;
245
+ timeout?: number | undefined;
246
+ } | {
247
+ enabled: boolean;
248
+ }> | null;
249
+ };
250
+ agentPrompt: {
251
+ sessionTitle: string;
252
+ promptText: string;
253
+ };
254
+ }>;
255
+ completeStepExecution: (stepExecutionId: string, body: {
256
+ claimToken: string;
257
+ status: "succeeded" | "failed";
258
+ resultJson: JsonValue;
259
+ errorJson: JsonValue;
260
+ }, options?: RequestOptions) => Promise<{
261
+ id: string & {
262
+ readonly __brand: "uuidv7";
263
+ };
264
+ projectId: string & {
265
+ readonly __brand: "uuidv7";
266
+ };
267
+ stepDefinitionId: string & {
268
+ readonly __brand: "uuidv7";
269
+ };
270
+ stepDefinitionVersion: number;
271
+ status: "queued" | "running" | "succeeded" | "failed" | "cancelled" | "skipped" | "timeout" | "abandoned";
272
+ inputJson: import("@boboddy/core/common/contracts/json").AnyJsonValue;
273
+ claimedBy: string | null;
274
+ claimedAt: string | null;
275
+ lastHeartbeatAt: string | null;
276
+ leaseExpiresAt: string | null;
277
+ executionTimeoutSeconds: number | null;
278
+ executionDeadlineAt: string | null;
279
+ startedAt: string | null;
280
+ completedAt: string | null;
281
+ results: {
282
+ id: string & {
283
+ readonly __brand: "uuidv7";
284
+ };
285
+ stepExecutionId: string & {
286
+ readonly __brand: "uuidv7";
287
+ };
288
+ attempt: number;
289
+ status: "succeeded" | "failed";
290
+ resultJson: import("@boboddy/core/common/contracts/json").AnyJsonValue;
291
+ errorJson: import("@boboddy/core/common/contracts/json").AnyJsonValue;
292
+ signals: {
293
+ id: string & {
294
+ readonly __brand: "uuidv7";
295
+ };
296
+ stepExecutionResultId: string & {
297
+ readonly __brand: "uuidv7";
298
+ };
299
+ key: string;
300
+ type: "string" | "number" | "boolean" | "object" | "array";
301
+ source: "extracted" | "computed";
302
+ valueJson: import("@boboddy/core/common/contracts/json").AnyJsonValue;
303
+ sourcePath: string | null;
304
+ computedFromSignalKeys: string[] | null;
305
+ createdAt: string;
306
+ }[];
307
+ createdAt: string;
308
+ }[];
309
+ createdAt: string;
310
+ updatedAt: string;
311
+ }>;
312
+ failStepExecution: (stepExecutionId: string, body: {
313
+ claimToken: string;
314
+ resultJson: JsonValue;
315
+ errorJson: JsonValue;
316
+ }, options?: RequestOptions) => Promise<{
317
+ id: string & {
318
+ readonly __brand: "uuidv7";
319
+ };
320
+ projectId: string & {
321
+ readonly __brand: "uuidv7";
322
+ };
323
+ stepDefinitionId: string & {
324
+ readonly __brand: "uuidv7";
325
+ };
326
+ stepDefinitionVersion: number;
327
+ status: "queued" | "running" | "succeeded" | "failed" | "cancelled" | "skipped" | "timeout" | "abandoned";
328
+ inputJson: import("@boboddy/core/common/contracts/json").AnyJsonValue;
329
+ claimedBy: string | null;
330
+ claimedAt: string | null;
331
+ lastHeartbeatAt: string | null;
332
+ leaseExpiresAt: string | null;
333
+ executionTimeoutSeconds: number | null;
334
+ executionDeadlineAt: string | null;
335
+ startedAt: string | null;
336
+ completedAt: string | null;
337
+ results: {
338
+ id: string & {
339
+ readonly __brand: "uuidv7";
340
+ };
341
+ stepExecutionId: string & {
342
+ readonly __brand: "uuidv7";
343
+ };
344
+ attempt: number;
345
+ status: "succeeded" | "failed";
346
+ resultJson: import("@boboddy/core/common/contracts/json").AnyJsonValue;
347
+ errorJson: import("@boboddy/core/common/contracts/json").AnyJsonValue;
348
+ signals: {
349
+ id: string & {
350
+ readonly __brand: "uuidv7";
351
+ };
352
+ stepExecutionResultId: string & {
353
+ readonly __brand: "uuidv7";
354
+ };
355
+ key: string;
356
+ type: "string" | "number" | "boolean" | "object" | "array";
357
+ source: "extracted" | "computed";
358
+ valueJson: import("@boboddy/core/common/contracts/json").AnyJsonValue;
359
+ sourcePath: string | null;
360
+ computedFromSignalKeys: string[] | null;
361
+ createdAt: string;
362
+ }[];
363
+ createdAt: string;
364
+ }[];
365
+ createdAt: string;
366
+ updatedAt: string;
367
+ }>;
368
+ };
369
+ export {};
@@ -0,0 +1,13 @@
1
+ import { treaty } from "@elysiajs/eden";
2
+ import type { App } from "@boboddy/api/app";
3
+ export declare function createBoboddyTreaty(baseUrlOrApp: string | App): ReturnType<typeof treaty<App>>;
4
+ export type BoboddyTreaty = ReturnType<typeof createBoboddyTreaty>;
5
+ type EdenResult<T> = {
6
+ data: T | null | undefined;
7
+ error: {
8
+ value: unknown;
9
+ } | null | undefined;
10
+ };
11
+ export declare const unwrapTreatyResponse: <T>(promise: Promise<EdenResult<T>>) => Promise<T>;
12
+ export declare const createBoboddyApiClient: typeof createBoboddyTreaty;
13
+ export {};
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/package.json",
3
+ "name": "@boboddy/sdk",
4
+ "version": "0.0.7-alpha",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./dist/index.js",
9
+ "types": "./dist/index.d.ts"
10
+ },
11
+ "./client": {
12
+ "import": "./dist/client.js",
13
+ "types": "./dist/client.d.ts"
14
+ },
15
+ "./treaty": {
16
+ "import": "./dist/treaty.js",
17
+ "types": "./dist/treaty.d.ts"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "README.md"
23
+ ],
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "scripts": {
28
+ "build": "bun run script/build.ts",
29
+ "typecheck": "tsc -p tsconfig.json --noEmit"
30
+ },
31
+ "dependencies": {
32
+ "@elysiajs/eden": "^1.4.9"
33
+ },
34
+ "devDependencies": {
35
+ "@hey-api/openapi-ts": "^0.90.10",
36
+ "bun-types": "^1.3.12"
37
+ }
38
+ }