@agentuity/core 1.0.48 → 1.0.50

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.
Files changed (57) hide show
  1. package/dist/services/api.d.ts.map +1 -1
  2. package/dist/services/api.js +13 -5
  3. package/dist/services/api.js.map +1 -1
  4. package/dist/services/oauth/flow.d.ts +51 -0
  5. package/dist/services/oauth/flow.d.ts.map +1 -0
  6. package/dist/services/oauth/flow.js +183 -0
  7. package/dist/services/oauth/flow.js.map +1 -0
  8. package/dist/services/oauth/index.d.ts +1 -0
  9. package/dist/services/oauth/index.d.ts.map +1 -1
  10. package/dist/services/oauth/index.js +1 -0
  11. package/dist/services/oauth/index.js.map +1 -1
  12. package/dist/services/oauth/types.d.ts +34 -0
  13. package/dist/services/oauth/types.d.ts.map +1 -1
  14. package/dist/services/oauth/types.js +52 -0
  15. package/dist/services/oauth/types.js.map +1 -1
  16. package/dist/services/sandbox/client.d.ts.map +1 -1
  17. package/dist/services/sandbox/client.js +35 -13
  18. package/dist/services/sandbox/client.js.map +1 -1
  19. package/dist/services/sandbox/create.d.ts +2 -0
  20. package/dist/services/sandbox/create.d.ts.map +1 -1
  21. package/dist/services/sandbox/create.js +4 -0
  22. package/dist/services/sandbox/create.js.map +1 -1
  23. package/dist/services/sandbox/execution.d.ts +1 -0
  24. package/dist/services/sandbox/execution.d.ts.map +1 -1
  25. package/dist/services/sandbox/execution.js +4 -2
  26. package/dist/services/sandbox/execution.js.map +1 -1
  27. package/dist/services/sandbox/files.js +1 -1
  28. package/dist/services/sandbox/files.js.map +1 -1
  29. package/dist/services/sandbox/index.d.ts +2 -0
  30. package/dist/services/sandbox/index.d.ts.map +1 -1
  31. package/dist/services/sandbox/index.js +1 -0
  32. package/dist/services/sandbox/index.js.map +1 -1
  33. package/dist/services/sandbox/job.d.ts +227 -0
  34. package/dist/services/sandbox/job.d.ts.map +1 -0
  35. package/dist/services/sandbox/job.js +109 -0
  36. package/dist/services/sandbox/job.js.map +1 -0
  37. package/dist/services/sandbox/types.d.ts +35 -0
  38. package/dist/services/sandbox/types.d.ts.map +1 -1
  39. package/dist/services/sandbox/types.js +23 -0
  40. package/dist/services/sandbox/types.js.map +1 -1
  41. package/dist/services/sandbox/util.d.ts +1 -0
  42. package/dist/services/sandbox/util.d.ts.map +1 -1
  43. package/dist/services/sandbox/util.js +1 -0
  44. package/dist/services/sandbox/util.js.map +1 -1
  45. package/package.json +2 -2
  46. package/src/services/api.ts +15 -5
  47. package/src/services/oauth/flow.ts +215 -0
  48. package/src/services/oauth/index.ts +1 -0
  49. package/src/services/oauth/types.ts +66 -0
  50. package/src/services/sandbox/client.ts +40 -14
  51. package/src/services/sandbox/create.ts +4 -0
  52. package/src/services/sandbox/execution.ts +5 -2
  53. package/src/services/sandbox/files.ts +1 -1
  54. package/src/services/sandbox/index.ts +18 -0
  55. package/src/services/sandbox/job.ts +161 -0
  56. package/src/services/sandbox/types.ts +29 -0
  57. package/src/services/sandbox/util.ts +1 -0
