@remixhq/core 0.1.13 → 0.1.14

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/collab.d.ts CHANGED
@@ -1,613 +1,6 @@
1
- type JsonObject = Record<string, any>;
2
- type MergeRequestStatus = "open" | "approved" | "rejected" | "merged" | "closed";
3
- type MergeRequestQueue = "reviewable" | "created_by_me" | "app_reviewable" | "app_outgoing" | "app_related_visible";
4
- type MergeRequest = {
5
- id: string;
6
- sourceAppId: string;
7
- sourceCommitId: string;
8
- sourceTipCommitId: string | null;
9
- targetAppId: string;
10
- targetCommitId: string | null;
11
- kind: "merge" | "sync";
12
- status: MergeRequestStatus;
13
- title: string | null;
14
- description: string | null;
15
- category: string | null;
16
- tags: string[] | null;
17
- createdBy: string;
18
- reviewedBy: string | null;
19
- mergedBy: string | null;
20
- createdAt: string;
21
- updatedAt: string;
22
- mergedAt: string | null;
23
- closedAt: string | null;
24
- };
25
- type MergeRequestReviewPrompt = {
26
- commitId: string;
27
- messageId: string | null;
28
- prompt: string | null;
29
- };
30
- type MergeRequestReviewChangeStep = {
31
- id: string;
32
- appId: string;
33
- threadId: string | null;
34
- messageId: string | null;
35
- commitId: string | null;
36
- baseCommitHash: string | null;
37
- headCommitHash: string | null;
38
- changedFilesCount: number | null;
39
- insertions: number | null;
40
- deletions: number | null;
41
- status: string | null;
42
- statusError: string | null;
43
- actor: {
44
- type: string | null;
45
- name: string | null;
46
- version: string | null;
47
- provider: string | null;
48
- };
49
- workspaceMetadata: JsonObject | null;
50
- prompt: string | null;
51
- diff: string;
52
- createdAt: string;
53
- };
54
- type MergeRequestReview = {
55
- mergeRequest: MergeRequest;
56
- prompts: MergeRequestReviewPrompt[];
57
- changeSteps: MergeRequestReviewChangeStep[];
58
- unifiedDiff: string;
59
- stats: {
60
- changeStepCount: number;
61
- changedFilesCount: number;
62
- insertions: number;
63
- deletions: number;
64
- };
65
- };
66
- type CollabApproveMode = "remote-only" | "sync-target-repo";
67
- type CollabStatusBlockedReason = "not_git_repo" | "not_bound" | "branch_binding_missing" | "family_ambiguous" | "missing_head" | "detached_head" | "branch_mismatch" | "dirty_worktree" | "baseline_missing" | "metadata_conflict" | "remote_error";
68
- type CollabRepoStateKind = "idle" | "local_only_changed" | "server_only_changed" | "both_changed" | "external_local_base_changed" | "metadata_conflict" | "binding_problem";
69
- type CollabPendingFinalizeState = "idle" | "queued" | "processing" | "retry_scheduled" | "failed";
70
- type CollabPendingFinalizeSummary = {
71
- state: CollabPendingFinalizeState;
72
- activeJobCount: number;
73
- queuedJobCount: number;
74
- processingJobCount: number;
75
- retryScheduledJobCount: number;
76
- failedJobCount: number;
77
- oldestCapturedAt: string | null;
78
- newestCapturedAt: string | null;
79
- nextRetryAt: string | null;
80
- latestError: string | null;
81
- };
82
- type CollabStatusRecommendedAction = "init" | "pull" | "re_anchor" | "reconcile" | "await_finalize" | "record" | "review_queue" | "choose_family" | "no_action";
83
- type CollabStatus = {
84
- schemaVersion: 1;
85
- repo: {
86
- isGitRepo: boolean;
87
- repoRoot: string | null;
88
- branch: string | null;
89
- branchMismatch: boolean;
90
- headCommitHash: string | null;
91
- worktree: {
92
- isClean: boolean;
93
- entryCount: number;
94
- hasTrackedChanges: boolean;
95
- hasUntrackedFiles: boolean;
96
- preview: string[];
97
- };
98
- };
99
- binding: {
100
- isBound: boolean;
101
- path: string | null;
102
- projectId: string | null;
103
- currentAppId: string | null;
104
- upstreamAppId: string | null;
105
- isRemix: boolean | null;
106
- threadId: string | null;
107
- repoFingerprint: string | null;
108
- remoteUrl: string | null;
109
- defaultBranch: string | null;
110
- laneId: string | null;
111
- branchName: string | null;
112
- bindingMode: "legacy" | "lane" | "explicit_root" | null;
113
- };
114
- remote: {
115
- checked: boolean;
116
- error: string | null;
117
- appStatus: string | null;
118
- incomingOpenMergeRequestCount: number | null;
119
- outgoingOpenMergeRequestCount: number | null;
120
- };
121
- sync: {
122
- checked: boolean;
123
- error: string | null;
124
- canApply: boolean;
125
- status: "not_available" | SyncLocalResponse["status"];
126
- blockedReasons: CollabStatusBlockedReason[];
127
- warnings: string[];
128
- targetCommitHash: string | null;
129
- targetCommitId: string | null;
130
- stats: SyncLocalResponse["stats"] | null;
131
- };
132
- reconcile: {
133
- checked: boolean;
134
- error: string | null;
135
- canApply: boolean;
136
- status: "not_available" | "not_needed" | ReconcilePreflightResponse["status"];
137
- blockedReasons: CollabStatusBlockedReason[];
138
- warnings: string[];
139
- targetHeadCommitHash: string | null;
140
- targetHeadCommitId: string | null;
141
- };
142
- alignment: {
143
- checked: boolean;
144
- error: string | null;
145
- repoState: CollabRepoStateKind | null;
146
- canRecordTurn: boolean;
147
- pendingFinalize: CollabPendingFinalizeSummary;
148
- baseline: {
149
- lastSnapshotId: string | null;
150
- lastSnapshotHash: string | null;
151
- lastServerHeadHash: string | null;
152
- lastSeenLocalCommitHash: string | null;
153
- };
154
- current: {
155
- snapshotHash: string | null;
156
- serverHeadHash: string | null;
157
- serverHeadCommitId: string | null;
158
- localCommitHash: string | null;
159
- };
160
- };
161
- recommendedAction: CollabStatusRecommendedAction;
162
- warnings: string[];
163
- };
164
- type SyncLocalResponse = {
165
- status: "up_to_date" | "delta_ready" | "ready_to_fast_forward" | "base_unknown" | "conflict_risk";
166
- baseCommitHash: string;
167
- targetCommitHash: string;
168
- targetCommitId: string;
169
- bundleRef: string | null;
170
- bundleBase64: string | null;
171
- bundleEncoding: "base64" | null;
172
- bundleSizeBytes: number;
173
- stats: {
174
- changedFilesCount: number;
175
- insertions: number;
176
- deletions: number;
177
- };
178
- warnings: string[];
179
- };
180
- type AppHeadResponse = {
181
- appId: string;
182
- headCommitId: string;
183
- headCommitHash: string;
184
- status: string;
185
- updatedAt: string;
186
- };
187
- type AppDeltaResponse = {
188
- status: "up_to_date" | "delta_ready" | "base_unknown" | "content_equivalent" | "conflict_risk";
189
- baseHeadHash: string;
190
- targetHeadHash: string;
191
- targetHeadCommitId: string | null;
192
- diff: string;
193
- diffSha256: string | null;
194
- stats: {
195
- changedFilesCount: number;
196
- insertions: number;
197
- deletions: number;
198
- };
199
- warnings: string[];
200
- };
201
- type SyncUpstreamResponse = {
202
- status: "up-to-date" | "queued";
203
- mergeRequestId?: string;
204
- };
205
- type CollabRecordingPreflightStatus = "not_git_repo" | "not_bound" | "branch_binding_missing" | "family_ambiguous" | "missing_head" | "branch_mismatch" | "metadata_conflict" | "ready" | "pull_required" | "re_anchor_required" | "reconcile_required";
206
- type CollabRecordingPreflight = {
207
- status: CollabRecordingPreflightStatus;
208
- repoState: CollabRepoStateKind | null;
209
- repoRoot: string | null;
210
- appId: string | null;
211
- currentBranch: string | null;
212
- branchName: string | null;
213
- headCommitHash: string | null;
214
- worktreeClean: boolean;
215
- syncStatus: SyncLocalResponse["status"] | AppDeltaResponse["status"] | null;
216
- syncTargetCommitHash: string | null;
217
- syncTargetCommitId: string | null;
218
- reconcileTargetHeadCommitHash: string | null;
219
- reconcileTargetHeadCommitId: string | null;
220
- warnings: string[];
221
- hint: string | null;
222
- };
223
- type ReconcilePreflightResponse = {
224
- status: "up_to_date" | "ready_to_reconcile" | "metadata_conflict";
225
- localHeadCommitHash: string;
226
- targetHeadCommitId: string;
227
- targetHeadCommitHash: string;
228
- warnings: string[];
229
- };
230
- type AppReconcileResponse = {
231
- id: string;
232
- appId: string;
233
- uploadId: string;
234
- queueItemId: string | null;
235
- requestedBy: string;
236
- repoFingerprint: string | null;
237
- remoteUrl: string | null;
238
- defaultBranch: string | null;
239
- localHeadCommitHash: string;
240
- targetHeadCommitId: string | null;
241
- targetHeadCommitHash: string | null;
242
- mergeBaseCommitHash: string | null;
243
- reconciledHeadCommitId: string | null;
244
- reconciledHeadCommitHash: string | null;
245
- localCommitHashes: string[];
246
- reconciledCommitIds: string[];
247
- reconciledCommitHashes: string[];
248
- status: "pending" | "queued" | "processing" | "succeeded" | "failed" | "manual_reconcile_required" | "cancelled";
249
- failureKind: string | null;
250
- statusError: string | null;
251
- idempotencyKey: string | null;
252
- resultBundleRef: string | null;
253
- queuePosition?: number | null;
254
- runId?: string | null;
255
- createdAt: string;
256
- updatedAt: string;
257
- };
258
- type CollabApproveResult = {
259
- mode: CollabApproveMode;
260
- mergeRequestId: string;
261
- terminalStatus: MergeRequestStatus;
262
- targetAppId: string;
263
- mergeRequest: MergeRequest;
264
- repoRoot?: string;
265
- localSync?: {
266
- status: SyncLocalResponse["status"];
267
- branch: string;
268
- repoRoot: string;
269
- baseCommitHash: string;
270
- targetCommitHash: string;
271
- targetCommitId: string | null;
272
- stats: SyncLocalResponse["stats"];
273
- bundleRef?: string | null;
274
- bundleSizeBytes?: number;
275
- localCommitHash: string | null;
276
- applied: boolean;
277
- dryRun: boolean;
278
- };
279
- };
280
- type CollabTurn = {
281
- id: string;
282
- appId: string;
283
- threadId: string;
284
- humanMessageId: string;
285
- assistantMessageId: string;
286
- changeStepId: string | null;
287
- actor: {
288
- type: string;
289
- name: string | null;
290
- version: string | null;
291
- provider: string | null;
292
- };
293
- workspaceMetadata: JsonObject | null;
294
- idempotencyKey: string | null;
295
- createdBy: string;
296
- createdAt: string;
297
- updatedAt: string;
298
- prompt: string | null;
299
- assistantResponse: string | null;
300
- };
301
- type CollabFinalizeTurnMode = "changed_turn" | "no_diff_turn";
302
- type CollabFinalizeTurnAutoSync = {
303
- requested: boolean;
304
- eligible: boolean;
305
- attempted: boolean;
306
- applied: boolean;
307
- trackedChangesDiscarded: boolean;
308
- capturedUntrackedPathsCandidate: string[];
309
- localHeadBefore: string | null;
310
- localHeadAfter: string | null;
311
- localRepoMutated: boolean;
312
- };
313
- type CollabFinalizeTurnResult = {
314
- mode: CollabFinalizeTurnMode;
315
- idempotencyKey: string;
316
- queued: boolean;
317
- jobId: string | null;
318
- repoState: CollabRepoStateKind | null;
319
- changeStep: JsonObject | null;
320
- collabTurn: CollabTurn | null;
321
- autoSync: CollabFinalizeTurnAutoSync | null;
322
- warnings: string[];
323
- };
324
- type InvitationScopeType = "organization" | "project" | "app";
325
- type MembershipScopeType = InvitationScopeType;
326
- type OrganizationMemberRole = "owner" | "admin" | "member" | "viewer";
327
- type ProjectMemberRole = "owner" | "maintainer" | "editor" | "viewer";
328
- type AppMemberRole = "owner" | "maintainer" | "editor" | "viewer";
329
- type OrganizationMember = {
330
- id: string;
331
- userId: string;
332
- organizationId: string;
333
- role: OrganizationMemberRole;
334
- invitedBy: string | null;
335
- createdAt: string;
336
- updatedAt: string;
337
- };
338
- type ProjectMember = {
339
- id: string;
340
- userId: string;
341
- projectId: string;
342
- role: ProjectMemberRole;
343
- invitedBy: string | null;
344
- createdAt: string;
345
- updatedAt: string;
346
- };
347
- type AppMember = {
348
- id: string;
349
- userId: string;
350
- appId: string;
351
- role: AppMemberRole;
352
- invitedBy: string | null;
353
- createdAt: string;
354
- updatedAt: string;
355
- };
356
- type CollabMember = OrganizationMember | ProjectMember | AppMember;
357
- type CollabApiClient = {
358
- resolveProjectBinding(params: {
359
- repoFingerprint?: string;
360
- remoteUrl?: string;
361
- branchName?: string;
362
- }): Promise<unknown>;
363
- resolveProjectLaneBinding(params: {
364
- projectId?: string;
365
- repoFingerprint?: string;
366
- remoteUrl?: string;
367
- defaultBranch?: string;
368
- branchName: string;
369
- }): Promise<unknown>;
370
- ensureProjectLaneBinding(payload: {
371
- projectId?: string;
372
- repoFingerprint?: string;
373
- remoteUrl?: string;
374
- defaultBranch?: string;
375
- branchName: string;
376
- seedAppId?: string;
377
- seedHeadCommitHash?: string;
378
- }): Promise<unknown>;
379
- bootstrapFreshProjectLane(payload: {
380
- projectId?: string;
381
- repoFingerprint?: string;
382
- remoteUrl?: string;
383
- defaultBranch?: string;
384
- branchName: string;
385
- seedAppId: string;
386
- seedHeadCommitHash?: string;
387
- }): Promise<unknown>;
388
- getOrganization(orgId: string): Promise<unknown>;
389
- getProject(projectId: string): Promise<unknown>;
390
- listApps(params?: {
391
- projectId?: string;
392
- organizationId?: string;
393
- ownership?: "mine" | "shared" | "all";
394
- accessScope?: "all_readable" | "explicit_member";
395
- createdBy?: "me" | string;
396
- forked?: "only" | "exclude" | "all";
397
- limit?: number;
398
- offset?: number;
399
- }): Promise<unknown>;
400
- getApp(appId: string): Promise<unknown>;
401
- getAppHead(appId: string): Promise<unknown>;
402
- getAppDelta(appId: string, payload: {
403
- baseHeadHash: string;
404
- targetHeadHash?: string;
405
- localSnapshotHash?: string;
406
- repoFingerprint?: string;
407
- remoteUrl?: string;
408
- defaultBranch?: string;
409
- }): Promise<unknown>;
410
- getMergeRequest(mrId: string): Promise<unknown>;
411
- presignImportUploadFirstParty(payload: {
412
- file: {
413
- name: string;
414
- mimeType: string;
415
- size: number;
416
- checksumSha256?: string;
417
- };
418
- }): Promise<unknown>;
419
- importFromUploadFirstParty(payload: {
420
- uploadId: string;
421
- appName?: string;
422
- threadId?: string;
423
- branch?: string;
424
- path?: string;
425
- platform?: string;
426
- isPublic?: boolean;
427
- remoteUrl?: string;
428
- defaultBranch?: string;
429
- repoFingerprint?: string;
430
- headCommitHash?: string;
431
- }): Promise<unknown>;
432
- forkApp(appId: string, payload?: {
433
- name?: string;
434
- platform?: string;
435
- forkedFromCommitId?: string;
436
- branchName?: string;
437
- }): Promise<unknown>;
438
- downloadAppBundle(appId: string): Promise<{
439
- data: Buffer;
440
- fileName: string | null;
441
- contentType: string | null;
442
- }>;
443
- createChangeStep(appId: string, payload: {
444
- threadId?: string;
445
- collabLaneId?: string;
446
- prompt: string;
447
- assistantResponse?: string;
448
- diff: string;
449
- baseCommitHash?: string | null;
450
- headCommitHash?: string | null;
451
- changedFilesCount?: number;
452
- insertions?: number;
453
- deletions?: number;
454
- actor?: {
455
- type?: string;
456
- name?: string;
457
- version?: string;
458
- provider?: string;
459
- };
460
- workspaceMetadata?: Record<string, unknown>;
461
- idempotencyKey?: string;
462
- }): Promise<unknown>;
463
- startChangeStepReplay(appId: string, payload: {
464
- prompt: string;
465
- assistantResponse?: string;
466
- diff: string;
467
- baseCommitHash: string;
468
- targetHeadCommitHash: string;
469
- expectedPaths: string[];
470
- actor?: {
471
- type?: string;
472
- name?: string;
473
- version?: string;
474
- provider?: string;
475
- };
476
- workspaceMetadata?: Record<string, unknown>;
477
- idempotencyKey?: string;
478
- }): Promise<unknown>;
479
- getChangeStepReplay(appId: string, replayId: string): Promise<unknown>;
480
- getChangeStepReplayDiff(appId: string, replayId: string): Promise<unknown>;
481
- createCollabTurn(appId: string, payload: {
482
- threadId?: string;
483
- collabLaneId?: string;
484
- prompt: string;
485
- assistantResponse: string;
486
- actor?: {
487
- type?: string;
488
- name?: string;
489
- version?: string;
490
- provider?: string;
491
- };
492
- workspaceMetadata?: Record<string, unknown>;
493
- idempotencyKey?: string;
494
- }): Promise<unknown>;
495
- getChangeStep(appId: string, changeStepId: string): Promise<unknown>;
496
- listMergeRequests(params?: {
497
- queue?: MergeRequestQueue;
498
- appId?: string;
499
- sourceAppId?: string;
500
- targetAppId?: string;
501
- status?: string | string[];
502
- kind?: string;
503
- limit?: number;
504
- offset?: number;
505
- }): Promise<unknown>;
506
- listCollabTurns(appId: string, params?: {
507
- limit?: number;
508
- offset?: number;
509
- changeStepId?: string;
510
- threadId?: string;
511
- collabLaneId?: string;
512
- createdAfter?: string;
513
- createdBefore?: string;
514
- }): Promise<unknown>;
515
- openMergeRequest(sourceAppId: string): Promise<unknown>;
516
- getMergeRequestReview(mrId: string): Promise<unknown>;
517
- updateMergeRequest(mrId: string, payload: {
518
- title?: string;
519
- description?: string;
520
- status?: string;
521
- }): Promise<unknown>;
522
- createOrganizationInvite(orgId: string, payload: {
523
- email: string;
524
- role?: string;
525
- ttlDays?: number;
526
- }): Promise<unknown>;
527
- createProjectInvite(projectId: string, payload: {
528
- email: string;
529
- role?: string;
530
- ttlDays?: number;
531
- }): Promise<unknown>;
532
- createAppInvite(appId: string, payload: {
533
- email: string;
534
- role?: string;
535
- ttlDays?: number;
536
- }): Promise<unknown>;
537
- listOrganizationMembers(orgId: string, params?: {
538
- limit?: number;
539
- offset?: number;
540
- }): Promise<unknown>;
541
- updateOrganizationMember(orgId: string, userId: string, payload: {
542
- role: OrganizationMemberRole;
543
- }): Promise<unknown>;
544
- listProjectMembers(projectId: string, params?: {
545
- limit?: number;
546
- offset?: number;
547
- }): Promise<unknown>;
548
- updateProjectMember(projectId: string, userId: string, payload: {
549
- role: ProjectMemberRole;
550
- }): Promise<unknown>;
551
- listAppMembers(appId: string, params?: {
552
- limit?: number;
553
- offset?: number;
554
- }): Promise<unknown>;
555
- updateAppMember(appId: string, userId: string, payload: {
556
- role: AppMemberRole;
557
- }): Promise<unknown>;
558
- listOrganizationInvites(orgId: string, params?: {
559
- limit?: number;
560
- offset?: number;
561
- }): Promise<unknown>;
562
- listProjectInvites(projectId: string, params?: {
563
- limit?: number;
564
- offset?: number;
565
- }): Promise<unknown>;
566
- listAppInvites(appId: string, params?: {
567
- limit?: number;
568
- offset?: number;
569
- }): Promise<unknown>;
570
- resendOrganizationInvite(orgId: string, inviteId: string, payload?: {
571
- ttlDays?: number;
572
- }): Promise<unknown>;
573
- resendProjectInvite(projectId: string, inviteId: string, payload?: {
574
- ttlDays?: number;
575
- }): Promise<unknown>;
576
- resendAppInvite(appId: string, inviteId: string, payload?: {
577
- ttlDays?: number;
578
- }): Promise<unknown>;
579
- revokeOrganizationInvite(orgId: string, inviteId: string): Promise<unknown>;
580
- revokeProjectInvite(projectId: string, inviteId: string): Promise<unknown>;
581
- revokeAppInvite(appId: string, inviteId: string): Promise<unknown>;
582
- syncUpstreamApp(appId: string): Promise<unknown>;
583
- preflightAppReconcile(appId: string, payload: {
584
- localHeadCommitHash: string;
585
- repoFingerprint?: string;
586
- remoteUrl?: string;
587
- defaultBranch?: string;
588
- }): Promise<unknown>;
589
- startAppReconcile(appId: string, payload: {
590
- uploadId: string;
591
- localHeadCommitHash: string;
592
- repoFingerprint?: string;
593
- remoteUrl?: string;
594
- defaultBranch?: string;
595
- idempotencyKey?: string;
596
- }): Promise<unknown>;
597
- getAppReconcile(appId: string, reconcileId: string): Promise<unknown>;
598
- downloadAppReconcileBundle(appId: string, reconcileId: string): Promise<{
599
- data: Buffer;
600
- fileName: string | null;
601
- contentType: string | null;
602
- }>;
603
- syncLocalApp(appId: string, payload: {
604
- baseCommitHash: string;
605
- repoFingerprint?: string;
606
- remoteUrl?: string;
607
- defaultBranch?: string;
608
- dryRun?: boolean;
609
- }): Promise<unknown>;
610
- };
1
+ import { C as CollabApiClient, T as TurnUsagePayload, a as CollabFinalizeTurnResult, b as CollabRecordingPreflight, c as CollabApproveMode, d as CollabApproveResult, M as MergeRequestQueue, e as MergeRequest, I as InvitationScopeType, f as CollabMember, J as JsonObject, A as AppDeltaResponse, g as CollabStatus, h as MergeRequestReview } from './contracts-NbV3P_Rl.js';
2
+ export { i as AppHeadResponse, j as AppMember, k as AppMemberRole, l as AppReconcileResponse, m as CollabFinalizeTurnAutoSync, n as CollabFinalizeTurnMode, o as CollabPendingFinalizeState, p as CollabPendingFinalizeSummary, q as CollabRecordingPreflightStatus, r as CollabRepoStateKind, s as CollabStatusBlockedReason, t as CollabStatusRecommendedAction, u as CollabTurn, v as MembershipScopeType, w as MergeRequestStatus, x as ModelCall, O as OrganizationMember, y as OrganizationMemberRole, P as ProjectMember, z as ProjectMemberRole, R as ReconcilePreflightResponse, S as ServerToolUsage, B as SyncLocalResponse, D as SyncUpstreamResponse, E as TurnUsage, F as TurnUsageCaptureSource, G as TurnUsageConfidence, H as TurnUsagePreviousPatch } from './contracts-NbV3P_Rl.js';
3
+ import { B as BranchBindingMode } from './binding-WiIRI2fl.js';
611
4
 
