@agentdocumentformat/cli 0.7.8 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/README.md +1 -1
  2. package/dist/adf.mjs +59 -8
  3. package/dist/chunks/{APEv2Parser-2CNNHMXV.mjs → APEv2Parser-WIXRJLHB.mjs} +2 -2
  4. package/dist/chunks/{AiffParser-7BR4RL6G.mjs → AiffParser-ZC4QFOVJ.mjs} +5 -5
  5. package/dist/chunks/{App-7RIIOHJJ.mjs → App-A5GUFCFJ.mjs} +279 -293
  6. package/dist/chunks/{DsdiffParser-CMD4AX7A.mjs → DsdiffParser-UAPAJHFX.mjs} +5 -5
  7. package/dist/chunks/{DsfParser-UOGZDS2M.mjs → DsfParser-NNYZK2QX.mjs} +6 -6
  8. package/dist/chunks/{FlacParser-HB3T3CD4.mjs → FlacParser-MW2W4LO3.mjs} +6 -6
  9. package/dist/chunks/{MP4Parser-66HBRUSX.mjs → MP4Parser-Z57SYOOQ.mjs} +4 -4
  10. package/dist/chunks/{MpegParser-YW6LIUEW.mjs → MpegParser-XIIPAZVM.mjs} +7 -7
  11. package/dist/chunks/{MusepackParser-PAUSXP7D.mjs → MusepackParser-QWNDEYHJ.mjs} +6 -6
  12. package/dist/chunks/{OggParser-NUBV3GWC.mjs → OggParser-WRX53F77.mjs} +9 -9
  13. package/dist/chunks/{WavPackParser-WQAGT7TC.mjs → WavPackParser-MJ7WCSJ5.mjs} +2 -2
  14. package/dist/chunks/{WaveParser-EWLQVDX4.mjs → WaveParser-RAVLHZ5S.mjs} +7 -7
  15. package/dist/chunks/{adf-schema-US4NFHMR.mjs → adf-schema-YJSGLMA4.mjs} +2 -2
  16. package/dist/chunks/auth-manager-AJ32FZWS.mjs +19 -0
  17. package/dist/chunks/auth-manager-C5OBEQK2.mjs +18 -0
  18. package/dist/chunks/auth-manager-TBNKCJ45.mjs +17 -0
  19. package/dist/chunks/{chatgpt-subscription-E4MXTIAT.mjs → chatgpt-subscription-MMGNW5KJ.mjs} +5 -2
  20. package/dist/chunks/chunk-3UGZFWIF.mjs +26 -0
  21. package/dist/chunks/{chunk-5PO5PKRV.mjs → chunk-4OGZFUKA.mjs} +126 -67
  22. package/dist/chunks/{chunk-VN7UH7I5.mjs → chunk-6XQZGYMK.mjs} +246 -67
  23. package/dist/chunks/{chunk-XNPZBLYL.mjs → chunk-75DC5EWN.mjs} +13 -2
  24. package/dist/chunks/chunk-AZYOXXVL.mjs +865 -0
  25. package/dist/chunks/{chunk-6VQEXLE2.mjs → chunk-BHY7QDCM.mjs} +41 -3
  26. package/dist/chunks/chunk-C2S64Y6F.mjs +203 -0
  27. package/dist/chunks/chunk-C4GA5SI4.mjs +12799 -0
  28. package/dist/chunks/chunk-DDTTSKGG.mjs +2443 -0
  29. package/dist/chunks/{chunk-VAUOM3IN.mjs → chunk-DLWCKKIO.mjs} +1 -1
  30. package/dist/chunks/{chunk-QPLEAE6V.mjs → chunk-G6NBFYG5.mjs} +152 -824
  31. package/dist/chunks/{chunk-KXEF4F4E.mjs → chunk-GAZO6UMI.mjs} +1 -1
  32. package/dist/chunks/{chunk-XYTWGHFS.mjs → chunk-H3XLRWVE.mjs} +1 -1
  33. package/dist/chunks/{chunk-7T2YMTWL.mjs → chunk-H4C65MTP.mjs} +4 -4
  34. package/dist/chunks/chunk-HBOFZRUS.mjs +738 -0
  35. package/dist/chunks/chunk-JVPZIMXW.mjs +976 -0
  36. package/dist/chunks/{chunk-XYV3VCIX.mjs → chunk-JZFONJSL.mjs} +79 -20
  37. package/dist/chunks/chunk-KDDVQKCG.mjs +65 -0
  38. package/dist/chunks/chunk-KRPKWOMB.mjs +290 -0
  39. package/dist/chunks/{chunk-G6PH7RPW.mjs → chunk-LCMANRYY.mjs} +3 -3
  40. package/dist/chunks/{chunk-ZESQMP66.mjs → chunk-LGL6ML37.mjs} +3 -3
  41. package/dist/chunks/chunk-LKFHERRV.mjs +145 -0
  42. package/dist/chunks/chunk-LTX74NU6.mjs +29 -0
  43. package/dist/chunks/chunk-M2F7C2UJ.mjs +425 -0
  44. package/dist/chunks/{chunk-62NE4LG4.mjs → chunk-MQAMI5BF.mjs} +5 -5
  45. package/dist/chunks/chunk-MZRXFWPQ.mjs +278 -0
  46. package/dist/chunks/{chunk-PRMGZZM5.mjs → chunk-NZLEPJ5M.mjs} +2 -0
  47. package/dist/chunks/{chunk-CD3ATSXE.mjs → chunk-NZO5O4VN.mjs} +1 -1
  48. package/dist/chunks/{chunk-I3UYSITV.mjs → chunk-O7XKQ6CH.mjs} +1 -1
  49. package/dist/chunks/chunk-P3RG5LQA.mjs +244 -0
  50. package/dist/chunks/chunk-PAK5JCO2.mjs +48 -0
  51. package/dist/chunks/chunk-PC63YFB7.mjs +34 -0
  52. package/dist/chunks/{daemon-control-HKFVSQTQ.mjs → chunk-PRPTKMQW.mjs} +67 -26
  53. package/dist/chunks/{chunk-LFMB4PAA.mjs → chunk-TKXIH27X.mjs} +974 -113
  54. package/dist/chunks/{chunk-5W7KES6P.mjs → chunk-UZPDETEU.mjs} +1 -1
  55. package/dist/chunks/chunk-V2T6NZX2.mjs +517 -0
  56. package/dist/chunks/chunk-V3MM6PCH.mjs +366 -0
  57. package/dist/chunks/chunk-WJGPNHGX.mjs +67 -0
  58. package/dist/chunks/chunk-WVTPPOKK.mjs +290 -0
  59. package/dist/chunks/{chunk-J74STFKE.mjs → chunk-WX6QCUWI.mjs} +272 -51
  60. package/dist/chunks/{chunk-Y5ZLKFLE.mjs → chunk-XNNJQCZP.mjs} +196 -165
  61. package/dist/chunks/{chunk-HDBPBORT.mjs → chunk-XT2BJUFC.mjs} +15 -6
  62. package/dist/chunks/{chunk-HSBV6YFU.mjs → chunk-YRMKSHW3.mjs} +614 -92
  63. package/dist/chunks/{chunk-BNXUAOO4.mjs → chunk-ZGXUOAWZ.mjs} +3186 -959
  64. package/dist/chunks/chunk-ZPB3HYM7.mjs +45 -0
  65. package/dist/chunks/claude-subscription-33BMZB6I.mjs +29 -0
  66. package/dist/chunks/{cli-NMFIAR7Z.mjs → cli-I47IFDHJ.mjs} +797 -56
  67. package/dist/chunks/{commands-KPJWFRUE.mjs → commands-E4EQUHE5.mjs} +4 -3
  68. package/dist/chunks/{daemon-YDIK3AAM.mjs → daemon-FQ5BV3AP.mjs} +82058 -63958
  69. package/dist/chunks/daemon-control-L3CLG63P.mjs +59 -0
  70. package/dist/chunks/{daemon-token-WRSULP7G.mjs → daemon-token-L5QKTHU5.mjs} +3 -1
  71. package/dist/chunks/{discord-DSP4HUWI.mjs → discord-IR62565M.mjs} +3 -52
  72. package/dist/chunks/{email-BRG7KUO2.mjs → email-KHHTJBDW.mjs} +4 -2
  73. package/dist/chunks/{grok-subscription-4PYX7TBF.mjs → grok-subscription-E74FS5EG.mjs} +5 -2
  74. package/dist/chunks/{lib-N7FCZWKH.mjs → lib-L27L5PXM.mjs} +22 -22
  75. package/dist/chunks/{open-VAU7PXT6.mjs → open-TLGS2Z3Q.mjs} +4 -4
  76. package/dist/chunks/{parser-JVY2PWSM.mjs → parser-7GARNT5L.mjs} +1 -1
  77. package/dist/chunks/{pipeline-executor-O77NTGLP.mjs → pipeline-executor-FD4FBWQA.mjs} +6 -5
  78. package/dist/chunks/prompt-RRHZX4YT.mjs +13 -0
  79. package/dist/chunks/remote-access-cli-XXAPQWH6.mjs +268 -0
  80. package/dist/chunks/remote-hello-UFWUBDQI.mjs +37 -0
  81. package/dist/chunks/sdk-5FD2ZP7N.mjs +28422 -0
  82. package/dist/chunks/{slack-OCNNF4DX.mjs → slack-IYC5RAB5.mjs} +3 -4
  83. package/dist/chunks/{store-HUVDJPYN.mjs → store-ZRN2WCFB.mjs} +6 -3
  84. package/dist/chunks/tailscale-WLJATFMB.mjs +25 -0
  85. package/dist/chunks/{theme-SFE3JMA2.mjs → theme-HLBDTF6F.mjs} +1 -1
  86. package/dist/chunks/{themes-YLXLOIJF.mjs → themes-BQ72P446.mjs} +2 -2
  87. package/dist/chunks/{token-6G3HCMNX.mjs → token-6D22WECM.mjs} +20 -16
  88. package/dist/chunks/{token-util-UXYSDQIW.mjs → token-util-YF3ZWBZ4.mjs} +1 -2
  89. package/dist/chunks/{tui-UQJLK7XI.mjs → tui-SPSPDADM.mjs} +17 -14
  90. package/dist/chunks/{welcome-XHXFV7SH.mjs → welcome-J5JZZAM5.mjs} +1 -1
  91. package/dist/chunks/{whatsapp-AJMRQBT7.mjs → whatsapp-YJFFVN4Q.mjs} +9 -9
  92. package/package.json +1 -1
  93. package/dist/chunks/chunk-GKKCMXIZ.mjs +0 -94
  94. package/dist/chunks/chunk-IHDDCZBS.mjs +0 -112
  95. package/dist/chunks/chunk-KWFOS5WC.mjs +0 -41
  96. package/dist/chunks/chunk-UEZR2CNS.mjs +0 -65
  97. package/dist/chunks/chunk-VMHTYDH4.mjs +0 -172
  98. package/dist/chunks/chunk-Y2QA53AN.mjs +0 -259
  99. package/dist/chunks/{chunk-NBTUWMGP.mjs → chunk-2MTE22CR.mjs} +3 -3
  100. package/dist/chunks/{telegram-2EFGKIVK.mjs → telegram-JYY2VDTI.mjs} +5 -5