@@ -0,0 +1,161 @@
1
+ import { type APIClient, APIResponseSchema } from '../api.ts';
2
+ import { CreateJobOptionsSchema, JobSchema, type Job } from './types.ts';
3
+ import { throwSandboxError } from './util.ts';
4
+ import { z } from 'zod';
5
+
6
+ export const CreateJobRequestSchema = CreateJobOptionsSchema;
7
+
8
+ export const CreateJobDataSchema = JobSchema;
9
+
10
+ export const CreateJobResponseSchema = APIResponseSchema(CreateJobDataSchema);
11
+
12
+ export const JobCreateParamsSchema = z.object({
13
+ sandboxId: z.string().describe('Sandbox ID where the job should run'),
14
+ options: CreateJobOptionsSchema.describe('Job creation options'),
15
+ orgId: z.string().optional().describe('Optional org id for CLI auth context'),
16
+ signal: z.custom<AbortSignal>().optional().describe('Optional abort signal for cancellation'),
17
+ });
18
+ export type JobCreateParams = z.infer<typeof JobCreateParamsSchema>;
19
+
20
+ export async function jobCreate(client: APIClient, params: JobCreateParams): Promise<Job> {
21
+ const { sandboxId, options, orgId, signal } = params;
22
+ const body: z.infer<typeof CreateJobRequestSchema> = {
23
+ command: options.command,
24
+ };
25
+ if (options.streams) {
26
+ body.streams = options.streams;
27
+ }
28
+
29
+ const queryParams = new URLSearchParams();
30
+ if (orgId) {
31
+ queryParams.set('orgId', orgId);
32
+ }
33
+ const queryString = queryParams.toString();
34
+ const url = `/sandbox/sandboxes/${sandboxId}/jobs${queryString ? `?${queryString}` : ''}`;
35
+
36
+ const resp = await client.post<z.infer<typeof CreateJobResponseSchema>>(
37
+ url,
38
+ body,
39
+ CreateJobResponseSchema,
40
+ CreateJobRequestSchema,
41
+ signal
42
+ );
43
+
44
+ if (resp.success) {
45
+ return resp.data;
46
+ }
47
+
48
+ throwSandboxError(resp, { sandboxId });
49
+ }
50
+
51
+ export const JobGetDataSchema = JobSchema;
52
+
53
+ export const JobGetResponseSchema = APIResponseSchema(JobGetDataSchema);
54
+
55
+ export const JobGetParamsSchema = z.object({
56
+ sandboxId: z.string().describe('Sandbox ID'),
57
+ jobId: z.string().describe('Job ID'),
58
+ orgId: z.string().optional().describe('Organization ID'),
59
+ signal: z.custom<AbortSignal>().optional().describe('Abort signal for cancellation'),
60
+ });
61
+ export type JobGetParams = z.infer<typeof JobGetParamsSchema>;
62
+
63
+ export async function jobGet(client: APIClient, params: JobGetParams): Promise<Job> {
64
+ const { sandboxId, jobId, orgId, signal } = params;
65
+ const queryParams = new URLSearchParams();
66
+ if (orgId) {
67
+ queryParams.set('orgId', orgId);
68
+ }
69
+ const queryString = queryParams.toString();
70
+ const url = `/sandbox/sandboxes/${sandboxId}/jobs/${jobId}${queryString ? `?${queryString}` : ''}`;
71
+
72
+ const resp = await client.get<z.infer<typeof JobGetResponseSchema>>(
73
+ url,
74
+ JobGetResponseSchema,
75
+ signal
76
+ );
77
+
78
+ if (resp.success) {
79
+ return resp.data;
80
+ }
81
+
82
+ throwSandboxError(resp, { sandboxId, jobId: params.jobId });
83
+ }
84
+
85
+ export const JobListDataSchema = z.object({
86
+ jobs: z.array(JobSchema).describe('List of jobs'),
87
+ });
88
+ export type JobListResponse = z.infer<typeof JobListDataSchema>;
89
+
90
+ export const JobListResponseSchema = APIResponseSchema(JobListDataSchema);
91
+
92
+ export const JobListParamsSchema = z.object({
93
+ sandboxId: z.string().describe('Sandbox ID'),
94
+ orgId: z.string().optional().describe('Organization ID'),
95
+ limit: z.number().optional().describe('Maximum number of results'),
96
+ signal: z.custom<AbortSignal>().optional().describe('Abort signal for cancellation'),
97
+ });
98
+ export type JobListParams = z.infer<typeof JobListParamsSchema>;
99
+
100
+ export async function jobList(client: APIClient, params: JobListParams): Promise<JobListResponse> {
101
+ const { sandboxId, orgId, limit, signal } = params;
102
+ const queryParams = new URLSearchParams();
103
+ if (orgId) {
104
+ queryParams.set('orgId', orgId);
105
+ }
106
+ if (limit !== undefined) {
107
+ queryParams.set('limit', String(limit));
108
+ }
109
+ const queryString = queryParams.toString();
110
+ const url = `/sandbox/sandboxes/${sandboxId}/jobs${queryString ? `?${queryString}` : ''}`;
111
+
112
+ const resp = await client.get<z.infer<typeof JobListResponseSchema>>(
113
+ url,
114
+ JobListResponseSchema,
115
+ signal
116
+ );
117
+
118
+ if (resp.success) {
119
+ return resp.data;
120
+ }
121
+
122
+ throwSandboxError(resp, { sandboxId });
123
+ }
124
+
125
+ export const JobStopDataSchema = JobSchema;
126
+
127
+ export const JobStopResponseSchema = APIResponseSchema(JobStopDataSchema);
128
+
129
+ export const JobStopParamsSchema = z.object({
130
+ sandboxId: z.string().describe('Sandbox ID'),
131
+ jobId: z.string().describe('Job ID'),
132
+ force: z.boolean().optional().describe('Force termination (SIGKILL)'),
133
+ orgId: z.string().optional().describe('Organization ID'),
134
+ signal: z.custom<AbortSignal>().optional().describe('Abort signal for cancellation'),
135
+ });
136
+ export type JobStopParams = z.infer<typeof JobStopParamsSchema>;
137
+
138
+ export async function jobStop(client: APIClient, params: JobStopParams): Promise<Job> {
139
+ const { sandboxId, jobId, force, orgId, signal } = params;
140
+ const queryParams = new URLSearchParams();
141
+ if (orgId) {
142
+ queryParams.set('orgId', orgId);
143
+ }
144
+ if (force) {
145
+ queryParams.set('force', 'true');
146
+ }
147
+ const queryString = queryParams.toString();
148
+ const url = `/sandbox/sandboxes/${sandboxId}/jobs/${jobId}${queryString ? `?${queryString}` : ''}`;
149
+
150
+ const resp = await client.delete<z.infer<typeof JobStopResponseSchema>>(
151
+ url,
152
+ JobStopResponseSchema,
153
+ signal
154
+ );
155
+
156
+ if (resp.success) {
157
+ return resp.data;
158
+ }
159
+
160
+ throwSandboxError(resp, { sandboxId, jobId: params.jobId });
161
+ }
@@ -167,6 +167,35 @@ export const ExecutionStatusSchema = z.enum([
167
167
  ]);
