@akanjs/cli 2.1.1-rc.1 → 2.1.1-rc.2

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.
@@ -1,328 +1,6 @@
1
1
  // @bun
2
- var __create = Object.create;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- function __accessProp(key) {
8
- return this[key];
9
- }
10
- var __toESMCache_node;
11
- var __toESMCache_esm;
12
- var __toESM = (mod, isNodeMode, target) => {
13
- var canCache = mod != null && typeof mod === "object";
14
- if (canCache) {
15
- var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
- var cached = cache.get(mod);
17
- if (cached)
18
- return cached;
19
- }
20
- target = mod != null ? __create(__getProtoOf(mod)) : {};
21
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
- for (let key of __getOwnPropNames(mod))
23
- if (!__hasOwnProp.call(to, key))
24
- __defProp(to, key, {
25
- get: __accessProp.bind(mod, key),
26
- enumerable: true
27
- });
28
- if (canCache)
29
- cache.set(mod, to);
30
- return to;
31
- };
32
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
33
2
  var __require = import.meta.require;
34
3
 
35
- // node_modules/dayjs/dayjs.min.js
36
- var require_dayjs_min = __commonJS((exports, module) => {
37
- (function(t, e) {
38
- typeof exports == "object" && typeof module != "undefined" ? module.exports = e() : typeof define == "function" && define.amd ? define(e) : (t = typeof globalThis != "undefined" ? globalThis : t || self).dayjs = e();
39
- })(exports, function() {
40
- var t = 1000, e = 60000, n = 3600000, r = "millisecond", i = "second", s = "minute", u = "hour", a = "day", o = "week", c = "month", f = "quarter", h = "year", d = "date", l = "Invalid Date", $2 = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y = /\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(t2) {
41
- var e2 = ["th", "st", "nd", "rd"], n2 = t2 % 100;
42
- return "[" + t2 + (e2[(n2 - 20) % 10] || e2[n2] || e2[0]) + "]";
43
- } }, m = function(t2, e2, n2) {
44
- var r2 = String(t2);
45
- return !r2 || r2.length >= e2 ? t2 : "" + Array(e2 + 1 - r2.length).join(n2) + t2;
46
- }, v = { s: m, z: function(t2) {
47
- var e2 = -t2.utcOffset(), n2 = Math.abs(e2), r2 = Math.floor(n2 / 60), i2 = n2 % 60;
48
- return (e2 <= 0 ? "+" : "-") + m(r2, 2, "0") + ":" + m(i2, 2, "0");
49
- }, m: function t2(e2, n2) {
50
- if (e2.date() < n2.date())
51
- return -t2(n2, e2);
52
- var r2 = 12 * (n2.year() - e2.year()) + (n2.month() - e2.month()), i2 = e2.clone().add(r2, c), s2 = n2 - i2 < 0, u2 = e2.clone().add(r2 + (s2 ? -1 : 1), c);
53
- return +(-(r2 + (n2 - i2) / (s2 ? i2 - u2 : u2 - i2)) || 0);
54
- }, a: function(t2) {
55
- return t2 < 0 ? Math.ceil(t2) || 0 : Math.floor(t2);
56
- }, p: function(t2) {
57
- return { M: c, y: h, w: o, d: a, D: d, h: u, m: s, s: i, ms: r, Q: f }[t2] || String(t2 || "").toLowerCase().replace(/s$/, "");
58
- }, u: function(t2) {
59
- return t2 === undefined;
60
- } }, g = "en", D = {};
61
- D[g] = M;
62
- var p = "$isDayjsObject", S = function(t2) {
63
- return t2 instanceof _ || !(!t2 || !t2[p]);
64
- }, w = function t2(e2, n2, r2) {
65
- var i2;
66
- if (!e2)
67
- return g;
68
- if (typeof e2 == "string") {
69
- var s2 = e2.toLowerCase();
70
- D[s2] && (i2 = s2), n2 && (D[s2] = n2, i2 = s2);
71
- var u2 = e2.split("-");
72
- if (!i2 && u2.length > 1)
73
- return t2(u2[0]);
74
- } else {
75
- var a2 = e2.name;
76
- D[a2] = e2, i2 = a2;
77
- }
78
- return !r2 && i2 && (g = i2), i2 || !r2 && g;
79
- }, O = function(t2, e2) {
80
- if (S(t2))
81
- return t2.clone();
82
- var n2 = typeof e2 == "object" ? e2 : {};
83
- return n2.date = t2, n2.args = arguments, new _(n2);
84
- }, b = v;
85
- b.l = w, b.i = S, b.w = function(t2, e2) {
86
- return O(t2, { locale: e2.$L, utc: e2.$u, x: e2.$x, $offset: e2.$offset });
87
- };
88
- var _ = function() {
89
- function M2(t2) {
90
- this.$L = w(t2.locale, null, true), this.parse(t2), this.$x = this.$x || t2.x || {}, this[p] = true;
91
- }
92
- var m2 = M2.prototype;
93
- return m2.parse = function(t2) {
94
- this.$d = function(t3) {
95
- var { date: e2, utc: n2 } = t3;
96
- if (e2 === null)
97
- return new Date(NaN);
98
- if (b.u(e2))
99
- return new Date;
100
- if (e2 instanceof Date)
101
- return new Date(e2);
102
- if (typeof e2 == "string" && !/Z$/i.test(e2)) {
103
- var r2 = e2.match($2);
104
- if (r2) {
105
- var i2 = r2[2] - 1 || 0, s2 = (r2[7] || "0").substring(0, 3);
106
- return n2 ? new Date(Date.UTC(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2)) : new Date(r2[1], i2, r2[3] || 1, r2[4] || 0, r2[5] || 0, r2[6] || 0, s2);
107
- }
108
- }
109
- return new Date(e2);
110
- }(t2), this.init();
111
- }, m2.init = function() {
112
- var t2 = this.$d;
113
- this.$y = t2.getFullYear(), this.$M = t2.getMonth(), this.$D = t2.getDate(), this.$W = t2.getDay(), this.$H = t2.getHours(), this.$m = t2.getMinutes(), this.$s = t2.getSeconds(), this.$ms = t2.getMilliseconds();
114
- }, m2.$utils = function() {
115
- return b;
116
- }, m2.isValid = function() {
117
- return !(this.$d.toString() === l);
118
- }, m2.isSame = function(t2, e2) {
119
- var n2 = O(t2);
120
- return this.startOf(e2) <= n2 && n2 <= this.endOf(e2);
121
- }, m2.isAfter = function(t2, e2) {
122
- return O(t2) < this.startOf(e2);
123
- }, m2.isBefore = function(t2, e2) {
124
- return this.endOf(e2) < O(t2);
125
- }, m2.$g = function(t2, e2, n2) {
126
- return b.u(t2) ? this[e2] : this.set(n2, t2);
127
- }, m2.unix = function() {
128
- return Math.floor(this.valueOf() / 1000);
129
- }, m2.valueOf = function() {
130
- return this.$d.getTime();
131
- }, m2.startOf = function(t2, e2) {
132
- var n2 = this, r2 = !!b.u(e2) || e2, f2 = b.p(t2), l2 = function(t3, e3) {
133
- var i2 = b.w(n2.$u ? Date.UTC(n2.$y, e3, t3) : new Date(n2.$y, e3, t3), n2);
134
- return r2 ? i2 : i2.endOf(a);
135
- }, $3 = function(t3, e3) {
136
- return b.w(n2.toDate()[t3].apply(n2.toDate("s"), (r2 ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e3)), n2);
137
- }, y2 = this.$W, M3 = this.$M, m3 = this.$D, v2 = "set" + (this.$u ? "UTC" : "");
138
- switch (f2) {
139
- case h:
140
- return r2 ? l2(1, 0) : l2(31, 11);
141
- case c:
142
- return r2 ? l2(1, M3) : l2(0, M3 + 1);
143
- case o:
144
- var g2 = this.$locale().weekStart || 0, D2 = (y2 < g2 ? y2 + 7 : y2) - g2;
145
- return l2(r2 ? m3 - D2 : m3 + (6 - D2), M3);
146
- case a:
147
- case d:
148
- return $3(v2 + "Hours", 0);
149
- case u:
150
- return $3(v2 + "Minutes", 1);
151
- case s:
152
- return $3(v2 + "Seconds", 2);
153
- case i:
154
- return $3(v2 + "Milliseconds", 3);
155
- default:
156
- return this.clone();
157
- }
158
- }, m2.endOf = function(t2) {
159
- return this.startOf(t2, false);
160
- }, m2.$set = function(t2, e2) {
161
- var n2, o2 = b.p(t2), f2 = "set" + (this.$u ? "UTC" : ""), l2 = (n2 = {}, n2[a] = f2 + "Date", n2[d] = f2 + "Date", n2[c] = f2 + "Month", n2[h] = f2 + "FullYear", n2[u] = f2 + "Hours", n2[s] = f2 + "Minutes", n2[i] = f2 + "Seconds", n2[r] = f2 + "Milliseconds", n2)[o2], $3 = o2 === a ? this.$D + (e2 - this.$W) : e2;
162
- if (o2 === c || o2 === h) {
163
- var y2 = this.clone().set(d, 1);
164
- y2.$d[l2]($3), y2.init(), this.$d = y2.set(d, Math.min(this.$D, y2.daysInMonth())).$d;
165
- } else
166
- l2 && this.$d[l2]($3);
167
- return this.init(), this;
168
- }, m2.set = function(t2, e2) {
169
- return this.clone().$set(t2, e2);
170
- }, m2.get = function(t2) {
171
- return this[b.p(t2)]();
172
- }, m2.add = function(r2, f2) {
173
- var d2, l2 = this;
174
- r2 = Number(r2);
175
- var $3 = b.p(f2), y2 = function(t2) {
176
- var e2 = O(l2);
177
- return b.w(e2.date(e2.date() + Math.round(t2 * r2)), l2);
178
- };
179
- if ($3 === c)
180
- return this.set(c, this.$M + r2);
181
- if ($3 === h)
182
- return this.set(h, this.$y + r2);
183
- if ($3 === a)
184
- return y2(1);
185
- if ($3 === o)
186
- return y2(7);
187
- var M3 = (d2 = {}, d2[s] = e, d2[u] = n, d2[i] = t, d2)[$3] || 1, m3 = this.$d.getTime() + r2 * M3;
188
- return b.w(m3, this);
189
- }, m2.subtract = function(t2, e2) {
190
- return this.add(-1 * t2, e2);
191
- }, m2.format = function(t2) {
192
- var e2 = this, n2 = this.$locale();
193
- if (!this.isValid())
194
- return n2.invalidDate || l;
195
- var r2 = t2 || "YYYY-MM-DDTHH:mm:ssZ", i2 = b.z(this), s2 = this.$H, u2 = this.$m, a2 = this.$M, o2 = n2.weekdays, c2 = n2.months, f2 = n2.meridiem, h2 = function(t3, n3, i3, s3) {
196
- return t3 && (t3[n3] || t3(e2, r2)) || i3[n3].slice(0, s3);
197
- }, d2 = function(t3) {
198
- return b.s(s2 % 12 || 12, t3, "0");
199
- }, $3 = f2 || function(t3, e3, n3) {
200
- var r3 = t3 < 12 ? "AM" : "PM";
201
- return n3 ? r3.toLowerCase() : r3;
202
- };
203
- return r2.replace(y, function(t3, r3) {
204
- return r3 || function(t4) {
205
- switch (t4) {
206
- case "YY":
207
- return String(e2.$y).slice(-2);
208
- case "YYYY":
209
- return b.s(e2.$y, 4, "0");
210
- case "M":
211
- return a2 + 1;
212
- case "MM":
213
- return b.s(a2 + 1, 2, "0");
214
- case "MMM":
215
- return h2(n2.monthsShort, a2, c2, 3);
216
- case "MMMM":
217
- return h2(c2, a2);
218
- case "D":
219
- return e2.$D;
220
- case "DD":
221
- return b.s(e2.$D, 2, "0");
222
- case "d":
223
- return String(e2.$W);
224
- case "dd":
225
- return h2(n2.weekdaysMin, e2.$W, o2, 2);
226
- case "ddd":
227
- return h2(n2.weekdaysShort, e2.$W, o2, 3);
228
- case "dddd":
229
- return o2[e2.$W];
230
- case "H":
231
- return String(s2);
232
- case "HH":
233
- return b.s(s2, 2, "0");
234
- case "h":
235
- return d2(1);
236
- case "hh":
237
- return d2(2);
238
- case "a":
239
- return $3(s2, u2, true);
240
- case "A":
241
- return $3(s2, u2, false);
242
- case "m":
243
- return String(u2);
244
- case "mm":
245
- return b.s(u2, 2, "0");
246
- case "s":
247
- return String(e2.$s);
248
- case "ss":
249
- return b.s(e2.$s, 2, "0");
250
- case "SSS":
251
- return b.s(e2.$ms, 3, "0");
252
- case "Z":
253
- return i2;
254
- }
255
- return null;
256
- }(t3) || i2.replace(":", "");
257
- });
258
- }, m2.utcOffset = function() {
259
- return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
260
- }, m2.diff = function(r2, d2, l2) {
261
- var $3, y2 = this, M3 = b.p(d2), m3 = O(r2), v2 = (m3.utcOffset() - this.utcOffset()) * e, g2 = this - m3, D2 = function() {
262
- return b.m(y2, m3);
263
- };
264
- switch (M3) {
265
- case h:
266
- $3 = D2() / 12;
267
- break;
268
- case c:
269
- $3 = D2();
270
- break;
271
- case f:
272
- $3 = D2() / 3;
273
- break;
274
- case o:
275
- $3 = (g2 - v2) / 604800000;
276
- break;
277
- case a:
278
- $3 = (g2 - v2) / 86400000;
279
- break;
280
- case u:
281
- $3 = g2 / n;
282
- break;
283
- case s:
284
- $3 = g2 / e;
285
- break;
286
- case i:
287
- $3 = g2 / t;
288
- break;
289
- default:
290
- $3 = g2;
291
- }
292
- return l2 ? $3 : b.a($3);
293
- }, m2.daysInMonth = function() {
294
- return this.endOf(c).$D;
295
- }, m2.$locale = function() {
296
- return D[this.$L];
297
- }, m2.locale = function(t2, e2) {
298
- if (!t2)
299
- return this.$L;
300
- var n2 = this.clone(), r2 = w(t2, e2, true);
301
- return r2 && (n2.$L = r2), n2;
302
- }, m2.clone = function() {
303
- return b.w(this.$d, this);
304
- }, m2.toDate = function() {
305
- return new Date(this.valueOf());
306
- }, m2.toJSON = function() {
307
- return this.isValid() ? this.toISOString() : null;
308
- }, m2.toISOString = function() {
309
- return this.$d.toISOString();
310
- }, m2.toString = function() {
311
- return this.$d.toUTCString();
312
- }, M2;
313
- }(), Y = _.prototype;
314
- return O.prototype = Y, [["$ms", r], ["$s", i], ["$m", s], ["$H", u], ["$W", a], ["$M", c], ["$y", h], ["$D", d]].forEach(function(t2) {
315
- Y[t2[1]] = function(e2) {
316
- return this.$g(e2, t2[0], t2[1]);
317
- };
318
- }), O.extend = function(t2, e2) {
319
- return t2.$i || (t2(e2, _, O), t2.$i = true), O;
320
- }, O.locale = w, O.isDayjs = S, O.unix = function(t2) {
321
- return O(1000 * t2);
322
- }, O.en = D[g], O.Ls = D, O.p = {}, O;
323
- });
324
- });
325
-
326
4
  // pkgs/@akanjs/devkit/incrementalBuilder/incrementalBuilder.proc.ts
