anycodex 0.0.7 → 0.0.9

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.
@@ -0,0 +1,2765 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire } from 'module';
3
+ const require = createRequire(import.meta.url);
4
+ import {
5
+ Glob
6
+ } from "./chunk-5WPHGERF.js";
7
+ import {
8
+ Schema_exports,
9
+ withStatics,
10
+ zod_default
11
+ } from "./chunk-HGHQOBPB.js";
12
+ import {
13
+ __callDispose,
14
+ __using
15
+ } from "./chunk-CPXZVSHE.js";
16
+
17
+ // ../../node_modules/.pnpm/drizzle-orm@1.0.0-beta.16-ea816b6_@opentelemetry+api@1.9.0_@types+better-sqlite3@7.6.13_0f21266a0de314c39cfb891f27e2ae25/node_modules/drizzle-orm/column-common.js
18
+ var OriginalColumn = /* @__PURE__ */ Symbol.for("drizzle:OriginalColumn");
19
+
20
+ // ../../node_modules/.pnpm/drizzle-orm@1.0.0-beta.16-ea816b6_@opentelemetry+api@1.9.0_@types+better-sqlite3@7.6.13_0f21266a0de314c39cfb891f27e2ae25/node_modules/drizzle-orm/entity.js
21
+ var entityKind = /* @__PURE__ */ Symbol.for("drizzle:entityKind");
22
+ function is(value, type) {
23
+ if (!value || typeof value !== "object") return false;
24
+ if (value instanceof type) return true;
25
+ if (!Object.prototype.hasOwnProperty.call(type, entityKind)) throw new Error(`Class "${type.name ?? "<unknown>"}" doesn't look like a Drizzle entity. If this is incorrect and the class is provided by Drizzle, please report this as a bug.`);
26
+ let cls = Object.getPrototypeOf(value).constructor;
27
+ if (cls) while (cls) {
28
+ if (entityKind in cls && cls[entityKind] === type[entityKind]) return true;
29
+ cls = Object.getPrototypeOf(cls);
30
+ }
31
+ return false;
32
+ }
33
+
34
+ // ../../node_modules/.pnpm/drizzle-orm@1.0.0-beta.16-ea816b6_@opentelemetry+api@1.9.0_@types+better-sqlite3@7.6.13_0f21266a0de314c39cfb891f27e2ae25/node_modules/drizzle-orm/column.js
35
+ var Column = class {
36
+ static [entityKind] = "Column";
37
+ name;
38
+ keyAsName;
39
+ primary;
40
+ notNull;
41
+ default;
42
+ defaultFn;
43
+ onUpdateFn;
44
+ hasDefault;
45
+ isUnique;
46
+ uniqueName;
47
+ uniqueType;
48
+ dataType;
49
+ columnType;
50
+ enumValues = void 0;
51
+ generated = void 0;
52
+ generatedIdentity = void 0;
53
+ length;
54
+ isLengthExact;
55
+ isAlias;
56
+ /** @internal */
57
+ config;
58
+ /** @internal */
59
+ table;
60
+ /** @internal */
61
+ onInit() {
62
+ }
63
+ constructor(table, config) {
64
+ this.config = config;
65
+ this.onInit();
66
+ this.table = table;
67
+ this.name = config.name;
68
+ this.isAlias = false;
69
+ this.keyAsName = config.keyAsName;
70
+ this.notNull = config.notNull;
71
+ this.default = config.default;
72
+ this.defaultFn = config.defaultFn;
73
+ this.onUpdateFn = config.onUpdateFn;
74
+ this.hasDefault = config.hasDefault;
75
+ this.primary = config.primaryKey;
76
+ this.isUnique = config.isUnique;
77
+ this.uniqueName = config.uniqueName;
78
+ this.uniqueType = config.uniqueType;
79
+ this.dataType = config.dataType;
80
+ this.columnType = config.columnType;
81
+ this.generated = config.generated;
82
+ this.generatedIdentity = config.generatedIdentity;
83
+ this.length = config["length"];
84
+ this.isLengthExact = config["isLengthExact"];
85
+ }
86
+ mapFromDriverValue(value) {
87
+ return value;
88
+ }
89
+ mapToDriverValue(value) {
90
+ return value;
91
+ }
92
+ shouldDisableInsert() {
93
+ return this.config.generated !== void 0 && this.config.generated.type !== "byDefault";
94
+ }
95
+ /** @internal */
96
+ [OriginalColumn]() {
97
+ return this;
98
+ }
99
+ };
100
+
101
+ // ../../node_modules/.pnpm/drizzle-orm@1.0.0-beta.16-ea816b6_@opentelemetry+api@1.9.0_@types+better-sqlite3@7.6.13_0f21266a0de314c39cfb891f27e2ae25/node_modules/drizzle-orm/table.utils.js
102
+ var TableName = /* @__PURE__ */ Symbol.for("drizzle:Name");
103
+
104
+ // ../../node_modules/.pnpm/drizzle-orm@1.0.0-beta.16-ea816b6_@opentelemetry+api@1.9.0_@types+better-sqlite3@7.6.13_0f21266a0de314c39cfb891f27e2ae25/node_modules/drizzle-orm/table.js
105
+ var TableSchema = /* @__PURE__ */ Symbol.for("drizzle:Schema");
106
+ var TableColumns = /* @__PURE__ */ Symbol.for("drizzle:Columns");
107
+ var ExtraConfigColumns = /* @__PURE__ */ Symbol.for("drizzle:ExtraConfigColumns");
108
+ var OriginalName = /* @__PURE__ */ Symbol.for("drizzle:OriginalName");
109
+ var BaseName = /* @__PURE__ */ Symbol.for("drizzle:BaseName");
110
+ var IsAlias = /* @__PURE__ */ Symbol.for("drizzle:IsAlias");
111
+ var ExtraConfigBuilder = /* @__PURE__ */ Symbol.for("drizzle:ExtraConfigBuilder");
112
+ var IsDrizzleTable = /* @__PURE__ */ Symbol.for("drizzle:IsDrizzleTable");
113
+ var Table = class {
114
+ static [entityKind] = "Table";
115
+ /** @internal */
116
+ static Symbol = {
117
+ Name: TableName,
118
+ Schema: TableSchema,
119
+ OriginalName,
120
+ Columns: TableColumns,
121
+ ExtraConfigColumns,
122
+ BaseName,
123
+ IsAlias,
124
+ ExtraConfigBuilder
125
+ };
126
+ /**
127
+ * @internal
128
+ * Can be changed if the table is aliased.
129
+ */
130
+ [TableName];
131
+ /**
132
+ * @internal
133
+ * Used to store the original name of the table, before any aliasing.
134
+ */
135
+ [OriginalName];
136
+ /** @internal */
137
+ [TableSchema];
138
+ /** @internal */
139
+ [TableColumns];
140
+ /** @internal */
141
+ [ExtraConfigColumns];
142
+ /**
143
+ * @internal
144
+ * Used to store the table name before the transformation via the `tableCreator` functions.
145
+ */
146
+ [BaseName];
147
+ /** @internal */
148
+ [IsAlias] = false;
149
+ /** @internal */
150
+ [IsDrizzleTable] = true;
151
+ /** @internal */
152
+ [ExtraConfigBuilder] = void 0;
153
+ constructor(name, schema, baseName) {
154
+ this[TableName] = this[OriginalName] = name;
155
+ this[TableSchema] = schema;
156
+ this[BaseName] = baseName;
157
+ }
158
+ };
159
+
160
+ // ../../node_modules/.pnpm/drizzle-orm@1.0.0-beta.16-ea816b6_@opentelemetry+api@1.9.0_@types+better-sqlite3@7.6.13_0f21266a0de314c39cfb891f27e2ae25/node_modules/drizzle-orm/subquery.js
161
+ var Subquery = class {
162
+ static [entityKind] = "Subquery";
163
+ constructor(sql2, fields, alias, isWith = false, usedTables = []) {
164
+ this._ = {
165
+ brand: "Subquery",
166
+ sql: sql2,
167
+ selectedFields: fields,
168
+ alias,
169
+ isWith,
170
+ usedTables
171
+ };
172
+ }
173
+ };
174
+ var WithSubquery = class extends Subquery {
175
+ static [entityKind] = "WithSubquery";
176
+ };
177
+
178
+ // ../../node_modules/.pnpm/drizzle-orm@1.0.0-beta.16-ea816b6_@opentelemetry+api@1.9.0_@types+better-sqlite3@7.6.13_0f21266a0de314c39cfb891f27e2ae25/node_modules/drizzle-orm/tracing.js
179
+ var tracer = { startActiveSpan(name, fn) {
180
+ return fn();
181
+ } };
182
+
183
+ // ../../node_modules/.pnpm/drizzle-orm@1.0.0-beta.16-ea816b6_@opentelemetry+api@1.9.0_@types+better-sqlite3@7.6.13_0f21266a0de314c39cfb891f27e2ae25/node_modules/drizzle-orm/view-common.js
184
+ var ViewBaseConfig = /* @__PURE__ */ Symbol.for("drizzle:ViewBaseConfig");
185
+
186
+ // ../../node_modules/.pnpm/drizzle-orm@1.0.0-beta.16-ea816b6_@opentelemetry+api@1.9.0_@types+better-sqlite3@7.6.13_0f21266a0de314c39cfb891f27e2ae25/node_modules/drizzle-orm/sql/sql.js
187
+ var FakePrimitiveParam = class {
188
+ static [entityKind] = "FakePrimitiveParam";
189
+ };
190
+ function isSQLWrapper(value) {
191
+ return value !== null && value !== void 0 && typeof value.getSQL === "function";
192
+ }
193
+ function mergeQueries(queries) {
194
+ const result = {
195
+ sql: "",
196
+ params: []
197
+ };
198
+ for (const query of queries) {
199
+ result.sql += query.sql;
200
+ result.params.push(...query.params);
201
+ if (query.typings?.length) {
202
+ if (!result.typings) result.typings = [];
203
+ result.typings.push(...query.typings);
204
+ }
205
+ }
206
+ return result;
207
+ }
208
+ var StringChunk = class {
209
+ static [entityKind] = "StringChunk";
210
+ value;
211
+ constructor(value) {
212
+ this.value = Array.isArray(value) ? value : [value];
213
+ }
214
+ getSQL() {
215
+ return new SQL([this]);
216
+ }
217
+ };
218
+ var SQL = class SQL2 {
219
+ static [entityKind] = "SQL";
220
+ /** @internal */
221
+ decoder = noopDecoder;
222
+ /** @internal */
223
+ shouldInlineParams = false;
224
+ /** @internal */
225
+ usedTables = [];
226
+ constructor(queryChunks) {
227
+ this.queryChunks = queryChunks;
228
+ for (const chunk of queryChunks) if (is(chunk, Table)) {
229
+ const schemaName = chunk[Table.Symbol.Schema];
230
+ this.usedTables.push(schemaName === void 0 ? chunk[Table.Symbol.Name] : schemaName + "." + chunk[Table.Symbol.Name]);
231
+ }
232
+ }
233
+ append(query) {
234
+ this.queryChunks.push(...query.queryChunks);
235
+ return this;
236
+ }
237
+ toQuery(config) {
238
+ return tracer.startActiveSpan("drizzle.buildSQL", (span) => {
239
+ const query = this.buildQueryFromSourceParams(this.queryChunks, config);
240
+ span?.setAttributes({
241
+ "drizzle.query.text": query.sql,
242
+ "drizzle.query.params": JSON.stringify(query.params)
243
+ });
244
+ return query;
245
+ });
246
+ }
247
+ buildQueryFromSourceParams(chunks, _config) {
248
+ const config = Object.assign({}, _config, {
249
+ inlineParams: _config.inlineParams || this.shouldInlineParams,
250
+ paramStartIndex: _config.paramStartIndex || { value: 0 }
251
+ });
252
+ const { casing, escapeName, escapeParam, prepareTyping, inlineParams, paramStartIndex, invokeSource } = config;
253
+ return mergeQueries(chunks.map((chunk) => {
254
+ if (is(chunk, StringChunk)) return {
255
+ sql: chunk.value.join(""),
256
+ params: []
257
+ };
258
+ if (is(chunk, Name)) return {
259
+ sql: escapeName(chunk.value),
260
+ params: []
261
+ };
262
+ if (chunk === void 0) return {
263
+ sql: "",
264
+ params: []
265
+ };
266
+ if (Array.isArray(chunk)) {
267
+ const result = [new StringChunk("(")];
268
+ for (const [i, p] of chunk.entries()) {
269
+ result.push(p);
270
+ if (i < chunk.length - 1) result.push(new StringChunk(", "));
271
+ }
272
+ result.push(new StringChunk(")"));
273
+ return this.buildQueryFromSourceParams(result, config);
274
+ }
275
+ if (is(chunk, SQL2)) return this.buildQueryFromSourceParams(chunk.queryChunks, {
276
+ ...config,
277
+ inlineParams: inlineParams || chunk.shouldInlineParams
278
+ });
279
+ if (is(chunk, Table)) {
280
+ const schemaName = chunk[Table.Symbol.Schema];
281
+ const tableName = chunk[Table.Symbol.Name];
282
+ if (invokeSource === "mssql-view-with-schemabinding") return {
283
+ sql: (schemaName === void 0 ? escapeName("dbo") : escapeName(schemaName)) + "." + escapeName(tableName),
284
+ params: []
285
+ };
286
+ return {
287
+ sql: schemaName === void 0 || chunk[IsAlias] ? escapeName(tableName) : escapeName(schemaName) + "." + escapeName(tableName),
288
+ params: []
289
+ };
290
+ }
291
+ if (is(chunk, Column)) {
292
+ const columnName = casing.getColumnCasing(chunk);
293
+ if (_config.invokeSource === "indexes") return {
294
+ sql: escapeName(columnName),
295
+ params: []
296
+ };
297
+ const schemaName = invokeSource === "mssql-check" ? void 0 : chunk.table[Table.Symbol.Schema];
298
+ return {
299
+ sql: chunk.isAlias ? escapeName(chunk.name) : chunk.table[IsAlias] || schemaName === void 0 ? escapeName(chunk.table[Table.Symbol.Name]) + "." + escapeName(columnName) : escapeName(schemaName) + "." + escapeName(chunk.table[Table.Symbol.Name]) + "." + escapeName(columnName),
300
+ params: []
301
+ };
302
+ }
303
+ if (is(chunk, View)) {
304
+ const schemaName = chunk[ViewBaseConfig].schema;
305
+ const viewName = chunk[ViewBaseConfig].name;
306
+ return {
307
+ sql: schemaName === void 0 || chunk[ViewBaseConfig].isAlias ? escapeName(viewName) : escapeName(schemaName) + "." + escapeName(viewName),
308
+ params: []
309
+ };
310
+ }
311
+ if (is(chunk, Param)) {
312
+ if (is(chunk.value, Placeholder)) return {
313
+ sql: escapeParam(paramStartIndex.value++, chunk),
314
+ params: [chunk],
315
+ typings: ["none"]
316
+ };
317
+ const mappedValue = chunk.value === null ? null : chunk.encoder.mapToDriverValue(chunk.value);
318
+ if (is(mappedValue, SQL2)) return this.buildQueryFromSourceParams([mappedValue], config);
319
+ if (inlineParams) return {
320
+ sql: this.mapInlineParam(mappedValue, config),
321
+ params: []
322
+ };
323
+ let typings = ["none"];
324
+ if (prepareTyping) typings = [prepareTyping(chunk.encoder)];
325
+ return {
326
+ sql: escapeParam(paramStartIndex.value++, mappedValue),
327
+ params: [mappedValue],
328
+ typings
329
+ };
330
+ }
331
+ if (is(chunk, Placeholder)) return {
332
+ sql: escapeParam(paramStartIndex.value++, chunk),
333
+ params: [chunk],
334
+ typings: ["none"]
335
+ };
336
+ if (is(chunk, SQL2.Aliased) && chunk.fieldAlias !== void 0) return {
337
+ sql: (chunk.origin !== void 0 ? escapeName(chunk.origin) + "." : "") + escapeName(chunk.fieldAlias),
338
+ params: []
339
+ };
340
+ if (is(chunk, Subquery)) {
341
+ if (chunk._.isWith) return {
342
+ sql: escapeName(chunk._.alias),
343
+ params: []
344
+ };
345
+ return this.buildQueryFromSourceParams([
346
+ new StringChunk("("),
347
+ chunk._.sql,
348
+ new StringChunk(") "),
349
+ new Name(chunk._.alias)
350
+ ], config);
351
+ }
352
+ if (typeof chunk === "function" && "enumName" in chunk) {
353
+ if ("schema" in chunk && chunk.schema) return {
354
+ sql: escapeName(chunk.schema) + "." + escapeName(chunk.enumName),
355
+ params: []
356
+ };
357
+ return {
358
+ sql: escapeName(chunk.enumName),
359
+ params: []
360
+ };
361
+ }
362
+ if (isSQLWrapper(chunk)) {
363
+ if (chunk.shouldOmitSQLParens?.()) return this.buildQueryFromSourceParams([chunk.getSQL()], config);
364
+ return this.buildQueryFromSourceParams([
365
+ new StringChunk("("),
366
+ chunk.getSQL(),
367
+ new StringChunk(")")
368
+ ], config);
369
+ }
370
+ if (inlineParams) return {
371
+ sql: this.mapInlineParam(chunk, config),
372
+ params: []
373
+ };
374
+ return {
375
+ sql: escapeParam(paramStartIndex.value++, chunk),
376
+ params: [chunk],
377
+ typings: ["none"]
378
+ };
379
+ }));
380
+ }
381
+ mapInlineParam(chunk, { escapeString }) {
382
+ if (chunk === null) return "null";
383
+ if (typeof chunk === "number" || typeof chunk === "boolean" || typeof chunk === "bigint") return chunk.toString();
384
+ if (typeof chunk === "string") return escapeString(chunk);
385
+ if (typeof chunk === "object") {
386
+ const mappedValueAsString = chunk.toString();
387
+ if (mappedValueAsString === "[object Object]") return escapeString(JSON.stringify(chunk));
388
+ return escapeString(mappedValueAsString);
389
+ }
390
+ throw new Error("Unexpected param value: " + chunk);
391
+ }
392
+ getSQL() {
393
+ return this;
394
+ }
395
+ as(alias) {
396
+ if (alias === void 0) return this;
397
+ return new SQL2.Aliased(this, alias);
398
+ }
399
+ mapWith(decoder) {
400
+ this.decoder = typeof decoder === "function" ? { mapFromDriverValue: decoder } : decoder;
401
+ return this;
402
+ }
403
+ inlineParams() {
404
+ this.shouldInlineParams = true;
405
+ return this;
406
+ }
407
+ /**
408
+ * This method is used to conditionally include a part of the query.
409
+ *
410
+ * @param condition - Condition to check
411
+ * @returns itself if the condition is `true`, otherwise `undefined`
412
+ */
413
+ if(condition) {
414
+ return condition ? this : void 0;
415
+ }
416
+ };
417
+ var Name = class {
418
+ static [entityKind] = "Name";
419
+ brand;
420
+ constructor(value) {
421
+ this.value = value;
422
+ }
423
+ getSQL() {
424
+ return new SQL([this]);
425
+ }
426
+ };
427
+ var noopDecoder = { mapFromDriverValue: (value) => value };
428
+ var noopEncoder = { mapToDriverValue: (value) => value };
429
+ var noopMapper = {
430
+ ...noopDecoder,
431
+ ...noopEncoder
432
+ };
433
+ var Param = class {
434
+ static [entityKind] = "Param";
435
+ brand;
436
+ /**
437
+ * @param value - Parameter value
438
+ * @param encoder - Encoder to convert the value to a driver parameter
439
+ */
440
+ constructor(value, encoder = noopEncoder) {
441
+ this.value = value;
442
+ this.encoder = encoder;
443
+ }
444
+ getSQL() {
445
+ return new SQL([this]);
446
+ }
447
+ };
448
+ function sql(strings, ...params) {
449
+ const queryChunks = [];
450
+ if (params.length > 0 || strings.length > 0 && strings[0] !== "") queryChunks.push(new StringChunk(strings[0]));
451
+ for (const [paramIndex, param$1] of params.entries()) queryChunks.push(param$1, new StringChunk(strings[paramIndex + 1]));
452
+ return new SQL(queryChunks);
453
+ }
454
+ (function(_sql) {
455
+ function empty() {
456
+ return new SQL([]);
457
+ }
458
+ _sql.empty = empty;
459
+ function fromList(list) {
460
+ return new SQL(list);
461
+ }
462
+ _sql.fromList = fromList;
463
+ function raw(str) {
464
+ return new SQL([new StringChunk(str)]);
465
+ }
466
+ _sql.raw = raw;
467
+ function join2(chunks, separator) {
468
+ const result = [];
469
+ for (const [i, chunk] of chunks.entries()) {
470
+ if (i > 0 && separator !== void 0) result.push(separator);
471
+ result.push(chunk);
472
+ }
473
+ return new SQL(result);
474
+ }
475
+ _sql.join = join2;
476
+ function identifier(value) {
477
+ return new Name(value);
478
+ }
479
+ _sql.identifier = identifier;
480
+ function placeholder$1(name$1) {
481
+ return new Placeholder(name$1);
482
+ }
483
+ _sql.placeholder = placeholder$1;
484
+ function param$1(value, encoder) {
485
+ return new Param(value, encoder);
486
+ }
487
+ _sql.param = param$1;
488
+ })(sql || (sql = {}));
489
+ (function(_SQL) {
490
+ class Aliased {
491
+ static [entityKind] = "SQL.Aliased";
492
+ /** @internal */
493
+ isSelectionField = false;
494
+ /** @internal */
495
+ origin;
496
+ constructor(sql$1, fieldAlias) {
497
+ this.sql = sql$1;
498
+ this.fieldAlias = fieldAlias;
499
+ }
500
+ getSQL() {
501
+ return this.sql;
502
+ }
503
+ /** @internal */
504
+ clone() {
505
+ return new Aliased(this.sql, this.fieldAlias);
506
+ }
507
+ }
508
+ _SQL.Aliased = Aliased;
509
+ })(SQL || (SQL = {}));
510
+ var Placeholder = class {
511
+ static [entityKind] = "Placeholder";
512
+ constructor(name$1) {
513
+ this.name = name$1;
514
+ }
515
+ getSQL() {
516
+ return new SQL([this]);
517
+ }
518
+ };
519
+ var IsDrizzleView = /* @__PURE__ */ Symbol.for("drizzle:IsDrizzleView");
520
+ var View = class {
521
+ static [entityKind] = "View";
522
+ /** @internal */
523
+ [ViewBaseConfig];
524
+ /** @internal */
525
+ [IsDrizzleView] = true;
526
+ /** @internal */
527
+ get [TableName]() {
528
+ return this[ViewBaseConfig].name;
529
+ }
530
+ /** @internal */
531
+ get [TableSchema]() {
532
+ return this[ViewBaseConfig].schema;
533
+ }
534
+ /** @internal */
535
+ get [IsAlias]() {
536
+ return this[ViewBaseConfig].isAlias;
537
+ }
538
+ /** @internal */
539
+ get [OriginalName]() {
540
+ return this[ViewBaseConfig].originalName;
541
+ }
542
+ /** @internal */
543
+ get [TableColumns]() {
544
+ return this[ViewBaseConfig].selectedFields;
545
+ }
546
+ constructor({ name: name$1, schema, selectedFields, query }) {
547
+ this[ViewBaseConfig] = {
548
+ name: name$1,
549
+ originalName: name$1,
550
+ schema,
551
+ selectedFields,
552
+ query,
553
+ isExisting: !query,
554
+ isAlias: false
555
+ };
556
+ }
557
+ };
558
+ Column.prototype.getSQL = function() {
559
+ return new SQL([this]);
560
+ };
561
+ Subquery.prototype.getSQL = function() {
562
+ return new SQL([this]);
563
+ };
564
+
565
+ // ../../node_modules/.pnpm/drizzle-orm@1.0.0-beta.16-ea816b6_@opentelemetry+api@1.9.0_@types+better-sqlite3@7.6.13_0f21266a0de314c39cfb891f27e2ae25/node_modules/drizzle-orm/column-builder.js
566
+ var ColumnBuilder = class {
567
+ static [entityKind] = "ColumnBuilder";
568
+ /** @internal */
569
+ config;
570
+ constructor(name, dataType, columnType) {
571
+ this.config = {
572
+ name,
573
+ keyAsName: name === "",
574
+ notNull: false,
575
+ default: void 0,
576
+ hasDefault: false,
577
+ primaryKey: false,
578
+ isUnique: false,
579
+ uniqueName: void 0,
580
+ uniqueType: void 0,
581
+ dataType,
582
+ columnType,
583
+ generated: void 0
584
+ };
585
+ }
586
+ /**
587
+ * Changes the data type of the column. Commonly used with `json` columns. Also, useful for branded types.
588
+ *
589
+ * @example
590
+ * ```ts
591
+ * const users = pgTable('users', {
592
+ * id: integer('id').$type<UserId>().primaryKey(),
593
+ * details: json('details').$type<UserDetails>().notNull(),
594
+ * });
595
+ * ```
596
+ */
597
+ $type() {
598
+ return this;
599
+ }
600
+ /**
601
+ * Adds a `not null` clause to the column definition.
602
+ *
603
+ * Affects the `select` model of the table - columns *without* `not null` will be nullable on select.
604
+ */
605
+ notNull() {
606
+ this.config.notNull = true;
607
+ return this;
608
+ }
609
+ /**
610
+ * Adds a `default <value>` clause to the column definition.
611
+ *
612
+ * Affects the `insert` model of the table - columns *with* `default` are optional on insert.
613
+ *
614
+ * If you need to set a dynamic default value, use {@link $defaultFn} instead.
615
+ */
616
+ default(value) {
617
+ this.config.default = value;
618
+ this.config.hasDefault = true;
619
+ return this;
620
+ }
621
+ /**
622
+ * Adds a dynamic default value to the column.
623
+ * The function will be called when the row is inserted, and the returned value will be used as the column value.
624
+ *
625
+ * **Note:** This value does not affect the `drizzle-kit` behavior, it is only used at runtime in `drizzle-orm`.
626
+ */
627
+ $defaultFn(fn) {
628
+ this.config.defaultFn = fn;
629
+ this.config.hasDefault = true;
630
+ return this;
631
+ }
632
+ /**
633
+ * Alias for {@link $defaultFn}.
634
+ */
635
+ $default = this.$defaultFn;
636
+ /**
637
+ * Adds a dynamic update value to the column.
638
+ * The function will be called when the row is updated, and the returned value will be used as the column value if none is provided.
639
+ * If no `default` (or `$defaultFn`) value is provided, the function will be called when the row is inserted as well, and the returned value will be used as the column value.
640
+ *
641
+ * **Note:** This value does not affect the `drizzle-kit` behavior, it is only used at runtime in `drizzle-orm`.
642
+ */
643
+ $onUpdateFn(fn) {
644
+ this.config.onUpdateFn = fn;
645
+ this.config.hasDefault = true;
646
+ return this;
647
+ }
648
+ /**
649
+ * Alias for {@link $onUpdateFn}.
650
+ */
651
+ $onUpdate = this.$onUpdateFn;
652
+ /**
653
+ * Adds a `primary key` clause to the column definition. This implicitly makes the column `not null`.
654
+ *
655
+ * In SQLite, `integer primary key` implicitly makes the column auto-incrementing.
656
+ */
657
+ primaryKey() {
658
+ this.config.primaryKey = true;
659
+ this.config.notNull = true;
660
+ return this;
661
+ }
662
+ /** @internal Sets the name of the column to the key within the table definition if a name was not given. */
663
+ setName(name) {
664
+ if (this.config.name !== "") return;
665
+ this.config.name = name;
666
+ }
667
+ };
668
+
669
+ // ../../node_modules/.pnpm/drizzle-orm@1.0.0-beta.16-ea816b6_@opentelemetry+api@1.9.0_@types+better-sqlite3@7.6.13_0f21266a0de314c39cfb891f27e2ae25/node_modules/drizzle-orm/sqlite-core/foreign-keys.js
670
+ var ForeignKeyBuilder = class {
671
+ static [entityKind] = "SQLiteForeignKeyBuilder";
672
+ /** @internal */
673
+ reference;
674
+ /** @internal */
675
+ _onUpdate;
676
+ /** @internal */
677
+ _onDelete;
678
+ constructor(config, actions) {
679
+ this.reference = () => {
680
+ const { name, columns, foreignColumns } = config();
681
+ return {
682
+ name,
683
+ columns,
684
+ foreignTable: foreignColumns[0].table,
685
+ foreignColumns
686
+ };
687
+ };
688
+ if (actions) {
689
+ this._onUpdate = actions.onUpdate;
690
+ this._onDelete = actions.onDelete;
691
+ }
692
+ }
693
+ onUpdate(action) {
694
+ this._onUpdate = action;
695
+ return this;
696
+ }
697
+ onDelete(action) {
698
+ this._onDelete = action;
699
+ return this;
700
+ }
701
+ /** @internal */
702
+ build(table) {
703
+ return new ForeignKey(table, this);
704
+ }
705
+ };
706
+ var ForeignKey = class {
707
+ static [entityKind] = "SQLiteForeignKey";
708
+ reference;
709
+ onUpdate;
710
+ onDelete;
711
+ constructor(table, builder) {
712
+ this.table = table;
713
+ this.reference = builder.reference;
714
+ this.onUpdate = builder._onUpdate;
715
+ this.onDelete = builder._onDelete;
716
+ }
717
+ getName() {
718
+ const { name, columns, foreignColumns } = this.reference();
719
+ const columnNames = columns.map((column) => column.name);
720
+ const foreignColumnNames = foreignColumns.map((column) => column.name);
721
+ const chunks = [
722
+ this.table[TableName],
723
+ ...columnNames,
724
+ foreignColumns[0].table[TableName],
725
+ ...foreignColumnNames
726
+ ];
727
+ return name ?? `${chunks.join("_")}_fk`;
728
+ }
729
+ isNameExplicit() {
730
+ return !!this.reference().name;
731
+ }
732
+ };
733
+
734
+ // ../../node_modules/.pnpm/drizzle-orm@1.0.0-beta.16-ea816b6_@opentelemetry+api@1.9.0_@types+better-sqlite3@7.6.13_0f21266a0de314c39cfb891f27e2ae25/node_modules/drizzle-orm/sqlite-core/columns/common.js
735
+ var SQLiteColumnBuilder = class extends ColumnBuilder {
736
+ static [entityKind] = "SQLiteColumnBuilder";
737
+ foreignKeyConfigs = [];
738
+ references(ref, actions = {}) {
739
+ this.foreignKeyConfigs.push({
740
+ ref,
741
+ actions
742
+ });
743
+ return this;
744
+ }
745
+ unique(name) {
746
+ this.config.isUnique = true;
747
+ this.config.uniqueName = name;
748
+ return this;
749
+ }
750
+ generatedAlwaysAs(as, config) {
751
+ this.config.generated = {
752
+ as,
753
+ type: "always",
754
+ mode: config?.mode ?? "virtual"
755
+ };
756
+ return this;
757
+ }
758
+ /** @internal */
759
+ buildForeignKeys(column, table) {
760
+ return this.foreignKeyConfigs.map(({ ref, actions }) => {
761
+ return ((ref$1, actions$1) => {
762
+ const builder = new ForeignKeyBuilder(() => {
763
+ const foreignColumn = ref$1();
764
+ return {
765
+ columns: [column],
766
+ foreignColumns: [foreignColumn]
767
+ };
768
+ });
769
+ if (actions$1.onUpdate) builder.onUpdate(actions$1.onUpdate);
770
+ if (actions$1.onDelete) builder.onDelete(actions$1.onDelete);
771
+ return builder.build(table);
772
+ })(ref, actions);
773
+ });
774
+ }
775
+ };
776
+ var SQLiteColumn = class extends Column {
777
+ static [entityKind] = "SQLiteColumn";
778
+ /** @internal */
779
+ table;
780
+ constructor(table, config) {
781
+ super(table, config);
782
+ this.table = table;
783
+ }
784
+ };
785
+
786
+ // ../../node_modules/.pnpm/drizzle-orm@1.0.0-beta.16-ea816b6_@opentelemetry+api@1.9.0_@types+better-sqlite3@7.6.13_0f21266a0de314c39cfb891f27e2ae25/node_modules/drizzle-orm/utils.js
787
+ function getColumnNameAndConfig(a, b) {
788
+ return {
789
+ name: typeof a === "string" && a.length > 0 ? a : "",
790
+ config: typeof a === "object" ? a : b
791
+ };
792
+ }
793
+ var textDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder();
794
+
795
+ // ../../node_modules/.pnpm/drizzle-orm@1.0.0-beta.16-ea816b6_@opentelemetry+api@1.9.0_@types+better-sqlite3@7.6.13_0f21266a0de314c39cfb891f27e2ae25/node_modules/drizzle-orm/sqlite-core/columns/blob.js
796
+ function hexToText(hexString) {
797
+ let result = "";
798
+ for (let i = 0; i < hexString.length; i += 2) {
799
+ const hexPair = hexString.slice(i, i + 2);
800
+ const decimalValue = Number.parseInt(hexPair, 16);
801
+ result += String.fromCodePoint(decimalValue);
802
+ }
803
+ return result;
804
+ }
805
+ var SQLiteBigIntBuilder = class extends SQLiteColumnBuilder {
806
+ static [entityKind] = "SQLiteBigIntBuilder";
807
+ constructor(name) {
808
+ super(name, "bigint int64", "SQLiteBigInt");
809
+ }
810
+ /** @internal */
811
+ build(table) {
812
+ return new SQLiteBigInt(table, this.config);
813
+ }
814
+ };
815
+ var SQLiteBigInt = class extends SQLiteColumn {
816
+ static [entityKind] = "SQLiteBigInt";
817
+ getSQLType() {
818
+ return "blob";
819
+ }
820
+ mapFromDriverValue(value) {
821
+ if (typeof value === "string") return BigInt(hexToText(value));
822
+ if (typeof Buffer !== "undefined" && Buffer.from) {
823
+ const buf = Buffer.isBuffer(value) ? value : value instanceof ArrayBuffer ? Buffer.from(value) : value.buffer ? Buffer.from(value.buffer, value.byteOffset, value.byteLength) : Buffer.from(value);
824
+ return BigInt(buf.toString("utf8"));
825
+ }
826
+ return BigInt(textDecoder.decode(value));
827
+ }
828
+ mapToDriverValue(value) {
829
+ return Buffer.from(value.toString());
830
+ }
831
+ };
832
+ var SQLiteBlobJsonBuilder = class extends SQLiteColumnBuilder {
833
+ static [entityKind] = "SQLiteBlobJsonBuilder";
834
+ constructor(name) {
835
+ super(name, "object json", "SQLiteBlobJson");
836
+ }
837
+ /** @internal */
838
+ build(table) {
839
+ return new SQLiteBlobJson(table, this.config);
840
+ }
841
+ };
842
+ var SQLiteBlobJson = class extends SQLiteColumn {
843
+ static [entityKind] = "SQLiteBlobJson";
844
+ getSQLType() {
845
+ return "blob";
846
+ }
847
+ mapFromDriverValue(value) {
848
+ if (typeof value === "string") return JSON.parse(hexToText(value));
849
+ if (typeof Buffer !== "undefined" && Buffer.from) {
850
+ const buf = Buffer.isBuffer(value) ? value : value instanceof ArrayBuffer ? Buffer.from(value) : value.buffer ? Buffer.from(value.buffer, value.byteOffset, value.byteLength) : Buffer.from(value);
851
+ return JSON.parse(buf.toString("utf8"));
852
+ }
853
+ return JSON.parse(textDecoder.decode(value));
854
+ }
855
+ mapToDriverValue(value) {
856
+ return Buffer.from(JSON.stringify(value));
857
+ }
858
+ };
859
+ var SQLiteBlobBufferBuilder = class extends SQLiteColumnBuilder {
860
+ static [entityKind] = "SQLiteBlobBufferBuilder";
861
+ constructor(name) {
862
+ super(name, "object buffer", "SQLiteBlobBuffer");
863
+ }
864
+ /** @internal */
865
+ build(table) {
866
+ return new SQLiteBlobBuffer(table, this.config);
867
+ }
868
+ };
869
+ var SQLiteBlobBuffer = class extends SQLiteColumn {
870
+ static [entityKind] = "SQLiteBlobBuffer";
871
+ mapFromDriverValue(value) {
872
+ if (Buffer.isBuffer(value)) return value;
873
+ if (typeof value === "string") return Buffer.from(value, "hex");
874
+ return Buffer.from(value);
875
+ }
876
+ getSQLType() {
877
+ return "blob";
878
+ }
879
+ };
880
+ function blob(a, b) {
881
+ const { name, config } = getColumnNameAndConfig(a, b);
882
+ if (config?.mode === "json") return new SQLiteBlobJsonBuilder(name);
883
+ if (config?.mode === "bigint") return new SQLiteBigIntBuilder(name);
884
+ return new SQLiteBlobBufferBuilder(name);
885
+ }
886
+
887
+ // ../../node_modules/.pnpm/drizzle-orm@1.0.0-beta.16-ea816b6_@opentelemetry+api@1.9.0_@types+better-sqlite3@7.6.13_0f21266a0de314c39cfb891f27e2ae25/node_modules/drizzle-orm/sqlite-core/columns/custom.js
888
+ var SQLiteCustomColumnBuilder = class extends SQLiteColumnBuilder {
889
+ static [entityKind] = "SQLiteCustomColumnBuilder";
890
+ constructor(name, fieldConfig, customTypeParams) {
891
+ super(name, "custom", "SQLiteCustomColumn");
892
+ this.config.fieldConfig = fieldConfig;
893
+ this.config.customTypeParams = customTypeParams;
894
+ }
895
+ /** @internal */
896
+ build(table) {
897
+ return new SQLiteCustomColumn(table, this.config);
898
+ }
899
+ };
900
+ var SQLiteCustomColumn = class extends SQLiteColumn {
901
+ static [entityKind] = "SQLiteCustomColumn";
902
+ sqlName;
903
+ mapTo;
904
+ mapFrom;
905
+ mapJson;
906
+ forJsonSelect;
907
+ constructor(table, config) {
908
+ super(table, config);
909
+ this.sqlName = config.customTypeParams.dataType(config.fieldConfig);
910
+ this.mapTo = config.customTypeParams.toDriver;
911
+ this.mapFrom = config.customTypeParams.fromDriver;
912
+ this.mapJson = config.customTypeParams.fromJson;
913
+ this.forJsonSelect = config.customTypeParams.forJsonSelect;
914
+ }
915
+ getSQLType() {
916
+ return this.sqlName;
917
+ }
918
+ mapFromDriverValue(value) {
919
+ return typeof this.mapFrom === "function" ? this.mapFrom(value) : value;
920
+ }
921
+ mapFromJsonValue(value) {
922
+ return typeof this.mapJson === "function" ? this.mapJson(value) : this.mapFromDriverValue(value);
923
+ }
924
+ jsonSelectIdentifier(identifier, sql2) {
925
+ if (typeof this.forJsonSelect === "function") return this.forJsonSelect(identifier, sql2);
926
+ const rawType = this.getSQLType().toLowerCase();
927
+ const parenPos = rawType.indexOf("(");
928
+ switch (parenPos + 1 ? rawType.slice(0, parenPos) : rawType) {
929
+ case "numeric":
930
+ case "decimal":
931
+ case "bigint":
932
+ return sql2`cast(${identifier} as text)`;
933
+ case "blob":
934
+ return sql2`hex(${identifier})`;
935
+ default:
936
+ return identifier;
937
+ }
938
+ }
939
+ mapToDriverValue(value) {
940
+ return typeof this.mapTo === "function" ? this.mapTo(value) : value;
941
+ }
942
+ };
943
+ function customType(customTypeParams) {
944
+ return (a, b) => {
945
+ const { name, config } = getColumnNameAndConfig(a, b);
946
+ return new SQLiteCustomColumnBuilder(name, config, customTypeParams);
947
+ };
948
+ }
949
+
950
+ // ../../node_modules/.pnpm/drizzle-orm@1.0.0-beta.16-ea816b6_@opentelemetry+api@1.9.0_@types+better-sqlite3@7.6.13_0f21266a0de314c39cfb891f27e2ae25/node_modules/drizzle-orm/sqlite-core/columns/integer.js
951
+ var SQLiteBaseIntegerBuilder = class extends SQLiteColumnBuilder {
952
+ static [entityKind] = "SQLiteBaseIntegerBuilder";
953
+ constructor(name, dataType, columnType) {
954
+ super(name, dataType, columnType);
955
+ this.config.autoIncrement = false;
956
+ }
957
+ primaryKey(config) {
958
+ if (config?.autoIncrement) this.config.autoIncrement = true;
959
+ this.config.hasDefault = true;
960
+ return super.primaryKey();
961
+ }
962
+ };
963
+ var SQLiteBaseInteger = class extends SQLiteColumn {
964
+ static [entityKind] = "SQLiteBaseInteger";
965
+ autoIncrement = this.config.autoIncrement;
966
+ getSQLType() {
967
+ return "integer";
968
+ }
969
+ };
970
+ var SQLiteIntegerBuilder = class extends SQLiteBaseIntegerBuilder {
971
+ static [entityKind] = "SQLiteIntegerBuilder";
972
+ constructor(name) {
973
+ super(name, "number int53", "SQLiteInteger");
974
+ }
975
+ build(table) {
976
+ return new SQLiteInteger(table, this.config);
977
+ }
978
+ };
979
+ var SQLiteInteger = class extends SQLiteBaseInteger {
980
+ static [entityKind] = "SQLiteInteger";
981
+ };
982
+ var SQLiteTimestampBuilder = class extends SQLiteBaseIntegerBuilder {
983
+ static [entityKind] = "SQLiteTimestampBuilder";
984
+ constructor(name, mode) {
985
+ super(name, "object date", "SQLiteTimestamp");
986
+ this.config.mode = mode;
987
+ }
988
+ /**
989
+ * @deprecated Use `default()` with your own expression instead.
990
+ *
991
+ * Adds `DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer))` to the column, which is the current epoch timestamp in milliseconds.
992
+ */
993
+ defaultNow() {
994
+ return this.default(sql`(cast((julianday('now') - 2440587.5)*86400000 as integer))`);
995
+ }
996
+ build(table) {
997
+ return new SQLiteTimestamp(table, this.config);
998
+ }
999
+ };
1000
+ var SQLiteTimestamp = class extends SQLiteBaseInteger {
1001
+ static [entityKind] = "SQLiteTimestamp";
1002
+ mode = this.config.mode;
1003
+ mapFromDriverValue(value) {
1004
+ if (typeof value === "string") return new Date(value.replaceAll('"', ""));
1005
+ if (this.config.mode === "timestamp") return /* @__PURE__ */ new Date(value * 1e3);
1006
+ return new Date(value);
1007
+ }
1008
+ mapToDriverValue(value) {
1009
+ if (typeof value === "number") return value;
1010
+ const unix = value.getTime();
1011
+ if (this.config.mode === "timestamp") return Math.floor(unix / 1e3);
1012
+ return unix;
1013
+ }
1014
+ };
1015
+ var SQLiteBooleanBuilder = class extends SQLiteBaseIntegerBuilder {
1016
+ static [entityKind] = "SQLiteBooleanBuilder";
1017
+ constructor(name, mode) {
1018
+ super(name, "boolean", "SQLiteBoolean");
1019
+ this.config.mode = mode;
1020
+ }
1021
+ build(table) {
1022
+ return new SQLiteBoolean(table, this.config);
1023
+ }
1024
+ };
1025
+ var SQLiteBoolean = class extends SQLiteBaseInteger {
1026
+ static [entityKind] = "SQLiteBoolean";
1027
+ mode = this.config.mode;
1028
+ mapFromDriverValue(value) {
1029
+ return Number(value) === 1;
1030
+ }
1031
+ mapToDriverValue(value) {
1032
+ return value ? 1 : 0;
1033
+ }
1034
+ };
1035
+ function integer(a, b) {
1036
+ const { name, config } = getColumnNameAndConfig(a, b);
1037
+ if (config?.mode === "timestamp" || config?.mode === "timestamp_ms") return new SQLiteTimestampBuilder(name, config.mode);
1038
+ if (config?.mode === "boolean") return new SQLiteBooleanBuilder(name, config.mode);
1039
+ return new SQLiteIntegerBuilder(name);
1040
+ }
1041
+
1042
+ // ../../node_modules/.pnpm/drizzle-orm@1.0.0-beta.16-ea816b6_@opentelemetry+api@1.9.0_@types+better-sqlite3@7.6.13_0f21266a0de314c39cfb891f27e2ae25/node_modules/drizzle-orm/sqlite-core/columns/numeric.js
1043
+ var SQLiteNumericBuilder = class extends SQLiteColumnBuilder {
1044
+ static [entityKind] = "SQLiteNumericBuilder";
1045
+ constructor(name) {
1046
+ super(name, "string numeric", "SQLiteNumeric");
1047
+ }
1048
+ /** @internal */
1049
+ build(table) {
1050
+ return new SQLiteNumeric(table, this.config);
1051
+ }
1052
+ };
1053
+ var SQLiteNumeric = class extends SQLiteColumn {
1054
+ static [entityKind] = "SQLiteNumeric";
1055
+ mapFromDriverValue(value) {
1056
+ if (typeof value === "string") return value;
1057
+ return String(value);
1058
+ }
1059
+ getSQLType() {
1060
+ return "numeric";
1061
+ }
1062
+ };
1063
+ var SQLiteNumericNumberBuilder = class extends SQLiteColumnBuilder {
1064
+ static [entityKind] = "SQLiteNumericNumberBuilder";
1065
+ constructor(name) {
1066
+ super(name, "number", "SQLiteNumericNumber");
1067
+ }
1068
+ /** @internal */
1069
+ build(table) {
1070
+ return new SQLiteNumericNumber(table, this.config);
1071
+ }
1072
+ };
1073
+ var SQLiteNumericNumber = class extends SQLiteColumn {
1074
+ static [entityKind] = "SQLiteNumericNumber";
1075
+ mapFromDriverValue(value) {
1076
+ if (typeof value === "number") return value;
1077
+ return Number(value);
1078
+ }
1079
+ mapToDriverValue = String;
1080
+ getSQLType() {
1081
+ return "numeric";
1082
+ }
1083
+ };
1084
+ var SQLiteNumericBigIntBuilder = class extends SQLiteColumnBuilder {
1085
+ static [entityKind] = "SQLiteNumericBigIntBuilder";
1086
+ constructor(name) {
1087
+ super(name, "bigint int64", "SQLiteNumericBigInt");
1088
+ }
1089
+ /** @internal */
1090
+ build(table) {
1091
+ return new SQLiteNumericBigInt(table, this.config);
1092
+ }
1093
+ };
1094
+ var SQLiteNumericBigInt = class extends SQLiteColumn {
1095
+ static [entityKind] = "SQLiteNumericBigInt";
1096
+ mapFromDriverValue = BigInt;
1097
+ mapToDriverValue = String;
1098
+ getSQLType() {
1099
+ return "numeric";
1100
+ }
1101
+ };
1102
+ function numeric(a, b) {
1103
+ const { name, config } = getColumnNameAndConfig(a, b);
1104
+ const mode = config?.mode;
1105
+ return mode === "number" ? new SQLiteNumericNumberBuilder(name) : mode === "bigint" ? new SQLiteNumericBigIntBuilder(name) : new SQLiteNumericBuilder(name);
1106
+ }
1107
+
1108
+ // ../../node_modules/.pnpm/drizzle-orm@1.0.0-beta.16-ea816b6_@opentelemetry+api@1.9.0_@types+better-sqlite3@7.6.13_0f21266a0de314c39cfb891f27e2ae25/node_modules/drizzle-orm/sqlite-core/columns/real.js
1109
+ var SQLiteRealBuilder = class extends SQLiteColumnBuilder {
1110
+ static [entityKind] = "SQLiteRealBuilder";
1111
+ constructor(name) {
1112
+ super(name, "number double", "SQLiteReal");
1113
+ }
1114
+ /** @internal */
1115
+ build(table) {
1116
+ return new SQLiteReal(table, this.config);
1117
+ }
1118
+ };
1119
+ var SQLiteReal = class extends SQLiteColumn {
1120
+ static [entityKind] = "SQLiteReal";
1121
+ getSQLType() {
1122
+ return "real";
1123
+ }
1124
+ };
1125
+ function real(name) {
1126
+ return new SQLiteRealBuilder(name ?? "");
1127
+ }
1128
+
1129
+ // ../../node_modules/.pnpm/drizzle-orm@1.0.0-beta.16-ea816b6_@opentelemetry+api@1.9.0_@types+better-sqlite3@7.6.13_0f21266a0de314c39cfb891f27e2ae25/node_modules/drizzle-orm/sqlite-core/columns/text.js
1130
+ var SQLiteTextBuilder = class extends SQLiteColumnBuilder {
1131
+ static [entityKind] = "SQLiteTextBuilder";
1132
+ constructor(name, config) {
1133
+ super(name, config.enum?.length ? "string enum" : "string", "SQLiteText");
1134
+ this.config.enumValues = config.enum;
1135
+ this.config.length = config.length;
1136
+ }
1137
+ /** @internal */
1138
+ build(table) {
1139
+ return new SQLiteText(table, this.config);
1140
+ }
1141
+ };
1142
+ var SQLiteText = class extends SQLiteColumn {
1143
+ static [entityKind] = "SQLiteText";
1144
+ enumValues = this.config.enumValues;
1145
+ constructor(table, config) {
1146
+ super(table, config);
1147
+ }
1148
+ getSQLType() {
1149
+ return `text${this.config.length ? `(${this.config.length})` : ""}`;
1150
+ }
1151
+ };
1152
+ var SQLiteTextJsonBuilder = class extends SQLiteColumnBuilder {
1153
+ static [entityKind] = "SQLiteTextJsonBuilder";
1154
+ constructor(name) {
1155
+ super(name, "object json", "SQLiteTextJson");
1156
+ }
1157
+ /** @internal */
1158
+ build(table) {
1159
+ return new SQLiteTextJson(table, this.config);
1160
+ }
1161
+ };
1162
+ var SQLiteTextJson = class extends SQLiteColumn {
1163
+ static [entityKind] = "SQLiteTextJson";
1164
+ getSQLType() {
1165
+ return "text";
1166
+ }
1167
+ mapFromDriverValue(value) {
1168
+ return JSON.parse(value);
1169
+ }
1170
+ mapToDriverValue(value) {
1171
+ return JSON.stringify(value);
1172
+ }
1173
+ };
1174
+ function text(a, b = {}) {
1175
+ const { name, config } = getColumnNameAndConfig(a, b);
1176
+ if (config.mode === "json") return new SQLiteTextJsonBuilder(name);
1177
+ return new SQLiteTextBuilder(name, config);
1178
+ }
1179
+
1180
+ // ../../node_modules/.pnpm/drizzle-orm@1.0.0-beta.16-ea816b6_@opentelemetry+api@1.9.0_@types+better-sqlite3@7.6.13_0f21266a0de314c39cfb891f27e2ae25/node_modules/drizzle-orm/sqlite-core/indexes.js
1181
+ var IndexBuilderOn = class {
1182
+ static [entityKind] = "SQLiteIndexBuilderOn";
1183
+ constructor(name, unique) {
1184
+ this.name = name;
1185
+ this.unique = unique;
1186
+ }
1187
+ on(...columns) {
1188
+ return new IndexBuilder(this.name, columns, this.unique);
1189
+ }
1190
+ };
1191
+ var IndexBuilder = class {
1192
+ static [entityKind] = "SQLiteIndexBuilder";
1193
+ /** @internal */
1194
+ config;
1195
+ constructor(name, columns, unique) {
1196
+ this.config = {
1197
+ name,
1198
+ columns,
1199
+ unique,
1200
+ where: void 0
1201
+ };
1202
+ }
1203
+ /**
1204
+ * Condition for partial index.
1205
+ */
1206
+ where(condition) {
1207
+ this.config.where = condition;
1208
+ return this;
1209
+ }
1210
+ /** @internal */
1211
+ build(table) {
1212
+ return new Index(this.config, table);
1213
+ }
1214
+ };
1215
+ var Index = class {
1216
+ static [entityKind] = "SQLiteIndex";
1217
+ config;
1218
+ isNameExplicit;
1219
+ constructor(config, table) {
1220
+ this.config = {
1221
+ ...config,
1222
+ table
1223
+ };
1224
+ this.isNameExplicit = !!config.name;
1225
+ }
1226
+ };
1227
+ function index(name) {
1228
+ return new IndexBuilderOn(name, false);
1229
+ }
1230
+
1231
+ // ../../node_modules/.pnpm/drizzle-orm@1.0.0-beta.16-ea816b6_@opentelemetry+api@1.9.0_@types+better-sqlite3@7.6.13_0f21266a0de314c39cfb891f27e2ae25/node_modules/drizzle-orm/sqlite-core/columns/all.js
1232
+ function getSQLiteColumnBuilders() {
1233
+ return {
1234
+ blob,
1235
+ customType,
1236
+ integer,
1237
+ numeric,
1238
+ real,
1239
+ text
1240
+ };
1241
+ }
1242
+
1243
+ // ../../node_modules/.pnpm/drizzle-orm@1.0.0-beta.16-ea816b6_@opentelemetry+api@1.9.0_@types+better-sqlite3@7.6.13_0f21266a0de314c39cfb891f27e2ae25/node_modules/drizzle-orm/sqlite-core/table.js
1244
+ var InlineForeignKeys = /* @__PURE__ */ Symbol.for("drizzle:SQLiteInlineForeignKeys");
1245
+ var SQLiteTable = class extends Table {
1246
+ static [entityKind] = "SQLiteTable";
1247
+ /** @internal */
1248
+ static Symbol = Object.assign({}, Table.Symbol, { InlineForeignKeys });
1249
+ /** @internal */
1250
+ [Table.Symbol.Columns];
1251
+ /** @internal */
1252
+ [InlineForeignKeys] = [];
1253
+ /** @internal */
1254
+ [Table.Symbol.ExtraConfigBuilder] = void 0;
1255
+ };
1256
+ function sqliteTableBase(name, columns, extraConfig, schema, baseName = name) {
1257
+ const rawTable = new SQLiteTable(name, schema, baseName);
1258
+ const parsedColumns = typeof columns === "function" ? columns(getSQLiteColumnBuilders()) : columns;
1259
+ const builtColumns = Object.fromEntries(Object.entries(parsedColumns).map(([name$1, colBuilderBase]) => {
1260
+ const colBuilder = colBuilderBase;
1261
+ colBuilder.setName(name$1);
1262
+ const column = colBuilder.build(rawTable);
1263
+ rawTable[InlineForeignKeys].push(...colBuilder.buildForeignKeys(column, rawTable));
1264
+ return [name$1, column];
1265
+ }));
1266
+ const table = Object.assign(rawTable, builtColumns);
1267
+ table[Table.Symbol.Columns] = builtColumns;
1268
+ table[Table.Symbol.ExtraConfigColumns] = builtColumns;
1269
+ if (extraConfig) table[SQLiteTable.Symbol.ExtraConfigBuilder] = extraConfig;
1270
+ return table;
1271
+ }
1272
+ var sqliteTable = (name, columns, extraConfig) => {
1273
+ return sqliteTableBase(name, columns, extraConfig);
1274
+ };
1275
+
1276
+ // ../../node_modules/.pnpm/drizzle-orm@1.0.0-beta.16-ea816b6_@opentelemetry+api@1.9.0_@types+better-sqlite3@7.6.13_0f21266a0de314c39cfb891f27e2ae25/node_modules/drizzle-orm/sqlite-core/primary-keys.js
1277
+ function primaryKey(...config) {
1278
+ if (config[0].columns) return new PrimaryKeyBuilder(config[0].columns, config[0].name);
1279
+ return new PrimaryKeyBuilder(config);
1280
+ }
1281
+ var PrimaryKeyBuilder = class {
1282
+ static [entityKind] = "SQLitePrimaryKeyBuilder";
1283
+ /** @internal */
1284
+ columns;
1285
+ /** @internal */
1286
+ name;
1287
+ constructor(columns, name) {
1288
+ this.columns = columns;
1289
+ this.name = name;
1290
+ }
1291
+ /** @internal */
1292
+ build(table) {
1293
+ return new PrimaryKey(table, this.columns, this.name);
1294
+ }
1295
+ };
1296
+ var PrimaryKey = class {
1297
+ static [entityKind] = "SQLitePrimaryKey";
1298
+ columns;
1299
+ name;
1300
+ isNameExplicit;
1301
+ constructor(table, columns, name) {
1302
+ this.table = table;
1303
+ this.columns = columns;
1304
+ this.name = name;
1305
+ this.isNameExplicit = !!name;
1306
+ }
1307
+ getName() {
1308
+ return this.name ?? `${this.table[SQLiteTable.Symbol.Name]}_${this.columns.map((column) => column.name).join("_")}_pk`;
1309
+ }
1310
+ };
1311
+
1312
+ // ../agent/dist/chunk-KXKREECS.js
1313
+ import fs from "fs/promises";
1314
+ var sep = "/";
1315
+ function join(...parts) {
1316
+ const joined = parts.filter(Boolean).join("/");
1317
+ return normalize(joined);
1318
+ }
1319
+ function dirname(p) {
1320
+ if (!p) return ".";
1321
+ const i = p.lastIndexOf("/");
1322
+ if (i < 0) return ".";
1323
+ if (i === 0) return "/";
1324
+ return p.slice(0, i);
1325
+ }
1326
+ function basename(p, ext) {
1327
+ if (p.endsWith("/")) p = p.slice(0, -1);
1328
+ const i = p.lastIndexOf("/");
1329
+ const base = i < 0 ? p : p.slice(i + 1);
1330
+ if (ext && base.endsWith(ext)) return base.slice(0, -ext.length);
1331
+ return base;
1332
+ }
1333
+ function extname(p) {
1334
+ const base = basename(p);
1335
+ const i = base.lastIndexOf(".");
1336
+ if (i <= 0) return "";
1337
+ return base.slice(i);
1338
+ }
1339
+ function isAbsolute(p) {
1340
+ return p.startsWith("/");
1341
+ }
1342
+ function normalize(p) {
1343
+ if (!p) return ".";
1344
+ const isAbs = p.startsWith("/");
1345
+ const segments = p.split("/");
1346
+ const out = [];
1347
+ for (const s of segments) {
1348
+ if (s === "" || s === ".") continue;
1349
+ if (s === "..") {
1350
+ if (out.length > 0 && out[out.length - 1] !== "..") {
1351
+ out.pop();
1352
+ } else if (!isAbs) {
1353
+ out.push("..");
1354
+ }
1355
+ } else {
1356
+ out.push(s);
1357
+ }
1358
+ }
1359
+ const result = out.join("/");
1360
+ if (isAbs) return "/" + result;
1361
+ return result || ".";
1362
+ }
1363
+ function relative(from, to) {
1364
+ from = normalize(from);
1365
+ to = normalize(to);
1366
+ if (from === to) return "";
1367
+ const fromParts = from.split("/").filter(Boolean);
1368
+ const toParts = to.split("/").filter(Boolean);
1369
+ let common = 0;
1370
+ while (common < fromParts.length && common < toParts.length && fromParts[common] === toParts[common]) {
1371
+ common++;
1372
+ }
1373
+ const ups = fromParts.length - common;
1374
+ const downs = toParts.slice(common);
1375
+ const parts = [...Array(ups).fill(".."), ...downs];
1376
+ return parts.join("/") || ".";
1377
+ }
1378
+ function resolve(...parts) {
1379
+ let resolved = "";
1380
+ for (let i = parts.length - 1; i >= 0; i--) {
1381
+ const part = parts[i];
1382
+ if (!part) continue;
1383
+ resolved = resolved ? part + "/" + resolved : part;
1384
+ if (isAbsolute(part)) break;
1385
+ }
1386
+ return normalize(resolved);
1387
+ }
1388
+ var Filesystem;
1389
+ ((Filesystem2) => {
1390
+ async function exists(context, p) {
1391
+ return context.fs.exists(p);
1392
+ }
1393
+ Filesystem2.exists = exists;
1394
+ async function isDir(context, p) {
1395
+ const s = await context.fs.stat(p);
1396
+ return s?.isDirectory ?? false;
1397
+ }
1398
+ Filesystem2.isDir = isDir;
1399
+ async function stat(context, p) {
1400
+ return context.fs.stat(p);
1401
+ }
1402
+ Filesystem2.stat = stat;
1403
+ async function size(context, p) {
1404
+ const s = await context.fs.stat(p);
1405
+ return s?.size ?? 0;
1406
+ }
1407
+ Filesystem2.size = size;
1408
+ async function readText(context, p) {
1409
+ return context.fs.readText(p);
1410
+ }
1411
+ Filesystem2.readText = readText;
1412
+ async function readJson(context, p) {
1413
+ return JSON.parse(await readText(context, p));
1414
+ }
1415
+ Filesystem2.readJson = readJson;
1416
+ async function readBytes(context, p) {
1417
+ return context.fs.readBytes(p);
1418
+ }
1419
+ Filesystem2.readBytes = readBytes;
1420
+ async function readArrayBuffer(context, p) {
1421
+ const bytes = await readBytes(context, p);
1422
+ return bytes.buffer;
1423
+ }
1424
+ Filesystem2.readArrayBuffer = readArrayBuffer;
1425
+ async function write(context, p, content) {
1426
+ return context.fs.write(p, content);
1427
+ }
1428
+ Filesystem2.write = write;
1429
+ async function writeJson(context, p, data) {
1430
+ return write(context, p, JSON.stringify(data, null, 2));
1431
+ }
1432
+ Filesystem2.writeJson = writeJson;
1433
+ async function mkdir(context, p) {
1434
+ return context.fs.mkdir(p);
1435
+ }
1436
+ Filesystem2.mkdir = mkdir;
1437
+ async function remove(context, p) {
1438
+ return context.fs.remove(p);
1439
+ }
1440
+ Filesystem2.remove = remove;
1441
+ const MIME_MAP = {
1442
+ ".html": "text/html",
1443
+ ".css": "text/css",
1444
+ ".js": "application/javascript",
1445
+ ".mjs": "application/javascript",
1446
+ ".json": "application/json",
1447
+ ".ts": "text/typescript",
1448
+ ".tsx": "text/typescript",
1449
+ ".jsx": "text/javascript",
1450
+ ".md": "text/markdown",
1451
+ ".txt": "text/plain",
1452
+ ".csv": "text/csv",
1453
+ ".xml": "application/xml",
1454
+ ".yaml": "text/yaml",
1455
+ ".yml": "text/yaml",
1456
+ ".toml": "text/plain",
1457
+ ".svg": "image/svg+xml",
1458
+ ".png": "image/png",
1459
+ ".jpg": "image/jpeg",
1460
+ ".jpeg": "image/jpeg",
1461
+ ".gif": "image/gif",
1462
+ ".webp": "image/webp",
1463
+ ".ico": "image/x-icon",
1464
+ ".pdf": "application/pdf",
1465
+ ".zip": "application/zip",
1466
+ ".gz": "application/gzip",
1467
+ ".wasm": "application/wasm",
1468
+ ".mp4": "video/mp4",
1469
+ ".webm": "video/webm",
1470
+ ".mp3": "audio/mpeg",
1471
+ ".sh": "text/x-shellscript",
1472
+ ".py": "text/x-python",
1473
+ ".rb": "text/x-ruby",
1474
+ ".go": "text/x-go",
1475
+ ".rs": "text/x-rust",
1476
+ ".java": "text/x-java",
1477
+ ".c": "text/x-c",
1478
+ ".cpp": "text/x-c++",
1479
+ ".h": "text/x-c",
1480
+ ".hpp": "text/x-c++"
1481
+ };
1482
+ function mimeType(p) {
1483
+ return MIME_MAP[extname(p).toLowerCase()] || "application/octet-stream";
1484
+ }
1485
+ Filesystem2.mimeType = mimeType;
1486
+ function resolve2(p) {
1487
+ return resolve(p);
1488
+ }
1489
+ Filesystem2.resolve = resolve2;
1490
+ function overlaps(a, b) {
1491
+ const relA = relative(a, b);
1492
+ const relB = relative(b, a);
1493
+ return !relA || !relA.startsWith("..") || !relB || !relB.startsWith("..");
1494
+ }
1495
+ Filesystem2.overlaps = overlaps;
1496
+ function contains(parent, child) {
1497
+ return !relative(parent, child).startsWith("..");
1498
+ }
1499
+ Filesystem2.contains = contains;
1500
+ async function findUp(context, target, start, stop) {
1501
+ let current = start;
1502
+ const result = [];
1503
+ while (true) {
1504
+ const search = join(current, target);
1505
+ if (await exists(context, search)) result.push(search);
1506
+ if (stop === current) break;
1507
+ const parent = dirname(current);
1508
+ if (parent === current) break;
1509
+ current = parent;
1510
+ }
1511
+ return result;
1512
+ }
1513
+ Filesystem2.findUp = findUp;
1514
+ async function* up(context, options) {
1515
+ const { targets, start, stop } = options;
1516
+ let current = start;
1517
+ while (true) {
1518
+ for (const target of targets) {
1519
+ const search = join(current, target);
1520
+ if (await exists(context, search)) yield search;
1521
+ }
1522
+ if (stop === current) break;
1523
+ const parent = dirname(current);
1524
+ if (parent === current) break;
1525
+ current = parent;
1526
+ }
1527
+ }
1528
+ Filesystem2.up = up;
1529
+ async function globUp(context, pattern, start, stop) {
1530
+ let current = start;
1531
+ const result = [];
1532
+ while (true) {
1533
+ try {
1534
+ const { Glob: Glob2 } = await import("./glob-RMMK6FVW-AWD4KFLI.js");
1535
+ const matches = await Glob2.scan(context, pattern, {
1536
+ cwd: current,
1537
+ absolute: true,
1538
+ include: "file",
1539
+ dot: true
1540
+ });
1541
+ result.push(...matches);
1542
+ } catch {
1543
+ }
1544
+ if (stop === current) break;
1545
+ const parent = dirname(current);
1546
+ if (parent === current) break;
1547
+ current = parent;
1548
+ }
1549
+ return result;
1550
+ }
1551
+ Filesystem2.globUp = globUp;
1552
+ })(Filesystem || (Filesystem = {}));
1553
+ var Log;
1554
+ ((Log2) => {
1555
+ Log2.Level = zod_default.enum(["DEBUG", "INFO", "WARN", "ERROR"]).meta({ ref: "LogLevel", description: "Log level" });
1556
+ const levelPriority = {
1557
+ DEBUG: 0,
1558
+ INFO: 1,
1559
+ WARN: 2,
1560
+ ERROR: 3
1561
+ };
1562
+ let level = "INFO";
1563
+ function shouldLog(input) {
1564
+ return levelPriority[input] >= levelPriority[level];
1565
+ }
1566
+ const loggers = /* @__PURE__ */ new Map();
1567
+ Log2.Default = create({ service: "default" });
1568
+ let write = (msg) => {
1569
+ console.error(msg);
1570
+ return msg.length;
1571
+ };
1572
+ async function init(options) {
1573
+ if (options.level) level = options.level;
1574
+ if (options.writer) {
1575
+ write = (msg) => {
1576
+ options.writer(msg);
1577
+ return msg.length;
1578
+ };
1579
+ }
1580
+ }
1581
+ Log2.init = init;
1582
+ function formatError(error, depth = 0) {
1583
+ const result = error.message;
1584
+ return error.cause instanceof Error && depth < 10 ? result + " Caused by: " + formatError(error.cause, depth + 1) : result;
1585
+ }
1586
+ let last = Date.now();
1587
+ function create(tags) {
1588
+ tags = tags || {};
1589
+ const service = tags["service"];
1590
+ if (service && typeof service === "string") {
1591
+ const cached = loggers.get(service);
1592
+ if (cached) {
1593
+ return cached;
1594
+ }
1595
+ }
1596
+ function build(message, extra) {
1597
+ const prefix = Object.entries({
1598
+ ...tags,
1599
+ ...extra
1600
+ }).filter(([_, value]) => value !== void 0 && value !== null).map(([key, value]) => {
1601
+ const prefix2 = `${key}=`;
1602
+ if (value instanceof Error) return prefix2 + formatError(value);
1603
+ if (typeof value === "object") return prefix2 + JSON.stringify(value);
1604
+ return prefix2 + value;
1605
+ }).join(" ");
1606
+ const next = /* @__PURE__ */ new Date();
1607
+ const diff = next.getTime() - last;
1608
+ last = next.getTime();
1609
+ return [next.toISOString().split(".")[0], "+" + diff + "ms", prefix, message].filter(Boolean).join(" ") + "\n";
1610
+ }
1611
+ const result = {
1612
+ debug(message, extra) {
1613
+ if (shouldLog("DEBUG")) {
1614
+ write("DEBUG " + build(message, extra));
1615
+ }
1616
+ },
1617
+ info(message, extra) {
1618
+ if (shouldLog("INFO")) {
1619
+ write("INFO " + build(message, extra));
1620
+ }
1621
+ },
1622
+ error(message, extra) {
1623
+ if (shouldLog("ERROR")) {
1624
+ write("ERROR " + build(message, extra));
1625
+ }
1626
+ },
1627
+ warn(message, extra) {
1628
+ if (shouldLog("WARN")) {
1629
+ write("WARN " + build(message, extra));
1630
+ }
1631
+ },
1632
+ tag(key, value) {
1633
+ if (tags) tags[key] = value;
1634
+ return result;
1635
+ },
1636
+ clone() {
1637
+ return Log2.create({ ...tags });
1638
+ },
1639
+ time(message, extra) {
1640
+ const now = Date.now();
1641
+ result.info(message, { status: "started", ...extra });
1642
+ function stop() {
1643
+ result.info(message, {
1644
+ status: "completed",
1645
+ duration: Date.now() - now,
1646
+ ...extra
1647
+ });
1648
+ }
1649
+ return {
1650
+ stop,
1651
+ [Symbol.dispose]() {
1652
+ stop();
1653
+ }
1654
+ };
1655
+ }
1656
+ };
1657
+ if (service && typeof service === "string") {
1658
+ loggers.set(service, result);
1659
+ }
1660
+ return result;
1661
+ }
1662
+ Log2.create = create;
1663
+ })(Log || (Log = {}));
1664
+ var _env = {};
1665
+ function truthy(key) {
1666
+ const value = _env[key]?.toLowerCase();
1667
+ return value === "true" || value === "1";
1668
+ }
1669
+ function falsy(key) {
1670
+ const value = _env[key]?.toLowerCase();
1671
+ return value === "false" || value === "0";
1672
+ }
1673
+ function number(key) {
1674
+ const value = _env[key];
1675
+ if (!value) return void 0;
1676
+ const parsed = Number(value);
1677
+ return Number.isInteger(parsed) && parsed > 0 ? parsed : void 0;
1678
+ }
1679
+ var Flag;
1680
+ ((Flag2) => {
1681
+ function init(env) {
1682
+ _env = env;
1683
+ Flag2.OPENCODE_AUTO_SHARE = truthy("OPENCODE_AUTO_SHARE");
1684
+ Flag2.OPENCODE_GIT_BASH_PATH = _env["OPENCODE_GIT_BASH_PATH"];
1685
+ Flag2.OPENCODE_CONFIG = _env["OPENCODE_CONFIG"];
1686
+ Flag2.OPENCODE_CONFIG_CONTENT = _env["OPENCODE_CONFIG_CONTENT"];
1687
+ Flag2.OPENCODE_DISABLE_AUTOUPDATE = truthy("OPENCODE_DISABLE_AUTOUPDATE");
1688
+ Flag2.OPENCODE_DISABLE_PRUNE = truthy("OPENCODE_DISABLE_PRUNE");
1689
+ Flag2.OPENCODE_DISABLE_TERMINAL_TITLE = truthy("OPENCODE_DISABLE_TERMINAL_TITLE");
1690
+ Flag2.OPENCODE_PERMISSION = _env["OPENCODE_PERMISSION"];
1691
+ Flag2.OPENCODE_DISABLE_DEFAULT_PLUGINS = truthy("OPENCODE_DISABLE_DEFAULT_PLUGINS");
1692
+ Flag2.OPENCODE_DISABLE_LSP_DOWNLOAD = truthy("OPENCODE_DISABLE_LSP_DOWNLOAD");
1693
+ Flag2.OPENCODE_ENABLE_EXPERIMENTAL_MODELS = truthy("OPENCODE_ENABLE_EXPERIMENTAL_MODELS");
1694
+ Flag2.OPENCODE_DISABLE_AUTOCOMPACT = truthy("OPENCODE_DISABLE_AUTOCOMPACT");
1695
+ Flag2.OPENCODE_DISABLE_MODELS_FETCH = truthy("OPENCODE_DISABLE_MODELS_FETCH");
1696
+ Flag2.OPENCODE_DISABLE_CLAUDE_CODE = truthy("OPENCODE_DISABLE_CLAUDE_CODE");
1697
+ Flag2.OPENCODE_DISABLE_CLAUDE_CODE_PROMPT = Flag2.OPENCODE_DISABLE_CLAUDE_CODE || truthy("OPENCODE_DISABLE_CLAUDE_CODE_PROMPT");
1698
+ Flag2.OPENCODE_DISABLE_CLAUDE_CODE_SKILLS = Flag2.OPENCODE_DISABLE_CLAUDE_CODE || truthy("OPENCODE_DISABLE_CLAUDE_CODE_SKILLS");
1699
+ Flag2.OPENCODE_DISABLE_EXTERNAL_SKILLS = Flag2.OPENCODE_DISABLE_CLAUDE_CODE_SKILLS || truthy("OPENCODE_DISABLE_EXTERNAL_SKILLS");
1700
+ Flag2.OPENCODE_FAKE_VCS = _env["OPENCODE_FAKE_VCS"];
1701
+ Flag2.OPENCODE_SERVER_PASSWORD = _env["OPENCODE_SERVER_PASSWORD"];
1702
+ Flag2.OPENCODE_SERVER_USERNAME = _env["OPENCODE_SERVER_USERNAME"];
1703
+ Flag2.OPENCODE_ENABLE_QUESTION_TOOL = truthy("OPENCODE_ENABLE_QUESTION_TOOL");
1704
+ Flag2.OPENCODE_EXPERIMENTAL = truthy("OPENCODE_EXPERIMENTAL");
1705
+ Flag2.OPENCODE_EXPERIMENTAL_FILEWATCHER = truthy("OPENCODE_EXPERIMENTAL_FILEWATCHER");
1706
+ Flag2.OPENCODE_EXPERIMENTAL_DISABLE_FILEWATCHER = truthy("OPENCODE_EXPERIMENTAL_DISABLE_FILEWATCHER");
1707
+ Flag2.OPENCODE_EXPERIMENTAL_ICON_DISCOVERY = Flag2.OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_ICON_DISCOVERY");
1708
+ Flag2.OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT = (() => {
1709
+ const copy = _env["OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT"];
1710
+ return copy === void 0 ? false : truthy("OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT");
1711
+ })();
1712
+ Flag2.OPENCODE_ENABLE_EXA = truthy("OPENCODE_ENABLE_EXA") || Flag2.OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_EXA");
1713
+ Flag2.OPENCODE_EXPERIMENTAL_BASH_DEFAULT_TIMEOUT_MS = number("OPENCODE_EXPERIMENTAL_BASH_DEFAULT_TIMEOUT_MS");
1714
+ Flag2.OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX = number("OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX");
1715
+ Flag2.OPENCODE_EXPERIMENTAL_OXFMT = Flag2.OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_OXFMT");
1716
+ Flag2.OPENCODE_EXPERIMENTAL_LSP_TY = truthy("OPENCODE_EXPERIMENTAL_LSP_TY");
1717
+ Flag2.OPENCODE_EXPERIMENTAL_LSP_TOOL = Flag2.OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_LSP_TOOL");
1718
+ Flag2.OPENCODE_DISABLE_FILETIME_CHECK = truthy("OPENCODE_DISABLE_FILETIME_CHECK");
1719
+ Flag2.OPENCODE_EXPERIMENTAL_PLAN_MODE = Flag2.OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_PLAN_MODE");
1720
+ Flag2.OPENCODE_EXPERIMENTAL_WORKSPACES = Flag2.OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_WORKSPACES");
1721
+ Flag2.OPENCODE_EXPERIMENTAL_MARKDOWN = !falsy("OPENCODE_EXPERIMENTAL_MARKDOWN");
1722
+ Flag2.OPENCODE_MODELS_URL = _env["OPENCODE_MODELS_URL"];
1723
+ Flag2.OPENCODE_MODELS_PATH = _env["OPENCODE_MODELS_PATH"];
1724
+ Flag2.OPENCODE_DISABLE_CHANNEL_DB = truthy("OPENCODE_DISABLE_CHANNEL_DB");
1725
+ Flag2.OPENCODE_SKIP_MIGRATIONS = truthy("OPENCODE_SKIP_MIGRATIONS");
1726
+ Flag2.OPENCODE_STRICT_CONFIG_DEPS = truthy("OPENCODE_STRICT_CONFIG_DEPS");
1727
+ }
1728
+ Flag2.init = init;
1729
+ Flag2.OPENCODE_AUTO_SHARE = false;
1730
+ Flag2.OPENCODE_DISABLE_AUTOUPDATE = false;
1731
+ Flag2.OPENCODE_DISABLE_PRUNE = false;
1732
+ Flag2.OPENCODE_DISABLE_TERMINAL_TITLE = false;
1733
+ Flag2.OPENCODE_DISABLE_DEFAULT_PLUGINS = false;
1734
+ Flag2.OPENCODE_DISABLE_LSP_DOWNLOAD = false;
1735
+ Flag2.OPENCODE_ENABLE_EXPERIMENTAL_MODELS = false;
1736
+ Flag2.OPENCODE_DISABLE_AUTOCOMPACT = false;
1737
+ Flag2.OPENCODE_DISABLE_MODELS_FETCH = false;
1738
+ Flag2.OPENCODE_DISABLE_CLAUDE_CODE = false;
1739
+ Flag2.OPENCODE_DISABLE_CLAUDE_CODE_PROMPT = false;
1740
+ Flag2.OPENCODE_DISABLE_CLAUDE_CODE_SKILLS = false;
1741
+ Flag2.OPENCODE_DISABLE_EXTERNAL_SKILLS = false;
1742
+ Flag2.OPENCODE_ENABLE_QUESTION_TOOL = false;
1743
+ Flag2.OPENCODE_EXPERIMENTAL = false;
1744
+ Flag2.OPENCODE_EXPERIMENTAL_FILEWATCHER = false;
1745
+ Flag2.OPENCODE_EXPERIMENTAL_DISABLE_FILEWATCHER = false;
1746
+ Flag2.OPENCODE_EXPERIMENTAL_ICON_DISCOVERY = false;
1747
+ Flag2.OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT = false;
1748
+ Flag2.OPENCODE_ENABLE_EXA = false;
1749
+ Flag2.OPENCODE_EXPERIMENTAL_OXFMT = false;
1750
+ Flag2.OPENCODE_EXPERIMENTAL_LSP_TY = false;
1751
+ Flag2.OPENCODE_EXPERIMENTAL_LSP_TOOL = false;
1752
+ Flag2.OPENCODE_DISABLE_FILETIME_CHECK = false;
1753
+ Flag2.OPENCODE_EXPERIMENTAL_PLAN_MODE = false;
1754
+ Flag2.OPENCODE_EXPERIMENTAL_WORKSPACES = false;
1755
+ Flag2.OPENCODE_EXPERIMENTAL_MARKDOWN = true;
1756
+ Flag2.OPENCODE_DISABLE_CHANNEL_DB = false;
1757
+ Flag2.OPENCODE_SKIP_MIGRATIONS = false;
1758
+ Flag2.OPENCODE_STRICT_CONFIG_DEPS = false;
1759
+ })(Flag || (Flag = {}));
1760
+ Object.defineProperty(Flag, "OPENCODE_DISABLE_PROJECT_CONFIG", {
1761
+ get() {
1762
+ return truthy("OPENCODE_DISABLE_PROJECT_CONFIG");
1763
+ },
1764
+ enumerable: true,
1765
+ configurable: false
1766
+ });
1767
+ Object.defineProperty(Flag, "OPENCODE_TUI_CONFIG", {
1768
+ get() {
1769
+ return _env["OPENCODE_TUI_CONFIG"];
1770
+ },
1771
+ enumerable: true,
1772
+ configurable: false
1773
+ });
1774
+ Object.defineProperty(Flag, "OPENCODE_CONFIG_DIR", {
1775
+ get() {
1776
+ return _env["OPENCODE_CONFIG_DIR"];
1777
+ },
1778
+ enumerable: true,
1779
+ configurable: false
1780
+ });
1781
+ Object.defineProperty(Flag, "OPENCODE_CLIENT", {
1782
+ get() {
1783
+ return _env["OPENCODE_CLIENT"] ?? "cli";
1784
+ },
1785
+ enumerable: true,
1786
+ configurable: false
1787
+ });
1788
+ var projectIdSchema = Schema_exports.String.pipe(Schema_exports.brand("ProjectID"));
1789
+ var ProjectID = projectIdSchema.pipe(
1790
+ withStatics((schema) => ({
1791
+ global: schema.makeUnsafe("global"),
1792
+ make: (id) => schema.makeUnsafe(id),
1793
+ zod: zod_default.string().pipe(zod_default.custom())
1794
+ }))
1795
+ );
1796
+ var ProjectTable = sqliteTable("project", {
1797
+ id: text().$type().primaryKey(),
1798
+ worktree: text().notNull(),
1799
+ vcs: text(),
1800
+ name: text(),
1801
+ icon_url: text(),
1802
+ icon_color: text(),
1803
+ ...Timestamps,
1804
+ time_initialized: integer(),
1805
+ sandboxes: text({ mode: "json" }).notNull().$type(),
1806
+ commands: text({ mode: "json" }).$type()
1807
+ });
1808
+ var DARWIN_HOME = [
1809
+ "Music",
1810
+ "Pictures",
1811
+ "Movies",
1812
+ "Downloads",
1813
+ "Desktop",
1814
+ "Documents",
1815
+ "Public",
1816
+ "Applications",
1817
+ "Library"
1818
+ ];
1819
+ var DARWIN_LIBRARY = [
1820
+ "Application Support/AddressBook",
1821
+ "Calendars",
1822
+ "Mail",
1823
+ "Messages",
1824
+ "Safari",
1825
+ "Cookies",
1826
+ "Application Support/com.apple.TCC",
1827
+ "PersonalizationPortrait",
1828
+ "Metadata/CoreSpotlight",
1829
+ "Suggestions"
1830
+ ];
1831
+ var DARWIN_ROOT = ["/.DocumentRevisions-V100", "/.Spotlight-V100", "/.Trashes", "/.fseventsd"];
1832
+ var WIN32_HOME = ["AppData", "Downloads", "Desktop", "Documents", "Pictures", "Music", "Videos", "OneDrive"];
1833
+ var Protected;
1834
+ ((Protected2) => {
1835
+ function names(platform) {
1836
+ if (platform === "darwin") return new Set(DARWIN_HOME);
1837
+ if (platform === "win32") return new Set(WIN32_HOME);
1838
+ return /* @__PURE__ */ new Set();
1839
+ }
1840
+ Protected2.names = names;
1841
+ function paths(home, platform) {
1842
+ if (platform === "darwin")
1843
+ return [
1844
+ ...DARWIN_HOME.map((n) => join(home, n)),
1845
+ ...DARWIN_LIBRARY.map((n) => join(home, "Library", n)),
1846
+ ...DARWIN_ROOT
1847
+ ];
1848
+ if (platform === "win32") return WIN32_HOME.map((n) => join(home, n));
1849
+ return [];
1850
+ }
1851
+ Protected2.paths = paths;
1852
+ })(Protected || (Protected = {}));
1853
+ var FileIgnore;
1854
+ ((FileIgnore2) => {
1855
+ const FOLDERS = /* @__PURE__ */ new Set([
1856
+ "node_modules",
1857
+ "bower_components",
1858
+ ".pnpm-store",
1859
+ "vendor",
1860
+ ".npm",
1861
+ "dist",
1862
+ "build",
1863
+ "out",
1864
+ ".next",
1865
+ "target",
1866
+ "bin",
1867
+ "obj",
1868
+ ".git",
1869
+ ".svn",
1870
+ ".hg",
1871
+ ".vscode",
1872
+ ".idea",
1873
+ ".turbo",
1874
+ ".output",
1875
+ "desktop",
1876
+ ".sst",
1877
+ ".cache",
1878
+ ".webkit-cache",
1879
+ "__pycache__",
1880
+ ".pytest_cache",
1881
+ "mypy_cache",
1882
+ ".history",
1883
+ ".gradle"
1884
+ ]);
1885
+ const FILES = [
1886
+ "**/*.swp",
1887
+ "**/*.swo",
1888
+ "**/*.pyc",
1889
+ "**/.DS_Store",
1890
+ "**/Thumbs.db",
1891
+ "**/logs/**",
1892
+ "**/tmp/**",
1893
+ "**/temp/**",
1894
+ "**/*.log",
1895
+ "**/coverage/**",
1896
+ "**/.nyc_output/**"
1897
+ ];
1898
+ FileIgnore2.PATTERNS = [...FILES, ...FOLDERS];
1899
+ function match(filepath, opts) {
1900
+ for (const pattern of opts?.whitelist || []) {
1901
+ if (Glob.match(pattern, filepath)) return false;
1902
+ }
1903
+ const parts = filepath.split(/[/\\]/);
1904
+ for (let i = 0; i < parts.length; i++) {
1905
+ if (FOLDERS.has(parts[i])) return true;
1906
+ }
1907
+ const extra = opts?.extra || [];
1908
+ for (const pattern of [...FILES, ...extra]) {
1909
+ if (Glob.match(pattern, filepath)) return true;
1910
+ }
1911
+ return false;
1912
+ }
1913
+ FileIgnore2.match = match;
1914
+ })(FileIgnore || (FileIgnore = {}));
1915
+ var FileTimeService = class {
1916
+ log = Log.create({ service: "file.time" });
1917
+ readTimes = {};
1918
+ locks = /* @__PURE__ */ new Map();
1919
+ read(sessionID, file) {
1920
+ this.log.info("read", { sessionID, file });
1921
+ this.readTimes[sessionID] = this.readTimes[sessionID] || {};
1922
+ this.readTimes[sessionID][file] = /* @__PURE__ */ new Date();
1923
+ }
1924
+ get(sessionID, file) {
1925
+ return this.readTimes[sessionID]?.[file];
1926
+ }
1927
+ async assert(context, sessionID, filepath) {
1928
+ if (Flag.OPENCODE_DISABLE_FILETIME_CHECK === true) return;
1929
+ const time = this.get(sessionID, filepath);
1930
+ if (!time) throw new Error(`You must read file ${filepath} before overwriting it. Use the Read tool first`);
1931
+ const s = await Filesystem.stat(context, filepath);
1932
+ const mtimeMs = s?.mtimeMs;
1933
+ if (mtimeMs && mtimeMs > time.getTime() + 50) {
1934
+ const mtime = new Date(mtimeMs);
1935
+ throw new Error(
1936
+ `File ${filepath} has been modified since it was last read.
1937
+ Last modification: ${mtime.toISOString()}
1938
+ Last read: ${time.toISOString()}
1939
+
1940
+ Please read the file again before modifying it.`
1941
+ );
1942
+ }
1943
+ }
1944
+ async withLock(filepath, fn) {
1945
+ const currentLock = this.locks.get(filepath) ?? Promise.resolve();
1946
+ let release = () => {
1947
+ };
1948
+ const nextLock = new Promise((resolve2) => {
1949
+ release = resolve2;
1950
+ });
1951
+ const chained = currentLock.then(() => nextLock);
1952
+ this.locks.set(filepath, chained);
1953
+ await currentLock;
1954
+ try {
1955
+ return await fn();
1956
+ } finally {
1957
+ release();
1958
+ if (this.locks.get(filepath) === chained) this.locks.delete(filepath);
1959
+ }
1960
+ }
1961
+ };
1962
+ var FileTime;
1963
+ ((FileTime2) => {
1964
+ function svc(context) {
1965
+ if (context.fileTime) return context.fileTime;
1966
+ return context.fileTime;
1967
+ }
1968
+ function state(context) {
1969
+ const s = svc(context);
1970
+ return { read: s.readTimes, locks: s.locks };
1971
+ }
1972
+ FileTime2.state = state;
1973
+ function read(context, sessionID, file) {
1974
+ svc(context).read(sessionID, file);
1975
+ }
1976
+ FileTime2.read = read;
1977
+ function get(context, sessionID, file) {
1978
+ return svc(context).get(sessionID, file);
1979
+ }
1980
+ FileTime2.get = get;
1981
+ async function withLock(context, filepath, fn) {
1982
+ return svc(context).withLock(filepath, fn);
1983
+ }
1984
+ FileTime2.withLock = withLock;
1985
+ async function assert(context, sessionID, filepath) {
1986
+ return svc(context).assert(context, sessionID, filepath);
1987
+ }
1988
+ FileTime2.assert = assert;
1989
+ })(FileTime || (FileTime = {}));
1990
+ var Project;
1991
+ ((Project2) => {
1992
+ const log = Log.create({ service: "project" });
1993
+ Project2.Info = zod_default.object({
1994
+ id: ProjectID.zod,
1995
+ worktree: zod_default.string(),
1996
+ vcs: zod_default.literal("git").optional(),
1997
+ name: zod_default.string().optional(),
1998
+ icon: zod_default.object({
1999
+ url: zod_default.string().optional(),
2000
+ override: zod_default.string().optional(),
2001
+ color: zod_default.string().optional()
2002
+ }).optional(),
2003
+ commands: zod_default.object({
2004
+ start: zod_default.string().optional().describe("Startup script to run when creating a new workspace (worktree)")
2005
+ }).optional(),
2006
+ time: zod_default.object({
2007
+ created: zod_default.number(),
2008
+ updated: zod_default.number(),
2009
+ initialized: zod_default.number().optional()
2010
+ }),
2011
+ sandboxes: zod_default.array(zod_default.string())
2012
+ }).meta({ ref: "Project" });
2013
+ function fromRow(row) {
2014
+ const icon = row.icon_url || row.icon_color ? { url: row.icon_url ?? void 0, color: row.icon_color ?? void 0 } : void 0;
2015
+ return {
2016
+ id: ProjectID.make(row.id),
2017
+ worktree: row.worktree,
2018
+ vcs: row.vcs ? Project2.Info.shape.vcs.parse(row.vcs) : void 0,
2019
+ name: row.name ?? void 0,
2020
+ icon,
2021
+ time: {
2022
+ created: row.time_created,
2023
+ updated: row.time_updated,
2024
+ initialized: row.time_initialized ?? void 0
2025
+ },
2026
+ sandboxes: row.sandboxes,
2027
+ commands: row.commands ?? void 0
2028
+ };
2029
+ }
2030
+ Project2.fromRow = fromRow;
2031
+ function setInitialized(context, id) {
2032
+ context.db.update("project", { op: "eq", field: "id", value: id }, { time_initialized: Date.now() });
2033
+ }
2034
+ Project2.setInitialized = setInitialized;
2035
+ function list(context) {
2036
+ return context.db.findMany("project").map((row) => fromRow(row));
2037
+ }
2038
+ Project2.list = list;
2039
+ function get(context, id) {
2040
+ const row = context.db.findOne("project", { op: "eq", field: "id", value: id });
2041
+ if (!row) return void 0;
2042
+ return fromRow(row);
2043
+ }
2044
+ Project2.get = get;
2045
+ async function sandboxes(context, id) {
2046
+ const row = context.db.findOne("project", { op: "eq", field: "id", value: id });
2047
+ if (!row) return [];
2048
+ const data = fromRow(row);
2049
+ const valid = [];
2050
+ for (const dir of data.sandboxes) {
2051
+ const s = await Filesystem.stat(context, dir);
2052
+ if (s?.isDirectory) valid.push(dir);
2053
+ }
2054
+ return valid;
2055
+ }
2056
+ Project2.sandboxes = sandboxes;
2057
+ })(Project || (Project = {}));
2058
+ var SessionTable = sqliteTable(
2059
+ "session",
2060
+ {
2061
+ id: text().$type().primaryKey(),
2062
+ project_id: text().$type().notNull().references(() => ProjectTable.id, { onDelete: "cascade" }),
2063
+ workspace_id: text().$type(),
2064
+ parent_id: text().$type(),
2065
+ slug: text().notNull(),
2066
+ directory: text().notNull(),
2067
+ title: text().notNull(),
2068
+ version: text().notNull(),
2069
+ share_url: text(),
2070
+ summary_additions: integer(),
2071
+ summary_deletions: integer(),
2072
+ summary_files: integer(),
2073
+ summary_diffs: text({ mode: "json" }).$type(),
2074
+ revert: text({ mode: "json" }).$type(),
2075
+ ...Timestamps,
2076
+ time_compacting: integer(),
2077
+ time_archived: integer()
2078
+ },
2079
+ (table) => [
2080
+ index("session_project_idx").on(table.project_id),
2081
+ index("session_workspace_idx").on(table.workspace_id),
2082
+ index("session_parent_idx").on(table.parent_id)
2083
+ ]
2084
+ );
2085
+ var MessageTable = sqliteTable(
2086
+ "message",
2087
+ {
2088
+ id: text().$type().primaryKey(),
2089
+ session_id: text().$type().notNull().references(() => SessionTable.id, { onDelete: "cascade" }),
2090
+ ...Timestamps,
2091
+ data: text({ mode: "json" }).notNull().$type()
2092
+ },
2093
+ (table) => [index("message_session_time_created_id_idx").on(table.session_id, table.time_created, table.id)]
2094
+ );
2095
+ var PartTable = sqliteTable(
2096
+ "part",
2097
+ {
2098
+ id: text().$type().primaryKey(),
2099
+ message_id: text().$type().notNull().references(() => MessageTable.id, { onDelete: "cascade" }),
2100
+ session_id: text().$type().notNull(),
2101
+ ...Timestamps,
2102
+ data: text({ mode: "json" }).notNull().$type()
2103
+ },
2104
+ (table) => [
2105
+ index("part_message_id_id_idx").on(table.message_id, table.id),
2106
+ index("part_session_idx").on(table.session_id)
2107
+ ]
2108
+ );
2109
+ var TodoTable = sqliteTable(
2110
+ "todo",
2111
+ {
2112
+ session_id: text().$type().notNull().references(() => SessionTable.id, { onDelete: "cascade" }),
2113
+ content: text().notNull(),
2114
+ status: text().notNull(),
2115
+ priority: text().notNull(),
2116
+ position: integer().notNull(),
2117
+ ...Timestamps
2118
+ },
2119
+ (table) => [
2120
+ primaryKey({ columns: [table.session_id, table.position] }),
2121
+ index("todo_session_idx").on(table.session_id)
2122
+ ]
2123
+ );
2124
+ var NamedError = class _NamedError extends Error {
2125
+ static create(name, data) {
2126
+ const schema = zod_default.object({
2127
+ name: zod_default.literal(name),
2128
+ data
2129
+ }).meta({
2130
+ ref: name
2131
+ });
2132
+ const result = class extends _NamedError {
2133
+ constructor(data2, options) {
2134
+ super(name, options);
2135
+ this.data = data2;
2136
+ this.name = name;
2137
+ }
2138
+ static Schema = schema;
2139
+ name = name;
2140
+ static isInstance(input) {
2141
+ return typeof input === "object" && "name" in input && input.name === name;
2142
+ }
2143
+ schema() {
2144
+ return schema;
2145
+ }
2146
+ toObject() {
2147
+ return {
2148
+ name,
2149
+ data: this.data
2150
+ };
2151
+ }
2152
+ };
2153
+ Object.defineProperty(result, "name", { value: name });
2154
+ return result;
2155
+ }
2156
+ static Unknown = _NamedError.create(
2157
+ "UnknownError",
2158
+ zod_default.object({
2159
+ message: zod_default.string()
2160
+ })
2161
+ );
2162
+ };
2163
+ var Lock;
2164
+ ((Lock2) => {
2165
+ const locks = /* @__PURE__ */ new Map();
2166
+ function get(key) {
2167
+ if (!locks.has(key)) {
2168
+ locks.set(key, {
2169
+ readers: 0,
2170
+ writer: false,
2171
+ waitingReaders: [],
2172
+ waitingWriters: []
2173
+ });
2174
+ }
2175
+ return locks.get(key);
2176
+ }
2177
+ function process(key) {
2178
+ const lock = locks.get(key);
2179
+ if (!lock || lock.writer || lock.readers > 0) return;
2180
+ if (lock.waitingWriters.length > 0) {
2181
+ const nextWriter = lock.waitingWriters.shift();
2182
+ nextWriter();
2183
+ return;
2184
+ }
2185
+ while (lock.waitingReaders.length > 0) {
2186
+ const nextReader = lock.waitingReaders.shift();
2187
+ nextReader();
2188
+ }
2189
+ if (lock.readers === 0 && !lock.writer && lock.waitingReaders.length === 0 && lock.waitingWriters.length === 0) {
2190
+ locks.delete(key);
2191
+ }
2192
+ }
2193
+ async function read(key) {
2194
+ const lock = get(key);
2195
+ return new Promise((resolve2) => {
2196
+ if (!lock.writer && lock.waitingWriters.length === 0) {
2197
+ lock.readers++;
2198
+ resolve2({
2199
+ [Symbol.dispose]: () => {
2200
+ lock.readers--;
2201
+ process(key);
2202
+ }
2203
+ });
2204
+ } else {
2205
+ lock.waitingReaders.push(() => {
2206
+ lock.readers++;
2207
+ resolve2({
2208
+ [Symbol.dispose]: () => {
2209
+ lock.readers--;
2210
+ process(key);
2211
+ }
2212
+ });
2213
+ });
2214
+ }
2215
+ });
2216
+ }
2217
+ Lock2.read = read;
2218
+ async function write(key) {
2219
+ const lock = get(key);
2220
+ return new Promise((resolve2) => {
2221
+ if (!lock.writer && lock.readers === 0) {
2222
+ lock.writer = true;
2223
+ resolve2({
2224
+ [Symbol.dispose]: () => {
2225
+ lock.writer = false;
2226
+ process(key);
2227
+ }
2228
+ });
2229
+ } else {
2230
+ lock.waitingWriters.push(() => {
2231
+ lock.writer = true;
2232
+ resolve2({
2233
+ [Symbol.dispose]: () => {
2234
+ lock.writer = false;
2235
+ process(key);
2236
+ }
2237
+ });
2238
+ });
2239
+ }
2240
+ });
2241
+ }
2242
+ Lock2.write = write;
2243
+ })(Lock || (Lock = {}));
2244
+ var Timestamps = {
2245
+ time_created: integer().notNull().$default(() => Date.now()),
2246
+ time_updated: integer().notNull().$onUpdate(() => Date.now())
2247
+ };
2248
+ var NotFoundError = NamedError.create(
2249
+ "NotFoundError",
2250
+ zod_default.object({
2251
+ message: zod_default.string()
2252
+ })
2253
+ );
2254
+ var Database;
2255
+ ((Database2) => {
2256
+ const INITIAL_MIGRATION = `-- project table
2257
+ CREATE TABLE IF NOT EXISTS "project" (
2258
+ "id" TEXT PRIMARY KEY NOT NULL,
2259
+ "worktree" TEXT NOT NULL,
2260
+ "vcs" TEXT,
2261
+ "name" TEXT,
2262
+ "icon_url" TEXT,
2263
+ "icon_color" TEXT,
2264
+ "time_created" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
2265
+ "time_updated" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
2266
+ "time_initialized" INTEGER,
2267
+ "sandboxes" TEXT NOT NULL DEFAULT '[]',
2268
+ "commands" TEXT
2269
+ );
2270
+
2271
+ -- session table
2272
+ CREATE TABLE IF NOT EXISTS "session" (
2273
+ "id" TEXT PRIMARY KEY NOT NULL,
2274
+ "project_id" TEXT NOT NULL REFERENCES "project"("id") ON DELETE CASCADE,
2275
+ "workspace_id" TEXT,
2276
+ "parent_id" TEXT,
2277
+ "slug" TEXT NOT NULL,
2278
+ "directory" TEXT NOT NULL,
2279
+ "title" TEXT NOT NULL,
2280
+ "version" TEXT NOT NULL,
2281
+ "share_url" TEXT,
2282
+ "summary_additions" INTEGER,
2283
+ "summary_deletions" INTEGER,
2284
+ "summary_files" INTEGER,
2285
+ "summary_diffs" TEXT,
2286
+ "revert" TEXT,
2287
+ "permission" TEXT,
2288
+ "time_created" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
2289
+ "time_updated" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
2290
+ "time_compacting" INTEGER,
2291
+ "time_archived" INTEGER
2292
+ );
2293
+ CREATE INDEX IF NOT EXISTS "session_project_idx" ON "session"("project_id");
2294
+ CREATE INDEX IF NOT EXISTS "session_workspace_idx" ON "session"("workspace_id");
2295
+ CREATE INDEX IF NOT EXISTS "session_parent_idx" ON "session"("parent_id");
2296
+
2297
+ -- message table
2298
+ CREATE TABLE IF NOT EXISTS "message" (
2299
+ "id" TEXT PRIMARY KEY NOT NULL,
2300
+ "session_id" TEXT NOT NULL REFERENCES "session"("id") ON DELETE CASCADE,
2301
+ "time_created" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
2302
+ "time_updated" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
2303
+ "data" TEXT NOT NULL
2304
+ );
2305
+ CREATE INDEX IF NOT EXISTS "message_session_time_created_id_idx" ON "message"("session_id", "time_created", "id");
2306
+
2307
+ -- part table
2308
+ CREATE TABLE IF NOT EXISTS "part" (
2309
+ "id" TEXT PRIMARY KEY NOT NULL,
2310
+ "message_id" TEXT NOT NULL REFERENCES "message"("id") ON DELETE CASCADE,
2311
+ "session_id" TEXT NOT NULL,
2312
+ "time_created" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
2313
+ "time_updated" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
2314
+ "data" TEXT NOT NULL
2315
+ );
2316
+ CREATE INDEX IF NOT EXISTS "part_message_id_id_idx" ON "part"("message_id", "id");
2317
+ CREATE INDEX IF NOT EXISTS "part_session_idx" ON "part"("session_id");
2318
+
2319
+ -- todo table
2320
+ CREATE TABLE IF NOT EXISTS "todo" (
2321
+ "session_id" TEXT NOT NULL REFERENCES "session"("id") ON DELETE CASCADE,
2322
+ "content" TEXT NOT NULL,
2323
+ "status" TEXT NOT NULL,
2324
+ "priority" TEXT NOT NULL,
2325
+ "position" INTEGER NOT NULL,
2326
+ "time_created" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
2327
+ "time_updated" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
2328
+ PRIMARY KEY ("session_id", "position")
2329
+ );
2330
+ CREATE INDEX IF NOT EXISTS "todo_session_idx" ON "todo"("session_id");
2331
+
2332
+ -- permission table
2333
+ CREATE TABLE IF NOT EXISTS "permission" (
2334
+ "project_id" TEXT PRIMARY KEY NOT NULL REFERENCES "project"("id") ON DELETE CASCADE,
2335
+ "time_created" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
2336
+ "time_updated" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
2337
+ "data" TEXT NOT NULL
2338
+ );
2339
+
2340
+ -- session_share table
2341
+ CREATE TABLE IF NOT EXISTS "session_share" (
2342
+ "session_id" TEXT PRIMARY KEY NOT NULL REFERENCES "session"("id") ON DELETE CASCADE,
2343
+ "id" TEXT NOT NULL,
2344
+ "secret" TEXT NOT NULL,
2345
+ "url" TEXT NOT NULL,
2346
+ "time_created" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
2347
+ "time_updated" INTEGER NOT NULL DEFAULT (unixepoch() * 1000)
2348
+ );
2349
+
2350
+ -- workspace table
2351
+ CREATE TABLE IF NOT EXISTS "workspace" (
2352
+ "id" TEXT PRIMARY KEY NOT NULL,
2353
+ "type" TEXT NOT NULL,
2354
+ "branch" TEXT,
2355
+ "name" TEXT,
2356
+ "directory" TEXT,
2357
+ "extra" TEXT,
2358
+ "project_id" TEXT NOT NULL REFERENCES "project"("id") ON DELETE CASCADE
2359
+ );
2360
+
2361
+ -- account table
2362
+ CREATE TABLE IF NOT EXISTS "account" (
2363
+ "id" TEXT PRIMARY KEY NOT NULL,
2364
+ "email" TEXT NOT NULL,
2365
+ "url" TEXT NOT NULL,
2366
+ "access_token" TEXT NOT NULL,
2367
+ "refresh_token" TEXT NOT NULL,
2368
+ "token_expiry" INTEGER,
2369
+ "time_created" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
2370
+ "time_updated" INTEGER NOT NULL DEFAULT (unixepoch() * 1000)
2371
+ );
2372
+
2373
+ -- account_state table
2374
+ CREATE TABLE IF NOT EXISTS "account_state" (
2375
+ "id" INTEGER PRIMARY KEY,
2376
+ "active_account_id" TEXT REFERENCES "account"("id") ON DELETE SET NULL,
2377
+ "active_org_id" TEXT
2378
+ );
2379
+
2380
+ -- control_account table (legacy)
2381
+ CREATE TABLE IF NOT EXISTS "control_account" (
2382
+ "email" TEXT NOT NULL,
2383
+ "url" TEXT NOT NULL,
2384
+ "access_token" TEXT NOT NULL,
2385
+ "refresh_token" TEXT NOT NULL,
2386
+ "token_expiry" INTEGER,
2387
+ "active" INTEGER NOT NULL DEFAULT 0,
2388
+ "time_created" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
2389
+ "time_updated" INTEGER NOT NULL DEFAULT (unixepoch() * 1000),
2390
+ PRIMARY KEY ("email", "url")
2391
+ );`;
2392
+ function getMigrations() {
2393
+ const entries = [
2394
+ { sql: INITIAL_MIGRATION, timestamp: Date.UTC(2024, 0, 1), name: "20240101000000_initial" }
2395
+ ];
2396
+ if (Flag.OPENCODE_SKIP_MIGRATIONS) {
2397
+ for (const item of entries) {
2398
+ item.sql = "select 1;";
2399
+ }
2400
+ }
2401
+ return entries;
2402
+ }
2403
+ Database2.getMigrations = getMigrations;
2404
+ })(Database || (Database = {}));
2405
+ var SqliteNoSqlDb = class {
2406
+ constructor(raw) {
2407
+ this.raw = raw;
2408
+ }
2409
+ insert(table, row) {
2410
+ const cols = Object.keys(row);
2411
+ const placeholders = cols.map(() => "?").join(", ");
2412
+ const sql2 = `INSERT INTO "${table}" (${cols.map((c) => `"${c}"`).join(", ")}) VALUES (${placeholders})`;
2413
+ this.raw.run(sql2, cols.map((c) => serialize(row[c])));
2414
+ }
2415
+ upsert(table, row, conflictKeys, updateFields) {
2416
+ const cols = Object.keys(row);
2417
+ const placeholders = cols.map(() => "?").join(", ");
2418
+ const conflict = conflictKeys.map((k) => `"${k}"`).join(", ");
2419
+ const updates = Object.keys(updateFields).map((k) => `"${k}" = ?`).join(", ");
2420
+ const sql2 = `INSERT INTO "${table}" (${cols.map((c) => `"${c}"`).join(", ")}) VALUES (${placeholders}) ON CONFLICT (${conflict}) DO UPDATE SET ${updates}`;
2421
+ const params = [
2422
+ ...cols.map((c) => serialize(row[c])),
2423
+ ...Object.keys(updateFields).map((k) => serialize(updateFields[k]))
2424
+ ];
2425
+ this.raw.run(sql2, params);
2426
+ }
2427
+ findOne(table, filter, options) {
2428
+ const fields = options?.select?.map((f) => `"${f}"`).join(", ") ?? "*";
2429
+ const { clause, params } = filter ? buildWhere(filter) : { clause: "", params: [] };
2430
+ const where = clause ? ` WHERE ${clause}` : "";
2431
+ const sql2 = `SELECT ${fields} FROM "${table}"${where} LIMIT 1`;
2432
+ const row = this.raw.get(sql2, params);
2433
+ return row ? deserializeRow(row) : void 0;
2434
+ }
2435
+ findMany(table, options) {
2436
+ const fields = options?.select?.map((f) => `"${f}"`).join(", ") ?? "*";
2437
+ const { clause, params } = options?.filter ? buildWhere(options.filter) : { clause: "", params: [] };
2438
+ const where = clause ? ` WHERE ${clause}` : "";
2439
+ let orderClause = "";
2440
+ if (options?.orderBy?.length) {
2441
+ const parts = options.orderBy.map(
2442
+ (o) => `"${o.field}" ${o.direction === "desc" ? "DESC" : "ASC"}`
2443
+ );
2444
+ orderClause = ` ORDER BY ${parts.join(", ")}`;
2445
+ }
2446
+ const limitClause = options?.limit != null ? ` LIMIT ${options.limit}` : "";
2447
+ const sql2 = `SELECT ${fields} FROM "${table}"${where}${orderClause}${limitClause}`;
2448
+ return this.raw.all(sql2, params).map(deserializeRow);
2449
+ }
2450
+ update(table, filter, set) {
2451
+ const setCols = Object.keys(set);
2452
+ const setClause = setCols.map((k) => `"${k}" = ?`).join(", ");
2453
+ const { clause, params } = buildWhere(filter);
2454
+ const sql2 = `UPDATE "${table}" SET ${setClause} WHERE ${clause} RETURNING *`;
2455
+ const setParams = setCols.map((k) => serialize(set[k]));
2456
+ const row = this.raw.get(sql2, [...setParams, ...params]);
2457
+ return row ? deserializeRow(row) : void 0;
2458
+ }
2459
+ remove(table, filter) {
2460
+ const { clause, params } = buildWhere(filter);
2461
+ this.raw.run(`DELETE FROM "${table}" WHERE ${clause}`, params);
2462
+ }
2463
+ transaction(fn) {
2464
+ this.raw.transaction(() => {
2465
+ fn(this);
2466
+ });
2467
+ }
2468
+ };
2469
+ function buildWhere(filter) {
2470
+ switch (filter.op) {
2471
+ case "eq":
2472
+ return { clause: `"${filter.field}" = ?`, params: [serialize(filter.value)] };
2473
+ case "ne":
2474
+ return { clause: `"${filter.field}" != ?`, params: [serialize(filter.value)] };
2475
+ case "gt":
2476
+ return { clause: `"${filter.field}" > ?`, params: [serialize(filter.value)] };
2477
+ case "gte":
2478
+ return { clause: `"${filter.field}" >= ?`, params: [serialize(filter.value)] };
2479
+ case "lt":
2480
+ return { clause: `"${filter.field}" < ?`, params: [serialize(filter.value)] };
2481
+ case "like":
2482
+ return { clause: `"${filter.field}" LIKE ?`, params: [filter.value] };
2483
+ case "isNull":
2484
+ return { clause: `"${filter.field}" IS NULL`, params: [] };
2485
+ case "in": {
2486
+ const placeholders = filter.values.map(() => "?").join(", ");
2487
+ return { clause: `"${filter.field}" IN (${placeholders})`, params: filter.values.map(serialize) };
2488
+ }
2489
+ case "and": {
2490
+ const parts = filter.conditions.map(buildWhere);
2491
+ return {
2492
+ clause: parts.map((p) => `(${p.clause})`).join(" AND "),
2493
+ params: parts.flatMap((p) => p.params)
2494
+ };
2495
+ }
2496
+ case "or": {
2497
+ const parts = filter.conditions.map(buildWhere);
2498
+ return {
2499
+ clause: parts.map((p) => `(${p.clause})`).join(" OR "),
2500
+ params: parts.flatMap((p) => p.params)
2501
+ };
2502
+ }
2503
+ }
2504
+ }
2505
+ function serialize(value) {
2506
+ if (value === void 0) return null;
2507
+ if (value === null) return null;
2508
+ if (typeof value === "object" && !(value instanceof Buffer) && !(value instanceof Uint8Array)) {
2509
+ return JSON.stringify(value);
2510
+ }
2511
+ return value;
2512
+ }
2513
+ function deserializeRow(row) {
2514
+ const result = {};
2515
+ for (const [key, value] of Object.entries(row)) {
2516
+ if (typeof value === "string" && (value.startsWith("{") || value.startsWith("["))) {
2517
+ try {
2518
+ result[key] = JSON.parse(value);
2519
+ } catch {
2520
+ result[key] = value;
2521
+ }
2522
+ } else {
2523
+ result[key] = value;
2524
+ }
2525
+ }
2526
+ return result;
2527
+ }
2528
+ var Storage;
2529
+ ((Storage2) => {
2530
+ const log = Log.create({ service: "storage" });
2531
+ Storage2.NotFoundError = NamedError.create(
2532
+ "NotFoundError",
2533
+ zod_default.object({
2534
+ message: zod_default.string()
2535
+ })
2536
+ );
2537
+ const MIGRATIONS = [
2538
+ async (context, dir) => {
2539
+ const project = resolve(dir, "../project");
2540
+ if (!await Filesystem.isDir(context, project)) return;
2541
+ const projectDirs = await Glob.scan(context, "*", {
2542
+ cwd: project,
2543
+ include: "all"
2544
+ });
2545
+ for (const projectDir of projectDirs) {
2546
+ const fullPath = join(project, projectDir);
2547
+ if (!await Filesystem.isDir(context, fullPath)) continue;
2548
+ log.info(`migrating project ${projectDir}`);
2549
+ let projectID = projectDir;
2550
+ const fullProjectDir = join(project, projectDir);
2551
+ let worktree = "/";
2552
+ if (projectID !== "global") {
2553
+ for (const msgFile of await Glob.scan(context, "storage/session/message/*/*.json", {
2554
+ cwd: join(project, projectDir),
2555
+ absolute: true
2556
+ })) {
2557
+ const json = await Filesystem.readJson(context, msgFile);
2558
+ worktree = json.path?.root;
2559
+ if (worktree) break;
2560
+ }
2561
+ if (!worktree) continue;
2562
+ if (!await Filesystem.isDir(context, worktree)) continue;
2563
+ const result = await context.git.run(["rev-list", "--max-parents=0", "--all"], {
2564
+ cwd: worktree
2565
+ });
2566
+ const [id] = result.text().split("\n").filter(Boolean).map((x) => x.trim()).toSorted();
2567
+ if (!id) continue;
2568
+ projectID = id;
2569
+ await Filesystem.writeJson(context, join(dir, "project", projectID + ".json"), {
2570
+ id,
2571
+ vcs: "git",
2572
+ worktree,
2573
+ time: {
2574
+ created: Date.now(),
2575
+ initialized: Date.now()
2576
+ }
2577
+ });
2578
+ log.info(`migrating sessions for project ${projectID}`);
2579
+ for (const sessionFile of await Glob.scan(context, "storage/session/info/*.json", {
2580
+ cwd: fullProjectDir,
2581
+ absolute: true
2582
+ })) {
2583
+ const dest = join(dir, "session", projectID, basename(sessionFile));
2584
+ log.info("copying", {
2585
+ sessionFile,
2586
+ dest
2587
+ });
2588
+ const session = await Filesystem.readJson(context, sessionFile);
2589
+ await Filesystem.writeJson(context, dest, session);
2590
+ log.info(`migrating messages for session ${session.id}`);
2591
+ for (const msgFile of await Glob.scan(context, `storage/session/message/${session.id}/*.json`, {
2592
+ cwd: fullProjectDir,
2593
+ absolute: true
2594
+ })) {
2595
+ const dest2 = join(dir, "message", session.id, basename(msgFile));
2596
+ log.info("copying", {
2597
+ msgFile,
2598
+ dest: dest2
2599
+ });
2600
+ const message = await Filesystem.readJson(context, msgFile);
2601
+ await Filesystem.writeJson(context, dest2, message);
2602
+ log.info(`migrating parts for message ${message.id}`);
2603
+ for (const partFile of await Glob.scan(context, `storage/session/part/${session.id}/${message.id}/*.json`, {
2604
+ cwd: fullProjectDir,
2605
+ absolute: true
2606
+ })) {
2607
+ const dest3 = join(dir, "part", message.id, basename(partFile));
2608
+ const part = await Filesystem.readJson(context, partFile);
2609
+ log.info("copying", {
2610
+ partFile,
2611
+ dest: dest3
2612
+ });
2613
+ await Filesystem.writeJson(context, dest3, part);
2614
+ }
2615
+ }
2616
+ }
2617
+ }
2618
+ }
2619
+ },
2620
+ async (context, dir) => {
2621
+ for (const item of await Glob.scan(context, "session/*/*.json", {
2622
+ cwd: dir,
2623
+ absolute: true
2624
+ })) {
2625
+ const session = await Filesystem.readJson(context, item);
2626
+ if (!session.projectID) continue;
2627
+ if (!session.summary?.diffs) continue;
2628
+ const { diffs } = session.summary;
2629
+ await Filesystem.write(context, join(dir, "session_diff", session.id + ".json"), JSON.stringify(diffs));
2630
+ await Filesystem.writeJson(context, join(dir, "session", session.projectID, session.id + ".json"), {
2631
+ ...session,
2632
+ summary: {
2633
+ additions: diffs.reduce((sum, x) => sum + x.additions, 0),
2634
+ deletions: diffs.reduce((sum, x) => sum + x.deletions, 0)
2635
+ }
2636
+ });
2637
+ }
2638
+ }
2639
+ ];
2640
+ async function getDir(context) {
2641
+ const dir = join(context.dataPath, "storage");
2642
+ const migration = await Filesystem.readJson(context, join(dir, "migration")).then((x) => parseInt(x)).catch(() => 0);
2643
+ for (let index2 = migration; index2 < MIGRATIONS.length; index2++) {
2644
+ log.info("running migration", { index: index2 });
2645
+ const migrationFn = MIGRATIONS[index2];
2646
+ await migrationFn(context, dir).catch(() => log.error("failed to run migration", { index: index2 }));
2647
+ await Filesystem.write(context, join(dir, "migration"), (index2 + 1).toString());
2648
+ }
2649
+ return dir;
2650
+ }
2651
+ async function remove(context, key) {
2652
+ const dir = await getDir(context);
2653
+ const target = join(dir, ...key) + ".json";
2654
+ return withErrorHandling(async () => {
2655
+ await fs.unlink(target).catch(() => {
2656
+ });
2657
+ });
2658
+ }
2659
+ Storage2.remove = remove;
2660
+ async function read(context, key) {
2661
+ const dir = await getDir(context);
2662
+ const target = join(dir, ...key) + ".json";
2663
+ return withErrorHandling(async () => {
2664
+ var _stack = [];
2665
+ try {
2666
+ const _ = __using(_stack, await Lock.read(target));
2667
+ const result = await Filesystem.readJson(context, target);
2668
+ return result;
2669
+ } catch (_2) {
2670
+ var _error = _2, _hasError = true;
2671
+ } finally {
2672
+ __callDispose(_stack, _error, _hasError);
2673
+ }
2674
+ });
2675
+ }
2676
+ Storage2.read = read;
2677
+ async function update(context, key, fn) {
2678
+ const dir = await getDir(context);
2679
+ const target = join(dir, ...key) + ".json";
2680
+ return withErrorHandling(async () => {
2681
+ var _stack = [];
2682
+ try {
2683
+ const _ = __using(_stack, await Lock.write(target));
2684
+ const content = await Filesystem.readJson(context, target);
2685
+ fn(content);
2686
+ await Filesystem.writeJson(context, target, content);
2687
+ return content;
2688
+ } catch (_2) {
2689
+ var _error = _2, _hasError = true;
2690
+ } finally {
2691
+ __callDispose(_stack, _error, _hasError);
2692
+ }
2693
+ });
2694
+ }
2695
+ Storage2.update = update;
2696
+ async function write(context, key, content) {
2697
+ const dir = await getDir(context);
2698
+ const target = join(dir, ...key) + ".json";
2699
+ return withErrorHandling(async () => {
2700
+ var _stack = [];
2701
+ try {
2702
+ const _ = __using(_stack, await Lock.write(target));
2703
+ await Filesystem.writeJson(context, target, content);
2704
+ } catch (_2) {
2705
+ var _error = _2, _hasError = true;
2706
+ } finally {
2707
+ __callDispose(_stack, _error, _hasError);
2708
+ }
2709
+ });
2710
+ }
2711
+ Storage2.write = write;
2712
+ async function withErrorHandling(body) {
2713
+ return body().catch((e) => {
2714
+ if (!(e instanceof Error)) throw e;
2715
+ const errnoException = e;
2716
+ if (errnoException.code === "ENOENT") {
2717
+ throw new Storage2.NotFoundError({ message: `Resource not found: ${errnoException.path}` });
2718
+ }
2719
+ throw e;
2720
+ });
2721
+ }
2722
+ async function list(context, prefix) {
2723
+ const dir = await getDir(context);
2724
+ try {
2725
+ const result = await Glob.scan(context, "**/*", {
2726
+ cwd: join(dir, ...prefix),
2727
+ include: "file"
2728
+ }).then((results) => results.map((x) => [...prefix, ...x.slice(0, -5).split(sep)]));
2729
+ result.sort();
2730
+ return result;
2731
+ } catch {
2732
+ return [];
2733
+ }
2734
+ }
2735
+ Storage2.list = list;
2736
+ })(Storage || (Storage = {}));
2737
+
2738
+ export {
2739
+ join,
2740
+ dirname,
2741
+ basename,
2742
+ extname,
2743
+ isAbsolute,
2744
+ relative,
2745
+ resolve,
2746
+ Filesystem,
2747
+ Log,
2748
+ Flag,
2749
+ ProjectID,
2750
+ ProjectTable,
2751
+ Protected,
2752
+ FileIgnore,
2753
+ FileTimeService,
2754
+ Project,
2755
+ SessionTable,
2756
+ MessageTable,
2757
+ PartTable,
2758
+ TodoTable,
2759
+ NamedError,
2760
+ Timestamps,
2761
+ NotFoundError,
2762
+ Database,
2763
+ SqliteNoSqlDb,
2764
+ Storage
2765
+ };