@agentuity/core 2.0.7 → 2.0.9-v3.48d5810
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/dist/services/coder/agents.d.ts +172 -0
- package/dist/services/coder/agents.d.ts.map +1 -0
- package/dist/services/coder/agents.js +77 -0
- package/dist/services/coder/agents.js.map +1 -0
- package/dist/services/coder/api-reference.d.ts +4 -0
- package/dist/services/coder/api-reference.d.ts.map +1 -0
- package/dist/services/coder/api-reference.js +551 -0
- package/dist/services/coder/api-reference.js.map +1 -0
- package/dist/services/coder/client.d.ts +170 -0
- package/dist/services/coder/client.d.ts.map +1 -0
- package/dist/services/coder/client.js +351 -0
- package/dist/services/coder/client.js.map +1 -0
- package/dist/services/coder/close-codes.d.ts +76 -0
- package/dist/services/coder/close-codes.d.ts.map +1 -0
- package/dist/services/coder/close-codes.js +77 -0
- package/dist/services/coder/close-codes.js.map +1 -0
- package/dist/services/coder/discover.d.ts +13 -0
- package/dist/services/coder/discover.d.ts.map +1 -0
- package/dist/services/coder/discover.js +18 -0
- package/dist/services/coder/discover.js.map +1 -0
- package/dist/services/coder/github.d.ts +13 -0
- package/dist/services/coder/github.d.ts.map +1 -0
- package/dist/services/coder/github.js +15 -0
- package/dist/services/coder/github.js.map +1 -0
- package/dist/services/coder/index.d.ts +26 -0
- package/dist/services/coder/index.d.ts.map +1 -0
- package/dist/services/coder/index.js +18 -0
- package/dist/services/coder/index.js.map +1 -0
- package/dist/services/coder/loop-state.d.ts +10 -0
- package/dist/services/coder/loop-state.d.ts.map +1 -0
- package/dist/services/coder/loop-state.js +13 -0
- package/dist/services/coder/loop-state.js.map +1 -0
- package/dist/services/coder/protocol.d.ts +1855 -0
- package/dist/services/coder/protocol.d.ts.map +1 -0
- package/dist/services/coder/protocol.js +976 -0
- package/dist/services/coder/protocol.js.map +1 -0
- package/dist/services/coder/session-data.d.ts +28 -0
- package/dist/services/coder/session-data.d.ts.map +1 -0
- package/dist/services/coder/session-data.js +28 -0
- package/dist/services/coder/session-data.js.map +1 -0
- package/dist/services/coder/sessions.d.ts +164 -0
- package/dist/services/coder/sessions.d.ts.map +1 -0
- package/dist/services/coder/sessions.js +149 -0
- package/dist/services/coder/sessions.js.map +1 -0
- package/dist/services/coder/skills.d.ts +17 -0
- package/dist/services/coder/skills.d.ts.map +1 -0
- package/dist/services/coder/skills.js +43 -0
- package/dist/services/coder/skills.js.map +1 -0
- package/dist/services/coder/sse.d.ts +255 -0
- package/dist/services/coder/sse.d.ts.map +1 -0
- package/dist/services/coder/sse.js +676 -0
- package/dist/services/coder/sse.js.map +1 -0
- package/dist/services/coder/types.d.ts +2090 -0
- package/dist/services/coder/types.d.ts.map +1 -0
- package/dist/services/coder/types.js +802 -0
- package/dist/services/coder/types.js.map +1 -0
- package/dist/services/coder/users.d.ts +12 -0
- package/dist/services/coder/users.d.ts.map +1 -0
- package/dist/services/coder/users.js +35 -0
- package/dist/services/coder/users.js.map +1 -0
- package/dist/services/coder/util.d.ts +82 -0
- package/dist/services/coder/util.d.ts.map +1 -0
- package/dist/services/coder/util.js +60 -0
- package/dist/services/coder/util.js.map +1 -0
- package/dist/services/coder/websocket.d.ts +346 -0
- package/dist/services/coder/websocket.d.ts.map +1 -0
- package/dist/services/coder/websocket.js +791 -0
- package/dist/services/coder/websocket.js.map +1 -0
- package/dist/services/coder/workspaces.d.ts +13 -0
- package/dist/services/coder/workspaces.d.ts.map +1 -0
- package/dist/services/coder/workspaces.js +37 -0
- package/dist/services/coder/workspaces.js.map +1 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +1 -0
- package/dist/services/index.js.map +1 -1
- package/dist/services/oauth/types.d.ts +11 -0
- package/dist/services/oauth/types.d.ts.map +1 -1
- package/dist/services/oauth/types.js +4 -0
- package/dist/services/oauth/types.js.map +1 -1
- package/dist/services/project/deploy.d.ts +57 -6
- package/dist/services/project/deploy.d.ts.map +1 -1
- package/dist/services/project/deploy.js +39 -4
- package/dist/services/project/deploy.js.map +1 -1
- package/dist/services/queue/service.d.ts +28 -0
- package/dist/services/queue/service.d.ts.map +1 -1
- package/dist/services/queue/service.js +54 -9
- package/dist/services/queue/service.js.map +1 -1
- package/dist/services/sandbox/cli-list.d.ts +1 -1
- package/dist/services/sandbox/client.d.ts +10 -4
- package/dist/services/sandbox/client.d.ts.map +1 -1
- package/dist/services/sandbox/client.js +2 -2
- package/dist/services/sandbox/client.js.map +1 -1
- package/dist/services/sandbox/create.d.ts +2 -2
- package/dist/services/sandbox/execute.d.ts +2 -2
- package/dist/services/sandbox/execution.d.ts +4 -4
- package/dist/services/sandbox/files.d.ts +10 -2
- package/dist/services/sandbox/files.d.ts.map +1 -1
- package/dist/services/sandbox/files.js +14 -0
- package/dist/services/sandbox/files.js.map +1 -1
- package/dist/services/sandbox/get.d.ts +2 -2
- package/dist/services/sandbox/list.d.ts +4 -4
- package/dist/services/sandbox/run.d.ts +3 -3
- package/dist/services/sandbox/types.d.ts +20 -12
- package/dist/services/sandbox/types.d.ts.map +1 -1
- package/dist/services/sandbox/types.js +4 -4
- package/dist/services/sandbox/types.js.map +1 -1
- package/dist/services/session/events.d.ts +2 -2
- package/dist/services/workflow/types.d.ts +8 -8
- package/package.json +280 -100
- package/src/services/coder/agents.ts +148 -0
- package/src/services/coder/api-reference.ts +573 -0
- package/src/services/coder/client.ts +509 -0
- package/src/services/coder/close-codes.ts +83 -0
- package/src/services/coder/discover.ts +23 -0
- package/src/services/coder/github.ts +33 -0
- package/src/services/coder/index.ts +100 -0
- package/src/services/coder/loop-state.ts +19 -0
- package/src/services/coder/protocol.ts +1200 -0
- package/src/services/coder/session-data.ts +63 -0
- package/src/services/coder/sessions.ts +267 -0
- package/src/services/coder/skills.ts +102 -0
- package/src/services/coder/sse.ts +796 -0
- package/src/services/coder/types.ts +935 -0
- package/src/services/coder/users.ts +59 -0
- package/src/services/coder/util.ts +87 -0
- package/src/services/coder/websocket.ts +943 -0
- package/src/services/coder/workspaces.ts +77 -0
- package/src/services/index.ts +1 -0
- package/src/services/oauth/types.ts +4 -0
- package/src/services/project/deploy.ts +67 -26
- package/src/services/queue/service.ts +56 -13
- package/src/services/sandbox/client.ts +10 -8
- package/src/services/sandbox/files.ts +28 -2
- package/src/services/sandbox/types.ts +8 -6
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import { type APIClient } from '../api.ts';
|
|
3
|
+
import {
|
|
4
|
+
CoderCreateWorkspaceRequestSchema,
|
|
5
|
+
CoderWorkspaceDetailSchema,
|
|
6
|
+
CoderWorkspaceListResponseSchema,
|
|
7
|
+
type CoderCreateWorkspaceRequest,
|
|
8
|
+
type CoderWorkspaceDetail,
|
|
9
|
+
type CoderWorkspaceListResponse,
|
|
10
|
+
} from './types.ts';
|
|
11
|
+
|
|
12
|
+
const WorkspaceGetResponseSchema = z
|
|
13
|
+
.object({
|
|
14
|
+
workspace: CoderWorkspaceDetailSchema.describe('Workspace payload returned by coder hub'),
|
|
15
|
+
})
|
|
16
|
+
.passthrough()
|
|
17
|
+
.describe('Wrapped workspace response from coder hub');
|
|
18
|
+
|
|
19
|
+
const WorkspaceCreateResponseSchema = z
|
|
20
|
+
.object({
|
|
21
|
+
workspace: CoderWorkspaceDetailSchema.describe(
|
|
22
|
+
'Created workspace payload returned by coder hub'
|
|
23
|
+
),
|
|
24
|
+
})
|
|
25
|
+
.passthrough()
|
|
26
|
+
.describe('Wrapped workspace create response from coder hub');
|
|
27
|
+
|
|
28
|
+
const OkResponseSchema = z
|
|
29
|
+
.object({
|
|
30
|
+
ok: z.boolean().describe('Operation success indicator'),
|
|
31
|
+
})
|
|
32
|
+
.passthrough()
|
|
33
|
+
.describe('Generic ok response from coder hub');
|
|
34
|
+
|
|
35
|
+
export async function coderListWorkspaces(client: APIClient): Promise<CoderWorkspaceListResponse> {
|
|
36
|
+
return client.get<CoderWorkspaceListResponse>(
|
|
37
|
+
'/hub/workspaces',
|
|
38
|
+
CoderWorkspaceListResponseSchema
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export async function coderGetWorkspace(
|
|
43
|
+
client: APIClient,
|
|
44
|
+
params: { workspaceId: string }
|
|
45
|
+
): Promise<CoderWorkspaceDetail> {
|
|
46
|
+
const path = `/hub/workspaces/${encodeURIComponent(params.workspaceId)}`;
|
|
47
|
+
const resp = await client.get<z.infer<typeof WorkspaceGetResponseSchema>>(
|
|
48
|
+
path,
|
|
49
|
+
WorkspaceGetResponseSchema
|
|
50
|
+
);
|
|
51
|
+
return resp.workspace;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export async function coderCreateWorkspace(
|
|
55
|
+
client: APIClient,
|
|
56
|
+
params: { body: CoderCreateWorkspaceRequest }
|
|
57
|
+
): Promise<CoderWorkspaceDetail> {
|
|
58
|
+
const resp = await client.post<
|
|
59
|
+
z.infer<typeof WorkspaceCreateResponseSchema>,
|
|
60
|
+
CoderCreateWorkspaceRequest
|
|
61
|
+
>(
|
|
62
|
+
'/hub/workspaces',
|
|
63
|
+
params.body,
|
|
64
|
+
WorkspaceCreateResponseSchema,
|
|
65
|
+
CoderCreateWorkspaceRequestSchema
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
return resp.workspace;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export async function coderDeleteWorkspace(
|
|
72
|
+
client: APIClient,
|
|
73
|
+
params: { workspaceId: string }
|
|
74
|
+
): Promise<void> {
|
|
75
|
+
const path = `/hub/workspaces/${encodeURIComponent(params.workspaceId)}`;
|
|
76
|
+
await client.delete(path, OkResponseSchema);
|
|
77
|
+
}
|
package/src/services/index.ts
CHANGED
|
@@ -20,6 +20,7 @@ export const OAuthClientSchema = z.object({
|
|
|
20
20
|
id_token_lifetime_seconds: z.number().optional(),
|
|
21
21
|
allowed_user_ids: z.array(z.string()),
|
|
22
22
|
internal: z.boolean().optional().default(false),
|
|
23
|
+
is_public: z.boolean().default(true),
|
|
23
24
|
created_at: z.string(),
|
|
24
25
|
updated_at: z.string(),
|
|
25
26
|
});
|
|
@@ -50,6 +51,7 @@ export const OAuthClientCreateRequestSchema = z.object({
|
|
|
50
51
|
refresh_token_lifetime_seconds: z.number().optional(),
|
|
51
52
|
id_token_lifetime_seconds: z.number().optional(),
|
|
52
53
|
allowed_user_ids: z.array(z.string()).optional(),
|
|
54
|
+
is_public: z.boolean().optional(),
|
|
53
55
|
});
|
|
54
56
|
|
|
55
57
|
export type OAuthClientCreateRequest = z.infer<typeof OAuthClientCreateRequestSchema>;
|
|
@@ -77,6 +79,7 @@ export const OAuthClientUpdateRequestSchema = z.object({
|
|
|
77
79
|
refresh_token_lifetime_seconds: z.number().optional(),
|
|
78
80
|
id_token_lifetime_seconds: z.number().optional(),
|
|
79
81
|
allowed_user_ids: z.array(z.string()).optional(),
|
|
82
|
+
is_public: z.boolean().optional(),
|
|
80
83
|
});
|
|
81
84
|
|
|
82
85
|
export type OAuthClientUpdateRequest = z.infer<typeof OAuthClientUpdateRequestSchema>;
|
|
@@ -313,6 +316,7 @@ export const OAuthUserInfoSchema = z
|
|
|
313
316
|
name: z.string().optional(),
|
|
314
317
|
given_name: z.string().optional(),
|
|
315
318
|
family_name: z.string().optional(),
|
|
319
|
+
picture: z.string().optional(),
|
|
316
320
|
email: z.string().optional(),
|
|
317
321
|
email_verified: z.boolean().optional(),
|
|
318
322
|
})
|
|
@@ -73,33 +73,71 @@ export const BuildAgentSchema = z.object({
|
|
|
73
73
|
...BaseAgentFields,
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Launch process definition — describes how to start the application.
|
|
78
|
+
* Produced by the buildpack pipeline for any framework.
|
|
79
|
+
*/
|
|
80
|
+
export const LaunchProcessSchema = z.object({
|
|
81
|
+
type: z.string().describe('process type (e.g., web, worker)'),
|
|
82
|
+
command: z.string().describe('command to execute'),
|
|
83
|
+
default: z.boolean().describe('whether this is the default process'),
|
|
84
|
+
workingDirectory: z.string().optional().describe('working directory relative to app root'),
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
export const LaunchMetadataSchema = z.object({
|
|
88
|
+
processes: z.array(LaunchProcessSchema).describe('application processes'),
|
|
89
|
+
framework: z.object({
|
|
90
|
+
name: z.string().describe('detected framework name'),
|
|
91
|
+
version: z.string().optional().describe('framework version'),
|
|
92
|
+
}),
|
|
93
|
+
runtime: z.object({
|
|
94
|
+
name: z.string().describe('runtime binary (node, bun, deno)'),
|
|
95
|
+
port: z.number().optional().describe('port the app listens on'),
|
|
96
|
+
}),
|
|
97
|
+
build: z.object({
|
|
98
|
+
date: z.string().describe('build timestamp'),
|
|
99
|
+
duration: z.number().describe('build duration in ms'),
|
|
100
|
+
}),
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
export type LaunchMetadata = z.infer<typeof LaunchMetadataSchema>;
|
|
104
|
+
|
|
76
105
|
export const BuildMetadataSchema = z.object({
|
|
77
|
-
routes: z
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
106
|
+
routes: z
|
|
107
|
+
.array(
|
|
108
|
+
z.object({
|
|
109
|
+
id: z.string().describe('the unique calculated id for the route'),
|
|
110
|
+
filename: z.string().describe('the relative path for the file'),
|
|
111
|
+
path: z.string().describe('the route path'),
|
|
112
|
+
method: z.enum(['get', 'post', 'put', 'delete', 'patch']).describe('the HTTP method'),
|
|
113
|
+
version: z.string().describe('the SHA256 content of the file'),
|
|
114
|
+
type: z.enum(['api', 'sms', 'email', 'cron', 'websocket', 'sse', 'stream']),
|
|
115
|
+
agentIds: z
|
|
116
|
+
.array(z.string())
|
|
117
|
+
.optional()
|
|
118
|
+
.describe('the agent ids associated with this route'),
|
|
119
|
+
config: z
|
|
120
|
+
.record(z.string(), z.unknown())
|
|
121
|
+
.optional()
|
|
122
|
+
.describe('type specific configuration'),
|
|
123
|
+
schema: z
|
|
124
|
+
.object({
|
|
125
|
+
input: z.string().optional().describe('JSON schema for input (stringified JSON)'),
|
|
126
|
+
output: z
|
|
127
|
+
.string()
|
|
128
|
+
.optional()
|
|
129
|
+
.describe('JSON schema for output (stringified JSON)'),
|
|
130
|
+
})
|
|
131
|
+
.optional()
|
|
132
|
+
.describe('input and output JSON schemas for the route'),
|
|
133
|
+
})
|
|
134
|
+
)
|
|
135
|
+
.default([])
|
|
136
|
+
.describe('routes — only present for Agentuity native apps'),
|
|
137
|
+
agents: z
|
|
138
|
+
.array(BuildAgentSchema)
|
|
139
|
+
.default([])
|
|
140
|
+
.describe('agents — only present for Agentuity native apps'),
|
|
103
141
|
assets: z.array(
|
|
104
142
|
z.object({
|
|
105
143
|
filename: z.string().describe('the relative path for the file'),
|
|
@@ -176,6 +214,9 @@ export const BuildMetadataSchema = z.object({
|
|
|
176
214
|
}),
|
|
177
215
|
})
|
|
178
216
|
),
|
|
217
|
+
launch: LaunchMetadataSchema.optional().describe(
|
|
218
|
+
'launch metadata — how to start the application (processes, framework, runtime)'
|
|
219
|
+
),
|
|
179
220
|
});
|
|
180
221
|
|
|
181
222
|
export type BuildMetadata = z.infer<typeof BuildMetadataSchema>;
|
|
@@ -308,6 +308,14 @@ export interface QueueService {
|
|
|
308
308
|
*/
|
|
309
309
|
export const QueuePublishError = StructuredError('QueuePublishError');
|
|
310
310
|
|
|
311
|
+
/**
|
|
312
|
+
* Error thrown when a queue creation operation fails.
|
|
313
|
+
*
|
|
314
|
+
* This is a general error for create failures that aren't specifically
|
|
315
|
+
* validation, not-found, or conflict (409) errors.
|
|
316
|
+
*/
|
|
317
|
+
export const QueueCreateError = StructuredError('QueueCreateError');
|
|
318
|
+
|
|
311
319
|
/**
|
|
312
320
|
* Error thrown when a queue is not found.
|
|
313
321
|
*
|
|
@@ -389,6 +397,33 @@ function validatePayloadInternal(payload: string): void {
|
|
|
389
397
|
}
|
|
390
398
|
}
|
|
391
399
|
|
|
400
|
+
/**
|
|
401
|
+
* Unwraps the standard API response envelope.
|
|
402
|
+
*
|
|
403
|
+
* The queue server returns responses wrapped in:
|
|
404
|
+
* { success: true, data: { [key]: { ...actual data... } } }
|
|
405
|
+
*
|
|
406
|
+
* Since `fromResponse()` parses the raw JSON body, `res.data` from the
|
|
407
|
+
* adapter is the full envelope. This helper extracts the nested data by key.
|
|
408
|
+
*
|
|
409
|
+
* Falls back to treating the input as already-unwrapped data (e.g., in tests
|
|
410
|
+
* using mock adapters that provide flat data directly).
|
|
411
|
+
*
|
|
412
|
+
* @internal
|
|
413
|
+
*/
|
|
414
|
+
function unwrapApiResponse<T>(data: unknown, key: string): T {
|
|
415
|
+
if (data !== null && typeof data === 'object') {
|
|
416
|
+
const body = data as Record<string, unknown>;
|
|
417
|
+
if (body.success === true && typeof body.data === 'object' && body.data !== null) {
|
|
418
|
+
const envelope = body.data as Record<string, unknown>;
|
|
419
|
+
if (key in envelope) {
|
|
420
|
+
return envelope[key] as T;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
return data as T;
|
|
425
|
+
}
|
|
426
|
+
|
|
392
427
|
// ============================================================================
|
|
393
428
|
// QueueStorageService Implementation
|
|
394
429
|
// ============================================================================
|
|
@@ -496,16 +531,18 @@ export class QueueStorageService implements QueueService {
|
|
|
496
531
|
});
|
|
497
532
|
|
|
498
533
|
if (res.ok) {
|
|
499
|
-
const data = res.data
|
|
500
|
-
|
|
501
|
-
offset: number;
|
|
502
|
-
published_at: string;
|
|
503
|
-
};
|
|
504
|
-
return {
|
|
534
|
+
const data = unwrapApiResponse<Record<string, unknown>>(res.data, 'message');
|
|
535
|
+
const result = QueuePublishResultSchema.safeParse({
|
|
505
536
|
id: data.id,
|
|
506
537
|
offset: data.offset,
|
|
507
538
|
publishedAt: data.published_at,
|
|
508
|
-
};
|
|
539
|
+
});
|
|
540
|
+
if (result.success) {
|
|
541
|
+
return result.data;
|
|
542
|
+
}
|
|
543
|
+
throw new QueuePublishError({
|
|
544
|
+
message: `Queue publish returned an unexpected response format: ${result.error.message}`,
|
|
545
|
+
});
|
|
509
546
|
}
|
|
510
547
|
|
|
511
548
|
if (res.response.status === 404) {
|
|
@@ -579,12 +616,18 @@ export class QueueStorageService implements QueueService {
|
|
|
579
616
|
});
|
|
580
617
|
|
|
581
618
|
if (res.ok) {
|
|
582
|
-
const data =
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
619
|
+
const data = unwrapApiResponse<Record<string, unknown>>(res.data, 'queue');
|
|
620
|
+
const result = QueueCreateResultSchema.safeParse({
|
|
621
|
+
name: data.name,
|
|
622
|
+
queueType: data.queue_type,
|
|
623
|
+
});
|
|
624
|
+
if (result.success) {
|
|
625
|
+
this.#knownQueues.add(queueName);
|
|
626
|
+
return result.data;
|
|
627
|
+
}
|
|
628
|
+
throw new QueueCreateError({
|
|
629
|
+
message: `Queue create returned an unexpected response format: ${result.error.message}`,
|
|
630
|
+
});
|
|
588
631
|
}
|
|
589
632
|
|
|
590
633
|
if (res.response.status === 409) {
|
|
@@ -257,14 +257,16 @@ export interface SandboxInstance {
|
|
|
257
257
|
mkDir(path: string, recursive?: boolean): Promise<void>;
|
|
258
258
|
|
|
259
259
|
/**
|
|
260
|
-
* Remove a file from the sandbox workspace
|
|
260
|
+
* Remove a file from the sandbox workspace.
|
|
261
|
+
* @returns Object with `found` indicating whether the file existed before removal
|
|
261
262
|
*/
|
|
262
|
-
rmFile(path: string): Promise<
|
|
263
|
+
rmFile(path: string): Promise<{ found: boolean }>;
|
|
263
264
|
|
|
264
265
|
/**
|
|
265
|
-
* Remove a directory from the sandbox workspace
|
|
266
|
+
* Remove a directory from the sandbox workspace.
|
|
267
|
+
* @returns Object with `found` indicating whether the directory existed before removal
|
|
266
268
|
*/
|
|
267
|
-
rmDir(path: string, recursive?: boolean): Promise<
|
|
269
|
+
rmDir(path: string, recursive?: boolean): Promise<{ found: boolean }>;
|
|
268
270
|
|
|
269
271
|
/**
|
|
270
272
|
* Set environment variables on the sandbox. Pass null to delete a variable.
|
|
@@ -380,12 +382,12 @@ function createSandboxInstanceMethods(
|
|
|
380
382
|
await sandboxMkDir(client, { sandboxId, path, recursive, orgId });
|
|
381
383
|
},
|
|
382
384
|
|
|
383
|
-
async rmFile(path: string): Promise<
|
|
384
|
-
|
|
385
|
+
async rmFile(path: string): Promise<{ found: boolean }> {
|
|
386
|
+
return sandboxRmFile(client, { sandboxId, path, orgId });
|
|
385
387
|
},
|
|
386
388
|
|
|
387
|
-
async rmDir(path: string, recursive?: boolean): Promise<
|
|
388
|
-
|
|
389
|
+
async rmDir(path: string, recursive?: boolean): Promise<{ found: boolean }> {
|
|
390
|
+
return sandboxRmDir(client, { sandboxId, path, recursive, orgId });
|
|
389
391
|
},
|
|
390
392
|
|
|
391
393
|
async setEnv(env: Record<string, string | null>): Promise<Record<string, string>> {
|
|
@@ -217,6 +217,13 @@ export const RmDirResponseSchema = z.discriminatedUnion('success', [
|
|
|
217
217
|
}),
|
|
218
218
|
z.object({
|
|
219
219
|
success: z.literal<true>(true),
|
|
220
|
+
found: z
|
|
221
|
+
.boolean()
|
|
222
|
+
.optional()
|
|
223
|
+
.default(true)
|
|
224
|
+
.describe(
|
|
225
|
+
'Whether the directory existed before removal. False when already removed (idempotent).'
|
|
226
|
+
),
|
|
220
227
|
}),
|
|
221
228
|
]);
|
|
222
229
|
|
|
@@ -235,9 +242,13 @@ export type RmDirParams = z.infer<typeof RmDirParamsSchema>;
|
|
|
235
242
|
*
|
|
236
243
|
* @param client - The API client to use for the request
|
|
237
244
|
* @param params - Parameters including sandbox ID, path, and recursive flag
|
|
245
|
+
* @returns Object with `found` indicating whether the directory existed before removal
|
|
238
246
|
* @throws {SandboxResponseError} If the rmdir request fails
|
|
239
247
|
*/
|
|
240
|
-
export async function sandboxRmDir(
|
|
248
|
+
export async function sandboxRmDir(
|
|
249
|
+
client: APIClient,
|
|
250
|
+
params: RmDirParams
|
|
251
|
+
): Promise<{ found: boolean }> {
|
|
241
252
|
const { sandboxId, path, recursive, orgId, signal } = params;
|
|
242
253
|
|
|
243
254
|
const body: z.infer<typeof RmDirRequestSchema> = {
|
|
@@ -263,6 +274,8 @@ export async function sandboxRmDir(client: APIClient, params: RmDirParams): Prom
|
|
|
263
274
|
if (!resp.success) {
|
|
264
275
|
throwSandboxError(resp, { sandboxId });
|
|
265
276
|
}
|
|
277
|
+
|
|
278
|
+
return { found: resp.found };
|
|
266
279
|
}
|
|
267
280
|
|
|
268
281
|
export const RmFileRequestSchema = z
|
|
@@ -278,6 +291,13 @@ export const RmFileResponseSchema = z.discriminatedUnion('success', [
|
|
|
278
291
|
}),
|
|
279
292
|
z.object({
|
|
280
293
|
success: z.literal<true>(true),
|
|
294
|
+
found: z
|
|
295
|
+
.boolean()
|
|
296
|
+
.optional()
|
|
297
|
+
.default(true)
|
|
298
|
+
.describe(
|
|
299
|
+
'Whether the file existed before removal. False when already removed (idempotent).'
|
|
300
|
+
),
|
|
281
301
|
}),
|
|
282
302
|
]);
|
|
283
303
|
|
|
@@ -295,9 +315,13 @@ export type RmFileParams = z.infer<typeof RmFileParamsSchema>;
|
|
|
295
315
|
*
|
|
296
316
|
* @param client - The API client to use for the request
|
|
297
317
|
* @param params - Parameters including sandbox ID and path
|
|
318
|
+
* @returns Object with `found` indicating whether the file existed before removal
|
|
298
319
|
* @throws {SandboxResponseError} If the rm request fails
|
|
299
320
|
*/
|
|
300
|
-
export async function sandboxRmFile(
|
|
321
|
+
export async function sandboxRmFile(
|
|
322
|
+
client: APIClient,
|
|
323
|
+
params: RmFileParams
|
|
324
|
+
): Promise<{ found: boolean }> {
|
|
301
325
|
const { sandboxId, path, orgId, signal } = params;
|
|
302
326
|
|
|
303
327
|
const body: z.infer<typeof RmFileRequestSchema> = {
|
|
@@ -322,6 +346,8 @@ export async function sandboxRmFile(client: APIClient, params: RmFileParams): Pr
|
|
|
322
346
|
if (!resp.success) {
|
|
323
347
|
throwSandboxError(resp, { sandboxId });
|
|
324
348
|
}
|
|
349
|
+
|
|
350
|
+
return { found: resp.found };
|
|
325
351
|
}
|
|
326
352
|
|
|
327
353
|
export const FileInfoSchema = z.object({
|
|
@@ -383,14 +383,16 @@ export const SandboxSchema = z.object({
|
|
|
383
383
|
mkDir: z
|
|
384
384
|
.custom<(path: string, recursive?: boolean) => Promise<void>>()
|
|
385
385
|
.describe('Create a directory in the sandbox workspace.'),
|
|
386
|
-
/** Remove a file from the sandbox workspace. */
|
|
386
|
+
/** Remove a file from the sandbox workspace. Returns whether the file was found. */
|
|
387
387
|
rmFile: z
|
|
388
|
-
.custom<(path: string) => Promise<
|
|
389
|
-
.describe('Remove a file from the sandbox workspace.'),
|
|
390
|
-
/** Remove a directory from the sandbox workspace. */
|
|
388
|
+
.custom<(path: string) => Promise<{ found: boolean }>>()
|
|
389
|
+
.describe('Remove a file from the sandbox workspace. Returns whether the file was found.'),
|
|
390
|
+
/** Remove a directory from the sandbox workspace. Returns whether the directory was found. */
|
|
391
391
|
rmDir: z
|
|
392
|
-
.custom<(path: string, recursive?: boolean) => Promise<
|
|
393
|
-
.describe(
|
|
392
|
+
.custom<(path: string, recursive?: boolean) => Promise<{ found: boolean }>>()
|
|
393
|
+
.describe(
|
|
394
|
+
'Remove a directory from the sandbox workspace. Returns whether the directory was found.'
|
|
395
|
+
),
|
|
394
396
|
/** Set environment variables on the sandbox. Pass null to delete a variable. */
|
|
395
397
|
setEnv: z
|
|
396
398
|
.custom<(env: Record<string, string | null>) => Promise<Record<string, string>>>()
|