327
5
  import path37 from "path";
328
6
 
@@ -339,10 +17,7 @@ import { ChatOpenAI } from "@langchain/openai";
339
17
  import { Logger as Logger2 } from "akanjs/common";
340
18
  import chalk from "chalk";
341
19
 
342
- // pkgs/@akanjs/devkit/auth.ts
343
- import { mkdir } from "fs/promises";
344
-
345
- // pkgs/@akanjs/devkit/constants.ts
20
+ // pkgs/@akanjs/devkit/cloud/constants.ts
346
21
  var basePath = `${Bun.env.HOME ?? Bun.env.USERPROFILE}/.akan`;
347
22
  var configPath = `${basePath}/config.json`;
348
23
  var akanCloudHost = process.env.AKAN_PUBLIC_OPERATION_MODE === "local" ? "http://localhost" : "https://cloud.akanjs.com";
@@ -350,9 +25,14 @@ var akanCloudUrl = `${akanCloudHost}${process.env.AKAN_PUBLIC_OPERATION_MODE ===
350
25
  var defaultHostConfig = {};
351
26
  var defaultAkanGlobalConfig = {
352
27
  cloudHost: {},
28
+ remoteEnvServers: {},
353
29
  llm: null
354
30
  };
355
31
 
32
+ // pkgs/@akanjs/devkit/cloud/globalConfig.ts
33
+ import { mkdir } from "fs/promises";
34
+ import dayjs from "dayjs";
35
+
356
36
  // pkgs/@akanjs/devkit/fileSys.ts
357
37
  import { stat } from "fs/promises";
358
38
  import { Logger } from "akanjs/common";
@@ -391,35 +71,198 @@ class FileSys {
391
71
  }
392
72
  }
393
73
 
394
- // pkgs/@akanjs/devkit/auth.ts
395
- var getAkanGlobalConfig = async () => {
396
- const exists = await FileSys.fileExists(configPath);
397
- const akanConfig = exists ? await FileSys.readJson(configPath) : defaultAkanGlobalConfig;
398
- return akanConfig;
399
- };
400
- var setAkanGlobalConfig = async (akanConfig) => {
401
- await mkdir(basePath, { recursive: true });
402
- await Bun.write(configPath, JSON.stringify(akanConfig, null, 2));
403
- };
404
- var getHostConfig = async (host = akanCloudHost) => {
405
- const akanConfig = await getAkanGlobalConfig();
406
- return akanConfig.cloudHost[host] ?? defaultHostConfig;
407
- };
408
- var setHostConfig = async (host = akanCloudHost, config = {}) => {
409
- const akanConfig = await getAkanGlobalConfig();
410
- akanConfig.cloudHost[host] = config;
411
- await setAkanGlobalConfig(akanConfig);
412
- };
413
- var getSelf = async (token) => {
414
- try {
415
- const res = await fetch(`${akanCloudUrl}/user/getSelf`, { headers: { Authorization: `Bearer ${token}` } });
416
- const user = await res.json();
417
- return user;
418
- } catch (e) {
419
- return null;
74
+ // pkgs/@akanjs/devkit/cloud/globalConfig.ts
75
+ class GlobalConfig {
76
+ static async#getAkanGlobalConfig() {
77
+ const exists = await FileSys.fileExists(configPath);
78
+ const akanConfig = exists ? await FileSys.readJson(configPath) : {};
79
+ return {
80
+ ...defaultAkanGlobalConfig,
81
+ ...akanConfig,
82
+ cloudHost: akanConfig.cloudHost ?? defaultAkanGlobalConfig.cloudHost,
83
+ remoteEnvServers: akanConfig.remoteEnvServers ?? defaultAkanGlobalConfig.remoteEnvServers
84
+ };
420
85
  }
421
- };
86
+ static async#setAkanGlobalConfig(akanConfig) {
87
+ await mkdir(basePath, { recursive: true });
88
+ await Bun.write(configPath, JSON.stringify(akanConfig, null, 2));
89
+ }
90
+ static async getHostConfig(host = akanCloudHost) {
91
+ const akanConfig = await GlobalConfig.#getAkanGlobalConfig();
92
+ return GlobalConfig.toHostConfig(akanConfig.cloudHost[host] ?? defaultHostConfig);
93
+ }
94
+ static async setHostConfig(host = akanCloudHost, config = {}) {
95
+ const akanConfig = await GlobalConfig.#getAkanGlobalConfig();
96
+ akanConfig.cloudHost[host] = GlobalConfig.toHostConfigDto(config);
97
+ await GlobalConfig.#setAkanGlobalConfig(akanConfig);
98
+ }
99
+ static async getLlmConfig() {
100
+ const akanConfig = await GlobalConfig.#getAkanGlobalConfig();
101
+ return akanConfig.llm ?? null;
102
+ }
103
+ static async setLlmConfig(llmConfig) {
104
+ const akanConfig = await GlobalConfig.#getAkanGlobalConfig();
105
+ await GlobalConfig.#setAkanGlobalConfig({ ...akanConfig, llm: llmConfig });
106
+ }
107
+ static async getRemoteEnvServers() {
108
+ const akanConfig = await GlobalConfig.#getAkanGlobalConfig();
109
+ return akanConfig.remoteEnvServers;
110
+ }
111
+ static async setRemoteEnvServer(name, config) {
112
+ const akanConfig = await GlobalConfig.#getAkanGlobalConfig();
113
+ await GlobalConfig.#setAkanGlobalConfig({
114
+ ...akanConfig,
115
+ remoteEnvServers: {
116
+ ...akanConfig.remoteEnvServers,
117
+ [name]: config
118
+ }
119
+ });
120
+ }
121
+ static async removeRemoteEnvServer(name) {
122
+ const akanConfig = await GlobalConfig.#getAkanGlobalConfig();
123
+ const { [name]: _, ...remoteEnvServers } = akanConfig.remoteEnvServers;
124
+ await GlobalConfig.#setAkanGlobalConfig({
125
+ ...akanConfig,
126
+ remoteEnvServers
127
+ });
128
+ }
129
+ static needRefreshToken(accessToken) {
130
+ return !!accessToken?.expiresAt?.isBefore(dayjs().add(1, "hour"));
131
+ }
132
+ static toAccessToken(accessToken) {
133
+ return {
134
+ jwt: accessToken.jwt,
135
+ refreshToken: accessToken.refreshToken ?? null,
136
+ expiresAt: accessToken.expiresAt ? dayjs(accessToken.expiresAt) : null
137
+ };
138
+ }
139
+ static toAccessTokenDto(accessToken) {
140
+ return {
141
+ jwt: accessToken.jwt,
142
+ refreshToken: accessToken.refreshToken ?? null,
143
+ expiresAt: accessToken.expiresAt?.toString() ?? null
144
+ };
145
+ }
146
+ static toHostConfigDto(hostConfig) {
147
+ return {
148
+ auth: {
149
+ accessToken: hostConfig.auth?.accessToken ? GlobalConfig.toAccessTokenDto(hostConfig.auth.accessToken) : undefined,
150
+ self: hostConfig.auth?.self
151
+ }
152
+ };
153
+ }
154
+ static toHostConfig(hostConfigDto) {
155
+ return {
156
+ auth: {
157
+ accessToken: hostConfigDto.auth?.accessToken ? GlobalConfig.toAccessToken(hostConfigDto.auth.accessToken) : undefined,
158
+ self: hostConfigDto.auth?.self
159
+ }
160
+ };
161
+ }
162
+ }
163
+
164
+ // pkgs/@akanjs/devkit/cloud/cloudApi.ts
165
+ class HttpClient {
166
+ baseUrl;
167
+ headers = {};
168
+ constructor(baseUrl, headers = {}) {
169
+ this.baseUrl = baseUrl;
170
+ this.headers = headers;
171
+ }
172
+ async get(url, { headers } = {}) {
173
+ const response = await fetch(`${this.baseUrl}${url}`, {
174
+ headers: {
175
+ "Content-Type": "application/json",
176
+ ...this.headers,
177
+ ...headers
178
+ }
179
+ });
180
+ return response.json();
181
+ }
182
+ async getFile(url, localPath, headers) {
183
+ const response = await fetch(`${this.baseUrl}${url}`, {
184
+ headers: { ...this.headers, ...headers }
185
+ });
186
+ if (!response.ok)
187
+ throw new Error(`Failed to download file: ${response.status} ${response.statusText}`);
188
+ await Bun.write(localPath, response);
189
+ }
190
+ async post(url, data, { headers } = {}) {
191
+ const isFormData = data instanceof FormData;
192
+ const response = await fetch(`${this.baseUrl}${url}`, {
193
+ method: "POST",
194
+ body: isFormData ? data : JSON.stringify(data),
195
+ headers: isFormData ? { ...this.headers, ...headers } : { "Content-Type": "application/json", ...this.headers, ...headers }
196
+ });
197
+ return response.json();
198
+ }
199
+ setHeaders(headers) {
200
+ Object.assign(this.headers, headers);
201
+ return this;
202
+ }
203
+ }
422
204
 
205
+ class CloudApi {
206
+ #api;
207
+ #accessToken = null;
208
+ static async fromHost(host) {
209
+ const hostConfig = await GlobalConfig.getHostConfig(host);
210
+ return new CloudApi(hostConfig);
211
+ }
212
+ constructor(hostConfig) {
213
+ const host = akanCloudHost;
214
+ this.#api = new HttpClient(`${host}/api`);
215
+ this.#accessToken = hostConfig.auth?.accessToken ?? null;
216
+ if (this.#accessToken && !GlobalConfig.needRefreshToken(this.#accessToken))
217
+ this.#api.setHeaders({
218
+ Authorization: `Bearer ${this.#accessToken.jwt}`
219
+ });
220
+ }
221
+ async uploadEnv(devProjectId, file) {
222
+ const formData = new FormData;
223
+ formData.append("devProjectId", devProjectId);
224
+ formData.append("file", file);
225
+ const data = await this.#api.post(`/uploadEnv/${devProjectId}`, formData);
226
+ return data;
227
+ }
228
+ async downloadEnv(devProjectId, localPath) {
229
+ await this.#api.getFile(`/downloadEnv/${devProjectId}`, localPath);
230
+ }
231
+ async getRemoteAuthToken(remoteId) {
232
+ try {
233
+ if (this.#accessToken) {
234
+ if (GlobalConfig.needRefreshToken(this.#accessToken))
235
+ return await this.refreshAuthToken();
236
+ else
237
+ return await this.refreshAuthToken();
238
+ }
239
+ const accessToken = await this.#api.get(`/getRemoteAuthToken/${remoteId}`);
240
+ this.#accessToken = GlobalConfig.toAccessToken(accessToken);
241
+ this.#api.setHeaders({
242
+ Authorization: `Bearer ${this.#accessToken.jwt}`
243
+ });
244
+ return this.#accessToken;
245
+ } catch (_) {
246
+ return null;
247
+ }
248
+ }
249
+ async refreshAuthToken() {
250
+ const response = await this.#api.post(`/refreshRemoteAuthToken`, {
251
+ refreshToken: this.#accessToken?.refreshToken
252
+ });
253
+ this.#accessToken = GlobalConfig.toAccessToken(response);
254
+ this.#api.setHeaders({ Authorization: `Bearer ${this.#accessToken.jwt}` });
255
+ return this.#accessToken;
256
+ }
257
+ async getRemoteSelf() {
258
+ try {
259
+ const data = await this.#api.get(`/getRemoteSelf`);
260
+ return data;
261
+ } catch {
262
+ return null;
263
+ }
264
+ }
265
+ }
423
266
  // pkgs/@akanjs/devkit/spinner.ts
