@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
package/dist/api.d.ts CHANGED
@@ -1,7 +1,76 @@
1
1
  import { CoreConfig } from './config.js';
2
2
  import { T as TokenProvider } from './tokenProvider-BWTusyj4.js';
3
+ import { T as TurnUsage } from './contracts-CHmD-fMj.js';
3
4
  import 'zod';
4
5
 
6
+ type HistoryImportProvider = "claude_code" | "cursor";
7
+ type HistoryImportCaptureSource = "claude_local_v1" | "cursor_local_v1" | "cursor_local_v1_drift";
8
+ type HistoryImportRecordMetadata = {
9
+ importBatchId: string;
10
+ importerVersion: string;
11
+ scannerSchemaFingerprint?: string;
12
+ rawCwd?: string;
13
+ driftDetected?: boolean;
14
+ };
15
+ type HistoryImportWorkspaceMetadata = {
16
+ turnUsage: TurnUsage;
17
+ branch?: string;
18
+ } & Record<string, unknown>;
19
+ type HistoricalTurnRecord = {
20
+ provider: HistoryImportProvider;
21
+ providerSessionId: string | null;
22
+ providerTurnId: string;
23
+ repoFingerprint: string;
24
+ captureSource: HistoryImportCaptureSource;
25
+ occurredAt: string;
26
+ promptText: string | null;
27
+ assistantText?: string | null;
28
+ workspaceMetadata: HistoryImportWorkspaceMetadata;
29
+ metadata: HistoryImportRecordMetadata;
30
+ dedupKey: string;
31
+ };
32
+ type ImportHistoryRequest = {
33
+ records: HistoricalTurnRecord[];
34
+ };
35
+ type ImportHistoryRecordOutcome = {
36
+ ok: true;
37
+ outcome: "inserted";
38
+ historicalRepoTurnId: string;
39
+ } | {
40
+ ok: true;
41
+ outcome: "skipped_duplicate";
42
+ } | {
43
+ ok: false;
44
+ outcome: "validation_failed";
45
+ reason: string;
46
+ } | {
47
+ ok: false;
48
+ outcome: "dedup_key_mismatch";
49
+ expected: string;
50
+ } | {
51
+ ok: false;
52
+ outcome: "insert_failed";
53
+ reason: string;
54
+ };
55
+ type ImportHistoryResponse = {
56
+ importBatchId: string;
57
+ processed: number;
58
+ inserted: number;
59
+ skipped: number;
60
+ failed: number;
61
+ perRepo: Array<{
62
+ repoFingerprint: string;
63
+ inserted: number;
64
+ skipped: number;
65
+ failed: number;
66
+ }>;
67
+ failures: Array<{
68
+ dedupKey: string;
69
+ outcome: Exclude<ImportHistoryRecordOutcome["outcome"], "inserted" | "skipped_duplicate">;
70
+ reason: string;
71
+ }>;
72
+ };
73
+
5
74
  type Json = Record<string, unknown> | unknown[] | string | number | boolean | null;
6
75
  type MergeRequestStatus = "open" | "approved" | "rejected" | "merged" | "closed";
7
76
  type MergeRequest = {
@@ -413,6 +482,7 @@ type ApiClient = {
413
482
  defaultBranch?: string;
414
483
  repoFingerprint?: string;
415
484
  headCommitHash?: string;
485
+ forceNew?: boolean;
416
486
  }): Promise<Json>;
417
487
  importFromGithubFirstParty(payload: {
418
488
  repoFullName: string;
@@ -499,6 +569,10 @@ type ApiClient = {
499
569
  workspaceMetadata?: Record<string, unknown>;
500
570
  idempotencyKey?: string;
501
571
  }): Promise<Json>;
572
+ attachCollabTurnUsage(appId: string, payload: {
573
+ prompt: string;
574
+ workspaceMetadata: Record<string, unknown>;
575
+ }): Promise<Json>;
502
576
  listCollabTurns(appId: string, params?: {
503
577
  limit?: number;
504
578
  offset?: number;
@@ -660,10 +734,11 @@ type ApiClient = {
660
734
  createdBefore?: string;
661
735
  }): Promise<Json>;
662
736
  getSandboxStatus(appId: string): Promise<Json>;
737
+ importHistory(payload: ImportHistoryRequest): Promise<ImportHistoryResponse>;
663
738
  };
664
739
  declare function createApiClient(config: CoreConfig, opts?: {
665
740
  apiKey?: string | null;
666
741
  tokenProvider?: TokenProvider;
667
742
  }): ApiClient;
668
743
 
669
- export { type AgentMemoryItem, type AgentMemoryKind, type AgentMemorySearchItem, type AgentMemorySearchResponse, type AgentMemorySummary, type AgentMemoryTimelineResponse, type ApiClient, type AppContext, type AppContextAccessPath, type AppReconcileResponse, type Bundle, type BundlePlatform, type BundleStatus, type ChangeStepDiffResponse, type InitiateBundleRequest, type InvitationRecord, type MergeRequest, type MergeRequestReview, type MergeRequestStatus, type ReconcilePreflightResponse, type SyncLocalResponse, type SyncUpstreamResponse, createApiClient };
744
+ export { type AgentMemoryItem, type AgentMemoryKind, type AgentMemorySearchItem, type AgentMemorySearchResponse, type AgentMemorySummary, type AgentMemoryTimelineResponse, type ApiClient, type AppContext, type AppContextAccessPath, type AppReconcileResponse, type Bundle, type BundlePlatform, type BundleStatus, type ChangeStepDiffResponse, type HistoricalTurnRecord, type HistoryImportCaptureSource, type HistoryImportProvider, type HistoryImportRecordMetadata, type HistoryImportWorkspaceMetadata, type ImportHistoryRecordOutcome, type ImportHistoryRequest, type ImportHistoryResponse, type InitiateBundleRequest, type InvitationRecord, type MergeRequest, type MergeRequestReview, type MergeRequestStatus, type ReconcilePreflightResponse, type SyncLocalResponse, type SyncUpstreamResponse, createApiClient };
package/dist/api.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createApiClient
3
- } from "./chunk-R7FVSCQW.js";
3
+ } from "./chunk-US5SM7ZC.js";
4
4
  import "./chunk-YZ34ICNN.js";
