@remixhq/core 0.1.13 → 0.1.15

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 (78) hide show
  1. package/dist/api.d.ts +76 -1
  2. package/dist/api.js +1 -1
  3. package/dist/auth.js +1 -1
  4. package/dist/binding-WiIRI2fl.d.ts +43 -0
  5. package/dist/binding.d.ts +1 -21
  6. package/dist/binding.js +2 -0
  7. package/dist/{chunk-EVWDYCBL.js → chunk-P6JHXOV4.js} +36 -23
  8. package/dist/{chunk-R7FVSCQW.js → chunk-US5SM7ZC.js} +19 -1
  9. package/dist/collab.d.ts +376 -611
  10. package/dist/collab.js +2381 -376
  11. package/dist/contracts-CHmD-fMj.d.ts +677 -0
  12. package/dist/history.d.ts +64 -0
  13. package/dist/history.js +529 -0
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.js +2 -2
  16. package/package.json +9 -3
  17. package/dist/chunk-2WGZS7CD.js +0 -0
  18. package/dist/chunk-34WDQCPF.js +0 -242
  19. package/dist/chunk-4276ARDF.js +0 -303
  20. package/dist/chunk-4L3ZBZUQ.js +0 -281
  21. package/dist/chunk-54CBEP2W.js +0 -570
  22. package/dist/chunk-55K5GHAZ.js +0 -252
  23. package/dist/chunk-5H5CZKGN.js +0 -691
  24. package/dist/chunk-5NTOJXEZ.js +0 -223
  25. package/dist/chunk-7WUKH3ZD.js +0 -221
  26. package/dist/chunk-AE2HPMUZ.js +0 -80
  27. package/dist/chunk-AEAOYVIL.js +0 -200
  28. package/dist/chunk-B5S3PUIR.js +0 -388
  29. package/dist/chunk-BJFCN2C3.js +0 -46
  30. package/dist/chunk-BNKPTE2U.js +0 -401
  31. package/dist/chunk-C5NBNU32.js +0 -240
  32. package/dist/chunk-CJFGQE7D.js +0 -46
  33. package/dist/chunk-CUUXZSKW.js +0 -611
  34. package/dist/chunk-DCU3646I.js +0 -12
  35. package/dist/chunk-DEWAIK5X.js +0 -11
  36. package/dist/chunk-DRD6EVTT.js +0 -447
  37. package/dist/chunk-DXCL6I4Q.js +0 -399
  38. package/dist/chunk-E4KAGBU7.js +0 -134
  39. package/dist/chunk-E6AYE22H.js +0 -343
  40. package/dist/chunk-EF3677RE.js +0 -93
  41. package/dist/chunk-EW4PWFHB.js +0 -46
  42. package/dist/chunk-FAZUMWBS.js +0 -93
  43. package/dist/chunk-GEHSFPCD.js +0 -93
  44. package/dist/chunk-GFOBGYW4.js +0 -252
  45. package/dist/chunk-INDDXWAH.js +0 -92
  46. package/dist/chunk-IXWQWFYT.js +0 -342
  47. package/dist/chunk-J3J4PBQ7.js +0 -710
  48. package/dist/chunk-K54U353Z.js +0 -691
  49. package/dist/chunk-K57ZFDGC.js +0 -15
  50. package/dist/chunk-NDA7EJJA.js +0 -286
  51. package/dist/chunk-NK2DA4X6.js +0 -357
  52. package/dist/chunk-OBYR4JHZ.js +0 -374
  53. package/dist/chunk-OJMTW22J.js +0 -286
  54. package/dist/chunk-OMUDRPUI.js +0 -195
  55. package/dist/chunk-ONKKRS2C.js +0 -239
  56. package/dist/chunk-OWFBBWU7.js +0 -196
  57. package/dist/chunk-OZRXDDEL.js +0 -46
  58. package/dist/chunk-P7EM3N73.js +0 -46
  59. package/dist/chunk-POYB6MCQ.js +0 -373
  60. package/dist/chunk-PR5QKMHM.js +0 -46
  61. package/dist/chunk-R44EOUS4.js +0 -288
  62. package/dist/chunk-RIP2MIZL.js +0 -710
  63. package/dist/chunk-RKMMEML5.js +0 -46
  64. package/dist/chunk-RM2BGDBB.js +0 -400
  65. package/dist/chunk-RREREIGW.js +0 -710
  66. package/dist/chunk-TQHLFQY4.js +0 -448
  67. package/dist/chunk-TY3SSQQK.js +0 -688
  68. package/dist/chunk-UGKPOCN5.js +0 -710
  69. package/dist/chunk-UIGKSCTD.js +0 -406
  70. package/dist/chunk-UWIVJRTI.js +0 -343
  71. package/dist/chunk-VA6WXRWB.js +0 -636
  72. package/dist/chunk-XC2FV57P.js +0 -385
  73. package/dist/chunk-XOQIADCH.js +0 -223
  74. package/dist/chunk-ZAQZKEH4.js +0 -46
  75. package/dist/chunk-ZBMOGUSJ.js +0 -17
  76. package/dist/chunk-ZXP6ENQY.js +0 -244
  77. package/dist/index.cjs +0 -1269
  78. package/dist/index.d.cts +0 -482