424
267
  import ora from "ora";
425
268
 
@@ -482,12 +325,18 @@ class Spinner {
482
325
 
483
326
  // pkgs/@akanjs/devkit/aiEditor.ts
484
327
  var MAX_ASK_TRY = 300;
485
- var supportedLlmModels = ["deepseek-chat", "deepseek-reasoner"];
328
+ var supportedLlmModels = [
329
+ "deepseek-chat",
330
+ "deepseek-reasoner"
331
+ ];
486
332
 
487
333
  class AiSession {
488
334
  static #cacheDir = "node_modules/.cache/akan/aiSession";
489
335
  static #chat = null;
490
- static async init({ temperature = 0, useExisting = true } = {}) {
336
+ static async init({
337
+ temperature = 0,
338
+ useExisting = true
339
+ } = {}) {
491
340
  if (useExisting) {
492
341
  const llmConfig2 = await AiSession.getLlmConfig();
493
342
  if (llmConfig2) {
@@ -514,22 +363,24 @@ class AiSession {
514
363
  return AiSession;
515
364
  }
516
365
  static async getLlmConfig() {
517
- const akanConfig = await getAkanGlobalConfig();
518
- return akanConfig.llm ?? null;
366
+ return await GlobalConfig.getLlmConfig();
519
367
  }
520
368
  static async setLlmConfig(llmConfig) {
521
- const akanConfig = await getAkanGlobalConfig();
522
- akanConfig.llm = llmConfig;
523
- await setAkanGlobalConfig(akanConfig);
369
+ await GlobalConfig.setLlmConfig(llmConfig);
524
370
  return AiSession;
525
371
  }
526
372
  static async#requestLlmConfig() {
527
- const model = await select({ message: "Select a LLM model", choices: supportedLlmModels });
373
+ const model = await select({
374
+ message: "Select a LLM model",
375
+ choices: supportedLlmModels
376
+ });
528
377
  const apiKey = await input({ message: "Enter your API key" });
529
378
  return { model, apiKey };
530
379
  }
531
380
  static async#validateApiKey(modelName, apiKey) {
532
- const spinner = new Spinner("Validating LLM API key...", { prefix: `\uD83E\uDD16akan-editor` }).start();
381
+ const spinner = new Spinner("Validating LLM API key...", {
382
+ prefix: `\uD83E\uDD16akan-editor`
383
+ }).start();
533
384
  const chat = new ChatOpenAI({
534
385
  modelName,
535
386
  temperature: 0,
@@ -552,7 +403,11 @@ class AiSession {
552
403
  sessionKey;
553
404
  isCacheLoaded = false;
554
405
  workspace;
555
- constructor(type, { workspace, cacheKey, isContinued }) {
406
+ constructor(type, {
407
+ workspace,
408
+ cacheKey,
409
+ isContinued
410
+ }) {
556
411
  this.workspace = workspace;
557
412
  this.sessionKey = `${type}${cacheKey ? `-${cacheKey}` : ""}`;
558
413
  if (isContinued)
@@ -627,7 +482,13 @@ class AiSession {
627
482
  throw new Error("Failed to stream response");
628
483
  }
629
484
  }
630
- async edit(question, { onChunk, onReasoning, maxTry = MAX_ASK_TRY, validate, approve } = {}) {
485
+ async edit(question, {
486
+ onChunk,
487
+ onReasoning,
488
+ maxTry = MAX_ASK_TRY,
489
+ validate,
490
+ approve
491
+ } = {}) {
631
492
  for (let tryCount = 0;tryCount < maxTry; tryCount++) {
632
493
  let response = await this.ask(question, { onChunk, onReasoning });
633
494
  if (validate?.length && tryCount === 0) {
@@ -680,7 +541,9 @@ ${validate.map((v) => `- ${v}`).join(`
680
541
  async#tryFixTypescripts(writes, executor, options = {}) {
681
542
  const MAX_EDIT_TRY = 5;
682
543
  for (let tryCount = 0;tryCount < MAX_EDIT_TRY; tryCount++) {
683
- const loader = new Spinner(`Type checking and linting...`, { prefix: `\uD83E\uDD16akan-editor` }).start();
544
+ const loader = new Spinner(`Type checking and linting...`, {
545
+ prefix: `\uD83E\uDD16akan-editor`
546
+ }).start();
684
547
  const fileChecks = await Promise.all(writes.map(async ({ filePath }) => {
685
548
  const typeCheckResult = executor.typeCheck(filePath);
686
549
  const lintResult = await executor.lint(filePath);
@@ -2488,11 +2351,26 @@ class Executor {
2488
2351
  });
2489
2352
  return new Promise((resolve, reject) => {
2490
2353
  proc.on("error", (error) => {
2491
- reject(new CommandExecutionError({ command, cwd, code: null, signal: null, stdout, stderr, cause: error }));
2354
+ reject(new CommandExecutionError({
2355
+ command,
2356
+ cwd,
2357
+ code: null,
2358
+ signal: null,
2359
+ stdout,
2360
+ stderr,
2361
+ cause: error
2362
+ }));
2492
2363
  });
2493
2364
  proc.on("exit", (code, signal) => {
2494
2365
  if (!!code || signal)
2495
- reject(new CommandExecutionError({ command, cwd, code, signal, stdout, stderr }));
2366
+ reject(new CommandExecutionError({
2367
+ command,
2368
+ cwd,
2369
+ code,
2370
+ signal,
2371
+ stdout,
2372
+ stderr
2373
+ }));
2496
2374
  else
2497
2375
  resolve({ code, signal });
2498
2376
  });
@@ -2518,11 +2396,28 @@ class Executor {
2518
2396
  });
2519
2397
  return new Promise((resolve, reject) => {
2520
2398
  proc.on("error", (error) => {
2521
- reject(new CommandExecutionError({ command, args, cwd, code: null, signal: null, stdout, stderr, cause: error }));
2399
+ reject(new CommandExecutionError({
2400
+ command,
2401
+ args,
2402
+ cwd,
2403
+ code: null,
2404
+ signal: null,
2405
+ stdout,
2406
+ stderr,
2407
+ cause: error
2408
+ }));
2522
2409
  });
2523
2410
  proc.on("close", (code, signal) => {
2524
2411
  if (code !== 0 || signal)
2525
- reject(new CommandExecutionError({ command, args, cwd, code, signal, stdout, stderr }));
2412
+ reject(new CommandExecutionError({
2413
+ command,
2414
+ args,
2415
+ cwd,
2416
+ code,
2417
+ signal,
2418
+ stdout,
2419
+ stderr
2420
+ }));
2526
2421
  else
2527
2422
  resolve(stdout);
2528
2423
  });
@@ -2566,7 +2461,15 @@ class Executor {
2566
2461
  });
2567
2462
  proc.on("exit", (code, signal) => {
2568
2463
  if (!!code || signal)
2569
- reject(new CommandExecutionError({ command: modulePath, args, cwd, code, signal, stdout, stderr }));
2464
+ reject(new CommandExecutionError({
2465
+ command: modulePath,
2466
+ args,
2467
+ cwd,
2468
+ code,
2469
+ signal,
2470
+ stdout,
2471
+ stderr
2472
+ }));
2570
2473
  else
2571
2474
  resolve({ code, signal });
2572
2475
  });
@@ -2713,7 +2616,10 @@ class Executor {
2713
2616
  const result = {
2714
2617
  ...extendsTsconfig,
2715
2618
  ...tsconfig,
2716
- compilerOptions: { ...extendsTsconfig.compilerOptions, ...tsconfig.compilerOptions }
2619
+ compilerOptions: {
2620
+ ...extendsTsconfig.compilerOptions,
2621
+ ...tsconfig.compilerOptions
2622
+ }
2717
2623
  };
2718
2624
  this.#tsconfig = result;
2719
2625
  return result;
@@ -2768,7 +2674,9 @@ class Executor {
2768
2674
  const convertedTargetPath = Object.entries(dict).reduce((path8, [key, value]) => path8.replace(new RegExp(`__${key}__`, "g"), value), targetPath.slice(0, -9));
2769
2675
  const convertedContent = Object.entries(dict).reduce((data, [key, value]) => data.replace(new RegExp(`<%= ${key} %>`, "g"), value), content);
2770
2676
  this.logger.verbose(`Apply template ${templatePath} to ${convertedTargetPath}`);
2771
- return this.writeFile(convertedTargetPath, convertedContent, { overwrite });
2677
+ return this.writeFile(convertedTargetPath, convertedContent, {
2678
+ overwrite
2679
+ });
2772
2680
  } else if (staticTemplateFileExtensions.has(path7.extname(targetPath).toLowerCase())) {
2773
2681
  const convertedTargetPath = Object.entries(dict).reduce((path8, [key, value]) => path8.replace(new RegExp(`__${key}__`, "g"), value), targetPath);
2774
2682
  const writePath = this.getPath(convertedTargetPath);
@@ -2794,14 +2702,24 @@ class Executor {
2794
2702
  const prefixTemplatePath = templatePath;
2795
2703
  if ((await stat2(prefixTemplatePath)).isFile()) {
2796
2704
  const filename = path7.basename(prefixTemplatePath);
2797
- const fileContent = await this.#applyTemplateFile({ templatePath: prefixTemplatePath, targetPath: path7.join(basePath2, filename), scanInfo, overwrite }, dict, options);
2705
+ const fileContent = await this.#applyTemplateFile({
2706
+ templatePath: prefixTemplatePath,
2707
+ targetPath: path7.join(basePath2, filename),
2708
+ scanInfo,
2709
+ overwrite
2710
+ }, dict, options);
2798
2711
  return fileContent ? [fileContent] : [];
2799
2712
  } else {
2800
2713
  const subdirs = await readDirEntries(templatePath);
2801
2714
  const fileContents = (await Promise.all(subdirs.map(async (subdir) => {
2802
2715
  const subpath = path7.join(templatePath, subdir);
2803
2716
  if ((await stat2(subpath)).isFile()) {
2804
- const fileContent = await this.#applyTemplateFile({ templatePath: subpath, targetPath: path7.join(basePath2, subdir), scanInfo, overwrite }, dict, options);
2717
+ const fileContent = await this.#applyTemplateFile({
2718
+ templatePath: subpath,
2719
+ targetPath: path7.join(basePath2, subdir),
2720
+ scanInfo,
2721
+ overwrite
2722
+ }, dict, options);
2805
2723
  return fileContent ? [fileContent] : [];
2806
2724
  } else
2807
2725
  return await this._applyTemplate({
@@ -2852,7 +2770,10 @@ class Executor {
2852
2770
  async lint(filePath, { fix = false, dryRun = false } = {}) {
2853
2771
  const path8 = this.getPath(filePath);
2854
2772
  const linter = this.getLinter();
2855
- const { results, errors, warnings } = await linter.lint(path8, { fix, dryRun });
2773
+ const { results, errors, warnings } = await linter.lint(path8, {
2774
+ fix,
2775
+ dryRun
2776
+ });
2856
2777
  const message = linter.formatLintResults(results);
2857
2778
  return { results, message, errors, warnings };
2858
2779
  }
@@ -2878,6 +2799,7 @@ class WorkspaceExecutor extends Executor {
2878
2799
  const sourceEnv = envPath ? { ...process.env, ...parseEnvFile(envPath) } : process.env;
2879
2800
  const appName = sourceEnv.AKAN_PUBLIC_APP_NAME;
2880
2801
  const workspaceRoot = sourceEnv.AKAN_WORKSPACE_ROOT;
2802
+ const workspaceId = sourceEnv.AKAN_WORKSPACE_ID;
2881
2803
  const repoName = sourceEnv.AKAN_PUBLIC_REPO_NAME;
2882
2804
  if (!repoName)
2883
2805
  throw new Error("AKAN_PUBLIC_REPO_NAME is not set");
@@ -2888,7 +2810,15 @@ class WorkspaceExecutor extends Executor {
2888
2810
  const env = sourceEnv.AKAN_PUBLIC_ENV ?? "debug";
2889
2811
  if (!env)
2890
2812
  throw new Error("AKAN_PUBLIC_ENV is not set");
2891
- return { ...appName ? { appName } : {}, workspaceRoot, repoName, serveDomain, env, portOffset };
2813
+ return { ...appName ? { appName } : {}, workspaceRoot, repoName, serveDomain, env, portOffset, workspaceId };
2814
+ }
2815
+ getWorkspaceId({
2816
+ allowEmpty
2817
+ } = {}) {
2818
+ const { workspaceId } = WorkspaceExecutor.getBaseDevEnv();
2819
+ if (!workspaceId && !allowEmpty)
2820
+ throw new Error("Workspace ID is not found");
2821
+ return workspaceId;
2892
2822
  }
2893
2823
  async scan() {
2894
2824
  return await WorkspaceInfo.fromExecutor(this);
@@ -3092,7 +3022,11 @@ class SysExecutor extends Executor {
3092
3022
  } = {}) {
3093
3023
  if (this.#scanInfo && !refresh)
3094
3024
  return this.#scanInfo;
3095
- const scanInfo = this.type === "app" ? await AppInfo.fromExecutor(this, { refresh }) : await LibInfo.fromExecutor(this, { refresh });
3025
+ const scanInfo = this.type === "app" ? await AppInfo.fromExecutor(this, {
3026
+ refresh
3027
+ }) : await LibInfo.fromExecutor(this, {
3028
+ refresh
3029
+ });
3096
3030
  if (write) {
3097
3031
  await Promise.all(this.#getScanTemplateTasks(scanInfo));
3098
3032
  await this.writeJson(`akan.${this.type}.json`, scanInfo.getScanResult());
@@ -3201,7 +3135,11 @@ class SysExecutor extends Executor {
3201
3135
  ...Object.fromEntries(Object.entries(options.dict ?? {}).map(([key, value]) => [capitalize(key), capitalize(value)]))
3202
3136
  };
3203
3137
  const scanInfo = await this.scan();
3204
- const fileContents = await this._applyTemplate({ ...options, scanInfo, dict });
3138
+ const fileContents = await this._applyTemplate({
3139
+ ...options,
3140
+ scanInfo,
3141
+ dict
3142
+ });
3205
3143
  await this.scan();
3206
3144
  return fileContents;
3207
3145
  }
@@ -3307,7 +3245,11 @@ class AppExecutor extends SysExecutor {
3307
3245
  this.#pageKeys = [];
3308
3246
  return this.#pageKeys;
3309
3247
  }
3310
- for await (const rel of glob.scan({ cwd: pageDir, absolute: false, onlyFiles: true })) {
3248
+ for await (const rel of glob.scan({
3249
+ cwd: pageDir,
3250
+ absolute: false,
3251
+ onlyFiles: true
3252
+ })) {
3311
3253
  const segments = rel.split(path7.sep);
3312
3254
  if (segments.some((s) => s === "node_modules"))
3313
3255
  continue;
@@ -3317,7 +3259,10 @@ class AppExecutor extends SysExecutor {
3317
3259
  if (!isRouteSourceFile(posix))
3318
3260
  continue;
3319
3261
  const key = `./${posix}`;
3320
- validateSubRoutePageKey(key, akanConfig2.basePaths, { appName: this.name, filePath: absPath });
3262
+ validateSubRoutePageKey(key, akanConfig2.basePaths, {
3263
+ appName: this.name,
3264
+ filePath: absPath
3265
+ });
3321
3266
  const parsed = parseRouteModuleKey(key);
3322
3267
  if (parsed.isInternalRootLayout) {
3323
3268
  throw new Error(`[route-convention] __root_layout is reserved for Akan.js generated root layout: ${absPath}`);
@@ -3357,7 +3302,11 @@ class AppExecutor extends SysExecutor {
3357
3302
  ]);
3358
3303
  }
3359
3304
  async scanSync({ refresh = false, write = true } = {}) {
3360
- const scanInfo = await this.scan({ refresh, write, writeLib: write });
3305
+ const scanInfo = await this.scan({
3306
+ refresh,
3307
+ write,
3308
+ writeLib: write
3309
+ });
3361
3310
  if (write)
3362
3311
  await this.syncAssets(scanInfo.getScanResult().libDeps);
3363
3312
  return scanInfo;
@@ -3421,7 +3370,10 @@ class PkgExecutor extends Executor {
3421
3370
  return scanInfo;
3422
3371
  }
3423
3372
  async#getDependencyVersion(rootPackageJson, dep) {
3424
- const rootDeps = { ...rootPackageJson.dependencies, ...rootPackageJson.devDependencies };
3373
+ const rootDeps = {
3374
+ ...rootPackageJson.dependencies,
3375
+ ...rootPackageJson.devDependencies
3376
+ };
3425
3377
  const rootVersion = rootDeps[dep];
3426
3378
  if (rootVersion)
3427
3379
  return rootVersion;
@@ -3477,7 +3429,14 @@ class PkgExecutor extends Executor {
3477
3429
  const distPkgJson = {
3478
3430
  ...pkgJson,
3479
3431
  type: "module",
3480
- exports: { ...pkgJson.exports, ".": { import: "./index.ts", types: "./index.ts", default: "./index.ts" } },
3432
+ exports: {
3433
+ ...pkgJson.exports,
3434
+ ".": {
3435
+ import: "./index.ts",
3436
+ types: "./index.ts",
3437
+ default: "./index.ts"
3438
+ }
3439
+ },
3481
3440
  engines: { bun: ">=1.3.13" },
3482
3441
  ...dependencyMaps
3483
3442
  };
@@ -7771,7 +7730,7 @@ class ApplicationBuildRunner {
7771
7730
  import { cp, mkdir as mkdir8, rm as rm3 } from "fs/promises";
7772
7731
 
7773
7732
  // pkgs/@akanjs/devkit/uploadRelease.ts
7774
- import { HttpClient, Logger as Logger10 } from "akanjs/common";
7733
+ import { HttpClient as HttpClient2, Logger as Logger10 } from "akanjs/common";
7775
7734
  var spinning = (message) => {
7776
7735
  const spinner = new Spinner(message, { prefix: message, enableSpin: true }).start();
7777
7736
  return spinner;
@@ -7786,7 +7745,7 @@ var uploadRelease = async (appName, {
7786
7745
  }) => {
7787
7746
  const logger = new Logger10("uploadRelease");
7788
7747
  const basePath2 = local ? "http://localhost:8282/backend" : "https://cloud.akanjs.com/backend";
7789
- const httpClient = new HttpClient(basePath2);
7748
+ const httpClient = new HttpClient2(basePath2);
7790
7749
  const buildPath = `${workspaceRoot}/releases/builds/${appName}-release.tar.gz`;
7791
7750
  const appBuildPath = `${workspaceRoot}/releases/builds/${appName}-appBuild.zip`;
7792
7751
  const sourcePath = `${workspaceRoot}/releases/sources/${appName}-source.tar.gz`;
@@ -9773,77 +9732,6 @@ import { Box as Box2, Newline, Text as Text2, useInput as useInput2 } from "ink"
9773
9732
  import { useEffect as useEffect3, useState as useState3 } from "react";
9774
9733
  import { jsxDEV as jsxDEV2, Fragment as Fragment2 } from "react/jsx-dev-runtime";
9775
9734
  "use client";
9776
- // pkgs/@akanjs/devkit/cloud/cloudApi.ts
9777
- var import_dayjs = __toESM(require_dayjs_min(), 1);
9778
-
9779
- class HttpClient2 {
9780
- baseUrl;
9781
- constructor(baseUrl) {
9782
- this.baseUrl = baseUrl;
9783
- }
9784
- async get(url, { headers } = {}) {
9785
- const response = await fetch(`${this.baseUrl}${url}`, {
9786
- headers: { "Content-Type": "application/json", ...headers }
9787
- });
9788
- return response.json();
9789
- }
9790
- async post(url, data, { headers } = {}) {
9791
- const isFormData = data instanceof FormData;
9792
- const response = await fetch(`${this.baseUrl}${url}`, {
9793
- method: "POST",
9794
- body: isFormData ? data : JSON.stringify(data),
9795
- headers: isFormData ? headers : { "Content-Type": "application/json", ...headers }
9796
- });
9797
- return response.json();
9798
- }
9799
- }
9800
-
9801
- class CloudApi {
9802
- api;
9803
- #accessToken = null;
9804
- constructor(host, { accessToken } = {}) {
9805
- this.api = new HttpClient2(`${host}/api`);
9806
- this.#accessToken = accessToken ?? null;
9807
- }
9808
- async uploadEnv(devProjectId, file) {
9809
- const formData = new FormData;
9810
- formData.append("devProjectId", devProjectId);
9811
- formData.append("file", file);
9812
- const response = await this.api.post(`/uploadEnv/${devProjectId}`, formData);
9813
- return response.success;
9814
- }
9815
- async downloadEnv(devProjectId) {
9816
- const response = await this.api.get(`/downloadEnv/${devProjectId}`);
9817
- return response.success;
9818
- }
9819
- async getRemoteAuthToken(remoteId) {
9820
- if (this.#needRefreshToken())
9821
- return await this.refreshAuthToken();
9822
- else if (this.#accessToken)
9823
- return this.#accessToken;
9824
- const accessToken = await this.api.get(`/getRemoteAuthToken/${remoteId}`);
9825
- this.#accessToken = {
9826
- jwt: accessToken.jwt,
9827
- refreshToken: accessToken.refreshToken,
9828
- expiresAt: accessToken.expiresAt ? import_dayjs.default(accessToken.expiresAt) : null
9829
- };
9830
- return this.#accessToken;
9831
- }
9832
- async refreshAuthToken() {
9833
- const response = await this.api.post(`/refreshRemoteAuthToken`, {
9834
- refreshToken: this.#accessToken?.refreshToken
9835
- });
9836
- this.#accessToken = {
9837
- jwt: response.jwt,
9838
- refreshToken: response.refreshToken,
9839
- expiresAt: response.expiresAt ? import_dayjs.default(response.expiresAt) : null
9840
- };
9841
- return this.#accessToken;
9842
- }
9843
- #needRefreshToken() {
9844
- return !!this.#accessToken?.expiresAt?.isBefore(import_dayjs.default().add(1, "hour"));
9845
- }
9846
- }
9847
9735
  // pkgs/@akanjs/devkit/incrementalBuilder/incrementalBuilder.proc.ts
9848
9736
  import { Logger as Logger12 } from "akanjs/common";
9849
9737