5
5
  export {
6
6
  createApiClient
package/dist/auth.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  createSupabaseAuthHelpers,
5
5
  shouldRefreshSoon,
6
6
  storedSessionSchema
7
- } from "./chunk-EVWDYCBL.js";
7
+ } from "./chunk-P6JHXOV4.js";
8
8
  import "./chunk-YZ34ICNN.js";
9
9
  export {
10
10
  createLocalSessionStore,
@@ -0,0 +1,43 @@
1
+ type BranchBindingMode = "legacy" | "lane" | "explicit_root";
2
+ type BranchBinding = {
3
+ projectId: string | null;
4
+ currentAppId: string;
5
+ upstreamAppId: string;
6
+ threadId: string | null;
7
+ laneId: string | null;
8
+ bindingMode: BranchBindingMode;
9
+ };
10
+ type CollabBinding = {
11
+ schemaVersion: 3;
12
+ projectId: string | null;
13
+ currentAppId: string;
14
+ upstreamAppId: string;
15
+ threadId: string | null;
16
+ repoFingerprint: string | null;
17
+ remoteUrl: string | null;
18
+ defaultBranch: string | null;
19
+ laneId: string | null;
20
+ branchName: string | null;
21
+ bindingMode: BranchBindingMode;
22
+ };
23
+ declare function getCollabBindingPath(repoRoot: string): string;
24
+ type CollabBindingState = {
25
+ schemaVersion: 1 | 2 | 3;
26
+ projectId: string | null;
27
+ repoFingerprint: string | null;
28
+ remoteUrl: string | null;
29
+ defaultBranch: string | null;
30
+ currentBranch: string | null;
31
+ binding: CollabBinding | null;
32
+ branchBindings: Record<string, BranchBinding>;
33
+ explicitRootBinding: CollabBinding | null;
34
+ };
35
+ declare function readCollabBindingState(repoRoot: string, options?: {
36
+ persist?: boolean;
37
+ }): Promise<CollabBindingState | null>;
38
+ declare function readCollabBinding(repoRoot: string): Promise<CollabBinding | null>;
39
+ declare function writeCollabBinding(repoRoot: string, binding: Omit<CollabBinding, "schemaVersion" | "branchName"> & {
40
+ branchName?: string | null;
41
+ }): Promise<string>;
42
+
43
+ export { type BranchBindingMode as B, type CollabBinding as C, type CollabBindingState as a, readCollabBindingState as b, getCollabBindingPath as g, readCollabBinding as r, writeCollabBinding as w };
package/dist/binding.d.ts CHANGED
@@ -1,21 +1 @@
1
- type BranchBindingMode = "legacy" | "lane" | "explicit_root";
2
- type CollabBinding = {
3
- schemaVersion: 3;
4
- projectId: string | null;
5
- currentAppId: string;
6
- upstreamAppId: string;
7
- threadId: string | null;
8
- repoFingerprint: string | null;
9
- remoteUrl: string | null;
10
- defaultBranch: string | null;
11
- laneId: string | null;
12
- branchName: string | null;
13
- bindingMode: BranchBindingMode;
14
- };
15
- declare function getCollabBindingPath(repoRoot: string): string;
16
- declare function readCollabBinding(repoRoot: string): Promise<CollabBinding | null>;
17
- declare function writeCollabBinding(repoRoot: string, binding: Omit<CollabBinding, "schemaVersion" | "branchName"> & {
18
- branchName?: string | null;
19
- }): Promise<string>;
20
-
21
- export { type CollabBinding, getCollabBindingPath, readCollabBinding, writeCollabBinding };
1
+ export { C as CollabBinding, a as CollabBindingState, g as getCollabBindingPath, r as readCollabBinding, b as readCollabBindingState, w as writeCollabBinding } from './binding-WiIRI2fl.js';
package/dist/binding.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  getCollabBindingPath,
3
3
  readCollabBinding,
4
+ readCollabBindingState,
4
5
  writeCollabBinding
5
6
  } from "./chunk-YCFLOHJV.js";