168
168
  export type ExecutionStatus = z.infer<typeof ExecutionStatusSchema>;
169
169
 
170
+ export const JobStatusSchema = z.enum(['pending', 'running', 'completed', 'failed', 'cancelled']);
171
+ export type JobStatus = z.infer<typeof JobStatusSchema>;
172
+
173
+ export const JobSchema = z.object({
174
+ jobId: z.string().describe('Unique identifier for the job'),
175
+ sandboxId: z.string().describe('ID of the sandbox where the job is running'),
176
+ command: z.array(z.string()).describe('Command and arguments being executed'),
177
+ status: JobStatusSchema.describe('Current status of the job'),
178
+ exitCode: z.number().optional().describe('Exit code of the job (set when completed)'),
179
+ startedAt: z.string().optional().describe('ISO timestamp when the job started'),
180
+ completedAt: z.string().optional().describe('ISO timestamp when the job completed'),
181
+ error: z.string().optional().describe('Error message if the job failed'),
182
+ stdoutStreamUrl: z.string().optional().describe('URL to stream stdout output'),
183
+ stderrStreamUrl: z.string().optional().describe('URL to stream stderr output'),
184
+ });
185
+ export type Job = z.infer<typeof JobSchema>;
186
+
187
+ export const CreateJobOptionsSchema = z.object({
188
+ command: z.array(z.string()).describe('Command and arguments to execute'),
189
+ streams: z
190
+ .object({
191
+ stdout: z.string().optional().describe('Stream ID for stdout output'),
192
+ stderr: z.string().optional().describe('Stream ID for stderr output'),
193
+ })
194
+ .optional()
195
+ .describe('Stream configuration for output redirection'),
196
+ });
197
+ export type CreateJobOptions = z.infer<typeof CreateJobOptionsSchema>;
198
+
170
199
  /** Read-only stream interface for consuming streams without write access */
171
200
  export const StreamReaderSchema = z.object({
172
201
  /** Unique stream identifier */
@@ -176,6 +176,7 @@ export const SnapshotNotFoundError = StructuredError('SnapshotNotFoundError')<{
176
176
  export const SandboxErrorContextSchema = z.object({
177
177
  sandboxId: z.string().optional().describe('sandbox id'),
178
178
  executionId: z.string().optional().describe('execution id'),
179
+ jobId: z.string().optional().describe('job id'),
179
180
  sessionId: z.string().nullish().describe('session id'),
180
181
  snapshotId: z.string().optional().describe('snapshot id'),
181
182
  });