@theokit/agents 7.4.1 → 7.5.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.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 usetheo.dev
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/dist/auth.js CHANGED
@@ -1,19 +1,19 @@
1
- // src/auth/auth-provider.ts
2
1
  import {
3
- authFilePath,
4
- ensureFreshCredential,
5
- openaiDeviceLogin,
6
- persistOAuthTokens,
7
- readStoredOAuth
8
- } from "@theokit/sdk/auth";
2
+ __name
3
+ } from "./chunk-Z4QWC7IK.js";
4
+
5
+ // src/auth/auth-provider.ts
6
+ import { authFilePath, ensureFreshCredential, openaiDeviceLogin, persistOAuthTokens, readStoredOAuth } from "@theokit/sdk/auth";
9
7
  import { withFileLock } from "@theokit/sdk/persistence";
10
8
  var RefreshFailure = class extends Error {
9
+ static {
10
+ __name(this, "RefreshFailure");
11
+ }
12
+ transient;
11
13
  constructor(message, transient) {
12
- super(message);
13
- this.transient = transient;
14
+ super(message), this.transient = transient;
14
15
  this.name = "RefreshFailure";
15
16
  }
16
- transient;
17
17
  };
18
18
  var TRANSIENT_REASONS = [
19
19
  "ETIMEDOUT",
@@ -26,36 +26,39 @@ var TRANSIENT_REASONS = [
26
26
  function classifyRefreshFailure(err) {
27
27
  const text = err instanceof Error ? `${err.name}: ${err.message}` : String(err);
28
28
  if (/invalid_grant|invalid_request|unauthorized_client/i.test(text)) {
29
- return new RefreshFailure(
30
- "the refresh token is no longer valid \u2014 log in again. Retrying does not change the outcome.",
31
- false
32
- );
29
+ return new RefreshFailure("the refresh token is no longer valid \u2014 log in again. Retrying does not change the outcome.", false);
33
30
  }
34
31
  const transient = TRANSIENT_REASONS.some((m) => text.includes(m)) || /\b(5\d{2})\b|timeout|network/i.test(text);
35
- return new RefreshFailure(
36
- transient ? "transient failure refreshing the credential" : "failure refreshing the credential",
37
- transient
38
- );
32
+ return new RefreshFailure(transient ? "transient failure refreshing the credential" : "failure refreshing the credential", transient);
39
33
  }
34
+ __name(classifyRefreshFailure, "classifyRefreshFailure");
40
35
  function waitWithJitter(attempt, baseMs = 200, random = Math.random) {
41
36
  const base = baseMs * 2 ** attempt;
42
37
  return Math.round(base * (0.75 + random() * 0.5));
43
38
  }
39
+ __name(waitWithJitter, "waitWithJitter");
44
40
  var AuthProvider = class _AuthProvider {
41
+ static {
42
+ __name(this, "AuthProvider");
43
+ }
44
+ config;
45
+ store;
45
46
  constructor(config, store) {
46
47
  this.config = config;
47
48
  this.store = store;
48
49
  }
49
- config;
50
- store;
51
50
  /**
52
- * Refresh a resolved credential if stale. Delegates to `ensureFreshCredential` with the held
53
- * `config` + `store`; `env` (for reading the store's env overrides) + the `{ fetch, now }` HTTP deps
54
- * thread through. Returns the fresh `ResolvedCredential` — never logs the rotated token.
55
- */
51
+ * Refresh a resolved credential if stale. Delegates to `ensureFreshCredential` with the held
52
+ * `config` + `store`; `env` (for reading the store's env overrides) + the `{ fetch, now }` HTTP deps
53
+ * thread through. Returns the fresh `ResolvedCredential` — never logs the rotated token.
54
+ */
56
55
  async ensureFresh(resolved, deps, env) {
57
56
  if (resolved.kind !== "oauth") {
58
- return ensureFreshCredential(resolved, { config: this.config, store: this.store, env }, deps);
57
+ return ensureFreshCredential(resolved, {
58
+ config: this.config,
59
+ store: this.store,
60
+ env
61
+ }, deps);
59
62
  }
60
63
  const filePath = authFilePath(this.store, env);
61
64
  const inFlight = _AuthProvider.refreshInFlight.get(filePath);
@@ -71,25 +74,29 @@ var AuthProvider = class _AuthProvider {
71
74
  /** In-flight refresh per store path — the key is the file, not the instance. */
72
75
  static refreshInFlight = /* @__PURE__ */ new Map();
73
76
  /**
74
- * The refresh itself, serialized across PROCESSES and with a re-read.
75
- *
76
- * The re-read is not a detail: without it the lock merely serializes, and the second process
77
- * decides using the state it read BEFORE waiting — refreshing again and invalidating the token the
78
- * first one just wrote. It is classic double-checked locking, and it is what the two-process test
79
- * catches.
80
- */
77
+ * The refresh itself, serialized across PROCESSES and with a re-read.
78
+ *
79
+ * The re-read is not a detail: without it the lock merely serializes, and the second process
80
+ * decides using the state it read BEFORE waiting — refreshing again and invalidating the token the
81
+ * first one just wrote. It is classic double-checked locking, and it is what the two-process test
82
+ * catches.
83
+ */
81
84
  refreshUnderLock(filePath, resolved, deps, env) {
82
85
  return withFileLock(filePath, async () => {
83
86
  const doDisco = readStoredOAuth(this.store, env);
84
- const current = doDisco !== void 0 ? { ...resolved, apiKey: doDisco.access, expiresAt: doDisco.expires } : resolved;
87
+ const current = doDisco !== void 0 ? {
88
+ ...resolved,
89
+ apiKey: doDisco.access,
90
+ expiresAt: doDisco.expires
91
+ } : resolved;
85
92
  const MAX_ATTEMPTS = 3;
86
93
  for (let attempt = 0; ; attempt++) {
87
94
  try {
88
- return await ensureFreshCredential(
89
- current,
90
- { config: this.config, store: this.store, env },
91
- deps
92
- );
95
+ return await ensureFreshCredential(current, {
96
+ config: this.config,
97
+ store: this.store,
98
+ env
99
+ }, deps);
93
100
  } catch (err) {
94
101
  const failure = classifyRefreshFailure(err);
95
102
  if (!failure.transient || attempt >= MAX_ATTEMPTS - 1) throw failure;
@@ -99,43 +106,26 @@ var AuthProvider = class _AuthProvider {
99
106
  });
100
107
  }
101
108
  /**
102
- * Run the headless OpenAI device-login flow. Delegates to `openaiDeviceLogin` (which JWT-extracts the
103
- * account id). `deviceConfig` is passed per-call because it is a distinct endpoint set from the
104
- * refresh `config`. Returns `OAuthTokens` — the caller persists them via {@link AuthProvider.persist}.
105
- */
109
+ * Run the headless OpenAI device-login flow. Delegates to `openaiDeviceLogin` (which JWT-extracts the
110
+ * account id). `deviceConfig` is passed per-call because it is a distinct endpoint set from the
111
+ * refresh `config`. Returns `OAuthTokens` — the caller persists them via {@link AuthProvider.persist}.
112
+ */
106
113
  deviceLogin(deviceConfig, deps, hooks) {
107
114
  return openaiDeviceLogin(deviceConfig, deps, hooks);
108
115
  }
109
116
  /**
110
- * Persist freshly-obtained tokens through the held `store`. Delegates to `persistOAuthTokens` and
111
- * returns the credential-file path (never the token). `env` selects the store's home override.
112
- */
117
+ * Persist freshly-obtained tokens through the held `store`. Delegates to `persistOAuthTokens` and
118
+ * returns the credential-file path (never the token). `env` selects the store's home override.
119
+ */
113
120
  persist(provider, tokens, env) {
114
121
  return persistOAuthTokens(provider, tokens, this.store, env);
115
122
  }
116
123
  };
117
124
 
118
125
  // src/auth-entry.ts
119
- import {
120
- authFilePath as authFilePath2,
121
- CredentialError,
122
- credentialHome,
123
- readAuthFile,
124
- readStoredOAuth as readStoredOAuth2,
125
- writeCredential
126
- } from "@theokit/sdk/auth";
127
- import {
128
- deviceLogin,
129
- openaiDeviceLogin as openaiDeviceLogin3,
130
- pollDeviceToken,
131
- requestDeviceCode
132
- } from "@theokit/sdk/auth";
133
- import {
134
- ensureFreshCredential as ensureFreshCredential2,
135
- extractAccountId,
136
- persistOAuthTokens as persistOAuthTokens2,
137
- refreshOAuthTokens
138
- } from "@theokit/sdk/auth";
126
+ import { authFilePath as authFilePath2, CredentialError, credentialHome, readAuthFile, readStoredOAuth as readStoredOAuth2, writeCredential } from "@theokit/sdk/auth";
127
+ import { deviceLogin, openaiDeviceLogin as openaiDeviceLogin3, pollDeviceToken, requestDeviceCode } from "@theokit/sdk/auth";
128
+ import { ensureFreshCredential as ensureFreshCredential2, extractAccountId, persistOAuthTokens as persistOAuthTokens2, refreshOAuthTokens } from "@theokit/sdk/auth";
139
129
 
140
130
  // src/auth/device-provider.ts
141
131
  import { openaiDeviceLogin as openaiDeviceLogin2 } from "@theokit/sdk/auth";
@@ -147,7 +137,12 @@ var CODEX_OAUTH = {
147
137
  clientId: process.env[CODEX_CLIENT_ID_ENV_VAR] ?? CODEX_CLIENT_ID,
148
138
  authorizeEndpoint: `${CODEX_ISSUER}/oauth/authorize`,
149
139
  tokenEndpoint: `${CODEX_ISSUER}/oauth/token`,
150
- scopes: ["openid", "profile", "email", "offline_access"],
140
+ scopes: [
141
+ "openid",
142
+ "profile",
143
+ "email",
144
+ "offline_access"
145
+ ],
151
146
  redirectUri: `${CODEX_ISSUER}/deviceauth/callback`
152
147
  };
153
148
  var CODEX_DEVICE = {
@@ -165,7 +160,7 @@ var CODEX_PROVIDER = Object.freeze({
165
160
  type: "oauth",
166
161
  // Points at OpenAI's variant. An RFC 8628 provider would point at `deviceLogin`, and that is
167
162
  // how the two shapes coexist with no discriminant.
168
- authorize: (deps, hooks) => openaiDeviceLogin2(CODEX_DEVICE, deps, hooks)
163
+ authorize: /* @__PURE__ */ __name((deps, hooks) => openaiDeviceLogin2(CODEX_DEVICE, deps, hooks), "authorize")
169
164
  }),
170
165
  Object.freeze({
171
166
  label: "Manually enter API Key",
@@ -180,24 +175,27 @@ function comDefaults(deps) {
180
175
  now: deps?.now ?? Date.now
181
176
  };
182
177
  }
178
+ __name(comDefaults, "comDefaults");
183
179
  async function loginWithDevice(provider, method, store, hooks, opts = {}) {
184
180
  if (provider.methods.length === 0) {
185
- throw new TypeError(
186
- `provider "${provider.name}" declares no authentication method \u2014 there is nothing to choose`
187
- );
181
+ throw new TypeError(`provider "${provider.name}" declares no authentication method \u2014 there is nothing to choose`);
188
182
  }
189
183
  if (!provider.methods.includes(method)) {
190
184
  throw new TypeError(`method "${method.label}" does not belong to provider "${provider.name}"`);
191
185
  }
192
186
  if (method.type !== "oauth") {
193
- throw new TypeError(
194
- `method "${method.label}" is an api-key method, not a device method \u2014 use the api-key path`
195
- );
187
+ throw new TypeError(`method "${method.label}" is an api-key method, not a device method \u2014 use the api-key path`);
196
188
  }
197
189
  const tokens = await method.authorize(comDefaults(opts.deps), hooks);
198
190
  const path = new AuthProvider(provider.oauth, store).persist(provider.name, tokens, opts.env);
199
- return tokens.accountId === void 0 ? { path } : { path, accountId: tokens.accountId };
191
+ return tokens.accountId === void 0 ? {
192
+ path
193
+ } : {
194
+ path,
195
+ accountId: tokens.accountId
196
+ };
200
197
  }
198
+ __name(loginWithDevice, "loginWithDevice");
201
199
  export {
202
200
  AuthProvider,
203
201
  CODEX_CLIENT_ID_ENV_VAR,
package/dist/auth.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/auth/auth-provider.ts","../src/auth-entry.ts","../src/auth/device-provider.ts"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAQP,SAAS,oBAAoB;AAkCtB,IAAM,iBAAN,cAA6B,MAAM;AAAA,EACxC,YACE,SAES,WACT;AACA,UAAM,OAAO;AAFJ;AAGT,SAAK,OAAO;AAAA,EACd;AAAA,EAJW;AAKb;AAMA,IAAM,oBAAoB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAGO,SAAS,uBAAuB,KAA8B;AACnE,QAAM,OAAO,eAAe,QAAQ,GAAG,IAAI,IAAI,KAAK,IAAI,OAAO,KAAK,OAAO,GAAG;AAC9E,MAAI,qDAAqD,KAAK,IAAI,GAAG;AACnE,WAAO,IAAI;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,QAAM,YACJ,kBAAkB,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,KAAK,gCAAgC,KAAK,IAAI;AAC9F,SAAO,IAAI;AAAA,IACT,YAAY,gDAAgD;AAAA,IAC5D;AAAA,EACF;AACF;AAGO,SAAS,eAAe,SAAiB,SAAS,KAAK,SAAS,KAAK,QAAgB;AAC1F,QAAM,OAAO,SAAS,KAAK;AAC3B,SAAO,KAAK,MAAM,QAAQ,OAAO,OAAO,IAAI,IAAI;AAClD;AAEO,IAAM,eAAN,MAAM,cAAa;AAAA,EACxB,YACmB,QACA,OACjB;AAFiB;AACA;AAAA,EAChB;AAAA,EAFgB;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQnB,MAAM,YACJ,UACA,MACA,KAC6B;AAC7B,QAAI,SAAS,SAAS,SAAS;AAI7B,aAAO,sBA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C;AACH,CAAC;AAeD,SAAS,YAAY,MAAwC;AAC3D,SAAO;AAAA,IACL,OAAO,MAAM,SAAS;AAAA,IACtB,OAAO,MAAM,UAAU,CAAC,OAAe,IAAI,QAAc,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AAAA,IAC7F,KAAK,MAAM,OAAO,KAAK;AAAA,EACzB;AACF;AAeA,eAAsB,gBACpB,UACA,QACA,OACA,OACA,OAA+B,CAAC,GACe;AAI/C,MAAI,SAAS,QAAQ,WAAW,GAAG;AACjC,UAAM,IAAI;AAAA,MACR,aAAa,SAAS,IAAI;AAAA,IAC5B;AAAA,EACF;AACA,MAAI,CAAC,SAAS,QAAQ,SAAS,MAAM,GAAG;AACtC,UAAM,IAAI,UAAU,WAAW,OAAO,KAAK,kCAAkC,SAAS,IAAI,GAAG;AAAA,EAC/F;AACA,MAAI,OAAO,SAAS,SAAS;AAC3B,UAAM,IAAI;AAAA,MACR,WAAW,OAAO,KAAK;AAAA,IACzB;AAAA,EACF;AAEA,QAAM,SAAS,MAAM,OAAO,UAAU,YAAY,KAAK,IAAI,GAAG,KAAK;AACnE,QAAM,OAAO,IAAI,aAAa,SAAS,OAAO,KAAK,EAAE,QAAQ,SAAS,MAAM,QAAQ,KAAK,GAAG;AAE5F,SAAO,OAAO,cAAc,SAAY,EAAE,KAAK,IAAI,EAAE,MAAM,WAAW,OAAO,UAAU;AACzF;","names":["authFilePath","readStoredOAuth","openaiDeviceLogin","ensureFreshCredential","persistOAuthTokens","openaiDeviceLogin","openaiDeviceLogin"]}
1
+ {"version":3,"sources":["../src/auth/auth-provider.ts","../src/auth-entry.ts","../src/auth/device-provider.ts"],"mappings":";;;;;AAAA,SACEA,cACAC,uBACAC,mBACAC,oBACAC,uBACK;AAQP,SAASC,oBAAoB;AAkCtB,IAAMC,iBAAN,cAA6BC,MAAAA;EAhDpC,OAgDoCA;;;;EAClC,YACEC,SAESC,WACT;AACA,UAAMD,OAAAA,GAAAA,KAFGC,YAAAA;AAGT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B,UACR,WAAWJ,OAAOhB,KAAK,yEAAoE;EAE/F;AAEA,QAAMsB,SAAS,MAAMN,OAAOd,UAAUI,YAAYY,KAAKf,IAAI,GAAGC,KAAAA;AAC9D,QAAMmB,OAAO,IAAIC,aAAa1C,SAASgB,OAAOmB,KAAAA,EAAOQ,QAAQ3C,SAASe,MAAMyB,QAAQJ,KAAKjC,GAAG;AAE5F,SAAOqC,OAAOI,cAAcC,SAAY;IAAEJ;EAAK,IAAI;IAAEA;IAAMG,WAAWJ,OAAOI;EAAU;AACzF;AA5BsBX;","names":["authFilePath","ensureFreshCredential","openaiDeviceLogin","persistOAuthTokens","readStoredOAuth","withFileLock","RefreshFailure","Error","message","transient","name","TRANSIENT_REASONS","classifyRefreshFailure","err","text","String","test","some","m","includes","waitWithJitter","attempt","baseMs","random","Math","base","round","AuthProvider","config","store","ensureFresh","resolved","deps","env","kind","ensureFreshCredential","filePath","authFilePath","inFlight","refreshInFlight","get","undefined","promise","refreshUnderLock","set","delete","Map","withFileLock","doDisco","readStoredOAuth","current","apiKey","access","expiresAt","expires","MAX_ATTEMPTS","failure","Promise","resolve","setTimeout","deviceLogin","deviceConfig","hooks","openaiDeviceLogin","persist","provider","tokens","persistOAuthTokens","authFilePath","CredentialError","credentialHome","readAuthFile","readStoredOAuth","writeCredential","deviceLogin","openaiDeviceLogin","pollDeviceToken","requestDeviceCode","ensureFreshCredential","extractAccountId","persistOAuthTokens","refreshOAuthTokens","openaiDeviceLogin","CODEX_CLIENT_ID","CODEX_ISSUER","CODEX_CLIENT_ID_ENV_VAR","CODEX_OAUTH","provider","clientId","process","env","authorizeEndpoint","tokenEndpoint","scopes","redirectUri","CODEX_DEVICE","deviceUsercodeEndpoint","devicePollEndpoint","verificationUri","CODEX_PROVIDER","Object","freeze","name","oauth","methods","label","type","authorize","deps","hooks","openaiDeviceLogin","comDefaults","fetch","sleep","ms","Promise","resolve","setTimeout","now","Date","loginWithDevice","method","store","opts","length","TypeError","includes","tokens","path","AuthProvider","persist","accountId","undefined"]}
package/dist/bridge.js CHANGED
@@ -47,7 +47,8 @@ import {
47
47
  streamAgentUIMessages,
48
48
  toAgentFactory,
49
49
  translateSdkEvent
50
- } from "./chunk-PHUNONZT.js";
50
+ } from "./chunk-WKBZZQBO.js";
51
+ import "./chunk-Z4QWC7IK.js";
51
52
  export {
52
53
  AGENT_BRAND,
53
54
  AgentBuilder,