@remixhq/core 0.1.12 → 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,562 +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" | "metadata_conflict" | "remote_error";
68
- type CollabStatusRecommendedAction = "init" | "sync" | "reconcile" | "review_queue" | "choose_family" | "no_action";
69
- type CollabStatus = {
70
- schemaVersion: 1;
71
- repo: {
72
- isGitRepo: boolean;
73
- repoRoot: string | null;
74
- branch: string | null;
75
- branchMismatch: boolean;
76
- headCommitHash: string | null;
77
- worktree: {
78
- isClean: boolean;
79
- entryCount: number;
80
- hasTrackedChanges: boolean;
81
- hasUntrackedFiles: boolean;
82
- preview: string[];
83
- };
84
- };
85
- binding: {
86
- isBound: boolean;
87
- path: string | null;
88
- projectId: string | null;
89
- currentAppId: string | null;
90
- upstreamAppId: string | null;
91
- isRemix: boolean | null;
92
- threadId: string | null;
93
- repoFingerprint: string | null;
94
- remoteUrl: string | null;
95
- defaultBranch: string | null;
96
- laneId: string | null;
97
- branchName: string | null;
98
- bindingMode: "legacy" | "lane" | "explicit_root" | null;
99
- };
100
- remote: {
101
- checked: boolean;
102
- error: string | null;
103
- appStatus: string | null;
104
- incomingOpenMergeRequestCount: number | null;
105
- outgoingOpenMergeRequestCount: number | null;
106
- };
107
- sync: {
108
- checked: boolean;
109
- error: string | null;
110
- canApply: boolean;
111
- status: "not_available" | SyncLocalResponse["status"];
112
- blockedReasons: CollabStatusBlockedReason[];
113
- warnings: string[];
114
- targetCommitHash: string | null;
115
- targetCommitId: string | null;
116
- stats: SyncLocalResponse["stats"] | null;
117
- };
118
- reconcile: {
119
- checked: boolean;
120
- error: string | null;
121
- canApply: boolean;
122
- status: "not_available" | "not_needed" | ReconcilePreflightResponse["status"];
123
- blockedReasons: CollabStatusBlockedReason[];
124
- warnings: string[];
125
- targetHeadCommitHash: string | null;
126
- targetHeadCommitId: string | null;
127
- };
128
- recommendedAction: CollabStatusRecommendedAction;
129
- warnings: string[];
130
- };
131
- type SyncLocalResponse = {
132
- status: "up_to_date" | "ready_to_fast_forward" | "base_unknown" | "conflict_risk";
133
- baseCommitHash: string;
134
- targetCommitHash: string;
135
- targetCommitId: string;
136
- bundleRef: string | null;
137
- bundleBase64: string | null;
138
- bundleEncoding: "base64" | null;
139
- bundleSizeBytes: number;
140
- stats: {
141
- changedFilesCount: number;
142
- insertions: number;
143
- deletions: number;
144
- };
145
- warnings: string[];
146
- };
147
- type SyncUpstreamResponse = {
148
- status: "up-to-date" | "queued";
149
- mergeRequestId?: string;
150
- };
151
- type CollabRecordingPreflightStatus = "not_git_repo" | "not_bound" | "branch_binding_missing" | "family_ambiguous" | "missing_head" | "branch_mismatch" | "metadata_conflict" | "up_to_date" | "ready_to_fast_forward" | "reconcile_required";
152
- type CollabRecordingPreflight = {
153
- status: CollabRecordingPreflightStatus;
154
- repoRoot: string | null;
155
- appId: string | null;
156
- currentBranch: string | null;
157
- branchName: string | null;
158
- headCommitHash: string | null;
159
- worktreeClean: boolean;
160
- syncStatus: SyncLocalResponse["status"] | null;
161
- syncTargetCommitHash: string | null;
162
- syncTargetCommitId: string | null;
163
- reconcileTargetHeadCommitHash: string | null;
164
- reconcileTargetHeadCommitId: string | null;
165
- warnings: string[];
166
- hint: string | null;
167
- };
168
- type ReconcilePreflightResponse = {
169
- status: "up_to_date" | "ready_to_reconcile" | "metadata_conflict";
170
- localHeadCommitHash: string;
171
- targetHeadCommitId: string;
172
- targetHeadCommitHash: string;
173
- warnings: string[];
174
- };
175
- type AppReconcileResponse = {
176
- id: string;
177
- appId: string;
178
- uploadId: string;
179
- queueItemId: string | null;
180
- requestedBy: string;
181
- repoFingerprint: string | null;
182
- remoteUrl: string | null;
183
- defaultBranch: string | null;
184
- localHeadCommitHash: string;
185
- targetHeadCommitId: string | null;
186
- targetHeadCommitHash: string | null;
187
- mergeBaseCommitHash: string | null;
188
- reconciledHeadCommitId: string | null;
189
- reconciledHeadCommitHash: string | null;
190
- localCommitHashes: string[];
191
- reconciledCommitIds: string[];
192
- reconciledCommitHashes: string[];
193
- status: "pending" | "queued" | "processing" | "succeeded" | "failed" | "manual_reconcile_required" | "cancelled";
194
- failureKind: string | null;
195
- statusError: string | null;
196
- idempotencyKey: string | null;
197
- resultBundleRef: string | null;
198
- queuePosition?: number | null;
199
- runId?: string | null;
200
- createdAt: string;
201
- updatedAt: string;
202
- };
203
- type CollabApproveResult = {
204
- mode: CollabApproveMode;
205
- mergeRequestId: string;
206
- terminalStatus: MergeRequestStatus;
207
- targetAppId: string;
208
- mergeRequest: MergeRequest;
209
- repoRoot?: string;
210
- localSync?: {
211
- status: SyncLocalResponse["status"];
212
- branch: string;
213
- repoRoot: string;
214
- baseCommitHash: string;
215
- targetCommitHash: string;
216
- targetCommitId: string;
217
- stats: SyncLocalResponse["stats"];
218
- bundleRef?: string | null;
219
- bundleSizeBytes?: number;
220
- localCommitHash: string;
221
- applied: boolean;
222
- dryRun: boolean;
223
- };
224
- };
225
- type CollabTurn = {
226
- id: string;
227
- appId: string;
228
- threadId: string;
229
- humanMessageId: string;
230
- assistantMessageId: string;
231
- changeStepId: string | null;
232
- actor: {
233
- type: string;
234
- name: string | null;
235
- version: string | null;
236
- provider: string | null;
237
- };
238
- workspaceMetadata: JsonObject | null;
239
- idempotencyKey: string | null;
240
- createdBy: string;
241
- createdAt: string;
242
- updatedAt: string;
243
- prompt: string | null;
244
- assistantResponse: string | null;
245
- };
246
- type CollabFinalizeTurnMode = "changed_turn" | "no_diff_turn";
247
- type CollabFinalizeTurnAutoSync = {
248
- requested: boolean;
249
- eligible: boolean;
250
- attempted: boolean;
251
- applied: boolean;
252
- trackedChangesDiscarded: boolean;
253
- capturedUntrackedPathsCandidate: string[];
254
- localHeadBefore: string | null;
255
- localHeadAfter: string | null;
256
- localRepoMutated: boolean;
257
- };
258
- type CollabFinalizeTurnResult = {
259
- mode: CollabFinalizeTurnMode;
260
- idempotencyKey: string;
261
- changeStep: JsonObject | null;
262
- collabTurn: CollabTurn | null;
263
- autoSync: CollabFinalizeTurnAutoSync | null;
264
- warnings: string[];
265
- };
266
- type InvitationScopeType = "organization" | "project" | "app";
267
- type MembershipScopeType = InvitationScopeType;
268
- type OrganizationMemberRole = "owner" | "admin" | "member" | "viewer";
269
- type ProjectMemberRole = "owner" | "maintainer" | "editor" | "viewer";
270
- type AppMemberRole = "owner" | "maintainer" | "editor" | "viewer";
271
- type OrganizationMember = {
272
- id: string;
273
- userId: string;
274
- organizationId: string;
275
- role: OrganizationMemberRole;
276
- invitedBy: string | null;
277
- createdAt: string;
278
- updatedAt: string;
279
- };
280
- type ProjectMember = {
281
- id: string;
282
- userId: string;
283
- projectId: string;
284
- role: ProjectMemberRole;
285
- invitedBy: string | null;
286
- createdAt: string;
287
- updatedAt: string;
288
- };
289
- type AppMember = {
290
- id: string;
291
- userId: string;
292
- appId: string;
293
- role: AppMemberRole;
294
- invitedBy: string | null;
295
- createdAt: string;
296
- updatedAt: string;
297
- };
298
- type CollabMember = OrganizationMember | ProjectMember | AppMember;
299
- type CollabApiClient = {
300
- resolveProjectBinding(params: {
301
- repoFingerprint?: string;
302
- remoteUrl?: string;
303
- branchName?: string;
304
- }): Promise<unknown>;
305
- resolveProjectLaneBinding(params: {
306
- projectId?: string;
307
- repoFingerprint?: string;
308
- remoteUrl?: string;
309
- defaultBranch?: string;
310
- branchName: string;
311
- }): Promise<unknown>;
312
- ensureProjectLaneBinding(payload: {
313
- projectId?: string;
314
- repoFingerprint?: string;
315
- remoteUrl?: string;
316
- defaultBranch?: string;
317
- branchName: string;
318
- seedAppId?: string;
319
- }): Promise<unknown>;
320
- bootstrapFreshProjectLane(payload: {
321
- projectId?: string;
322
- repoFingerprint?: string;
323
- remoteUrl?: string;
324
- defaultBranch?: string;
325
- branchName: string;
326
- seedAppId: string;
327
- }): Promise<unknown>;
328
- getOrganization(orgId: string): Promise<unknown>;
329
- getProject(projectId: string): Promise<unknown>;
330
- listApps(params?: {
331
- projectId?: string;
332
- organizationId?: string;
333
- ownership?: "mine" | "shared" | "all";
334
- accessScope?: "all_readable" | "explicit_member";
335
- createdBy?: "me" | string;
336
- forked?: "only" | "exclude" | "all";
337
- limit?: number;
338
- offset?: number;
339
- }): Promise<unknown>;
340
- getApp(appId: string): Promise<unknown>;
341
- getMergeRequest(mrId: string): Promise<unknown>;
342
- presignImportUploadFirstParty(payload: {
343
- file: {
344
- name: string;
345
- mimeType: string;
346
- size: number;
347
- checksumSha256?: string;
348
- };
349
- }): Promise<unknown>;
350
- importFromUploadFirstParty(payload: {
351
- uploadId: string;
352
- appName?: string;
353
- threadId?: string;
354
- branch?: string;
355
- path?: string;
356
- platform?: string;
357
- isPublic?: boolean;
358
- remoteUrl?: string;
359
- defaultBranch?: string;
360
- repoFingerprint?: string;
361
- headCommitHash?: string;
362
- }): Promise<unknown>;
363
- forkApp(appId: string, payload?: {
364
- name?: string;
365
- platform?: string;
366
- forkedFromCommitId?: string;
367
- branchName?: string;
368
- }): Promise<unknown>;
369
- downloadAppBundle(appId: string): Promise<{
370
- data: Buffer;
371
- fileName: string | null;
372
- contentType: string | null;
373
- }>;
374
- createChangeStep(appId: string, payload: {
375
- threadId?: string;
376
- collabLaneId?: string;
377
- prompt: string;
378
- assistantResponse?: string;
379
- diff: string;
380
- baseCommitHash?: string | null;
381
- headCommitHash?: string | null;
382
- changedFilesCount?: number;
383
- insertions?: number;
384
- deletions?: number;
385
- actor?: {
386
- type?: string;
387
- name?: string;
388
- version?: string;
389
- provider?: string;
390
- };
391
- workspaceMetadata?: Record<string, unknown>;
392
- idempotencyKey?: string;
393
- }): Promise<unknown>;
394
- startChangeStepReplay(appId: string, payload: {
395
- prompt: string;
396
- assistantResponse?: string;
397
- diff: string;
398
- baseCommitHash: string;
399
- targetHeadCommitHash: string;
400
- expectedPaths: string[];
401
- actor?: {
402
- type?: string;
403
- name?: string;
404
- version?: string;
405
- provider?: string;
406
- };
407
- workspaceMetadata?: Record<string, unknown>;
408
- idempotencyKey?: string;
409
- }): Promise<unknown>;
410
- getChangeStepReplay(appId: string, replayId: string): Promise<unknown>;
411
- getChangeStepReplayDiff(appId: string, replayId: string): Promise<unknown>;
412
- createCollabTurn(appId: string, payload: {
413
- threadId?: string;
414
- collabLaneId?: string;
415
- prompt: string;
416
- assistantResponse: string;
417
- actor?: {
418
- type?: string;
419
- name?: string;
420
- version?: string;
421
- provider?: string;
422
- };
423
- workspaceMetadata?: Record<string, unknown>;
424
- idempotencyKey?: string;
425
- }): Promise<unknown>;
426
- getChangeStep(appId: string, changeStepId: string): Promise<unknown>;
427
- listMergeRequests(params?: {
428
- queue?: MergeRequestQueue;
429
- appId?: string;
430
- sourceAppId?: string;
431
- targetAppId?: string;
432
- status?: string | string[];
433
- kind?: string;
434
- limit?: number;
435
- offset?: number;
436
- }): Promise<unknown>;
437
- listCollabTurns(appId: string, params?: {
438
- limit?: number;
439
- offset?: number;
440
- changeStepId?: string;
441
- threadId?: string;
442
- collabLaneId?: string;
443
- createdAfter?: string;
444
- createdBefore?: string;
445
- }): Promise<unknown>;
446
- openMergeRequest(sourceAppId: string): Promise<unknown>;
447
- getMergeRequestReview(mrId: string): Promise<unknown>;
448
- updateMergeRequest(mrId: string, payload: {
449
- title?: string;
450
- description?: string;
451
- status?: string;
452
- }): Promise<unknown>;
453
- createOrganizationInvite(orgId: string, payload: {
454
- email: string;
455
- role?: string;
456
- ttlDays?: number;
457
- }): Promise<unknown>;
458
- createProjectInvite(projectId: string, payload: {
459
- email: string;
460
- role?: string;
461
- ttlDays?: number;
462
- }): Promise<unknown>;
463
- createAppInvite(appId: string, payload: {
464
- email: string;
465
- role?: string;
466
- ttlDays?: number;
467
- }): Promise<unknown>;
468
- listOrganizationMembers(orgId: string, params?: {
469
- limit?: number;
470
- offset?: number;
471
- }): Promise<unknown>;
472
- updateOrganizationMember(orgId: string, userId: string, payload: {
473
- role: OrganizationMemberRole;
474
- }): Promise<unknown>;
475
- listProjectMembers(projectId: string, params?: {
476
- limit?: number;
477
- offset?: number;
478
- }): Promise<unknown>;
479
- updateProjectMember(projectId: string, userId: string, payload: {
480
- role: ProjectMemberRole;
481
- }): Promise<unknown>;
482
- listAppMembers(appId: string, params?: {
483
- limit?: number;
484
- offset?: number;
485
- }): Promise<unknown>;
486
- updateAppMember(appId: string, userId: string, payload: {
487
- role: AppMemberRole;
488
- }): Promise<unknown>;
489
- listOrganizationInvites(orgId: string, params?: {
490
- limit?: number;
491
- offset?: number;
492
- }): Promise<unknown>;
493
- listProjectInvites(projectId: string, params?: {
494
- limit?: number;
495
- offset?: number;
496
- }): Promise<unknown>;
497
- listAppInvites(appId: string, params?: {
498
- limit?: number;
499
- offset?: number;
500
- }): Promise<unknown>;
501
- resendOrganizationInvite(orgId: string, inviteId: string, payload?: {
502
- ttlDays?: number;
503
- }): Promise<unknown>;
504
- resendProjectInvite(projectId: string, inviteId: string, payload?: {
505
- ttlDays?: number;
506
- }): Promise<unknown>;
507
- resendAppInvite(appId: string, inviteId: string, payload?: {
508
- ttlDays?: number;
509
- }): Promise<unknown>;
510
- revokeOrganizationInvite(orgId: string, inviteId: string): Promise<unknown>;
511
- revokeProjectInvite(projectId: string, inviteId: string): Promise<unknown>;
512
- revokeAppInvite(appId: string, inviteId: string): Promise<unknown>;
513
- syncUpstreamApp(appId: string): Promise<unknown>;
514
- preflightAppReconcile(appId: string, payload: {
515
- localHeadCommitHash: string;
516
- repoFingerprint?: string;
517
- remoteUrl?: string;
518
- defaultBranch?: string;
519
- }): Promise<unknown>;
520
- startAppReconcile(appId: string, payload: {
521
- uploadId: string;
522
- localHeadCommitHash: string;
523
- repoFingerprint?: string;
524
- remoteUrl?: string;
525
- defaultBranch?: string;
526
- idempotencyKey?: string;
527
- }): Promise<unknown>;
528
- getAppReconcile(appId: string, reconcileId: string): Promise<unknown>;
529
- downloadAppReconcileBundle(appId: string, reconcileId: string): Promise<{
530
- data: Buffer;
531
- fileName: string | null;
532
- contentType: string | null;
533
- }>;
534
- syncLocalApp(appId: string, payload: {
535
- baseCommitHash: string;
536
- repoFingerprint?: string;
537
- remoteUrl?: string;
538
- defaultBranch?: string;
539
- dryRun?: boolean;
540
- }): Promise<unknown>;
541
- };
542
-
543
- declare function collabAdd(params: {
544
- api: CollabApiClient;
545
- cwd: string;
546
- prompt: string;
547
- assistantResponse?: string | null;
548
- diff?: string | null;
549
- diffSource?: "worktree" | "external";
550
- sync?: boolean;
551
- allowBranchMismatch?: boolean;
552
- idempotencyKey?: string | null;
553
- actor?: {
554
- type?: string;
555
- name?: string;
556
- version?: string;
557
- provider?: string;
558
- };
559
- }): Promise<JsonObject>;
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';
560
4
 