@@ -4,14 +4,39 @@ import { dirname as __adfDirname } from 'node:path';
4
4
  const require = __adfCreateRequire(import.meta.url);
5
5
  const __filename = __adfFileURLToPath(import.meta.url);
6
6
  const __dirname = __adfDirname(__filename);
7
- import {
8
- require_token_error
9
- } from "./chunk-KWFOS5WC.mjs";
10
7
  import {
11
8
  __commonJS,
12
9
  __require
13
10
  } from "./chunk-M2RX3S2T.mjs";
14
11
 
12
+ // node_modules/@vercel/oidc/dist/token-error.js
13
+ var require_token_error = __commonJS({
14
+ "node_modules/@vercel/oidc/dist/token-error.js"(exports, module) {
15
+ "use strict";
16
+ var __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __getOwnPropNames = Object.getOwnPropertyNames, __hasOwnProp = Object.prototype.hasOwnProperty, __export = (target, all) => {
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: !0 });
19
+ }, __copyProps = (to, from, except, desc) => {
20
+ if (from && typeof from == "object" || typeof from == "function")
21
+ for (let key of __getOwnPropNames(from))
22
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ return to;
24
+ }, __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod), token_error_exports = {};
25
+ __export(token_error_exports, {
26
+ VercelOidcTokenError: () => VercelOidcTokenError
27
+ });
28
+ module.exports = __toCommonJS(token_error_exports);
29
+ var VercelOidcTokenError = class extends Error {
30
+ constructor(message, cause) {
31
+ super(message), this.name = "VercelOidcTokenError", this.cause = cause;
32
+ }
33
+ toString() {
34
+ return this.cause ? `${this.name}: ${this.message}: ${this.cause}` : `${this.name}: ${this.message}`;
35
+ }
36
+ };
37
+ }
38
+ });
39
+
15
40
  // node_modules/@vercel/oidc/dist/token-io.js
