codebuff 1.0.121 → 1.0.123
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/cli.d.ts +3 -6
- package/dist/cli.js +16 -18
- package/dist/cli.js.map +1 -1
- package/dist/client.d.ts +2 -2
- package/dist/client.js +1 -1
- package/dist/client.js.map +1 -1
- package/dist/common/actions.d.ts +66 -66
- package/dist/common/constants.d.ts +2 -0
- package/dist/common/constants.js +3 -1
- package/dist/common/constants.js.map +1 -1
- package/dist/common/scripts/update-subscriptions.d.ts +1 -0
- package/dist/common/scripts/update-subscriptions.js +92 -0
- package/dist/common/scripts/update-subscriptions.js.map +1 -0
- package/dist/common/types/usage.d.ts +3 -0
- package/dist/common/types/usage.js +1 -0
- package/dist/common/types/usage.js.map +1 -1
- package/dist/common/util/git.d.ts +2 -0
- package/dist/common/util/git.js +12 -0
- package/dist/common/util/git.js.map +1 -1
- package/dist/common/websockets/websocket-schema.d.ts +116 -116
- package/dist/index.js +10 -7
- package/dist/index.js.map +1 -1
- package/dist/tool-handlers.d.ts +1 -0
- package/dist/tool-handlers.js +32 -1
- package/dist/tool-handlers.js.map +1 -1
- package/dist/types.d.ts +7 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +10 -3
package/dist/common/actions.d.ts
CHANGED
|
@@ -35,16 +35,16 @@ declare const MessageContentObjectSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
35
35
|
}>>;
|
|
36
36
|
}, "strip", z.ZodTypeAny, {
|
|
37
37
|
type: "tool_use";
|
|
38
|
-
id: string;
|
|
39
38
|
name: string;
|
|
39
|
+
id: string;
|
|
40
40
|
input: Record<string, any>;
|
|
41
41
|
cache_control?: {
|
|
42
42
|
type: "ephemeral";
|
|
43
43
|
} | undefined;
|
|
44
44
|
}, {
|
|
45
45
|
type: "tool_use";
|
|
46
|
-
id: string;
|
|
47
46
|
name: string;
|
|
47
|
+
id: string;
|
|
48
48
|
input: Record<string, any>;
|
|
49
49
|
cache_control?: {
|
|
50
50
|
type: "ephemeral";
|
|
@@ -62,15 +62,15 @@ declare const MessageContentObjectSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
62
62
|
}>>;
|
|
63
63
|
}, "strip", z.ZodTypeAny, {
|
|
64
64
|
type: "tool_result";
|
|
65
|
-
tool_use_id: string;
|
|
66
65
|
content: string;
|
|
66
|
+
tool_use_id: string;
|
|
67
67
|
cache_control?: {
|
|
68
68
|
type: "ephemeral";
|
|
69
69
|
} | undefined;
|
|
70
70
|
}, {
|
|
71
71
|
type: "tool_result";
|
|
72
|
-
tool_use_id: string;
|
|
73
72
|
content: string;
|
|
73
|
+
tool_use_id: string;
|
|
74
74
|
cache_control?: {
|
|
75
75
|
type: "ephemeral";
|
|
76
76
|
} | undefined;
|
|
@@ -113,16 +113,16 @@ declare const MessageSchema: z.ZodObject<{
|
|
|
113
113
|
}>>;
|
|
114
114
|
}, "strip", z.ZodTypeAny, {
|
|
115
115
|
type: "tool_use";
|
|
116
|
-
id: string;
|
|
117
116
|
name: string;
|
|
117
|
+
id: string;
|
|
118
118
|
input: Record<string, any>;
|
|
119
119
|
cache_control?: {
|
|
120
120
|
type: "ephemeral";
|
|
121
121
|
} | undefined;
|
|
122
122
|
}, {
|
|
123
123
|
type: "tool_use";
|
|
124
|
-
id: string;
|
|
125
124
|
name: string;
|
|
125
|
+
id: string;
|
|
126
126
|
input: Record<string, any>;
|
|
127
127
|
cache_control?: {
|
|
128
128
|
type: "ephemeral";
|
|
@@ -140,15 +140,15 @@ declare const MessageSchema: z.ZodObject<{
|
|
|
140
140
|
}>>;
|
|
141
141
|
}, "strip", z.ZodTypeAny, {
|
|
142
142
|
type: "tool_result";
|
|
143
|
-
tool_use_id: string;
|
|
144
143
|
content: string;
|
|
144
|
+
tool_use_id: string;
|
|
145
145
|
cache_control?: {
|
|
146
146
|
type: "ephemeral";
|
|
147
147
|
} | undefined;
|
|
148
148
|
}, {
|
|
149
149
|
type: "tool_result";
|
|
150
|
-
tool_use_id: string;
|
|
151
150
|
content: string;
|
|
151
|
+
tool_use_id: string;
|
|
152
152
|
cache_control?: {
|
|
153
153
|
type: "ephemeral";
|
|
154
154
|
} | undefined;
|
|
@@ -162,16 +162,16 @@ declare const MessageSchema: z.ZodObject<{
|
|
|
162
162
|
} | undefined;
|
|
163
163
|
} | {
|
|
164
164
|
type: "tool_use";
|
|
165
|
-
id: string;
|
|
166
165
|
name: string;
|
|
166
|
+
id: string;
|
|
167
167
|
input: Record<string, any>;
|
|
168
168
|
cache_control?: {
|
|
169
169
|
type: "ephemeral";
|
|
170
170
|
} | undefined;
|
|
171
171
|
} | {
|
|
172
172
|
type: "tool_result";
|
|
173
|
-
tool_use_id: string;
|
|
174
173
|
content: string;
|
|
174
|
+
tool_use_id: string;
|
|
175
175
|
cache_control?: {
|
|
176
176
|
type: "ephemeral";
|
|
177
177
|
} | undefined;
|
|
@@ -186,16 +186,16 @@ declare const MessageSchema: z.ZodObject<{
|
|
|
186
186
|
} | undefined;
|
|
187
187
|
} | {
|
|
188
188
|
type: "tool_use";
|
|
189
|
-
id: string;
|
|
190
189
|
name: string;
|
|
190
|
+
id: string;
|
|
191
191
|
input: Record<string, any>;
|
|
192
192
|
cache_control?: {
|
|
193
193
|
type: "ephemeral";
|
|
194
194
|
} | undefined;
|
|
195
195
|
} | {
|
|
196
196
|
type: "tool_result";
|
|
197
|
-
tool_use_id: string;
|
|
198
197
|
content: string;
|
|
198
|
+
tool_use_id: string;
|
|
199
199
|
cache_control?: {
|
|
200
200
|
type: "ephemeral";
|
|
201
201
|
} | undefined;
|
|
@@ -210,12 +210,12 @@ export declare const FileChangeSchema: z.ZodObject<{
|
|
|
210
210
|
content: z.ZodString;
|
|
211
211
|
}, "strip", z.ZodTypeAny, {
|
|
212
212
|
type: "patch" | "file";
|
|
213
|
-
content: string;
|
|
214
213
|
filePath: string;
|
|
214
|
+
content: string;
|
|
215
215
|
}, {
|
|
216
216
|
type: "patch" | "file";
|
|
217
|
-
content: string;
|
|
218
217
|
filePath: string;
|
|
218
|
+
content: string;
|
|
219
219
|
}>;
|
|
220
220
|
export type FileChange = z.infer<typeof FileChangeSchema>;
|
|
221
221
|
export declare const CHANGES: z.ZodArray<z.ZodObject<{
|
|
@@ -224,12 +224,12 @@ export declare const CHANGES: z.ZodArray<z.ZodObject<{
|
|
|
224
224
|
content: z.ZodString;
|
|
225
225
|
}, "strip", z.ZodTypeAny, {
|
|
226
226
|
type: "patch" | "file";
|
|
227
|
-
content: string;
|
|
228
227
|
filePath: string;
|
|
228
|
+
content: string;
|
|
229
229
|
}, {
|
|
230
230
|
type: "patch" | "file";
|
|
231
|
-
content: string;
|
|
232
231
|
filePath: string;
|
|
232
|
+
content: string;
|
|
233
233
|
}>, "many">;
|
|
234
234
|
export type FileChanges = z.infer<typeof CHANGES>;
|
|
235
235
|
export declare const ToolCallSchema: z.ZodObject<{
|
|
@@ -237,12 +237,12 @@ export declare const ToolCallSchema: z.ZodObject<{
|
|
|
237
237
|
id: z.ZodString;
|
|
238
238
|
input: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
239
239
|
}, "strip", z.ZodTypeAny, {
|
|
240
|
-
id: string;
|
|
241
240
|
name: string;
|
|
241
|
+
id: string;
|
|
242
242
|
input: Record<string, any>;
|
|
243
243
|
}, {
|
|
244
|
-
id: string;
|
|
245
244
|
name: string;
|
|
245
|
+
id: string;
|
|
246
246
|
input: Record<string, any>;
|
|
247
247
|
}>;
|
|
248
248
|
export type ToolCall = z.infer<typeof ToolCallSchema>;
|
|
@@ -289,16 +289,16 @@ export declare const CLIENT_ACTION_SCHEMA: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
289
289
|
}>>;
|
|
290
290
|
}, "strip", z.ZodTypeAny, {
|
|
291
291
|
type: "tool_use";
|
|
292
|
-
id: string;
|
|
293
292
|
name: string;
|
|
293
|
+
id: string;
|
|
294
294
|
input: Record<string, any>;
|
|
295
295
|
cache_control?: {
|
|
296
296
|
type: "ephemeral";
|
|
297
297
|
} | undefined;
|
|
298
298
|
}, {
|
|
299
299
|
type: "tool_use";
|
|
300
|
-
id: string;
|
|
301
300
|
name: string;
|
|
301
|
+
id: string;
|
|
302
302
|
input: Record<string, any>;
|
|
303
303
|
cache_control?: {
|
|
304
304
|
type: "ephemeral";
|
|
@@ -316,15 +316,15 @@ export declare const CLIENT_ACTION_SCHEMA: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
316
316
|
}>>;
|
|
317
317
|
}, "strip", z.ZodTypeAny, {
|
|
318
318
|
type: "tool_result";
|
|
319
|
-
tool_use_id: string;
|
|
320
319
|
content: string;
|
|
320
|
+
tool_use_id: string;
|
|
321
321
|
cache_control?: {
|
|
322
322
|
type: "ephemeral";
|
|
323
323
|
} | undefined;
|
|
324
324
|
}, {
|
|
325
325
|
type: "tool_result";
|
|
326
|
-
tool_use_id: string;
|
|
327
326
|
content: string;
|
|
327
|
+
tool_use_id: string;
|
|
328
328
|
cache_control?: {
|
|
329
329
|
type: "ephemeral";
|
|
330
330
|
} | undefined;
|
|
@@ -338,16 +338,16 @@ export declare const CLIENT_ACTION_SCHEMA: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
338
338
|
} | undefined;
|
|
339
339
|
} | {
|
|
340
340
|
type: "tool_use";
|
|
341
|
-
id: string;
|
|
342
341
|
name: string;
|
|
342
|
+
id: string;
|
|
343
343
|
input: Record<string, any>;
|
|
344
344
|
cache_control?: {
|
|
345
345
|
type: "ephemeral";
|
|
346
346
|
} | undefined;
|
|
347
347
|
} | {
|
|
348
348
|
type: "tool_result";
|
|
349
|
-
tool_use_id: string;
|
|
350
349
|
content: string;
|
|
350
|
+
tool_use_id: string;
|
|
351
351
|
cache_control?: {
|
|
352
352
|
type: "ephemeral";
|
|
353
353
|
} | undefined;
|
|
@@ -362,16 +362,16 @@ export declare const CLIENT_ACTION_SCHEMA: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
362
362
|
} | undefined;
|
|
363
363
|
} | {
|
|
364
364
|
type: "tool_use";
|
|
365
|
-
id: string;
|
|
366
365
|
name: string;
|
|
366
|
+
id: string;
|
|
367
367
|
input: Record<string, any>;
|
|
368
368
|
cache_control?: {
|
|
369
369
|
type: "ephemeral";
|
|
370
370
|
} | undefined;
|
|
371
371
|
} | {
|
|
372
372
|
type: "tool_result";
|
|
373
|
-
tool_use_id: string;
|
|
374
373
|
content: string;
|
|
374
|
+
tool_use_id: string;
|
|
375
375
|
cache_control?: {
|
|
376
376
|
type: "ephemeral";
|
|
377
377
|
} | undefined;
|
|
@@ -490,12 +490,12 @@ export declare const CLIENT_ACTION_SCHEMA: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
490
490
|
content: z.ZodString;
|
|
491
491
|
}, "strip", z.ZodTypeAny, {
|
|
492
492
|
type: "patch" | "file";
|
|
493
|
-
content: string;
|
|
494
493
|
filePath: string;
|
|
494
|
+
content: string;
|
|
495
495
|
}, {
|
|
496
496
|
type: "patch" | "file";
|
|
497
|
-
content: string;
|
|
498
497
|
filePath: string;
|
|
498
|
+
content: string;
|
|
499
499
|
}>, "many">;
|
|
500
500
|
costMode: z.ZodDefault<z.ZodOptional<z.ZodEnum<["lite", "normal", "pro"]>>>;
|
|
501
501
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -511,16 +511,16 @@ export declare const CLIENT_ACTION_SCHEMA: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
511
511
|
} | undefined;
|
|
512
512
|
} | {
|
|
513
513
|
type: "tool_use";
|
|
514
|
-
id: string;
|
|
515
514
|
name: string;
|
|
515
|
+
id: string;
|
|
516
516
|
input: Record<string, any>;
|
|
517
517
|
cache_control?: {
|
|
518
518
|
type: "ephemeral";
|
|
519
519
|
} | undefined;
|
|
520
520
|
} | {
|
|
521
521
|
type: "tool_result";
|
|
522
|
-
tool_use_id: string;
|
|
523
522
|
content: string;
|
|
523
|
+
tool_use_id: string;
|
|
524
524
|
cache_control?: {
|
|
525
525
|
type: "ephemeral";
|
|
526
526
|
} | undefined;
|
|
@@ -555,8 +555,8 @@ export declare const CLIENT_ACTION_SCHEMA: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
555
555
|
};
|
|
556
556
|
changesAlreadyApplied: {
|
|
557
557
|
type: "patch" | "file";
|
|
558
|
-
content: string;
|
|
559
558
|
filePath: string;
|
|
559
|
+
content: string;
|
|
560
560
|
}[];
|
|
561
561
|
costMode: "lite" | "normal" | "pro";
|
|
562
562
|
authToken?: string | undefined;
|
|
@@ -573,16 +573,16 @@ export declare const CLIENT_ACTION_SCHEMA: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
573
573
|
} | undefined;
|
|
574
574
|
} | {
|
|
575
575
|
type: "tool_use";
|
|
576
|
-
id: string;
|
|
577
576
|
name: string;
|
|
577
|
+
id: string;
|
|
578
578
|
input: Record<string, any>;
|
|
579
579
|
cache_control?: {
|
|
580
580
|
type: "ephemeral";
|
|
581
581
|
} | undefined;
|
|
582
582
|
} | {
|
|
583
583
|
type: "tool_result";
|
|
584
|
-
tool_use_id: string;
|
|
585
584
|
content: string;
|
|
585
|
+
tool_use_id: string;
|
|
586
586
|
cache_control?: {
|
|
587
587
|
type: "ephemeral";
|
|
588
588
|
} | undefined;
|
|
@@ -617,8 +617,8 @@ export declare const CLIENT_ACTION_SCHEMA: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
617
617
|
};
|
|
618
618
|
changesAlreadyApplied: {
|
|
619
619
|
type: "patch" | "file";
|
|
620
|
-
content: string;
|
|
621
620
|
filePath: string;
|
|
621
|
+
content: string;
|
|
622
622
|
}[];
|
|
623
623
|
authToken?: string | undefined;
|
|
624
624
|
costMode?: "lite" | "normal" | "pro" | undefined;
|
|
@@ -936,12 +936,12 @@ export declare const ResponseCompleteSchema: z.ZodObject<z.objectUtil.extendShap
|
|
|
936
936
|
content: z.ZodString;
|
|
937
937
|
}, "strip", z.ZodTypeAny, {
|
|
938
938
|
type: "patch" | "file";
|
|
939
|
-
content: string;
|
|
940
939
|
filePath: string;
|
|
940
|
+
content: string;
|
|
941
941
|
}, {
|
|
942
942
|
type: "patch" | "file";
|
|
943
|
-
content: string;
|
|
944
943
|
filePath: string;
|
|
944
|
+
content: string;
|
|
945
945
|
}>, "many">;
|
|
946
946
|
changesAlreadyApplied: z.ZodArray<z.ZodObject<{
|
|
947
947
|
type: z.ZodEnum<["patch", "file"]>;
|
|
@@ -949,12 +949,12 @@ export declare const ResponseCompleteSchema: z.ZodObject<z.objectUtil.extendShap
|
|
|
949
949
|
content: z.ZodString;
|
|
950
950
|
}, "strip", z.ZodTypeAny, {
|
|
951
951
|
type: "patch" | "file";
|
|
952
|
-
content: string;
|
|
953
952
|
filePath: string;
|
|
953
|
+
content: string;
|
|
954
954
|
}, {
|
|
955
955
|
type: "patch" | "file";
|
|
956
|
-
content: string;
|
|
957
956
|
filePath: string;
|
|
957
|
+
content: string;
|
|
958
958
|
}>, "many">;
|
|
959
959
|
addedFileVersions: z.ZodArray<z.ZodObject<{
|
|
960
960
|
path: z.ZodString;
|
|
@@ -979,14 +979,14 @@ export declare const ResponseCompleteSchema: z.ZodObject<z.objectUtil.extendShap
|
|
|
979
979
|
userInputId: string;
|
|
980
980
|
changesAlreadyApplied: {
|
|
981
981
|
type: "patch" | "file";
|
|
982
|
-
content: string;
|
|
983
982
|
filePath: string;
|
|
983
|
+
content: string;
|
|
984
984
|
}[];
|
|
985
985
|
response: string;
|
|
986
986
|
changes: {
|
|
987
987
|
type: "patch" | "file";
|
|
988
|
-
content: string;
|
|
989
988
|
filePath: string;
|
|
989
|
+
content: string;
|
|
990
990
|
}[];
|
|
991
991
|
addedFileVersions: {
|
|
992
992
|
path: string;
|
|
@@ -1004,14 +1004,14 @@ export declare const ResponseCompleteSchema: z.ZodObject<z.objectUtil.extendShap
|
|
|
1004
1004
|
userInputId: string;
|
|
1005
1005
|
changesAlreadyApplied: {
|
|
1006
1006
|
type: "patch" | "file";
|
|
1007
|
-
content: string;
|
|
1008
1007
|
filePath: string;
|
|
1008
|
+
content: string;
|
|
1009
1009
|
}[];
|
|
1010
1010
|
response: string;
|
|
1011
1011
|
changes: {
|
|
1012
1012
|
type: "patch" | "file";
|
|
1013
|
-
content: string;
|
|
1014
1013
|
filePath: string;
|
|
1014
|
+
content: string;
|
|
1015
1015
|
}[];
|
|
1016
1016
|
addedFileVersions: {
|
|
1017
1017
|
path: string;
|
|
@@ -1047,12 +1047,12 @@ export declare const SERVER_ACTION_SCHEMA: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
1047
1047
|
content: z.ZodString;
|
|
1048
1048
|
}, "strip", z.ZodTypeAny, {
|
|
1049
1049
|
type: "patch" | "file";
|
|
1050
|
-
content: string;
|
|
1051
1050
|
filePath: string;
|
|
1051
|
+
content: string;
|
|
1052
1052
|
}, {
|
|
1053
1053
|
type: "patch" | "file";
|
|
1054
|
-
content: string;
|
|
1055
1054
|
filePath: string;
|
|
1055
|
+
content: string;
|
|
1056
1056
|
}>, "many">;
|
|
1057
1057
|
changesAlreadyApplied: z.ZodArray<z.ZodObject<{
|
|
1058
1058
|
type: z.ZodEnum<["patch", "file"]>;
|
|
@@ -1060,12 +1060,12 @@ export declare const SERVER_ACTION_SCHEMA: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
1060
1060
|
content: z.ZodString;
|
|
1061
1061
|
}, "strip", z.ZodTypeAny, {
|
|
1062
1062
|
type: "patch" | "file";
|
|
1063
|
-
content: string;
|
|
1064
1063
|
filePath: string;
|
|
1064
|
+
content: string;
|
|
1065
1065
|
}, {
|
|
1066
1066
|
type: "patch" | "file";
|
|
1067
|
-
content: string;
|
|
1068
1067
|
filePath: string;
|
|
1068
|
+
content: string;
|
|
1069
1069
|
}>, "many">;
|
|
1070
1070
|
addedFileVersions: z.ZodArray<z.ZodObject<{
|
|
1071
1071
|
path: z.ZodString;
|
|
@@ -1090,14 +1090,14 @@ export declare const SERVER_ACTION_SCHEMA: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
1090
1090
|
userInputId: string;
|
|
1091
1091
|
changesAlreadyApplied: {
|
|
1092
1092
|
type: "patch" | "file";
|
|
1093
|
-
content: string;
|
|
1094
1093
|
filePath: string;
|
|
1094
|
+
content: string;
|
|
1095
1095
|
}[];
|
|
1096
1096
|
response: string;
|
|
1097
1097
|
changes: {
|
|
1098
1098
|
type: "patch" | "file";
|
|
1099
|
-
content: string;
|
|
1100
1099
|
filePath: string;
|
|
1100
|
+
content: string;
|
|
1101
1101
|
}[];
|
|
1102
1102
|
addedFileVersions: {
|
|
1103
1103
|
path: string;
|
|
@@ -1115,14 +1115,14 @@ export declare const SERVER_ACTION_SCHEMA: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
1115
1115
|
userInputId: string;
|
|
1116
1116
|
changesAlreadyApplied: {
|
|
1117
1117
|
type: "patch" | "file";
|
|
1118
|
-
content: string;
|
|
1119
1118
|
filePath: string;
|
|
1119
|
+
content: string;
|
|
1120
1120
|
}[];
|
|
1121
1121
|
response: string;
|
|
1122
1122
|
changes: {
|
|
1123
1123
|
type: "patch" | "file";
|
|
1124
|
-
content: string;
|
|
1125
1124
|
filePath: string;
|
|
1125
|
+
content: string;
|
|
1126
1126
|
}[];
|
|
1127
1127
|
addedFileVersions: {
|
|
1128
1128
|
path: string;
|
|
@@ -1153,12 +1153,12 @@ export declare const SERVER_ACTION_SCHEMA: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
1153
1153
|
id: z.ZodString;
|
|
1154
1154
|
input: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
1155
1155
|
}, "strip", z.ZodTypeAny, {
|
|
1156
|
-
id: string;
|
|
1157
1156
|
name: string;
|
|
1157
|
+
id: string;
|
|
1158
1158
|
input: Record<string, any>;
|
|
1159
1159
|
}, {
|
|
1160
|
-
id: string;
|
|
1161
1160
|
name: string;
|
|
1161
|
+
id: string;
|
|
1162
1162
|
input: Record<string, any>;
|
|
1163
1163
|
}>;
|
|
1164
1164
|
changes: z.ZodArray<z.ZodObject<{
|
|
@@ -1167,12 +1167,12 @@ export declare const SERVER_ACTION_SCHEMA: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
1167
1167
|
content: z.ZodString;
|
|
1168
1168
|
}, "strip", z.ZodTypeAny, {
|
|
1169
1169
|
type: "patch" | "file";
|
|
1170
|
-
content: string;
|
|
1171
1170
|
filePath: string;
|
|
1171
|
+
content: string;
|
|
1172
1172
|
}, {
|
|
1173
1173
|
type: "patch" | "file";
|
|
1174
|
-
content: string;
|
|
1175
1174
|
filePath: string;
|
|
1175
|
+
content: string;
|
|
1176
1176
|
}>, "many">;
|
|
1177
1177
|
changesAlreadyApplied: z.ZodArray<z.ZodObject<{
|
|
1178
1178
|
type: z.ZodEnum<["patch", "file"]>;
|
|
@@ -1180,12 +1180,12 @@ export declare const SERVER_ACTION_SCHEMA: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
1180
1180
|
content: z.ZodString;
|
|
1181
1181
|
}, "strip", z.ZodTypeAny, {
|
|
1182
1182
|
type: "patch" | "file";
|
|
1183
|
-
content: string;
|
|
1184
1183
|
filePath: string;
|
|
1184
|
+
content: string;
|
|
1185
1185
|
}, {
|
|
1186
1186
|
type: "patch" | "file";
|
|
1187
|
-
content: string;
|
|
1188
1187
|
filePath: string;
|
|
1188
|
+
content: string;
|
|
1189
1189
|
}>, "many">;
|
|
1190
1190
|
addedFileVersions: z.ZodArray<z.ZodObject<{
|
|
1191
1191
|
path: z.ZodString;
|
|
@@ -1203,14 +1203,14 @@ export declare const SERVER_ACTION_SCHEMA: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
1203
1203
|
userInputId: string;
|
|
1204
1204
|
changesAlreadyApplied: {
|
|
1205
1205
|
type: "patch" | "file";
|
|
1206
|
-
content: string;
|
|
1207
1206
|
filePath: string;
|
|
1207
|
+
content: string;
|
|
1208
1208
|
}[];
|
|
1209
1209
|
response: string;
|
|
1210
1210
|
changes: {
|
|
1211
1211
|
type: "patch" | "file";
|
|
1212
|
-
content: string;
|
|
1213
1212
|
filePath: string;
|
|
1213
|
+
content: string;
|
|
1214
1214
|
}[];
|
|
1215
1215
|
addedFileVersions: {
|
|
1216
1216
|
path: string;
|
|
@@ -1218,8 +1218,8 @@ export declare const SERVER_ACTION_SCHEMA: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
1218
1218
|
}[];
|
|
1219
1219
|
resetFileVersions: boolean;
|
|
1220
1220
|
data: {
|
|
1221
|
-
id: string;
|
|
1222
1221
|
name: string;
|
|
1222
|
+
id: string;
|
|
1223
1223
|
input: Record<string, any>;
|
|
1224
1224
|
};
|
|
1225
1225
|
}, {
|
|
@@ -1227,14 +1227,14 @@ export declare const SERVER_ACTION_SCHEMA: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
1227
1227
|
userInputId: string;
|
|
1228
1228
|
changesAlreadyApplied: {
|
|
1229
1229
|
type: "patch" | "file";
|
|
1230
|
-
content: string;
|
|
1231
1230
|
filePath: string;
|
|
1231
|
+
content: string;
|
|
1232
1232
|
}[];
|
|
1233
1233
|
response: string;
|
|
1234
1234
|
changes: {
|
|
1235
1235
|
type: "patch" | "file";
|
|
1236
|
-
content: string;
|
|
1237
1236
|
filePath: string;
|
|
1237
|
+
content: string;
|
|
1238
1238
|
}[];
|
|
1239
1239
|
addedFileVersions: {
|
|
1240
1240
|
path: string;
|
|
@@ -1242,8 +1242,8 @@ export declare const SERVER_ACTION_SCHEMA: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
1242
1242
|
}[];
|
|
1243
1243
|
resetFileVersions: boolean;
|
|
1244
1244
|
data: {
|
|
1245
|
-
id: string;
|
|
1246
1245
|
name: string;
|
|
1246
|
+
id: string;
|
|
1247
1247
|
input: Record<string, any>;
|
|
1248
1248
|
};
|
|
1249
1249
|
}>, z.ZodObject<{
|
|
@@ -1306,15 +1306,15 @@ export declare const SERVER_ACTION_SCHEMA: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
1306
1306
|
fingerprintId: z.ZodString;
|
|
1307
1307
|
fingerprintHash: z.ZodString;
|
|
1308
1308
|
}, "strip", z.ZodTypeAny, {
|
|
1309
|
-
id: string;
|
|
1310
1309
|
name: string | null;
|
|
1310
|
+
id: string;
|
|
1311
1311
|
fingerprintId: string;
|
|
1312
1312
|
authToken: string;
|
|
1313
1313
|
email: string;
|
|
1314
1314
|
fingerprintHash: string;
|
|
1315
1315
|
}, {
|
|
1316
|
-
id: string;
|
|
1317
1316
|
name: string | null;
|
|
1317
|
+
id: string;
|
|
1318
1318
|
fingerprintId: string;
|
|
1319
1319
|
authToken: string;
|
|
1320
1320
|
email: string;
|
|
@@ -1325,8 +1325,8 @@ export declare const SERVER_ACTION_SCHEMA: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
1325
1325
|
type: "auth-result";
|
|
1326
1326
|
message: string;
|
|
1327
1327
|
user?: {
|
|
1328
|
-
id: string;
|
|
1329
1328
|
name: string | null;
|
|
1329
|
+
id: string;
|
|
1330
1330
|
fingerprintId: string;
|
|
1331
1331
|
authToken: string;
|
|
1332
1332
|
email: string;
|
|
@@ -1336,8 +1336,8 @@ export declare const SERVER_ACTION_SCHEMA: z.ZodDiscriminatedUnion<"type", [z.Zo
|
|
|
1336
1336
|
type: "auth-result";
|
|
1337
1337
|
message: string;
|
|
1338
1338
|
user?: {
|
|
1339
|
-
id: string;
|
|
1340
1339
|
name: string | null;
|
|
1340
|
+
id: string;
|
|
1341
1341
|
fingerprintId: string;
|
|
1342
1342
|
authToken: string;
|
|
1343
1343
|
email: string;
|
|
@@ -30,4 +30,6 @@ export declare const models: {
|
|
|
30
30
|
sonnet: "claude-3-5-sonnet-20241022";
|
|
31
31
|
haiku: "claude-3-5-haiku-20241022";
|
|
32
32
|
};
|
|
33
|
+
export declare const OVERAGE_RATE_PRO = 0.99;
|
|
34
|
+
export declare const OVERAGE_RATE_PRO_PLUS = 0.9;
|
|
33
35
|
export declare const TEST_USER_ID = "test-user-id";
|
package/dist/common/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// import { env } from './env.mjs'
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.TEST_USER_ID = exports.models = exports.geminiModels = exports.openaiModels = exports.claudeModels = exports.getModelForMode = exports.costModes = exports.CREDITS_REFERRAL_BONUS = exports.CREDITS_USAGE_LIMITS = exports.MAX_DATE = exports.REQUEST_CREDIT_SHOW_THRESHOLD = exports.SKIPPED_TERMINAL_COMMANDS = exports.DEFAULT_IGNORED_FILES = exports.EXISTING_CODE_MARKER = exports.TOOL_RESULT_MARKER = exports.FIND_FILES_MARKER = exports.STOP_MARKER = void 0;
|
|
4
|
+
exports.TEST_USER_ID = exports.OVERAGE_RATE_PRO_PLUS = exports.OVERAGE_RATE_PRO = exports.models = exports.geminiModels = exports.openaiModels = exports.claudeModels = exports.getModelForMode = exports.costModes = exports.CREDITS_REFERRAL_BONUS = exports.CREDITS_USAGE_LIMITS = exports.MAX_DATE = exports.REQUEST_CREDIT_SHOW_THRESHOLD = exports.SKIPPED_TERMINAL_COMMANDS = exports.DEFAULT_IGNORED_FILES = exports.EXISTING_CODE_MARKER = exports.TOOL_RESULT_MARKER = exports.FIND_FILES_MARKER = exports.STOP_MARKER = void 0;
|
|
5
5
|
exports.STOP_MARKER = '[' + 'END]';
|
|
6
6
|
exports.FIND_FILES_MARKER = '[' + 'FIND_FILES_PLEASE]';
|
|
7
7
|
exports.TOOL_RESULT_MARKER = '[' + 'TOOL_RESULT]';
|
|
@@ -114,5 +114,7 @@ exports.models = {
|
|
|
114
114
|
...exports.openaiModels,
|
|
115
115
|
...exports.geminiModels,
|
|
116
116
|
};
|
|
117
|
+
exports.OVERAGE_RATE_PRO = 0.99;
|
|
118
|
+
exports.OVERAGE_RATE_PRO_PLUS = 0.90;
|
|
117
119
|
exports.TEST_USER_ID = 'test-user-id';
|
|
118
120
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const drizzle_orm_1 = require("drizzle-orm");
|
|
30
|
+
const stripe_1 = require("../util/stripe");
|
|
31
|
+
const db_1 = __importDefault(require("../db"));
|
|
32
|
+
const schema = __importStar(require("../db/schema"));
|
|
33
|
+
async function main() {
|
|
34
|
+
const email = process.argv[2];
|
|
35
|
+
if (!email) {
|
|
36
|
+
console.error('Please provide an email address');
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
console.log(`Processing user ${email}...`);
|
|
40
|
+
// Find user and verify subscription
|
|
41
|
+
const user = await db_1.default.query.user.findFirst({
|
|
42
|
+
where: (0, drizzle_orm_1.eq)(schema.user.email, email),
|
|
43
|
+
});
|
|
44
|
+
if (!user?.stripe_customer_id) {
|
|
45
|
+
console.error('User not found or has no Stripe customer ID');
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
console.log('Found user:', user.id);
|
|
49
|
+
// Get subscriptions for customer
|
|
50
|
+
const subscriptions = await stripe_1.stripeServer.subscriptions.list({
|
|
51
|
+
customer: user.stripe_customer_id,
|
|
52
|
+
status: 'active',
|
|
53
|
+
});
|
|
54
|
+
if (subscriptions.data.length === 0) {
|
|
55
|
+
console.error('No active subscription found');
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
const subscription = subscriptions.data[0];
|
|
59
|
+
console.log('Found subscription:', subscription.id);
|
|
60
|
+
// Update subscription items
|
|
61
|
+
console.log('Updating subscription items...');
|
|
62
|
+
await stripe_1.stripeServer.subscriptions.update(subscription.id, {
|
|
63
|
+
items: [
|
|
64
|
+
{ price: 'price_1QLxwxKrNS6SjmqWeKhJIlAD', quantity: 1 },
|
|
65
|
+
{ price: 'price_1QMlqaKrNS6SjmqWQEeaTcqk' },
|
|
66
|
+
],
|
|
67
|
+
});
|
|
68
|
+
// Calculate usage since Oct 30, 2024
|
|
69
|
+
const startDate = new Date('2024-10-30');
|
|
70
|
+
const creditsUsed = await db_1.default
|
|
71
|
+
.select({
|
|
72
|
+
total: (0, drizzle_orm_1.sql) `SUM(${schema.message.credits})`,
|
|
73
|
+
})
|
|
74
|
+
.from(schema.message)
|
|
75
|
+
.where((0, drizzle_orm_1.and)((0, drizzle_orm_1.eq)(schema.message.user_id, user.id), (0, drizzle_orm_1.gte)(schema.message.finished_at, startDate)))
|
|
76
|
+
.then((result) => parseInt(result[0]?.total ?? '0'));
|
|
77
|
+
console.log('Credits used since Oct 30, 2024:', creditsUsed);
|
|
78
|
+
// Report usage
|
|
79
|
+
const timestamp = Math.floor(startDate.getTime() / 1000);
|
|
80
|
+
await stripe_1.stripeServer.subscriptionItems.createUsageRecord(subscription.items.data[1].id, // Get the metered price item
|
|
81
|
+
{
|
|
82
|
+
quantity: creditsUsed,
|
|
83
|
+
timestamp,
|
|
84
|
+
action: 'set',
|
|
85
|
+
});
|
|
86
|
+
console.log('Successfully updated subscription and usage');
|
|
87
|
+
}
|
|
88
|
+
main().catch((error) => {
|
|
89
|
+
console.error('Error:', error);
|
|
90
|
+
process.exit(1);
|
|
91
|
+
});
|
|
92
|
+
//# sourceMappingURL=update-subscriptions.js.map
|