612
5
  declare function collabFinalizeTurn(params: {
613
6
  api: CollabApiClient;
@@ -625,8 +18,37 @@ declare function collabFinalizeTurn(params: {
625
18
  version?: string;
626
19
  provider?: string;
627
20
  };
21
+ turnUsage?: TurnUsagePayload | null;
22
+ /**
23
+ * ISO-8601 timestamp of when the user actually typed/submitted this prompt
24
+ * on their local machine. Distinct from the server-side `created_at` that
25
+ * gets stamped at API ingestion time, which can drift by minutes (or longer)
26
+ * when:
27
+ * - prompts ride the queued-prompt reconciler recovery path (Cursor's
28
+ * queue holds prompts in memory while the agent is busy)
29
+ * - prompts ride the deferred-turn drainer (branch was unbound at submit
30
+ * time and finalization waits for `remix collab init` to land)
31
+ * - prompts ride the orphan-prompt recovery path (a previous turn's
32
+ * pending state was displaced before its afterAgentResponse fired)
33
+ *
34
+ * When provided, the dashboard sorts the timeline by this value (with a
35
+ * fallback to `created_at` for back-compat). When omitted, behaviour is
36
+ * unchanged. Stored under `workspace_metadata.promptedAt`.
37
+ */
38
+ promptedAt?: string | null;
39
+ /**
40
+ * When set and > 0, the enqueued job's `nextRetryAt` is offset this many ms into
41
+ * the future, blocking the drainer from claiming it until the deadline expires
42
+ * or another caller (typically the Stop hook) clears it after harvesting usage.
43
+ * When unset/null/0, behavior is unchanged: `nextRetryAt: null`, drain-immediately.
44
+ */
45
+ awaitingUsageDeadlineMs?: number | null;
628
46
  }): Promise<CollabFinalizeTurnResult>;
629
47
 
48
+ declare const FINALIZE_PREFLIGHT_FAILURE_CODES: readonly ["not_bound", "branch_binding_missing", "family_ambiguous", "metadata_conflict", "branch_mismatch", "missing_head", "remote_error", "pull_required", "re_anchor_required"];
49
+ type FinalizePreflightFailureCode = (typeof FINALIZE_PREFLIGHT_FAILURE_CODES)[number];
50
+ declare function isFinalizePreflightFailureCode(value: unknown): value is FinalizePreflightFailureCode;
51
+
630
52
  declare function collabRecordingPreflight(params: {
631
53
  api: CollabApiClient;
632
54
  cwd: string;
@@ -708,13 +130,90 @@ declare function collabUpdateMemberRole(params: {
708
130
  }>;
709
131
 
710
132
  type InitBaselineStatus = "seeded" | "existing" | "requires_re_anchor" | "requires_sync";
133
+ type CollabInitQueuedResult = {
134
+ queued: true;
135
+ jobId: string;
136
+ repoRoot: string;
137
+ projectId: string;
138
+ appId: string;
139
+ upstreamAppId: string;
140
+ dashboardUrl: string;
141
+ bindingPath: string;
142
+ bindingMode: BranchBindingMode;
143
+ createdCanonicalFamily: boolean;
144
+ remoteUrl: string | null;
145
+ defaultBranch: string | null;
146
+ warnings?: string[];
147
+ };
711
148
  declare function collabInit(params: {
712
149
  api: CollabApiClient;
713
150
  cwd: string;
714
151
  appName?: string | null;
715
152
  path?: string | null;
716
153
  forceNew?: boolean;
154
+ asyncSubmit?: boolean;
155
+ }): Promise<{
156
+ warnings?: string[] | undefined;
157
+ queued: true;
158
+ jobId: string;
159
+ repoRoot: string;
160
+ projectId: string;
161
+ appId: string;
162
+ upstreamAppId: string;
163
+ dashboardUrl: string;
164
+ bindingPath: string;
165
+ bindingMode: string;
166
+ createdCanonicalFamily: boolean;
167
+ remoteUrl: string | null;
168
+ defaultBranch: string | null;
169
+ } | {
170
+ warnings?: string[] | undefined;
171
+ reused: boolean;
172
+ projectId: string;
173
+ appId: string;
174
+ dashboardUrl: string;
175
+ upstreamAppId: string;
176
+ bindingPath: string;
177
+ repoRoot: string;
178
+ bindingMode: string;
179
+ createdCanonicalFamily: boolean;
180
+ baselineStatus: InitBaselineStatus;
181
+ } | {
182
+ warnings?: string[] | undefined;
183
+ reused: boolean;
184
+ projectId: string;
185
+ appId: string;
186
+ dashboardUrl: string;
187
+ upstreamAppId: string;
188
+ bindingPath: string;
189
+ repoRoot: string;
190
+ bindingMode: "lane" | "explicit_root";
191
+ createdCanonicalFamily: boolean;
192
+ baselineStatus: InitBaselineStatus;
193
+ remoteUrl: string | null;
194
+ defaultBranch: string | null;
195
+ }>;
196
+ declare function collabInitSubmit(params: {
197
+ api: CollabApiClient;
198
+ cwd: string;
199
+ appName?: string | null;
200
+ path?: string | null;
201
+ forceNew?: boolean;
717
202
  }): Promise<{
203
+ warnings?: string[] | undefined;
204
+ queued: true;
205
+ jobId: string;
206
+ repoRoot: string;
207
+ projectId: string;
208
+ appId: string;
209
+ upstreamAppId: string;
210
+ dashboardUrl: string;
211
+ bindingPath: string;
212
+ bindingMode: string;
213
+ createdCanonicalFamily: boolean;
214
+ remoteUrl: string | null;
215
+ defaultBranch: string | null;
216
+ } | {
718
217
  warnings?: string[] | undefined;
719
218
  reused: boolean;
720
219
  projectId: string;
@@ -777,6 +276,7 @@ declare function collabReAnchor(params: {
777
276
  cwd: string;
778
277
  dryRun?: boolean;
779
278
  allowBranchMismatch?: boolean;
279
+ asyncSubmit?: boolean;
780
280
  }): Promise<{
781
281
  status: string;
782
282
  repoRoot: string;
@@ -788,6 +288,71 @@ declare function collabReAnchor(params: {
788
288
  warnings: string[];
789
289
  applied: boolean;
790
290
  dryRun: boolean;
291
+ } | {
292
+ status: "queued";
293
+ queued: true;
294
+ jobId: string;
295
+ repoRoot: string;
296
+ branch: string;
297
+ currentAppId: string;
298
+ dryRun: boolean;
299
+ applied: boolean;
300
+ localHeadCommitHash?: undefined;
301
+ targetHeadCommitHash?: undefined;
302
+ warnings?: undefined;
303
+ } | {
304
+ status: "queued";
305
+ queued: true;
306
+ jobId: string;
307
+ repoRoot: string;
308
+ branch: string;
309
+ currentAppId: string;
310
+ localHeadCommitHash: string;
311
+ targetHeadCommitHash: string;
312
+ warnings: string[];
313
+ dryRun: boolean;
314
+ applied: boolean;
315
+ }>;
316
+ declare function collabReAnchorSubmit(params: {
317
+ api: CollabApiClient;
318
+ cwd: string;
319
+ dryRun?: boolean;
320
+ allowBranchMismatch?: boolean;
321
+ }): Promise<{
322
+ status: string;
323
+ repoRoot: string;
324
+ branch: string;
325
+ currentAppId: string;
326
+ localHeadCommitHash: string;
327
+ targetHeadCommitHash: string;
328
+ targetHeadCommitId: string;
329
+ warnings: string[];
330
+ applied: boolean;
331
+ dryRun: boolean;
332
+ } | {
333
+ status: "queued";
334
+ queued: true;
335
+ jobId: string;
336
+ repoRoot: string;
337
+ branch: string;
338
+ currentAppId: string;
339
+ dryRun: boolean;
340
+ applied: boolean;
341
+ localHeadCommitHash?: undefined;
342
+ targetHeadCommitHash?: undefined;
343
+ warnings?: undefined;
344
+ } | {
345
+ status: "queued";
346
+ queued: true;
347
+ jobId: string;
348
+ repoRoot: string;
349
+ branch: string;
350
+ currentAppId: string;
351
+ localHeadCommitHash: string;
352
+ targetHeadCommitHash: string;
353
+ warnings: string[];
354
+ dryRun: boolean;
355
+ applied: boolean;
791
356
  }>;
792
357
 
793
358
  declare function collabReconcile(params: {
@@ -818,6 +383,30 @@ declare function collabReconcile(params: {
818
383
  warnings: string[];
819
384
  applied: boolean;
820
385
  dryRun: boolean;
386
+ } | {
387
+ status: "queued";
388
+ queued: true;
389
+ jobId: string;
390
+ repoRoot: string;
391
+ branch: string;
392
+ currentAppId: string;
393
+ dryRun: boolean;
394
+ applied: boolean;
395
+ localHeadCommitHash?: undefined;
396
+ targetHeadCommitHash?: undefined;
397
+ warnings?: undefined;
398
+ } | {
399
+ status: "queued";
400
+ queued: true;
401
+ jobId: string;
402
+ repoRoot: string;
403
+ branch: string;
404
+ currentAppId: string;
405
+ localHeadCommitHash: string;
406
+ targetHeadCommitHash: string;
407
+ warnings: string[];
408
+ dryRun: boolean;
409
+ applied: boolean;
821
410
  } | {
822
411
  status: string;
823
412
  repoRoot: string;
@@ -924,6 +513,50 @@ declare function collabView(params: {
924
513
  mrId: string;
925
514
  }): Promise<MergeRequestReview>;
926
515
 
516
+ declare const FINALIZE_JOB_LOCK_STALE_MS: number;
517
+ type PendingFinalizeJobStatus = "queued" | "processing" | "completed" | "failed";
518
+ type PendingFinalizeJob = {
519
+ schemaVersion: 1;
520
+ id: string;
521
+ status: PendingFinalizeJobStatus;
522
+ repoRoot: string;
523
+ repoFingerprint: string | null;
524
+ currentAppId: string;
525
+ laneId: string | null;
526
+ threadId: string | null;
527
+ branchName: string | null;
528
+ prompt: string;
529
+ assistantResponse: string;
530
+ baselineSnapshotId: string | null;
531
+ baselineServerHeadHash: string | null;
532
+ currentSnapshotId: string;
533
+ capturedAt: string;
534
+ updatedAt: string;
535
+ idempotencyKey: string | null;
536
+ error: string | null;
537
+ retryCount: number;
538
+ lastAttemptAt: string | null;
539
+ nextRetryAt: string | null;
540
+ metadata: Record<string, unknown>;
541
+ };
542
+ declare function cleanStaleFinalizeJobLocks(): Promise<{
543
+ removed: string[];
544
+ skipped: Array<{
545
+ jobId: string;
546
+ reason: string;
547
+ }>;
548
+ errors: Array<{
549
+ jobId: string;
550
+ error: string;
551
+ }>;
552
+ }>;
553
+ declare function readPendingFinalizeJob(jobId: string): Promise<PendingFinalizeJob | null>;
554
+ declare function listPendingFinalizeJobs(): Promise<PendingFinalizeJob[]>;
555
+ declare function updatePendingFinalizeJob(jobId: string, update: Partial<Omit<PendingFinalizeJob, "schemaVersion" | "id" | "capturedAt">>): Promise<PendingFinalizeJob | null>;
556
+ declare function removePendingFinalizeJob(jobId: string): Promise<void>;
557
+ declare const forgetPendingFinalizeJob: typeof removePendingFinalizeJob;
558
+ declare function requeuePendingFinalizeJob(jobId: string): Promise<PendingFinalizeJob | null>;
559
+
927
560
  declare function processPendingFinalizeJob(params: {
928
561
  api: CollabApiClient;
929
562
  jobId: string;
@@ -932,4 +565,136 @@ declare function drainPendingFinalizeQueue(params: {
932
565
  api: CollabApiClient;
933
566
  }): Promise<CollabFinalizeTurnResult[]>;
934
567
 
935
- export { type AppDeltaResponse, type AppHeadResponse, type AppMember, type AppMemberRole, type AppReconcileResponse, type CollabApiClient, type CollabApproveMode, type CollabApproveResult, type CollabFinalizeTurnAutoSync, type CollabFinalizeTurnMode, type CollabFinalizeTurnResult, type CollabMember, type CollabPendingFinalizeState, type CollabPendingFinalizeSummary, type CollabRecordingPreflight, type CollabRecordingPreflightStatus, type CollabRepoStateKind, type CollabStatus, type CollabStatusBlockedReason, type CollabStatusRecommendedAction, type CollabTurn, type InvitationScopeType, type JsonObject, type MembershipScopeType, type MergeRequest, type MergeRequestQueue, type MergeRequestReview, type MergeRequestStatus, type OrganizationMember, type OrganizationMemberRole, type ProjectMember, type ProjectMemberRole, type ReconcilePreflightResponse, type SyncLocalResponse, type SyncUpstreamResponse, collabApprove, collabCheckout, collabFinalizeTurn, collabInit, collabInvite, collabList, collabListMembers, collabListMergeRequests, collabReAnchor, collabReconcile, collabRecordingPreflight, collabReject, collabRemix, collabRequestMerge, collabStatus, collabSync, collabSyncUpstream, collabUpdateMemberRole, collabView, drainPendingFinalizeQueue, getMemberRolesForScope, processPendingFinalizeJob, validateMemberRole };
568
+ type ProcessOutcome = {
569
+ status: "completed";
570
+ jobId: string;
571
+ } | {
572
+ status: "failed";
573
+ jobId: string;
574
+ error: string;
575
+ } | {
576
+ status: "retry_scheduled";
577
+ jobId: string;
578
+ error: string;
579
+ retryCount: number;
580
+ } | {
581
+ status: "skipped";
582
+ jobId: string;
583
+ };
584
+ declare function collabInitProcess(jobId: string, opts: {
585
+ api: CollabApiClient;
586
+ }): Promise<ProcessOutcome>;
587
+ declare function collabReAnchorProcess(jobId: string, opts: {
588
+ api: CollabApiClient;
589
+ }): Promise<ProcessOutcome>;
590
+ declare function drainAsyncJobs(opts: {
591
+ api: CollabApiClient;
592
+ respectPidLock?: boolean;
593
+ }): Promise<ProcessOutcome[]>;
594
+
595
+ type AsyncJobKind = "init" | "init_post" | "re_anchor";
596
+ type AsyncJobStatus = "queued" | "submitting" | "uploading" | "server_processing" | "completed" | "failed";
597
+ type AsyncJobBase = {
598
+ schemaVersion: 1;
599
+ id: string;
600
+ kind: AsyncJobKind;
601
+ status: AsyncJobStatus;
602
+ repoRoot: string;
603
+ repoFingerprint: string | null;
604
+ branchName: string | null;
605
+ laneId: string | null;
606
+ createdAt: string;
607
+ updatedAt: string;
608
+ retryCount: number;
609
+ error: string | null;
610
+ idempotencyKey: string | null;
611
+ };
612
+ type InitJobPayload = {
613
+ bundlePath: string;
614
+ bundleSha256: string;
615
+ appName: string | null;
616
+ forceNew: boolean;
617
+ path: string | null;
618
+ defaultBranch: string | null;
619
+ headCommitHash: string;
620
+ remoteUrl: string | null;
621
+ };
622
+ type ReAnchorJobPayload = {
623
+ bundlePath: string;
624
+ bundleSha256: string;
625
+ localHeadCommitHash: string;
626
+ targetHeadCommitHash: string;
627
+ appId: string;
628
+ };
629
+ type InitPostJobPayload = {
630
+ appId: string;
631
+ syncPhaseStartedAt: number;
632
+ syncPhaseFinishedAt: number;
633
+ };
634
+ type AsyncJob = (AsyncJobBase & {
635
+ kind: "init";
636
+ payload: InitJobPayload;
637
+ }) | (AsyncJobBase & {
638
+ kind: "init_post";
639
+ payload: InitPostJobPayload;
640
+ }) | (AsyncJobBase & {
641
+ kind: "re_anchor";
642
+ payload: ReAnchorJobPayload;
643
+ });
644
+ type AsyncJobSummary = {
645
+ state: "idle" | "queued" | "processing" | "failed";
646
+ activeJobCount: number;
647
+ queuedJobCount: number;
648
+ processingJobCount: number;
649
+ failedJobCount: number;
650
+ oldestCreatedAt: string | null;
651
+ newestCreatedAt: string | null;
652
+ latestError: string | null;
653
+ kinds: AsyncJobKind[];
654
+ };
655
+ declare function readAsyncJob(jobId: string): Promise<AsyncJob | null>;
656
+ declare function listAsyncJobs(): Promise<AsyncJob[]>;
657
+ declare function listAsyncJobsForRepo(params: {
658
+ repoRoot: string;
659
+ branchName?: string | null;
660
+ kind?: AsyncJobKind | null;
661
+ }): Promise<AsyncJob[]>;
662
+ declare function findPendingAsyncJob(params: {
663
+ repoRoot: string;
664
+ branchName: string | null;
665
+ kind: AsyncJobKind;
666
+ }): Promise<AsyncJob | null>;
667
+ declare function findFailedAsyncJob(params: {
668
+ repoRoot: string;
669
+ branchName: string | null;
670
+ kind: AsyncJobKind;
671
+ }): Promise<AsyncJob | null>;
672
+ declare function deleteAsyncJob(jobId: string): Promise<void>;
673
+ declare function summarizeAsyncJobs(params: {
674
+ repoRoot: string;
675
+ branchName?: string | null;
676
+ }): Promise<AsyncJobSummary>;
677
+ declare function pruneTerminalAsyncJobs(): Promise<void>;
678
+ type AwaitAsyncJobResult = {
679
+ status: "completed";
680
+ job: AsyncJob;
681
+ } | {
682
+ status: "failed";
683
+ job: AsyncJob;
684
+ } | {
685
+ status: "timeout";
686
+ job: AsyncJob | null;
687
+ };
688
+ declare function awaitAsyncJob(params: {
689
+ jobId: string;
690
+ timeoutMs: number;
691
+ pollIntervalMs?: number;
692
+ }): Promise<AwaitAsyncJobResult>;
693
+
694
+ type DrainerLogEvent = "submitted" | "claimed" | "uploading" | "server_accepted" | "server_completed" | "retrying" | "failed" | "completed" | "replaced" | "binding_cleared";
695
+ declare function drainerLogPath(): string;
696
+
697
+ declare function getDrainerLogPath(): string;
698
+ declare function getDrainerPidPath(): string;
699
+
700
+ export { AppDeltaResponse, type AsyncJob, type AsyncJobBase, type AsyncJobKind, type AsyncJobStatus, type AsyncJobSummary, type AwaitAsyncJobResult, CollabApiClient, CollabApproveMode, CollabApproveResult, CollabFinalizeTurnResult, type CollabInitQueuedResult, CollabMember, CollabRecordingPreflight, CollabStatus, type DrainerLogEvent, FINALIZE_JOB_LOCK_STALE_MS, FINALIZE_PREFLIGHT_FAILURE_CODES, type FinalizePreflightFailureCode, type InitJobPayload, InvitationScopeType, JsonObject, MergeRequest, MergeRequestQueue, MergeRequestReview, type PendingFinalizeJob, type ReAnchorJobPayload, TurnUsagePayload, awaitAsyncJob, cleanStaleFinalizeJobLocks, collabApprove, collabCheckout, collabFinalizeTurn, collabInit, collabInitProcess, collabInitSubmit, collabInvite, collabList, collabListMembers, collabListMergeRequests, collabReAnchor, collabReAnchorProcess, collabReAnchorSubmit, collabReconcile, collabRecordingPreflight, collabReject, collabRemix, collabRequestMerge, collabStatus, collabSync, collabSyncUpstream, collabUpdateMemberRole, collabView, deleteAsyncJob, drainAsyncJobs, drainPendingFinalizeQueue, drainerLogPath, findFailedAsyncJob, findPendingAsyncJob, forgetPendingFinalizeJob, getDrainerLogPath, getDrainerPidPath, getMemberRolesForScope, isFinalizePreflightFailureCode, listAsyncJobs, listAsyncJobsForRepo, listPendingFinalizeJobs, processPendingFinalizeJob, pruneTerminalAsyncJobs, readAsyncJob, readPendingFinalizeJob, requeuePendingFinalizeJob, summarizeAsyncJobs, updatePendingFinalizeJob, validateMemberRole };