16
41
  var require_token_io = __commonJS({
17
42
  "node_modules/@vercel/oidc/dist/token-io.js"(exports, module) {
@@ -121,13 +146,13 @@ var require_auth_config = __commonJS({
121
146
  let authPath = getAuthConfigPath(), authDir = path.dirname(authPath);
122
147
  fs.existsSync(authDir) || fs.mkdirSync(authDir, { mode: 504, recursive: !0 }), fs.writeFileSync(authPath, JSON.stringify(config, null, 2), { mode: 384 });
123
148
  }
124
- function isValidAccessToken(authConfig) {
149
+ function isValidAccessToken(authConfig, expirationBufferMs = 0) {
125
150
  if (!authConfig.token)
126
151
  return !1;
127
152
  if (typeof authConfig.expiresAt != "number")
128
153
  return !0;
129
- let nowInSeconds = Math.floor(Date.now() / 1e3);
130
- return authConfig.expiresAt >= nowInSeconds;
154
+ let nowInSeconds = Math.floor(Date.now() / 1e3), bufferInSeconds = expirationBufferMs / 1e3;
155
+ return authConfig.expiresAt >= nowInSeconds + bufferInSeconds;
131
156
  }
132
157
  }
133
158
  });
@@ -191,6 +216,38 @@ var require_oauth = __commonJS({
191
216
  }
192
217
  });
193
218
 
219
+ // node_modules/@vercel/oidc/dist/auth-errors.js
220
+ var require_auth_errors = __commonJS({
221
+ "node_modules/@vercel/oidc/dist/auth-errors.js"(exports, module) {
222
+ "use strict";
223
+ var __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __getOwnPropNames = Object.getOwnPropertyNames, __hasOwnProp = Object.prototype.hasOwnProperty, __export = (target, all) => {
224
+ for (var name in all)
225
+ __defProp(target, name, { get: all[name], enumerable: !0 });
226
+ }, __copyProps = (to, from, except, desc) => {
227
+ if (from && typeof from == "object" || typeof from == "function")
228
+ for (let key of __getOwnPropNames(from))
229
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
230
+ return to;
231
+ }, __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod), auth_errors_exports = {};
232
+ __export(auth_errors_exports, {
233
+ AccessTokenMissingError: () => AccessTokenMissingError,
234
+ RefreshAccessTokenFailedError: () => RefreshAccessTokenFailedError
235
+ });
236
+ module.exports = __toCommonJS(auth_errors_exports);
237
+ var AccessTokenMissingError = class extends Error {
238
+ constructor() {
239
+ super(
240
+ "No authentication found. Please log in with the Vercel CLI (vercel login)."
241
+ ), this.name = "AccessTokenMissingError";
242
+ }
243
+ }, RefreshAccessTokenFailedError = class extends Error {
244
+ constructor(cause) {
245
+ super("Failed to refresh authentication token.", { cause }), this.name = "RefreshAccessTokenFailedError";
246
+ }
247
+ };
248
+ }
249
+ });
250
+
194
251
  // node_modules/@vercel/oidc/dist/token-util.js