@@ -1,242 +0,0 @@
1
- import {
2
- ComergeError
3
- } from "./chunk-K57ZFDGC.js";
4
-
5
- // src/api/client.ts
6
- async function readJsonSafe(res) {
7
- const ct = res.headers.get("content-type") ?? "";
8
- if (!ct.toLowerCase().includes("application/json")) return null;
9
- try {
10
- return await res.json();
11
- } catch {
12
- return null;
13
- }
14
- }
15
- function createApiClient(config, opts) {
16
- const apiKey = (opts?.apiKey ?? "").trim();
17
- const tokenProvider = opts?.tokenProvider;
18
- const CLIENT_KEY_HEADER = "x-comerge-api-key";
19
- async function request(path, init) {
20
- if (!tokenProvider) {
21
- throw new ComergeError("API client is missing a token provider.", {
22
- exitCode: 1,
23
- hint: "Configure auth before creating the Comerge API client."
24
- });
25
- }
26
- const auth = await tokenProvider();
27
- const url = new URL(path, config.apiUrl).toString();
28
- const doFetch = async (bearer) => fetch(url, {
29
- ...init,
30
- headers: {
31
- Accept: "application/json",
32
- "Content-Type": "application/json",
33
- ...init?.headers ?? {},
34
- Authorization: `Bearer ${bearer}`,
35
- ...apiKey ? { [CLIENT_KEY_HEADER]: apiKey } : {}
36
- }
37
- });
38
- let res = await doFetch(auth.token);
39
- if (res.status === 401 && !auth.fromEnv && auth.session?.refresh_token) {
40
- const refreshed = await tokenProvider({ forceRefresh: true });
41
- res = await doFetch(refreshed.token);
42
- }
43
- if (!res.ok) {
44
- const body = await readJsonSafe(res);
45
- const msg = (body && typeof body === "object" && body && "message" in body && typeof body.message === "string" ? body.message : null) ?? `Request failed (status ${res.status})`;
46
- throw new ComergeError(msg, { exitCode: 1, hint: body ? JSON.stringify(body, null, 2) : null });
47
- }
48
- const json = await readJsonSafe(res);
49
- return json ?? null;
50
- }
51
- async function requestBinary(path, init) {
52
- if (!tokenProvider) {
53
- throw new ComergeError("API client is missing a token provider.", {
54
- exitCode: 1,
55
- hint: "Configure auth before creating the Comerge API client."
56
- });
57
- }
58
- const auth = await tokenProvider();
59
- const url = new URL(path, config.apiUrl).toString();
60
- const doFetch = async (bearer) => fetch(url, {
61
- ...init,
62
- headers: {
63
- Accept: "*/*",
64
- ...init?.headers ?? {},
65
- Authorization: `Bearer ${bearer}`,
66
- ...apiKey ? { [CLIENT_KEY_HEADER]: apiKey } : {}
67
- }
68
- });
69
- let res = await doFetch(auth.token);
70
- if (res.status === 401 && !auth.fromEnv && auth.session?.refresh_token) {
71
- const refreshed = await tokenProvider({ forceRefresh: true });
72
- res = await doFetch(refreshed.token);
73
- }
74
- if (!res.ok) {
75
- const body = await readJsonSafe(res);
76
- const msg = (body && typeof body === "object" && body && "message" in body && typeof body.message === "string" ? body.message : null) ?? `Request failed (status ${res.status})`;
77
- throw new ComergeError(msg, { exitCode: 1, hint: body ? JSON.stringify(body, null, 2) : null });
78
- }
79
- const contentDisposition = res.headers.get("content-disposition") ?? "";
80
- const fileNameMatch = contentDisposition.match(/filename=\"([^\"]+)\"/i);
81
- return {
82
- data: Buffer.from(await res.arrayBuffer()),
83
- fileName: fileNameMatch?.[1] ?? null,
84
- contentType: res.headers.get("content-type")
85
- };
86
- }
87
- return {
88
- getMe: () => request("/v1/me", { method: "GET" }),
89
- listOrganizations: () => request("/v1/organizations", { method: "GET" }),
90
- listProjects: (params) => {
91
- const qs = new URLSearchParams();
92
- if (params?.organizationId) qs.set("organizationId", params.organizationId);
93
- if (params?.clientAppId) qs.set("clientAppId", params.clientAppId);
94
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
95
- return request(`/v1/projects${suffix}`, { method: "GET" });
96
- },
97
- resolveProjectBinding: (params) => {
98
- const qs = new URLSearchParams();
99
- if (params.repoFingerprint) qs.set("repoFingerprint", params.repoFingerprint);
100
- if (params.remoteUrl) qs.set("remoteUrl", params.remoteUrl);
101
- return request(`/v1/projects/bindings/resolve?${qs.toString()}`, { method: "GET" });
102
- },
103
- autoEnableDeveloper: () => request("/v1/developer/auto-enable", { method: "POST" }),
104
- listClientApps: (params) => {
105
- const qs = params?.orgId ? `?orgId=${encodeURIComponent(params.orgId)}` : "";
106
- return request(`/v1/developer/client-apps${qs}`, { method: "GET" });
107
- },
108
- createClientApp: (payload) => request("/v1/developer/client-apps", { method: "POST", body: JSON.stringify(payload) }),
109
- createClientAppKey: (clientAppId, payload) => request(`/v1/developer/client-apps/${encodeURIComponent(clientAppId)}/keys`, {
110
- method: "POST",
111
- body: JSON.stringify(payload ?? {})
112
- }),
113
- listApps: (params) => {
114
- const qs = new URLSearchParams();
115
- if (params?.projectId) qs.set("projectId", params.projectId);
116
- if (params?.organizationId) qs.set("organizationId", params.organizationId);
117
- if (params?.forked) qs.set("forked", params.forked);
118
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
119
- return request(`/v1/apps${suffix}`, { method: "GET" });
120
- },
121
- getApp: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}`, { method: "GET" }),
122
- getMergeRequest: (mrId) => request(`/v1/merge-requests/${encodeURIComponent(mrId)}`, { method: "GET" }),
123
- presignImportUpload: (payload) => request("/v1/apps/import/upload/presign", { method: "POST", body: JSON.stringify(payload) }),
124
- importFromUpload: (payload) => request("/v1/apps/import/upload", { method: "POST", body: JSON.stringify(payload) }),
125
- presignImportUploadFirstParty: (payload) => request("/v1/apps/import/upload/presign/first-party", { method: "POST", body: JSON.stringify(payload) }),
126
- importFromUploadFirstParty: (payload) => request("/v1/apps/import/upload/first-party", { method: "POST", body: JSON.stringify(payload) }),
127
- importFromGithubFirstParty: (payload) => request("/v1/apps/import/github/first-party", { method: "POST", body: JSON.stringify(payload) }),
128
- forkApp: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/fork`, { method: "POST", body: JSON.stringify(payload ?? {}) }),
129
- downloadAppBundle: (appId) => requestBinary(`/v1/apps/${encodeURIComponent(appId)}/download.bundle`, { method: "GET" }),
130
- createChangeStep: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/change-steps`, {
131
- method: "POST",
132
- body: JSON.stringify(payload)
133
- }),
134
- createCollabTurn: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/collab-turns`, {
135
- method: "POST",
136
- body: JSON.stringify(payload)
137
- }),
138
- listCollabTurns: (appId, params) => {
139
- const qs = new URLSearchParams();
140
- if (params?.limit !== void 0) qs.set("limit", String(params.limit));
141
- if (params?.offset !== void 0) qs.set("offset", String(params.offset));
142
- if (params?.changeStepId) qs.set("changeStepId", params.changeStepId);
143
- if (params?.threadId) qs.set("threadId", params.threadId);
144
- if (params?.createdAfter) qs.set("createdAfter", params.createdAfter);
145
- if (params?.createdBefore) qs.set("createdBefore", params.createdBefore);
146
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
147
- return request(`/v1/apps/${encodeURIComponent(appId)}/collab-turns${suffix}`, { method: "GET" });
148
- },
149
- getCollabTurn: (appId, collabTurnId) => request(`/v1/apps/${encodeURIComponent(appId)}/collab-turns/${encodeURIComponent(collabTurnId)}`, {
150
- method: "GET"
151
- }),
152
- getAgentMemorySummary: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}/agent-memory/summary`, { method: "GET" }),
153
- listAgentMemoryTimeline: (appId, params) => {
154
- const qs = new URLSearchParams();
155
- if (params?.limit !== void 0) qs.set("limit", String(params.limit));
156
- if (params?.offset !== void 0) qs.set("offset", String(params.offset));
157
- if (params?.createdAfter) qs.set("createdAfter", params.createdAfter);
158
- if (params?.createdBefore) qs.set("createdBefore", params.createdBefore);
159
- if (params?.kinds?.length) {
160
- for (const kind of params.kinds) qs.append("kinds", kind);
161
- }
162
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
163
- return request(`/v1/apps/${encodeURIComponent(appId)}/agent-memory/timeline${suffix}`, { method: "GET" });
164
- },
165
- searchAgentMemory: (appId, params) => {
166
- const qs = new URLSearchParams();
167
- qs.set("q", params.q);
168
- if (params.limit !== void 0) qs.set("limit", String(params.limit));
169
- if (params.offset !== void 0) qs.set("offset", String(params.offset));
170
- if (params.createdAfter) qs.set("createdAfter", params.createdAfter);
171
- if (params.createdBefore) qs.set("createdBefore", params.createdBefore);
172
- if (params.kinds?.length) {
173
- for (const kind of params.kinds) qs.append("kinds", kind);
174
- }
175
- return request(`/v1/apps/${encodeURIComponent(appId)}/agent-memory/search?${qs.toString()}`, { method: "GET" });
176
- },
177
- getChangeStep: (appId, changeStepId) => request(`/v1/apps/${encodeURIComponent(appId)}/change-steps/${encodeURIComponent(changeStepId)}`, { method: "GET" }),
178
- getChangeStepDiff: (appId, changeStepId) => request(`/v1/apps/${encodeURIComponent(appId)}/change-steps/${encodeURIComponent(changeStepId)}/diff`, {
179
- method: "GET"
180
- }),
181
- listMergeRequests: (params) => {
182
- const qs = new URLSearchParams();
183
- if (params?.sourceAppId) qs.set("sourceAppId", params.sourceAppId);
184
- if (params?.targetAppId) qs.set("targetAppId", params.targetAppId);
185
- if (Array.isArray(params?.status)) {
186
- for (const status of params.status) qs.append("status", status);
187
- } else if (typeof params?.status === "string") {
188
- qs.set("status", params.status);
189
- }
190
- if (params?.kind) qs.set("kind", params.kind);
191
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
192
- return request(`/v1/merge-requests${suffix}`, { method: "GET" });
193
- },
194
- openMergeRequest: (sourceAppId) => request("/v1/merge-requests", { method: "POST", body: JSON.stringify({ sourceAppId }) }),
195
- getMergeRequestReview: (mrId) => request(`/v1/merge-requests/${encodeURIComponent(mrId)}/review`, { method: "GET" }),
196
- updateMergeRequest: (mrId, payload) => request(`/v1/merge-requests/${encodeURIComponent(mrId)}`, { method: "PATCH", body: JSON.stringify(payload) }),
197
- createProjectInvite: (projectId, payload) => request(`/v1/projects/${encodeURIComponent(projectId)}/invitations`, {
198
- method: "POST",
199
- body: JSON.stringify(payload)
200
- }),
201
- syncUpstreamApp: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}/sync-upstream`, {
202
- method: "POST",
203
- body: JSON.stringify({})
204
- }),
205
- preflightAppReconcile: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/reconcile/preflight`, {
206
- method: "POST",
207
- body: JSON.stringify(payload)
208
- }),
209
- startAppReconcile: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/reconcile/start`, {
210
- method: "POST",
211
- body: JSON.stringify(payload)
212
- }),
213
- getAppReconcile: (appId, reconcileId) => request(`/v1/apps/${encodeURIComponent(appId)}/reconcile/${encodeURIComponent(reconcileId)}`, { method: "GET" }),
214
- downloadAppReconcileBundle: (appId, reconcileId) => requestBinary(`/v1/apps/${encodeURIComponent(appId)}/reconcile/${encodeURIComponent(reconcileId)}/download.bundle`, {
215
- method: "GET"
216
- }),
217
- syncLocalApp: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/sync-local`, {
218
- method: "POST",
219
- body: JSON.stringify(payload)
220
- }),
221
- initiateBundle: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/bundles`, { method: "POST", body: JSON.stringify(payload) }),
222
- getBundle: (appId, bundleId) => request(`/v1/apps/${encodeURIComponent(appId)}/bundles/${encodeURIComponent(bundleId)}`, { method: "GET" }),
223
- getBundleDownloadUrl: (appId, bundleId, options) => request(
224
- `/v1/apps/${encodeURIComponent(appId)}/bundles/${encodeURIComponent(bundleId)}/download?redirect=${options?.redirect ?? false}`,
225
- { method: "GET" }
226
- ),
227
- getBundleAssetsDownloadUrl: (appId, bundleId, options) => {
228
- const qs = new URLSearchParams({
229
- redirect: String(options?.redirect ?? false),
230
- kind: options?.kind ?? "metro-assets"
231
- });
232
- return request(
233
- `/v1/apps/${encodeURIComponent(appId)}/bundles/${encodeURIComponent(bundleId)}/assets/download?${qs.toString()}`,
234
- { method: "GET" }
235
- );
236
- }
237
- };
238
- }
239
-
240
- export {
241
- createApiClient
242
- };
@@ -1,303 +0,0 @@
1
- import {
2
- RemixError
3
- } from "./chunk-YZ34ICNN.js";
4
-
5
- // src/api/client.ts
6
- async function readJsonSafe(res) {
7
- const ct = res.headers.get("content-type") ?? "";
8
- if (!ct.toLowerCase().includes("application/json")) return null;
9
- try {
10
- return await res.json();
11
- } catch {
12
- return null;
13
- }
14
- }
15
- function createApiClient(config, opts) {
16
- const apiKey = (opts?.apiKey ?? "").trim();
17
- const tokenProvider = opts?.tokenProvider;
18
- const CLIENT_KEY_HEADER = "x-comerge-api-key";
19
- async function request(path, init) {
20
- if (!tokenProvider) {
21
- throw new RemixError("API client is missing a token provider.", {
22
- exitCode: 1,
23
- hint: "Configure auth before creating the Remix API client."
24
- });
25
- }
26
- const auth = await tokenProvider();
27
- const url = new URL(path, config.apiUrl).toString();
28
- const doFetch = async (bearer) => fetch(url, {
29
- ...init,
30
- headers: {
31
- Accept: "application/json",
32
- "Content-Type": "application/json",
33
- ...init?.headers ?? {},
34
- Authorization: `Bearer ${bearer}`,
35
- ...apiKey ? { [CLIENT_KEY_HEADER]: apiKey } : {}
36
- }
37
- });
38
- let res = await doFetch(auth.token);
39
- if (res.status === 401 && !auth.fromEnv && auth.session?.refresh_token) {
40
- const refreshed = await tokenProvider({ forceRefresh: true });
41
- res = await doFetch(refreshed.token);
42
- }
43
- if (!res.ok) {
44
- const body = await readJsonSafe(res);
45
- const msg = (body && typeof body === "object" && body && "message" in body && typeof body.message === "string" ? body.message : null) ?? `Request failed (status ${res.status})`;
46
- throw new RemixError(msg, { exitCode: 1, hint: body ? JSON.stringify(body, null, 2) : null });
47
- }
48
- const json = await readJsonSafe(res);
49
- return json ?? null;
50
- }
51
- async function requestBinary(path, init) {
52
- if (!tokenProvider) {
53
- throw new RemixError("API client is missing a token provider.", {
54
- exitCode: 1,
55
- hint: "Configure auth before creating the Remix API client."
56
- });
57
- }
58
- const auth = await tokenProvider();
59
- const url = new URL(path, config.apiUrl).toString();
60
- const doFetch = async (bearer) => fetch(url, {
61
- ...init,
62
- headers: {
63
- Accept: "*/*",
64
- ...init?.headers ?? {},
65
- Authorization: `Bearer ${bearer}`,
66
- ...apiKey ? { [CLIENT_KEY_HEADER]: apiKey } : {}
67
- }
68
- });
69
- let res = await doFetch(auth.token);
70
- if (res.status === 401 && !auth.fromEnv && auth.session?.refresh_token) {
71
- const refreshed = await tokenProvider({ forceRefresh: true });
72
- res = await doFetch(refreshed.token);
73
- }
74
- if (!res.ok) {
75
- const body = await readJsonSafe(res);
76
- const msg = (body && typeof body === "object" && body && "message" in body && typeof body.message === "string" ? body.message : null) ?? `Request failed (status ${res.status})`;
77
- throw new RemixError(msg, { exitCode: 1, hint: body ? JSON.stringify(body, null, 2) : null });
78
- }
79
- const contentDisposition = res.headers.get("content-disposition") ?? "";
80
- const fileNameMatch = contentDisposition.match(/filename=\"([^\"]+)\"/i);
81
- return {
82
- data: Buffer.from(await res.arrayBuffer()),
83
- fileName: fileNameMatch?.[1] ?? null,
84
- contentType: res.headers.get("content-type")
85
- };
86
- }
87
- return {
88
- getMe: () => request("/v1/me", { method: "GET" }),
89
- listOrganizations: () => request("/v1/organizations", { method: "GET" }),
90
- getOrganization: (orgId) => request(`/v1/organizations/${encodeURIComponent(orgId)}`, { method: "GET" }),
91
- listProjects: (params) => {
92
- const qs = new URLSearchParams();
93
- if (params?.organizationId) qs.set("organizationId", params.organizationId);
94
- if (params?.clientAppId) qs.set("clientAppId", params.clientAppId);
95
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
96
- return request(`/v1/projects${suffix}`, { method: "GET" });
97
- },
98
- getProject: (projectId) => request(`/v1/projects/${encodeURIComponent(projectId)}`, { method: "GET" }),
99
- resolveProjectBinding: (params) => {
100
- const qs = new URLSearchParams();
101
- if (params.repoFingerprint) qs.set("repoFingerprint", params.repoFingerprint);
102
- if (params.remoteUrl) qs.set("remoteUrl", params.remoteUrl);
103
- return request(`/v1/projects/bindings/resolve?${qs.toString()}`, { method: "GET" });
104
- },
105
- autoEnableDeveloper: () => request("/v1/developer/auto-enable", { method: "POST" }),
106
- listClientApps: (params) => {
107
- const qs = params?.orgId ? `?orgId=${encodeURIComponent(params.orgId)}` : "";
108
- return request(`/v1/developer/client-apps${qs}`, { method: "GET" });
109
- },
110
- createClientApp: (payload) => request("/v1/developer/client-apps", { method: "POST", body: JSON.stringify(payload) }),
111
- createClientAppKey: (clientAppId, payload) => request(`/v1/developer/client-apps/${encodeURIComponent(clientAppId)}/keys`, {
112
- method: "POST",
113
- body: JSON.stringify(payload ?? {})
114
- }),
115
- listApps: (params) => {
116
- const qs = new URLSearchParams();
117
- if (params?.projectId) qs.set("projectId", params.projectId);
118
- if (params?.organizationId) qs.set("organizationId", params.organizationId);
119
- if (params?.forked) qs.set("forked", params.forked);
120
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
121
- return request(`/v1/apps${suffix}`, { method: "GET" });
122
- },
123
- getApp: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}`, { method: "GET" }),
124
- getMergeRequest: (mrId) => request(`/v1/merge-requests/${encodeURIComponent(mrId)}`, { method: "GET" }),
125
- presignImportUpload: (payload) => request("/v1/apps/import/upload/presign", { method: "POST", body: JSON.stringify(payload) }),
126
- importFromUpload: (payload) => request("/v1/apps/import/upload", { method: "POST", body: JSON.stringify(payload) }),
127
- presignImportUploadFirstParty: (payload) => request("/v1/apps/import/upload/presign/first-party", { method: "POST", body: JSON.stringify(payload) }),
128
- importFromUploadFirstParty: (payload) => request("/v1/apps/import/upload/first-party", { method: "POST", body: JSON.stringify(payload) }),
129
- importFromGithubFirstParty: (payload) => request("/v1/apps/import/github/first-party", { method: "POST", body: JSON.stringify(payload) }),
130
- forkApp: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/fork`, { method: "POST", body: JSON.stringify(payload ?? {}) }),
131
- downloadAppBundle: (appId) => requestBinary(`/v1/apps/${encodeURIComponent(appId)}/download.bundle`, { method: "GET" }),
132
- createChangeStep: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/change-steps`, {
133
- method: "POST",
134
- body: JSON.stringify(payload)
135
- }),
136
- createCollabTurn: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/collab-turns`, {
137
- method: "POST",
138
- body: JSON.stringify(payload)
139
- }),
140
- listCollabTurns: (appId, params) => {
141
- const qs = new URLSearchParams();
142
- if (params?.limit !== void 0) qs.set("limit", String(params.limit));
143
- if (params?.offset !== void 0) qs.set("offset", String(params.offset));
144
- if (params?.changeStepId) qs.set("changeStepId", params.changeStepId);
145
- if (params?.threadId) qs.set("threadId", params.threadId);
146
- if (params?.createdAfter) qs.set("createdAfter", params.createdAfter);
147
- if (params?.createdBefore) qs.set("createdBefore", params.createdBefore);
148
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
149
- return request(`/v1/apps/${encodeURIComponent(appId)}/collab-turns${suffix}`, { method: "GET" });
150
- },
151
- getCollabTurn: (appId, collabTurnId) => request(`/v1/apps/${encodeURIComponent(appId)}/collab-turns/${encodeURIComponent(collabTurnId)}`, {
152
- method: "GET"
153
- }),
154
- getAgentMemorySummary: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}/agent-memory/summary`, { method: "GET" }),
155
- listAgentMemoryTimeline: (appId, params) => {
156
- const qs = new URLSearchParams();
157
- if (params?.limit !== void 0) qs.set("limit", String(params.limit));
158
- if (params?.offset !== void 0) qs.set("offset", String(params.offset));
159
- if (params?.createdAfter) qs.set("createdAfter", params.createdAfter);
160
- if (params?.createdBefore) qs.set("createdBefore", params.createdBefore);
161
- if (params?.kinds?.length) {
162
- for (const kind of params.kinds) qs.append("kinds", kind);
163
- }
164
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
165
- return request(`/v1/apps/${encodeURIComponent(appId)}/agent-memory/timeline${suffix}`, { method: "GET" });
166
- },
167
- searchAgentMemory: (appId, params) => {
168
- const qs = new URLSearchParams();
169
- qs.set("q", params.q);
170
- if (params.limit !== void 0) qs.set("limit", String(params.limit));
171
- if (params.offset !== void 0) qs.set("offset", String(params.offset));
172
- if (params.createdAfter) qs.set("createdAfter", params.createdAfter);
173
- if (params.createdBefore) qs.set("createdBefore", params.createdBefore);
174
- if (params.kinds?.length) {
175
- for (const kind of params.kinds) qs.append("kinds", kind);
176
- }
177
- return request(`/v1/apps/${encodeURIComponent(appId)}/agent-memory/search?${qs.toString()}`, { method: "GET" });
178
- },
179
- getChangeStep: (appId, changeStepId) => request(`/v1/apps/${encodeURIComponent(appId)}/change-steps/${encodeURIComponent(changeStepId)}`, { method: "GET" }),
180
- getChangeStepDiff: (appId, changeStepId) => request(`/v1/apps/${encodeURIComponent(appId)}/change-steps/${encodeURIComponent(changeStepId)}/diff`, {
181
- method: "GET"
182
- }),
183
- startChangeStepReplay: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/change-steps/replays`, {
184
- method: "POST",
185
- body: JSON.stringify(payload)
186
- }),
187
- getChangeStepReplay: (appId, replayId) => request(`/v1/apps/${encodeURIComponent(appId)}/change-steps/replays/${encodeURIComponent(replayId)}`, {
188
- method: "GET"
189
- }),
190
- getChangeStepReplayDiff: (appId, replayId) => request(`/v1/apps/${encodeURIComponent(appId)}/change-steps/replays/${encodeURIComponent(replayId)}/diff`, {
191
- method: "GET"
192
- }),
193
- listMergeRequests: (params) => {
194
- const qs = new URLSearchParams();
195
- if (params?.queue) qs.set("queue", params.queue);
196
- if (params?.appId) qs.set("appId", params.appId);
197
- if (params?.sourceAppId) qs.set("sourceAppId", params.sourceAppId);
198
- if (params?.targetAppId) qs.set("targetAppId", params.targetAppId);
199
- if (Array.isArray(params?.status)) {
200
- for (const status of params.status) qs.append("status", status);
201
- } else if (typeof params?.status === "string") {
202
- qs.set("status", params.status);
203
- }
204
- if (params?.kind) qs.set("kind", params.kind);
205
- const suffix = qs.toString() ? `?${qs.toString()}` : "";
206
- return request(`/v1/merge-requests${suffix}`, { method: "GET" });
207
- },
208
- openMergeRequest: (sourceAppId) => request("/v1/merge-requests", { method: "POST", body: JSON.stringify({ sourceAppId }) }),
209
- getMergeRequestReview: (mrId) => request(`/v1/merge-requests/${encodeURIComponent(mrId)}/review`, { method: "GET" }),
210
- updateMergeRequest: (mrId, payload) => request(`/v1/merge-requests/${encodeURIComponent(mrId)}`, { method: "PATCH", body: JSON.stringify(payload) }),
211
- createOrganizationInvite: (orgId, payload) => request(`/v1/organizations/${encodeURIComponent(orgId)}/invitations`, {
212
- method: "POST",
213
- body: JSON.stringify(payload)
214
- }),
215
- createProjectInvite: (projectId, payload) => request(`/v1/projects/${encodeURIComponent(projectId)}/invitations`, {
216
- method: "POST",
217
- body: JSON.stringify(payload)
218
- }),
219
- createAppInvite: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/invitations`, {
220
- method: "POST",
221
- body: JSON.stringify(payload)
222
- }),
223
- listOrganizationMembers: (orgId) => request(`/v1/organizations/${encodeURIComponent(orgId)}/members`, { method: "GET" }),
224
- updateOrganizationMember: (orgId, userId, payload) => request(`/v1/organizations/${encodeURIComponent(orgId)}/members/${encodeURIComponent(userId)}`, {
225
- method: "PATCH",
226
- body: JSON.stringify(payload)
227
- }),
228
- listProjectMembers: (projectId) => request(`/v1/projects/${encodeURIComponent(projectId)}/members`, { method: "GET" }),
229
- updateProjectMember: (projectId, userId, payload) => request(`/v1/projects/${encodeURIComponent(projectId)}/members/${encodeURIComponent(userId)}`, {
230
- method: "PATCH",
231
- body: JSON.stringify(payload)
232
- }),
233
- listAppMembers: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}/members`, { method: "GET" }),
234
- updateAppMember: (appId, userId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/members/${encodeURIComponent(userId)}`, {
235
- method: "PATCH",
236
- body: JSON.stringify(payload)
237
- }),
238
- listOrganizationInvites: (orgId) => request(`/v1/organizations/${encodeURIComponent(orgId)}/invitations`, { method: "GET" }),
239
- listProjectInvites: (projectId) => request(`/v1/projects/${encodeURIComponent(projectId)}/invitations`, { method: "GET" }),
240
- listAppInvites: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}/invitations`, { method: "GET" }),
241
- resendOrganizationInvite: (orgId, inviteId, payload) => request(`/v1/organizations/${encodeURIComponent(orgId)}/invitations/${encodeURIComponent(inviteId)}/resend`, {
242
- method: "POST",
243
- body: JSON.stringify(payload ?? {})
244
- }),
245
- resendProjectInvite: (projectId, inviteId, payload) => request(`/v1/projects/${encodeURIComponent(projectId)}/invitations/${encodeURIComponent(inviteId)}/resend`, {
246
- method: "POST",
247
- body: JSON.stringify(payload ?? {})
248
- }),
249
- resendAppInvite: (appId, inviteId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/invitations/${encodeURIComponent(inviteId)}/resend`, {
250
- method: "POST",
251
- body: JSON.stringify(payload ?? {})
252
- }),
253
- revokeOrganizationInvite: (orgId, inviteId) => request(`/v1/organizations/${encodeURIComponent(orgId)}/invitations/${encodeURIComponent(inviteId)}`, {
254
- method: "DELETE"
255
- }),
256
- revokeProjectInvite: (projectId, inviteId) => request(`/v1/projects/${encodeURIComponent(projectId)}/invitations/${encodeURIComponent(inviteId)}`, {
257
- method: "DELETE"
258
- }),
259
- revokeAppInvite: (appId, inviteId) => request(`/v1/apps/${encodeURIComponent(appId)}/invitations/${encodeURIComponent(inviteId)}`, {
260
- method: "DELETE"
261
- }),
262
- syncUpstreamApp: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}/sync-upstream`, {
263
- method: "POST",
264
- body: JSON.stringify({})
265
- }),
266
- preflightAppReconcile: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/reconcile/preflight`, {
267
- method: "POST",
268
- body: JSON.stringify(payload)
269
- }),
270
- startAppReconcile: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/reconcile/start`, {
271
- method: "POST",
272
- body: JSON.stringify(payload)
273
- }),
274
- getAppReconcile: (appId, reconcileId) => request(`/v1/apps/${encodeURIComponent(appId)}/reconcile/${encodeURIComponent(reconcileId)}`, { method: "GET" }),
275
- downloadAppReconcileBundle: (appId, reconcileId) => requestBinary(`/v1/apps/${encodeURIComponent(appId)}/reconcile/${encodeURIComponent(reconcileId)}/download.bundle`, {
276
- method: "GET"
277
- }),
278
- syncLocalApp: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/sync-local`, {
279
- method: "POST",
280
- body: JSON.stringify(payload)
281
- }),
282
- initiateBundle: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/bundles`, { method: "POST", body: JSON.stringify(payload) }),
283
- getBundle: (appId, bundleId) => request(`/v1/apps/${encodeURIComponent(appId)}/bundles/${encodeURIComponent(bundleId)}`, { method: "GET" }),
284
- getBundleDownloadUrl: (appId, bundleId, options) => request(
285
- `/v1/apps/${encodeURIComponent(appId)}/bundles/${encodeURIComponent(bundleId)}/download?redirect=${options?.redirect ?? false}`,
286
- { method: "GET" }
287
- ),
288
- getBundleAssetsDownloadUrl: (appId, bundleId, options) => {
289
- const qs = new URLSearchParams({
290
- redirect: String(options?.redirect ?? false),
291
- kind: options?.kind ?? "metro-assets"
292
- });
293
- return request(
294
- `/v1/apps/${encodeURIComponent(appId)}/bundles/${encodeURIComponent(bundleId)}/assets/download?${qs.toString()}`,
295
- { method: "GET" }
296
- );
297
- }
298
- };
299
- }
300
-
301
- export {
302
- createApiClient
303
- };