6
7
  import "./chunk-WT6VRLXU.js";
@@ -9,5 +10,6 @@ import "./chunk-YZ34ICNN.js";
9
10
  export {
10
11
  getCollabBindingPath,
11
12
  readCollabBinding,
13
+ readCollabBindingState,
12
14
  writeCollabBinding
13
15
  };
@@ -65,40 +65,53 @@ function createLocalSessionStore(params) {
65
65
  const service = params?.service?.trim() || "remix-cli";
66
66
  const account = params?.account?.trim() || "default";
67
67
  const filePath = params?.filePath?.trim() || path.join(xdgConfigHome(), "remix", "session.json");
68
+ async function readKeytar() {
69
+ const keytar = await maybeLoadKeytar();
70
+ if (!keytar) return null;
71
+ const raw = await keytar.getPassword(service, account).catch(() => null);
72
+ if (!raw) return null;
73
+ try {
74
+ const parsed = storedSessionSchema.safeParse(JSON.parse(raw));
75
+ return parsed.success ? parsed.data : null;
76
+ } catch {
77
+ return null;
78
+ }
79
+ }
80
+ async function readFile() {
81
+ const raw = await fs.readFile(filePath, "utf8").catch(() => null);
82
+ if (!raw) return null;
83
+ try {
84
+ const parsed = storedSessionSchema.safeParse(JSON.parse(raw));
85
+ if (!parsed.success) return null;
86
+ await ensurePathPermissions(filePath);
87
+ return parsed.data;
88
+ } catch {
89
+ return null;
90
+ }
91
+ }
92
+ function pickFreshest(a, b) {
93
+ if (!a) return b;
94
+ if (!b) return a;
95
+ return a.expires_at >= b.expires_at ? a : b;
96
+ }
68
97
  return {
69
98
  async getSession() {
70
- const keytar = await maybeLoadKeytar();
71
- if (keytar) {
72
- const raw2 = await keytar.getPassword(service, account);
73
- if (!raw2) return null;
74
- try {
75
- const parsed = storedSessionSchema.safeParse(JSON.parse(raw2));
76
- return parsed.success ? parsed.data : null;
77
- } catch {
78
- return null;
79
- }
80
- }
81
- const raw = await fs.readFile(filePath, "utf8").catch(() => null);
82
- if (!raw) return null;
83
- try {
84
- const parsed = storedSessionSchema.safeParse(JSON.parse(raw));
85
- if (!parsed.success) return null;
86
- await ensurePathPermissions(filePath);
87
- return parsed.data;
88
- } catch {
89
- return null;
90
- }
99
+ const [k, f] = await Promise.all([readKeytar(), readFile()]);
100
+ return pickFreshest(k, f);
91
101
  },
92
102
  async setSession(session) {
93
103
  const parsed = storedSessionSchema.safeParse(session);
94
104
  if (!parsed.success) {
95
105
  throw new Error("Session data is invalid and was not stored.");
96
106
  }
107
+ await writeSessionFileFallback(filePath, parsed.data);
97
108
  const keytar = await maybeLoadKeytar();
98
109
  if (keytar) {
99
- await keytar.setPassword(service, account, JSON.stringify(parsed.data));
110
+ try {
111
+ await keytar.setPassword(service, account, JSON.stringify(parsed.data));
112
+ } catch {
113
+ }
100
114
  }
101
- await writeSessionFileFallback(filePath, parsed.data);
102
115
  }
103
116
  };
104
117
  }
@@ -185,6 +185,10 @@ function createApiClient(config, opts) {
185
185
  method: "POST",
186
186
  body: JSON.stringify(payload)
187
187
  }),
188
+ attachCollabTurnUsage: (appId, payload) => request(`/v1/apps/${encodeURIComponent(appId)}/collab-turns/attach-usage`, {
189
+ method: "POST",
190
+ body: JSON.stringify(payload)
191
+ }),
188
192
  listCollabTurns: (appId, params) => {
189
193
  const qs = new URLSearchParams();
190
194
  if (params?.limit !== void 0) qs.set("limit", String(params.limit));
@@ -406,7 +410,21 @@ function createApiClient(config, opts) {
406
410
  method: "GET"
407
411
  });
408
412
  },
409
- getSandboxStatus: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}/sandbox/status`, { method: "GET" })
413
+ getSandboxStatus: (appId) => request(`/v1/apps/${encodeURIComponent(appId)}/sandbox/status`, { method: "GET" }),
414
+ importHistory: async (payload) => {
415
+ const res = await request("/v1/history/import", {
416
+ method: "POST",
417
+ body: JSON.stringify(payload)
418
+ });
419
+ const envelope = res;
420
+ if (!envelope || typeof envelope !== "object" || !envelope.responseObject) {
421
+ throw new RemixError("Malformed importHistory response from server.", {
422
+ exitCode: 1,
423
+ hint: "Expected `{ responseObject: ImportHistoryResponse }`."
424
+ });
425
+ }
426
+ return envelope.responseObject;
427
+ }
410
428
  };
411
429
  }
412
430