195
252
  var require_token_util = __commonJS({
196
253
  "node_modules/@vercel/oidc/dist/token-util.js"(exports, module) {
@@ -214,40 +271,40 @@ var require_token_util = __commonJS({
214
271
  assertVercelOidcTokenResponse: () => assertVercelOidcTokenResponse,
215
272
  findProjectInfo: () => findProjectInfo,
216
273
  getTokenPayload: () => getTokenPayload,
217
- getVercelCliToken: () => getVercelCliToken,
218
274
  getVercelDataDir: () => getVercelDataDir,
219
275
  getVercelOidcToken: () => getVercelOidcToken,
276
+ getVercelToken: () => getVercelToken,
220
277
  isExpired: () => isExpired,
221
278
  loadToken: () => loadToken,
222
279
  saveToken: () => saveToken
223
280
  });
224
281
  module.exports = __toCommonJS(token_util_exports);
225
- var path = __toESM(__require("path")), fs = __toESM(__require("fs")), import_token_error = require_token_error(), import_token_io = require_token_io(), import_auth_config = require_auth_config(), import_oauth = require_oauth();
282
+ var path = __toESM(__require("path")), fs = __toESM(__require("fs")), import_token_error = require_token_error(), import_token_io = require_token_io(), import_auth_config = require_auth_config(), import_oauth = require_oauth(), import_auth_errors = require_auth_errors();
226
283
  function getVercelDataDir() {
227
284
  let vercelFolder = "com.vercel.cli", dataDir = (0, import_token_io.getUserDataDir)();
228
285
  return dataDir ? path.join(dataDir, vercelFolder) : null;
229
286
  }
230
- async function getVercelCliToken() {
287
+ async function getVercelToken(options) {
231
288
  let authConfig = (0, import_auth_config.readAuthConfig)();
232
- if (!authConfig)
233
- return null;
234
- if ((0, import_auth_config.isValidAccessToken)(authConfig))
235
- return authConfig.token || null;
289
+ if (!authConfig?.token)
290
+ throw new import_auth_errors.AccessTokenMissingError();
291
+ if ((0, import_auth_config.isValidAccessToken)(authConfig, options?.expirationBufferMs))
292
+ return authConfig.token;
236
293
  if (!authConfig.refreshToken)
237
- return (0, import_auth_config.writeAuthConfig)({}), null;
294
+ throw (0, import_auth_config.writeAuthConfig)({}), new import_auth_errors.RefreshAccessTokenFailedError("No refresh token available");
238
295
  try {
239
296
  let tokenResponse = await (0, import_oauth.refreshTokenRequest)({
240
297
  refresh_token: authConfig.refreshToken
241
298
  }), [tokensError, tokens] = await (0, import_oauth.processTokenResponse)(tokenResponse);
242
299
  if (tokensError || !tokens)
243
- return (0, import_auth_config.writeAuthConfig)({}), null;
300
+ throw (0, import_auth_config.writeAuthConfig)({}), new import_auth_errors.RefreshAccessTokenFailedError(tokensError);
244
301
  let updatedConfig = {
245
302
  token: tokens.access_token,
246
303
  expiresAt: Math.floor(Date.now() / 1e3) + tokens.expires_in
247
304
  };
248
- return tokens.refresh_token && (updatedConfig.refreshToken = tokens.refresh_token), (0, import_auth_config.writeAuthConfig)(updatedConfig), updatedConfig.token ?? null;
249
- } catch {
250
- return (0, import_auth_config.writeAuthConfig)({}), null;
305
+ return tokens.refresh_token && (updatedConfig.refreshToken = tokens.refresh_token), (0, import_auth_config.writeAuthConfig)(updatedConfig), updatedConfig.token;
306
+ } catch (error) {
307
+ throw (0, import_auth_config.writeAuthConfig)({}), error instanceof import_auth_errors.AccessTokenMissingError || error instanceof import_auth_errors.RefreshAccessTokenFailedError ? error : new import_auth_errors.RefreshAccessTokenFailedError(error);
251
308
  }
252
309
  }
253
310
  async function getVercelOidcToken(authToken, projectId, teamId) {
@@ -325,12 +382,14 @@ var require_token_util = __commonJS({
325
382
  );
326
383
  return JSON.parse(Buffer.from(padded, "base64").toString("utf8"));
327
384
  }
328
- function isExpired(token) {
329
- return token.exp * 1e3 < Date.now();
385
+ function isExpired(token, bufferMs = 0) {
386
+ return token.exp * 1e3 < Date.now() + bufferMs;
330
387
  }
331
388
  }
332
389
  });
333
390
 
334
391
  export {
392
+ require_token_error,
393
+ require_auth_errors,
335
394
  require_token_util
336
395
  };
@@ -0,0 +1,65 @@
1
+ import { createRequire as __adfCreateRequire } from 'node:module';
2
+ import { fileURLToPath as __adfFileURLToPath } from 'node:url';
3
+ import { dirname as __adfDirname } from 'node:path';
4
+ const require = __adfCreateRequire(import.meta.url);
5
+ const __filename = __adfFileURLToPath(import.meta.url);
6
+ const __dirname = __adfDirname(__filename);
7
+ import {
8
+ __commonJS
9
+ } from "./chunk-M2RX3S2T.mjs";
10
+
11
+ // node_modules/fast-deep-equal/es6/index.js
12
+ var require_es6 = __commonJS({
13
+ "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
14
+ "use strict";
15
+ module.exports = function equal(a, b) {
16
+ if (a === b) return !0;
17
+ if (a && b && typeof a == "object" && typeof b == "object") {
18
+ if (a.constructor !== b.constructor) return !1;
19
+ var length, i, keys;
20
+ if (Array.isArray(a)) {
21
+ if (length = a.length, length != b.length) return !1;
22
+ for (i = length; i-- !== 0; )
23
+ if (!equal(a[i], b[i])) return !1;
24
+ return !0;
25
+ }
26
+ if (a instanceof Map && b instanceof Map) {
27
+ if (a.size !== b.size) return !1;
28
+ for (i of a.entries())
29
+ if (!b.has(i[0])) return !1;
30
+ for (i of a.entries())
31
+ if (!equal(i[1], b.get(i[0]))) return !1;
32
+ return !0;
33
+ }
34
+ if (a instanceof Set && b instanceof Set) {
35
+ if (a.size !== b.size) return !1;
36
+ for (i of a.entries())
37
+ if (!b.has(i[0])) return !1;
38
+ return !0;
39
+ }
40
+ if (ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
41
+ if (length = a.length, length != b.length) return !1;
42
+ for (i = length; i-- !== 0; )
43
+ if (a[i] !== b[i]) return !1;
44
+ return !0;
45
+ }
46
+ if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
47
+ if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
48
+ if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
49
+ if (keys = Object.keys(a), length = keys.length, length !== Object.keys(b).length) return !1;
50
+ for (i = length; i-- !== 0; )
51
+ if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return !1;
52
+ for (i = length; i-- !== 0; ) {
53
+ var key = keys[i];
54
+ if (!equal(a[key], b[key])) return !1;
55
+ }
56
+ return !0;
57
+ }
58
+ return a !== a && b !== b;
59
+ };
60
+ }
61
+ });
62
+
63
+ export {
64
+ require_es6
65
+ };
@@ -0,0 +1,290 @@
1
+ import { createRequire as __adfCreateRequire } from 'node:module';
2
+ import { fileURLToPath as __adfFileURLToPath } from 'node:url';
3
+ import { dirname as __adfDirname } from 'node:path';
4
+ const require = __adfCreateRequire(import.meta.url);
5
+ const __filename = __adfFileURLToPath(import.meta.url);
6
+ const __dirname = __adfDirname(__filename);
7
+ import {
8
+ startCallbackServer
9
+ } from "./chunk-2NAP2ZF7.mjs";
10
+ import {
11
+ createSubscriptionTokenStore
12
+ } from "./chunk-C2S64Y6F.mjs";
13
+ import {
14
+ __require
15
+ } from "./chunk-M2RX3S2T.mjs";
16
+
17
+ // src/main/providers/chatgpt-subscription/auth-manager.ts
18
+ import crypto from "crypto";
19
+
20
+ // src/main/providers/chatgpt-subscription/token-store.ts
21
+ var store = createSubscriptionTokenStore("chatgpt-subscription");
22
+ function readTokens() {
23
+ return store.readTokens();
24
+ }
25
+ function writeTokens(tokens) {
26
+ store.writeTokens(tokens);
27
+ }
28
+ function clearTokens() {
29
+ store.clearTokens();
30
+ }
31
+ function noteSignIn(accountId) {
32
+ store.signedIn(accountId);
33
+ }
34
+
35
+ // src/main/providers/chatgpt-subscription/auth-manager.ts
36
+ var CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann", AUTH_URL = "https://auth.openai.com/oauth/authorize", TOKEN_URL = "https://auth.openai.com/oauth/token", SCOPE = "openid profile email offline_access api.connectors.read api.connectors.invoke", REFRESH_BUFFER_MS = 300 * 1e3, RELAY_FLOW_TTL_MS = 600 * 1e3;
37
+ function base64url(buf) {
38
+ return buf.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
39
+ }
40
+ function generateCodeVerifier() {
41
+ let bytes = crypto.getRandomValues(new Uint8Array(64));
42
+ return base64url(Buffer.from(bytes));
43
+ }
44
+ function generateCodeChallenge(verifier) {
45
+ let hash = crypto.createHash("sha256").update(verifier).digest();
46
+ return base64url(hash);
47
+ }
48
+ function generateState() {
49
+ return base64url(Buffer.from(crypto.getRandomValues(new Uint8Array(32))));
50
+ }
51
+ function decodeJwtPayload(token) {
52
+ let parts = token.split(".");
53
+ if (parts.length < 2) return {};
54
+ try {
55
+ let payload = Buffer.from(parts[1], "base64url").toString("utf-8");
56
+ return JSON.parse(payload);
57
+ } catch {
58
+ return {};
59
+ }
60
+ }
61
+ function chatgptAccountIdFromJwt(token) {
62
+ if (!token) return "";
63
+ let claims = decodeJwtPayload(token), auth = claims["https://api.openai.com/auth"], id = (auth && typeof auth == "object" ? auth.chatgpt_account_id : void 0) ?? claims.chatgpt_account_id;
64
+ return typeof id == "string" ? id : "";
65
+ }
66
+ async function openExternal(url) {
67
+ try {
68
+ let electron = __require("electron");
69
+ if (electron.shell?.openExternal) {
70
+ await electron.shell.openExternal(url);
71
+ return;
72
+ }
73
+ } catch {
74
+ }
75
+ console.log(`[ChatGPT Auth] Open this URL to sign in: ${url}`);
76
+ }
77
+ function assertLoopbackRedirect(redirectUri) {
78
+ let parsed;
79
+ try {
80
+ parsed = new URL(redirectUri);
81
+ } catch {
82
+ throw new Error(`Invalid redirectUri: ${redirectUri}`);
83
+ }
84
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:")
85
+ throw new Error("redirectUri must be an http(s) URL");
86
+ if (!["localhost", "127.0.0.1", "[::1]", "::1"].includes(parsed.hostname))
87
+ throw new Error("redirectUri must target localhost \u2014 the OAuth callback runs on the machine with the browser");
88
+ }
89
+ var ChatGptAuthManager = class {
90
+ refreshPromise = null;
91
+ cachedTokens = null;
92
+ email;
93
+ activeAuthFlow = null;
94
+ relayFlows = /* @__PURE__ */ new Map();
95
+ constructor() {
96
+ this.syncFromDisk();
97
+ }
98
+ /**
99
+ * Re-read the token file, picking up writes from other processes.
100
+ *
101
+ * Each surface has its own file (see subscription-token-store), but several
102
+ * processes can share one — e.g. an installed and a dev Studio, or a CLI
103
+ * next to its daemon — and OpenAI rotates the refresh token on every
104
+ * refresh, so acting on a cached copy can invalidate a sibling's session. Always reading is what prevents that; the file is
105
+ * well under a kilobyte and this runs once per LLM request.
106
+ */
107
+ syncFromDisk() {
108
+ let tokens = readTokens();
109
+ return tokens?.access_token !== this.cachedTokens?.access_token && (this.email = void 0), this.cachedTokens = tokens, tokens;
110
+ }
111
+ persist(tokens) {
112
+ writeTokens(tokens), this.cachedTokens = tokens;
113
+ }
114
+ async startAuthFlow() {
115
+ await (await this.startAuthFlowDetached()).completion;
116
+ }
117
+ async startAuthFlowDetached() {
118
+ if (this.activeAuthFlow) return this.activeAuthFlow;
119
+ let codeVerifier = generateCodeVerifier(), codeChallenge = generateCodeChallenge(codeVerifier), state = generateState(), server = await startCallbackServer(), redirectUri = `http://localhost:${server.port}/auth/callback`, params = new URLSearchParams({
120
+ client_id: CLIENT_ID,
121
+ redirect_uri: redirectUri,
122
+ response_type: "code",
123
+ code_challenge: codeChallenge,
124
+ code_challenge_method: "S256",
125
+ state,
126
+ scope: SCOPE,
127
+ id_token_add_organizations: "true",
128
+ codex_cli_simplified_flow: "true",
129
+ originator: "adf_studio"
130
+ }), authUrl = `${AUTH_URL}?${params.toString()}`;
131
+ await openExternal(authUrl);
132
+ let completion = (async () => {
133
+ try {
134
+ let result = await server.waitForCallback();
135
+ if (result.state !== state)
136
+ throw new Error("OAuth state mismatch \u2014 possible CSRF attack");
137
+ await this.exchangeCode(result.code, codeVerifier, redirectUri);
138
+ } finally {
139
+ server.close(), this.activeAuthFlow = null;
140
+ }
141
+ })();
142
+ return this.activeAuthFlow = { authUrl, callbackPort: server.port, completion }, this.activeAuthFlow;
143
+ }
144
+ /**
145
+ * Begin a sign-in whose OAuth callback lands on the *caller's* machine rather
146
+ * than on this process.
147
+ *
148
+ * The loopback flow assumes the browser and the token store share a host.
149
+ * That breaks for a daemon on a remote box: `http://localhost:1455` in the
150
+ * user's browser reaches their laptop, not the daemon. Here the daemon keeps
151
+ * the PKCE verifier, the caller runs its own callback server, and the caller
152
+ * posts the code back via `completeRelayAuthFlow`.
153
+ */
154
+ startRelayAuthFlow(redirectUri) {
155
+ assertLoopbackRedirect(redirectUri), this.pruneRelayFlows();
156
+ let codeVerifier = generateCodeVerifier(), state = generateState(), flowId = base64url(Buffer.from(crypto.getRandomValues(new Uint8Array(24)))), expiresAt = Date.now() + RELAY_FLOW_TTL_MS, params = new URLSearchParams({
157
+ client_id: CLIENT_ID,
158
+ redirect_uri: redirectUri,
159
+ response_type: "code",
160
+ code_challenge: generateCodeChallenge(codeVerifier),
161
+ code_challenge_method: "S256",
162
+ state,
163
+ scope: SCOPE,
164
+ id_token_add_organizations: "true",
165
+ codex_cli_simplified_flow: "true",
166
+ originator: "adf_studio"
167
+ });
168
+ return this.relayFlows.set(flowId, { codeVerifier, state, redirectUri, expiresAt }), { flowId, authUrl: `${AUTH_URL}?${params.toString()}`, state, expiresAt };
169
+ }
170
+ /** Finish a relay flow with the code the caller's callback server received. */
171
+ async completeRelayAuthFlow(flowId, code, state) {
172
+ this.pruneRelayFlows();
173
+ let flow = this.relayFlows.get(flowId);
174
+ if (!flow)
175
+ throw new Error("Unknown or expired auth flow \u2014 start sign-in again");
176
+ if (this.relayFlows.delete(flowId), state !== flow.state)
177
+ throw new Error("OAuth state mismatch \u2014 possible CSRF attack");
178
+ await this.exchangeCode(code, flow.codeVerifier, flow.redirectUri);
179
+ }
180
+ pruneRelayFlows() {
181
+ let now = Date.now();
182
+ for (let [id, flow] of this.relayFlows)
183
+ flow.expiresAt <= now && this.relayFlows.delete(id);
184
+ }
185
+ /** Trade an authorization code for tokens and persist them. */
186
+ async exchangeCode(code, codeVerifier, redirectUri) {
187
+ let tokenResponse = await fetch(TOKEN_URL, {
188
+ method: "POST",
189
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
190
+ body: new URLSearchParams({
191
+ grant_type: "authorization_code",
192
+ client_id: CLIENT_ID,
193
+ code,
194
+ redirect_uri: redirectUri,
195
+ code_verifier: codeVerifier
196
+ }).toString()
197
+ });
198
+ if (!tokenResponse.ok) {
199
+ let body = await tokenResponse.text();
200
+ throw new Error(`Token exchange failed (${tokenResponse.status}): ${body}`);
201
+ }
202
+ let tokenData = await tokenResponse.json();
203
+ tokenData.id_token && (this.email = decodeJwtPayload(tokenData.id_token).email);
204
+ let accountId = chatgptAccountIdFromJwt(tokenData.access_token) || chatgptAccountIdFromJwt(tokenData.id_token);
205
+ console.log(`[ChatGPT Auth] signed in: email=${this.email}, chatgpt_account_id=${accountId || "(missing)"}`), this.persist({
206
+ access_token: tokenData.access_token,
207
+ refresh_token: tokenData.refresh_token,
208
+ expires_at: Date.now() + tokenData.expires_in * 1e3,
209
+ account_id: accountId
210
+ }), noteSignIn(accountId);
211
+ }
212
+ async getValidAccessToken() {
213
+ let tokens = this.syncFromDisk();
214
+ if (!tokens)
215
+ throw new Error("Not authenticated \u2014 sign in first");
216
+ return Date.now() + REFRESH_BUFFER_MS < tokens.expires_at ? tokens.access_token : this.refreshPromise ? this.refreshPromise : (this.refreshPromise = this.refreshIfStillNeeded(tokens).finally(() => {
217
+ this.refreshPromise = null;
218
+ }), this.refreshPromise);
219
+ }
220
+ getAccountId() {
221
+ let tokens = this.syncFromDisk();
222
+ return chatgptAccountIdFromJwt(tokens?.access_token) || tokens?.account_id || void 0;
223
+ }
224
+ /**
225
+ * Re-check the file after winning the in-process refresh lock.
226
+ *
227
+ * OpenAI rotates the refresh token on every refresh, so if Studio refreshed
228
+ * while this call queued, our copy is already dead and spending it would both
229
+ * fail here and be pointless. Adopt the newer set instead.
230
+ */
231
+ async refreshIfStillNeeded(tokens) {
232
+ let fresh = this.syncFromDisk();
233
+ return fresh && Date.now() + REFRESH_BUFFER_MS < fresh.expires_at ? fresh.access_token : this.refreshTokens(fresh ?? tokens);
234
+ }
235
+ async refreshTokens(tokens) {
236
+ let data, rejected = !1;
237
+ try {
238
+ let response = await fetch(TOKEN_URL, {
239
+ method: "POST",
240
+ headers: { "Content-Type": "application/json" },
241
+ body: JSON.stringify({
242
+ client_id: CLIENT_ID,
243
+ grant_type: "refresh_token",
244
+ refresh_token: tokens.refresh_token
245
+ })
246
+ });
247
+ if (!response.ok)
248
+ throw rejected = response.status === 400 || response.status === 401, new Error(`Token refresh failed (${response.status})`);
249
+ data = await response.json();
250
+ } catch (err) {
251
+ let fresh = this.syncFromDisk();
252
+ if (fresh && fresh.refresh_token !== tokens.refresh_token && Date.now() + REFRESH_BUFFER_MS < fresh.expires_at)
253
+ return fresh.access_token;
254
+ throw rejected ? (clearTokens(), this.cachedTokens = null, this.email = void 0, new Error("Session expired \u2014 please sign in again")) : new Error(`Could not refresh the session (${err instanceof Error ? err.message : String(err)}) \u2014 still signed in, try again`);
255
+ }
256
+ if (data.id_token) {
257
+ let claims = decodeJwtPayload(data.id_token);
258
+ this.email = claims.email;
259
+ }
260
+ return this.persist({
261
+ access_token: data.access_token,
262
+ refresh_token: data.refresh_token,
263
+ expires_at: Date.now() + data.expires_in * 1e3,
264
+ account_id: chatgptAccountIdFromJwt(data.access_token) || chatgptAccountIdFromJwt(data.id_token) || tokens.account_id
265
+ }), data.access_token;
266
+ }
267
+ getAuthStatus() {
268
+ let tokens = this.syncFromDisk();
269
+ return tokens ? {
270
+ authenticated: !0,
271
+ email: this.email,
272
+ expiresAt: tokens.expires_at
273
+ } : { authenticated: !1 };
274
+ }
275
+ isAuthenticated() {
276
+ return this.syncFromDisk() !== null;
277
+ }
278
+ logout() {
279
+ clearTokens(), this.cachedTokens = null, this.email = void 0, this.refreshPromise = null, this.relayFlows.clear();
280
+ }
281
+ }, instance = null;
282
+ function getChatGptAuthManager() {
283
+ return instance || (instance = new ChatGptAuthManager()), instance;
284
+ }
285
+
286
+ export {
287
+ readTokens,
288
+ chatgptAccountIdFromJwt,
289
+ getChatGptAuthManager
290
+ };
@@ -7,7 +7,7 @@ const __dirname = __adfDirname(__filename);
7
7
  import {
8
8
  AGENT_DEFAULTS,
9
9
  DEFAULT_TOOLS
10
- } from "./chunk-CD3ATSXE.mjs";
10
+ } from "./chunk-NZO5O4VN.mjs";
11
11
 
12
12
  // src/shared/constants/adf-defaults.ts
13
13
  var ADF_VERSION = "0.2", DOCS_GUIDES_URL = "https://raw.githubusercontent.com/christianbalevski/adf/main/docs/guides", ADF_SKILLS_REGISTRY_URL = "https://raw.githubusercontent.com/christianbalevski/adf/main/skills/registry.json", PROVIDER_TYPES = [
@@ -16,7 +16,8 @@ var ADF_VERSION = "0.2", DOCS_GUIDES_URL = "https://raw.githubusercontent.com/ch
16
16
  { type: "openai-compatible", label: "OpenAI Compatible", placeholder: { apiKey: "Optional", model: "e.g. llama-3-8b" } },
17
17
  { type: "openrouter", label: "OpenRouter", placeholder: { apiKey: "sk-or-...", model: "e.g. anthropic/claude-sonnet-4" } },
18
18
  { type: "chatgpt-subscription", label: "ChatGPT Subscription", placeholder: { apiKey: "OAuth \u2014 click Sign In", model: "e.g. gpt-5.6-sol" } },
19
- { type: "grok-subscription", label: "Grok Subscription", placeholder: { apiKey: "OAuth \u2014 click Sign In", model: "e.g. grok-4.5" } }
19
+ { type: "grok-subscription", label: "Grok Subscription", placeholder: { apiKey: "OAuth \u2014 click Sign In", model: "e.g. grok-4.5" } },
20
+ { type: "claude-subscription", label: "Claude Subscription", placeholder: { apiKey: "Claude Code sign-in \u2014 click Sign In", model: "e.g. claude-sonnet-5-5" } }
20
21
  ], DEFAULT_AGENT_CONFIG = {
21
22
  adf_version: ADF_VERSION,
22
23
  name: "Untitled Agent",
@@ -28,7 +29,6 @@ var ADF_VERSION = "0.2", DOCS_GUIDES_URL = "https://raw.githubusercontent.com/ch
28
29
  provider: "",
29
30
  model_id: "",
30
31
  temperature: 0.7,
31
- max_tokens: 4096,
32
32
  vision: !1
33
33
  },
34
34
  instructions: "",
@@ -8,7 +8,7 @@ import {
8
8
  classifyRedirectTarget,
9
9
  parseBracedExpansion,
10
10
  unsupportedDevTargetMessage
11
- } from "./chunk-5W7KES6P.mjs";
11
+ } from "./chunk-UZPDETEU.mjs";
12
12
  import {
13
13
  resolveWithDefault
14
14
  } from "./chunk-ESP3VNMX.mjs";
@@ -21,7 +21,7 @@ import {
21
21
  getCommand,
22
22
  notifyToolCallObservers,
23
23
  shellReadFile
24
- } from "./chunk-HSBV6YFU.mjs";
24
+ } from "./chunk-YRMKSHW3.mjs";
25
25
 
26
26
  // src/main/tools/shell/executor/pipeline-executor.ts
27
27
  function vfsPath(p) {
@@ -147,7 +147,7 @@ async function executeCommand(cmd, stdin, ctx) {
147
147
  for (let r of redirects) {
148
148
  if (r.type === "in" && r.target !== void 0) {
149
149
  let [redirectContent, redirectErr] = await shellReadFile(ctx.toolRegistry, ctx.workspace, vfsPath(r.target));
150
- if (redirectErr)
150
+ if (redirectErr !== null)
151
151
  return err(`${name}: ${redirectErr}`);
152
152
  stdin = redirectContent;
153
153
  }