561
5
  declare function collabFinalizeTurn(params: {
562
6
  api: CollabApiClient;
@@ -574,29 +18,43 @@ declare function collabFinalizeTurn(params: {
574
18
  version?: string;
575
19
  provider?: string;
576
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;
577
46
  }): Promise<CollabFinalizeTurnResult>;
578
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
+
579
52
  declare function collabRecordingPreflight(params: {
580
53
  api: CollabApiClient;
581
54
  cwd: string;
582
55
  allowBranchMismatch?: boolean;
583
56
  }): Promise<CollabRecordingPreflight>;
584
57
 
585
- declare function collabRecordTurn(params: {
586
- api: CollabApiClient;
587
- cwd: string;
588
- prompt: string;
589
- assistantResponse: string;
590
- allowBranchMismatch?: boolean;
591
- idempotencyKey?: string | null;
592
- actor?: {
593
- type?: string;
594
- name?: string;
595
- version?: string;
596
- provider?: string;
597
- };
598
- }): Promise<CollabTurn>;
599
-
600
58
  declare function collabApprove(params: {
601
59
  api: CollabApiClient;
602
60
  mrId: string;
@@ -671,13 +129,91 @@ declare function collabUpdateMemberRole(params: {
671
129
  member: CollabMember;
672
130
  }>;
673
131
 
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
+ };
674
148
  declare function collabInit(params: {
675
149
  api: CollabApiClient;
676
150
  cwd: string;
677
151
  appName?: string | null;
678
152
  path?: string | null;
679
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;
680
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
+ } | {
681
217
  warnings?: string[] | undefined;
682
218
  reused: boolean;
683
219
  projectId: string;
@@ -688,6 +224,7 @@ declare function collabInit(params: {
688
224
  repoRoot: string;
689
225
  bindingMode: string;
690
226
  createdCanonicalFamily: boolean;
227
+ baselineStatus: InitBaselineStatus;
691
228
  } | {
692
229
  warnings?: string[] | undefined;
693
230
  reused: boolean;
@@ -699,6 +236,7 @@ declare function collabInit(params: {
699
236
  repoRoot: string;
700
237
  bindingMode: "lane" | "explicit_root";
701
238
  createdCanonicalFamily: boolean;
239
+ baselineStatus: InitBaselineStatus;
702
240
  remoteUrl: string | null;
703
241
  defaultBranch: string | null;
704
242
  }>;
@@ -733,69 +271,159 @@ declare function collabList(params: {
733
271
  };
734
272
  }>;
735
273
 
736
- declare function collabReconcile(params: {
274
+ declare function collabReAnchor(params: {
737
275
  api: CollabApiClient;
738
276
  cwd: string;
739
- dryRun: boolean;
277
+ dryRun?: boolean;
740
278
  allowBranchMismatch?: boolean;
279
+ asyncSubmit?: boolean;
741
280
  }): Promise<{
742
- status: "ready_to_fast_forward";
743
- branch: string;
281
+ status: string;
744
282
  repoRoot: string;
745
- baseCommitHash: string;
746
- targetCommitHash: string;
747
- targetCommitId: string;
748
- stats: {
749
- changedFilesCount: number;
750
- insertions: number;
751
- deletions: number;
752
- };
753
- bundleRef: string | null;
754
- bundleSizeBytes: number;
755
- localCommitHash: string;
283
+ branch: string;
284
+ currentAppId: string;
285
+ localHeadCommitHash: string;
286
+ targetHeadCommitHash: string;
287
+ targetHeadCommitId: string;
288
+ warnings: string[];
756
289
  applied: boolean;
757
290
  dryRun: boolean;
758
291
  } | {
759
- status: "up_to_date";
292
+ status: "queued";
293
+ queued: true;
294
+ jobId: string;
295
+ repoRoot: string;
760
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;
761
307
  repoRoot: string;
762
- baseCommitHash: string;
763
- targetCommitHash: string;
764
- targetCommitId: string;
765
- stats: {
766
- changedFilesCount: number;
767
- insertions: number;
768
- deletions: number;
769
- };
770
- localCommitHash: 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[];
771
330
  applied: boolean;
772
331
  dryRun: boolean;
773
332
  } | {
774
- status: "ready_to_reconcile";
333
+ status: "queued";
334
+ queued: true;
335
+ jobId: string;
336
+ repoRoot: string;
775
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;
776
348
  repoRoot: string;
349
+ branch: string;
350
+ currentAppId: string;
777
351
  localHeadCommitHash: string;
778
- targetHeadCommitId: string;
779
352
  targetHeadCommitHash: string;
780
353
  warnings: string[];
354
+ dryRun: boolean;
781
355
  applied: boolean;
356
+ }>;
357
+
358
+ declare function collabReconcile(params: {
359
+ api: CollabApiClient;
360
+ cwd: string;
782
361
  dryRun: boolean;
783
- } | {
784
- status: "failed" | "queued" | "pending" | "processing" | "succeeded" | "manual_reconcile_required" | "cancelled";
785
- reconcileId: string;
786
- mergeBaseCommitHash: string | null;
787
- reconciledHeadCommitId: string | null;
788
- reconciledHeadCommitHash: string | null;
789
- backupBranchName: string;
790
- localCommitHash: string;
362
+ allowBranchMismatch?: boolean;
363
+ }): Promise<{
364
+ status: "up_to_date" | "delta_ready" | "base_unknown" | "conflict_risk";
365
+ branch: string;
366
+ repoRoot: string;
367
+ baseCommitHash: string;
368
+ targetCommitHash: string;
369
+ targetCommitId: string | null;
370
+ stats: AppDeltaResponse["stats"];
371
+ localCommitHash: string | null;
791
372
  applied: boolean;
792
373
  dryRun: boolean;
374
+ warnings?: string[];
375
+ } | {
376
+ status: string;
377
+ repoRoot: string;
378
+ branch: string;
379
+ currentAppId: string;
380
+ localHeadCommitHash: string;
381
+ targetHeadCommitHash: string;
382
+ targetHeadCommitId: string;
793
383
  warnings: string[];
384
+ applied: boolean;
385
+ dryRun: boolean;
386
+ } | {
387
+ status: "queued";
388
+ queued: true;
389
+ jobId: string;
390
+ repoRoot: string;
794
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;
795
402
  repoRoot: string;
403
+ branch: string;
404
+ currentAppId: string;
796
405
  localHeadCommitHash: string;
797
- targetHeadCommitId: string;
798
406
  targetHeadCommitHash: string;
407
+ warnings: string[];
408
+ dryRun: boolean;
409
+ applied: boolean;
410
+ } | {
411
+ status: string;
412
+ repoRoot: string;
413
+ branch: string;
414
+ currentAppId: string;
415
+ localHeadCommitHash: string | null;
416
+ baseHeadCommitHash: string;
417
+ targetHeadCommitHash: string;
418
+ targetHeadCommitId: string;
419
+ stats: {
420
+ changedFilesCount: number;
421
+ insertions: number;
422
+ deletions: number;
423
+ };
424
+ warnings: string[];
425
+ applied: boolean;
426
+ dryRun: boolean;
799
427
  }>;
800
428
 
801
429
  declare function collabReject(params: {
@@ -834,37 +462,17 @@ declare function collabSync(params: {
834
462
  dryRun: boolean;
835
463
  allowBranchMismatch?: boolean;
836
464
  }): Promise<{
837
- status: "ready_to_fast_forward";
838
- branch: string;
839
- repoRoot: string;
840
- baseCommitHash: string;
841
- targetCommitHash: string;
842
- targetCommitId: string;
843
- stats: {
844
- changedFilesCount: number;
845
- insertions: number;
846
- deletions: number;
847
- };
848
- bundleRef: string | null;
849
- bundleSizeBytes: number;
850
- localCommitHash: string;
851
- applied: boolean;
852
- dryRun: boolean;
853
- } | {
854
- status: "up_to_date";
465
+ status: "up_to_date" | "delta_ready" | "base_unknown" | "conflict_risk";
855
466
  branch: string;
856
467
  repoRoot: string;
857
468
  baseCommitHash: string;
858
469
  targetCommitHash: string;
859
- targetCommitId: string;
860
- stats: {
861
- changedFilesCount: number;
862
- insertions: number;
863
- deletions: number;
864
- };
865
- localCommitHash: string;
470
+ targetCommitId: string | null;
471
+ stats: AppDeltaResponse["stats"];
472
+ localCommitHash: string | null;
866
473
  applied: boolean;
867
474
  dryRun: boolean;
475
+ warnings?: string[];
868
476
  }>;
869
477
 
870
478
  declare function collabSyncUpstream(params: {
@@ -885,37 +493,15 @@ declare function collabSyncUpstream(params: {
885
493
  upstreamAppId: string;
886
494
  remoteHeadCommitId: string | null;
887
495
  localSync: {
888
- warnings?: string[] | undefined;
889
- status: "ready_to_fast_forward";
890
- branch: string;
891
- repoRoot: string;
892
- baseCommitHash: string;
893
- targetCommitHash: string;
894
- targetCommitId: string;
895
- stats: {
896
- changedFilesCount: number;
897
- insertions: number;
898
- deletions: number;
899
- };
900
- bundleRef: string | null;
901
- bundleSizeBytes: number;
902
- localCommitHash: string;
903
- applied: boolean;
904
- dryRun: boolean;
905
- } | {
906
- warnings?: string[] | undefined;
907
- status: "up_to_date";
496
+ warnings?: string[];
497
+ status: "up_to_date" | "delta_ready" | "base_unknown" | "conflict_risk";
908
498
  branch: string;
909
499
  repoRoot: string;
910
500
  baseCommitHash: string;
911
501
  targetCommitHash: string;
912
- targetCommitId: string;
913
- stats: {
914
- changedFilesCount: number;
915
- insertions: number;
916
- deletions: number;
917
- };
918
- localCommitHash: string;
502
+ targetCommitId: string | null;
503
+ stats: AppDeltaResponse["stats"];
504
+ localCommitHash: string | null;
919
505
  applied: boolean;
920
506
  dryRun: boolean;
921
507
  };
@@ -927,4 +513,188 @@ declare function collabView(params: {
927
513
  mrId: string;
928
514
  }): Promise<MergeRequestReview>;
929
515
 
930
- export { type AppMember, type AppMemberRole, type AppReconcileResponse, type CollabApiClient, type CollabApproveMode, type CollabApproveResult, type CollabFinalizeTurnAutoSync, type CollabFinalizeTurnMode, type CollabFinalizeTurnResult, type CollabMember, type CollabRecordingPreflight, type CollabRecordingPreflightStatus, 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, collabAdd, collabApprove, collabCheckout, collabFinalizeTurn, collabInit, collabInvite, collabList, collabListMembers, collabListMergeRequests, collabReconcile, collabRecordTurn, collabRecordingPreflight, collabReject, collabRemix, collabRequestMerge, collabStatus, collabSync, collabSyncUpstream, collabUpdateMemberRole, collabView, getMemberRolesForScope, validateMemberRole };
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
+
560
+ declare function processPendingFinalizeJob(params: {
561
+ api: CollabApiClient;
562
+ jobId: string;
563
+ }): Promise<CollabFinalizeTurnResult>;
564
+ declare function drainPendingFinalizeQueue(params: {
565
+ api: CollabApiClient;
566
+ }): Promise<CollabFinalizeTurnResult[]>;
567
+
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 };