@mgamadeus/ddd-agent-sandbox 0.0.0-stage → 0.2.1
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/LICENSE +21 -0
- package/README.md +25 -2
- package/dist/i18n/hints.json +140 -0
- package/dist/i18n-keys.json +1201 -0
- package/dist/index.d.ts +377 -0
- package/dist/index.js +140 -0
- package/dist/index.js.map +1 -0
- package/dist/screen/index.d.ts +177 -0
- package/dist/screen/index.js +1053 -0
- package/dist/screen/index.js.map +1 -0
- package/package.json +76 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import { InjectableBaseApi, ApiQueryHook, ApiMutationHook, StaticQueryFailure, InjectedRequest } from '@mgamadeus/ddd-admin-ui/logic/pure';
|
|
2
|
+
|
|
3
|
+
/** `SandboxWorkspace::STATE_*`. */
|
|
4
|
+
type SandboxState = 'RUNNING' | 'IDLE' | 'OFFLOADED';
|
|
5
|
+
/** `SandboxWorkspace::MOUNT_MODE_*`. */
|
|
6
|
+
type SandboxMountMode = 'FUSE' | 'PLAIN';
|
|
7
|
+
interface SandboxElements<TItem> {
|
|
8
|
+
elements?: TItem[] | null;
|
|
9
|
+
}
|
|
10
|
+
/** One workspace (one per agent space). */
|
|
11
|
+
interface SandboxWorkspace {
|
|
12
|
+
workspaceKey: string;
|
|
13
|
+
agentSpaceId?: number | null;
|
|
14
|
+
/** The space's name as the drive shows it; `null` = none (the key is shown). */
|
|
15
|
+
displayName?: string | null;
|
|
16
|
+
state: SandboxState | string;
|
|
17
|
+
lastActivityAt?: string | null;
|
|
18
|
+
diskUsedBytes?: number | null;
|
|
19
|
+
diskQuotaBytes?: number | null;
|
|
20
|
+
memoryBytes?: number | null;
|
|
21
|
+
memoryPeakBytes?: number | null;
|
|
22
|
+
memoryLimitBytes?: number | null;
|
|
23
|
+
mountMode?: SandboxMountMode | string | null;
|
|
24
|
+
mountModeReason?: string | null;
|
|
25
|
+
runnerPod?: string | null;
|
|
26
|
+
ownerDisplayName?: string | null;
|
|
27
|
+
runningJobCount?: number | null;
|
|
28
|
+
conversationCount?: number | null;
|
|
29
|
+
/** A conversation of the space has a running turn: actions need `force` + a reason. */
|
|
30
|
+
hasLiveTurn?: boolean;
|
|
31
|
+
}
|
|
32
|
+
interface SandboxWorkspacesResponse {
|
|
33
|
+
/** `false`: the host has no `SandboxAdministration`; the screen says so. */
|
|
34
|
+
isConfigured: boolean;
|
|
35
|
+
workspaces: SandboxElements<SandboxWorkspace>;
|
|
36
|
+
}
|
|
37
|
+
interface SandboxWorkspaceResponse {
|
|
38
|
+
workspace: SandboxWorkspace;
|
|
39
|
+
}
|
|
40
|
+
type SandboxFileType = 'FILE' | 'DIRECTORY' | 'SYMLINK';
|
|
41
|
+
interface SandboxFileEntry {
|
|
42
|
+
name: string;
|
|
43
|
+
/** Relative to the workspace root (`reports/q1.csv`). */
|
|
44
|
+
path: string;
|
|
45
|
+
type: SandboxFileType | string;
|
|
46
|
+
sizeBytes?: number | null;
|
|
47
|
+
modifiedAt?: string | null;
|
|
48
|
+
}
|
|
49
|
+
interface SandboxFilesResponse {
|
|
50
|
+
directoryPath: string;
|
|
51
|
+
entries: SandboxElements<SandboxFileEntry>;
|
|
52
|
+
}
|
|
53
|
+
interface SandboxDriveChange {
|
|
54
|
+
path: string;
|
|
55
|
+
changeType: 'ADDED' | 'MODIFIED' | 'DELETED' | 'RENAMED' | string;
|
|
56
|
+
previousPath?: string | null;
|
|
57
|
+
sizeBytes?: number | null;
|
|
58
|
+
}
|
|
59
|
+
interface SandboxDriveStatus {
|
|
60
|
+
isDriveWorkspace: boolean;
|
|
61
|
+
pendingChangeCount: number;
|
|
62
|
+
changes: SandboxElements<SandboxDriveChange>;
|
|
63
|
+
lastCommittedAt?: string | null;
|
|
64
|
+
}
|
|
65
|
+
interface SandboxDriveStatusResponse {
|
|
66
|
+
driveStatus: SandboxDriveStatus;
|
|
67
|
+
}
|
|
68
|
+
interface SandboxProcess {
|
|
69
|
+
pid: number;
|
|
70
|
+
command: string;
|
|
71
|
+
startedAt?: string | null;
|
|
72
|
+
cpuSeconds?: number | null;
|
|
73
|
+
rssBytes?: number | null;
|
|
74
|
+
jobId?: string | null;
|
|
75
|
+
}
|
|
76
|
+
interface SandboxProcessesResponse {
|
|
77
|
+
processes: SandboxElements<SandboxProcess>;
|
|
78
|
+
}
|
|
79
|
+
interface SandboxCommand {
|
|
80
|
+
seq: number;
|
|
81
|
+
command: string;
|
|
82
|
+
startedAt?: string | null;
|
|
83
|
+
durationMs?: number | null;
|
|
84
|
+
exitCode?: number | null;
|
|
85
|
+
stdoutTail?: string | null;
|
|
86
|
+
stderrTail?: string | null;
|
|
87
|
+
isTruncated: boolean;
|
|
88
|
+
jobId?: string | null;
|
|
89
|
+
/**
|
|
90
|
+
* `RUNNING` | `EXITED` | `KILLED` | `TIMED_OUT`; null or absent = unknown — never read as
|
|
91
|
+
* running.
|
|
92
|
+
*/
|
|
93
|
+
status?: SandboxCommandStatus | null;
|
|
94
|
+
}
|
|
95
|
+
/** `SandboxCommand.status`. */
|
|
96
|
+
type SandboxCommandStatus = 'RUNNING' | 'EXITED' | 'KILLED' | 'TIMED_OUT';
|
|
97
|
+
interface SandboxCommandsResponse {
|
|
98
|
+
commands: SandboxElements<SandboxCommand>;
|
|
99
|
+
}
|
|
100
|
+
interface SandboxSessionEvent {
|
|
101
|
+
occurredAt?: string | null;
|
|
102
|
+
/** `MEMORY_EXCEEDED`, `SECCOMP_DENIED`, `TIMEOUT`, … */
|
|
103
|
+
type: string;
|
|
104
|
+
detail?: string | null;
|
|
105
|
+
}
|
|
106
|
+
interface SandboxSessionEventsResponse {
|
|
107
|
+
sessionEvents: SandboxElements<SandboxSessionEvent>;
|
|
108
|
+
}
|
|
109
|
+
interface SandboxConversation {
|
|
110
|
+
conversationId: number;
|
|
111
|
+
accountId?: number | null;
|
|
112
|
+
runState?: string | null;
|
|
113
|
+
purposeName?: string | null;
|
|
114
|
+
createdAt?: string | null;
|
|
115
|
+
updatedAt?: string | null;
|
|
116
|
+
}
|
|
117
|
+
interface SandboxConversationsResponse {
|
|
118
|
+
conversations: SandboxElements<SandboxConversation>;
|
|
119
|
+
}
|
|
120
|
+
/** `SandboxActionLogEntry::ACTION_*`. */
|
|
121
|
+
type SandboxAction = 'START' | 'OFFLOAD' | 'KILL_JOB' | 'END' | 'RESET';
|
|
122
|
+
/** `SandboxActionLogEntry::OUTCOME_*`. */
|
|
123
|
+
type SandboxActionOutcome = 'SUCCEEDED' | 'REFUSED' | 'FAILED';
|
|
124
|
+
interface SandboxActionLogEntry {
|
|
125
|
+
id?: number | null;
|
|
126
|
+
workspaceKey?: string | null;
|
|
127
|
+
agentSpaceId?: number | null;
|
|
128
|
+
action?: SandboxAction | string | null;
|
|
129
|
+
jobId?: string | null;
|
|
130
|
+
actorAccountId?: number | null;
|
|
131
|
+
forced?: boolean | null;
|
|
132
|
+
reason?: string | null;
|
|
133
|
+
outcome?: SandboxActionOutcome | string | null;
|
|
134
|
+
outcomeDetail?: string | null;
|
|
135
|
+
/** When the action ran (the row's change history). */
|
|
136
|
+
changeHistory?: {
|
|
137
|
+
createdTime?: string | null;
|
|
138
|
+
modifiedTime?: string | null;
|
|
139
|
+
} | null;
|
|
140
|
+
}
|
|
141
|
+
interface SandboxActionLogEntriesResponse {
|
|
142
|
+
actionLogEntries: SandboxElements<SandboxActionLogEntry>;
|
|
143
|
+
}
|
|
144
|
+
interface SandboxOffloadResult {
|
|
145
|
+
committedChangeCount: number;
|
|
146
|
+
wasSessionReleased: boolean;
|
|
147
|
+
detail?: string | null;
|
|
148
|
+
}
|
|
149
|
+
interface SandboxActionResult {
|
|
150
|
+
action: SandboxAction | string;
|
|
151
|
+
workspaceKey: string;
|
|
152
|
+
outcome: SandboxActionOutcome | string;
|
|
153
|
+
offloadResult?: SandboxOffloadResult | null;
|
|
154
|
+
actionLogEntryId?: number | null;
|
|
155
|
+
}
|
|
156
|
+
interface SandboxActionResponse {
|
|
157
|
+
actionResult: SandboxActionResult;
|
|
158
|
+
}
|
|
159
|
+
interface SandboxKeyArg {
|
|
160
|
+
workspaceKey: string;
|
|
161
|
+
}
|
|
162
|
+
interface SandboxLimitArg extends SandboxKeyArg {
|
|
163
|
+
limit?: number;
|
|
164
|
+
}
|
|
165
|
+
interface SandboxFilesArg extends SandboxKeyArg {
|
|
166
|
+
/** `''` = the root. */
|
|
167
|
+
path?: string;
|
|
168
|
+
}
|
|
169
|
+
interface SandboxFileContentArg extends SandboxKeyArg {
|
|
170
|
+
path: string;
|
|
171
|
+
disposition: 'inline' | 'attachment';
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* One file's bytes, in the shape of every file download (`{ blob, filename, contentType }`, as ddd-web's
|
|
175
|
+
* `blobResponseHandler`): a host whose store ignores `payload.blob` needs no other rule. The bytes never enter the
|
|
176
|
+
* cache (a mutation, not a query).
|
|
177
|
+
*/
|
|
178
|
+
interface SandboxFileContent {
|
|
179
|
+
blob: Blob;
|
|
180
|
+
/** From `Content-Disposition`; null without one. */
|
|
181
|
+
filename: string | null;
|
|
182
|
+
contentType: string;
|
|
183
|
+
/** The server cut an inline text preview (`X-Content-Truncated: true`). */
|
|
184
|
+
isTruncated: boolean;
|
|
185
|
+
}
|
|
186
|
+
/** The body of every action: `force` with a `reason` while a turn runs; `confirmation` (the name) for a reset. */
|
|
187
|
+
interface SandboxActionBody {
|
|
188
|
+
force?: boolean;
|
|
189
|
+
reason?: string;
|
|
190
|
+
confirmation?: string;
|
|
191
|
+
}
|
|
192
|
+
interface SandboxActionArg extends SandboxKeyArg, SandboxActionBody {
|
|
193
|
+
action: 'start' | 'offload' | 'end' | 'reset';
|
|
194
|
+
}
|
|
195
|
+
interface SandboxKillArg extends SandboxKeyArg, SandboxActionBody {
|
|
196
|
+
jobId: string;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** The file name of a `Content-Disposition` header (`filename*=UTF-8''…` before `filename="…"`); null without one. */
|
|
200
|
+
declare const fileNameOfContentDisposition: (header: string | null) => string | null;
|
|
201
|
+
/** The response handler of the file content: the shared download shape. */
|
|
202
|
+
declare const readSandboxFileContent: (response: Response) => Promise<SandboxFileContent>;
|
|
203
|
+
/** The cache tag type of the sandbox operations (ids `LIST`, `DETAIL`). */
|
|
204
|
+
declare const SANDBOXES_TAG = "AdminUiSandboxes";
|
|
205
|
+
/** The hooks `createSandboxesApi` returns; the sandbox screens take them as their `api`. */
|
|
206
|
+
interface SandboxesApi {
|
|
207
|
+
/** `GET /list`: every workspace, `isConfigured` false without a host administration. */
|
|
208
|
+
useSandboxesListQuery: ApiQueryHook<void, SandboxWorkspacesResponse>;
|
|
209
|
+
/** `GET /{workspaceKey}`: one workspace (404: unknown). */
|
|
210
|
+
useSandboxQuery: ApiQueryHook<SandboxKeyArg, SandboxWorkspaceResponse>;
|
|
211
|
+
/** `GET /{workspaceKey}/files?path=`: one directory, read only. */
|
|
212
|
+
useSandboxFilesQuery: ApiQueryHook<SandboxFilesArg, SandboxFilesResponse>;
|
|
213
|
+
/** `GET /{workspaceKey}/driveStatus`: changes not yet in the drive. */
|
|
214
|
+
useSandboxDriveStatusQuery: ApiQueryHook<SandboxKeyArg, SandboxDriveStatusResponse>;
|
|
215
|
+
/** `GET /{workspaceKey}/processes`: running processes and jobs. */
|
|
216
|
+
useSandboxProcessesQuery: ApiQueryHook<SandboxKeyArg, SandboxProcessesResponse>;
|
|
217
|
+
/** `GET /{workspaceKey}/commands?limit=`: the newest commands with exit code, duration and output tails. */
|
|
218
|
+
useSandboxCommandsQuery: ApiQueryHook<SandboxLimitArg, SandboxCommandsResponse>;
|
|
219
|
+
/** `GET /{workspaceKey}/events?limit=`: the session log (memory, seccomp, timeouts). */
|
|
220
|
+
useSandboxSessionEventsQuery: ApiQueryHook<SandboxLimitArg, SandboxSessionEventsResponse>;
|
|
221
|
+
/** `GET /{workspaceKey}/conversations?limit=`: the agent conversations of the space, newest first. */
|
|
222
|
+
useSandboxConversationsQuery: ApiQueryHook<SandboxLimitArg, SandboxConversationsResponse>;
|
|
223
|
+
/** `GET /{workspaceKey}/actions?limit=`: the audit of the actions on this workspace. */
|
|
224
|
+
useSandboxActionLogQuery: ApiQueryHook<SandboxLimitArg, SandboxActionLogEntriesResponse>;
|
|
225
|
+
/** `GET /{workspaceKey}/files/content?path&disposition`: one file's bytes as `{ blob, filename, contentType, isTruncated }` (not cached). */
|
|
226
|
+
useSandboxFileContentMutation: ApiMutationHook<SandboxFileContentArg, SandboxFileContent>;
|
|
227
|
+
/** `POST /{workspaceKey}/start|offload|end|reset` (409 while a turn runs, unless `force` + `reason`). */
|
|
228
|
+
useSandboxActionMutation: ApiMutationHook<SandboxActionArg, SandboxActionResponse>;
|
|
229
|
+
/** `POST /{workspaceKey}/jobs/{jobId}/kill`. */
|
|
230
|
+
useKillSandboxJobMutation: ApiMutationHook<SandboxKillArg, SandboxActionResponse>;
|
|
231
|
+
}
|
|
232
|
+
interface CreateSandboxesApiOptions {
|
|
233
|
+
/** The host's RTK Query api (`createApi` with the React hooks module). */
|
|
234
|
+
baseApi: InjectableBaseApi;
|
|
235
|
+
/** Where the host mounts `SandboxesControllerTrait`, without a trailing slash (`/api/admin/maintenance/sandboxes`). */
|
|
236
|
+
apiPrefix: string;
|
|
237
|
+
}
|
|
238
|
+
/** The request of every operation, on `apiPrefix`. Pure: no RTK runtime. */
|
|
239
|
+
declare const buildSandboxesRequests: (apiPrefix: string) => {
|
|
240
|
+
list: () => InjectedRequest;
|
|
241
|
+
workspace: ({ workspaceKey }: SandboxKeyArg) => InjectedRequest;
|
|
242
|
+
files: ({ workspaceKey, path }: SandboxFilesArg) => InjectedRequest;
|
|
243
|
+
driveStatus: ({ workspaceKey }: SandboxKeyArg) => InjectedRequest;
|
|
244
|
+
processes: ({ workspaceKey }: SandboxKeyArg) => InjectedRequest;
|
|
245
|
+
commands: ({ workspaceKey, limit }: SandboxLimitArg) => InjectedRequest;
|
|
246
|
+
events: ({ workspaceKey, limit }: SandboxLimitArg) => InjectedRequest;
|
|
247
|
+
conversations: ({ workspaceKey, limit }: SandboxLimitArg) => InjectedRequest;
|
|
248
|
+
actions: ({ workspaceKey, limit }: SandboxLimitArg) => InjectedRequest;
|
|
249
|
+
content: ({ workspaceKey, path, disposition }: SandboxFileContentArg) => InjectedRequest;
|
|
250
|
+
action: ({ workspaceKey, action, ...body }: SandboxActionArg) => InjectedRequest;
|
|
251
|
+
kill: ({ workspaceKey, jobId, ...body }: SandboxKillArg) => InjectedRequest;
|
|
252
|
+
};
|
|
253
|
+
/** The operations as injected. Every action invalidates the list and the details; file bytes are never cached. */
|
|
254
|
+
declare const sandboxesEndpointDefinitions: (apiPrefix: string) => {
|
|
255
|
+
readonly adminUiSandboxesList: {
|
|
256
|
+
readonly kind: "query";
|
|
257
|
+
readonly request: () => InjectedRequest;
|
|
258
|
+
readonly providesTags: readonly [{
|
|
259
|
+
readonly type: "AdminUiSandboxes";
|
|
260
|
+
readonly id: "LIST";
|
|
261
|
+
}];
|
|
262
|
+
};
|
|
263
|
+
readonly adminUiSandbox: {
|
|
264
|
+
readonly kind: "query";
|
|
265
|
+
readonly request: ({ workspaceKey }: SandboxKeyArg) => InjectedRequest;
|
|
266
|
+
readonly providesTags: readonly [{
|
|
267
|
+
readonly type: "AdminUiSandboxes";
|
|
268
|
+
readonly id: "DETAIL";
|
|
269
|
+
}];
|
|
270
|
+
};
|
|
271
|
+
readonly adminUiSandboxFiles: {
|
|
272
|
+
readonly kind: "query";
|
|
273
|
+
readonly request: ({ workspaceKey, path }: SandboxFilesArg) => InjectedRequest;
|
|
274
|
+
readonly providesTags: readonly [{
|
|
275
|
+
readonly type: "AdminUiSandboxes";
|
|
276
|
+
readonly id: "DETAIL";
|
|
277
|
+
}];
|
|
278
|
+
};
|
|
279
|
+
readonly adminUiSandboxDriveStatus: {
|
|
280
|
+
readonly kind: "query";
|
|
281
|
+
readonly request: ({ workspaceKey }: SandboxKeyArg) => InjectedRequest;
|
|
282
|
+
readonly providesTags: readonly [{
|
|
283
|
+
readonly type: "AdminUiSandboxes";
|
|
284
|
+
readonly id: "DETAIL";
|
|
285
|
+
}];
|
|
286
|
+
};
|
|
287
|
+
readonly adminUiSandboxProcesses: {
|
|
288
|
+
readonly kind: "query";
|
|
289
|
+
readonly request: ({ workspaceKey }: SandboxKeyArg) => InjectedRequest;
|
|
290
|
+
readonly providesTags: readonly [{
|
|
291
|
+
readonly type: "AdminUiSandboxes";
|
|
292
|
+
readonly id: "DETAIL";
|
|
293
|
+
}];
|
|
294
|
+
};
|
|
295
|
+
readonly adminUiSandboxCommands: {
|
|
296
|
+
readonly kind: "query";
|
|
297
|
+
readonly request: ({ workspaceKey, limit }: SandboxLimitArg) => InjectedRequest;
|
|
298
|
+
readonly providesTags: readonly [{
|
|
299
|
+
readonly type: "AdminUiSandboxes";
|
|
300
|
+
readonly id: "DETAIL";
|
|
301
|
+
}];
|
|
302
|
+
};
|
|
303
|
+
readonly adminUiSandboxEvents: {
|
|
304
|
+
readonly kind: "query";
|
|
305
|
+
readonly request: ({ workspaceKey, limit }: SandboxLimitArg) => InjectedRequest;
|
|
306
|
+
readonly providesTags: readonly [{
|
|
307
|
+
readonly type: "AdminUiSandboxes";
|
|
308
|
+
readonly id: "DETAIL";
|
|
309
|
+
}];
|
|
310
|
+
};
|
|
311
|
+
readonly adminUiSandboxConversations: {
|
|
312
|
+
readonly kind: "query";
|
|
313
|
+
readonly request: ({ workspaceKey, limit }: SandboxLimitArg) => InjectedRequest;
|
|
314
|
+
readonly providesTags: readonly [{
|
|
315
|
+
readonly type: "AdminUiSandboxes";
|
|
316
|
+
readonly id: "DETAIL";
|
|
317
|
+
}];
|
|
318
|
+
};
|
|
319
|
+
readonly adminUiSandboxActionLog: {
|
|
320
|
+
readonly kind: "query";
|
|
321
|
+
readonly request: ({ workspaceKey, limit }: SandboxLimitArg) => InjectedRequest;
|
|
322
|
+
readonly providesTags: readonly [{
|
|
323
|
+
readonly type: "AdminUiSandboxes";
|
|
324
|
+
readonly id: "DETAIL";
|
|
325
|
+
}];
|
|
326
|
+
};
|
|
327
|
+
readonly adminUiSandboxFileContent: {
|
|
328
|
+
readonly kind: "mutation";
|
|
329
|
+
readonly request: ({ workspaceKey, path, disposition }: SandboxFileContentArg) => InjectedRequest;
|
|
330
|
+
};
|
|
331
|
+
readonly adminUiSandboxAction: {
|
|
332
|
+
readonly kind: "mutation";
|
|
333
|
+
readonly request: ({ workspaceKey, action, ...body }: SandboxActionArg) => InjectedRequest;
|
|
334
|
+
readonly invalidatesTags: readonly [{
|
|
335
|
+
readonly type: "AdminUiSandboxes";
|
|
336
|
+
readonly id: "LIST";
|
|
337
|
+
}, {
|
|
338
|
+
readonly type: "AdminUiSandboxes";
|
|
339
|
+
readonly id: "DETAIL";
|
|
340
|
+
}];
|
|
341
|
+
};
|
|
342
|
+
readonly adminUiSandboxKillJob: {
|
|
343
|
+
readonly kind: "mutation";
|
|
344
|
+
readonly request: ({ workspaceKey, jobId, ...body }: SandboxKillArg) => InjectedRequest;
|
|
345
|
+
readonly invalidatesTags: readonly [{
|
|
346
|
+
readonly type: "AdminUiSandboxes";
|
|
347
|
+
readonly id: "LIST";
|
|
348
|
+
}, {
|
|
349
|
+
readonly type: "AdminUiSandboxes";
|
|
350
|
+
readonly id: "DETAIL";
|
|
351
|
+
}];
|
|
352
|
+
};
|
|
353
|
+
};
|
|
354
|
+
/**
|
|
355
|
+
* Injects the sandbox operations into the host's RTK Query api and returns their hooks. Call it once at module scope:
|
|
356
|
+
* `export const sandboxesApi = createSandboxesApi({ baseApi: adminApi, apiPrefix: '/api/admin/maintenance/sandboxes' });`
|
|
357
|
+
*/
|
|
358
|
+
declare const createSandboxesApi: ({ baseApi, apiPrefix }: CreateSandboxesApiOptions) => SandboxesApi;
|
|
359
|
+
/** Fixed answers of a `createStaticSandboxesApi`; a query without one stays loading. */
|
|
360
|
+
interface StaticSandboxesData {
|
|
361
|
+
list?: SandboxWorkspacesResponse | StaticQueryFailure;
|
|
362
|
+
workspace?: (arg: SandboxKeyArg) => SandboxWorkspaceResponse | StaticQueryFailure | undefined;
|
|
363
|
+
files?: (arg: SandboxFilesArg) => SandboxFilesResponse | StaticQueryFailure | undefined;
|
|
364
|
+
driveStatus?: (arg: SandboxKeyArg) => SandboxDriveStatusResponse | StaticQueryFailure | undefined;
|
|
365
|
+
processes?: (arg: SandboxKeyArg) => SandboxProcessesResponse | StaticQueryFailure | undefined;
|
|
366
|
+
commands?: (arg: SandboxLimitArg) => SandboxCommandsResponse | StaticQueryFailure | undefined;
|
|
367
|
+
events?: (arg: SandboxLimitArg) => SandboxSessionEventsResponse | StaticQueryFailure | undefined;
|
|
368
|
+
conversations?: (arg: SandboxLimitArg) => SandboxConversationsResponse | StaticQueryFailure | undefined;
|
|
369
|
+
actions?: (arg: SandboxLimitArg) => SandboxActionLogEntriesResponse | StaticQueryFailure | undefined;
|
|
370
|
+
/** A file's text (served as `text/plain`); absent = 404. */
|
|
371
|
+
fileText?: (arg: SandboxFileContentArg) => string | undefined;
|
|
372
|
+
}
|
|
373
|
+
/** A `SandboxesApi` answering fixed payloads, without a store or a request; actions are refused. */
|
|
374
|
+
declare const createStaticSandboxesApi: (data: StaticSandboxesData) => SandboxesApi;
|
|
375
|
+
|
|
376
|
+
export { SANDBOXES_TAG, buildSandboxesRequests, createSandboxesApi, createStaticSandboxesApi, fileNameOfContentDisposition, readSandboxFileContent, sandboxesEndpointDefinitions };
|
|
377
|
+
export type { CreateSandboxesApiOptions, SandboxAction, SandboxActionArg, SandboxActionBody, SandboxActionLogEntriesResponse, SandboxActionLogEntry, SandboxActionOutcome, SandboxActionResponse, SandboxActionResult, SandboxCommand, SandboxCommandStatus, SandboxCommandsResponse, SandboxConversation, SandboxConversationsResponse, SandboxDriveChange, SandboxDriveStatus, SandboxDriveStatusResponse, SandboxElements, SandboxFileContent, SandboxFileContentArg, SandboxFileEntry, SandboxFileType, SandboxFilesArg, SandboxFilesResponse, SandboxKeyArg, SandboxKillArg, SandboxLimitArg, SandboxMountMode, SandboxOffloadResult, SandboxProcess, SandboxProcessesResponse, SandboxSessionEvent, SandboxSessionEventsResponse, SandboxState, SandboxWorkspace, SandboxWorkspaceResponse, SandboxWorkspacesResponse, SandboxesApi, StaticSandboxesData };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
// src/api.ts
|
|
4
|
+
import {
|
|
5
|
+
injectEndpointsOnce,
|
|
6
|
+
staticMutationHook,
|
|
7
|
+
staticQueryHook,
|
|
8
|
+
toQueryString,
|
|
9
|
+
trimApiPrefix
|
|
10
|
+
} from "@mgamadeus/ddd-admin-ui/logic/pure";
|
|
11
|
+
var fileNameOfContentDisposition = (header) => {
|
|
12
|
+
if (!header) return null;
|
|
13
|
+
const encoded = /filename\*\s*=\s*(?:UTF-8|utf-8)''([^;]+)/.exec(header);
|
|
14
|
+
if (encoded?.[1]) {
|
|
15
|
+
try {
|
|
16
|
+
return decodeURIComponent(encoded[1].trim().replace(/^"|"$/g, ""));
|
|
17
|
+
} catch {
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const plain = /filename\s*=\s*"?([^";]+)"?/i.exec(header);
|
|
21
|
+
return plain?.[1]?.trim() || null;
|
|
22
|
+
};
|
|
23
|
+
var readSandboxFileContent = async (response) => {
|
|
24
|
+
const blob = await response.blob();
|
|
25
|
+
return {
|
|
26
|
+
blob,
|
|
27
|
+
filename: fileNameOfContentDisposition(response.headers.get("Content-Disposition")),
|
|
28
|
+
contentType: response.headers.get("Content-Type") ?? blob.type,
|
|
29
|
+
isTruncated: response.headers.get("X-Content-Truncated") === "true"
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
var SANDBOXES_TAG = "AdminUiSandboxes";
|
|
33
|
+
var keyPath = (workspaceKey) => `/${encodeURIComponent(workspaceKey)}`;
|
|
34
|
+
var actionBody = ({ force, reason, confirmation }) => ({
|
|
35
|
+
...force ? { force: true } : {},
|
|
36
|
+
...reason ? { reason } : {},
|
|
37
|
+
...confirmation !== void 0 ? { confirmation } : {}
|
|
38
|
+
});
|
|
39
|
+
var buildSandboxesRequests = (apiPrefix) => {
|
|
40
|
+
const prefix = trimApiPrefix(apiPrefix);
|
|
41
|
+
return {
|
|
42
|
+
list: () => ({ url: `${prefix}/list` }),
|
|
43
|
+
workspace: ({ workspaceKey }) => ({ url: `${prefix}${keyPath(workspaceKey)}` }),
|
|
44
|
+
files: ({ workspaceKey, path }) => ({
|
|
45
|
+
url: `${prefix}${keyPath(workspaceKey)}/files${toQueryString({ path: path || void 0 })}`
|
|
46
|
+
}),
|
|
47
|
+
driveStatus: ({ workspaceKey }) => ({ url: `${prefix}${keyPath(workspaceKey)}/driveStatus` }),
|
|
48
|
+
processes: ({ workspaceKey }) => ({ url: `${prefix}${keyPath(workspaceKey)}/processes` }),
|
|
49
|
+
commands: ({ workspaceKey, limit }) => ({
|
|
50
|
+
url: `${prefix}${keyPath(workspaceKey)}/commands${toQueryString({ limit })}`
|
|
51
|
+
}),
|
|
52
|
+
events: ({ workspaceKey, limit }) => ({
|
|
53
|
+
url: `${prefix}${keyPath(workspaceKey)}/events${toQueryString({ limit })}`
|
|
54
|
+
}),
|
|
55
|
+
conversations: ({ workspaceKey, limit }) => ({
|
|
56
|
+
url: `${prefix}${keyPath(workspaceKey)}/conversations${toQueryString({ limit })}`
|
|
57
|
+
}),
|
|
58
|
+
actions: ({ workspaceKey, limit }) => ({
|
|
59
|
+
url: `${prefix}${keyPath(workspaceKey)}/actions${toQueryString({ limit })}`
|
|
60
|
+
}),
|
|
61
|
+
content: ({ workspaceKey, path, disposition }) => ({
|
|
62
|
+
url: `${prefix}${keyPath(workspaceKey)}/files/content${toQueryString({ path, disposition })}`,
|
|
63
|
+
responseHandler: readSandboxFileContent
|
|
64
|
+
}),
|
|
65
|
+
action: ({ workspaceKey, action, ...body }) => ({
|
|
66
|
+
url: `${prefix}${keyPath(workspaceKey)}/${action}`,
|
|
67
|
+
method: "POST",
|
|
68
|
+
body: actionBody(body)
|
|
69
|
+
}),
|
|
70
|
+
kill: ({ workspaceKey, jobId, ...body }) => ({
|
|
71
|
+
url: `${prefix}${keyPath(workspaceKey)}/jobs/${encodeURIComponent(jobId)}/kill`,
|
|
72
|
+
method: "POST",
|
|
73
|
+
body: actionBody(body)
|
|
74
|
+
})
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
var LIST = { type: SANDBOXES_TAG, id: "LIST" };
|
|
78
|
+
var DETAIL = { type: SANDBOXES_TAG, id: "DETAIL" };
|
|
79
|
+
var sandboxesEndpointDefinitions = (apiPrefix) => {
|
|
80
|
+
const requests = buildSandboxesRequests(apiPrefix);
|
|
81
|
+
return {
|
|
82
|
+
adminUiSandboxesList: { kind: "query", request: requests.list, providesTags: [LIST] },
|
|
83
|
+
adminUiSandbox: { kind: "query", request: requests.workspace, providesTags: [DETAIL] },
|
|
84
|
+
adminUiSandboxFiles: { kind: "query", request: requests.files, providesTags: [DETAIL] },
|
|
85
|
+
adminUiSandboxDriveStatus: { kind: "query", request: requests.driveStatus, providesTags: [DETAIL] },
|
|
86
|
+
adminUiSandboxProcesses: { kind: "query", request: requests.processes, providesTags: [DETAIL] },
|
|
87
|
+
adminUiSandboxCommands: { kind: "query", request: requests.commands, providesTags: [DETAIL] },
|
|
88
|
+
adminUiSandboxEvents: { kind: "query", request: requests.events, providesTags: [DETAIL] },
|
|
89
|
+
adminUiSandboxConversations: { kind: "query", request: requests.conversations, providesTags: [DETAIL] },
|
|
90
|
+
adminUiSandboxActionLog: { kind: "query", request: requests.actions, providesTags: [DETAIL] },
|
|
91
|
+
adminUiSandboxFileContent: { kind: "mutation", request: requests.content },
|
|
92
|
+
adminUiSandboxAction: { kind: "mutation", request: requests.action, invalidatesTags: [LIST, DETAIL] },
|
|
93
|
+
adminUiSandboxKillJob: { kind: "mutation", request: requests.kill, invalidatesTags: [LIST, DETAIL] }
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
var createSandboxesApi = ({ baseApi, apiPrefix }) => injectEndpointsOnce(baseApi, `sandboxes:${trimApiPrefix(apiPrefix)}`, [SANDBOXES_TAG], sandboxesEndpointDefinitions(apiPrefix), (hookOf) => ({
|
|
97
|
+
useSandboxesListQuery: hookOf("adminUiSandboxesList"),
|
|
98
|
+
useSandboxQuery: hookOf("adminUiSandbox"),
|
|
99
|
+
useSandboxFilesQuery: hookOf("adminUiSandboxFiles"),
|
|
100
|
+
useSandboxDriveStatusQuery: hookOf("adminUiSandboxDriveStatus"),
|
|
101
|
+
useSandboxProcessesQuery: hookOf("adminUiSandboxProcesses"),
|
|
102
|
+
useSandboxCommandsQuery: hookOf("adminUiSandboxCommands"),
|
|
103
|
+
useSandboxSessionEventsQuery: hookOf("adminUiSandboxEvents"),
|
|
104
|
+
useSandboxConversationsQuery: hookOf("adminUiSandboxConversations"),
|
|
105
|
+
useSandboxActionLogQuery: hookOf("adminUiSandboxActionLog"),
|
|
106
|
+
useSandboxFileContentMutation: hookOf("adminUiSandboxFileContent"),
|
|
107
|
+
useSandboxActionMutation: hookOf("adminUiSandboxAction"),
|
|
108
|
+
useKillSandboxJobMutation: hookOf("adminUiSandboxKillJob")
|
|
109
|
+
}));
|
|
110
|
+
var NOT_AVAILABLE = () => {
|
|
111
|
+
throw { status: 403, data: { error: "Not available in this preview" } };
|
|
112
|
+
};
|
|
113
|
+
var createStaticSandboxesApi = (data) => ({
|
|
114
|
+
useSandboxesListQuery: staticQueryHook(() => data.list),
|
|
115
|
+
useSandboxQuery: staticQueryHook((arg) => data.workspace?.(arg)),
|
|
116
|
+
useSandboxFilesQuery: staticQueryHook((arg) => data.files?.(arg)),
|
|
117
|
+
useSandboxDriveStatusQuery: staticQueryHook((arg) => data.driveStatus?.(arg)),
|
|
118
|
+
useSandboxProcessesQuery: staticQueryHook((arg) => data.processes?.(arg)),
|
|
119
|
+
useSandboxCommandsQuery: staticQueryHook((arg) => data.commands?.(arg)),
|
|
120
|
+
useSandboxSessionEventsQuery: staticQueryHook((arg) => data.events?.(arg)),
|
|
121
|
+
useSandboxConversationsQuery: staticQueryHook((arg) => data.conversations?.(arg)),
|
|
122
|
+
useSandboxActionLogQuery: staticQueryHook((arg) => data.actions?.(arg)),
|
|
123
|
+
useSandboxFileContentMutation: staticMutationHook((arg) => {
|
|
124
|
+
const text = data.fileText?.(arg);
|
|
125
|
+
if (text === void 0) throw { status: 404, data: { error: "Not found" } };
|
|
126
|
+
return { blob: new Blob([text], { type: "text/plain" }), filename: null, contentType: "text/plain", isTruncated: false };
|
|
127
|
+
}),
|
|
128
|
+
useSandboxActionMutation: staticMutationHook(NOT_AVAILABLE),
|
|
129
|
+
useKillSandboxJobMutation: staticMutationHook(NOT_AVAILABLE)
|
|
130
|
+
});
|
|
131
|
+
export {
|
|
132
|
+
SANDBOXES_TAG,
|
|
133
|
+
buildSandboxesRequests,
|
|
134
|
+
createSandboxesApi,
|
|
135
|
+
createStaticSandboxesApi,
|
|
136
|
+
fileNameOfContentDisposition,
|
|
137
|
+
readSandboxFileContent,
|
|
138
|
+
sandboxesEndpointDefinitions
|
|
139
|
+
};
|
|
140
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/api.ts"],"sourcesContent":["import {\n type ApiMutationHook,\n type ApiQueryHook,\n type InjectableBaseApi,\n type InjectedEndpointDefinition,\n type InjectedRequest,\n injectEndpointsOnce,\n type StaticQueryFailure,\n staticMutationHook,\n staticQueryHook,\n toQueryString,\n trimApiPrefix,\n} from '@mgamadeus/ddd-admin-ui/logic/pure';\nimport type {\n SandboxActionArg,\n SandboxActionLogEntriesResponse,\n SandboxActionResponse,\n SandboxCommandsResponse,\n SandboxConversationsResponse,\n SandboxDriveStatusResponse,\n SandboxFileContent,\n SandboxFileContentArg,\n SandboxFilesArg,\n SandboxFilesResponse,\n SandboxKeyArg,\n SandboxKillArg,\n SandboxLimitArg,\n SandboxProcessesResponse,\n SandboxSessionEventsResponse,\n SandboxWorkspaceResponse,\n SandboxWorkspacesResponse,\n} from './types.ts';\n\n/** The file name of a `Content-Disposition` header (`filename*=UTF-8''…` before `filename=\"…\"`); null without one. */\nexport const fileNameOfContentDisposition = (header: string | null): string | null => {\n if (!header) return null;\n const encoded = /filename\\*\\s*=\\s*(?:UTF-8|utf-8)''([^;]+)/.exec(header);\n if (encoded?.[1]) {\n try {\n return decodeURIComponent(encoded[1].trim().replace(/^\"|\"$/g, ''));\n } catch {\n // fall through to the plain name\n }\n }\n const plain = /filename\\s*=\\s*\"?([^\";]+)\"?/i.exec(header);\n return plain?.[1]?.trim() || null;\n};\n\n/** The response handler of the file content: the shared download shape. */\nexport const readSandboxFileContent = async (response: Response): Promise<SandboxFileContent> => {\n const blob = await response.blob();\n return {\n blob,\n filename: fileNameOfContentDisposition(response.headers.get('Content-Disposition')),\n contentType: response.headers.get('Content-Type') ?? blob.type,\n isTruncated: response.headers.get('X-Content-Truncated') === 'true',\n };\n};\n\n/** The cache tag type of the sandbox operations (ids `LIST`, `DETAIL`). */\nexport const SANDBOXES_TAG = 'AdminUiSandboxes';\n\n/** The hooks `createSandboxesApi` returns; the sandbox screens take them as their `api`. */\nexport interface SandboxesApi {\n /** `GET /list`: every workspace, `isConfigured` false without a host administration. */\n useSandboxesListQuery: ApiQueryHook<void, SandboxWorkspacesResponse>;\n /** `GET /{workspaceKey}`: one workspace (404: unknown). */\n useSandboxQuery: ApiQueryHook<SandboxKeyArg, SandboxWorkspaceResponse>;\n /** `GET /{workspaceKey}/files?path=`: one directory, read only. */\n useSandboxFilesQuery: ApiQueryHook<SandboxFilesArg, SandboxFilesResponse>;\n /** `GET /{workspaceKey}/driveStatus`: changes not yet in the drive. */\n useSandboxDriveStatusQuery: ApiQueryHook<SandboxKeyArg, SandboxDriveStatusResponse>;\n /** `GET /{workspaceKey}/processes`: running processes and jobs. */\n useSandboxProcessesQuery: ApiQueryHook<SandboxKeyArg, SandboxProcessesResponse>;\n /** `GET /{workspaceKey}/commands?limit=`: the newest commands with exit code, duration and output tails. */\n useSandboxCommandsQuery: ApiQueryHook<SandboxLimitArg, SandboxCommandsResponse>;\n /** `GET /{workspaceKey}/events?limit=`: the session log (memory, seccomp, timeouts). */\n useSandboxSessionEventsQuery: ApiQueryHook<SandboxLimitArg, SandboxSessionEventsResponse>;\n /** `GET /{workspaceKey}/conversations?limit=`: the agent conversations of the space, newest first. */\n useSandboxConversationsQuery: ApiQueryHook<SandboxLimitArg, SandboxConversationsResponse>;\n /** `GET /{workspaceKey}/actions?limit=`: the audit of the actions on this workspace. */\n useSandboxActionLogQuery: ApiQueryHook<SandboxLimitArg, SandboxActionLogEntriesResponse>;\n /** `GET /{workspaceKey}/files/content?path&disposition`: one file's bytes as `{ blob, filename, contentType, isTruncated }` (not cached). */\n useSandboxFileContentMutation: ApiMutationHook<SandboxFileContentArg, SandboxFileContent>;\n /** `POST /{workspaceKey}/start|offload|end|reset` (409 while a turn runs, unless `force` + `reason`). */\n useSandboxActionMutation: ApiMutationHook<SandboxActionArg, SandboxActionResponse>;\n /** `POST /{workspaceKey}/jobs/{jobId}/kill`. */\n useKillSandboxJobMutation: ApiMutationHook<SandboxKillArg, SandboxActionResponse>;\n}\n\nexport interface CreateSandboxesApiOptions {\n /** The host's RTK Query api (`createApi` with the React hooks module). */\n baseApi: InjectableBaseApi;\n /** Where the host mounts `SandboxesControllerTrait`, without a trailing slash (`/api/admin/maintenance/sandboxes`). */\n apiPrefix: string;\n}\n\nconst keyPath = (workspaceKey: string): string => `/${encodeURIComponent(workspaceKey)}`;\nconst actionBody = ({ force, reason, confirmation }: { force?: boolean; reason?: string; confirmation?: string }) => ({\n ...(force ? { force: true } : {}),\n ...(reason ? { reason } : {}),\n ...(confirmation !== undefined ? { confirmation } : {}),\n});\n\n/** The request of every operation, on `apiPrefix`. Pure: no RTK runtime. */\nexport const buildSandboxesRequests = (apiPrefix: string) => {\n const prefix = trimApiPrefix(apiPrefix);\n return {\n list: (): InjectedRequest => ({ url: `${prefix}/list` }),\n workspace: ({ workspaceKey }: SandboxKeyArg): InjectedRequest => ({ url: `${prefix}${keyPath(workspaceKey)}` }),\n files: ({ workspaceKey, path }: SandboxFilesArg): InjectedRequest => ({\n url: `${prefix}${keyPath(workspaceKey)}/files${toQueryString({ path: path || undefined })}`,\n }),\n driveStatus: ({ workspaceKey }: SandboxKeyArg): InjectedRequest => ({ url: `${prefix}${keyPath(workspaceKey)}/driveStatus` }),\n processes: ({ workspaceKey }: SandboxKeyArg): InjectedRequest => ({ url: `${prefix}${keyPath(workspaceKey)}/processes` }),\n commands: ({ workspaceKey, limit }: SandboxLimitArg): InjectedRequest => ({\n url: `${prefix}${keyPath(workspaceKey)}/commands${toQueryString({ limit })}`,\n }),\n events: ({ workspaceKey, limit }: SandboxLimitArg): InjectedRequest => ({\n url: `${prefix}${keyPath(workspaceKey)}/events${toQueryString({ limit })}`,\n }),\n conversations: ({ workspaceKey, limit }: SandboxLimitArg): InjectedRequest => ({\n url: `${prefix}${keyPath(workspaceKey)}/conversations${toQueryString({ limit })}`,\n }),\n actions: ({ workspaceKey, limit }: SandboxLimitArg): InjectedRequest => ({\n url: `${prefix}${keyPath(workspaceKey)}/actions${toQueryString({ limit })}`,\n }),\n content: ({ workspaceKey, path, disposition }: SandboxFileContentArg): InjectedRequest => ({\n url: `${prefix}${keyPath(workspaceKey)}/files/content${toQueryString({ path, disposition })}`,\n responseHandler: readSandboxFileContent,\n }),\n action: ({ workspaceKey, action, ...body }: SandboxActionArg): InjectedRequest => ({\n url: `${prefix}${keyPath(workspaceKey)}/${action}`,\n method: 'POST',\n body: actionBody(body),\n }),\n kill: ({ workspaceKey, jobId, ...body }: SandboxKillArg): InjectedRequest => ({\n url: `${prefix}${keyPath(workspaceKey)}/jobs/${encodeURIComponent(jobId)}/kill`,\n method: 'POST',\n body: actionBody(body),\n }),\n };\n};\n\nconst LIST = { type: SANDBOXES_TAG, id: 'LIST' } as const;\nconst DETAIL = { type: SANDBOXES_TAG, id: 'DETAIL' } as const;\n\n/** The operations as injected. Every action invalidates the list and the details; file bytes are never cached. */\nexport const sandboxesEndpointDefinitions = (apiPrefix: string) => {\n const requests = buildSandboxesRequests(apiPrefix);\n return {\n adminUiSandboxesList: { kind: 'query', request: requests.list, providesTags: [LIST] },\n adminUiSandbox: { kind: 'query', request: requests.workspace, providesTags: [DETAIL] },\n adminUiSandboxFiles: { kind: 'query', request: requests.files, providesTags: [DETAIL] },\n adminUiSandboxDriveStatus: { kind: 'query', request: requests.driveStatus, providesTags: [DETAIL] },\n adminUiSandboxProcesses: { kind: 'query', request: requests.processes, providesTags: [DETAIL] },\n adminUiSandboxCommands: { kind: 'query', request: requests.commands, providesTags: [DETAIL] },\n adminUiSandboxEvents: { kind: 'query', request: requests.events, providesTags: [DETAIL] },\n adminUiSandboxConversations: { kind: 'query', request: requests.conversations, providesTags: [DETAIL] },\n adminUiSandboxActionLog: { kind: 'query', request: requests.actions, providesTags: [DETAIL] },\n adminUiSandboxFileContent: { kind: 'mutation', request: requests.content },\n adminUiSandboxAction: { kind: 'mutation', request: requests.action, invalidatesTags: [LIST, DETAIL] },\n adminUiSandboxKillJob: { kind: 'mutation', request: requests.kill, invalidatesTags: [LIST, DETAIL] },\n } as const satisfies Record<string, InjectedEndpointDefinition<never>>;\n};\n\n/**\n * Injects the sandbox operations into the host's RTK Query api and returns their hooks. Call it once at module scope:\n * `export const sandboxesApi = createSandboxesApi({ baseApi: adminApi, apiPrefix: '/api/admin/maintenance/sandboxes' });`\n */\nexport const createSandboxesApi = ({ baseApi, apiPrefix }: CreateSandboxesApiOptions): SandboxesApi =>\n injectEndpointsOnce(baseApi, `sandboxes:${trimApiPrefix(apiPrefix)}`, [SANDBOXES_TAG], sandboxesEndpointDefinitions(apiPrefix), hookOf => ({\n useSandboxesListQuery: hookOf('adminUiSandboxesList') as SandboxesApi['useSandboxesListQuery'],\n useSandboxQuery: hookOf('adminUiSandbox') as SandboxesApi['useSandboxQuery'],\n useSandboxFilesQuery: hookOf('adminUiSandboxFiles') as SandboxesApi['useSandboxFilesQuery'],\n useSandboxDriveStatusQuery: hookOf('adminUiSandboxDriveStatus') as SandboxesApi['useSandboxDriveStatusQuery'],\n useSandboxProcessesQuery: hookOf('adminUiSandboxProcesses') as SandboxesApi['useSandboxProcessesQuery'],\n useSandboxCommandsQuery: hookOf('adminUiSandboxCommands') as SandboxesApi['useSandboxCommandsQuery'],\n useSandboxSessionEventsQuery: hookOf('adminUiSandboxEvents') as SandboxesApi['useSandboxSessionEventsQuery'],\n useSandboxConversationsQuery: hookOf('adminUiSandboxConversations') as SandboxesApi['useSandboxConversationsQuery'],\n useSandboxActionLogQuery: hookOf('adminUiSandboxActionLog') as SandboxesApi['useSandboxActionLogQuery'],\n useSandboxFileContentMutation: hookOf('adminUiSandboxFileContent') as SandboxesApi['useSandboxFileContentMutation'],\n useSandboxActionMutation: hookOf('adminUiSandboxAction') as SandboxesApi['useSandboxActionMutation'],\n useKillSandboxJobMutation: hookOf('adminUiSandboxKillJob') as SandboxesApi['useKillSandboxJobMutation'],\n }));\n\n/** Fixed answers of a `createStaticSandboxesApi`; a query without one stays loading. */\nexport interface StaticSandboxesData {\n list?: SandboxWorkspacesResponse | StaticQueryFailure;\n workspace?: (arg: SandboxKeyArg) => SandboxWorkspaceResponse | StaticQueryFailure | undefined;\n files?: (arg: SandboxFilesArg) => SandboxFilesResponse | StaticQueryFailure | undefined;\n driveStatus?: (arg: SandboxKeyArg) => SandboxDriveStatusResponse | StaticQueryFailure | undefined;\n processes?: (arg: SandboxKeyArg) => SandboxProcessesResponse | StaticQueryFailure | undefined;\n commands?: (arg: SandboxLimitArg) => SandboxCommandsResponse | StaticQueryFailure | undefined;\n events?: (arg: SandboxLimitArg) => SandboxSessionEventsResponse | StaticQueryFailure | undefined;\n conversations?: (arg: SandboxLimitArg) => SandboxConversationsResponse | StaticQueryFailure | undefined;\n actions?: (arg: SandboxLimitArg) => SandboxActionLogEntriesResponse | StaticQueryFailure | undefined;\n /** A file's text (served as `text/plain`); absent = 404. */\n fileText?: (arg: SandboxFileContentArg) => string | undefined;\n}\n\nconst NOT_AVAILABLE = (): never => {\n throw { status: 403, data: { error: 'Not available in this preview' } };\n};\n\n/** A `SandboxesApi` answering fixed payloads, without a store or a request; actions are refused. */\nexport const createStaticSandboxesApi = (data: StaticSandboxesData): SandboxesApi => ({\n useSandboxesListQuery: staticQueryHook(() => data.list),\n useSandboxQuery: staticQueryHook(arg => data.workspace?.(arg)),\n useSandboxFilesQuery: staticQueryHook(arg => data.files?.(arg)),\n useSandboxDriveStatusQuery: staticQueryHook(arg => data.driveStatus?.(arg)),\n useSandboxProcessesQuery: staticQueryHook(arg => data.processes?.(arg)),\n useSandboxCommandsQuery: staticQueryHook(arg => data.commands?.(arg)),\n useSandboxSessionEventsQuery: staticQueryHook(arg => data.events?.(arg)),\n useSandboxConversationsQuery: staticQueryHook(arg => data.conversations?.(arg)),\n useSandboxActionLogQuery: staticQueryHook(arg => data.actions?.(arg)),\n useSandboxFileContentMutation: staticMutationHook((arg: SandboxFileContentArg) => {\n const text = data.fileText?.(arg);\n if (text === undefined) throw { status: 404, data: { error: 'Not found' } };\n return { blob: new Blob([text], { type: 'text/plain' }), filename: null, contentType: 'text/plain', isTruncated: false };\n }),\n useSandboxActionMutation: staticMutationHook(NOT_AVAILABLE),\n useKillSandboxJobMutation: staticMutationHook(NOT_AVAILABLE),\n});\n"],"mappings":";;;AAAA;AAAA,EAME;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAsBA,IAAM,+BAA+B,CAAC,WAAyC;AACpF,MAAI,CAAC,OAAQ,QAAO;AACpB,QAAM,UAAU,4CAA4C,KAAK,MAAM;AACvE,MAAI,UAAU,CAAC,GAAG;AAChB,QAAI;AACF,aAAO,mBAAmB,QAAQ,CAAC,EAAE,KAAK,EAAE,QAAQ,UAAU,EAAE,CAAC;AAAA,IACnE,QAAQ;AAAA,IAER;AAAA,EACF;AACA,QAAM,QAAQ,+BAA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